@zohodesk/components 1.6.32 → 1.6.35

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 (234) hide show
  1. package/CHANGELOG.md +13 -0
  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_v1_LightMode.module.css +20 -0
  9. package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +2 -0
  10. package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +2 -0
  11. package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +2 -0
  12. package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +2 -0
  13. package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +2 -0
  14. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +20 -0
  15. package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  16. package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  17. package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  18. package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  19. package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +2 -0
  20. package/cbt.config.js +1 -0
  21. package/es/Accordion/__tests__/Accordion.spec.js +117 -3
  22. package/es/Accordion/__tests__/AccordionItem.spec.js +118 -6
  23. package/es/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
  24. package/es/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
  25. package/es/Animation/__tests__/Animation.spec.js +28 -4
  26. package/es/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
  27. package/es/Button/css/Button.module.css +2 -3
  28. package/es/CheckBox/CheckBox.js +1 -1
  29. package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
  30. package/es/DateTime/DateTime.module.css +2 -2
  31. package/es/DateTime/__tests__/CalendarView.spec.js +70 -3
  32. package/es/DateTime/__tests__/DateTime.spec.js +89 -6
  33. package/es/DateTime/__tests__/DateTimePopupFooter.spec.js +20 -2
  34. package/es/DateTime/__tests__/DateTimePopupHeader.spec.js +29 -2
  35. package/es/DateTime/__tests__/DateWidget.spec.js +34 -2
  36. package/es/DateTime/__tests__/DaysRow.spec.js +19 -3
  37. package/es/DateTime/__tests__/Time.spec.js +50 -3
  38. package/es/DateTime/__tests__/YearView.spec.js +60 -3
  39. package/es/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
  40. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
  41. package/es/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
  42. package/es/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
  43. package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
  44. package/es/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
  45. package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
  46. package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
  47. package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
  48. package/es/Heading/Heading.module.css +1 -1
  49. package/es/Heading/__tests__/Heading.spec.js +57 -3
  50. package/es/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
  51. package/es/ListItem/__tests__/ListContainer.spec.js +228 -1
  52. package/es/ListItem/__tests__/ListItem.spec.js +359 -1
  53. package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +390 -1
  54. package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +214 -1
  55. package/es/ListItem/__tests__/ListItemWithIcon.spec.js +303 -1
  56. package/es/ListItem/__tests__/ListItemWithRadio.spec.js +230 -1
  57. package/es/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
  58. package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
  59. package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
  60. package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
  61. package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
  62. package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
  63. package/es/MultiSelect/MultiSelect.module.css +1 -2
  64. package/es/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +671 -1
  65. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +730 -1
  66. package/es/MultiSelect/__tests__/EmptyState.spec.js +268 -1
  67. package/es/MultiSelect/__tests__/MultiSelect.spec.js +889 -2
  68. package/es/MultiSelect/__tests__/MultiSelectHeader.spec.js +50 -1
  69. package/es/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +487 -1
  70. package/es/MultiSelect/__tests__/SelectedOptions.spec.js +291 -1
  71. package/es/MultiSelect/__tests__/Suggestions.spec.js +370 -2
  72. package/es/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
  73. package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
  74. package/es/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
  75. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
  76. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
  77. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
  78. package/es/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
  79. package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
  80. package/es/PopOver/__tests__/PopOver.spec.js +141 -2
  81. package/es/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
  82. package/es/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +212 -1
  83. package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
  84. package/es/Tab/Tabs.module.css +1 -2
  85. package/es/Tab/__tests__/Tab.spec.js +249 -1
  86. package/es/Tab/__tests__/TabContent.spec.js +34 -1
  87. package/es/Tab/__tests__/TabContentWrapper.spec.js +72 -1
  88. package/es/Tab/__tests__/TabWrapper.spec.js +163 -1
  89. package/es/Tab/__tests__/Tabs.spec.js +681 -1
  90. package/es/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
  91. package/es/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
  92. package/es/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
  93. package/es/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
  94. package/es/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
  95. package/es/Textarea/Textarea.module.css +1 -1
  96. package/es/Tooltip/Tooltip.module.css +1 -2
  97. package/es/Tooltip/__tests__/Tooltip.spec.js +590 -0
  98. package/es/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
  99. package/es/Typography/css/Typography.module.css +8 -7
  100. package/es/common/common.module.css +4 -4
  101. package/es/index.d.ts +39 -0
  102. package/es/index.js +12 -12
  103. package/es/v1/Tab/Tab.js +159 -0
  104. package/es/v1/Tab/TabList.js +153 -0
  105. package/es/v1/Tab/TabMoreMenu.js +245 -0
  106. package/es/v1/Tab/TabPanel.js +51 -0
  107. package/es/v1/Tab/Tabs.js +125 -0
  108. package/es/v1/Tab/__tests__/Tab.spec.js +1082 -0
  109. package/es/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
  110. package/es/v1/Tab/constants/index.js +112 -0
  111. package/es/v1/Tab/constants/presets.js +36 -0
  112. package/es/v1/Tab/context.js +19 -0
  113. package/es/v1/Tab/core/Tab.js +60 -0
  114. package/es/v1/Tab/core/TabList.js +51 -0
  115. package/es/v1/Tab/core/TabListFocusScope.js +18 -0
  116. package/es/v1/Tab/core/TabPanel.js +54 -0
  117. package/es/v1/Tab/core/Tabs.js +45 -0
  118. package/es/v1/Tab/core/index.js +6 -0
  119. package/es/v1/Tab/css/Tab_v1.module.css +335 -0
  120. package/es/v1/Tab/css/cssJSLogic.js +1 -0
  121. package/es/v1/Tab/css/tab.cva.js +205 -0
  122. package/es/v1/Tab/index.js +8 -0
  123. package/es/v1/Tab/props/defaultProps.js +55 -0
  124. package/es/v1/Tab/props/propTypes.js +221 -0
  125. package/es/v1/Tab/utils/pinSelectedTab.js +44 -0
  126. package/lib/Accordion/__tests__/Accordion.spec.js +122 -2
  127. package/lib/Accordion/__tests__/AccordionItem.spec.js +126 -4
  128. package/lib/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
  129. package/lib/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
  130. package/lib/Animation/__tests__/Animation.spec.js +31 -5
  131. package/lib/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
  132. package/lib/Button/css/Button.module.css +2 -3
  133. package/lib/CheckBox/CheckBox.js +1 -1
  134. package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
  135. package/lib/DateTime/DateTime.module.css +2 -2
  136. package/lib/DateTime/__tests__/CalendarView.spec.js +71 -2
  137. package/lib/DateTime/__tests__/DateTime.spec.js +92 -6
  138. package/lib/DateTime/__tests__/DateTimePopupFooter.spec.js +21 -1
  139. package/lib/DateTime/__tests__/DateTimePopupHeader.spec.js +30 -1
  140. package/lib/DateTime/__tests__/DateWidget.spec.js +35 -1
  141. package/lib/DateTime/__tests__/DaysRow.spec.js +20 -2
  142. package/lib/DateTime/__tests__/Time.spec.js +51 -2
  143. package/lib/DateTime/__tests__/YearView.spec.js +61 -2
  144. package/lib/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
  145. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
  146. package/lib/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
  147. package/lib/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
  148. package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
  149. package/lib/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
  150. package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
  151. package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
  152. package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
  153. package/lib/Heading/Heading.module.css +1 -1
  154. package/lib/Heading/__tests__/Heading.spec.js +60 -4
  155. package/lib/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
  156. package/lib/ListItem/__tests__/ListContainer.spec.js +229 -0
  157. package/lib/ListItem/__tests__/ListItem.spec.js +362 -0
  158. package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +391 -0
  159. package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +215 -0
  160. package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +304 -0
  161. package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +231 -0
  162. package/lib/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
  163. package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
  164. package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
  165. package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
  166. package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
  167. package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
  168. package/lib/MultiSelect/MultiSelect.module.css +1 -2
  169. package/lib/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +692 -0
  170. package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +741 -0
  171. package/lib/MultiSelect/__tests__/EmptyState.spec.js +273 -0
  172. package/lib/MultiSelect/__tests__/MultiSelect.spec.js +910 -0
  173. package/lib/MultiSelect/__tests__/MultiSelectHeader.spec.js +51 -0
  174. package/lib/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +497 -0
  175. package/lib/MultiSelect/__tests__/SelectedOptions.spec.js +305 -0
  176. package/lib/MultiSelect/__tests__/Suggestions.spec.js +375 -0
  177. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
  178. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
  179. package/lib/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
  180. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
  181. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
  182. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
  183. package/lib/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
  184. package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
  185. package/lib/PopOver/__tests__/PopOver.spec.js +150 -1
  186. package/lib/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
  187. package/lib/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +213 -0
  188. package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
  189. package/lib/Tab/Tabs.module.css +1 -2
  190. package/lib/Tab/__tests__/Tab.spec.js +250 -0
  191. package/lib/Tab/__tests__/TabContent.spec.js +35 -0
  192. package/lib/Tab/__tests__/TabContentWrapper.spec.js +76 -0
  193. package/lib/Tab/__tests__/TabWrapper.spec.js +174 -0
  194. package/lib/Tab/__tests__/Tabs.spec.js +741 -0
  195. package/lib/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
  196. package/lib/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
  197. package/lib/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
  198. package/lib/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
  199. package/lib/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
  200. package/lib/Textarea/Textarea.module.css +1 -1
  201. package/lib/Tooltip/Tooltip.module.css +1 -2
  202. package/lib/Tooltip/__tests__/Tooltip.spec.js +629 -0
  203. package/lib/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
  204. package/lib/Typography/css/Typography.module.css +8 -7
  205. package/lib/common/common.module.css +4 -4
  206. package/lib/index.d.ts +39 -0
  207. package/lib/index.js +270 -173
  208. package/lib/v1/Tab/Tab.js +180 -0
  209. package/lib/v1/Tab/TabList.js +191 -0
  210. package/lib/v1/Tab/TabMoreMenu.js +284 -0
  211. package/lib/v1/Tab/TabPanel.js +64 -0
  212. package/lib/v1/Tab/Tabs.js +151 -0
  213. package/lib/v1/Tab/__tests__/Tab.spec.js +1174 -0
  214. package/lib/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
  215. package/lib/v1/Tab/constants/index.js +113 -0
  216. package/lib/v1/Tab/constants/presets.js +64 -0
  217. package/lib/v1/Tab/context.js +30 -0
  218. package/lib/v1/Tab/core/Tab.js +89 -0
  219. package/lib/v1/Tab/core/TabList.js +82 -0
  220. package/lib/v1/Tab/core/TabListFocusScope.js +28 -0
  221. package/lib/v1/Tab/core/TabPanel.js +85 -0
  222. package/lib/v1/Tab/core/Tabs.js +63 -0
  223. package/lib/v1/Tab/core/index.js +109 -0
  224. package/lib/v1/Tab/css/Tab_v1.module.css +335 -0
  225. package/lib/v1/Tab/css/cssJSLogic.js +25 -0
  226. package/lib/v1/Tab/css/tab.cva.js +192 -0
  227. package/lib/v1/Tab/index.js +159 -0
  228. package/lib/v1/Tab/props/defaultProps.js +69 -0
  229. package/lib/v1/Tab/props/propTypes.js +246 -0
  230. package/lib/v1/Tab/utils/pinSelectedTab.js +59 -0
  231. package/package.json +16 -13
  232. package/tsconfig.jest.json +5 -0
  233. package/tsconfig.json +9 -0
  234. package/ut.config.js +2 -1
@@ -0,0 +1,1082 @@
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
+ labelStyle: LABEL_STYLE.TEXT,
716
+ textTransform: 'upper',
717
+ textTruncate: 'ellipsis',
718
+ hasListBorder: true,
719
+ hasListPadding: true
720
+ }); // The preset leaves variant to the consumer, so the strip renders the default underline.
721
+
722
+ expect(SUBTAB_STRIP).not.toHaveProperty('variant');
723
+ const {
724
+ container
725
+ } = render( /*#__PURE__*/React.createElement(Group, SUBTAB_STRIP));
726
+ const list = container.querySelector('[role="tablist"]');
727
+ const tab = container.querySelector('[role="tab"]');
728
+ expect(list.className).toContain('d-border-solid');
729
+ expect(list.className).not.toContain('listDotted'); // The strip draws its own bottom border and start inset; a consumer only adjusts them.
730
+
731
+ expect(list.className).toContain('listTop');
732
+ expect(list.className).not.toContain('listNoBorder');
733
+ expect(list.className).not.toContain('listNoPadding');
734
+ expect(tab.className).not.toContain('tabDotted');
735
+ expect(tab.className).toContain('tabSmall');
736
+ expect(tab.querySelector('.transform_upper')).not.toBeNull();
737
+ });
738
+ test('a rail preset can move to the right edge by overriding position', () => {
739
+ const {
740
+ container
741
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_ICON_TOP, {
742
+ position: POSITION.RIGHT
743
+ })));
744
+ expect(container.querySelector('[role="tablist"]').className).toContain('listRight');
745
+ });
746
+ });
747
+ /*
748
+ * The behaviour these cover is not visible in a snapshot: the F1 font-size
749
+ * cascade fix, the F2 customClass merge fix, a keyboard model, and a click
750
+ * that must NOT change state.
751
+ */
752
+
753
+ describe('Tab - Behaviour', () => {
754
+ test('size is the sole font-size axis: no variant declares font-size', () => {
755
+ /*
756
+ * The F1 regression. Size and variant classes sit on the same tab element
757
+ * at equal specificity, and the variant blocks come later in the file - so
758
+ * a variant that declared font-size would always win, and `size` would
759
+ * silently have no visible effect whenever a variant was also set.
760
+ *
761
+ * jsdom applies no CSS-module styles, so the guard is in two parts: both
762
+ * the size and variant classes must reach the tab element together, and
763
+ * the stylesheet must declare font-size in exactly the size blocks, never
764
+ * in the variant blocks.
765
+ */
766
+ const {
767
+ container
768
+ } = render( /*#__PURE__*/React.createElement(Group, {
769
+ size: "large",
770
+ variant: "elevated"
771
+ }));
772
+ const tab = container.querySelector('[role="tab"]');
773
+ expect(tab.className).toContain('tabLarge');
774
+ expect(tab.className).toContain('tabElevated');
775
+ const css = readStylesheet();
776
+
777
+ const block = selector => {
778
+ const match = css.match(new RegExp(`\\.${selector}\\s*\\{([^}]*)\\}`));
779
+ return match ? match[1] : '';
780
+ };
781
+
782
+ expect(block('tabSmall')).toMatch(/font-size/);
783
+ expect(block('tabMedium')).toMatch(/font-size/);
784
+ expect(block('tabLarge')).toMatch(/font-size/);
785
+ expect(block('tabElevated')).not.toMatch(/font-size/);
786
+ expect(block('tabSpaced')).not.toMatch(/font-size/);
787
+ expect(block('tabDotted')).not.toMatch(/font-size/);
788
+ });
789
+ test('the stylesheet exposes no --local-* variables: customClass is the only override path', () => {
790
+ expect(readStylesheet()).not.toMatch(/--local-/);
791
+ });
792
+ test('modifier classes land on the slots, not on the Tabs root', () => {
793
+ const {
794
+ container
795
+ } = render( /*#__PURE__*/React.createElement(Group, {
796
+ size: "small",
797
+ variant: "dotted",
798
+ position: "left",
799
+ hasSurface: true,
800
+ hasListBorder: false,
801
+ hasListPadding: false
802
+ }));
803
+ const root = container.firstChild;
804
+ const list = container.querySelector('[role="tablist"]');
805
+ const tab = container.querySelector('[role="tab"]');
806
+ const panel = container.querySelector('[role="tabpanel"]');
807
+ expect(root.className).not.toMatch(/\b(small|dotted|left|vertical|hasSurface)\b/);
808
+ expect(list.className).toEqual(expect.stringContaining('listDotted'));
809
+ expect(list.className).toEqual(expect.stringContaining('listLeft'));
810
+ expect(list.className).toEqual(expect.stringContaining('listVertical'));
811
+ expect(list.className).toEqual(expect.stringContaining('listSurface'));
812
+ expect(list.className).toEqual(expect.stringContaining('listNoBorder'));
813
+ expect(list.className).toEqual(expect.stringContaining('listNoPadding'));
814
+ expect(tab.className).toEqual(expect.stringContaining('tabSmall'));
815
+ expect(tab.className).toEqual(expect.stringContaining('tabDotted'));
816
+ expect(tab.className).toEqual(expect.stringContaining('tabLeft'));
817
+ expect(tab.className).toEqual(expect.stringContaining('tabVertical'));
818
+ expect(tab.className).toEqual(expect.stringContaining('tabSurface'));
819
+ expect(panel.className).toEqual(expect.stringContaining('panelSurface'));
820
+ });
821
+ test('a nested Tabs does not inherit the outer variant', () => {
822
+ render( /*#__PURE__*/React.createElement(Tabs, {
823
+ uniqueId: "outer",
824
+ variant: "elevated"
825
+ }, /*#__PURE__*/React.createElement(TabList, {
826
+ ariaLabel: "Outer"
827
+ }, /*#__PURE__*/React.createElement(Tab, {
828
+ value: "o1",
829
+ text: "o1"
830
+ })), /*#__PURE__*/React.createElement(TabPanel, {
831
+ value: "o1"
832
+ }, /*#__PURE__*/React.createElement(Tabs, {
833
+ uniqueId: "inner",
834
+ variant: "underline"
835
+ }, /*#__PURE__*/React.createElement(TabList, {
836
+ ariaLabel: "Inner"
837
+ }, /*#__PURE__*/React.createElement(Tab, {
838
+ value: "i1",
839
+ text: "i1"
840
+ })), /*#__PURE__*/React.createElement(TabPanel, {
841
+ value: "i1"
842
+ }, "Inner panel")))));
843
+ const outerTab = screen.getByRole('tab', {
844
+ name: 'o1'
845
+ });
846
+ const innerTab = screen.getByRole('tab', {
847
+ name: 'i1'
848
+ });
849
+ expect(outerTab.className).toContain('tabElevated');
850
+ expect(innerTab.className).not.toContain('tabElevated');
851
+ expect(screen.getByRole('tablist', {
852
+ name: 'Inner'
853
+ }).className).not.toContain('listElevated');
854
+ });
855
+ test('single-value properties come from d-* utilities, as mutually exclusive variants', () => {
856
+ /*
857
+ * The utility layer and the component layer have no declared order, so a
858
+ * d-* class must never compete with a component rule for one property.
859
+ * Exclusive values are cva variants: exactly one of each pair is applied.
860
+ */
861
+ render( /*#__PURE__*/React.createElement(Tabs, {
862
+ uniqueId: "tabs",
863
+ variant: "dotted"
864
+ }, /*#__PURE__*/React.createElement(TabList, {
865
+ ariaLabel: "Cities"
866
+ }, /*#__PURE__*/React.createElement(Tab, {
867
+ value: "one",
868
+ text: "one"
869
+ }), /*#__PURE__*/React.createElement(Tab, {
870
+ value: "two",
871
+ text: "two",
872
+ isDisabled: true
873
+ }))));
874
+ const [enabled, disabled] = screen.getAllByRole('tab');
875
+ const list = screen.getByRole('tablist');
876
+ expect(enabled.className).toContain('d-cursor-pointer');
877
+ expect(enabled.className).not.toContain('d-cursor-not-allowed');
878
+ expect(disabled.className).toContain('d-cursor-not-allowed');
879
+ expect(disabled.className).not.toContain('d-cursor-pointer');
880
+ expect(list.className).toContain('d-border-dotted');
881
+ expect(list.className).not.toContain('d-border-solid'); // margins are set per variant in the stylesheet, so no d-m-0 to fight them
882
+
883
+ expect(enabled.className).not.toContain('d-m-0');
884
+ });
885
+ test('the stylesheet does not re-declare what a d-* utility now owns', () => {
886
+ const css = readStylesheet();
887
+
888
+ const block = selector => {
889
+ const match = css.match(new RegExp(`(?:^|\\n)\\.${selector}\\s*\\{([^}]*)\\}`));
890
+ return match ? match[1] : null;
891
+ };
892
+
893
+ expect(block('content')).toBeNull();
894
+ expect(block('tabText')).toBeNull();
895
+ expect(block('moreWrapper')).toBeNull();
896
+ expect(block('moreItem')).toBeNull();
897
+ expect(block('list')).not.toMatch(/border-style/);
898
+ expect(block('tab')).not.toMatch(/cursor/);
899
+ expect(css).not.toMatch(/\.listDotted\s*\{[^}]*border-style/);
900
+ });
901
+ test('a customClass slot class is appended after the component classes', () => {
902
+ const {
903
+ container
904
+ } = render( /*#__PURE__*/React.createElement(Group, {
905
+ variant: "elevated",
906
+ customClass: {
907
+ tab: 'my-tab',
908
+ list: 'my-list'
909
+ }
910
+ }));
911
+ const tab = container.querySelector('[role="tab"]');
912
+ const list = container.querySelector('[role="tablist"]');
913
+ expect(tab.className.trim().split(/\s+/).pop()).toBe('my-tab');
914
+ expect(list.className).toMatch(/listElevated.*my-list/);
915
+ });
916
+ test('a group customClass.tab is merged with, not overwritten by, a per-tab getClasses call', () => {
917
+ /*
918
+ * The F2 regression. Tabs.js's `getClasses(extra)` used to spread `extra`
919
+ * over the whole style-props object in one shallow merge, so Tab.js's own
920
+ * `getClasses({ labelStyle, customClass })` call - always made, even when
921
+ * the tab has no per-tab `customClass` of its own - replaced the group's
922
+ * `customClass` outright with `undefined` instead of layering onto it.
923
+ */
924
+ const {
925
+ container
926
+ } = render( /*#__PURE__*/React.createElement(Group, {
927
+ customClass: {
928
+ tab: 'group-tab-class'
929
+ }
930
+ }));
931
+ const tab = container.querySelector('[role="tab"]');
932
+ expect(tab.className).toContain('group-tab-class');
933
+ });
934
+ test('a disabled link tab carries no href', () => {
935
+ render( /*#__PURE__*/React.createElement(Tabs, {
936
+ uniqueId: "tabs"
937
+ }, /*#__PURE__*/React.createElement(TabList, {
938
+ ariaLabel: "Cities"
939
+ }, /*#__PURE__*/React.createElement(Tab, {
940
+ value: "one",
941
+ text: "one"
942
+ }), /*#__PURE__*/React.createElement(Tab, {
943
+ value: "two",
944
+ text: "two",
945
+ href: "/two",
946
+ isDisabled: true
947
+ }))));
948
+ const link = screen.getByRole('tab', {
949
+ name: 'two'
950
+ });
951
+ expect(link.tagName).toBe('A');
952
+ expect(link).not.toHaveAttribute('href');
953
+ });
954
+ test('the overflow menu filters, and shows an empty state when nothing matches', () => {
955
+ render( /*#__PURE__*/React.createElement(Tabs, {
956
+ uniqueId: "tabs"
957
+ }, /*#__PURE__*/React.createElement(TabList, {
958
+ ariaLabel: "Cities",
959
+ items: ITEMS,
960
+ moreMenu: {
961
+ ariaLabel: 'More tabs',
962
+ searchThreshold: 1,
963
+ searchErrorText: 'No results'
964
+ }
965
+ })));
966
+ fireEvent.click(screen.getByRole('button', {
967
+ name: 'More tabs'
968
+ }));
969
+ const search = document.querySelector('input[name="search"]');
970
+ expect(search).not.toBeNull();
971
+ expect(screen.getAllByRole('menuitem')).toHaveLength(2);
972
+ fireEvent.change(search, {
973
+ target: {
974
+ value: 'char'
975
+ }
976
+ });
977
+ expect(screen.getAllByRole('menuitem')).toHaveLength(1);
978
+ expect(screen.getByText('Charlie')).toBeInTheDocument();
979
+ fireEvent.change(search, {
980
+ target: {
981
+ value: 'zzz'
982
+ }
983
+ });
984
+ expect(screen.queryAllByRole('menuitem')).toHaveLength(0);
985
+ expect(screen.getByText('No results')).toBeInTheDocument();
986
+ });
987
+ test('the overflow menu hides its search below the threshold', () => {
988
+ render( /*#__PURE__*/React.createElement(Tabs, {
989
+ uniqueId: "tabs"
990
+ }, /*#__PURE__*/React.createElement(TabList, {
991
+ ariaLabel: "Cities",
992
+ items: ITEMS,
993
+ moreMenu: {
994
+ ariaLabel: 'More tabs'
995
+ }
996
+ })));
997
+ fireEvent.click(screen.getByRole('button', {
998
+ name: 'More tabs'
999
+ }));
1000
+ /* Two tabs collapse here, and the default threshold is 4. */
1001
+
1002
+ expect(document.querySelector('input[name="search"]')).toBeNull();
1003
+ });
1004
+ });
1005
+ /*
1006
+ * Per-item customClass exists for the ticket detail-view subtab strip, where a
1007
+ * custom-lookup tab caps its own width.
1008
+ */
1009
+
1010
+ describe('Tab - Item customClass and an inline more menu', () => {
1011
+ test('a data-driven item customClass lands on that tab only', () => {
1012
+ render( /*#__PURE__*/React.createElement(Tabs, {
1013
+ uniqueId: "tabs"
1014
+ }, /*#__PURE__*/React.createElement(TabList, {
1015
+ ariaLabel: "Cities",
1016
+ minVisibleTabs: ITEMS.length,
1017
+ items: ITEMS.map(item => item.value === 'b' ? { ...item,
1018
+ customClass: {
1019
+ tab: 'capped-tab'
1020
+ }
1021
+ } : item)
1022
+ })));
1023
+ expect(screen.getByRole('tab', {
1024
+ name: 'Bravo'
1025
+ }).className).toContain('capped-tab');
1026
+ expect(screen.getByRole('tab', {
1027
+ name: 'Alpha'
1028
+ }).className).not.toContain('capped-tab');
1029
+ expect(screen.getByRole('tab', {
1030
+ name: 'Charlie'
1031
+ }).className).not.toContain('capped-tab');
1032
+ });
1033
+ test('changing only an item customClass re-renders that tab', () => {
1034
+ const renderList = tabClass => /*#__PURE__*/React.createElement(Tabs, {
1035
+ uniqueId: "tabs"
1036
+ }, /*#__PURE__*/React.createElement(TabList, {
1037
+ ariaLabel: "Cities",
1038
+ minVisibleTabs: ITEMS.length,
1039
+ items: ITEMS.map(item => item.value === 'a' ? { ...item,
1040
+ customClass: {
1041
+ tab: tabClass
1042
+ }
1043
+ } : item)
1044
+ }));
1045
+
1046
+ const {
1047
+ rerender
1048
+ } = render(renderList('first-class'));
1049
+ rerender(renderList('second-class'));
1050
+ const tab = screen.getByRole('tab', {
1051
+ name: 'Alpha'
1052
+ });
1053
+ expect(tab.className).toContain('second-class');
1054
+ expect(tab.className).not.toContain('first-class');
1055
+ });
1056
+ test('the data-driven list clips overflow only while the more menu is portalled', () => {
1057
+ const {
1058
+ rerender
1059
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
1060
+ uniqueId: "tabs"
1061
+ }, /*#__PURE__*/React.createElement(TabList, {
1062
+ ariaLabel: "Cities",
1063
+ items: ITEMS
1064
+ })));
1065
+ expect(screen.getByRole('tablist').className).toContain('d-overflow-hidden');
1066
+ /* An inline (absolutely positioned) menu renders inside the list, so a
1067
+ * clipping list would hide it. */
1068
+
1069
+ rerender( /*#__PURE__*/React.createElement(Tabs, {
1070
+ uniqueId: "tabs"
1071
+ }, /*#__PURE__*/React.createElement(TabList, {
1072
+ ariaLabel: "Cities",
1073
+ items: ITEMS,
1074
+ customProps: {
1075
+ popup: {
1076
+ isAbsolutePositioningNeeded: true
1077
+ }
1078
+ }
1079
+ })));
1080
+ expect(screen.getByRole('tablist').className).not.toContain('d-overflow-hidden');
1081
+ });
1082
+ });