@dxc-technology/halstack-react 0.0.0-de7c6b0 → 0.0.0-dec566a

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 (286) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +4 -21
  3. package/HalstackContext.d.ts +52 -139
  4. package/HalstackContext.js +11 -36
  5. package/README.md +47 -0
  6. package/accordion/Accordion.js +31 -84
  7. package/accordion/Accordion.stories.tsx +5 -50
  8. package/accordion/Accordion.test.js +18 -33
  9. package/accordion/types.d.ts +6 -6
  10. package/accordion-group/AccordionGroup.d.ts +2 -3
  11. package/accordion-group/AccordionGroup.js +17 -44
  12. package/accordion-group/AccordionGroup.stories.tsx +1 -1
  13. package/accordion-group/AccordionGroup.test.js +42 -60
  14. package/accordion-group/AccordionGroupAccordion.js +11 -23
  15. package/accordion-group/AccordionGroupContext.d.ts +3 -0
  16. package/accordion-group/AccordionGroupContext.js +8 -0
  17. package/accordion-group/types.d.ts +7 -7
  18. package/action-icon/ActionIcon.d.ts +4 -0
  19. package/action-icon/ActionIcon.js +48 -0
  20. package/action-icon/ActionIcon.stories.tsx +41 -0
  21. package/action-icon/ActionIcon.test.js +64 -0
  22. package/action-icon/types.d.ts +26 -0
  23. package/alert/Alert.js +29 -118
  24. package/alert/Alert.test.js +28 -45
  25. package/alert/types.d.ts +5 -5
  26. package/badge/Badge.d.ts +1 -1
  27. package/badge/Badge.js +141 -43
  28. package/badge/Badge.stories.tsx +210 -0
  29. package/badge/Badge.test.js +30 -0
  30. package/badge/types.d.ts +52 -3
  31. package/bleed/Bleed.js +13 -21
  32. package/bleed/types.d.ts +2 -2
  33. package/box/Box.js +11 -33
  34. package/box/Box.test.js +1 -6
  35. package/box/types.d.ts +3 -3
  36. package/bulleted-list/BulletedList.js +22 -55
  37. package/bulleted-list/BulletedList.stories.tsx +2 -93
  38. package/bulleted-list/types.d.ts +5 -5
  39. package/button/Button.d.ts +1 -1
  40. package/button/Button.js +68 -100
  41. package/button/Button.stories.tsx +33 -132
  42. package/button/Button.test.js +19 -16
  43. package/button/types.d.ts +9 -5
  44. package/card/Card.js +21 -44
  45. package/card/Card.test.js +10 -21
  46. package/card/types.d.ts +5 -5
  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 +52 -139
  59. package/common/variables.js +63 -157
  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/contextual-menu/ContextualMenu.d.ts +7 -0
  65. package/contextual-menu/ContextualMenu.js +71 -0
  66. package/contextual-menu/ContextualMenu.stories.tsx +182 -0
  67. package/contextual-menu/ContextualMenu.test.js +71 -0
  68. package/contextual-menu/MenuItemAction.d.ts +4 -0
  69. package/contextual-menu/MenuItemAction.js +46 -0
  70. package/contextual-menu/types.d.ts +22 -0
  71. package/contextual-menu/types.js +5 -0
  72. package/date-input/Calendar.js +15 -59
  73. package/date-input/DateInput.js +50 -96
  74. package/date-input/DateInput.stories.tsx +11 -30
  75. package/date-input/DateInput.test.js +674 -701
  76. package/date-input/DatePicker.js +11 -42
  77. package/date-input/Icons.d.ts +6 -6
  78. package/date-input/Icons.js +6 -23
  79. package/date-input/YearPicker.js +8 -34
  80. package/date-input/types.d.ts +28 -22
  81. package/dialog/Dialog.js +13 -40
  82. package/dialog/Dialog.stories.tsx +170 -0
  83. package/dialog/Dialog.test.js +125 -187
  84. package/dialog/types.d.ts +18 -13
  85. package/divider/Divider.d.ts +4 -0
  86. package/divider/Divider.js +36 -0
  87. package/divider/Divider.stories.tsx +223 -0
  88. package/divider/Divider.test.js +38 -0
  89. package/divider/types.d.ts +21 -0
  90. package/divider/types.js +5 -0
  91. package/dropdown/Dropdown.js +59 -128
  92. package/dropdown/Dropdown.stories.tsx +5 -16
  93. package/dropdown/Dropdown.test.js +391 -378
  94. package/dropdown/DropdownMenu.js +8 -19
  95. package/dropdown/DropdownMenuItem.js +11 -20
  96. package/dropdown/types.d.ts +20 -24
  97. package/file-input/FileInput.js +180 -248
  98. package/file-input/FileInput.stories.tsx +1 -1
  99. package/file-input/FileInput.test.js +356 -354
  100. package/file-input/FileItem.js +14 -41
  101. package/file-input/types.d.ts +10 -10
  102. package/flex/Flex.js +25 -39
  103. package/flex/types.d.ts +6 -6
  104. package/footer/Footer.d.ts +1 -1
  105. package/footer/Footer.js +70 -102
  106. package/footer/Footer.stories.tsx +37 -6
  107. package/footer/Footer.test.js +21 -33
  108. package/footer/Icons.d.ts +3 -2
  109. package/footer/Icons.js +66 -7
  110. package/footer/types.d.ts +25 -21
  111. package/grid/Grid.d.ts +1 -1
  112. package/grid/Grid.js +2 -17
  113. package/grid/Grid.stories.tsx +38 -38
  114. package/grid/types.d.ts +10 -10
  115. package/header/Header.d.ts +1 -1
  116. package/header/Header.js +28 -84
  117. package/header/Header.test.js +12 -25
  118. package/header/Icons.d.ts +2 -2
  119. package/header/Icons.js +2 -7
  120. package/header/types.d.ts +7 -8
  121. package/heading/Heading.js +9 -31
  122. package/heading/Heading.test.js +70 -87
  123. package/heading/types.d.ts +7 -7
  124. package/icon/Icon.d.ts +4 -0
  125. package/icon/Icon.js +33 -0
  126. package/icon/Icon.stories.tsx +28 -0
  127. package/icon/types.d.ts +4 -0
  128. package/icon/types.js +5 -0
  129. package/image/Image.d.ts +4 -0
  130. package/image/Image.js +70 -0
  131. package/image/Image.stories.tsx +129 -0
  132. package/image/types.d.ts +72 -0
  133. package/image/types.js +5 -0
  134. package/inset/Inset.js +13 -21
  135. package/inset/types.d.ts +2 -2
  136. package/layout/ApplicationLayout.d.ts +2 -2
  137. package/layout/ApplicationLayout.js +29 -66
  138. package/layout/ApplicationLayout.stories.tsx +1 -1
  139. package/layout/Icons.d.ts +8 -5
  140. package/layout/Icons.js +51 -59
  141. package/layout/types.d.ts +3 -3
  142. package/link/Link.js +21 -42
  143. package/link/Link.test.js +23 -41
  144. package/link/types.d.ts +14 -14
  145. package/main.d.ts +8 -4
  146. package/main.js +39 -59
  147. package/nav-tabs/NavTabs.d.ts +1 -2
  148. package/nav-tabs/NavTabs.js +19 -48
  149. package/nav-tabs/NavTabs.stories.tsx +7 -5
  150. package/nav-tabs/NavTabs.test.js +38 -44
  151. package/nav-tabs/NavTabsContext.d.ts +3 -0
  152. package/nav-tabs/NavTabsContext.js +8 -0
  153. package/nav-tabs/Tab.js +24 -52
  154. package/nav-tabs/types.d.ts +9 -9
  155. package/number-input/NumberInput.js +46 -36
  156. package/number-input/NumberInput.stories.tsx +42 -26
  157. package/number-input/NumberInput.test.js +859 -412
  158. package/number-input/NumberInputContext.d.ts +3 -4
  159. package/number-input/NumberInputContext.js +3 -14
  160. package/number-input/types.d.ts +17 -5
  161. package/package.json +30 -28
  162. package/paginator/Icons.d.ts +5 -5
  163. package/paginator/Icons.js +5 -19
  164. package/paginator/Paginator.js +15 -43
  165. package/paginator/Paginator.test.js +224 -207
  166. package/paginator/types.d.ts +3 -3
  167. package/paragraph/Paragraph.js +3 -19
  168. package/paragraph/Paragraph.stories.tsx +0 -17
  169. package/password-input/Icons.d.ts +6 -0
  170. package/password-input/Icons.js +35 -0
  171. package/password-input/PasswordInput.js +57 -126
  172. package/password-input/PasswordInput.stories.tsx +1 -33
  173. package/password-input/PasswordInput.test.js +157 -140
  174. package/password-input/types.d.ts +8 -7
  175. package/progress-bar/ProgressBar.js +21 -53
  176. package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
  177. package/progress-bar/ProgressBar.test.js +35 -52
  178. package/progress-bar/types.d.ts +3 -3
  179. package/quick-nav/QuickNav.js +4 -27
  180. package/quick-nav/QuickNav.stories.tsx +1 -1
  181. package/quick-nav/types.d.ts +10 -10
  182. package/radio-group/Radio.d.ts +1 -1
  183. package/radio-group/Radio.js +22 -54
  184. package/radio-group/RadioGroup.js +37 -83
  185. package/radio-group/RadioGroup.stories.tsx +10 -10
  186. package/radio-group/RadioGroup.test.js +504 -470
  187. package/radio-group/types.d.ts +8 -8
  188. package/resultset-table/Icons.d.ts +7 -0
  189. package/{resultsetTable → resultset-table}/Icons.js +1 -5
  190. package/resultset-table/ResultsetTable.d.ts +7 -0
  191. package/{resultsetTable → resultset-table}/ResultsetTable.js +44 -69
  192. package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +106 -5
  193. package/{resultsetTable → resultset-table}/ResultsetTable.test.js +148 -92
  194. package/{resultsetTable → resultset-table}/types.d.ts +44 -11
  195. package/resultset-table/types.js +5 -0
  196. package/select/Icons.d.ts +7 -7
  197. package/select/Icons.js +1 -5
  198. package/select/Listbox.js +13 -39
  199. package/select/Option.js +17 -27
  200. package/select/Select.js +87 -163
  201. package/select/Select.stories.tsx +3 -3
  202. package/select/Select.test.js +1946 -1804
  203. package/select/types.d.ts +14 -15
  204. package/sidenav/Icons.d.ts +4 -4
  205. package/sidenav/Icons.js +1 -5
  206. package/sidenav/Sidenav.js +29 -70
  207. package/sidenav/Sidenav.test.js +3 -10
  208. package/{layout → sidenav}/SidenavContext.d.ts +1 -1
  209. package/{layout → sidenav}/SidenavContext.js +3 -9
  210. package/sidenav/types.d.ts +18 -18
  211. package/slider/Slider.js +68 -125
  212. package/slider/Slider.test.js +107 -103
  213. package/slider/types.d.ts +4 -4
  214. package/spinner/Spinner.js +16 -54
  215. package/spinner/Spinner.test.js +25 -34
  216. package/spinner/types.d.ts +3 -3
  217. package/status-light/StatusLight.d.ts +4 -0
  218. package/status-light/StatusLight.js +51 -0
  219. package/status-light/StatusLight.stories.tsx +74 -0
  220. package/status-light/StatusLight.test.js +25 -0
  221. package/status-light/types.d.ts +17 -0
  222. package/status-light/types.js +5 -0
  223. package/switch/Switch.js +49 -97
  224. package/switch/Switch.stories.tsx +0 -34
  225. package/switch/Switch.test.js +51 -96
  226. package/switch/types.d.ts +4 -4
  227. package/table/DropdownTheme.js +62 -0
  228. package/table/Table.d.ts +6 -2
  229. package/table/Table.js +76 -33
  230. package/table/{Table.stories.jsx → Table.stories.tsx} +297 -2
  231. package/table/Table.test.js +93 -6
  232. package/table/types.d.ts +34 -6
  233. package/tabs/Tab.js +17 -33
  234. package/tabs/Tabs.js +52 -129
  235. package/tabs/Tabs.stories.tsx +1 -1
  236. package/tabs/Tabs.test.js +62 -118
  237. package/tabs/types.d.ts +19 -19
  238. package/tag/Tag.js +21 -51
  239. package/tag/Tag.test.js +19 -30
  240. package/tag/types.d.ts +7 -7
  241. package/text-input/Suggestion.js +9 -26
  242. package/text-input/Suggestions.d.ts +1 -1
  243. package/text-input/Suggestions.js +19 -67
  244. package/text-input/TextInput.js +221 -327
  245. package/text-input/TextInput.stories.tsx +49 -153
  246. package/text-input/TextInput.test.js +1227 -1194
  247. package/text-input/types.d.ts +25 -17
  248. package/textarea/Textarea.js +67 -109
  249. package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
  250. package/textarea/Textarea.test.js +150 -179
  251. package/textarea/types.d.ts +9 -5
  252. package/toggle-group/ToggleGroup.js +90 -107
  253. package/toggle-group/ToggleGroup.stories.tsx +7 -4
  254. package/toggle-group/ToggleGroup.test.js +68 -87
  255. package/toggle-group/types.d.ts +26 -17
  256. package/typography/Typography.js +4 -13
  257. package/typography/types.d.ts +1 -1
  258. package/useTheme.d.ts +49 -136
  259. package/useTheme.js +1 -8
  260. package/useTranslatedLabels.js +1 -7
  261. package/utils/BaseTypography.d.ts +2 -2
  262. package/utils/BaseTypography.js +16 -30
  263. package/utils/FocusLock.js +25 -39
  264. package/wizard/Wizard.js +14 -49
  265. package/wizard/Wizard.test.js +53 -80
  266. package/wizard/types.d.ts +7 -7
  267. package/common/OpenSans.css +0 -69
  268. package/common/fonts/OpenSans-Bold.ttf +0 -0
  269. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  270. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  271. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  272. package/common/fonts/OpenSans-Italic.ttf +0 -0
  273. package/common/fonts/OpenSans-Light.ttf +0 -0
  274. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  275. package/common/fonts/OpenSans-Regular.ttf +0 -0
  276. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  277. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  278. package/number-input/numberInputContextTypes.d.ts +0 -19
  279. package/resultsetTable/Icons.d.ts +0 -7
  280. package/resultsetTable/ResultsetTable.d.ts +0 -4
  281. package/slider/Slider.stories.tsx +0 -240
  282. package/text-input/Icons.d.ts +0 -8
  283. package/text-input/Icons.js +0 -60
  284. /package/{resultsetTable → action-icon}/types.js +0 -0
  285. /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
  286. /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
@@ -1,186 +1,143 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _react = _interopRequireDefault(require("react"));
6
-
7
5
  var _react2 = require("@testing-library/react");
8
-
9
6
  var _Switch = _interopRequireDefault(require("./Switch.tsx"));
10
-
11
7
  describe("Switch component tests", function () {
12
8
  test("Switch renders with correct text", function () {
13
9
  var onChange = jest.fn(function (returnedValue) {
14
10
  expect(returnedValue).toBe(true);
15
11
  });
16
-
17
12
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
18
- label: "SwitchComponent",
19
- checked: false,
20
- onChange: onChange
21
- })),
22
- getByText = _render.getByText;
23
-
13
+ label: "SwitchComponent",
14
+ checked: false,
15
+ onChange: onChange
16
+ })),
17
+ getByText = _render.getByText;
24
18
  expect(getByText("SwitchComponent")).toBeTruthy();
25
19
  });
26
20
  test("Calls correct function on click", function () {
27
21
  var onChange = jest.fn();
28
-
29
22
  var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
30
- label: "SwitchComponent",
31
- checked: false,
32
- onChange: onChange
33
- })),
34
- getByText = _render2.getByText;
35
-
23
+ label: "SwitchComponent",
24
+ checked: false,
25
+ onChange: onChange
26
+ })),
27
+ getByText = _render2.getByText;
36
28
  _react2.fireEvent.click(getByText("SwitchComponent"));
37
-
38
29
  expect(onChange).toHaveBeenCalled();
39
30
  });
40
31
  test("Calls correct function on key down", function () {
41
32
  var onChange = jest.fn();
42
-
43
33
  var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
44
- label: "SwitchComponent",
45
- checked: false,
46
- onChange: onChange
47
- })),
48
- getByText = _render3.getByText;
49
-
34
+ label: "SwitchComponent",
35
+ checked: false,
36
+ onChange: onChange
37
+ })),
38
+ getByText = _render3.getByText;
50
39
  _react2.fireEvent.focus(getByText("SwitchComponent"));
51
-
52
40
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
53
41
  key: "Enter"
54
42
  });
55
-
56
43
  expect(onChange).toHaveBeenCalled();
57
-
58
44
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
59
45
  key: " "
60
46
  });
61
-
62
47
  expect(onChange).toHaveBeenCalled();
63
48
  });
64
49
  test("Everytime the user clicks the component the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
65
50
  var onChange = jest.fn();
66
-
67
51
  var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
68
- label: "SwitchComponent",
69
- checked: false,
70
- onChange: onChange
71
- })),
72
- getByText = _render4.getByText;
73
-
52
+ label: "SwitchComponent",
53
+ checked: false,
54
+ onChange: onChange
55
+ })),
56
+ getByText = _render4.getByText;
74
57
  _react2.fireEvent.click(getByText("SwitchComponent"));
75
-
76
58
  _react2.fireEvent.click(getByText("SwitchComponent"));
77
-
78
59
  expect(onChange.mock.calls[0][0]).toBe(true);
79
60
  expect(onChange.mock.calls[1][0]).toBe(true);
80
61
  });
81
62
  test("Everytime the user use enter in the component, the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
82
63
  var onChange = jest.fn();
83
-
84
64
  var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
85
- label: "SwitchComponent",
86
- checked: false,
87
- onChange: onChange
88
- })),
89
- getByText = _render5.getByText;
90
-
65
+ label: "SwitchComponent",
66
+ checked: false,
67
+ onChange: onChange
68
+ })),
69
+ getByText = _render5.getByText;
91
70
  _react2.fireEvent.focus(getByText("SwitchComponent"));
92
-
93
71
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
94
72
  key: "Enter"
95
73
  });
96
-
97
74
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
98
75
  key: "Enter"
99
76
  });
100
-
101
77
  expect(onChange.mock.calls[0][0]).toBe(true);
102
78
  expect(onChange.mock.calls[1][0]).toBe(true);
103
79
  });
104
80
  test("Everytime the user use space in the component, the onchange function is called with the correct value CONTROLLED COMPONENT", function () {
105
81
  var onChange = jest.fn();
106
-
107
82
  var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
108
- label: "SwitchComponent",
109
- checked: false,
110
- onChange: onChange
111
- })),
112
- getByText = _render6.getByText;
113
-
83
+ label: "SwitchComponent",
84
+ checked: false,
85
+ onChange: onChange
86
+ })),
87
+ getByText = _render6.getByText;
114
88
  _react2.fireEvent.focus(getByText("SwitchComponent"));
115
-
116
89
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
117
90
  key: " "
118
91
  });
119
-
120
92
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
121
93
  key: " "
122
94
  });
123
-
124
95
  expect(onChange.mock.calls[0][0]).toBe(true);
125
96
  expect(onChange.mock.calls[1][0]).toBe(true);
126
97
  });
127
98
  test("Everytime the user clicks the component the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
128
99
  var onChange = jest.fn();
129
-
130
100
  var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
131
- label: "SwitchComponent",
132
- onChange: onChange
133
- })),
134
- getByText = _render7.getByText;
135
-
101
+ label: "SwitchComponent",
102
+ onChange: onChange
103
+ })),
104
+ getByText = _render7.getByText;
136
105
  _react2.fireEvent.click(getByText("SwitchComponent"));
137
-
138
106
  _react2.fireEvent.click(getByText("SwitchComponent"));
139
-
140
107
  expect(onChange.mock.calls[0][0]).toBe(true);
141
108
  expect(onChange.mock.calls[1][0]).toBe(false);
142
109
  });
143
110
  test("Everytime the user use enter in the component, the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
144
111
  var onChange = jest.fn();
145
-
146
112
  var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
147
- label: "SwitchComponent",
148
- onChange: onChange
149
- })),
150
- getByText = _render8.getByText;
151
-
113
+ label: "SwitchComponent",
114
+ onChange: onChange
115
+ })),
116
+ getByText = _render8.getByText;
152
117
  _react2.fireEvent.focus(getByText("SwitchComponent"));
153
-
154
118
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
155
119
  key: "Enter"
156
120
  });
157
-
158
121
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
159
122
  key: "Enter"
160
123
  });
161
-
162
124
  expect(onChange.mock.calls[0][0]).toBe(true);
163
125
  expect(onChange.mock.calls[1][0]).toBe(false);
164
126
  });
165
127
  test("Everytime the user use space in the component, the onchange function is called with the correct value UNCONTROLLED COMPONENT", function () {
166
128
  var onChange = jest.fn();
167
-
168
129
  var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
169
- label: "SwitchComponent",
170
- onChange: onChange
171
- })),
172
- getByText = _render9.getByText;
173
-
130
+ label: "SwitchComponent",
131
+ onChange: onChange
132
+ })),
133
+ getByText = _render9.getByText;
174
134
  _react2.fireEvent.focus(getByText("SwitchComponent"));
175
-
176
135
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
177
136
  key: " "
178
137
  });
179
-
180
138
  _react2.fireEvent.keyDown(getByText("SwitchComponent"), {
181
139
  key: " "
182
140
  });
183
-
184
141
  expect(onChange.mock.calls[0][0]).toBe(true);
185
142
  expect(onChange.mock.calls[1][0]).toBe(false);
186
143
  });
@@ -198,11 +155,10 @@ describe("Switch component tests", function () {
198
155
  });
199
156
  test("Renders with correct aria attributes", function () {
200
157
  var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
201
- label: "Default label"
202
- })),
203
- getByText = _render10.getByText,
204
- getByRole = _render10.getByRole;
205
-
158
+ label: "Default label"
159
+ })),
160
+ getByText = _render10.getByText,
161
+ getByRole = _render10.getByRole;
206
162
  var switchEl = getByRole("switch");
207
163
  var label = getByText("Default label");
208
164
  expect(switchEl.getAttribute("aria-labelledby")).toBe(label.id);
@@ -210,12 +166,11 @@ describe("Switch component tests", function () {
210
166
  });
211
167
  test("Renders disabled switch correctly", function () {
212
168
  var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
213
- label: "Default label",
214
- disabled: true
215
- })),
216
- getByText = _render11.getByText,
217
- getByRole = _render11.getByRole;
218
-
169
+ label: "Default label",
170
+ disabled: true
171
+ })),
172
+ getByText = _render11.getByText,
173
+ getByRole = _render11.getByRole;
219
174
  var switchEl = getByRole("switch");
220
175
  var label = getByText("Default label");
221
176
  expect(switchEl.getAttribute("aria-labelledby")).toBe(label.id);
package/switch/types.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
- declare type Margin = {
1
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
+ type Margin = {
3
3
  top?: Space;
4
4
  bottom?: Space;
5
5
  left?: Space;
6
6
  right?: Space;
7
7
  };
8
- declare type Props = {
8
+ type Props = {
9
9
  /**
10
10
  * Initial state of the switch, only when it is uncontrolled.
11
11
  */
@@ -62,5 +62,5 @@ declare type Props = {
62
62
  /**
63
63
  * Reference to the component.
64
64
  */
65
- export declare type RefType = HTMLDivElement;
65
+ export type RefType = HTMLDivElement;
66
66
  export default Props;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _variables = require("../common/variables");
8
+ var _default = exports["default"] = {
9
+ dropdown: {
10
+ // ActionIcon size tokens
11
+ buttonIconSize: "16px",
12
+ buttonPaddingTop: "4px",
13
+ buttonPaddingBottom: "4px",
14
+ buttonPaddingLeft: "4px",
15
+ buttonPaddingRight: "4px",
16
+ buttonHeight: "24px",
17
+ buttonBorderRadius: "2px",
18
+ buttonBorderStyle: "none",
19
+ buttonBorderThickness: "0px",
20
+ buttonBorderColor: "transparent",
21
+ optionFontSize: "14px",
22
+ optionPaddingTop: "0px",
23
+ optionPaddingBottom: "0px",
24
+ optionPaddingLeft: "16px",
25
+ optionPaddingRight: "16px",
26
+ // Dropdown tokens
27
+ buttonBackgroundColor: _variables.componentTokens.table.actionBackgroundColor,
28
+ hoverButtonBackgroundColor: _variables.componentTokens.table.hoverActionBackgroundColor,
29
+ activeButtonBackgroundColor: _variables.componentTokens.table.activeActionBackgroundColor,
30
+ buttonFontFamily: _variables.componentTokens.dropdown.buttonFontFamily,
31
+ buttonFontSize: _variables.componentTokens.dropdown.buttonFontSize,
32
+ buttonFontStyle: _variables.componentTokens.dropdown.buttonFontStyle,
33
+ buttonFontWeight: _variables.componentTokens.dropdown.buttonFontWeight,
34
+ buttonFontColor: _variables.componentTokens.dropdown.buttonFontColor,
35
+ buttonIconSpacing: _variables.componentTokens.dropdown.buttonIconSpacing,
36
+ buttonIconColor: _variables.componentTokens.table.actionIconColor,
37
+ disabledColor: _variables.componentTokens.table.disabledActionIconColor,
38
+ disabledButtonBorderColor: _variables.componentTokens.dropdown.disabledButtonBorderColor,
39
+ disabledButtonBackgroundColor: _variables.componentTokens.table.disabledActionBackgroundColor,
40
+ disabledBorderColor: _variables.componentTokens.dropdown.disabledBorderColor,
41
+ optionBackgroundColor: _variables.componentTokens.dropdown.optionBackgroundColor,
42
+ hoverOptionBackgroundColor: _variables.componentTokens.dropdown.hoverOptionBackgroundColor,
43
+ activeOptionBackgroundColor: _variables.componentTokens.dropdown.activeOptionBackgroundColor,
44
+ optionFontFamily: _variables.componentTokens.dropdown.optionFontFamily,
45
+ optionFontStyle: _variables.componentTokens.dropdown.optionFontStyle,
46
+ optionFontWeight: _variables.componentTokens.dropdown.optionFontWeight,
47
+ optionFontColor: _variables.componentTokens.dropdown.optionFontColor,
48
+ optionIconSize: _variables.componentTokens.dropdown.optionIconSize,
49
+ optionIconSpacing: _variables.componentTokens.dropdown.optionIconSpacing,
50
+ optionIconColor: _variables.componentTokens.dropdown.optionIconColor,
51
+ caretIconSize: _variables.componentTokens.dropdown.caretIconSize,
52
+ caretIconColor: _variables.componentTokens.dropdown.caretIconColor,
53
+ caretIconSpacing: _variables.componentTokens.dropdown.caretIconSpacing,
54
+ borderRadius: _variables.componentTokens.dropdown.borderRadius,
55
+ borderStyle: _variables.componentTokens.dropdown.borderStyle,
56
+ borderThickness: _variables.componentTokens.dropdown.borderThickness,
57
+ borderColor: _variables.componentTokens.dropdown.borderColor,
58
+ scrollBarThumbColor: _variables.componentTokens.dropdown.scrollBarThumbColor,
59
+ scrollBarTrackColor: _variables.componentTokens.dropdown.scrollBarTrackColor,
60
+ focusColor: _variables.componentTokens.table.focusActionBorderColor
61
+ }
62
+ };
package/table/Table.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
- import TablePropsType from "./types";
3
- declare const DxcTable: ({ children, margin }: TablePropsType) => JSX.Element;
2
+ import TablePropsType, { ActionCellsPropsType } from "./types";
3
+ export declare const DxcActionsCell: ({ actions }: ActionCellsPropsType) => JSX.Element;
4
+ declare const DxcTable: {
5
+ ({ children, margin, mode }: TablePropsType): JSX.Element;
6
+ ActionsCell: ({ actions }: ActionCellsPropsType) => JSX.Element;
7
+ };
4
8
  export default DxcTable;
package/table/Table.js CHANGED
@@ -1,53 +1,88 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
- exports["default"] = void 0;
11
-
8
+ exports["default"] = exports.DxcActionsCell = void 0;
12
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
-
14
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
12
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
19
-
20
13
  var _variables = require("../common/variables");
21
-
22
14
  var _utils = require("../common/utils");
23
-
24
15
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
-
26
- var _BackgroundColorContext = require("../BackgroundColorContext");
27
-
16
+ var _DropdownTheme = _interopRequireDefault(require("./DropdownTheme"));
17
+ var _Dropdown = _interopRequireDefault(require("../dropdown/Dropdown"));
18
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
19
+ var _HalstackContext = require("../HalstackContext");
20
+ var _ActionIcon = _interopRequireDefault(require("../action-icon/ActionIcon"));
28
21
  var _templateObject, _templateObject2;
29
-
30
- 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); }
31
-
32
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
33
-
34
- var DxcTable = function DxcTable(_ref) {
35
- var children = _ref.children,
36
- margin = _ref.margin;
22
+ 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); }
23
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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; }
24
+ var overwriteTheme = function overwriteTheme(theme) {
25
+ var newTheme = _DropdownTheme["default"];
26
+ newTheme.dropdown.buttonBackgroundColor = theme.table.actionBackgroundColor;
27
+ newTheme.dropdown.hoverButtonBackgroundColor = theme.table.hoverActionBackgroundColor;
28
+ newTheme.dropdown.activeButtonBackgroundColor = theme.table.activeActionBackgroundColor;
29
+ newTheme.dropdown.buttonIconColor = theme.table.actionIconColor;
30
+ newTheme.dropdown.disabledColor = theme.table.disabledActionIconColor;
31
+ newTheme.dropdown.disabledButtonBackgroundColor = theme.table.disabledActionBackgroundColor;
32
+ return newTheme;
33
+ };
34
+ var DxcActionsCell = exports.DxcActionsCell = function DxcActionsCell(_ref) {
35
+ var actions = _ref.actions;
36
+ var actionIcons = actions.filter(function (action) {
37
+ return !action.options;
38
+ });
39
+ var actionDropdown = actions.find(function (action) {
40
+ return action.options;
41
+ });
42
+ var maxNumberOfActions = actionDropdown ? 2 : 3;
43
+ var colorsTheme = (0, _useTheme["default"])();
44
+ return /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
45
+ gap: "0.5rem",
46
+ alignItems: "center"
47
+ }, actionIcons.map(function (action, index) {
48
+ var _action$disabled, _action$tabIndex;
49
+ return index < maxNumberOfActions && /*#__PURE__*/_react["default"].createElement(_ActionIcon["default"], {
50
+ icon: action.icon,
51
+ title: action.title,
52
+ onClick: action.onClick,
53
+ disabled: (_action$disabled = action.disabled) !== null && _action$disabled !== void 0 ? _action$disabled : false,
54
+ tabIndex: (_action$tabIndex = action.tabIndex) !== null && _action$tabIndex !== void 0 ? _action$tabIndex : 0,
55
+ key: "action-".concat(index)
56
+ });
57
+ }), actionDropdown && /*#__PURE__*/_react["default"].createElement(_HalstackContext.HalstackProvider, {
58
+ advancedTheme: overwriteTheme(colorsTheme),
59
+ key: "provider-dropdown"
60
+ }, /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
61
+ options: actionDropdown.options,
62
+ onSelectOption: actionDropdown.onClick,
63
+ disabled: actionDropdown.disabled,
64
+ icon: "more_vert",
65
+ tabIndex: actionDropdown.tabIndex,
66
+ caretHidden: true
67
+ })));
68
+ };
69
+ var DxcTable = function DxcTable(_ref2) {
70
+ var children = _ref2.children,
71
+ margin = _ref2.margin,
72
+ _ref2$mode = _ref2.mode,
73
+ mode = _ref2$mode === void 0 ? "default" : _ref2$mode;
37
74
  var colorsTheme = (0, _useTheme["default"])();
38
75
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
39
76
  theme: colorsTheme.table
40
77
  }, /*#__PURE__*/_react["default"].createElement(DxcTableContainer, {
41
78
  margin: margin
42
- }, /*#__PURE__*/_react["default"].createElement(DxcTableContent, null, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
43
- color: colorsTheme.table.dataBackgroundColor
44
- }, children))));
79
+ }, /*#__PURE__*/_react["default"].createElement(DxcTableContent, {
80
+ mode: mode
81
+ }, children)));
45
82
  };
46
-
47
83
  var calculateWidth = function calculateWidth(margin) {
48
84
  return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
49
85
  };
50
-
51
86
  var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
52
87
  return calculateWidth(props.margin);
53
88
  }, function (props) {
@@ -65,9 +100,10 @@ var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_te
65
100
  }, function (props) {
66
101
  return props.theme.scrollBarTrackColor;
67
102
  });
68
-
69
- var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: 60px;\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n }\n & td:last-child {\n padding-right: 40px;\n }\n"])), function (props) {
103
+ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n border-collapse: collapse;\n width: 100%;\n\n & tr {\n border-bottom: ", ";\n height: ", ";\n }\n & td {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th {\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-transform: ", ";\n text-align: ", ";\n line-height: ", ";\n padding: ", ";\n }\n & th:first-child {\n border-top-left-radius: ", ";\n padding-left: ", ";\n }\n & th:last-child {\n border-top-right-radius: ", ";\n padding-right: ", ";\n }\n & td:first-child {\n padding-left: ", ";\n }\n & td:last-child {\n padding-right: ", ";\n }\n"])), function (props) {
70
104
  return "".concat(props.theme.rowSeparatorThickness, " ").concat(props.theme.rowSeparatorStyle, " ").concat(props.theme.rowSeparatorColor);
105
+ }, function (props) {
106
+ return props.mode === "default" ? "60px" : "36px";
71
107
  }, function (props) {
72
108
  return props.theme.dataBackgroundColor;
73
109
  }, function (props) {
@@ -87,7 +123,7 @@ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_t
87
123
  }, function (props) {
88
124
  return props.theme.dataTextLineHeight;
89
125
  }, function (props) {
90
- return "".concat(props.theme.dataPaddingTop, " ").concat(props.theme.dataPaddingRight, " ").concat(props.theme.dataPaddingBottom, " ").concat(props.theme.dataPaddingLeft);
126
+ return props.mode === "default" ? "".concat(props.theme.dataPaddingTop, " ").concat(props.theme.dataPaddingRight, " ").concat(props.theme.dataPaddingBottom, " ").concat(props.theme.dataPaddingLeft) : "".concat(props.theme.dataPaddingTopReduced, " ").concat(props.theme.dataPaddingRightReduced, " ").concat(props.theme.dataPaddingBottomReduced, " ").concat(props.theme.dataPaddingLeftReduced);
91
127
  }, function (props) {
92
128
  return props.theme.headerBackgroundColor;
93
129
  }, function (props) {
@@ -107,12 +143,19 @@ var DxcTableContent = _styledComponents["default"].table(_templateObject2 || (_t
107
143
  }, function (props) {
108
144
  return props.theme.headerTextLineHeight;
109
145
  }, function (props) {
110
- return "".concat(props.theme.headerPaddingTop, " ").concat(props.theme.headerPaddingRight, " ").concat(props.theme.headerPaddingBottom, " ").concat(props.theme.headerPaddingLeft);
146
+ return props.mode === "default" ? "".concat(props.theme.headerPaddingTop, " ").concat(props.theme.headerPaddingRight, " ").concat(props.theme.headerPaddingBottom, " ").concat(props.theme.headerPaddingLeft) : "".concat(props.theme.headerPaddingTopReduced, " ").concat(props.theme.headerPaddingRightReduced, " ").concat(props.theme.headerPaddingBottomReduced, " ").concat(props.theme.headerPaddingLeftReduced);
111
147
  }, function (props) {
112
148
  return props.theme.headerBorderRadius;
149
+ }, function (props) {
150
+ return props.mode === "default" ? props.theme.firstChildPaddingLeft : props.theme.firstChildPaddingLeftReduced;
113
151
  }, function (props) {
114
152
  return props.theme.headerBorderRadius;
153
+ }, function (props) {
154
+ return props.mode === "default" ? props.theme.lastChildPaddingRight : props.theme.lastChildPaddingRightReduced;
155
+ }, function (props) {
156
+ return props.mode === "default" ? props.theme.firstChildPaddingLeft : props.theme.firstChildPaddingLeftReduced;
157
+ }, function (props) {
158
+ return props.mode === "default" ? props.theme.lastChildPaddingRight : props.theme.lastChildPaddingRightReduced;
115
159
  });
116
-
117
- var _default = DxcTable;
118
- exports["default"] = _default;
160
+ DxcTable.ActionsCell = DxcActionsCell;
161
+ var _default = exports["default"] = DxcTable;