@patternfly/react-core 4.235.6 → 4.236.0

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 (86) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/DualListSelector/DualListSelectorControl.d.ts.map +1 -1
  3. package/dist/esm/components/DualListSelector/DualListSelectorControl.js +2 -1
  4. package/dist/esm/components/DualListSelector/DualListSelectorControl.js.map +1 -1
  5. package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.d.ts.map +1 -1
  6. package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.js +2 -1
  7. package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.js.map +1 -1
  8. package/dist/esm/components/DualListSelector/DualListSelectorListItem.d.ts.map +1 -1
  9. package/dist/esm/components/DualListSelector/DualListSelectorListItem.js +2 -1
  10. package/dist/esm/components/DualListSelector/DualListSelectorListItem.js.map +1 -1
  11. package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.d.ts.map +1 -1
  12. package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.js +2 -1
  13. package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.js.map +1 -1
  14. package/dist/esm/components/InputGroup/InputGroup.d.ts.map +1 -1
  15. package/dist/esm/components/InputGroup/InputGroup.js +2 -1
  16. package/dist/esm/components/InputGroup/InputGroup.js.map +1 -1
  17. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  18. package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
  19. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  20. package/dist/esm/components/Page/PageSection.d.ts +2 -0
  21. package/dist/esm/components/Page/PageSection.d.ts.map +1 -1
  22. package/dist/esm/components/Page/PageSection.js +3 -2
  23. package/dist/esm/components/Page/PageSection.js.map +1 -1
  24. package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
  25. package/dist/esm/components/SearchInput/SearchInput.js +2 -1
  26. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  27. package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
  28. package/dist/esm/components/TextInputGroup/TextInputGroup.js +2 -1
  29. package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -1
  30. package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
  31. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +2 -1
  32. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
  33. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  34. package/dist/esm/next/components/Wizard/WizardToggle.js +32 -31
  35. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
  36. package/dist/js/components/DualListSelector/DualListSelectorControl.d.ts.map +1 -1
  37. package/dist/js/components/DualListSelector/DualListSelectorControl.js +2 -1
  38. package/dist/js/components/DualListSelector/DualListSelectorControl.js.map +1 -1
  39. package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.d.ts.map +1 -1
  40. package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.js +2 -1
  41. package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.js.map +1 -1
  42. package/dist/js/components/DualListSelector/DualListSelectorListItem.d.ts.map +1 -1
  43. package/dist/js/components/DualListSelector/DualListSelectorListItem.js +2 -1
  44. package/dist/js/components/DualListSelector/DualListSelectorListItem.js.map +1 -1
  45. package/dist/js/components/DualListSelector/DualListSelectorListWrapper.d.ts.map +1 -1
  46. package/dist/js/components/DualListSelector/DualListSelectorListWrapper.js +2 -1
  47. package/dist/js/components/DualListSelector/DualListSelectorListWrapper.js.map +1 -1
  48. package/dist/js/components/InputGroup/InputGroup.d.ts.map +1 -1
  49. package/dist/js/components/InputGroup/InputGroup.js +2 -1
  50. package/dist/js/components/InputGroup/InputGroup.js.map +1 -1
  51. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  52. package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
  53. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  54. package/dist/js/components/Page/PageSection.d.ts +2 -0
  55. package/dist/js/components/Page/PageSection.d.ts.map +1 -1
  56. package/dist/js/components/Page/PageSection.js +3 -2
  57. package/dist/js/components/Page/PageSection.js.map +1 -1
  58. package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
  59. package/dist/js/components/SearchInput/SearchInput.js +2 -1
  60. package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
  61. package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
  62. package/dist/js/components/TextInputGroup/TextInputGroup.js +2 -1
  63. package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -1
  64. package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
  65. package/dist/js/components/TextInputGroup/TextInputGroupMain.js +2 -1
  66. package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
  67. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  68. package/dist/js/next/components/Wizard/WizardToggle.js +32 -31
  69. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
  70. package/dist/umd/react-core.min.css +1337 -1337
  71. package/dist/umd/react-core.min.js +2 -2
  72. package/package.json +5 -5
  73. package/src/components/Dropdown/__tests__/Dropdown.test.tsx +1 -1
  74. package/src/components/Dropdown/examples/DropdownPrimaryToggle.tsx +1 -1
  75. package/src/components/DualListSelector/DualListSelectorControl.tsx +2 -1
  76. package/src/components/DualListSelector/DualListSelectorControlsWrapper.tsx +2 -1
  77. package/src/components/DualListSelector/DualListSelectorListItem.tsx +2 -1
  78. package/src/components/DualListSelector/DualListSelectorListWrapper.tsx +2 -1
  79. package/src/components/InputGroup/InputGroup.tsx +2 -1
  80. package/src/components/MenuToggle/MenuToggle.tsx +7 -1
  81. package/src/components/Page/PageSection.tsx +7 -2
  82. package/src/components/Page/__tests__/PageSection.test.tsx +12 -0
  83. package/src/components/SearchInput/SearchInput.tsx +2 -1
  84. package/src/components/TextInputGroup/TextInputGroup.tsx +2 -1
  85. package/src/components/TextInputGroup/TextInputGroupMain.tsx +2 -1
  86. package/src/next/components/Wizard/WizardToggle.tsx +87 -85
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.235.6",
3
+ "version": "4.236.0",
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",
@@ -44,9 +44,9 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.86.6",
48
- "@patternfly/react-styles": "^4.85.6",
49
- "@patternfly/react-tokens": "^4.87.6",
47
+ "@patternfly/react-icons": "^4.87.0",
48
+ "@patternfly/react-styles": "^4.86.0",
49
+ "@patternfly/react-tokens": "^4.88.0",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "e688e3b26385dc09280dca250d72a733ce18b52a"
73
+ "gitHead": "a4b7c93b2fad078f13a177a886317bbb054f4922"
74
74
  }
@@ -106,7 +106,7 @@ describe('Dropdown', () => {
106
106
  <Dropdown
107
107
  dropdownItems={dropdownItems}
108
108
  toggle={
109
- <DropdownToggle id="Dropdown Toggle" isPrimary>
109
+ <DropdownToggle id="Dropdown Toggle" toggleVariant="primary">
110
110
  Dropdown
111
111
  </DropdownToggle>
112
112
  }
@@ -46,7 +46,7 @@ export const DropdownPrimaryToggle: React.FunctionComponent = () => {
46
46
  <Dropdown
47
47
  onSelect={onSelect}
48
48
  toggle={
49
- <DropdownToggle id="toggle-primary" isPrimary onToggle={onToggle}>
49
+ <DropdownToggle id="toggle-primary" toggleVariant="primary" onToggle={onToggle}>
50
50
  Dropdown
51
51
  </DropdownToggle>
52
52
  }
@@ -37,7 +37,8 @@ export const DualListSelectorControlBase: React.FunctionComponent<DualListSelect
37
37
  tooltipProps = {} as any,
38
38
  ...props
39
39
  }: DualListSelectorControlProps) => {
40
- const ref = innerRef || React.useRef(null);
40
+ const privateRef = React.useRef(null);
41
+ const ref = innerRef || privateRef;
41
42
  return (
42
43
  <div className={css('pf-c-dual-list-selector__controls-item', className)} {...props}>
43
44
  <Button
@@ -23,7 +23,8 @@ export const DualListSelectorControlsWrapperBase: React.FunctionComponent<DualLi
23
23
  'aria-label': ariaLabel = 'Controls for moving options between lists',
24
24
  ...props
25
25
  }: DualListSelectorControlsWrapperProps) => {
26
- const wrapperRef = innerRef || React.useRef(null);
26
+ const ref = React.useRef(null);
27
+ const wrapperRef = innerRef || ref;
27
28
  // Adds keyboard navigation to the dynamically built dual list selector controls. Works when controls are dynamically built
28
29
  // as well as when they are passed in via children.
29
30
  const handleKeys = (event: KeyboardEvent) => {
@@ -47,7 +47,8 @@ export const DualListSelectorListItemBase: React.FunctionComponent<DualListSelec
47
47
  draggableButtonAriaLabel = 'Reorder option',
48
48
  ...props
49
49
  }: DualListSelectorListItemProps) => {
50
- const ref = innerRef || React.useRef<HTMLLIElement>(null);
50
+ const privateRef = React.useRef<HTMLLIElement>(null);
51
+ const ref = innerRef || privateRef;
51
52
  const { setFocusedOption } = React.useContext(DualListSelectorListContext);
52
53
 
53
54
  return (
@@ -42,7 +42,8 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
42
42
  ...props
43
43
  }: DualListSelectorListWrapperProps) => {
44
44
  const [focusedOption, setFocusedOption] = React.useState('');
45
- const menuRef = innerRef || React.useRef(null);
45
+ const ref = React.useRef(null);
46
+ const menuRef = innerRef || ref;
46
47
  const { isTree } = React.useContext(DualListSelectorContext);
47
48
 
48
49
  // sets up keyboard focus handling for the dual list selector menu child of the pane. This keyboard
@@ -25,7 +25,8 @@ export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
25
25
  (child: any) => !formCtrls.includes(child.type.displayName) && child.props.id
26
26
  ) as React.ReactElement<{ id: string }>;
27
27
 
28
- const inputGroupRef = innerRef || React.useRef(null);
28
+ const ref = React.useRef(null);
29
+ const inputGroupRef = innerRef || ref;
29
30
 
30
31
  return (
31
32
  <div ref={inputGroupRef} className={css(styles.inputGroup, className)} {...props}>
@@ -124,7 +124,13 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
124
124
  };
125
125
 
126
126
  if (isTypeahead) {
127
- return <div ref={innerRef as React.Ref<HTMLDivElement>} className={css(commonStyles)} {...componentProps} />;
127
+ return (
128
+ <div
129
+ ref={innerRef as React.Ref<HTMLDivElement>}
130
+ className={css(commonStyles, styles.modifiers.typeahead)}
131
+ {...componentProps}
132
+ />
133
+ );
128
134
  }
129
135
 
130
136
  if (splitButtonOptions) {
@@ -65,6 +65,8 @@ export interface PageSectionProps extends React.HTMLProps<HTMLDivElement> {
65
65
  * This prop should also be passed in if a heading is not being used to describe the content of the page section.
66
66
  */
67
67
  'aria-label'?: string;
68
+ /** Sets the base component to render. Defaults to section */
69
+ component?: keyof JSX.IntrinsicElements;
68
70
  }
69
71
 
70
72
  const variantType = {
@@ -98,6 +100,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
98
100
  hasShadowBottom = false,
99
101
  hasOverflowScroll = false,
100
102
  'aria-label': ariaLabel,
103
+ component = 'section',
101
104
  ...props
102
105
  }: PageSectionProps) => {
103
106
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
@@ -109,8 +112,10 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
109
112
  }
110
113
  }, [hasOverflowScroll, ariaLabel]);
111
114
 
115
+ const Component = component as any;
116
+
112
117
  return (
113
- <section
118
+ <Component
114
119
  {...props}
115
120
  className={css(
116
121
  variantType[type],
@@ -133,7 +138,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
133
138
  >
134
139
  {isWidthLimited && <div className={css(styles.pageMainBody)}>{children}</div>}
135
140
  {!isWidthLimited && children}
136
- </section>
141
+ </Component>
137
142
  );
138
143
  };
139
144
  PageSection.displayName = 'PageSection';
@@ -128,3 +128,15 @@ test('Logs a warning in the console when an aria-label is not included with hasO
128
128
 
129
129
  expect(consoleWarning).toHaveBeenCalled();
130
130
  });
131
+
132
+ test('Renders as a section by default', () => {
133
+ render(<PageSection>test</PageSection>);
134
+
135
+ expect(screen.getByText('test')).toHaveProperty('nodeName', 'SECTION');
136
+ });
137
+
138
+ test('Renders as other elements when a different element type is passed using the component prop', () => {
139
+ render(<PageSection component="main">test</PageSection>);
140
+
141
+ expect(screen.getByRole('main')).toHaveTextContent('test');
142
+ });
@@ -125,7 +125,8 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
125
125
  const [isSearchMenuOpen, setIsSearchMenuOpen] = React.useState(false);
126
126
  const [searchValue, setSearchValue] = React.useState(value);
127
127
  const searchInputRef = React.useRef(null);
128
- const searchInputInputRef = innerRef || React.useRef(null);
128
+ const ref = React.useRef(null);
129
+ const searchInputInputRef = innerRef || ref;
129
130
 
130
131
  React.useEffect(() => {
131
132
  setSearchValue(value);
@@ -27,7 +27,8 @@ export const TextInputGroup: React.FunctionComponent<TextInputGroupProps> = ({
27
27
  innerRef,
28
28
  ...props
29
29
  }: TextInputGroupProps) => {
30
- const textInputGroupRef = innerRef || React.useRef(null);
30
+ const ref = React.useRef(null);
31
+ const textInputGroupRef = innerRef || ref;
31
32
 
32
33
  return (
33
34
  <TextInputGroupContext.Provider value={{ isDisabled }}>
@@ -57,7 +57,8 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
57
57
  ...props
58
58
  }: TextInputGroupMainProps) => {
59
59
  const { isDisabled } = React.useContext(TextInputGroupContext);
60
- const textInputGroupInputInputRef = innerRef || React.useRef(null);
60
+ const ref = React.useRef(null);
61
+ const textInputGroupInputInputRef = innerRef || ref;
61
62
 
62
63
  const handleChange = (event: React.FormEvent<HTMLInputElement>) => {
63
64
  onChange(event.currentTarget.value, event);
@@ -84,95 +84,97 @@ export const WizardToggle = ({
84
84
  );
85
85
  });
86
86
 
87
- const wizardNav = isCustomWizardNav(nav)
88
- ? nav(isNavOpen, steps, activeStep, goToStepByIndex)
89
- : React.useMemo(() => {
90
- const props = {
91
- isOpen: isNavOpen,
92
- 'aria-label': nav?.ariaLabel || 'Wizard nav',
93
- ...(nav?.ariaLabelledBy && { 'aria-labelledby': nav?.ariaLabelledBy })
94
- };
87
+ const wizardNav = React.useMemo(() => {
88
+ if (isCustomWizardNav(nav)) {
89
+ return nav(isNavOpen, steps, activeStep, goToStepByIndex);
90
+ }
91
+
92
+ const props = {
93
+ isOpen: isNavOpen,
94
+ 'aria-label': nav?.ariaLabel || 'Wizard nav',
95
+ ...(nav?.ariaLabelledBy && { 'aria-labelledby': nav?.ariaLabelledBy })
96
+ };
95
97
 
96
- return (
97
- <WizardNav {...props}>
98
- {steps.map((step, index) => {
99
- const stepIndex = index + 1;
100
- const stepNavItem = step.navItem && <React.Fragment key={step.id}>{step.navItem}</React.Fragment>;
101
-
102
- if (isWizardParentStep(step)) {
103
- let firstSubStepIndex;
104
- let hasActiveChild = false;
105
-
106
- const subNavItems = step.subStepIds?.map((subStepId, index) => {
107
- const subStep = steps.find(step => step.id === subStepId);
108
- const subStepIndex = steps.indexOf(subStep) + 1;
109
-
110
- if (index === 0) {
111
- firstSubStepIndex = subStepIndex;
112
- }
113
-
114
- if (activeStep?.id === subStep.id) {
115
- hasActiveChild = true;
116
- }
117
-
118
- return subStep.navItem ? (
119
- <React.Fragment key={subStep.id}>{subStep.navItem}</React.Fragment>
120
- ) : (
121
- <WizardNavItem
122
- key={subStep.id}
123
- id={subStep.id}
124
- content={subStep.name}
125
- isCurrent={activeStep?.id === subStep.id}
126
- isDisabled={subStep.isDisabled || (nav?.forceStepVisit && !subStep.visited)}
127
- step={subStepIndex}
128
- onNavItemClick={goToStepByIndex}
129
- />
130
- );
131
- });
132
-
133
- const hasEnabledChildren = React.Children.toArray(subNavItems).some(
134
- child => React.isValidElement(child) && !child.props.isDisabled
135
- );
136
-
137
- return (
138
- stepNavItem || (
139
- <WizardNavItem
140
- key={step.id}
141
- id={step.id}
142
- content={step.name}
143
- isExpandable={nav?.isExpandable}
144
- isCurrent={hasActiveChild}
145
- isDisabled={!hasEnabledChildren}
146
- step={firstSubStepIndex}
147
- onNavItemClick={goToStepByIndex}
148
- >
149
- <WizardNav {...props} returnList>
150
- {subNavItems}
151
- </WizardNav>
152
- </WizardNavItem>
153
- )
154
- );
98
+ return (
99
+ <WizardNav {...props}>
100
+ {steps.map((step, index) => {
101
+ const stepIndex = index + 1;
102
+ const stepNavItem = step.navItem && <React.Fragment key={step.id}>{step.navItem}</React.Fragment>;
103
+
104
+ if (isWizardParentStep(step)) {
105
+ let firstSubStepIndex;
106
+ let hasActiveChild = false;
107
+
108
+ const subNavItems = step.subStepIds?.map((subStepId, index) => {
109
+ const subStep = steps.find(step => step.id === subStepId);
110
+ const subStepIndex = steps.indexOf(subStep) + 1;
111
+
112
+ if (index === 0) {
113
+ firstSubStepIndex = subStepIndex;
155
114
  }
156
115
 
157
- if (isWizardBasicStep(step)) {
158
- return (
159
- stepNavItem || (
160
- <WizardNavItem
161
- key={step.id}
162
- id={step.id}
163
- content={step.name}
164
- isCurrent={activeStep?.id === step.id}
165
- isDisabled={step.isDisabled || (nav?.forceStepVisit && !step.visited)}
166
- step={stepIndex}
167
- onNavItemClick={goToStepByIndex}
168
- />
169
- )
170
- );
116
+ if (activeStep?.id === subStep.id) {
117
+ hasActiveChild = true;
171
118
  }
172
- })}
173
- </WizardNav>
174
- );
175
- }, [activeStep?.id, goToStepByIndex, isNavOpen, nav, steps]);
119
+
120
+ return subStep.navItem ? (
121
+ <React.Fragment key={subStep.id}>{subStep.navItem}</React.Fragment>
122
+ ) : (
123
+ <WizardNavItem
124
+ key={subStep.id}
125
+ id={subStep.id}
126
+ content={subStep.name}
127
+ isCurrent={activeStep?.id === subStep.id}
128
+ isDisabled={subStep.isDisabled || (nav?.forceStepVisit && !subStep.visited)}
129
+ step={subStepIndex}
130
+ onNavItemClick={goToStepByIndex}
131
+ />
132
+ );
133
+ });
134
+
135
+ const hasEnabledChildren = React.Children.toArray(subNavItems).some(
136
+ child => React.isValidElement(child) && !child.props.isDisabled
137
+ );
138
+
139
+ return (
140
+ stepNavItem || (
141
+ <WizardNavItem
142
+ key={step.id}
143
+ id={step.id}
144
+ content={step.name}
145
+ isExpandable={nav?.isExpandable}
146
+ isCurrent={hasActiveChild}
147
+ isDisabled={!hasEnabledChildren}
148
+ step={firstSubStepIndex}
149
+ onNavItemClick={goToStepByIndex}
150
+ >
151
+ <WizardNav {...props} returnList>
152
+ {subNavItems}
153
+ </WizardNav>
154
+ </WizardNavItem>
155
+ )
156
+ );
157
+ }
158
+
159
+ if (isWizardBasicStep(step)) {
160
+ return (
161
+ stepNavItem || (
162
+ <WizardNavItem
163
+ key={step.id}
164
+ id={step.id}
165
+ content={step.name}
166
+ isCurrent={activeStep?.id === step.id}
167
+ isDisabled={step.isDisabled || (nav?.forceStepVisit && !step.visited)}
168
+ step={stepIndex}
169
+ onNavItemClick={goToStepByIndex}
170
+ />
171
+ )
172
+ );
173
+ }
174
+ })}
175
+ </WizardNav>
176
+ );
177
+ }, [activeStep?.id, goToStepByIndex, isNavOpen, nav, steps]);
176
178
 
177
179
  return (
178
180
  <>