@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,3 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
  import Result from './result';
4
3
  import * as common from './common';
@@ -8,20 +7,20 @@ const componentsKeyByStatus = Object.keys(common).reduce(
8
7
  {}
9
8
  );
10
9
 
11
- const ResultWrapper = ({ status, ...rest }) => {
10
+ function ResultWrapper({ status, ...rest }) {
12
11
  if (status) {
13
12
  if (componentsKeyByStatus[status]) {
14
13
  const Component = componentsKeyByStatus[status];
15
14
  return <Component {...rest} />;
16
15
  }
17
16
  throw new Error(
18
- `Please provide a valid status for Result.status. Valid values are: ${Object.keys(
19
- componentsKeyByStatus
20
- ).join(', ')}`
17
+ `Please provide a valid status for Result.status. Valid values are: ${Object.keys(componentsKeyByStatus).join(
18
+ ', '
19
+ )}`
21
20
  );
22
21
  }
23
22
  return <Result {...rest} />;
24
- };
23
+ }
25
24
 
26
25
  ResultWrapper.propTypes = {
27
26
  status: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
  import styled from 'styled-components';
4
3
  import Box from '@mui/material/Box';
5
4
 
6
- const Result = ({ icon, title, description, extra, ...rest }) => {
5
+ function Result({ icon, title, description, extra, ...rest }) {
7
6
  return (
8
7
  <Root {...rest}>
9
8
  {icon}
@@ -26,7 +25,7 @@ const Result = ({ icon, title, description, extra, ...rest }) => {
26
25
  <Box mt={3}>{extra}</Box>
27
26
  </Root>
28
27
  );
29
- };
28
+ }
30
29
 
31
30
  Result.propTypes = {
32
31
  icon: PropTypes.element,
@@ -2,8 +2,7 @@ export default {
2
2
  en: {
3
3
  404: {
4
4
  title: '404 - Page Not Found',
5
- description:
6
- 'Sorry about that, the page you are looking for does not exist or has been moved.',
5
+ description: 'Sorry about that, the page you are looking for does not exist or has been moved.',
7
6
  },
8
7
  403: {
9
8
  title: '403 – Forbidden',
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { createElement, Children } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
 
@@ -79,8 +79,8 @@ const childProps = {
79
79
  video: ['alt', 'title', 'muted', 'autoplay', 'loop', 'key', 'children'],
80
80
  };
81
81
 
82
- const createChild = child => [
83
- React.createElement(
82
+ const createChild = (child) => [
83
+ createElement(
84
84
  child.type,
85
85
  childProps[child.type].reduce((acc, x) => {
86
86
  acc[x] = child.props[x];
@@ -98,7 +98,7 @@ const findChildren = (children, returnArgWhenNotFound = true) => {
98
98
  }
99
99
 
100
100
  if (child.props && child.props.children) {
101
- const subChildren = React.Children.toArray(child.props.children);
101
+ const subChildren = Children.toArray(child.props.children);
102
102
  const result = findChildren(subChildren, false);
103
103
  if (result) {
104
104
  return result;
@@ -116,7 +116,7 @@ const findChildren = (children, returnArgWhenNotFound = true) => {
116
116
  // This component is built upon the awesome device.css lib
117
117
  // By default it will find and only render img/video tags in the children
118
118
  // If neither of them are found, the whole child tree is rendered
119
- const Screenshot = props => {
119
+ function Screenshot(props) {
120
120
  const newProps = mergeProps(props, Screenshot, ['style', 'width', 'height']);
121
121
  const { type, children, style, className, width, height, ...rest } = newProps;
122
122
  const { zIndex = 0, borderRadius = 0 } = types[type] || {};
@@ -130,7 +130,7 @@ const Screenshot = props => {
130
130
  contentRadius={borderRadius}
131
131
  contentZIndex={zIndex}>
132
132
  <div className="device-frame">
133
- <div className="device-content">{findChildren(React.Children.toArray(children))}</div>
133
+ <div className="device-content">{findChildren(Children.toArray(children))}</div>
134
134
  </div>
135
135
  <div className="device-stripe" />
136
136
  <div className="device-header" />
@@ -139,19 +139,19 @@ const Screenshot = props => {
139
139
  <div className="device-power" />
140
140
  </Div>
141
141
  );
142
- };
142
+ }
143
143
 
144
144
  const Div = styled.div`
145
- @media (max-width: ${props => types[props.type].width}px) {
145
+ @media (max-width: ${(props) => types[props.type].width}px) {
146
146
  transform-origin: 0 0;
147
- transform: scale(${props => types[props.type].scale});
147
+ transform: scale(${(props) => types[props.type].scale});
148
148
  }
149
149
  .device-content {
150
150
  overflow: hidden;
151
151
  }
152
152
  .device-content video,
153
153
  .device-content img {
154
- border-radius: ${props => props.contentRadius}px;
154
+ border-radius: ${(props) => props.contentRadius}px;
155
155
  background-color: #fff;
156
156
  background-position: center center;
157
157
  background-size: cover;
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import CircularProgress from '@mui/material/CircularProgress';
3
2
 
4
3
  /**
@@ -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 styled from 'styled-components';
4
4
  import ExpandMore from '@mui/icons-material/ExpandMore';
@@ -10,24 +10,15 @@ import MenuItem from '@mui/material/MenuItem';
10
10
  import ButtonGroup from '@mui/material/ButtonGroup';
11
11
  import Button from '../Button';
12
12
 
13
- export default function SplitButton({
14
- size,
15
- color,
16
- menu,
17
- children,
18
- variant,
19
- onClick,
20
- menuButtonProps,
21
- ...rest
22
- }) {
13
+ export default function SplitButton({ size, color, menu, children, variant, onClick, menuButtonProps, ...rest }) {
23
14
  const [open, setOpen] = useState(false);
24
15
  const anchorRef = useRef(null);
25
16
 
26
17
  const onToggle = () => {
27
- setOpen(prevOpen => !prevOpen);
18
+ setOpen((prevOpen) => !prevOpen);
28
19
  };
29
20
 
30
- const handleClose = e => {
21
+ const handleClose = (e) => {
31
22
  if (anchorRef.current && anchorRef.current.contains(e.target)) {
32
23
  return;
33
24
  }
@@ -35,7 +26,7 @@ export default function SplitButton({
35
26
  };
36
27
 
37
28
  // 点击 item 后收起下拉菜单, 如果想要点击 action 后不收起下拉菜单, 可以在 item#onClick 时调用 e.stopPropagation()
38
- const handleItemClick = e => {
29
+ const handleItemClick = (e) => {
39
30
  if (e.target.classList.contains('MuiListItem-root')) {
40
31
  setOpen(false);
41
32
  }
@@ -55,11 +46,7 @@ export default function SplitButton({
55
46
  <ExpandMore />
56
47
  </Button>
57
48
  </StyledButtonGroup>
58
- <StyledPopper
59
- open={open}
60
- anchorEl={anchorRef.current}
61
- placement="bottom-end"
62
- disablePortal={false}>
49
+ <StyledPopper open={open} anchorEl={anchorRef.current} placement="bottom-end" disablePortal={false}>
63
50
  <Paper>
64
51
  <ClickAwayListener onClickAway={handleClose}>
65
52
  <MenuList onClick={handleItemClick}>{menu}</MenuList>
@@ -1,57 +1,56 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
  import { styled } from '@mui/material/styles';
4
3
  import FormControlLabel from '@mui/material/FormControlLabel';
5
4
  import MuiSwitch from '@mui/material/Switch';
6
5
 
7
6
  // 参考: https://mui.com/material-ui/react-switch/#customization
8
- const IOSSwitch = styled(props => (
9
- <MuiSwitch focusVisibleClassName=".Mui-focusVisible" disableRipple {...props} />
10
- ))(({ theme }) => ({
11
- width: 42,
12
- height: 26,
13
- padding: 0,
14
- '& .MuiSwitch-switchBase': {
7
+ const IOSSwitch = styled((props) => <MuiSwitch focusVisibleClassName=".Mui-focusVisible" disableRipple {...props} />)(
8
+ ({ theme }) => ({
9
+ width: 42,
10
+ height: 26,
15
11
  padding: 0,
16
- margin: 2,
17
- transitionDuration: '300ms',
18
- '&.Mui-checked': {
19
- transform: 'translateX(16px)',
20
- color: '#fff',
21
- '& + .MuiSwitch-track': {
22
- backgroundColor: theme.palette.mode === 'dark' ? '#2ECA45' : '#65C466',
23
- opacity: 1,
24
- border: 0,
12
+ '& .MuiSwitch-switchBase': {
13
+ padding: 0,
14
+ margin: 2,
15
+ transitionDuration: '300ms',
16
+ '&.Mui-checked': {
17
+ transform: 'translateX(16px)',
18
+ color: '#fff',
19
+ '& + .MuiSwitch-track': {
20
+ backgroundColor: theme.palette.mode === 'dark' ? '#2ECA45' : '#65C466',
21
+ opacity: 1,
22
+ border: 0,
23
+ },
24
+ '&.Mui-disabled + .MuiSwitch-track': {
25
+ opacity: 0.5,
26
+ },
27
+ },
28
+ '&.Mui-focusVisible .MuiSwitch-thumb': {
29
+ color: '#33cf4d',
30
+ border: '6px solid #fff',
31
+ },
32
+ '&.Mui-disabled .MuiSwitch-thumb': {
33
+ color: theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[600],
25
34
  },
26
35
  '&.Mui-disabled + .MuiSwitch-track': {
27
- opacity: 0.5,
36
+ opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
28
37
  },
29
38
  },
30
- '&.Mui-focusVisible .MuiSwitch-thumb': {
31
- color: '#33cf4d',
32
- border: '6px solid #fff',
33
- },
34
- '&.Mui-disabled .MuiSwitch-thumb': {
35
- color: theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[600],
39
+ '& .MuiSwitch-thumb': {
40
+ boxSizing: 'border-box',
41
+ width: 22,
42
+ height: 22,
36
43
  },
37
- '&.Mui-disabled + .MuiSwitch-track': {
38
- opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
44
+ '& .MuiSwitch-track': {
45
+ borderRadius: 26 / 2,
46
+ backgroundColor: theme.palette.mode === 'light' ? '#E9E9EA' : '#39393D',
47
+ opacity: 1,
48
+ transition: theme.transitions.create(['background-color'], {
49
+ duration: 500,
50
+ }),
39
51
  },
40
- },
41
- '& .MuiSwitch-thumb': {
42
- boxSizing: 'border-box',
43
- width: 22,
44
- height: 22,
45
- },
46
- '& .MuiSwitch-track': {
47
- borderRadius: 26 / 2,
48
- backgroundColor: theme.palette.mode === 'light' ? '#E9E9EA' : '#39393D',
49
- opacity: 1,
50
- transition: theme.transitions.create(['background-color'], {
51
- duration: 500,
52
- }),
53
- },
54
- }));
52
+ })
53
+ );
55
54
 
56
55
  /**
57
56
  * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
package/src/Tabs/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { styled } from '@mui/material/styles';
3
2
  import PropTypes from 'prop-types';
4
3
  import MuiTabs from '@mui/material/Tabs';
@@ -32,14 +31,8 @@ export default function Tabs({ tabs, current, onChange, ...rest }) {
32
31
  indicatorColor="primary"
33
32
  {...rest}
34
33
  className={[classes.tabs, rest.className || ''].join(' ')}>
35
- {tabs.map(x => (
36
- <MuiTab
37
- className={classes.tab}
38
- key={x.value}
39
- value={x.value}
40
- label={x.label}
41
- icon={x.icon || null}
42
- />
34
+ {tabs.map((x) => (
35
+ <MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
43
36
  ))}
44
37
  </StyledMuiTabs>
45
38
  );
package/src/Tag/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
 
@@ -68,7 +68,7 @@ Tag.defaultProps = {
68
68
  style: {},
69
69
  };
70
70
 
71
- export default React.forwardRef((props, ref) => <Tag {...props} forwardedRef={ref} />);
71
+ export default forwardRef((props, ref) => <Tag {...props} forwardedRef={ref} />);
72
72
 
73
73
  const Span = styled(Typography)`
74
74
  && {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/no-unused-prop-types */
2
- import React, { useReducer, useState, useRef, useEffect } from 'react';
2
+ import { useReducer, useState, useRef, useEffect } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import useInterval from '@arcblock/react-hooks/lib/useInterval';
5
5
  import useWindowSize from 'react-use/lib/useWindowSize';
@@ -111,6 +111,7 @@ export default function Player(props) {
111
111
  } catch (err) {
112
112
  // Do nothing
113
113
  }
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
114
115
  }, [width, maxWidth]);
115
116
 
116
117
  // console.log('main.render', state, { totalFrame: frames.length, totalDuration });
@@ -131,7 +132,7 @@ export default function Player(props) {
131
132
  };
132
133
 
133
134
  // Emit a event
134
- const emitEvent = name => {
135
+ const emitEvent = (name) => {
135
136
  if (typeof props[name] === 'function') {
136
137
  props[name]({ state, frames, options });
137
138
  }
@@ -154,6 +155,7 @@ export default function Player(props) {
154
155
  } else {
155
156
  doJump(Math.min(Math.abs(options.thumbnailTime), totalDuration));
156
157
  }
158
+ // eslint-disable-next-line react-hooks/exhaustive-deps
157
159
  }, []);
158
160
 
159
161
  // Tick intervals
@@ -231,7 +233,7 @@ export default function Player(props) {
231
233
  options.frameBox.style.paddingBottom = '40px';
232
234
  }
233
235
 
234
- const doJump = time => {
236
+ const doJump = (time) => {
235
237
  terminal.current.reset();
236
238
 
237
239
  const toFrameIndex = findFrameAt(frames, time);
@@ -240,7 +242,7 @@ export default function Player(props) {
240
242
  }
241
243
  };
242
244
 
243
- const onJump = e => {
245
+ const onJump = (e) => {
244
246
  if (!progress.current || !terminal.current || !state.isStarted) {
245
247
  return false;
246
248
  }
@@ -331,10 +333,7 @@ export default function Player(props) {
331
333
  <div className="timer">{formatTime(state.currentTime)}</div>
332
334
  <div className="progressbar-wrapper">
333
335
  <div className="progressbar" ref={progress} onClick={onJump}>
334
- <div
335
- className="progress"
336
- style={{ width: `${(state.currentTime / totalDuration) * 100}%` }}
337
- />
336
+ <div className="progress" style={{ width: `${(state.currentTime / totalDuration) * 100}%` }} />
338
337
  </div>
339
338
  </div>
340
339
  </div>
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/no-unused-class-component-methods */
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { Terminal as XTerm } from 'xterm';
@@ -85,13 +86,13 @@ export default class Terminal extends React.Component {
85
86
  }
86
87
  }
87
88
 
88
- onData = data => {
89
+ onData = (data) => {
89
90
  if (this.props.onData) {
90
91
  this.props.onData(data);
91
92
  }
92
93
  };
93
94
 
94
- onRender = data => {
95
+ onRender = (data) => {
95
96
  if (this.props.onRender) {
96
97
  this.props.onRender(data);
97
98
  }
@@ -125,7 +126,7 @@ export default class Terminal extends React.Component {
125
126
  const className = ['react-xterm', this.props.className].filter(Boolean).join(' ');
126
127
  return (
127
128
  // eslint-disable-next-line no-return-assign
128
- <div ref={ref => (this.container = ref)} className={className} style={this.props.style} />
129
+ <div ref={(ref) => (this.container = ref)} className={className} style={this.props.style} />
129
130
  );
130
131
  }
131
132
  }
@@ -14,7 +14,7 @@
14
14
  * - Multiply the frames delays by this factor
15
15
  */
16
16
  export const formatFrames = (frames, options) => {
17
- frames.forEach(x => {
17
+ frames.forEach((x) => {
18
18
  let { delay } = x;
19
19
 
20
20
  // Adjust the delay according to the options
@@ -102,7 +102,7 @@ export const isFrameAt = (frames, time, frameIndex) => {
102
102
  return false;
103
103
  };
104
104
 
105
- export const formatTime = time => {
105
+ export const formatTime = (time) => {
106
106
  let minutes = Math.floor(time / 60000);
107
107
  let seconds = parseInt((time - minutes * 60000) / 1000, 10);
108
108
 
@@ -137,7 +137,7 @@ export const getPlayerClass = (options, state) => {
137
137
  return playerClass.filter(Boolean).join(' ');
138
138
  };
139
139
 
140
- export const getFrameClass = options => {
140
+ export const getFrameClass = (options) => {
141
141
  const frameClass = ['terminal-frame'];
142
142
  if (options.frameBox.type) {
143
143
  frameClass.push(`terminal-${options.frameBox.type}`);
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
 
4
3
  import Typography from '@mui/material/Typography';
@@ -35,12 +34,7 @@ export default function TextCollapse({
35
34
  ];
36
35
 
37
36
  return (
38
- <Container
39
- component="span"
40
- style={styles}
41
- startwidth={startWidth}
42
- endwidth={endWidth}
43
- {...rest}>
37
+ <Container component="span" style={styles} startwidth={startWidth} endwidth={endWidth} {...rest}>
44
38
  <span className="start-part">{startPart}</span>
45
39
  <span className="end-part">{endPart}</span>
46
40
  </Container>
@@ -81,12 +75,12 @@ const Container = styled(Typography)`
81
75
  overflow: hidden;
82
76
  }
83
77
  .start-part {
84
- max-width: calc(100% - ${props => props.endwidth});
85
- min-width: ${props => props.startwidth};
78
+ max-width: calc(100% - ${(props) => props.endwidth});
79
+ min-width: ${(props) => props.startwidth};
86
80
  text-overflow: ellipsis;
87
81
  }
88
82
  .end-part {
89
- max-width: calc(100% - ${props => props.startwidth});
83
+ max-width: calc(100% - ${(props) => props.startwidth});
90
84
  direction: rtl;
91
85
  }
92
86
  `;
@@ -8,14 +8,7 @@ const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
8
8
 
9
9
  // https://material-ui.com/customization/default-theme/
10
10
  // eslint-disable-next-line import/prefer-default-export
11
- export const create = ({
12
- mode = 'light',
13
- pageWidth = 'md',
14
- palette,
15
- typography,
16
- overrides,
17
- ...rest
18
- } = {}) => {
11
+ export const create = ({ mode = 'light', pageWidth = 'md', palette, typography, overrides, ...rest } = {}) => {
19
12
  // palette 考虑 light & dark mode, dark mode 需要持续完善
20
13
  // - 能配合 ColorModeContext 使用
21
14
  // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { createRef } from 'react';
2
2
  import { SnackbarProvider, useSnackbar } from 'notistack';
3
3
  import IconButton from '@mui/material/IconButton';
4
4
  import CloseIcon from '@mui/icons-material/Close';
@@ -20,8 +20,8 @@ const genFn = (enqueueSnackbar, variant) => (message, opts) => {
20
20
 
21
21
  // eslint-disable-next-line react/prop-types
22
22
  function ToastProvider({ children }) {
23
- const notistackRef = React.createRef();
24
- const onClickDismiss = key => () => {
23
+ const notistackRef = createRef();
24
+ const onClickDismiss = (key) => () => {
25
25
  notistackRef.current.closeSnackbar(key);
26
26
  };
27
27
 
@@ -32,13 +32,9 @@ function ToastProvider({ children }) {
32
32
  horizontal: 'right',
33
33
  }}
34
34
  ref={notistackRef}
35
- action={key => (
36
- <IconButton
37
- key="close"
38
- aria-label="close"
39
- color="inherit"
40
- onClick={onClickDismiss(key)}
41
- size="large">
35
+ // eslint-disable-next-line react/no-unstable-nested-components
36
+ action={(key) => (
37
+ <IconButton key="close" aria-label="close" color="inherit" onClick={onClickDismiss(key)} size="large">
42
38
  <CloseIcon style={{ fontSize: 16 }} />
43
39
  </IconButton>
44
40
  )}>
package/src/Util/index.js CHANGED
@@ -7,7 +7,7 @@ export function parseQuery(str) {
7
7
  return str
8
8
  .replace(/^\?/, '')
9
9
  .split('&')
10
- .map(x => x.split('='))
10
+ .map((x) => x.split('='))
11
11
  .filter(([key]) => !!key)
12
12
  .reduce((memo, x) => {
13
13
  const key = x[0];
@@ -73,7 +73,7 @@ export function getCookieOptions(expireInDays = 1) {
73
73
  return options;
74
74
  }
75
75
 
76
- export const getColor = props => {
76
+ export const getColor = (props) => {
77
77
  if (props.color) {
78
78
  return props.color;
79
79
  }
@@ -85,7 +85,7 @@ export const getColor = props => {
85
85
  return props.theme.palette.text.primary;
86
86
  };
87
87
 
88
- export const getBackground = props => {
88
+ export const getBackground = (props) => {
89
89
  if (props.background) {
90
90
  return props.background;
91
91
  }
@@ -99,14 +99,14 @@ export const getBackground = props => {
99
99
 
100
100
  export function mergeProps(props, component, jsonAttrs = []) {
101
101
  const newProps = Object.assign({}, props);
102
- Object.keys(component.defaultProps || {}).forEach(x => {
102
+ Object.keys(component.defaultProps || {}).forEach((x) => {
103
103
  if (typeof newProps[x] === 'string' && newProps[x].indexOf('::prop::') === 0) {
104
104
  newProps[x] = component.defaultProps[x];
105
105
  }
106
106
  });
107
107
 
108
108
  if (Array.isArray(jsonAttrs)) {
109
- jsonAttrs.forEach(x => {
109
+ jsonAttrs.forEach((x) => {
110
110
  if (typeof newProps[x] === 'string') {
111
111
  try {
112
112
  newProps[x] = JSON.parse(newProps[x]);
@@ -117,7 +117,7 @@ export function mergeProps(props, component, jsonAttrs = []) {
117
117
  });
118
118
  }
119
119
 
120
- Object.keys(newProps).forEach(x => {
120
+ Object.keys(newProps).forEach((x) => {
121
121
  if (typeof newProps[x] === 'string' && newProps[x].indexOf('::prop::') === 0) {
122
122
  newProps[x] = '';
123
123
  }
@@ -128,9 +128,7 @@ export function mergeProps(props, component, jsonAttrs = []) {
128
128
 
129
129
  export function getCopyright(startYear = 2017) {
130
130
  const currentYear = new Date().getFullYear();
131
- return `${currentYear}` === `${startYear}`
132
- ? `© ArcBlock ${currentYear}`
133
- : `© ArcBlock ${startYear} - ${currentYear}`;
131
+ return `${currentYear}` === `${startYear}` ? `© ArcBlock ${currentYear}` : `© ArcBlock ${startYear} - ${currentYear}`;
134
132
  }
135
133
 
136
134
  export const getTimezone = () => {
@@ -145,7 +143,7 @@ export const getTimezone = () => {
145
143
  return '';
146
144
  };
147
145
 
148
- export const str2color = str => {
146
+ export const str2color = (str) => {
149
147
  let hash = 0;
150
148
  for (let i = 0; i < str.length; i++) {
151
149
  hash = str.charCodeAt(i) + ((hash << 5) - hash);
@@ -158,7 +156,7 @@ export const str2color = str => {
158
156
  return colour;
159
157
  };
160
158
 
161
- export const formatUptime = uptime => {
159
+ export const formatUptime = (uptime) => {
162
160
  const total = Math.round(uptime / 1000);
163
161
  const hours = Math.floor(total / 3600);
164
162
  const minutes = Math.floor((total - hours * 3600) / 60);
@@ -180,7 +178,7 @@ export function getDateTool() {
180
178
  }
181
179
 
182
180
  const createDateFormater =
183
- format =>
181
+ (format) =>
184
182
  (date, { locale, tz }) => {
185
183
  if (dateTool === null) {
186
184
  throw new Error('call setDateTool to set the date tool library, such as: setDateTool(dayjs)');
@@ -229,13 +227,7 @@ export function formatToDatetime(date, { locale, tz } = {}) {
229
227
  return createDateFormater('lll')(date, { locale, tz });
230
228
  }
231
229
 
232
- export function openWebWallet({
233
- webWalletUrl,
234
- action = 'login',
235
- locale = 'en',
236
- url,
237
- windowFeatures,
238
- }) {
230
+ export function openWebWallet({ webWalletUrl, action = 'login', locale = 'en', url, windowFeatures }) {
239
231
  // web wallet extension
240
232
  const webWalletExtension = window?.ABT_DEV || window.ABT;
241
233
  if (webWalletExtension && typeof webWalletExtension.open === 'function') {
@@ -259,14 +251,10 @@ export function openWebWallet({
259
251
  width: 414,
260
252
  height: 736,
261
253
  };
262
- const windowUrl = `${webWalletUrl}?action=${action}&locale=${locale}&url=${encodeURIComponent(
263
- url
264
- )}`;
254
+ const windowUrl = `${webWalletUrl}?action=${action}&locale=${locale}&url=${encodeURIComponent(url)}`;
265
255
  const mergedWindowFeatures = Object.assign({}, defaultWindowFeatures, windowFeatures);
266
- const getWindowWidth = win => {
267
- return (
268
- win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth
269
- );
256
+ const getWindowWidth = (win) => {
257
+ return win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth;
270
258
  };
271
259
  // 默认在浏览器右上角弹出窗口
272
260
  if (!('left' in mergedWindowFeatures)) {
@@ -279,7 +267,7 @@ export function openWebWallet({
279
267
  mergedWindowFeatures.top = winTop;
280
268
  }
281
269
  const strWindowFeatures = Object.keys(mergedWindowFeatures)
282
- .map(key => `${key}=${mergedWindowFeatures[key]}`)
270
+ .map((key) => `${key}=${mergedWindowFeatures[key]}`)
283
271
  .join(',');
284
272
  window.open(windowUrl, 'targetWindow', strWindowFeatures);
285
273
  }