@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.
- 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 +44 -27
- package/lib/Datatable/index.js +44 -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 +18 -13
- package/src/Datatable/index.js +13 -12
- 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/Datatable/utils.js
CHANGED
|
@@ -12,18 +12,18 @@ function escapeDangerousCSVCharacters(data) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function buildCSV(columns, data, options) {
|
|
15
|
-
const replaceDoubleQuoteInString = columnData =>
|
|
15
|
+
const replaceDoubleQuoteInString = (columnData) =>
|
|
16
16
|
typeof columnData === 'string' ? columnData.replace(/"/g, '""') : columnData;
|
|
17
17
|
|
|
18
18
|
// eslint-disable-next-line no-shadow
|
|
19
|
-
const buildHead = columns => {
|
|
19
|
+
const buildHead = (columns) => {
|
|
20
20
|
return `${columns
|
|
21
21
|
.reduce(
|
|
22
22
|
(soFar, column) =>
|
|
23
23
|
column.download
|
|
24
|
-
? `${soFar}"${escapeDangerousCSVCharacters(
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
? `${soFar}"${escapeDangerousCSVCharacters(replaceDoubleQuoteInString(column.label || column.name))}"${
|
|
25
|
+
options.downloadOptions.separator
|
|
26
|
+
}`
|
|
27
27
|
: soFar,
|
|
28
28
|
''
|
|
29
29
|
)
|
|
@@ -33,14 +33,14 @@ function buildCSV(columns, data, options) {
|
|
|
33
33
|
const CSVHead = buildHead(columns);
|
|
34
34
|
|
|
35
35
|
// eslint-disable-next-line no-shadow
|
|
36
|
-
const buildBody = data => {
|
|
36
|
+
const buildBody = (data) => {
|
|
37
37
|
if (!data.length) return '';
|
|
38
38
|
return data
|
|
39
39
|
.reduce(
|
|
40
40
|
(soFar, row) =>
|
|
41
41
|
`${soFar}"${row.data
|
|
42
42
|
.filter((_, index) => columns[index].download)
|
|
43
|
-
.map(columnData => escapeDangerousCSVCharacters(replaceDoubleQuoteInString(columnData)))
|
|
43
|
+
.map((columnData) => escapeDangerousCSVCharacters(replaceDoubleQuoteInString(columnData)))
|
|
44
44
|
.join(`"${options.downloadOptions.separator}"`)}"\r\n`,
|
|
45
45
|
''
|
|
46
46
|
)
|
|
@@ -65,8 +65,7 @@ function downloadCSV(csv, filename) {
|
|
|
65
65
|
const dataURI = `data:text/csv;charset=utf-8,${csv}`;
|
|
66
66
|
|
|
67
67
|
const URL = window.URL || window.webkitURL;
|
|
68
|
-
const downloadURI =
|
|
69
|
-
typeof URL.createObjectURL === 'undefined' ? dataURI : URL.createObjectURL(blob);
|
|
68
|
+
const downloadURI = typeof URL.createObjectURL === 'undefined' ? dataURI : URL.createObjectURL(blob);
|
|
70
69
|
|
|
71
70
|
const link = document.createElement('a');
|
|
72
71
|
link.setAttribute('href', downloadURI);
|
|
@@ -98,15 +97,15 @@ export function handleCSVDownload(props) {
|
|
|
98
97
|
columnOrderCopy = columns.map((item, idx) => idx);
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
data.forEach(row => {
|
|
100
|
+
data.forEach((row) => {
|
|
102
101
|
const newRow = { index: row.index, data: [] };
|
|
103
|
-
columnOrderCopy.forEach(idx => {
|
|
102
|
+
columnOrderCopy.forEach((idx) => {
|
|
104
103
|
newRow.data.push(row.data[idx]);
|
|
105
104
|
});
|
|
106
105
|
dataToDownload.push(newRow);
|
|
107
106
|
});
|
|
108
107
|
|
|
109
|
-
columnOrderCopy.forEach(idx => {
|
|
108
|
+
columnOrderCopy.forEach((idx) => {
|
|
110
109
|
columnsToDownload.push(columns[idx]);
|
|
111
110
|
});
|
|
112
111
|
|
|
@@ -120,7 +119,7 @@ export function handleCSVDownload(props) {
|
|
|
120
119
|
row.index = index;
|
|
121
120
|
|
|
122
121
|
return {
|
|
123
|
-
data: row.data.map(column => {
|
|
122
|
+
data: row.data.map((column) => {
|
|
124
123
|
i += 1;
|
|
125
124
|
|
|
126
125
|
// if we have a custom render, which will appear as a react element, we must grab the actual value from data
|
|
@@ -128,19 +127,18 @@ export function handleCSVDownload(props) {
|
|
|
128
127
|
// TODO: Create a utility function for checking whether or not something is a react object
|
|
129
128
|
let val =
|
|
130
129
|
typeof column === 'object' && column !== null && !Array.isArray(column)
|
|
131
|
-
? find(data, d => d.index === row.dataIndex).data[i]
|
|
130
|
+
? find(data, (d) => d.index === row.dataIndex).data[i]
|
|
132
131
|
: column;
|
|
133
|
-
val =
|
|
134
|
-
typeof val === 'function' ? find(data, d => d.index === row.dataIndex).data[i] : val;
|
|
132
|
+
val = typeof val === 'function' ? find(data, (d) => d.index === row.dataIndex).data[i] : val;
|
|
135
133
|
return val;
|
|
136
134
|
}),
|
|
137
135
|
};
|
|
138
136
|
});
|
|
139
137
|
|
|
140
138
|
dataToDownload = [];
|
|
141
|
-
filteredDataToDownload.forEach(row => {
|
|
139
|
+
filteredDataToDownload.forEach((row) => {
|
|
142
140
|
const newRow = { index: row.index, data: [] };
|
|
143
|
-
columnOrderCopy.forEach(idx => {
|
|
141
|
+
columnOrderCopy.forEach((idx) => {
|
|
144
142
|
newRow.data.push(row.data[idx]);
|
|
145
143
|
});
|
|
146
144
|
dataToDownload.push(newRow);
|
|
@@ -149,12 +147,10 @@ export function handleCSVDownload(props) {
|
|
|
149
147
|
|
|
150
148
|
// now, check columns:
|
|
151
149
|
if (options.downloadOptions.filterOptions.useDisplayedColumnsOnly) {
|
|
152
|
-
columnsToDownload = columnsToDownload.filter(_ => _.display === 'true');
|
|
150
|
+
columnsToDownload = columnsToDownload.filter((_) => _.display === 'true');
|
|
153
151
|
|
|
154
|
-
dataToDownload = dataToDownload.map(row => {
|
|
155
|
-
row.data = row.data.filter(
|
|
156
|
-
(_, index) => columns[columnOrderCopy[index]].display === 'true'
|
|
157
|
-
);
|
|
152
|
+
dataToDownload = dataToDownload.map((row) => {
|
|
153
|
+
row.data = row.data.filter((_, index) => columns[columnOrderCopy[index]].display === 'true');
|
|
158
154
|
return row;
|
|
159
155
|
});
|
|
160
156
|
}
|
package/src/Dialog/confirm.js
CHANGED
package/src/Dialog/dialog.js
CHANGED
|
@@ -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 MuiDialog from '@mui/material/Dialog';
|
|
@@ -16,17 +15,7 @@ import CloseIcon from '@mui/icons-material/Close';
|
|
|
16
15
|
* 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
|
|
17
16
|
* - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
children,
|
|
21
|
-
title,
|
|
22
|
-
prepend,
|
|
23
|
-
toolbar,
|
|
24
|
-
actions,
|
|
25
|
-
showCloseButton,
|
|
26
|
-
actionsPosition,
|
|
27
|
-
PaperProps,
|
|
28
|
-
...rest
|
|
29
|
-
}) => {
|
|
18
|
+
function Dialog({ children, title, prepend, toolbar, actions, showCloseButton, actionsPosition, PaperProps, ...rest }) {
|
|
30
19
|
const theme = useTheme();
|
|
31
20
|
// 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
|
|
32
21
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
@@ -48,20 +37,13 @@ const Dialog = ({
|
|
|
48
37
|
);
|
|
49
38
|
|
|
50
39
|
const closeButton = (
|
|
51
|
-
<IconButton
|
|
52
|
-
className="ux-dialog_closeButton"
|
|
53
|
-
onClick={e => handleOnClose(e, 'closeButton')}
|
|
54
|
-
size="large">
|
|
40
|
+
<IconButton className="ux-dialog_closeButton" onClick={(e) => handleOnClose(e, 'closeButton')} size="large">
|
|
55
41
|
<CloseIcon />
|
|
56
42
|
</IconButton>
|
|
57
43
|
);
|
|
58
44
|
|
|
59
45
|
return (
|
|
60
|
-
<StyledMuiDialog
|
|
61
|
-
fullScreen={isMobile}
|
|
62
|
-
onClose={handleOnClose}
|
|
63
|
-
PaperProps={PaperProps}
|
|
64
|
-
{...rest}>
|
|
46
|
+
<StyledMuiDialog fullScreen={isMobile} onClose={handleOnClose} PaperProps={PaperProps} {...rest}>
|
|
65
47
|
{showHeader && (
|
|
66
48
|
<Header className="ux-dialog_header" isMobile={isMobile}>
|
|
67
49
|
<div className="ux-dialog_left">
|
|
@@ -77,12 +59,10 @@ const Dialog = ({
|
|
|
77
59
|
</Header>
|
|
78
60
|
)}
|
|
79
61
|
<MuiDialogContent>{children}</MuiDialogContent>
|
|
80
|
-
{actions &&
|
|
81
|
-
<DialogActions className={`ux-dialog_actions--${actionsPosition}`}>{actions}</DialogActions>
|
|
82
|
-
)}
|
|
62
|
+
{actions && <DialogActions className={`ux-dialog_actions--${actionsPosition}`}>{actions}</DialogActions>}
|
|
83
63
|
</StyledMuiDialog>
|
|
84
64
|
);
|
|
85
|
-
}
|
|
65
|
+
}
|
|
86
66
|
|
|
87
67
|
Dialog.propTypes = {
|
|
88
68
|
children: PropTypes.node.isRequired,
|
|
@@ -109,7 +89,7 @@ Dialog.defaultProps = {
|
|
|
109
89
|
|
|
110
90
|
const StyledMuiDialog = styled(MuiDialog)`
|
|
111
91
|
.MuiDialog-paper {
|
|
112
|
-
${props => (props.fullScreen ? 'border-radius: 0;' : '')};
|
|
92
|
+
${(props) => (props.fullScreen ? 'border-radius: 0;' : '')};
|
|
113
93
|
}
|
|
114
94
|
.MuiDialogContent-root {
|
|
115
95
|
padding: 16px 24px;
|
|
@@ -158,7 +138,7 @@ const Header = styled.div`
|
|
|
158
138
|
}
|
|
159
139
|
.ux-dialog_closeButton {
|
|
160
140
|
/* 使 closeButton 与 content 左/右对齐 */
|
|
161
|
-
${props => (props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;')}
|
|
141
|
+
${(props) => (props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;')}
|
|
162
142
|
}
|
|
163
143
|
`;
|
|
164
144
|
|
package/src/Dialog/index.js
CHANGED
package/src/DriftBot/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
import
|
|
2
|
+
import { Component } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
|
|
5
5
|
import { mergeProps } from '../Util';
|
|
6
6
|
|
|
7
|
-
export default class DriftBot extends
|
|
7
|
+
export default class DriftBot extends Component {
|
|
8
8
|
constructor(props) {
|
|
9
9
|
super(mergeProps(props, DriftBot, ['attributes']));
|
|
10
10
|
|
package/src/Earth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable consistent-return */
|
|
2
|
-
import
|
|
2
|
+
import { useReducer, useRef, useEffect } from 'react';
|
|
3
3
|
import useSpring from 'react-use/lib/useSpring';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import styled from 'styled-components';
|
|
@@ -94,9 +94,7 @@ export default function Earth({
|
|
|
94
94
|
const t = useSpring(state.animateDuration, 170, 26);
|
|
95
95
|
|
|
96
96
|
const isValid =
|
|
97
|
-
activeMarkerId &&
|
|
98
|
-
rotateRef.current.markerId !== activeMarkerId &&
|
|
99
|
-
markers.some(x => x.id === activeMarkerId);
|
|
97
|
+
activeMarkerId && rotateRef.current.markerId !== activeMarkerId && markers.some((x) => x.id === activeMarkerId);
|
|
100
98
|
|
|
101
99
|
// Setup path for globe
|
|
102
100
|
const projection = d3
|
|
@@ -109,9 +107,7 @@ export default function Earth({
|
|
|
109
107
|
geoJson
|
|
110
108
|
)
|
|
111
109
|
.rotate(
|
|
112
|
-
t <= 1 || state.isDragging || !activeMarkerId
|
|
113
|
-
? state.rotation
|
|
114
|
-
: rotateRef.current.iv(t / state.animateDuration)
|
|
110
|
+
t <= 1 || state.isDragging || !activeMarkerId ? state.rotation : rotateRef.current.iv(t / state.animateDuration)
|
|
115
111
|
);
|
|
116
112
|
|
|
117
113
|
const pathGenerator = d3.geoPath().projection(projection).pointRadius(2);
|
|
@@ -123,7 +119,7 @@ export default function Earth({
|
|
|
123
119
|
let { p1, p2, r1, r2, markerId } = rotateRef.current;
|
|
124
120
|
// We should only start new animation if the marker has changed
|
|
125
121
|
if (markerId !== activeMarkerId && !state.isDragging) {
|
|
126
|
-
const marker = markers.find(x => x.id === activeMarkerId);
|
|
122
|
+
const marker = markers.find((x) => x.id === activeMarkerId);
|
|
127
123
|
p1 = p2;
|
|
128
124
|
p2 = [marker.longitude, marker.latitude];
|
|
129
125
|
r1 = r2;
|
|
@@ -151,11 +147,7 @@ export default function Earth({
|
|
|
151
147
|
// Enable auto rotation
|
|
152
148
|
} else if (enableRotation) {
|
|
153
149
|
const handler = window.requestAnimationFrame(() => {
|
|
154
|
-
const newRotation = [
|
|
155
|
-
state.rotation[0] + 2 / rotationSpeed,
|
|
156
|
-
state.rotation[1],
|
|
157
|
-
state.rotation[2],
|
|
158
|
-
];
|
|
150
|
+
const newRotation = [state.rotation[0] + 2 / rotationSpeed, state.rotation[1], state.rotation[2]];
|
|
159
151
|
dispatch({ type: 'rotate', payload: { rotation: newRotation } });
|
|
160
152
|
});
|
|
161
153
|
|
|
@@ -165,18 +157,15 @@ export default function Earth({
|
|
|
165
157
|
}
|
|
166
158
|
});
|
|
167
159
|
|
|
168
|
-
const getMousePosition = event => {
|
|
160
|
+
const getMousePosition = (event) => {
|
|
169
161
|
const node = svgRef.current;
|
|
170
162
|
const rect = node.getBoundingClientRect();
|
|
171
|
-
const mousePosition = [
|
|
172
|
-
event.clientX - rect.left - node.clientLeft,
|
|
173
|
-
event.clientY - rect.top - node.clientTop,
|
|
174
|
-
];
|
|
163
|
+
const mousePosition = [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
|
|
175
164
|
|
|
176
165
|
return mousePosition;
|
|
177
166
|
};
|
|
178
167
|
|
|
179
|
-
const onDragStart = event => {
|
|
168
|
+
const onDragStart = (event) => {
|
|
180
169
|
const mousePosition = getMousePosition(event);
|
|
181
170
|
|
|
182
171
|
if (!mousePosition[0]) {
|
|
@@ -190,7 +179,7 @@ export default function Earth({
|
|
|
190
179
|
dispatch({ type: 'dragStart', payload: { mousePosition } });
|
|
191
180
|
};
|
|
192
181
|
|
|
193
|
-
const onDrag = event => {
|
|
182
|
+
const onDrag = (event) => {
|
|
194
183
|
if (state.isDragging === false) {
|
|
195
184
|
return;
|
|
196
185
|
}
|
|
@@ -217,8 +206,7 @@ export default function Earth({
|
|
|
217
206
|
payload: { tooltipIndex: i, mousePosition: getMousePosition(event) },
|
|
218
207
|
});
|
|
219
208
|
|
|
220
|
-
const onHideTooltip = () =>
|
|
221
|
-
dispatch({ type: 'tooltip', payload: { tooltipIndex: -1, mousePosition: null } });
|
|
209
|
+
const onHideTooltip = () => dispatch({ type: 'tooltip', payload: { tooltipIndex: -1, mousePosition: null } });
|
|
222
210
|
|
|
223
211
|
const renderMarkers = () =>
|
|
224
212
|
markers.map((x, i) => {
|
|
@@ -233,9 +221,9 @@ export default function Earth({
|
|
|
233
221
|
<g
|
|
234
222
|
key={x.id}
|
|
235
223
|
className={`marker ${isActive ? 'marker--active' : ''}`}
|
|
236
|
-
onFocus={event => onShowTooltip(event, i)}
|
|
224
|
+
onFocus={(event) => onShowTooltip(event, i)}
|
|
237
225
|
onBlur={onHideTooltip}
|
|
238
|
-
onMouseOver={event => onShowTooltip(event, i)}
|
|
226
|
+
onMouseOver={(event) => onShowTooltip(event, i)}
|
|
239
227
|
onMouseOut={onHideTooltip}>
|
|
240
228
|
<circle
|
|
241
229
|
key="marker-inner"
|
|
@@ -277,10 +265,10 @@ export default function Earth({
|
|
|
277
265
|
};
|
|
278
266
|
|
|
279
267
|
let activeCountry = null;
|
|
280
|
-
if (activeMarkerId && markers.some(x => x.id === activeMarkerId)) {
|
|
281
|
-
const activeMarker = markers.find(x => x.id === activeMarkerId);
|
|
268
|
+
if (activeMarkerId && markers.some((x) => x.id === activeMarkerId)) {
|
|
269
|
+
const activeMarker = markers.find((x) => x.id === activeMarkerId);
|
|
282
270
|
activeCountry = geoJson.features.findIndex(
|
|
283
|
-
x => x.properties && x.properties.name && x.properties.name === activeMarker.country
|
|
271
|
+
(x) => x.properties && x.properties.name && x.properties.name === activeMarker.country
|
|
284
272
|
);
|
|
285
273
|
}
|
|
286
274
|
|
|
@@ -296,13 +284,7 @@ export default function Earth({
|
|
|
296
284
|
onMouseUp={onDragEnd}
|
|
297
285
|
ref={svgRef}>
|
|
298
286
|
<rect className="frame" width={width} height={height} />
|
|
299
|
-
<circle
|
|
300
|
-
cx={width / 2}
|
|
301
|
-
cy={height / 2}
|
|
302
|
-
r={projection.scale()}
|
|
303
|
-
className="globe"
|
|
304
|
-
filter="url(#glow)"
|
|
305
|
-
/>
|
|
287
|
+
<circle cx={width / 2} cy={height / 2} r={projection.scale()} className="globe" filter="url(#glow)" />
|
|
306
288
|
<path className="graticule" d={pathGenerator(d3.geoGraticule().step([10, 10])())} />
|
|
307
289
|
<g className="features">
|
|
308
290
|
{geoJson.features.map((x, i) => (
|
|
@@ -390,9 +372,9 @@ Earth.defaultProps = {
|
|
|
390
372
|
};
|
|
391
373
|
|
|
392
374
|
const Container = styled.div`
|
|
393
|
-
background-color: ${props => (props.theme === 'light' ? '#f7f7f7' : '#222')};
|
|
394
|
-
width: ${props => props.width}px;
|
|
395
|
-
height: ${props => props.height}px;
|
|
375
|
+
background-color: ${(props) => (props.theme === 'light' ? '#f7f7f7' : '#222')};
|
|
376
|
+
width: ${(props) => props.width}px;
|
|
377
|
+
height: ${(props) => props.height}px;
|
|
396
378
|
position: relative;
|
|
397
379
|
animation-name: zoomIn;
|
|
398
380
|
animation-duration: 1s;
|
|
@@ -411,29 +393,29 @@ const Container = styled.div`
|
|
|
411
393
|
}
|
|
412
394
|
|
|
413
395
|
.country {
|
|
414
|
-
fill: ${props => props.colors.land};
|
|
415
|
-
stroke: ${props => props.colors.border};
|
|
396
|
+
fill: ${(props) => props.colors.land};
|
|
397
|
+
stroke: ${(props) => props.colors.border};
|
|
416
398
|
stroke-width: 0.5px;
|
|
417
399
|
transition: fill 300ms ease;
|
|
418
400
|
|
|
419
401
|
&:hover {
|
|
420
|
-
fill: ${props => props.colors.activeLand};
|
|
402
|
+
fill: ${(props) => props.colors.activeLand};
|
|
421
403
|
}
|
|
422
404
|
}
|
|
423
405
|
|
|
424
406
|
.country--active {
|
|
425
|
-
fill: ${props => props.colors.activeLand};
|
|
407
|
+
fill: ${(props) => props.colors.activeLand};
|
|
426
408
|
}
|
|
427
409
|
|
|
428
410
|
.globe {
|
|
429
|
-
fill: ${props => props.colors.ocean};
|
|
411
|
+
fill: ${(props) => props.colors.ocean};
|
|
430
412
|
stroke: rgba(255, 255, 255, 0.5);
|
|
431
413
|
stroke-width: 0.25px;
|
|
432
414
|
}
|
|
433
415
|
|
|
434
416
|
.graticule {
|
|
435
417
|
fill: none;
|
|
436
|
-
stroke: ${props => props.colors.graticule};
|
|
418
|
+
stroke: ${(props) => props.colors.graticule};
|
|
437
419
|
}
|
|
438
420
|
|
|
439
421
|
.star {
|
|
@@ -494,7 +476,7 @@ const Tooltip = styled.div`
|
|
|
494
476
|
}
|
|
495
477
|
|
|
496
478
|
.description {
|
|
497
|
-
margin-top: ${props => props.theme.spacing(1)}px;
|
|
479
|
+
margin-top: ${(props) => props.theme.spacing(1)}px;
|
|
498
480
|
color: #fff;
|
|
499
481
|
font-size: 12px;
|
|
500
482
|
}
|
package/src/Empty/index.js
CHANGED
|
@@ -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 useTheme from '@mui/styles/useTheme';
|
|
@@ -49,9 +48,9 @@ ErrorFallbackRetry.propTypes = {
|
|
|
49
48
|
|
|
50
49
|
const Root = styled.div`
|
|
51
50
|
padding: 16px;
|
|
52
|
-
border: 2px solid ${props => props.$theme.palette.error.main};
|
|
51
|
+
border: 2px solid ${(props) => props.$theme.palette.error.main};
|
|
53
52
|
border-radius: 4px;
|
|
54
|
-
color: ${props => props.$theme.palette.error.main};
|
|
53
|
+
color: ${(props) => props.$theme.palette.error.main};
|
|
55
54
|
background-color: ${red[50]};
|
|
56
55
|
font-size: 14px;
|
|
57
56
|
h3 {
|
package/src/Footer/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/no-unused-prop-types */
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import styled from 'styled-components';
|
|
5
4
|
import Typography from '@mui/material/Typography';
|
|
@@ -21,10 +20,7 @@ export default function Footer(props) {
|
|
|
21
20
|
<span className="footer-copy">Copyright © {copyYear} </span>
|
|
22
21
|
<span className="footer-brand">{brand}</span>
|
|
23
22
|
</Typography>
|
|
24
|
-
<Typography
|
|
25
|
-
component="p"
|
|
26
|
-
className="footer-item"
|
|
27
|
-
style={{ justifyContent: 'flex-end', flexShrink: 0 }}>
|
|
23
|
+
<Typography component="p" className="footer-item" style={{ justifyContent: 'flex-end', flexShrink: 0 }}>
|
|
28
24
|
Powered by
|
|
29
25
|
<Logo mode={dark ? 'light' : 'dark'} layout="horizontal" className="logo-container" />
|
|
30
26
|
</Typography>
|
|
@@ -52,7 +48,7 @@ Footer.defaultProps = {
|
|
|
52
48
|
const Container = styled.div`
|
|
53
49
|
margin-top: 64px;
|
|
54
50
|
padding: 24px 0 32px;
|
|
55
|
-
border-top: 1px solid ${props => (props.dark ? props.theme.palette.grey[900] : '#dee2e7')};
|
|
51
|
+
border-top: 1px solid ${(props) => (props.dark ? props.theme.palette.grey[900] : '#dee2e7')};
|
|
56
52
|
box-sizing: border-box;
|
|
57
53
|
width: 100%;
|
|
58
54
|
|
|
@@ -66,7 +62,7 @@ const Container = styled.div`
|
|
|
66
62
|
justify-content: space-between;
|
|
67
63
|
|
|
68
64
|
.footer-item {
|
|
69
|
-
color: ${props => props.theme.palette.grey[900]};
|
|
65
|
+
color: ${(props) => props.theme.palette.grey[900]};
|
|
70
66
|
display: flex;
|
|
71
67
|
align-items: center;
|
|
72
68
|
flex-wrap: wrap;
|
package/src/Header/header.js
CHANGED
|
@@ -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 Box from '@mui/material/Box';
|
|
@@ -59,9 +58,9 @@ Header.defaultProps = {
|
|
|
59
58
|
|
|
60
59
|
const Root = styled.div`
|
|
61
60
|
position: relative;
|
|
62
|
-
z-index: ${props => props.$theme.zIndex.appBar};
|
|
61
|
+
z-index: ${(props) => props.$theme.zIndex.appBar};
|
|
63
62
|
font-size: 14px;
|
|
64
|
-
background: ${props => props.$theme.palette.common.white};
|
|
63
|
+
background: ${(props) => props.$theme.palette.common.white};
|
|
65
64
|
.header-container {
|
|
66
65
|
display: flex;
|
|
67
66
|
align-items: center;
|
|
@@ -122,7 +121,7 @@ const Root = styled.div`
|
|
|
122
121
|
padding-right: 0;
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
|
-
${props => props.$theme.breakpoints.down('lg')} {
|
|
124
|
+
${(props) => props.$theme.breakpoints.down('lg')} {
|
|
126
125
|
.header-brand {
|
|
127
126
|
margin-right: 12px;
|
|
128
127
|
.header-brand-title {
|
|
@@ -132,7 +131,7 @@ const Root = styled.div`
|
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
${props => props.$theme.breakpoints.down('md')} {
|
|
134
|
+
${(props) => props.$theme.breakpoints.down('md')} {
|
|
136
135
|
.header-container {
|
|
137
136
|
height: 56px;
|
|
138
137
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import MenuIcon from '@mui/icons-material/Menu';
|
|
@@ -20,9 +20,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
|
20
20
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
21
21
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
22
22
|
const _children =
|
|
23
|
-
typeof children === 'function'
|
|
24
|
-
? children({ isMobile, closeMenu: () => setDrawerOpen(false) })
|
|
25
|
-
: children;
|
|
23
|
+
typeof children === 'function' ? children({ isMobile, closeMenu: () => setDrawerOpen(false) }) : children;
|
|
26
24
|
const { logo, brand, brandAddon, description } = rest;
|
|
27
25
|
// 如果 children 没有值, 则使用普通的 Header 组件渲染 (此时并没有什么内容需要在 menu 中显示)
|
|
28
26
|
if (!children) {
|
|
@@ -32,11 +30,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
|
32
30
|
<Root
|
|
33
31
|
prepend={
|
|
34
32
|
prepend || (
|
|
35
|
-
<Button
|
|
36
|
-
color="inherit"
|
|
37
|
-
edge="start"
|
|
38
|
-
className="header-menu"
|
|
39
|
-
onClick={() => setDrawerOpen(true)}>
|
|
33
|
+
<Button color="inherit" edge="start" className="header-menu" onClick={() => setDrawerOpen(true)}>
|
|
40
34
|
<MenuIcon />
|
|
41
35
|
</Button>
|
|
42
36
|
)
|
|
@@ -81,7 +75,7 @@ const Root = styled(Header)`
|
|
|
81
75
|
.header-menu {
|
|
82
76
|
display: none;
|
|
83
77
|
}
|
|
84
|
-
${props => props.$theme.breakpoints.down('md')} {
|
|
78
|
+
${(props) => props.$theme.breakpoints.down('md')} {
|
|
85
79
|
.header-menu {
|
|
86
80
|
display: block;
|
|
87
81
|
}
|
package/src/Icon/image.js
CHANGED
package/src/Icon/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ const variants = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line react/prop-types
|
|
14
|
-
|
|
14
|
+
function Icon({ name, color, size, variant, rounded, style, className, forwardedRef, ...rest }) {
|
|
15
15
|
const content = (
|
|
16
16
|
<i
|
|
17
17
|
ref={forwardedRef}
|
|
@@ -29,7 +29,7 @@ const Icon = ({ name, color, size, variant, rounded, style, className, forwarded
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return content;
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
Icon.propTypes = {
|
|
35
35
|
name: PropTypes.string.isRequired,
|
|
@@ -51,10 +51,10 @@ Icon.defaultProps = {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const Span = styled.span`
|
|
54
|
-
width: ${props => props.size * 2}px;
|
|
55
|
-
height: ${props => props.size * 2}px;
|
|
54
|
+
width: ${(props) => props.size * 2}px;
|
|
55
|
+
height: ${(props) => props.size * 2}px;
|
|
56
56
|
border-radius: 50%;
|
|
57
|
-
border: 1px solid ${props => props.color};
|
|
57
|
+
border: 1px solid ${(props) => props.color};
|
|
58
58
|
display: flex;
|
|
59
59
|
justify-content: center;
|
|
60
60
|
align-items: center;
|
|
@@ -63,8 +63,8 @@ const Span = styled.span`
|
|
|
63
63
|
.fas,
|
|
64
64
|
.fal,
|
|
65
65
|
.far {
|
|
66
|
-
line-height: ${props => props.size}px;
|
|
66
|
+
line-height: ${(props) => props.size}px;
|
|
67
67
|
}
|
|
68
68
|
`;
|
|
69
69
|
|
|
70
|
-
export default
|
|
70
|
+
export default forwardRef((props, ref) => <Icon {...props} forwardedRef={ref} />);
|
package/src/Img/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { SvgIcon } from '@mui/material';
|
|
@@ -63,6 +63,7 @@ function Img({
|
|
|
63
63
|
onSuccess,
|
|
64
64
|
...rest
|
|
65
65
|
}) {
|
|
66
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
66
67
|
const [ref, inView] = lazy ? useInView({ threshold: 0, triggerOnce: true }) : [null, true];
|
|
67
68
|
|
|
68
69
|
const [imgState, setImgState] = useState('init');
|
|
@@ -81,10 +82,7 @@ function Img({
|
|
|
81
82
|
}
|
|
82
83
|
}, [placeholder, fallback, src, imgState]);
|
|
83
84
|
|
|
84
|
-
const actualRatio =
|
|
85
|
-
if (width && height) return (100 * height) / width;
|
|
86
|
-
return ratio * 100;
|
|
87
|
-
});
|
|
85
|
+
const actualRatio = width && height ? (100 * height) / width : ratio * 100;
|
|
88
86
|
|
|
89
87
|
const mergedStyle = useMemo(
|
|
90
88
|
() => ({
|
|
@@ -94,6 +92,7 @@ function Img({
|
|
|
94
92
|
backgroundRepeat: repeat,
|
|
95
93
|
paddingTop: `${actualRatio}%`,
|
|
96
94
|
}),
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
96
|
[actualSrc, position, size, imgState]
|
|
98
97
|
);
|
|
99
98
|
|
|
@@ -111,7 +110,7 @@ function Img({
|
|
|
111
110
|
setImgState('loaded');
|
|
112
111
|
onSuccess();
|
|
113
112
|
};
|
|
114
|
-
img.onerror = err => {
|
|
113
|
+
img.onerror = (err) => {
|
|
115
114
|
setImgState('error');
|
|
116
115
|
onError(err);
|
|
117
116
|
};
|
|
@@ -119,6 +118,7 @@ function Img({
|
|
|
119
118
|
|
|
120
119
|
useEffect(() => {
|
|
121
120
|
if (inView) loadImg();
|
|
121
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
122
|
}, [inView]);
|
|
123
123
|
|
|
124
124
|
return (
|