@thecb/components 8.4.10 → 8.4.11-beta.1
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.js +66 -49
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +66 -49
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.js +4 -1
- package/src/components/atoms/dropdown/Dropdown.js +5 -3
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- package/src/components/atoms/form-select/FormSelect.js +24 -23
- package/src/components/molecules/address-form/AddressForm.js +12 -5
package/package.json
CHANGED
|
@@ -9,7 +9,8 @@ const CountryDropdown = ({
|
|
|
9
9
|
field,
|
|
10
10
|
fieldActions,
|
|
11
11
|
showErrors,
|
|
12
|
-
onChange
|
|
12
|
+
onChange,
|
|
13
|
+
...rest
|
|
13
14
|
}) => (
|
|
14
15
|
<FormSelect
|
|
15
16
|
options={options}
|
|
@@ -20,6 +21,8 @@ const CountryDropdown = ({
|
|
|
20
21
|
showErrors={showErrors}
|
|
21
22
|
onChange={onChange}
|
|
22
23
|
autocompleteValue="country-name"
|
|
24
|
+
autoComplete="country-name"
|
|
25
|
+
{...rest}
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
export default CountryDropdown;
|
|
@@ -295,7 +295,10 @@ const Dropdown = ({
|
|
|
295
295
|
aria-labelledby={ariaLabelledby}
|
|
296
296
|
aria-describedby={ariaDescribedby}
|
|
297
297
|
aria-expanded={isOpen}
|
|
298
|
-
|
|
298
|
+
aria-live="assertive"
|
|
299
|
+
role="combobox"
|
|
300
|
+
disabled={disabled}
|
|
301
|
+
autoComplete={autocompleteValue}
|
|
299
302
|
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
300
303
|
borderRadius="2px"
|
|
301
304
|
borderSize="1px"
|
|
@@ -325,7 +328,6 @@ const Dropdown = ({
|
|
|
325
328
|
}}
|
|
326
329
|
padding="12px"
|
|
327
330
|
placeholder={getSelection()}
|
|
328
|
-
role="combobox"
|
|
329
331
|
themeValues={themeValues}
|
|
330
332
|
title={hasTitles ? getSelection() : null}
|
|
331
333
|
type="text"
|
|
@@ -365,7 +367,7 @@ const Dropdown = ({
|
|
|
365
367
|
}
|
|
366
368
|
key={choice.value}
|
|
367
369
|
ref={optionRefs.current[i]}
|
|
368
|
-
tabIndex={
|
|
370
|
+
tabIndex={0}
|
|
369
371
|
onClick={e => handleItemSelection(e, choice, i)}
|
|
370
372
|
onKeyDown={e => {
|
|
371
373
|
if (e.keyCode === 13) {
|
|
@@ -249,7 +249,7 @@ const FormInput = ({
|
|
|
249
249
|
/>
|
|
250
250
|
)}
|
|
251
251
|
</Box>
|
|
252
|
-
<Stack direction="row" justify="space-between"
|
|
252
|
+
<Stack direction="row" justify="space-between" role="alert">
|
|
253
253
|
{(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
|
|
254
254
|
<Text
|
|
255
255
|
color={ERROR_COLOR}
|
|
@@ -22,7 +22,8 @@ const FormSelect = ({
|
|
|
22
22
|
themeValues,
|
|
23
23
|
hasTitles = false,
|
|
24
24
|
autocompleteValue, // browser autofill value, like country-name or address-level1 for state
|
|
25
|
-
smoothScroll = true // whether the browser should animate scroll to selected item on first open
|
|
25
|
+
smoothScroll = true, // whether the browser should animate scroll to selected item on first open
|
|
26
|
+
...rest
|
|
26
27
|
}) => {
|
|
27
28
|
const [open, setOpen] = useState(false);
|
|
28
29
|
const dropdownRef = useRef(null);
|
|
@@ -41,7 +42,7 @@ const FormSelect = ({
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
return (
|
|
44
|
-
<SelectContainer ref={dropdownRef} disabled={disabled}>
|
|
45
|
+
<SelectContainer ref={dropdownRef} disabled={disabled} {...rest}>
|
|
45
46
|
<Box padding="0" minWidth="100%">
|
|
46
47
|
<Cluster justify="space-between" align="center">
|
|
47
48
|
<Text
|
|
@@ -61,8 +62,8 @@ const FormSelect = ({
|
|
|
61
62
|
</Cluster>
|
|
62
63
|
</Box>
|
|
63
64
|
<Dropdown
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
aria-labelledBy={createIdFromString(labelTextWhenNoError)}
|
|
66
|
+
aria-describedBy={createIdFromString(
|
|
66
67
|
labelTextWhenNoError,
|
|
67
68
|
"error message"
|
|
68
69
|
)}
|
|
@@ -80,28 +81,28 @@ const FormSelect = ({
|
|
|
80
81
|
onChange ? value => onChange(value) : value => fieldActions.set(value)
|
|
81
82
|
}
|
|
82
83
|
onClick={() => setOpen(!open)}
|
|
83
|
-
disabled={disabled}
|
|
84
|
+
aria-disabled={disabled}
|
|
84
85
|
autocompleteValue={autocompleteValue}
|
|
85
86
|
smoothScroll={smoothScroll}
|
|
87
|
+
required={options.required}
|
|
86
88
|
/>
|
|
87
|
-
<Stack direction="row" justify="space-between" aria-live="
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)}
|
|
89
|
+
<Stack direction="row" justify="space-between" aria-live="assertive">
|
|
90
|
+
<Text
|
|
91
|
+
color={ERROR_COLOR}
|
|
92
|
+
variant="pXS"
|
|
93
|
+
weight={themeValues.fontWeight}
|
|
94
|
+
extraStyles={`word-break: break-word;
|
|
95
|
+
font-family: Public Sans;
|
|
96
|
+
&::first-letter {
|
|
97
|
+
text-transform: uppercase;
|
|
98
|
+
}`}
|
|
99
|
+
id={createIdFromString(labelTextWhenNoError, "error message")}
|
|
100
|
+
aria-live="assertive"
|
|
101
|
+
>
|
|
102
|
+
{(field.hasErrors && field.dirty) || (field.hasErrors && showErrors)
|
|
103
|
+
? errorMessages[field.errors[0]]
|
|
104
|
+
: ""}
|
|
105
|
+
</Text>
|
|
105
106
|
</Stack>
|
|
106
107
|
</SelectContainer>
|
|
107
108
|
);
|
|
@@ -51,6 +51,7 @@ const AddressForm = ({
|
|
|
51
51
|
<CountryDropdown
|
|
52
52
|
labelTextWhenNoError="Country"
|
|
53
53
|
errorMessages={countryErrorMessages}
|
|
54
|
+
aria-label="country"
|
|
54
55
|
field={fields.country}
|
|
55
56
|
onChange={value => {
|
|
56
57
|
actions.fields.country.set(value);
|
|
@@ -68,11 +69,13 @@ const AddressForm = ({
|
|
|
68
69
|
<FormInput
|
|
69
70
|
labelTextWhenNoError="Address"
|
|
70
71
|
errorMessages={street1ErrorMessages}
|
|
72
|
+
required={true}
|
|
73
|
+
aria-label="address line 1"
|
|
71
74
|
field={fields.street1}
|
|
72
75
|
fieldActions={actions.fields.street1}
|
|
73
76
|
showErrors={showErrors}
|
|
74
77
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
75
|
-
|
|
78
|
+
autoComplete="address-line1"
|
|
76
79
|
/>
|
|
77
80
|
<FormInput
|
|
78
81
|
labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
|
|
@@ -80,16 +83,18 @@ const AddressForm = ({
|
|
|
80
83
|
fieldActions={actions.fields.street2}
|
|
81
84
|
showErrors={showErrors}
|
|
82
85
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
83
|
-
|
|
86
|
+
autoComplete="address-line2"
|
|
84
87
|
/>
|
|
85
88
|
<FormInput
|
|
86
89
|
labelTextWhenNoError="City"
|
|
90
|
+
aria-label="city"
|
|
91
|
+
required={true}
|
|
87
92
|
errorMessages={cityErrorMessages}
|
|
88
93
|
field={fields.city}
|
|
89
94
|
fieldActions={actions.fields.city}
|
|
90
95
|
showErrors={showErrors}
|
|
91
96
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
92
|
-
|
|
97
|
+
autoComplete="address-level2"
|
|
93
98
|
/>
|
|
94
99
|
<StateProvinceDropdown
|
|
95
100
|
labelTextWhenNoError={isUS ? "State" : "State or Province"}
|
|
@@ -99,7 +104,9 @@ const AddressForm = ({
|
|
|
99
104
|
fieldActions={actions.fields.stateProvince}
|
|
100
105
|
showErrors={showErrors}
|
|
101
106
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
102
|
-
|
|
107
|
+
autoComplete="address-level1"
|
|
108
|
+
aria-label={isUS ? "State" : "State or Province"}
|
|
109
|
+
required={true}
|
|
103
110
|
/>
|
|
104
111
|
<FormInput
|
|
105
112
|
isNum={isUS}
|
|
@@ -110,7 +117,7 @@ const AddressForm = ({
|
|
|
110
117
|
fieldActions={actions.fields.zip}
|
|
111
118
|
showErrors={showErrors}
|
|
112
119
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
113
|
-
|
|
120
|
+
autoComplete="postal-code"
|
|
114
121
|
/>
|
|
115
122
|
{showWalletCheckbox && (
|
|
116
123
|
<Checkbox
|