@patternfly/react-core 4.267.3 → 4.267.5

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 (30) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts +14 -1
  3. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  4. package/dist/esm/components/CalendarMonth/CalendarMonth.js +10 -2
  5. package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
  6. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts +14 -1
  7. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  8. package/dist/js/components/CalendarMonth/CalendarMonth.js +10 -2
  9. package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
  10. package/dist/umd/react-core.min.js +1 -1
  11. package/package.json +2 -2
  12. package/src/components/CalendarMonth/CalendarMonth.tsx +26 -1
  13. package/src/components/CalendarMonth/__tests__/CalendarMonth.test.tsx +9 -0
  14. package/src/components/CalendarMonth/examples/CalendarMonth.md +1 -1
  15. package/src/components/CalendarMonth/examples/CalendarMonthDateRange.tsx +19 -2
  16. package/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx +14 -4
  17. package/src/components/Wizard/examples/Wizard.md +14 -691
  18. package/src/components/Wizard/examples/WizardAnchorsForNavItems.tsx +42 -0
  19. package/src/components/Wizard/examples/WizardBasic.tsx +14 -0
  20. package/src/components/Wizard/examples/WizardBasicWithDisabledSteps.tsx +14 -0
  21. package/src/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +139 -0
  22. package/src/components/Wizard/examples/WizardExpandableSteps.tsx +34 -0
  23. package/src/components/Wizard/examples/WizardFinished.tsx +90 -0
  24. package/src/components/Wizard/examples/WizardGetCurrentStep.tsx +33 -0
  25. package/src/components/Wizard/examples/WizardInModal.tsx +32 -0
  26. package/src/components/Wizard/examples/WizardIncrementallyEnabledSteps.tsx +61 -0
  27. package/src/components/Wizard/examples/WizardValidateOnButtonPress.tsx +204 -0
  28. package/src/components/Wizard/examples/WizardWithDrawer.tsx +126 -0
  29. package/src/components/Wizard/examples/FinishedStep.js +0 -70
  30. package/src/components/Wizard/examples/SampleForm.js +0 -59
@@ -8,11 +8,11 @@ ouia: true
8
8
  ---
9
9
 
10
10
  import { Button, Drawer, DrawerActions, DrawerCloseButton, DrawerColorVariant,
11
- DrawerContent, DrawerContentBody, DrawerHead, DrawerPanelContent, DrawerSection, Wizard, WizardFooter, WizardContextConsumer, ModalVariant, Alert, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStateSecondaryActions, Title, Progress } from '@patternfly/react-core';
11
+ DrawerContent, DrawerContentBody, DrawerHead, DrawerPanelContent, DrawerSection, Wizard, WizardFooter, WizardContextConsumer, ModalVariant, Alert, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStateSecondaryActions, Title, Progress, Form, FormGroup, TextInput } from '@patternfly/react-core';
12
12
  import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
13
13
  import SlackHashIcon from '@patternfly/react-icons/dist/esm/icons/slack-hash-icon';
14
- import FinishedStep from './FinishedStep';
15
- import SampleForm from './SampleForm';
14
+ import CogsIcon from '@patternfly/react-icons/dist/esm/icons/cogs-icon';
15
+
16
16
 
17
17
  If you seek a wizard solution that allows for more composition, see the [React next](/components/wizard/react-next) tab.
18
18
 
@@ -20,374 +20,37 @@ If you seek a wizard solution that allows for more composition, see the [React n
20
20
 
21
21
  ### Basic
22
22
 
23
- ```js
24
- import React from 'react';
25
- import { Button, Wizard } from '@patternfly/react-core';
26
-
27
- class SimpleWizard extends React.Component {
28
- constructor(props) {
29
- super(props);
30
- }
31
-
32
- render() {
33
- const steps = [
34
- { name: 'First step', component: <p>Step 1 content</p> },
35
- { name: 'Second step', component: <p>Step 2 content</p> },
36
- { name: 'Third step', component: <p>Step 3 content</p> },
37
- { name: 'Fourth step', component: <p>Step 4 content</p> },
38
- { name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' }
39
- ];
40
- const title = 'Basic wizard';
41
- return <Wizard navAriaLabel={`${title} steps`} mainAriaLabel={`${title} content`} steps={steps} height={400} />;
42
- }
43
- }
23
+ ```ts file="./WizardBasic.tsx"
44
24
  ```
45
25
 
46
26
  ### Basic with disabled steps
47
27
 
48
- ```js
49
- import React from 'react';
50
- import { Button, Wizard } from '@patternfly/react-core';
51
-
52
- class SimpleWizard extends React.Component {
53
- constructor(props) {
54
- super(props);
55
- }
56
-
57
- render() {
58
- const steps = [
59
- { name: 'First step', component: <p>Step 1 content</p> },
60
- { name: 'Second step', component: <p>Step 2 content</p>, isDisabled: true },
61
- { name: 'Third step', component: <p>Step 3 content</p> },
62
- { name: 'Fourth step', component: <p>Step 4 content</p>, isDisabled: true },
63
- { name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' }
64
- ];
65
- const title = 'Basic wizard';
66
- return <Wizard navAriaLabel={`${title} steps`} mainAriaLabel={`${title} content`} steps={steps} height={400} />;
67
- }
68
- }
28
+ ```ts file="./WizardBasicWithDisabledSteps.tsx"
69
29
  ```
70
30
 
71
31
  ### Anchors for nav items
72
32
 
73
- ```js
74
- import React from 'react';
75
- import { Button, Wizard } from '@patternfly/react-core';
76
- import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
77
- import SlackHashIcon from '@patternfly/react-icons/dist/esm/icons/slack-hash-icon';
78
-
79
- class WizardWithNavAnchors extends React.Component {
80
- constructor(props) {
81
- super(props);
82
- }
83
-
84
- render() {
85
- const steps = [
86
- {
87
- name: (
88
- <div>
89
- <ExternalLinkAltIcon /> PF3
90
- </div>
91
- ),
92
- component: <p>Step 1: Read about PF3</p>,
93
- stepNavItemProps: { navItemComponent: 'a', href: 'https://www.patternfly.org/v3/', target: '_blank' }
94
- },
95
- {
96
- name: (
97
- <div>
98
- <ExternalLinkAltIcon /> PF4
99
- </div>
100
- ),
101
- component: <p>Step 2: Read about PF4</p>,
102
- stepNavItemProps: { navItemComponent: 'a', href: 'https://www.patternfly.org/v4/', target: '_blank' }
103
- },
104
- {
105
- name: (
106
- <div>
107
- <SlackHashIcon /> Join us on slack
108
- </div>
109
- ),
110
- component: (
111
- <Button variant="link" component="a" target="_blank" href="https://patternfly.slack.com/">
112
- Join the conversation
113
- </Button>
114
- ),
115
- stepNavItemProps: { navItemComponent: 'a', href: 'https://patternfly.slack.com/', target: '_blank' }
116
- }
117
- ];
118
- const title = 'Anchor link wizard';
119
- return <Wizard navAriaLabel={`${title} steps`} mainAriaLabel={`${title} content`} steps={steps} height={400} />;
120
- }
121
- }
33
+ ```ts file="./WizardAnchorsForNavItems.tsx"
122
34
  ```
123
35
 
124
36
  ### Incrementally enabled steps
125
37
 
126
- ```js
127
- import React from 'react';
128
- import { Button, Wizard } from '@patternfly/react-core';
129
-
130
- class IncrementallyEnabledStepsWizard extends React.Component {
131
- constructor(props) {
132
- super(props);
133
- this.state = {
134
- stepIdReached: 1
135
- };
136
- this.onNext = ({ id }) => {
137
- const [, orderIndex] = id.split('-');
138
-
139
- this.setState({
140
- stepIdReached: this.state.stepIdReached < orderIndex ? orderIndex : this.state.stepIdReached
141
- });
142
- };
143
- this.closeWizard = () => {
144
- console.log('close wizard');
145
- };
146
- }
147
-
148
- render() {
149
- const { stepIdReached } = this.state;
150
-
151
- const steps = [
152
- { id: 'incrementallyEnabled-1', name: 'First step', component: <p>Step 1 content</p> },
153
- {
154
- id: 'incrementallyEnabled-2',
155
- name: 'Second step',
156
- component: <p>Step 2 content</p>,
157
- canJumpTo: stepIdReached >= 2
158
- },
159
- {
160
- id: 'incrementallyEnabled-3',
161
- name: 'Third step',
162
- component: <p>Step 3 content</p>,
163
- canJumpTo: stepIdReached >= 3
164
- },
165
- {
166
- id: 'incrementallyEnabled-4',
167
- name: 'Fourth step',
168
- component: <p>Step 4 content</p>,
169
- canJumpTo: stepIdReached >= 4
170
- },
171
- {
172
- id: 'incrementallyEnabled-5',
173
- name: 'Review',
174
- component: <p>Review step content</p>,
175
- nextButtonText: 'Finish',
176
- canJumpTo: stepIdReached >= 5
177
- }
178
- ];
179
- const title = 'Incrementally enabled wizard';
180
- return (
181
- <Wizard
182
- navAriaLabel={`${title} steps`}
183
- mainAriaLabel={`${title} content`}
184
- onClose={this.closeWizard}
185
- steps={steps}
186
- onNext={this.onNext}
187
- height={400}
188
- />
189
- );
190
- }
191
- }
38
+ ```ts file="./WizardIncrementallyEnabledSteps.tsx"
192
39
  ```
193
40
 
194
41
  ### Expandable steps
195
42
 
196
- ```js
197
- import React from 'react';
198
- import { Button, Wizard } from '@patternfly/react-core';
199
-
200
- class SimpleWizard extends React.Component {
201
- constructor(props) {
202
- super(props);
203
- }
204
-
205
- render() {
206
- const steps = [
207
- {
208
- name: 'First step',
209
- steps: [
210
- { name: 'Substep A', component: <p>Substep A content</p> },
211
- { name: 'Substep B', component: <p>Substep B content</p> }
212
- ]
213
- },
214
- { name: 'Second step', component: <p>Step 2 content</p> },
215
- {
216
- name: 'Third step',
217
- steps: [
218
- { name: 'Substep C', component: <p>Substep C content</p> },
219
- { name: 'Substep D', component: <p>Substep D content</p> }
220
- ]
221
- },
222
- { name: 'Fourth step', component: <p>Step 4 content</p> },
223
- { name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' }
224
- ];
225
- const title = 'Expandable wizard';
226
- return (
227
- <Wizard
228
- navAriaLabel={`${title} steps`}
229
- mainAriaLabel={`${title} content`}
230
- steps={steps}
231
- height={400}
232
- isNavExpandable
233
- />
234
- );
235
- }
236
- }
43
+ ```ts file="./WizardExpandableSteps.tsx"
237
44
  ```
238
45
 
239
46
  ### Finished
240
47
 
241
- ```js
242
- import React from 'react';
243
- import { Button, Wizard } from '@patternfly/react-core';
244
- import FinishedStep from './examples/FinishedStep';
245
-
246
- class FinishedStepWizard extends React.Component {
247
- constructor(props) {
248
- super(props);
249
-
250
- this.closeWizard = () => {
251
- console.log('close wizard');
252
- };
253
- }
254
-
255
- render() {
256
- const steps = [
257
- { name: 'First step', component: <p>Step 1 content</p> },
258
- { name: 'Second step', component: <p>Step 2 content</p> },
259
- { name: 'Third step', component: <p>Step 3 content</p> },
260
- { name: 'Fourth step', component: <p>Step 4 content</p> },
261
- { name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' },
262
- { name: 'Finish', component: <FinishedStep onClose={this.closeWizard} />, isFinishedStep: true }
263
- ];
264
- const title = 'Finished wizard';
265
- return (
266
- <Wizard
267
- navAriaLabel={`${title} steps`}
268
- mainAriaLabel={`${title} content`}
269
- onClose={this.closeWizard}
270
- steps={steps}
271
- height={400}
272
- />
273
- );
274
- }
275
- }
48
+ ```ts file="./WizardFinished.tsx"
276
49
  ```
277
50
 
278
51
  ### Enabled on form validation
279
52
 
280
- ```js
281
- import React from 'react';
282
- import { Button, Wizard, Form, FormGroup, TextInput } from '@patternfly/react-core';
283
- import SampleForm from './examples/SampleForm';
284
-
285
- class ValidationWizard extends React.Component {
286
- constructor(props) {
287
- super(props);
288
- this.state = {
289
- isFormValid: false,
290
- formValue: 'Thirty',
291
- allStepsValid: false,
292
- stepIdReached: 1
293
- };
294
-
295
- this.closeWizard = () => {
296
- console.log('close wizard');
297
- };
298
-
299
- this.onFormChange = (isValid, value) => {
300
- this.setState(
301
- {
302
- isFormValid: isValid,
303
- formValue: value
304
- },
305
- this.areAllStepsValid
306
- );
307
- };
308
-
309
- this.areAllStepsValid = () => {
310
- this.setState({
311
- allStepsValid: this.state.isFormValid
312
- });
313
- };
314
-
315
- this.onNext = ({ id, name }, { prevId, prevName }) => {
316
- console.log(`current id: ${id}, current name: ${name}, previous id: ${prevId}, previous name: ${prevName}`);
317
- const [, orderIndex] = id.split('-');
318
-
319
- this.setState({
320
- stepIdReached: this.state.stepIdReached < orderIndex ? orderIndex : this.state.stepIdReached
321
- });
322
- this.areAllStepsValid();
323
- };
324
-
325
- this.onBack = ({ id, name }, { prevId, prevName }) => {
326
- console.log(`current id: ${id}, current name: ${name}, previous id: ${prevId}, previous name: ${prevName}`);
327
- this.areAllStepsValid();
328
- };
329
-
330
- this.onGoToStep = ({ id, name }, { prevId, prevName }) => {
331
- console.log(`current id: ${id}, current name: ${name}, previous id: ${prevId}, previous name: ${prevName}`);
332
- };
333
-
334
- this.onSave = () => {
335
- console.log('Saved and closed the wizard');
336
- this.setState({
337
- isOpen: false
338
- });
339
- };
340
- }
341
-
342
- render() {
343
- const { isFormValid, formValue, allStepsValid, stepIdReached } = this.state;
344
-
345
- const steps = [
346
- { id: 'validated-1', name: 'Information', component: <p>Step 1 content</p> },
347
- {
348
- name: 'Configuration',
349
- steps: [
350
- {
351
- id: 'validated-2',
352
- name: 'Substep A with validation',
353
- component: <SampleForm formValue={formValue} isFormValid={isFormValid} onChange={this.onFormChange} />,
354
- enableNext: isFormValid,
355
- canJumpTo: stepIdReached >= 2
356
- },
357
- { id: 'validated-3', name: 'Substep B', component: <p>Substep B</p>, canJumpTo: stepIdReached >= 3 }
358
- ]
359
- },
360
- {
361
- id: 'validated-4',
362
- name: 'Additional',
363
- component: <p>Step 3 content</p>,
364
- enableNext: allStepsValid,
365
- canJumpTo: stepIdReached >= 4
366
- },
367
- {
368
- id: 'validated-5',
369
- name: 'Review',
370
- component: <p>Step 4 content</p>,
371
- nextButtonText: 'Close',
372
- canJumpTo: stepIdReached >= 5
373
- }
374
- ];
375
- const title = 'Enabled on form validation wizard';
376
- return (
377
- <Wizard
378
- navAriaLabel={`${title} steps`}
379
- mainAriaLabel={`${title} content`}
380
- onClose={this.closeWizard}
381
- onSave={this.onSave}
382
- steps={steps}
383
- onNext={this.onNext}
384
- onBack={this.onBack}
385
- onGoToStep={this.onGoToStep}
386
- height={400}
387
- />
388
- );
389
- }
390
- }
53
+ ```ts file="./WizardEnabledOnFormValidation.tsx"
391
54
  ```
392
55
 
393
56
  ### Validate on button press
@@ -407,104 +70,7 @@ interface WizardContext {
407
70
  }
408
71
  ```
409
72
 
410
- ```js
411
- import React from 'react';
412
- import { Button, Wizard, WizardFooter, WizardContextConsumer, Alert } from '@patternfly/react-core';
413
- import SampleForm from './examples/SampleForm';
414
- import FinishedStep from './examples/FinishedStep';
415
-
416
- class ValidateButtonPressWizard extends React.Component {
417
- constructor(props) {
418
- super(props);
419
- this.state = {
420
- stepsValid: 0
421
- };
422
-
423
- this.closeWizard = () => {
424
- console.log('close wizard');
425
- };
426
-
427
- this.validateLastStep = onNext => {
428
- const { stepsValid } = this.state;
429
- if (stepsValid !== 1) {
430
- this.setState({
431
- stepsValid: 1
432
- });
433
- } else {
434
- onNext();
435
- }
436
- };
437
- }
438
-
439
- render() {
440
- const { stepsValid } = this.state;
441
-
442
- const steps = [
443
- { name: 'First step', component: <p>Step 1 content</p> },
444
- { name: 'Second step', component: <p>Step 2 content</p> },
445
- {
446
- name: 'Final Step',
447
- component: (
448
- <>
449
- {stepsValid === 1 && (
450
- <div style={{ padding: '15px 0' }}>
451
- <Alert variant="warning" title="Validation failed, please try again" />
452
- </div>
453
- )}
454
- <SampleForm formValue="Validating on button press" isFormValid={stepsValid !== 1} />
455
- </>
456
- )
457
- },
458
- { name: 'Finish', component: <FinishedStep onClose={this.closeWizard} />, isFinishedStep: true }
459
- ];
460
-
461
- const CustomFooter = (
462
- <WizardFooter>
463
- <WizardContextConsumer>
464
- {({ activeStep, goToStepByName, goToStepById, onNext, onBack, onClose }) => {
465
- if (activeStep.name !== 'Final Step') {
466
- return (
467
- <>
468
- <Button variant="primary" type="submit" onClick={onNext}>
469
- Forward
470
- </Button>
471
- <Button
472
- variant="secondary"
473
- onClick={onBack}
474
- className={activeStep.name === 'Step 1' ? 'pf-m-disabled' : ''}
475
- >
476
- Backward
477
- </Button>
478
- <Button variant="link" onClick={onClose}>
479
- Cancel
480
- </Button>
481
- </>
482
- );
483
- }
484
- // Final step buttons
485
- return (
486
- <>
487
- <Button onClick={() => this.validateLastStep(onNext)}>Validate</Button>
488
- <Button onClick={() => goToStepByName('Step 1')}>Go to Beginning</Button>
489
- </>
490
- );
491
- }}
492
- </WizardContextConsumer>
493
- </WizardFooter>
494
- );
495
- const title = 'Validate on button press wizard';
496
- return (
497
- <Wizard
498
- navAriaLabel={`${title} steps`}
499
- mainAriaLabel={`${title} content`}
500
- onClose={this.closeWizard}
501
- footer={CustomFooter}
502
- steps={steps}
503
- height={400}
504
- />
505
- );
506
- }
507
- }
73
+ ```ts file="./WizardValidateOnButtonPress.tsx"
508
74
  ```
509
75
 
510
76
  ### Progressive steps
@@ -512,8 +78,6 @@ class ValidateButtonPressWizard extends React.Component {
512
78
  ```js
513
79
  import React from 'react';
514
80
  import { Button, Radio, Wizard, WizardFooter, WizardContextConsumer, Alert } from '@patternfly/react-core';
515
- import SampleForm from './examples/SampleForm';
516
- import FinishedStep from './examples/FinishedStep';
517
81
 
518
82
  class ProgressiveWizard extends React.Component {
519
83
  constructor(props) {
@@ -642,7 +206,6 @@ class ProgressiveWizard extends React.Component {
642
206
  }
643
207
  };
644
208
  }
645
-
646
209
  render() {
647
210
  const {
648
211
  stepsValid,
@@ -654,7 +217,6 @@ class ProgressiveWizard extends React.Component {
654
217
  showOptionsStep,
655
218
  showReviewStep
656
219
  } = this.state;
657
-
658
220
  const getStartedStep = {
659
221
  name: 'Get started',
660
222
  component: (
@@ -678,7 +240,6 @@ class ProgressiveWizard extends React.Component {
678
240
  </div>
679
241
  )
680
242
  };
681
-
682
243
  const createStep = {
683
244
  name: 'Create options',
684
245
  component: (
@@ -702,7 +263,6 @@ class ProgressiveWizard extends React.Component {
702
263
  </div>
703
264
  )
704
265
  };
705
-
706
266
  const updateStep = {
707
267
  name: 'Update options',
708
268
  component: (
@@ -726,7 +286,6 @@ class ProgressiveWizard extends React.Component {
726
286
  </div>
727
287
  )
728
288
  };
729
-
730
289
  const optionsStep = {
731
290
  name: showCreateStep ? `${createStepRadio} Options` : `${updateStepRadio} Options`,
732
291
  steps: [
@@ -744,7 +303,6 @@ class ProgressiveWizard extends React.Component {
744
303
  }
745
304
  ]
746
305
  };
747
-
748
306
  const reviewStep = {
749
307
  name: 'Review',
750
308
  component: (
@@ -754,7 +312,6 @@ class ProgressiveWizard extends React.Component {
754
312
  </div>
755
313
  )
756
314
  };
757
-
758
315
  const steps = [
759
316
  getStartedStep,
760
317
  ...(showCreateStep ? [createStep] : []),
@@ -762,7 +319,6 @@ class ProgressiveWizard extends React.Component {
762
319
  ...(showOptionsStep ? [optionsStep] : []),
763
320
  ...(showReviewStep ? [reviewStep] : [])
764
321
  ];
765
-
766
322
  const CustomFooter = (
767
323
  <WizardFooter>
768
324
  <WizardContextConsumer>
@@ -806,248 +362,15 @@ class ProgressiveWizard extends React.Component {
806
362
 
807
363
  ### Get current step
808
364
 
809
- ```js
810
- import React from 'react';
811
- import { Button, Wizard } from '@patternfly/react-core';
812
-
813
- class GetCurrentStepWizard extends React.Component {
814
- constructor(props) {
815
- super(props);
816
- this.state = {
817
- step: 1
818
- };
819
- this.onCurrentStepChanged = ({ id }) => {
820
- this.setState({
821
- step: id
822
- });
823
- };
824
- this.closeWizard = () => {
825
- console.log('close wizard');
826
- };
827
- }
828
-
829
- render() {
830
- const steps = [
831
- { id: 1, name: 'First step', component: <p>Step 1 content</p> },
832
- { id: 2, name: 'Second step', component: <p>Step 2 content</p> },
833
- { id: 3, name: 'Third step', component: <p>Step 3 content</p> },
834
- { id: 4, name: 'Fourth step', component: <p>Step 4 content</p> },
835
- { id: 5, name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' }
836
- ];
837
- const title = 'Get current step wizard';
838
- return (
839
- <Wizard
840
- navAriaLabel={`${title} steps`}
841
- mainAriaLabel={`${title} content`}
842
- onClose={this.closeWizard}
843
- description="Simple Wizard Description"
844
- steps={steps}
845
- height={400}
846
- onCurrentStepChanged={this.onCurrentStepChanged}
847
- />
848
- );
849
- }
850
- }
365
+ ```ts file="./WizardGetCurrentStep.tsx"
851
366
  ```
852
367
 
853
368
  ### Wizard in modal
854
369
 
855
- ```js
856
- import React from 'react';
857
- import { Button, Wizard } from '@patternfly/react-core';
858
-
859
- class WizardInModal extends React.Component {
860
- constructor(props) {
861
- super(props);
862
- this.state = {
863
- isOpen: false
864
- };
865
- this.handleModalToggle = () => {
866
- this.setState(({ isOpen }) => ({
867
- isOpen: !isOpen
868
- }));
869
- };
870
- }
871
-
872
- render() {
873
- const { isOpen } = this.state;
874
-
875
- const steps = [
876
- { name: 'First step', component: <p>Step 1 content</p> },
877
- { name: 'Second step', component: <p>Step 2 content</p> },
878
- { name: 'Third step', component: <p>Step 3 content</p> },
879
- { name: 'Fourth step', component: <p>Step 4 content</p> },
880
- { name: 'Review', component: <p>Review step content</p>, nextButtonText: 'Finish' }
881
- ];
882
- const title = 'Wizard in modal';
883
- return (
884
- <React.Fragment>
885
- <Button variant="primary" onClick={this.handleModalToggle}>
886
- Show Modal
887
- </Button>
888
- <Wizard
889
- title={title}
890
- description="Simple Wizard Description"
891
- descriptionComponent="div"
892
- steps={steps}
893
- onClose={this.handleModalToggle}
894
- isOpen={isOpen}
895
- />
896
- </React.Fragment>
897
- );
898
- }
899
- }
370
+ ```ts file="./WizardInModal.tsx"
900
371
  ```
901
372
 
902
373
  ### Wizard with drawer
903
374
 
904
- ```js
905
- import React from 'react';
906
- import {
907
- Button,
908
- DrawerActions,
909
- DrawerCloseButton,
910
- DrawerHead,
911
- DrawerPanelContent,
912
- Text,
913
- TextContent,
914
- Wizard
915
- } from '@patternfly/react-core';
916
-
917
- class WizardWithDrawer extends React.Component {
918
- constructor(props) {
919
- super(props);
920
- this.state = {
921
- isOpen: false,
922
- isDrawerExpanded: false,
923
- sectionGray: false,
924
- panelGray: true,
925
- contentGray: false
926
- };
927
-
928
- this.drawerRef = React.createRef();
929
-
930
- this.onExpand = () => {
931
- this.drawerRef.current && this.drawerRef.current.focus();
932
- };
933
-
934
- this.onOpenClick = () => {
935
- this.setState({
936
- isDrawerExpanded: true
937
- });
938
- };
939
-
940
- this.onCloseClick = () => {
941
- this.setState({
942
- isDrawerExpanded: false
943
- });
944
- };
945
- }
946
-
947
- render() {
948
- const { isDrawerExpanded } = this.state;
949
-
950
- const panel1Content = (
951
- <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
952
- <DrawerHead>
953
- <span tabIndex={isDrawerExpanded ? 0 : -1} ref={this.drawerRef}>
954
- drawer-panel-1 content
955
- </span>
956
- <DrawerActions>
957
- <DrawerCloseButton onClick={this.onCloseClick} />
958
- </DrawerActions>
959
- </DrawerHead>
960
- </DrawerPanelContent>
961
- );
962
-
963
- const panel2Content = (
964
- <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
965
- <DrawerHead>
966
- <span tabIndex={0} ref={this.drawerRef}>
967
- drawer-panel-2 content
968
- </span>
969
- <DrawerActions>
970
- <DrawerCloseButton onClick={this.onCloseClick} />
971
- </DrawerActions>
972
- </DrawerHead>
973
- </DrawerPanelContent>
974
- );
975
-
976
- const panel3Content = (
977
- <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
978
- <DrawerHead>
979
- <span tabIndex={0} ref={this.drawerRef}>
980
- drawer-panel-3 content
981
- </span>
982
- <DrawerActions>
983
- <DrawerCloseButton onClick={this.onCloseClick} />
984
- </DrawerActions>
985
- </DrawerHead>
986
- </DrawerPanelContent>
987
- );
988
-
989
- const drawerToggleButton = (
990
- <Button isInline variant="link" onClick={this.onOpenClick}>
991
- Open Drawer
992
- </Button>
993
- );
994
-
995
- const steps = [
996
- {
997
- name: 'Information',
998
- component: <p>Information step content</p>,
999
- drawerPanelContent: panel1Content,
1000
- drawerToggleButton: drawerToggleButton
1001
- },
1002
- {
1003
- name: 'Configuration',
1004
- steps: [
1005
- {
1006
- name: 'Substep A',
1007
- component: <p>Substep A content</p>,
1008
- drawerPanelContent: panel2Content,
1009
- drawerToggleButton: drawerToggleButton
1010
- },
1011
- {
1012
- name: 'Substep B',
1013
- component: <p>Substep B content</p>,
1014
- drawerPanelContent: panel2Content,
1015
- drawerToggleButton: drawerToggleButton
1016
- },
1017
- {
1018
- name: 'Substep C',
1019
- component: <p>Substep C content</p>,
1020
- drawerPanelContent: panel2Content,
1021
- drawerToggleButton: drawerToggleButton
1022
- }
1023
- ]
1024
- },
1025
- {
1026
- name: 'Additional',
1027
- component: <p>Additional step content</p>,
1028
- drawerPanelContent: panel3Content,
1029
- drawerToggleButton: drawerToggleButton
1030
- },
1031
- {
1032
- name: 'Review',
1033
- component: <p>Review step content</p>,
1034
- nextButtonText: 'Finish'
1035
- }
1036
- ];
1037
-
1038
- const title = 'Wizard with drawer';
1039
-
1040
- return (
1041
- <React.Fragment>
1042
- <Wizard
1043
- height={400}
1044
- isDrawerExpanded={isDrawerExpanded}
1045
- hasDrawer
1046
- navAriaLabel={`${title} steps`}
1047
- steps={steps}
1048
- />
1049
- </React.Fragment>
1050
- );
1051
- }
1052
- }
375
+ ```ts file="./WizardWithDrawer.tsx"
1053
376
  ```