@arcblock/ux 3.4.15 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json.js +1 -1
- package/package.json +10 -7
- package/src/ActionButton/ActionButton.stories.jsx +0 -61
- package/src/ActionButton/index.jsx +0 -106
- package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
- package/src/ActivityIndicator/index.jsx +0 -140
- package/src/Address/Address.stories.jsx +0 -38
- package/src/Address/compact-text.jsx +0 -76
- package/src/Address/did-address.tsx +0 -223
- package/src/Address/index.tsx +0 -21
- package/src/Address/responsive-did-address.tsx +0 -154
- package/src/Alert/Alert.stories.jsx +0 -100
- package/src/Alert/index.jsx +0 -130
- package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
- package/src/AnimationWaiter/dark-animation.json +0 -1
- package/src/AnimationWaiter/default-animation.json +0 -1
- package/src/AnimationWaiter/index.jsx +0 -296
- package/src/Async/index.tsx +0 -44
- package/src/Avatar/Avatar.stories.jsx +0 -11
- package/src/Avatar/did-motif.jsx +0 -38
- package/src/Avatar/etherscan-blockies.js +0 -81
- package/src/Avatar/index.jsx +0 -195
- package/src/Badge/Badge.stories.jsx +0 -41
- package/src/Badge/index.jsx +0 -101
- package/src/Blocklet/Blocklet.stories.jsx +0 -21
- package/src/Blocklet/blocklet.jsx +0 -276
- package/src/Blocklet/index.js +0 -5
- package/src/Blocklet/utils.jsx +0 -58
- package/src/BlockletContext/index.tsx +0 -72
- package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
- package/src/BlockletNFT/index.jsx +0 -378
- package/src/BlockletV2/Blocklet.stories.jsx +0 -34
- package/src/BlockletV2/blocklet.tsx +0 -247
- package/src/BlockletV2/components/icon-text.tsx +0 -47
- package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
- package/src/BlockletV2/index.ts +0 -6
- package/src/BlockletV2/utils.js +0 -75
- package/src/Button/Button.stories.jsx +0 -24
- package/src/Button/index.js +0 -9
- package/src/Button/wrap.jsx +0 -126
- package/src/ButtonGroup/index.js +0 -16
- package/src/CardSelector/index.tsx +0 -136
- package/src/Center/Center.stories.jsx +0 -20
- package/src/Center/index.tsx +0 -33
- package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
- package/src/ClickToCopy/copy-button.tsx +0 -43
- package/src/ClickToCopy/hook.ts +0 -42
- package/src/ClickToCopy/index.tsx +0 -96
- package/src/CloseButton/index.tsx +0 -37
- package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
- package/src/CodeBlock/LightBox.tsx +0 -87
- package/src/CodeBlock/index.tsx +0 -217
- package/src/Colors/Colors.stories.jsx +0 -211
- package/src/Colors/index.ts +0 -4
- package/src/Colors/themes/default.ts +0 -8
- package/src/Colors/themes/did-connect.ts +0 -64
- package/src/Colors/themes/temp.ts +0 -52
- package/src/Config/Config.stories.jsx +0 -16
- package/src/Config/config-provider.tsx +0 -62
- package/src/Config/index.ts +0 -2
- package/src/Config/theme-mode-toggle.tsx +0 -38
- package/src/ContactForm/ContactForm.stories.jsx +0 -32
- package/src/ContactForm/index.tsx +0 -264
- package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
- package/src/CookieConsent/index.tsx +0 -104
- package/src/CountDown/CountDown.stories.jsx +0 -15
- package/src/CountDown/index.tsx +0 -170
- package/src/DID/DID.stories.jsx +0 -37
- package/src/DID/index.tsx +0 -393
- package/src/DIDConnect/app-icon.tsx +0 -37
- package/src/DIDConnect/app-info-item.tsx +0 -93
- package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
- package/src/DIDConnect/auth-apps/index.tsx +0 -278
- package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
- package/src/DIDConnect/did-connect-container.tsx +0 -326
- package/src/DIDConnect/did-connect-footer.tsx +0 -76
- package/src/DIDConnect/did-connect-logo.tsx +0 -8
- package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
- package/src/DIDConnect/icons/github-logo.tsx +0 -17
- package/src/DIDConnect/index.ts +0 -11
- package/src/DIDConnect/landing-page.tsx +0 -218
- package/src/DIDConnect/powered-by.tsx +0 -48
- package/src/DIDConnect/provider-icon.tsx +0 -62
- package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
- package/src/DIDConnect/with-container.tsx +0 -323
- package/src/DIDConnect/with-ux-theme.tsx +0 -22
- package/src/DIDLogo/Logo.stories.jsx +0 -11
- package/src/DIDLogo/index.tsx +0 -168
- package/src/Datatable/CustomToolbar.jsx +0 -415
- package/src/Datatable/Datatable.stories.jsx +0 -92
- package/src/Datatable/DatatableContext.jsx +0 -35
- package/src/Datatable/TableSearch.jsx +0 -166
- package/src/Datatable/index.jsx +0 -652
- package/src/Datatable/utils.js +0 -161
- package/src/Dialog/Dialog.stories.jsx +0 -21
- package/src/Dialog/confirm.jsx +0 -143
- package/src/Dialog/dialog.jsx +0 -199
- package/src/Dialog/index.js +0 -4
- package/src/Dialog/types.d.ts +0 -20
- package/src/Dialog/use-confirm.jsx +0 -188
- package/src/DriftBot/index.tsx +0 -81
- package/src/Earth/Earth.stories.jsx +0 -39
- package/src/Earth/countries.json +0 -8057
- package/src/Earth/index.tsx +0 -515
- package/src/Earth/util.ts +0 -72
- package/src/Empty/Empty.stories.jsx +0 -23
- package/src/Empty/index.jsx +0 -48
- package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
- package/src/ErrorBoundary/fallback.tsx +0 -85
- package/src/ErrorBoundary/index.ts +0 -1
- package/src/Footer/Footer.stories.jsx +0 -13
- package/src/Footer/index.tsx +0 -130
- package/src/Header/Header.stories.jsx +0 -30
- package/src/Header/addon-button.tsx +0 -41
- package/src/Header/auto-hidden.tsx +0 -31
- package/src/Header/header-addons.tsx +0 -37
- package/src/Header/header.tsx +0 -214
- package/src/Header/index.ts +0 -3
- package/src/Header/responsive-header.tsx +0 -145
- package/src/Icon/Icon.stories.jsx +0 -45
- package/src/Icon/image.tsx +0 -53
- package/src/Icon/index.tsx +0 -63
- package/src/Img/Img.stories.jsx +0 -17
- package/src/Img/index.jsx +0 -258
- package/src/InfoRow/InfoRow.stories.jsx +0 -14
- package/src/InfoRow/index.tsx +0 -91
- package/src/Layout/Layout.stories.jsx +0 -24
- package/src/Layout/dashboard/external-link.tsx +0 -59
- package/src/Layout/dashboard/full-page.tsx +0 -58
- package/src/Layout/dashboard/index.tsx +0 -260
- package/src/Layout/dashboard/sidebar.tsx +0 -198
- package/src/Layout/dashboard-legacy/header.tsx +0 -156
- package/src/Layout/dashboard-legacy/index.tsx +0 -127
- package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
- package/src/Layout/index.tsx +0 -310
- package/src/LoadingMask/index.tsx +0 -108
- package/src/Locale/LocaleSelector.stories.jsx +0 -44
- package/src/Locale/browser-lang.ts +0 -65
- package/src/Locale/context.tsx +0 -162
- package/src/Locale/languages.ts +0 -58
- package/src/Locale/selector.tsx +0 -174
- package/src/Locale/util.ts +0 -38
- package/src/Logo/Logo.stories.jsx +0 -23
- package/src/Logo/images/logo-dark-text.svg +0 -3
- package/src/Logo/images/logo-dark-top.svg +0 -6
- package/src/Logo/images/logo-light-text.svg +0 -3
- package/src/Logo/images/logo-light-top.svg +0 -6
- package/src/Logo/index.tsx +0 -58
- package/src/Metric/Metric.stories.jsx +0 -29
- package/src/Metric/index.tsx +0 -130
- package/src/MuiWrap/index.tsx +0 -10
- package/src/NFTDisplay/NFTBroken.svg +0 -34
- package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
- package/src/NFTDisplay/README.md +0 -59
- package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
- package/src/NFTDisplay/broken.tsx +0 -51
- package/src/NFTDisplay/displayApi.ts +0 -43
- package/src/NFTDisplay/index.tsx +0 -393
- package/src/NFTDisplay/loading.tsx +0 -16
- package/src/NFTDisplay/preview.tsx +0 -84
- package/src/NFTDisplay/render-svg.tsx +0 -21
- package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
- package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
- package/src/NavMenu/NavMenu.stories.jsx +0 -17
- package/src/NavMenu/images/OCAP.svg +0 -1
- package/src/NavMenu/images/abt-network.svg +0 -1
- package/src/NavMenu/images/ai-kit.svg +0 -1
- package/src/NavMenu/images/aigne-image-smith.svg +0 -1
- package/src/NavMenu/images/aigne.svg +0 -1
- package/src/NavMenu/images/aistro.png +0 -0
- package/src/NavMenu/images/arcsphere.svg +0 -1
- package/src/NavMenu/images/blocklet-framework.svg +0 -1
- package/src/NavMenu/images/blocklet-launcher.svg +0 -1
- package/src/NavMenu/images/blocklet-server.svg +0 -1
- package/src/NavMenu/images/blocklet-store.svg +0 -1
- package/src/NavMenu/images/creator-studio.svg +0 -1
- package/src/NavMenu/images/did-wallet.svg +0 -1
- package/src/NavMenu/images/did.svg +0 -1
- package/src/NavMenu/images/nft-studio.svg +0 -1
- package/src/NavMenu/images/payment-kit.png +0 -0
- package/src/NavMenu/images/vc.svg +0 -1
- package/src/NavMenu/images/web3-kit.svg +0 -1
- package/src/NavMenu/index.ts +0 -3
- package/src/NavMenu/nav-menu-context.tsx +0 -30
- package/src/NavMenu/nav-menu.tsx +0 -441
- package/src/NavMenu/products.tsx +0 -830
- package/src/NavMenu/style.ts +0 -258
- package/src/NavMenu/sub-container.tsx +0 -125
- package/src/NavMenu/sub-item-group.tsx +0 -42
- package/src/OrgTransfer/index.tsx +0 -53
- package/src/OrgTransfer/locales.ts +0 -25
- package/src/OrgTransfer/selector.tsx +0 -252
- package/src/OrgTransfer/type.ts +0 -31
- package/src/PageScroller/index.tsx +0 -316
- package/src/PageScroller/story/FifthComponent.jsx +0 -7
- package/src/PageScroller/story/FirstComponent.jsx +0 -7
- package/src/PageScroller/story/FourthComponent.jsx +0 -7
- package/src/PageScroller/story/FullPage.jsx +0 -55
- package/src/PageScroller/story/PageContain.jsx +0 -59
- package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
- package/src/PageScroller/story/SecondComponent.jsx +0 -7
- package/src/PageScroller/story/ThirdComponent.jsx +0 -7
- package/src/PageScroller/story/index.css +0 -115
- package/src/PageScroller/usePrevValue.ts +0 -11
- package/src/Passport/index.ts +0 -3
- package/src/Passport/passport.tsx +0 -118
- package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
- package/src/PhoneInput/country-select.tsx +0 -148
- package/src/PhoneInput/index.tsx +0 -269
- package/src/PoweredByArcBlock/index.tsx +0 -27
- package/src/PricingTable/PricingPlan.tsx +0 -120
- package/src/PricingTable/PricingTable.stories.jsx +0 -38
- package/src/PricingTable/index.tsx +0 -59
- package/src/QRCode/QRCode.stories.jsx +0 -13
- package/src/QRCode/index.tsx +0 -66
- package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
- package/src/RelativeTime/index.tsx +0 -334
- package/src/Result/Result.stories.jsx +0 -61
- package/src/Result/common.tsx +0 -119
- package/src/Result/index.tsx +0 -30
- package/src/Result/result.tsx +0 -65
- package/src/Result/translations.ts +0 -57
- package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
- package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
- package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
- package/src/Screenshot/Screenshot.stories.jsx +0 -44
- package/src/Screenshot/devices.css +0 -1366
- package/src/Screenshot/index.tsx +0 -300
- package/src/SessionBlocklet/index.tsx +0 -178
- package/src/SessionManager/SessionManager.stories.jsx +0 -9
- package/src/SessionManager/index.tsx +0 -3
- package/src/SessionPermission/index.tsx +0 -26
- package/src/SessionUser/components/did-space.tsx +0 -68
- package/src/SessionUser/components/logged-in.tsx +0 -338
- package/src/SessionUser/components/quick-login-item.tsx +0 -132
- package/src/SessionUser/components/session-user-item.tsx +0 -93
- package/src/SessionUser/components/session-user-switch.tsx +0 -240
- package/src/SessionUser/components/un-login.tsx +0 -257
- package/src/SessionUser/components/user-info.tsx +0 -201
- package/src/SessionUser/index.tsx +0 -68
- package/src/SessionUser/libs/translation.ts +0 -30
- package/src/SessionUser/libs/utils.ts +0 -39
- package/src/SharedBridge/index.tsx +0 -126
- package/src/SocialShare/index.tsx +0 -194
- package/src/Sparkline/Sparkline.stories.jsx +0 -13
- package/src/Sparkline/index.tsx +0 -231
- package/src/Spinner/Spinner.stories.jsx +0 -98
- package/src/Spinner/index.tsx +0 -20
- package/src/SplitButton/SplitButton.stories.jsx +0 -32
- package/src/SplitButton/index.tsx +0 -116
- package/src/SplitButton/useClickAway.tsx +0 -24
- package/src/Success/index.tsx +0 -175
- package/src/Switch/Switch.stories.jsx +0 -16
- package/src/Switch/index.jsx +0 -79
- package/src/Tabs/Tabs.stories.jsx +0 -18
- package/src/Tabs/index.tsx +0 -255
- package/src/Tag/Tag.stories.jsx +0 -15
- package/src/Tag/index.jsx +0 -106
- package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
- package/src/TextCollapse/index.tsx +0 -85
- package/src/Theme/Theme.stories.jsx +0 -11
- package/src/Theme/index.ts +0 -21
- package/src/Theme/theme-provider.tsx +0 -374
- package/src/Theme/theme.ts +0 -229
- package/src/Toast/Toast.stories.jsx +0 -28
- package/src/Toast/index.tsx +0 -80
- package/src/Typography/index.tsx +0 -124
- package/src/UserCard/Cards/avatar-only.tsx +0 -27
- package/src/UserCard/Cards/basic-info.tsx +0 -43
- package/src/UserCard/Cards/index.tsx +0 -16
- package/src/UserCard/Cards/social-actions.tsx +0 -196
- package/src/UserCard/Container/card.tsx +0 -63
- package/src/UserCard/Container/dialog.tsx +0 -37
- package/src/UserCard/Content/basic.tsx +0 -330
- package/src/UserCard/Content/clock.tsx +0 -82
- package/src/UserCard/Content/minimal.tsx +0 -113
- package/src/UserCard/Content/shorten-label.tsx +0 -32
- package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
- package/src/UserCard/UserCard.stories.jsx +0 -19
- package/src/UserCard/components.tsx +0 -81
- package/src/UserCard/index.tsx +0 -132
- package/src/UserCard/types.ts +0 -165
- package/src/UserCard/use-follow.tsx +0 -111
- package/src/UserCard/utils.ts +0 -155
- package/src/Util/WebWalletOpener.stories.jsx +0 -5
- package/src/Util/client.ts +0 -4
- package/src/Util/constant.ts +0 -70
- package/src/Util/deprecate.tsx +0 -29
- package/src/Util/federated.ts +0 -125
- package/src/Util/iframe.ts +0 -19
- package/src/Util/index.ts +0 -760
- package/src/Util/logger.ts +0 -44
- package/src/Util/passport.ts +0 -127
- package/src/Util/security.ts +0 -72
- package/src/Util/style.ts +0 -17
- package/src/Util/wallet.ts +0 -35
- package/src/VerificationCode/index.tsx +0 -83
- package/src/Video/Video.stories.jsx +0 -6
- package/src/Video/index.tsx +0 -70
- package/src/Wallet/Action.stories.jsx +0 -8
- package/src/Wallet/Action.tsx +0 -118
- package/src/Wallet/Download.stories.jsx +0 -9
- package/src/Wallet/Download.tsx +0 -157
- package/src/Wallet/Open.tsx +0 -47
- package/src/Wallet/OpenInWallet.stories.jsx +0 -5
- package/src/Wallet/images/abtwallet.png +0 -0
- package/src/Wallet/images/android_download.svg +0 -22
- package/src/Wallet/images/app-store.svg +0 -30
- package/src/Wallet/images/google-play.svg +0 -69
- package/src/WalletOSIcon/index.tsx +0 -47
- package/src/WebWalletSWKeeper/index.tsx +0 -117
- package/src/WechatPrompt/images/android.png +0 -0
- package/src/WechatPrompt/images/ios.png +0 -0
- package/src/WechatPrompt/index.tsx +0 -75
- package/src/global.d.ts +0 -28
- package/src/hooks/use-blocklet-logo.tsx +0 -32
- package/src/hooks/use-clock.tsx +0 -62
- package/src/hooks/use-location-state.tsx +0 -117
- package/src/hooks/use-mobile.tsx +0 -6
- package/src/index.ts +0 -79
- package/src/type.d.ts +0 -44
- package/src/withTheme/index.tsx +0 -72
- package/src/withTracker/README.md +0 -37
- package/src/withTracker/action/bind-wallet.tsx +0 -17
- package/src/withTracker/action/login.tsx +0 -18
- package/src/withTracker/action/pay.tsx +0 -14
- package/src/withTracker/action/switch-passport.tsx +0 -20
- package/src/withTracker/constant/index.tsx +0 -3
- package/src/withTracker/env.tsx +0 -1
- package/src/withTracker/error_boundary.jsx +0 -34
- package/src/withTracker/index.tsx +0 -50
- package/src/withTracker/libs/utm.ts +0 -46
- package/vite.config.mjs +0 -37
package/src/Typography/index.tsx
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Box, Typography as MuiTypography, Skeleton, type TypographyProps as MuiTypographyProps } from '@mui/material';
|
|
2
|
-
import { useCreation, useReactive, useSize } from 'ahooks';
|
|
3
|
-
import noop from 'lodash/noop';
|
|
4
|
-
import { useEffect, useRef } from 'react';
|
|
5
|
-
|
|
6
|
-
export interface TypographyProps extends MuiTypographyProps {
|
|
7
|
-
fontSize?: string | number;
|
|
8
|
-
minFontSize?: number;
|
|
9
|
-
onShrink?: ({ fontSize, initialSize }: { fontSize: number; initialSize: number }) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
let minBrowserFontSize = -1;
|
|
13
|
-
|
|
14
|
-
function detectMinimumFontSize() {
|
|
15
|
-
const testDiv = document.createElement('div');
|
|
16
|
-
|
|
17
|
-
Object.assign(testDiv.style, {
|
|
18
|
-
fontSize: '1px',
|
|
19
|
-
visibility: 'hidden',
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
});
|
|
22
|
-
testDiv.textContent = 'Test';
|
|
23
|
-
document.body.appendChild(testDiv);
|
|
24
|
-
|
|
25
|
-
const size = parseFloat(getComputedStyle(testDiv).fontSize);
|
|
26
|
-
document.body.removeChild(testDiv);
|
|
27
|
-
return size;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default function Typography({
|
|
31
|
-
children = null,
|
|
32
|
-
minFontSize = 12,
|
|
33
|
-
/* 设置为 auto 时字体会自动收缩,直到达到浏览器最小字体限制 */
|
|
34
|
-
fontSize = undefined,
|
|
35
|
-
sx,
|
|
36
|
-
onShrink = noop,
|
|
37
|
-
...rest
|
|
38
|
-
}: TypographyProps) {
|
|
39
|
-
const refMock = useRef<HTMLSpanElement>(null);
|
|
40
|
-
const refContainer = useRef<HTMLDivElement>(null);
|
|
41
|
-
const state = useReactive<{
|
|
42
|
-
fontSize?: number;
|
|
43
|
-
loading: boolean;
|
|
44
|
-
initialSize?: number;
|
|
45
|
-
}>({
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
fontSize,
|
|
48
|
-
loading: true,
|
|
49
|
-
});
|
|
50
|
-
const mockSize = useSize(refMock.current);
|
|
51
|
-
const containerSize = useSize(refContainer.current);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (state.loading) {
|
|
55
|
-
if (fontSize === 'auto') {
|
|
56
|
-
if (mockSize && !state.initialSize) {
|
|
57
|
-
const styleSize = getComputedStyle(refMock.current!).fontSize;
|
|
58
|
-
state.initialSize = Number(styleSize.replace('px', ''));
|
|
59
|
-
state.fontSize = state.initialSize;
|
|
60
|
-
}
|
|
61
|
-
if (minBrowserFontSize < 0) {
|
|
62
|
-
minBrowserFontSize = detectMinimumFontSize();
|
|
63
|
-
}
|
|
64
|
-
// 达到浏览器最小字体限制,停止缩放
|
|
65
|
-
if (state.fontSize! <= minBrowserFontSize) {
|
|
66
|
-
state.loading = false;
|
|
67
|
-
onShrink?.({ fontSize: state.fontSize!, initialSize: state.initialSize! });
|
|
68
|
-
} else if (containerSize && mockSize) {
|
|
69
|
-
// 超过容器宽度,尝试收缩
|
|
70
|
-
if (containerSize.width < mockSize.width && state.fontSize! > minFontSize) {
|
|
71
|
-
state.fontSize!--;
|
|
72
|
-
} else {
|
|
73
|
-
state.loading = false;
|
|
74
|
-
onShrink?.({ fontSize: state.fontSize!, initialSize: state.initialSize! });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
state.loading = false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
-
}, [fontSize, mockSize?.width, containerSize?.width]);
|
|
83
|
-
|
|
84
|
-
const loading = useCreation(() => {
|
|
85
|
-
if (fontSize === 'auto') {
|
|
86
|
-
return state.loading;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}, [fontSize, state.loading]);
|
|
90
|
-
|
|
91
|
-
return loading ? (
|
|
92
|
-
<Box
|
|
93
|
-
ref={refContainer}
|
|
94
|
-
sx={{
|
|
95
|
-
flex: 1,
|
|
96
|
-
}}>
|
|
97
|
-
<MuiTypography {...rest} sx={sx} noWrap>
|
|
98
|
-
<Skeleton variant="text" sx={{ fontSize: '1rem' }} />
|
|
99
|
-
</MuiTypography>
|
|
100
|
-
<MuiTypography
|
|
101
|
-
ref={refMock}
|
|
102
|
-
{...rest}
|
|
103
|
-
sx={{
|
|
104
|
-
...sx,
|
|
105
|
-
...(state.fontSize ? { fontSize: `${state.fontSize}px !important` } : {}),
|
|
106
|
-
position: 'fixed',
|
|
107
|
-
top: -1000,
|
|
108
|
-
left: -1000,
|
|
109
|
-
}}
|
|
110
|
-
noWrap>
|
|
111
|
-
{children}
|
|
112
|
-
</MuiTypography>
|
|
113
|
-
</Box>
|
|
114
|
-
) : (
|
|
115
|
-
<MuiTypography
|
|
116
|
-
{...rest}
|
|
117
|
-
sx={{
|
|
118
|
-
...sx,
|
|
119
|
-
...(state.fontSize ? { fontSize: `${state.fontSize}px !important` } : {}),
|
|
120
|
-
}}>
|
|
121
|
-
{children}
|
|
122
|
-
</MuiTypography>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UserCardProps, User } from '../types';
|
|
3
|
-
import TooltipAvatar from '../Content/tooltip-avatar';
|
|
4
|
-
|
|
5
|
-
interface AvatarOnlyCardProps extends Omit<UserCardProps, 'user'> {
|
|
6
|
-
user: User;
|
|
7
|
-
renderCardContent: () => React.ReactNode;
|
|
8
|
-
shouldShowHoverCard: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// AvatarOnly卡片组件,处理仅头像模式的渲染
|
|
12
|
-
function AvatarOnlyCard(props: AvatarOnlyCardProps) {
|
|
13
|
-
const { user, infoType, avatarSize = 48, shouldShowHoverCard = false, renderCardContent, ...rest } = props;
|
|
14
|
-
|
|
15
|
-
// 其他类型使用自定义Tooltip或无Tooltip
|
|
16
|
-
return (
|
|
17
|
-
<TooltipAvatar
|
|
18
|
-
user={user}
|
|
19
|
-
avatarSize={avatarSize}
|
|
20
|
-
shouldShowHoverCard={shouldShowHoverCard}
|
|
21
|
-
renderCardContent={renderCardContent}
|
|
22
|
-
{...rest}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default AvatarOnlyCard;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box } from '@mui/material';
|
|
3
|
-
import { InfoType, UserCardProps, User } from '../types';
|
|
4
|
-
import MinimalContent from '../Content/minimal';
|
|
5
|
-
import BasicContent from '../Content/basic';
|
|
6
|
-
|
|
7
|
-
interface BasicCardProps extends Omit<UserCardProps, 'user'> {
|
|
8
|
-
user: User;
|
|
9
|
-
shouldShowHoverCard: boolean;
|
|
10
|
-
renderCardContent?: () => React.ReactNode | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// 详细卡片模式下的Basic渲染组件
|
|
14
|
-
function BasicCard({ ...props }: BasicCardProps) {
|
|
15
|
-
const {
|
|
16
|
-
user,
|
|
17
|
-
avatarSize = 40,
|
|
18
|
-
renderCustomContent,
|
|
19
|
-
infoType = InfoType.Minimal,
|
|
20
|
-
renderFields,
|
|
21
|
-
popupRenderFields,
|
|
22
|
-
...rest
|
|
23
|
-
} = props;
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<Box
|
|
27
|
-
sx={{
|
|
28
|
-
display: 'flex',
|
|
29
|
-
flexDirection: 'column',
|
|
30
|
-
width: '100%',
|
|
31
|
-
flex: 1,
|
|
32
|
-
height: '100%',
|
|
33
|
-
}}>
|
|
34
|
-
<MinimalContent user={user} avatarSize={avatarSize} {...rest} />
|
|
35
|
-
{infoType === InfoType.Basic && <BasicContent user={user} renderFields={renderFields} />}
|
|
36
|
-
<Box className="user-card__footer">
|
|
37
|
-
{renderCustomContent && <Box sx={{ mt: 1.5 }}>{renderCustomContent()}</Box>}
|
|
38
|
-
</Box>
|
|
39
|
-
</Box>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default BasicCard;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UserCardProps, User } from '../types';
|
|
3
|
-
import BasicCard from './basic-info';
|
|
4
|
-
|
|
5
|
-
interface DetailedCardProps extends Omit<UserCardProps, 'user'> {
|
|
6
|
-
user: User;
|
|
7
|
-
shouldShowHoverCard: boolean;
|
|
8
|
-
renderCardContent?: () => React.ReactNode | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// DetailedCard组件,根据infoType选择不同的卡片组件进行渲染
|
|
12
|
-
function DetailedCard({ ...props }: DetailedCardProps) {
|
|
13
|
-
return <BasicCard {...props} />;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default DetailedCard;
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { Box, Button, styled } from '@mui/material';
|
|
3
|
-
import { useMemoizedFn } from 'ahooks';
|
|
4
|
-
import { joinURL } from 'ufo';
|
|
5
|
-
import noop from 'lodash/noop';
|
|
6
|
-
import { Icon } from '@iconify/react';
|
|
7
|
-
|
|
8
|
-
import useFollow from '../use-follow';
|
|
9
|
-
import { User, UserCardProps } from '../types';
|
|
10
|
-
import { useLocaleContext } from '../../Locale/context';
|
|
11
|
-
import { translate } from '../../Locale/util';
|
|
12
|
-
import { isSupportFollow } from '../../Util';
|
|
13
|
-
|
|
14
|
-
type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session' | 'onFollowClick'> & {
|
|
15
|
-
user: User; // 当前卡片显示的用户,要与 session.user 区分开
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const translations = {
|
|
19
|
-
zh: {
|
|
20
|
-
chat: '聊天',
|
|
21
|
-
follow: '关注',
|
|
22
|
-
unfollow: '取消关注',
|
|
23
|
-
follow_success: '关注成功',
|
|
24
|
-
unfollow_success: '取消关注成功',
|
|
25
|
-
},
|
|
26
|
-
en: {
|
|
27
|
-
chat: 'Chat',
|
|
28
|
-
follow: 'Follow',
|
|
29
|
-
unfollow: 'Unfollow',
|
|
30
|
-
follow_success: 'Follow success',
|
|
31
|
-
unfollow_success: 'Unfollow success',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const getDiscussKitMountPoint = () => {
|
|
36
|
-
const { componentMountPoints = [] } = window.blocklet || {};
|
|
37
|
-
const component = componentMountPoints.find((c: any) => c.name === 'did-comments');
|
|
38
|
-
return component?.mountPoint;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// chat: 1. showSocialActions.chat 为 true,2. 必须安装了 discuss kit
|
|
42
|
-
function Chat({
|
|
43
|
-
user,
|
|
44
|
-
showSocialActions,
|
|
45
|
-
session,
|
|
46
|
-
}: {
|
|
47
|
-
user: SocialActionsProps['user'];
|
|
48
|
-
showSocialActions: SocialActionsProps['showSocialActions'];
|
|
49
|
-
session: SocialActionsProps['session'];
|
|
50
|
-
}) {
|
|
51
|
-
const { locale } = useLocaleContext() || { locale: 'en' };
|
|
52
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
53
|
-
return translate(translations, key, locale, 'en', data);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const isLogin = useMemo(() => {
|
|
57
|
-
return !!session?.user?.did;
|
|
58
|
-
}, [session?.user?.did]);
|
|
59
|
-
|
|
60
|
-
// 获取 discuss kit 的挂载点
|
|
61
|
-
const discussKitMountPoint = useMemo(() => getDiscussKitMountPoint(), []);
|
|
62
|
-
|
|
63
|
-
const onNavigateToChat = useMemoizedFn(() => {
|
|
64
|
-
if (!isLogin) {
|
|
65
|
-
session?.login(noop, {
|
|
66
|
-
openMode: 'redirect',
|
|
67
|
-
redirect: window.location.href,
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
window.open(joinURL(discussKitMountPoint, `/chat/dm/${user?.did}`), '_blank');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const showChat = useMemo(() => {
|
|
75
|
-
// boolean:直接使用原值;对象:取对应属性值
|
|
76
|
-
const chatEnabled = typeof showSocialActions === 'boolean' ? !!showSocialActions : showSocialActions?.chat;
|
|
77
|
-
|
|
78
|
-
return chatEnabled && !!discussKitMountPoint;
|
|
79
|
-
}, [showSocialActions, discussKitMountPoint]);
|
|
80
|
-
|
|
81
|
-
if (!showChat) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return (
|
|
85
|
-
<ButtonWrapper
|
|
86
|
-
className="user-card__social-actions-chat"
|
|
87
|
-
variant="outlined"
|
|
88
|
-
color="primary"
|
|
89
|
-
size="small"
|
|
90
|
-
onClick={onNavigateToChat}>
|
|
91
|
-
<Icon icon="tabler:message-dots" style={{ marginRight: 4 }} />
|
|
92
|
-
{t('chat')}
|
|
93
|
-
</ButtonWrapper>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// follow: 1. showSocialActions.follow 为 true
|
|
98
|
-
function Follow({
|
|
99
|
-
user,
|
|
100
|
-
showSocialActions,
|
|
101
|
-
session,
|
|
102
|
-
onFollowClick,
|
|
103
|
-
}: {
|
|
104
|
-
user: SocialActionsProps['user'];
|
|
105
|
-
showSocialActions: SocialActionsProps['showSocialActions'];
|
|
106
|
-
session: SocialActionsProps['session'];
|
|
107
|
-
onFollowClick: SocialActionsProps['onFollowClick'];
|
|
108
|
-
}) {
|
|
109
|
-
const { locale } = useLocaleContext() || { locale: 'en' };
|
|
110
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
111
|
-
return translate(translations, key, locale, 'en', data);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const isLogin = useMemo(() => {
|
|
115
|
-
return !!session?.user?.did;
|
|
116
|
-
}, [session?.user?.did]);
|
|
117
|
-
|
|
118
|
-
const showFollow = useMemo(() => {
|
|
119
|
-
// boolean:直接使用原值;对象:取对应属性值
|
|
120
|
-
return typeof showSocialActions === 'boolean' ? !!showSocialActions : showSocialActions?.follow;
|
|
121
|
-
}, [showSocialActions]);
|
|
122
|
-
|
|
123
|
-
const { followed, followUser, unfollowUser } = useFollow({
|
|
124
|
-
user,
|
|
125
|
-
t,
|
|
126
|
-
isMySelf: false,
|
|
127
|
-
visible: !!showFollow,
|
|
128
|
-
});
|
|
129
|
-
const handleFollowAction = useMemoizedFn(async (e) => {
|
|
130
|
-
if (!isLogin) {
|
|
131
|
-
session?.login(noop, {
|
|
132
|
-
openMode: 'redirect',
|
|
133
|
-
redirect: window.location.href,
|
|
134
|
-
});
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (followed) {
|
|
138
|
-
await unfollowUser(user.did);
|
|
139
|
-
} else {
|
|
140
|
-
await followUser(user.did);
|
|
141
|
-
}
|
|
142
|
-
if (onFollowClick && typeof onFollowClick === 'function') {
|
|
143
|
-
onFollowClick(user, e);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
if (!showFollow) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<ButtonWrapper
|
|
153
|
-
className="user-card__social-actions-follow"
|
|
154
|
-
variant="outlined"
|
|
155
|
-
color="primary"
|
|
156
|
-
size="small"
|
|
157
|
-
onClick={handleFollowAction}>
|
|
158
|
-
{followed ? t('unfollow') : t('follow')}
|
|
159
|
-
</ButtonWrapper>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// 社交操作组件
|
|
164
|
-
// 按钮的显示逻辑
|
|
165
|
-
// 通用逻辑: 1. user 和 session.user 不能是同一个用户, 2. 相关依赖支持,3. showSocialActions 为 true 或 为 object
|
|
166
|
-
// 其他逻辑: 1. 如果 session 中没有用户信息,点击后需要重定向到登录页面
|
|
167
|
-
function SocialActions({ showSocialActions, session, user, onFollowClick = undefined }: SocialActionsProps) {
|
|
168
|
-
const isSameUser = useMemo(() => {
|
|
169
|
-
return session?.user?.did === user?.did;
|
|
170
|
-
}, [session?.user?.did, user?.did]);
|
|
171
|
-
|
|
172
|
-
const isSupportSocialActions = useMemo(() => {
|
|
173
|
-
return isSupportFollow();
|
|
174
|
-
}, []);
|
|
175
|
-
|
|
176
|
-
// 如果 session 中没有用户信息,或者 user 和 session.user 是同一个用户,则不显示社交操作
|
|
177
|
-
if (isSameUser || !isSupportSocialActions || !showSocialActions) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<Box className="user-card__social-actions" sx={{ display: 'flex', gap: 1 }}>
|
|
183
|
-
<Chat session={session} user={user} showSocialActions={showSocialActions} />
|
|
184
|
-
<Follow onFollowClick={onFollowClick} session={session} user={user} showSocialActions={showSocialActions} />
|
|
185
|
-
</Box>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export default SocialActions;
|
|
190
|
-
|
|
191
|
-
export const ButtonWrapper = styled(Button)`
|
|
192
|
-
color: ${({ theme }) => theme.palette.text.primary};
|
|
193
|
-
font-weight: 500;
|
|
194
|
-
border-color: ${({ theme }) => theme.palette.grey[300]};
|
|
195
|
-
line-height: 1.5;
|
|
196
|
-
`;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Paper, SxProps } from '@mui/material';
|
|
3
|
-
import { UserCardProps, CardType } from '../types';
|
|
4
|
-
import { mergeSx } from '../../Util/style';
|
|
5
|
-
|
|
6
|
-
interface CardContainerProps {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
cardType?: UserCardProps['cardType'];
|
|
9
|
-
variant?: 'paper' | 'box';
|
|
10
|
-
containerRef?: React.Ref<unknown>;
|
|
11
|
-
sx?: UserCardProps['sx'];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 统一的卡片容器组件,处理常见的布局容器样式
|
|
16
|
-
*/
|
|
17
|
-
function CardContainer({
|
|
18
|
-
children,
|
|
19
|
-
cardType = CardType.Detailed,
|
|
20
|
-
variant = 'box',
|
|
21
|
-
containerRef = undefined,
|
|
22
|
-
sx = {},
|
|
23
|
-
}: CardContainerProps) {
|
|
24
|
-
const commonStyles = {
|
|
25
|
-
minWidth: 320,
|
|
26
|
-
p: 2,
|
|
27
|
-
borderRadius: 1,
|
|
28
|
-
...(cardType === CardType.Detailed
|
|
29
|
-
? {
|
|
30
|
-
border: '1px solid',
|
|
31
|
-
borderColor: 'divider',
|
|
32
|
-
}
|
|
33
|
-
: {}),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// Paper变体,用于Basic和Full类型卡片
|
|
37
|
-
if (variant === 'paper') {
|
|
38
|
-
return (
|
|
39
|
-
<Paper ref={containerRef as React.Ref<HTMLDivElement>} elevation={0} sx={commonStyles}>
|
|
40
|
-
{children}
|
|
41
|
-
</Paper>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Box变体,用于Minimal和NameOnly类型卡片
|
|
46
|
-
return (
|
|
47
|
-
<Box
|
|
48
|
-
ref={containerRef}
|
|
49
|
-
sx={mergeSx(
|
|
50
|
-
commonStyles,
|
|
51
|
-
{
|
|
52
|
-
display: 'flex',
|
|
53
|
-
alignItems: cardType === CardType.AvatarOnly ? 'center' : 'flex-start',
|
|
54
|
-
gap: 2,
|
|
55
|
-
},
|
|
56
|
-
sx ? (sx as SxProps) : null
|
|
57
|
-
)}>
|
|
58
|
-
{children}
|
|
59
|
-
</Box>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default CardContainer;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, SxProps, useTheme } from '@mui/material';
|
|
3
|
-
import { UserCardProps } from '../types';
|
|
4
|
-
import { mergeSx } from '../../Util/style';
|
|
5
|
-
|
|
6
|
-
interface DialogContainerProps {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
sx?: UserCardProps['sx'];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 统一的卡片容器组件,处理常见的布局容器样式
|
|
13
|
-
*/
|
|
14
|
-
function DialogContainer({ children, sx = {} }: DialogContainerProps) {
|
|
15
|
-
// Box变体,用于Minimal和NameOnly类型卡片
|
|
16
|
-
const theme = useTheme();
|
|
17
|
-
return (
|
|
18
|
-
<Box
|
|
19
|
-
sx={mergeSx(
|
|
20
|
-
{
|
|
21
|
-
p: 2,
|
|
22
|
-
backgroundColor: theme.palette.background.paper,
|
|
23
|
-
border: '1px solid',
|
|
24
|
-
borderColor: 'divider',
|
|
25
|
-
borderRadius: 1,
|
|
26
|
-
maxWidth: 500,
|
|
27
|
-
minWidth: 320,
|
|
28
|
-
display: 'flex',
|
|
29
|
-
},
|
|
30
|
-
sx ? (sx as SxProps) : null
|
|
31
|
-
)}>
|
|
32
|
-
{children}
|
|
33
|
-
</Box>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default DialogContainer;
|