@thecb/components 6.0.0-beta.10 → 6.0.0-beta.11
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 +14 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +78 -72
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ const DropdownContentWrapper = styled.div`
|
|
|
41
41
|
}
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
|
-
const DropdownItemWrapper = styled.
|
|
44
|
+
const DropdownItemWrapper = styled.li`
|
|
45
45
|
background-color: ${({ selected, themeValues }) =>
|
|
46
46
|
selected ? themeValues.selectedColor : WHITE};
|
|
47
47
|
text-align: start;
|
|
@@ -170,6 +170,11 @@ const Dropdown = ({
|
|
|
170
170
|
optionRefs?.current?.length ?? 0 - 1
|
|
171
171
|
].current.focus();
|
|
172
172
|
break;
|
|
173
|
+
case "Escape":
|
|
174
|
+
if (isOpen) {
|
|
175
|
+
onClick();
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
173
178
|
}
|
|
174
179
|
};
|
|
175
180
|
|
|
@@ -275,62 +280,67 @@ const Dropdown = ({
|
|
|
275
280
|
value={inputValue}
|
|
276
281
|
width="100%"
|
|
277
282
|
dataQa={placeholder}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
283
|
+
/>
|
|
284
|
+
<IconWrapper open={isOpen}>
|
|
285
|
+
<DropdownIcon />
|
|
286
|
+
</IconWrapper>
|
|
287
|
+
</Stack>
|
|
288
|
+
<Fragment>
|
|
289
|
+
{isOpen ? (
|
|
290
|
+
<DropdownContentWrapper
|
|
291
|
+
maxHeight={maxHeight}
|
|
292
|
+
open={isOpen}
|
|
293
|
+
ref={dropdownRef}
|
|
294
|
+
widthFitOptions={widthFitOptions}
|
|
295
|
+
tabIndex={0}
|
|
296
|
+
role="listbox"
|
|
297
|
+
id={`${ariaLabelledby}_listbox`}
|
|
298
|
+
>
|
|
299
|
+
<Stack childGap="0" as="ul">
|
|
300
|
+
{filteredOptions.map((choice, i) => {
|
|
301
|
+
if (
|
|
302
|
+
choice.value === value &&
|
|
303
|
+
selectedRef !== optionRefs.current[i]
|
|
304
|
+
) {
|
|
305
|
+
setSelectedRef(optionRefs.current[i]);
|
|
306
|
+
}
|
|
307
|
+
return (
|
|
308
|
+
<DropdownItemWrapper
|
|
309
|
+
id={
|
|
310
|
+
focusedRef === optionRefs.current[i]
|
|
311
|
+
? "focused_option"
|
|
312
|
+
: choice.value
|
|
313
|
+
}
|
|
314
|
+
key={choice.value}
|
|
315
|
+
ref={optionRefs.current[i]}
|
|
316
|
+
tabIndex={-1}
|
|
317
|
+
onClick={
|
|
318
|
+
disabledValues.includes(choice.value)
|
|
319
|
+
? evt => evt.preventDefault()
|
|
320
|
+
: () => {
|
|
321
|
+
setSelectedRef(optionRefs.current[i]);
|
|
322
|
+
onSelect(choice.value);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
selected={choice.value === value}
|
|
326
|
+
aria-selected={choice.value === value}
|
|
327
|
+
disabled={disabledValues.includes(choice.value)}
|
|
328
|
+
data-qa={choice.text}
|
|
329
|
+
themeValues={themeValues}
|
|
330
|
+
title={hasTitles ? choice.text : null}
|
|
331
|
+
role="option"
|
|
332
|
+
onFocus={() => setFocusedRef(optionRefs.current[i])}
|
|
333
|
+
>
|
|
334
|
+
<Text
|
|
335
|
+
variant="p"
|
|
336
|
+
color={
|
|
337
|
+
choice.value === value
|
|
338
|
+
? WHITE
|
|
339
|
+
: disabledValues.includes(choice.value)
|
|
340
|
+
? STORM_GREY
|
|
341
|
+
: MINESHAFT_GREY
|
|
314
342
|
}
|
|
315
|
-
|
|
316
|
-
aria-selected={choice.value === value}
|
|
317
|
-
disabled={disabledValues.includes(choice.value)}
|
|
318
|
-
data-qa={choice.text}
|
|
319
|
-
themeValues={themeValues}
|
|
320
|
-
title={hasTitles ? choice.text : null}
|
|
321
|
-
role="option"
|
|
322
|
-
onFocus={() => setFocusedRef(optionRefs.current[i])}
|
|
323
|
-
>
|
|
324
|
-
<Text
|
|
325
|
-
variant="p"
|
|
326
|
-
color={
|
|
327
|
-
choice.value === value
|
|
328
|
-
? WHITE
|
|
329
|
-
: disabledValues.includes(choice.value)
|
|
330
|
-
? STORM_GREY
|
|
331
|
-
: MINESHAFT_GREY
|
|
332
|
-
}
|
|
333
|
-
extraStyles={`padding-left: 16px;
|
|
343
|
+
extraStyles={`padding-left: 16px;
|
|
334
344
|
cursor: ${
|
|
335
345
|
disabledValues.includes(choice.value)
|
|
336
346
|
? "default"
|
|
@@ -339,22 +349,18 @@ const Dropdown = ({
|
|
|
339
349
|
white-space: nowrap;
|
|
340
350
|
overflow: hidden;
|
|
341
351
|
text-overflow: ellipsis;`}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
<IconWrapper open={isOpen}>
|
|
355
|
-
<DropdownIcon />
|
|
356
|
-
</IconWrapper>
|
|
357
|
-
</Stack>
|
|
352
|
+
>
|
|
353
|
+
{choice.text}
|
|
354
|
+
</Text>
|
|
355
|
+
</DropdownItemWrapper>
|
|
356
|
+
);
|
|
357
|
+
})}
|
|
358
|
+
</Stack>
|
|
359
|
+
</DropdownContentWrapper>
|
|
360
|
+
) : (
|
|
361
|
+
<Fragment />
|
|
362
|
+
)}
|
|
363
|
+
</Fragment>
|
|
358
364
|
</Fragment>
|
|
359
365
|
);
|
|
360
366
|
};
|