@arcblock/ux 2.6.9 → 2.7.0
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/babel.config.es.js +12 -0
- package/es/ActionButton/index.js +99 -0
- package/es/ActivityIndicator/index.js +180 -0
- package/es/Address/compact-text.js +105 -0
- package/es/Address/did-address.js +211 -0
- package/es/Address/index.js +23 -0
- package/es/Address/responsive-did-address.js +88 -0
- package/es/Alert/index.js +134 -0
- package/es/AnimationWaiter/default-animation.json +1 -0
- package/es/AnimationWaiter/index.js +239 -0
- package/es/Async/index.js +38 -0
- package/es/Avatar/did-motif.js +64 -0
- package/es/Avatar/etherscan-blockies.js +83 -0
- package/es/Avatar/index.js +176 -0
- package/es/Badge/index.js +98 -0
- package/es/Blocklet/blocklet.js +298 -0
- package/es/Blocklet/index.js +4 -0
- package/es/Blocklet/utils.js +52 -0
- package/es/BlockletNFT/index.js +412 -0
- package/es/Button/index.js +8 -0
- package/es/Button/wrap.js +140 -0
- package/es/ButtonGroup/index.js +6 -0
- package/es/CardSelector/index.js +131 -0
- package/es/Center/index.js +41 -0
- package/es/ClickToCopy/copy-button.js +72 -0
- package/es/ClickToCopy/hook.js +39 -0
- package/es/ClickToCopy/index.js +93 -0
- package/es/CodeBlock/LightBox.js +85 -0
- package/es/CodeBlock/index.js +226 -0
- package/es/Colors/index.js +2 -0
- package/es/Colors/themes/default.js +78 -0
- package/es/ContactForm/index.js +230 -0
- package/es/CookieConsent/index.js +113 -0
- package/es/CountDown/index.js +178 -0
- package/es/DID/index.js +105 -0
- package/es/Datatable/CustomToolbar.js +396 -0
- package/es/Datatable/DatatableContext.js +34 -0
- package/es/Datatable/TableSearch.js +165 -0
- package/es/Datatable/index.js +627 -0
- package/es/Datatable/utils.js +132 -0
- package/es/Dialog/confirm.js +90 -0
- package/es/Dialog/dialog.js +192 -0
- package/es/Dialog/index.js +3 -0
- package/es/DidLogo/index.js +31 -0
- package/es/DriftBot/index.js +70 -0
- package/es/Earth/countries.json +8057 -0
- package/es/Earth/index.js +521 -0
- package/es/Earth/util.js +51 -0
- package/es/Empty/index.js +64 -0
- package/es/ErrorBoundary/fallback.js +73 -0
- package/es/ErrorBoundary/index.js +1 -0
- package/es/Footer/index.js +172 -0
- package/es/Header/auto-hidden.js +35 -0
- package/es/Header/header.js +211 -0
- package/es/Header/index.js +2 -0
- package/es/Header/responsive-header.js +111 -0
- package/es/Icon/image.js +65 -0
- package/es/Icon/index.js +84 -0
- package/es/Img/index.js +217 -0
- package/es/InfoRow/index.js +87 -0
- package/es/Layout/dashboard/external-link.js +58 -0
- package/es/Layout/dashboard/full-page.js +53 -0
- package/es/Layout/dashboard/index.js +275 -0
- package/es/Layout/dashboard/sidebar.js +209 -0
- package/es/Layout/dashboard-legacy/header.js +174 -0
- package/es/Layout/dashboard-legacy/index.js +149 -0
- package/es/Layout/dashboard-legacy/sidebar.js +129 -0
- package/es/Layout/index.js +335 -0
- package/es/Locale/browser-lang.js +52 -0
- package/es/Locale/context.js +114 -0
- package/es/Locale/languages.js +60 -0
- package/es/Locale/selector.js +180 -0
- package/es/Locale/util.js +13 -0
- package/es/Logo/images/logo-dark-text.svg +3 -0
- package/es/Logo/images/logo-dark-top.svg +6 -0
- package/es/Logo/images/logo-light-text.svg +3 -0
- package/es/Logo/images/logo-light-top.svg +6 -0
- package/es/Logo/index.js +136 -0
- package/es/Metric/index.js +132 -0
- package/es/NFTDisplay/README.md +59 -0
- package/es/NFTDisplay/aspect-ratio-container.js +39 -0
- package/es/NFTDisplay/broken.js +18 -0
- package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
- package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
- package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
- package/es/NFTDisplay/index.js +323 -0
- package/es/NFTDisplay/loading.js +18 -0
- package/es/NFTDisplay/svg-embedder/img.js +45 -0
- package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
- package/es/NavMenu/index.js +2 -0
- package/es/NavMenu/nav-menu.js +286 -0
- package/es/NavMenu/style.js +176 -0
- package/es/PageScroller/index.js +286 -0
- package/es/PageScroller/story/FifthComponent.js +9 -0
- package/es/PageScroller/story/FirstComponent.js +9 -0
- package/es/PageScroller/story/FourthComponent.js +12 -0
- package/es/PageScroller/story/FullPage.js +47 -0
- package/es/PageScroller/story/PageContain.js +59 -0
- package/es/PageScroller/story/SecondComponent.js +9 -0
- package/es/PageScroller/story/ThirdComponent.js +9 -0
- package/es/PageScroller/story/index.css +115 -0
- package/es/PageScroller/usePrevValue.js +9 -0
- package/es/PricingTable/PricingPlan.js +124 -0
- package/es/PricingTable/index.js +53 -0
- package/es/QRCode/index.js +72 -0
- package/es/RelativeTime/index.js +98 -0
- package/es/Result/common.js +140 -0
- package/es/Result/demo/fixtures/result-image-404.svg +1 -0
- package/es/Result/index.js +33 -0
- package/es/Result/result.js +59 -0
- package/es/Result/translations.js +54 -0
- package/es/Screenshot/BaseScreenshot/index.js +91 -0
- package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
- package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
- package/es/Screenshot/demo/images/bg-00.jpg +0 -0
- package/es/Screenshot/demo/images/bg-01.jpg +0 -0
- package/es/Screenshot/demo/images/bg-02.jpg +0 -0
- package/es/Screenshot/demo/images/bg-03.jpg +0 -0
- package/es/Screenshot/demo/images/bg-04.jpg +0 -0
- package/es/Screenshot/demo/images/bg-05.jpg +0 -0
- package/es/Screenshot/demo/images/bg-06.jpg +0 -0
- package/es/Screenshot/demo/images/bg-07.jpg +0 -0
- package/es/Screenshot/demo/images/bg-08.jpg +0 -0
- package/es/Screenshot/demo/images/bg-09.jpg +0 -0
- package/es/Screenshot/devices.css +1366 -0
- package/es/Screenshot/index.js +299 -0
- package/es/SessionManager/federated-login-detecter.js +166 -0
- package/es/SessionManager/index.js +468 -0
- package/es/SessionManager/user-popper.js +132 -0
- package/es/Sparkline/index.js +193 -0
- package/es/Spinner/index.js +28 -0
- package/es/SplitButton/index.js +144 -0
- package/es/Switch/index.js +96 -0
- package/es/Tabs/index.js +48 -0
- package/es/Tag/index.js +108 -0
- package/es/TextCollapse/index.js +92 -0
- package/es/Theme/index.js +16 -0
- package/es/Theme/theme-provider.js +39 -0
- package/es/Theme/theme.js +133 -0
- package/es/Toast/index.js +95 -0
- package/es/Util/deprecate.js +28 -0
- package/es/Util/index.js +298 -0
- package/es/Util/wallet.js +32 -0
- package/es/Video/index.js +89 -0
- package/es/Wallet/Action.js +119 -0
- package/es/Wallet/Download.js +331 -0
- package/es/Wallet/Open.js +45 -0
- package/es/Wallet/images/abtwallet.png +0 -0
- package/es/Wallet/images/android_download.svg +23 -0
- package/es/Wallet/images/app-store.svg +20 -0
- package/es/Wallet/images/google-play.svg +70 -0
- package/es/WebWalletSWKeeper/index.js +115 -0
- package/es/WechatPrompt/images/android.png +0 -0
- package/es/WechatPrompt/images/ios.png +0 -0
- package/es/WechatPrompt/index.js +88 -0
- package/es/index.js +38 -0
- package/es/withTheme/index.js +69 -0
- package/es/withTracker/README.md +34 -0
- package/es/withTracker/error_boundary.js +34 -0
- package/es/withTracker/index.js +56 -0
- package/package.json +272 -5
@@ -0,0 +1,132 @@
|
|
1
|
+
import find from 'lodash/find';
|
2
|
+
function escapeDangerousCSVCharacters(data) {
|
3
|
+
if (typeof data === 'string') {
|
4
|
+
// Places single quote before the appearance of dangerous characters if they
|
5
|
+
// are the first in the data string.
|
6
|
+
// eslint-disable-next-line no-useless-escape
|
7
|
+
return data.replace(/^\+|^\-|^\=|^\@/g, "'$&");
|
8
|
+
}
|
9
|
+
return data;
|
10
|
+
}
|
11
|
+
function buildCSV(columns, data, options) {
|
12
|
+
const replaceDoubleQuoteInString = columnData => typeof columnData === 'string' ? columnData.replace(/"/g, '""') : columnData;
|
13
|
+
|
14
|
+
// eslint-disable-next-line no-shadow
|
15
|
+
const buildHead = columns => {
|
16
|
+
return `${columns.reduce((soFar, column) => column.download ? `${soFar}"${escapeDangerousCSVCharacters(replaceDoubleQuoteInString(column.label || column.name))}"${options.downloadOptions.separator}` : soFar, '').slice(0, -1)}\r\n`;
|
17
|
+
};
|
18
|
+
const CSVHead = buildHead(columns);
|
19
|
+
|
20
|
+
// eslint-disable-next-line no-shadow
|
21
|
+
const buildBody = data => {
|
22
|
+
if (!data.length) return '';
|
23
|
+
return data.reduce((soFar, row) => `${soFar}"${row.data.filter((_, index) => columns[index].download).map(columnData => escapeDangerousCSVCharacters(replaceDoubleQuoteInString(columnData))).join(`"${options.downloadOptions.separator}"`)}"\r\n`, '').trim();
|
24
|
+
};
|
25
|
+
const CSVBody = buildBody(data);
|
26
|
+
const csv = options.onDownload ? options.onDownload(buildHead, buildBody, columns, data) : `${CSVHead}${CSVBody}`.trim();
|
27
|
+
return csv;
|
28
|
+
}
|
29
|
+
function downloadCSV(csv, filename) {
|
30
|
+
const blob = new Blob([csv], {
|
31
|
+
type: 'text/csv'
|
32
|
+
});
|
33
|
+
|
34
|
+
/* taken from react-csv */
|
35
|
+
if (navigator && navigator.msSaveOrOpenBlob) {
|
36
|
+
navigator.msSaveOrOpenBlob(blob, filename);
|
37
|
+
} else {
|
38
|
+
const dataURI = `data:text/csv;charset=utf-8,${csv}`;
|
39
|
+
const URL = window.URL || window.webkitURL;
|
40
|
+
const downloadURI = typeof URL.createObjectURL === 'undefined' ? dataURI : URL.createObjectURL(blob);
|
41
|
+
const link = document.createElement('a');
|
42
|
+
link.setAttribute('href', downloadURI);
|
43
|
+
link.setAttribute('download', filename);
|
44
|
+
document.body.appendChild(link);
|
45
|
+
link.click();
|
46
|
+
document.body.removeChild(link);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
// eslint-disable-next-line no-shadow
|
51
|
+
function createCSVDownload(columns, data, options, downloadCSV) {
|
52
|
+
const csv = buildCSV(columns, data, options);
|
53
|
+
if (options.onDownload && csv === false) {
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
downloadCSV(csv, options.downloadOptions.filename);
|
57
|
+
}
|
58
|
+
export function handleCSVDownload(props) {
|
59
|
+
const {
|
60
|
+
data,
|
61
|
+
displayData,
|
62
|
+
columns,
|
63
|
+
options,
|
64
|
+
columnOrder
|
65
|
+
} = props;
|
66
|
+
let dataToDownload = [];
|
67
|
+
let columnsToDownload = [];
|
68
|
+
let columnOrderCopy = Array.isArray(columnOrder) ? columnOrder.slice(0) : [];
|
69
|
+
if (columnOrderCopy.length === 0) {
|
70
|
+
columnOrderCopy = columns.map((item, idx) => idx);
|
71
|
+
}
|
72
|
+
data.forEach(row => {
|
73
|
+
const newRow = {
|
74
|
+
index: row.index,
|
75
|
+
data: []
|
76
|
+
};
|
77
|
+
columnOrderCopy.forEach(idx => {
|
78
|
+
newRow.data.push(row.data[idx]);
|
79
|
+
});
|
80
|
+
dataToDownload.push(newRow);
|
81
|
+
});
|
82
|
+
columnOrderCopy.forEach(idx => {
|
83
|
+
columnsToDownload.push(columns[idx]);
|
84
|
+
});
|
85
|
+
if (options.downloadOptions && options.downloadOptions.filterOptions) {
|
86
|
+
// check rows first:
|
87
|
+
if (options.downloadOptions.filterOptions.useDisplayedRowsOnly) {
|
88
|
+
const filteredDataToDownload = displayData.map((row, index) => {
|
89
|
+
let i = -1;
|
90
|
+
|
91
|
+
// Help to preserve sort order in custom render columns
|
92
|
+
row.index = index;
|
93
|
+
return {
|
94
|
+
data: row.data.map(column => {
|
95
|
+
i += 1;
|
96
|
+
|
97
|
+
// if we have a custom render, which will appear as a react element, we must grab the actual value from data
|
98
|
+
// that matches the dataIndex and column
|
99
|
+
// TODO: Create a utility function for checking whether or not something is a react object
|
100
|
+
let val = typeof column === 'object' && column !== null && !Array.isArray(column) ? find(data, d => d.index === row.dataIndex).data[i] : column;
|
101
|
+
val = typeof val === 'function' ? find(data, d => d.index === row.dataIndex).data[i] : val;
|
102
|
+
return val;
|
103
|
+
})
|
104
|
+
};
|
105
|
+
});
|
106
|
+
dataToDownload = [];
|
107
|
+
filteredDataToDownload.forEach(row => {
|
108
|
+
const newRow = {
|
109
|
+
index: row.index,
|
110
|
+
data: []
|
111
|
+
};
|
112
|
+
columnOrderCopy.forEach(idx => {
|
113
|
+
newRow.data.push(row.data[idx]);
|
114
|
+
});
|
115
|
+
dataToDownload.push(newRow);
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
// now, check columns:
|
120
|
+
if (options.downloadOptions.filterOptions.useDisplayedColumnsOnly) {
|
121
|
+
columnsToDownload = columnsToDownload.filter(_ => _.display === 'true');
|
122
|
+
dataToDownload = dataToDownload.map(row => {
|
123
|
+
row.data = row.data.filter((_, index) => columns[columnOrderCopy[index]].display === 'true');
|
124
|
+
return row;
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
createCSVDownload(columnsToDownload, dataToDownload, options, downloadCSV);
|
129
|
+
}
|
130
|
+
export default {
|
131
|
+
handleCSVDownload
|
132
|
+
};
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import Button from '../Button';
|
3
|
+
import Dialog from './dialog';
|
4
|
+
|
5
|
+
/**
|
6
|
+
@typedef {Object} ConfirmProps
|
7
|
+
@property {boolean} open
|
8
|
+
@property {React.ReactNode} title
|
9
|
+
@property {React.ReactNode} children
|
10
|
+
@property {() => void | Promise<void>} onConfirm
|
11
|
+
@property {() => void | Promise<void>} onCancel
|
12
|
+
@property {boolean} [showCancelButton=true]
|
13
|
+
@property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
|
14
|
+
@property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
|
15
|
+
@property {import('@mui/material').PaperProps} [PaperProps={}]
|
16
|
+
*/
|
17
|
+
|
18
|
+
// 注意排在 {...rest} 之后的 props 优先级更高
|
19
|
+
/**
|
20
|
+
*
|
21
|
+
* @param {ConfirmProps} props
|
22
|
+
* @returns {import('react').ReactComponentElement}
|
23
|
+
*/
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
26
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
27
|
+
export default function Confirm({
|
28
|
+
title,
|
29
|
+
children,
|
30
|
+
onConfirm,
|
31
|
+
onCancel,
|
32
|
+
showCancelButton,
|
33
|
+
confirmButton,
|
34
|
+
cancelButton,
|
35
|
+
PaperProps,
|
36
|
+
...rest
|
37
|
+
}) {
|
38
|
+
// 去除 dialog 默认的 300 最小高度
|
39
|
+
PaperProps.style = Object.assign({
|
40
|
+
minHeight: 0
|
41
|
+
}, PaperProps.style);
|
42
|
+
return /*#__PURE__*/_jsx(Dialog, {
|
43
|
+
title: title,
|
44
|
+
PaperProps: PaperProps,
|
45
|
+
...rest,
|
46
|
+
onClose: () => onCancel(),
|
47
|
+
actions: /*#__PURE__*/_jsxs(_Fragment, {
|
48
|
+
children: [showCancelButton && /*#__PURE__*/_jsx(Button, {
|
49
|
+
onClick: () => onCancel(),
|
50
|
+
color: "primary",
|
51
|
+
...cancelButton.props,
|
52
|
+
children: cancelButton.text
|
53
|
+
}), /*#__PURE__*/_jsx(Button, {
|
54
|
+
onClick: () => onConfirm(),
|
55
|
+
color: "primary",
|
56
|
+
autoFocus: true,
|
57
|
+
...confirmButton.props,
|
58
|
+
children: confirmButton.text
|
59
|
+
})]
|
60
|
+
}),
|
61
|
+
children: children
|
62
|
+
});
|
63
|
+
}
|
64
|
+
Confirm.propTypes = {
|
65
|
+
title: PropTypes.node.isRequired,
|
66
|
+
children: PropTypes.node.isRequired,
|
67
|
+
onConfirm: PropTypes.func.isRequired,
|
68
|
+
onCancel: PropTypes.func.isRequired,
|
69
|
+
showCancelButton: PropTypes.bool,
|
70
|
+
// 可以传入 {text: ..., props: ...}
|
71
|
+
confirmButton: PropTypes.shape({
|
72
|
+
text: PropTypes.string.isRequired,
|
73
|
+
props: PropTypes.object
|
74
|
+
}),
|
75
|
+
cancelButton: PropTypes.shape({
|
76
|
+
text: PropTypes.string.isRequired,
|
77
|
+
props: PropTypes.object
|
78
|
+
}),
|
79
|
+
PaperProps: PropTypes.object
|
80
|
+
};
|
81
|
+
Confirm.defaultProps = {
|
82
|
+
showCancelButton: true,
|
83
|
+
confirmButton: {
|
84
|
+
text: 'Confirm'
|
85
|
+
},
|
86
|
+
cancelButton: {
|
87
|
+
text: 'Cancel'
|
88
|
+
},
|
89
|
+
PaperProps: {}
|
90
|
+
};
|
@@ -0,0 +1,192 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import MuiDialog from '@mui/material/Dialog';
|
3
|
+
import MuiDialogContent from '@mui/material/DialogContent';
|
4
|
+
import DialogActions from '@mui/material/DialogActions';
|
5
|
+
import IconButton from '@mui/material/IconButton';
|
6
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
7
|
+
import CloseIcon from '@mui/icons-material/Close';
|
8
|
+
import { styled, useTheme } from '../Theme';
|
9
|
+
|
10
|
+
/**
|
11
|
+
@typedef {import('@mui/material').PaperProps & {
|
12
|
+
minWidth: number | string,
|
13
|
+
minHeight: number | string,
|
14
|
+
}} PaperStyle
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
@typedef {Object} DialogProps
|
19
|
+
@property {React.ReactNode} children - The content of the dialog.
|
20
|
+
@property {React.ReactNode} [title] - The title of the dialog.
|
21
|
+
@property {React.ReactNode} [prepend] - Content to be displayed before the dialog title.
|
22
|
+
@property {React.ReactNode} [toolbar] - Content to be displayed in the top toolbar of the dialog.
|
23
|
+
@property {React.ReactNode} [actions] - Content to be displayed in the bottom actions toolbar of the dialog.
|
24
|
+
@property {boolean} [showCloseButton=true] - Whether or not to show the close button.
|
25
|
+
@property {'left'|'center'|'right'} [actionsPosition='right'] - The position of the actions toolbar.
|
26
|
+
@property {PaperStyle} [PaperProps] - Props to be passed down to the dialog paper.
|
27
|
+
@property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
|
28
|
+
*/
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Dialog
|
32
|
+
*
|
33
|
+
* - 固定尺寸或特殊的尺寸控制需求, 可使用 PaperProps.style (不再提供 width/height 等 props)
|
34
|
+
* 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
|
35
|
+
* - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
|
36
|
+
*/
|
37
|
+
/**
|
38
|
+
* @description
|
39
|
+
* @param {DialogProps} props
|
40
|
+
* @return {React.ReactComponentElement<any, DialogProps>}
|
41
|
+
*/
|
42
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
43
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
44
|
+
function Dialog({
|
45
|
+
children,
|
46
|
+
title,
|
47
|
+
prepend,
|
48
|
+
toolbar,
|
49
|
+
actions,
|
50
|
+
showCloseButton,
|
51
|
+
actionsPosition,
|
52
|
+
PaperProps,
|
53
|
+
...rest
|
54
|
+
}) {
|
55
|
+
const theme = useTheme();
|
56
|
+
// 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
|
57
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
58
|
+
const showHeader = title || showCloseButton || toolbar;
|
59
|
+
const handleOnClose = (e, reason) => {
|
60
|
+
// escapeKeyDown/backdropClick
|
61
|
+
const {
|
62
|
+
onClose
|
63
|
+
} = rest;
|
64
|
+
if (onClose) {
|
65
|
+
onClose(e, reason);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
// 添加默认最小尺寸 (300x300)
|
69
|
+
PaperProps.style = Object.assign({
|
70
|
+
minWidth: 300,
|
71
|
+
minHeight: 300
|
72
|
+
}, PaperProps.style);
|
73
|
+
const closeButton = /*#__PURE__*/_jsx(IconButton, {
|
74
|
+
className: "ux-dialog_closeButton",
|
75
|
+
onClick: e => handleOnClose(e, 'closeButton'),
|
76
|
+
size: "large",
|
77
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
78
|
+
});
|
79
|
+
return /*#__PURE__*/_jsxs(StyledMuiDialog, {
|
80
|
+
fullScreen: isMobile,
|
81
|
+
onClose: handleOnClose,
|
82
|
+
PaperProps: PaperProps,
|
83
|
+
...rest,
|
84
|
+
children: [showHeader && /*#__PURE__*/_jsxs(Header, {
|
85
|
+
className: "ux-dialog_header",
|
86
|
+
isMobile: isMobile,
|
87
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
88
|
+
className: "ux-dialog_left",
|
89
|
+
children: [showCloseButton && isMobile && closeButton, prepend && /*#__PURE__*/_jsx("div", {
|
90
|
+
className: "ux-dialog_prepend",
|
91
|
+
children: prepend
|
92
|
+
}), title && /*#__PURE__*/_jsx("h6", {
|
93
|
+
className: "ux-dialog_title",
|
94
|
+
children: title
|
95
|
+
})]
|
96
|
+
}), /*#__PURE__*/_jsxs("div", {
|
97
|
+
className: "ux-dialog_right",
|
98
|
+
children: [/*#__PURE__*/_jsx("div", {
|
99
|
+
className: "ux-dialog_toolbar",
|
100
|
+
children: toolbar
|
101
|
+
}), showCloseButton && !isMobile && closeButton]
|
102
|
+
})]
|
103
|
+
}), /*#__PURE__*/_jsx(MuiDialogContent, {
|
104
|
+
children: children
|
105
|
+
}), actions && /*#__PURE__*/_jsx(DialogActions, {
|
106
|
+
className: `ux-dialog_actions--${actionsPosition}`,
|
107
|
+
children: actions
|
108
|
+
})]
|
109
|
+
});
|
110
|
+
}
|
111
|
+
Dialog.propTypes = {
|
112
|
+
children: PropTypes.node.isRequired,
|
113
|
+
title: PropTypes.node,
|
114
|
+
// 在 title 之前追加内容, 比如返回按钮
|
115
|
+
prepend: PropTypes.node,
|
116
|
+
// 顶部工具栏, 在 close button 另一侧
|
117
|
+
toolbar: PropTypes.node,
|
118
|
+
actions: PropTypes.node,
|
119
|
+
showCloseButton: PropTypes.bool,
|
120
|
+
actionsPosition: PropTypes.oneOf(['left', 'center', 'right']),
|
121
|
+
PaperProps: PropTypes.object
|
122
|
+
};
|
123
|
+
Dialog.defaultProps = {
|
124
|
+
showCloseButton: true,
|
125
|
+
title: '',
|
126
|
+
prepend: null,
|
127
|
+
toolbar: null,
|
128
|
+
actions: null,
|
129
|
+
actionsPosition: 'right',
|
130
|
+
PaperProps: {}
|
131
|
+
};
|
132
|
+
/**
|
133
|
+
* @type {import('@emotion/styled').StyledComponent<import('@mui/material').DialogProps, {}, { ref?: React.Ref<any> | undefined;}>}
|
134
|
+
*/
|
135
|
+
const StyledMuiDialog = styled(MuiDialog)`
|
136
|
+
.MuiDialog-paper {
|
137
|
+
${props => props.fullScreen ? 'border-radius: 0;' : ''};
|
138
|
+
}
|
139
|
+
.MuiDialogContent-root {
|
140
|
+
padding: 16px 24px;
|
141
|
+
}
|
142
|
+
.MuiDialogActions-root {
|
143
|
+
padding: 8px 24px 16px 24px;
|
144
|
+
}
|
145
|
+
.MuiDialogActions-root.ux-dialog_actions--left {
|
146
|
+
justify-content: flex-start;
|
147
|
+
}
|
148
|
+
.MuiDialogActions-root.ux-dialog_actions--right {
|
149
|
+
justify-content: flex-end;
|
150
|
+
}
|
151
|
+
.MuiDialogActions-root.ux-dialog_actions--center {
|
152
|
+
justify-content: center;
|
153
|
+
}
|
154
|
+
`;
|
155
|
+
|
156
|
+
/** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
|
157
|
+
const Header = styled('div', {
|
158
|
+
shouldForwardProp: prop => prop !== 'isMobile'
|
159
|
+
})`
|
160
|
+
display: flex;
|
161
|
+
justify-content: space-between;
|
162
|
+
align-items: center;
|
163
|
+
padding: 16px 24px;
|
164
|
+
.ux-dialog_left {
|
165
|
+
display: flex;
|
166
|
+
justify-content: flex-start;
|
167
|
+
align-items: center;
|
168
|
+
min-width: 0;
|
169
|
+
}
|
170
|
+
.ux-dialog_right {
|
171
|
+
display: flex;
|
172
|
+
justify-content: flex-end;
|
173
|
+
align-items: center;
|
174
|
+
}
|
175
|
+
.ux-dialog_toolbar {
|
176
|
+
display: flex;
|
177
|
+
align-items: center;
|
178
|
+
}
|
179
|
+
.ux-dialog_title {
|
180
|
+
margin: 0;
|
181
|
+
font-size: 18px;
|
182
|
+
font-weight: 500;
|
183
|
+
white-space: nowrap;
|
184
|
+
overflow: hidden;
|
185
|
+
text-overflow: ellipsis;
|
186
|
+
}
|
187
|
+
.ux-dialog_closeButton {
|
188
|
+
/* 使 closeButton 与 content 左/右对齐 */
|
189
|
+
${props => props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;'}
|
190
|
+
}
|
191
|
+
`;
|
192
|
+
export default Dialog;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import DidLogoIcon from '@arcblock/icons/lib/DidLogo';
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
const defaultStyle = {
|
5
|
+
width: 'auto',
|
6
|
+
height: '1em',
|
7
|
+
fill: 'currentColor'
|
8
|
+
};
|
9
|
+
export default function DidLogo({
|
10
|
+
style,
|
11
|
+
size,
|
12
|
+
className
|
13
|
+
}) {
|
14
|
+
const height = Number(size) > 0 ? `${Number(size)}px` : size;
|
15
|
+
return /*#__PURE__*/_jsx(DidLogoIcon, {
|
16
|
+
className: `${className}`.trim(),
|
17
|
+
style: Object.assign({}, defaultStyle, style, height ? {
|
18
|
+
height
|
19
|
+
} : {})
|
20
|
+
});
|
21
|
+
}
|
22
|
+
DidLogo.propTypes = {
|
23
|
+
style: PropTypes.object,
|
24
|
+
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
25
|
+
className: PropTypes.string
|
26
|
+
};
|
27
|
+
DidLogo.defaultProps = {
|
28
|
+
style: defaultStyle,
|
29
|
+
size: 0,
|
30
|
+
className: ''
|
31
|
+
};
|
@@ -0,0 +1,70 @@
|
|
1
|
+
/* eslint-disable max-len */
|
2
|
+
import { Component } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import { mergeProps } from '../Util';
|
5
|
+
export default class DriftBot extends Component {
|
6
|
+
constructor(props) {
|
7
|
+
super(mergeProps(props, DriftBot, ['attributes']));
|
8
|
+
this.addMainScript = this.addMainScript.bind(this);
|
9
|
+
this.addIdentityVariables = this.addIdentityVariables.bind(this);
|
10
|
+
this.insertScript = this.insertScript.bind(this);
|
11
|
+
}
|
12
|
+
insertScript(scriptText) {
|
13
|
+
const script = document.createElement('script');
|
14
|
+
script.innerText = scriptText;
|
15
|
+
script.async = true;
|
16
|
+
document.body.appendChild(script);
|
17
|
+
}
|
18
|
+
addMainScript() {
|
19
|
+
const scriptText = `!function() {
|
20
|
+
var t = window.driftt = window.drift = window.driftt || [];
|
21
|
+
if (!t.init) {
|
22
|
+
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
|
23
|
+
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
|
24
|
+
t.factory = function(e) {
|
25
|
+
return function() {
|
26
|
+
var n = Array.prototype.slice.call(arguments);
|
27
|
+
return n.unshift(e), t.push(n), t;
|
28
|
+
};
|
29
|
+
}, t.methods.forEach(function(e) {
|
30
|
+
t[e] = t.factory(e);
|
31
|
+
}), t.load = function(t) {
|
32
|
+
var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
|
33
|
+
o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
|
34
|
+
var i = document.getElementsByTagName("script")[0];
|
35
|
+
i.parentNode.insertBefore(o, i);
|
36
|
+
};
|
37
|
+
}
|
38
|
+
}();
|
39
|
+
drift.SNIPPET_VERSION = '0.3.1';
|
40
|
+
drift.load('${this.props.appId}');`;
|
41
|
+
this.insertScript(scriptText);
|
42
|
+
}
|
43
|
+
addIdentityVariables() {
|
44
|
+
if (typeof this.props.userId !== 'undefined') {
|
45
|
+
const scriptText = `
|
46
|
+
var t = window.driftt = window.drift = window.driftt || [];
|
47
|
+
drift.identify('${this.props.userId}', ${JSON.stringify(this.props.attributes)})
|
48
|
+
`;
|
49
|
+
this.insertScript(scriptText);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
componentDidMount() {
|
53
|
+
if (typeof window !== 'undefined') {
|
54
|
+
this.addMainScript();
|
55
|
+
this.addIdentityVariables();
|
56
|
+
}
|
57
|
+
}
|
58
|
+
render() {
|
59
|
+
return '';
|
60
|
+
}
|
61
|
+
}
|
62
|
+
DriftBot.propTypes = {
|
63
|
+
appId: PropTypes.string.isRequired,
|
64
|
+
userId: PropTypes.string,
|
65
|
+
attributes: PropTypes.object
|
66
|
+
};
|
67
|
+
DriftBot.defaultProps = {
|
68
|
+
userId: '',
|
69
|
+
attributes: {}
|
70
|
+
};
|