@patternfly/react-core 4.268.0 → 4.268.2

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 (55) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  3. package/components/LabelGroup/LabelGroup.js +4 -5
  4. package/components/LabelGroup/LabelGroup.js.map +1 -1
  5. package/components/SearchInput/AdvancedSearchMenu.d.ts +2 -2
  6. package/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
  7. package/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
  8. package/components/SearchInput/SearchInput.d.ts +5 -5
  9. package/components/SearchInput/SearchInput.d.ts.map +1 -1
  10. package/components/SearchInput/SearchInput.js +1 -1
  11. package/components/SearchInput/SearchInput.js.map +1 -1
  12. package/components/SimpleList/SimpleList.d.ts +2 -0
  13. package/components/SimpleList/SimpleList.d.ts.map +1 -1
  14. package/components/SimpleList/SimpleList.js +2 -2
  15. package/components/SimpleList/SimpleList.js.map +1 -1
  16. package/dist/esm/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  17. package/dist/esm/components/LabelGroup/LabelGroup.js +4 -5
  18. package/dist/esm/components/LabelGroup/LabelGroup.js.map +1 -1
  19. package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts +2 -2
  20. package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
  21. package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
  22. package/dist/esm/components/SearchInput/SearchInput.d.ts +5 -5
  23. package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
  24. package/dist/esm/components/SearchInput/SearchInput.js +1 -1
  25. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  26. package/dist/esm/components/SimpleList/SimpleList.d.ts +2 -0
  27. package/dist/esm/components/SimpleList/SimpleList.d.ts.map +1 -1
  28. package/dist/esm/components/SimpleList/SimpleList.js +2 -2
  29. package/dist/esm/components/SimpleList/SimpleList.js.map +1 -1
  30. package/dist/js/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  31. package/dist/js/components/LabelGroup/LabelGroup.js +4 -5
  32. package/dist/js/components/LabelGroup/LabelGroup.js.map +1 -1
  33. package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts +2 -2
  34. package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
  35. package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
  36. package/dist/js/components/SearchInput/SearchInput.d.ts +5 -5
  37. package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
  38. package/dist/js/components/SearchInput/SearchInput.js +1 -1
  39. package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
  40. package/dist/js/components/SimpleList/SimpleList.d.ts +2 -0
  41. package/dist/js/components/SimpleList/SimpleList.d.ts.map +1 -1
  42. package/dist/js/components/SimpleList/SimpleList.js +2 -2
  43. package/dist/js/components/SimpleList/SimpleList.js.map +1 -1
  44. package/dist/umd/react-core.min.js +2 -2
  45. package/package.json +2 -2
  46. package/src/components/LabelGroup/LabelGroup.tsx +4 -5
  47. package/src/components/SearchInput/AdvancedSearchMenu.tsx +3 -3
  48. package/src/components/SearchInput/SearchInput.tsx +6 -6
  49. package/src/components/SearchInput/__tests__/SearchInput.test.tsx +1 -1
  50. package/src/components/SearchInput/examples/SearchInput.md +1 -1
  51. package/src/components/SearchInput/examples/SearchInputWithExpandable.tsx +1 -1
  52. package/src/components/SimpleList/SimpleList.tsx +4 -2
  53. package/src/components/SimpleList/__tests__/SimpleList.test.tsx +5 -0
  54. package/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +43 -0
  55. package/dist/umd/react-core.min.css +0 -28293
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.268.0",
3
+ "version": "4.268.2",
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": "^16.8 || ^17 || ^18",
72
72
  "react-dom": "^16.8 || ^17 || ^18"
73
73
  },
74
- "gitHead": "4464f97977ce3984b4e589711f26993f1f64a23f"
74
+ "gitHead": "a25b3ab583bd808d640a1c7ebb14d9296d701b2b"
75
75
  }
@@ -156,15 +156,14 @@ export class LabelGroup extends React.Component<LabelGroupProps, LabelGroupState
156
156
  ...rest
157
157
  } = this.props;
158
158
  const { isOpen } = this.state;
159
- const numChildren = React.Children.count(children);
159
+ const renderedChildren = React.Children.toArray(children);
160
+ const numChildren = renderedChildren.length;
160
161
  const collapsedTextResult = fillTemplate(collapsedText as string, {
161
- remaining: React.Children.count(children) - numLabels
162
+ remaining: numChildren - numLabels
162
163
  });
163
164
 
164
165
  const renderLabelGroup = (id: string) => {
165
- const labelArray = !isOpen
166
- ? React.Children.toArray(children).slice(0, numLabels)
167
- : React.Children.toArray(children);
166
+ const labelArray = !isOpen ? renderedChildren.slice(0, numLabels) : renderedChildren;
168
167
 
169
168
  const content = (
170
169
  <React.Fragment>
@@ -3,7 +3,7 @@ import { Button } from '../Button';
3
3
  import { ActionGroup, Form, FormGroup } from '../Form';
4
4
  import { TextInput } from '../TextInput';
5
5
  import { GenerateId, KeyTypes } from '../../helpers';
6
- import { SearchAttribute } from './SearchInput';
6
+ import { SearchInputSearchAttribute } from './SearchInput';
7
7
  import { Panel, PanelMain, PanelMainBody } from '../Panel';
8
8
  import { css } from '@patternfly/react-styles';
9
9
 
@@ -13,7 +13,7 @@ export interface AdvancedSearchMenuProps extends Omit<React.HTMLProps<HTMLDivEle
13
13
  */
14
14
  advancedSearchDelimiter?: string;
15
15
  /** Array of attribute values used for dynamically generated advanced search. */
16
- attributes?: string[] | SearchAttribute[];
16
+ attributes?: string[] | SearchInputSearchAttribute[];
17
17
  /** Additional classes added to the advanced search menu. */
18
18
  className?: string;
19
19
  /* Additional elements added after the attributes in the form.
@@ -161,7 +161,7 @@ export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps
161
161
 
162
162
  const buildFormGroups = () => {
163
163
  const formGroups = [] as React.ReactNode[];
164
- attributes.forEach((attribute: string | SearchAttribute, index: number) => {
164
+ attributes.forEach((attribute: string | SearchInputSearchAttribute, index: number) => {
165
165
  const display = typeof attribute === 'string' ? attribute : attribute.display;
166
166
  const queryAttr = typeof attribute === 'string' ? attribute : attribute.attr;
167
167
  if (index === 0) {
@@ -17,7 +17,7 @@ import { Popper } from '../../helpers';
17
17
  * be passed in as an object within an array to the search input component's attribute properrty.
18
18
  */
19
19
 
20
- export interface SearchAttribute {
20
+ export interface SearchInputSearchAttribute {
21
21
  /** The search attribute's value to be provided in the search input's query string.
22
22
  * It should have no spaces and be unique for every attribute.
23
23
  */
@@ -32,11 +32,11 @@ export interface SearchAttribute {
32
32
  * the search input component's expandableInput property.
33
33
  */
34
34
 
35
- export interface ExpandableInput {
35
+ export interface SearchInputExpandable {
36
36
  /** Flag to indicate if the search input is expanded. */
37
37
  isExpanded: boolean;
38
38
  /** Callback function to toggle the expandable search input. */
39
- onToggleExpand: (isExpanded: boolean, event: React.SyntheticEvent<HTMLButtonElement>) => void;
39
+ onToggleExpand: (event: React.SyntheticEvent<HTMLButtonElement>, isExpanded: boolean) => void;
40
40
  /** An accessible label for the expandable search input toggle. */
41
41
  toggleAriaLabel: string;
42
42
  }
@@ -58,11 +58,11 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
58
58
  /** An accessible label for the search input. */
59
59
  'aria-label'?: string;
60
60
  /** Array of attribute values used for dynamically generated advanced search. */
61
- attributes?: string[] | SearchAttribute[];
61
+ attributes?: string[] | SearchInputSearchAttribute[];
62
62
  /** Additional classes added to the search input. */
63
63
  className?: string;
64
64
  /** Object that makes the search input expandable/collapsible. */
65
- expandableInput?: ExpandableInput;
65
+ expandableInput?: SearchInputExpandable;
66
66
  /* Additional elements added after the attributes in the form.
67
67
  * The new form elements can be wrapped in a form group component for automatic formatting. */
68
68
  formAdditionalItems?: React.ReactNode;
@@ -285,7 +285,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
285
285
 
286
286
  const onExpandHandler = (event: React.SyntheticEvent<HTMLButtonElement>) => {
287
287
  setSearchValue('');
288
- onToggleExpand(isExpanded, event);
288
+ onToggleExpand(event, isExpanded);
289
289
  setFocusAfterExpandChange(true);
290
290
  };
291
291
 
@@ -239,7 +239,7 @@ test('onToggleExpand is called if the expandable toggle is clicked', async () =>
239
239
  await user.click(screen.getByRole('button'));
240
240
 
241
241
  expect(mockOnToggleExpand).toHaveBeenCalledTimes(1);
242
- expect(mockOnToggleExpand).toHaveBeenCalledWith(true, expect.objectContaining({ type: 'click' }));
242
+ expect(mockOnToggleExpand).toHaveBeenCalledWith(expect.objectContaining({ type: 'click' }), true);
243
243
  });
244
244
 
245
245
  test('toggleAriaLabel is applied to the expandable toggle', () => {
@@ -2,7 +2,7 @@
2
2
  id: 'Search input'
3
3
  section: components
4
4
  cssPrefix: 'pf-c-search-input'
5
- propComponents: ['SearchInput', 'SearchAttribute', 'ExpandableInput']
5
+ propComponents: ['SearchInput', 'SearchInputSearchAttribute', 'SearchInputExpandable']
6
6
  beta: true
7
7
  ---
8
8
 
@@ -9,7 +9,7 @@ export const SearchInputWithExpandable: React.FunctionComponent = () => {
9
9
  setValue(value);
10
10
  };
11
11
 
12
- const onToggleExpand = (isExpanded: boolean) => {
12
+ const onToggleExpand = (_event: React.SyntheticEvent<HTMLButtonElement>, isExpanded: boolean) => {
13
13
  setIsExpanded(!isExpanded);
14
14
  };
15
15
 
@@ -16,6 +16,8 @@ export interface SimpleListProps extends Omit<React.HTMLProps<HTMLDivElement>, '
16
16
  ) => void;
17
17
  /** Indicates whether component is controlled by its internal state */
18
18
  isControlled?: boolean;
19
+ /** aria-label for the <ul> element that wraps the SimpleList items. */
20
+ 'aria-label'?: string;
19
21
  }
20
22
 
21
23
  export interface SimpleListState {
@@ -57,7 +59,7 @@ export class SimpleList extends React.Component<SimpleListProps, SimpleListState
57
59
 
58
60
  render() {
59
61
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
- const { children, className, onSelect, isControlled, ...props } = this.props;
62
+ const { children, className, onSelect, isControlled, 'aria-label': ariaLabel, ...props } = this.props;
61
63
 
62
64
  let isGrouped = false;
63
65
  if (children) {
@@ -74,7 +76,7 @@ export class SimpleList extends React.Component<SimpleListProps, SimpleListState
74
76
  >
75
77
  <div className={css(styles.simpleList, className)} {...props}>
76
78
  {isGrouped && children}
77
- {!isGrouped && <ul>{children}</ul>}
79
+ {!isGrouped && <ul aria-label={ariaLabel}>{children}</ul>}
78
80
  </div>
79
81
  </SimpleListContext.Provider>
80
82
  );
@@ -31,6 +31,11 @@ describe('SimpleList', () => {
31
31
  expect(asFragment()).toMatchSnapshot();
32
32
  });
33
33
 
34
+ test('renders aria-labelled content', () => {
35
+ const { asFragment } = render(<SimpleList aria-label="This is a simple list">{items}</SimpleList>);
36
+ expect(asFragment()).toMatchSnapshot();
37
+ });
38
+
34
39
  test('renders grouped content', () => {
35
40
  const { asFragment } = render(
36
41
  <SimpleList>
@@ -1,5 +1,48 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`SimpleList renders aria-labelled content 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-simple-list"
7
+ >
8
+ <ul
9
+ aria-label="This is a simple list"
10
+ >
11
+ <li
12
+ class=""
13
+ >
14
+ <button
15
+ class="pf-c-simple-list__item-link"
16
+ type="button"
17
+ >
18
+ Item 1
19
+ </button>
20
+ </li>
21
+ <li
22
+ class=""
23
+ >
24
+ <button
25
+ class="pf-c-simple-list__item-link"
26
+ type="button"
27
+ >
28
+ Item 2
29
+ </button>
30
+ </li>
31
+ <li
32
+ class=""
33
+ >
34
+ <button
35
+ class="pf-c-simple-list__item-link"
36
+ type="button"
37
+ >
38
+ Item 3
39
+ </button>
40
+ </li>
41
+ </ul>
42
+ </div>
43
+ </DocumentFragment>
44
+ `;
45
+
3
46
  exports[`SimpleList renders content 1`] = `
4
47
  <DocumentFragment>
5
48
  <div