@tendaui/components 1.3.0 → 1.3.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.
- package/LICENSE +21 -21
- package/README.md +176 -176
- package/button/_example/ghost.tsx +2 -5
- package/color-picker/utils/color-picker/cmyk.ts +89 -89
- package/color-picker/utils/color-picker/color.ts +467 -467
- package/color-picker/utils/color-picker/constants.ts +187 -187
- package/color-picker/utils/color-picker/draggable.ts +99 -99
- package/color-picker/utils/color-picker/format.ts +90 -90
- package/color-picker/utils/color-picker/gradient.ts +237 -237
- package/color-picker/utils/color-picker/index.ts +7 -7
- package/color-picker/utils/color-picker/types.ts +33 -33
- package/dialog/hooks/useDialogPosition.ts +35 -35
- package/form/type.ts +519 -519
- package/global-config/default-config.ts +95 -95
- package/global-config/locale/ar_KW.ts +259 -259
- package/global-config/locale/en_US.ts +265 -265
- package/global-config/locale/it_IT.ts +264 -264
- package/global-config/locale/ja_JP.ts +264 -264
- package/global-config/locale/ko_KR.ts +264 -264
- package/global-config/locale/ru_RU.ts +277 -277
- package/global-config/locale/zh_CN.ts +265 -265
- package/global-config/locale/zh_TW.ts +265 -265
- package/global-config/mobile/default-config.ts +6 -6
- package/global-config/mobile/locale/ar_KW.ts +112 -112
- package/global-config/mobile/locale/en_US.ts +113 -113
- package/global-config/mobile/locale/it_IT.ts +113 -113
- package/global-config/mobile/locale/ja_JP.ts +100 -100
- package/global-config/mobile/locale/ko_KR.ts +100 -100
- package/global-config/mobile/locale/ru_RU.ts +112 -112
- package/global-config/mobile/locale/zh_CN.ts +100 -100
- package/global-config/mobile/locale/zh_TW.ts +100 -100
- package/global-config/t.ts +111 -111
- package/input-number/InputNumber.tsx +124 -124
- package/input-number/defaultProps.ts +17 -17
- package/input-number/index.ts +9 -9
- package/input-number/style/css.js +1 -1
- package/input-number/style/index.js +1 -1
- package/input-number/useInputNumber.tsx +270 -270
- package/list/ListItem.tsx +36 -36
- package/list/ListItemMeta.tsx +40 -40
- package/list/defaultProps.ts +11 -11
- package/list/hooks/useListVirtualScroll.ts +82 -82
- package/list/style/css.js +1 -1
- package/list/style/index.js +1 -1
- package/locale/LocalReceiver.ts +55 -55
- package/locale/ar_KW.ts +7 -7
- package/locale/en_US.ts +7 -7
- package/locale/it_IT.ts +6 -6
- package/locale/ja_JP.ts +6 -6
- package/locale/ko_KR.ts +6 -6
- package/locale/ru_RU.ts +6 -6
- package/locale/zh_CN.ts +5 -5
- package/locale/zh_TW.ts +7 -7
- package/package.json +2 -2
- package/radio/_example/default.tsx +2 -2
- package/select/type.ts +382 -382
- package/select-input/type.ts +280 -280
- package/slider/SliderHandleButton.tsx +50 -50
- package/slider/defaultProps.ts +15 -15
- package/slider/style/css.js +1 -1
- package/slider/style/index.js +1 -1
- package/styles/_global.scss +40 -40
- package/styles/_vars.scss +374 -374
- package/styles/components/alert/_index.scss +175 -175
- package/styles/components/alert/_vars.scss +41 -41
- package/styles/components/badge/_index.scss +71 -71
- package/styles/components/badge/_vars.scss +26 -26
- package/styles/components/button/_index.scss +499 -499
- package/styles/components/button/_mixins.scss +40 -40
- package/styles/components/button/_vars.scss +121 -121
- package/styles/components/checkbox/_index.scss +158 -158
- package/styles/components/checkbox/_var.scss +59 -59
- package/styles/components/color-picker/_index.scss +586 -586
- package/styles/components/color-picker/_vars.scss +79 -79
- package/styles/components/dialog/_animate.scss +133 -133
- package/styles/components/dialog/_index.scss +310 -310
- package/styles/components/dialog/_vars.scss +60 -60
- package/styles/components/drawer/_index.scss +206 -206
- package/styles/components/drawer/_var.scss +55 -55
- package/styles/components/fireworks/_index.scss +86 -86
- package/styles/components/fireworks/_vars.scss +5 -5
- package/styles/components/form/_index.scss +175 -175
- package/styles/components/form/_mixins.scss +74 -74
- package/styles/components/form/_vars.scss +101 -101
- package/styles/components/input/_index.scss +350 -350
- package/styles/components/input/_mixins.scss +120 -120
- package/styles/components/input/_vars.scss +130 -130
- package/styles/components/input-number/_index.scss +327 -327
- package/styles/components/input-number/_vars.scss +56 -56
- package/styles/components/ip-input/_index.scss +277 -277
- package/styles/components/layout/_index.scss +47 -47
- package/styles/components/layout/_vars.scss +19 -19
- package/styles/components/layout/doc.scss +74 -74
- package/styles/components/list/_index.scss +172 -172
- package/styles/components/list/_vars.scss +42 -42
- package/styles/components/loading/_index.scss +113 -113
- package/styles/components/loading/_vars.scss +40 -40
- package/styles/components/notification/_index.scss +140 -140
- package/styles/components/notification/_mixins.scss +13 -13
- package/styles/components/notification/_vars.scss +60 -60
- package/styles/components/popup/_index.scss +78 -78
- package/styles/components/popup/_mixin.scss +149 -149
- package/styles/components/popup/_vars.scss +33 -33
- package/styles/components/radio/_index.scss +376 -376
- package/styles/components/radio/_vars.scss +89 -89
- package/styles/components/select/_index.scss +291 -291
- package/styles/components/select/_var.scss +64 -64
- package/styles/components/select-input/_index.scss +5 -5
- package/styles/components/select-input/_var.scss +4 -4
- package/styles/components/slider/_index.scss +241 -241
- package/styles/components/slider/_vars.scss +51 -51
- package/styles/components/switch/_index.scss +175 -175
- package/styles/components/switch/_vars.scss +63 -63
- package/styles/components/table/_index.scss +194 -194
- package/styles/components/table/_var.scss +52 -52
- package/styles/components/tabs/_index.scss +165 -165
- package/styles/components/tabs/_mixins.scss +11 -11
- package/styles/components/tabs/_vars.scss +72 -72
- package/styles/components/tag/_index.scss +317 -317
- package/styles/components/tag/_var.scss +86 -86
- package/styles/components/tag-input/_index.scss +164 -164
- package/styles/components/tag-input/_vars.scss +17 -17
- package/styles/mixins/_focus.scss +8 -8
- package/styles/mixins/_layout.scss +32 -32
- package/styles/mixins/_reset.scss +11 -11
- package/styles/mixins/_scrollbar.scss +32 -32
- package/styles/mixins/_text.scss +50 -50
- package/styles/themes/_dark.scss +169 -169
- package/styles/themes/_font.scss +69 -69
- package/styles/themes/_index.scss +5 -5
- package/styles/themes/_light.scss +170 -170
- package/styles/themes/_radius.scss +9 -9
- package/styles/themes/_size.scss +68 -68
- package/styles/utilities/_animation.scss +58 -58
- package/styles/utilities/_tips.scss +10 -10
- package/switch/_example/with-label.tsx +1 -1
- package/utils/input-number/large-number.ts +423 -423
- package/utils/input-number/number.ts +257 -257
- package/utils/log/index.ts +3 -3
- package/utils/log/log.ts +29 -29
- package/utils/log/types.ts +9 -9
- package/utils/style.ts +58 -58
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
// 文件有效,为国际化做准备
|
|
2
|
-
import "dayjs/locale/zh-cn";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
actionSheet: {
|
|
6
|
-
cancel: "取消"
|
|
7
|
-
},
|
|
8
|
-
calendar: {
|
|
9
|
-
title: "请选择日期",
|
|
10
|
-
confirm: "确认",
|
|
11
|
-
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
12
|
-
monthTitle: "{year} 年 {month}",
|
|
13
|
-
months: ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"]
|
|
14
|
-
},
|
|
15
|
-
cascader: {
|
|
16
|
-
title: "标题",
|
|
17
|
-
placeholder: "选择选项"
|
|
18
|
-
},
|
|
19
|
-
dropdownMenu: {
|
|
20
|
-
reset: "重置",
|
|
21
|
-
confirm: "确定"
|
|
22
|
-
},
|
|
23
|
-
dateTimePicker: {
|
|
24
|
-
title: "选择时间",
|
|
25
|
-
cancel: "取消",
|
|
26
|
-
confirm: "确定",
|
|
27
|
-
format: "YYYY-MM-DD",
|
|
28
|
-
yearLabel: "年",
|
|
29
|
-
monthLabel: "月",
|
|
30
|
-
dateLabel: "日",
|
|
31
|
-
hourLabel: "时",
|
|
32
|
-
minuteLabel: "分",
|
|
33
|
-
secondLabel: "秒"
|
|
34
|
-
},
|
|
35
|
-
form: {
|
|
36
|
-
errorMessage: {
|
|
37
|
-
date: "请输入正确的${name}",
|
|
38
|
-
url: "请输入正确的${name}",
|
|
39
|
-
required: "${name}必填",
|
|
40
|
-
whitespace: "${name}不能为空",
|
|
41
|
-
max: "${name}字符长度不能超过 ${validate} 个字符,一个中文等于两个字符",
|
|
42
|
-
min: "${name}字符长度不能少于 ${validate} 个字符,一个中文等于两个字符",
|
|
43
|
-
len: "${name}字符长度必须是 ${validate}",
|
|
44
|
-
enum: "${name}只能是${validate}等",
|
|
45
|
-
idcard: "请输入正确的${name}",
|
|
46
|
-
telnumber: "请输入正确的${name}",
|
|
47
|
-
pattern: "请输入正确的${name}",
|
|
48
|
-
validator: "${name}不符合要求",
|
|
49
|
-
boolean: "${name}数据类型必须是布尔类型",
|
|
50
|
-
number: "${name}必须是数字"
|
|
51
|
-
},
|
|
52
|
-
colonText: ":"
|
|
53
|
-
},
|
|
54
|
-
picker: {
|
|
55
|
-
cancel: "取消",
|
|
56
|
-
confirm: "确认"
|
|
57
|
-
},
|
|
58
|
-
pullDownRefresh: {
|
|
59
|
-
loadingTexts: ["下拉刷新", "松手刷新", "正在刷新", "刷新完成"]
|
|
60
|
-
},
|
|
61
|
-
rate: {
|
|
62
|
-
valueText: "{value} 分",
|
|
63
|
-
noValueText: "未评分"
|
|
64
|
-
},
|
|
65
|
-
tabBar: {
|
|
66
|
-
newsAriaLabel: "有新的消息",
|
|
67
|
-
moreNewsAriaLabel: "有很多消息",
|
|
68
|
-
haveMoreNewsAriaLabel: "有 {value}+ 条消息",
|
|
69
|
-
haveNewsAriaLabel: "有 {value} 条消息"
|
|
70
|
-
},
|
|
71
|
-
table: {
|
|
72
|
-
empty: "暂无数据"
|
|
73
|
-
},
|
|
74
|
-
list: {
|
|
75
|
-
loading: "加载中...",
|
|
76
|
-
loadingMoreText: "点击加载更多",
|
|
77
|
-
pulling: "下拉即可刷新...",
|
|
78
|
-
loosing: "释放即可刷新...",
|
|
79
|
-
success: "刷新成功"
|
|
80
|
-
},
|
|
81
|
-
upload: {
|
|
82
|
-
progress: {
|
|
83
|
-
uploadingText: "上传中...",
|
|
84
|
-
waitingText: "待上传",
|
|
85
|
-
failText: "上传失败",
|
|
86
|
-
successText: "上传成功"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
guide: {
|
|
90
|
-
next: "下一步",
|
|
91
|
-
skip: "跳过",
|
|
92
|
-
finish: "完成",
|
|
93
|
-
back: "返回"
|
|
94
|
-
},
|
|
95
|
-
qrcode: {
|
|
96
|
-
expiredText: "二维码过期",
|
|
97
|
-
refreshText: "点击刷新",
|
|
98
|
-
scannedText: "已扫描"
|
|
99
|
-
}
|
|
100
|
-
};
|
|
1
|
+
// 文件有效,为国际化做准备
|
|
2
|
+
import "dayjs/locale/zh-cn";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
actionSheet: {
|
|
6
|
+
cancel: "取消"
|
|
7
|
+
},
|
|
8
|
+
calendar: {
|
|
9
|
+
title: "请选择日期",
|
|
10
|
+
confirm: "确认",
|
|
11
|
+
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
12
|
+
monthTitle: "{year} 年 {month}",
|
|
13
|
+
months: ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"]
|
|
14
|
+
},
|
|
15
|
+
cascader: {
|
|
16
|
+
title: "标题",
|
|
17
|
+
placeholder: "选择选项"
|
|
18
|
+
},
|
|
19
|
+
dropdownMenu: {
|
|
20
|
+
reset: "重置",
|
|
21
|
+
confirm: "确定"
|
|
22
|
+
},
|
|
23
|
+
dateTimePicker: {
|
|
24
|
+
title: "选择时间",
|
|
25
|
+
cancel: "取消",
|
|
26
|
+
confirm: "确定",
|
|
27
|
+
format: "YYYY-MM-DD",
|
|
28
|
+
yearLabel: "年",
|
|
29
|
+
monthLabel: "月",
|
|
30
|
+
dateLabel: "日",
|
|
31
|
+
hourLabel: "时",
|
|
32
|
+
minuteLabel: "分",
|
|
33
|
+
secondLabel: "秒"
|
|
34
|
+
},
|
|
35
|
+
form: {
|
|
36
|
+
errorMessage: {
|
|
37
|
+
date: "请输入正确的${name}",
|
|
38
|
+
url: "请输入正确的${name}",
|
|
39
|
+
required: "${name}必填",
|
|
40
|
+
whitespace: "${name}不能为空",
|
|
41
|
+
max: "${name}字符长度不能超过 ${validate} 个字符,一个中文等于两个字符",
|
|
42
|
+
min: "${name}字符长度不能少于 ${validate} 个字符,一个中文等于两个字符",
|
|
43
|
+
len: "${name}字符长度必须是 ${validate}",
|
|
44
|
+
enum: "${name}只能是${validate}等",
|
|
45
|
+
idcard: "请输入正确的${name}",
|
|
46
|
+
telnumber: "请输入正确的${name}",
|
|
47
|
+
pattern: "请输入正确的${name}",
|
|
48
|
+
validator: "${name}不符合要求",
|
|
49
|
+
boolean: "${name}数据类型必须是布尔类型",
|
|
50
|
+
number: "${name}必须是数字"
|
|
51
|
+
},
|
|
52
|
+
colonText: ":"
|
|
53
|
+
},
|
|
54
|
+
picker: {
|
|
55
|
+
cancel: "取消",
|
|
56
|
+
confirm: "确认"
|
|
57
|
+
},
|
|
58
|
+
pullDownRefresh: {
|
|
59
|
+
loadingTexts: ["下拉刷新", "松手刷新", "正在刷新", "刷新完成"]
|
|
60
|
+
},
|
|
61
|
+
rate: {
|
|
62
|
+
valueText: "{value} 分",
|
|
63
|
+
noValueText: "未评分"
|
|
64
|
+
},
|
|
65
|
+
tabBar: {
|
|
66
|
+
newsAriaLabel: "有新的消息",
|
|
67
|
+
moreNewsAriaLabel: "有很多消息",
|
|
68
|
+
haveMoreNewsAriaLabel: "有 {value}+ 条消息",
|
|
69
|
+
haveNewsAriaLabel: "有 {value} 条消息"
|
|
70
|
+
},
|
|
71
|
+
table: {
|
|
72
|
+
empty: "暂无数据"
|
|
73
|
+
},
|
|
74
|
+
list: {
|
|
75
|
+
loading: "加载中...",
|
|
76
|
+
loadingMoreText: "点击加载更多",
|
|
77
|
+
pulling: "下拉即可刷新...",
|
|
78
|
+
loosing: "释放即可刷新...",
|
|
79
|
+
success: "刷新成功"
|
|
80
|
+
},
|
|
81
|
+
upload: {
|
|
82
|
+
progress: {
|
|
83
|
+
uploadingText: "上传中...",
|
|
84
|
+
waitingText: "待上传",
|
|
85
|
+
failText: "上传失败",
|
|
86
|
+
successText: "上传成功"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
guide: {
|
|
90
|
+
next: "下一步",
|
|
91
|
+
skip: "跳过",
|
|
92
|
+
finish: "完成",
|
|
93
|
+
back: "返回"
|
|
94
|
+
},
|
|
95
|
+
qrcode: {
|
|
96
|
+
expiredText: "二维码过期",
|
|
97
|
+
refreshText: "点击刷新",
|
|
98
|
+
scannedText: "已扫描"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
// 文件有效,为国际化做准备
|
|
2
|
-
import "dayjs/locale/zh-tw";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
actionSheet: {
|
|
6
|
-
cancel: "取消"
|
|
7
|
-
},
|
|
8
|
-
calendar: {
|
|
9
|
-
title: "請選擇日期",
|
|
10
|
-
confirm: "確認",
|
|
11
|
-
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
12
|
-
monthTitle: "{year} 年 {month}",
|
|
13
|
-
months: ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"]
|
|
14
|
-
},
|
|
15
|
-
cascader: {
|
|
16
|
-
title: "標題",
|
|
17
|
-
placeholder: "選擇選項"
|
|
18
|
-
},
|
|
19
|
-
dropdownMenu: {
|
|
20
|
-
reset: "重置",
|
|
21
|
-
confirm: "確定"
|
|
22
|
-
},
|
|
23
|
-
dateTimePicker: {
|
|
24
|
-
title: "選擇時間",
|
|
25
|
-
cancel: "取消",
|
|
26
|
-
confirm: "確定",
|
|
27
|
-
format: "YYYY-MM-DD",
|
|
28
|
-
yearLabel: "年",
|
|
29
|
-
monthLabel: "月",
|
|
30
|
-
dateLabel: "日",
|
|
31
|
-
hourLabel: "時",
|
|
32
|
-
minuteLabel: "分",
|
|
33
|
-
secondLabel: "秒"
|
|
34
|
-
},
|
|
35
|
-
form: {
|
|
36
|
-
errorMessage: {
|
|
37
|
-
date: "請輸入正確的${name}",
|
|
38
|
-
url: "請輸入正確的${name}",
|
|
39
|
-
whitespace: "${name}不能為空",
|
|
40
|
-
required: "${name}必填",
|
|
41
|
-
max: "${name}字符長度不能超過 ${validate} 個字符,一個中文等於兩個字符",
|
|
42
|
-
min: "${name}字符長度不能少於 ${validate} 個字符,一個中文等於兩個字符",
|
|
43
|
-
len: "${name}字符長度必須是 ${validate}",
|
|
44
|
-
enum: "${name}只能是${validate}等",
|
|
45
|
-
idcard: "請輸入正確的${name}",
|
|
46
|
-
telnumber: "請輸入正確的${name}",
|
|
47
|
-
pattern: "請輸入正確的${name}",
|
|
48
|
-
validator: "${name}不符合要求",
|
|
49
|
-
boolean: "${name}數據類型必須是布林類型",
|
|
50
|
-
number: "${name}必須是數字"
|
|
51
|
-
},
|
|
52
|
-
colonText: ":"
|
|
53
|
-
},
|
|
54
|
-
picker: {
|
|
55
|
-
cancel: "取消",
|
|
56
|
-
confirm: "確認"
|
|
57
|
-
},
|
|
58
|
-
pullDownRefresh: {
|
|
59
|
-
loadingTexts: ["下拉刷新", "鬆手刷新", "正在刷新", "刷新完成"]
|
|
60
|
-
},
|
|
61
|
-
rate: {
|
|
62
|
-
valueText: "{value} 分",
|
|
63
|
-
noValueText: "未評分"
|
|
64
|
-
},
|
|
65
|
-
tabBar: {
|
|
66
|
-
newsAriaLabel: "有新消息",
|
|
67
|
-
moreNewsAriaLabel: "有很多消息",
|
|
68
|
-
haveMoreNewsAriaLabel: "有 {value}+ 條消息",
|
|
69
|
-
haveNewsAriaLabel: "有 {value} 條消息"
|
|
70
|
-
},
|
|
71
|
-
table: {
|
|
72
|
-
empty: "暫無數據"
|
|
73
|
-
},
|
|
74
|
-
list: {
|
|
75
|
-
loading: "加載中...",
|
|
76
|
-
loadingMoreText: "點擊加載更多",
|
|
77
|
-
pulling: "下拉即可刷新...",
|
|
78
|
-
loosing: "釋放即可刷新...",
|
|
79
|
-
success: "刷新成功"
|
|
80
|
-
},
|
|
81
|
-
upload: {
|
|
82
|
-
progress: {
|
|
83
|
-
uploadingText: "上傳中...",
|
|
84
|
-
waitingText: "待上傳",
|
|
85
|
-
failText: "上傳失敗",
|
|
86
|
-
successText: "上傳成功"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
guide: {
|
|
90
|
-
next: "下一步",
|
|
91
|
-
skip: "跳過",
|
|
92
|
-
finish: "完成",
|
|
93
|
-
back: "返回"
|
|
94
|
-
},
|
|
95
|
-
qrcode: {
|
|
96
|
-
expiredText: "二維碼過期",
|
|
97
|
-
refreshText: "點擊刷新",
|
|
98
|
-
scannedText: "已掃描"
|
|
99
|
-
}
|
|
100
|
-
};
|
|
1
|
+
// 文件有效,为国际化做准备
|
|
2
|
+
import "dayjs/locale/zh-tw";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
actionSheet: {
|
|
6
|
+
cancel: "取消"
|
|
7
|
+
},
|
|
8
|
+
calendar: {
|
|
9
|
+
title: "請選擇日期",
|
|
10
|
+
confirm: "確認",
|
|
11
|
+
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
12
|
+
monthTitle: "{year} 年 {month}",
|
|
13
|
+
months: ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"]
|
|
14
|
+
},
|
|
15
|
+
cascader: {
|
|
16
|
+
title: "標題",
|
|
17
|
+
placeholder: "選擇選項"
|
|
18
|
+
},
|
|
19
|
+
dropdownMenu: {
|
|
20
|
+
reset: "重置",
|
|
21
|
+
confirm: "確定"
|
|
22
|
+
},
|
|
23
|
+
dateTimePicker: {
|
|
24
|
+
title: "選擇時間",
|
|
25
|
+
cancel: "取消",
|
|
26
|
+
confirm: "確定",
|
|
27
|
+
format: "YYYY-MM-DD",
|
|
28
|
+
yearLabel: "年",
|
|
29
|
+
monthLabel: "月",
|
|
30
|
+
dateLabel: "日",
|
|
31
|
+
hourLabel: "時",
|
|
32
|
+
minuteLabel: "分",
|
|
33
|
+
secondLabel: "秒"
|
|
34
|
+
},
|
|
35
|
+
form: {
|
|
36
|
+
errorMessage: {
|
|
37
|
+
date: "請輸入正確的${name}",
|
|
38
|
+
url: "請輸入正確的${name}",
|
|
39
|
+
whitespace: "${name}不能為空",
|
|
40
|
+
required: "${name}必填",
|
|
41
|
+
max: "${name}字符長度不能超過 ${validate} 個字符,一個中文等於兩個字符",
|
|
42
|
+
min: "${name}字符長度不能少於 ${validate} 個字符,一個中文等於兩個字符",
|
|
43
|
+
len: "${name}字符長度必須是 ${validate}",
|
|
44
|
+
enum: "${name}只能是${validate}等",
|
|
45
|
+
idcard: "請輸入正確的${name}",
|
|
46
|
+
telnumber: "請輸入正確的${name}",
|
|
47
|
+
pattern: "請輸入正確的${name}",
|
|
48
|
+
validator: "${name}不符合要求",
|
|
49
|
+
boolean: "${name}數據類型必須是布林類型",
|
|
50
|
+
number: "${name}必須是數字"
|
|
51
|
+
},
|
|
52
|
+
colonText: ":"
|
|
53
|
+
},
|
|
54
|
+
picker: {
|
|
55
|
+
cancel: "取消",
|
|
56
|
+
confirm: "確認"
|
|
57
|
+
},
|
|
58
|
+
pullDownRefresh: {
|
|
59
|
+
loadingTexts: ["下拉刷新", "鬆手刷新", "正在刷新", "刷新完成"]
|
|
60
|
+
},
|
|
61
|
+
rate: {
|
|
62
|
+
valueText: "{value} 分",
|
|
63
|
+
noValueText: "未評分"
|
|
64
|
+
},
|
|
65
|
+
tabBar: {
|
|
66
|
+
newsAriaLabel: "有新消息",
|
|
67
|
+
moreNewsAriaLabel: "有很多消息",
|
|
68
|
+
haveMoreNewsAriaLabel: "有 {value}+ 條消息",
|
|
69
|
+
haveNewsAriaLabel: "有 {value} 條消息"
|
|
70
|
+
},
|
|
71
|
+
table: {
|
|
72
|
+
empty: "暫無數據"
|
|
73
|
+
},
|
|
74
|
+
list: {
|
|
75
|
+
loading: "加載中...",
|
|
76
|
+
loadingMoreText: "點擊加載更多",
|
|
77
|
+
pulling: "下拉即可刷新...",
|
|
78
|
+
loosing: "釋放即可刷新...",
|
|
79
|
+
success: "刷新成功"
|
|
80
|
+
},
|
|
81
|
+
upload: {
|
|
82
|
+
progress: {
|
|
83
|
+
uploadingText: "上傳中...",
|
|
84
|
+
waitingText: "待上傳",
|
|
85
|
+
failText: "上傳失敗",
|
|
86
|
+
successText: "上傳成功"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
guide: {
|
|
90
|
+
next: "下一步",
|
|
91
|
+
skip: "跳過",
|
|
92
|
+
finish: "完成",
|
|
93
|
+
back: "返回"
|
|
94
|
+
},
|
|
95
|
+
qrcode: {
|
|
96
|
+
expiredText: "二維碼過期",
|
|
97
|
+
refreshText: "點擊刷新",
|
|
98
|
+
scannedText: "已掃描"
|
|
99
|
+
}
|
|
100
|
+
};
|
package/global-config/t.ts
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { isString } from "lodash-es";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 复数规则判断函数
|
|
5
|
-
* @param count 数量
|
|
6
|
-
* @returns 返回复数形式的索引 (0: zero/none, 1: one, 2: other/many)
|
|
7
|
-
*/
|
|
8
|
-
function getPluralIndex(count: number): number {
|
|
9
|
-
if (count === 0) return 0; // no items
|
|
10
|
-
if (count === 1) return 1; // one item
|
|
11
|
-
return 2; // multiple items
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @see https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/config-provider/hooks/useConfig.ts#L48
|
|
16
|
-
* 自定义 t function 可能依赖特定库函数,例如 tdesign-vue-next 中使用了 vue 的 h 函数
|
|
17
|
-
* 因此交由各个类库自行实现
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 国际化函数,支持复数处理和变量替换
|
|
22
|
-
*
|
|
23
|
-
* 示例用法:
|
|
24
|
-
* 1. 基本变量替换:
|
|
25
|
-
* t('Hello {name}', { name: 'World' }) // => 'Hello World'
|
|
26
|
-
*
|
|
27
|
-
* 2. 复数处理(传入数字):
|
|
28
|
-
* t('no apples | one apple | {count} apples', 0) // => 'no apples'
|
|
29
|
-
* t('no apples | one apple | {count} apples', 1) // => 'one apple'
|
|
30
|
-
* t('no apples | one apple | {count} apples', 5) // => '5 apples'
|
|
31
|
-
*
|
|
32
|
-
* 3. 复合使用:
|
|
33
|
-
* t('no items found | found {count} item | found {count} items', 3, { count: 3 }) // => 'found 3 items'
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
// 类型重载定义
|
|
37
|
-
export function t(pattern: string): string;
|
|
38
|
-
export function t(pattern: string, data: Record<string, any>): string;
|
|
39
|
-
export function t(pattern: string, count: number): string;
|
|
40
|
-
export function t(pattern: string, count: number, data: Record<string, any>): string;
|
|
41
|
-
export function t<T>(pattern: T): string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param pattern 文本模式,可以是字符串、函数或其他类型
|
|
45
|
-
* @param args 参数列表,支持 (count: number) 或 (count: number, data: object) 或 (data: object)
|
|
46
|
-
* @returns 处理后的文本
|
|
47
|
-
*/
|
|
48
|
-
export function t<T>(pattern: T, ...args: any[]): string {
|
|
49
|
-
if (isString(pattern)) {
|
|
50
|
-
let text = pattern as string;
|
|
51
|
-
let count: number | undefined;
|
|
52
|
-
let data: Record<string, any> = {};
|
|
53
|
-
|
|
54
|
-
// 解析参数
|
|
55
|
-
if (args.length > 0) {
|
|
56
|
-
const [firstArg, secondArg] = args;
|
|
57
|
-
|
|
58
|
-
if (typeof firstArg === "number") {
|
|
59
|
-
// 第一个参数是数字,表示 count
|
|
60
|
-
count = firstArg;
|
|
61
|
-
if (secondArg && typeof secondArg === "object") {
|
|
62
|
-
// 第二个参数是对象,表示额外的数据
|
|
63
|
-
data = secondArg;
|
|
64
|
-
} else {
|
|
65
|
-
data.count = count; // 若没有提供第二个参数,则将 count 添加到数据中
|
|
66
|
-
}
|
|
67
|
-
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
68
|
-
// 第一个参数是对象,表示数据
|
|
69
|
-
data = firstArg;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 处理复数形式:支持 "no items | one item | {count} items" 格式
|
|
74
|
-
if (text.includes("|")) {
|
|
75
|
-
const pluralParts = text.split("|").map((part) => part.trim());
|
|
76
|
-
|
|
77
|
-
if (typeof count === "number") {
|
|
78
|
-
// 使用 count 进行复数处理
|
|
79
|
-
const pluralIndex = getPluralIndex(count);
|
|
80
|
-
|
|
81
|
-
// 根据复数索引选择对应的文本
|
|
82
|
-
if (pluralIndex < pluralParts.length) {
|
|
83
|
-
text = pluralParts[pluralIndex];
|
|
84
|
-
} else {
|
|
85
|
-
// 如果索引超出范围,使用最后一个选项
|
|
86
|
-
text = pluralParts[pluralParts.length - 1];
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
// 如果没有 count,默认使用第一个选项
|
|
90
|
-
const [firstPart] = pluralParts;
|
|
91
|
-
text = firstPart;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 处理变量替换:{key} 格式
|
|
96
|
-
if (data && Object.keys(data).length > 0) {
|
|
97
|
-
const regular = /\{\s*([\w-]+)\s*\}/g;
|
|
98
|
-
text = text.replace(regular, (match, key) => {
|
|
99
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
100
|
-
return String(data[key]);
|
|
101
|
-
}
|
|
102
|
-
return match; // 如果找不到对应的键,保留原始占位符
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return text as any;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 如果不是字符串或函数,返回空字符串
|
|
110
|
-
return "";
|
|
111
|
-
}
|
|
1
|
+
import { isString } from "lodash-es";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 复数规则判断函数
|
|
5
|
+
* @param count 数量
|
|
6
|
+
* @returns 返回复数形式的索引 (0: zero/none, 1: one, 2: other/many)
|
|
7
|
+
*/
|
|
8
|
+
function getPluralIndex(count: number): number {
|
|
9
|
+
if (count === 0) return 0; // no items
|
|
10
|
+
if (count === 1) return 1; // one item
|
|
11
|
+
return 2; // multiple items
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @see https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/config-provider/hooks/useConfig.ts#L48
|
|
16
|
+
* 自定义 t function 可能依赖特定库函数,例如 tdesign-vue-next 中使用了 vue 的 h 函数
|
|
17
|
+
* 因此交由各个类库自行实现
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 国际化函数,支持复数处理和变量替换
|
|
22
|
+
*
|
|
23
|
+
* 示例用法:
|
|
24
|
+
* 1. 基本变量替换:
|
|
25
|
+
* t('Hello {name}', { name: 'World' }) // => 'Hello World'
|
|
26
|
+
*
|
|
27
|
+
* 2. 复数处理(传入数字):
|
|
28
|
+
* t('no apples | one apple | {count} apples', 0) // => 'no apples'
|
|
29
|
+
* t('no apples | one apple | {count} apples', 1) // => 'one apple'
|
|
30
|
+
* t('no apples | one apple | {count} apples', 5) // => '5 apples'
|
|
31
|
+
*
|
|
32
|
+
* 3. 复合使用:
|
|
33
|
+
* t('no items found | found {count} item | found {count} items', 3, { count: 3 }) // => 'found 3 items'
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// 类型重载定义
|
|
37
|
+
export function t(pattern: string): string;
|
|
38
|
+
export function t(pattern: string, data: Record<string, any>): string;
|
|
39
|
+
export function t(pattern: string, count: number): string;
|
|
40
|
+
export function t(pattern: string, count: number, data: Record<string, any>): string;
|
|
41
|
+
export function t<T>(pattern: T): string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param pattern 文本模式,可以是字符串、函数或其他类型
|
|
45
|
+
* @param args 参数列表,支持 (count: number) 或 (count: number, data: object) 或 (data: object)
|
|
46
|
+
* @returns 处理后的文本
|
|
47
|
+
*/
|
|
48
|
+
export function t<T>(pattern: T, ...args: any[]): string {
|
|
49
|
+
if (isString(pattern)) {
|
|
50
|
+
let text = pattern as string;
|
|
51
|
+
let count: number | undefined;
|
|
52
|
+
let data: Record<string, any> = {};
|
|
53
|
+
|
|
54
|
+
// 解析参数
|
|
55
|
+
if (args.length > 0) {
|
|
56
|
+
const [firstArg, secondArg] = args;
|
|
57
|
+
|
|
58
|
+
if (typeof firstArg === "number") {
|
|
59
|
+
// 第一个参数是数字,表示 count
|
|
60
|
+
count = firstArg;
|
|
61
|
+
if (secondArg && typeof secondArg === "object") {
|
|
62
|
+
// 第二个参数是对象,表示额外的数据
|
|
63
|
+
data = secondArg;
|
|
64
|
+
} else {
|
|
65
|
+
data.count = count; // 若没有提供第二个参数,则将 count 添加到数据中
|
|
66
|
+
}
|
|
67
|
+
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
68
|
+
// 第一个参数是对象,表示数据
|
|
69
|
+
data = firstArg;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 处理复数形式:支持 "no items | one item | {count} items" 格式
|
|
74
|
+
if (text.includes("|")) {
|
|
75
|
+
const pluralParts = text.split("|").map((part) => part.trim());
|
|
76
|
+
|
|
77
|
+
if (typeof count === "number") {
|
|
78
|
+
// 使用 count 进行复数处理
|
|
79
|
+
const pluralIndex = getPluralIndex(count);
|
|
80
|
+
|
|
81
|
+
// 根据复数索引选择对应的文本
|
|
82
|
+
if (pluralIndex < pluralParts.length) {
|
|
83
|
+
text = pluralParts[pluralIndex];
|
|
84
|
+
} else {
|
|
85
|
+
// 如果索引超出范围,使用最后一个选项
|
|
86
|
+
text = pluralParts[pluralParts.length - 1];
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// 如果没有 count,默认使用第一个选项
|
|
90
|
+
const [firstPart] = pluralParts;
|
|
91
|
+
text = firstPart;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 处理变量替换:{key} 格式
|
|
96
|
+
if (data && Object.keys(data).length > 0) {
|
|
97
|
+
const regular = /\{\s*([\w-]+)\s*\}/g;
|
|
98
|
+
text = text.replace(regular, (match, key) => {
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
100
|
+
return String(data[key]);
|
|
101
|
+
}
|
|
102
|
+
return match; // 如果找不到对应的键,保留原始占位符
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return text as any;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 如果不是字符串或函数,返回空字符串
|
|
110
|
+
return "";
|
|
111
|
+
}
|