@dxc-technology/halstack-react 0.0.0-e201636 → 0.0.0-e2a3793
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/accordion/Accordion.stories.tsx +1 -1
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +1 -0
- package/accordion-group/types.d.ts +1 -1
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +43 -61
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +34 -36
- package/chip/types.d.ts +1 -1
- package/common/variables.js +48 -14
- package/date-input/DateInput.js +3 -3
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -246
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/{row → flex}/types.js +0 -0
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +74 -72
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +15 -6
- package/layout/ApplicationLayout.js +37 -65
- package/layout/ApplicationLayout.stories.tsx +79 -44
- package/layout/types.d.ts +17 -27
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +13 -6
- package/link/types.d.ts +1 -1
- package/main.d.ts +5 -8
- package/main.js +28 -52
- package/package.json +8 -7
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +56 -50
- package/progress-bar/ProgressBar.stories.jsx +3 -1
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +21 -15
- package/quick-nav/QuickNav.stories.tsx +41 -14
- package/radio-group/RadioGroup.js +13 -14
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +54 -7
- package/select/Select.js +41 -43
- package/select/Select.stories.tsx +131 -98
- package/select/Select.test.js +105 -50
- package/select/types.d.ts +2 -5
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +176 -55
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.js +3 -3
- package/slider/Slider.test.js +37 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +110 -54
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/types.d.ts +1 -1
- package/tabs-nav/NavTabs.js +5 -5
- package/tabs-nav/Tab.js +3 -5
- package/tabs-nav/types.d.ts +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/TextInput.js +12 -21
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/{stack → typography}/types.js +0 -0
- package/wizard/Wizard.js +9 -16
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
package/select/Select.js
CHANGED
|
@@ -35,6 +35,8 @@ var _Icons = _interopRequireDefault(require("./Icons"));
|
|
|
35
35
|
|
|
36
36
|
var _Listbox = _interopRequireDefault(require("./Listbox"));
|
|
37
37
|
|
|
38
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
39
|
+
|
|
38
40
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
39
41
|
|
|
40
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -195,9 +197,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
195
197
|
isOpen = _useState10[0],
|
|
196
198
|
changeIsOpen = _useState10[1];
|
|
197
199
|
|
|
198
|
-
var
|
|
200
|
+
var selectRef = (0, _react.useRef)(null);
|
|
199
201
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
200
|
-
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
201
202
|
var colorsTheme = (0, _useTheme["default"])();
|
|
202
203
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
203
204
|
var optionalItem = {
|
|
@@ -275,9 +276,9 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
275
276
|
};
|
|
276
277
|
|
|
277
278
|
var handleSelectOnKeyDown = function handleSelectOnKeyDown(event) {
|
|
278
|
-
switch (event.
|
|
279
|
-
case
|
|
280
|
-
|
|
279
|
+
switch (event.key) {
|
|
280
|
+
case "Down":
|
|
281
|
+
case "ArrowDown":
|
|
281
282
|
event.preventDefault();
|
|
282
283
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
283
284
|
if (visualFocusIndex < lastOptionIndex) return visualFocusIndex + 1;else if (visualFocusIndex === lastOptionIndex) return 0;
|
|
@@ -285,8 +286,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
285
286
|
openOptions();
|
|
286
287
|
break;
|
|
287
288
|
|
|
288
|
-
case
|
|
289
|
-
|
|
289
|
+
case "Up":
|
|
290
|
+
case "ArrowUp":
|
|
290
291
|
event.preventDefault();
|
|
291
292
|
singleSelectionIndex !== undefined && (!isOpen || visualFocusIndex === -1 && singleSelectionIndex > -1 && singleSelectionIndex <= lastOptionIndex) ? changeVisualFocusIndex(singleSelectionIndex) : changeVisualFocusIndex(function (visualFocusIndex) {
|
|
292
293
|
return visualFocusIndex === 0 || visualFocusIndex === -1 ? lastOptionIndex : visualFocusIndex - 1;
|
|
@@ -294,15 +295,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
294
295
|
openOptions();
|
|
295
296
|
break;
|
|
296
297
|
|
|
297
|
-
case
|
|
298
|
-
|
|
298
|
+
case "Esc":
|
|
299
|
+
case "Escape":
|
|
299
300
|
event.preventDefault();
|
|
300
301
|
closeOptions();
|
|
301
302
|
setSearchValue("");
|
|
302
303
|
break;
|
|
303
304
|
|
|
304
|
-
case
|
|
305
|
-
// Enter
|
|
305
|
+
case "Enter":
|
|
306
306
|
if (isOpen && visualFocusIndex >= 0) {
|
|
307
307
|
var accLength = optional && !multiple ? 1 : 0;
|
|
308
308
|
|
|
@@ -359,26 +359,12 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
359
359
|
!multiple && closeOptions();
|
|
360
360
|
setSearchValue("");
|
|
361
361
|
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
362
|
-
(0, _react.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
listEl === null || listEl === void 0 ? void 0 : (_listEl$scrollTo = listEl.scrollTo) === null || _listEl$scrollTo === void 0 ? void 0 : _listEl$scrollTo.call(listEl, {
|
|
369
|
-
top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}, [isOpen]);
|
|
373
|
-
(0, _react.useLayoutEffect)(function () {
|
|
374
|
-
var _selectOptionsListRef, _visualFocusedOptionE;
|
|
375
|
-
|
|
376
|
-
var visualFocusedOptionEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : (_selectOptionsListRef = selectOptionsListRef.current) === null || _selectOptionsListRef === void 0 ? void 0 : _selectOptionsListRef.querySelectorAll("[role='option']")[visualFocusIndex];
|
|
377
|
-
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
378
|
-
block: "nearest",
|
|
379
|
-
inline: "start"
|
|
380
|
-
});
|
|
381
|
-
}, [visualFocusIndex]);
|
|
362
|
+
var getSelectWidth = (0, _react.useCallback)(function () {
|
|
363
|
+
var _selectRef$current;
|
|
364
|
+
|
|
365
|
+
var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
|
|
366
|
+
return rect === null || rect === void 0 ? void 0 : rect.width;
|
|
367
|
+
}, []);
|
|
382
368
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
383
369
|
theme: colorsTheme.select
|
|
384
370
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -389,12 +375,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
389
375
|
id: selectLabelId,
|
|
390
376
|
disabled: disabled,
|
|
391
377
|
onClick: function onClick() {
|
|
392
|
-
|
|
378
|
+
selectRef.current.focus();
|
|
393
379
|
},
|
|
394
380
|
helperText: helperText
|
|
395
381
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
396
382
|
disabled: disabled
|
|
397
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(
|
|
383
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
384
|
+
open: isOpen
|
|
385
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
386
|
+
asChild: true
|
|
387
|
+
}, /*#__PURE__*/_react["default"].createElement(Select, {
|
|
398
388
|
id: selectId,
|
|
399
389
|
disabled: disabled,
|
|
400
390
|
error: error,
|
|
@@ -402,16 +392,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
402
392
|
onClick: handleSelectOnClick,
|
|
403
393
|
onFocus: handleSelectOnFocus,
|
|
404
394
|
onKeyDown: handleSelectOnKeyDown,
|
|
405
|
-
ref:
|
|
406
|
-
tabIndex: tabIndex,
|
|
395
|
+
ref: selectRef,
|
|
396
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
407
397
|
role: "combobox",
|
|
408
398
|
"aria-controls": optionsListId,
|
|
409
399
|
"aria-disabled": disabled,
|
|
410
400
|
"aria-expanded": isOpen,
|
|
411
401
|
"aria-haspopup": "listbox",
|
|
412
|
-
"aria-labelledby": selectLabelId,
|
|
402
|
+
"aria-labelledby": label ? selectLabelId : undefined,
|
|
413
403
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
414
|
-
"aria-invalid": error ?
|
|
404
|
+
"aria-invalid": error ? true : false,
|
|
415
405
|
"aria-errormessage": error ? errorId : undefined,
|
|
416
406
|
"aria-required": !disabled && !optional
|
|
417
407
|
}, multiple && selectedOption.length > 0 && /*#__PURE__*/_react["default"].createElement(SelectionIndicator, null, /*#__PURE__*/_react["default"].createElement(SelectionNumber, {
|
|
@@ -458,7 +448,17 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
458
448
|
"aria-label": translatedLabels.select.actionClearSearchTitle
|
|
459
449
|
}, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
|
|
460
450
|
disabled: disabled
|
|
461
|
-
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown),
|
|
451
|
+
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
452
|
+
sideOffset: 4,
|
|
453
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
454
|
+
// Avoid select to lose focus when the list is opened
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
},
|
|
457
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
458
|
+
// Avoid select to lose focus when the list is closed
|
|
459
|
+
event.preventDefault();
|
|
460
|
+
}
|
|
461
|
+
}, /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
|
|
462
462
|
id: optionsListId,
|
|
463
463
|
currentValue: value !== null && value !== void 0 ? value : innerValue,
|
|
464
464
|
options: searchable ? filteredOptions : options,
|
|
@@ -469,8 +469,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
469
469
|
optionalItem: optionalItem,
|
|
470
470
|
searchable: searchable,
|
|
471
471
|
handleOptionOnClick: handleOptionOnClick,
|
|
472
|
-
|
|
473
|
-
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
472
|
+
getSelectWidth: getSelectWidth
|
|
473
|
+
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
474
474
|
id: errorId,
|
|
475
475
|
"aria-live": error ? "assertive" : "off"
|
|
476
476
|
}, error)));
|
|
@@ -569,9 +569,7 @@ var SelectionNumber = _styledComponents["default"].span(_templateObject7 || (_te
|
|
|
569
569
|
return props.disabled ? "cursor: not-allowed;" : "cursor: default;";
|
|
570
570
|
});
|
|
571
571
|
|
|
572
|
-
var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n
|
|
573
|
-
return props.theme.fontFamily;
|
|
574
|
-
}, function (props) {
|
|
572
|
+
var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n border: none;\n padding: 0.25rem;\n ", "\n background-color: ", ";\n color: ", ";\n\n :focus-visible {\n outline: none;\n }\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
|
|
575
573
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
576
574
|
}, function (props) {
|
|
577
575
|
return props.disabled ? "transparent" : props.theme.enabledSelectionIndicatorActionBackgroundColor;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
2
|
import { userEvent, within, waitFor } from "@storybook/testing-library";
|
|
4
|
-
import { fireEvent } from "@testing-library/react";
|
|
5
|
-
|
|
6
3
|
import Title from "../../.storybook/components/Title";
|
|
7
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
8
|
-
|
|
9
5
|
import DxcSelect from "./Select";
|
|
6
|
+
import Listbox from "./Listbox";
|
|
7
|
+
import DxcButton from "../button/Button";
|
|
8
|
+
import DxcCheckbox from "../checkbox/Checkbox";
|
|
10
9
|
|
|
11
10
|
export default {
|
|
12
11
|
title: "Select",
|
|
@@ -340,7 +339,7 @@ const Select = () => (
|
|
|
340
339
|
<DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
|
|
341
340
|
<Title title="Value with ellipsis" theme="light" level={4} />
|
|
342
341
|
<DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
|
|
343
|
-
<Title title="
|
|
342
|
+
<Title title="Options with ellipsis" theme="light" level={4} />
|
|
344
343
|
<DxcSelect
|
|
345
344
|
label="Label"
|
|
346
345
|
placeholder="Choose an option"
|
|
@@ -351,16 +350,104 @@ const Select = () => (
|
|
|
351
350
|
</ExampleContainer>
|
|
352
351
|
</>
|
|
353
352
|
);
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
353
|
+
const SelectListbox = () => (
|
|
354
|
+
<>
|
|
355
|
+
<Title title="Listbox" theme="light" level={2} />
|
|
356
|
+
<Title title="Default with opened listbox" theme="light" level={3} />
|
|
357
|
+
<ExampleContainer>
|
|
358
|
+
<div style={{ display: "flex", gap: "30px", flexDirection: "column", marginBottom: "80px" }}>
|
|
359
|
+
<DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
|
|
360
|
+
<DxcCheckbox
|
|
361
|
+
label="You understand the selection and give your consent"
|
|
362
|
+
onChange={() => {}}
|
|
363
|
+
labelPosition="after"
|
|
364
|
+
/>
|
|
365
|
+
<DxcButton label="Submit" onClick={() => {}} size="medium" />
|
|
366
|
+
</div>
|
|
367
|
+
</ExampleContainer>
|
|
368
|
+
<Title title="Listbox option states" theme="light" level={3} />
|
|
369
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
370
|
+
<Title title="Hovered option" theme="light" level={4} />
|
|
371
|
+
<Listbox
|
|
372
|
+
id="x"
|
|
373
|
+
currentValue=""
|
|
374
|
+
options={one_option}
|
|
375
|
+
visualFocusIndex={-1}
|
|
376
|
+
lastOptionIndex={0}
|
|
377
|
+
multiple={false}
|
|
378
|
+
optional={false}
|
|
379
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
380
|
+
searchable={false}
|
|
381
|
+
handleOptionOnClick={() => {}}
|
|
382
|
+
getSelectWidth={() => 360}
|
|
383
|
+
/>
|
|
384
|
+
</ExampleContainer>
|
|
385
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
386
|
+
<Title title="Active option" theme="light" level={4} />
|
|
387
|
+
<Listbox
|
|
388
|
+
id="x"
|
|
389
|
+
currentValue=""
|
|
390
|
+
options={one_option}
|
|
391
|
+
visualFocusIndex={-1}
|
|
392
|
+
lastOptionIndex={0}
|
|
393
|
+
multiple={false}
|
|
394
|
+
optional={false}
|
|
395
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
396
|
+
searchable={false}
|
|
397
|
+
handleOptionOnClick={() => {}}
|
|
398
|
+
getSelectWidth={() => 360}
|
|
399
|
+
|
|
400
|
+
/>
|
|
401
|
+
</ExampleContainer>
|
|
402
|
+
<ExampleContainer>
|
|
403
|
+
<Title title="Focused option" theme="light" level={4} />
|
|
404
|
+
<Listbox
|
|
405
|
+
id="x"
|
|
406
|
+
currentValue=""
|
|
407
|
+
options={one_option}
|
|
408
|
+
visualFocusIndex={0}
|
|
409
|
+
lastOptionIndex={0}
|
|
410
|
+
multiple={false}
|
|
411
|
+
optional={false}
|
|
412
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
413
|
+
searchable={false}
|
|
414
|
+
handleOptionOnClick={() => {}}
|
|
415
|
+
getSelectWidth={() => 360}
|
|
416
|
+
/>
|
|
417
|
+
</ExampleContainer>
|
|
418
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
419
|
+
<Title title="Hovered selected option" theme="light" level={4} />
|
|
420
|
+
<Listbox
|
|
421
|
+
id="x"
|
|
422
|
+
currentValue="1"
|
|
423
|
+
options={single_options}
|
|
424
|
+
visualFocusIndex={-1}
|
|
425
|
+
lastOptionIndex={3}
|
|
426
|
+
multiple={false}
|
|
427
|
+
optional={false}
|
|
428
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
429
|
+
searchable={false}
|
|
430
|
+
handleOptionOnClick={() => {}}
|
|
431
|
+
getSelectWidth={() => 360}
|
|
432
|
+
/>
|
|
433
|
+
</ExampleContainer>
|
|
434
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
435
|
+
<Title title="Active selected option" theme="light" level={4} />
|
|
436
|
+
<Listbox
|
|
437
|
+
id="x"
|
|
438
|
+
currentValue="2"
|
|
439
|
+
options={single_options}
|
|
440
|
+
visualFocusIndex={0}
|
|
441
|
+
lastOptionIndex={3}
|
|
442
|
+
multiple={false}
|
|
443
|
+
optional={false}
|
|
444
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
445
|
+
searchable={false}
|
|
446
|
+
handleOptionOnClick={() => {}}
|
|
447
|
+
getSelectWidth={() => 360}
|
|
448
|
+
/>
|
|
449
|
+
</ExampleContainer>
|
|
450
|
+
</>
|
|
364
451
|
);
|
|
365
452
|
const SearchableSelect = () => (
|
|
366
453
|
<ExampleContainer expanded>
|
|
@@ -368,7 +455,7 @@ const SearchableSelect = () => (
|
|
|
368
455
|
<DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
|
|
369
456
|
</ExampleContainer>
|
|
370
457
|
);
|
|
371
|
-
const
|
|
458
|
+
const SearchValue = () => (
|
|
372
459
|
<ExampleContainer expanded>
|
|
373
460
|
<Title title="Searchable select with value" theme="light" level={4} />
|
|
374
461
|
<DxcSelect
|
|
@@ -380,7 +467,6 @@ const SearchableWithValue = () => (
|
|
|
380
467
|
/>
|
|
381
468
|
</ExampleContainer>
|
|
382
469
|
);
|
|
383
|
-
|
|
384
470
|
const MultipleSelect = () => (
|
|
385
471
|
<>
|
|
386
472
|
<ExampleContainer expanded>
|
|
@@ -443,36 +529,7 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
|
|
|
443
529
|
/>
|
|
444
530
|
</ExampleContainer>
|
|
445
531
|
);
|
|
446
|
-
|
|
447
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
448
|
-
<Title title="Hovered Option" theme="light" level={4} />
|
|
449
|
-
<DxcSelect label="Hovered" options={one_option} placeholder="Choose an option" />
|
|
450
|
-
</ExampleContainer>
|
|
451
|
-
);
|
|
452
|
-
const OnlyOneOptionFocused = () => (
|
|
453
|
-
<ExampleContainer pseudoState="pseudo-focus" expanded>
|
|
454
|
-
<Title title="Focused Option" theme="light" level={4} />
|
|
455
|
-
<DxcSelect label="Focused" options={one_option} placeholder="Choose an option" />
|
|
456
|
-
</ExampleContainer>
|
|
457
|
-
);
|
|
458
|
-
const OnlyOneOptionActived = () => (
|
|
459
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
460
|
-
<Title title="Actived Option" theme="light" level={4} />
|
|
461
|
-
<DxcSelect label="Actived" options={one_option} placeholder="Choose an option" />
|
|
462
|
-
</ExampleContainer>
|
|
463
|
-
);
|
|
464
|
-
const SelectedOptionHovered = () => (
|
|
465
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
466
|
-
<Title title="Hovered Selected Option" theme="light" level={4} />
|
|
467
|
-
<DxcSelect label="Hovered" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
468
|
-
</ExampleContainer>
|
|
469
|
-
);
|
|
470
|
-
const SelectedOptionActived = () => (
|
|
471
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
472
|
-
<Title title="Actived Selected Option" theme="light" level={4} />
|
|
473
|
-
<DxcSelect label="Actived" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
474
|
-
</ExampleContainer>
|
|
475
|
-
);
|
|
532
|
+
|
|
476
533
|
const MultipleSearchable = () => (
|
|
477
534
|
<ExampleContainer expanded>
|
|
478
535
|
<Title title="Searchable multiple select with value" theme="light" level={4} />
|
|
@@ -486,12 +543,20 @@ const MultipleSearchable = () => (
|
|
|
486
543
|
/>
|
|
487
544
|
</ExampleContainer>
|
|
488
545
|
);
|
|
489
|
-
|
|
490
|
-
|
|
546
|
+
|
|
547
|
+
export const Chromatic = Select.bind({});
|
|
548
|
+
Chromatic.play = async ({ canvasElement }) => {
|
|
549
|
+
const canvas = within(canvasElement);
|
|
550
|
+
await userEvent.click(canvas.getAllByRole("combobox")[24]);
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
export const ListboxStates = SelectListbox.bind({});
|
|
554
|
+
ListboxStates.play = async ({ canvasElement }) => {
|
|
491
555
|
const canvas = within(canvasElement);
|
|
492
556
|
const select = canvas.getByRole("combobox");
|
|
493
557
|
await userEvent.click(select);
|
|
494
558
|
};
|
|
559
|
+
|
|
495
560
|
export const Searchable = SearchableSelect.bind({});
|
|
496
561
|
Searchable.play = async ({ canvasElement }) => {
|
|
497
562
|
const canvas = within(canvasElement);
|
|
@@ -500,14 +565,15 @@ Searchable.play = async ({ canvasElement }) => {
|
|
|
500
565
|
userEvent.type(canvas.getByRole("combobox"), "r");
|
|
501
566
|
});
|
|
502
567
|
};
|
|
503
|
-
|
|
504
|
-
|
|
568
|
+
|
|
569
|
+
export const SearchableWithValue = SearchValue.bind({});
|
|
570
|
+
SearchableWithValue.play = async ({ canvasElement }) => {
|
|
505
571
|
const canvas = within(canvasElement);
|
|
506
572
|
await userEvent.click(canvas.getByRole("combobox"));
|
|
507
573
|
};
|
|
508
574
|
|
|
509
|
-
export const
|
|
510
|
-
|
|
575
|
+
export const MultipleSearchableWithValue = MultipleSearchable.bind({});
|
|
576
|
+
MultipleSearchableWithValue.play = async ({ canvasElement }) => {
|
|
511
577
|
const canvas = within(canvasElement);
|
|
512
578
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
513
579
|
};
|
|
@@ -519,75 +585,42 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
|
519
585
|
await userEvent.click(select);
|
|
520
586
|
};
|
|
521
587
|
|
|
522
|
-
export const
|
|
523
|
-
|
|
588
|
+
export const MultipleOptionsDisplayed = MultipleSelect.bind({});
|
|
589
|
+
MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
524
590
|
const canvas = within(canvasElement);
|
|
525
591
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
526
592
|
};
|
|
527
593
|
|
|
528
|
-
export const
|
|
529
|
-
|
|
530
|
-
const canvas = within(canvasElement);
|
|
531
|
-
const select = canvas.getByRole("combobox");
|
|
532
|
-
await userEvent.click(select);
|
|
533
|
-
};
|
|
534
|
-
export const SelectWithIconsDisplayed = SelectWithIcons.bind({});
|
|
535
|
-
SelectWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
594
|
+
export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
|
|
595
|
+
MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
536
596
|
const canvas = within(canvasElement);
|
|
537
597
|
const select = canvas.getByRole("combobox");
|
|
538
598
|
await userEvent.click(select);
|
|
539
599
|
};
|
|
540
600
|
|
|
541
|
-
export const
|
|
542
|
-
|
|
543
|
-
const canvas = within(canvasElement);
|
|
544
|
-
const select = canvas.getByRole("combobox");
|
|
545
|
-
await userEvent.click(select);
|
|
546
|
-
};
|
|
547
|
-
export const SelectMultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
548
|
-
SelectMultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
601
|
+
export const WithIconsDisplayed = SelectWithIcons.bind({});
|
|
602
|
+
WithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
549
603
|
const canvas = within(canvasElement);
|
|
550
604
|
const select = canvas.getByRole("combobox");
|
|
551
605
|
await userEvent.click(select);
|
|
552
606
|
};
|
|
553
607
|
|
|
554
|
-
export const
|
|
555
|
-
|
|
608
|
+
export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
|
|
609
|
+
WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
|
|
556
610
|
const canvas = within(canvasElement);
|
|
557
611
|
const select = canvas.getByRole("combobox");
|
|
558
612
|
await userEvent.click(select);
|
|
559
613
|
};
|
|
560
614
|
|
|
561
|
-
export const
|
|
562
|
-
|
|
615
|
+
export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
616
|
+
MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
563
617
|
const canvas = within(canvasElement);
|
|
564
618
|
const select = canvas.getByRole("combobox");
|
|
565
619
|
await userEvent.click(select);
|
|
566
620
|
};
|
|
567
621
|
|
|
568
|
-
export const
|
|
569
|
-
|
|
570
|
-
const canvas = within(canvasElement);
|
|
571
|
-
const select = canvas.getByRole("combobox");
|
|
572
|
-
await userEvent.click(select);
|
|
573
|
-
await waitFor(async () => {
|
|
574
|
-
fireEvent.keyDown(select, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
export const OptionActived = OnlyOneOptionActived.bind({});
|
|
578
|
-
OptionActived.play = async ({ canvasElement }) => {
|
|
579
|
-
const canvas = within(canvasElement);
|
|
580
|
-
const select = canvas.getByRole("combobox");
|
|
581
|
-
await userEvent.click(select);
|
|
582
|
-
};
|
|
583
|
-
export const OptionSelectedHovered = SelectedOptionHovered.bind({});
|
|
584
|
-
OptionSelectedHovered.play = async ({ canvasElement }) => {
|
|
585
|
-
const canvas = within(canvasElement);
|
|
586
|
-
const select = canvas.getByRole("combobox");
|
|
587
|
-
await userEvent.click(select);
|
|
588
|
-
};
|
|
589
|
-
export const OptionSelectedActived = SelectedOptionActived.bind({});
|
|
590
|
-
OptionSelectedActived.play = async ({ canvasElement }) => {
|
|
622
|
+
export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
|
|
623
|
+
MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
591
624
|
const canvas = within(canvasElement);
|
|
592
625
|
const select = canvas.getByRole("combobox");
|
|
593
626
|
await userEvent.click(select);
|