@dxc-technology/halstack-react 0.0.0-ec7b867 → 0.0.0-ecc45e2

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 (240) hide show
  1. package/HalstackContext.d.ts +12 -0
  2. package/HalstackContext.js +295 -0
  3. package/accordion/Accordion.d.ts +1 -1
  4. package/accordion/Accordion.js +7 -28
  5. package/accordion/Accordion.stories.tsx +12 -12
  6. package/accordion/Accordion.test.js +72 -0
  7. package/accordion/types.d.ts +5 -1
  8. package/accordion-group/AccordionGroup.d.ts +1 -1
  9. package/accordion-group/AccordionGroup.js +14 -15
  10. package/accordion-group/AccordionGroup.stories.tsx +1 -1
  11. package/accordion-group/AccordionGroup.test.js +151 -0
  12. package/accordion-group/types.d.ts +5 -1
  13. package/alert/Alert.js +4 -1
  14. package/alert/Alert.test.js +92 -0
  15. package/badge/Badge.d.ts +4 -0
  16. package/badge/Badge.js +5 -3
  17. package/badge/types.d.ts +5 -0
  18. package/{list → badge}/types.js +0 -0
  19. package/bleed/Bleed.js +1 -34
  20. package/bleed/Bleed.stories.tsx +94 -95
  21. package/bleed/types.d.ts +25 -1
  22. package/box/Box.js +22 -32
  23. package/box/Box.test.js +18 -0
  24. package/bulleted-list/BulletedList.d.ts +7 -0
  25. package/bulleted-list/BulletedList.js +123 -0
  26. package/bulleted-list/BulletedList.stories.tsx +200 -0
  27. package/bulleted-list/types.d.ts +11 -0
  28. package/{radio → bulleted-list}/types.js +0 -0
  29. package/button/Button.js +53 -68
  30. package/button/Button.stories.tsx +9 -0
  31. package/button/Button.test.js +35 -0
  32. package/button/types.d.ts +7 -7
  33. package/card/Card.js +24 -27
  34. package/card/Card.test.js +50 -0
  35. package/checkbox/Checkbox.d.ts +1 -1
  36. package/checkbox/Checkbox.js +43 -39
  37. package/checkbox/Checkbox.stories.tsx +124 -128
  38. package/checkbox/Checkbox.test.js +78 -0
  39. package/checkbox/types.d.ts +7 -3
  40. package/chip/Chip.test.js +56 -0
  41. package/chip/types.d.ts +1 -1
  42. package/common/variables.js +229 -336
  43. package/date-input/DateInput.js +56 -42
  44. package/date-input/DateInput.stories.tsx +7 -7
  45. package/date-input/DateInput.test.js +479 -0
  46. package/date-input/types.d.ts +16 -9
  47. package/dialog/Dialog.js +46 -50
  48. package/dialog/Dialog.stories.tsx +1 -2
  49. package/dialog/Dialog.test.js +70 -0
  50. package/dialog/types.d.ts +2 -2
  51. package/dropdown/Dropdown.d.ts +1 -1
  52. package/dropdown/Dropdown.js +242 -250
  53. package/dropdown/Dropdown.stories.tsx +126 -63
  54. package/dropdown/Dropdown.test.js +591 -0
  55. package/dropdown/DropdownMenu.d.ts +4 -0
  56. package/dropdown/DropdownMenu.js +80 -0
  57. package/dropdown/DropdownMenuItem.d.ts +4 -0
  58. package/dropdown/DropdownMenuItem.js +92 -0
  59. package/dropdown/types.d.ts +25 -5
  60. package/file-input/FileInput.js +9 -6
  61. package/file-input/FileInput.test.js +457 -0
  62. package/file-input/FileItem.js +7 -5
  63. package/flex/Flex.d.ts +4 -0
  64. package/flex/Flex.js +57 -0
  65. package/flex/Flex.stories.tsx +103 -0
  66. package/flex/types.d.ts +21 -0
  67. package/{row → flex}/types.js +0 -0
  68. package/footer/Footer.js +15 -88
  69. package/footer/Footer.test.js +109 -0
  70. package/footer/Icons.js +1 -1
  71. package/footer/types.d.ts +1 -1
  72. package/header/Header.js +95 -114
  73. package/header/Header.stories.tsx +46 -36
  74. package/header/Header.test.js +79 -0
  75. package/header/Icons.js +2 -2
  76. package/header/types.d.ts +2 -2
  77. package/heading/Heading.test.js +186 -0
  78. package/inset/Inset.js +1 -34
  79. package/inset/Inset.stories.tsx +36 -36
  80. package/inset/types.d.ts +25 -1
  81. package/layout/ApplicationLayout.d.ts +16 -6
  82. package/layout/ApplicationLayout.js +71 -131
  83. package/layout/ApplicationLayout.stories.tsx +83 -93
  84. package/layout/Icons.d.ts +5 -0
  85. package/layout/Icons.js +13 -2
  86. package/layout/SidenavContext.d.ts +5 -0
  87. package/layout/SidenavContext.js +19 -0
  88. package/layout/types.d.ts +18 -33
  89. package/link/Link.d.ts +3 -2
  90. package/link/Link.js +57 -74
  91. package/link/Link.stories.tsx +95 -53
  92. package/link/Link.test.js +83 -0
  93. package/link/types.d.ts +7 -23
  94. package/main.d.ts +10 -15
  95. package/main.js +48 -82
  96. package/number-input/NumberInput.js +11 -18
  97. package/number-input/NumberInput.stories.tsx +5 -5
  98. package/number-input/NumberInput.test.js +506 -0
  99. package/number-input/types.d.ts +17 -10
  100. package/package.json +12 -10
  101. package/paginator/Paginator.js +17 -38
  102. package/paginator/Paginator.test.js +308 -0
  103. package/paragraph/Paragraph.d.ts +6 -0
  104. package/paragraph/Paragraph.js +38 -0
  105. package/paragraph/Paragraph.stories.tsx +44 -0
  106. package/password-input/PasswordInput.js +7 -4
  107. package/password-input/PasswordInput.test.js +180 -0
  108. package/password-input/types.d.ts +14 -11
  109. package/progress-bar/ProgressBar.d.ts +2 -2
  110. package/progress-bar/ProgressBar.js +57 -51
  111. package/progress-bar/ProgressBar.stories.jsx +13 -11
  112. package/progress-bar/ProgressBar.test.js +110 -0
  113. package/progress-bar/types.d.ts +3 -4
  114. package/quick-nav/QuickNav.d.ts +4 -0
  115. package/quick-nav/QuickNav.js +118 -0
  116. package/quick-nav/QuickNav.stories.tsx +264 -0
  117. package/quick-nav/types.d.ts +21 -0
  118. package/{stack → quick-nav}/types.js +0 -0
  119. package/radio-group/Radio.d.ts +1 -1
  120. package/radio-group/Radio.js +25 -24
  121. package/radio-group/RadioGroup.js +58 -50
  122. package/radio-group/RadioGroup.stories.tsx +60 -39
  123. package/radio-group/RadioGroup.test.js +530 -83
  124. package/radio-group/types.d.ts +80 -2
  125. package/resultsetTable/ResultsetTable.test.js +348 -0
  126. package/select/Icons.d.ts +10 -0
  127. package/select/Icons.js +93 -0
  128. package/select/Listbox.d.ts +4 -0
  129. package/select/Listbox.js +199 -0
  130. package/select/Option.d.ts +4 -0
  131. package/select/Option.js +110 -0
  132. package/select/Select.js +145 -365
  133. package/select/Select.stories.tsx +231 -176
  134. package/select/Select.test.js +2175 -0
  135. package/select/types.d.ts +52 -12
  136. package/sidenav/Sidenav.d.ts +6 -5
  137. package/sidenav/Sidenav.js +184 -52
  138. package/sidenav/Sidenav.stories.tsx +154 -156
  139. package/sidenav/Sidenav.test.js +44 -0
  140. package/sidenav/types.d.ts +50 -27
  141. package/slider/Slider.d.ts +1 -1
  142. package/slider/Slider.js +5 -4
  143. package/slider/Slider.stories.tsx +8 -8
  144. package/slider/Slider.test.js +187 -0
  145. package/slider/types.d.ts +4 -0
  146. package/spinner/Spinner.js +1 -1
  147. package/spinner/Spinner.test.js +64 -0
  148. package/switch/Switch.d.ts +2 -2
  149. package/switch/Switch.js +127 -55
  150. package/switch/Switch.stories.tsx +20 -42
  151. package/switch/Switch.test.js +212 -0
  152. package/switch/types.d.ts +9 -6
  153. package/table/Table.test.js +26 -0
  154. package/tabs/Tabs.d.ts +1 -1
  155. package/tabs/Tabs.js +9 -11
  156. package/tabs/Tabs.stories.tsx +0 -8
  157. package/tabs/Tabs.test.js +140 -0
  158. package/tabs/types.d.ts +5 -1
  159. package/tabs-nav/NavTabs.d.ts +8 -0
  160. package/tabs-nav/NavTabs.js +125 -0
  161. package/tabs-nav/NavTabs.stories.tsx +170 -0
  162. package/tabs-nav/NavTabs.test.js +82 -0
  163. package/tabs-nav/Tab.d.ts +4 -0
  164. package/tabs-nav/Tab.js +130 -0
  165. package/tabs-nav/types.d.ts +53 -0
  166. package/tabs-nav/types.js +5 -0
  167. package/tag/Tag.js +14 -19
  168. package/tag/Tag.stories.tsx +12 -8
  169. package/tag/Tag.test.js +60 -0
  170. package/tag/types.d.ts +1 -1
  171. package/text-input/Suggestion.d.ts +4 -0
  172. package/text-input/Suggestion.js +55 -0
  173. package/text-input/TextInput.js +68 -101
  174. package/text-input/TextInput.stories.tsx +31 -14
  175. package/text-input/TextInput.test.js +1712 -0
  176. package/text-input/types.d.ts +31 -12
  177. package/textarea/Textarea.js +20 -27
  178. package/textarea/Textarea.stories.jsx +33 -12
  179. package/textarea/Textarea.test.js +437 -0
  180. package/textarea/types.d.ts +18 -11
  181. package/toggle-group/ToggleGroup.d.ts +1 -1
  182. package/toggle-group/ToggleGroup.js +5 -4
  183. package/toggle-group/ToggleGroup.stories.tsx +4 -4
  184. package/toggle-group/ToggleGroup.test.js +156 -0
  185. package/toggle-group/types.d.ts +9 -1
  186. package/typography/Typography.d.ts +4 -0
  187. package/typography/Typography.js +131 -0
  188. package/typography/Typography.stories.tsx +198 -0
  189. package/typography/types.d.ts +18 -0
  190. package/typography/types.js +5 -0
  191. package/useTheme.js +2 -2
  192. package/useTranslatedLabels.d.ts +2 -0
  193. package/useTranslatedLabels.js +20 -0
  194. package/wizard/Wizard.d.ts +1 -1
  195. package/wizard/Wizard.js +58 -54
  196. package/wizard/Wizard.stories.tsx +33 -24
  197. package/wizard/Wizard.test.js +141 -0
  198. package/wizard/types.d.ts +10 -5
  199. package/ThemeContext.d.ts +0 -15
  200. package/ThemeContext.js +0 -243
  201. package/V3Select/V3Select.js +0 -455
  202. package/V3Select/index.d.ts +0 -27
  203. package/V3Textarea/V3Textarea.js +0 -260
  204. package/V3Textarea/index.d.ts +0 -27
  205. package/date/Date.js +0 -373
  206. package/date/index.d.ts +0 -27
  207. package/input-text/Icons.js +0 -22
  208. package/input-text/InputText.js +0 -611
  209. package/input-text/index.d.ts +0 -36
  210. package/list/List.d.ts +0 -4
  211. package/list/List.js +0 -47
  212. package/list/List.stories.tsx +0 -95
  213. package/list/types.d.ts +0 -7
  214. package/radio/Radio.d.ts +0 -4
  215. package/radio/Radio.js +0 -174
  216. package/radio/Radio.stories.tsx +0 -192
  217. package/radio/types.d.ts +0 -54
  218. package/row/Row.d.ts +0 -3
  219. package/row/Row.js +0 -127
  220. package/row/Row.stories.tsx +0 -237
  221. package/row/types.d.ts +0 -10
  222. package/stack/Stack.d.ts +0 -3
  223. package/stack/Stack.js +0 -97
  224. package/stack/Stack.stories.tsx +0 -164
  225. package/stack/types.d.ts +0 -9
  226. package/text/Text.d.ts +0 -7
  227. package/text/Text.js +0 -30
  228. package/text/Text.stories.tsx +0 -19
  229. package/upload/Upload.js +0 -201
  230. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  231. package/upload/buttons-upload/Icons.js +0 -40
  232. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  233. package/upload/dragAndDropArea/Icons.js +0 -39
  234. package/upload/file-upload/FileToUpload.js +0 -115
  235. package/upload/file-upload/Icons.js +0 -66
  236. package/upload/files-upload/FilesToUpload.js +0 -109
  237. package/upload/index.d.ts +0 -15
  238. package/upload/transaction/Icons.js +0 -160
  239. package/upload/transaction/Transaction.js +0 -104
  240. package/upload/transactions/Transactions.js +0 -94
@@ -1,19 +1,18 @@
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",
13
12
  component: DxcSelect,
14
13
  };
15
- const one_option = [{ label: "Option 01", value: "1" }];
16
14
 
15
+ const one_option = [{ label: "Option 01", value: "1" }];
17
16
  const single_options = [
18
17
  { label: "Option 01", value: "1" },
19
18
  { label: "Option 02", value: "2" },
@@ -224,10 +223,12 @@ const optionsWithEllipsisMedium = [
224
223
  { label: "Optiond1234567890123456789012345678901234", value: "1" },
225
224
  { label: "Optiond12345678901234567890123456789012345", value: "2" },
226
225
  { label: "Option 031111111111111111111111111111222", value: "3" },
227
- { label: "Option 03111111111111111111111111111122", value: "4" },
226
+ { label: "Option 03111111111111111111111111111222", value: "4" },
228
227
  ];
228
+
229
229
  const Select = () => (
230
230
  <>
231
+ <Title title="States" theme="light" level={2} />
231
232
  <ExampleContainer pseudoState="pseudo-hover">
232
233
  <Title title="Hovered" theme="light" level={4} />
233
234
  <DxcSelect label="Hovered" options={single_options} />
@@ -242,115 +243,211 @@ const Select = () => (
242
243
  </ExampleContainer>
243
244
  <ExampleContainer>
244
245
  <Title title="Disabled with value" theme="light" level={4} />
245
- <DxcSelect label="Disabled with value" disabled options={single_options} value="1" />
246
+ <DxcSelect label="Disabled with value" disabled options={single_options} defaultValue="1" />
246
247
  </ExampleContainer>
247
248
  <ExampleContainer>
248
- <Title title="With label" theme="light" level={4} />
249
- <DxcSelect label="Label" options={single_options} />
250
- <Title title="Label and placeholder" theme="light" level={4} />
251
- <DxcSelect label="Label" options={single_options} placeholder="Placeholder" />
252
- <Title title="Label, placeholder and helper text" theme="light" level={4} />
253
- <DxcSelect label="Label" options={single_options} helperText="Helper text" placeholder="Placeholder" />
254
249
  <Title title="Error" theme="light" level={4} />
255
250
  <DxcSelect
256
251
  label="Label"
257
252
  options={single_options}
258
- error="Error message"
253
+ error="Error message."
259
254
  helperText="Helper text"
260
255
  placeholder="Placeholder"
261
256
  />
257
+ </ExampleContainer>
258
+ <ExampleContainer pseudoState="pseudo-hover">
259
+ <Title title="Hovered error" theme="light" level={4} />
260
+ <DxcSelect
261
+ label="Label"
262
+ options={single_options}
263
+ error="Error message."
264
+ helperText="Helper text"
265
+ placeholder="Placeholder"
266
+ />
267
+ </ExampleContainer>
268
+ <Title title="Anatomy" theme="light" level={2} />
269
+ <ExampleContainer>
270
+ <Title title="Label, placeholder and helper text" theme="light" level={4} />
271
+ <DxcSelect label="Label" options={single_options} helperText="Helper text" placeholder="Placeholder" />
272
+ </ExampleContainer>
273
+ <Title title="Variants" theme="light" level={2} />
274
+ <ExampleContainer>
262
275
  <Title title="Simple selection" theme="light" level={4} />
263
- <DxcSelect label="Simple selection" searchable options={single_options} value="2" />
276
+ <DxcSelect label="Simple selection" searchable options={single_options} defaultValue="2" />
277
+ </ExampleContainer>
278
+ <ExampleContainer>
264
279
  <Title title="Multiple selection" theme="light" level={4} />
265
- <DxcSelect label="Multiple select" searchable options={single_options} multiple value={["1", "2"]} />
280
+ <DxcSelect label="Multiple select" searchable options={single_options} multiple defaultValue={["1", "2"]} />
266
281
  </ExampleContainer>
267
-
268
282
  <ExampleContainer pseudoState="pseudo-hover">
269
283
  <Title title="Multiple clear hovered" theme="light" level={4} />
270
- <DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
284
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
271
285
  </ExampleContainer>
272
-
273
286
  <ExampleContainer pseudoState="pseudo-active">
274
287
  <Title title="Multiple clear actived" theme="light" level={4} />
275
- <DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
288
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
289
+ </ExampleContainer>
290
+ <Title title="Sizes" theme="light" level={2} />
291
+ <ExampleContainer>
292
+ <Title title="Small size" theme="light" level={4} />
293
+ <DxcSelect label="Small" options={single_options} size="small" />
294
+ </ExampleContainer>
295
+ <ExampleContainer>
296
+ <Title title="Medium size" theme="light" level={4} />
297
+ <DxcSelect label="Medium" options={single_options} size="medium" />
298
+ </ExampleContainer>
299
+ <ExampleContainer>
300
+ <Title title="Large size" theme="light" level={4} />
301
+ <DxcSelect label="Large" options={single_options} size="large" />
302
+ </ExampleContainer>
303
+ <ExampleContainer>
304
+ <Title title="Fillparent size" theme="light" level={4} />
305
+ <DxcSelect label="Fillparent" options={single_options} size="fillParent" />
306
+ </ExampleContainer>
307
+ <Title title="Margins" theme="light" level={2} />
308
+ <ExampleContainer>
309
+ <Title title="xxsmall margin" theme="light" level={4} />
310
+ <DxcSelect label="xxSmall" options={single_options} margin="xxsmall" />
311
+ </ExampleContainer>
312
+ <ExampleContainer>
313
+ <Title title="xsmall margin" theme="light" level={4} />
314
+ <DxcSelect label="xSmall" options={single_options} margin="xsmall" />
315
+ </ExampleContainer>
316
+ <ExampleContainer>
317
+ <Title title="small margin" theme="light" level={4} />
318
+ <DxcSelect label="Small" options={single_options} margin="small" />
319
+ </ExampleContainer>
320
+ <ExampleContainer>
321
+ <Title title="medium margin" theme="light" level={4} />
322
+ <DxcSelect label="Medium" options={single_options} margin="medium" />
323
+ </ExampleContainer>
324
+ <ExampleContainer>
325
+ <Title title="large margin" theme="light" level={4} />
326
+ <DxcSelect label="Large" options={single_options} margin="large" />
327
+ </ExampleContainer>
328
+ <ExampleContainer>
329
+ <Title title="xlarge margin" theme="light" level={4} />
330
+ <DxcSelect label="xLarge" options={single_options} margin="xlarge" />
331
+ </ExampleContainer>
332
+ <ExampleContainer>
333
+ <Title title="xxlarge margin" theme="light" level={4} />
334
+ <DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
276
335
  </ExampleContainer>
277
- <>
278
- <Title title="Sizes" theme="light" level={2} />
279
- <ExampleContainer>
280
- <Title title="Small size" theme="light" level={4} />
281
- <DxcSelect label="Small" options={single_options} size="small" />
282
- </ExampleContainer>
283
- <ExampleContainer>
284
- <Title title="Medium size" theme="light" level={4} />
285
- <DxcSelect label="Medium" options={single_options} size="medium" />
286
- </ExampleContainer>
287
- <ExampleContainer>
288
- <Title title="Large size" theme="light" level={4} />
289
- <DxcSelect label="Large" options={single_options} size="large" />
290
- </ExampleContainer>
291
- <ExampleContainer>
292
- <Title title="Fillparent size" theme="light" level={4} />
293
- <DxcSelect label="Fillparent" options={single_options} size="fillParent" />
294
- </ExampleContainer>
295
- </>
296
- <>
297
- <Title title="Margins" theme="light" level={2} />
298
- <ExampleContainer>
299
- <Title title="xxsmall margin" theme="light" level={4} />
300
- <DxcSelect label="xxSmall" options={single_options} margin="xxsmall" />
301
- </ExampleContainer>
302
- <ExampleContainer>
303
- <Title title="xsmall margin" theme="light" level={4} />
304
- <DxcSelect label="xSmall" options={single_options} margin="xsmall" />
305
- </ExampleContainer>
306
- <ExampleContainer>
307
- <Title title="small margin" theme="light" level={4} />
308
- <DxcSelect label="Small" options={single_options} margin="small" />
309
- </ExampleContainer>
310
- <ExampleContainer>
311
- <Title title="medium margin" theme="light" level={4} />
312
- <DxcSelect label="Medium" options={single_options} margin="medium" />
313
- </ExampleContainer>
314
- <ExampleContainer>
315
- <Title title="large margin" theme="light" level={4} />
316
- <DxcSelect label="Large" options={single_options} margin="large" />
317
- </ExampleContainer>
318
- <ExampleContainer>
319
- <Title title="xlarge margin" theme="light" level={4} />
320
- <DxcSelect label="xLarge" options={single_options} margin="xlarge" />
321
- </ExampleContainer>
322
- <ExampleContainer>
323
- <Title title="xxlarge margin" theme="light" level={4} />
324
- <DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
325
- </ExampleContainer>
326
- </>
327
336
  <ExampleContainer expanded>
328
337
  <Title title="Ellipsis" theme="light" level={2} />
329
338
  <Title title="Multiple selection with ellipsis" theme="light" level={4} />
330
- <DxcSelect label="Label" options={single_options} multiple value={["1", "2", "3", "4"]} />
339
+ <DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
331
340
  <Title title="Value with ellipsis" theme="light" level={4} />
332
- <DxcSelect label="Label" options={optionsWithEllipsisMedium} value="1" size="medium" />
333
- <Title title="Option with ellipsis" theme="light" level={4} />
341
+ <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
342
+ <Title title="Options with ellipsis" theme="light" level={4} />
334
343
  <DxcSelect
335
344
  label="Label"
336
345
  placeholder="Choose an option"
337
- value="1"
346
+ defaultValue="1"
338
347
  options={optionsWithEllipsisMedium}
339
348
  size="medium"
340
349
  />
341
350
  </ExampleContainer>
342
351
  </>
343
352
  );
344
- export const Chromatic = Select.bind({});
345
- Chromatic.play = async ({ canvasElement }) => {
346
- const canvas = within(canvasElement);
347
- await userEvent.click(canvas.getAllByRole("combobox")[25]);
348
- };
349
- const DefaultSelect = () => (
350
- <ExampleContainer expanded>
351
- <Title title="Default select" theme="light" level={4} />
352
- <DxcSelect label="Select label" options={single_options} optional placeholder="Choose an option" />
353
- </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
+ </>
354
451
  );
355
452
  const SearchableSelect = () => (
356
453
  <ExampleContainer expanded>
@@ -358,13 +455,18 @@ const SearchableSelect = () => (
358
455
  <DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
359
456
  </ExampleContainer>
360
457
  );
361
- const SearchableWithValue = () => (
458
+ const SearchValue = () => (
362
459
  <ExampleContainer expanded>
363
460
  <Title title="Searchable select with value" theme="light" level={4} />
364
- <DxcSelect label="Select Label" searchable value="1" options={single_options} placeholder="Choose an option" />
461
+ <DxcSelect
462
+ label="Select Label"
463
+ searchable
464
+ defaultValue="1"
465
+ options={single_options}
466
+ placeholder="Choose an option"
467
+ />
365
468
  </ExampleContainer>
366
469
  );
367
-
368
470
  const MultipleSelect = () => (
369
471
  <>
370
472
  <ExampleContainer expanded>
@@ -372,7 +474,7 @@ const MultipleSelect = () => (
372
474
  <DxcSelect
373
475
  label="Select label"
374
476
  options={single_options}
375
- value={["1", "4"]}
477
+ defaultValue={["1", "4"]}
376
478
  multiple
377
479
  placeholder="Choose an option"
378
480
  />
@@ -382,31 +484,37 @@ const MultipleSelect = () => (
382
484
  const DefaultGroupedOptionsSelect = () => (
383
485
  <ExampleContainer expanded>
384
486
  <Title title="Grouped options simple select" theme="light" level={4} />
385
- <DxcSelect label="Label" options={group_options} value="9" placeholder="Choose an option" />
487
+ <DxcSelect label="Label" options={group_options} defaultValue="9" placeholder="Choose an option" />
386
488
  </ExampleContainer>
387
489
  );
388
490
  const MultipleGroupedOptionsSelect = () => (
389
491
  <ExampleContainer expanded>
390
492
  <Title title="Grouped options multiple select" theme="light" level={4} />
391
- <DxcSelect label="Label" options={group_options} value={["0", "2"]} multiple placeholder="Choose an option" />
493
+ <DxcSelect
494
+ label="Label"
495
+ options={group_options}
496
+ defaultValue={["0", "2"]}
497
+ multiple
498
+ placeholder="Choose an option"
499
+ />
392
500
  </ExampleContainer>
393
501
  );
394
502
  const RescaledIcons = () => (
395
503
  <ExampleContainer expanded>
396
504
  <Title title="Rescaled icons displayed" theme="light" level={4} />
397
- <DxcSelect label="Label" options={url_options} value="facebook" placeholder="Choose an option" />
505
+ <DxcSelect label="Label" options={url_options} defaultValue="facebook" placeholder="Choose an option" />
398
506
  </ExampleContainer>
399
507
  );
400
508
  const SelectWithIcons = () => (
401
509
  <ExampleContainer expanded>
402
510
  <Title title="Normal icons displayed" theme="light" level={4} />
403
- <DxcSelect label="Label" options={icon_options} value="3" placeholder="Choose an option" />
511
+ <DxcSelect label="Label" options={icon_options} defaultValue="3" placeholder="Choose an option" />
404
512
  </ExampleContainer>
405
513
  );
406
514
  const SelectMultipleWithIcons = () => (
407
515
  <ExampleContainer expanded>
408
516
  <Title title="Multiple select with icons" theme="light" level={4} />
409
- <DxcSelect label="Label" options={icon_options} multiple value={["1", "3"]} placeholder="Choose an option" />
517
+ <DxcSelect label="Label" options={icon_options} multiple defaultValue={["1", "3"]} placeholder="Choose an option" />
410
518
  </ExampleContainer>
411
519
  );
412
520
  const MultipleGroupedOptionsSelectWithIcons = () => (
@@ -416,41 +524,12 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
416
524
  label="Label"
417
525
  options={icon_options_grouped}
418
526
  multiple
419
- value={["3", "2"]}
527
+ defaultValue={["3", "2"]}
420
528
  placeholder="Choose an option"
421
529
  />
422
530
  </ExampleContainer>
423
531
  );
424
- const OnlyOneOptionHovered = () => (
425
- <ExampleContainer pseudoState="pseudo-hover" expanded>
426
- <Title title="Hovered Option" theme="light" level={4} />
427
- <DxcSelect label="Hovered" options={one_option} placeholder="Choose an option" />
428
- </ExampleContainer>
429
- );
430
- const OnlyOneOptionFocused = () => (
431
- <ExampleContainer pseudoState="pseudo-focus" expanded>
432
- <Title title="Focused Option" theme="light" level={4} />
433
- <DxcSelect label="Focused" options={one_option} placeholder="Choose an option" />
434
- </ExampleContainer>
435
- );
436
- const OnlyOneOptionActived = () => (
437
- <ExampleContainer pseudoState="pseudo-active" expanded>
438
- <Title title="Actived Option" theme="light" level={4} />
439
- <DxcSelect label="Actived" options={one_option} placeholder="Choose an option" />
440
- </ExampleContainer>
441
- );
442
- const SelectedOptionHovered = () => (
443
- <ExampleContainer pseudoState="pseudo-hover" expanded>
444
- <Title title="Hovered Selected Option" theme="light" level={4} />
445
- <DxcSelect label="Hovered" value="1" options={one_option} placeholder="Choose an option" />
446
- </ExampleContainer>
447
- );
448
- const SelectedOptionActived = () => (
449
- <ExampleContainer pseudoState="pseudo-active" expanded>
450
- <Title title="Actived Selected Option" theme="light" level={4} />
451
- <DxcSelect label="Actived" value="1" options={one_option} placeholder="Choose an option" />
452
- </ExampleContainer>
453
- );
532
+
454
533
  const MultipleSearchable = () => (
455
534
  <ExampleContainer expanded>
456
535
  <Title title="Searchable multiple select with value" theme="light" level={4} />
@@ -458,18 +537,26 @@ const MultipleSearchable = () => (
458
537
  label="Select Label"
459
538
  searchable
460
539
  multiple
461
- value={["1", "4"]}
540
+ defaultValue={["1", "4"]}
462
541
  options={single_options}
463
542
  placeholder="Choose an option"
464
543
  />
465
544
  </ExampleContainer>
466
545
  );
467
- export const OptionsDisplayed = DefaultSelect.bind({});
468
- 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 }) => {
469
555
  const canvas = within(canvasElement);
470
556
  const select = canvas.getByRole("combobox");
471
557
  await userEvent.click(select);
472
558
  };
559
+
473
560
  export const Searchable = SearchableSelect.bind({});
474
561
  Searchable.play = async ({ canvasElement }) => {
475
562
  const canvas = within(canvasElement);
@@ -478,14 +565,15 @@ Searchable.play = async ({ canvasElement }) => {
478
565
  userEvent.type(canvas.getByRole("combobox"), "r");
479
566
  });
480
567
  };
481
- export const SelectSearchableWithValue = SearchableWithValue.bind({});
482
- SelectSearchableWithValue.play = async ({ canvasElement }) => {
568
+
569
+ export const SearchableWithValue = SearchValue.bind({});
570
+ SearchableWithValue.play = async ({ canvasElement }) => {
483
571
  const canvas = within(canvasElement);
484
572
  await userEvent.click(canvas.getByRole("combobox"));
485
573
  };
486
574
 
487
- export const SelectMultipleSearchableWithValue = MultipleSearchable.bind({});
488
- SelectMultipleSearchableWithValue.play = async ({ canvasElement }) => {
575
+ export const MultipleSearchableWithValue = MultipleSearchable.bind({});
576
+ MultipleSearchableWithValue.play = async ({ canvasElement }) => {
489
577
  const canvas = within(canvasElement);
490
578
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
491
579
  };
@@ -497,75 +585,42 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
497
585
  await userEvent.click(select);
498
586
  };
499
587
 
500
- export const SelectMultipleOptionsDisplayed = MultipleSelect.bind({});
501
- SelectMultipleOptionsDisplayed.play = async ({ canvasElement }) => {
588
+ export const MultipleOptionsDisplayed = MultipleSelect.bind({});
589
+ MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
502
590
  const canvas = within(canvasElement);
503
591
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
504
592
  };
505
593
 
506
- export const SelectMultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
507
- SelectMultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
508
- const canvas = within(canvasElement);
509
- const select = canvas.getByRole("combobox");
510
- await userEvent.click(select);
511
- };
512
- export const SelectWithIconsDisplayed = SelectWithIcons.bind({});
513
- SelectWithIconsDisplayed.play = async ({ canvasElement }) => {
594
+ export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
595
+ MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
514
596
  const canvas = within(canvasElement);
515
597
  const select = canvas.getByRole("combobox");
516
598
  await userEvent.click(select);
517
599
  };
518
600
 
519
- export const SelectWithRescaledIconsDisplayed = RescaledIcons.bind({});
520
- SelectWithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
521
- const canvas = within(canvasElement);
522
- const select = canvas.getByRole("combobox");
523
- await userEvent.click(select);
524
- };
525
- export const SelectMultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
526
- SelectMultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
601
+ export const WithIconsDisplayed = SelectWithIcons.bind({});
602
+ WithIconsDisplayed.play = async ({ canvasElement }) => {
527
603
  const canvas = within(canvasElement);
528
604
  const select = canvas.getByRole("combobox");
529
605
  await userEvent.click(select);
530
606
  };
531
607
 
532
- export const SelectMultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
533
- SelectMultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
608
+ export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
609
+ WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
534
610
  const canvas = within(canvasElement);
535
611
  const select = canvas.getByRole("combobox");
536
612
  await userEvent.click(select);
537
613
  };
538
614
 
539
- export const OptionHovered = OnlyOneOptionHovered.bind({});
540
- OptionHovered.play = async ({ canvasElement }) => {
615
+ export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
616
+ MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
541
617
  const canvas = within(canvasElement);
542
618
  const select = canvas.getByRole("combobox");
543
619
  await userEvent.click(select);
544
620
  };
545
621
 
546
- export const OptionFocused = OnlyOneOptionFocused.bind({});
547
- OptionFocused.play = async ({ canvasElement }) => {
548
- const canvas = within(canvasElement);
549
- const select = canvas.getByRole("combobox");
550
- await userEvent.click(select);
551
- await waitFor(async () => {
552
- fireEvent.keyDown(select, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
553
- });
554
- };
555
- export const OptionActived = OnlyOneOptionActived.bind({});
556
- OptionActived.play = async ({ canvasElement }) => {
557
- const canvas = within(canvasElement);
558
- const select = canvas.getByRole("combobox");
559
- await userEvent.click(select);
560
- };
561
- export const OptionSelectedHovered = SelectedOptionHovered.bind({});
562
- OptionSelectedHovered.play = async ({ canvasElement }) => {
563
- const canvas = within(canvasElement);
564
- const select = canvas.getByRole("combobox");
565
- await userEvent.click(select);
566
- };
567
- export const OptionSelectedActived = SelectedOptionActived.bind({});
568
- OptionSelectedActived.play = async ({ canvasElement }) => {
622
+ export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
623
+ MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
569
624
  const canvas = within(canvasElement);
570
625
  const select = canvas.getByRole("combobox");
571
626
  await userEvent.click(select);