@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
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import {
3
+ DescriptionList,
4
+ DescriptionListGroup,
5
+ DescriptionListTerm,
6
+ DescriptionListDescription
7
+ } from '@patternfly/react-core';
8
+ import { Wizard, WizardStep, WizardStepType } from '@patternfly/react-core/next';
9
+
10
+ const CurrentStepDescriptionList = ({ currentStep }: { currentStep: WizardStepType | undefined }) => (
11
+ <DescriptionList isHorizontal isCompact>
12
+ <DescriptionListGroup>
13
+ <DescriptionListTerm>Index</DescriptionListTerm>
14
+ <DescriptionListDescription>{currentStep?.index}</DescriptionListDescription>
15
+ </DescriptionListGroup>
16
+
17
+ <DescriptionListGroup>
18
+ <DescriptionListTerm>ID</DescriptionListTerm>
19
+ <DescriptionListDescription>{currentStep?.id}</DescriptionListDescription>
20
+ </DescriptionListGroup>
21
+
22
+ <DescriptionListGroup>
23
+ <DescriptionListTerm>Name</DescriptionListTerm>
24
+ <DescriptionListDescription>{currentStep?.name}</DescriptionListDescription>
25
+ </DescriptionListGroup>
26
+
27
+ <DescriptionListGroup>
28
+ <DescriptionListTerm>Visited</DescriptionListTerm>
29
+ <DescriptionListDescription>{currentStep?.isVisited ? 'true' : 'false'}</DescriptionListDescription>
30
+ </DescriptionListGroup>
31
+ </DescriptionList>
32
+ );
33
+
34
+ export const GetCurrentStepWizard: React.FunctionComponent = () => {
35
+ const [currentStep, setCurrentStep] = React.useState<WizardStepType>();
36
+
37
+ const onStepChange = (event: React.MouseEvent<HTMLButtonElement>, currentStep: WizardStepType) =>
38
+ setCurrentStep(currentStep);
39
+
40
+ return (
41
+ <Wizard height={400} title="Get current step wizard" onStepChange={onStepChange}>
42
+ <WizardStep name="Step 1" id="get-current-step-1">
43
+ {currentStep ? <CurrentStepDescriptionList currentStep={currentStep} /> : 'Step 1 content'}
44
+ </WizardStep>
45
+ <WizardStep name="Step 2" id="get-current-step-2">
46
+ <CurrentStepDescriptionList currentStep={currentStep} />
47
+ </WizardStep>
48
+ <WizardStep name="Review" id="get-current-review-step" footer={{ nextButtonText: 'Finish' }}>
49
+ <CurrentStepDescriptionList currentStep={currentStep} />
50
+ </WizardStep>
51
+ </Wizard>
52
+ );
53
+ };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardProgressiveSteps: React.FunctionComponent = () => (
5
+ <Wizard height={400} title="Progressive steps wizard" isProgressive>
6
+ <WizardStep id="progressive-step-1" name="Get started">
7
+ Get started content
8
+ </WizardStep>
9
+ <WizardStep id="progressive-step-2" name="Update options">
10
+ Update options content
11
+ </WizardStep>
12
+ <WizardStep
13
+ id="progressive-step-3"
14
+ name="Quick options"
15
+ steps={[
16
+ <WizardStep key="progressive-substep-1" id="progressive-substep-1" name="Substep 1">
17
+ Substep 1 content
18
+ </WizardStep>,
19
+ <WizardStep key="progressive-substep-2" id="progressive-substep-2" name="Substep 2">
20
+ Substep 2 content
21
+ </WizardStep>,
22
+ <WizardStep key="progressive-substep-3" id="progressive-substep-3" name="Substep 3">
23
+ Substep 3 content
24
+ </WizardStep>
25
+ ]}
26
+ />
27
+ <WizardStep id="progressive-step-4" name="Review" footer={{ nextButtonText: 'Finish' }}>
28
+ Review content
29
+ </WizardStep>
30
+ </Wizard>
31
+ );
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ Drawer,
5
+ DrawerContent,
6
+ DrawerPanelContent,
7
+ DrawerColorVariant,
8
+ DrawerHead,
9
+ DrawerActions,
10
+ DrawerCloseButton,
11
+ Flex,
12
+ Button
13
+ } from '@patternfly/react-core';
14
+ import { useWizardContext, Wizard, WizardStep } from '@patternfly/react-core/next';
15
+
16
+ const StepContentWithDrawer: React.FunctionComponent = () => {
17
+ const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false);
18
+ const { activeStep } = useWizardContext();
19
+ const drawerRef = React.useRef<HTMLSpanElement>(null);
20
+
21
+ const onWizardExpand = () => drawerRef.current && drawerRef.current.focus();
22
+
23
+ return (
24
+ <Drawer isInline isExpanded={isDrawerExpanded} onExpand={onWizardExpand}>
25
+ <DrawerContent
26
+ panelContent={
27
+ <DrawerPanelContent widths={{ default: 'width_50' }} colorVariant={DrawerColorVariant.light200}>
28
+ <DrawerHead>
29
+ <span tabIndex={isDrawerExpanded ? 0 : -1} ref={drawerRef}>
30
+ Drawer content: <strong>{activeStep?.name}</strong>
31
+ </span>
32
+ <DrawerActions>
33
+ <DrawerCloseButton onClick={() => setIsDrawerExpanded(false)} />
34
+ </DrawerActions>
35
+ </DrawerHead>
36
+ </DrawerPanelContent>
37
+ }
38
+ >
39
+ <Flex
40
+ className="pf-c-wizard__main-body"
41
+ direction={{ default: 'column' }}
42
+ spaceItems={{ default: 'spaceItemsLg' }}
43
+ height="100%"
44
+ >
45
+ {!isDrawerExpanded && (
46
+ <Button isInline variant="link" onClick={() => setIsDrawerExpanded(prevExpanded => !prevExpanded)}>
47
+ Open drawer
48
+ </Button>
49
+ )}
50
+ <div>{activeStep?.name} content</div>
51
+ </Flex>
52
+ </DrawerContent>
53
+ </Drawer>
54
+ );
55
+ };
56
+
57
+ export const WizardStepDrawerContent: React.FunctionComponent = () => (
58
+ <Wizard height={400} title="With drawer wizard">
59
+ <WizardStep body={null} name="Step 1" id="with-drawer-step-1">
60
+ <StepContentWithDrawer />
61
+ </WizardStep>
62
+ <WizardStep
63
+ name="Step 2"
64
+ id="with-drawer-step-2"
65
+ steps={[
66
+ <WizardStep body={null} key="with-drawer-substep-1" name="Substep 1" id="with-drawer-substep-1">
67
+ <StepContentWithDrawer />
68
+ </WizardStep>,
69
+ <WizardStep body={null} key="with-drawer-substep-2" name="Substep 2" id="with-drawer-substep-2">
70
+ <StepContentWithDrawer />
71
+ </WizardStep>
72
+ ]}
73
+ >
74
+ <StepContentWithDrawer />
75
+ </WizardStep>
76
+ <WizardStep name="Review" id="with-drawer-review-step" footer={{ nextButtonText: 'Finish' }}>
77
+ Review step content
78
+ </WizardStep>
79
+ </Wizard>
80
+ );
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ import { Checkbox } from '@patternfly/react-core';
4
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
5
+
6
+ interface SomeContextProps {
7
+ errorMessage: string | undefined;
8
+ setErrorMessage(error: string | undefined): void;
9
+ }
10
+ type SomeContextRenderProps = Pick<SomeContextProps, 'errorMessage'>;
11
+ interface SomeContextProviderProps {
12
+ children: (context: SomeContextRenderProps) => React.ReactElement;
13
+ }
14
+
15
+ const SomeContext: React.Context<SomeContextProps> = React.createContext({} as SomeContextProps);
16
+
17
+ const SomeContextProvider = ({ children }: SomeContextProviderProps) => {
18
+ const [errorMessage, setErrorMessage] = React.useState<string>();
19
+
20
+ return (
21
+ <SomeContext.Provider value={{ errorMessage, setErrorMessage }}>{children({ errorMessage })}</SomeContext.Provider>
22
+ );
23
+ };
24
+
25
+ const StepContentWithAction = () => {
26
+ const { errorMessage, setErrorMessage } = React.useContext(SomeContext);
27
+
28
+ return (
29
+ <Checkbox
30
+ label="Give step 1 an error status"
31
+ isChecked={!!errorMessage}
32
+ onChange={checked => setErrorMessage(checked ? 'Some error message' : undefined)}
33
+ id="toggle-error-checkbox"
34
+ name="Toggle Error Checkbox"
35
+ />
36
+ );
37
+ };
38
+
39
+ export const WizardStepErrorStatus: React.FunctionComponent = () => (
40
+ <SomeContextProvider>
41
+ {({ errorMessage }) => (
42
+ <Wizard height={400} title="Step error status wizard">
43
+ <WizardStep status={errorMessage ? 'error' : 'default'} id="error-status-step-1" name="Step 1">
44
+ Step 1 content
45
+ </WizardStep>
46
+ <WizardStep name="Error action step" id="error-status-step-2">
47
+ <StepContentWithAction />
48
+ </WizardStep>
49
+ <WizardStep name="Review" id="error-status-review-step" footer={{ nextButtonText: 'Finish' }}>
50
+ Review step content
51
+ </WizardStep>
52
+ </Wizard>
53
+ )}
54
+ </SomeContextProvider>
55
+ );
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardStepVisitRequired: React.FunctionComponent = () => (
5
+ <Wizard height={400} title="Incrementally enabled steps wizard" isVisitRequired>
6
+ <WizardStep name="Step 1" id="req-visit-first-step">
7
+ Step 1 content
8
+ </WizardStep>
9
+ <WizardStep name="Step 2" id="req-visit-second-step">
10
+ Step 2 content
11
+ </WizardStep>
12
+ <WizardStep name="Step 3" id="req-visit-third-step">
13
+ Step 3 content
14
+ </WizardStep>
15
+ <WizardStep name="Step 4" id="req-visit-fourth-step">
16
+ Step 4 content
17
+ </WizardStep>
18
+ <WizardStep name="Review" id="req-visit-review-step" footer={{ nextButtonText: 'Finish' }}>
19
+ Review step content
20
+ </WizardStep>
21
+ </Wizard>
22
+ );
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+
3
+ import { Checkbox } from '@patternfly/react-core';
4
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
5
+
6
+ interface SomeContextProps {
7
+ isToggleStepChecked: boolean;
8
+ setIsToggleStepChecked(isHidden: boolean): void;
9
+ }
10
+ type SomeContextRenderProps = Pick<SomeContextProps, 'isToggleStepChecked'>;
11
+ interface SomeContextProviderProps {
12
+ children: (context: SomeContextRenderProps) => React.ReactElement;
13
+ }
14
+
15
+ const SomeContext: React.Context<SomeContextProps> = React.createContext({} as SomeContextProps);
16
+
17
+ const SomeContextProvider: React.FunctionComponent<SomeContextProviderProps> = ({ children }) => {
18
+ const [isToggleStepChecked, setIsToggleStepChecked] = React.useState(false);
19
+
20
+ return (
21
+ <SomeContext.Provider value={{ isToggleStepChecked, setIsToggleStepChecked }}>
22
+ {children({ isToggleStepChecked })}
23
+ </SomeContext.Provider>
24
+ );
25
+ };
26
+
27
+ const StepContentWithAction: React.FunctionComponent = () => {
28
+ const { isToggleStepChecked, setIsToggleStepChecked } = React.useContext(SomeContext);
29
+
30
+ return (
31
+ <Checkbox
32
+ label="Toggle visibility of the next step"
33
+ isChecked={isToggleStepChecked}
34
+ onChange={checked => setIsToggleStepChecked(checked)}
35
+ id="toggle-hide-step-checkbox"
36
+ name="Toggle Hide Step Checkbox"
37
+ />
38
+ );
39
+ };
40
+
41
+ export const WizardToggleStepVisibility: React.FunctionComponent = () => (
42
+ <SomeContextProvider>
43
+ {({ isToggleStepChecked }) => (
44
+ <Wizard height={400} title="Toggle step visibility wizard">
45
+ <WizardStep name="Hidden action step" id="toggle-visible-step-1">
46
+ <StepContentWithAction />
47
+ </WizardStep>
48
+ <WizardStep name="Step 2" id="toggle-visible-step-2" isHidden={isToggleStepChecked}>
49
+ Step 2 content
50
+ </WizardStep>
51
+ <WizardStep name="Review" id="toggle-visible-review-step" footer={{ nextButtonText: 'Finish' }}>
52
+ Review step content
53
+ </WizardStep>
54
+ </Wizard>
55
+ )}
56
+ </SomeContextProvider>
57
+ );
@@ -0,0 +1,183 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ Button,
5
+ Alert,
6
+ EmptyState,
7
+ EmptyStateIcon,
8
+ Title,
9
+ EmptyStateBody,
10
+ Progress,
11
+ EmptyStateSecondaryActions,
12
+ Form,
13
+ FormGroup,
14
+ TextInput
15
+ } from '@patternfly/react-core';
16
+ import { Wizard, WizardStep, WizardFooterWrapper, useWizardContext } from '@patternfly/react-core/next';
17
+ import CogsIcon from '@patternfly/react-icons/dist/esm/icons/cogs-icon';
18
+
19
+ interface ValidationProgressProps {
20
+ onClose(): void;
21
+ }
22
+
23
+ const ValidationProgress: React.FunctionComponent<ValidationProgressProps> = ({ onClose }) => {
24
+ const [percentValidated, setPercentValidated] = React.useState(0);
25
+
26
+ const tick = React.useCallback(() => {
27
+ if (percentValidated < 100) {
28
+ setPercentValidated(prevValue => prevValue + 20);
29
+ }
30
+ }, [percentValidated]);
31
+
32
+ React.useEffect(() => {
33
+ const interval = setInterval(() => tick(), 1000);
34
+
35
+ return () => {
36
+ clearInterval(interval);
37
+ };
38
+ }, [tick]);
39
+
40
+ return (
41
+ <div className="pf-l-bullseye">
42
+ <EmptyState variant="large">
43
+ <EmptyStateIcon icon={CogsIcon} />
44
+ <Title headingLevel="h4" size="lg">
45
+ {percentValidated === 100 ? 'Validation complete' : 'Validating credentials'}
46
+ </Title>
47
+ <EmptyStateBody>
48
+ <Progress value={percentValidated} measureLocation="outside" aria-label="Wizard validation progress" />
49
+ </EmptyStateBody>
50
+ <EmptyStateBody>
51
+ Description can be used to further elaborate on the validation step, or give the user a better idea of how
52
+ long the process will take.
53
+ </EmptyStateBody>
54
+ <EmptyStateSecondaryActions>
55
+ <Button isDisabled={percentValidated !== 100} onClick={onClose}>
56
+ Log to console
57
+ </Button>
58
+ </EmptyStateSecondaryActions>
59
+ </EmptyState>
60
+ </div>
61
+ );
62
+ };
63
+
64
+ interface LastStepFooterProps {
65
+ isValid: boolean;
66
+ setIsSubmitted(isSubmitted: boolean): void;
67
+ setHasErrorOnSubmit(isSubmitted: boolean): void;
68
+ }
69
+
70
+ const LastStepFooter: React.FunctionComponent<LastStepFooterProps> = ({
71
+ isValid,
72
+ setIsSubmitted,
73
+ setHasErrorOnSubmit
74
+ }) => {
75
+ const { goToNextStep, goToPrevStep } = useWizardContext();
76
+
77
+ const onValidate = () => {
78
+ setIsSubmitted(true);
79
+
80
+ if (!isValid) {
81
+ setIsSubmitted(false);
82
+ setHasErrorOnSubmit(true);
83
+ } else {
84
+ goToNextStep();
85
+ }
86
+ };
87
+
88
+ return (
89
+ <WizardFooterWrapper>
90
+ <Button onClick={onValidate}>Validate</Button>
91
+ <Button variant="secondary" onClick={goToPrevStep}>
92
+ Back
93
+ </Button>
94
+ </WizardFooterWrapper>
95
+ );
96
+ };
97
+
98
+ interface SampleFormProps {
99
+ value: string;
100
+ isValid: boolean;
101
+ setValue: (value: string) => void;
102
+ setIsValid: (isValid: boolean) => void;
103
+ }
104
+
105
+ const SampleForm: React.FunctionComponent<SampleFormProps> = ({ value, isValid, setValue, setIsValid }) => {
106
+ const validated = isValid ? 'default' : 'error';
107
+
108
+ const handleTextInputChange = (value: string) => {
109
+ const isValid = /^\d+$/.test(value);
110
+
111
+ setValue(value);
112
+ setIsValid(isValid);
113
+ };
114
+
115
+ return (
116
+ <Form>
117
+ <FormGroup
118
+ label="Age:"
119
+ type="number"
120
+ helperText="Write your age in numbers."
121
+ helperTextInvalid="Age has to be a number"
122
+ fieldId="age"
123
+ validated={validated}
124
+ >
125
+ <TextInput
126
+ validated={validated}
127
+ value={value}
128
+ id="age"
129
+ aria-describedby="age-helper"
130
+ onChange={handleTextInputChange}
131
+ />
132
+ </FormGroup>
133
+ </Form>
134
+ );
135
+ };
136
+
137
+ export const WizardValidateOnButtonPress: React.FunctionComponent = () => {
138
+ const [ageValue, setAgeValue] = React.useState('Thirty');
139
+ const [isSubmitted, setIsSubmitted] = React.useState(false);
140
+ const [isFirstStepValid, setIsFirstStepValid] = React.useState(false);
141
+ const [hasErrorOnSubmit, setHasErrorOnSubmit] = React.useState(false);
142
+
143
+ // eslint-disable-next-line no-console
144
+ const onClose = () => console.log('Some close action occurs here.');
145
+
146
+ if (isSubmitted && isFirstStepValid) {
147
+ return <ValidationProgress onClose={onClose} />;
148
+ }
149
+
150
+ return (
151
+ <Wizard title="Validate on button press wizard" onClose={onClose} height={400}>
152
+ <WizardStep name="Step 1" id="validate-btn-step-1">
153
+ Step 1 content
154
+ </WizardStep>
155
+ <WizardStep name="Step 2" id="validate-btn-step-2">
156
+ Step 2 content
157
+ </WizardStep>
158
+ <WizardStep
159
+ name="Final Step"
160
+ id="validate-btn-finish-step"
161
+ footer={
162
+ <LastStepFooter
163
+ isValid={isFirstStepValid}
164
+ setIsSubmitted={setIsSubmitted}
165
+ setHasErrorOnSubmit={setHasErrorOnSubmit}
166
+ />
167
+ }
168
+ >
169
+ {hasErrorOnSubmit && (
170
+ <div style={{ padding: '15px 0' }}>
171
+ <Alert isInline variant="danger" title="Validation failed, please try again." />
172
+ </div>
173
+ )}
174
+ <SampleForm
175
+ value={ageValue}
176
+ setValue={value => setAgeValue(value)}
177
+ isValid={!hasErrorOnSubmit || isFirstStepValid}
178
+ setIsValid={setIsFirstStepValid}
179
+ />
180
+ </WizardStep>
181
+ </Wizard>
182
+ );
183
+ };
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+
3
+ import { Button, Flex, FlexItem, Spinner } from '@patternfly/react-core';
4
+ import { useWizardContext, Wizard, WizardFooter, WizardFooterWrapper, WizardStep } from '@patternfly/react-core/next';
5
+
6
+ const CustomWizardFooter = () => {
7
+ const { activeStep, goToNextStep, goToPrevStep, close } = useWizardContext();
8
+
9
+ return (
10
+ <WizardFooter
11
+ activeStep={activeStep}
12
+ onNext={goToNextStep}
13
+ onBack={goToPrevStep}
14
+ onClose={close}
15
+ isBackDisabled={activeStep.index === 1}
16
+ />
17
+ );
18
+ };
19
+
20
+ const CustomStepTwoFooter = () => {
21
+ const { goToNextStep, goToPrevStep, close } = useWizardContext();
22
+ const [isLoading, setIsLoading] = React.useState(false);
23
+
24
+ async function onNext() {
25
+ setIsLoading(true);
26
+ await new Promise(resolve => setTimeout(resolve, 2000));
27
+ setIsLoading(false);
28
+
29
+ goToNextStep();
30
+ }
31
+
32
+ return (
33
+ <WizardFooterWrapper>
34
+ <Button variant="primary" onClick={onNext} isLoading={isLoading} isDisabled={isLoading}>
35
+ Async Next
36
+ </Button>
37
+ <Button variant="secondary" onClick={goToPrevStep} isDisabled={isLoading}>
38
+ Back
39
+ </Button>
40
+ <Button variant="link" onClick={close} isDisabled={isLoading}>
41
+ Cancel
42
+ </Button>
43
+ </WizardFooterWrapper>
44
+ );
45
+ };
46
+
47
+ interface ReviewStepContentProps {
48
+ isSubmitting: boolean | undefined;
49
+ }
50
+
51
+ const ReviewStepContent: React.FunctionComponent<ReviewStepContentProps> = ({ isSubmitting }) => {
52
+ if (isSubmitting === undefined) {
53
+ return <FlexItem alignSelf={{ default: 'alignSelfFlexStart' }}>Review step content</FlexItem>;
54
+ }
55
+
56
+ if (isSubmitting) {
57
+ return (
58
+ <>
59
+ <div>Calculating wizard score...</div>
60
+ <Spinner />
61
+ </>
62
+ );
63
+ }
64
+
65
+ return <>50 points to Gryffindor!</>;
66
+ };
67
+
68
+ export const WizardWithCustomFooter: React.FunctionComponent = () => {
69
+ const [isSubmitting, setIsSubmitting] = React.useState<boolean>();
70
+
71
+ async function onSubmit(): Promise<void> {
72
+ setIsSubmitting(true);
73
+
74
+ await new Promise(resolve => setTimeout(resolve, 5000));
75
+
76
+ setIsSubmitting(false);
77
+ }
78
+
79
+ return (
80
+ <Wizard height={400} title="Custom footer wizard" footer={<CustomWizardFooter />}>
81
+ <WizardStep name="Step 1" id="custom-footer-first-step">
82
+ Step 1 content
83
+ </WizardStep>
84
+ <WizardStep id="custom-footer-second-step" name="Step 2" footer={<CustomStepTwoFooter />}>
85
+ Step 2 content with a custom async footer
86
+ </WizardStep>
87
+ <WizardStep
88
+ id="custom-footer-review-step"
89
+ name="Review"
90
+ footer={{
91
+ nextButtonText: 'Submit',
92
+ onNext: onSubmit,
93
+ isNextDisabled: isSubmitting,
94
+ isBackDisabled: isSubmitting
95
+ }}
96
+ >
97
+ <Flex
98
+ direction={{ default: 'column' }}
99
+ alignItems={{ default: 'alignItemsCenter' }}
100
+ spaceItems={{ default: 'spaceItemsLg' }}
101
+ >
102
+ <ReviewStepContent isSubmitting={isSubmitting} />
103
+ </Flex>
104
+ </WizardStep>
105
+ </Wizard>
106
+ );
107
+ };
@@ -2,17 +2,17 @@ import React from 'react';
2
2
  import {
3
3
  Wizard,
4
4
  WizardStep,
5
- WizardControlStep,
5
+ WizardStepType,
6
6
  CustomWizardNavFunction,
7
7
  WizardNav,
8
8
  WizardNavItem
9
9
  } from '@patternfly/react-core/next';
10
10
 
11
- export const WizardCustomNav: React.FunctionComponent = () => {
11
+ export const WizardWithCustomNav: React.FunctionComponent = () => {
12
12
  const nav: CustomWizardNavFunction = (
13
13
  isExpanded: boolean,
14
- steps: WizardControlStep[],
15
- activeStep: WizardControlStep,
14
+ steps: WizardStepType[],
15
+ activeStep: WizardStepType,
16
16
  goToStepByIndex: (index: number) => void
17
17
  ) => (
18
18
  <WizardNav isExpanded={isExpanded}>
@@ -24,7 +24,7 @@ export const WizardCustomNav: React.FunctionComponent = () => {
24
24
  isCurrent={activeStep.id === step.id}
25
25
  isDisabled={step.isDisabled}
26
26
  stepIndex={step.index}
27
- onNavItemClick={goToStepByIndex}
27
+ onClick={() => goToStepByIndex(step.index)}
28
28
  />
29
29
  ))}
30
30
  </WizardNav>
@@ -32,14 +32,14 @@ export const WizardCustomNav: React.FunctionComponent = () => {
32
32
 
33
33
  return (
34
34
  <Wizard height={400} nav={nav}>
35
- <WizardStep name="First step" id="cnav-first-step">
36
- <p>Did you say...custom nav?</p>
35
+ <WizardStep name="Step 1" id="custom-nav-first-step">
36
+ Did you say...custom nav?
37
37
  </WizardStep>
38
- <WizardStep name="Second step" id="cnav-second-step">
39
- <p>Step 2 content</p>
38
+ <WizardStep name="Step 2" id="custom-nav-second-step">
39
+ Oh, you didn't?
40
40
  </WizardStep>
41
- <WizardStep name="Review" id="cnav-review-step" footer={{ nextButtonText: 'Wrap it up' }}>
42
- <p>Review step content</p>
41
+ <WizardStep name="Review" id="custom-nav-review-step" footer={{ nextButtonText: 'Wrap it up' }}>
42
+ Well, this is awkward.
43
43
  </WizardStep>
44
44
  </Wizard>
45
45
  );
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardWithCustomNavItem: React.FunctionComponent = () => (
5
+ <Wizard height={400} title="Custom navigation item wizard">
6
+ <WizardStep name="Step 1" id="custom-nav-item-first-step">
7
+ Step 1 content
8
+ </WizardStep>
9
+ <WizardStep
10
+ id="custom-nav-item-second-step"
11
+ name="Step 2"
12
+ navItem={{
13
+ content: <span style={{ color: 'var(--pf-global--default-color--200)' }}>Custom item</span>
14
+ }}
15
+ >
16
+ Step 2 content with a custom navigation item
17
+ </WizardStep>
18
+ <WizardStep name="Review" id="custom-nav-item-review-step" footer={{ nextButtonText: 'Finish' }}>
19
+ Review step content
20
+ </WizardStep>
21
+ </Wizard>
22
+ );