@thecb/components 10.8.1 → 10.9.0-beta.0

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": "10.8.1",
3
+ "version": "10.9.0-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -135,7 +135,8 @@ const Dropdown = ({
135
135
  autocompleteValue, // browser autofill value, like country-name
136
136
  smoothScroll = true,
137
137
  ariaInvalid = false,
138
- isRequired = false
138
+ isRequired = false,
139
+ inputId = false
139
140
  }) => {
140
141
  const [inputValue, setInputValue] = useState("");
141
142
  const [optionsState, setOptionsState] = useState([]);
@@ -329,6 +330,7 @@ const Dropdown = ({
329
330
  dataQa={`${ariaLabelledby}-dropdown`}
330
331
  >
331
332
  <Box
333
+ id={inputId}
332
334
  as="input"
333
335
  autoComplete={autocompleteValue}
334
336
  aria-controls={`${ariaLabelledby}_listbox`}
@@ -117,6 +117,8 @@ const FormInput = ({
117
117
  removeFromValue, // regex of characters to remove before setting value
118
118
  dataQa = null,
119
119
  isRequired = false,
120
+ htmlFor = null,
121
+ inputId = null,
120
122
  ...props
121
123
  }) => {
122
124
  const [showPassword, setShowPassword] = useState(false);
@@ -154,6 +156,7 @@ const FormInput = ({
154
156
  text-transform: uppercase;
155
157
  }`}
156
158
  id={createIdFromString(labelTextWhenNoError)}
159
+ htmlFor={htmlFor}
157
160
  >
158
161
  {labelTextWhenNoError}
159
162
  </Text>
@@ -173,6 +176,7 @@ const FormInput = ({
173
176
  text-transform: uppercase;
174
177
  }`}
175
178
  id={createIdFromString(labelTextWhenNoError)}
179
+ htmlFor={htmlFor}
176
180
  >
177
181
  {labelTextWhenNoError}
178
182
  </Text>
@@ -204,6 +208,7 @@ const FormInput = ({
204
208
  <Box padding="0">
205
209
  {formatter ? (
206
210
  <FormattedInputField
211
+ id={inputId || props?.id}
207
212
  aria-labelledby={createIdFromString(labelTextWhenNoError)}
208
213
  aria-describedby={createIdFromString(
209
214
  labelTextWhenNoError,
@@ -241,6 +246,7 @@ const FormInput = ({
241
246
  />
242
247
  ) : (
243
248
  <InputField
249
+ id={inputId || props?.id}
244
250
  aria-labelledby={createIdFromString(labelTextWhenNoError)}
245
251
  aria-describedby={createIdFromString(
246
252
  labelTextWhenNoError,
@@ -25,7 +25,9 @@ const FormSelect = ({
25
25
  smoothScroll = true, // whether the browser should animate scroll to selected item on first open
26
26
  dataQa = null,
27
27
  widthFitOptions = false,
28
- isRequired = false
28
+ isRequired = false,
29
+ htmlFor = null,
30
+ inputId = null
29
31
  }) => {
30
32
  const [open, setOpen] = useState(false);
31
33
  const dropdownRef = useRef(null);
@@ -63,12 +65,14 @@ const FormSelect = ({
63
65
  text-transform: uppercase;
64
66
  }`}
65
67
  id={createIdFromString(labelTextWhenNoError)}
68
+ htmlFor={htmlFor}
66
69
  >
67
70
  {labelTextWhenNoError}
68
71
  </Text>
69
72
  </Cluster>
70
73
  </Box>
71
74
  <Dropdown
75
+ inputId={inputId}
72
76
  ariaLabelledby={createIdFromString(labelTextWhenNoError)}
73
77
  ariaDescribedby={createIdFromString(
74
78
  labelTextWhenNoError,
@@ -24,6 +24,8 @@ export interface FormSelectProps {
24
24
  smoothScroll?: boolean;
25
25
  dataQa?: string | null;
26
26
  widthFitOptions?: boolean;
27
+ htmlFor?: string;
28
+ inputId?: string;
27
29
  }
28
30
 
29
31
  export const FormSelect: React.FC<Expand<FormSelectProps> &
@@ -27,6 +27,7 @@ export interface BoxProps {
27
27
  extraStyles?: string;
28
28
  srOnly?: boolean;
29
29
  dataQa?: string;
30
+ id?: string;
30
31
  }
31
32
 
32
33
  export const Box: React.FC<Expand<BoxProps> &
@@ -46,6 +46,7 @@ const Box = forwardRef(
46
46
  extraStyles,
47
47
  srOnly = false,
48
48
  dataQa,
49
+ id,
49
50
  children,
50
51
  ...rest
51
52
  },
@@ -87,6 +88,7 @@ const Box = forwardRef(
87
88
  onBlur={onBlur}
88
89
  onTouchEnd={onTouchEnd}
89
90
  ref={ref}
91
+ id={id}
90
92
  {...rest}
91
93
  >
92
94
  {children && safeChildren(children, <Fragment />)}
@@ -10,7 +10,9 @@ const FormStateDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  countryCode,
13
- isRequired = false
13
+ isRequired = false,
14
+ htmlFor = null,
15
+ inputId = null
14
16
  }) => {
15
17
  const placeholder =
16
18
  countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
@@ -24,6 +26,8 @@ const FormStateDropdown = ({
24
26
  errorMessages={errorMessages}
25
27
  showErrors={showErrors}
26
28
  autocompleteValue="address-level1"
29
+ htmlFor={htmlFor}
30
+ inputId={inputId}
27
31
  isRequired={isRequired}
28
32
  />
29
33
  );
@@ -10,6 +10,8 @@ export interface TextProps {
10
10
  as?: string;
11
11
  dataQa?: string;
12
12
  variant?: string;
13
+ htmlFor?: string;
14
+ inputId?: string;
13
15
  }
14
16
 
15
17
  export const Text: React.FC<Expand<TextProps> &
@@ -81,6 +81,8 @@ const AddressForm = ({
81
81
  showErrors={showErrors}
82
82
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
83
83
  autocompleteValue="address-line1"
84
+ htmlFor="address-line1"
85
+ inputId="address-line1"
84
86
  dataQa="Address"
85
87
  isRequired={true}
86
88
  />
@@ -91,6 +93,8 @@ const AddressForm = ({
91
93
  showErrors={showErrors}
92
94
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
93
95
  autocompleteValue="address-line2"
96
+ htmlFor="address-line2"
97
+ inputId="address-line2"
94
98
  dataQa="Address Line 2"
95
99
  />
96
100
  <FormInput
@@ -101,6 +105,8 @@ const AddressForm = ({
101
105
  showErrors={showErrors}
102
106
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
103
107
  autocompleteValue="address-level2"
108
+ htmlFor="city"
109
+ inputId="city"
104
110
  dataQa="City"
105
111
  isRequired={true}
106
112
  />
@@ -112,6 +118,9 @@ const AddressForm = ({
112
118
  fieldActions={actions.fields.stateProvince}
113
119
  showErrors={showErrors}
114
120
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
121
+ autocompleteValue="address-level1"
122
+ htmlFor="stateOrProvince"
123
+ inputId="stateOrProvince"
115
124
  dataQa="State or Province"
116
125
  isRequired={true}
117
126
  />
@@ -125,6 +134,8 @@ const AddressForm = ({
125
134
  showErrors={showErrors}
126
135
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
127
136
  autocompleteValue="postal-code"
137
+ htmlFor="postal-code"
138
+ inputId="postal-code"
128
139
  dataQa="Zip code"
129
140
  isRequired={true}
130
141
  />