@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
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { useCreation, useReactive } from 'ahooks';
|
|
3
|
-
import { Menu as MenuIcon, Close as CloseIcon } from '@mui/icons-material';
|
|
4
|
-
import { Button, Container, useMediaQuery, Drawer } from '@mui/material';
|
|
5
|
-
import Header from './header';
|
|
6
|
-
import { styled, useTheme } from '../Theme';
|
|
7
|
-
import { type HeaderProps } from './header';
|
|
8
|
-
|
|
9
|
-
export interface ResponsiveHeaderProps extends Omit<HeaderProps, 'children'> {
|
|
10
|
-
menu?: React.ReactNode;
|
|
11
|
-
children?: React.ReactNode | ((props: { isMobile: boolean; closeMenu: () => void }) => React.ReactNode);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* ResponsiveHeader
|
|
16
|
-
* - 窄屏下显示 burge menu
|
|
17
|
-
* - 窄屏下将 children 区域显示到 menu 中
|
|
18
|
-
*
|
|
19
|
-
* 注意: 暂时不要通过 display: none 隐藏 logo, https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
|
|
20
|
-
*/
|
|
21
|
-
function ResponsiveHeader({ prepend, children = null, ...rest }: ResponsiveHeaderProps) {
|
|
22
|
-
const theme = useTheme();
|
|
23
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
24
|
-
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
25
|
-
const _children =
|
|
26
|
-
typeof children === 'function' ? children({ isMobile, closeMenu: () => setDrawerOpen(false) }) : children;
|
|
27
|
-
|
|
28
|
-
// HACK: MUI 的 modal 只会对 body 元素设置防滚动样式,还需要对 html 元素进行设置防滚动样式
|
|
29
|
-
const htmlOverflowState = useReactive({
|
|
30
|
-
changed: false,
|
|
31
|
-
value: '',
|
|
32
|
-
priority: '',
|
|
33
|
-
});
|
|
34
|
-
useCreation(() => {
|
|
35
|
-
if (document.documentElement?.style) {
|
|
36
|
-
const clean = () => {
|
|
37
|
-
if (htmlOverflowState.changed) {
|
|
38
|
-
if (htmlOverflowState.value) {
|
|
39
|
-
document.documentElement.style.setProperty('overflow', htmlOverflowState.value, htmlOverflowState.priority);
|
|
40
|
-
} else {
|
|
41
|
-
document.documentElement.style.removeProperty('overflow');
|
|
42
|
-
}
|
|
43
|
-
htmlOverflowState.value = '';
|
|
44
|
-
htmlOverflowState.priority = '';
|
|
45
|
-
htmlOverflowState.changed = false;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
if (drawerOpen) {
|
|
49
|
-
htmlOverflowState.changed = true;
|
|
50
|
-
htmlOverflowState.value = document.documentElement.style.getPropertyValue('overflow');
|
|
51
|
-
htmlOverflowState.priority = document.documentElement.style.getPropertyPriority('overflow');
|
|
52
|
-
document.documentElement.style.setProperty('overflow', 'revert', 'important');
|
|
53
|
-
} else {
|
|
54
|
-
clean();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return clean;
|
|
58
|
-
}
|
|
59
|
-
return () => {};
|
|
60
|
-
}, [drawerOpen]);
|
|
61
|
-
|
|
62
|
-
// 如果 children 没有值, 则使用普通的 Header 组件渲染 (此时并没有什么内容需要在 menu 中显示)
|
|
63
|
-
if (!children) {
|
|
64
|
-
return <Header prepend={prepend} {...rest} />;
|
|
65
|
-
}
|
|
66
|
-
return (
|
|
67
|
-
<Root
|
|
68
|
-
prepend={
|
|
69
|
-
prepend || (
|
|
70
|
-
<Button
|
|
71
|
-
sx={{ color: theme.palette.grey[500] }}
|
|
72
|
-
className="header-menu"
|
|
73
|
-
aria-label="header menu button"
|
|
74
|
-
onClick={() => setDrawerOpen(!drawerOpen)}>
|
|
75
|
-
{drawerOpen ? <CloseIcon /> : <MenuIcon />}
|
|
76
|
-
</Button>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
{...rest}>
|
|
80
|
-
{!isMobile && _children}
|
|
81
|
-
{isMobile && (
|
|
82
|
-
<Drawer
|
|
83
|
-
open={drawerOpen}
|
|
84
|
-
onClose={() => setDrawerOpen(false)}
|
|
85
|
-
ModalProps={{
|
|
86
|
-
disablePortal: false,
|
|
87
|
-
keepMounted: true,
|
|
88
|
-
BackdropComponent: undefined,
|
|
89
|
-
}}
|
|
90
|
-
anchor="top"
|
|
91
|
-
sx={{
|
|
92
|
-
top: 64,
|
|
93
|
-
zIndex: theme.zIndex.appBar - 1,
|
|
94
|
-
}}
|
|
95
|
-
slotProps={{
|
|
96
|
-
paper: {
|
|
97
|
-
sx: {
|
|
98
|
-
top: 64,
|
|
99
|
-
bottom: 0,
|
|
100
|
-
boxShadow: 'none',
|
|
101
|
-
backgroundImage: 'none',
|
|
102
|
-
backgroundColor: theme.palette.background.paper,
|
|
103
|
-
'& .navmenu.navmenu--inline': {
|
|
104
|
-
margin: 0,
|
|
105
|
-
padding: 0,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
}}>
|
|
110
|
-
<MenuPanel>{_children}</MenuPanel>
|
|
111
|
-
</Drawer>
|
|
112
|
-
)}
|
|
113
|
-
</Root>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const Root = styled(Header)`
|
|
118
|
-
.header-menu {
|
|
119
|
-
display: none;
|
|
120
|
-
}
|
|
121
|
-
${(props) => props.theme.breakpoints.down('md')} {
|
|
122
|
-
.header-menu {
|
|
123
|
-
display: flex;
|
|
124
|
-
padding-left: 6px;
|
|
125
|
-
padding-right: 6px;
|
|
126
|
-
min-width: 0;
|
|
127
|
-
margin-left: -4px;
|
|
128
|
-
margin-right: 8px;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
132
|
-
|
|
133
|
-
const MenuPanel = styled(Container)`
|
|
134
|
-
padding-top: 8px;
|
|
135
|
-
padding-bottom: 16px;
|
|
136
|
-
.navmenu {
|
|
137
|
-
margin: 0 -16px;
|
|
138
|
-
.navmenu-root > .navmenu-item,
|
|
139
|
-
.navmenu-root > .navmenu-sub {
|
|
140
|
-
border: 0;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
|
|
145
|
-
export default ResponsiveHeader;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Icon from '.';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Deprecated/Icon',
|
|
5
|
-
|
|
6
|
-
parameters: {
|
|
7
|
-
readme: {
|
|
8
|
-
sidebar: '<!-- PROPS -->',
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function WithDifferentNames() {
|
|
14
|
-
return (
|
|
15
|
-
<div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
|
|
16
|
-
<Icon name="box" variant="solid" />
|
|
17
|
-
<Icon name="cut" />
|
|
18
|
-
<Icon name="copy" />
|
|
19
|
-
<Icon name="file" />
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
WithDifferentNames.storyName = 'with different names';
|
|
25
|
-
|
|
26
|
-
export function WithDifferentSizes() {
|
|
27
|
-
return (
|
|
28
|
-
<div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
|
|
29
|
-
<Icon name="box" variant="solid" />
|
|
30
|
-
<Icon name="box" size={50} variant="solid" />
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
WithDifferentSizes.storyName = 'with different sizes';
|
|
36
|
-
|
|
37
|
-
export function WithRounded() {
|
|
38
|
-
return (
|
|
39
|
-
<div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
|
|
40
|
-
<Icon name="box" rounded variant="solid" />
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
WithRounded.storyName = 'with rounded';
|
package/src/Icon/image.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import Img, { type ImgProps } from '../Img';
|
|
2
|
-
import { styled } from '../Theme';
|
|
3
|
-
|
|
4
|
-
export interface ImageIconProps extends Omit<ImgProps, 'size' | 'src'> {
|
|
5
|
-
name: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
color?: string;
|
|
8
|
-
alt?: string;
|
|
9
|
-
prefix?: string;
|
|
10
|
-
showBadge?: false | true;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function ImageIcon({
|
|
14
|
-
name,
|
|
15
|
-
size = 36,
|
|
16
|
-
alt = '',
|
|
17
|
-
color = '#000000',
|
|
18
|
-
prefix = '/images',
|
|
19
|
-
showBadge = false,
|
|
20
|
-
style = {},
|
|
21
|
-
...rest
|
|
22
|
-
}: ImageIconProps) {
|
|
23
|
-
const src = `${prefix}/${name}-${color.replace(/^#/, '')}.png`;
|
|
24
|
-
return (
|
|
25
|
-
<Div style={{ width: size, height: size }}>
|
|
26
|
-
<Img
|
|
27
|
-
width={size}
|
|
28
|
-
height={size}
|
|
29
|
-
alt={alt || name}
|
|
30
|
-
src={src}
|
|
31
|
-
style={Object.assign({ width: size }, style)}
|
|
32
|
-
{...rest}
|
|
33
|
-
/>
|
|
34
|
-
{showBadge && <i className="badge-point" />}
|
|
35
|
-
</Div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const Div = styled('div')`
|
|
40
|
-
position: relative;
|
|
41
|
-
.badge-point {
|
|
42
|
-
position: absolute;
|
|
43
|
-
width: 10px;
|
|
44
|
-
height: 10px;
|
|
45
|
-
border-radius: 10px;
|
|
46
|
-
background-color: #fe4e44;
|
|
47
|
-
right: -2px;
|
|
48
|
-
top: 0;
|
|
49
|
-
box-shadow:
|
|
50
|
-
0px 1px 4px rgba(0, 0, 0, 0.3),
|
|
51
|
-
0px 0px 20px rgba(0, 0, 0, 0.1);
|
|
52
|
-
}
|
|
53
|
-
`;
|
package/src/Icon/index.tsx
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Icon as IconifyIcon } from '@iconify/react';
|
|
2
|
-
|
|
3
|
-
import colors from '../Colors';
|
|
4
|
-
import { styled } from '../Theme';
|
|
5
|
-
import { withDeprecated } from '../Util/deprecate';
|
|
6
|
-
|
|
7
|
-
export interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
name: string;
|
|
9
|
-
color?: string;
|
|
10
|
-
size?: number;
|
|
11
|
-
variant?: 'light' | 'regular' | 'solid';
|
|
12
|
-
rounded?: false | true;
|
|
13
|
-
forwardedRef?: React.Ref<unknown>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line react/prop-types
|
|
17
|
-
function Icon({
|
|
18
|
-
name,
|
|
19
|
-
color = colors.grey[900],
|
|
20
|
-
size = 24,
|
|
21
|
-
variant = 'regular',
|
|
22
|
-
rounded = false,
|
|
23
|
-
className = '',
|
|
24
|
-
forwardedRef = undefined,
|
|
25
|
-
}: IconProps) {
|
|
26
|
-
const iconName = variant === 'solid' ? `fa-solid:${name}` : `fa-regular:${name}`;
|
|
27
|
-
const content = <IconifyIcon icon={iconName} color={color} width={size} height={size} className={className} />;
|
|
28
|
-
if (rounded) {
|
|
29
|
-
return (
|
|
30
|
-
<Span ref={forwardedRef as React.Ref<HTMLSpanElement>} size={size} color={color} className={className}>
|
|
31
|
-
{content}
|
|
32
|
-
</Span>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return content;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const Span = styled('span')<{ size: number; color: string }>`
|
|
39
|
-
width: ${(props) => props.size * 2}px;
|
|
40
|
-
height: ${(props) => props.size * 2}px;
|
|
41
|
-
border-radius: 50%;
|
|
42
|
-
border: 1px solid ${(props) => props.color};
|
|
43
|
-
display: flex;
|
|
44
|
-
justify-content: center;
|
|
45
|
-
align-items: center;
|
|
46
|
-
|
|
47
|
-
.fa,
|
|
48
|
-
.fas,
|
|
49
|
-
.fal,
|
|
50
|
-
.far {
|
|
51
|
-
line-height: ${(props) => props.size}px;
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
export default withDeprecated(
|
|
56
|
-
({
|
|
57
|
-
ref,
|
|
58
|
-
...props
|
|
59
|
-
}: IconProps & {
|
|
60
|
-
ref?: React.Ref<unknown>;
|
|
61
|
-
}) => <Icon {...props} forwardedRef={ref} />,
|
|
62
|
-
{ name: 'Icon', alternative: 'SVG icons' }
|
|
63
|
-
);
|
package/src/Img/Img.stories.jsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Basic from './demo/basic';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Data Display/Img',
|
|
5
|
-
parameters: {
|
|
6
|
-
docs: {
|
|
7
|
-
description: {
|
|
8
|
-
component:
|
|
9
|
-
'The Image component allows you to place an image on your page. It supports fixed size, aspect ratio, lazy loading and fallback image.',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
Basic.storyName = 'Img';
|
|
16
|
-
|
|
17
|
-
export { Basic };
|
package/src/Img/index.jsx
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useInView } from 'react-intersection-observer';
|
|
4
|
-
import WarningRoundedIcon from '@iconify-icons/material-symbols/warning-rounded';
|
|
5
|
-
import ImageRoundedIcon from '@iconify-icons/material-symbols/image-rounded';
|
|
6
|
-
import { Icon } from '@iconify/react';
|
|
7
|
-
import { Box } from '@mui/material';
|
|
8
|
-
import noop from 'lodash/noop';
|
|
9
|
-
import { mergeSx } from '../Util/style';
|
|
10
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX } from '../Util/constant';
|
|
11
|
-
|
|
12
|
-
const getProxyImageUrl = (url) => {
|
|
13
|
-
if (!url) return '';
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
// 检查是否是一个有效的URL
|
|
17
|
-
const urlObj = new URL(url);
|
|
18
|
-
|
|
19
|
-
// 检查协议是否是https
|
|
20
|
-
if (urlObj.protocol !== 'https:') {
|
|
21
|
-
console.warn('Image URL must use HTTPS protocol:', url);
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 返回代理URL
|
|
26
|
-
return `${BLOCKLET_SERVICE_PATH_PREFIX}/proxy?url=${encodeURIComponent(url)}`;
|
|
27
|
-
} catch (error) {
|
|
28
|
-
// URL construction failed, indicating invalid URL format
|
|
29
|
-
console.warn('Invalid image URL format:', url, error);
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @typedef {Object} ImgExProps
|
|
36
|
-
* @property {string} src - required
|
|
37
|
-
* @property {string} [alt]
|
|
38
|
-
* @property {string} [size='cover']
|
|
39
|
-
* @property {string} [position='top center']
|
|
40
|
-
* @property {object} [style]
|
|
41
|
-
* @property {number} [ratio=1]
|
|
42
|
-
* @property {string} [repeat='no-repeat']
|
|
43
|
-
* @property {number} [width]
|
|
44
|
-
* @property {number} [height]
|
|
45
|
-
* @property {boolean} [lazy=true]
|
|
46
|
-
* @property {string} [placeholder]
|
|
47
|
-
* @property {string} [fallback]
|
|
48
|
-
* @property {boolean} [useProxyFallback=false] - 是否使用代理 fallback, 用于解决 CSP 的问题
|
|
49
|
-
* @property {string} [className='']
|
|
50
|
-
* @property {function} [onError=() => {}]
|
|
51
|
-
* @property {function} [onSuccess=() => {}]
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @typedef {ImgExProps & import('@mui/material').BoxProps} ImgProps
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
const PREFIX = 'Img';
|
|
59
|
-
|
|
60
|
-
const classes = {
|
|
61
|
-
root: `${PREFIX}-root`,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* @param {ImgProps} props
|
|
67
|
-
* @returns {React.ReactComponentElement}
|
|
68
|
-
*/
|
|
69
|
-
function Img({
|
|
70
|
-
lazy = true,
|
|
71
|
-
width = null,
|
|
72
|
-
height = null,
|
|
73
|
-
repeat = 'no-repeat',
|
|
74
|
-
ratio = 1,
|
|
75
|
-
alt = null,
|
|
76
|
-
size = 'cover',
|
|
77
|
-
position = 'top center',
|
|
78
|
-
src,
|
|
79
|
-
useProxyFallback = false, // 是否使用代理 fallback, 用于解决 CSP 的问题
|
|
80
|
-
placeholder = null,
|
|
81
|
-
fallback = null,
|
|
82
|
-
style = null,
|
|
83
|
-
className = '',
|
|
84
|
-
onError = noop,
|
|
85
|
-
onSuccess = noop,
|
|
86
|
-
...rest
|
|
87
|
-
}) {
|
|
88
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
89
|
-
const [ref, inView] = lazy ? useInView({ threshold: 0, triggerOnce: true }) : [null, true];
|
|
90
|
-
|
|
91
|
-
const [imgState, setImgState] = useState('init');
|
|
92
|
-
const [fallbackError, setFallbackError] = useState(false);
|
|
93
|
-
|
|
94
|
-
const fallbackSrc = useMemo(() => {
|
|
95
|
-
if (fallback) {
|
|
96
|
-
return fallback;
|
|
97
|
-
}
|
|
98
|
-
if (useProxyFallback && src) {
|
|
99
|
-
return getProxyImageUrl(src);
|
|
100
|
-
}
|
|
101
|
-
return fallback;
|
|
102
|
-
}, [src, useProxyFallback, fallback]);
|
|
103
|
-
|
|
104
|
-
const actualSrc = useMemo(() => {
|
|
105
|
-
switch (imgState) {
|
|
106
|
-
case 'init':
|
|
107
|
-
case 'loading':
|
|
108
|
-
return placeholder;
|
|
109
|
-
case 'error':
|
|
110
|
-
return fallbackError ? null : fallbackSrc;
|
|
111
|
-
case 'loaded':
|
|
112
|
-
return src;
|
|
113
|
-
default:
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
}, [placeholder, fallbackSrc, src, imgState, fallbackError]);
|
|
117
|
-
|
|
118
|
-
const actualRatio = width && height ? (100 * height) / width : ratio * 100;
|
|
119
|
-
|
|
120
|
-
const mergedStyle = useMemo(
|
|
121
|
-
() => ({
|
|
122
|
-
backgroundImage: actualSrc ? `url(${actualSrc})` : '',
|
|
123
|
-
backgroundPosition: position,
|
|
124
|
-
backgroundSize: size,
|
|
125
|
-
backgroundRepeat: repeat,
|
|
126
|
-
paddingTop: `${actualRatio}%`,
|
|
127
|
-
}),
|
|
128
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
[actualSrc, position, size, imgState]
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @type {CSSStyleDeclaration}
|
|
134
|
-
*/
|
|
135
|
-
const outerStyle = {
|
|
136
|
-
...style,
|
|
137
|
-
display: 'inline-block',
|
|
138
|
-
width: width ? `${width}px` : '100%',
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
function loadImg() {
|
|
142
|
-
const img = new Image();
|
|
143
|
-
img.src = src;
|
|
144
|
-
setImgState('loading');
|
|
145
|
-
setFallbackError(false);
|
|
146
|
-
img.onload = () => {
|
|
147
|
-
setImgState('loaded');
|
|
148
|
-
onSuccess();
|
|
149
|
-
};
|
|
150
|
-
img.onerror = () => {
|
|
151
|
-
setImgState('error');
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (inView) loadImg();
|
|
157
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
158
|
-
}, [inView]);
|
|
159
|
-
|
|
160
|
-
// 处理 fallback 加载
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
if (imgState === 'error' && fallbackSrc && !fallbackError) {
|
|
163
|
-
const fallbackImg = new Image();
|
|
164
|
-
fallbackImg.src = fallbackSrc;
|
|
165
|
-
fallbackImg.onload = () => {
|
|
166
|
-
// fallback 加载成功,保持在 error 状态但显示 fallback
|
|
167
|
-
};
|
|
168
|
-
fallbackImg.onerror = (err) => {
|
|
169
|
-
// fallback 也加载失败
|
|
170
|
-
setFallbackError(true);
|
|
171
|
-
if (imgState === 'error') {
|
|
172
|
-
onError(err);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}, [imgState, fallbackSrc, fallbackError, onError]);
|
|
177
|
-
|
|
178
|
-
return (
|
|
179
|
-
// paddingTop 要求元素本身的宽度为 100%,所以只能加一个外层元素去限制宽度
|
|
180
|
-
<Box
|
|
181
|
-
data-id="2"
|
|
182
|
-
ref={ref}
|
|
183
|
-
style={outerStyle}
|
|
184
|
-
className="arcblock_ux_img-wrapper"
|
|
185
|
-
{...rest}
|
|
186
|
-
sx={mergeSx(
|
|
187
|
-
{
|
|
188
|
-
[`& .${classes.root}`]: {
|
|
189
|
-
position: 'relative',
|
|
190
|
-
overflow: 'hidden',
|
|
191
|
-
'& .image--state, & .image--img': {
|
|
192
|
-
minWidth: '100%',
|
|
193
|
-
minHeight: '100%',
|
|
194
|
-
position: 'absolute',
|
|
195
|
-
top: 0,
|
|
196
|
-
left: '50%',
|
|
197
|
-
transform: 'translateX(-50%)',
|
|
198
|
-
},
|
|
199
|
-
'& .image--state': {
|
|
200
|
-
display: 'flex',
|
|
201
|
-
flexDirection: 'column',
|
|
202
|
-
justifyContent: 'center',
|
|
203
|
-
alignItems: 'center',
|
|
204
|
-
color: '#999',
|
|
205
|
-
background: '#eee',
|
|
206
|
-
width: '100%',
|
|
207
|
-
height: '100%',
|
|
208
|
-
},
|
|
209
|
-
'& .image--img': {
|
|
210
|
-
opacity: 0,
|
|
211
|
-
visibility: 'hidden',
|
|
212
|
-
},
|
|
213
|
-
'& .image--icon': {
|
|
214
|
-
fontSize: 30,
|
|
215
|
-
maxWidth: '80%',
|
|
216
|
-
maxHeight: '80%',
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
rest.sx
|
|
221
|
-
)}>
|
|
222
|
-
<div className={`image ${className} ${classes.root}`} style={mergedStyle}>
|
|
223
|
-
{(fallbackError || (!fallbackSrc && imgState === 'error')) && (
|
|
224
|
-
<div className="image--state" title="Image load error">
|
|
225
|
-
<Icon icon={WarningRoundedIcon} className="image--icon" />
|
|
226
|
-
</div>
|
|
227
|
-
)}
|
|
228
|
-
{!placeholder && imgState === 'loading' && (
|
|
229
|
-
<div className="image--state" title="loading image">
|
|
230
|
-
<Icon icon={ImageRoundedIcon} className="image--icon" />
|
|
231
|
-
</div>
|
|
232
|
-
)}
|
|
233
|
-
{imgState === 'loaded' && <img className="image--img" src={src} alt={alt} />}
|
|
234
|
-
</div>
|
|
235
|
-
</Box>
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
Img.propTypes = {
|
|
240
|
-
src: PropTypes.string.isRequired,
|
|
241
|
-
alt: PropTypes.string,
|
|
242
|
-
size: PropTypes.string,
|
|
243
|
-
position: PropTypes.string,
|
|
244
|
-
style: PropTypes.object,
|
|
245
|
-
ratio: PropTypes.number,
|
|
246
|
-
repeat: PropTypes.string,
|
|
247
|
-
width: PropTypes.number,
|
|
248
|
-
height: PropTypes.number,
|
|
249
|
-
lazy: PropTypes.bool,
|
|
250
|
-
placeholder: PropTypes.string,
|
|
251
|
-
fallback: PropTypes.string,
|
|
252
|
-
className: PropTypes.string,
|
|
253
|
-
onError: PropTypes.func,
|
|
254
|
-
onSuccess: PropTypes.func,
|
|
255
|
-
useProxyFallback: PropTypes.bool,
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export default Img;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { default as DifferentWidth } from './demo/different-width';
|
|
2
|
-
export { default as CustomValueComponent } from './demo/custom-value-component';
|
|
3
|
-
export { default as CustomNameComponent } from './demo/custom-name-component';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Data Display/InfoRow',
|
|
7
|
-
parameters: {
|
|
8
|
-
docs: {
|
|
9
|
-
description: {
|
|
10
|
-
component: 'InfoRow is typically used to display data with key-value pairs, such as a product specification.',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
package/src/InfoRow/index.tsx
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import camelCase from 'lodash/camelCase';
|
|
2
|
-
import upperFirst from 'lodash/upperFirst';
|
|
3
|
-
import { Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import { styled } from '../Theme';
|
|
6
|
-
|
|
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
|
-
nameFormatter = (rawName) => {
|
|
19
|
-
if (typeof rawName === 'string') {
|
|
20
|
-
return rawName
|
|
21
|
-
.split(' ')
|
|
22
|
-
.map((x: any) => upperFirst(camelCase(x)))
|
|
23
|
-
.join(' ');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return rawName;
|
|
27
|
-
},
|
|
28
|
-
layout = 'horizontal',
|
|
29
|
-
children,
|
|
30
|
-
valueComponent = 'div',
|
|
31
|
-
nameWidth = 90,
|
|
32
|
-
...rest
|
|
33
|
-
}: InfoRowProps) {
|
|
34
|
-
return (
|
|
35
|
-
<Container layout={layout} width={nameWidth} {...rest}>
|
|
36
|
-
<Typography color="textSecondary" className="info-row__name">
|
|
37
|
-
{nameFormatter(name)}
|
|
38
|
-
</Typography>
|
|
39
|
-
|
|
40
|
-
{children && (
|
|
41
|
-
<Typography color="textPrimary" component={valueComponent} className="info-row__value">
|
|
42
|
-
{children}
|
|
43
|
-
</Typography>
|
|
44
|
-
)}
|
|
45
|
-
</Container>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type ContainerProps = {
|
|
50
|
-
layout: 'horizontal' | 'vertical';
|
|
51
|
-
width: number;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const Container = styled('div')<ContainerProps>`
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: ${(props) => (props.layout === 'vertical' ? 'column' : 'row')};
|
|
57
|
-
justify-content: flex-start;
|
|
58
|
-
align-items: ${(props) => (props.layout === 'vertical' ? 'flex-start' : 'center')};
|
|
59
|
-
margin-bottom: 16px;
|
|
60
|
-
|
|
61
|
-
.info-row__name {
|
|
62
|
-
width: ${(props) => props.width}px;
|
|
63
|
-
margin-right: ${(props) => (props.layout === 'vertical' ? '0' : '8px')};
|
|
64
|
-
margin-bottom: ${(props) => (props.layout === 'vertical' ? '8px' : '0')};
|
|
65
|
-
text-transform: capitalize;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.info-row__value {
|
|
69
|
-
flex: 1;
|
|
70
|
-
overflow: auto;
|
|
71
|
-
word-wrap: break-word;
|
|
72
|
-
font-weight: 500;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@media (max-width: ${(props) => props.theme.breakpoints.values.md}px) {
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
justify-content: flex-start;
|
|
78
|
-
align-items: flex-start;
|
|
79
|
-
.info-row__name {
|
|
80
|
-
font-weight: bold;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.info-row__value {
|
|
84
|
-
width: 100%;
|
|
85
|
-
font-size: 12px;
|
|
86
|
-
margin-top: 8px;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
export default InfoRow;
|