@arcblock/ux 2.6.9 → 2.7.0
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/babel.config.es.js +12 -0
- package/es/ActionButton/index.js +99 -0
- package/es/ActivityIndicator/index.js +180 -0
- package/es/Address/compact-text.js +105 -0
- package/es/Address/did-address.js +211 -0
- package/es/Address/index.js +23 -0
- package/es/Address/responsive-did-address.js +88 -0
- package/es/Alert/index.js +134 -0
- package/es/AnimationWaiter/default-animation.json +1 -0
- package/es/AnimationWaiter/index.js +239 -0
- package/es/Async/index.js +38 -0
- package/es/Avatar/did-motif.js +64 -0
- package/es/Avatar/etherscan-blockies.js +83 -0
- package/es/Avatar/index.js +176 -0
- package/es/Badge/index.js +98 -0
- package/es/Blocklet/blocklet.js +298 -0
- package/es/Blocklet/index.js +4 -0
- package/es/Blocklet/utils.js +52 -0
- package/es/BlockletNFT/index.js +412 -0
- package/es/Button/index.js +8 -0
- package/es/Button/wrap.js +140 -0
- package/es/ButtonGroup/index.js +6 -0
- package/es/CardSelector/index.js +131 -0
- package/es/Center/index.js +41 -0
- package/es/ClickToCopy/copy-button.js +72 -0
- package/es/ClickToCopy/hook.js +39 -0
- package/es/ClickToCopy/index.js +93 -0
- package/es/CodeBlock/LightBox.js +85 -0
- package/es/CodeBlock/index.js +226 -0
- package/es/Colors/index.js +2 -0
- package/es/Colors/themes/default.js +78 -0
- package/es/ContactForm/index.js +230 -0
- package/es/CookieConsent/index.js +113 -0
- package/es/CountDown/index.js +178 -0
- package/es/DID/index.js +105 -0
- package/es/Datatable/CustomToolbar.js +396 -0
- package/es/Datatable/DatatableContext.js +34 -0
- package/es/Datatable/TableSearch.js +165 -0
- package/es/Datatable/index.js +627 -0
- package/es/Datatable/utils.js +132 -0
- package/es/Dialog/confirm.js +90 -0
- package/es/Dialog/dialog.js +192 -0
- package/es/Dialog/index.js +3 -0
- package/es/DidLogo/index.js +31 -0
- package/es/DriftBot/index.js +70 -0
- package/es/Earth/countries.json +8057 -0
- package/es/Earth/index.js +521 -0
- package/es/Earth/util.js +51 -0
- package/es/Empty/index.js +64 -0
- package/es/ErrorBoundary/fallback.js +73 -0
- package/es/ErrorBoundary/index.js +1 -0
- package/es/Footer/index.js +172 -0
- package/es/Header/auto-hidden.js +35 -0
- package/es/Header/header.js +211 -0
- package/es/Header/index.js +2 -0
- package/es/Header/responsive-header.js +111 -0
- package/es/Icon/image.js +65 -0
- package/es/Icon/index.js +84 -0
- package/es/Img/index.js +217 -0
- package/es/InfoRow/index.js +87 -0
- package/es/Layout/dashboard/external-link.js +58 -0
- package/es/Layout/dashboard/full-page.js +53 -0
- package/es/Layout/dashboard/index.js +275 -0
- package/es/Layout/dashboard/sidebar.js +209 -0
- package/es/Layout/dashboard-legacy/header.js +174 -0
- package/es/Layout/dashboard-legacy/index.js +149 -0
- package/es/Layout/dashboard-legacy/sidebar.js +129 -0
- package/es/Layout/index.js +335 -0
- package/es/Locale/browser-lang.js +52 -0
- package/es/Locale/context.js +114 -0
- package/es/Locale/languages.js +60 -0
- package/es/Locale/selector.js +180 -0
- package/es/Locale/util.js +13 -0
- package/es/Logo/images/logo-dark-text.svg +3 -0
- package/es/Logo/images/logo-dark-top.svg +6 -0
- package/es/Logo/images/logo-light-text.svg +3 -0
- package/es/Logo/images/logo-light-top.svg +6 -0
- package/es/Logo/index.js +136 -0
- package/es/Metric/index.js +132 -0
- package/es/NFTDisplay/README.md +59 -0
- package/es/NFTDisplay/aspect-ratio-container.js +39 -0
- package/es/NFTDisplay/broken.js +18 -0
- package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
- package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
- package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
- package/es/NFTDisplay/index.js +323 -0
- package/es/NFTDisplay/loading.js +18 -0
- package/es/NFTDisplay/svg-embedder/img.js +45 -0
- package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
- package/es/NavMenu/index.js +2 -0
- package/es/NavMenu/nav-menu.js +286 -0
- package/es/NavMenu/style.js +176 -0
- package/es/PageScroller/index.js +286 -0
- package/es/PageScroller/story/FifthComponent.js +9 -0
- package/es/PageScroller/story/FirstComponent.js +9 -0
- package/es/PageScroller/story/FourthComponent.js +12 -0
- package/es/PageScroller/story/FullPage.js +47 -0
- package/es/PageScroller/story/PageContain.js +59 -0
- package/es/PageScroller/story/SecondComponent.js +9 -0
- package/es/PageScroller/story/ThirdComponent.js +9 -0
- package/es/PageScroller/story/index.css +115 -0
- package/es/PageScroller/usePrevValue.js +9 -0
- package/es/PricingTable/PricingPlan.js +124 -0
- package/es/PricingTable/index.js +53 -0
- package/es/QRCode/index.js +72 -0
- package/es/RelativeTime/index.js +98 -0
- package/es/Result/common.js +140 -0
- package/es/Result/demo/fixtures/result-image-404.svg +1 -0
- package/es/Result/index.js +33 -0
- package/es/Result/result.js +59 -0
- package/es/Result/translations.js +54 -0
- package/es/Screenshot/BaseScreenshot/index.js +91 -0
- package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
- package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
- package/es/Screenshot/demo/images/bg-00.jpg +0 -0
- package/es/Screenshot/demo/images/bg-01.jpg +0 -0
- package/es/Screenshot/demo/images/bg-02.jpg +0 -0
- package/es/Screenshot/demo/images/bg-03.jpg +0 -0
- package/es/Screenshot/demo/images/bg-04.jpg +0 -0
- package/es/Screenshot/demo/images/bg-05.jpg +0 -0
- package/es/Screenshot/demo/images/bg-06.jpg +0 -0
- package/es/Screenshot/demo/images/bg-07.jpg +0 -0
- package/es/Screenshot/demo/images/bg-08.jpg +0 -0
- package/es/Screenshot/demo/images/bg-09.jpg +0 -0
- package/es/Screenshot/devices.css +1366 -0
- package/es/Screenshot/index.js +299 -0
- package/es/SessionManager/federated-login-detecter.js +166 -0
- package/es/SessionManager/index.js +468 -0
- package/es/SessionManager/user-popper.js +132 -0
- package/es/Sparkline/index.js +193 -0
- package/es/Spinner/index.js +28 -0
- package/es/SplitButton/index.js +144 -0
- package/es/Switch/index.js +96 -0
- package/es/Tabs/index.js +48 -0
- package/es/Tag/index.js +108 -0
- package/es/TextCollapse/index.js +92 -0
- package/es/Theme/index.js +16 -0
- package/es/Theme/theme-provider.js +39 -0
- package/es/Theme/theme.js +133 -0
- package/es/Toast/index.js +95 -0
- package/es/Util/deprecate.js +28 -0
- package/es/Util/index.js +298 -0
- package/es/Util/wallet.js +32 -0
- package/es/Video/index.js +89 -0
- package/es/Wallet/Action.js +119 -0
- package/es/Wallet/Download.js +331 -0
- package/es/Wallet/Open.js +45 -0
- package/es/Wallet/images/abtwallet.png +0 -0
- package/es/Wallet/images/android_download.svg +23 -0
- package/es/Wallet/images/app-store.svg +20 -0
- package/es/Wallet/images/google-play.svg +70 -0
- package/es/WebWalletSWKeeper/index.js +115 -0
- package/es/WechatPrompt/images/android.png +0 -0
- package/es/WechatPrompt/images/ios.png +0 -0
- package/es/WechatPrompt/index.js +88 -0
- package/es/index.js +38 -0
- package/es/withTheme/index.js +69 -0
- package/es/withTracker/README.md +34 -0
- package/es/withTracker/error_boundary.js +34 -0
- package/es/withTracker/index.js +56 -0
- package/package.json +272 -5
@@ -0,0 +1,41 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import { styled } from '../Theme';
|
3
|
+
|
4
|
+
/**
|
5
|
+
*
|
6
|
+
* @param {string} relative 容器相对尺寸,默认相对屏幕(screen),可设置为父容器(parent)
|
7
|
+
* @returns react component element
|
8
|
+
*/
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
export default function Center({
|
11
|
+
children,
|
12
|
+
relative
|
13
|
+
}) {
|
14
|
+
let style = {};
|
15
|
+
if (relative === 'parent') {
|
16
|
+
style = {
|
17
|
+
width: '100%',
|
18
|
+
height: '100%'
|
19
|
+
};
|
20
|
+
}
|
21
|
+
return /*#__PURE__*/_jsx(Div, {
|
22
|
+
style: style,
|
23
|
+
children: children
|
24
|
+
});
|
25
|
+
}
|
26
|
+
const Div = styled('div')`
|
27
|
+
flex: 1;
|
28
|
+
width: 100vw;
|
29
|
+
height: 100vh;
|
30
|
+
|
31
|
+
display: flex;
|
32
|
+
justify-content: center;
|
33
|
+
align-items: center;
|
34
|
+
`;
|
35
|
+
Center.propTypes = {
|
36
|
+
children: PropTypes.any.isRequired,
|
37
|
+
relative: PropTypes.string
|
38
|
+
};
|
39
|
+
Center.defaultProps = {
|
40
|
+
relative: 'screen'
|
41
|
+
};
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import Tooltip from '@mui/material/Tooltip';
|
3
|
+
import { green } from '@mui/material/colors';
|
4
|
+
import CopyIcon from '@mui/icons-material/ContentCopy';
|
5
|
+
import CheckIcon from '@mui/icons-material/Check';
|
6
|
+
import useCopy from './hook';
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
export default function CopyButton({
|
9
|
+
content,
|
10
|
+
locale,
|
11
|
+
render,
|
12
|
+
showTooltip,
|
13
|
+
...rest
|
14
|
+
}) {
|
15
|
+
const {
|
16
|
+
containerRef,
|
17
|
+
copied,
|
18
|
+
copy,
|
19
|
+
texts
|
20
|
+
} = useCopy({
|
21
|
+
content,
|
22
|
+
locale
|
23
|
+
});
|
24
|
+
const iconStyle = {
|
25
|
+
fontSize: '1em'
|
26
|
+
};
|
27
|
+
const copyButton = /*#__PURE__*/_jsx("span", {
|
28
|
+
title: copied ? '' : texts.copy,
|
29
|
+
...rest,
|
30
|
+
style: {
|
31
|
+
height: '1em',
|
32
|
+
...rest.style
|
33
|
+
},
|
34
|
+
children: copied ? /*#__PURE__*/_jsx(Tooltip, {
|
35
|
+
title: texts.copied,
|
36
|
+
placement: "bottom",
|
37
|
+
arrow: true,
|
38
|
+
open: copied && showTooltip,
|
39
|
+
children: /*#__PURE__*/_jsx(CheckIcon, {
|
40
|
+
sx: {
|
41
|
+
...iconStyle,
|
42
|
+
color: green[500]
|
43
|
+
}
|
44
|
+
})
|
45
|
+
}) : /*#__PURE__*/_jsx(CopyIcon, {
|
46
|
+
onClick: copy,
|
47
|
+
sx: {
|
48
|
+
...iconStyle,
|
49
|
+
cursor: 'pointer'
|
50
|
+
}
|
51
|
+
})
|
52
|
+
});
|
53
|
+
if (render) {
|
54
|
+
return render({
|
55
|
+
copyButton,
|
56
|
+
containerRef
|
57
|
+
});
|
58
|
+
}
|
59
|
+
return copyButton;
|
60
|
+
}
|
61
|
+
CopyButton.propTypes = {
|
62
|
+
content: PropTypes.string,
|
63
|
+
locale: PropTypes.oneOf(['en', 'zh']),
|
64
|
+
render: PropTypes.func,
|
65
|
+
showTooltip: PropTypes.bool
|
66
|
+
};
|
67
|
+
CopyButton.defaultProps = {
|
68
|
+
content: '',
|
69
|
+
locale: 'en',
|
70
|
+
render: undefined,
|
71
|
+
showTooltip: true
|
72
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { useState, useEffect, useRef } from 'react';
|
2
|
+
import Copy from 'copy-to-clipboard';
|
3
|
+
const translations = {
|
4
|
+
en: {
|
5
|
+
copy: 'Click To Copy',
|
6
|
+
copied: 'Copied!'
|
7
|
+
},
|
8
|
+
zh: {
|
9
|
+
copy: '点击复制',
|
10
|
+
copied: '已复制!'
|
11
|
+
}
|
12
|
+
};
|
13
|
+
export default function useCopy({
|
14
|
+
content,
|
15
|
+
locale = 'en'
|
16
|
+
}) {
|
17
|
+
const [copied, setCopied] = useState(false);
|
18
|
+
const containerRef = useRef();
|
19
|
+
const copy = e => {
|
20
|
+
if (e) {
|
21
|
+
e.stopPropagation();
|
22
|
+
}
|
23
|
+
Copy(content || containerRef.current.textContent);
|
24
|
+
setCopied(true);
|
25
|
+
};
|
26
|
+
useEffect(() => {
|
27
|
+
let timer = null;
|
28
|
+
if (copied) {
|
29
|
+
timer = setTimeout(() => setCopied(false), 2000);
|
30
|
+
}
|
31
|
+
return () => clearTimeout(timer);
|
32
|
+
}, [copied]);
|
33
|
+
return {
|
34
|
+
containerRef,
|
35
|
+
copied,
|
36
|
+
copy,
|
37
|
+
texts: translations[locale] || translations.en
|
38
|
+
};
|
39
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import useWindowSize from 'react-use/lib/useWindowSize';
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
4
|
+
import useCopy from './hook';
|
5
|
+
import Toast, { ToastProvider } from '../Toast';
|
6
|
+
import { mergeProps } from '../Util';
|
7
|
+
import { styled } from '../Theme';
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
export { default as CopyButton } from './copy-button';
|
10
|
+
export default function ClickToCopy(props) {
|
11
|
+
const newProps = mergeProps(props, ClickToCopy, ['style']);
|
12
|
+
const {
|
13
|
+
children,
|
14
|
+
content,
|
15
|
+
tip,
|
16
|
+
copiedTip,
|
17
|
+
tipPlacement,
|
18
|
+
locale,
|
19
|
+
style,
|
20
|
+
unstyled,
|
21
|
+
...rest
|
22
|
+
} = newProps;
|
23
|
+
const {
|
24
|
+
containerRef,
|
25
|
+
copied,
|
26
|
+
copy,
|
27
|
+
texts
|
28
|
+
} = useCopy({
|
29
|
+
content,
|
30
|
+
locale
|
31
|
+
});
|
32
|
+
const _tip = tip || texts.copy;
|
33
|
+
const _copiedTip = copiedTip || texts.copied;
|
34
|
+
const {
|
35
|
+
width
|
36
|
+
} = useWindowSize();
|
37
|
+
const onCopy = e => {
|
38
|
+
copy(e);
|
39
|
+
if (width < 600) {
|
40
|
+
Toast.success(_copiedTip);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const ContainerComponent = unstyled ? UnstyledContainer : Container;
|
44
|
+
return /*#__PURE__*/_jsx(ToastProvider, {
|
45
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
46
|
+
title: copied ? _copiedTip : _tip,
|
47
|
+
...rest,
|
48
|
+
placement: tipPlacement,
|
49
|
+
disableFocusListener: true,
|
50
|
+
children: /*#__PURE__*/_jsx(ContainerComponent, {
|
51
|
+
ref: containerRef,
|
52
|
+
style: style,
|
53
|
+
onClick: onCopy,
|
54
|
+
children: children || content
|
55
|
+
})
|
56
|
+
})
|
57
|
+
});
|
58
|
+
}
|
59
|
+
ClickToCopy.propTypes = {
|
60
|
+
children: PropTypes.any.isRequired,
|
61
|
+
content: PropTypes.string,
|
62
|
+
tip: PropTypes.string,
|
63
|
+
tipPlacement: PropTypes.string,
|
64
|
+
copiedTip: PropTypes.string,
|
65
|
+
locale: PropTypes.oneOf(['en', 'zh']),
|
66
|
+
style: PropTypes.object,
|
67
|
+
// 仅提供点击复制功能, 不提供样式
|
68
|
+
unstyled: PropTypes.bool
|
69
|
+
};
|
70
|
+
ClickToCopy.defaultProps = {
|
71
|
+
content: '',
|
72
|
+
tip: '',
|
73
|
+
copiedTip: '',
|
74
|
+
tipPlacement: 'right',
|
75
|
+
locale: 'en',
|
76
|
+
style: {},
|
77
|
+
unstyled: false
|
78
|
+
};
|
79
|
+
const Container = styled('span')`
|
80
|
+
display: inline;
|
81
|
+
white-space: pre-wrap;
|
82
|
+
word-wrap: break-word;
|
83
|
+
overflow-wrap: break-word;
|
84
|
+
align-items: center;
|
85
|
+
justify-content: start;
|
86
|
+
border-radius: 15px;
|
87
|
+
padding: 1px 12px;
|
88
|
+
background-color: rgba(0, 0, 0, 0.08);
|
89
|
+
cursor: pointer;
|
90
|
+
`;
|
91
|
+
const UnstyledContainer = styled('span')`
|
92
|
+
cursor: pointer;
|
93
|
+
`;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
// highlight.js/styles/atom-one-light.css
|
2
|
+
import styled from '@emotion/styled';
|
3
|
+
const LightBox = styled('div')`
|
4
|
+
display: block;
|
5
|
+
pre code.hljs {
|
6
|
+
display: block;
|
7
|
+
overflow-x: auto;
|
8
|
+
padding: 1em;
|
9
|
+
}
|
10
|
+
code.hljs {
|
11
|
+
padding: 3px 5px;
|
12
|
+
}
|
13
|
+
.hljs {
|
14
|
+
color: #383a42;
|
15
|
+
background: #fafafa;
|
16
|
+
}
|
17
|
+
.hljs-comment,
|
18
|
+
.hljs-quote {
|
19
|
+
color: #a0a1a7;
|
20
|
+
font-style: italic;
|
21
|
+
}
|
22
|
+
.hljs-doctag,
|
23
|
+
.hljs-formula,
|
24
|
+
.hljs-keyword {
|
25
|
+
color: #a626a4;
|
26
|
+
}
|
27
|
+
.hljs-deletion,
|
28
|
+
.hljs-name,
|
29
|
+
.hljs-section,
|
30
|
+
.hljs-selector-tag,
|
31
|
+
.hljs-subst {
|
32
|
+
color: #e45649;
|
33
|
+
}
|
34
|
+
.hljs-literal {
|
35
|
+
color: #0184bb;
|
36
|
+
}
|
37
|
+
.hljs-addition,
|
38
|
+
.hljs-attribute,
|
39
|
+
.hljs-meta .hljs-string,
|
40
|
+
.hljs-regexp,
|
41
|
+
.hljs-string {
|
42
|
+
color: #50a14f;
|
43
|
+
}
|
44
|
+
.hljs-attr,
|
45
|
+
.hljs-number,
|
46
|
+
.hljs-selector-attr,
|
47
|
+
.hljs-selector-class,
|
48
|
+
.hljs-selector-pseudo,
|
49
|
+
.hljs-template-variable,
|
50
|
+
.hljs-type,
|
51
|
+
.hljs-variable {
|
52
|
+
color: #986801;
|
53
|
+
}
|
54
|
+
.hljs-bullet,
|
55
|
+
.hljs-link,
|
56
|
+
.hljs-meta,
|
57
|
+
.hljs-selector-id,
|
58
|
+
.hljs-symbol,
|
59
|
+
.hljs-title {
|
60
|
+
color: #4078f2;
|
61
|
+
}
|
62
|
+
.hljs-built_in,
|
63
|
+
.hljs-class .hljs-title,
|
64
|
+
.hljs-title.class_ {
|
65
|
+
color: #c18401;
|
66
|
+
}
|
67
|
+
.hljs-emphasis {
|
68
|
+
font-style: italic;
|
69
|
+
}
|
70
|
+
.hljs-strong {
|
71
|
+
font-weight: 700;
|
72
|
+
}
|
73
|
+
.hljs-link {
|
74
|
+
text-decoration: underline;
|
75
|
+
}
|
76
|
+
|
77
|
+
pre {
|
78
|
+
.copy-button {
|
79
|
+
> .default-text {
|
80
|
+
color: #222;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
`;
|
85
|
+
export default LightBox;
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/* eslint-disable react/no-danger */
|
2
|
+
import { useState } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import Copy from 'copy-to-clipboard';
|
5
|
+
import useMountedState from 'react-use/lib/useMountedState';
|
6
|
+
import hljs from 'highlight.js/lib/core';
|
7
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
8
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
9
|
+
import json from 'highlight.js/lib/languages/json';
|
10
|
+
import elixir from 'highlight.js/lib/languages/elixir';
|
11
|
+
import java from 'highlight.js/lib/languages/java';
|
12
|
+
import swift from 'highlight.js/lib/languages/swift';
|
13
|
+
import objectivec from 'highlight.js/lib/languages/objectivec';
|
14
|
+
import kotlin from 'highlight.js/lib/languages/kotlin';
|
15
|
+
import protobuf from 'highlight.js/lib/languages/protobuf';
|
16
|
+
import python from 'highlight.js/lib/languages/python';
|
17
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
18
|
+
import shell from 'highlight.js/lib/languages/shell';
|
19
|
+
import diff from 'highlight.js/lib/languages/diff';
|
20
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
21
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
22
|
+
import 'highlight.js/styles/atom-one-dark.css';
|
23
|
+
import CopyIcon from '@mui/icons-material/FileCopy';
|
24
|
+
import CheckIcon from '@mui/icons-material/Check';
|
25
|
+
import colors from '../Colors';
|
26
|
+
import { styled } from '../Theme';
|
27
|
+
import LightBox from './LightBox';
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
29
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
30
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
31
|
+
hljs.registerLanguage('javascript', javascript);
|
32
|
+
hljs.registerLanguage('js', javascript);
|
33
|
+
hljs.registerLanguage('jsx', javascript);
|
34
|
+
hljs.registerLanguage('typescript', typescript);
|
35
|
+
hljs.registerLanguage('ts', typescript);
|
36
|
+
hljs.registerLanguage('tsx', typescript);
|
37
|
+
hljs.registerLanguage('json', json);
|
38
|
+
hljs.registerLanguage('elixir', elixir);
|
39
|
+
hljs.registerLanguage('java', java);
|
40
|
+
hljs.registerLanguage('kotlin', kotlin);
|
41
|
+
hljs.registerLanguage('kt', kotlin);
|
42
|
+
hljs.registerLanguage('protobuf', protobuf);
|
43
|
+
hljs.registerLanguage('protobuffer', protobuf);
|
44
|
+
hljs.registerLanguage('python', python);
|
45
|
+
hljs.registerLanguage('py', python);
|
46
|
+
hljs.registerLanguage('yaml', yaml);
|
47
|
+
hljs.registerLanguage('yml', yaml);
|
48
|
+
hljs.registerLanguage('shell', shell);
|
49
|
+
hljs.registerLanguage('sh', shell);
|
50
|
+
hljs.registerLanguage('plaintext', plaintext);
|
51
|
+
hljs.registerLanguage('text', plaintext);
|
52
|
+
hljs.registerLanguage('patch', diff);
|
53
|
+
hljs.registerLanguage('diff', diff);
|
54
|
+
hljs.registerLanguage('swift', swift);
|
55
|
+
hljs.registerLanguage('objectivec', objectivec);
|
56
|
+
hljs.registerLanguage('oc', objectivec);
|
57
|
+
hljs.registerLanguage('markdown', markdown);
|
58
|
+
export default function CodeBlock({
|
59
|
+
code,
|
60
|
+
language,
|
61
|
+
children,
|
62
|
+
dark,
|
63
|
+
...rest
|
64
|
+
}) {
|
65
|
+
const [copied, setCopied] = useState(false);
|
66
|
+
const isMounted = useMountedState();
|
67
|
+
const source = code || children;
|
68
|
+
const onCopy = () => {
|
69
|
+
if (copied) {
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
Copy(source);
|
73
|
+
setCopied(true);
|
74
|
+
// 恢复 copied 状态
|
75
|
+
setTimeout(() => {
|
76
|
+
if (isMounted()) {
|
77
|
+
setCopied(false);
|
78
|
+
}
|
79
|
+
}, 1500);
|
80
|
+
};
|
81
|
+
const originEl = /*#__PURE__*/_jsxs(Pre, {
|
82
|
+
...rest,
|
83
|
+
children: [/*#__PURE__*/_jsx("span", {
|
84
|
+
className: "codeblock__inner",
|
85
|
+
children: /*#__PURE__*/_jsx("code", {
|
86
|
+
className: `hljs ${language}`,
|
87
|
+
dangerouslySetInnerHTML: {
|
88
|
+
__html: hljs.highlightAuto(source, [language]).value
|
89
|
+
}
|
90
|
+
})
|
91
|
+
}), /*#__PURE__*/_jsxs("div", {
|
92
|
+
className: "copy-button",
|
93
|
+
onClick: onCopy,
|
94
|
+
children: [/*#__PURE__*/_jsx("span", {
|
95
|
+
className: "default-text",
|
96
|
+
children: language
|
97
|
+
}), /*#__PURE__*/_jsx("span", {
|
98
|
+
className: "hover-text",
|
99
|
+
children: !copied ? /*#__PURE__*/_jsxs(_Fragment, {
|
100
|
+
children: [/*#__PURE__*/_jsx(CopyIcon, {
|
101
|
+
className: "copy-icon"
|
102
|
+
}), /*#__PURE__*/_jsx("span", {
|
103
|
+
className: "button-lang-text",
|
104
|
+
children: "copy"
|
105
|
+
})]
|
106
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
107
|
+
children: [/*#__PURE__*/_jsx(CheckIcon, {
|
108
|
+
className: "copy-icon"
|
109
|
+
}), /*#__PURE__*/_jsx("span", {
|
110
|
+
className: "button-lang-text",
|
111
|
+
children: "copied"
|
112
|
+
})]
|
113
|
+
})
|
114
|
+
})]
|
115
|
+
})]
|
116
|
+
});
|
117
|
+
if (!dark) {
|
118
|
+
return /*#__PURE__*/_jsx(LightBox, {
|
119
|
+
children: originEl
|
120
|
+
});
|
121
|
+
}
|
122
|
+
return originEl;
|
123
|
+
}
|
124
|
+
CodeBlock.propTypes = {
|
125
|
+
code: PropTypes.string,
|
126
|
+
language: PropTypes.string,
|
127
|
+
children: PropTypes.any,
|
128
|
+
dark: PropTypes.bool
|
129
|
+
};
|
130
|
+
CodeBlock.defaultProps = {
|
131
|
+
code: '',
|
132
|
+
language: 'text',
|
133
|
+
children: null,
|
134
|
+
dark: true
|
135
|
+
};
|
136
|
+
const fontFamily = 'source-code-pro, Menlo, Monaco, Consolas, Courier New, monospace !important';
|
137
|
+
const Pre = styled('pre')`
|
138
|
+
font-family: ${fontFamily};
|
139
|
+
display: block;
|
140
|
+
font-size: 14px;
|
141
|
+
line-height: 1.42857143;
|
142
|
+
margin: 0 0 32px;
|
143
|
+
word-break: break-word;
|
144
|
+
word-wrap: break-word;
|
145
|
+
text-align: left;
|
146
|
+
border-radius: 5px;
|
147
|
+
border: 1px solid #dedede;
|
148
|
+
background: #222;
|
149
|
+
color: ${colors.common.white};
|
150
|
+
position: relative;
|
151
|
+
|
152
|
+
.codeblock__inner {
|
153
|
+
display: block;
|
154
|
+
width: 100%;
|
155
|
+
max-height: 46.25rem;
|
156
|
+
overflow: scroll;
|
157
|
+
}
|
158
|
+
|
159
|
+
.copy-button {
|
160
|
+
display: flex;
|
161
|
+
justify-content: center;
|
162
|
+
align-items: center;
|
163
|
+
position: absolute;
|
164
|
+
top: 8px;
|
165
|
+
right: 24px;
|
166
|
+
padding: 4px;
|
167
|
+
min-width: 72px;
|
168
|
+
height: 24px;
|
169
|
+
border-radius: 4px;
|
170
|
+
background: transparent;
|
171
|
+
cursor: pointer;
|
172
|
+
transition: all ease 0.2s;
|
173
|
+
|
174
|
+
.copy-icon {
|
175
|
+
font-size: 16px;
|
176
|
+
color: ${colors.common.white};
|
177
|
+
}
|
178
|
+
|
179
|
+
.hover-text {
|
180
|
+
display: none;
|
181
|
+
}
|
182
|
+
.default-text {
|
183
|
+
font-size: 12px;
|
184
|
+
color: ${colors.common.white};
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
&:hover {
|
189
|
+
.copy-button {
|
190
|
+
display: flex;
|
191
|
+
background: ${colors.primary.main};
|
192
|
+
|
193
|
+
.hover-text {
|
194
|
+
display: flex;
|
195
|
+
justify-content: center;
|
196
|
+
align-items: center;
|
197
|
+
color: ${colors.common.white};
|
198
|
+
}
|
199
|
+
.default-text {
|
200
|
+
display: none;
|
201
|
+
font-size: 12px;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
.button-lang-text {
|
207
|
+
margin-left: 4px;
|
208
|
+
font-size: 12px;
|
209
|
+
color: ${colors.common.white};
|
210
|
+
}
|
211
|
+
|
212
|
+
code {
|
213
|
+
counter-reset: line;
|
214
|
+
counter-increment: line;
|
215
|
+
padding: 16px;
|
216
|
+
font-family: ${fontFamily};
|
217
|
+
color: ${colors.common.white};
|
218
|
+
* {
|
219
|
+
font-family: ${fontFamily};
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
.hljs * {
|
224
|
+
white-space: normal; // autowrap
|
225
|
+
}
|
226
|
+
`;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* 默认 colors, ABT 系列
|
3
|
+
*
|
4
|
+
* - colors object 结构是在 mui theme#palette object 基础上调整后的结构
|
5
|
+
* - 色值在 mui default theme 基础上将 figma 中常用的 colors 进行覆盖
|
6
|
+
* - 扩展一些常用色值 (如 DID 系列)
|
7
|
+
* - figma: https://www.figma.com/file/1qHyMF137EXOQpSFVByszG/UX-Library?node-id=295%3A1518
|
8
|
+
*/
|
9
|
+
const colors = {
|
10
|
+
common: {
|
11
|
+
black: '#000',
|
12
|
+
white: '#fff'
|
13
|
+
},
|
14
|
+
primary: {
|
15
|
+
main: '#3773F2',
|
16
|
+
contrastText: '#fff'
|
17
|
+
},
|
18
|
+
// override
|
19
|
+
secondary: {
|
20
|
+
main: '#16CED1',
|
21
|
+
contrastText: '#fff'
|
22
|
+
},
|
23
|
+
// override
|
24
|
+
error: {
|
25
|
+
main: '#F16E6E',
|
26
|
+
contrastText: '#fff'
|
27
|
+
},
|
28
|
+
// override
|
29
|
+
warning: {
|
30
|
+
main: '#DE9E37',
|
31
|
+
contrastText: '#fff'
|
32
|
+
},
|
33
|
+
// override
|
34
|
+
info: {
|
35
|
+
main: '#0775F8',
|
36
|
+
contrastText: '#fff'
|
37
|
+
},
|
38
|
+
// override
|
39
|
+
success: {
|
40
|
+
main: '#34BE74',
|
41
|
+
contrastText: '#fff'
|
42
|
+
},
|
43
|
+
// override
|
44
|
+
grey: {
|
45
|
+
50: '#fafafa',
|
46
|
+
100: '#f5f5f5',
|
47
|
+
200: '#eeeeee',
|
48
|
+
300: '#e0e0e0',
|
49
|
+
400: '#bdbdbd',
|
50
|
+
500: '#9e9e9e',
|
51
|
+
600: '#757575',
|
52
|
+
700: '#616161',
|
53
|
+
800: '#424242',
|
54
|
+
900: '#212121',
|
55
|
+
A100: '#d5d5d5',
|
56
|
+
A200: '#aaaaaa',
|
57
|
+
A400: '#303030',
|
58
|
+
A700: '#616161'
|
59
|
+
},
|
60
|
+
text: {
|
61
|
+
primary: 'rgba(0, 0, 0, 0.87)',
|
62
|
+
secondary: 'rgba(0, 0, 0, 0.54)',
|
63
|
+
disabled: 'rgba(0, 0, 0, 0.38)',
|
64
|
+
hint: 'rgba(0, 0, 0, 0.38)'
|
65
|
+
},
|
66
|
+
divider: 'rgba(0, 0, 0, 0.12)',
|
67
|
+
background: {
|
68
|
+
default: '#fff'
|
69
|
+
},
|
70
|
+
// 扩展色值, 适用于 did 相关的组件, 如果某些产品整体风格是 did 系列, 可以扩展出一个 did 系列的 theme
|
71
|
+
did: {
|
72
|
+
primary: '#4598FA',
|
73
|
+
secondary: '#49C3AD'
|
74
|
+
}
|
75
|
+
// TODO: 等设计规范稳定后, 考虑扩展 trade 相关的常用颜色 (send/receive/exchange/transfer)
|
76
|
+
};
|
77
|
+
|
78
|
+
export default colors;
|