@arcblock/ux 3.4.14 → 3.5.0

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.
Files changed (335) hide show
  1. package/lib/Util/constant.d.ts +6 -0
  2. package/lib/Util/constant.js +25 -16
  3. package/lib/package.json.js +1 -1
  4. package/package.json +12 -9
  5. package/src/ActionButton/ActionButton.stories.jsx +0 -61
  6. package/src/ActionButton/index.jsx +0 -106
  7. package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
  8. package/src/ActivityIndicator/index.jsx +0 -140
  9. package/src/Address/Address.stories.jsx +0 -38
  10. package/src/Address/compact-text.jsx +0 -76
  11. package/src/Address/did-address.tsx +0 -223
  12. package/src/Address/index.tsx +0 -21
  13. package/src/Address/responsive-did-address.tsx +0 -154
  14. package/src/Alert/Alert.stories.jsx +0 -100
  15. package/src/Alert/index.jsx +0 -130
  16. package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
  17. package/src/AnimationWaiter/dark-animation.json +0 -1
  18. package/src/AnimationWaiter/default-animation.json +0 -1
  19. package/src/AnimationWaiter/index.jsx +0 -296
  20. package/src/Async/index.tsx +0 -44
  21. package/src/Avatar/Avatar.stories.jsx +0 -11
  22. package/src/Avatar/did-motif.jsx +0 -38
  23. package/src/Avatar/etherscan-blockies.js +0 -81
  24. package/src/Avatar/index.jsx +0 -195
  25. package/src/Badge/Badge.stories.jsx +0 -41
  26. package/src/Badge/index.jsx +0 -101
  27. package/src/Blocklet/Blocklet.stories.jsx +0 -21
  28. package/src/Blocklet/blocklet.jsx +0 -276
  29. package/src/Blocklet/index.js +0 -5
  30. package/src/Blocklet/utils.jsx +0 -58
  31. package/src/BlockletContext/index.tsx +0 -72
  32. package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
  33. package/src/BlockletNFT/index.jsx +0 -378
  34. package/src/BlockletV2/Blocklet.stories.jsx +0 -34
  35. package/src/BlockletV2/blocklet.tsx +0 -247
  36. package/src/BlockletV2/components/icon-text.tsx +0 -47
  37. package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
  38. package/src/BlockletV2/index.ts +0 -6
  39. package/src/BlockletV2/utils.js +0 -75
  40. package/src/Button/Button.stories.jsx +0 -24
  41. package/src/Button/index.js +0 -9
  42. package/src/Button/wrap.jsx +0 -126
  43. package/src/ButtonGroup/index.js +0 -16
  44. package/src/CardSelector/index.tsx +0 -136
  45. package/src/Center/Center.stories.jsx +0 -20
  46. package/src/Center/index.tsx +0 -33
  47. package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
  48. package/src/ClickToCopy/copy-button.tsx +0 -43
  49. package/src/ClickToCopy/hook.ts +0 -42
  50. package/src/ClickToCopy/index.tsx +0 -96
  51. package/src/CloseButton/index.tsx +0 -37
  52. package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
  53. package/src/CodeBlock/LightBox.tsx +0 -87
  54. package/src/CodeBlock/index.tsx +0 -217
  55. package/src/Colors/Colors.stories.jsx +0 -211
  56. package/src/Colors/index.ts +0 -4
  57. package/src/Colors/themes/default.ts +0 -8
  58. package/src/Colors/themes/did-connect.ts +0 -64
  59. package/src/Colors/themes/temp.ts +0 -52
  60. package/src/Config/Config.stories.jsx +0 -16
  61. package/src/Config/config-provider.tsx +0 -62
  62. package/src/Config/index.ts +0 -2
  63. package/src/Config/theme-mode-toggle.tsx +0 -38
  64. package/src/ContactForm/ContactForm.stories.jsx +0 -32
  65. package/src/ContactForm/index.tsx +0 -264
  66. package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
  67. package/src/CookieConsent/index.tsx +0 -104
  68. package/src/CountDown/CountDown.stories.jsx +0 -15
  69. package/src/CountDown/index.tsx +0 -170
  70. package/src/DID/DID.stories.jsx +0 -37
  71. package/src/DID/index.tsx +0 -393
  72. package/src/DIDConnect/app-icon.tsx +0 -37
  73. package/src/DIDConnect/app-info-item.tsx +0 -93
  74. package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
  75. package/src/DIDConnect/auth-apps/index.tsx +0 -278
  76. package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
  77. package/src/DIDConnect/did-connect-container.tsx +0 -326
  78. package/src/DIDConnect/did-connect-footer.tsx +0 -76
  79. package/src/DIDConnect/did-connect-logo.tsx +0 -8
  80. package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
  81. package/src/DIDConnect/icons/github-logo.tsx +0 -17
  82. package/src/DIDConnect/index.ts +0 -11
  83. package/src/DIDConnect/landing-page.tsx +0 -218
  84. package/src/DIDConnect/powered-by.tsx +0 -48
  85. package/src/DIDConnect/provider-icon.tsx +0 -62
  86. package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
  87. package/src/DIDConnect/with-container.tsx +0 -323
  88. package/src/DIDConnect/with-ux-theme.tsx +0 -22
  89. package/src/DIDLogo/Logo.stories.jsx +0 -11
  90. package/src/DIDLogo/index.tsx +0 -168
  91. package/src/Datatable/CustomToolbar.jsx +0 -415
  92. package/src/Datatable/Datatable.stories.jsx +0 -92
  93. package/src/Datatable/DatatableContext.jsx +0 -35
  94. package/src/Datatable/TableSearch.jsx +0 -166
  95. package/src/Datatable/index.jsx +0 -652
  96. package/src/Datatable/utils.js +0 -161
  97. package/src/Dialog/Dialog.stories.jsx +0 -21
  98. package/src/Dialog/confirm.jsx +0 -143
  99. package/src/Dialog/dialog.jsx +0 -199
  100. package/src/Dialog/index.js +0 -4
  101. package/src/Dialog/types.d.ts +0 -20
  102. package/src/Dialog/use-confirm.jsx +0 -188
  103. package/src/DriftBot/index.tsx +0 -81
  104. package/src/Earth/Earth.stories.jsx +0 -39
  105. package/src/Earth/countries.json +0 -8057
  106. package/src/Earth/index.tsx +0 -515
  107. package/src/Earth/util.ts +0 -72
  108. package/src/Empty/Empty.stories.jsx +0 -23
  109. package/src/Empty/index.jsx +0 -48
  110. package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
  111. package/src/ErrorBoundary/fallback.tsx +0 -85
  112. package/src/ErrorBoundary/index.ts +0 -1
  113. package/src/Footer/Footer.stories.jsx +0 -13
  114. package/src/Footer/index.tsx +0 -130
  115. package/src/Header/Header.stories.jsx +0 -30
  116. package/src/Header/addon-button.tsx +0 -41
  117. package/src/Header/auto-hidden.tsx +0 -31
  118. package/src/Header/header-addons.tsx +0 -37
  119. package/src/Header/header.tsx +0 -214
  120. package/src/Header/index.ts +0 -3
  121. package/src/Header/responsive-header.tsx +0 -145
  122. package/src/Icon/Icon.stories.jsx +0 -45
  123. package/src/Icon/image.tsx +0 -53
  124. package/src/Icon/index.tsx +0 -63
  125. package/src/Img/Img.stories.jsx +0 -17
  126. package/src/Img/index.jsx +0 -258
  127. package/src/InfoRow/InfoRow.stories.jsx +0 -14
  128. package/src/InfoRow/index.tsx +0 -91
  129. package/src/Layout/Layout.stories.jsx +0 -24
  130. package/src/Layout/dashboard/external-link.tsx +0 -59
  131. package/src/Layout/dashboard/full-page.tsx +0 -58
  132. package/src/Layout/dashboard/index.tsx +0 -260
  133. package/src/Layout/dashboard/sidebar.tsx +0 -198
  134. package/src/Layout/dashboard-legacy/header.tsx +0 -156
  135. package/src/Layout/dashboard-legacy/index.tsx +0 -127
  136. package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
  137. package/src/Layout/index.tsx +0 -310
  138. package/src/LoadingMask/index.tsx +0 -108
  139. package/src/Locale/LocaleSelector.stories.jsx +0 -44
  140. package/src/Locale/browser-lang.ts +0 -65
  141. package/src/Locale/context.tsx +0 -162
  142. package/src/Locale/languages.ts +0 -58
  143. package/src/Locale/selector.tsx +0 -174
  144. package/src/Locale/util.ts +0 -38
  145. package/src/Logo/Logo.stories.jsx +0 -23
  146. package/src/Logo/images/logo-dark-text.svg +0 -3
  147. package/src/Logo/images/logo-dark-top.svg +0 -6
  148. package/src/Logo/images/logo-light-text.svg +0 -3
  149. package/src/Logo/images/logo-light-top.svg +0 -6
  150. package/src/Logo/index.tsx +0 -58
  151. package/src/Metric/Metric.stories.jsx +0 -29
  152. package/src/Metric/index.tsx +0 -130
  153. package/src/MuiWrap/index.tsx +0 -10
  154. package/src/NFTDisplay/NFTBroken.svg +0 -34
  155. package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
  156. package/src/NFTDisplay/README.md +0 -59
  157. package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
  158. package/src/NFTDisplay/broken.tsx +0 -51
  159. package/src/NFTDisplay/displayApi.ts +0 -43
  160. package/src/NFTDisplay/index.tsx +0 -393
  161. package/src/NFTDisplay/loading.tsx +0 -16
  162. package/src/NFTDisplay/preview.tsx +0 -84
  163. package/src/NFTDisplay/render-svg.tsx +0 -21
  164. package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
  165. package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
  166. package/src/NavMenu/NavMenu.stories.jsx +0 -17
  167. package/src/NavMenu/images/OCAP.svg +0 -1
  168. package/src/NavMenu/images/abt-network.svg +0 -1
  169. package/src/NavMenu/images/ai-kit.svg +0 -1
  170. package/src/NavMenu/images/aigne-image-smith.svg +0 -1
  171. package/src/NavMenu/images/aigne.svg +0 -1
  172. package/src/NavMenu/images/aistro.png +0 -0
  173. package/src/NavMenu/images/arcsphere.svg +0 -1
  174. package/src/NavMenu/images/blocklet-framework.svg +0 -1
  175. package/src/NavMenu/images/blocklet-launcher.svg +0 -1
  176. package/src/NavMenu/images/blocklet-server.svg +0 -1
  177. package/src/NavMenu/images/blocklet-store.svg +0 -1
  178. package/src/NavMenu/images/creator-studio.svg +0 -1
  179. package/src/NavMenu/images/did-wallet.svg +0 -1
  180. package/src/NavMenu/images/did.svg +0 -1
  181. package/src/NavMenu/images/nft-studio.svg +0 -1
  182. package/src/NavMenu/images/payment-kit.png +0 -0
  183. package/src/NavMenu/images/vc.svg +0 -1
  184. package/src/NavMenu/images/web3-kit.svg +0 -1
  185. package/src/NavMenu/index.ts +0 -3
  186. package/src/NavMenu/nav-menu-context.tsx +0 -30
  187. package/src/NavMenu/nav-menu.tsx +0 -441
  188. package/src/NavMenu/products.tsx +0 -830
  189. package/src/NavMenu/style.ts +0 -258
  190. package/src/NavMenu/sub-container.tsx +0 -125
  191. package/src/NavMenu/sub-item-group.tsx +0 -42
  192. package/src/OrgTransfer/index.tsx +0 -53
  193. package/src/OrgTransfer/locales.ts +0 -25
  194. package/src/OrgTransfer/selector.tsx +0 -252
  195. package/src/OrgTransfer/type.ts +0 -31
  196. package/src/PageScroller/index.tsx +0 -316
  197. package/src/PageScroller/story/FifthComponent.jsx +0 -7
  198. package/src/PageScroller/story/FirstComponent.jsx +0 -7
  199. package/src/PageScroller/story/FourthComponent.jsx +0 -7
  200. package/src/PageScroller/story/FullPage.jsx +0 -55
  201. package/src/PageScroller/story/PageContain.jsx +0 -59
  202. package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
  203. package/src/PageScroller/story/SecondComponent.jsx +0 -7
  204. package/src/PageScroller/story/ThirdComponent.jsx +0 -7
  205. package/src/PageScroller/story/index.css +0 -115
  206. package/src/PageScroller/usePrevValue.ts +0 -11
  207. package/src/Passport/index.ts +0 -3
  208. package/src/Passport/passport.tsx +0 -118
  209. package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
  210. package/src/PhoneInput/country-select.tsx +0 -148
  211. package/src/PhoneInput/index.tsx +0 -269
  212. package/src/PoweredByArcBlock/index.tsx +0 -27
  213. package/src/PricingTable/PricingPlan.tsx +0 -120
  214. package/src/PricingTable/PricingTable.stories.jsx +0 -38
  215. package/src/PricingTable/index.tsx +0 -59
  216. package/src/QRCode/QRCode.stories.jsx +0 -13
  217. package/src/QRCode/index.tsx +0 -66
  218. package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
  219. package/src/RelativeTime/index.tsx +0 -334
  220. package/src/Result/Result.stories.jsx +0 -61
  221. package/src/Result/common.tsx +0 -119
  222. package/src/Result/index.tsx +0 -30
  223. package/src/Result/result.tsx +0 -65
  224. package/src/Result/translations.ts +0 -57
  225. package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
  226. package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
  227. package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
  228. package/src/Screenshot/Screenshot.stories.jsx +0 -44
  229. package/src/Screenshot/devices.css +0 -1366
  230. package/src/Screenshot/index.tsx +0 -300
  231. package/src/SessionBlocklet/index.tsx +0 -178
  232. package/src/SessionManager/SessionManager.stories.jsx +0 -9
  233. package/src/SessionManager/index.tsx +0 -3
  234. package/src/SessionPermission/index.tsx +0 -26
  235. package/src/SessionUser/components/did-space.tsx +0 -68
  236. package/src/SessionUser/components/logged-in.tsx +0 -338
  237. package/src/SessionUser/components/quick-login-item.tsx +0 -132
  238. package/src/SessionUser/components/session-user-item.tsx +0 -93
  239. package/src/SessionUser/components/session-user-switch.tsx +0 -240
  240. package/src/SessionUser/components/un-login.tsx +0 -257
  241. package/src/SessionUser/components/user-info.tsx +0 -201
  242. package/src/SessionUser/index.tsx +0 -68
  243. package/src/SessionUser/libs/translation.ts +0 -30
  244. package/src/SessionUser/libs/utils.ts +0 -39
  245. package/src/SharedBridge/index.tsx +0 -126
  246. package/src/SocialShare/index.tsx +0 -194
  247. package/src/Sparkline/Sparkline.stories.jsx +0 -13
  248. package/src/Sparkline/index.tsx +0 -231
  249. package/src/Spinner/Spinner.stories.jsx +0 -98
  250. package/src/Spinner/index.tsx +0 -20
  251. package/src/SplitButton/SplitButton.stories.jsx +0 -32
  252. package/src/SplitButton/index.tsx +0 -116
  253. package/src/SplitButton/useClickAway.tsx +0 -24
  254. package/src/Success/index.tsx +0 -175
  255. package/src/Switch/Switch.stories.jsx +0 -16
  256. package/src/Switch/index.jsx +0 -79
  257. package/src/Tabs/Tabs.stories.jsx +0 -18
  258. package/src/Tabs/index.tsx +0 -255
  259. package/src/Tag/Tag.stories.jsx +0 -15
  260. package/src/Tag/index.jsx +0 -106
  261. package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
  262. package/src/TextCollapse/index.tsx +0 -85
  263. package/src/Theme/Theme.stories.jsx +0 -11
  264. package/src/Theme/index.ts +0 -21
  265. package/src/Theme/theme-provider.tsx +0 -374
  266. package/src/Theme/theme.ts +0 -229
  267. package/src/Toast/Toast.stories.jsx +0 -28
  268. package/src/Toast/index.tsx +0 -80
  269. package/src/Typography/index.tsx +0 -124
  270. package/src/UserCard/Cards/avatar-only.tsx +0 -27
  271. package/src/UserCard/Cards/basic-info.tsx +0 -43
  272. package/src/UserCard/Cards/index.tsx +0 -16
  273. package/src/UserCard/Cards/social-actions.tsx +0 -196
  274. package/src/UserCard/Container/card.tsx +0 -63
  275. package/src/UserCard/Container/dialog.tsx +0 -37
  276. package/src/UserCard/Content/basic.tsx +0 -330
  277. package/src/UserCard/Content/clock.tsx +0 -82
  278. package/src/UserCard/Content/minimal.tsx +0 -113
  279. package/src/UserCard/Content/shorten-label.tsx +0 -32
  280. package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
  281. package/src/UserCard/UserCard.stories.jsx +0 -19
  282. package/src/UserCard/components.tsx +0 -81
  283. package/src/UserCard/index.tsx +0 -132
  284. package/src/UserCard/types.ts +0 -165
  285. package/src/UserCard/use-follow.tsx +0 -111
  286. package/src/UserCard/utils.ts +0 -155
  287. package/src/Util/WebWalletOpener.stories.jsx +0 -5
  288. package/src/Util/client.ts +0 -4
  289. package/src/Util/constant.ts +0 -60
  290. package/src/Util/deprecate.tsx +0 -29
  291. package/src/Util/federated.ts +0 -125
  292. package/src/Util/iframe.ts +0 -19
  293. package/src/Util/index.ts +0 -760
  294. package/src/Util/logger.ts +0 -44
  295. package/src/Util/passport.ts +0 -127
  296. package/src/Util/security.ts +0 -72
  297. package/src/Util/style.ts +0 -17
  298. package/src/Util/wallet.ts +0 -35
  299. package/src/VerificationCode/index.tsx +0 -83
  300. package/src/Video/Video.stories.jsx +0 -6
  301. package/src/Video/index.tsx +0 -70
  302. package/src/Wallet/Action.stories.jsx +0 -8
  303. package/src/Wallet/Action.tsx +0 -118
  304. package/src/Wallet/Download.stories.jsx +0 -9
  305. package/src/Wallet/Download.tsx +0 -157
  306. package/src/Wallet/Open.tsx +0 -47
  307. package/src/Wallet/OpenInWallet.stories.jsx +0 -5
  308. package/src/Wallet/images/abtwallet.png +0 -0
  309. package/src/Wallet/images/android_download.svg +0 -22
  310. package/src/Wallet/images/app-store.svg +0 -30
  311. package/src/Wallet/images/google-play.svg +0 -69
  312. package/src/WalletOSIcon/index.tsx +0 -47
  313. package/src/WebWalletSWKeeper/index.tsx +0 -117
  314. package/src/WechatPrompt/images/android.png +0 -0
  315. package/src/WechatPrompt/images/ios.png +0 -0
  316. package/src/WechatPrompt/index.tsx +0 -75
  317. package/src/global.d.ts +0 -28
  318. package/src/hooks/use-blocklet-logo.tsx +0 -32
  319. package/src/hooks/use-clock.tsx +0 -62
  320. package/src/hooks/use-location-state.tsx +0 -117
  321. package/src/hooks/use-mobile.tsx +0 -6
  322. package/src/index.ts +0 -79
  323. package/src/type.d.ts +0 -44
  324. package/src/withTheme/index.tsx +0 -72
  325. package/src/withTracker/README.md +0 -37
  326. package/src/withTracker/action/bind-wallet.tsx +0 -17
  327. package/src/withTracker/action/login.tsx +0 -18
  328. package/src/withTracker/action/pay.tsx +0 -14
  329. package/src/withTracker/action/switch-passport.tsx +0 -20
  330. package/src/withTracker/constant/index.tsx +0 -3
  331. package/src/withTracker/env.tsx +0 -1
  332. package/src/withTracker/error_boundary.jsx +0 -34
  333. package/src/withTracker/index.tsx +0 -50
  334. package/src/withTracker/libs/utm.ts +0 -46
  335. package/vite.config.mjs +0 -37
@@ -1 +0,0 @@
1
- <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.171 36a3.067 3.067 0 0 1-2.24-.923C6.312 34.46 6 33.72 6 32.857V14c0-.864.31-1.604.932-2.22a3.067 3.067 0 0 1 2.24-.923h3.17c0-2.174.773-4.027 2.32-5.559C16.206 3.766 18.076 3 20.27 3c2.194 0 4.063.766 5.61 2.298 1.545 1.532 2.318 3.385 2.318 5.56h3.171a3.07 3.07 0 0 1 2.24.922c.621.616.931 1.356.931 2.22v18.857c0 .864-.31 1.604-.931 2.22a3.067 3.067 0 0 1-2.24.923H9.171zm6.343-25.143h9.513c0-1.31-.463-2.422-1.387-3.34-.925-.916-2.049-1.374-3.37-1.374-1.321 0-2.444.458-3.37 1.375-.924.917-1.386 2.03-1.386 3.34zM20.23 23.43c1.955 0 3.726-.642 5.311-1.925 1.586-1.284 2.366-2.724 2.34-4.322a1.62 1.62 0 0 0-.437-1.14 1.445 1.445 0 0 0-1.11-.47c-.37 0-.7.117-.99.353-.291.236-.503.59-.635 1.06a4.367 4.367 0 0 1-1.705 2.397c-.845.602-1.77.904-2.774.904-1.005 0-1.936-.302-2.795-.904-.859-.602-1.42-1.401-1.685-2.396-.132-.498-.33-.858-.594-1.08a1.428 1.428 0 0 0-.952-.335c-.449 0-.825.158-1.13.472a1.58 1.58 0 0 0-.455 1.14c0 1.597.78 3.037 2.339 4.32 1.559 1.284 3.316 1.926 5.272 1.926z" fill="url(#a)"/><defs><linearGradient id="a" x1="12.342" y1="13.214" x2="36.685" y2="39.361" gradientUnits="userSpaceOnUse"><stop stop-color="#FF73B2"/><stop offset=".333" stop-color="#E9ED7D"/><stop offset=".557" stop-color="#74E583"/><stop offset="1" stop-color="#01ACC8"/></linearGradient></defs></svg>
@@ -1 +0,0 @@
1
- <svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><rect width="98" height="98" rx="16" transform="matrix(1 0 0 -1 11 109)" fill="url(#b)"/><g filter="url(#c)"><path d="M60 80V40c-11.04 0-20 8.96-20 20s8.96 20 20 20z" fill="#fff" fill-opacity=".36" shape-rendering="crispEdges"/></g><path d="M60 100c-22.08 0-40-17.92-40-40s17.92-40 40-40 40 17.92 40 40-17.92 40-40 40zm0-60c-11.04 0-20 8.96-20 20s8.96 20 20 20 20-8.96 20-20-8.96-20-20-20z" fill="url(#d)" style="mix-blend-mode:plus-lighter"/></g><defs><linearGradient id="b" x1="7.273" y1="7.273" x2="90.152" y2="90.152" gradientUnits="userSpaceOnUse"><stop stop-color="#2563EB"/><stop offset=".333" stop-color="#2998FF"/><stop offset=".667" stop-color="#48E0A1"/><stop offset="1" stop-color="#9BEF2F"/></linearGradient><linearGradient id="d" x1="60" y1="100" x2="60" y2="20" gradientUnits="userSpaceOnUse"><stop stop-color="#C4C4C4"/><stop offset="1" stop-color="#7D7D7D"/></linearGradient><clipPath id="a"><rect width="98" height="98" rx="16" transform="matrix(1 0 0 -1 11 109)" fill="#fff"/></clipPath><filter id="c" x="-20" y="-20" width="140" height="160" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feGaussianBlur in="BackgroundImageFix" stdDeviation="30"/><feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_3296_9356"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dx="20"/><feGaussianBlur stdDeviation="20"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0.404508 0 0 0 0 0.283156 0 0 0 0.2 0"/><feBlend in2="effect1_backgroundBlur_3296_9356" result="effect2_dropShadow_3296_9356"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dx="10"/><feGaussianBlur stdDeviation="10"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0.404508 0 0 0 0 0.283156 0 0 0 0.05 0"/><feBlend in2="effect2_dropShadow_3296_9356" result="effect3_dropShadow_3296_9356"/><feBlend in="SourceGraphic" in2="effect3_dropShadow_3296_9356" result="shape"/></filter></defs></svg>
@@ -1 +0,0 @@
1
- <svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="9" y="9" width="102" height="102" rx="12" fill="url(#a)"/><mask id="b" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="9" y="9" width="102" height="102"><rect x="9" y="9" width="102" height="102" rx="12" fill="#fff"/></mask><g mask="url(#b)"><rect x="9" y="9" width="102" height="102" rx="12" fill="url(#c)"/><path d="M20.22 32.269a7.969 7.969 0 0 1 7.969-7.969H91.81a7.969 7.969 0 0 1 7.969 7.969V71.41a7.969 7.969 0 0 1-7.969 7.97H28.19a7.969 7.969 0 0 1-7.969-7.97V32.27z" fill="#9FCBFF"/><path d="M17.16 38.389a7.969 7.969 0 0 1 7.969-7.969H94.87a7.969 7.969 0 0 1 7.969 7.969V82.12a7.969 7.969 0 0 1-7.969 7.969H25.13a7.969 7.969 0 0 1-7.969-7.969V38.39z" fill="url(#d)"/><path d="M9 80.145 111 60.51V99c0 6.627-5.373 12-12 12H21c-6.627 0-12-5.373-12-12V80.145z" fill="url(#e)"/></g><path fill-rule="evenodd" clip-rule="evenodd" d="M21.84 54.153V39.44h7.781a3.791 3.791 0 0 1 3.528 3.782v7.138a3.791 3.791 0 0 1-3.791 3.792H21.84zM38.041 39.44h-2.02v14.734h2.02V39.441zm-14.18 12.691v-10.68h5.497c.978 0 1.77.793 1.77 1.771v7.138a1.77 1.77 0 0 1-1.77 1.771H23.86zm17.018-12.69v14.71h7.518a3.791 3.791 0 0 0 3.791-3.79v-7.139a3.791 3.791 0 0 0-3.528-3.782h-7.78zm13.88 3.413h2.259v2.259h-2.259v-2.259zm2.259 5.647h-2.259v2.259h2.259v-2.259zM42.9 41.452v10.68h5.497a1.77 1.77 0 0 0 1.77-1.77v-7.139a1.77 1.77 0 0 0-1.77-1.77H42.9z" fill="#4598FA"/><path fill-rule="evenodd" clip-rule="evenodd" d="M92.652 87.208v9.266l-.82.474 1.448.837.821-.474v-10.94l-6.945-4.01h-6.461v18.96h6.46l1.778-1.026-1.45-.837-.715.414h-4.624V83.81h4.624l5.884 3.397zm.96-4.846-1.774 1.025 1.449.836.714-.412h4.624v16.06H94l-5.884-3.397v-9.266l.823-.475-1.45-.837-.823.476V97.31l6.707 3.872c.156.09.334.138.515.138h6.185V82.36h-6.461z" fill="#fff"/><defs><linearGradient id="a" x1="9" y1="9" x2="9" y2="111" gradientUnits="userSpaceOnUse"><stop stop-color="#4F9DF6"/><stop offset="1" stop-color="#0A79F8"/></linearGradient><linearGradient id="c" x1="9" y1="9" x2="9" y2="111" gradientUnits="userSpaceOnUse"><stop stop-color="#4F9DF6"/><stop offset="1" stop-color="#0A79F8"/></linearGradient><linearGradient id="d" x1="17.16" y1="30.42" x2="17.16" y2="90.09" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#ECEFFF"/></linearGradient><linearGradient id="e" x1="20.156" y1="77.531" x2="26.73" y2="110.104" gradientUnits="userSpaceOnUse"><stop offset=".007" stop-color="#77B2F6"/><stop offset=".206" stop-color="#4F9DF6"/><stop offset="1" stop-color="#4598FA"/></linearGradient></defs></svg>
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 90 65" xmlns="http://www.w3.org/2000/svg"><path d="M79.425.7c5.688 0 10.3 4.612 10.3 10.3v43.234c0 5.689-4.612 10.3-10.3 10.3H11.156c-5.688 0-10.3-4.611-10.3-10.3v-.215h4.6v.215a5.7 5.7 0 0 0 5.7 5.7h68.269a5.7 5.7 0 0 0 5.7-5.7V11a5.7 5.7 0 0 0-5.7-5.7H11.156a5.7 5.7 0 0 0-5.7 5.7v.49h-4.6V11C.856 5.312 5.468.7 11.156.7h68.269zM11.293 17.691c2.945 0 5.495.62 7.65 1.86 2.182 1.211 3.879 2.929 5.088 5.154 1.21 2.225 1.814 4.845 1.814 7.86 0 2.985-.604 5.577-1.814 7.774a12.78 12.78 0 0 1-5.088 5.112c-2.155 1.211-4.706 1.818-7.65 1.818H1V17.69h10.293zM35.206 47.27h-5.324V17.69h5.324v29.58zm15.677-29.58c2.944 0 5.494.62 7.65 1.86 2.182 1.21 3.878 2.929 5.087 5.154 1.21 2.225 1.815 4.846 1.815 7.86 0 2.985-.606 5.577-1.815 7.774a12.78 12.78 0 0 1-5.087 5.112c-2.156 1.211-4.706 1.818-7.65 1.818H40.59V17.69h10.293zm22.595 19.066a2.98 2.98 0 1 1-.001 5.958 2.98 2.98 0 0 1 .001-5.958zM6.325 42.494h4.812c2.97 0 5.257-.874 6.861-2.62 1.604-1.775 2.405-4.211 2.405-7.31 0-3.126-.801-5.591-2.405-7.394-1.604-1.803-3.89-2.704-6.861-2.704H6.324v20.028zm39.59 0h4.81c2.971 0 5.26-.873 6.863-2.62 1.603-1.775 2.405-4.211 2.405-7.31 0-3.126-.801-5.591-2.405-7.394-1.604-1.803-3.892-2.704-6.862-2.704h-4.81v20.028zm27.564-19.637a2.978 2.978 0 1 1 0 5.957 2.978 2.978 0 0 1 0-5.957z" fill="currentColor"/></svg>
@@ -1 +0,0 @@
1
- <svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg"><path opacity=".8" d="M14.291 102.867c0 3.431 3.59 5.18 5.74 2.796l54.861-60.857-15.332-31.49H14.291v89.551z" fill="url(#a)"/><path opacity=".8" d="M105.709 17.849c0-3.429-3.585-5.178-5.736-2.8l-54.87 60.709 15.337 31.489h45.269V17.849z" fill="url(#b)"/><path opacity=".8" d="m105.709 107.247-45.867-93.93h-45.55l46.148 93.93h45.269z" fill="url(#c)"/><defs><linearGradient id="a" x1="58.95" y1="13.563" x2="1.148" y2="99.881" gradientUnits="userSpaceOnUse"><stop stop-color="#FF44B4"/><stop offset="1" stop-color="#FFAB48"/></linearGradient><linearGradient id="b" x1="105.788" y1="13.563" x2="48.861" y2="100.72" gradientUnits="userSpaceOnUse"><stop stop-color="#44B3FF"/><stop offset="1" stop-color="#A448FF"/></linearGradient><linearGradient id="c" x1="38.636" y1="11.296" x2="95.518" y2="102.845" gradientUnits="userSpaceOnUse"><stop stop-color="#FF44A9"/><stop offset="1" stop-color="#7452FA"/></linearGradient></defs></svg>
Binary file
@@ -1 +0,0 @@
1
- <svg width="76" height="76" viewBox="0 0 76 76" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 15a2 2 0 0 0-2 2v3.176H0V17a6 6 0 0 1 6-6h63.23a6 6 0 0 1 6 6v42.069a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6v-2.945h4v2.945a2 2 0 0 0 2 2h63.23a2 2 0 0 0 2-2V17a2 2 0 0 0-2-2H6z" fill="#4598FA"/><circle cx="32" cy="31" r="10" stroke="#4598FA" stroke-width="4"/><path d="m40.688 48.384 5.602 5.602 10.343-10.343m-6.966-5.073c3.253 0 5.891-3.166 5.891-7.07 0-3.905-2.638-7.07-5.891-7.07M32 41h-7.147a7 7 0 0 0-7 7v7.065" stroke="#4598FA" stroke-width="4"/></svg>
@@ -1 +0,0 @@
1
- <svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="a" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="120" height="120"><path fill="#fff" d="M0 0h119.883v119.883H0z"/></mask><g mask="url(#a)"><path d="M62.025 14.05A5.05 5.05 0 0 1 67.075 9h23.988a5.05 5.05 0 0 1 5.05 5.05v60.6a5.05 5.05 0 0 1-5.05 5.05H67.075a5.05 5.05 0 0 1-5.05-5.05v-60.6z" fill="url(#b)"/><path d="M24.15 32.987a5.05 5.05 0 0 1 5.05-5.05h40.4a5.05 5.05 0 0 1 5.05 5.05V74.65a5.05 5.05 0 0 1-5.05 5.05H29.2a5.05 5.05 0 0 1-5.05-5.05V32.987z" fill="url(#c)"/><g filter="url(#d)"><path d="M16.575 64.55c0-5.578 4.522-10.1 10.1-10.1h64.388c5.578 0 10.1 4.522 10.1 10.1V99.9c0 5.578-4.522 10.1-10.1 10.1H26.675c-5.578 0-10.1-4.522-10.1-10.1V64.55z" fill="url(#e)"/></g><g filter="url(#f)"><path d="M10.263 55.712a7.575 7.575 0 0 1 7.575-7.575H99.9a7.575 7.575 0 0 1 7.575 7.575v10.1a7.575 7.575 0 0 1-7.575 7.575H17.838a7.575 7.575 0 0 1-7.575-7.575v-10.1z" fill="url(#g)"/></g><circle cx="58.869" cy="87.906" r="6.944" fill="#6BADFF"/></g><defs><linearGradient id="b" x1="86.013" y1="9" x2="86.644" y2="46.875" gradientUnits="userSpaceOnUse"><stop stop-color="#FF7575"/><stop offset="1" stop-color="#C91C1C"/></linearGradient><linearGradient id="c" x1="49.4" y1="56.975" x2="49.4" y2="27.938" gradientUnits="userSpaceOnUse"><stop stop-color="#ED7F1A"/><stop offset="1" stop-color="#FFE074"/></linearGradient><linearGradient id="e" x1="16.575" y1="75.281" x2="101.163" y2="114.419" gradientUnits="userSpaceOnUse"><stop stop-color="#54A0FD"/><stop offset="1" stop-color="#136EDE"/></linearGradient><linearGradient id="g" x1="16.575" y1="55.712" x2="58.789" y2="111.945" gradientUnits="userSpaceOnUse"><stop stop-color="#83BAFF"/><stop offset="1" stop-color="#2482F6"/></linearGradient><filter id="d" x="16.575" y="54.45" width="86.587" height="57.55" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feMorphology radius="4" in="SourceAlpha" result="effect1_innerShadow_3296_9286"/><feOffset dx="2" dy="2"/><feGaussianBlur stdDeviation="3"/><feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/><feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.25 0"/><feBlend in2="shape" result="effect1_innerShadow_3296_9286"/></filter><filter id="f" x="10.263" y="48.138" width="99.212" height="27.25" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feMorphology radius="4" in="SourceAlpha" result="effect1_innerShadow_3296_9286"/><feOffset dx="2" dy="2"/><feGaussianBlur stdDeviation="3"/><feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/><feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.25 0"/><feBlend in2="shape" result="effect1_innerShadow_3296_9286"/></filter></defs></svg>
@@ -1,3 +0,0 @@
1
- // eslint-disable-next-line no-restricted-exports
2
- export { default } from './nav-menu';
3
- export { default as Products, type ProductsType, type ProductsProps } from './products';
@@ -1,30 +0,0 @@
1
- import { createContext, use } from 'react';
2
-
3
- export type NavMenuContextValue = {
4
- activeId: string | null;
5
- openedIds: string[];
6
- hiddenItemCount: number;
7
- mode: 'horizontal' | 'vertical' | 'inline';
8
- textColor: string;
9
- activeTextColor: string;
10
- bgColor: string;
11
- activate: (id: string) => void;
12
- open: (id: string) => void;
13
- close: (id: string) => void;
14
- };
15
-
16
- const NavMenuContext = createContext<NavMenuContextValue | null>(null);
17
-
18
- export function NavMenuProvider({ value, children }: { value: NavMenuContextValue; children: React.ReactNode }) {
19
- return <NavMenuContext value={value}>{children}</NavMenuContext>;
20
- }
21
-
22
- export function useNavMenuContext() {
23
- const context = use(NavMenuContext);
24
-
25
- if (!context) {
26
- throw new Error('NavMenuContext is not found');
27
- }
28
-
29
- return context;
30
- }
@@ -1,441 +0,0 @@
1
- import { Children, cloneElement, useEffect, useRef, useLayoutEffect, isValidElement } from 'react';
2
- import { ClickAwayListener, type SxProps } from '@mui/material';
3
- import clsx from 'clsx';
4
- import {
5
- MoreHoriz as MoreHorizIcon,
6
- ExpandMore as ExpandMoreIcon,
7
- Menu as MenuIcon,
8
- ArrowForward as ArrowForwardIcon,
9
- } from '@mui/icons-material';
10
- import { useCreation, useMemoizedFn, useReactive, useSize, useThrottleFn } from 'ahooks';
11
- import noop from 'lodash/noop';
12
- import { NavMenuProvider, useNavMenuContext } from './nav-menu-context';
13
- import { NavMenuRoot, NavMenuItem, NavMenuSub, NavMenuSubList, NavMenuStyled } from './style';
14
- import { SubContainer } from './sub-container';
15
- import { useTheme } from '../Theme';
16
-
17
- // 过滤 children 中的 Item/Sub, 忽略其它类型的 element
18
- function filterItems(children: React.ReactNode) {
19
- if (children) {
20
- // eslint-disable-next-line no-use-before-define
21
- return Children.toArray(children).filter((child) => {
22
- if (!isValidElement(child)) {
23
- return false;
24
- }
25
- return child.type === Item || child.type === Sub;
26
- }) as React.ReactElement<any>[];
27
- }
28
- return null;
29
- }
30
-
31
- function useUniqueId(id?: string) {
32
- const _id = useRef(id || `navmenu-item-id-${Math.random().toString(36).slice(2)}`);
33
- return _id.current;
34
- }
35
-
36
- export type ItemOptions = {
37
- id?: string;
38
- icon?: React.ReactNode;
39
- label?: React.ReactNode;
40
- description?: React.ReactNode;
41
- active?: boolean;
42
- variant?: 'default' | 'panel';
43
- children?: ItemOptions[];
44
- };
45
-
46
- export interface NavMenuProps extends React.HTMLAttributes<HTMLElement> {
47
- items?: ItemOptions[];
48
- mode?: 'horizontal' | 'vertical' | 'inline';
49
- children?: React.ReactNode;
50
- activeId?: string | null;
51
- textColor?: string;
52
- activeTextColor?: string;
53
- bgColor?: string;
54
- onSelected?: (id: string) => void;
55
- sx?: SxProps;
56
- }
57
-
58
- /**
59
- * NavMenu, 导航组件, 可用于 header/footer/sidebar
60
- */
61
- function NavMenu({
62
- items = [],
63
- mode = 'horizontal',
64
- children: _childs = null,
65
- activeId = null,
66
- // eslint-disable-next-line react/require-default-props
67
- textColor,
68
- // eslint-disable-next-line react/require-default-props
69
- activeTextColor,
70
- // eslint-disable-next-line react/require-default-props
71
- bgColor,
72
- onSelected = undefined,
73
- ...rest
74
- }: NavMenuProps) {
75
- const theme = useTheme();
76
- const $textColor = useCreation(() => theme.palette.text.secondary, [theme]);
77
- const $activeTextColor = useCreation(() => theme.palette.text.primary, [theme]);
78
- const $bgColor = useCreation(() => theme.palette.background.default, [theme]);
79
- // eslint-disable-next-line no-param-reassign
80
- const children = filterItems(_childs);
81
- if (!items?.length && !children?.length) {
82
- throw new Error("One of 'items' or 'children' is required by NavMenu component.");
83
- }
84
- const currentState = useReactive({
85
- activeId,
86
- openedIds: [] as string[],
87
- hiddenItemCount: 0,
88
- });
89
-
90
- const activate = useMemoizedFn((id) => {
91
- currentState.activeId = id;
92
- onSelected?.(id);
93
- });
94
- const open = useMemoizedFn((id: string) => {
95
- currentState.openedIds.push(id);
96
- });
97
- const close = useMemoizedFn((id) => {
98
- currentState.openedIds = currentState.openedIds.filter((item) => item !== id);
99
- });
100
-
101
- const contextValue = useCreation(() => {
102
- return {
103
- ...currentState,
104
- mode,
105
- textColor: $textColor,
106
- activeTextColor: $activeTextColor,
107
- bgColor: $bgColor,
108
- activate,
109
- open,
110
- close,
111
- };
112
- }, [
113
- currentState.activeId,
114
- currentState.hiddenItemCount,
115
- currentState.openedIds,
116
- mode,
117
- $textColor,
118
- $activeTextColor,
119
- $bgColor,
120
- activate,
121
- open,
122
- close,
123
- ]);
124
-
125
- const navMenuRef = useRef<HTMLUListElement | null>(null);
126
- const itemRefs = useRef<HTMLElement[]>([]);
127
- const moreIconRef = useRef<HTMLLIElement | null>(null);
128
- const containerWidth = useRef(0);
129
- const isAllItemsHidden = currentState.hiddenItemCount === itemRefs.current?.length;
130
- const style = isAllItemsHidden ? { marginLeft: '0px' } : undefined;
131
-
132
- const icon = useCreation(() => {
133
- return isAllItemsHidden ? <MenuIcon /> : <MoreHorizIcon />;
134
- }, [isAllItemsHidden]);
135
-
136
- const renderChildrenWithRef = (childrenElement: React.ReactElement<any>[]) => {
137
- return Children.map(childrenElement, (child, index) => {
138
- return cloneElement(child, {
139
- ref: (el: HTMLElement) => {
140
- itemRefs.current[index] = el;
141
- },
142
- });
143
- });
144
- };
145
-
146
- const containerSize = useSize(navMenuRef.current);
147
-
148
- const { run: checkItemsFit } = useThrottleFn(
149
- useMemoizedFn(() => {
150
- let totalWidthUsed = 0;
151
- let newHiddenCount = 0;
152
- let leftAllHidden = false;
153
- const moreIconWidth = moreIconRef.current
154
- ? moreIconRef.current.offsetWidth + parseFloat(window.getComputedStyle(moreIconRef.current).marginLeft)
155
- : 0;
156
-
157
- itemRefs.current.forEach((item, index) => {
158
- if (item) {
159
- item.style.display = 'flex';
160
- const marginLeft = index > 0 ? parseFloat(window.getComputedStyle(item).marginLeft) : 0;
161
- const currentItemWidth = item.offsetWidth + marginLeft;
162
-
163
- if (containerWidth.current - moreIconWidth >= totalWidthUsed + currentItemWidth && !leftAllHidden) {
164
- totalWidthUsed += currentItemWidth;
165
- } else {
166
- item.style.display = 'none';
167
- leftAllHidden = true;
168
- newHiddenCount++;
169
- }
170
- }
171
- });
172
-
173
- if (newHiddenCount !== currentState.hiddenItemCount) {
174
- currentState.hiddenItemCount = newHiddenCount;
175
- }
176
- }),
177
- { wait: 100 }
178
- );
179
-
180
- useLayoutEffect(() => {
181
- containerWidth.current = containerSize?.width || navMenuRef.current?.clientWidth || 0;
182
- if (mode === 'horizontal') {
183
- checkItemsFit();
184
- }
185
- // eslint-disable-next-line react-hooks/exhaustive-deps
186
- }, [containerSize?.width, mode]);
187
-
188
- useEffect(() => {
189
- if (mode === 'horizontal') {
190
- checkItemsFit();
191
- window.addEventListener('resize', checkItemsFit);
192
-
193
- return () => {
194
- window.removeEventListener('resize', checkItemsFit);
195
- };
196
- }
197
- return undefined;
198
- // eslint-disable-next-line react-hooks/exhaustive-deps
199
- }, [mode, items]);
200
-
201
- useEffect(() => {
202
- // NavMenu#activeId 和 Item#active prop 都可以用来控制激活状态 (一般不会混用这两种方式)
203
- // 如果未传入 NavMenu#activeId, 应该避免设置一个空值的 activeId 状态 (会与 Item#active 冲突)
204
- if (activeId !== undefined && activeId !== null) {
205
- currentState.activeId = activeId;
206
- }
207
- // eslint-disable-next-line react-hooks/exhaustive-deps
208
- }, [activeId]);
209
-
210
- const classes = clsx('navmenu', `navmenu--${mode}`, rest.className);
211
-
212
- const renderItem = (item: ItemOptions, index: number, level = 0) => {
213
- const isTopLevel = level === 0;
214
-
215
- if (item?.children) {
216
- // 只渲染两级子菜单
217
- if (level > 0) {
218
- return null;
219
- }
220
-
221
- // 对于 Sub 组件,如果它是顶级组件,则包含 ref
222
- return (
223
- <Sub
224
- key={item.id}
225
- id={item.id}
226
- icon={item.icon}
227
- label={item.label}
228
- variant={isTopLevel ? 'default' : 'panel'}
229
- ref={
230
- isTopLevel
231
- ? (el: HTMLElement) => {
232
- itemRefs.current[index] = el!;
233
- }
234
- : undefined
235
- }>
236
- {typeof item.children === 'function'
237
- ? item.children
238
- : item.children.map((childItem, childIndex: number) =>
239
- renderItem({ ...childItem, variant: 'panel' }, childIndex, level + 1)
240
- )}
241
- </Sub>
242
- );
243
- }
244
-
245
- // 顶级 Item 组件总是包含 ref
246
- return (
247
- <Item
248
- key={item.id}
249
- id={item.id}
250
- icon={item.icon}
251
- label={item.label}
252
- description={item.description}
253
- active={item.active}
254
- variant={item.variant}
255
- ref={
256
- isTopLevel
257
- ? (el: HTMLElement) => {
258
- itemRefs.current[index] = el!;
259
- }
260
- : undefined
261
- }
262
- />
263
- );
264
- };
265
-
266
- const content = items
267
- ? items?.slice(-currentState.hiddenItemCount).map((item, index) => renderItem(item, index, 1))
268
- : children?.slice(-currentState.hiddenItemCount);
269
-
270
- // 当前展开的子菜单
271
- // const openedId = currentState.openedIds[0];
272
-
273
- return (
274
- <NavMenuProvider value={contextValue}>
275
- <NavMenuStyled {...rest} className={classes} $textColor={$textColor} $bgColor={$bgColor}>
276
- <NavMenuRoot className={clsx('navmenu-root', `navmenu-root--${mode}`)} ref={navMenuRef}>
277
- {items ? items.map((item, index) => renderItem(item, index)) : renderChildrenWithRef(children || [])}
278
- {currentState.hiddenItemCount > 0 && (
279
- <Sub expandIcon={false} icon={icon} label="" ref={moreIconRef} style={style}>
280
- {content}
281
- </Sub>
282
- )}
283
- </NavMenuRoot>
284
- </NavMenuStyled>
285
- </NavMenuProvider>
286
- );
287
- }
288
-
289
- export interface ItemProps extends React.HTMLAttributes<HTMLLIElement> {
290
- id?: string;
291
- icon?: React.ReactNode;
292
- label?: React.ReactNode;
293
- description?: React.ReactNode;
294
- active?: boolean;
295
- variant?: 'default' | 'panel';
296
- onClick?: () => void;
297
- }
298
-
299
- export function Item({
300
- ref = undefined,
301
- id: _id = '',
302
- icon = null,
303
- label = '',
304
- description = undefined,
305
- active = false,
306
- variant = 'default',
307
- onClick = noop,
308
- ...rest
309
- }: ItemProps & {
310
- ref?: React.Ref<unknown>;
311
- }) {
312
- const id = useUniqueId(_id);
313
- const { mode, activeId, activate, activeTextColor } = useNavMenuContext();
314
- const classes = clsx(
315
- 'navmenu-item',
316
- { 'navmenu-item--active': activeId === id },
317
- `navmenu-item--${mode}`,
318
- `navmenu-item--${variant}`,
319
- rest.className
320
- );
321
- useEffect(() => {
322
- if (active) {
323
- activate?.(id);
324
- }
325
- // eslint-disable-next-line react-hooks/exhaustive-deps
326
- }, [active]);
327
-
328
- const handleClick = () => {
329
- onClick?.();
330
- activate?.(id);
331
- };
332
-
333
- return (
334
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
335
- <NavMenuItem
336
- {...rest}
337
- className={classes}
338
- ref={ref as React.Ref<HTMLLIElement>}
339
- $activeTextColor={activeTextColor}
340
- onClick={handleClick}>
341
- {icon && <span className="navmenu-item__icon">{icon}</span>}
342
- <div className="navmenu-item__content">
343
- <span className="navmenu-item__label">
344
- {label} <ArrowForwardIcon className="navmenu-item__label-arrow" />
345
- </span>
346
- {description && <span className="navmenu-item__desc">{description}</span>}
347
- </div>
348
- </NavMenuItem>
349
- );
350
- }
351
- Item.displayName = 'NavMenu.Item';
352
-
353
- export interface SubProps extends Omit<ItemProps, 'children' | 'active'> {
354
- children?: Array<React.ReactElement<any> | null> | ((props: { isOpen: boolean }) => React.ReactElement<any> | null);
355
- expandIcon?: React.ReactNode | ((props: { isOpen: boolean }) => React.ReactNode);
356
- }
357
-
358
- export function Sub({
359
- ref = undefined,
360
- id: _id = '',
361
- icon = null,
362
- label = null,
363
- description,
364
- variant = 'default',
365
- children = undefined,
366
-
367
- expandIcon = ({ isOpen }) => (
368
- <ExpandMoreIcon
369
- style={{
370
- transform: `rotate(${isOpen ? 180 : 0}deg)`,
371
- }}
372
- />
373
- ),
374
-
375
- ...rest
376
- }: SubProps & {
377
- ref?: React.Ref<unknown>;
378
- }) {
379
- const id = useUniqueId(_id);
380
- const { openedIds, open, close, mode, activeTextColor } = useNavMenuContext();
381
- const isOpen = openedIds?.includes(id) ?? false;
382
- const isInlineMode = mode === 'inline';
383
- const classes = clsx(
384
- 'navmenu-sub',
385
- 'navmenu-item',
386
- { 'navmenu-item--panel': variant === 'panel' },
387
- { 'navmenu-sub--opened': isOpen, 'navmenu-item--inline': isInlineMode },
388
- rest.className
389
- );
390
-
391
- // 统一使用 click 事件控制收缩/伸展子菜单
392
- const props = {
393
- onClick: () => {
394
- if (openedIds?.includes(id)) {
395
- close?.(id);
396
- } else {
397
- open?.(id);
398
- }
399
- },
400
- };
401
- // inline mode, 避免点击子菜单项时触发父菜单的 open/close
402
- const containerProps = isInlineMode ? { onClick: (e: React.MouseEvent) => e.stopPropagation() } : {};
403
- const menu = (
404
- <NavMenuSub
405
- {...rest}
406
- className={classes}
407
- {...props}
408
- ref={ref as React.Ref<HTMLLIElement>}
409
- $activeTextColor={activeTextColor}>
410
- {icon && <span className="navmenu-item__icon">{icon}</span>}
411
- <div className="navmenu-item__content">
412
- <span className="navmenu-item__label">{label}</span>
413
- {description && <span className="navmenu-item__desc">{description}</span>}
414
- </div>
415
- {expandIcon && (
416
- <span className="navmenu-sub__expand-icon">
417
- {typeof expandIcon === 'function' ? expandIcon({ isOpen }) : expandIcon}
418
- </span>
419
- )}
420
- <SubContainer inline={isInlineMode} {...containerProps}>
421
- {typeof children === 'function' ? (
422
- children({ isOpen }) // 自定义渲染
423
- ) : (
424
- <NavMenuSubList className="navmenu-sub__list">{filterItems(children)}</NavMenuSubList>
425
- )}
426
- </SubContainer>
427
- </NavMenuSub>
428
- );
429
-
430
- if (isInlineMode) {
431
- return menu;
432
- }
433
-
434
- return <ClickAwayListener onClickAway={() => close?.(id)}>{menu}</ClickAwayListener>;
435
- }
436
- Sub.displayName = 'NavMenu.Sub';
437
-
438
- NavMenu.Item = Item;
439
- NavMenu.Sub = Sub;
440
-
441
- export default NavMenu;