@dxc-technology/halstack-react 0.0.0-b4fde6b → 0.0.0-b5ec444

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 (257) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +4 -21
  3. package/HalstackContext.d.ts +51 -138
  4. package/HalstackContext.js +10 -35
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +24 -76
  8. package/accordion/Accordion.stories.tsx +1 -113
  9. package/accordion/Accordion.test.js +18 -33
  10. package/accordion/types.d.ts +5 -17
  11. package/accordion-group/AccordionGroup.js +15 -42
  12. package/accordion-group/AccordionGroup.stories.tsx +78 -77
  13. package/accordion-group/AccordionGroup.test.js +43 -71
  14. package/accordion-group/AccordionGroupAccordion.js +9 -21
  15. package/accordion-group/types.d.ts +6 -18
  16. package/action-icon/ActionIcon.d.ts +4 -0
  17. package/action-icon/ActionIcon.js +47 -0
  18. package/action-icon/ActionIcon.stories.tsx +41 -0
  19. package/action-icon/ActionIcon.test.js +64 -0
  20. package/action-icon/types.d.ts +26 -0
  21. package/alert/Alert.js +15 -50
  22. package/alert/Alert.test.js +28 -45
  23. package/alert/types.d.ts +5 -5
  24. package/badge/Badge.d.ts +1 -1
  25. package/badge/Badge.js +141 -43
  26. package/badge/Badge.stories.tsx +210 -0
  27. package/badge/Badge.test.js +30 -0
  28. package/badge/types.d.ts +52 -3
  29. package/bleed/Bleed.js +13 -21
  30. package/bleed/types.d.ts +2 -2
  31. package/box/Box.js +11 -33
  32. package/box/Box.test.js +1 -6
  33. package/box/types.d.ts +3 -3
  34. package/bulleted-list/BulletedList.js +18 -54
  35. package/bulleted-list/BulletedList.stories.tsx +1 -92
  36. package/bulleted-list/types.d.ts +5 -5
  37. package/button/Button.d.ts +1 -1
  38. package/button/Button.js +66 -99
  39. package/button/Button.stories.tsx +6 -87
  40. package/button/Button.test.js +19 -16
  41. package/button/types.d.ts +8 -4
  42. package/card/Card.d.ts +1 -1
  43. package/card/Card.js +39 -79
  44. package/card/Card.stories.tsx +0 -29
  45. package/card/Card.test.js +10 -21
  46. package/card/types.d.ts +6 -12
  47. package/checkbox/Checkbox.js +85 -120
  48. package/checkbox/Checkbox.stories.tsx +16 -54
  49. package/checkbox/Checkbox.test.js +107 -63
  50. package/checkbox/types.d.ts +8 -4
  51. package/chip/Chip.js +12 -31
  52. package/chip/Chip.stories.tsx +1 -1
  53. package/chip/Chip.test.js +15 -28
  54. package/chip/types.d.ts +4 -4
  55. package/common/coreTokens.d.ts +105 -14
  56. package/common/coreTokens.js +41 -24
  57. package/common/utils.js +2 -8
  58. package/common/variables.d.ts +51 -138
  59. package/common/variables.js +61 -155
  60. package/container/Container.d.ts +4 -0
  61. package/container/Container.js +194 -0
  62. package/container/Container.stories.tsx +214 -0
  63. package/container/types.d.ts +74 -0
  64. package/date-input/Calendar.js +15 -59
  65. package/date-input/DateInput.js +50 -96
  66. package/date-input/DateInput.stories.tsx +11 -30
  67. package/date-input/DateInput.test.js +674 -701
  68. package/date-input/DatePicker.js +11 -42
  69. package/date-input/Icons.d.ts +6 -6
  70. package/date-input/Icons.js +6 -23
  71. package/date-input/YearPicker.js +8 -34
  72. package/date-input/types.d.ts +27 -21
  73. package/dialog/Dialog.js +13 -40
  74. package/dialog/Dialog.stories.tsx +170 -0
  75. package/dialog/Dialog.test.js +125 -187
  76. package/dialog/types.d.ts +18 -13
  77. package/dropdown/Dropdown.js +48 -100
  78. package/dropdown/Dropdown.test.js +391 -378
  79. package/dropdown/DropdownMenu.js +8 -19
  80. package/dropdown/DropdownMenuItem.js +5 -17
  81. package/dropdown/types.d.ts +17 -19
  82. package/file-input/FileInput.js +180 -248
  83. package/file-input/FileInput.stories.tsx +1 -1
  84. package/file-input/FileInput.test.js +356 -354
  85. package/file-input/FileItem.js +14 -41
  86. package/file-input/types.d.ts +10 -10
  87. package/flex/Flex.js +25 -39
  88. package/flex/types.d.ts +6 -6
  89. package/footer/Footer.d.ts +1 -1
  90. package/footer/Footer.js +70 -102
  91. package/footer/Footer.stories.tsx +37 -6
  92. package/footer/Footer.test.js +21 -33
  93. package/footer/Icons.d.ts +3 -2
  94. package/footer/Icons.js +66 -7
  95. package/footer/types.d.ts +25 -21
  96. package/grid/Grid.d.ts +1 -1
  97. package/grid/Grid.js +2 -17
  98. package/grid/Grid.stories.tsx +38 -38
  99. package/grid/types.d.ts +10 -10
  100. package/header/Header.d.ts +2 -2
  101. package/header/Header.js +31 -114
  102. package/header/Header.stories.tsx +7 -71
  103. package/header/Header.test.js +12 -25
  104. package/header/Icons.d.ts +2 -2
  105. package/header/Icons.js +2 -7
  106. package/header/types.d.ts +5 -20
  107. package/heading/Heading.js +9 -31
  108. package/heading/Heading.test.js +70 -87
  109. package/heading/types.d.ts +7 -7
  110. package/image/Image.d.ts +4 -0
  111. package/image/Image.js +70 -0
  112. package/image/Image.stories.tsx +127 -0
  113. package/image/types.d.ts +72 -0
  114. package/image/types.js +5 -0
  115. package/inset/Inset.js +13 -21
  116. package/inset/types.d.ts +2 -2
  117. package/layout/ApplicationLayout.d.ts +3 -3
  118. package/layout/ApplicationLayout.js +28 -65
  119. package/layout/ApplicationLayout.stories.tsx +1 -1
  120. package/layout/Icons.d.ts +8 -5
  121. package/layout/Icons.js +51 -59
  122. package/layout/SidenavContext.d.ts +1 -1
  123. package/layout/SidenavContext.js +3 -9
  124. package/layout/types.d.ts +3 -3
  125. package/link/Link.js +21 -42
  126. package/link/Link.test.js +23 -41
  127. package/link/types.d.ts +14 -14
  128. package/main.d.ts +6 -4
  129. package/main.js +25 -59
  130. package/nav-tabs/NavTabs.js +17 -46
  131. package/nav-tabs/NavTabs.stories.tsx +7 -5
  132. package/nav-tabs/NavTabs.test.js +38 -44
  133. package/nav-tabs/Tab.js +22 -50
  134. package/nav-tabs/types.d.ts +9 -9
  135. package/number-input/NumberInput.d.ts +7 -0
  136. package/number-input/NumberInput.js +47 -37
  137. package/number-input/NumberInput.stories.tsx +42 -26
  138. package/number-input/NumberInput.test.js +859 -412
  139. package/number-input/types.d.ts +11 -5
  140. package/package.json +30 -28
  141. package/paginator/Icons.d.ts +5 -5
  142. package/paginator/Icons.js +5 -19
  143. package/paginator/Paginator.js +15 -43
  144. package/paginator/Paginator.test.js +224 -207
  145. package/paginator/types.d.ts +3 -3
  146. package/paragraph/Paragraph.js +3 -19
  147. package/paragraph/Paragraph.stories.tsx +0 -17
  148. package/password-input/Icons.d.ts +6 -0
  149. package/password-input/Icons.js +35 -0
  150. package/password-input/PasswordInput.js +57 -126
  151. package/password-input/PasswordInput.stories.tsx +1 -33
  152. package/password-input/PasswordInput.test.js +157 -140
  153. package/password-input/types.d.ts +8 -7
  154. package/progress-bar/ProgressBar.js +21 -53
  155. package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
  156. package/progress-bar/ProgressBar.test.js +35 -52
  157. package/progress-bar/types.d.ts +3 -3
  158. package/quick-nav/QuickNav.js +4 -27
  159. package/quick-nav/QuickNav.stories.tsx +1 -1
  160. package/quick-nav/types.d.ts +10 -10
  161. package/radio-group/Radio.d.ts +1 -1
  162. package/radio-group/Radio.js +22 -54
  163. package/radio-group/RadioGroup.js +37 -83
  164. package/radio-group/RadioGroup.stories.tsx +10 -10
  165. package/radio-group/RadioGroup.test.js +504 -470
  166. package/radio-group/types.d.ts +8 -8
  167. package/resultset-table/Icons.d.ts +7 -0
  168. package/{resultsetTable → resultset-table}/Icons.js +1 -5
  169. package/resultset-table/ResultsetTable.d.ts +7 -0
  170. package/{resultsetTable → resultset-table}/ResultsetTable.js +36 -64
  171. package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +102 -5
  172. package/{resultsetTable → resultset-table}/ResultsetTable.test.js +138 -92
  173. package/{resultsetTable → resultset-table}/types.d.ts +13 -7
  174. package/resultset-table/types.js +5 -0
  175. package/select/Icons.d.ts +7 -7
  176. package/select/Icons.js +1 -5
  177. package/select/Listbox.js +13 -39
  178. package/select/Option.js +17 -27
  179. package/select/Select.js +87 -163
  180. package/select/Select.stories.tsx +3 -3
  181. package/select/Select.test.js +1946 -1804
  182. package/select/types.d.ts +14 -15
  183. package/sidenav/Icons.d.ts +4 -4
  184. package/sidenav/Icons.js +1 -5
  185. package/sidenav/Sidenav.js +26 -68
  186. package/sidenav/Sidenav.test.js +3 -10
  187. package/sidenav/types.d.ts +18 -18
  188. package/slider/Slider.js +68 -125
  189. package/slider/Slider.test.js +107 -103
  190. package/slider/types.d.ts +4 -4
  191. package/spinner/Spinner.js +16 -54
  192. package/spinner/Spinner.test.js +25 -34
  193. package/spinner/types.d.ts +3 -3
  194. package/status-light/StatusLight.d.ts +4 -0
  195. package/status-light/StatusLight.js +51 -0
  196. package/status-light/StatusLight.stories.tsx +74 -0
  197. package/status-light/StatusLight.test.js +25 -0
  198. package/status-light/types.d.ts +17 -0
  199. package/status-light/types.js +5 -0
  200. package/switch/Switch.js +49 -97
  201. package/switch/Switch.stories.tsx +0 -34
  202. package/switch/Switch.test.js +51 -96
  203. package/switch/types.d.ts +4 -4
  204. package/table/ActionsCell.d.ts +4 -0
  205. package/table/ActionsCell.js +68 -0
  206. package/table/DropdownTheme.js +62 -0
  207. package/table/Table.d.ts +4 -1
  208. package/table/Table.js +24 -30
  209. package/table/{Table.stories.jsx → Table.stories.tsx} +304 -2
  210. package/table/Table.test.js +93 -6
  211. package/table/types.d.ts +45 -6
  212. package/tabs/Tab.js +17 -33
  213. package/tabs/Tabs.js +52 -129
  214. package/tabs/Tabs.stories.tsx +1 -1
  215. package/tabs/Tabs.test.js +62 -118
  216. package/tabs/types.d.ts +19 -19
  217. package/tag/Tag.js +21 -51
  218. package/tag/Tag.test.js +19 -30
  219. package/tag/types.d.ts +7 -7
  220. package/text-input/Icons.d.ts +5 -5
  221. package/text-input/Icons.js +1 -5
  222. package/text-input/Suggestion.js +9 -26
  223. package/text-input/Suggestions.d.ts +1 -1
  224. package/text-input/Suggestions.js +15 -65
  225. package/text-input/TextInput.js +218 -326
  226. package/text-input/TextInput.stories.tsx +48 -152
  227. package/text-input/TextInput.test.js +1227 -1194
  228. package/text-input/types.d.ts +25 -17
  229. package/textarea/Textarea.js +67 -109
  230. package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
  231. package/textarea/Textarea.test.js +150 -179
  232. package/textarea/types.d.ts +9 -5
  233. package/toggle-group/ToggleGroup.js +90 -107
  234. package/toggle-group/ToggleGroup.stories.tsx +7 -4
  235. package/toggle-group/ToggleGroup.test.js +68 -87
  236. package/toggle-group/types.d.ts +26 -17
  237. package/typography/Typography.js +4 -13
  238. package/typography/types.d.ts +1 -1
  239. package/useTheme.d.ts +48 -135
  240. package/useTheme.js +1 -8
  241. package/useTranslatedLabels.js +1 -7
  242. package/utils/BaseTypography.d.ts +2 -2
  243. package/utils/BaseTypography.js +16 -30
  244. package/utils/FocusLock.js +25 -39
  245. package/wizard/Wizard.js +14 -49
  246. package/wizard/Wizard.test.js +53 -80
  247. package/wizard/types.d.ts +6 -6
  248. package/card/ice-cream.jpg +0 -0
  249. package/number-input/NumberInputContext.d.ts +0 -4
  250. package/number-input/NumberInputContext.js +0 -19
  251. package/number-input/numberInputContextTypes.d.ts +0 -19
  252. package/resultsetTable/Icons.d.ts +0 -7
  253. package/resultsetTable/ResultsetTable.d.ts +0 -4
  254. package/slider/Slider.stories.tsx +0 -240
  255. /package/{resultsetTable → action-icon}/types.js +0 -0
  256. /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
  257. /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
@@ -3,6 +3,7 @@ import DxcTable from "./Table";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
5
  import { HalstackProvider } from "../HalstackContext";
6
+ import { userEvent, within } from "@storybook/testing-library";
6
7
 
7
8
  export default {
8
9
  title: "Table",
@@ -17,11 +18,240 @@ const opinionatedTheme = {
17
18
  },
18
19
  };
19
20
 
21
+ const advancedTheme = {
22
+ table: {
23
+ actionIconColor: "#1B75BB",
24
+ hoverActionIconColor: "#1B75BB",
25
+ activeActionIconColor: "#1B75BB",
26
+ focusActionIconColor: "#1B75BB",
27
+ hoverButtonBackgroundColor: "#cccccc",
28
+ },
29
+ };
30
+
31
+ const icon1 = (
32
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
33
+ <path d="M0 0h24v24H0V0z" fill="none" />
34
+ <path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
35
+ </svg>
36
+ );
37
+
38
+ const actions = [
39
+ {
40
+ title: "icon",
41
+ onClick: (value?) => {
42
+ console.log(value);
43
+ },
44
+ options: [
45
+ {
46
+ value: "1",
47
+ label: "Amazon with a very long text",
48
+ },
49
+ {
50
+ value: "2",
51
+ label: "Ebay",
52
+ },
53
+ {
54
+ value: "3",
55
+ label: "Apple",
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ title: "icon",
61
+ onClick: (value?) => {
62
+ console.log(value);
63
+ },
64
+ options: [
65
+ {
66
+ value: "1",
67
+ label: "Amazon with a very long text",
68
+ },
69
+ {
70
+ value: "2",
71
+ label: "Ebay",
72
+ },
73
+ {
74
+ value: "3",
75
+ label: "Apple",
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ disabled: true,
81
+ title: "icon",
82
+ onClick: (value?) => {
83
+ console.log(value);
84
+ },
85
+ options: [
86
+ {
87
+ value: "1",
88
+ label: "Amazon with a very long text",
89
+ },
90
+ {
91
+ value: "2",
92
+ label: "Ebay",
93
+ },
94
+ {
95
+ value: "3",
96
+ label: "Apple",
97
+ },
98
+ ],
99
+ },
100
+ {
101
+ icon: icon1,
102
+ title: "icon",
103
+ onClick: () => {},
104
+ },
105
+ {
106
+ icon: icon1,
107
+ title: "icon",
108
+ onClick: () => {},
109
+ disabled: true,
110
+ },
111
+ ];
112
+
20
113
  export const Chromatic = () => (
21
114
  <>
22
115
  <ExampleContainer>
23
116
  <Title title="Default" theme="light" level={4} />
24
117
  <DxcTable>
118
+ <tr>
119
+ <th>header 1</th>
120
+ <th>header 2</th>
121
+ <th>actions</th>
122
+ </tr>
123
+ <tr>
124
+ <td>cell 1</td>
125
+ <td>cell 2</td>
126
+ <td>
127
+ <DxcTable.ActionsCell actions={actions} />
128
+ </td>
129
+ </tr>
130
+ <tr>
131
+ <td>cell 4</td>
132
+ <td>cell 5</td>
133
+ <td>
134
+ <DxcTable.ActionsCell actions={actions} />
135
+ </td>
136
+ </tr>
137
+ <tr>
138
+ <td>cell 7</td>
139
+ <td>cell 8</td>
140
+ <td>
141
+ <DxcTable.ActionsCell actions={actions} />
142
+ </td>
143
+ </tr>
144
+ </DxcTable>
145
+ </ExampleContainer>
146
+ <ExampleContainer>
147
+ <Title title="Custom actionsCell theme" theme="light" level={4} />
148
+ <HalstackProvider advancedTheme={advancedTheme}>
149
+ <DxcTable>
150
+ <tr>
151
+ <th>header 1</th>
152
+ <th>header 2</th>
153
+ <th>actions</th>
154
+ </tr>
155
+ <tr>
156
+ <td>cell 1</td>
157
+ <td>cell 2</td>
158
+ <td>
159
+ <DxcTable.ActionsCell actions={actions} />
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td>cell 4</td>
164
+ <td>cell 5</td>
165
+ <td>
166
+ <DxcTable.ActionsCell actions={actions} />
167
+ </td>
168
+ </tr>
169
+ <tr>
170
+ <td>cell 7</td>
171
+ <td>cell 8</td>
172
+ <td>
173
+ <DxcTable.ActionsCell actions={actions} />
174
+ </td>
175
+ </tr>
176
+ </DxcTable>
177
+ </HalstackProvider>
178
+ </ExampleContainer>
179
+ <ExampleContainer>
180
+ <Title title="With scrollbar" theme="light" level={4} />
181
+ <div
182
+ style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
183
+ >
184
+ <DxcTable>
185
+ <tr>
186
+ <th>
187
+ header<br></br>subheader
188
+ </th>
189
+ <th>
190
+ header<br></br>subheader
191
+ </th>
192
+ <th>
193
+ header<br></br>subheader
194
+ </th>
195
+ </tr>
196
+ <tr>
197
+ <td>
198
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
199
+ dolore magna aliqua.
200
+ </td>
201
+ <td>
202
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
203
+ consequat.
204
+ </td>
205
+ <td>
206
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
207
+ </td>
208
+ </tr>
209
+ <tr>
210
+ <td>cell data</td>
211
+ <td>cell data</td>
212
+ <td>cell data</td>
213
+ </tr>
214
+ <tr>
215
+ <td>cell data</td>
216
+ <td>cell data</td>
217
+ <td>cell data</td>
218
+ </tr>
219
+ <tr>
220
+ <td>cell data</td>
221
+ <td>cell data</td>
222
+ <td>cell data</td>
223
+ </tr>
224
+ <tr>
225
+ <td>cell data</td>
226
+ <td>cell data</td>
227
+ <td>cell data</td>
228
+ </tr>
229
+ <tr>
230
+ <td>cell data</td>
231
+ <td>cell data</td>
232
+ <td>cell data</td>
233
+ </tr>
234
+ <tr>
235
+ <td>cell data</td>
236
+ <td>cell data</td>
237
+ <td>cell data</td>
238
+ </tr>
239
+ <tr>
240
+ <td>cell data</td>
241
+ <td>cell data</td>
242
+ <td>cell data</td>
243
+ </tr>
244
+ <tr>
245
+ <td>cell data</td>
246
+ <td>cell data</td>
247
+ <td>cell data</td>
248
+ </tr>
249
+ </DxcTable>
250
+ </div>
251
+ </ExampleContainer>
252
+ <ExampleContainer>
253
+ <Title title="Default reduced" theme="light" level={4} />
254
+ <DxcTable mode="reduced">
25
255
  <tr>
26
256
  <th>header 1</th>
27
257
  <th>header 2</th>
@@ -45,11 +275,11 @@ export const Chromatic = () => (
45
275
  </DxcTable>
46
276
  </ExampleContainer>
47
277
  <ExampleContainer>
48
- <Title title="With scrollbar" theme="light" level={4} />
278
+ <Title title="Reduced with scrollbar" theme="light" level={4} />
49
279
  <div
50
280
  style={{ height: 200 + "px", display: "flex", flexDirection: "row", width: 100 + "%", marginBottom: 50 + "px" }}
51
281
  >
52
- <DxcTable>
282
+ <DxcTable mode="reduced">
53
283
  <tr>
54
284
  <th>
55
285
  header<br></br>subheader
@@ -117,6 +347,37 @@ export const Chromatic = () => (
117
347
  </DxcTable>
118
348
  </div>
119
349
  </ExampleContainer>
350
+ <ExampleContainer>
351
+ <Title title="Reduced table with actions" theme="light" level={4} />
352
+ <DxcTable mode="reduced">
353
+ <tr>
354
+ <th>header 1</th>
355
+ <th>header 2</th>
356
+ <th>header 3</th>
357
+ </tr>
358
+ <tr>
359
+ <td>cell 1</td>
360
+ <td>cell 2</td>
361
+ <td>
362
+ <DxcTable.ActionsCell actions={actions} />
363
+ </td>
364
+ </tr>
365
+ <tr>
366
+ <td>cell 4</td>
367
+ <td>cell 5</td>
368
+ <td>
369
+ <DxcTable.ActionsCell actions={actions} />
370
+ </td>
371
+ </tr>
372
+ <tr>
373
+ <td>cell 7</td>
374
+ <td>cell 8</td>
375
+ <td>
376
+ <DxcTable.ActionsCell actions={actions} />
377
+ </td>
378
+ </tr>
379
+ </DxcTable>
380
+ </ExampleContainer>
120
381
  <Title title="Margins" theme="light" level={2} />
121
382
  <ExampleContainer>
122
383
  <Title title="Xxsmall margin" theme="light" level={4} />
@@ -354,3 +615,44 @@ export const Chromatic = () => (
354
615
  </ExampleContainer>
355
616
  </>
356
617
  );
618
+
619
+ const ActionsCellDropdown = () => (
620
+ <ExampleContainer>
621
+ <Title title="Dropdown Action" theme="light" level={4} />
622
+ <DxcTable>
623
+ <tr>
624
+ <th>header 1</th>
625
+ <th>header 2</th>
626
+ <th>actions</th>
627
+ </tr>
628
+ <tr>
629
+ <td>cell 1</td>
630
+ <td>cell 2</td>
631
+ <td>
632
+ <DxcTable.ActionsCell actions={actions} />
633
+ </td>
634
+ </tr>
635
+ <tr>
636
+ <td>cell 4</td>
637
+ <td>cell 5</td>
638
+ <td>
639
+ <DxcTable.ActionsCell actions={actions} />
640
+ </td>
641
+ </tr>
642
+ <tr>
643
+ <td>cell 7</td>
644
+ <td>cell 8</td>
645
+ <td>
646
+ <DxcTable.ActionsCell actions={actions} />
647
+ </td>
648
+ </tr>
649
+ </DxcTable>
650
+ </ExampleContainer>
651
+ );
652
+
653
+ export const DropdownAction = ActionsCellDropdown.bind({});
654
+ DropdownAction.play = async ({ canvasElement }) => {
655
+ const canvas = within(canvasElement);
656
+ const nextButton = canvas.getAllByRole("button")[8];
657
+ await userEvent.click(nextButton);
658
+ };
@@ -1,18 +1,59 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
4
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
5
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
6
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
7
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
5
8
  var _react = _interopRequireDefault(require("react"));
6
-
7
9
  var _react2 = require("@testing-library/react");
8
-
9
10
  var _Table = _interopRequireDefault(require("./Table.tsx"));
10
-
11
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
12
+ global.globalThis = global;
13
+ global.DOMRect = {
14
+ fromRect: function fromRect() {
15
+ return {
16
+ top: 0,
17
+ left: 0,
18
+ bottom: 0,
19
+ right: 0,
20
+ width: 0,
21
+ height: 0
22
+ };
23
+ }
24
+ };
25
+ global.ResizeObserver = /*#__PURE__*/function () {
26
+ function ResizeObserver() {
27
+ (0, _classCallCheck2["default"])(this, ResizeObserver);
28
+ }
29
+ (0, _createClass2["default"])(ResizeObserver, [{
30
+ key: "observe",
31
+ value: function observe() {}
32
+ }, {
33
+ key: "unobserve",
34
+ value: function unobserve() {}
35
+ }, {
36
+ key: "disconnect",
37
+ value: function disconnect() {}
38
+ }]);
39
+ return ResizeObserver;
40
+ }();
41
+ var icon = /*#__PURE__*/_react["default"].createElement("svg", {
42
+ xmlns: "http://www.w3.org/2000/svg",
43
+ height: "24px",
44
+ viewBox: "0 0 24 24",
45
+ width: "24px",
46
+ fill: "currentColor"
47
+ }, /*#__PURE__*/_react["default"].createElement("path", {
48
+ d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
49
+ fill: "none"
50
+ }), /*#__PURE__*/_react["default"].createElement("path", {
51
+ d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
52
+ }));
11
53
  describe("Table component tests", function () {
12
54
  test("Table renders with correct content", function () {
13
55
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-6"))))),
14
- getByText = _render.getByText;
15
-
56
+ getByText = _render.getByText;
16
57
  expect(getByText("header-1")).toBeTruthy();
17
58
  expect(getByText("header-2")).toBeTruthy();
18
59
  expect(getByText("header-3")).toBeTruthy();
@@ -23,4 +64,50 @@ describe("Table component tests", function () {
23
64
  expect(getByText("cell-5")).toBeTruthy();
24
65
  expect(getByText("cell-6")).toBeTruthy();
25
66
  });
67
+ test("Table ActionsCell", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
68
+ var onSelectOption, onClick, actions, _render2, getAllByRole, getByRole, getByText, dropdown, option, action;
69
+ return _regenerator["default"].wrap(function _callee$(_context) {
70
+ while (1) switch (_context.prev = _context.next) {
71
+ case 0:
72
+ onSelectOption = jest.fn();
73
+ onClick = jest.fn();
74
+ actions = [{
75
+ icon: icon,
76
+ title: "icon1",
77
+ onClick: onSelectOption,
78
+ options: [{
79
+ value: "1",
80
+ label: "Amazon"
81
+ }, {
82
+ value: "2",
83
+ label: "Ebay"
84
+ }, {
85
+ value: "3",
86
+ label: "Aliexpress"
87
+ }]
88
+ }, {
89
+ icon: icon,
90
+ title: "icon2",
91
+ onClick: onClick
92
+ }];
93
+ _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, /*#__PURE__*/_react["default"].createElement(_Table["default"].ActionsCell, {
94
+ actions: actions
95
+ })))))), getAllByRole = _render2.getAllByRole, getByRole = _render2.getByRole, getByText = _render2.getByText;
96
+ dropdown = getAllByRole("button")[1];
97
+ (0, _react2.act)(function () {
98
+ _userEvent["default"].click(dropdown);
99
+ });
100
+ expect(getByRole("menu")).toBeTruthy();
101
+ option = getByText("Aliexpress");
102
+ _userEvent["default"].click(option);
103
+ expect(onSelectOption).toHaveBeenCalledWith("3");
104
+ action = getAllByRole("button")[0];
105
+ _userEvent["default"].click(action);
106
+ expect(onClick).toHaveBeenCalled();
107
+ case 13:
108
+ case "end":
109
+ return _context.stop();
110
+ }
111
+ }, _callee);
112
+ })));
26
113
  });
package/table/types.d.ts CHANGED
@@ -1,21 +1,60 @@
1
1
  /// <reference types="react" />
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Margin = {
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type Props = {
9
+ type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
+ type Option = {
10
11
  /**
11
- * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
12
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
12
+ * Option display value.
13
13
  */
14
- margin?: Space | Margin;
14
+ label?: string;
15
+ /**
16
+ * Element or path used as the icon that will be placed next to the
17
+ * option label.
18
+ */
19
+ icon?: string | SVG;
20
+ /**
21
+ * Option inner value.
22
+ */
23
+ value: string;
24
+ };
25
+ export type ActionCellsPropsType = {
26
+ actions: Array<{
27
+ icon: string | SVG;
28
+ title: string;
29
+ onClick: () => void;
30
+ disabled?: boolean;
31
+ tabIndex?: number;
32
+ options?: never;
33
+ } | {
34
+ icon?: never;
35
+ title: string;
36
+ onClick: (value?: string) => void;
37
+ disabled?: boolean;
38
+ tabIndex?: number;
39
+ options: Option[];
40
+ }>;
41
+ };
42
+ type Props = {
15
43
  /**
16
44
  * The center section of the table. Can be used to render custom
17
45
  * content in this area.
18
46
  */
19
47
  children: React.ReactNode;
48
+ /**
49
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
50
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
51
+ */
52
+ margin?: Space | Margin;
53
+ /**
54
+ * Determines the visual style and layout
55
+ * - "default": Table with big spacing, applicable to most cases.
56
+ * - "reduced": Smaller table with minimal spacing for high density information.
57
+ */
58
+ mode?: "default" | "reduced";
20
59
  };
21
60
  export default Props;
package/tabs/Tab.js CHANGED
@@ -1,41 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
-
12
9
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _styledComponents = _interopRequireDefault(require("styled-components"));
17
-
18
12
  var _Badge = _interopRequireDefault(require("../badge/Badge"));
19
-
20
13
  var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
21
-
22
14
  var _useTheme = _interopRequireDefault(require("../useTheme"));
23
-
24
15
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
25
-
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
30
18
  var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
31
19
  var active = _ref.active,
32
- tab = _ref.tab,
33
- tabIndex = _ref.tabIndex,
34
- hasLabelAndIcon = _ref.hasLabelAndIcon,
35
- iconPosition = _ref.iconPosition,
36
- _onClick = _ref.onClick,
37
- _onMouseEnter = _ref.onMouseEnter,
38
- _onMouseLeave = _ref.onMouseLeave;
20
+ tab = _ref.tab,
21
+ tabIndex = _ref.tabIndex,
22
+ hasLabelAndIcon = _ref.hasLabelAndIcon,
23
+ iconPosition = _ref.iconPosition,
24
+ _onClick = _ref.onClick,
25
+ _onMouseEnter = _ref.onMouseEnter,
26
+ _onMouseLeave = _ref.onMouseLeave;
39
27
  var colorsTheme = (0, _useTheme["default"])();
40
28
  return /*#__PURE__*/_react["default"].createElement(TabContainer, {
41
29
  role: "tab",
@@ -58,7 +46,8 @@ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
58
46
  }, /*#__PURE__*/_react["default"].createElement(MainLabelContainer, {
59
47
  notificationNumber: tab.notificationNumber,
60
48
  hasLabelAndIcon: hasLabelAndIcon,
61
- iconPosition: iconPosition
49
+ iconPosition: iconPosition,
50
+ disabled: tab.isDisabled
62
51
  }, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
63
52
  hasLabelAndIcon: hasLabelAndIcon,
64
53
  iconPosition: iconPosition
@@ -73,14 +62,15 @@ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
73
62
  textAlign: "center",
74
63
  letterSpacing: "0.025em",
75
64
  lineHeight: "1.715em"
76
- }, tab.label)), tab.notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
65
+ }, tab.label)), tab.notificationNumber && !tab.isDisabled && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
77
66
  hasLabelAndIcon: hasLabelAndIcon,
78
67
  iconPosition: iconPosition
79
68
  }, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
80
- notificationText: typeof tab.notificationNumber === "number" && tab.notificationNumber > 99 ? "+99" : tab.notificationNumber
69
+ mode: "notification",
70
+ size: "small",
71
+ label: typeof tab.notificationNumber === "number" && tab.notificationNumber
81
72
  })));
82
73
  });
83
-
84
74
  var TabContainer = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n text-transform: ", ";\n overflow: hidden;\n flex-shrink: 0;\n border: 0;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n user-select: none;\n vertical-align: middle;\n justify-content: center;\n min-width: 90px;\n max-width: 360px;\n padding: ", ";\n height: ", ";\n min-height: ", ";\n background-color: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n svg {\n color: ", ";\n }\n\n &[aria-selected=\"true\"] {\n background-color: ", ";\n svg {\n color: ", ";\n }\n opacity: 1;\n }\n\n &:disabled {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n font-style: ", ";\n outline: none !important;\n\n svg {\n color: ", ";\n }\n > div {\n opacity: 0.5;\n }\n }\n"])), function (props) {
85
75
  return props.theme.fontTextTransform;
86
76
  }, function (props) {
@@ -110,23 +100,17 @@ var TabContainer = _styledComponents["default"].button(_templateObject || (_temp
110
100
  }, function (props) {
111
101
  return props.theme.disabledIconColor;
112
102
  });
113
-
114
103
  var BadgeContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n height: 100%;\n display: flex;\n align-items: ", ";\n"])), function (props) {
115
104
  return props.hasLabelAndIcon && props.iconPosition === "top" ? "flex-start" : "center";
116
105
  });
117
-
118
106
  var MainLabelContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n align-items: center;\n margin-left: ", ";\n"])), function (props) {
119
107
  return props.hasLabelAndIcon && props.iconPosition === "top" && "column" || "row";
120
108
  }, function (props) {
121
- return props.notificationNumber ? typeof props.notificationNumber === "number" ? "calc(".concat(props.theme.badgeWidthWithNotificationNumber, " + 12px)") : "calc(".concat(props.theme.badgeWidth, " + 12px)") : "unset";
109
+ return props.notificationNumber && !props.disabled ? typeof props.notificationNumber === "number" ? "36px" : "18px" : "unset";
122
110
  });
123
-
124
111
  var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 22px;\n width: 22px;\n }\n"])), function (props) {
125
112
  return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
126
113
  }, function (props) {
127
114
  return props.hasLabelAndIcon && props.iconPosition === "left" && "12px" || "";
128
115
  });
129
-
130
- var _default = /*#__PURE__*/_react["default"].memo(Tab);
131
-
132
- exports["default"] = _default;
116
+ var _default = exports["default"] = /*#__PURE__*/_react["default"].memo(Tab);