@solexllc/usx-react 0.3.1 → 0.5.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 +132 -0
- package/dist/index.cjs +504 -450
- package/dist/index.js +504 -450
- package/package.json +6 -5
- package/src/assets.ts +16 -0
- package/src/components/alert/Alert.tsx +4 -3
- package/src/components/alert/alert.django.html +2 -3
- package/src/components/alert/config.json +15 -4
- package/src/components/attribution/config.json +5 -5
- package/src/components/banner/Banner.tsx +8 -6
- package/src/components/banner/banner.django.html +4 -5
- package/src/components/banner/config.json +7 -3
- package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
- package/src/components/breadcrumb/config.json +11 -1
- package/src/components/button/Button.tsx +1 -1
- package/src/components/button/button.django.html +2 -2
- package/src/components/button/button.html +2 -2
- package/src/components/button/config.json +14 -6
- package/src/components/button-group/button-group.django.html +1 -1
- package/src/components/calendar-date/calendar-date.django.html +3 -3
- package/src/components/callout/Callout.tsx +53 -0
- package/src/components/callout/callout.django.html +5 -0
- package/src/components/callout/callout.html +76 -0
- package/src/components/callout/config.json +74 -0
- package/src/components/card/Card.tsx +18 -34
- package/src/components/card/card.django.html +12 -10
- package/src/components/card/config.json +15 -40
- package/src/components/card-group/card-group.django.html +1 -1
- package/src/components/carousel/Carousel.tsx +3 -2
- package/src/components/carousel/carousel.django.html +13 -2
- package/src/components/carousel/config.json +2 -2
- package/src/components/character-count/config.json +2 -2
- package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
- package/src/components/checkbox-group/checkbox-group.django.html +10 -4
- package/src/components/checkbox-group/config.json +10 -5
- package/src/components/clickable/clickable.html +21 -39
- package/src/components/clickable/config.json +2 -2
- package/src/components/code/Code.tsx +4 -27
- package/src/components/code/code.django.html +3 -9
- package/src/components/code/config.json +4 -0
- package/src/components/collection/Collection.tsx +5 -5
- package/src/components/collection/collection.django.html +2 -4
- package/src/components/collection/config.json +7 -6
- package/src/components/combobox/config.json +4 -4
- package/src/components/copy-to-clipboard/CopyToClipboard.tsx +35 -24
- package/src/components/copy-to-clipboard/config.json +14 -7
- package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +14 -14
- package/src/components/date-picker/config.json +4 -4
- package/src/components/date-range-picker/config.json +7 -7
- package/src/components/error-message/config.json +2 -2
- package/src/components/eyebrow/Eyebrow.tsx +2 -1
- package/src/components/eyebrow/config.json +2 -2
- package/src/components/fieldset/config.json +5 -5
- package/src/components/file-input/FileInput.tsx +3 -2
- package/src/components/file-input/config.json +5 -5
- package/src/components/file-list/FileList.tsx +2 -1
- package/src/components/file-list/config.json +2 -2
- package/src/components/footer/Footer.tsx +31 -11
- package/src/components/footer/config.json +4 -0
- package/src/components/footer/footer.django.html +10 -9
- package/src/components/form-group/config.json +2 -2
- package/src/components/header/Branding.tsx +9 -6
- package/src/components/header/Header.tsx +3 -1
- package/src/components/header/config.json +4 -0
- package/src/components/header/header.django.html +5 -26
- package/src/components/header/header.html +10 -10
- package/src/components/hero/Hero.tsx +8 -14
- package/src/components/hero/config.json +36 -27
- package/src/components/hero/hero.django.html +2 -2
- package/src/components/hint/config.json +2 -2
- package/src/components/icon/Icon.tsx +6 -3
- package/src/components/icon/config.json +12 -6
- package/src/components/icon/icon.django.html +6 -4
- package/src/components/image/Image.tsx +8 -4
- package/src/components/image/config.json +10 -2
- package/src/components/image/image.django.html +8 -6
- package/src/components/in-page-nav/config.json +11 -1
- package/src/components/indicator/config.json +2 -2
- package/src/components/input/config.json +2 -2
- package/src/components/label/config.json +2 -2
- package/src/components/language-selector/config.json +2 -2
- package/src/components/layout/Layout.tsx +1 -1
- package/src/components/layout/config.json +9 -9
- package/src/components/layout/layout.django.html +1 -1
- package/src/components/legend/config.json +3 -3
- package/src/components/link/config.json +2 -2
- package/src/components/memorable-date/config.json +9 -9
- package/src/components/misc-banner/MiscBanner.tsx +2 -1
- package/src/components/misc-banner/config.json +2 -2
- package/src/components/modal/config.json +2 -2
- package/src/components/page/Page.tsx +2 -1
- package/src/components/page/config.json +7 -7
- package/src/components/page/page.django.html +1 -1
- package/src/components/pagination/Pagination.tsx +2 -1
- package/src/components/pagination/container/PaginationContainer.tsx +2 -1
- package/src/components/prose/config.json +5 -1
- package/src/components/quote/Quote.tsx +58 -0
- package/src/components/quote/config.json +51 -0
- package/src/components/quote/quote.django.html +15 -0
- package/src/components/quote/quote.html +66 -0
- package/src/components/radio-buttons/config.json +3 -3
- package/src/components/range-slider/RangeSlider.tsx +2 -1
- package/src/components/range-slider/config.json +4 -4
- package/src/components/required/config.json +2 -2
- package/src/components/section/Section.tsx +6 -2
- package/src/components/section/config.json +19 -6
- package/src/components/section/section.django.html +9 -2
- package/src/components/select/config.json +2 -2
- package/src/components/site-alert/SiteAlert.tsx +5 -6
- package/src/components/skipnav/config.json +2 -2
- package/src/components/spinner/Spinner.tsx +18 -25
- package/src/components/spinner/config.json +4 -0
- package/src/components/spinner/spinner.django.html +4 -6
- package/src/components/summary-box/config.json +3 -3
- package/src/components/swap/Swap.tsx +4 -3
- package/src/components/swap/config.json +4 -4
- package/src/components/switch/config.json +2 -2
- package/src/components/table/config.json +13 -3
- package/src/components/tag/config.json +2 -2
- package/src/components/tag-group/config.json +2 -2
- package/src/components/text-area/config.json +2 -2
- package/src/components/time-picker/config.json +4 -4
- package/src/components/toggle/Toggle.tsx +69 -40
- package/src/components/toggle/config.json +42 -10
- package/src/components/toggle/toggle.django.html +25 -17
- package/src/components/toggle/toggle.html +319 -85
- package/src/components/tooltip/Tooltip.tsx +4 -2
- package/src/components/tooltip/config.json +9 -4
- package/src/components/tooltip/tooltip.django.html +1 -1
- package/src/components/villain/Villain.tsx +2 -1
- package/src/index.js +2 -1
- package/src/components/block/Block.tsx +0 -78
- package/src/components/block/block.django.html +0 -26
- package/src/components/block/block.html +0 -162
- package/src/components/block/config.json +0 -88
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "switch",
|
|
3
3
|
"template": "switch/switch.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"id": {
|
|
7
7
|
"type": "string",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"description": "Color variant (primary, success, warning, etc.)"
|
|
36
36
|
},
|
|
37
37
|
"label": {
|
|
38
|
-
"type": "
|
|
38
|
+
"type": "slot",
|
|
39
39
|
"description": "Optional label text to display next to the switch"
|
|
40
40
|
},
|
|
41
41
|
"indeterminate": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "table",
|
|
3
3
|
"template": "table/table.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"required": [
|
|
6
6
|
"columns",
|
|
7
7
|
"data"
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"description": "Property name used as the unique row identifier."
|
|
94
94
|
},
|
|
95
95
|
"caption": {
|
|
96
|
-
"type": "
|
|
96
|
+
"type": "slot",
|
|
97
97
|
"description": "Table caption rendered as <caption>."
|
|
98
98
|
},
|
|
99
99
|
"striped": {
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
"description": "Show a loading state overlay. Does not affect interactivity."
|
|
221
221
|
},
|
|
222
222
|
"placeholder": {
|
|
223
|
-
"type": "
|
|
223
|
+
"type": "slot",
|
|
224
224
|
"description": "Content shown when the data array is empty."
|
|
225
225
|
},
|
|
226
226
|
"className": {
|
|
@@ -292,6 +292,16 @@
|
|
|
292
292
|
"type": "object",
|
|
293
293
|
"default": null,
|
|
294
294
|
"description": "Django only. Pagination state dict from table_helper.paginate_table(): {current_page, total_pages, total, page_size}. Required when paginate is True."
|
|
295
|
+
},
|
|
296
|
+
"children": {
|
|
297
|
+
"type": "slot",
|
|
298
|
+
"description": "Composed table sections, replacing the generated table sections (React only).",
|
|
299
|
+
"renderers": {
|
|
300
|
+
"django": {
|
|
301
|
+
"supported": false,
|
|
302
|
+
"description": "The Django template does not consume children."
|
|
303
|
+
}
|
|
304
|
+
}
|
|
295
305
|
}
|
|
296
306
|
}
|
|
297
307
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tag",
|
|
3
3
|
"template": "tag/tag.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"id": {
|
|
7
7
|
"type": "string",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"description": "Additional classes to add to the tag"
|
|
48
48
|
},
|
|
49
49
|
"children": {
|
|
50
|
-
"type": "
|
|
50
|
+
"type": "slot",
|
|
51
51
|
"description": "Inner HTML or text for the tag"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tag-group",
|
|
3
3
|
"template": "tag-group/tag-group.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"tagProps": {
|
|
7
7
|
"type": "array",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"children": {
|
|
16
|
-
"type": "
|
|
16
|
+
"type": "slot",
|
|
17
17
|
"description": "Inner HTML or text"
|
|
18
18
|
},
|
|
19
19
|
"className": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "text-area",
|
|
3
3
|
"template": "text-area/text-area.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"label": {
|
|
7
|
-
"type": "
|
|
7
|
+
"type": "slot",
|
|
8
8
|
"default": null,
|
|
9
9
|
"description": "The label for the textarea. If provided, renders a label element associated with the control."
|
|
10
10
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "time-picker",
|
|
3
3
|
"template": "time-picker/time-picker.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"default": {
|
|
6
6
|
"id": "appointment-time",
|
|
7
7
|
"name": "appointment-time",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"description": "name attribute for the input. Defaults to id."
|
|
20
20
|
},
|
|
21
21
|
"label": {
|
|
22
|
-
"type": "
|
|
22
|
+
"type": "slot",
|
|
23
23
|
"description": "Label text for the field."
|
|
24
24
|
},
|
|
25
25
|
"hint": {
|
|
26
|
-
"type": "
|
|
26
|
+
"type": "slot",
|
|
27
27
|
"default": "Select a time from the dropdown. Type into the input to filter options.",
|
|
28
28
|
"description": "Hint text displayed below the label."
|
|
29
29
|
},
|
|
30
30
|
"error": {
|
|
31
|
-
"type": "
|
|
31
|
+
"type": "slot",
|
|
32
32
|
"description": "Error message. Renders aria-describedby and error styling."
|
|
33
33
|
},
|
|
34
34
|
"disabled": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useId } from 'react';
|
|
2
|
+
import ClassNames from 'classnames';
|
|
2
3
|
import Icon from '../icon/Icon';
|
|
3
4
|
|
|
4
5
|
export interface ToggleOption {
|
|
@@ -8,73 +9,101 @@ export interface ToggleOption {
|
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export interface ToggleProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
12
|
+
export interface ToggleProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onChange'> {
|
|
13
|
+
className?: string;
|
|
14
|
+
id?: string;
|
|
12
15
|
options?: (ToggleOption | string | number)[];
|
|
13
16
|
value?: string | number;
|
|
14
17
|
defaultValue?: string | number;
|
|
15
18
|
onChange?: (value: string | number) => void;
|
|
16
19
|
name?: string;
|
|
17
|
-
|
|
20
|
+
ariaLabel?: string;
|
|
18
21
|
variant?: 'text' | 'icon';
|
|
19
22
|
disabled?: boolean;
|
|
20
|
-
|
|
23
|
+
required?: boolean;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
export default function Toggle({
|
|
24
27
|
options = [],
|
|
25
28
|
value,
|
|
26
29
|
defaultValue,
|
|
27
30
|
onChange,
|
|
28
31
|
name,
|
|
29
32
|
id,
|
|
33
|
+
ariaLabel,
|
|
30
34
|
variant = 'text',
|
|
31
35
|
disabled = false,
|
|
32
|
-
|
|
36
|
+
required = false,
|
|
37
|
+
className,
|
|
38
|
+
'aria-label': nativeAriaLabel,
|
|
39
|
+
'aria-labelledby': labelledBy,
|
|
33
40
|
...props
|
|
34
|
-
})
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
'usx-button-group',
|
|
40
|
-
'usa-button-group--segmented',
|
|
41
|
-
'usx-toggle',
|
|
42
|
-
variant === 'icon' ? 'usx-toggle--icon' : '',
|
|
43
|
-
className
|
|
44
|
-
].filter(Boolean).join(' ');
|
|
41
|
+
}: ToggleProps) {
|
|
42
|
+
const instanceId = useId();
|
|
43
|
+
const groupId = id || `toggle-${instanceId}`;
|
|
44
|
+
const groupName = name || groupId;
|
|
45
|
+
const controlled = value !== undefined;
|
|
45
46
|
return (
|
|
46
|
-
<ul
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
<ul
|
|
48
|
+
{...props}
|
|
49
|
+
id={groupId}
|
|
50
|
+
className={ClassNames(
|
|
51
|
+
'usx-toggle',
|
|
52
|
+
'usa-button-group',
|
|
53
|
+
variant === 'icon' && 'usx-toggle--icon',
|
|
54
|
+
className
|
|
55
|
+
)}
|
|
56
|
+
role="radiogroup"
|
|
57
|
+
aria-labelledby={labelledBy}
|
|
58
|
+
aria-label={
|
|
59
|
+
labelledBy ? undefined : ariaLabel || nativeAriaLabel || name || 'Choose an option'
|
|
60
|
+
}
|
|
61
|
+
aria-disabled={disabled || undefined}
|
|
62
|
+
aria-required={required || undefined}
|
|
63
|
+
>
|
|
64
|
+
{options.map((option, index) => {
|
|
65
|
+
const opt = typeof option === 'object' ? option : { value: option, label: option };
|
|
66
|
+
const optionValue =
|
|
67
|
+
opt.value ??
|
|
68
|
+
(typeof opt.label === 'string' || typeof opt.label === 'number' ? opt.label : index);
|
|
69
|
+
const optionLabel = opt.label ?? String(optionValue);
|
|
70
|
+
const inputId = `${groupId}-option-${index}`;
|
|
71
|
+
const iconOnly = variant === 'icon' && Boolean(opt.icon);
|
|
53
72
|
return (
|
|
54
|
-
<li key={inputId} className=
|
|
73
|
+
<li key={inputId} className="usa-button-group__item" role="presentation">
|
|
55
74
|
<input
|
|
56
75
|
className="usx-toggle__input"
|
|
57
76
|
type="radio"
|
|
58
77
|
id={inputId}
|
|
59
|
-
name={
|
|
60
|
-
value={
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
name={groupName}
|
|
79
|
+
value={optionValue}
|
|
80
|
+
{...(controlled
|
|
81
|
+
? { checked: value === optionValue }
|
|
82
|
+
: { defaultChecked: defaultValue === optionValue })}
|
|
83
|
+
disabled={disabled || opt.disabled}
|
|
84
|
+
required={required}
|
|
85
|
+
onChange={(event) => {
|
|
86
|
+
if (event.target.checked) onChange?.(optionValue);
|
|
87
|
+
}}
|
|
65
88
|
/>
|
|
66
|
-
<label
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
<label
|
|
90
|
+
htmlFor={inputId}
|
|
91
|
+
className="usa-button usx-button usa-button--primary usx-toggle__button"
|
|
92
|
+
aria-disabled={disabled || opt.disabled || undefined}
|
|
93
|
+
title={
|
|
94
|
+
iconOnly && (typeof optionLabel === 'string' || typeof optionLabel === 'number')
|
|
95
|
+
? String(optionLabel)
|
|
96
|
+
: undefined
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
{opt.icon && <Icon name={opt.icon} className="usx-toggle__icon" aria-hidden="true" />}
|
|
100
|
+
<span className={iconOnly ? 'usa-sr-only' : undefined}>
|
|
101
|
+
{optionLabel}
|
|
102
|
+
</span>
|
|
72
103
|
</label>
|
|
73
104
|
</li>
|
|
74
105
|
);
|
|
75
106
|
})}
|
|
76
107
|
</ul>
|
|
77
108
|
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default Toggle;
|
|
109
|
+
}
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toggle",
|
|
3
3
|
"template": "toggle/toggle.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"required": [
|
|
6
6
|
"options"
|
|
7
7
|
],
|
|
8
8
|
"props": {
|
|
9
9
|
"id": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "ID for the control (used as prefix for option IDs)"
|
|
11
|
+
"description": "ID for the control (used as prefix for option IDs). Supply a unique ID in Django."
|
|
12
12
|
},
|
|
13
13
|
"options": {
|
|
14
14
|
"type": "array",
|
|
15
|
-
"description": "
|
|
15
|
+
"description": "Options as strings, numbers, or objects with value, label, icon, and disabled. Django requires option objects with value and label. Use distinct values and a label for every icon option.",
|
|
16
16
|
"items": {
|
|
17
|
-
"type":
|
|
17
|
+
"type": [
|
|
18
|
+
"object",
|
|
19
|
+
"string",
|
|
20
|
+
"number"
|
|
21
|
+
],
|
|
18
22
|
"description": "Toggle option.",
|
|
19
23
|
"properties": {
|
|
20
24
|
"value": {
|
|
21
|
-
"type":
|
|
25
|
+
"type": [
|
|
26
|
+
"string",
|
|
27
|
+
"number"
|
|
28
|
+
],
|
|
22
29
|
"description": "Option value."
|
|
23
30
|
},
|
|
24
31
|
"label": {
|
|
25
|
-
"type": "
|
|
32
|
+
"type": "slot",
|
|
26
33
|
"description": "Option display label."
|
|
27
34
|
},
|
|
28
35
|
"icon": {
|
|
@@ -37,11 +44,17 @@
|
|
|
37
44
|
}
|
|
38
45
|
},
|
|
39
46
|
"value": {
|
|
40
|
-
"type":
|
|
47
|
+
"type": [
|
|
48
|
+
"string",
|
|
49
|
+
"number"
|
|
50
|
+
],
|
|
41
51
|
"description": "Controlled selected value"
|
|
42
52
|
},
|
|
43
53
|
"defaultValue": {
|
|
44
|
-
"type":
|
|
54
|
+
"type": [
|
|
55
|
+
"string",
|
|
56
|
+
"number"
|
|
57
|
+
],
|
|
45
58
|
"description": "Uncontrolled initial value"
|
|
46
59
|
},
|
|
47
60
|
"name": {
|
|
@@ -54,7 +67,8 @@
|
|
|
54
67
|
"text",
|
|
55
68
|
"icon"
|
|
56
69
|
],
|
|
57
|
-
"description": "Visual variant"
|
|
70
|
+
"description": "Visual variant",
|
|
71
|
+
"default": "text"
|
|
58
72
|
},
|
|
59
73
|
"disabled": {
|
|
60
74
|
"type": "boolean",
|
|
@@ -63,7 +77,25 @@
|
|
|
63
77
|
},
|
|
64
78
|
"className": {
|
|
65
79
|
"type": "string",
|
|
66
|
-
"description": "Additional classes"
|
|
80
|
+
"description": "Additional classes for the toggle list"
|
|
81
|
+
},
|
|
82
|
+
"ariaLabel": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Accessible name for the radio group. Defaults to name when omitted."
|
|
85
|
+
},
|
|
86
|
+
"required": {
|
|
87
|
+
"type": "boolean",
|
|
88
|
+
"default": false,
|
|
89
|
+
"description": "Require a choice for native form submission."
|
|
90
|
+
},
|
|
91
|
+
"onChange": {
|
|
92
|
+
"type": "function",
|
|
93
|
+
"description": "React callback receiving the selected string or number.",
|
|
94
|
+
"renderers": {
|
|
95
|
+
"django": {
|
|
96
|
+
"supported": false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
67
99
|
}
|
|
68
100
|
}
|
|
69
101
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
{# Django template for Toggle using USWDS segmented button group #}
|
|
2
1
|
{% load components %}
|
|
3
|
-
|
|
4
|
-
<ul class="
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
{% spaceless %}
|
|
3
|
+
<ul id="{{ id }}" class="usx-toggle usa-button-group{% if variant == 'icon' %} usx-toggle--icon{% endif %}{% if className %} {{ className }}{% endif %}" role="radiogroup" aria-label="{% firstof ariaLabel name 'Choose an option' %}"{% if disabled %} aria-disabled="true"{% endif %}{% if required %} aria-required="true"{% endif %}>
|
|
4
|
+
{% for option in options %}
|
|
5
|
+
{% with optionSuffix=option.value|stringformat:"s" %}
|
|
6
|
+
{% with optionId=id|add:"-"|add:optionSuffix %}
|
|
7
|
+
<li class="usa-button-group__item" role="presentation">
|
|
8
|
+
<input
|
|
9
|
+
class="usx-toggle__input"
|
|
10
|
+
id="{{ optionId }}"
|
|
11
|
+
type="radio"
|
|
12
|
+
name="{% firstof name id "toggle-group" %}"
|
|
13
|
+
value="{{ option.value }}"
|
|
14
|
+
{% if value != None %}{% if value == option.value %}checked="checked"{% endif %}{% elif defaultValue == option.value or option.checked %}checked="checked"{% endif %}
|
|
15
|
+
{% if disabled or option.disabled %}disabled="disabled"{% endif %}
|
|
16
|
+
{% if required %}required="required"{% endif %}
|
|
17
|
+
>
|
|
18
|
+
<label for="{{ optionId }}" class="usa-button usx-button usa-button--primary usx-toggle__button"{% if disabled or option.disabled %} aria-disabled="true"{% endif %}{% if variant == 'icon' and option.icon %} title="{{ option.label|striptags }}"{% endif %}>
|
|
19
|
+
{% if option.icon %}{% icon name=option.icon className="usx-toggle__icon" %}{% endicon %}{% endif %}
|
|
20
|
+
<span{% if variant == 'icon' and option.icon %} class="usa-sr-only"{% endif %}>{{ option.label|safe }}</span>
|
|
21
|
+
</label>
|
|
22
|
+
</li>
|
|
23
|
+
{% endwith %}
|
|
24
|
+
{% endwith %}
|
|
25
|
+
{% endfor %}
|
|
19
26
|
</ul>
|
|
27
|
+
{% endspaceless %}
|