Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import AboutModalContainer from './AboutModalContainer';
import { canUseDOM } from 'exenv';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Backdrop/backdrop.css';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import AboutModal from './AboutModal';
import ReactDOM from 'react-dom';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';

jest.spyOn(ReactDOM, 'createPortal');
jest.spyOn(document, 'createElement');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import styles from '@patternfly/patternfly/components/Alert/alert.css';
import accessibleStyles from '@patternfly/patternfly/utilities/Accessibility/accessibility.css';
import AlertIcon from './AlertIcon';
import { capitalize } from '../../internal/util';
import { capitalize } from '../../helpers/util';
import AlertActionCloseButton from './AlertActionCloseButton';
import AlertActionLink from './AlertActionLink';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styles from '@patternfly/patternfly/components/Breadcrumb/breadcrumb.css';
import PropTypes from 'prop-types';
import { css } from '@patternfly/react-styles';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
/** Content rendered inside the breadcrumb title. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from '@patternfly/patternfly/components/Breadcrumb/breadcrumb.css'
import PropTypes from 'prop-types';
import { AngleRightIcon } from '@patternfly/react-icons';
import { css, getModifier } from '@patternfly/react-styles';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
/** Content rendered inside the breadcrumb item. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { css, getModifier } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';
import styles from '@patternfly/patternfly/components/Button/button.css';

export const ButtonVariant = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Card/card.css';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
/** content rendered inside the Card */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Card/card.css';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
/** content rendered inside the Card Body */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Card/card.css';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
/** content rendered inside the Card Footer */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Card/card.css';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';

const propTypes = {
children: PropTypes.any,
Expand Down
78 changes: 39 additions & 39 deletions packages/patternfly-4/react-core/src/components/Chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import ChipButton from './ChipButton';
import { Tooltip, TooltipPosition } from '../Tooltip';
import { TimesCircleIcon } from '@patternfly/react-icons';
import styles from '@patternfly/patternfly/components/Chip/chip.css';
import GenerateId from '../../internal/GenerateId/GenerateId';
import GenerateId from '../../helpers/GenerateId/GenerateId';

class Chip extends React.Component {
span = React.createRef();
state = { isTooltipVisible: false };

componentDidMount() {
this.setState({ isTooltipVisible: this.span.current && this.span.current.offsetWidth < this.span.current.scrollWidth });
this.setState({
isTooltipVisible: this.span.current && this.span.current.offsetWidth < this.span.current.scrollWidth
});
}

renderOverflowChip = () => {
Expand All @@ -23,58 +26,55 @@ class Chip extends React.Component {
</ChipButton>
</div>
);
}
};

renderChip = (randomId) => {
const {
children,
closeBtnAriaLabel,
tooltipPosition,
className,
onClick,
} = this.props;
renderChip = randomId => {
const { children, closeBtnAriaLabel, tooltipPosition, className, onClick } = this.props;
if (this.state.isTooltipVisible) {
return (
<Tooltip position={tooltipPosition} content={children}>
<div className={css(styles.chip, className)}>
<span ref={this.span} className={css(styles.chipText)} id={randomId}>
{children}
</span>
<ChipButton onClick={onClick} ariaLabel={closeBtnAriaLabel} id={`remove_${randomId}`} aria-labelledby={`remove_${randomId} ${randomId}`}>
<ChipButton
onClick={onClick}
ariaLabel={closeBtnAriaLabel}
id={`remove_${randomId}`}
aria-labelledby={`remove_${randomId} ${randomId}`}
>
<TimesCircleIcon aria-hidden="true" />
</ChipButton>
</div>
</Tooltip>
)
} else {
return (
<div className={css(styles.chip, className)}>
<span ref={this.span} className={css(styles.chipText)} id={randomId}>
{children}
</span>
<ChipButton onClick={onClick} ariaLabel={closeBtnAriaLabel} id={`remove_${randomId}`} aria-labelledby={`remove_${randomId} ${randomId}`}>
<TimesCircleIcon aria-hidden="true" />
</ChipButton>
</div>
)
);
}
}
return (
<div className={css(styles.chip, className)}>
<span ref={this.span} className={css(styles.chipText)} id={randomId}>
{children}
</span>
<ChipButton
onClick={onClick}
ariaLabel={closeBtnAriaLabel}
id={`remove_${randomId}`}
aria-labelledby={`remove_${randomId} ${randomId}`}
>
<TimesCircleIcon aria-hidden="true" />
</ChipButton>
</div>
);
};

render() {
const {
isOverflowChip,
} = this.props;
const { isOverflowChip } = this.props;
return (
<GenerateId>
{(randomId) =>
(
<React.Fragment>
{isOverflowChip ? this.renderOverflowChip() : this.renderChip(randomId)}
</React.Fragment>
)
}
{randomId => (
<React.Fragment>{isOverflowChip ? this.renderOverflowChip() : this.renderChip(randomId)}</React.Fragment>
)}
</GenerateId>
)
);
}
}
Chip.propTypes = {
Expand All @@ -86,20 +86,20 @@ Chip.propTypes = {
id: PropTypes.string,
/** Additional classes added to the chip item */
className: PropTypes.string,
/** Flag indicating if the chip has overflow*/
/** Flag indicating if the chip has overflow */
isOverflowChip: PropTypes.bool,
/** Position of the tooltip which is displayed if text is longer */
tooltipPosition: PropTypes.oneOf(Object.values(TooltipPosition)),
/** Function that is called when clicking on the chip button */
onClick: PropTypes.func,
onClick: PropTypes.func
};

Chip.defaultProps = {
id: undefined,
closeBtnAriaLabel: 'close',
className: '',
tooltipPosition: 'top',
isOverflowChip: false,
isOverflowChip: false
};

export default Chip;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import styles from '@patternfly/patternfly/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';
import { DropdownContext } from './dropdownConstants';

const propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styles from '@patternfly/patternfly/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';
import { DropdownPosition, DropdownContext, DropdownArrowContext } from './dropdownConstants';
import ReactDOM from 'react-dom';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import DropdownItem from './DropdownItem';
import styles from '@patternfly/patternfly/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';
import { DropdownArrowContext } from './dropdownConstants';

const Item = ({ className, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DropdownItem from './DropdownItem';
import PropTypes from 'prop-types';
import styles from '@patternfly/patternfly/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';
import { componentShape } from '../../internal/componentShape';
import { componentShape } from '../../helpers/componentShape';
import { DropdownArrowContext } from './dropdownConstants';

const Separator = ({ className, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import styles from '@patternfly/patternfly/components/Dropdown/dropdown.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';

const propTypes = {
/** HTML ID of dropdown toggle */
Expand Down Expand Up @@ -64,7 +64,12 @@ class DropdownToggle extends Component {
onEscPress = event => {
const { parentRef } = this.props;
const keyCode = event.keyCode || event.which;
if (this.props.isOpen && (keyCode === KEY_CODES.ESCAPE_KEY || event.key === 'Tab') && parentRef && parentRef.contains(event.target)) {
if (
this.props.isOpen &&
(keyCode === KEY_CODES.ESCAPE_KEY || event.key === 'Tab') &&
parentRef &&
parentRef.contains(event.target)
) {
this.props.onToggle && this.props.onToggle(false);
this.toggle.focus();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from '@patternfly/patternfly/components/Form/form.css';
import { ASTERISK } from '../../internal/htmlConstants';
import { ASTERISK } from '../../helpers/htmlConstants';
import { FormContext } from '../Form/FormContext';
import { css, getModifier } from '@patternfly/react-styles';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import ModalContent from './ModalContent';
import safeHTMLElement from '../../internal/safeHTMLElement';
import safeHTMLElement from '../../helpers/safeHTMLElement';
import { canUseDOM } from 'exenv';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Backdrop/backdrop.css';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Modal from './Modal';
import React from 'react';
import ReactDOM from 'react-dom';
import { shallow } from 'enzyme';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';

jest.spyOn(ReactDOM, 'createPortal');
jest.spyOn(document, 'createElement');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import NavToggle from './NavToggle';
import { AngleRightIcon } from '@patternfly/react-icons';
import { NavContext } from './Nav';
import { getUniqueId } from '../../internal/util';
import { getUniqueId } from '../../helpers/util';

const propTypes = {
/** Title shown for the expandable list */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styles from '@patternfly/patternfly/components/Nav/nav.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { getUniqueId } from '../../internal/util';
import { getUniqueId } from '../../helpers/util';

const propTypes = {
/** Title shown for the group */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from '@patternfly/patternfly/components/Page/page.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { global_breakpoint_md as globalBreakpointMd } from '@patternfly/react-tokens';
import { debounce } from '../../internal/util';
import { debounce } from '../../helpers/util';

export const PageLayouts = {
vertical: 'vertical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import Tippy from '@tippy.js/react';
import FocusTrap from 'focus-trap-react';
import { KEY_CODES } from '../../internal/constants';
import { KEY_CODES } from '../../helpers/constants';
import styles from '@patternfly/patternfly/components/Popover/popover.css';
import { css, getModifier } from '@patternfly/react-styles';
import PopoverArrow from './PopoverArrow';
Expand All @@ -11,7 +11,7 @@ import PopoverBody from './PopoverBody';
import PopoverHeader from './PopoverHeader';
import PopoverFooter from './PopoverFooter';
import PopoverCloseButton from './PopoverCloseButton';
import GenerateId from '../../internal/GenerateId/GenerateId';
import GenerateId from '../../helpers/GenerateId/GenerateId';
import { c_popover_MaxWidth as popoverMaxWidth } from '@patternfly/react-tokens';
import { tippyStyles } from '../Tooltip/styles';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import PopoverContent from './PopoverContent';
import PopoverBody from './PopoverBody';
import PopoverHeader from './PopoverHeader';
import PopoverCloseButton from './PopoverCloseButton';
import GenerateId from '../../internal/GenerateId/GenerateId';
import GenerateId from '../../helpers/GenerateId/GenerateId';
import { Instance, BasicPlacement } from 'tippy.js';

// Need to unset tippy default styles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from '@patternfly/patternfly/components/Progress/progress.css';
import { css, getModifier } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import ProgressContainer, { ProgressMeasureLocation, ProgressVariant } from './ProgressContainer';
import { getUniqueId } from '../../internal/util';
import { getUniqueId } from '../../helpers/util';

export const ProgressSize = {
sm: 'sm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styles from '@patternfly/patternfly/components/Switch/switch.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { getUniqueId } from '../../internal/util';
import { getUniqueId } from '../../helpers/util';

const propTypes = {
/** id for the label. */
Expand Down
4 changes: 2 additions & 2 deletions packages/patternfly-4/react-core/src/components/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styles from '@patternfly/patternfly/components/Tabs/tabs.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';
import { AngleLeftIcon, AngleRightIcon } from '@patternfly/react-icons';
import { getUniqueId, isElementInView, sideElementIsOutOfView } from '../../internal/util';
import { SIDE } from '../../internal/constants';
import { getUniqueId, isElementInView, sideElementIsOutOfView } from '../../helpers/util';
import { SIDE } from '../../helpers/constants';

const propTypes = {
/** content rendered inside the Tabs Component. */
Expand Down
Loading