@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
@@ -11,6 +11,7 @@ export interface ComboboxOption {
11
11
  }
12
12
 
13
13
  export interface ComboboxProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'onSelect' | 'defaultValue'> {
14
+ extraAttributes?: Record<string, unknown>;
14
15
  id: string;
15
16
  name: string;
16
17
  label: React.ReactNode;
@@ -19,6 +20,7 @@ export interface ComboboxProps extends Omit<React.SelectHTMLAttributes<HTMLSelec
19
20
  hint?: React.ReactNode;
20
21
  placeholder?: string;
21
22
  defaultValue?: string | null;
23
+ value?: string;
22
24
  error?: React.ReactNode;
23
25
  options?: ComboboxOption[];
24
26
  onSearch?: (value: string) => void;
@@ -44,12 +46,14 @@ export default function Combobox({
44
46
  hint = null,
45
47
  placeholder,
46
48
  defaultValue = null,
49
+ value,
47
50
  error = null,
48
51
  options = [],
49
52
  onSearch,
50
53
  onSelect,
51
54
  formGroup = true,
52
55
  className = '',
56
+ extraAttributes,
53
57
  ...props
54
58
  }: ComboboxProps) {
55
59
  const labelId = `${id}-label`;
@@ -81,6 +85,7 @@ export default function Combobox({
81
85
  {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}
82
86
 
83
87
  <div
88
+ {...extraAttributes}
84
89
  className={
85
90
  classNames(
86
91
  'usa-combo-box',
@@ -90,7 +95,7 @@ export default function Combobox({
90
95
  )
91
96
  }
92
97
  {...(placeholder ? { 'data-placeholder': placeholder } : {})}
93
- {...(defaultValue ? { 'data-default-value': defaultValue } : {})}
98
+ {...((value ?? defaultValue) ? { 'data-default-value': value ?? defaultValue } : {})}
94
99
  {...(onSearch ? { onInput: handleInput } : {})}
95
100
  >
96
101
  <select
@@ -1300,3 +1300,144 @@
1300
1300
  </select>
1301
1301
  </div>
1302
1302
  </div>
1303
+
1304
+ <h3 class="site-preview-heading">With Value</h3>
1305
+ <div class="usa-form-group usx-form-group">
1306
+ <label id="django-fruit-value-label" class="usa-label usx-label" for="django-fruit-value">
1307
+ Current fruit
1308
+ </label>
1309
+
1310
+ <div class="usa-combo-box usx-combo-box" data-default-value="peach">
1311
+ <select id="django-fruit-value" class="usa-select usx-select" name="fruit-value">
1312
+ <option value="">Select a fruit</option>
1313
+
1314
+ <option value="apple">Apple</option>
1315
+
1316
+ <option value="apricot">Apricot</option>
1317
+
1318
+ <option value="avocado">Avocado</option>
1319
+
1320
+ <option value="banana">Banana</option>
1321
+
1322
+ <option value="blackberry">Blackberry</option>
1323
+
1324
+ <option value="blood orange">Blood orange</option>
1325
+
1326
+ <option value="blueberry">Blueberry</option>
1327
+
1328
+ <option value="boysenberry">Boysenberry</option>
1329
+
1330
+ <option value="breadfruit">Breadfruit</option>
1331
+
1332
+ <option value="buddhas hand citron">Buddha&#x27;s hand citron</option>
1333
+
1334
+ <option value="cantaloupe">Cantaloupe</option>
1335
+
1336
+ <option value="clementine">Clementine</option>
1337
+
1338
+ <option value="crab apple">Crab apple</option>
1339
+
1340
+ <option value="currant">Currant</option>
1341
+
1342
+ <option value="cherry">Cherry</option>
1343
+
1344
+ <option value="custard apple">Custard apple</option>
1345
+
1346
+ <option value="coconut">Coconut</option>
1347
+
1348
+ <option value="cranberry">Cranberry</option>
1349
+
1350
+ <option value="date">Date</option>
1351
+
1352
+ <option value="dragonfruit">Dragonfruit</option>
1353
+
1354
+ <option value="durian">Durian</option>
1355
+
1356
+ <option value="elderberry">Elderberry</option>
1357
+
1358
+ <option value="fig">Fig</option>
1359
+
1360
+ <option value="gooseberry">Gooseberry</option>
1361
+
1362
+ <option value="grape">Grape</option>
1363
+
1364
+ <option value="grapefruit">Grapefruit</option>
1365
+
1366
+ <option value="guava">Guava</option>
1367
+
1368
+ <option value="honeydew melon">Honeydew melon</option>
1369
+
1370
+ <option value="jackfruit">Jackfruit</option>
1371
+
1372
+ <option value="kiwifruit">Kiwifruit</option>
1373
+
1374
+ <option value="kumquat">Kumquat</option>
1375
+
1376
+ <option value="lemon">Lemon</option>
1377
+
1378
+ <option value="lime">Lime</option>
1379
+
1380
+ <option value="lychee">Lychee</option>
1381
+
1382
+ <option value="mandarine">Mandarine</option>
1383
+
1384
+ <option value="mango">Mango</option>
1385
+
1386
+ <option value="mangosteen">Mangosteen</option>
1387
+
1388
+ <option value="marionberry">Marionberry</option>
1389
+
1390
+ <option value="nectarine">Nectarine</option>
1391
+
1392
+ <option value="orange">Orange</option>
1393
+
1394
+ <option value="papaya">Papaya</option>
1395
+
1396
+ <option value="passionfruit">Passionfruit</option>
1397
+
1398
+ <option value="peach">Peach</option>
1399
+
1400
+ <option value="pear">Pear</option>
1401
+
1402
+ <option value="persimmon">Persimmon</option>
1403
+
1404
+ <option value="plantain">Plantain</option>
1405
+
1406
+ <option value="plum">Plum</option>
1407
+
1408
+ <option value="pineapple">Pineapple</option>
1409
+
1410
+ <option value="pluot">Pluot</option>
1411
+
1412
+ <option value="pomegranate">Pomegranate</option>
1413
+
1414
+ <option value="pomelo">Pomelo</option>
1415
+
1416
+ <option value="quince">Quince</option>
1417
+
1418
+ <option value="raspberry">Raspberry</option>
1419
+
1420
+ <option value="rambutan">Rambutan</option>
1421
+
1422
+ <option value="soursop">Soursop</option>
1423
+
1424
+ <option value="starfruit">Starfruit</option>
1425
+
1426
+ <option value="strawberry">Strawberry</option>
1427
+
1428
+ <option value="tamarind">Tamarind</option>
1429
+
1430
+ <option value="tangelo">Tangelo</option>
1431
+
1432
+ <option value="tangerine">Tangerine</option>
1433
+
1434
+ <option value="ugli fruit">Ugli fruit</option>
1435
+
1436
+ <option value="watermelon">Watermelon</option>
1437
+
1438
+ <option value="white currant">White currant</option>
1439
+
1440
+ <option value="yuzu">Yuzu</option>
1441
+ </select>
1442
+ </div>
1443
+ </div>
@@ -13,7 +13,7 @@
13
13
  {% error_message id=id|add:"-error" %}{{ error }}{% enderror_message %}
14
14
  {% endif %}
15
15
 
16
- <div class="usa-combo-box usx-combo-box{% if error %} usx-combo-box--error{% endif %}{% if className %} {{ className }}{% endif %}"{% if placeholder %} data-placeholder="{{ placeholder }}"{% endif %}{% if defaultValue %} data-default-value="{{ defaultValue }}"{% endif %}>
16
+ <div class="usa-combo-box usx-combo-box{% if error %} usx-combo-box--error{% endif %}{% 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 %}{% if placeholder %} data-placeholder="{{ placeholder }}"{% endif %}{% if value is not None and value or value is None and defaultValue %} data-default-value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"{% endif %}>
17
17
  <select
18
18
  id="{{ id }}"
19
19
  class="usa-select usx-select"
@@ -40,7 +40,7 @@
40
40
  {% error_message id=id|add:"-error" %}{{ error }}{% enderror_message %}
41
41
  {% endif %}
42
42
 
43
- <div class="usa-combo-box usx-combo-box{% if error %} usx-combo-box--error{% endif %}{% if className %} {{ className }}{% endif %}"{% if placeholder %} data-placeholder="{{ placeholder }}"{% endif %}{% if defaultValue %} data-default-value="{{ defaultValue }}"{% endif %}>
43
+ <div class="usa-combo-box usx-combo-box{% if error %} usx-combo-box--error{% endif %}{% 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 %}{% if placeholder %} data-placeholder="{{ placeholder }}"{% endif %}{% if value is not None and value or value is None and defaultValue %} data-default-value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"{% endif %}>
44
44
  <select
45
45
  id="{{ id }}"
46
46
  class="usa-select usx-select"
@@ -712,3 +712,79 @@
712
712
  </select>
713
713
  </div>
714
714
  </div>
715
+
716
+ <h3 class="site-preview-heading">With Value</h3>
717
+ <div class="usa-form-group usx-form-group">
718
+ <label id="react-fruit-value-label" class="usa-label usx-label" for="react-fruit-value"
719
+ >Current fruit</label
720
+ >
721
+ <div class="usa-combo-box usx-combo-box" data-default-value="peach">
722
+ <select class="usa-select usx-select" id="react-fruit-value" name="fruit-value">
723
+ <option value="">Select a fruit</option>
724
+ <option value="apple">Apple</option>
725
+ <option value="apricot">Apricot</option>
726
+ <option value="avocado">Avocado</option>
727
+ <option value="banana">Banana</option>
728
+ <option value="blackberry">Blackberry</option>
729
+ <option value="blood orange">Blood orange</option>
730
+ <option value="blueberry">Blueberry</option>
731
+ <option value="boysenberry">Boysenberry</option>
732
+ <option value="breadfruit">Breadfruit</option>
733
+ <option value="buddhas hand citron">Buddha&#x27;s hand citron</option>
734
+ <option value="cantaloupe">Cantaloupe</option>
735
+ <option value="clementine">Clementine</option>
736
+ <option value="crab apple">Crab apple</option>
737
+ <option value="currant">Currant</option>
738
+ <option value="cherry">Cherry</option>
739
+ <option value="custard apple">Custard apple</option>
740
+ <option value="coconut">Coconut</option>
741
+ <option value="cranberry">Cranberry</option>
742
+ <option value="date">Date</option>
743
+ <option value="dragonfruit">Dragonfruit</option>
744
+ <option value="durian">Durian</option>
745
+ <option value="elderberry">Elderberry</option>
746
+ <option value="fig">Fig</option>
747
+ <option value="gooseberry">Gooseberry</option>
748
+ <option value="grape">Grape</option>
749
+ <option value="grapefruit">Grapefruit</option>
750
+ <option value="guava">Guava</option>
751
+ <option value="honeydew melon">Honeydew melon</option>
752
+ <option value="jackfruit">Jackfruit</option>
753
+ <option value="kiwifruit">Kiwifruit</option>
754
+ <option value="kumquat">Kumquat</option>
755
+ <option value="lemon">Lemon</option>
756
+ <option value="lime">Lime</option>
757
+ <option value="lychee">Lychee</option>
758
+ <option value="mandarine">Mandarine</option>
759
+ <option value="mango">Mango</option>
760
+ <option value="mangosteen">Mangosteen</option>
761
+ <option value="marionberry">Marionberry</option>
762
+ <option value="nectarine">Nectarine</option>
763
+ <option value="orange">Orange</option>
764
+ <option value="papaya">Papaya</option>
765
+ <option value="passionfruit">Passionfruit</option>
766
+ <option value="peach">Peach</option>
767
+ <option value="pear">Pear</option>
768
+ <option value="persimmon">Persimmon</option>
769
+ <option value="plantain">Plantain</option>
770
+ <option value="plum">Plum</option>
771
+ <option value="pineapple">Pineapple</option>
772
+ <option value="pluot">Pluot</option>
773
+ <option value="pomegranate">Pomegranate</option>
774
+ <option value="pomelo">Pomelo</option>
775
+ <option value="quince">Quince</option>
776
+ <option value="raspberry">Raspberry</option>
777
+ <option value="rambutan">Rambutan</option>
778
+ <option value="soursop">Soursop</option>
779
+ <option value="starfruit">Starfruit</option>
780
+ <option value="strawberry">Strawberry</option>
781
+ <option value="tamarind">Tamarind</option>
782
+ <option value="tangelo">Tangelo</option>
783
+ <option value="tangerine">Tangerine</option>
784
+ <option value="ugli fruit">Ugli fruit</option>
785
+ <option value="watermelon">Watermelon</option>
786
+ <option value="white currant">White currant</option>
787
+ <option value="yuzu">Yuzu</option>
788
+ </select>
789
+ </div>
790
+ </div>
@@ -270,6 +270,10 @@
270
270
  ]
271
271
  },
272
272
  "props": {
273
+ "extraAttributes": {
274
+ "type": "object",
275
+ "description": "Additional attributes on the USWDS enhancement target."
276
+ },
273
277
  "id": {
274
278
  "type": "string",
275
279
  "description": "id attribute for the select"
@@ -304,6 +308,11 @@
304
308
  "type": "string",
305
309
  "description": "Default selected value"
306
310
  },
311
+ "value": {
312
+ "type": "string",
313
+ "default": null,
314
+ "description": "Option used to initialize the USWDS combo box, taking precedence over defaultValue."
315
+ },
307
316
  "error": {
308
317
  "type": "slot",
309
318
  "description": "Error message (renders aria-describedby and error class)"
@@ -64,6 +64,7 @@ export interface TableProps extends Omit<React.TableHTMLAttributes<HTMLTableElem
64
64
  loading?: boolean;
65
65
  placeholder?: React.ReactNode;
66
66
  children?: React.ReactNode;
67
+ extraAttributes?: Record<string, unknown>;
67
68
  }
68
69
 
69
70
  /** Data-driven table with a compound markup escape hatch. */
@@ -101,6 +102,7 @@ function DataTable({
101
102
  placeholder = 'No rows to display',
102
103
  className = '',
103
104
  children,
105
+ extraAttributes,
104
106
  ...props
105
107
  }: TableProps) {
106
108
  const generatedId = useId();
@@ -156,7 +158,8 @@ function DataTable({
156
158
  data-page-size={paginate ? pageSize : undefined}
157
159
  data-initial-sort-key={initialSort?.direction ? initialSort.key || undefined : undefined}
158
160
  data-initial-sort-direction={initialSort?.direction || undefined}
159
- data-total-count={pageConfig.totalCount} data-infinite={infinite || undefined}>
161
+ data-total-count={pageConfig.totalCount} data-infinite={infinite || undefined}
162
+ {...extraAttributes}>
160
163
  {searchable && <div className="usx-data-table__toolbar">
161
164
  <Input id={`${id}-search`} label="Search" formGroup={false} placeholder={searchPlaceholder} />
162
165
  </div>}
@@ -370,6 +370,10 @@
370
370
  "type": "boolean",
371
371
  "default": false,
372
372
  "description": "Make rows keyboard and pointer activatable; the JS initializer emits usx:data-table:row-activate."
373
+ },
374
+ "extraAttributes": {
375
+ "type": "object",
376
+ "description": "Additional HTML attributes on the table shell."
373
377
  }
374
378
  }
375
379
  }
@@ -1,5 +1,5 @@
1
1
  {% load components %}
2
- <div class="usx-data-table-shell" data-usx-data-table="true"{% if searchable %} data-searchable="true"{% endif %}{% if paginate %} data-paginate="true" data-page-size="{{ paginate.pageSize|default:10 }}"{% endif %}{% if sort.key and sort.direction %} data-initial-sort-key="{{ sort.key }}" data-initial-sort-direction="{{ sort.direction }}"{% endif %}>
2
+ <div class="usx-data-table-shell" data-usx-data-table="true"{% if searchable %} data-searchable="true"{% endif %}{% if paginate %} data-paginate="true" data-page-size="{{ paginate.pageSize|default:10 }}"{% endif %}{% if sort.key and sort.direction %} data-initial-sort-key="{{ sort.key }}" data-initial-sort-direction="{{ sort.direction }}"{% 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 %}>
3
3
  {% if searchable %}<div class="usx-data-table__toolbar">{% input id=id|add:'-search' label='Search' placeholder=searchPlaceholder|default:'Search table' formGroup=False %}{% endinput %}</div>{% endif %}
4
4
  {% if scrollable or height %}<div class="usx-data-table-container--scrollable" tabindex="0"{% if height %} style="max-height: {{ height }}; overflow: auto"{% endif %}>{% endif %}
5
5
  <table{% if id %} id="{{ id }}"{% endif %} class="usa-table usx-data-table{% if striped %} usx-data-table--striped{% endif %}{% if borderless %} usx-data-table--borderless{% endif %}{% if compact %} usx-data-table--compact{% endif %}{% if stickyHeader %} usx-data-table--sticky-header{% endif %}{% if responsive == 'stack' %} usx-data-table--stacked{% elif responsive == 'stack-header' %} usx-data-table--stacked-header{% endif %}{% if stickyFirstColumn %} usx-data-table--sticky-first-col{% endif %}{% if className %} {{ className }}{% endif %}">
@@ -6,10 +6,12 @@ import ErrorMessage from '../error-message/ErrorMessage';
6
6
  import FormGroup from '../form-group/FormGroup';
7
7
 
8
8
  export interface DatePickerProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> {
9
+ extraAttributes?: Record<string, unknown>;
9
10
  label?: React.ReactNode;
10
11
  hint?: React.ReactNode;
11
12
  error?: React.ReactNode;
12
13
  defaultValue?: string | null;
14
+ value?: string;
13
15
  minDate?: string | null;
14
16
  maxDate?: string | null;
15
17
  rangeDate?: string | null;
@@ -25,11 +27,13 @@ export default function DatePicker({
25
27
  disabled = false,
26
28
  required = false,
27
29
  defaultValue = null,
30
+ value,
28
31
  minDate = null,
29
32
  maxDate = null,
30
33
  rangeDate = null,
31
34
  formGroup = true,
32
35
  className = '',
36
+ extraAttributes,
33
37
  ...props
34
38
  }: DatePickerProps) {
35
39
  const labelId = `${id}-label`;
@@ -47,8 +51,9 @@ export default function DatePicker({
47
51
  {hint && <Hint id={hintId}>{hint}</Hint>}
48
52
  {error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}
49
53
  <div
54
+ {...extraAttributes}
50
55
  className={classNames('usa-date-picker', 'usx-date-picker', className)}
51
- {...(defaultValue ? { 'data-default-value': defaultValue } : {})}
56
+ {...((value ?? defaultValue) ? { 'data-default-value': value ?? defaultValue } : {})}
52
57
  {...(minDate ? { 'data-min-date': minDate } : {})}
53
58
  {...(maxDate ? { 'data-max-date': maxDate } : {})}
54
59
  {...(rangeDate ? { 'data-range-date': rangeDate } : {})}
@@ -9,6 +9,10 @@
9
9
  "hint": "mm/dd/yyyy"
10
10
  },
11
11
  "props": {
12
+ "extraAttributes": {
13
+ "type": "object",
14
+ "description": "Additional attributes on the USWDS enhancement target."
15
+ },
12
16
  "id": {
13
17
  "type": "string",
14
18
  "default": "appointment-date",
@@ -45,6 +49,11 @@
45
49
  "type": "string",
46
50
  "description": "Initial date (yyyy-mm-dd). Sets data-default-value on the usa-date-picker wrapper."
47
51
  },
52
+ "value": {
53
+ "type": "string",
54
+ "default": null,
55
+ "description": "Date used to initialize the USWDS date picker, taking precedence over defaultValue."
56
+ },
48
57
  "minDate": {
49
58
  "type": "string",
50
59
  "description": "Earliest selectable date (yyyy-mm-dd). Sets data-min-date on the wrapper."
@@ -148,3 +148,26 @@
148
148
  />
149
149
  </div>
150
150
  </div>
151
+
152
+ <h3 class="site-preview-heading">With Value</h3>
153
+ <div class="usa-form-group usx-form-group">
154
+ <label
155
+ id="django-date-picker-value-label"
156
+ class="usa-label usx-label"
157
+ for="django-date-picker-value"
158
+ >
159
+ Current date
160
+ </label>
161
+
162
+ <span class="usa-hint usx-hint" id="django-date-picker-value-hint">mm/dd/yyyy</span>
163
+
164
+ <div class="usa-date-picker usx-date-picker" data-default-value="2021-06-20">
165
+ <input
166
+ class="usa-input usx-input"
167
+ id="django-date-picker-value"
168
+ name="date-picker-value"
169
+ aria-labelledby="django-date-picker-value-label"
170
+ aria-describedby="django-date-picker-value-hint"
171
+ />
172
+ </div>
173
+ </div>
@@ -16,8 +16,8 @@
16
16
  {% endif %}
17
17
 
18
18
  <div
19
- class="usa-date-picker usx-date-picker{% if className %} {{ className }}{% endif %}"
20
- {% if defaultValue %} data-default-value="{{ defaultValue }}"{% endif %}
19
+ class="usa-date-picker usx-date-picker{% 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 %}
20
+ {% if value is not None and value or value is None and defaultValue %} data-default-value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"{% endif %}
21
21
  {% if minDate %} data-min-date="{{ minDate }}"{% endif %}
22
22
  {% if maxDate %} data-max-date="{{ maxDate }}"{% endif %}
23
23
  {% if rangeDate %} data-range-date="{{ rangeDate }}"{% endif %}
@@ -47,8 +47,8 @@
47
47
  {% endif %}
48
48
 
49
49
  <div
50
- class="usa-date-picker usx-date-picker{% if className %} {{ className }}{% endif %}"
51
- {% if defaultValue %} data-default-value="{{ defaultValue }}"{% endif %}
50
+ class="usa-date-picker usx-date-picker{% 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
+ {% if value is not None and value or value is None and defaultValue %} data-default-value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"{% endif %}
52
52
  {% if minDate %} data-min-date="{{ minDate }}"{% endif %}
53
53
  {% if maxDate %} data-max-date="{{ maxDate }}"{% endif %}
54
54
  {% if rangeDate %} data-range-date="{{ rangeDate }}"{% endif %}
@@ -120,3 +120,22 @@
120
120
  />
121
121
  </div>
122
122
  </div>
123
+
124
+ <h3 class="site-preview-heading">With Value</h3>
125
+ <div class="usa-form-group usx-form-group">
126
+ <label
127
+ id="react-date-picker-value-label"
128
+ class="usa-label usx-label"
129
+ for="react-date-picker-value"
130
+ >Current date</label
131
+ ><span class="usa-hint usx-hint" id="react-date-picker-value-hint">mm/dd/yyyy</span>
132
+ <div class="usa-date-picker usx-date-picker" data-default-value="2021-06-20">
133
+ <input
134
+ class="usa-input usx-input"
135
+ id="react-date-picker-value"
136
+ name="date-picker-value"
137
+ aria-labelledby="react-date-picker-value-label"
138
+ aria-describedby="react-date-picker-value-hint"
139
+ />
140
+ </div>
141
+ </div>
@@ -6,6 +6,7 @@ import ErrorMessage from '../error-message/ErrorMessage';
6
6
  import FormGroup from '../form-group/FormGroup';
7
7
 
8
8
  export interface DateRangePickerProps {
9
+ extraAttributes?: Record<string, unknown>;
9
10
  startId?: string;
10
11
  endId?: string;
11
12
  startName?: string;
@@ -20,6 +21,8 @@ export interface DateRangePickerProps {
20
21
  required?: boolean;
21
22
  defaultStartDate?: string | null;
22
23
  defaultEndDate?: string | null;
24
+ startDate?: string | null;
25
+ endDate?: string | null;
23
26
  minDate?: string | null;
24
27
  maxDate?: string | null;
25
28
  className?: string;
@@ -40,9 +43,12 @@ export default function DateRangePicker({
40
43
  required = false,
41
44
  defaultStartDate = null,
42
45
  defaultEndDate = null,
46
+ startDate,
47
+ endDate,
43
48
  minDate = null,
44
49
  maxDate = null,
45
50
  className = '',
51
+ extraAttributes,
46
52
  }: DateRangePickerProps) {
47
53
  const startLabelId = `${startId}-label`;
48
54
  const startHintId = startHint ? `${startId}-hint` : undefined;
@@ -56,6 +62,7 @@ export default function DateRangePicker({
56
62
 
57
63
  return (
58
64
  <div
65
+ {...extraAttributes}
59
66
  className={classNames('usa-date-range-picker', 'usx-date-range-picker', className)}
60
67
  {...(minDate ? { 'data-min-date': minDate } : {})}
61
68
  {...(maxDate ? { 'data-max-date': maxDate } : {})}
@@ -69,8 +76,9 @@ export default function DateRangePicker({
69
76
  {startHint && <Hint id={startHintId}>{startHint}</Hint>}
70
77
  {startError && <ErrorMessage id={startErrorId}>{startError}</ErrorMessage>}
71
78
  <div
79
+ data-enhanced={extraAttributes?.['data-enhanced'] === 'true' ? 'true' : undefined}
72
80
  className="usa-date-picker usx-date-picker"
73
- {...(defaultStartDate ? { 'data-default-value': defaultStartDate } : {})}
81
+ {...((startDate ?? defaultStartDate) ? { 'data-default-value': startDate ?? defaultStartDate } : {})}
74
82
  >
75
83
  <input
76
84
  className="usa-input usx-input"
@@ -93,8 +101,9 @@ export default function DateRangePicker({
93
101
  {endHint && <Hint id={endHintId}>{endHint}</Hint>}
94
102
  {endError && <ErrorMessage id={endErrorId}>{endError}</ErrorMessage>}
95
103
  <div
104
+ data-enhanced={extraAttributes?.['data-enhanced'] === 'true' ? 'true' : undefined}
96
105
  className="usa-date-picker usx-date-picker"
97
- {...(defaultEndDate ? { 'data-default-value': defaultEndDate } : {})}
106
+ {...((endDate ?? defaultEndDate) ? { 'data-default-value': endDate ?? defaultEndDate } : {})}
98
107
  >
99
108
  <input
100
109
  className="usa-input usx-input"
@@ -11,6 +11,10 @@
11
11
  "endHint": "mm/dd/yyyy"
12
12
  },
13
13
  "props": {
14
+ "extraAttributes": {
15
+ "type": "object",
16
+ "description": "Additional attributes on the USWDS enhancement target."
17
+ },
14
18
  "startId": {
15
19
  "type": "string",
16
20
  "default": "event-date-start",
@@ -71,10 +75,20 @@
71
75
  "type": "string",
72
76
  "description": "Initial start date (yyyy-mm-dd). Sets data-default-value on the start usa-date-picker wrapper."
73
77
  },
78
+ "startDate": {
79
+ "type": "string",
80
+ "default": null,
81
+ "description": "Start date used to initialize the USWDS date picker, taking precedence over defaultStartDate."
82
+ },
74
83
  "defaultEndDate": {
75
84
  "type": "string",
76
85
  "description": "Initial end date (yyyy-mm-dd). Sets data-default-value on the end usa-date-picker wrapper."
77
86
  },
87
+ "endDate": {
88
+ "type": "string",
89
+ "default": null,
90
+ "description": "End date used to initialize the USWDS date picker, taking precedence over defaultEndDate."
91
+ },
78
92
  "minDate": {
79
93
  "type": "string",
80
94
  "description": "Earliest selectable date (yyyy-mm-dd). Sets data-min-date on the usa-date-range-picker wrapper."
@@ -299,3 +299,50 @@
299
299
  </div>
300
300
  </div>
301
301
  </div>
302
+
303
+ <h3 class="site-preview-heading">With Values</h3>
304
+ <div class="usa-date-range-picker usx-date-range-picker">
305
+ <div class="usa-form-group usx-form-group">
306
+ <label
307
+ id="django-event-date-value-start-label"
308
+ class="usa-label usx-label"
309
+ for="django-event-date-value-start"
310
+ >
311
+ Event start date
312
+ </label>
313
+
314
+ <span class="usa-hint usx-hint" id="django-event-date-value-start-hint">mm/dd/yyyy</span>
315
+
316
+ <div class="usa-date-picker usx-date-picker" data-default-value="2021-06-20">
317
+ <input
318
+ class="usa-input usx-input"
319
+ id="django-event-date-value-start"
320
+ name="event-date-value-start"
321
+ aria-labelledby="django-event-date-value-start-label"
322
+ aria-describedby="django-event-date-value-start-hint"
323
+ />
324
+ </div>
325
+ </div>
326
+
327
+ <div class="usa-form-group usx-form-group">
328
+ <label
329
+ id="django-event-date-value-end-label"
330
+ class="usa-label usx-label"
331
+ for="django-event-date-value-end"
332
+ >
333
+ Event end date
334
+ </label>
335
+
336
+ <span class="usa-hint usx-hint" id="django-event-date-value-end-hint">mm/dd/yyyy</span>
337
+
338
+ <div class="usa-date-picker usx-date-picker" data-default-value="2021-06-27">
339
+ <input
340
+ class="usa-input usx-input"
341
+ id="django-event-date-value-end"
342
+ name="event-date-value-end"
343
+ aria-labelledby="django-event-date-value-end-label"
344
+ aria-describedby="django-event-date-value-end-hint"
345
+ />
346
+ </div>
347
+ </div>
348
+ </div>