@arcblock/ux 2.1.17 → 2.1.20
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/ActionButton/index.js +16 -8
- package/lib/ActivityIndicator/index.js +49 -36
- package/lib/Alert/index.js +25 -17
- package/lib/AnimationWaiter/index.js +44 -35
- package/lib/Async/index.js +15 -3
- package/lib/Badge/index.js +14 -4
- package/lib/Blocklet/blocklet.js +81 -62
- package/lib/BlockletNFT/index.js +95 -76
- package/lib/Button/wrap.js +13 -9
- package/lib/Center/index.js +6 -5
- package/lib/ClickToCopy/index.js +31 -21
- package/lib/CodeBlock/index.js +35 -27
- package/lib/ContactForm/index.js +46 -41
- package/lib/CookieConsent/index.js +33 -21
- package/lib/CountDown/index.js +50 -34
- package/lib/Datatable/CustomToolbar.js +138 -97
- package/lib/Datatable/DatatableContext.js +9 -12
- package/lib/Datatable/TableSearch.js +50 -29
- package/lib/Datatable/index.js +46 -28
- package/lib/Dialog/confirm.js +26 -13
- package/lib/Dialog/dialog.js +42 -26
- package/lib/DriftBot/index.js +2 -2
- package/lib/Earth/index.js +121 -107
- package/lib/Empty/index.js +19 -10
- package/lib/ErrorBoundary/fallback.js +18 -12
- package/lib/Footer/index.js +32 -26
- package/lib/Header/header.js +37 -21
- package/lib/Header/responsive-header.js +40 -30
- package/lib/Icon/image.js +22 -15
- package/lib/Icon/index.js +17 -7
- package/lib/Img/index.js +34 -32
- package/lib/InfoRow/index.js +23 -13
- package/lib/Layout/dashboard/index.js +66 -54
- package/lib/Layout/dashboard/sidebar.js +39 -26
- package/lib/Layout/dashboard-legacy/header.js +56 -38
- package/lib/Layout/dashboard-legacy/index.js +54 -44
- package/lib/Layout/dashboard-legacy/sidebar.js +48 -38
- package/lib/Layout/index.js +147 -111
- package/lib/Locale/context.js +8 -10
- package/lib/Locale/selector.js +55 -41
- package/lib/Logo/index.js +50 -30
- package/lib/Metric/index.js +30 -23
- package/lib/NFTDisplay/aspect-ratio-container.js +15 -6
- package/lib/NFTDisplay/broken.js +3 -3
- package/lib/NFTDisplay/index.js +29 -28
- package/lib/NFTDisplay/loading.js +6 -5
- package/lib/NFTDisplay/svg-embedder/img.js +10 -4
- package/lib/NFTDisplay/svg-embedder/inline-svg.js +14 -6
- package/lib/NavMenu/nav-menu.js +60 -49
- package/lib/PageScroller/index.js +29 -27
- package/lib/PageScroller/usePrevValue.js +1 -5
- package/lib/PricingTable/PricingPlan.js +46 -36
- package/lib/PricingTable/index.js +22 -20
- package/lib/QRCode/index.js +6 -9
- package/lib/RelativeTime/index.js +14 -5
- package/lib/Result/common.js +49 -44
- package/lib/Result/index.js +6 -6
- package/lib/Result/result.js +29 -18
- package/lib/Screenshot/index.js +32 -21
- package/lib/Spinner/index.js +3 -3
- package/lib/SplitButton/index.js +40 -24
- package/lib/Switch/index.js +12 -6
- package/lib/Tabs/index.js +18 -12
- package/lib/Tag/index.js +14 -4
- package/lib/Terminal/Player.js +108 -92
- package/lib/Terminal/index.js +3 -1
- package/lib/TextCollapse/index.js +18 -8
- package/lib/Toast/index.js +17 -14
- package/lib/Video/index.js +31 -25
- package/lib/Wallet/Action.js +37 -25
- package/lib/Wallet/Download.js +236 -181
- package/lib/Wallet/Open.js +6 -5
- package/lib/WechatPrompt/index.js +40 -28
- package/lib/withTheme/index.js +23 -9
- package/lib/withTracker/error_boundary.js +10 -7
- package/lib/withTracker/index.js +8 -4
- package/package.json +4 -4
- package/src/ActionButton/index.js +3 -4
- package/src/ActivityIndicator/index.js +4 -7
- package/src/Alert/index.js +4 -10
- package/src/AnimationWaiter/index.js +4 -2
- package/src/Async/index.js +4 -8
- package/src/Badge/index.js +2 -2
- package/src/Blocklet/blocklet.js +16 -27
- package/src/Blocklet/utils.js +3 -3
- package/src/BlockletNFT/index.js +7 -15
- package/src/Button/wrap.js +2 -2
- package/src/Center/index.js +0 -1
- package/src/ClickToCopy/index.js +5 -12
- package/src/CodeBlock/index.js +2 -7
- package/src/Colors/index.js +1 -0
- package/src/ContactForm/index.js +16 -16
- package/src/CookieConsent/index.js +3 -2
- package/src/CountDown/index.js +8 -8
- package/src/Datatable/CustomToolbar.js +8 -9
- package/src/Datatable/DatatableContext.js +3 -3
- package/src/Datatable/TableSearch.js +20 -14
- package/src/Datatable/index.js +19 -14
- package/src/Datatable/utils.js +19 -23
- package/src/Dialog/confirm.js +0 -1
- package/src/Dialog/dialog.js +7 -27
- package/src/Dialog/index.js +1 -0
- package/src/DriftBot/index.js +2 -2
- package/src/Earth/index.js +26 -44
- package/src/Empty/index.js +0 -1
- package/src/ErrorBoundary/fallback.js +2 -3
- package/src/Footer/index.js +3 -7
- package/src/Header/header.js +4 -5
- package/src/Header/responsive-header.js +4 -10
- package/src/Icon/image.js +0 -1
- package/src/Icon/index.js +8 -8
- package/src/Img/index.js +6 -6
- package/src/InfoRow/index.js +22 -21
- package/src/Layout/dashboard/index.js +9 -4
- package/src/Layout/dashboard/sidebar.js +4 -10
- package/src/Layout/dashboard-legacy/header.js +9 -15
- package/src/Layout/dashboard-legacy/index.js +4 -11
- package/src/Layout/dashboard-legacy/sidebar.js +7 -7
- package/src/Layout/index.js +12 -26
- package/src/Locale/browser-lang.js +2 -2
- package/src/Locale/context.js +7 -11
- package/src/Locale/selector.js +8 -8
- package/src/Logo/index.js +4 -6
- package/src/Metric/index.js +9 -10
- package/src/NFTDisplay/aspect-ratio-container.js +0 -1
- package/src/NFTDisplay/broken.js +0 -1
- package/src/NFTDisplay/index.js +10 -8
- package/src/NFTDisplay/loading.js +0 -1
- package/src/NFTDisplay/svg-embedder/img.js +1 -2
- package/src/NFTDisplay/svg-embedder/inline-svg.js +0 -1
- package/src/NavMenu/index.js +1 -0
- package/src/NavMenu/nav-menu.js +14 -27
- package/src/NavMenu/style.js +3 -3
- package/src/PageScroller/index.js +19 -35
- package/src/PageScroller/usePrevValue.js +1 -1
- package/src/PricingTable/PricingPlan.js +31 -30
- package/src/PricingTable/index.js +4 -5
- package/src/QRCode/index.js +3 -2
- package/src/RelativeTime/index.js +1 -5
- package/src/Result/common.js +19 -20
- package/src/Result/index.js +5 -6
- package/src/Result/result.js +2 -3
- package/src/Result/translations.js +1 -2
- package/src/Screenshot/index.js +10 -10
- package/src/Spinner/index.js +0 -1
- package/src/SplitButton/index.js +6 -19
- package/src/Switch/index.js +40 -41
- package/src/Tabs/index.js +2 -9
- package/src/Tag/index.js +2 -2
- package/src/Terminal/Player.js +7 -8
- package/src/Terminal/index.js +4 -3
- package/src/Terminal/util.js +3 -3
- package/src/TextCollapse/index.js +4 -10
- package/src/Theme/index.js +1 -8
- package/src/Toast/index.js +6 -10
- package/src/Util/index.js +15 -27
- package/src/Video/index.js +2 -8
- package/src/Wallet/Action.js +5 -6
- package/src/Wallet/Download.js +6 -7
- package/src/Wallet/Open.js +1 -2
- package/src/WechatPrompt/index.js +2 -7
- package/src/withTheme/index.js +5 -5
- package/src/withTracker/error_boundary.js +3 -3
- package/src/withTracker/index.js +2 -2
package/src/BlockletNFT/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Portal from '@mui/material/Portal';
|
|
@@ -32,7 +32,7 @@ function prettySize(_size, digits = 1) {
|
|
|
32
32
|
const Div = styled.div`
|
|
33
33
|
&.arcblock-blocklet {
|
|
34
34
|
padding: 0 16px;
|
|
35
|
-
background: ${props => props.theme.palette.common.white};
|
|
35
|
+
background: ${(props) => props.theme.palette.common.white};
|
|
36
36
|
overflow: hidden;
|
|
37
37
|
box-shadow: 0px 0px 8px #f0f0f0;
|
|
38
38
|
&:hover {
|
|
@@ -88,7 +88,7 @@ const Div = styled.div`
|
|
|
88
88
|
width: 100%;
|
|
89
89
|
top: 0;
|
|
90
90
|
left: 0;
|
|
91
|
-
background-color: ${props => props.theme.palette.primary.main};
|
|
91
|
+
background-color: ${(props) => props.theme.palette.primary.main};
|
|
92
92
|
transform: scale(0.1);
|
|
93
93
|
opacity: 0;
|
|
94
94
|
z-index: -1;
|
|
@@ -103,11 +103,11 @@ const Div = styled.div`
|
|
|
103
103
|
|
|
104
104
|
&:not(.Mui-disabled) {
|
|
105
105
|
background-color: transparent !important;
|
|
106
|
-
color: ${props => props.theme.palette.primary.main};
|
|
106
|
+
color: ${(props) => props.theme.palette.primary.main};
|
|
107
107
|
}
|
|
108
108
|
&:not(.Mui-disabled) {
|
|
109
109
|
&:hover {
|
|
110
|
-
color: ${props => props.theme.palette.common.white};
|
|
110
|
+
color: ${(props) => props.theme.palette.common.white};
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -271,19 +271,11 @@ export default function BlockletNFT({
|
|
|
271
271
|
)
|
|
272
272
|
)}
|
|
273
273
|
<div className="arcblock-blocklet__info">
|
|
274
|
-
<Typography
|
|
275
|
-
component="h3"
|
|
276
|
-
variant="h3"
|
|
277
|
-
className="arcblock-blocklet__title"
|
|
278
|
-
title={title}>
|
|
274
|
+
<Typography component="h3" variant="h3" className="arcblock-blocklet__title" title={title}>
|
|
279
275
|
{title}
|
|
280
276
|
</Typography>
|
|
281
277
|
{description && (
|
|
282
|
-
<Typography
|
|
283
|
-
component="div"
|
|
284
|
-
variant="body2"
|
|
285
|
-
className="arcblock-blocklet__describe"
|
|
286
|
-
title={description}>
|
|
278
|
+
<Typography component="div" variant="body2" className="arcblock-blocklet__describe" title={description}>
|
|
287
279
|
{description}
|
|
288
280
|
</Typography>
|
|
289
281
|
)}
|
package/src/Button/wrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable prefer-destructuring */
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
|
-
import
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
|
|
6
6
|
import Spinner from '../Spinner';
|
|
@@ -78,5 +78,5 @@ export default function (BaseComponent) {
|
|
|
78
78
|
style: {},
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
return
|
|
81
|
+
return forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
|
|
82
82
|
}
|
package/src/Center/index.js
CHANGED
package/src/ClickToCopy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRef, useState, useEffect } from 'react';
|
|
2
2
|
import Copy from 'copy-to-clipboard';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import useWindowSize from 'react-use/lib/useWindowSize';
|
|
@@ -15,10 +15,10 @@ export default function ClickToCopy(props) {
|
|
|
15
15
|
const { children, content, tip, copiedTip, tipPlacement, style, ...rest } = newProps;
|
|
16
16
|
|
|
17
17
|
const [copied, setCopied] = useState(false);
|
|
18
|
-
const childrenRef =
|
|
18
|
+
const childrenRef = createRef();
|
|
19
19
|
const { width } = useWindowSize();
|
|
20
20
|
|
|
21
|
-
const onCopy = e => {
|
|
21
|
+
const onCopy = (e) => {
|
|
22
22
|
Copy(content || e.current.textContent);
|
|
23
23
|
setCopied(true);
|
|
24
24
|
if (width < 600) {
|
|
@@ -43,18 +43,11 @@ export default function ClickToCopy(props) {
|
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<ToastProvider>
|
|
46
|
-
<Tooltip
|
|
47
|
-
title={copied ? copiedTip : tip}
|
|
48
|
-
{...rest}
|
|
49
|
-
placement={tipPlacement}
|
|
50
|
-
disableFocusListener>
|
|
46
|
+
<Tooltip title={copied ? copiedTip : tip} {...rest} placement={tipPlacement} disableFocusListener>
|
|
51
47
|
<Container
|
|
52
48
|
ref={childrenRef}
|
|
53
49
|
component="span"
|
|
54
|
-
style={Object.assign(
|
|
55
|
-
{ fontSize: 'inherit', color: 'inherit', fontWeight: 'inherit' },
|
|
56
|
-
style
|
|
57
|
-
)}
|
|
50
|
+
style={Object.assign({ fontSize: 'inherit', color: 'inherit', fontWeight: 'inherit' }, style)}
|
|
58
51
|
onClick={() => onCopy(childrenRef)}>
|
|
59
52
|
{children || content}
|
|
60
53
|
</Container>
|
package/src/CodeBlock/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/no-danger */
|
|
2
|
-
import
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import Copy from 'copy-to-clipboard';
|
|
@@ -74,12 +74,7 @@ export default function CodeBlock({ code, language, children, ...rest }) {
|
|
|
74
74
|
dangerouslySetInnerHTML={{ __html: hljs.highlightAuto(source, [language]).value }}
|
|
75
75
|
/>
|
|
76
76
|
</span>
|
|
77
|
-
<Button
|
|
78
|
-
className="copy-button"
|
|
79
|
-
onClick={onCopy}
|
|
80
|
-
tabIndex="-1"
|
|
81
|
-
color="primary"
|
|
82
|
-
disabled={copied}>
|
|
77
|
+
<Button className="copy-button" onClick={onCopy} tabIndex="-1" color="primary" disabled={copied}>
|
|
83
78
|
{!copied && <CopyIcon style={{ color: '#fff', fontSize: 16 }} />}
|
|
84
79
|
{copied && <CheckIcon style={{ color: '#fff', fontSize: 16 }} />}
|
|
85
80
|
</Button>
|
package/src/Colors/index.js
CHANGED
package/src/ContactForm/index.js
CHANGED
|
@@ -16,15 +16,15 @@ export async function submitContactForm({ formId, portalId }, fields, context) {
|
|
|
16
16
|
return axios
|
|
17
17
|
.post(url, {
|
|
18
18
|
submittedAt: Date.now(),
|
|
19
|
-
fields: Object.keys(fields).map(x => ({
|
|
19
|
+
fields: Object.keys(fields).map((x) => ({
|
|
20
20
|
name: x.replace(/\s+/, '').toLowerCase(),
|
|
21
21
|
value: fields[x],
|
|
22
22
|
})),
|
|
23
23
|
context,
|
|
24
24
|
skipValidation: false,
|
|
25
25
|
})
|
|
26
|
-
.then(res => res.data.inlineMessage)
|
|
27
|
-
.catch(res => (res.data ? res.data.message : 'Form Submit Failed'));
|
|
26
|
+
.then((res) => res.data.inlineMessage)
|
|
27
|
+
.catch((res) => (res.data ? res.data.message : 'Form Submit Failed'));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export default class ContactForm extends React.Component {
|
|
@@ -56,7 +56,7 @@ export default class ContactForm extends React.Component {
|
|
|
56
56
|
super(props);
|
|
57
57
|
|
|
58
58
|
if (typeof props.fields === 'string') {
|
|
59
|
-
this.fields = props.fields.split(',').map(x => x.trim());
|
|
59
|
+
this.fields = props.fields.split(',').map((x) => x.trim());
|
|
60
60
|
} else {
|
|
61
61
|
this.fields = props.fields;
|
|
62
62
|
}
|
|
@@ -67,7 +67,7 @@ export default class ContactForm extends React.Component {
|
|
|
67
67
|
successMessage: '',
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
this.fields.forEach(x => {
|
|
70
|
+
this.fields.forEach((x) => {
|
|
71
71
|
this.state[x] = '';
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -102,7 +102,7 @@ export default class ContactForm extends React.Component {
|
|
|
102
102
|
</Typography>
|
|
103
103
|
)}
|
|
104
104
|
<div className="form-controls">
|
|
105
|
-
{this.fields.map(x => (
|
|
105
|
+
{this.fields.map((x) => (
|
|
106
106
|
<input
|
|
107
107
|
required
|
|
108
108
|
key={x}
|
|
@@ -145,7 +145,7 @@ export default class ContactForm extends React.Component {
|
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
onSubmit = async e => {
|
|
148
|
+
onSubmit = async (e) => {
|
|
149
149
|
e.preventDefault();
|
|
150
150
|
this.setState({ loading: true });
|
|
151
151
|
|
|
@@ -176,7 +176,7 @@ export default class ContactForm extends React.Component {
|
|
|
176
176
|
|
|
177
177
|
getInputHandler =
|
|
178
178
|
(name, state = {}) =>
|
|
179
|
-
e => {
|
|
179
|
+
(e) => {
|
|
180
180
|
this.setState(
|
|
181
181
|
Object.assign(state, {
|
|
182
182
|
[name]: e.target.value,
|
|
@@ -193,7 +193,7 @@ const Form = styled.form`
|
|
|
193
193
|
flex-direction: column;
|
|
194
194
|
justify-content: center;
|
|
195
195
|
align-items: center;
|
|
196
|
-
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
|
196
|
+
@media (max-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
197
197
|
width: 100% !important;
|
|
198
198
|
}
|
|
199
199
|
max-width: 800px;
|
|
@@ -202,24 +202,24 @@ const Form = styled.form`
|
|
|
202
202
|
.title {
|
|
203
203
|
font-size: 30px;
|
|
204
204
|
text-align: center;
|
|
205
|
-
color: ${props => props.theme.typography.color.main};
|
|
205
|
+
color: ${(props) => props.theme.typography.color.main};
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
.form-controls {
|
|
209
209
|
width: 100%;
|
|
210
|
-
flex-direction: ${props => (props.layout === 'vertical' ? 'column' : 'row')};
|
|
210
|
+
flex-direction: ${(props) => (props.layout === 'vertical' ? 'column' : 'row')};
|
|
211
211
|
justify-content: space-between;
|
|
212
212
|
align-items: center;
|
|
213
213
|
|
|
214
214
|
.input {
|
|
215
|
-
width: ${props => getInputWidth(props)};
|
|
215
|
+
width: ${(props) => getInputWidth(props)};
|
|
216
216
|
height: 50px;
|
|
217
217
|
border: none;
|
|
218
|
-
border-bottom: 1px solid ${props => props.theme.typography.color.main};
|
|
218
|
+
border-bottom: 1px solid ${(props) => props.theme.typography.color.main};
|
|
219
219
|
font-size: 16px;
|
|
220
220
|
letter-spacing: 1.8px;
|
|
221
221
|
outline: none;
|
|
222
|
-
margin: ${props => (props.layout === 'vertical' ? '12px 0' : '12px')};
|
|
222
|
+
margin: ${(props) => (props.layout === 'vertical' ? '12px 0' : '12px')};
|
|
223
223
|
background: transparent;
|
|
224
224
|
|
|
225
225
|
&:first-of-type {
|
|
@@ -228,8 +228,8 @@ const Form = styled.form`
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
.subscribe-btn-empty {
|
|
231
|
-
margin-top: ${props => (props.layout === 'vertical' ? '40px' : '0')};
|
|
232
|
-
width: ${props => (props.layout === 'vertical' ? '100%' : 'auto')};
|
|
231
|
+
margin-top: ${(props) => (props.layout === 'vertical' ? '40px' : '0')};
|
|
232
|
+
width: ${(props) => (props.layout === 'vertical' ? '100%' : 'auto')};
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
import Button from '@mui/material/Button';
|
|
@@ -19,7 +18,9 @@ const translations = {
|
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
function AcceptButton(props) {
|
|
22
|
+
return <Button variant="contained" {...props} />;
|
|
23
|
+
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* DefaultCookieConsent, 对 react-cookie-consent package 封装, 以便 arcblock 内部产品可以快速使用
|
package/src/CountDown/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
@@ -41,7 +41,7 @@ function FixWidthNumber({ number, label, length = 2 }) {
|
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export default class CountDown extends
|
|
44
|
+
export default class CountDown extends Component {
|
|
45
45
|
constructor(props) {
|
|
46
46
|
const newProps = mergeProps(props, CountDown, ['dark', 'endTime', 'style']);
|
|
47
47
|
super(newProps);
|
|
@@ -100,7 +100,7 @@ const textBackground = `linear-gradient(to bottom, rgba(0, 0, 0, 0.4), rgba(0, 0
|
|
|
100
100
|
linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5) 77%, rgba(0, 0, 0, 0.5))`;
|
|
101
101
|
|
|
102
102
|
const Container = styled.div`
|
|
103
|
-
color: ${props => getColor(props)};
|
|
103
|
+
color: ${(props) => getColor(props)};
|
|
104
104
|
font-size: 50px;
|
|
105
105
|
display: flex;
|
|
106
106
|
flex-direction: row;
|
|
@@ -114,10 +114,10 @@ const Container = styled.div`
|
|
|
114
114
|
align-items: center;
|
|
115
115
|
margin: 0 60px;
|
|
116
116
|
|
|
117
|
-
@media (max-width: ${props => props.theme.breakpoints.values.md}px) {
|
|
117
|
+
@media (max-width: ${(props) => props.theme.breakpoints.values.md}px) {
|
|
118
118
|
margin: 0 20px;
|
|
119
119
|
}
|
|
120
|
-
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
|
120
|
+
@media (max-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
121
121
|
margin: 0;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -131,12 +131,12 @@ const Container = styled.div`
|
|
|
131
131
|
width: 40px;
|
|
132
132
|
height: 60px;
|
|
133
133
|
line-height: 60px;
|
|
134
|
-
background-image: ${props => (props.dark ? textBackground : 'none')};
|
|
134
|
+
background-image: ${(props) => (props.dark ? textBackground : 'none')};
|
|
135
135
|
text-align: center;
|
|
136
136
|
|
|
137
137
|
&:first-of-type {
|
|
138
138
|
margin-right: 10px;
|
|
139
|
-
@media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
|
|
139
|
+
@media (max-width: ${(props) => props.theme.breakpoints.values.sm}px) {
|
|
140
140
|
margin: 0;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -145,7 +145,7 @@ const Container = styled.div`
|
|
|
145
145
|
.num-label {
|
|
146
146
|
margin-top: 20px;
|
|
147
147
|
font-size: 24px;
|
|
148
|
-
color: ${props => getColor(props)};
|
|
148
|
+
color: ${(props) => getColor(props)};
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useRef, useEffect, isValidElement } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { TableFilter, TableViewCol } from 'mui-datatables';
|
|
4
4
|
import styled from 'styled-components';
|
|
@@ -69,7 +69,7 @@ export default function CustomToolbar(props) {
|
|
|
69
69
|
}
|
|
70
70
|
}, [loading, disabled]);
|
|
71
71
|
|
|
72
|
-
const printArea = func => {
|
|
72
|
+
const printArea = (func) => {
|
|
73
73
|
return (
|
|
74
74
|
<ReactToPrint content={() => props.tableRef()}>
|
|
75
75
|
<PrintContextConsumer>{func}</PrintContextConsumer>
|
|
@@ -77,7 +77,7 @@ export default function CustomToolbar(props) {
|
|
|
77
77
|
);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const getPopId = key => `toolbar-pop-${toolbarId.current}-${key}`;
|
|
80
|
+
const getPopId = (key) => `toolbar-pop-${toolbarId.current}-${key}`;
|
|
81
81
|
|
|
82
82
|
const defaultButtons = [];
|
|
83
83
|
|
|
@@ -96,6 +96,7 @@ export default function CustomToolbar(props) {
|
|
|
96
96
|
defaultButtons.push({
|
|
97
97
|
icon: <ViewColumnIcon />,
|
|
98
98
|
title: viewColumns,
|
|
99
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
99
100
|
popRender() {
|
|
100
101
|
return (
|
|
101
102
|
<TableViewColComponent
|
|
@@ -115,6 +116,7 @@ export default function CustomToolbar(props) {
|
|
|
115
116
|
defaultButtons.push({
|
|
116
117
|
icon: <FilterIcon />,
|
|
117
118
|
title: filterTable,
|
|
119
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
118
120
|
popRender() {
|
|
119
121
|
return (
|
|
120
122
|
<TableFilterComponent
|
|
@@ -133,8 +135,7 @@ export default function CustomToolbar(props) {
|
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
const showMore =
|
|
137
|
-
[!hidePrint, ...defaultButtons, ...customButtons].filter(e => !!e).length > 1 && isMobile;
|
|
138
|
+
const showMore = [!hidePrint, ...defaultButtons, ...customButtons].filter((e) => !!e).length > 1 && isMobile;
|
|
138
139
|
|
|
139
140
|
const allPops = [];
|
|
140
141
|
const [allPopsEl, setAllPopsEl] = useState({});
|
|
@@ -283,7 +284,7 @@ export default function CustomToolbar(props) {
|
|
|
283
284
|
ref={moreBtn}
|
|
284
285
|
aria-haspopup="true"
|
|
285
286
|
aria-expanded={menuIconEl ? 'true' : undefined}
|
|
286
|
-
onClick={event => setMenuIconEl(event.currentTarget)}
|
|
287
|
+
onClick={(event) => setMenuIconEl(event.currentTarget)}
|
|
287
288
|
style={{ flexShrink: 0 }}>
|
|
288
289
|
<MoreVertIcon />
|
|
289
290
|
</IconButton>
|
|
@@ -317,9 +318,7 @@ export default function CustomToolbar(props) {
|
|
|
317
318
|
{allPops.map((e, index) => (
|
|
318
319
|
<div key={getPopId(index)}>{e}</div>
|
|
319
320
|
))}
|
|
320
|
-
<ProgressContainer>
|
|
321
|
-
{loading && <LinearProgress className="toolbar-progress" />}
|
|
322
|
-
</ProgressContainer>
|
|
321
|
+
<ProgressContainer>{loading && <LinearProgress className="toolbar-progress" />}</ProgressContainer>
|
|
323
322
|
</div>
|
|
324
323
|
);
|
|
325
324
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, useContext, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
const DatatableContext = createContext({});
|
|
4
4
|
|
|
5
5
|
const { Provider } = DatatableContext;
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line react/prop-types
|
|
8
|
-
|
|
8
|
+
function DatatableProvide({ children }) {
|
|
9
9
|
const [customButtons, setCustomButtons] = useState([]);
|
|
10
10
|
const [loading, setLoading] = useState(false);
|
|
11
11
|
const [disabled, setDisabled] = useState(false);
|
|
@@ -23,7 +23,7 @@ const DatatableProvide = ({ children }) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return <Provider value={value}>{children}</Provider>;
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
28
|
function useDatatableContext() {
|
|
29
29
|
return useContext(DatatableContext);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import IconButton from '@mui/material/IconButton';
|
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
|
@@ -7,23 +7,29 @@ import TextField from '@mui/material/TextField';
|
|
|
7
7
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
|
|
10
|
-
export default function TableSearch({
|
|
11
|
-
search,
|
|
12
|
-
options,
|
|
13
|
-
searchText,
|
|
14
|
-
searchTextUpdate,
|
|
15
|
-
searchClose,
|
|
16
|
-
onSearchOpen,
|
|
17
|
-
}) {
|
|
10
|
+
export default function TableSearch({ search, options, searchText, searchTextUpdate, searchClose, onSearchOpen }) {
|
|
18
11
|
const [inputMode, setInputMode] = useState(false);
|
|
12
|
+
const [innerSearchText, setInnerSearchText] = useState('');
|
|
13
|
+
const inputTimer = useRef(null);
|
|
14
|
+
|
|
15
|
+
const searchDebounceTime = options.serverSide && options.searchDebounceTime;
|
|
19
16
|
|
|
20
17
|
const clickSearchIcon = () => {
|
|
21
18
|
setInputMode(true);
|
|
22
19
|
onSearchOpen(true);
|
|
23
20
|
};
|
|
24
21
|
|
|
25
|
-
const onChange = event => {
|
|
26
|
-
|
|
22
|
+
const onChange = (event) => {
|
|
23
|
+
const { value } = event.currentTarget;
|
|
24
|
+
if (searchDebounceTime) {
|
|
25
|
+
clearTimeout(inputTimer.current);
|
|
26
|
+
setInnerSearchText(value);
|
|
27
|
+
inputTimer.current = setTimeout(() => {
|
|
28
|
+
searchTextUpdate(value);
|
|
29
|
+
}, searchDebounceTime);
|
|
30
|
+
} else {
|
|
31
|
+
searchTextUpdate(value);
|
|
32
|
+
}
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
const clickClose = () => {
|
|
@@ -56,7 +62,7 @@ export default function TableSearch({
|
|
|
56
62
|
variant="standard"
|
|
57
63
|
spacing={2}
|
|
58
64
|
onChange={onChange}
|
|
59
|
-
value={searchText || ''}
|
|
65
|
+
value={searchDebounceTime ? innerSearchText : searchText || ''}
|
|
60
66
|
autoFocus
|
|
61
67
|
/>
|
|
62
68
|
)}
|
|
@@ -100,11 +106,11 @@ const Container = styled.div`
|
|
|
100
106
|
width: 260px;
|
|
101
107
|
padding-left: 8px;
|
|
102
108
|
|
|
103
|
-
${props => props.theme.breakpoints.down('md')} {
|
|
109
|
+
${(props) => props.theme.breakpoints.down('md')} {
|
|
104
110
|
width: 200px;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
${props => props.theme.breakpoints.down('sm')} {
|
|
113
|
+
${(props) => props.theme.breakpoints.down('sm')} {
|
|
108
114
|
width: 180px;
|
|
109
115
|
}
|
|
110
116
|
&.small-textfield {
|
package/src/Datatable/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import MUIDataTable, { TableFilterList, TableFooter } from 'mui-datatables';
|
|
4
5
|
import styled from 'styled-components';
|
|
5
6
|
import isObject from 'lodash/isObject';
|
|
6
7
|
import cloneDeep from 'lodash/cloneDeep';
|
|
8
|
+
import Empty from '../Empty';
|
|
7
9
|
import CustomToolbar from './CustomToolbar';
|
|
8
10
|
import { DatatableProvide, useDatatableContext } from './DatatableContext';
|
|
9
11
|
|
|
@@ -47,7 +49,7 @@ function ReDatatable({
|
|
|
47
49
|
const keys = [];
|
|
48
50
|
|
|
49
51
|
// Convert Columns fields to object sets to support the width function
|
|
50
|
-
const columns = originColumns.map(e => {
|
|
52
|
+
const columns = originColumns.map((e) => {
|
|
51
53
|
let tempObj;
|
|
52
54
|
|
|
53
55
|
if (!isObject(e)) {
|
|
@@ -65,7 +67,7 @@ function ReDatatable({
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
const { setCellHeaderProps } = tempObj.options;
|
|
68
|
-
tempObj.options.setCellHeaderProps = columnMeta => {
|
|
70
|
+
tempObj.options.setCellHeaderProps = (columnMeta) => {
|
|
69
71
|
let cellProps = {};
|
|
70
72
|
|
|
71
73
|
// Complementing width while inheriting old setCellHeaderProps
|
|
@@ -91,9 +93,9 @@ function ReDatatable({
|
|
|
91
93
|
});
|
|
92
94
|
|
|
93
95
|
// Fixing object-type structures
|
|
94
|
-
const data = originData.map(e => {
|
|
96
|
+
const data = originData.map((e) => {
|
|
95
97
|
if (!Array.isArray(e) && isObject(e)) {
|
|
96
|
-
return keys.map(key => e[key]);
|
|
98
|
+
return keys.map((key) => e[key]);
|
|
97
99
|
}
|
|
98
100
|
return e;
|
|
99
101
|
});
|
|
@@ -103,7 +105,10 @@ function ReDatatable({
|
|
|
103
105
|
useEffect(() => setDisabled(disabled), [disabled]);
|
|
104
106
|
|
|
105
107
|
let textLabels = {
|
|
106
|
-
body: {
|
|
108
|
+
body: {
|
|
109
|
+
noMatch: <Empty>Sorry, no matching records found</Empty>,
|
|
110
|
+
toolTip: 'Sort',
|
|
111
|
+
},
|
|
107
112
|
pagination: {
|
|
108
113
|
next: 'Next Page',
|
|
109
114
|
previous: 'Previous Page',
|
|
@@ -125,7 +130,7 @@ function ReDatatable({
|
|
|
125
130
|
|
|
126
131
|
if (locale === 'zh') {
|
|
127
132
|
textLabels = {
|
|
128
|
-
body: { noMatch:
|
|
133
|
+
body: { noMatch: <Empty>对不起,没有找到匹配的记录</Empty>, toolTip: '排序' },
|
|
129
134
|
pagination: {
|
|
130
135
|
next: '下一页',
|
|
131
136
|
previous: '上一页',
|
|
@@ -232,7 +237,7 @@ const TableContainer = styled.div`
|
|
|
232
237
|
height: 100%;
|
|
233
238
|
box-shadow: none;
|
|
234
239
|
}
|
|
235
|
-
${props => props.theme.breakpoints.down('md')} {
|
|
240
|
+
${(props) => props.theme.breakpoints.down('md')} {
|
|
236
241
|
[class*='MUIDataTableBody-emptyTitle'] {
|
|
237
242
|
padding-left: 16px;
|
|
238
243
|
width: 200%;
|
|
@@ -243,7 +248,7 @@ const TableContainer = styled.div`
|
|
|
243
248
|
&.datatable-stripped {
|
|
244
249
|
.MuiTableBody-root {
|
|
245
250
|
tr:nth-of-type(odd) {
|
|
246
|
-
background-color: ${props => props.theme.palette.action.hover};
|
|
251
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
254
|
}
|
|
@@ -261,9 +266,9 @@ const FilterLine = styled.div`
|
|
|
261
266
|
}
|
|
262
267
|
`;
|
|
263
268
|
|
|
264
|
-
|
|
269
|
+
function WrapFilterList(props) {
|
|
265
270
|
const { filterLabel } = useDatatableContext();
|
|
266
|
-
const hasFilter = !!props.filterList.filter(e => e.length).length;
|
|
271
|
+
const hasFilter = !!props.filterList.filter((e) => e.length).length;
|
|
267
272
|
if (hasFilter) {
|
|
268
273
|
return (
|
|
269
274
|
<FilterLine>
|
|
@@ -275,7 +280,7 @@ const WrapFilterList = props => {
|
|
|
275
280
|
);
|
|
276
281
|
}
|
|
277
282
|
return '';
|
|
278
|
-
}
|
|
283
|
+
}
|
|
279
284
|
|
|
280
285
|
WrapFilterList.propTypes = {
|
|
281
286
|
filterList: PropTypes.array,
|
|
@@ -285,7 +290,7 @@ WrapFilterList.defaultProps = {
|
|
|
285
290
|
filterList: [],
|
|
286
291
|
};
|
|
287
292
|
|
|
288
|
-
|
|
293
|
+
function WrapTableFooter(props) {
|
|
289
294
|
const { loading, disabled } = useDatatableContext();
|
|
290
295
|
|
|
291
296
|
return (
|
|
@@ -295,7 +300,7 @@ const WrapTableFooter = props => {
|
|
|
295
300
|
</div>
|
|
296
301
|
</FooterContainer>
|
|
297
302
|
);
|
|
298
|
-
}
|
|
303
|
+
}
|
|
299
304
|
|
|
300
305
|
const FooterContainer = styled.div`
|
|
301
306
|
display: flex;
|