@hi-ui/hiui 4.0.0-beta.93 → 4.0.0
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/lib/cjs/index.js +8 -18
- package/lib/cjs/ui/locale-context/lib/esm/LocaleContext.js +68 -0
- package/lib/cjs/ui/locale-context/lib/esm/LocaleProvider.js +84 -0
- package/lib/cjs/ui/locale-context/lib/esm/locale/en-US.js +193 -0
- package/lib/cjs/ui/locale-context/lib/esm/locale/index.js +41 -0
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-CN.js +197 -0
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-HK.js +197 -0
- package/lib/cjs/ui/locale-context/lib/esm/locale/zh-TW.js +197 -0
- package/lib/cjs/ui/locale-context/lib/esm/types.js +32 -0
- package/lib/cjs/utils/array-utils/lib/esm/index.js +37 -0
- package/lib/cjs/utils/env/lib/esm/index.js +53 -0
- package/lib/cjs/utils/object-utils/lib/esm/index.js +61 -0
- package/lib/cjs/utils/type-assertion/lib/esm/index.js +32 -0
- package/lib/esm/index.js +3 -3
- package/lib/esm/ui/locale-context/lib/esm/LocaleContext.js +55 -0
- package/lib/esm/ui/locale-context/lib/esm/LocaleProvider.js +61 -0
- package/lib/esm/ui/locale-context/lib/esm/locale/en-US.js +188 -0
- package/lib/esm/ui/locale-context/lib/esm/locale/index.js +31 -0
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-CN.js +192 -0
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-HK.js +192 -0
- package/lib/esm/ui/locale-context/lib/esm/locale/zh-TW.js +192 -0
- package/lib/esm/ui/locale-context/lib/esm/types.js +27 -0
- package/lib/esm/utils/array-utils/lib/esm/index.js +30 -0
- package/lib/esm/utils/env/lib/esm/index.js +47 -0
- package/lib/esm/utils/object-utils/lib/esm/index.js +53 -0
- package/lib/esm/utils/type-assertion/lib/esm/index.js +24 -0
- package/lib/types/index.d.ts +2 -2
- package/package.json +68 -66
@@ -0,0 +1,197 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
/** @LICENSE
|
16
|
+
* @hi-ui/locale-context
|
17
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
18
|
+
*
|
19
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
20
|
+
*
|
21
|
+
* This source code is licensed under the MIT license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
|
25
|
+
var zhHK = {
|
26
|
+
timePicker: {
|
27
|
+
ok: '確認',
|
28
|
+
to: '-',
|
29
|
+
now: '此刻'
|
30
|
+
},
|
31
|
+
datePicker: {
|
32
|
+
ok: '確認',
|
33
|
+
to: '-',
|
34
|
+
placeholder: ['請選擇日期'],
|
35
|
+
placeholderTimePeriod: ['請選擇時間'],
|
36
|
+
dateChoose: '日期選擇',
|
37
|
+
timeChoose: '時間選擇',
|
38
|
+
undefinedType: '類型未定義',
|
39
|
+
lastWeek: '近壹周',
|
40
|
+
lastMonth: '近壹月',
|
41
|
+
lastThreeMonth: '近三月',
|
42
|
+
lastYear: '近壹年',
|
43
|
+
month: ['壹月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十壹月', '十二月'],
|
44
|
+
monthShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
45
|
+
week: ['日', '壹', '二', '三', '四', '五', '六'],
|
46
|
+
placeholders: {
|
47
|
+
date: ['請選擇日期'],
|
48
|
+
month: ['請選擇月'],
|
49
|
+
year: ['請選擇年'],
|
50
|
+
time: ['請選擇時間'],
|
51
|
+
daterange: ['開始日期', '結束日期'],
|
52
|
+
week: ['請選擇周'],
|
53
|
+
weekrange: ['開始周', '結束周'],
|
54
|
+
timeperiod: ['開始時間', '結束時間'],
|
55
|
+
timerange: ['請選擇開始時間', '請選擇結束時間']
|
56
|
+
},
|
57
|
+
year: '年',
|
58
|
+
timePeriod: '時間段',
|
59
|
+
hours: '時',
|
60
|
+
minutes: '分',
|
61
|
+
seconds: '秒',
|
62
|
+
weekRange: '{{year}}-W{{week}}'
|
63
|
+
},
|
64
|
+
pagination: {
|
65
|
+
total: ['共', '條'],
|
66
|
+
simple: ['第', '頁', '共', '頁', '條記錄'],
|
67
|
+
item: '條',
|
68
|
+
itemPerPage: '頁',
|
69
|
+
"goto": '前往',
|
70
|
+
page: '頁'
|
71
|
+
},
|
72
|
+
cascader: {
|
73
|
+
placeholder: '請選擇',
|
74
|
+
noFoundTip: '無匹配數據',
|
75
|
+
emptyContent: '暫無數據'
|
76
|
+
},
|
77
|
+
checkCascader: {
|
78
|
+
placeholder: '請選擇',
|
79
|
+
noFoundTip: '無匹配數據',
|
80
|
+
emptyContent: '暫無數據'
|
81
|
+
},
|
82
|
+
picker: {
|
83
|
+
placeholder: '請選擇',
|
84
|
+
emptyContent: '暫無數據',
|
85
|
+
noFoundTip: '無匹配數據',
|
86
|
+
searchPlaceholder: '搜索',
|
87
|
+
loadingContent: '數據加載中...'
|
88
|
+
},
|
89
|
+
treeSelect: {
|
90
|
+
placeholder: '請選擇'
|
91
|
+
},
|
92
|
+
checkTreeSelect: {
|
93
|
+
placeholder: '請選擇'
|
94
|
+
},
|
95
|
+
select: {
|
96
|
+
placeholder: '請選擇',
|
97
|
+
emptyContent: '無匹配數據',
|
98
|
+
searchPlaceholder: '搜索',
|
99
|
+
checkAll: '全選',
|
100
|
+
justSelected: '僅看已選'
|
101
|
+
},
|
102
|
+
checkSelect: {
|
103
|
+
placeholder: '請選擇',
|
104
|
+
emptyContent: '無匹配數據',
|
105
|
+
searchPlaceholder: '搜索',
|
106
|
+
checkAll: '全選',
|
107
|
+
justSelected: '僅看已選'
|
108
|
+
},
|
109
|
+
selectTree: {
|
110
|
+
back: '返回',
|
111
|
+
search: '搜索',
|
112
|
+
placeholder: '請選擇',
|
113
|
+
emptyContent: '無匹配數據'
|
114
|
+
},
|
115
|
+
search: {
|
116
|
+
searchEmptyResult: '未找到搜索結果',
|
117
|
+
searchEmptyRecord: '無搜索記錄',
|
118
|
+
searchRecord: '搜索歷史'
|
119
|
+
},
|
120
|
+
transfer: {
|
121
|
+
checkAll: '全選',
|
122
|
+
items: '項',
|
123
|
+
searchPlaceholder: '搜索',
|
124
|
+
emptyContent: '暫無數據',
|
125
|
+
limit: '數量達上限,無法添加'
|
126
|
+
},
|
127
|
+
upload: {
|
128
|
+
buttonText: '上傳',
|
129
|
+
uploadSuccess: '上傳成功',
|
130
|
+
cancel: '取消',
|
131
|
+
"delete": '刪除',
|
132
|
+
drag: '點擊或将文件拖拽至此上傳',
|
133
|
+
dragTips: '請點擊或拖拽文件上傳',
|
134
|
+
dragTipsLimited: '數量已達上限',
|
135
|
+
preview: '預覽',
|
136
|
+
modalTiptitle: '上傳失敗',
|
137
|
+
modalTiptxt: '該上傳文件超過指定上傳文件大小',
|
138
|
+
modalBtn: '我知道了',
|
139
|
+
modalTitle: '提示'
|
140
|
+
},
|
141
|
+
modal: {
|
142
|
+
confirmText: '確定',
|
143
|
+
cancelText: '取消'
|
144
|
+
},
|
145
|
+
tabs: {
|
146
|
+
more: '更多'
|
147
|
+
},
|
148
|
+
timeline: {
|
149
|
+
expand: '展開',
|
150
|
+
collapse: '收起'
|
151
|
+
},
|
152
|
+
form: {
|
153
|
+
colon: ':'
|
154
|
+
},
|
155
|
+
tree: {
|
156
|
+
addNode: '添加節點',
|
157
|
+
addChildNode: '添加子節點',
|
158
|
+
edit: '編輯節點',
|
159
|
+
del: '刪除',
|
160
|
+
confirm: '確認',
|
161
|
+
cancel: '取消',
|
162
|
+
nodePlaceholder: '請輸入節點名稱',
|
163
|
+
searchPlaceholder: '關鍵詞搜索',
|
164
|
+
searchEmptyResult: '未找到搜索結果',
|
165
|
+
modalTitle: '提示',
|
166
|
+
delTips: '刪除節點將刪除所有子節點,確定刪除嗎?'
|
167
|
+
},
|
168
|
+
table: {
|
169
|
+
emptyContent: '暫無數據',
|
170
|
+
confirm: '確定',
|
171
|
+
reset: '重置',
|
172
|
+
ascend: '升序',
|
173
|
+
descend: '降序',
|
174
|
+
highlight: '高亮',
|
175
|
+
freeze: '凍結',
|
176
|
+
total: '合計',
|
177
|
+
average: '平均值',
|
178
|
+
fieldExplorer: '字段管理'
|
179
|
+
},
|
180
|
+
watermark: {
|
181
|
+
content: '請勿外傳'
|
182
|
+
},
|
183
|
+
emptyState: {
|
184
|
+
emptyContent: '暫無數據'
|
185
|
+
},
|
186
|
+
zenMode: {
|
187
|
+
back: '返回'
|
188
|
+
},
|
189
|
+
popConfirm: {
|
190
|
+
confirmText: '確定',
|
191
|
+
cancelText: '取消'
|
192
|
+
},
|
193
|
+
tag: {
|
194
|
+
add: '添加'
|
195
|
+
}
|
196
|
+
};
|
197
|
+
exports["default"] = zhHK;
|
@@ -0,0 +1,197 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
/** @LICENSE
|
16
|
+
* @hi-ui/locale-context
|
17
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
18
|
+
*
|
19
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
20
|
+
*
|
21
|
+
* This source code is licensed under the MIT license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
|
25
|
+
var zhTW = {
|
26
|
+
timePicker: {
|
27
|
+
ok: '確認',
|
28
|
+
to: '-',
|
29
|
+
now: '此刻'
|
30
|
+
},
|
31
|
+
datePicker: {
|
32
|
+
ok: '確認',
|
33
|
+
to: '-',
|
34
|
+
placeholder: ['請選擇日期'],
|
35
|
+
placeholderTimePeriod: ['請選擇時間'],
|
36
|
+
dateChoose: '日期選擇',
|
37
|
+
timeChoose: '時間選擇',
|
38
|
+
undefinedType: '類型未定義',
|
39
|
+
lastWeek: '近壹周',
|
40
|
+
lastMonth: '近壹月',
|
41
|
+
lastThreeMonth: '近三月',
|
42
|
+
lastYear: '近壹年',
|
43
|
+
month: ['壹月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十壹月', '十二月'],
|
44
|
+
monthShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
45
|
+
week: ['日', '壹', '二', '三', '四', '五', '六'],
|
46
|
+
placeholders: {
|
47
|
+
date: ['請選擇日期'],
|
48
|
+
month: ['請選擇月'],
|
49
|
+
year: ['請選擇年'],
|
50
|
+
time: ['請選擇時間'],
|
51
|
+
daterange: ['開始日期', '結束日期'],
|
52
|
+
week: ['請選擇周'],
|
53
|
+
weekrange: ['開始周', '結束周'],
|
54
|
+
timeperiod: ['開始時間', '結束時間'],
|
55
|
+
timerange: ['請選擇開始時間', '請選擇結束時間']
|
56
|
+
},
|
57
|
+
year: '年',
|
58
|
+
timePeriod: '時間段',
|
59
|
+
hours: '時',
|
60
|
+
minutes: '分',
|
61
|
+
seconds: '秒',
|
62
|
+
weekRange: '{{year}}-W{{week}}'
|
63
|
+
},
|
64
|
+
pagination: {
|
65
|
+
total: ['共', '條'],
|
66
|
+
simple: ['第', '頁', '共', '頁', '條記錄'],
|
67
|
+
item: '條',
|
68
|
+
itemPerPage: '頁',
|
69
|
+
"goto": '前往',
|
70
|
+
page: '頁'
|
71
|
+
},
|
72
|
+
cascader: {
|
73
|
+
placeholder: '請選擇',
|
74
|
+
noFoundTip: '無匹配數據',
|
75
|
+
emptyContent: '暫無數據'
|
76
|
+
},
|
77
|
+
checkCascader: {
|
78
|
+
placeholder: '請選擇',
|
79
|
+
noFoundTip: '無匹配數據',
|
80
|
+
emptyContent: '暫無數據'
|
81
|
+
},
|
82
|
+
picker: {
|
83
|
+
placeholder: '請選擇',
|
84
|
+
emptyContent: '暫無數據',
|
85
|
+
noFoundTip: '無匹配數據',
|
86
|
+
searchPlaceholder: '搜索',
|
87
|
+
loadingContent: '數據加載中...'
|
88
|
+
},
|
89
|
+
treeSelect: {
|
90
|
+
placeholder: '請選擇'
|
91
|
+
},
|
92
|
+
checkTreeSelect: {
|
93
|
+
placeholder: '請選擇'
|
94
|
+
},
|
95
|
+
select: {
|
96
|
+
placeholder: '請選擇',
|
97
|
+
emptyContent: '無匹配數據',
|
98
|
+
searchPlaceholder: '搜索',
|
99
|
+
checkAll: '全選',
|
100
|
+
justSelected: '僅看已選'
|
101
|
+
},
|
102
|
+
checkSelect: {
|
103
|
+
placeholder: '請選擇',
|
104
|
+
emptyContent: '無匹配數據',
|
105
|
+
searchPlaceholder: '搜索',
|
106
|
+
checkAll: '全選',
|
107
|
+
justSelected: '僅看已選'
|
108
|
+
},
|
109
|
+
selectTree: {
|
110
|
+
back: '返回',
|
111
|
+
search: '搜索',
|
112
|
+
placeholder: '請選擇',
|
113
|
+
emptyContent: '無匹配數據'
|
114
|
+
},
|
115
|
+
search: {
|
116
|
+
searchEmptyResult: '未找到搜索結果',
|
117
|
+
searchEmptyRecord: '無搜索記錄',
|
118
|
+
searchRecord: '搜索歷史'
|
119
|
+
},
|
120
|
+
transfer: {
|
121
|
+
checkAll: '全選',
|
122
|
+
items: '項',
|
123
|
+
searchPlaceholder: '搜索',
|
124
|
+
emptyContent: '暫無數據',
|
125
|
+
limit: '數量達上限,無法添加'
|
126
|
+
},
|
127
|
+
upload: {
|
128
|
+
buttonText: '上傳',
|
129
|
+
uploadSuccess: '上傳成功',
|
130
|
+
cancel: '取消',
|
131
|
+
"delete": '刪除',
|
132
|
+
drag: '點擊或将文件拖拽至此上傳',
|
133
|
+
dragTips: '請點擊或拖拽文件上傳',
|
134
|
+
dragTipsLimited: '數量已達上限',
|
135
|
+
preview: '預覽',
|
136
|
+
modalTiptitle: '上傳失敗',
|
137
|
+
modalTiptxt: '該上傳文件超過指定上傳文件大小',
|
138
|
+
modalBtn: '我知道了',
|
139
|
+
modalTitle: '提示'
|
140
|
+
},
|
141
|
+
modal: {
|
142
|
+
confirmText: '確定',
|
143
|
+
cancelText: '取消'
|
144
|
+
},
|
145
|
+
tabs: {
|
146
|
+
more: '更多'
|
147
|
+
},
|
148
|
+
timeline: {
|
149
|
+
expand: '展開',
|
150
|
+
collapse: '收起'
|
151
|
+
},
|
152
|
+
form: {
|
153
|
+
colon: ':'
|
154
|
+
},
|
155
|
+
tree: {
|
156
|
+
addNode: '添加節點',
|
157
|
+
addChildNode: '添加子節點',
|
158
|
+
edit: '編輯節點',
|
159
|
+
del: '刪除',
|
160
|
+
confirm: '確認',
|
161
|
+
cancel: '取消',
|
162
|
+
nodePlaceholder: '請輸入節點名稱',
|
163
|
+
searchPlaceholder: '關鍵詞搜索',
|
164
|
+
searchEmptyResult: '未找到搜索結果',
|
165
|
+
modalTitle: '提示',
|
166
|
+
delTips: '刪除節點將刪除所有子節點,確定刪除嗎?'
|
167
|
+
},
|
168
|
+
table: {
|
169
|
+
emptyContent: '暫無數據',
|
170
|
+
confirm: '確定',
|
171
|
+
reset: '重置',
|
172
|
+
ascend: '升序',
|
173
|
+
descend: '降序',
|
174
|
+
highlight: '高亮',
|
175
|
+
freeze: '凍結',
|
176
|
+
total: '合計',
|
177
|
+
average: '平均值',
|
178
|
+
fieldExplorer: '字段管理'
|
179
|
+
},
|
180
|
+
watermark: {
|
181
|
+
content: '請勿外傳'
|
182
|
+
},
|
183
|
+
emptyState: {
|
184
|
+
emptyContent: '暫無數據'
|
185
|
+
},
|
186
|
+
zenMode: {
|
187
|
+
back: '返回'
|
188
|
+
},
|
189
|
+
popConfirm: {
|
190
|
+
confirmText: '確定',
|
191
|
+
cancelText: '取消'
|
192
|
+
},
|
193
|
+
tag: {
|
194
|
+
add: '添加'
|
195
|
+
}
|
196
|
+
};
|
197
|
+
exports["default"] = zhTW;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
/** @LICENSE
|
16
|
+
* @hi-ui/locale-context
|
17
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
18
|
+
*
|
19
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
20
|
+
*
|
21
|
+
* This source code is licensed under the MIT license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
|
25
|
+
var LocaleEnum = {
|
26
|
+
ZH_CN: 'zh-CN',
|
27
|
+
ZH_HANS: 'zh-Hans',
|
28
|
+
EN_US: 'en-US',
|
29
|
+
ZH_HK: 'zh-HK',
|
30
|
+
ZH_TW: 'zh-TW'
|
31
|
+
};
|
32
|
+
exports.LocaleEnum = LocaleEnum;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
|
16
|
+
var index = require('../../../type-assertion/lib/esm/index.js');
|
17
|
+
/** @LICENSE
|
18
|
+
* @hi-ui/array-utils
|
19
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/array-utils#readme
|
20
|
+
*
|
21
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
22
|
+
*
|
23
|
+
* This source code is licensed under the MIT license found in the
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
25
|
+
*/
|
26
|
+
|
27
|
+
/**
|
28
|
+
* 抹平结构为数组
|
29
|
+
*/
|
30
|
+
|
31
|
+
|
32
|
+
var normalizeArray = function normalizeArray(arg) {
|
33
|
+
if (index.isNullish(arg)) return [];
|
34
|
+
return index.isArray(arg) ? arg : [arg];
|
35
|
+
};
|
36
|
+
|
37
|
+
exports.normalizeArray = normalizeArray;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
/** @LICENSE
|
16
|
+
* @hi-ui/env
|
17
|
+
* https://github.com/XiaoMi/hiui#readme
|
18
|
+
*
|
19
|
+
* Copyright (c) Flcwl <flcwl@vip.qq.com>.
|
20
|
+
*
|
21
|
+
* This source code is licensed under the MIT license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
|
25
|
+
var __DEV__ = process.env.NODE_ENV !== 'production';
|
26
|
+
|
27
|
+
var invariant = function invariant(condition, format) {
|
28
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
29
|
+
args[_key - 2] = arguments[_key];
|
30
|
+
}
|
31
|
+
|
32
|
+
if (__DEV__) {
|
33
|
+
if (!condition) {
|
34
|
+
var argIndex = 0;
|
35
|
+
var message = "[HiUI] " + format.replace(/%s/g, function () {
|
36
|
+
return args[argIndex++];
|
37
|
+
});
|
38
|
+
|
39
|
+
try {
|
40
|
+
// To find the call stack of error.
|
41
|
+
throw new Error(message);
|
42
|
+
} catch (error) {
|
43
|
+
// support for SSR.
|
44
|
+
if (typeof console !== 'undefined') {
|
45
|
+
console.error(error);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
exports.__DEV__ = __DEV__;
|
53
|
+
exports.invariant = invariant;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
|
16
|
+
var index = require('../../../type-assertion/lib/esm/index.js');
|
17
|
+
|
18
|
+
var index$1 = require('../../../array-utils/lib/esm/index.js');
|
19
|
+
/** @LICENSE
|
20
|
+
* @hi-ui/object-utils
|
21
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/object-utils#readme
|
22
|
+
*
|
23
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
24
|
+
*
|
25
|
+
* This source code is licensed under the MIT license found in the
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
27
|
+
*/
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Get value by deep key in nested object
|
31
|
+
*
|
32
|
+
* @refs https://github.com/Flcwl/unext/blob/master/src/get.ts
|
33
|
+
* @example
|
34
|
+
*
|
35
|
+
* get({ a: { b: 3 } }, ['a', 'b']) // 3
|
36
|
+
*/
|
37
|
+
|
38
|
+
|
39
|
+
var getNested = function getNested(obj, paths) {
|
40
|
+
paths = index$1.normalizeArray(paths);
|
41
|
+
var props = paths.map(function (p) {
|
42
|
+
return p + '';
|
43
|
+
}).filter(function (p) {
|
44
|
+
return p !== '';
|
45
|
+
});
|
46
|
+
var target = obj;
|
47
|
+
var i = 0;
|
48
|
+
var len = props.length;
|
49
|
+
|
50
|
+
for (; i < len; ++i) {
|
51
|
+
if (index.isNullish(target)) {
|
52
|
+
break;
|
53
|
+
}
|
54
|
+
|
55
|
+
target = target[props[i]];
|
56
|
+
}
|
57
|
+
|
58
|
+
return i === len ? target : undefined;
|
59
|
+
};
|
60
|
+
|
61
|
+
exports.getNested = getNested;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
|
16
|
+
require('@babel/runtime/helpers/esm/typeof');
|
17
|
+
/**
|
18
|
+
* Assert is Nullish
|
19
|
+
*/
|
20
|
+
|
21
|
+
|
22
|
+
var isNullish = function isNullish(arg) {
|
23
|
+
return arg === null || arg === undefined;
|
24
|
+
};
|
25
|
+
/**
|
26
|
+
* Assert is an array
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
var isArray = Array.isArray;
|
31
|
+
exports.isArray = isArray;
|
32
|
+
exports.isNullish = isNullish;
|
package/lib/esm/index.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @hi-ui/hiui
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
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.
|
@@ -59,8 +59,8 @@ export * from '@hi-ui/list';
|
|
59
59
|
export { default as List } from '@hi-ui/list';
|
60
60
|
export * from '@hi-ui/loading';
|
61
61
|
export { default as Loading } from '@hi-ui/loading';
|
62
|
-
export
|
63
|
-
export {
|
62
|
+
export { getLanguage, useLocaleContext } from './ui/locale-context/lib/esm/LocaleContext.js';
|
63
|
+
export { LocaleProvider as LocaleContext, LocaleProvider } from './ui/locale-context/lib/esm/LocaleProvider.js';
|
64
64
|
export * from '@hi-ui/menu';
|
65
65
|
export { default as Menu } from '@hi-ui/menu';
|
66
66
|
export * from '@hi-ui/message';
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/** @LICENSE
|
2
|
+
* @hi-ui/hiui
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
|
4
|
+
*
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
import { createContext, useContext } from 'react';
|
11
|
+
import { LocaleEnum } from './types.js';
|
12
|
+
import zhCN from './locale/zh-CN.js';
|
13
|
+
import { getNested } from '../../../../utils/object-utils/lib/esm/index.js';
|
14
|
+
import { invariant } from '../../../../utils/env/lib/esm/index.js';
|
15
|
+
/** @LICENSE
|
16
|
+
* @hi-ui/locale-context
|
17
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/locale-context#readme
|
18
|
+
*
|
19
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
20
|
+
*
|
21
|
+
* This source code is licensed under the MIT license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
|
25
|
+
var getLanguage = function getLanguage(languageData) {
|
26
|
+
return function (key, data) {
|
27
|
+
var value = getNested(languageData, key.split('.'));
|
28
|
+
invariant(!!value, "The " + key + " in language package is missing.");
|
29
|
+
|
30
|
+
if (data) {
|
31
|
+
Object.keys(data).forEach(function (key) {
|
32
|
+
value = value.replace("{{" + key + "}}", data[key]);
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
return value;
|
37
|
+
};
|
38
|
+
};
|
39
|
+
|
40
|
+
var LocaleContext = /*#__PURE__*/createContext(Object.assign(Object.assign({}, zhCN), {
|
41
|
+
locale: LocaleEnum.ZH_CN,
|
42
|
+
get: getLanguage(zhCN)
|
43
|
+
}));
|
44
|
+
|
45
|
+
var useLocaleContext = function useLocaleContext() {
|
46
|
+
var context = useContext(LocaleContext);
|
47
|
+
|
48
|
+
if (!context) {
|
49
|
+
throw new Error('The locale context should be wrapped by <LocaleContext locale={locale} /> in App.');
|
50
|
+
}
|
51
|
+
|
52
|
+
return context;
|
53
|
+
};
|
54
|
+
|
55
|
+
export { LocaleContext, getLanguage, useLocaleContext };
|