@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
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
id="{{ id }}"
|
|
21
21
|
class="usa-input usx-input"
|
|
22
22
|
placeholder="{{ placeholder }}"
|
|
23
|
-
value="{{ defaultValue }}"
|
|
23
|
+
value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"
|
|
24
24
|
type="search"
|
|
25
25
|
name="{{ searchKey|default:'q' }}"
|
|
26
26
|
/>
|
|
@@ -391,3 +391,28 @@
|
|
|
391
391
|
</button>
|
|
392
392
|
</form>
|
|
393
393
|
</section>
|
|
394
|
+
|
|
395
|
+
<h3 class="site-preview-heading">With Value</h3>
|
|
396
|
+
<section aria-label="Search">
|
|
397
|
+
<form id="react-search-value-form" class="usa-search" method="get" role="search">
|
|
398
|
+
<label class="usa-label usx-label usa-sr-only" for="react-search-value">Search</label
|
|
399
|
+
><input
|
|
400
|
+
id="react-search-value"
|
|
401
|
+
class="usa-input usx-input"
|
|
402
|
+
placeholder=""
|
|
403
|
+
type="search"
|
|
404
|
+
name="q"
|
|
405
|
+
value="Current search"
|
|
406
|
+
/><button type="submit" class="usa-button usx-button usa-button--primary">
|
|
407
|
+
<span class="usa-search__submit-text">Search</span
|
|
408
|
+
><svg
|
|
409
|
+
class="usa-icon usx-icon usa-search__submit-icon"
|
|
410
|
+
aria-hidden="true"
|
|
411
|
+
focusable="false"
|
|
412
|
+
role="img"
|
|
413
|
+
>
|
|
414
|
+
<use href="/img/sprite.svg#search"></use>
|
|
415
|
+
</svg>
|
|
416
|
+
</button>
|
|
417
|
+
</form>
|
|
418
|
+
</section>
|
|
@@ -17,6 +17,7 @@ export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement
|
|
|
17
17
|
name?: string;
|
|
18
18
|
options?: SelectOption[];
|
|
19
19
|
defaultValue?: string;
|
|
20
|
+
value?: string;
|
|
20
21
|
placeholder?: string;
|
|
21
22
|
error?: string;
|
|
22
23
|
success?: string;
|
|
@@ -33,6 +34,7 @@ export default function Select({
|
|
|
33
34
|
name,
|
|
34
35
|
options = [],
|
|
35
36
|
defaultValue,
|
|
37
|
+
value,
|
|
36
38
|
placeholder = 'Select an option',
|
|
37
39
|
error,
|
|
38
40
|
success,
|
|
@@ -71,7 +73,7 @@ export default function Select({
|
|
|
71
73
|
className: combinedSelectClasses,
|
|
72
74
|
disabled,
|
|
73
75
|
required: required || undefined,
|
|
74
|
-
defaultValue,
|
|
76
|
+
...(value !== undefined ? { value } : { defaultValue }),
|
|
75
77
|
'aria-describedby': describedByParts.length ? describedByParts.join(' ') : undefined,
|
|
76
78
|
'aria-invalid': hasError ? true : undefined,
|
|
77
79
|
...props,
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"default": null,
|
|
46
46
|
"description": "Default selected value for the select input"
|
|
47
47
|
},
|
|
48
|
+
"value": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"default": null,
|
|
51
|
+
"description": "Current selected option. Takes precedence over defaultValue."
|
|
52
|
+
},
|
|
48
53
|
"placeholder": {
|
|
49
54
|
"type": "string",
|
|
50
55
|
"default": "Select an option",
|
|
@@ -144,3 +144,18 @@
|
|
|
144
144
|
<option value="option3">Option C</option>
|
|
145
145
|
</select>
|
|
146
146
|
</div>
|
|
147
|
+
|
|
148
|
+
<h3 class="site-preview-heading">Value</h3>
|
|
149
|
+
<div class="usa-form-group usx-form-group">
|
|
150
|
+
<label class="usa-label usx-label" for="django-select-value"> Current selection </label>
|
|
151
|
+
|
|
152
|
+
<select class="usa-select usx-select" id="django-select-value">
|
|
153
|
+
<option value="">Select an option</option>
|
|
154
|
+
|
|
155
|
+
<option value="option1">Option A</option>
|
|
156
|
+
|
|
157
|
+
<option value="option2">Option B</option>
|
|
158
|
+
|
|
159
|
+
<option value="option3" selected>Option C</option>
|
|
160
|
+
</select>
|
|
161
|
+
</div>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<option value="">{{ placeholder|default:'Select an option' }}</option>
|
|
24
24
|
{% for option in options %}
|
|
25
25
|
{% with optionValue=option.value|default:option optionLabel=option.label|default:option %}
|
|
26
|
-
<option value="{{ optionValue }}" {% if optionValue == defaultValue %}selected{% endif %}>{{ optionLabel }}</option>
|
|
26
|
+
<option value="{{ optionValue }}" {% if value is not None and optionValue == value or value is None and optionValue == defaultValue %}selected{% endif %}>{{ optionLabel }}</option>
|
|
27
27
|
{% endwith %}
|
|
28
28
|
{% endfor %}
|
|
29
29
|
</select>
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
<option value="">{{ placeholder|default:'Select an option' }}</option>
|
|
55
55
|
{% for option in options %}
|
|
56
56
|
{% with optionValue=option.value|default:option optionLabel=option.label|default:option %}
|
|
57
|
-
<option value="{{ optionValue }}" {% if optionValue == defaultValue %}selected{% endif %}>{{ optionLabel }}</option>
|
|
57
|
+
<option value="{{ optionValue }}" {% if value is not None and optionValue == value or value is None and optionValue == defaultValue %}selected{% endif %}>{{ optionLabel }}</option>
|
|
58
58
|
{% endwith %}
|
|
59
59
|
{% endfor %}
|
|
60
60
|
</select>
|
|
@@ -102,3 +102,14 @@
|
|
|
102
102
|
<option value="option3">Option C</option>
|
|
103
103
|
</select>
|
|
104
104
|
</div>
|
|
105
|
+
|
|
106
|
+
<h3 class="site-preview-heading">Value</h3>
|
|
107
|
+
<div class="usa-form-group usx-form-group">
|
|
108
|
+
<label class="usa-label usx-label" for="react-select-value">Current selection</label
|
|
109
|
+
><select id="react-select-value" class="usa-select usx-select">
|
|
110
|
+
<option value="">Select an option</option>
|
|
111
|
+
<option value="option1">Option A</option>
|
|
112
|
+
<option value="option2">Option B</option>
|
|
113
|
+
<option value="option3" selected="">Option C</option>
|
|
114
|
+
</select>
|
|
115
|
+
</div>
|
|
@@ -1,73 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
indeterminate?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Switch: React.FC<SwitchProps> = ({
|
|
19
|
-
id,
|
|
20
|
-
name,
|
|
21
|
-
checked,
|
|
22
|
-
defaultChecked,
|
|
23
|
-
disabled = false,
|
|
24
|
-
onChange,
|
|
25
|
-
size = 'md',
|
|
26
|
-
variant = '',
|
|
27
|
-
className = '',
|
|
28
|
-
label,
|
|
29
|
-
indeterminate = false,
|
|
30
|
-
...props
|
|
31
|
-
}) => {
|
|
32
|
-
const classes = ClassNames(
|
|
33
|
-
'usx-switch',
|
|
34
|
-
size && `usx-toggle-${size}`,
|
|
35
|
-
variant && `text-${variant}`,
|
|
36
|
-
className,
|
|
3
|
+
import Checkbox, { type CheckboxProps } from '../checkbox/Checkbox';
|
|
4
|
+
|
|
5
|
+
export type SwitchProps = CheckboxProps & { color?: string };
|
|
6
|
+
|
|
7
|
+
/** A checkbox with a switch-shaped control. Its form behavior is Checkbox's behavior. */
|
|
8
|
+
export default function Switch({ className, labelClassName, color, ...props }: SwitchProps) {
|
|
9
|
+
return (
|
|
10
|
+
<Checkbox
|
|
11
|
+
{...props}
|
|
12
|
+
className={ClassNames('usx-switch', className)}
|
|
13
|
+
labelClassName={ClassNames(labelClassName, color && `before-${color}`)}
|
|
14
|
+
/>
|
|
37
15
|
);
|
|
38
|
-
|
|
39
|
-
const ref = React.useRef<HTMLInputElement>(null);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
if (ref.current) {
|
|
42
|
-
ref.current.indeterminate = Boolean(indeterminate);
|
|
43
|
-
}
|
|
44
|
-
}, [indeterminate]);
|
|
45
|
-
|
|
46
|
-
const inputProps = {
|
|
47
|
-
id,
|
|
48
|
-
name,
|
|
49
|
-
type: 'checkbox',
|
|
50
|
-
className: classes,
|
|
51
|
-
checked: typeof checked === 'boolean' ? checked : undefined,
|
|
52
|
-
defaultChecked,
|
|
53
|
-
disabled,
|
|
54
|
-
'aria-checked': indeterminate ? 'mixed' : (typeof checked === 'boolean' ? checked : undefined),
|
|
55
|
-
onChange,
|
|
56
|
-
...props,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const input = <input ref={ref} {...inputProps} />;
|
|
60
|
-
|
|
61
|
-
if (label) {
|
|
62
|
-
return (
|
|
63
|
-
<label className="usa-label usx-switch__label">
|
|
64
|
-
{input}
|
|
65
|
-
{label}
|
|
66
|
-
</label>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return input;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export default Switch;
|
|
16
|
+
}
|
|
@@ -1,58 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "switch",
|
|
3
3
|
"template": "switch/switch.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 3,
|
|
5
5
|
"default": {
|
|
6
|
-
"id": "switch-1"
|
|
6
|
+
"id": "example-switch-1",
|
|
7
|
+
"name": "example-1",
|
|
8
|
+
"value": "example-value-1",
|
|
9
|
+
"label": "Example Switch 1"
|
|
7
10
|
},
|
|
8
11
|
"props": {
|
|
9
12
|
"id": {
|
|
10
13
|
"type": "string",
|
|
11
|
-
"description": "
|
|
14
|
+
"description": "Unique identifier for the switch input"
|
|
12
15
|
},
|
|
13
16
|
"name": {
|
|
14
17
|
"type": "string",
|
|
15
|
-
"description": "
|
|
18
|
+
"description": "Name attribute for the switch input, used for form submission"
|
|
19
|
+
},
|
|
20
|
+
"value": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Value attribute for the switch input"
|
|
23
|
+
},
|
|
24
|
+
"label": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Visible label for the switch"
|
|
16
27
|
},
|
|
17
28
|
"checked": {
|
|
18
29
|
"type": "boolean",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
30
|
+
"default": null,
|
|
31
|
+
"description": "Whether the switch is checked"
|
|
21
32
|
},
|
|
22
33
|
"defaultChecked": {
|
|
23
34
|
"type": "boolean",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
35
|
+
"default": null,
|
|
36
|
+
"description": "Initial checked state when checked is not supplied."
|
|
37
|
+
},
|
|
38
|
+
"ariaLabel": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Accessible name when a visible label is unsuitable."
|
|
26
41
|
},
|
|
27
42
|
"disabled": {
|
|
28
43
|
"type": "boolean",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
44
|
+
"default": false,
|
|
45
|
+
"description": "Whether the switch is disabled"
|
|
31
46
|
},
|
|
32
|
-
"
|
|
47
|
+
"description": {
|
|
33
48
|
"type": "string",
|
|
34
|
-
"
|
|
49
|
+
"default": null,
|
|
50
|
+
"description": "Optional description text that provides additional information about the switch"
|
|
51
|
+
},
|
|
52
|
+
"tile": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"default": false,
|
|
55
|
+
"description": "Whether to use the tile switch style"
|
|
56
|
+
},
|
|
57
|
+
"small": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"default": false,
|
|
60
|
+
"description": "Whether to use the compact switch style"
|
|
35
61
|
},
|
|
36
|
-
"
|
|
62
|
+
"error": {
|
|
37
63
|
"type": "string",
|
|
38
|
-
"
|
|
64
|
+
"default": null,
|
|
65
|
+
"description": "Error message to display when the switch is in an error state"
|
|
39
66
|
},
|
|
40
|
-
"
|
|
41
|
-
"type": "
|
|
42
|
-
"
|
|
67
|
+
"success": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"default": null,
|
|
70
|
+
"description": "Success message to display when the switch is in a success state"
|
|
43
71
|
},
|
|
44
|
-
"
|
|
72
|
+
"formGroup": {
|
|
45
73
|
"type": "boolean",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
74
|
+
"default": true,
|
|
75
|
+
"description": "Wrap the switch and its message in a form group. Set false inside another form group."
|
|
48
76
|
},
|
|
49
|
-
"
|
|
77
|
+
"color": {
|
|
50
78
|
"type": "string",
|
|
51
|
-
"description": "
|
|
79
|
+
"description": "Color of the checked track, applied as before-{color} on the label. Defaults to primary."
|
|
52
80
|
},
|
|
53
81
|
"className": {
|
|
54
82
|
"type": "string",
|
|
55
|
-
"description": "Additional
|
|
83
|
+
"description": "Additional classes on the switch container."
|
|
84
|
+
},
|
|
85
|
+
"onChange": {
|
|
86
|
+
"type": "function",
|
|
87
|
+
"description": "Function called when the switch value changes (React) or JavaScript code string for onchange attribute (Django)"
|
|
88
|
+
},
|
|
89
|
+
"required": {
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"default": false,
|
|
92
|
+
"description": "Whether the switch is required, adds asterisk to label and required attribute to input"
|
|
56
93
|
}
|
|
57
94
|
}
|
|
58
95
|
}
|