@zohodesk/components 1.2.20 → 1.2.21
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.
- package/.cli/PropLessFiles.html +1 -1
- package/.cli/propValidation_report.html +1 -1
- package/README.md +6 -0
- package/es/DateTime/DateTime.module.css +2 -2
- package/es/DateTime/YearView.module.css +1 -1
- package/es/Label/Label.module.css +6 -1
- package/es/ListItem/ListItem.module.css +1 -1
- package/es/Ribbon/Ribbon.module.css +49 -3
- package/es/Select/Select.js +10 -2
- package/es/Select/Select.module.css +27 -1
- package/es/Tab/Tab.module.css +3 -3
- package/es/TextBox/TextBox.js +8 -1
- package/es/TextBox/TextBox.module.css +45 -6
- package/es/TextBox/props/defaultProps.js +1 -0
- package/es/TextBox/props/propTypes.js +1 -0
- package/es/TextBoxIcon/TextBoxIcon.js +2 -0
- package/es/TextBoxIcon/props/defaultProps.js +1 -0
- package/es/TextBoxIcon/props/propTypes.js +1 -0
- package/es/Textarea/Textarea.module.css +4 -3
- package/es/Tooltip/Tooltip.js +4 -2
- package/es/Tooltip/Tooltip.module.css +1 -1
- package/es/v1/Card/Card.js +1 -1
- package/es/v1/CheckBox/CheckBox.js +1 -1
- package/es/v1/Select/Select.js +10 -2
- package/es/v1/Tab/Tab.js +1 -2
- package/es/v1/Tab/TabContent.js +1 -1
- package/es/v1/Tab/Tabs.js +182 -271
- package/es/v1/Tab/v1Tab.module.css +100 -0
- package/es/v1/Tab/v1TabContent.module.css +4 -0
- package/es/v1/Tab/v1Tabs.module.css +137 -0
- package/es/v1/TextBox/TextBox.js +8 -2
- package/es/v1/TextBox/props/defaultProps.js +1 -0
- package/es/v1/TextBox/props/propTypes.js +1 -0
- package/es/v1/TextBoxIcon/TextBoxIcon.js +3 -1
- package/es/v1/TextBoxIcon/props/defaultProps.js +1 -0
- package/es/v1/TextBoxIcon/props/propTypes.js +1 -0
- package/es/v1/Tooltip/Tooltip.js +4 -2
- package/lib/DateTime/DateTime.module.css +2 -2
- package/lib/DateTime/YearView.module.css +1 -1
- package/lib/Label/Label.module.css +6 -1
- package/lib/ListItem/ListItem.module.css +1 -1
- package/lib/Ribbon/Ribbon.module.css +49 -3
- package/lib/Select/Select.js +14 -2
- package/lib/Select/Select.module.css +27 -1
- package/lib/Tab/Tab.module.css +3 -3
- package/lib/TextBox/TextBox.js +9 -1
- package/lib/TextBox/TextBox.module.css +45 -6
- package/lib/TextBox/props/defaultProps.js +1 -0
- package/lib/TextBox/props/propTypes.js +1 -1
- package/lib/TextBoxIcon/TextBoxIcon.js +2 -0
- package/lib/TextBoxIcon/props/defaultProps.js +1 -0
- package/lib/TextBoxIcon/props/propTypes.js +1 -0
- package/lib/Textarea/Textarea.module.css +4 -3
- package/lib/Tooltip/Tooltip.js +4 -2
- package/lib/Tooltip/Tooltip.module.css +1 -1
- package/lib/v1/Card/Card.js +1 -1
- package/lib/v1/CheckBox/CheckBox.js +1 -1
- package/lib/v1/Select/Select.js +14 -2
- package/lib/v1/Tab/Tab.js +6 -6
- package/lib/v1/Tab/TabContent.js +2 -2
- package/lib/v1/Tab/Tabs.js +478 -567
- package/lib/v1/Tab/v1Tab.module.css +100 -0
- package/lib/v1/Tab/v1TabContent.module.css +4 -0
- package/lib/v1/Tab/v1Tabs.module.css +137 -0
- package/lib/v1/TextBox/TextBox.js +10 -2
- package/lib/v1/TextBox/props/defaultProps.js +1 -0
- package/lib/v1/TextBox/props/propTypes.js +1 -1
- package/lib/v1/TextBoxIcon/TextBoxIcon.js +3 -1
- package/lib/v1/TextBoxIcon/props/defaultProps.js +1 -0
- package/lib/v1/TextBoxIcon/props/propTypes.js +1 -0
- package/lib/v1/Tooltip/Tooltip.js +4 -2
- package/package.json +9 -7
- package/result.json +1 -1
package/es/v1/Tab/Tabs.js
CHANGED
|
@@ -1,51 +1,60 @@
|
|
|
1
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
2
|
|
|
3
|
-
|
|
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';
|
|
3
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
4
|
+
import useEffectCallOnlyAfterState from '@zohodesk/hooks/es/utils/useEffectCallOnlyAfterState';
|
|
13
5
|
import Tab from './Tab';
|
|
14
6
|
import { Tabs_defaultProps } from './props/defaultProps';
|
|
15
7
|
import { Tabs_propTypes } from './props/propTypes';
|
|
16
|
-
import { remConvert, getTotalDimension, cs,
|
|
8
|
+
import { remConvert, getTotalDimension, cs, throttle, cancelBubblingEffect } from '../../utils/Common';
|
|
17
9
|
import { Box, Container } from '../Layout';
|
|
18
10
|
import ResizeObserver from '../Responsive/ResizeObserver';
|
|
19
11
|
import ListItem from '../ListItem/ListItem';
|
|
20
12
|
import { Icon } from '@zohodesk/icons';
|
|
21
|
-
import tabsStyle from '
|
|
13
|
+
import tabsStyle from './v1Tabs.module.css';
|
|
22
14
|
import Popup from '../Popup/Popup';
|
|
23
15
|
import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
24
16
|
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
25
17
|
import btnstyle from '../../semantic/Button/semanticButton.module.css';
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
const Tabs = props => {
|
|
20
|
+
const [totalDimension, setTotalDimension] = useState(null);
|
|
21
|
+
const [tabDimensions, setTabDimensions] = useState({});
|
|
22
|
+
const highlightInitialDimension = useRef(null);
|
|
23
|
+
const [renderVirtualTabs, setRenderVirtualTabs] = useState(true);
|
|
24
|
+
const [tabKeys, setTabKeys] = useState([]);
|
|
25
|
+
const tabsObserver = useRef(new ResizeObserver(onResize));
|
|
26
|
+
const tabObserver = useRef({});
|
|
27
|
+
const highlight = useRef(null);
|
|
28
|
+
const tabsEle = useRef(null);
|
|
29
|
+
const tabElement = useRef({});
|
|
30
|
+
let {
|
|
31
|
+
style,
|
|
32
|
+
className,
|
|
33
|
+
dataId,
|
|
34
|
+
highlightClass,
|
|
35
|
+
type,
|
|
36
|
+
isAnimate,
|
|
37
|
+
needTabBorder,
|
|
38
|
+
needBorder,
|
|
39
|
+
needPadding,
|
|
40
|
+
align,
|
|
41
|
+
boxPosition,
|
|
42
|
+
removeClose,
|
|
43
|
+
togglePopup,
|
|
44
|
+
needAppearance,
|
|
45
|
+
children,
|
|
46
|
+
onSelect,
|
|
47
|
+
onScroll,
|
|
48
|
+
isResponsive,
|
|
49
|
+
maxTabsCount,
|
|
50
|
+
minTabsCount,
|
|
51
|
+
childType,
|
|
52
|
+
containerClass,
|
|
53
|
+
dataSelectorId,
|
|
54
|
+
selectedTab
|
|
55
|
+
} = props;
|
|
56
|
+
|
|
57
|
+
function onTabResize(size, target) {
|
|
49
58
|
let newDim = Object.assign({}, tabDimensions);
|
|
50
59
|
let elemDim = getTotalDimension(target, align);
|
|
51
60
|
|
|
@@ -53,18 +62,12 @@ class Tabs extends React.Component {
|
|
|
53
62
|
newDim[target.dataset.key] = elemDim;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
tabDimensions: newDim
|
|
58
|
-
});
|
|
65
|
+
setTabDimensions(newDim);
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
childType
|
|
65
|
-
} = this.props;
|
|
66
|
-
let totalDimension = this.getTotalDimension();
|
|
67
|
-
let tabDimensions = this.getTabDimensions();
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
let totalDimension = getTotalDimensionLocal();
|
|
70
|
+
let tabDimensions = getTabDimensions();
|
|
68
71
|
let tabKeys = [];
|
|
69
72
|
let restrictedKeys = ['state', 'props', 'refs', 'context'];
|
|
70
73
|
React.Children.toArray(children).forEach(child => {
|
|
@@ -76,71 +79,50 @@ class Tabs extends React.Component {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, () => {
|
|
88
|
-
this.moveHighlight();
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
componentWillUnmount() {
|
|
93
|
-
if (this.tabsObserver) {
|
|
94
|
-
this.tabsObserver.disconnect();
|
|
95
|
-
this.tabsObserver = null;
|
|
82
|
+
setTotalDimension(totalDimension);
|
|
83
|
+
setTabDimensions(tabDimensions);
|
|
84
|
+
setRenderVirtualTabs(false);
|
|
85
|
+
setTabKeys(tabKeys);
|
|
86
|
+
|
|
87
|
+
if (highlight.current) {
|
|
88
|
+
highlightInitialDimension.current = getHighlightDim();
|
|
89
|
+
moveHighlight();
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
return () => {
|
|
93
|
+
if (tabsObserver.current) {
|
|
94
|
+
tabsObserver.current.disconnect();
|
|
95
|
+
tabsObserver.current = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (tabObserver.current) {
|
|
99
|
+
Object.keys(tabObserver.current).forEach(observer => {
|
|
100
|
+
tabObserver.current[observer] && tabObserver.current[observer].disconnect();
|
|
101
|
+
});
|
|
102
|
+
tabObserver.current = null;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}, []);
|
|
105
106
|
|
|
106
|
-
setMaxDim() {
|
|
107
|
+
function setMaxDim() {
|
|
107
108
|
let totalDimension = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} = this.props; // let actual = Object.keys(tabDimensions).reduce(
|
|
109
|
+
|
|
110
|
+
// let actual = Object.keys(tabDimensions).reduce(
|
|
111
111
|
// (sum, tab) => sum + (tabDimensions[tab] || 0),
|
|
112
112
|
// 0
|
|
113
113
|
// );
|
|
114
|
-
|
|
115
|
-
if (totalDimension && this[selectedTab]) {
|
|
116
|
-
let {
|
|
117
|
-
align
|
|
118
|
-
} = this.props;
|
|
114
|
+
if (totalDimension && tabElement.current[selectedTab]) {
|
|
119
115
|
let newDim = `${remConvert(totalDimension)}rem`;
|
|
120
|
-
align === 'vertical' ?
|
|
116
|
+
align === 'vertical' ? tabElement.current[selectedTab].style.maxWidth = newDim : tabElement.current[selectedTab].style.maxHeight = newDim;
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
getHighlightDim() {
|
|
125
|
-
|
|
126
|
-
align
|
|
127
|
-
} = this.props;
|
|
128
|
-
return align === 'vertical' ? this.highlight.offsetLeft : this.highlight.offsetTop;
|
|
120
|
+
function getHighlightDim() {
|
|
121
|
+
return align === 'vertical' ? highlight.current.offsetLeft : highlight.current.offsetTop;
|
|
129
122
|
}
|
|
130
123
|
|
|
131
|
-
|
|
132
|
-
|
|
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) {
|
|
124
|
+
useEffectCallOnlyAfterState(() => {
|
|
125
|
+
if (children) {
|
|
144
126
|
/**
|
|
145
127
|
* To recalculate the dimensions of tabs we are checking the children length.
|
|
146
128
|
* and also checking the tab id and their order.
|
|
@@ -154,40 +136,33 @@ class Tabs extends React.Component {
|
|
|
154
136
|
let isSameTabKeys = newTabKeys.every((current, index) => tabKeys[index] === current);
|
|
155
137
|
|
|
156
138
|
if (newTabKeys.length !== tabKeys.length || !isSameTabKeys) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.setState({
|
|
164
|
-
tabDimensions,
|
|
165
|
-
totalDimension,
|
|
166
|
-
renderVirtualTabs: false
|
|
167
|
-
});
|
|
139
|
+
setRenderVirtualTabs(true);
|
|
140
|
+
setTabKeys(newTabKeys);
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
setTabDimensions(getTabDimensions());
|
|
143
|
+
setTotalDimension(getTotalDimensionLocal());
|
|
144
|
+
setRenderVirtualTabs(false);
|
|
168
145
|
});
|
|
169
146
|
}
|
|
170
147
|
|
|
171
|
-
if (
|
|
172
|
-
|
|
148
|
+
if (newTabKeys.length === 1) {
|
|
149
|
+
moveHighlight();
|
|
173
150
|
}
|
|
174
151
|
}
|
|
175
|
-
}
|
|
152
|
+
});
|
|
153
|
+
useEffectCallOnlyAfterState(() => {
|
|
154
|
+
tabsObserver.current && tabsObserver.current.replaceResizeHandler(onResize);
|
|
176
155
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let {
|
|
185
|
-
highlightInitialDimension
|
|
186
|
-
} = this.state;
|
|
187
|
-
let node = this.highlight;
|
|
156
|
+
if (children) {
|
|
157
|
+
moveHighlight();
|
|
158
|
+
}
|
|
159
|
+
}, [selectedTab]);
|
|
160
|
+
|
|
161
|
+
function moveHighlight() {
|
|
162
|
+
let node = highlight.current;
|
|
188
163
|
|
|
189
164
|
if (isAnimate && needTabBorder && node) {
|
|
190
|
-
let tabActive =
|
|
165
|
+
let tabActive = tabElement.current[selectedTab];
|
|
191
166
|
|
|
192
167
|
if (tabActive) {
|
|
193
168
|
let position, dimension;
|
|
@@ -195,97 +170,72 @@ class Tabs extends React.Component {
|
|
|
195
170
|
if (align === 'vertical') {
|
|
196
171
|
position = tabActive.offsetLeft;
|
|
197
172
|
dimension = tabActive.offsetWidth;
|
|
198
|
-
node.style.transform = `translateX(${remConvert(position - highlightInitialDimension)}rem)`;
|
|
173
|
+
node.style.transform = `translateX(${remConvert(position - highlightInitialDimension.current)}rem)`;
|
|
199
174
|
node.style.width = `${remConvert(dimension)}rem`;
|
|
200
175
|
} else if (align === 'horizontal') {
|
|
201
176
|
position = tabActive.offsetTop;
|
|
202
177
|
dimension = tabActive.offsetHeight;
|
|
203
|
-
node.style.transform = `translateY(${remConvert(position - highlightInitialDimension)}rem)`;
|
|
178
|
+
node.style.transform = `translateY(${remConvert(position - highlightInitialDimension.current)}rem)`;
|
|
204
179
|
node.style.height = `${remConvert(dimension)}rem`;
|
|
205
180
|
}
|
|
206
181
|
}
|
|
207
182
|
}
|
|
208
183
|
}
|
|
209
184
|
|
|
210
|
-
getHighlightRef(ele
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.tabsEle = ele;
|
|
185
|
+
const getHighlightRef = useCallback(ele => {
|
|
186
|
+
highlight.current = ele;
|
|
187
|
+
}, []);
|
|
188
|
+
const getTabsRef = useCallback(ele => {
|
|
189
|
+
tabsEle.current = ele;
|
|
216
190
|
|
|
217
191
|
if (ele) {
|
|
218
|
-
|
|
192
|
+
tabsObserver.current.observe(ele);
|
|
219
193
|
} else {
|
|
220
|
-
|
|
194
|
+
tabsObserver.current && tabsObserver.current.disconnect();
|
|
221
195
|
}
|
|
222
|
-
}
|
|
196
|
+
}, []);
|
|
223
197
|
|
|
224
|
-
onSizeChange() {
|
|
225
|
-
let totalDimension =
|
|
226
|
-
|
|
227
|
-
totalDimension
|
|
228
|
-
});
|
|
229
|
-
this.highlight && this.setState({
|
|
230
|
-
highlightInitialDimension: this.getHighlightDim()
|
|
231
|
-
}, () => {
|
|
232
|
-
this.moveHighlight();
|
|
233
|
-
});
|
|
234
|
-
}
|
|
198
|
+
function onSizeChange() {
|
|
199
|
+
let totalDimension = getTotalDimensionLocal();
|
|
200
|
+
setTotalDimension(totalDimension);
|
|
235
201
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
202
|
+
if (highlight.current) {
|
|
203
|
+
highlightInitialDimension.current = getHighlightDim();
|
|
204
|
+
moveHighlight();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
240
207
|
|
|
241
|
-
|
|
208
|
+
function onResize(timer) {
|
|
209
|
+
if (tabsEle.current && isResponsive) {
|
|
242
210
|
if (!timer) {
|
|
243
|
-
|
|
211
|
+
onSizeChange();
|
|
244
212
|
} else {
|
|
245
213
|
setTimeout(() => {
|
|
246
|
-
|
|
214
|
+
onSizeChange();
|
|
247
215
|
}, timer);
|
|
248
216
|
}
|
|
249
217
|
}
|
|
250
218
|
}
|
|
251
219
|
|
|
252
|
-
|
|
253
|
-
let
|
|
254
|
-
align
|
|
255
|
-
} = this.props;
|
|
256
|
-
let totalDimension = this.tabsEle && getTotalDimension(this.tabsEle, align);
|
|
220
|
+
function getTotalDimensionLocal() {
|
|
221
|
+
let totalDimension = tabsEle.current && getTotalDimension(tabsEle.current, align);
|
|
257
222
|
return totalDimension;
|
|
258
223
|
}
|
|
259
224
|
|
|
260
|
-
getTabDimensions() {
|
|
261
|
-
let {
|
|
262
|
-
children,
|
|
263
|
-
align,
|
|
264
|
-
childType
|
|
265
|
-
} = this.props;
|
|
225
|
+
function getTabDimensions() {
|
|
266
226
|
let tabDimensions = {};
|
|
267
|
-
React.Children.forEach(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === childType &&
|
|
268
|
-
[child.props.id]:
|
|
227
|
+
React.Children.forEach(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === childType && tabElement.current[child.props.id] && Object.assign(tabDimensions, {
|
|
228
|
+
[child.props.id]: tabElement.current[child.props.id] && getTotalDimension(tabElement.current[child.props.id], align)
|
|
269
229
|
}));
|
|
270
230
|
return tabDimensions;
|
|
271
231
|
}
|
|
272
232
|
|
|
273
|
-
responsiveTab(totalDimension, tabDimensions) {
|
|
274
|
-
let {
|
|
275
|
-
children,
|
|
276
|
-
maxTabsCount,
|
|
277
|
-
minTabsCount,
|
|
278
|
-
isResponsive
|
|
279
|
-
} = this.props;
|
|
233
|
+
function responsiveTab(totalDimension, tabDimensions) {
|
|
280
234
|
let mainTabs = [],
|
|
281
235
|
moreTabs = [],
|
|
282
236
|
otherTabs = [];
|
|
283
237
|
|
|
284
238
|
if (totalDimension && isResponsive) {
|
|
285
|
-
let {
|
|
286
|
-
childType,
|
|
287
|
-
selectedTab
|
|
288
|
-
} = this.props;
|
|
289
239
|
let selectedTabDimension = tabDimensions[selectedTab] || 0;
|
|
290
240
|
let remainingDimension = totalDimension - selectedTabDimension;
|
|
291
241
|
let maxTabsTobeVisible = maxTabsCount - 1;
|
|
@@ -325,12 +275,9 @@ class Tabs extends React.Component {
|
|
|
325
275
|
newTabs = mainTabs.map(tab => React.cloneElement(tab, { style: { maxHeight: newDim } }));
|
|
326
276
|
}
|
|
327
277
|
mainTabs = newTabs; */
|
|
328
|
-
|
|
278
|
+
setMaxDim(totalDimension);
|
|
329
279
|
}
|
|
330
280
|
} else if (!isResponsive) {
|
|
331
|
-
let {
|
|
332
|
-
childType
|
|
333
|
-
} = this.props;
|
|
334
281
|
React.Children.forEach(children, child => {
|
|
335
282
|
if (child && child.type === childType && child.props.id) {
|
|
336
283
|
mainTabs.push(child);
|
|
@@ -349,25 +296,25 @@ class Tabs extends React.Component {
|
|
|
349
296
|
};
|
|
350
297
|
}
|
|
351
298
|
|
|
352
|
-
getTabRef(refName, ele, isVirtual) {
|
|
353
|
-
|
|
299
|
+
function getTabRef(refName, ele, isVirtual) {
|
|
300
|
+
if (ele) {
|
|
301
|
+
tabElement.current[refName] = ele;
|
|
302
|
+
} // tabElement.current[refName] = ele
|
|
303
|
+
|
|
304
|
+
|
|
354
305
|
let key = isVirtual ? `virtual_${refName}` : refName;
|
|
355
306
|
|
|
356
307
|
if (ele) {
|
|
357
|
-
|
|
358
|
-
|
|
308
|
+
tabObserver.current[key] = new ResizeObserver(onTabResize);
|
|
309
|
+
tabObserver.current[key].observe(ele);
|
|
359
310
|
} else {
|
|
360
|
-
if (
|
|
361
|
-
|
|
311
|
+
if (tabObserver.current && tabObserver.current[key]) {
|
|
312
|
+
tabObserver.current[key].disconnect();
|
|
362
313
|
}
|
|
363
314
|
}
|
|
364
315
|
}
|
|
365
316
|
|
|
366
|
-
moreTabSelect(tab, value, index, e) {
|
|
367
|
-
let {
|
|
368
|
-
onSelect
|
|
369
|
-
} = this.props;
|
|
370
|
-
|
|
317
|
+
function moreTabSelect(tab, value, index, e) {
|
|
371
318
|
if (e && e.target && e.target.parentElement.tagName === 'A' && (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)) {
|
|
372
319
|
cancelBubblingEffect(e);
|
|
373
320
|
return;
|
|
@@ -377,28 +324,19 @@ class Tabs extends React.Component {
|
|
|
377
324
|
onSelect(tab);
|
|
378
325
|
}
|
|
379
326
|
|
|
380
|
-
|
|
327
|
+
function onScrollLocal(e) {
|
|
381
328
|
e.persist();
|
|
382
|
-
let {
|
|
383
|
-
onScroll
|
|
384
|
-
} = this.props;
|
|
385
329
|
onScroll && throttle(onScroll, 100, e);
|
|
386
330
|
}
|
|
387
331
|
|
|
388
|
-
|
|
389
|
-
let {
|
|
390
|
-
boxPosition,
|
|
391
|
-
togglePopup,
|
|
392
|
-
align,
|
|
393
|
-
removeClose
|
|
394
|
-
} = this.props;
|
|
332
|
+
function togglePopupLocal(e) {
|
|
395
333
|
removeClose && removeClose(e);
|
|
396
334
|
let popupPosition = align === 'vertical' ? 'bottomLeft' : 'rightTop';
|
|
397
335
|
boxPosition = boxPosition ? boxPosition : popupPosition;
|
|
398
336
|
togglePopup(e, boxPosition);
|
|
399
337
|
}
|
|
400
338
|
|
|
401
|
-
responsiveFunc(_ref) {
|
|
339
|
+
function responsiveFunc(_ref) {
|
|
402
340
|
let {
|
|
403
341
|
mediaQueryOR
|
|
404
342
|
} = _ref;
|
|
@@ -409,9 +347,8 @@ class Tabs extends React.Component {
|
|
|
409
347
|
};
|
|
410
348
|
}
|
|
411
349
|
|
|
412
|
-
renderTabs(mainTabs, moreTabs, isVirtual) {
|
|
350
|
+
function renderTabs(mainTabs, moreTabs, isVirtual) {
|
|
413
351
|
let {
|
|
414
|
-
selectedTab,
|
|
415
352
|
moreButtonClass,
|
|
416
353
|
moreButtonActiveClass,
|
|
417
354
|
moreBoxClass,
|
|
@@ -423,7 +360,6 @@ class Tabs extends React.Component {
|
|
|
423
360
|
isPopupOpen,
|
|
424
361
|
getContainerRef,
|
|
425
362
|
showTitleInMoreOptions,
|
|
426
|
-
onSelect,
|
|
427
363
|
moreContainerClass,
|
|
428
364
|
align,
|
|
429
365
|
type,
|
|
@@ -434,9 +370,8 @@ class Tabs extends React.Component {
|
|
|
434
370
|
getTargetRef,
|
|
435
371
|
position,
|
|
436
372
|
customProps,
|
|
437
|
-
getCustomDropBoxHeaderPlaceHolder
|
|
438
|
-
|
|
439
|
-
} = this.props;
|
|
373
|
+
getCustomDropBoxHeaderPlaceHolder
|
|
374
|
+
} = props;
|
|
440
375
|
let {
|
|
441
376
|
DropBoxProps = {},
|
|
442
377
|
ListItemProps = {},
|
|
@@ -461,9 +396,9 @@ class Tabs extends React.Component {
|
|
|
461
396
|
|
|
462
397
|
return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(MainTab, _extends({}, child.props, {
|
|
463
398
|
key: child.props.id,
|
|
464
|
-
getTabRef:
|
|
465
|
-
onSelect: onSelect
|
|
466
|
-
|
|
399
|
+
getTabRef: getTabRef,
|
|
400
|
+
onSelect: onSelect // recalculateDimension={tabElement.current[recalculateDimension]}
|
|
401
|
+
,
|
|
467
402
|
isActive: child.props.id === selectedTab,
|
|
468
403
|
type: type,
|
|
469
404
|
isAnimate: isAnimate,
|
|
@@ -478,7 +413,7 @@ class Tabs extends React.Component {
|
|
|
478
413
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
479
414
|
className: `${btnstyle.buttonReset} ${moreButtonClass} ${isPopupOpen ? moreButtonActiveClass : ''}`,
|
|
480
415
|
align: "both",
|
|
481
|
-
onClick:
|
|
416
|
+
onClick: togglePopupLocal,
|
|
482
417
|
dataId: "moreTabs",
|
|
483
418
|
eleRef: getTargetRef
|
|
484
419
|
}, MoreButtonProps, {
|
|
@@ -489,7 +424,7 @@ class Tabs extends React.Component {
|
|
|
489
424
|
name: iconName,
|
|
490
425
|
size: iconSize
|
|
491
426
|
})), isPopupOpen && /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
492
|
-
query:
|
|
427
|
+
query: responsiveFunc,
|
|
493
428
|
responsiveId: "Helmet"
|
|
494
429
|
}, _ref2 => {
|
|
495
430
|
let {
|
|
@@ -509,13 +444,13 @@ class Tabs extends React.Component {
|
|
|
509
444
|
}, DropBoxProps, {
|
|
510
445
|
isResponsivePadding: true,
|
|
511
446
|
needFocusScope: true,
|
|
512
|
-
onClose:
|
|
513
|
-
}), getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(
|
|
447
|
+
onClose: togglePopupLocal
|
|
448
|
+
}), getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(props), /*#__PURE__*/React.createElement(Box, {
|
|
514
449
|
flexible: true,
|
|
515
450
|
shrink: true,
|
|
516
451
|
scroll: "vertical",
|
|
517
452
|
className: `${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
518
|
-
onScroll:
|
|
453
|
+
onScroll: onScrollLocal
|
|
519
454
|
}, React.Children.map(moreTabs, child => {
|
|
520
455
|
if (!child) {
|
|
521
456
|
return null;
|
|
@@ -534,7 +469,7 @@ class Tabs extends React.Component {
|
|
|
534
469
|
return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
535
470
|
key: id,
|
|
536
471
|
value: value,
|
|
537
|
-
onClick:
|
|
472
|
+
onClick: moreTabSelect,
|
|
538
473
|
id: id,
|
|
539
474
|
title: title || text,
|
|
540
475
|
isLink: isLink,
|
|
@@ -550,60 +485,36 @@ class Tabs extends React.Component {
|
|
|
550
485
|
})) : null);
|
|
551
486
|
}
|
|
552
487
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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
|
-
}
|
|
488
|
+
let {
|
|
489
|
+
mainTabs,
|
|
490
|
+
moreTabs,
|
|
491
|
+
otherTabs
|
|
492
|
+
} = responsiveTab(totalDimension, tabDimensions);
|
|
493
|
+
let appearanceClass = cs([tabsStyle[type], needBorder && tabsStyle[`${type}_border`], needPadding && tabsStyle[`${type}_padding`]]);
|
|
494
|
+
let tabsClass = cs([tabsStyle.tab, className, needAppearance && appearanceClass]);
|
|
495
|
+
let hlClass = cs([tabsStyle.highlight, highlightClass, isAnimate && tabsStyle.lineAnimate]);
|
|
496
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
497
|
+
className: containerClass,
|
|
498
|
+
dataSelectorId: dataSelectorId
|
|
499
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
500
|
+
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
501
|
+
className: tabsClass,
|
|
502
|
+
style: style
|
|
503
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
504
|
+
eleRef: getTabsRef,
|
|
505
|
+
flexible: true
|
|
506
|
+
}, renderVirtualTabs && /*#__PURE__*/React.createElement(Container, {
|
|
507
|
+
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
508
|
+
className: tabsStyle.hidden
|
|
509
|
+
}, renderTabs(children, [], true)), /*#__PURE__*/React.createElement(Container, {
|
|
510
|
+
alignBox: align === 'vertical' ? 'row' : 'column'
|
|
511
|
+
}, renderTabs(mainTabs, moreTabs, false))), otherTabs.length ? /*#__PURE__*/React.createElement(Box, null, otherTabs) : null, isAnimate && needTabBorder && needAppearance && /*#__PURE__*/React.createElement("div", {
|
|
512
|
+
className: hlClass,
|
|
513
|
+
ref: getHighlightRef,
|
|
514
|
+
"data-id": dataId,
|
|
515
|
+
"data-test-id": dataId
|
|
516
|
+
})));
|
|
517
|
+
};
|
|
607
518
|
|
|
608
519
|
Tabs.propTypes = Tabs_propTypes;
|
|
609
520
|
Tabs.defaultProps = { ...Tabs_defaultProps,
|