@patternfly/react-core 4.223.2 → 4.224.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/esm/components/Form/FormGroup.d.ts +4 -2
  3. package/dist/esm/components/Form/FormGroup.d.ts.map +1 -1
  4. package/dist/esm/components/Form/FormGroup.js +4 -3
  5. package/dist/esm/components/Form/FormGroup.js.map +1 -1
  6. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  7. package/dist/esm/components/Select/Select.js +25 -23
  8. package/dist/esm/components/Select/Select.js.map +1 -1
  9. package/dist/esm/components/Wizard/Wizard.d.ts +9 -0
  10. package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
  11. package/dist/esm/components/Wizard/Wizard.js +6 -3
  12. package/dist/esm/components/Wizard/Wizard.js.map +1 -1
  13. package/dist/esm/components/Wizard/WizardBody.d.ts +6 -0
  14. package/dist/esm/components/Wizard/WizardBody.d.ts.map +1 -1
  15. package/dist/esm/components/Wizard/WizardBody.js +6 -2
  16. package/dist/esm/components/Wizard/WizardBody.js.map +1 -1
  17. package/dist/esm/components/Wizard/WizardDrawerWrapper.d.ts +11 -0
  18. package/dist/esm/components/Wizard/WizardDrawerWrapper.d.ts.map +1 -0
  19. package/dist/esm/components/Wizard/WizardDrawerWrapper.js +3 -0
  20. package/dist/esm/components/Wizard/WizardDrawerWrapper.js.map +1 -0
  21. package/dist/esm/components/Wizard/WizardToggle.d.ts +5 -1
  22. package/dist/esm/components/Wizard/WizardToggle.d.ts.map +1 -1
  23. package/dist/esm/components/Wizard/WizardToggle.js +4 -2
  24. package/dist/esm/components/Wizard/WizardToggle.js.map +1 -1
  25. package/dist/js/components/Form/FormGroup.d.ts +4 -2
  26. package/dist/js/components/Form/FormGroup.d.ts.map +1 -1
  27. package/dist/js/components/Form/FormGroup.js +4 -3
  28. package/dist/js/components/Form/FormGroup.js.map +1 -1
  29. package/dist/js/components/Select/Select.d.ts.map +1 -1
  30. package/dist/js/components/Select/Select.js +25 -23
  31. package/dist/js/components/Select/Select.js.map +1 -1
  32. package/dist/js/components/Wizard/Wizard.d.ts +9 -0
  33. package/dist/js/components/Wizard/Wizard.d.ts.map +1 -1
  34. package/dist/js/components/Wizard/Wizard.js +6 -3
  35. package/dist/js/components/Wizard/Wizard.js.map +1 -1
  36. package/dist/js/components/Wizard/WizardBody.d.ts +6 -0
  37. package/dist/js/components/Wizard/WizardBody.d.ts.map +1 -1
  38. package/dist/js/components/Wizard/WizardBody.js +6 -2
  39. package/dist/js/components/Wizard/WizardBody.js.map +1 -1
  40. package/dist/js/components/Wizard/WizardDrawerWrapper.d.ts +11 -0
  41. package/dist/js/components/Wizard/WizardDrawerWrapper.d.ts.map +1 -0
  42. package/dist/js/components/Wizard/WizardDrawerWrapper.js +7 -0
  43. package/dist/js/components/Wizard/WizardDrawerWrapper.js.map +1 -0
  44. package/dist/js/components/Wizard/WizardToggle.d.ts +5 -1
  45. package/dist/js/components/Wizard/WizardToggle.d.ts.map +1 -1
  46. package/dist/js/components/Wizard/WizardToggle.js +4 -2
  47. package/dist/js/components/Wizard/WizardToggle.js.map +1 -1
  48. package/dist/umd/react-core.js +45 -33
  49. package/dist/umd/react-core.min.js +4 -4
  50. package/package.json +6 -6
  51. package/src/components/Form/FormGroup.tsx +40 -29
  52. package/src/components/Form/examples/Form.md +12 -1271
  53. package/src/components/Form/examples/FormBasic.tsx +122 -0
  54. package/src/components/Form/examples/FormFieldGroups.tsx +324 -0
  55. package/src/components/Form/examples/FormGrid.tsx +66 -0
  56. package/src/components/Form/examples/FormGroupLabelInfo.tsx +72 -0
  57. package/src/components/Form/examples/FormHorizontal.tsx +118 -0
  58. package/src/components/Form/examples/FormHorizontalHelper.tsx +23 -0
  59. package/src/components/Form/examples/FormHorizontalStacked.tsx +11 -0
  60. package/src/components/Form/examples/FormInvalid.tsx +47 -0
  61. package/src/components/Form/examples/FormInvalidWithFormAlert.tsx +52 -0
  62. package/src/components/Form/examples/FormLimitWidth.tsx +122 -0
  63. package/src/components/Form/examples/FormSections.tsx +44 -0
  64. package/src/components/Form/examples/FormValidated.tsx +60 -0
  65. package/src/components/Select/Select.tsx +35 -33
  66. package/src/components/Wizard/Wizard.tsx +21 -1
  67. package/src/components/Wizard/WizardBody.tsx +23 -2
  68. package/src/components/Wizard/WizardDrawerWrapper.tsx +18 -0
  69. package/src/components/Wizard/WizardToggle.tsx +12 -2
  70. package/src/components/Wizard/__tests__/Wizard.test.tsx +24 -7
  71. package/src/components/Wizard/examples/Wizard.md +157 -2
  72. package/src/demos/Wizard/WizardDemo.md +1033 -2
@@ -42,1319 +42,60 @@ import TrashIcon from '@patternfly/react-icons/dist/esm/icons/trash-icon';
42
42
 
43
43
  ### Basic
44
44
 
45
- ```js
46
- import React from 'react';
47
- import { Form, FormGroup, TextInput, Checkbox, Popover, ActionGroup, Button, Radio } from '@patternfly/react-core';
48
- import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
49
-
50
- class SimpleForm extends React.Component {
51
- constructor(props) {
52
- super(props);
53
- this.state = {
54
- value1: '',
55
- value2: '',
56
- value3: ''
57
- };
58
- this.handleTextInputChange1 = value1 => {
59
- this.setState({ value1 });
60
- };
61
- this.handleTextInputChange2 = value2 => {
62
- this.setState({ value2 });
63
- };
64
- this.handleTextInputChange3 = value3 => {
65
- this.setState({ value3 });
66
- };
67
- }
68
-
69
- render() {
70
- const { value1, value2, value3 } = this.state;
71
-
72
- return (
73
- <Form>
74
- <FormGroup
75
- label="Full name"
76
- labelIcon={
77
- <Popover
78
- headerContent={
79
- <div>
80
- The{' '}
81
- <a href="https://schema.org/name" target="_blank">
82
- name
83
- </a>{' '}
84
- of a{' '}
85
- <a href="https://schema.org/Person" target="_blank">
86
- Person
87
- </a>
88
- </div>
89
- }
90
- bodyContent={
91
- <div>
92
- Often composed of{' '}
93
- <a href="https://schema.org/givenName" target="_blank">
94
- givenName
95
- </a>{' '}
96
- and{' '}
97
- <a href="https://schema.org/familyName" target="_blank">
98
- familyName
99
- </a>
100
- .
101
- </div>
102
- }
103
- >
104
- <button
105
- type="button"
106
- aria-label="More info for name field"
107
- onClick={e => e.preventDefault()}
108
- aria-describedby="simple-form-name-01"
109
- className="pf-c-form__group-label-help"
110
- >
111
- <HelpIcon noVerticalAlign />
112
- </button>
113
- </Popover>
114
- }
115
- isRequired
116
- fieldId="simple-form-name-01"
117
- helperText="Include your middle name if you have one."
118
- >
119
- <TextInput
120
- isRequired
121
- type="text"
122
- id="simple-form-name-01"
123
- name="simple-form-name-01"
124
- aria-describedby="simple-form-name-01-helper"
125
- value={value1}
126
- onChange={this.handleTextInputChange1}
127
- />
128
- </FormGroup>
129
- <FormGroup label="Email" isRequired fieldId="simple-form-email-01">
130
- <TextInput
131
- isRequired
132
- type="email"
133
- id="simple-form-email-01"
134
- name="simple-form-email-01"
135
- value={value2}
136
- onChange={this.handleTextInputChange2}
137
- />
138
- </FormGroup>
139
- <FormGroup label="Phone number" isRequired fieldId="simple-form-number-01">
140
- <TextInput
141
- isRequired
142
- type="tel"
143
- id="simple-form-number-01"
144
- placeholder="555-555-5555"
145
- name="simple-form-number-01"
146
- value={value3}
147
- onChange={this.handleTextInputChange3}
148
- />
149
- </FormGroup>
150
- <FormGroup role="group" isInline fieldId="basic-form-checkbox-group" label="How can we contact you?">
151
- <Checkbox label="Email" aria-label="Email" id="inlinecheck01" />
152
- <Checkbox label="Phone" aria-label="Phone" id="inlinecheck02" />
153
- <Checkbox label="Mail" aria-label="Mail" id="inlinecheck03" />
154
- </FormGroup>
155
- <FormGroup role="radiogroup" isInline fieldId="simple-form-radio-group" label="Time zone">
156
- <Radio name="basic-inline-radio" label="Eastern" id="basic-inline-radio-01" />
157
- <Radio name="basic-inline-radio" label="Central" id="basic-inline-radio-02" />
158
- <Radio name="basic-inline-radio" label="Pacific" id="basic-inline-radio-03" />
159
- </FormGroup>
160
- <FormGroup label="Additional note" fieldId="simple-form-note-01">
161
- <TextInput isDisabled type="text" id="simple-form-note-01" name="simple-form-number" value="disabled" />
162
- </FormGroup>
163
- <FormGroup fieldId="checkbox01">
164
- <Checkbox
165
- label="I'd like updates via email."
166
- id="checkbox01"
167
- name="checkbox01"
168
- aria-label="Update via email"
169
- />
170
- </FormGroup>
171
- <ActionGroup>
172
- <Button variant="primary">Submit</Button>
173
- <Button variant="link">Cancel</Button>
174
- </ActionGroup>
175
- </Form>
176
- );
177
- }
178
- }
45
+ ```ts file="./FormBasic.tsx"
179
46
  ```
180
47
 
181
48
  ### Horizontal
182
49
 
183
- ```js
184
- import React from 'react';
185
- import {
186
- Form,
187
- FormGroup,
188
- TextInput,
189
- TextArea,
190
- FormSelect,
191
- FormSelectOption,
192
- Checkbox,
193
- ActionGroup,
194
- Button,
195
- Radio
196
- } from '@patternfly/react-core';
197
-
198
- class HorizontalForm extends React.Component {
199
- constructor(props) {
200
- super(props);
201
- this.state = {
202
- value: 'please choose',
203
- value1: '',
204
- value2: '',
205
- value3: ''
206
- };
207
- this.onChange = (value, event) => {
208
- this.setState({ value });
209
- };
210
- this.handleTextInputChange1 = value1 => {
211
- this.setState({ value1 });
212
- };
213
- this.handleTextInputChange2 = value2 => {
214
- this.setState({ value2 });
215
- };
216
- this.handleTextInputChange3 = value3 => {
217
- this.setState({ value3 });
218
- };
219
- this.options = [
220
- { value: 'select one', label: 'Select one', disabled: false },
221
- { value: 'mr', label: 'Mr', disabled: false },
222
- { value: 'miss', label: 'Miss', disabled: false },
223
- { value: 'mrs', label: 'Mrs', disabled: false },
224
- { value: 'ms', label: 'Ms', disabled: false },
225
- { value: 'dr', label: 'Dr', disabled: false },
226
- { value: 'other', label: 'Other', disabled: false }
227
- ];
228
- }
229
-
230
- render() {
231
- const { value1, value2, value3 } = this.state;
232
-
233
- return (
234
- <Form isHorizontal>
235
- <FormGroup
236
- label="Full name"
237
- isRequired
238
- fieldId="horizontal-form-name"
239
- helperText="Include your middle name if you have one."
240
- >
241
- <TextInput
242
- value={value1}
243
- isRequired
244
- type="text"
245
- id="horizontal-form-name"
246
- aria-describedby="horizontal-form-name-helper"
247
- name="horizontal-form-name"
248
- onChange={this.handleTextInputChange1}
249
- />
250
- </FormGroup>
251
- <FormGroup label="Email" isRequired fieldId="horizontal-form-email">
252
- <TextInput
253
- value={value2}
254
- onChange={this.handleTextInputChange2}
255
- isRequired
256
- type="email"
257
- id="horizontal-form-email"
258
- name="horizontal-form-email"
259
- />
260
- </FormGroup>
261
- <FormGroup label="Your title" fieldId="horizontal-form-title">
262
- <FormSelect
263
- value={this.state.value}
264
- onChange={this.onChange}
265
- id="horzontal-form-title"
266
- name="horizontal-form-title"
267
- aria-label="Your title"
268
- >
269
- {this.options.map((option, index) => (
270
- <FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
271
- ))}
272
- </FormSelect>
273
- </FormGroup>
274
- <FormGroup label="Your experience" fieldId="horizontal-form-exp">
275
- <TextArea
276
- value={value3}
277
- onChange={this.handleTextInputChange3}
278
- name="horizontal-form-exp"
279
- id="horizontal-form-exp"
280
- />
281
- </FormGroup>
282
- <FormGroup
283
- label="How can we contact you?"
284
- isStack
285
- hasNoPaddingTop
286
- role="group"
287
- fieldId="horizontal-form-checkbox-group"
288
- >
289
- <Checkbox label="Email" id="alt-form-checkbox-1" name="alt-form-checkbox-1" />
290
- <Checkbox label="Phone" id="alt-form-checkbox-2" name="alt-form-checkbox-2" />
291
- <Checkbox label="Mail" id="alt-form-checkbox-3" name="alt-form-checkbox-3" />
292
- </FormGroup>
293
- <FormGroup role="radiogroup" isStack hasNoPaddingTop fieldId="horizontal-form-radio-group" label="Time zone">
294
- <Radio name="horizontal-inline-radio" label="Eastern" id="horizontal-inline-radio-01" />
295
- <Radio name="horizontal-inline-radio" label="Central" id="horizontal-inline-radio-02" />
296
- <Radio name="horizontal-inline-radio" label="Pacific" id="horizontal-inline-radio-03" />
297
- </FormGroup>
298
- <ActionGroup>
299
- <Button variant="primary">Submit</Button>
300
- <Button variant="link">Cancel</Button>
301
- </ActionGroup>
302
- </Form>
303
- );
304
- }
305
- }
50
+ ```ts file="./FormHorizontal.tsx"
306
51
  ```
307
52
 
308
53
  ### Limit width
309
54
 
310
- ```js
311
- import React from 'react';
312
- import { Form, FormGroup, TextInput, Checkbox, Popover, ActionGroup, Button, Radio } from '@patternfly/react-core';
313
- import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
314
-
315
- class SimpleForm extends React.Component {
316
- constructor(props) {
317
- super(props);
318
- this.state = {
319
- value1: '',
320
- value2: '',
321
- value3: ''
322
- };
323
- this.handleTextInputChange1 = value1 => {
324
- this.setState({ value1 });
325
- };
326
- this.handleTextInputChange2 = value2 => {
327
- this.setState({ value2 });
328
- };
329
- this.handleTextInputChange3 = value3 => {
330
- this.setState({ value3 });
331
- };
332
- }
333
-
334
- render() {
335
- const { value1, value2, value3 } = this.state;
336
-
337
- return (
338
- <Form isWidthLimited>
339
- <FormGroup
340
- label="Full name"
341
- labelIcon={
342
- <Popover
343
- headerContent={
344
- <div>
345
- The{' '}
346
- <a href="https://schema.org/name" target="_blank">
347
- name
348
- </a>{' '}
349
- of a{' '}
350
- <a href="https://schema.org/Person" target="_blank">
351
- Person
352
- </a>
353
- </div>
354
- }
355
- bodyContent={
356
- <div>
357
- Often composed of{' '}
358
- <a href="https://schema.org/givenName" target="_blank">
359
- givenName
360
- </a>{' '}
361
- and{' '}
362
- <a href="https://schema.org/familyName" target="_blank">
363
- familyName
364
- </a>
365
- .
366
- </div>
367
- }
368
- >
369
- <button
370
- type="button"
371
- aria-label="More info for name field"
372
- onClick={e => e.preventDefault()}
373
- aria-describedby="simple-form-name-02"
374
- className="pf-c-form__group-label-help"
375
- >
376
- <HelpIcon noVerticalAlign />
377
- </button>
378
- </Popover>
379
- }
380
- isRequired
381
- fieldId="simple-form-name-02"
382
- helperText="Include your middle name if you have one."
383
- >
384
- <TextInput
385
- isRequired
386
- type="text"
387
- id="simple-form-name-02"
388
- name="simple-form-name-02"
389
- aria-describedby="simple-form-name-02-helper"
390
- value={value1}
391
- onChange={this.handleTextInputChange1}
392
- />
393
- </FormGroup>
394
- <FormGroup label="Email" isRequired fieldId="simple-form-email-02">
395
- <TextInput
396
- isRequired
397
- type="email"
398
- id="simple-form-email-02"
399
- name="simple-form-email-02"
400
- value={value2}
401
- onChange={this.handleTextInputChange2}
402
- />
403
- </FormGroup>
404
- <FormGroup label="Phone number" isRequired fieldId="simple-form-number">
405
- <TextInput
406
- isRequired
407
- type="tel"
408
- id="simple-form-number"
409
- placeholder="555-555-5555"
410
- name="simple-form-number"
411
- value={value3}
412
- onChange={this.handleTextInputChange3}
413
- />
414
- </FormGroup>
415
- <FormGroup fieldId="limit-width-form-checkbox-group" role="group" isInline label="How can we contact you?">
416
- <Checkbox label="Email" aria-label="Email" id="inlinecheck04" />
417
- <Checkbox label="Phone" aria-label="Phone" id="inlinecheck05" />
418
- <Checkbox label="Mail" aria-label="Mail" id="inlinecheck06" />
419
- </FormGroup>
420
- <FormGroup role="radiogroup" isInline fieldId="limit-width-form-radio-group" label="Time zone">
421
- <Radio name="limit-width-radio" label="Eastern" id="limit-width-inline-radio-01" />
422
- <Radio name="limit-width-radio" label="Central" id="limit-width-inline-radio-02" />
423
- <Radio name="limit-width-radio" label="Pacific" id="limit-width-inline-radio-03" />
424
- </FormGroup>
425
- <FormGroup label="Additional note" fieldId="simple-form-note-02">
426
- <TextInput isDisabled type="text" id="simple-form-note-02" name="simple-form-number" value="disabled" />
427
- </FormGroup>
428
- <FormGroup fieldId="checkbox02">
429
- <Checkbox
430
- label="I'd like updates via email."
431
- id="checkbox02"
432
- name="checkbox02"
433
- aria-label="Update via email"
434
- />
435
- </FormGroup>
436
- <ActionGroup>
437
- <Button variant="primary">Submit</Button>
438
- <Button variant="link">Cancel</Button>
439
- </ActionGroup>
440
- </Form>
441
- );
442
- }
443
- }
55
+ ```ts file="./FormLimitWidth.tsx"
444
56
  ```
445
57
 
446
58
  ### Invalid
447
59
 
448
- ```js
449
- import React from 'react';
450
- import { Form, FormGroup, TextInput, FormHelperText } from '@patternfly/react-core';
451
- import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
452
-
453
- class InvalidForm extends React.Component {
454
- constructor(props) {
455
- super(props);
456
- this.state = {
457
- value: 'Five',
458
- validated: 'error'
459
- };
460
- this.handleTextInputChange = value => {
461
- this.setState({ value, validated: value === '' ? 'noval' : /^\d+$/.test(value) ? 'success' : 'error' });
462
- };
463
- }
464
-
465
- render() {
466
- const { value, validated } = this.state;
467
-
468
- return (
469
- <Form>
470
- <FormGroup
471
- label="Age"
472
- type="number"
473
- helperText={
474
- <FormHelperText icon={<ExclamationCircleIcon />} isHidden={validated !== 'noval'}>
475
- Please enter your age
476
- </FormHelperText>
477
- }
478
- helperTextInvalid="Must be a number"
479
- helperTextInvalidIcon={<ExclamationCircleIcon />}
480
- fieldId="age-1"
481
- validated={validated}
482
- >
483
- <TextInput
484
- validated={validated}
485
- value={value}
486
- id="age-1"
487
- aria-describedby="age-1-helper"
488
- onChange={this.handleTextInputChange}
489
- />
490
- </FormGroup>
491
- </Form>
492
- );
493
- }
494
- }
60
+ ```ts file="./FormInvalid.tsx"
495
61
  ```
496
62
 
497
63
  ### Invalid with form alert
498
64
 
499
- ```js
500
- import React from 'react';
501
- import { Alert, Form, FormAlert, FormGroup, TextInput, FormHelperText } from '@patternfly/react-core';
502
- import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
503
-
504
- class InvalidFormWithFormAlert extends React.Component {
505
- constructor(props) {
506
- super(props);
507
- this.state = {
508
- value: 'Five',
509
- validated: 'error'
510
- };
511
- this.handleTextInputChange = value => {
512
- this.setState({ value, validated: value === '' ? 'noval' : /^\d+$/.test(value) ? 'success' : 'error' });
513
- };
514
- }
515
-
516
- render() {
517
- const { value, validated } = this.state;
518
-
519
- return (
520
- <Form>
521
- {validated === 'error' && (
522
- <FormAlert>
523
- <Alert
524
- variant="danger"
525
- title="Fill out all required fields before continuing."
526
- aria-live="polite"
527
- isInline
528
- />
529
- </FormAlert>
530
- )}
531
- <FormGroup
532
- label="Age"
533
- type="number"
534
- helperText={
535
- <FormHelperText icon={<ExclamationCircleIcon />} isHidden={validated !== 'noval'}>
536
- Please enter your age
537
- </FormHelperText>
538
- }
539
- helperTextInvalid="Must be a number"
540
- helperTextInvalidIcon={<ExclamationCircleIcon />}
541
- fieldId="age-2"
542
- validated={validated}
543
- >
544
- <TextInput
545
- validated={validated}
546
- value={value}
547
- id="age-2"
548
- aria-describedby="age-2-helper"
549
- onChange={this.handleTextInputChange}
550
- />
551
- </FormGroup>
552
- </Form>
553
- );
554
- }
555
- }
65
+ ```ts file="./FormInvalidWithFormAlert.tsx"
556
66
  ```
557
67
 
558
68
  ### Validated
559
69
 
560
- ```js
561
- import React from 'react';
562
- import { Form, FormGroup, TextInput } from '@patternfly/react-core';
563
- import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
564
-
565
- class InvalidForm extends React.Component {
566
- constructor(props) {
567
- super(props);
568
- this.state = {
569
- value: '',
570
- invalidText: 'Must be a number',
571
- validated: 'default',
572
- helperText: 'Enter your age to continue'
573
- };
574
-
575
- this.simulateNetworkCall = callback => {
576
- setTimeout(callback, 2000);
577
- };
578
-
579
- this.handleTextInputChange = value => {
580
- this.setState(
581
- { value, validated: 'default', helperText: 'Validating...' },
582
- this.simulateNetworkCall(() => {
583
- if (/^\d+$/.test(value)) {
584
- if (parseInt(value, 10) >= 21) {
585
- this.setState({ validated: 'success', helperText: 'Enjoy your stay' });
586
- } else {
587
- this.setState({ validated: 'warning', helperText: 'You must be at least 21 to continue' });
588
- }
589
- } else {
590
- this.setState({ validated: 'error', invalidText: 'Must be a number' });
591
- }
592
- })
593
- );
594
- };
595
- }
596
-
597
- render() {
598
- const { value, validated, helperText, invalidText } = this.state;
599
-
600
- return (
601
- <Form>
602
- <FormGroup
603
- label="Age"
604
- type="number"
605
- helperText={helperText}
606
- helperTextInvalid={invalidText}
607
- helperTextInvalidIcon={<ExclamationCircleIcon />}
608
- fieldId="age-3"
609
- validated={validated}
610
- >
611
- <TextInput
612
- validated={validated}
613
- value={value}
614
- id="age-3"
615
- aria-describedby="age-3-helper"
616
- onChange={this.handleTextInputChange}
617
- />
618
- </FormGroup>
619
- </Form>
620
- );
621
- }
622
- }
70
+ ```ts file="./FormValidated.tsx"
623
71
  ```
624
72
 
625
73
  ### Horizontal stacked no padding top
626
74
 
627
- ```js
628
- import React from 'react';
629
- import { Form, FormGroup, Checkbox } from '@patternfly/react-core';
630
-
631
- class HorizontalForm extends React.Component {
632
- render() {
633
- return (
634
- <Form isHorizontal>
635
- <FormGroup role="group" label="Label" hasNoPaddingTop fieldId="options" isStack>
636
- <Checkbox label="option 1" id="option-01" />
637
- <Checkbox label="option 2" id="option-02" />
638
- </FormGroup>
639
- </Form>
640
- );
641
- }
642
- }
75
+ ```ts file="./FormHorizontalStacked.tsx"
643
76
  ```
644
77
 
645
78
  ### Horizontal stacked helper text on top
646
79
 
647
- ```js
648
- import React from 'react';
649
- import { Form, FormGroup, Checkbox } from '@patternfly/react-core';
650
-
651
- class HorizontalFormHelperTextOnTop extends React.Component {
652
- constructor(props) {
653
- super(props);
654
- this.state = {
655
- helperText: 'Select all that apply:'
656
- };
657
- }
658
-
659
- render() {
660
- return (
661
- <Form isHorizontal>
662
- <FormGroup
663
- label="Label"
664
- helperText={this.state.helperText}
665
- isHelperTextBeforeField
666
- hasNoPaddingTop
667
- fieldId="options"
668
- isStack
669
- role="group"
670
- >
671
- <Checkbox label="Option 1" id="option-03" />
672
- <Checkbox label="Option 2" id="option-04" />
673
- </FormGroup>
674
- </Form>
675
- );
676
- }
677
- }
80
+ ```ts file="./FormHorizontalHelper.tsx"
678
81
  ```
679
82
 
680
83
  ### Form group with additional label info
681
84
 
682
- ```js
683
- import React from 'react';
684
- import { Form, FormGroup, TextInput, Popover } from '@patternfly/react-core';
685
- import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
686
-
687
- class FormGroupLabelInfo extends React.Component {
688
- constructor(props) {
689
- super(props);
690
- this.state = {
691
- value1: ''
692
- };
693
- this.handleTextInputChange1 = value1 => {
694
- this.setState({ value1 });
695
- };
696
- }
697
-
698
- render() {
699
- const { value1 } = this.state;
700
-
701
- return (
702
- <Form>
703
- <FormGroup
704
- label="Full name"
705
- labelInfo="Additional label info"
706
- labelIcon={
707
- <Popover
708
- headerContent={
709
- <div>
710
- The{' '}
711
- <a href="https://schema.org/name" target="_blank">
712
- name
713
- </a>{' '}
714
- of a{' '}
715
- <a href="https://schema.org/Person" target="_blank">
716
- Person
717
- </a>
718
- </div>
719
- }
720
- bodyContent={
721
- <div>
722
- Often composed of{' '}
723
- <a href="https://schema.org/givenName" target="_blank">
724
- givenName
725
- </a>{' '}
726
- and{' '}
727
- <a href="https://schema.org/familyName" target="_blank">
728
- familyName
729
- </a>
730
- .
731
- </div>
732
- }
733
- >
734
- <button
735
- type="button"
736
- aria-label="More info for name field"
737
- onClick={e => e.preventDefault()}
738
- aria-describedby="form-group-label-info"
739
- className="pf-c-form__group-label-help"
740
- >
741
- <HelpIcon noVerticalAlign />
742
- </button>
743
- </Popover>
744
- }
745
- isRequired
746
- fieldId="form-group-label-info"
747
- helperText="Include your middle name if you have one."
748
- >
749
- <TextInput
750
- isRequired
751
- type="text"
752
- id="form-group-label-info"
753
- name="form-group-label-info"
754
- aria-describedby="form-group-label-info-helper"
755
- value={value1}
756
- onChange={this.handleTextInputChange1}
757
- />
758
- </FormGroup>
759
- </Form>
760
- );
761
- }
762
- }
85
+ ```ts file="./FormGroupLabelInfo.tsx"
763
86
  ```
764
87
 
765
88
  ### Form Sections
766
89
 
767
- ```js
768
- import React from 'react';
769
- import { Form, FormGroup, FormSection, TextInput } from '@patternfly/react-core';
770
-
771
- class FormSections extends React.Component {
772
- constructor(props) {
773
- super(props);
774
- this.state = {
775
- value1: '',
776
- value2: ''
777
- };
778
- this.handleTextInputChange1 = value1 => {
779
- this.setState({ value1 });
780
- };
781
- this.handleTextInputChange2 = value2 => {
782
- this.setState({ value2 });
783
- };
784
- }
785
-
786
- render() {
787
- const { value1, value2 } = this.state;
788
-
789
- return (
790
- <Form>
791
- <FormSection>
792
- <FormGroup label="Form section 1 input" isRequired fieldId="simple-form-section-1-input">
793
- <TextInput
794
- isRequired
795
- type="section-1-input"
796
- id="simple-form-section-1-input"
797
- name="simple-form-section-1-input"
798
- value={value1}
799
- onChange={this.handleTextInputChange1}
800
- />
801
- </FormGroup>
802
- </FormSection>
803
- <FormSection title="Form section 2 (optional title)" titleElement="h2">
804
- <FormGroup label="Form section 2 input" isRequired fieldId="simple-form-section-2-input">
805
- <TextInput
806
- isRequired
807
- type="section-2-input"
808
- id="simple-form-section-2-input"
809
- name="simple-form-section-2-input"
810
- value={value2}
811
- onChange={this.handleTextInputChange2}
812
- />
813
- </FormGroup>
814
- </FormSection>
815
- </Form>
816
- );
817
- }
818
- }
90
+ ```ts file="./FormSections.tsx"
819
91
  ```
820
92
 
821
93
  ### Grid form
822
94
 
823
- ```js
824
- import React from 'react';
825
- import { Form, FormGroup, TextInput, Button, Grid, GridItem } from '@patternfly/react-core';
826
- import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
827
-
828
- class SimpleForm extends React.Component {
829
- constructor(props) {
830
- super(props);
831
- this.state = {
832
- value1: '',
833
- value2: '',
834
- value3: ''
835
- };
836
- this.handleTextInputChange1 = value1 => {
837
- this.setState({ value1 });
838
- };
839
- this.handleTextInputChange2 = value2 => {
840
- this.setState({ value2 });
841
- };
842
- this.handleTextInputChange3 = value3 => {
843
- this.setState({ value3 });
844
- };
845
- }
846
-
847
- render() {
848
- const { value1, value2, value3 } = this.state;
849
-
850
- return (
851
- <Form>
852
- <Grid hasGutter md={6}>
853
- <GridItem span={12}>
854
- <FormGroup
855
- label="Full name"
856
- isRequired
857
- fieldId="grid-form-name-01"
858
- helperText="Include your middle name if you have one."
859
- >
860
- <TextInput
861
- isRequired
862
- type="text"
863
- id="grid-form-name-01"
864
- name="grid-form-name-01"
865
- aria-describedby="grid-form-name-01-helper"
866
- value={value1}
867
- onChange={this.handleTextInputChange1}
868
- />
869
- </FormGroup>
870
- </GridItem>
871
- <FormGroup label="Email" isRequired fieldId="grid-form-email-01">
872
- <TextInput
873
- isRequired
874
- type="email"
875
- id="grid-form-email-01"
876
- name="grid-form-email-01"
877
- value={value2}
878
- onChange={this.handleTextInputChange2}
879
- />
880
- </FormGroup>
881
- <FormGroup label="Phone number" isRequired fieldId="grid-form-number-01">
882
- <TextInput
883
- isRequired
884
- type="tel"
885
- id="grid-form-number-01"
886
- placeholder="555-555-5555"
887
- name="grid-form-number-01"
888
- value={value3}
889
- onChange={this.handleTextInputChange3}
890
- />
891
- </FormGroup>
892
- </Grid>
893
- </Form>
894
- );
895
- }
896
- }
95
+ ```ts file="./FormGrid.tsx"
897
96
  ```
898
97
 
899
98
  ### Field Groups
900
99
 
901
- ```js
902
- import React from 'react';
903
- import {
904
- Form,
905
- FormGroup,
906
- FormFieldGroup,
907
- FormFieldGroupExpandable,
908
- FormFieldGroupHeader,
909
- TextInput,
910
- Button
911
- } from '@patternfly/react-core';
912
- import TrashIcon from '@patternfly/react-icons/dist/esm/icons/trash-icon';
913
-
914
- class FieldGroups extends React.Component {
915
- constructor(props) {
916
- super(props);
917
- this.state = {
918
- value1: '',
919
- value2: '',
920
- value3: '',
921
- value4: '',
922
- value5: '',
923
- value6: '',
924
- value7: '',
925
- value8: '',
926
- value9: '',
927
- value10: '',
928
- value11: '',
929
- value12: '',
930
- value13: '',
931
- value14: '',
932
- value15: '',
933
- value16: '',
934
- value17: '',
935
- value18: '',
936
- value19: '',
937
- value20: '',
938
- value21: '',
939
- value22: ''
940
- };
941
- this.handleTextInputChange = value => {
942
- this.setState(value);
943
- };
944
- }
945
-
946
- render() {
947
- const {
948
- value1,
949
- value2,
950
- value3,
951
- value4,
952
- value5,
953
- value6,
954
- value7,
955
- value8,
956
- value9,
957
- value10,
958
- value11,
959
- value12,
960
- value13,
961
- value14,
962
- value15,
963
- value16,
964
- value17,
965
- value18,
966
- value19,
967
- value20,
968
- value21,
969
- value22
970
- } = this.state;
971
-
972
- return (
973
- <Form>
974
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-label1">
975
- <TextInput
976
- isRequired
977
- id="form-expandable-field-groups-label1"
978
- name="form-expandable-field-groups-label1"
979
- value={value1}
980
- onChange={value => {
981
- this.handleTextInputChange({ value1: value });
982
- }}
983
- />
984
- </FormGroup>
985
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-label2">
986
- <TextInput
987
- isRequired
988
- id="form-expandable-field-groups-label2"
989
- name="form-expandable-field-groups-label2"
990
- value={value2}
991
- onChange={value => {
992
- this.handleTextInputChange({ value2: value });
993
- }}
994
- />
995
- </FormGroup>
996
- <FormFieldGroupExpandable
997
- isExpanded
998
- toggleAriaLabel="Details"
999
- header={
1000
- <FormFieldGroupHeader
1001
- titleText={{ text: 'Field group 1', id: 'field-group1-titleText-id' }}
1002
- titleDescription="Field group 1 description text."
1003
- actions={
1004
- <>
1005
- <Button variant="link">Delete all</Button> <Button variant="secondary">Add parameter</Button>
1006
- </>
1007
- }
1008
- />
1009
- }
1010
- >
1011
- <FormFieldGroupExpandable
1012
- isExpanded
1013
- toggleAriaLabel="Details"
1014
- header={
1015
- <FormFieldGroupHeader
1016
- titleText={{ text: 'Nested field group 1', id: 'nested-field-group1-titleText-id' }}
1017
- titleDescription="Nested field group 1 description text."
1018
- actions={
1019
- <Button variant="plain" aria-label="Remove">
1020
- <TrashIcon />
1021
- </Button>
1022
- }
1023
- />
1024
- }
1025
- >
1026
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-field-group1-label1">
1027
- <TextInput
1028
- isRequired
1029
- id="form-expandable-field-groups-field-group1-label1"
1030
- name="form-expandable-field-groups-field-group1-label1"
1031
- value={value3}
1032
- onChange={value => {
1033
- this.handleTextInputChange({ value3: value });
1034
- }}
1035
- />
1036
- </FormGroup>
1037
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-field-group1-label2">
1038
- <TextInput
1039
- isRequired
1040
- id="form-expandable-field-groups-field-group1-label2"
1041
- name="form-expandable-field-groups-field-group1-label2"
1042
- value={value4}
1043
- onChange={value => {
1044
- this.handleTextInputChange({ value4: value });
1045
- }}
1046
- />
1047
- </FormGroup>
1048
- </FormFieldGroupExpandable>
1049
- <FormFieldGroupExpandable
1050
- toggleAriaLabel="Details"
1051
- header={
1052
- <FormFieldGroupHeader
1053
- titleText={{ text: 'Nested field group 2', id: 'nested-field-group2-titleText-id' }}
1054
- actions={
1055
- <Button variant="plain" aria-label="Remove">
1056
- <TrashIcon />
1057
- </Button>
1058
- }
1059
- />
1060
- }
1061
- >
1062
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-field-group2-label1">
1063
- <TextInput
1064
- isRequired
1065
- id="form-expandable-field-groups-field-group2-label1"
1066
- name="form-expandable-field-groups-field-group2-label1"
1067
- value={value5}
1068
- onChange={value => {
1069
- this.handleTextInputChange({ value5: value });
1070
- }}
1071
- />
1072
- </FormGroup>
1073
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-field-group2-label2">
1074
- <TextInput
1075
- isRequired
1076
- id="form-expandable-field-groups-field-group2-label2"
1077
- name="form-expandable-field-groups-field-group2-label2"
1078
- value={value6}
1079
- onChange={value => {
1080
- this.handleTextInputChange({ value6: value });
1081
- }}
1082
- />
1083
- </FormGroup>
1084
- </FormFieldGroupExpandable>
1085
- <FormFieldGroupExpandable
1086
- toggleAriaLabel="Details"
1087
- header={
1088
- <FormFieldGroupHeader
1089
- titleText={{ text: 'Nested field group 3', id: 'nested-field-group3-titleText-id' }}
1090
- titleDescription="Field group 3 description text."
1091
- actions={
1092
- <Button variant="plain" aria-label="Remove">
1093
- <TrashIcon />
1094
- </Button>
1095
- }
1096
- />
1097
- }
1098
- >
1099
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-field-group3-label1">
1100
- <TextInput
1101
- isRequired
1102
- id="form-expandable-field-groups-field-group3-label1"
1103
- name="form-expandable-field-groups-field-group3-label1"
1104
- value={value7}
1105
- onChange={value => {
1106
- this.handleTextInputChange({ value7: value });
1107
- }}
1108
- />
1109
- </FormGroup>
1110
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-field-group3-label2">
1111
- <TextInput
1112
- isRequired
1113
- id="form-expandable-field-groups-field-group3-label2"
1114
- name="form-expandable-field-groups-field-group3-label2"
1115
- value={value8}
1116
- onChange={value => {
1117
- this.handleTextInputChange({ value8: value });
1118
- }}
1119
- />
1120
- </FormGroup>
1121
- </FormFieldGroupExpandable>
1122
- <FormGroup
1123
- label="Label 1"
1124
- isRequired
1125
- fieldId="form-expandable-field-groupsform-expandable-field-groups-field-group1-label1"
1126
- >
1127
- <TextInput
1128
- isRequired
1129
- id="form-expandable-field-groupsform-expandable-field-groups-field-group1-label1"
1130
- name="form-expandable-field-groupsform-expandable-field-groups-field-group1-label1"
1131
- value={value9}
1132
- onChange={value => {
1133
- this.handleTextInputChange({ value9: value });
1134
- }}
1135
- />
1136
- </FormGroup>
1137
- <FormGroup
1138
- label="Label 2"
1139
- isRequired
1140
- fieldId="form-expandable-field-groupsform-expandable-field-groups-field-group1-label2"
1141
- >
1142
- <TextInput
1143
- isRequired
1144
- id="form-expandable-field-groupsform-expandable-field-groups-field-group1-label2"
1145
- name="form-expandable-field-groupsform-expandable-field-groups-field-group1-label2"
1146
- value={value10}
1147
- onChange={value => {
1148
- this.handleTextInputChange({ value10: value });
1149
- }}
1150
- />
1151
- </FormGroup>
1152
- </FormFieldGroupExpandable>
1153
- <FormFieldGroupExpandable
1154
- toggleAriaLabel="Details"
1155
- header={
1156
- <FormFieldGroupHeader
1157
- titleText={{ text: 'Field group 2', id: 'field-group2-titleText-id' }}
1158
- titleDescription="Field group 2 description text."
1159
- actions={
1160
- <>
1161
- <Button variant="link">Delete all</Button> <Button variant="secondary">Add parameter</Button>
1162
- </>
1163
- }
1164
- />
1165
- }
1166
- >
1167
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-group2-label1">
1168
- <TextInput
1169
- isRequired
1170
- id="form-expandable-field-group2-label1"
1171
- name="form-expandable-field-group2-label1"
1172
- value={value11}
1173
- onChange={value => {
1174
- this.handleTextInputChange({ value11: value });
1175
- }}
1176
- />
1177
- </FormGroup>
1178
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-group2-label2">
1179
- <TextInput
1180
- isRequired
1181
- id="form-expandable-field-group2-label2"
1182
- name="form-expandable-field-group2-label2"
1183
- value={value12}
1184
- onChange={value => {
1185
- this.handleTextInputChange({ value12: value });
1186
- }}
1187
- />
1188
- </FormGroup>
1189
- </FormFieldGroupExpandable>
1190
- <FormFieldGroupExpandable
1191
- isExpanded
1192
- toggleAriaLabel="Details"
1193
- header={
1194
- <FormFieldGroupHeader
1195
- titleText={{ text: 'Field group 3', id: 'field-group3-titleText-id' }}
1196
- titleDescription="Field group 3 description text."
1197
- />
1198
- }
1199
- >
1200
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-group3-label1">
1201
- <TextInput
1202
- isRequired
1203
- id="form-expandable-field-group3-label1"
1204
- name="form-expandable-field-group3-label1"
1205
- value={value13}
1206
- onChange={value => {
1207
- this.handleTextInputChange({ value13: value });
1208
- }}
1209
- />
1210
- </FormGroup>
1211
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-group3-label2">
1212
- <TextInput
1213
- isRequired
1214
- id="form-expandable-field-group3-label2"
1215
- name="form-expandable-field-group3-label2"
1216
- value={value14}
1217
- onChange={value => {
1218
- this.handleTextInputChange({ value14: value });
1219
- }}
1220
- />
1221
- </FormGroup>
1222
- <FormFieldGroup
1223
- header={
1224
- <FormFieldGroupHeader
1225
- titleText={{
1226
- text: 'Nested field group 1 (non-expandable)',
1227
- id: 'nested-field-group1-non-expandable-titleText-id'
1228
- }}
1229
- />
1230
- }
1231
- >
1232
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-field-group7-label1">
1233
- <TextInput
1234
- isRequired
1235
- id="form-expandable-field-groups-field-group7-label1"
1236
- name="form-expandable-field-groups-field-group7-label1"
1237
- value={value15}
1238
- onChange={value => {
1239
- this.handleTextInputChange({ value15: value });
1240
- }}
1241
- />
1242
- </FormGroup>
1243
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-field-group7-label2">
1244
- <TextInput
1245
- isRequired
1246
- id="form-expandable-field-groups-field-group7-label2"
1247
- name="form-expandable-field-groups-field-group7-label2"
1248
- value={value16}
1249
- onChange={value => {
1250
- this.handleTextInputChange({ value16: value });
1251
- }}
1252
- />
1253
- </FormGroup>
1254
- </FormFieldGroup>
1255
- <FormFieldGroup
1256
- header={
1257
- <FormFieldGroupHeader
1258
- titleText={{
1259
- text: 'Nested field group 2 (non-expandable)',
1260
- id: 'nested-field-group2-non-expandable-titleText-id'
1261
- }}
1262
- titleDescription="Field group 2 description text."
1263
- />
1264
- }
1265
- >
1266
- <FormGroup label="Label 1" isRequired fieldId="form-expandable-field-groups-field-group8-label1">
1267
- <TextInput
1268
- isRequired
1269
- id="form-expandable-field-groups-field-group8-label1"
1270
- name="form-expandable-field-groups-field-group8-label1"
1271
- value={value17}
1272
- onChange={value => {
1273
- this.handleTextInputChange({ value17: value });
1274
- }}
1275
- />
1276
- </FormGroup>
1277
- <FormGroup label="Label 2" isRequired fieldId="form-expandable-field-groups-field-group8-label2">
1278
- <TextInput
1279
- isRequired
1280
- id="form-expandable-field-groups-field-group8-label2"
1281
- name="form-expandable-field-groups-field-group8-label2"
1282
- value={value18}
1283
- onChange={value => {
1284
- this.handleTextInputChange({ value18: value });
1285
- }}
1286
- />
1287
- </FormGroup>
1288
- </FormFieldGroup>
1289
- </FormFieldGroupExpandable>
1290
- <FormFieldGroup
1291
- header={
1292
- <FormFieldGroupHeader
1293
- titleText={{ text: 'Field group 4 (non-expandable)', id: 'field-group4-non-expandable-titleText-id' }}
1294
- titleDescription="Field group 4 description text."
1295
- actions={
1296
- <>
1297
- <Button variant="link">Delete all</Button> <Button variant="secondary">Add parameter</Button>
1298
- </>
1299
- }
1300
- />
1301
- }
1302
- >
1303
- <FormGroup
1304
- label="Label 1"
1305
- isRequired
1306
- fieldId="form-expandable-field-groupsform-expandable-field-groups-field-group10-label1"
1307
- >
1308
- <TextInput
1309
- isRequired
1310
- id="form-expandable-field-groupsform-expandable-field-groups-field-group10-label1"
1311
- name="form-expandable-field-groupsform-expandable-field-groups-field-group10-label1"
1312
- value={value19}
1313
- onChange={value => {
1314
- this.handleTextInputChange({ value19: value });
1315
- }}
1316
- />
1317
- </FormGroup>
1318
- <FormGroup
1319
- label="Label 2"
1320
- isRequired
1321
- fieldId="form-expandable-field-groupsform-expandable-field-groups-field-group10-label2"
1322
- >
1323
- <TextInput
1324
- isRequired
1325
- id="form-expandable-field-groupsform-expandable-field-groups-field-group10-label2"
1326
- name="form-expandable-field-groupsform-expandable-field-groups-field-group10-label2"
1327
- value={value20}
1328
- onChange={value => {
1329
- this.handleTextInputChange({ value20: value });
1330
- }}
1331
- />
1332
- </FormGroup>
1333
- </FormFieldGroup>
1334
- <FormGroup label="Label 3" isRequired fieldId="form-expandable-field-groups-label3">
1335
- <TextInput
1336
- isRequired
1337
- id="form-expandable-field-groups-label3"
1338
- name="form-expandable-field-groups-label3"
1339
- value={value21}
1340
- onChange={value => {
1341
- this.handleTextInputChange({ value21: value });
1342
- }}
1343
- />
1344
- </FormGroup>
1345
- <FormGroup label="Label 4" isRequired fieldId="form-expandable-field-groups-label4">
1346
- <TextInput
1347
- isRequired
1348
- id="form-expandable-field-groups-label4"
1349
- name="form-expandable-field-groups-label4"
1350
- value={value22}
1351
- onChange={value => {
1352
- this.handleTextInputChange({ value22: value });
1353
- }}
1354
- />
1355
- </FormGroup>
1356
- </Form>
1357
- );
1358
- }
1359
- }
100
+ ```ts file="./FormFieldGroups.tsx"
1360
101
  ```