@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,223 +0,0 @@
1
- import '@fontsource/ubuntu-mono/400.css';
2
- import { Check as CheckIcon } from '@mui/icons-material';
3
- import { Box, BoxProps, Tooltip } from '@mui/material';
4
- import copy from 'copy-to-clipboard';
5
- import noop from 'lodash/noop';
6
- import CopyIcon from '@arcblock/icons/lib/Copy';
7
- import React, { ReactNode, useImperativeHandle, useRef, useState } from 'react';
8
- import { styled } from '../Theme';
9
- import { getFontSize } from '../Util';
10
- import CompactText from './compact-text';
11
- import type { Locale, Translations } from '../type';
12
-
13
- const translations: Translations = {
14
- en: {
15
- copy: 'Click To Copy',
16
- copied: 'Copied!',
17
- },
18
- zh: {
19
- copy: '点击复制',
20
- copied: '已复制!',
21
- },
22
- };
23
-
24
- export interface HTMLDidAddressElement extends HTMLDivElement {
25
- copy: () => void;
26
- getEl: () => HTMLDivElement;
27
- }
28
- export interface IDidAddressProps extends BoxProps {
29
- component?: React.ElementType;
30
- size?: number;
31
- copyable?: true | false;
32
- // compact mode 下, hover 时会在 tooltip 中显示完整地址, showCopyButtonInTooltip = true 时会在完整地址后显示一个复制按钮
33
- showCopyButtonInTooltip?: false | true;
34
- content?: string;
35
- inline?: false | true;
36
- prepend?: ReactNode;
37
- append?: ReactNode;
38
- // 紧凑模式
39
- compact?: false | true;
40
- startChars?: number;
41
- endChars?: number;
42
- locale?: Locale;
43
- }
44
-
45
- /**
46
- * DidAddress 组件 (新版设计)
47
- *
48
- * - 样式调整
49
- * - click-to-copy 调整
50
- * - 长文本截断处理 (Ellipsis)
51
- * - 支持 inline 或 block 的显示方式
52
- * - 支持紧凑模式, 该模式下:
53
- * - 占用宽度较小, 因此不考虑水平空间不够用的情况, 且忽略末尾省略号
54
- * - 对于多层元素结构的 children, 保持元素结构, 将最内层 text 替换为 CompactText 组件
55
- * - 为保证 copy 功能正常工作, 原 children 始终渲染, 但在紧凑式下会隐藏
56
- * - 可配合 useMediaQuery 使用
57
- */
58
- function DidAddress({
59
- ref = undefined,
60
- ...props
61
- }: IDidAddressProps & {
62
- ref?: React.Ref<unknown>;
63
- }) {
64
- const {
65
- component = 'span',
66
- size = 0,
67
- copyable = true,
68
- showCopyButtonInTooltip = false,
69
- children = null,
70
- content = '',
71
- prepend = null,
72
- append = null,
73
- compact = false,
74
- startChars = 6,
75
- endChars = 6,
76
- locale: originalLocale = 'en',
77
- ...rest
78
- } = props;
79
- let locale = originalLocale;
80
- if (!translations[locale]) {
81
- locale = 'en';
82
- }
83
-
84
- const [copied, setCopied] = useState(false);
85
- const textRef = useRef<HTMLDivElement>(null);
86
- const rootRef = useRef<any>(null);
87
-
88
- const handleCopy = () => {
89
- copy(content || textRef.current?.textContent || '');
90
- setCopied(true);
91
- // 恢复 copied 状态
92
- setTimeout(() => {
93
- setCopied(false);
94
- }, 1500);
95
- };
96
- const onCopy = (e: any) => {
97
- e.stopPropagation();
98
- e.preventDefault();
99
- handleCopy();
100
- };
101
- useImperativeHandle(
102
- ref,
103
- () =>
104
- new Proxy(
105
- {
106
- copy: handleCopy,
107
- getEl: () => rootRef.current,
108
- },
109
- {
110
- get(target: any, key: string) {
111
- return target[key] || rootRef.current?.[key];
112
- },
113
- }
114
- )
115
- );
116
-
117
- let copyElement = null;
118
- if (copyable) {
119
- copyElement = (
120
- <span className="did-address-copy-wrapper" title={copied ? '' : translations[locale].copy}>
121
- {copied ? (
122
- <Tooltip title={translations[locale].copied} placement="bottom" arrow open={copied}>
123
- <CheckIcon className="did-address-copy" sx={{ color: 'success.main' }} />
124
- </Tooltip>
125
- ) : (
126
- /* title prop 直接加在 icon 上不生效 */
127
- <CopyIcon className="did-address-copy" width="1em" height="1em" onClick={onCopy} />
128
- )}
129
- </span>
130
- );
131
- }
132
-
133
- return (
134
- <Root as={component} size={size} {...rest} ref={rootRef}>
135
- {prepend}
136
- <Box sx={{ display: 'none' }} ref={textRef}>
137
- {children}
138
- </Box>
139
- {/* 注意: 该元素必须渲染(可以隐藏), 以便 compact 模式下复制的文本是完整的 */}
140
- <Tooltip title={copyable ? '' : translations[locale].copied} placement="bottom" arrow open={copied}>
141
- {compact ? (
142
- <Box
143
- component="span"
144
- className="did-address-text"
145
- sx={{
146
- cursor: copyable ? 'unset' : 'pointer',
147
- }}
148
- onDoubleClick={copyable ? noop : onCopy}>
149
- <CompactText startChars={startChars} endChars={endChars} showCopyButtonInTooltip={showCopyButtonInTooltip}>
150
- {children}
151
- </CompactText>
152
- </Box>
153
- ) : (
154
- <Box
155
- component="span"
156
- className="did-address-text did-address-truncate"
157
- sx={{
158
- display: compact ? 'none' : 'inline',
159
- cursor: copyable ? 'unset' : 'pointer',
160
- }}
161
- onDoubleClick={copyable ? noop : onCopy}>
162
- {children}
163
- </Box>
164
- )}
165
- </Tooltip>
166
- {copyElement}
167
- {append}
168
- </Root>
169
- );
170
- }
171
-
172
- export default DidAddress;
173
-
174
- const Root = styled<any>(Box, { shouldForwardProp: (prop) => prop !== 'inline' })`
175
- font-family: 'Ubuntu Mono', monospace;
176
- && {
177
- display: ${({ inline }: any) => (inline ? 'inline-flex' : 'flex')};
178
- align-items: center;
179
- max-width: 100%;
180
- overflow: hidden;
181
- color: #ccc;
182
- font-size: ${(props: any) => getFontSize(props.size)};
183
- font-weight: 400;
184
-
185
- svg {
186
- fill: currentColor;
187
- }
188
- }
189
-
190
- .did-address-text {
191
- color: ${({ theme }) => theme.palette.text.secondary};
192
- }
193
- /* truncate string with ellipsis */
194
- .did-address-truncate {
195
- white-space: nowrap;
196
- overflow: hidden;
197
- text-overflow: ellipsis;
198
- }
199
-
200
- .did-address-copy-wrapper {
201
- display: flex;
202
- justify-content: center;
203
- align-items: center;
204
- width: 1em;
205
- height: 1em;
206
- margin-left: 8px;
207
- }
208
- .did-address-copy {
209
- flex: 0 0 auto;
210
- font-size: 1em;
211
- color: ${({ theme }) => theme.palette.text.secondary};
212
- cursor: pointer;
213
- }
214
-
215
- /* link */
216
- a {
217
- color: ${({ theme }) => theme.palette.text.secondary};
218
- }
219
- &:hover a {
220
- color: ${({ theme }) => theme.palette.text.primary};
221
- text-decoration: underline;
222
- }
223
- `;
@@ -1,21 +0,0 @@
1
- import DidAddress, { IDidAddressProps } from './did-address';
2
- import ResponsiveDidAddress from './responsive-did-address';
3
-
4
- export interface IDidAddressWrapper extends IDidAddressProps {
5
- responsive?: true | false;
6
- }
7
-
8
- function DidAddressWrapper({
9
- ref = undefined,
10
- responsive = true,
11
- ...rest
12
- }: IDidAddressWrapper & {
13
- ref?: React.Ref<unknown>;
14
- }) {
15
- if (responsive) {
16
- return <ResponsiveDidAddress {...rest} ref={ref} />;
17
- }
18
- return <DidAddress {...rest} ref={ref} />;
19
- }
20
-
21
- export default DidAddressWrapper;
@@ -1,154 +0,0 @@
1
- import { useDebounceFn, useLatest } from 'ahooks';
2
- import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
3
- import { Box } from '@mui/material';
4
- import { styled } from '../Theme';
5
- import DidAddress, { HTMLDidAddressElement, IDidAddressProps } from './did-address';
6
- import { getFontSize } from '../Util';
7
-
8
- /**
9
- * 根据父容器宽度自动切换 compact 模式
10
- *
11
- * 实现逻辑:
12
- * - DidAddress 外层包裹一个容器, 其宽度自动撑满父容器宽度 (即这个容器需要是块级元素或 100% 宽的 inline-block)
13
- * - DidAddress 本身以 inline 形式渲染 (方便探测 did-address 的 full-width)
14
- * - 组件 mounted 时记录 did address 的 full-width (非 compact 模式的宽度)
15
- * - 监听容器宽度变化, 当容器宽度变化时, 对比容器宽度和 did address full-width, => 切换 compact 模式
16
- */
17
- export default function ResponsiveDidAddress({
18
- ref = undefined,
19
- style = {},
20
- className = undefined,
21
- component = 'span',
22
- size = 0,
23
- ...rest
24
- }: IResponsiveDidAddressProps & {
25
- ref?: React.Ref<unknown>;
26
- }) {
27
- const [compact, setCompact] = useState(false);
28
- const isCompact = useLatest(compact);
29
- // did address 完整显示时的宽度
30
- const [addressFullWidth, setAddressFullWidth] = useState<number | null | undefined>(null);
31
- const [containerWidth, setContainerWidth] = useState<number | null | undefined>(null);
32
- const [loading, setLoading] = useState(true);
33
- const { run: delaySetLoadingFalse } = useDebounceFn(() => setLoading(false), {
34
- wait: 50,
35
- });
36
- const containerRef = useRef<HTMLDivElement>(null);
37
- const innerRef = useRef<HTMLDidAddressElement>(null);
38
-
39
- useImperativeHandle(
40
- ref,
41
- () =>
42
- new Proxy(
43
- {},
44
- {
45
- get(target: any, key: keyof HTMLDidAddressElement) {
46
- return innerRef.current?.[key];
47
- },
48
- }
49
- )
50
- );
51
-
52
- // 存储完整显示时 address 组件的宽度
53
- useEffect(() => {
54
- const innerWidth = innerRef.current?.offsetWidth || 0;
55
- let innerObserver: ResizeObserver | null = null;
56
- let containerObserver: ResizeObserver | null = null;
57
-
58
- // 初始化宽度
59
- setAddressFullWidth(innerWidth);
60
- setContainerWidth(containerRef.current?.offsetWidth);
61
-
62
- // 由于自定义字体的缘故,innerRef 的初始宽度可能发生二次改变,使用 observer 监听捕获
63
- innerObserver = new ResizeObserver(() => {
64
- if (!isCompact.current && innerRef.current?.offsetWidth !== innerWidth) {
65
- setAddressFullWidth(innerRef.current?.offsetWidth);
66
- delaySetLoadingFalse();
67
- }
68
- });
69
- containerObserver = new ResizeObserver(() => {
70
- setContainerWidth(containerRef.current?.offsetWidth);
71
- });
72
-
73
- innerObserver.observe(innerRef.current!.getEl());
74
- containerObserver.observe(containerRef.current!);
75
- delaySetLoadingFalse();
76
-
77
- return () => {
78
- innerObserver?.disconnect();
79
- containerObserver?.disconnect();
80
- };
81
- // eslint-disable-next-line react-hooks/exhaustive-deps
82
- }, []);
83
-
84
- useEffect(() => {
85
- if (containerWidth && addressFullWidth) {
86
- setCompact(containerWidth < addressFullWidth);
87
- }
88
- }, [containerWidth, addressFullWidth]);
89
-
90
- return (
91
- <Root
92
- as={component}
93
- ref={containerRef}
94
- style={style}
95
- className={className}
96
- size={size}
97
- {...(component === 'span'
98
- ? {}
99
- : {
100
- inline: rest.inline,
101
- })}>
102
- <StyledDidAddress
103
- style={{
104
- position: loading ? 'absolute' : 'static',
105
- left: loading ? '-99999px' : 'auto',
106
- }}
107
- {...rest}
108
- size={size}
109
- component={component}
110
- inline
111
- compact={compact}
112
- ref={innerRef}
113
- />
114
- {/* placeholder */}
115
- {loading && <div style={{ width: '100%', height: `${(size || 16) * 1.5}px` }} />}
116
- </Root>
117
- );
118
- }
119
-
120
- export interface IResponsiveDidAddressProps extends IDidAddressProps {
121
- style?: React.CSSProperties;
122
- className?: string;
123
- component?: React.ElementType;
124
- }
125
-
126
- type RootProps = {
127
- size: number;
128
- inline?: boolean;
129
- };
130
-
131
- const Root = styled(Box, { shouldForwardProp: (prop) => prop !== 'size' })<RootProps>`
132
- display: block;
133
- width: 100%; /* flex & column & align-items: flex-start 时, 块级元素不会自动铺满容器 */
134
- font-size: ${({ size }) => getFontSize(size)};
135
- overflow: hidden;
136
- ${({ inline }) =>
137
- inline &&
138
- `
139
- display: inline-block;
140
- width: 100%;
141
- `}
142
- `;
143
-
144
- const StyledDidAddress = styled(DidAddress)`
145
- && {
146
- max-width: none;
147
- }
148
- .did-address-text {
149
- /* 禁止文本 Ellipsis/截断, 以便测量真实的宽度 */
150
- white-space: nowrap;
151
- overflow: visible;
152
- text-overflow: unset;
153
- }
154
- `;
@@ -1,100 +0,0 @@
1
- import Alert from '.';
2
-
3
- export default {
4
- title: 'Deprecated/Alert',
5
-
6
- parameters: {
7
- readme: {
8
- sidebar: '<!-- PROPS -->',
9
- },
10
- },
11
- };
12
-
13
- export function WithDifferentType() {
14
- return (
15
- <div
16
- style={{
17
- display: 'flex',
18
- flexDirection: 'column',
19
- width: '300px',
20
- justifyContent: 'space-between',
21
- }}>
22
- <Alert type="error">Error message</Alert>
23
- <Alert type="warning">Warning message</Alert>
24
- <Alert type="success">Success message</Alert>
25
- <Alert type="tip">Default tip</Alert>
26
- </div>
27
- );
28
- }
29
-
30
- WithDifferentType.storyName = 'with different type';
31
-
32
- export function WithDifferentVariant() {
33
- return (
34
- <div
35
- style={{
36
- display: 'flex',
37
- flexDirection: 'column',
38
- width: '300px',
39
- justifyContent: 'space-between',
40
- }}>
41
- <Alert type="error" variant="icon">
42
- Error message
43
- </Alert>
44
- <Alert type="warning" variant="border">
45
- Warning message
46
- </Alert>
47
- </div>
48
- );
49
- }
50
-
51
- WithDifferentVariant.storyName = 'with different variant';
52
-
53
- export function WithIcon() {
54
- return (
55
- <div
56
- style={{
57
- display: 'flex',
58
- flexDirection: 'column',
59
- width: '300px',
60
- justifyContent: 'space-between',
61
- }}>
62
- <Alert type="error" showIcon>
63
- Error message
64
- </Alert>
65
- <Alert type="warning" showIcon>
66
- Warning message
67
- </Alert>
68
- <Alert type="success" showIcon>
69
- Success message
70
- </Alert>
71
- <Alert type="tip" showIcon>
72
- Default tip
73
- </Alert>
74
- </div>
75
- );
76
- }
77
-
78
- WithIcon.storyName = 'with icon';
79
-
80
- export function WithDifferentMessage() {
81
- return (
82
- <div
83
- style={{
84
- display: 'flex',
85
- flexDirection: 'column',
86
- width: '300px',
87
- justifyContent: 'space-between',
88
- }}>
89
- <Alert type="error">Error message</Alert>
90
- <Alert type="error">
91
- <ul>
92
- <li>Error message 1</li>
93
- <li>Error message 2</li>
94
- </ul>
95
- </Alert>
96
- </div>
97
- );
98
- }
99
-
100
- WithDifferentMessage.storyName = 'with different message';
@@ -1,130 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { Typography } from '@mui/material';
3
- import { blueGrey } from '@mui/material/colors';
4
- import isUndefined from 'lodash/isUndefined';
5
-
6
- import Icon from '../Icon';
7
- import { mergeProps } from '../Util';
8
- import colors from '../Colors';
9
- import { styled } from '../Theme';
10
- import { withDeprecated } from '../Util/deprecate';
11
-
12
- const types = {
13
- error: {
14
- icon: 'exclamation-circle',
15
- color: colors.error.main,
16
- borderColor: '#e35b54',
17
- backgroundColor: 'rgba(227, 91, 84, 0.2)',
18
- variant: 'solid',
19
- },
20
- warning: {
21
- icon: 'exclamation-triangle',
22
- color: colors.warning.main,
23
- borderColor: '#f7d040',
24
- backgroundColor: 'rgba(247, 208, 64, 0.2)',
25
- variant: 'solid',
26
- },
27
- success: {
28
- icon: 'check-circle',
29
- color: colors.success.main,
30
- borderColor: '#89ddd9',
31
- backgroundColor: 'rgba(137, 221, 217, 0.2)',
32
- },
33
- tip: {
34
- icon: 'info-circle',
35
- color: colors.grey[500],
36
- borderColor: '#222222',
37
- backgroundColor: '#EEEEEE',
38
- variant: 'solid',
39
- },
40
- };
41
-
42
- /**
43
- * Alert notification component
44
- * @typedef {{
45
- * type?: 'error' | 'warning' | 'success' | 'tip';
46
- * children: any;
47
- * className?: string;
48
- * style?: object | string;
49
- * variant?: 'border' | 'icon';
50
- * } & import('react').ComponentPropsWithoutRef<"div"> } AlertProps
51
- */
52
-
53
- /**
54
- * Alert notification component
55
- * @param {AlertProps} props
56
- * @returns {JSX.Element}
57
- */
58
- function Alert({ ...rawProps }) {
59
- const props = Object.assign({}, rawProps);
60
- if (isUndefined(props.type)) {
61
- props.type = 'tip';
62
- }
63
- if (isUndefined(props.className)) {
64
- props.className = '';
65
- }
66
- if (isUndefined(props.style)) {
67
- props.style = {};
68
- }
69
- if (isUndefined(props.variant)) {
70
- props.variant = 'border';
71
- }
72
- /** @type {AlertProps} */
73
- const newProps = mergeProps(props, Alert, ['style']);
74
- const { type, children, style, className, variant, showIcon = false, ...rest } = newProps;
75
- const { icon, color, backgroundColor, borderColor, variant: iconVariant } = types[type] || types.success;
76
-
77
- /** @type {import('react').CSSProperties} */
78
- const styles = Object.assign(
79
- {
80
- color: blueGrey[500],
81
- backgroundColor: variant === 'border' ? backgroundColor : 'transparent',
82
- borderLeft: variant === 'border' ? `5px solid ${borderColor}` : 'none',
83
- },
84
- style
85
- );
86
-
87
- return (
88
- <Container {...rest} className={`alert alert--${type} alert--${variant} ${className}`.trim()} style={styles}>
89
- {(variant === 'icon' || showIcon) && (
90
- <Icon className="alert-icon" name={icon} size={24} color={color} variant={iconVariant} />
91
- )}
92
- <Typography component="div" className="alert-content">
93
- {children}
94
- </Typography>
95
- </Container>
96
- );
97
- }
98
-
99
- Alert.propTypes = {
100
- type: PropTypes.oneOf(Object.keys(types)),
101
- children: PropTypes.any.isRequired,
102
- className: PropTypes.string,
103
- style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
104
- variant: PropTypes.oneOf(['border', 'icon']),
105
- };
106
-
107
- export default withDeprecated(Alert, { name: 'Alert', alternative: '@mui/material/Alert' });
108
-
109
- const Container = styled('div')`
110
- display: flex;
111
- align-items: center;
112
- font-size: 16px;
113
- margin: 0;
114
- padding: 16px;
115
- margin: 16px 0;
116
-
117
- strong {
118
- margin: 0 5px;
119
- }
120
-
121
- .alert-icon {
122
- margin-right: 16px;
123
- }
124
-
125
- .alert-content {
126
- flex: 1;
127
- display: flex;
128
- flex-direction: column;
129
- }
130
- `;
@@ -1,35 +0,0 @@
1
- import { Box } from '@mui/material';
2
- import AnimationWaiter from '.';
3
- import { ThemeProvider } from '../Theme';
4
- import { ThemeModeToggle } from '../Config';
5
-
6
- export { default as Basic } from './demo/basic';
7
- export { default as WithCustomMessages } from './demo/with-custom-messages';
8
- export { default as WithMoreMessages } from './demo/with-more-messages';
9
- export { default as Sizes } from './demo/sizes';
10
- export { default as WithTips } from './demo/with-tips';
11
- export { default as WithSpeed } from './demo/with-speed';
12
- export { default as WithMaybeDuration } from './demo/with-maybe-duration';
13
-
14
- export default {
15
- title: 'Feedback/AnimationWaiter',
16
- component: AnimationWaiter,
17
- parameters: {
18
- docs: {
19
- description: {
20
- component:
21
- 'AnimationWaiter is a loading component that provides feedback when the user is waiting for a long time to perform an operation.',
22
- },
23
- },
24
- },
25
- decorators: [
26
- (Story) => (
27
- <ThemeProvider prefer="system">
28
- <Box sx={{ py: 1 }}>
29
- <ThemeModeToggle />
30
- </Box>
31
- <Story />
32
- </ThemeProvider>
33
- ),
34
- ],
35
- };