@dxc-technology/halstack-react 0.0.0-59568e7 → 0.0.0-5a1e592

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 (283) 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 -80
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +110 -114
  8. package/accordion/Accordion.stories.tsx +105 -115
  9. package/accordion/Accordion.test.js +10 -11
  10. package/accordion/types.d.ts +1 -12
  11. package/accordion-group/AccordionGroup.d.ts +4 -3
  12. package/accordion-group/AccordionGroup.js +25 -65
  13. package/accordion-group/AccordionGroup.stories.tsx +93 -66
  14. package/accordion-group/AccordionGroup.test.js +27 -62
  15. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  16. package/accordion-group/AccordionGroupAccordion.js +43 -0
  17. package/accordion-group/types.d.ts +7 -12
  18. package/alert/Alert.js +5 -9
  19. package/alert/Alert.stories.tsx +28 -0
  20. package/alert/Alert.test.js +1 -1
  21. package/badge/Badge.d.ts +1 -1
  22. package/badge/Badge.js +5 -3
  23. package/badge/types.d.ts +1 -0
  24. package/bleed/Bleed.js +1 -34
  25. package/bleed/Bleed.stories.tsx +95 -95
  26. package/bleed/types.d.ts +1 -1
  27. package/box/Box.d.ts +1 -1
  28. package/box/Box.js +19 -48
  29. package/box/Box.stories.tsx +38 -51
  30. package/box/Box.test.js +1 -1
  31. package/box/types.d.ts +0 -11
  32. package/bulleted-list/BulletedList.d.ts +7 -0
  33. package/bulleted-list/BulletedList.js +125 -0
  34. package/bulleted-list/BulletedList.stories.tsx +206 -0
  35. package/bulleted-list/types.d.ts +38 -0
  36. package/button/Button.d.ts +1 -1
  37. package/button/Button.js +42 -72
  38. package/button/Button.stories.tsx +159 -8
  39. package/button/Button.test.js +12 -1
  40. package/button/types.d.ts +9 -5
  41. package/card/Card.d.ts +1 -1
  42. package/card/Card.js +43 -63
  43. package/card/Card.stories.tsx +12 -42
  44. package/card/Card.test.js +1 -1
  45. package/card/types.d.ts +1 -6
  46. package/checkbox/Checkbox.d.ts +2 -2
  47. package/checkbox/Checkbox.js +127 -115
  48. package/checkbox/Checkbox.stories.tsx +146 -58
  49. package/checkbox/Checkbox.test.js +168 -18
  50. package/checkbox/types.d.ts +8 -0
  51. package/chip/Chip.js +28 -49
  52. package/chip/Chip.stories.tsx +121 -26
  53. package/chip/Chip.test.js +3 -5
  54. package/chip/types.d.ts +1 -1
  55. package/common/OpenSans.css +68 -80
  56. package/common/coreTokens.d.ts +146 -0
  57. package/common/coreTokens.js +167 -0
  58. package/common/utils.d.ts +1 -0
  59. package/common/utils.js +4 -4
  60. package/common/variables.d.ts +1499 -0
  61. package/common/variables.js +1025 -1131
  62. package/date-input/Calendar.d.ts +4 -0
  63. package/date-input/Calendar.js +258 -0
  64. package/date-input/DateInput.js +138 -239
  65. package/date-input/DateInput.stories.tsx +209 -33
  66. package/date-input/DateInput.test.js +519 -149
  67. package/date-input/DatePicker.d.ts +4 -0
  68. package/date-input/DatePicker.js +146 -0
  69. package/date-input/Icons.d.ts +6 -0
  70. package/date-input/Icons.js +75 -0
  71. package/date-input/YearPicker.d.ts +4 -0
  72. package/date-input/YearPicker.js +126 -0
  73. package/date-input/types.d.ts +55 -0
  74. package/dialog/Dialog.d.ts +1 -1
  75. package/dialog/Dialog.js +72 -79
  76. package/dialog/Dialog.stories.tsx +154 -171
  77. package/dialog/Dialog.test.js +334 -5
  78. package/dialog/types.d.ts +0 -12
  79. package/dropdown/Dropdown.d.ts +1 -1
  80. package/dropdown/Dropdown.js +246 -249
  81. package/dropdown/Dropdown.stories.tsx +245 -56
  82. package/dropdown/Dropdown.test.js +507 -110
  83. package/dropdown/DropdownMenu.d.ts +4 -0
  84. package/dropdown/DropdownMenu.js +74 -0
  85. package/dropdown/DropdownMenuItem.d.ts +4 -0
  86. package/dropdown/DropdownMenuItem.js +79 -0
  87. package/dropdown/types.d.ts +23 -3
  88. package/file-input/FileInput.d.ts +2 -2
  89. package/file-input/FileInput.js +174 -220
  90. package/file-input/FileInput.stories.tsx +122 -11
  91. package/file-input/FileInput.test.js +14 -14
  92. package/file-input/FileItem.d.ts +4 -14
  93. package/file-input/FileItem.js +39 -63
  94. package/file-input/types.d.ts +18 -1
  95. package/flex/Flex.d.ts +4 -0
  96. package/flex/Flex.js +71 -0
  97. package/flex/Flex.stories.tsx +112 -0
  98. package/flex/types.d.ts +97 -0
  99. package/footer/Footer.d.ts +1 -1
  100. package/footer/Footer.js +44 -64
  101. package/footer/Footer.stories.tsx +41 -19
  102. package/footer/Footer.test.js +16 -26
  103. package/footer/Icons.js +1 -1
  104. package/footer/types.d.ts +11 -12
  105. package/grid/Grid.d.ts +7 -0
  106. package/grid/Grid.js +91 -0
  107. package/grid/Grid.stories.tsx +219 -0
  108. package/grid/types.d.ts +115 -0
  109. package/header/Header.d.ts +4 -3
  110. package/header/Header.js +83 -110
  111. package/header/Header.stories.tsx +118 -39
  112. package/header/Header.test.js +2 -2
  113. package/header/Icons.js +2 -2
  114. package/header/types.d.ts +0 -13
  115. package/heading/Heading.js +1 -1
  116. package/heading/Heading.test.js +1 -1
  117. package/image/Image.d.ts +4 -0
  118. package/image/Image.js +85 -0
  119. package/image/Image.stories.tsx +127 -0
  120. package/image/types.d.ts +72 -0
  121. package/inset/Inset.js +1 -34
  122. package/inset/Inset.stories.tsx +37 -36
  123. package/inset/types.d.ts +1 -1
  124. package/layout/ApplicationLayout.d.ts +16 -6
  125. package/layout/ApplicationLayout.js +81 -125
  126. package/layout/ApplicationLayout.stories.tsx +85 -94
  127. package/layout/Icons.d.ts +8 -0
  128. package/layout/Icons.js +52 -45
  129. package/layout/SidenavContext.d.ts +5 -0
  130. package/layout/SidenavContext.js +19 -0
  131. package/layout/types.d.ts +19 -35
  132. package/link/Link.d.ts +2 -2
  133. package/link/Link.js +26 -52
  134. package/link/Link.stories.tsx +73 -6
  135. package/link/Link.test.js +2 -4
  136. package/link/types.d.ts +5 -6
  137. package/main.d.ts +8 -9
  138. package/main.js +44 -52
  139. package/nav-tabs/NavTabs.d.ts +8 -0
  140. package/nav-tabs/NavTabs.js +122 -0
  141. package/nav-tabs/NavTabs.stories.tsx +274 -0
  142. package/nav-tabs/NavTabs.test.js +82 -0
  143. package/nav-tabs/Tab.d.ts +4 -0
  144. package/nav-tabs/Tab.js +146 -0
  145. package/nav-tabs/types.d.ts +52 -0
  146. package/number-input/NumberInput.d.ts +7 -0
  147. package/number-input/NumberInput.js +6 -4
  148. package/number-input/NumberInput.test.js +317 -98
  149. package/package.json +18 -22
  150. package/paginator/Icons.d.ts +5 -0
  151. package/paginator/Icons.js +16 -28
  152. package/paginator/Paginator.js +8 -16
  153. package/paginator/Paginator.stories.tsx +24 -0
  154. package/paginator/Paginator.test.js +91 -39
  155. package/paragraph/Paragraph.d.ts +5 -0
  156. package/paragraph/Paragraph.js +38 -0
  157. package/paragraph/Paragraph.stories.tsx +44 -0
  158. package/password-input/Icons.d.ts +6 -0
  159. package/password-input/Icons.js +39 -0
  160. package/password-input/PasswordInput.js +35 -82
  161. package/password-input/PasswordInput.stories.tsx +1 -0
  162. package/password-input/PasswordInput.test.js +34 -40
  163. package/progress-bar/ProgressBar.js +60 -54
  164. package/progress-bar/ProgressBar.stories.jsx +38 -3
  165. package/progress-bar/ProgressBar.test.js +68 -23
  166. package/quick-nav/QuickNav.js +25 -20
  167. package/quick-nav/QuickNav.stories.tsx +145 -26
  168. package/radio-group/Radio.d.ts +1 -1
  169. package/radio-group/Radio.js +50 -35
  170. package/radio-group/RadioGroup.js +37 -38
  171. package/radio-group/RadioGroup.stories.tsx +132 -18
  172. package/radio-group/RadioGroup.test.js +153 -99
  173. package/radio-group/types.d.ts +5 -5
  174. package/resultsetTable/Icons.d.ts +7 -0
  175. package/resultsetTable/Icons.js +51 -0
  176. package/resultsetTable/ResultsetTable.js +49 -108
  177. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  178. package/resultsetTable/ResultsetTable.test.js +61 -42
  179. package/resultsetTable/types.d.ts +1 -1
  180. package/select/Listbox.d.ts +1 -1
  181. package/select/Listbox.js +33 -16
  182. package/select/Option.js +11 -24
  183. package/select/Select.js +92 -71
  184. package/select/Select.stories.tsx +516 -139
  185. package/select/Select.test.js +417 -309
  186. package/select/types.d.ts +3 -6
  187. package/sidenav/Icons.d.ts +7 -0
  188. package/sidenav/Icons.js +51 -0
  189. package/sidenav/Sidenav.d.ts +6 -5
  190. package/sidenav/Sidenav.js +146 -44
  191. package/sidenav/Sidenav.stories.tsx +251 -151
  192. package/sidenav/Sidenav.test.js +25 -37
  193. package/sidenav/types.d.ts +52 -26
  194. package/slider/Slider.d.ts +2 -2
  195. package/slider/Slider.js +121 -97
  196. package/slider/Slider.stories.tsx +64 -1
  197. package/slider/Slider.test.js +122 -22
  198. package/slider/types.d.ts +4 -0
  199. package/spinner/Spinner.js +17 -23
  200. package/spinner/Spinner.stories.jsx +53 -27
  201. package/spinner/Spinner.test.js +1 -1
  202. package/switch/Switch.d.ts +2 -2
  203. package/switch/Switch.js +137 -70
  204. package/switch/Switch.stories.tsx +41 -30
  205. package/switch/Switch.test.js +145 -18
  206. package/switch/types.d.ts +4 -0
  207. package/table/Table.js +3 -3
  208. package/table/Table.stories.jsx +80 -1
  209. package/table/Table.test.js +2 -2
  210. package/tabs/Tab.d.ts +4 -0
  211. package/tabs/Tab.js +132 -0
  212. package/tabs/Tabs.js +358 -108
  213. package/tabs/Tabs.stories.tsx +119 -5
  214. package/tabs/Tabs.test.js +220 -10
  215. package/tabs/types.d.ts +13 -3
  216. package/tag/Tag.js +8 -10
  217. package/tag/Tag.stories.tsx +14 -1
  218. package/tag/Tag.test.js +1 -1
  219. package/tag/types.d.ts +1 -1
  220. package/text-input/Icons.d.ts +8 -0
  221. package/text-input/Icons.js +60 -0
  222. package/text-input/Suggestion.js +40 -11
  223. package/text-input/Suggestions.d.ts +4 -0
  224. package/text-input/Suggestions.js +134 -0
  225. package/text-input/TextInput.js +240 -351
  226. package/text-input/TextInput.stories.tsx +319 -185
  227. package/text-input/TextInput.test.js +826 -726
  228. package/text-input/types.d.ts +26 -3
  229. package/textarea/Textarea.js +27 -26
  230. package/textarea/Textarea.stories.jsx +68 -1
  231. package/textarea/Textarea.test.js +61 -19
  232. package/textarea/types.d.ts +4 -0
  233. package/toggle-group/ToggleGroup.d.ts +2 -2
  234. package/toggle-group/ToggleGroup.js +85 -59
  235. package/toggle-group/ToggleGroup.stories.tsx +48 -3
  236. package/toggle-group/ToggleGroup.test.js +38 -24
  237. package/toggle-group/types.d.ts +23 -14
  238. package/typography/Typography.d.ts +4 -0
  239. package/typography/Typography.js +32 -0
  240. package/typography/Typography.stories.tsx +198 -0
  241. package/typography/types.d.ts +18 -0
  242. package/typography/types.js +5 -0
  243. package/useTheme.d.ts +1251 -1
  244. package/useTheme.js +1 -1
  245. package/useTranslatedLabels.d.ts +84 -1
  246. package/utils/BaseTypography.d.ts +21 -0
  247. package/utils/BaseTypography.js +108 -0
  248. package/utils/FocusLock.d.ts +13 -0
  249. package/utils/FocusLock.js +138 -0
  250. package/wizard/Wizard.js +10 -17
  251. package/wizard/Wizard.stories.tsx +40 -1
  252. package/wizard/Wizard.test.js +1 -1
  253. package/wizard/types.d.ts +3 -3
  254. package/card/ice-cream.jpg +0 -0
  255. package/common/RequiredComponent.js +0 -32
  256. package/list/List.d.ts +0 -4
  257. package/list/List.js +0 -47
  258. package/list/List.stories.tsx +0 -95
  259. package/list/types.d.ts +0 -7
  260. package/number-input/NumberInputContext.d.ts +0 -4
  261. package/number-input/NumberInputContext.js +0 -19
  262. package/number-input/numberInputContextTypes.d.ts +0 -19
  263. package/radio/Radio.d.ts +0 -4
  264. package/radio/Radio.js +0 -173
  265. package/radio/Radio.stories.tsx +0 -192
  266. package/radio/Radio.test.js +0 -71
  267. package/radio/types.d.ts +0 -54
  268. package/row/Row.d.ts +0 -3
  269. package/row/Row.js +0 -127
  270. package/row/Row.stories.tsx +0 -237
  271. package/row/types.d.ts +0 -28
  272. package/stack/Stack.d.ts +0 -3
  273. package/stack/Stack.js +0 -97
  274. package/stack/Stack.stories.tsx +0 -164
  275. package/stack/types.d.ts +0 -24
  276. package/text/Text.d.ts +0 -7
  277. package/text/Text.js +0 -30
  278. package/text/Text.stories.tsx +0 -19
  279. /package/{list → bulleted-list}/types.js +0 -0
  280. /package/{radio → flex}/types.js +0 -0
  281. /package/{row → grid}/types.js +0 -0
  282. /package/{stack → image}/types.js +0 -0
  283. /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
@@ -1,11 +1,17 @@
1
1
  import React from "react";
2
- import { userEvent, within, waitFor } from "@storybook/testing-library";
3
- import { fireEvent } from "@testing-library/react";
2
+ import { userEvent, within } from "@storybook/testing-library";
4
3
  import { BackgroundColorProvider } from "../BackgroundColorContext";
5
4
  import Title from "../../.storybook/components/Title";
6
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
7
6
  import DarkContainer from "../../.storybook/components/DarkSection";
8
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";
9
15
 
10
16
  export default {
11
17
  title: "Text input",
@@ -22,7 +28,7 @@ const action = {
22
28
  ),
23
29
  };
24
30
 
25
- const actionLargeIcon = {
31
+ const actionLargeIconSVG = {
26
32
  onClick: () => {},
27
33
  icon: (
28
34
  <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
@@ -32,6 +38,11 @@ const actionLargeIcon = {
32
38
  ),
33
39
  };
34
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
+
35
46
  const country = ["Afghanistan"];
36
47
  const countries = [
37
48
  "Afghanistan",
@@ -56,8 +67,16 @@ const countries = [
56
67
  "Dominica",
57
68
  "Denmark",
58
69
  "Djibouti",
70
+ "*",
59
71
  ];
60
72
 
73
+ const opinionatedTheme = {
74
+ textInput: {
75
+ fontColor: "#000000",
76
+ hoverBorderColor: "#a46ede",
77
+ },
78
+ };
79
+
61
80
  export const Chromatic = () => (
62
81
  <>
63
82
  <ExampleContainer pseudoState="pseudo-hover">
@@ -72,6 +91,14 @@ export const Chromatic = () => (
72
91
  <Title title="Hovered action" theme="light" level={4} />
73
92
  <DxcTextInput label="Text input" defaultValue="Text" clearable />
74
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>
75
102
  <ExampleContainer>
76
103
  <Title title="Without label" theme="light" level={4} />
77
104
  <DxcTextInput />
@@ -85,12 +112,21 @@ export const Chromatic = () => (
85
112
  <DxcTextInput label="Text input" clearable defaultValue="Text" helperText="Help message" optional />
86
113
  </ExampleContainer>
87
114
  <ExampleContainer>
88
- <Title title="Clearable and large icon action" theme="light" level={4} />
115
+ <Title title="Clearable and large icon action (SVG)" theme="light" level={4} />
89
116
  <DxcTextInput
90
117
  label="Text input"
91
118
  defaultValue="Text text text text text text text text text text"
92
119
  clearable
93
- 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}
94
130
  />
95
131
  </ExampleContainer>
96
132
  <ExampleContainer>
@@ -150,9 +186,48 @@ export const Chromatic = () => (
150
186
  action={action}
151
187
  />
152
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>
153
228
  <BackgroundColorProvider color="#333333">
154
229
  <DarkContainer>
155
- <Title title="Dark" theme="dark" level={2} />
230
+ <Title title="Dark theme" theme="dark" level={2} />
156
231
  <ExampleContainer pseudoState="pseudo-hover">
157
232
  <Title title="Hovered" theme="dark" level={4} />
158
233
  <DxcTextInput label="Text input" />
@@ -165,6 +240,14 @@ export const Chromatic = () => (
165
240
  <Title title="Hovered action" theme="dark" level={4} />
166
241
  <DxcTextInput label="Text input" defaultValue="Text" clearable />
167
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>
168
251
  <ExampleContainer>
169
252
  <Title title="Helper text, placeholder, optional and action" theme="dark" level={4} />
170
253
  <DxcTextInput
@@ -276,199 +359,250 @@ export const Chromatic = () => (
276
359
  <Title title="FillParent size" theme="light" level={4} />
277
360
  <DxcTextInput label="FillParent" size="fillParent" />
278
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>
279
422
  </>
280
423
  );
281
424
 
282
- const FocusedActionTextInput = () => (
283
- <ExampleContainer expanded>
284
- <Title title="Focused action" theme="light" level={4} />
285
- <DxcTextInput label="Text input" action={action} clearable />
286
- </ExampleContainer>
287
- );
288
-
289
- const ActivedActionTextInput = () => (
290
- <ExampleContainer pseudoState="pseudo-active" expanded>
291
- <Title title="Actived action" theme="light" level={4} />
292
- <DxcTextInput label="Text input" action={action} clearable />
293
- </ExampleContainer>
294
- );
295
-
296
- const ShowOptionsAutosuggest = () => (
297
- <ExampleContainer expanded>
298
- <Title title="Show options" theme="light" level={4} />
299
- <DxcTextInput label="Text input" suggestions={countries} clearable />
300
- </ExampleContainer>
301
- );
302
-
303
- const HoveredOptionAutosuggest = () => (
304
- <ExampleContainer expanded pseudoState="pseudo-hover">
305
- <Title title="Hovered option" theme="light" level={4} />
306
- <DxcTextInput label="Text input" suggestions={country} clearable />
307
- </ExampleContainer>
308
- );
309
-
310
- const FocusedOptionAutosuggest = () => (
311
- <ExampleContainer expanded>
312
- <Title title="Focused option" theme="light" level={4} />
313
- <DxcTextInput label="Text input" suggestions={country} clearable />
314
- </ExampleContainer>
315
- );
316
-
317
- const ActivedOptionAutosuggest = () => (
318
- <ExampleContainer expanded pseudoState="pseudo-active">
319
- <Title title="Actived option" theme="light" level={4} />
320
- <DxcTextInput label="Text input" suggestions={country} clearable />
321
- </ExampleContainer>
322
- );
425
+ const AutosuggestListbox = () => {
426
+ const colorsTheme: any = useTheme();
323
427
 
324
- const FocusedActionTextInputOnDark = () => (
325
- <BackgroundColorProvider color="#333333">
326
- <DarkContainer>
327
- <ExampleContainer expanded>
328
- <Title title="Focused action" theme="dark" level={4} />
329
- <DxcTextInput label="Text input" action={action} clearable />
330
- </ExampleContainer>
331
- </DarkContainer>
332
- </BackgroundColorProvider>
333
- );
334
-
335
- const ActivedActionTextInputOnDark = () => (
336
- <BackgroundColorProvider color="#333333">
337
- <DarkContainer>
338
- <ExampleContainer pseudoState="pseudo-active" expanded>
339
- <Title title="Actived action" theme="dark" level={4} />
340
- <DxcTextInput label="Text input" action={action} clearable />
341
- </ExampleContainer>
342
- </DarkContainer>
343
- </BackgroundColorProvider>
344
- );
345
-
346
- const ShowOptionsAutosuggestOnDark = () => (
347
- <BackgroundColorProvider color="#333333">
348
- <DarkContainer>
349
- <ExampleContainer expanded>
350
- <Title title="Show options" theme="dark" level={4} />
351
- <DxcTextInput label="Text input" suggestions={countries} clearable />
352
- </ExampleContainer>
353
- </DarkContainer>
354
- </BackgroundColorProvider>
355
- );
356
-
357
- const HoveredActionAutosuggestOnDark = () => (
358
- <BackgroundColorProvider color="#333333">
359
- <DarkContainer>
360
- <ExampleContainer expanded pseudoState="pseudo-hover">
361
- <Title title="Hovered option" theme="dark" level={4} />
362
- <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>
363
521
  </ExampleContainer>
364
- </DarkContainer>
365
- </BackgroundColorProvider>
366
- );
367
-
368
- const FocusedOptionAutosuggestOnDark = () => (
369
- <BackgroundColorProvider color="#333333">
370
- <DarkContainer>
371
- <ExampleContainer expanded>
372
- <Title title="Focused option" theme="dark" level={4} />
373
- <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
+ />
374
535
  </ExampleContainer>
375
- </DarkContainer>
376
- </BackgroundColorProvider>
377
- );
378
-
379
- const ActivedOptionAutosuggestOnDark = () => (
380
- <BackgroundColorProvider color="#333333">
381
- <DarkContainer>
382
- <ExampleContainer expanded pseudoState="pseudo-active">
383
- <Title title="Actived option" theme="dark" level={4} />
384
- <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
+ />
385
549
  </ExampleContainer>
386
- </DarkContainer>
387
- </BackgroundColorProvider>
388
- );
389
-
390
- export const FocusedAction = FocusedActionTextInput.bind({});
391
- FocusedAction.play = async ({ canvasElement }) => {
392
- const canvas = within(canvasElement);
393
- const action = canvas.getByRole("button");
394
- await action.focus();
395
- };
396
-
397
- export const ActivedAction = ActivedActionTextInput.bind({});
398
- ActivedAction.play = async ({ canvasElement }) => {
399
- const canvas = within(canvasElement);
400
- const action = canvas.getByRole("button");
401
- await userEvent.click(action);
402
- };
403
-
404
- export const ShowOptions = ShowOptionsAutosuggest.bind({});
405
- ShowOptions.play = async ({ canvasElement }) => {
406
- const canvas = within(canvasElement);
407
- const autosuggest = canvas.getByRole("combobox");
408
- await userEvent.click(autosuggest);
550
+ </ThemeProvider>
551
+ );
409
552
  };
410
553
 
411
- export const HoveredOption = HoveredOptionAutosuggest.bind({});
412
- HoveredOption.play = async ({ canvasElement }) => {
413
- const canvas = within(canvasElement);
414
- const autosuggest = canvas.getByRole("combobox");
415
- await userEvent.click(autosuggest);
416
- };
417
-
418
- export const FocusedOption = FocusedOptionAutosuggest.bind({});
419
- FocusedOption.play = async ({ canvasElement }) => {
420
- const canvas = within(canvasElement);
421
- const autosuggest = canvas.getByRole("combobox");
422
- await userEvent.click(autosuggest);
423
- fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
424
- };
425
-
426
- export const ActivedOption = ActivedOptionAutosuggest.bind({});
427
- ActivedOption.play = async ({ canvasElement }) => {
428
- const canvas = within(canvasElement);
429
- const autosuggest = canvas.getByRole("combobox");
430
- await userEvent.click(autosuggest);
431
- };
432
-
433
- export const FocusedActionOnDark = FocusedActionTextInputOnDark.bind({});
434
- FocusedActionOnDark.play = async ({ canvasElement }) => {
435
- const canvas = within(canvasElement);
436
- const action = canvas.getByRole("button");
437
- await action.focus();
438
- };
439
-
440
- export const ActivedActionOnDark = ActivedActionTextInputOnDark.bind({});
441
- ActivedActionOnDark.play = async ({ canvasElement }) => {
442
- const canvas = within(canvasElement);
443
- const action = canvas.getByRole("button");
444
- await userEvent.click(action);
445
- };
554
+ const DarkAutosuggestListbox = () => {
555
+ const colorsTheme: any = useTheme();
446
556
 
447
- export const ShowOptionsOnDark = ShowOptionsAutosuggestOnDark.bind({});
448
- ShowOptionsOnDark.play = async ({ canvasElement }) => {
449
- const canvas = within(canvasElement);
450
- const autosuggest = canvas.getByRole("combobox");
451
- await userEvent.click(autosuggest);
452
- };
453
-
454
- export const HoveredActionOnDark = HoveredActionAutosuggestOnDark.bind({});
455
- HoveredActionOnDark.play = async ({ canvasElement }) => {
456
- const canvas = within(canvasElement);
457
- const autosuggest = canvas.getByRole("combobox");
458
- 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
+ );
459
594
  };
460
595
 
461
- export const FocusedOptionOnDark = FocusedOptionAutosuggestOnDark.bind({});
462
- FocusedOptionOnDark.play = async ({ canvasElement }) => {
596
+ export const AutosuggestListboxStates = AutosuggestListbox.bind({});
597
+ AutosuggestListboxStates.play = async ({ canvasElement }) => {
463
598
  const canvas = within(canvasElement);
464
- const autosuggest = canvas.getByRole("combobox");
465
- await userEvent.click(autosuggest);
466
- fireEvent.keyDown(autosuggest, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
599
+ const select = canvas.getByRole("combobox");
600
+ await userEvent.click(select);
467
601
  };
468
602
 
469
- export const ActivedOptionOnDark = ActivedOptionAutosuggestOnDark.bind({});
470
- ActivedOptionOnDark.play = async ({ canvasElement }) => {
603
+ export const AutosuggestListboxOnDark = DarkAutosuggestListbox.bind({});
604
+ AutosuggestListboxOnDark.play = async ({ canvasElement }) => {
471
605
  const canvas = within(canvasElement);
472
- const autosuggest = canvas.getByRole("combobox");
473
- await userEvent.click(autosuggest);
606
+ const select = canvas.getByRole("combobox");
607
+ await userEvent.click(select);
474
608
  };