@solexllc/usx-react 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +16 -0
  2. package/dist/index.cjs +3231 -3270
  3. package/dist/index.js +3232 -3271
  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 +17 -13
  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 +10 -1
  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 +180 -0
  31. package/src/components/data-table/README.md +42 -0
  32. package/src/components/data-table/TableBody.tsx +123 -0
  33. package/src/components/{table → data-table}/TableCell.tsx +6 -3
  34. package/src/components/data-table/TableContext.tsx +49 -0
  35. package/src/components/{table → data-table}/TableFoot.tsx +8 -7
  36. package/src/components/data-table/TableGroup.tsx +62 -0
  37. package/src/components/data-table/TableHead.tsx +126 -0
  38. package/src/components/data-table/TableRow.tsx +24 -0
  39. package/src/components/data-table/cells.ts +49 -0
  40. package/src/components/data-table/columns.ts +15 -0
  41. package/src/components/data-table/config.json +379 -0
  42. package/src/components/data-table/data-table.django-snapshot.html +13560 -0
  43. package/src/components/data-table/data-table.django.html +13 -0
  44. package/src/components/data-table/data-table.html +34 -0
  45. package/src/components/data-table/data-table.react-snapshot.html +12033 -0
  46. package/src/components/{table → data-table}/table-body.django.html +12 -12
  47. package/src/components/{table → data-table}/table-foot.django.html +6 -6
  48. package/src/components/data-table/table-group.django.html +24 -0
  49. package/src/components/data-table/table-head.django.html +21 -0
  50. package/src/components/data-table/table-row.django.html +57 -0
  51. package/src/components/{table → data-table}/types.ts +48 -5
  52. package/src/components/date-picker/DatePicker.tsx +6 -1
  53. package/src/components/date-picker/config.json +9 -0
  54. package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
  55. package/src/components/date-picker/date-picker.django.html +4 -4
  56. package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
  57. package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
  58. package/src/components/date-range-picker/config.json +14 -0
  59. package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
  60. package/src/components/date-range-picker/date-range-picker.django.html +5 -5
  61. package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
  62. package/src/components/drawer/Drawer.tsx +3 -1
  63. package/src/components/drawer/config.json +4 -0
  64. package/src/components/drawer/drawer.django.html +1 -1
  65. package/src/components/file-input/FileInput.tsx +7 -2
  66. package/src/components/file-input/_contents.django.html +2 -1
  67. package/src/components/file-input/config.json +4 -0
  68. package/src/components/header/Header.tsx +15 -9
  69. package/src/components/header/config.json +1 -0
  70. package/src/components/header/header.django-snapshot.html +24 -0
  71. package/src/components/header/header.django.html +8 -4
  72. package/src/components/header/header.html +20 -0
  73. package/src/components/header/header.react-snapshot.html +20 -0
  74. package/src/components/in-page-nav/InPageNav.tsx +3 -0
  75. package/src/components/in-page-nav/config.json +1 -0
  76. package/src/components/in-page-nav/in-page-nav.django.html +1 -1
  77. package/src/components/input/Input.tsx +3 -0
  78. package/src/components/input/config.json +10 -0
  79. package/src/components/input/input.django-snapshot.html +24 -0
  80. package/src/components/input/input.django.html +4 -4
  81. package/src/components/input/input.react-snapshot.html +22 -0
  82. package/src/components/language-selector/LanguageSelector.tsx +10 -5
  83. package/src/components/language-selector/config.json +1 -0
  84. package/src/components/language-selector/language-selector.django.html +2 -2
  85. package/src/components/layout/Layout.tsx +3 -1
  86. package/src/components/layout/config.json +4 -0
  87. package/src/components/layout/layout.django.html +1 -1
  88. package/src/components/memorable-date/MemorableDate.tsx +18 -3
  89. package/src/components/memorable-date/config.json +15 -0
  90. package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
  91. package/src/components/memorable-date/memorable-date.django.html +14 -14
  92. package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
  93. package/src/components/modal/Modal.tsx +3 -0
  94. package/src/components/modal/config.json +1 -0
  95. package/src/components/modal/modal.django.html +1 -1
  96. package/src/components/pagination/Pagination.tsx +7 -1
  97. package/src/components/pagination/config.json +8 -0
  98. package/src/components/pagination/navigation/PaginationNavigation.tsx +10 -0
  99. package/src/components/pagination/step-options/PaginationStepOptions.tsx +3 -0
  100. package/src/components/popover/Popover.tsx +3 -0
  101. package/src/components/popover/config.json +4 -0
  102. package/src/components/popover/popover.django-snapshot.html +30 -0
  103. package/src/components/popover/popover.django.html +1 -0
  104. package/src/components/radio-buttons/RadioButtons.tsx +41 -27
  105. package/src/components/radio-buttons/config.json +19 -1
  106. package/src/components/radio-buttons/radio-buttons.django-snapshot.html +93 -60
  107. package/src/components/radio-buttons/radio-buttons.django.html +16 -28
  108. package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
  109. package/src/components/range-slider/RangeSlider.tsx +4 -2
  110. package/src/components/range-slider/config.json +1 -0
  111. package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
  112. package/src/components/range-slider/range-slider.django.html +4 -4
  113. package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
  114. package/src/components/search/Search.tsx +6 -1
  115. package/src/components/search/config.json +5 -0
  116. package/src/components/search/search.django-snapshot.html +683 -563
  117. package/src/components/search/search.django.html +1 -1
  118. package/src/components/search/search.react-snapshot.html +25 -0
  119. package/src/components/select/Select.tsx +3 -1
  120. package/src/components/select/config.json +5 -0
  121. package/src/components/select/select.django-snapshot.html +15 -0
  122. package/src/components/select/select.django.html +2 -2
  123. package/src/components/select/select.react-snapshot.html +11 -0
  124. package/src/components/switch/Switch.tsx +13 -70
  125. package/src/components/switch/config.json +60 -23
  126. package/src/components/switch/switch.django-snapshot.html +507 -56
  127. package/src/components/switch/switch.django.html +23 -26
  128. package/src/components/switch/switch.html +425 -33
  129. package/src/components/switch/switch.react-snapshot.html +447 -58
  130. package/src/components/table/Table.tsx +66 -334
  131. package/src/components/table/config.json +22 -339
  132. package/src/components/table/table.django-snapshot.html +712 -1482
  133. package/src/components/table/table.django.html +14 -59
  134. package/src/components/table/table.html +7 -2364
  135. package/src/components/table/table.react-snapshot.html +711 -2085
  136. package/src/components/text-area/TextArea.tsx +3 -1
  137. package/src/components/text-area/config.json +5 -0
  138. package/src/components/text-area/text-area.django-snapshot.html +18 -0
  139. package/src/components/text-area/text-area.django.html +4 -4
  140. package/src/components/text-area/text-area.react-snapshot.html +16 -0
  141. package/src/components/theme-picker/ThemePicker.tsx +3 -1
  142. package/src/components/theme-picker/config.json +14 -1
  143. package/src/components/theme-picker/theme-picker.django-snapshot.html +64 -0
  144. package/src/components/theme-picker/theme-picker.django.html +2 -2
  145. package/src/components/theme-picker/theme-picker.react-snapshot.html +52 -0
  146. package/src/components/time-picker/TimePicker.tsx +6 -1
  147. package/src/components/time-picker/config.json +9 -0
  148. package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
  149. package/src/components/time-picker/time-picker.django.html +4 -4
  150. package/src/components/time-picker/time-picker.react-snapshot.html +22 -0
  151. package/src/index.js +1 -0
  152. package/src/components/table/TableBody.tsx +0 -256
  153. package/src/components/table/TableContext.tsx +0 -87
  154. package/src/components/table/TableGroup.tsx +0 -69
  155. package/src/components/table/TableHead.tsx +0 -139
  156. package/src/components/table/TableRow.tsx +0 -56
  157. package/src/components/table/hooks/useRowDetails.ts +0 -34
  158. package/src/components/table/hooks/useTableGroups.ts +0 -61
  159. package/src/components/table/hooks/useTableSelect.ts +0 -82
  160. package/src/components/table/hooks/useTableSort.ts +0 -60
  161. package/src/components/table/table-group.django.html +0 -40
  162. package/src/components/table/table-head.django.html +0 -85
  163. package/src/components/table/table-row.django.html +0 -98
  164. package/src/components/table/table_helper.py +0 -298
  165. /package/src/components/{table → data-table}/table-detail-row.django.html +0 -0
@@ -1,9 +1,9 @@
1
1
  {# Django template for LanguageSelector #}
2
2
  {# Props: languages (array of {code,label,description,href,current,plain}), variant ('two'|'menu'), unstyled (bool), small (bool), label (string), id (string), navAriaLabel (string), className (string) #}
3
3
  {# For variant="two", mark exactly one language `current: true` — the other renders as the switch target. #}
4
- <nav aria-label="{{ navAriaLabel|default:'Language selection' }}" class="usx-language-selector{% if className %} {{ className }}{% endif %}">
4
+ <nav aria-label="{{ navAriaLabel|default:'Language selection' }}" class="usx-language-selector{% if className %} {{ className }}{% endif %}"{% if variant != 'menu' and extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}>
5
5
  {% if variant == 'menu' %}
6
- <div class="usa-language-container{% if small %} usa-language--small{% endif %}">
6
+ <div class="usa-language-container{% if small %} usa-language--small{% 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 %}>
7
7
  <ul class="usa-language__primary usa-accordion">
8
8
  <li class="usa-language__primary-item">
9
9
  <button
@@ -103,6 +103,7 @@ export type LayoutProps = {
103
103
  /** Optional callback fired when the layout is expanded or contracted. */
104
104
  onToggleExpanded?: (expanded: boolean) => void;
105
105
  className?: string;
106
+ extraAttributes?: Record<string, unknown>;
106
107
  } & HTMLAttributes<HTMLDivElement>;
107
108
 
108
109
  export default function Layout({
@@ -116,6 +117,7 @@ export default function Layout({
116
117
  expandable = false,
117
118
  onToggleExpanded,
118
119
  className = '',
120
+ extraAttributes,
119
121
  ...props
120
122
  }: LayoutProps) {
121
123
  const [expanded, setExpanded] = useState(false);
@@ -150,7 +152,7 @@ export default function Layout({
150
152
  ) : null;
151
153
 
152
154
  return (
153
- <div className={classes} {...props}>
155
+ <div className={classes} {...props} {...extraAttributes}>
154
156
  {variant === 'single-column' ? (
155
157
  <SingleColumnLayout expandButton={expandButton}>
156
158
  {children || content}
@@ -53,6 +53,10 @@
53
53
  "className": {
54
54
  "type": "string",
55
55
  "description": "Additional CSS classes"
56
+ },
57
+ "extraAttributes": {
58
+ "type": "object",
59
+ "description": "Additional HTML attributes on the layout root."
56
60
  }
57
61
  }
58
62
  }
@@ -11,7 +11,7 @@
11
11
  {% endbutton %}
12
12
  {% endif %}
13
13
  {% endfragment %}
14
- <div class="usx-layout{% if className %} {{ className }}{% endif %}">
14
+ <div class="usx-layout{% 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 %}>
15
15
  {% if variant == 'single-column' %}
16
16
  <div class="usx-layout__single-column">
17
17
  {{ expandButton }}
@@ -22,6 +22,12 @@ export interface MemorableDateProps {
22
22
  defaultMonth?: string;
23
23
  defaultDay?: string;
24
24
  defaultYear?: string;
25
+ month?: string;
26
+ day?: string;
27
+ year?: string;
28
+ onMonthChange?: React.ChangeEventHandler<HTMLSelectElement>;
29
+ onDayChange?: React.ChangeEventHandler<HTMLInputElement>;
30
+ onYearChange?: React.ChangeEventHandler<HTMLInputElement>;
25
31
  disabled?: boolean;
26
32
  ariaDisabled?: boolean;
27
33
  required?: boolean;
@@ -60,6 +66,12 @@ export default function MemorableDate({
60
66
  defaultMonth,
61
67
  defaultDay,
62
68
  defaultYear,
69
+ month,
70
+ day,
71
+ year,
72
+ onMonthChange,
73
+ onDayChange,
74
+ onYearChange,
63
75
  disabled = false,
64
76
  ariaDisabled = false,
65
77
  required = false,
@@ -101,7 +113,8 @@ export default function MemorableDate({
101
113
  label={monthLabel}
102
114
  options={MONTH_OPTIONS}
103
115
  placeholder="- Select -"
104
- defaultValue={defaultMonth}
116
+ {...(month !== undefined ? { value: month } : { defaultValue: defaultMonth })}
117
+ onChange={onMonthChange}
105
118
  required={required}
106
119
  aria-describedby={describedBy(monthHintId)}
107
120
  aria-invalid={hasError || undefined}
@@ -121,7 +134,8 @@ export default function MemorableDate({
121
134
  name={dayName || dayId}
122
135
  label={dayLabel}
123
136
  placeholder=""
124
- defaultValue={defaultDay}
137
+ {...(day !== undefined ? { value: day } : { defaultValue: defaultDay })}
138
+ onChange={onDayChange}
125
139
  maxLength={2}
126
140
  pattern="[0-9]*"
127
141
  inputMode="numeric"
@@ -143,7 +157,8 @@ export default function MemorableDate({
143
157
  name={yearName || yearId}
144
158
  label={yearLabel}
145
159
  placeholder=""
146
- defaultValue={defaultYear}
160
+ {...(year !== undefined ? { value: year } : { defaultValue: defaultYear })}
161
+ onChange={onYearChange}
147
162
  minLength={4}
148
163
  maxLength={4}
149
164
  pattern="[0-9]*"
@@ -67,14 +67,29 @@
67
67
  "type": "string",
68
68
  "description": "Initial selected month value (\"1\"-\"12\")."
69
69
  },
70
+ "month": {
71
+ "type": "string",
72
+ "default": null,
73
+ "description": "Current month selection. Takes precedence over defaultMonth."
74
+ },
70
75
  "defaultDay": {
71
76
  "type": "string",
72
77
  "description": "Initial day value."
73
78
  },
79
+ "day": {
80
+ "type": "string",
81
+ "default": null,
82
+ "description": "Current day value. Takes precedence over defaultDay."
83
+ },
74
84
  "defaultYear": {
75
85
  "type": "string",
76
86
  "description": "Initial year value."
77
87
  },
88
+ "year": {
89
+ "type": "string",
90
+ "default": null,
91
+ "description": "Current year value. Takes precedence over defaultYear."
92
+ },
78
93
  "disabled": {
79
94
  "type": "boolean",
80
95
  "default": false,
@@ -534,3 +534,85 @@
534
534
  </div>
535
535
  </fieldset>
536
536
  </div>
537
+
538
+ <h3 class="site-preview-heading">With Values</h3>
539
+ <div class="usa-form-group usx-form-group">
540
+ <fieldset class="usa-fieldset usx-fieldset">
541
+ <legend class="usa-legend usx-legend">Date of Birth</legend>
542
+
543
+ <span class="usa-hint usx-hint" aria-hidden="true" id="django-memorable-date-values-hint"
544
+ >Select a month. Enter 1 or 2 digits for the day and 4 digits for the year.</span
545
+ >
546
+ <div class="usa-memorable-date usx-memorable-date">
547
+ <div class="usa-form-group usx-form-group usa-form-group--month usa-form-group--select">
548
+ <label class="usa-label usx-label" for="django-memorable-date-values-month"> Month </label>
549
+
550
+ <select
551
+ class="usa-select usx-select"
552
+ id="django-memorable-date-values-month"
553
+ name="memorable-date-values-month"
554
+ aria-describedby="django-memorable-date-values-month-hint"
555
+ >
556
+ <option value="">- Select -</option>
557
+ <option value="1">January</option>
558
+ <option value="2">February</option>
559
+ <option value="3">March</option>
560
+ <option value="4">April</option>
561
+ <option value="5">May</option>
562
+ <option value="6" selected>June</option>
563
+ <option value="7">July</option>
564
+ <option value="8">August</option>
565
+ <option value="9">September</option>
566
+ <option value="10">October</option>
567
+ <option value="11">November</option>
568
+ <option value="12">December</option>
569
+ </select>
570
+
571
+ <span class="usa-hint usa-sr-only" id="django-memorable-date-values-month-hint"
572
+ >Select a month from the dropdown.</span
573
+ >
574
+ </div>
575
+
576
+ <div class="usa-form-group usx-form-group usa-form-group--day">
577
+ <label class="usa-label usx-label" for="django-memorable-date-values-day"> Day </label>
578
+
579
+ <input
580
+ class="usa-input usx-input"
581
+ id="django-memorable-date-values-day"
582
+ name="memorable-date-values-day"
583
+ value="20"
584
+ maxlength="2"
585
+ pattern="[0-9]*"
586
+ placeholder=""
587
+ inputmode="numeric"
588
+ aria-describedby="django-memorable-date-values-day-hint"
589
+ />
590
+
591
+ <span class="usa-hint usa-sr-only" id="django-memorable-date-values-day-hint"
592
+ >Enter 1 or 2 digits for the day.</span
593
+ >
594
+ </div>
595
+
596
+ <div class="usa-form-group usx-form-group usa-form-group--year">
597
+ <label class="usa-label usx-label" for="django-memorable-date-values-year"> Year </label>
598
+
599
+ <input
600
+ class="usa-input usx-input"
601
+ id="django-memorable-date-values-year"
602
+ name="memorable-date-values-year"
603
+ value="1990"
604
+ minlength="4"
605
+ maxlength="4"
606
+ pattern="[0-9]*"
607
+ placeholder=""
608
+ inputmode="numeric"
609
+ aria-describedby="django-memorable-date-values-year-hint"
610
+ />
611
+
612
+ <span class="usa-hint usa-sr-only" id="django-memorable-date-values-year-hint"
613
+ >Enter 4 digits for the year.</span
614
+ >
615
+ </div>
616
+ </div>
617
+ </fieldset>
618
+ </div>
@@ -20,18 +20,18 @@
20
20
  {% if required %}required{% endif %}
21
21
  >
22
22
  <option value="">- Select -</option>
23
- <option value="1" {% if defaultMonth == "1" %}selected{% endif %}>January</option>
24
- <option value="2" {% if defaultMonth == "2" %}selected{% endif %}>February</option>
25
- <option value="3" {% if defaultMonth == "3" %}selected{% endif %}>March</option>
26
- <option value="4" {% if defaultMonth == "4" %}selected{% endif %}>April</option>
27
- <option value="5" {% if defaultMonth == "5" %}selected{% endif %}>May</option>
28
- <option value="6" {% if defaultMonth == "6" %}selected{% endif %}>June</option>
29
- <option value="7" {% if defaultMonth == "7" %}selected{% endif %}>July</option>
30
- <option value="8" {% if defaultMonth == "8" %}selected{% endif %}>August</option>
31
- <option value="9" {% if defaultMonth == "9" %}selected{% endif %}>September</option>
32
- <option value="10" {% if defaultMonth == "10" %}selected{% endif %}>October</option>
33
- <option value="11" {% if defaultMonth == "11" %}selected{% endif %}>November</option>
34
- <option value="12" {% if defaultMonth == "12" %}selected{% endif %}>December</option>
23
+ <option value="1" {% if month is not None and month == "1" or month is None and defaultMonth == "1" %}selected{% endif %}>January</option>
24
+ <option value="2" {% if month is not None and month == "2" or month is None and defaultMonth == "2" %}selected{% endif %}>February</option>
25
+ <option value="3" {% if month is not None and month == "3" or month is None and defaultMonth == "3" %}selected{% endif %}>March</option>
26
+ <option value="4" {% if month is not None and month == "4" or month is None and defaultMonth == "4" %}selected{% endif %}>April</option>
27
+ <option value="5" {% if month is not None and month == "5" or month is None and defaultMonth == "5" %}selected{% endif %}>May</option>
28
+ <option value="6" {% if month is not None and month == "6" or month is None and defaultMonth == "6" %}selected{% endif %}>June</option>
29
+ <option value="7" {% if month is not None and month == "7" or month is None and defaultMonth == "7" %}selected{% endif %}>July</option>
30
+ <option value="8" {% if month is not None and month == "8" or month is None and defaultMonth == "8" %}selected{% endif %}>August</option>
31
+ <option value="9" {% if month is not None and month == "9" or month is None and defaultMonth == "9" %}selected{% endif %}>September</option>
32
+ <option value="10" {% if month is not None and month == "10" or month is None and defaultMonth == "10" %}selected{% endif %}>October</option>
33
+ <option value="11" {% if month is not None and month == "11" or month is None and defaultMonth == "11" %}selected{% endif %}>November</option>
34
+ <option value="12" {% if month is not None and month == "12" or month is None and defaultMonth == "12" %}selected{% endif %}>December</option>
35
35
  </select>
36
36
  {% if monthHint %}
37
37
  <span class="usa-hint usa-sr-only" id="{{ month_hint_id }}">{{ monthHint|default:"Select a month from the dropdown." }}</span>
@@ -44,7 +44,7 @@
44
44
  class="usa-input usx-input{% if error %} usa-input--error{% endif %}"
45
45
  id="{{ day_id }}"
46
46
  name="{{ dayName|default:day_id }}"
47
- value="{{ defaultDay|default:'' }}"
47
+ value="{% if day is not None %}{{ day }}{% else %}{{ defaultDay|default:'' }}{% endif %}"
48
48
  maxlength="2"
49
49
  pattern="[0-9]*"
50
50
  placeholder=""
@@ -65,7 +65,7 @@
65
65
  class="usa-input usx-input{% if error %} usa-input--error{% endif %}"
66
66
  id="{{ year_id }}"
67
67
  name="{{ yearName|default:year_id }}"
68
- value="{{ defaultYear|default:'' }}"
68
+ value="{% if year is not None %}{{ year }}{% else %}{{ defaultYear|default:'' }}{% endif %}"
69
69
  minlength="4"
70
70
  maxlength="4"
71
71
  pattern="[0-9]*"
@@ -435,3 +435,73 @@
435
435
  </div>
436
436
  </fieldset>
437
437
  </div>
438
+
439
+ <h3 class="site-preview-heading">With Values</h3>
440
+ <div class="usa-form-group usx-form-group">
441
+ <fieldset class="usa-fieldset usx-fieldset">
442
+ <legend class="usa-legend usx-legend">Date of Birth</legend>
443
+ <span class="usa-hint usx-hint" id="react-memorable-date-values-hint" aria-hidden="true"
444
+ >Select a month. Enter 1 or 2 digits for the day and 4 digits for the year.</span
445
+ >
446
+ <div class="usa-memorable-date usx-memorable-date">
447
+ <div class="usa-form-group usx-form-group usa-form-group--month usa-form-group--select">
448
+ <label class="usa-label usx-label" for="react-memorable-date-values-month">Month</label
449
+ ><select
450
+ id="react-memorable-date-values-month"
451
+ name="memorable-date-values-month"
452
+ class="usa-select usx-select"
453
+ aria-describedby="react-memorable-date-values-month-hint"
454
+ >
455
+ <option value="">- Select -</option>
456
+ <option value="1">January</option>
457
+ <option value="2">February</option>
458
+ <option value="3">March</option>
459
+ <option value="4">April</option>
460
+ <option value="5">May</option>
461
+ <option value="6" selected="">June</option>
462
+ <option value="7">July</option>
463
+ <option value="8">August</option>
464
+ <option value="9">September</option>
465
+ <option value="10">October</option>
466
+ <option value="11">November</option>
467
+ <option value="12">December</option></select
468
+ ><span class="usa-hint usa-sr-only" id="react-memorable-date-values-month-hint"
469
+ >Select a month from the dropdown.</span
470
+ >
471
+ </div>
472
+ <div class="usa-form-group usx-form-group usa-form-group--day">
473
+ <label class="usa-label usx-label" for="react-memorable-date-values-day">Day</label
474
+ ><input
475
+ id="react-memorable-date-values-day"
476
+ class="usa-input usx-input"
477
+ placeholder=""
478
+ aria-describedby="react-memorable-date-values-day-hint"
479
+ name="memorable-date-values-day"
480
+ maxlength="2"
481
+ pattern="[0-9]*"
482
+ inputmode="numeric"
483
+ value="20"
484
+ /><span class="usa-hint usa-sr-only" id="react-memorable-date-values-day-hint"
485
+ >Enter 1 or 2 digits for the day.</span
486
+ >
487
+ </div>
488
+ <div class="usa-form-group usx-form-group usa-form-group--year">
489
+ <label class="usa-label usx-label" for="react-memorable-date-values-year">Year</label
490
+ ><input
491
+ id="react-memorable-date-values-year"
492
+ class="usa-input usx-input"
493
+ placeholder=""
494
+ aria-describedby="react-memorable-date-values-year-hint"
495
+ name="memorable-date-values-year"
496
+ minlength="4"
497
+ maxlength="4"
498
+ pattern="[0-9]*"
499
+ inputmode="numeric"
500
+ value="1990"
501
+ /><span class="usa-hint usa-sr-only" id="react-memorable-date-values-year-hint"
502
+ >Enter 4 digits for the year.</span
503
+ >
504
+ </div>
505
+ </div>
506
+ </fieldset>
507
+ </div>
@@ -5,6 +5,7 @@ import Prose from '../prose/Prose';
5
5
  import ButtonGroup, { ButtonGroupProps } from '../button-group/ButtonGroup';
6
6
 
7
7
  export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
8
+ extraAttributes?: Record<string, unknown>;
8
9
  id?: string;
9
10
  heading?: string;
10
11
  description?: string;
@@ -27,6 +28,7 @@ export default function Modal({
27
28
  forceAction = false,
28
29
  className = '',
29
30
  children,
31
+ extraAttributes,
30
32
  ...props
31
33
  }: ModalProps) {
32
34
  const classes = classNames('usa-modal', 'usx-modal', {
@@ -42,6 +44,7 @@ export default function Modal({
42
44
  aria-describedby={`${id}-description`}
43
45
  {...(forceAction ? { 'data-force-action': true } : {})}
44
46
  {...props}
47
+ {...extraAttributes}
45
48
  >
46
49
  <div className="usa-modal__content">
47
50
  <div className="usa-modal__main">
@@ -25,6 +25,7 @@
25
25
  ]
26
26
  },
27
27
  "props": {
28
+ "extraAttributes": { "type": "object", "description": "Additional attributes on the USWDS enhancement target." },
28
29
  "id": {
29
30
  "type": "string",
30
31
  "default": "example-modal",
@@ -1,7 +1,7 @@
1
1
  {# Django template for Modal #}
2
2
  {% load usx_components %}
3
3
  <div
4
- class="usa-modal usx-modal{% if size == 'lg' %} usa-modal--lg{% elif size == 'lg-collapsed' %} usx-modal--lg-collapsed{% endif %}{% if className %} {{ className }}{% endif %}"
4
+ class="usa-modal usx-modal{% if size == 'lg' %} usa-modal--lg{% elif size == 'lg-collapsed' %} usx-modal--lg-collapsed{% 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 %}
5
5
  id="{{ id }}"
6
6
  aria-labelledby="{{ id }}-heading"
7
7
  aria-describedby="{{ id }}-description"
@@ -25,6 +25,8 @@ export interface PaginationProps {
25
25
  arrowsOnly?: boolean;
26
26
  pageUrlPrefix?: string;
27
27
  className?: string;
28
+ onPageChange?: (page: number) => void;
29
+ onPageSizeChange?: (size: number) => void;
28
30
  }
29
31
 
30
32
  export default function Pagination({
@@ -47,13 +49,15 @@ export default function Pagination({
47
49
  arrowsOnly = false,
48
50
  pageUrlPrefix,
49
51
  className = '',
52
+ onPageChange,
53
+ onPageSizeChange,
50
54
  }: PaginationProps) {
51
55
  const currentPage = page ?? initialPage;
52
56
  const pageSize = size ?? initialPageSize;
53
57
 
54
58
  const totalPages =
55
59
  totalItems !== undefined && !unbounded
56
- ? Math.ceil(totalItems / pageSize)
60
+ ? Math.max(1, Math.ceil(totalItems / pageSize))
57
61
  : undefined;
58
62
 
59
63
  // showSummary defaults to true when totalItems is provided
@@ -73,6 +77,7 @@ export default function Pagination({
73
77
  hideLinkText={hideLinkText}
74
78
  arrowsOnly={arrowsOnly}
75
79
  pageUrlPrefix={pageUrlPrefix}
80
+ onPageChange={onPageChange}
76
81
  />
77
82
  );
78
83
  const stepOptions = (
@@ -80,6 +85,7 @@ export default function Pagination({
80
85
  pageSize={pageSize}
81
86
  pageSizeOptions={pageSizeOptions}
82
87
  id={stepOptionsId}
88
+ onPageSizeChange={onPageSizeChange}
83
89
  />
84
90
  );
85
91
  const summary = typeof totalItems === 'number' ? (
@@ -175,6 +175,14 @@
175
175
  "default": "pagination-step-options",
176
176
  "description": "HTML id for the step options select element"
177
177
  },
178
+ "onPageChange": {
179
+ "type": "function",
180
+ "description": "React-only callback for client-side page navigation."
181
+ },
182
+ "onPageSizeChange": {
183
+ "type": "function",
184
+ "description": "React-only callback when the page size changes."
185
+ },
178
186
  "className": {
179
187
  "type": "string",
180
188
  "default": "",
@@ -14,6 +14,7 @@ export interface PaginationNavigationProps {
14
14
  arrowsOnly?: boolean;
15
15
  pageUrlPrefix?: string;
16
16
  className?: string;
17
+ onPageChange?: (page: number) => void;
17
18
  }
18
19
 
19
20
  export function getPageItems(currentPage: number, totalPages: number) {
@@ -76,6 +77,7 @@ export default function PaginationNavigation({
76
77
  arrowsOnly = false,
77
78
  pageUrlPrefix,
78
79
  className = '',
80
+ onPageChange,
79
81
  }: PaginationNavigationProps) {
80
82
  const unbounded = totalPages === undefined || totalPages === null;
81
83
  const items = unbounded
@@ -85,6 +87,11 @@ export default function PaginationNavigation({
85
87
  const isFirstPage = currentPage === 1;
86
88
  const isLastPage = !unbounded && currentPage === totalPages;
87
89
  const hrefFor = (page: number) => pageUrlPrefix ? `${pageUrlPrefix}${page}` : '#';
90
+ const goTo = (event: React.MouseEvent<HTMLAnchorElement>, page: number) => {
91
+ if (!onPageChange) return;
92
+ event.preventDefault();
93
+ if (page >= 1 && (unbounded || page <= totalPages!)) onPageChange(page);
94
+ };
88
95
 
89
96
  const navClasses = ClassNames(
90
97
  'usa-pagination',
@@ -112,6 +119,7 @@ export default function PaginationNavigation({
112
119
  }
113
120
  >
114
121
  <a
122
+ onClick={(event) => goTo(event, currentPage - 1)}
115
123
  href={isFirstPage ? '#' : hrefFor(currentPage - 1)}
116
124
  data-usx-pagination-page={currentPage - 1}
117
125
  className={
@@ -153,6 +161,7 @@ export default function PaginationNavigation({
153
161
  return (
154
162
  <li key={item.page} className="usa-pagination__item usa-pagination__page-no">
155
163
  <a
164
+ onClick={(event) => goTo(event, item.page)}
156
165
  href={hrefFor(item.page)}
157
166
  data-usx-pagination-page={item.page}
158
167
  className={
@@ -179,6 +188,7 @@ export default function PaginationNavigation({
179
188
  }
180
189
  >
181
190
  <a
191
+ onClick={(event) => goTo(event, currentPage + 1)}
182
192
  href={isLastPage ? '#' : hrefFor(currentPage + 1)}
183
193
  data-usx-pagination-page={currentPage + 1}
184
194
  className={
@@ -8,6 +8,7 @@ export interface PaginationStepOptionsProps {
8
8
  label?: string;
9
9
  id?: string;
10
10
  className?: string;
11
+ onPageSizeChange?: (size: number) => void;
11
12
  }
12
13
 
13
14
  export default function PaginationStepOptions({
@@ -16,6 +17,7 @@ export default function PaginationStepOptions({
16
17
  label = 'Items per page',
17
18
  id = 'pagination-step-options',
18
19
  className = '',
20
+ onPageSizeChange,
19
21
  }: PaginationStepOptionsProps) {
20
22
  const classes = ClassNames(
21
23
  'usx-pagination__step-options',
@@ -31,6 +33,7 @@ export default function PaginationStepOptions({
31
33
  defaultValue={String(pageSize)}
32
34
  formGroup={false}
33
35
  options={pageSizeOptions.map((size) => ({ value: String(size), label: String(size) }))}
36
+ onChange={(event) => onPageSizeChange?.(Number(event.target.value))}
34
37
  />
35
38
  </div>
36
39
  );
@@ -42,6 +42,7 @@ export interface PopoverProps extends Omit<
42
42
  panelClassName?: string;
43
43
  /** Optional class name for the inner content container. */
44
44
  contentClassName?: string;
45
+ extraAttributes?: Record<string, unknown>;
45
46
  }
46
47
 
47
48
  /**
@@ -64,6 +65,7 @@ export default function Popover({
64
65
  summaryProps,
65
66
  panelClassName,
66
67
  contentClassName,
68
+ extraAttributes,
67
69
  children,
68
70
  ...props
69
71
  }: PopoverProps) {
@@ -78,6 +80,7 @@ export default function Popover({
78
80
  open={initiallyOpen || undefined}
79
81
  data-side={side}
80
82
  data-align={align}
83
+ {...extraAttributes}
81
84
  >
82
85
  <Summary unstyled {...composedSummaryProps} />
83
86
  <div
@@ -125,6 +125,10 @@
125
125
  "contentClassName": {
126
126
  "type": "string",
127
127
  "description": "Optional class name for the inner content container."
128
+ },
129
+ "extraAttributes": {
130
+ "type": "object",
131
+ "description": "Additional HTML attributes on the popover root."
128
132
  }
129
133
  }
130
134
  }