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