@solexllc/usx-react 0.12.0 → 1.0.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 +15 -0
- package/dist/{Popover-BzDCTuQM.cjs → Popover-Bg4-2-cU.cjs} +3 -0
- package/dist/{Popover-LToVWsWc.js → Popover-CqHczzNE.js} +3 -0
- package/dist/chat.cjs +7 -2
- package/dist/chat.js +7 -2
- package/dist/index.cjs +83 -56
- package/dist/index.js +86 -59
- package/package.json +4 -4
- package/src/components/accordion/Accordion.tsx +9 -57
- package/src/components/accordion/accordion.django.html +10 -20
- package/src/components/accordion/config.json +8 -2
- package/src/components/accordion-item/AccordionItem.tsx +54 -0
- package/src/components/accordion-item/accordion-item.django.html +19 -0
- package/src/components/accordion-item/accordion-item.html +8 -0
- package/src/components/accordion-item/config.json +55 -0
- package/src/components/alert/alert.django-snapshot.html +4 -4
- package/src/components/avatar/avatar.django-snapshot.html +6 -2
- package/src/components/avatar/avatar.react-snapshot.html +6 -3
- package/src/components/avatar/config.json +4 -2
- package/src/components/avatar-group/avatar-group.django-snapshot.html +176 -176
- package/src/components/avatar-group/avatar-group.react-snapshot.html +198 -167
- package/src/components/avatar-group/config.json +12 -6
- package/src/components/banner/banner.django-snapshot.html +2 -2
- package/src/components/button/Button.tsx +3 -0
- package/src/components/button/button.django-snapshot.html +64 -0
- package/src/components/button/button.django.html +2 -0
- package/src/components/button/button.react-snapshot.html +64 -0
- package/src/components/button/config.json +6 -1
- package/src/components/card/card.django-snapshot.html +43 -0
- package/src/components/card/card.react-snapshot.html +36 -0
- package/src/components/chat/chat.django-snapshot.html +90 -26
- package/src/components/chat/chat.html +10 -10
- package/src/components/chat/chat.react-snapshot.html +49 -49
- package/src/components/chat-composer/ChatComposer.tsx +3 -0
- package/src/components/chat-composer/chat-composer.django-snapshot.html +10 -10
- package/src/components/chat-composer/chat-composer.django.html +2 -2
- package/src/components/chat-composer/chat-composer.html +10 -10
- package/src/components/chat-composer/chat-composer.react-snapshot.html +10 -10
- package/src/components/chat-composer/chat-formatting.django.html +8 -8
- package/src/components/chat-window/ChatWindow.tsx +3 -1
- package/src/components/chat-window/chat-window.django-snapshot.html +7 -5
- package/src/components/chat-window/chat-window.django.html +3 -3
- package/src/components/chat-window/chat-window.html +1 -1
- package/src/components/chat-window/chat-window.react-snapshot.html +7 -7
- package/src/components/checkbox/checkbox.django-snapshot.html +2 -2
- package/src/components/data-table/data-table.django-snapshot.html +4 -5
- package/src/components/data-table/data-table.react-snapshot.html +4 -4
- package/src/components/drawer/drawer.django-snapshot.html +53 -30
- package/src/components/error-page/error-page.django-snapshot.html +20 -7
- package/src/components/fieldset/fieldset.django-snapshot.html +1 -6
- package/src/components/form-group/form-group.django-snapshot.html +0 -2
- package/src/components/header/header.django-snapshot.html +3 -3
- package/src/components/header/header.html +1 -1
- package/src/components/header/header.react-snapshot.html +3 -3
- package/src/components/identifier/config.json +4 -2
- package/src/components/identifier/identifier.django-snapshot.html +13 -16
- package/src/components/identifier/identifier.react-snapshot.html +13 -15
- package/src/components/image/image.django-snapshot.html +6 -6
- package/src/components/layout/layout.django-snapshot.html +2 -0
- package/src/components/modal/Modal.tsx +4 -3
- package/src/components/modal/config.json +3 -2
- package/src/components/modal/modal.django-snapshot.html +70 -14
- package/src/components/modal/modal.django.html +7 -9
- package/src/components/modal/modal.html +4 -4
- package/src/components/modal/modal.react-snapshot.html +64 -4
- package/src/components/page/Page.tsx +10 -7
- package/src/components/page/page.django-snapshot.html +5 -8
- package/src/components/page/page.django.html +2 -2
- package/src/components/page/page.html +1 -2
- package/src/components/page/page.react-snapshot.html +5 -8
- package/src/components/pagination/navigation/PaginationNavigation.tsx +2 -0
- package/src/components/pagination/navigation/pagination-navigation.django.html +2 -0
- package/src/components/pagination/pagination.django-snapshot.html +62 -0
- package/src/components/pagination/pagination.django.html +3 -1
- package/src/components/pagination/pagination.html +46 -0
- package/src/components/pagination/pagination.react-snapshot.html +48 -0
- package/src/components/pagination/summary/PaginationSummary.tsx +1 -1
- package/src/components/pagination/summary/pagination-summary.django.html +1 -1
- package/src/components/popover/Popover.tsx +1 -0
- package/src/components/popover/popover.django-snapshot.html +37 -1
- package/src/components/popover/popover.django.html +1 -1
- package/src/components/popover/popover.react-snapshot.html +30 -3
- package/src/components/section/Section.tsx +3 -1
- package/src/components/site-alert/site-alert.django-snapshot.html +8 -8
- package/src/components/swap/Swap.tsx +35 -3
- package/src/components/swap/config.json +28 -1
- package/src/components/swap/swap.django-snapshot.html +29 -7
- package/src/components/swap/swap.django.html +15 -1
- package/src/components/swap/swap.react-snapshot.html +34 -4
- package/src/components/theme-picker/ThemePicker.tsx +48 -42
- package/src/components/theme-picker/config.json +27 -29
- package/src/components/theme-picker/theme-picker-select.django.html +1 -1
- package/src/components/theme-picker/theme-picker.django-snapshot.html +283 -78
- package/src/components/theme-picker/theme-picker.django.html +24 -11
- package/src/components/theme-picker/theme-picker.html +155 -54
- package/src/components/theme-picker/theme-picker.react-snapshot.html +265 -67
- package/src/index.js +1 -0
|
@@ -2,14 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
3
|
import Icon from '../icon/Icon';
|
|
4
4
|
import Label from '../label/Label';
|
|
5
|
+
import Popover, { type PopoverAlign } from '../popover/Popover';
|
|
5
6
|
import Swap from '../swap/Swap';
|
|
6
7
|
|
|
7
8
|
export interface ThemePickerOption {
|
|
9
|
+
/** Value written to <html data-usx-theme>. */
|
|
8
10
|
value: string;
|
|
9
11
|
label: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export type ThemePickerVariant = 'default' | 'swap' | '
|
|
14
|
+
export type ThemePickerVariant = 'default' | 'swap' | 'popover';
|
|
13
15
|
|
|
14
16
|
export interface ThemePickerProps {
|
|
15
17
|
id?: string;
|
|
@@ -18,9 +20,10 @@ export interface ThemePickerProps {
|
|
|
18
20
|
themes?: ThemePickerOption[];
|
|
19
21
|
/** Swap uses the first option for light and the second for dark. */
|
|
20
22
|
variant?: ThemePickerVariant;
|
|
23
|
+
/** Alignment of the panel when variant is popover. */
|
|
24
|
+
popoverAlign?: PopoverAlign;
|
|
21
25
|
value?: string;
|
|
22
26
|
defaultValue?: string;
|
|
23
|
-
onChange?: (value: string) => void;
|
|
24
27
|
className?: string;
|
|
25
28
|
extraAttributes?: Record<string, unknown>;
|
|
26
29
|
}
|
|
@@ -31,34 +34,24 @@ export default function ThemePicker({
|
|
|
31
34
|
label = 'Theme',
|
|
32
35
|
themes = [],
|
|
33
36
|
variant = 'default',
|
|
37
|
+
popoverAlign = 'start',
|
|
34
38
|
value,
|
|
35
39
|
defaultValue,
|
|
36
|
-
onChange,
|
|
37
40
|
className = '',
|
|
38
41
|
extraAttributes,
|
|
39
42
|
}: ThemePickerProps) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const selectedLabel = themes.find((option) => option.value === selectedValue)?.label ?? label;
|
|
44
|
-
const choose = (next: string) => {
|
|
45
|
-
if (value === undefined) setLocalValue(next);
|
|
46
|
-
onChange?.(next);
|
|
47
|
-
};
|
|
48
|
-
const select = (hidden = false) => (
|
|
43
|
+
const fieldId = id || 'theme-picker';
|
|
44
|
+
const selectedValue = value ?? defaultValue ?? themes[0]?.value ?? '';
|
|
45
|
+
const select = () => (
|
|
49
46
|
<>
|
|
50
|
-
<Label htmlFor={
|
|
47
|
+
<Label htmlFor={fieldId} screenReaderOnly>
|
|
51
48
|
{label}
|
|
52
49
|
</Label>
|
|
53
50
|
<select
|
|
54
|
-
id={
|
|
51
|
+
id={fieldId}
|
|
55
52
|
name={name}
|
|
56
|
-
className=
|
|
57
|
-
|
|
58
|
-
hidden && 'usx-theme-picker__select--hidden'
|
|
59
|
-
)}
|
|
60
|
-
value={selectedValue}
|
|
61
|
-
onChange={(event) => choose(event.target.value)}
|
|
53
|
+
className="usa-select usx-select"
|
|
54
|
+
defaultValue={selectedValue}
|
|
62
55
|
>
|
|
63
56
|
{themes.map((option) => (
|
|
64
57
|
<option key={option.value} value={option.value}>
|
|
@@ -77,6 +70,7 @@ export default function ThemePicker({
|
|
|
77
70
|
className
|
|
78
71
|
)}
|
|
79
72
|
{...extraAttributes}
|
|
73
|
+
hidden
|
|
80
74
|
>
|
|
81
75
|
{variant === 'default' && (
|
|
82
76
|
<>
|
|
@@ -85,11 +79,11 @@ export default function ThemePicker({
|
|
|
85
79
|
className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
|
|
86
80
|
aria-label={label}
|
|
87
81
|
aria-expanded="false"
|
|
88
|
-
aria-controls={`${
|
|
82
|
+
aria-controls={`${fieldId}-panel`}
|
|
89
83
|
>
|
|
90
84
|
<Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
|
|
91
85
|
</button>
|
|
92
|
-
<div id={`${
|
|
86
|
+
<div id={`${fieldId}-panel`} className="usx-theme-picker__panel">
|
|
93
87
|
{select()}
|
|
94
88
|
<button
|
|
95
89
|
type="button"
|
|
@@ -104,32 +98,44 @@ export default function ThemePicker({
|
|
|
104
98
|
{variant === 'swap' && (
|
|
105
99
|
<>
|
|
106
100
|
<Swap
|
|
107
|
-
|
|
101
|
+
as="button"
|
|
102
|
+
className="usx-theme-picker__swap usx-button--ghost usx-button--tight"
|
|
108
103
|
variant="rotate"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
event.stopPropagation();
|
|
114
|
-
choose(themes[event.target.checked ? 1 : 0]?.value ?? '');
|
|
115
|
-
},
|
|
116
|
-
}}
|
|
104
|
+
defaultPressed={selectedValue === themes[1]?.value}
|
|
105
|
+
ariaLabel={`${themes[1]?.label ?? ''} ${label}`.trim()}
|
|
106
|
+
data-usx-theme-off={themes[0]?.value}
|
|
107
|
+
data-usx-theme-on={themes[1]?.value}
|
|
117
108
|
offContent={<Icon name="sun" source="usx" className="usx-theme-picker__icon" />}
|
|
118
109
|
onContent={<Icon name="moon" source="usx" className="usx-theme-picker__icon" />}
|
|
119
110
|
/>
|
|
120
|
-
<
|
|
111
|
+
<input id={fieldId} type="hidden" name={name} defaultValue={selectedValue} />
|
|
121
112
|
</>
|
|
122
113
|
)}
|
|
123
|
-
{variant === '
|
|
124
|
-
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
114
|
+
{variant === 'popover' && (
|
|
115
|
+
<>
|
|
116
|
+
<Popover
|
|
117
|
+
id={`${fieldId}-panel`}
|
|
118
|
+
className="usx-theme-picker__popover"
|
|
119
|
+
align={popoverAlign}
|
|
120
|
+
panelShape="square"
|
|
121
|
+
summaryProps={{
|
|
122
|
+
className: 'usa-button usx-button usx-button--ghost usx-button--tight margin-0',
|
|
123
|
+
ariaLabel: label,
|
|
124
|
+
children: (
|
|
125
|
+
<Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
|
|
126
|
+
),
|
|
127
|
+
}}
|
|
128
|
+
menuItems={themes.map((theme) => ({
|
|
129
|
+
type: 'button',
|
|
130
|
+
text: theme.label,
|
|
131
|
+
extraAttributes: {
|
|
132
|
+
'data-usx-theme-value': theme.value,
|
|
133
|
+
'aria-pressed': theme.value === selectedValue,
|
|
134
|
+
},
|
|
135
|
+
}))}
|
|
136
|
+
/>
|
|
137
|
+
<input id={fieldId} type="hidden" name={name} defaultValue={selectedValue} />
|
|
138
|
+
</>
|
|
133
139
|
)}
|
|
134
140
|
</div>
|
|
135
141
|
);
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theme-picker",
|
|
3
3
|
"template": "theme-picker/theme-picker.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 6,
|
|
5
5
|
"required": ["themes"],
|
|
6
6
|
"default": {
|
|
7
7
|
"id": "theme-picker-1",
|
|
8
8
|
"label": "Theme",
|
|
9
9
|
"themes": [
|
|
10
10
|
{
|
|
11
|
-
"value": "
|
|
11
|
+
"value": "default",
|
|
12
12
|
"label": "Default"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
"value": "
|
|
15
|
+
"value": "forest",
|
|
16
16
|
"label": "Forest"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
"value": "
|
|
19
|
+
"value": "sunset",
|
|
20
20
|
"label": "Sunset"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
"value": "
|
|
23
|
+
"value": "ocean",
|
|
24
24
|
"label": "Ocean"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
"value": "
|
|
27
|
+
"value": "aurora",
|
|
28
28
|
"label": "Aurora"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
"value": "
|
|
31
|
+
"value": "borealis",
|
|
32
32
|
"label": "Borealis"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
"value": "
|
|
35
|
+
"value": "midnight",
|
|
36
36
|
"label": "Midnight"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
"value": "
|
|
39
|
+
"value": "carbon",
|
|
40
40
|
"label": "Carbon"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
"value": "
|
|
43
|
+
"value": "vads",
|
|
44
44
|
"label": "VADS"
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
"value": "
|
|
47
|
+
"value": "gov-uk",
|
|
48
48
|
"label": "GOV.UK"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
|
-
"value": "
|
|
51
|
+
"value": "nasa",
|
|
52
52
|
"label": "NASA"
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
|
-
"defaultValue": "
|
|
55
|
+
"defaultValue": "default"
|
|
56
56
|
},
|
|
57
57
|
"props": {
|
|
58
58
|
"id": {
|
|
59
59
|
"type": "string",
|
|
60
|
-
"description": "Element id for the
|
|
60
|
+
"description": "Element id for the value field"
|
|
61
61
|
},
|
|
62
62
|
"name": {
|
|
63
63
|
"type": "string",
|
|
@@ -66,29 +66,20 @@
|
|
|
66
66
|
"label": {
|
|
67
67
|
"type": "string",
|
|
68
68
|
"default": "Theme",
|
|
69
|
-
"description": "
|
|
69
|
+
"description": "Accessible picker label"
|
|
70
70
|
},
|
|
71
71
|
"themes": {
|
|
72
72
|
"type": "array",
|
|
73
|
-
"description": "
|
|
73
|
+
"description": "Theme choices with a label and a value written verbatim to <html data-usx-theme>."
|
|
74
74
|
},
|
|
75
75
|
"defaultValue": {
|
|
76
76
|
"type": "string",
|
|
77
|
-
"description": "Initial
|
|
77
|
+
"description": "Initial theme value when value is omitted"
|
|
78
78
|
},
|
|
79
79
|
"value": {
|
|
80
80
|
"type": "string",
|
|
81
81
|
"default": null,
|
|
82
|
-
"description": "
|
|
83
|
-
},
|
|
84
|
-
"onChange": {
|
|
85
|
-
"type": "function",
|
|
86
|
-
"description": "React callback for a selected theme. Django consumers can listen for the select's native change event; applying the theme remains the application's responsibility.",
|
|
87
|
-
"renderers": {
|
|
88
|
-
"django": {
|
|
89
|
-
"supported": false
|
|
90
|
-
}
|
|
91
|
-
}
|
|
82
|
+
"description": "Initial selected theme. Takes precedence over defaultValue."
|
|
92
83
|
},
|
|
93
84
|
"className": {
|
|
94
85
|
"type": "string",
|
|
@@ -99,9 +90,16 @@
|
|
|
99
90
|
"description": "Additional HTML attributes on the theme picker root."
|
|
100
91
|
},
|
|
101
92
|
"variant": {
|
|
102
|
-
"type": "
|
|
93
|
+
"type": "select",
|
|
94
|
+
"options": ["default", "popover", "swap"],
|
|
103
95
|
"default": "default",
|
|
104
|
-
"description": "Picker presentation: default,
|
|
96
|
+
"description": "Picker presentation: default, popover, or swap. All variants stay hidden until enhanced. ThemePicker enhancement applies the selected theme and connects Swap's button behavior. Swap uses two themes."
|
|
97
|
+
},
|
|
98
|
+
"popoverAlign": {
|
|
99
|
+
"type": "select",
|
|
100
|
+
"options": ["start", "center", "end"],
|
|
101
|
+
"default": "start",
|
|
102
|
+
"description": "Alignment of the popover panel relative to its trigger. Only used by the popover variant."
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% load usx_components %}
|
|
2
2
|
{% label htmlFor=field_id screenReaderOnly=True only %}{{ label|default:'Theme' }}{% endlabel %}
|
|
3
|
-
<select id="{{ field_id }}" class="usa-select usx-select
|
|
3
|
+
<select id="{{ field_id }}" class="usa-select usx-select"{% if name %} name="{{ name }}"{% endif %}>
|
|
4
4
|
{% for theme in themes %}
|
|
5
5
|
<option value="{{ theme.value }}"{% if theme.value == selected_value %} selected{% endif %}>{{ theme.label }}</option>
|
|
6
6
|
{% endfor %}
|