@chaoswise/ui 2.4.0 → 2.4.1
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.
|
@@ -35,6 +35,13 @@ import { formatMessage } from "../../utils";
|
|
|
35
35
|
import "./index.less";
|
|
36
36
|
var useThemeSwitcher = _ThemeProvider.useThemeSwitcher;
|
|
37
37
|
var TabPane = _Tabs.TabPane;
|
|
38
|
+
var localOptionsMap = {
|
|
39
|
+
en: "enName",
|
|
40
|
+
en_US: "enName",
|
|
41
|
+
zh_TW: "name",
|
|
42
|
+
zh: "name",
|
|
43
|
+
zh_CN: "name"
|
|
44
|
+
};
|
|
38
45
|
var MessageContent = function MessageContent(props) {
|
|
39
46
|
var hideOnSinglePage = props.hideOnSinglePage,
|
|
40
47
|
setVisible = props.setVisible,
|
|
@@ -218,7 +225,7 @@ var MessageContent = function MessageContent(props) {
|
|
|
218
225
|
className: "cw-message-content-tabs",
|
|
219
226
|
animated: false
|
|
220
227
|
}, tabOption.map(function (item) {
|
|
221
|
-
var tabName = item
|
|
228
|
+
var tabName = item[localOptionsMap[locale]];
|
|
222
229
|
var moreTitle = formatMessage(localeObj["more"]);
|
|
223
230
|
return /*#__PURE__*/React.createElement(TabPane, {
|
|
224
231
|
tab: unreadTypeArr.includes(item.code) ? /*#__PURE__*/React.createElement(_Badge, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
import "antd/es/config-provider/style";
|
|
3
3
|
import _ConfigProvider from "antd/es/config-provider";
|
|
4
|
-
var _excluded = ["children", "locales", "defaultLocale"];
|
|
4
|
+
var _excluded = ["children", "locales", "defaultLocale", "messages"];
|
|
5
5
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -19,11 +19,29 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
19
|
import React, { useEffect, useState } from 'react';
|
|
20
20
|
import Antd4ConfigProvider from '../Antd4/config-provider';
|
|
21
21
|
import { IntlProvider } from 'react-intl';
|
|
22
|
-
import zh_CN_antd from '../Antd4/locale/zh_CN';
|
|
23
|
-
import en_US_antd from '../Antd4/locale/en_US';
|
|
24
|
-
import zh_TW_antd from '../Antd4/locale/zh_TW';
|
|
25
22
|
import moment from 'moment';
|
|
26
23
|
import 'moment/locale/zh-cn';
|
|
24
|
+
import zh_CN_antd4 from '../Antd4/locale/zh_CN';
|
|
25
|
+
import en_US_antd4 from '../Antd4/locale/en_US';
|
|
26
|
+
import zh_TW_antd4 from '../Antd4/locale/zh_TW';
|
|
27
|
+
import zh_CN_antd from 'antd/es/locale/zh_CN';
|
|
28
|
+
import zh_TW_antd from 'antd/es/locale/zh_TW';
|
|
29
|
+
import en_US_antd from 'antd/es/locale/en_US';
|
|
30
|
+
var ANTD4_LOCALE_MAP = {
|
|
31
|
+
zh_CN: zh_CN_antd4,
|
|
32
|
+
en_US: en_US_antd4,
|
|
33
|
+
zh_TW: zh_TW_antd4
|
|
34
|
+
};
|
|
35
|
+
var ANTD3_LOCALE_MAP = {
|
|
36
|
+
zh_CN: zh_CN_antd,
|
|
37
|
+
en_US: en_US_antd,
|
|
38
|
+
zh_TW: zh_TW_antd
|
|
39
|
+
};
|
|
40
|
+
var I18N_MAP = {
|
|
41
|
+
zh_CN: 'zh',
|
|
42
|
+
en_US: 'en',
|
|
43
|
+
zh_TW: 'zh'
|
|
44
|
+
};
|
|
27
45
|
export var intlContext = /*#__PURE__*/React.createContext({
|
|
28
46
|
localeContext: {
|
|
29
47
|
locale: '',
|
|
@@ -31,42 +49,44 @@ export var intlContext = /*#__PURE__*/React.createContext({
|
|
|
31
49
|
}
|
|
32
50
|
});
|
|
33
51
|
var Provider = intlContext.Provider;
|
|
52
|
+
|
|
53
|
+
// 兼容映射
|
|
54
|
+
var LOCALE_MAP = {
|
|
55
|
+
zh: 'zh_CN',
|
|
56
|
+
en: 'en_US'
|
|
57
|
+
};
|
|
34
58
|
var AllProvider = function AllProvider(_ref) {
|
|
59
|
+
var _locales$locale;
|
|
35
60
|
var children = _ref.children,
|
|
36
61
|
_ref$locales = _ref.locales,
|
|
37
62
|
locales = _ref$locales === void 0 ? {} : _ref$locales,
|
|
38
63
|
_ref$defaultLocale = _ref.defaultLocale,
|
|
39
64
|
defaultLocale = _ref$defaultLocale === void 0 ? 'zh_CN' : _ref$defaultLocale,
|
|
65
|
+
messages = _ref.messages,
|
|
40
66
|
resProps = _objectWithoutProperties(_ref, _excluded);
|
|
41
67
|
var _useState = useState(defaultLocale),
|
|
42
68
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
69
|
locale = _useState2[0],
|
|
44
70
|
setLocale = _useState2[1];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
71
|
+
var currentLocale = LOCALE_MAP[locale] || locale;
|
|
72
|
+
var getMomentLocale = function getMomentLocale(currentLocale) {
|
|
73
|
+
if (['zh_CN', 'zh_TW'].includes(currentLocale)) {
|
|
74
|
+
return 'zh-cn';
|
|
48
75
|
}
|
|
49
|
-
|
|
50
|
-
|
|
76
|
+
return 'en';
|
|
77
|
+
};
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
moment.locale(getMomentLocale(currentLocale));
|
|
51
80
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
nowLocalInfo.antdLocale.Empty.description = 'No data';
|
|
81
|
+
// 文案按UX规范,原始为 No Data
|
|
82
|
+
if (currentLocale === 'en_US') {
|
|
83
|
+
ANTD3_LOCALE_MAP[currentLocale].Empty.description = 'No data';
|
|
56
84
|
}
|
|
57
|
-
}
|
|
85
|
+
}, [currentLocale]);
|
|
58
86
|
var configProps = _objectSpread({
|
|
59
|
-
locale:
|
|
87
|
+
locale: ANTD3_LOCALE_MAP[currentLocale],
|
|
60
88
|
autoInsertSpaceInButton: false
|
|
61
89
|
}, resProps);
|
|
62
|
-
var Antd4Local = {
|
|
63
|
-
zh_CN_antd: zh_CN_antd,
|
|
64
|
-
zh_TW_antd: zh_TW_antd,
|
|
65
|
-
en_US_antd: en_US_antd,
|
|
66
|
-
// 兼容老版本
|
|
67
|
-
zh: zh_CN_antd,
|
|
68
|
-
en: en_US_antd
|
|
69
|
-
};
|
|
70
90
|
return /*#__PURE__*/React.createElement(Provider, {
|
|
71
91
|
value: {
|
|
72
92
|
locale: locale,
|
|
@@ -74,10 +94,10 @@ var AllProvider = function AllProvider(_ref) {
|
|
|
74
94
|
locales: locales
|
|
75
95
|
}
|
|
76
96
|
}, /*#__PURE__*/React.createElement(_ConfigProvider, configProps, /*#__PURE__*/React.createElement(Antd4ConfigProvider, _extends({}, configProps, {
|
|
77
|
-
locale:
|
|
78
|
-
}),
|
|
79
|
-
locale:
|
|
80
|
-
messages:
|
|
81
|
-
}, children)
|
|
97
|
+
locale: ANTD4_LOCALE_MAP[currentLocale]
|
|
98
|
+
}), /*#__PURE__*/React.createElement(IntlProvider, {
|
|
99
|
+
locale: I18N_MAP[currentLocale],
|
|
100
|
+
messages: messages ? messages : (_locales$locale = locales[locale]) === null || _locales$locale === void 0 ? void 0 : _locales$locale.messages
|
|
101
|
+
}, children))));
|
|
82
102
|
};
|
|
83
103
|
export default AllProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaoswise/ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "公共UI库",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -143,5 +143,5 @@
|
|
|
143
143
|
"access": "public"
|
|
144
144
|
},
|
|
145
145
|
"license": "MIT",
|
|
146
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "7a1c75490a7afac8fa31b8bff80bc00a59f60e57"
|
|
147
147
|
}
|