@solexllc/usx-react 0.9.0 → 0.11.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 (145) hide show
  1. package/README.md +6 -5
  2. package/dist/index.cjs +245 -162
  3. package/dist/index.js +246 -163
  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/code/code.django-snapshot.html +4 -6
  26. package/src/components/code/code.html +2 -2
  27. package/src/components/code/code.react-snapshot.html +2 -4
  28. package/src/components/combobox/Combobox.tsx +6 -1
  29. package/src/components/combobox/combobox.django-snapshot.html +141 -0
  30. package/src/components/combobox/combobox.django.html +2 -2
  31. package/src/components/combobox/combobox.react-snapshot.html +76 -0
  32. package/src/components/combobox/config.json +9 -0
  33. package/src/components/data-table/DataTable.tsx +4 -1
  34. package/src/components/data-table/config.json +4 -0
  35. package/src/components/data-table/data-table.django.html +1 -1
  36. package/src/components/date-picker/DatePicker.tsx +6 -1
  37. package/src/components/date-picker/config.json +9 -0
  38. package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
  39. package/src/components/date-picker/date-picker.django.html +4 -4
  40. package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
  41. package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
  42. package/src/components/date-range-picker/config.json +14 -0
  43. package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
  44. package/src/components/date-range-picker/date-range-picker.django.html +5 -5
  45. package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
  46. package/src/components/drawer/Drawer.tsx +3 -1
  47. package/src/components/drawer/config.json +4 -0
  48. package/src/components/drawer/drawer.django.html +1 -1
  49. package/src/components/file-input/FileInput.tsx +7 -2
  50. package/src/components/file-input/_contents.django.html +2 -1
  51. package/src/components/file-input/config.json +4 -0
  52. package/src/components/header/Header.tsx +15 -9
  53. package/src/components/header/config.json +1 -0
  54. package/src/components/header/header.django-snapshot.html +29 -7
  55. package/src/components/header/header.django.html +8 -4
  56. package/src/components/header/header.html +21 -11
  57. package/src/components/header/header.react-snapshot.html +23 -6
  58. package/src/components/icon-list/IconList.tsx +10 -2
  59. package/src/components/icon-list/config.json +5 -1
  60. package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
  61. package/src/components/icon-list/icon-list.django.html +2 -0
  62. package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
  63. package/src/components/in-page-nav/InPageNav.tsx +3 -0
  64. package/src/components/in-page-nav/config.json +1 -0
  65. package/src/components/in-page-nav/in-page-nav.django.html +1 -1
  66. package/src/components/input/Input.tsx +3 -0
  67. package/src/components/input/config.json +10 -0
  68. package/src/components/input/input.django-snapshot.html +24 -0
  69. package/src/components/input/input.django.html +4 -4
  70. package/src/components/input/input.react-snapshot.html +22 -0
  71. package/src/components/language-selector/LanguageSelector.tsx +10 -5
  72. package/src/components/language-selector/config.json +1 -0
  73. package/src/components/language-selector/language-selector.django.html +2 -2
  74. package/src/components/layout/Layout.tsx +3 -1
  75. package/src/components/layout/config.json +4 -0
  76. package/src/components/layout/layout.django.html +1 -1
  77. package/src/components/list/List.tsx +10 -2
  78. package/src/components/list/config.json +5 -1
  79. package/src/components/list/list.django-snapshot.html +26 -0
  80. package/src/components/list/list.django.html +2 -0
  81. package/src/components/list/list.html +20 -0
  82. package/src/components/list/list.react-snapshot.html +20 -0
  83. package/src/components/memorable-date/MemorableDate.tsx +18 -3
  84. package/src/components/memorable-date/config.json +15 -0
  85. package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
  86. package/src/components/memorable-date/memorable-date.django.html +14 -14
  87. package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
  88. package/src/components/modal/Modal.tsx +3 -0
  89. package/src/components/modal/config.json +1 -0
  90. package/src/components/modal/modal.django.html +1 -1
  91. package/src/components/page/Page.tsx +16 -0
  92. package/src/components/page/config.json +18 -1
  93. package/src/components/page/page.django-snapshot.html +74 -0
  94. package/src/components/page/page.django.html +8 -0
  95. package/src/components/page/page.html +60 -0
  96. package/src/components/page/page.react-snapshot.html +60 -0
  97. package/src/components/popover/Popover.tsx +3 -0
  98. package/src/components/popover/config.json +4 -0
  99. package/src/components/popover/popover.django-snapshot.html +30 -0
  100. package/src/components/popover/popover.django.html +1 -0
  101. package/src/components/radio-buttons/RadioButtons.tsx +5 -1
  102. package/src/components/radio-buttons/radio-buttons.django-snapshot.html +65 -0
  103. package/src/components/radio-buttons/radio-buttons.django.html +1 -1
  104. package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
  105. package/src/components/range-slider/RangeSlider.tsx +4 -2
  106. package/src/components/range-slider/config.json +1 -0
  107. package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
  108. package/src/components/range-slider/range-slider.django.html +4 -4
  109. package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
  110. package/src/components/search/Search.tsx +6 -1
  111. package/src/components/search/config.json +5 -0
  112. package/src/components/search/search.django-snapshot.html +683 -563
  113. package/src/components/search/search.django.html +1 -1
  114. package/src/components/search/search.react-snapshot.html +25 -0
  115. package/src/components/select/Select.tsx +3 -1
  116. package/src/components/select/config.json +5 -0
  117. package/src/components/select/select.django-snapshot.html +15 -0
  118. package/src/components/select/select.django.html +2 -2
  119. package/src/components/select/select.react-snapshot.html +11 -0
  120. package/src/components/switch/Switch.tsx +13 -70
  121. package/src/components/switch/config.json +60 -23
  122. package/src/components/switch/switch.django-snapshot.html +507 -56
  123. package/src/components/switch/switch.django.html +23 -26
  124. package/src/components/switch/switch.html +425 -33
  125. package/src/components/switch/switch.react-snapshot.html +447 -58
  126. package/src/components/table/Table.tsx +3 -1
  127. package/src/components/table/config.json +1 -0
  128. package/src/components/table/table.django.html +1 -1
  129. package/src/components/text-area/TextArea.tsx +3 -1
  130. package/src/components/text-area/config.json +5 -0
  131. package/src/components/text-area/text-area.django-snapshot.html +18 -0
  132. package/src/components/text-area/text-area.django.html +4 -4
  133. package/src/components/text-area/text-area.react-snapshot.html +16 -0
  134. package/src/components/theme-picker/ThemePicker.tsx +97 -52
  135. package/src/components/theme-picker/config.json +21 -5
  136. package/src/components/theme-picker/theme-picker-select.django.html +7 -0
  137. package/src/components/theme-picker/theme-picker.django-snapshot.html +158 -14
  138. package/src/components/theme-picker/theme-picker.django.html +22 -24
  139. package/src/components/theme-picker/theme-picker.html +86 -56
  140. package/src/components/theme-picker/theme-picker.react-snapshot.html +120 -12
  141. package/src/components/time-picker/TimePicker.tsx +6 -1
  142. package/src/components/time-picker/config.json +9 -0
  143. package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
  144. package/src/components/time-picker/time-picker.django.html +4 -4
  145. package/src/components/time-picker/time-picker.react-snapshot.html +22 -0
@@ -106,7 +106,7 @@
106
106
  <div class="usx-mockup-code__content">
107
107
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
108
108
 
109
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
109
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
110
110
 
111
111
  <pre
112
112
  data-prefix="3"
@@ -127,7 +127,7 @@
127
127
  class="usa-button usx-button usx-button--ghost usx-copy"
128
128
  onclick="
129
129
  navigator.clipboard.writeText(
130
- '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022 tabIndex\u003D{\u002D1}\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
130
+ '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
131
131
  )
132
132
  "
133
133
  >
@@ -157,9 +157,7 @@
157
157
  <div class="usx-mockup-code__content">
158
158
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
159
159
 
160
- <pre
161
- data-prefix="2"
162
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
160
+ <pre data-prefix="2"><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
163
161
 
164
162
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
165
163
 
@@ -178,7 +176,7 @@
178
176
  class="usa-button usx-button usx-button--ghost usx-copy"
179
177
  onclick="
180
178
  navigator.clipboard.writeText(
181
- '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022 tabIndex\u003D{\u002D1}\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
179
+ '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
182
180
  )
183
181
  "
184
182
  >
@@ -88,7 +88,7 @@
88
88
  <div class="usx-mockup-code">
89
89
  <div class="usx-mockup-code__content">
90
90
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
91
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
91
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
92
92
  <pre
93
93
  data-prefix="3"
94
94
  ><code> &lt;Section title=&quot;Contact information&quot;&gt;</code></pre>
@@ -129,7 +129,7 @@
129
129
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
130
130
  <pre
131
131
  data-prefix="2"
132
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
132
+ ><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
133
133
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
134
134
  <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
135
135
  <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>
@@ -81,7 +81,7 @@
81
81
  <div class="usx-mockup-code">
82
82
  <div class="usx-mockup-code__content">
83
83
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
84
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
84
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
85
85
  <pre
86
86
  data-prefix="3"
87
87
  ><code> &lt;Section title=&quot;Contact information&quot;&gt;</code></pre>
@@ -113,9 +113,7 @@
113
113
  <div class="usx-mockup-code">
114
114
  <div class="usx-mockup-code__content">
115
115
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
116
- <pre
117
- data-prefix="2"
118
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
116
+ <pre data-prefix="2"><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
119
117
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
120
118
  <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
121
119
  <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>
@@ -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"