Debian Codegraph @

node/@patternfly/react-core/src/deprecated/components/Wizard/examples/WizardIncrementallyEnabledSteps.tsx

raw
1 import { useState } from 'react';
2 import { Wizard as WizardDeprecated, WizardStep } from '@patternfly/react-core/deprecated';
3
4 export const WizardIncrementallyEnabledSteps: React.FunctionComponent = () => {
5 const [stepIdReached, setStepIdReached] = useState(1);
6
7 const onNext = ({ id }: WizardStep) => {
8 if (id) {
9 if (typeof id === 'string') {
10 const [, orderIndex] = id.split('-');
11 id = parseInt(orderIndex);
12 }
13 setStepIdReached(stepIdReached < id ? id : stepIdReached);
14 }
15 };
16
17 const closeWizard = () => {
18 // eslint-disable-next-line no-console
19 console.log('close wizard');
20 };
21
22 const steps = [
23 { id: 'incrementallyEnabled-1', name: 'First step', component: <p>Step 1 content</p> },
24 {
25 id: 'incrementallyEnabled-2',
26 name: 'Second step',
27 component: <p>Step 2 content</p>,
28 canJumpTo: stepIdReached >= 2
29 },
30 {
31 id: 'incrementallyEnabled-3',
32 name: 'Third step',
33 component: <p>Step 3 content</p>,
34 canJumpTo: stepIdReached >= 3
35 },
36 {
37 id: 'incrementallyEnabled-4',
38 name: 'Fourth step',
39 component: <p>Step 4 content</p>,
40 canJumpTo: stepIdReached >= 4
41 },
42 {
43 id: 'incrementallyEnabled-5',
44 name: 'Review',
45 component: <p>Review step content</p>,
46 nextButtonText: 'Finish',
47 canJumpTo: stepIdReached >= 5
48 }
49 ];
50 const title = 'Incrementally enabled wizard example';
51 return (
52 <WizardDeprecated
53 navAriaLabel={`${title} steps`}
54 mainAriaLabel={`${title} content`}
55 onClose={closeWizard}
56 steps={steps}
57 onNext={onNext}
58 height={400}
59 />
60 );
61 };