@abtnode/ux 1.8.39 → 1.8.41

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.
@@ -41,7 +41,7 @@ const Configs = [..._config.default, {
41
41
  icon: _Group.default,
42
42
  title: {
43
43
  zh: '指定通行证可访问',
44
- en: 'Accessible to passports'
44
+ en: 'Accessible to selected passports'
45
45
  },
46
46
  description: {
47
47
  zh: '只有指定的通行证可以访问',
@@ -189,6 +189,7 @@ function ConfigAccess(_ref) {
189
189
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
190
190
  onClick: onClose,
191
191
  color: "inherit",
192
+ "data-cy": "config-access-cancel",
192
193
  children: t('common.cancel')
193
194
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
194
195
  onClick: onConfirm,
@@ -196,6 +197,7 @@ function ConfigAccess(_ref) {
196
197
  disabled: disabled,
197
198
  variant: "contained",
198
199
  autoFocus: true,
200
+ "data-cy": "config-access-confirm",
199
201
  children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
200
202
  size: [16, 10]
201
203
  }), t('common.confirm')]
@@ -210,6 +212,7 @@ function ConfigAccess(_ref) {
210
212
  fullWidth: true,
211
213
  value: whoCanAccess,
212
214
  onChange: onWhoCanAccessChange,
215
+ "data-cy": "config-access-select",
213
216
  SelectProps: {
214
217
  renderValue: selected => {
215
218
  const d = Configs.find(x => x.value === selected);
@@ -226,6 +229,7 @@ function ConfigAccess(_ref) {
226
229
  sx: {
227
230
  display: 'block'
228
231
  },
232
+ "data-cy": "config-access-opt-".concat(d.value),
229
233
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
230
234
  display: "flex",
231
235
  alignItems: "center",
@@ -154,6 +154,7 @@ function ComponentItem(_ref) {
154
154
  title: t('common.edit'),
155
155
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
156
156
  onClick: open,
157
+ "data-cy": "btn-edit-".concat(blocklet.meta.did),
157
158
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditIcon.default, {
158
159
  style: iconStyle
159
160
  })
@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = BlockletAvatar;
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _urlJoin = _interopRequireDefault(require("url-join"));
9
8
  var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
10
9
  var _Avatar2 = _interopRequireDefault(require("@arcblock/did-connect/lib/Avatar"));
11
- var _constant = require("@abtnode/constant");
10
+ var _useAvatar = _interopRequireDefault(require("../hooks/use-avatar"));
12
11
  var _node = require("../contexts/node");
13
- var _util = require("../util");
14
12
  var _jsxRuntime = require("react/jsx-runtime");
15
13
  const _excluded = ["blocklet", "style", "size", "ancestors"];
16
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -20,7 +18,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
20
18
  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; }
21
19
  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; }
22
20
  function BlockletAvatar(_ref) {
23
- var _blocklet$meta;
24
21
  let {
25
22
  blocklet,
26
23
  style,
@@ -30,21 +27,15 @@ function BlockletAvatar(_ref) {
30
27
  rest = _objectWithoutProperties(_ref, _excluded);
31
28
  const node = (0, _node.useNodeContext)();
32
29
  const {
30
+ logoUrl,
33
31
  inService
34
- } = node;
35
- const search = "?version=".concat(blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.version);
36
- let logoUrl = inService ? (0, _urlJoin.default)(_util.APP_PREFIX, _constant.WELLKNOWN_SERVICE_PATH_PREFIX, '/blocklet/logo', search) : (0, _urlJoin.default)(node.prefix, 'blocklet.png');
32
+ } = (0, _useAvatar.default)({
33
+ blocklet,
34
+ ancestors
35
+ });
37
36
  const {
38
37
  variant
39
38
  } = rest;
40
- if (blocklet.source === 'registry' && blocklet.deployedFrom && blocklet.meta.logo) {
41
- logoUrl = (0, _urlJoin.default)(blocklet.deployedFrom, (0, _util.formatRegistryLogoPath)(blocklet.meta.bundleDid, blocklet.meta.logo), search);
42
- } else {
43
- const prefix = window.env.apiPrefix || '/';
44
- const components = ancestors.concat(blocklet);
45
- const list = inService ? components.slice(1) : components;
46
- logoUrl = (0, _urlJoin.default)(prefix, "/blocklet/logo".concat(list.map(x => "/".concat(x.meta.did)).join('')), search);
47
- }
48
39
  const setFallBackUrl = inService ? () => {} : ev => {
49
40
  ev.target.src = "".concat(node.prefix, "/blocklet.png");
50
41
  };
@@ -456,8 +456,7 @@ function AddComponent(_ref2) {
456
456
  rest = _objectWithoutProperties(item, _excluded);
457
457
  const formatItem = {
458
458
  // if the blocklet has validation, provide the validation (fix not inStore)
459
- validation: (0, _isNil.default)(validation) ? '' : validation,
460
- custom: false
459
+ validation: (0, _isNil.default)(validation) ? '' : validation
461
460
  };
462
461
  return _objectSpread(_objectSpread({}, rest), {}, {
463
462
  key
@@ -0,0 +1,218 @@
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
+ var _ahooks = require("ahooks");
9
+ var _lodash = require("lodash");
10
+ var _react = require("react");
11
+ var _react2 = require("@iconify/react");
12
+ var _material = require("@mui/material");
13
+ var _context = require("@arcblock/ux/lib/Locale/context");
14
+ var _simpleSelect = _interopRequireDefault(require("./simple-select"));
15
+ var _locales = _interopRequireDefault(require("../../../util/locales"));
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ /* eslint-disable react/jsx-no-bind */
19
+
20
+ const defaultLocale = 'en';
21
+ function LocaleTabs(_ref) {
22
+ let {
23
+ sx,
24
+ onChange,
25
+ locales,
26
+ onRemoveLocale
27
+ } = _ref;
28
+ const {
29
+ t
30
+ } = (0, _context.useLocaleContext)();
31
+ const inputRef = (0, _react.useRef)();
32
+ const [addLocaleButtonEl, setAddLocaleButtonEl] = (0, _react.useState)(null);
33
+ const state = (0, _ahooks.useReactive)({
34
+ currentLocale: defaultLocale,
35
+ localeList: [],
36
+ inputLocale: '',
37
+ localeError: ''
38
+ });
39
+ const openChooseLocale = (0, _react.useMemo)(() => {
40
+ return !!addLocaleButtonEl;
41
+ }, [addLocaleButtonEl]);
42
+ const localeOptions = (0, _react.useMemo)(() => {
43
+ return Object.keys((0, _lodash.omit)(_locales.default, [...state.localeList, defaultLocale])).map(locale => ({
44
+ title: _locales.default[locale],
45
+ value: locale
46
+ }));
47
+ }, [state.localeList]);
48
+ (0, _react.useEffect)(() => {
49
+ onChange(state.currentLocale);
50
+ }, [onChange, state.currentLocale]);
51
+ (0, _react.useEffect)(() => {
52
+ state.localeList = [...locales];
53
+ }, [locales, state]);
54
+ (0, _ahooks.useKeyPress)('enter', () => {
55
+ // HACK: 必须加一个延时,否则无法正确关闭 chooseLocale 弹窗
56
+ setTimeout(() => {
57
+ handleAddLocale();
58
+ });
59
+ }, {
60
+ target: inputRef
61
+ });
62
+ function checkLocale(locale) {
63
+ if (!locale) {
64
+ return t('common.requiredErrorText', {
65
+ name: 'Locale'
66
+ });
67
+ }
68
+ if (locale === 'en' || state.localeList.includes(locale)) {
69
+ return t('navigation.form.localeExists', {
70
+ value: locale
71
+ });
72
+ }
73
+ return true;
74
+ }
75
+ function checkValidLocale() {
76
+ let locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
77
+ const value = locale === null || locale === void 0 ? void 0 : locale.trim();
78
+ const checkResult = checkLocale(value);
79
+ if (checkResult !== true) {
80
+ state.localeError = checkResult;
81
+ } else {
82
+ state.localeError = '';
83
+ }
84
+ return checkResult;
85
+ }
86
+ function handleAddLocale() {
87
+ var _state$inputLocale;
88
+ const value = (_state$inputLocale = state.inputLocale) === null || _state$inputLocale === void 0 ? void 0 : _state$inputLocale.trim();
89
+ const checkResult = checkValidLocale(value);
90
+ if (checkResult === true) {
91
+ close();
92
+ state.localeList.push(value);
93
+ state.currentLocale = value;
94
+ }
95
+ }
96
+ function close() {
97
+ setAddLocaleButtonEl(null);
98
+ state.inputLocale = '';
99
+ state.localeError = '';
100
+ }
101
+ function handleRemoveLocale(e, locale) {
102
+ e.preventDefault();
103
+ e.stopPropagation();
104
+ state.localeList = (0, _lodash.without)(state.localeList, locale);
105
+ onRemoveLocale(locale);
106
+ if (locale === state.currentLocale) {
107
+ state.currentLocale = defaultLocale;
108
+ }
109
+ }
110
+ function handleChangeLocale(e) {
111
+ const {
112
+ value
113
+ } = e.target;
114
+ checkValidLocale(value);
115
+ state.inputLocale = value;
116
+ }
117
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
118
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Tabs, {
119
+ sx: sx,
120
+ value: state.currentLocale,
121
+ onChange: (e, value) => {
122
+ state.currentLocale = value;
123
+ },
124
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tab, {
125
+ label: "Default (".concat(_locales.default[defaultLocale], ")"),
126
+ value: "en"
127
+ }), state.localeList.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tab, {
128
+ sx: {
129
+ position: 'relative'
130
+ },
131
+ label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
132
+ children: [_locales.default[item], /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
133
+ size: "small",
134
+ color: "inherit",
135
+ sx: {
136
+ position: 'absolute',
137
+ top: 0,
138
+ right: 0
139
+ },
140
+ onClick: e => {
141
+ handleRemoveLocale(e, item);
142
+ },
143
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
144
+ icon: "mdi:close",
145
+ height: 14
146
+ })
147
+ })]
148
+ }),
149
+ value: item
150
+ }, item)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
151
+ color: "primary",
152
+ disableFocusRipple: true,
153
+ sx: {
154
+ width: '48px'
155
+ },
156
+ onClick: e => {
157
+ setAddLocaleButtonEl(e.currentTarget);
158
+ },
159
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
160
+ icon: "mdi:plus"
161
+ })
162
+ })]
163
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popover, {
164
+ open: openChooseLocale,
165
+ anchorEl: addLocaleButtonEl,
166
+ onClose: close,
167
+ anchorOrigin: {
168
+ vertical: 'bottom',
169
+ horizontal: 'left'
170
+ },
171
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
172
+ sx: {
173
+ p: 2,
174
+ width: '270px'
175
+ },
176
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
177
+ variant: "subtitle2",
178
+ children: t('navigation.form.localePlaceholder')
179
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
180
+ mt: 1,
181
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_simpleSelect.default, {
182
+ required: true,
183
+ fullWidth: true,
184
+ label: "Locale",
185
+ value: state.inputLocale,
186
+ options: localeOptions,
187
+ onChange: handleChangeLocale,
188
+ error: !!state.localeError,
189
+ helperText: state.localeError || ' '
190
+ })
191
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
192
+ display: "flex",
193
+ justifyContent: "flex-end",
194
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
195
+ size: "small",
196
+ variant: "contained",
197
+ onClick: handleAddLocale,
198
+ children: t('common.confirm')
199
+ })
200
+ })]
201
+ })
202
+ })]
203
+ });
204
+ }
205
+ LocaleTabs.propTypes = {
206
+ sx: _propTypes.default.any,
207
+ onChange: _propTypes.default.func,
208
+ onRemoveLocale: _propTypes.default.func,
209
+ locales: _propTypes.default.array
210
+ };
211
+ LocaleTabs.defaultProps = {
212
+ sx: null,
213
+ onChange: () => {},
214
+ onRemoveLocale: () => {},
215
+ locales: []
216
+ };
217
+ var _default = LocaleTabs;
218
+ exports.default = _default;
@@ -0,0 +1,103 @@
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
+ var _react = require("@iconify/react");
9
+ var _material = require("@mui/material");
10
+ var _react2 = require("react");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function NavigationActions(_ref) {
14
+ let {
15
+ className,
16
+ add,
17
+ edit,
18
+ toggle,
19
+ del,
20
+ data,
21
+ section
22
+ } = _ref;
23
+ const isDisabled = ['yaml', 'tmpl'].includes(data.from);
24
+ const isUninstalled = /*#__PURE__*/(0, _react2.isValidElement)(data.subtitle);
25
+ function handleClick(e) {
26
+ e.preventDefault();
27
+ e.stopPropagation();
28
+ }
29
+ const handleClickAdd = (0, _react2.useCallback)(e => {
30
+ handleClick(e);
31
+ add(data);
32
+ }, [add, data]);
33
+ const handleClickEdit = (0, _react2.useCallback)(e => {
34
+ handleClick(e);
35
+ edit(data);
36
+ }, [edit, data]);
37
+ const handleClickToggle = (0, _react2.useCallback)(e => {
38
+ handleClick(e);
39
+ toggle(data);
40
+ }, [toggle, data]);
41
+ const handleClickDelete = (0, _react2.useCallback)(e => {
42
+ handleClick(e);
43
+ del(data);
44
+ }, [del, data]);
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
46
+ className: className,
47
+ children: [!data.parent && ['header', 'footer', 'dashboard'].includes(section) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
48
+ size: "small",
49
+ color: "success",
50
+ onClick: handleClickAdd,
51
+ disabled: isUninstalled,
52
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
53
+ icon: "mdi:plus-box-outline"
54
+ })
55
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
56
+ size: "small",
57
+ color: "primary",
58
+ onClick: handleClickEdit,
59
+ disabled: isUninstalled,
60
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
61
+ icon: "mdi:pencil"
62
+ })
63
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
64
+ size: "small",
65
+ color: "warning",
66
+ onClick: handleClickToggle,
67
+ disabled: isUninstalled,
68
+ children: data.visible === false ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
69
+ icon: "mdi:eye-off-outline"
70
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
71
+ icon: "mdi:eye-outline"
72
+ })
73
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
74
+ disabled: isDisabled,
75
+ size: "small",
76
+ color: "error",
77
+ onClick: handleClickDelete,
78
+ title: isDisabled ? 'Not allowed delete built-in navigation' : 'Delete navigation',
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
80
+ icon: "mdi:delete"
81
+ })
82
+ })]
83
+ });
84
+ }
85
+ NavigationActions.propTypes = {
86
+ data: _propTypes.default.object.isRequired,
87
+ className: _propTypes.default.string,
88
+ add: _propTypes.default.func,
89
+ edit: _propTypes.default.func,
90
+ toggle: _propTypes.default.func,
91
+ del: _propTypes.default.func,
92
+ section: _propTypes.default.string
93
+ };
94
+ NavigationActions.defaultProps = {
95
+ className: '',
96
+ add: () => {},
97
+ edit: () => {},
98
+ toggle: () => {},
99
+ del: () => {},
100
+ section: ''
101
+ };
102
+ var _default = NavigationActions;
103
+ exports.default = _default;