@patternfly/react-core 4.274.0 → 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 (199) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/components/Menu/MenuGroup.d.ts +1 -1
  3. package/components/Menu/MenuGroup.d.ts.map +1 -1
  4. package/components/Menu/MenuGroup.js.map +1 -1
  5. package/dist/esm/components/Menu/MenuGroup.d.ts +1 -1
  6. package/dist/esm/components/Menu/MenuGroup.d.ts.map +1 -1
  7. package/dist/esm/components/Menu/MenuGroup.js.map +1 -1
  8. package/dist/esm/next/components/Wizard/Wizard.d.ts +11 -14
  9. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
  10. package/dist/esm/next/components/Wizard/Wizard.js +30 -23
  11. package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
  12. package/dist/esm/next/components/Wizard/WizardContext.d.ts +16 -16
  13. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
  14. package/dist/esm/next/components/Wizard/WizardContext.js +17 -19
  15. package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
  16. package/dist/esm/next/components/Wizard/WizardFooter.d.ts +8 -5
  17. package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  18. package/dist/esm/next/components/Wizard/WizardFooter.js +1 -1
  19. package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -1
  20. package/dist/esm/next/components/Wizard/WizardHeader.d.ts +1 -1
  21. package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  22. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  23. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  24. package/dist/esm/next/components/Wizard/WizardNavInternal.js +15 -9
  25. package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -1
  26. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +10 -4
  27. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  28. package/dist/esm/next/components/Wizard/WizardNavItem.js +10 -9
  29. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
  30. package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
  31. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
  32. package/dist/esm/next/components/Wizard/WizardStep.js +4 -2
  33. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
  34. package/dist/esm/next/components/Wizard/WizardToggle.d.ts +4 -4
  35. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  36. package/dist/esm/next/components/Wizard/WizardToggle.js +1 -1
  37. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
  38. package/dist/esm/next/components/Wizard/hooks/index.d.ts +1 -0
  39. package/dist/esm/next/components/Wizard/hooks/index.d.ts.map +1 -1
  40. package/dist/esm/next/components/Wizard/hooks/index.js +1 -0
  41. package/dist/esm/next/components/Wizard/hooks/index.js.map +1 -1
  42. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  43. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  44. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
  45. package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  46. package/dist/esm/next/components/Wizard/index.d.ts +2 -2
  47. package/dist/esm/next/components/Wizard/index.d.ts.map +1 -1
  48. package/dist/esm/next/components/Wizard/index.js +2 -2
  49. package/dist/esm/next/components/Wizard/index.js.map +1 -1
  50. package/dist/esm/next/components/Wizard/types.d.ts +13 -19
  51. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
  52. package/dist/esm/next/components/Wizard/types.js +6 -0
  53. package/dist/esm/next/components/Wizard/types.js.map +1 -1
  54. package/dist/esm/next/components/Wizard/utils.d.ts +5 -6
  55. package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
  56. package/dist/esm/next/components/Wizard/utils.js +15 -22
  57. package/dist/esm/next/components/Wizard/utils.js.map +1 -1
  58. package/dist/js/components/Menu/MenuGroup.d.ts +1 -1
  59. package/dist/js/components/Menu/MenuGroup.d.ts.map +1 -1
  60. package/dist/js/components/Menu/MenuGroup.js.map +1 -1
  61. package/dist/js/next/components/Wizard/Wizard.d.ts +11 -14
  62. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
  63. package/dist/js/next/components/Wizard/Wizard.js +28 -21
  64. package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
  65. package/dist/js/next/components/Wizard/WizardContext.d.ts +16 -16
  66. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
  67. package/dist/js/next/components/Wizard/WizardContext.js +16 -17
  68. package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
  69. package/dist/js/next/components/Wizard/WizardFooter.d.ts +8 -5
  70. package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  71. package/dist/js/next/components/Wizard/WizardFooter.js +1 -1
  72. package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -1
  73. package/dist/js/next/components/Wizard/WizardHeader.d.ts +1 -1
  74. package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  75. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  76. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  77. package/dist/js/next/components/Wizard/WizardNavInternal.js +15 -9
  78. package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -1
  79. package/dist/js/next/components/Wizard/WizardNavItem.d.ts +10 -4
  80. package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  81. package/dist/js/next/components/Wizard/WizardNavItem.js +10 -8
  82. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
  83. package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
  84. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
  85. package/dist/js/next/components/Wizard/WizardStep.js +4 -2
  86. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
  87. package/dist/js/next/components/Wizard/WizardToggle.d.ts +4 -4
  88. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  89. package/dist/js/next/components/Wizard/WizardToggle.js +1 -1
  90. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
  91. package/dist/js/next/components/Wizard/hooks/index.d.ts +1 -0
  92. package/dist/js/next/components/Wizard/hooks/index.d.ts.map +1 -1
  93. package/dist/js/next/components/Wizard/hooks/index.js +3 -1
  94. package/dist/js/next/components/Wizard/hooks/index.js.map +1 -1
  95. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  96. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  97. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js +38 -0
  98. package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  99. package/dist/js/next/components/Wizard/index.d.ts +2 -2
  100. package/dist/js/next/components/Wizard/index.d.ts.map +1 -1
  101. package/dist/js/next/components/Wizard/index.js +4 -2
  102. package/dist/js/next/components/Wizard/index.js.map +1 -1
  103. package/dist/js/next/components/Wizard/types.d.ts +13 -19
  104. package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
  105. package/dist/js/next/components/Wizard/types.js +7 -1
  106. package/dist/js/next/components/Wizard/types.js.map +1 -1
  107. package/dist/js/next/components/Wizard/utils.d.ts +5 -6
  108. package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
  109. package/dist/js/next/components/Wizard/utils.js +17 -25
  110. package/dist/js/next/components/Wizard/utils.js.map +1 -1
  111. package/next/components/Wizard/Wizard.d.ts +11 -14
  112. package/next/components/Wizard/Wizard.d.ts.map +1 -1
  113. package/next/components/Wizard/Wizard.js +30 -23
  114. package/next/components/Wizard/Wizard.js.map +1 -1
  115. package/next/components/Wizard/WizardContext.d.ts +16 -16
  116. package/next/components/Wizard/WizardContext.d.ts.map +1 -1
  117. package/next/components/Wizard/WizardContext.js +17 -19
  118. package/next/components/Wizard/WizardContext.js.map +1 -1
  119. package/next/components/Wizard/WizardFooter.d.ts +8 -5
  120. package/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  121. package/next/components/Wizard/WizardFooter.js +1 -1
  122. package/next/components/Wizard/WizardFooter.js.map +1 -1
  123. package/next/components/Wizard/WizardHeader.d.ts +1 -1
  124. package/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  125. package/next/components/Wizard/WizardNavInternal.d.ts +2 -2
  126. package/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
  127. package/next/components/Wizard/WizardNavInternal.js +15 -9
  128. package/next/components/Wizard/WizardNavInternal.js.map +1 -1
  129. package/next/components/Wizard/WizardNavItem.d.ts +10 -4
  130. package/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  131. package/next/components/Wizard/WizardNavItem.js +10 -9
  132. package/next/components/Wizard/WizardNavItem.js.map +1 -1
  133. package/next/components/Wizard/WizardStep.d.ts +3 -3
  134. package/next/components/Wizard/WizardStep.d.ts.map +1 -1
  135. package/next/components/Wizard/WizardStep.js +4 -2
  136. package/next/components/Wizard/WizardStep.js.map +1 -1
  137. package/next/components/Wizard/WizardToggle.d.ts +4 -4
  138. package/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  139. package/next/components/Wizard/WizardToggle.js +1 -1
  140. package/next/components/Wizard/WizardToggle.js.map +1 -1
  141. package/next/components/Wizard/hooks/index.d.ts +1 -0
  142. package/next/components/Wizard/hooks/index.d.ts.map +1 -1
  143. package/next/components/Wizard/hooks/index.js +1 -0
  144. package/next/components/Wizard/hooks/index.js.map +1 -1
  145. package/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
  146. package/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
  147. package/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
  148. package/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
  149. package/next/components/Wizard/index.d.ts +2 -2
  150. package/next/components/Wizard/index.d.ts.map +1 -1
  151. package/next/components/Wizard/index.js +2 -2
  152. package/next/components/Wizard/index.js.map +1 -1
  153. package/next/components/Wizard/types.d.ts +13 -19
  154. package/next/components/Wizard/types.d.ts.map +1 -1
  155. package/next/components/Wizard/types.js +6 -0
  156. package/next/components/Wizard/types.js.map +1 -1
  157. package/next/components/Wizard/utils.d.ts +5 -6
  158. package/next/components/Wizard/utils.d.ts.map +1 -1
  159. package/next/components/Wizard/utils.js +15 -22
  160. package/next/components/Wizard/utils.js.map +1 -1
  161. package/package.json +2 -2
  162. package/src/components/Menu/MenuGroup.tsx +2 -2
  163. package/src/next/components/Wizard/Wizard.tsx +71 -46
  164. package/src/next/components/Wizard/WizardContext.tsx +38 -43
  165. package/src/next/components/Wizard/WizardFooter.tsx +10 -6
  166. package/src/next/components/Wizard/WizardHeader.tsx +1 -1
  167. package/src/next/components/Wizard/WizardNavInternal.tsx +51 -43
  168. package/src/next/components/Wizard/WizardNavItem.tsx +21 -14
  169. package/src/next/components/Wizard/WizardStep.tsx +8 -6
  170. package/src/next/components/Wizard/WizardToggle.tsx +5 -5
  171. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +129 -26
  172. package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +5 -5
  173. package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +2 -2
  174. package/src/next/components/Wizard/__tests__/utils.test.tsx +3 -17
  175. package/src/next/components/Wizard/examples/Wizard.md +69 -41
  176. package/src/next/components/Wizard/examples/WizardBasic.tsx +6 -12
  177. package/src/next/components/Wizard/examples/WizardBasicDisabledSteps.tsx +22 -0
  178. package/src/next/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +84 -0
  179. package/src/next/components/Wizard/examples/WizardExpandableSteps.tsx +42 -0
  180. package/src/next/components/Wizard/examples/WizardGetCurrentStep.tsx +53 -0
  181. package/src/next/components/Wizard/examples/WizardProgressiveSteps.tsx +31 -0
  182. package/src/next/components/Wizard/examples/WizardStepDrawerContent.tsx +80 -0
  183. package/src/next/components/Wizard/examples/WizardStepErrorStatus.tsx +55 -0
  184. package/src/next/components/Wizard/examples/WizardStepVisitRequired.tsx +22 -0
  185. package/src/next/components/Wizard/examples/WizardToggleStepVisibility.tsx +57 -0
  186. package/src/next/components/Wizard/examples/WizardValidateOnButtonPress.tsx +183 -0
  187. package/src/next/components/Wizard/examples/WizardWithCustomFooter.tsx +107 -0
  188. package/src/next/components/Wizard/examples/{WizardCustomNav.tsx → WizardWithCustomNav.tsx} +11 -11
  189. package/src/next/components/Wizard/examples/WizardWithCustomNavItem.tsx +22 -0
  190. package/src/next/components/Wizard/examples/WizardWithHeader.tsx +26 -0
  191. package/src/next/components/Wizard/examples/WizardWithNavAnchors.tsx +46 -0
  192. package/src/next/components/Wizard/examples/WizardWithSubmitProgress.tsx +86 -0
  193. package/src/next/components/Wizard/examples/WizardWithinModal.tsx +41 -0
  194. package/src/next/components/Wizard/hooks/index.ts +1 -0
  195. package/src/next/components/Wizard/hooks/useGetMergedSteps.tsx +45 -0
  196. package/src/next/components/Wizard/index.ts +2 -2
  197. package/src/next/components/Wizard/types.tsx +19 -29
  198. package/src/next/components/Wizard/utils.ts +27 -33
  199. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +0 -243
@@ -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
+ );
@@ -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
+ };