@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,9 +1,18 @@
1
- import PropTypes from 'prop-types';
2
1
  import { red } from '@mui/material/colors';
3
2
  import Button from '../Button';
4
3
  import { styled } from '../Theme';
5
4
 
6
- function InternalErrorFallback({ title, desc, retryFunc }) {
5
+ export interface InternalErrorFallbackProps {
6
+ title?: string;
7
+ desc: string;
8
+ retryFunc?: (() => void) | null;
9
+ }
10
+
11
+ function InternalErrorFallback({
12
+ title = 'Something went wrong...',
13
+ desc,
14
+ retryFunc = null,
15
+ }: InternalErrorFallbackProps) {
7
16
  return (
8
17
  <Root role="alert">
9
18
  <h3>{title}</h3>
@@ -17,33 +26,23 @@ function InternalErrorFallback({ title, desc, retryFunc }) {
17
26
  );
18
27
  }
19
28
 
20
- InternalErrorFallback.propTypes = {
21
- title: PropTypes.string,
22
- desc: PropTypes.string.isRequired,
23
- retryFunc: PropTypes.func,
24
- };
25
- InternalErrorFallback.defaultProps = {
26
- title: 'Something went wrong...',
27
- retryFunc: null,
28
- };
29
+ export interface ErrorFallbackProps {
30
+ error: Error;
31
+ }
29
32
 
30
- export function ErrorFallback({ error }) {
33
+ export function ErrorFallback({ error }: ErrorFallbackProps) {
31
34
  return <InternalErrorFallback desc={error.message} />;
32
35
  }
33
36
 
34
- ErrorFallback.propTypes = {
35
- error: PropTypes.instanceOf(Error).isRequired,
36
- };
37
+ export interface ErrorFallbackRetryProps {
38
+ error: Error;
39
+ resetErrorBoundary: () => void;
40
+ }
37
41
 
38
- export function ErrorFallbackRetry({ error, resetErrorBoundary }) {
42
+ export function ErrorFallbackRetry({ error, resetErrorBoundary }: ErrorFallbackRetryProps) {
39
43
  return <InternalErrorFallback desc={error.message} retryFunc={resetErrorBoundary} />;
40
44
  }
41
45
 
42
- ErrorFallbackRetry.propTypes = {
43
- error: PropTypes.instanceOf(Error).isRequired,
44
- resetErrorBoundary: PropTypes.func.isRequired,
45
- };
46
-
47
46
  const Root = styled('div')`
48
47
  padding: 16px;
49
48
  border: 2px solid ${(props) => props.theme.palette.error.main};
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable react/no-unused-prop-types */
2
- import PropTypes from 'prop-types';
3
2
  import Typography from '@mui/material/Typography';
4
3
  import MuiContainer from '@mui/material/Container';
5
4
  import Box from '@mui/material/Box';
@@ -8,7 +7,16 @@ import { mergeProps } from '../Util';
8
7
  import Logo from '../Logo';
9
8
  import { styled } from '../Theme';
10
9
 
11
- export default function Footer(props) {
10
+ export interface FooterProps {
11
+ dark?: false | true;
12
+ className?: string;
13
+ copyStart?: number | string;
14
+ brand?: string;
15
+ style?: React.CSSProperties;
16
+ addon?: React.ReactNode;
17
+ }
18
+
19
+ export default function Footer(props: FooterProps) {
12
20
  const newProps = mergeProps(props, Footer, ['dark', 'style']);
13
21
  const { className, copyStart, style, brand, dark, addon } = newProps;
14
22
 
@@ -50,27 +58,22 @@ export default function Footer(props) {
50
58
  );
51
59
  }
52
60
 
53
- Footer.propTypes = {
54
- dark: PropTypes.bool,
55
- className: PropTypes.string,
56
- copyStart: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
57
- brand: PropTypes.string,
58
- style: PropTypes.object,
59
- addon: PropTypes.node,
60
- };
61
-
62
61
  Footer.defaultProps = {
63
62
  dark: false,
64
- brand: 'ArcBlock',
65
- copyStart: '2017',
66
63
  className: '',
64
+ copyStart: '2017',
65
+ brand: 'ArcBlock',
67
66
  style: {},
68
67
  addon: null,
69
68
  };
70
69
 
70
+ type ContainerProps = {
71
+ dark: boolean;
72
+ };
73
+
71
74
  const Container = styled('div', {
72
75
  shouldForwardProp: (prop) => prop !== 'dark',
73
- })`
76
+ })<ContainerProps>`
74
77
  position: relative;
75
78
  margin-top: 64px;
76
79
  padding: 24px 0 32px;
@@ -1,9 +1,9 @@
1
- import { Box, Container, type Breakpoint } from '@mui/material';
1
+ import { Box, type BoxProps, Container, type Breakpoint } from '@mui/material';
2
2
  import { useRef, useState, useEffect } from 'react';
3
3
  import AutoHidden from './auto-hidden';
4
4
  import { styled } from '../Theme';
5
5
 
6
- export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
6
+ export interface HeaderProps extends Omit<BoxProps, 'maxWidth'> {
7
7
  /** logo img/svg, 可以包裹一个 a 标签 */
8
8
  logo?: React.ReactNode;
9
9
  /** 相当于 Title, 可以包裹一个 a 标签 */
@@ -18,7 +18,6 @@ export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
18
18
  prepend?: React.ReactNode;
19
19
  align?: 'left' | 'right';
20
20
  maxWidth?: Breakpoint | false;
21
- // eslint-disable-next-line no-unused-vars
22
21
  homeLink?: string | ((brandContent: React.ReactNode) => React.ReactNode);
23
22
  }
24
23
 
@@ -12,7 +12,6 @@ import { type HeaderProps } from './header';
12
12
 
13
13
  export interface ResponsiveHeaderProps extends Omit<HeaderProps, 'children'> {
14
14
  menu?: React.ReactNode;
15
- // eslint-disable-next-line no-unused-vars
16
15
  children?: React.ReactNode | ((props: { isMobile: boolean; closeMenu: () => void }) => React.ReactNode);
17
16
  }
18
17
 
@@ -1,13 +1,13 @@
1
- import Img from '../Img';
1
+ import Img, { type ImgProps } from '../Img';
2
2
  import { styled } from '../Theme';
3
3
 
4
- export interface ImageIconProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ export interface ImageIconProps extends Omit<ImgProps, 'size' | 'src'> {
5
5
  name: string;
6
6
  size?: number;
7
7
  color?: string;
8
8
  alt?: string;
9
9
  prefix?: string;
10
- showBadge?: boolean;
10
+ showBadge?: false | true;
11
11
  }
12
12
 
13
13
  export default function ImageIcon({
@@ -1,4 +1,6 @@
1
1
  import { forwardRef } from 'react';
2
+ import { type SxProps } from '@mui/material';
3
+
2
4
  import colors from '../Colors';
3
5
  import { styled } from '../Theme';
4
6
  import { withDeprecated } from '../Util/deprecate';
@@ -9,13 +11,14 @@ const variants = {
9
11
  solid: 'fas',
10
12
  };
11
13
 
12
- export interface IconProps extends React.HTMLAttributes<HTMLElement> {
14
+ export interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
13
15
  name: string;
14
16
  color?: string;
15
17
  size?: number;
16
18
  variant?: 'light' | 'regular' | 'solid';
17
- rounded?: boolean;
18
- forwardedRef?: React.ForwardedRef<HTMLElement>;
19
+ rounded?: false | true;
20
+ forwardedRef?: React.ForwardedRef<HTMLDivElement>;
21
+ sx?: SxProps;
19
22
  }
20
23
 
21
24
  // eslint-disable-next-line react/prop-types
@@ -67,6 +70,6 @@ const Span = styled('span')<{ size: number; color: string }>`
67
70
  `;
68
71
 
69
72
  export default withDeprecated(
70
- forwardRef<HTMLElement, IconProps>((props, ref) => <Icon {...props} forwardedRef={ref} />),
73
+ forwardRef<HTMLDivElement, IconProps>((props, ref) => <Icon {...props} forwardedRef={ref} />),
71
74
  { name: 'Icon', alternative: 'SVG icons' }
72
75
  );
package/src/Img/index.jsx CHANGED
@@ -27,7 +27,7 @@ import noop from 'lodash/noop';
27
27
  */
28
28
 
29
29
  /**
30
- * @typedef {ImgExProps & import('react').ComponentPropsWithoutRef<"div">} ImgProps
30
+ * @typedef {ImgExProps & import('@mui/material').BoxProps} ImgProps
31
31
  */
32
32
 
33
33
  const PREFIX = 'Img';
@@ -1,11 +1,37 @@
1
- import PropTypes from 'prop-types';
2
1
  import camelCase from 'lodash/camelCase';
3
2
  import upperFirst from 'lodash/upperFirst';
4
3
  import Typography from '@mui/material/Typography';
5
4
 
6
5
  import { styled } from '../Theme';
7
6
 
8
- function InfoRow({ name, nameFormatter, layout, children, valueComponent, nameWidth, ...rest }) {
7
+ export interface InfoRowProps {
8
+ name: React.ReactNode;
9
+ nameFormatter: (name: React.ReactNode) => React.ReactNode;
10
+ layout?: 'horizontal' | 'vertical';
11
+ children: React.ReactNode;
12
+ valueComponent?: React.ElementType;
13
+ nameWidth?: number;
14
+ }
15
+
16
+ function InfoRow({
17
+ name,
18
+ // eslint-disable-next-line no-shadow
19
+ nameFormatter = (name) => {
20
+ if (typeof name === 'string') {
21
+ return name
22
+ .split(' ')
23
+ .map((x: any) => upperFirst(camelCase(x)))
24
+ .join(' ');
25
+ }
26
+
27
+ return name;
28
+ },
29
+ layout = 'horizontal',
30
+ children,
31
+ valueComponent = 'div',
32
+ nameWidth = 90,
33
+ ...rest
34
+ }: InfoRowProps) {
9
35
  return (
10
36
  <Container layout={layout} width={nameWidth} {...rest}>
11
37
  <Typography color="textSecondary" className="info-row__name">
@@ -21,31 +47,12 @@ function InfoRow({ name, nameFormatter, layout, children, valueComponent, nameWi
21
47
  );
22
48
  }
23
49
 
24
- InfoRow.propTypes = {
25
- name: PropTypes.any.isRequired,
26
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
27
- children: PropTypes.any,
28
- nameFormatter: PropTypes.func,
29
- valueComponent: PropTypes.string,
30
- nameWidth: PropTypes.number,
31
- };
32
-
33
- InfoRow.defaultProps = {
34
- children: null,
35
- nameWidth: 90,
36
- nameFormatter: (name) => {
37
- const resetName = name
38
- .split(' ')
39
- .map((x) => upperFirst(camelCase(x)))
40
- .join(' ');
41
-
42
- return typeof name === 'string' ? resetName : name;
43
- },
44
- valueComponent: 'div',
45
- layout: 'horizontal',
50
+ type ContainerProps = {
51
+ layout: 'horizontal' | 'vertical';
52
+ width: number;
46
53
  };
47
54
 
48
- const Container = styled('div')`
55
+ const Container = styled('div')<ContainerProps>`
49
56
  display: flex;
50
57
  flex-direction: ${(props) => (props.layout === 'vertical' ? 'column' : 'row')};
51
58
  justify-content: flex-start;
@@ -0,0 +1,46 @@
1
+ import PropTypes from 'prop-types';
2
+ import { Link as RouterLink, NavLink as RouterNavLink } from 'react-router-dom';
3
+
4
+ interface ExternalLinkProps extends React.ComponentProps<typeof RouterLink> {
5
+ routerLinkComponent: React.ElementType;
6
+ to: string | object;
7
+ external?: false | true;
8
+ }
9
+
10
+ // 包裹 router Link/NavLink 组件, 支持 external link (external 为 true 时渲染为 a 标签)
11
+ function ExternalLink({
12
+ routerLinkComponent: RouterLinkComponent,
13
+ to,
14
+ external = false,
15
+ children,
16
+ ...rest
17
+ }: ExternalLinkProps) {
18
+ if (external) {
19
+ return (
20
+ <a href={to as string} {...rest}>
21
+ {children}
22
+ </a>
23
+ );
24
+ }
25
+ return (
26
+ <RouterLinkComponent to={to} {...rest}>
27
+ {children}
28
+ </RouterLinkComponent>
29
+ );
30
+ }
31
+
32
+ export interface LinkProps extends Omit<ExternalLinkProps, 'routerLinkComponent'> {}
33
+
34
+ export function Link(props: LinkProps) {
35
+ return <ExternalLink routerLinkComponent={RouterLink} {...props} />;
36
+ }
37
+
38
+ export interface NavLinkProps extends Omit<ExternalLinkProps, 'routerLinkComponent' | 'className'> {
39
+ className?: string | (() => string);
40
+ }
41
+
42
+ export function NavLink({ className = '', ...rest }: NavLinkProps) {
43
+ // NavLink#className 支持 function
44
+ const classes = typeof className === 'function' ? className() : className;
45
+ return <ExternalLink routerLinkComponent={RouterNavLink} className={classes} {...rest} />;
46
+ }
@@ -1,9 +1,24 @@
1
1
  import { useState, useContext, createContext, useMemo, useLayoutEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
2
 
4
- export const FullPageContext = createContext();
3
+ type FullPageState = {
4
+ inFullPage: boolean;
5
+ showToggleButton: boolean;
6
+ headerVisibleInFullPage: boolean;
7
+ footerVisibleInFullPage: boolean;
8
+ sidebarVisibleInFullPage: boolean;
9
+ };
10
+
11
+ type FullPageContextValue = FullPageState & {
12
+ headerVisible: boolean;
13
+ footerVisible: boolean;
14
+ sidebarVisible: boolean;
15
+ toggleFullPage: () => void;
16
+ configure: (params: Partial<FullPageState>) => void;
17
+ };
5
18
 
6
- export const useFullPage = (initialState) => {
19
+ export const FullPageContext = createContext<FullPageContextValue>(null!);
20
+
21
+ export const useFullPage = (initialState?: FullPageState) => {
7
22
  const ctx = useContext(FullPageContext);
8
23
  useLayoutEffect(() => {
9
24
  if (initialState) {
@@ -14,7 +29,7 @@ export const useFullPage = (initialState) => {
14
29
  return ctx;
15
30
  };
16
31
 
17
- export function FullPageProvider({ children, ...rest }) {
32
+ export function FullPageProvider({ children, ...rest }: { children?: React.ReactNode }) {
18
33
  const [state, setState] = useState({
19
34
  inFullPage: false,
20
35
  showToggleButton: false,
@@ -25,7 +40,7 @@ export function FullPageProvider({ children, ...rest }) {
25
40
  const toggleFullPage = () => {
26
41
  setState((prev) => ({ ...prev, inFullPage: !prev.inFullPage }));
27
42
  };
28
- const value = useMemo(() => {
43
+ const value = useMemo<FullPageContextValue>(() => {
29
44
  return {
30
45
  ...state,
31
46
  headerVisible: !state.inFullPage || state.headerVisibleInFullPage,
@@ -41,7 +56,3 @@ export function FullPageProvider({ children, ...rest }) {
41
56
  </FullPageContext.Provider>
42
57
  );
43
58
  }
44
-
45
- FullPageProvider.propTypes = {
46
- children: PropTypes.node.isRequired,
47
- };
@@ -1,26 +1,27 @@
1
1
  import { useEffect, useMemo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useLocation, matchPath } from 'react-router-dom';
2
+ import { useLocation, matchPath, type Location } from 'react-router-dom';
4
3
  import Helmet from 'react-helmet';
5
4
  import Container from '@mui/material/Container';
6
5
  import Hidden from '@mui/material/Hidden';
7
6
  import Box from '@mui/material/Box';
7
+ import { type SxProps } from '@mui/material';
8
8
  import clsx from 'clsx';
9
9
  import OpenInFullIcon from '@mui/icons-material/OpenInFull';
10
10
  import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
11
11
  import DashboardLegacy from '../dashboard-legacy';
12
12
  import { ResponsiveHeader } from '../../Header';
13
13
  import NavMenu from '../../NavMenu';
14
- import Footer from '../../Footer';
15
- import Sidebar from './sidebar';
14
+ import Footer, { type FooterProps } from '../../Footer';
15
+ import Sidebar, { type LinkItem } from './sidebar';
16
16
  import { styled, useTheme } from '../../Theme';
17
17
  import { Link } from './external-link';
18
18
  import { FullPageProvider, useFullPage } from './full-page';
19
+ import { NavMenuProps } from '../../NavMenu/nav-menu';
20
+ import { type DashboardProps as DashboardLegacyProps } from '../dashboard-legacy';
19
21
 
20
22
  // 监听 location 变化并关闭 header 中的 menu (确保 drawer - disablePortal:false, keepMounted:true)
21
23
  // 直接监听 menu 中 link 点击来触发 closeMenu 会有问题 (Suspense & lazy)
22
- // eslint-disable-next-line react/prop-types
23
- function NavMenuWrapper({ closeMenu, ...rest }) {
24
+ function NavMenuWrapper({ closeMenu, ...rest }: { closeMenu: () => void } & NavMenuProps) {
24
25
  const location = useLocation();
25
26
  useEffect(() => {
26
27
  closeMenu();
@@ -29,7 +30,7 @@ function NavMenuWrapper({ closeMenu, ...rest }) {
29
30
  return <NavMenu {...rest} />;
30
31
  }
31
32
 
32
- function formatLinks(links, location) {
33
+ function formatLinks(links: LinkItem[], location: Location): LinkItem[] {
33
34
  return links.map((link) => {
34
35
  if (link.children?.length) {
35
36
  return {
@@ -51,7 +52,30 @@ function formatLinks(links, location) {
51
52
  });
52
53
  }
53
54
 
54
- function Dashboard({ children, title, headerProps, links = [], fullWidth, dense, footerProps, ...rest }) {
55
+ export interface DashboardProps extends React.HTMLAttributes<HTMLDivElement> {
56
+ title?: string;
57
+ headerProps?: object;
58
+ /** 支持分组, links item 如果是数组, 则视为一个 group */
59
+ links?: LinkItem[];
60
+ sidebarWidth?: number;
61
+ fullWidth?: false | true;
62
+ /** sidenav 稠密一些的布局, 纵向空间占用较少, 默认为 auto, 当 links 个数 > 8 时自动启用 */
63
+ dense?: 'auto' | boolean;
64
+ footerProps?: FooterProps;
65
+ sx?: SxProps;
66
+ }
67
+
68
+ function Dashboard({
69
+ title = 'Home',
70
+ headerProps = {},
71
+ links = [],
72
+ sidebarWidth = 120,
73
+ fullWidth = false,
74
+ dense = 'auto',
75
+ footerProps = {},
76
+ children,
77
+ ...rest
78
+ }: DashboardProps) {
55
79
  const theme = useTheme();
56
80
  const { inFullPage, showToggleButton, headerVisible, footerVisible, sidebarVisible, toggleFullPage } = useFullPage();
57
81
  const location = useLocation();
@@ -60,7 +84,7 @@ function Dashboard({ children, title, headerProps, links = [], fullWidth, dense,
60
84
  // 一级菜单数量 > 8 或都分组模式, 都启用 dense 布局
61
85
  const _dense = dense === 'auto' ? navItems.length >= 8 || isGroupedMode : dense;
62
86
  const classes = clsx('dashboard', { 'dashboard-dense': _dense }, rest.className);
63
- const defaultHomeLink = (content) => <Link to={window.blocklet?.prefix || '/'}>{content}</Link>;
87
+ const defaultHomeLink = (content: React.ReactNode) => <Link to={window.blocklet?.prefix || '/'}>{content}</Link>;
64
88
  const _headerProps = {
65
89
  homeLink: defaultHomeLink,
66
90
  ...headerProps,
@@ -69,12 +93,12 @@ function Dashboard({ children, title, headerProps, links = [], fullWidth, dense,
69
93
  useEffect(() => {
70
94
  const { searchParams } = new URL(window.location.href);
71
95
  if (searchParams.get('inviter')) {
72
- window.localStorage.setItem('inviter', searchParams.get('inviter'));
96
+ window.localStorage.setItem('inviter', searchParams.get('inviter')!);
73
97
  }
74
98
  }, []);
75
99
 
76
100
  return (
77
- <Wrapper {...rest} className={classes}>
101
+ <Wrapper {...rest} className={classes} sidebarWidth={sidebarWidth}>
78
102
  <Helmet title={title} key={title} />
79
103
 
80
104
  {headerVisible && (
@@ -147,29 +171,11 @@ function Dashboard({ children, title, headerProps, links = [], fullWidth, dense,
147
171
  );
148
172
  }
149
173
 
150
- Dashboard.propTypes = {
151
- children: PropTypes.any.isRequired,
152
- title: PropTypes.string,
153
- // 支持分组, links item 如果是数组, 则视为一个 group
154
- links: PropTypes.array.isRequired,
155
- headerProps: PropTypes.object,
156
- fullWidth: PropTypes.bool,
157
- sidebarWidth: PropTypes.number,
158
- // sidenav 稠密一些的布局, 纵向空间占用较少, 默认为 auto, 当 links 个数 > 8 时自动启用
159
- dense: PropTypes.oneOf([true, false, 'auto']),
160
- };
161
-
162
- Dashboard.defaultProps = {
163
- title: 'Home',
164
- headerProps: {},
165
- fullWidth: false,
166
- sidebarWidth: 120,
167
- dense: 'auto',
168
- };
174
+ type WrapperProps = React.HTMLAttributes<HTMLDivElement> & { sidebarWidth: number };
169
175
 
170
176
  const Wrapper = styled('div', {
171
177
  shouldForwardProp: (prop) => prop !== 'sidebarWidth',
172
- })`
178
+ })<WrapperProps>`
173
179
  &.dashboard {
174
180
  display: flex;
175
181
  flex-direction: column;
@@ -231,9 +237,12 @@ const StyledUxHeader = styled(ResponsiveHeader)`
231
237
  `;
232
238
 
233
239
  // 兼容旧版 dashboard
234
- export default function DashboardWrapper({ legacy, ...rest }) {
240
+ export default function DashboardWrapper<T extends boolean = true>({
241
+ legacy = true as T,
242
+ ...rest
243
+ }: T extends true ? { legacy?: T } & DashboardLegacyProps : { legacy?: T } & DashboardProps) {
235
244
  if (legacy) {
236
- return <DashboardLegacy {...rest} />;
245
+ return <DashboardLegacy {...(rest as unknown as DashboardLegacyProps)} />;
237
246
  }
238
247
  return (
239
248
  <FullPageProvider>
@@ -241,14 +250,3 @@ export default function DashboardWrapper({ legacy, ...rest }) {
241
250
  </FullPageProvider>
242
251
  );
243
252
  }
244
-
245
- DashboardWrapper.propTypes = {
246
- ...Dashboard.propTypes,
247
- legacy: PropTypes.bool,
248
- footerProps: PropTypes.shape(Footer.propTypes),
249
- };
250
-
251
- DashboardWrapper.defaultProps = {
252
- ...Dashboard.defaultProps,
253
- legacy: true,
254
- };
@@ -1,12 +1,22 @@
1
- /* eslint-disable react/no-array-index-key */
2
- import PropTypes from 'prop-types';
3
1
  import Typography from '@mui/material/Typography';
4
2
  import { teal } from '@mui/material/colors';
5
3
  import clsx from 'clsx';
6
4
  import { styled } from '../../Theme';
7
5
  import { NavLink } from './external-link';
8
6
 
9
- function renderItem(item, index) {
7
+ export type LinkItem = {
8
+ url: string;
9
+ title: React.ReactNode;
10
+ icon?: React.ReactNode;
11
+ iconZoom?: number;
12
+ color?: string;
13
+ showBadge?: false | true;
14
+ external?: false | true;
15
+ active?: boolean;
16
+ children?: LinkItem[];
17
+ };
18
+
19
+ function renderItem(item: LinkItem, index: number) {
10
20
  if (item.children?.length) {
11
21
  // eslint-disable-next-line no-use-before-define
12
22
  return renderGroup(item, index);
@@ -18,9 +28,7 @@ function renderItem(item, index) {
18
28
  <NavLink
19
29
  external={external}
20
30
  to={url}
21
- className={({ isActive }) =>
22
- clsx('layout-sidebar-link', { 'layout-sidebar-link--active': external ? active : isActive })
23
- }>
31
+ className={() => clsx('layout-sidebar-link', { 'layout-sidebar-link--active': external ? active : false })}>
24
32
  {icon && <span className={`layout-sidebar-icon ${showBadge ? 'layout-sidebar-badge' : ''}`}>{icon}</span>}
25
33
  <Typography component="span" className="layout-sidebar-link-text">
26
34
  {title}
@@ -30,16 +38,22 @@ function renderItem(item, index) {
30
38
  );
31
39
  }
32
40
 
33
- function renderGroup(item, index) {
41
+ function renderGroup(item: LinkItem, index: number) {
34
42
  return (
35
43
  <li key={`group-${item.title}-${index}`} className="layout-sidebar-group">
36
44
  <span className="layout-sidebar-group-title">{item.title}</span>
37
- <ul>{item.children.map(renderItem)}</ul>
45
+ <ul>{item.children!.map(renderItem)}</ul>
38
46
  </li>
39
47
  );
40
48
  }
41
49
 
42
- function Sidebar({ links, addons, dense, ...rest }) {
50
+ export interface SidebarProps {
51
+ links: LinkItem[];
52
+ addons?: React.ReactNode;
53
+ dense?: false | true;
54
+ }
55
+
56
+ function Sidebar({ links, addons, dense = false, ...rest }: SidebarProps) {
43
57
  return (
44
58
  <Root {...rest} className={clsx({ 'layout-sidebar-dense': dense })}>
45
59
  <ul>{links.map(renderItem)}</ul>
@@ -49,17 +63,6 @@ function Sidebar({ links, addons, dense, ...rest }) {
49
63
  );
50
64
  }
51
65
 
52
- Sidebar.propTypes = {
53
- links: PropTypes.array.isRequired,
54
- addons: PropTypes.any,
55
- dense: PropTypes.bool,
56
- };
57
-
58
- Sidebar.defaultProps = {
59
- addons: null,
60
- dense: false,
61
- };
62
-
63
66
  const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
64
67
 
65
68
  const Root = styled('div')`