@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
package/src/global.d.ts DELETED
@@ -1,28 +0,0 @@
1
- declare module '@arcblock/did-motif';
2
- declare module 'd3-geo';
3
- declare module 'topojson-client';
4
- declare module 'versor';
5
- declare module 'axios/*';
6
-
7
- // ux svg 由 babel-plugin-inline-react-svg 处理
8
- declare module '*.svg?react' {
9
- import React from 'react';
10
- const SVG: React.FC<React.SVGProps<SVGSVGElement>>;
11
- export default SVG;
12
- }
13
-
14
- declare module '*.png' {
15
- export default string;
16
- }
17
-
18
- type Blocklet = import('./type').Blocklet;
19
-
20
- interface Window {
21
- blocklet?: Blocklet;
22
- env?: Blocklet;
23
- }
24
-
25
- declare module globalThis {
26
- var blocklet: Blocklet;
27
- var env: Blocklet;
28
- }
@@ -1,32 +0,0 @@
1
- import { type Breakpoint } from '@mui/material';
2
- import { type ThemeOptions } from '@blocklet/theme';
3
- import { useCreation } from 'ahooks';
4
- import { useTheme } from '../Theme';
5
- import useMobile from './use-mobile';
6
-
7
- export default function useBlockletLogo({
8
- key = 'sm',
9
- meta = {},
10
- theme: themeOverrides = {},
11
- square,
12
- }: { key?: number | Breakpoint; meta?: any; theme?: ThemeOptions; square?: boolean } = {}) {
13
- const isMobileDevice = useMobile({ key });
14
- const theme = useTheme();
15
-
16
- const mode = useCreation(() => {
17
- return themeOverrides?.palette?.mode || theme.palette.mode;
18
- }, [theme, themeOverrides]);
19
-
20
- const finalAppLogo = useCreation<string>(() => {
21
- const { appLogo, appLogoDark, appLogoRect, appLogoRectDark } = Object.assign({}, window.blocklet ?? {}, meta);
22
- const isDark = mode === 'dark';
23
-
24
- const squareLogo = (isDark ? appLogoDark : appLogo) || appLogo;
25
- // 深色模式尽可能优先使用深色图标
26
- const rectLogo = (isDark ? appLogoRectDark || appLogoDark : appLogoRect) || appLogoRect;
27
-
28
- return isMobileDevice || square ? squareLogo : rectLogo || squareLogo || '';
29
- }, [mode, meta, isMobileDevice, square]);
30
-
31
- return finalAppLogo;
32
- }
@@ -1,62 +0,0 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import dayjs from 'dayjs';
3
- import 'dayjs/locale/zh-cn';
4
- import 'dayjs/locale/en';
5
- import utc from 'dayjs/plugin/utc';
6
- import timezonePlugin from 'dayjs/plugin/timezone';
7
- import localizedFormat from 'dayjs/plugin/localizedFormat';
8
-
9
- import { formatToDatetime } from '../Util';
10
-
11
- dayjs.extend(utc);
12
- dayjs.extend(timezonePlugin);
13
- dayjs.extend(localizedFormat);
14
-
15
- const currentTimezone = dayjs.tz.guess();
16
-
17
- // 获取时间段
18
- const getTimePhase = (hour: number) => {
19
- if (hour >= 0 && hour < 6) return { phase: 'dawn', icon: '🌒' }; // 凌晨 00:00-05:59
20
- if (hour >= 6 && hour < 12) return { phase: 'morning', icon: '🌞' }; // 上午 06:00-11:59
21
- if (hour >= 12 && hour < 18) return { phase: 'afternoon', icon: '🌞' }; // 下午 12:00-17:59
22
- return { phase: 'night', icon: '🌒' }; // 晚上 18:00-23:59
23
- };
24
-
25
- export default function useClock(timezone = currentTimezone, locale = 'zh') {
26
- const getLatestTimeInfo = useCallback(() => {
27
- const currentLocale = locale === 'zh' ? 'zh-cn' : 'en';
28
- const localeOption = locale === 'zh' ? 'zh-cn' : 'en-us';
29
- dayjs.locale(currentLocale);
30
-
31
- const now = dayjs().tz(timezone);
32
- const hour = now.hour();
33
- const { phase, icon } = getTimePhase(hour);
34
-
35
- return {
36
- formattedTime: now.format('LT'),
37
- fullDateTime: formatToDatetime(now.toDate(), { tz: timezone, locale: localeOption }),
38
- phase,
39
- icon,
40
- rawTime: now,
41
- };
42
- }, [timezone, locale]);
43
-
44
- const [timeInfo, setTimeInfo] = useState(getLatestTimeInfo());
45
-
46
- useEffect(() => {
47
- // 立即更新一次,确保初始状态是最新的
48
- setTimeInfo(getLatestTimeInfo());
49
-
50
- // 设置定时器
51
- const timerId = setInterval(() => {
52
- setTimeInfo(getLatestTimeInfo());
53
- }, 6000);
54
-
55
- // 清理函数
56
- return () => {
57
- clearInterval(timerId);
58
- };
59
- }, [timezone, locale, getLatestTimeInfo]);
60
-
61
- return timeInfo;
62
- }
@@ -1,117 +0,0 @@
1
- /* eslint-disable no-restricted-globals */
2
- import { useEffect, useState } from 'react';
3
-
4
- type UrlChangeCallback = (location: Location) => void;
5
-
6
- const subscribers = new Set<UrlChangeCallback>();
7
- let patched = false;
8
- let lastHref = '';
9
-
10
- // 检查是否在浏览器环境中
11
- const isBrowser = typeof window !== 'undefined';
12
-
13
- function notifyIfChanged() {
14
- if (!isBrowser) return;
15
-
16
- const currentHref = window.location.href;
17
- if (currentHref !== lastHref) {
18
- lastHref = currentHref;
19
- subscribers.forEach((cb) => cb(window.location));
20
- }
21
- }
22
-
23
- function patchHistoryOnce() {
24
- if (!isBrowser || patched) return;
25
- patched = true;
26
-
27
- const originalPushState = history.pushState;
28
- history.pushState = function patchedPushState(...args) {
29
- const result = originalPushState.apply(this, args);
30
- notifyIfChanged();
31
- return result;
32
- };
33
-
34
- const originalReplaceState = history.replaceState;
35
- history.replaceState = function patchedReplaceState(...args) {
36
- const result = originalReplaceState.apply(this, args);
37
- notifyIfChanged();
38
- return result;
39
- };
40
-
41
- window.addEventListener('popstate', notifyIfChanged);
42
- window.addEventListener('hashchange', notifyIfChanged);
43
- }
44
-
45
- function subscribeUrlChange(callback: UrlChangeCallback): () => void {
46
- if (isBrowser) {
47
- patchHistoryOnce();
48
- subscribers.add(callback);
49
- }
50
- return () => {
51
- subscribers.delete(callback);
52
- };
53
- }
54
-
55
- export interface LocationLike {
56
- href: string;
57
- origin: string;
58
- host: string;
59
- hostname: string;
60
- port: string;
61
- protocol: string;
62
- pathname: string;
63
- search: string;
64
- hash: string;
65
- }
66
-
67
- function extractLocation(location: Location): LocationLike {
68
- return {
69
- href: location.href,
70
- origin: location.origin,
71
- host: location.host,
72
- hostname: location.hostname,
73
- pathname: location.pathname,
74
- port: location.port,
75
- protocol: location.protocol,
76
- search: location.search,
77
- hash: location.hash,
78
- };
79
- }
80
-
81
- const defaultLocation: LocationLike = {
82
- href: '',
83
- origin: '',
84
- host: '',
85
- hostname: '',
86
- port: '',
87
- protocol: '',
88
- pathname: '',
89
- search: '',
90
- hash: '',
91
- };
92
-
93
- /**
94
- * 监听 location 变化,返回当前 location 状态
95
- */
96
- export function useLocationState(): LocationLike {
97
- const [location, setLocation] = useState<LocationLike>(() => {
98
- if (!isBrowser) {
99
- return defaultLocation;
100
- }
101
- return extractLocation(window.location);
102
- });
103
-
104
- useEffect(() => {
105
- if (!isBrowser) {
106
- return undefined;
107
- }
108
-
109
- return subscribeUrlChange((newLocation) => {
110
- setLocation(extractLocation(newLocation));
111
- });
112
- }, []);
113
-
114
- return location;
115
- }
116
-
117
- export default useLocationState;
@@ -1,6 +0,0 @@
1
- import { Breakpoint, useTheme, useMediaQuery } from '@mui/material';
2
-
3
- export default function useMobile({ key = 'sm' }: { key?: number | Breakpoint } = {}) {
4
- const theme = useTheme();
5
- return useMediaQuery(theme.breakpoints.down(key));
6
- }
package/src/index.ts DELETED
@@ -1,79 +0,0 @@
1
- import ActionButton from './ActionButton';
2
- import ActivityIndicator from './ActivityIndicator';
3
- import Address from './Address';
4
- import Alert from './Alert';
5
- import AnimationWaiter from './AnimationWaiter';
6
- import Async from './Async';
7
- import Avatar from './Avatar';
8
- import Badge from './Badge';
9
- import Button from './Button';
10
- import ClickToCopy from './ClickToCopy';
11
- import CodeBlock from './CodeBlock';
12
- import ContactForm from './ContactForm';
13
- import CountDown from './CountDown';
14
- import Earth from './Earth';
15
- import Footer from './Footer';
16
- import Icon from './Icon';
17
- import LocaleSelector from './Locale/selector';
18
- import Logo from './Logo';
19
- import RelativeTime from './RelativeTime';
20
- import SessionManager from './SessionManager';
21
- import Datatable from './Datatable';
22
- import Dialog from './Dialog';
23
- import DIDLogo from './DIDLogo';
24
- import SocialShare from './SocialShare';
25
- import Tabs from './Tabs';
26
- import Tag from './Tag';
27
- import TextCollapse from './TextCollapse';
28
- import * as Theme from './Theme';
29
- import Toast from './Toast';
30
- import * as Util from './Util';
31
- import Video from './Video';
32
- import WebWalletSWKeeper from './WebWalletSWKeeper';
33
- import WalletAction from './Wallet/Action';
34
- import WalletDownload from './Wallet/Download';
35
- import WechatPrompt from './WechatPrompt';
36
- import withTheme from './withTheme';
37
- import withTracker from './withTracker';
38
- import Img from './Img';
39
-
40
- export {
41
- ActionButton,
42
- ActivityIndicator,
43
- Address,
44
- Alert,
45
- AnimationWaiter,
46
- Async,
47
- Avatar,
48
- Badge,
49
- Button,
50
- ClickToCopy,
51
- CodeBlock,
52
- ContactForm,
53
- CountDown,
54
- Earth,
55
- Footer,
56
- Icon,
57
- LocaleSelector,
58
- Logo,
59
- Tabs,
60
- RelativeTime,
61
- SessionManager,
62
- Datatable,
63
- Dialog,
64
- DIDLogo,
65
- SocialShare,
66
- Tag,
67
- TextCollapse,
68
- Theme,
69
- Toast,
70
- Util,
71
- Video,
72
- WebWalletSWKeeper,
73
- WalletAction,
74
- WalletDownload,
75
- WechatPrompt,
76
- withTheme,
77
- withTracker,
78
- Img,
79
- };
package/src/type.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import type { Theme } from '@mui/material';
2
- import type { LiteralUnion } from 'type-fest';
3
-
4
- export type $TSFixMe = any;
5
- export type Translations = Record<string, Record<string, any>>;
6
- export type Locale = LiteralUnion<'en' | 'zh', string>;
7
-
8
- // TODO: 以下为 blocklet 应用专属的全局对象类型,可以更加具体
9
- export type User = Record<string, any>;
10
- export type Session = Record<string, any>;
11
- export type Passport = Record<string, any>;
12
- export type Blocklet = {
13
- appId: string;
14
- appIds: string[];
15
- appPid: string;
16
- appName: string;
17
- appDescription: string;
18
- appLogo: string;
19
- appLogoRect: string;
20
- appUrl: string;
21
- isComponent: boolean;
22
- prefix: string;
23
- groupPrefix: string;
24
- pageGroup: string;
25
- version: string;
26
- mode: string;
27
- tenantMode: 'single' | 'multiple';
28
- theme: {
29
- prefer?: 'light' | 'dark' | 'system';
30
- light: Theme;
31
- dark: Theme;
32
- };
33
- navigation: $TSFixMe[];
34
- preferences: Record<string, any>;
35
- languages: {
36
- code: string;
37
- name: string;
38
- }[];
39
- passportColor: string;
40
- componentMountPoints: $TSFixMe[];
41
- alsoKnownAs: string[];
42
- trustedFactories: string[];
43
- [x: string]: any;
44
- };
@@ -1,72 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { Global, css } from '@emotion/react';
3
- import { CssBaseline, Breakpoint, type PaletteMode, type PaletteOptions } from '@mui/material';
4
- import { TypographyStyleOptions } from '@mui/material/styles/createTypography';
5
-
6
- import { createTheme, ThemeProvider } from '../Theme';
7
-
8
- function withTheme<P extends object>(
9
- Component: React.ComponentType<P>,
10
- {
11
- mode = 'light',
12
- pageWidth = 'md',
13
- palette,
14
- typography,
15
- }: { mode?: PaletteMode; pageWidth?: Breakpoint; palette?: PaletteOptions; typography?: TypographyStyleOptions } = {}
16
- ) {
17
- // @ts-expect-error
18
- const theme = createTheme({ mode, pageWidth, palette, typography });
19
-
20
- const color = theme.typography.color.main;
21
- const globalStyles = css`
22
- font-family: ${theme.typography.fontFamily};
23
- color: ${color};
24
-
25
- a,
26
- a:hover,
27
- a:active {
28
- text-decoration: none;
29
- color: ${theme.palette.primary.dark};
30
- }
31
-
32
- a:hover {
33
- color: ${theme.palette.primary.main};
34
- }
35
-
36
- .section--latest-post {
37
- p:last-of-type {
38
- margin: 0;
39
- }
40
- }
41
-
42
- .has-scrolled {
43
- .section--footnotes {
44
- position: static !important;
45
- transition-property: background-color;
46
- transition-duration: 600ms;
47
- transition-timing-function: ease;
48
- .footnote__title {
49
- color: #fff;
50
- }
51
- }
52
- }
53
- `;
54
-
55
- return function WithTheme(props: P) {
56
- useEffect(() => {
57
- const jssStyles = document.querySelector('#jss-server-side');
58
- if (jssStyles && jssStyles.parentNode) {
59
- jssStyles.parentNode.removeChild(jssStyles);
60
- }
61
- }, []);
62
- return (
63
- <ThemeProvider theme={theme}>
64
- <CssBaseline />
65
- <Global styles={globalStyles} />
66
- <Component {...props} />
67
- </ThemeProvider>
68
- );
69
- };
70
- }
71
-
72
- export default withTheme;
@@ -1,37 +0,0 @@
1
- # withTracker
2
-
3
- Add google analytics reporting to your application.
4
-
5
- ## Usage
6
-
7
- ### Installation
8
-
9
- ```bash
10
- yarn add @arcblock/ux
11
- ```
12
-
13
- ### Configuration & Usage
14
-
15
- In your application entry file
16
-
17
- ```javascript
18
- import React from 'react';
19
- import withTracker from '@arcblock/ux/lib/withTracker';
20
- import { BrowserRouter as Router } from 'react-router-dom';
21
-
22
- const App = () => <p>My awesome application</p>;
23
- const TrackedApp = withTracker(App);
24
-
25
- export default function WrappedApp() {
26
- // While the blocklet is deploy to a sub path, this will be work properly.
27
- const basename = window?.blocklet?.prefix || '/';
28
-
29
- return (
30
- <Router basename={basename}>
31
- <TrackedApp />
32
- </Router>
33
- );
34
- }
35
- ```
36
-
37
- Then you can use `window.trackPage(path, title)` and `window.trackEvent(category, action, label, value)` to track page views and events.
@@ -1,17 +0,0 @@
1
- import type { LiteralUnion } from 'type-fest';
2
-
3
- export interface BindWalletEvent {
4
- action: 'bindWalletSuccess' | 'bindWalletFailed';
5
- provider: LiteralUnion<'wallet' | 'apple' | 'github' | 'google' | 'email' | 'twitter' | 'passkey', string>;
6
- }
7
-
8
- export interface BindWalletSuccessEvent extends BindWalletEvent {
9
- action: 'bindWalletSuccess';
10
- success: true;
11
- }
12
-
13
- export interface BindWalletFailedEvent extends BindWalletEvent {
14
- action: 'bindWalletFailed';
15
- success: false;
16
- errorMessage: string;
17
- }
@@ -1,18 +0,0 @@
1
- import type { LiteralUnion } from 'type-fest';
2
-
3
- export interface LoginEvent {
4
- action: 'loginSuccess' | 'loginFailed';
5
- provider: LiteralUnion<'wallet' | 'apple' | 'github' | 'google' | 'email' | 'twitter' | 'passkey', string>;
6
- success: boolean;
7
- }
8
-
9
- export interface LoginSuccessEvent extends LoginEvent {
10
- action: 'loginSuccess';
11
- success: true;
12
- }
13
-
14
- export interface LoginFailedEvent extends LoginEvent {
15
- action: 'loginFailed';
16
- success: false;
17
- errorMessage: string;
18
- }
@@ -1,14 +0,0 @@
1
- export interface PayEvent {
2
- action: 'paySuccess' | 'payFailed';
3
- checkoutSessionMode: string;
4
- success: boolean;
5
- }
6
-
7
- export interface PaySuccessEvent extends PayEvent {
8
- success: true;
9
- }
10
-
11
- export interface PayFailedEvent extends PayEvent {
12
- success: false;
13
- errorMessage: string;
14
- }
@@ -1,20 +0,0 @@
1
- export interface SwitchPassportEvent {
2
- action: 'switchPassportSuccess' | 'switchPassportFailed';
3
- success: boolean;
4
- }
5
-
6
- export interface SwitchPassportSuccessEvent extends SwitchPassportEvent {
7
- success: true;
8
- /**
9
- *
10
- * @example guest -> admin
11
- * @type {string}
12
- * @memberof SwitchPassportEvent
13
- */
14
- change: string;
15
- }
16
-
17
- export interface SwitchPassportFailedEvent extends SwitchPassportEvent {
18
- success: false;
19
- errorMessage: string;
20
- }
@@ -1,3 +0,0 @@
1
- export const GA_LAST_LOGIN_METHOD = 'ga-last-login-method';
2
- export const GA_LAST_ROLE = 'ga-last-role';
3
- export const GA_LAST_SOURCE_PROVIDER = 'ga-last-source-provider';
@@ -1 +0,0 @@
1
- export const googleAnalyticsMeasurementId: string = window.blocklet?.GA_MEASUREMENT_ID || '';
@@ -1,34 +0,0 @@
1
- /* eslint-disable import/no-unresolved */
2
- import { Component } from 'react';
3
- import * as Sentry from '@sentry/browser';
4
-
5
- import Alert from '../Alert';
6
-
7
- export default class ErrorBoundary extends Component {
8
- constructor(props) {
9
- super(props);
10
- this.state = { error: null };
11
- }
12
-
13
- componentDidCatch(error, info) {
14
- this.setState({ error });
15
-
16
- Sentry.withScope((scope) => {
17
- scope.setExtras(info);
18
- Sentry.captureException(error);
19
- });
20
- }
21
-
22
- render() {
23
- if (this.state.error) {
24
- return (
25
- <Alert type="error" variant="icon">
26
- Oops! We encountered an error, please try reload this application.
27
- </Alert>
28
- );
29
- }
30
-
31
- // eslint-disable-next-line react/prop-types
32
- return this.props.children;
33
- }
34
- }
@@ -1,50 +0,0 @@
1
- import { useLocation } from 'react-router-dom';
2
- import { useMount, useDeepCompareEffect } from 'ahooks';
3
- import ReactGA from 'react-ga4';
4
- import { googleAnalyticsMeasurementId } from './env';
5
-
6
- let isInitialized = false;
7
-
8
- const initializeGA = () => {
9
- if (googleAnalyticsMeasurementId && !isInitialized) {
10
- ReactGA.initialize(googleAnalyticsMeasurementId);
11
- isInitialized = true;
12
- }
13
- };
14
-
15
- export { ReactGA };
16
-
17
- export default <P extends object>(WrappedComponent: React.ComponentType<P>) => {
18
- const trackPage = (page: string, title = document.title) => {
19
- initializeGA();
20
- if (googleAnalyticsMeasurementId) {
21
- ReactGA.send({ hitType: 'pageview', page, title });
22
- }
23
- };
24
-
25
- const trackEvent = (category: string, action: string, label: string, value: number) => {
26
- initializeGA();
27
- if (googleAnalyticsMeasurementId) {
28
- ReactGA.event({ category, action, label, value, transport: 'beacon' });
29
- }
30
- };
31
-
32
- // @ts-ignore
33
- window.trackPage = trackPage;
34
- // @ts-ignore
35
- window.trackEvent = trackEvent;
36
-
37
- return function TrackedComponent(props: P) {
38
- const location = useLocation();
39
-
40
- useMount(() => {
41
- trackPage(location.pathname);
42
- });
43
-
44
- useDeepCompareEffect(() => {
45
- trackPage(location.pathname);
46
- }, [location.pathname]);
47
-
48
- return <WrappedComponent {...props} />;
49
- };
50
- };