@arcblock/ux 2.10.5 → 2.10.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/Header/header.js +1 -1
- package/lib/Header/responsive-header.js +1 -1
- package/lib/Layout/index.js +1 -11
- package/lib/NavMenu/nav-menu.js +18 -6
- package/package.json +5 -5
- package/src/Header/header.jsx +1 -1
- package/src/Header/responsive-header.jsx +1 -1
- package/src/Layout/{index.js → index.jsx} +13 -12
- package/src/NavMenu/nav-menu.jsx +30 -6
- /package/src/Layout/dashboard/{external-link.js → external-link.jsx} +0 -0
- /package/src/Layout/dashboard/{full-page.js → full-page.jsx} +0 -0
- /package/src/Layout/dashboard/{index.js → index.jsx} +0 -0
- /package/src/Layout/dashboard/{sidebar.js → sidebar.jsx} +0 -0
- /package/src/Layout/dashboard-legacy/{header.js → header.jsx} +0 -0
- /package/src/Layout/dashboard-legacy/{index.js → index.jsx} +0 -0
- /package/src/Layout/dashboard-legacy/{sidebar.js → sidebar.jsx} +0 -0
package/lib/Header/header.js
CHANGED
@@ -57,7 +57,7 @@ function ResponsiveHeader({
|
|
57
57
|
htmlOverflowState.changed = true;
|
58
58
|
htmlOverflowState.value = document.documentElement.style.getPropertyValue('overflow');
|
59
59
|
htmlOverflowState.priority = document.documentElement.style.getPropertyPriority('overflow');
|
60
|
-
document.documentElement.style.setProperty('overflow', '
|
60
|
+
document.documentElement.style.setProperty('overflow', 'revert', 'important');
|
61
61
|
} else {
|
62
62
|
clean();
|
63
63
|
}
|
package/lib/Layout/index.js
CHANGED
@@ -1,17 +1,7 @@
|
|
1
1
|
import { useState } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import Helmet from 'react-helmet';
|
4
|
-
import Link from '@mui/material
|
5
|
-
import AppBar from '@mui/material/AppBar';
|
6
|
-
import Container from '@mui/material/Container';
|
7
|
-
import Drawer from '@mui/material/Drawer';
|
8
|
-
import Divider from '@mui/material/Divider';
|
9
|
-
import Toolbar from '@mui/material/Toolbar';
|
10
|
-
import Typography from '@mui/material/Typography';
|
11
|
-
import List from '@mui/material/List';
|
12
|
-
import ListItem from '@mui/material/ListItem';
|
13
|
-
import ListItemText from '@mui/material/ListItemText';
|
14
|
-
import IconButton from '@mui/material/IconButton';
|
4
|
+
import { AppBar, Container, Drawer, Divider, IconButton, Link, List, ListItem, ListItemText, Toolbar, Typography } from '@mui/material';
|
15
5
|
import MenuIcon from '@mui/icons-material/Menu';
|
16
6
|
import Footer from '../Footer';
|
17
7
|
import OpenInWallet from '../Wallet/Open';
|
package/lib/NavMenu/nav-menu.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Children, cloneElement, useEffect, createContext, useContext, useRef, forwardRef } from 'react';
|
1
|
+
import { Children, cloneElement, useEffect, createContext, useContext, useRef, forwardRef, useLayoutEffect } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import clsx from 'clsx';
|
4
4
|
import { MoreHoriz as MoreHorizIcon, ExpandMore as ExpandMoreIcon, Menu as MenuIcon } from '@mui/icons-material';
|
@@ -63,7 +63,7 @@ function NavMenu({
|
|
63
63
|
open,
|
64
64
|
close
|
65
65
|
};
|
66
|
-
}, [currentState, mode, activate, open, close]);
|
66
|
+
}, [currentState.activeId, currentState.hiddenItemCount, currentState.openedIds, mode, activate, open, close]);
|
67
67
|
const navMenuRef = useRef();
|
68
68
|
const itemRefs = useRef([]);
|
69
69
|
const moreIconRef = useRef();
|
@@ -109,9 +109,15 @@ function NavMenu({
|
|
109
109
|
if (newHiddenCount !== currentState.hiddenItemCount) {
|
110
110
|
currentState.hiddenItemCount = newHiddenCount;
|
111
111
|
}
|
112
|
-
}
|
112
|
+
}), {
|
113
113
|
wait: 100
|
114
114
|
});
|
115
|
+
useLayoutEffect(() => {
|
116
|
+
if (mode === 'horizontal') {
|
117
|
+
checkItemsFit();
|
118
|
+
}
|
119
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
120
|
+
}, [containerSize?.width, mode]);
|
115
121
|
useEffect(() => {
|
116
122
|
if (mode === 'horizontal') {
|
117
123
|
checkItemsFit();
|
@@ -143,7 +149,7 @@ function NavMenu({
|
|
143
149
|
itemRefs.current[index] = el;
|
144
150
|
} : undefined,
|
145
151
|
children: item.children.map((childItem, childIndex) => renderItem(childItem, childIndex, false))
|
146
|
-
},
|
152
|
+
}, item.id);
|
147
153
|
}
|
148
154
|
|
149
155
|
// 顶级 Item 组件总是包含 ref
|
@@ -155,7 +161,7 @@ function NavMenu({
|
|
155
161
|
ref: isTopLevel ? el => {
|
156
162
|
itemRefs.current[index] = el;
|
157
163
|
} : undefined
|
158
|
-
},
|
164
|
+
}, item.id);
|
159
165
|
};
|
160
166
|
const content = items ? items?.slice(-currentState.hiddenItemCount).map((item, index) => renderItem(item, index)) : children?.slice(-currentState.hiddenItemCount);
|
161
167
|
const StyledRoot = mode === 'inline' ? InlineStyle : HorizontalStyle;
|
@@ -292,7 +298,13 @@ const Sub = /*#__PURE__*/forwardRef(({
|
|
292
298
|
const isInlineMode = mode === 'inline';
|
293
299
|
// inline mode 时使用 click 事件控制收缩/伸展子菜单
|
294
300
|
const props = isInlineMode ? {
|
295
|
-
onClick: () =>
|
301
|
+
onClick: () => {
|
302
|
+
if (openedIds.includes(id)) {
|
303
|
+
close(id);
|
304
|
+
} else {
|
305
|
+
open(id);
|
306
|
+
}
|
307
|
+
}
|
296
308
|
} : {
|
297
309
|
onMouseEnter: () => open(id),
|
298
310
|
onMouseLeave: () => close(id)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.10.
|
3
|
+
"version": "2.10.6",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -54,12 +54,12 @@
|
|
54
54
|
"react": ">=18.2.0",
|
55
55
|
"react-router-dom": ">=6.22.3"
|
56
56
|
},
|
57
|
-
"gitHead": "
|
57
|
+
"gitHead": "b167099e5491387e6f7cc2d36d8f8a8e56e8f28d",
|
58
58
|
"dependencies": {
|
59
59
|
"@arcblock/did-motif": "^1.1.13",
|
60
|
-
"@arcblock/icons": "^2.10.
|
61
|
-
"@arcblock/nft-display": "^2.10.
|
62
|
-
"@arcblock/react-hooks": "^2.10.
|
60
|
+
"@arcblock/icons": "^2.10.6",
|
61
|
+
"@arcblock/nft-display": "^2.10.6",
|
62
|
+
"@arcblock/react-hooks": "^2.10.6",
|
63
63
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
64
64
|
"@fontsource/inter": "^5.0.16",
|
65
65
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
package/src/Header/header.jsx
CHANGED
@@ -48,7 +48,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
48
48
|
htmlOverflowState.changed = true;
|
49
49
|
htmlOverflowState.value = document.documentElement.style.getPropertyValue('overflow');
|
50
50
|
htmlOverflowState.priority = document.documentElement.style.getPropertyPriority('overflow');
|
51
|
-
document.documentElement.style.setProperty('overflow', '
|
51
|
+
document.documentElement.style.setProperty('overflow', 'revert', 'important');
|
52
52
|
} else {
|
53
53
|
clean();
|
54
54
|
}
|
@@ -1,18 +1,19 @@
|
|
1
1
|
import { useState } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import Helmet from 'react-helmet';
|
4
|
-
import
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
import {
|
5
|
+
AppBar,
|
6
|
+
Container,
|
7
|
+
Drawer,
|
8
|
+
Divider,
|
9
|
+
IconButton,
|
10
|
+
Link,
|
11
|
+
List,
|
12
|
+
ListItem,
|
13
|
+
ListItemText,
|
14
|
+
Toolbar,
|
15
|
+
Typography,
|
16
|
+
} from '@mui/material';
|
16
17
|
import MenuIcon from '@mui/icons-material/Menu';
|
17
18
|
|
18
19
|
import Footer from '../Footer';
|
package/src/NavMenu/nav-menu.jsx
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
Children,
|
3
|
+
cloneElement,
|
4
|
+
useEffect,
|
5
|
+
createContext,
|
6
|
+
useContext,
|
7
|
+
useRef,
|
8
|
+
forwardRef,
|
9
|
+
useLayoutEffect,
|
10
|
+
} from 'react';
|
2
11
|
import PropTypes from 'prop-types';
|
3
12
|
import clsx from 'clsx';
|
4
13
|
import { MoreHoriz as MoreHorizIcon, ExpandMore as ExpandMoreIcon, Menu as MenuIcon } from '@mui/icons-material';
|
@@ -56,7 +65,7 @@ function NavMenu({ items, mode, children, activeId, textColor, activeTextColor,
|
|
56
65
|
open,
|
57
66
|
close,
|
58
67
|
};
|
59
|
-
}, [currentState, mode, activate, open, close]);
|
68
|
+
}, [currentState.activeId, currentState.hiddenItemCount, currentState.openedIds, mode, activate, open, close]);
|
60
69
|
|
61
70
|
const navMenuRef = useRef();
|
62
71
|
const itemRefs = useRef([]);
|
@@ -109,10 +118,17 @@ function NavMenu({ items, mode, children, activeId, textColor, activeTextColor,
|
|
109
118
|
if (newHiddenCount !== currentState.hiddenItemCount) {
|
110
119
|
currentState.hiddenItemCount = newHiddenCount;
|
111
120
|
}
|
112
|
-
}
|
121
|
+
}),
|
113
122
|
{ wait: 100 }
|
114
123
|
);
|
115
124
|
|
125
|
+
useLayoutEffect(() => {
|
126
|
+
if (mode === 'horizontal') {
|
127
|
+
checkItemsFit();
|
128
|
+
}
|
129
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
130
|
+
}, [containerSize?.width, mode]);
|
131
|
+
|
116
132
|
useEffect(() => {
|
117
133
|
if (mode === 'horizontal') {
|
118
134
|
checkItemsFit();
|
@@ -142,7 +158,7 @@ function NavMenu({ items, mode, children, activeId, textColor, activeTextColor,
|
|
142
158
|
// 对于 Sub 组件,如果它是顶级组件,则包含 ref
|
143
159
|
return (
|
144
160
|
<Sub
|
145
|
-
key={
|
161
|
+
key={item.id}
|
146
162
|
id={item.id}
|
147
163
|
icon={item.icon}
|
148
164
|
label={item.label}
|
@@ -161,7 +177,7 @@ function NavMenu({ items, mode, children, activeId, textColor, activeTextColor,
|
|
161
177
|
// 顶级 Item 组件总是包含 ref
|
162
178
|
return (
|
163
179
|
<Item
|
164
|
-
key={
|
180
|
+
key={item.id}
|
165
181
|
id={item.id}
|
166
182
|
icon={item.icon}
|
167
183
|
label={item.label}
|
@@ -283,7 +299,15 @@ const Sub = forwardRef(({ id: _id, icon, label, children, expandIcon, ...rest },
|
|
283
299
|
const isInlineMode = mode === 'inline';
|
284
300
|
// inline mode 时使用 click 事件控制收缩/伸展子菜单
|
285
301
|
const props = isInlineMode
|
286
|
-
? {
|
302
|
+
? {
|
303
|
+
onClick: () => {
|
304
|
+
if (openedIds.includes(id)) {
|
305
|
+
close(id);
|
306
|
+
} else {
|
307
|
+
open(id);
|
308
|
+
}
|
309
|
+
},
|
310
|
+
}
|
287
311
|
: {
|
288
312
|
onMouseEnter: () => open(id),
|
289
313
|
onMouseLeave: () => close(id),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|