@solexllc/usx-react 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/index.cjs +3231 -3270
- package/dist/index.js +3232 -3271
- package/package.json +4 -4
- package/src/components/accordion/Accordion.tsx +4 -1
- package/src/components/accordion/accordion.django.html +1 -1
- package/src/components/accordion/config.json +1 -0
- package/src/components/banner/Banner.tsx +3 -1
- package/src/components/banner/banner.django.html +1 -1
- package/src/components/banner/config.json +1 -0
- package/src/components/carousel/carousel.django-snapshot.html +0 -40
- package/src/components/carousel/carousel.react-snapshot.html +0 -38
- package/src/components/character-count/CharacterCount.tsx +3 -0
- package/src/components/character-count/character-count.django-snapshot.html +43 -0
- package/src/components/character-count/character-count.django.html +2 -2
- package/src/components/character-count/character-count.react-snapshot.html +37 -0
- package/src/components/character-count/config.json +9 -0
- package/src/components/checkbox/Checkbox.tsx +17 -13
- package/src/components/checkbox/checkbox.django-snapshot.html +18 -0
- package/src/components/checkbox/checkbox.django.html +6 -4
- package/src/components/checkbox/checkbox.react-snapshot.html +14 -0
- package/src/components/checkbox/config.json +10 -1
- package/src/components/checkbox-group/checkbox-group.django-snapshot.html +54 -0
- package/src/components/checkbox-group/checkbox-group.react-snapshot.html +45 -0
- package/src/components/combobox/Combobox.tsx +6 -1
- package/src/components/combobox/combobox.django-snapshot.html +141 -0
- package/src/components/combobox/combobox.django.html +2 -2
- package/src/components/combobox/combobox.react-snapshot.html +76 -0
- package/src/components/combobox/config.json +9 -0
- package/src/components/data-table/DataTable.tsx +180 -0
- package/src/components/data-table/README.md +42 -0
- package/src/components/data-table/TableBody.tsx +123 -0
- package/src/components/{table → data-table}/TableCell.tsx +6 -3
- package/src/components/data-table/TableContext.tsx +49 -0
- package/src/components/{table → data-table}/TableFoot.tsx +8 -7
- package/src/components/data-table/TableGroup.tsx +62 -0
- package/src/components/data-table/TableHead.tsx +126 -0
- package/src/components/data-table/TableRow.tsx +24 -0
- package/src/components/data-table/cells.ts +49 -0
- package/src/components/data-table/columns.ts +15 -0
- package/src/components/data-table/config.json +379 -0
- package/src/components/data-table/data-table.django-snapshot.html +13560 -0
- package/src/components/data-table/data-table.django.html +13 -0
- package/src/components/data-table/data-table.html +34 -0
- package/src/components/data-table/data-table.react-snapshot.html +12033 -0
- package/src/components/{table → data-table}/table-body.django.html +12 -12
- package/src/components/{table → data-table}/table-foot.django.html +6 -6
- package/src/components/data-table/table-group.django.html +24 -0
- package/src/components/data-table/table-head.django.html +21 -0
- package/src/components/data-table/table-row.django.html +57 -0
- package/src/components/{table → data-table}/types.ts +48 -5
- package/src/components/date-picker/DatePicker.tsx +6 -1
- package/src/components/date-picker/config.json +9 -0
- package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
- package/src/components/date-picker/date-picker.django.html +4 -4
- package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
- package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
- package/src/components/date-range-picker/config.json +14 -0
- package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
- package/src/components/date-range-picker/date-range-picker.django.html +5 -5
- package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
- package/src/components/drawer/Drawer.tsx +3 -1
- package/src/components/drawer/config.json +4 -0
- package/src/components/drawer/drawer.django.html +1 -1
- package/src/components/file-input/FileInput.tsx +7 -2
- package/src/components/file-input/_contents.django.html +2 -1
- package/src/components/file-input/config.json +4 -0
- package/src/components/header/Header.tsx +15 -9
- package/src/components/header/config.json +1 -0
- package/src/components/header/header.django-snapshot.html +24 -0
- package/src/components/header/header.django.html +8 -4
- package/src/components/header/header.html +20 -0
- package/src/components/header/header.react-snapshot.html +20 -0
- package/src/components/in-page-nav/InPageNav.tsx +3 -0
- package/src/components/in-page-nav/config.json +1 -0
- package/src/components/in-page-nav/in-page-nav.django.html +1 -1
- package/src/components/input/Input.tsx +3 -0
- package/src/components/input/config.json +10 -0
- package/src/components/input/input.django-snapshot.html +24 -0
- package/src/components/input/input.django.html +4 -4
- package/src/components/input/input.react-snapshot.html +22 -0
- package/src/components/language-selector/LanguageSelector.tsx +10 -5
- package/src/components/language-selector/config.json +1 -0
- package/src/components/language-selector/language-selector.django.html +2 -2
- package/src/components/layout/Layout.tsx +3 -1
- package/src/components/layout/config.json +4 -0
- package/src/components/layout/layout.django.html +1 -1
- package/src/components/memorable-date/MemorableDate.tsx +18 -3
- package/src/components/memorable-date/config.json +15 -0
- package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
- package/src/components/memorable-date/memorable-date.django.html +14 -14
- package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
- package/src/components/modal/Modal.tsx +3 -0
- package/src/components/modal/config.json +1 -0
- package/src/components/modal/modal.django.html +1 -1
- package/src/components/pagination/Pagination.tsx +7 -1
- package/src/components/pagination/config.json +8 -0
- package/src/components/pagination/navigation/PaginationNavigation.tsx +10 -0
- package/src/components/pagination/step-options/PaginationStepOptions.tsx +3 -0
- package/src/components/popover/Popover.tsx +3 -0
- package/src/components/popover/config.json +4 -0
- package/src/components/popover/popover.django-snapshot.html +30 -0
- package/src/components/popover/popover.django.html +1 -0
- package/src/components/radio-buttons/RadioButtons.tsx +41 -27
- package/src/components/radio-buttons/config.json +19 -1
- package/src/components/radio-buttons/radio-buttons.django-snapshot.html +93 -60
- package/src/components/radio-buttons/radio-buttons.django.html +16 -28
- package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
- package/src/components/range-slider/RangeSlider.tsx +4 -2
- package/src/components/range-slider/config.json +1 -0
- package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
- package/src/components/range-slider/range-slider.django.html +4 -4
- package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
- package/src/components/search/Search.tsx +6 -1
- package/src/components/search/config.json +5 -0
- package/src/components/search/search.django-snapshot.html +683 -563
- package/src/components/search/search.django.html +1 -1
- package/src/components/search/search.react-snapshot.html +25 -0
- package/src/components/select/Select.tsx +3 -1
- package/src/components/select/config.json +5 -0
- package/src/components/select/select.django-snapshot.html +15 -0
- package/src/components/select/select.django.html +2 -2
- package/src/components/select/select.react-snapshot.html +11 -0
- package/src/components/switch/Switch.tsx +13 -70
- package/src/components/switch/config.json +60 -23
- package/src/components/switch/switch.django-snapshot.html +507 -56
- package/src/components/switch/switch.django.html +23 -26
- package/src/components/switch/switch.html +425 -33
- package/src/components/switch/switch.react-snapshot.html +447 -58
- package/src/components/table/Table.tsx +66 -334
- package/src/components/table/config.json +22 -339
- package/src/components/table/table.django-snapshot.html +712 -1482
- package/src/components/table/table.django.html +14 -59
- package/src/components/table/table.html +7 -2364
- package/src/components/table/table.react-snapshot.html +711 -2085
- package/src/components/text-area/TextArea.tsx +3 -1
- package/src/components/text-area/config.json +5 -0
- package/src/components/text-area/text-area.django-snapshot.html +18 -0
- package/src/components/text-area/text-area.django.html +4 -4
- package/src/components/text-area/text-area.react-snapshot.html +16 -0
- package/src/components/theme-picker/ThemePicker.tsx +3 -1
- package/src/components/theme-picker/config.json +14 -1
- package/src/components/theme-picker/theme-picker.django-snapshot.html +64 -0
- package/src/components/theme-picker/theme-picker.django.html +2 -2
- package/src/components/theme-picker/theme-picker.react-snapshot.html +52 -0
- package/src/components/time-picker/TimePicker.tsx +6 -1
- package/src/components/time-picker/config.json +9 -0
- package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
- package/src/components/time-picker/time-picker.django.html +4 -4
- package/src/components/time-picker/time-picker.react-snapshot.html +22 -0
- package/src/index.js +1 -0
- package/src/components/table/TableBody.tsx +0 -256
- package/src/components/table/TableContext.tsx +0 -87
- package/src/components/table/TableGroup.tsx +0 -69
- package/src/components/table/TableHead.tsx +0 -139
- package/src/components/table/TableRow.tsx +0 -56
- package/src/components/table/hooks/useRowDetails.ts +0 -34
- package/src/components/table/hooks/useTableGroups.ts +0 -61
- package/src/components/table/hooks/useTableSelect.ts +0 -82
- package/src/components/table/hooks/useTableSort.ts +0 -60
- package/src/components/table/table-group.django.html +0 -40
- package/src/components/table/table-head.django.html +0 -85
- package/src/components/table/table-row.django.html +0 -98
- package/src/components/table/table_helper.py +0 -298
- /package/src/components/{table → data-table}/table-detail-row.django.html +0 -0
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
class="usx-popover usx-details"
|
|
6
6
|
data-side="bottom"
|
|
7
7
|
data-align="start"
|
|
8
|
+
|
|
8
9
|
>
|
|
9
10
|
|
|
10
11
|
<summary>Where is my case number?</summary>
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
class="usx-popover"
|
|
21
22
|
data-side="bottom"
|
|
22
23
|
data-align="start"
|
|
24
|
+
|
|
23
25
|
>
|
|
24
26
|
|
|
25
27
|
<summary class="usa-button usx-button usa-button--primary margin-0">Rounded panel</summary>
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
class="usx-popover"
|
|
36
38
|
data-side="bottom"
|
|
37
39
|
data-align="start"
|
|
40
|
+
|
|
38
41
|
>
|
|
39
42
|
|
|
40
43
|
<summary class="usa-button usx-button usa-button--primary margin-0">Square panel</summary>
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
class="usx-popover"
|
|
51
54
|
data-side="bottom"
|
|
52
55
|
data-align="start"
|
|
56
|
+
|
|
53
57
|
>
|
|
54
58
|
|
|
55
59
|
<summary class="display-flex flex-align-center padding-2 bg-surface-2 text-ink usx-rounded-lg"><svg class="usa-icon usa-icon--size-3 margin-right-2" aria-hidden="true" focusable="false"><use href="./img/sprite.svg#folder"></use></svg><span><span class="display-block text-bold">Application 10482</span><span class="display-block font-sans-xs">View status and next steps</span></span></summary>
|
|
@@ -76,6 +80,7 @@
|
|
|
76
80
|
class="usx-popover"
|
|
77
81
|
data-side="bottom"
|
|
78
82
|
data-align="start"
|
|
83
|
+
|
|
79
84
|
>
|
|
80
85
|
|
|
81
86
|
<summary class="usa-button usx-button usa-button--primary margin-0" aria-label="Account options menu">Account options</summary>
|
|
@@ -91,6 +96,7 @@
|
|
|
91
96
|
class="usx-popover"
|
|
92
97
|
data-side="bottom"
|
|
93
98
|
data-align="start"
|
|
99
|
+
|
|
94
100
|
>
|
|
95
101
|
|
|
96
102
|
<summary class="usa-button usx-button usa-button--primary margin-0">Resident services</summary>
|
|
@@ -158,6 +164,7 @@
|
|
|
158
164
|
class="usx-popover"
|
|
159
165
|
data-side="bottom"
|
|
160
166
|
data-align="start"
|
|
167
|
+
|
|
161
168
|
>
|
|
162
169
|
|
|
163
170
|
<summary class="usa-button usx-button usa-button--primary margin-0">Resident services</summary>
|
|
@@ -225,6 +232,7 @@
|
|
|
225
232
|
class="usx-popover margin-left-2"
|
|
226
233
|
data-side="bottom"
|
|
227
234
|
data-align="start"
|
|
235
|
+
|
|
228
236
|
>
|
|
229
237
|
|
|
230
238
|
<summary class="usa-button usx-button usa-button--primary margin-0" aria-label="Account and services, 3 notifications"><svg class="usa-icon margin-right-1" aria-hidden="true" focusable="false"><use href="./img/sprite.svg#menu"></use></svg><span>Account and services</span><span class="usa-tag margin-left-1">3</span></summary>
|
|
@@ -311,6 +319,7 @@
|
|
|
311
319
|
class="usx-popover"
|
|
312
320
|
data-side="bottom"
|
|
313
321
|
data-align="start"
|
|
322
|
+
|
|
314
323
|
>
|
|
315
324
|
|
|
316
325
|
<summary class="usa-button usx-button usa-button--primary margin-0">Record links</summary>
|
|
@@ -335,6 +344,7 @@
|
|
|
335
344
|
class="usx-popover"
|
|
336
345
|
data-side="bottom"
|
|
337
346
|
data-align="start"
|
|
347
|
+
|
|
338
348
|
>
|
|
339
349
|
|
|
340
350
|
<summary class="usa-button usx-button usa-button--primary margin-0">Filter results</summary>
|
|
@@ -376,6 +386,7 @@
|
|
|
376
386
|
class="usx-popover"
|
|
377
387
|
data-side="bottom"
|
|
378
388
|
data-align="start"
|
|
389
|
+
|
|
379
390
|
>
|
|
380
391
|
|
|
381
392
|
<summary class="usa-button usx-button usa-button--primary margin-0">Important dates</summary>
|
|
@@ -393,6 +404,7 @@
|
|
|
393
404
|
class="usx-popover"
|
|
394
405
|
data-side="bottom"
|
|
395
406
|
data-align="start"
|
|
407
|
+
|
|
396
408
|
>
|
|
397
409
|
|
|
398
410
|
<summary class="usa-button usx-button usa-button--primary margin-0">Important dates</summary>
|
|
@@ -410,6 +422,7 @@
|
|
|
410
422
|
class="usx-popover"
|
|
411
423
|
data-side="bottom"
|
|
412
424
|
data-align="start"
|
|
425
|
+
|
|
413
426
|
>
|
|
414
427
|
|
|
415
428
|
<summary class="usa-button usx-button usa-button--primary margin-0">Important dates</summary>
|
|
@@ -429,6 +442,7 @@
|
|
|
429
442
|
class="usx-popover"
|
|
430
443
|
data-side="right"
|
|
431
444
|
data-align="start"
|
|
445
|
+
|
|
432
446
|
>
|
|
433
447
|
|
|
434
448
|
<summary class="usa-button usx-button usa-button--primary margin-0">right / start</summary>
|
|
@@ -444,6 +458,7 @@
|
|
|
444
458
|
class="usx-popover"
|
|
445
459
|
data-side="top"
|
|
446
460
|
data-align="start"
|
|
461
|
+
|
|
447
462
|
>
|
|
448
463
|
|
|
449
464
|
<summary class="usa-button usx-button usa-button--primary margin-0">top / start</summary>
|
|
@@ -459,6 +474,7 @@
|
|
|
459
474
|
class="usx-popover"
|
|
460
475
|
data-side="bottom"
|
|
461
476
|
data-align="start"
|
|
477
|
+
|
|
462
478
|
>
|
|
463
479
|
|
|
464
480
|
<summary class="usa-button usx-button usa-button--primary margin-0">bottom / start</summary>
|
|
@@ -474,6 +490,7 @@
|
|
|
474
490
|
class="usx-popover"
|
|
475
491
|
data-side="left"
|
|
476
492
|
data-align="start"
|
|
493
|
+
|
|
477
494
|
>
|
|
478
495
|
|
|
479
496
|
<summary class="usa-button usx-button usa-button--primary margin-0">left / start</summary>
|
|
@@ -489,6 +506,7 @@
|
|
|
489
506
|
class="usx-popover"
|
|
490
507
|
data-side="right"
|
|
491
508
|
data-align="center"
|
|
509
|
+
|
|
492
510
|
>
|
|
493
511
|
|
|
494
512
|
<summary class="usa-button usx-button usa-button--primary margin-0">right / center</summary>
|
|
@@ -504,6 +522,7 @@
|
|
|
504
522
|
class="usx-popover"
|
|
505
523
|
data-side="top"
|
|
506
524
|
data-align="center"
|
|
525
|
+
|
|
507
526
|
>
|
|
508
527
|
|
|
509
528
|
<summary class="usa-button usx-button usa-button--primary margin-0">top / center</summary>
|
|
@@ -519,6 +538,7 @@
|
|
|
519
538
|
class="usx-popover"
|
|
520
539
|
data-side="bottom"
|
|
521
540
|
data-align="center"
|
|
541
|
+
|
|
522
542
|
>
|
|
523
543
|
|
|
524
544
|
<summary class="usa-button usx-button usa-button--primary margin-0">bottom / center</summary>
|
|
@@ -534,6 +554,7 @@
|
|
|
534
554
|
class="usx-popover"
|
|
535
555
|
data-side="left"
|
|
536
556
|
data-align="center"
|
|
557
|
+
|
|
537
558
|
>
|
|
538
559
|
|
|
539
560
|
<summary class="usa-button usx-button usa-button--primary margin-0">left / center</summary>
|
|
@@ -549,6 +570,7 @@
|
|
|
549
570
|
class="usx-popover"
|
|
550
571
|
data-side="right"
|
|
551
572
|
data-align="end"
|
|
573
|
+
|
|
552
574
|
>
|
|
553
575
|
|
|
554
576
|
<summary class="usa-button usx-button usa-button--primary margin-0">right / end</summary>
|
|
@@ -564,6 +586,7 @@
|
|
|
564
586
|
class="usx-popover"
|
|
565
587
|
data-side="top"
|
|
566
588
|
data-align="end"
|
|
589
|
+
|
|
567
590
|
>
|
|
568
591
|
|
|
569
592
|
<summary class="usa-button usx-button usa-button--primary margin-0">top / end</summary>
|
|
@@ -579,6 +602,7 @@
|
|
|
579
602
|
class="usx-popover"
|
|
580
603
|
data-side="bottom"
|
|
581
604
|
data-align="end"
|
|
605
|
+
|
|
582
606
|
>
|
|
583
607
|
|
|
584
608
|
<summary class="usa-button usx-button usa-button--primary margin-0">bottom / end</summary>
|
|
@@ -594,6 +618,7 @@
|
|
|
594
618
|
class="usx-popover"
|
|
595
619
|
data-side="left"
|
|
596
620
|
data-align="end"
|
|
621
|
+
|
|
597
622
|
>
|
|
598
623
|
|
|
599
624
|
<summary class="usa-button usx-button usa-button--primary margin-0">left / end</summary>
|
|
@@ -612,6 +637,7 @@
|
|
|
612
637
|
class="usx-popover"
|
|
613
638
|
data-side="bottom"
|
|
614
639
|
data-align="start"
|
|
640
|
+
|
|
615
641
|
>
|
|
616
642
|
|
|
617
643
|
<summary class="usa-button usx-button usa-button--primary margin-0">Bottom / start in RTL</summary>
|
|
@@ -626,6 +652,7 @@
|
|
|
626
652
|
class="usx-popover"
|
|
627
653
|
data-side="bottom"
|
|
628
654
|
data-align="end"
|
|
655
|
+
|
|
629
656
|
>
|
|
630
657
|
|
|
631
658
|
<summary class="usa-button usx-button usa-button--primary margin-0">Bottom / end in RTL</summary>
|
|
@@ -642,6 +669,7 @@
|
|
|
642
669
|
class="usx-popover"
|
|
643
670
|
data-side="bottom"
|
|
644
671
|
data-align="start"
|
|
672
|
+
|
|
645
673
|
>
|
|
646
674
|
|
|
647
675
|
<summary class="usa-button usx-button usa-button--primary margin-0">City departments</summary>
|
|
@@ -882,6 +910,7 @@
|
|
|
882
910
|
class="usx-popover"
|
|
883
911
|
data-side="bottom"
|
|
884
912
|
data-align="start"
|
|
913
|
+
|
|
885
914
|
>
|
|
886
915
|
|
|
887
916
|
<summary class="usa-button usx-button usa-button--primary margin-0"><svg class="usa-icon margin-right-1" aria-hidden="true" focusable="false"><use href="./img/sprite.svg#menu"></use></svg><span>Menu</span></summary>
|
|
@@ -1128,6 +1157,7 @@
|
|
|
1128
1157
|
class="usx-popover"
|
|
1129
1158
|
data-side="bottom"
|
|
1130
1159
|
data-align="start"
|
|
1160
|
+
|
|
1131
1161
|
>
|
|
1132
1162
|
|
|
1133
1163
|
<summary class="padding-2 bg-surface-2 border-left-1px border-right-1px usa-button usx-button usa-button--unstyled margin-0">Resident services</summary>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
class="usx-popover{% if className %} {{ className }}{% endif %}"{% if defaultOpen %} open{% endif %}
|
|
6
6
|
data-side="{{ side|default:'bottom'|force_escape }}"
|
|
7
7
|
data-align="{{ align|default:'start'|force_escape }}"
|
|
8
|
+
{% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
|
|
8
9
|
>{% summary props=summaryProps label=summaryProps.label|default:'Open panel' unstyled=True %}{% endsummary %}<div
|
|
9
10
|
id="{{ id|force_escape }}"
|
|
10
11
|
class="usx-popover__panel{% if panelShape == 'square' %} usx-popover__panel--square{% endif %}{% if panelClassName %} {{ panelClassName }}{% endif %}"
|
|
@@ -8,12 +8,13 @@ export interface RadioOption {
|
|
|
8
8
|
id?: string;
|
|
9
9
|
value: string;
|
|
10
10
|
label: React.ReactNode;
|
|
11
|
+
ariaLabel?: string;
|
|
11
12
|
description?: React.ReactNode;
|
|
12
13
|
checked?: boolean;
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export interface RadioButtonsProps extends React.HTMLAttributes<HTMLFieldSetElement> {
|
|
17
|
+
export interface RadioButtonsProps extends Omit<React.HTMLAttributes<HTMLFieldSetElement>, 'onChange'> {
|
|
17
18
|
tile?: boolean;
|
|
18
19
|
small?: boolean;
|
|
19
20
|
legend?: string;
|
|
@@ -23,6 +24,10 @@ export interface RadioButtonsProps extends React.HTMLAttributes<HTMLFieldSetElem
|
|
|
23
24
|
name?: string;
|
|
24
25
|
options: RadioOption[];
|
|
25
26
|
defaultValue?: string;
|
|
27
|
+
value?: string;
|
|
28
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
29
|
+
formGroup?: boolean;
|
|
30
|
+
fieldset?: boolean;
|
|
26
31
|
className?: string;
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -37,6 +42,10 @@ const RadioButtons: React.FC<RadioButtonsProps> = ({
|
|
|
37
42
|
id: groupId,
|
|
38
43
|
options = [],
|
|
39
44
|
defaultValue = undefined,
|
|
45
|
+
value,
|
|
46
|
+
onChange,
|
|
47
|
+
formGroup = true,
|
|
48
|
+
fieldset = true,
|
|
40
49
|
className = '',
|
|
41
50
|
...props
|
|
42
51
|
}) => {
|
|
@@ -44,8 +53,34 @@ const RadioButtons: React.FC<RadioButtonsProps> = ({
|
|
|
44
53
|
|
|
45
54
|
const inputClasses = classNames('usa-radio__input', { 'usa-radio__input--tile': tile });
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const optionsMarkup = options.map((opt, idx) => {
|
|
57
|
+
const id = opt.id || `${groupId || name}-${idx}`;
|
|
58
|
+
return (
|
|
59
|
+
<div className={classes} key={id}>
|
|
60
|
+
<input
|
|
61
|
+
className={inputClasses}
|
|
62
|
+
id={id}
|
|
63
|
+
type="radio"
|
|
64
|
+
name={name}
|
|
65
|
+
value={opt.value}
|
|
66
|
+
aria-label={opt.ariaLabel}
|
|
67
|
+
{...(value !== undefined && onChange
|
|
68
|
+
? { checked: value === opt.value }
|
|
69
|
+
: { defaultChecked: (value ?? defaultValue) !== undefined
|
|
70
|
+
? (value ?? defaultValue) === opt.value
|
|
71
|
+
: !!opt.checked })}
|
|
72
|
+
onChange={onChange}
|
|
73
|
+
disabled={!!opt.disabled}
|
|
74
|
+
/>
|
|
75
|
+
<Label className="usa-radio__label" classOverride={true} htmlFor={id}>
|
|
76
|
+
{opt.label}
|
|
77
|
+
{opt.description ? <span className="usa-checkbox__label-description">{opt.description}</span> : null}
|
|
78
|
+
</Label>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const content = fieldset ? (
|
|
49
84
|
<Fieldset
|
|
50
85
|
id={groupId}
|
|
51
86
|
legend={legend}
|
|
@@ -54,31 +89,10 @@ const RadioButtons: React.FC<RadioButtonsProps> = ({
|
|
|
54
89
|
error={error}
|
|
55
90
|
{...props}
|
|
56
91
|
>
|
|
57
|
-
{
|
|
58
|
-
const id = opt.id || `${groupId || name}-${idx}`;
|
|
59
|
-
return (
|
|
60
|
-
<div className={classes} key={id}>
|
|
61
|
-
<input
|
|
62
|
-
className={inputClasses}
|
|
63
|
-
id={id}
|
|
64
|
-
type="radio"
|
|
65
|
-
name={name}
|
|
66
|
-
value={opt.value}
|
|
67
|
-
defaultChecked={defaultValue === opt.value || !!opt.checked}
|
|
68
|
-
disabled={!!opt.disabled}
|
|
69
|
-
/>
|
|
70
|
-
<Label className="usa-radio__label" classOverride={true} htmlFor={id}>
|
|
71
|
-
{opt.label}
|
|
72
|
-
{opt.description ? (
|
|
73
|
-
<span className="usa-checkbox__label-description">{opt.description}</span>
|
|
74
|
-
) : null}
|
|
75
|
-
</Label>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
})}
|
|
92
|
+
{optionsMarkup}
|
|
79
93
|
</Fieldset>
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
) : optionsMarkup;
|
|
95
|
+
return formGroup ? <FormGroup error={!!error}>{content}</FormGroup> : content;
|
|
82
96
|
};
|
|
83
97
|
|
|
84
98
|
export default RadioButtons;
|
|
@@ -68,9 +68,27 @@
|
|
|
68
68
|
"type": "string",
|
|
69
69
|
"description": "Value of the option to be selected by default"
|
|
70
70
|
},
|
|
71
|
+
"value": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "Controlled selected value in React."
|
|
74
|
+
},
|
|
75
|
+
"onChange": {
|
|
76
|
+
"type": "function",
|
|
77
|
+
"description": "React change handler for the selected radio input."
|
|
78
|
+
},
|
|
79
|
+
"fieldset": {
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"default": true,
|
|
82
|
+
"description": "Wrap options in a fieldset; false allows one option inside a table cell."
|
|
83
|
+
},
|
|
84
|
+
"formGroup": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"default": true,
|
|
87
|
+
"description": "Wrap the fieldset in a form group."
|
|
88
|
+
},
|
|
71
89
|
"options": {
|
|
72
90
|
"type": "array",
|
|
73
|
-
"description": "Array of option objects: {id, value, label, description, checked, disabled}"
|
|
91
|
+
"description": "Array of option objects: {id, value, label, ariaLabel, description, checked, disabled}"
|
|
74
92
|
},
|
|
75
93
|
"className": {
|
|
76
94
|
"type": "string",
|