@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.
- package/README.md +6 -5
- package/dist/index.cjs +123 -97
- package/dist/index.js +124 -98
- package/package.json +4 -4
- package/src/components/accordion/Accordion.tsx +4 -1
- package/src/components/accordion/accordion.django.html +1 -1
- package/src/components/accordion/config.json +1 -0
- package/src/components/banner/Banner.tsx +3 -1
- package/src/components/banner/banner.django.html +1 -1
- package/src/components/banner/config.json +1 -0
- package/src/components/carousel/carousel.django-snapshot.html +0 -40
- package/src/components/carousel/carousel.react-snapshot.html +0 -38
- package/src/components/character-count/CharacterCount.tsx +3 -0
- package/src/components/character-count/character-count.django-snapshot.html +43 -0
- package/src/components/character-count/character-count.django.html +2 -2
- package/src/components/character-count/character-count.react-snapshot.html +37 -0
- package/src/components/character-count/config.json +9 -0
- package/src/components/checkbox/Checkbox.tsx +16 -17
- package/src/components/checkbox/checkbox.django-snapshot.html +18 -0
- package/src/components/checkbox/checkbox.django.html +6 -4
- package/src/components/checkbox/checkbox.react-snapshot.html +14 -0
- package/src/components/checkbox/config.json +4 -4
- package/src/components/checkbox-group/checkbox-group.django-snapshot.html +54 -0
- package/src/components/checkbox-group/checkbox-group.react-snapshot.html +45 -0
- package/src/components/combobox/Combobox.tsx +6 -1
- package/src/components/combobox/combobox.django-snapshot.html +141 -0
- package/src/components/combobox/combobox.django.html +2 -2
- package/src/components/combobox/combobox.react-snapshot.html +76 -0
- package/src/components/combobox/config.json +9 -0
- package/src/components/data-table/DataTable.tsx +4 -1
- package/src/components/data-table/config.json +4 -0
- package/src/components/data-table/data-table.django.html +1 -1
- package/src/components/date-picker/DatePicker.tsx +6 -1
- package/src/components/date-picker/config.json +9 -0
- package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
- package/src/components/date-picker/date-picker.django.html +4 -4
- package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
- package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
- package/src/components/date-range-picker/config.json +14 -0
- package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
- package/src/components/date-range-picker/date-range-picker.django.html +5 -5
- package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
- package/src/components/drawer/Drawer.tsx +3 -1
- package/src/components/drawer/config.json +4 -0
- package/src/components/drawer/drawer.django.html +1 -1
- package/src/components/file-input/FileInput.tsx +7 -2
- package/src/components/file-input/_contents.django.html +2 -1
- package/src/components/file-input/config.json +4 -0
- package/src/components/header/Header.tsx +15 -9
- package/src/components/header/config.json +1 -0
- package/src/components/header/header.django-snapshot.html +24 -0
- package/src/components/header/header.django.html +8 -4
- package/src/components/header/header.html +20 -0
- package/src/components/header/header.react-snapshot.html +20 -0
- package/src/components/in-page-nav/InPageNav.tsx +3 -0
- package/src/components/in-page-nav/config.json +1 -0
- package/src/components/in-page-nav/in-page-nav.django.html +1 -1
- package/src/components/input/Input.tsx +3 -0
- package/src/components/input/config.json +10 -0
- package/src/components/input/input.django-snapshot.html +24 -0
- package/src/components/input/input.django.html +4 -4
- package/src/components/input/input.react-snapshot.html +22 -0
- package/src/components/language-selector/LanguageSelector.tsx +10 -5
- package/src/components/language-selector/config.json +1 -0
- package/src/components/language-selector/language-selector.django.html +2 -2
- package/src/components/layout/Layout.tsx +3 -1
- package/src/components/layout/config.json +4 -0
- package/src/components/layout/layout.django.html +1 -1
- package/src/components/memorable-date/MemorableDate.tsx +18 -3
- package/src/components/memorable-date/config.json +15 -0
- package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
- package/src/components/memorable-date/memorable-date.django.html +14 -14
- package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
- package/src/components/modal/Modal.tsx +3 -0
- package/src/components/modal/config.json +1 -0
- package/src/components/modal/modal.django.html +1 -1
- package/src/components/popover/Popover.tsx +3 -0
- package/src/components/popover/config.json +4 -0
- package/src/components/popover/popover.django-snapshot.html +30 -0
- package/src/components/popover/popover.django.html +1 -0
- package/src/components/radio-buttons/RadioButtons.tsx +5 -1
- package/src/components/radio-buttons/radio-buttons.django-snapshot.html +65 -0
- package/src/components/radio-buttons/radio-buttons.django.html +1 -1
- package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
- package/src/components/range-slider/RangeSlider.tsx +4 -2
- package/src/components/range-slider/config.json +1 -0
- package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
- package/src/components/range-slider/range-slider.django.html +4 -4
- package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
- package/src/components/search/Search.tsx +6 -1
- package/src/components/search/config.json +5 -0
- package/src/components/search/search.django-snapshot.html +683 -563
- package/src/components/search/search.django.html +1 -1
- package/src/components/search/search.react-snapshot.html +25 -0
- package/src/components/select/Select.tsx +3 -1
- package/src/components/select/config.json +5 -0
- package/src/components/select/select.django-snapshot.html +15 -0
- package/src/components/select/select.django.html +2 -2
- package/src/components/select/select.react-snapshot.html +11 -0
- package/src/components/switch/Switch.tsx +13 -70
- package/src/components/switch/config.json +60 -23
- package/src/components/switch/switch.django-snapshot.html +507 -56
- package/src/components/switch/switch.django.html +23 -26
- package/src/components/switch/switch.html +425 -33
- package/src/components/switch/switch.react-snapshot.html +447 -58
- package/src/components/table/Table.tsx +3 -1
- package/src/components/table/config.json +1 -0
- package/src/components/table/table.django.html +1 -1
- package/src/components/text-area/TextArea.tsx +3 -1
- package/src/components/text-area/config.json +5 -0
- package/src/components/text-area/text-area.django-snapshot.html +18 -0
- package/src/components/text-area/text-area.django.html +4 -4
- package/src/components/text-area/text-area.react-snapshot.html +16 -0
- package/src/components/theme-picker/ThemePicker.tsx +3 -1
- package/src/components/theme-picker/config.json +14 -1
- package/src/components/theme-picker/theme-picker.django-snapshot.html +64 -0
- package/src/components/theme-picker/theme-picker.django.html +2 -2
- package/src/components/theme-picker/theme-picker.react-snapshot.html +52 -0
- package/src/components/time-picker/TimePicker.tsx +6 -1
- package/src/components/time-picker/config.json +9 -0
- package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
- package/src/components/time-picker/time-picker.django.html +4 -4
- package/src/components/time-picker/time-picker.react-snapshot.html +22 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{# Django template for DateRangePicker #}
|
|
2
2
|
{% load usx_components %}
|
|
3
3
|
<div
|
|
4
|
-
class="usa-date-range-picker usx-date-range-picker{% if className %} {{ className }}{% endif %}"
|
|
4
|
+
class="usa-date-range-picker usx-date-range-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 %}
|
|
5
5
|
{% if minDate %} data-min-date="{{ minDate }}"{% endif %}
|
|
6
6
|
{% if maxDate %} data-max-date="{{ maxDate }}"{% endif %}
|
|
7
7
|
>
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
{% endif %}
|
|
20
20
|
|
|
21
21
|
<div
|
|
22
|
-
class="usa-date-picker usx-date-picker"
|
|
23
|
-
{% if defaultStartDate %} data-default-value="{{ defaultStartDate }}"{% endif %}
|
|
22
|
+
class="usa-date-picker usx-date-picker"{% if extraAttributes %}{% for attr, value in extraAttributes.items %}{% if attr == "data-enhanced" %} data-enhanced="{{ value }}"{% endif %}{% endfor %}{% endif %}
|
|
23
|
+
{% if startDate is not None and startDate or startDate is None and defaultStartDate %} data-default-value="{% if startDate is not None %}{{ startDate }}{% else %}{{ defaultStartDate }}{% endif %}"{% endif %}
|
|
24
24
|
>
|
|
25
25
|
<input
|
|
26
26
|
class="usa-input usx-input"
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
{% endif %}
|
|
49
49
|
|
|
50
50
|
<div
|
|
51
|
-
class="usa-date-picker usx-date-picker"
|
|
52
|
-
{% if defaultEndDate %} data-default-value="{{ defaultEndDate }}"{% endif %}
|
|
51
|
+
class="usa-date-picker usx-date-picker"{% if extraAttributes %}{% for attr, value in extraAttributes.items %}{% if attr == "data-enhanced" %} data-enhanced="{{ value }}"{% endif %}{% endfor %}{% endif %}
|
|
52
|
+
{% if endDate is not None and endDate or endDate is None and defaultEndDate %} data-default-value="{% if endDate is not None %}{{ endDate }}{% else %}{{ defaultEndDate }}{% endif %}"{% endif %}
|
|
53
53
|
>
|
|
54
54
|
<input
|
|
55
55
|
class="usa-input usx-input"
|
|
@@ -244,3 +244,41 @@
|
|
|
244
244
|
</div>
|
|
245
245
|
</div>
|
|
246
246
|
</div>
|
|
247
|
+
|
|
248
|
+
<h3 class="site-preview-heading">With Values</h3>
|
|
249
|
+
<div class="usa-date-range-picker usx-date-range-picker">
|
|
250
|
+
<div class="usa-form-group usx-form-group">
|
|
251
|
+
<label
|
|
252
|
+
id="react-event-date-value-start-label"
|
|
253
|
+
class="usa-label usx-label"
|
|
254
|
+
for="react-event-date-value-start"
|
|
255
|
+
>Event start date</label
|
|
256
|
+
><span class="usa-hint usx-hint" id="react-event-date-value-start-hint">mm/dd/yyyy</span>
|
|
257
|
+
<div class="usa-date-picker usx-date-picker" data-default-value="2021-06-20">
|
|
258
|
+
<input
|
|
259
|
+
class="usa-input usx-input"
|
|
260
|
+
id="react-event-date-value-start"
|
|
261
|
+
name="event-date-value-start"
|
|
262
|
+
aria-labelledby="react-event-date-value-start-label"
|
|
263
|
+
aria-describedby="react-event-date-value-start-hint"
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
<div class="usa-form-group usx-form-group">
|
|
268
|
+
<label
|
|
269
|
+
id="react-event-date-value-end-label"
|
|
270
|
+
class="usa-label usx-label"
|
|
271
|
+
for="react-event-date-value-end"
|
|
272
|
+
>Event end date</label
|
|
273
|
+
><span class="usa-hint usx-hint" id="react-event-date-value-end-hint">mm/dd/yyyy</span>
|
|
274
|
+
<div class="usa-date-picker usx-date-picker" data-default-value="2021-06-27">
|
|
275
|
+
<input
|
|
276
|
+
class="usa-input usx-input"
|
|
277
|
+
id="react-event-date-value-end"
|
|
278
|
+
name="event-date-value-end"
|
|
279
|
+
aria-labelledby="react-event-date-value-end-label"
|
|
280
|
+
aria-describedby="react-event-date-value-end-hint"
|
|
281
|
+
/>
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
@@ -40,6 +40,7 @@ export interface DrawerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
40
40
|
disabled?: boolean;
|
|
41
41
|
triggerClassName?: string;
|
|
42
42
|
panelClassName?: string;
|
|
43
|
+
extraAttributes?: Record<string, unknown>;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/** A native dialog drawer with declarative open and close controls. */
|
|
@@ -62,6 +63,7 @@ export default function Drawer({
|
|
|
62
63
|
className,
|
|
63
64
|
triggerClassName,
|
|
64
65
|
panelClassName,
|
|
66
|
+
extraAttributes,
|
|
65
67
|
...props
|
|
66
68
|
}: DrawerProps) {
|
|
67
69
|
// Lowercase native attributes work with React 18 and its current DOM typings.
|
|
@@ -72,7 +74,7 @@ export default function Drawer({
|
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
return (
|
|
75
|
-
<div {...props} className={ClassNames('usx-drawer', className)}>
|
|
77
|
+
<div {...props} className={ClassNames('usx-drawer', className)} {...extraAttributes}>
|
|
76
78
|
<button
|
|
77
79
|
type="button"
|
|
78
80
|
className={triggerClassName || undefined}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% load usx_components %}
|
|
2
2
|
<!-- prettier-ignore -->
|
|
3
|
-
<div class="usx-drawer{% if className %} {{ className }}{% endif %}">
|
|
3
|
+
<div class="usx-drawer{% 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 %}>
|
|
4
4
|
<button
|
|
5
5
|
type="button"
|
|
6
6
|
{% if triggerClassName %}class="{{ triggerClassName|force_escape }}"
|
|
@@ -27,6 +27,7 @@ export interface FileInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
27
27
|
onFilesChange?: ((files: File[]) => void) | null;
|
|
28
28
|
defaultFiles?: FileInputDefaultFile[];
|
|
29
29
|
formGroup?: boolean;
|
|
30
|
+
extraAttributes?: Record<string, unknown>;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// Mirrors USWDS's own default aria-label text (see updateVisibleInstructions
|
|
@@ -59,6 +60,7 @@ export default function FileInput({
|
|
|
59
60
|
onFilesChange = null,
|
|
60
61
|
defaultFiles = [],
|
|
61
62
|
formGroup = true,
|
|
63
|
+
extraAttributes,
|
|
62
64
|
...props
|
|
63
65
|
}: FileInputProps) {
|
|
64
66
|
const hintId = hint ? `${id}-hint` : undefined;
|
|
@@ -71,6 +73,7 @@ export default function FileInput({
|
|
|
71
73
|
// and always looks ready for the next file. The actual selection lives in
|
|
72
74
|
// the FileList below, which owns its own Delete action.
|
|
73
75
|
const isManagedMultiple = multiple && manageIndividualFiles;
|
|
76
|
+
const usxManagedDisabled = extraAttributes?.['usx-data-enhanced'] === 'true';
|
|
74
77
|
const nextFileId = useRef(0);
|
|
75
78
|
// defaultFiles seeds rows for files that already exist on the server (no
|
|
76
79
|
// File object) — e.g. previously-submitted uploads. Uncontrolled: only read
|
|
@@ -137,6 +140,7 @@ export default function FileInput({
|
|
|
137
140
|
required={required}
|
|
138
141
|
{...(invalidFileTypeMessage ? { 'data-errormessage': invalidFileTypeMessage } : {})}
|
|
139
142
|
{...props}
|
|
143
|
+
{...extraAttributes}
|
|
140
144
|
/>
|
|
141
145
|
</>
|
|
142
146
|
);
|
|
@@ -148,7 +152,7 @@ export default function FileInput({
|
|
|
148
152
|
{commonLabel}
|
|
149
153
|
{commonHint}
|
|
150
154
|
{commonError}
|
|
151
|
-
<div className="usx-file-input__add-only" data-usx-file-list-hint={typeof fileListHint === 'string' && fileListHint ? fileListHint : 'Selected files'}>
|
|
155
|
+
<div className="usx-file-input__add-only" {...(usxManagedDisabled ? { 'usx-data-enhanced': 'true' } : {})} data-usx-file-list-hint={typeof fileListHint === 'string' && fileListHint ? fileListHint : 'Selected files'}>
|
|
152
156
|
<input
|
|
153
157
|
ref={(node) => { if (node) (node as HTMLInputElement & { usxReactManaged?: boolean }).usxReactManaged = true; }}
|
|
154
158
|
className={ClassNames('usa-file-input', 'usx-file-input', className)}
|
|
@@ -162,7 +166,8 @@ export default function FileInput({
|
|
|
162
166
|
required={required && managedFiles.length === 0}
|
|
163
167
|
{...(invalidFileTypeMessage ? { 'data-errormessage': invalidFileTypeMessage } : {})}
|
|
164
168
|
{...props}
|
|
165
|
-
|
|
169
|
+
{...extraAttributes}
|
|
170
|
+
onChange={usxManagedDisabled ? undefined : addFiles}
|
|
166
171
|
/>
|
|
167
172
|
</div>
|
|
168
173
|
<FileList files={managedFiles} hint={fileListHint} onRemove={removeFile} disabled={disabled} />
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{% if error %}
|
|
9
9
|
{% error_message id=id|add:"-error" %}{{ error }}{% enderror_message %}
|
|
10
10
|
{% endif %}
|
|
11
|
-
{% if multiple and manageIndividualFiles %}<div class="usx-file-input__add-only" data-usx-file-list-hint="{{ fileListHint|default:'Selected files' }}">{% endif %}
|
|
11
|
+
{% if multiple and manageIndividualFiles %}<div class="usx-file-input__add-only"{% if extraAttributes %}{% for attr, value in extraAttributes.items %}{% if attr == 'usx-data-enhanced' %} usx-data-enhanced="{{ value }}"{% endif %}{% endfor %}{% endif %} data-usx-file-list-hint="{{ fileListHint|default:'Selected files' }}">{% endif %}
|
|
12
12
|
<input
|
|
13
13
|
class="usa-file-input usx-file-input{% if className %} {{ className }}{% endif %}"
|
|
14
14
|
id="{{ id }}"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
{% if invalidFileTypeMessage %} data-errormessage="{{ invalidFileTypeMessage }}"{% endif %}
|
|
21
21
|
{% if disabled %} disabled{% endif %}
|
|
22
22
|
{% if required %}{% if multiple and manageIndividualFiles %}{% if not defaultFiles %} required{% endif %}{% else %} required{% endif %}{% endif %}
|
|
23
|
+
{% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
|
|
23
24
|
/>
|
|
24
25
|
{% if multiple and manageIndividualFiles %}
|
|
25
26
|
</div>
|
|
@@ -79,6 +79,10 @@
|
|
|
79
79
|
"onFilesChange": {
|
|
80
80
|
"type": "function",
|
|
81
81
|
"description": "Receives the current browser File objects after managed add or delete. React calls this function; Django dispatches a bubbling usx:files-change event from the input with detail.files. Preloaded files are excluded."
|
|
82
|
+
},
|
|
83
|
+
"extraAttributes": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"description": "Additional HTML attributes on the file input."
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
}
|
|
@@ -158,6 +158,7 @@ function PrimaryNav({
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
export interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
|
|
161
|
+
extraAttributes?: Record<string, unknown>;
|
|
161
162
|
id?: string;
|
|
162
163
|
branding: BrandingProps;
|
|
163
164
|
staticBaseUrl?: string;
|
|
@@ -191,6 +192,7 @@ export default function Header({
|
|
|
191
192
|
className = '',
|
|
192
193
|
utilityContent = null,
|
|
193
194
|
navEndContent = null,
|
|
195
|
+
extraAttributes,
|
|
194
196
|
...props
|
|
195
197
|
}: HeaderProps) {
|
|
196
198
|
const headerClasses = ClassNames(
|
|
@@ -207,23 +209,27 @@ export default function Header({
|
|
|
207
209
|
'usx-nav',
|
|
208
210
|
{ 'usx-nav--sticky': stickyNav },
|
|
209
211
|
);
|
|
212
|
+
const hasNavigation = navSections.length > 0 || Boolean(searchProps || utilityContent ||
|
|
213
|
+
(extended && (secondaryLinks.length > 0 || navEndContent)));
|
|
210
214
|
|
|
211
215
|
const navbar = (
|
|
212
216
|
<div className="usa-navbar">
|
|
213
217
|
<Branding branding={branding} projectUrl={projectUrl} staticBaseUrl={staticBaseUrl} />
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
{hasNavigation && (
|
|
219
|
+
<button type="button" className="usa-menu-btn align-center">
|
|
220
|
+
{useMenuIcon ? <Icon name="menu" size={3} /> : 'Menu'}
|
|
221
|
+
</button>
|
|
222
|
+
)}
|
|
217
223
|
</div>
|
|
218
224
|
);
|
|
219
225
|
|
|
220
226
|
if (extended) {
|
|
221
227
|
return (
|
|
222
228
|
<>
|
|
223
|
-
<header id={id} className={headerClasses} {...props}>
|
|
229
|
+
<header id={id} className={headerClasses} {...props} {...extraAttributes}>
|
|
224
230
|
{navbar}
|
|
225
231
|
</header>
|
|
226
|
-
<nav aria-label="Primary navigation" className={navClasses}>
|
|
232
|
+
{hasNavigation && <nav aria-label="Primary navigation" className={navClasses} {...(extraAttributes?.['data-enhanced'] === 'true' ? { 'data-enhanced': 'true' } : {})}>
|
|
227
233
|
<div className="usa-nav__inner">
|
|
228
234
|
<PrimaryNav
|
|
229
235
|
navSections={navSections}
|
|
@@ -254,16 +260,16 @@ export default function Header({
|
|
|
254
260
|
</div>
|
|
255
261
|
{navEndContent && <div className="usx-nav__end-slot">{navEndContent}</div>}
|
|
256
262
|
</div>
|
|
257
|
-
</nav>
|
|
263
|
+
</nav>}
|
|
258
264
|
</>
|
|
259
265
|
);
|
|
260
266
|
}
|
|
261
267
|
|
|
262
268
|
return (
|
|
263
|
-
<header id={id} className={headerClasses} {...props}>
|
|
269
|
+
<header id={id} className={headerClasses} {...props} {...extraAttributes}>
|
|
264
270
|
<div className="usa-nav-container">
|
|
265
271
|
{navbar}
|
|
266
|
-
<nav aria-label="Primary navigation" className={navClasses}>
|
|
272
|
+
{hasNavigation && <nav aria-label="Primary navigation" className={navClasses}>
|
|
267
273
|
<PrimaryNav
|
|
268
274
|
navSections={navSections}
|
|
269
275
|
megamenu={megamenu}
|
|
@@ -274,7 +280,7 @@ export default function Header({
|
|
|
274
280
|
headerId={id}
|
|
275
281
|
renderSearchDirectly={true}
|
|
276
282
|
/>
|
|
277
|
-
</nav>
|
|
283
|
+
</nav>}
|
|
278
284
|
</div>
|
|
279
285
|
</header>
|
|
280
286
|
);
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"megamenu": true
|
|
77
77
|
},
|
|
78
78
|
"props": {
|
|
79
|
+
"extraAttributes": { "type": "object", "description": "Additional attributes on the USWDS enhancement target." },
|
|
79
80
|
"staticBaseUrl": {
|
|
80
81
|
"type": "string",
|
|
81
82
|
"description": "Optional branding image asset base, overriding window.usxBaseUrl in React or STATIC_URL in Django. Defaults to the global base or /."
|
|
@@ -1060,6 +1060,30 @@
|
|
|
1060
1060
|
</div>
|
|
1061
1061
|
</header>
|
|
1062
1062
|
|
|
1063
|
+
<h3 class="site-preview-heading">Brand Only</h3>
|
|
1064
|
+
<header class="usa-header usx-header usa-header--basic" id="django-header-brand-only">
|
|
1065
|
+
<div class="usa-nav-container">
|
|
1066
|
+
<div class="usa-navbar">
|
|
1067
|
+
<div class="usa-logo usx-logo">
|
|
1068
|
+
<em class="usa-logo__text">
|
|
1069
|
+
<a href="/" class="usx-logo__title">Simple Site</a>
|
|
1070
|
+
</em>
|
|
1071
|
+
</div>
|
|
1072
|
+
</div>
|
|
1073
|
+
</div>
|
|
1074
|
+
</header>
|
|
1075
|
+
|
|
1076
|
+
<h3 class="site-preview-heading">Brand Only Extended</h3>
|
|
1077
|
+
<header class="usa-header usx-header usa-header--extended" id="django-header-brand-only-extended">
|
|
1078
|
+
<div class="usa-navbar">
|
|
1079
|
+
<div class="usa-logo usx-logo">
|
|
1080
|
+
<em class="usa-logo__text">
|
|
1081
|
+
<a href="/" class="usx-logo__title">Simple Site</a>
|
|
1082
|
+
</em>
|
|
1083
|
+
</div>
|
|
1084
|
+
</div>
|
|
1085
|
+
</header>
|
|
1086
|
+
|
|
1063
1087
|
<h3 class="site-preview-heading">Minimal</h3>
|
|
1064
1088
|
<header class="usa-header usx-header usa-header--basic" id="django-header-minimal">
|
|
1065
1089
|
<div class="usa-nav-container">
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{% if megamenu and not extended %}usa-header--megamenu{% endif %}
|
|
8
8
|
{% if extended %}usa-header--extended{% endif %}
|
|
9
9
|
{{ className }}
|
|
10
|
-
" {% if id %}id="{{ id }}"{% endif %} {% if styles %}style="{{ styles|safe }}"{% endif %}>
|
|
10
|
+
" {% if id %}id="{{ id }}"{% endif %} {% if styles %}style="{{ styles|safe }}"{% 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 %}>
|
|
11
11
|
{% if not extended %}
|
|
12
12
|
<div class="usa-nav-container">
|
|
13
13
|
{% endif %}
|
|
@@ -35,16 +35,17 @@
|
|
|
35
35
|
</em>
|
|
36
36
|
{% endif %}
|
|
37
37
|
</div>
|
|
38
|
-
<button type="button" class="usa-menu-btn align-center">
|
|
38
|
+
{% if navSections or searchProps or utilityContent or extended and secondaryLinks or extended and navEndContent %}<button type="button" class="usa-menu-btn align-center">
|
|
39
39
|
{% if useMenuIcon %}
|
|
40
40
|
{% icon name='menu' size=3 %}{% endicon %}
|
|
41
41
|
{% else %}
|
|
42
42
|
Menu
|
|
43
43
|
{% endif %}
|
|
44
|
-
</button>
|
|
44
|
+
</button>{% endif %}
|
|
45
45
|
</div>
|
|
46
46
|
|
|
47
47
|
{% if not extended %}
|
|
48
|
+
{% if navSections or searchProps or utilityContent %}
|
|
48
49
|
<nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}">
|
|
49
50
|
<button type="button" class="usa-nav__close">
|
|
50
51
|
{% icon name='close' size=3 %}{% endicon %}
|
|
@@ -107,11 +108,13 @@
|
|
|
107
108
|
</div>
|
|
108
109
|
{% endif %}
|
|
109
110
|
</nav>
|
|
111
|
+
{% endif %}
|
|
110
112
|
{% endif %}
|
|
111
113
|
{% if not extended %}</div>{% endif %}
|
|
112
114
|
</header>
|
|
113
115
|
{% if extended %}
|
|
114
|
-
|
|
116
|
+
{% if navSections or secondaryLinks or searchProps or utilityContent or navEndContent %}
|
|
117
|
+
<nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}"{% if extraAttributes %}{% for attr, value in extraAttributes.items %}{% if attr == 'data-enhanced' %} data-enhanced="{{ value }}"{% endif %}{% endfor %}{% endif %}>
|
|
115
118
|
<div class="usa-nav__inner">
|
|
116
119
|
<button type="button" class="usa-nav__close">
|
|
117
120
|
{% icon name='close' size=3 %}{% endicon %}
|
|
@@ -188,4 +191,5 @@
|
|
|
188
191
|
{% if navEndContent %}<div class="usx-nav__end-slot">{{ navEndContent|safe }}</div>{% endif %}
|
|
189
192
|
</div>
|
|
190
193
|
</nav>
|
|
194
|
+
{% endif %}
|
|
191
195
|
{% endif %}
|
|
@@ -1599,6 +1599,26 @@
|
|
|
1599
1599
|
</div>
|
|
1600
1600
|
</header>
|
|
1601
1601
|
|
|
1602
|
+
<h3 class="site-preview-heading">Brand Only</h3>
|
|
1603
|
+
<header id="html-header-brand-only" class="usa-header usx-header usa-header--basic">
|
|
1604
|
+
<div class="usa-nav-container">
|
|
1605
|
+
<div class="usa-navbar">
|
|
1606
|
+
<div class="usa-logo usx-logo">
|
|
1607
|
+
<em class="usa-logo__text"><a href="/" class="usx-logo__title">Simple Site</a></em>
|
|
1608
|
+
</div>
|
|
1609
|
+
</div>
|
|
1610
|
+
</div>
|
|
1611
|
+
</header>
|
|
1612
|
+
|
|
1613
|
+
<h3 class="site-preview-heading">Brand Only Extended</h3>
|
|
1614
|
+
<header id="html-header-brand-only-extended" class="usa-header usx-header usa-header--extended">
|
|
1615
|
+
<div class="usa-navbar">
|
|
1616
|
+
<div class="usa-logo usx-logo">
|
|
1617
|
+
<em class="usa-logo__text"><a href="/" class="usx-logo__title">Simple Site</a></em>
|
|
1618
|
+
</div>
|
|
1619
|
+
</div>
|
|
1620
|
+
</header>
|
|
1621
|
+
|
|
1602
1622
|
<h3 class="site-preview-heading">Minimal</h3>
|
|
1603
1623
|
<header class="usa-header usx-header usa-header--basic">
|
|
1604
1624
|
<div class="usa-nav-container">
|
|
@@ -813,6 +813,26 @@
|
|
|
813
813
|
</div>
|
|
814
814
|
</header>
|
|
815
815
|
|
|
816
|
+
<h3 class="site-preview-heading">Brand Only</h3>
|
|
817
|
+
<header id="react-header-brand-only" class="usa-header usx-header usa-header--basic">
|
|
818
|
+
<div class="usa-nav-container">
|
|
819
|
+
<div class="usa-navbar">
|
|
820
|
+
<div class="usa-logo usx-logo">
|
|
821
|
+
<em class="usa-logo__text"><a href="/" class="usx-logo__title">Simple Site</a></em>
|
|
822
|
+
</div>
|
|
823
|
+
</div>
|
|
824
|
+
</div>
|
|
825
|
+
</header>
|
|
826
|
+
|
|
827
|
+
<h3 class="site-preview-heading">Brand Only Extended</h3>
|
|
828
|
+
<header id="react-header-brand-only-extended" class="usa-header usx-header usa-header--extended">
|
|
829
|
+
<div class="usa-navbar">
|
|
830
|
+
<div class="usa-logo usx-logo">
|
|
831
|
+
<em class="usa-logo__text"><a href="/" class="usx-logo__title">Simple Site</a></em>
|
|
832
|
+
</div>
|
|
833
|
+
</div>
|
|
834
|
+
</header>
|
|
835
|
+
|
|
816
836
|
<h3 class="site-preview-heading">Minimal</h3>
|
|
817
837
|
<header id="react-header-minimal" class="usa-header usx-header usa-header--basic">
|
|
818
838
|
<div class="usa-nav-container">
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
export interface InPageNavProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
+
extraAttributes?: Record<string, unknown>;
|
|
6
7
|
headingElements?: string;
|
|
7
8
|
mainContentSelector?: string | null;
|
|
8
9
|
titleAs?: string;
|
|
@@ -35,6 +36,7 @@ export default function InPageNav({
|
|
|
35
36
|
children = null,
|
|
36
37
|
className = '',
|
|
37
38
|
contentClassName = '',
|
|
39
|
+
extraAttributes,
|
|
38
40
|
...props
|
|
39
41
|
}: InPageNavProps) {
|
|
40
42
|
const contentId = `${id}-content`;
|
|
@@ -60,6 +62,7 @@ export default function InPageNav({
|
|
|
60
62
|
data-threshold={threshold}
|
|
61
63
|
data-minimum-heading-count={minimumHeadingCount}
|
|
62
64
|
{...props}
|
|
65
|
+
{...extraAttributes}
|
|
63
66
|
/>
|
|
64
67
|
<div
|
|
65
68
|
id={contentId}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"content": "\n <h2>Introduction</h2>\n <p>This page walks through setting up and using the example project.</p>\n <p>It's also meant to demonstrate how the in-page navigation component tracks scroll\n position and highlights whichever section is currently in view. Scroll down through\n each section below to see the link list on the side update automatically.</p>\n <p>None of the copy on this page is meant to be read closely — it exists purely to give\n the navigation something substantial enough to observe.</p>\n <h2>Getting started</h2>\n <p>Before you begin, make sure the prerequisites below are met.</p>\n <p>Getting started with any new project usually means working through a short checklist\n before the real work begins. The sections below cover what you'll need and how to get\n everything installed.</p>\n <h3>Prerequisites</h3>\n <p>A recent browser and a working internet connection.</p>\n <p>You'll also want a modern code editor and enough disk space for the dependencies.\n Nothing here is unusual — most standard front-end tooling already satisfies these\n requirements.</p>\n <p>If you already have Node.js and a package manager installed, you can skip ahead to\n the installation section below.</p>\n <h3>Installation</h3>\n <p>Download the package and follow the setup instructions.</p>\n <p>Installation typically takes just a few minutes. Run the installer, accept the\n default options, and confirm that the command-line tool reports a successful install\n before moving on.</p>\n <p>If you run into trouble, double-check that your environment matches the\n prerequisites listed above before trying again.</p>\n <h2>Advanced usage</h2>\n <p>Once installed, explore the configuration options to fit your workflow.</p>\n <p>Advanced users can customize almost every aspect of the setup, from heading\n detection to scroll offsets and intersection thresholds — all of which this component\n exposes as simple data attributes.</p>\n <p>Most projects never need to touch these settings, but they're available for the\n cases that do.</p>\n <h2>Conclusion</h2>\n <p>You should now be ready to explore the rest of the documentation.</p>\n <p>Thanks for reading through this example. Scroll back up and watch the navigation\n list highlight each section as it passes by — that's the entire behavior this\n component provides.</p>\n"
|
|
8
8
|
},
|
|
9
9
|
"props": {
|
|
10
|
+
"extraAttributes": { "type": "object", "description": "Additional attributes on the USWDS enhancement target." },
|
|
10
11
|
"id": {
|
|
11
12
|
"type": "string",
|
|
12
13
|
"default": "in-page-nav",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<div class="usa-in-page-nav-container usx-in-page-nav-container">
|
|
12
12
|
<aside
|
|
13
13
|
id="{{ id|default:'in-page-nav' }}"
|
|
14
|
-
class="usa-in-page-nav usx-in-page-nav{% if className %} {{ className }}{% endif %}"
|
|
14
|
+
class="usa-in-page-nav usx-in-page-nav{% 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
|
data-heading-elements="{{ headingElements|default:'h2 h3' }}"
|
|
16
16
|
data-main-content-selector="{% if mainContentSelector %}{{ mainContentSelector }}{% else %}#{{ content_id }}{% endif %}"
|
|
17
17
|
data-title-heading-level="{{ titleAs|default:'h4' }}"
|
|
@@ -31,6 +31,8 @@ export default function Input({
|
|
|
31
31
|
screenReaderOnlyLabel = false,
|
|
32
32
|
formGroup = true,
|
|
33
33
|
className = '',
|
|
34
|
+
value,
|
|
35
|
+
defaultValue,
|
|
34
36
|
...props
|
|
35
37
|
}: InputProps) {
|
|
36
38
|
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -61,6 +63,7 @@ export default function Input({
|
|
|
61
63
|
required,
|
|
62
64
|
'aria-describedby': describedByParts.length ? describedByParts.join(' ') : undefined,
|
|
63
65
|
'aria-invalid': hasError ? true : undefined,
|
|
66
|
+
...(value !== undefined ? { value } : { defaultValue }),
|
|
64
67
|
...props,
|
|
65
68
|
};
|
|
66
69
|
|
|
@@ -85,6 +85,16 @@
|
|
|
85
85
|
"type": "string",
|
|
86
86
|
"default": "",
|
|
87
87
|
"description": "Additional CSS classes to apply to the input field."
|
|
88
|
+
},
|
|
89
|
+
"defaultValue": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"default": null,
|
|
92
|
+
"description": "Initial input value; editable by the user."
|
|
93
|
+
},
|
|
94
|
+
"value": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"default": null,
|
|
97
|
+
"description": "Current input value. Takes precedence over defaultValue."
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
}
|
|
@@ -119,3 +119,27 @@
|
|
|
119
119
|
disabled
|
|
120
120
|
/>
|
|
121
121
|
</div>
|
|
122
|
+
|
|
123
|
+
<h3 class="site-preview-heading">Value</h3>
|
|
124
|
+
<div class="usa-form-group usx-form-group">
|
|
125
|
+
<label class="usa-label usx-label" for="django-input-value"> Current value </label>
|
|
126
|
+
|
|
127
|
+
<input
|
|
128
|
+
class="usa-input usx-input"
|
|
129
|
+
id="django-input-value"
|
|
130
|
+
placeholder="Type here"
|
|
131
|
+
value="Current value"
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<h3 class="site-preview-heading">Default Value</h3>
|
|
136
|
+
<div class="usa-form-group usx-form-group">
|
|
137
|
+
<label class="usa-label usx-label" for="django-input-default-value"> Initial value </label>
|
|
138
|
+
|
|
139
|
+
<input
|
|
140
|
+
class="usa-input usx-input"
|
|
141
|
+
id="django-input-default-value"
|
|
142
|
+
placeholder="Type here"
|
|
143
|
+
value="Editable initial value"
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
{% endif %}
|
|
17
17
|
<input
|
|
18
18
|
class="usa-input usx-input{% if error %} usa-input--error{% elif success %} usa-input--success{% endif %}{% if className %} {{ className }}{% endif %}"
|
|
19
|
-
id="{{ field_id }}"
|
|
19
|
+
id="{{ field_id }}"{% 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
20
|
{% if name %}name="{{ name }}" {% endif %}
|
|
21
21
|
{% if type %}type="{{ type }}" {% endif %}
|
|
22
22
|
{% if autoComplete %}autocomplete="{{ autoComplete }}" {% endif %}
|
|
23
23
|
placeholder="{% if placeholder is None %}Type here{% else %}{{ placeholder }}{% endif %}"
|
|
24
|
-
value="{{ value|default:'' }}"
|
|
24
|
+
value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue|default:'' }}{% endif %}"
|
|
25
25
|
{% if maxlength %}maxlength="{{ maxlength }}" {% endif %}
|
|
26
26
|
{% if hint or describedBy or error and error != "true" and error != True and error != "false" %}aria-describedby="{% if describedBy %}{{ describedBy }} {% endif %}{% if hint %}{{ field_id }}-hint {% endif %}{% if error and error != "true" and error != True and error != "false" %}{{ field_id }}-error {% endif %}"
|
|
27
27
|
{% endif %}
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
{% endif %}
|
|
44
44
|
<input
|
|
45
45
|
class="usa-input usx-input{% if error %} usa-input--error{% elif success %} usa-input--success{% endif %}{% if className %} {{ className }}{% endif %}"
|
|
46
|
-
id="{{ field_id }}"
|
|
46
|
+
id="{{ field_id }}"{% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
|
|
47
47
|
{% if name %}name="{{ name }}" {% endif %}
|
|
48
48
|
{% if type %}type="{{ type }}" {% endif %}
|
|
49
49
|
{% if autoComplete %}autocomplete="{{ autoComplete }}" {% endif %}
|
|
50
50
|
placeholder="{% if placeholder is None %}Type here{% else %}{{ placeholder }}{% endif %}"
|
|
51
|
-
value="{{ value|default:'' }}"
|
|
51
|
+
value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue|default:'' }}{% endif %}"
|
|
52
52
|
{% if maxlength %}maxlength="{{ maxlength }}" {% endif %}
|
|
53
53
|
{% if hint or describedBy or error and error != "true" and error != True and error != "false" %}aria-describedby="{% if describedBy %}{{ describedBy }} {% endif %}{% if hint %}{{ field_id }}-hint {% endif %}{% if error and error != "true" and error != True and error != "false" %}{{ field_id }}-error {% endif %}"
|
|
54
54
|
{% endif %}
|
|
@@ -92,3 +92,25 @@
|
|
|
92
92
|
disabled=""
|
|
93
93
|
/>
|
|
94
94
|
</div>
|
|
95
|
+
|
|
96
|
+
<h3 class="site-preview-heading">Value</h3>
|
|
97
|
+
<div class="usa-form-group usx-form-group">
|
|
98
|
+
<label class="usa-label usx-label" for="react-input-value">Current value</label
|
|
99
|
+
><input
|
|
100
|
+
id="react-input-value"
|
|
101
|
+
class="usa-input usx-input"
|
|
102
|
+
placeholder="Type here"
|
|
103
|
+
value="Current value"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<h3 class="site-preview-heading">Default Value</h3>
|
|
108
|
+
<div class="usa-form-group usx-form-group">
|
|
109
|
+
<label class="usa-label usx-label" for="react-input-default-value">Initial value</label
|
|
110
|
+
><input
|
|
111
|
+
id="react-input-default-value"
|
|
112
|
+
class="usa-input usx-input"
|
|
113
|
+
placeholder="Type here"
|
|
114
|
+
value="Editable initial value"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|