@solexllc/usx-react 0.9.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.
Files changed (123) hide show
  1. package/README.md +6 -5
  2. package/dist/index.cjs +123 -97
  3. package/dist/index.js +124 -98
  4. package/package.json +4 -4
  5. package/src/components/accordion/Accordion.tsx +4 -1
  6. package/src/components/accordion/accordion.django.html +1 -1
  7. package/src/components/accordion/config.json +1 -0
  8. package/src/components/banner/Banner.tsx +3 -1
  9. package/src/components/banner/banner.django.html +1 -1
  10. package/src/components/banner/config.json +1 -0
  11. package/src/components/carousel/carousel.django-snapshot.html +0 -40
  12. package/src/components/carousel/carousel.react-snapshot.html +0 -38
  13. package/src/components/character-count/CharacterCount.tsx +3 -0
  14. package/src/components/character-count/character-count.django-snapshot.html +43 -0
  15. package/src/components/character-count/character-count.django.html +2 -2
  16. package/src/components/character-count/character-count.react-snapshot.html +37 -0
  17. package/src/components/character-count/config.json +9 -0
  18. package/src/components/checkbox/Checkbox.tsx +16 -17
  19. package/src/components/checkbox/checkbox.django-snapshot.html +18 -0
  20. package/src/components/checkbox/checkbox.django.html +6 -4
  21. package/src/components/checkbox/checkbox.react-snapshot.html +14 -0
  22. package/src/components/checkbox/config.json +4 -4
  23. package/src/components/checkbox-group/checkbox-group.django-snapshot.html +54 -0
  24. package/src/components/checkbox-group/checkbox-group.react-snapshot.html +45 -0
  25. package/src/components/combobox/Combobox.tsx +6 -1
  26. package/src/components/combobox/combobox.django-snapshot.html +141 -0
  27. package/src/components/combobox/combobox.django.html +2 -2
  28. package/src/components/combobox/combobox.react-snapshot.html +76 -0
  29. package/src/components/combobox/config.json +9 -0
  30. package/src/components/data-table/DataTable.tsx +4 -1
  31. package/src/components/data-table/config.json +4 -0
  32. package/src/components/data-table/data-table.django.html +1 -1
  33. package/src/components/date-picker/DatePicker.tsx +6 -1
  34. package/src/components/date-picker/config.json +9 -0
  35. package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
  36. package/src/components/date-picker/date-picker.django.html +4 -4
  37. package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
  38. package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
  39. package/src/components/date-range-picker/config.json +14 -0
  40. package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
  41. package/src/components/date-range-picker/date-range-picker.django.html +5 -5
  42. package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
  43. package/src/components/drawer/Drawer.tsx +3 -1
  44. package/src/components/drawer/config.json +4 -0
  45. package/src/components/drawer/drawer.django.html +1 -1
  46. package/src/components/file-input/FileInput.tsx +7 -2
  47. package/src/components/file-input/_contents.django.html +2 -1
  48. package/src/components/file-input/config.json +4 -0
  49. package/src/components/header/Header.tsx +15 -9
  50. package/src/components/header/config.json +1 -0
  51. package/src/components/header/header.django-snapshot.html +24 -0
  52. package/src/components/header/header.django.html +8 -4
  53. package/src/components/header/header.html +20 -0
  54. package/src/components/header/header.react-snapshot.html +20 -0
  55. package/src/components/in-page-nav/InPageNav.tsx +3 -0
  56. package/src/components/in-page-nav/config.json +1 -0
  57. package/src/components/in-page-nav/in-page-nav.django.html +1 -1
  58. package/src/components/input/Input.tsx +3 -0
  59. package/src/components/input/config.json +10 -0
  60. package/src/components/input/input.django-snapshot.html +24 -0
  61. package/src/components/input/input.django.html +4 -4
  62. package/src/components/input/input.react-snapshot.html +22 -0
  63. package/src/components/language-selector/LanguageSelector.tsx +10 -5
  64. package/src/components/language-selector/config.json +1 -0
  65. package/src/components/language-selector/language-selector.django.html +2 -2
  66. package/src/components/layout/Layout.tsx +3 -1
  67. package/src/components/layout/config.json +4 -0
  68. package/src/components/layout/layout.django.html +1 -1
  69. package/src/components/memorable-date/MemorableDate.tsx +18 -3
  70. package/src/components/memorable-date/config.json +15 -0
  71. package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
  72. package/src/components/memorable-date/memorable-date.django.html +14 -14
  73. package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
  74. package/src/components/modal/Modal.tsx +3 -0
  75. package/src/components/modal/config.json +1 -0
  76. package/src/components/modal/modal.django.html +1 -1
  77. package/src/components/popover/Popover.tsx +3 -0
  78. package/src/components/popover/config.json +4 -0
  79. package/src/components/popover/popover.django-snapshot.html +30 -0
  80. package/src/components/popover/popover.django.html +1 -0
  81. package/src/components/radio-buttons/RadioButtons.tsx +5 -1
  82. package/src/components/radio-buttons/radio-buttons.django-snapshot.html +65 -0
  83. package/src/components/radio-buttons/radio-buttons.django.html +1 -1
  84. package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
  85. package/src/components/range-slider/RangeSlider.tsx +4 -2
  86. package/src/components/range-slider/config.json +1 -0
  87. package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
  88. package/src/components/range-slider/range-slider.django.html +4 -4
  89. package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
  90. package/src/components/search/Search.tsx +6 -1
  91. package/src/components/search/config.json +5 -0
  92. package/src/components/search/search.django-snapshot.html +683 -563
  93. package/src/components/search/search.django.html +1 -1
  94. package/src/components/search/search.react-snapshot.html +25 -0
  95. package/src/components/select/Select.tsx +3 -1
  96. package/src/components/select/config.json +5 -0
  97. package/src/components/select/select.django-snapshot.html +15 -0
  98. package/src/components/select/select.django.html +2 -2
  99. package/src/components/select/select.react-snapshot.html +11 -0
  100. package/src/components/switch/Switch.tsx +13 -70
  101. package/src/components/switch/config.json +60 -23
  102. package/src/components/switch/switch.django-snapshot.html +507 -56
  103. package/src/components/switch/switch.django.html +23 -26
  104. package/src/components/switch/switch.html +425 -33
  105. package/src/components/switch/switch.react-snapshot.html +447 -58
  106. package/src/components/table/Table.tsx +3 -1
  107. package/src/components/table/config.json +1 -0
  108. package/src/components/table/table.django.html +1 -1
  109. package/src/components/text-area/TextArea.tsx +3 -1
  110. package/src/components/text-area/config.json +5 -0
  111. package/src/components/text-area/text-area.django-snapshot.html +18 -0
  112. package/src/components/text-area/text-area.django.html +4 -4
  113. package/src/components/text-area/text-area.react-snapshot.html +16 -0
  114. package/src/components/theme-picker/ThemePicker.tsx +3 -1
  115. package/src/components/theme-picker/config.json +14 -1
  116. package/src/components/theme-picker/theme-picker.django-snapshot.html +64 -0
  117. package/src/components/theme-picker/theme-picker.django.html +2 -2
  118. package/src/components/theme-picker/theme-picker.react-snapshot.html +52 -0
  119. package/src/components/time-picker/TimePicker.tsx +6 -1
  120. package/src/components/time-picker/config.json +9 -0
  121. package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
  122. package/src/components/time-picker/time-picker.django.html +4 -4
  123. package/src/components/time-picker/time-picker.react-snapshot.html +22 -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 %}"
@@ -64,7 +64,11 @@ const RadioButtons: React.FC<RadioButtonsProps> = ({
64
64
  name={name}
65
65
  value={opt.value}
66
66
  aria-label={opt.ariaLabel}
67
- {...(value !== undefined && onChange ? { checked: value === opt.value } : { defaultChecked: defaultValue === opt.value || !!opt.checked })}
67
+ {...(value !== undefined && onChange
68
+ ? { checked: value === opt.value }
69
+ : { defaultChecked: (value ?? defaultValue) !== undefined
70
+ ? (value ?? defaultValue) === opt.value
71
+ : !!opt.checked })}
68
72
  onChange={onChange}
69
73
  disabled={!!opt.disabled}
70
74
  />
@@ -726,3 +726,68 @@
726
726
  </div>
727
727
  </fieldset>
728
728
  </div>
729
+
730
+ <h3 class="site-preview-heading">With Value</h3>
731
+ <div class="usa-form-group usx-form-group">
732
+ <fieldset id="django-historical-figures-value" class="usa-fieldset usx-fieldset">
733
+ <legend class="usa-legend usx-legend">Select one option</legend>
734
+
735
+ <div class="usa-radio usx-radio">
736
+ <input
737
+ class="usa-radio__input"
738
+ id="django-historical-figures-value-0"
739
+ type="radio"
740
+ name="historical-figures-value"
741
+ value="sojourner-truth"
742
+ />
743
+
744
+ <label class="usa-radio__label" for="django-historical-figures-value-0">
745
+ Sojourner Truth
746
+ </label>
747
+ </div>
748
+
749
+ <div class="usa-radio usx-radio">
750
+ <input
751
+ class="usa-radio__input"
752
+ id="django-historical-figures-value-1"
753
+ type="radio"
754
+ name="historical-figures-value"
755
+ value="frederick-douglass"
756
+ />
757
+
758
+ <label class="usa-radio__label" for="django-historical-figures-value-1">
759
+ Frederick Douglass
760
+ </label>
761
+ </div>
762
+
763
+ <div class="usa-radio usx-radio">
764
+ <input
765
+ class="usa-radio__input"
766
+ id="django-historical-figures-value-2"
767
+ type="radio"
768
+ name="historical-figures-value"
769
+ value="booker-t-washington"
770
+ checked
771
+ />
772
+
773
+ <label class="usa-radio__label" for="django-historical-figures-value-2">
774
+ Booker T. Washington
775
+ </label>
776
+ </div>
777
+
778
+ <div class="usa-radio usx-radio">
779
+ <input
780
+ class="usa-radio__input"
781
+ id="django-historical-figures-value-3"
782
+ type="radio"
783
+ name="historical-figures-value"
784
+ value="george-washington-carver"
785
+ disabled
786
+ />
787
+
788
+ <label class="usa-radio__label" for="django-historical-figures-value-3">
789
+ George Washington Carver
790
+ </label>
791
+ </div>
792
+ </fieldset>
793
+ </div>
@@ -8,7 +8,7 @@
8
8
  {% with generatedId=baseId|add:'-'|add:index %}
9
9
  {% with optionId=opt.id|default:generatedId %}
10
10
  <div class="usa-radio usx-radio{% if small %} usx-radio--small{% endif %}{% if className %} {{ className }}{% endif %}">
11
- <input class="usa-radio__input{% if tile %} usa-radio__input--tile{% endif %}" id="{{ optionId }}" type="radio" name="{{ groupName }}" value="{{ opt.value }}"{% if opt.ariaLabel %} aria-label="{{ opt.ariaLabel }}"{% endif %}{% if defaultValue == opt.value or opt.checked %} checked{% endif %}{% if opt.disabled %} disabled{% endif %}>
11
+ <input class="usa-radio__input{% if tile %} usa-radio__input--tile{% endif %}" id="{{ optionId }}" type="radio" name="{{ groupName }}" value="{{ opt.value }}"{% if opt.ariaLabel %} aria-label="{{ opt.ariaLabel }}"{% endif %}{% if value is not None and value == opt.value or value is None and defaultValue is not None and defaultValue == opt.value or value is None and defaultValue is None and opt.checked %} checked{% endif %}{% if opt.disabled %} disabled{% endif %}>
12
12
  {% label htmlFor=optionId className='usa-radio__label' classOverride=True %}{{ opt.label }}{% if opt.description %}<span class="usa-checkbox__label-description">{{ opt.description }}</span>{% endif %}{% endlabel %}
13
13
  </div>
14
14
  {% endwith %}{% endwith %}{% endwith %}{% endwith %}
@@ -590,3 +590,56 @@
590
590
  </div>
591
591
  </fieldset>
592
592
  </div>
593
+
594
+ <h3 class="site-preview-heading">With Value</h3>
595
+ <div class="usa-form-group usx-form-group">
596
+ <fieldset class="usa-fieldset usx-fieldset" id="react-historical-figures-value">
597
+ <legend class="usa-legend usx-legend">Select one option</legend>
598
+ <div class="usa-radio usx-radio">
599
+ <input
600
+ class="usa-radio__input"
601
+ id="react-historical-figures-value-0"
602
+ type="radio"
603
+ name="historical-figures-value"
604
+ value="sojourner-truth"
605
+ /><label class="usa-radio__label" for="react-historical-figures-value-0"
606
+ >Sojourner Truth</label
607
+ >
608
+ </div>
609
+ <div class="usa-radio usx-radio">
610
+ <input
611
+ class="usa-radio__input"
612
+ id="react-historical-figures-value-1"
613
+ type="radio"
614
+ name="historical-figures-value"
615
+ value="frederick-douglass"
616
+ /><label class="usa-radio__label" for="react-historical-figures-value-1"
617
+ >Frederick Douglass</label
618
+ >
619
+ </div>
620
+ <div class="usa-radio usx-radio">
621
+ <input
622
+ class="usa-radio__input"
623
+ id="react-historical-figures-value-2"
624
+ type="radio"
625
+ name="historical-figures-value"
626
+ checked=""
627
+ value="booker-t-washington"
628
+ /><label class="usa-radio__label" for="react-historical-figures-value-2"
629
+ >Booker T. Washington</label
630
+ >
631
+ </div>
632
+ <div class="usa-radio usx-radio">
633
+ <input
634
+ class="usa-radio__input"
635
+ id="react-historical-figures-value-3"
636
+ type="radio"
637
+ name="historical-figures-value"
638
+ disabled=""
639
+ value="george-washington-carver"
640
+ /><label class="usa-radio__label" for="react-historical-figures-value-3"
641
+ >George Washington Carver</label
642
+ >
643
+ </div>
644
+ </fieldset>
645
+ </div>
@@ -7,6 +7,7 @@ import Hint from '../hint/Hint';
7
7
  import ErrorMessage from '../error-message/ErrorMessage';
8
8
 
9
9
  export interface RangeSliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue'> {
10
+ extraAttributes?: Record<string, unknown>;
10
11
  label?: React.ReactNode;
11
12
  hint?: React.ReactNode;
12
13
  error?: React.ReactNode;
@@ -38,6 +39,7 @@ export default function RangeSlider({
38
39
  textPreposition = 'of',
39
40
  formGroup = true,
40
41
  className = '',
42
+ extraAttributes,
41
43
  ...props
42
44
  }: RangeSliderProps) {
43
45
  const hintId = hint ? `${id}-hint` : undefined;
@@ -61,14 +63,14 @@ export default function RangeSlider({
61
63
  min={min}
62
64
  max={max}
63
65
  step={step}
64
- value={typeof value !== 'undefined' ? value : undefined}
65
- defaultValue={defaultValue}
66
+ {...(value !== undefined ? { value } : { defaultValue })}
66
67
  disabled={disabled}
67
68
  required={required}
68
69
  aria-describedby={describedBy}
69
70
  {...(textUnit ? { 'data-text-unit': textUnit } : {})}
70
71
  {...(textPreposition ? { 'data-text-preposition': textPreposition } : {})}
71
72
  {...props}
73
+ {...extraAttributes}
72
74
  />
73
75
  </>
74
76
  );
@@ -12,6 +12,7 @@
12
12
  "defaultValue": 20
13
13
  },
14
14
  "props": {
15
+ "extraAttributes": { "type": "object", "description": "Additional attributes on the USWDS enhancement target." },
15
16
  "id": {
16
17
  "type": "string",
17
18
  "default": "range-slider",
@@ -155,3 +155,20 @@
155
155
  disabled
156
156
  />
157
157
  </div>
158
+
159
+ <h3 class="site-preview-heading">With Value</h3>
160
+ <div class="usa-form-group usx-form-group">
161
+ <label class="usa-label usx-label" for="django-range-value"> Current range value </label>
162
+
163
+ <input
164
+ class="usa-range usx-range-slider"
165
+ id="django-range-value"
166
+ type="range"
167
+ name="range-value"
168
+ min="0"
169
+ max="100"
170
+ step="1"
171
+ value="75"
172
+ data-text-preposition="of"
173
+ />
174
+ </div>
@@ -18,14 +18,14 @@
18
18
  {% endif %}
19
19
 
20
20
  <input
21
- class="usa-range usx-range-slider{% if className %} {{ className }}{% endif %}"
21
+ class="usa-range usx-range-slider{% if className %} {{ className }}{% endif %}" {% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
22
22
  id="{{ id }}"
23
23
  type="range"
24
24
  name="{{ name|default:id }}"
25
25
  min="{{ min|default:0 }}"
26
26
  max="{{ max|default:100 }}"
27
27
  step="{{ step|default:1 }}"
28
- value="{% firstof value defaultValue 0 %}"
28
+ value="{% if value is not None %}{{ value }}{% elif defaultValue is not None %}{{ defaultValue }}{% else %}0{% endif %}"
29
29
  {% if textUnit %} data-text-unit="{{ textUnit }}"{% endif %}
30
30
  {% if textPreposition %} data-text-preposition="{{ textPreposition }}"{% endif %}
31
31
  {% if hint or error %} aria-describedby="{% if hint %}{{ id }}-hint{% endif %}{% if hint and error %} {% endif %}{% if error %}{{ id }}-error{% endif %}"{% endif %}
@@ -47,14 +47,14 @@
47
47
  {% endif %}
48
48
 
49
49
  <input
50
- class="usa-range usx-range-slider{% if className %} {{ className }}{% endif %}"
50
+ class="usa-range usx-range-slider{% if className %} {{ className }}{% endif %}" {% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
51
51
  id="{{ id }}"
52
52
  type="range"
53
53
  name="{{ name|default:id }}"
54
54
  min="{{ min|default:0 }}"
55
55
  max="{{ max|default:100 }}"
56
56
  step="{{ step|default:1 }}"
57
- value="{% firstof value defaultValue 0 %}"
57
+ value="{% if value is not None %}{{ value }}{% elif defaultValue is not None %}{{ defaultValue }}{% else %}0{% endif %}"
58
58
  {% if textUnit %} data-text-unit="{{ textUnit }}"{% endif %}
59
59
  {% if textPreposition %} data-text-preposition="{{ textPreposition }}"{% endif %}
60
60
  {% if hint or error %} aria-describedby="{% if hint %}{{ id }}-hint{% endif %}{% if hint and error %} {% endif %}{% if error %}{{ id }}-error{% endif %}"{% endif %}
@@ -132,3 +132,19 @@
132
132
  value="20"
133
133
  />
134
134
  </div>
135
+
136
+ <h3 class="site-preview-heading">With Value</h3>
137
+ <div class="usa-form-group usx-form-group">
138
+ <label class="usa-label usx-label" for="react-range-value">Current range value</label
139
+ ><input
140
+ class="usa-range usx-range-slider"
141
+ id="react-range-value"
142
+ type="range"
143
+ name="range-value"
144
+ min="0"
145
+ max="100"
146
+ step="1"
147
+ data-text-preposition="of"
148
+ value="75"
149
+ />
150
+ </div>
@@ -18,6 +18,8 @@ export interface SearchProps {
18
18
  action?: string;
19
19
  placeholder?: string;
20
20
  defaultValue?: string;
21
+ value?: string;
22
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
21
23
  onSubmit?: (query: FormDataEntryValue | null) => void;
22
24
  className?: string;
23
25
  }
@@ -34,6 +36,8 @@ export default function Search({
34
36
  placeholder,
35
37
  action,
36
38
  defaultValue,
39
+ value,
40
+ onChange,
37
41
  onSubmit,
38
42
  className = '',
39
43
  }: SearchProps) {
@@ -74,7 +78,8 @@ export default function Search({
74
78
  label={label}
75
79
  screenReaderOnlyLabel={true}
76
80
  placeholder={placeholder ?? ''}
77
- defaultValue={defaultValue}
81
+ {...(value !== undefined ? { value } : { defaultValue })}
82
+ onChange={onChange}
78
83
  type="search"
79
84
  name={searchKey}
80
85
  formGroup={false}
@@ -57,6 +57,11 @@
57
57
  "type": "string",
58
58
  "description": "Default value for the search input"
59
59
  },
60
+ "value": {
61
+ "type": "string",
62
+ "default": null,
63
+ "description": "Current search query. Takes precedence over defaultValue."
64
+ },
60
65
  "onSubmit": {
61
66
  "type": "string",
62
67
  "default": "",