@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,26 @@
1
+ import React from 'react';
2
+ import { Wizard, WizardHeader, WizardStep } from '@patternfly/react-core/next';
3
+
4
+ export const WizardWithHeader: React.FunctionComponent = () => (
5
+ <Wizard
6
+ height={400}
7
+ title="Header wizard"
8
+ header={
9
+ <WizardHeader
10
+ title="You're a wizard, Harry"
11
+ description="To be clear, all those not named Harry are not wizards."
12
+ closeButtonAriaLabel="Close header"
13
+ />
14
+ }
15
+ >
16
+ <WizardStep name="Step 1" id="header-first-step">
17
+ Step 1 content
18
+ </WizardStep>
19
+ <WizardStep name="Step 2" id="header-second-step">
20
+ Step 2 content
21
+ </WizardStep>
22
+ <WizardStep name="Review" id="header-review-step" footer={{ nextButtonText: 'Finish' }}>
23
+ Review step content
24
+ </WizardStep>
25
+ </Wizard>
26
+ );
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+
3
+ import { Button } from '@patternfly/react-core';
4
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
5
+ import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
6
+ import SlackHashIcon from '@patternfly/react-icons/dist/esm/icons/slack-hash-icon';
7
+
8
+ export const WizardWithNavAnchors: React.FunctionComponent = () => (
9
+ <Wizard height={400} title="Anchor link wizard">
10
+ <WizardStep
11
+ name={
12
+ <>
13
+ <ExternalLinkAltIcon /> PF3
14
+ </>
15
+ }
16
+ id="navanchors-pf3-step"
17
+ navItem={{ component: 'a', href: 'https://www.patternfly.org/v3', target: '_blank' }}
18
+ >
19
+ Step 1: Read about PF3
20
+ </WizardStep>
21
+ <WizardStep
22
+ name={
23
+ <>
24
+ <ExternalLinkAltIcon /> PF4
25
+ </>
26
+ }
27
+ id="navanchors-pf4-step"
28
+ navItem={{ component: 'a', href: 'https://www.patternfly.org/v4', target: '_blank' }}
29
+ >
30
+ Step 2: Read about PF4
31
+ </WizardStep>
32
+ <WizardStep
33
+ name={
34
+ <>
35
+ <SlackHashIcon /> Join us on slack
36
+ </>
37
+ }
38
+ id="navanchors-slack-step"
39
+ navItem={{ component: 'a', href: 'https://patternfly.slack.com', target: '_blank' }}
40
+ >
41
+ <Button variant="link" component="a" target="_blank" href="https://patternfly.slack.com">
42
+ Join the conversation
43
+ </Button>
44
+ </WizardStep>
45
+ </Wizard>
46
+ );
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import {
3
+ EmptyState,
4
+ EmptyStateIcon,
5
+ EmptyStateBody,
6
+ EmptyStateSecondaryActions,
7
+ Title,
8
+ Progress,
9
+ Button
10
+ } from '@patternfly/react-core';
11
+ import { Wizard, WizardStep } from '@patternfly/react-core/next';
12
+ import CogsIcon from '@patternfly/react-icons/dist/esm/icons/cogs-icon';
13
+
14
+ interface ValidationProgressProps {
15
+ onClose(): void;
16
+ }
17
+
18
+ const ValidationProgress: React.FunctionComponent<ValidationProgressProps> = ({ onClose }) => {
19
+ const [percentValidated, setPercentValidated] = React.useState(0);
20
+
21
+ const tick = React.useCallback(() => {
22
+ if (percentValidated < 100) {
23
+ setPercentValidated(prevValue => prevValue + 20);
24
+ }
25
+ }, [percentValidated]);
26
+
27
+ React.useEffect(() => {
28
+ const interval = setInterval(() => tick(), 1000);
29
+
30
+ return () => {
31
+ clearInterval(interval);
32
+ };
33
+ }, [tick]);
34
+
35
+ return (
36
+ <div className="pf-l-bullseye">
37
+ <EmptyState variant="large">
38
+ <EmptyStateIcon icon={CogsIcon} />
39
+ <Title headingLevel="h4" size="lg">
40
+ {percentValidated === 100 ? 'Validation complete' : 'Validating credentials'}
41
+ </Title>
42
+ <EmptyStateBody>
43
+ <Progress value={percentValidated} measureLocation="outside" aria-label="Wizard validation progress" />
44
+ </EmptyStateBody>
45
+ <EmptyStateBody>
46
+ Description can be used to further elaborate on the validation step, or give the user a better idea of how
47
+ long the process will take.
48
+ </EmptyStateBody>
49
+ <EmptyStateSecondaryActions>
50
+ <Button isDisabled={percentValidated !== 100} onClick={onClose}>
51
+ Log to console
52
+ </Button>
53
+ </EmptyStateSecondaryActions>
54
+ </EmptyState>
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export const WizardWithSubmitProgress: React.FunctionComponent = () => {
60
+ const [isSubmitted, setIsSubmitted] = React.useState(false);
61
+
62
+ // eslint-disable-next-line no-console
63
+ const onClose = () => console.log('Some close action occurs here.');
64
+
65
+ if (isSubmitted) {
66
+ return <ValidationProgress onClose={onClose} />;
67
+ }
68
+
69
+ return (
70
+ <Wizard height={400} title="Submit progress wizard" onClose={onClose}>
71
+ <WizardStep name="Step 1" id="submit-progress-step-1">
72
+ Step 1 content
73
+ </WizardStep>
74
+ <WizardStep name="Step 2" id="submit-progress-step-2">
75
+ Step 2 content
76
+ </WizardStep>
77
+ <WizardStep
78
+ name="Review"
79
+ id="submit-progress-review"
80
+ footer={{ nextButtonText: 'Finish', onNext: () => setIsSubmitted(true) }}
81
+ >
82
+ Review step content
83
+ </WizardStep>
84
+ </Wizard>
85
+ );
86
+ };
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Button, Modal, ModalVariant } from '@patternfly/react-core';
3
+ import { Wizard, WizardStep, WizardHeader } from '@patternfly/react-core/next';
4
+
5
+ export const WizardWithinModal = () => {
6
+ const [isModelOpen, setIsModalOpen] = React.useState(false);
7
+
8
+ return (
9
+ <>
10
+ <Button onClick={() => setIsModalOpen(true)}>Show Modal</Button>
11
+
12
+ <Modal
13
+ isOpen={isModelOpen}
14
+ showClose={false}
15
+ aria-label="Wizard modal"
16
+ hasNoBodyWrapper
17
+ variant={ModalVariant.medium}
18
+ >
19
+ <Wizard
20
+ height={400}
21
+ title="In modal wizard"
22
+ header={<WizardHeader title="Wizard in modal" description="Simple wizard description" />}
23
+ >
24
+ <WizardStep name="Step 1" id="in-modal-step-1">
25
+ Step 1 content
26
+ </WizardStep>
27
+ <WizardStep name="Step 2" id="in-modal-step-2">
28
+ Step 2 content
29
+ </WizardStep>
30
+ <WizardStep
31
+ name="Review"
32
+ id="in-modal-review-step"
33
+ footer={{ nextButtonText: 'Finish', onNext: () => setIsModalOpen(false) }}
34
+ >
35
+ Review step content
36
+ </WizardStep>
37
+ </Wizard>
38
+ </Modal>
39
+ </>
40
+ );
41
+ };
@@ -1 +1,2 @@
1
1
  export { useWizardFooter } from './useWizardFooter';
2
+ export { useGetMergedSteps } from './useGetMergedSteps';
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import isEqual from 'fast-deep-equal';
3
+ import { WizardStepType } from '../types';
4
+
5
+ /**
6
+ * Get stable ref of combined initial (prop provided) and current (context stored) steps.
7
+ * @param initialSteps
8
+ * @param currentSteps
9
+ * @returns WizardStepType[]
10
+ */
11
+ export const useGetMergedSteps = (initialSteps: WizardStepType[], currentSteps: WizardStepType[]): WizardStepType[] => {
12
+ const initialStepsRef = React.useRef(initialSteps);
13
+ const currentStepsRef = React.useRef(currentSteps);
14
+
15
+ // Check each value within the array of initialSteps (props) and currentSteps (context).
16
+ // If any value changes for either of these, update the reference.
17
+ if (!isEqual(initialStepsRef.current, initialSteps)) {
18
+ initialStepsRef.current = initialSteps;
19
+ }
20
+ if (!isEqual(currentStepsRef.current, currentSteps)) {
21
+ currentStepsRef.current = currentSteps;
22
+ }
23
+
24
+ // Combine both initial and current steps, where prop provided values
25
+ // take precedence over what's stored in context.
26
+ const mergedSteps = React.useMemo(
27
+ () =>
28
+ initialSteps.reduce((acc, initialStepProps, index) => {
29
+ const currentStepProps = currentSteps[index];
30
+
31
+ if (initialStepProps.id === currentStepProps.id) {
32
+ acc.push({
33
+ ...currentStepProps,
34
+ ...initialStepProps
35
+ });
36
+ }
37
+
38
+ return acc;
39
+ }, []),
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ [initialStepsRef.current, currentStepsRef.current]
42
+ );
43
+
44
+ return mergedSteps;
45
+ };
@@ -6,6 +6,6 @@ export * from './WizardStep';
6
6
  export * from './WizardNav';
7
7
  export * from './WizardNavItem';
8
8
  export * from './WizardHeader';
9
- export * from './hooks';
10
9
  export * from './types';
11
- export { useWizardContext } from './WizardContext';
10
+ export { useWizardFooter } from './hooks';
11
+ export { useWizardContext, WizardContext } from './WizardContext';
@@ -34,8 +34,8 @@ export enum WizardNavItemStatus {
34
34
  export interface WizardParentStep extends WizardBasicStep {
35
35
  /** Nested step IDs */
36
36
  subStepIds: (string | number)[];
37
- /** Flag to determine whether sub-steps can collapse or not */
38
- isCollapsible?: boolean;
37
+ /** Flag to determine whether the step can expand or not. */
38
+ isExpandable?: boolean;
39
39
  }
40
40
 
41
41
  /** Type used to define sub-steps. */
@@ -45,22 +45,12 @@ export interface WizardSubStep extends WizardBasicStep {
45
45
  }
46
46
 
47
47
  /** Encompasses all step type variants that are internally controlled by the Wizard. */
48
- export type WizardControlStep = WizardBasicStep | WizardParentStep | WizardSubStep;
48
+ export type WizardStepType = WizardBasicStep | WizardParentStep | WizardSubStep;
49
49
 
50
- /** Callback for the Wizard's 'onNext', 'onBack', and 'onNavByIndex' properties. */
51
- export type WizardNavStepFunction = (
52
- currentStep: WizardNavStepData,
53
- previousStep: WizardNavStepData
54
- ) => void | Promise<void>;
55
-
56
- /** Data returned for either parameter of WizardNavStepFunction. */
57
- export interface WizardNavStepData {
58
- /** Unique identifier */
59
- id: string | number;
60
- /** Name of the step */
61
- name: string;
62
- /** Index of the step (starts at 1) */
63
- index: number;
50
+ export enum WizardStepChangeScope {
51
+ Next = 'next',
52
+ Back = 'back',
53
+ Nav = 'nav'
64
54
  }
65
55
 
66
56
  export type WizardFooterType = Partial<WizardFooterProps> | CustomWizardFooterFunction | React.ReactElement;
@@ -70,25 +60,25 @@ export type WizardNavItemType = Partial<WizardNavItemProps> | CustomWizardNavIte
70
60
  /** Callback for the Wizard's 'nav' property. Returns element which replaces the Wizard's default navigation. */
71
61
  export type CustomWizardNavFunction = (
72
62
  isExpanded: boolean,
73
- steps: WizardControlStep[],
74
- activeStep: WizardControlStep,
63
+ steps: WizardStepType[],
64
+ activeStep: WizardStepType,
75
65
  goToStepByIndex: (index: number) => void
76
66
  ) => React.ReactElement<WizardNavProps>;
77
67
 
78
68
  /** Callback for the Wizard's 'navItem' property. Returns element which replaces the WizardStep's default navigation item. */
79
69
  export type CustomWizardNavItemFunction = (
80
- step: WizardControlStep,
81
- activeStep: WizardControlStep,
82
- steps: WizardControlStep[],
70
+ step: WizardStepType,
71
+ activeStep: WizardStepType,
72
+ steps: WizardStepType[],
83
73
  goToStepByIndex: (index: number) => void
84
74
  ) => React.ReactElement<WizardNavItemProps>;
85
75
 
86
76
  /** Callback for the Wizard's 'footer' property. Returns element which replaces the Wizard's default footer. */
87
77
  export type CustomWizardFooterFunction = (
88
- activeStep: WizardControlStep,
89
- onNext: () => void | Promise<void>,
90
- onBack: () => void | Promise<void>,
91
- onClose: () => void | Promise<void>
78
+ activeStep: WizardStepType,
79
+ onNext: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>,
80
+ onBack: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>,
81
+ onClose: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>
92
82
  ) => React.ReactElement<WizardFooterProps>;
93
83
 
94
84
  export function isCustomWizardNav(nav: WizardNavType): nav is CustomWizardNavFunction | React.ReactElement {
@@ -107,14 +97,14 @@ export function isCustomWizardFooter(
107
97
  return typeof footer === 'function' || React.isValidElement(footer);
108
98
  }
109
99
 
110
- export function isWizardBasicStep(step: WizardControlStep): step is WizardBasicStep {
100
+ export function isWizardBasicStep(step: WizardStepType): step is WizardBasicStep {
111
101
  return (step as WizardParentStep)?.subStepIds === undefined && !isWizardSubStep(step);
112
102
  }
113
103
 
114
- export function isWizardSubStep(step: WizardControlStep): step is WizardSubStep {
104
+ export function isWizardSubStep(step: WizardStepType): step is WizardSubStep {
115
105
  return (step as WizardSubStep)?.parentId !== undefined;
116
106
  }
117
107
 
118
- export function isWizardParentStep(step: WizardControlStep): step is WizardParentStep {
108
+ export function isWizardParentStep(step: WizardStepType): step is WizardParentStep {
119
109
  return (step as WizardParentStep)?.subStepIds !== undefined;
120
110
  }
@@ -1,45 +1,45 @@
1
1
  import React from 'react';
2
2
 
3
- import { WizardControlStep, WizardNavStepData } from './types';
3
+ import { WizardStepType } from './types';
4
4
  import { WizardStep, WizardStepProps } from './WizardStep';
5
5
 
6
6
  /**
7
7
  * Accumulate list of step & sub-step props pulled from child components
8
8
  * @param children
9
- * @returns WizardControlStep[]
9
+ * @returns WizardStepType[]
10
10
  */
11
- export const buildSteps = (children: React.ReactElement<WizardStepProps> | React.ReactElement<WizardStepProps>[]) =>
12
- React.Children.toArray(children).reduce((acc: WizardControlStep[], child: React.ReactNode) => {
11
+ export const buildSteps = (children: React.ReactNode | React.ReactNode[]) =>
12
+ React.Children.toArray(children).reduce((acc: WizardStepType[], child: React.ReactNode, index: number) => {
13
13
  if (isWizardStep(child)) {
14
- const { steps: subSteps, id, isHidden, isDisabled } = child.props;
15
- const subControlledSteps: WizardControlStep[] = [];
14
+ const { props: childProps } = child;
15
+ const { steps: childStepComponents, id } = childProps;
16
16
  const stepIndex = acc.length + 1;
17
+ const subSteps: WizardStepType[] = [];
17
18
 
18
19
  acc.push(
19
20
  {
20
21
  index: stepIndex,
21
22
  component: child,
22
- ...(stepIndex === 1 && { isVisited: true }),
23
- ...(subSteps && {
24
- subStepIds: subSteps?.map((subStep, subStepIndex) => {
25
- subControlledSteps.push({
26
- isHidden,
27
- isDisabled,
28
- component: subStep,
29
- parentId: id,
23
+ ...(index === 0 && !childStepComponents?.length && { isVisited: true }),
24
+ ...(childStepComponents && {
25
+ subStepIds: childStepComponents?.map((childStepComponent, subStepIndex) => {
26
+ subSteps.push({
30
27
  index: stepIndex + subStepIndex + 1,
31
- ...normalizeStep(subStep.props)
28
+ component: childStepComponent,
29
+ parentId: id,
30
+ ...(index === 0 && subStepIndex === 0 && { isVisited: true }),
31
+ ...normalizeStepProps(childStepComponent.props)
32
32
  });
33
33
 
34
- return subStep.props.id;
34
+ return childStepComponent.props.id;
35
35
  })
36
36
  }),
37
- ...normalizeStep(child.props)
37
+ ...normalizeStepProps(childProps)
38
38
  },
39
- ...subControlledSteps
39
+ ...subSteps
40
40
  );
41
41
  } else {
42
- throw new Error('Wizard only accepts children with required WizardStepProps.');
42
+ throw new Error('Wizard only accepts children of type WizardStep.');
43
43
  }
44
44
 
45
45
  return acc;
@@ -48,21 +48,15 @@ export const buildSteps = (children: React.ReactElement<WizardStepProps> | React
48
48
  export function isWizardStep(
49
49
  child: any | React.ReactElement<WizardStepProps>
50
50
  ): child is React.ReactElement<WizardStepProps> {
51
- return (
52
- (React.isValidElement(child) && (child as React.ReactElement<WizardStepProps>).type === WizardStep) ||
53
- (child.props?.name !== undefined && child.props?.id !== undefined)
54
- );
51
+ return React.isValidElement(child) && (child as React.ReactElement<WizardStepProps>).type === WizardStep;
55
52
  }
56
53
 
57
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
58
- export const normalizeStep = ({ children, steps, ...controlStep }: WizardStepProps): Omit<WizardControlStep, 'index'> =>
59
- controlStep;
60
-
61
- export const normalizeNavStep = (navStep: WizardControlStep): WizardNavStepData => ({
62
- id: navStep.id,
63
- index: navStep.index,
64
- name: navStep.name.toString()
65
- });
54
+ // Omit "children" and "steps" when building steps for the Wizard's context
55
+ export const normalizeStepProps = ({
56
+ children: _children,
57
+ steps: _steps,
58
+ ...controlStep
59
+ }: WizardStepProps): Omit<WizardStepType, 'index'> => controlStep;
66
60
 
67
- export const getActiveStep = (steps: WizardControlStep[], activeStepIndex: number) =>
61
+ export const getActiveStep = (steps: WizardStepType[], activeStepIndex: number) =>
68
62
  steps.find(step => step.index === activeStepIndex);