@arcblock/ux 3.4.15 → 3.5.1

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 (333) hide show
  1. package/lib/package.json.js +1 -1
  2. package/package.json +10 -7
  3. package/src/ActionButton/ActionButton.stories.jsx +0 -61
  4. package/src/ActionButton/index.jsx +0 -106
  5. package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
  6. package/src/ActivityIndicator/index.jsx +0 -140
  7. package/src/Address/Address.stories.jsx +0 -38
  8. package/src/Address/compact-text.jsx +0 -76
  9. package/src/Address/did-address.tsx +0 -223
  10. package/src/Address/index.tsx +0 -21
  11. package/src/Address/responsive-did-address.tsx +0 -154
  12. package/src/Alert/Alert.stories.jsx +0 -100
  13. package/src/Alert/index.jsx +0 -130
  14. package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
  15. package/src/AnimationWaiter/dark-animation.json +0 -1
  16. package/src/AnimationWaiter/default-animation.json +0 -1
  17. package/src/AnimationWaiter/index.jsx +0 -296
  18. package/src/Async/index.tsx +0 -44
  19. package/src/Avatar/Avatar.stories.jsx +0 -11
  20. package/src/Avatar/did-motif.jsx +0 -38
  21. package/src/Avatar/etherscan-blockies.js +0 -81
  22. package/src/Avatar/index.jsx +0 -195
  23. package/src/Badge/Badge.stories.jsx +0 -41
  24. package/src/Badge/index.jsx +0 -101
  25. package/src/Blocklet/Blocklet.stories.jsx +0 -21
  26. package/src/Blocklet/blocklet.jsx +0 -276
  27. package/src/Blocklet/index.js +0 -5
  28. package/src/Blocklet/utils.jsx +0 -58
  29. package/src/BlockletContext/index.tsx +0 -72
  30. package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
  31. package/src/BlockletNFT/index.jsx +0 -378
  32. package/src/BlockletV2/Blocklet.stories.jsx +0 -34
  33. package/src/BlockletV2/blocklet.tsx +0 -247
  34. package/src/BlockletV2/components/icon-text.tsx +0 -47
  35. package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
  36. package/src/BlockletV2/index.ts +0 -6
  37. package/src/BlockletV2/utils.js +0 -75
  38. package/src/Button/Button.stories.jsx +0 -24
  39. package/src/Button/index.js +0 -9
  40. package/src/Button/wrap.jsx +0 -126
  41. package/src/ButtonGroup/index.js +0 -16
  42. package/src/CardSelector/index.tsx +0 -136
  43. package/src/Center/Center.stories.jsx +0 -20
  44. package/src/Center/index.tsx +0 -33
  45. package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
  46. package/src/ClickToCopy/copy-button.tsx +0 -43
  47. package/src/ClickToCopy/hook.ts +0 -42
  48. package/src/ClickToCopy/index.tsx +0 -96
  49. package/src/CloseButton/index.tsx +0 -37
  50. package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
  51. package/src/CodeBlock/LightBox.tsx +0 -87
  52. package/src/CodeBlock/index.tsx +0 -217
  53. package/src/Colors/Colors.stories.jsx +0 -211
  54. package/src/Colors/index.ts +0 -4
  55. package/src/Colors/themes/default.ts +0 -8
  56. package/src/Colors/themes/did-connect.ts +0 -64
  57. package/src/Colors/themes/temp.ts +0 -52
  58. package/src/Config/Config.stories.jsx +0 -16
  59. package/src/Config/config-provider.tsx +0 -62
  60. package/src/Config/index.ts +0 -2
  61. package/src/Config/theme-mode-toggle.tsx +0 -38
  62. package/src/ContactForm/ContactForm.stories.jsx +0 -32
  63. package/src/ContactForm/index.tsx +0 -264
  64. package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
  65. package/src/CookieConsent/index.tsx +0 -104
  66. package/src/CountDown/CountDown.stories.jsx +0 -15
  67. package/src/CountDown/index.tsx +0 -170
  68. package/src/DID/DID.stories.jsx +0 -37
  69. package/src/DID/index.tsx +0 -393
  70. package/src/DIDConnect/app-icon.tsx +0 -37
  71. package/src/DIDConnect/app-info-item.tsx +0 -93
  72. package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
  73. package/src/DIDConnect/auth-apps/index.tsx +0 -278
  74. package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
  75. package/src/DIDConnect/did-connect-container.tsx +0 -326
  76. package/src/DIDConnect/did-connect-footer.tsx +0 -76
  77. package/src/DIDConnect/did-connect-logo.tsx +0 -8
  78. package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
  79. package/src/DIDConnect/icons/github-logo.tsx +0 -17
  80. package/src/DIDConnect/index.ts +0 -11
  81. package/src/DIDConnect/landing-page.tsx +0 -218
  82. package/src/DIDConnect/powered-by.tsx +0 -48
  83. package/src/DIDConnect/provider-icon.tsx +0 -62
  84. package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
  85. package/src/DIDConnect/with-container.tsx +0 -323
  86. package/src/DIDConnect/with-ux-theme.tsx +0 -22
  87. package/src/DIDLogo/Logo.stories.jsx +0 -11
  88. package/src/DIDLogo/index.tsx +0 -168
  89. package/src/Datatable/CustomToolbar.jsx +0 -415
  90. package/src/Datatable/Datatable.stories.jsx +0 -92
  91. package/src/Datatable/DatatableContext.jsx +0 -35
  92. package/src/Datatable/TableSearch.jsx +0 -166
  93. package/src/Datatable/index.jsx +0 -652
  94. package/src/Datatable/utils.js +0 -161
  95. package/src/Dialog/Dialog.stories.jsx +0 -21
  96. package/src/Dialog/confirm.jsx +0 -143
  97. package/src/Dialog/dialog.jsx +0 -199
  98. package/src/Dialog/index.js +0 -4
  99. package/src/Dialog/types.d.ts +0 -20
  100. package/src/Dialog/use-confirm.jsx +0 -188
  101. package/src/DriftBot/index.tsx +0 -81
  102. package/src/Earth/Earth.stories.jsx +0 -39
  103. package/src/Earth/countries.json +0 -8057
  104. package/src/Earth/index.tsx +0 -515
  105. package/src/Earth/util.ts +0 -72
  106. package/src/Empty/Empty.stories.jsx +0 -23
  107. package/src/Empty/index.jsx +0 -48
  108. package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
  109. package/src/ErrorBoundary/fallback.tsx +0 -85
  110. package/src/ErrorBoundary/index.ts +0 -1
  111. package/src/Footer/Footer.stories.jsx +0 -13
  112. package/src/Footer/index.tsx +0 -130
  113. package/src/Header/Header.stories.jsx +0 -30
  114. package/src/Header/addon-button.tsx +0 -41
  115. package/src/Header/auto-hidden.tsx +0 -31
  116. package/src/Header/header-addons.tsx +0 -37
  117. package/src/Header/header.tsx +0 -214
  118. package/src/Header/index.ts +0 -3
  119. package/src/Header/responsive-header.tsx +0 -145
  120. package/src/Icon/Icon.stories.jsx +0 -45
  121. package/src/Icon/image.tsx +0 -53
  122. package/src/Icon/index.tsx +0 -63
  123. package/src/Img/Img.stories.jsx +0 -17
  124. package/src/Img/index.jsx +0 -258
  125. package/src/InfoRow/InfoRow.stories.jsx +0 -14
  126. package/src/InfoRow/index.tsx +0 -91
  127. package/src/Layout/Layout.stories.jsx +0 -24
  128. package/src/Layout/dashboard/external-link.tsx +0 -59
  129. package/src/Layout/dashboard/full-page.tsx +0 -58
  130. package/src/Layout/dashboard/index.tsx +0 -260
  131. package/src/Layout/dashboard/sidebar.tsx +0 -198
  132. package/src/Layout/dashboard-legacy/header.tsx +0 -156
  133. package/src/Layout/dashboard-legacy/index.tsx +0 -127
  134. package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
  135. package/src/Layout/index.tsx +0 -310
  136. package/src/LoadingMask/index.tsx +0 -108
  137. package/src/Locale/LocaleSelector.stories.jsx +0 -44
  138. package/src/Locale/browser-lang.ts +0 -65
  139. package/src/Locale/context.tsx +0 -162
  140. package/src/Locale/languages.ts +0 -58
  141. package/src/Locale/selector.tsx +0 -174
  142. package/src/Locale/util.ts +0 -38
  143. package/src/Logo/Logo.stories.jsx +0 -23
  144. package/src/Logo/images/logo-dark-text.svg +0 -3
  145. package/src/Logo/images/logo-dark-top.svg +0 -6
  146. package/src/Logo/images/logo-light-text.svg +0 -3
  147. package/src/Logo/images/logo-light-top.svg +0 -6
  148. package/src/Logo/index.tsx +0 -58
  149. package/src/Metric/Metric.stories.jsx +0 -29
  150. package/src/Metric/index.tsx +0 -130
  151. package/src/MuiWrap/index.tsx +0 -10
  152. package/src/NFTDisplay/NFTBroken.svg +0 -34
  153. package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
  154. package/src/NFTDisplay/README.md +0 -59
  155. package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
  156. package/src/NFTDisplay/broken.tsx +0 -51
  157. package/src/NFTDisplay/displayApi.ts +0 -43
  158. package/src/NFTDisplay/index.tsx +0 -393
  159. package/src/NFTDisplay/loading.tsx +0 -16
  160. package/src/NFTDisplay/preview.tsx +0 -84
  161. package/src/NFTDisplay/render-svg.tsx +0 -21
  162. package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
  163. package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
  164. package/src/NavMenu/NavMenu.stories.jsx +0 -17
  165. package/src/NavMenu/images/OCAP.svg +0 -1
  166. package/src/NavMenu/images/abt-network.svg +0 -1
  167. package/src/NavMenu/images/ai-kit.svg +0 -1
  168. package/src/NavMenu/images/aigne-image-smith.svg +0 -1
  169. package/src/NavMenu/images/aigne.svg +0 -1
  170. package/src/NavMenu/images/aistro.png +0 -0
  171. package/src/NavMenu/images/arcsphere.svg +0 -1
  172. package/src/NavMenu/images/blocklet-framework.svg +0 -1
  173. package/src/NavMenu/images/blocklet-launcher.svg +0 -1
  174. package/src/NavMenu/images/blocklet-server.svg +0 -1
  175. package/src/NavMenu/images/blocklet-store.svg +0 -1
  176. package/src/NavMenu/images/creator-studio.svg +0 -1
  177. package/src/NavMenu/images/did-wallet.svg +0 -1
  178. package/src/NavMenu/images/did.svg +0 -1
  179. package/src/NavMenu/images/nft-studio.svg +0 -1
  180. package/src/NavMenu/images/payment-kit.png +0 -0
  181. package/src/NavMenu/images/vc.svg +0 -1
  182. package/src/NavMenu/images/web3-kit.svg +0 -1
  183. package/src/NavMenu/index.ts +0 -3
  184. package/src/NavMenu/nav-menu-context.tsx +0 -30
  185. package/src/NavMenu/nav-menu.tsx +0 -441
  186. package/src/NavMenu/products.tsx +0 -830
  187. package/src/NavMenu/style.ts +0 -258
  188. package/src/NavMenu/sub-container.tsx +0 -125
  189. package/src/NavMenu/sub-item-group.tsx +0 -42
  190. package/src/OrgTransfer/index.tsx +0 -53
  191. package/src/OrgTransfer/locales.ts +0 -25
  192. package/src/OrgTransfer/selector.tsx +0 -252
  193. package/src/OrgTransfer/type.ts +0 -31
  194. package/src/PageScroller/index.tsx +0 -316
  195. package/src/PageScroller/story/FifthComponent.jsx +0 -7
  196. package/src/PageScroller/story/FirstComponent.jsx +0 -7
  197. package/src/PageScroller/story/FourthComponent.jsx +0 -7
  198. package/src/PageScroller/story/FullPage.jsx +0 -55
  199. package/src/PageScroller/story/PageContain.jsx +0 -59
  200. package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
  201. package/src/PageScroller/story/SecondComponent.jsx +0 -7
  202. package/src/PageScroller/story/ThirdComponent.jsx +0 -7
  203. package/src/PageScroller/story/index.css +0 -115
  204. package/src/PageScroller/usePrevValue.ts +0 -11
  205. package/src/Passport/index.ts +0 -3
  206. package/src/Passport/passport.tsx +0 -118
  207. package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
  208. package/src/PhoneInput/country-select.tsx +0 -148
  209. package/src/PhoneInput/index.tsx +0 -269
  210. package/src/PoweredByArcBlock/index.tsx +0 -27
  211. package/src/PricingTable/PricingPlan.tsx +0 -120
  212. package/src/PricingTable/PricingTable.stories.jsx +0 -38
  213. package/src/PricingTable/index.tsx +0 -59
  214. package/src/QRCode/QRCode.stories.jsx +0 -13
  215. package/src/QRCode/index.tsx +0 -66
  216. package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
  217. package/src/RelativeTime/index.tsx +0 -334
  218. package/src/Result/Result.stories.jsx +0 -61
  219. package/src/Result/common.tsx +0 -119
  220. package/src/Result/index.tsx +0 -30
  221. package/src/Result/result.tsx +0 -65
  222. package/src/Result/translations.ts +0 -57
  223. package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
  224. package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
  225. package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
  226. package/src/Screenshot/Screenshot.stories.jsx +0 -44
  227. package/src/Screenshot/devices.css +0 -1366
  228. package/src/Screenshot/index.tsx +0 -300
  229. package/src/SessionBlocklet/index.tsx +0 -178
  230. package/src/SessionManager/SessionManager.stories.jsx +0 -9
  231. package/src/SessionManager/index.tsx +0 -3
  232. package/src/SessionPermission/index.tsx +0 -26
  233. package/src/SessionUser/components/did-space.tsx +0 -68
  234. package/src/SessionUser/components/logged-in.tsx +0 -338
  235. package/src/SessionUser/components/quick-login-item.tsx +0 -132
  236. package/src/SessionUser/components/session-user-item.tsx +0 -93
  237. package/src/SessionUser/components/session-user-switch.tsx +0 -240
  238. package/src/SessionUser/components/un-login.tsx +0 -257
  239. package/src/SessionUser/components/user-info.tsx +0 -201
  240. package/src/SessionUser/index.tsx +0 -68
  241. package/src/SessionUser/libs/translation.ts +0 -30
  242. package/src/SessionUser/libs/utils.ts +0 -39
  243. package/src/SharedBridge/index.tsx +0 -126
  244. package/src/SocialShare/index.tsx +0 -194
  245. package/src/Sparkline/Sparkline.stories.jsx +0 -13
  246. package/src/Sparkline/index.tsx +0 -231
  247. package/src/Spinner/Spinner.stories.jsx +0 -98
  248. package/src/Spinner/index.tsx +0 -20
  249. package/src/SplitButton/SplitButton.stories.jsx +0 -32
  250. package/src/SplitButton/index.tsx +0 -116
  251. package/src/SplitButton/useClickAway.tsx +0 -24
  252. package/src/Success/index.tsx +0 -175
  253. package/src/Switch/Switch.stories.jsx +0 -16
  254. package/src/Switch/index.jsx +0 -79
  255. package/src/Tabs/Tabs.stories.jsx +0 -18
  256. package/src/Tabs/index.tsx +0 -255
  257. package/src/Tag/Tag.stories.jsx +0 -15
  258. package/src/Tag/index.jsx +0 -106
  259. package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
  260. package/src/TextCollapse/index.tsx +0 -85
  261. package/src/Theme/Theme.stories.jsx +0 -11
  262. package/src/Theme/index.ts +0 -21
  263. package/src/Theme/theme-provider.tsx +0 -374
  264. package/src/Theme/theme.ts +0 -229
  265. package/src/Toast/Toast.stories.jsx +0 -28
  266. package/src/Toast/index.tsx +0 -80
  267. package/src/Typography/index.tsx +0 -124
  268. package/src/UserCard/Cards/avatar-only.tsx +0 -27
  269. package/src/UserCard/Cards/basic-info.tsx +0 -43
  270. package/src/UserCard/Cards/index.tsx +0 -16
  271. package/src/UserCard/Cards/social-actions.tsx +0 -196
  272. package/src/UserCard/Container/card.tsx +0 -63
  273. package/src/UserCard/Container/dialog.tsx +0 -37
  274. package/src/UserCard/Content/basic.tsx +0 -330
  275. package/src/UserCard/Content/clock.tsx +0 -82
  276. package/src/UserCard/Content/minimal.tsx +0 -113
  277. package/src/UserCard/Content/shorten-label.tsx +0 -32
  278. package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
  279. package/src/UserCard/UserCard.stories.jsx +0 -19
  280. package/src/UserCard/components.tsx +0 -81
  281. package/src/UserCard/index.tsx +0 -132
  282. package/src/UserCard/types.ts +0 -165
  283. package/src/UserCard/use-follow.tsx +0 -111
  284. package/src/UserCard/utils.ts +0 -155
  285. package/src/Util/WebWalletOpener.stories.jsx +0 -5
  286. package/src/Util/client.ts +0 -4
  287. package/src/Util/constant.ts +0 -70
  288. package/src/Util/deprecate.tsx +0 -29
  289. package/src/Util/federated.ts +0 -125
  290. package/src/Util/iframe.ts +0 -19
  291. package/src/Util/index.ts +0 -760
  292. package/src/Util/logger.ts +0 -44
  293. package/src/Util/passport.ts +0 -127
  294. package/src/Util/security.ts +0 -72
  295. package/src/Util/style.ts +0 -17
  296. package/src/Util/wallet.ts +0 -35
  297. package/src/VerificationCode/index.tsx +0 -83
  298. package/src/Video/Video.stories.jsx +0 -6
  299. package/src/Video/index.tsx +0 -70
  300. package/src/Wallet/Action.stories.jsx +0 -8
  301. package/src/Wallet/Action.tsx +0 -118
  302. package/src/Wallet/Download.stories.jsx +0 -9
  303. package/src/Wallet/Download.tsx +0 -157
  304. package/src/Wallet/Open.tsx +0 -47
  305. package/src/Wallet/OpenInWallet.stories.jsx +0 -5
  306. package/src/Wallet/images/abtwallet.png +0 -0
  307. package/src/Wallet/images/android_download.svg +0 -22
  308. package/src/Wallet/images/app-store.svg +0 -30
  309. package/src/Wallet/images/google-play.svg +0 -69
  310. package/src/WalletOSIcon/index.tsx +0 -47
  311. package/src/WebWalletSWKeeper/index.tsx +0 -117
  312. package/src/WechatPrompt/images/android.png +0 -0
  313. package/src/WechatPrompt/images/ios.png +0 -0
  314. package/src/WechatPrompt/index.tsx +0 -75
  315. package/src/global.d.ts +0 -28
  316. package/src/hooks/use-blocklet-logo.tsx +0 -32
  317. package/src/hooks/use-clock.tsx +0 -62
  318. package/src/hooks/use-location-state.tsx +0 -117
  319. package/src/hooks/use-mobile.tsx +0 -6
  320. package/src/index.ts +0 -79
  321. package/src/type.d.ts +0 -44
  322. package/src/withTheme/index.tsx +0 -72
  323. package/src/withTracker/README.md +0 -37
  324. package/src/withTracker/action/bind-wallet.tsx +0 -17
  325. package/src/withTracker/action/login.tsx +0 -18
  326. package/src/withTracker/action/pay.tsx +0 -14
  327. package/src/withTracker/action/switch-passport.tsx +0 -20
  328. package/src/withTracker/constant/index.tsx +0 -3
  329. package/src/withTracker/env.tsx +0 -1
  330. package/src/withTracker/error_boundary.jsx +0 -34
  331. package/src/withTracker/index.tsx +0 -50
  332. package/src/withTracker/libs/utm.ts +0 -46
  333. package/vite.config.mjs +0 -37
@@ -1,330 +0,0 @@
1
- import { Typography, Box, Grid, useTheme } from '@mui/material';
2
- import { useCreation, useMemoizedFn } from 'ahooks';
3
- import styled from '@emotion/styled';
4
- import isArray from 'lodash/isArray';
5
- import { Icon as IconifyIcon } from '@iconify/react';
6
- import infoCircleIcon from '@iconify-icons/tabler/info-circle';
7
- import LinkIcon from '@arcblock/icons/lib/Link';
8
- import PhoneIcon from '@arcblock/icons/lib/Phone';
9
- import LocationIcon from '@arcblock/icons/lib/Location';
10
- import EmailIcon from '@arcblock/icons/lib/Email';
11
- import TimezoneIcon from '@arcblock/icons/lib/Timezone';
12
- import { withoutProtocol } from 'ufo';
13
- import { useMemo, useCallback } from 'react';
14
-
15
- import { User } from '../types';
16
- import Clock from './clock';
17
-
18
- const IconMap = {
19
- timezone: TimezoneIcon,
20
- email: EmailIcon,
21
- phone: PhoneIcon,
22
- location: LocationIcon,
23
- link: LinkIcon,
24
- };
25
-
26
- /**
27
- * 格式化链接显示
28
- * 对于 http/https 协议只显示域名,其他协议显示完整链接
29
- */
30
- function formatLinkDisplay(link: string): string {
31
- return withoutProtocol(link);
32
- }
33
-
34
- /**
35
- * dark mode 下,转换 icon 颜色
36
- */
37
- function convertIconColor(isDark: boolean) {
38
- return isDark
39
- ? {
40
- filter: 'brightness(0) saturate(100%) invert(1)',
41
- }
42
- : {};
43
- }
44
- const iconSize = {
45
- width: 16,
46
- height: 16,
47
- };
48
- interface BasicContentProps {
49
- user: User;
50
- renderFields?: string[];
51
- }
52
-
53
- // 定义渲染项的类型
54
- interface RenderItem {
55
- field: string;
56
- value: string | any;
57
- key: string;
58
- }
59
-
60
- function TimeZoneField({ value }: { value: string }) {
61
- const theme = useTheme();
62
- const isDark = theme.palette.mode === 'dark';
63
- return (
64
- <Box
65
- className="user-card__timezone-field"
66
- sx={{
67
- display: 'flex',
68
- alignItems: 'center',
69
- gap: 1,
70
- }}>
71
- <TimezoneIcon {...iconSize} style={convertIconColor(isDark)} />
72
- <Clock value={value} variant="body2" color="grey.800" />
73
- </Box>
74
- );
75
- }
76
-
77
- function LinkField({ value }: { value: string }) {
78
- const theme = useTheme();
79
- const isDark = theme.palette.mode === 'dark';
80
-
81
- return (
82
- <Box display="flex" alignItems="center" gap={1} className="user-card__link-field">
83
- <LinkIcon {...iconSize} style={convertIconColor(isDark)} />
84
- <LineText variant="body2" color="grey.800">
85
- <Typography
86
- component="a"
87
- href={value}
88
- style={{ textDecoration: 'none', color: 'inherit', fontSize: 'inherit' }}
89
- target="_blank"
90
- variant="body2"
91
- rel="noopener noreferrer"
92
- sx={{
93
- color: 'grey.800',
94
- }}>
95
- {formatLinkDisplay(value)}
96
- </Typography>
97
- </LineText>
98
- </Box>
99
- );
100
- }
101
-
102
- function BasicField({ field, value, children = null }: { field: string; value: string; children?: React.ReactNode }) {
103
- const Icon = IconMap[field as keyof typeof IconMap];
104
- const theme = useTheme();
105
- const isDark = theme.palette.mode === 'dark';
106
- const iconColor = convertIconColor(isDark);
107
- return (
108
- <Box
109
- key={field}
110
- className={`user-card__${field}-field`}
111
- sx={{
112
- display: 'flex',
113
- alignItems: 'center',
114
- gap: 1,
115
- }}>
116
- {Icon ? (
117
- <Icon {...iconSize} style={iconColor} />
118
- ) : (
119
- <IconifyIcon icon={infoCircleIcon} {...iconSize} {...iconColor} />
120
- )}
121
- <LineText variant="body2" color="grey.800">
122
- {children ?? value}
123
- </LineText>
124
- </Box>
125
- );
126
- }
127
-
128
- function BasicContent({ user, renderFields = undefined }: BasicContentProps) {
129
- const fields = useCreation(() => {
130
- return renderFields ?? ['bio', 'email', 'phone', 'location', 'timezone', 'link'];
131
- }, [renderFields]);
132
-
133
- const includeBio = useCreation(() => {
134
- return fields.includes('bio');
135
- }, [fields]);
136
-
137
- const metadata = useCreation(() => {
138
- return (
139
- user.metadata ?? {
140
- joinedAt: user?.createdAt,
141
- email: user?.email,
142
- phone: {
143
- country: 'cn',
144
- phoneNumber: user?.phone ?? '',
145
- },
146
- }
147
- );
148
- }, [user]);
149
-
150
- const address = useCreation(() => {
151
- return user.address;
152
- }, [user.address]);
153
-
154
- const getFieldValue = useCallback(
155
- (field: string) => {
156
- if (!field) return '';
157
- switch (field) {
158
- case 'bio':
159
- return user.metadata?.bio || '';
160
- case 'email':
161
- return metadata.email || user.email || '';
162
- case 'phone':
163
- return metadata.phone?.phoneNumber || user.phone || '';
164
- case 'location':
165
- return address?.city || metadata.location || '';
166
- case 'timezone':
167
- return metadata.timezone || '';
168
- case 'link':
169
- return metadata.links?.map((link) => link.url).filter(Boolean) || [];
170
- default:
171
- return user[field as keyof User] || '';
172
- }
173
- },
174
- [user, metadata, address]
175
- );
176
-
177
- // 计算实际可见的字段数量和渲染元素数量
178
- const { effectiveRenderCount } = useMemo(() => {
179
- const visible = fields.filter((field) => {
180
- if (field === 'bio') return false; // bio field is handled separately
181
- const value = getFieldValue(field);
182
-
183
- if (value === undefined || value === null || value === '') return false;
184
-
185
- if (isArray(value)) {
186
- return value.length > 0;
187
- }
188
-
189
- return String(value).trim().length > 0;
190
- });
191
-
192
- // 计算实际渲染数量
193
- const renderCount = visible.reduce((count, field) => {
194
- const value = getFieldValue(field);
195
- return count + (Array.isArray(value) ? value.filter((item) => item && String(item).trim()).length : 1);
196
- }, 0);
197
-
198
- return { visibleFields: visible, effectiveRenderCount: renderCount };
199
- }, [fields, getFieldValue]);
200
-
201
- // 判断是否需要使用两列布局
202
- const useDoubleColumn = effectiveRenderCount > 4;
203
-
204
- const isValidValue = useMemoizedFn(
205
- (value: any) => value !== undefined && value !== null && String(value).trim().length > 0
206
- );
207
-
208
- // 准备要渲染的所有元素项
209
- const renderItems = useMemo(() => {
210
- const items: RenderItem[] = [];
211
-
212
- // 遍历有效字段,展开数组字段为单独的渲染项
213
- fields.forEach((field) => {
214
- if (field === 'bio') return; // bio field is handled separately
215
- const value = getFieldValue(field);
216
-
217
- if (!value) return;
218
-
219
- if (isArray(value)) {
220
- // 数组类型字段,每个有效项生成一个渲染元素
221
- value.forEach((item, index) => {
222
- if (isValidValue(item)) {
223
- items.push({
224
- field,
225
- value: item,
226
- key: `${field}-${index}`,
227
- });
228
- }
229
- });
230
- } else if (isValidValue(value)) {
231
- // 非数组类型字段,生成一个渲染元素
232
- items.push({
233
- field,
234
- value,
235
- key: field,
236
- });
237
- }
238
- });
239
-
240
- return items;
241
- }, [fields, getFieldValue, isValidValue]);
242
-
243
- if (fields.length === 0) {
244
- return null;
245
- }
246
-
247
- const renderItem = (item: RenderItem) => {
248
- const { field, value, key } = item;
249
-
250
- switch (field) {
251
- case 'link':
252
- return <LinkField key={key} value={value as string} />;
253
- case 'timezone':
254
- return <TimeZoneField key={key} value={value as string} />;
255
- case 'email':
256
- return (
257
- <BasicField
258
- field={field}
259
- value={value as string}
260
- // eslint-disable-next-line react/no-children-prop
261
- children={
262
- <Typography
263
- component="a"
264
- href={`mailto:${value}`}
265
- rel="noopener noreferrer"
266
- referrerPolicy="no-referrer"
267
- style={{
268
- color: 'inherit',
269
- textDecoration: 'none',
270
- fontSize: 'inherit',
271
- }}>
272
- {value}
273
- </Typography>
274
- }
275
- />
276
- );
277
- default:
278
- return <BasicField key={key} field={field} value={value as string} />;
279
- }
280
- };
281
-
282
- return (
283
- <Box
284
- className="user-card__basic-content"
285
- sx={{
286
- mt: 1,
287
- display: 'flex',
288
- flexDirection: 'column',
289
- gap: 1.5,
290
- }}>
291
- {includeBio && user.metadata?.bio && (
292
- <LineText variant="body2" color="grey.800" className="user-card__bio-field">
293
- {user.metadata.bio}
294
- </LineText>
295
- )}
296
- {/* 其他字段 */}
297
- {useDoubleColumn ? (
298
- <Grid container spacing={0.5}>
299
- {renderItems.map((item) => (
300
- <Grid key={item.key} size={6}>
301
- {renderItem(item)}
302
- </Grid>
303
- ))}
304
- </Grid>
305
- ) : (
306
- <Box
307
- sx={{
308
- display: 'flex',
309
- flexDirection: 'column',
310
- gap: 0.5,
311
- }}>
312
- {renderItems.map((item) => renderItem(item))}
313
- </Box>
314
- )}
315
- </Box>
316
- );
317
- }
318
-
319
- export default BasicContent;
320
-
321
- const LineText = styled(Typography)`
322
- flex: 1;
323
- display: -webkit-box;
324
- line-height: 1.5;
325
- -webkit-line-clamp: 1;
326
- -webkit-box-orient: vertical;
327
- overflow: hidden;
328
- text-overflow: ellipsis;
329
- word-break: break-word;
330
- `;
@@ -1,82 +0,0 @@
1
- import { Tooltip, Typography, Box, type SxProps } from '@mui/material';
2
- import { useMemoizedFn } from 'ahooks';
3
- import useClock from '../../hooks/use-clock';
4
- import { translate } from '../../Locale/util';
5
- import { useLocaleContext } from '../../Locale/context';
6
-
7
- const translations = {
8
- en: {
9
- localTime: 'Local Time',
10
- timezonePhase: {
11
- dawn: 'AM',
12
- morning: 'AM',
13
- afternoon: 'PM',
14
- night: 'PM',
15
- },
16
- },
17
- zh: {
18
- localTime: '本地时间',
19
- timezonePhase: {
20
- dawn: '凌晨',
21
- morning: '上午',
22
- afternoon: '下午',
23
- night: '晚上',
24
- },
25
- },
26
- };
27
- export default function Clock({ value, ...props }: { value: string; sx?: SxProps; [key: string]: any }) {
28
- const { locale } = useLocaleContext() || { locale: 'en' };
29
- const t = useMemoizedFn((key, data = {}) => {
30
- return translate(translations, key, locale, 'en', data);
31
- });
32
- const timeInfo = useClock(value, locale);
33
-
34
- return (
35
- <Box
36
- sx={{
37
- display: 'flex',
38
- alignItems: 'center',
39
- gap: 1,
40
- flex: 1,
41
- justifyContent: 'flex-start',
42
- overflow: 'hidden',
43
- width: '100%',
44
- }}>
45
- <Typography
46
- {...props}
47
- noWrap
48
- component="span"
49
- sx={{
50
- flex: '0 1 auto',
51
- minWidth: 0,
52
- ...props.sx,
53
- }}>
54
- {value}
55
- </Typography>
56
- <Tooltip
57
- enterDelay={200}
58
- title={
59
- <span>
60
- {t('localTime')} {timeInfo.fullDateTime}
61
- </span>
62
- }
63
- placement="top"
64
- arrow>
65
- <Typography
66
- component="span"
67
- noWrap
68
- sx={{
69
- fontSize: 14,
70
- whiteSpace: 'nowrap',
71
- overflow: 'hidden',
72
- textOverflow: 'ellipsis',
73
- flex: '0 0 auto',
74
- maxWidth: '100%',
75
- }}>
76
- ({locale === 'zh' ? `${t(`timezonePhase.${timeInfo.phase}`)} ` : ''}
77
- {timeInfo.formattedTime})
78
- </Typography>
79
- </Tooltip>
80
- </Box>
81
- );
82
- }
@@ -1,113 +0,0 @@
1
- import React, { memo } from 'react';
2
- import { Typography, Box, useMediaQuery, Divider } from '@mui/material';
3
- import { DID } from '../../DID';
4
- import { User, UserCardProps } from '../types';
5
- import TooltipAvatar from './tooltip-avatar';
6
- import { renderTopRight } from '../components';
7
- import ShortenLabel from './shorten-label';
8
- import SocialActions from '../Cards/social-actions';
9
-
10
- interface MinimalContentProps extends UserCardProps {
11
- user: User;
12
- avatarSize: number;
13
- shouldShowHoverCard: boolean;
14
- renderCardContent?: () => React.ReactNode | null;
15
- avatarProps?: UserCardProps['avatarProps'];
16
- shortenLabelProps?: UserCardProps['shortenLabelProps'];
17
- }
18
-
19
- function MinimalContent({ ...props }: MinimalContentProps) {
20
- const {
21
- user,
22
- showDid,
23
- didProps,
24
- avatarSize,
25
- shouldShowHoverCard,
26
- renderCardContent,
27
- renderTopRightContent,
28
- topRightMaxWidth,
29
- avatarProps,
30
- shortenLabelProps,
31
- renderName,
32
- ...rest
33
- } = props;
34
- const isSmallScreen = useMediaQuery('(max-width:500px)');
35
- return (
36
- <Box
37
- className="user-card__avatar-content"
38
- sx={{
39
- display: 'flex',
40
- justifyContent: 'space-between',
41
- alignItems: 'center',
42
- }}>
43
- <Box
44
- sx={{
45
- display: 'flex',
46
- justifyContent: 'space-between',
47
- flexDirection: isSmallScreen ? 'column' : 'row',
48
- alignItems: isSmallScreen ? 'flex-start' : 'center',
49
- gap: isSmallScreen ? 2 : 1,
50
- flex: 1,
51
- minWidth: 0,
52
- flexWrap: 'wrap',
53
- }}>
54
- <Box
55
- sx={{ display: 'flex', justifyContent: 'flex-start', alignItems: 'center', gap: 1, flex: 1, width: '100%' }}>
56
- <TooltipAvatar
57
- user={user}
58
- avatarSize={avatarSize}
59
- shouldShowHoverCard={shouldShowHoverCard}
60
- renderCardContent={renderCardContent}
61
- avatarProps={avatarProps}
62
- {...rest}
63
- />
64
- <Box sx={{ width: '100%' }}>
65
- <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 1, width: '100%' }}>
66
- <Typography
67
- variant="subtitle1"
68
- className="user-card__full-name-label"
69
- noWrap
70
- sx={{
71
- fontWeight: 500,
72
- color: 'text.primary',
73
- fontSize: 18,
74
- lineHeight: 1.1,
75
- }}>
76
- {renderName ? (
77
- renderName(user)
78
- ) : (
79
- <ShortenLabel sx={{ fontWeight: 500 }} {...shortenLabelProps}>
80
- {user.fullName || user.email || user.did}
81
- </ShortenLabel>
82
- )}
83
- </Typography>
84
- {renderTopRight(renderTopRightContent, topRightMaxWidth)}
85
- </Box>
86
-
87
- {showDid && user.did ? (
88
- <DID
89
- did={user.did}
90
- size={14}
91
- copyable
92
- compact
93
- locale="en"
94
- sx={{ lineHeight: 1.5 }}
95
- {...(didProps ?? {})}
96
- />
97
- ) : null}
98
- </Box>
99
- </Box>
100
- {isSmallScreen && !renderTopRightContent && rest.showSocialActions ? <Divider sx={{ width: '100%' }} /> : null}
101
- {!renderTopRightContent ? (
102
- <SocialActions
103
- onFollowClick={rest.onFollowClick}
104
- showSocialActions={rest.showSocialActions}
105
- user={user!}
106
- session={rest.session}
107
- />
108
- ) : null}
109
- </Box>
110
- </Box>
111
- );
112
- }
113
- export default memo(MinimalContent);
@@ -1,32 +0,0 @@
1
- import { Tooltip, Typography, TypographyProps } from '@mui/material';
2
- import { useMemo } from 'react';
3
-
4
- function shortenString(str: string | undefined, maxLength: number = 10): string {
5
- if (!str) return '';
6
- if (str.length <= maxLength) return str;
7
- return `${str.slice(0, maxLength - 1)}...${str.slice(-2)}`;
8
- }
9
-
10
- export interface ShortenLabelProps {
11
- children: string;
12
- maxLength?: number;
13
- sx?: TypographyProps['sx'];
14
- hiddenTip?: boolean;
15
- }
16
-
17
- function ShortenLabel({ children, maxLength = 10, sx = undefined, hiddenTip = false }: ShortenLabelProps) {
18
- const shortenedText = useMemo(() => shortenString(children, maxLength), [children, maxLength]);
19
- if (children?.length <= maxLength) {
20
- return <Typography sx={sx}>{children}</Typography>;
21
- }
22
- if (hiddenTip) {
23
- return <Typography sx={sx}>{shortenedText}</Typography>;
24
- }
25
- return (
26
- <Tooltip title={children} placement="top">
27
- <Typography sx={sx}>{shortenedText}</Typography>
28
- </Tooltip>
29
- );
30
- }
31
-
32
- export default ShortenLabel;
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
- import { Zoom, Tooltip } from '@mui/material';
3
-
4
- import { User, UserCardProps } from '../types';
5
- import { renderAvatar } from '../components';
6
-
7
- interface TooltipAvatarProps extends UserCardProps {
8
- user: User;
9
- avatarSize: number;
10
- shouldShowHoverCard: boolean;
11
- renderCardContent?: () => React.ReactNode | null;
12
- tooltipTitle?: string;
13
- tooltipProps?: UserCardProps['tooltipProps'];
14
- avatarProps?: UserCardProps['avatarProps'];
15
- }
16
-
17
- /**
18
- * 统一处理头像的Tooltip显示组件
19
- * 根据条件显示普通Tooltip、自定义Tooltip内容或无Tooltip的头像
20
- */
21
- function TooltipAvatar({
22
- user,
23
- avatarSize,
24
- shouldShowHoverCard,
25
- renderCardContent = undefined,
26
- tooltipTitle = undefined,
27
- tooltipProps = undefined,
28
- avatarProps = undefined,
29
- onAvatarClick,
30
- }: TooltipAvatarProps) {
31
- const avatarElement = renderAvatar(
32
- user,
33
- avatarSize,
34
- avatarProps,
35
- onAvatarClick,
36
- shouldShowHoverCard || !!tooltipTitle
37
- );
38
- // 使用普通文本Tooltip
39
- if (tooltipTitle) {
40
- return (
41
- <Tooltip enterDelay={200} title={tooltipTitle} placement="bottom" {...(tooltipProps ?? {})}>
42
- {avatarElement}
43
- </Tooltip>
44
- );
45
- }
46
-
47
- // 使用自定义内容Tooltip
48
- if (shouldShowHoverCard) {
49
- return (
50
- <Tooltip
51
- enterDelay={200}
52
- title={renderCardContent ? renderCardContent() : null}
53
- placement="bottom"
54
- arrow={false}
55
- {...(tooltipProps ?? {})}
56
- slotProps={{
57
- popper: {
58
- sx: {
59
- '& .MuiTooltip-tooltip': {
60
- backgroundColor: 'transparent',
61
- p: 0,
62
- maxWidth: 500,
63
- zIndex: 1000,
64
- },
65
- },
66
- },
67
- }}
68
- slots={{
69
- transition: Zoom,
70
- }}>
71
- {avatarElement}
72
- </Tooltip>
73
- );
74
- }
75
-
76
- // 无Tooltip
77
- return avatarElement;
78
- }
79
-
80
- export default TooltipAvatar;
@@ -1,19 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
- export { default as AvatarWithHover } from './demo/avatarWithHover';
3
- export { default as DetailedCard } from './demo/detailedCard';
4
- export { default as DidControl } from './demo/didControl';
5
- export { default as TopRightContent } from './demo/topRightContent';
6
- export { default as CustomFooter } from './demo/customFooter';
7
- export { default as DidOnlyAvatar } from './demo/did-only-avatar';
8
- export { default as SocialActions } from './demo/socialActions';
9
-
10
- export default {
11
- title: 'Data Display/UserCard',
12
- parameters: {
13
- docs: {
14
- description: {
15
- component: 'Used to display user information.',
16
- },
17
- },
18
- },
19
- };