@patternfly/react-core 4.273.3 → 4.274.1

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 (232) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/components/Chip/Chip.d.ts.map +1 -1
  3. package/components/Chip/Chip.js +5 -4
  4. package/components/Chip/Chip.js.map +1 -1
  5. package/components/Menu/MenuGroup.d.ts +1 -1
  6. package/components/Menu/MenuGroup.d.ts.map +1 -1
  7. package/components/Menu/MenuGroup.js.map +1 -1
  8. package/components/Text/TextList.d.ts +2 -0
  9. package/components/Text/TextList.d.ts.map +1 -1
  10. package/components/Text/TextList.js +3 -2
  11. package/components/Text/TextList.js.map +1 -1
  12. package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
  13. package/dist/esm/components/Chip/Chip.js +5 -4
  14. package/dist/esm/components/Chip/Chip.js.map +1 -1
  15. package/dist/esm/components/Menu/MenuGroup.d.ts +1 -1
  16. package/dist/esm/components/Menu/MenuGroup.d.ts.map +1 -1
  17. package/dist/esm/components/Menu/MenuGroup.js.map +1 -1
  18. package/dist/esm/components/Text/TextList.d.ts +2 -0
  19. package/dist/esm/components/Text/TextList.d.ts.map +1 -1
  20. package/dist/esm/components/Text/TextList.js +3 -2
  21. package/dist/esm/components/Text/TextList.js.map +1 -1
  22. package/dist/esm/next/components/Wizard/Wizard.d.ts +11 -14
  23. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
  24. package/dist/esm/next/components/Wizard/Wizard.js +30 -23
  25. package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
  26. package/dist/esm/next/components/Wizard/WizardContext.d.ts +16 -16
  27. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
  28. package/dist/esm/next/components/Wizard/WizardContext.js +17 -19
  29. package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
  30. package/dist/esm/next/components/Wizard/WizardFooter.d.ts +8 -5
  31. package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  32. package/dist/esm/next/components/Wizard/WizardFooter.js +1 -1
  33. package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -1
  34. package/dist/esm/next/components/Wizard/WizardHeader.d.ts +1 -1
  35. package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  36. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  37. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  38. package/dist/esm/next/components/Wizard/WizardNavInternal.js +15 -9
  39. package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -1
  40. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +10 -4
  41. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  42. package/dist/esm/next/components/Wizard/WizardNavItem.js +10 -9
  43. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
  44. package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
  45. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
  46. package/dist/esm/next/components/Wizard/WizardStep.js +4 -2
  47. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
  48. package/dist/esm/next/components/Wizard/WizardToggle.d.ts +4 -4
  49. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  50. package/dist/esm/next/components/Wizard/WizardToggle.js +1 -1
  51. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
  52. package/dist/esm/next/components/Wizard/hooks/index.d.ts +1 -0
  53. package/dist/esm/next/components/Wizard/hooks/index.d.ts.map +1 -1
  54. package/dist/esm/next/components/Wizard/hooks/index.js +1 -0
  55. package/dist/esm/next/components/Wizard/hooks/index.js.map +1 -1
  56. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  57. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  58. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
  59. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  60. package/dist/esm/next/components/Wizard/index.d.ts +2 -2
  61. package/dist/esm/next/components/Wizard/index.d.ts.map +1 -1
  62. package/dist/esm/next/components/Wizard/index.js +2 -2
  63. package/dist/esm/next/components/Wizard/index.js.map +1 -1
  64. package/dist/esm/next/components/Wizard/types.d.ts +13 -19
  65. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
  66. package/dist/esm/next/components/Wizard/types.js +6 -0
  67. package/dist/esm/next/components/Wizard/types.js.map +1 -1
  68. package/dist/esm/next/components/Wizard/utils.d.ts +5 -6
  69. package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
  70. package/dist/esm/next/components/Wizard/utils.js +15 -22
  71. package/dist/esm/next/components/Wizard/utils.js.map +1 -1
  72. package/dist/js/components/Chip/Chip.d.ts.map +1 -1
  73. package/dist/js/components/Chip/Chip.js +4 -4
  74. package/dist/js/components/Chip/Chip.js.map +1 -1
  75. package/dist/js/components/Menu/MenuGroup.d.ts +1 -1
  76. package/dist/js/components/Menu/MenuGroup.d.ts.map +1 -1
  77. package/dist/js/components/Menu/MenuGroup.js.map +1 -1
  78. package/dist/js/components/Text/TextList.d.ts +2 -0
  79. package/dist/js/components/Text/TextList.d.ts.map +1 -1
  80. package/dist/js/components/Text/TextList.js +3 -2
  81. package/dist/js/components/Text/TextList.js.map +1 -1
  82. package/dist/js/next/components/Wizard/Wizard.d.ts +11 -14
  83. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
  84. package/dist/js/next/components/Wizard/Wizard.js +28 -21
  85. package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
  86. package/dist/js/next/components/Wizard/WizardContext.d.ts +16 -16
  87. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
  88. package/dist/js/next/components/Wizard/WizardContext.js +16 -17
  89. package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
  90. package/dist/js/next/components/Wizard/WizardFooter.d.ts +8 -5
  91. package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  92. package/dist/js/next/components/Wizard/WizardFooter.js +1 -1
  93. package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -1
  94. package/dist/js/next/components/Wizard/WizardHeader.d.ts +1 -1
  95. package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  96. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  97. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  98. package/dist/js/next/components/Wizard/WizardNavInternal.js +15 -9
  99. package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -1
  100. package/dist/js/next/components/Wizard/WizardNavItem.d.ts +10 -4
  101. package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  102. package/dist/js/next/components/Wizard/WizardNavItem.js +10 -8
  103. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
  104. package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
  105. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
  106. package/dist/js/next/components/Wizard/WizardStep.js +4 -2
  107. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
  108. package/dist/js/next/components/Wizard/WizardToggle.d.ts +4 -4
  109. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  110. package/dist/js/next/components/Wizard/WizardToggle.js +1 -1
  111. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
  112. package/dist/js/next/components/Wizard/hooks/index.d.ts +1 -0
  113. package/dist/js/next/components/Wizard/hooks/index.d.ts.map +1 -1
  114. package/dist/js/next/components/Wizard/hooks/index.js +3 -1
  115. package/dist/js/next/components/Wizard/hooks/index.js.map +1 -1
  116. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  117. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  118. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js +38 -0
  119. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  120. package/dist/js/next/components/Wizard/index.d.ts +2 -2
  121. package/dist/js/next/components/Wizard/index.d.ts.map +1 -1
  122. package/dist/js/next/components/Wizard/index.js +4 -2
  123. package/dist/js/next/components/Wizard/index.js.map +1 -1
  124. package/dist/js/next/components/Wizard/types.d.ts +13 -19
  125. package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
  126. package/dist/js/next/components/Wizard/types.js +7 -1
  127. package/dist/js/next/components/Wizard/types.js.map +1 -1
  128. package/dist/js/next/components/Wizard/utils.d.ts +5 -6
  129. package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
  130. package/dist/js/next/components/Wizard/utils.js +17 -25
  131. package/dist/js/next/components/Wizard/utils.js.map +1 -1
  132. package/dist/umd/react-core.min.js +2 -2
  133. package/next/components/Wizard/Wizard.d.ts +11 -14
  134. package/next/components/Wizard/Wizard.d.ts.map +1 -1
  135. package/next/components/Wizard/Wizard.js +30 -23
  136. package/next/components/Wizard/Wizard.js.map +1 -1
  137. package/next/components/Wizard/WizardContext.d.ts +16 -16
  138. package/next/components/Wizard/WizardContext.d.ts.map +1 -1
  139. package/next/components/Wizard/WizardContext.js +17 -19
  140. package/next/components/Wizard/WizardContext.js.map +1 -1
  141. package/next/components/Wizard/WizardFooter.d.ts +8 -5
  142. package/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  143. package/next/components/Wizard/WizardFooter.js +1 -1
  144. package/next/components/Wizard/WizardFooter.js.map +1 -1
  145. package/next/components/Wizard/WizardHeader.d.ts +1 -1
  146. package/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  147. package/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  148. package/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  149. package/next/components/Wizard/WizardNavInternal.js +15 -9
  150. package/next/components/Wizard/WizardNavInternal.js.map +1 -1
  151. package/next/components/Wizard/WizardNavItem.d.ts +10 -4
  152. package/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  153. package/next/components/Wizard/WizardNavItem.js +10 -9
  154. package/next/components/Wizard/WizardNavItem.js.map +1 -1
  155. package/next/components/Wizard/WizardStep.d.ts +3 -3
  156. package/next/components/Wizard/WizardStep.d.ts.map +1 -1
  157. package/next/components/Wizard/WizardStep.js +4 -2
  158. package/next/components/Wizard/WizardStep.js.map +1 -1
  159. package/next/components/Wizard/WizardToggle.d.ts +4 -4
  160. package/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  161. package/next/components/Wizard/WizardToggle.js +1 -1
  162. package/next/components/Wizard/WizardToggle.js.map +1 -1
  163. package/next/components/Wizard/hooks/index.d.ts +1 -0
  164. package/next/components/Wizard/hooks/index.d.ts.map +1 -1
  165. package/next/components/Wizard/hooks/index.js +1 -0
  166. package/next/components/Wizard/hooks/index.js.map +1 -1
  167. package/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  168. package/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  169. package/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
  170. package/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  171. package/next/components/Wizard/index.d.ts +2 -2
  172. package/next/components/Wizard/index.d.ts.map +1 -1
  173. package/next/components/Wizard/index.js +2 -2
  174. package/next/components/Wizard/index.js.map +1 -1
  175. package/next/components/Wizard/types.d.ts +13 -19
  176. package/next/components/Wizard/types.d.ts.map +1 -1
  177. package/next/components/Wizard/types.js +6 -0
  178. package/next/components/Wizard/types.js.map +1 -1
  179. package/next/components/Wizard/utils.d.ts +5 -6
  180. package/next/components/Wizard/utils.d.ts.map +1 -1
  181. package/next/components/Wizard/utils.js +15 -22
  182. package/next/components/Wizard/utils.js.map +1 -1
  183. package/package.json +2 -2
  184. package/src/components/Chip/Chip.tsx +4 -2
  185. package/src/components/Chip/__tests__/Chip.test.tsx +9 -0
  186. package/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +55 -0
  187. package/src/components/ChipGroup/__tests__/__snapshots__/ChipGroup.test.tsx.snap +4 -0
  188. package/src/components/Menu/MenuGroup.tsx +2 -2
  189. package/src/components/Modal/examples/Modal.md +46 -11
  190. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
  191. package/src/components/Text/TextList.tsx +5 -1
  192. package/src/components/Text/__tests__/TextList.test.tsx +5 -0
  193. package/src/components/Text/examples/Text.md +5 -0
  194. package/src/components/Text/examples/TextPlainList.tsx +24 -0
  195. package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +2 -0
  196. package/src/next/components/Wizard/Wizard.tsx +71 -46
  197. package/src/next/components/Wizard/WizardContext.tsx +38 -43
  198. package/src/next/components/Wizard/WizardFooter.tsx +10 -6
  199. package/src/next/components/Wizard/WizardHeader.tsx +1 -1
  200. package/src/next/components/Wizard/WizardNavInternal.tsx +51 -43
  201. package/src/next/components/Wizard/WizardNavItem.tsx +21 -14
  202. package/src/next/components/Wizard/WizardStep.tsx +8 -6
  203. package/src/next/components/Wizard/WizardToggle.tsx +5 -5
  204. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +129 -26
  205. package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +5 -5
  206. package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +2 -2
  207. package/src/next/components/Wizard/__tests__/utils.test.tsx +3 -17
  208. package/src/next/components/Wizard/examples/Wizard.md +69 -41
  209. package/src/next/components/Wizard/examples/WizardBasic.tsx +6 -12
  210. package/src/next/components/Wizard/examples/WizardBasicDisabledSteps.tsx +22 -0
  211. package/src/next/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +84 -0
  212. package/src/next/components/Wizard/examples/WizardExpandableSteps.tsx +42 -0
  213. package/src/next/components/Wizard/examples/WizardGetCurrentStep.tsx +53 -0
  214. package/src/next/components/Wizard/examples/WizardProgressiveSteps.tsx +31 -0
  215. package/src/next/components/Wizard/examples/WizardStepDrawerContent.tsx +80 -0
  216. package/src/next/components/Wizard/examples/WizardStepErrorStatus.tsx +55 -0
  217. package/src/next/components/Wizard/examples/WizardStepVisitRequired.tsx +22 -0
  218. package/src/next/components/Wizard/examples/WizardToggleStepVisibility.tsx +57 -0
  219. package/src/next/components/Wizard/examples/WizardValidateOnButtonPress.tsx +183 -0
  220. package/src/next/components/Wizard/examples/WizardWithCustomFooter.tsx +107 -0
  221. package/src/next/components/Wizard/examples/{WizardCustomNav.tsx → WizardWithCustomNav.tsx} +11 -11
  222. package/src/next/components/Wizard/examples/WizardWithCustomNavItem.tsx +22 -0
  223. package/src/next/components/Wizard/examples/WizardWithHeader.tsx +26 -0
  224. package/src/next/components/Wizard/examples/WizardWithNavAnchors.tsx +46 -0
  225. package/src/next/components/Wizard/examples/WizardWithSubmitProgress.tsx +86 -0
  226. package/src/next/components/Wizard/examples/WizardWithinModal.tsx +41 -0
  227. package/src/next/components/Wizard/hooks/index.ts +1 -0
  228. package/src/next/components/Wizard/hooks/useGetMergedSteps.tsx +45 -0
  229. package/src/next/components/Wizard/index.ts +2 -2
  230. package/src/next/components/Wizard/types.tsx +19 -29
  231. package/src/next/components/Wizard/utils.ts +27 -33
  232. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +0 -243
@@ -18,21 +18,6 @@ test('renders step when child is of type WizardStep', () => {
18
18
  expect(screen.getByText('Step content')).toBeVisible();
19
19
  });
20
20
 
21
- test('renders step when child has required props; name, id, children', () => {
22
- const CustomStep = props => <div {...props} />;
23
-
24
- render(
25
- <Wizard>
26
- <CustomStep id="test-step" name="Test step">
27
- Custom step content
28
- </CustomStep>
29
- </Wizard>
30
- );
31
-
32
- expect(screen.getByRole('button', { name: 'Test step' })).toBeVisible();
33
- expect(screen.getByText('Custom step content')).toBeVisible();
34
- });
35
-
36
21
  test('renders a header when specified', () => {
37
22
  render(
38
23
  <Wizard header="Some header">
@@ -101,7 +86,7 @@ test('renders default nav with custom props', () => {
101
86
  };
102
87
 
103
88
  render(
104
- <Wizard id="wizard-id" nav={nav} isStepVisitRequired>
89
+ <Wizard id="wizard-id" nav={nav} isVisitRequired>
105
90
  <WizardStep id="step-1" name="Test step 1" steps={[<WizardStep id="nested-step" name="Nested step" />]} />
106
91
  <WizardStep id="step-2" name="Test step 2" />
107
92
  </Wizard>
@@ -111,7 +96,6 @@ test('renders default nav with custom props', () => {
111
96
 
112
97
  expect(navElement).toBeVisible();
113
98
  expect(navElement).toHaveAttribute('aria-labelledby', 'wizard-id');
114
- expect(screen.getByRole('button', { name: 'Test step 1, visited' }).parentElement).toHaveClass('pf-m-expandable');
115
99
  expect(screen.getByRole('button', { name: 'Test step 2' })).toHaveAttribute('disabled');
116
100
  });
117
101
 
@@ -183,7 +167,7 @@ test('calls onNavByIndex on nav item click', async () => {
183
167
  const onNavByIndex = jest.fn();
184
168
 
185
169
  render(
186
- <Wizard onNavByIndex={onNavByIndex}>
170
+ <Wizard onStepChange={onNavByIndex}>
187
171
  <WizardStep id="step-1" name="Test step 1" />
188
172
  <WizardStep id="step-2" name="Test step 2" />
189
173
  </Wizard>
@@ -199,7 +183,7 @@ test('calls onNext and not onSave on next button click when not on the last step
199
183
  const onSave = jest.fn();
200
184
 
201
185
  render(
202
- <Wizard onNext={onNext} onSave={onSave}>
186
+ <Wizard onStepChange={onNext} onSave={onSave}>
203
187
  <WizardStep id="step-1" name="Test step 1" />
204
188
  <WizardStep id="step-2" name="Test step 2" />
205
189
  </Wizard>
@@ -216,7 +200,7 @@ test('calls onBack on back button click', async () => {
216
200
  const onBack = jest.fn();
217
201
 
218
202
  render(
219
- <Wizard onBack={onBack}>
203
+ <Wizard onStepChange={onBack}>
220
204
  <WizardStep id="step-1" name="Test step 1" />
221
205
  <WizardStep id="step-2" name="Test step 2" />
222
206
  </Wizard>
@@ -298,13 +282,18 @@ test('does not render inactive step content', async () => {
298
282
  expect(screen.getByText('Step 2 content')).toBeVisible();
299
283
  });
300
284
 
301
- test('parent steps have collapsed sub-steps by default unless the step is active', async () => {
285
+ test('parent steps have collapsed sub-steps when isExpandable is true unless the step is active', async () => {
302
286
  const user = userEvent.setup();
303
287
 
304
288
  render(
305
- <Wizard startIndex={2}>
289
+ <Wizard>
306
290
  <WizardStep id="step-1" name="Test step 1" />
307
- <WizardStep id="step-2" name="Test step 2" steps={[<WizardStep id="sub-step-1" name="Test sub step 1" />]} />
291
+ <WizardStep
292
+ id="step-2"
293
+ name="Test step 2"
294
+ isExpandable
295
+ steps={[<WizardStep id="sub-step-1" name="Test sub step 1" />]}
296
+ />
308
297
  </Wizard>
309
298
  );
310
299
 
@@ -315,17 +304,131 @@ test('parent steps have collapsed sub-steps by default unless the step is active
315
304
  expect(screen.getByLabelText('Collapse step icon')).toBeVisible();
316
305
  });
317
306
 
318
- test('parent step can be non-collapsible by setting isCollapsible to false', () => {
307
+ test('parent step can be expandable by setting isExpandable to true', () => {
319
308
  render(
320
309
  <Wizard>
321
310
  <WizardStep
322
311
  id="step-1"
323
312
  name="Test step 1"
324
- isCollapsible={false}
313
+ isExpandable
325
314
  steps={[<WizardStep id="sub-step-1" name="Sub step 1" />]}
326
315
  />
327
316
  </Wizard>
328
317
  );
329
318
 
330
- expect(screen.queryByLabelText('step icon', { exact: false })).toBeNull();
319
+ expect(screen.queryByLabelText('step icon', { exact: false })).toBeVisible();
320
+ });
321
+
322
+ test('incrementally shows/hides steps based on the activeStep when isProgressive is enabled', async () => {
323
+ const user = userEvent.setup();
324
+
325
+ render(
326
+ <Wizard isProgressive>
327
+ <WizardStep id="step-1" name="Test step 1">
328
+ Step 1 content
329
+ </WizardStep>
330
+ <WizardStep id="step-2" name="Test step 2">
331
+ Step 2 content
332
+ </WizardStep>
333
+ <WizardStep id="step-3" name="Test step 3">
334
+ Step 3 content
335
+ </WizardStep>
336
+ </Wizard>
337
+ );
338
+
339
+ const nextButton = screen.getByRole('button', {
340
+ name: 'Next'
341
+ });
342
+ const backButton = screen.getByRole('button', {
343
+ name: 'Back'
344
+ });
345
+
346
+ // Initially only the first nav item will be visible
347
+ expect(
348
+ screen.getByRole('button', {
349
+ name: 'Test step 1'
350
+ })
351
+ ).toBeVisible();
352
+ expect(
353
+ screen.queryByRole('button', {
354
+ name: 'Test step 2'
355
+ })
356
+ ).toBeNull();
357
+ expect(
358
+ screen.queryByRole('button', {
359
+ name: 'Test step 3'
360
+ })
361
+ ).toBeNull();
362
+
363
+ // Progressing to the next step will show steps 1 & 2
364
+ await user.click(nextButton);
365
+ expect(
366
+ screen.getByRole('button', {
367
+ name: 'Test step 1, visited'
368
+ })
369
+ ).toBeVisible();
370
+ expect(
371
+ screen.getByRole('button', {
372
+ name: 'Test step 2'
373
+ })
374
+ ).toBeVisible();
375
+ expect(
376
+ screen.queryByRole('button', {
377
+ name: 'Test step 3'
378
+ })
379
+ ).toBeNull();
380
+
381
+ // Progressing to the next step will show all steps
382
+ await user.click(nextButton);
383
+ expect(
384
+ screen.getByRole('button', {
385
+ name: 'Test step 1, visited'
386
+ })
387
+ ).toBeVisible();
388
+ expect(
389
+ screen.getByRole('button', {
390
+ name: 'Test step 2, visited'
391
+ })
392
+ ).toBeVisible();
393
+ expect(
394
+ screen.getByRole('button', {
395
+ name: 'Test step 3'
396
+ })
397
+ ).toBeVisible();
398
+
399
+ // Going back a step will hide step 3
400
+ await user.click(backButton);
401
+ expect(
402
+ screen.getByRole('button', {
403
+ name: 'Test step 1, visited'
404
+ })
405
+ ).toBeVisible();
406
+ expect(
407
+ screen.getByRole('button', {
408
+ name: 'Test step 2'
409
+ })
410
+ ).toBeVisible();
411
+ expect(
412
+ screen.queryByRole('button', {
413
+ name: 'Test step 3'
414
+ })
415
+ ).toBeNull();
416
+
417
+ // Going back a step will hide step 2 & 3
418
+ await user.click(backButton);
419
+ expect(
420
+ screen.getByRole('button', {
421
+ name: 'Test step 1'
422
+ })
423
+ ).toBeVisible();
424
+ expect(
425
+ screen.queryByRole('button', {
426
+ name: 'Test step 2'
427
+ })
428
+ ).toBeNull();
429
+ expect(
430
+ screen.queryByRole('button', {
431
+ name: 'Test step 3'
432
+ })
433
+ ).toBeNull();
331
434
  });
@@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
4
4
 
5
5
  import { WizardStep, WizardStepProps } from '../WizardStep';
6
6
  import * as WizardContext from '../WizardContext';
7
- import { WizardControlStep } from '..';
7
+ import { WizardStepType } from '..';
8
8
 
9
9
  const testStepProps: WizardStepProps = {
10
10
  id: 'test-step',
@@ -12,7 +12,7 @@ const testStepProps: WizardStepProps = {
12
12
  footer: <>Step footer</>
13
13
  };
14
14
 
15
- const testStep: WizardControlStep = {
15
+ const testStep: WizardStepType = {
16
16
  ...testStepProps,
17
17
  index: 1
18
18
  };
@@ -24,9 +24,9 @@ const wizardContext: WizardContext.WizardContextProps = {
24
24
  steps: [testStep],
25
25
  activeStep: testStep,
26
26
  footer: <>Wizard footer</>,
27
- onNext: jest.fn(),
28
- onBack: jest.fn(),
29
- onClose: jest.fn(),
27
+ goToNextStep: jest.fn(),
28
+ goToPrevStep: jest.fn(),
29
+ close: jest.fn(),
30
30
  goToStepById: jest.fn(),
31
31
  goToStepByName: jest.fn(),
32
32
  goToStepByIndex: jest.fn(),
@@ -5,9 +5,9 @@ import userEvent from '@testing-library/user-event';
5
5
 
6
6
  import { KeyTypes } from '../../../../helpers';
7
7
  import { WizardToggle, WizardToggleProps } from '../WizardToggle';
8
- import { WizardControlStep } from '../types';
8
+ import { WizardStepType } from '../types';
9
9
 
10
- const steps: WizardControlStep[] = [
10
+ const steps: WizardStepType[] = [
11
11
  { id: 'id-1', name: 'First step', index: 1, component: <>First step content</> },
12
12
  { id: 'id-2', name: 'Second step', index: 2, component: <>Second step content</> }
13
13
  ];
@@ -5,11 +5,11 @@ import { buildSteps } from '../utils';
5
5
  import { WizardStep } from '../WizardStep';
6
6
 
7
7
  describe('buildSteps', () => {
8
- test('throws error if child does not have required props or type of WizardStep', () => {
8
+ test('throws error if child is not of type WizardStep', () => {
9
9
  try {
10
10
  buildSteps(<div />);
11
11
  } catch (error) {
12
- expect(error.message).toEqual('Wizard only accepts children with required WizardStepProps.');
12
+ expect(error.message).toEqual('Wizard only accepts children of type WizardStep.');
13
13
  }
14
14
  });
15
15
 
@@ -17,7 +17,7 @@ describe('buildSteps', () => {
17
17
  try {
18
18
  buildSteps('test' as any);
19
19
  } catch (error) {
20
- expect(error.message).toEqual('Wizard only accepts children with required WizardStepProps.');
20
+ expect(error.message).toEqual('Wizard only accepts children of type WizardStep.');
21
21
  }
22
22
  });
23
23
 
@@ -30,20 +30,6 @@ describe('buildSteps', () => {
30
30
  expect(step.component?.props).toEqual(component.props);
31
31
  });
32
32
 
33
- test('returns array of steps if children have required props', () => {
34
- const CustomStep = props => <div {...props} />;
35
- const component = (
36
- <CustomStep name="Step 1" id="step-1">
37
- Content
38
- </CustomStep>
39
- );
40
- const [step] = buildSteps(component);
41
-
42
- expect(step.id).toEqual('step-1');
43
- expect(step.name).toEqual('Step 1');
44
- expect(step.component?.props).toEqual(component.props);
45
- });
46
-
47
33
  test('returns flattened array of steps and sub-steps when sub-steps exist', () => {
48
34
  const CustomSubStep = props => <div {...props} />;
49
35
 
@@ -6,6 +6,7 @@ propComponents:
6
6
  [
7
7
  'Wizard',
8
8
  'WizardFooter',
9
+ 'WizardFooterWrapper',
9
10
  'WizardToggle',
10
11
  'WizardStep',
11
12
  'WizardBody',
@@ -16,7 +17,6 @@ propComponents:
16
17
  'WizardBasicStep',
17
18
  'WizardParentStep',
18
19
  'WizardSubStep',
19
- 'WizardNavStepData',
20
20
  ]
21
21
  beta: true
22
22
  ---
@@ -49,6 +49,9 @@ WizardNavItem,
49
49
  WizardNav,
50
50
  WizardHeader
51
51
  } from '@patternfly/react-core/next';
52
+ import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
53
+ import SlackHashIcon from '@patternfly/react-icons/dist/esm/icons/slack-hash-icon';
54
+ import CogsIcon from '@patternfly/react-icons/dist/esm/icons/cogs-icon';
52
55
 
53
56
  PatternFly has two implementations of a `Wizard`. This newer `Wizard` takes a more explicit and declarative approach compared to the older implementation, which can be found under the [React](/components/wizard/react) tab.
54
57
 
@@ -59,64 +62,89 @@ PatternFly has two implementations of a `Wizard`. This newer `Wizard` takes a mo
59
62
  ```ts file="./WizardBasic.tsx"
60
63
  ```
61
64
 
62
- ### Custom navigation
65
+ ### Basic with disabled steps
63
66
 
64
- The `Wizard`'s `nav` property can be used to build your own navigation.
67
+ ```ts file="./WizardBasicDisabledSteps.tsx"
68
+ ```
65
69
 
66
- ```noLive
67
- /** Callback for the Wizard's 'nav' property. Returns element which replaces the Wizard's default navigation. */
68
- export type CustomWizardNavFunction = (
69
- isExpanded: boolean,
70
- steps: WizardControlStep[],
71
- activeStep: WizardControlStep,
72
- goToStepByIndex: (index: number) => void
73
- ) => React.ReactElement<WizardNavProps>;
70
+ ### Anchors for nav items
74
71
 
75
- /** Encompasses all step type variants that are internally controlled by the Wizard */
76
- type WizardControlStep = WizardBasicStep | WizardParentStep | WizardSubStep;
72
+ ```ts file="./WizardWithNavAnchors.tsx"
77
73
  ```
78
74
 
79
- ```ts file="./WizardCustomNav.tsx"
75
+ ### Incrementally enabled steps
76
+
77
+ ```ts file="./WizardStepVisitRequired.tsx"
80
78
  ```
81
79
 
82
- ### Kitchen sink
80
+ ### Expandable steps
83
81
 
84
- Includes the following:
82
+ ```ts file="./WizardExpandableSteps.tsx"
83
+ ```
85
84
 
86
- - Header
87
- - Custom footer
88
- - Sub-steps
89
- - Step content with a drawer
90
- - Custom navigation item
91
- - Disabled navigation items until visited
92
- - Action to toggle visibility of a step
93
- - Action to toggle navigation item error status
85
+ ### Progress after submission
94
86
 
95
- Custom operations when navigating between steps can be achieved by utilizing `onNext`, `onBack`, or `onNavByIndex` properties whose callback functions return the 'id' and 'name' of the currently focused step (currentStep), and the previously focused step (previousStep).
87
+ ```ts file="./WizardWithSubmitProgress.tsx"
88
+ ```
96
89
 
97
- ```noLive
98
- /** Callback for the Wizard's 'onNext', 'onBack', and 'onNavByIndex' properties */
99
- type WizardNavStepFunction = (currentStep: WizardNavStepData, previousStep: WizardNavStepData) => void | Promise<void>;
90
+ ### Enabled on form validation
100
91
 
101
- /** Data returned for either parameter of WizardNavStepFunction */
102
- type WizardNavStepData = Pick<WizardControlStep, 'id' | 'name'>;
92
+ ```ts file="./WizardEnabledOnFormValidation.tsx"
103
93
  ```
104
94
 
105
- #
95
+ ### Validate on button press
106
96
 
107
- The `WizardStep`'s `navItem` property can be used to build your own nav item for that step.
97
+ ```ts file="./WizardValidateOnButtonPress.tsx"
98
+ ```
108
99
 
109
- ```noLive
110
- /** Callback for the Wizard's 'navItem' property. Returns element which replaces the WizardStep's default navItem. */
111
- export type CustomWizardNavItemFunction = (
112
- step: WizardControlStep,
113
- activeStep: WizardControlStep,
114
- steps: WizardControlStep[],
115
- goToStepByIndex: (index: number) => void
116
- ) => React.ReactElement<WizardNavItemProps>;
100
+ ### Progressive steps
101
+
102
+ ```ts file="./WizardProgressiveSteps.tsx"
103
+ ```
104
+
105
+ ### Get current step
106
+
107
+ ```ts file="./WizardGetCurrentStep.tsx"
108
+ ```
109
+
110
+ ### Within modal
111
+
112
+ ```ts file="./WizardWithinModal.tsx"
113
+ ```
114
+
115
+ ### Step drawer content
116
+
117
+ ```ts file="./WizardStepDrawerContent.tsx"
118
+ ```
119
+
120
+ ### Custom navigation
121
+
122
+ ```ts file="./WizardWithCustomNav.tsx"
123
+ ```
124
+
125
+ ### Header
126
+
127
+ ```ts file="./WizardWithHeader.tsx"
128
+ ```
129
+
130
+ ### Custom footer
131
+
132
+ ```ts file="./WizardWithCustomFooter.tsx"
133
+ ```
134
+
135
+ ### Custom navigation item
136
+
137
+ ```ts file="./WizardWithCustomNavItem.tsx"
117
138
  ```
118
139
 
119
- ```ts file="./WizardKitchenSink.tsx"
140
+ ### Toggle step visibility
141
+
142
+ ```ts file="./WizardToggleStepVisibility.tsx"
143
+ ```
144
+
145
+ ### Step error status
146
+
147
+ ```ts file="./WizardStepErrorStatus.tsx"
120
148
  ```
121
149
 
122
150
  ## Hooks
@@ -2,21 +2,15 @@ import React from 'react';
2
2
  import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
3
 
4
4
  export const WizardBasic: React.FunctionComponent = () => (
5
- <Wizard height={400}>
6
- <WizardStep name="First step" id="basic-first-step">
7
- <p>Step 1 content</p>
5
+ <Wizard height={400} title="Basic wizard">
6
+ <WizardStep name="Step 1" id="basic-first-step">
7
+ Step 1 content
8
8
  </WizardStep>
9
- <WizardStep name="Second step" id="basic-second-step">
10
- <p>Step 2 content</p>
11
- </WizardStep>
12
- <WizardStep name="Third step" id="basic-third-step">
13
- <p>Step 3 content</p>
14
- </WizardStep>
15
- <WizardStep name="Fourth step" id="basic-fourth-step">
16
- <p>Step 4 content</p>
9
+ <WizardStep name="Step 2" id="basic-second-step">
10
+ Step 2 content
17
11
  </WizardStep>
18
12
  <WizardStep name="Review" id="basic-review-step" footer={{ nextButtonText: 'Finish' }}>
19
- <p>Review step content</p>
13
+ Review step content
20
14
  </WizardStep>
21
15
  </Wizard>
22
16
  );
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardBasicDisabledSteps: React.FunctionComponent = () => (
5
+ <Wizard height={400} title="Basic disabled wizard">
6
+ <WizardStep name="Step 1" id="bdisabled-first-step">
7
+ Step 1 content
8
+ </WizardStep>
9
+ <WizardStep name="Step 2" id="bdisabled-second-step" isDisabled>
10
+ Step 2 content
11
+ </WizardStep>
12
+ <WizardStep name="Step 3" id="bdisabled-third-step">
13
+ Step 3 content
14
+ </WizardStep>
15
+ <WizardStep name="Step 4" id="bdisabled-fourth-step" isDisabled>
16
+ Step 4 content
17
+ </WizardStep>
18
+ <WizardStep name="Review" id="bdisabled-review-step" footer={{ nextButtonText: 'Finish' }}>
19
+ Review step content
20
+ </WizardStep>
21
+ </Wizard>
22
+ );
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+
3
+ import { Form, FormGroup, TextInput } from '@patternfly/react-core';
4
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
5
+
6
+ interface SampleFormProps {
7
+ value: string;
8
+ isValid: boolean;
9
+ setValue: (value: string) => void;
10
+ setIsValid: (isValid: boolean) => void;
11
+ }
12
+
13
+ const SampleForm: React.FunctionComponent<SampleFormProps> = ({ value, isValid, setValue, setIsValid }) => {
14
+ const validated = isValid ? 'default' : 'error';
15
+
16
+ const handleTextInputChange = (value: string) => {
17
+ const isValid = /^\d+$/.test(value);
18
+
19
+ setValue(value);
20
+ setIsValid(isValid);
21
+ };
22
+
23
+ return (
24
+ <Form>
25
+ <FormGroup
26
+ label="Age:"
27
+ type="number"
28
+ helperText="Write your age in numbers."
29
+ helperTextInvalid="Age has to be a number"
30
+ fieldId="age"
31
+ validated={validated}
32
+ >
33
+ <TextInput
34
+ validated={validated}
35
+ value={value}
36
+ id="age"
37
+ aria-describedby="age-helper"
38
+ onChange={handleTextInputChange}
39
+ />
40
+ </FormGroup>
41
+ </Form>
42
+ );
43
+ };
44
+
45
+ export const WizardEnabledOnFormValidation: React.FunctionComponent = () => {
46
+ const [ageValue, setAgeValue] = React.useState('Thirty');
47
+ const [isSubAFormValid, setIsSubAFormValid] = React.useState(false);
48
+
49
+ const onSave = () => alert(`Wow, you look a lot younger than ${ageValue}.`);
50
+
51
+ return (
52
+ <Wizard isVisitRequired height={400} title="Enabled on form validation wizard" onSave={onSave}>
53
+ <WizardStep name="Information" id="form-valid-info">
54
+ Information content
55
+ </WizardStep>
56
+ <WizardStep
57
+ name="Configuration"
58
+ id="form-valid-config"
59
+ steps={[
60
+ <WizardStep
61
+ name="Substep A with validation"
62
+ id="form-valid-sub-a"
63
+ key="form-valid-sub-a"
64
+ footer={{ isNextDisabled: !isSubAFormValid }}
65
+ >
66
+ <SampleForm
67
+ value={ageValue}
68
+ setValue={setAgeValue}
69
+ isValid={isSubAFormValid}
70
+ setIsValid={setIsSubAFormValid}
71
+ />
72
+ </WizardStep>,
73
+ <WizardStep name="Substep B" id="form-valid-sub-b" key="form-valid-sub-b">
74
+ Substep B content
75
+ </WizardStep>
76
+ ]}
77
+ />
78
+ <WizardStep name="Additional" id="form-valid-additional">
79
+ Additional step content
80
+ </WizardStep>
81
+ <WizardStep name="Review" id="form-valid-review" footer={{ nextButtonText: 'Submit form' }}></WizardStep>
82
+ </Wizard>
83
+ );
84
+ };
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardExpandableSteps: React.FunctionComponent = () => (
5
+ <Wizard height={400} title="Expandable steps wizard" nav={{ isExpanded: true }}>
6
+ <WizardStep
7
+ name="Step 1"
8
+ id="expand-steps-1"
9
+ isExpandable
10
+ steps={[
11
+ <WizardStep name="Substep A" id="expand-steps-sub-a" key="expand-steps-sub-a">
12
+ Substep A content
13
+ </WizardStep>,
14
+ <WizardStep name="Substep B" id="expand-steps-sub-b" key="expand-steps-sub-b">
15
+ Substep B content
16
+ </WizardStep>
17
+ ]}
18
+ />
19
+ <WizardStep name="Step 2" id="expand-steps-2">
20
+ Step 2 content
21
+ </WizardStep>
22
+ <WizardStep
23
+ name="Step 3"
24
+ id="expand-steps-3"
25
+ isExpandable
26
+ steps={[
27
+ <WizardStep name="Substep C" id="expand-steps-sub-c" key="expand-steps-sub-c">
28
+ Substep C content
29
+ </WizardStep>,
30
+ <WizardStep name="Substep D" id="expand-steps-sub-d" key="expand-steps-sub-d">
31
+ Substep D content
32
+ </WizardStep>
33
+ ]}
34
+ />
35
+ <WizardStep name="Step 4" id="expand-steps-4">
36
+ Step 4 content
37
+ </WizardStep>
38
+ <WizardStep name="Review" id="expand-steps-review" footer={{ nextButtonText: 'Finish' }}>
39
+ Review step content
40
+ </WizardStep>
41
+ </Wizard>
42
+ );