@hi-ui/hiui 4.3.5 → 4.3.7
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.
- package/CHANGELOG.md +27 -0
- package/lib/cjs/index.js +130 -664
- package/lib/cjs/ui/locale-context/lib/esm/LocaleContext.js +3 -17
- package/lib/cjs/ui/locale-context/lib/esm/LocaleProvider.js +7 -34
- package/lib/cjs/ui/locale-context/lib/esm/locale/en-US.js +1 -1
- package/lib/cjs/ui/locale-context/lib/esm/locale/index.js +1 -6
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-CN.js +1 -1
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-HK.js +1 -1
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-TW.js +1 -1
- package/lib/cjs/ui/locale-context/lib/esm/types.js +0 -4
- package/lib/cjs/utils/array-utils/lib/esm/index.js +1 -8
- package/lib/cjs/utils/env/lib/esm/index.js +0 -8
- package/lib/cjs/utils/object-utils/lib/esm/index.js +4 -15
- package/lib/cjs/utils/type-assertion/lib/esm/index.js +1 -8
- package/lib/esm/ui/locale-context/lib/esm/LocaleContext.js +3 -7
- package/lib/esm/ui/locale-context/lib/esm/LocaleProvider.js +5 -11
- package/lib/esm/ui/locale-context/lib/esm/locale/en-US.js +0 -1
- package/lib/esm/ui/locale-context/lib/esm/locale/index.js +1 -1
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-CN.js +0 -1
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-HK.js +0 -1
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-TW.js +0 -1
- package/lib/esm/ui/locale-context/lib/esm/types.js +0 -1
- package/lib/esm/utils/array-utils/lib/esm/index.js +1 -3
- package/lib/esm/utils/env/lib/esm/index.js +0 -5
- package/lib/esm/utils/object-utils/lib/esm/index.js +1 -6
- package/lib/esm/utils/type-assertion/lib/esm/index.js +1 -3
- package/package.json +6 -6
@@ -9,21 +9,13 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
12
|
var React = require('react');
|
17
|
-
|
18
13
|
var types = require('./types.js');
|
19
|
-
|
20
14
|
var zhCN = require('./locale/zh-CN.js');
|
21
|
-
|
22
15
|
var index = require('../../../../utils/object-utils/lib/esm/index.js');
|
23
|
-
|
24
16
|
var index$1 = require('../../../../utils/env/lib/esm/index.js');
|
25
|
-
|
26
17
|
var index$2 = require('../../../../utils/type-assertion/lib/esm/index.js');
|
18
|
+
|
27
19
|
/** @LICENSE
|
28
20
|
* @hi-ui/locale-context
|
29
21
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -34,37 +26,31 @@ var index$2 = require('../../../../utils/type-assertion/lib/esm/index.js');
|
|
34
26
|
* LICENSE file in the root directory of this source tree.
|
35
27
|
*/
|
36
28
|
|
37
|
-
|
29
|
+
// 1. 赋予动态能力,获取 国际化文案值
|
30
|
+
// 2. 查找异常拦截,进行报错提示
|
38
31
|
var getLanguage = function getLanguage(languageData) {
|
39
32
|
return function (key, data) {
|
40
33
|
var value = index.getNested(languageData, key.split('.'));
|
41
34
|
index$1.invariant(!index$2.isNullish(value), "The " + key + " in language package is missing.");
|
42
|
-
|
43
35
|
if (data) {
|
44
36
|
Object.keys(data).forEach(function (key) {
|
45
37
|
value = value.replace("{{" + key + "}}", data[key]);
|
46
38
|
});
|
47
39
|
}
|
48
|
-
|
49
40
|
return value;
|
50
41
|
};
|
51
42
|
};
|
52
|
-
|
53
43
|
var LocaleContext = /*#__PURE__*/React.createContext(Object.assign(Object.assign({}, zhCN["default"]), {
|
54
44
|
locale: types.LocaleEnum.ZH_CN,
|
55
45
|
get: getLanguage(zhCN["default"])
|
56
46
|
}));
|
57
|
-
|
58
47
|
var useLocaleContext = function useLocaleContext() {
|
59
48
|
var context = React.useContext(LocaleContext);
|
60
|
-
|
61
49
|
if (!context) {
|
62
50
|
throw new Error('The locale context should be wrapped by <LocaleContext locale={locale} /> in App.');
|
63
51
|
}
|
64
|
-
|
65
52
|
return context;
|
66
53
|
};
|
67
|
-
|
68
54
|
exports.LocaleContext = LocaleContext;
|
69
55
|
exports.getLanguage = getLanguage;
|
70
56
|
exports.useLocaleContext = useLocaleContext;
|
@@ -9,49 +9,25 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
var _typeof2 = require("@babel/runtime/helpers/typeof");
|
13
|
-
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
15
|
-
value: true
|
16
|
-
});
|
17
|
-
|
18
12
|
var _typeof = require('@babel/runtime/helpers/esm/typeof');
|
19
|
-
|
20
13
|
var React = require('react');
|
21
|
-
|
22
14
|
var index$1 = require('../../../../utils/env/lib/esm/index.js');
|
23
|
-
|
24
15
|
var LocaleContext = require('./LocaleContext.js');
|
25
|
-
|
26
16
|
var index = require('./locale/index.js');
|
27
|
-
|
28
|
-
|
29
|
-
return e && _typeof2(e) === 'object' && 'default' in e ? e : {
|
30
|
-
'default': e
|
31
|
-
};
|
32
|
-
}
|
33
|
-
|
34
|
-
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
35
|
-
|
36
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
37
|
-
|
38
|
-
var DEFAULT_LOCALE = 'zh-CN'; // 自定义语言包注册表
|
39
|
-
|
17
|
+
var DEFAULT_LOCALE = 'zh-CN';
|
18
|
+
// 自定义语言包注册表
|
40
19
|
var USER_LANGUAGES_TABLES = {};
|
41
|
-
|
42
20
|
var LocaleProvider = function LocaleProvider(_ref) {
|
43
21
|
var children = _ref.children,
|
44
|
-
|
45
|
-
|
46
|
-
|
22
|
+
_ref$locale = _ref.locale,
|
23
|
+
locale = _ref$locale === void 0 ? DEFAULT_LOCALE : _ref$locale,
|
24
|
+
languages = _ref.languages;
|
47
25
|
var get = React.useMemo(function () {
|
48
|
-
var languageData =
|
49
|
-
|
26
|
+
var languageData = _typeof(languages) === 'object' ? languages : USER_LANGUAGES_TABLES[locale] || index["default"][locale];
|
50
27
|
if (!languageData) {
|
51
28
|
index$1.invariant(false, "Will use " + DEFAULT_LOCALE + " as default locale because of the " + locale + " language package is missing.");
|
52
29
|
languageData = index["default"][DEFAULT_LOCALE];
|
53
30
|
}
|
54
|
-
|
55
31
|
return LocaleContext.getLanguage(languageData);
|
56
32
|
}, [locale, languages]);
|
57
33
|
var providedValue = React.useMemo(function () {
|
@@ -60,15 +36,13 @@ var LocaleProvider = function LocaleProvider(_ref) {
|
|
60
36
|
locale: locale
|
61
37
|
});
|
62
38
|
}, [locale, get]);
|
63
|
-
return /*#__PURE__*/
|
39
|
+
return /*#__PURE__*/React.createElement(LocaleContext.LocaleContext.Provider, {
|
64
40
|
value: providedValue
|
65
41
|
}, children);
|
66
42
|
};
|
67
|
-
|
68
43
|
if (index$1.__DEV__) {
|
69
44
|
LocaleProvider.displayName = 'LocaleProvider';
|
70
45
|
}
|
71
|
-
|
72
46
|
var extendsLanguage = function extendsLanguage(locale, languages) {
|
73
47
|
if (!languages) {
|
74
48
|
delete USER_LANGUAGES_TABLES[locale];
|
@@ -76,6 +50,5 @@ var extendsLanguage = function extendsLanguage(locale, languages) {
|
|
76
50
|
USER_LANGUAGES_TABLES[locale] = languages;
|
77
51
|
}
|
78
52
|
};
|
79
|
-
|
80
53
|
LocaleProvider["extends"] = extendsLanguage;
|
81
54
|
exports.LocaleProvider = LocaleProvider;
|
@@ -12,6 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
+
|
15
16
|
/** @LICENSE
|
16
17
|
* @hi-ui/locale-context
|
17
18
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -21,7 +22,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
22
|
* This source code is licensed under the MIT license found in the
|
22
23
|
* LICENSE file in the root directory of this source tree.
|
23
24
|
*/
|
24
|
-
|
25
25
|
var enUS = {
|
26
26
|
timePicker: {
|
27
27
|
ok: 'OK',
|
@@ -12,14 +12,11 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
|
16
15
|
var zhCN = require('./zh-CN.js');
|
17
|
-
|
18
16
|
var enUS = require('./en-US.js');
|
19
|
-
|
20
17
|
var zhHK = require('./zh-HK.js');
|
21
|
-
|
22
18
|
var zhTW = require('./zh-TW.js');
|
19
|
+
|
23
20
|
/** @LICENSE
|
24
21
|
* @hi-ui/locale-context
|
25
22
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -29,8 +26,6 @@ var zhTW = require('./zh-TW.js');
|
|
29
26
|
* This source code is licensed under the MIT license found in the
|
30
27
|
* LICENSE file in the root directory of this source tree.
|
31
28
|
*/
|
32
|
-
|
33
|
-
|
34
29
|
var localeMap = {
|
35
30
|
'zh-CN': zhCN["default"],
|
36
31
|
'zh-Hans': zhCN["default"],
|
@@ -12,6 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
+
|
15
16
|
/** @LICENSE
|
16
17
|
* @hi-ui/locale-context
|
17
18
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -21,7 +22,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
22
|
* This source code is licensed under the MIT license found in the
|
22
23
|
* LICENSE file in the root directory of this source tree.
|
23
24
|
*/
|
24
|
-
|
25
25
|
var zhCN = {
|
26
26
|
timePicker: {
|
27
27
|
ok: '确认',
|
@@ -12,6 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
+
|
15
16
|
/** @LICENSE
|
16
17
|
* @hi-ui/locale-context
|
17
18
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -21,7 +22,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
22
|
* This source code is licensed under the MIT license found in the
|
22
23
|
* LICENSE file in the root directory of this source tree.
|
23
24
|
*/
|
24
|
-
|
25
25
|
var zhHK = {
|
26
26
|
timePicker: {
|
27
27
|
ok: '確認',
|
@@ -12,6 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
+
|
15
16
|
/** @LICENSE
|
16
17
|
* @hi-ui/locale-context
|
17
18
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -21,7 +22,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
22
|
* This source code is licensed under the MIT license found in the
|
22
23
|
* LICENSE file in the root directory of this source tree.
|
23
24
|
*/
|
24
|
-
|
25
25
|
var zhTW = {
|
26
26
|
timePicker: {
|
27
27
|
ok: '確認',
|
@@ -9,9 +9,6 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
12
|
/** @LICENSE
|
16
13
|
* @hi-ui/locale-context
|
17
14
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -21,7 +18,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
18
|
* This source code is licensed under the MIT license found in the
|
22
19
|
* LICENSE file in the root directory of this source tree.
|
23
20
|
*/
|
24
|
-
|
25
21
|
var LocaleEnum = {
|
26
22
|
ZH_CN: 'zh-CN',
|
27
23
|
ZH_HANS: 'zh-Hans',
|
@@ -9,11 +9,8 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
12
|
var index = require('../../../type-assertion/lib/esm/index.js');
|
13
|
+
|
17
14
|
/** @LICENSE
|
18
15
|
* @hi-ui/array-utils
|
19
16
|
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/array-utils#readme
|
@@ -23,15 +20,11 @@ var index = require('../../../type-assertion/lib/esm/index.js');
|
|
23
20
|
* This source code is licensed under the MIT license found in the
|
24
21
|
* LICENSE file in the root directory of this source tree.
|
25
22
|
*/
|
26
|
-
|
27
23
|
/**
|
28
24
|
* 抹平结构为数组
|
29
25
|
*/
|
30
|
-
|
31
|
-
|
32
26
|
var normalizeArray = function normalizeArray(arg) {
|
33
27
|
if (index.isNullish(arg)) return [];
|
34
28
|
return index.isArray(arg) ? arg : [arg];
|
35
29
|
};
|
36
|
-
|
37
30
|
exports.normalizeArray = normalizeArray;
|
@@ -9,9 +9,6 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
12
|
/** @LICENSE
|
16
13
|
* @hi-ui/env
|
17
14
|
* https://github.com/XiaoMi/hiui#readme
|
@@ -21,21 +18,17 @@ Object.defineProperty(exports, '__esModule', {
|
|
21
18
|
* This source code is licensed under the MIT license found in the
|
22
19
|
* LICENSE file in the root directory of this source tree.
|
23
20
|
*/
|
24
|
-
|
25
21
|
var __DEV__ = process.env.NODE_ENV !== 'production';
|
26
|
-
|
27
22
|
var invariant = function invariant(condition, format) {
|
28
23
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
29
24
|
args[_key - 2] = arguments[_key];
|
30
25
|
}
|
31
|
-
|
32
26
|
if (__DEV__) {
|
33
27
|
if (!condition) {
|
34
28
|
var argIndex = 0;
|
35
29
|
var message = "[HiUI] " + format.replace(/%s/g, function () {
|
36
30
|
return args[argIndex++];
|
37
31
|
});
|
38
|
-
|
39
32
|
try {
|
40
33
|
// To find the call stack of error.
|
41
34
|
throw new Error(message);
|
@@ -48,6 +41,5 @@ var invariant = function invariant(condition, format) {
|
|
48
41
|
}
|
49
42
|
}
|
50
43
|
};
|
51
|
-
|
52
44
|
exports.__DEV__ = __DEV__;
|
53
45
|
exports.invariant = invariant;
|
@@ -9,13 +9,9 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
});
|
12
|
+
var index$1 = require('../../../type-assertion/lib/esm/index.js');
|
13
|
+
var index = require('../../../array-utils/lib/esm/index.js');
|
15
14
|
|
16
|
-
var index = require('../../../type-assertion/lib/esm/index.js');
|
17
|
-
|
18
|
-
var index$1 = require('../../../array-utils/lib/esm/index.js');
|
19
15
|
/** @LICENSE
|
20
16
|
* @hi-ui/object-utils
|
21
17
|
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/object-utils#readme
|
@@ -25,7 +21,6 @@ var index$1 = require('../../../array-utils/lib/esm/index.js');
|
|
25
21
|
* This source code is licensed under the MIT license found in the
|
26
22
|
* LICENSE file in the root directory of this source tree.
|
27
23
|
*/
|
28
|
-
|
29
24
|
/**
|
30
25
|
* Get value by deep key in nested object
|
31
26
|
*
|
@@ -34,10 +29,8 @@ var index$1 = require('../../../array-utils/lib/esm/index.js');
|
|
34
29
|
*
|
35
30
|
* get({ a: { b: 3 } }, ['a', 'b']) // 3
|
36
31
|
*/
|
37
|
-
|
38
|
-
|
39
32
|
var getNested = function getNested(obj, paths) {
|
40
|
-
paths = index
|
33
|
+
paths = index.normalizeArray(paths);
|
41
34
|
var props = paths.map(function (p) {
|
42
35
|
return p + '';
|
43
36
|
}).filter(function (p) {
|
@@ -46,16 +39,12 @@ var getNested = function getNested(obj, paths) {
|
|
46
39
|
var target = obj;
|
47
40
|
var i = 0;
|
48
41
|
var len = props.length;
|
49
|
-
|
50
42
|
for (; i < len; ++i) {
|
51
|
-
if (index.isNullish(target)) {
|
43
|
+
if (index$1.isNullish(target)) {
|
52
44
|
break;
|
53
45
|
}
|
54
|
-
|
55
46
|
target = target[props[i]];
|
56
47
|
}
|
57
|
-
|
58
48
|
return i === len ? target : undefined;
|
59
49
|
};
|
60
|
-
|
61
50
|
exports.getNested = getNested;
|
@@ -9,24 +9,17 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
12
|
require('@babel/runtime/helpers/esm/typeof');
|
13
|
+
|
17
14
|
/**
|
18
15
|
* Assert is Nullish
|
19
16
|
*/
|
20
|
-
|
21
|
-
|
22
17
|
var isNullish = function isNullish(arg) {
|
23
18
|
return arg === null || arg === undefined;
|
24
19
|
};
|
25
20
|
/**
|
26
21
|
* Assert is an array
|
27
22
|
*/
|
28
|
-
|
29
|
-
|
30
23
|
var isArray = Array.isArray;
|
31
24
|
exports.isArray = isArray;
|
32
25
|
exports.isNullish = isNullish;
|
@@ -13,6 +13,7 @@ import zhCN from './locale/zh-CN.js';
|
|
13
13
|
import { getNested } from '../../../../utils/object-utils/lib/esm/index.js';
|
14
14
|
import { invariant } from '../../../../utils/env/lib/esm/index.js';
|
15
15
|
import { isNullish } from '../../../../utils/type-assertion/lib/esm/index.js';
|
16
|
+
|
16
17
|
/** @LICENSE
|
17
18
|
* @hi-ui/locale-context
|
18
19
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -23,34 +24,29 @@ import { isNullish } from '../../../../utils/type-assertion/lib/esm/index.js';
|
|
23
24
|
* LICENSE file in the root directory of this source tree.
|
24
25
|
*/
|
25
26
|
|
27
|
+
// 1. 赋予动态能力,获取 国际化文案值
|
28
|
+
// 2. 查找异常拦截,进行报错提示
|
26
29
|
var getLanguage = function getLanguage(languageData) {
|
27
30
|
return function (key, data) {
|
28
31
|
var value = getNested(languageData, key.split('.'));
|
29
32
|
invariant(!isNullish(value), "The " + key + " in language package is missing.");
|
30
|
-
|
31
33
|
if (data) {
|
32
34
|
Object.keys(data).forEach(function (key) {
|
33
35
|
value = value.replace("{{" + key + "}}", data[key]);
|
34
36
|
});
|
35
37
|
}
|
36
|
-
|
37
38
|
return value;
|
38
39
|
};
|
39
40
|
};
|
40
|
-
|
41
41
|
var LocaleContext = /*#__PURE__*/createContext(Object.assign(Object.assign({}, zhCN), {
|
42
42
|
locale: LocaleEnum.ZH_CN,
|
43
43
|
get: getLanguage(zhCN)
|
44
44
|
}));
|
45
|
-
|
46
45
|
var useLocaleContext = function useLocaleContext() {
|
47
46
|
var context = useContext(LocaleContext);
|
48
|
-
|
49
47
|
if (!context) {
|
50
48
|
throw new Error('The locale context should be wrapped by <LocaleContext locale={locale} /> in App.');
|
51
49
|
}
|
52
|
-
|
53
50
|
return context;
|
54
51
|
};
|
55
|
-
|
56
52
|
export { LocaleContext, getLanguage, useLocaleContext };
|
@@ -12,23 +12,20 @@ import React, { useMemo } from 'react';
|
|
12
12
|
import { invariant, __DEV__ } from '../../../../utils/env/lib/esm/index.js';
|
13
13
|
import { getLanguage, LocaleContext } from './LocaleContext.js';
|
14
14
|
import localeMap from './locale/index.js';
|
15
|
-
var DEFAULT_LOCALE = 'zh-CN';
|
16
|
-
|
15
|
+
var DEFAULT_LOCALE = 'zh-CN';
|
16
|
+
// 自定义语言包注册表
|
17
17
|
var USER_LANGUAGES_TABLES = {};
|
18
|
-
|
19
18
|
var LocaleProvider = function LocaleProvider(_ref) {
|
20
19
|
var children = _ref.children,
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
_ref$locale = _ref.locale,
|
21
|
+
locale = _ref$locale === void 0 ? DEFAULT_LOCALE : _ref$locale,
|
22
|
+
languages = _ref.languages;
|
24
23
|
var get = useMemo(function () {
|
25
24
|
var languageData = _typeof(languages) === 'object' ? languages : USER_LANGUAGES_TABLES[locale] || localeMap[locale];
|
26
|
-
|
27
25
|
if (!languageData) {
|
28
26
|
invariant(false, "Will use " + DEFAULT_LOCALE + " as default locale because of the " + locale + " language package is missing.");
|
29
27
|
languageData = localeMap[DEFAULT_LOCALE];
|
30
28
|
}
|
31
|
-
|
32
29
|
return getLanguage(languageData);
|
33
30
|
}, [locale, languages]);
|
34
31
|
var providedValue = useMemo(function () {
|
@@ -41,11 +38,9 @@ var LocaleProvider = function LocaleProvider(_ref) {
|
|
41
38
|
value: providedValue
|
42
39
|
}, children);
|
43
40
|
};
|
44
|
-
|
45
41
|
if (__DEV__) {
|
46
42
|
LocaleProvider.displayName = 'LocaleProvider';
|
47
43
|
}
|
48
|
-
|
49
44
|
var extendsLanguage = function extendsLanguage(locale, languages) {
|
50
45
|
if (!languages) {
|
51
46
|
delete USER_LANGUAGES_TABLES[locale];
|
@@ -53,6 +48,5 @@ var extendsLanguage = function extendsLanguage(locale, languages) {
|
|
53
48
|
USER_LANGUAGES_TABLES[locale] = languages;
|
54
49
|
}
|
55
50
|
};
|
56
|
-
|
57
51
|
LocaleProvider["extends"] = extendsLanguage;
|
58
52
|
export { LocaleProvider };
|
@@ -11,6 +11,7 @@ import zhCN from './zh-CN.js';
|
|
11
11
|
import enUS from './en-US.js';
|
12
12
|
import zhHK from './zh-HK.js';
|
13
13
|
import zhTW from './zh-TW.js';
|
14
|
+
|
14
15
|
/** @LICENSE
|
15
16
|
* @hi-ui/locale-context
|
16
17
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
@@ -20,7 +21,6 @@ import zhTW from './zh-TW.js';
|
|
20
21
|
* This source code is licensed under the MIT license found in the
|
21
22
|
* LICENSE file in the root directory of this source tree.
|
22
23
|
*/
|
23
|
-
|
24
24
|
var localeMap = {
|
25
25
|
'zh-CN': zhCN,
|
26
26
|
'zh-Hans': zhCN,
|
@@ -8,6 +8,7 @@
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import { isNullish, isArray } from '../../../type-assertion/lib/esm/index.js';
|
11
|
+
|
11
12
|
/** @LICENSE
|
12
13
|
* @hi-ui/array-utils
|
13
14
|
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/array-utils#readme
|
@@ -17,14 +18,11 @@ import { isNullish, isArray } from '../../../type-assertion/lib/esm/index.js';
|
|
17
18
|
* This source code is licensed under the MIT license found in the
|
18
19
|
* LICENSE file in the root directory of this source tree.
|
19
20
|
*/
|
20
|
-
|
21
21
|
/**
|
22
22
|
* 抹平结构为数组
|
23
23
|
*/
|
24
|
-
|
25
24
|
var normalizeArray = function normalizeArray(arg) {
|
26
25
|
if (isNullish(arg)) return [];
|
27
26
|
return isArray(arg) ? arg : [arg];
|
28
27
|
};
|
29
|
-
|
30
28
|
export { normalizeArray };
|
@@ -7,7 +7,6 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
|
11
10
|
/** @LICENSE
|
12
11
|
* @hi-ui/env
|
13
12
|
* https://github.com/XiaoMi/hiui#readme
|
@@ -18,19 +17,16 @@
|
|
18
17
|
* LICENSE file in the root directory of this source tree.
|
19
18
|
*/
|
20
19
|
var __DEV__ = process.env.NODE_ENV !== 'production';
|
21
|
-
|
22
20
|
var invariant = function invariant(condition, format) {
|
23
21
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
24
22
|
args[_key - 2] = arguments[_key];
|
25
23
|
}
|
26
|
-
|
27
24
|
if (__DEV__) {
|
28
25
|
if (!condition) {
|
29
26
|
var argIndex = 0;
|
30
27
|
var message = "[HiUI] " + format.replace(/%s/g, function () {
|
31
28
|
return args[argIndex++];
|
32
29
|
});
|
33
|
-
|
34
30
|
try {
|
35
31
|
// To find the call stack of error.
|
36
32
|
throw new Error(message);
|
@@ -43,5 +39,4 @@ var invariant = function invariant(condition, format) {
|
|
43
39
|
}
|
44
40
|
}
|
45
41
|
};
|
46
|
-
|
47
42
|
export { __DEV__, invariant };
|
@@ -9,6 +9,7 @@
|
|
9
9
|
*/
|
10
10
|
import { isNullish } from '../../../type-assertion/lib/esm/index.js';
|
11
11
|
import { normalizeArray } from '../../../array-utils/lib/esm/index.js';
|
12
|
+
|
12
13
|
/** @LICENSE
|
13
14
|
* @hi-ui/object-utils
|
14
15
|
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/object-utils#readme
|
@@ -18,7 +19,6 @@ import { normalizeArray } from '../../../array-utils/lib/esm/index.js';
|
|
18
19
|
* This source code is licensed under the MIT license found in the
|
19
20
|
* LICENSE file in the root directory of this source tree.
|
20
21
|
*/
|
21
|
-
|
22
22
|
/**
|
23
23
|
* Get value by deep key in nested object
|
24
24
|
*
|
@@ -27,7 +27,6 @@ import { normalizeArray } from '../../../array-utils/lib/esm/index.js';
|
|
27
27
|
*
|
28
28
|
* get({ a: { b: 3 } }, ['a', 'b']) // 3
|
29
29
|
*/
|
30
|
-
|
31
30
|
var getNested = function getNested(obj, paths) {
|
32
31
|
paths = normalizeArray(paths);
|
33
32
|
var props = paths.map(function (p) {
|
@@ -38,16 +37,12 @@ var getNested = function getNested(obj, paths) {
|
|
38
37
|
var target = obj;
|
39
38
|
var i = 0;
|
40
39
|
var len = props.length;
|
41
|
-
|
42
40
|
for (; i < len; ++i) {
|
43
41
|
if (isNullish(target)) {
|
44
42
|
break;
|
45
43
|
}
|
46
|
-
|
47
44
|
target = target[props[i]];
|
48
45
|
}
|
49
|
-
|
50
46
|
return i === len ? target : undefined;
|
51
47
|
};
|
52
|
-
|
53
48
|
export { getNested };
|
@@ -8,17 +8,15 @@
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import '@babel/runtime/helpers/esm/typeof';
|
11
|
+
|
11
12
|
/**
|
12
13
|
* Assert is Nullish
|
13
14
|
*/
|
14
|
-
|
15
15
|
var isNullish = function isNullish(arg) {
|
16
16
|
return arg === null || arg === undefined;
|
17
17
|
};
|
18
18
|
/**
|
19
19
|
* Assert is an array
|
20
20
|
*/
|
21
|
-
|
22
|
-
|
23
21
|
var isArray = Array.isArray;
|
24
22
|
export { isArray, isNullish };
|