@arcblock/ux 2.1.18 → 2.1.21

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.
Files changed (164) hide show
  1. package/lib/ActionButton/index.js +16 -8
  2. package/lib/ActivityIndicator/index.js +49 -36
  3. package/lib/Alert/index.js +25 -17
  4. package/lib/AnimationWaiter/index.js +44 -35
  5. package/lib/Async/index.js +15 -3
  6. package/lib/Badge/index.js +14 -4
  7. package/lib/Blocklet/blocklet.js +81 -62
  8. package/lib/BlockletNFT/index.js +95 -76
  9. package/lib/Button/wrap.js +13 -9
  10. package/lib/Center/index.js +6 -5
  11. package/lib/ClickToCopy/index.js +31 -21
  12. package/lib/CodeBlock/index.js +35 -27
  13. package/lib/ContactForm/index.js +46 -41
  14. package/lib/CookieConsent/index.js +33 -21
  15. package/lib/CountDown/index.js +50 -34
  16. package/lib/Datatable/CustomToolbar.js +138 -97
  17. package/lib/Datatable/DatatableContext.js +9 -12
  18. package/lib/Datatable/TableSearch.js +44 -27
  19. package/lib/Datatable/index.js +44 -28
  20. package/lib/Dialog/confirm.js +26 -13
  21. package/lib/Dialog/dialog.js +42 -26
  22. package/lib/DriftBot/index.js +2 -2
  23. package/lib/Earth/index.js +121 -107
  24. package/lib/Empty/index.js +19 -10
  25. package/lib/ErrorBoundary/fallback.js +18 -12
  26. package/lib/Footer/index.js +32 -26
  27. package/lib/Header/header.js +37 -21
  28. package/lib/Header/responsive-header.js +40 -30
  29. package/lib/Icon/image.js +22 -15
  30. package/lib/Icon/index.js +17 -7
  31. package/lib/Img/index.js +34 -32
  32. package/lib/InfoRow/index.js +23 -13
  33. package/lib/Layout/dashboard/index.js +66 -54
  34. package/lib/Layout/dashboard/sidebar.js +39 -26
  35. package/lib/Layout/dashboard-legacy/header.js +56 -38
  36. package/lib/Layout/dashboard-legacy/index.js +54 -44
  37. package/lib/Layout/dashboard-legacy/sidebar.js +48 -38
  38. package/lib/Layout/index.js +147 -111
  39. package/lib/Locale/context.js +8 -10
  40. package/lib/Locale/selector.js +55 -41
  41. package/lib/Logo/index.js +50 -30
  42. package/lib/Metric/index.js +30 -23
  43. package/lib/NFTDisplay/aspect-ratio-container.js +15 -6
  44. package/lib/NFTDisplay/broken.js +3 -3
  45. package/lib/NFTDisplay/index.js +29 -28
  46. package/lib/NFTDisplay/loading.js +6 -5
  47. package/lib/NFTDisplay/svg-embedder/img.js +10 -4
  48. package/lib/NFTDisplay/svg-embedder/inline-svg.js +14 -6
  49. package/lib/NavMenu/nav-menu.js +60 -49
  50. package/lib/PageScroller/index.js +29 -27
  51. package/lib/PageScroller/usePrevValue.js +1 -5
  52. package/lib/PricingTable/PricingPlan.js +46 -36
  53. package/lib/PricingTable/index.js +22 -20
  54. package/lib/QRCode/index.js +6 -9
  55. package/lib/RelativeTime/index.js +14 -5
  56. package/lib/Result/common.js +49 -44
  57. package/lib/Result/index.js +6 -6
  58. package/lib/Result/result.js +29 -18
  59. package/lib/Screenshot/index.js +32 -21
  60. package/lib/Spinner/index.js +3 -3
  61. package/lib/SplitButton/index.js +40 -24
  62. package/lib/Switch/index.js +12 -6
  63. package/lib/Tabs/index.js +18 -12
  64. package/lib/Tag/index.js +14 -4
  65. package/lib/Terminal/Player.js +108 -92
  66. package/lib/Terminal/index.js +3 -1
  67. package/lib/TextCollapse/index.js +18 -8
  68. package/lib/Toast/index.js +17 -14
  69. package/lib/Video/index.js +31 -25
  70. package/lib/Wallet/Action.js +37 -25
  71. package/lib/Wallet/Download.js +236 -181
  72. package/lib/Wallet/Open.js +6 -5
  73. package/lib/WechatPrompt/index.js +40 -28
  74. package/lib/withTheme/index.js +23 -9
  75. package/lib/withTracker/error_boundary.js +10 -7
  76. package/lib/withTracker/index.js +8 -4
  77. package/package.json +4 -4
  78. package/src/ActionButton/index.js +3 -4
  79. package/src/ActivityIndicator/index.js +4 -7
  80. package/src/Alert/index.js +4 -10
  81. package/src/AnimationWaiter/index.js +4 -2
  82. package/src/Async/index.js +4 -8
  83. package/src/Badge/index.js +2 -2
  84. package/src/Blocklet/blocklet.js +16 -27
  85. package/src/Blocklet/utils.js +3 -3
  86. package/src/BlockletNFT/index.js +7 -15
  87. package/src/Button/wrap.js +2 -2
  88. package/src/Center/index.js +0 -1
  89. package/src/ClickToCopy/index.js +5 -12
  90. package/src/CodeBlock/index.js +2 -7
  91. package/src/Colors/index.js +1 -0
  92. package/src/ContactForm/index.js +16 -16
  93. package/src/CookieConsent/index.js +3 -2
  94. package/src/CountDown/index.js +8 -8
  95. package/src/Datatable/CustomToolbar.js +8 -9
  96. package/src/Datatable/DatatableContext.js +3 -3
  97. package/src/Datatable/TableSearch.js +18 -13
  98. package/src/Datatable/index.js +13 -12
  99. package/src/Datatable/utils.js +19 -23
  100. package/src/Dialog/confirm.js +0 -1
  101. package/src/Dialog/dialog.js +7 -27
  102. package/src/Dialog/index.js +1 -0
  103. package/src/DriftBot/index.js +2 -2
  104. package/src/Earth/index.js +26 -44
  105. package/src/Empty/index.js +0 -1
  106. package/src/ErrorBoundary/fallback.js +2 -3
  107. package/src/Footer/index.js +3 -7
  108. package/src/Header/header.js +4 -5
  109. package/src/Header/responsive-header.js +4 -10
  110. package/src/Icon/image.js +0 -1
  111. package/src/Icon/index.js +8 -8
  112. package/src/Img/index.js +6 -6
  113. package/src/InfoRow/index.js +22 -21
  114. package/src/Layout/dashboard/index.js +9 -4
  115. package/src/Layout/dashboard/sidebar.js +4 -10
  116. package/src/Layout/dashboard-legacy/header.js +9 -15
  117. package/src/Layout/dashboard-legacy/index.js +4 -11
  118. package/src/Layout/dashboard-legacy/sidebar.js +7 -7
  119. package/src/Layout/index.js +12 -26
  120. package/src/Locale/browser-lang.js +2 -2
  121. package/src/Locale/context.js +7 -11
  122. package/src/Locale/selector.js +8 -8
  123. package/src/Logo/index.js +4 -6
  124. package/src/Metric/index.js +9 -10
  125. package/src/NFTDisplay/aspect-ratio-container.js +0 -1
  126. package/src/NFTDisplay/broken.js +0 -1
  127. package/src/NFTDisplay/index.js +10 -8
  128. package/src/NFTDisplay/loading.js +0 -1
  129. package/src/NFTDisplay/svg-embedder/img.js +1 -2
  130. package/src/NFTDisplay/svg-embedder/inline-svg.js +0 -1
  131. package/src/NavMenu/index.js +1 -0
  132. package/src/NavMenu/nav-menu.js +14 -27
  133. package/src/NavMenu/style.js +3 -3
  134. package/src/PageScroller/index.js +19 -35
  135. package/src/PageScroller/usePrevValue.js +1 -1
  136. package/src/PricingTable/PricingPlan.js +31 -30
  137. package/src/PricingTable/index.js +4 -5
  138. package/src/QRCode/index.js +3 -2
  139. package/src/RelativeTime/index.js +1 -5
  140. package/src/Result/common.js +19 -20
  141. package/src/Result/index.js +5 -6
  142. package/src/Result/result.js +2 -3
  143. package/src/Result/translations.js +1 -2
  144. package/src/Screenshot/index.js +10 -10
  145. package/src/Spinner/index.js +0 -1
  146. package/src/SplitButton/index.js +6 -19
  147. package/src/Switch/index.js +40 -41
  148. package/src/Tabs/index.js +2 -9
  149. package/src/Tag/index.js +2 -2
  150. package/src/Terminal/Player.js +7 -8
  151. package/src/Terminal/index.js +4 -3
  152. package/src/Terminal/util.js +3 -3
  153. package/src/TextCollapse/index.js +4 -10
  154. package/src/Theme/index.js +1 -8
  155. package/src/Toast/index.js +6 -10
  156. package/src/Util/index.js +15 -27
  157. package/src/Video/index.js +2 -8
  158. package/src/Wallet/Action.js +5 -6
  159. package/src/Wallet/Download.js +6 -7
  160. package/src/Wallet/Open.js +1 -2
  161. package/src/WechatPrompt/index.js +2 -7
  162. package/src/withTheme/index.js +5 -5
  163. package/src/withTracker/error_boundary.js +3 -3
  164. package/src/withTracker/index.js +2 -2
@@ -1,4 +1,4 @@
1
- import React, { useRef } from 'react';
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
  )}
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable prefer-destructuring */
2
2
  /* eslint-disable func-names */
3
- import React from 'react';
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 React.forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
81
+ return forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
82
82
  }
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import styled from 'styled-components';
3
2
  import PropTypes from 'prop-types';
4
3
 
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react';
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 = React.createRef();
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>
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/no-danger */
2
- import React, { useState } from 'react';
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>
@@ -1 +1,2 @@
1
+ // eslint-disable-next-line no-restricted-exports
1
2
  export { default } from './themes/default';
@@ -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
- const AcceptButton = props => <Button variant="contained" {...props} />;
21
+ function AcceptButton(props) {
22
+ return <Button variant="contained" {...props} />;
23
+ }
23
24
 
24
25
  /**
25
26
  * DefaultCookieConsent, 对 react-cookie-consent package 封装, 以便 arcblock 内部产品可以快速使用
@@ -1,4 +1,4 @@
1
- import React from 'react';
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 React.Component {
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 React, { useState, useRef, useEffect, isValidElement } from 'react';
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 React, { createContext, useContext, useState } from 'react';
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
- const DatatableProvide = ({ children }) => {
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 React, { useState, useRef } from 'react';
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';
@@ -6,18 +6,13 @@ import SearchIcon from '@mui/icons-material/Search';
6
6
  import TextField from '@mui/material/TextField';
7
7
  import ClearIcon from '@mui/icons-material/Clear';
8
8
  import styled from 'styled-components';
9
+ import { useDatatableContext } from './DatatableContext';
9
10
 
10
- export default function TableSearch({
11
- search,
12
- options,
13
- searchText,
14
- searchTextUpdate,
15
- searchClose,
16
- onSearchOpen,
17
- }) {
11
+ export default function TableSearch({ search, options, searchText, searchTextUpdate, searchClose, onSearchOpen }) {
18
12
  const [inputMode, setInputMode] = useState(false);
19
13
  const [innerSearchText, setInnerSearchText] = useState('');
20
14
  const inputTimer = useRef(null);
15
+ const { loading } = useDatatableContext();
21
16
 
22
17
  const searchDebounceTime = options.serverSide && options.searchDebounceTime;
23
18
 
@@ -26,7 +21,7 @@ export default function TableSearch({
26
21
  onSearchOpen(true);
27
22
  };
28
23
 
29
- const onChange = event => {
24
+ const onChange = (event) => {
30
25
  const { value } = event.currentTarget;
31
26
  if (searchDebounceTime) {
32
27
  clearTimeout(inputTimer.current);
@@ -42,6 +37,7 @@ export default function TableSearch({
42
37
  const clickClose = () => {
43
38
  setInputMode(false);
44
39
  searchClose();
40
+ setInnerSearchText('');
45
41
  onSearchOpen(false);
46
42
  };
47
43
 
@@ -64,7 +60,7 @@ export default function TableSearch({
64
60
  )}
65
61
 
66
62
  <div className={`toolbar-search-area ${inputMode ? 'toolbar-btn-show' : ''}`}>
67
- {inputMode && (
63
+ {inputMode && !loading && (
68
64
  <TextField
69
65
  variant="standard"
70
66
  spacing={2}
@@ -73,6 +69,15 @@ export default function TableSearch({
73
69
  autoFocus
74
70
  />
75
71
  )}
72
+ {/* loading完成后没办法使用focus方法,所以改用两个 TextField */}
73
+ {loading && (
74
+ <TextField
75
+ disabled
76
+ variant="standard"
77
+ spacing={2}
78
+ value={searchDebounceTime ? innerSearchText : searchText || ''}
79
+ />
80
+ )}
76
81
  </div>
77
82
  <div className={`toolbar-search-close ${inputMode ? 'toolbar-btn-show' : ''}`}>
78
83
  <IconButton onClick={clickClose}>
@@ -113,11 +118,11 @@ const Container = styled.div`
113
118
  width: 260px;
114
119
  padding-left: 8px;
115
120
 
116
- ${props => props.theme.breakpoints.down('md')} {
121
+ ${(props) => props.theme.breakpoints.down('md')} {
117
122
  width: 200px;
118
123
  }
119
124
 
120
- ${props => props.theme.breakpoints.down('sm')} {
125
+ ${(props) => props.theme.breakpoints.down('sm')} {
121
126
  width: 180px;
122
127
  }
123
128
  &.small-textfield {
@@ -1,4 +1,5 @@
1
- import React, { useEffect, useRef } from 'react';
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';
@@ -48,7 +49,7 @@ function ReDatatable({
48
49
  const keys = [];
49
50
 
50
51
  // Convert Columns fields to object sets to support the width function
51
- const columns = originColumns.map(e => {
52
+ const columns = originColumns.map((e) => {
52
53
  let tempObj;
53
54
 
54
55
  if (!isObject(e)) {
@@ -66,7 +67,7 @@ function ReDatatable({
66
67
  }
67
68
 
68
69
  const { setCellHeaderProps } = tempObj.options;
69
- tempObj.options.setCellHeaderProps = columnMeta => {
70
+ tempObj.options.setCellHeaderProps = (columnMeta) => {
70
71
  let cellProps = {};
71
72
 
72
73
  // Complementing width while inheriting old setCellHeaderProps
@@ -92,9 +93,9 @@ function ReDatatable({
92
93
  });
93
94
 
94
95
  // Fixing object-type structures
95
- const data = originData.map(e => {
96
+ const data = originData.map((e) => {
96
97
  if (!Array.isArray(e) && isObject(e)) {
97
- return keys.map(key => e[key]);
98
+ return keys.map((key) => e[key]);
98
99
  }
99
100
  return e;
100
101
  });
@@ -236,7 +237,7 @@ const TableContainer = styled.div`
236
237
  height: 100%;
237
238
  box-shadow: none;
238
239
  }
239
- ${props => props.theme.breakpoints.down('md')} {
240
+ ${(props) => props.theme.breakpoints.down('md')} {
240
241
  [class*='MUIDataTableBody-emptyTitle'] {
241
242
  padding-left: 16px;
242
243
  width: 200%;
@@ -247,7 +248,7 @@ const TableContainer = styled.div`
247
248
  &.datatable-stripped {
248
249
  .MuiTableBody-root {
249
250
  tr:nth-of-type(odd) {
250
- background-color: ${props => props.theme.palette.action.hover};
251
+ background-color: ${(props) => props.theme.palette.action.hover};
251
252
  }
252
253
  }
253
254
  }
@@ -265,9 +266,9 @@ const FilterLine = styled.div`
265
266
  }
266
267
  `;
267
268
 
268
- const WrapFilterList = props => {
269
+ function WrapFilterList(props) {
269
270
  const { filterLabel } = useDatatableContext();
270
- const hasFilter = !!props.filterList.filter(e => e.length).length;
271
+ const hasFilter = !!props.filterList.filter((e) => e.length).length;
271
272
  if (hasFilter) {
272
273
  return (
273
274
  <FilterLine>
@@ -279,7 +280,7 @@ const WrapFilterList = props => {
279
280
  );
280
281
  }
281
282
  return '';
282
- };
283
+ }
283
284
 
284
285
  WrapFilterList.propTypes = {
285
286
  filterList: PropTypes.array,
@@ -289,7 +290,7 @@ WrapFilterList.defaultProps = {
289
290
  filterList: [],
290
291
  };
291
292
 
292
- const WrapTableFooter = props => {
293
+ function WrapTableFooter(props) {
293
294
  const { loading, disabled } = useDatatableContext();
294
295
 
295
296
  return (
@@ -299,7 +300,7 @@ const WrapTableFooter = props => {
299
300
  </div>
300
301
  </FooterContainer>
301
302
  );
302
- };
303
+ }
303
304
 
304
305
  const FooterContainer = styled.div`
305
306
  display: flex;