@thecb/components 6.0.0-beta.6 → 6.0.0-beta.9
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 +26 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +26 -22
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -0
- package/src/components/atoms/dropdown/Dropdown.js +44 -55
- package/src/components/atoms/form-select/FormSelect.js +3 -1
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -0
package/package.json
CHANGED
|
@@ -122,6 +122,8 @@ const Dropdown = ({
|
|
|
122
122
|
value ? options.find(option => option.value === value)?.text : placeholder;
|
|
123
123
|
|
|
124
124
|
const onKeyDown = e => {
|
|
125
|
+
console.log("key down event is", e.target);
|
|
126
|
+
console.log("key down event value is", e.target.value);
|
|
125
127
|
const { key, keyCode } = e;
|
|
126
128
|
const focus = document.activeElement;
|
|
127
129
|
console.log("dropdown value is", value);
|
|
@@ -183,13 +185,14 @@ const Dropdown = ({
|
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
useEffect(() => {
|
|
188
|
+
console.log("option refs in isopen useffect", optionRefs);
|
|
186
189
|
console.log(
|
|
187
|
-
"option
|
|
190
|
+
"option ref current in isopen useffect",
|
|
188
191
|
optionRefs.current[0].current
|
|
189
192
|
);
|
|
190
193
|
console.log("selected refs in isopen useffect", selectedRef);
|
|
191
194
|
console.log("value in isopen useffect", value);
|
|
192
|
-
if (isOpen && selectedRef !== undefined) {
|
|
195
|
+
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
193
196
|
// WAI-ARIA requires the selected option to receive focus
|
|
194
197
|
selectedRef.current.focus();
|
|
195
198
|
} else if (isOpen && optionRefs.current[0].current) {
|
|
@@ -203,7 +206,7 @@ const Dropdown = ({
|
|
|
203
206
|
useEffect(() => {
|
|
204
207
|
if (autoEraseTypeAhead) {
|
|
205
208
|
clearTimeout(timer);
|
|
206
|
-
setTimer(setTimeout(() => setInputValue(""),
|
|
209
|
+
setTimer(setTimeout(() => setInputValue(""), 3000));
|
|
207
210
|
}
|
|
208
211
|
setFilteredOptions(
|
|
209
212
|
options.filter(
|
|
@@ -236,9 +239,10 @@ const Dropdown = ({
|
|
|
236
239
|
<Box
|
|
237
240
|
onKeyDown={onKeyDown}
|
|
238
241
|
onClick={onClick}
|
|
239
|
-
padding="
|
|
242
|
+
padding="12px"
|
|
240
243
|
width="100%"
|
|
241
244
|
hoverStyles={`background-color: ${themeValues.hoverColor};`}
|
|
245
|
+
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
242
246
|
aria-expanded={isOpen}
|
|
243
247
|
role="combobox"
|
|
244
248
|
aria-owns={`${ariaLabelledby}_listbox`}
|
|
@@ -251,58 +255,43 @@ const Dropdown = ({
|
|
|
251
255
|
pointer-events: none;`
|
|
252
256
|
}
|
|
253
257
|
title={hasTitles ? getSelection() : null}
|
|
258
|
+
dataQa={placeholder}
|
|
259
|
+
tabIndex={0}
|
|
260
|
+
borderRadius="2px"
|
|
261
|
+
borderSize="1px"
|
|
262
|
+
borderColor={
|
|
263
|
+
isError
|
|
264
|
+
? ERROR_COLOR
|
|
265
|
+
: isOpen
|
|
266
|
+
? themeValues.selectedColor
|
|
267
|
+
: GREY_CHATEAU
|
|
268
|
+
}
|
|
254
269
|
>
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
direction="row"
|
|
281
|
-
bottomItem={2}
|
|
282
|
-
extraStyles={`position: relative;`}
|
|
283
|
-
>
|
|
284
|
-
<SearchInput
|
|
285
|
-
aria-label={getSelection()}
|
|
286
|
-
placeholder={getSelection()}
|
|
287
|
-
value={inputValue}
|
|
288
|
-
onChange={noop}
|
|
289
|
-
themeValues={themeValues}
|
|
290
|
-
role="searchbox"
|
|
291
|
-
type="text"
|
|
292
|
-
aria-multiline="false"
|
|
293
|
-
aria-autocomplete="list"
|
|
294
|
-
aria-controls={`${ariaLabelledby}_listbox`}
|
|
295
|
-
aria-activedescendant="selected_option"
|
|
296
|
-
isOpen={isOpen}
|
|
297
|
-
tabIndex={-1}
|
|
298
|
-
name={autocompleteValue}
|
|
299
|
-
autocomplete={autocompleteValue}
|
|
300
|
-
/>
|
|
301
|
-
<IconWrapper open={isOpen}>
|
|
302
|
-
<DropdownIcon />
|
|
303
|
-
</IconWrapper>
|
|
304
|
-
</Stack>
|
|
305
|
-
</Box>
|
|
270
|
+
<Stack direction="row" bottomItem={2} extraStyles={`position: relative;`}>
|
|
271
|
+
<SearchInput
|
|
272
|
+
aria-label={getSelection()}
|
|
273
|
+
placeholder={getSelection()}
|
|
274
|
+
value={inputValue}
|
|
275
|
+
onChange={e => {
|
|
276
|
+
console.log("input change event", e.target);
|
|
277
|
+
console.log("input change event value", e.target.value);
|
|
278
|
+
}}
|
|
279
|
+
themeValues={themeValues}
|
|
280
|
+
role="searchbox"
|
|
281
|
+
type="text"
|
|
282
|
+
aria-multiline="false"
|
|
283
|
+
aria-autocomplete="list"
|
|
284
|
+
aria-controls={`${ariaLabelledby}_listbox`}
|
|
285
|
+
aria-activedescendant="selected_option"
|
|
286
|
+
isOpen={isOpen}
|
|
287
|
+
tabIndex={-1}
|
|
288
|
+
name={autocompleteValue}
|
|
289
|
+
autocomplete={autocompleteValue}
|
|
290
|
+
/>
|
|
291
|
+
<IconWrapper open={isOpen}>
|
|
292
|
+
<DropdownIcon />
|
|
293
|
+
</IconWrapper>
|
|
294
|
+
</Stack>
|
|
306
295
|
{isOpen ? (
|
|
307
296
|
<DropdownContentWrapper
|
|
308
297
|
maxHeight={maxHeight}
|
|
@@ -19,7 +19,8 @@ const FormSelect = ({
|
|
|
19
19
|
disabledValues,
|
|
20
20
|
disabled,
|
|
21
21
|
themeValues,
|
|
22
|
-
hasTitles = false
|
|
22
|
+
hasTitles = false,
|
|
23
|
+
autocompleteValue // autofill item for browsers, like country-name or address-level1 for state
|
|
23
24
|
}) => {
|
|
24
25
|
const [open, setOpen] = useState(false);
|
|
25
26
|
const dropdownRef = useRef(null);
|
|
@@ -74,6 +75,7 @@ const FormSelect = ({
|
|
|
74
75
|
}
|
|
75
76
|
onClick={() => setOpen(!open)}
|
|
76
77
|
disabled={disabled}
|
|
78
|
+
autocompleteValue={autocompleteValue}
|
|
77
79
|
/>
|
|
78
80
|
<Stack direction="row" justify="space-between">
|
|
79
81
|
{(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
|