@zohodesk/components 1.0.0-temp-261 → 1.0.0-temp-262.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +20 -0
  3. package/assets/Appearance/dark/themes/blue/blue_componentsCTA_DarkModifyCategory.module.css +2 -0
  4. package/assets/Appearance/dark/themes/green/green_componentsCTA_DarkModifyCategory.module.css +2 -0
  5. package/assets/Appearance/dark/themes/orange/orange_componentsCTA_DarkModifyCategory.module.css +2 -0
  6. package/assets/Appearance/dark/themes/red/red_componentsCTA_DarkModifyCategory.module.css +2 -0
  7. package/assets/Appearance/dark/themes/yellow/yellow_componentsCTA_DarkModifyCategory.module.css +2 -0
  8. package/assets/Appearance/light/mode/Component_LightMode.module.css +1 -1
  9. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +20 -0
  10. package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +2 -0
  11. package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +2 -0
  12. package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +2 -0
  13. package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +2 -0
  14. package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +2 -0
  15. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +20 -0
  16. package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  17. package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  18. package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  19. package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  20. package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  21. package/cbt.config.js +1 -0
  22. package/es/Accordion/__tests__/Accordion.spec.js +117 -3
  23. package/es/Accordion/__tests__/AccordionItem.spec.js +118 -6
  24. package/es/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
  25. package/es/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
  26. package/es/Animation/__tests__/Animation.spec.js +28 -4
  27. package/es/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
  28. package/es/Button/css/Button.module.css +3 -5
  29. package/es/CheckBox/CheckBox.js +1 -1
  30. package/es/CheckBox/CheckBox.module.css +1 -1
  31. package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
  32. package/es/DateTime/DateTime.module.css +2 -2
  33. package/es/DateTime/__tests__/CalendarView.spec.js +70 -3
  34. package/es/DateTime/__tests__/DateTime.spec.js +89 -6
  35. package/es/DateTime/__tests__/DateTimePopupFooter.spec.js +20 -2
  36. package/es/DateTime/__tests__/DateTimePopupHeader.spec.js +29 -2
  37. package/es/DateTime/__tests__/DateWidget.spec.js +34 -2
  38. package/es/DateTime/__tests__/DaysRow.spec.js +19 -3
  39. package/es/DateTime/__tests__/Time.spec.js +50 -3
  40. package/es/DateTime/__tests__/YearView.spec.js +60 -3
  41. package/es/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
  42. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
  43. package/es/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
  44. package/es/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
  45. package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
  46. package/es/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
  47. package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
  48. package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
  49. package/es/DividerLine/css/DividerLine.module.css +1 -2
  50. package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
  51. package/es/Heading/Heading.module.css +1 -1
  52. package/es/Heading/__tests__/Heading.spec.js +57 -3
  53. package/es/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
  54. package/es/ListItem/ListItem.module.css +1 -2
  55. package/es/ListItem/__tests__/ListContainer.spec.js +228 -1
  56. package/es/ListItem/__tests__/ListItem.spec.js +359 -1
  57. package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +390 -1
  58. package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +214 -1
  59. package/es/ListItem/__tests__/ListItemWithIcon.spec.js +303 -1
  60. package/es/ListItem/__tests__/ListItemWithRadio.spec.js +230 -1
  61. package/es/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
  62. package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
  63. package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
  64. package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
  65. package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
  66. package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
  67. package/es/MultiSelect/MultiSelect.module.css +1 -2
  68. package/es/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +671 -1
  69. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +730 -1
  70. package/es/MultiSelect/__tests__/EmptyState.spec.js +268 -1
  71. package/es/MultiSelect/__tests__/MultiSelect.spec.js +889 -2
  72. package/es/MultiSelect/__tests__/MultiSelectHeader.spec.js +50 -1
  73. package/es/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +487 -1
  74. package/es/MultiSelect/__tests__/SelectedOptions.spec.js +291 -1
  75. package/es/MultiSelect/__tests__/Suggestions.spec.js +370 -2
  76. package/es/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
  77. package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
  78. package/es/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
  79. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
  80. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
  81. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
  82. package/es/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
  83. package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
  84. package/es/PopOver/__tests__/PopOver.spec.js +141 -2
  85. package/es/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
  86. package/es/Radio/Radio.module.css +1 -1
  87. package/es/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +212 -1
  88. package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
  89. package/es/Tab/Tab.module.css +1 -2
  90. package/es/Tab/Tabs.module.css +1 -2
  91. package/es/Tab/__tests__/Tab.spec.js +249 -1
  92. package/es/Tab/__tests__/TabContent.spec.js +34 -1
  93. package/es/Tab/__tests__/TabContentWrapper.spec.js +72 -1
  94. package/es/Tab/__tests__/TabWrapper.spec.js +163 -1
  95. package/es/Tab/__tests__/Tabs.spec.js +681 -1
  96. package/es/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
  97. package/es/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
  98. package/es/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
  99. package/es/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
  100. package/es/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
  101. package/es/Textarea/Textarea.module.css +1 -1
  102. package/es/Tooltip/Tooltip.module.css +1 -2
  103. package/es/Tooltip/__tests__/Tooltip.spec.js +590 -0
  104. package/es/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
  105. package/es/Typography/__tests__/Typography.spec.js +1 -1
  106. package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +0 -40
  107. package/es/Typography/css/Typography.module.css +9 -16
  108. package/es/Typography/props/propTypes.js +1 -1
  109. package/es/common/common.module.css +4 -4
  110. package/es/index.d.ts +39 -0
  111. package/es/index.js +12 -12
  112. package/es/semantic/Button/semanticButton.module.css +1 -2
  113. package/es/v1/Button/css/Button_v1.module.css +0 -1
  114. package/es/v1/Switch/css/Switch_v1.module.css +2 -3
  115. package/es/v1/Tab/Tab.js +155 -0
  116. package/es/v1/Tab/TabList.js +145 -0
  117. package/es/v1/Tab/TabMoreMenu.js +245 -0
  118. package/es/v1/Tab/TabPanel.js +51 -0
  119. package/es/v1/Tab/Tabs.js +125 -0
  120. package/es/v1/Tab/__tests__/Tab.spec.js +1102 -0
  121. package/es/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
  122. package/es/v1/Tab/constants/index.js +112 -0
  123. package/es/v1/Tab/constants/presets.js +37 -0
  124. package/es/v1/Tab/context.js +19 -0
  125. package/es/v1/Tab/core/Tab.js +60 -0
  126. package/es/v1/Tab/core/TabList.js +51 -0
  127. package/es/v1/Tab/core/TabListFocusScope.js +18 -0
  128. package/es/v1/Tab/core/TabPanel.js +54 -0
  129. package/es/v1/Tab/core/Tabs.js +45 -0
  130. package/es/v1/Tab/core/index.js +6 -0
  131. package/es/v1/Tab/css/Tab_v1.module.css +360 -0
  132. package/es/v1/Tab/css/cssJSLogic.js +1 -0
  133. package/es/v1/Tab/css/tab.cva.js +205 -0
  134. package/es/v1/Tab/index.js +8 -0
  135. package/es/v1/Tab/props/defaultProps.js +55 -0
  136. package/es/v1/Tab/props/propTypes.js +215 -0
  137. package/es/v1/Tab/utils/pinSelectedTab.js +44 -0
  138. package/lib/Accordion/__tests__/Accordion.spec.js +122 -2
  139. package/lib/Accordion/__tests__/AccordionItem.spec.js +126 -4
  140. package/lib/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
  141. package/lib/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
  142. package/lib/Animation/__tests__/Animation.spec.js +31 -5
  143. package/lib/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
  144. package/lib/Button/css/Button.module.css +3 -5
  145. package/lib/CheckBox/CheckBox.js +1 -1
  146. package/lib/CheckBox/CheckBox.module.css +1 -1
  147. package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
  148. package/lib/DateTime/DateTime.module.css +2 -2
  149. package/lib/DateTime/__tests__/CalendarView.spec.js +71 -2
  150. package/lib/DateTime/__tests__/DateTime.spec.js +92 -6
  151. package/lib/DateTime/__tests__/DateTimePopupFooter.spec.js +21 -1
  152. package/lib/DateTime/__tests__/DateTimePopupHeader.spec.js +30 -1
  153. package/lib/DateTime/__tests__/DateWidget.spec.js +35 -1
  154. package/lib/DateTime/__tests__/DaysRow.spec.js +20 -2
  155. package/lib/DateTime/__tests__/Time.spec.js +51 -2
  156. package/lib/DateTime/__tests__/YearView.spec.js +61 -2
  157. package/lib/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
  158. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
  159. package/lib/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
  160. package/lib/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
  161. package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
  162. package/lib/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
  163. package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
  164. package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
  165. package/lib/DividerLine/css/DividerLine.module.css +1 -2
  166. package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
  167. package/lib/Heading/Heading.module.css +1 -1
  168. package/lib/Heading/__tests__/Heading.spec.js +60 -4
  169. package/lib/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
  170. package/lib/ListItem/ListItem.module.css +1 -2
  171. package/lib/ListItem/__tests__/ListContainer.spec.js +229 -0
  172. package/lib/ListItem/__tests__/ListItem.spec.js +362 -0
  173. package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +391 -0
  174. package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +215 -0
  175. package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +304 -0
  176. package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +231 -0
  177. package/lib/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
  178. package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
  179. package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
  180. package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
  181. package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
  182. package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
  183. package/lib/MultiSelect/MultiSelect.module.css +1 -2
  184. package/lib/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +692 -0
  185. package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +741 -0
  186. package/lib/MultiSelect/__tests__/EmptyState.spec.js +273 -0
  187. package/lib/MultiSelect/__tests__/MultiSelect.spec.js +910 -0
  188. package/lib/MultiSelect/__tests__/MultiSelectHeader.spec.js +51 -0
  189. package/lib/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +497 -0
  190. package/lib/MultiSelect/__tests__/SelectedOptions.spec.js +305 -0
  191. package/lib/MultiSelect/__tests__/Suggestions.spec.js +375 -0
  192. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
  193. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
  194. package/lib/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
  195. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
  196. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
  197. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
  198. package/lib/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
  199. package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
  200. package/lib/PopOver/__tests__/PopOver.spec.js +150 -1
  201. package/lib/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
  202. package/lib/Radio/Radio.module.css +1 -1
  203. package/lib/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +213 -0
  204. package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
  205. package/lib/Tab/Tab.module.css +1 -2
  206. package/lib/Tab/Tabs.module.css +1 -2
  207. package/lib/Tab/__tests__/Tab.spec.js +250 -0
  208. package/lib/Tab/__tests__/TabContent.spec.js +35 -0
  209. package/lib/Tab/__tests__/TabContentWrapper.spec.js +76 -0
  210. package/lib/Tab/__tests__/TabWrapper.spec.js +174 -0
  211. package/lib/Tab/__tests__/Tabs.spec.js +741 -0
  212. package/lib/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
  213. package/lib/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
  214. package/lib/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
  215. package/lib/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
  216. package/lib/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
  217. package/lib/Textarea/Textarea.module.css +1 -1
  218. package/lib/Tooltip/Tooltip.module.css +1 -2
  219. package/lib/Tooltip/__tests__/Tooltip.spec.js +629 -0
  220. package/lib/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
  221. package/lib/Typography/__tests__/Typography.spec.js +1 -1
  222. package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +0 -40
  223. package/lib/Typography/css/Typography.module.css +9 -16
  224. package/lib/Typography/props/propTypes.js +1 -1
  225. package/lib/common/common.module.css +4 -4
  226. package/lib/index.d.ts +39 -0
  227. package/lib/index.js +270 -173
  228. package/lib/semantic/Button/semanticButton.module.css +1 -2
  229. package/lib/v1/Button/css/Button_v1.module.css +0 -1
  230. package/lib/v1/Switch/css/Switch_v1.module.css +2 -3
  231. package/lib/v1/Tab/Tab.js +176 -0
  232. package/lib/v1/Tab/TabList.js +180 -0
  233. package/lib/v1/Tab/TabMoreMenu.js +284 -0
  234. package/lib/v1/Tab/TabPanel.js +64 -0
  235. package/lib/v1/Tab/Tabs.js +151 -0
  236. package/lib/v1/Tab/__tests__/Tab.spec.js +1206 -0
  237. package/lib/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
  238. package/lib/v1/Tab/constants/index.js +113 -0
  239. package/lib/v1/Tab/constants/presets.js +65 -0
  240. package/lib/v1/Tab/context.js +30 -0
  241. package/lib/v1/Tab/core/Tab.js +88 -0
  242. package/lib/v1/Tab/core/TabList.js +82 -0
  243. package/lib/v1/Tab/core/TabListFocusScope.js +28 -0
  244. package/lib/v1/Tab/core/TabPanel.js +85 -0
  245. package/lib/v1/Tab/core/Tabs.js +63 -0
  246. package/lib/v1/Tab/core/index.js +109 -0
  247. package/lib/v1/Tab/css/Tab_v1.module.css +360 -0
  248. package/lib/v1/Tab/css/cssJSLogic.js +25 -0
  249. package/lib/v1/Tab/css/tab.cva.js +192 -0
  250. package/lib/v1/Tab/index.js +159 -0
  251. package/lib/v1/Tab/props/defaultProps.js +69 -0
  252. package/lib/v1/Tab/props/propTypes.js +240 -0
  253. package/lib/v1/Tab/utils/pinSelectedTab.js +59 -0
  254. package/package.json +18 -15
  255. package/tsconfig.jest.json +5 -0
  256. package/tsconfig.json +9 -0
  257. package/ut.config.js +2 -1
@@ -0,0 +1,1102 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import React from 'react';
6
+ import { render, screen, fireEvent } from '@testing-library/react';
7
+ import Tabs from "../Tabs";
8
+ import TabList from "../TabList";
9
+ import Tab from "../Tab";
10
+ import TabPanel from "../TabPanel";
11
+ import { SIZE, VARIANT, POSITION, LABEL_STYLE, ICON_PLACEMENT, ICON_SPACING } from "../constants";
12
+ import { INFO_BAR_RAIL, INFO_BAR_RAIL_TEXT, INFO_BAR_RAIL_ICON_LEFT, INFO_BAR_RAIL_ICON_TOP, SUBTAB_STRIP } from "../constants/presets";
13
+ /*
14
+ * `uniqueId` is passed on every render on purpose. The id scope is otherwise
15
+ * counter-based, so every id, aria-controls and aria-labelledby recorded below
16
+ * would depend on how many <Tabs> rendered before it - and adding a test above
17
+ * would invalidate every snapshot under it.
18
+ *
19
+ * Data-driven mode is deterministic here too: jsdom reports every offsetWidth
20
+ * as 0, so useAdaptiveRenderer keeps exactly `minVisibleTabs` tabs in the strip
21
+ * and collapses the rest into the more menu.
22
+ */
23
+
24
+ const ITEMS = [{
25
+ value: 'a',
26
+ text: 'Alpha',
27
+ iconName: 'ZD-TB-menu'
28
+ }, {
29
+ value: 'b',
30
+ text: 'Bravo'
31
+ }, {
32
+ value: 'c',
33
+ text: 'Charlie'
34
+ }];
35
+
36
+ const readStylesheet = () => fs.readFileSync(path.join(__dirname, '..', 'css', 'Tab_v1.module.css'), 'utf8');
37
+
38
+ function Group({
39
+ uniqueId = 'tabs',
40
+ tabProps,
41
+ listProps,
42
+ ...tabsProps
43
+ }) {
44
+ return /*#__PURE__*/React.createElement(Tabs, _extends({
45
+ uniqueId: uniqueId
46
+ }, tabsProps), /*#__PURE__*/React.createElement(TabList, _extends({
47
+ ariaLabel: "Cities"
48
+ }, listProps), /*#__PURE__*/React.createElement(Tab, _extends({
49
+ value: "one",
50
+ text: "one"
51
+ }, tabProps)), /*#__PURE__*/React.createElement(Tab, {
52
+ value: "two",
53
+ text: "two"
54
+ })), /*#__PURE__*/React.createElement(TabPanel, {
55
+ value: "one"
56
+ }, "Panel one"), /*#__PURE__*/React.createElement(TabPanel, {
57
+ value: "two"
58
+ }, "Panel two"));
59
+ }
60
+
61
+ describe('Tab - Snapshot', () => {
62
+ test('Render with default props', () => {
63
+ const {
64
+ asFragment
65
+ } = render( /*#__PURE__*/React.createElement(Group, null));
66
+ expect(asFragment()).toMatchSnapshot();
67
+ });
68
+ test('Render with defaultValue', () => {
69
+ const {
70
+ asFragment
71
+ } = render( /*#__PURE__*/React.createElement(Group, {
72
+ defaultValue: "two"
73
+ }));
74
+ expect(asFragment()).toMatchSnapshot();
75
+ });
76
+ test('Render with selectedValue', () => {
77
+ const {
78
+ asFragment
79
+ } = render( /*#__PURE__*/React.createElement(Group, {
80
+ selectedValue: "two"
81
+ }));
82
+ expect(asFragment()).toMatchSnapshot();
83
+ });
84
+ test('Render with activation=manual', () => {
85
+ const {
86
+ asFragment
87
+ } = render( /*#__PURE__*/React.createElement(Group, {
88
+ activation: "manual"
89
+ }));
90
+ expect(asFragment()).toMatchSnapshot();
91
+ });
92
+ test.each(Object.values(SIZE))('Render with size=%s', size => {
93
+ const {
94
+ asFragment
95
+ } = render( /*#__PURE__*/React.createElement(Group, {
96
+ size: size
97
+ }));
98
+ expect(asFragment()).toMatchSnapshot();
99
+ });
100
+ test.each(Object.values(VARIANT))('Render with variant=%s', variant => {
101
+ const {
102
+ asFragment
103
+ } = render( /*#__PURE__*/React.createElement(Group, {
104
+ variant: variant
105
+ }));
106
+ expect(asFragment()).toMatchSnapshot();
107
+ });
108
+ test.each(Object.values(POSITION))('Render with position=%s', position => {
109
+ const {
110
+ asFragment
111
+ } = render( /*#__PURE__*/React.createElement(Group, {
112
+ position: position
113
+ }));
114
+ expect(asFragment()).toMatchSnapshot();
115
+ });
116
+ test.each(Object.values(LABEL_STYLE))('Render with labelStyle=%s', labelStyle => {
117
+ const {
118
+ asFragment
119
+ } = render( /*#__PURE__*/React.createElement(Group, {
120
+ labelStyle: labelStyle,
121
+ tabProps: {
122
+ iconName: 'ZD-TB-menu'
123
+ }
124
+ }));
125
+ expect(asFragment()).toMatchSnapshot();
126
+ });
127
+ test.each(Object.values(ICON_PLACEMENT))('Render with iconPlacement=%s', iconPlacement => {
128
+ const {
129
+ asFragment
130
+ } = render( /*#__PURE__*/React.createElement(Group, {
131
+ iconPlacement: iconPlacement,
132
+ labelStyle: "iconAndText",
133
+ tabProps: {
134
+ iconName: 'ZD-TB-menu'
135
+ }
136
+ }));
137
+ expect(asFragment()).toMatchSnapshot();
138
+ });
139
+ test('Render with iconSpacing', () => {
140
+ const {
141
+ asFragment
142
+ } = render( /*#__PURE__*/React.createElement(Group, {
143
+ iconSpacing: "12",
144
+ tabProps: {
145
+ iconName: 'ZD-TB-menu'
146
+ }
147
+ }));
148
+ expect(asFragment()).toMatchSnapshot();
149
+ });
150
+ test('Render with isFullWidth', () => {
151
+ const {
152
+ asFragment
153
+ } = render( /*#__PURE__*/React.createElement(Group, {
154
+ isFullWidth: true
155
+ }));
156
+ expect(asFragment()).toMatchSnapshot();
157
+ });
158
+ test('Render with hasScroll', () => {
159
+ const {
160
+ asFragment
161
+ } = render( /*#__PURE__*/React.createElement(Group, {
162
+ hasScroll: true
163
+ }));
164
+ expect(asFragment()).toMatchSnapshot();
165
+ });
166
+ test('Render with hasSurface', () => {
167
+ const {
168
+ asFragment
169
+ } = render( /*#__PURE__*/React.createElement(Group, {
170
+ hasSurface: true
171
+ }));
172
+ expect(asFragment()).toMatchSnapshot();
173
+ });
174
+ test('Render with hasListBorder=false and hasListPadding=false', () => {
175
+ const {
176
+ asFragment
177
+ } = render( /*#__PURE__*/React.createElement(Group, {
178
+ hasListBorder: false,
179
+ hasListPadding: false
180
+ }));
181
+ expect(asFragment()).toMatchSnapshot();
182
+ });
183
+ test('Render with textTransform and textTruncate', () => {
184
+ const {
185
+ asFragment
186
+ } = render( /*#__PURE__*/React.createElement(Group, {
187
+ textTransform: "upper",
188
+ textTruncate: "ellipsis"
189
+ }));
190
+ expect(asFragment()).toMatchSnapshot();
191
+ });
192
+ test('Render with customClass for every slot', () => {
193
+ const {
194
+ asFragment
195
+ } = render( /*#__PURE__*/React.createElement(Group, {
196
+ customClass: {
197
+ root: 'my-root',
198
+ list: 'my-list',
199
+ tab: 'my-tab',
200
+ tabText: 'my-text',
201
+ panel: 'my-panel'
202
+ }
203
+ }));
204
+ expect(asFragment()).toMatchSnapshot();
205
+ });
206
+ test('Render with customId and testId', () => {
207
+ const {
208
+ asFragment
209
+ } = render( /*#__PURE__*/React.createElement(Group, {
210
+ customId: "tab-customId",
211
+ testId: "tab-testId"
212
+ }));
213
+ expect(asFragment()).toMatchSnapshot();
214
+ });
215
+ test('Render with customProps and customAttributes on the root', () => {
216
+ const {
217
+ asFragment
218
+ } = render( /*#__PURE__*/React.createElement(Group, {
219
+ customProps: {
220
+ root: {
221
+ 'data-custom-prop': 'true'
222
+ }
223
+ },
224
+ customAttributes: {
225
+ root: {
226
+ 'data-custom-attr': 'true'
227
+ }
228
+ },
229
+ a11yAttributes: {
230
+ 'aria-roledescription': 'tab group'
231
+ }
232
+ }));
233
+ expect(asFragment()).toMatchSnapshot();
234
+ });
235
+ test('Render a tab with an icon', () => {
236
+ const {
237
+ asFragment
238
+ } = render( /*#__PURE__*/React.createElement(Group, {
239
+ tabProps: {
240
+ iconName: 'ZD-TB-menu',
241
+ iconSize: 14
242
+ }
243
+ }));
244
+ expect(asFragment()).toMatchSnapshot();
245
+ });
246
+ test('Render a disabled tab', () => {
247
+ const {
248
+ asFragment
249
+ } = render( /*#__PURE__*/React.createElement(Group, {
250
+ tabProps: {
251
+ isDisabled: true
252
+ }
253
+ }));
254
+ expect(asFragment()).toMatchSnapshot();
255
+ });
256
+ test('Render a tab with title', () => {
257
+ const {
258
+ asFragment
259
+ } = render( /*#__PURE__*/React.createElement(Group, {
260
+ tabProps: {
261
+ title: 'First tab'
262
+ }
263
+ }));
264
+ expect(asFragment()).toMatchSnapshot();
265
+ });
266
+ test('Render a tab with renderIcon, renderBefore and renderAfter', () => {
267
+ const {
268
+ asFragment
269
+ } = render( /*#__PURE__*/React.createElement(Group, {
270
+ tabProps: {
271
+ renderIcon: () => /*#__PURE__*/React.createElement("span", null, "icon"),
272
+ renderBefore: () => /*#__PURE__*/React.createElement("span", null, "before"),
273
+ renderAfter: ({
274
+ isSelected
275
+ }) => /*#__PURE__*/React.createElement("span", null, isSelected ? 'on' : 'off')
276
+ }
277
+ }));
278
+ expect(asFragment()).toMatchSnapshot();
279
+ });
280
+ test('Render a tab with children', () => {
281
+ const {
282
+ asFragment
283
+ } = render( /*#__PURE__*/React.createElement(Group, {
284
+ tabProps: {
285
+ children: /*#__PURE__*/React.createElement("span", null, "badge")
286
+ }
287
+ }));
288
+ expect(asFragment()).toMatchSnapshot();
289
+ });
290
+ test('Render a tab with its own customAttributes and a11yAttributes', () => {
291
+ const {
292
+ asFragment
293
+ } = render( /*#__PURE__*/React.createElement(Group, {
294
+ tabProps: {
295
+ customAttributes: {
296
+ tab: {
297
+ 'data-tour-step': 'step-1'
298
+ }
299
+ },
300
+ a11yAttributes: {
301
+ 'aria-keyshortcuts': 'Alt+1'
302
+ }
303
+ }
304
+ }));
305
+ expect(asFragment()).toMatchSnapshot();
306
+ });
307
+ test('Render a tab with tourId and title', () => {
308
+ const {
309
+ asFragment
310
+ } = render( /*#__PURE__*/React.createElement(Group, {
311
+ tabProps: {
312
+ title: 'One',
313
+ tourId: 'tour-one'
314
+ }
315
+ }));
316
+ expect(asFragment()).toMatchSnapshot();
317
+ });
318
+ test('Render a link tab', () => {
319
+ const {
320
+ asFragment
321
+ } = render( /*#__PURE__*/React.createElement(Group, {
322
+ tabProps: {
323
+ href: '/one',
324
+ target: '_blank',
325
+ rel: 'noreferrer'
326
+ }
327
+ }));
328
+ expect(asFragment()).toMatchSnapshot();
329
+ });
330
+ test('Render a panel kept in the DOM with shouldUnmount=false', () => {
331
+ const {
332
+ asFragment
333
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
334
+ uniqueId: "tabs"
335
+ }, /*#__PURE__*/React.createElement(TabList, {
336
+ ariaLabel: "Cities"
337
+ }, /*#__PURE__*/React.createElement(Tab, {
338
+ value: "one",
339
+ text: "one"
340
+ }), /*#__PURE__*/React.createElement(Tab, {
341
+ value: "two",
342
+ text: "two"
343
+ })), /*#__PURE__*/React.createElement(TabPanel, {
344
+ value: "one"
345
+ }, "Panel one"), /*#__PURE__*/React.createElement(TabPanel, {
346
+ value: "two",
347
+ shouldUnmount: false
348
+ }, "Panel two")));
349
+ expect(asFragment()).toMatchSnapshot();
350
+ });
351
+ test('Render a static panel', () => {
352
+ const {
353
+ asFragment
354
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
355
+ uniqueId: "tabs"
356
+ }, /*#__PURE__*/React.createElement(TabList, {
357
+ ariaLabel: "Cities"
358
+ }, /*#__PURE__*/React.createElement(Tab, {
359
+ value: "one",
360
+ text: "one"
361
+ })), /*#__PURE__*/React.createElement(TabPanel, {
362
+ value: "two",
363
+ isStatic: true
364
+ }, "Always here")));
365
+ expect(asFragment()).toMatchSnapshot();
366
+ });
367
+ test('Render a panel with customId, testId and prop bags', () => {
368
+ const {
369
+ asFragment
370
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
371
+ uniqueId: "tabs"
372
+ }, /*#__PURE__*/React.createElement(TabList, {
373
+ ariaLabel: "Cities"
374
+ }, /*#__PURE__*/React.createElement(Tab, {
375
+ value: "one",
376
+ text: "one"
377
+ })), /*#__PURE__*/React.createElement(TabPanel, {
378
+ value: "one",
379
+ customId: "panel-customId",
380
+ testId: "panel-testId",
381
+ customAttributes: {
382
+ panel: {
383
+ 'data-custom-attr': 'true'
384
+ }
385
+ },
386
+ a11yAttributes: {
387
+ 'aria-live': 'polite'
388
+ }
389
+ }, "Panel one")));
390
+ expect(asFragment()).toMatchSnapshot();
391
+ });
392
+ test('Render a panel with scroll', () => {
393
+ const {
394
+ asFragment
395
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
396
+ uniqueId: "tabs"
397
+ }, /*#__PURE__*/React.createElement(TabList, {
398
+ ariaLabel: "Cities"
399
+ }, /*#__PURE__*/React.createElement(Tab, {
400
+ value: "one",
401
+ text: "one"
402
+ })), /*#__PURE__*/React.createElement(TabPanel, {
403
+ value: "one",
404
+ scroll: "vertical"
405
+ }, "Panel one")));
406
+ expect(asFragment()).toMatchSnapshot();
407
+ });
408
+ test('Render a tablist named with ariaLabelledBy', () => {
409
+ const {
410
+ asFragment
411
+ } = render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", {
412
+ id: "cities-heading"
413
+ }, "Cities"), /*#__PURE__*/React.createElement(Group, {
414
+ listProps: {
415
+ ariaLabel: undefined,
416
+ ariaLabelledBy: 'cities-heading'
417
+ }
418
+ })));
419
+ expect(asFragment()).toMatchSnapshot();
420
+ });
421
+ test('Render a data-driven tablist collapsing into a more menu', () => {
422
+ const {
423
+ asFragment
424
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
425
+ uniqueId: "tabs"
426
+ }, /*#__PURE__*/React.createElement(TabList, {
427
+ ariaLabel: "Cities",
428
+ items: ITEMS
429
+ })));
430
+ expect(asFragment()).toMatchSnapshot();
431
+ });
432
+ test('Render a data-driven tablist with minVisibleTabs raised', () => {
433
+ const {
434
+ asFragment
435
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
436
+ uniqueId: "tabs"
437
+ }, /*#__PURE__*/React.createElement(TabList, {
438
+ ariaLabel: "Cities",
439
+ items: ITEMS,
440
+ minVisibleTabs: 2
441
+ })));
442
+ expect(asFragment()).toMatchSnapshot();
443
+ });
444
+ test('Render a data-driven tablist with nothing overflowing', () => {
445
+ const {
446
+ asFragment
447
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
448
+ uniqueId: "tabs"
449
+ }, /*#__PURE__*/React.createElement(TabList, {
450
+ ariaLabel: "Cities",
451
+ items: ITEMS,
452
+ minVisibleTabs: ITEMS.length
453
+ })));
454
+ expect(asFragment()).toMatchSnapshot();
455
+ });
456
+ test('Render a data-driven tablist carrying renderBefore and renderAfter into the more menu', () => {
457
+ const {
458
+ asFragment
459
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
460
+ uniqueId: "tabs"
461
+ }, /*#__PURE__*/React.createElement(TabList, {
462
+ ariaLabel: "Cities",
463
+ items: ITEMS.map(item => ({ ...item,
464
+ renderBefore: () => /*#__PURE__*/React.createElement("span", null, "dot"),
465
+ renderAfter: ({
466
+ value
467
+ }) => /*#__PURE__*/React.createElement("span", null, `count-${value}`)
468
+ }))
469
+ })));
470
+ expect(asFragment()).toMatchSnapshot();
471
+ });
472
+ test('Render the open more menu with renderBefore and renderAfter mapped onto ListItem', () => {
473
+ /*
474
+ * The menu only mounts while the popup is open, so the ListItem mapping -
475
+ * renderBefore sharing the leading slot with the icon, renderAfter as the
476
+ * right-of-value placeholder - is only reachable through the trigger.
477
+ *
478
+ * Recorded from `baseElement`, not `asFragment()`: the DropBox renders in a
479
+ * portal on document.body, which the container fragment does not include.
480
+ */
481
+ const {
482
+ baseElement
483
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
484
+ uniqueId: "tabs"
485
+ }, /*#__PURE__*/React.createElement(TabList, {
486
+ ariaLabel: "Cities",
487
+ moreMenu: {
488
+ ariaLabel: 'More tabs'
489
+ },
490
+ items: ITEMS.map(item => ({ ...item,
491
+
492
+ /* every item gets an icon here, so the collapsed ones record what
493
+ * the strip cannot: the icon and renderBefore sharing one slot */
494
+ iconName: 'ZD-TB-menu',
495
+ renderBefore: () => /*#__PURE__*/React.createElement("span", null, "dot"),
496
+ renderAfter: ({
497
+ value
498
+ }) => /*#__PURE__*/React.createElement("span", null, `count-${value}`)
499
+ }))
500
+ })));
501
+ fireEvent.click(screen.getByRole('button', {
502
+ name: 'More tabs'
503
+ }));
504
+ expect(baseElement).toMatchSnapshot();
505
+ });
506
+ test('Render a data-driven tablist with a custom more trigger', () => {
507
+ const {
508
+ asFragment
509
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
510
+ uniqueId: "tabs"
511
+ }, /*#__PURE__*/React.createElement(TabList, {
512
+ ariaLabel: "Cities",
513
+ items: ITEMS,
514
+ moreMenu: {
515
+ iconName: 'ZD-more',
516
+ iconSize: 14,
517
+ ariaLabel: 'Show the rest',
518
+ renderTarget: ({
519
+ hiddenCount
520
+ }) => /*#__PURE__*/React.createElement("span", null, "+", hiddenCount)
521
+ }
522
+ })));
523
+ expect(asFragment()).toMatchSnapshot();
524
+ });
525
+ test('Render the open more menu with Popup HOC options forwarded via customProps.popup', () => {
526
+ const {
527
+ baseElement
528
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
529
+ uniqueId: "tabs"
530
+ }, /*#__PURE__*/React.createElement(TabList, {
531
+ ariaLabel: "Cities",
532
+ items: ITEMS,
533
+ moreMenu: {
534
+ ariaLabel: 'More tabs'
535
+ },
536
+ customProps: {
537
+ popup: {
538
+ isAbsolutePositioningNeeded: true,
539
+ isArrow: true
540
+ }
541
+ }
542
+ })));
543
+ fireEvent.click(screen.getByRole('button', {
544
+ name: 'More tabs'
545
+ }));
546
+ expect(baseElement).toMatchSnapshot();
547
+ });
548
+ test('Render extra children after the tabs in items mode', () => {
549
+ const {
550
+ asFragment
551
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
552
+ uniqueId: "tabs"
553
+ }, /*#__PURE__*/React.createElement(TabList, {
554
+ ariaLabel: "Cities",
555
+ items: ITEMS
556
+ }, /*#__PURE__*/React.createElement("span", {
557
+ "data-id": "otherTab"
558
+ }, "extra"))));
559
+ expect(asFragment()).toMatchSnapshot();
560
+ });
561
+ test('Render the open more menu with search and link items', () => {
562
+ const {
563
+ baseElement
564
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
565
+ uniqueId: "tabs"
566
+ }, /*#__PURE__*/React.createElement(TabList, {
567
+ ariaLabel: "Cities",
568
+ moreMenu: {
569
+ ariaLabel: 'More tabs',
570
+ searchThreshold: 1
571
+ },
572
+ items: ITEMS.map(item => ({ ...item,
573
+ href: `/${item.value}`,
574
+ target: '_blank'
575
+ }))
576
+ })));
577
+ fireEvent.click(screen.getByRole('button', {
578
+ name: 'More tabs'
579
+ }));
580
+ expect(baseElement).toMatchSnapshot();
581
+ });
582
+ describe('Presets', () => {
583
+ const presets = [['INFO_BAR_RAIL', INFO_BAR_RAIL], ['INFO_BAR_RAIL_TEXT', INFO_BAR_RAIL_TEXT], ['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT], ['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP], ['SUBTAB_STRIP', SUBTAB_STRIP]];
584
+ test.each(presets)('Should render preset %s', (_name, preset) => {
585
+ const {
586
+ asFragment
587
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
588
+ tabProps: {
589
+ iconName: 'ZD-TB-menu'
590
+ }
591
+ })));
592
+ expect(asFragment()).toMatchSnapshot();
593
+ });
594
+ });
595
+ });
596
+ describe('Tab - Info bar rail presets', () => {
597
+ const railPresets = [INFO_BAR_RAIL, INFO_BAR_RAIL_TEXT, INFO_BAR_RAIL_ICON_LEFT, INFO_BAR_RAIL_ICON_TOP];
598
+ test('every rail preset is the same vertical rail, differing only in its label', () => {
599
+ railPresets.forEach(preset => {
600
+ expect(preset).toMatchObject({
601
+ position: POSITION.LEFT,
602
+ hasSurface: true,
603
+ hasListBorder: true
604
+ });
605
+ });
606
+ });
607
+ test('INFO_BAR_RAIL_TEXT renders the text and drops the icon', () => {
608
+ const {
609
+ container
610
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_TEXT, {
611
+ tabProps: {
612
+ iconName: 'ZD-TB-menu'
613
+ }
614
+ })));
615
+ const tab = container.querySelector('[role="tab"]');
616
+ expect(tab.textContent).toContain('one');
617
+ expect(tab.querySelector('.iconBox')).toBeNull();
618
+ });
619
+ test.each([['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT, ICON_PLACEMENT.LEFT], ['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP, ICON_PLACEMENT.TOP]])('%s renders icon and text with its iconPlacement', (_name, preset, placement) => {
620
+ expect(preset.labelStyle).toBe(LABEL_STYLE.ICON_AND_TEXT);
621
+ expect(preset.iconPlacement).toBe(placement);
622
+ const {
623
+ container
624
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
625
+ tabProps: {
626
+ iconName: 'ZD-TB-menu'
627
+ }
628
+ })));
629
+ const tab = container.querySelector('[role="tab"]');
630
+ expect(tab.textContent).toContain('one');
631
+ expect(tab.querySelector('.iconBox')).not.toBeNull();
632
+ });
633
+
634
+ const getLabelParts = container => {
635
+ const tab = container.querySelector('[role="tab"]');
636
+ const content = tab.firstElementChild;
637
+ const text = Array.from(content.children).find(node => node.textContent === 'one');
638
+ return {
639
+ tab,
640
+ content,
641
+ text
642
+ };
643
+ };
644
+
645
+ test.each([['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT]])('%s aligns the label to the start of the rail with left-aligned text', (_name, preset) => {
646
+ const {
647
+ container
648
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
649
+ tabProps: {
650
+ iconName: 'ZD-TB-menu'
651
+ }
652
+ })));
653
+ const {
654
+ tab,
655
+ content,
656
+ text
657
+ } = getLabelParts(container);
658
+ expect(tab.className).toContain('d-justify-start');
659
+ expect(content.className).toContain('d-justify-start');
660
+ expect(text.className).toContain('textalign_left');
661
+ });
662
+ test.each([['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP], ['INFO_BAR_RAIL_TEXT', INFO_BAR_RAIL_TEXT]])('%s centres the label and its text', (_name, preset) => {
663
+ const {
664
+ container
665
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
666
+ tabProps: {
667
+ iconName: 'ZD-TB-menu'
668
+ }
669
+ })));
670
+ const {
671
+ tab,
672
+ content,
673
+ text
674
+ } = getLabelParts(container);
675
+ expect(tab.className).toContain('d-justify-center');
676
+ expect(content.className).toContain('d-justify-center');
677
+ expect(text.className).toContain('textalign_center');
678
+ });
679
+ test('a horizontal strip keeps a side-icon label centred in its tab', () => {
680
+ const {
681
+ container
682
+ } = render( /*#__PURE__*/React.createElement(Group, {
683
+ labelStyle: LABEL_STYLE.ICON_AND_TEXT,
684
+ isFullWidth: true,
685
+ tabProps: {
686
+ iconName: 'ZD-TB-menu'
687
+ }
688
+ }));
689
+ const {
690
+ tab,
691
+ content
692
+ } = getLabelParts(container);
693
+ expect(tab.className).toContain('d-justify-center');
694
+ expect(content.className).toContain('d-justify-center');
695
+ });
696
+ test.each(ICON_SPACING)('iconSpacing %s maps to a gap utility that css-utility defines', spacing => {
697
+ const utilities = fs.readFileSync(require.resolve('@dot-system/css-utility/es/utilities.plain.css'), 'utf8');
698
+ const {
699
+ container
700
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_ICON_LEFT, {
701
+ iconSpacing: spacing,
702
+ tabProps: {
703
+ iconName: 'ZD-TB-menu'
704
+ }
705
+ })));
706
+ const content = container.querySelector('[role="tab"]').firstElementChild;
707
+ const gapClass = `d-gap-[${spacing}px]`;
708
+ expect(content.classList.contains(gapClass)).toBe(true);
709
+ expect(utilities).toContain(`.d-gap-\\[${spacing}px\\]`);
710
+ });
711
+ test('SUBTAB_STRIP mirrors the ticket detail-view subtabs (v0 delta tabs)', () => {
712
+ expect(SUBTAB_STRIP).toMatchObject({
713
+ position: POSITION.TOP,
714
+ size: SIZE.SMALL,
715
+ variant: VARIANT.DOTTED,
716
+ labelStyle: LABEL_STYLE.TEXT,
717
+ textTransform: 'upper',
718
+ textTruncate: 'ellipsis',
719
+ hasListBorder: true,
720
+ hasListPadding: true
721
+ });
722
+ const {
723
+ container
724
+ } = render( /*#__PURE__*/React.createElement(Group, SUBTAB_STRIP));
725
+ const list = container.querySelector('[role="tablist"]');
726
+ const tab = container.querySelector('[role="tab"]');
727
+ expect(list.className).toContain('listDotted'); // The strip draws its own bottom border and start inset; a consumer only adjusts them.
728
+
729
+ expect(list.className).toContain('listTop');
730
+ expect(list.className).not.toContain('listNoBorder');
731
+ expect(list.className).not.toContain('listNoPadding');
732
+ expect(tab.className).toContain('tabDotted');
733
+ expect(tab.className).toContain('tabSmall');
734
+ expect(tab.querySelector('.transform_upper')).not.toBeNull();
735
+ });
736
+ test('a rail preset can move to the right edge by overriding position', () => {
737
+ const {
738
+ container
739
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_ICON_TOP, {
740
+ position: POSITION.RIGHT
741
+ })));
742
+ expect(container.querySelector('[role="tablist"]').className).toContain('listRight');
743
+ });
744
+ });
745
+ /*
746
+ * The behaviour these cover is not visible in a snapshot: the F1 font-size
747
+ * cascade fix, the F2 customClass merge fix, a keyboard model, and a click
748
+ * that must NOT change state.
749
+ */
750
+
751
+ describe('Tab - Behaviour', () => {
752
+ test('size is the sole font-size axis: no variant declares font-size', () => {
753
+ /*
754
+ * The F1 regression. Size and variant classes sit on the same tab element
755
+ * at equal specificity, and the variant blocks come later in the file - so
756
+ * a variant that declared font-size would always win, and `size` would
757
+ * silently have no visible effect whenever a variant was also set.
758
+ *
759
+ * jsdom applies no CSS-module styles, so the guard is in two parts: both
760
+ * the size and variant classes must reach the tab element together, and
761
+ * the stylesheet must declare font-size in exactly the size blocks, never
762
+ * in the variant blocks.
763
+ */
764
+ const {
765
+ container
766
+ } = render( /*#__PURE__*/React.createElement(Group, {
767
+ size: "large",
768
+ variant: "elevated"
769
+ }));
770
+ const tab = container.querySelector('[role="tab"]');
771
+ expect(tab.className).toContain('tabLarge');
772
+ expect(tab.className).toContain('tabElevated');
773
+ const css = readStylesheet();
774
+
775
+ const block = selector => {
776
+ const match = css.match(new RegExp(`\\.${selector}\\s*\\{([^}]*)\\}`));
777
+ return match ? match[1] : '';
778
+ };
779
+
780
+ expect(block('tabSmall')).toMatch(/font-size/);
781
+ expect(block('tabMedium')).toMatch(/font-size/);
782
+ expect(block('tabLarge')).toMatch(/font-size/);
783
+ expect(block('tabElevated')).not.toMatch(/font-size/);
784
+ expect(block('tabSpaced')).not.toMatch(/font-size/);
785
+ expect(block('tabDotted')).not.toMatch(/font-size/);
786
+ });
787
+ test('the stylesheet exposes no --local-* variables: customClass is the only override path', () => {
788
+ expect(readStylesheet()).not.toMatch(/--local-/);
789
+ });
790
+ test('modifier classes land on the slots, not on the Tabs root', () => {
791
+ const {
792
+ container
793
+ } = render( /*#__PURE__*/React.createElement(Group, {
794
+ size: "small",
795
+ variant: "dotted",
796
+ position: "left",
797
+ hasSurface: true,
798
+ hasListBorder: false,
799
+ hasListPadding: false
800
+ }));
801
+ const root = container.firstChild;
802
+ const list = container.querySelector('[role="tablist"]');
803
+ const tab = container.querySelector('[role="tab"]');
804
+ const panel = container.querySelector('[role="tabpanel"]');
805
+ expect(root.className).not.toMatch(/\b(small|dotted|left|vertical|hasSurface)\b/);
806
+ expect(list.className).toEqual(expect.stringContaining('listDotted'));
807
+ expect(list.className).toEqual(expect.stringContaining('listLeft'));
808
+ expect(list.className).toEqual(expect.stringContaining('listVertical'));
809
+ expect(list.className).toEqual(expect.stringContaining('listSurface'));
810
+ expect(list.className).toEqual(expect.stringContaining('listNoBorder'));
811
+ expect(list.className).toEqual(expect.stringContaining('listNoPadding'));
812
+ expect(tab.className).toEqual(expect.stringContaining('tabSmall'));
813
+ expect(tab.className).toEqual(expect.stringContaining('tabDotted'));
814
+ expect(tab.className).toEqual(expect.stringContaining('tabLeft'));
815
+ expect(tab.className).toEqual(expect.stringContaining('tabVertical'));
816
+ expect(tab.className).toEqual(expect.stringContaining('tabSurface'));
817
+ expect(panel.className).toEqual(expect.stringContaining('panelSurface'));
818
+ expect(panel.className).toEqual(expect.stringContaining('panelDotted'));
819
+ });
820
+ test('a nested Tabs does not inherit the outer variant', () => {
821
+ render( /*#__PURE__*/React.createElement(Tabs, {
822
+ uniqueId: "outer",
823
+ variant: "elevated"
824
+ }, /*#__PURE__*/React.createElement(TabList, {
825
+ ariaLabel: "Outer"
826
+ }, /*#__PURE__*/React.createElement(Tab, {
827
+ value: "o1",
828
+ text: "o1"
829
+ })), /*#__PURE__*/React.createElement(TabPanel, {
830
+ value: "o1"
831
+ }, /*#__PURE__*/React.createElement(Tabs, {
832
+ uniqueId: "inner",
833
+ variant: "underline"
834
+ }, /*#__PURE__*/React.createElement(TabList, {
835
+ ariaLabel: "Inner"
836
+ }, /*#__PURE__*/React.createElement(Tab, {
837
+ value: "i1",
838
+ text: "i1"
839
+ })), /*#__PURE__*/React.createElement(TabPanel, {
840
+ value: "i1"
841
+ }, "Inner panel")))));
842
+ const outerTab = screen.getByRole('tab', {
843
+ name: 'o1'
844
+ });
845
+ const innerTab = screen.getByRole('tab', {
846
+ name: 'i1'
847
+ });
848
+ expect(outerTab.className).toContain('tabElevated');
849
+ expect(innerTab.className).not.toContain('tabElevated');
850
+ expect(screen.getByRole('tablist', {
851
+ name: 'Inner'
852
+ }).className).not.toContain('listElevated');
853
+ });
854
+ test('single-value properties come from d-* utilities, as mutually exclusive variants', () => {
855
+ /*
856
+ * The utility layer and the component layer have no declared order, so a
857
+ * d-* class must never compete with a component rule for one property.
858
+ * Exclusive values are cva variants: exactly one of each pair is applied.
859
+ */
860
+ render( /*#__PURE__*/React.createElement(Tabs, {
861
+ uniqueId: "tabs",
862
+ variant: "dotted"
863
+ }, /*#__PURE__*/React.createElement(TabList, {
864
+ ariaLabel: "Cities"
865
+ }, /*#__PURE__*/React.createElement(Tab, {
866
+ value: "one",
867
+ text: "one"
868
+ }), /*#__PURE__*/React.createElement(Tab, {
869
+ value: "two",
870
+ text: "two",
871
+ isDisabled: true
872
+ }))));
873
+ const [enabled, disabled] = screen.getAllByRole('tab');
874
+ const list = screen.getByRole('tablist');
875
+ expect(enabled.className).toContain('d-cursor-pointer');
876
+ expect(enabled.className).not.toContain('d-cursor-not-allowed');
877
+ expect(disabled.className).toContain('d-cursor-not-allowed');
878
+ expect(disabled.className).not.toContain('d-cursor-pointer');
879
+ expect(list.className).toContain('d-border-dotted');
880
+ expect(list.className).not.toContain('d-border-solid'); // margins are set per variant in the stylesheet, so no d-m-0 to fight them
881
+
882
+ expect(enabled.className).not.toContain('d-m-0');
883
+ });
884
+ test('the stylesheet does not re-declare what a d-* utility now owns', () => {
885
+ const css = readStylesheet();
886
+
887
+ const block = selector => {
888
+ const match = css.match(new RegExp(`(?:^|\\n)\\.${selector}\\s*\\{([^}]*)\\}`));
889
+ return match ? match[1] : null;
890
+ };
891
+
892
+ expect(block('content')).toBeNull();
893
+ expect(block('tabText')).toBeNull();
894
+ expect(block('moreWrapper')).toBeNull();
895
+ expect(block('moreItem')).toBeNull();
896
+ expect(block('list')).not.toMatch(/border-style/);
897
+ expect(block('tab')).not.toMatch(/cursor/);
898
+ expect(css).not.toMatch(/\.listDotted\s*\{[^}]*border-style/);
899
+ });
900
+ test('a customClass slot class is appended after the component classes', () => {
901
+ const {
902
+ container
903
+ } = render( /*#__PURE__*/React.createElement(Group, {
904
+ variant: "elevated",
905
+ customClass: {
906
+ tab: 'my-tab',
907
+ list: 'my-list'
908
+ }
909
+ }));
910
+ const tab = container.querySelector('[role="tab"]');
911
+ const list = container.querySelector('[role="tablist"]');
912
+ expect(tab.className.trim().split(/\s+/).pop()).toBe('my-tab');
913
+ expect(list.className).toMatch(/listElevated.*my-list/);
914
+ });
915
+ test('a group customClass.tab is merged with, not overwritten by, a per-tab getClasses call', () => {
916
+ /*
917
+ * The F2 regression. Tabs.js's `getClasses(extra)` used to spread `extra`
918
+ * over the whole style-props object in one shallow merge, so Tab.js's own
919
+ * `getClasses({ labelStyle, customClass })` call - always made, even when
920
+ * the tab has no per-tab `customClass` of its own - replaced the group's
921
+ * `customClass` outright with `undefined` instead of layering onto it.
922
+ */
923
+ const {
924
+ container
925
+ } = render( /*#__PURE__*/React.createElement(Group, {
926
+ customClass: {
927
+ tab: 'group-tab-class'
928
+ }
929
+ }));
930
+ const tab = container.querySelector('[role="tab"]');
931
+ expect(tab.className).toContain('group-tab-class');
932
+ });
933
+ test('a link tab selects on a plain click and defers to the browser on a modifier click', () => {
934
+ const onChange = jest.fn();
935
+ render( /*#__PURE__*/React.createElement(Tabs, {
936
+ uniqueId: "tabs",
937
+ onChange: onChange
938
+ }, /*#__PURE__*/React.createElement(TabList, {
939
+ ariaLabel: "Cities"
940
+ }, /*#__PURE__*/React.createElement(Tab, {
941
+ value: "one",
942
+ text: "one"
943
+ }), /*#__PURE__*/React.createElement(Tab, {
944
+ value: "two",
945
+ text: "two",
946
+ href: "/two"
947
+ }))));
948
+ const link = screen.getByRole('tab', {
949
+ name: 'two'
950
+ });
951
+ expect(link.tagName).toBe('A');
952
+ expect(link).toHaveAttribute('href', '/two');
953
+ /* Mount already reported one call - the reducer adopting the first enabled
954
+ * tab - so clear before asserting on what the click does. */
955
+
956
+ onChange.mockClear();
957
+ /* Modifier-click is the browser's: open in a new tab, selection untouched. */
958
+
959
+ fireEvent.click(link, {
960
+ metaKey: true
961
+ });
962
+ expect(onChange).not.toHaveBeenCalled();
963
+ fireEvent.click(link);
964
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
965
+ value: 'two'
966
+ }), expect.anything());
967
+ });
968
+ test('a disabled link tab carries no href', () => {
969
+ render( /*#__PURE__*/React.createElement(Tabs, {
970
+ uniqueId: "tabs"
971
+ }, /*#__PURE__*/React.createElement(TabList, {
972
+ ariaLabel: "Cities"
973
+ }, /*#__PURE__*/React.createElement(Tab, {
974
+ value: "one",
975
+ text: "one"
976
+ }), /*#__PURE__*/React.createElement(Tab, {
977
+ value: "two",
978
+ text: "two",
979
+ href: "/two",
980
+ isDisabled: true
981
+ }))));
982
+ const link = screen.getByRole('tab', {
983
+ name: 'two'
984
+ });
985
+ expect(link.tagName).toBe('A');
986
+ expect(link).not.toHaveAttribute('href');
987
+ });
988
+ test('a vertical tablist (position=left) moves focus with ArrowDown, ArrowUp, Home and End', () => {
989
+ render( /*#__PURE__*/React.createElement(Tabs, {
990
+ uniqueId: "tabs",
991
+ position: "left",
992
+ activation: "manual"
993
+ }, /*#__PURE__*/React.createElement(TabList, {
994
+ ariaLabel: "Cities"
995
+ }, /*#__PURE__*/React.createElement(Tab, {
996
+ value: "one",
997
+ text: "one"
998
+ }), /*#__PURE__*/React.createElement(Tab, {
999
+ value: "two",
1000
+ text: "two"
1001
+ }), /*#__PURE__*/React.createElement(Tab, {
1002
+ value: "three",
1003
+ text: "three"
1004
+ }))));
1005
+ const [one, two, three] = screen.getAllByRole('tab');
1006
+ /* Dispatched on the focused tab, which is where a real keypress lands - the
1007
+ * tablist sees it on the way through, in the capture phase. */
1008
+
1009
+ const press = key => fireEvent.keyDown(document.activeElement, {
1010
+ key
1011
+ });
1012
+
1013
+ one.focus();
1014
+ press('ArrowDown');
1015
+ expect(document.activeElement).toBe(two);
1016
+ press('ArrowUp');
1017
+ expect(document.activeElement).toBe(one);
1018
+ press('End');
1019
+ expect(document.activeElement).toBe(three);
1020
+ press('Home');
1021
+ expect(document.activeElement).toBe(one);
1022
+ /* Wraps, matching the horizontal loop useFocusLoop already provides. */
1023
+
1024
+ press('ArrowUp');
1025
+ expect(document.activeElement).toBe(three);
1026
+ });
1027
+ test('vertical arrow keys skip a disabled tab', () => {
1028
+ render( /*#__PURE__*/React.createElement(Tabs, {
1029
+ uniqueId: "tabs",
1030
+ position: "left",
1031
+ activation: "manual"
1032
+ }, /*#__PURE__*/React.createElement(TabList, {
1033
+ ariaLabel: "Cities"
1034
+ }, /*#__PURE__*/React.createElement(Tab, {
1035
+ value: "one",
1036
+ text: "one"
1037
+ }), /*#__PURE__*/React.createElement(Tab, {
1038
+ value: "two",
1039
+ text: "two",
1040
+ isDisabled: true
1041
+ }), /*#__PURE__*/React.createElement(Tab, {
1042
+ value: "three",
1043
+ text: "three"
1044
+ }))));
1045
+ const [one,, three] = screen.getAllByRole('tab');
1046
+ one.focus();
1047
+ fireEvent.keyDown(document.activeElement, {
1048
+ key: 'ArrowDown'
1049
+ });
1050
+ expect(document.activeElement).toBe(three);
1051
+ });
1052
+ test('the overflow menu filters, and shows an empty state when nothing matches', () => {
1053
+ render( /*#__PURE__*/React.createElement(Tabs, {
1054
+ uniqueId: "tabs"
1055
+ }, /*#__PURE__*/React.createElement(TabList, {
1056
+ ariaLabel: "Cities",
1057
+ items: ITEMS,
1058
+ moreMenu: {
1059
+ ariaLabel: 'More tabs',
1060
+ searchThreshold: 1,
1061
+ searchErrorText: 'No results'
1062
+ }
1063
+ })));
1064
+ fireEvent.click(screen.getByRole('button', {
1065
+ name: 'More tabs'
1066
+ }));
1067
+ const search = document.querySelector('input[name="search"]');
1068
+ expect(search).not.toBeNull();
1069
+ expect(screen.getAllByRole('menuitem')).toHaveLength(2);
1070
+ fireEvent.change(search, {
1071
+ target: {
1072
+ value: 'char'
1073
+ }
1074
+ });
1075
+ expect(screen.getAllByRole('menuitem')).toHaveLength(1);
1076
+ expect(screen.getByText('Charlie')).toBeInTheDocument();
1077
+ fireEvent.change(search, {
1078
+ target: {
1079
+ value: 'zzz'
1080
+ }
1081
+ });
1082
+ expect(screen.queryAllByRole('menuitem')).toHaveLength(0);
1083
+ expect(screen.getByText('No results')).toBeInTheDocument();
1084
+ });
1085
+ test('the overflow menu hides its search below the threshold', () => {
1086
+ render( /*#__PURE__*/React.createElement(Tabs, {
1087
+ uniqueId: "tabs"
1088
+ }, /*#__PURE__*/React.createElement(TabList, {
1089
+ ariaLabel: "Cities",
1090
+ items: ITEMS,
1091
+ moreMenu: {
1092
+ ariaLabel: 'More tabs'
1093
+ }
1094
+ })));
1095
+ fireEvent.click(screen.getByRole('button', {
1096
+ name: 'More tabs'
1097
+ }));
1098
+ /* Two tabs collapse here, and the default threshold is 4. */
1099
+
1100
+ expect(document.querySelector('input[name="search"]')).toBeNull();
1101
+ });
1102
+ });