@patternfly/react-core 5.2.0-prerelease.29 → 5.2.0-prerelease.30
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 +6 -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/Chip/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/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/package.json +1 -1
- package/dist/esm/components/Chip/Chip.d.ts +1 -0
- package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
- package/dist/esm/components/Chip/Chip.js +8 -0
- package/dist/esm/components/Chip/Chip.js.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js +2 -2
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/DataList/DataListAction.js +3 -3
- package/dist/esm/components/DataList/DataListAction.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/components/Chip/Chip.d.ts +1 -0
- package/dist/js/components/Chip/Chip.d.ts.map +1 -1
- package/dist/js/components/Chip/Chip.js +8 -0
- package/dist/js/components/Chip/Chip.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js +2 -2
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/DataList/DataListAction.js +3 -3
- package/dist/js/components/DataList/DataListAction.js.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +1 -1
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- package/src/components/Chip/Chip.tsx +11 -0
- package/src/components/ClipboardCopy/ClipboardCopy.tsx +5 -5
- package/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx +0 -1
- package/src/components/DataList/DataList.tsx +2 -0
- package/src/components/DataList/DataListAction.tsx +1 -1
- package/src/components/DataList/__tests__/DataList.test.tsx +140 -304
- package/src/components/DataList/__tests__/DataListAction.test.tsx +75 -0
- package/src/components/DataList/__tests__/DataListCell.test.tsx +120 -0
- package/src/components/DataList/__tests__/DataListCheck.test.tsx +5 -0
- package/src/components/DataList/__tests__/DataListContent.test.tsx +73 -0
- package/src/components/DataList/__tests__/DataListItem.test.tsx +46 -0
- package/src/components/DataList/__tests__/DataListItemCells.test.tsx +25 -0
- package/src/components/DataList/__tests__/DataListItemRow.test.tsx +44 -0
- package/src/components/DataList/__tests__/DataListToggle.test.tsx +61 -0
- package/src/components/DataList/__tests__/__snapshots__/DataList.test.tsx.snap +2 -323
- package/src/components/DataList/__tests__/__snapshots__/DataListAction.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListCell.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListContent.test.tsx.snap +17 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItem.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItemCells.test.tsx.snap +9 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItemRow.test.tsx.snap +9 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListToggle.test.tsx.snap +45 -0
- package/src/components/DataList/examples/DataListCheckboxes.tsx +5 -5
- package/src/components/DataList/examples/DataListMixedExpandable.tsx +1 -1
- package/src/components/DatePicker/DatePicker.tsx +1 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2 -2
- package/src/components/DescriptionList/__tests__/DescriptionList.test.tsx +128 -102
- package/src/components/DescriptionList/__tests__/DescriptionListDescription.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/DescriptionListGroup.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/DescriptionListHelpTextButton.test.tsx +27 -0
- package/src/components/DescriptionList/__tests__/DescriptionListTerm.test.tsx +35 -0
- package/src/components/DescriptionList/__tests__/DescriptionListTermHelpText.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionList.test.tsx.snap +1 -157
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListDescription.test.tsx.snap +15 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListGroup.test.tsx.snap +11 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListHelpTextButton.test.tsx.snap +14 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTerm.test.tsx.snap +15 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTermHelpText.test.tsx.snap +11 -0
- package/src/components/HelperText/__tests__/HelperText.test.tsx +67 -57
- package/src/components/HelperText/__tests__/HelperTextItem.test.tsx +93 -0
- package/src/components/HelperText/__tests__/__snapshots__/HelperText.test.tsx.snap +2 -223
- package/src/components/HelperText/__tests__/__snapshots__/HelperTextItem.test.tsx.snap +15 -0
- package/src/demos/CustomMenus/CustomMenus.md +6 -0
- package/src/demos/CustomMenus/examples/InlineSearchFilterMenuDemo.tsx +102 -0
- package/src/demos/SearchInput/SearchInput.md +1 -1
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.29","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.29","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.29","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.2.0-prerelease.
|
|
3
|
+
"version": "5.2.0-prerelease.30",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react": "^17 || ^18",
|
|
72
72
|
"react-dom": "^17 || ^18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "e112034cf060e8917e5ba47079af4850a4f12d1a"
|
|
75
75
|
}
|
|
@@ -81,6 +81,17 @@ class Chip extends React.Component<ChipProps, ChipState> {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
componentDidUpdate(_prevProps: ChipProps, prevState: ChipState) {
|
|
85
|
+
const nextIsTooltipVisible = Boolean(
|
|
86
|
+
this.span.current && this.span.current.offsetWidth < this.span.current.scrollWidth
|
|
87
|
+
);
|
|
88
|
+
if (prevState.isTooltipVisible !== nextIsTooltipVisible) {
|
|
89
|
+
this.setState({
|
|
90
|
+
isTooltipVisible: nextIsTooltipVisible
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
setChipStyle = () => ({
|
|
85
96
|
[cssChipTextMaxWidth.name]: this.props.textMaxWidth
|
|
86
97
|
});
|
|
@@ -10,7 +10,7 @@ import { ClipboardCopyToggle } from './ClipboardCopyToggle';
|
|
|
10
10
|
import { ClipboardCopyExpanded } from './ClipboardCopyExpanded';
|
|
11
11
|
import { getOUIAProps, OUIAProps } from '../../helpers';
|
|
12
12
|
|
|
13
|
-
export const clipboardCopyFunc = (event: React.ClipboardEvent<HTMLDivElement>, text?:
|
|
13
|
+
export const clipboardCopyFunc = (event: React.ClipboardEvent<HTMLDivElement>, text?: string) => {
|
|
14
14
|
navigator.clipboard.writeText(text.toString());
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -27,7 +27,7 @@ export interface ClipboardCopyState {
|
|
|
27
27
|
textWhenExpanded: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'>, OUIAProps {
|
|
30
|
+
export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange' | 'children'>, OUIAProps {
|
|
31
31
|
/** Additional classes added to the clipboard copy container. */
|
|
32
32
|
className?: string;
|
|
33
33
|
/** Tooltip message to display when hover the copy button */
|
|
@@ -71,12 +71,12 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
|
|
|
71
71
|
/** Delay in ms before the tooltip appears. */
|
|
72
72
|
entryDelay?: number;
|
|
73
73
|
/** A function that is triggered on clicking the copy button. */
|
|
74
|
-
onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, text?:
|
|
74
|
+
onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, text?: string) => void;
|
|
75
75
|
/** A function that is triggered on changing the text. */
|
|
76
76
|
onChange?: (event: React.FormEvent, text?: string) => void;
|
|
77
77
|
/** The text which is copied. */
|
|
78
|
-
children:
|
|
79
|
-
/** Additional actions for inline
|
|
78
|
+
children: string;
|
|
79
|
+
/** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */
|
|
80
80
|
additionalActions?: React.ReactNode;
|
|
81
81
|
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
82
82
|
ouiaId?: number | string;
|
|
@@ -6,7 +6,6 @@ import { PickOptional } from '../../helpers/typeUtils';
|
|
|
6
6
|
|
|
7
7
|
export interface ClipboardCopyExpandedProps extends Omit<ClipboardCopyProps, 'onChange'> {
|
|
8
8
|
className?: string;
|
|
9
|
-
children: React.ReactNode;
|
|
10
9
|
onChange?: (e: React.FormEvent<HTMLDivElement>, text: string) => void;
|
|
11
10
|
isReadOnly?: boolean;
|
|
12
11
|
isCode?: boolean;
|
|
@@ -73,6 +73,7 @@ class DataList extends React.Component<DataListProps> {
|
|
|
73
73
|
const {
|
|
74
74
|
className,
|
|
75
75
|
children,
|
|
76
|
+
'aria-label': ariaLabel,
|
|
76
77
|
onSelectDataListItem,
|
|
77
78
|
selectedDataListItemId,
|
|
78
79
|
isCompact,
|
|
@@ -106,6 +107,7 @@ class DataList extends React.Component<DataListProps> {
|
|
|
106
107
|
)}
|
|
107
108
|
style={props.style}
|
|
108
109
|
role="list"
|
|
110
|
+
aria-label={ariaLabel}
|
|
109
111
|
{...props}
|
|
110
112
|
ref={this.ref}
|
|
111
113
|
>
|
|
@@ -35,8 +35,8 @@ export const DataListAction: React.FunctionComponent<DataListActionProps> = ({
|
|
|
35
35
|
id,
|
|
36
36
|
'aria-label': ariaLabel,
|
|
37
37
|
'aria-labelledby': ariaLabelledBy,
|
|
38
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
38
39
|
isPlainButtonAction,
|
|
39
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
40
40
|
...props
|
|
41
41
|
}: DataListActionProps) => (
|
|
42
42
|
<div className={css(styles.dataListItemAction, formatBreakpointMods(visibility, styles), className)} {...props}>
|
|
@@ -5,346 +5,182 @@ import userEvent from '@testing-library/user-event';
|
|
|
5
5
|
|
|
6
6
|
import { DataList } from '../DataList';
|
|
7
7
|
import { DataListItem } from '../DataListItem';
|
|
8
|
-
import { DataListAction } from '../DataListAction';
|
|
9
|
-
import { DataListCell } from '../DataListCell';
|
|
10
|
-
import { DataListToggle } from '../DataListToggle';
|
|
11
|
-
import { DataListItemCells } from '../DataListItemCells';
|
|
12
8
|
import { DataListItemRow } from '../DataListItemRow';
|
|
13
|
-
import { DataListContent } from '../DataListContent';
|
|
14
|
-
import { Button } from '../../Button';
|
|
15
|
-
import { Dropdown, DropdownList, DropdownItem } from '../../Dropdown';
|
|
16
|
-
import { MenuToggle } from '../../MenuToggle';
|
|
17
|
-
import styles from '@patternfly/react-styles/css/components/DataList/data-list';
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
test('List default', () => {
|
|
21
|
-
const { asFragment } = render(<DataList aria-label="this is a simple list" />);
|
|
22
|
-
expect(asFragment()).toMatchSnapshot();
|
|
23
|
-
});
|
|
10
|
+
import styles from '@patternfly/react-styles/css/components/DataList/data-list';
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
test('Renders to match snapshot', () => {
|
|
13
|
+
const { asFragment } = render(<DataList aria-label="list" />);
|
|
14
|
+
expect(asFragment()).toMatchSnapshot();
|
|
15
|
+
});
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<DataList aria-label="this is a simple list" gridBreakpoint={oneBreakpoint as any} />
|
|
35
|
-
);
|
|
36
|
-
expect(asFragment()).toMatchSnapshot();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
17
|
+
test(`Renders with default class ${styles.dataList}`, () => {
|
|
18
|
+
render(<DataList aria-label="list" />);
|
|
19
|
+
expect(screen.getByLabelText('list')).toHaveClass(styles.dataList);
|
|
20
|
+
});
|
|
40
21
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
test(`Renders with custom class when className is passed`, () => {
|
|
23
|
+
render(<DataList aria-label="list" className="custom" />);
|
|
24
|
+
expect(screen.getByLabelText('list')).toHaveClass('custom');
|
|
25
|
+
});
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(asFragment()).toMatchSnapshot();
|
|
51
|
-
});
|
|
27
|
+
test(`Renders with spread props`, () => {
|
|
28
|
+
render(<DataList aria-label="list" id="test" />);
|
|
29
|
+
expect(screen.getByLabelText('list')).toHaveAttribute('id', 'test');
|
|
30
|
+
});
|
|
52
31
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<DataListItemRow aria-labelledby="test-id">
|
|
58
|
-
<p id="test-id">Test</p>
|
|
59
|
-
</DataListItemRow>
|
|
60
|
-
</DataListItem>
|
|
61
|
-
</DataList>
|
|
62
|
-
);
|
|
32
|
+
test(`Renders with aria-label when aria-label is passed`, () => {
|
|
33
|
+
render(<DataList aria-label="list">test</DataList>);
|
|
34
|
+
expect(screen.getByText('test')).toHaveAccessibleName('list');
|
|
35
|
+
});
|
|
63
36
|
|
|
64
|
-
|
|
37
|
+
test(`Renders ${styles.modifiers.compact} when isCompact = true`, () => {
|
|
38
|
+
render(<DataList aria-label="list" isCompact />);
|
|
39
|
+
expect(screen.getByLabelText('list')).toHaveClass(styles.modifiers.compact);
|
|
40
|
+
});
|
|
65
41
|
|
|
66
|
-
|
|
42
|
+
['nowrap', 'truncate', 'breakWord'].forEach((wrap) => {
|
|
43
|
+
test(`Renders with class ${styles.modifiers[wrap]} when wrapModifier = ${wrap} is pased`, () => {
|
|
44
|
+
render(<DataList aria-label="list" wrapModifier={wrap as 'nowrap' | 'truncate' | 'breakWord'} />);
|
|
45
|
+
expect(screen.getByLabelText('list')).toHaveClass(styles.modifiers[wrap]);
|
|
67
46
|
});
|
|
47
|
+
});
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
expect(
|
|
49
|
+
const gridBreakpointClasses = {
|
|
50
|
+
none: styles.modifiers.gridNone,
|
|
51
|
+
always: 'pf-m-grid',
|
|
52
|
+
sm: styles.modifiers.gridSm,
|
|
53
|
+
md: styles.modifiers.gridMd,
|
|
54
|
+
lg: styles.modifiers.gridLg,
|
|
55
|
+
xl: styles.modifiers.gridXl,
|
|
56
|
+
'2xl': styles.modifiers.grid_2xl
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
['none', 'always', 'sm', 'md', 'lg', 'xl', '2xl'].forEach((oneBreakpoint) => {
|
|
60
|
+
test(`Has breakpoint - ${oneBreakpoint} when gridBreakpoint is pased`, () => {
|
|
61
|
+
render(<DataList aria-label="list" gridBreakpoint={oneBreakpoint as any} />);
|
|
62
|
+
expect(screen.getByLabelText('list')).toHaveClass(gridBreakpointClasses[oneBreakpoint]);
|
|
83
63
|
});
|
|
64
|
+
});
|
|
84
65
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
render(
|
|
90
|
-
<DataList aria-label="this is a simple list" onSelectableRowChange={mock} selectedDataListItemId="">
|
|
91
|
-
<DataListItem id="item-test-id">
|
|
92
|
-
<DataListItemRow aria-labelledby="test-id">
|
|
93
|
-
<p id="test-id">Test</p>
|
|
94
|
-
</DataListItemRow>
|
|
95
|
-
</DataListItem>
|
|
96
|
-
</DataList>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
100
|
-
await user.click(selectableInput);
|
|
66
|
+
test(`Renders default class ${styles.dataList}`, () => {
|
|
67
|
+
render(<DataList key="list-id-1" aria-label="list" />);
|
|
68
|
+
expect(screen.getByLabelText('list')).toHaveClass(styles.dataList);
|
|
69
|
+
});
|
|
101
70
|
|
|
102
|
-
|
|
103
|
-
|
|
71
|
+
test('Renders custom class when passed', () => {
|
|
72
|
+
render(<DataList key="list-id-1" className="data-list-custom" aria-label="list" />);
|
|
73
|
+
expect(screen.getByLabelText('list')).toHaveClass('data-list-custom');
|
|
74
|
+
});
|
|
104
75
|
|
|
105
|
-
|
|
106
|
-
|
|
76
|
+
test('Renders with a hidden input to improve a11y when onSelectableRowChange is passed', () => {
|
|
77
|
+
render(
|
|
78
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
79
|
+
<DataListItem>
|
|
80
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
81
|
+
<p id="test-id">Test</p>
|
|
82
|
+
</DataListItemRow>
|
|
83
|
+
</DataListItem>
|
|
84
|
+
</DataList>
|
|
85
|
+
);
|
|
107
86
|
|
|
108
|
-
|
|
109
|
-
<DataList aria-label="this is a simple list" onSelectableRowChange={mock} selectedDataListItemId="">
|
|
110
|
-
<DataListItem id="item-test-id">
|
|
111
|
-
<DataListItemRow aria-labelledby="test-id">
|
|
112
|
-
<p id="test-id">Test</p>
|
|
113
|
-
</DataListItemRow>
|
|
114
|
-
</DataListItem>
|
|
115
|
-
</DataList>
|
|
116
|
-
);
|
|
87
|
+
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
117
88
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
test('Item applies selectableInputAriaLabel to the hidden input', () => {
|
|
122
|
-
render(
|
|
123
|
-
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
124
|
-
<DataListItem selectableInputAriaLabel="Data list item label test">
|
|
125
|
-
<DataListItemRow aria-labelledby="test-id">
|
|
126
|
-
<p id="test-id">Test</p>
|
|
127
|
-
</DataListItemRow>
|
|
128
|
-
</DataListItem>
|
|
129
|
-
</DataList>
|
|
130
|
-
);
|
|
89
|
+
expect(selectableInput).toBeInTheDocument();
|
|
90
|
+
});
|
|
131
91
|
|
|
132
|
-
|
|
92
|
+
test('Does not render with a hidden input to improve a11y when onSelectableRowChange is not passed', () => {
|
|
93
|
+
render(
|
|
94
|
+
<DataList aria-label="this is a simple list">
|
|
95
|
+
<DataListItem>
|
|
96
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
97
|
+
<p id="test-id">Test</p>
|
|
98
|
+
</DataListItemRow>
|
|
99
|
+
</DataListItem>
|
|
100
|
+
</DataList>
|
|
101
|
+
);
|
|
133
102
|
|
|
134
|
-
|
|
135
|
-
});
|
|
103
|
+
const selectableInput = screen.queryByRole('radio', { hidden: true });
|
|
136
104
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
140
|
-
<DataListItem aria-labelledby="test-id">
|
|
141
|
-
<p id="test-id">Test cell content</p>
|
|
142
|
-
</DataListItem>
|
|
143
|
-
</DataList>
|
|
144
|
-
);
|
|
105
|
+
expect(selectableInput).not.toBeInTheDocument();
|
|
106
|
+
});
|
|
145
107
|
|
|
146
|
-
|
|
108
|
+
test('Calls onSelectableRowChange when the selectable input changes', async () => {
|
|
109
|
+
const mock = jest.fn();
|
|
110
|
+
const user = userEvent.setup();
|
|
147
111
|
|
|
148
|
-
|
|
149
|
-
|
|
112
|
+
render(
|
|
113
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={mock} selectedDataListItemId="">
|
|
114
|
+
<DataListItem id="item-test-id">
|
|
115
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
116
|
+
<p id="test-id">Test</p>
|
|
117
|
+
</DataListItemRow>
|
|
118
|
+
</DataListItem>
|
|
119
|
+
</DataList>
|
|
120
|
+
);
|
|
150
121
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
154
|
-
<DataListItem aria-labelledby="test-id" selectableInputAriaLabel="Data list item label test">
|
|
155
|
-
<p id="test-id">Test cell content</p>
|
|
156
|
-
</DataListItem>
|
|
157
|
-
</DataList>
|
|
158
|
-
);
|
|
122
|
+
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
123
|
+
await user.click(selectableInput);
|
|
159
124
|
|
|
160
|
-
|
|
125
|
+
expect(mock).toHaveBeenCalled();
|
|
126
|
+
});
|
|
161
127
|
|
|
162
|
-
|
|
163
|
-
|
|
128
|
+
test('Does not call onSelectableRowChange when the selectable input is not changed', () => {
|
|
129
|
+
const mock = jest.fn();
|
|
164
130
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<DataListItem
|
|
168
|
-
test
|
|
131
|
+
render(
|
|
132
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={mock} selectedDataListItemId="">
|
|
133
|
+
<DataListItem id="item-test-id">
|
|
134
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
135
|
+
<p id="test-id">Test</p>
|
|
136
|
+
</DataListItemRow>
|
|
169
137
|
</DataListItem>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
138
|
+
</DataList>
|
|
139
|
+
);
|
|
173
140
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<DataListItem aria-labelledby="item-1" isExpanded>
|
|
177
|
-
test
|
|
178
|
-
</DataListItem>
|
|
179
|
-
);
|
|
180
|
-
expect(screen.getByRole('listitem')).toHaveClass(`${styles.dataListItem} ${styles.modifiers.expanded}`);
|
|
181
|
-
});
|
|
141
|
+
expect(mock).not.toHaveBeenCalled();
|
|
142
|
+
});
|
|
182
143
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
144
|
+
test('Applies selectableInputAriaLabel to the hidden input', () => {
|
|
145
|
+
render(
|
|
146
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
147
|
+
<DataListItem selectableInputAriaLabel="Data list item label test">
|
|
148
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
149
|
+
<p id="test-id">Test</p>
|
|
150
|
+
</DataListItemRow>
|
|
187
151
|
</DataListItem>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
test('item row default', () => {
|
|
193
|
-
const { asFragment } = render(<DataListItemRow>test</DataListItemRow>);
|
|
194
|
-
expect(asFragment()).toMatchSnapshot();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test('Cell default', () => {
|
|
198
|
-
const { asFragment } = render(<DataListCell>Secondary</DataListCell>);
|
|
199
|
-
expect(asFragment()).toMatchSnapshot();
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test('Cells', () => {
|
|
203
|
-
const { asFragment } = render(
|
|
204
|
-
<DataListItemCells
|
|
205
|
-
dataListCells={[
|
|
206
|
-
<DataListCell key="list-id-1" id="primary-item" className="data-list-custom">
|
|
207
|
-
Primary Id
|
|
208
|
-
</DataListCell>,
|
|
209
|
-
<DataListCell key="list-id-2" id="primary-item" className="data-list-custom">
|
|
210
|
-
Primary Id 2
|
|
211
|
-
</DataListCell>
|
|
212
|
-
]}
|
|
213
|
-
/>
|
|
214
|
-
);
|
|
215
|
-
expect(asFragment()).toMatchSnapshot();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('Cell with width modifier', () => {
|
|
219
|
-
[
|
|
220
|
-
{ width: 1, class: '' },
|
|
221
|
-
{ width: 2, class: 'pf-m-flex-2' },
|
|
222
|
-
{ width: 3, class: 'pf-m-flex-3' },
|
|
223
|
-
{ width: 4, class: 'pf-m-flex-4' },
|
|
224
|
-
{ width: 5, class: 'pf-m-flex-5' }
|
|
225
|
-
].forEach((testCase, index) => {
|
|
226
|
-
const testId = `cell-test-id-${index}`;
|
|
227
|
-
|
|
228
|
-
render(
|
|
229
|
-
<DataListCell data-testid={testId} width={testCase.width as any} key={index}>
|
|
230
|
-
Primary Id
|
|
231
|
-
</DataListCell>
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const dataListCell = screen.getByTestId(testId);
|
|
235
|
-
|
|
236
|
-
testCase.class === ''
|
|
237
|
-
? expect(dataListCell).toHaveClass(styles.dataListCell)
|
|
238
|
-
: expect(dataListCell).toHaveClass(`${styles.dataListCell} ${testCase.class}`);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
152
|
+
</DataList>
|
|
153
|
+
);
|
|
241
154
|
|
|
242
|
-
|
|
243
|
-
[
|
|
244
|
-
{ wrapModifier: null as any, class: '' },
|
|
245
|
-
{ wrapModifier: 'breakWord', class: 'pf-m-break-word' },
|
|
246
|
-
{ wrapModifier: 'nowrap', class: 'pf-m-nowrap' },
|
|
247
|
-
{ wrapModifier: 'truncate', class: 'pf-m-truncate' }
|
|
248
|
-
].forEach((testCase, index) => {
|
|
249
|
-
const testId = `cell-test-id-${index}`;
|
|
250
|
-
|
|
251
|
-
render(
|
|
252
|
-
<DataListCell data-testid={testId} wrapModifier={testCase.wrapModifier} key={index}>
|
|
253
|
-
Primary Id
|
|
254
|
-
</DataListCell>
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
const dataListCell = screen.getByTestId(testId);
|
|
258
|
-
|
|
259
|
-
testCase.class === ''
|
|
260
|
-
? expect(dataListCell).toHaveClass(styles.dataListCell)
|
|
261
|
-
: expect(dataListCell).toHaveClass(`${styles.dataListCell} ${testCase.class}`);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
test('Toggle default with aria label', () => {
|
|
266
|
-
render(<DataListToggle aria-label="Toggle details for" id="ex-toggle2" />);
|
|
155
|
+
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
267
156
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false');
|
|
271
|
-
});
|
|
157
|
+
expect(selectableInput).toHaveAccessibleName('Data list item label test');
|
|
158
|
+
});
|
|
272
159
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
160
|
+
test('Defaults to labelling its input using its aria-labelledby prop', () => {
|
|
161
|
+
render(
|
|
162
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
163
|
+
<DataListItem aria-labelledby="test-id">
|
|
164
|
+
<p id="test-id">Test cell content</p>
|
|
165
|
+
</DataListItem>
|
|
166
|
+
</DataList>
|
|
167
|
+
);
|
|
277
168
|
|
|
278
|
-
|
|
279
|
-
const { asFragment } = render(
|
|
280
|
-
<DataListAction aria-label="Actions" aria-labelledby="ex-action" id="ex-action" isPlainButtonAction>
|
|
281
|
-
<Dropdown toggle={(toggleRef) => <MenuToggle ref={toggleRef} />}>
|
|
282
|
-
<DropdownList>
|
|
283
|
-
<DropdownItem onClick={jest.fn()} key="action-1">
|
|
284
|
-
action-1
|
|
285
|
-
</DropdownItem>
|
|
286
|
-
,
|
|
287
|
-
<DropdownItem onClick={jest.fn()} key="action-2">
|
|
288
|
-
action-2
|
|
289
|
-
</DropdownItem>
|
|
290
|
-
</DropdownList>
|
|
291
|
-
</Dropdown>
|
|
292
|
-
</DataListAction>
|
|
293
|
-
);
|
|
294
|
-
expect(asFragment()).toMatchSnapshot();
|
|
295
|
-
});
|
|
169
|
+
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
296
170
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
<DataListAction aria-label="Actions" aria-labelledby="ex-action" id="ex-action">
|
|
300
|
-
<Button id="delete-item-1">Delete</Button>
|
|
301
|
-
</DataListAction>
|
|
302
|
-
);
|
|
303
|
-
expect(asFragment()).toMatchSnapshot();
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
test('DataListAction visibility - show button when lg', () => {
|
|
307
|
-
render(
|
|
308
|
-
<DataListAction
|
|
309
|
-
visibility={{ default: 'hidden', lg: 'visible' }}
|
|
310
|
-
aria-labelledby="check-action-item2 check-action-action2"
|
|
311
|
-
id="check-action-action2"
|
|
312
|
-
aria-label="Actions"
|
|
313
|
-
>
|
|
314
|
-
<Button variant="primary">Primary</Button>
|
|
315
|
-
</DataListAction>
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
expect(screen.getByRole('button').parentElement).toHaveClass('pf-m-hidden');
|
|
319
|
-
expect(screen.getByRole('button').parentElement).toHaveClass('pf-m-visible-on-lg');
|
|
320
|
-
});
|
|
171
|
+
expect(selectableInput).toHaveAccessibleName('Test cell content');
|
|
172
|
+
});
|
|
321
173
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
<Button variant="primary">Primary</Button>
|
|
331
|
-
</DataListAction>
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
expect(screen.getByRole('button').parentElement).toHaveClass('pf-m-hidden-on-2xl');
|
|
335
|
-
});
|
|
174
|
+
test('Prioritizes selectableInputAriaLabel over aria-labelledby prop', () => {
|
|
175
|
+
render(
|
|
176
|
+
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
|
|
177
|
+
<DataListItem aria-labelledby="test-id" selectableInputAriaLabel="Data list item label test">
|
|
178
|
+
<p id="test-id">Test cell content</p>
|
|
179
|
+
</DataListItem>
|
|
180
|
+
</DataList>
|
|
181
|
+
);
|
|
336
182
|
|
|
337
|
-
|
|
338
|
-
const { asFragment } = render(<DataListContent aria-label="Primary Content Details"> test</DataListContent>);
|
|
339
|
-
expect(asFragment()).toMatchSnapshot();
|
|
340
|
-
});
|
|
183
|
+
const selectableInput = screen.getByRole('radio', { hidden: true });
|
|
341
184
|
|
|
342
|
-
|
|
343
|
-
const { asFragment } = render(
|
|
344
|
-
<DataListContent aria-label="Primary Content Details" hidden hasNoPadding>
|
|
345
|
-
test
|
|
346
|
-
</DataListContent>
|
|
347
|
-
);
|
|
348
|
-
expect(asFragment()).toMatchSnapshot();
|
|
349
|
-
});
|
|
185
|
+
expect(selectableInput).toHaveAccessibleName('Data list item label test');
|
|
350
186
|
});
|