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

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 (380) hide show
  1. package/README.md +1 -2
  2. package/dist/index.d.mts +6581 -0
  3. package/dist/index.d.ts +6581 -0
  4. package/dist/index.js +14078 -0
  5. package/dist/index.mjs +14020 -0
  6. package/package.json +68 -68
  7. package/BackgroundColorContext.d.ts +0 -1
  8. package/BackgroundColorContext.js +0 -30
  9. package/HalstackContext.d.ts +0 -1249
  10. package/HalstackContext.js +0 -310
  11. package/accordion/Accordion.d.ts +0 -4
  12. package/accordion/Accordion.js +0 -169
  13. package/accordion/Accordion.stories.tsx +0 -252
  14. package/accordion/Accordion.test.js +0 -56
  15. package/accordion/types.d.ts +0 -57
  16. package/accordion/types.js +0 -5
  17. package/accordion-group/AccordionGroup.d.ts +0 -7
  18. package/accordion-group/AccordionGroup.js +0 -101
  19. package/accordion-group/AccordionGroup.stories.tsx +0 -252
  20. package/accordion-group/AccordionGroup.test.js +0 -98
  21. package/accordion-group/AccordionGroupAccordion.d.ts +0 -4
  22. package/accordion-group/AccordionGroupAccordion.js +0 -31
  23. package/accordion-group/AccordionGroupContext.d.ts +0 -3
  24. package/accordion-group/AccordionGroupContext.js +0 -8
  25. package/accordion-group/types.d.ts +0 -67
  26. package/accordion-group/types.js +0 -5
  27. package/action-icon/ActionIcon.d.ts +0 -4
  28. package/action-icon/ActionIcon.js +0 -48
  29. package/action-icon/ActionIcon.stories.tsx +0 -41
  30. package/action-icon/ActionIcon.test.js +0 -64
  31. package/action-icon/types.d.ts +0 -26
  32. package/action-icon/types.js +0 -5
  33. package/alert/Alert.d.ts +0 -4
  34. package/alert/Alert.js +0 -200
  35. package/alert/Alert.stories.tsx +0 -198
  36. package/alert/Alert.test.js +0 -75
  37. package/alert/types.d.ts +0 -49
  38. package/alert/types.js +0 -5
  39. package/badge/Badge.d.ts +0 -4
  40. package/badge/Badge.js +0 -159
  41. package/badge/Badge.stories.tsx +0 -210
  42. package/badge/Badge.test.js +0 -30
  43. package/badge/types.d.ts +0 -54
  44. package/badge/types.js +0 -5
  45. package/bleed/Bleed.d.ts +0 -3
  46. package/bleed/Bleed.js +0 -43
  47. package/bleed/Bleed.stories.tsx +0 -342
  48. package/bleed/types.d.ts +0 -37
  49. package/bleed/types.js +0 -5
  50. package/box/Box.d.ts +0 -4
  51. package/box/Box.js +0 -75
  52. package/box/Box.stories.tsx +0 -119
  53. package/box/Box.test.js +0 -13
  54. package/box/types.d.ts +0 -32
  55. package/box/types.js +0 -5
  56. package/bulleted-list/BulletedList.d.ts +0 -7
  57. package/bulleted-list/BulletedList.js +0 -92
  58. package/bulleted-list/BulletedList.stories.tsx +0 -115
  59. package/bulleted-list/types.d.ts +0 -38
  60. package/bulleted-list/types.js +0 -5
  61. package/button/Button.d.ts +0 -4
  62. package/button/Button.js +0 -121
  63. package/button/Button.stories.tsx +0 -326
  64. package/button/Button.test.js +0 -38
  65. package/button/types.d.ts +0 -57
  66. package/button/types.js +0 -5
  67. package/card/Card.d.ts +0 -4
  68. package/card/Card.js +0 -120
  69. package/card/Card.stories.tsx +0 -171
  70. package/card/Card.test.js +0 -39
  71. package/card/types.d.ts +0 -62
  72. package/card/types.js +0 -5
  73. package/checkbox/Checkbox.d.ts +0 -4
  74. package/checkbox/Checkbox.js +0 -215
  75. package/checkbox/Checkbox.stories.tsx +0 -222
  76. package/checkbox/Checkbox.test.js +0 -199
  77. package/checkbox/types.d.ts +0 -72
  78. package/checkbox/types.js +0 -5
  79. package/chip/Chip.d.ts +0 -4
  80. package/chip/Chip.js +0 -121
  81. package/chip/Chip.stories.tsx +0 -214
  82. package/chip/Chip.test.js +0 -41
  83. package/chip/types.d.ts +0 -45
  84. package/chip/types.js +0 -5
  85. package/common/coreTokens.d.ts +0 -237
  86. package/common/coreTokens.js +0 -184
  87. package/common/utils.d.ts +0 -1
  88. package/common/utils.js +0 -16
  89. package/common/variables.d.ts +0 -1395
  90. package/common/variables.js +0 -1267
  91. package/container/Container.d.ts +0 -4
  92. package/container/Container.js +0 -194
  93. package/container/Container.stories.tsx +0 -214
  94. package/container/types.d.ts +0 -74
  95. package/container/types.js +0 -5
  96. package/contextual-menu/ContextualMenu.d.ts +0 -7
  97. package/contextual-menu/ContextualMenu.js +0 -71
  98. package/contextual-menu/ContextualMenu.stories.tsx +0 -182
  99. package/contextual-menu/ContextualMenu.test.js +0 -71
  100. package/contextual-menu/MenuItemAction.d.ts +0 -4
  101. package/contextual-menu/MenuItemAction.js +0 -46
  102. package/contextual-menu/types.d.ts +0 -22
  103. package/contextual-menu/types.js +0 -5
  104. package/date-input/Calendar.d.ts +0 -4
  105. package/date-input/Calendar.js +0 -214
  106. package/date-input/DateInput.d.ts +0 -4
  107. package/date-input/DateInput.js +0 -223
  108. package/date-input/DateInput.stories.tsx +0 -285
  109. package/date-input/DateInput.test.js +0 -808
  110. package/date-input/DatePicker.d.ts +0 -4
  111. package/date-input/DatePicker.js +0 -115
  112. package/date-input/Icons.d.ts +0 -6
  113. package/date-input/Icons.js +0 -58
  114. package/date-input/YearPicker.d.ts +0 -4
  115. package/date-input/YearPicker.js +0 -100
  116. package/date-input/types.d.ts +0 -164
  117. package/date-input/types.js +0 -5
  118. package/dialog/Dialog.d.ts +0 -4
  119. package/dialog/Dialog.js +0 -104
  120. package/dialog/Dialog.stories.tsx +0 -365
  121. package/dialog/Dialog.test.js +0 -307
  122. package/dialog/types.d.ts +0 -36
  123. package/dialog/types.js +0 -5
  124. package/divider/Divider.d.ts +0 -4
  125. package/divider/Divider.js +0 -36
  126. package/divider/Divider.stories.tsx +0 -223
  127. package/divider/Divider.test.js +0 -38
  128. package/divider/types.d.ts +0 -21
  129. package/divider/types.js +0 -5
  130. package/dropdown/Dropdown.d.ts +0 -4
  131. package/dropdown/Dropdown.js +0 -319
  132. package/dropdown/Dropdown.stories.tsx +0 -427
  133. package/dropdown/Dropdown.test.js +0 -599
  134. package/dropdown/DropdownMenu.d.ts +0 -4
  135. package/dropdown/DropdownMenu.js +0 -63
  136. package/dropdown/DropdownMenuItem.d.ts +0 -4
  137. package/dropdown/DropdownMenuItem.js +0 -70
  138. package/dropdown/types.d.ts +0 -96
  139. package/dropdown/types.js +0 -5
  140. package/file-input/FileInput.d.ts +0 -4
  141. package/file-input/FileInput.js +0 -479
  142. package/file-input/FileInput.stories.tsx +0 -618
  143. package/file-input/FileInput.test.js +0 -459
  144. package/file-input/FileItem.d.ts +0 -4
  145. package/file-input/FileItem.js +0 -135
  146. package/file-input/types.d.ts +0 -129
  147. package/file-input/types.js +0 -5
  148. package/flex/Flex.d.ts +0 -4
  149. package/flex/Flex.js +0 -57
  150. package/flex/Flex.stories.tsx +0 -112
  151. package/flex/types.d.ts +0 -97
  152. package/flex/types.js +0 -5
  153. package/footer/Footer.d.ts +0 -4
  154. package/footer/Footer.js +0 -138
  155. package/footer/Footer.stories.tsx +0 -171
  156. package/footer/Footer.test.js +0 -85
  157. package/footer/Icons.d.ts +0 -3
  158. package/footer/Icons.js +0 -136
  159. package/footer/types.d.ts +0 -64
  160. package/footer/types.js +0 -5
  161. package/grid/Grid.d.ts +0 -7
  162. package/grid/Grid.js +0 -76
  163. package/grid/Grid.stories.tsx +0 -219
  164. package/grid/types.d.ts +0 -115
  165. package/grid/types.js +0 -5
  166. package/header/Header.d.ts +0 -8
  167. package/header/Header.js +0 -220
  168. package/header/Header.stories.tsx +0 -251
  169. package/header/Header.test.js +0 -66
  170. package/header/Icons.d.ts +0 -2
  171. package/header/Icons.js +0 -29
  172. package/header/types.d.ts +0 -33
  173. package/header/types.js +0 -5
  174. package/heading/Heading.d.ts +0 -4
  175. package/heading/Heading.js +0 -137
  176. package/heading/Heading.stories.tsx +0 -54
  177. package/heading/Heading.test.js +0 -169
  178. package/heading/types.d.ts +0 -33
  179. package/heading/types.js +0 -5
  180. package/icon/Icon.d.ts +0 -4
  181. package/icon/Icon.js +0 -33
  182. package/icon/Icon.stories.tsx +0 -28
  183. package/icon/types.d.ts +0 -4
  184. package/icon/types.js +0 -5
  185. package/image/Image.d.ts +0 -4
  186. package/image/Image.js +0 -70
  187. package/image/Image.stories.tsx +0 -129
  188. package/image/types.d.ts +0 -72
  189. package/image/types.js +0 -5
  190. package/inset/Inset.d.ts +0 -3
  191. package/inset/Inset.js +0 -43
  192. package/inset/Inset.stories.tsx +0 -230
  193. package/inset/types.d.ts +0 -37
  194. package/inset/types.js +0 -5
  195. package/layout/ApplicationLayout.d.ts +0 -20
  196. package/layout/ApplicationLayout.js +0 -134
  197. package/layout/ApplicationLayout.stories.tsx +0 -162
  198. package/layout/Icons.d.ts +0 -8
  199. package/layout/Icons.js +0 -58
  200. package/layout/types.d.ts +0 -41
  201. package/layout/types.js +0 -5
  202. package/link/Link.d.ts +0 -4
  203. package/link/Link.js +0 -115
  204. package/link/Link.stories.tsx +0 -253
  205. package/link/Link.test.js +0 -63
  206. package/link/types.d.ts +0 -54
  207. package/link/types.js +0 -5
  208. package/main.d.ts +0 -49
  209. package/main.js +0 -357
  210. package/nav-tabs/NavTabs.d.ts +0 -7
  211. package/nav-tabs/NavTabs.js +0 -93
  212. package/nav-tabs/NavTabs.stories.tsx +0 -276
  213. package/nav-tabs/NavTabs.test.js +0 -76
  214. package/nav-tabs/NavTabsContext.d.ts +0 -3
  215. package/nav-tabs/NavTabsContext.js +0 -8
  216. package/nav-tabs/Tab.d.ts +0 -4
  217. package/nav-tabs/Tab.js +0 -118
  218. package/nav-tabs/types.d.ts +0 -52
  219. package/nav-tabs/types.js +0 -5
  220. package/number-input/NumberInput.d.ts +0 -4
  221. package/number-input/NumberInput.js +0 -86
  222. package/number-input/NumberInput.stories.tsx +0 -131
  223. package/number-input/NumberInput.test.js +0 -989
  224. package/number-input/NumberInputContext.d.ts +0 -3
  225. package/number-input/NumberInputContext.js +0 -8
  226. package/number-input/types.d.ts +0 -136
  227. package/number-input/types.js +0 -5
  228. package/paginator/Icons.d.ts +0 -5
  229. package/paginator/Icons.js +0 -40
  230. package/paginator/Paginator.d.ts +0 -4
  231. package/paginator/Paginator.js +0 -135
  232. package/paginator/Paginator.stories.tsx +0 -87
  233. package/paginator/Paginator.test.js +0 -335
  234. package/paginator/types.d.ts +0 -38
  235. package/paginator/types.js +0 -5
  236. package/paragraph/Paragraph.d.ts +0 -5
  237. package/paragraph/Paragraph.js +0 -22
  238. package/paragraph/Paragraph.stories.tsx +0 -27
  239. package/password-input/Icons.d.ts +0 -6
  240. package/password-input/Icons.js +0 -35
  241. package/password-input/PasswordInput.d.ts +0 -4
  242. package/password-input/PasswordInput.js +0 -97
  243. package/password-input/PasswordInput.stories.tsx +0 -99
  244. package/password-input/PasswordInput.test.js +0 -198
  245. package/password-input/types.d.ts +0 -111
  246. package/password-input/types.js +0 -5
  247. package/progress-bar/ProgressBar.d.ts +0 -4
  248. package/progress-bar/ProgressBar.js +0 -144
  249. package/progress-bar/ProgressBar.stories.tsx +0 -93
  250. package/progress-bar/ProgressBar.test.js +0 -93
  251. package/progress-bar/types.d.ts +0 -37
  252. package/progress-bar/types.js +0 -5
  253. package/quick-nav/QuickNav.d.ts +0 -4
  254. package/quick-nav/QuickNav.js +0 -94
  255. package/quick-nav/QuickNav.stories.tsx +0 -356
  256. package/quick-nav/types.d.ts +0 -21
  257. package/quick-nav/types.js +0 -5
  258. package/radio-group/Radio.d.ts +0 -4
  259. package/radio-group/Radio.js +0 -124
  260. package/radio-group/RadioGroup.d.ts +0 -4
  261. package/radio-group/RadioGroup.js +0 -235
  262. package/radio-group/RadioGroup.stories.tsx +0 -214
  263. package/radio-group/RadioGroup.test.js +0 -756
  264. package/radio-group/types.d.ts +0 -114
  265. package/radio-group/types.js +0 -5
  266. package/resultset-table/Icons.d.ts +0 -7
  267. package/resultset-table/Icons.js +0 -47
  268. package/resultset-table/ResultsetTable.d.ts +0 -7
  269. package/resultset-table/ResultsetTable.js +0 -170
  270. package/resultset-table/ResultsetTable.stories.tsx +0 -401
  271. package/resultset-table/ResultsetTable.test.js +0 -381
  272. package/resultset-table/types.d.ts +0 -100
  273. package/resultset-table/types.js +0 -5
  274. package/select/Icons.d.ts +0 -10
  275. package/select/Icons.js +0 -89
  276. package/select/Listbox.d.ts +0 -4
  277. package/select/Listbox.js +0 -143
  278. package/select/Option.d.ts +0 -4
  279. package/select/Option.js +0 -87
  280. package/select/Select.d.ts +0 -4
  281. package/select/Select.js +0 -590
  282. package/select/Select.stories.tsx +0 -971
  283. package/select/Select.test.js +0 -2370
  284. package/select/types.d.ts +0 -209
  285. package/select/types.js +0 -5
  286. package/sidenav/Icons.d.ts +0 -7
  287. package/sidenav/Icons.js +0 -47
  288. package/sidenav/Sidenav.d.ts +0 -10
  289. package/sidenav/Sidenav.js +0 -197
  290. package/sidenav/Sidenav.stories.tsx +0 -282
  291. package/sidenav/Sidenav.test.js +0 -37
  292. package/sidenav/SidenavContext.d.ts +0 -5
  293. package/sidenav/SidenavContext.js +0 -13
  294. package/sidenav/types.d.ts +0 -76
  295. package/sidenav/types.js +0 -5
  296. package/slider/Slider.d.ts +0 -4
  297. package/slider/Slider.js +0 -285
  298. package/slider/Slider.test.js +0 -254
  299. package/slider/types.d.ts +0 -86
  300. package/slider/types.js +0 -5
  301. package/spinner/Spinner.d.ts +0 -4
  302. package/spinner/Spinner.js +0 -206
  303. package/spinner/Spinner.stories.tsx +0 -129
  304. package/spinner/Spinner.test.js +0 -55
  305. package/spinner/types.d.ts +0 -32
  306. package/spinner/types.js +0 -5
  307. package/status-light/StatusLight.d.ts +0 -4
  308. package/status-light/StatusLight.js +0 -51
  309. package/status-light/StatusLight.stories.tsx +0 -74
  310. package/status-light/StatusLight.test.js +0 -25
  311. package/status-light/types.d.ts +0 -17
  312. package/status-light/types.js +0 -5
  313. package/switch/Switch.d.ts +0 -4
  314. package/switch/Switch.js +0 -214
  315. package/switch/Switch.stories.tsx +0 -137
  316. package/switch/Switch.test.js +0 -180
  317. package/switch/types.d.ts +0 -66
  318. package/switch/types.js +0 -5
  319. package/table/DropdownTheme.js +0 -62
  320. package/table/Table.d.ts +0 -8
  321. package/table/Table.js +0 -161
  322. package/table/Table.stories.tsx +0 -651
  323. package/table/Table.test.js +0 -113
  324. package/table/types.d.ts +0 -49
  325. package/table/types.js +0 -5
  326. package/tabs/Tab.d.ts +0 -4
  327. package/tabs/Tab.js +0 -116
  328. package/tabs/Tabs.d.ts +0 -4
  329. package/tabs/Tabs.js +0 -384
  330. package/tabs/Tabs.stories.tsx +0 -226
  331. package/tabs/Tabs.test.js +0 -294
  332. package/tabs/types.d.ts +0 -92
  333. package/tabs/types.js +0 -5
  334. package/tag/Tag.d.ts +0 -4
  335. package/tag/Tag.js +0 -151
  336. package/tag/Tag.stories.tsx +0 -155
  337. package/tag/Tag.test.js +0 -49
  338. package/tag/types.d.ts +0 -69
  339. package/tag/types.js +0 -5
  340. package/text-input/Suggestion.d.ts +0 -4
  341. package/text-input/Suggestion.js +0 -67
  342. package/text-input/Suggestions.d.ts +0 -4
  343. package/text-input/Suggestions.js +0 -86
  344. package/text-input/TextInput.d.ts +0 -4
  345. package/text-input/TextInput.js +0 -567
  346. package/text-input/TextInput.stories.tsx +0 -465
  347. package/text-input/TextInput.test.js +0 -1756
  348. package/text-input/types.d.ts +0 -205
  349. package/text-input/types.js +0 -5
  350. package/textarea/Textarea.d.ts +0 -4
  351. package/textarea/Textarea.js +0 -234
  352. package/textarea/Textarea.stories.tsx +0 -174
  353. package/textarea/Textarea.test.js +0 -406
  354. package/textarea/types.d.ts +0 -141
  355. package/textarea/types.js +0 -5
  356. package/toggle-group/ToggleGroup.d.ts +0 -4
  357. package/toggle-group/ToggleGroup.js +0 -201
  358. package/toggle-group/ToggleGroup.stories.tsx +0 -218
  359. package/toggle-group/ToggleGroup.test.js +0 -137
  360. package/toggle-group/types.d.ts +0 -114
  361. package/toggle-group/types.js +0 -5
  362. package/typography/Typography.d.ts +0 -4
  363. package/typography/Typography.js +0 -23
  364. package/typography/Typography.stories.tsx +0 -198
  365. package/typography/types.d.ts +0 -18
  366. package/typography/types.js +0 -5
  367. package/useTheme.d.ts +0 -1148
  368. package/useTheme.js +0 -15
  369. package/useTranslatedLabels.d.ts +0 -85
  370. package/useTranslatedLabels.js +0 -14
  371. package/utils/BaseTypography.d.ts +0 -21
  372. package/utils/BaseTypography.js +0 -94
  373. package/utils/FocusLock.d.ts +0 -13
  374. package/utils/FocusLock.js +0 -124
  375. package/wizard/Wizard.d.ts +0 -4
  376. package/wizard/Wizard.js +0 -250
  377. package/wizard/Wizard.stories.tsx +0 -253
  378. package/wizard/Wizard.test.js +0 -114
  379. package/wizard/types.d.ts +0 -64
  380. package/wizard/types.js +0 -5
package/tabs/Tabs.js DELETED
@@ -1,384 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof3 = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
14
- var _variables = require("../common/variables");
15
- var _useTheme = _interopRequireDefault(require("../useTheme"));
16
- var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
17
- var _Tab = _interopRequireDefault(require("./Tab"));
18
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
19
- 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); }
20
- 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; }
21
- var arrowIcons = {
22
- left: /*#__PURE__*/_react["default"].createElement("svg", {
23
- focusable: "false",
24
- viewBox: "0 0 24 24",
25
- "aria-hidden": "true"
26
- }, /*#__PURE__*/_react["default"].createElement("path", {
27
- d: "M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
28
- })),
29
- right: /*#__PURE__*/_react["default"].createElement("svg", {
30
- focusable: "false",
31
- viewBox: "0 0 24 24",
32
- "aria-hidden": "true"
33
- }, /*#__PURE__*/_react["default"].createElement("path", {
34
- d: "M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
35
- }))
36
- };
37
- var useResize = function useResize(refTabList) {
38
- var _useState = (0, _react.useState)(0),
39
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
40
- viewWidth = _useState2[0],
41
- setViewWidth = _useState2[1];
42
- var handleWindowSizeChange = (0, _react.useCallback)(function () {
43
- var _refTabList$current$o, _refTabList$current;
44
- setViewWidth((_refTabList$current$o = refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current = refTabList.current) === null || _refTabList$current === void 0 ? void 0 : _refTabList$current.offsetWidth) !== null && _refTabList$current$o !== void 0 ? _refTabList$current$o : 0);
45
- }, [refTabList]);
46
- (0, _react.useEffect)(function () {
47
- handleWindowSizeChange();
48
- window.addEventListener("resize", handleWindowSizeChange);
49
- return function () {
50
- window.removeEventListener("resize", handleWindowSizeChange);
51
- };
52
- }, [handleWindowSizeChange]);
53
- return viewWidth;
54
- };
55
- var DxcTabs = function DxcTabs(_ref) {
56
- var defaultActiveTabIndex = _ref.defaultActiveTabIndex,
57
- activeTabIndex = _ref.activeTabIndex,
58
- tabs = _ref.tabs,
59
- onTabClick = _ref.onTabClick,
60
- onTabHover = _ref.onTabHover,
61
- margin = _ref.margin,
62
- _ref$iconPosition = _ref.iconPosition,
63
- iconPosition = _ref$iconPosition === void 0 ? "top" : _ref$iconPosition,
64
- _ref$tabIndex = _ref.tabIndex,
65
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
66
- var colorsTheme = (0, _useTheme["default"])();
67
- var hasLabelAndIcon = tabs && tabs.filter(function (tab) {
68
- return tab.label && tab.icon;
69
- }).length > 0;
70
- var firstFocus = tabs && tabs.findIndex(function (tab) {
71
- return !tab.isDisabled;
72
- });
73
- var _useState3 = (0, _react.useState)(tabs && defaultActiveTabIndex && !tabs[defaultActiveTabIndex].isDisabled ? defaultActiveTabIndex : firstFocus),
74
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
75
- innerActiveTabIndex = _useState4[0],
76
- setInnerActiveTabIndex = _useState4[1];
77
- var _useState5 = (0, _react.useState)(0),
78
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
79
- activeIndicatorWidth = _useState6[0],
80
- setActiveIndicatorWidth = _useState6[1];
81
- var _useState7 = (0, _react.useState)(0),
82
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
83
- activeIndicatorLeft = _useState8[0],
84
- setActiveIndicatorLeft = _useState8[1];
85
- var _useState9 = (0, _react.useState)(0),
86
- _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
87
- translateScroll = _useState10[0],
88
- setTranslateScroll = _useState10[1];
89
- var _useState11 = (0, _react.useState)(true),
90
- _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
91
- scrollRightEnabled = _useState12[0],
92
- setScrollRightEnabled = _useState12[1];
93
- var _useState13 = (0, _react.useState)(false),
94
- _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
95
- scrollLeftEnabled = _useState14[0],
96
- setScrollLeftEnabled = _useState14[1];
97
- var _useState15 = (0, _react.useState)(0),
98
- _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
99
- countClick = _useState16[0],
100
- setCountClick = _useState16[1];
101
- var _useState17 = (0, _react.useState)(0),
102
- _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
103
- totalTabsWidth = _useState18[0],
104
- setTotalTabsWidth = _useState18[1];
105
- var _useState19 = (0, _react.useState)(activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex),
106
- _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
107
- currentFocusIndex = _useState20[0],
108
- setCurrentFocusIndex = _useState20[1];
109
- var _useState21 = (0, _react.useState)(activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : innerActiveTabIndex),
110
- _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
111
- temporalFocusIndex = _useState22[0],
112
- setTemporalFocusIndex = _useState22[1];
113
- var _useState23 = (0, _react.useState)(0),
114
- _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
115
- minHeightTabs = _useState24[0],
116
- setMinHeightTabs = _useState24[1];
117
- var refTabs = (0, _react.useRef)([]);
118
- var refTabList = (0, _react.useRef)(null);
119
- var viewWidth = useResize(refTabList);
120
- var translatedLabels = (0, _useTranslatedLabels["default"])();
121
- var enabledIndicator = (0, _react.useMemo)(function () {
122
- return viewWidth < totalTabsWidth;
123
- }, [viewWidth]);
124
- (0, _react.useEffect)(function () {
125
- var _refTabs$current, _refTabs$current2, _refTabs$current3;
126
- 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) {
127
- return count + obj.offsetWidth;
128
- }, 0);
129
- setTotalTabsWidth(sumWidth);
130
- 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);
131
- 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);
132
- }, [refTabs]);
133
- (0, _react.useEffect)(function () {
134
- var _refTabList$current2;
135
- setMinHeightTabs((refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current2 = refTabList.current) === null || _refTabList$current2 === void 0 ? void 0 : _refTabList$current2.offsetHeight) + 1);
136
- }, [refTabList]);
137
- (0, _react.useEffect)(function () {
138
- if (activeTabIndex >= 0) {
139
- var _refTabs$current$acti, _refTabs$current$acti2;
140
- 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);
141
- 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);
142
- }
143
- }, [activeTabIndex]);
144
- var handleSelected = function handleSelected(newValue) {
145
- activeTabIndex !== null && activeTabIndex !== void 0 ? activeTabIndex : setInnerActiveTabIndex(newValue);
146
- onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(newValue);
147
- if (activeTabIndex === undefined) {
148
- var _refTabs$current$newV, _refTabs$current$newV2;
149
- 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);
150
- 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);
151
- }
152
- };
153
- var scrollLeft = function scrollLeft() {
154
- var _refTabList$current3;
155
- 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;
156
- var moveX = 0;
157
- if (countClick <= scrollWidth) {
158
- moveX = 0;
159
- setScrollLeftEnabled(false);
160
- setScrollRightEnabled(true);
161
- } else {
162
- moveX = countClick - scrollWidth;
163
- setScrollRightEnabled(true);
164
- setScrollLeftEnabled(true);
165
- }
166
- setTranslateScroll(-moveX);
167
- setCountClick(moveX);
168
- };
169
- var scrollRight = function scrollRight() {
170
- var _refTabList$current4, _refTabList$current5;
171
- 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;
172
- var moveX = 0;
173
- 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) {
174
- var _refTabList$current6;
175
- moveX = totalTabsWidth - (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current6 = refTabList.current) === null || _refTabList$current6 === void 0 ? void 0 : _refTabList$current6.offsetWidth);
176
- setScrollRightEnabled(false);
177
- setScrollLeftEnabled(true);
178
- } else {
179
- moveX = countClick + scrollWidth;
180
- setScrollLeftEnabled(true);
181
- setScrollRightEnabled(true);
182
- }
183
- setTranslateScroll(-moveX);
184
- setCountClick(moveX);
185
- };
186
- var setPreviousTabFocus = function setPreviousTabFocus() {
187
- setTemporalFocusIndex(function (temporalFocusIndex) {
188
- var index = temporalFocusIndex === 0 ? tabs.length - 1 : temporalFocusIndex - 1;
189
- while (tabs[index].isDisabled) {
190
- index = index === 0 ? tabs.length - 1 : index - 1;
191
- }
192
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[index].focus({
193
- preventScroll: true
194
- });
195
- setScrollFocus(index);
196
- return index;
197
- });
198
- };
199
- var setNextTabFocus = function setNextTabFocus() {
200
- setTemporalFocusIndex(function (temporalFocusIndex) {
201
- var index = temporalFocusIndex === tabs.length - 1 ? 0 : temporalFocusIndex + 1;
202
- while (tabs[index].isDisabled) {
203
- index = index === tabs.length - 1 ? 0 : index + 1;
204
- }
205
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[index].focus({
206
- preventScroll: true
207
- });
208
- setScrollFocus(index);
209
- return index;
210
- });
211
- };
212
- var setScrollFocus = function setScrollFocus(actualIndex) {
213
- var _refTabs$current4, _refTabList$current8;
214
- var sumPrev = 0;
215
- refTabs === null || refTabs === void 0 ? void 0 : (_refTabs$current4 = refTabs.current) === null || _refTabs$current4 === void 0 ? void 0 : _refTabs$current4.map(function (item, index) {
216
- if (index <= actualIndex) {
217
- sumPrev += item.offsetWidth;
218
- }
219
- });
220
- var moveX = 0;
221
- if (actualIndex === tabs.length - 1) {
222
- var _refTabList$current7;
223
- moveX = totalTabsWidth - (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current7 = refTabList.current) === null || _refTabList$current7 === void 0 ? void 0 : _refTabList$current7.offsetWidth);
224
- setScrollLeftEnabled(true);
225
- setScrollRightEnabled(false);
226
- } else if (sumPrev > (refTabList === null || refTabList === void 0 ? void 0 : (_refTabList$current8 = refTabList.current) === null || _refTabList$current8 === void 0 ? void 0 : _refTabList$current8.offsetWidth)) {
227
- var _refTabList$current9;
228
- 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
229
- setScrollLeftEnabled(true);
230
- setScrollRightEnabled(true);
231
- } else {
232
- setScrollLeftEnabled(false);
233
- setScrollRightEnabled(true);
234
- }
235
- setTranslateScroll(-moveX);
236
- setCountClick(moveX);
237
- };
238
- var handleOnKeyDown = function handleOnKeyDown(event) {
239
- switch (event.key) {
240
- case "Left":
241
- case "ArrowLeft":
242
- event.preventDefault();
243
- setPreviousTabFocus();
244
- break;
245
- case "Right":
246
- case "ArrowRight":
247
- event.preventDefault();
248
- setNextTabFocus();
249
- break;
250
- case "Enter":
251
- case " ":
252
- event.preventDefault();
253
- setCurrentFocusIndex(temporalFocusIndex);
254
- handleSelected(temporalFocusIndex);
255
- break;
256
- case "Tab":
257
- if (temporalFocusIndex !== currentFocusIndex) {
258
- event.preventDefault();
259
- setTemporalFocusIndex(currentFocusIndex);
260
- refTabs === null || refTabs === void 0 ? void 0 : refTabs.current[currentFocusIndex].focus();
261
- }
262
- handleSelected(currentFocusIndex);
263
- break;
264
- }
265
- };
266
- var isTabActive = function isTabActive(index) {
267
- return activeTabIndex >= 0 ? activeTabIndex === index : innerActiveTabIndex === index;
268
- };
269
- var isActiveIndicatorDisabled = firstFocus === -1 || tabs && activeTabIndex >= 0 && tabs[activeTabIndex].isDisabled;
270
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
271
- theme: colorsTheme.tabs
272
- }, /*#__PURE__*/_react["default"].createElement(TabsContainer, {
273
- margin: margin
274
- }, /*#__PURE__*/_react["default"].createElement(Underline, null), /*#__PURE__*/_react["default"].createElement(Tabs, {
275
- hasLabelAndIcon: hasLabelAndIcon,
276
- iconPosition: iconPosition
277
- }, /*#__PURE__*/_react["default"].createElement(ScrollIndicator, {
278
- onClick: scrollLeft,
279
- enabled: enabledIndicator,
280
- disabled: !scrollLeftEnabled,
281
- "aria-label": translatedLabels.tabs.scrollLeft,
282
- tabIndex: scrollLeftEnabled ? tabIndex : -1,
283
- minHeightTabs: minHeightTabs
284
- }, arrowIcons.left), /*#__PURE__*/_react["default"].createElement(TabsContent, null, /*#__PURE__*/_react["default"].createElement(TabsContentScroll, {
285
- translateScroll: translateScroll,
286
- ref: refTabList,
287
- enabled: enabledIndicator
288
- }, /*#__PURE__*/_react["default"].createElement(TabList, {
289
- role: "tablist",
290
- onKeyDown: handleOnKeyDown,
291
- minHeightTabs: minHeightTabs
292
- }, tabs.map(function (tab, i) {
293
- return /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
294
- tab: tab,
295
- key: "tab".concat(i).concat(tab.label),
296
- active: isTabActive(i),
297
- tabIndex: isTabActive(i) && !tab.isDisabled ? tabIndex : -1,
298
- hasLabelAndIcon: hasLabelAndIcon,
299
- iconPosition: iconPosition,
300
- ref: function ref(el) {
301
- return refTabs.current[i] = el;
302
- },
303
- onClick: function onClick() {
304
- setCurrentFocusIndex(i);
305
- setTemporalFocusIndex(i);
306
- handleSelected(i);
307
- },
308
- onMouseEnter: function onMouseEnter() {
309
- onTabHover === null || onTabHover === void 0 ? void 0 : onTabHover(i);
310
- },
311
- onMouseLeave: function onMouseLeave() {
312
- onTabHover === null || onTabHover === void 0 ? void 0 : onTabHover(null);
313
- }
314
- });
315
- })), /*#__PURE__*/_react["default"].createElement(ActiveIndicator, {
316
- tabWidth: activeIndicatorWidth,
317
- tabLeft: activeIndicatorLeft,
318
- "aria-disabled": isActiveIndicatorDisabled
319
- }))), /*#__PURE__*/_react["default"].createElement(ScrollIndicator, {
320
- onClick: scrollRight,
321
- enabled: enabledIndicator,
322
- disabled: !scrollRightEnabled,
323
- "aria-label": translatedLabels.tabs.scrollRight,
324
- tabIndex: scrollRightEnabled ? tabIndex : -1,
325
- minHeightTabs: minHeightTabs
326
- }, arrowIcons.right))));
327
- };
328
- var Underline = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n height: ", ";\n background-color: ", ";\n"])), function (props) {
329
- return props.theme.dividerThickness;
330
- }, function (props) {
331
- return props.theme.dividerColor;
332
- });
333
- 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) {
334
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
335
- }, function (props) {
336
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
337
- }, function (props) {
338
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
339
- }, function (props) {
340
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
341
- }, function (props) {
342
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
343
- });
344
- 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) {
345
- return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "48px" || "72px";
346
- }, function (props) {
347
- return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "48px" || "72px";
348
- }, function (props) {
349
- return props.theme.unselectedBackgroundColor;
350
- });
351
- var ScrollIndicator = _styledComponents["default"].button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: ", ";\n justify-content: center;\n min-width: ", ";\n height: ", "px;\n padding: 0;\n border: none;\n background-color: #ffffff;\n font-size: 1.25rem;\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n &:active {\n background-color: ", ";\n }\n &:disabled {\n cursor: default;\n display: none;\n svg {\n visibility: hidden;\n }\n &:focus {\n outline: none;\n }\n &:hover,\n &:active {\n background-color: transparent !important;\n }\n }\n\n svg {\n align-self: center;\n height: 20px;\n width: 20px;\n fill: ", ";\n }\n"])), function (props) {
352
- return props.enabled ? "flex" : "none";
353
- }, function (props) {
354
- return props.theme.scrollButtonsWidth;
355
- }, function (props) {
356
- return props.minHeightTabs - 1;
357
- }, function (props) {
358
- return "".concat(props.theme.hoverBackgroundColor, " !important");
359
- }, function (props) {
360
- return props.theme.focusOutline;
361
- }, function (props) {
362
- return "".concat(props.theme.pressedBackgroundColor, " !important");
363
- }, function (props) {
364
- return props.theme.unselectedFontColor;
365
- });
366
- var ActiveIndicator = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n bottom: 0;\n left: ", ";\n width: ", ";\n height: ", ";\n background-color: ", ";\n &[aria-disabled=\"true\"] {\n background-color: ", ";\n display: none;\n }\n"])), function (props) {
367
- return "".concat(props.tabLeft, "px");
368
- }, function (props) {
369
- return "".concat(props.tabWidth, "px");
370
- }, function (props) {
371
- return props.theme.selectedUnderlineThickness;
372
- }, function (props) {
373
- return props.theme.selectedUnderlineColor;
374
- }, function (props) {
375
- return props.theme.disabledFontColor;
376
- });
377
- var TabsContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\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"])));
378
- var TabList = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n min-height: ", "px;\n"])), function (props) {
379
- return props.minHeightTabs;
380
- });
381
- 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) {
382
- return props.enabled ? "transform: translateX(".concat(props.translateScroll, "px)") : "transform: translateX(0px)";
383
- });
384
- var _default = exports["default"] = DxcTabs;
@@ -1,226 +0,0 @@
1
- import React from "react";
2
- import DxcTabs from "./Tabs";
3
- import Title from "../../.storybook/components/Title";
4
- import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
- import { HalstackProvider } from "../HalstackContext";
6
-
7
- export default {
8
- title: "Tabs",
9
- component: DxcTabs,
10
- };
11
-
12
- const iconSVG = (
13
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20" fill="currentColor">
14
- <path d="m10 17-1.042-.938q-2.083-1.854-3.437-3.177-1.354-1.323-2.136-2.354Q2.604 9.5 2.302 8.646 2 7.792 2 6.896q0-1.854 1.271-3.125T6.396 2.5q1.021 0 1.979.438.958.437 1.625 1.229.667-.792 1.625-1.229.958-.438 1.979-.438 1.854 0 3.125 1.271T18 6.896q0 .896-.292 1.729-.291.833-1.073 1.854-.781 1.021-2.145 2.365-1.365 1.344-3.49 3.26Zm0-2.021q1.938-1.729 3.188-2.948 1.25-1.219 1.989-2.125.74-.906 1.031-1.614.292-.709.292-1.396 0-1.229-.833-2.063Q14.833 4 13.604 4q-.729 0-1.364.302-.636.302-1.094.844L10.417 6h-.834l-.729-.854q-.458-.542-1.114-.844Q7.083 4 6.396 4q-1.229 0-2.063.833-.833.834-.833 2.063 0 .687.271 1.364.271.678.989 1.573.719.896 1.98 2.125Q8 13.188 10 14.979Zm0-5.5Z" />
15
- </svg>
16
- );
17
-
18
- const tabs: any = [
19
- {
20
- label: "Tab 1",
21
- },
22
- {
23
- label: "Tab 2",
24
- },
25
- {
26
- label: "Tab 3",
27
- isDisabled: true,
28
- },
29
- {
30
- label: "Tab 4",
31
- },
32
- {
33
- label: "Tab 5",
34
- },
35
- {
36
- label: "Tab 6",
37
- },
38
- {
39
- label: "Tab 7",
40
- },
41
- ];
42
-
43
- const disabledTabs: any = [
44
- {
45
- label: "Tab 1",
46
- isDisabled: true,
47
- },
48
- {
49
- label: "Tab 2",
50
- isDisabled: true,
51
- },
52
- {
53
- label: "Tab 3",
54
- isDisabled: true,
55
- },
56
- ];
57
-
58
- const firstDisabledTabs: any = [
59
- {
60
- label: "Tab 1",
61
- isDisabled: true,
62
- },
63
- {
64
- label: "Tab 2",
65
- isDisabled: true,
66
- },
67
- {
68
- label: "Tab 3",
69
- },
70
- ];
71
-
72
- const tabsNotification = tabs.map((tab, index) => ({
73
- ...tab,
74
- notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 100) || (index === 3 && 200),
75
- }));
76
-
77
- const tabsIcon = tabs.map((tab, index) =>
78
- index <= tabs.length / 2
79
- ? { ...tab, icon: "https://cdn-icons-png.flaticon.com/512/5039/5039041.png" }
80
- : { ...tab, icon: iconSVG }
81
- );
82
-
83
- const tabsNotificationIcon = tabsNotification.map((tab) => ({ ...tab, icon: iconSVG }));
84
-
85
- const opinionatedTheme = {
86
- tabs: {
87
- baseColor: "#5f249f",
88
- },
89
- };
90
-
91
- export const Chromatic = () => (
92
- <>
93
- <ExampleContainer>
94
- <Title title="Only label" theme="light" level={4} />
95
- <DxcTabs tabs={tabs} />
96
- </ExampleContainer>
97
- <ExampleContainer>
98
- <Title title="Disabled tabs" theme="light" level={4} />
99
- <DxcTabs activeTabIndex={0} tabs={disabledTabs} />
100
- </ExampleContainer>
101
- <ExampleContainer>
102
- <Title title="First two tabs disabled" theme="light" level={4} />
103
- <DxcTabs tabs={firstDisabledTabs} />
104
- </ExampleContainer>
105
- <ExampleContainer pseudoState="pseudo-hover">
106
- <Title title="Hovered tabs" theme="light" level={4} />
107
- <DxcTabs tabs={tabs} />
108
- </ExampleContainer>
109
- <ExampleContainer pseudoState="pseudo-focus">
110
- <Title title="Focused tabs" theme="light" level={4} />
111
- <DxcTabs tabs={tabs} />
112
- </ExampleContainer>
113
- <ExampleContainer pseudoState="pseudo-active">
114
- <Title title="Actived tabs" theme="light" level={4} />
115
- <DxcTabs tabs={tabs} />
116
- </ExampleContainer>
117
- <ExampleContainer>
118
- <Title title="With notification number" theme="light" level={4} />
119
- <DxcTabs tabs={tabsNotification} />
120
- </ExampleContainer>
121
- <ExampleContainer>
122
- <Title title="With icon position top" theme="light" level={4} />
123
- <DxcTabs tabs={tabsIcon} />
124
- </ExampleContainer>
125
- <ExampleContainer>
126
- <Title title="With icon position left" theme="light" level={4} />
127
- <DxcTabs tabs={tabsIcon} iconPosition="left" />
128
- </ExampleContainer>
129
- <ExampleContainer>
130
- <Title title="With icon and notification number" theme="light" level={4} />
131
- <DxcTabs tabs={tabsNotificationIcon} />
132
- </ExampleContainer>
133
- <ExampleContainer>
134
- <Title title="With icon on the left and notification number" theme="light" level={4} />
135
- <DxcTabs tabs={tabsNotificationIcon} iconPosition="left" />
136
- </ExampleContainer>
137
- <Title title="Margins" theme="light" level={2} />
138
- <ExampleContainer>
139
- <Title title="Xxsmall margin" theme="light" level={4} />
140
- <DxcTabs tabs={tabs} margin="xxsmall" />
141
- </ExampleContainer>
142
- <ExampleContainer>
143
- <Title title="Xsmall margin" theme="light" level={4} />
144
- <DxcTabs tabs={tabs} margin="xsmall" />
145
- </ExampleContainer>
146
- <ExampleContainer>
147
- <Title title="Small margin" theme="light" level={4} />
148
- <DxcTabs tabs={tabs} margin="small" />
149
- </ExampleContainer>
150
- <ExampleContainer>
151
- <Title title="Medium margin" theme="light" level={4} />
152
- <DxcTabs tabs={tabs} margin="medium" />
153
- </ExampleContainer>
154
- <ExampleContainer>
155
- <Title title="Large margin" theme="light" level={4} />
156
- <DxcTabs tabs={tabs} margin="large" />
157
- </ExampleContainer>
158
- <ExampleContainer>
159
- <Title title="Xlarge margin" theme="light" level={4} />
160
- <DxcTabs tabs={tabs} margin="xlarge" />
161
- </ExampleContainer>
162
- <ExampleContainer>
163
- <Title title="Xxlarge margin" theme="light" level={4} />
164
- <DxcTabs tabs={tabs} margin="xxlarge" />
165
- </ExampleContainer>
166
- <Title title="Opinionated theme" theme="light" level={2} />
167
- <ExampleContainer>
168
- <Title title="With icon and notification" theme="light" level={4} />
169
- <HalstackProvider theme={opinionatedTheme}>
170
- <DxcTabs tabs={tabsNotificationIcon} />
171
- </HalstackProvider>
172
- </ExampleContainer>
173
- <ExampleContainer>
174
- <Title title="Disabled" theme="light" level={4} />
175
- <HalstackProvider theme={opinionatedTheme}>
176
- <DxcTabs activeTabIndex={0} tabs={disabledTabs} />
177
- </HalstackProvider>
178
- </ExampleContainer>
179
- <ExampleContainer pseudoState="pseudo-hover">
180
- <Title title="Hovered" theme="light" level={4} />
181
- <HalstackProvider theme={opinionatedTheme}>
182
- <DxcTabs tabs={tabs} />
183
- </HalstackProvider>
184
- </ExampleContainer>
185
- <ExampleContainer pseudoState="pseudo-focus">
186
- <Title title="Focused" theme="light" level={4} />
187
- <HalstackProvider theme={opinionatedTheme}>
188
- <DxcTabs tabs={tabs} />
189
- </HalstackProvider>
190
- </ExampleContainer>
191
- <ExampleContainer pseudoState="pseudo-active">
192
- <Title title="Actived" theme="light" level={4} />
193
- <HalstackProvider theme={opinionatedTheme}>
194
- <DxcTabs tabs={tabs} />
195
- </HalstackProvider>
196
- </ExampleContainer>
197
- </>
198
- );
199
-
200
- export const ScrollableTabs = () => (
201
- <>
202
- <ExampleContainer>
203
- <Title title="Only label" theme="light" level={4} />
204
- <DxcTabs tabs={tabs} />
205
- </ExampleContainer>
206
- <ExampleContainer pseudoState="pseudo-hover">
207
- <Title title="Hovered tabs" theme="light" level={4} />
208
- <DxcTabs tabs={tabs} />
209
- </ExampleContainer>
210
- <ExampleContainer pseudoState="pseudo-focus">
211
- <Title title="Focused tabs" theme="light" level={4} />
212
- <DxcTabs tabs={tabs} />
213
- </ExampleContainer>
214
- <ExampleContainer pseudoState="pseudo-active">
215
- <Title title="Actived tabs" theme="light" level={4} />
216
- <DxcTabs tabs={tabs} />
217
- </ExampleContainer>
218
- </>
219
- );
220
-
221
- ScrollableTabs.parameters = {
222
- viewport: {
223
- defaultViewport: "iphonex",
224
- },
225
- chromatic: { viewports: [375], delay: 5000 },
226
- };