@dxc-technology/halstack-react 0.0.0-099fc65 → 0.0.0-0a9608a

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 (287) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +1 -4
  3. package/HalstackContext.d.ts +12 -0
  4. package/HalstackContext.js +294 -0
  5. package/accordion/Accordion.d.ts +1 -1
  6. package/accordion/Accordion.js +119 -138
  7. package/accordion/Accordion.stories.tsx +346 -0
  8. package/accordion/Accordion.test.js +71 -0
  9. package/accordion/types.d.ts +12 -11
  10. package/accordion-group/AccordionGroup.d.ts +1 -1
  11. package/accordion-group/AccordionGroup.js +16 -37
  12. package/accordion-group/AccordionGroup.stories.tsx +28 -2
  13. package/accordion-group/AccordionGroup.test.js +126 -0
  14. package/accordion-group/types.d.ts +17 -10
  15. package/alert/Alert.js +7 -4
  16. package/alert/Alert.test.js +92 -0
  17. package/badge/Badge.d.ts +4 -0
  18. package/badge/Badge.js +6 -4
  19. package/badge/types.d.ts +5 -0
  20. package/{radio → badge}/types.js +0 -0
  21. package/bleed/Bleed.d.ts +3 -0
  22. package/bleed/Bleed.js +51 -0
  23. package/bleed/Bleed.stories.tsx +341 -0
  24. package/bleed/types.d.ts +37 -0
  25. package/bleed/types.js +5 -0
  26. package/box/Box.js +25 -35
  27. package/box/Box.test.js +18 -0
  28. package/box/types.d.ts +1 -0
  29. package/bulleted-list/BulletedList.d.ts +7 -0
  30. package/bulleted-list/BulletedList.js +123 -0
  31. package/bulleted-list/BulletedList.stories.tsx +200 -0
  32. package/bulleted-list/types.d.ts +11 -0
  33. package/bulleted-list/types.js +5 -0
  34. package/button/Button.d.ts +1 -1
  35. package/button/Button.js +56 -81
  36. package/button/Button.stories.tsx +72 -8
  37. package/button/Button.test.js +35 -0
  38. package/button/types.d.ts +8 -12
  39. package/card/Card.js +25 -28
  40. package/card/Card.stories.tsx +1 -1
  41. package/card/Card.test.js +50 -0
  42. package/card/types.d.ts +1 -0
  43. package/checkbox/Checkbox.d.ts +2 -2
  44. package/checkbox/Checkbox.js +108 -111
  45. package/checkbox/Checkbox.stories.tsx +146 -130
  46. package/checkbox/Checkbox.test.js +155 -0
  47. package/checkbox/types.d.ts +14 -6
  48. package/chip/Chip.d.ts +1 -1
  49. package/chip/Chip.js +20 -70
  50. package/chip/Chip.stories.tsx +44 -14
  51. package/chip/Chip.test.js +56 -0
  52. package/chip/types.d.ts +7 -15
  53. package/common/variables.js +398 -464
  54. package/date-input/Calendar.d.ts +4 -0
  55. package/date-input/Calendar.js +246 -0
  56. package/date-input/DateInput.js +174 -266
  57. package/date-input/DateInput.stories.tsx +137 -38
  58. package/date-input/DateInput.test.js +835 -0
  59. package/date-input/DatePicker.d.ts +4 -0
  60. package/date-input/DatePicker.js +132 -0
  61. package/date-input/Icons.d.ts +6 -0
  62. package/date-input/Icons.js +75 -0
  63. package/date-input/YearPicker.d.ts +4 -0
  64. package/date-input/YearPicker.js +116 -0
  65. package/date-input/types.d.ts +67 -9
  66. package/dialog/Dialog.js +50 -53
  67. package/dialog/Dialog.stories.tsx +57 -2
  68. package/dialog/Dialog.test.js +70 -0
  69. package/dialog/types.d.ts +3 -2
  70. package/dropdown/Dropdown.d.ts +1 -1
  71. package/dropdown/Dropdown.js +248 -277
  72. package/dropdown/Dropdown.stories.tsx +393 -0
  73. package/dropdown/Dropdown.test.js +585 -0
  74. package/dropdown/DropdownMenu.d.ts +4 -0
  75. package/dropdown/DropdownMenu.js +70 -0
  76. package/dropdown/DropdownMenuItem.d.ts +4 -0
  77. package/dropdown/DropdownMenuItem.js +81 -0
  78. package/dropdown/types.d.ts +29 -18
  79. package/file-input/FileInput.d.ts +2 -2
  80. package/file-input/FileInput.js +177 -137
  81. package/file-input/FileInput.stories.tsx +535 -0
  82. package/file-input/FileInput.test.js +498 -0
  83. package/file-input/FileItem.d.ts +4 -14
  84. package/file-input/FileItem.js +45 -68
  85. package/file-input/types.d.ts +49 -7
  86. package/flex/Flex.d.ts +4 -0
  87. package/flex/Flex.js +69 -0
  88. package/flex/Flex.stories.tsx +103 -0
  89. package/flex/types.d.ts +32 -0
  90. package/flex/types.js +5 -0
  91. package/footer/Footer.d.ts +1 -1
  92. package/footer/Footer.js +32 -113
  93. package/footer/{Footer.stories.jsx → Footer.stories.tsx} +5 -19
  94. package/footer/Footer.test.js +109 -0
  95. package/footer/Icons.d.ts +2 -0
  96. package/footer/Icons.js +4 -4
  97. package/footer/types.d.ts +6 -9
  98. package/header/Header.js +109 -130
  99. package/header/Header.stories.tsx +78 -35
  100. package/header/Header.test.js +79 -0
  101. package/header/Icons.d.ts +2 -0
  102. package/header/Icons.js +2 -2
  103. package/header/types.d.ts +3 -2
  104. package/heading/Heading.js +1 -1
  105. package/heading/Heading.stories.tsx +3 -2
  106. package/heading/Heading.test.js +186 -0
  107. package/inset/Inset.d.ts +3 -0
  108. package/inset/Inset.js +51 -0
  109. package/inset/Inset.stories.tsx +229 -0
  110. package/inset/types.d.ts +37 -0
  111. package/inset/types.js +5 -0
  112. package/layout/ApplicationLayout.d.ts +20 -0
  113. package/layout/ApplicationLayout.js +71 -135
  114. package/layout/ApplicationLayout.stories.tsx +162 -0
  115. package/layout/Icons.d.ts +5 -0
  116. package/layout/Icons.js +13 -2
  117. package/layout/SidenavContext.d.ts +5 -0
  118. package/layout/SidenavContext.js +19 -0
  119. package/layout/types.d.ts +42 -0
  120. package/layout/types.js +5 -0
  121. package/link/Link.d.ts +3 -2
  122. package/link/Link.js +62 -87
  123. package/link/Link.stories.tsx +99 -52
  124. package/link/Link.test.js +83 -0
  125. package/link/types.d.ts +9 -29
  126. package/main.d.ts +12 -12
  127. package/main.js +64 -58
  128. package/number-input/NumberInput.js +14 -24
  129. package/number-input/NumberInput.stories.tsx +5 -5
  130. package/number-input/NumberInput.test.js +542 -0
  131. package/number-input/types.d.ts +17 -10
  132. package/package.json +21 -22
  133. package/paginator/Icons.d.ts +5 -0
  134. package/paginator/Icons.js +16 -28
  135. package/paginator/Paginator.js +21 -54
  136. package/paginator/Paginator.test.js +315 -0
  137. package/paragraph/Paragraph.d.ts +6 -0
  138. package/paragraph/Paragraph.js +38 -0
  139. package/paragraph/Paragraph.stories.tsx +44 -0
  140. package/password-input/PasswordInput.js +19 -17
  141. package/password-input/PasswordInput.stories.tsx +3 -3
  142. package/password-input/PasswordInput.test.js +181 -0
  143. package/password-input/types.d.ts +14 -11
  144. package/progress-bar/ProgressBar.d.ts +2 -2
  145. package/progress-bar/ProgressBar.js +59 -53
  146. package/progress-bar/ProgressBar.stories.jsx +13 -11
  147. package/progress-bar/ProgressBar.test.js +110 -0
  148. package/progress-bar/types.d.ts +3 -4
  149. package/quick-nav/QuickNav.d.ts +4 -0
  150. package/quick-nav/QuickNav.js +117 -0
  151. package/quick-nav/QuickNav.stories.tsx +342 -0
  152. package/quick-nav/types.d.ts +21 -0
  153. package/quick-nav/types.js +5 -0
  154. package/radio-group/Radio.d.ts +4 -0
  155. package/radio-group/Radio.js +156 -0
  156. package/radio-group/RadioGroup.d.ts +4 -0
  157. package/radio-group/RadioGroup.js +283 -0
  158. package/radio-group/RadioGroup.stories.tsx +101 -0
  159. package/radio-group/RadioGroup.test.js +722 -0
  160. package/radio-group/types.d.ts +114 -0
  161. package/radio-group/types.js +5 -0
  162. package/resultsetTable/Icons.d.ts +7 -0
  163. package/resultsetTable/Icons.js +51 -0
  164. package/resultsetTable/ResultsetTable.js +50 -106
  165. package/resultsetTable/ResultsetTable.stories.tsx +300 -0
  166. package/resultsetTable/ResultsetTable.test.js +325 -0
  167. package/resultsetTable/types.d.ts +3 -3
  168. package/select/Icons.d.ts +10 -0
  169. package/select/Icons.js +93 -0
  170. package/select/Listbox.d.ts +4 -0
  171. package/select/Listbox.js +169 -0
  172. package/select/Option.d.ts +4 -0
  173. package/select/Option.js +97 -0
  174. package/select/Select.d.ts +4 -0
  175. package/select/Select.js +196 -397
  176. package/select/Select.stories.tsx +317 -220
  177. package/select/Select.test.js +2228 -0
  178. package/select/types.d.ts +210 -0
  179. package/select/types.js +5 -0
  180. package/sidenav/Sidenav.d.ts +6 -5
  181. package/sidenav/Sidenav.js +184 -54
  182. package/sidenav/Sidenav.stories.tsx +163 -139
  183. package/sidenav/Sidenav.test.js +44 -0
  184. package/sidenav/types.d.ts +50 -27
  185. package/slider/Slider.d.ts +2 -2
  186. package/slider/Slider.js +124 -98
  187. package/slider/Slider.stories.tsx +15 -9
  188. package/slider/Slider.test.js +250 -0
  189. package/slider/types.d.ts +10 -2
  190. package/spinner/Spinner.js +5 -5
  191. package/spinner/Spinner.stories.jsx +1 -0
  192. package/spinner/Spinner.test.js +64 -0
  193. package/switch/Switch.d.ts +2 -2
  194. package/switch/Switch.js +152 -69
  195. package/switch/Switch.stories.tsx +21 -43
  196. package/switch/Switch.test.js +225 -0
  197. package/switch/types.d.ts +12 -4
  198. package/table/Table.js +3 -3
  199. package/table/Table.stories.jsx +2 -1
  200. package/table/Table.test.js +26 -0
  201. package/tabs/Tab.d.ts +4 -0
  202. package/tabs/Tab.js +133 -0
  203. package/tabs/Tabs.d.ts +1 -1
  204. package/tabs/Tabs.js +364 -110
  205. package/tabs/Tabs.stories.tsx +84 -17
  206. package/tabs/Tabs.test.js +351 -0
  207. package/tabs/types.d.ts +39 -17
  208. package/tabs-nav/NavTabs.d.ts +8 -0
  209. package/tabs-nav/NavTabs.js +125 -0
  210. package/tabs-nav/NavTabs.stories.tsx +172 -0
  211. package/tabs-nav/NavTabs.test.js +82 -0
  212. package/tabs-nav/Tab.d.ts +4 -0
  213. package/tabs-nav/Tab.js +128 -0
  214. package/tabs-nav/types.d.ts +53 -0
  215. package/tabs-nav/types.js +5 -0
  216. package/tag/Tag.d.ts +1 -1
  217. package/tag/Tag.js +19 -29
  218. package/tag/Tag.stories.tsx +26 -29
  219. package/tag/Tag.test.js +60 -0
  220. package/tag/types.d.ts +23 -14
  221. package/text-input/Icons.d.ts +8 -0
  222. package/text-input/Icons.js +60 -0
  223. package/text-input/Suggestion.d.ts +4 -0
  224. package/text-input/Suggestion.js +84 -0
  225. package/text-input/Suggestions.d.ts +4 -0
  226. package/text-input/Suggestions.js +134 -0
  227. package/text-input/TextInput.js +229 -342
  228. package/text-input/TextInput.stories.tsx +241 -196
  229. package/text-input/TextInput.test.js +1724 -0
  230. package/text-input/types.d.ts +51 -13
  231. package/textarea/Textarea.d.ts +4 -0
  232. package/textarea/Textarea.js +34 -73
  233. package/textarea/Textarea.stories.jsx +37 -15
  234. package/textarea/Textarea.test.js +437 -0
  235. package/textarea/types.d.ts +137 -0
  236. package/textarea/types.js +5 -0
  237. package/toggle-group/ToggleGroup.d.ts +1 -1
  238. package/toggle-group/ToggleGroup.js +15 -17
  239. package/toggle-group/ToggleGroup.stories.tsx +27 -32
  240. package/toggle-group/ToggleGroup.test.js +156 -0
  241. package/toggle-group/types.d.ts +46 -25
  242. package/typography/Typography.d.ts +4 -0
  243. package/typography/Typography.js +131 -0
  244. package/typography/Typography.stories.tsx +198 -0
  245. package/typography/types.d.ts +18 -0
  246. package/typography/types.js +5 -0
  247. package/useTheme.d.ts +2 -0
  248. package/useTheme.js +2 -2
  249. package/useTranslatedLabels.d.ts +2 -0
  250. package/useTranslatedLabels.js +20 -0
  251. package/wizard/Wizard.d.ts +1 -1
  252. package/wizard/Wizard.js +112 -58
  253. package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +33 -24
  254. package/wizard/Wizard.test.js +141 -0
  255. package/wizard/types.d.ts +12 -11
  256. package/ThemeContext.js +0 -246
  257. package/V3Select/V3Select.js +0 -455
  258. package/V3Select/index.d.ts +0 -27
  259. package/V3Textarea/V3Textarea.js +0 -260
  260. package/V3Textarea/index.d.ts +0 -27
  261. package/common/RequiredComponent.js +0 -32
  262. package/date/Date.js +0 -373
  263. package/date/index.d.ts +0 -27
  264. package/input-text/Icons.js +0 -22
  265. package/input-text/InputText.js +0 -611
  266. package/input-text/index.d.ts +0 -36
  267. package/radio/Radio.d.ts +0 -4
  268. package/radio/Radio.js +0 -174
  269. package/radio/Radio.stories.tsx +0 -192
  270. package/radio/types.d.ts +0 -54
  271. package/select/index.d.ts +0 -131
  272. package/textarea/index.d.ts +0 -127
  273. package/toggle/Toggle.js +0 -186
  274. package/toggle/index.d.ts +0 -21
  275. package/upload/Upload.js +0 -201
  276. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  277. package/upload/buttons-upload/Icons.js +0 -40
  278. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  279. package/upload/dragAndDropArea/Icons.js +0 -39
  280. package/upload/file-upload/FileToUpload.js +0 -115
  281. package/upload/file-upload/Icons.js +0 -66
  282. package/upload/files-upload/FilesToUpload.js +0 -109
  283. package/upload/index.d.ts +0 -15
  284. package/upload/transaction/Icons.js +0 -160
  285. package/upload/transaction/Transaction.js +0 -104
  286. package/upload/transactions/Transactions.js +0 -94
  287. package/wizard/Icons.js +0 -65
@@ -1,19 +1,18 @@
1
1
  import React from "react";
2
-
3
- import { userEvent, within, waitFor } from "@storybook/testing-library";
4
- import { fireEvent } from "@testing-library/react";
5
-
2
+ import { userEvent, within } from "@storybook/testing-library";
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 { ThemeProvider } from "styled-components";
8
+ import useTheme from "../useTheme";
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" },
@@ -190,7 +189,29 @@ const url_options = [
190
189
  {
191
190
  label: "Facebook",
192
191
  value: "facebook",
193
- icon: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/2021_Facebook_icon.svg/2048px-2021_Facebook_icon.svg.png",
192
+ icon: (
193
+ <svg
194
+ version="1.1"
195
+ id="Capa_1"
196
+ x="0px"
197
+ y="0px"
198
+ width="438.536px"
199
+ height="438.536px"
200
+ viewBox="0 0 438.536 438.536"
201
+ fill="#4267B2"
202
+ >
203
+ <g>
204
+ <path
205
+ d="M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123
206
+ C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126
207
+ h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
208
+ C438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402
209
+ c0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401
210
+ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
211
+ />
212
+ </g>
213
+ </svg>
214
+ ),
194
215
  },
195
216
  {
196
217
  label: "Pinterest",
@@ -224,10 +245,11 @@ const optionsWithEllipsisMedium = [
224
245
  { label: "Optiond1234567890123456789012345678901234", value: "1" },
225
246
  { label: "Optiond12345678901234567890123456789012345", value: "2" },
226
247
  { label: "Option 031111111111111111111111111111222", value: "3" },
227
- { label: "Option 03111111111111111111111111111122", value: "4" },
228
248
  ];
249
+
229
250
  const Select = () => (
230
251
  <>
252
+ <Title title="States" theme="light" level={2} />
231
253
  <ExampleContainer pseudoState="pseudo-hover">
232
254
  <Title title="Hovered" theme="light" level={4} />
233
255
  <DxcSelect label="Hovered" options={single_options} />
@@ -242,129 +264,313 @@ const Select = () => (
242
264
  </ExampleContainer>
243
265
  <ExampleContainer>
244
266
  <Title title="Disabled with value" theme="light" level={4} />
245
- <DxcSelect label="Disabled with value" disabled options={single_options} value="1" />
267
+ <DxcSelect label="Disabled with value" disabled options={single_options} defaultValue="1" />
246
268
  </ExampleContainer>
247
269
  <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
270
  <Title title="Error" theme="light" level={4} />
255
271
  <DxcSelect
256
272
  label="Label"
257
273
  options={single_options}
258
- error="Error message"
274
+ error="Error message."
259
275
  helperText="Helper text"
260
276
  placeholder="Placeholder"
261
277
  />
278
+ </ExampleContainer>
279
+ <ExampleContainer pseudoState="pseudo-hover">
280
+ <Title title="Hovered error" theme="light" level={4} />
281
+ <DxcSelect
282
+ label="Label"
283
+ options={single_options}
284
+ error="Error message."
285
+ helperText="Helper text"
286
+ placeholder="Placeholder"
287
+ />
288
+ </ExampleContainer>
289
+ <Title title="Anatomy" theme="light" level={2} />
290
+ <ExampleContainer>
291
+ <Title title="Label, placeholder and helper text" theme="light" level={4} />
292
+ <DxcSelect label="Label" options={single_options} helperText="Helper text" placeholder="Placeholder" />
293
+ </ExampleContainer>
294
+ <Title title="Variants" theme="light" level={2} />
295
+ <ExampleContainer>
262
296
  <Title title="Simple selection" theme="light" level={4} />
263
- <DxcSelect label="Simple selection" searchable options={single_options} value="2" />
297
+ <DxcSelect label="Simple selection" searchable options={single_options} defaultValue="2" />
298
+ </ExampleContainer>
299
+ <ExampleContainer>
264
300
  <Title title="Multiple selection" theme="light" level={4} />
265
- <DxcSelect label="Multiple select" searchable options={single_options} multiple value={["1", "2"]} />
301
+ <DxcSelect label="Multiple select" searchable options={single_options} multiple defaultValue={["1", "2"]} />
266
302
  </ExampleContainer>
267
-
268
303
  <ExampleContainer pseudoState="pseudo-hover">
269
304
  <Title title="Multiple clear hovered" theme="light" level={4} />
270
- <DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
305
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
271
306
  </ExampleContainer>
272
-
273
307
  <ExampleContainer pseudoState="pseudo-active">
274
308
  <Title title="Multiple clear actived" theme="light" level={4} />
275
- <DxcSelect label="Multiple select" options={single_options} multiple value={["1", "2"]} />
309
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
276
310
  </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>
311
+ <Title title="Sizes" theme="light" level={2} />
312
+ <ExampleContainer>
313
+ <Title title="Small size" theme="light" level={4} />
314
+ <DxcSelect label="Small" options={single_options} size="small" />
315
+ </ExampleContainer>
316
+ <ExampleContainer>
317
+ <Title title="Medium size" theme="light" level={4} />
318
+ <DxcSelect label="Medium" options={single_options} size="medium" />
319
+ </ExampleContainer>
320
+ <ExampleContainer>
321
+ <Title title="Large size" theme="light" level={4} />
322
+ <DxcSelect label="Large" options={single_options} size="large" />
323
+ </ExampleContainer>
324
+ <ExampleContainer>
325
+ <Title title="Fillparent size" theme="light" level={4} />
326
+ <DxcSelect label="Fillparent" options={single_options} size="fillParent" />
327
+ </ExampleContainer>
328
+ <Title title="Margins" theme="light" level={2} />
329
+ <ExampleContainer>
330
+ <Title title="xxsmall margin" theme="light" level={4} />
331
+ <DxcSelect label="xxSmall" options={single_options} margin="xxsmall" />
332
+ </ExampleContainer>
333
+ <ExampleContainer>
334
+ <Title title="xsmall margin" theme="light" level={4} />
335
+ <DxcSelect label="xSmall" options={single_options} margin="xsmall" />
336
+ </ExampleContainer>
337
+ <ExampleContainer>
338
+ <Title title="small margin" theme="light" level={4} />
339
+ <DxcSelect label="Small" options={single_options} margin="small" />
340
+ </ExampleContainer>
341
+ <ExampleContainer>
342
+ <Title title="medium margin" theme="light" level={4} />
343
+ <DxcSelect label="Medium" options={single_options} margin="medium" />
344
+ </ExampleContainer>
345
+ <ExampleContainer>
346
+ <Title title="large margin" theme="light" level={4} />
347
+ <DxcSelect label="Large" options={single_options} margin="large" />
348
+ </ExampleContainer>
349
+ <ExampleContainer>
350
+ <Title title="xlarge margin" theme="light" level={4} />
351
+ <DxcSelect label="xLarge" options={single_options} margin="xlarge" />
352
+ </ExampleContainer>
353
+ <ExampleContainer>
354
+ <Title title="xxlarge margin" theme="light" level={4} />
355
+ <DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
356
+ </ExampleContainer>
357
+ <ExampleContainer expanded>
358
+ <Title title="Ellipsis" theme="light" level={2} />
359
+ <Title title="Multiple selection with ellipsis" theme="light" level={4} />
360
+ <DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
361
+ <Title title="Value with ellipsis" theme="light" level={4} />
362
+ <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" />
363
+ <Title title="Options with ellipsis" theme="light" level={4} />
364
+ <DxcSelect
365
+ label="Label"
366
+ placeholder="Choose an option"
367
+ defaultValue="1"
368
+ options={optionsWithEllipsisMedium}
369
+ margin={{ top: "xxlarge" }}
370
+ />
371
+ </ExampleContainer>
372
+ </>
373
+ );
374
+ const SelectListbox = () => {
375
+ const colorsTheme: any = useTheme();
376
+
377
+ return (
378
+ <ThemeProvider theme={colorsTheme.select}>
379
+ <Title title="Listbox" theme="light" level={2} />
283
380
  <ExampleContainer>
284
- <Title title="Medium size" theme="light" level={4} />
285
- <DxcSelect label="Medium" options={single_options} size="medium" />
381
+ <Title
382
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
383
+ theme="light"
384
+ level={3}
385
+ />
386
+ <div
387
+ style={{
388
+ position: "relative",
389
+ display: "flex",
390
+ flexDirection: "column",
391
+ gap: "20px",
392
+ height: "150px",
393
+ width: "min-content",
394
+ marginBottom: "100px",
395
+ padding: "20px",
396
+ border: "1px solid black",
397
+ borderRadius: "4px",
398
+ overflow: "auto",
399
+ zIndex: "1300",
400
+ }}
401
+ >
402
+ <DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
403
+ <button style={{ zIndex: "1", width: "100px" }}>Submit</button>
404
+ </div>
286
405
  </ExampleContainer>
287
- <ExampleContainer>
288
- <Title title="Large size" theme="light" level={4} />
289
- <DxcSelect label="Large" options={single_options} size="large" />
406
+ <Title title="Listbox option states" theme="light" level={3} />
407
+ <ExampleContainer pseudoState="pseudo-hover">
408
+ <Title title="Hovered option" theme="light" level={4} />
409
+ <Listbox
410
+ id="x"
411
+ currentValue=""
412
+ options={one_option}
413
+ visualFocusIndex={-1}
414
+ lastOptionIndex={0}
415
+ multiple={false}
416
+ optional={false}
417
+ optionalItem={{ label: "Empty", value: "" }}
418
+ searchable={false}
419
+ handleOptionOnClick={() => {}}
420
+ styles={{ width: 360 }}
421
+ />
290
422
  </ExampleContainer>
291
- <ExampleContainer>
292
- <Title title="Fillparent size" theme="light" level={4} />
293
- <DxcSelect label="Fillparent" options={single_options} size="fillParent" />
423
+ <ExampleContainer pseudoState="pseudo-active">
424
+ <Title title="Active option" theme="light" level={4} />
425
+ <Listbox
426
+ id="x"
427
+ currentValue=""
428
+ options={one_option}
429
+ visualFocusIndex={-1}
430
+ lastOptionIndex={0}
431
+ multiple={false}
432
+ optional={false}
433
+ optionalItem={{ label: "Empty", value: "" }}
434
+ searchable={false}
435
+ handleOptionOnClick={() => {}}
436
+ styles={{ width: 360 }}
437
+ />
294
438
  </ExampleContainer>
295
- </>
296
- <>
297
- <Title title="Margins" theme="light" level={2} />
298
439
  <ExampleContainer>
299
- <Title title="xxsmall margin" theme="light" level={4} />
300
- <DxcSelect label="xxSmall" options={single_options} margin="xxsmall" />
440
+ <Title title="Focused option" theme="light" level={4} />
441
+ <Listbox
442
+ id="x"
443
+ currentValue=""
444
+ options={one_option}
445
+ visualFocusIndex={0}
446
+ lastOptionIndex={0}
447
+ multiple={false}
448
+ optional={false}
449
+ optionalItem={{ label: "Empty", value: "" }}
450
+ searchable={false}
451
+ handleOptionOnClick={() => {}}
452
+ styles={{ width: 360 }}
453
+ />
301
454
  </ExampleContainer>
302
- <ExampleContainer>
303
- <Title title="xsmall margin" theme="light" level={4} />
304
- <DxcSelect label="xSmall" options={single_options} margin="xsmall" />
455
+ <ExampleContainer pseudoState="pseudo-hover">
456
+ <Title title="Hovered selected option" theme="light" level={4} />
457
+ <Listbox
458
+ id="x"
459
+ currentValue="1"
460
+ options={single_options}
461
+ visualFocusIndex={-1}
462
+ lastOptionIndex={3}
463
+ multiple={false}
464
+ optional={false}
465
+ optionalItem={{ label: "Empty", value: "" }}
466
+ searchable={false}
467
+ handleOptionOnClick={() => {}}
468
+ styles={{ width: 360 }}
469
+ />
305
470
  </ExampleContainer>
306
- <ExampleContainer>
307
- <Title title="small margin" theme="light" level={4} />
308
- <DxcSelect label="Small" options={single_options} margin="small" />
471
+ <ExampleContainer pseudoState="pseudo-active">
472
+ <Title title="Active selected option" theme="light" level={4} />
473
+ <Listbox
474
+ id="x"
475
+ currentValue="2"
476
+ options={single_options}
477
+ visualFocusIndex={0}
478
+ lastOptionIndex={3}
479
+ multiple={false}
480
+ optional={false}
481
+ optionalItem={{ label: "Empty", value: "" }}
482
+ searchable={false}
483
+ handleOptionOnClick={() => {}}
484
+ styles={{ width: 360 }}
485
+ />
309
486
  </ExampleContainer>
487
+ <Title title="Listbox with icons" theme="light" level={3} />
310
488
  <ExampleContainer>
311
- <Title title="medium margin" theme="light" level={4} />
312
- <DxcSelect label="Medium" options={single_options} margin="medium" />
489
+ <Title title="Icons (SVGs)" theme="light" level={4} />
490
+ <Listbox
491
+ id="x"
492
+ currentValue="3"
493
+ options={icon_options}
494
+ visualFocusIndex={-1}
495
+ lastOptionIndex={3}
496
+ multiple={false}
497
+ optional={false}
498
+ optionalItem={{ label: "Empty", value: "" }}
499
+ searchable={false}
500
+ handleOptionOnClick={() => {}}
501
+ styles={{ width: 360 }}
502
+ />
313
503
  </ExampleContainer>
314
504
  <ExampleContainer>
315
- <Title title="large margin" theme="light" level={4} />
316
- <DxcSelect label="Large" options={single_options} margin="large" />
505
+ <Title title="Icons (Images)" theme="light" level={4} />
506
+ <Listbox
507
+ id="x"
508
+ currentValue="facebook"
509
+ options={url_options}
510
+ visualFocusIndex={-1}
511
+ lastOptionIndex={6}
512
+ multiple={false}
513
+ optional={false}
514
+ optionalItem={{ label: "Empty", value: "" }}
515
+ searchable={false}
516
+ handleOptionOnClick={() => {}}
517
+ styles={{ width: 360 }}
518
+ />
317
519
  </ExampleContainer>
318
520
  <ExampleContainer>
319
- <Title title="xlarge margin" theme="light" level={4} />
320
- <DxcSelect label="xLarge" options={single_options} margin="xlarge" />
521
+ <Title title="Grouped icons (SVGs)" theme="light" level={4} />
522
+ <Listbox
523
+ id="x"
524
+ currentValue={["0", "3"]}
525
+ options={icon_options_grouped}
526
+ visualFocusIndex={-1}
527
+ lastOptionIndex={3}
528
+ multiple={false}
529
+ optional={false}
530
+ optionalItem={{ label: "Empty", value: "" }}
531
+ searchable={false}
532
+ handleOptionOnClick={() => {}}
533
+ styles={{ width: 360 }}
534
+ />
321
535
  </ExampleContainer>
322
536
  <ExampleContainer>
323
- <Title title="xxlarge margin" theme="light" level={4} />
324
- <DxcSelect label="xxLarge" options={single_options} margin="xxlarge" />
537
+ <Title title="Grouped icons (Images)" theme="light" level={4} />
538
+ <Listbox
539
+ id="x"
540
+ currentValue={["facebook", "figma"]}
541
+ options={url_options}
542
+ visualFocusIndex={-1}
543
+ lastOptionIndex={6}
544
+ multiple={true}
545
+ optional={false}
546
+ optionalItem={{ label: "Empty", value: "" }}
547
+ searchable={false}
548
+ handleOptionOnClick={() => {}}
549
+ styles={{ width: 360 }}
550
+ />
325
551
  </ExampleContainer>
326
- </>
327
- <ExampleContainer expanded>
328
- <Title title="Ellipsis" theme="light" level={2} />
329
- <Title title="Multiple selection with ellipsis" theme="light" level={4} />
330
- <DxcSelect label="Label" options={single_options} multiple value={["1", "2", "3", "4"]} />
331
- <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} />
334
- <DxcSelect
335
- label="Label"
336
- placeholder="Choose an option"
337
- value="1"
338
- options={optionsWithEllipsisMedium}
339
- size="medium"
340
- />
341
- </ExampleContainer>
342
- </>
343
- );
344
- export const Chromatic = Select.bind({});
345
- Chromatic.play = async ({ canvasElement }) => {
346
- const canvas = within(canvasElement);
347
- await userEvent.click(canvas.getAllByRole("combobox")[25]);
552
+ </ThemeProvider>
553
+ );
348
554
  };
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>
354
- );
555
+
355
556
  const SearchableSelect = () => (
356
557
  <ExampleContainer expanded>
357
558
  <Title title="Searchable select" theme="light" level={4} />
358
559
  <DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
359
560
  </ExampleContainer>
360
561
  );
361
- const SearchableWithValue = () => (
562
+ const SearchValue = () => (
362
563
  <ExampleContainer expanded>
363
564
  <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" />
565
+ <DxcSelect
566
+ label="Select Label"
567
+ searchable
568
+ defaultValue="1"
569
+ options={single_options}
570
+ placeholder="Choose an option"
571
+ />
365
572
  </ExampleContainer>
366
573
  );
367
-
368
574
  const MultipleSelect = () => (
369
575
  <>
370
576
  <ExampleContainer expanded>
@@ -372,7 +578,7 @@ const MultipleSelect = () => (
372
578
  <DxcSelect
373
579
  label="Select label"
374
580
  options={single_options}
375
- value={["1", "4"]}
581
+ defaultValue={["1", "4"]}
376
582
  multiple
377
583
  placeholder="Choose an option"
378
584
  />
@@ -382,75 +588,21 @@ const MultipleSelect = () => (
382
588
  const DefaultGroupedOptionsSelect = () => (
383
589
  <ExampleContainer expanded>
384
590
  <Title title="Grouped options simple select" theme="light" level={4} />
385
- <DxcSelect label="Label" options={group_options} value="9" placeholder="Choose an option" />
591
+ <DxcSelect label="Label" options={group_options} defaultValue="9" placeholder="Choose an option" />
386
592
  </ExampleContainer>
387
593
  );
388
594
  const MultipleGroupedOptionsSelect = () => (
389
595
  <ExampleContainer expanded>
390
596
  <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" />
392
- </ExampleContainer>
393
- );
394
- const RescaledIcons = () => (
395
- <ExampleContainer expanded>
396
- <Title title="Rescaled icons displayed" theme="light" level={4} />
397
- <DxcSelect label="Label" options={url_options} value="facebook" placeholder="Choose an option" />
398
- </ExampleContainer>
399
- );
400
- const SelectWithIcons = () => (
401
- <ExampleContainer expanded>
402
- <Title title="Normal icons displayed" theme="light" level={4} />
403
- <DxcSelect label="Label" options={icon_options} value="3" placeholder="Choose an option" />
404
- </ExampleContainer>
405
- );
406
- const SelectMultipleWithIcons = () => (
407
- <ExampleContainer expanded>
408
- <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" />
410
- </ExampleContainer>
411
- );
412
- const MultipleGroupedOptionsSelectWithIcons = () => (
413
- <ExampleContainer expanded>
414
- <Title title="Multiple grouped options with icons" theme="light" level={4} />
415
597
  <DxcSelect
416
598
  label="Label"
417
- options={icon_options_grouped}
599
+ options={group_options}
600
+ defaultValue={["0", "2"]}
418
601
  multiple
419
- value={["3", "2"]}
420
602
  placeholder="Choose an option"
421
603
  />
422
604
  </ExampleContainer>
423
605
  );
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
- );
454
606
  const MultipleSearchable = () => (
455
607
  <ExampleContainer expanded>
456
608
  <Title title="Searchable multiple select with value" theme="light" level={4} />
@@ -458,34 +610,40 @@ const MultipleSearchable = () => (
458
610
  label="Select Label"
459
611
  searchable
460
612
  multiple
461
- value={["1", "4"]}
613
+ defaultValue={["1", "4"]}
462
614
  options={single_options}
463
615
  placeholder="Choose an option"
464
616
  />
465
617
  </ExampleContainer>
466
618
  );
467
- export const OptionsDisplayed = DefaultSelect.bind({});
468
- OptionsDisplayed.play = async ({ canvasElement }) => {
619
+
620
+ export const Chromatic = Select.bind({});
621
+ Chromatic.play = async ({ canvasElement }) => {
622
+ const canvas = within(canvasElement);
623
+ await userEvent.click(canvas.getAllByRole("combobox")[24]);
624
+ };
625
+
626
+ export const ListboxStates = SelectListbox.bind({});
627
+ ListboxStates.play = async ({ canvasElement }) => {
469
628
  const canvas = within(canvasElement);
470
629
  const select = canvas.getByRole("combobox");
471
630
  await userEvent.click(select);
472
631
  };
632
+
473
633
  export const Searchable = SearchableSelect.bind({});
474
634
  Searchable.play = async ({ canvasElement }) => {
475
635
  const canvas = within(canvasElement);
476
- await userEvent.click(canvas.getByRole("combobox"));
477
- await waitFor(async () => {
478
- userEvent.type(canvas.getByRole("combobox"), "r");
479
- });
636
+ await userEvent.type(canvas.getByRole("combobox"), "r");
480
637
  };
481
- export const SelectSearchableWithValue = SearchableWithValue.bind({});
482
- SelectSearchableWithValue.play = async ({ canvasElement }) => {
638
+
639
+ export const SearchableWithValue = SearchValue.bind({});
640
+ SearchableWithValue.play = async ({ canvasElement }) => {
483
641
  const canvas = within(canvasElement);
484
642
  await userEvent.click(canvas.getByRole("combobox"));
485
643
  };
486
644
 
487
- export const SelectMultipleSearchableWithValue = MultipleSearchable.bind({});
488
- SelectMultipleSearchableWithValue.play = async ({ canvasElement }) => {
645
+ export const MultipleSearchableWithValue = MultipleSearchable.bind({});
646
+ MultipleSearchableWithValue.play = async ({ canvasElement }) => {
489
647
  const canvas = within(canvasElement);
490
648
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
491
649
  };
@@ -497,75 +655,14 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
497
655
  await userEvent.click(select);
498
656
  };
499
657
 
500
- export const SelectMultipleOptionsDisplayed = MultipleSelect.bind({});
501
- SelectMultipleOptionsDisplayed.play = async ({ canvasElement }) => {
658
+ export const MultipleOptionsDisplayed = MultipleSelect.bind({});
659
+ MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
502
660
  const canvas = within(canvasElement);
503
661
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
504
662
  };
505
663
 
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 }) => {
514
- const canvas = within(canvasElement);
515
- const select = canvas.getByRole("combobox");
516
- await userEvent.click(select);
517
- };
518
-
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 }) => {
527
- const canvas = within(canvasElement);
528
- const select = canvas.getByRole("combobox");
529
- await userEvent.click(select);
530
- };
531
-
532
- export const SelectMultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
533
- SelectMultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
534
- const canvas = within(canvasElement);
535
- const select = canvas.getByRole("combobox");
536
- await userEvent.click(select);
537
- };
538
-
539
- export const OptionHovered = OnlyOneOptionHovered.bind({});
540
- OptionHovered.play = async ({ canvasElement }) => {
541
- const canvas = within(canvasElement);
542
- const select = canvas.getByRole("combobox");
543
- await userEvent.click(select);
544
- };
545
-
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 }) => {
664
+ export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
665
+ MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
569
666
  const canvas = within(canvasElement);
570
667
  const select = canvas.getByRole("combobox");
571
668
  await userEvent.click(select);