@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,6 +1,5 @@
1
1
  /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
2
2
  import { Children, cloneElement, useCallback, useEffect, useRef, useState } from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import isEqual from 'lodash/isEqual';
5
4
  import isNil from 'lodash/isNil';
6
5
  import isNull from 'lodash/isNull';
@@ -11,7 +10,7 @@ import { withDeprecated } from '../Util/deprecate';
11
10
  const Events = {
12
11
  TOUCHMOVE: 'touchmove',
13
12
  KEYDOWN: 'keydown',
14
- };
13
+ } as const;
15
14
 
16
15
  const DEFAULT_ANIMATION_TIMER = 500;
17
16
  const DEFAULT_ANIMATION = 'ease-in-out';
@@ -25,33 +24,48 @@ const KEY_UP = 38;
25
24
  const KEY_DOWN = 40;
26
25
  const DISABLED_CLASS_NAME = 'rps-scroll--disabled';
27
26
 
28
- let previousTouchMove = null;
27
+ let previousTouchMove: number | null = null;
29
28
  let isScrolling = false;
30
29
  let isMounted = false;
31
30
  let isBodyScrollEnabled = true;
32
31
  let isTransitionAfterComponentsToRenderChanged = false;
33
- const containers = [];
32
+ const containers: boolean[] = [];
33
+
34
+ export interface PageScrollerProps {
35
+ animationTimer?: number;
36
+ blockScrollDown?: false | true;
37
+ blockScrollUp?: false | true;
38
+ children?: React.ReactElement | React.ReactElement[];
39
+ height?: number | string;
40
+ width?: number | string;
41
+ customPageNumber?: number;
42
+ onScrollUnavailable?: () => void;
43
+ onChange?: (index: number) => void;
44
+ renderAllPagesOnFirstRender?: false | true;
45
+ transitionTimingFunction?: string;
46
+ }
34
47
 
35
48
  function PageScroller({
36
- animationTimer,
37
- blockScrollDown,
38
- blockScrollUp,
39
- children,
40
- height,
41
- width,
49
+ animationTimer = DEFAULT_ANIMATION_TIMER,
50
+ blockScrollDown = false,
51
+ blockScrollUp = false,
52
+ children: _children,
53
+ height = DEFAULT_CONTAINER_HEIGHT,
54
+ width = DEFAULT_CONTAINER_WIDTH,
42
55
  customPageNumber,
43
56
  onScrollUnavailable,
44
57
  onChange,
45
- renderAllPagesOnFirstRender,
46
- transitionTimingFunction,
47
- }) {
58
+ renderAllPagesOnFirstRender = false,
59
+ transitionTimingFunction = DEFAULT_ANIMATION,
60
+ }: PageScrollerProps) {
48
61
  const [componentIndex, setComponentIndex] = useState(DEFAULT_COMPONENT_INDEX);
49
62
  const [componentsToRenderLength, setComponentsToRenderLength] = useState(DEFAULT_COMPONENTS_TO_RENDER_LENGTH);
50
63
  const prevComponentIndex = usePrevious(componentIndex);
51
- const pageContainer = useRef(null);
64
+ const pageContainer = useRef<HTMLDivElement>(null);
65
+ const children = Children.toArray(_children) as React.ReactElement[];
52
66
 
53
67
  const addNextComponent = useCallback(
54
- (componentsToRenderOnMountLength) => {
68
+ (componentsToRenderOnMountLength?: number) => {
55
69
  let tempComponentsToRenderLength = 0;
56
70
 
57
71
  if (!isNil(componentsToRenderOnMountLength)) {
@@ -123,7 +137,7 @@ function PageScroller({
123
137
  if (!isNil(containers[componentIndex + 1])) {
124
138
  disableScroll();
125
139
  isScrolling = true;
126
- pageContainer.current.style.transform = `translate3d(0, ${(componentIndex + 1) * -100}%, 0)`; // prettier-ignore
140
+ pageContainer.current!.style.transform = `translate3d(0, ${(componentIndex + 1) * -100}%, 0)`; // prettier-ignore
127
141
 
128
142
  setTimeout(() => {
129
143
  if (isMounted) {
@@ -144,7 +158,7 @@ function PageScroller({
144
158
  if (!isNil(containers[componentIndex - 1])) {
145
159
  disableScroll();
146
160
  isScrolling = true;
147
- pageContainer.current.style.transform = `translate3d(0, ${(componentIndex - 1) * -100}%, 0)`; // prettier-ignore
161
+ pageContainer.current!.style.transform = `translate3d(0, ${(componentIndex - 1) * -100}%, 0)`; // prettier-ignore
148
162
 
149
163
  setTimeout(() => {
150
164
  if (isMounted) {
@@ -161,7 +175,7 @@ function PageScroller({
161
175
  }, [animationTimer, blockScrollUp, componentIndex, disableScroll, enableDocumentScroll, onScrollUnavailable]);
162
176
 
163
177
  const touchMove = useCallback(
164
- (event) => {
178
+ (event: TouchEvent) => {
165
179
  if (!isNull(previousTouchMove)) {
166
180
  if (event.touches[0].clientY > previousTouchMove) {
167
181
  scrollWindowUp();
@@ -176,7 +190,7 @@ function PageScroller({
176
190
  );
177
191
 
178
192
  const wheelScroll = useCallback(
179
- (event) => {
193
+ (event: React.WheelEvent<HTMLDivElement>) => {
180
194
  if (event.deltaY < 0) {
181
195
  scrollWindowUp();
182
196
  } else {
@@ -187,7 +201,7 @@ function PageScroller({
187
201
  );
188
202
 
189
203
  const keyPress = useCallback(
190
- (event) => {
204
+ (event: KeyboardEvent) => {
191
205
  if (isEqual(event.keyCode, KEY_UP)) {
192
206
  scrollWindowUp();
193
207
  }
@@ -199,8 +213,8 @@ function PageScroller({
199
213
  );
200
214
 
201
215
  useEffect(() => {
202
- pageContainer.current.addEventListener(Events.TOUCHMOVE, touchMove);
203
- pageContainer.current.addEventListener(Events.KEYDOWN, keyPress);
216
+ pageContainer.current?.addEventListener(Events.TOUCHMOVE, touchMove);
217
+ pageContainer.current?.addEventListener(Events.KEYDOWN, keyPress);
204
218
  return () => {
205
219
  if (pageContainer.current?.removeEventListener) {
206
220
  pageContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
@@ -223,7 +237,7 @@ function PageScroller({
223
237
  useEffect(() => {
224
238
  isScrolling = false;
225
239
  previousTouchMove = null;
226
- if (componentIndex > prevComponentIndex) {
240
+ if (prevComponentIndex !== undefined && componentIndex > prevComponentIndex) {
227
241
  addNextComponent();
228
242
  }
229
243
  }, [addNextComponent, componentIndex, prevComponentIndex]);
@@ -241,7 +255,7 @@ function PageScroller({
241
255
  if (!isEqual(componentIndex, customPageNumber)) {
242
256
  if (!isNil(containers[customPageNumber]) && !isScrolling) {
243
257
  isScrolling = true;
244
- pageContainer.current.style.transform = `translate3d(0, ${customPageNumber * -100}%, 0)`;
258
+ pageContainer.current!.style.transform = `translate3d(0, ${customPageNumber * -100}%, 0)`;
245
259
 
246
260
  if (isNil(containers[customPageNumber]) && !isNil(children[customPageNumber])) {
247
261
  newComponentsToRenderLength++;
@@ -273,10 +287,10 @@ function PageScroller({
273
287
  if (isTransitionAfterComponentsToRenderChanged) {
274
288
  isTransitionAfterComponentsToRenderChanged = false;
275
289
 
276
- pageContainer.current.style.transform = `translate3d(0, ${customPageNumber * -100}%, 0)`;
290
+ pageContainer.current!.style.transform = `translate3d(0, ${customPageNumber! * -100}%, 0)`;
277
291
 
278
292
  setTimeout(() => {
279
- setComponentIndex(customPageNumber);
293
+ setComponentIndex(customPageNumber!);
280
294
  }, animationTimer + ANIMATION_TIMER_BUFFER);
281
295
  }
282
296
  }, [animationTimer, componentsToRenderLength, customPageNumber]);
@@ -299,31 +313,4 @@ function PageScroller({
299
313
  );
300
314
  }
301
315
 
302
- PageScroller.propTypes = {
303
- animationTimer: PropTypes.number,
304
- blockScrollDown: PropTypes.bool,
305
- blockScrollUp: PropTypes.bool,
306
- children: PropTypes.any.isRequired,
307
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
308
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
309
- customPageNumber: PropTypes.number,
310
- onScrollUnavailable: PropTypes.func,
311
- onChange: PropTypes.func,
312
- renderAllPagesOnFirstRender: PropTypes.bool,
313
- transitionTimingFunction: PropTypes.string,
314
- };
315
-
316
- PageScroller.defaultProps = {
317
- animationTimer: DEFAULT_ANIMATION_TIMER,
318
- transitionTimingFunction: DEFAULT_ANIMATION,
319
- height: DEFAULT_CONTAINER_HEIGHT,
320
- width: DEFAULT_CONTAINER_WIDTH,
321
- onChange: undefined,
322
- onScrollUnavailable: undefined,
323
- blockScrollUp: false,
324
- blockScrollDown: false,
325
- renderAllPagesOnFirstRender: false,
326
- customPageNumber: undefined,
327
- };
328
-
329
316
  export default withDeprecated(PageScroller, { name: 'PageScroller' });
@@ -1,8 +1,7 @@
1
- // eslint-disable-next-line no-unused-vars
2
1
  import { useEffect, useRef } from 'react';
3
2
 
4
- export default function usePrevious(value) {
5
- const ref = useRef({});
3
+ export default function usePrevious<T>(value: T) {
4
+ const ref = useRef<T>();
6
5
 
7
6
  useEffect(() => {
8
7
  ref.current = value;
@@ -1,12 +1,31 @@
1
- import PropTypes from 'prop-types';
2
1
  import upperFirst from 'lodash/upperFirst';
3
- import { Box } from '@mui/material';
2
+ import { Box, type BoxProps } from '@mui/material';
4
3
  import RevokeIcon from '@arcblock/icons/lib/RevokeIcon';
5
4
 
6
5
  import NFTDisplay from '../NFTDisplay';
7
6
  import { useLocaleContext } from '../Locale/context';
7
+ import { Passport as PassportType, User } from '../type';
8
8
 
9
- export default function Passport({ passport, user, color, width, icon, children, createPassportSvg, ...rest }) {
9
+ export interface PassportProps extends BoxProps {
10
+ passport: PassportType;
11
+ user: User;
12
+ color: string;
13
+ width?: number;
14
+ icon?: React.ReactNode;
15
+ createPassportSvg: (props: any) => string;
16
+ }
17
+
18
+ export default function Passport({
19
+ passport,
20
+ user,
21
+ color,
22
+ width = 150,
23
+ icon = null,
24
+ createPassportSvg,
25
+ // inherit props
26
+ children,
27
+ ...rest
28
+ }: PassportProps) {
10
29
  const { t } = useLocaleContext();
11
30
  return (
12
31
  <Box
@@ -97,19 +116,3 @@ export default function Passport({ passport, user, color, width, icon, children,
97
116
  </Box>
98
117
  );
99
118
  }
100
-
101
- Passport.propTypes = {
102
- passport: PropTypes.any.isRequired,
103
- user: PropTypes.any.isRequired,
104
- color: PropTypes.string.isRequired,
105
- createPassportSvg: PropTypes.func.isRequired,
106
- icon: PropTypes.any,
107
- children: PropTypes.any,
108
- width: PropTypes.number,
109
- };
110
-
111
- Passport.defaultProps = {
112
- icon: null,
113
- children: null,
114
- width: 150,
115
- };
@@ -1,7 +1,10 @@
1
- import PropTypes from 'prop-types';
2
- import { Link, Typography } from '@mui/material';
1
+ import { Link, Typography, type TypographyProps, type LinkProps } from '@mui/material';
3
2
 
4
- export default function PoweredByArcBlock({ linkProps, ...props }) {
3
+ export interface PoweredByArcBlockProps extends TypographyProps {
4
+ linkProps?: LinkProps;
5
+ }
6
+
7
+ export default function PoweredByArcBlock({ linkProps, ...props }: PoweredByArcBlockProps) {
5
8
  return (
6
9
  <Typography {...props}>
7
10
  Powered by{' '}
@@ -16,11 +19,3 @@ export default function PoweredByArcBlock({ linkProps, ...props }) {
16
19
  </Typography>
17
20
  );
18
21
  }
19
-
20
- PoweredByArcBlock.propTypes = {
21
- linkProps: PropTypes.object,
22
- };
23
-
24
- PoweredByArcBlock.defaultProps = {
25
- linkProps: {},
26
- };
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import Card from '@mui/material/Card';
3
2
  import Button from '@mui/material/Button';
4
3
  import CardContent from '@mui/material/CardContent';
@@ -6,7 +5,18 @@ import Typography from '@mui/material/Typography';
6
5
 
7
6
  import { styled } from '../Theme';
8
7
 
9
- function PricingPlan({ plan }) {
8
+ export interface PricingPlanProps {
9
+ plan: {
10
+ name: string;
11
+ price: string;
12
+ featureList: string[];
13
+ showButton: boolean;
14
+ buttonLink: string;
15
+ buttonText: string;
16
+ };
17
+ }
18
+
19
+ function PricingPlan({ plan }: PricingPlanProps) {
10
20
  return (
11
21
  <PlanCard $shadow>
12
22
  <div className="card-header">
@@ -41,11 +51,11 @@ function PricingPlan({ plan }) {
41
51
 
42
52
  export default PricingPlan;
43
53
 
44
- PricingPlan.propTypes = {
45
- plan: PropTypes.object.isRequired,
54
+ type PlanCardProps = {
55
+ $shadow?: boolean;
46
56
  };
47
57
 
48
- const PlanCard = styled(Card)`
58
+ const PlanCard = styled(Card)<PlanCardProps>`
49
59
  height: 500px;
50
60
  display: flex;
51
61
  flex-direction: column;
@@ -1,11 +1,14 @@
1
- import PropTypes from 'prop-types';
2
1
  import Grid from '@mui/material/Grid';
3
2
 
4
- import PricingPlan from './PricingPlan';
3
+ import PricingPlan, { type PricingPlanProps } from './PricingPlan';
5
4
  import { styled } from '../Theme';
6
5
  import { withDeprecated } from '../Util/deprecate';
7
6
 
8
- function PricingTable({ plans }) {
7
+ export interface PricingTableProps {
8
+ plans?: Array<PricingPlanProps['plan']>;
9
+ }
10
+
11
+ function PricingTable({ plans = [] }: PricingTableProps) {
9
12
  if (plans && plans.length > 0) {
10
13
  return (
11
14
  <Div variant="even">
@@ -25,11 +28,11 @@ function PricingTable({ plans }) {
25
28
 
26
29
  export default withDeprecated(PricingTable, { name: 'PricingTable' });
27
30
 
28
- PricingTable.propTypes = {
29
- plans: PropTypes.array.isRequired,
31
+ type DivProps = {
32
+ variant: 'even' | 'odd';
30
33
  };
31
34
 
32
- const Div = styled('div')`
35
+ const Div = styled('div')<DivProps>`
33
36
  padding: 100px 0;
34
37
  text-align: center;
35
38
  background-color: ${(props) => (props.variant === 'even' ? '#fbfbfb' : '#ffffff')};
@@ -1,9 +1,10 @@
1
1
  import { useRef, useEffect, useMemo, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import QRCodeStyling from '@solana/qr-code-styling';
4
3
  import { Box } from '@mui/material';
5
4
 
6
- const defaults = {
5
+ type QRCodeStylingOptions = NonNullable<ConstructorParameters<typeof QRCodeStyling>[0]>;
6
+
7
+ const defaults: QRCodeStylingOptions = {
7
8
  margin: 0,
8
9
  dotsOptions: {
9
10
  type: 'dots',
@@ -16,9 +17,18 @@ const defaults = {
16
17
  },
17
18
  };
18
19
 
20
+ export interface QRCodeProps {
21
+ /** 一般情况下仅使用 data/size/image 即可 */
22
+ data: string;
23
+ size: number;
24
+ image?: string;
25
+ /** 覆盖 qr-code-styling 配置 */
26
+ config?: QRCodeStylingOptions;
27
+ }
28
+
19
29
  // 该组件用于生成与 android wallet 样式风格相似的 qrcode
20
30
  // 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
21
- function QRCode({ data, size, image, config, ...rest }) {
31
+ function QRCode({ data, size, image, config = {}, ...rest }: QRCodeProps) {
22
32
  const ref = useRef(null);
23
33
  const options = useMemo(() => {
24
34
  return {
@@ -54,18 +64,4 @@ function QRCode({ data, size, image, config, ...rest }) {
54
64
  return <Box ref={ref} {...rest} />;
55
65
  }
56
66
 
57
- QRCode.propTypes = {
58
- // 一般情况下仅使用 data/size/image 即可
59
- data: PropTypes.string.isRequired,
60
- size: PropTypes.number.isRequired,
61
- image: PropTypes.string,
62
- // 覆盖 qr-code-styling 配置
63
- config: PropTypes.object,
64
- };
65
-
66
- QRCode.defaultProps = {
67
- image: null,
68
- config: {},
69
- };
70
-
71
67
  export default QRCode;
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import relativeTime from 'dayjs/plugin/relativeTime';
3
2
  import dayjs from 'dayjs';
4
3
  import 'dayjs/locale/zh-cn';
@@ -8,6 +7,7 @@ import utc from 'dayjs/plugin/utc';
8
7
  import timezone from 'dayjs/plugin/timezone';
9
8
  import updateLocale from 'dayjs/plugin/updateLocale';
10
9
  import { formatToDatetime, setDateTool } from '../Util';
10
+ import type { Locale } from '../type';
11
11
 
12
12
  dayjs.extend(localizedFormat);
13
13
  dayjs.extend(utc);
@@ -34,7 +34,28 @@ dayjs.updateLocale('zh-cn', {
34
34
  });
35
35
  setDateTool(dayjs);
36
36
 
37
- export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz, relativeRange, ...rest }) {
37
+ export interface RelativeTimeProps {
38
+ value: string | number;
39
+ locale?: Locale;
40
+ withoutSuffix?: false | true;
41
+ from?: string | number;
42
+ to?: string | number;
43
+ type?: 'relative' | 'absolute';
44
+ tz?: string;
45
+ relativeRange?: number;
46
+ }
47
+
48
+ export default function RelativeTime({
49
+ value,
50
+ locale = 'en',
51
+ withoutSuffix = false,
52
+ from = '',
53
+ to = '',
54
+ type = 'relative',
55
+ tz,
56
+ relativeRange,
57
+ ...rest
58
+ }: RelativeTimeProps) {
38
59
  if (!value) {
39
60
  return '-';
40
61
  }
@@ -46,7 +67,7 @@ export default function RelativeTime({ value, locale, withoutSuffix, from, to, t
46
67
  datetime.tz(tz);
47
68
  }
48
69
 
49
- const absoluteString = formatToDatetime(value, { locale: localeOption, tz });
70
+ const absoluteString = formatToDatetime(value.toString(), { locale: localeOption, tz });
50
71
 
51
72
  let relativeString;
52
73
 
@@ -79,24 +100,3 @@ export default function RelativeTime({ value, locale, withoutSuffix, from, to, t
79
100
  </Tooltip>
80
101
  );
81
102
  }
82
-
83
- RelativeTime.propTypes = {
84
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
85
- locale: PropTypes.string,
86
- withoutSuffix: PropTypes.bool,
87
- from: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
88
- to: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
89
- type: PropTypes.oneOf(['relative', 'absolute']),
90
- tz: PropTypes.string,
91
- relativeRange: PropTypes.number,
92
- };
93
-
94
- RelativeTime.defaultProps = {
95
- locale: 'en',
96
- withoutSuffix: false,
97
- from: '',
98
- to: '',
99
- type: 'relative',
100
- tz: undefined,
101
- relativeRange: undefined,
102
- };
@@ -2,27 +2,31 @@
2
2
  /* eslint-disable no-param-reassign */
3
3
  import InfoIcon from '@mui/icons-material/Info';
4
4
  import CancelRoundedIcon from '@mui/icons-material/CancelRounded';
5
- import Result from './result';
5
+ import { type SvgIconProps } from '@mui/material';
6
+ import Result, { type ResultProps } from './result';
6
7
  import translations from './translations';
7
8
  import { useLocaleContext } from '../Locale/context';
8
9
  import { useTheme } from '../Theme';
10
+ import type { Locale } from '../type';
9
11
 
10
12
  // 优先使用显式指定的 locale, 再尝试使用 context 中的 locale, 最后使用默认 'en'
11
- const useLocale = (locale) => {
13
+ const useLocale = (locale: Locale) => {
12
14
  locale = ['zh', 'en'].includes(locale) ? locale : '';
13
15
  const { locale: localeFromContext } = useLocaleContext() || { locale: 'en' };
14
16
  const result = locale || localeFromContext;
15
17
  return translations[result] ? result : 'en';
16
18
  };
17
19
 
20
+ export type CommonResultProps = { locale: Locale } & Omit<ResultProps, 'icon' | 'title' | 'description'>;
21
+
18
22
  // 404
19
- export function PageNotFound({ locale, ...rest }) {
23
+ export function PageNotFound({ locale, ...rest }: CommonResultProps) {
20
24
  locale = useLocale(locale);
21
25
  return (
22
26
  <Result
23
27
  icon={<StyledErrorIcon />}
24
- title={translations[locale][404].title}
25
- description={translations[locale][404].description}
28
+ title={translations[locale]['404'].title}
29
+ description={translations[locale]['404'].description}
26
30
  {...rest}
27
31
  />
28
32
  );
@@ -30,7 +34,7 @@ export function PageNotFound({ locale, ...rest }) {
30
34
  PageNotFound.status = '404';
31
35
 
32
36
  // 403
33
- export function Forbidden({ locale, ...rest }) {
37
+ export function Forbidden({ locale, ...rest }: CommonResultProps) {
34
38
  locale = useLocale(locale);
35
39
  return (
36
40
  <Result
@@ -44,7 +48,7 @@ export function Forbidden({ locale, ...rest }) {
44
48
  Forbidden.status = '403';
45
49
 
46
50
  // 500
47
- export function InternalServerError({ locale, ...rest }) {
51
+ export function InternalServerError({ locale, ...rest }: CommonResultProps) {
48
52
  locale = useLocale(locale);
49
53
  return (
50
54
  <Result
@@ -58,7 +62,7 @@ export function InternalServerError({ locale, ...rest }) {
58
62
  InternalServerError.status = '500';
59
63
 
60
64
  // 通用错误
61
- export function Error({ locale, ...rest }) {
65
+ export function Error({ locale, ...rest }: CommonResultProps) {
62
66
  locale = useLocale(locale);
63
67
  return (
64
68
  <Result
@@ -72,7 +76,7 @@ export function Error({ locale, ...rest }) {
72
76
  Error.status = 'error';
73
77
 
74
78
  // under maintenance
75
- export function Maintenance({ locale, ...rest }) {
79
+ export function Maintenance({ locale, ...rest }: CommonResultProps) {
76
80
  locale = useLocale(locale);
77
81
  return (
78
82
  <Result
@@ -86,7 +90,7 @@ export function Maintenance({ locale, ...rest }) {
86
90
  Maintenance.status = 'maintenance';
87
91
 
88
92
  // coming soon
89
- export function ComingSoon({ locale, ...rest }) {
93
+ export function ComingSoon({ locale, ...rest }: CommonResultProps) {
90
94
  locale = useLocale(locale);
91
95
  return (
92
96
  <Result
@@ -100,17 +104,17 @@ export function ComingSoon({ locale, ...rest }) {
100
104
  ComingSoon.status = 'comingSoon';
101
105
 
102
106
  // info, 与其它 status 不同, title/description 需要使用方自己传入
103
- export function Info(props) {
107
+ export function Info(props: Omit<ResultProps, 'icon'>) {
104
108
  return <Result icon={<StyledInfoIcon />} {...props} />;
105
109
  }
106
110
  Info.status = 'info';
107
111
 
108
- function StyledErrorIcon(props) {
112
+ function StyledErrorIcon(props: SvgIconProps) {
109
113
  const theme = useTheme();
110
114
  return <CancelRoundedIcon style={{ color: theme.palette.error.main, fontSize: 72 }} {...props} />;
111
115
  }
112
116
 
113
- function StyledInfoIcon(props) {
117
+ function StyledInfoIcon(props: SvgIconProps) {
114
118
  const theme = useTheme();
115
119
  return <InfoIcon style={{ color: theme.palette.info.main, fontSize: 72 }} {...props} />;
116
120
  }
@@ -0,0 +1,30 @@
1
+ import Result, { type ResultProps } from './result';
2
+ import * as common from './common';
3
+
4
+ type ComponentNames = keyof typeof common;
5
+
6
+ const componentsKeyByStatus = Object.keys(common).reduce<Record<string, React.ComponentType<ResultProps>>>(
7
+ (acc, cur) => ({ ...acc, [common[cur as ComponentNames].status || cur]: common[cur as ComponentNames] as any }),
8
+ {}
9
+ );
10
+
11
+ export interface ResultWrapperProps extends ResultProps {
12
+ status?: string | number;
13
+ }
14
+
15
+ function ResultWrapper({ status = '', ...rest }: ResultWrapperProps) {
16
+ if (status) {
17
+ if (componentsKeyByStatus[status]) {
18
+ const Component = componentsKeyByStatus[status];
19
+ return <Component {...rest} />;
20
+ }
21
+ throw new Error(
22
+ `Please provide a valid status for Result.status. Valid values are: ${Object.keys(componentsKeyByStatus).join(
23
+ ', '
24
+ )}`
25
+ );
26
+ }
27
+ return <Result {...rest} />;
28
+ }
29
+
30
+ export default ResultWrapper;
@@ -1,9 +1,15 @@
1
- import PropTypes from 'prop-types';
2
1
  import Box from '@mui/material/Box';
3
2
 
4
3
  import { styled } from '../Theme';
5
4
 
6
- function Result({ icon, title, description, extra, ...rest }) {
5
+ export interface ResultProps {
6
+ icon?: React.ReactNode;
7
+ title?: React.ReactNode;
8
+ description?: React.ReactNode;
9
+ extra?: React.ReactNode;
10
+ }
11
+
12
+ function Result({ icon, title = '', description = '', extra, ...rest }: ResultProps) {
7
13
  return (
8
14
  <Root {...rest}>
9
15
  {icon}
@@ -28,21 +34,6 @@ function Result({ icon, title, description, extra, ...rest }) {
28
34
  );
29
35
  }
30
36
 
31
- Result.propTypes = {
32
- icon: PropTypes.element,
33
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
34
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
35
- actions: PropTypes.any,
36
- extra: PropTypes.element,
37
- };
38
- Result.defaultProps = {
39
- icon: undefined,
40
- title: '',
41
- description: '',
42
- actions: null,
43
- extra: undefined,
44
- };
45
-
46
37
  const Root = styled('div')`
47
38
  box-sizing: border-box;
48
39
  display: flex;
@@ -1,3 +1,5 @@
1
+ import type { Translations } from '../type';
2
+
1
3
  export default {
2
4
  en: {
3
5
  404: {
@@ -52,4 +54,4 @@ export default {
52
54
  description: '我们的网站正在建设中。我们很快就会在这里推出我们的新网站。',
53
55
  },
54
56
  },
55
- };
57
+ } as Translations;