@thecb/components 6.0.0-beta.4 → 6.0.0-beta.7
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 +46 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +46 -35
- 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 +25 -8
- 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
|
@@ -74,10 +74,10 @@ const DropdownItemWrapper = styled.div`
|
|
|
74
74
|
|
|
75
75
|
const SearchInput = styled.input`
|
|
76
76
|
border: none;
|
|
77
|
-
background-color:
|
|
78
|
-
themeValues.hoverColor && themeValues.hoverColor};
|
|
77
|
+
background-color: transparent;
|
|
79
78
|
font-size: 16px;
|
|
80
79
|
height: 24px;
|
|
80
|
+
min-width: 80%;
|
|
81
81
|
`;
|
|
82
82
|
|
|
83
83
|
const Dropdown = ({
|
|
@@ -95,7 +95,8 @@ const Dropdown = ({
|
|
|
95
95
|
disabled,
|
|
96
96
|
hasTitles = false,
|
|
97
97
|
autoEraseTypeAhead = true, // legacy behavior as of 05/22
|
|
98
|
-
ariaLabelledby
|
|
98
|
+
ariaLabelledby,
|
|
99
|
+
autocompleteValue = "" // autofill item for browsers, like country-name or address-level1 for state
|
|
99
100
|
}) => {
|
|
100
101
|
const [inputValue, setInputValue] = useState("");
|
|
101
102
|
const [optionsState, setOptionsState] = useState([]);
|
|
@@ -202,7 +203,7 @@ const Dropdown = ({
|
|
|
202
203
|
useEffect(() => {
|
|
203
204
|
if (autoEraseTypeAhead) {
|
|
204
205
|
clearTimeout(timer);
|
|
205
|
-
setTimer(setTimeout(() => setInputValue(""),
|
|
206
|
+
setTimer(setTimeout(() => setInputValue(""), 5000));
|
|
206
207
|
}
|
|
207
208
|
setFilteredOptions(
|
|
208
209
|
options.filter(
|
|
@@ -220,6 +221,8 @@ const Dropdown = ({
|
|
|
220
221
|
!disabledValues.includes(filteredOptions[0].value) &&
|
|
221
222
|
filteredOptions[0].text != placeholder
|
|
222
223
|
) {
|
|
224
|
+
console.log("filtered options are", filteredOptions);
|
|
225
|
+
console.log("option refs are", optionRefs);
|
|
223
226
|
onSelect(filteredOptions[0].value);
|
|
224
227
|
}
|
|
225
228
|
if (optionRefs.current[0].current) {
|
|
@@ -264,6 +267,7 @@ const Dropdown = ({
|
|
|
264
267
|
: GREY_CHATEAU
|
|
265
268
|
}
|
|
266
269
|
borderRadius="2px"
|
|
270
|
+
tabIndex={0}
|
|
267
271
|
dataQa={placeholder}
|
|
268
272
|
extraStyles={`height: 48px;
|
|
269
273
|
${disabled &&
|
|
@@ -272,7 +276,11 @@ const Dropdown = ({
|
|
|
272
276
|
pointer-events: none;`}
|
|
273
277
|
`}
|
|
274
278
|
>
|
|
275
|
-
<Stack
|
|
279
|
+
<Stack
|
|
280
|
+
direction="row"
|
|
281
|
+
bottomItem={2}
|
|
282
|
+
extraStyles={`position: relative;`}
|
|
283
|
+
>
|
|
276
284
|
<SearchInput
|
|
277
285
|
aria-label={getSelection()}
|
|
278
286
|
placeholder={getSelection()}
|
|
@@ -285,7 +293,10 @@ const Dropdown = ({
|
|
|
285
293
|
aria-autocomplete="list"
|
|
286
294
|
aria-controls={`${ariaLabelledby}_listbox`}
|
|
287
295
|
aria-activedescendant="selected_option"
|
|
288
|
-
|
|
296
|
+
isOpen={isOpen}
|
|
297
|
+
tabIndex={-1}
|
|
298
|
+
name={autocompleteValue}
|
|
299
|
+
autocomplete={autocompleteValue}
|
|
289
300
|
/>
|
|
290
301
|
<IconWrapper open={isOpen}>
|
|
291
302
|
<DropdownIcon />
|
|
@@ -304,7 +315,10 @@ const Dropdown = ({
|
|
|
304
315
|
>
|
|
305
316
|
<Stack childGap="0">
|
|
306
317
|
{filteredOptions.map((choice, i) => {
|
|
307
|
-
if (
|
|
318
|
+
if (
|
|
319
|
+
choice.value === value &&
|
|
320
|
+
selectedRef !== optionRefs.current[i]
|
|
321
|
+
) {
|
|
308
322
|
setSelectedRef(optionRefs.current[i]);
|
|
309
323
|
}
|
|
310
324
|
return (
|
|
@@ -317,7 +331,10 @@ const Dropdown = ({
|
|
|
317
331
|
onClick={
|
|
318
332
|
disabledValues.includes(choice.value)
|
|
319
333
|
? evt => evt.preventDefault()
|
|
320
|
-
: () =>
|
|
334
|
+
: () => {
|
|
335
|
+
setSelectedRef(optionRefs.current[i]);
|
|
336
|
+
onSelect(choice.value);
|
|
337
|
+
}
|
|
321
338
|
}
|
|
322
339
|
selected={choice.value === value}
|
|
323
340
|
aria-selected={choice.value === value}
|
|
@@ -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) ? (
|