@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.
- package/CHANGELOG.md +8 -0
- package/components/Menu/MenuGroup.d.ts +1 -1
- package/components/Menu/MenuGroup.d.ts.map +1 -1
- package/components/Menu/MenuGroup.js.map +1 -1
- package/dist/esm/components/Menu/MenuGroup.d.ts +1 -1
- package/dist/esm/components/Menu/MenuGroup.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuGroup.js.map +1 -1
- package/dist/esm/next/components/Wizard/Wizard.d.ts +11 -14
- package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/Wizard.js +30 -23
- package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.d.ts +16 -16
- package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.js +17 -19
- package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.js +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavInternal.js +15 -9
- package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.js +10 -9
- package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.js +4 -2
- package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/index.d.ts +1 -0
- package/dist/esm/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/index.js +1 -0
- package/dist/esm/next/components/Wizard/hooks/index.js.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/dist/esm/next/components/Wizard/index.d.ts +2 -2
- package/dist/esm/next/components/Wizard/index.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/index.js +2 -2
- package/dist/esm/next/components/Wizard/index.js.map +1 -1
- package/dist/esm/next/components/Wizard/types.d.ts +13 -19
- package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/types.js +6 -0
- package/dist/esm/next/components/Wizard/types.js.map +1 -1
- package/dist/esm/next/components/Wizard/utils.d.ts +5 -6
- package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/utils.js +15 -22
- package/dist/esm/next/components/Wizard/utils.js.map +1 -1
- package/dist/js/components/Menu/MenuGroup.d.ts +1 -1
- package/dist/js/components/Menu/MenuGroup.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuGroup.js.map +1 -1
- package/dist/js/next/components/Wizard/Wizard.d.ts +11 -14
- package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/Wizard.js +28 -21
- package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.d.ts +16 -16
- package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.js +16 -17
- package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.js +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/dist/js/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavInternal.js +15 -9
- package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.js +10 -8
- package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.js +4 -2
- package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/js/next/components/Wizard/hooks/index.d.ts +1 -0
- package/dist/js/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/hooks/index.js +3 -1
- package/dist/js/next/components/Wizard/hooks/index.js.map +1 -1
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js +38 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/dist/js/next/components/Wizard/index.d.ts +2 -2
- package/dist/js/next/components/Wizard/index.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/index.js +4 -2
- package/dist/js/next/components/Wizard/index.js.map +1 -1
- package/dist/js/next/components/Wizard/types.d.ts +13 -19
- package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/types.js +7 -1
- package/dist/js/next/components/Wizard/types.js.map +1 -1
- package/dist/js/next/components/Wizard/utils.d.ts +5 -6
- package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/utils.js +17 -25
- package/dist/js/next/components/Wizard/utils.js.map +1 -1
- package/next/components/Wizard/Wizard.d.ts +11 -14
- package/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/next/components/Wizard/Wizard.js +30 -23
- package/next/components/Wizard/Wizard.js.map +1 -1
- package/next/components/Wizard/WizardContext.d.ts +16 -16
- package/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/next/components/Wizard/WizardContext.js +17 -19
- package/next/components/Wizard/WizardContext.js.map +1 -1
- package/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/next/components/Wizard/WizardFooter.js +1 -1
- package/next/components/Wizard/WizardFooter.js.map +1 -1
- package/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavInternal.js +15 -9
- package/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavItem.js +10 -9
- package/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/next/components/Wizard/WizardStep.d.ts +3 -3
- package/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/next/components/Wizard/WizardStep.js +4 -2
- package/next/components/Wizard/WizardStep.js.map +1 -1
- package/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/next/components/Wizard/WizardToggle.js +1 -1
- package/next/components/Wizard/WizardToggle.js.map +1 -1
- package/next/components/Wizard/hooks/index.d.ts +1 -0
- package/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/next/components/Wizard/hooks/index.js +1 -0
- package/next/components/Wizard/hooks/index.js.map +1 -1
- package/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/next/components/Wizard/index.d.ts +2 -2
- package/next/components/Wizard/index.d.ts.map +1 -1
- package/next/components/Wizard/index.js +2 -2
- package/next/components/Wizard/index.js.map +1 -1
- package/next/components/Wizard/types.d.ts +13 -19
- package/next/components/Wizard/types.d.ts.map +1 -1
- package/next/components/Wizard/types.js +6 -0
- package/next/components/Wizard/types.js.map +1 -1
- package/next/components/Wizard/utils.d.ts +5 -6
- package/next/components/Wizard/utils.d.ts.map +1 -1
- package/next/components/Wizard/utils.js +15 -22
- package/next/components/Wizard/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Menu/MenuGroup.tsx +2 -2
- package/src/next/components/Wizard/Wizard.tsx +71 -46
- package/src/next/components/Wizard/WizardContext.tsx +38 -43
- package/src/next/components/Wizard/WizardFooter.tsx +10 -6
- package/src/next/components/Wizard/WizardHeader.tsx +1 -1
- package/src/next/components/Wizard/WizardNavInternal.tsx +51 -43
- package/src/next/components/Wizard/WizardNavItem.tsx +21 -14
- package/src/next/components/Wizard/WizardStep.tsx +8 -6
- package/src/next/components/Wizard/WizardToggle.tsx +5 -5
- package/src/next/components/Wizard/__tests__/Wizard.test.tsx +129 -26
- package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +5 -5
- package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +2 -2
- package/src/next/components/Wizard/__tests__/utils.test.tsx +3 -17
- package/src/next/components/Wizard/examples/Wizard.md +69 -41
- package/src/next/components/Wizard/examples/WizardBasic.tsx +6 -12
- package/src/next/components/Wizard/examples/WizardBasicDisabledSteps.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +84 -0
- package/src/next/components/Wizard/examples/WizardExpandableSteps.tsx +42 -0
- package/src/next/components/Wizard/examples/WizardGetCurrentStep.tsx +53 -0
- package/src/next/components/Wizard/examples/WizardProgressiveSteps.tsx +31 -0
- package/src/next/components/Wizard/examples/WizardStepDrawerContent.tsx +80 -0
- package/src/next/components/Wizard/examples/WizardStepErrorStatus.tsx +55 -0
- package/src/next/components/Wizard/examples/WizardStepVisitRequired.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardToggleStepVisibility.tsx +57 -0
- package/src/next/components/Wizard/examples/WizardValidateOnButtonPress.tsx +183 -0
- package/src/next/components/Wizard/examples/WizardWithCustomFooter.tsx +107 -0
- package/src/next/components/Wizard/examples/{WizardCustomNav.tsx → WizardWithCustomNav.tsx} +11 -11
- package/src/next/components/Wizard/examples/WizardWithCustomNavItem.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardWithHeader.tsx +26 -0
- package/src/next/components/Wizard/examples/WizardWithNavAnchors.tsx +46 -0
- package/src/next/components/Wizard/examples/WizardWithSubmitProgress.tsx +86 -0
- package/src/next/components/Wizard/examples/WizardWithinModal.tsx +41 -0
- package/src/next/components/Wizard/hooks/index.ts +1 -0
- package/src/next/components/Wizard/hooks/useGetMergedSteps.tsx +45 -0
- package/src/next/components/Wizard/index.ts +2 -2
- package/src/next/components/Wizard/types.tsx +19 -29
- package/src/next/components/Wizard/utils.ts +27 -33
- 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
|
+
};
|