@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,68 +0,0 @@
1
- import noop from 'lodash/noop';
2
- import { useCreation } from 'ahooks';
3
- import { ReactNode } from 'react';
4
-
5
- import LoggedIn from './components/logged-in';
6
- import UnLogin from './components/un-login';
7
- import type { Locale, Session } from '../type';
8
- import { PROFILE_URL } from '../Util/constant';
9
-
10
- export interface SessionUserProps {
11
- session: Session;
12
- onBindWallet?: () => void;
13
- locale?: Locale;
14
- size?: number;
15
- popperType?: 'hover' | 'click';
16
- profileUrl?: string;
17
- renderUserButton?: (props: {
18
- isBlocklet: boolean;
19
- session: Session;
20
- locale: Locale;
21
- size: number;
22
- popperType: 'hover' | 'click';
23
- profileUrl?: string;
24
- dashboardUrl?: string;
25
- mode?: any;
26
- avatar: string;
27
- isInviteEnabled: boolean;
28
- handleSwitchPassport: () => void;
29
- handleSwitchAccount: () => void;
30
- handleSwitchProfile: () => void;
31
- handleBindWallet: () => void;
32
- handleOpenInvite: () => void;
33
- handleLogout: () => void;
34
- }) => ReactNode;
35
- }
36
-
37
- export default function SessionUser({
38
- session,
39
- onBindWallet = noop,
40
- locale = 'en',
41
- size = 24,
42
- popperType = 'click',
43
- profileUrl = PROFILE_URL,
44
- renderUserButton = undefined,
45
- }: SessionUserProps) {
46
- const isBlocklet = useCreation(() => {
47
- return !!globalThis?.blocklet;
48
- }, []);
49
-
50
- const mode = globalThis?.blocklet?.SESSION_USER_MODE;
51
-
52
- if (session.user) {
53
- return (
54
- <LoggedIn
55
- isBlocklet={isBlocklet}
56
- session={session}
57
- onBindWallet={onBindWallet}
58
- locale={locale}
59
- size={size}
60
- popperType={popperType}
61
- profileUrl={profileUrl}
62
- mode={mode}
63
- renderUserButton={renderUserButton}
64
- />
65
- );
66
- }
67
- return <UnLogin session={session} locale={locale} size={size} />;
68
- }
@@ -1,30 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
- import type { Translations } from '../../type';
3
-
4
- export const translations: Translations = {
5
- en: {
6
- connectDIDWallet: 'Connect your DID Wallet for enhanced security',
7
- switch: 'Switch',
8
- profile: 'Profile',
9
- invite: 'Invite friends',
10
- inviteCopied:
11
- 'Your invite link has been copied to the clipboard. Send it to your friends to complete the invitation',
12
- dashboard: 'Dashboard',
13
- logout: 'Sign Out',
14
- addAnotherAccount: 'Add another account',
15
- disconnected: 'Disconnected',
16
- useQuickLogin: 'Use {name} account to login',
17
- },
18
- zh: {
19
- connectDIDWallet: '连接你的 DID Wallet 获得更高的安全性',
20
- switch: '切换',
21
- profile: '个人中心',
22
- invite: '邀请好友',
23
- inviteCopied: '你的专属链接已经复制到剪贴板,发送给朋友即可完成邀请',
24
- dashboard: '控制台',
25
- logout: '退出登录',
26
- addAnotherAccount: '添加账户',
27
- disconnected: '未连接',
28
- useQuickLogin: '使用 {name} 账号登录',
29
- },
30
- };
@@ -1,39 +0,0 @@
1
- import { $TSFixMe, User } from '../../type';
2
-
3
- export const getSourceAppPid = (user: User) => user?.sourceAppPid;
4
-
5
- export const getCurrentAppPid = (user: User) => user?.sourceAppPid || window?.blocklet?.appPid;
6
-
7
- export function getPermanentDid(user: User) {
8
- return user?.did;
9
- }
10
-
11
- export function getConnectedAccounts(user: User) {
12
- return user?.connectedAccounts || user?.extraConfigs?.connectedAccounts || [];
13
- }
14
-
15
- export function getSourceProvider(user: User) {
16
- return user?.sourceProvider || user?.extraConfigs?.sourceProvider || 'wallet';
17
- }
18
-
19
- export function getSourceProviders(user: User) {
20
- const connectedAccounts = getConnectedAccounts(user);
21
- return connectedAccounts.map((item: $TSFixMe) => item.provider);
22
- }
23
-
24
- export function getConnectedDids(user: User) {
25
- const connectedAccounts = getConnectedAccounts(user);
26
- const didList = connectedAccounts.map((item: $TSFixMe) => item.did);
27
- return didList;
28
- }
29
-
30
- export function getWallet(user: User) {
31
- const connectedAccounts = getConnectedAccounts(user);
32
- const walletAccount = connectedAccounts.find((item: $TSFixMe) => item.provider === 'wallet');
33
- return walletAccount;
34
- }
35
-
36
- export function getWalletDid(user: User) {
37
- const walletAccount = getWallet(user);
38
- return walletAccount?.did;
39
- }
@@ -1,126 +0,0 @@
1
- import { Box } from '@mui/material';
2
- import type { SxProps } from '@mui/material';
3
- import { memo, useEffect, useId, useImperativeHandle, useRef } from 'react';
4
- import { withQuery } from 'ufo';
5
- import { useMemoizedFn, useReactive } from 'ahooks';
6
- import noop from 'lodash/noop';
7
-
8
- import { mergeSx } from '../Util/style';
9
- import { callIframe, getCallbackAction } from '../Util/iframe';
10
-
11
- function SharedBridge({
12
- ref = undefined,
13
- src,
14
- onClick,
15
- onLoad = noop,
16
- sx = {},
17
- ...rest
18
- }: {
19
- src: string;
20
- onClick: (data: { action: string; value: boolean; visitorId?: string; error?: Error }) => void;
21
- onLoad?: () => void;
22
- sx?: SxProps;
23
- } & {
24
- ref?: React.Ref<unknown>;
25
- }) {
26
- const targetIframeRef = useRef<HTMLIFrameElement>(null);
27
- const refId = useId();
28
- const dataId = `shared-bridge_${refId}`;
29
- const currentState = useReactive<{
30
- hasInited?: boolean;
31
- open: boolean;
32
- hasStorageAccess: boolean;
33
- origin: string;
34
- host: string;
35
- containerEl: HTMLDivElement | null;
36
- }>({
37
- hasInited: undefined,
38
- open: false,
39
- hasStorageAccess: false,
40
- containerEl: null,
41
- get origin() {
42
- try {
43
- return new URL(src).origin;
44
- } catch (error) {
45
- return src;
46
- }
47
- },
48
- get host() {
49
- try {
50
- return new URL(src).host;
51
- } catch (error) {
52
- return src;
53
- }
54
- },
55
- });
56
-
57
- useEffect(() => {
58
- async function handleMessage(event: MessageEvent) {
59
- const { data } = event;
60
- if (data.action === getCallbackAction(dataId, 'requestStorageAccess')) {
61
- currentState.open = false;
62
-
63
- if (!data.value) {
64
- onClick(data);
65
- return;
66
- }
67
-
68
- const { value: visitorId } = await callIframe(targetIframeRef.current as HTMLIFrameElement, 'getVisitorId');
69
- onClick({ ...data, visitorId });
70
- } else if (data.action === getCallbackAction(dataId, 'preRequestStorageAccess')) {
71
- currentState.open = true;
72
- }
73
- }
74
-
75
- window.addEventListener('message', handleMessage);
76
- return () => {
77
- window.removeEventListener('message', handleMessage);
78
- };
79
- // eslint-disable-next-line react-hooks/exhaustive-deps
80
- }, [onClick, dataId, targetIframeRef?.current]);
81
-
82
- const handleLoad = useMemoizedFn(() => {
83
- callIframe(targetIframeRef.current as HTMLIFrameElement, 'hasStorageAccess').then(({ value }) => {
84
- currentState.hasStorageAccess = value;
85
- currentState.hasInited = true;
86
- });
87
- // HACK: 如果目标 bridge 1s 内没有初始化,则认为目标 bridge 不兼容,不进行后续内容的加载
88
- setTimeout(() => {
89
- if (currentState.hasInited === undefined) {
90
- currentState.hasInited = false;
91
- }
92
- }, 1000);
93
- onLoad();
94
- });
95
-
96
- useImperativeHandle(ref, () => ({
97
- callIframe(action: string) {
98
- return callIframe(targetIframeRef.current as HTMLIFrameElement, action);
99
- },
100
- }));
101
- return (
102
- <Box
103
- {...rest}
104
- component="iframe"
105
- ref={targetIframeRef}
106
- onLoad={handleLoad}
107
- data-id={dataId}
108
- src={withQuery(src, { id: dataId })}
109
- sx={mergeSx(
110
- {
111
- border: 0,
112
- position: 'absolute',
113
- top: 0,
114
- left: 0,
115
- width: '100%',
116
- height: '100%',
117
- cursor: 'pointer',
118
- backgroundColor: 'transparent',
119
- },
120
- sx
121
- )}
122
- />
123
- );
124
- }
125
-
126
- export default memo(SharedBridge);
@@ -1,194 +0,0 @@
1
- /**
2
- * 社交媒体共享组件
3
- */
4
-
5
- import { Menu, MenuItem, Box, useTheme } from '@mui/material';
6
- import { useMemoizedFn } from 'ahooks';
7
- import { Icon } from '@iconify/react';
8
- import {
9
- FacebookIcon,
10
- FacebookShareButton,
11
- RedditIcon,
12
- RedditShareButton,
13
- TelegramIcon,
14
- TelegramShareButton,
15
- TwitterShareButton,
16
- XIcon,
17
- WeiboIcon,
18
- WeiboShareButton,
19
- LinkedinIcon,
20
- LinkedinShareButton,
21
- } from 'react-share';
22
- import Toast from '../Toast';
23
- import { translate } from '../Locale/util';
24
-
25
- const shareButtonStyle = {
26
- display: 'flex',
27
- alignItems: 'center',
28
- width: '100%',
29
- '& > button': {
30
- display: 'flex',
31
- alignItems: 'center',
32
- width: '100%',
33
- justifyContent: 'flex-start',
34
- },
35
- };
36
-
37
- export interface SharedProps {
38
- title: string; // 分享标题
39
- url: string; // 分享链接
40
- }
41
-
42
- const translations = {
43
- en: {
44
- copyLink: 'Copy Link',
45
- x: 'X (Twitter)',
46
- telegram: 'Telegram',
47
- reddit: 'Reddit',
48
- facebook: 'Facebook',
49
- weiBo: 'Weibo',
50
- linkedin: 'LinkedIn',
51
- copySuccess: 'Link copied to clipboard',
52
- },
53
- zh: {
54
- copyLink: '复制链接',
55
- x: 'X (Twitter)',
56
- telegram: 'Telegram',
57
- reddit: 'Reddit',
58
- facebook: 'Facebook',
59
- weiBo: '微博',
60
- linkedin: 'LinkedIn',
61
- copySuccess: '链接已复制到剪贴板',
62
- },
63
- };
64
-
65
- const buttonSx = {
66
- display: 'flex',
67
- alignItems: 'center',
68
- gap: 1.5,
69
- minWidth: 120,
70
- lineHeight: '1!important',
71
- };
72
-
73
- const itemIconSx = (theme: any) => ({
74
- display: 'flex',
75
- alignItems: 'center',
76
- justifyContent: 'center',
77
- width: 22,
78
- height: 22,
79
- border: 1,
80
- borderColor: theme.palette.text.secondary,
81
- borderRadius: 0.75,
82
- });
83
-
84
- export default function SocialShare({
85
- anchorEl,
86
- onClose,
87
- sharedProps,
88
- locale = 'en',
89
- }: {
90
- anchorEl: HTMLElement | null;
91
- onClose: () => void;
92
- sharedProps: SharedProps;
93
- locale?: string;
94
- }) {
95
- const theme = useTheme();
96
- const shareOpen = Boolean(anchorEl);
97
-
98
- const t = useMemoizedFn((key, data = {}) => {
99
- return translate(translations, key, locale, 'en', data);
100
- });
101
-
102
- const iconProps = {
103
- bgStyle: { fill: theme.palette.background.paper },
104
- iconFillColor: theme.palette.text.secondary,
105
- };
106
-
107
- const { title, url } = sharedProps;
108
-
109
- const handleCopyLink = () => {
110
- if (!url) {
111
- return;
112
- }
113
- navigator.clipboard.writeText(url).then(() => {
114
- Toast.success(t('copySuccess'));
115
- });
116
- };
117
-
118
- return (
119
- <Menu
120
- id="basic-menu"
121
- anchorEl={anchorEl}
122
- open={shareOpen}
123
- onClose={onClose}
124
- anchorOrigin={{
125
- vertical: 'top',
126
- horizontal: 'right',
127
- }}
128
- transformOrigin={{
129
- vertical: 'top',
130
- horizontal: 'left',
131
- }}
132
- sx={{
133
- '& .MuiPaper-root': {
134
- marginTop: '-140px', // 向上移动菜单
135
- },
136
- }}
137
- slotProps={{
138
- paper: {
139
- 'aria-labelledby': 'basic-button',
140
- },
141
- }}>
142
- <MenuItem
143
- key="copy-to-clipboard"
144
- onClick={() => {
145
- handleCopyLink();
146
- onClose();
147
- }}
148
- sx={shareButtonStyle}>
149
- <Box sx={buttonSx}>
150
- <Box sx={itemIconSx}>
151
- <Icon icon="tabler:link" />
152
- </Box>
153
- <span>{t('copyLink')}</span>
154
- </Box>
155
- </MenuItem>
156
- <MenuItem key="share-to-x" onClick={onClose} sx={shareButtonStyle}>
157
- <Box component={TwitterShareButton} url={url} title={title} sx={buttonSx}>
158
- <Box component={XIcon} sx={itemIconSx} round {...iconProps} />
159
- <span>{t('x')}</span>
160
- </Box>
161
- </MenuItem>
162
- <MenuItem key="share-to-telegram" onClick={onClose} sx={shareButtonStyle}>
163
- <Box component={TelegramShareButton} url={url} title={title} sx={buttonSx}>
164
- <Box component={TelegramIcon} sx={itemIconSx} round {...iconProps} />
165
- <span>{t('telegram')}</span>
166
- </Box>
167
- </MenuItem>
168
- <MenuItem key="share-to-reddit" onClick={onClose} sx={shareButtonStyle}>
169
- <Box component={RedditShareButton} url={url} title={title} sx={buttonSx}>
170
- <Box component={RedditIcon} sx={itemIconSx} round {...iconProps} />
171
- <span>{t('reddit')}</span>
172
- </Box>
173
- </MenuItem>
174
- <MenuItem key="share-to-weibo" onClick={onClose} sx={shareButtonStyle}>
175
- <Box component={WeiboShareButton} url={url} title={title} sx={buttonSx}>
176
- <Box component={WeiboIcon} sx={itemIconSx} round {...iconProps} />
177
- <span>{t('weiBo')}</span>
178
- </Box>
179
- </MenuItem>
180
- <MenuItem key="share-to-facebook" onClick={onClose} sx={shareButtonStyle}>
181
- <Box component={FacebookShareButton} url={url} title={title} sx={buttonSx}>
182
- <Box component={FacebookIcon} sx={itemIconSx} round {...iconProps} />
183
- <span>{t('facebook')}</span>
184
- </Box>
185
- </MenuItem>
186
- <MenuItem key="share-to-linkedin" onClick={onClose} sx={shareButtonStyle}>
187
- <Box component={LinkedinShareButton} url={url} title={title} sx={buttonSx}>
188
- <Box component={LinkedinIcon} sx={itemIconSx} round {...iconProps} />
189
- <span>{t('linkedin')}</span>
190
- </Box>
191
- </MenuItem>
192
- </Menu>
193
- );
194
- }
@@ -1,13 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
-
3
- export default {
4
- title: 'Data-Display/Sparkline',
5
-
6
- parameters: {
7
- docs: {
8
- description: {
9
- component: 'Line Graph',
10
- },
11
- },
12
- },
13
- };
@@ -1,231 +0,0 @@
1
- // origin: https://github.com/fnando/sparkline
2
- function getY(max: number, height: number, diff: number, value: number) {
3
- return parseFloat((height - (value * height) / max + diff).toFixed(2));
4
- }
5
-
6
- function removeChildren(svg: SVGElement) {
7
- [...svg.querySelectorAll('*')].forEach((element) => svg.removeChild(element));
8
- }
9
-
10
- function defaultFetch(entry: { value: number }) {
11
- return entry.value;
12
- }
13
-
14
- function buildElement(tag: string, attrs: Record<string, any>) {
15
- const element = document.createElementNS('http://www.w3.org/2000/svg', tag);
16
-
17
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
18
- for (const name in attrs) {
19
- element.setAttribute(name, attrs[name]);
20
- }
21
-
22
- return element;
23
- }
24
-
25
- export default function sparkline(
26
- svg: SVGElement,
27
- rawEntries: number[] | { value: number }[] = [],
28
- options: {
29
- fetch?: (entry: { value: number }) => number;
30
- interactive?: boolean;
31
- onmousemove?: (event: MouseEvent, currentDataPoint: { value: number; index: number; x: number; y: number }) => void;
32
- onmouseout?: (event: MouseEvent) => void;
33
- spotRadius?: number;
34
- cursorWidth?: number;
35
- } = {}
36
- ) {
37
- removeChildren(svg);
38
-
39
- if (rawEntries.length <= 1) {
40
- return;
41
- }
42
-
43
- let entries: { value: number }[] = [];
44
- if (typeof rawEntries[0] === 'number') {
45
- entries = (rawEntries as number[]).map((entry) => {
46
- return { value: entry };
47
- });
48
- } else {
49
- entries = rawEntries as typeof entries;
50
- }
51
-
52
- // This function will be called whenever the mouse moves
53
- // over the SVG. You can use it to render something like a
54
- // tooltip.
55
- const { onmousemove } = options;
56
-
57
- // This function will be called whenever the mouse leaves
58
- // the SVG area. You can use it to hide the tooltip.
59
- const { onmouseout } = options;
60
-
61
- // Should we run in interactive mode? If yes, this will handle the
62
- // cursor and spot position when moving the mouse.
63
- const interactive = 'interactive' in options ? options.interactive : !!onmousemove;
64
-
65
- // Define how big should be the spot area.
66
- const spotRadius = options.spotRadius || 2;
67
- const spotDiameter = spotRadius * 2;
68
-
69
- // Define how wide should be the cursor area.
70
- const cursorWidth = options.cursorWidth || 2;
71
-
72
- // Get the stroke width; this is used to compute the
73
- // rendering offset.
74
- // @ts-expect-error
75
- const strokeWidth = parseFloat(svg.attributes['stroke-width'].value);
76
-
77
- // By default, data must be formatted as an array of numbers or
78
- // an array of objects with the value key (like `[{value: 1}]`).
79
- // You can set a custom function to return data for a different
80
- // data structure.
81
- const fetch = options.fetch || defaultFetch;
82
-
83
- // Retrieve only values, easing the find for the maximum value.
84
- const values = entries.map((entry) => fetch(entry));
85
-
86
- // The rendering width will account for the spot size.
87
- // @ts-expect-error
88
- const width = parseFloat(svg.attributes.width.value) - spotDiameter * 2;
89
-
90
- // Get the SVG element's full height.
91
- // This is used
92
- // @ts-expect-error
93
- const fullHeight = parseFloat(svg.attributes.height.value);
94
-
95
- // The rendering height accounts for stroke width and spot size.
96
- const height = fullHeight - strokeWidth * 2 - spotDiameter;
97
-
98
- // The maximum value. This is used to calculate the Y coord of
99
- // each sparkline datapoint.
100
- const max = Math.max(...values) === 0 ? 1 : Math.max(...values);
101
-
102
- // Some arbitrary value to remove the cursor and spot out of
103
- // the viewing canvas.
104
- const offscreen = -1000;
105
-
106
- // Cache the last item index.
107
- const lastItemIndex = values.length - 1;
108
-
109
- // Calculate the X coord base step.
110
- const offset = width / lastItemIndex;
111
-
112
- // Hold all datapoints, which is whatever we got as the entry plus
113
- // x/y coords and the index.
114
- const datapoints: { value: number; index: number; x: number; y: number }[] = [];
115
-
116
- // Hold the line coordinates.
117
- const pathY = getY(max, height, strokeWidth + spotRadius, values[0]);
118
- let pathCoords = `M${spotDiameter} ${pathY}`;
119
-
120
- values.forEach((value, index) => {
121
- const x = index * offset + spotDiameter;
122
- const y = getY(max, height, strokeWidth + spotRadius, value);
123
-
124
- datapoints.push(
125
- Object.assign({}, entries[index], {
126
- index,
127
- x,
128
- y,
129
- })
130
- );
131
-
132
- pathCoords += ` L ${x} ${y}`;
133
- });
134
-
135
- const path = buildElement('path', {
136
- class: 'sparkline--line',
137
- d: pathCoords,
138
- fill: 'none',
139
- });
140
-
141
- const fillCoords = `${pathCoords} V ${fullHeight} L ${spotDiameter} ${fullHeight} Z`;
142
-
143
- const fill = buildElement('path', {
144
- class: 'sparkline--fill',
145
- d: fillCoords,
146
- stroke: 'none',
147
- });
148
-
149
- svg.appendChild(fill);
150
- svg.appendChild(path);
151
-
152
- if (!interactive) {
153
- return;
154
- }
155
-
156
- const cursor = buildElement('line', {
157
- class: 'sparkline--cursor',
158
- x1: offscreen,
159
- x2: offscreen,
160
- y1: 0,
161
- y2: fullHeight,
162
- 'stroke-width': cursorWidth,
163
- });
164
-
165
- const spot = buildElement('circle', {
166
- class: 'sparkline--spot',
167
- cx: offscreen,
168
- cy: offscreen,
169
- r: spotRadius,
170
- });
171
-
172
- svg.appendChild(cursor);
173
- svg.appendChild(spot);
174
-
175
- const interactionLayer = buildElement('rect', {
176
- // @ts-expect-error
177
- width: svg.attributes.width.value,
178
- // @ts-expect-error
179
- height: svg.attributes.height.value,
180
- style: 'fill: transparent; stroke: transparent',
181
- class: 'sparkline--interaction-layer',
182
- });
183
- svg.appendChild(interactionLayer);
184
-
185
- interactionLayer.addEventListener('mouseout', (event) => {
186
- cursor.setAttribute('x1', offscreen.toString());
187
- cursor.setAttribute('x2', offscreen.toString());
188
-
189
- spot.setAttribute('cx', offscreen.toString());
190
-
191
- if (onmouseout) {
192
- onmouseout(event);
193
- }
194
- });
195
-
196
- interactionLayer.addEventListener('mousemove', (event) => {
197
- const mouseX = event.offsetX;
198
-
199
- let nextDataPoint = datapoints.find((entry) => {
200
- return entry.x >= mouseX;
201
- });
202
-
203
- if (!nextDataPoint) {
204
- nextDataPoint = datapoints[lastItemIndex];
205
- }
206
-
207
- const previousDataPoint = datapoints[datapoints.indexOf(nextDataPoint) - 1];
208
- let currentDataPoint;
209
- let halfway;
210
-
211
- if (previousDataPoint) {
212
- halfway = previousDataPoint.x + (nextDataPoint.x - previousDataPoint.x) / 2;
213
- currentDataPoint = mouseX >= halfway ? nextDataPoint : previousDataPoint;
214
- } else {
215
- currentDataPoint = nextDataPoint;
216
- }
217
-
218
- const { x } = currentDataPoint;
219
- const { y } = currentDataPoint;
220
-
221
- spot.setAttribute('cx', x.toString());
222
- spot.setAttribute('cy', y.toString());
223
-
224
- cursor.setAttribute('x1', x.toString());
225
- cursor.setAttribute('x2', x.toString());
226
-
227
- if (onmousemove) {
228
- onmousemove(event, currentDataPoint);
229
- }
230
- });
231
- }