@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.
- package/CHANGELOG.md +24 -0
- package/components/Chip/Chip.d.ts.map +1 -1
- package/components/Chip/Chip.js +5 -4
- package/components/Chip/Chip.js.map +1 -1
- 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/components/Text/TextList.d.ts +2 -0
- package/components/Text/TextList.d.ts.map +1 -1
- package/components/Text/TextList.js +3 -2
- package/components/Text/TextList.js.map +1 -1
- package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
- package/dist/esm/components/Chip/Chip.js +5 -4
- package/dist/esm/components/Chip/Chip.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/components/Text/TextList.d.ts +2 -0
- package/dist/esm/components/Text/TextList.d.ts.map +1 -1
- package/dist/esm/components/Text/TextList.js +3 -2
- package/dist/esm/components/Text/TextList.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/Chip/Chip.d.ts.map +1 -1
- package/dist/js/components/Chip/Chip.js +4 -4
- package/dist/js/components/Chip/Chip.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/components/Text/TextList.d.ts +2 -0
- package/dist/js/components/Text/TextList.d.ts.map +1 -1
- package/dist/js/components/Text/TextList.js +3 -2
- package/dist/js/components/Text/TextList.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/dist/umd/react-core.min.js +2 -2
- 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/Chip/Chip.tsx +4 -2
- package/src/components/Chip/__tests__/Chip.test.tsx +9 -0
- package/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +55 -0
- package/src/components/ChipGroup/__tests__/__snapshots__/ChipGroup.test.tsx.snap +4 -0
- package/src/components/Menu/MenuGroup.tsx +2 -2
- package/src/components/Modal/examples/Modal.md +46 -11
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
- package/src/components/Text/TextList.tsx +5 -1
- package/src/components/Text/__tests__/TextList.test.tsx +5 -0
- package/src/components/Text/examples/Text.md +5 -0
- package/src/components/Text/examples/TextPlainList.tsx +24 -0
- package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +2 -0
- 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,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
|
+
};
|
|
@@ -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 {
|
|
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
|
|
38
|
-
|
|
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
|
|
48
|
+
export type WizardStepType = WizardBasicStep | WizardParentStep | WizardSubStep;
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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:
|
|
74
|
-
activeStep:
|
|
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:
|
|
81
|
-
activeStep:
|
|
82
|
-
steps:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 {
|
|
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
|
|
9
|
+
* @returns WizardStepType[]
|
|
10
10
|
*/
|
|
11
|
-
export const buildSteps = (children: React.
|
|
12
|
-
React.Children.toArray(children).reduce((acc:
|
|
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 {
|
|
15
|
-
const
|
|
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
|
-
...(
|
|
23
|
-
...(
|
|
24
|
-
subStepIds:
|
|
25
|
-
|
|
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
|
-
|
|
28
|
+
component: childStepComponent,
|
|
29
|
+
parentId: id,
|
|
30
|
+
...(index === 0 && subStepIndex === 0 && { isVisited: true }),
|
|
31
|
+
...normalizeStepProps(childStepComponent.props)
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
return
|
|
34
|
+
return childStepComponent.props.id;
|
|
35
35
|
})
|
|
36
36
|
}),
|
|
37
|
-
...
|
|
37
|
+
...normalizeStepProps(childProps)
|
|
38
38
|
},
|
|
39
|
-
...
|
|
39
|
+
...subSteps
|
|
40
40
|
);
|
|
41
41
|
} else {
|
|
42
|
-
throw new Error('Wizard only accepts children
|
|
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
|
-
//
|
|
58
|
-
export const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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:
|
|
61
|
+
export const getActiveStep = (steps: WizardStepType[], activeStepIndex: number) =>
|
|
68
62
|
steps.find(step => step.index === activeStepIndex);
|