@solexllc/usx-react 0.1.5 → 0.1.6
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/dist/index.cjs +92 -1264
- package/dist/index.js +94 -1266
- package/package.json +4 -4
- package/src/components/accordion/Accordion.tsx +105 -0
- package/src/components/accordion/accordion.django.html +1 -1
- package/src/components/accordion/config.json +6 -1
- package/src/components/banner/Banner.tsx +35 -27
- package/src/components/banner/banner.django.html +1 -1
- package/src/components/banner/config.json +4 -0
- package/src/components/date-picker/{DatePicker.jsx → DatePicker.tsx} +12 -17
- package/src/components/date-range-picker/{DateRangePicker.jsx → DateRangePicker.tsx} +21 -21
- package/src/components/fieldset/Fieldset.tsx +1 -1
- package/src/components/file-input/{FileInput.jsx → FileInput.tsx} +31 -34
- package/src/components/file-list/{FileList.jsx → FileList.tsx} +24 -24
- package/src/components/header/{HeaderBranding.jsx → HeaderBranding.tsx} +0 -1
- package/src/components/hero/Hero.tsx +49 -7
- package/src/components/hero/config.json +45 -0
- package/src/components/hero/hero.django.html +16 -5
- package/src/components/hero/hero.html +19 -0
- package/src/components/in-page-nav/{InPageNav.jsx → InPageNav.tsx} +14 -18
- package/src/components/language-selector/{LanguageSelector.jsx → LanguageSelector.tsx} +40 -69
- package/src/components/legend/Legend.tsx +1 -1
- package/src/components/memorable-date/{MemorableDate.jsx → MemorableDate.tsx} +27 -27
- package/src/components/page/{Page.jsx → Page.tsx} +7 -11
- package/src/components/range-slider/{RangeSlider.jsx → RangeSlider.tsx} +13 -21
- package/src/components/select/Select.tsx +2 -2
- package/src/components/time-picker/{TimePicker.jsx → TimePicker.tsx} +14 -19
- package/src/index.js +11 -11
- package/src/components/accordion/Accordion.jsx +0 -170
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import Label from '../label/Label';
|
|
5
5
|
import Hint from '../hint/Hint';
|
|
6
6
|
import ErrorMessage from '../error-message/ErrorMessage';
|
|
7
7
|
import FormGroup from '../form-group/FormGroup';
|
|
8
8
|
|
|
9
|
+
export interface TimePickerProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'step'> {
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
hint?: React.ReactNode;
|
|
12
|
+
error?: React.ReactNode;
|
|
13
|
+
ariaDisabled?: boolean;
|
|
14
|
+
defaultValue?: string | null;
|
|
15
|
+
minTime?: string | null;
|
|
16
|
+
maxTime?: string | null;
|
|
17
|
+
step?: string | number | null;
|
|
18
|
+
formGroup?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
export default function TimePicker({
|
|
10
22
|
id = 'appointment-time',
|
|
11
23
|
name,
|
|
@@ -22,7 +34,7 @@ export default function TimePicker({
|
|
|
22
34
|
formGroup = true,
|
|
23
35
|
className = '',
|
|
24
36
|
...props
|
|
25
|
-
}) {
|
|
37
|
+
}: TimePickerProps) {
|
|
26
38
|
const labelId = `${id}-label`;
|
|
27
39
|
const hintId = hint ? `${id}-hint` : undefined;
|
|
28
40
|
const errorId = error ? `${id}-error` : undefined;
|
|
@@ -68,20 +80,3 @@ export default function TimePicker({
|
|
|
68
80
|
|
|
69
81
|
return formGroup ? <FormGroup error={!!error}>{content}</FormGroup> : content;
|
|
70
82
|
}
|
|
71
|
-
|
|
72
|
-
TimePicker.propTypes = {
|
|
73
|
-
id: PropTypes.string,
|
|
74
|
-
name: PropTypes.string,
|
|
75
|
-
label: PropTypes.node,
|
|
76
|
-
hint: PropTypes.node,
|
|
77
|
-
error: PropTypes.node,
|
|
78
|
-
disabled: PropTypes.bool,
|
|
79
|
-
ariaDisabled: PropTypes.bool,
|
|
80
|
-
required: PropTypes.bool,
|
|
81
|
-
defaultValue: PropTypes.string,
|
|
82
|
-
minTime: PropTypes.string,
|
|
83
|
-
maxTime: PropTypes.string,
|
|
84
|
-
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
85
|
-
formGroup: PropTypes.bool,
|
|
86
|
-
className: PropTypes.string,
|
|
87
|
-
};
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Auto-generated by scripts/generate-exports.js — do not edit by hand.
|
|
2
2
|
// Run: pnpm generate:exports
|
|
3
|
-
export { default as Accordion } from './components/accordion/Accordion.
|
|
3
|
+
export { default as Accordion } from './components/accordion/Accordion.tsx';
|
|
4
4
|
export { default as Alert } from './components/alert/Alert.tsx';
|
|
5
5
|
export { default as Attribution } from './components/attribution/Attribution.tsx';
|
|
6
6
|
export { default as Avatar } from './components/avatar/Avatar.tsx';
|
|
@@ -23,13 +23,13 @@ export { default as Code } from './components/code/Code.tsx';
|
|
|
23
23
|
export { default as Collection } from './components/collection/Collection.tsx';
|
|
24
24
|
export { default as Combobox } from './components/combobox/Combobox.tsx';
|
|
25
25
|
export { default as CopyToClipboard } from './components/copy-to-clipboard/CopyToClipboard.tsx';
|
|
26
|
-
export { default as DatePicker } from './components/date-picker/DatePicker.
|
|
27
|
-
export { default as DateRangePicker } from './components/date-range-picker/DateRangePicker.
|
|
26
|
+
export { default as DatePicker } from './components/date-picker/DatePicker.tsx';
|
|
27
|
+
export { default as DateRangePicker } from './components/date-range-picker/DateRangePicker.tsx';
|
|
28
28
|
export { default as ErrorMessage } from './components/error-message/ErrorMessage.tsx';
|
|
29
29
|
export { default as Eyebrow } from './components/eyebrow/Eyebrow.tsx';
|
|
30
30
|
export { default as Fieldset } from './components/fieldset/Fieldset.tsx';
|
|
31
|
-
export { default as FileInput } from './components/file-input/FileInput.
|
|
32
|
-
export { default as FileList } from './components/file-list/FileList.
|
|
31
|
+
export { default as FileInput } from './components/file-input/FileInput.tsx';
|
|
32
|
+
export { default as FileList } from './components/file-list/FileList.tsx';
|
|
33
33
|
export { default as Footer } from './components/footer/Footer.tsx';
|
|
34
34
|
export { default as FormGroup } from './components/form-group/FormGroup.tsx';
|
|
35
35
|
export { default as Header } from './components/header/Header.tsx';
|
|
@@ -39,24 +39,24 @@ export { default as Icon } from './components/icon/Icon.tsx';
|
|
|
39
39
|
export { default as IconList } from './components/icon-list/IconList.tsx';
|
|
40
40
|
export { default as Identifier } from './components/identifier/Identifier.tsx';
|
|
41
41
|
export { default as Image } from './components/image/Image.tsx';
|
|
42
|
-
export { default as InPageNav } from './components/in-page-nav/InPageNav.
|
|
42
|
+
export { default as InPageNav } from './components/in-page-nav/InPageNav.tsx';
|
|
43
43
|
export { default as Indicator } from './components/indicator/Indicator.tsx';
|
|
44
44
|
export { default as Input } from './components/input/Input.tsx';
|
|
45
45
|
export { default as Label } from './components/label/Label.tsx';
|
|
46
|
-
export { default as LanguageSelector } from './components/language-selector/LanguageSelector.
|
|
46
|
+
export { default as LanguageSelector } from './components/language-selector/LanguageSelector.tsx';
|
|
47
47
|
export { default as Layout } from './components/layout/Layout.tsx';
|
|
48
48
|
export { default as Legend } from './components/legend/Legend.tsx';
|
|
49
49
|
export { default as Link } from './components/link/Link.tsx';
|
|
50
50
|
export { default as List } from './components/list/List.tsx';
|
|
51
|
-
export { default as MemorableDate } from './components/memorable-date/MemorableDate.
|
|
51
|
+
export { default as MemorableDate } from './components/memorable-date/MemorableDate.tsx';
|
|
52
52
|
export { default as MiscBanner } from './components/misc-banner/MiscBanner.tsx';
|
|
53
53
|
export { default as Modal } from './components/modal/Modal.tsx';
|
|
54
|
-
export { default as Page } from './components/page/Page.
|
|
54
|
+
export { default as Page } from './components/page/Page.tsx';
|
|
55
55
|
export { default as Pagination } from './components/pagination/Pagination.tsx';
|
|
56
56
|
export { default as ProcessList } from './components/process-list/ProcessList.tsx';
|
|
57
57
|
export { default as Prose } from './components/prose/Prose.tsx';
|
|
58
58
|
export { default as RadioButtons } from './components/radio-buttons/RadioButtons.tsx';
|
|
59
|
-
export { default as RangeSlider } from './components/range-slider/RangeSlider.
|
|
59
|
+
export { default as RangeSlider } from './components/range-slider/RangeSlider.tsx';
|
|
60
60
|
export { default as Required } from './components/required/Required.tsx';
|
|
61
61
|
export { default as Search } from './components/search/Search.tsx';
|
|
62
62
|
export { default as Section } from './components/section/Section.tsx';
|
|
@@ -76,7 +76,7 @@ export { default as TagGroup } from './components/tag-group/TagGroup.tsx';
|
|
|
76
76
|
export { default as TaskList } from './components/task-list/TaskList.tsx';
|
|
77
77
|
export { default as TextArea } from './components/text-area/TextArea.tsx';
|
|
78
78
|
export { default as ThemePicker } from './components/theme-picker/ThemePicker.tsx';
|
|
79
|
-
export { default as TimePicker } from './components/time-picker/TimePicker.
|
|
79
|
+
export { default as TimePicker } from './components/time-picker/TimePicker.tsx';
|
|
80
80
|
export { default as Toggle } from './components/toggle/Toggle.tsx';
|
|
81
81
|
export { default as Tooltip } from './components/tooltip/Tooltip.tsx';
|
|
82
82
|
export { default as Villain } from './components/villain/Villain.tsx';
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
|
|
5
|
-
function AccordionItem({
|
|
6
|
-
title,
|
|
7
|
-
id,
|
|
8
|
-
content,
|
|
9
|
-
expanded,
|
|
10
|
-
className,
|
|
11
|
-
headingLevel,
|
|
12
|
-
handleToggle,
|
|
13
|
-
}) {
|
|
14
|
-
const headingClasses = classnames('usa-accordion__heading', className)
|
|
15
|
-
const contentClasses = classnames(
|
|
16
|
-
'usa-accordion__content',
|
|
17
|
-
'usa-prose',
|
|
18
|
-
className
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const Heading = headingLevel
|
|
22
|
-
|
|
23
|
-
const handleClick = (e) => {
|
|
24
|
-
// Prevent default navigation/behavior and stop other listeners
|
|
25
|
-
// (including non-React handlers added by imported JS) from running.
|
|
26
|
-
if (e && typeof e.preventDefault === 'function') e.preventDefault();
|
|
27
|
-
if (e && typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
|
|
28
|
-
if (e && typeof e.stopPropagation === 'function') e.stopPropagation();
|
|
29
|
-
handleToggle(e)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
<Heading id={`${id}-heading`} className={headingClasses}>
|
|
35
|
-
<button
|
|
36
|
-
type="button"
|
|
37
|
-
className="usa-accordion__button"
|
|
38
|
-
aria-expanded={expanded}
|
|
39
|
-
aria-controls={`${id}-content`}
|
|
40
|
-
data-testid={`accordionButton_${id}`}
|
|
41
|
-
onClickCapture={handleClick}>
|
|
42
|
-
{title}
|
|
43
|
-
</button>
|
|
44
|
-
</Heading>
|
|
45
|
-
<div
|
|
46
|
-
id={`${id}-content`}
|
|
47
|
-
aria-labelledby={`${id}-heading`}
|
|
48
|
-
data-testid={`accordionItem_${id}`}
|
|
49
|
-
className={contentClasses}
|
|
50
|
-
hidden={!expanded}>
|
|
51
|
-
{content}
|
|
52
|
-
</div>
|
|
53
|
-
</>
|
|
54
|
-
)
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function buildExpansions(
|
|
58
|
-
items,
|
|
59
|
-
multiselectable,
|
|
60
|
-
savedExpansions = new Map()
|
|
61
|
-
) {
|
|
62
|
-
const lastExpandedItem = multiselectable
|
|
63
|
-
? undefined
|
|
64
|
-
: items.findLast((item) => item.expanded || savedExpansions.get(item.id))
|
|
65
|
-
return items.reduce((map, item) => {
|
|
66
|
-
map.set(
|
|
67
|
-
item.id,
|
|
68
|
-
multiselectable
|
|
69
|
-
? (savedExpansions.get(item.id) ?? item.expanded)
|
|
70
|
-
: !!lastExpandedItem && item.id === lastExpandedItem.id
|
|
71
|
-
)
|
|
72
|
-
return map
|
|
73
|
-
}, new Map())
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
AccordionItem.propTypes = {
|
|
77
|
-
title: PropTypes.node.isRequired,
|
|
78
|
-
id: PropTypes.string.isRequired,
|
|
79
|
-
content: PropTypes.node.isRequired,
|
|
80
|
-
expanded: PropTypes.bool,
|
|
81
|
-
className: PropTypes.string,
|
|
82
|
-
headingLevel: PropTypes.string,
|
|
83
|
-
handleToggle: PropTypes.func,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Accordion.propTypes = {
|
|
87
|
-
id: PropTypes.string,
|
|
88
|
-
bordered: PropTypes.bool,
|
|
89
|
-
items: PropTypes.arrayOf(PropTypes.shape(AccordionItem.propTypes)),
|
|
90
|
-
multiselectable: PropTypes.bool,
|
|
91
|
-
headingLevel: PropTypes.string,
|
|
92
|
-
className: PropTypes.string,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export function Accordion({
|
|
96
|
-
id,
|
|
97
|
-
bordered = false,
|
|
98
|
-
items = [],
|
|
99
|
-
multiselectable = false,
|
|
100
|
-
headingLevel = 'h3',
|
|
101
|
-
className = '',
|
|
102
|
-
...props
|
|
103
|
-
}) {
|
|
104
|
-
const [savedExpansions, setSavedExpansions] = useState(() =>
|
|
105
|
-
buildExpansions(items, multiselectable)
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
const [prevItems, setPrevItems] = useState(items)
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
if (items !== prevItems) {
|
|
111
|
-
setPrevItems(items)
|
|
112
|
-
}
|
|
113
|
-
}, [items, prevItems])
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
if (items !== prevItems) {
|
|
117
|
-
setSavedExpansions((prevExpansions) =>
|
|
118
|
-
buildExpansions(items, multiselectable, prevExpansions)
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
}, [items, multiselectable, prevItems])
|
|
122
|
-
|
|
123
|
-
const accordionClasses = classnames(
|
|
124
|
-
'usa-accordion',
|
|
125
|
-
'usx-accordion',
|
|
126
|
-
bordered && 'usa-accordion--bordered',
|
|
127
|
-
className
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const toggleItem = (itemId) => {
|
|
132
|
-
setSavedExpansions((prevExpansions) => {
|
|
133
|
-
const updatedExpansions = new Map(prevExpansions)
|
|
134
|
-
if (updatedExpansions.get(itemId)) {
|
|
135
|
-
updatedExpansions.set(itemId, false)
|
|
136
|
-
} else {
|
|
137
|
-
if (!multiselectable) {
|
|
138
|
-
updatedExpansions.forEach((_val, key, map) => map.set(key, false))
|
|
139
|
-
}
|
|
140
|
-
updatedExpansions.set(itemId, true)
|
|
141
|
-
}
|
|
142
|
-
return updatedExpansions
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<div
|
|
148
|
-
id={id}
|
|
149
|
-
className={accordionClasses}
|
|
150
|
-
data-allow-multiple={multiselectable}
|
|
151
|
-
{...props}
|
|
152
|
-
>
|
|
153
|
-
{items.map((item) => (
|
|
154
|
-
<AccordionItem
|
|
155
|
-
key={item.id}
|
|
156
|
-
{...item}
|
|
157
|
-
expanded={savedExpansions.get(item.id) ?? false}
|
|
158
|
-
handleToggle={(e) => {
|
|
159
|
-
if (item.handleToggle) item.handleToggle(e)
|
|
160
|
-
toggleItem(item.id)
|
|
161
|
-
}}
|
|
162
|
-
headingLevel={headingLevel}
|
|
163
|
-
className={className}
|
|
164
|
-
/>
|
|
165
|
-
))}
|
|
166
|
-
</div>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export default Accordion;
|