@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,76 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Button from '../Button';
4
+ import Dialog from './dialog';
5
+
6
+ // 注意排在 {...rest} 之后的 props 优先级更高
7
+ export default function Confirm({
8
+ title,
9
+ children,
10
+ onConfirm,
11
+ onCancel,
12
+ showCancelButton,
13
+ confirmButton,
14
+ cancelButton,
15
+ PaperProps,
16
+ ...rest
17
+ }) {
18
+ // 去除 dialog 默认的 300 最小高度
19
+ PaperProps.style = Object.assign(
20
+ {
21
+ minHeight: 0,
22
+ },
23
+ PaperProps.style
24
+ );
25
+
26
+ return (
27
+ <Dialog
28
+ title={title}
29
+ PaperProps={PaperProps}
30
+ {...rest}
31
+ onClose={() => onCancel()}
32
+ actions={
33
+ <>
34
+ {showCancelButton && (
35
+ <Button onClick={() => onCancel()} color="primary" {...cancelButton.props}>
36
+ {cancelButton.text}
37
+ </Button>
38
+ )}
39
+ <Button onClick={() => onConfirm()} color="primary" autoFocus {...confirmButton.props}>
40
+ {confirmButton.text}
41
+ </Button>
42
+ </>
43
+ }>
44
+ {children}
45
+ </Dialog>
46
+ );
47
+ }
48
+
49
+ Confirm.propTypes = {
50
+ title: PropTypes.node.isRequired,
51
+ children: PropTypes.node.isRequired,
52
+ onConfirm: PropTypes.func.isRequired,
53
+ onCancel: PropTypes.func.isRequired,
54
+ showCancelButton: PropTypes.bool,
55
+ // 可以传入 {text: ..., props: ...}
56
+ confirmButton: PropTypes.shape({
57
+ text: PropTypes.string.isRequired,
58
+ props: PropTypes.object,
59
+ }),
60
+ cancelButton: PropTypes.shape({
61
+ text: PropTypes.string.isRequired,
62
+ props: PropTypes.object,
63
+ }),
64
+ PaperProps: PropTypes.object,
65
+ };
66
+
67
+ Confirm.defaultProps = {
68
+ showCancelButton: true,
69
+ confirmButton: {
70
+ text: 'Confirm',
71
+ },
72
+ cancelButton: {
73
+ text: 'Cancel',
74
+ },
75
+ PaperProps: {},
76
+ };
@@ -0,0 +1,162 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import MuiDialog from '@material-ui/core/Dialog';
5
+ import MuiDialogContent from '@material-ui/core/DialogContent';
6
+ import DialogActions from '@material-ui/core/DialogActions';
7
+ import IconButton from '@material-ui/core/IconButton';
8
+ import useMediaQuery from '@material-ui/core/useMediaQuery';
9
+ import { useTheme } from '@material-ui/core/styles';
10
+ import CloseIcon from '@material-ui/icons/Close';
11
+
12
+ /**
13
+ * Dialog
14
+ *
15
+ * - 固定尺寸或特殊的尺寸控制需求, 可使用 PaperProps.style (不再提供 width/height 等 props)
16
+ * 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
17
+ * - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
18
+ */
19
+ const Dialog = ({
20
+ children,
21
+ title,
22
+ prepend,
23
+ toolbar,
24
+ actions,
25
+ showCloseButton,
26
+ actionsPosition,
27
+ PaperProps,
28
+ ...rest
29
+ }) => {
30
+ const theme = useTheme();
31
+ // 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
32
+ const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
33
+ const showHeader = title || showCloseButton || toolbar;
34
+ const handleOnClose = (e, reason) => {
35
+ // escapeKeyDown/backdropClick
36
+ const { onClose } = rest;
37
+ if (onClose) {
38
+ onClose(e, reason);
39
+ }
40
+ };
41
+ // 添加默认最小尺寸 (300x300)
42
+ PaperProps.style = Object.assign(
43
+ {
44
+ minWidth: 300,
45
+ minHeight: 300,
46
+ },
47
+ PaperProps.style
48
+ );
49
+
50
+ const closeButton = (
51
+ <IconButton className="ux-dialog_closeButton" onClick={e => handleOnClose(e, 'closeButton')}>
52
+ <CloseIcon />
53
+ </IconButton>
54
+ );
55
+
56
+ return (
57
+ <StyledMuiDialog
58
+ fullScreen={isMobile}
59
+ onClose={handleOnClose}
60
+ PaperProps={PaperProps}
61
+ {...rest}>
62
+ {showHeader && (
63
+ <Header className="ux-dialog_header" isMobile={isMobile}>
64
+ <div className="ux-dialog_left">
65
+ {showCloseButton && isMobile && closeButton}
66
+ {prepend && <div className="ux-dialog_prepend">{prepend}</div>}
67
+ {title && <h6 className="ux-dialog_title">{title}</h6>}
68
+ </div>
69
+
70
+ <div className="ux-dialog_right">
71
+ <div className="ux-dialog_toolbar">{toolbar}</div>
72
+ {showCloseButton && !isMobile && closeButton}
73
+ </div>
74
+ </Header>
75
+ )}
76
+ <MuiDialogContent>{children}</MuiDialogContent>
77
+ {actions && (
78
+ <DialogActions className={`ux-dialog_actions--${actionsPosition}`}>{actions}</DialogActions>
79
+ )}
80
+ </StyledMuiDialog>
81
+ );
82
+ };
83
+
84
+ Dialog.propTypes = {
85
+ children: PropTypes.node.isRequired,
86
+ title: PropTypes.node,
87
+ // 在 title 之前追加内容, 比如返回按钮
88
+ prepend: PropTypes.node,
89
+ // 顶部工具栏, 在 close button 另一侧
90
+ toolbar: PropTypes.node,
91
+ actions: PropTypes.node,
92
+ showCloseButton: PropTypes.bool,
93
+ actionsPosition: PropTypes.oneOf(['left', 'center', 'right']),
94
+ PaperProps: PropTypes.object,
95
+ };
96
+
97
+ Dialog.defaultProps = {
98
+ showCloseButton: true,
99
+ title: '',
100
+ prepend: null,
101
+ toolbar: null,
102
+ actions: null,
103
+ actionsPosition: 'right',
104
+ PaperProps: {},
105
+ };
106
+
107
+ const StyledMuiDialog = styled(MuiDialog)`
108
+ .MuiDialog-paper {
109
+ border-radius: ${props => (props.fullScreen ? 0 : 12)}px;
110
+ }
111
+ .MuiDialogContent-root {
112
+ padding: 16px 24px;
113
+ }
114
+ .MuiDialogActions-root {
115
+ padding: 8px 24px 16px 24px;
116
+ }
117
+ .MuiDialogActions-root.ux-dialog_actions--left {
118
+ justify-content: flex-start;
119
+ }
120
+ .MuiDialogActions-root.ux-dialog_actions--right {
121
+ justify-content: flex-end;
122
+ }
123
+ .MuiDialogActions-root.ux-dialog_actions--center {
124
+ justify-content: center;
125
+ }
126
+ `;
127
+
128
+ const Header = styled.div`
129
+ display: flex;
130
+ justify-content: space-between;
131
+ align-items: center;
132
+ padding: 16px 24px;
133
+ .ux-dialog_left {
134
+ display: flex;
135
+ justify-content: flex-start;
136
+ align-items: center;
137
+ min-width: 0;
138
+ }
139
+ .ux-dialog_right {
140
+ display: flex;
141
+ justify-content: flex-end;
142
+ align-items: center;
143
+ }
144
+ .ux-dialog_toolbar {
145
+ display: flex;
146
+ align-items: center;
147
+ }
148
+ .ux-dialog_title {
149
+ margin: 0;
150
+ font-size: 18px;
151
+ font-weight: 500;
152
+ white-space: nowrap;
153
+ overflow: hidden;
154
+ text-overflow: ellipsis;
155
+ }
156
+ .ux-dialog_closeButton {
157
+ /* 使 closeButton 与 content 左/右对齐 */
158
+ ${props => (props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;')}
159
+ }
160
+ `;
161
+
162
+ export default Dialog;
@@ -0,0 +1,2 @@
1
+ export { default } from './dialog';
2
+ export { default as Confirm } from './confirm';
@@ -0,0 +1,81 @@
1
+ /* eslint-disable max-len */
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+
5
+ import { mergeProps } from '../Util';
6
+
7
+ export default class DriftBot extends React.Component {
8
+ constructor(props) {
9
+ super(mergeProps(props, DriftBot, ['attributes']));
10
+
11
+ this.addMainScript = this.addMainScript.bind(this);
12
+ this.addIdentityVariables = this.addIdentityVariables.bind(this);
13
+ this.insertScript = this.insertScript.bind(this);
14
+ }
15
+
16
+ insertScript(scriptText) {
17
+ const script = document.createElement('script');
18
+ script.innerText = scriptText;
19
+ script.async = true;
20
+ document.body.appendChild(script);
21
+ }
22
+
23
+ addMainScript() {
24
+ const scriptText = `!function() {
25
+ var t = window.driftt = window.drift = window.driftt || [];
26
+ if (!t.init) {
27
+ if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
28
+ t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
29
+ t.factory = function(e) {
30
+ return function() {
31
+ var n = Array.prototype.slice.call(arguments);
32
+ return n.unshift(e), t.push(n), t;
33
+ };
34
+ }, t.methods.forEach(function(e) {
35
+ t[e] = t.factory(e);
36
+ }), t.load = function(t) {
37
+ var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
38
+ o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
39
+ var i = document.getElementsByTagName("script")[0];
40
+ i.parentNode.insertBefore(o, i);
41
+ };
42
+ }
43
+ }();
44
+ drift.SNIPPET_VERSION = '0.3.1';
45
+ drift.load('${this.props.appId}');`;
46
+
47
+ this.insertScript(scriptText);
48
+ }
49
+
50
+ addIdentityVariables() {
51
+ if (typeof this.props.userId !== 'undefined') {
52
+ const scriptText = `
53
+ var t = window.driftt = window.drift = window.driftt || [];
54
+ drift.identify('${this.props.userId}', ${JSON.stringify(this.props.attributes)})
55
+ `;
56
+ this.insertScript(scriptText);
57
+ }
58
+ }
59
+
60
+ componentDidMount() {
61
+ if (typeof window !== 'undefined') {
62
+ this.addMainScript();
63
+ this.addIdentityVariables();
64
+ }
65
+ }
66
+
67
+ render() {
68
+ return '';
69
+ }
70
+ }
71
+
72
+ DriftBot.propTypes = {
73
+ appId: PropTypes.string.isRequired,
74
+ userId: PropTypes.string,
75
+ attributes: PropTypes.object,
76
+ };
77
+
78
+ DriftBot.defaultProps = {
79
+ userId: '',
80
+ attributes: {},
81
+ };