@dxc-technology/halstack-react 0.0.0-4448bdb → 0.0.0-453c87a

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