@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "8.4.10",
3
+ "version": "8.4.11-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -126,7 +126,7 @@ const Checkbox = ({
126
126
  onChange={onChange}
127
127
  tabIndex="-1"
128
128
  aria-invalid={error}
129
- aria-describedby={error ? `${name}-error-message` : ""}
129
+ aria-describedBy={error ? `${name}-error-message` : ""}
130
130
  />
131
131
  <StyledCheckbox
132
132
  error={error}
@@ -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
- autocomplete={autocompleteValue}
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={-1}
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" aria-live="polite">
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
- ariaLabelledby={createIdFromString(labelTextWhenNoError)}
65
- ariaDescribedby={createIdFromString(
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="polite">
88
- {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
89
- <Text
90
- color={ERROR_COLOR}
91
- variant="pXS"
92
- weight={themeValues.fontWeight}
93
- extraStyles={`word-break: break-word;
94
- font-family: Public Sans;
95
- &::first-letter {
96
- text-transform: uppercase;
97
- }`}
98
- id={createIdFromString(labelTextWhenNoError, "error message")}
99
- >
100
- {errorMessages[field.errors[0]]}
101
- </Text>
102
- ) : (
103
- <Text extraStyles={`height: ${themeValues.lineHeight};`} />
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
- autocomplete="address-line1"
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
- autocomplete="address-line2"
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
- autocomplete="address-level2"
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
- autocomplete="address-level1"
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
- autocomplete="postal-code"
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 wallet"
127
+ title="Save address to Wallet"
119
128
  checked={walletCheckboxMarked}
120
129
  onChange={saveToWallet}
121
130
  />