import * as React from 'react'; import { css } from '@patternfly/react-styles'; import { Button } from '../Button'; import { Tooltip, TooltipPosition } from '../Tooltip'; import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon'; import styles from '@patternfly/react-styles/css/components/Chip/chip'; import { GenerateId } from '../../helpers/GenerateId/GenerateId'; import { getOUIAProps, OUIAProps, getDefaultOUIAId } from '../../helpers'; export interface ChipProps extends React.HTMLProps, OUIAProps { /** Badge to add to the chip. The badge will be rendered after the chip text. */ badge?: React.ReactNode; /** Content rendered inside the chip text */ children?: React.ReactNode; /** Aria Label for close button */ closeBtnAriaLabel?: string; /** Additional classes added to the chip item */ className?: string; /** Flag indicating if the chip is an overflow chip */ isOverflowChip?: boolean; /** Flag indicating if chip is read only */ isReadOnly?: boolean; /** Function that is called when clicking on the chip close button */ onClick?: (event: React.MouseEvent) => void; /** Component that will be used for chip. It is recommended that )} ); } renderChip = (randomId: string) => { const { children, tooltipPosition } = this.props; if (this.state.isTooltipVisible) { return ( {this.renderInnerChip(randomId)} ); } return this.renderInnerChip(randomId); }; render() { const { isOverflowChip } = this.props; return ( {(randomId) => (isOverflowChip ? this.renderOverflowChip() : this.renderChip((this.props.id || randomId) as string))} ); } } export { Chip };