@abtnode/ux 1.8.35 → 1.8.37
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/blocklet/actions.js +1 -3
- package/lib/blocklet/agreement-app.js +28 -0
- package/lib/blocklet/agreement.js +72 -0
- package/lib/blocklet/avatar.js +1 -10
- package/lib/blocklet/component/add.js +1083 -0
- package/lib/blocklet/component/configuration.js +1 -1
- package/lib/blocklet/component/environment.js +1 -1
- package/lib/blocklet/component/index.js +9 -11
- package/lib/blocklet/component/select-store.js +151 -0
- package/lib/blocklet/component/setting.js +1 -1
- package/lib/blocklet/component/store-blocklet-list.js +203 -0
- package/lib/blocklet/configuration.js +2 -2
- package/lib/blocklet/install-from-url.js +362 -0
- package/lib/blocklet/preferences/index.js +168 -0
- package/lib/blocklet/purchase/common.js +103 -0
- package/lib/blocklet/purchase/component-purchase.js +251 -0
- package/lib/blocklet/purchase/index.js +13 -0
- package/lib/blocklet/router/rule-list.js +1 -1
- package/lib/blocklet/util.js +4 -16
- package/lib/blocklet/version.js +2 -2
- package/lib/hooks/blocklet.js +26 -10
- package/lib/locales/en.js +2 -0
- package/lib/locales/zh.js +2 -0
- package/lib/schema-form/index.js +1 -1
- package/lib/store/add.js +185 -0
- package/lib/store/delete.js +102 -0
- package/lib/store/item.js +84 -0
- package/lib/util/api.js +21 -0
- package/lib/util/constants.js +10 -0
- package/lib/util/index.js +24 -8
- package/package.json +10 -7
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = InstallFromUrl;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _semver = _interopRequireDefault(require("semver"));
|
|
10
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
11
|
+
var _Spinner = _interopRequireDefault(require("@arcblock/ux/lib/Spinner"));
|
|
12
|
+
var _DialogContentText = _interopRequireDefault(require("@mui/material/DialogContentText"));
|
|
13
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
14
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
15
|
+
var _Stepper = _interopRequireDefault(require("@mui/material/Stepper"));
|
|
16
|
+
var _Step = _interopRequireDefault(require("@mui/material/Step"));
|
|
17
|
+
var _StepLabel = _interopRequireDefault(require("@mui/material/StepLabel"));
|
|
18
|
+
var _InfoRow = _interopRequireDefault(require("@arcblock/ux/lib/InfoRow"));
|
|
19
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
20
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
21
|
+
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
22
|
+
var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
|
|
23
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
24
|
+
var _node = require("../contexts/node");
|
|
25
|
+
var _util2 = require("../util");
|
|
26
|
+
var _didAddress = _interopRequireDefault(require("../did-address"));
|
|
27
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
|
+
function InstallFromUrl(_ref) {
|
|
33
|
+
let {
|
|
34
|
+
defaultUrl,
|
|
35
|
+
onCancel: _onCancel,
|
|
36
|
+
onSuccess,
|
|
37
|
+
onError,
|
|
38
|
+
mode,
|
|
39
|
+
handleText
|
|
40
|
+
} = _ref;
|
|
41
|
+
const {
|
|
42
|
+
api
|
|
43
|
+
} = (0, _node.useNodeContext)();
|
|
44
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
45
|
+
const [error, setError] = (0, _react.useState)('');
|
|
46
|
+
const {
|
|
47
|
+
t
|
|
48
|
+
} = (0, _context.useLocaleContext)();
|
|
49
|
+
const initMeta = {
|
|
50
|
+
dist: {}
|
|
51
|
+
};
|
|
52
|
+
const [url, setUrl] = (0, _react.useState)(defaultUrl);
|
|
53
|
+
const [activeStep, setActiveStep] = (0, _react.useState)(defaultUrl ? 1 : 0);
|
|
54
|
+
const [meta, setMeta] = (0, _react.useState)(initMeta);
|
|
55
|
+
const [existingMeta, setExistingMeta] = (0, _react.useState)(null);
|
|
56
|
+
const [params, setParams] = (0, _react.useState)({});
|
|
57
|
+
const isComponentMode = mode === 'component';
|
|
58
|
+
// if mode is component , we need to always show the step, that means the user can return to the previous step
|
|
59
|
+
const alwayShowSteps = isComponentMode ? true : !defaultUrl;
|
|
60
|
+
const onGetMeta = async () => {
|
|
61
|
+
setMeta(initMeta);
|
|
62
|
+
setError(null);
|
|
63
|
+
setLoading(true);
|
|
64
|
+
try {
|
|
65
|
+
const decoded = decodeURIComponent(url.trim());
|
|
66
|
+
// validate
|
|
67
|
+
try {
|
|
68
|
+
new URL(decoded); // eslint-disable-line no-new
|
|
69
|
+
} catch (_unused) {
|
|
70
|
+
throw new Error('Invalid URL');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// request
|
|
74
|
+
const {
|
|
75
|
+
meta: newer,
|
|
76
|
+
inStore,
|
|
77
|
+
registryUrl
|
|
78
|
+
} = await api.getBlockletMetaFromUrl({
|
|
79
|
+
input: {
|
|
80
|
+
url: decoded
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// if mode is component, never check existing blocklet
|
|
85
|
+
if (isComponentMode) {
|
|
86
|
+
setMeta(newer);
|
|
87
|
+
} else {
|
|
88
|
+
const {
|
|
89
|
+
blocklet: existedBlocklet
|
|
90
|
+
} = await api.getBlocklet({
|
|
91
|
+
input: {
|
|
92
|
+
did: newer.did,
|
|
93
|
+
attachRuntimeInfo: false
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (existedBlocklet && _semver.default.gte(existedBlocklet.meta.version, newer.version)) {
|
|
97
|
+
setExistingMeta(existedBlocklet.meta);
|
|
98
|
+
setMeta(newer);
|
|
99
|
+
} else {
|
|
100
|
+
setMeta(newer);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
setParams({
|
|
104
|
+
inStore,
|
|
105
|
+
registryUrl,
|
|
106
|
+
inputUrl: url.trim()
|
|
107
|
+
});
|
|
108
|
+
} catch (err) {
|
|
109
|
+
console.error(err);
|
|
110
|
+
const errMsg = "Blocklet Install failed: ".concat((0, _util2.formatError)(err));
|
|
111
|
+
setError(errMsg);
|
|
112
|
+
onError(err);
|
|
113
|
+
} finally {
|
|
114
|
+
setLoading(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const _onConfirm = async () => {
|
|
118
|
+
if (isComponentMode) {
|
|
119
|
+
onSuccess(_objectSpread({
|
|
120
|
+
meta
|
|
121
|
+
}, params));
|
|
122
|
+
} else {
|
|
123
|
+
await onInstall();
|
|
124
|
+
}
|
|
125
|
+
_onCancel();
|
|
126
|
+
};
|
|
127
|
+
const onInstall = async () => {
|
|
128
|
+
setLoading(true);
|
|
129
|
+
try {
|
|
130
|
+
await api.installBlocklet({
|
|
131
|
+
input: {
|
|
132
|
+
url: decodeURIComponent(url.trim())
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
onSuccess(_objectSpread({
|
|
136
|
+
meta
|
|
137
|
+
}, params));
|
|
138
|
+
} catch (err) {
|
|
139
|
+
const errMsg = "Blocklet Install failed: ".concat((0, _util2.formatError)(err));
|
|
140
|
+
setError(errMsg);
|
|
141
|
+
} finally {
|
|
142
|
+
setLoading(false);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
(0, _react.useEffect)(() => {
|
|
146
|
+
if (defaultUrl) {
|
|
147
|
+
onGetMeta();
|
|
148
|
+
}
|
|
149
|
+
}, [defaultUrl]); // eslint-disable-line
|
|
150
|
+
|
|
151
|
+
const rows = [{
|
|
152
|
+
name: t('common.name'),
|
|
153
|
+
value: (0, _util.getDisplayName)({
|
|
154
|
+
meta
|
|
155
|
+
}, true)
|
|
156
|
+
}, {
|
|
157
|
+
name: t('common.version'),
|
|
158
|
+
value: meta.version
|
|
159
|
+
}, {
|
|
160
|
+
name: t('common.did'),
|
|
161
|
+
value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_didAddress.default, {
|
|
162
|
+
did: meta.did
|
|
163
|
+
})
|
|
164
|
+
}, {
|
|
165
|
+
name: t('common.author'),
|
|
166
|
+
value: (0, _util2.formatPerson)(meta.author)
|
|
167
|
+
}, {
|
|
168
|
+
name: t('blocklet.dist.downloadLink'),
|
|
169
|
+
value: meta.dist.tarball
|
|
170
|
+
}];
|
|
171
|
+
const getStep1Body = () => {
|
|
172
|
+
if (loading) {
|
|
173
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
174
|
+
style: {
|
|
175
|
+
height: 200,
|
|
176
|
+
width: '100%',
|
|
177
|
+
display: 'flex',
|
|
178
|
+
alignItems: 'center',
|
|
179
|
+
justifyContent: 'center',
|
|
180
|
+
flexDirection: 'column'
|
|
181
|
+
},
|
|
182
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {})
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (meta.did) {
|
|
186
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
187
|
+
style: {
|
|
188
|
+
paddingLeft: '10%'
|
|
189
|
+
},
|
|
190
|
+
children: [rows.map(row => {
|
|
191
|
+
if (row.name === t('common.did')) {
|
|
192
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoRow.default, {
|
|
193
|
+
valueComponent: "div",
|
|
194
|
+
nameWidth: 120,
|
|
195
|
+
name: row.name,
|
|
196
|
+
nameFormatter: () => t('common.did'),
|
|
197
|
+
children: row.value
|
|
198
|
+
}, row.name);
|
|
199
|
+
}
|
|
200
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoRow.default, {
|
|
201
|
+
valueComponent: "div",
|
|
202
|
+
nameWidth: 120,
|
|
203
|
+
name: row.name,
|
|
204
|
+
children: row.value
|
|
205
|
+
}, row.name);
|
|
206
|
+
}), existingMeta && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
207
|
+
type: "error",
|
|
208
|
+
variant: "icon",
|
|
209
|
+
style: {
|
|
210
|
+
margin: '15px 0 0 -16px'
|
|
211
|
+
},
|
|
212
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
213
|
+
children: [t('blocklet.fromUrl.existTipPrefix'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
|
|
214
|
+
content: existingMeta.version,
|
|
215
|
+
style: {
|
|
216
|
+
margin: '0 5px'
|
|
217
|
+
}
|
|
218
|
+
}), t('blocklet.fromUrl.existTipSuffix')]
|
|
219
|
+
})
|
|
220
|
+
})]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
const steps = [{
|
|
226
|
+
label: t('blocklet.fromUrl.step0'),
|
|
227
|
+
body: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
228
|
+
component: "div",
|
|
229
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
230
|
+
label: t('blocklet.fromUrl.label'),
|
|
231
|
+
autoComplete: "off",
|
|
232
|
+
variant: "outlined",
|
|
233
|
+
name: "url",
|
|
234
|
+
"data-cy": "blocklet-url-input",
|
|
235
|
+
fullWidth: true,
|
|
236
|
+
autoFocus: true,
|
|
237
|
+
style: {
|
|
238
|
+
marginBottom: 32
|
|
239
|
+
},
|
|
240
|
+
margin: "dense",
|
|
241
|
+
helperText: t('blocklet.fromUrl.description'),
|
|
242
|
+
value: url,
|
|
243
|
+
onChange: e => {
|
|
244
|
+
setError(null);
|
|
245
|
+
setUrl(e.target.value);
|
|
246
|
+
},
|
|
247
|
+
disabled: loading,
|
|
248
|
+
onKeyPress: e => {
|
|
249
|
+
if (e.key === 'Enter') {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
onGetMeta();
|
|
252
|
+
setActiveStep(1);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
}),
|
|
257
|
+
cancel: t('common.cancel'),
|
|
258
|
+
confirm: t('common.next'),
|
|
259
|
+
onCancel: _onCancel,
|
|
260
|
+
onConfirm: () => {
|
|
261
|
+
onGetMeta();
|
|
262
|
+
setActiveStep(1);
|
|
263
|
+
}
|
|
264
|
+
}, {
|
|
265
|
+
label: t('blocklet.fromUrl.step1'),
|
|
266
|
+
body: getStep1Body(),
|
|
267
|
+
cancel: alwayShowSteps ? t('common.pre') : t('common.cancel'),
|
|
268
|
+
confirm: (handleText === null || handleText === void 0 ? void 0 : handleText.confirm) || (existingMeta ? t('common.confirm') : t('blocklet.fromUrl.confirm')),
|
|
269
|
+
onCancel: () => {
|
|
270
|
+
if (alwayShowSteps) {
|
|
271
|
+
setActiveStep(s => s - 1);
|
|
272
|
+
} else {
|
|
273
|
+
_onCancel();
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
onConfirm: () => {
|
|
277
|
+
if (existingMeta) {
|
|
278
|
+
_onCancel();
|
|
279
|
+
} else {
|
|
280
|
+
_onConfirm();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}];
|
|
284
|
+
const step = steps[activeStep];
|
|
285
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
286
|
+
title: (handleText === null || handleText === void 0 ? void 0 : handleText.title) || t('blocklet.fromUrl.title'),
|
|
287
|
+
fullWidth: true,
|
|
288
|
+
maxWidth: "md",
|
|
289
|
+
onClose: () => step.onCancel(),
|
|
290
|
+
showCloseButton: activeStep === 0,
|
|
291
|
+
disableEscapeKeyDown: true,
|
|
292
|
+
open: true,
|
|
293
|
+
actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
294
|
+
children: [step.cancel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
295
|
+
onClick: e => {
|
|
296
|
+
e.stopPropagation();
|
|
297
|
+
setError(null);
|
|
298
|
+
step.onCancel();
|
|
299
|
+
},
|
|
300
|
+
color: "inherit",
|
|
301
|
+
children: step.cancel || t('common.cancel')
|
|
302
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
303
|
+
onClick: e => {
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
step.onConfirm();
|
|
306
|
+
},
|
|
307
|
+
color: "primary",
|
|
308
|
+
"data-cy": "install-blocklet-next-step",
|
|
309
|
+
disabled: loading || !url || error,
|
|
310
|
+
variant: "contained",
|
|
311
|
+
autoFocus: true,
|
|
312
|
+
style: {
|
|
313
|
+
marginLeft: 8
|
|
314
|
+
},
|
|
315
|
+
children: [loading && activeStep === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
|
|
316
|
+
size: [16, 10]
|
|
317
|
+
}), step.confirm]
|
|
318
|
+
})]
|
|
319
|
+
}),
|
|
320
|
+
children: [alwayShowSteps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Stepper.default, {
|
|
321
|
+
alternativeLabel: true,
|
|
322
|
+
activeStep: activeStep,
|
|
323
|
+
children: steps.map(_ref2 => {
|
|
324
|
+
let {
|
|
325
|
+
label
|
|
326
|
+
} = _ref2;
|
|
327
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Step.default, {
|
|
328
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
329
|
+
children: label
|
|
330
|
+
})
|
|
331
|
+
}, label);
|
|
332
|
+
})
|
|
333
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogContentText.default, {
|
|
334
|
+
component: "div",
|
|
335
|
+
style: {
|
|
336
|
+
marginTop: 24
|
|
337
|
+
},
|
|
338
|
+
children: step.body
|
|
339
|
+
}), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
340
|
+
type: "error",
|
|
341
|
+
style: {
|
|
342
|
+
width: '100%',
|
|
343
|
+
marginTop: 8
|
|
344
|
+
},
|
|
345
|
+
children: error
|
|
346
|
+
})]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
InstallFromUrl.propTypes = {
|
|
350
|
+
defaultUrl: _propTypes.default.string,
|
|
351
|
+
onCancel: _propTypes.default.func.isRequired,
|
|
352
|
+
onSuccess: _propTypes.default.func.isRequired,
|
|
353
|
+
onError: _propTypes.default.func,
|
|
354
|
+
mode: _propTypes.default.oneOf(['install', 'component']),
|
|
355
|
+
handleText: _propTypes.default.object
|
|
356
|
+
};
|
|
357
|
+
InstallFromUrl.defaultProps = {
|
|
358
|
+
onError: () => {},
|
|
359
|
+
defaultUrl: '',
|
|
360
|
+
mode: 'install',
|
|
361
|
+
handleText: {}
|
|
362
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = BlockletPreferences;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _reactIframe = _interopRequireDefault(require("react-iframe"));
|
|
11
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
12
|
+
var _constant = require("@abtnode/constant");
|
|
13
|
+
var _material = require("@mui/material");
|
|
14
|
+
var _TuneRounded = _interopRequireDefault(require("@mui/icons-material/TuneRounded"));
|
|
15
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
16
|
+
var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
|
|
17
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
18
|
+
var _avatar = _interopRequireDefault(require("../avatar"));
|
|
19
|
+
var _configuration = _interopRequireDefault(require("../configuration"));
|
|
20
|
+
var _node = require("../../contexts/node");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
var _templateObject;
|
|
23
|
+
const _excluded = ["blocklet", "onUpdate"];
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
32
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
33
|
+
const addComponentTabs = function addComponentTabs(tabs, blocklet) {
|
|
34
|
+
let ancestors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
35
|
+
let depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
36
|
+
const key = [...ancestors.map(x => x.meta.did), blocklet.meta.did].join('/');
|
|
37
|
+
tabs.push({
|
|
38
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
39
|
+
pl: (depth - 1) * 2,
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
justifyContent: "flex-start",
|
|
43
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_avatar.default, {
|
|
44
|
+
size: 24,
|
|
45
|
+
blocklet: blocklet,
|
|
46
|
+
ancestors: ancestors
|
|
47
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
48
|
+
ml: "16px",
|
|
49
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
50
|
+
style: {
|
|
51
|
+
color: '#222'
|
|
52
|
+
},
|
|
53
|
+
children: (0, _util.getDisplayName)(blocklet, true)
|
|
54
|
+
})
|
|
55
|
+
})]
|
|
56
|
+
}, key),
|
|
57
|
+
value: key
|
|
58
|
+
});
|
|
59
|
+
if (blocklet.children.length > 0) {
|
|
60
|
+
blocklet.children.forEach(x => {
|
|
61
|
+
addComponentTabs(tabs, x, [...ancestors, blocklet], depth + 1);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function BlockletPreferences(_ref) {
|
|
66
|
+
let {
|
|
67
|
+
blocklet,
|
|
68
|
+
onUpdate
|
|
69
|
+
} = _ref,
|
|
70
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
71
|
+
const {
|
|
72
|
+
t
|
|
73
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
74
|
+
const {
|
|
75
|
+
info,
|
|
76
|
+
inService
|
|
77
|
+
} = (0, _node.useNodeContext)();
|
|
78
|
+
const [current, setCurrent] = (0, _react.useState)('general');
|
|
79
|
+
const tabs = [{
|
|
80
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
81
|
+
display: "flex",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TuneRounded.default, {
|
|
84
|
+
sx: {
|
|
85
|
+
fontSize: 24
|
|
86
|
+
}
|
|
87
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
88
|
+
ml: "16px",
|
|
89
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
90
|
+
style: {
|
|
91
|
+
color: '#222'
|
|
92
|
+
},
|
|
93
|
+
children: t('common.general')
|
|
94
|
+
})
|
|
95
|
+
})]
|
|
96
|
+
}, "general"),
|
|
97
|
+
value: 'general'
|
|
98
|
+
}];
|
|
99
|
+
addComponentTabs(tabs, blocklet);
|
|
100
|
+
let content = null;
|
|
101
|
+
if (current === 'general') {
|
|
102
|
+
content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_configuration.default, {
|
|
103
|
+
blocklet: blocklet,
|
|
104
|
+
onUpdate: onUpdate
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
// eslint-disable-next-line no-nested-ternary
|
|
108
|
+
const pathPrefix = inService ? _constant.WELLKNOWN_SERVICE_PATH_PREFIX : process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
|
|
109
|
+
const searchParams = new URLSearchParams();
|
|
110
|
+
if (!inService) {
|
|
111
|
+
searchParams.set('authKey', '__sst');
|
|
112
|
+
}
|
|
113
|
+
searchParams.set('schemaKey', (0, _urlJoin.default)(window.location.origin, pathPrefix, "/api/preferences?id=".concat(encodeURIComponent(current))));
|
|
114
|
+
content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIframe.default, {
|
|
115
|
+
url: "".concat((0, _urlJoin.default)(window.location.origin, pathPrefix, '/hosted/form-collector/'), "?").concat(searchParams.toString()),
|
|
116
|
+
width: "100%",
|
|
117
|
+
height: "100%",
|
|
118
|
+
frameBorder: 0,
|
|
119
|
+
styles: {
|
|
120
|
+
border: 0
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Div, _objectSpread(_objectSpread({}, rest), {}, {
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
126
|
+
container: true,
|
|
127
|
+
spacing: 4,
|
|
128
|
+
columns: 16,
|
|
129
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
|
|
130
|
+
item: true,
|
|
131
|
+
sm: 5,
|
|
132
|
+
md: 3,
|
|
133
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tabs.default, {
|
|
134
|
+
tabs: tabs,
|
|
135
|
+
current: current,
|
|
136
|
+
orientation: "vertical",
|
|
137
|
+
onChange: setCurrent,
|
|
138
|
+
sx: {
|
|
139
|
+
borderRight: 1,
|
|
140
|
+
height: '100%',
|
|
141
|
+
borderColor: 'divider'
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
|
|
145
|
+
item: true,
|
|
146
|
+
sm: 11,
|
|
147
|
+
md: 13,
|
|
148
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
149
|
+
style: {
|
|
150
|
+
minHeight: '66vh',
|
|
151
|
+
height: '100%',
|
|
152
|
+
position: 'relative',
|
|
153
|
+
overflow: 'hidden'
|
|
154
|
+
},
|
|
155
|
+
children: content
|
|
156
|
+
})
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
BlockletPreferences.propTypes = {
|
|
162
|
+
blocklet: _propTypes.default.object.isRequired,
|
|
163
|
+
onUpdate: _propTypes.default.func
|
|
164
|
+
};
|
|
165
|
+
BlockletPreferences.defaultProps = {
|
|
166
|
+
onUpdate: () => {}
|
|
167
|
+
};
|
|
168
|
+
const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiTab-root {\n text-align: left;\n align-items: flex-start;\n font-weight: normal;\n }\n .Mui-selected {\n font-weight: bold;\n }\n"])));
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CustomSelect = CustomSelect;
|
|
7
|
+
exports.useStyles = exports.commonProps = void 0;
|
|
8
|
+
var _styles = require("@mui/styles");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _List = _interopRequireDefault(require("@mui/material/List"));
|
|
11
|
+
var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
|
|
12
|
+
var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
|
|
13
|
+
var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
|
|
14
|
+
var _ShoppingCart = _interopRequireDefault(require("@mui/icons-material/ShoppingCart"));
|
|
15
|
+
var _VerifiedUser = _interopRequireDefault(require("@mui/icons-material/VerifiedUser"));
|
|
16
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
17
|
+
var _Colors = _interopRequireDefault(require("@arcblock/ux/lib/Colors"));
|
|
18
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
const commonProps = {
|
|
22
|
+
meta: _propTypes.default.object.isRequired,
|
|
23
|
+
onCancel: _propTypes.default.func.isRequired
|
|
24
|
+
};
|
|
25
|
+
exports.commonProps = commonProps;
|
|
26
|
+
const useStyles = (0, _styles.makeStyles)(() => ({
|
|
27
|
+
dialogAuth: {
|
|
28
|
+
padding: '0 0 24px !important',
|
|
29
|
+
'& .auth-title': {
|
|
30
|
+
textAlign: 'center !important',
|
|
31
|
+
marginBottom: '4px !important'
|
|
32
|
+
},
|
|
33
|
+
'& .auth-tip--scan': {
|
|
34
|
+
textAlign: 'center !important'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
iconRoot: {
|
|
38
|
+
minWidth: 48
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
exports.useStyles = useStyles;
|
|
42
|
+
function CustomSelect(_ref) {
|
|
43
|
+
let {
|
|
44
|
+
action,
|
|
45
|
+
onSelect,
|
|
46
|
+
onNext
|
|
47
|
+
} = _ref;
|
|
48
|
+
const classes = useStyles();
|
|
49
|
+
const {
|
|
50
|
+
t
|
|
51
|
+
} = (0, _context.useLocaleContext)();
|
|
52
|
+
const options = [{
|
|
53
|
+
action: 'purchase',
|
|
54
|
+
title: t('store.purchase.purchase.title'),
|
|
55
|
+
description: t('store.purchase.purchase.description')
|
|
56
|
+
}, {
|
|
57
|
+
action: 'verify',
|
|
58
|
+
title: t('store.purchase.verify.title'),
|
|
59
|
+
description: t('store.purchase.verify.description')
|
|
60
|
+
}];
|
|
61
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
62
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_List.default, {
|
|
63
|
+
className: classes.tabPanel,
|
|
64
|
+
children: options.map(x => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItem.default, {
|
|
65
|
+
button: true,
|
|
66
|
+
selected: action === x.action,
|
|
67
|
+
onClick: () => onSelect(x.action),
|
|
68
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon.default, {
|
|
69
|
+
className: classes.iconRoot,
|
|
70
|
+
children: x.action === 'purchase' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ShoppingCart.default, {
|
|
71
|
+
style: {
|
|
72
|
+
color: action === 'purchase' ? _Colors.default.primary.main : '#AAA',
|
|
73
|
+
fontSize: 32
|
|
74
|
+
}
|
|
75
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_VerifiedUser.default, {
|
|
76
|
+
style: {
|
|
77
|
+
color: action === 'verify' ? _Colors.default.primary.main : '#AAA',
|
|
78
|
+
fontSize: 32
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText.default, {
|
|
82
|
+
primary: x.title,
|
|
83
|
+
secondary: x.description
|
|
84
|
+
})]
|
|
85
|
+
}, x.action))
|
|
86
|
+
}), onNext && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
87
|
+
fullWidth: true,
|
|
88
|
+
disabled: !action,
|
|
89
|
+
variant: "contained",
|
|
90
|
+
color: "primary",
|
|
91
|
+
style: {
|
|
92
|
+
marginTop: 16
|
|
93
|
+
},
|
|
94
|
+
onClick: onNext,
|
|
95
|
+
children: t('common.next')
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
CustomSelect.propTypes = {
|
|
100
|
+
action: _propTypes.default.oneOf(['both', 'purchase', 'verify']).isRequired,
|
|
101
|
+
onSelect: _propTypes.default.func.isRequired,
|
|
102
|
+
onNext: _propTypes.default.func.isRequired
|
|
103
|
+
};
|