@abtnode/ux 1.8.67-beta-794a8082 → 1.8.68-beta-500af7e5

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.
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
10
+ var _urlJoin = _interopRequireDefault(require("url-join"));
11
+ var _isUrl = _interopRequireDefault(require("is-url"));
12
+ var _useLocalStorage = _interopRequireDefault(require("react-use/lib/useLocalStorage"));
13
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
14
+ var _context = require("@arcblock/ux/lib/Locale/context");
15
+ var _material = require("@mui/material");
16
+ var _Autocomplete = _interopRequireWildcard(require("@mui/material/Autocomplete"));
17
+ var _session = require("../../../lib/contexts/session");
18
+ var _toast = _interopRequireDefault(require("../../toast"));
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ var _templateObject;
21
+ const _excluded = ["onSelect", "endpoint", "loading"];
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ 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); }
24
+ 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; }
25
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
26
+ 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; }
27
+ 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; }
28
+ 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; }
29
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
30
+ 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); }
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 DEFAULT_GATEWAY_LIST = [{
34
+ value: 'https://www.didspaces.com/app',
35
+ label: 'Prod DID Spaces',
36
+ avatar: 'P'
37
+ }, {
38
+ value: 'https://storage.staging.abtnet.io/app',
39
+ label: 'Staging DID Spaces',
40
+ avatar: 'S'
41
+ }];
42
+ const filter = (0, _Autocomplete.createFilterOptions)();
43
+ function SpaceGatewaySelector(_ref) {
44
+ let {
45
+ onSelect,
46
+ endpoint,
47
+ loading
48
+ } = _ref,
49
+ rest = _objectWithoutProperties(_ref, _excluded);
50
+ const [gatewayList, setGatewayList] = (0, _useLocalStorage.default)('did-space-gateway-list', DEFAULT_GATEWAY_LIST);
51
+ const [gatewayUrl, setGatewayUrl] = (0, _useLocalStorage.default)('did-space-gateway-url', DEFAULT_GATEWAY_LIST[0].value);
52
+ const {
53
+ t
54
+ } = (0, _context.useLocaleContext)();
55
+ const {
56
+ api
57
+ } = (0, _session.useSessionContext)();
58
+ (0, _react.useEffect)(() => {
59
+ if (gatewayUrl && !gatewayList.find(x => x.value === gatewayUrl)) {
60
+ api.get((0, _urlJoin.default)(gatewayUrl, '/__blocklet__.js?type=json')).then(res => {
61
+ // FIXME: @wangshijun handle mountPoint
62
+ setGatewayList([...gatewayList, {
63
+ value: gatewayUrl,
64
+ label: res.data.appName
65
+ }]);
66
+ }).catch(err => {
67
+ console.error(err);
68
+ _toast.default.error('Can not add this gateway, please check the url and try again');
69
+ });
70
+ }
71
+ }, [gatewayUrl]); // eslint-disable-line
72
+
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Container, _objectSpread(_objectSpread({}, rest), {}, {
74
+ freeSolo: true,
75
+ selectOnFocus: true,
76
+ clearOnBlur: true,
77
+ handleHomeEndKeys: true,
78
+ value: gatewayUrl,
79
+ options: gatewayList,
80
+ onChange: (e, v) => {
81
+ if (!v) {
82
+ return;
83
+ }
84
+ if (typeof v === 'string') {
85
+ const x = gatewayList.find(o => o.label === v);
86
+ if (x) {
87
+ setGatewayUrl(x.value);
88
+ }
89
+ } else if (v.inputValue) {
90
+ // Create a new value from the user input
91
+ setGatewayUrl(v.inputValue);
92
+ } else if (v.value) {
93
+ setGatewayUrl(v.value);
94
+ }
95
+ },
96
+ getOptionLabel: x => {
97
+ // Value selected with enter, right from the input
98
+ if (typeof x === 'string') {
99
+ return x;
100
+ }
101
+
102
+ // Add "xxx" x created dynamically
103
+ if (x.inputValue) {
104
+ return x.inputValue;
105
+ }
106
+ return x.label;
107
+ },
108
+ renderOption: (props, x) => {
109
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItem, _objectSpread(_objectSpread({}, props), {}, {
110
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemAvatar, {
111
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Avatar, {
112
+ children: x.avatar
113
+ })
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
115
+ primary: x.label,
116
+ secondary: x.value
117
+ })]
118
+ }), x.value);
119
+ },
120
+ filterOptions: (options, params) => {
121
+ const filtered = filter(options, params);
122
+
123
+ // Suggest the creation of a new value if its a valid url
124
+ if (params.inputValue && (0, _isUrl.default)(params.inputValue)) {
125
+ const isExisting = options.some(x => params.inputValue === x.value);
126
+ if (!isExisting) {
127
+ filtered.push({
128
+ value: params.inputValue,
129
+ label: 'Add new gateway'
130
+ });
131
+ }
132
+ }
133
+ return filtered;
134
+ },
135
+ renderInput: params => {
136
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, params), {}, {
137
+ label: t('storage.spaces.label'),
138
+ size: "small",
139
+ InputProps: _objectSpread(_objectSpread({}, params.InputProps), {}, {
140
+ type: 'search',
141
+ endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
142
+ variant: "contained",
143
+ onClick: () => onSelect(gatewayUrl),
144
+ size: "small",
145
+ loading: loading,
146
+ disable: loading,
147
+ sx: {
148
+ position: 'absolute',
149
+ right: 0,
150
+ display: 'flex',
151
+ justifyContent: 'center',
152
+ alignItems: 'center',
153
+ width: '100px',
154
+ height: '100%'
155
+ },
156
+ children: endpoint ? t('storage.spaces.reconnect') : t('storage.spaces.connect')
157
+ })
158
+ })
159
+ }));
160
+ }
161
+ }));
162
+ }
163
+ const Container = (0, _styled.default)(_Autocomplete.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 40px;\n width: 100%;\n max-width: 720px;\n ", " {\n width: 75%;\n }\n input.MuiInputBase-input {\n max-width: calc(100% - 80px);\n }\n"])), props => props.theme.breakpoints.down('md'));
164
+ SpaceGatewaySelector.propTypes = {
165
+ onSelect: _propTypes.default.func.isRequired,
166
+ endpoint: _propTypes.default.string,
167
+ loading: _propTypes.default.bool
168
+ };
169
+ SpaceGatewaySelector.defaultProps = {
170
+ endpoint: undefined,
171
+ loading: false
172
+ };
173
+ var _default = SpaceGatewaySelector;
174
+ exports.default = _default;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = BlockletEnvironmentWithPermission;
7
- var _react = require("react");
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _styled = _interopRequireDefault(require("@emotion/styled"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  var _get = _interopRequireDefault(require("lodash/get"));
@@ -41,6 +41,8 @@ var _templateObject;
41
41
  const _excluded = ["blocklet", "onUpdate", "hasPermission"],
42
42
  _excluded2 = ["value"];
43
43
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
+ 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); }
45
+ 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; }
44
46
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
45
47
  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; }
46
48
  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; }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = BlockletOverview;
7
+ var _react = _interopRequireDefault(require("react"));
7
8
  var _styled = _interopRequireDefault(require("@emotion/styled"));
8
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
@@ -113,13 +114,25 @@ function BlockletOverview() {
113
114
  loadingRuntimeInfo
114
115
  } = (0, _blocklet.useBlockletContext)();
115
116
  const {
116
- value: appDid
117
- } = (blocklet.environments || []).find(x => x.key === 'BLOCKLET_APP_ID') || {};
117
+ appDid,
118
+ appPid,
119
+ migratedFrom = []
120
+ } = blocklet;
118
121
  const infoRows = [appDid ? {
119
122
  name: t('blocklet.appId'),
120
123
  value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_didAddress.default, {
121
124
  did: appDid
122
125
  })
126
+ } : null, appPid ? {
127
+ name: t('blocklet.appPid'),
128
+ value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_didAddress.default, {
129
+ did: appPid
130
+ })
131
+ } : null, migratedFrom !== null && migratedFrom !== void 0 && migratedFrom.length ? {
132
+ name: t('blocklet.alsoKnownAs'),
133
+ value: migratedFrom.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_didAddress.default, {
134
+ did: x.appDid
135
+ }))
123
136
  } : null, {
124
137
  name: t('common.name'),
125
138
  value: (0, _util.getDisplayName)(blocklet, true)
@@ -4,13 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = AppSk;
7
- var _react = require("react");
7
+ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _styled = _interopRequireDefault(require("@emotion/styled"));
10
+ var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
11
+ var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
10
12
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
11
13
  var _context = require("@arcblock/ux/lib/Locale/context");
12
14
  var _formTextInput = _interopRequireDefault(require("../../form/form-text-input"));
13
15
  var _confirm = _interopRequireDefault(require("../../confirm"));
16
+ var _session = require("../../contexts/session");
17
+ var _blocklet = require("../../contexts/blocklet");
14
18
  var _jsxRuntime = require("react/jsx-runtime");
15
19
  var _templateObject;
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -25,10 +29,19 @@ function AppSk(_ref) {
25
29
  const {
26
30
  t
27
31
  } = (0, _context.useLocaleContext)();
28
- const [confirmAppSk, setConfirmAppSk] = (0, _react.useState)(null);
32
+ const {
33
+ api
34
+ } = (0, _session.useSessionContext)();
35
+ const {
36
+ blocklet
37
+ } = (0, _blocklet.useBlockletContext)();
38
+ const [state, setState] = (0, _useSetState.default)({
39
+ newAppSk: '',
40
+ isConnectOpen: false
41
+ });
29
42
  const onAppSkChange = value => {
30
- setConfirmAppSk({
31
- value
43
+ setState({
44
+ newAppSk: value
32
45
  });
33
46
  return false;
34
47
  };
@@ -36,16 +49,29 @@ function AppSk(_ref) {
36
49
  try {
37
50
  await onChange(v);
38
51
  } finally {
39
- setConfirmAppSk(null);
52
+ setState({
53
+ newAppSk: ''
54
+ });
40
55
  }
41
56
  };
57
+ const onClose = () => setState({
58
+ isConnectOpen: false
59
+ });
60
+ const triggers = [{
61
+ key: 'rotate-with-did-wallet',
62
+ title: 'Migrate with DID Wallet',
63
+ handler: () => setState({
64
+ isConnectOpen: true
65
+ })
66
+ }];
42
67
  return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
43
68
  disabled: disabled,
44
69
  loading: loading,
45
70
  initialValue: initialValue,
46
71
  onSubmit: onAppSkChange,
72
+ triggers: triggers,
47
73
  secure: true
48
- }), confirmAppSk && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
74
+ }), state.newAppSk && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
49
75
  title: t('blocklet.config.appSkTitle'),
50
76
  description: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
51
77
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
@@ -64,8 +90,28 @@ function AppSk(_ref) {
64
90
  }),
65
91
  confirm: t('confirm'),
66
92
  cancel: t('cancel'),
67
- onConfirm: () => _onConfirm(confirmAppSk.value),
68
- onCancel: () => setConfirmAppSk(null)
93
+ onConfirm: () => _onConfirm(state.newAppSk),
94
+ onCancel: () => setState({
95
+ newAppSk: ''
96
+ })
97
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
98
+ popup: true,
99
+ open: state.isConnectOpen,
100
+ forceConnected: false,
101
+ action: "rotate-key-pair",
102
+ checkFn: api.get,
103
+ checkTimeout: 5 * 60 * 1000,
104
+ onSuccess: onClose,
105
+ extraParams: {
106
+ appDid: blocklet.appDid
107
+ },
108
+ messages: {
109
+ title: t('setup.keyPair.title'),
110
+ scan: t('setup.keyPair.scan'),
111
+ confirm: t('setup.keyPair.confirm'),
112
+ success: t('setup.keyPair.success')
113
+ },
114
+ onClose: onClose
69
115
  })];
70
116
  }
71
117
  AppSk.propTypes = {
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Storage;
7
+ var _react = _interopRequireWildcard(require("react"));
7
8
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
8
9
  var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
9
- var _react = require("react");
10
10
  var _context = require("@arcblock/ux/lib/Locale/context");
11
11
  var _constant = require("@blocklet/constant");
12
12
  var _axios = _interopRequireDefault(require("axios"));
@@ -14,35 +14,77 @@ var _urlJoin = _interopRequireDefault(require("url-join"));
14
14
  var _styled = _interopRequireDefault(require("@emotion/styled"));
15
15
  var _lodash = require("lodash");
16
16
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
17
- var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
18
17
  var _material = require("@mui/material");
19
18
  var _blocklet = require("../../lib/contexts/blocklet");
20
19
  var _node = require("../contexts/node");
21
20
  var _toast = _interopRequireDefault(require("../../lib/toast"));
21
+ var _spaceGatewaySelector = _interopRequireDefault(require("./component/space-gateway-selector"));
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
- var _templateObject, _templateObject2;
23
+ var _templateObject;
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
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; }
26
27
  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; }
27
28
  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; }
28
29
  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; }
29
30
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
30
31
  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); }
31
- function Storage() {
32
- var _localStorage$getItem, _blocklet$environment, _blocklet$environment2, _blocklet$environment3;
33
- const options = [
34
- // TODO: 测试用,上线后才需删除
35
- {
36
- value: (_localStorage$getItem = localStorage.getItem('test-spaces')) !== null && _localStorage$getItem !== void 0 && _localStorage$getItem.startsWith('http') ? localStorage.getItem('test-spaces') : 'https://bbqazi2fhuczchrlggs4njj2bucbvnwjjm2xlq6yk6i.did.abtnet.io',
37
- label: 'test spaces'
38
- }, {
39
- value: 'https://storage.staging.abtnet.io/app',
40
- label: 'staging spaces'
41
- }, {
42
- value: 'https://service.didspaces.com/app',
43
- label: 'prod spaces'
44
- }];
32
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
33
+ const Container = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
34
+
35
+ /**
36
+ * @description 实时显示备份的进度
37
+ * @param {{appDid: string}} {appDid}
38
+ * @return {{message: string, progress: number, completed: boolean}}
39
+ */
40
+ function useBackupProgress(_ref) {
41
+ let {
42
+ appDid
43
+ } = _ref;
44
+ const [progress, setProgress] = (0, _react.useState)({
45
+ message: '',
46
+ progress: 0,
47
+ completed: false
48
+ });
49
+ const node = (0, _node.useNodeContext)();
50
+ const webSocketClient = node.ws.getWsClient();
51
+ (0, _react.useEffect)(() => {
52
+ webSocketClient.on(_constant.BlockletEvents.backupProgress, data => {
53
+ if (appDid === (data === null || data === void 0 ? void 0 : data.did)) {
54
+ setProgress(preValue => _objectSpread(_objectSpread({}, preValue), data));
55
+ }
56
+ });
57
+ return () => {
58
+ webSocketClient.off(_constant.BlockletEvents.backupProgress);
59
+ };
60
+ }, [appDid, webSocketClient]);
61
+ return progress;
62
+ }
63
+
64
+ /**
65
+ *
66
+ *
67
+ * @param {import('@abtnode/client').BlockletState} blocklet
68
+ * @return {*}
69
+ */
70
+ function useAppUrl(blocklet) {
71
+ var _blocklet$site, _blocklet$site$domain, _blocklet$site$domain2;
72
+ const appUrls = blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$site = blocklet.site) === null || _blocklet$site === void 0 ? void 0 : (_blocklet$site$domain = _blocklet$site.domainAliases) === null || _blocklet$site$domain === void 0 ? void 0 : (_blocklet$site$domain2 = _blocklet$site$domain.sort((a, b) => {
73
+ if (a.accessibility.accessible && b.accessibility.accessible) {
74
+ return +a.isProtected - +b.isProtected;
75
+ }
76
+ return +b.accessibility.accessible - +a.accessibility.accessible;
77
+ })) === null || _blocklet$site$domain2 === void 0 ? void 0 : _blocklet$site$domain2.map(domainAlias => domainAlias.accessibility.url);
78
+ const appUrl = appUrls === null || appUrls === void 0 ? void 0 : appUrls[0];
45
79
 
80
+ // 授权的时候提供 appUrl, 因为 appUrl 可能很久都拿不到值,所以加一个 loading 效果过渡一下
81
+ return {
82
+ appUrl,
83
+ isReady: Boolean(appUrl)
84
+ };
85
+ }
86
+ function Storage() {
87
+ var _blocklet$environment;
46
88
  /** @type {{ api: import('@abtnode/client').ABTNodeClient }} */
47
89
  const {
48
90
  api
@@ -51,13 +93,15 @@ function Storage() {
51
93
  t,
52
94
  locale
53
95
  } = (0, _react.useContext)(_context.LocaleContext);
54
- const [errorMessage, setErrorMessage] = (0, _react.useState)(false);
55
96
  /** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
56
97
  const {
57
98
  blocklet
58
99
  } = (0, _blocklet.useBlockletContext)();
100
+ const [gatewayUrl, setGatewayUrl] = (0, _react.useState)('');
59
101
  const [endpoint, setEndpoint] = (0, _react.useState)(((_blocklet$environment = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)) === null || _blocklet$environment === void 0 ? void 0 : _blocklet$environment.value) || '');
60
- const [didSpacesUrl, setDidSpacesUrl] = (0, _react.useState)((_blocklet$environment2 = (_blocklet$environment3 = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACES_URL)) === null || _blocklet$environment3 === void 0 ? void 0 : _blocklet$environment3.value) !== null && _blocklet$environment2 !== void 0 ? _blocklet$environment2 : options[0].value);
102
+ const progress = useBackupProgress({
103
+ appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
104
+ });
61
105
  const [isLoading, setIsLoading] = (0, _react.useState)(false);
62
106
  const {
63
107
  appDid
@@ -66,26 +110,24 @@ function Storage() {
66
110
  title: appName,
67
111
  description: appDescription
68
112
  } = blocklet.meta;
69
-
70
- /**
71
- *
72
- * @param {string} did
73
- * @param {string} storageEndpoint
74
- */
113
+ const {
114
+ appUrl,
115
+ isReady
116
+ } = useAppUrl(blocklet);
75
117
  async function saveStorageEndpoint(did, storageEndpoint) {
76
118
  await api.configBlocklet({
77
119
  input: {
78
120
  did: [did],
79
121
  configs: [{
80
122
  key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACES_URL,
81
- value: didSpacesUrl
123
+ value: gatewayUrl
82
124
  }, {
83
125
  key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT,
84
126
  value: storageEndpoint
85
127
  }]
86
128
  }
87
129
  }).then(() => {
88
- _toast.default.success(t('storage.didSpaces.getSpacesAuthorizeSuccessfully', locale));
130
+ _toast.default.success(t('storage.spaces.connected', locale));
89
131
  }).catch(error => {
90
132
  console.error(error);
91
133
  _toast.default.error(error.message);
@@ -101,49 +143,41 @@ function Storage() {
101
143
  }, 3000);
102
144
  };
103
145
  const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
104
- open: false,
105
- action: 'one-click-authorization',
106
- checkTimeout: 1000 * 300,
107
- checkFn: _axios.default.create({
108
- baseURL: (0, _urlJoin.default)(didSpacesUrl, 'space')
109
- }).get,
110
- onClose: () => {
111
- setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
112
- open: false
113
- }));
114
- }
146
+ open: false
115
147
  });
116
- const handleOnClickAuthorize = async () => {
117
- if ((0, _lodash.isEmpty)(didSpacesUrl)) {
118
- _toast.default.error(t('storage.didSpaces.addressCannotEmpty', locale));
148
+
149
+ // eslint-disable-next-line no-shadow
150
+ const handleOnClickAuthorize = async gatewayUrl => {
151
+ if ((0, _lodash.isEmpty)(gatewayUrl)) {
152
+ _toast.default.error(t('storage.spaces.addressCannotEmpty', locale));
119
153
  return;
120
154
  }
155
+ setGatewayUrl(gatewayUrl);
121
156
  setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
122
- prefix: (0, _urlJoin.default)(didSpacesUrl, 'space/api/did'),
123
- baseUrl: new URL(didSpacesUrl).origin,
157
+ action: 'one-click-authorization',
158
+ checkTimeout: 1000 * 300,
159
+ prefix: (0, _urlJoin.default)(gatewayUrl, 'space/api/did'),
160
+ baseUrl: new URL(gatewayUrl).origin,
124
161
  checkFn: _axios.default.create({
125
- baseURL: (0, _urlJoin.default)(didSpacesUrl, 'space')
162
+ baseURL: (0, _urlJoin.default)(gatewayUrl, 'space')
126
163
  }).get,
127
164
  extraParams: {
128
165
  appDid,
129
166
  appName,
130
167
  appDescription,
131
- scopes: 'list:object read:object write:object'
168
+ scopes: 'list:object read:object write:object',
169
+ appUrl,
170
+ referrer: window.location.href
171
+ },
172
+ onClose: () => {
173
+ // eslint-disable-next-line no-shadow
174
+ setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
175
+ open: false
176
+ }));
132
177
  },
133
178
  open: true
134
179
  }));
135
180
  };
136
- const onDidSpacesUrlChange = event => {
137
- const {
138
- value
139
- } = event.target;
140
- if ((0, _lodash.isEmpty)(value)) {
141
- setErrorMessage(t('storage.didSpaces.addressCannotEmpty', locale));
142
- return;
143
- }
144
- setErrorMessage(null);
145
- setDidSpacesUrl(value);
146
- };
147
181
  const onBackup = async () => {
148
182
  try {
149
183
  if (isLoading) {
@@ -155,7 +189,7 @@ function Storage() {
155
189
  did: blocklet.appDid
156
190
  }
157
191
  });
158
- _toast.default.success(t('storage.didSpaces.backupSuccessfully'));
192
+ _toast.default.success(t('storage.spaces.backupSuccessfully'));
159
193
  } catch (error) {
160
194
  _toast.default.error(error.message);
161
195
  console.error(error);
@@ -166,88 +200,96 @@ function Storage() {
166
200
  (0, _react.useEffect)(() => {
167
201
  setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
168
202
  messages: {
169
- title: t('storage.didSpaces.authorize.title', {
203
+ title: t('storage.spaces.authorize.title', {
170
204
  appName
171
205
  }),
172
- scan: t('storage.didSpaces.authorize.scan', {
206
+ scan: t('storage.spaces.authorize.scan', {
173
207
  appName
174
208
  }),
175
209
  confirm: '',
176
210
  success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
177
211
  gutterBottom: true,
178
- children: t('storage.didSpaces.authorize.success')
212
+ children: t('storage.spaces.authorize.success')
179
213
  })
180
214
  }
181
215
  }));
182
216
  }, [appName, locale, t]);
217
+ (0, _react.useEffect)(() => {
218
+ if (progress !== null && progress !== void 0 && progress.completed) {
219
+ setIsLoading(false);
220
+ } else if (progress !== null && progress !== void 0 && progress.message) {
221
+ setIsLoading(true);
222
+ }
223
+ }, [progress === null || progress === void 0 ? void 0 : progress.completed, progress === null || progress === void 0 ? void 0 : progress.message, t]);
183
224
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
184
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StorageUrlTextField, {
185
- select: true,
225
+ style: {
226
+ maxWidth: '720px'
227
+ },
228
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_spaceGatewaySelector.default, {
186
229
  sx: {
187
- marginTop: '20px'
230
+ marginTop: '24px',
231
+ marginBottom: '40px'
188
232
  },
189
- label: t('storage.didSpaces.label'),
190
- value: didSpacesUrl,
191
- onChange: onDidSpacesUrlChange,
192
- autoFocus: true,
193
- size: "small",
194
- error: !!errorMessage,
195
- helperText: errorMessage,
196
- InputProps: {
197
- endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
198
- variant: "contained",
199
- onClick: handleOnClickAuthorize,
200
- size: "small",
201
- sx: {
202
- position: 'absolute',
203
- right: 0,
204
- display: 'flex',
205
- justifyContent: 'center',
206
- alignItems: 'center',
207
- width: '140px',
208
- height: '100%'
209
- },
210
- children: endpoint ? t('storage.didSpaces.reAuthorization') : t('storage.didSpaces.goToAuthorization')
211
- })
212
- },
213
- children: options.map(option => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
214
- value: option.value,
215
- children: option.label
216
- }, option.value))
217
- }), endpoint && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
218
- color: "text.secondary",
219
- sx: {
220
- marginTop: '20px'
221
- },
222
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
223
- display: "flex",
224
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
225
- display: "inline",
226
- children: [t('storage.didSpaces.tips'), ": \xA0", ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
227
- display: "inline",
228
- color: "primary.main",
229
- fontWeight: "fontWeightBold",
230
- children: t('storage.didSpaces.getSpacesAuthorizeSuccessfully')
231
- })]
232
- })
233
- })
234
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
233
+ onSelect: handleOnClickAuthorize,
234
+ endpoint: endpoint,
235
+ loading: !isReady
236
+ }), endpoint && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
237
+ mt: 3,
235
238
  display: "flex",
236
- justifyContent: "center",
237
- sx: {
238
- maxWidth: '580px',
239
- marginTop: '20px',
240
- padding: '0px 0px'
241
- },
242
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
239
+ alignItems: "center",
240
+ justifyContent: "space-between",
241
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
242
+ display: "inline",
243
+ children: [t('storage.spaces.tips'), ": \xA0", ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
244
+ display: "inline",
245
+ color: "primary.main",
246
+ fontWeight: "fontWeightBold",
247
+ children: t('storage.spaces.connected')
248
+ })]
249
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
243
250
  onClick: onBackup,
244
251
  loading: isLoading,
245
252
  variant: "contained",
246
253
  color: "primary",
247
254
  "data-cy": "add-domain-alias",
248
255
  disabled: !endpoint || isLoading,
249
- children: t('storage.didSpaces.backup')
250
- })
256
+ children: t('storage.spaces.backup')
257
+ })]
258
+ }), isLoading && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
259
+ display: "flex",
260
+ flexDirection: "column",
261
+ justifyContent: "center",
262
+ textAlign: "center",
263
+ marginTop: "16px",
264
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
265
+ color: "primary",
266
+ children: progress === null || progress === void 0 ? void 0 : progress.message
267
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
268
+ sx: {
269
+ display: 'flex',
270
+ alignItems: 'center'
271
+ },
272
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
273
+ sx: {
274
+ width: '100%',
275
+ mr: 1
276
+ },
277
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
278
+ color: "primary",
279
+ variant: "determinate",
280
+ value: progress === null || progress === void 0 ? void 0 : progress.progress
281
+ })
282
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
283
+ sx: {
284
+ minWidth: 35
285
+ },
286
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
287
+ variant: "body2",
288
+ color: "text.secondary",
289
+ children: [progress === null || progress === void 0 ? void 0 : progress.progress, "%"]
290
+ })
291
+ })]
292
+ })]
251
293
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
252
294
  prefix: authorizeConnect.prefix,
253
295
  open: authorizeConnect.open,
@@ -264,6 +306,4 @@ function Storage() {
264
306
  })]
265
307
  });
266
308
  }
267
- const Container = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
268
- const StorageUrlTextField = (0, _styled.default)(_material.TextField)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 56px;\n width: 580px;\n ", " {\n width: 75%;\n }\n input.MuiInputBase-input {\n width: calc(100% - 144px);\n }\n"])), props => props.theme.breakpoints.down('md'));
269
309
  Storage.propTypes = {};
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = FormTextInput;
7
- var _react = require("react");
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
10
10
  var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
@@ -13,11 +13,21 @@ var _EditIcon = _interopRequireDefault(require("@arcblock/icons/lib/EditIcon"));
13
13
  var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
14
14
  var _Done = _interopRequireDefault(require("@mui/icons-material/Done"));
15
15
  var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
16
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
17
+ var _ButtonGroup = _interopRequireDefault(require("@mui/material/ButtonGroup"));
18
+ var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
19
+ var _ClickAwayListener = _interopRequireDefault(require("@mui/material/ClickAwayListener"));
20
+ var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
21
+ var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
22
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
23
+ var _MenuList = _interopRequireDefault(require("@mui/material/MenuList"));
16
24
  var _required = _interopRequireDefault(require("./required"));
17
25
  var _formWrapper = _interopRequireDefault(require("./form-wrapper"));
18
26
  var _jsxRuntime = require("react/jsx-runtime");
19
- const _excluded = ["label", "disabled", "required", "initialValue", "onChange", "placeholder", "style", "onSubmit", "secure", "formatterBeforeSubmit"];
27
+ const _excluded = ["label", "disabled", "required", "initialValue", "onChange", "placeholder", "style", "onSubmit", "secure", "triggers", "formatterBeforeSubmit"];
20
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ 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); }
30
+ 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; }
21
31
  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; }
22
32
  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; }
23
33
  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; }
@@ -25,7 +35,91 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
25
35
  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); }
26
36
  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; }
27
37
  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; }
28
- function FormTextInput(_ref) {
38
+ function InputTriggers(_ref) {
39
+ let {
40
+ triggers,
41
+ onEnterEdit,
42
+ disabled
43
+ } = _ref;
44
+ const anchorRef = _react.default.useRef(null);
45
+ const [open, setOpen] = _react.default.useState(false);
46
+ const handleTriggerClick = cb => {
47
+ setOpen(false);
48
+ cb();
49
+ };
50
+ const handleToggle = () => {
51
+ setOpen(prevOpen => !prevOpen);
52
+ };
53
+ const handleClose = event => {
54
+ if (anchorRef.current && anchorRef.current.contains(event.target)) {
55
+ return;
56
+ }
57
+ setOpen(false);
58
+ };
59
+ if (triggers.length === 0) {
60
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
61
+ "data-cy": "schema-form-item-edit",
62
+ onClick: onEnterEdit,
63
+ disabled: disabled,
64
+ size: "large",
65
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditIcon.default, {})
66
+ });
67
+ }
68
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
69
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ButtonGroup.default, {
70
+ variant: "outlined",
71
+ ref: anchorRef,
72
+ "aria-label": "split button",
73
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
74
+ "data-cy": "schema-form-item-edit",
75
+ onClick: onEnterEdit,
76
+ disabled: disabled,
77
+ size: "large",
78
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditIcon.default, {})
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
80
+ size: "small",
81
+ "aria-controls": open ? 'split-button-menu' : undefined,
82
+ "aria-expanded": open ? 'true' : undefined,
83
+ onClick: handleToggle,
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropDown.default, {})
85
+ })]
86
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popper.default, {
87
+ sx: {
88
+ zIndex: 9999
89
+ },
90
+ open: open,
91
+ anchorEl: anchorRef.current,
92
+ role: undefined,
93
+ placement: "bottom-end",
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Paper.default, {
95
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayListener.default, {
96
+ onClickAway: handleClose,
97
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
98
+ id: "split-button-menu",
99
+ autoFocusItem: true,
100
+ children: triggers.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.default, {
101
+ onClick: () => handleTriggerClick(x.handler),
102
+ children: x.title
103
+ }, x.key))
104
+ })
105
+ })
106
+ })
107
+ })]
108
+ });
109
+ }
110
+ InputTriggers.propTypes = {
111
+ triggers: _propTypes.default.arrayOf(_propTypes.default.shape({
112
+ key: _propTypes.default.string.isRequired,
113
+ title: _propTypes.default.string.isRequired,
114
+ handler: _propTypes.default.func.isRequired
115
+ })),
116
+ onEnterEdit: _propTypes.default.func.isRequired,
117
+ disabled: _propTypes.default.bool.isRequired
118
+ };
119
+ InputTriggers.defaultProps = {
120
+ triggers: []
121
+ };
122
+ function FormTextInput(_ref2) {
29
123
  let {
30
124
  label,
31
125
  disabled,
@@ -36,9 +130,10 @@ function FormTextInput(_ref) {
36
130
  style,
37
131
  onSubmit,
38
132
  secure,
133
+ triggers,
39
134
  formatterBeforeSubmit
40
- } = _ref,
41
- rest = _objectWithoutProperties(_ref, _excluded);
135
+ } = _ref2,
136
+ rest = _objectWithoutProperties(_ref2, _excluded);
42
137
  const [editing, setEditing] = (0, _react.useState)(false);
43
138
  const [loading, setLoading] = (0, _react.useState)(false);
44
139
  const [defaultValue, setDefaultValue] = (0, _react.useState)(secure && initialValue === '__encrypted__' ? '' : initialValue);
@@ -133,12 +228,10 @@ function FormTextInput(_ref) {
133
228
  size: "large",
134
229
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {})
135
230
  })]
136
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
137
- "data-cy": "schema-form-item-edit",
138
- onClick: () => setEditing(true),
139
- disabled: disabled,
140
- size: "large",
141
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditIcon.default, {})
231
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(InputTriggers, {
232
+ triggers: triggers,
233
+ onEnterEdit: () => setEditing(true),
234
+ disabled: disabled
142
235
  })
143
236
  })]
144
237
  })]
@@ -155,6 +248,7 @@ FormTextInput.propTypes = {
155
248
  required: _propTypes.default.bool,
156
249
  disabled: _propTypes.default.bool,
157
250
  secure: _propTypes.default.bool,
251
+ triggers: _propTypes.default.array,
158
252
  formatterBeforeSubmit: _propTypes.default.func
159
253
  };
160
254
  FormTextInput.defaultProps = {
@@ -167,5 +261,6 @@ FormTextInput.defaultProps = {
167
261
  required: false,
168
262
  disabled: false,
169
263
  secure: false,
264
+ triggers: [],
170
265
  formatterBeforeSubmit: null
171
266
  };
package/lib/locales/en.js CHANGED
@@ -297,6 +297,8 @@ module.exports = {
297
297
  upstreamPort: 'Upstream Port',
298
298
  noService: 'No Services',
299
299
  appId: 'App ID',
300
+ appPid: 'Permanent ID',
301
+ alsoKnownAs: 'Also Known As',
300
302
  reloadSuccess: 'Blocklet was reloaded successfully',
301
303
  statusTip: 'Blocklet is {status}',
302
304
  initialUptime: 'Less than 1m',
@@ -1188,12 +1190,14 @@ module.exports = {
1188
1190
  }
1189
1191
  },
1190
1192
  storage: {
1191
- didSpaces: {
1193
+ spaces: {
1192
1194
  tips: 'Tips',
1193
- label: 'Please enter DID Spaces service address',
1194
- getSpacesAuthorizeSuccessfully: 'You have successfully obtained a Spaces license',
1195
- goToAuthorization: 'Go to Authorization',
1196
- reAuthorization: 'Re-authorization',
1195
+ label: 'Enter DID Spaces Gateway',
1196
+ connected: 'You have successfully connect to did-space gateway',
1197
+ connect: 'Connect',
1198
+ reconnect: 'Reconnect',
1199
+ addressCannotEmpty: 'Address cannot be empty',
1200
+ addressNotValid: '{url} is not a valid address',
1197
1201
  authorize: {
1198
1202
  title: 'Authorize {appName}',
1199
1203
  scan: 'Use your DID Wallet to scan the QR code below to authorize the app {appName} to access the space in spaces',
package/lib/locales/zh.js CHANGED
@@ -303,6 +303,8 @@ module.exports = {
303
303
  upstreamPort: '上游端口',
304
304
  noService: '暂无服务',
305
305
  appId: '应用 ID',
306
+ appPid: '永久性 ID',
307
+ alsoKnownAs: '曾用 ID',
306
308
  reloadSuccess: 'Blocklet 重启成功',
307
309
  statusTip: 'Blocklet {status}',
308
310
  initialUptime: '少于1分钟',
@@ -1193,13 +1195,14 @@ module.exports = {
1193
1195
  }
1194
1196
  },
1195
1197
  storage: {
1196
- didSpaces: {
1198
+ spaces: {
1197
1199
  tips: '提示',
1198
1200
  label: '请输入 DID Spaces 服务地址',
1199
- getSpacesAuthorizeSuccessfully: '你已成功获得 Spaces 授权',
1200
- goToAuthorization: '前往授权',
1201
- reAuthorization: '重新授权',
1201
+ connected: '你已成功获得 Spaces 授权',
1202
+ connect: '前往授权',
1203
+ reconnect: '重新授权',
1202
1204
  addressCannotEmpty: '地址不能为空',
1205
+ addressNotValid: '{url} 不是一个合法的地址',
1203
1206
  authorize: {
1204
1207
  title: '授权 {appName}',
1205
1208
  scan: '使用你的 DID Wallet 扫描下面的二维码以授权应用 {appName} 访问 Spaces 中的空间',
package/lib/util/index.js CHANGED
@@ -26,7 +26,6 @@ exports.getBlockletServices = void 0;
26
26
  exports.getBlockletUrl = getBlockletUrl;
27
27
  exports.getBlockletUrlParams = void 0;
28
28
  exports.getBlockletUrls = getBlockletUrls;
29
- exports.getEndPoint = void 0;
30
29
  exports.getExplorerLink = getExplorerLink;
31
30
  exports.getPathPrefix = exports.getIssuePassportLink = exports.getInviteLink = void 0;
32
31
  exports.getRelativeTime = getRelativeTime;
@@ -377,30 +376,7 @@ const stringSortHandlerAsc = function stringSortHandlerAsc() {
377
376
  }
378
377
  return 0;
379
378
  };
380
-
381
- /**
382
- *
383
- * @param {ABTNode} nodeInfo
384
- * @returns {string} like http://localhost:3000, http://localhost:3000/admin
385
- */
386
379
  exports.stringSortHandlerAsc = stringSortHandlerAsc;
387
- const getEndPoint = nodeInfo => {
388
- const {
389
- routing
390
- } = nodeInfo;
391
- const {
392
- protocol,
393
- hostname,
394
- origin,
395
- port
396
- } = window.location;
397
- let endpoint = "".concat(origin).concat(routing.adminPath);
398
- if (process.env.NODE_ENV === 'development') {
399
- endpoint = "".concat(protocol, "//").concat(hostname, ":").concat(port);
400
- }
401
- return endpoint;
402
- };
403
- exports.getEndPoint = getEndPoint;
404
380
  const getInviteLink = _ref2 => {
405
381
  let {
406
382
  inviteId,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.67-beta-794a8082",
6
+ "version": "1.8.68-beta-500af7e5",
7
7
  "description": "UX components shared across abtnode packages",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -21,19 +21,19 @@
21
21
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@abtnode/auth": "1.8.67-beta-794a8082",
25
- "@abtnode/constant": "1.8.67-beta-794a8082",
26
- "@abtnode/util": "1.8.67-beta-794a8082",
27
- "@arcblock/did-connect": "^2.5.4",
24
+ "@abtnode/auth": "1.8.68-beta-500af7e5",
25
+ "@abtnode/constant": "1.8.68-beta-500af7e5",
26
+ "@abtnode/util": "1.8.68-beta-500af7e5",
27
+ "@arcblock/did-connect": "^2.5.5",
28
28
  "@arcblock/did-motif": "^1.1.10",
29
- "@arcblock/icons": "^2.5.4",
30
- "@arcblock/terminal": "^2.5.4",
31
- "@arcblock/ux": "^2.5.4",
32
- "@blocklet/constant": "1.8.67-beta-794a8082",
33
- "@blocklet/launcher-layout": "^1.9.60",
29
+ "@arcblock/icons": "^2.5.5",
30
+ "@arcblock/terminal": "^2.5.5",
31
+ "@arcblock/ux": "^2.5.5",
32
+ "@blocklet/constant": "1.8.68-beta-500af7e5",
33
+ "@blocklet/launcher-layout": "^1.9.61",
34
34
  "@blocklet/list": "^0.11.4",
35
- "@blocklet/meta": "1.8.67-beta-794a8082",
36
- "@blocklet/ui-react": "^2.5.4",
35
+ "@blocklet/meta": "1.8.68-beta-500af7e5",
36
+ "@blocklet/ui-react": "^2.5.5",
37
37
  "@emotion/react": "^11.10.4",
38
38
  "@emotion/styled": "^11.10.4",
39
39
  "@iconify/react": "^4.0.0",
@@ -86,5 +86,5 @@
86
86
  "@babel/preset-react": "^7.18.6",
87
87
  "babel-plugin-inline-react-svg": "^1.1.2"
88
88
  },
89
- "gitHead": "f4ad32bea4d80b12971fb6bef941bdbe2af6a834"
89
+ "gitHead": "9070621373f317a10ff0d289323bf725e30d3521"
90
90
  }