@kne/system-layout 0.2.0-alpha.16 → 0.2.0-alpha.20
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/README.md +719 -207
- package/dist/{index-b1c94af4.js → index-0c46f1c7.js} +1 -1
- package/dist/{index-b1c94af4.js.map → index-0c46f1c7.js.map} +1 -1
- package/dist/index.css +170 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +644 -411
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +568 -378
- package/dist/index.modern.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var react = require('react');
|
|
2
|
+
var reactDom = require('react-dom');
|
|
2
3
|
var antd = require('antd');
|
|
3
4
|
var classnames = require('classnames');
|
|
4
5
|
var localStorage = require('@kne/local-storage');
|
|
@@ -8,13 +9,13 @@ var reactRouterDom = require('react-router-dom');
|
|
|
8
9
|
var Icon = require('@kne/react-icon');
|
|
9
10
|
var ensureSlash = require('@kne/ensure-slash');
|
|
10
11
|
var isPlainObject = require('lodash/isPlainObject');
|
|
11
|
-
var
|
|
12
|
+
var VirtualList = require('rc-virtual-list');
|
|
13
|
+
var responsiveUtils = require('@kne/responsive-utils');
|
|
12
14
|
var defaultLogo = require('./defaultLogo~beHinxEU.svg');
|
|
13
15
|
var expand_bdCTnjYJ_svg = require('./expand~bdCTnjYJ.svg');
|
|
14
16
|
var ReactErrorBoundary = require('@kne/react-error-boundary');
|
|
15
17
|
var reactIntl = require('@kne/react-intl');
|
|
16
18
|
var SimpleBar = require('simplebar-react');
|
|
17
|
-
var throttle = require('lodash/throttle');
|
|
18
19
|
require('simplebar-react/dist/simplebar.min.css');
|
|
19
20
|
var ButtonGroup = require('@kne/button-group');
|
|
20
21
|
var merge = require('lodash/merge');
|
|
@@ -27,10 +28,10 @@ var localStorage__default = /*#__PURE__*/_interopDefaultLegacy(localStorage);
|
|
|
27
28
|
var Icon__default = /*#__PURE__*/_interopDefaultLegacy(Icon);
|
|
28
29
|
var ensureSlash__default = /*#__PURE__*/_interopDefaultLegacy(ensureSlash);
|
|
29
30
|
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
|
|
31
|
+
var VirtualList__default = /*#__PURE__*/_interopDefaultLegacy(VirtualList);
|
|
30
32
|
var defaultLogo__default = /*#__PURE__*/_interopDefaultLegacy(defaultLogo);
|
|
31
33
|
var ReactErrorBoundary__default = /*#__PURE__*/_interopDefaultLegacy(ReactErrorBoundary);
|
|
32
34
|
var SimpleBar__default = /*#__PURE__*/_interopDefaultLegacy(SimpleBar);
|
|
33
|
-
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
34
35
|
var ButtonGroup__default = /*#__PURE__*/_interopDefaultLegacy(ButtonGroup);
|
|
35
36
|
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
36
37
|
var transform__default = /*#__PURE__*/_interopDefaultLegacy(transform);
|
|
@@ -45,7 +46,7 @@ function _extends() {
|
|
|
45
46
|
}, _extends.apply(null, arguments);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
var style$3 = {"layout":"kne-system-layout_sK89O","has-toolbar":"kne-system-layout_gyKfI","has-navbar":"kne-system-layout_X1wZG","menu":"kne-system-layout_-LpWn","open":"kne-system-layout_G-zuN","layer-menu":"kne-system-layout_6TCwG","ai-entry":"kne-system-layout_5qnw5","page":"kne-system-layout_HnwkM","toolbar":"kne-system-layout_h8PAW","page-children":"kne-system-layout_OM1Q2","is-
|
|
49
|
+
var style$3 = {"kne-responsive-boundary":"kne-system-layout_VtEb1","kne-responsive-scroll":"kne-system-layout_UMzfg","layout":"kne-system-layout_sK89O","has-toolbar":"kne-system-layout_gyKfI","has-navbar":"kne-system-layout_X1wZG","menu":"kne-system-layout_-LpWn","open":"kne-system-layout_G-zuN","layer-menu":"kne-system-layout_6TCwG","ai-entry":"kne-system-layout_5qnw5","page":"kne-system-layout_HnwkM","page-content":"kne-system-layout_nyAa2","toolbar":"kne-system-layout_h8PAW","page-children":"kne-system-layout_OM1Q2","is-scroller":"kne-system-layout_6gjkS","is-mobile":"kne-system-layout_udBgQ","logo":"kne-system-layout_-T-Dc","menu-header":"kne-system-layout_LOrmu","menu-boundary-overlay":"kne-system-layout_-cMpV","is-portaled":"kne-system-layout_leFsD","logo-img":"kne-system-layout_2cRWf","expand-btn-wrapper":"kne-system-layout_5D-Oq","expand-btn-bg":"kne-system-layout_p4eOE","expand-btn":"kne-system-layout_8dzE7","menu-inner":"kne-system-layout_7wq3X","menu-list":"kne-system-layout_8gqbZ","username":"kne-system-layout_b7XeQ","user-description":"kne-system-layout_U0YTk","ai-dialog-window":"kne-system-layout_UAJc-","pulse-dialog-window":"kne-system-layout_VjIWn","page-dialog-outer":"kne-system-layout_I7Anv","page-dialog":"kne-system-layout_UhsFd","pulse-page-dialog":"kne-system-layout_H7slV","page-window-content":"kne-system-layout_2mdNn","ai-dialog-window-title":"kne-system-layout_33Tja","ai-dialog-window-content":"kne-system-layout_YmBhl"};
|
|
49
50
|
|
|
50
51
|
const UserCard = ({
|
|
51
52
|
name,
|
|
@@ -87,8 +88,12 @@ const UserCard = ({
|
|
|
87
88
|
});
|
|
88
89
|
};
|
|
89
90
|
|
|
90
|
-
var style$2 = {"menu-group":"kne-system-layout_Rfzv4","menu-item-icon":"kne-system-layout_qoDtD","menu-group-split":"kne-system-layout_socoO","menu-item":"kne-system-layout_Xa-2h"};
|
|
91
|
+
var style$2 = {"menu-list":"kne-system-layout_dVWvr","menu-group":"kne-system-layout_Rfzv4","menu-item-icon":"kne-system-layout_qoDtD","menu-group-split":"kne-system-layout_socoO","menu-item":"kne-system-layout_Xa-2h"};
|
|
91
92
|
|
|
93
|
+
const MENU_ITEM_HEIGHT = 52;
|
|
94
|
+
const MENU_GROUP_HEIGHT = 48;
|
|
95
|
+
const MENU_GROUP_SPLIT_HEIGHT = 17;
|
|
96
|
+
const getItemKey = (item, index) => item.key || item.path || index;
|
|
92
97
|
const Menu = ({
|
|
93
98
|
className,
|
|
94
99
|
menuOpen,
|
|
@@ -99,94 +104,169 @@ const Menu = ({
|
|
|
99
104
|
}) => {
|
|
100
105
|
const location = reactRouterDom.useLocation();
|
|
101
106
|
const navigate = reactRouterDom.useNavigate();
|
|
107
|
+
const listRef = react.useRef(null);
|
|
108
|
+
const virtualListRef = react.useRef(null);
|
|
109
|
+
const [listHeight, setListHeight] = react.useState(0);
|
|
102
110
|
const currentPathname = base ? location.pathname.replace(new RegExp(`^${base}`), '') : location.pathname;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
const isItemActive = react.useCallback(item => {
|
|
112
|
+
if (typeof activeKey === 'string') {
|
|
113
|
+
return activeKey === item.key;
|
|
114
|
+
}
|
|
115
|
+
if (typeof activeKey === 'function') {
|
|
116
|
+
return activeKey(item, {
|
|
117
|
+
menuOpen,
|
|
118
|
+
base
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (typeof item.path === 'string') {
|
|
122
|
+
return ensureSlash__default["default"](currentPathname) === ensureSlash__default["default"](item.path);
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}, [activeKey, base, currentPathname, menuOpen]);
|
|
126
|
+
const getEstimatedItemHeight = react.useCallback((item, index) => {
|
|
127
|
+
const hasGroup = item.group && item.group !== items[index - 1]?.group;
|
|
128
|
+
if (!hasGroup) {
|
|
129
|
+
return MENU_ITEM_HEIGHT;
|
|
130
|
+
}
|
|
131
|
+
return MENU_ITEM_HEIGHT + (menuOpen ? MENU_GROUP_HEIGHT : MENU_GROUP_SPLIT_HEIGHT);
|
|
132
|
+
}, [items, menuOpen]);
|
|
133
|
+
const estimatedItemHeight = react.useMemo(() => {
|
|
134
|
+
if (!items.length) {
|
|
135
|
+
return MENU_ITEM_HEIGHT;
|
|
136
|
+
}
|
|
137
|
+
const total = items.reduce((sum, item, index) => sum + getEstimatedItemHeight(item, index), 0);
|
|
138
|
+
return Math.max(MENU_ITEM_HEIGHT, Math.ceil(total / items.length));
|
|
139
|
+
}, [getEstimatedItemHeight, items]);
|
|
140
|
+
const listData = react.useMemo(() => items.map((item, index) => ({
|
|
141
|
+
item,
|
|
142
|
+
index,
|
|
143
|
+
key: getItemKey(item, index)
|
|
144
|
+
})), [items]);
|
|
145
|
+
const activeIndex = react.useMemo(() => listData.findIndex(({
|
|
146
|
+
item
|
|
147
|
+
}) => isItemActive(item)), [isItemActive, listData]);
|
|
148
|
+
react.useLayoutEffect(() => {
|
|
149
|
+
const el = listRef.current;
|
|
150
|
+
if (!el) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const updateHeight = () => {
|
|
154
|
+
const styles = getComputedStyle(el);
|
|
155
|
+
const paddingY = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom);
|
|
156
|
+
setListHeight(el.clientHeight - paddingY);
|
|
157
|
+
};
|
|
158
|
+
updateHeight();
|
|
159
|
+
const observer = new ResizeObserver(updateHeight);
|
|
160
|
+
observer.observe(el);
|
|
161
|
+
return () => observer.disconnect();
|
|
162
|
+
}, []);
|
|
163
|
+
react.useLayoutEffect(() => {
|
|
164
|
+
if (activeIndex < 0 || listHeight <= 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
virtualListRef.current?.scrollTo({
|
|
168
|
+
index: activeIndex,
|
|
169
|
+
align: 'auto'
|
|
170
|
+
});
|
|
171
|
+
}, [activeIndex, listHeight, menuOpen, listData.length]);
|
|
172
|
+
const renderMenuItem = (item, index) => {
|
|
173
|
+
const active = isItemActive(item);
|
|
174
|
+
const icon = typeof item.icon === 'function' ? item.icon({
|
|
175
|
+
menuOpen,
|
|
176
|
+
active
|
|
177
|
+
}) : item.icon;
|
|
178
|
+
const hasGroup = item.group && item.group !== items[index - 1]?.group;
|
|
179
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
180
|
+
title: item.label,
|
|
181
|
+
onClick: e => {
|
|
182
|
+
if (active) {
|
|
183
|
+
return;
|
|
109
184
|
}
|
|
110
|
-
|
|
111
|
-
|
|
185
|
+
onChange && onChange(item, {
|
|
186
|
+
menuOpen,
|
|
187
|
+
base
|
|
188
|
+
});
|
|
189
|
+
if (typeof item.onClick === 'function') {
|
|
190
|
+
item.onClick(item, {
|
|
112
191
|
menuOpen,
|
|
113
|
-
base
|
|
192
|
+
base,
|
|
193
|
+
event: e
|
|
114
194
|
});
|
|
195
|
+
return;
|
|
115
196
|
}
|
|
116
|
-
if (
|
|
117
|
-
|
|
197
|
+
if (item.path) {
|
|
198
|
+
navigate(ensureSlash__default["default"](`${base}${item.path}`));
|
|
118
199
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
200
|
+
},
|
|
201
|
+
children: [hasGroup && menuOpen ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
202
|
+
className: classnames__default["default"]('menu-group', style$2['menu-group']),
|
|
203
|
+
children: item.groupLabel || item.group
|
|
204
|
+
}) : null, hasGroup && !menuOpen ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
205
|
+
className: classnames__default["default"]('menu-group-split', style$2['menu-group-split'])
|
|
206
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
207
|
+
className: classnames__default["default"]('menu-item', style$2['menu-item'], {
|
|
208
|
+
['is-active']: active,
|
|
209
|
+
['is-closed']: !menuOpen
|
|
210
|
+
}),
|
|
211
|
+
align: "center",
|
|
212
|
+
gap: 8,
|
|
213
|
+
children: [(icon => {
|
|
214
|
+
if (typeof icon === 'string') {
|
|
215
|
+
return /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
216
|
+
className: classnames__default["default"]('menu-item-icon', style$2['menu-item-icon']),
|
|
217
|
+
type: icon,
|
|
218
|
+
fontClassName: "system"
|
|
219
|
+
});
|
|
131
220
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (typeof item.onClick === 'function') {
|
|
137
|
-
item.onClick(item, {
|
|
138
|
-
menuOpen,
|
|
139
|
-
base,
|
|
140
|
-
event: e
|
|
221
|
+
if (/*#__PURE__*/react.isValidElement(icon)) {
|
|
222
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
223
|
+
className: classnames__default["default"]('menu-item-icon', style$2['menu-item-icon']),
|
|
224
|
+
children: icon
|
|
141
225
|
});
|
|
142
|
-
return;
|
|
143
226
|
}
|
|
144
|
-
if (
|
|
145
|
-
|
|
227
|
+
if (isPlainObject__default["default"](icon) && typeof icon.type === 'string') {
|
|
228
|
+
return /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
229
|
+
...icon,
|
|
230
|
+
className: classnames__default["default"]('menu-item-icon', style$2['menu-item-icon'])
|
|
231
|
+
});
|
|
146
232
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
if (/*#__PURE__*/react.isValidElement(icon)) {
|
|
169
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
170
|
-
className: classnames__default["default"]('menu-item-icon', style$2['menu-item-icon']),
|
|
171
|
-
children: icon
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (isPlainObject__default["default"](icon) && typeof icon.type === 'string') {
|
|
175
|
-
return /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
176
|
-
...icon,
|
|
177
|
-
className: classnames__default["default"]('menu-item-icon', style$2['menu-item-icon'])
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return null;
|
|
181
|
-
})(icon), menuOpen && item.label]
|
|
182
|
-
})]
|
|
183
|
-
}, item.key || item.path || index);
|
|
184
|
-
})
|
|
233
|
+
return null;
|
|
234
|
+
})(icon), menuOpen && item.label]
|
|
235
|
+
})]
|
|
236
|
+
}, getItemKey(item, index));
|
|
237
|
+
};
|
|
238
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
239
|
+
ref: listRef,
|
|
240
|
+
className: classnames__default["default"]('menu', className, style$2['menu-list']),
|
|
241
|
+
children: listHeight > 0 ? /*#__PURE__*/jsxRuntime.jsx(VirtualList__default["default"], {
|
|
242
|
+
ref: virtualListRef,
|
|
243
|
+
data: listData,
|
|
244
|
+
height: listHeight,
|
|
245
|
+
itemHeight: estimatedItemHeight,
|
|
246
|
+
itemKey: "key",
|
|
247
|
+
virtual: listData.length > 0,
|
|
248
|
+
children: ({
|
|
249
|
+
item,
|
|
250
|
+
index
|
|
251
|
+
}) => renderMenuItem(item, index)
|
|
252
|
+
}) : null
|
|
185
253
|
});
|
|
186
254
|
};
|
|
187
255
|
|
|
188
|
-
var style$1 = {"toolbar":"kne-system-layout_SLK-0","toolbar-list":"kne-system-layout_GTQvM","toolbar-item":"kne-system-layout_fAZ3n","toolbar-item-icon":"kne-system-layout_qOB9o","is-hidden":"kne-system-layout_ss5zk","toolbar-item-label":"kne-system-layout_h48es","toolbar-indicator":"kne-system-layout_1s-bc","toolbar-click":"kne-system-layout_Ys3yu"};
|
|
256
|
+
var style$1 = {"toolbar":"kne-system-layout_SLK-0","toolbar-inline":"kne-system-layout_RgKpk","toolbar-boundary-overlay":"kne-system-layout_VEMgn","toolbar-list":"kne-system-layout_GTQvM","is-viewport":"kne-system-layout_c6f0m","is-boundary":"kne-system-layout_3ctCY","toolbar-item":"kne-system-layout_fAZ3n","toolbar-item-icon":"kne-system-layout_qOB9o","is-hidden":"kne-system-layout_ss5zk","toolbar-item-label":"kne-system-layout_h48es","toolbar-indicator":"kne-system-layout_1s-bc","toolbar-click":"kne-system-layout_Ys3yu"};
|
|
189
257
|
|
|
258
|
+
const context = /*#__PURE__*/react.createContext({});
|
|
259
|
+
const useContext = () => {
|
|
260
|
+
return react.useContext(context);
|
|
261
|
+
};
|
|
262
|
+
const Provider = context.Provider;
|
|
263
|
+
|
|
264
|
+
const resolveTarget = target => {
|
|
265
|
+
if (!target) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
return typeof target === 'function' ? target() : target;
|
|
269
|
+
};
|
|
190
270
|
const Toolbar = ({
|
|
191
271
|
show = true,
|
|
192
272
|
className,
|
|
@@ -198,6 +278,15 @@ const Toolbar = ({
|
|
|
198
278
|
}) => {
|
|
199
279
|
const location = reactRouterDom.useLocation();
|
|
200
280
|
const navigate = reactRouterDom.useNavigate();
|
|
281
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
282
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
283
|
+
const {
|
|
284
|
+
mode
|
|
285
|
+
} = responsiveUtils.useResponsiveContext();
|
|
286
|
+
const isMobile = responsiveUtils.useIsMobile();
|
|
287
|
+
const {
|
|
288
|
+
scrollReady
|
|
289
|
+
} = useContext();
|
|
201
290
|
const currentPathname = base ? location.pathname.replace(new RegExp(`^${base}`), '') : location.pathname;
|
|
202
291
|
const toolbarMenu = items.filter(item => item.toolbar);
|
|
203
292
|
const itemRefs = react.useRef([]);
|
|
@@ -227,6 +316,10 @@ const Toolbar = ({
|
|
|
227
316
|
});
|
|
228
317
|
const displayIndex = activeIndex >= 0 ? activeIndex : 0;
|
|
229
318
|
const listRef = react.useRef(null);
|
|
319
|
+
const explicitTarget = resolveTarget(target);
|
|
320
|
+
const useBoundaryMount = isMobile && mode === 'container' && !explicitTarget;
|
|
321
|
+
const useViewportFixed = isMobile && mode !== 'container' && !explicitTarget;
|
|
322
|
+
const boundaryTarget = useBoundaryMount ? getBoundaryElement() : null;
|
|
230
323
|
react.useLayoutEffect(() => {
|
|
231
324
|
if (activeIndex < 0) {
|
|
232
325
|
return;
|
|
@@ -250,14 +343,10 @@ const Toolbar = ({
|
|
|
250
343
|
});
|
|
251
344
|
return;
|
|
252
345
|
}
|
|
253
|
-
|
|
254
|
-
// Phase 1: scale up
|
|
255
346
|
setIndicator(prev => ({
|
|
256
347
|
...prev,
|
|
257
348
|
scale: 1.15
|
|
258
349
|
}));
|
|
259
|
-
|
|
260
|
-
// Phase 2: move
|
|
261
350
|
const t1 = setTimeout(() => {
|
|
262
351
|
setIndicator(prev => ({
|
|
263
352
|
...prev,
|
|
@@ -265,8 +354,6 @@ const Toolbar = ({
|
|
|
265
354
|
width: newWidth
|
|
266
355
|
}));
|
|
267
356
|
}, 120);
|
|
268
|
-
|
|
269
|
-
// Phase 3: scale down
|
|
270
357
|
const t2 = setTimeout(() => {
|
|
271
358
|
setIndicator(prev => ({
|
|
272
359
|
...prev,
|
|
@@ -277,10 +364,10 @@ const Toolbar = ({
|
|
|
277
364
|
clearTimeout(t1);
|
|
278
365
|
clearTimeout(t2);
|
|
279
366
|
};
|
|
280
|
-
}, [activeIndex, show, target]);
|
|
281
|
-
const resolvedTarget = target ? typeof target === 'function' ? target() : target : null;
|
|
367
|
+
}, [activeIndex, show, target, useBoundaryMount, useViewportFixed]);
|
|
282
368
|
react.useEffect(() => {
|
|
283
|
-
|
|
369
|
+
const scrollEl = getScrollElement();
|
|
370
|
+
if (!scrollEl || typeof scrollEl.addEventListener !== 'function') {
|
|
284
371
|
return;
|
|
285
372
|
}
|
|
286
373
|
const handleScroll = () => {
|
|
@@ -292,115 +379,128 @@ const Toolbar = ({
|
|
|
292
379
|
setScrolling(false);
|
|
293
380
|
}, 500);
|
|
294
381
|
};
|
|
295
|
-
|
|
382
|
+
scrollEl.addEventListener('scroll', handleScroll, {
|
|
296
383
|
passive: true
|
|
297
384
|
});
|
|
298
|
-
document.addEventListener('scroll', handleScroll, {
|
|
299
|
-
passive: true,
|
|
300
|
-
capture: true
|
|
301
|
-
});
|
|
302
385
|
return () => {
|
|
303
|
-
|
|
304
|
-
document.removeEventListener('scroll', handleScroll, {
|
|
305
|
-
capture: true
|
|
306
|
-
});
|
|
386
|
+
scrollEl.removeEventListener('scroll', handleScroll);
|
|
307
387
|
if (scrollTimerRef.current) {
|
|
308
388
|
clearTimeout(scrollTimerRef.current);
|
|
309
389
|
}
|
|
310
390
|
};
|
|
311
|
-
}, [
|
|
391
|
+
}, [getScrollElement, show, scrollReady]);
|
|
312
392
|
if (!show) {
|
|
313
393
|
return null;
|
|
314
394
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
395
|
+
const toolbarList = /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
396
|
+
ref: listRef,
|
|
397
|
+
className: classnames__default["default"]('toolbar-list', style$1['toolbar-list'], {
|
|
398
|
+
['is-clicked']: clicked,
|
|
399
|
+
['is-scrolling']: scrolling,
|
|
400
|
+
[style$1['is-boundary']]: useBoundaryMount,
|
|
401
|
+
[style$1['is-viewport']]: useViewportFixed
|
|
402
|
+
}),
|
|
403
|
+
style: {
|
|
404
|
+
'--toolbar-count': toolbarMenu.length || 1
|
|
405
|
+
},
|
|
406
|
+
onAnimationEnd: () => {
|
|
407
|
+
if (clicked) {
|
|
408
|
+
setClicked(false);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
children: [indicator.visible && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
412
|
+
className: classnames__default["default"]('toolbar-indicator', style$1['toolbar-indicator']),
|
|
323
413
|
style: {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
setClicked(true);
|
|
360
|
-
onChange && onChange(item, {
|
|
361
|
-
base
|
|
414
|
+
left: `${indicator.left}px`,
|
|
415
|
+
width: `${indicator.width}px`,
|
|
416
|
+
transform: `scale(${indicator.scale})`
|
|
417
|
+
}
|
|
418
|
+
}), toolbarMenu.map((item, index) => {
|
|
419
|
+
const active = index === activeIndex;
|
|
420
|
+
const icon = typeof item.icon === 'function' ? item.icon({
|
|
421
|
+
active
|
|
422
|
+
}) : item.icon;
|
|
423
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
424
|
+
ref: el => {
|
|
425
|
+
itemRefs.current[index] = el;
|
|
426
|
+
},
|
|
427
|
+
vertical: true,
|
|
428
|
+
flex: 1,
|
|
429
|
+
justify: "center",
|
|
430
|
+
align: "center",
|
|
431
|
+
className: classnames__default["default"]('toolbar-item', style$1['toolbar-item'], {
|
|
432
|
+
['is-active']: active,
|
|
433
|
+
[style$1['is-hidden']]: scrolling && index !== displayIndex
|
|
434
|
+
}),
|
|
435
|
+
onClick: e => {
|
|
436
|
+
if (active) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
setClicked(true);
|
|
440
|
+
onChange && onChange(item, {
|
|
441
|
+
base
|
|
442
|
+
});
|
|
443
|
+
if (typeof item.onClick === 'function') {
|
|
444
|
+
item.onClick(item, {
|
|
445
|
+
base,
|
|
446
|
+
event: e
|
|
362
447
|
});
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
})(icon), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
397
|
-
className: classnames__default["default"]('toolbar-item-label', style$1['toolbar-item-label']),
|
|
398
|
-
children: item.label
|
|
399
|
-
})]
|
|
400
|
-
}, item.key || item.path || index);
|
|
401
|
-
})]
|
|
402
|
-
}), resolvedTarget || document.body)
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (item.path) {
|
|
451
|
+
navigate(ensureSlash__default["default"](`${base}${item.path}`));
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
children: [(icon => {
|
|
455
|
+
if (typeof icon === 'string') {
|
|
456
|
+
return /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
457
|
+
className: classnames__default["default"]('toolbar-item-icon', style$1['toolbar-item-icon']),
|
|
458
|
+
type: icon,
|
|
459
|
+
fontClassName: "system"
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
if (/*#__PURE__*/react.isValidElement(icon)) {
|
|
463
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
464
|
+
className: classnames__default["default"]('toolbar-item-icon', style$1['toolbar-item-icon']),
|
|
465
|
+
children: icon
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
if (isPlainObject__default["default"](icon) && typeof icon.type === 'string') {
|
|
469
|
+
return /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
470
|
+
...icon,
|
|
471
|
+
className: classnames__default["default"]('toolbar-item-icon', style$1['toolbar-item-icon'])
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return null;
|
|
475
|
+
})(icon), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
476
|
+
className: classnames__default["default"]('toolbar-item-label', style$1['toolbar-item-label']),
|
|
477
|
+
children: item.label
|
|
478
|
+
})]
|
|
479
|
+
}, item.key || item.path || index);
|
|
480
|
+
})]
|
|
403
481
|
});
|
|
482
|
+
if (useBoundaryMount && boundaryTarget) {
|
|
483
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
484
|
+
className: classnames__default["default"]('toolbar', style$1['toolbar'], className),
|
|
485
|
+
children: /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
486
|
+
className: classnames__default["default"]('toolbar-boundary-overlay', style$1['toolbar-boundary-overlay']),
|
|
487
|
+
children: toolbarList
|
|
488
|
+
}), boundaryTarget)
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
if (useViewportFixed) {
|
|
492
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
493
|
+
className: classnames__default["default"]('toolbar', style$1['toolbar'], style$1['toolbar-inline'], className),
|
|
494
|
+
children: toolbarList
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
if (explicitTarget) {
|
|
498
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
499
|
+
className: classnames__default["default"]('toolbar', style$1['toolbar'], className),
|
|
500
|
+
children: /*#__PURE__*/reactDom.createPortal(toolbarList, explicitTarget)
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
404
504
|
};
|
|
405
505
|
|
|
406
506
|
const locale$1 = {
|
|
@@ -449,66 +549,90 @@ const ErrorBoundary = props => {
|
|
|
449
549
|
});
|
|
450
550
|
};
|
|
451
551
|
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
return react.useContext(context);
|
|
552
|
+
const hasParentResponsiveProvider = parent => {
|
|
553
|
+
return parent.getBoundaryElement !== responsiveUtils.defaultResponsiveContextValue.getBoundaryElement || parent.getScrollElement !== responsiveUtils.defaultResponsiveContextValue.getScrollElement;
|
|
455
554
|
};
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
|
|
555
|
+
const resolvePageScrollElement = (pageScrollRef, openScrollbar, deviceIsMobile) => {
|
|
556
|
+
if (deviceIsMobile && !openScrollbar) {
|
|
557
|
+
const anchor = pageScrollRef.current;
|
|
558
|
+
if (anchor && anchor.parentElement) {
|
|
559
|
+
const parentScroll = responsiveUtils.findResponsiveScroll(anchor.parentElement);
|
|
560
|
+
if (parentScroll) {
|
|
561
|
+
return parentScroll;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return responsiveUtils.getDefaultScrollElement();
|
|
565
|
+
}
|
|
566
|
+
const anchor = pageScrollRef.current;
|
|
567
|
+
if (anchor && typeof anchor.getScrollElement === 'function') {
|
|
568
|
+
return anchor.getScrollElement();
|
|
569
|
+
}
|
|
570
|
+
if (anchor && anchor.nodeType === 1 && openScrollbar) {
|
|
571
|
+
const wrapper = anchor.querySelector('.simplebar-content-wrapper');
|
|
572
|
+
if (wrapper) {
|
|
573
|
+
return wrapper;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return responsiveUtils.findResponsiveScroll(anchor) || responsiveUtils.getDefaultScrollElement();
|
|
460
577
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
578
|
+
const LayoutResponsiveScope = _ref => {
|
|
579
|
+
let boundaryRef = _ref.boundaryRef,
|
|
580
|
+
scrollRef = _ref.scrollRef,
|
|
581
|
+
getScrollElement = _ref.getScrollElement,
|
|
582
|
+
children = _ref.children;
|
|
583
|
+
const parent = responsiveUtils.useResponsiveContext();
|
|
584
|
+
if (hasParentResponsiveProvider(parent)) {
|
|
585
|
+
return children;
|
|
586
|
+
}
|
|
587
|
+
return /*#__PURE__*/jsxRuntime.jsx(responsiveUtils.ResponsiveProvider, {
|
|
588
|
+
boundaryRef: boundaryRef,
|
|
589
|
+
scrollRef: scrollRef,
|
|
590
|
+
getScrollElement: getScrollElement,
|
|
591
|
+
children: children
|
|
592
|
+
});
|
|
476
593
|
};
|
|
477
|
-
|
|
478
594
|
const LayoutMenuOpenKey = 'LAYOUT_MENU_OPEN';
|
|
479
|
-
const Layout =
|
|
480
|
-
let className =
|
|
481
|
-
menu =
|
|
482
|
-
|
|
483
|
-
background =
|
|
484
|
-
|
|
485
|
-
menuMaxWidth =
|
|
486
|
-
|
|
487
|
-
menuMinWidth =
|
|
488
|
-
logo =
|
|
489
|
-
menuHeader =
|
|
490
|
-
userInfo =
|
|
491
|
-
|
|
492
|
-
aiDialog =
|
|
493
|
-
openScrollbarProps =
|
|
494
|
-
isMobileProps =
|
|
495
|
-
toolbarTarget =
|
|
496
|
-
children =
|
|
595
|
+
const Layout = _ref2 => {
|
|
596
|
+
let className = _ref2.className,
|
|
597
|
+
menu = _ref2.menu,
|
|
598
|
+
_ref2$background = _ref2.background,
|
|
599
|
+
background = _ref2$background === void 0 ? 'linear-gradient(0deg, #BBCFE7 0%, #BBCFE7 100%), #FFFFFF' : _ref2$background,
|
|
600
|
+
_ref2$menuMaxWidth = _ref2.menuMaxWidth,
|
|
601
|
+
menuMaxWidth = _ref2$menuMaxWidth === void 0 ? '254px' : _ref2$menuMaxWidth,
|
|
602
|
+
_ref2$menuMinWidth = _ref2.menuMinWidth,
|
|
603
|
+
menuMinWidth = _ref2$menuMinWidth === void 0 ? '84px' : _ref2$menuMinWidth,
|
|
604
|
+
logo = _ref2.logo,
|
|
605
|
+
menuHeader = _ref2.menuHeader,
|
|
606
|
+
userInfo = _ref2.userInfo,
|
|
607
|
+
_ref2$aiDialog = _ref2.aiDialog,
|
|
608
|
+
aiDialog = _ref2$aiDialog === void 0 ? null : _ref2$aiDialog,
|
|
609
|
+
openScrollbarProps = _ref2.openScrollbar,
|
|
610
|
+
isMobileProps = _ref2.isMobile,
|
|
611
|
+
toolbarTarget = _ref2.toolbarTarget,
|
|
612
|
+
children = _ref2.children;
|
|
497
613
|
const localMenuOpen = localStorage__default["default"].getItem(LayoutMenuOpenKey);
|
|
498
|
-
const isMobile = useIsMobile();
|
|
614
|
+
const isMobile = responsiveUtils.useIsMobile();
|
|
615
|
+
const responsiveContext = responsiveUtils.useResponsiveContext();
|
|
499
616
|
const deviceIsMobile = typeof isMobileProps === 'boolean' ? isMobileProps : isMobile;
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
617
|
+
const useMenuPortal = deviceIsMobile && responsiveContext.mode === 'container';
|
|
618
|
+
const _useState = react.useState(null),
|
|
619
|
+
menuPortalTarget = _useState[0],
|
|
620
|
+
setMenuPortalTarget = _useState[1];
|
|
621
|
+
const _useState2 = react.useState(typeof localMenuOpen === 'boolean' && !deviceIsMobile ? localMenuOpen : !deviceIsMobile),
|
|
622
|
+
menuOpen = _useState2[0],
|
|
623
|
+
setMenuOpen = _useState2[1];
|
|
506
624
|
const _useState3 = react.useState(true),
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const _useState4 = react.useState(
|
|
510
|
-
|
|
511
|
-
|
|
625
|
+
toolbarShow = _useState3[0],
|
|
626
|
+
setToolbarShow = _useState3[1];
|
|
627
|
+
const _useState4 = react.useState(true),
|
|
628
|
+
navbarShow = _useState4[0],
|
|
629
|
+
setNavbarShow = _useState4[1];
|
|
630
|
+
const _useState5 = react.useState('closed'),
|
|
631
|
+
aiType = _useState5[0],
|
|
632
|
+
setAiType = _useState5[1];
|
|
633
|
+
const _useState6 = react.useState(0),
|
|
634
|
+
scrollReady = _useState6[0],
|
|
635
|
+
setScrollReady = _useState6[1];
|
|
512
636
|
const openScrollbar = typeof openScrollbarProps === 'boolean' ? openScrollbarProps : !deviceIsMobile && !window.__COMPONENTS_CORE_SIMPLE_BAR_DISABLED;
|
|
513
637
|
const userAvatar = userInfo == null ? void 0 : userInfo.avatar;
|
|
514
638
|
const contextValue = react.useMemo(() => {
|
|
@@ -517,196 +641,245 @@ const Layout = _ref => {
|
|
|
517
641
|
setNavbarShow,
|
|
518
642
|
setMenuOpen,
|
|
519
643
|
deviceIsMobile,
|
|
644
|
+
scrollReady,
|
|
520
645
|
logo: Object.assign({}, logo ? logo : {
|
|
521
646
|
src: defaultLogo__default["default"]
|
|
522
647
|
}),
|
|
523
648
|
userAvatar
|
|
524
649
|
};
|
|
525
|
-
}, [deviceIsMobile, logo, userAvatar]);
|
|
650
|
+
}, [deviceIsMobile, logo, userAvatar, scrollReady]);
|
|
526
651
|
const topRef = react.useRef(null);
|
|
527
652
|
const pageRef = react.useRef(null);
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
setComputedToolbarTarget = _useState5[1];
|
|
653
|
+
const layoutBoundaryRef = react.useRef(null);
|
|
654
|
+
const pageScrollRef = react.useRef(null);
|
|
531
655
|
const location = reactRouterDom.useLocation();
|
|
532
|
-
react.
|
|
533
|
-
|
|
534
|
-
|
|
656
|
+
const getPageScrollElement = react.useCallback(() => {
|
|
657
|
+
return resolvePageScrollElement(pageScrollRef, openScrollbar, deviceIsMobile);
|
|
658
|
+
}, [openScrollbar, deviceIsMobile]);
|
|
659
|
+
const handlePageScrollRef = react.useCallback(node => {
|
|
660
|
+
pageScrollRef.current = node;
|
|
661
|
+
if (node) {
|
|
662
|
+
setScrollReady(version => version + 1);
|
|
663
|
+
}
|
|
664
|
+
}, []);
|
|
665
|
+
react.useEffect(() => {
|
|
666
|
+
if (!useMenuPortal) {
|
|
667
|
+
setMenuPortalTarget(null);
|
|
668
|
+
return;
|
|
535
669
|
}
|
|
536
|
-
|
|
670
|
+
const target = typeof responsiveContext.getBoundaryElement === 'function' ? responsiveContext.getBoundaryElement() : null;
|
|
671
|
+
setMenuPortalTarget(target || null);
|
|
672
|
+
}, [useMenuPortal, responsiveContext, scrollReady]);
|
|
537
673
|
react.useEffect(() => {
|
|
538
|
-
|
|
539
|
-
|
|
674
|
+
var _topRef$current;
|
|
675
|
+
const scrollEl = getPageScrollElement();
|
|
676
|
+
if (scrollEl && typeof scrollEl.scrollTo === 'function') {
|
|
677
|
+
scrollEl.scrollTo(0, 0);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
(_topRef$current = topRef.current) == null || _topRef$current.scrollIntoView();
|
|
681
|
+
}, [location, getPageScrollElement]);
|
|
540
682
|
const userCard = /*#__PURE__*/jsxRuntime.jsx(UserCard, _extends({
|
|
541
683
|
menuOpen: menuOpen
|
|
542
684
|
}, Object.assign({}, userInfo)));
|
|
543
|
-
|
|
544
|
-
|
|
685
|
+
const menuPortalVars = useMenuPortal ? {
|
|
686
|
+
'--menu-max-width': menuMaxWidth,
|
|
687
|
+
'--menu-min-width': menuMinWidth,
|
|
688
|
+
'--background': background
|
|
689
|
+
} : undefined;
|
|
690
|
+
const layerMenuNode = deviceIsMobile ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
691
|
+
className: classnames__default["default"]('layer-menu', style$3['layer-menu'], {
|
|
692
|
+
['open']: menuOpen,
|
|
693
|
+
[style$3['open']]: menuOpen,
|
|
694
|
+
[style$3['is-portaled']]: useMenuPortal
|
|
695
|
+
}),
|
|
696
|
+
style: menuPortalVars,
|
|
697
|
+
onClick: () => {
|
|
698
|
+
setMenuOpen(false);
|
|
699
|
+
}
|
|
700
|
+
}) : null;
|
|
701
|
+
const menuNode = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
702
|
+
className: classnames__default["default"]('menu', style$3['menu'], {
|
|
703
|
+
['open']: menuOpen,
|
|
704
|
+
[style$3['open']]: menuOpen,
|
|
705
|
+
[style$3['is-portaled']]: useMenuPortal
|
|
706
|
+
}),
|
|
707
|
+
style: menuPortalVars,
|
|
545
708
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
'--menu-max-width': menuMaxWidth,
|
|
558
|
-
'--menu-min-width': menuMinWidth,
|
|
559
|
-
'--background': background
|
|
709
|
+
className: classnames__default["default"]('logo', style$3['logo']),
|
|
710
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactFile.Image, _extends({
|
|
711
|
+
className: style$3['logo-img']
|
|
712
|
+
}, contextValue.logo))
|
|
713
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
714
|
+
className: classnames__default["default"]('expand-btn-wrapper', style$3['expand-btn-wrapper']),
|
|
715
|
+
onClick: () => {
|
|
716
|
+
setMenuOpen(menuOpen => {
|
|
717
|
+
localStorage__default["default"].setItem(LayoutMenuOpenKey, !menuOpen);
|
|
718
|
+
return !menuOpen;
|
|
719
|
+
});
|
|
560
720
|
},
|
|
561
|
-
children:
|
|
562
|
-
className: classnames__default["default"]('
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
721
|
+
children: /*#__PURE__*/jsxRuntime.jsx(expand_bdCTnjYJ_svg.ReactComponent, {
|
|
722
|
+
className: classnames__default["default"]('expand-btn', style$3['expand-btn'], {
|
|
723
|
+
'is-closed': !menuOpen
|
|
724
|
+
})
|
|
725
|
+
})
|
|
726
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
727
|
+
className: classnames__default["default"]('menu-inner', style$3['menu-inner']),
|
|
728
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
729
|
+
className: classnames__default["default"]('menu-header', style$3['menu-header']),
|
|
730
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
731
|
+
children: menuHeader ? typeof menuHeader === 'function' ? menuHeader({
|
|
732
|
+
menuOpen,
|
|
733
|
+
userCard
|
|
734
|
+
}) : menuHeader : userCard
|
|
735
|
+
})
|
|
736
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
737
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Menu, _extends({
|
|
738
|
+
className: classnames__default["default"]('menu-list', style$3['menu-list']),
|
|
739
|
+
menuOpen: menuOpen
|
|
740
|
+
}, menu, {
|
|
741
|
+
onChange: () => {
|
|
742
|
+
deviceIsMobile && setMenuOpen(false);
|
|
743
|
+
}
|
|
744
|
+
}))
|
|
745
|
+
}), aiDialog && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
746
|
+
className: classnames__default["default"]('ai-entry', style$3['ai-entry']),
|
|
566
747
|
onClick: () => {
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
className: "btn",
|
|
642
|
-
type: "icon-a-Typeclose",
|
|
643
|
-
fontClassName: "system",
|
|
644
|
-
onClick: () => {
|
|
645
|
-
setAiType('closed');
|
|
646
|
-
}
|
|
748
|
+
setAiType('small');
|
|
749
|
+
},
|
|
750
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
751
|
+
type: "system-prompt",
|
|
752
|
+
colorful: true
|
|
753
|
+
})
|
|
754
|
+
})]
|
|
755
|
+
})]
|
|
756
|
+
});
|
|
757
|
+
const portalMenu = useMenuPortal && menuPortalTarget;
|
|
758
|
+
return /*#__PURE__*/jsxRuntime.jsx(LayoutResponsiveScope, {
|
|
759
|
+
boundaryRef: layoutBoundaryRef,
|
|
760
|
+
scrollRef: pageScrollRef,
|
|
761
|
+
getScrollElement: getPageScrollElement,
|
|
762
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(Provider, {
|
|
763
|
+
value: contextValue,
|
|
764
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
765
|
+
ref: topRef
|
|
766
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
767
|
+
ref: layoutBoundaryRef,
|
|
768
|
+
className: classnames__default["default"](className, 'layout', style$3['layout'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, {
|
|
769
|
+
'is-mobile': deviceIsMobile,
|
|
770
|
+
[style$3['is-mobile']]: deviceIsMobile,
|
|
771
|
+
'has-toolbar': deviceIsMobile && toolbarShow,
|
|
772
|
+
[style$3['has-toolbar']]: deviceIsMobile && toolbarShow,
|
|
773
|
+
'has-navbar': deviceIsMobile && navbarShow,
|
|
774
|
+
[style$3['has-navbar']]: deviceIsMobile && navbarShow
|
|
775
|
+
}),
|
|
776
|
+
style: {
|
|
777
|
+
'--menu-max-width': menuMaxWidth,
|
|
778
|
+
'--menu-min-width': menuMinWidth,
|
|
779
|
+
'--background': background
|
|
780
|
+
},
|
|
781
|
+
children: [!portalMenu && layerMenuNode, /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
782
|
+
style: {
|
|
783
|
+
flex: 1,
|
|
784
|
+
minHeight: 0,
|
|
785
|
+
width: '100%',
|
|
786
|
+
height: 0
|
|
787
|
+
},
|
|
788
|
+
children: [!portalMenu && menuNode, portalMenu && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
789
|
+
className: classnames__default["default"](style$3['menu-boundary-overlay']),
|
|
790
|
+
style: menuPortalVars,
|
|
791
|
+
children: [layerMenuNode, menuNode]
|
|
792
|
+
}), menuPortalTarget), /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
|
|
793
|
+
flex: 1,
|
|
794
|
+
ref: pageRef,
|
|
795
|
+
className: classnames__default["default"]('page', style$3['page']),
|
|
796
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
|
|
797
|
+
className: classnames__default["default"]('page-content', style$3['page-content']),
|
|
798
|
+
children: [!deviceIsMobile && aiDialog && aiType === 'inner' && /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
799
|
+
span: 8,
|
|
800
|
+
className: classnames__default["default"]('page-dialog-outer', style$3['page-dialog-outer']),
|
|
801
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
802
|
+
className: classnames__default["default"]('page-dialog', style$3['page-dialog']),
|
|
803
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
804
|
+
className: classnames__default["default"]('ai-dialog-window-title', style$3['ai-dialog-window-title']),
|
|
805
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
806
|
+
children: aiDialog.title
|
|
807
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
|
|
808
|
+
gap: 10,
|
|
809
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
810
|
+
className: "btn",
|
|
811
|
+
type: "icon-a-Typeclose",
|
|
812
|
+
fontClassName: "system",
|
|
813
|
+
onClick: () => {
|
|
814
|
+
setAiType('closed');
|
|
815
|
+
}
|
|
816
|
+
})
|
|
817
|
+
})]
|
|
818
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
819
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
820
|
+
className: classnames__default["default"]('page-window-content', style$3['page-window-content']),
|
|
821
|
+
children: aiDialog.content
|
|
647
822
|
})
|
|
648
823
|
})]
|
|
649
|
-
})
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
824
|
+
})
|
|
825
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
826
|
+
span: !deviceIsMobile && aiDialog && aiType === 'inner' ? 16 : 24,
|
|
827
|
+
className: responsiveUtils.RESPONSIVE_CONTAINER_CLASS,
|
|
828
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
829
|
+
children: openScrollbar ? /*#__PURE__*/jsxRuntime.jsx(SimpleBar__default["default"], {
|
|
830
|
+
ref: handlePageScrollRef,
|
|
831
|
+
className: classnames__default["default"]('page-children', style$3['page-children'], responsiveUtils.RESPONSIVE_SCROLL_CLASS, {
|
|
832
|
+
['has-left']: aiType === 'inner'
|
|
833
|
+
}),
|
|
834
|
+
children: children
|
|
835
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
836
|
+
ref: handlePageScrollRef,
|
|
837
|
+
className: classnames__default["default"]('page-children', style$3['page-children'], !deviceIsMobile && 'is-scroller', !deviceIsMobile && style$3['is-scroller'], !deviceIsMobile && responsiveUtils.RESPONSIVE_SCROLL_CLASS, {
|
|
838
|
+
['has-left']: aiType === 'inner'
|
|
839
|
+
}),
|
|
840
|
+
children: children
|
|
653
841
|
})
|
|
654
|
-
})]
|
|
655
|
-
})
|
|
656
|
-
}), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
657
|
-
span: !deviceIsMobile && aiDialog && aiType === 'inner' ? 16 : 24,
|
|
658
|
-
children: /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
659
|
-
children: openScrollbar ? /*#__PURE__*/jsxRuntime.jsx(SimpleBar__default["default"], {
|
|
660
|
-
className: classnames__default["default"]('page-children', style$3['page-children'], {
|
|
661
|
-
['has-left']: aiType === 'inner'
|
|
662
|
-
}),
|
|
663
|
-
children: children
|
|
664
|
-
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
665
|
-
className: classnames__default["default"]('page-children', 'is-scroller', style$3['page-children'], style$3['is-scroller'], {
|
|
666
|
-
['has-left']: aiType === 'inner'
|
|
667
|
-
}),
|
|
668
|
-
children: children
|
|
669
842
|
})
|
|
670
|
-
})
|
|
671
|
-
})]
|
|
672
|
-
})
|
|
673
|
-
}), aiDialog && aiType === 'small' && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
674
|
-
className: classnames__default["default"]('ai-dialog-window', style$3['ai-dialog-window']),
|
|
675
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
676
|
-
className: classnames__default["default"]('ai-dialog-window-title', style$3['ai-dialog-window-title']),
|
|
677
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
678
|
-
children: aiDialog.title
|
|
679
|
-
}), /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
680
|
-
gap: 10,
|
|
681
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
682
|
-
className: "btn",
|
|
683
|
-
type: "icon-a-Typeopen_in_full",
|
|
684
|
-
fontClassName: "system",
|
|
685
|
-
onClick: () => {
|
|
686
|
-
setAiType('inner');
|
|
687
|
-
}
|
|
688
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
689
|
-
className: "btn",
|
|
690
|
-
type: "icon-a-Typeclose",
|
|
691
|
-
fontClassName: "system",
|
|
692
|
-
onClick: () => {
|
|
693
|
-
setAiType('closed');
|
|
694
|
-
}
|
|
695
843
|
})]
|
|
696
|
-
})]
|
|
697
|
-
}), /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
698
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
699
|
-
className: classnames__default["default"]('ai-dialog-window-content', style$3['ai-dialog-window-content']),
|
|
700
|
-
children: aiDialog.content
|
|
701
844
|
})
|
|
845
|
+
}), aiDialog && aiType === 'small' && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
846
|
+
className: classnames__default["default"]('ai-dialog-window', style$3['ai-dialog-window']),
|
|
847
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
848
|
+
className: classnames__default["default"]('ai-dialog-window-title', style$3['ai-dialog-window-title']),
|
|
849
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
850
|
+
children: aiDialog.title
|
|
851
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
852
|
+
gap: 10,
|
|
853
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
854
|
+
className: "btn",
|
|
855
|
+
type: "icon-a-Typeopen_in_full",
|
|
856
|
+
fontClassName: "system",
|
|
857
|
+
onClick: () => {
|
|
858
|
+
setAiType('inner');
|
|
859
|
+
}
|
|
860
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Icon__default["default"], {
|
|
861
|
+
className: "btn",
|
|
862
|
+
type: "icon-a-Typeclose",
|
|
863
|
+
fontClassName: "system",
|
|
864
|
+
onClick: () => {
|
|
865
|
+
setAiType('closed');
|
|
866
|
+
}
|
|
867
|
+
})]
|
|
868
|
+
})]
|
|
869
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
870
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
871
|
+
className: classnames__default["default"]('ai-dialog-window-content', style$3['ai-dialog-window-content']),
|
|
872
|
+
children: aiDialog.content
|
|
873
|
+
})
|
|
874
|
+
})]
|
|
702
875
|
})]
|
|
703
|
-
})
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
})
|
|
709
|
-
})
|
|
876
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Toolbar, _extends({}, menu, {
|
|
877
|
+
className: classnames__default["default"](style$3['toolbar']),
|
|
878
|
+
show: deviceIsMobile && toolbarShow,
|
|
879
|
+
target: toolbarTarget
|
|
880
|
+
}))]
|
|
881
|
+
})]
|
|
882
|
+
})
|
|
710
883
|
});
|
|
711
884
|
};
|
|
712
885
|
|
|
@@ -741,8 +914,10 @@ const Page = _ref => {
|
|
|
741
914
|
setNavbarShow = _useContext.setNavbarShow,
|
|
742
915
|
setMenuOpen = _useContext.setMenuOpen,
|
|
743
916
|
deviceIsMobile = _useContext.deviceIsMobile,
|
|
744
|
-
userAvatar = _useContext.userAvatar
|
|
917
|
+
userAvatar = _useContext.userAvatar,
|
|
918
|
+
scrollReady = _useContext.scrollReady;
|
|
745
919
|
const navigate = reactRouterDom.useNavigate();
|
|
920
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
746
921
|
const navbarRef = react.useRef(null);
|
|
747
922
|
const _useState = react.useState(false),
|
|
748
923
|
isScrolled = _useState[0],
|
|
@@ -755,16 +930,20 @@ const Page = _ref => {
|
|
|
755
930
|
if (!deviceIsMobile || !navbar) {
|
|
756
931
|
return;
|
|
757
932
|
}
|
|
933
|
+
const scrollEl = getScrollElement();
|
|
934
|
+
if (!scrollEl || typeof scrollEl.addEventListener !== 'function') {
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
758
937
|
const handleScroll = () => {
|
|
759
938
|
const threshold = navbarRef.current ? navbarRef.current.offsetHeight : 48;
|
|
760
|
-
setIsScrolled(
|
|
939
|
+
setIsScrolled(scrollEl.scrollTop > threshold);
|
|
761
940
|
};
|
|
762
941
|
handleScroll();
|
|
763
|
-
|
|
942
|
+
scrollEl.addEventListener('scroll', handleScroll, {
|
|
764
943
|
passive: true
|
|
765
944
|
});
|
|
766
|
-
return () =>
|
|
767
|
-
}, [deviceIsMobile, navbar]);
|
|
945
|
+
return () => scrollEl.removeEventListener('scroll', handleScroll);
|
|
946
|
+
}, [deviceIsMobile, navbar, getScrollElement, scrollReady]);
|
|
768
947
|
const navbarEl = navbar ? /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
769
948
|
ref: navbarRef,
|
|
770
949
|
justify: "space-between",
|
|
@@ -866,6 +1045,13 @@ const Page = _ref => {
|
|
|
866
1045
|
};
|
|
867
1046
|
Page.PageLoading = PageLoading;
|
|
868
1047
|
|
|
1048
|
+
const isMobile = () => {
|
|
1049
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
return window.matchMedia(responsiveUtils.IS_MOBILE_QUERY).matches;
|
|
1053
|
+
};
|
|
1054
|
+
|
|
869
1055
|
const transparentBgContainer = {
|
|
870
1056
|
colorBgContainer: 'transparent'
|
|
871
1057
|
};
|
|
@@ -876,13 +1062,60 @@ const themeToken = {
|
|
|
876
1062
|
}, {}))
|
|
877
1063
|
};
|
|
878
1064
|
|
|
879
|
-
Promise.resolve().then(function () { return require('./index-
|
|
1065
|
+
Promise.resolve().then(function () { return require('./index-0c46f1c7.js'); });
|
|
880
1066
|
|
|
1067
|
+
Object.defineProperty(exports, 'MOBILE_BREAKPOINT', {
|
|
1068
|
+
enumerable: true,
|
|
1069
|
+
get: function () { return responsiveUtils.MOBILE_BREAKPOINT; }
|
|
1070
|
+
});
|
|
1071
|
+
Object.defineProperty(exports, 'RESPONSIVE_BOUNDARY_CLASS', {
|
|
1072
|
+
enumerable: true,
|
|
1073
|
+
get: function () { return responsiveUtils.RESPONSIVE_BOUNDARY_CLASS; }
|
|
1074
|
+
});
|
|
1075
|
+
Object.defineProperty(exports, 'RESPONSIVE_CONTAINER_CLASS', {
|
|
1076
|
+
enumerable: true,
|
|
1077
|
+
get: function () { return responsiveUtils.RESPONSIVE_CONTAINER_CLASS; }
|
|
1078
|
+
});
|
|
1079
|
+
Object.defineProperty(exports, 'RESPONSIVE_SCROLL_CLASS', {
|
|
1080
|
+
enumerable: true,
|
|
1081
|
+
get: function () { return responsiveUtils.RESPONSIVE_SCROLL_CLASS; }
|
|
1082
|
+
});
|
|
1083
|
+
Object.defineProperty(exports, 'ResponsiveProvider', {
|
|
1084
|
+
enumerable: true,
|
|
1085
|
+
get: function () { return responsiveUtils.ResponsiveProvider; }
|
|
1086
|
+
});
|
|
1087
|
+
Object.defineProperty(exports, 'mobileBreakpoint', {
|
|
1088
|
+
enumerable: true,
|
|
1089
|
+
get: function () { return responsiveUtils.MOBILE_BREAKPOINT; }
|
|
1090
|
+
});
|
|
1091
|
+
Object.defineProperty(exports, 'useBreakpoint', {
|
|
1092
|
+
enumerable: true,
|
|
1093
|
+
get: function () { return responsiveUtils.useBreakpoint; }
|
|
1094
|
+
});
|
|
1095
|
+
Object.defineProperty(exports, 'useIsMobile', {
|
|
1096
|
+
enumerable: true,
|
|
1097
|
+
get: function () { return responsiveUtils.useIsMobile; }
|
|
1098
|
+
});
|
|
1099
|
+
Object.defineProperty(exports, 'useMediaQuery', {
|
|
1100
|
+
enumerable: true,
|
|
1101
|
+
get: function () { return responsiveUtils.useMediaQuery; }
|
|
1102
|
+
});
|
|
1103
|
+
Object.defineProperty(exports, 'usePopupContainer', {
|
|
1104
|
+
enumerable: true,
|
|
1105
|
+
get: function () { return responsiveUtils.usePopupContainer; }
|
|
1106
|
+
});
|
|
1107
|
+
Object.defineProperty(exports, 'useResponsiveContext', {
|
|
1108
|
+
enumerable: true,
|
|
1109
|
+
get: function () { return responsiveUtils.useResponsiveContext; }
|
|
1110
|
+
});
|
|
1111
|
+
Object.defineProperty(exports, 'useScrollElement', {
|
|
1112
|
+
enumerable: true,
|
|
1113
|
+
get: function () { return responsiveUtils.useScrollElement; }
|
|
1114
|
+
});
|
|
881
1115
|
exports.Layout = Layout;
|
|
882
1116
|
exports.Page = Page;
|
|
883
1117
|
exports["default"] = Layout;
|
|
884
1118
|
exports.isMobile = isMobile;
|
|
885
1119
|
exports.themeToken = themeToken;
|
|
886
|
-
exports.useIsMobile = useIsMobile;
|
|
887
1120
|
exports.useLayoutContext = useContext;
|
|
888
1121
|
//# sourceMappingURL=index.js.map
|