@patternfly/react-core 4.224.2 → 4.224.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 (38) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/DataList/DataListCheck.js +1 -1
  3. package/dist/esm/components/DataList/DataListCheck.js.map +1 -1
  4. package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
  5. package/dist/esm/components/NumberInput/NumberInput.js +10 -1
  6. package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
  7. package/dist/js/components/DataList/DataListCheck.js +1 -1
  8. package/dist/js/components/DataList/DataListCheck.js.map +1 -1
  9. package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
  10. package/dist/js/components/NumberInput/NumberInput.js +10 -1
  11. package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
  12. package/dist/umd/react-core.js +11 -2
  13. package/dist/umd/react-core.min.js +2 -2
  14. package/package.json +6 -6
  15. package/src/components/DataList/DataListCheck.tsx +2 -2
  16. package/src/components/DataList/__tests__/DataListCheck.test.tsx +20 -0
  17. package/src/components/Modal/examples/Modal.md +22 -804
  18. package/src/components/Modal/examples/ModalBasic.tsx +37 -0
  19. package/src/components/Modal/examples/ModalCustomHeaderFooter.tsx +56 -0
  20. package/src/components/Modal/examples/ModalCustomTitleIcon.tsx +46 -0
  21. package/src/components/Modal/examples/ModalCustomWidth.tsx +38 -0
  22. package/src/components/Modal/examples/ModalLarge.tsx +38 -0
  23. package/src/components/Modal/examples/ModalMedium.tsx +38 -0
  24. package/src/components/Modal/examples/ModalNoHeaderFooter.tsx +37 -0
  25. package/src/components/Modal/examples/ModalSmall.tsx +38 -0
  26. package/src/components/Modal/examples/ModalTitleIcon.tsx +45 -0
  27. package/src/components/Modal/examples/ModalTopAligned.tsx +38 -0
  28. package/src/components/Modal/examples/ModalWithDescription.tsx +38 -0
  29. package/src/components/Modal/examples/ModalWithDropdown.tsx +97 -0
  30. package/src/components/Modal/examples/ModalWithForm.tsx +4 -12
  31. package/src/components/Modal/examples/ModalWithHelp.tsx +54 -0
  32. package/src/components/Modal/examples/ModalWithWizard.tsx +45 -0
  33. package/src/components/NotificationBadge/examples/NotificationBadge.md +4 -72
  34. package/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx +30 -0
  35. package/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx +36 -0
  36. package/src/components/NumberInput/NumberInput.tsx +11 -1
  37. package/src/components/NumberInput/__tests__/NumberInput.test.tsx +94 -1
  38. package/src/components/NumberInput/examples/NumberInput.md +0 -1
@@ -15,864 +15,82 @@ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
15
15
 
16
16
  ### Basic
17
17
 
18
- ```js
19
- import React from 'react';
20
- import { Modal, Button } from '@patternfly/react-core';
21
-
22
- class SimpleModal extends React.Component {
23
- constructor(props) {
24
- super(props);
25
- this.state = {
26
- isModalOpen: false
27
- };
28
- this.handleModalToggle = () => {
29
- this.setState(({ isModalOpen }) => ({
30
- isModalOpen: !isModalOpen
31
- }));
32
- };
33
- }
34
-
35
- render() {
36
- const { isModalOpen } = this.state;
37
-
38
- return (
39
- <React.Fragment>
40
- <Button variant="primary" onClick={this.handleModalToggle}>
41
- Show modal
42
- </Button>
43
- <Modal
44
- title="Simple modal header"
45
- isOpen={isModalOpen}
46
- onClose={this.handleModalToggle}
47
- actions={[
48
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
49
- Confirm
50
- </Button>,
51
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
52
- Cancel
53
- </Button>
54
- ]}
55
- >
56
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
57
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
58
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
59
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
60
- est laborum.
61
- </Modal>
62
- </React.Fragment>
63
- );
64
- }
65
- }
18
+ ```ts file="./ModalBasic.tsx"
66
19
  ```
67
20
 
68
21
  ### With description
69
22
 
70
- ```js
71
- import React from 'react';
72
- import { Modal, Button } from '@patternfly/react-core';
73
-
74
- class SimpleModal extends React.Component {
75
- constructor(props) {
76
- super(props);
77
- this.state = {
78
- isModalOpen: false
79
- };
80
- this.handleModalToggle = () => {
81
- this.setState(({ isModalOpen }) => ({
82
- isModalOpen: !isModalOpen
83
- }));
84
- };
85
- }
86
-
87
- render() {
88
- const { isModalOpen } = this.state;
89
-
90
- return (
91
- <React.Fragment>
92
- <Button variant="primary" onClick={this.handleModalToggle}>
93
- Show modal
94
- </Button>
95
- <Modal
96
- aria-label="My modal context"
97
- title="Modal header with description"
98
- isOpen={isModalOpen}
99
- onClose={this.handleModalToggle}
100
- description="A description is used when you want to provide more info about the modal than the title is able to describe. The content in the description is static and will not scroll with the rest of the modal body."
101
- actions={[
102
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
103
- Confirm
104
- </Button>,
105
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
106
- Cancel
107
- </Button>
108
- ]}
109
- >
110
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
111
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
112
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
113
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
114
- est laborum.
115
- </Modal>
116
- </React.Fragment>
117
- );
118
- }
119
- }
23
+ ```ts file="./ModalWithDescription.tsx"
120
24
  ```
121
25
 
122
26
  ### Top aligned
123
27
 
124
- ```js
125
- import React from 'react';
126
- import { Modal, ModalVariant, Button } from '@patternfly/react-core';
127
-
128
- class TopModal extends React.Component {
129
- constructor(props) {
130
- super(props);
131
- this.state = {
132
- isModalOpen: false
133
- };
134
- this.handleModalToggle = () => {
135
- this.setState(({ isModalOpen }) => ({
136
- isModalOpen: !isModalOpen
137
- }));
138
- };
139
- }
140
-
141
- render() {
142
- const { isModalOpen } = this.state;
143
-
144
- return (
145
- <React.Fragment>
146
- <Button variant="primary" onClick={this.handleModalToggle}>
147
- Show top aligned modal
148
- </Button>
149
- <Modal
150
- position="top"
151
- title="Top modal header"
152
- isOpen={isModalOpen}
153
- onClose={this.handleModalToggle}
154
- actions={[
155
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
156
- Confirm
157
- </Button>,
158
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
159
- Cancel
160
- </Button>
161
- ]}
162
- >
163
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
164
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
165
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
166
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
167
- est laborum.
168
- </Modal>
169
- </React.Fragment>
170
- );
171
- }
172
- }
28
+ ```ts file="./ModalTopAligned.tsx"
173
29
  ```
174
30
 
175
31
  ### Small
176
32
 
177
- ```js
178
- import React from 'react';
179
- import { Modal, ModalVariant, Button } from '@patternfly/react-core';
180
-
181
- class SmallModal extends React.Component {
182
- constructor(props) {
183
- super(props);
184
- this.state = {
185
- isModalOpen: false
186
- };
187
- this.handleModalToggle = () => {
188
- this.setState(({ isModalOpen }) => ({
189
- isModalOpen: !isModalOpen
190
- }));
191
- };
192
- }
193
-
194
- render() {
195
- const { isModalOpen } = this.state;
196
-
197
- return (
198
- <React.Fragment>
199
- <Button variant="primary" onClick={this.handleModalToggle}>
200
- Show small modal
201
- </Button>
202
- <Modal
203
- variant={ModalVariant.small}
204
- title="Small modal header"
205
- isOpen={isModalOpen}
206
- onClose={this.handleModalToggle}
207
- actions={[
208
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
209
- Confirm
210
- </Button>,
211
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
212
- Cancel
213
- </Button>
214
- ]}
215
- >
216
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
217
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
218
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
219
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
220
- est laborum.
221
- </Modal>
222
- </React.Fragment>
223
- );
224
- }
225
- }
33
+ ```ts file="./ModalSmall.tsx"
226
34
  ```
227
35
 
228
36
  ### Medium
229
37
 
230
- ```js
231
- import React from 'react';
232
- import { Modal, ModalVariant, Button } from '@patternfly/react-core';
233
-
234
- class MediumModal extends React.Component {
235
- constructor(props) {
236
- super(props);
237
- this.state = {
238
- isModalOpen: false
239
- };
240
- this.handleModalToggle = () => {
241
- this.setState(({ isModalOpen }) => ({
242
- isModalOpen: !isModalOpen
243
- }));
244
- };
245
- }
246
-
247
- render() {
248
- const { isModalOpen } = this.state;
249
-
250
- return (
251
- <React.Fragment>
252
- <Button variant="primary" onClick={this.handleModalToggle}>
253
- Show medium modal
254
- </Button>
255
- <Modal
256
- variant={ModalVariant.medium}
257
- title="Medium modal header"
258
- isOpen={isModalOpen}
259
- onClose={this.handleModalToggle}
260
- actions={[
261
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
262
- Confirm
263
- </Button>,
264
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
265
- Cancel
266
- </Button>
267
- ]}
268
- >
269
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
270
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
271
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
272
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
273
- est laborum.
274
- </Modal>
275
- </React.Fragment>
276
- );
277
- }
278
- }
38
+ ```ts file="./ModalMedium.tsx"
279
39
  ```
280
40
 
281
41
  ### Large
282
42
 
283
- ```js
284
- import React from 'react';
285
- import { Modal, ModalVariant, Button } from '@patternfly/react-core';
286
-
287
- class LargeModal extends React.Component {
288
- constructor(props) {
289
- super(props);
290
- this.state = {
291
- isModalOpen: false
292
- };
293
- this.handleModalToggle = () => {
294
- this.setState(({ isModalOpen }) => ({
295
- isModalOpen: !isModalOpen
296
- }));
297
- };
298
- }
299
-
300
- render() {
301
- const { isModalOpen } = this.state;
302
-
303
- return (
304
- <React.Fragment>
305
- <Button variant="primary" onClick={this.handleModalToggle}>
306
- Show large modal
307
- </Button>
308
- <Modal
309
- variant={ModalVariant.large}
310
- title="Large modal header"
311
- isOpen={isModalOpen}
312
- onClose={this.handleModalToggle}
313
- actions={[
314
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
315
- Confirm
316
- </Button>,
317
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
318
- Cancel
319
- </Button>
320
- ]}
321
- >
322
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
323
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
324
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
325
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
326
- est laborum.
327
- </Modal>
328
- </React.Fragment>
329
- );
330
- }
331
- }
43
+ ```ts file="./ModalLarge.tsx"
332
44
  ```
333
45
 
334
- ### Width
335
-
336
- ```js
337
- import React from 'react';
338
- import { Modal, Button } from '@patternfly/react-core';
339
-
340
- class WidthModal extends React.Component {
341
- constructor(props) {
342
- super(props);
343
- this.state = {
344
- isModalOpen: false
345
- };
346
- this.handleModalToggle = () => {
347
- this.setState(({ isModalOpen }) => ({
348
- isModalOpen: !isModalOpen
349
- }));
350
- };
351
- }
352
-
353
- render() {
354
- const { isModalOpen } = this.state;
355
-
356
- return (
357
- <React.Fragment>
358
- <Button variant="primary" onClick={this.handleModalToggle}>
359
- Show 50% width modal
360
- </Button>
361
- <Modal
362
- width={'50%'}
363
- title="Modal header for set width example"
364
- isOpen={isModalOpen}
365
- onClose={this.handleModalToggle}
366
- actions={[
367
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
368
- Confirm
369
- </Button>,
370
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
371
- Cancel
372
- </Button>
373
- ]}
374
- >
375
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
376
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
377
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
378
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
379
- est laborum.
380
- </Modal>
381
- </React.Fragment>
382
- );
383
- }
384
- }
46
+ ### Custom width
47
+
48
+ ```ts file="./ModalCustomWidth.tsx"
385
49
  ```
386
50
 
387
51
  ### Custom header and footer
388
52
 
389
- ```js
390
- import React from 'react';
391
- import { Modal, ModalVariant, Button, Title, TitleSizes } from '@patternfly/react-core';
392
- import WarningTriangleIcon from '@patternfly/react-icons/dist/esm/icons/warning-triangle-icon';
393
-
394
- class CustomHeaderFooter extends React.Component {
395
- constructor(props) {
396
- super(props);
397
- this.state = {
398
- isModalOpen: false
399
- };
400
- this.handleModalToggle = () => {
401
- this.setState(({ isModalOpen }) => ({
402
- isModalOpen: !isModalOpen
403
- }));
404
- };
405
- }
406
-
407
- render() {
408
- const { isModalOpen } = this.state;
409
-
410
- const header = (
411
- <React.Fragment>
412
- <Title id="custom-header-label" headingLevel="h1" size={TitleSizes['2xl']}>
413
- With custom modal header/footer
414
- </Title>
415
- <p className="pf-u-pt-sm">Allows for custom content in the header and/or footer by passing components.</p>
416
- </React.Fragment>
417
- );
418
-
419
- const footer = (
420
- <Title headingLevel="h4" size={TitleSizes.md}>
421
- <WarningTriangleIcon />
422
- <span className="pf-u-pl-sm">Custom modal footer.</span>
423
- </Title>
424
- );
425
-
426
- return (
427
- <React.Fragment>
428
- <Button variant="primary" onClick={this.handleModalToggle}>
429
- Show custom header/footer modal
430
- </Button>
431
- <Modal
432
- variant={ModalVariant.large}
433
- isOpen={isModalOpen}
434
- header={header}
435
- aria-label="My dialog"
436
- aria-labelledby="custom-header-label"
437
- aria-describedby="custom-header-description"
438
- onClose={this.handleModalToggle}
439
- footer={footer}
440
- >
441
- <span id="custom-header-description">
442
- When static text describing the modal is available, it can be wrapped with an ID referring to the modal's
443
- aria-describedby value.
444
- </span>
445
- <br />
446
- <br />
447
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
448
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
449
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
450
- </Modal>
451
- </React.Fragment>
452
- );
453
- }
454
- }
53
+ ```ts file="./ModalCustomHeaderFooter.tsx"
455
54
  ```
456
55
 
457
- ### No header
458
-
459
- ```js
460
- import React from 'react';
461
- import { Modal, ModalVariant, Button } from '@patternfly/react-core';
462
-
463
- class NoHeader extends React.Component {
464
- constructor(props) {
465
- super(props);
466
- this.state = {
467
- isModalOpen: false
468
- };
469
- this.handleModalToggle = () => {
470
- this.setState(({ isModalOpen }) => ({
471
- isModalOpen: !isModalOpen
472
- }));
473
- };
474
- }
475
-
476
- render() {
477
- const { isModalOpen } = this.state;
478
- const footer = <React.Fragment>Modal Footer</React.Fragment>;
479
-
480
- return (
481
- <React.Fragment>
482
- <Button variant="primary" onClick={this.handleModalToggle}>
483
- Show no header modal
484
- </Button>
485
- <Modal
486
- variant={ModalVariant.large}
487
- isOpen={isModalOpen}
488
- aria-label="No header example"
489
- showClose={true}
490
- aria-describedby="no-header-example"
491
- onClose={this.handleModalToggle}
492
- footer={footer}
493
- >
494
- <span id="no-header-example">
495
- When static text describing the modal is available, it can be wrapped with an ID referring to the modal's
496
- aria-describedby value.
497
- </span>
498
- <br />
499
- <br />
500
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
501
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
502
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
503
- </Modal>
504
- </React.Fragment>
505
- );
506
- }
507
- }
508
- ```
56
+ ### No header or footer
509
57
 
510
- ### Custom Icon
58
+ ```ts file="./ModalNoHeaderFooter.tsx"
59
+ ```
511
60
 
512
- ```js
513
- import React from 'react';
514
- import { Modal, Button } from '@patternfly/react-core';
515
- import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
61
+ ### Title icon
516
62
 
517
- class NoHeader extends React.Component {
518
- constructor(props) {
519
- super(props);
520
- this.state = {
521
- isModalOpen: false
522
- };
523
- this.handleModalToggle = () => {
524
- this.setState(({ isModalOpen }) => ({
525
- isModalOpen: !isModalOpen
526
- }));
527
- };
528
- }
529
-
530
- render() {
531
- const { isModalOpen } = this.state;
532
-
533
- return (
534
- <React.Fragment>
535
- <Button variant="primary" onClick={this.handleModalToggle}>
536
- Show icon modal
537
- </Button>
538
- <Modal
539
- isOpen={isModalOpen}
540
- aria-label="Modal custom icon example"
541
- title="Modal Header"
542
- titleIconVariant={BullhornIcon}
543
- showClose={true}
544
- aria-describedby="no-header-example"
545
- onClose={this.handleModalToggle}
546
- >
547
- <span id="no-header-example">
548
- When static text describing the modal is available, it can be wrapped with an ID referring to the modal's
549
- aria-describedby value.
550
- </span>
551
- <br />
552
- <br />
553
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
554
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
555
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
556
- </Modal>
557
- </React.Fragment>
558
- );
559
- }
560
- }
63
+ ```ts file="./ModalTitleIcon.tsx"
561
64
  ```
562
65
 
563
- ### Warning Alert
564
-
565
- ```js
566
- import React from 'react';
567
- import { Modal, Button } from '@patternfly/react-core';
568
-
569
- class NoHeader extends React.Component {
570
- constructor(props) {
571
- super(props);
572
- this.state = {
573
- isModalOpen: false
574
- };
575
- this.handleModalToggle = () => {
576
- this.setState(({ isModalOpen }) => ({
577
- isModalOpen: !isModalOpen
578
- }));
579
- };
580
- }
581
-
582
- render() {
583
- const { isModalOpen } = this.state;
584
-
585
- return (
586
- <React.Fragment>
587
- <Button variant="primary" onClick={this.handleModalToggle}>
588
- Show icon modal
589
- </Button>
590
- <Modal
591
- isOpen={isModalOpen}
592
- aria-label="Modal warning example"
593
- title="Modal Header"
594
- titleIconVariant="warning"
595
- showClose={true}
596
- aria-describedby="no-header-example"
597
- onClose={this.handleModalToggle}
598
- >
599
- <span id="no-header-example">
600
- When static text describing the modal is available, it can be wrapped with an ID referring to the modal's
601
- aria-describedby value.
602
- </span>
603
- <br />
604
- <br />
605
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
606
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
607
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
608
- </Modal>
609
- </React.Fragment>
610
- );
611
- }
612
- }
66
+ ### Custom title icon
67
+
68
+ ```ts file="./ModalCustomTitleIcon.tsx"
613
69
  ```
614
70
 
615
71
  ### With wizard
616
72
 
617
- ```js
618
- import React from 'react';
619
- import { Modal, Button, Wizard } from '@patternfly/react-core';
620
-
621
- class WithWizard extends React.Component {
622
- constructor(props) {
623
- super(props);
624
- this.state = {
625
- isModalOpen: false
626
- };
627
- this.handleModalToggle = () => {
628
- this.setState(({ isModalOpen }) => ({
629
- isModalOpen: !isModalOpen
630
- }));
631
- };
632
- }
633
-
634
- render() {
635
- const { isModalOpen } = this.state;
636
-
637
- const steps = [
638
- { name: 'Step 1', component: <p>Step 1</p> },
639
- { name: 'Step 2', component: <p>Step 2</p> },
640
- { name: 'Step 3', component: <p>Step 3</p> },
641
- { name: 'Step 4', component: <p>Step 4</p> },
642
- { name: 'Review', component: <p>Review Step</p>, nextButtonText: 'Finish' }
643
- ];
644
-
645
- return (
646
- <React.Fragment>
647
- <Button variant="primary" onClick={this.handleModalToggle}>
648
- Show modal
649
- </Button>
650
- <Modal
651
- isOpen={isModalOpen}
652
- variant={ModalVariant.large}
653
- showClose={false}
654
- onClose={this.handleModalToggle}
655
- hasNoBodyWrapper
656
- aria-describedby="wiz-modal-example-description"
657
- aria-labelledby="wiz-modal-example-title"
658
- >
659
- <Wizard
660
- titleId="wiz-modal-example-title"
661
- descriptionId="wiz-modal-example-description"
662
- title="Simple Wizard"
663
- description="Simple Wizard Description"
664
- steps={steps}
665
- onClose={this.handleModalToggle}
666
- height={400}
667
- />
668
- </Modal>
669
- </React.Fragment>
670
- );
671
- }
672
- }
73
+ ```ts file="./ModalWithWizard.tsx"
673
74
  ```
674
75
 
675
76
  ### With dropdown
676
77
 
677
- ```js
678
- import React from 'react';
679
- import { Modal, Button, Dropdown, DropdownToggle, DropdownItem, KebabToggle } from '@patternfly/react-core';
680
- import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
681
-
682
- class WithDropdown extends React.Component {
683
- constructor(props) {
684
- super(props);
685
- this.state = {
686
- isModalOpen: false,
687
- isDropdownOpen: false
688
- };
689
- this.handleModalToggle = () => {
690
- const { isModalOpen } = this.state;
691
- this.setState({
692
- isModalOpen: !isModalOpen,
693
- isDropdownOpen: false
694
- });
695
- };
696
- this.onToggle = isDropdownOpen => {
697
- this.setState({
698
- isDropdownOpen
699
- });
700
- };
701
- this.onSelect = event => {
702
- this.setState({
703
- isDropdownOpen: !this.state.isDropdownOpen
704
- });
705
- this.onFocus();
706
- };
707
- this.onFocus = () => {
708
- const element = document.getElementById('toggle-id-menu-document-body');
709
- element.focus();
710
- };
711
- this.onEscapePress = () => {
712
- const { isDropdownOpen } = this.state;
713
- if (isDropdownOpen) {
714
- this.setState(
715
- {
716
- isDropdownOpen: !isDropdownOpen
717
- },
718
- () => {
719
- this.onFocus();
720
- }
721
- );
722
- } else {
723
- this.handleModalToggle();
724
- }
725
- };
726
- }
727
-
728
- render() {
729
- const { isModalOpen, isDropdownOpen } = this.state;
730
-
731
- const dropdownItems = [
732
- <DropdownItem key="link">Link</DropdownItem>,
733
- <DropdownItem key="action" component="button">
734
- Action
735
- </DropdownItem>,
736
- <DropdownItem key="disabled link" isDisabled>
737
- Disabled Link
738
- </DropdownItem>,
739
- <DropdownItem key="disabled action" isDisabled component="button">
740
- Disabled Action
741
- </DropdownItem>,
742
- <DropdownItem key="separated link">Separated Link</DropdownItem>,
743
- <DropdownItem key="separated action" component="button">
744
- Separated Action
745
- </DropdownItem>
746
- ];
747
-
748
- return (
749
- <React.Fragment>
750
- <Button variant="primary" onClick={this.handleModalToggle}>
751
- Show modal
752
- </Button>
753
- <Modal
754
- title="Modal with dropdown"
755
- variant={ModalVariant.small}
756
- isOpen={isModalOpen}
757
- onClose={this.handleModalToggle}
758
- actions={[
759
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
760
- Confirm
761
- </Button>,
762
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
763
- Cancel
764
- </Button>
765
- ]}
766
- onEscapePress={this.onEscapePress}
767
- >
768
- <div>
769
- Set the dropdown <strong>menuAppendTo</strong> prop to <em>parent</em> in order to allow the dropdown menu
770
- break out of the modal container. You'll also want to handle closing of the modal yourself, by listening to
771
- the <strong>onEscapePress</strong> callback on the Modal component, so you can close the Dropdown first if
772
- it's open.
773
- </div>
774
- <div>
775
- <Dropdown
776
- onSelect={this.onSelect}
777
- toggle={
778
- <DropdownToggle
779
- id="toggle-id-menu-document-body"
780
- onToggle={this.onToggle}
781
- toggleIndicator={CaretDownIcon}
782
- >
783
- Dropdown with a menu that can break out
784
- </DropdownToggle>
785
- }
786
- isOpen={isDropdownOpen}
787
- dropdownItems={dropdownItems}
788
- menuAppendTo="parent"
789
- />
790
- </div>
791
- </Modal>
792
- </React.Fragment>
793
- );
794
- }
795
- }
78
+ ```ts file="./ModalWithDropdown.tsx"
796
79
  ```
797
80
 
798
81
  ### With help
799
82
 
800
- ```js
801
- import React from 'react';
802
- import { Modal, Button, Popover } from '@patternfly/react-core';
803
- import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
804
-
805
- class HelpModal extends React.Component {
806
- constructor(props) {
807
- super(props);
808
- this.state = {
809
- isModalOpen: false
810
- };
811
- this.handleModalToggle = () => {
812
- this.setState(({ isModalOpen }) => ({
813
- isModalOpen: !isModalOpen
814
- }));
815
- };
816
- }
817
-
818
- render() {
819
- const { isModalOpen } = this.state;
820
-
821
- return (
822
- <React.Fragment>
823
- <Button variant="primary" onClick={this.handleModalToggle}>
824
- Show modal
825
- </Button>
826
- <Modal
827
- title="Simple modal header"
828
- help={
829
- <Popover
830
- headerContent={<div>Help Popover</div>}
831
- bodyContent={
832
- <div>
833
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla
834
- turpis.
835
- </div>
836
- }
837
- footerContent="Popover Footer"
838
- >
839
- <Button variant="plain" aria-label="Help">
840
- <HelpIcon />
841
- </Button>
842
- </Popover>
843
- }
844
- isOpen={isModalOpen}
845
- onClose={this.handleModalToggle}
846
- actions={[
847
- <Button key="confirm" variant="primary" onClick={this.handleModalToggle}>
848
- Confirm
849
- </Button>,
850
- <Button key="cancel" variant="link" onClick={this.handleModalToggle}>
851
- Cancel
852
- </Button>
853
- ]}
854
- >
855
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
856
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
857
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
858
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
859
- est laborum.
860
- </Modal>
861
- </React.Fragment>
862
- );
863
- }
864
- }
83
+ ```ts file="./ModalWithHelp.tsx"
865
84
  ```
866
85
 
867
86
  ### With form
868
87
 
869
88
  ```ts file="ModalWithForm.tsx"
870
-
871
89
  ```
872
90
 
873
91
  ### With overflowing content
874
92
 
875
- If the content that you're passing to the modal is likely to overflow the modal content area, pass tabIndex={0} to the modal to enable keyboard accessible scrolling.
93
+ If the content that you're passing to the modal is likely to overflow the modal content area, pass `tabIndex={0}` to the modal to enable keyboard accessible scrolling.
876
94
 
877
95
  ```ts file="ModalWithOverflowingContent.tsx"
878
96
  ```