@ringcentral/juno 2.33.0 → 2.35.0
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/components/Presence/styles/StyledPresence.js +3 -3
- package/components/Presence/utils/RcPresenceUtils.js +1 -1
- package/components/Tabs/Tabs/MoreMenuTab/MoreMenuTab.js +4 -5
- package/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabSentinel.d.ts +7 -0
- package/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabSentinel.js +9 -0
- package/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabs.d.ts +0 -1
- package/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabs.js +276 -197
- package/components/Tabs/Tabs/MoreMenuTabs/utils/MoreMenuTabsUtils.d.ts +3 -34
- package/components/Tabs/Tabs/MoreMenuTabs/utils/MoreMenuTabsUtils.js +0 -87
- package/components/Tabs/Tabs/MoreMenuTabs/utils/index.js +0 -2
- package/es6/components/Presence/styles/StyledPresence.js +3 -3
- package/es6/components/Presence/utils/RcPresenceUtils.js +1 -1
- package/es6/components/Tabs/Tabs/MoreMenuTab/MoreMenuTab.js +4 -5
- package/es6/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabSentinel.js +6 -0
- package/es6/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabs.js +278 -199
- package/es6/components/Tabs/Tabs/MoreMenuTabs/utils/MoreMenuTabsUtils.js +0 -87
- package/es6/components/Tabs/Tabs/MoreMenuTabs/utils/index.js +0 -1
- package/es6/foundation/hooks/useDebounce/useDebounce.js +3 -2
- package/es6/foundation/hooks/useOnReRender/useOnReRender.js +6 -3
- package/es6/foundation/hooks/useThrottle/useThrottle.js +4 -3
- package/foundation/hooks/useDebounce/useDebounce.d.ts +3 -2
- package/foundation/hooks/useDebounce/useDebounce.js +3 -2
- package/foundation/hooks/useOnReRender/useOnReRender.d.ts +1 -1
- package/foundation/hooks/useOnReRender/useOnReRender.js +5 -2
- package/foundation/hooks/useThrottle/useThrottle.d.ts +3 -2
- package/foundation/hooks/useThrottle/useThrottle.js +4 -3
- package/package.json +1 -1
|
@@ -1,232 +1,311 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
-
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
|
|
6
4
|
var Tabs_1 = tslib_1.__importDefault(require("@material-ui/core/Tabs"));
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
6
|
var foundation_1 = require("../../../../foundation");
|
|
8
7
|
var MoreMenuTab_1 = require("../MoreMenuTab");
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
var MoreMenuTabSentinel_1 = require("./MoreMenuTabSentinel");
|
|
9
|
+
// with of more button with a icon
|
|
10
|
+
var basicMoreButtonSize = 44;
|
|
11
|
+
var getTabsInfoFromChildren = function (children) {
|
|
12
|
+
var childrenInfo = react_1.default.Children.map(children, function (child, index) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if (react_1.isValidElement(child)) {
|
|
15
|
+
var key = (_a = child.key) !== null && _a !== void 0 ? _a : index;
|
|
16
|
+
return {
|
|
17
|
+
index: index,
|
|
18
|
+
key: key,
|
|
19
|
+
value: (_b = child.props.value) !== null && _b !== void 0 ? _b : key,
|
|
20
|
+
element: child,
|
|
21
|
+
};
|
|
18
22
|
}
|
|
23
|
+
return null;
|
|
19
24
|
});
|
|
20
|
-
|
|
25
|
+
if (!childrenInfo)
|
|
26
|
+
return [];
|
|
27
|
+
return childrenInfo.filter(function (info) { return Boolean(info); });
|
|
21
28
|
};
|
|
22
29
|
var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
|
|
23
|
-
var orientation = props.orientation, childrenProp = props.children,
|
|
30
|
+
var orientation = props.orientation, childrenProp = props.children, value = props.value, onChange = props.onChange, _a = props.MoreButtonProps, MoreButtonProps = _a === void 0 ? {} : _a, _b = props.resizeThrottleTime, resizeThrottleTime = _b === void 0 ? 100 : _b, rest = tslib_1.__rest(props, ["orientation", "children", "value", "onChange", "MoreButtonProps", "resizeThrottleTime"]);
|
|
24
31
|
var onGroupInfoChange = MoreButtonProps.onGroupInfoChange, MoreButtonPropsRest = tslib_1.__rest(MoreButtonProps, ["onGroupInfoChange"]);
|
|
25
|
-
var prevChildrenProp = foundation_1.usePrevious(function () { return childrenProp; });
|
|
26
32
|
var isVertical = orientation === 'vertical';
|
|
27
|
-
var
|
|
33
|
+
var sizeKey = isVertical ? 'offsetHeight' : 'offsetWidth';
|
|
28
34
|
var innerRef = react_1.useRef(null);
|
|
29
35
|
var moreTabRef = react_1.useRef(null);
|
|
36
|
+
var sentinelStartRef = react_1.useRef(null);
|
|
30
37
|
var tabsRef = foundation_1.useForkRef(innerRef, ref);
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var sizeChange = function (size) {
|
|
42
|
-
hasResizeRef.current = true;
|
|
43
|
-
if (tabsSizeRef.current.height !== size.height ||
|
|
44
|
-
tabsSizeRef.current.width !== size.width) {
|
|
45
|
-
tabsSizeRef.current = size;
|
|
46
|
-
forceUpdate();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var throttleTabsSizeChange = foundation_1.useThrottle(sizeChange, resizeThrottleTime);
|
|
50
|
-
foundation_1.useResizeObserver(innerRef, function (_a) {
|
|
51
|
-
var _b = tslib_1.__read(_a, 1), entry = _b[0];
|
|
52
|
-
var _c = entry.contentRect, width = _c.width, height = _c.height;
|
|
53
|
-
var obj = { width: width, height: height };
|
|
54
|
-
throttleTabsSizeChange(obj);
|
|
55
|
-
}, { mode: 'none' });
|
|
56
|
-
var tabsSize = tabsSizeRef.current;
|
|
57
|
-
// initial tabRefsMapRef and tabsTabChildRef
|
|
58
|
-
if (tabRefsMapRef.current === undefined ||
|
|
59
|
-
prevChildrenProp !== childrenProp) {
|
|
60
|
-
var tabRefs_1 = new Map();
|
|
61
|
-
var tabsTabDefaultChild_1 = [];
|
|
62
|
-
react_1.default.Children.forEach(childrenProp, function (child, index) {
|
|
63
|
-
var _a = child.props, ref = _a.ref, value = _a.value;
|
|
64
|
-
var innerRef = react_1.createRef();
|
|
65
|
-
var tabRef = ref ? foundation_1.useForkRef(innerRef, ref) : innerRef;
|
|
66
|
-
var childrenValue = value || index;
|
|
67
|
-
var children = react_1.default.cloneElement(child, {
|
|
68
|
-
ref: tabRef,
|
|
69
|
-
value: childrenValue,
|
|
70
|
-
});
|
|
71
|
-
var keyString = typeof child.key === 'string' ? child.key : '';
|
|
72
|
-
tabRefs_1.set(utils_1.getKey(keyString, index), {
|
|
73
|
-
ref: tabRef,
|
|
74
|
-
size: null,
|
|
75
|
-
index: index,
|
|
76
|
-
value: childrenValue,
|
|
77
|
-
});
|
|
78
|
-
tabsTabDefaultChild_1.push(children);
|
|
79
|
-
});
|
|
80
|
-
tabRefsMapRef.current = tabRefs_1;
|
|
81
|
-
tabsTabChildRef.current = tabsTabDefaultChild_1;
|
|
82
|
-
}
|
|
83
|
-
var updateAllTabsSize = function () {
|
|
84
|
-
var tabRefsMap = tabRefsMapRef.current;
|
|
85
|
-
var allTabsSize = tslib_1.__assign({}, utils_1.DEFAULT_SIZE);
|
|
86
|
-
if (tabRefsMap && tabRefsMap.size !== 0) {
|
|
87
|
-
tabRefsMap.forEach(function (value, key) {
|
|
88
|
-
var _a = utils_1.getDomBoundingClientSize(value.ref.current), width = _a.width, height = _a.height;
|
|
89
|
-
allTabsSize.width += width;
|
|
90
|
-
allTabsSize.height += height;
|
|
91
|
-
var newRef = {
|
|
92
|
-
ref: value.ref,
|
|
93
|
-
size: { width: width, height: height },
|
|
94
|
-
index: value.index,
|
|
95
|
-
value: value.value,
|
|
96
|
-
};
|
|
97
|
-
tabRefsMap.set(key, newRef);
|
|
98
|
-
});
|
|
99
|
-
allTabsSizeRef.current = allTabsSize;
|
|
38
|
+
var _c = foundation_1.useRcPortalWindowContext().externalWindow, externalWindow = _c === void 0 ? window : _c;
|
|
39
|
+
var mountStateRef = foundation_1.useMountState();
|
|
40
|
+
var _d = tslib_1.__read(react_1.useState(function () {
|
|
41
|
+
var tabsInfo = getTabsInfoFromChildren(childrenProp);
|
|
42
|
+
if (!tabsInfo) {
|
|
43
|
+
return {
|
|
44
|
+
all: [],
|
|
45
|
+
tab: [],
|
|
46
|
+
menu: [],
|
|
47
|
+
};
|
|
100
48
|
}
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
49
|
+
return {
|
|
50
|
+
all: tabsInfo,
|
|
51
|
+
tab: tabsInfo,
|
|
52
|
+
menu: [],
|
|
53
|
+
};
|
|
54
|
+
}), 2), groupInfo = _d[0], setGroupInfo = _d[1];
|
|
55
|
+
var throttleCalculateGroupInfo = foundation_1.useThrottle(function () {
|
|
56
|
+
var e_1, _a;
|
|
57
|
+
var _b;
|
|
58
|
+
var tablist = (_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[role="tablist"]');
|
|
59
|
+
if (!tablist)
|
|
106
60
|
return;
|
|
61
|
+
var allTabs = Array.from(tablist.children);
|
|
62
|
+
var allTabsSize = [];
|
|
63
|
+
var selectedIndex = groupInfo.all.findIndex(function (info) { return info.value === value; });
|
|
64
|
+
var tablistSize = tablist[sizeKey];
|
|
65
|
+
var moreButtonSize = basicMoreButtonSize;
|
|
66
|
+
var allTabsSizeSumWidthoutMoreButton = 0;
|
|
67
|
+
try {
|
|
68
|
+
for (var allTabs_1 = tslib_1.__values(allTabs), allTabs_1_1 = allTabs_1.next(); !allTabs_1_1.done; allTabs_1_1 = allTabs_1.next()) {
|
|
69
|
+
var tabEl = allTabs_1_1.value;
|
|
70
|
+
if (typeof tabEl.dataset['tabOriginIndex'] === 'string') {
|
|
71
|
+
var tabOriginIndex = Number(tabEl.dataset['tabOriginIndex']);
|
|
72
|
+
var elSize = tabEl[sizeKey];
|
|
73
|
+
allTabsSize[tabOriginIndex] = elSize;
|
|
74
|
+
allTabsSizeSumWidthoutMoreButton += elSize;
|
|
75
|
+
}
|
|
76
|
+
else if (typeof tabEl.dataset['tabMoreButton'] === 'string') {
|
|
77
|
+
var elSize = tabEl[sizeKey];
|
|
78
|
+
moreButtonSize = elSize;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
107
81
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
82
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (allTabs_1_1 && !allTabs_1_1.done && (_a = allTabs_1.return)) _a.call(allTabs_1);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e_1) throw e_1.error; }
|
|
113
88
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
89
|
+
var newGroupInfo = {
|
|
90
|
+
all: groupInfo.all,
|
|
91
|
+
tab: [],
|
|
92
|
+
menu: [],
|
|
93
|
+
};
|
|
94
|
+
if (allTabsSizeSumWidthoutMoreButton > tablistSize) {
|
|
95
|
+
var allTabsSizeSum = allTabsSizeSumWidthoutMoreButton + moreButtonSize;
|
|
96
|
+
var targetSize = allTabsSizeSum;
|
|
97
|
+
for (var i = allTabsSize.length - 1; i >= 0; i--) {
|
|
98
|
+
if (i !== selectedIndex) {
|
|
99
|
+
targetSize -= allTabsSize[i];
|
|
100
|
+
newGroupInfo.menu.unshift(groupInfo.all[i]);
|
|
101
|
+
if (targetSize <= tablistSize) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
newGroupInfo.tab = groupInfo.all.filter(function (info) { return !newGroupInfo.menu.some(function (_a) {
|
|
107
|
+
var index = _a.index;
|
|
108
|
+
return index === info.index;
|
|
109
|
+
}); });
|
|
124
110
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
else {
|
|
112
|
+
newGroupInfo.tab = newGroupInfo.all;
|
|
113
|
+
}
|
|
114
|
+
var shouldUpdateGroupInfo = false;
|
|
115
|
+
if (newGroupInfo.tab.length === groupInfo.tab.length &&
|
|
116
|
+
newGroupInfo.tab.length === groupInfo.tab.length) {
|
|
117
|
+
for (var i = 0; i < groupInfo.tab.length; i++) {
|
|
118
|
+
if (newGroupInfo.tab[i] !== groupInfo.tab[i]) {
|
|
119
|
+
shouldUpdateGroupInfo = true;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
136
122
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
shouldUpdateGroupInfo = true;
|
|
126
|
+
}
|
|
127
|
+
if (shouldUpdateGroupInfo) {
|
|
128
|
+
// prevent resize observer loop limit exceeded
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
if (mountStateRef.current)
|
|
131
|
+
setGroupInfo(newGroupInfo);
|
|
132
|
+
}, 0);
|
|
133
|
+
}
|
|
134
|
+
}, resizeThrottleTime);
|
|
135
|
+
react_1.useEffect(function () {
|
|
136
|
+
var e_2, _a;
|
|
137
|
+
var _b;
|
|
138
|
+
var tablist = (_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[role="tablist"]');
|
|
139
|
+
if (!tablist)
|
|
140
|
+
return;
|
|
141
|
+
var resizeObserver = foundation_1.getResizeObserver(throttleCalculateGroupInfo, externalWindow);
|
|
142
|
+
resizeObserver.observe(tablist);
|
|
143
|
+
try {
|
|
144
|
+
for (var _c = tslib_1.__values(Array.from(tablist.children)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
145
|
+
var tabItem = _d.value;
|
|
146
|
+
resizeObserver.observe(tabItem,
|
|
147
|
+
// TODO: remove this, after remove ResizeObserver polyfill
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
{ box: 'border-box' });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
153
|
+
finally {
|
|
154
|
+
try {
|
|
155
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
141
156
|
}
|
|
142
|
-
if (
|
|
143
|
-
|
|
157
|
+
finally { if (e_2) throw e_2.error; }
|
|
158
|
+
}
|
|
159
|
+
var mutationObserver = new externalWindow.MutationObserver(function (mutations) {
|
|
160
|
+
var e_3, _a;
|
|
161
|
+
try {
|
|
162
|
+
for (var mutations_1 = tslib_1.__values(mutations), mutations_1_1 = mutations_1.next(); !mutations_1_1.done; mutations_1_1 = mutations_1.next()) {
|
|
163
|
+
var mutation = mutations_1_1.value;
|
|
164
|
+
if (mutation.type === 'childList') {
|
|
165
|
+
mutation.removedNodes.forEach(function (removedNode) {
|
|
166
|
+
if (removedNode.getAttribute('role') === 'tab') {
|
|
167
|
+
resizeObserver.unobserve(removedNode);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
mutation.addedNodes.forEach(function (addedNode) {
|
|
171
|
+
if (addedNode.getAttribute('role') === 'tab') {
|
|
172
|
+
resizeObserver.observe(addedNode,
|
|
173
|
+
// TODO: remove this, after remove ResizeObserver polyfill
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
{ box: 'border-box' });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
// should re-calculate group info when dom is removed and not added
|
|
179
|
+
if (mutation.removedNodes.length && !mutation.addedNodes.length) {
|
|
180
|
+
setTimeout(function () {
|
|
181
|
+
if (mountStateRef.current)
|
|
182
|
+
throttleCalculateGroupInfo();
|
|
183
|
+
}, 0);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
144
187
|
}
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
189
|
+
finally {
|
|
190
|
+
try {
|
|
191
|
+
if (mutations_1_1 && !mutations_1_1.done && (_a = mutations_1.return)) _a.call(mutations_1);
|
|
192
|
+
}
|
|
193
|
+
finally { if (e_3) throw e_3.error; }
|
|
147
194
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
size: value.size ? value.size[oriStr] : 0,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
var limitSize = tabsSizeRef.current[oriStr] - moreTabSizeRef.current[oriStr];
|
|
159
|
-
var _a = utils_1.computeChildBySize(labelArray, currSelectTabItem === null || currSelectTabItem === void 0 ? void 0 : currSelectTabItem[0], limitSize), tabsTabLabel = _a.plainArr, menuTabLabel = _a.groupArr;
|
|
160
|
-
computeGroupingInfo(tabsTabLabel, menuTabLabel);
|
|
161
|
-
var tabsTabChild = tabsTabLabel.map(function (key) {
|
|
162
|
-
return exports.findChildrenByKey(childrenProp, key);
|
|
163
|
-
});
|
|
164
|
-
var menuTabChild = menuTabLabel.map(function (key) {
|
|
165
|
-
return exports.findChildrenByKey(childrenProp, key);
|
|
166
|
-
});
|
|
167
|
-
tabsTabChildRef.current = tabsTabChild;
|
|
168
|
-
setMenuTabChild(menuTabChild);
|
|
195
|
+
});
|
|
196
|
+
mutationObserver.observe(tablist, {
|
|
197
|
+
childList: true,
|
|
198
|
+
});
|
|
199
|
+
return function () {
|
|
200
|
+
resizeObserver.disconnect();
|
|
201
|
+
mutationObserver.disconnect();
|
|
169
202
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
204
|
+
}, []);
|
|
205
|
+
// No need calculate during the first rendering,
|
|
206
|
+
// resize observer will do this
|
|
207
|
+
foundation_1.useOnReRender(function () {
|
|
208
|
+
throttleCalculateGroupInfo();
|
|
209
|
+
}, [value], false);
|
|
210
|
+
foundation_1.useOnReRender(function () {
|
|
211
|
+
var e_4, _a;
|
|
212
|
+
var tabsInfo = getTabsInfoFromChildren(childrenProp);
|
|
213
|
+
var newGroupInfo = {
|
|
214
|
+
all: tabsInfo,
|
|
215
|
+
tab: [],
|
|
216
|
+
menu: [],
|
|
181
217
|
};
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
218
|
+
var _loop_1 = function (tabInfo) {
|
|
219
|
+
if (groupInfo.tab.some(function (_a) {
|
|
220
|
+
var key = _a.key;
|
|
221
|
+
return tabInfo.key === key;
|
|
222
|
+
})) {
|
|
223
|
+
newGroupInfo.tab.push(tabInfo);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// push new tab or invisible old tab to menu group
|
|
227
|
+
newGroupInfo.menu.push(tabInfo);
|
|
190
228
|
}
|
|
191
229
|
};
|
|
192
|
-
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
prevChildrenProp === childrenProp) {
|
|
198
|
-
return;
|
|
230
|
+
try {
|
|
231
|
+
// Prevent moreButton from flickering after children update
|
|
232
|
+
for (var tabsInfo_1 = tslib_1.__values(tabsInfo), tabsInfo_1_1 = tabsInfo_1.next(); !tabsInfo_1_1.done; tabsInfo_1_1 = tabsInfo_1.next()) {
|
|
233
|
+
var tabInfo = tabsInfo_1_1.value;
|
|
234
|
+
_loop_1(tabInfo);
|
|
199
235
|
}
|
|
200
|
-
// can't use tabsSize
|
|
201
|
-
// It is possible that the children prop render effect will execute before the sizeChange effect
|
|
202
|
-
// which get a old tabsSize value
|
|
203
|
-
computeTabChild(tabsSizeRef.current);
|
|
204
|
-
hasResizeRef.current = false;
|
|
205
236
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
]);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
237
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
238
|
+
finally {
|
|
239
|
+
try {
|
|
240
|
+
if (tabsInfo_1_1 && !tabsInfo_1_1.done && (_a = tabsInfo_1.return)) _a.call(tabsInfo_1);
|
|
241
|
+
}
|
|
242
|
+
finally { if (e_4) throw e_4.error; }
|
|
243
|
+
}
|
|
244
|
+
setGroupInfo(newGroupInfo);
|
|
245
|
+
}, [childrenProp], false);
|
|
246
|
+
react_1.useEffect(function () {
|
|
247
|
+
onGroupInfoChange === null || onGroupInfoChange === void 0 ? void 0 : onGroupInfoChange([
|
|
248
|
+
groupInfo.tab.map(function (_a) {
|
|
249
|
+
var index = _a.index, key = _a.key;
|
|
250
|
+
return ({ index: index, key: key });
|
|
251
|
+
}),
|
|
252
|
+
groupInfo.menu.map(function (_a) {
|
|
253
|
+
var index = _a.index, key = _a.key;
|
|
254
|
+
return ({ index: index, key: key });
|
|
255
|
+
}),
|
|
256
|
+
]);
|
|
257
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
258
|
+
}, [groupInfo]); // ignore onGroupInfoChange
|
|
259
|
+
var useMoreMode = groupInfo.menu.length > 0;
|
|
260
|
+
var MoreMenuTabCmp = (function () {
|
|
261
|
+
if (!useMoreMode)
|
|
262
|
+
return null;
|
|
263
|
+
var menuItems = groupInfo.menu.map(function (_a) {
|
|
264
|
+
var key = _a.key, element = _a.element;
|
|
265
|
+
return tslib_1.__assign(tslib_1.__assign({}, element.props), { key: key });
|
|
218
266
|
});
|
|
219
267
|
return useMoreMode ? (react_1.default.createElement(MoreMenuTab_1.MoreMenuTab, tslib_1.__assign({}, MoreButtonPropsRest, { key: MoreMenuTab_1.DEFAULT_MORE_MENU_TAB_LABEL, size: rest.size, menuItems: menuItems, ref: moreTabRef, onChange: onChange, orientation: orientation }))) : null;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
268
|
+
})();
|
|
269
|
+
var children = (function () {
|
|
270
|
+
var tabGroupElements = groupInfo.tab.map(function (_a) {
|
|
271
|
+
var index = _a.index, key = _a.key, tabValue = _a.value, element = _a.element;
|
|
272
|
+
return react_1.cloneElement(element, {
|
|
273
|
+
key: key,
|
|
274
|
+
value: tabValue,
|
|
275
|
+
'data-tab-origin-index': index,
|
|
276
|
+
'data-tab-key': key,
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
if (!useMoreMode)
|
|
280
|
+
return tabGroupElements;
|
|
281
|
+
return tslib_1.__spread(tabGroupElements, [
|
|
282
|
+
react_1.default.createElement(MoreMenuTabSentinel_1.MoreMenuTabSentinel, { id: "start", value: "sentinel-start", key: "sentinel-start", ref: sentinelStartRef, onFocus: function () {
|
|
283
|
+
var _a;
|
|
284
|
+
(_a = moreTabRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
285
|
+
} })
|
|
286
|
+
], groupInfo.menu.map(function (_a) {
|
|
287
|
+
var index = _a.index, key = _a.key, tabValue = _a.value, element = _a.element;
|
|
288
|
+
return react_1.cloneElement(element, {
|
|
289
|
+
key: key,
|
|
290
|
+
value: tabValue,
|
|
291
|
+
'data-tab-origin-index': index,
|
|
292
|
+
'data-tab-key': key,
|
|
293
|
+
'aria-hidden': true,
|
|
294
|
+
disabled: true,
|
|
295
|
+
style: tslib_1.__assign(tslib_1.__assign({}, element.props.style), { opacity: 0, position: 'absolute', top: 0, left: 0 }),
|
|
296
|
+
});
|
|
297
|
+
}), [
|
|
298
|
+
react_1.default.createElement(MoreMenuTabSentinel_1.MoreMenuTabSentinel, { id: "end", value: "sentinel-end", key: "sentinel-end", onFocus: function () {
|
|
299
|
+
var _a;
|
|
300
|
+
var focusTarget = ((_a = sentinelStartRef.current) === null || _a === void 0 ? void 0 : _a.previousElementSibling) ||
|
|
301
|
+
moreTabRef.current;
|
|
302
|
+
if (focusTarget)
|
|
303
|
+
focusTarget.focus();
|
|
304
|
+
} }),
|
|
305
|
+
]);
|
|
306
|
+
})();
|
|
307
|
+
return (react_1.default.createElement(Tabs_1.default, tslib_1.__assign({}, rest, { ref: tabsRef, value: value, variant: "standard", indicatorColor: "primary", textColor: "primary", onChange: onChange, orientation: orientation }),
|
|
308
|
+
children,
|
|
230
309
|
MoreMenuTabCmp));
|
|
231
310
|
});
|
|
232
311
|
/** inner component */
|
|
@@ -1,36 +1,5 @@
|
|
|
1
|
-
export declare const DEFAULT_SIZE: {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
};
|
|
5
|
-
export declare const computeChildBySize: (labelArray: {
|
|
6
|
-
key: string;
|
|
7
|
-
size: number;
|
|
8
|
-
}[], fixLabel: string | undefined, limitSize: number) => {
|
|
9
|
-
plainArr: string[];
|
|
10
|
-
groupArr: string[];
|
|
11
|
-
};
|
|
12
|
-
export declare const getDomBoundingClientSize: (dom: HTMLElement | null) => {
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param keyProp React.key
|
|
19
|
-
* @param idx string
|
|
20
|
-
* @example
|
|
21
|
-
* getKey('tab_0', 0) => childIdx_0_propKey_tab_0
|
|
22
|
-
* getKey(undefined, 1) => childIdx_1
|
|
23
|
-
*/
|
|
24
|
-
export declare const getKey: (keyProp?: string | number | undefined, idx?: number | undefined) => string;
|
|
25
1
|
export declare type GroupTabInfoType = {
|
|
26
|
-
index
|
|
27
|
-
key
|
|
2
|
+
index: number;
|
|
3
|
+
key: string | number;
|
|
28
4
|
};
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* parseKey(childIdx_1) => { index: 1 }
|
|
33
|
-
* parseKey(childIdx_1_propKey_tab_1) => { index: 1, key: tab_1 }
|
|
34
|
-
*/
|
|
35
|
-
export declare const parseKey: (key: string) => GroupTabInfoType;
|
|
36
|
-
export declare type RcTabsMoreMenuGroupInfoType = GroupTabInfoType[][];
|
|
5
|
+
export declare type RcTabsMoreMenuGroupInfoType = [GroupTabInfoType[], GroupTabInfoType[]];
|
|
@@ -1,89 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SIZE = {
|
|
4
|
-
width: 0,
|
|
5
|
-
height: 0,
|
|
6
|
-
};
|
|
7
|
-
exports.computeChildBySize = function (labelArray, fixLabel, limitSize) {
|
|
8
|
-
var plainArr = [];
|
|
9
|
-
var groupArr = [];
|
|
10
|
-
var sumSize = 0;
|
|
11
|
-
var groupFlag = false;
|
|
12
|
-
labelArray.forEach(function (_label) {
|
|
13
|
-
var label = _label.key, size = _label.size;
|
|
14
|
-
if (groupFlag === false && sumSize + size < limitSize) {
|
|
15
|
-
sumSize += size;
|
|
16
|
-
plainArr.push(label);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
groupFlag = true;
|
|
20
|
-
groupArr.push(label);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
if (fixLabel && groupArr.includes(fixLabel)) {
|
|
24
|
-
plainArr = [];
|
|
25
|
-
groupArr = [];
|
|
26
|
-
var fixLabelSize_1 = 0;
|
|
27
|
-
labelArray.forEach(function (_label) {
|
|
28
|
-
var label = _label.key, size = _label.size;
|
|
29
|
-
if (label === fixLabel) {
|
|
30
|
-
fixLabelSize_1 = size;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
var sumFixSize_1 = 0;
|
|
34
|
-
var groupFlag_1 = false;
|
|
35
|
-
labelArray.forEach(function (_label) {
|
|
36
|
-
var label = _label.key, size = _label.size;
|
|
37
|
-
if (label === fixLabel) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (groupFlag_1 === false && sumFixSize_1 + size < limitSize - fixLabelSize_1) {
|
|
41
|
-
sumFixSize_1 += size;
|
|
42
|
-
plainArr.push(label);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
groupFlag_1 = true;
|
|
46
|
-
groupArr.push(label);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
plainArr.push(fixLabel);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
plainArr: plainArr,
|
|
53
|
-
groupArr: groupArr,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.getDomBoundingClientSize = function (dom) {
|
|
57
|
-
if (!dom || dom.nodeType !== 1) {
|
|
58
|
-
return exports.DEFAULT_SIZE;
|
|
59
|
-
}
|
|
60
|
-
var _a = dom.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
61
|
-
return {
|
|
62
|
-
width: width,
|
|
63
|
-
height: height,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param keyProp React.key
|
|
69
|
-
* @param idx string
|
|
70
|
-
* @example
|
|
71
|
-
* getKey('tab_0', 0) => childIdx_0_propKey_tab_0
|
|
72
|
-
* getKey(undefined, 1) => childIdx_1
|
|
73
|
-
*/
|
|
74
|
-
exports.getKey = function (keyProp, idx) {
|
|
75
|
-
return "childIdx_" + idx + (keyProp ? "_propKey_" + keyProp : '');
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* parseKey(childIdx_1) => { index: 1 }
|
|
81
|
-
* parseKey(childIdx_1_propKey_tab_1) => { index: 1, key: tab_1 }
|
|
82
|
-
*/
|
|
83
|
-
exports.parseKey = function (key) {
|
|
84
|
-
var match = /^(?:childIdx_)(\d+)(?:_propKey_)?(.*)/gi.exec(key);
|
|
85
|
-
return {
|
|
86
|
-
index: match === null || match === void 0 ? void 0 : match[1],
|
|
87
|
-
key: match === null || match === void 0 ? void 0 : match[2].replace(/^\.\$/i, ''),
|
|
88
|
-
};
|
|
89
|
-
};
|