@arcblock/did-playground 2.13.69 → 3.0.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/lib/Action/actions.js +391 -500
- package/lib/Action/index.js +192 -261
- package/lib/Action/session.js +8 -17
- package/lib/index.js +8 -32
- package/package.json +13 -20
- package/src/Action/{index.js → index.jsx} +51 -24
- package/vite.config.mjs +29 -0
- /package/src/Action/{actions.js → actions.jsx} +0 -0
- /package/src/Action/{session.js → session.jsx} +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { use, useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useSize } from 'ahooks';
|
|
4
4
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
5
5
|
import { styled, useTheme } from '@arcblock/ux/lib/Theme';
|
|
6
|
+
import isUndefined from 'lodash/isUndefined';
|
|
6
7
|
|
|
7
|
-
import CircularProgress from '@mui/material
|
|
8
|
-
import Dialog from '@mui/material/Dialog';
|
|
9
|
-
import DialogContent from '@mui/material/DialogContent';
|
|
8
|
+
import { CircularProgress, Dialog, DialogContent } from '@mui/material';
|
|
10
9
|
|
|
11
10
|
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
12
11
|
import Button from '@arcblock/ux/lib/Button';
|
|
@@ -32,7 +31,53 @@ const CloseContainer = styled('div')`
|
|
|
32
31
|
user-select: none;
|
|
33
32
|
`;
|
|
34
33
|
|
|
35
|
-
function PlaygroundAction(
|
|
34
|
+
function PlaygroundAction(rawProps) {
|
|
35
|
+
const props = Object.assign({}, rawProps);
|
|
36
|
+
if (isUndefined(props.autoClose)) {
|
|
37
|
+
props.autoClose = true;
|
|
38
|
+
}
|
|
39
|
+
if (isUndefined(props.buttonText)) {
|
|
40
|
+
props.buttonText = '';
|
|
41
|
+
}
|
|
42
|
+
if (isUndefined(props.buttonColor)) {
|
|
43
|
+
props.buttonColor = 'primary';
|
|
44
|
+
}
|
|
45
|
+
if (isUndefined(props.buttonVariant)) {
|
|
46
|
+
props.buttonVariant = 'contained';
|
|
47
|
+
}
|
|
48
|
+
if (isUndefined(props.buttonSize)) {
|
|
49
|
+
props.buttonSize = 'large';
|
|
50
|
+
}
|
|
51
|
+
if (isUndefined(props.buttonRounded)) {
|
|
52
|
+
props.buttonRounded = false;
|
|
53
|
+
}
|
|
54
|
+
if (isUndefined(props.scanMessage)) {
|
|
55
|
+
props.scanMessage = 'Scan the QR Code with your DID Wallet';
|
|
56
|
+
}
|
|
57
|
+
if (isUndefined(props.confirmMessage)) {
|
|
58
|
+
props.confirmMessage = 'Confirm in your DID Wallet';
|
|
59
|
+
}
|
|
60
|
+
if (isUndefined(props.successMessage)) {
|
|
61
|
+
props.successMessage = 'Operation success!';
|
|
62
|
+
}
|
|
63
|
+
if (isUndefined(props.extraParams)) {
|
|
64
|
+
props.extraParams = {};
|
|
65
|
+
}
|
|
66
|
+
if (isUndefined(props.timeout)) {
|
|
67
|
+
props.timeout = 5 * 60 * 1000;
|
|
68
|
+
}
|
|
69
|
+
if (isUndefined(props.successUrl)) {
|
|
70
|
+
props.successUrl = '';
|
|
71
|
+
}
|
|
72
|
+
if (isUndefined(props.successTarget)) {
|
|
73
|
+
props.successTarget = '_self';
|
|
74
|
+
}
|
|
75
|
+
if (isUndefined(props.frameProps)) {
|
|
76
|
+
props.frameProps = {};
|
|
77
|
+
}
|
|
78
|
+
if (isUndefined(props.webWalletUrl)) {
|
|
79
|
+
props.webWalletUrl = '';
|
|
80
|
+
}
|
|
36
81
|
const newProps = mergeProps(props, PlaygroundAction, ['buttonRounded', 'extraParams', 'timeout']);
|
|
37
82
|
const {
|
|
38
83
|
autoClose,
|
|
@@ -59,7 +104,7 @@ function PlaygroundAction(props) {
|
|
|
59
104
|
|
|
60
105
|
const theme = useTheme();
|
|
61
106
|
const browser = useBrowser();
|
|
62
|
-
const { api, session } =
|
|
107
|
+
const { api, session } = use(SessionContext);
|
|
63
108
|
const [open, setOpen] = useState(false);
|
|
64
109
|
const [loading, setLoading] = useState(false);
|
|
65
110
|
const [dynamicParams, setDynamicParams] = useState({});
|
|
@@ -254,22 +299,4 @@ PlaygroundAction.propTypes = {
|
|
|
254
299
|
webWalletUrl: PropTypes.string,
|
|
255
300
|
};
|
|
256
301
|
|
|
257
|
-
PlaygroundAction.defaultProps = {
|
|
258
|
-
autoClose: true, // 只在没有 successUrl 属性下有效
|
|
259
|
-
buttonText: '',
|
|
260
|
-
buttonColor: 'primary', // primary | secondary | reverse | error
|
|
261
|
-
buttonVariant: 'contained', // contained | outlined | default
|
|
262
|
-
buttonSize: 'large', // small | large | medium
|
|
263
|
-
buttonRounded: false,
|
|
264
|
-
scanMessage: 'Scan the QR Code with your DID Wallet',
|
|
265
|
-
confirmMessage: 'Confirm in your DID Wallet',
|
|
266
|
-
successMessage: 'Operation success!',
|
|
267
|
-
extraParams: {},
|
|
268
|
-
timeout: 5 * 60 * 1000,
|
|
269
|
-
successUrl: '',
|
|
270
|
-
successTarget: '_self',
|
|
271
|
-
frameProps: {},
|
|
272
|
-
webWalletUrl: '',
|
|
273
|
-
};
|
|
274
|
-
|
|
275
302
|
export default PlaygroundAction;
|
package/vite.config.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import svgr from 'vite-plugin-svgr';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import noBundlePlugin from 'vite-plugin-no-bundle';
|
|
5
|
+
import fg from 'fast-glob';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [
|
|
9
|
+
react({ jsxRuntime: 'automatic' }),
|
|
10
|
+
svgr({
|
|
11
|
+
include: ['**/*.svg', '**/*.svg?react'],
|
|
12
|
+
}),
|
|
13
|
+
noBundlePlugin({
|
|
14
|
+
root: 'src',
|
|
15
|
+
copy: ['**/*.png', '**/*.gif', '**/*.jpg', '**/*.jpeg', '**/*.d.ts'],
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
build: {
|
|
19
|
+
lib: {
|
|
20
|
+
entry: fg.sync('src/**/*.{tsx,ts,jsx,js}', {
|
|
21
|
+
ignore: ['**/stories/**', '**/demo/**', '**/*.d.ts', '**/*.stories.*'],
|
|
22
|
+
}),
|
|
23
|
+
formats: ['es'],
|
|
24
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
25
|
+
},
|
|
26
|
+
outDir: 'lib',
|
|
27
|
+
emptyOutDir: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
File without changes
|
|
File without changes
|