@patternfly/react-core 6.0.0-alpha.32 → 6.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/Chip/package.json +1 -0
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/Modal/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +2 -2
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/esm/components/Label/Label.d.ts.map +1 -1
- package/dist/esm/components/Label/Label.js +8 -1
- package/dist/esm/components/Label/Label.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js +4 -4
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Menu/MenuItem.js +1 -1
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/Menu/MenuItemAction.js +1 -1
- package/dist/esm/components/Menu/MenuItemAction.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarFilter.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarFilter.js +2 -3
- package/dist/esm/components/Toolbar/ToolbarFilter.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.js +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +0 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/{components → deprecated/components}/Chip/Chip.d.ts +6 -18
- package/dist/esm/deprecated/components/Chip/Chip.d.ts.map +1 -0
- package/dist/esm/deprecated/components/Chip/Chip.js +35 -0
- package/dist/esm/deprecated/components/Chip/Chip.js.map +1 -0
- package/dist/esm/{components → deprecated/components}/Chip/ChipGroup.d.ts +7 -14
- package/dist/esm/deprecated/components/Chip/ChipGroup.d.ts.map +1 -0
- package/dist/esm/deprecated/components/Chip/ChipGroup.js +29 -0
- package/dist/esm/deprecated/components/Chip/ChipGroup.js.map +1 -0
- package/dist/esm/deprecated/components/Chip/index.d.ts.map +1 -0
- package/dist/esm/deprecated/components/Chip/index.js.map +1 -0
- package/dist/esm/deprecated/components/Select/Select.d.ts +1 -1
- package/dist/esm/deprecated/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/deprecated/components/Select/Select.js +2 -2
- package/dist/esm/deprecated/components/Select/Select.js.map +1 -1
- package/dist/esm/deprecated/components/index.d.ts +1 -0
- package/dist/esm/deprecated/components/index.d.ts.map +1 -1
- package/dist/esm/deprecated/components/index.js +1 -0
- package/dist/esm/deprecated/components/index.js.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +2 -2
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/Label/Label.d.ts.map +1 -1
- package/dist/js/components/Label/Label.js +8 -1
- package/dist/js/components/Label/Label.js.map +1 -1
- package/dist/js/components/Menu/Menu.js +4 -4
- package/dist/js/components/Menu/Menu.js.map +1 -1
- package/dist/js/components/Menu/MenuItem.js +1 -1
- package/dist/js/components/Menu/MenuItem.js.map +1 -1
- package/dist/js/components/Menu/MenuItemAction.js +1 -1
- package/dist/js/components/Menu/MenuItemAction.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarFilter.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarFilter.js +2 -3
- package/dist/js/components/Toolbar/ToolbarFilter.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.js +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/js/components/index.d.ts +0 -1
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +0 -1
- package/dist/js/components/index.js.map +1 -1
- package/dist/js/{components → deprecated/components}/Chip/Chip.d.ts +6 -18
- package/dist/js/deprecated/components/Chip/Chip.d.ts.map +1 -0
- package/dist/js/deprecated/components/Chip/Chip.js +38 -0
- package/dist/js/deprecated/components/Chip/Chip.js.map +1 -0
- package/dist/js/{components → deprecated/components}/Chip/ChipGroup.d.ts +7 -14
- package/dist/js/deprecated/components/Chip/ChipGroup.d.ts.map +1 -0
- package/dist/js/deprecated/components/Chip/ChipGroup.js +32 -0
- package/dist/js/deprecated/components/Chip/ChipGroup.js.map +1 -0
- package/dist/js/deprecated/components/Chip/index.d.ts.map +1 -0
- package/dist/js/deprecated/components/Chip/index.js.map +1 -0
- package/dist/js/deprecated/components/Select/Select.d.ts +1 -1
- package/dist/js/deprecated/components/Select/Select.d.ts.map +1 -1
- package/dist/js/deprecated/components/Select/Select.js +2 -2
- package/dist/js/deprecated/components/Select/Select.js.map +1 -1
- package/dist/js/deprecated/components/index.d.ts +1 -0
- package/dist/js/deprecated/components/index.d.ts.map +1 -1
- package/dist/js/deprecated/components/index.js +1 -0
- package/dist/js/deprecated/components/index.js.map +1 -1
- package/dist/styles/base-no-reset.css +26 -15
- package/dist/styles/base.css +26 -15
- package/dist/umd/react-core.min.js +2 -2
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/CalendarMonth/CalendarMonth.tsx +2 -2
- package/src/components/Divider/examples/Divider.md +11 -3
- package/src/components/Divider/examples/{DividerVerticalFlexInsetMedium.tsx → DividerVerticalFlexInsetSmall.tsx} +2 -2
- package/src/components/Label/Label.tsx +8 -1
- package/src/components/Menu/Menu.tsx +2 -2
- package/src/components/Menu/MenuItem.tsx +1 -1
- package/src/components/Menu/MenuItemAction.tsx +1 -1
- package/src/components/Menu/__tests__/Menu.test.tsx +0 -11
- package/src/components/MenuToggle/MenuToggle.tsx +1 -1
- package/src/components/Select/examples/SelectMultiTypeahead.tsx +8 -7
- package/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx +8 -7
- package/src/components/TextInputGroup/examples/TextInputGroupFilters.tsx +12 -6
- package/src/components/Toolbar/ToolbarFilter.tsx +7 -8
- package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +29 -44
- package/src/components/TreeView/TreeViewListItem.tsx +1 -1
- package/src/components/TreeView/__tests__/TreeViewListItem.test.tsx +6 -6
- package/src/components/index.ts +0 -1
- package/src/demos/examples/TextInputGroup/AttributeValueFiltering.tsx +7 -7
- package/src/demos/examples/TextInputGroup/AutoCompleteSearch.tsx +7 -7
- package/src/deprecated/components/Chip/Chip.tsx +104 -0
- package/src/deprecated/components/Chip/ChipGroup.tsx +111 -0
- package/src/{components → deprecated/components}/Chip/__tests__/Chip.test.tsx +25 -60
- package/src/{components → deprecated/components}/Chip/__tests__/ChipGroup.test.tsx +11 -28
- package/src/{components → deprecated/components}/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +11 -12
- package/src/{components → deprecated/components}/Chip/__tests__/__snapshots__/ChipGroup.test.tsx.snap +6 -8
- package/src/{components → deprecated/components}/Chip/examples/Chip.md +6 -0
- package/src/{components → deprecated/components}/Chip/examples/ChipDefault.tsx +2 -1
- package/src/{components → deprecated/components}/Chip/examples/ChipGroupInline.tsx +1 -1
- package/src/{components → deprecated/components}/Chip/examples/ChipGroupRemovableCategories.tsx +1 -1
- package/src/{components → deprecated/components}/Chip/examples/ChipGroupWithCategories.tsx +1 -1
- package/src/deprecated/components/Select/Select.tsx +2 -2
- package/src/deprecated/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +25 -31
- package/src/deprecated/components/Select/examples/Select.md +1 -1
- package/src/deprecated/components/index.ts +1 -0
- package/dist/dynamic/components/Chip/package.json +0 -1
- package/dist/esm/components/Chip/Chip.d.ts.map +0 -1
- package/dist/esm/components/Chip/Chip.js +0 -95
- package/dist/esm/components/Chip/Chip.js.map +0 -1
- package/dist/esm/components/Chip/ChipGroup.d.ts.map +0 -1
- package/dist/esm/components/Chip/ChipGroup.js +0 -87
- package/dist/esm/components/Chip/ChipGroup.js.map +0 -1
- package/dist/esm/components/Chip/index.d.ts.map +0 -1
- package/dist/esm/components/Chip/index.js.map +0 -1
- package/dist/js/components/Chip/Chip.d.ts.map +0 -1
- package/dist/js/components/Chip/Chip.js +0 -98
- package/dist/js/components/Chip/Chip.js.map +0 -1
- package/dist/js/components/Chip/ChipGroup.d.ts.map +0 -1
- package/dist/js/components/Chip/ChipGroup.js +0 -90
- package/dist/js/components/Chip/ChipGroup.js.map +0 -1
- package/dist/js/components/Chip/index.d.ts.map +0 -1
- package/dist/js/components/Chip/index.js.map +0 -1
- package/src/components/Chip/Chip.tsx +0 -216
- package/src/components/Chip/ChipGroup.tsx +0 -214
- /package/dist/esm/{components → deprecated/components}/Chip/index.d.ts +0 -0
- /package/dist/esm/{components → deprecated/components}/Chip/index.js +0 -0
- /package/dist/js/{components → deprecated/components}/Chip/index.d.ts +0 -0
- /package/dist/js/{components → deprecated/components}/Chip/index.js +0 -0
- /package/src/{components → deprecated/components}/Chip/index.ts +0 -0
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
MenuList,
|
|
10
10
|
MenuItem,
|
|
11
11
|
Popper,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Divider,
|
|
13
|
+
Label,
|
|
14
|
+
LabelGroup
|
|
15
15
|
} from '@patternfly/react-core';
|
|
16
16
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
17
17
|
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
@@ -218,13 +218,13 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
218
218
|
placeholder="search"
|
|
219
219
|
aria-label="Search input"
|
|
220
220
|
>
|
|
221
|
-
<
|
|
221
|
+
<LabelGroup>
|
|
222
222
|
{currentChips.map((currentChip) => (
|
|
223
|
-
<
|
|
223
|
+
<Label key={currentChip} variant="outline" onClose={() => deleteChip(currentChip)}>
|
|
224
224
|
{currentChip}
|
|
225
|
-
</
|
|
225
|
+
</Label>
|
|
226
226
|
))}
|
|
227
|
-
</
|
|
227
|
+
</LabelGroup>
|
|
228
228
|
</TextInputGroupMain>
|
|
229
229
|
{showUtilities && (
|
|
230
230
|
<TextInputGroupUtilities>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TooltipPosition } from '../../../components/Tooltip';
|
|
3
|
+
import { Label, LabelProps } from '../../../components/Label';
|
|
4
|
+
import { getOUIAProps, OUIAProps, getDefaultOUIAId } from '../../../helpers';
|
|
5
|
+
|
|
6
|
+
export interface ChipProps extends LabelProps, OUIAProps {
|
|
7
|
+
/** Badge to add to the chip. The badge will be rendered after the chip text. */
|
|
8
|
+
badge?: React.ReactNode;
|
|
9
|
+
/** Content rendered inside the chip text */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** Aria Label for close button */
|
|
12
|
+
closeBtnAriaLabel?: string;
|
|
13
|
+
/** Additional classes added to the chip item */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Flag indicating if the chip is an overflow chip */
|
|
16
|
+
isOverflowChip?: boolean;
|
|
17
|
+
/** Flag indicating if chip is read only */
|
|
18
|
+
isReadOnly?: boolean;
|
|
19
|
+
/** Function that is called when clicking on the chip close button */
|
|
20
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
21
|
+
/** @deprecated Component that will be used for chip. It is recommended that <button> or <li> are used when the chip is an overflow chip. */
|
|
22
|
+
component?: React.ReactNode;
|
|
23
|
+
/** Position of the tooltip which is displayed if text is longer */
|
|
24
|
+
tooltipPosition?:
|
|
25
|
+
| TooltipPosition
|
|
26
|
+
| 'auto'
|
|
27
|
+
| 'top'
|
|
28
|
+
| 'bottom'
|
|
29
|
+
| 'left'
|
|
30
|
+
| 'right'
|
|
31
|
+
| 'top-start'
|
|
32
|
+
| 'top-end'
|
|
33
|
+
| 'bottom-start'
|
|
34
|
+
| 'bottom-end'
|
|
35
|
+
| 'left-start'
|
|
36
|
+
| 'left-end'
|
|
37
|
+
| 'right-start'
|
|
38
|
+
| 'right-end';
|
|
39
|
+
|
|
40
|
+
/** Css property expressed in percentage or any css unit that overrides the default value of the max-width of the chip's text */
|
|
41
|
+
textMaxWidth?: string;
|
|
42
|
+
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
43
|
+
ouiaId?: number | string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class Chip extends React.Component<ChipProps> {
|
|
47
|
+
static displayName = 'Chip';
|
|
48
|
+
constructor(props: ChipProps) {
|
|
49
|
+
super(props);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static defaultProps: ChipProps = {
|
|
53
|
+
className: '',
|
|
54
|
+
isOverflowChip: false,
|
|
55
|
+
isReadOnly: false,
|
|
56
|
+
tooltipPosition: 'top' as 'auto' | 'top' | 'bottom' | 'left' | 'right',
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
|
+
onClick: (_e: React.MouseEvent) => undefined as any,
|
|
59
|
+
textMaxWidth: '16ch'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
render() {
|
|
63
|
+
const {
|
|
64
|
+
isOverflowChip,
|
|
65
|
+
children,
|
|
66
|
+
badge,
|
|
67
|
+
onClick,
|
|
68
|
+
className,
|
|
69
|
+
textMaxWidth,
|
|
70
|
+
isReadOnly,
|
|
71
|
+
closeBtnAriaLabel,
|
|
72
|
+
tooltipPosition,
|
|
73
|
+
ouiaId,
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
component,
|
|
76
|
+
...props
|
|
77
|
+
} = this.props;
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Label
|
|
81
|
+
variant="outline"
|
|
82
|
+
className={className}
|
|
83
|
+
textMaxWidth={textMaxWidth}
|
|
84
|
+
tooltipPosition={tooltipPosition}
|
|
85
|
+
{...(!isReadOnly &&
|
|
86
|
+
!isOverflowChip && {
|
|
87
|
+
onClose: onClick,
|
|
88
|
+
closeBtnAriaLabel: closeBtnAriaLabel ? closeBtnAriaLabel : `Close ${children}`
|
|
89
|
+
})}
|
|
90
|
+
{...(isOverflowChip && { onClick, variant: 'overflow' })}
|
|
91
|
+
{...getOUIAProps(
|
|
92
|
+
isOverflowChip ? 'OverflowChip' : Chip.displayName,
|
|
93
|
+
ouiaId !== undefined ? ouiaId : getDefaultOUIAId(Chip.displayName)
|
|
94
|
+
)}
|
|
95
|
+
{...props}
|
|
96
|
+
>
|
|
97
|
+
{children}
|
|
98
|
+
{badge && <React.Fragment> {badge}</React.Fragment>}
|
|
99
|
+
</Label>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { Chip };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { LabelGroup, LabelGroupProps } from '../../../components/Label';
|
|
3
|
+
import { TooltipPosition } from '../../../components/Tooltip';
|
|
4
|
+
import { getOUIAProps, OUIAProps } from '../../../helpers';
|
|
5
|
+
|
|
6
|
+
export interface ChipGroupProps extends Omit<LabelGroupProps, 'ref'>, OUIAProps {
|
|
7
|
+
/** Content rendered inside the chip group. Should be <Chip> elements. */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** Additional classes added to the chip item */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Flag for having the chip group default to expanded */
|
|
12
|
+
defaultIsOpen?: boolean;
|
|
13
|
+
/** Customizable "Show Less" text string */
|
|
14
|
+
expandedText?: string;
|
|
15
|
+
/** Customizeable template string. Use variable "${remaining}" for the overflow chip count. */
|
|
16
|
+
collapsedText?: string;
|
|
17
|
+
/** Category name text for the chip group category. If this prop is supplied the chip group with have a label and category styling applied */
|
|
18
|
+
categoryName?: string;
|
|
19
|
+
/** Aria label for chip group that does not have a category name */
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
/** Set number of chips to show before overflow */
|
|
22
|
+
numChips?: number;
|
|
23
|
+
/** Flag if chip group can be closed*/
|
|
24
|
+
isClosable?: boolean;
|
|
25
|
+
/** Aria label for close button */
|
|
26
|
+
closeBtnAriaLabel?: string;
|
|
27
|
+
/** Function that is called when clicking on the chip group close button or on an overflow chip */
|
|
28
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
29
|
+
/** @deprecated Function that is called when clicking on the overflow (expand/collapse) chip button */
|
|
30
|
+
onOverflowChipClick?: (event: React.MouseEvent) => void;
|
|
31
|
+
/** Position of the tooltip which is displayed if the category name text is longer */
|
|
32
|
+
tooltipPosition?:
|
|
33
|
+
| TooltipPosition
|
|
34
|
+
| 'auto'
|
|
35
|
+
| 'top'
|
|
36
|
+
| 'bottom'
|
|
37
|
+
| 'left'
|
|
38
|
+
| 'right'
|
|
39
|
+
| 'top-start'
|
|
40
|
+
| 'top-end'
|
|
41
|
+
| 'bottom-start'
|
|
42
|
+
| 'bottom-end'
|
|
43
|
+
| 'left-start'
|
|
44
|
+
| 'left-end'
|
|
45
|
+
| 'right-start'
|
|
46
|
+
| 'right-end';
|
|
47
|
+
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
48
|
+
ouiaId?: number | string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class ChipGroup extends React.Component<ChipGroupProps> {
|
|
52
|
+
static displayName = 'ChipGroup';
|
|
53
|
+
constructor(props: ChipGroupProps) {
|
|
54
|
+
super(props);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static defaultProps: ChipGroupProps = {
|
|
58
|
+
expandedText: 'Show Less',
|
|
59
|
+
collapsedText: '${remaining} more',
|
|
60
|
+
categoryName: '',
|
|
61
|
+
defaultIsOpen: false,
|
|
62
|
+
numChips: 3,
|
|
63
|
+
isClosable: false,
|
|
64
|
+
closeBtnAriaLabel: 'Close chip group',
|
|
65
|
+
tooltipPosition: 'top',
|
|
66
|
+
'aria-label': 'Chip group category'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
const {
|
|
71
|
+
categoryName,
|
|
72
|
+
children,
|
|
73
|
+
className,
|
|
74
|
+
isClosable,
|
|
75
|
+
closeBtnAriaLabel,
|
|
76
|
+
'aria-label': ariaLabel,
|
|
77
|
+
onClick,
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
+
onOverflowChipClick,
|
|
80
|
+
numChips,
|
|
81
|
+
expandedText,
|
|
82
|
+
collapsedText,
|
|
83
|
+
ouiaId,
|
|
84
|
+
defaultIsOpen,
|
|
85
|
+
tooltipPosition,
|
|
86
|
+
...props
|
|
87
|
+
} = this.props;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<LabelGroup
|
|
91
|
+
className={className}
|
|
92
|
+
categoryName={categoryName}
|
|
93
|
+
numLabels={numChips}
|
|
94
|
+
isClosable={isClosable}
|
|
95
|
+
closeBtnAriaLabel={closeBtnAriaLabel}
|
|
96
|
+
aria-label={ariaLabel}
|
|
97
|
+
onClick={onClick}
|
|
98
|
+
expandedText={expandedText}
|
|
99
|
+
collapsedText={collapsedText}
|
|
100
|
+
defaultIsOpen={defaultIsOpen}
|
|
101
|
+
tooltipPosition={tooltipPosition}
|
|
102
|
+
{...getOUIAProps(ChipGroup.displayName, ouiaId)}
|
|
103
|
+
{...props}
|
|
104
|
+
>
|
|
105
|
+
{children}
|
|
106
|
+
</LabelGroup>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { ChipGroup };
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { Chip } from '../Chip';
|
|
5
|
-
import styles from '@patternfly/react-styles/css/components/
|
|
5
|
+
import styles from '@patternfly/react-styles/css/components/Label/label';
|
|
6
6
|
|
|
7
|
-
jest.mock('
|
|
7
|
+
jest.mock('../../../../components/Tooltip', () => ({
|
|
8
8
|
Tooltip: ({ content, position }) => (
|
|
9
9
|
<div data-testid="tooltip-mock">
|
|
10
10
|
<p>{`content: ${content}`}</p>
|
|
@@ -26,7 +26,7 @@ jest.mock('../../Tooltip', () => ({
|
|
|
26
26
|
expect(screen.getByTestId('container').firstChild).toBeVisible();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
test(`Renders with class ${styles.
|
|
29
|
+
test(`Renders with class ${styles.label} on the ${chipType} container element`, () => {
|
|
30
30
|
render(
|
|
31
31
|
<Chip isOverflowChip={isOverflowChip} data-testid="container">
|
|
32
32
|
Chip text
|
|
@@ -35,23 +35,28 @@ jest.mock('../../Tooltip', () => ({
|
|
|
35
35
|
|
|
36
36
|
// Only a non-overflow chip will have exactly the class "pf-v5-c-chip", we test for
|
|
37
37
|
// additional classes on overflow chips elsewhere in the suite
|
|
38
|
-
expect(screen.getByTestId('container')).toHaveClass(
|
|
38
|
+
expect(screen.getByTestId('container')).toHaveClass(
|
|
39
|
+
isOverflowChip ? `${styles.label} ${styles.modifiers.overflow}` : `${styles.label} ${styles.modifiers.outline}`,
|
|
40
|
+
{
|
|
41
|
+
exact: !isOverflowChip
|
|
42
|
+
}
|
|
43
|
+
);
|
|
39
44
|
});
|
|
40
45
|
|
|
41
|
-
test(`Renders with class ${styles.
|
|
46
|
+
test(`Renders with class ${styles.labelContent} around the ${chipType} content`, () => {
|
|
42
47
|
render(
|
|
43
48
|
<Chip isOverflowChip={isOverflowChip} data-testid="container">
|
|
44
49
|
Chip text
|
|
45
50
|
</Chip>
|
|
46
51
|
);
|
|
47
52
|
|
|
48
|
-
expect(screen.getByTestId('container').firstChild).toHaveClass(styles.
|
|
53
|
+
expect(screen.getByTestId('container').firstChild).toHaveClass(styles.labelContent, { exact: true });
|
|
49
54
|
});
|
|
50
55
|
|
|
51
|
-
test(`Renders ${chipType} children with class ${styles.
|
|
56
|
+
test(`Renders ${chipType} children with class ${styles.labelText}`, () => {
|
|
52
57
|
render(<Chip isOverflowChip={isOverflowChip}>Chip text</Chip>);
|
|
53
58
|
|
|
54
|
-
expect(screen.getByText('Chip text')).toHaveClass(styles.
|
|
59
|
+
expect(screen.getByText('Chip text')).toHaveClass(styles.labelText, { exact: true });
|
|
55
60
|
});
|
|
56
61
|
|
|
57
62
|
test(`Renders with custom class on the ${chipType} container element`, () => {
|
|
@@ -74,34 +79,14 @@ jest.mock('../../Tooltip', () => ({
|
|
|
74
79
|
expect(screen.getByText('Badge content')).toBeVisible();
|
|
75
80
|
});
|
|
76
81
|
|
|
77
|
-
test(`Renders with div container on ${chipType} by default`, () => {
|
|
78
|
-
render(
|
|
79
|
-
<Chip isOverflowChip={isOverflowChip} data-testid="container">
|
|
80
|
-
Chip text
|
|
81
|
-
</Chip>
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(screen.getByTestId('container').tagName).toBe('DIV');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test(`Renders with custom container on ${chipType} when component prop is passed`, () => {
|
|
88
|
-
render(
|
|
89
|
-
<Chip component="li" isOverflowChip={isOverflowChip}>
|
|
90
|
-
Chip text
|
|
91
|
-
</Chip>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect(screen.getByRole('listitem')).toBeVisible();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
82
|
test(`Renders maxWidth css var in style attribute when textMaxWidth is passed for ${chipType}`, () => {
|
|
98
83
|
render(
|
|
99
|
-
<Chip isOverflowChip={isOverflowChip}
|
|
84
|
+
<Chip isOverflowChip={isOverflowChip} textMaxWidth="10px">
|
|
100
85
|
Chip text
|
|
101
86
|
</Chip>
|
|
102
87
|
);
|
|
103
88
|
|
|
104
|
-
expect(screen.
|
|
89
|
+
expect(screen.getByText('Chip text')).toHaveAttribute('style', '--pf-v5-c-label__text--MaxWidth: 10px;');
|
|
105
90
|
});
|
|
106
91
|
|
|
107
92
|
test(`Spreads additional props to container for ${chipType}`, () => {
|
|
@@ -115,13 +100,13 @@ jest.mock('../../Tooltip', () => ({
|
|
|
115
100
|
});
|
|
116
101
|
});
|
|
117
102
|
|
|
118
|
-
test(`Renders id prop on ${styles.
|
|
103
|
+
test(`Renders id prop on ${styles.labelText} container for default chip`, () => {
|
|
119
104
|
render(<Chip id="custom-id">Chip text</Chip>);
|
|
120
105
|
|
|
121
|
-
expect(screen.getByText('Chip text')).toHaveAttribute('id', 'custom-id');
|
|
106
|
+
expect(screen.getByText('Chip text').parentElement?.parentElement).toHaveAttribute('id', 'custom-id');
|
|
122
107
|
});
|
|
123
108
|
|
|
124
|
-
test(`Does not render id prop on ${styles.
|
|
109
|
+
test(`Does not render id prop on ${styles.labelText} container for overflow chip`, () => {
|
|
125
110
|
render(
|
|
126
111
|
<Chip isOverflowChip id="custom-id">
|
|
127
112
|
Chip text
|
|
@@ -131,41 +116,29 @@ test(`Does not render id prop on ${styles.chipText} container for overflow chip`
|
|
|
131
116
|
expect(screen.getByText('Chip text')).not.toHaveAttribute('id');
|
|
132
117
|
});
|
|
133
118
|
|
|
134
|
-
test(`Renders actions container with class ${styles.
|
|
119
|
+
test(`Renders actions container with class ${styles.labelActions} when isReadOnly is false`, () => {
|
|
135
120
|
render(<Chip>Chip text</Chip>);
|
|
136
121
|
|
|
137
|
-
expect(screen.getByRole('button').parentElement).toHaveClass(styles.
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test(`Renders aria-labelledby on action close button by default`, () => {
|
|
141
|
-
render(<Chip>Chip text</Chip>);
|
|
142
|
-
|
|
143
|
-
expect(screen.getByRole('button')).toHaveAccessibleName('close Chip text');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test(`Renders aria-labelledby on action close button with custom id passed`, () => {
|
|
147
|
-
render(<Chip id="custom-id">Chip text</Chip>);
|
|
148
|
-
|
|
149
|
-
expect(screen.getByRole('button')).toHaveAccessibleName('close Chip text');
|
|
122
|
+
expect(screen.getByRole('button').parentElement).toHaveClass(styles.labelActions);
|
|
150
123
|
});
|
|
151
124
|
|
|
152
125
|
test(`Renders concatenated aria-label on action close button by default`, () => {
|
|
153
126
|
render(<Chip>Chip text</Chip>);
|
|
154
127
|
|
|
155
|
-
expect(screen.getByRole('button')).toHaveAccessibleName('
|
|
128
|
+
expect(screen.getByRole('button')).toHaveAccessibleName('Close Chip text');
|
|
156
129
|
});
|
|
157
130
|
|
|
158
131
|
test(`Renders custom aria-label on action close button when closeBtnAriaLabel is passed`, () => {
|
|
159
132
|
render(<Chip closeBtnAriaLabel="custom label">Chip text</Chip>);
|
|
160
133
|
|
|
161
|
-
expect(screen.getByRole('button')).toHaveAccessibleName('custom label
|
|
134
|
+
expect(screen.getByRole('button')).toHaveAccessibleName('custom label');
|
|
162
135
|
});
|
|
163
136
|
|
|
164
137
|
test(`Does not render close button action when isOverflowChip is true`, () => {
|
|
165
138
|
render(<Chip isOverflowChip>Chip text</Chip>);
|
|
166
139
|
|
|
167
140
|
// Because overflow chip renders as a button, we need to add the accessible name to the query
|
|
168
|
-
expect(screen.queryByRole('button', { name: '
|
|
141
|
+
expect(screen.queryByRole('button', { name: 'Close Chip text' })).not.toBeInTheDocument();
|
|
169
142
|
});
|
|
170
143
|
|
|
171
144
|
test(`Does not render close button action when isReadOnly is true`, () => {
|
|
@@ -196,7 +169,7 @@ test(`Calls onClick when close button action is clicked for default chip`, async
|
|
|
196
169
|
|
|
197
170
|
render(<Chip onClick={onClickMock}>Chip text</Chip>);
|
|
198
171
|
|
|
199
|
-
await user.click(screen.getByRole('button', { name: '
|
|
172
|
+
await user.click(screen.getByRole('button', { name: 'Close Chip text' }));
|
|
200
173
|
|
|
201
174
|
expect(onClickMock).toHaveBeenCalledTimes(1);
|
|
202
175
|
});
|
|
@@ -227,7 +200,7 @@ test(`Calls onClick when chip is clicked for overflow chip`, async () => {
|
|
|
227
200
|
</Chip>
|
|
228
201
|
);
|
|
229
202
|
|
|
230
|
-
await user.click(screen.getByRole('button'
|
|
203
|
+
await user.click(screen.getByRole('button'));
|
|
231
204
|
|
|
232
205
|
expect(onClickMock).toHaveBeenCalledTimes(1);
|
|
233
206
|
});
|
|
@@ -258,14 +231,6 @@ test('Passes position to Tooltip', () => {
|
|
|
258
231
|
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 0 });
|
|
259
232
|
});
|
|
260
233
|
|
|
261
|
-
test('Passes content to Tooltip', () => {
|
|
262
|
-
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 500 });
|
|
263
|
-
render(<Chip>Test chip text</Chip>);
|
|
264
|
-
|
|
265
|
-
expect(screen.getByText(`content: Test chip text`)).toBeVisible();
|
|
266
|
-
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 0 });
|
|
267
|
-
});
|
|
268
|
-
|
|
269
234
|
test('Matches snapshot', () => {
|
|
270
235
|
const { asFragment } = render(
|
|
271
236
|
<Chip id="snapshot-test" ouiaId="snapshot-test">
|
|
@@ -4,8 +4,8 @@ import { render, screen } from '@testing-library/react';
|
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
5
5
|
|
|
6
6
|
import { ChipGroup } from '../index';
|
|
7
|
-
import { Chip } from '
|
|
8
|
-
import styles from '@patternfly/react-styles/css/components/
|
|
7
|
+
import { Chip } from '..';
|
|
8
|
+
import styles from '@patternfly/react-styles/css/components/Label/label-group';
|
|
9
9
|
|
|
10
10
|
test('chip group default', () => {
|
|
11
11
|
render(
|
|
@@ -14,7 +14,7 @@ test('chip group default', () => {
|
|
|
14
14
|
</ChipGroup>
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
-
expect(screen.getByRole('
|
|
17
|
+
expect(screen.getByRole('list').parentElement?.parentElement).toHaveClass(styles.labelGroup);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
test('chip group with custom className', () => {
|
|
@@ -24,7 +24,7 @@ test('chip group with custom className', () => {
|
|
|
24
24
|
</ChipGroup>
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
expect(screen.getByRole('
|
|
27
|
+
expect(screen.getByRole('list').parentElement?.parentElement).toHaveClass(`${styles.labelGroup} test`);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test('chip group has aria-label by default when categoryName is not passed', () => {
|
|
@@ -34,7 +34,7 @@ test('chip group has aria-label by default when categoryName is not passed', ()
|
|
|
34
34
|
</ChipGroup>
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
expect(screen.getByRole('
|
|
37
|
+
expect(screen.getByRole('list')).toHaveAccessibleName('Chip group category');
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test('chip group with custom aria-label', () => {
|
|
@@ -44,7 +44,7 @@ test('chip group with custom aria-label', () => {
|
|
|
44
44
|
</ChipGroup>
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
expect(screen.getByRole('
|
|
47
|
+
expect(screen.getByRole('list')).toHaveAccessibleName('test chip group');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
test('chip group with category', () => {
|
|
@@ -62,7 +62,7 @@ test('chip group with category renders with class pf-m-category', () => {
|
|
|
62
62
|
<Chip>1.1</Chip>
|
|
63
63
|
</ChipGroup>
|
|
64
64
|
);
|
|
65
|
-
expect(screen.getByRole('
|
|
65
|
+
expect(screen.getByRole('list').parentElement?.parentElement).toHaveClass(`${styles.modifiers.category}`);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test('chip group has aria-labelledby attribute', () => {
|
|
@@ -71,7 +71,7 @@ test('chip group has aria-labelledby attribute', () => {
|
|
|
71
71
|
<Chip>1.1</Chip>
|
|
72
72
|
</ChipGroup>
|
|
73
73
|
);
|
|
74
|
-
expect(screen.getByRole('
|
|
74
|
+
expect(screen.getByRole('list')).toHaveAttribute('aria-labelledby', expect.stringContaining(`pf-random-id`));
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
test('chip group has aria-labelledby attribute set to ID value', () => {
|
|
@@ -80,7 +80,7 @@ test('chip group has aria-labelledby attribute set to ID value', () => {
|
|
|
80
80
|
<Chip>1.1</Chip>
|
|
81
81
|
</ChipGroup>
|
|
82
82
|
);
|
|
83
|
-
expect(screen.getByRole('
|
|
83
|
+
expect(screen.getByRole('list')).toHaveAttribute('aria-labelledby', 'chip-group-id');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
test('chip group expands', async () => {
|
|
@@ -105,7 +105,7 @@ test('chip group with closable category', () => {
|
|
|
105
105
|
<Chip>1.1</Chip>
|
|
106
106
|
</ChipGroup>
|
|
107
107
|
);
|
|
108
|
-
expect(screen.getByRole('
|
|
108
|
+
expect(screen.getByRole('list').parentElement?.parentElement?.lastChild).toHaveClass(styles.labelGroupClose);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
test('chip group with closeBtnAriaLabel', () => {
|
|
@@ -132,23 +132,6 @@ test('chip group onClick', async () => {
|
|
|
132
132
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
test('chip group onOverflowChipClick', async () => {
|
|
136
|
-
const onOverflowChipClick = jest.fn();
|
|
137
|
-
const user = userEvent.setup();
|
|
138
|
-
|
|
139
|
-
render(
|
|
140
|
-
<ChipGroup categoryName="category" onOverflowChipClick={onOverflowChipClick}>
|
|
141
|
-
<Chip>1</Chip>
|
|
142
|
-
<Chip>2</Chip>
|
|
143
|
-
<Chip>3</Chip>
|
|
144
|
-
<Chip>4</Chip>
|
|
145
|
-
</ChipGroup>
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
await user.click(screen.getByText('1 more'));
|
|
149
|
-
expect(onOverflowChipClick).toHaveBeenCalledTimes(1);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
135
|
test('chip group expanded', async () => {
|
|
153
136
|
const user = userEvent.setup();
|
|
154
137
|
|
|
@@ -288,6 +271,6 @@ test('chip group will not render if no children passed', () => {
|
|
|
288
271
|
|
|
289
272
|
test('chip group renders to match snapshot', () => {
|
|
290
273
|
const { asFragment } = render(<ChipGroup>chips</ChipGroup>);
|
|
291
|
-
expect(screen.getByRole('
|
|
274
|
+
expect(screen.getByRole('list')).toBeInTheDocument();
|
|
292
275
|
expect(asFragment()).toMatchSnapshot();
|
|
293
276
|
});
|
package/src/{components → deprecated/components}/Chip/__tests__/__snapshots__/Chip.test.tsx.snap
RENAMED
|
@@ -2,34 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Matches snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
-
<
|
|
6
|
-
class="pf-v5-c-
|
|
5
|
+
<span
|
|
6
|
+
class="pf-v5-c-label pf-m-outline"
|
|
7
7
|
data-ouia-component-id="snapshot-test"
|
|
8
8
|
data-ouia-component-type="PF5/Chip"
|
|
9
9
|
data-ouia-safe="true"
|
|
10
|
+
id="snapshot-test"
|
|
10
11
|
>
|
|
11
12
|
<span
|
|
12
|
-
class="pf-v5-c-
|
|
13
|
+
class="pf-v5-c-label__content"
|
|
13
14
|
>
|
|
14
15
|
<span
|
|
15
|
-
class="pf-v5-c-
|
|
16
|
-
|
|
16
|
+
class="pf-v5-c-label__text"
|
|
17
|
+
style="--pf-v5-c-label__text--MaxWidth: 16ch;"
|
|
17
18
|
>
|
|
18
19
|
Chip text
|
|
19
20
|
</span>
|
|
20
21
|
</span>
|
|
21
22
|
<span
|
|
22
|
-
class="pf-v5-c-
|
|
23
|
+
class="pf-v5-c-label__actions"
|
|
23
24
|
>
|
|
24
25
|
<button
|
|
25
26
|
aria-disabled="false"
|
|
26
|
-
aria-label="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
data-ouia-component-id="snapshot-test"
|
|
27
|
+
aria-label="Close Chip text"
|
|
28
|
+
class="pf-v5-c-button pf-m-plain pf-m-no-padding"
|
|
29
|
+
data-ouia-component-id="OUIA-Generated-Button-plain-17"
|
|
30
30
|
data-ouia-component-type="PF5/Button"
|
|
31
31
|
data-ouia-safe="true"
|
|
32
|
-
id="remove_snapshot-test"
|
|
33
32
|
type="button"
|
|
34
33
|
>
|
|
35
34
|
<svg
|
|
@@ -47,6 +46,6 @@ exports[`Matches snapshot 1`] = `
|
|
|
47
46
|
</svg>
|
|
48
47
|
</button>
|
|
49
48
|
</span>
|
|
50
|
-
</
|
|
49
|
+
</span>
|
|
51
50
|
</DocumentFragment>
|
|
52
51
|
`;
|
|
@@ -3,22 +3,20 @@
|
|
|
3
3
|
exports[`chip group renders to match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
|
|
7
|
-
class="pf-v5-c-chip-group"
|
|
8
|
-
data-ouia-component-type="PF5/ChipGroup"
|
|
9
|
-
data-ouia-safe="true"
|
|
10
|
-
role="group"
|
|
6
|
+
class="pf-v5-c-label-group"
|
|
11
7
|
>
|
|
12
8
|
<div
|
|
13
|
-
class="pf-v5-c-
|
|
9
|
+
class="pf-v5-c-label-group__main"
|
|
14
10
|
>
|
|
15
11
|
<ul
|
|
16
12
|
aria-label="Chip group category"
|
|
17
|
-
class="pf-v5-c-
|
|
13
|
+
class="pf-v5-c-label-group__list"
|
|
14
|
+
data-ouia-component-type="PF5/ChipGroup"
|
|
15
|
+
data-ouia-safe="true"
|
|
18
16
|
role="list"
|
|
19
17
|
>
|
|
20
18
|
<li
|
|
21
|
-
class="pf-v5-c-
|
|
19
|
+
class="pf-v5-c-label-group__list-item"
|
|
22
20
|
>
|
|
23
21
|
chips
|
|
24
22
|
</li>
|
|
@@ -4,14 +4,17 @@ section: components
|
|
|
4
4
|
cssPrefix: ['pf-v5-c-chip', 'pf-v5-c-chip-group']
|
|
5
5
|
propComponents: ['Chip', 'ChipGroup']
|
|
6
6
|
ouia: true
|
|
7
|
+
deprecated: true
|
|
7
8
|
---
|
|
8
9
|
|
|
9
10
|
## Examples
|
|
10
11
|
|
|
11
12
|
### Chip variants
|
|
13
|
+
|
|
12
14
|
Chips can be removable or read-only. The Overflow chip is a special chip that is used to expand or collapse the content of a chip group.
|
|
13
15
|
|
|
14
16
|
```ts file='./ChipDefault.tsx'
|
|
17
|
+
|
|
15
18
|
```
|
|
16
19
|
|
|
17
20
|
### Chip groups
|
|
@@ -19,14 +22,17 @@ Chips can be removable or read-only. The Overflow chip is a special chip that is
|
|
|
19
22
|
A chip group is a collection of chips that can be grouped by category and used to represent one or more values assigned to a single attribute. When the value of `numChips` is exceeded, additional chips will be hidden using an overflow chip.
|
|
20
23
|
|
|
21
24
|
```ts file='./ChipGroupInline.tsx'
|
|
25
|
+
|
|
22
26
|
```
|
|
23
27
|
|
|
24
28
|
### Chip groups with categories
|
|
25
29
|
|
|
26
30
|
```ts file='./ChipGroupWithCategories.tsx'
|
|
31
|
+
|
|
27
32
|
```
|
|
28
33
|
|
|
29
34
|
### Chip groups with removable categories
|
|
30
35
|
|
|
31
36
|
```ts file='./ChipGroupRemovableCategories.tsx'
|
|
37
|
+
|
|
32
38
|
```
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Badge
|
|
2
|
+
import { Badge } from '@patternfly/react-core';
|
|
3
|
+
import { Chip } from '@patternfly/react-core/deprecated';
|
|
3
4
|
|
|
4
5
|
export const ChipDefault: React.FunctionComponent = () => {
|
|
5
6
|
const [chips, setChips] = React.useState({
|