@arcblock/ux 2.12.3 → 2.12.5

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.
@@ -38,7 +38,7 @@ export interface ItemProps extends React.HTMLAttributes<HTMLLIElement> {
38
38
  }
39
39
  export declare const Item: import("react").ForwardRefExoticComponent<ItemProps & import("react").RefAttributes<HTMLLIElement>>;
40
40
  export interface SubProps extends Omit<ItemProps, 'children' | 'active'> {
41
- children?: Array<React.ReactElement> | ((props: {
41
+ children?: Array<React.ReactElement | null> | ((props: {
42
42
  isOpen: boolean;
43
43
  }) => React.ReactElement | null);
44
44
  expandIcon?: React.ReactNode | ((props: {
@@ -5,7 +5,8 @@ import { MoreHoriz as MoreHorizIcon, ExpandMore as ExpandMoreIcon, Menu as MenuI
5
5
  import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
6
6
  import { useCreation, useMemoizedFn, useReactive, useSize, useThrottleFn } from 'ahooks';
7
7
  import { NavMenuProvider, useNavMenuContext } from './nav-menu-context';
8
- import { NavMenuRoot, NavMenuList, NavMenuItem, NavMenuSub, NavMenuSubList } from './style';
8
+ import { NavMenuRoot, NavMenuItem, NavMenuSub, NavMenuSubList, NavMenuStyled } from './style';
9
+ import { SubContainer } from './sub-container';
9
10
 
10
11
  // 过滤 children 中的 Item/Sub, 忽略其它类型的 element
11
12
  function filterItems(children) {
@@ -73,6 +74,7 @@ function NavMenu({
73
74
  const navMenuRef = useRef(null);
74
75
  const itemRefs = useRef([]);
75
76
  const moreIconRef = useRef(null);
77
+ const containerWidth = useRef(0);
76
78
  const isAllItemsHidden = currentState.hiddenItemCount === itemRefs.current?.length;
77
79
  const style = isAllItemsHidden ? {
78
80
  marginLeft: '0px'
@@ -96,14 +98,13 @@ function NavMenu({
96
98
  let totalWidthUsed = 0;
97
99
  let newHiddenCount = 0;
98
100
  let leftAllHidden = false;
99
- const containerWidth = containerSize?.width || 0;
100
101
  const moreIconWidth = moreIconRef.current ? moreIconRef.current.offsetWidth + parseFloat(window.getComputedStyle(moreIconRef.current).marginLeft) : 0;
101
102
  itemRefs.current.forEach((item, index) => {
102
103
  if (item) {
103
104
  item.style.display = 'flex';
104
105
  const marginLeft = index > 0 ? parseFloat(window.getComputedStyle(item).marginLeft) : 0;
105
106
  const currentItemWidth = item.offsetWidth + marginLeft;
106
- if (containerWidth - moreIconWidth >= totalWidthUsed + currentItemWidth && !leftAllHidden) {
107
+ if (containerWidth.current - moreIconWidth >= totalWidthUsed + currentItemWidth && !leftAllHidden) {
107
108
  totalWidthUsed += currentItemWidth;
108
109
  } else {
109
110
  item.style.display = 'none';
@@ -119,6 +120,7 @@ function NavMenu({
119
120
  wait: 100
120
121
  });
121
122
  useLayoutEffect(() => {
123
+ containerWidth.current = containerSize?.width || navMenuRef.current?.clientWidth || 0;
122
124
  if (mode === 'horizontal') {
123
125
  checkItemsFit();
124
126
  }
@@ -144,8 +146,14 @@ function NavMenu({
144
146
  // eslint-disable-next-line react-hooks/exhaustive-deps
145
147
  }, [activeId]);
146
148
  const classes = clsx('navmenu', `navmenu--${mode}`, rest.className);
147
- const renderItem = (item, index, isTopLevel = false) => {
149
+ const renderItem = (item, index, level = 0) => {
150
+ const isTopLevel = level === 0;
148
151
  if (item?.children) {
152
+ // 只渲染两级子菜单
153
+ if (level > 0) {
154
+ return null;
155
+ }
156
+
149
157
  // 对于 Sub 组件,如果它是顶级组件,则包含 ref
150
158
  return /*#__PURE__*/_jsx(Sub, {
151
159
  id: item.id,
@@ -158,7 +166,7 @@ function NavMenu({
158
166
  children: typeof item.children === 'function' ? item.children : item.children.map((childItem, childIndex) => renderItem({
159
167
  ...childItem,
160
168
  variant: 'panel'
161
- }, childIndex, false))
169
+ }, childIndex, level + 1))
162
170
  }, item.id);
163
171
  }
164
172
 
@@ -175,18 +183,21 @@ function NavMenu({
175
183
  } : undefined
176
184
  }, item.id);
177
185
  };
178
- const content = items ? items?.slice(-currentState.hiddenItemCount).map((item, index) => renderItem(item, index)) : children?.slice(-currentState.hiddenItemCount);
186
+ const content = items ? items?.slice(-currentState.hiddenItemCount).map((item, index) => renderItem(item, index, 1)) : children?.slice(-currentState.hiddenItemCount);
187
+
188
+ // 当前展开的子菜单
189
+ const openedId = currentState.openedIds[0];
179
190
  return /*#__PURE__*/_jsx(NavMenuProvider, {
180
191
  value: contextValue,
181
- children: /*#__PURE__*/_jsx(NavMenuRoot, {
192
+ children: /*#__PURE__*/_jsx(NavMenuStyled, {
182
193
  ...rest,
183
194
  className: classes,
184
195
  $textColor: textColor,
185
196
  $bgColor: bgColor,
186
- children: /*#__PURE__*/_jsxs(NavMenuList, {
187
- className: clsx('navmenu-list', `navmenu-list--${mode}`),
197
+ children: /*#__PURE__*/_jsxs(NavMenuRoot, {
198
+ className: clsx('navmenu-root', `navmenu-root--${mode}`),
188
199
  ref: navMenuRef,
189
- children: [items ? items.map((item, index) => renderItem(item, index, true)) : renderChildrenWithRef(children || []), currentState.hiddenItemCount > 0 && /*#__PURE__*/_jsx(Sub, {
200
+ children: [items ? items.map((item, index) => renderItem(item, index)) : renderChildrenWithRef(children || []), currentState.hiddenItemCount > 0 && /*#__PURE__*/_jsx(Sub, {
190
201
  expandIcon: false,
191
202
  icon: icon,
192
203
  label: "",
@@ -329,8 +340,7 @@ export const Sub = /*#__PURE__*/forwardRef(({
329
340
  children: typeof expandIcon === 'function' ? expandIcon({
330
341
  isOpen
331
342
  }) : expandIcon
332
- }), /*#__PURE__*/_jsx("div", {
333
- className: "navmenu-sub__container",
343
+ }), /*#__PURE__*/_jsx(SubContainer, {
334
344
  ...containerProps,
335
345
  children: typeof children === 'function' ? children({
336
346
  isOpen
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
- import { useLayoutEffect, useRef } from 'react';
3
+ import { useRef } from 'react';
4
4
  import { Link } from 'react-router-dom';
5
5
  import { useCreation, useMemoizedFn } from 'ahooks';
6
6
  import { Box, Grid } from '@mui/material';
7
- import { useWindowSize } from 'react-use';
8
7
  import SubItemGroup from './sub-item-group';
9
8
  import { Item } from './nav-menu';
10
9
  import { styled } from '../Theme';
@@ -1284,58 +1283,58 @@ const translations = {
1284
1283
  },
1285
1284
  products: {
1286
1285
  nftStudio: {
1287
- description: 'Toolkit for NFT creation'
1286
+ description: 'Mint and manage NFTs'
1288
1287
  },
1289
1288
  creatorStudio: {
1290
- description: "Content creators' Swiss knife"
1289
+ description: 'All-in-one creator tool'
1291
1290
  },
1292
1291
  aigne: {
1293
- description: 'Chat with AIGNE'
1292
+ description: 'Your AI assistant'
1294
1293
  },
1295
1294
  aistro: {
1296
- description: 'Al Language Model Astrologer'
1295
+ description: 'AI-powered astrology'
1297
1296
  },
1298
1297
  blockletLauncher: {
1299
- description: 'Launch your blocklet here'
1298
+ description: 'One-click app launcher'
1300
1299
  },
1301
1300
  alKit: {
1302
- description: 'Empowers Al for application'
1301
+ description: 'Boost apps with AI'
1303
1302
  },
1304
1303
  blockletStore: {
1305
- description: 'App Store for all Blocklets'
1304
+ description: 'Discover & deploy apps'
1306
1305
  },
1307
1306
  web3Kit: {
1308
- description: 'Provides series components'
1307
+ description: 'Web3 dev toolkit'
1309
1308
  },
1310
1309
  blockletFramework: {
1311
- description: 'Launch your blocklet here'
1310
+ description: 'Build and run blocklets'
1312
1311
  },
1313
1312
  didSpaces: {
1314
- description: 'Decentralized storage space'
1313
+ description: 'Secure personal storage'
1315
1314
  },
1316
1315
  abtNetwork: {
1317
- description: "ArcBlock's blockchain system"
1316
+ description: 'Fast blockchain network'
1318
1317
  },
1319
1318
  blockletServer: {
1320
- description: 'Runtime Container Service'
1319
+ description: 'Host your apps easily'
1321
1320
  },
1322
- osar: {
1323
- description: 'Supports multpy blockchains'
1321
+ ocap: {
1322
+ description: 'Multi-chain connector'
1324
1323
  },
1325
1324
  did: {
1326
- description: 'Decentralized Identity'
1325
+ description: 'Self-sovereign ID'
1327
1326
  },
1328
1327
  didWallet: {
1329
- description: 'Intelligent digital wallet'
1328
+ description: 'Smart digital wallet'
1330
1329
  },
1331
1330
  didNameService: {
1332
- description: 'Purchase/host domain'
1331
+ description: 'Web3 domain names'
1333
1332
  },
1334
1333
  vc: {
1335
1334
  description: 'Verifiable Credentials'
1336
1335
  },
1337
1336
  didConnect: {
1338
- description: 'Login with DID'
1337
+ description: 'Passwordless login'
1339
1338
  }
1340
1339
  }
1341
1340
  },
@@ -1348,58 +1347,58 @@ const translations = {
1348
1347
  },
1349
1348
  products: {
1350
1349
  nftStudio: {
1351
- description: 'NFT 创作工具包'
1350
+ description: '铸造和管理 NFT'
1352
1351
  },
1353
1352
  creatorStudio: {
1354
- description: '内容创作者的瑞士军刀'
1353
+ description: '一体化创作工具'
1355
1354
  },
1356
1355
  aigne: {
1357
- description: '与 AIGNE 聊天'
1356
+ description: '您的人工智能助手'
1358
1357
  },
1359
1358
  aistro: {
1360
- description: 'Al 语言模型占星师'
1359
+ description: 'AI 占星术'
1361
1360
  },
1362
1361
  blockletLauncher: {
1363
- description: '在这里启动你的 blocklet'
1362
+ description: '一键启动应用程序'
1364
1363
  },
1365
1364
  alKit: {
1366
- description: '为应用赋能 Al'
1365
+ description: 'AI 赋能应用'
1367
1366
  },
1368
1367
  blockletStore: {
1369
- description: '所有 Blocklets 的应用商店'
1368
+ description: '发现和部署应用程序'
1370
1369
  },
1371
1370
  web3Kit: {
1372
- description: '提供系列组件'
1371
+ description: 'Web3 开发工具包'
1373
1372
  },
1374
1373
  blockletFramework: {
1375
- description: '在这里启动你的 blocklet'
1374
+ description: '构建并运行 Blocklet'
1376
1375
  },
1377
1376
  didSpaces: {
1378
- description: '去中心化存储空间'
1377
+ description: '安全的个人存储'
1379
1378
  },
1380
1379
  abtNetwork: {
1381
- description: 'ArcBlock 的区块链系统'
1380
+ description: '快速区块链网络'
1382
1381
  },
1383
1382
  blockletServer: {
1384
- description: '运行时容器服务'
1383
+ description: '轻松托管应用程序'
1385
1384
  },
1386
- osar: {
1387
- description: '支持多链'
1385
+ ocap: {
1386
+ description: '多链连接器'
1388
1387
  },
1389
1388
  did: {
1390
- description: '去中心化身份'
1389
+ description: '自主身份'
1391
1390
  },
1392
1391
  didWallet: {
1393
1392
  description: '智能数字钱包'
1394
1393
  },
1395
1394
  didNameService: {
1396
- description: '购买/托管域名'
1395
+ description: 'Web3 域名'
1397
1396
  },
1398
1397
  vc: {
1399
1398
  description: '可验证凭证'
1400
1399
  },
1401
1400
  didConnect: {
1402
- description: '使用 DID 登录'
1401
+ description: '无密码登录'
1403
1402
  }
1404
1403
  }
1405
1404
  }
@@ -1437,10 +1436,6 @@ export default function Products({
1437
1436
  mode
1438
1437
  } = useNavMenuContext();
1439
1438
  const wrapperRef = useRef(null);
1440
- const {
1441
- width,
1442
- height
1443
- } = useWindowSize();
1444
1439
  const {
1445
1440
  locale = 'en'
1446
1441
  } = useLocaleContext() || {};
@@ -1452,6 +1447,8 @@ export default function Products({
1452
1447
  children: [[{
1453
1448
  label: /*#__PURE__*/_jsx(Link, {
1454
1449
  to: `https://www.nftstudio.rocks/${locale}`,
1450
+ target: "_blank",
1451
+ rel: "noreferrer noopener",
1455
1452
  children: "NFT Studio"
1456
1453
  }),
1457
1454
  description: t('products.nftStudio.description'),
@@ -1459,6 +1456,8 @@ export default function Products({
1459
1456
  }, {
1460
1457
  label: /*#__PURE__*/_jsx(Link, {
1461
1458
  to: `https://www.arcblock.io/content/collections/${locale}/creator-studio`,
1459
+ target: "_blank",
1460
+ rel: "noreferrer noopener",
1462
1461
  children: "Creator Studio"
1463
1462
  }),
1464
1463
  description: t('products.creatorStudio.description'),
@@ -1466,6 +1465,8 @@ export default function Products({
1466
1465
  }], [{
1467
1466
  label: /*#__PURE__*/_jsx(Link, {
1468
1467
  to: `https://www.aigne.io/${locale}`,
1468
+ target: "_blank",
1469
+ rel: "noreferrer noopener",
1469
1470
  children: "AIGNE"
1470
1471
  }),
1471
1472
  description: t('products.aigne.description'),
@@ -1473,6 +1474,8 @@ export default function Products({
1473
1474
  }, {
1474
1475
  label: /*#__PURE__*/_jsx(Link, {
1475
1476
  to: `https://www.aistro.io/${locale}`,
1477
+ target: "_blank",
1478
+ rel: "noreferrer noopener",
1476
1479
  children: "Aistro"
1477
1480
  }),
1478
1481
  description: t('products.aistro.description'),
@@ -1484,6 +1487,8 @@ export default function Products({
1484
1487
  children: [[{
1485
1488
  label: /*#__PURE__*/_jsx(Link, {
1486
1489
  to: `https://launcher.arcblock.io/${locale}`,
1490
+ target: "_blank",
1491
+ rel: "noreferrer noopener",
1487
1492
  children: "Blocklet Launcher"
1488
1493
  }),
1489
1494
  description: t('products.blockletLauncher.description'),
@@ -1491,6 +1496,8 @@ export default function Products({
1491
1496
  }, {
1492
1497
  label: /*#__PURE__*/_jsx(Link, {
1493
1498
  to: `https://www.arcblock.io/content/collections/${locale}/ai-kit`,
1499
+ target: "_blank",
1500
+ rel: "noreferrer noopener",
1494
1501
  children: "Al Kit"
1495
1502
  }),
1496
1503
  description: t('products.alKit.description'),
@@ -1498,6 +1505,8 @@ export default function Products({
1498
1505
  }], [{
1499
1506
  label: /*#__PURE__*/_jsx(Link, {
1500
1507
  to: `https://store.blocklet.dev/${locale}`,
1508
+ target: "_blank",
1509
+ rel: "noreferrer noopener",
1501
1510
  children: "Blocklet Store"
1502
1511
  }),
1503
1512
  description: t('products.blockletStore.description'),
@@ -1505,6 +1514,8 @@ export default function Products({
1505
1514
  }, {
1506
1515
  label: /*#__PURE__*/_jsx(Link, {
1507
1516
  to: `https://www.web3kit.rocks/${locale}`,
1517
+ target: "_blank",
1518
+ rel: "noreferrer noopener",
1508
1519
  children: "Web3 Kit"
1509
1520
  }),
1510
1521
  description: t('products.web3Kit.description'),
@@ -1516,6 +1527,8 @@ export default function Products({
1516
1527
  children: [[{
1517
1528
  label: /*#__PURE__*/_jsx(Link, {
1518
1529
  to: `https://www.arcblock.io/content/collections/${locale}/blocklet`,
1530
+ target: "_blank",
1531
+ rel: "noreferrer noopener",
1519
1532
  children: "Blocklet Framework"
1520
1533
  }),
1521
1534
  description: t('products.blockletFramework.description'),
@@ -1523,6 +1536,8 @@ export default function Products({
1523
1536
  }, {
1524
1537
  label: /*#__PURE__*/_jsx(Link, {
1525
1538
  to: `https://www.didspaces.com/${locale}`,
1539
+ target: "_blank",
1540
+ rel: "noreferrer noopener",
1526
1541
  children: "DID Spaces"
1527
1542
  }),
1528
1543
  description: t('products.didSpaces.description'),
@@ -1530,6 +1545,8 @@ export default function Products({
1530
1545
  }, {
1531
1546
  label: /*#__PURE__*/_jsx(Link, {
1532
1547
  to: `https://main.abtnetwork.io/${locale}`,
1548
+ target: "_blank",
1549
+ rel: "noreferrer noopener",
1533
1550
  children: "ABT Network"
1534
1551
  }),
1535
1552
  description: t('products.abtNetwork.description'),
@@ -1537,6 +1554,8 @@ export default function Products({
1537
1554
  }], [{
1538
1555
  label: /*#__PURE__*/_jsx(Link, {
1539
1556
  to: `https://www.arcblock.io/content/collections/${locale}/blocklet-server`,
1557
+ target: "_blank",
1558
+ rel: "noreferrer noopener",
1540
1559
  children: "Blocklet Server"
1541
1560
  }),
1542
1561
  description: t('products.blockletServer.description'),
@@ -1544,9 +1563,11 @@ export default function Products({
1544
1563
  }, {
1545
1564
  label: /*#__PURE__*/_jsx(Link, {
1546
1565
  to: `https://www.arcblock.io/content/collections/${locale}/blockchain`,
1566
+ target: "_blank",
1567
+ rel: "noreferrer noopener",
1547
1568
  children: "\u041E\u0421\u0410\u0420"
1548
1569
  }),
1549
- description: t('products.osar.description'),
1570
+ description: t('products.ocap.description'),
1550
1571
  icon: /*#__PURE__*/_jsx(OCAPSvg, {})
1551
1572
  }]]
1552
1573
  }, {
@@ -1555,6 +1576,8 @@ export default function Products({
1555
1576
  children: [[{
1556
1577
  label: /*#__PURE__*/_jsx(Link, {
1557
1578
  to: `https://www.arcblock.io/content/collections/${locale}/did`,
1579
+ target: "_blank",
1580
+ rel: "noreferrer noopener",
1558
1581
  children: "DID"
1559
1582
  }),
1560
1583
  description: t('products.did.description'),
@@ -1562,6 +1585,8 @@ export default function Products({
1562
1585
  }, {
1563
1586
  label: /*#__PURE__*/_jsx(Link, {
1564
1587
  to: `https://www.didwallet.io/${locale}`,
1588
+ target: "_blank",
1589
+ rel: "noreferrer noopener",
1565
1590
  children: "DID Wallet"
1566
1591
  }),
1567
1592
  description: t('products.didWallet.description'),
@@ -1569,13 +1594,17 @@ export default function Products({
1569
1594
  }, {
1570
1595
  label: /*#__PURE__*/_jsx(Link, {
1571
1596
  to: `https://www.didnames.io/${locale}`,
1572
- children: "DID Name Service"
1597
+ target: "_blank",
1598
+ rel: "noreferrer noopener",
1599
+ children: "DID Names"
1573
1600
  }),
1574
1601
  description: t('products.didNameService.description'),
1575
1602
  icon: /*#__PURE__*/_jsx(DidNameServiceSvg, {})
1576
1603
  }], [{
1577
1604
  label: /*#__PURE__*/_jsx(Link, {
1578
1605
  to: `https://www.arcblock.io/content/collections/${locale}/verifiable-credential`,
1606
+ target: "_blank",
1607
+ rel: "noreferrer noopener",
1579
1608
  children: "VC"
1580
1609
  }),
1581
1610
  description: t('products.vc.description'),
@@ -1583,6 +1612,8 @@ export default function Products({
1583
1612
  }, {
1584
1613
  label: /*#__PURE__*/_jsx(Link, {
1585
1614
  to: `https://www.didconnect.io/${locale}`,
1615
+ target: "_blank",
1616
+ rel: "noreferrer noopener",
1586
1617
  children: "DID Connect"
1587
1618
  }),
1588
1619
  description: t('products.didConnect.description'),
@@ -1590,26 +1621,6 @@ export default function Products({
1590
1621
  }]]
1591
1622
  }];
1592
1623
  }, [t, locale]);
1593
-
1594
- // 防止弹框超出 window
1595
- useLayoutEffect(() => {
1596
- const wrapper = wrapperRef.current;
1597
- if (!wrapper) return;
1598
- if (!isOpen) {
1599
- wrapper.style.transform = '';
1600
- return;
1601
- }
1602
- const rect = wrapper.getBoundingClientRect();
1603
- const windowWidth = window.innerWidth;
1604
- if (rect.right > windowWidth) {
1605
- const offset = rect.right - windowWidth;
1606
- wrapper.style.transform = `translateX(-${offset + 16}px)`;
1607
- } else if (rect.left < 0) {
1608
- wrapper.style.transform = `translateX(${Math.abs(rect.left) + 16}px)`;
1609
- } else {
1610
- wrapper.style.transform = '';
1611
- }
1612
- }, [width, height, isOpen]);
1613
1624
  return /*#__PURE__*/_jsx(Wrapper, {
1614
1625
  ref: wrapperRef,
1615
1626
  className: `is-${mode} ${className}`,
@@ -2,8 +2,8 @@ type NavMenuProps = {
2
2
  $bgColor: string;
3
3
  $textColor: string;
4
4
  };
5
- export declare const NavMenuRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & NavMenuProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
6
- export declare const NavMenuList: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
5
+ export declare const NavMenuStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & NavMenuProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
6
+ export declare const NavMenuRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
7
7
  type NavMenuItemProps = {
8
8
  $activeTextColor: string;
9
9
  };
@@ -1,12 +1,13 @@
1
1
  import { styled } from '../Theme';
2
- // .navmenu-root
3
- export const NavMenuRoot = styled('nav', {
2
+ // .navmenu
3
+ export const NavMenuStyled = styled('nav', {
4
4
  shouldForwardProp: prop => prop !== '$bgColor' && prop !== '$textColor'
5
5
  })(({
6
6
  $bgColor,
7
7
  $textColor
8
8
  }) => ({
9
- padding: '8px 16px',
9
+ position: 'relative',
10
+ padding: '0 16px',
10
11
  minWidth: '50px',
11
12
  // FIXME: @zhanghan 这个只是临时的解决方案,会导致 header align right 不能真正的右对齐,需要修改 header 才能真正解决这个问题
12
13
  flexGrow: 100,
@@ -15,15 +16,15 @@ export const NavMenuRoot = styled('nav', {
15
16
  fontSize: '16px'
16
17
  }));
17
18
 
18
- // .navmenu-list
19
- export const NavMenuList = styled('ul')(() => ({
19
+ // .navmenu-root
20
+ export const NavMenuRoot = styled('ul')(() => ({
20
21
  listStyle: 'none',
21
22
  margin: 0,
22
23
  padding: 0,
23
24
  display: 'flex',
24
25
  alignItems: 'center',
25
26
  // inline 布局
26
- '&.navmenu-list--inline ': {
27
+ '&.navmenu-root--inline ': {
27
28
  flexDirection: 'column',
28
29
  alignItems: 'stretch'
29
30
  }
@@ -32,15 +33,18 @@ export const NavMenuList = styled('ul')(() => ({
32
33
  export const NavMenuItem = styled('li', {
33
34
  shouldForwardProp: prop => prop !== '$activeTextColor'
34
35
  })(({
35
- $activeTextColor
36
+ $activeTextColor,
37
+ theme
36
38
  }) => ({
37
39
  display: 'flex',
38
40
  alignItems: 'center',
39
41
  position: 'relative',
40
- padding: '0 12px',
42
+ padding: '8px 12px',
41
43
  whiteSpace: 'nowrap',
42
44
  cursor: 'pointer',
43
- transition: 'color 0.2s ease-in-out',
45
+ transition: theme.transitions.create('color', {
46
+ duration: theme.transitions.duration.standard
47
+ }),
44
48
  // 间距调整
45
49
  '&:first-of-type': {
46
50
  paddingLeft: 0
@@ -93,7 +97,9 @@ export const NavMenuItem = styled('li', {
93
97
  marginLeft: '6px',
94
98
  fontSize: '14px',
95
99
  opacity: 0,
96
- transition: 'opacity 0.2s ease-in-out'
100
+ transition: theme.transitions.create('opacity', {
101
+ duration: theme.transitions.duration.standard
102
+ })
97
103
  }
98
104
  },
99
105
  '.navmenu-item__desc': {
@@ -131,13 +137,17 @@ export const NavMenuItem = styled('li', {
131
137
  },
132
138
  '&:hover': {
133
139
  background: '#f9f9fb',
134
- transition: 'background 0.2s ease-in-out',
140
+ transition: theme.transitions.create('background', {
141
+ duration: theme.transitions.duration.standard
142
+ }),
135
143
  '.navmenu-item__label-arrow': {
136
144
  opacity: 1
137
145
  },
138
146
  '.navmenu-item__desc': {
139
147
  color: '#26292e',
140
- transition: 'color 0.2s ease-in-out'
148
+ transition: theme.transitions.create('color', {
149
+ duration: theme.transitions.duration.standard
150
+ })
141
151
  }
142
152
  },
143
153
  '&.navmenu-item--active': {
@@ -155,24 +165,28 @@ export const NavMenuItem = styled('li', {
155
165
  }));
156
166
 
157
167
  // 包含子菜单的导航项 .navmenu-item .navmenu-sub
158
- export const NavMenuSub = styled(NavMenuItem)(() => ({
168
+ export const NavMenuSub = styled(NavMenuItem)(({
169
+ theme
170
+ }) => ({
159
171
  '.navmenu-item': {
160
- marginLeft: 0
172
+ marginLeft: 0,
173
+ overflow: 'hidden'
161
174
  },
162
175
  '& .navmenu-sub__container': {
163
- visibility: 'hidden',
176
+ pointerEvents: 'none',
164
177
  opacity: 0,
165
178
  position: 'absolute',
166
179
  top: '100%',
167
- left: '50%',
168
- zIndex: 1,
169
- transform: 'translateX(-50%)',
170
- paddingTop: '16px',
171
- transition: 'opacity 0.2s ease-in-out, visibility 0.2s ease-in-out'
180
+ left: 0,
181
+ zIndex: 1
172
182
  },
173
183
  '&.navmenu-sub--opened > .navmenu-sub__container': {
174
- visibility: 'visible',
175
- opacity: 1
184
+ pointerEvents: 'auto',
185
+ opacity: 1,
186
+ transition: theme.transitions.create('opacity', {
187
+ duration: theme.transitions.duration.standard,
188
+ easing: theme.transitions.easing.easeOut
189
+ })
176
190
  },
177
191
  // 扩展图标
178
192
  '.navmenu-sub__expand-icon': {
@@ -183,7 +197,9 @@ export const NavMenuSub = styled(NavMenuItem)(() => ({
183
197
  '& > *': {
184
198
  width: '0.8em',
185
199
  height: '0.8em',
186
- transition: 'transform 0.2s ease-in-out'
200
+ transition: theme.transitions.create('transform', {
201
+ duration: theme.transitions.duration.standard
202
+ })
187
203
  },
188
204
  '.navmenu-item--inline &': {
189
205
  marginLeft: 'auto'
@@ -199,7 +215,9 @@ export const NavMenuSub = styled(NavMenuItem)(() => ({
199
215
  padding: 0,
200
216
  height: 0,
201
217
  overflow: 'hidden',
202
- transition: 'height 0.2s ease-in-out'
218
+ transition: theme.transitions.create('height', {
219
+ duration: theme.transitions.duration.standard
220
+ })
203
221
  },
204
222
  '&.navmenu-sub--opened > .navmenu-sub__container': {
205
223
  height: 'auto'
@@ -208,11 +226,14 @@ export const NavMenuSub = styled(NavMenuItem)(() => ({
208
226
  padding: 0,
209
227
  paddingLeft: '16px',
210
228
  boxShadow: 'none'
229
+ },
230
+ '.navmenu-item__content': {
231
+ height: '48px'
211
232
  }
212
233
  }
213
234
  }));
214
235
 
215
- // 下拉子菜单 .navmenu-sub-list
236
+ // 下拉子菜单 .navmenu-sub__list
216
237
  export const NavMenuSubList = styled('ul')(() => ({
217
238
  margin: 0,
218
239
  padding: '16px',
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface SubContainerProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ children: React.ReactNode;
4
+ }
5
+ export declare function SubContainer({ children, ...props }: SubContainerProps): import("react/jsx-runtime").JSX.Element;
6
+ export default SubContainer;