@abtnode/ux 1.15.17 → 1.16.0-beta-b16cb035
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/actions.js +111 -0
- package/lib/blocklet/access/config-access.js +303 -0
- package/lib/blocklet/access/index.js +221 -0
- package/lib/blocklet/actions.js +438 -0
- package/lib/blocklet/add-cert.js +191 -0
- package/lib/blocklet/agreement-app.js +30 -0
- package/lib/blocklet/agreement.js +72 -0
- package/lib/blocklet/app-avatar.js +74 -0
- package/lib/blocklet/audit-logs.js +197 -0
- package/lib/blocklet/blocklet-source.js +56 -0
- package/lib/blocklet/bundle-avatar.js +80 -0
- package/lib/blocklet/component/add.js +1063 -0
- package/lib/blocklet/component/configuration.js +124 -0
- package/lib/blocklet/component/delete.js +117 -0
- package/lib/blocklet/component/environment.js +289 -0
- package/lib/blocklet/component/expiration.js +53 -0
- package/lib/blocklet/component/index.js +804 -0
- package/lib/blocklet/component/line.js +28 -0
- package/lib/blocklet/component/navigation/locale-tabs.js +218 -0
- package/lib/blocklet/component/navigation/navigation-actions.js +120 -0
- package/lib/blocklet/component/navigation/navigation-dialog.js +620 -0
- package/lib/blocklet/component/navigation/navigation-preview.js +102 -0
- package/lib/blocklet/component/navigation/simple-select.js +131 -0
- package/lib/blocklet/component/select-store.js +153 -0
- package/lib/blocklet/component/setting.js +151 -0
- package/lib/blocklet/component/sortable-tree.js +138 -0
- package/lib/blocklet/component/space-gateway-selector.js +174 -0
- package/lib/blocklet/component/store-blocklet-list.js +205 -0
- package/lib/blocklet/config-navigation.js +344 -0
- package/lib/blocklet/configuration.js +574 -0
- package/lib/blocklet/disk-info.js +91 -0
- package/lib/blocklet/icons.js +26 -0
- package/lib/blocklet/install-from-url.js +347 -0
- package/lib/blocklet/log.js +62 -0
- package/lib/blocklet/migration.js +153 -0
- package/lib/blocklet/mode.js +35 -0
- package/lib/blocklet/monitor.js +186 -0
- package/lib/blocklet/overview.js +236 -0
- package/lib/blocklet/preferences/app-sk.js +131 -0
- package/lib/blocklet/preferences/index.js +238 -0
- package/lib/blocklet/preferences/wallet-type.js +107 -0
- package/lib/blocklet/purchase/common.js +103 -0
- package/lib/blocklet/purchase/component-purchase.js +253 -0
- package/lib/blocklet/purchase/index.js +13 -0
- package/lib/blocklet/router/action/add-domain-alias.js +173 -0
- package/lib/blocklet/router/action/add-rule.js +204 -0
- package/lib/blocklet/router/action/config-routing-rule.js +129 -0
- package/lib/blocklet/router/action/delete-domain-alias.js +107 -0
- package/lib/blocklet/router/action/delete-rule.js +114 -0
- package/lib/blocklet/router/action/update-rule.js +203 -0
- package/lib/blocklet/router/domain-actions.js +71 -0
- package/lib/blocklet/router/domain-status.js +96 -0
- package/lib/blocklet/router/rule-actions.js +77 -0
- package/lib/blocklet/router/rule-list.js +181 -0
- package/lib/blocklet/router/util.js +146 -0
- package/lib/blocklet/runtime-info.js +87 -0
- package/lib/blocklet/status.js +105 -0
- package/lib/blocklet/storage.js +322 -0
- package/lib/blocklet/types.js +25 -0
- package/lib/blocklet/util.js +213 -0
- package/lib/blocklet/version.js +156 -0
- package/lib/card-selector.js +109 -0
- package/lib/certificate.js +110 -0
- package/lib/click-to-copy.js +38 -0
- package/lib/confirm.js +149 -0
- package/lib/contexts/audit-log.js +141 -0
- package/lib/contexts/blocklet.js +19 -0
- package/lib/contexts/deleting-blocklets.js +78 -0
- package/lib/contexts/node.js +30 -0
- package/lib/contexts/session.js +20 -0
- package/lib/contexts/team.js +19 -0
- package/lib/delete-confirm.js +127 -0
- package/lib/did-address.js +77 -0
- package/lib/dot.js +18 -0
- package/lib/form/form-text-input.js +266 -0
- package/lib/form/form-wrapper.js +13 -0
- package/lib/form/required.js +13 -0
- package/lib/hooks/blocklet.js +231 -0
- package/lib/hooks/mobile-width.js +19 -0
- package/lib/hooks/url-evaluation.js +168 -0
- package/lib/hooks/use-app-logo.js +25 -0
- package/lib/hooks/use-bundle-logo.js +36 -0
- package/lib/hooks/use-navigation.js +355 -0
- package/lib/hooks/use-passport-id.js +21 -0
- package/lib/hooks/use-subscription.js +28 -0
- package/lib/icons/long-arrow.svg +5 -0
- package/lib/index.js +0 -3
- package/lib/invitation/invitation-app.js +51 -0
- package/lib/invitation/invitation-login.js +47 -0
- package/lib/invitation/invitation-passport.js +130 -0
- package/lib/invitation/invitation-receive.js +108 -0
- package/lib/invitation/invitation-success.js +82 -0
- package/lib/invitation/invitation-user.js +79 -0
- package/lib/invitation/invitation.js +80 -0
- package/lib/issue-passport.js +84 -84
- package/lib/launch-blocklet/content-layout.js +33 -0
- package/lib/launch-blocklet/page-header.js +38 -0
- package/lib/layout/addon.js +100 -0
- package/lib/layout/feedback.js +55 -0
- package/lib/locales/en.js +1221 -10
- package/lib/locales/index.js +3 -4
- package/lib/locales/zh.js +1232 -15
- package/lib/logs/clock.js +19 -0
- package/lib/logs/download.js +139 -0
- package/lib/logs/log-terminal.js +183 -0
- package/lib/lost-passport.js +191 -195
- package/lib/monitor/card.js +73 -0
- package/lib/monitor/cpu.js +109 -0
- package/lib/monitor/disk.js +122 -0
- package/lib/monitor/memory.js +144 -0
- package/lib/nav-logo.js +120 -0
- package/lib/passport-tag.js +43 -0
- package/lib/permission.js +70 -0
- package/lib/relative-time.js +61 -0
- package/lib/schema-form/color-input.js +105 -0
- package/lib/schema-form/common-prop-types.js +21 -0
- package/lib/schema-form/index.js +229 -0
- package/lib/schema-form/passport-input.js +66 -0
- package/lib/schema-form/text-input.js +72 -0
- package/lib/store/add.js +185 -0
- package/lib/store/delete.js +102 -0
- package/lib/store/item.js +84 -0
- package/lib/table-icons.js +42 -0
- package/lib/table.js +13 -0
- package/lib/tag.js +37 -0
- package/lib/team/members/actions.js +99 -0
- package/lib/team/members/index.js +503 -0
- package/lib/team/members/invitations.js +196 -0
- package/lib/team/members/invite-member.js +212 -0
- package/lib/team/members/issue-passport.js +155 -0
- package/lib/team/members/member.js +300 -0
- package/lib/team/members/passport-issuances.js +154 -0
- package/lib/team/members/passports.js +336 -0
- package/lib/team/members/toggle-user-approval.js +128 -0
- package/lib/team/members/transfer-node.js +262 -0
- package/lib/team/members/util.js +20 -0
- package/lib/team/passports/color.js +132 -0
- package/lib/team/passports/detail.js +271 -0
- package/lib/team/passports/index.js +233 -0
- package/lib/team/passports/mutate-role.js +204 -0
- package/lib/team/passports/trusted-issuer.js +297 -0
- package/lib/team/passports/trusted-issuers.js +240 -0
- package/lib/team/search-input.js +38 -0
- package/lib/team/styles/dialog.js +13 -0
- package/lib/team/styles/list-header.js +13 -0
- package/lib/toast.js +86 -0
- package/lib/util/api.js +21 -0
- package/lib/util/constants.js +10 -0
- package/lib/util/index.js +703 -0
- package/lib/util/locales.js +28 -0
- package/lib/util/mode.js +11 -0
- package/lib/who-can-access/config.js +46 -0
- package/lib/wrap-locale.js +12 -13
- package/package.json +69 -17
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = RelativeTime;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _prettyMsI18n = _interopRequireDefault(require("pretty-ms-i18n"));
|
|
9
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
10
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
+
var _util = require("./util");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function RelativeTime(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
value
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
t,
|
|
20
|
+
locale
|
|
21
|
+
} = (0, _context.useLocaleContext)();
|
|
22
|
+
if (!value) {
|
|
23
|
+
return '-';
|
|
24
|
+
}
|
|
25
|
+
const prettyOption = {
|
|
26
|
+
locale: locale === 'zh' ? 'zh_CN' : 'zh_US',
|
|
27
|
+
compact: true
|
|
28
|
+
};
|
|
29
|
+
const valTime = new Date(value).getTime();
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
if (valTime > now) {
|
|
32
|
+
const time = (0, _prettyMsI18n.default)(valTime - now, prettyOption);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
34
|
+
title: (0, _util.formatToDatetime)(value),
|
|
35
|
+
placement: "top-end",
|
|
36
|
+
enterTouchDelay: 0,
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
38
|
+
children: t('common.afterTime', {
|
|
39
|
+
time
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const time = (0, _prettyMsI18n.default)(now - valTime, prettyOption);
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
46
|
+
title: (0, _util.formatToDatetime)(value),
|
|
47
|
+
placement: "top-end",
|
|
48
|
+
enterTouchDelay: 0,
|
|
49
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
50
|
+
children: t('common.timeAgo', {
|
|
51
|
+
time
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
RelativeTime.propTypes = {
|
|
57
|
+
value: _propTypes.default.any
|
|
58
|
+
};
|
|
59
|
+
RelativeTime.defaultProps = {
|
|
60
|
+
value: ''
|
|
61
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ColorInput;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
+
var _Popover = _interopRequireDefault(require("@mui/material/Popover"));
|
|
10
|
+
var _reactColor = require("react-color");
|
|
11
|
+
var _commonPropTypes = _interopRequireDefault(require("./common-prop-types"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function ColorInput(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
editing,
|
|
17
|
+
value,
|
|
18
|
+
onChange
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
21
|
+
const colorElm = (0, _react.useRef)();
|
|
22
|
+
const colorValue = (0, _react.useRef)(value);
|
|
23
|
+
|
|
24
|
+
// auto open color picker when editing, should wait the useRef to be ready
|
|
25
|
+
(0, _react.useEffect)(() => {
|
|
26
|
+
let timer = null;
|
|
27
|
+
if (editing) {
|
|
28
|
+
timer = setTimeout(() => {
|
|
29
|
+
setOpen(true);
|
|
30
|
+
}, 50);
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
};
|
|
35
|
+
}, [editing]);
|
|
36
|
+
const onColorChange = color => {
|
|
37
|
+
colorValue.current = color;
|
|
38
|
+
onChange(color);
|
|
39
|
+
};
|
|
40
|
+
const handleEnterKeyDown = () => {
|
|
41
|
+
setOpen(false);
|
|
42
|
+
onChange(colorValue.current);
|
|
43
|
+
};
|
|
44
|
+
const ReadView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
45
|
+
className: "form-item-input slot",
|
|
46
|
+
px: 1,
|
|
47
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
48
|
+
display: "flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
children: [value, value !== 'auto' && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
51
|
+
style: {
|
|
52
|
+
marginLeft: 4,
|
|
53
|
+
backgroundColor: value,
|
|
54
|
+
width: '1em',
|
|
55
|
+
height: '1em',
|
|
56
|
+
borderRadius: '0.2em'
|
|
57
|
+
}
|
|
58
|
+
})]
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
const EditView = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
62
|
+
display: "flex",
|
|
63
|
+
flexGrow: 1,
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
height: "40px",
|
|
66
|
+
onKeyDown: handleEnterKeyDown,
|
|
67
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
68
|
+
display: "flex",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
onClick: () => setOpen(true),
|
|
71
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
72
|
+
ref: colorElm,
|
|
73
|
+
style: {
|
|
74
|
+
flexShrink: 0,
|
|
75
|
+
marginLeft: '8px',
|
|
76
|
+
backgroundColor: value,
|
|
77
|
+
width: '32px',
|
|
78
|
+
height: '32px',
|
|
79
|
+
boxSizing: 'border-box',
|
|
80
|
+
borderRadius: '8px',
|
|
81
|
+
border: '1px solid #eee',
|
|
82
|
+
cursor: value === 'auto' ? 'default' : 'pointer'
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
86
|
+
open: open,
|
|
87
|
+
anchorEl: colorElm.current,
|
|
88
|
+
onClose: () => setOpen(false),
|
|
89
|
+
anchorOrigin: {
|
|
90
|
+
vertical: 'bottom',
|
|
91
|
+
horizontal: 'center'
|
|
92
|
+
},
|
|
93
|
+
transformOrigin: {
|
|
94
|
+
vertical: 'top',
|
|
95
|
+
horizontal: 'center'
|
|
96
|
+
},
|
|
97
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactColor.ChromePicker, {
|
|
98
|
+
color: value,
|
|
99
|
+
onChange: c => onColorChange(c.hex)
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
});
|
|
103
|
+
return editing ? EditView : ReadView;
|
|
104
|
+
}
|
|
105
|
+
ColorInput.propTypes = _commonPropTypes.default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = {
|
|
10
|
+
description: _propTypes.default.string,
|
|
11
|
+
editing: _propTypes.default.bool,
|
|
12
|
+
onChange: _propTypes.default.func,
|
|
13
|
+
required: _propTypes.default.bool,
|
|
14
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
15
|
+
value: _propTypes.default.any,
|
|
16
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
17
|
+
componentProps: _propTypes.default.object,
|
|
18
|
+
render: _propTypes.default.func,
|
|
19
|
+
renderFormItem: _propTypes.default.func
|
|
20
|
+
};
|
|
21
|
+
exports.default = _default;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = SchemaForm;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
11
|
+
var _EditIcon = _interopRequireDefault(require("@arcblock/icons/lib/EditIcon"));
|
|
12
|
+
var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
|
|
13
|
+
var _Done = _interopRequireDefault(require("@mui/icons-material/Done"));
|
|
14
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
15
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
16
|
+
var _colorInput = _interopRequireDefault(require("./color-input"));
|
|
17
|
+
var _textInput = _interopRequireDefault(require("./text-input"));
|
|
18
|
+
var _passportInput = _interopRequireDefault(require("./passport-input"));
|
|
19
|
+
var _required = _interopRequireDefault(require("../form/required"));
|
|
20
|
+
var _formWrapper = _interopRequireDefault(require("../form/form-wrapper"));
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
var _templateObject;
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
25
|
+
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; }
|
|
26
|
+
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; }
|
|
27
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
29
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
|
+
function getComponent(item, _ref) {
|
|
31
|
+
let {
|
|
32
|
+
editing = false
|
|
33
|
+
} = _ref;
|
|
34
|
+
const {
|
|
35
|
+
componentType = 'input',
|
|
36
|
+
render,
|
|
37
|
+
renderFormItem
|
|
38
|
+
} = item;
|
|
39
|
+
// if provided renderItem and editing is true, use it
|
|
40
|
+
if (editing && renderFormItem) {
|
|
41
|
+
return renderFormItem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if provided render and editing is false, use it
|
|
45
|
+
if (!editing && render) {
|
|
46
|
+
return render;
|
|
47
|
+
}
|
|
48
|
+
const componentMap = {
|
|
49
|
+
input: _textInput.default,
|
|
50
|
+
color: _colorInput.default,
|
|
51
|
+
passport: _passportInput.default
|
|
52
|
+
};
|
|
53
|
+
return componentMap[componentType === null || componentType === void 0 ? void 0 : componentType.toLowerCase()];
|
|
54
|
+
}
|
|
55
|
+
function SchemaForm(_ref2) {
|
|
56
|
+
let {
|
|
57
|
+
schema,
|
|
58
|
+
loading,
|
|
59
|
+
value,
|
|
60
|
+
defaultValue,
|
|
61
|
+
onChange,
|
|
62
|
+
style,
|
|
63
|
+
disabled
|
|
64
|
+
} = _ref2;
|
|
65
|
+
const isControlled = Object.prototype.toString.call(value) === '[object Object]';
|
|
66
|
+
const [editingItem, setEditingItem] = (0, _react.useState)(null);
|
|
67
|
+
const [formValues, setFormValues] = (0, _react.useState)(isControlled ? value : defaultValue);
|
|
68
|
+
const editingItemInitialValue = (0, _react.useRef)();
|
|
69
|
+
function onFormItemChange(item, changeValue, action) {
|
|
70
|
+
const {
|
|
71
|
+
key,
|
|
72
|
+
secure
|
|
73
|
+
} = item;
|
|
74
|
+
const oldValue = formValues[key];
|
|
75
|
+
const isChanged = oldValue !== changeValue;
|
|
76
|
+
const newValues = _objectSpread(_objectSpread({}, formValues), {}, {
|
|
77
|
+
[key]: changeValue
|
|
78
|
+
});
|
|
79
|
+
if (isChanged) {
|
|
80
|
+
setFormValues(newValues);
|
|
81
|
+
}
|
|
82
|
+
onChange({
|
|
83
|
+
[key]: changeValue
|
|
84
|
+
}, {
|
|
85
|
+
allValues: newValues,
|
|
86
|
+
action,
|
|
87
|
+
currentItem: item
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// hide secure text after confirm
|
|
91
|
+
if (action === 'confirm' && secure) {
|
|
92
|
+
setFormValues(_objectSpread(_objectSpread({}, formValues), {}, {
|
|
93
|
+
[key]: '__encrypted__'
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
if (['confirm', 'cancel'].includes(action)) {
|
|
97
|
+
onItemEditingStatusChange(null);
|
|
98
|
+
} else {
|
|
99
|
+
onItemEditingStatusChange(item);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function onItemEditingStatusChange(item) {
|
|
103
|
+
if (item) {
|
|
104
|
+
editingItemInitialValue.current = formValues[item.key];
|
|
105
|
+
setEditingItem(item);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
editingItemInitialValue.current = null;
|
|
109
|
+
setEditingItem(null);
|
|
110
|
+
}
|
|
111
|
+
function getValue(item, _ref3) {
|
|
112
|
+
let {
|
|
113
|
+
editing = false
|
|
114
|
+
} = _ref3;
|
|
115
|
+
const {
|
|
116
|
+
key
|
|
117
|
+
} = item;
|
|
118
|
+
const currentValue = isControlled ? value[key] : formValues[key];
|
|
119
|
+
if (currentValue === '__encrypted__') {
|
|
120
|
+
if (!editing) {
|
|
121
|
+
return '******';
|
|
122
|
+
}
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
125
|
+
return currentValue;
|
|
126
|
+
}
|
|
127
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFormWrapper, {
|
|
128
|
+
className: "form",
|
|
129
|
+
style: style,
|
|
130
|
+
children: schema === null || schema === void 0 ? void 0 : schema.map(x => {
|
|
131
|
+
const {
|
|
132
|
+
key,
|
|
133
|
+
description,
|
|
134
|
+
required,
|
|
135
|
+
hidden = false,
|
|
136
|
+
componentProps = {}
|
|
137
|
+
} = x;
|
|
138
|
+
if (hidden) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const editing = !!(editingItem && key === editingItem.key);
|
|
142
|
+
const currentValue = getValue(x, {
|
|
143
|
+
editing
|
|
144
|
+
});
|
|
145
|
+
// get component by componentType
|
|
146
|
+
const CurrentComponent = getComponent(x, {
|
|
147
|
+
editing
|
|
148
|
+
});
|
|
149
|
+
const renderComponentProps = {
|
|
150
|
+
inputProps: {
|
|
151
|
+
'data-cy': 'schema-form-item-component'
|
|
152
|
+
},
|
|
153
|
+
key,
|
|
154
|
+
description,
|
|
155
|
+
editing,
|
|
156
|
+
value: currentValue,
|
|
157
|
+
onChange: function onChange(changeValue) {
|
|
158
|
+
let action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'change';
|
|
159
|
+
return onFormItemChange(x, changeValue, action);
|
|
160
|
+
},
|
|
161
|
+
componentProps
|
|
162
|
+
};
|
|
163
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
164
|
+
className: "form-item",
|
|
165
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
166
|
+
className: "form-item-label",
|
|
167
|
+
style: {
|
|
168
|
+
color: required && !currentValue ? '#ff0000' : '#333'
|
|
169
|
+
},
|
|
170
|
+
children: [description, required && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
|
|
171
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
172
|
+
className: "form-item-body",
|
|
173
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
174
|
+
className: "form-item-input",
|
|
175
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CurrentComponent, _objectSpread({}, renderComponentProps))
|
|
176
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
177
|
+
className: "form-item-action",
|
|
178
|
+
children: editing ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
179
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
180
|
+
"data-cy": "schema-form-item-confirm",
|
|
181
|
+
onClick: () => {
|
|
182
|
+
onFormItemChange(x, currentValue, 'confirm');
|
|
183
|
+
},
|
|
184
|
+
disabled: disabled || loading,
|
|
185
|
+
size: "large",
|
|
186
|
+
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
187
|
+
size: 24
|
|
188
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Done.default, {})
|
|
189
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
190
|
+
"data-cy": "schema-form-item-cancel",
|
|
191
|
+
onClick: () => {
|
|
192
|
+
onFormItemChange(x, editingItemInitialValue.current, 'cancel');
|
|
193
|
+
},
|
|
194
|
+
disabled: disabled || loading,
|
|
195
|
+
size: "large",
|
|
196
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {})
|
|
197
|
+
})]
|
|
198
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
199
|
+
"data-cy": "schema-form-item-edit",
|
|
200
|
+
onClick: () => {
|
|
201
|
+
onFormItemChange(x, formValues[key], 'edit');
|
|
202
|
+
},
|
|
203
|
+
disabled: disabled || editingItem,
|
|
204
|
+
size: "large",
|
|
205
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditIcon.default, {})
|
|
206
|
+
})
|
|
207
|
+
})]
|
|
208
|
+
})]
|
|
209
|
+
}, key);
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
SchemaForm.propTypes = {
|
|
214
|
+
schema: _propTypes.default.array.isRequired,
|
|
215
|
+
loading: _propTypes.default.bool,
|
|
216
|
+
onChange: _propTypes.default.func.isRequired,
|
|
217
|
+
value: _propTypes.default.object,
|
|
218
|
+
defaultValue: _propTypes.default.object,
|
|
219
|
+
style: _propTypes.default.object,
|
|
220
|
+
disabled: _propTypes.default.bool
|
|
221
|
+
};
|
|
222
|
+
SchemaForm.defaultProps = {
|
|
223
|
+
loading: false,
|
|
224
|
+
value: undefined,
|
|
225
|
+
defaultValue: {},
|
|
226
|
+
style: {},
|
|
227
|
+
disabled: false
|
|
228
|
+
};
|
|
229
|
+
const StyledFormWrapper = (0, _styled.default)(_formWrapper.default)(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = PassportInput;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
+
var _createPassportSvg = _interopRequireDefault(require("@abtnode/auth/lib/util/create-passport-svg"));
|
|
10
|
+
var _passportColor = require("@abtnode/auth/lib/util/passport-color");
|
|
11
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
12
|
+
var _colorInput = _interopRequireDefault(require("./color-input"));
|
|
13
|
+
var _commonPropTypes = _interopRequireDefault(require("./common-prop-types"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const _excluded = ["editing", "value", "onChange", "componentProps"];
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
function PassportInput(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
editing,
|
|
27
|
+
value,
|
|
28
|
+
onChange,
|
|
29
|
+
componentProps
|
|
30
|
+
} = _ref,
|
|
31
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
const {
|
|
33
|
+
blocklet
|
|
34
|
+
} = componentProps;
|
|
35
|
+
const color = value === 'auto' ? (0, _passportColor.getPassportColorFromDid)(blocklet.appDid) : value;
|
|
36
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
37
|
+
display: "flex",
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
40
|
+
style: {
|
|
41
|
+
width: 96,
|
|
42
|
+
marginRight: 12
|
|
43
|
+
},
|
|
44
|
+
alt: "",
|
|
45
|
+
src: (0, _createPassportSvg.default)({
|
|
46
|
+
title: 'Owner',
|
|
47
|
+
issuer: (0, _util.getDisplayName)(blocklet),
|
|
48
|
+
issuerDid: blocklet.appDid,
|
|
49
|
+
ownerName: 'Your Name',
|
|
50
|
+
isDataUrl: true,
|
|
51
|
+
preferredColor: value || 'auto'
|
|
52
|
+
})
|
|
53
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_colorInput.default, _objectSpread(_objectSpread({}, rest), {}, {
|
|
54
|
+
editing: editing,
|
|
55
|
+
value: editing ? color : value,
|
|
56
|
+
onChange: onChange,
|
|
57
|
+
componentProps: componentProps
|
|
58
|
+
}))]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
PassportInput.propTypes = _objectSpread(_objectSpread({}, _commonPropTypes.default), {}, {
|
|
62
|
+
componentProps: _propTypes.default.shape({
|
|
63
|
+
blocklet: _propTypes.default.object.isRequired
|
|
64
|
+
}).isRequired
|
|
65
|
+
});
|
|
66
|
+
PassportInput.defaultProps = {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = TextInput;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
10
|
+
var _commonPropTypes = _interopRequireDefault(require("./common-prop-types"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
const _excluded = ["editing", "description", "value", "onChange", "componentProps"];
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
function TextInput(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
editing,
|
|
24
|
+
description,
|
|
25
|
+
value,
|
|
26
|
+
onChange,
|
|
27
|
+
componentProps
|
|
28
|
+
} = _ref,
|
|
29
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
const {
|
|
31
|
+
placeholder
|
|
32
|
+
} = componentProps;
|
|
33
|
+
const inputValue = (0, _react.useRef)(value);
|
|
34
|
+
|
|
35
|
+
// enter keydown
|
|
36
|
+
const handleKeydown = e => {
|
|
37
|
+
if (e.key === 'Enter') {
|
|
38
|
+
onChange(inputValue.current, 'confirm');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const onInputChange = changeValue => {
|
|
42
|
+
inputValue.current = changeValue;
|
|
43
|
+
onChange(changeValue);
|
|
44
|
+
};
|
|
45
|
+
if (editing) {
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, _objectSpread({
|
|
47
|
+
style: {
|
|
48
|
+
flex: 1
|
|
49
|
+
},
|
|
50
|
+
fullWidth: true,
|
|
51
|
+
value: value,
|
|
52
|
+
onChange: e => {
|
|
53
|
+
e.persist();
|
|
54
|
+
onInputChange(e.target.value);
|
|
55
|
+
},
|
|
56
|
+
autoFocus: true,
|
|
57
|
+
size: "small",
|
|
58
|
+
variant: "outlined",
|
|
59
|
+
placeholder: description || placeholder,
|
|
60
|
+
onKeyDown: handleKeydown
|
|
61
|
+
}, rest));
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
64
|
+
px: 1,
|
|
65
|
+
className: "form-item-input slot",
|
|
66
|
+
children: value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
TextInput.propTypes = _commonPropTypes.default;
|
|
70
|
+
TextInput.defaultProps = {
|
|
71
|
+
componentProps: {}
|
|
72
|
+
};
|