@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.
Files changed (202) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/components/package.json +1 -1
  3. package/deprecated/package.json +1 -1
  4. package/dist/dynamic/components/AboutModal/package.json +1 -1
  5. package/dist/dynamic/components/Accordion/package.json +1 -1
  6. package/dist/dynamic/components/ActionList/package.json +1 -1
  7. package/dist/dynamic/components/Alert/package.json +1 -1
  8. package/dist/dynamic/components/Avatar/package.json +1 -1
  9. package/dist/dynamic/components/BackToTop/package.json +1 -1
  10. package/dist/dynamic/components/Backdrop/package.json +1 -1
  11. package/dist/dynamic/components/BackgroundImage/package.json +1 -1
  12. package/dist/dynamic/components/Badge/package.json +1 -1
  13. package/dist/dynamic/components/Banner/package.json +1 -1
  14. package/dist/dynamic/components/Brand/package.json +1 -1
  15. package/dist/dynamic/components/Breadcrumb/package.json +1 -1
  16. package/dist/dynamic/components/Button/package.json +1 -1
  17. package/dist/dynamic/components/CalendarMonth/package.json +1 -1
  18. package/dist/dynamic/components/Card/package.json +1 -1
  19. package/dist/dynamic/components/Checkbox/package.json +1 -1
  20. package/dist/dynamic/components/Chip/package.json +1 -1
  21. package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
  22. package/dist/dynamic/components/CodeBlock/package.json +1 -1
  23. package/dist/dynamic/components/DataList/package.json +1 -1
  24. package/dist/dynamic/components/DatePicker/package.json +1 -1
  25. package/dist/dynamic/components/DescriptionList/package.json +1 -1
  26. package/dist/dynamic/components/Divider/package.json +1 -1
  27. package/dist/dynamic/components/DragDrop/package.json +1 -1
  28. package/dist/dynamic/components/Drawer/package.json +1 -1
  29. package/dist/dynamic/components/Dropdown/package.json +1 -1
  30. package/dist/dynamic/components/DualListSelector/package.json +1 -1
  31. package/dist/dynamic/components/EmptyState/package.json +1 -1
  32. package/dist/dynamic/components/ExpandableSection/package.json +1 -1
  33. package/dist/dynamic/components/FileUpload/package.json +1 -1
  34. package/dist/dynamic/components/Form/package.json +1 -1
  35. package/dist/dynamic/components/FormSelect/package.json +1 -1
  36. package/dist/dynamic/components/HelperText/package.json +1 -1
  37. package/dist/dynamic/components/Hint/package.json +1 -1
  38. package/dist/dynamic/components/Icon/package.json +1 -1
  39. package/dist/dynamic/components/InputGroup/package.json +1 -1
  40. package/dist/dynamic/components/JumpLinks/package.json +1 -1
  41. package/dist/dynamic/components/Label/package.json +1 -1
  42. package/dist/dynamic/components/List/package.json +1 -1
  43. package/dist/dynamic/components/LoginPage/package.json +1 -1
  44. package/dist/dynamic/components/Masthead/package.json +1 -1
  45. package/dist/dynamic/components/Menu/package.json +1 -1
  46. package/dist/dynamic/components/MenuToggle/package.json +1 -1
  47. package/dist/dynamic/components/Modal/package.json +1 -1
  48. package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
  49. package/dist/dynamic/components/Nav/package.json +1 -1
  50. package/dist/dynamic/components/NotificationBadge/package.json +1 -1
  51. package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
  52. package/dist/dynamic/components/NumberInput/package.json +1 -1
  53. package/dist/dynamic/components/OverflowMenu/package.json +1 -1
  54. package/dist/dynamic/components/Page/package.json +1 -1
  55. package/dist/dynamic/components/Pagination/package.json +1 -1
  56. package/dist/dynamic/components/Panel/package.json +1 -1
  57. package/dist/dynamic/components/Popover/package.json +1 -1
  58. package/dist/dynamic/components/Progress/package.json +1 -1
  59. package/dist/dynamic/components/ProgressStepper/package.json +1 -1
  60. package/dist/dynamic/components/Radio/package.json +1 -1
  61. package/dist/dynamic/components/SearchInput/package.json +1 -1
  62. package/dist/dynamic/components/Select/package.json +1 -1
  63. package/dist/dynamic/components/Sidebar/package.json +1 -1
  64. package/dist/dynamic/components/SimpleList/package.json +1 -1
  65. package/dist/dynamic/components/Skeleton/package.json +1 -1
  66. package/dist/dynamic/components/SkipToContent/package.json +1 -1
  67. package/dist/dynamic/components/Slider/package.json +1 -1
  68. package/dist/dynamic/components/Spinner/package.json +1 -1
  69. package/dist/dynamic/components/Switch/package.json +1 -1
  70. package/dist/dynamic/components/Tabs/package.json +1 -1
  71. package/dist/dynamic/components/Text/package.json +1 -1
  72. package/dist/dynamic/components/TextArea/package.json +1 -1
  73. package/dist/dynamic/components/TextInput/package.json +1 -1
  74. package/dist/dynamic/components/TextInputGroup/package.json +1 -1
  75. package/dist/dynamic/components/Tile/package.json +1 -1
  76. package/dist/dynamic/components/TimePicker/package.json +1 -1
  77. package/dist/dynamic/components/Timestamp/package.json +1 -1
  78. package/dist/dynamic/components/Title/package.json +1 -1
  79. package/dist/dynamic/components/ToggleGroup/package.json +1 -1
  80. package/dist/dynamic/components/Toolbar/package.json +1 -1
  81. package/dist/dynamic/components/Tooltip/package.json +1 -1
  82. package/dist/dynamic/components/TreeView/package.json +1 -1
  83. package/dist/dynamic/components/Truncate/package.json +1 -1
  84. package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
  85. package/dist/dynamic/components/Wizard/package.json +1 -1
  86. package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
  87. package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
  88. package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
  89. package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
  90. package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
  91. package/dist/dynamic/deprecated/components/Select/package.json +1 -1
  92. package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
  93. package/dist/dynamic/deprecated/components/package.json +1 -1
  94. package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
  95. package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
  96. package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
  97. package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
  98. package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
  99. package/dist/dynamic/helpers/constants/package.json +1 -1
  100. package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
  101. package/dist/dynamic/helpers/favorites/package.json +1 -1
  102. package/dist/dynamic/helpers/fileUtils/package.json +1 -1
  103. package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
  104. package/dist/dynamic/helpers/package.json +1 -1
  105. package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
  106. package/dist/dynamic/helpers/typeUtils/package.json +1 -1
  107. package/dist/dynamic/helpers/useInterval/package.json +1 -1
  108. package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
  109. package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
  110. package/dist/dynamic/helpers/util/package.json +1 -1
  111. package/dist/dynamic/layouts/Bullseye/package.json +1 -1
  112. package/dist/dynamic/layouts/Flex/package.json +1 -1
  113. package/dist/dynamic/layouts/Gallery/package.json +1 -1
  114. package/dist/dynamic/layouts/Grid/package.json +1 -1
  115. package/dist/dynamic/layouts/Level/package.json +1 -1
  116. package/dist/dynamic/layouts/Split/package.json +1 -1
  117. package/dist/dynamic/layouts/Stack/package.json +1 -1
  118. package/dist/dynamic/next/components/package.json +1 -1
  119. package/dist/esm/components/Chip/Chip.d.ts +1 -0
  120. package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
  121. package/dist/esm/components/Chip/Chip.js +8 -0
  122. package/dist/esm/components/Chip/Chip.js.map +1 -1
  123. package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
  124. package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
  125. package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
  126. package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
  127. package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
  128. package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
  129. package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
  130. package/dist/esm/components/DataList/DataList.js +2 -2
  131. package/dist/esm/components/DataList/DataList.js.map +1 -1
  132. package/dist/esm/components/DataList/DataListAction.js +3 -3
  133. package/dist/esm/components/DataList/DataListAction.js.map +1 -1
  134. package/dist/esm/components/DatePicker/DatePicker.js +1 -1
  135. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  136. package/dist/js/components/Chip/Chip.d.ts +1 -0
  137. package/dist/js/components/Chip/Chip.d.ts.map +1 -1
  138. package/dist/js/components/Chip/Chip.js +8 -0
  139. package/dist/js/components/Chip/Chip.js.map +1 -1
  140. package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
  141. package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
  142. package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
  143. package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
  144. package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
  145. package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
  146. package/dist/js/components/DataList/DataList.d.ts.map +1 -1
  147. package/dist/js/components/DataList/DataList.js +2 -2
  148. package/dist/js/components/DataList/DataList.js.map +1 -1
  149. package/dist/js/components/DataList/DataListAction.js +3 -3
  150. package/dist/js/components/DataList/DataListAction.js.map +1 -1
  151. package/dist/js/components/DatePicker/DatePicker.js +1 -1
  152. package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
  153. package/dist/umd/react-core.min.js +1 -1
  154. package/helpers/package.json +1 -1
  155. package/layouts/package.json +1 -1
  156. package/next/package.json +1 -1
  157. package/package.json +2 -2
  158. package/src/components/Chip/Chip.tsx +11 -0
  159. package/src/components/ClipboardCopy/ClipboardCopy.tsx +5 -5
  160. package/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx +0 -1
  161. package/src/components/DataList/DataList.tsx +2 -0
  162. package/src/components/DataList/DataListAction.tsx +1 -1
  163. package/src/components/DataList/__tests__/DataList.test.tsx +140 -304
  164. package/src/components/DataList/__tests__/DataListAction.test.tsx +75 -0
  165. package/src/components/DataList/__tests__/DataListCell.test.tsx +120 -0
  166. package/src/components/DataList/__tests__/DataListCheck.test.tsx +5 -0
  167. package/src/components/DataList/__tests__/DataListContent.test.tsx +73 -0
  168. package/src/components/DataList/__tests__/DataListItem.test.tsx +46 -0
  169. package/src/components/DataList/__tests__/DataListItemCells.test.tsx +25 -0
  170. package/src/components/DataList/__tests__/DataListItemRow.test.tsx +44 -0
  171. package/src/components/DataList/__tests__/DataListToggle.test.tsx +61 -0
  172. package/src/components/DataList/__tests__/__snapshots__/DataList.test.tsx.snap +2 -323
  173. package/src/components/DataList/__tests__/__snapshots__/DataListAction.test.tsx.snap +11 -0
  174. package/src/components/DataList/__tests__/__snapshots__/DataListCell.test.tsx.snap +11 -0
  175. package/src/components/DataList/__tests__/__snapshots__/DataListContent.test.tsx.snap +17 -0
  176. package/src/components/DataList/__tests__/__snapshots__/DataListItem.test.tsx.snap +11 -0
  177. package/src/components/DataList/__tests__/__snapshots__/DataListItemCells.test.tsx.snap +9 -0
  178. package/src/components/DataList/__tests__/__snapshots__/DataListItemRow.test.tsx.snap +9 -0
  179. package/src/components/DataList/__tests__/__snapshots__/DataListToggle.test.tsx.snap +45 -0
  180. package/src/components/DataList/examples/DataListCheckboxes.tsx +5 -5
  181. package/src/components/DataList/examples/DataListMixedExpandable.tsx +1 -1
  182. package/src/components/DatePicker/DatePicker.tsx +1 -1
  183. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2 -2
  184. package/src/components/DescriptionList/__tests__/DescriptionList.test.tsx +128 -102
  185. package/src/components/DescriptionList/__tests__/DescriptionListDescription.test.tsx +25 -0
  186. package/src/components/DescriptionList/__tests__/DescriptionListGroup.test.tsx +25 -0
  187. package/src/components/DescriptionList/__tests__/DescriptionListHelpTextButton.test.tsx +27 -0
  188. package/src/components/DescriptionList/__tests__/DescriptionListTerm.test.tsx +35 -0
  189. package/src/components/DescriptionList/__tests__/DescriptionListTermHelpText.test.tsx +25 -0
  190. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionList.test.tsx.snap +1 -157
  191. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListDescription.test.tsx.snap +15 -0
  192. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListGroup.test.tsx.snap +11 -0
  193. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListHelpTextButton.test.tsx.snap +14 -0
  194. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTerm.test.tsx.snap +15 -0
  195. package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTermHelpText.test.tsx.snap +11 -0
  196. package/src/components/HelperText/__tests__/HelperText.test.tsx +67 -57
  197. package/src/components/HelperText/__tests__/HelperTextItem.test.tsx +93 -0
  198. package/src/components/HelperText/__tests__/__snapshots__/HelperText.test.tsx.snap +2 -223
  199. package/src/components/HelperText/__tests__/__snapshots__/HelperTextItem.test.tsx.snap +15 -0
  200. package/src/demos/CustomMenus/CustomMenus.md +6 -0
  201. package/src/demos/CustomMenus/examples/InlineSearchFilterMenuDemo.tsx +102 -0
  202. package/src/demos/SearchInput/SearchInput.md +1 -1
@@ -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.28","private":true}
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}
@@ -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.28","private":true}
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.28","private":true}
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.29",
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": "4f123b1aa89500ccaf0a4cac977dc2e5352cb75b"
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?: React.ReactNode) => {
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?: React.ReactNode) => void;
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: React.ReactNode;
79
- /** Additional actions for inline-compact clipboard copy. Should be wrapped with ClipboardCopyAction. */
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
- describe('DataList', () => {
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
- test('List compact', () => {
26
- const { asFragment } = render(<DataList aria-label="this is a simple list" isCompact />);
27
- expect(asFragment()).toMatchSnapshot();
28
- });
12
+ test('Renders to match snapshot', () => {
13
+ const { asFragment } = render(<DataList aria-label="list" />);
14
+ expect(asFragment()).toMatchSnapshot();
15
+ });
29
16
 
30
- describe('DataList variants', () => {
31
- ['none', 'always', 'sm', 'md', 'lg', 'xl', '2xl'].forEach((oneBreakpoint) => {
32
- test(`Breakpoint - ${oneBreakpoint}`, () => {
33
- const { asFragment } = render(
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
- test('List draggable', () => {
42
- const { asFragment } = render(<DataList aria-label="this is a simple list" isCompact onDragFinish={jest.fn()} />);
43
- expect(asFragment()).toMatchSnapshot();
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
- test('List', () => {
47
- const { asFragment } = render(
48
- <DataList key="list-id-1" className="data-list-custom" aria-label="this is a simple list" />
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
- test('List renders with a hidden input to improve a11y when selectableRow is passed', () => {
54
- render(
55
- <DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>
56
- <DataListItem>
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
- const selectableInput = screen.getByRole('radio', { hidden: true });
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
- expect(selectableInput).toBeInTheDocument();
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
- test('List does not render with a hidden input to improve a11y when selectableRow is not passed', () => {
70
- render(
71
- <DataList aria-label="this is a simple list">
72
- <DataListItem>
73
- <DataListItemRow aria-labelledby="test-id">
74
- <p id="test-id">Test</p>
75
- </DataListItemRow>
76
- </DataListItem>
77
- </DataList>
78
- );
79
-
80
- const selectableInput = screen.queryByRole('radio', { hidden: true });
81
-
82
- expect(selectableInput).not.toBeInTheDocument();
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
- test('List calls selectableRow.onChange when the selectable input changes', async () => {
86
- const mock = jest.fn();
87
- const user = userEvent.setup();
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
- expect(mock).toHaveBeenCalled();
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
- test('List does not call selectableRow.onChange when the selectable input is not changed', () => {
106
- const mock = jest.fn();
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
- render(
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
- expect(mock).not.toHaveBeenCalled();
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
- const selectableInput = screen.getByRole('radio', { hidden: true });
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
- expect(selectableInput).toHaveAccessibleName('Data list item label test');
135
- });
103
+ const selectableInput = screen.queryByRole('radio', { hidden: true });
136
104
 
137
- test('Item defaults to labelling its input using its aria-labelledby prop', () => {
138
- render(
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
- const selectableInput = screen.getByRole('radio', { hidden: true });
108
+ test('Calls onSelectableRowChange when the selectable input changes', async () => {
109
+ const mock = jest.fn();
110
+ const user = userEvent.setup();
147
111
 
148
- expect(selectableInput).toHaveAccessibleName('Test cell content');
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
- test('Item prioritizes selectableInputAriaLabel over aria-labelledby prop', () => {
152
- render(
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
- const selectableInput = screen.getByRole('radio', { hidden: true });
125
+ expect(mock).toHaveBeenCalled();
126
+ });
161
127
 
162
- expect(selectableInput).toHaveAccessibleName('Data list item label test');
163
- });
128
+ test('Does not call onSelectableRowChange when the selectable input is not changed', () => {
129
+ const mock = jest.fn();
164
130
 
165
- test('Item default', () => {
166
- const { asFragment } = render(
167
- <DataListItem key="item-id-1" aria-labelledby="item-1">
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
- expect(asFragment()).toMatchSnapshot();
172
- });
138
+ </DataList>
139
+ );
173
140
 
174
- test('Item expanded', () => {
175
- render(
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
- test('Item', () => {
184
- const { asFragment } = render(
185
- <DataListItem className="data-list-item-custom" aria-labelledby="item-1">
186
- test
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
- expect(asFragment()).toMatchSnapshot();
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
- test('Cell with text modifiers', () => {
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
- expect(screen.getByRole('button')).not.toHaveAttribute('aria-labelledby');
269
- expect(screen.getByRole('button')).toHaveAttribute('aria-label', 'Toggle details for');
270
- expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false');
271
- });
157
+ expect(selectableInput).toHaveAccessibleName('Data list item label test');
158
+ });
272
159
 
273
- test('Toggle expanded', () => {
274
- render(<DataListToggle aria-label="Toggle details for" id="ex-toggle2" isExpanded />);
275
- expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
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
- test('DataListAction dropdown', () => {
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
- test('DataListAction button', () => {
298
- const { asFragment } = render(
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
- test('DataListAction visibility - hide button on 2xl', () => {
323
- render(
324
- <DataListAction
325
- visibility={{ '2xl': 'hidden' }}
326
- aria-labelledby="check-action-item2 check-action-action2"
327
- id="check-action-action2"
328
- aria-label="Actions"
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
- test('DataListContent', () => {
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
- test('DataListContent hasNoPadding', () => {
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
  });