@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.
Files changed (118) hide show
  1. package/accordion/Accordion.stories.tsx +1 -1
  2. package/accordion/types.d.ts +1 -1
  3. package/accordion-group/AccordionGroup.js +1 -0
  4. package/accordion-group/types.d.ts +1 -1
  5. package/bleed/Bleed.js +1 -34
  6. package/bleed/Bleed.stories.tsx +94 -95
  7. package/bleed/types.d.ts +1 -1
  8. package/bulleted-list/BulletedList.d.ts +7 -0
  9. package/bulleted-list/BulletedList.js +123 -0
  10. package/bulleted-list/BulletedList.stories.tsx +200 -0
  11. package/bulleted-list/types.d.ts +11 -0
  12. package/{list → bulleted-list}/types.js +0 -0
  13. package/button/Button.js +43 -61
  14. package/button/Button.stories.tsx +9 -0
  15. package/button/types.d.ts +7 -7
  16. package/card/Card.js +34 -36
  17. package/chip/types.d.ts +1 -1
  18. package/common/variables.js +48 -14
  19. package/date-input/DateInput.js +3 -3
  20. package/dialog/Dialog.js +52 -28
  21. package/dialog/Dialog.stories.tsx +1 -2
  22. package/dialog/Dialog.test.js +34 -4
  23. package/dialog/types.d.ts +2 -2
  24. package/dropdown/Dropdown.d.ts +1 -1
  25. package/dropdown/Dropdown.js +242 -246
  26. package/dropdown/Dropdown.stories.tsx +126 -63
  27. package/dropdown/Dropdown.test.js +510 -108
  28. package/dropdown/DropdownMenu.d.ts +4 -0
  29. package/dropdown/DropdownMenu.js +80 -0
  30. package/dropdown/DropdownMenuItem.d.ts +4 -0
  31. package/dropdown/DropdownMenuItem.js +92 -0
  32. package/dropdown/types.d.ts +25 -5
  33. package/flex/Flex.d.ts +4 -0
  34. package/flex/Flex.js +57 -0
  35. package/flex/Flex.stories.tsx +103 -0
  36. package/flex/types.d.ts +21 -0
  37. package/{row → flex}/types.js +0 -0
  38. package/footer/Icons.js +1 -1
  39. package/footer/types.d.ts +1 -1
  40. package/header/Header.js +74 -72
  41. package/header/Icons.js +2 -2
  42. package/header/types.d.ts +2 -2
  43. package/inset/Inset.js +1 -34
  44. package/inset/Inset.stories.tsx +36 -36
  45. package/inset/types.d.ts +1 -1
  46. package/layout/ApplicationLayout.d.ts +15 -6
  47. package/layout/ApplicationLayout.js +37 -65
  48. package/layout/ApplicationLayout.stories.tsx +79 -44
  49. package/layout/types.d.ts +17 -27
  50. package/link/Link.js +1 -1
  51. package/link/Link.stories.tsx +13 -6
  52. package/link/types.d.ts +1 -1
  53. package/main.d.ts +5 -8
  54. package/main.js +28 -52
  55. package/package.json +8 -7
  56. package/paginator/Paginator.test.js +42 -0
  57. package/paragraph/Paragraph.d.ts +6 -0
  58. package/paragraph/Paragraph.js +38 -0
  59. package/paragraph/Paragraph.stories.tsx +44 -0
  60. package/progress-bar/ProgressBar.d.ts +2 -2
  61. package/progress-bar/ProgressBar.js +56 -50
  62. package/progress-bar/ProgressBar.stories.jsx +3 -1
  63. package/progress-bar/ProgressBar.test.js +67 -22
  64. package/progress-bar/types.d.ts +3 -4
  65. package/quick-nav/QuickNav.js +21 -15
  66. package/quick-nav/QuickNav.stories.tsx +41 -14
  67. package/radio-group/RadioGroup.js +13 -14
  68. package/resultsetTable/ResultsetTable.test.js +42 -0
  69. package/select/Listbox.d.ts +1 -1
  70. package/select/Listbox.js +54 -7
  71. package/select/Select.js +41 -43
  72. package/select/Select.stories.tsx +131 -98
  73. package/select/Select.test.js +105 -50
  74. package/select/types.d.ts +2 -5
  75. package/sidenav/Sidenav.d.ts +6 -5
  76. package/sidenav/Sidenav.js +176 -55
  77. package/sidenav/Sidenav.stories.tsx +154 -156
  78. package/sidenav/Sidenav.test.js +25 -37
  79. package/sidenav/types.d.ts +50 -27
  80. package/slider/Slider.js +3 -3
  81. package/slider/Slider.test.js +37 -0
  82. package/switch/Switch.d.ts +1 -1
  83. package/switch/Switch.js +110 -54
  84. package/switch/Switch.stories.tsx +8 -30
  85. package/switch/Switch.test.js +122 -8
  86. package/switch/types.d.ts +3 -4
  87. package/tabs/types.d.ts +1 -1
  88. package/tabs-nav/NavTabs.js +5 -5
  89. package/tabs-nav/Tab.js +3 -5
  90. package/tabs-nav/types.d.ts +1 -1
  91. package/tag/types.d.ts +1 -1
  92. package/text-input/TextInput.js +12 -21
  93. package/text-input/TextInput.stories.tsx +1 -2
  94. package/text-input/types.d.ts +1 -1
  95. package/toggle-group/types.d.ts +1 -1
  96. package/typography/Typography.d.ts +4 -0
  97. package/typography/Typography.js +131 -0
  98. package/typography/Typography.stories.tsx +198 -0
  99. package/typography/types.d.ts +18 -0
  100. package/{stack → typography}/types.js +0 -0
  101. package/wizard/Wizard.js +9 -16
  102. package/wizard/Wizard.stories.tsx +20 -1
  103. package/wizard/types.d.ts +5 -4
  104. package/list/List.d.ts +0 -4
  105. package/list/List.js +0 -47
  106. package/list/List.stories.tsx +0 -95
  107. package/list/types.d.ts +0 -7
  108. package/row/Row.d.ts +0 -3
  109. package/row/Row.js +0 -127
  110. package/row/Row.stories.tsx +0 -237
  111. package/row/types.d.ts +0 -28
  112. package/stack/Stack.d.ts +0 -3
  113. package/stack/Stack.js +0 -97
  114. package/stack/Stack.stories.tsx +0 -164
  115. package/stack/types.d.ts +0 -24
  116. package/text/Text.d.ts +0 -7
  117. package/text/Text.js +0 -30
  118. 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 selectContainerRef = (0, _react.useRef)(null);
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.keyCode) {
279
- case 40:
280
- // Arrow Down
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 38:
289
- // Arrow Up
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 27:
298
- // Esc
298
+ case "Esc":
299
+ case "Escape":
299
300
  event.preventDefault();
300
301
  closeOptions();
301
302
  setSearchValue("");
302
303
  break;
303
304
 
304
- case 13:
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.useLayoutEffect)(function () {
363
- if (isOpen && singleSelectionIndex) {
364
- var _listEl$scrollTo;
365
-
366
- var listEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : selectOptionsListRef.current;
367
- var selectedListOptionEl = listEl === null || listEl === void 0 ? void 0 : listEl.querySelector("[aria-selected='true']");
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
- selectContainerRef.current.focus();
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(Select, {
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: selectContainerRef,
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 ? "true" : "false",
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), isOpen && /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
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
- ref: selectOptionsListRef
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 font-size: 1rem;\n font-family: ", ";\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) {
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="Option with ellipsis" theme="light" level={4} />
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
- export const Chromatic = Select.bind({});
355
- Chromatic.play = async ({ canvasElement }) => {
356
- const canvas = within(canvasElement);
357
- await userEvent.click(canvas.getAllByRole("combobox")[24]);
358
- };
359
- const DefaultSelect = () => (
360
- <ExampleContainer expanded>
361
- <Title title="Default select" theme="light" level={4} />
362
- <DxcSelect label="Select label" options={single_options} optional placeholder="Choose an option" />
363
- </ExampleContainer>
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 SearchableWithValue = () => (
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
- const OnlyOneOptionHovered = () => (
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
- export const OptionsDisplayed = DefaultSelect.bind({});
490
- OptionsDisplayed.play = async ({ canvasElement }) => {
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
- export const SelectSearchableWithValue = SearchableWithValue.bind({});
504
- SelectSearchableWithValue.play = async ({ canvasElement }) => {
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 SelectMultipleSearchableWithValue = MultipleSearchable.bind({});
510
- SelectMultipleSearchableWithValue.play = async ({ canvasElement }) => {
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 SelectMultipleOptionsDisplayed = MultipleSelect.bind({});
523
- SelectMultipleOptionsDisplayed.play = async ({ canvasElement }) => {
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 SelectMultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
529
- SelectMultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
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 SelectWithRescaledIconsDisplayed = RescaledIcons.bind({});
542
- SelectWithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
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 SelectMultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
555
- SelectMultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
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 OptionHovered = OnlyOneOptionHovered.bind({});
562
- OptionHovered.play = async ({ canvasElement }) => {
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 OptionFocused = OnlyOneOptionFocused.bind({});
569
- OptionFocused.play = async ({ canvasElement }) => {
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);