@arcblock/ux 2.6.9 → 2.7.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/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,230 @@
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
4
|
+
/* eslint-disable react/no-unused-prop-types */
|
5
|
+
/* eslint-disable react/static-property-placement */
|
6
|
+
import React from 'react';
|
7
|
+
import PropTypes from 'prop-types';
|
8
|
+
import axios from 'axios';
|
9
|
+
import Typography from '@mui/material/Typography';
|
10
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
11
|
+
import { mergeProps } from '../Util';
|
12
|
+
import { warn as deprecatedWarn } from '../Util/deprecate';
|
13
|
+
import Button from '../Button';
|
14
|
+
import { styled } from '../Theme';
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
17
|
+
export function submitContactForm({
|
18
|
+
formId,
|
19
|
+
portalId
|
20
|
+
}, fields, context) {
|
21
|
+
const url = `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formId}`;
|
22
|
+
return axios.post(url, {
|
23
|
+
submittedAt: Date.now(),
|
24
|
+
fields: Object.keys(fields).map(x => ({
|
25
|
+
name: x.replace(/\s+/, '').toLowerCase(),
|
26
|
+
value: fields[x]
|
27
|
+
})),
|
28
|
+
context,
|
29
|
+
skipValidation: false
|
30
|
+
}).then(res => res.data.inlineMessage).catch(res => res.data ? res.data.message : 'Form Submit Failed');
|
31
|
+
}
|
32
|
+
export default class ContactForm extends React.Component {
|
33
|
+
constructor(props) {
|
34
|
+
super(props);
|
35
|
+
_defineProperty(this, "onSubmit", async e => {
|
36
|
+
e.preventDefault();
|
37
|
+
this.setState({
|
38
|
+
loading: true
|
39
|
+
});
|
40
|
+
try {
|
41
|
+
const message = await submitContactForm({
|
42
|
+
formId: this.props.formId,
|
43
|
+
portalId: this.props.portalId
|
44
|
+
}, this.fields.reduce((obj, x) => {
|
45
|
+
obj[x] = this.state[x];
|
46
|
+
return obj;
|
47
|
+
}, {}), {
|
48
|
+
pageUri: window.location.href,
|
49
|
+
pageName: window.location.title
|
50
|
+
});
|
51
|
+
this.setState({
|
52
|
+
loading: false,
|
53
|
+
successMessage: message || this.props.successMessage
|
54
|
+
});
|
55
|
+
} catch (err) {
|
56
|
+
this.setState({
|
57
|
+
loading: false,
|
58
|
+
errorMessage: err ? err.message : 'Form submit failed'
|
59
|
+
});
|
60
|
+
}
|
61
|
+
});
|
62
|
+
_defineProperty(this, "getInputHandler", (name, state = {}) => e => {
|
63
|
+
this.setState(Object.assign(state, {
|
64
|
+
[name]: e.target.value
|
65
|
+
}));
|
66
|
+
});
|
67
|
+
if (typeof props.fields === 'string') {
|
68
|
+
this.fields = props.fields.split(',').map(x => x.trim());
|
69
|
+
} else {
|
70
|
+
this.fields = props.fields;
|
71
|
+
}
|
72
|
+
this.state = {
|
73
|
+
loading: false,
|
74
|
+
errorMessage: '',
|
75
|
+
successMessage: ''
|
76
|
+
};
|
77
|
+
this.fields.forEach(x => {
|
78
|
+
this.state[x] = '';
|
79
|
+
});
|
80
|
+
deprecatedWarn('ContactForm');
|
81
|
+
}
|
82
|
+
deriveProps() {
|
83
|
+
const newProps = mergeProps(this.props, ContactForm);
|
84
|
+
if (typeof newProps.title === 'undefined') {
|
85
|
+
newProps.title = 'Signup for our news letter';
|
86
|
+
}
|
87
|
+
if (!newProps.button) {
|
88
|
+
newProps.button = 'Subscribe';
|
89
|
+
}
|
90
|
+
return newProps;
|
91
|
+
}
|
92
|
+
render() {
|
93
|
+
const {
|
94
|
+
className,
|
95
|
+
style,
|
96
|
+
title,
|
97
|
+
button,
|
98
|
+
layout
|
99
|
+
} = this.deriveProps();
|
100
|
+
const {
|
101
|
+
loading,
|
102
|
+
errorMessage,
|
103
|
+
successMessage
|
104
|
+
} = this.state;
|
105
|
+
return /*#__PURE__*/_jsxs(Form, {
|
106
|
+
onSubmit: this.onSubmit,
|
107
|
+
className: className,
|
108
|
+
style: style,
|
109
|
+
layout: layout,
|
110
|
+
fieldCount: this.fields.length,
|
111
|
+
name: "subscribe",
|
112
|
+
children: [!!title && /*#__PURE__*/_jsx(Typography, {
|
113
|
+
component: "p",
|
114
|
+
className: "title",
|
115
|
+
children: title
|
116
|
+
}), /*#__PURE__*/_jsxs("div", {
|
117
|
+
className: "form-controls",
|
118
|
+
children: [this.fields.map(x => /*#__PURE__*/_jsx("input", {
|
119
|
+
required: true,
|
120
|
+
type: "text",
|
121
|
+
value: this.state[x],
|
122
|
+
onChange: this.getInputHandler(x),
|
123
|
+
className: "input",
|
124
|
+
placeholder: x
|
125
|
+
}, x)), /*#__PURE__*/_jsx(Button, {
|
126
|
+
variant: "outlined",
|
127
|
+
type: "submit",
|
128
|
+
color: "inherit",
|
129
|
+
size: "large",
|
130
|
+
disabled: loading,
|
131
|
+
className: "subscribe-btn-empty",
|
132
|
+
children: loading ? /*#__PURE__*/_jsx(CircularProgress, {
|
133
|
+
size: 28
|
134
|
+
}) : button
|
135
|
+
})]
|
136
|
+
}), !!errorMessage && /*#__PURE__*/_jsx(Typography, {
|
137
|
+
component: "p",
|
138
|
+
variant: "body1",
|
139
|
+
className: "error",
|
140
|
+
color: "secondary",
|
141
|
+
dangerouslySetInnerHTML: {
|
142
|
+
__html: errorMessage
|
143
|
+
}
|
144
|
+
}), !!successMessage && /*#__PURE__*/_jsx(Typography, {
|
145
|
+
component: "p",
|
146
|
+
variant: "body1",
|
147
|
+
className: "success",
|
148
|
+
color: "primary",
|
149
|
+
dangerouslySetInnerHTML: {
|
150
|
+
__html: successMessage
|
151
|
+
}
|
152
|
+
})]
|
153
|
+
});
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
// prettier-ignore
|
158
|
+
_defineProperty(ContactForm, "propTypes", {
|
159
|
+
style: PropTypes.object,
|
160
|
+
className: PropTypes.string,
|
161
|
+
portalId: PropTypes.string,
|
162
|
+
formId: PropTypes.string,
|
163
|
+
title: PropTypes.string,
|
164
|
+
button: PropTypes.string,
|
165
|
+
successMessage: PropTypes.string,
|
166
|
+
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
167
|
+
fields: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
|
168
|
+
});
|
169
|
+
_defineProperty(ContactForm, "defaultProps", {
|
170
|
+
style: {},
|
171
|
+
className: '',
|
172
|
+
portalId: '4796488',
|
173
|
+
formId: '929a510f-34f4-4251-98b3-34175200aebd',
|
174
|
+
title: undefined,
|
175
|
+
button: '',
|
176
|
+
layout: 'vertical',
|
177
|
+
successMessage: 'Form Submit Success',
|
178
|
+
fields: ['Email', 'First Name', 'Last Name']
|
179
|
+
});
|
180
|
+
const getInputWidth = props => props.layout === 'vertical' ? '100%' : `${Math.max(95 / (props.fieldCount + 1), 20)}%`;
|
181
|
+
const Form = styled('form')`
|
182
|
+
display: flex;
|
183
|
+
flex-direction: column;
|
184
|
+
justify-content: center;
|
185
|
+
align-items: center;
|
186
|
+
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
187
|
+
width: 100% !important;
|
188
|
+
}
|
189
|
+
max-width: 800px;
|
190
|
+
margin: 0px auto;
|
191
|
+
|
192
|
+
.title {
|
193
|
+
font-size: 30px;
|
194
|
+
text-align: center;
|
195
|
+
color: ${props => props.theme.typography.color.main};
|
196
|
+
}
|
197
|
+
|
198
|
+
.form-controls {
|
199
|
+
width: 100%;
|
200
|
+
flex-direction: ${props => props.layout === 'vertical' ? 'column' : 'row'};
|
201
|
+
justify-content: space-between;
|
202
|
+
align-items: center;
|
203
|
+
|
204
|
+
.input {
|
205
|
+
width: ${props => getInputWidth(props)};
|
206
|
+
height: 50px;
|
207
|
+
border: none;
|
208
|
+
border-bottom: 1px solid ${props => props.theme.typography.color.main};
|
209
|
+
font-size: 16px;
|
210
|
+
letter-spacing: 1.8px;
|
211
|
+
outline: none;
|
212
|
+
margin: ${props => props.layout === 'vertical' ? '12px 0' : '12px'};
|
213
|
+
background: transparent;
|
214
|
+
|
215
|
+
&:first-of-type {
|
216
|
+
margin-top: 40px;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
.subscribe-btn-empty {
|
221
|
+
margin-top: ${props => props.layout === 'vertical' ? '40px' : '0'};
|
222
|
+
width: ${props => props.layout === 'vertical' ? '100%' : 'auto'};
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
.error,
|
227
|
+
.success {
|
228
|
+
margin-top: 20px;
|
229
|
+
}
|
230
|
+
`;
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import Button from '@mui/material/Button';
|
3
|
+
import CookieConsent, { resetCookieConsentValue } from 'react-cookie-consent';
|
4
|
+
import { styled } from '../Theme';
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
+
export { resetCookieConsentValue };
|
7
|
+
const translations = {
|
8
|
+
en: {
|
9
|
+
content: 'We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.',
|
10
|
+
agree: 'I Understand'
|
11
|
+
},
|
12
|
+
zh: {
|
13
|
+
content: '我们使用 cookies 和其他跟踪技术来改善您在我们网站上的浏览体验,向您展示个性化的内容,分析我们的网站流量,并了解我们的访问者来自哪里。',
|
14
|
+
agree: '我知道了'
|
15
|
+
}
|
16
|
+
};
|
17
|
+
function inIframe() {
|
18
|
+
try {
|
19
|
+
return window.self !== window.top;
|
20
|
+
} catch (e) {
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
function AcceptButton(props) {
|
25
|
+
return /*#__PURE__*/_jsx(Button, {
|
26
|
+
variant: "contained",
|
27
|
+
...props
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* DefaultCookieConsent, 对 react-cookie-consent package 封装, 以便 arcblock 内部产品可以快速使用
|
33
|
+
* - 默认内容
|
34
|
+
* - 默认配置/样式
|
35
|
+
*/
|
36
|
+
export default function DefaultCookieConsent({
|
37
|
+
children,
|
38
|
+
locale,
|
39
|
+
style,
|
40
|
+
displayInIframe,
|
41
|
+
...rest
|
42
|
+
}) {
|
43
|
+
if (!displayInIframe && inIframe()) {
|
44
|
+
return null;
|
45
|
+
}
|
46
|
+
if (locale && !translations[locale]) {
|
47
|
+
// eslint-disable-next-line no-param-reassign
|
48
|
+
locale = 'en';
|
49
|
+
}
|
50
|
+
return /*#__PURE__*/_jsx(Wrapper, {
|
51
|
+
style: style,
|
52
|
+
children: /*#__PURE__*/_jsx(CookieConsent, {
|
53
|
+
disableStyles: true,
|
54
|
+
disableButtonStyles: true,
|
55
|
+
ButtonComponent: AcceptButton,
|
56
|
+
buttonText: translations[locale].agree,
|
57
|
+
buttonStyle: {
|
58
|
+
marginTop: 16,
|
59
|
+
padding: '6px 16px'
|
60
|
+
},
|
61
|
+
...rest,
|
62
|
+
children: children || /*#__PURE__*/_jsx("p", {
|
63
|
+
style: {
|
64
|
+
margin: 0
|
65
|
+
},
|
66
|
+
children: translations[locale].content
|
67
|
+
})
|
68
|
+
})
|
69
|
+
});
|
70
|
+
}
|
71
|
+
DefaultCookieConsent.propTypes = {
|
72
|
+
children: PropTypes.any,
|
73
|
+
style: PropTypes.object,
|
74
|
+
locale: PropTypes.string,
|
75
|
+
displayInIframe: PropTypes.bool
|
76
|
+
};
|
77
|
+
DefaultCookieConsent.defaultProps = {
|
78
|
+
children: null,
|
79
|
+
style: {},
|
80
|
+
locale: 'en',
|
81
|
+
displayInIframe: false
|
82
|
+
};
|
83
|
+
const Wrapper = styled('div')`
|
84
|
+
box-sizing: border-box;
|
85
|
+
position: fixed;
|
86
|
+
right: 20px;
|
87
|
+
bottom: 20px;
|
88
|
+
z-index: 999;
|
89
|
+
max-width: 440px;
|
90
|
+
padding: 16px 24px;
|
91
|
+
font-size: 16px;
|
92
|
+
color: #666;
|
93
|
+
background: #fff;
|
94
|
+
border-radius: 6px;
|
95
|
+
box-shadow: 0 0 18px rgba(0, 0, 0, 0.2);
|
96
|
+
&:empty {
|
97
|
+
display: none;
|
98
|
+
}
|
99
|
+
button {
|
100
|
+
min-width: 200px;
|
101
|
+
}
|
102
|
+
|
103
|
+
@media screen and (max-width: 480px) {
|
104
|
+
left: 16px;
|
105
|
+
right: 16px;
|
106
|
+
bottom: 16px;
|
107
|
+
width: auto;
|
108
|
+
button {
|
109
|
+
display: block;
|
110
|
+
width: 100%;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
`;
|
@@ -0,0 +1,178 @@
|
|
1
|
+
import { Component } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { getColor, mergeProps } from '../Util';
|
4
|
+
import { styled } from '../Theme';
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
7
|
+
const SECONDS_OF_MINUTE = 60;
|
8
|
+
const SECONDS_OF_HOUR = 60 * SECONDS_OF_MINUTE;
|
9
|
+
const SECONDS_OF_DAY = 24 * SECONDS_OF_HOUR;
|
10
|
+
function getRemaining(endTime) {
|
11
|
+
const now = new Date().getTime();
|
12
|
+
const diff = Math.round((endTime - now) / 1000);
|
13
|
+
const days = Math.floor(diff / SECONDS_OF_DAY);
|
14
|
+
const hours = Math.floor(diff % SECONDS_OF_DAY / SECONDS_OF_HOUR);
|
15
|
+
const minutes = Math.floor(diff % SECONDS_OF_DAY % SECONDS_OF_HOUR / SECONDS_OF_MINUTE);
|
16
|
+
const seconds = Math.round(diff % SECONDS_OF_DAY % SECONDS_OF_HOUR % SECONDS_OF_MINUTE);
|
17
|
+
return {
|
18
|
+
days,
|
19
|
+
hours,
|
20
|
+
minutes,
|
21
|
+
seconds,
|
22
|
+
done: diff <= 0
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
// eslint-disable-next-line react/prop-types
|
27
|
+
function FixWidthNumber({
|
28
|
+
number,
|
29
|
+
label,
|
30
|
+
length = 2
|
31
|
+
}) {
|
32
|
+
let str = number.toString();
|
33
|
+
while (str.length < length) {
|
34
|
+
str = `0${str}`;
|
35
|
+
}
|
36
|
+
const numbers = str.split('');
|
37
|
+
return /*#__PURE__*/_jsxs("span", {
|
38
|
+
className: "num-group",
|
39
|
+
children: [/*#__PURE__*/_jsx("span", {
|
40
|
+
className: "num-items",
|
41
|
+
children: numbers.map((x, i) =>
|
42
|
+
/*#__PURE__*/
|
43
|
+
// eslint-disable-next-line react/no-array-index-key
|
44
|
+
_jsx("strong", {
|
45
|
+
className: "num-item",
|
46
|
+
children: x
|
47
|
+
}, `num-${i}`))
|
48
|
+
}), /*#__PURE__*/_jsx("span", {
|
49
|
+
className: "num-label",
|
50
|
+
children: label
|
51
|
+
})]
|
52
|
+
});
|
53
|
+
}
|
54
|
+
export default class CountDown extends Component {
|
55
|
+
constructor(props) {
|
56
|
+
super(props);
|
57
|
+
const newProps = mergeProps(props, CountDown, ['dark', 'endTime', 'style']);
|
58
|
+
this.state = getRemaining(newProps.endTime);
|
59
|
+
this.timer = null;
|
60
|
+
}
|
61
|
+
componentDidMount() {
|
62
|
+
this.timer = setInterval(() => {
|
63
|
+
const remaining = getRemaining(this.props.endTime);
|
64
|
+
if (remaining.done) {
|
65
|
+
clearInterval(this.timer);
|
66
|
+
this.timer = null;
|
67
|
+
}
|
68
|
+
this.setState(remaining);
|
69
|
+
}, 1000);
|
70
|
+
}
|
71
|
+
componentWillUnmount() {
|
72
|
+
if (this.timer) {
|
73
|
+
clearInterval(this.timer);
|
74
|
+
this.timer = null;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
render() {
|
78
|
+
const {
|
79
|
+
dark,
|
80
|
+
endTime,
|
81
|
+
...rest
|
82
|
+
} = this.props;
|
83
|
+
const {
|
84
|
+
days,
|
85
|
+
hours,
|
86
|
+
minutes,
|
87
|
+
seconds
|
88
|
+
} = this.state;
|
89
|
+
return /*#__PURE__*/_jsxs(Container, {
|
90
|
+
dark: dark,
|
91
|
+
...rest,
|
92
|
+
children: [/*#__PURE__*/_jsx(FixWidthNumber, {
|
93
|
+
number: days,
|
94
|
+
label: "D"
|
95
|
+
}), /*#__PURE__*/_jsx("span", {
|
96
|
+
className: "num-sep",
|
97
|
+
children: ":"
|
98
|
+
}), /*#__PURE__*/_jsx(FixWidthNumber, {
|
99
|
+
number: hours,
|
100
|
+
label: "H"
|
101
|
+
}), /*#__PURE__*/_jsx("span", {
|
102
|
+
className: "num-sep",
|
103
|
+
children: ":"
|
104
|
+
}), /*#__PURE__*/_jsx(FixWidthNumber, {
|
105
|
+
number: minutes,
|
106
|
+
label: "M"
|
107
|
+
}), /*#__PURE__*/_jsx("span", {
|
108
|
+
className: "num-sep",
|
109
|
+
children: ":"
|
110
|
+
}), /*#__PURE__*/_jsx(FixWidthNumber, {
|
111
|
+
number: seconds,
|
112
|
+
label: "S"
|
113
|
+
})]
|
114
|
+
});
|
115
|
+
}
|
116
|
+
}
|
117
|
+
CountDown.propTypes = {
|
118
|
+
endTime: PropTypes.number.isRequired,
|
119
|
+
// endTime should be UTC
|
120
|
+
dark: PropTypes.bool,
|
121
|
+
style: PropTypes.object
|
122
|
+
};
|
123
|
+
CountDown.defaultProps = {
|
124
|
+
dark: true,
|
125
|
+
style: {}
|
126
|
+
};
|
127
|
+
const textBackground = `linear-gradient(to bottom, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
|
128
|
+
linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5) 77%, rgba(0, 0, 0, 0.5))`;
|
129
|
+
const Container = styled('div')`
|
130
|
+
color: ${props => getColor(props)};
|
131
|
+
font-size: 50px;
|
132
|
+
display: flex;
|
133
|
+
flex-direction: row;
|
134
|
+
justify-content: center;
|
135
|
+
align-items: flex-start;
|
136
|
+
|
137
|
+
.num-group {
|
138
|
+
display: flex;
|
139
|
+
flex-direction: column;
|
140
|
+
justify-content: center;
|
141
|
+
align-items: center;
|
142
|
+
margin: 0 60px;
|
143
|
+
|
144
|
+
@media (max-width: ${props => props.theme.breakpoints.values.md}px) {
|
145
|
+
margin: 0 20px;
|
146
|
+
}
|
147
|
+
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
148
|
+
margin: 0;
|
149
|
+
}
|
150
|
+
|
151
|
+
.num-items {
|
152
|
+
display: flex;
|
153
|
+
flex-direction: row;
|
154
|
+
}
|
155
|
+
|
156
|
+
.num-item {
|
157
|
+
display: inline-block;
|
158
|
+
width: 40px;
|
159
|
+
height: 60px;
|
160
|
+
line-height: 60px;
|
161
|
+
background-image: ${props => props.dark ? textBackground : 'none'};
|
162
|
+
text-align: center;
|
163
|
+
|
164
|
+
&:first-of-type {
|
165
|
+
margin-right: 10px;
|
166
|
+
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
167
|
+
margin: 0;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
.num-label {
|
173
|
+
margin-top: 20px;
|
174
|
+
font-size: 24px;
|
175
|
+
color: ${props => getColor(props)};
|
176
|
+
}
|
177
|
+
}
|
178
|
+
`;
|
package/es/DID/index.js
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
import React, { forwardRef } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
4
|
+
import Address from '../Address';
|
5
|
+
import Avatar from '../Avatar';
|
6
|
+
import { isEthereumDid, getFontSize } from '../Util';
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
const DIDPropTypes = {
|
9
|
+
did: PropTypes.string.isRequired,
|
10
|
+
size: PropTypes.number,
|
11
|
+
component: PropTypes.string,
|
12
|
+
copyable: PropTypes.bool,
|
13
|
+
responsive: PropTypes.bool,
|
14
|
+
showCopyButtonInTooltip: PropTypes.bool,
|
15
|
+
inline: PropTypes.bool,
|
16
|
+
append: PropTypes.any,
|
17
|
+
compact: PropTypes.bool,
|
18
|
+
startChars: PropTypes.number,
|
19
|
+
endChars: PropTypes.number,
|
20
|
+
locale: PropTypes.oneOf(['en', 'zh'])
|
21
|
+
};
|
22
|
+
const getFontColor = (did, didMotifInfo, isEthDid) => {
|
23
|
+
if (isEthDid) {
|
24
|
+
const index = Uint8Array.from(did.slice(2).match(/.{1,2}/g).map(pair => parseInt(pair, 16))).slice(0, 8).reduce((acc, val) => acc + val, 0) % colors.length;
|
25
|
+
return colors[index];
|
26
|
+
}
|
27
|
+
return didMotifInfo.color;
|
28
|
+
};
|
29
|
+
const isSquareMotif = roleType => {
|
30
|
+
const roles = {
|
31
|
+
0: true,
|
32
|
+
// ACCOUNT
|
33
|
+
6: true,
|
34
|
+
// ASSET
|
35
|
+
17: true // TOKEN
|
36
|
+
};
|
37
|
+
|
38
|
+
return !roles[roleType];
|
39
|
+
};
|
40
|
+
const getAvatarSize = (didMotifInfo, isEthDid, size) => {
|
41
|
+
if (isEthDid) {
|
42
|
+
return size * 0.75;
|
43
|
+
}
|
44
|
+
if (isSquareMotif(didMotifInfo.roleType)) {
|
45
|
+
return size * 0.75;
|
46
|
+
}
|
47
|
+
return size;
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @type React.ForwardRefRenderFunction<HTMLElement, typeof DIDPropTypes>
|
52
|
+
*/
|
53
|
+
const DID = /*#__PURE__*/forwardRef(({
|
54
|
+
did,
|
55
|
+
...rest
|
56
|
+
}, ref) => {
|
57
|
+
const isEthDid = isEthereumDid(did);
|
58
|
+
const didMotifInfo = isEthDid ? undefined : getDIDMotifInfo(did);
|
59
|
+
const fontSize = getFontSize(rest.size);
|
60
|
+
const prepend = [/*#__PURE__*/_jsx("span", {
|
61
|
+
style: {
|
62
|
+
fontSize,
|
63
|
+
color: getFontColor(did, didMotifInfo, isEthDid)
|
64
|
+
},
|
65
|
+
children: "DID:"
|
66
|
+
}, "prefix-did"), /*#__PURE__*/_jsx("span", {
|
67
|
+
className: "did-address-text",
|
68
|
+
style: {
|
69
|
+
fontSize
|
70
|
+
},
|
71
|
+
children: "ABT:"
|
72
|
+
}, "prefix-abt"), /*#__PURE__*/_jsx(Avatar, {
|
73
|
+
did: did,
|
74
|
+
size: getAvatarSize(didMotifInfo, isEthDid, rest.size || 18),
|
75
|
+
style: {
|
76
|
+
display: 'inline-flex',
|
77
|
+
alignItems: 'center',
|
78
|
+
marginLeft: 2,
|
79
|
+
marginRight: 4
|
80
|
+
},
|
81
|
+
blockiesPadding: false,
|
82
|
+
className: "did-address-avatar"
|
83
|
+
}, "avatar")];
|
84
|
+
return /*#__PURE__*/_jsx(Address, {
|
85
|
+
ref: ref,
|
86
|
+
...rest,
|
87
|
+
prepend: prepend,
|
88
|
+
children: did
|
89
|
+
});
|
90
|
+
});
|
91
|
+
export default DID;
|
92
|
+
DID.propTypes = DIDPropTypes;
|
93
|
+
DID.defaultProps = {
|
94
|
+
size: 0,
|
95
|
+
component: 'span',
|
96
|
+
copyable: true,
|
97
|
+
responsive: true,
|
98
|
+
showCopyButtonInTooltip: false,
|
99
|
+
inline: false,
|
100
|
+
append: null,
|
101
|
+
compact: false,
|
102
|
+
startChars: 6,
|
103
|
+
endChars: 6,
|
104
|
+
locale: 'en'
|
105
|
+
};
|