@arcblock/ux 2.10.4 → 2.10.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,7 +124,7 @@ Header.defaultProps = {
124
124
  maxWidth: undefined,
125
125
  homeLink: '/'
126
126
  };
127
- const Root = styled('div')`
127
+ const Root = styled(Box)`
128
128
  position: relative;
129
129
  z-index: ${props => props.theme.zIndex.appBar};
130
130
  font-size: 14px;
@@ -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', 'hidden', 'important');
60
+ document.documentElement.style.setProperty('overflow', 'revert', 'important');
61
61
  } else {
62
62
  clean();
63
63
  }
@@ -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/Link';
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';
@@ -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
- }, [currentState.hiddenItemCount, containerSize?.width]), {
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
- }, index);
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
- }, index);
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: () => openedIds.includes(id) ? close(id) : open(id)
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.4",
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": "57248b30b2ad697026249b768894c44345c37ed3",
57
+ "gitHead": "b167099e5491387e6f7cc2d36d8f8a8e56e8f28d",
58
58
  "dependencies": {
59
59
  "@arcblock/did-motif": "^1.1.13",
60
- "@arcblock/icons": "^2.10.4",
61
- "@arcblock/nft-display": "^2.10.4",
62
- "@arcblock/react-hooks": "^2.10.4",
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",
@@ -105,7 +105,7 @@ Header.defaultProps = {
105
105
  homeLink: '/',
106
106
  };
107
107
 
108
- const Root = styled('div')`
108
+ const Root = styled(Box)`
109
109
  position: relative;
110
110
  z-index: ${(props) => props.theme.zIndex.appBar};
111
111
  font-size: 14px;
@@ -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', 'hidden', 'important');
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 Link from '@mui/material/Link';
5
-
6
- import AppBar from '@mui/material/AppBar';
7
- import Container from '@mui/material/Container';
8
- import Drawer from '@mui/material/Drawer';
9
- import Divider from '@mui/material/Divider';
10
- import Toolbar from '@mui/material/Toolbar';
11
- import Typography from '@mui/material/Typography';
12
- import List from '@mui/material/List';
13
- import ListItem from '@mui/material/ListItem';
14
- import ListItemText from '@mui/material/ListItemText';
15
- import IconButton from '@mui/material/IconButton';
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';
@@ -1,4 +1,13 @@
1
- import { Children, cloneElement, useEffect, createContext, useContext, useRef, forwardRef } from 'react';
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
- }, [currentState.hiddenItemCount, containerSize?.width]),
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={index}
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={index}
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
- ? { onClick: () => (openedIds.includes(id) ? close(id) : open(id)) }
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