@arcblock/ux 2.10.66 → 2.10.68

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. package/lib/Address/did-address.d.ts +6 -5
  2. package/lib/Address/index.d.ts +1 -1
  3. package/lib/Avatar/index.d.ts +10 -8
  4. package/lib/Avatar/index.js +6 -4
  5. package/lib/Blocklet/blocklet.d.ts +4 -4
  6. package/lib/Blocklet/blocklet.js +2 -2
  7. package/lib/BlockletContext/index.d.ts +3 -3
  8. package/lib/BlockletNFT/index.d.ts +6 -6
  9. package/lib/BlockletNFT/index.js +3 -3
  10. package/lib/BlockletV2/blocklet.d.ts +2 -2
  11. package/lib/Button/wrap.d.ts +4 -4
  12. package/lib/Button/wrap.js +2 -2
  13. package/lib/CardSelector/index.js +0 -1
  14. package/lib/Center/index.d.ts +1 -1
  15. package/lib/ClickToCopy/copy-button.d.ts +5 -4
  16. package/lib/ClickToCopy/copy-button.js +0 -1
  17. package/lib/ClickToCopy/hook.d.ts +3 -8
  18. package/lib/ClickToCopy/index.d.ts +6 -4
  19. package/lib/CodeBlock/index.d.ts +3 -1
  20. package/lib/CookieConsent/index.d.ts +8 -29
  21. package/lib/CookieConsent/index.js +3 -17
  22. package/lib/CountDown/index.d.ts +21 -25
  23. package/lib/CountDown/index.js +12 -11
  24. package/lib/DID/index.d.ts +9 -8
  25. package/lib/Datatable/index.d.ts +5 -5
  26. package/lib/Datatable/index.js +5 -5
  27. package/lib/Dialog/confirm.d.ts +6 -6
  28. package/lib/Dialog/confirm.js +3 -3
  29. package/lib/Dialog/types.d.ts +1 -1
  30. package/lib/DidLogo/index.d.ts +5 -25
  31. package/lib/DidLogo/index.js +4 -15
  32. package/lib/DriftBot/index.d.ts +13 -19
  33. package/lib/DriftBot/index.js +5 -6
  34. package/lib/Earth/index.d.ts +28 -10
  35. package/lib/Earth/index.js +12 -52
  36. package/lib/Earth/util.d.ts +10 -5
  37. package/lib/Earth/util.js +1 -0
  38. package/lib/ErrorBoundary/fallback.d.ts +12 -19
  39. package/lib/ErrorBoundary/fallback.js +2 -19
  40. package/lib/ErrorBoundary/index.d.ts +1 -1
  41. package/lib/Footer/index.d.ts +17 -24
  42. package/lib/Footer/index.js +2 -11
  43. package/lib/Header/header.d.ts +2 -2
  44. package/lib/Icon/image.d.ts +3 -2
  45. package/lib/Icon/index.d.ts +6 -4
  46. package/lib/Img/index.d.ts +1 -1
  47. package/lib/Img/index.js +1 -1
  48. package/lib/InfoRow/index.d.ts +9 -32
  49. package/lib/InfoRow/index.js +10 -23
  50. package/lib/Layout/dashboard/external-link.d.ts +13 -14
  51. package/lib/Layout/dashboard/external-link.js +5 -22
  52. package/lib/Layout/dashboard/full-page.d.ts +19 -11
  53. package/lib/Layout/dashboard/full-page.js +2 -6
  54. package/lib/Layout/dashboard/index.d.ts +20 -39
  55. package/lib/Layout/dashboard/index.js +10 -38
  56. package/lib/Layout/dashboard/sidebar.d.ts +17 -20
  57. package/lib/Layout/dashboard/sidebar.js +3 -16
  58. package/lib/Layout/dashboard-legacy/header.d.ts +10 -36
  59. package/lib/Layout/dashboard-legacy/header.js +5 -24
  60. package/lib/Layout/dashboard-legacy/index.d.ts +17 -56
  61. package/lib/Layout/dashboard-legacy/index.js +12 -41
  62. package/lib/Layout/dashboard-legacy/sidebar.d.ts +15 -26
  63. package/lib/Layout/dashboard-legacy/sidebar.js +5 -15
  64. package/lib/Layout/index.d.ts +17 -56
  65. package/lib/Layout/index.js +24 -50
  66. package/lib/LoadingMask/index.d.ts +8 -31
  67. package/lib/LoadingMask/index.js +2 -18
  68. package/lib/Locale/browser-lang.d.ts +4 -1
  69. package/lib/Locale/browser-lang.js +8 -3
  70. package/lib/Locale/context.d.ts +18 -8
  71. package/lib/Locale/context.js +1 -1
  72. package/lib/Locale/languages.d.ts +9 -55
  73. package/lib/Locale/selector.d.ts +10 -26
  74. package/lib/Locale/selector.js +8 -25
  75. package/lib/Locale/util.d.ts +4 -3
  76. package/lib/Locale/util.js +0 -1
  77. package/lib/Logo/index.d.ts +9 -40
  78. package/lib/Logo/index.js +88 -46
  79. package/lib/Metric/index.d.ts +9 -31
  80. package/lib/Metric/index.js +5 -20
  81. package/lib/NFTDisplay/aspect-ratio-container.d.ts +5 -12
  82. package/lib/NFTDisplay/aspect-ratio-container.js +0 -5
  83. package/lib/NFTDisplay/broken.d.ts +3 -13
  84. package/lib/NFTDisplay/broken.js +80 -10
  85. package/lib/NFTDisplay/displayApi.d.ts +1 -1
  86. package/lib/NFTDisplay/index.d.ts +28 -6
  87. package/lib/NFTDisplay/index.js +17 -51
  88. package/lib/NFTDisplay/svg-embedder/img.d.ts +8 -23
  89. package/lib/NFTDisplay/svg-embedder/img.js +3 -17
  90. package/lib/NFTDisplay/svg-embedder/inline-svg.d.ts +7 -13
  91. package/lib/NFTDisplay/svg-embedder/inline-svg.js +1 -8
  92. package/lib/NavMenu/nav-menu.d.ts +2 -0
  93. package/lib/NavMenu/nav-menu.js +0 -1
  94. package/lib/PageScroller/index.d.ts +14 -13
  95. package/lib/PageScroller/index.js +12 -37
  96. package/lib/PageScroller/usePrevValue.d.ts +1 -1
  97. package/lib/PageScroller/usePrevValue.js +1 -2
  98. package/lib/Passport/index.d.ts +1 -1
  99. package/lib/Passport/passport.d.ts +10 -30
  100. package/lib/Passport/passport.js +5 -19
  101. package/lib/PoweredByArcBlock/index.d.ts +4 -14
  102. package/lib/PoweredByArcBlock/index.js +1 -8
  103. package/lib/PricingTable/PricingPlan.d.ts +11 -9
  104. package/lib/PricingTable/PricingPlan.js +0 -4
  105. package/lib/PricingTable/index.d.ts +5 -3
  106. package/lib/PricingTable/index.js +1 -5
  107. package/lib/QRCode/index.d.ts +11 -22
  108. package/lib/QRCode/index.js +1 -15
  109. package/lib/RelativeTime/index.d.ts +12 -40
  110. package/lib/RelativeTime/index.js +7 -27
  111. package/lib/Result/common.d.ts +26 -45
  112. package/lib/Result/common.js +2 -4
  113. package/lib/Result/index.d.ts +5 -18
  114. package/lib/Result/index.js +1 -9
  115. package/lib/Result/result.d.ts +7 -29
  116. package/lib/Result/result.js +2 -17
  117. package/lib/Result/translations.d.ts +2 -54
  118. package/lib/Screenshot/BaseScreenshot/index.d.ts +7 -24
  119. package/lib/Screenshot/BaseScreenshot/index.js +2 -15
  120. package/lib/Screenshot/BaseScreenshot/shells/Macbook.d.ts +25 -19
  121. package/lib/Screenshot/BaseScreenshot/shells/Phone.d.ts +25 -19
  122. package/lib/Screenshot/index.d.ts +84 -28
  123. package/lib/Screenshot/index.js +14 -43
  124. package/lib/SessionBlocklet/index.d.ts +6 -19
  125. package/lib/SessionBlocklet/index.js +3 -14
  126. package/lib/SessionManager/index.d.ts +1 -1
  127. package/lib/SessionPermission/index.d.ts +9 -17
  128. package/lib/SessionPermission/index.js +3 -11
  129. package/lib/SessionUser/components/logged-in.d.ts +9 -31
  130. package/lib/SessionUser/components/logged-in.js +13 -29
  131. package/lib/SessionUser/components/session-user-item.d.ts +8 -1
  132. package/lib/SessionUser/components/session-user-item.js +2 -12
  133. package/lib/SessionUser/components/session-user-switch.d.ts +9 -21
  134. package/lib/SessionUser/components/session-user-switch.js +3 -15
  135. package/lib/SessionUser/components/un-login.d.ts +7 -23
  136. package/lib/SessionUser/components/un-login.js +4 -16
  137. package/lib/SessionUser/components/user-info.d.ts +12 -29
  138. package/lib/SessionUser/components/user-info.js +4 -19
  139. package/lib/SessionUser/index.d.ts +7 -30
  140. package/lib/SessionUser/index.js +5 -26
  141. package/lib/SessionUser/libs/translation.d.ts +2 -31
  142. package/lib/SessionUser/libs/translation.js +1 -0
  143. package/lib/SessionUser/libs/utils.d.ts +10 -9
  144. package/lib/Sparkline/index.d.ts +22 -1
  145. package/lib/Sparkline/index.js +25 -17
  146. package/lib/Spinner/index.d.ts +6 -1
  147. package/lib/Spinner/index.js +4 -11
  148. package/lib/Success/index.d.ts +5 -21
  149. package/lib/Success/index.js +4 -16
  150. package/lib/Tabs/index.d.ts +12 -26
  151. package/lib/Tabs/index.js +7 -37
  152. package/lib/TextCollapse/index.d.ts +10 -10
  153. package/lib/TextCollapse/index.js +4 -21
  154. package/lib/Theme/index.js +0 -2
  155. package/lib/Theme/theme-provider.d.ts +1 -1
  156. package/lib/Theme/theme.d.ts +4 -1
  157. package/lib/Theme/theme.js +1 -2
  158. package/lib/Typography/index.d.ts +5 -24
  159. package/lib/Typography/index.js +5 -17
  160. package/lib/Util/index.d.ts +11 -6
  161. package/lib/Util/index.js +6 -0
  162. package/lib/Video/index.d.ts +12 -16
  163. package/lib/Video/index.js +0 -14
  164. package/lib/Wallet/Action.d.ts +13 -18
  165. package/lib/Wallet/Action.js +0 -7
  166. package/lib/Wallet/Download.d.ts +24 -30
  167. package/lib/Wallet/Download.js +201 -18
  168. package/lib/Wallet/Open.d.ts +5 -15
  169. package/lib/Wallet/Open.js +5 -11
  170. package/lib/WalletOSIcon/index.d.ts +6 -25
  171. package/lib/WalletOSIcon/index.js +3 -16
  172. package/lib/WebWalletSWKeeper/index.d.ts +8 -20
  173. package/lib/WebWalletSWKeeper/index.js +14 -19
  174. package/lib/WechatPrompt/index.js +2 -0
  175. package/lib/global.d.ts +15 -0
  176. package/lib/type.d.ts +12 -3
  177. package/lib/withTheme/index.d.ts +8 -6
  178. package/lib/withTracker/index.d.ts +1 -1
  179. package/lib/withTracker/index.js +3 -0
  180. package/package.json +9 -5
  181. package/src/Address/did-address.tsx +7 -6
  182. package/src/Address/index.tsx +1 -1
  183. package/src/Avatar/index.jsx +6 -4
  184. package/src/Blocklet/blocklet.jsx +2 -2
  185. package/src/BlockletContext/index.tsx +3 -3
  186. package/src/BlockletNFT/index.jsx +3 -3
  187. package/src/BlockletV2/blocklet.tsx +2 -2
  188. package/src/Button/wrap.jsx +2 -2
  189. package/src/CardSelector/index.tsx +0 -1
  190. package/src/Center/index.tsx +1 -1
  191. package/src/ClickToCopy/copy-button.tsx +4 -4
  192. package/src/ClickToCopy/hook.ts +3 -2
  193. package/src/ClickToCopy/index.tsx +6 -5
  194. package/src/CodeBlock/index.tsx +3 -1
  195. package/src/CookieConsent/{index.jsx → index.tsx} +16 -19
  196. package/src/CountDown/{index.jsx → index.tsx} +30 -16
  197. package/src/DID/index.tsx +9 -8
  198. package/src/Datatable/index.jsx +5 -5
  199. package/src/Dialog/confirm.jsx +3 -3
  200. package/src/Dialog/types.d.ts +1 -1
  201. package/src/DidLogo/{index.jsx → index.tsx} +7 -14
  202. package/src/DriftBot/{index.jsx → index.tsx} +13 -11
  203. package/src/Earth/{index.jsx → index.tsx} +94 -66
  204. package/src/Earth/{util.js → util.ts} +20 -17
  205. package/src/ErrorBoundary/{fallback.jsx → fallback.tsx} +20 -21
  206. package/src/Footer/{index.jsx → index.tsx} +17 -14
  207. package/src/Header/header.tsx +2 -3
  208. package/src/Header/responsive-header.tsx +0 -1
  209. package/src/Icon/image.tsx +3 -3
  210. package/src/Icon/index.tsx +7 -4
  211. package/src/Img/index.jsx +1 -1
  212. package/src/InfoRow/{index.jsx → index.tsx} +32 -25
  213. package/src/Layout/dashboard/external-link.tsx +46 -0
  214. package/src/Layout/dashboard/{full-page.jsx → full-page.tsx} +20 -9
  215. package/src/Layout/dashboard/{index.jsx → index.tsx} +42 -44
  216. package/src/Layout/dashboard/{sidebar.jsx → sidebar.tsx} +23 -20
  217. package/src/Layout/dashboard-legacy/{header.jsx → header.tsx} +16 -26
  218. package/src/Layout/dashboard-legacy/{index.jsx → index.tsx} +32 -46
  219. package/src/Layout/dashboard-legacy/{sidebar.jsx → sidebar.tsx} +27 -19
  220. package/src/Layout/{index.jsx → index.tsx} +41 -47
  221. package/src/LoadingMask/{index.jsx → index.tsx} +17 -19
  222. package/src/Locale/{browser-lang.js → browser-lang.ts} +9 -7
  223. package/src/Locale/context.tsx +18 -11
  224. package/src/Locale/{languages.js → languages.ts} +1 -1
  225. package/src/Locale/{selector.jsx → selector.tsx} +32 -29
  226. package/src/Locale/{util.js → util.ts} +9 -2
  227. package/src/Logo/index.tsx +58 -0
  228. package/src/Metric/{index.jsx → index.tsx} +23 -18
  229. package/src/NFTDisplay/{aspect-ratio-container.jsx → aspect-ratio-container.tsx} +9 -7
  230. package/src/NFTDisplay/{broken.jsx → broken.tsx} +7 -12
  231. package/src/NFTDisplay/{displayApi.js → displayApi.ts} +4 -4
  232. package/src/NFTDisplay/{index.jsx → index.tsx} +59 -64
  233. package/src/NFTDisplay/svg-embedder/{img.jsx → img.tsx} +10 -18
  234. package/src/NFTDisplay/svg-embedder/{inline-svg.jsx → inline-svg.tsx} +8 -9
  235. package/src/NavMenu/nav-menu.tsx +2 -3
  236. package/src/PageScroller/{index.jsx → index.tsx} +40 -53
  237. package/src/PageScroller/{usePrevValue.js → usePrevValue.ts} +2 -3
  238. package/src/Passport/{passport.jsx → passport.tsx} +22 -19
  239. package/src/PoweredByArcBlock/{index.jsx → index.tsx} +6 -11
  240. package/src/PricingTable/{PricingPlan.jsx → PricingPlan.tsx} +15 -5
  241. package/src/PricingTable/{index.jsx → index.tsx} +9 -6
  242. package/src/QRCode/{index.jsx → index.tsx} +13 -17
  243. package/src/RelativeTime/{index.jsx → index.tsx} +24 -24
  244. package/src/Result/{common.jsx → common.tsx} +17 -13
  245. package/src/Result/index.tsx +30 -0
  246. package/src/Result/{result.jsx → result.tsx} +8 -17
  247. package/src/Result/{translations.js → translations.ts} +3 -1
  248. package/src/Screenshot/BaseScreenshot/{index.jsx → index.tsx} +9 -15
  249. package/src/Screenshot/BaseScreenshot/shells/{Macbook.jsx → Macbook.tsx} +3 -1
  250. package/src/Screenshot/BaseScreenshot/shells/{Phone.jsx → Phone.tsx} +3 -1
  251. package/src/Screenshot/{index.jsx → index.tsx} +60 -54
  252. package/src/SessionBlocklet/{index.jsx → index.tsx} +8 -14
  253. package/src/SessionPermission/index.tsx +25 -0
  254. package/src/SessionUser/components/{logged-in.jsx → logged-in.tsx} +49 -31
  255. package/src/SessionUser/components/session-user-item.tsx +97 -0
  256. package/src/SessionUser/components/{session-user-switch.jsx → session-user-switch.tsx} +16 -21
  257. package/src/SessionUser/components/{un-login.jsx → un-login.tsx} +10 -15
  258. package/src/SessionUser/components/{user-info.jsx → user-info.tsx} +16 -22
  259. package/src/SessionUser/index.tsx +26 -0
  260. package/src/SessionUser/libs/{translation.js → translation.ts} +3 -1
  261. package/src/SessionUser/libs/utils.ts +39 -0
  262. package/src/Sparkline/{index.jsx → index.tsx} +38 -22
  263. package/src/Spinner/index.tsx +20 -0
  264. package/src/Success/{index.jsx → index.tsx} +7 -13
  265. package/src/Tabs/{index.jsx → index.tsx} +26 -40
  266. package/src/TextCollapse/{index.jsx → index.tsx} +26 -21
  267. package/src/Theme/index.ts +0 -1
  268. package/src/Theme/theme-provider.tsx +1 -1
  269. package/src/Theme/theme.ts +6 -3
  270. package/src/Typography/{index.jsx → index.tsx} +19 -22
  271. package/src/Util/index.ts +14 -8
  272. package/src/Video/{index.jsx → index.tsx} +7 -10
  273. package/src/Wallet/{Action.jsx → Action.tsx} +16 -12
  274. package/src/Wallet/{Download.jsx → Download.tsx} +25 -21
  275. package/src/Wallet/{Open.jsx → Open.tsx} +8 -11
  276. package/src/WalletOSIcon/{index.jsx → index.tsx} +8 -16
  277. package/src/WebWalletSWKeeper/{index.jsx → index.tsx} +21 -24
  278. package/src/WechatPrompt/{index.jsx → index.tsx} +1 -0
  279. package/src/global.d.ts +15 -0
  280. package/src/type.d.ts +12 -3
  281. package/src/withTheme/{index.jsx → index.tsx} +12 -2
  282. package/src/withTracker/{index.jsx → index.tsx} +6 -4
  283. package/src/Layout/dashboard/external-link.jsx +0 -47
  284. package/src/Logo/index.jsx +0 -66
  285. package/src/Result/index.jsx +0 -33
  286. package/src/SessionPermission/index.jsx +0 -28
  287. package/src/SessionUser/components/session-user-item.jsx +0 -93
  288. package/src/SessionUser/index.jsx +0 -38
  289. package/src/SessionUser/libs/utils.js +0 -37
  290. package/src/Spinner/index.jsx +0 -21
  291. /package/src/ErrorBoundary/{index.jsx → index.ts} +0 -0
  292. /package/src/NFTDisplay/{loading.jsx → loading.tsx} +0 -0
  293. /package/src/Passport/{index.jsx → index.ts} +0 -0
  294. /package/src/SessionManager/{index.jsx → index.tsx} +0 -0
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import { Box, CircularProgress, IconButton } from '@mui/material';
3
2
  import { Icon } from '@iconify/react';
4
3
  import PersonOutlineRoundedIcon from 'iconify-icons-material-symbols-400/person-outline-rounded';
@@ -6,7 +5,16 @@ import { useRef } from 'react';
6
5
  import { useMemoizedFn } from 'ahooks';
7
6
  import noop from 'lodash/noop';
8
7
 
9
- export default function UnLogin({ session, onLogin, size, dark }) {
8
+ import { Session } from '../../type';
9
+
10
+ export interface UnLoginProps {
11
+ session: Session;
12
+ onLogin?: () => void;
13
+ size?: number;
14
+ dark?: false | true;
15
+ }
16
+
17
+ export default function UnLogin({ session, onLogin = noop, size = 24, dark = false }: UnLoginProps) {
10
18
  const isFirstLoading = false;
11
19
  const userAnchorRef = useRef(null);
12
20
  const _onLogin = useMemoizedFn(() => {
@@ -40,16 +48,3 @@ export default function UnLogin({ session, onLogin, size, dark }) {
40
48
  </Box>
41
49
  );
42
50
  }
43
-
44
- UnLogin.propTypes = {
45
- session: PropTypes.object.isRequired,
46
- onLogin: PropTypes.func,
47
- size: PropTypes.number,
48
- dark: PropTypes.bool,
49
- };
50
-
51
- UnLogin.defaultProps = {
52
- onLogin: noop,
53
- size: 24,
54
- dark: false,
55
- };
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import { Box, Chip, Typography } from '@mui/material';
3
2
  import { Icon } from '@iconify/react';
4
3
  import SwapHorizRoundedIcon from '@iconify-icons/material-symbols/swap-horiz-rounded';
@@ -13,22 +12,33 @@ import { temp as colors } from '../../Colors';
13
12
  import { getWallet } from '../libs/utils';
14
13
  import { translations } from '../libs/translation';
15
14
  import { translate } from '../../Locale/util';
15
+ import type { $TSFixMe, Locale, Session } from '../../type';
16
+
17
+ export interface UserInfoProps {
18
+ session: Session;
19
+ onSwitchPassport: () => void;
20
+ onSwitchAccount: (params?: { userSession: Session }) => void;
21
+ onBindWallet: () => void;
22
+ onSwitchProfile?: () => void;
23
+ locale?: Locale;
24
+ isBlocklet?: true | false;
25
+ }
16
26
 
17
27
  export default function UserInfo({
18
28
  session,
19
29
  onSwitchPassport,
20
30
  onSwitchAccount,
21
31
  onBindWallet,
22
- onSwitchProfile,
23
- locale,
24
- isBlocklet,
25
- }) {
32
+ onSwitchProfile = noop,
33
+ locale = 'en',
34
+ isBlocklet = true,
35
+ }: UserInfoProps) {
26
36
  const t = useMemoizedFn((key, data = {}) => {
27
37
  return translate(translations, key, locale, 'en', data);
28
38
  });
29
39
  const avatar = getUserAvatar(session.user?.avatar?.replace(/\s/g, encodeURIComponent(' ')), 64);
30
40
  const currentRole = useCreation(
31
- () => session.user?.passports?.find((item) => item.name === session.user.role),
41
+ () => session.user?.passports?.find((item: $TSFixMe) => item.name === session.user.role),
32
42
  [session?.user?.passports, session?.user?.role]
33
43
  );
34
44
 
@@ -152,19 +162,3 @@ export default function UserInfo({
152
162
  </Box>
153
163
  );
154
164
  }
155
-
156
- UserInfo.propTypes = {
157
- session: PropTypes.object.isRequired,
158
- onSwitchPassport: PropTypes.func.isRequired,
159
- onSwitchAccount: PropTypes.func.isRequired,
160
- onBindWallet: PropTypes.func.isRequired,
161
- onSwitchProfile: PropTypes.func,
162
- locale: PropTypes.string,
163
- isBlocklet: PropTypes.bool,
164
- };
165
-
166
- UserInfo.defaultProps = {
167
- locale: 'en',
168
- isBlocklet: true,
169
- onSwitchProfile: noop,
170
- };
@@ -0,0 +1,26 @@
1
+ import noop from 'lodash/noop';
2
+ import { useCreation } from 'ahooks';
3
+
4
+ import LoggedIn from './components/logged-in';
5
+ import UnLogin from './components/un-login';
6
+ import type { Locale, Session } from '../type';
7
+
8
+ export interface SessionUserProps {
9
+ session: Session;
10
+ onBindWallet?: () => void;
11
+ locale?: Locale;
12
+ size?: number;
13
+ }
14
+
15
+ export default function SessionUser({ session, onBindWallet = noop, locale = 'en', size = 24 }: SessionUserProps) {
16
+ const isBlocklet = useCreation(() => {
17
+ return !!globalThis?.blocklet;
18
+ }, []);
19
+
20
+ if (session.user) {
21
+ return (
22
+ <LoggedIn isBlocklet={isBlocklet} session={session} onBindWallet={onBindWallet} locale={locale} size={size} />
23
+ );
24
+ }
25
+ return <UnLogin session={session} size={size} />;
26
+ }
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
- export const translations = {
2
+ import type { Translations } from '../../type';
3
+
4
+ export const translations: Translations = {
3
5
  en: {
4
6
  connectDIDWallet: 'Connect your DID Wallet for enhanced security',
5
7
  switch: 'Switch',
@@ -0,0 +1,39 @@
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,21 +1,20 @@
1
- /* eslint-disable guard-for-in */
2
- /* eslint-disable no-restricted-syntax */
3
1
  // origin: https://github.com/fnando/sparkline
4
- function getY(max, height, diff, value) {
2
+ function getY(max: number, height: number, diff: number, value: number) {
5
3
  return parseFloat((height - (value * height) / max + diff).toFixed(2));
6
4
  }
7
5
 
8
- function removeChildren(svg) {
6
+ function removeChildren(svg: SVGElement) {
9
7
  [...svg.querySelectorAll('*')].forEach((element) => svg.removeChild(element));
10
8
  }
11
9
 
12
- function defaultFetch(entry) {
10
+ function defaultFetch(entry: { value: number }) {
13
11
  return entry.value;
14
12
  }
15
13
 
16
- function buildElement(tag, attrs) {
14
+ function buildElement(tag: string, attrs: Record<string, any>) {
17
15
  const element = document.createElementNS('http://www.w3.org/2000/svg', tag);
18
16
 
17
+ // eslint-disable-next-line no-restricted-syntax, guard-for-in
19
18
  for (const name in attrs) {
20
19
  element.setAttribute(name, attrs[name]);
21
20
  }
@@ -23,21 +22,33 @@ function buildElement(tag, attrs) {
23
22
  return element;
24
23
  }
25
24
 
26
- export default function sparkline(svg, entries, options) {
25
+ export interface SparklineProps {
26
+ svg: SVGElement;
27
+ entries?: 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
+
38
+ export default function sparkline({ svg, entries: _entries = [], options = {} }: SparklineProps) {
27
39
  removeChildren(svg);
28
40
 
29
- if (entries.length <= 1) {
41
+ if (_entries.length <= 1) {
30
42
  return;
31
43
  }
32
44
 
33
- // eslint-disable-next-line no-param-reassign
34
- options = options || {};
35
-
36
- if (typeof entries[0] === 'number') {
37
- // eslint-disable-next-line no-param-reassign
38
- entries = entries.map((entry) => {
45
+ let entries: { value: number }[] = [];
46
+ if (typeof _entries[0] === 'number') {
47
+ entries = (_entries as number[]).map((entry) => {
39
48
  return { value: entry };
40
49
  });
50
+ } else {
51
+ entries = _entries as typeof entries;
41
52
  }
42
53
 
43
54
  // This function will be called whenever the mouse moves
@@ -62,6 +73,7 @@ export default function sparkline(svg, entries, options) {
62
73
 
63
74
  // Get the stroke width; this is used to compute the
64
75
  // rendering offset.
76
+ // @ts-expect-error
65
77
  const strokeWidth = parseFloat(svg.attributes['stroke-width'].value);
66
78
 
67
79
  // By default, data must be formatted as an array of numbers or
@@ -74,10 +86,12 @@ export default function sparkline(svg, entries, options) {
74
86
  const values = entries.map((entry) => fetch(entry));
75
87
 
76
88
  // The rendering width will account for the spot size.
89
+ // @ts-expect-error
77
90
  const width = parseFloat(svg.attributes.width.value) - spotDiameter * 2;
78
91
 
79
92
  // Get the SVG element's full height.
80
93
  // This is used
94
+ // @ts-expect-error
81
95
  const fullHeight = parseFloat(svg.attributes.height.value);
82
96
 
83
97
  // The rendering height accounts for stroke width and spot size.
@@ -99,7 +113,7 @@ export default function sparkline(svg, entries, options) {
99
113
 
100
114
  // Hold all datapoints, which is whatever we got as the entry plus
101
115
  // x/y coords and the index.
102
- const datapoints = [];
116
+ const datapoints: { value: number; index: number; x: number; y: number }[] = [];
103
117
 
104
118
  // Hold the line coordinates.
105
119
  const pathY = getY(max, height, strokeWidth + spotRadius, values[0]);
@@ -161,7 +175,9 @@ export default function sparkline(svg, entries, options) {
161
175
  svg.appendChild(spot);
162
176
 
163
177
  const interactionLayer = buildElement('rect', {
178
+ // @ts-expect-error
164
179
  width: svg.attributes.width.value,
180
+ // @ts-expect-error
165
181
  height: svg.attributes.height.value,
166
182
  style: 'fill: transparent; stroke: transparent',
167
183
  class: 'sparkline--interaction-layer',
@@ -169,10 +185,10 @@ export default function sparkline(svg, entries, options) {
169
185
  svg.appendChild(interactionLayer);
170
186
 
171
187
  interactionLayer.addEventListener('mouseout', (event) => {
172
- cursor.setAttribute('x1', offscreen);
173
- cursor.setAttribute('x2', offscreen);
188
+ cursor.setAttribute('x1', offscreen.toString());
189
+ cursor.setAttribute('x2', offscreen.toString());
174
190
 
175
- spot.setAttribute('cx', offscreen);
191
+ spot.setAttribute('cx', offscreen.toString());
176
192
 
177
193
  if (onmouseout) {
178
194
  onmouseout(event);
@@ -204,11 +220,11 @@ export default function sparkline(svg, entries, options) {
204
220
  const { x } = currentDataPoint;
205
221
  const { y } = currentDataPoint;
206
222
 
207
- spot.setAttribute('cx', x);
208
- spot.setAttribute('cy', y);
223
+ spot.setAttribute('cx', x.toString());
224
+ spot.setAttribute('cy', y.toString());
209
225
 
210
- cursor.setAttribute('x1', x);
211
- cursor.setAttribute('x2', x);
226
+ cursor.setAttribute('x1', x.toString());
227
+ cursor.setAttribute('x2', x.toString());
212
228
 
213
229
  if (onmousemove) {
214
230
  onmousemove(event, currentDataPoint);
@@ -0,0 +1,20 @@
1
+ import CircularProgress, { type CircularProgressProps } from '@mui/material/CircularProgress';
2
+ import { withDeprecated } from '../Util/deprecate';
3
+
4
+ export interface SpinnerProps extends Omit<CircularProgressProps, 'size'> {
5
+ /** 之前 size prop 是 array 类型, 需要与 CircularProgress#size 兼容 */
6
+ size?: number | [number, number];
7
+ }
8
+
9
+ /** 之前的 Spinner 实现由内外 2 个环构成, 现在改为基于 @mui/material/CircularProgress 的实现 */
10
+ function Spinner(props: SpinnerProps) {
11
+ const _props = { ...props } as CircularProgressProps;
12
+
13
+ // 兼容之前的 size prop (设置外圈/内圈的尺寸)
14
+ if (_props.size && Array.isArray(props.size)) {
15
+ [_props.size] = props.size;
16
+ }
17
+ return <CircularProgress {..._props} />;
18
+ }
19
+
20
+ export default withDeprecated(Spinner, { name: 'Spinner', alternative: '@mui/material/CircularProgress' });
@@ -1,8 +1,13 @@
1
- import PropTypes from 'prop-types';
2
1
  import { Box } from '@mui/material';
3
2
 
3
+ export interface SuccessProps {
4
+ size?: number;
5
+ backgroundColor?: string;
6
+ borderWidth?: number;
7
+ }
8
+
4
9
  // FIXME: @zhanghan 目前无法适配各种 size,后续优化
5
- export default function Success({ size, backgroundColor, borderWidth }) {
10
+ export default function Success({ size = 64, backgroundColor = 'white', borderWidth = 4 }: SuccessProps) {
6
11
  const contentSize = size - borderWidth * 2;
7
12
 
8
13
  return (
@@ -163,14 +168,3 @@ export default function Success({ size, backgroundColor, borderWidth }) {
163
168
  </Box>
164
169
  );
165
170
  }
166
-
167
- Success.propTypes = {
168
- size: PropTypes.number,
169
- borderWidth: PropTypes.number,
170
- backgroundColor: PropTypes.string,
171
- };
172
- Success.defaultProps = {
173
- size: 64,
174
- borderWidth: 4,
175
- backgroundColor: 'white',
176
- };
@@ -1,5 +1,4 @@
1
- import PropTypes from 'prop-types';
2
- import { Tabs as MuiTabs, Tab as MuiTab } from '@mui/material';
1
+ import { Tabs as MuiTabs, Tab as MuiTab, type TabsProps as MuiTabsProps } from '@mui/material';
3
2
 
4
3
  import { temp as colors } from '../Colors';
5
4
  import { styled } from '../Theme';
@@ -22,7 +21,13 @@ const StyledMuiTabs = styled(MuiTabs)(({ theme }) => ({
22
21
  },
23
22
  }));
24
23
 
25
- function CardTabs({ tabs, current, onChange, ...rest }) {
24
+ interface CardTabsProps extends Omit<MuiTabsProps, 'onChange'> {
25
+ tabs: { value: any; label: React.ReactNode; icon?: string | React.ReactElement }[];
26
+ current: any;
27
+ onChange: (value: string) => void;
28
+ }
29
+
30
+ function CardTabs({ tabs, current, onChange, ...rest }: CardTabsProps) {
26
31
  return (
27
32
  <MuiTabs
28
33
  scrollButtons="auto"
@@ -72,19 +77,19 @@ function CardTabs({ tabs, current, onChange, ...rest }) {
72
77
  ...rest.sx,
73
78
  }}>
74
79
  {tabs.map((x) => (
75
- <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
80
+ <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon} />
76
81
  ))}
77
82
  </MuiTabs>
78
83
  );
79
84
  }
80
85
 
81
- CardTabs.propTypes = {
82
- tabs: PropTypes.array.isRequired,
83
- current: PropTypes.string.isRequired,
84
- onChange: PropTypes.func.isRequired,
85
- };
86
+ interface LineTabsProps extends Omit<MuiTabsProps, 'onChange'> {
87
+ tabs: { value: any; label: React.ReactNode; icon?: string | React.ReactElement }[];
88
+ current: any;
89
+ onChange: (value: string) => void;
90
+ }
86
91
 
87
- function LineTabs({ tabs, current, onChange, ...rest }) {
92
+ function LineTabs({ tabs, current, onChange, ...rest }: LineTabsProps) {
88
93
  return (
89
94
  <MuiTabs
90
95
  scrollButtons="auto"
@@ -137,38 +142,25 @@ function LineTabs({ tabs, current, onChange, ...rest }) {
137
142
  ...rest.sx,
138
143
  }}>
139
144
  {tabs.map((x) => (
140
- <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
145
+ <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon} />
141
146
  ))}
142
147
  </MuiTabs>
143
148
  );
144
149
  }
145
150
 
146
- LineTabs.propTypes = {
147
- tabs: PropTypes.array.isRequired,
148
- current: PropTypes.string.isRequired,
149
- onChange: PropTypes.func.isRequired,
150
- };
151
-
152
- /**
153
- * @typedef {import('@mui/material').TabsProps & {
154
- * tabs: string[];
155
- * onChange: (value) => {};
156
- * variant: 'line' | 'card' | 'fullWidth' | 'scrollable' | 'standard'
157
- * }} TabsProps
158
- */
159
-
160
- /**
161
- * @description
162
- * @param {TabsProps} props
163
- * @return {import('react').ReactNode}
164
- */
151
+ interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
152
+ tabs: { value: any; label: React.ReactNode; icon?: string | React.ReactElement }[];
153
+ current: any;
154
+ onChange: (value: string) => void;
155
+ variant?: 'card' | 'line' | MuiTabsProps['variant'];
156
+ }
165
157
 
166
- export default function Tabs({ tabs, current, onChange, ...rest }) {
167
- if (rest.variant === 'card') {
158
+ export default function Tabs({ tabs, current, onChange, variant, ...rest }: TabsProps) {
159
+ if (variant === 'card') {
168
160
  return <CardTabs {...rest} tabs={tabs} current={current} onChange={onChange} />;
169
161
  }
170
162
 
171
- if (rest.variant === 'line') {
163
+ if (variant === 'line') {
172
164
  return <LineTabs {...rest} tabs={tabs} current={current} onChange={onChange} />;
173
165
  }
174
166
 
@@ -182,14 +174,8 @@ export default function Tabs({ tabs, current, onChange, ...rest }) {
182
174
  {...rest}
183
175
  className={[classes.tabs, rest.className || ''].join(' ')}>
184
176
  {tabs.map((x) => (
185
- <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
177
+ <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon} />
186
178
  ))}
187
179
  </StyledMuiTabs>
188
180
  );
189
181
  }
190
-
191
- Tabs.propTypes = {
192
- tabs: PropTypes.array.isRequired,
193
- current: PropTypes.string.isRequired,
194
- onChange: PropTypes.func.isRequired,
195
- };
@@ -1,10 +1,28 @@
1
- import PropTypes from 'prop-types';
2
- import Typography from '@mui/material/Typography';
1
+ import Typography, { type TypographyProps } from '@mui/material/Typography';
3
2
 
4
3
  import { styled } from '../Theme';
5
4
  import { withDeprecated } from '../Util/deprecate';
6
5
 
7
- function TextCollapse({ children, startChars, endChars, scaleFactor, maxWidth, style, fontType, ...rest }) {
6
+ export interface TextCollapseProps {
7
+ children: string;
8
+ maxWidth: string | number;
9
+ startChars?: number;
10
+ endChars?: number;
11
+ scaleFactor?: number;
12
+ style?: React.CSSProperties;
13
+ fontType?: 'monospace' | 'normal';
14
+ }
15
+
16
+ function TextCollapse({
17
+ children,
18
+ maxWidth,
19
+ startChars = 5,
20
+ endChars = 5,
21
+ scaleFactor = 0.45,
22
+ style,
23
+ fontType = 'normal',
24
+ ...rest
25
+ }: TextCollapseProps) {
8
26
  if (typeof children !== 'string') {
9
27
  return null;
10
28
  }
@@ -33,27 +51,14 @@ function TextCollapse({ children, startChars, endChars, scaleFactor, maxWidth, s
33
51
  );
34
52
  }
35
53
 
36
- TextCollapse.propTypes = {
37
- children: PropTypes.string.isRequired,
38
- maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
39
- fontType: PropTypes.oneOf(['monospace', 'normal']),
40
- style: PropTypes.object,
41
- startChars: PropTypes.number,
42
- endChars: PropTypes.number,
43
- scaleFactor: PropTypes.number,
44
- };
54
+ export default withDeprecated(TextCollapse, { name: 'TextCollapse' });
45
55
 
46
- TextCollapse.defaultProps = {
47
- style: {},
48
- startChars: 5,
49
- endChars: 5,
50
- scaleFactor: 0.45,
51
- fontType: 'normal',
56
+ type ContainerProps = {
57
+ startwidth: string;
58
+ endwidth: string;
52
59
  };
53
60
 
54
- export default withDeprecated(TextCollapse, { name: 'TextCollapse' });
55
-
56
- const Container = styled(Typography)`
61
+ const Container = styled(Typography)<ContainerProps & TypographyProps>`
57
62
  display: inline-flex;
58
63
  align-items: center;
59
64
  justify-content: start;
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import { CreateMUIStyled, Theme } from '@mui/material';
3
2
  import { styled as muiStyled, useTheme } from '@mui/material/styles';
4
3
 
@@ -14,7 +14,7 @@ export default function ThemeProvider({
14
14
  theme,
15
15
  injectFirst,
16
16
  }: {
17
- children: React.ReactNode;
17
+ children?: React.ReactNode;
18
18
  theme: Theme;
19
19
  injectFirst: boolean;
20
20
  }) {
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  /* eslint-disable no-shadow */
3
2
  // https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
4
3
  import {
@@ -21,8 +20,8 @@ import '@fontsource/inter/latin-ext-500.css';
21
20
  import '@fontsource/inter/latin-ext-700.css';
22
21
  import colors from '../Colors';
23
22
 
24
- // 扩展 Theme 和 ThemeOptions 接口
25
- declare module '@mui/material/styles/createTheme' {
23
+ // 扩展 Theme
24
+ declare module '@mui/material/styles' {
26
25
  interface Theme {
27
26
  mode?: string;
28
27
  themeName?: string;
@@ -42,6 +41,10 @@ declare module '@mui/material/styles/createTheme' {
42
41
  pageWidth?: string;
43
42
  colors?: Record<string, string>;
44
43
  }
44
+
45
+ interface TypeText {
46
+ hint: string;
47
+ }
45
48
  }
46
49
 
47
50
  const muiDarkTheme = _createTheme({ palette: { mode: 'dark' } });
@@ -1,29 +1,38 @@
1
- import PropTyps from 'prop-types';
2
- import { Box, Typography as MuiTypography, Skeleton } from '@mui/material';
1
+ import { Box, Typography as MuiTypography, Skeleton, type TypographyProps as MuiTypographyProps } from '@mui/material';
3
2
  import { useCreation, useReactive, useSize } from 'ahooks';
4
3
  import { useEffect, useRef } from 'react';
5
4
 
6
- export default function Typography({ minFontSize, fontSize, children, sx, ...rest }) {
7
- const refMock = useRef(null);
8
- const refContainer = useRef(null);
9
- const state = useReactive({
5
+ export interface TypographyProps extends MuiTypographyProps {
6
+ fontSize?: string | number;
7
+ minFontSize?: number;
8
+ }
9
+
10
+ export default function Typography({ children = null, minFontSize = 12, fontSize, sx, ...rest }: TypographyProps) {
11
+ const refMock = useRef<HTMLSpanElement>(null);
12
+ const refContainer = useRef<HTMLDivElement>(null);
13
+ const state = useReactive<{
14
+ fontSize?: number;
15
+ loading: boolean;
16
+ initialSize?: number;
17
+ }>({
18
+ // @ts-expect-error
10
19
  fontSize,
11
20
  loading: true,
12
- initialSize: undefined,
13
21
  });
14
22
  const mockSize = useSize(refMock.current);
15
23
  const containerSize = useSize(refContainer.current);
24
+
16
25
  useEffect(() => {
17
26
  if (state.loading) {
18
27
  if (fontSize === 'auto') {
19
28
  if (mockSize && !state.initialSize) {
20
- const styleSize = getComputedStyle(refMock.current).fontSize;
29
+ const styleSize = getComputedStyle(refMock.current!).fontSize;
21
30
  state.initialSize = Number(styleSize.replace('px', ''));
22
31
  state.fontSize = state.initialSize;
23
32
  }
24
33
  if (containerSize && mockSize) {
25
- if (containerSize.width < mockSize.width && state.fontSize > minFontSize) {
26
- state.fontSize--;
34
+ if (containerSize.width < mockSize.width && state.fontSize! > minFontSize) {
35
+ state.fontSize!--;
27
36
  } else {
28
37
  state.loading = false;
29
38
  }
@@ -72,15 +81,3 @@ export default function Typography({ minFontSize, fontSize, children, sx, ...res
72
81
  </MuiTypography>
73
82
  );
74
83
  }
75
-
76
- Typography.propTypes = {
77
- fontSize: PropTyps.oneOfType([PropTyps.string, PropTyps.number]),
78
- children: PropTyps.any.isRequired,
79
- minFontSize: PropTyps.number,
80
- sx: PropTyps.object,
81
- };
82
- Typography.defaultProps = {
83
- fontSize: undefined,
84
- minFontSize: 12,
85
- sx: {},
86
- };