@abtnode/ux 1.16.0-beta-1f8bf936 → 1.16.0-beta-ad6df3ae
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.
|
@@ -27,7 +27,8 @@ const defaultLocale = 'en';
|
|
|
27
27
|
function LocaleTabs(_ref) {
|
|
28
28
|
let {
|
|
29
29
|
sx,
|
|
30
|
-
|
|
30
|
+
onAdd,
|
|
31
|
+
onChange: _onChange,
|
|
31
32
|
locales,
|
|
32
33
|
onRemoveLocale
|
|
33
34
|
} = _ref;
|
|
@@ -45,15 +46,18 @@ function LocaleTabs(_ref) {
|
|
|
45
46
|
const openChooseLocale = (0, _react.useMemo)(() => {
|
|
46
47
|
return !!addLocaleButtonEl;
|
|
47
48
|
}, [addLocaleButtonEl]);
|
|
49
|
+
const showLocale = (0, _react.useMemo)(() => {
|
|
50
|
+
if (locales.includes(state.currentLocale)) {
|
|
51
|
+
return state.currentLocale;
|
|
52
|
+
}
|
|
53
|
+
return defaultLocale;
|
|
54
|
+
}, [locales, state.currentLocale]);
|
|
48
55
|
const localeOptions = (0, _react.useMemo)(() => {
|
|
49
56
|
return Object.keys((0, _lodash.omit)(_locales.default, [...state.localeList, defaultLocale])).map(locale => ({
|
|
50
57
|
title: _locales.default[locale],
|
|
51
58
|
value: locale
|
|
52
59
|
}));
|
|
53
60
|
}, [state.localeList]);
|
|
54
|
-
(0, _react.useEffect)(() => {
|
|
55
|
-
onChange(state.currentLocale);
|
|
56
|
-
}, [onChange, state.currentLocale]);
|
|
57
61
|
(0, _react.useEffect)(() => {
|
|
58
62
|
state.localeList = [...locales];
|
|
59
63
|
}, [locales, state]);
|
|
@@ -97,6 +101,7 @@ function LocaleTabs(_ref) {
|
|
|
97
101
|
close();
|
|
98
102
|
state.localeList.push(value);
|
|
99
103
|
state.currentLocale = value;
|
|
104
|
+
onAdd(value);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
function close() {
|
|
@@ -123,9 +128,10 @@ function LocaleTabs(_ref) {
|
|
|
123
128
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
124
129
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Tabs.default, {
|
|
125
130
|
sx: sx,
|
|
126
|
-
value:
|
|
131
|
+
value: showLocale,
|
|
127
132
|
onChange: (e, value) => {
|
|
128
133
|
state.currentLocale = value;
|
|
134
|
+
_onChange(value);
|
|
129
135
|
},
|
|
130
136
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tab.default, {
|
|
131
137
|
label: "Default (".concat(_locales.default[defaultLocale], ")"),
|
|
@@ -210,12 +216,14 @@ function LocaleTabs(_ref) {
|
|
|
210
216
|
}
|
|
211
217
|
LocaleTabs.propTypes = {
|
|
212
218
|
sx: _propTypes.default.any,
|
|
219
|
+
onAdd: _propTypes.default.func,
|
|
213
220
|
onChange: _propTypes.default.func,
|
|
214
221
|
onRemoveLocale: _propTypes.default.func,
|
|
215
222
|
locales: _propTypes.default.array
|
|
216
223
|
};
|
|
217
224
|
LocaleTabs.defaultProps = {
|
|
218
225
|
sx: null,
|
|
226
|
+
onAdd: () => {},
|
|
219
227
|
onChange: () => {},
|
|
220
228
|
onRemoveLocale: () => {},
|
|
221
229
|
locales: []
|
|
@@ -214,6 +214,8 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
214
214
|
return '--';
|
|
215
215
|
}, [state.type, t]);
|
|
216
216
|
const reset = (0, _react.useCallback)(() => {
|
|
217
|
+
state.isRoot = true;
|
|
218
|
+
state.locale = defaultLocale;
|
|
217
219
|
state.type = defaultType;
|
|
218
220
|
state.linkDisabled = false;
|
|
219
221
|
saveFn.current = () => {};
|
|
@@ -402,6 +404,15 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
402
404
|
state.formState.title = (0, _omit.default)(state.formState.title, currentLocale);
|
|
403
405
|
state.formState.link = (0, _omit.default)(state.formState.link, currentLocale);
|
|
404
406
|
}, [state.formState]);
|
|
407
|
+
const handleAddLocale = (0, _react.useCallback)(newLocale => {
|
|
408
|
+
var _state$formState$titl, _state$formState$link;
|
|
409
|
+
state.locale = newLocale;
|
|
410
|
+
state.formState.title[newLocale] = (_state$formState$titl = state.formState.title) === null || _state$formState$titl === void 0 ? void 0 : _state$formState$titl[defaultLocale];
|
|
411
|
+
state.formState.link[newLocale] = (_state$formState$link = state.formState.link) === null || _state$formState$link === void 0 ? void 0 : _state$formState$link[defaultLocale];
|
|
412
|
+
setTimeout(() => {
|
|
413
|
+
clearErrors();
|
|
414
|
+
});
|
|
415
|
+
}, [clearErrors, state]);
|
|
405
416
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
406
417
|
open: show,
|
|
407
418
|
title: name,
|
|
@@ -417,6 +428,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
417
428
|
sx: {
|
|
418
429
|
mb: 1
|
|
419
430
|
},
|
|
431
|
+
onAdd: handleAddLocale,
|
|
420
432
|
onChange: handleChangeLocale,
|
|
421
433
|
onRemoveLocale: handleRemoveLocale,
|
|
422
434
|
locales: state.localeList
|
|
@@ -464,6 +476,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
464
476
|
placeholder: t('navigation.form.iconPlaceholder'),
|
|
465
477
|
label: t('navigation.form.icon'),
|
|
466
478
|
error: !!(errors !== null && errors !== void 0 && (_errors$icon = errors.icon) !== null && _errors$icon !== void 0 && _errors$icon.message),
|
|
479
|
+
disabled: state.locale !== defaultLocale,
|
|
467
480
|
helperText: (errors === null || errors === void 0 ? void 0 : (_errors$icon2 = errors.icon) === null || _errors$icon2 === void 0 ? void 0 : _errors$icon2.message) || /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
468
481
|
display: "flex",
|
|
469
482
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
@@ -490,7 +503,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
490
503
|
},
|
|
491
504
|
disableFocusRipple: true,
|
|
492
505
|
disableRipple: true,
|
|
493
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconSuffix, {
|
|
506
|
+
children: watchIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconSuffix, {
|
|
494
507
|
icon: watchIcon
|
|
495
508
|
})
|
|
496
509
|
})
|
|
@@ -509,7 +522,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
509
522
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_simpleSelect.default, _objectSpread({
|
|
510
523
|
fullWidth: true,
|
|
511
524
|
margin: "dense",
|
|
512
|
-
disabled: state.type === 'edit',
|
|
525
|
+
disabled: state.type === 'edit' || state.locale !== defaultLocale,
|
|
513
526
|
label: t('navigation.form.component'),
|
|
514
527
|
placeholer: t('navigation.form.componentPlaceholder'),
|
|
515
528
|
options: components.map(item => ({
|
|
@@ -519,7 +532,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
519
532
|
})),
|
|
520
533
|
error: !!(errors !== null && errors !== void 0 && (_errors$component = errors.component) !== null && _errors$component !== void 0 && _errors$component.message),
|
|
521
534
|
helperText: (errors === null || errors === void 0 ? void 0 : (_errors$component2 = errors.component) === null || _errors$component2 === void 0 ? void 0 : _errors$component2.message) || ' '
|
|
522
|
-
}, field));
|
|
535
|
+
}, (0, _omit.default)(field, 'ref')));
|
|
523
536
|
}
|
|
524
537
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
525
538
|
name: "link",
|
|
@@ -528,7 +541,6 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
528
541
|
validate: validLink
|
|
529
542
|
},
|
|
530
543
|
render: _ref6 => {
|
|
531
|
-
var _errors$link3, _errors$link4;
|
|
532
544
|
let {
|
|
533
545
|
field
|
|
534
546
|
} = _ref6;
|
|
@@ -575,8 +587,6 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
575
587
|
children: option.title
|
|
576
588
|
})]
|
|
577
589
|
})),
|
|
578
|
-
error: !!(errors !== null && errors !== void 0 && (_errors$link3 = errors.link) !== null && _errors$link3 !== void 0 && _errors$link3.message),
|
|
579
|
-
helperText: (errors === null || errors === void 0 ? void 0 : (_errors$link4 = errors.link) === null || _errors$link4 === void 0 ? void 0 : _errors$link4.message) || ' ',
|
|
580
590
|
margin: "dense"
|
|
581
591
|
}, field), {}, {
|
|
582
592
|
onChange: () => {},
|
|
@@ -606,7 +616,7 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
|
|
|
606
616
|
})),
|
|
607
617
|
error: !!(errors !== null && errors !== void 0 && (_errors$role = errors.role) !== null && _errors$role !== void 0 && _errors$role.message),
|
|
608
618
|
helperText: (errors === null || errors === void 0 ? void 0 : (_errors$role2 = errors.role) === null || _errors$role2 === void 0 ? void 0 : _errors$role2.message) || ' '
|
|
609
|
-
}, field));
|
|
619
|
+
}, (0, _omit.default)(field, 'ref')));
|
|
610
620
|
}
|
|
611
621
|
})]
|
|
612
622
|
})]
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-beta-
|
|
6
|
+
"version": "1.16.0-beta-ad6df3ae",
|
|
7
7
|
"description": "UX components shared across abtnode packages",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@abtnode/auth": "1.16.0-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.0-beta-
|
|
26
|
-
"@abtnode/util": "1.16.0-beta-
|
|
27
|
-
"@arcblock/did-connect": "^2.5.
|
|
24
|
+
"@abtnode/auth": "1.16.0-beta-ad6df3ae",
|
|
25
|
+
"@abtnode/constant": "1.16.0-beta-ad6df3ae",
|
|
26
|
+
"@abtnode/util": "1.16.0-beta-ad6df3ae",
|
|
27
|
+
"@arcblock/did-connect": "^2.5.16",
|
|
28
28
|
"@arcblock/did-motif": "^1.1.10",
|
|
29
|
-
"@arcblock/icons": "^2.5.
|
|
30
|
-
"@arcblock/react-hooks": "^2.5.
|
|
31
|
-
"@arcblock/terminal": "^2.5.
|
|
32
|
-
"@arcblock/ux": "^2.5.
|
|
33
|
-
"@blocklet/constant": "1.16.0-beta-
|
|
29
|
+
"@arcblock/icons": "^2.5.16",
|
|
30
|
+
"@arcblock/react-hooks": "^2.5.16",
|
|
31
|
+
"@arcblock/terminal": "^2.5.16",
|
|
32
|
+
"@arcblock/ux": "^2.5.16",
|
|
33
|
+
"@blocklet/constant": "1.16.0-beta-ad6df3ae",
|
|
34
34
|
"@blocklet/launcher-layout": "1.9.65",
|
|
35
35
|
"@blocklet/list": "^0.11.10",
|
|
36
|
-
"@blocklet/meta": "1.16.0-beta-
|
|
37
|
-
"@blocklet/ui-react": "^2.5.
|
|
36
|
+
"@blocklet/meta": "1.16.0-beta-ad6df3ae",
|
|
37
|
+
"@blocklet/ui-react": "^2.5.16",
|
|
38
38
|
"@emotion/react": "^11.10.4",
|
|
39
39
|
"@emotion/styled": "^11.10.4",
|
|
40
40
|
"@iconify/react": "^4.0.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"@babel/preset-react": "^7.18.6",
|
|
89
89
|
"babel-plugin-inline-react-svg": "^1.1.2"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "8fa60176a00400cd412b308df3c7d6dcd9af2db1"
|
|
92
92
|
}
|