@thecb/components 6.0.0-beta.10 → 6.0.0-beta.13
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
|
@@ -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;
|
|
@@ -51,6 +51,7 @@ const DropdownItemWrapper = styled.div`
|
|
|
51
51
|
padding: 1rem;
|
|
52
52
|
box-sizing: border-box;
|
|
53
53
|
width: 100%;
|
|
54
|
+
list-style: none;
|
|
54
55
|
cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
|
|
55
56
|
|
|
56
57
|
&:hover {
|
|
@@ -170,6 +171,11 @@ const Dropdown = ({
|
|
|
170
171
|
optionRefs?.current?.length ?? 0 - 1
|
|
171
172
|
].current.focus();
|
|
172
173
|
break;
|
|
174
|
+
case "Escape":
|
|
175
|
+
if (isOpen) {
|
|
176
|
+
onClick();
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
173
179
|
}
|
|
174
180
|
};
|
|
175
181
|
|
|
@@ -225,8 +231,13 @@ const Dropdown = ({
|
|
|
225
231
|
}, [filteredOptions]);
|
|
226
232
|
|
|
227
233
|
return (
|
|
228
|
-
<
|
|
229
|
-
|
|
234
|
+
<Box
|
|
235
|
+
padding="0"
|
|
236
|
+
extraStyles={`position: relative;`}
|
|
237
|
+
minWidth="100%"
|
|
238
|
+
width="100%"
|
|
239
|
+
>
|
|
240
|
+
<Stack direction="row" bottomItem={2}>
|
|
230
241
|
<Box
|
|
231
242
|
as="input"
|
|
232
243
|
aria-multiline="false"
|
|
@@ -256,6 +267,7 @@ const Dropdown = ({
|
|
|
256
267
|
}
|
|
257
268
|
hoverStyles={`background-color: ${themeValues.hoverColor};`}
|
|
258
269
|
isOpen={isOpen}
|
|
270
|
+
minWidth="85%"
|
|
259
271
|
name={autocompleteValue}
|
|
260
272
|
onKeyDown={onKeyDown}
|
|
261
273
|
onClick={onClick}
|
|
@@ -273,64 +285,69 @@ const Dropdown = ({
|
|
|
273
285
|
type="text"
|
|
274
286
|
tabIndex={-1}
|
|
275
287
|
value={inputValue}
|
|
276
|
-
width="
|
|
288
|
+
width="85%"
|
|
277
289
|
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
|
-
|
|
290
|
+
/>
|
|
291
|
+
<IconWrapper open={isOpen}>
|
|
292
|
+
<DropdownIcon />
|
|
293
|
+
</IconWrapper>
|
|
294
|
+
</Stack>
|
|
295
|
+
<Fragment>
|
|
296
|
+
{isOpen ? (
|
|
297
|
+
<DropdownContentWrapper
|
|
298
|
+
maxHeight={maxHeight}
|
|
299
|
+
open={isOpen}
|
|
300
|
+
ref={dropdownRef}
|
|
301
|
+
widthFitOptions={widthFitOptions}
|
|
302
|
+
tabIndex={0}
|
|
303
|
+
role="listbox"
|
|
304
|
+
id={`${ariaLabelledby}_listbox`}
|
|
305
|
+
>
|
|
306
|
+
<Stack childGap="0" as="ul">
|
|
307
|
+
{filteredOptions.map((choice, i) => {
|
|
308
|
+
if (
|
|
309
|
+
choice.value === value &&
|
|
310
|
+
selectedRef !== optionRefs.current[i]
|
|
311
|
+
) {
|
|
312
|
+
setSelectedRef(optionRefs.current[i]);
|
|
313
|
+
}
|
|
314
|
+
return (
|
|
315
|
+
<DropdownItemWrapper
|
|
316
|
+
id={
|
|
317
|
+
focusedRef === optionRefs.current[i]
|
|
318
|
+
? "focused_option"
|
|
319
|
+
: choice.value
|
|
320
|
+
}
|
|
321
|
+
key={choice.value}
|
|
322
|
+
ref={optionRefs.current[i]}
|
|
323
|
+
tabIndex={-1}
|
|
324
|
+
onClick={
|
|
325
|
+
disabledValues.includes(choice.value)
|
|
326
|
+
? evt => evt.preventDefault()
|
|
327
|
+
: () => {
|
|
328
|
+
setSelectedRef(optionRefs.current[i]);
|
|
329
|
+
onSelect(choice.value);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
selected={choice.value === value}
|
|
333
|
+
aria-selected={choice.value === value}
|
|
334
|
+
disabled={disabledValues.includes(choice.value)}
|
|
335
|
+
data-qa={choice.text}
|
|
336
|
+
themeValues={themeValues}
|
|
337
|
+
title={hasTitles ? choice.text : null}
|
|
338
|
+
role="option"
|
|
339
|
+
onFocus={() => setFocusedRef(optionRefs.current[i])}
|
|
340
|
+
>
|
|
341
|
+
<Text
|
|
342
|
+
variant="p"
|
|
343
|
+
color={
|
|
344
|
+
choice.value === value
|
|
345
|
+
? WHITE
|
|
346
|
+
: disabledValues.includes(choice.value)
|
|
347
|
+
? STORM_GREY
|
|
348
|
+
: MINESHAFT_GREY
|
|
314
349
|
}
|
|
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;
|
|
350
|
+
extraStyles={`padding-left: 16px;
|
|
334
351
|
cursor: ${
|
|
335
352
|
disabledValues.includes(choice.value)
|
|
336
353
|
? "default"
|
|
@@ -339,23 +356,19 @@ const Dropdown = ({
|
|
|
339
356
|
white-space: nowrap;
|
|
340
357
|
overflow: hidden;
|
|
341
358
|
text-overflow: ellipsis;`}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
<DropdownIcon />
|
|
356
|
-
</IconWrapper>
|
|
357
|
-
</Stack>
|
|
358
|
-
</Fragment>
|
|
359
|
+
>
|
|
360
|
+
{choice.text}
|
|
361
|
+
</Text>
|
|
362
|
+
</DropdownItemWrapper>
|
|
363
|
+
);
|
|
364
|
+
})}
|
|
365
|
+
</Stack>
|
|
366
|
+
</DropdownContentWrapper>
|
|
367
|
+
) : (
|
|
368
|
+
<Fragment />
|
|
369
|
+
)}
|
|
370
|
+
</Fragment>
|
|
371
|
+
</Box>
|
|
359
372
|
);
|
|
360
373
|
};
|
|
361
374
|
|