mdui 2.0.5 → 2.1.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/components/avatar/index.js +2 -7
- package/components/avatar/style.js +1 -31
- package/components/badge/style.js +1 -25
- package/components/bottom-app-bar/style.js +1 -92
- package/components/button/button-base-style.js +1 -28
- package/components/button/button-base.js +1 -8
- package/components/button/index.js +8 -18
- package/components/button/style.js +2 -111
- package/components/button-icon/index.js +5 -22
- package/components/button-icon/style.js +2 -103
- package/components/card/index.js +1 -5
- package/components/card/style.js +1 -72
- package/components/checkbox/index.js +7 -50
- package/components/checkbox/style.js +1 -131
- package/components/chip/index.js +9 -33
- package/components/chip/style.js +2 -205
- package/components/circular-progress/index.js +5 -39
- package/components/circular-progress/style.js +1 -136
- package/components/collapse/collapse-item-style.js +1 -21
- package/components/collapse/collapse-item.js +2 -10
- package/components/collapse/collapse-style.js +1 -5
- package/components/collapse/collapse.js +1 -4
- package/components/dialog/index.js +10 -35
- package/components/dialog/style.js +1 -116
- package/components/divider/style.js +1 -18
- package/components/dropdown/index.js +1 -8
- package/components/dropdown/style.js +1 -11
- package/components/fab/index.js +5 -13
- package/components/fab/style.js +4 -153
- package/components/icon/index.js +1 -5
- package/components/icon/style.js +1 -29
- package/components/layout/layout-item-style.js +1 -6
- package/components/layout/layout-main-style.js +1 -7
- package/components/layout/layout-style.js +1 -11
- package/components/linear-progress/index.js +2 -6
- package/components/linear-progress/style.js +1 -73
- package/components/list/list-item-style.js +2 -153
- package/components/list/list-item.js +8 -27
- package/components/list/list-style.js +1 -10
- package/components/list/list-subheader-style.js +1 -19
- package/components/menu/menu-item-style.js +1 -125
- package/components/menu/menu-item.js +13 -55
- package/components/menu/menu-style.js +1 -19
- package/components/menu/menu.js +1 -5
- package/components/navigation-bar/navigation-bar-item-style.js +1 -132
- package/components/navigation-bar/navigation-bar-item.js +7 -23
- package/components/navigation-bar/navigation-bar-style.js +1 -28
- package/components/navigation-bar/navigation-bar.js +1 -4
- package/components/navigation-drawer/index.js +1 -12
- package/components/navigation-drawer/style.js +1 -66
- package/components/navigation-rail/navigation-rail-item-style.js +1 -122
- package/components/navigation-rail/navigation-rail-item.js +7 -26
- package/components/navigation-rail/navigation-rail-style.js +1 -79
- package/components/navigation-rail/navigation-rail.js +1 -10
- package/components/radio/radio-group-style.js +1 -20
- package/components/radio/radio-group.js +1 -19
- package/components/radio/radio-style.js +1 -107
- package/components/radio/radio.js +5 -23
- package/components/range-slider/index.d.ts +1 -1
- package/components/range-slider/index.js +5 -53
- package/components/ripple/index.js +2 -5
- package/components/ripple/style.js +1 -96
- package/components/segmented-button/segmented-button-group-style.js +1 -28
- package/components/segmented-button/segmented-button-group.js +1 -21
- package/components/segmented-button/segmented-button-style.js +2 -81
- package/components/segmented-button/segmented-button.js +11 -27
- package/components/select/index.d.ts +18 -0
- package/components/select/index.js +42 -87
- package/components/select/style.js +1 -27
- package/components/slider/index.js +2 -33
- package/components/slider/slider-base-style.js +1 -173
- package/components/slider/slider-base.js +1 -6
- package/components/slider/style.js +1 -7
- package/components/snackbar/index.js +5 -32
- package/components/snackbar/style.js +1 -100
- package/components/switch/index.js +6 -40
- package/components/switch/style.js +1 -202
- package/components/tabs/tab-panel-style.js +1 -10
- package/components/tabs/tab-style.js +1 -85
- package/components/tabs/tab.js +4 -24
- package/components/tabs/tabs-style.js +1 -138
- package/components/tabs/tabs.js +1 -9
- package/components/text-field/index.d.ts +2 -0
- package/components/text-field/index.js +58 -163
- package/components/text-field/style.js +1 -362
- package/components/tooltip/index.js +1 -10
- package/components/tooltip/style.js +1 -57
- package/components/top-app-bar/top-app-bar-style.js +1 -78
- package/components/top-app-bar/top-app-bar-title-style.js +1 -81
- package/components/top-app-bar/top-app-bar-title.js +3 -17
- package/custom-elements.json +1194 -1099
- package/functions/alert.d.ts +2 -0
- package/functions/alert.js +19 -4
- package/functions/confirm.d.ts +4 -0
- package/functions/confirm.js +33 -6
- package/functions/getLocale.d.ts +6 -0
- package/functions/getLocale.js +11 -0
- package/functions/getTheme.d.ts +1 -1
- package/functions/loadLocale.d.ts +6 -0
- package/functions/loadLocale.js +8 -0
- package/functions/prompt.d.ts +4 -0
- package/functions/prompt.js +35 -8
- package/functions/removeColorScheme.js +1 -1
- package/functions/setColorScheme.d.ts +1 -1
- package/functions/setColorScheme.js +1 -1
- package/functions/setLocale.d.ts +6 -0
- package/functions/setLocale.js +11 -0
- package/functions/setTheme.d.ts +1 -1
- package/internal/localeCodes.d.ts +13 -0
- package/internal/localeCodes.js +144 -0
- package/internal/localize.d.ts +32 -0
- package/internal/localize.js +55 -0
- package/locales/ar-eg.d.ts +8 -0
- package/locales/ar-eg.js +12 -0
- package/locales/az-az.d.ts +8 -0
- package/locales/az-az.js +12 -0
- package/locales/be-by.d.ts +8 -0
- package/locales/be-by.js +12 -0
- package/locales/bg-bg.d.ts +8 -0
- package/locales/bg-bg.js +12 -0
- package/locales/bn-bd.d.ts +8 -0
- package/locales/bn-bd.js +12 -0
- package/locales/ca-es.d.ts +8 -0
- package/locales/ca-es.js +12 -0
- package/locales/cs-cz.d.ts +8 -0
- package/locales/cs-cz.js +12 -0
- package/locales/da-dk.d.ts +8 -0
- package/locales/da-dk.js +12 -0
- package/locales/de-de.d.ts +8 -0
- package/locales/de-de.js +12 -0
- package/locales/el-gr.d.ts +8 -0
- package/locales/el-gr.js +12 -0
- package/locales/en-gb.d.ts +8 -0
- package/locales/en-gb.js +12 -0
- package/locales/es-es.d.ts +8 -0
- package/locales/es-es.js +12 -0
- package/locales/et-ee.d.ts +8 -0
- package/locales/et-ee.js +12 -0
- package/locales/fa-ir.d.ts +8 -0
- package/locales/fa-ir.js +12 -0
- package/locales/fi-fi.d.ts +8 -0
- package/locales/fi-fi.js +12 -0
- package/locales/fr-be.d.ts +8 -0
- package/locales/fr-be.js +12 -0
- package/locales/fr-ca.d.ts +8 -0
- package/locales/fr-ca.js +12 -0
- package/locales/fr-fr.d.ts +8 -0
- package/locales/fr-fr.js +12 -0
- package/locales/ga-ie.d.ts +8 -0
- package/locales/ga-ie.js +12 -0
- package/locales/gl-es.d.ts +8 -0
- package/locales/gl-es.js +12 -0
- package/locales/he-il.d.ts +8 -0
- package/locales/he-il.js +12 -0
- package/locales/hi-in.d.ts +8 -0
- package/locales/hi-in.js +12 -0
- package/locales/hr-hr.d.ts +8 -0
- package/locales/hr-hr.js +12 -0
- package/locales/hu-hu.d.ts +8 -0
- package/locales/hu-hu.js +12 -0
- package/locales/hy-am.d.ts +8 -0
- package/locales/hy-am.js +12 -0
- package/locales/id-id.d.ts +8 -0
- package/locales/id-id.js +12 -0
- package/locales/is-is.d.ts +8 -0
- package/locales/is-is.js +12 -0
- package/locales/it-it.d.ts +8 -0
- package/locales/it-it.js +12 -0
- package/locales/ja-jp.d.ts +8 -0
- package/locales/ja-jp.js +12 -0
- package/locales/ka-ge.d.ts +8 -0
- package/locales/ka-ge.js +12 -0
- package/locales/kk-kz.d.ts +8 -0
- package/locales/kk-kz.js +12 -0
- package/locales/km-kh.d.ts +8 -0
- package/locales/km-kh.js +12 -0
- package/locales/kmr-iq.d.ts +8 -0
- package/locales/kmr-iq.js +12 -0
- package/locales/kn-in.d.ts +8 -0
- package/locales/kn-in.js +12 -0
- package/locales/ko-kr.d.ts +8 -0
- package/locales/ko-kr.js +12 -0
- package/locales/lt-lt.d.ts +8 -0
- package/locales/lt-lt.js +12 -0
- package/locales/lv-lv.d.ts +8 -0
- package/locales/lv-lv.js +12 -0
- package/locales/mk-mk.d.ts +8 -0
- package/locales/mk-mk.js +12 -0
- package/locales/ml-in.d.ts +8 -0
- package/locales/ml-in.js +12 -0
- package/locales/mn-mn.d.ts +8 -0
- package/locales/mn-mn.js +12 -0
- package/locales/ms-my.d.ts +8 -0
- package/locales/ms-my.js +12 -0
- package/locales/nb-no.d.ts +8 -0
- package/locales/nb-no.js +12 -0
- package/locales/ne-np.d.ts +8 -0
- package/locales/ne-np.js +12 -0
- package/locales/nl-be.d.ts +8 -0
- package/locales/nl-be.js +12 -0
- package/locales/nl-nl.d.ts +8 -0
- package/locales/nl-nl.js +12 -0
- package/locales/pl-pl.d.ts +8 -0
- package/locales/pl-pl.js +12 -0
- package/locales/pt-br.d.ts +8 -0
- package/locales/pt-br.js +12 -0
- package/locales/pt-pt.d.ts +8 -0
- package/locales/pt-pt.js +12 -0
- package/locales/ro-ro.d.ts +8 -0
- package/locales/ro-ro.js +12 -0
- package/locales/ru-ru.d.ts +8 -0
- package/locales/ru-ru.js +12 -0
- package/locales/sk-sk.d.ts +8 -0
- package/locales/sk-sk.js +12 -0
- package/locales/sl-si.d.ts +8 -0
- package/locales/sl-si.js +12 -0
- package/locales/sr-rs.d.ts +8 -0
- package/locales/sr-rs.js +12 -0
- package/locales/sv-se.d.ts +8 -0
- package/locales/sv-se.js +12 -0
- package/locales/ta-in.d.ts +8 -0
- package/locales/ta-in.js +12 -0
- package/locales/th-th.d.ts +8 -0
- package/locales/th-th.js +12 -0
- package/locales/tr-tr.d.ts +8 -0
- package/locales/tr-tr.js +12 -0
- package/locales/uk-ua.d.ts +8 -0
- package/locales/uk-ua.js +12 -0
- package/locales/ur-pk.d.ts +8 -0
- package/locales/ur-pk.js +12 -0
- package/locales/vi-vn.d.ts +8 -0
- package/locales/vi-vn.js +12 -0
- package/locales/zh-cn.d.ts +8 -0
- package/locales/zh-cn.js +12 -0
- package/locales/zh-hk.d.ts +8 -0
- package/locales/zh-hk.js +12 -0
- package/locales/zh-tw.d.ts +8 -0
- package/locales/zh-tw.js +12 -0
- package/mdui.d.ts +5 -0
- package/mdui.esm.js +22 -0
- package/mdui.global.js +22 -0
- package/mdui.js +3 -0
- package/package.json +9 -6
- package/web-types.en.json +91 -1
- package/web-types.zh-cn.json +91 -1
- /package/{functions/utils → internal}/colorScheme.d.ts +0 -0
- /package/{functions/utils → internal}/colorScheme.js +0 -0
- /package/{functions/utils → internal}/theme.d.ts +0 -0
- /package/{functions/utils → internal}/theme.js +0 -0
package/functions/alert.d.ts
CHANGED
package/functions/alert.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { msg } from '@lit/localize';
|
|
1
2
|
import isPromise from 'is-promise';
|
|
2
3
|
import { $ } from '@mdui/jq/$.js';
|
|
4
|
+
import '@mdui/jq/methods/find.js';
|
|
3
5
|
import '@mdui/jq/methods/on.js';
|
|
6
|
+
import '@mdui/jq/methods/text.js';
|
|
4
7
|
import { isUndefined, returnTrue } from '@mdui/jq/shared/helper.js';
|
|
8
|
+
import { onLocaleReady, offLocaleReady } from '../internal/localize.js';
|
|
5
9
|
import { dialog as openDialog } from './dialog.js';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const getConfirmText = () => {
|
|
11
|
+
return msg('OK', {
|
|
12
|
+
id: 'functions.alert.confirmText',
|
|
13
|
+
});
|
|
9
14
|
};
|
|
10
15
|
/**
|
|
11
16
|
* 打开一个 alert,返回 Promise。
|
|
@@ -14,7 +19,10 @@ const defaultOptions = {
|
|
|
14
19
|
* @param options
|
|
15
20
|
*/
|
|
16
21
|
export const alert = (options) => {
|
|
17
|
-
const mergedOptions = Object.assign({},
|
|
22
|
+
const mergedOptions = Object.assign({}, {
|
|
23
|
+
confirmText: getConfirmText(),
|
|
24
|
+
onConfirm: returnTrue,
|
|
25
|
+
}, options);
|
|
18
26
|
const properties = [
|
|
19
27
|
'headline',
|
|
20
28
|
'description',
|
|
@@ -52,8 +60,15 @@ export const alert = (options) => {
|
|
|
52
60
|
},
|
|
53
61
|
],
|
|
54
62
|
});
|
|
63
|
+
// 若未传入自定义文案,则监听 locale 变化更新文案
|
|
64
|
+
if (!options.confirmText) {
|
|
65
|
+
onLocaleReady(dialog, () => {
|
|
66
|
+
$(dialog).find('[slot="action"]').text(getConfirmText());
|
|
67
|
+
});
|
|
68
|
+
}
|
|
55
69
|
$(dialog).on('close', () => {
|
|
56
70
|
isResolve ? resolve() : reject();
|
|
71
|
+
offLocaleReady(dialog);
|
|
57
72
|
});
|
|
58
73
|
});
|
|
59
74
|
};
|
package/functions/confirm.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import '@mdui/jq/methods/find.js';
|
|
2
|
+
import '@mdui/jq/methods/first.js';
|
|
3
|
+
import '@mdui/jq/methods/last.js';
|
|
1
4
|
import '@mdui/jq/methods/on.js';
|
|
5
|
+
import '@mdui/jq/methods/text.js';
|
|
2
6
|
import type { Dialog } from '../components/dialog.js';
|
|
3
7
|
interface Options {
|
|
4
8
|
/**
|
package/functions/confirm.js
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
import { msg } from '@lit/localize';
|
|
1
2
|
import isPromise from 'is-promise';
|
|
2
3
|
import { $ } from '@mdui/jq/$.js';
|
|
4
|
+
import '@mdui/jq/methods/find.js';
|
|
5
|
+
import '@mdui/jq/methods/first.js';
|
|
6
|
+
import '@mdui/jq/methods/last.js';
|
|
3
7
|
import '@mdui/jq/methods/on.js';
|
|
8
|
+
import '@mdui/jq/methods/text.js';
|
|
4
9
|
import { isUndefined, returnTrue } from '@mdui/jq/shared/helper.js';
|
|
10
|
+
import { onLocaleReady, offLocaleReady } from '../internal/localize.js';
|
|
5
11
|
import { dialog as openDialog } from './dialog.js';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const getConfirmText = () => {
|
|
13
|
+
return msg('OK', {
|
|
14
|
+
id: 'functions.confirm.confirmText',
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const getCancelText = () => {
|
|
18
|
+
return msg('Cancel', {
|
|
19
|
+
id: 'functions.confirm.cancelText',
|
|
20
|
+
});
|
|
11
21
|
};
|
|
12
22
|
/**
|
|
13
23
|
* 打开一个 confirm,返回 Promise。
|
|
@@ -16,7 +26,12 @@ const defaultOptions = {
|
|
|
16
26
|
* @param options
|
|
17
27
|
*/
|
|
18
28
|
export const confirm = (options) => {
|
|
19
|
-
const mergedOptions = Object.assign({},
|
|
29
|
+
const mergedOptions = Object.assign({}, {
|
|
30
|
+
confirmText: getConfirmText(),
|
|
31
|
+
cancelText: getCancelText(),
|
|
32
|
+
onConfirm: returnTrue,
|
|
33
|
+
onCancel: returnTrue,
|
|
34
|
+
}, options);
|
|
20
35
|
const properties = [
|
|
21
36
|
'headline',
|
|
22
37
|
'description',
|
|
@@ -61,8 +76,20 @@ export const confirm = (options) => {
|
|
|
61
76
|
},
|
|
62
77
|
],
|
|
63
78
|
});
|
|
79
|
+
// 若未传入自定义文案,则监听 locale 变化更新文案
|
|
80
|
+
if (!options.confirmText) {
|
|
81
|
+
onLocaleReady(dialog, () => {
|
|
82
|
+
$(dialog).find('[slot="action"]').last().text(getConfirmText());
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (!options.cancelText) {
|
|
86
|
+
onLocaleReady(dialog, () => {
|
|
87
|
+
$(dialog).find('[slot="action"]').first().text(getCancelText());
|
|
88
|
+
});
|
|
89
|
+
}
|
|
64
90
|
$(dialog).on('close', () => {
|
|
65
91
|
isResolve ? resolve() : reject();
|
|
92
|
+
offLocaleReady(dialog);
|
|
66
93
|
});
|
|
67
94
|
});
|
|
68
95
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getLocale as getLocaleInternal, uninitializedError, } from '../internal/localize.js';
|
|
2
|
+
/**
|
|
3
|
+
* 获取当前的语言代码。如果当前正在加载新的语言包,则该函数仍返回先前的语言代码
|
|
4
|
+
* @return string 当前的语言代码
|
|
5
|
+
*/
|
|
6
|
+
export const getLocale = () => {
|
|
7
|
+
if (!getLocaleInternal) {
|
|
8
|
+
throw new Error(uninitializedError);
|
|
9
|
+
}
|
|
10
|
+
return getLocaleInternal();
|
|
11
|
+
};
|
package/functions/getTheme.d.ts
CHANGED
package/functions/prompt.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import '@mdui/jq/methods/find.js';
|
|
2
|
+
import '@mdui/jq/methods/first';
|
|
3
|
+
import '@mdui/jq/methods/last.js';
|
|
1
4
|
import '@mdui/jq/methods/on.js';
|
|
5
|
+
import '@mdui/jq/methods/text.js';
|
|
2
6
|
import { TextField } from '../components/text-field.js';
|
|
3
7
|
import type { Dialog } from '../components/dialog.js';
|
|
4
8
|
interface Options {
|
package/functions/prompt.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
import { msg } from '@lit/localize';
|
|
1
2
|
import isPromise from 'is-promise';
|
|
2
3
|
import { $ } from '@mdui/jq/$.js';
|
|
4
|
+
import '@mdui/jq/methods/find.js';
|
|
5
|
+
import '@mdui/jq/methods/first';
|
|
6
|
+
import '@mdui/jq/methods/last.js';
|
|
3
7
|
import '@mdui/jq/methods/on.js';
|
|
8
|
+
import '@mdui/jq/methods/text.js';
|
|
4
9
|
import { isBoolean, isString, isUndefined, returnTrue, } from '@mdui/jq/shared/helper.js';
|
|
5
10
|
import { TextField } from '../components/text-field.js';
|
|
11
|
+
import { onLocaleReady, offLocaleReady } from '../internal/localize.js';
|
|
6
12
|
import { dialog as openDialog } from './dialog.js';
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const getConfirmText = () => {
|
|
14
|
+
return msg('OK', {
|
|
15
|
+
id: 'functions.prompt.confirmText',
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const getCancelText = () => {
|
|
19
|
+
return msg('Cancel', {
|
|
20
|
+
id: 'functions.prompt.cancelText',
|
|
21
|
+
});
|
|
14
22
|
};
|
|
15
23
|
/**
|
|
16
24
|
* 打开一个 prompt,返回 Promise。
|
|
@@ -19,7 +27,14 @@ const defaultOptions = {
|
|
|
19
27
|
* @param options
|
|
20
28
|
*/
|
|
21
29
|
export const prompt = (options) => {
|
|
22
|
-
const mergedOptions = Object.assign({},
|
|
30
|
+
const mergedOptions = Object.assign({}, {
|
|
31
|
+
confirmText: getConfirmText(),
|
|
32
|
+
cancelText: getCancelText(),
|
|
33
|
+
onConfirm: returnTrue,
|
|
34
|
+
onCancel: returnTrue,
|
|
35
|
+
validator: returnTrue,
|
|
36
|
+
textFieldOptions: {},
|
|
37
|
+
}, options);
|
|
23
38
|
const properties = [
|
|
24
39
|
'headline',
|
|
25
40
|
'description',
|
|
@@ -96,8 +111,20 @@ export const prompt = (options) => {
|
|
|
96
111
|
},
|
|
97
112
|
],
|
|
98
113
|
});
|
|
114
|
+
// 若未传入自定义文案,则监听 locale 变化更新文案
|
|
115
|
+
if (!options.confirmText) {
|
|
116
|
+
onLocaleReady(dialog, () => {
|
|
117
|
+
$(dialog).find('[slot="action"]').last().text(getConfirmText());
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (!options.cancelText) {
|
|
121
|
+
onLocaleReady(dialog, () => {
|
|
122
|
+
$(dialog).find('[slot="action"]').first().text(getCancelText());
|
|
123
|
+
});
|
|
124
|
+
}
|
|
99
125
|
$(dialog).on('close', () => {
|
|
100
126
|
isResolve ? resolve(textField.value) : reject();
|
|
127
|
+
offLocaleReady(dialog);
|
|
101
128
|
});
|
|
102
129
|
});
|
|
103
130
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { setLocale as setLocaleInternal, uninitializedError, } from '../internal/localize.js';
|
|
2
|
+
/**
|
|
3
|
+
* 切换到指定的语言。返回 Promise,在新的语言包加载完成后 resolve
|
|
4
|
+
* @param locale 语言代码
|
|
5
|
+
*/
|
|
6
|
+
export const setLocale = (locale) => {
|
|
7
|
+
if (!setLocaleInternal) {
|
|
8
|
+
throw new Error(uninitializedError);
|
|
9
|
+
}
|
|
10
|
+
return setLocaleInternal(locale);
|
|
11
|
+
};
|
package/functions/setTheme.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The locale code that templates in this source code are written in.
|
|
3
|
+
*/
|
|
4
|
+
export declare const sourceLocale = "en-us";
|
|
5
|
+
/**
|
|
6
|
+
* The other locale codes that this application is localized into. Sorted
|
|
7
|
+
* lexicographically.
|
|
8
|
+
*/
|
|
9
|
+
export declare const targetLocales: readonly ["ar-eg", "az-az", "be-by", "bg-bg", "bn-bd", "ca-es", "cs-cz", "da-dk", "de-de", "el-gr", "en-gb", "es-es", "et-ee", "fa-ir", "fi-fi", "fr-be", "fr-ca", "fr-fr", "ga-ie", "gl-es", "he-il", "hi-in", "hr-hr", "hu-hu", "hy-am", "id-id", "is-is", "it-it", "ja-jp", "ka-ge", "kk-kz", "km-kh", "kmr-iq", "kn-in", "ko-kr", "lt-lt", "lv-lv", "mk-mk", "ml-in", "mn-mn", "ms-my", "nb-no", "ne-np", "nl-be", "nl-nl", "pl-pl", "pt-br", "pt-pt", "ro-ro", "ru-ru", "sk-sk", "sl-si", "sr-rs", "sv-se", "ta-in", "th-th", "tr-tr", "uk-ua", "ur-pk", "vi-vn", "zh-cn", "zh-hk", "zh-tw"];
|
|
10
|
+
/**
|
|
11
|
+
* All valid project locale codes. Sorted lexicographically.
|
|
12
|
+
*/
|
|
13
|
+
export declare const allLocales: readonly ["ar-eg", "az-az", "be-by", "bg-bg", "bn-bd", "ca-es", "cs-cz", "da-dk", "de-de", "el-gr", "en-gb", "en-us", "es-es", "et-ee", "fa-ir", "fi-fi", "fr-be", "fr-ca", "fr-fr", "ga-ie", "gl-es", "he-il", "hi-in", "hr-hr", "hu-hu", "hy-am", "id-id", "is-is", "it-it", "ja-jp", "ka-ge", "kk-kz", "km-kh", "kmr-iq", "kn-in", "ko-kr", "lt-lt", "lv-lv", "mk-mk", "ml-in", "mn-mn", "ms-my", "nb-no", "ne-np", "nl-be", "nl-nl", "pl-pl", "pt-br", "pt-pt", "ro-ro", "ru-ru", "sk-sk", "sl-si", "sr-rs", "sv-se", "ta-in", "th-th", "tr-tr", "uk-ua", "ur-pk", "vi-vn", "zh-cn", "zh-hk", "zh-tw"];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Do not modify this file by hand!
|
|
2
|
+
// Re-generate this file by running lit-localize.
|
|
3
|
+
/**
|
|
4
|
+
* The locale code that templates in this source code are written in.
|
|
5
|
+
*/
|
|
6
|
+
export const sourceLocale = `en-us`;
|
|
7
|
+
/**
|
|
8
|
+
* The other locale codes that this application is localized into. Sorted
|
|
9
|
+
* lexicographically.
|
|
10
|
+
*/
|
|
11
|
+
export const targetLocales = [
|
|
12
|
+
`ar-eg`,
|
|
13
|
+
`az-az`,
|
|
14
|
+
`be-by`,
|
|
15
|
+
`bg-bg`,
|
|
16
|
+
`bn-bd`,
|
|
17
|
+
`ca-es`,
|
|
18
|
+
`cs-cz`,
|
|
19
|
+
`da-dk`,
|
|
20
|
+
`de-de`,
|
|
21
|
+
`el-gr`,
|
|
22
|
+
`en-gb`,
|
|
23
|
+
`es-es`,
|
|
24
|
+
`et-ee`,
|
|
25
|
+
`fa-ir`,
|
|
26
|
+
`fi-fi`,
|
|
27
|
+
`fr-be`,
|
|
28
|
+
`fr-ca`,
|
|
29
|
+
`fr-fr`,
|
|
30
|
+
`ga-ie`,
|
|
31
|
+
`gl-es`,
|
|
32
|
+
`he-il`,
|
|
33
|
+
`hi-in`,
|
|
34
|
+
`hr-hr`,
|
|
35
|
+
`hu-hu`,
|
|
36
|
+
`hy-am`,
|
|
37
|
+
`id-id`,
|
|
38
|
+
`is-is`,
|
|
39
|
+
`it-it`,
|
|
40
|
+
`ja-jp`,
|
|
41
|
+
`ka-ge`,
|
|
42
|
+
`kk-kz`,
|
|
43
|
+
`km-kh`,
|
|
44
|
+
`kmr-iq`,
|
|
45
|
+
`kn-in`,
|
|
46
|
+
`ko-kr`,
|
|
47
|
+
`lt-lt`,
|
|
48
|
+
`lv-lv`,
|
|
49
|
+
`mk-mk`,
|
|
50
|
+
`ml-in`,
|
|
51
|
+
`mn-mn`,
|
|
52
|
+
`ms-my`,
|
|
53
|
+
`nb-no`,
|
|
54
|
+
`ne-np`,
|
|
55
|
+
`nl-be`,
|
|
56
|
+
`nl-nl`,
|
|
57
|
+
`pl-pl`,
|
|
58
|
+
`pt-br`,
|
|
59
|
+
`pt-pt`,
|
|
60
|
+
`ro-ro`,
|
|
61
|
+
`ru-ru`,
|
|
62
|
+
`sk-sk`,
|
|
63
|
+
`sl-si`,
|
|
64
|
+
`sr-rs`,
|
|
65
|
+
`sv-se`,
|
|
66
|
+
`ta-in`,
|
|
67
|
+
`th-th`,
|
|
68
|
+
`tr-tr`,
|
|
69
|
+
`uk-ua`,
|
|
70
|
+
`ur-pk`,
|
|
71
|
+
`vi-vn`,
|
|
72
|
+
`zh-cn`,
|
|
73
|
+
`zh-hk`,
|
|
74
|
+
`zh-tw`,
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* All valid project locale codes. Sorted lexicographically.
|
|
78
|
+
*/
|
|
79
|
+
export const allLocales = [
|
|
80
|
+
`ar-eg`,
|
|
81
|
+
`az-az`,
|
|
82
|
+
`be-by`,
|
|
83
|
+
`bg-bg`,
|
|
84
|
+
`bn-bd`,
|
|
85
|
+
`ca-es`,
|
|
86
|
+
`cs-cz`,
|
|
87
|
+
`da-dk`,
|
|
88
|
+
`de-de`,
|
|
89
|
+
`el-gr`,
|
|
90
|
+
`en-gb`,
|
|
91
|
+
`en-us`,
|
|
92
|
+
`es-es`,
|
|
93
|
+
`et-ee`,
|
|
94
|
+
`fa-ir`,
|
|
95
|
+
`fi-fi`,
|
|
96
|
+
`fr-be`,
|
|
97
|
+
`fr-ca`,
|
|
98
|
+
`fr-fr`,
|
|
99
|
+
`ga-ie`,
|
|
100
|
+
`gl-es`,
|
|
101
|
+
`he-il`,
|
|
102
|
+
`hi-in`,
|
|
103
|
+
`hr-hr`,
|
|
104
|
+
`hu-hu`,
|
|
105
|
+
`hy-am`,
|
|
106
|
+
`id-id`,
|
|
107
|
+
`is-is`,
|
|
108
|
+
`it-it`,
|
|
109
|
+
`ja-jp`,
|
|
110
|
+
`ka-ge`,
|
|
111
|
+
`kk-kz`,
|
|
112
|
+
`km-kh`,
|
|
113
|
+
`kmr-iq`,
|
|
114
|
+
`kn-in`,
|
|
115
|
+
`ko-kr`,
|
|
116
|
+
`lt-lt`,
|
|
117
|
+
`lv-lv`,
|
|
118
|
+
`mk-mk`,
|
|
119
|
+
`ml-in`,
|
|
120
|
+
`mn-mn`,
|
|
121
|
+
`ms-my`,
|
|
122
|
+
`nb-no`,
|
|
123
|
+
`ne-np`,
|
|
124
|
+
`nl-be`,
|
|
125
|
+
`nl-nl`,
|
|
126
|
+
`pl-pl`,
|
|
127
|
+
`pt-br`,
|
|
128
|
+
`pt-pt`,
|
|
129
|
+
`ro-ro`,
|
|
130
|
+
`ru-ru`,
|
|
131
|
+
`sk-sk`,
|
|
132
|
+
`sl-si`,
|
|
133
|
+
`sr-rs`,
|
|
134
|
+
`sv-se`,
|
|
135
|
+
`ta-in`,
|
|
136
|
+
`th-th`,
|
|
137
|
+
`tr-tr`,
|
|
138
|
+
`uk-ua`,
|
|
139
|
+
`ur-pk`,
|
|
140
|
+
`vi-vn`,
|
|
141
|
+
`zh-cn`,
|
|
142
|
+
`zh-hk`,
|
|
143
|
+
`zh-tw`,
|
|
144
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { targetLocales } from './localeCodes.js';
|
|
2
|
+
import type { allLocales } from './localeCodes.js';
|
|
3
|
+
import type { LocaleModule, LocaleStatusEventDetail } from '@lit/localize';
|
|
4
|
+
export type LocaleTargetCode = (typeof targetLocales)[number];
|
|
5
|
+
export type LocaleCode = (typeof allLocales)[number];
|
|
6
|
+
export type LoadFunc = (locale: LocaleTargetCode) => Promise<LocaleModule>;
|
|
7
|
+
export type GetLocal = () => LocaleCode;
|
|
8
|
+
export type SetLocal = (locale: LocaleCode) => Promise<void>;
|
|
9
|
+
declare global {
|
|
10
|
+
interface WindowEventMap {
|
|
11
|
+
'mdui-localize-status': CustomEvent<LocaleStatusEventDetail>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const uninitializedError = "You must call `loadLocale` first to set up the localized template.";
|
|
15
|
+
export declare let getLocale: GetLocal | undefined;
|
|
16
|
+
export declare let setLocale: SetLocal | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* 初始化 localization
|
|
19
|
+
* @param loadFunc
|
|
20
|
+
*/
|
|
21
|
+
export declare const initializeLocalize: (loadFunc: LoadFunc) => void;
|
|
22
|
+
/**
|
|
23
|
+
* 监听 localize ready 事件
|
|
24
|
+
* @param target
|
|
25
|
+
* @param callback
|
|
26
|
+
*/
|
|
27
|
+
export declare const onLocaleReady: (target: HTMLElement, callback: () => void) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 取消监听 localize ready 事件
|
|
30
|
+
* @param target
|
|
31
|
+
*/
|
|
32
|
+
export declare const offLocaleReady: (target: HTMLElement) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { configureLocalization, LOCALE_STATUS_EVENT } from '@lit/localize';
|
|
2
|
+
import { getWindow } from 'ssr-window';
|
|
3
|
+
import { sourceLocale, targetLocales } from './localeCodes.js';
|
|
4
|
+
export const uninitializedError = 'You must call `loadLocale` first to set up the localized template.';
|
|
5
|
+
export let getLocale;
|
|
6
|
+
export let setLocale;
|
|
7
|
+
/**
|
|
8
|
+
* 初始化 localization
|
|
9
|
+
* @param loadFunc
|
|
10
|
+
*/
|
|
11
|
+
export const initializeLocalize = (loadFunc) => {
|
|
12
|
+
const window = getWindow();
|
|
13
|
+
const result = configureLocalization({
|
|
14
|
+
sourceLocale,
|
|
15
|
+
targetLocales,
|
|
16
|
+
loadLocale: loadFunc,
|
|
17
|
+
});
|
|
18
|
+
getLocale = result.getLocale;
|
|
19
|
+
setLocale = result.setLocale;
|
|
20
|
+
window.addEventListener(LOCALE_STATUS_EVENT, (event) => {
|
|
21
|
+
window.dispatchEvent(new CustomEvent('mdui-localize-status', {
|
|
22
|
+
detail: event.detail,
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
let listeningLitLocalizeStatus = false;
|
|
27
|
+
const localeReadyCallbacksMap = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* 监听 localize ready 事件
|
|
30
|
+
* @param target
|
|
31
|
+
* @param callback
|
|
32
|
+
*/
|
|
33
|
+
export const onLocaleReady = (target, callback) => {
|
|
34
|
+
if (!listeningLitLocalizeStatus) {
|
|
35
|
+
listeningLitLocalizeStatus = true;
|
|
36
|
+
const window = getWindow();
|
|
37
|
+
window.addEventListener(LOCALE_STATUS_EVENT, (event) => {
|
|
38
|
+
if (event.detail.status === 'ready') {
|
|
39
|
+
localeReadyCallbacksMap.forEach((callbacks) => {
|
|
40
|
+
callbacks.forEach((cb) => cb());
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const callbacks = localeReadyCallbacksMap.get(target) || [];
|
|
46
|
+
callbacks.push(callback);
|
|
47
|
+
localeReadyCallbacksMap.set(target, callbacks);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 取消监听 localize ready 事件
|
|
51
|
+
* @param target
|
|
52
|
+
*/
|
|
53
|
+
export const offLocaleReady = (target) => {
|
|
54
|
+
localeReadyCallbacksMap.delete(target);
|
|
55
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const templates: {
|
|
2
|
+
'components.textField.patternError': string;
|
|
3
|
+
'functions.alert.confirmText': string;
|
|
4
|
+
'functions.confirm.cancelText': string;
|
|
5
|
+
'functions.confirm.confirmText': string;
|
|
6
|
+
'functions.prompt.cancelText': string;
|
|
7
|
+
'functions.prompt.confirmText': string;
|
|
8
|
+
};
|
package/locales/ar-eg.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Do not modify this file by hand!
|
|
2
|
+
// Re-generate this file by running lit-localize
|
|
3
|
+
/* eslint-disable no-irregular-whitespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
export const templates = {
|
|
6
|
+
'components.textField.patternError': `يرجى تطابق التنسيق المطلوب.`,
|
|
7
|
+
'functions.alert.confirmText': `حسنًا`,
|
|
8
|
+
'functions.confirm.cancelText': `إلغاء`,
|
|
9
|
+
'functions.confirm.confirmText': `حسنًا`,
|
|
10
|
+
'functions.prompt.cancelText': `إلغاء`,
|
|
11
|
+
'functions.prompt.confirmText': `حسنًا`,
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const templates: {
|
|
2
|
+
'components.textField.patternError': string;
|
|
3
|
+
'functions.alert.confirmText': string;
|
|
4
|
+
'functions.confirm.cancelText': string;
|
|
5
|
+
'functions.confirm.confirmText': string;
|
|
6
|
+
'functions.prompt.cancelText': string;
|
|
7
|
+
'functions.prompt.confirmText': string;
|
|
8
|
+
};
|
package/locales/az-az.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Do not modify this file by hand!
|
|
2
|
+
// Re-generate this file by running lit-localize
|
|
3
|
+
/* eslint-disable no-irregular-whitespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
export const templates = {
|
|
6
|
+
'components.textField.patternError': `Zəhmət olmasa, tələb olunan formatla uyğun gəlin.`,
|
|
7
|
+
'functions.alert.confirmText': `Oldu`,
|
|
8
|
+
'functions.confirm.cancelText': `Ləğv et`,
|
|
9
|
+
'functions.confirm.confirmText': `Oldu`,
|
|
10
|
+
'functions.prompt.cancelText': `Ləğv et`,
|
|
11
|
+
'functions.prompt.confirmText': `Oldu`,
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const templates: {
|
|
2
|
+
'components.textField.patternError': string;
|
|
3
|
+
'functions.alert.confirmText': string;
|
|
4
|
+
'functions.confirm.cancelText': string;
|
|
5
|
+
'functions.confirm.confirmText': string;
|
|
6
|
+
'functions.prompt.cancelText': string;
|
|
7
|
+
'functions.prompt.confirmText': string;
|
|
8
|
+
};
|
package/locales/be-by.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Do not modify this file by hand!
|
|
2
|
+
// Re-generate this file by running lit-localize
|
|
3
|
+
/* eslint-disable no-irregular-whitespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
export const templates = {
|
|
6
|
+
'components.textField.patternError': `Калі ласка, адпавядайце патрабаванаму фармату.`,
|
|
7
|
+
'functions.alert.confirmText': `Добра`,
|
|
8
|
+
'functions.confirm.cancelText': `Адмяніць`,
|
|
9
|
+
'functions.confirm.confirmText': `Добра`,
|
|
10
|
+
'functions.prompt.cancelText': `Адмяніць`,
|
|
11
|
+
'functions.prompt.confirmText': `Добра`,
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const templates: {
|
|
2
|
+
'components.textField.patternError': string;
|
|
3
|
+
'functions.alert.confirmText': string;
|
|
4
|
+
'functions.confirm.cancelText': string;
|
|
5
|
+
'functions.confirm.confirmText': string;
|
|
6
|
+
'functions.prompt.cancelText': string;
|
|
7
|
+
'functions.prompt.confirmText': string;
|
|
8
|
+
};
|
package/locales/bg-bg.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Do not modify this file by hand!
|
|
2
|
+
// Re-generate this file by running lit-localize
|
|
3
|
+
/* eslint-disable no-irregular-whitespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
export const templates = {
|
|
6
|
+
'components.textField.patternError': `Моля, съответствайте на изискания формат.`,
|
|
7
|
+
'functions.alert.confirmText': `ОК`,
|
|
8
|
+
'functions.confirm.cancelText': `Отказ`,
|
|
9
|
+
'functions.confirm.confirmText': `ОК`,
|
|
10
|
+
'functions.prompt.cancelText': `Отказ`,
|
|
11
|
+
'functions.prompt.confirmText': `ОК`,
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const templates: {
|
|
2
|
+
'components.textField.patternError': string;
|
|
3
|
+
'functions.alert.confirmText': string;
|
|
4
|
+
'functions.confirm.cancelText': string;
|
|
5
|
+
'functions.confirm.confirmText': string;
|
|
6
|
+
'functions.prompt.cancelText': string;
|
|
7
|
+
'functions.prompt.confirmText': string;
|
|
8
|
+
};
|