@abtnode/ux 1.16.19-beta-630ac853 → 1.16.19-beta-626e4d43

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.
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import { useRef } from 'react';
11
11
  import useAsyncRetry from 'react-use/lib/useAsyncRetry';
12
12
  import useSetState from 'react-use/lib/useSetState';
13
+ import useMediaQuery from '@mui/material/useMediaQuery';
13
14
  import { formatPrettyMsLocale, getAsset, getAssetExpiration, getSubscriptionURL } from './util';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -17,6 +18,21 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
17
18
  const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
18
19
  const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
19
20
 
21
+ // eslint-disable-next-line react/prop-types
22
+ function ChipLabel({
23
+ children
24
+ }) {
25
+ return /*#__PURE__*/_jsxs(Box, {
26
+ sx: {
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ gap: 1
30
+ },
31
+ children: [/*#__PURE__*/_jsx(AccessTimeIcon, {
32
+ fontSize: "small"
33
+ }), children]
34
+ });
35
+ }
20
36
  function Subscription({
21
37
  launcherUrl,
22
38
  chainHost,
@@ -33,10 +49,12 @@ function Subscription({
33
49
  popoverAnchorEl: null
34
50
  });
35
51
  const iframeRef = useRef(null);
52
+ const isMobile = useMediaQuery(x => x.breakpoints.down('md'));
36
53
  const {
37
54
  sx = {},
38
55
  ...rest
39
56
  } = props;
57
+ const typoKey = isMobile ? 'mobile' : 'desktop';
40
58
  const asyncState = useAsyncRetry(async () => {
41
59
  const [asset, subscriptionURL] = await Promise.all([getAsset(chainHost, nftId), getSubscriptionURL({
42
60
  launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
@@ -49,24 +67,26 @@ function Subscription({
49
67
  };
50
68
  }, [locale]);
51
69
  if (asyncState.loading) {
52
- return /*#__PURE__*/_jsxs(Box, {
70
+ return /*#__PURE__*/_jsx(Chip, {
71
+ label: /*#__PURE__*/_jsxs(ChipLabel, {
72
+ children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/_jsx(CircularProgress, {
73
+ size: 16
74
+ })]
75
+ }),
76
+ variant: "success",
53
77
  sx: {
54
- display: 'flex',
55
- alignItems: 'center',
56
- color: 'grey',
57
- gap: 1,
78
+ cursor: 'pointer',
58
79
  ...sx
59
80
  },
60
- ...rest,
61
- children: [/*#__PURE__*/_jsx(CircularProgress, {
62
- size: 16
63
- }), t('expiration.loading')]
81
+ ...rest
64
82
  });
65
83
  }
66
84
  if (asyncState.error) {
67
85
  console.error(asyncState.error);
68
86
  return /*#__PURE__*/_jsx(Chip, {
69
- label: t('expiration.loadFailed'),
87
+ label: /*#__PURE__*/_jsx(ChipLabel, {
88
+ children: t(`expiration.${typoKey}.loadFailed`)
89
+ }),
70
90
  color: "error",
71
91
  variant: "success",
72
92
  sx: {
@@ -99,23 +119,14 @@ function Subscription({
99
119
  };
100
120
  return /*#__PURE__*/_jsxs(_Fragment, {
101
121
  children: [/*#__PURE__*/_jsx(Chip, {
102
- label: /*#__PURE__*/_jsxs(Box, {
103
- sx: {
104
- display: 'flex',
105
- alignItems: 'center'
106
- },
107
- children: [/*#__PURE__*/_jsx(AccessTimeIcon, {
108
- sx: {
109
- mr: '4px'
110
- },
111
- fontSize: "small"
112
- }), t(`expiration.tips.${status}`, {
122
+ label: /*#__PURE__*/_jsx(ChipLabel, {
123
+ children: t(`expiration.${typoKey}.tips.${status}`, {
113
124
  validity: prettyMs(validityMs, {
114
125
  locale: formatPrettyMsLocale(locale),
115
126
  compact: true,
116
127
  verbose: true
117
128
  })
118
- })]
129
+ })
119
130
  }),
120
131
  color: status,
121
132
  variant: status !== 'success' ? 'contained' : 'outlined',
@@ -341,6 +341,7 @@ function AddComponentCore(_ref3) {
341
341
  component.current = {};
342
342
  onClose();
343
343
  };
344
+ const alreadyInstalled = did => ((blocklet === null || blocklet === void 0 ? void 0 : blocklet.children) || []).some(x => x.meta.did === did);
344
345
  const onInstall = async payload => {
345
346
  var _component$current2, _component$current3;
346
347
  const {
@@ -538,7 +539,7 @@ function AddComponentCore(_ref3) {
538
539
  } = meta;
539
540
 
540
541
  // deleted history list
541
- const list = (((_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.children) || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
542
+ const deletedList = (((_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.children) || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
542
543
  const componentDid = componentDidValue || '';
543
544
  const newConfigs = (_meta$environments = meta.environments) === null || _meta$environments === void 0 ? void 0 : _meta$environments.map(item => {
544
545
  const {
@@ -623,20 +624,27 @@ function AddComponentCore(_ref3) {
623
624
  const hasRootPath = blocklet.children.some(x => x.mountPoint === '/');
624
625
 
625
626
  // use deleted history
626
- const config = list.find(x => x.meta.bundleDid === bundleDid);
627
- if (config) {
627
+ const deletedConfig = deletedList.find(x => x.meta.bundleDid === bundleDid);
628
+ const installedConfig = blocklet.children.find(x => x.meta.bundleDid === bundleDid);
629
+ doc.title = title || '';
630
+ if (deletedConfig) {
628
631
  doc = _objectSpread(_objectSpread({}, doc), {}, {
629
- pathPrefix: config.mountPoint || '',
630
- title: title || '',
631
- componentName: config.meta.name,
632
+ pathPrefix: deletedConfig.mountPoint || '',
633
+ componentName: deletedConfig.meta.name,
632
634
  // use history's environments
633
635
  hasEnvironmentsStep: false
634
636
  });
637
+ } else if (installedConfig) {
638
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
639
+ pathPrefix: installedConfig.mountPoint || '',
640
+ componentName: installedConfig.meta.name,
641
+ // use current's environments
642
+ hasEnvironmentsStep: false
643
+ });
635
644
  } else {
636
645
  var _component$current$me, _component$current$me2;
637
646
  doc = _objectSpread(_objectSpread({}, doc), {}, {
638
647
  pathPrefix: hasRootPath ? "/".concat((0, _urlPathFriendly.default)(title) || (0, _urlPathFriendly.default)(name)) : '/',
639
- title: title || '',
640
648
  componentName: '',
641
649
  hasEnvironmentsStep: ((_component$current$me = component.current.meta) === null || _component$current$me === void 0 ? void 0 : (_component$current$me2 = _component$current$me.environments) === null || _component$current$me2 === void 0 ? void 0 : _component$current$me2.length) > 0
642
650
  });
@@ -861,7 +869,7 @@ function AddComponentCore(_ref3) {
861
869
  onCancel: () => {
862
870
  _onCancel();
863
871
  }
864
- }, (0, _util.hasStartEngine)(meta) && {
872
+ }, (0, _util.hasStartEngine)(meta) && !alreadyInstalled(meta.did) && {
865
873
  key: 'config',
866
874
  name: t('common.config'),
867
875
  error,
@@ -909,7 +917,7 @@ function AddComponentCore(_ref3) {
909
917
  onConfirm: () => {
910
918
  _onNext();
911
919
  }
912
- }, meta && (params === null || params === void 0 ? void 0 : params.hasEnvironmentsStep) && {
920
+ }, meta && !alreadyInstalled(meta.did) && (params === null || params === void 0 ? void 0 : params.hasEnvironmentsStep) && {
913
921
  key: 'environment',
914
922
  name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
915
923
  children: [t('common.environment'), " ", params.hasRequiredEnvironments && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
@@ -955,7 +963,7 @@ function AddComponentCore(_ref3) {
955
963
  confirm: t('common.next'),
956
964
  onCancel: _onCancel,
957
965
  onConfirm: _onNext
958
- }, meta && (params === null || params === void 0 ? void 0 : params.didSpaceCapability) && {
966
+ }, meta && !alreadyInstalled(meta.did) && (params === null || params === void 0 ? void 0 : params.didSpaceCapability) && {
959
967
  key: 'didSpace',
960
968
  name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
961
969
  children: [t('blocklet.component.didSpaceConfig'), " ", params.didSpaceCapability === 'required' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
@@ -995,7 +1003,7 @@ function AddComponentCore(_ref3) {
995
1003
  onConfirm: _onNext
996
1004
  }, {
997
1005
  key: 'install',
998
- name: t('common.install'),
1006
+ name: alreadyInstalled(meta === null || meta === void 0 ? void 0 : meta.did) ? t('common.upgrade') : t('common.install'),
999
1007
  disabled: false,
1000
1008
  loading: false,
1001
1009
  body: /*#__PURE__*/(0, _jsxRuntime.jsx)(TypographyWrapper, {
@@ -74,13 +74,20 @@ function DomainListWithPermission(props) {
74
74
  loadingRuntimeInfo: loadingRuntimeInfo
75
75
  }));
76
76
  }
77
+ DomainListWithPermission.propTypes = {
78
+ listOnly: _propTypes.default.bool
79
+ };
80
+ DomainListWithPermission.defaultProps = {
81
+ listOnly: false
82
+ };
77
83
  function DomainList(_ref) {
78
84
  var _blocklet$site2, _blocklet$environment, _blocklet$environment2, _blocklet$meta;
79
85
  let {
80
86
  hasPermission,
81
87
  blocklet,
82
88
  loadingRuntimeInfo,
83
- inService
89
+ inService,
90
+ listOnly
84
91
  } = _ref;
85
92
  const {
86
93
  t
@@ -115,49 +122,51 @@ function DomainList(_ref) {
115
122
  }
116
123
  });
117
124
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
118
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
119
- className: "title first",
120
- display: "flex",
121
- justifyContent: "space-between",
122
- alignItems: "center",
123
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
124
- children: t('common.domain')
125
- }), hasMutatePermission && /*#__PURE__*/(0, _jsxRuntime.jsx)(_addDomainAlias.default, {
126
- id: site.id,
127
- title: t('router.domain.add.title'),
128
- teamDid: (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did,
129
- appId: blocklet.appPid,
130
- appPk: appPk,
131
- systemDomains: systemDomains === null || systemDomains === void 0 ? void 0 : systemDomains.map(x => x.value),
132
- children: _ref2 => {
133
- let {
134
- open
135
- } = _ref2;
136
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
137
- style: {
138
- marginLeft: 16
139
- },
140
- variant: "contained",
141
- color: "primary",
142
- "data-cy": "add-domain-alias",
143
- onClick: open,
144
- disabled: (0, _util.isInProgress)(blocklet.status),
145
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
125
+ children: [!listOnly && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
126
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
127
+ className: "title first",
128
+ display: "flex",
129
+ justifyContent: "space-between",
130
+ alignItems: "center",
131
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
132
+ children: t('common.domain')
133
+ }), hasMutatePermission && /*#__PURE__*/(0, _jsxRuntime.jsx)(_addDomainAlias.default, {
134
+ id: site.id,
135
+ title: t('router.domain.add.title'),
136
+ teamDid: (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did,
137
+ appId: blocklet.appPid,
138
+ appPk: appPk,
139
+ systemDomains: systemDomains === null || systemDomains === void 0 ? void 0 : systemDomains.map(x => x.value),
140
+ children: _ref2 => {
141
+ let {
142
+ open
143
+ } = _ref2;
144
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
146
145
  style: {
147
- fontSize: '1.3em',
148
- marginRight: 4
149
- }
150
- }), t('common.add')]
151
- });
152
- }
146
+ marginLeft: 16
147
+ },
148
+ variant: "contained",
149
+ color: "primary",
150
+ "data-cy": "add-domain-alias",
151
+ onClick: open,
152
+ disabled: (0, _util.isInProgress)(blocklet.status),
153
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
154
+ style: {
155
+ fontSize: '1.3em',
156
+ marginRight: 4
157
+ }
158
+ }), t('common.add')]
159
+ });
160
+ }
161
+ })]
162
+ }), (0, _util.isAccessible)(blocklet.status) === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
163
+ mt: 1.5,
164
+ mb: 1.5,
165
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
166
+ severity: "warning",
167
+ children: t('blocklet.router.noRunning')
168
+ })
153
169
  })]
154
- }), (0, _util.isAccessible)(blocklet.status) === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
155
- mt: 1.5,
156
- mb: 1.5,
157
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
158
- severity: "warning",
159
- children: t('blocklet.router.noRunning')
160
- })
161
170
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
162
171
  sx: {
163
172
  display: 'flex',
@@ -272,11 +281,13 @@ DomainList.propTypes = {
272
281
  hasPermission: _propTypes.default.bool,
273
282
  blocklet: _propTypes.default.object.isRequired,
274
283
  loadingRuntimeInfo: _propTypes.default.bool,
275
- inService: _propTypes.default.bool.isRequired
284
+ inService: _propTypes.default.bool.isRequired,
285
+ listOnly: _propTypes.default.bool
276
286
  };
277
287
  DomainList.defaultProps = {
278
288
  hasPermission: false,
279
- loadingRuntimeInfo: false
289
+ loadingRuntimeInfo: false,
290
+ listOnly: false
280
291
  };
281
292
  function DomainLink(_ref3) {
282
293
  let {
@@ -93,14 +93,16 @@ function ComponentEnvironment(_ref) {
93
93
  return;
94
94
  }
95
95
  data.custom = true;
96
- const result = await node.api.configBlocklet({
97
- input: {
98
- did: dids,
99
- configs: [data]
100
- }
101
- });
102
- if (result.code === 'ok') {
96
+ try {
97
+ const result = await node.api.configBlocklet({
98
+ input: {
99
+ did: dids,
100
+ configs: [data]
101
+ }
102
+ });
103
103
  onConfigChanged(result.blocklet);
104
+ } catch (err) {
105
+ _Toast.default.error((0, _util2.formatError)(err));
104
106
  }
105
107
  };
106
108
  const onEditConfig = async (newData, oldData) => {
@@ -138,9 +140,7 @@ function ComponentEnvironment(_ref) {
138
140
  configs
139
141
  }
140
142
  });
141
- if (result.code === 'ok') {
142
- onConfigChanged(result.blocklet);
143
- }
143
+ onConfigChanged(result.blocklet);
144
144
  } catch (err) {
145
145
  _Toast.default.error((0, _util2.formatError)(err));
146
146
  }
@@ -154,17 +154,19 @@ function ComponentEnvironment(_ref) {
154
154
  _Toast.default.error('Only key of custom env can be changed');
155
155
  return;
156
156
  }
157
- const result = await node.api.configBlocklet({
158
- input: {
159
- did: dids,
160
- configs: [{
161
- key: data.key,
162
- custom: true
163
- }]
164
- }
165
- });
166
- if (result.code === 'ok') {
157
+ try {
158
+ const result = await node.api.configBlocklet({
159
+ input: {
160
+ did: dids,
161
+ configs: [{
162
+ key: data.key,
163
+ custom: true
164
+ }]
165
+ }
166
+ });
167
167
  onConfigChanged(result.blocklet);
168
+ } catch (err) {
169
+ _Toast.default.error((0, _util2.formatError)(err));
168
170
  }
169
171
  };
170
172
 
@@ -139,7 +139,7 @@ const getComponentName = (componentId, app) => {
139
139
  return names.join(' / ');
140
140
  };
141
141
  function ComponentItem(_ref) {
142
- var _blocklet$dependents, _blocklet$meta$resour, _blocklet$dependents2, _blocklet$dependents3;
142
+ var _blocklet$dependents, _blocklet$meta$resour, _blocklet$dependents2, _blocklet$meta, _blocklet$dependents3;
143
143
  let {
144
144
  blocklet,
145
145
  ancestors,
@@ -299,26 +299,39 @@ function ComponentItem(_ref) {
299
299
  ancestors: ancestors
300
300
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
301
301
  ml: "16px",
302
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
303
- className: "component-name",
302
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
303
+ className: "component-header",
304
304
  onClick: () => setComponentInfo(blocklet),
305
- children: (0, _util.getDisplayName)(blocklet, true)
305
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
306
+ className: "component-name",
307
+ children: (0, _util.getDisplayName)(blocklet, true)
308
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
309
+ className: "component-version",
310
+ children: blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.version
311
+ })]
306
312
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
307
313
  display: "flex",
308
314
  alignItems: "center",
309
- children: [!(0, _util.hasStartEngine)(blocklet.meta) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_resourceType.default, {
310
- blocklet: blocklet
311
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_mode.default, {
315
+ sx: {
316
+ mt: '2px',
317
+ ml: -0.5
318
+ },
319
+ children: [status !== 'unknown' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
312
320
  style: {
313
321
  marginLeft: 4
314
322
  },
315
- mode: blocklet.mode || ''
316
- }), status !== 'unknown' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
323
+ status: status,
324
+ source: blocklet.source
325
+ }), !(0, _util.hasStartEngine)(blocklet.meta) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_resourceType.default, {
317
326
  style: {
318
327
  marginLeft: 4
319
328
  },
320
- status: status,
321
- source: blocklet.source
329
+ blocklet: blocklet
330
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_mode.default, {
331
+ style: {
332
+ marginLeft: 4
333
+ },
334
+ mode: blocklet.mode || ''
322
335
  }), !!((_blocklet$dependents3 = blocklet.dependents) !== null && _blocklet$dependents3 !== void 0 && _blocklet$dependents3.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
323
336
  title: ["".concat(t('common.dependents'), ": "), blocklet.dependents.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
324
337
  pl: 1,
@@ -517,7 +530,7 @@ ComponentItem.defaultProps = {
517
530
  app: null
518
531
  };
519
532
  const StyledBadge = (0, _styled.default)(_Badge.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .BaseBadge-badge {\n top: ", "px;\n right: ", "px;\n }\n"])), props => props.top * 8 || 6, props => props.right * 8 || 6);
520
- const StyledComponentRow = (0, _styled.default)(_Box.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .component-name {\n color: #222;\n font-size: 16px;\n cursor: pointer;\n }\n"])));
533
+ const StyledComponentRow = (0, _styled.default)(_Box.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .component-header {\n display: flex;\n align-items: center;\n align-items: flex-end;\n cursor: pointer;\n }\n .component-name {\n color: #222;\n font-size: 16px;\n }\n .component-version {\n color: #999;\n font-size: 12px;\n margin-left: 4px;\n transform: translateY(-1px);\n }\n"])));
521
534
  function BlockletComponent(_ref4) {
522
535
  let {
523
536
  blocklet,
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = AddDomain;
7
7
  var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
8
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
8
9
  var _context = require("@arcblock/ux/lib/Locale/context");
9
- var _Diamond = _interopRequireDefault(require("@mui/icons-material/Diamond"));
10
- var _Edit = _interopRequireDefault(require("@mui/icons-material/Edit"));
11
10
  var _OpenInNew = _interopRequireDefault(require("@mui/icons-material/OpenInNew"));
12
11
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
13
- var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
14
12
  var _Link = _interopRequireDefault(require("@mui/material/Link"));
15
13
  var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
16
- var _useTheme = _interopRequireDefault(require("@mui/material/styles/useTheme"));
17
14
  var _noop = _interopRequireDefault(require("lodash/noop"));
15
+ var _trim = _interopRequireDefault(require("lodash/trim"));
18
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
17
  var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
20
18
  var _urlJoin = _interopRequireDefault(require("url-join"));
@@ -25,7 +23,7 @@ var _api = require("../../util/api");
25
23
  var _dnsTip = _interopRequireDefault(require("./dns-tip"));
26
24
  var _util3 = require("./util");
27
25
  var _jsxRuntime = require("react/jsx-runtime");
28
- const _excluded = ["siteId", "teamDid", "cnameDomain", "defaultCustomDomain", "onInputDomain", "appId", "appPk", "onSuccess"];
26
+ const _excluded = ["siteId", "teamDid", "cnameDomain", "defaultCustomDomain", "onInputDomain", "appId", "appPk", "onSuccess", "disabled", "autoFocus"];
29
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
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; }
31
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; }
@@ -35,7 +33,6 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
35
33
  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; }
36
34
  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; }
37
35
  function AddDomain(_ref) {
38
- var _domainTypes$state$ty;
39
36
  let {
40
37
  siteId,
41
38
  teamDid,
@@ -44,10 +41,11 @@ function AddDomain(_ref) {
44
41
  onInputDomain,
45
42
  appId,
46
43
  appPk,
47
- onSuccess
44
+ onSuccess,
45
+ disabled,
46
+ autoFocus
48
47
  } = _ref,
49
48
  props = _objectWithoutProperties(_ref, _excluded);
50
- const theme = (0, _useTheme.default)();
51
49
  const {
52
50
  t,
53
51
  locale
@@ -101,23 +99,19 @@ function AddDomain(_ref) {
101
99
  const domainTypes = {
102
100
  inputDomain: {
103
101
  name: t('router.domainAlias.inputDomain'),
104
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Edit.default, {}),
105
- component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
102
+ component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
106
103
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
107
- style: {
108
- marginTop: '8px'
109
- },
110
104
  label: t('router.domainAlias.add.domainDescription'),
111
105
  helperText: state.error || t('router.domainAlias.add.helperText'),
112
106
  inputProps: {
113
107
  'data-cy': 'domain-name-input'
114
108
  },
115
109
  fullWidth: true,
110
+ disabled: disabled,
116
111
  value: state.domain,
117
112
  onChange: e => {
118
- const {
119
- value
120
- } = e.target;
113
+ var _e$target;
114
+ const value = (0, _trim.default)((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
121
115
  setState({
122
116
  domain: value
123
117
  });
@@ -131,7 +125,14 @@ function AddDomain(_ref) {
131
125
  error: errMessage
132
126
  });
133
127
  },
134
- autoFocus: true,
128
+ autoFocus: autoFocus,
129
+ onBlur: () => {
130
+ if (!state.domain) {
131
+ setState({
132
+ error: null
133
+ });
134
+ }
135
+ },
135
136
  size: "small",
136
137
  variant: "outlined",
137
138
  error: !!state.error
@@ -148,11 +149,7 @@ function AddDomain(_ref) {
148
149
  if (info !== null && info !== void 0 && info.nftDomainUrl) {
149
150
  domainTypes.nftDomain = {
150
151
  name: t('router.domainAlias.nftDomain'),
151
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Diamond.default, {}),
152
- component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
153
- sx: {
154
- marginTop: '12px'
155
- },
152
+ component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
156
153
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
157
154
  sx: {
158
155
  maxWidth: '640px',
@@ -181,6 +178,7 @@ function AddDomain(_ref) {
181
178
  sx: {
182
179
  marginTop: '8px'
183
180
  },
181
+ disabled: disabled,
184
182
  onClick: () => setState({
185
183
  showNFTDomainAuth: true
186
184
  }),
@@ -223,36 +221,28 @@ function AddDomain(_ref) {
223
221
  }
224
222
  return -1;
225
223
  });
226
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, _objectSpread(_objectSpread({}, props), {}, {
227
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
224
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({}, props), {}, {
225
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
228
226
  sx: {
229
227
  display: 'flex',
228
+ flexDirection: 'column',
230
229
  justifyContent: 'flex-start',
231
- gap: '16px'
230
+ gap: '1em'
232
231
  },
233
- children: inputDomainTypes.map(type => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
234
- sx: {
235
- width: '128px',
236
- height: '64px',
237
- padding: '8px',
238
- cursor: 'pointer',
239
- borderRadius: '8px',
240
- display: 'flex',
241
- flexDirection: 'column',
242
- justifyContent: 'center',
243
- alignItems: 'flex-start',
244
- color: type === state.type ? theme.palette.primary.main : theme.palette.common.main,
245
- border: "1px solid ".concat(type === state.type ? theme.palette.primary.main : '#E0E0E0')
246
- },
247
- onClick: () => setState({
248
- type
249
- }),
250
- children: [domainTypes[type].icon, domainTypes[type].name]
251
- }, type))
252
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
253
- marginTop: "12px",
254
- children: (_domainTypes$state$ty = domainTypes[state.type]) === null || _domainTypes$state$ty === void 0 ? void 0 : _domainTypes$state$ty.component
255
- })]
232
+ children: inputDomainTypes.map((type, index) => {
233
+ var _domainTypes$type, _domainTypes$type2;
234
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
235
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
236
+ children: "".concat(t("optionsOrder.".concat(index + 1)), ": ").concat((_domainTypes$type = domainTypes[type]) === null || _domainTypes$type === void 0 ? void 0 : _domainTypes$type.name)
237
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
238
+ sx: {
239
+ marginTop: '8px'
240
+ },
241
+ children: (_domainTypes$type2 = domainTypes[type]) === null || _domainTypes$type2 === void 0 ? void 0 : _domainTypes$type2.component
242
+ })]
243
+ }, type);
244
+ })
245
+ })
256
246
  }));
257
247
  }
258
248
  AddDomain.propTypes = {
@@ -263,12 +253,16 @@ AddDomain.propTypes = {
263
253
  onInputDomain: _propTypes.default.func,
264
254
  onSuccess: _propTypes.default.func,
265
255
  appId: _propTypes.default.string,
266
- appPk: _propTypes.default.string
256
+ appPk: _propTypes.default.string,
257
+ disabled: _propTypes.default.bool,
258
+ autoFocus: _propTypes.default.bool
267
259
  };
268
260
  AddDomain.defaultProps = {
269
261
  defaultCustomDomain: '',
270
262
  onInputDomain: _noop.default,
271
263
  onSuccess: _noop.default,
272
264
  appId: '',
273
- appPk: ''
265
+ appPk: '',
266
+ disabled: false,
267
+ autoFocus: true
274
268
  };