@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.
- package/README.md +6 -5
- package/dist/index.cjs +245 -162
- package/dist/index.js +246 -163
- 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/code/code.django-snapshot.html +4 -6
- package/src/components/code/code.html +2 -2
- package/src/components/code/code.react-snapshot.html +2 -4
- 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 +29 -7
- package/src/components/header/header.django.html +8 -4
- package/src/components/header/header.html +21 -11
- package/src/components/header/header.react-snapshot.html +23 -6
- package/src/components/icon-list/IconList.tsx +10 -2
- package/src/components/icon-list/config.json +5 -1
- package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
- package/src/components/icon-list/icon-list.django.html +2 -0
- package/src/components/icon-list/icon-list.react-snapshot.html +31 -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/list/List.tsx +10 -2
- package/src/components/list/config.json +5 -1
- package/src/components/list/list.django-snapshot.html +26 -0
- package/src/components/list/list.django.html +2 -0
- package/src/components/list/list.html +20 -0
- package/src/components/list/list.react-snapshot.html +20 -0
- 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/page/Page.tsx +16 -0
- package/src/components/page/config.json +18 -1
- package/src/components/page/page.django-snapshot.html +74 -0
- package/src/components/page/page.django.html +8 -0
- package/src/components/page/page.html +60 -0
- package/src/components/page/page.react-snapshot.html +60 -0
- 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 +97 -52
- package/src/components/theme-picker/config.json +21 -5
- package/src/components/theme-picker/theme-picker-select.django.html +7 -0
- package/src/components/theme-picker/theme-picker.django-snapshot.html +158 -14
- package/src/components/theme-picker/theme-picker.django.html +22 -24
- package/src/components/theme-picker/theme-picker.html +86 -56
- package/src/components/theme-picker/theme-picker.react-snapshot.html +120 -12
- 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
|
@@ -81,6 +81,45 @@
|
|
|
81
81
|
</li>
|
|
82
82
|
</ul>
|
|
83
83
|
|
|
84
|
+
<h3 class="site-preview-heading">Captioned</h3>
|
|
85
|
+
<figure class="usx-list-figure">
|
|
86
|
+
<figcaption class="usx-list-figure__caption">Health and safety guidance</figcaption>
|
|
87
|
+
<ul class="usa-icon-list usx-icon-list">
|
|
88
|
+
<li class="usa-icon-list__item">
|
|
89
|
+
<div class="usa-icon-list__icon text-green">
|
|
90
|
+
<svg class="usa-icon usx-icon text-green" aria-hidden="true" focusable="false" role="img">
|
|
91
|
+
<use href="img/sprite.svg#check_circle"></use>
|
|
92
|
+
</svg>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="usa-icon-list__content">
|
|
95
|
+
<div>Wash your hands for 20 seconds with soap</div>
|
|
96
|
+
</div>
|
|
97
|
+
</li>
|
|
98
|
+
|
|
99
|
+
<li class="usa-icon-list__item">
|
|
100
|
+
<div class="usa-icon-list__icon text-green">
|
|
101
|
+
<svg class="usa-icon usx-icon text-green" aria-hidden="true" focusable="false" role="img">
|
|
102
|
+
<use href="img/sprite.svg#check_circle"></use>
|
|
103
|
+
</svg>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="usa-icon-list__content">
|
|
106
|
+
<div>Stay six feet away from others</div>
|
|
107
|
+
</div>
|
|
108
|
+
</li>
|
|
109
|
+
|
|
110
|
+
<li class="usa-icon-list__item">
|
|
111
|
+
<div class="usa-icon-list__icon text-red">
|
|
112
|
+
<svg class="usa-icon usx-icon text-red" aria-hidden="true" focusable="false" role="img">
|
|
113
|
+
<use href="img/sprite.svg#cancel"></use>
|
|
114
|
+
</svg>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="usa-icon-list__content">
|
|
117
|
+
<div>Avoid large gatherings</div>
|
|
118
|
+
</div>
|
|
119
|
+
</li>
|
|
120
|
+
</ul>
|
|
121
|
+
</figure>
|
|
122
|
+
|
|
84
123
|
<h3 class="site-preview-heading">Rich Content</h3>
|
|
85
124
|
<ul class="usa-icon-list usx-icon-list">
|
|
86
125
|
<li class="usa-icon-list__item">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% load usx_components %}
|
|
2
2
|
|
|
3
|
+
{% if caption %}<figure class="usx-list-figure"><figcaption class="usx-list-figure__caption">{{ caption }}</figcaption>{% endif %}
|
|
3
4
|
<ul class="usa-icon-list usx-icon-list{% if primary %} usa-icon-list--primary{% endif %}{% if size == 'lg' %} usa-icon-list--size-lg{% endif %}{% if className %} {{ className }}{% endif %}">
|
|
4
5
|
{% for item in items %}
|
|
5
6
|
<li class="usa-icon-list__item{% if item.itemClassName %} {{ item.itemClassName }}{% endif %}">
|
|
@@ -15,3 +16,4 @@
|
|
|
15
16
|
</li>
|
|
16
17
|
{% endfor %}
|
|
17
18
|
</ul>
|
|
19
|
+
{% if caption %}</figure>{% endif %}
|
|
@@ -64,6 +64,37 @@
|
|
|
64
64
|
</li>
|
|
65
65
|
</ul>
|
|
66
66
|
|
|
67
|
+
<h3 class="site-preview-heading">Captioned</h3>
|
|
68
|
+
<figure class="usx-list-figure">
|
|
69
|
+
<figcaption class="usx-list-figure__caption">Health and safety guidance</figcaption>
|
|
70
|
+
<ul class="usa-icon-list usx-icon-list">
|
|
71
|
+
<li class="usa-icon-list__item">
|
|
72
|
+
<div class="usa-icon-list__icon text-green">
|
|
73
|
+
<svg class="usa-icon usx-icon text-green" aria-hidden="true" focusable="false" role="img">
|
|
74
|
+
<use href="/img/sprite.svg#check_circle"></use>
|
|
75
|
+
</svg>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="usa-icon-list__content"><div>Wash your hands for 20 seconds with soap</div></div>
|
|
78
|
+
</li>
|
|
79
|
+
<li class="usa-icon-list__item">
|
|
80
|
+
<div class="usa-icon-list__icon text-green">
|
|
81
|
+
<svg class="usa-icon usx-icon text-green" aria-hidden="true" focusable="false" role="img">
|
|
82
|
+
<use href="/img/sprite.svg#check_circle"></use>
|
|
83
|
+
</svg>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="usa-icon-list__content"><div>Stay six feet away from others</div></div>
|
|
86
|
+
</li>
|
|
87
|
+
<li class="usa-icon-list__item">
|
|
88
|
+
<div class="usa-icon-list__icon text-red">
|
|
89
|
+
<svg class="usa-icon usx-icon text-red" aria-hidden="true" focusable="false" role="img">
|
|
90
|
+
<use href="/img/sprite.svg#cancel"></use>
|
|
91
|
+
</svg>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="usa-icon-list__content"><div>Avoid large gatherings</div></div>
|
|
94
|
+
</li>
|
|
95
|
+
</ul>
|
|
96
|
+
</figure>
|
|
97
|
+
|
|
67
98
|
<h3 class="site-preview-heading">Rich Content</h3>
|
|
68
99
|
<ul class="usa-icon-list usx-icon-list">
|
|
69
100
|
<li class="usa-icon-list__item">
|
|
@@ -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>
|
|
@@ -12,6 +12,7 @@ export interface LanguageOption {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface LanguageSelectorProps {
|
|
15
|
+
extraAttributes?: Record<string, unknown>;
|
|
15
16
|
languages?: LanguageOption[];
|
|
16
17
|
variant?: 'two' | 'menu' | null;
|
|
17
18
|
unstyled?: boolean;
|
|
@@ -23,7 +24,7 @@ export interface LanguageSelectorProps {
|
|
|
23
24
|
onSelect?: ((language: LanguageOption, event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void) | null;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
interface TwoLanguageSelectorProps extends Pick<LanguageSelectorProps, 'onSelect' | 'className' | 'navAriaLabel'> {
|
|
27
|
+
interface TwoLanguageSelectorProps extends Pick<LanguageSelectorProps, 'onSelect' | 'className' | 'navAriaLabel' | 'extraAttributes'> {
|
|
27
28
|
target: LanguageOption;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -51,7 +52,7 @@ function LanguageLabel({ code, label, description }: Pick<LanguageOption, 'code'
|
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
function TwoLanguageSelector({ target, onSelect, className, navAriaLabel }: TwoLanguageSelectorProps) {
|
|
55
|
+
function TwoLanguageSelector({ target, onSelect, className, navAriaLabel, extraAttributes }: TwoLanguageSelectorProps) {
|
|
55
56
|
const handleClick = (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => {
|
|
56
57
|
if (onSelect) onSelect(target, event);
|
|
57
58
|
if (!target.href) event.preventDefault();
|
|
@@ -63,7 +64,7 @@ function TwoLanguageSelector({ target, onSelect, className, navAriaLabel }: TwoL
|
|
|
63
64
|
: { type: 'button' as const };
|
|
64
65
|
|
|
65
66
|
return (
|
|
66
|
-
<nav aria-label={navAriaLabel} className={className}>
|
|
67
|
+
<nav aria-label={navAriaLabel} className={className} {...extraAttributes}>
|
|
67
68
|
<div className="usa-language-container">
|
|
68
69
|
<Tag className="usa-button usx-button usa-button--primary" onClick={handleClick} {...tagProps}>
|
|
69
70
|
<LanguageLabel code={target.code} label={target.label} />
|
|
@@ -82,6 +83,7 @@ function MenuLanguageSelector({
|
|
|
82
83
|
onSelect,
|
|
83
84
|
className,
|
|
84
85
|
navAriaLabel,
|
|
86
|
+
extraAttributes,
|
|
85
87
|
}: MenuLanguageSelectorProps) {
|
|
86
88
|
// Open/close (aria-expanded, hidden, outside-click, Escape, focusout) is
|
|
87
89
|
// driven by USWDS's own JS, initialized via a decorator in the story/host
|
|
@@ -100,7 +102,7 @@ function MenuLanguageSelector({
|
|
|
100
102
|
|
|
101
103
|
return (
|
|
102
104
|
<nav aria-label={navAriaLabel} className={className}>
|
|
103
|
-
<div className={containerClasses}>
|
|
105
|
+
<div className={containerClasses} {...extraAttributes}>
|
|
104
106
|
<ul className="usa-language__primary usa-accordion">
|
|
105
107
|
<li className="usa-language__primary-item">
|
|
106
108
|
<button
|
|
@@ -157,13 +159,14 @@ export default function LanguageSelector({
|
|
|
157
159
|
navAriaLabel = 'Language selection',
|
|
158
160
|
className = '',
|
|
159
161
|
onSelect = null,
|
|
162
|
+
extraAttributes,
|
|
160
163
|
...props
|
|
161
164
|
}: LanguageSelectorProps) {
|
|
162
165
|
const resolvedVariant = variant || (languages.length > 2 ? 'menu' : 'two');
|
|
163
166
|
const classes = classnames('usx-language-selector', className);
|
|
164
167
|
|
|
165
168
|
if (!languages || languages.length === 0) {
|
|
166
|
-
return <div className={classes}>{'LanguageSelector'}</div>;
|
|
169
|
+
return <div className={classes} {...extraAttributes}>{'LanguageSelector'}</div>;
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
if (resolvedVariant === 'two') {
|
|
@@ -174,6 +177,7 @@ export default function LanguageSelector({
|
|
|
174
177
|
onSelect={onSelect}
|
|
175
178
|
className={classes}
|
|
176
179
|
navAriaLabel={navAriaLabel}
|
|
180
|
+
extraAttributes={extraAttributes}
|
|
177
181
|
{...props}
|
|
178
182
|
/>
|
|
179
183
|
);
|
|
@@ -189,6 +193,7 @@ export default function LanguageSelector({
|
|
|
189
193
|
onSelect={onSelect}
|
|
190
194
|
className={classes}
|
|
191
195
|
navAriaLabel={navAriaLabel}
|
|
196
|
+
extraAttributes={extraAttributes}
|
|
192
197
|
{...props}
|
|
193
198
|
/>
|
|
194
199
|
);
|
|
@@ -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}
|
|
@@ -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 }}
|
|
@@ -60,12 +60,13 @@ function renderItems(items: ListItem[] = [], parentOptions: { ordered?: boolean;
|
|
|
60
60
|
|
|
61
61
|
export interface ListProps extends HTMLAttributes<HTMLUListElement | HTMLOListElement> {
|
|
62
62
|
items?: ListItem[];
|
|
63
|
+
caption?: string;
|
|
63
64
|
ordered?: boolean;
|
|
64
65
|
unstyled?: boolean;
|
|
65
66
|
className?: string;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
export default function List({ items = [], ordered = false, unstyled = false, className = '', ...props }: ListProps) {
|
|
69
|
+
export default function List({ items = [], caption, ordered = false, unstyled = false, className = '', ...props }: ListProps) {
|
|
69
70
|
const classes = ClassNames(
|
|
70
71
|
'usa-list',
|
|
71
72
|
'usx-list',
|
|
@@ -74,9 +75,16 @@ export default function List({ items = [], ordered = false, unstyled = false, cl
|
|
|
74
75
|
);
|
|
75
76
|
const Tag = ordered ? 'ol' : 'ul';
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
const list = (
|
|
78
79
|
<Tag className={classes} {...props}>
|
|
79
80
|
{renderItems(items, { ordered, unstyled })}
|
|
80
81
|
</Tag>
|
|
81
82
|
);
|
|
83
|
+
|
|
84
|
+
return caption ? (
|
|
85
|
+
<figure className="usx-list-figure">
|
|
86
|
+
<figcaption className="usx-list-figure__caption">{caption}</figcaption>
|
|
87
|
+
{list}
|
|
88
|
+
</figure>
|
|
89
|
+
) : list;
|
|
82
90
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "list",
|
|
3
3
|
"template": "list/list.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"default": {
|
|
6
6
|
"items": [
|
|
7
7
|
"List item",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"type": "object",
|
|
15
15
|
"description": "Array of list items. A string renders a simple item. Objects can include content and children for nested lists of any depth; optional ordered/unstyled/className customize nested lists."
|
|
16
16
|
},
|
|
17
|
+
"caption": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Optional label rendered in a figcaption before the list. Wraps the list in a figure when provided."
|
|
20
|
+
},
|
|
17
21
|
"ordered": {
|
|
18
22
|
"type": "boolean",
|
|
19
23
|
"default": false,
|
|
@@ -25,6 +25,32 @@
|
|
|
25
25
|
<li>List item</li>
|
|
26
26
|
</ul>
|
|
27
27
|
|
|
28
|
+
<h3 class="site-preview-heading">Captioned</h3>
|
|
29
|
+
<figure class="usx-list-figure">
|
|
30
|
+
<figcaption class="usx-list-figure__caption">Fruit</figcaption>
|
|
31
|
+
|
|
32
|
+
<ul class="usa-list usx-list">
|
|
33
|
+
<li>Apple</li>
|
|
34
|
+
|
|
35
|
+
<li>Pear</li>
|
|
36
|
+
|
|
37
|
+
<li>Orange</li>
|
|
38
|
+
</ul>
|
|
39
|
+
</figure>
|
|
40
|
+
|
|
41
|
+
<h3 class="site-preview-heading">Captioned Ordered</h3>
|
|
42
|
+
<figure class="usx-list-figure">
|
|
43
|
+
<figcaption class="usx-list-figure__caption">Application steps</figcaption>
|
|
44
|
+
|
|
45
|
+
<ol class="usa-list usx-list">
|
|
46
|
+
<li>Create an account</li>
|
|
47
|
+
|
|
48
|
+
<li>Complete the form</li>
|
|
49
|
+
|
|
50
|
+
<li>Submit your application</li>
|
|
51
|
+
</ol>
|
|
52
|
+
</figure>
|
|
53
|
+
|
|
28
54
|
<h3 class="site-preview-heading">Nested</h3>
|
|
29
55
|
<ul class="usa-list usx-list">
|
|
30
56
|
<li>Main point</li>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% load usx_components %}
|
|
2
2
|
|
|
3
|
+
{% if caption %}<figure class="usx-list-figure"><figcaption class="usx-list-figure__caption">{{ caption }}</figcaption>{% endif %}
|
|
3
4
|
{% if ordered %}
|
|
4
5
|
<ol class="usa-list usx-list{% if unstyled %} usa-list--unstyled{% endif %}{% if className %} {{ className }}{% endif %}">
|
|
5
6
|
{% include "list/_list-items.django.html" with items=items ordered=ordered unstyled=unstyled only %}
|
|
@@ -9,3 +10,4 @@
|
|
|
9
10
|
{% include "list/_list-items.django.html" with items=items ordered=ordered unstyled=unstyled only %}
|
|
10
11
|
</ul>
|
|
11
12
|
{% endif %}
|
|
13
|
+
{% if caption %}</figure>{% endif %}
|
|
@@ -19,6 +19,26 @@
|
|
|
19
19
|
<li>List item</li>
|
|
20
20
|
</ul>
|
|
21
21
|
|
|
22
|
+
<h3 class="site-preview-heading">Captioned</h3>
|
|
23
|
+
<figure class="usx-list-figure">
|
|
24
|
+
<figcaption class="usx-list-figure__caption">Fruit</figcaption>
|
|
25
|
+
<ul class="usa-list usx-list">
|
|
26
|
+
<li>Apple</li>
|
|
27
|
+
<li>Pear</li>
|
|
28
|
+
<li>Orange</li>
|
|
29
|
+
</ul>
|
|
30
|
+
</figure>
|
|
31
|
+
|
|
32
|
+
<h3 class="site-preview-heading">Captioned Ordered</h3>
|
|
33
|
+
<figure class="usx-list-figure">
|
|
34
|
+
<figcaption class="usx-list-figure__caption">Application steps</figcaption>
|
|
35
|
+
<ol class="usa-list usx-list">
|
|
36
|
+
<li>Create an account</li>
|
|
37
|
+
<li>Complete the form</li>
|
|
38
|
+
<li>Submit your application</li>
|
|
39
|
+
</ol>
|
|
40
|
+
</figure>
|
|
41
|
+
|
|
22
42
|
<h3 class="site-preview-heading">Nested</h3>
|
|
23
43
|
<ul class="usa-list usx-list">
|
|
24
44
|
<li>Main point</li>
|
|
@@ -19,6 +19,26 @@
|
|
|
19
19
|
<li>List item</li>
|
|
20
20
|
</ul>
|
|
21
21
|
|
|
22
|
+
<h3 class="site-preview-heading">Captioned</h3>
|
|
23
|
+
<figure class="usx-list-figure">
|
|
24
|
+
<figcaption class="usx-list-figure__caption">Fruit</figcaption>
|
|
25
|
+
<ul class="usa-list usx-list">
|
|
26
|
+
<li>Apple</li>
|
|
27
|
+
<li>Pear</li>
|
|
28
|
+
<li>Orange</li>
|
|
29
|
+
</ul>
|
|
30
|
+
</figure>
|
|
31
|
+
|
|
32
|
+
<h3 class="site-preview-heading">Captioned Ordered</h3>
|
|
33
|
+
<figure class="usx-list-figure">
|
|
34
|
+
<figcaption class="usx-list-figure__caption">Application steps</figcaption>
|
|
35
|
+
<ol class="usa-list usx-list">
|
|
36
|
+
<li>Create an account</li>
|
|
37
|
+
<li>Complete the form</li>
|
|
38
|
+
<li>Submit your application</li>
|
|
39
|
+
</ol>
|
|
40
|
+
</figure>
|
|
41
|
+
|
|
22
42
|
<h3 class="site-preview-heading">Nested</h3>
|
|
23
43
|
<ul class="usa-list usx-list">
|
|
24
44
|
<li>Main point</li>
|
|
@@ -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
|
|
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
|
|
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
|
|
160
|
+
{...(year !== undefined ? { value: year } : { defaultValue: defaultYear })}
|
|
161
|
+
onChange={onYearChange}
|
|
147
162
|
minLength={4}
|
|
148
163
|
maxLength={4}
|
|
149
164
|
pattern="[0-9]*"
|