@zohodesk/components 1.2.4 → 1.2.6

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 (202) hide show
  1. package/README.md +8 -0
  2. package/coverage/Button/Button.js.html +1 -1
  3. package/coverage/Button/css/Button.module.css.html +1 -1
  4. package/coverage/Button/css/cssJSLogic.js.html +1 -1
  5. package/coverage/Button/css/index.html +1 -1
  6. package/coverage/Button/index.html +1 -1
  7. package/coverage/Button/props/defaultProps.js.html +1 -1
  8. package/coverage/Button/props/index.html +1 -1
  9. package/coverage/Button/props/propTypes.js.html +1 -1
  10. package/coverage/Buttongroup/Buttongroup.js.html +1 -1
  11. package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
  12. package/coverage/Buttongroup/index.html +1 -1
  13. package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
  14. package/coverage/Buttongroup/props/index.html +1 -1
  15. package/coverage/Buttongroup/props/propTypes.js.html +1 -1
  16. package/coverage/index.html +1 -1
  17. package/coverage/utils/dummyFunction.js.html +1 -1
  18. package/coverage/utils/index.html +1 -1
  19. package/es/AppContainer/AppContainer.js +3 -0
  20. package/es/v1/Accordion/Accordion.js +65 -0
  21. package/es/v1/Accordion/AccordionItem.js +57 -0
  22. package/es/v1/Accordion/index.js +2 -0
  23. package/es/v1/Animation/Animation.js +127 -0
  24. package/es/v1/AppContainer/AppContainer.js +137 -0
  25. package/es/v1/Avatar/Avatar.js +189 -0
  26. package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
  27. package/es/v1/Button/Button.js +68 -0
  28. package/es/v1/Buttongroup/Buttongroup.js +31 -0
  29. package/es/v1/Card/Card.js +271 -0
  30. package/es/v1/CheckBox/CheckBox.js +155 -0
  31. package/es/v1/DateTime/CalendarView.js +218 -0
  32. package/es/v1/DateTime/DateTime.js +783 -0
  33. package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
  34. package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
  35. package/es/v1/DateTime/DateWidget.js +1098 -0
  36. package/es/v1/DateTime/DaysRow.js +31 -0
  37. package/es/v1/DateTime/Time.js +166 -0
  38. package/es/v1/DateTime/YearView.js +264 -0
  39. package/es/v1/DateTime/index.js +1 -0
  40. package/es/v1/DropBox/DropBox.js +91 -0
  41. package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
  42. package/es/v1/DropDown/DropDown.js +73 -0
  43. package/es/v1/DropDown/DropDownHeading.js +44 -0
  44. package/es/v1/DropDown/DropDownItem.js +76 -0
  45. package/es/v1/DropDown/DropDownSearch.js +63 -0
  46. package/es/v1/DropDown/DropDownSeparator.js +15 -0
  47. package/es/v1/Heading/Heading.js +32 -0
  48. package/es/v1/Label/Label.js +40 -0
  49. package/es/v1/Layout/Box.js +115 -0
  50. package/es/v1/Layout/Container.js +132 -0
  51. package/es/v1/Layout/index.js +2 -0
  52. package/es/v1/ListItem/ListContainer.js +102 -0
  53. package/es/v1/ListItem/ListItem.js +124 -0
  54. package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
  55. package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
  56. package/es/v1/ListItem/ListItemWithIcon.js +127 -0
  57. package/es/v1/ListItem/ListItemWithRadio.js +105 -0
  58. package/es/v1/ListItem/index.js +6 -0
  59. package/es/v1/Modal/Modal.js +154 -0
  60. package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
  61. package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
  62. package/es/v1/MultiSelect/EmptyState.js +64 -0
  63. package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
  64. package/es/v1/MultiSelect/MultiSelect.js +1120 -0
  65. package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
  66. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
  67. package/es/v1/MultiSelect/SelectedOptions.js +82 -0
  68. package/es/v1/MultiSelect/Suggestions.js +142 -0
  69. package/es/v1/MultiSelect/index.js +4 -0
  70. package/es/v1/PopOver/PopOver.js +211 -0
  71. package/es/v1/Popup/Popup.js +645 -0
  72. package/es/v1/Radio/Radio.js +115 -0
  73. package/es/v1/Responsive/CustomResponsive.js +195 -0
  74. package/es/v1/Responsive/RefWrapper.js +39 -0
  75. package/es/v1/Responsive/ResizeComponent.js +197 -0
  76. package/es/v1/Responsive/ResizeObserver.js +140 -0
  77. package/es/v1/Responsive/Responsive.js +194 -0
  78. package/es/v1/Responsive/index.js +9 -0
  79. package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
  80. package/es/v1/Ribbon/Ribbon.js +33 -0
  81. package/es/v1/RippleEffect/RippleEffect.js +24 -0
  82. package/es/v1/Select/GroupSelect.js +803 -0
  83. package/es/v1/Select/Select.js +969 -0
  84. package/es/v1/Select/SelectWithAvatar.js +344 -0
  85. package/es/v1/Select/SelectWithIcon.js +535 -0
  86. package/es/v1/Select/index.js +4 -0
  87. package/es/v1/Stencils/Stencils.js +26 -0
  88. package/es/v1/Switch/Switch.js +94 -0
  89. package/es/v1/Tab/Tab.js +108 -0
  90. package/es/v1/Tab/TabContent.js +30 -0
  91. package/es/v1/Tab/TabContentWrapper.js +29 -0
  92. package/es/v1/Tab/TabWrapper.js +57 -0
  93. package/es/v1/Tab/Tabs.js +612 -0
  94. package/es/v1/Tab/index.js +5 -0
  95. package/es/v1/Tag/Tag.js +134 -0
  96. package/es/v1/TextBox/TextBox.js +154 -0
  97. package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
  98. package/es/v1/Textarea/Textarea.js +102 -0
  99. package/es/v1/Tooltip/Tooltip.js +518 -0
  100. package/es/v1/Typography/Typography.js +38 -0
  101. package/es/v1/Typography/css/Typography.module.css +376 -0
  102. package/es/v1/Typography/css/cssJSLogic.js +46 -0
  103. package/es/v1/Typography/css/letterSpacingMap.js +12 -0
  104. package/es/v1/Typography/props/defaultProps.js +8 -0
  105. package/es/v1/Typography/props/propTypes.js +24 -0
  106. package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
  107. package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
  108. package/es/v1/semantic/Button/Button.js +53 -0
  109. package/es/v1/semantic/index.js +1 -0
  110. package/lib/AppContainer/AppContainer.js +5 -0
  111. package/lib/v1/Accordion/Accordion.js +96 -0
  112. package/lib/v1/Accordion/AccordionItem.js +68 -0
  113. package/lib/v1/Accordion/index.js +23 -0
  114. package/lib/v1/Animation/Animation.js +143 -0
  115. package/lib/v1/AppContainer/AppContainer.js +209 -0
  116. package/lib/v1/Avatar/Avatar.js +246 -0
  117. package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
  118. package/lib/v1/Button/Button.js +82 -0
  119. package/lib/v1/Buttongroup/Buttongroup.js +44 -0
  120. package/lib/v1/Card/Card.js +365 -0
  121. package/lib/v1/CheckBox/CheckBox.js +166 -0
  122. package/lib/v1/DateTime/CalendarView.js +285 -0
  123. package/lib/v1/DateTime/DateTime.js +872 -0
  124. package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
  125. package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
  126. package/lib/v1/DateTime/DateWidget.js +1125 -0
  127. package/lib/v1/DateTime/DaysRow.js +80 -0
  128. package/lib/v1/DateTime/Time.js +254 -0
  129. package/lib/v1/DateTime/YearView.js +325 -0
  130. package/lib/v1/DateTime/index.js +15 -0
  131. package/lib/v1/DropBox/DropBox.js +119 -0
  132. package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
  133. package/lib/v1/DropDown/DropDown.js +170 -0
  134. package/lib/v1/DropDown/DropDownHeading.js +93 -0
  135. package/lib/v1/DropDown/DropDownItem.js +127 -0
  136. package/lib/v1/DropDown/DropDownSearch.js +113 -0
  137. package/lib/v1/DropDown/DropDownSeparator.js +64 -0
  138. package/lib/v1/Heading/Heading.js +49 -0
  139. package/lib/v1/Label/Label.js +51 -0
  140. package/lib/v1/Layout/Box.js +128 -0
  141. package/lib/v1/Layout/Container.js +145 -0
  142. package/lib/v1/Layout/index.js +23 -0
  143. package/lib/v1/ListItem/ListContainer.js +120 -0
  144. package/lib/v1/ListItem/ListItem.js +138 -0
  145. package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
  146. package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
  147. package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
  148. package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
  149. package/lib/v1/ListItem/index.js +55 -0
  150. package/lib/v1/Modal/Modal.js +212 -0
  151. package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
  152. package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
  153. package/lib/v1/MultiSelect/EmptyState.js +112 -0
  154. package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
  155. package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
  156. package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
  157. package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
  158. package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
  159. package/lib/v1/MultiSelect/Suggestions.js +195 -0
  160. package/lib/v1/MultiSelect/index.js +39 -0
  161. package/lib/v1/PopOver/PopOver.js +293 -0
  162. package/lib/v1/Popup/Popup.js +715 -0
  163. package/lib/v1/Radio/Radio.js +126 -0
  164. package/lib/v1/Responsive/CustomResponsive.js +242 -0
  165. package/lib/v1/Responsive/RefWrapper.js +57 -0
  166. package/lib/v1/Responsive/ResizeComponent.js +268 -0
  167. package/lib/v1/Responsive/ResizeObserver.js +168 -0
  168. package/lib/v1/Responsive/Responsive.js +274 -0
  169. package/lib/v1/Responsive/index.js +55 -0
  170. package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
  171. package/lib/v1/Ribbon/Ribbon.js +44 -0
  172. package/lib/v1/RippleEffect/RippleEffect.js +39 -0
  173. package/lib/v1/Select/GroupSelect.js +877 -0
  174. package/lib/v1/Select/Select.js +1013 -0
  175. package/lib/v1/Select/SelectWithAvatar.js +394 -0
  176. package/lib/v1/Select/SelectWithIcon.js +597 -0
  177. package/lib/v1/Select/index.js +39 -0
  178. package/lib/v1/Stencils/Stencils.js +43 -0
  179. package/lib/v1/Switch/Switch.js +108 -0
  180. package/lib/v1/Tab/Tab.js +132 -0
  181. package/lib/v1/Tab/TabContent.js +42 -0
  182. package/lib/v1/Tab/TabContentWrapper.js +42 -0
  183. package/lib/v1/Tab/TabWrapper.js +89 -0
  184. package/lib/v1/Tab/Tabs.js +680 -0
  185. package/lib/v1/Tab/index.js +47 -0
  186. package/lib/v1/Tag/Tag.js +154 -0
  187. package/lib/v1/TextBox/TextBox.js +168 -0
  188. package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
  189. package/lib/v1/Textarea/Textarea.js +118 -0
  190. package/lib/v1/Tooltip/Tooltip.js +586 -0
  191. package/lib/v1/Typography/Typography.js +56 -0
  192. package/lib/v1/Typography/css/Typography.module.css +376 -0
  193. package/lib/v1/Typography/css/cssJSLogic.js +41 -0
  194. package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
  195. package/lib/v1/Typography/props/defaultProps.js +15 -0
  196. package/lib/v1/Typography/props/propTypes.js +35 -0
  197. package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
  198. package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
  199. package/lib/v1/semantic/Button/Button.js +63 -0
  200. package/lib/v1/semantic/index.js +15 -0
  201. package/package.json +1 -1
  202. package/result.json +1 -1
@@ -0,0 +1,612 @@
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
+ /* eslint-disable react/forbid-component-props */
4
+
5
+ /* eslint css-modules/no-unused-class: [2, {
6
+ markAsUsed: [
7
+ 'hidden','alpha','gamma','beta','delta','special','text','maxWidth','widgetList','menuContainer','border','tabText','block','tabAlpha','alphaActive','gammaActive','betaActive','deltaActive','tabGamma','tabBeta','tabDelta','specialActive','tabSpecial',
8
+ 'alpha_padding','alpha_border','gamma_padding','gamma_border','beta_padding','beta_border','delta_padding','delta_border','textContainer','disabled','alphaActive_border','gammaActive_border','betaActive_border','deltaActive_border'
9
+ ]
10
+ }]
11
+ */
12
+ import React from 'react';
13
+ import Tab from './Tab';
14
+ import { Tabs_defaultProps } from '../../Tab/props/defaultProps';
15
+ import { Tabs_propTypes } from '../../Tab/props/propTypes';
16
+ import { remConvert, getTotalDimension, cs, bind, throttle, cancelBubblingEffect } from '../../utils/Common';
17
+ import { Box, Container } from '../Layout';
18
+ import ResizeObserver from '../Responsive/ResizeObserver';
19
+ import ListItem from '../ListItem/ListItem';
20
+ import { Icon } from '@zohodesk/icons';
21
+ import tabsStyle from '../../Tab/Tabs.module.css';
22
+ import Popup from '../Popup/Popup';
23
+ import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
24
+ import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
25
+ import btnstyle from '../../semantic/Button/semanticButton.module.css';
26
+
27
+ class Tabs extends React.Component {
28
+ constructor(props) {
29
+ super(props);
30
+ this.state = {
31
+ totalDimension: null,
32
+ tabDimensions: {},
33
+ highlightInitialDimension: null,
34
+ renderVirtualTabs: true,
35
+ tabKeys: []
36
+ };
37
+ bind.apply(this, ['moreTabSelect', 'onResize', 'onTabResize', 'getHighlightRef', 'getTabsRef', 'getTabRef', 'getHighlightDim', 'onSizeChange', 'onScroll', 'togglePopup', 'setMaxDim']);
38
+ this.tabsObserver = new ResizeObserver(this.onResize);
39
+ this.tabObserver = {};
40
+ }
41
+
42
+ onTabResize(size, target) {
43
+ let {
44
+ align
45
+ } = this.props;
46
+ let {
47
+ tabDimensions
48
+ } = this.state;
49
+ let newDim = Object.assign({}, tabDimensions);
50
+ let elemDim = getTotalDimension(target, align);
51
+
52
+ if (elemDim !== 0) {
53
+ newDim[target.dataset.key] = elemDim;
54
+ }
55
+
56
+ this.setState({
57
+ tabDimensions: newDim
58
+ });
59
+ }
60
+
61
+ componentDidMount() {
62
+ let {
63
+ children,
64
+ childType
65
+ } = this.props;
66
+ let totalDimension = this.getTotalDimension();
67
+ let tabDimensions = this.getTabDimensions();
68
+ let tabKeys = [];
69
+ let restrictedKeys = ['state', 'props', 'refs', 'context'];
70
+ React.Children.toArray(children).forEach(child => {
71
+ if (child && child.props.id && child.type === childType) {
72
+ if (restrictedKeys.includes(child.props.id)) {
73
+ throw new Error('Restricted id name found in Tabs, Please avoid these names => ' + restrictedKeys.toString());
74
+ } else {
75
+ tabKeys.push(child.props.id);
76
+ }
77
+ }
78
+ });
79
+ this.setState({
80
+ totalDimension,
81
+ tabDimensions,
82
+ renderVirtualTabs: false,
83
+ tabKeys
84
+ });
85
+ this.highlight && this.setState({
86
+ highlightInitialDimension: this.getHighlightDim()
87
+ }, () => {
88
+ this.moveHighlight();
89
+ });
90
+ }
91
+
92
+ componentWillUnmount() {
93
+ if (this.tabsObserver) {
94
+ this.tabsObserver.disconnect();
95
+ this.tabsObserver = null;
96
+ }
97
+
98
+ if (this.tabObserver) {
99
+ Object.keys(this.tabObserver).forEach(observer => {
100
+ this.tabObserver[observer] && this.tabObserver[observer].disconnect();
101
+ });
102
+ this.tabObserver = null;
103
+ }
104
+ }
105
+
106
+ setMaxDim() {
107
+ let totalDimension = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
108
+ let {
109
+ selectedTab
110
+ } = this.props; // let actual = Object.keys(tabDimensions).reduce(
111
+ // (sum, tab) => sum + (tabDimensions[tab] || 0),
112
+ // 0
113
+ // );
114
+
115
+ if (totalDimension && this[selectedTab]) {
116
+ let {
117
+ align
118
+ } = this.props;
119
+ let newDim = `${remConvert(totalDimension)}rem`;
120
+ align === 'vertical' ? this[selectedTab].style.maxWidth = newDim : this[selectedTab].style.maxHeight = newDim;
121
+ }
122
+ }
123
+
124
+ getHighlightDim() {
125
+ let {
126
+ align
127
+ } = this.props;
128
+ return align === 'vertical' ? this.highlight.offsetLeft : this.highlight.offsetTop;
129
+ }
130
+
131
+ componentDidUpdate(prevProps) {
132
+ let {
133
+ children,
134
+ selectedTab,
135
+ childType
136
+ } = this.props;
137
+ let {
138
+ tabDimensions,
139
+ totalDimension,
140
+ tabKeys
141
+ } = this.state;
142
+
143
+ if (prevProps.children && children) {
144
+ /**
145
+ * To recalculate the dimensions of tabs we are checking the children length.
146
+ * and also checking the tab id and their order.
147
+ */
148
+ let newTabKeys = [];
149
+ React.Children.toArray(children).forEach(child => {
150
+ if (child && child.props.id && child.type === childType) {
151
+ newTabKeys.push(child.props.id);
152
+ }
153
+ });
154
+ let isSameTabKeys = newTabKeys.every((current, index) => tabKeys[index] === current);
155
+
156
+ if (newTabKeys.length !== tabKeys.length || !isSameTabKeys) {
157
+ this.setState({
158
+ renderVirtualTabs: true,
159
+ tabKeys: newTabKeys
160
+ }, () => {
161
+ totalDimension = this.getTotalDimension();
162
+ tabDimensions = this.getTabDimensions();
163
+ this.setState({
164
+ tabDimensions,
165
+ totalDimension,
166
+ renderVirtualTabs: false
167
+ });
168
+ });
169
+ }
170
+
171
+ if (prevProps.selectedTab !== selectedTab || newTabKeys.length === 1) {
172
+ this.moveHighlight();
173
+ }
174
+ }
175
+ }
176
+
177
+ moveHighlight() {
178
+ let {
179
+ isAnimate,
180
+ needTabBorder,
181
+ selectedTab,
182
+ align
183
+ } = this.props;
184
+ let {
185
+ highlightInitialDimension
186
+ } = this.state;
187
+ let node = this.highlight;
188
+
189
+ if (isAnimate && needTabBorder && node) {
190
+ let tabActive = this[selectedTab];
191
+
192
+ if (tabActive) {
193
+ let position, dimension;
194
+
195
+ if (align === 'vertical') {
196
+ position = tabActive.offsetLeft;
197
+ dimension = tabActive.offsetWidth;
198
+ node.style.transform = `translateX(${remConvert(position - highlightInitialDimension)}rem)`;
199
+ node.style.width = `${remConvert(dimension)}rem`;
200
+ } else if (align === 'horizontal') {
201
+ position = tabActive.offsetTop;
202
+ dimension = tabActive.offsetHeight;
203
+ node.style.transform = `translateY(${remConvert(position - highlightInitialDimension)}rem)`;
204
+ node.style.height = `${remConvert(dimension)}rem`;
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ getHighlightRef(ele) {
211
+ this.highlight = ele;
212
+ }
213
+
214
+ getTabsRef(ele) {
215
+ this.tabsEle = ele;
216
+
217
+ if (ele) {
218
+ this.tabsObserver.observe(ele);
219
+ } else {
220
+ this.tabsObserver && this.tabsObserver.disconnect();
221
+ }
222
+ }
223
+
224
+ onSizeChange() {
225
+ let totalDimension = this.getTotalDimension();
226
+ this.setState({
227
+ totalDimension
228
+ });
229
+ this.highlight && this.setState({
230
+ highlightInitialDimension: this.getHighlightDim()
231
+ }, () => {
232
+ this.moveHighlight();
233
+ });
234
+ }
235
+
236
+ onResize(timer) {
237
+ let {
238
+ isResponsive
239
+ } = this.props;
240
+
241
+ if (this.tabsEle && isResponsive) {
242
+ if (!timer) {
243
+ this.onSizeChange();
244
+ } else {
245
+ setTimeout(() => {
246
+ this.onSizeChange();
247
+ }, timer);
248
+ }
249
+ }
250
+ }
251
+
252
+ getTotalDimension() {
253
+ let {
254
+ align
255
+ } = this.props;
256
+ let totalDimension = this.tabsEle && getTotalDimension(this.tabsEle, align);
257
+ return totalDimension;
258
+ }
259
+
260
+ getTabDimensions() {
261
+ let {
262
+ children,
263
+ align,
264
+ childType
265
+ } = this.props;
266
+ let tabDimensions = {};
267
+ React.Children.forEach(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === childType && this[child.props.id] && Object.assign(tabDimensions, {
268
+ [child.props.id]: this[child.props.id] && getTotalDimension(this[child.props.id], align)
269
+ }));
270
+ return tabDimensions;
271
+ }
272
+
273
+ responsiveTab(totalDimension, tabDimensions) {
274
+ let {
275
+ children,
276
+ maxTabsCount,
277
+ minTabsCount,
278
+ isResponsive
279
+ } = this.props;
280
+ let mainTabs = [],
281
+ moreTabs = [],
282
+ otherTabs = [];
283
+
284
+ if (totalDimension && isResponsive) {
285
+ let {
286
+ childType,
287
+ selectedTab
288
+ } = this.props;
289
+ let selectedTabDimension = tabDimensions[selectedTab] || 0;
290
+ let remainingDimension = totalDimension - selectedTabDimension;
291
+ let maxTabsTobeVisible = maxTabsCount - 1;
292
+ let minTabsToBeVisible = 1;
293
+ React.Children.forEach(children, child => {
294
+ if (child && child.type === childType && child.props.id) {
295
+ const elemDimension = tabDimensions[child.props.id];
296
+ let isMaxCountExceeded = maxTabsTobeVisible <= 0 ? true : false;
297
+ let isMinCountNotExceeded = minTabsToBeVisible < minTabsCount ? true : false;
298
+
299
+ if (child.props.id === selectedTab) {
300
+ mainTabs.push(child);
301
+ } else if (isMinCountNotExceeded) {
302
+ mainTabs.push(child);
303
+ remainingDimension -= tabDimensions[child.props.id];
304
+ minTabsToBeVisible++;
305
+ maxTabsTobeVisible--;
306
+ } else if (remainingDimension - elemDimension >= 20 && !moreTabs.length && !isMaxCountExceeded) {
307
+ mainTabs.push(child);
308
+ remainingDimension -= tabDimensions[child.props.id];
309
+ maxTabsTobeVisible--;
310
+ } else {
311
+ moreTabs.push(child);
312
+ }
313
+ } else if ( /*#__PURE__*/React.isValidElement(child)) {
314
+ otherTabs.push(child);
315
+ }
316
+ });
317
+
318
+ if (selectedTabDimension > totalDimension) {
319
+ /* let { align } = this.props;
320
+ let newDim = `${remConvert(totalDimension)}rem`;
321
+ let newTabs;
322
+ if (align === 'vertical') {
323
+ newTabs = mainTabs.map(tab => React.cloneElement(tab, { style: { maxWidth: newDim } }));
324
+ } else {
325
+ newTabs = mainTabs.map(tab => React.cloneElement(tab, { style: { maxHeight: newDim } }));
326
+ }
327
+ mainTabs = newTabs; */
328
+ this.setMaxDim(totalDimension);
329
+ }
330
+ } else if (!isResponsive) {
331
+ let {
332
+ childType
333
+ } = this.props;
334
+ React.Children.forEach(children, child => {
335
+ if (child && child.type === childType && child.props.id) {
336
+ mainTabs.push(child);
337
+ } else {
338
+ otherTabs.push(child);
339
+ }
340
+ });
341
+ } else {
342
+ moreTabs = children;
343
+ }
344
+
345
+ return {
346
+ mainTabs,
347
+ moreTabs,
348
+ otherTabs
349
+ };
350
+ }
351
+
352
+ getTabRef(refName, ele, isVirtual) {
353
+ this[refName] = ele;
354
+ let key = isVirtual ? `virtual_${refName}` : refName;
355
+
356
+ if (ele) {
357
+ this.tabObserver[key] = new ResizeObserver(this.onTabResize);
358
+ this.tabObserver[key].observe(ele);
359
+ } else {
360
+ if (this.tabObserver && this.tabObserver[key]) {
361
+ this.tabObserver[key].disconnect();
362
+ }
363
+ }
364
+ }
365
+
366
+ moreTabSelect(tab, value, index, e) {
367
+ let {
368
+ onSelect
369
+ } = this.props;
370
+
371
+ if (e && e.target && e.target.parentElement.tagName === 'A' && (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)) {
372
+ cancelBubblingEffect(e);
373
+ return;
374
+ }
375
+
376
+ e.preventDefault();
377
+ onSelect(tab);
378
+ }
379
+
380
+ onScroll(e) {
381
+ e.persist();
382
+ let {
383
+ onScroll
384
+ } = this.props;
385
+ onScroll && throttle(onScroll, 100, e);
386
+ }
387
+
388
+ togglePopup(e) {
389
+ let {
390
+ boxPosition,
391
+ togglePopup,
392
+ align,
393
+ removeClose
394
+ } = this.props;
395
+ removeClose && removeClose(e);
396
+ let popupPosition = align === 'vertical' ? 'bottomLeft' : 'rightTop';
397
+ boxPosition = boxPosition ? boxPosition : popupPosition;
398
+ togglePopup(e, boxPosition);
399
+ }
400
+
401
+ responsiveFunc(_ref) {
402
+ let {
403
+ mediaQueryOR
404
+ } = _ref;
405
+ return {
406
+ tabletMode: mediaQueryOR([{
407
+ maxWidth: 700
408
+ }])
409
+ };
410
+ }
411
+
412
+ renderTabs(mainTabs, moreTabs, isVirtual) {
413
+ let {
414
+ selectedTab,
415
+ moreButtonClass,
416
+ moreButtonActiveClass,
417
+ moreBoxClass,
418
+ menuItemClass,
419
+ itemClass,
420
+ itemActiveClass,
421
+ iconName,
422
+ isPopupReady,
423
+ isPopupOpen,
424
+ getContainerRef,
425
+ showTitleInMoreOptions,
426
+ onSelect,
427
+ moreContainerClass,
428
+ align,
429
+ type,
430
+ isAnimate,
431
+ needTabBorder,
432
+ needAppearance,
433
+ iconSize,
434
+ getTargetRef,
435
+ position,
436
+ customProps,
437
+ getCustomDropBoxHeaderPlaceHolder,
438
+ dataSelectorId
439
+ } = this.props;
440
+ let {
441
+ DropBoxProps = {},
442
+ ListItemProps = {},
443
+ MoreButtonProps = {}
444
+ } = customProps;
445
+ let popupClass = align === 'vertical' ? tabsStyle[position] ? tabsStyle[position] : '' : '';
446
+ return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(mainTabs, child => {
447
+ if (!child) {
448
+ return null;
449
+ }
450
+
451
+ let MainTab = child.type;
452
+ let classProps = {};
453
+
454
+ if (itemActiveClass) {
455
+ classProps.activeClass = itemActiveClass;
456
+ }
457
+
458
+ if (itemClass) {
459
+ classProps.className = itemClass;
460
+ }
461
+
462
+ return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(MainTab, _extends({}, child.props, {
463
+ key: child.props.id,
464
+ getTabRef: this.getTabRef,
465
+ onSelect: onSelect,
466
+ recalculateDimension: this.recalculateDimension,
467
+ isActive: child.props.id === selectedTab,
468
+ type: type,
469
+ isAnimate: isAnimate,
470
+ needBorder: needTabBorder,
471
+ needAppearance: needAppearance,
472
+ align: align,
473
+ isVirtual: isVirtual
474
+ }, classProps));
475
+ }), React.Children.count(moreTabs) ? /*#__PURE__*/React.createElement(Box, {
476
+ className: `${tabsStyle.menu} `,
477
+ dataSelectorId: `${dataSelectorId}_moreIcon`
478
+ }, /*#__PURE__*/React.createElement(Container, _extends({
479
+ className: `${btnstyle.buttonReset} ${moreButtonClass} ${isPopupOpen ? moreButtonActiveClass : ''}`,
480
+ align: "both",
481
+ onClick: this.togglePopup,
482
+ dataId: "moreTabs",
483
+ eleRef: getTargetRef
484
+ }, MoreButtonProps, {
485
+ "aria-label": "MoreTabs",
486
+ role: "link",
487
+ tagName: "button"
488
+ }), /*#__PURE__*/React.createElement(Icon, {
489
+ name: iconName,
490
+ size: iconSize
491
+ })), isPopupOpen && /*#__PURE__*/React.createElement(ResponsiveReceiver, {
492
+ query: this.responsiveFunc,
493
+ responsiveId: "Helmet"
494
+ }, _ref2 => {
495
+ let {
496
+ tabletMode
497
+ } = _ref2;
498
+ return /*#__PURE__*/React.createElement(ResponsiveDropBox, _extends({
499
+ isActive: isPopupReady,
500
+ isAnimate: true,
501
+ size: "medium",
502
+ customClass: {
503
+ customDropBoxWrap: `${moreContainerClass} ${popupClass}`
504
+ },
505
+ boxPosition: position,
506
+ getRef: getContainerRef,
507
+ isBoxPaddingNeed: true,
508
+ isArrow: false
509
+ }, DropBoxProps, {
510
+ isResponsivePadding: true,
511
+ needFocusScope: true,
512
+ onClose: this.togglePopup
513
+ }), getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(this.props), /*#__PURE__*/React.createElement(Box, {
514
+ flexible: true,
515
+ shrink: true,
516
+ scroll: "vertical",
517
+ className: `${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
518
+ onScroll: this.onScroll
519
+ }, React.Children.map(moreTabs, child => {
520
+ if (!child) {
521
+ return null;
522
+ }
523
+
524
+ let {
525
+ text,
526
+ id,
527
+ title,
528
+ isLink,
529
+ href,
530
+ children,
531
+ dataId
532
+ } = child.props;
533
+ const value = text ? text : showTitleInMoreOptions ? title : null;
534
+ return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(ListItem, _extends({
535
+ key: id,
536
+ value: value,
537
+ onClick: this.moreTabSelect,
538
+ id: id,
539
+ title: title || text,
540
+ isLink: isLink,
541
+ href: href,
542
+ autoHover: true,
543
+ customClass: {
544
+ customListItem: menuItemClass
545
+ },
546
+ target: "self",
547
+ dataId: `${dataId}_Tab`
548
+ }, ListItemProps), !showTitleInMoreOptions ? children : null);
549
+ })));
550
+ })) : null);
551
+ }
552
+
553
+ render() {
554
+ let {
555
+ style,
556
+ className,
557
+ dataId,
558
+ highlightClass,
559
+ type,
560
+ isAnimate,
561
+ needTabBorder,
562
+ needBorder,
563
+ needPadding,
564
+ align,
565
+ needAppearance,
566
+ children,
567
+ containerClass,
568
+ dataSelectorId
569
+ } = this.props;
570
+ let {
571
+ totalDimension,
572
+ tabDimensions,
573
+ renderVirtualTabs
574
+ } = this.state;
575
+ let {
576
+ mainTabs,
577
+ moreTabs,
578
+ otherTabs
579
+ } = this.responsiveTab(totalDimension, tabDimensions);
580
+ let appearanceClass = cs([tabsStyle[type], needBorder && tabsStyle[`${type}_border`], needPadding && tabsStyle[`${type}_padding`]]);
581
+ let tabsClass = cs([tabsStyle.tab, className, needAppearance && appearanceClass]);
582
+ let hlClass = cs([tabsStyle.highlight, highlightClass, isAnimate && tabsStyle.lineAnimate]);
583
+ return /*#__PURE__*/React.createElement(Box, {
584
+ className: containerClass,
585
+ dataSelectorId: dataSelectorId
586
+ }, /*#__PURE__*/React.createElement(Container, {
587
+ alignBox: align === 'vertical' ? 'row' : 'column',
588
+ className: tabsClass,
589
+ style: style
590
+ }, /*#__PURE__*/React.createElement(Box, {
591
+ eleRef: this.getTabsRef,
592
+ flexible: true
593
+ }, renderVirtualTabs && /*#__PURE__*/React.createElement(Container, {
594
+ alignBox: align === 'vertical' ? 'row' : 'column',
595
+ className: tabsStyle.hidden
596
+ }, this.renderTabs(children, [], true)), /*#__PURE__*/React.createElement(Container, {
597
+ alignBox: align === 'vertical' ? 'row' : 'column'
598
+ }, this.renderTabs(mainTabs, moreTabs, false))), otherTabs.length ? /*#__PURE__*/React.createElement(Box, null, otherTabs) : null, isAnimate && needTabBorder && needAppearance && /*#__PURE__*/React.createElement("div", {
599
+ className: hlClass,
600
+ ref: this.getHighlightRef,
601
+ "data-id": dataId,
602
+ "data-test-id": dataId
603
+ })));
604
+ }
605
+
606
+ }
607
+
608
+ Tabs.propTypes = Tabs_propTypes;
609
+ Tabs.defaultProps = { ...Tabs_defaultProps,
610
+ childType: Tab
611
+ };
612
+ export default Popup(Tabs);
@@ -0,0 +1,5 @@
1
+ export { default as TabWrapper } from './TabWrapper';
2
+ export { default as TabContentWrapper } from './TabContentWrapper';
3
+ export { default as TabContent } from './TabContent';
4
+ export { default as Tabs } from './Tabs';
5
+ export { default as Tab } from './Tab';