@thecb/components 8.4.10 → 8.4.11-beta.2
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 +71 -52
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +71 -52
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +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 +15 -6
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
|
);
|
|
@@ -64,15 +64,18 @@ const AddressForm = ({
|
|
|
64
64
|
}
|
|
65
65
|
}}
|
|
66
66
|
showErrors={showErrors}
|
|
67
|
+
aria-label="country"
|
|
67
68
|
/>
|
|
68
69
|
<FormInput
|
|
69
70
|
labelTextWhenNoError="Address"
|
|
70
71
|
errorMessages={street1ErrorMessages}
|
|
72
|
+
required={true}
|
|
71
73
|
field={fields.street1}
|
|
72
74
|
fieldActions={actions.fields.street1}
|
|
73
75
|
showErrors={showErrors}
|
|
74
76
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
75
|
-
|
|
77
|
+
autoComplete="address-line1"
|
|
78
|
+
aria-label="address line 1"
|
|
76
79
|
/>
|
|
77
80
|
<FormInput
|
|
78
81
|
labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
|
|
@@ -80,16 +83,19 @@ 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"
|
|
87
|
+
aria-label="address line 2"
|
|
84
88
|
/>
|
|
85
89
|
<FormInput
|
|
86
90
|
labelTextWhenNoError="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="locality"
|
|
98
|
+
aria-label="city"
|
|
93
99
|
/>
|
|
94
100
|
<StateProvinceDropdown
|
|
95
101
|
labelTextWhenNoError={isUS ? "State" : "State or Province"}
|
|
@@ -99,7 +105,9 @@ const AddressForm = ({
|
|
|
99
105
|
fieldActions={actions.fields.stateProvince}
|
|
100
106
|
showErrors={showErrors}
|
|
101
107
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
102
|
-
|
|
108
|
+
autoComplete="administrative-area"
|
|
109
|
+
aria-label={isUS ? "state" : "state or province"}
|
|
110
|
+
required={true}
|
|
103
111
|
/>
|
|
104
112
|
<FormInput
|
|
105
113
|
isNum={isUS}
|
|
@@ -110,12 +118,13 @@ const AddressForm = ({
|
|
|
110
118
|
fieldActions={actions.fields.zip}
|
|
111
119
|
showErrors={showErrors}
|
|
112
120
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
113
|
-
|
|
121
|
+
aria-label="zip code"
|
|
122
|
+
autoComplete="postal-code"
|
|
114
123
|
/>
|
|
115
124
|
{showWalletCheckbox && (
|
|
116
125
|
<Checkbox
|
|
117
126
|
name="address checkbox"
|
|
118
|
-
title="Save address to
|
|
127
|
+
title="Save address to Wallet"
|
|
119
128
|
checked={walletCheckboxMarked}
|
|
120
129
|
onChange={saveToWallet}
|
|
121
130
|
/>
|