@arcblock/ux 1.16.0 → 1.16.4

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 (90) hide show
  1. package/lib/CodeBlock/index.js +3 -1
  2. package/package.json +6 -5
  3. package/src/ActionButton/index.js +65 -0
  4. package/src/ActivityIndicator/index.js +186 -0
  5. package/src/Alert/index.js +104 -0
  6. package/src/Async/index.js +39 -0
  7. package/src/Badge/index.js +71 -0
  8. package/src/Blocklet/index.js +335 -0
  9. package/src/Button/index.js +4 -0
  10. package/src/Button/wrap.js +88 -0
  11. package/src/ButtonGroup/index.js +19 -0
  12. package/src/Center/index.js +17 -0
  13. package/src/ClickToCopy/index.js +90 -0
  14. package/src/CodeBlock/index.js +160 -0
  15. package/src/Colors/index.js +1 -0
  16. package/src/Colors/themes/default.js +53 -0
  17. package/src/ContactForm/index.js +240 -0
  18. package/src/CookieConsent/index.js +90 -0
  19. package/src/CountDown/index.js +151 -0
  20. package/src/Dialog/confirm.js +76 -0
  21. package/src/Dialog/dialog.js +162 -0
  22. package/src/Dialog/index.js +2 -0
  23. package/src/DriftBot/index.js +81 -0
  24. package/src/Earth/countries.json +8057 -0
  25. package/src/Earth/index.js +511 -0
  26. package/src/Earth/util.js +69 -0
  27. package/src/Empty/index.js +41 -0
  28. package/src/Footer/index.js +84 -0
  29. package/src/Icon/image.js +55 -0
  30. package/src/Icon/index.js +69 -0
  31. package/src/Img/index.js +172 -0
  32. package/src/InfoRow/index.js +83 -0
  33. package/src/Layout/dashboard/header.js +145 -0
  34. package/src/Layout/dashboard/index.js +140 -0
  35. package/src/Layout/dashboard/sidebar.js +120 -0
  36. package/src/Layout/index.js +318 -0
  37. package/src/Locale/browser-lang.js +63 -0
  38. package/src/Locale/context.js +88 -0
  39. package/src/Locale/images/globe-dark.png +0 -0
  40. package/src/Locale/images/globe-light.png +0 -0
  41. package/src/Locale/selector.js +138 -0
  42. package/src/Logo/images/logo-dark-text.svg +3 -0
  43. package/src/Logo/images/logo-dark-top.svg +6 -0
  44. package/src/Logo/images/logo-light-text.svg +3 -0
  45. package/src/Logo/images/logo-light-top.svg +6 -0
  46. package/src/Logo/index.js +47 -0
  47. package/src/Metric/index.js +115 -0
  48. package/src/NFTDisplay/README.md +59 -0
  49. package/src/NFTDisplay/aspect-ratio-container.js +34 -0
  50. package/src/NFTDisplay/broken.js +18 -0
  51. package/src/NFTDisplay/index.js +230 -0
  52. package/src/NFTDisplay/loading.js +17 -0
  53. package/src/NFTDisplay/svg-embedder/img.js +36 -0
  54. package/src/NFTDisplay/svg-embedder/inline-svg.js +37 -0
  55. package/src/PageScroller/index.js +342 -0
  56. package/src/PageScroller/usePrevValue.js +12 -0
  57. package/src/PricingTable/PricingPlan.js +112 -0
  58. package/src/PricingTable/index.js +43 -0
  59. package/src/Screenshot/devices.css +1366 -0
  60. package/src/Screenshot/index.js +181 -0
  61. package/src/Spinner/index.js +33 -0
  62. package/src/Switch/index.js +78 -0
  63. package/src/Tabs/index.js +46 -0
  64. package/src/Tag/index.js +73 -0
  65. package/src/Terminal/Player.js +364 -0
  66. package/src/Terminal/index.js +150 -0
  67. package/src/Terminal/player.css +378 -0
  68. package/src/Terminal/util.js +167 -0
  69. package/src/Terminal/xterm.css +171 -0
  70. package/src/TextCollapse/index.js +92 -0
  71. package/src/Theme/index.js +169 -0
  72. package/src/Theme/responsiveFontSizes.js +94 -0
  73. package/src/Toast/index.js +118 -0
  74. package/src/Util/index.js +264 -0
  75. package/src/Video/index.js +72 -0
  76. package/src/Wallet/Action.js +105 -0
  77. package/src/Wallet/Download.js +130 -0
  78. package/src/Wallet/Open.js +50 -0
  79. package/src/Wallet/images/abtwallet.png +0 -0
  80. package/src/Wallet/images/android_download.svg +23 -0
  81. package/src/Wallet/images/app-store.svg +20 -0
  82. package/src/Wallet/images/google-play.svg +70 -0
  83. package/src/WechatPrompt/images/android.png +0 -0
  84. package/src/WechatPrompt/images/ios.png +0 -0
  85. package/src/WechatPrompt/index.js +81 -0
  86. package/src/index.js +63 -0
  87. package/src/withTheme/index.js +72 -0
  88. package/src/withTracker/README.md +34 -0
  89. package/src/withTracker/error_boundary.js +34 -0
  90. package/src/withTracker/index.js +70 -0
@@ -0,0 +1,181 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+
5
+ import { mergeProps } from '../Util';
6
+
7
+ import './devices.css';
8
+
9
+ const types = {
10
+ 'iphone-x': {
11
+ borderRadius: 32,
12
+ width: 342,
13
+ scale: 0.78,
14
+ },
15
+ 'iphone-8': {
16
+ borderRadius: 0,
17
+ width: 336,
18
+ scale: 0.78,
19
+ },
20
+ 'ipad-pro': {
21
+ borderRadius: 0,
22
+ width: 560,
23
+ scale: 0.62,
24
+ },
25
+ 'imac-pro': {
26
+ borderRadius: 0,
27
+ width: 624,
28
+ scale: 0.56,
29
+ },
30
+ macbook: {
31
+ borderRadius: 0,
32
+ width: 740,
33
+ scale: 0.47,
34
+ },
35
+ 'macbook-pro': {
36
+ borderRadius: 0,
37
+ width: 740,
38
+ scale: 0.47,
39
+ },
40
+ 'surface-pro': {
41
+ borderRadius: 0,
42
+ width: 561,
43
+ scale: 0.62,
44
+ },
45
+ 'surface-book': {
46
+ borderRadius: 0,
47
+ width: 728,
48
+ scale: 0.47,
49
+ },
50
+ 'surface-studio': {
51
+ borderRadius: 0,
52
+ width: 640,
53
+ scale: 0.55,
54
+ },
55
+ 'galaxy-s8': {
56
+ borderRadius: 0,
57
+ width: 321,
58
+ scale: 0.8,
59
+ },
60
+ 'google-pixel': {
61
+ borderRadius: 0,
62
+ width: 360,
63
+ scale: 0.72,
64
+ },
65
+ 'google-pixel-2-xl': {
66
+ borderRadius: 0,
67
+ width: 360,
68
+ scale: 0.72,
69
+ },
70
+ 'apple-watch': {
71
+ borderRadius: 0,
72
+ width: 200,
73
+ scale: 1,
74
+ },
75
+ };
76
+
77
+ const childProps = {
78
+ img: ['alt', 'title', 'src', 'srcSet', 'sizes', 'loading', 'key', 'children'],
79
+ video: ['alt', 'title', 'muted', 'autoplay', 'loop', 'key', 'children'],
80
+ };
81
+
82
+ const createChild = child => [
83
+ React.createElement(
84
+ child.type,
85
+ childProps[child.type].reduce((acc, x) => {
86
+ acc[x] = child.props[x];
87
+ return acc;
88
+ }, {})
89
+ ),
90
+ ];
91
+
92
+ const findChildren = (children, returnArgWhenNotFound = true) => {
93
+ for (let i = 0; i < children.length; i++) {
94
+ const child = children[i];
95
+
96
+ if (['img', 'video'].includes(child.type)) {
97
+ return createChild(child);
98
+ }
99
+
100
+ if (child.props && child.props.children) {
101
+ const subChildren = React.Children.toArray(child.props.children);
102
+ const result = findChildren(subChildren, false);
103
+ if (result) {
104
+ return result;
105
+ }
106
+ }
107
+ }
108
+
109
+ if (returnArgWhenNotFound) {
110
+ return children;
111
+ }
112
+
113
+ return null;
114
+ };
115
+
116
+ // This component is built upon the awesome device.css lib
117
+ // By default it will find and only render img/video tags in the children
118
+ // If neither of them are found, the whole child tree is rendered
119
+ const Screenshot = props => {
120
+ const newProps = mergeProps(props, Screenshot, ['style', 'width', 'height']);
121
+ const { type, children, style, className, width, height, ...rest } = newProps;
122
+ const { zIndex = 0, borderRadius = 0 } = types[type] || {};
123
+
124
+ return (
125
+ <Div
126
+ {...rest}
127
+ type={type}
128
+ className={`device device-${type} ${className}`.trim()}
129
+ style={style}
130
+ contentRadius={borderRadius}
131
+ contentZIndex={zIndex}>
132
+ <div className="device-frame">
133
+ <div className="device-content">{findChildren(React.Children.toArray(children))}</div>
134
+ </div>
135
+ <div className="device-stripe" />
136
+ <div className="device-header" />
137
+ <div className="device-sensors" />
138
+ <div className="device-btns" />
139
+ <div className="device-power" />
140
+ </Div>
141
+ );
142
+ };
143
+
144
+ const Div = styled.div`
145
+ @media (max-width: ${props => types[props.type].width}px) {
146
+ transform-origin: 0 0;
147
+ transform: scale(${props => types[props.type].scale});
148
+ }
149
+ .device-content {
150
+ overflow: hidden;
151
+ }
152
+ .device-content video,
153
+ .device-content img {
154
+ border-radius: ${props => props.contentRadius}px;
155
+ background-color: #fff;
156
+ background-position: center center;
157
+ background-size: cover;
158
+ object-fit: cover;
159
+ width: 100.1%;
160
+ height: 100.1%;
161
+ }
162
+ `;
163
+
164
+ Screenshot.propTypes = {
165
+ type: PropTypes.oneOf(Object.keys(types)),
166
+ children: PropTypes.any.isRequired,
167
+ className: PropTypes.string,
168
+ width: PropTypes.number,
169
+ height: PropTypes.number,
170
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
171
+ };
172
+
173
+ Screenshot.defaultProps = {
174
+ type: 'iphone-x',
175
+ className: '',
176
+ style: '{}',
177
+ width: 0,
178
+ height: 0,
179
+ };
180
+
181
+ export default Screenshot;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import CircularProgress from '@material-ui/core/CircularProgress';
4
+
5
+ /**
6
+ * Spinner
7
+ *
8
+ * 之前的 Spinner 实现由内外 2 个环构成, 现在改为基于 @material-ui/core/CircularProgress 的实现
9
+ *
10
+ * - 之前 size prop 是 array 类型, 需要与 CircularProgress#size 兼容
11
+ * - color 默认使用 #4598fa, 如果调用方传入了 color prop 或 style#color, 则默认 color 被覆盖
12
+ */
13
+ export default function Spinner(props) {
14
+ const _props = { ...props };
15
+ // 兼容之前的 size prop (设置外圈/内圈的尺寸)
16
+ if (_props.size && Array.isArray(_props.size)) {
17
+ [_props.size] = _props.size;
18
+ }
19
+ // 默认 color: #4598fa
20
+ if (!(_props.color || _props.style?.color)) {
21
+ _props.style = { ..._props.style, color: '#4598fa' };
22
+ }
23
+ return <CircularProgress {..._props} />;
24
+ }
25
+
26
+ Spinner.propTypes = {
27
+ // 改为基于 @material-ui/core/CircularProgress 的实现后, 该 prop 将被废弃
28
+ duration: PropTypes.array,
29
+ };
30
+
31
+ Spinner.defaultProps = {
32
+ duration: [1, 1.6],
33
+ };
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { withStyles } from '@material-ui/core/styles';
4
+ import FormControlLabel from '@material-ui/core/FormControlLabel';
5
+ import MuiSwitch from '@material-ui/core/Switch';
6
+
7
+ // 参考: https://v4.mui.com/components/switches/
8
+ const IOSSwitch = withStyles(theme => ({
9
+ root: {
10
+ width: 42,
11
+ height: 26,
12
+ padding: 0,
13
+ margin: theme.spacing(1),
14
+ },
15
+ switchBase: {
16
+ padding: 1,
17
+ '&$checked': {
18
+ transform: 'translateX(16px)',
19
+ color: theme.palette.common.white,
20
+ '& + $track': {
21
+ backgroundColor: '#52d869',
22
+ opacity: 1,
23
+ border: 'none',
24
+ },
25
+ },
26
+ '&$focusVisible $thumb': {
27
+ color: '#52d869',
28
+ border: '6px solid #fff',
29
+ },
30
+ },
31
+ thumb: {
32
+ width: 24,
33
+ height: 24,
34
+ },
35
+ track: {
36
+ // fix: 下边框截断问题
37
+ boxSizing: 'border-box',
38
+ borderRadius: 26 / 2,
39
+ border: `1px solid ${theme.palette.grey[400]}`,
40
+ backgroundColor: theme.palette.grey[50],
41
+ opacity: 1,
42
+ transition: theme.transitions.create(['background-color', 'border']),
43
+ },
44
+ checked: {},
45
+ focusVisible: {},
46
+ }))(({ classes, ...props }) => {
47
+ return (
48
+ <MuiSwitch
49
+ focusVisibleClassName={classes.focusVisible}
50
+ disableRipple
51
+ classes={{
52
+ root: classes.root,
53
+ switchBase: classes.switchBase,
54
+ thumb: classes.thumb,
55
+ track: classes.track,
56
+ checked: classes.checked,
57
+ }}
58
+ {...props}
59
+ />
60
+ );
61
+ });
62
+
63
+ /**
64
+ * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
65
+ * 兼容 mui Switch props, 使用 labelProps 控制 FormControlLabel
66
+ */
67
+ function Switch({ labelProps, ...rest }) {
68
+ return <FormControlLabel control={<IOSSwitch {...rest} />} {...labelProps} />;
69
+ }
70
+
71
+ Switch.propTypes = {
72
+ labelProps: PropTypes.object,
73
+ };
74
+ Switch.defaultProps = {
75
+ labelProps: {},
76
+ };
77
+
78
+ export default Switch;
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { makeStyles } from '@material-ui/core';
4
+ import MuiTabs from '@material-ui/core/Tabs';
5
+ import MuiTab from '@material-ui/core/Tab';
6
+
7
+ const useStyles = makeStyles(theme => ({
8
+ tabs: {},
9
+ tab: {
10
+ fontSize: '0.875rem',
11
+ [theme.breakpoints.up('md')]: {
12
+ fontSize: '1rem',
13
+ },
14
+ },
15
+ }));
16
+
17
+ export default function Tabs({ tabs, current, onChange, ...rest }) {
18
+ const classes = useStyles();
19
+
20
+ return (
21
+ <MuiTabs
22
+ scrollButtons="on"
23
+ variant="scrollable"
24
+ value={current}
25
+ onChange={(_, newValue) => onChange(newValue)}
26
+ indicatorColor="primary"
27
+ {...rest}
28
+ className={[classes.tabs, rest.className || ''].join(' ')}>
29
+ {tabs.map(x => (
30
+ <MuiTab
31
+ className={classes.tab}
32
+ key={x.value}
33
+ value={x.value}
34
+ label={x.label}
35
+ icon={x.icon || null}
36
+ />
37
+ ))}
38
+ </MuiTabs>
39
+ );
40
+ }
41
+
42
+ Tabs.propTypes = {
43
+ tabs: PropTypes.array.isRequired,
44
+ current: PropTypes.string.isRequired,
45
+ onChange: PropTypes.func.isRequired,
46
+ };
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+
5
+ import Typography from '@material-ui/core/Typography';
6
+
7
+ import { mergeProps } from '../Util';
8
+ import colors from '../Colors';
9
+
10
+ const types = {
11
+ error: {
12
+ color: colors.error.main,
13
+ backgroundColor: 'rgba(227, 91, 84, 0.2)',
14
+ },
15
+ warning: {
16
+ color: colors.warning.main,
17
+ backgroundColor: 'rgba(247, 208, 64, 0.2)',
18
+ },
19
+ success: {
20
+ color: colors.success.main,
21
+ backgroundColor: '#eafbd9',
22
+ },
23
+ primary: {
24
+ color: colors.primary.main,
25
+ backgroundColor: '#ECEFFF',
26
+ },
27
+ reverse: {
28
+ color: '#fff',
29
+ backgroundColor: '#222',
30
+ },
31
+ };
32
+
33
+ function Tag(props) {
34
+ const newProps = mergeProps(props, Tag, ['style']);
35
+ const { type, content, children, style, className, forwardedRef, ...rest } = newProps;
36
+ const styles = Object.assign({}, types[type] || types.primary, style);
37
+
38
+ return (
39
+ <Span ref={forwardedRef} component="span" className={className} style={styles} {...rest}>
40
+ {content || children}
41
+ </Span>
42
+ );
43
+ }
44
+
45
+ Tag.propTypes = {
46
+ children: PropTypes.any.isRequired,
47
+ type: PropTypes.oneOf(Object.keys(types)),
48
+ content: PropTypes.string,
49
+ className: PropTypes.string,
50
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
51
+ };
52
+
53
+ Tag.defaultProps = {
54
+ type: 'primary',
55
+ content: '',
56
+ className: '',
57
+ style: {},
58
+ };
59
+
60
+ export default React.forwardRef((props, ref) => <Tag {...props} forwardedRef={ref} />);
61
+
62
+ const Span = styled(Typography)`
63
+ && {
64
+ display: inline-flex;
65
+ justify-content: center;
66
+ align-items: center;
67
+ padding: 2px 10px;
68
+ height: 20px;
69
+ line-height: 20px;
70
+ font-size: 12px;
71
+ font-weight: 500;
72
+ }
73
+ `;