@dxc-technology/halstack-react 0.0.0-dcee34a → 0.0.0-dd6acd7

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 (330) hide show
  1. package/README.md +46 -0
  2. package/dist/index.d.mts +6518 -0
  3. package/dist/index.d.ts +6518 -0
  4. package/dist/index.js +13484 -0
  5. package/dist/index.mjs +13427 -0
  6. package/package.json +68 -66
  7. package/BackgroundColorContext.d.ts +0 -10
  8. package/BackgroundColorContext.js +0 -47
  9. package/HalstackContext.d.ts +0 -12
  10. package/HalstackContext.js +0 -343
  11. package/accordion/Accordion.d.ts +0 -4
  12. package/accordion/Accordion.js +0 -239
  13. package/accordion/Accordion.stories.tsx +0 -395
  14. package/accordion/Accordion.test.js +0 -71
  15. package/accordion/types.d.ts +0 -69
  16. package/accordion/types.js +0 -5
  17. package/accordion-group/AccordionGroup.d.ts +0 -7
  18. package/accordion-group/AccordionGroup.js +0 -149
  19. package/accordion-group/AccordionGroup.stories.tsx +0 -251
  20. package/accordion-group/AccordionGroup.test.js +0 -126
  21. package/accordion-group/types.d.ts +0 -79
  22. package/accordion-group/types.js +0 -5
  23. package/alert/Alert.d.ts +0 -4
  24. package/alert/Alert.js +0 -293
  25. package/alert/Alert.stories.tsx +0 -198
  26. package/alert/Alert.test.js +0 -92
  27. package/alert/types.d.ts +0 -49
  28. package/alert/types.js +0 -5
  29. package/badge/Badge.d.ts +0 -4
  30. package/badge/Badge.js +0 -61
  31. package/badge/types.d.ts +0 -5
  32. package/badge/types.js +0 -5
  33. package/bleed/Bleed.d.ts +0 -3
  34. package/bleed/Bleed.js +0 -51
  35. package/bleed/Bleed.stories.tsx +0 -341
  36. package/bleed/types.d.ts +0 -37
  37. package/bleed/types.js +0 -5
  38. package/box/Box.d.ts +0 -4
  39. package/box/Box.js +0 -116
  40. package/box/Box.stories.tsx +0 -147
  41. package/box/Box.test.js +0 -18
  42. package/box/types.d.ts +0 -44
  43. package/box/types.js +0 -5
  44. package/bulleted-list/BulletedList.d.ts +0 -7
  45. package/bulleted-list/BulletedList.js +0 -123
  46. package/bulleted-list/BulletedList.stories.tsx +0 -200
  47. package/bulleted-list/types.d.ts +0 -11
  48. package/bulleted-list/types.js +0 -5
  49. package/button/Button.d.ts +0 -4
  50. package/button/Button.js +0 -154
  51. package/button/Button.stories.tsx +0 -425
  52. package/button/Button.test.js +0 -35
  53. package/button/types.d.ts +0 -53
  54. package/button/types.js +0 -5
  55. package/card/Card.d.ts +0 -4
  56. package/card/Card.js +0 -161
  57. package/card/Card.stories.tsx +0 -201
  58. package/card/Card.test.js +0 -50
  59. package/card/ice-cream.jpg +0 -0
  60. package/card/types.d.ts +0 -68
  61. package/card/types.js +0 -5
  62. package/checkbox/Checkbox.d.ts +0 -4
  63. package/checkbox/Checkbox.js +0 -250
  64. package/checkbox/Checkbox.stories.tsx +0 -260
  65. package/checkbox/Checkbox.test.js +0 -155
  66. package/checkbox/types.d.ts +0 -68
  67. package/checkbox/types.js +0 -5
  68. package/chip/Chip.d.ts +0 -4
  69. package/chip/Chip.js +0 -155
  70. package/chip/Chip.stories.tsx +0 -206
  71. package/chip/Chip.test.js +0 -56
  72. package/chip/types.d.ts +0 -45
  73. package/chip/types.js +0 -5
  74. package/common/OpenSans.css +0 -81
  75. package/common/fonts/OpenSans-Bold.ttf +0 -0
  76. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  77. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  78. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  79. package/common/fonts/OpenSans-Italic.ttf +0 -0
  80. package/common/fonts/OpenSans-Light.ttf +0 -0
  81. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  82. package/common/fonts/OpenSans-Regular.ttf +0 -0
  83. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  84. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  85. package/common/utils.js +0 -22
  86. package/common/variables.js +0 -1538
  87. package/date-input/Calendar.d.ts +0 -4
  88. package/date-input/Calendar.js +0 -258
  89. package/date-input/DateInput.d.ts +0 -4
  90. package/date-input/DateInput.js +0 -269
  91. package/date-input/DateInput.stories.tsx +0 -304
  92. package/date-input/DateInput.test.js +0 -835
  93. package/date-input/DatePicker.d.ts +0 -4
  94. package/date-input/DatePicker.js +0 -146
  95. package/date-input/Icons.d.ts +0 -6
  96. package/date-input/Icons.js +0 -75
  97. package/date-input/YearPicker.d.ts +0 -4
  98. package/date-input/YearPicker.js +0 -126
  99. package/date-input/types.d.ts +0 -158
  100. package/date-input/types.js +0 -5
  101. package/dialog/Dialog.d.ts +0 -4
  102. package/dialog/Dialog.js +0 -160
  103. package/dialog/Dialog.stories.tsx +0 -289
  104. package/dialog/Dialog.test.js +0 -70
  105. package/dialog/types.d.ts +0 -44
  106. package/dialog/types.js +0 -5
  107. package/dropdown/Dropdown.d.ts +0 -4
  108. package/dropdown/Dropdown.js +0 -388
  109. package/dropdown/Dropdown.stories.tsx +0 -438
  110. package/dropdown/Dropdown.test.js +0 -585
  111. package/dropdown/DropdownMenu.d.ts +0 -4
  112. package/dropdown/DropdownMenu.js +0 -70
  113. package/dropdown/DropdownMenuItem.d.ts +0 -4
  114. package/dropdown/DropdownMenuItem.js +0 -81
  115. package/dropdown/types.d.ts +0 -100
  116. package/dropdown/types.js +0 -5
  117. package/file-input/FileInput.d.ts +0 -4
  118. package/file-input/FileInput.js +0 -551
  119. package/file-input/FileInput.stories.tsx +0 -618
  120. package/file-input/FileInput.test.js +0 -498
  121. package/file-input/FileItem.d.ts +0 -4
  122. package/file-input/FileItem.js +0 -161
  123. package/file-input/types.d.ts +0 -129
  124. package/file-input/types.js +0 -5
  125. package/flex/Flex.d.ts +0 -4
  126. package/flex/Flex.js +0 -69
  127. package/flex/Flex.stories.tsx +0 -103
  128. package/flex/types.d.ts +0 -32
  129. package/flex/types.js +0 -5
  130. package/footer/Footer.d.ts +0 -4
  131. package/footer/Footer.js +0 -185
  132. package/footer/Footer.stories.tsx +0 -228
  133. package/footer/Footer.test.js +0 -109
  134. package/footer/Icons.d.ts +0 -2
  135. package/footer/Icons.js +0 -77
  136. package/footer/types.d.ts +0 -66
  137. package/footer/types.js +0 -5
  138. package/header/Header.d.ts +0 -7
  139. package/header/Header.js +0 -303
  140. package/header/Header.stories.tsx +0 -315
  141. package/header/Header.test.js +0 -79
  142. package/header/Icons.d.ts +0 -2
  143. package/header/Icons.js +0 -34
  144. package/header/types.d.ts +0 -48
  145. package/header/types.js +0 -5
  146. package/heading/Heading.d.ts +0 -4
  147. package/heading/Heading.js +0 -159
  148. package/heading/Heading.stories.tsx +0 -54
  149. package/heading/Heading.test.js +0 -186
  150. package/heading/types.d.ts +0 -33
  151. package/heading/types.js +0 -5
  152. package/inset/Inset.d.ts +0 -3
  153. package/inset/Inset.js +0 -51
  154. package/inset/Inset.stories.tsx +0 -229
  155. package/inset/types.d.ts +0 -37
  156. package/inset/types.js +0 -5
  157. package/layout/ApplicationLayout.d.ts +0 -20
  158. package/layout/ApplicationLayout.js +0 -171
  159. package/layout/ApplicationLayout.stories.tsx +0 -162
  160. package/layout/Icons.d.ts +0 -5
  161. package/layout/Icons.js +0 -66
  162. package/layout/SidenavContext.d.ts +0 -5
  163. package/layout/SidenavContext.js +0 -19
  164. package/layout/types.d.ts +0 -42
  165. package/layout/types.js +0 -5
  166. package/link/Link.d.ts +0 -4
  167. package/link/Link.js +0 -136
  168. package/link/Link.stories.tsx +0 -253
  169. package/link/Link.test.js +0 -83
  170. package/link/types.d.ts +0 -54
  171. package/link/types.js +0 -5
  172. package/main.d.ts +0 -44
  173. package/main.js +0 -369
  174. package/nav-tabs/NavTabs.d.ts +0 -8
  175. package/nav-tabs/NavTabs.js +0 -125
  176. package/nav-tabs/NavTabs.stories.tsx +0 -260
  177. package/nav-tabs/NavTabs.test.js +0 -82
  178. package/nav-tabs/Tab.d.ts +0 -4
  179. package/nav-tabs/Tab.js +0 -149
  180. package/nav-tabs/types.d.ts +0 -53
  181. package/nav-tabs/types.js +0 -5
  182. package/number-input/NumberInput.d.ts +0 -4
  183. package/number-input/NumberInput.js +0 -76
  184. package/number-input/NumberInput.stories.tsx +0 -115
  185. package/number-input/NumberInput.test.js +0 -542
  186. package/number-input/NumberInputContext.d.ts +0 -4
  187. package/number-input/NumberInputContext.js +0 -19
  188. package/number-input/numberInputContextTypes.d.ts +0 -19
  189. package/number-input/numberInputContextTypes.js +0 -5
  190. package/number-input/types.d.ts +0 -124
  191. package/number-input/types.js +0 -5
  192. package/paginator/Icons.d.ts +0 -5
  193. package/paginator/Icons.js +0 -54
  194. package/paginator/Paginator.d.ts +0 -4
  195. package/paginator/Paginator.js +0 -165
  196. package/paginator/Paginator.stories.tsx +0 -87
  197. package/paginator/Paginator.test.js +0 -315
  198. package/paginator/types.d.ts +0 -38
  199. package/paginator/types.js +0 -5
  200. package/paragraph/Paragraph.d.ts +0 -6
  201. package/paragraph/Paragraph.js +0 -38
  202. package/paragraph/Paragraph.stories.tsx +0 -44
  203. package/password-input/PasswordInput.d.ts +0 -4
  204. package/password-input/PasswordInput.js +0 -166
  205. package/password-input/PasswordInput.stories.tsx +0 -131
  206. package/password-input/PasswordInput.test.js +0 -181
  207. package/password-input/types.d.ts +0 -110
  208. package/password-input/types.js +0 -5
  209. package/progress-bar/ProgressBar.d.ts +0 -4
  210. package/progress-bar/ProgressBar.js +0 -176
  211. package/progress-bar/ProgressBar.stories.jsx +0 -93
  212. package/progress-bar/ProgressBar.test.js +0 -110
  213. package/progress-bar/types.d.ts +0 -36
  214. package/progress-bar/types.js +0 -5
  215. package/quick-nav/QuickNav.d.ts +0 -4
  216. package/quick-nav/QuickNav.js +0 -117
  217. package/quick-nav/QuickNav.stories.tsx +0 -356
  218. package/quick-nav/types.d.ts +0 -21
  219. package/quick-nav/types.js +0 -5
  220. package/radio-group/Radio.d.ts +0 -4
  221. package/radio-group/Radio.js +0 -156
  222. package/radio-group/RadioGroup.d.ts +0 -4
  223. package/radio-group/RadioGroup.js +0 -283
  224. package/radio-group/RadioGroup.stories.tsx +0 -214
  225. package/radio-group/RadioGroup.test.js +0 -722
  226. package/radio-group/types.d.ts +0 -114
  227. package/radio-group/types.js +0 -5
  228. package/resultsetTable/Icons.d.ts +0 -7
  229. package/resultsetTable/Icons.js +0 -51
  230. package/resultsetTable/ResultsetTable.d.ts +0 -4
  231. package/resultsetTable/ResultsetTable.js +0 -195
  232. package/resultsetTable/ResultsetTable.stories.tsx +0 -300
  233. package/resultsetTable/ResultsetTable.test.js +0 -325
  234. package/resultsetTable/types.d.ts +0 -67
  235. package/resultsetTable/types.js +0 -5
  236. package/select/Icons.d.ts +0 -10
  237. package/select/Icons.js +0 -93
  238. package/select/Listbox.d.ts +0 -4
  239. package/select/Listbox.js +0 -169
  240. package/select/Option.d.ts +0 -4
  241. package/select/Option.js +0 -97
  242. package/select/Select.d.ts +0 -4
  243. package/select/Select.js +0 -664
  244. package/select/Select.stories.tsx +0 -971
  245. package/select/Select.test.js +0 -2228
  246. package/select/types.d.ts +0 -210
  247. package/select/types.js +0 -5
  248. package/sidenav/Sidenav.d.ts +0 -10
  249. package/sidenav/Sidenav.js +0 -266
  250. package/sidenav/Sidenav.stories.tsx +0 -282
  251. package/sidenav/Sidenav.test.js +0 -44
  252. package/sidenav/types.d.ts +0 -73
  253. package/sidenav/types.js +0 -5
  254. package/slider/Slider.d.ts +0 -4
  255. package/slider/Slider.js +0 -343
  256. package/slider/Slider.stories.tsx +0 -240
  257. package/slider/Slider.test.js +0 -250
  258. package/slider/types.d.ts +0 -86
  259. package/slider/types.js +0 -5
  260. package/spinner/Spinner.d.ts +0 -4
  261. package/spinner/Spinner.js +0 -250
  262. package/spinner/Spinner.stories.jsx +0 -129
  263. package/spinner/Spinner.test.js +0 -64
  264. package/spinner/types.d.ts +0 -32
  265. package/spinner/types.js +0 -5
  266. package/switch/Switch.d.ts +0 -4
  267. package/switch/Switch.js +0 -262
  268. package/switch/Switch.stories.tsx +0 -171
  269. package/switch/Switch.test.js +0 -225
  270. package/switch/types.d.ts +0 -66
  271. package/switch/types.js +0 -5
  272. package/table/Table.d.ts +0 -4
  273. package/table/Table.js +0 -118
  274. package/table/Table.stories.jsx +0 -356
  275. package/table/Table.test.js +0 -26
  276. package/table/types.d.ts +0 -21
  277. package/table/types.js +0 -5
  278. package/tabs/Tab.d.ts +0 -4
  279. package/tabs/Tab.js +0 -133
  280. package/tabs/Tabs.d.ts +0 -4
  281. package/tabs/Tabs.js +0 -467
  282. package/tabs/Tabs.stories.tsx +0 -226
  283. package/tabs/Tabs.test.js +0 -351
  284. package/tabs/types.d.ts +0 -92
  285. package/tabs/types.js +0 -5
  286. package/tag/Tag.d.ts +0 -4
  287. package/tag/Tag.js +0 -183
  288. package/tag/Tag.stories.tsx +0 -155
  289. package/tag/Tag.test.js +0 -60
  290. package/tag/types.d.ts +0 -69
  291. package/tag/types.js +0 -5
  292. package/text-input/Icons.d.ts +0 -8
  293. package/text-input/Icons.js +0 -60
  294. package/text-input/Suggestion.d.ts +0 -4
  295. package/text-input/Suggestion.js +0 -84
  296. package/text-input/Suggestions.d.ts +0 -4
  297. package/text-input/Suggestions.js +0 -134
  298. package/text-input/TextInput.d.ts +0 -4
  299. package/text-input/TextInput.js +0 -673
  300. package/text-input/TextInput.stories.tsx +0 -569
  301. package/text-input/TextInput.test.js +0 -1724
  302. package/text-input/types.d.ts +0 -197
  303. package/text-input/types.js +0 -5
  304. package/textarea/Textarea.d.ts +0 -4
  305. package/textarea/Textarea.js +0 -277
  306. package/textarea/Textarea.stories.jsx +0 -216
  307. package/textarea/Textarea.test.js +0 -437
  308. package/textarea/types.d.ts +0 -137
  309. package/textarea/types.js +0 -5
  310. package/toggle-group/ToggleGroup.d.ts +0 -4
  311. package/toggle-group/ToggleGroup.js +0 -215
  312. package/toggle-group/ToggleGroup.stories.tsx +0 -215
  313. package/toggle-group/ToggleGroup.test.js +0 -156
  314. package/toggle-group/types.d.ts +0 -105
  315. package/toggle-group/types.js +0 -5
  316. package/typography/Typography.d.ts +0 -4
  317. package/typography/Typography.js +0 -131
  318. package/typography/Typography.stories.tsx +0 -198
  319. package/typography/types.d.ts +0 -18
  320. package/typography/types.js +0 -5
  321. package/useTheme.d.ts +0 -2
  322. package/useTheme.js +0 -22
  323. package/useTranslatedLabels.d.ts +0 -2
  324. package/useTranslatedLabels.js +0 -20
  325. package/wizard/Wizard.d.ts +0 -4
  326. package/wizard/Wizard.js +0 -285
  327. package/wizard/Wizard.stories.tsx +0 -253
  328. package/wizard/Wizard.test.js +0 -141
  329. package/wizard/types.d.ts +0 -65
  330. package/wizard/types.js +0 -5
package/tabs/Tabs.js DELETED
@@ -1,467 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
-
14
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _react = _interopRequireWildcard(require("react"));
19
-
20
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
-
22
- var _variables = require("../common/variables.js");
23
-
24
- var _useTheme = _interopRequireDefault(require("../useTheme"));
25
-
26
- var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
27
-
28
- var _Tab = _interopRequireDefault(require("./Tab"));
29
-
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
31
-
32
- 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); }
33
-
34
- 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; }
35
-
36
- var arrowIcons = {
37
- left: /*#__PURE__*/_react["default"].createElement("svg", {
38
- focusable: "false",
39
- viewBox: "0 0 24 24",
40
- "aria-hidden": "true"
41
- }, /*#__PURE__*/_react["default"].createElement("path", {
42
- d: "M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
43
- })),
44
- right: /*#__PURE__*/_react["default"].createElement("svg", {
45
- focusable: "false",
46
- viewBox: "0 0 24 24",
47
- "aria-hidden": "true"
48
- }, /*#__PURE__*/_react["default"].createElement("path", {
49
- d: "M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
50
- }))
51
- };
52
-
53
- var useResize = function useResize(refTabList) {
54
- var _useState = (0, _react.useState)(0),
55
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
56
- viewWidth = _useState2[0],
57
- setViewWidth = _useState2[1];
58
-
59
- var handleWindowSizeChange = (0, _react.useCallback)(function () {
60
- var _refTabList$current;
61
-
62
- setViewWidth(refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current = refTabList.current) === null || _refTabList$current === void 0 ? void 0 : _refTabList$current.offsetWidth);
63
- }, [refTabList]);
64
- (0, _react.useEffect)(function () {
65
- window.addEventListener("load", handleWindowSizeChange);
66
- window.addEventListener("resize", handleWindowSizeChange);
67
- return function () {
68
- window.removeEventListener("load", handleWindowSizeChange);
69
- window.removeEventListener("resize", handleWindowSizeChange);
70
- };
71
- }, [handleWindowSizeChange]);
72
- return viewWidth;
73
- };
74
-
75
- var DxcTabs = function DxcTabs(_ref) {
76
- var defaultActiveTabIndex = _ref.defaultActiveTabIndex,
77
- activeTabIndex = _ref.activeTabIndex,
78
- tabs = _ref.tabs,
79
- onTabClick = _ref.onTabClick,
80
- onTabHover = _ref.onTabHover,
81
- margin = _ref.margin,
82
- _ref$iconPosition = _ref.iconPosition,
83
- iconPosition = _ref$iconPosition === void 0 ? "top" : _ref$iconPosition,
84
- _ref$tabIndex = _ref.tabIndex,
85
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
86
- var colorsTheme = (0, _useTheme["default"])();
87
- var hasLabelAndIcon = tabs && tabs.filter(function (tab) {
88
- return tab.label && tab.icon;
89
- }).length > 0;
90
- var firstFocus = tabs && tabs.findIndex(function (tab) {
91
- return !tab.isDisabled;
92
- });
93
-
94
- var _useState3 = (0, _react.useState)(tabs && defaultActiveTabIndex && !tabs[defaultActiveTabIndex].isDisabled ? defaultActiveTabIndex : firstFocus),
95
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
96
- innerActiveTabIndex = _useState4[0],
97
- setInnerActiveTabIndex = _useState4[1];
98
-
99
- var _useState5 = (0, _react.useState)(0),
100
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
101
- activeIndicatorWidth = _useState6[0],
102
- setActiveIndicatorWidth = _useState6[1];
103
-
104
- var _useState7 = (0, _react.useState)(0),
105
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
106
- activeIndicatorLeft = _useState8[0],
107
- setActiveIndicatorLeft = _useState8[1];
108
-
109
- var _useState9 = (0, _react.useState)(0),
110
- _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
111
- translateScroll = _useState10[0],
112
- setTranslateScroll = _useState10[1];
113
-
114
- var _useState11 = (0, _react.useState)(true),
115
- _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
116
- scrollRightEnabled = _useState12[0],
117
- setScrollRightEnabled = _useState12[1];
118
-
119
- var _useState13 = (0, _react.useState)(false),
120
- _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
121
- scrollLeftEnabled = _useState14[0],
122
- setScrollLeftEnabled = _useState14[1];
123
-
124
- var _useState15 = (0, _react.useState)(0),
125
- _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
126
- countClick = _useState16[0],
127
- setCountClick = _useState16[1];
128
-
129
- var _useState17 = (0, _react.useState)(0),
130
- _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
131
- totalTabsWidth = _useState18[0],
132
- setTotalTabsWidth = _useState18[1];
133
-
134
- var _useState19 = (0, _react.useState)(activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex),
135
- _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
136
- currentFocusIndex = _useState20[0],
137
- setCurrentFocusIndex = _useState20[1];
138
-
139
- var _useState21 = (0, _react.useState)(activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex),
140
- _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
141
- temporalFocusIndex = _useState22[0],
142
- setTemporalFocusIndex = _useState22[1];
143
-
144
- var _useState23 = (0, _react.useState)(0),
145
- _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
146
- minHeightTabs = _useState24[0],
147
- setMinHeightTabs = _useState24[1];
148
-
149
- var refTabs = (0, _react.useRef)([]);
150
- var refTabList = (0, _react.useRef)(null);
151
- var viewWidth = useResize(refTabList);
152
- var translatedLabels = (0, _useTranslatedLabels["default"])();
153
- var enabledIndicator = (0, _react.useMemo)(function () {
154
- return viewWidth < totalTabsWidth;
155
- }, [viewWidth]);
156
- (0, _react.useEffect)(function () {
157
- var _refTabs$current, _refTabs$current2, _refTabs$current3;
158
-
159
- var sumWidth = refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current = refTabs.current) === null || _refTabs$current === void 0 ? void 0 : _refTabs$current.reduce(function (count, obj) {
160
- return count + obj.offsetWidth;
161
- }, 0);
162
- setTotalTabsWidth(sumWidth);
163
- setActiveIndicatorWidth(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current2 = refTabs.current[activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex]) === null || _refTabs$current2 === void 0 ? void 0 : _refTabs$current2.offsetWidth);
164
- setActiveIndicatorLeft(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current3 = refTabs.current[activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex]) === null || _refTabs$current3 === void 0 ? void 0 : _refTabs$current3.offsetLeft);
165
- }, [refTabs]);
166
- (0, _react.useEffect)(function () {
167
- var _refTabList$current2;
168
-
169
- setMinHeightTabs((refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current2 = refTabList.current) === null || _refTabList$current2 === void 0 ? void 0 : _refTabList$current2.offsetHeight) + 1);
170
- }, [refTabList]);
171
- (0, _react.useEffect)(function () {
172
- if (activeTabIndex >= 0) {
173
- var _refTabs$current$acti, _refTabs$current$acti2;
174
-
175
- setActiveIndicatorWidth(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current$acti = refTabs.current[activeTabIndex]) === null || _refTabs$current$acti === void 0 ? void 0 : _refTabs$current$acti.offsetWidth);
176
- setActiveIndicatorLeft(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current$acti2 = refTabs.current[activeTabIndex]) === null || _refTabs$current$acti2 === void 0 ? void 0 : _refTabs$current$acti2.offsetLeft);
177
- }
178
- }, [activeTabIndex]);
179
-
180
- var handleSelected = function handleSelected(newValue) {
181
- activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : setInnerActiveTabIndex(newValue);
182
- onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(newValue);
183
-
184
- if (activeTabIndex === undefined) {
185
- var _refTabs$current$newV, _refTabs$current$newV2;
186
-
187
- setActiveIndicatorWidth(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current$newV = refTabs.current[newValue]) === null || _refTabs$current$newV === void 0 ? void 0 : _refTabs$current$newV.offsetWidth);
188
- setActiveIndicatorLeft(refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current$newV2 = refTabs.current[newValue]) === null || _refTabs$current$newV2 === void 0 ? void 0 : _refTabs$current$newV2.offsetLeft);
189
- }
190
- };
191
-
192
- var scrollLeft = function scrollLeft() {
193
- var _refTabList$current3;
194
-
195
- var scrollWidth = (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current3 = refTabList.current) === null || _refTabList$current3 === void 0 ? void 0 : _refTabList$current3.offsetWidth) * 0.75;
196
- var moveX;
197
-
198
- if (countClick <= scrollWidth) {
199
- moveX = 0;
200
- setScrollLeftEnabled(false);
201
- setScrollRightEnabled(true);
202
- } else {
203
- moveX = countClick - scrollWidth;
204
- setScrollRightEnabled(true);
205
- setScrollLeftEnabled(true);
206
- }
207
-
208
- setTranslateScroll(-moveX);
209
- setCountClick(moveX);
210
- };
211
-
212
- var scrollRight = function scrollRight() {
213
- var _refTabList$current4, _refTabList$current5;
214
-
215
- var scrollWidth = (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current4 = refTabList.current) === null || _refTabList$current4 === void 0 ? void 0 : _refTabList$current4.offsetWidth) * 0.75;
216
- var moveX;
217
-
218
- if (countClick + scrollWidth + (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current5 = refTabList.current) === null || _refTabList$current5 === void 0 ? void 0 : _refTabList$current5.offsetWidth) >= totalTabsWidth) {
219
- var _refTabList$current6;
220
-
221
- moveX = totalTabsWidth - (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current6 = refTabList.current) === null || _refTabList$current6 === void 0 ? void 0 : _refTabList$current6.offsetWidth);
222
- setScrollRightEnabled(false);
223
- setScrollLeftEnabled(true);
224
- } else {
225
- moveX = countClick + scrollWidth;
226
- setScrollLeftEnabled(true);
227
- setScrollRightEnabled(true);
228
- }
229
-
230
- setTranslateScroll(-moveX);
231
- setCountClick(moveX);
232
- };
233
-
234
- var setPreviousTabFocus = function setPreviousTabFocus() {
235
- setTemporalFocusIndex(function (temporalFocusIndex) {
236
- var index = temporalFocusIndex === 0 ? tabs.length - 1 : temporalFocusIndex - 1;
237
-
238
- while (tabs[index].isDisabled) {
239
- index = index === 0 ? tabs.length - 1 : index - 1;
240
- }
241
-
242
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[index].focus({
243
- preventScroll: true
244
- });
245
- setScrollFocus(index);
246
- return index;
247
- });
248
- };
249
-
250
- var setNextTabFocus = function setNextTabFocus() {
251
- setTemporalFocusIndex(function (temporalFocusIndex) {
252
- var index = temporalFocusIndex === tabs.length - 1 ? 0 : temporalFocusIndex + 1;
253
-
254
- while (tabs[index].isDisabled) {
255
- index = index === tabs.length - 1 ? 0 : index + 1;
256
- }
257
-
258
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[index].focus({
259
- preventScroll: true
260
- });
261
- setScrollFocus(index);
262
- return index;
263
- });
264
- };
265
-
266
- var setScrollFocus = function setScrollFocus(actualIndex) {
267
- var _refTabs$current4, _refTabList$current8;
268
-
269
- var sumPrev = 0;
270
- refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current4 = refTabs.current) === null || _refTabs$current4 === void 0 ? void 0 : _refTabs$current4.map(function (item, index) {
271
- if (index <= actualIndex) {
272
- sumPrev += item.offsetWidth;
273
- }
274
- });
275
- var moveX = 0;
276
-
277
- if (actualIndex === tabs.length - 1) {
278
- var _refTabList$current7;
279
-
280
- moveX = totalTabsWidth - (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current7 = refTabList.current) === null || _refTabList$current7 === void 0 ? void 0 : _refTabList$current7.offsetWidth);
281
- setScrollLeftEnabled(true);
282
- setScrollRightEnabled(false);
283
- } else if (sumPrev > (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current8 = refTabList.current) === null || _refTabList$current8 === void 0 ? void 0 : _refTabList$current8.offsetWidth)) {
284
- var _refTabList$current9;
285
-
286
- moveX = sumPrev - (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current9 = refTabList.current) === null || _refTabList$current9 === void 0 ? void 0 : _refTabList$current9.offsetWidth) + 1; //plus 1px for the outline
287
-
288
- setScrollLeftEnabled(true);
289
- setScrollRightEnabled(true);
290
- } else {
291
- setScrollLeftEnabled(false);
292
- setScrollRightEnabled(true);
293
- }
294
-
295
- setTranslateScroll(-moveX);
296
- setCountClick(moveX);
297
- };
298
-
299
- var handleOnKeyDown = function handleOnKeyDown(event) {
300
- switch (event.key) {
301
- case "Left":
302
- case "ArrowLeft":
303
- event.preventDefault();
304
- setPreviousTabFocus();
305
- break;
306
-
307
- case "Right":
308
- case "ArrowRight":
309
- event.preventDefault();
310
- setNextTabFocus();
311
- break;
312
-
313
- case "Enter":
314
- case " ":
315
- event.preventDefault();
316
- setCurrentFocusIndex(temporalFocusIndex);
317
- handleSelected(temporalFocusIndex);
318
- break;
319
-
320
- case "Tab":
321
- if (temporalFocusIndex !== currentFocusIndex) {
322
- event.preventDefault();
323
- setTemporalFocusIndex(currentFocusIndex);
324
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[currentFocusIndex].focus();
325
- }
326
-
327
- handleSelected(currentFocusIndex);
328
- break;
329
- }
330
- };
331
-
332
- var isTabActive = function isTabActive(index) {
333
- return activeTabIndex >= 0 ? activeTabIndex === index : innerActiveTabIndex === index;
334
- };
335
-
336
- var isActiveIndicatorDisabled = firstFocus === -1 || tabs && activeTabIndex >= 0 && tabs[activeTabIndex].isDisabled;
337
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
338
- theme: colorsTheme.tabs
339
- }, /*#__PURE__*/_react["default"].createElement(TabsContainer, {
340
- margin: margin
341
- }, /*#__PURE__*/_react["default"].createElement(Underline, null), /*#__PURE__*/_react["default"].createElement(Tabs, {
342
- hasLabelAndIcon: hasLabelAndIcon,
343
- iconPosition: iconPosition
344
- }, /*#__PURE__*/_react["default"].createElement(ScrollIndicator, {
345
- onClick: scrollLeft,
346
- scrollLeftEnabled: scrollLeftEnabled,
347
- enabled: enabledIndicator,
348
- "aria-disabled": !scrollLeftEnabled,
349
- "aria-label": translatedLabels.tabs.scrollLeft,
350
- tabIndex: scrollLeftEnabled ? tabIndex : -1,
351
- minHeightTabs: minHeightTabs
352
- }, arrowIcons.left), /*#__PURE__*/_react["default"].createElement(TabsContent, null, /*#__PURE__*/_react["default"].createElement(TabsContentScroll, {
353
- translateScroll: translateScroll,
354
- ref: refTabList,
355
- enabled: enabledIndicator
356
- }, /*#__PURE__*/_react["default"].createElement(TabList, {
357
- role: "tablist",
358
- onKeyDown: handleOnKeyDown,
359
- minHeightTabs: minHeightTabs
360
- }, tabs.map(function (tab, i) {
361
- return /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
362
- tab: tab,
363
- key: "tab".concat(i).concat(tab.label),
364
- active: isTabActive(i),
365
- tabIndex: isTabActive(i) && !tab.isDisabled ? tabIndex : -1,
366
- hasLabelAndIcon: hasLabelAndIcon,
367
- iconPosition: iconPosition,
368
- ref: function ref(el) {
369
- return refTabs.current[i] = el;
370
- },
371
- onClick: function onClick() {
372
- setCurrentFocusIndex(i);
373
- setTemporalFocusIndex(i);
374
- handleSelected(i);
375
- },
376
- onMouseEnter: function onMouseEnter() {
377
- onTabHover === null || onTabHover === void 0 ? void 0 : onTabHover(i);
378
- },
379
- onMouseLeave: function onMouseLeave() {
380
- onTabHover === null || onTabHover === void 0 ? void 0 : onTabHover(null);
381
- }
382
- });
383
- })), /*#__PURE__*/_react["default"].createElement(ActiveIndicator, {
384
- tabWidth: activeIndicatorWidth,
385
- tabLeft: activeIndicatorLeft,
386
- "aria-disabled": isActiveIndicatorDisabled
387
- }))), /*#__PURE__*/_react["default"].createElement(ScrollIndicator, {
388
- onClick: scrollRight,
389
- scrollRightEnabled: scrollRightEnabled,
390
- enabled: enabledIndicator,
391
- "aria-disabled": !scrollRightEnabled,
392
- "aria-label": translatedLabels.tabs.scrollRight,
393
- tabIndex: scrollRightEnabled ? tabIndex : -1,
394
- minHeightTabs: minHeightTabs
395
- }, arrowIcons.right))));
396
- };
397
-
398
- var Underline = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n height: ", ";\n background-color: ", ";\n"])), function (props) {
399
- return props.theme.dividerThickness;
400
- }, function (props) {
401
- return props.theme.dividerColor;
402
- });
403
-
404
- var TabsContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
405
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
406
- }, function (props) {
407
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
408
- }, function (props) {
409
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
410
- }, function (props) {
411
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
412
- }, function (props) {
413
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
414
- });
415
-
416
- var Tabs = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: ", ";\n height: ", ";\n display: flex;\n overflow: hidden;\n background-color: ", ";\n"])), function (props) {
417
- return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "48px" || "72px";
418
- }, function (props) {
419
- return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "48px" || "72px";
420
- }, function (props) {
421
- return props.theme.unselectedBackgroundColor;
422
- });
423
-
424
- var ScrollIndicator = _styledComponents["default"].button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: ", ";\n background-color: #ffffff;\n font-size: 1.25rem;\n min-width: ", ";\n height: ", "px;\n padding: 0;\n justify-content: center;\n cursor: pointer;\n border-bottom: solid ", " ", ";\n box-sizing: border-box;\n border: none;\n &:hover {\n background-color: ", ";\n }\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n &:active {\n background-color: ", ";\n }\n svg {\n height: 20px;\n width: 20px;\n align-self: center;\n fill: ", ";\n visibility: visible;\n }\n &[aria-disabled=\"true\"] {\n pointer-events: none;\n cursor: default;\n svg {\n visibility: hidden;\n }\n &:focus {\n outline: none;\n }\n &:hover,\n &:active {\n background-color: transparent !important;\n }\n }\n"])), function (props) {
425
- return props.enabled ? "flex" : "none";
426
- }, function (props) {
427
- return props.theme.scrollButtonsWidth;
428
- }, function (props) {
429
- return props.minHeightTabs - 1;
430
- }, function (props) {
431
- return props.theme.dividerThickness;
432
- }, function (props) {
433
- return props.theme.dividerColor;
434
- }, function (props) {
435
- return "".concat(props.theme.hoverBackgroundColor, " !important");
436
- }, function (props) {
437
- return props.theme.focusOutline;
438
- }, function (props) {
439
- return "".concat(props.theme.pressedBackgroundColor, " !important");
440
- }, function (props) {
441
- return props.theme.unselectedFontColor;
442
- });
443
-
444
- var ActiveIndicator = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n left: ", ";\n width: ", ";\n background-color: ", ";\n bottom: 0;\n height: ", ";\n position: absolute;\n &[aria-disabled=\"true\"] {\n background-color: ", ";\n display: none;\n }\n"])), function (props) {
445
- return "".concat(props.tabLeft, "px");
446
- }, function (props) {
447
- return "".concat(props.tabWidth, "px");
448
- }, function (props) {
449
- return props.theme.selectedUnderlineColor;
450
- }, function (props) {
451
- return props.theme.selectedUnderlineThickness;
452
- }, function (props) {
453
- return props.theme.disabledFontColor;
454
- });
455
-
456
- var TabsContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex: 1 1 auto;\n display: inline-block;\n position: relative;\n white-space: nowrap;\n overflow-x: scroll;\n ::-webkit-scrollbar {\n display: none;\n }\n"])));
457
-
458
- var TabList = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n min-height: ", "px;\n"])), function (props) {
459
- return props.minHeightTabs;
460
- });
461
-
462
- var TabsContentScroll = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n ", ";\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n"])), function (props) {
463
- return props.enabled ? "transform: translateX(".concat(props.translateScroll, "px)") : "transform: translateX(0px)";
464
- });
465
-
466
- var _default = DxcTabs;
467
- exports["default"] = _default;