@dxc-technology/halstack-react 0.0.0-61a8ced → 0.0.0-62702b8

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 (244) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1349 -5
  4. package/HalstackContext.js +117 -77
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +14 -37
  8. package/accordion/Accordion.stories.tsx +104 -113
  9. package/accordion/Accordion.test.js +1 -1
  10. package/accordion/types.d.ts +2 -13
  11. package/accordion-group/AccordionGroup.d.ts +4 -3
  12. package/accordion-group/AccordionGroup.js +23 -44
  13. package/accordion-group/AccordionGroup.stories.tsx +77 -76
  14. package/accordion-group/AccordionGroup.test.js +7 -17
  15. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  16. package/accordion-group/AccordionGroupAccordion.js +43 -0
  17. package/accordion-group/types.d.ts +2 -13
  18. package/alert/Alert.js +4 -8
  19. package/alert/Alert.stories.tsx +28 -0
  20. package/alert/Alert.test.js +1 -1
  21. package/bleed/Bleed.stories.tsx +1 -0
  22. package/box/Box.d.ts +1 -1
  23. package/box/Box.js +7 -26
  24. package/box/Box.stories.tsx +38 -51
  25. package/box/Box.test.js +1 -1
  26. package/box/types.d.ts +0 -11
  27. package/bulleted-list/BulletedList.js +4 -2
  28. package/bulleted-list/BulletedList.stories.tsx +7 -1
  29. package/bulleted-list/types.d.ts +31 -4
  30. package/button/Button.d.ts +1 -1
  31. package/button/Button.js +48 -60
  32. package/button/Button.stories.tsx +151 -9
  33. package/button/Button.test.js +12 -1
  34. package/button/types.d.ts +7 -3
  35. package/card/Card.d.ts +1 -1
  36. package/card/Card.js +27 -45
  37. package/card/Card.stories.tsx +12 -42
  38. package/card/Card.test.js +1 -1
  39. package/card/types.d.ts +1 -6
  40. package/checkbox/Checkbox.d.ts +2 -2
  41. package/checkbox/Checkbox.js +74 -53
  42. package/checkbox/Checkbox.stories.tsx +146 -58
  43. package/checkbox/Checkbox.test.js +84 -11
  44. package/checkbox/types.d.ts +10 -2
  45. package/chip/Chip.js +28 -49
  46. package/chip/Chip.stories.tsx +121 -26
  47. package/chip/Chip.test.js +3 -5
  48. package/common/OpenSans.css +68 -80
  49. package/common/coreTokens.d.ts +146 -0
  50. package/common/coreTokens.js +167 -0
  51. package/common/utils.d.ts +1 -0
  52. package/common/utils.js +4 -4
  53. package/common/variables.d.ts +1499 -0
  54. package/common/variables.js +1004 -1134
  55. package/date-input/Calendar.d.ts +4 -0
  56. package/date-input/Calendar.js +258 -0
  57. package/date-input/DateInput.js +138 -239
  58. package/date-input/DateInput.stories.tsx +209 -33
  59. package/date-input/DateInput.test.js +519 -149
  60. package/date-input/DatePicker.d.ts +4 -0
  61. package/date-input/DatePicker.js +146 -0
  62. package/date-input/Icons.d.ts +6 -0
  63. package/date-input/Icons.js +75 -0
  64. package/date-input/YearPicker.d.ts +4 -0
  65. package/date-input/YearPicker.js +126 -0
  66. package/date-input/types.d.ts +57 -0
  67. package/dialog/Dialog.d.ts +1 -1
  68. package/dialog/Dialog.js +54 -85
  69. package/dialog/Dialog.stories.tsx +154 -170
  70. package/dialog/Dialog.test.js +302 -3
  71. package/dialog/types.d.ts +0 -12
  72. package/dropdown/Dropdown.js +42 -41
  73. package/dropdown/Dropdown.stories.tsx +210 -84
  74. package/dropdown/Dropdown.test.js +22 -27
  75. package/dropdown/DropdownMenu.js +12 -18
  76. package/dropdown/DropdownMenuItem.js +5 -18
  77. package/dropdown/types.d.ts +3 -3
  78. package/file-input/FileInput.d.ts +2 -2
  79. package/file-input/FileInput.js +174 -220
  80. package/file-input/FileInput.stories.tsx +122 -11
  81. package/file-input/FileInput.test.js +14 -14
  82. package/file-input/FileItem.d.ts +4 -14
  83. package/file-input/FileItem.js +39 -63
  84. package/file-input/types.d.ts +18 -1
  85. package/flex/Flex.d.ts +1 -1
  86. package/flex/Flex.js +33 -19
  87. package/flex/Flex.stories.tsx +35 -26
  88. package/flex/types.d.ts +83 -7
  89. package/footer/Footer.d.ts +1 -1
  90. package/footer/Footer.js +44 -64
  91. package/footer/Footer.stories.tsx +36 -21
  92. package/footer/Footer.test.js +16 -26
  93. package/footer/types.d.ts +10 -11
  94. package/grid/Grid.d.ts +7 -0
  95. package/grid/Grid.js +91 -0
  96. package/grid/Grid.stories.tsx +219 -0
  97. package/grid/types.d.ts +115 -0
  98. package/header/Header.d.ts +4 -3
  99. package/header/Header.js +20 -49
  100. package/header/Header.stories.tsx +115 -36
  101. package/header/Header.test.js +2 -2
  102. package/header/types.d.ts +1 -14
  103. package/heading/Heading.js +1 -1
  104. package/heading/Heading.test.js +1 -1
  105. package/image/Image.d.ts +4 -0
  106. package/image/Image.js +85 -0
  107. package/image/Image.stories.tsx +127 -0
  108. package/image/types.d.ts +72 -0
  109. package/inset/Inset.stories.tsx +2 -1
  110. package/layout/ApplicationLayout.d.ts +5 -5
  111. package/layout/ApplicationLayout.js +15 -12
  112. package/layout/ApplicationLayout.stories.tsx +1 -1
  113. package/layout/Icons.d.ts +7 -4
  114. package/layout/Icons.js +52 -56
  115. package/layout/types.d.ts +2 -3
  116. package/link/Link.js +4 -4
  117. package/link/Link.stories.tsx +60 -0
  118. package/link/Link.test.js +2 -4
  119. package/link/types.d.ts +2 -2
  120. package/main.d.ts +5 -3
  121. package/main.js +18 -2
  122. package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
  123. package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
  124. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +110 -6
  125. package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
  126. package/{tabs-nav → nav-tabs}/Tab.js +49 -33
  127. package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
  128. package/number-input/NumberInput.d.ts +7 -0
  129. package/number-input/NumberInput.js +8 -4
  130. package/number-input/NumberInput.stories.tsx +47 -2
  131. package/number-input/NumberInput.test.js +354 -92
  132. package/number-input/types.d.ts +6 -0
  133. package/package.json +14 -19
  134. package/paginator/Icons.d.ts +5 -0
  135. package/paginator/Icons.js +16 -28
  136. package/paginator/Paginator.js +8 -16
  137. package/paginator/Paginator.stories.tsx +24 -0
  138. package/paginator/Paginator.test.js +58 -48
  139. package/paragraph/Paragraph.d.ts +3 -4
  140. package/paragraph/Paragraph.js +5 -5
  141. package/password-input/Icons.d.ts +6 -0
  142. package/password-input/Icons.js +39 -0
  143. package/password-input/PasswordInput.js +35 -82
  144. package/password-input/PasswordInput.stories.tsx +1 -0
  145. package/password-input/PasswordInput.test.js +34 -40
  146. package/progress-bar/ProgressBar.d.ts +2 -2
  147. package/progress-bar/ProgressBar.js +5 -5
  148. package/progress-bar/ProgressBar.stories.jsx +35 -2
  149. package/progress-bar/ProgressBar.test.js +1 -1
  150. package/progress-bar/types.d.ts +4 -3
  151. package/quick-nav/QuickNav.js +11 -12
  152. package/quick-nav/QuickNav.stories.tsx +111 -19
  153. package/radio-group/Radio.d.ts +1 -1
  154. package/radio-group/Radio.js +50 -35
  155. package/radio-group/RadioGroup.js +29 -29
  156. package/radio-group/RadioGroup.stories.tsx +132 -18
  157. package/radio-group/RadioGroup.test.js +153 -99
  158. package/radio-group/types.d.ts +5 -5
  159. package/resultset-table/Icons.d.ts +7 -0
  160. package/resultset-table/Icons.js +51 -0
  161. package/{resultsetTable → resultset-table}/ResultsetTable.js +49 -108
  162. package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +50 -25
  163. package/{resultsetTable → resultset-table}/ResultsetTable.test.js +41 -64
  164. package/{resultsetTable → resultset-table}/types.d.ts +1 -1
  165. package/resultset-table/types.js +5 -0
  166. package/select/Listbox.d.ts +1 -1
  167. package/select/Listbox.js +5 -35
  168. package/select/Option.js +11 -24
  169. package/select/Select.js +59 -36
  170. package/select/Select.stories.tsx +497 -153
  171. package/select/Select.test.js +345 -292
  172. package/select/types.d.ts +2 -2
  173. package/sidenav/Icons.d.ts +7 -0
  174. package/sidenav/Icons.js +51 -0
  175. package/sidenav/Sidenav.d.ts +2 -2
  176. package/sidenav/Sidenav.js +66 -96
  177. package/sidenav/Sidenav.stories.tsx +165 -63
  178. package/sidenav/types.d.ts +21 -18
  179. package/slider/Slider.d.ts +2 -2
  180. package/slider/Slider.js +17 -14
  181. package/slider/Slider.stories.tsx +57 -0
  182. package/slider/Slider.test.js +1 -1
  183. package/slider/types.d.ts +6 -2
  184. package/spinner/Spinner.js +17 -23
  185. package/spinner/Spinner.stories.jsx +53 -27
  186. package/spinner/Spinner.test.js +1 -1
  187. package/switch/Switch.d.ts +3 -3
  188. package/switch/Switch.js +95 -84
  189. package/switch/Switch.stories.tsx +33 -0
  190. package/switch/Switch.test.js +27 -14
  191. package/switch/types.d.ts +8 -3
  192. package/table/Table.js +3 -3
  193. package/table/Table.stories.jsx +80 -1
  194. package/table/Table.test.js +2 -2
  195. package/tabs/Tab.js +12 -15
  196. package/tabs/Tabs.js +11 -17
  197. package/tabs/Tabs.stories.tsx +45 -5
  198. package/tabs/Tabs.test.js +4 -5
  199. package/tabs/types.d.ts +2 -2
  200. package/tag/Tag.js +7 -9
  201. package/tag/Tag.stories.tsx +14 -1
  202. package/tag/Tag.test.js +1 -1
  203. package/text-input/Icons.d.ts +8 -0
  204. package/text-input/Icons.js +60 -0
  205. package/text-input/Suggestion.js +40 -11
  206. package/text-input/Suggestions.d.ts +4 -0
  207. package/text-input/Suggestions.js +134 -0
  208. package/text-input/TextInput.js +232 -342
  209. package/text-input/TextInput.stories.tsx +319 -184
  210. package/text-input/TextInput.test.js +848 -726
  211. package/text-input/types.d.ts +27 -2
  212. package/textarea/Textarea.js +27 -26
  213. package/textarea/Textarea.stories.jsx +68 -1
  214. package/textarea/Textarea.test.js +61 -19
  215. package/textarea/types.d.ts +4 -0
  216. package/toggle-group/ToggleGroup.d.ts +2 -2
  217. package/toggle-group/ToggleGroup.js +85 -59
  218. package/toggle-group/ToggleGroup.stories.tsx +48 -3
  219. package/toggle-group/ToggleGroup.test.js +38 -24
  220. package/toggle-group/types.d.ts +22 -13
  221. package/typography/Typography.d.ts +2 -2
  222. package/typography/Typography.js +14 -113
  223. package/typography/Typography.stories.tsx +1 -1
  224. package/useTheme.d.ts +1251 -1
  225. package/useTheme.js +1 -1
  226. package/useTranslatedLabels.d.ts +84 -1
  227. package/utils/BaseTypography.d.ts +21 -0
  228. package/utils/BaseTypography.js +108 -0
  229. package/utils/FocusLock.d.ts +13 -0
  230. package/utils/FocusLock.js +138 -0
  231. package/wizard/Wizard.js +2 -2
  232. package/wizard/Wizard.stories.tsx +20 -0
  233. package/wizard/Wizard.test.js +1 -1
  234. package/wizard/types.d.ts +5 -6
  235. package/card/ice-cream.jpg +0 -0
  236. package/common/RequiredComponent.js +0 -32
  237. package/number-input/NumberInputContext.d.ts +0 -4
  238. package/number-input/NumberInputContext.js +0 -19
  239. package/number-input/numberInputContextTypes.d.ts +0 -19
  240. /package/{resultsetTable → grid}/types.js +0 -0
  241. /package/{tabs-nav → image}/types.js +0 -0
  242. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
  243. /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
  244. /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
@@ -1,10 +1,17 @@
1
1
  import React from "react";
2
- import { userEvent, within, fireEvent } from "@storybook/testing-library";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
3
  import { BackgroundColorProvider } from "../BackgroundColorContext";
4
4
  import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
6
  import DarkContainer from "../../.storybook/components/DarkSection";
7
7
  import DxcTextInput from "./TextInput";
8
+ import DxcButton from "../button/Button";
9
+ import DxcCheckbox from "../checkbox/Checkbox";
10
+ import DxcFlex from "../flex/Flex";
11
+ import Suggestions from "./Suggestions";
12
+ import { ThemeProvider } from "styled-components";
13
+ import useTheme from "../useTheme";
14
+ import { HalstackProvider } from "../HalstackContext";
8
15
 
9
16
  export default {
10
17
  title: "Text input",
@@ -21,7 +28,7 @@ const action = {
21
28
  ),
22
29
  };
23
30
 
24
- const actionLargeIcon = {
31
+ const actionLargeIconSVG = {
25
32
  onClick: () => {},
26
33
  icon: (
27
34
  <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
@@ -31,6 +38,11 @@ const actionLargeIcon = {
31
38
  ),
32
39
  };
33
40
 
41
+ const actionLargeIconURL = {
42
+ onClick: () => {},
43
+ icon: "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png",
44
+ };
45
+
34
46
  const country = ["Afghanistan"];
35
47
  const countries = [
36
48
  "Afghanistan",
@@ -55,8 +67,16 @@ const countries = [
55
67
  "Dominica",
56
68
  "Denmark",
57
69
  "Djibouti",
70
+ "*",
58
71
  ];
59
72
 
73
+ const opinionatedTheme = {
74
+ textInput: {
75
+ fontColor: "#000000",
76
+ hoverBorderColor: "#a46ede",
77
+ },
78
+ };
79
+
60
80
  export const Chromatic = () => (
61
81
  <>
62
82
  <ExampleContainer pseudoState="pseudo-hover">
@@ -71,6 +91,14 @@ export const Chromatic = () => (
71
91
  <Title title="Hovered action" theme="light" level={4} />
72
92
  <DxcTextInput label="Text input" defaultValue="Text" clearable />
73
93
  </ExampleContainer>
94
+ <ExampleContainer pseudoState="pseudo-active">
95
+ <Title title="Actived action" theme="light" level={4} />
96
+ <DxcTextInput label="Text input" action={action} clearable />
97
+ </ExampleContainer>
98
+ <ExampleContainer pseudoState="pseudo-focus">
99
+ <Title title="Focused action" theme="light" level={4} />
100
+ <DxcTextInput label="Text input" action={action} clearable />
101
+ </ExampleContainer>
74
102
  <ExampleContainer>
75
103
  <Title title="Without label" theme="light" level={4} />
76
104
  <DxcTextInput />
@@ -84,12 +112,21 @@ export const Chromatic = () => (
84
112
  <DxcTextInput label="Text input" clearable defaultValue="Text" helperText="Help message" optional />
85
113
  </ExampleContainer>
86
114
  <ExampleContainer>
87
- <Title title="Clearable and large icon action" theme="light" level={4} />
115
+ <Title title="Clearable and large icon action (SVG)" theme="light" level={4} />
88
116
  <DxcTextInput
89
117
  label="Text input"
90
118
  defaultValue="Text text text text text text text text text text"
91
119
  clearable
92
- action={actionLargeIcon}
120
+ action={actionLargeIconSVG}
121
+ />
122
+ </ExampleContainer>
123
+ <ExampleContainer>
124
+ <Title title="Clearable and large icon action (URL)" theme="light" level={4} />
125
+ <DxcTextInput
126
+ label="Text input"
127
+ defaultValue="Text text text text text text text text text text"
128
+ clearable
129
+ action={actionLargeIconURL}
93
130
  />
94
131
  </ExampleContainer>
95
132
  <ExampleContainer>
@@ -149,9 +186,48 @@ export const Chromatic = () => (
149
186
  action={action}
150
187
  />
151
188
  </ExampleContainer>
189
+ <ExampleContainer>
190
+ <Title title="Read only" theme="light" level={4} />
191
+ <DxcTextInput
192
+ label="Example label"
193
+ helperText="Help message"
194
+ clearable
195
+ readOnly
196
+ optional
197
+ prefix="+34"
198
+ defaultValue="Text"
199
+ action={action}
200
+ />
201
+ </ExampleContainer>
202
+ <ExampleContainer pseudoState="pseudo-hover">
203
+ <Title title="Hovered read only" theme="light" level={4} />
204
+ <DxcTextInput
205
+ label="Example label"
206
+ helperText="Help message"
207
+ clearable
208
+ readOnly
209
+ optional
210
+ prefix="+34"
211
+ defaultValue="Text"
212
+ action={action}
213
+ />
214
+ </ExampleContainer>
215
+ <ExampleContainer pseudoState="pseudo-active">
216
+ <Title title="Active read only" theme="light" level={4} />
217
+ <DxcTextInput
218
+ label="Example label"
219
+ helperText="Help message"
220
+ clearable
221
+ readOnly
222
+ optional
223
+ prefix="+34"
224
+ defaultValue="Text"
225
+ action={action}
226
+ />
227
+ </ExampleContainer>
152
228
  <BackgroundColorProvider color="#333333">
153
229
  <DarkContainer>
154
- <Title title="Dark" theme="dark" level={2} />
230
+ <Title title="Dark theme" theme="dark" level={2} />
155
231
  <ExampleContainer pseudoState="pseudo-hover">
156
232
  <Title title="Hovered" theme="dark" level={4} />
157
233
  <DxcTextInput label="Text input" />
@@ -164,6 +240,14 @@ export const Chromatic = () => (
164
240
  <Title title="Hovered action" theme="dark" level={4} />
165
241
  <DxcTextInput label="Text input" defaultValue="Text" clearable />
166
242
  </ExampleContainer>
243
+ <ExampleContainer pseudoState="pseudo-active">
244
+ <Title title="Actived action" theme="dark" level={4} />
245
+ <DxcTextInput label="Text input" action={action} clearable />
246
+ </ExampleContainer>
247
+ <ExampleContainer pseudoState="pseudo-focus">
248
+ <Title title="Focused action" theme="dark" level={4} />
249
+ <DxcTextInput label="Text input" action={action} clearable />
250
+ </ExampleContainer>
167
251
  <ExampleContainer>
168
252
  <Title title="Helper text, placeholder, optional and action" theme="dark" level={4} />
169
253
  <DxcTextInput
@@ -275,199 +359,250 @@ export const Chromatic = () => (
275
359
  <Title title="FillParent size" theme="light" level={4} />
276
360
  <DxcTextInput label="FillParent" size="fillParent" />
277
361
  </ExampleContainer>
362
+ <Title title="Opinionated theme" theme="light" level={2} />
363
+ <ExampleContainer>
364
+ <HalstackProvider theme={opinionatedTheme}>
365
+ <ExampleContainer pseudoState="pseudo-hover">
366
+ <Title title="Hovered input" theme="light" level={4} />
367
+ <DxcTextInput label="Text input" helperText="Help message" />
368
+ </ExampleContainer>
369
+ <ExampleContainer pseudoState="pseudo-focus-within">
370
+ <Title title="Focused input" theme="light" level={4} />
371
+ <DxcTextInput label="Text input" helperText="Help message" />
372
+ </ExampleContainer>
373
+ <ExampleContainer pseudoState="pseudo-hover">
374
+ <Title title="Hovered action" theme="light" level={4} />
375
+ <DxcTextInput label="Text input" helperText="Help message" defaultValue="Text" clearable />
376
+ </ExampleContainer>
377
+ <ExampleContainer pseudoState="pseudo-active">
378
+ <Title title="Actived action" theme="light" level={4} />
379
+ <DxcTextInput label="Text input" helperText="Help message" action={action} clearable />
380
+ </ExampleContainer>
381
+ <ExampleContainer pseudoState="pseudo-focus">
382
+ <Title title="Focused action" theme="light" level={4} />
383
+ <DxcTextInput label="Text input" helperText="Help message" action={action} clearable />
384
+ </ExampleContainer>
385
+ <ExampleContainer>
386
+ <Title title="Prefix" theme="light" level={4} />
387
+ <DxcTextInput label="With prefix" prefix="+34" helperText="Help message" />
388
+ </ExampleContainer>
389
+ <ExampleContainer>
390
+ <Title title="Suffix and action" theme="light" level={4} />
391
+ <DxcTextInput label="With suffix" helperText="Help message" suffix="USD" action={action} />
392
+ </ExampleContainer>
393
+ <ExampleContainer>
394
+ <Title title="Invalid" theme="light" level={4} />
395
+ <DxcTextInput
396
+ label="Error text input"
397
+ helperText="Help message"
398
+ error="Error message."
399
+ defaultValue="Text"
400
+ clearable
401
+ optional
402
+ action={action}
403
+ />
404
+ </ExampleContainer>
405
+ <ExampleContainer>
406
+ <Title title="Disabled and placeholder" theme="light" level={4} />
407
+ <DxcTextInput label="Disabled text input" disabled placeholder="Placeholder" prefix="+34" suffix="USD" />
408
+ </ExampleContainer>
409
+ <ExampleContainer>
410
+ <Title title="Disabled, helper text, optional, value and action" theme="light" level={4} />
411
+ <DxcTextInput
412
+ label="Disabled text input"
413
+ helperText="Help message"
414
+ disabled
415
+ optional
416
+ defaultValue="Text"
417
+ action={action}
418
+ />
419
+ </ExampleContainer>
420
+ </HalstackProvider>
421
+ </ExampleContainer>
278
422
  </>
279
423
  );
280
424
 
281
- const FocusedActionTextInput = () => (
282
- <ExampleContainer expanded>
283
- <Title title="Focused action" theme="light" level={4} />
284
- <DxcTextInput label="Text input" action={action} clearable />
285
- </ExampleContainer>
286
- );
287
-
288
- const ActivedActionTextInput = () => (
289
- <ExampleContainer pseudoState="pseudo-active" expanded>
290
- <Title title="Actived action" theme="light" level={4} />
291
- <DxcTextInput label="Text input" action={action} clearable />
292
- </ExampleContainer>
293
- );
294
-
295
- const ShowOptionsAutosuggest = () => (
296
- <ExampleContainer expanded>
297
- <Title title="Show options" theme="light" level={4} />
298
- <DxcTextInput label="Text input" suggestions={countries} clearable />
299
- </ExampleContainer>
300
- );
301
-
302
- const HoveredOptionAutosuggest = () => (
303
- <ExampleContainer expanded pseudoState="pseudo-hover">
304
- <Title title="Hovered option" theme="light" level={4} />
305
- <DxcTextInput label="Text input" suggestions={country} clearable />
306
- </ExampleContainer>
307
- );
308
-
309
- const FocusedOptionAutosuggest = () => (
310
- <ExampleContainer expanded>
311
- <Title title="Focused option" theme="light" level={4} />
312
- <DxcTextInput label="Text input" suggestions={country} clearable />
313
- </ExampleContainer>
314
- );
315
-
316
- const ActivedOptionAutosuggest = () => (
317
- <ExampleContainer expanded pseudoState="pseudo-active">
318
- <Title title="Actived option" theme="light" level={4} />
319
- <DxcTextInput label="Text input" suggestions={country} clearable />
320
- </ExampleContainer>
321
- );
425
+ const AutosuggestListbox = () => {
426
+ const colorsTheme: any = useTheme();
322
427
 
323
- const FocusedActionTextInputOnDark = () => (
324
- <BackgroundColorProvider color="#333333">
325
- <DarkContainer>
326
- <ExampleContainer expanded>
327
- <Title title="Focused action" theme="dark" level={4} />
328
- <DxcTextInput label="Text input" action={action} clearable />
329
- </ExampleContainer>
330
- </DarkContainer>
331
- </BackgroundColorProvider>
332
- );
333
-
334
- const ActivedActionTextInputOnDark = () => (
335
- <BackgroundColorProvider color="#333333">
336
- <DarkContainer>
337
- <ExampleContainer pseudoState="pseudo-active" expanded>
338
- <Title title="Actived action" theme="dark" level={4} />
339
- <DxcTextInput label="Text input" action={action} clearable />
340
- </ExampleContainer>
341
- </DarkContainer>
342
- </BackgroundColorProvider>
343
- );
344
-
345
- const ShowOptionsAutosuggestOnDark = () => (
346
- <BackgroundColorProvider color="#333333">
347
- <DarkContainer>
348
- <ExampleContainer expanded>
349
- <Title title="Show options" theme="dark" level={4} />
350
- <DxcTextInput label="Text input" suggestions={countries} clearable />
351
- </ExampleContainer>
352
- </DarkContainer>
353
- </BackgroundColorProvider>
354
- );
355
-
356
- const HoveredActionAutosuggestOnDark = () => (
357
- <BackgroundColorProvider color="#333333">
358
- <DarkContainer>
359
- <ExampleContainer expanded pseudoState="pseudo-hover">
360
- <Title title="Hovered option" theme="dark" level={4} />
361
- <DxcTextInput label="Text input" suggestions={country} clearable />
428
+ return (
429
+ <ThemeProvider theme={colorsTheme.textInput}>
430
+ <ExampleContainer>
431
+ <Title title="Autosuggest listbox" theme="light" level={2} />
432
+ <ExampleContainer>
433
+ <Title
434
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
435
+ theme="light"
436
+ level={3}
437
+ />
438
+ <div
439
+ style={{
440
+ display: "flex",
441
+ flexDirection: "column",
442
+ gap: "20px",
443
+ height: "150px",
444
+ width: "500px",
445
+ marginBottom: "250px",
446
+ padding: "20px",
447
+ border: "1px solid black",
448
+ borderRadius: "4px",
449
+ overflow: "auto",
450
+ zIndex: "1300",
451
+ position: "relative",
452
+ }}
453
+ >
454
+ <DxcTextInput
455
+ label="Label"
456
+ suggestions={countries}
457
+ optional
458
+ placeholder="Choose an option"
459
+ size="fillParent"
460
+ />
461
+ <button style={{ zIndex: "1", width: "100px" }}>Submit</button>
462
+ </div>
463
+ </ExampleContainer>
464
+ <Title title="Listbox suggestion states" theme="light" level={3} />
465
+ <ExampleContainer pseudoState="pseudo-hover">
466
+ <Title title="Hovered suggestion" theme="light" level={4} />
467
+ <Suggestions
468
+ id="x"
469
+ value=""
470
+ suggestions={country}
471
+ visualFocusIndex={-1}
472
+ highlightedSuggestions={false}
473
+ searchHasErrors={false}
474
+ isSearching={false}
475
+ suggestionOnClick={() => {}}
476
+ getTextInputWidth={() => 350}
477
+ />
478
+ </ExampleContainer>
479
+ <ExampleContainer pseudoState="pseudo-active">
480
+ <Title title="Active suggestion" theme="light" level={4} />
481
+ <Suggestions
482
+ id="x"
483
+ value=""
484
+ suggestions={country}
485
+ visualFocusIndex={-1}
486
+ highlightedSuggestions={false}
487
+ searchHasErrors={false}
488
+ isSearching={false}
489
+ suggestionOnClick={(suggestion) => {}}
490
+ getTextInputWidth={() => 350}
491
+ />
492
+ </ExampleContainer>
493
+ <ExampleContainer>
494
+ <Title title="Focused suggestion" theme="light" level={4} />
495
+ <Suggestions
496
+ id="x"
497
+ value=""
498
+ suggestions={country}
499
+ visualFocusIndex={0}
500
+ highlightedSuggestions={false}
501
+ searchHasErrors={false}
502
+ isSearching={false}
503
+ suggestionOnClick={(suggestion) => {}}
504
+ getTextInputWidth={() => 350}
505
+ />
506
+ </ExampleContainer>
507
+ <ExampleContainer>
508
+ <Title title="Highlighted suggestion" theme="light" level={4} />
509
+ <Suggestions
510
+ id="x"
511
+ value="Afgh"
512
+ suggestions={country}
513
+ visualFocusIndex={-1}
514
+ highlightedSuggestions={true}
515
+ searchHasErrors={false}
516
+ isSearching={false}
517
+ suggestionOnClick={(suggestion) => {}}
518
+ getTextInputWidth={() => 350}
519
+ />
520
+ </ExampleContainer>
362
521
  </ExampleContainer>
363
- </DarkContainer>
364
- </BackgroundColorProvider>
365
- );
366
-
367
- const FocusedOptionAutosuggestOnDark = () => (
368
- <BackgroundColorProvider color="#333333">
369
- <DarkContainer>
370
- <ExampleContainer expanded>
371
- <Title title="Focused option" theme="dark" level={4} />
372
- <DxcTextInput label="Text input" suggestions={country} clearable />
522
+ <ExampleContainer>
523
+ <Title title="Autosuggest Error" theme="light" level={3} />
524
+ <Suggestions
525
+ id="x"
526
+ value=""
527
+ suggestions={country}
528
+ visualFocusIndex={-1}
529
+ highlightedSuggestions={false}
530
+ searchHasErrors={true}
531
+ isSearching={false}
532
+ suggestionOnClick={(suggestion) => {}}
533
+ getTextInputWidth={() => 350}
534
+ />
373
535
  </ExampleContainer>
374
- </DarkContainer>
375
- </BackgroundColorProvider>
376
- );
377
-
378
- const ActivedOptionAutosuggestOnDark = () => (
379
- <BackgroundColorProvider color="#333333">
380
- <DarkContainer>
381
- <ExampleContainer expanded pseudoState="pseudo-active">
382
- <Title title="Actived option" theme="dark" level={4} />
383
- <DxcTextInput label="Text input" suggestions={country} clearable />
536
+ <ExampleContainer>
537
+ <Title title="Autosuggest Searching message" theme="light" level={3} />
538
+ <Suggestions
539
+ id="x"
540
+ value=""
541
+ suggestions={country}
542
+ visualFocusIndex={-1}
543
+ highlightedSuggestions={false}
544
+ searchHasErrors={false}
545
+ isSearching={true}
546
+ suggestionOnClick={(suggestion) => {}}
547
+ getTextInputWidth={() => 350}
548
+ />
384
549
  </ExampleContainer>
385
- </DarkContainer>
386
- </BackgroundColorProvider>
387
- );
388
-
389
- export const FocusedAction = FocusedActionTextInput.bind({});
390
- FocusedAction.play = async ({ canvasElement }) => {
391
- const canvas = within(canvasElement);
392
- const action = canvas.getByRole("button");
393
- await action.focus();
394
- };
395
-
396
- export const ActivedAction = ActivedActionTextInput.bind({});
397
- ActivedAction.play = async ({ canvasElement }) => {
398
- const canvas = within(canvasElement);
399
- const action = canvas.getByRole("button");
400
- await userEvent.click(action);
401
- };
402
-
403
- export const ShowOptions = ShowOptionsAutosuggest.bind({});
404
- ShowOptions.play = async ({ canvasElement }) => {
405
- const canvas = within(canvasElement);
406
- const autosuggest = canvas.getByRole("combobox");
407
- await userEvent.click(autosuggest);
550
+ </ThemeProvider>
551
+ );
408
552
  };
409
553
 
410
- export const HoveredOption = HoveredOptionAutosuggest.bind({});
411
- HoveredOption.play = async ({ canvasElement }) => {
412
- const canvas = within(canvasElement);
413
- const autosuggest = canvas.getByRole("combobox");
414
- await userEvent.click(autosuggest);
415
- };
416
-
417
- export const FocusedOption = FocusedOptionAutosuggest.bind({});
418
- FocusedOption.play = async ({ canvasElement }) => {
419
- const canvas = within(canvasElement);
420
- const autosuggest = canvas.getByRole("combobox");
421
- await userEvent.click(autosuggest);
422
- fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
423
- };
424
-
425
- export const ActivedOption = ActivedOptionAutosuggest.bind({});
426
- ActivedOption.play = async ({ canvasElement }) => {
427
- const canvas = within(canvasElement);
428
- const autosuggest = canvas.getByRole("combobox");
429
- await userEvent.click(autosuggest);
430
- };
431
-
432
- export const FocusedActionOnDark = FocusedActionTextInputOnDark.bind({});
433
- FocusedActionOnDark.play = async ({ canvasElement }) => {
434
- const canvas = within(canvasElement);
435
- const action = canvas.getByRole("button");
436
- await action.focus();
437
- };
438
-
439
- export const ActivedActionOnDark = ActivedActionTextInputOnDark.bind({});
440
- ActivedActionOnDark.play = async ({ canvasElement }) => {
441
- const canvas = within(canvasElement);
442
- const action = canvas.getByRole("button");
443
- await userEvent.click(action);
444
- };
554
+ const DarkAutosuggestListbox = () => {
555
+ const colorsTheme: any = useTheme();
445
556
 
446
- export const ShowOptionsOnDark = ShowOptionsAutosuggestOnDark.bind({});
447
- ShowOptionsOnDark.play = async ({ canvasElement }) => {
448
- const canvas = within(canvasElement);
449
- const autosuggest = canvas.getByRole("combobox");
450
- await userEvent.click(autosuggest);
451
- };
452
-
453
- export const HoveredActionOnDark = HoveredActionAutosuggestOnDark.bind({});
454
- HoveredActionOnDark.play = async ({ canvasElement }) => {
455
- const canvas = within(canvasElement);
456
- const autosuggest = canvas.getByRole("combobox");
457
- await userEvent.click(autosuggest);
557
+ return (
558
+ <ThemeProvider theme={colorsTheme.textInput}>
559
+ <BackgroundColorProvider color="#333333">
560
+ <DarkContainer>
561
+ <Title title="Dark theme" theme="dark" level={2} />
562
+ <ExampleContainer>
563
+ <Title title="Default with opened suggestions" theme="dark" level={3} />
564
+ <DxcFlex direction="column" gap="5rem">
565
+ <DxcTextInput label="Label" suggestions={countries} optional placeholder="Choose an option" />
566
+ <DxcCheckbox
567
+ label="You understand the selection and give your consent"
568
+ onChange={() => {}}
569
+ labelPosition="after"
570
+ />
571
+ <DxcButton label="Submit" onClick={() => {}} size="medium" margin={{ bottom: "xxlarge" }} />
572
+ </DxcFlex>
573
+ </ExampleContainer>
574
+ <ExampleContainer>
575
+ <Title title="Autosuggest Error" theme="dark" level={3} />
576
+ <div style={{ height: "100px" }}>
577
+ <Suggestions
578
+ id="x"
579
+ value=""
580
+ suggestions={country}
581
+ visualFocusIndex={-1}
582
+ highlightedSuggestions={false}
583
+ searchHasErrors={true}
584
+ isSearching={false}
585
+ suggestionOnClick={(suggestion) => {}}
586
+ getTextInputWidth={() => 350}
587
+ />
588
+ </div>
589
+ </ExampleContainer>
590
+ </DarkContainer>
591
+ </BackgroundColorProvider>
592
+ </ThemeProvider>
593
+ );
458
594
  };
459
595
 
460
- export const FocusedOptionOnDark = FocusedOptionAutosuggestOnDark.bind({});
461
- FocusedOptionOnDark.play = async ({ canvasElement }) => {
596
+ export const AutosuggestListboxStates = AutosuggestListbox.bind({});
597
+ AutosuggestListboxStates.play = async ({ canvasElement }) => {
462
598
  const canvas = within(canvasElement);
463
- const autosuggest = canvas.getByRole("combobox");
464
- await userEvent.click(autosuggest);
465
- fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
599
+ const select = canvas.getByRole("combobox");
600
+ await userEvent.click(select);
466
601
  };
467
602
 
468
- export const ActivedOptionOnDark = ActivedOptionAutosuggestOnDark.bind({});
469
- ActivedOptionOnDark.play = async ({ canvasElement }) => {
603
+ export const AutosuggestListboxOnDark = DarkAutosuggestListbox.bind({});
604
+ AutosuggestListboxOnDark.play = async ({ canvasElement }) => {
470
605
  const canvas = within(canvasElement);
471
- const autosuggest = canvas.getByRole("combobox");
472
- await userEvent.click(autosuggest);
606
+ const select = canvas.getByRole("combobox");
607
+ await userEvent.click(select);
473
608
  };