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

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 (205) hide show
  1. package/HalstackContext.js +7 -11
  2. package/accordion/Accordion.js +117 -104
  3. package/accordion/Accordion.stories.tsx +54 -15
  4. package/accordion/Accordion.test.js +9 -10
  5. package/accordion/types.d.ts +5 -4
  6. package/accordion-group/AccordionGroup.js +2 -21
  7. package/accordion-group/AccordionGroup.stories.tsx +27 -1
  8. package/accordion-group/AccordionGroup.test.js +20 -45
  9. package/accordion-group/types.d.ts +10 -3
  10. package/alert/Alert.js +1 -1
  11. package/badge/Badge.d.ts +1 -1
  12. package/badge/Badge.js +5 -3
  13. package/badge/types.d.ts +1 -0
  14. package/bleed/Bleed.js +1 -34
  15. package/bleed/Bleed.stories.tsx +94 -95
  16. package/bleed/types.d.ts +1 -1
  17. package/box/Box.js +23 -33
  18. package/box/types.d.ts +1 -0
  19. package/bulleted-list/BulletedList.d.ts +7 -0
  20. package/bulleted-list/BulletedList.js +123 -0
  21. package/bulleted-list/BulletedList.stories.tsx +200 -0
  22. package/bulleted-list/types.d.ts +11 -0
  23. package/{list → bulleted-list}/types.js +0 -0
  24. package/button/Button.js +50 -70
  25. package/button/Button.stories.tsx +61 -1
  26. package/button/types.d.ts +7 -7
  27. package/card/Card.js +34 -36
  28. package/card/types.d.ts +1 -0
  29. package/checkbox/Checkbox.d.ts +2 -2
  30. package/checkbox/Checkbox.js +92 -99
  31. package/checkbox/Checkbox.stories.tsx +79 -59
  32. package/checkbox/Checkbox.test.js +93 -16
  33. package/checkbox/types.d.ts +6 -2
  34. package/chip/Chip.js +11 -23
  35. package/chip/Chip.stories.tsx +41 -9
  36. package/chip/types.d.ts +1 -1
  37. package/common/variables.js +186 -158
  38. package/date-input/Calendar.d.ts +4 -0
  39. package/date-input/Calendar.js +258 -0
  40. package/date-input/DateInput.js +77 -222
  41. package/date-input/DateInput.stories.tsx +30 -17
  42. package/date-input/DateInput.test.js +411 -138
  43. package/date-input/DatePicker.d.ts +4 -0
  44. package/date-input/DatePicker.js +160 -0
  45. package/date-input/YearPicker.d.ts +4 -0
  46. package/date-input/YearPicker.js +115 -0
  47. package/date-input/types.d.ts +53 -0
  48. package/dialog/Dialog.js +52 -28
  49. package/dialog/Dialog.stories.tsx +57 -2
  50. package/dialog/Dialog.test.js +34 -4
  51. package/dialog/types.d.ts +3 -2
  52. package/dropdown/Dropdown.d.ts +1 -1
  53. package/dropdown/Dropdown.js +247 -249
  54. package/dropdown/Dropdown.stories.tsx +135 -64
  55. package/dropdown/Dropdown.test.js +504 -108
  56. package/dropdown/DropdownMenu.d.ts +4 -0
  57. package/dropdown/DropdownMenu.js +80 -0
  58. package/dropdown/DropdownMenuItem.d.ts +4 -0
  59. package/dropdown/DropdownMenuItem.js +92 -0
  60. package/dropdown/types.d.ts +25 -5
  61. package/file-input/FileInput.d.ts +2 -2
  62. package/file-input/FileInput.js +177 -219
  63. package/file-input/FileInput.stories.tsx +38 -10
  64. package/file-input/FileInput.test.js +53 -12
  65. package/file-input/FileItem.d.ts +4 -14
  66. package/file-input/FileItem.js +38 -63
  67. package/file-input/types.d.ts +17 -0
  68. package/flex/Flex.d.ts +4 -0
  69. package/flex/Flex.js +69 -0
  70. package/flex/Flex.stories.tsx +103 -0
  71. package/flex/types.d.ts +32 -0
  72. package/{radio → flex}/types.js +0 -0
  73. package/footer/Footer.stories.tsx +8 -1
  74. package/footer/Icons.js +1 -1
  75. package/footer/types.d.ts +2 -1
  76. package/header/Header.js +74 -72
  77. package/header/Header.stories.tsx +4 -4
  78. package/header/Icons.js +2 -2
  79. package/header/types.d.ts +3 -2
  80. package/inset/Inset.js +1 -34
  81. package/inset/Inset.stories.tsx +36 -36
  82. package/inset/types.d.ts +1 -1
  83. package/layout/ApplicationLayout.d.ts +16 -6
  84. package/layout/ApplicationLayout.js +70 -117
  85. package/layout/ApplicationLayout.stories.tsx +84 -93
  86. package/layout/Icons.d.ts +5 -0
  87. package/layout/Icons.js +13 -2
  88. package/layout/SidenavContext.d.ts +5 -0
  89. package/layout/SidenavContext.js +19 -0
  90. package/layout/types.d.ts +18 -33
  91. package/link/Link.d.ts +2 -2
  92. package/link/Link.js +24 -50
  93. package/link/Link.stories.tsx +13 -6
  94. package/link/types.d.ts +3 -4
  95. package/main.d.ts +6 -9
  96. package/main.js +32 -56
  97. package/number-input/NumberInput.test.js +43 -7
  98. package/package.json +16 -20
  99. package/paginator/Icons.d.ts +5 -0
  100. package/paginator/Icons.js +16 -28
  101. package/paginator/Paginator.js +6 -12
  102. package/paginator/Paginator.test.js +43 -1
  103. package/paragraph/Paragraph.d.ts +6 -0
  104. package/paragraph/Paragraph.js +38 -0
  105. package/paragraph/Paragraph.stories.tsx +44 -0
  106. package/password-input/PasswordInput.test.js +13 -12
  107. package/progress-bar/ProgressBar.d.ts +2 -2
  108. package/progress-bar/ProgressBar.js +56 -50
  109. package/progress-bar/ProgressBar.stories.jsx +3 -1
  110. package/progress-bar/ProgressBar.test.js +67 -22
  111. package/progress-bar/types.d.ts +3 -4
  112. package/quick-nav/QuickNav.js +25 -20
  113. package/quick-nav/QuickNav.stories.tsx +131 -26
  114. package/radio-group/Radio.d.ts +1 -1
  115. package/radio-group/Radio.js +43 -28
  116. package/radio-group/RadioGroup.js +23 -22
  117. package/radio-group/RadioGroup.stories.tsx +1 -0
  118. package/radio-group/RadioGroup.test.js +123 -96
  119. package/radio-group/types.d.ts +2 -2
  120. package/resultsetTable/Icons.d.ts +7 -0
  121. package/resultsetTable/Icons.js +51 -0
  122. package/resultsetTable/ResultsetTable.js +48 -107
  123. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  124. package/resultsetTable/ResultsetTable.test.js +65 -41
  125. package/resultsetTable/types.d.ts +2 -2
  126. package/select/Listbox.d.ts +1 -1
  127. package/select/Listbox.js +53 -7
  128. package/select/Option.js +8 -10
  129. package/select/Select.js +43 -43
  130. package/select/Select.stories.tsx +225 -136
  131. package/select/Select.test.js +363 -250
  132. package/select/types.d.ts +2 -5
  133. package/sidenav/Sidenav.d.ts +6 -5
  134. package/sidenav/Sidenav.js +182 -52
  135. package/sidenav/Sidenav.stories.tsx +163 -156
  136. package/sidenav/Sidenav.test.js +25 -37
  137. package/sidenav/types.d.ts +50 -27
  138. package/slider/Slider.d.ts +2 -2
  139. package/slider/Slider.js +120 -95
  140. package/slider/Slider.stories.tsx +7 -1
  141. package/slider/Slider.test.js +121 -21
  142. package/slider/types.d.ts +6 -2
  143. package/spinner/Spinner.js +2 -2
  144. package/switch/Switch.d.ts +2 -2
  145. package/switch/Switch.js +135 -68
  146. package/switch/Switch.stories.tsx +8 -30
  147. package/switch/Switch.test.js +144 -17
  148. package/switch/types.d.ts +6 -2
  149. package/table/Table.js +1 -1
  150. package/table/Table.test.js +1 -1
  151. package/tabs/Tab.d.ts +4 -0
  152. package/tabs/Tab.js +133 -0
  153. package/tabs/Tabs.js +360 -104
  154. package/tabs/Tabs.stories.tsx +81 -5
  155. package/tabs/Tabs.test.js +217 -6
  156. package/tabs/types.d.ts +15 -5
  157. package/tabs-nav/NavTabs.d.ts +8 -0
  158. package/tabs-nav/NavTabs.js +125 -0
  159. package/tabs-nav/NavTabs.stories.tsx +172 -0
  160. package/tabs-nav/NavTabs.test.js +82 -0
  161. package/tabs-nav/Tab.d.ts +4 -0
  162. package/tabs-nav/Tab.js +128 -0
  163. package/tabs-nav/types.d.ts +53 -0
  164. package/{row → tabs-nav}/types.js +0 -0
  165. package/tag/Tag.js +1 -1
  166. package/tag/types.d.ts +1 -1
  167. package/text-input/Icons.d.ts +8 -0
  168. package/text-input/Icons.js +60 -0
  169. package/text-input/Suggestion.js +38 -9
  170. package/text-input/Suggestions.d.ts +4 -0
  171. package/text-input/Suggestions.js +134 -0
  172. package/text-input/TextInput.js +195 -292
  173. package/text-input/TextInput.stories.tsx +211 -185
  174. package/text-input/TextInput.test.js +737 -725
  175. package/text-input/types.d.ts +22 -3
  176. package/toggle-group/types.d.ts +1 -1
  177. package/typography/Typography.d.ts +4 -0
  178. package/typography/Typography.js +131 -0
  179. package/typography/Typography.stories.tsx +198 -0
  180. package/typography/types.d.ts +18 -0
  181. package/{stack → typography}/types.js +0 -0
  182. package/wizard/Wizard.js +9 -16
  183. package/wizard/Wizard.stories.tsx +20 -1
  184. package/wizard/types.d.ts +5 -4
  185. package/common/RequiredComponent.js +0 -32
  186. package/list/List.d.ts +0 -4
  187. package/list/List.js +0 -47
  188. package/list/List.stories.tsx +0 -95
  189. package/list/types.d.ts +0 -7
  190. package/radio/Radio.d.ts +0 -4
  191. package/radio/Radio.js +0 -173
  192. package/radio/Radio.stories.tsx +0 -192
  193. package/radio/Radio.test.js +0 -71
  194. package/radio/types.d.ts +0 -54
  195. package/row/Row.d.ts +0 -3
  196. package/row/Row.js +0 -127
  197. package/row/Row.stories.tsx +0 -237
  198. package/row/types.d.ts +0 -28
  199. package/stack/Stack.d.ts +0 -3
  200. package/stack/Stack.js +0 -97
  201. package/stack/Stack.stories.tsx +0 -164
  202. package/stack/types.d.ts +0 -24
  203. package/text/Text.d.ts +0 -7
  204. package/text/Text.js +0 -30
  205. package/text/Text.stories.tsx +0 -19
@@ -3,21 +3,29 @@ import { userEvent, within } from "@storybook/testing-library";
3
3
  import DxcDropdown from "./Dropdown";
4
4
  import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
+ import DropdownMenu from "./DropdownMenu";
7
+ import DxcCheckbox from "../checkbox/Checkbox";
8
+ import DxcTextInput from "../text-input/TextInput";
9
+ import { Option } from "./types";
6
10
 
7
11
  export default {
8
12
  title: "Dropdown",
9
13
  component: DxcDropdown,
10
14
  };
11
15
 
16
+ const hamburguerIcon = (
17
+ <svg xmlns="http://www.w3.org/2000/svg" height="20" width="20">
18
+ <path d="M3 14.5V13h14v1.5Zm0-3.75v-1.5h14v1.5ZM3 7V5.5h14V7Z" />
19
+ </svg>
20
+ );
12
21
  const iconSVG = (
13
22
  <svg viewBox="0 0 24 24" fill="currentColor">
14
23
  <path d="M0 0h24v24H0z" fill="none" />
15
24
  <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
16
25
  </svg>
17
26
  );
18
-
19
27
  const iconSVGLarge = (
20
- <svg enable-background="new 0 0 24 24" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
28
+ <svg enableBackground="new 0 0 24 24" height="48" viewBox="0 0 24 24" width="48" fill="currentColor">
21
29
  <g>
22
30
  <path d="M0,0h24v24H0V0z" fill="none" />
23
31
  <path d="M0,0h24v24H0V0z" fill="none" />
@@ -27,11 +35,13 @@ const iconSVGLarge = (
27
35
  </g>
28
36
  </svg>
29
37
  );
38
+ const iconUrl = "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png";
39
+ const icons = [iconSVG, iconSVGLarge, iconUrl];
30
40
 
31
- const options: any = [
41
+ const defaultOptions: Option[] = [
32
42
  {
33
43
  value: "1",
34
- label: "Amazon with a very long text",
44
+ label: "Amazon",
35
45
  },
36
46
  {
37
47
  value: "2",
@@ -41,19 +51,35 @@ const options: any = [
41
51
  value: "3",
42
52
  label: "Apple",
43
53
  },
54
+ {
55
+ value: "4",
56
+ label: "Wallapop",
57
+ },
58
+ {
59
+ value: "5",
60
+ label: "Aliexpress",
61
+ },
44
62
  ];
45
-
46
- const option: any = [
63
+ const options: Option[] = [
47
64
  {
48
65
  value: "1",
66
+ label: "Amazon with a very long text",
67
+ },
68
+ {
69
+ value: "2",
49
70
  label: "Ebay",
50
71
  },
72
+ {
73
+ value: "3",
74
+ label: "Apple",
75
+ },
51
76
  ];
52
-
53
- const icons = [
54
- iconSVG,
55
- iconSVGLarge,
56
- "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png",
77
+ const optionWithIcon: Option[] = [
78
+ {
79
+ value: "1",
80
+ label: "Ebay",
81
+ icon: iconUrl,
82
+ },
57
83
  ];
58
84
 
59
85
  const optionsIcon: any = options.map((op, i) => ({ ...op, icon: icons[i] }));
@@ -68,7 +94,7 @@ export const Chromatic = () => (
68
94
  <Title title="Hovered" theme="light" level={4} />
69
95
  <DxcDropdown label="Hovered" options={options} onSelectOption={(value) => {}} />
70
96
  </ExampleContainer>
71
- <ExampleContainer pseudoState="pseudo-focus-visible">
97
+ <ExampleContainer pseudoState="pseudo-focus">
72
98
  <Title title="Focused" theme="light" level={4} />
73
99
  <DxcDropdown label="Focused" options={options} onSelectOption={(value) => {}} />
74
100
  </ExampleContainer>
@@ -103,9 +129,22 @@ export const Chromatic = () => (
103
129
  <DxcDropdown options={options} onSelectOption={(value) => {}} icon={iconSVG} />
104
130
  </ExampleContainer>
105
131
  <ExampleContainer>
106
- <Title title="Large icon" theme="light" level={4} />
132
+ <Title title="Only icon without caret" theme="light" level={4} />
133
+ <DxcDropdown options={options} onSelectOption={(value) => {}} icon={hamburguerIcon} caretHidden />
134
+ </ExampleContainer>
135
+ <ExampleContainer>
136
+ <Title title="Large icon (SVG)" theme="light" level={4} />
107
137
  <DxcDropdown label="Large icon" options={options} onSelectOption={(value) => {}} icon={iconSVGLarge} />
108
138
  </ExampleContainer>
139
+ <ExampleContainer>
140
+ <Title title="Large icon (image)" theme="light" level={4} />
141
+ <DxcDropdown
142
+ label="Large icon"
143
+ options={options}
144
+ onSelectOption={(value) => {}}
145
+ icon="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Hamburger_icon.svg/2048px-Hamburger_icon.svg.png"
146
+ />
147
+ </ExampleContainer>
109
148
  <ExampleContainer>
110
149
  <Title title="Disabled with icon" theme="light" level={4} />
111
150
  <DxcDropdown
@@ -191,59 +230,91 @@ export const Chromatic = () => (
191
230
  </>
192
231
  );
193
232
 
194
- const DropdownWithOptions = () => (
195
- <ExampleContainer expanded>
196
- <Title title="Options" theme="light" level={4} />
197
- <DxcDropdown label="Options with icon" options={optionsIcon} onSelectOption={(value) => {}} />
198
- </ExampleContainer>
199
- );
200
-
201
- const DropdownHoverOption = () => (
202
- <ExampleContainer pseudoState="pseudo-hover" expanded>
203
- <Title title="Hovered option" theme="light" level={4} />
204
- <DxcDropdown label="Hovered options" options={option} onSelectOption={(value) => {}} />
205
- </ExampleContainer>
206
- );
207
-
208
- const DropdownActiveOption = () => (
209
- <ExampleContainer pseudoState="pseudo-active" expanded>
210
- <Title title="Actived option" theme="light" level={4} />
211
- <DxcDropdown label="Actived options" options={option} onSelectOption={(value) => {}} />
212
- </ExampleContainer>
213
- );
214
-
215
- const DropdownWithOptionsIconAfter = () => (
216
- <ExampleContainer expanded>
217
- <Title title="Icon after options" theme="light" level={4} />
218
- <DxcDropdown
219
- label="Icon after options"
220
- options={optionsIcon}
221
- onSelectOption={(value) => {}}
222
- optionsIconPosition="after"
223
- />
224
- </ExampleContainer>
233
+ const DropdownListStates = () => (
234
+ <>
235
+ <Title title="Dropdown Menu" theme="light" level={2} />
236
+ <Title title="Default with opened menu" theme="light" level={3} />
237
+ <ExampleContainer>
238
+ <div style={{ display: "flex", gap: "30px", flexDirection: "column", marginBottom: "80px" }}>
239
+ <DxcDropdown label="Select a platform" options={defaultOptions} onSelectOption={(option) => {}} size="medium" />
240
+ <DxcTextInput label="Your name" onChange={() => {}} />
241
+ <DxcCheckbox
242
+ label="You understand the selection and give your consent"
243
+ onChange={() => {}}
244
+ labelPosition="after"
245
+ />
246
+ </div>
247
+ </ExampleContainer>
248
+ <Title title="Option states" theme="light" level={3} />
249
+ <ExampleContainer pseudoState="pseudo-hover">
250
+ <Title title="Hovered option" theme="light" level={4} />
251
+ <DropdownMenu
252
+ id="x"
253
+ dropdownTriggerId="dtx"
254
+ iconsPosition="before"
255
+ visualFocusIndex={-1}
256
+ menuItemOnClick={(value) => {}}
257
+ onKeyDown={(e) => {}}
258
+ options={optionWithIcon}
259
+ styles={{ width: 240 }}
260
+ />
261
+ </ExampleContainer>
262
+ <ExampleContainer pseudoState="pseudo-active">
263
+ <Title title="Active option" theme="light" level={4} />
264
+ <DropdownMenu
265
+ id="x"
266
+ dropdownTriggerId="dtx"
267
+ iconsPosition="before"
268
+ visualFocusIndex={-1}
269
+ menuItemOnClick={(value) => {}}
270
+ onKeyDown={(e) => {}}
271
+ options={optionWithIcon}
272
+ styles={{ width: 240 }}
273
+ />
274
+ </ExampleContainer>
275
+ <ExampleContainer>
276
+ <Title title="Focused option" theme="light" level={4} />
277
+ <DropdownMenu
278
+ id="x"
279
+ dropdownTriggerId="dtx"
280
+ iconsPosition="before"
281
+ visualFocusIndex={0}
282
+ menuItemOnClick={(value) => {}}
283
+ onKeyDown={(e) => {}}
284
+ options={options}
285
+ styles={{ width: 240 }}
286
+ />
287
+ </ExampleContainer>
288
+ <Title title="Icons" theme="light" level={3} />
289
+ <ExampleContainer>
290
+ <Title title="Before" theme="light" level={4} />
291
+ <DropdownMenu
292
+ id="x"
293
+ dropdownTriggerId="dtx"
294
+ iconsPosition="before"
295
+ visualFocusIndex={-1}
296
+ menuItemOnClick={(value) => {}}
297
+ onKeyDown={(e) => {}}
298
+ options={optionsIcon}
299
+ styles={{ width: 240 }}
300
+ />
301
+ <Title title="After" theme="light" level={4} />
302
+ <DropdownMenu
303
+ id="x"
304
+ dropdownTriggerId="dtx"
305
+ iconsPosition="after"
306
+ visualFocusIndex={-1}
307
+ menuItemOnClick={(value) => {}}
308
+ onKeyDown={(e) => {}}
309
+ options={optionsIcon}
310
+ styles={{ width: 240 }}
311
+ />
312
+ </ExampleContainer>
313
+ </>
225
314
  );
226
315
 
227
- export const DropdownOptions = DropdownWithOptions.bind({});
228
- DropdownOptions.play = async ({ canvasElement }) => {
229
- const canvas = within(canvasElement);
230
- await userEvent.click(canvas.getByRole("button"));
231
- };
232
-
233
- export const DropdownHoveredOption = DropdownHoverOption.bind({});
234
- DropdownHoveredOption.play = async ({ canvasElement }) => {
235
- const canvas = within(canvasElement);
236
- await userEvent.click(canvas.getByRole("button"));
237
- };
238
-
239
- export const DropdownActivedOption = DropdownActiveOption.bind({});
240
- DropdownActivedOption.play = async ({ canvasElement }) => {
241
- const canvas = within(canvasElement);
242
- await userEvent.click(canvas.getByRole("button"));
243
- };
244
-
245
- export const DropdownOptionsIconAfter = DropdownWithOptionsIconAfter.bind({});
246
- DropdownOptionsIconAfter.play = async ({ canvasElement }) => {
316
+ export const DropdownMenuStates = DropdownListStates.bind({});
317
+ DropdownMenuStates.play = async ({ canvasElement }) => {
247
318
  const canvas = within(canvasElement);
248
319
  await userEvent.click(canvas.getByRole("button"));
249
320
  };