@arcblock/ux 2.10.67 → 2.10.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Address/did-address.d.ts +6 -5
- package/lib/Address/index.d.ts +1 -1
- package/lib/Avatar/index.d.ts +10 -8
- package/lib/Avatar/index.js +6 -4
- package/lib/Blocklet/blocklet.d.ts +4 -4
- package/lib/Blocklet/blocklet.js +2 -2
- package/lib/BlockletContext/index.d.ts +3 -3
- package/lib/BlockletNFT/index.d.ts +6 -6
- package/lib/BlockletNFT/index.js +3 -3
- package/lib/BlockletV2/blocklet.d.ts +2 -2
- package/lib/Button/wrap.d.ts +4 -4
- package/lib/Button/wrap.js +2 -2
- package/lib/CardSelector/index.js +0 -1
- package/lib/Center/index.d.ts +1 -1
- package/lib/ClickToCopy/copy-button.d.ts +5 -4
- package/lib/ClickToCopy/copy-button.js +0 -1
- package/lib/ClickToCopy/hook.d.ts +3 -8
- package/lib/ClickToCopy/index.d.ts +6 -4
- package/lib/CodeBlock/index.d.ts +3 -1
- package/lib/CookieConsent/index.d.ts +8 -29
- package/lib/CookieConsent/index.js +3 -17
- package/lib/CountDown/index.d.ts +21 -25
- package/lib/CountDown/index.js +12 -11
- package/lib/DID/index.d.ts +9 -8
- package/lib/Datatable/index.d.ts +5 -5
- package/lib/Datatable/index.js +5 -5
- package/lib/Dialog/confirm.d.ts +6 -6
- package/lib/Dialog/confirm.js +3 -3
- package/lib/Dialog/types.d.ts +1 -1
- package/lib/DidLogo/index.d.ts +5 -25
- package/lib/DidLogo/index.js +4 -15
- package/lib/DriftBot/index.d.ts +13 -19
- package/lib/DriftBot/index.js +5 -6
- package/lib/Earth/index.d.ts +28 -10
- package/lib/Earth/index.js +12 -52
- package/lib/Earth/util.d.ts +10 -5
- package/lib/Earth/util.js +1 -0
- package/lib/ErrorBoundary/fallback.d.ts +12 -19
- package/lib/ErrorBoundary/fallback.js +2 -19
- package/lib/ErrorBoundary/index.d.ts +1 -1
- package/lib/Footer/index.d.ts +17 -24
- package/lib/Footer/index.js +2 -11
- package/lib/Header/header.d.ts +2 -2
- package/lib/Icon/image.d.ts +3 -2
- package/lib/Icon/index.d.ts +6 -4
- package/lib/Img/index.d.ts +1 -1
- package/lib/Img/index.js +1 -1
- package/lib/InfoRow/index.d.ts +9 -32
- package/lib/InfoRow/index.js +10 -23
- package/lib/Layout/dashboard/external-link.d.ts +13 -14
- package/lib/Layout/dashboard/external-link.js +5 -22
- package/lib/Layout/dashboard/full-page.d.ts +19 -11
- package/lib/Layout/dashboard/full-page.js +2 -6
- package/lib/Layout/dashboard/index.d.ts +20 -39
- package/lib/Layout/dashboard/index.js +10 -38
- package/lib/Layout/dashboard/sidebar.d.ts +17 -20
- package/lib/Layout/dashboard/sidebar.js +3 -16
- package/lib/Layout/dashboard-legacy/header.d.ts +10 -36
- package/lib/Layout/dashboard-legacy/header.js +5 -24
- package/lib/Layout/dashboard-legacy/index.d.ts +17 -56
- package/lib/Layout/dashboard-legacy/index.js +12 -41
- package/lib/Layout/dashboard-legacy/sidebar.d.ts +15 -26
- package/lib/Layout/dashboard-legacy/sidebar.js +5 -15
- package/lib/Layout/index.d.ts +17 -56
- package/lib/Layout/index.js +24 -50
- package/lib/LoadingMask/index.d.ts +8 -31
- package/lib/LoadingMask/index.js +3 -19
- package/lib/Locale/browser-lang.d.ts +4 -1
- package/lib/Locale/browser-lang.js +8 -3
- package/lib/Locale/context.d.ts +18 -8
- package/lib/Locale/context.js +1 -1
- package/lib/Locale/languages.d.ts +9 -55
- package/lib/Locale/selector.d.ts +10 -26
- package/lib/Locale/selector.js +8 -25
- package/lib/Locale/util.d.ts +4 -3
- package/lib/Locale/util.js +0 -1
- package/lib/Logo/index.d.ts +9 -40
- package/lib/Logo/index.js +88 -46
- package/lib/Metric/index.d.ts +9 -31
- package/lib/Metric/index.js +5 -20
- package/lib/NFTDisplay/aspect-ratio-container.d.ts +5 -12
- package/lib/NFTDisplay/aspect-ratio-container.js +0 -5
- package/lib/NFTDisplay/broken.d.ts +3 -13
- package/lib/NFTDisplay/broken.js +80 -10
- package/lib/NFTDisplay/displayApi.d.ts +1 -1
- package/lib/NFTDisplay/index.d.ts +28 -6
- package/lib/NFTDisplay/index.js +17 -51
- package/lib/NFTDisplay/svg-embedder/img.d.ts +8 -23
- package/lib/NFTDisplay/svg-embedder/img.js +3 -17
- package/lib/NFTDisplay/svg-embedder/inline-svg.d.ts +7 -13
- package/lib/NFTDisplay/svg-embedder/inline-svg.js +1 -8
- package/lib/NavMenu/nav-menu.d.ts +2 -0
- package/lib/NavMenu/nav-menu.js +0 -1
- package/lib/PageScroller/index.d.ts +14 -13
- package/lib/PageScroller/index.js +12 -37
- package/lib/PageScroller/usePrevValue.d.ts +1 -1
- package/lib/PageScroller/usePrevValue.js +1 -2
- package/lib/Passport/index.d.ts +1 -1
- package/lib/Passport/passport.d.ts +10 -30
- package/lib/Passport/passport.js +5 -19
- package/lib/PoweredByArcBlock/index.d.ts +4 -14
- package/lib/PoweredByArcBlock/index.js +1 -8
- package/lib/PricingTable/PricingPlan.d.ts +11 -9
- package/lib/PricingTable/PricingPlan.js +0 -4
- package/lib/PricingTable/index.d.ts +5 -3
- package/lib/PricingTable/index.js +1 -5
- package/lib/QRCode/index.d.ts +11 -22
- package/lib/QRCode/index.js +2 -17
- package/lib/RelativeTime/index.d.ts +12 -40
- package/lib/RelativeTime/index.js +7 -27
- package/lib/Result/common.d.ts +26 -45
- package/lib/Result/common.js +2 -4
- package/lib/Result/index.d.ts +5 -18
- package/lib/Result/index.js +1 -9
- package/lib/Result/result.d.ts +7 -29
- package/lib/Result/result.js +2 -17
- package/lib/Result/translations.d.ts +2 -54
- package/lib/Screenshot/BaseScreenshot/index.d.ts +7 -24
- package/lib/Screenshot/BaseScreenshot/index.js +2 -15
- package/lib/Screenshot/BaseScreenshot/shells/Macbook.d.ts +25 -19
- package/lib/Screenshot/BaseScreenshot/shells/Phone.d.ts +25 -19
- package/lib/Screenshot/index.d.ts +84 -28
- package/lib/Screenshot/index.js +14 -43
- package/lib/SessionBlocklet/index.d.ts +6 -19
- package/lib/SessionBlocklet/index.js +5 -15
- package/lib/SessionManager/index.d.ts +1 -1
- package/lib/SessionPermission/index.d.ts +9 -17
- package/lib/SessionPermission/index.js +3 -11
- package/lib/SessionUser/components/logged-in.d.ts +9 -31
- package/lib/SessionUser/components/logged-in.js +13 -29
- package/lib/SessionUser/components/session-user-item.d.ts +8 -1
- package/lib/SessionUser/components/session-user-item.js +2 -12
- package/lib/SessionUser/components/session-user-switch.d.ts +9 -21
- package/lib/SessionUser/components/session-user-switch.js +3 -15
- package/lib/SessionUser/components/un-login.d.ts +7 -23
- package/lib/SessionUser/components/un-login.js +4 -16
- package/lib/SessionUser/components/user-info.d.ts +12 -29
- package/lib/SessionUser/components/user-info.js +4 -19
- package/lib/SessionUser/index.d.ts +7 -30
- package/lib/SessionUser/index.js +5 -26
- package/lib/SessionUser/libs/translation.d.ts +2 -31
- package/lib/SessionUser/libs/translation.js +1 -0
- package/lib/SessionUser/libs/utils.d.ts +10 -9
- package/lib/Sparkline/index.d.ts +22 -1
- package/lib/Sparkline/index.js +25 -17
- package/lib/Spinner/index.d.ts +6 -1
- package/lib/Spinner/index.js +4 -11
- package/lib/Success/index.d.ts +5 -21
- package/lib/Success/index.js +10 -19
- package/lib/Tabs/index.d.ts +12 -26
- package/lib/Tabs/index.js +7 -37
- package/lib/TextCollapse/index.d.ts +10 -10
- package/lib/TextCollapse/index.js +4 -21
- package/lib/Theme/index.js +0 -2
- package/lib/Theme/theme-provider.d.ts +1 -1
- package/lib/Theme/theme.d.ts +4 -1
- package/lib/Theme/theme.js +1 -2
- package/lib/Typography/index.d.ts +5 -24
- package/lib/Typography/index.js +5 -17
- package/lib/Util/index.d.ts +17 -8
- package/lib/Util/index.js +22 -3
- package/lib/Video/index.d.ts +12 -16
- package/lib/Video/index.js +0 -14
- package/lib/Wallet/Action.d.ts +13 -18
- package/lib/Wallet/Action.js +0 -7
- package/lib/Wallet/Download.d.ts +24 -30
- package/lib/Wallet/Download.js +201 -18
- package/lib/Wallet/Open.d.ts +5 -15
- package/lib/Wallet/Open.js +5 -11
- package/lib/WalletOSIcon/index.d.ts +6 -25
- package/lib/WalletOSIcon/index.js +3 -16
- package/lib/WebWalletSWKeeper/index.d.ts +8 -20
- package/lib/WebWalletSWKeeper/index.js +14 -19
- package/lib/WechatPrompt/index.js +2 -0
- package/lib/global.d.ts +15 -0
- package/lib/type.d.ts +12 -3
- package/lib/withTheme/index.d.ts +8 -6
- package/lib/withTracker/index.d.ts +1 -1
- package/lib/withTracker/index.js +3 -0
- package/package.json +9 -5
- package/src/Address/did-address.tsx +7 -6
- package/src/Address/index.tsx +1 -1
- package/src/Avatar/index.jsx +6 -4
- package/src/Blocklet/blocklet.jsx +2 -2
- package/src/BlockletContext/index.tsx +3 -3
- package/src/BlockletNFT/index.jsx +3 -3
- package/src/BlockletV2/blocklet.tsx +2 -2
- package/src/Button/wrap.jsx +2 -2
- package/src/CardSelector/index.tsx +0 -1
- package/src/Center/index.tsx +1 -1
- package/src/ClickToCopy/copy-button.tsx +4 -4
- package/src/ClickToCopy/hook.ts +3 -2
- package/src/ClickToCopy/index.tsx +6 -5
- package/src/CodeBlock/index.tsx +3 -1
- package/src/CookieConsent/{index.jsx → index.tsx} +16 -19
- package/src/CountDown/{index.jsx → index.tsx} +30 -16
- package/src/DID/index.tsx +9 -8
- package/src/Datatable/index.jsx +5 -5
- package/src/Dialog/confirm.jsx +3 -3
- package/src/Dialog/types.d.ts +1 -1
- package/src/DidLogo/{index.jsx → index.tsx} +7 -14
- package/src/DriftBot/{index.jsx → index.tsx} +13 -11
- package/src/Earth/{index.jsx → index.tsx} +94 -66
- package/src/Earth/{util.js → util.ts} +20 -17
- package/src/ErrorBoundary/{fallback.jsx → fallback.tsx} +20 -21
- package/src/Footer/{index.jsx → index.tsx} +17 -14
- package/src/Header/header.tsx +2 -3
- package/src/Header/responsive-header.tsx +0 -1
- package/src/Icon/image.tsx +3 -3
- package/src/Icon/index.tsx +7 -4
- package/src/Img/index.jsx +1 -1
- package/src/InfoRow/{index.jsx → index.tsx} +32 -25
- package/src/Layout/dashboard/external-link.tsx +46 -0
- package/src/Layout/dashboard/{full-page.jsx → full-page.tsx} +20 -9
- package/src/Layout/dashboard/{index.jsx → index.tsx} +42 -44
- package/src/Layout/dashboard/{sidebar.jsx → sidebar.tsx} +23 -20
- package/src/Layout/dashboard-legacy/{header.jsx → header.tsx} +16 -26
- package/src/Layout/dashboard-legacy/{index.jsx → index.tsx} +32 -46
- package/src/Layout/dashboard-legacy/{sidebar.jsx → sidebar.tsx} +27 -19
- package/src/Layout/{index.jsx → index.tsx} +41 -47
- package/src/LoadingMask/{index.jsx → index.tsx} +18 -20
- package/src/Locale/{browser-lang.js → browser-lang.ts} +9 -7
- package/src/Locale/context.tsx +18 -11
- package/src/Locale/{languages.js → languages.ts} +1 -1
- package/src/Locale/{selector.jsx → selector.tsx} +32 -29
- package/src/Locale/{util.js → util.ts} +9 -2
- package/src/Logo/index.tsx +58 -0
- package/src/Metric/{index.jsx → index.tsx} +23 -18
- package/src/NFTDisplay/{aspect-ratio-container.jsx → aspect-ratio-container.tsx} +9 -7
- package/src/NFTDisplay/{broken.jsx → broken.tsx} +7 -12
- package/src/NFTDisplay/{displayApi.js → displayApi.ts} +4 -4
- package/src/NFTDisplay/{index.jsx → index.tsx} +59 -64
- package/src/NFTDisplay/svg-embedder/{img.jsx → img.tsx} +10 -18
- package/src/NFTDisplay/svg-embedder/{inline-svg.jsx → inline-svg.tsx} +8 -9
- package/src/NavMenu/nav-menu.tsx +2 -3
- package/src/PageScroller/{index.jsx → index.tsx} +40 -53
- package/src/PageScroller/{usePrevValue.js → usePrevValue.ts} +2 -3
- package/src/Passport/{passport.jsx → passport.tsx} +22 -19
- package/src/PoweredByArcBlock/{index.jsx → index.tsx} +6 -11
- package/src/PricingTable/{PricingPlan.jsx → PricingPlan.tsx} +15 -5
- package/src/PricingTable/{index.jsx → index.tsx} +9 -6
- package/src/QRCode/{index.jsx → index.tsx} +14 -19
- package/src/RelativeTime/{index.jsx → index.tsx} +24 -24
- package/src/Result/{common.jsx → common.tsx} +17 -13
- package/src/Result/index.tsx +30 -0
- package/src/Result/{result.jsx → result.tsx} +8 -17
- package/src/Result/{translations.js → translations.ts} +3 -1
- package/src/Screenshot/BaseScreenshot/{index.jsx → index.tsx} +9 -15
- package/src/Screenshot/BaseScreenshot/shells/{Macbook.jsx → Macbook.tsx} +3 -1
- package/src/Screenshot/BaseScreenshot/shells/{Phone.jsx → Phone.tsx} +3 -1
- package/src/Screenshot/{index.jsx → index.tsx} +60 -54
- package/src/SessionBlocklet/{index.jsx → index.tsx} +9 -14
- package/src/SessionPermission/index.tsx +25 -0
- package/src/SessionUser/components/{logged-in.jsx → logged-in.tsx} +49 -31
- package/src/SessionUser/components/session-user-item.tsx +97 -0
- package/src/SessionUser/components/{session-user-switch.jsx → session-user-switch.tsx} +16 -21
- package/src/SessionUser/components/{un-login.jsx → un-login.tsx} +10 -15
- package/src/SessionUser/components/{user-info.jsx → user-info.tsx} +16 -22
- package/src/SessionUser/index.tsx +26 -0
- package/src/SessionUser/libs/{translation.js → translation.ts} +3 -1
- package/src/SessionUser/libs/utils.ts +39 -0
- package/src/Sparkline/{index.jsx → index.tsx} +38 -22
- package/src/Spinner/index.tsx +20 -0
- package/src/Success/{index.jsx → index.tsx} +13 -16
- package/src/Tabs/{index.jsx → index.tsx} +26 -40
- package/src/TextCollapse/{index.jsx → index.tsx} +26 -21
- package/src/Theme/index.ts +0 -1
- package/src/Theme/theme-provider.tsx +1 -1
- package/src/Theme/theme.ts +6 -3
- package/src/Typography/{index.jsx → index.tsx} +19 -22
- package/src/Util/index.ts +26 -9
- package/src/Video/{index.jsx → index.tsx} +7 -10
- package/src/Wallet/{Action.jsx → Action.tsx} +16 -12
- package/src/Wallet/{Download.jsx → Download.tsx} +25 -21
- package/src/Wallet/{Open.jsx → Open.tsx} +8 -11
- package/src/WalletOSIcon/{index.jsx → index.tsx} +8 -16
- package/src/WebWalletSWKeeper/{index.jsx → index.tsx} +21 -24
- package/src/WechatPrompt/{index.jsx → index.tsx} +1 -0
- package/src/global.d.ts +15 -0
- package/src/type.d.ts +12 -3
- package/src/withTheme/{index.jsx → index.tsx} +12 -2
- package/src/withTracker/{index.jsx → index.tsx} +6 -4
- package/src/Layout/dashboard/external-link.jsx +0 -47
- package/src/Logo/index.jsx +0 -66
- package/src/Result/index.jsx +0 -33
- package/src/SessionPermission/index.jsx +0 -28
- package/src/SessionUser/components/session-user-item.jsx +0 -93
- package/src/SessionUser/index.jsx +0 -38
- package/src/SessionUser/libs/utils.js +0 -37
- package/src/Spinner/index.jsx +0 -21
- /package/src/ErrorBoundary/{index.jsx → index.ts} +0 -0
- /package/src/NFTDisplay/{loading.jsx → loading.tsx} +0 -0
- /package/src/Passport/{index.jsx → index.ts} +0 -0
- /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
|
-
|
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
|
-
|
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
|
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 (
|
41
|
+
if (_entries.length <= 1) {
|
30
42
|
return;
|
31
43
|
}
|
32
44
|
|
33
|
-
|
34
|
-
|
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 (
|
@@ -16,7 +21,8 @@ export default function Success({ size, backgroundColor, borderWidth }) {
|
|
16
21
|
'&, *, *::before, *::after': {
|
17
22
|
boxSizing: 'content-box !important',
|
18
23
|
},
|
19
|
-
|
24
|
+
// 转圈边框的颜色
|
25
|
+
border: (theme) => `${borderWidth}px solid ${theme.palette.success.light}`,
|
20
26
|
'&::before, &::after': {
|
21
27
|
content: '""',
|
22
28
|
height: '125%',
|
@@ -41,7 +47,8 @@ export default function Success({ size, backgroundColor, borderWidth }) {
|
|
41
47
|
},
|
42
48
|
'.icon-line': {
|
43
49
|
height: `${borderWidth + 1}px`,
|
44
|
-
|
50
|
+
// 对勾的颜色
|
51
|
+
backgroundColor: (theme) => theme.palette.success.light,
|
45
52
|
display: 'block',
|
46
53
|
borderRadius: '100vw',
|
47
54
|
position: 'absolute',
|
@@ -144,7 +151,8 @@ export default function Success({ size, backgroundColor, borderWidth }) {
|
|
144
151
|
borderRadius: '100%',
|
145
152
|
position: 'absolute',
|
146
153
|
boxSizing: 'contentBox',
|
147
|
-
|
154
|
+
// 圆环的颜色
|
155
|
+
border: `${borderWidth}px solid rgba(76, 175, 80, 0.63)`,
|
148
156
|
}}
|
149
157
|
/>
|
150
158
|
<Box
|
@@ -163,14 +171,3 @@ export default function Success({ size, backgroundColor, borderWidth }) {
|
|
163
171
|
</Box>
|
164
172
|
);
|
165
173
|
}
|
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
|
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
|
-
|
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
|
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
|
-
|
82
|
-
tabs:
|
83
|
-
current:
|
84
|
-
onChange:
|
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
|
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
|
-
|
147
|
-
tabs:
|
148
|
-
current:
|
149
|
-
onChange:
|
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 (
|
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 (
|
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
|
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
|
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
|
-
|
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
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
endChars: 5,
|
50
|
-
scaleFactor: 0.45,
|
51
|
-
fontType: 'normal',
|
56
|
+
type ContainerProps = {
|
57
|
+
startwidth: string;
|
58
|
+
endwidth: string;
|
52
59
|
};
|
53
60
|
|
54
|
-
|
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;
|
package/src/Theme/index.ts
CHANGED
package/src/Theme/theme.ts
CHANGED
@@ -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
|
25
|
-
declare module '@mui/material/styles
|
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' } });
|