@thecb/components 8.4.11-beta.1 → 8.4.11-beta.10
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 +60 -65
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -65
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/alert/Alert.js +1 -0
- package/src/components/atoms/checkbox/Checkbox.js +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.js +0 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +2 -0
- package/src/components/atoms/dropdown/Dropdown.js +13 -16
- package/src/components/atoms/form-layouts/FormInput.js +4 -10
- package/src/components/atoms/form-select/FormSelect.js +6 -11
- package/src/components/molecules/address-form/AddressForm.js +11 -9
package/package.json
CHANGED
|
@@ -26,6 +26,8 @@ const story = page({
|
|
|
26
26
|
const CountryFormWrapper = ({ fields, actions }) => (
|
|
27
27
|
<Box minHeight="300px">
|
|
28
28
|
<CountryDropdown
|
|
29
|
+
aria-label="Country"
|
|
30
|
+
labelTextWhenNoError="Country"
|
|
29
31
|
errorMessages={errorMessages}
|
|
30
32
|
options={options}
|
|
31
33
|
field={fields.country}
|
|
@@ -288,16 +288,12 @@ const Dropdown = ({
|
|
|
288
288
|
as="input"
|
|
289
289
|
aria-multiline="false"
|
|
290
290
|
aria-autocomplete="list"
|
|
291
|
-
aria-
|
|
292
|
-
aria-
|
|
293
|
-
aria-
|
|
291
|
+
// aria-activedescendant="focused_option"
|
|
292
|
+
// aria-owns={`${ariaLabelledby}_listbox`}
|
|
293
|
+
// aria-controls={`${ariaLabelledby}_listbox`}
|
|
294
294
|
aria-haspopup="listbox"
|
|
295
295
|
aria-labelledby={ariaLabelledby}
|
|
296
296
|
aria-describedby={ariaDescribedby}
|
|
297
|
-
aria-expanded={isOpen}
|
|
298
|
-
aria-live="assertive"
|
|
299
|
-
role="combobox"
|
|
300
|
-
disabled={disabled}
|
|
301
297
|
autoComplete={autocompleteValue}
|
|
302
298
|
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
303
299
|
borderRadius="2px"
|
|
@@ -319,6 +315,7 @@ const Dropdown = ({
|
|
|
319
315
|
minHeight="48px"
|
|
320
316
|
minWidth="100%"
|
|
321
317
|
name={autocompleteValue}
|
|
318
|
+
// aria-expanded={isOpen}
|
|
322
319
|
onChange={e => {
|
|
323
320
|
// support autofill and copy/paste
|
|
324
321
|
if (e.target.value !== inputValue) {
|
|
@@ -367,7 +364,7 @@ const Dropdown = ({
|
|
|
367
364
|
}
|
|
368
365
|
key={choice.value}
|
|
369
366
|
ref={optionRefs.current[i]}
|
|
370
|
-
tabIndex={
|
|
367
|
+
tabIndex={-1}
|
|
371
368
|
onClick={e => handleItemSelection(e, choice, i)}
|
|
372
369
|
onKeyDown={e => {
|
|
373
370
|
if (e.keyCode === 13) {
|
|
@@ -393,14 +390,14 @@ const Dropdown = ({
|
|
|
393
390
|
: MINESHAFT_GREY
|
|
394
391
|
}
|
|
395
392
|
extraStyles={`padding-left: 16px;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
393
|
+
cursor: ${
|
|
394
|
+
disabledValues.includes(choice.value)
|
|
395
|
+
? "default"
|
|
396
|
+
: "pointer"
|
|
397
|
+
};
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
overflow: hidden;
|
|
400
|
+
text-overflow: ellipsis;`}
|
|
404
401
|
>
|
|
405
402
|
{choice.text}
|
|
406
403
|
</Text>
|
|
@@ -198,10 +198,7 @@ const FormInput = ({
|
|
|
198
198
|
{formatter ? (
|
|
199
199
|
<FormattedInputField
|
|
200
200
|
aria-labelledby={createIdFromString(labelTextWhenNoError)}
|
|
201
|
-
aria-describedby={createIdFromString(
|
|
202
|
-
labelTextWhenNoError,
|
|
203
|
-
"error message"
|
|
204
|
-
)}
|
|
201
|
+
aria-describedby={createIdFromString(labelTextWhenNoError)}
|
|
205
202
|
aria-invalid={
|
|
206
203
|
(field.dirty && field.hasErrors) ||
|
|
207
204
|
(field.hasErrors && showErrors)
|
|
@@ -218,16 +215,13 @@ const FormInput = ({
|
|
|
218
215
|
themeValues={themeValues}
|
|
219
216
|
$customHeight={customHeight}
|
|
220
217
|
$extraStyles={extraStyles}
|
|
221
|
-
|
|
218
|
+
autocomplete={autocomplete}
|
|
222
219
|
{...props}
|
|
223
220
|
/>
|
|
224
221
|
) : (
|
|
225
222
|
<InputField
|
|
226
223
|
aria-labelledby={createIdFromString(labelTextWhenNoError)}
|
|
227
|
-
aria-describedby={createIdFromString(
|
|
228
|
-
labelTextWhenNoError,
|
|
229
|
-
"error message"
|
|
230
|
-
)}
|
|
224
|
+
aria-describedby={createIdFromString(labelTextWhenNoError)}
|
|
231
225
|
aria-invalid={
|
|
232
226
|
(field.dirty && field.hasErrors) ||
|
|
233
227
|
(field.hasErrors && showErrors)
|
|
@@ -244,7 +238,7 @@ const FormInput = ({
|
|
|
244
238
|
background={background}
|
|
245
239
|
$customHeight={customHeight}
|
|
246
240
|
$extraStyles={extraStyles}
|
|
247
|
-
|
|
241
|
+
autocomplete={autocomplete}
|
|
248
242
|
{...props}
|
|
249
243
|
/>
|
|
250
244
|
)}
|
|
@@ -22,8 +22,7 @@ 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
|
|
26
|
-
...rest
|
|
25
|
+
smoothScroll = true // whether the browser should animate scroll to selected item on first open
|
|
27
26
|
}) => {
|
|
28
27
|
const [open, setOpen] = useState(false);
|
|
29
28
|
const dropdownRef = useRef(null);
|
|
@@ -42,7 +41,7 @@ const FormSelect = ({
|
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
return (
|
|
45
|
-
<SelectContainer ref={dropdownRef} disabled={disabled}
|
|
44
|
+
<SelectContainer ref={dropdownRef} disabled={disabled}>
|
|
46
45
|
<Box padding="0" minWidth="100%">
|
|
47
46
|
<Cluster justify="space-between" align="center">
|
|
48
47
|
<Text
|
|
@@ -62,11 +61,8 @@ const FormSelect = ({
|
|
|
62
61
|
</Cluster>
|
|
63
62
|
</Box>
|
|
64
63
|
<Dropdown
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
labelTextWhenNoError,
|
|
68
|
-
"error message"
|
|
69
|
-
)}
|
|
64
|
+
ariaLabelledby={createIdFromString(labelTextWhenNoError)}
|
|
65
|
+
ariaDescribedby={createIdFromString(labelTextWhenNoError)}
|
|
70
66
|
maxHeight={dropdownMaxHeight}
|
|
71
67
|
hasTitles={hasTitles}
|
|
72
68
|
placeholder={options[0] ? options[0].text : ""}
|
|
@@ -81,12 +77,12 @@ const FormSelect = ({
|
|
|
81
77
|
onChange ? value => onChange(value) : value => fieldActions.set(value)
|
|
82
78
|
}
|
|
83
79
|
onClick={() => setOpen(!open)}
|
|
84
|
-
|
|
80
|
+
disabled={disabled}
|
|
85
81
|
autocompleteValue={autocompleteValue}
|
|
86
82
|
smoothScroll={smoothScroll}
|
|
87
83
|
required={options.required}
|
|
88
84
|
/>
|
|
89
|
-
<Stack direction="row" justify="space-between"
|
|
85
|
+
<Stack direction="row" justify="space-between" role="alert">
|
|
90
86
|
<Text
|
|
91
87
|
color={ERROR_COLOR}
|
|
92
88
|
variant="pXS"
|
|
@@ -97,7 +93,6 @@ const FormSelect = ({
|
|
|
97
93
|
text-transform: uppercase;
|
|
98
94
|
}`}
|
|
99
95
|
id={createIdFromString(labelTextWhenNoError, "error message")}
|
|
100
|
-
aria-live="assertive"
|
|
101
96
|
>
|
|
102
97
|
{(field.hasErrors && field.dirty) || (field.hasErrors && showErrors)
|
|
103
98
|
? errorMessages[field.errors[0]]
|
|
@@ -51,7 +51,6 @@ const AddressForm = ({
|
|
|
51
51
|
<CountryDropdown
|
|
52
52
|
labelTextWhenNoError="Country"
|
|
53
53
|
errorMessages={countryErrorMessages}
|
|
54
|
-
aria-label="country"
|
|
55
54
|
field={fields.country}
|
|
56
55
|
onChange={value => {
|
|
57
56
|
actions.fields.country.set(value);
|
|
@@ -65,17 +64,18 @@ const AddressForm = ({
|
|
|
65
64
|
}
|
|
66
65
|
}}
|
|
67
66
|
showErrors={showErrors}
|
|
67
|
+
aria-label="Country"
|
|
68
68
|
/>
|
|
69
69
|
<FormInput
|
|
70
70
|
labelTextWhenNoError="Address"
|
|
71
71
|
errorMessages={street1ErrorMessages}
|
|
72
72
|
required={true}
|
|
73
|
-
aria-label="address line 1"
|
|
74
73
|
field={fields.street1}
|
|
75
74
|
fieldActions={actions.fields.street1}
|
|
76
75
|
showErrors={showErrors}
|
|
77
76
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
78
|
-
|
|
77
|
+
autocomplete="address-line1"
|
|
78
|
+
aria-label="Address Line 1"
|
|
79
79
|
/>
|
|
80
80
|
<FormInput
|
|
81
81
|
labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
|
|
@@ -83,18 +83,19 @@ const AddressForm = ({
|
|
|
83
83
|
fieldActions={actions.fields.street2}
|
|
84
84
|
showErrors={showErrors}
|
|
85
85
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
86
|
-
|
|
86
|
+
autocomplete="address-line2"
|
|
87
|
+
aria-label="Address Line 2"
|
|
87
88
|
/>
|
|
88
89
|
<FormInput
|
|
89
90
|
labelTextWhenNoError="City"
|
|
90
|
-
aria-label="city"
|
|
91
91
|
required={true}
|
|
92
92
|
errorMessages={cityErrorMessages}
|
|
93
93
|
field={fields.city}
|
|
94
94
|
fieldActions={actions.fields.city}
|
|
95
95
|
showErrors={showErrors}
|
|
96
96
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
97
|
-
|
|
97
|
+
autocomplete="city"
|
|
98
|
+
aria-label="City"
|
|
98
99
|
/>
|
|
99
100
|
<StateProvinceDropdown
|
|
100
101
|
labelTextWhenNoError={isUS ? "State" : "State or Province"}
|
|
@@ -104,7 +105,6 @@ const AddressForm = ({
|
|
|
104
105
|
fieldActions={actions.fields.stateProvince}
|
|
105
106
|
showErrors={showErrors}
|
|
106
107
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
107
|
-
autoComplete="address-level1"
|
|
108
108
|
aria-label={isUS ? "State" : "State or Province"}
|
|
109
109
|
required={true}
|
|
110
110
|
/>
|
|
@@ -117,12 +117,14 @@ const AddressForm = ({
|
|
|
117
117
|
fieldActions={actions.fields.zip}
|
|
118
118
|
showErrors={showErrors}
|
|
119
119
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
120
|
-
|
|
120
|
+
aria-label="zip code"
|
|
121
|
+
autocomplete="postal-code"
|
|
122
|
+
required={true}
|
|
121
123
|
/>
|
|
122
124
|
{showWalletCheckbox && (
|
|
123
125
|
<Checkbox
|
|
124
126
|
name="address checkbox"
|
|
125
|
-
title="Save address to
|
|
127
|
+
title="Save address to Wallet"
|
|
126
128
|
checked={walletCheckboxMarked}
|
|
127
129
|
onChange={saveToWallet}
|
|
128
130
|
/>
|