@zohodesk/components 1.0.0-temp-183 → 1.0.0-temp-184
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/propValidation_report.html +1 -1
- package/.cli/stringContains.js +1 -0
- package/README.md +6 -0
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +15 -0
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkTheme.module.css +1 -0
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +15 -0
- package/assets/Appearance/dark/themes/green/green_CTA_DarkTheme.module.css +1 -0
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +15 -0
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkTheme.module.css +1 -0
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +15 -0
- package/assets/Appearance/dark/themes/red/red_CTA_DarkTheme.module.css +1 -0
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +15 -0
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkTheme.module.css +1 -0
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +15 -0
- package/assets/Appearance/light/themes/blue/blue_CTA_LightTheme.module.css +1 -0
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +15 -0
- package/assets/Appearance/light/themes/green/green_CTA_LightTheme.module.css +1 -0
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +15 -0
- package/assets/Appearance/light/themes/orange/orange_CTA_LightTheme.module.css +1 -0
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +15 -0
- package/assets/Appearance/light/themes/red/red_CTA_LightTheme.module.css +1 -0
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +15 -0
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightTheme.module.css +1 -0
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +15 -0
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkTheme.module.css +1 -0
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +15 -0
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkTheme.module.css +1 -0
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +15 -0
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkTheme.module.css +1 -0
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +15 -0
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkTheme.module.css +1 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +15 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkTheme.module.css +1 -0
- package/es/AvatarTeam/AvatarTeam.module.css +2 -0
- package/es/DropBox/DropBoxElement/DropBoxElement.js +2 -1
- package/es/Select/Select.js +10 -2
- package/es/Select/Select.module.css +26 -1
- package/es/Tab/TabContentWrapper.js +8 -4
- package/es/Tab/props/defaultProps.js +2 -1
- package/es/Tab/props/propTypes.js +3 -1
- package/es/TextBox/TextBox.js +7 -1
- package/es/TextBox/TextBox.module.css +39 -1
- 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/Tooltip/Tooltip.js +4 -2
- package/es/Tooltip/Tooltip.module.css +0 -4
- package/es/common/customscroll.module.css +0 -10
- package/es/v1/Select/Select.js +10 -2
- package/es/v1/Tab/Tab.js +1 -3
- package/es/v1/Tab/TabContent.js +1 -1
- package/es/v1/Tab/Tabs.js +175 -262
- 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 +7 -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/AvatarTeam/AvatarTeam.module.css +2 -0
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +2 -1
- package/lib/Select/Select.js +11 -2
- package/lib/Select/Select.module.css +26 -1
- package/lib/Tab/TabContentWrapper.js +8 -4
- package/lib/Tab/props/defaultProps.js +2 -1
- package/lib/Tab/props/propTypes.js +3 -1
- package/lib/TextBox/TextBox.js +9 -1
- package/lib/TextBox/TextBox.module.css +39 -1
- 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/Tooltip/Tooltip.js +4 -2
- package/lib/Tooltip/Tooltip.module.css +0 -4
- package/lib/common/customscroll.module.css +0 -10
- package/lib/v1/Select/Select.js +11 -2
- package/lib/v1/Tab/Tab.js +6 -6
- package/lib/v1/Tab/TabContent.js +2 -2
- package/lib/v1/Tab/Tabs.js +434 -530
- 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 +8 -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 +8 -7
- package/result.json +1 -1
- /package/.cli/{AppearanceThemeValidationExcludeFiles.js → ThemeValidationExcludeFiles.js} +0 -0
package/es/v1/Tab/Tabs.js
CHANGED
|
@@ -1,63 +1,67 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
markAsUsed: [
|
|
5
|
-
'hidden','alpha','gamma','beta','delta','special','text','maxWidth','widgetList','menuContainer','border','tabText','block','tabAlpha','alphaActive','gammaActive','betaActive','deltaActive','tabGamma','tabBeta','tabDelta','specialActive','tabSpecial',
|
|
6
|
-
'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'
|
|
7
|
-
]
|
|
8
|
-
}]
|
|
9
|
-
*/
|
|
10
|
-
import React from 'react';
|
|
2
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import useEffectCallOnlyAfterState from '@zohodesk/hooks/es/utils/useEffectCallOnlyAfterState';
|
|
11
4
|
import Tab from './Tab';
|
|
12
5
|
import { Tabs_defaultProps } from './props/defaultProps';
|
|
13
6
|
import { Tabs_propTypes } from './props/propTypes';
|
|
14
|
-
import { remConvert, getTotalDimension, cs,
|
|
7
|
+
import { remConvert, getTotalDimension, cs, throttle, cancelBubblingEffect } from '../../utils/Common';
|
|
15
8
|
import { Box, Container } from '../Layout';
|
|
16
9
|
import ResizeObserver from '../Responsive/ResizeObserver';
|
|
17
10
|
import ListItem from '../ListItem/ListItem';
|
|
18
11
|
import { Icon } from '@zohodesk/icons';
|
|
19
|
-
import tabsStyle from '
|
|
12
|
+
import tabsStyle from './v1Tabs.module.css';
|
|
20
13
|
import Popup from '../Popup/Popup';
|
|
21
14
|
import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
22
15
|
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
23
16
|
import btnstyle from '../../semantic/Button/semanticButton.module.css';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
const Tabs = props => {
|
|
18
|
+
const [totalDimension, setTotalDimension] = useState(null);
|
|
19
|
+
const [tabDimensions, setTabDimensions] = useState({});
|
|
20
|
+
const highlightInitialDimension = useRef(null);
|
|
21
|
+
const [renderVirtualTabs, setRenderVirtualTabs] = useState(true);
|
|
22
|
+
const [tabKeys, setTabKeys] = useState([]);
|
|
23
|
+
const tabsObserver = useRef(new ResizeObserver(onResize));
|
|
24
|
+
const tabObserver = useRef({});
|
|
25
|
+
const highlight = useRef(null);
|
|
26
|
+
const tabsEle = useRef(null);
|
|
27
|
+
const tabElement = useRef({});
|
|
28
|
+
let {
|
|
29
|
+
style,
|
|
30
|
+
className,
|
|
31
|
+
dataId,
|
|
32
|
+
highlightClass,
|
|
33
|
+
type,
|
|
34
|
+
isAnimate,
|
|
35
|
+
needTabBorder,
|
|
36
|
+
needBorder,
|
|
37
|
+
needPadding,
|
|
38
|
+
align,
|
|
39
|
+
boxPosition,
|
|
40
|
+
removeClose,
|
|
41
|
+
togglePopup,
|
|
42
|
+
needAppearance,
|
|
43
|
+
children,
|
|
44
|
+
onSelect,
|
|
45
|
+
onScroll,
|
|
46
|
+
isResponsive,
|
|
47
|
+
maxTabsCount,
|
|
48
|
+
minTabsCount,
|
|
49
|
+
childType,
|
|
50
|
+
containerClass,
|
|
51
|
+
dataSelectorId,
|
|
52
|
+
selectedTab
|
|
53
|
+
} = props;
|
|
54
|
+
function onTabResize(size, target) {
|
|
45
55
|
let newDim = Object.assign({}, tabDimensions);
|
|
46
56
|
let elemDim = getTotalDimension(target, align);
|
|
47
57
|
if (elemDim !== 0) {
|
|
48
58
|
newDim[target.dataset.key] = elemDim;
|
|
49
59
|
}
|
|
50
|
-
|
|
51
|
-
tabDimensions: newDim
|
|
52
|
-
});
|
|
60
|
+
setTabDimensions(newDim);
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
childType
|
|
58
|
-
} = this.props;
|
|
59
|
-
let totalDimension = this.getTotalDimension();
|
|
60
|
-
let tabDimensions = this.getTabDimensions();
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
let totalDimension = getTotalDimensionLocal();
|
|
64
|
+
let tabDimensions = getTabDimensions();
|
|
61
65
|
let tabKeys = [];
|
|
62
66
|
let restrictedKeys = ['state', 'props', 'refs', 'context'];
|
|
63
67
|
React.Children.toArray(children).forEach(child => {
|
|
@@ -69,65 +73,43 @@ class Tabs extends React.Component {
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
highlightInitialDimension: this.getHighlightDim()
|
|
80
|
-
}, () => {
|
|
81
|
-
this.moveHighlight();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
componentWillUnmount() {
|
|
85
|
-
if (this.tabsObserver) {
|
|
86
|
-
this.tabsObserver.disconnect();
|
|
87
|
-
this.tabsObserver = null;
|
|
88
|
-
}
|
|
89
|
-
if (this.tabObserver) {
|
|
90
|
-
Object.keys(this.tabObserver).forEach(observer => {
|
|
91
|
-
this.tabObserver[observer] && this.tabObserver[observer].disconnect();
|
|
92
|
-
});
|
|
93
|
-
this.tabObserver = null;
|
|
76
|
+
setTotalDimension(totalDimension);
|
|
77
|
+
setTabDimensions(tabDimensions);
|
|
78
|
+
setRenderVirtualTabs(false);
|
|
79
|
+
setTabKeys(tabKeys);
|
|
80
|
+
if (highlight.current) {
|
|
81
|
+
highlightInitialDimension.current = getHighlightDim();
|
|
82
|
+
moveHighlight();
|
|
94
83
|
}
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
return () => {
|
|
85
|
+
if (tabsObserver.current) {
|
|
86
|
+
tabsObserver.current.disconnect();
|
|
87
|
+
tabsObserver.current = null;
|
|
88
|
+
}
|
|
89
|
+
if (tabObserver.current) {
|
|
90
|
+
Object.keys(tabObserver.current).forEach(observer => {
|
|
91
|
+
tabObserver.current[observer] && tabObserver.current[observer].disconnect();
|
|
92
|
+
});
|
|
93
|
+
tabObserver.current = null;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}, []);
|
|
97
|
+
function setMaxDim() {
|
|
97
98
|
let totalDimension = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
98
|
-
let {
|
|
99
|
-
selectedTab
|
|
100
|
-
} = this.props;
|
|
101
99
|
// let actual = Object.keys(tabDimensions).reduce(
|
|
102
100
|
// (sum, tab) => sum + (tabDimensions[tab] || 0),
|
|
103
101
|
// 0
|
|
104
102
|
// );
|
|
105
|
-
if (totalDimension &&
|
|
106
|
-
let {
|
|
107
|
-
align
|
|
108
|
-
} = this.props;
|
|
103
|
+
if (totalDimension && tabElement.current[selectedTab]) {
|
|
109
104
|
let newDim = `${remConvert(totalDimension)}rem`;
|
|
110
|
-
align === 'vertical' ?
|
|
105
|
+
align === 'vertical' ? tabElement.current[selectedTab].style.maxWidth = newDim : tabElement.current[selectedTab].style.maxHeight = newDim;
|
|
111
106
|
}
|
|
112
107
|
}
|
|
113
|
-
getHighlightDim() {
|
|
114
|
-
|
|
115
|
-
align
|
|
116
|
-
} = this.props;
|
|
117
|
-
return align === 'vertical' ? this.highlight.offsetLeft : this.highlight.offsetTop;
|
|
108
|
+
function getHighlightDim() {
|
|
109
|
+
return align === 'vertical' ? highlight.current.offsetLeft : highlight.current.offsetTop;
|
|
118
110
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
children,
|
|
122
|
-
selectedTab,
|
|
123
|
-
childType
|
|
124
|
-
} = this.props;
|
|
125
|
-
let {
|
|
126
|
-
tabDimensions,
|
|
127
|
-
totalDimension,
|
|
128
|
-
tabKeys
|
|
129
|
-
} = this.state;
|
|
130
|
-
if (prevProps.children && children) {
|
|
111
|
+
useEffectCallOnlyAfterState(() => {
|
|
112
|
+
if (children) {
|
|
131
113
|
/**
|
|
132
114
|
* To recalculate the dimensions of tabs we are checking the children length.
|
|
133
115
|
* and also checking the tab id and their order.
|
|
@@ -141,123 +123,91 @@ class Tabs extends React.Component {
|
|
|
141
123
|
});
|
|
142
124
|
let isSameTabKeys = newTabKeys.every((current, index) => tabKeys[index] === current);
|
|
143
125
|
if (newTabKeys.length !== tabKeys.length || !isSameTabKeys) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.setState({
|
|
151
|
-
tabDimensions,
|
|
152
|
-
totalDimension,
|
|
153
|
-
renderVirtualTabs: false
|
|
154
|
-
});
|
|
126
|
+
setRenderVirtualTabs(true);
|
|
127
|
+
setTabKeys(newTabKeys);
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
setTabDimensions(getTabDimensions());
|
|
130
|
+
setTotalDimension(getTotalDimensionLocal());
|
|
131
|
+
setRenderVirtualTabs(false);
|
|
155
132
|
});
|
|
156
133
|
}
|
|
157
|
-
if (
|
|
158
|
-
|
|
134
|
+
if (newTabKeys.length === 1) {
|
|
135
|
+
moveHighlight();
|
|
159
136
|
}
|
|
160
137
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
let
|
|
170
|
-
highlightInitialDimension
|
|
171
|
-
} = this.state;
|
|
172
|
-
let node = this.highlight;
|
|
138
|
+
});
|
|
139
|
+
useEffectCallOnlyAfterState(() => {
|
|
140
|
+
tabsObserver.current && tabsObserver.current.replaceResizeHandler(onResize);
|
|
141
|
+
if (children) {
|
|
142
|
+
moveHighlight();
|
|
143
|
+
}
|
|
144
|
+
}, [selectedTab]);
|
|
145
|
+
function moveHighlight() {
|
|
146
|
+
let node = highlight.current;
|
|
173
147
|
if (isAnimate && needTabBorder && node) {
|
|
174
|
-
let tabActive =
|
|
148
|
+
let tabActive = tabElement.current[selectedTab];
|
|
175
149
|
if (tabActive) {
|
|
176
150
|
let position, dimension;
|
|
177
151
|
if (align === 'vertical') {
|
|
178
152
|
position = tabActive.offsetLeft;
|
|
179
153
|
dimension = tabActive.offsetWidth;
|
|
180
|
-
node.style.transform = `translateX(${remConvert(position - highlightInitialDimension)}rem)`;
|
|
154
|
+
node.style.transform = `translateX(${remConvert(position - highlightInitialDimension.current)}rem)`;
|
|
181
155
|
node.style.width = `${remConvert(dimension)}rem`;
|
|
182
156
|
} else if (align === 'horizontal') {
|
|
183
157
|
position = tabActive.offsetTop;
|
|
184
158
|
dimension = tabActive.offsetHeight;
|
|
185
|
-
node.style.transform = `translateY(${remConvert(position - highlightInitialDimension)}rem)`;
|
|
159
|
+
node.style.transform = `translateY(${remConvert(position - highlightInitialDimension.current)}rem)`;
|
|
186
160
|
node.style.height = `${remConvert(dimension)}rem`;
|
|
187
161
|
}
|
|
188
162
|
}
|
|
189
163
|
}
|
|
190
164
|
}
|
|
191
|
-
getHighlightRef(ele
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
getTabsRef(ele
|
|
195
|
-
|
|
165
|
+
const getHighlightRef = useCallback(ele => {
|
|
166
|
+
highlight.current = ele;
|
|
167
|
+
}, []);
|
|
168
|
+
const getTabsRef = useCallback(ele => {
|
|
169
|
+
tabsEle.current = ele;
|
|
196
170
|
if (ele) {
|
|
197
|
-
|
|
171
|
+
tabsObserver.current.observe(ele);
|
|
198
172
|
} else {
|
|
199
|
-
|
|
173
|
+
tabsObserver.current && tabsObserver.current.disconnect();
|
|
174
|
+
}
|
|
175
|
+
}, []);
|
|
176
|
+
function onSizeChange() {
|
|
177
|
+
let totalDimension = getTotalDimensionLocal();
|
|
178
|
+
setTotalDimension(totalDimension);
|
|
179
|
+
if (highlight.current) {
|
|
180
|
+
highlightInitialDimension.current = getHighlightDim();
|
|
181
|
+
moveHighlight();
|
|
200
182
|
}
|
|
201
183
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.setState({
|
|
205
|
-
totalDimension
|
|
206
|
-
});
|
|
207
|
-
this.highlight && this.setState({
|
|
208
|
-
highlightInitialDimension: this.getHighlightDim()
|
|
209
|
-
}, () => {
|
|
210
|
-
this.moveHighlight();
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
onResize(timer) {
|
|
214
|
-
let {
|
|
215
|
-
isResponsive
|
|
216
|
-
} = this.props;
|
|
217
|
-
if (this.tabsEle && isResponsive) {
|
|
184
|
+
function onResize(timer) {
|
|
185
|
+
if (tabsEle.current && isResponsive) {
|
|
218
186
|
if (!timer) {
|
|
219
|
-
|
|
187
|
+
onSizeChange();
|
|
220
188
|
} else {
|
|
221
189
|
setTimeout(() => {
|
|
222
|
-
|
|
190
|
+
onSizeChange();
|
|
223
191
|
}, timer);
|
|
224
192
|
}
|
|
225
193
|
}
|
|
226
194
|
}
|
|
227
|
-
|
|
228
|
-
let
|
|
229
|
-
align
|
|
230
|
-
} = this.props;
|
|
231
|
-
let totalDimension = this.tabsEle && getTotalDimension(this.tabsEle, align);
|
|
195
|
+
function getTotalDimensionLocal() {
|
|
196
|
+
let totalDimension = tabsEle.current && getTotalDimension(tabsEle.current, align);
|
|
232
197
|
return totalDimension;
|
|
233
198
|
}
|
|
234
|
-
getTabDimensions() {
|
|
235
|
-
let {
|
|
236
|
-
children,
|
|
237
|
-
align,
|
|
238
|
-
childType
|
|
239
|
-
} = this.props;
|
|
199
|
+
function getTabDimensions() {
|
|
240
200
|
let tabDimensions = {};
|
|
241
|
-
React.Children.forEach(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === childType &&
|
|
242
|
-
[child.props.id]:
|
|
201
|
+
React.Children.forEach(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === childType && tabElement.current[child.props.id] && Object.assign(tabDimensions, {
|
|
202
|
+
[child.props.id]: tabElement.current[child.props.id] && getTotalDimension(tabElement.current[child.props.id], align)
|
|
243
203
|
}));
|
|
244
204
|
return tabDimensions;
|
|
245
205
|
}
|
|
246
|
-
responsiveTab(totalDimension, tabDimensions) {
|
|
247
|
-
let {
|
|
248
|
-
children,
|
|
249
|
-
maxTabsCount,
|
|
250
|
-
minTabsCount,
|
|
251
|
-
isResponsive
|
|
252
|
-
} = this.props;
|
|
206
|
+
function responsiveTab(totalDimension, tabDimensions) {
|
|
253
207
|
let mainTabs = [],
|
|
254
208
|
moreTabs = [],
|
|
255
209
|
otherTabs = [];
|
|
256
210
|
if (totalDimension && isResponsive) {
|
|
257
|
-
let {
|
|
258
|
-
childType,
|
|
259
|
-
selectedTab
|
|
260
|
-
} = this.props;
|
|
261
211
|
let selectedTabDimension = tabDimensions[selectedTab] || 0;
|
|
262
212
|
let remainingDimension = totalDimension - selectedTabDimension;
|
|
263
213
|
let maxTabsTobeVisible = maxTabsCount - 1;
|
|
@@ -295,12 +245,9 @@ class Tabs extends React.Component {
|
|
|
295
245
|
newTabs = mainTabs.map(tab => React.cloneElement(tab, { style: { maxHeight: newDim } }));
|
|
296
246
|
}
|
|
297
247
|
mainTabs = newTabs; */
|
|
298
|
-
|
|
248
|
+
setMaxDim(totalDimension);
|
|
299
249
|
}
|
|
300
250
|
} else if (!isResponsive) {
|
|
301
|
-
let {
|
|
302
|
-
childType
|
|
303
|
-
} = this.props;
|
|
304
251
|
React.Children.forEach(children, child => {
|
|
305
252
|
if (child && child.type === childType && child.props.id) {
|
|
306
253
|
mainTabs.push(child);
|
|
@@ -317,22 +264,22 @@ class Tabs extends React.Component {
|
|
|
317
264
|
otherTabs
|
|
318
265
|
};
|
|
319
266
|
}
|
|
320
|
-
getTabRef(refName, ele, isVirtual) {
|
|
321
|
-
|
|
267
|
+
function getTabRef(refName, ele, isVirtual) {
|
|
268
|
+
if (ele) {
|
|
269
|
+
tabElement.current[refName] = ele;
|
|
270
|
+
}
|
|
271
|
+
// tabElement.current[refName] = ele
|
|
322
272
|
let key = isVirtual ? `virtual_${refName}` : refName;
|
|
323
273
|
if (ele) {
|
|
324
|
-
|
|
325
|
-
|
|
274
|
+
tabObserver.current[key] = new ResizeObserver(onTabResize);
|
|
275
|
+
tabObserver.current[key].observe(ele);
|
|
326
276
|
} else {
|
|
327
|
-
if (
|
|
328
|
-
|
|
277
|
+
if (tabObserver.current && tabObserver.current[key]) {
|
|
278
|
+
tabObserver.current[key].disconnect();
|
|
329
279
|
}
|
|
330
280
|
}
|
|
331
281
|
}
|
|
332
|
-
moreTabSelect(tab, value, index, e) {
|
|
333
|
-
let {
|
|
334
|
-
onSelect
|
|
335
|
-
} = this.props;
|
|
282
|
+
function moreTabSelect(tab, value, index, e) {
|
|
336
283
|
if (e && e.target && e.target.parentElement.tagName === 'A' && (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)) {
|
|
337
284
|
cancelBubblingEffect(e);
|
|
338
285
|
return;
|
|
@@ -340,26 +287,17 @@ class Tabs extends React.Component {
|
|
|
340
287
|
e.preventDefault();
|
|
341
288
|
onSelect(tab);
|
|
342
289
|
}
|
|
343
|
-
|
|
290
|
+
function onScrollLocal(e) {
|
|
344
291
|
e.persist();
|
|
345
|
-
let {
|
|
346
|
-
onScroll
|
|
347
|
-
} = this.props;
|
|
348
292
|
onScroll && throttle(onScroll, 100, e);
|
|
349
293
|
}
|
|
350
|
-
|
|
351
|
-
let {
|
|
352
|
-
boxPosition,
|
|
353
|
-
togglePopup,
|
|
354
|
-
align,
|
|
355
|
-
removeClose
|
|
356
|
-
} = this.props;
|
|
294
|
+
function togglePopupLocal(e) {
|
|
357
295
|
removeClose && removeClose(e);
|
|
358
296
|
let popupPosition = align === 'vertical' ? 'bottomLeft' : 'rightTop';
|
|
359
297
|
boxPosition = boxPosition ? boxPosition : popupPosition;
|
|
360
298
|
togglePopup(e, boxPosition);
|
|
361
299
|
}
|
|
362
|
-
responsiveFunc(_ref) {
|
|
300
|
+
function responsiveFunc(_ref) {
|
|
363
301
|
let {
|
|
364
302
|
mediaQueryOR
|
|
365
303
|
} = _ref;
|
|
@@ -369,9 +307,8 @@ class Tabs extends React.Component {
|
|
|
369
307
|
}])
|
|
370
308
|
};
|
|
371
309
|
}
|
|
372
|
-
renderTabs(mainTabs, moreTabs, isVirtual) {
|
|
310
|
+
function renderTabs(mainTabs, moreTabs, isVirtual) {
|
|
373
311
|
let {
|
|
374
|
-
selectedTab,
|
|
375
312
|
moreButtonClass,
|
|
376
313
|
moreButtonActiveClass,
|
|
377
314
|
moreBoxClass,
|
|
@@ -383,7 +320,6 @@ class Tabs extends React.Component {
|
|
|
383
320
|
isPopupOpen,
|
|
384
321
|
getContainerRef,
|
|
385
322
|
showTitleInMoreOptions,
|
|
386
|
-
onSelect,
|
|
387
323
|
moreContainerClass,
|
|
388
324
|
align,
|
|
389
325
|
type,
|
|
@@ -394,9 +330,8 @@ class Tabs extends React.Component {
|
|
|
394
330
|
getTargetRef,
|
|
395
331
|
position,
|
|
396
332
|
customProps,
|
|
397
|
-
getCustomDropBoxHeaderPlaceHolder
|
|
398
|
-
|
|
399
|
-
} = this.props;
|
|
333
|
+
getCustomDropBoxHeaderPlaceHolder
|
|
334
|
+
} = props;
|
|
400
335
|
let {
|
|
401
336
|
DropBoxProps = {},
|
|
402
337
|
ListItemProps = {},
|
|
@@ -417,9 +352,10 @@ class Tabs extends React.Component {
|
|
|
417
352
|
}
|
|
418
353
|
return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(MainTab, _extends({}, child.props, {
|
|
419
354
|
key: child.props.id,
|
|
420
|
-
getTabRef:
|
|
421
|
-
onSelect: onSelect
|
|
422
|
-
recalculateDimension
|
|
355
|
+
getTabRef: getTabRef,
|
|
356
|
+
onSelect: onSelect
|
|
357
|
+
// recalculateDimension={tabElement.current[recalculateDimension]}
|
|
358
|
+
,
|
|
423
359
|
isActive: child.props.id === selectedTab,
|
|
424
360
|
type: type,
|
|
425
361
|
isAnimate: isAnimate,
|
|
@@ -434,7 +370,7 @@ class Tabs extends React.Component {
|
|
|
434
370
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
435
371
|
className: `${btnstyle.buttonReset} ${moreButtonClass} ${isPopupOpen ? moreButtonActiveClass : ''}`,
|
|
436
372
|
align: "both",
|
|
437
|
-
onClick:
|
|
373
|
+
onClick: togglePopupLocal,
|
|
438
374
|
dataId: "moreTabs",
|
|
439
375
|
eleRef: getTargetRef
|
|
440
376
|
}, MoreButtonProps, {
|
|
@@ -445,7 +381,7 @@ class Tabs extends React.Component {
|
|
|
445
381
|
name: iconName,
|
|
446
382
|
size: iconSize
|
|
447
383
|
})), isPopupOpen && /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
448
|
-
query:
|
|
384
|
+
query: responsiveFunc,
|
|
449
385
|
responsiveId: "Helmet"
|
|
450
386
|
}, _ref2 => {
|
|
451
387
|
let {
|
|
@@ -465,13 +401,13 @@ class Tabs extends React.Component {
|
|
|
465
401
|
}, DropBoxProps, {
|
|
466
402
|
isResponsivePadding: true,
|
|
467
403
|
needFocusScope: true,
|
|
468
|
-
onClose:
|
|
469
|
-
}), getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(
|
|
404
|
+
onClose: togglePopupLocal
|
|
405
|
+
}), getCustomDropBoxHeaderPlaceHolder && getCustomDropBoxHeaderPlaceHolder(props), /*#__PURE__*/React.createElement(Box, {
|
|
470
406
|
flexible: true,
|
|
471
407
|
shrink: true,
|
|
472
408
|
scroll: "vertical",
|
|
473
409
|
className: `${tabletMode ? '' : tabsStyle.menuBox} ${moreBoxClass}`,
|
|
474
|
-
onScroll:
|
|
410
|
+
onScroll: onScrollLocal
|
|
475
411
|
}, React.Children.map(moreTabs, child => {
|
|
476
412
|
if (!child) {
|
|
477
413
|
return null;
|
|
@@ -489,7 +425,7 @@ class Tabs extends React.Component {
|
|
|
489
425
|
return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
490
426
|
key: id,
|
|
491
427
|
value: value,
|
|
492
|
-
onClick:
|
|
428
|
+
onClick: moreTabSelect,
|
|
493
429
|
id: id,
|
|
494
430
|
title: title || text,
|
|
495
431
|
isLink: isLink,
|
|
@@ -504,59 +440,36 @@ class Tabs extends React.Component {
|
|
|
504
440
|
})));
|
|
505
441
|
})) : null);
|
|
506
442
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
538
|
-
className: containerClass,
|
|
539
|
-
dataSelectorId: dataSelectorId
|
|
540
|
-
}, /*#__PURE__*/React.createElement(Container, {
|
|
541
|
-
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
542
|
-
className: tabsClass,
|
|
543
|
-
style: style
|
|
544
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
545
|
-
eleRef: this.getTabsRef,
|
|
546
|
-
flexible: true
|
|
547
|
-
}, renderVirtualTabs && /*#__PURE__*/React.createElement(Container, {
|
|
548
|
-
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
549
|
-
className: tabsStyle.hidden
|
|
550
|
-
}, this.renderTabs(children, [], true)), /*#__PURE__*/React.createElement(Container, {
|
|
551
|
-
alignBox: align === 'vertical' ? 'row' : 'column'
|
|
552
|
-
}, this.renderTabs(mainTabs, moreTabs, false))), otherTabs.length ? /*#__PURE__*/React.createElement(Box, null, otherTabs) : null, isAnimate && needTabBorder && needAppearance && /*#__PURE__*/React.createElement("div", {
|
|
553
|
-
className: hlClass,
|
|
554
|
-
ref: this.getHighlightRef,
|
|
555
|
-
"data-id": dataId,
|
|
556
|
-
"data-test-id": dataId
|
|
557
|
-
})));
|
|
558
|
-
}
|
|
559
|
-
}
|
|
443
|
+
let {
|
|
444
|
+
mainTabs,
|
|
445
|
+
moreTabs,
|
|
446
|
+
otherTabs
|
|
447
|
+
} = responsiveTab(totalDimension, tabDimensions);
|
|
448
|
+
let appearanceClass = cs([tabsStyle[type], needBorder && tabsStyle[`${type}_border`], needPadding && tabsStyle[`${type}_padding`]]);
|
|
449
|
+
let tabsClass = cs([tabsStyle.tab, className, needAppearance && appearanceClass]);
|
|
450
|
+
let hlClass = cs([tabsStyle.highlight, highlightClass, isAnimate && tabsStyle.lineAnimate]);
|
|
451
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
452
|
+
className: containerClass,
|
|
453
|
+
dataSelectorId: dataSelectorId
|
|
454
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
455
|
+
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
456
|
+
className: tabsClass,
|
|
457
|
+
style: style
|
|
458
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
459
|
+
eleRef: getTabsRef,
|
|
460
|
+
flexible: true
|
|
461
|
+
}, renderVirtualTabs && /*#__PURE__*/React.createElement(Container, {
|
|
462
|
+
alignBox: align === 'vertical' ? 'row' : 'column',
|
|
463
|
+
className: tabsStyle.hidden
|
|
464
|
+
}, renderTabs(children, [], true)), /*#__PURE__*/React.createElement(Container, {
|
|
465
|
+
alignBox: align === 'vertical' ? 'row' : 'column'
|
|
466
|
+
}, renderTabs(mainTabs, moreTabs, false))), otherTabs.length ? /*#__PURE__*/React.createElement(Box, null, otherTabs) : null, isAnimate && needTabBorder && needAppearance && /*#__PURE__*/React.createElement("div", {
|
|
467
|
+
className: hlClass,
|
|
468
|
+
ref: getHighlightRef,
|
|
469
|
+
"data-id": dataId,
|
|
470
|
+
"data-test-id": dataId
|
|
471
|
+
})));
|
|
472
|
+
};
|
|
560
473
|
Tabs.propTypes = Tabs_propTypes;
|
|
561
474
|
Tabs.defaultProps = {
|
|
562
475
|
...Tabs_defaultProps,
|