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.
Files changed (249) hide show
  1. package/components/avatar/index.js +2 -7
  2. package/components/avatar/style.js +1 -31
  3. package/components/badge/style.js +1 -25
  4. package/components/bottom-app-bar/style.js +1 -92
  5. package/components/button/button-base-style.js +1 -28
  6. package/components/button/button-base.js +1 -8
  7. package/components/button/index.js +8 -18
  8. package/components/button/style.js +2 -111
  9. package/components/button-icon/index.js +5 -22
  10. package/components/button-icon/style.js +2 -103
  11. package/components/card/index.js +1 -5
  12. package/components/card/style.js +1 -72
  13. package/components/checkbox/index.js +7 -50
  14. package/components/checkbox/style.js +1 -131
  15. package/components/chip/index.js +9 -33
  16. package/components/chip/style.js +2 -205
  17. package/components/circular-progress/index.js +5 -39
  18. package/components/circular-progress/style.js +1 -136
  19. package/components/collapse/collapse-item-style.js +1 -21
  20. package/components/collapse/collapse-item.js +2 -10
  21. package/components/collapse/collapse-style.js +1 -5
  22. package/components/collapse/collapse.js +1 -4
  23. package/components/dialog/index.js +10 -35
  24. package/components/dialog/style.js +1 -116
  25. package/components/divider/style.js +1 -18
  26. package/components/dropdown/index.js +1 -8
  27. package/components/dropdown/style.js +1 -11
  28. package/components/fab/index.js +5 -13
  29. package/components/fab/style.js +4 -153
  30. package/components/icon/index.js +1 -5
  31. package/components/icon/style.js +1 -29
  32. package/components/layout/layout-item-style.js +1 -6
  33. package/components/layout/layout-main-style.js +1 -7
  34. package/components/layout/layout-style.js +1 -11
  35. package/components/linear-progress/index.js +2 -6
  36. package/components/linear-progress/style.js +1 -73
  37. package/components/list/list-item-style.js +2 -153
  38. package/components/list/list-item.js +8 -27
  39. package/components/list/list-style.js +1 -10
  40. package/components/list/list-subheader-style.js +1 -19
  41. package/components/menu/menu-item-style.js +1 -125
  42. package/components/menu/menu-item.js +13 -55
  43. package/components/menu/menu-style.js +1 -19
  44. package/components/menu/menu.js +1 -5
  45. package/components/navigation-bar/navigation-bar-item-style.js +1 -132
  46. package/components/navigation-bar/navigation-bar-item.js +7 -23
  47. package/components/navigation-bar/navigation-bar-style.js +1 -28
  48. package/components/navigation-bar/navigation-bar.js +1 -4
  49. package/components/navigation-drawer/index.js +1 -12
  50. package/components/navigation-drawer/style.js +1 -66
  51. package/components/navigation-rail/navigation-rail-item-style.js +1 -122
  52. package/components/navigation-rail/navigation-rail-item.js +7 -26
  53. package/components/navigation-rail/navigation-rail-style.js +1 -79
  54. package/components/navigation-rail/navigation-rail.js +1 -10
  55. package/components/radio/radio-group-style.js +1 -20
  56. package/components/radio/radio-group.js +1 -19
  57. package/components/radio/radio-style.js +1 -107
  58. package/components/radio/radio.js +5 -23
  59. package/components/range-slider/index.d.ts +1 -1
  60. package/components/range-slider/index.js +5 -53
  61. package/components/ripple/index.js +2 -5
  62. package/components/ripple/style.js +1 -96
  63. package/components/segmented-button/segmented-button-group-style.js +1 -28
  64. package/components/segmented-button/segmented-button-group.js +1 -21
  65. package/components/segmented-button/segmented-button-style.js +2 -81
  66. package/components/segmented-button/segmented-button.js +11 -27
  67. package/components/select/index.d.ts +18 -0
  68. package/components/select/index.js +42 -87
  69. package/components/select/style.js +1 -27
  70. package/components/slider/index.js +2 -33
  71. package/components/slider/slider-base-style.js +1 -173
  72. package/components/slider/slider-base.js +1 -6
  73. package/components/slider/style.js +1 -7
  74. package/components/snackbar/index.js +5 -32
  75. package/components/snackbar/style.js +1 -100
  76. package/components/switch/index.js +6 -40
  77. package/components/switch/style.js +1 -202
  78. package/components/tabs/tab-panel-style.js +1 -10
  79. package/components/tabs/tab-style.js +1 -85
  80. package/components/tabs/tab.js +4 -24
  81. package/components/tabs/tabs-style.js +1 -138
  82. package/components/tabs/tabs.js +1 -9
  83. package/components/text-field/index.d.ts +2 -0
  84. package/components/text-field/index.js +58 -163
  85. package/components/text-field/style.js +1 -362
  86. package/components/tooltip/index.js +1 -10
  87. package/components/tooltip/style.js +1 -57
  88. package/components/top-app-bar/top-app-bar-style.js +1 -78
  89. package/components/top-app-bar/top-app-bar-title-style.js +1 -81
  90. package/components/top-app-bar/top-app-bar-title.js +3 -17
  91. package/custom-elements.json +1194 -1099
  92. package/functions/alert.d.ts +2 -0
  93. package/functions/alert.js +19 -4
  94. package/functions/confirm.d.ts +4 -0
  95. package/functions/confirm.js +33 -6
  96. package/functions/getLocale.d.ts +6 -0
  97. package/functions/getLocale.js +11 -0
  98. package/functions/getTheme.d.ts +1 -1
  99. package/functions/loadLocale.d.ts +6 -0
  100. package/functions/loadLocale.js +8 -0
  101. package/functions/prompt.d.ts +4 -0
  102. package/functions/prompt.js +35 -8
  103. package/functions/removeColorScheme.js +1 -1
  104. package/functions/setColorScheme.d.ts +1 -1
  105. package/functions/setColorScheme.js +1 -1
  106. package/functions/setLocale.d.ts +6 -0
  107. package/functions/setLocale.js +11 -0
  108. package/functions/setTheme.d.ts +1 -1
  109. package/internal/localeCodes.d.ts +13 -0
  110. package/internal/localeCodes.js +144 -0
  111. package/internal/localize.d.ts +32 -0
  112. package/internal/localize.js +55 -0
  113. package/locales/ar-eg.d.ts +8 -0
  114. package/locales/ar-eg.js +12 -0
  115. package/locales/az-az.d.ts +8 -0
  116. package/locales/az-az.js +12 -0
  117. package/locales/be-by.d.ts +8 -0
  118. package/locales/be-by.js +12 -0
  119. package/locales/bg-bg.d.ts +8 -0
  120. package/locales/bg-bg.js +12 -0
  121. package/locales/bn-bd.d.ts +8 -0
  122. package/locales/bn-bd.js +12 -0
  123. package/locales/ca-es.d.ts +8 -0
  124. package/locales/ca-es.js +12 -0
  125. package/locales/cs-cz.d.ts +8 -0
  126. package/locales/cs-cz.js +12 -0
  127. package/locales/da-dk.d.ts +8 -0
  128. package/locales/da-dk.js +12 -0
  129. package/locales/de-de.d.ts +8 -0
  130. package/locales/de-de.js +12 -0
  131. package/locales/el-gr.d.ts +8 -0
  132. package/locales/el-gr.js +12 -0
  133. package/locales/en-gb.d.ts +8 -0
  134. package/locales/en-gb.js +12 -0
  135. package/locales/es-es.d.ts +8 -0
  136. package/locales/es-es.js +12 -0
  137. package/locales/et-ee.d.ts +8 -0
  138. package/locales/et-ee.js +12 -0
  139. package/locales/fa-ir.d.ts +8 -0
  140. package/locales/fa-ir.js +12 -0
  141. package/locales/fi-fi.d.ts +8 -0
  142. package/locales/fi-fi.js +12 -0
  143. package/locales/fr-be.d.ts +8 -0
  144. package/locales/fr-be.js +12 -0
  145. package/locales/fr-ca.d.ts +8 -0
  146. package/locales/fr-ca.js +12 -0
  147. package/locales/fr-fr.d.ts +8 -0
  148. package/locales/fr-fr.js +12 -0
  149. package/locales/ga-ie.d.ts +8 -0
  150. package/locales/ga-ie.js +12 -0
  151. package/locales/gl-es.d.ts +8 -0
  152. package/locales/gl-es.js +12 -0
  153. package/locales/he-il.d.ts +8 -0
  154. package/locales/he-il.js +12 -0
  155. package/locales/hi-in.d.ts +8 -0
  156. package/locales/hi-in.js +12 -0
  157. package/locales/hr-hr.d.ts +8 -0
  158. package/locales/hr-hr.js +12 -0
  159. package/locales/hu-hu.d.ts +8 -0
  160. package/locales/hu-hu.js +12 -0
  161. package/locales/hy-am.d.ts +8 -0
  162. package/locales/hy-am.js +12 -0
  163. package/locales/id-id.d.ts +8 -0
  164. package/locales/id-id.js +12 -0
  165. package/locales/is-is.d.ts +8 -0
  166. package/locales/is-is.js +12 -0
  167. package/locales/it-it.d.ts +8 -0
  168. package/locales/it-it.js +12 -0
  169. package/locales/ja-jp.d.ts +8 -0
  170. package/locales/ja-jp.js +12 -0
  171. package/locales/ka-ge.d.ts +8 -0
  172. package/locales/ka-ge.js +12 -0
  173. package/locales/kk-kz.d.ts +8 -0
  174. package/locales/kk-kz.js +12 -0
  175. package/locales/km-kh.d.ts +8 -0
  176. package/locales/km-kh.js +12 -0
  177. package/locales/kmr-iq.d.ts +8 -0
  178. package/locales/kmr-iq.js +12 -0
  179. package/locales/kn-in.d.ts +8 -0
  180. package/locales/kn-in.js +12 -0
  181. package/locales/ko-kr.d.ts +8 -0
  182. package/locales/ko-kr.js +12 -0
  183. package/locales/lt-lt.d.ts +8 -0
  184. package/locales/lt-lt.js +12 -0
  185. package/locales/lv-lv.d.ts +8 -0
  186. package/locales/lv-lv.js +12 -0
  187. package/locales/mk-mk.d.ts +8 -0
  188. package/locales/mk-mk.js +12 -0
  189. package/locales/ml-in.d.ts +8 -0
  190. package/locales/ml-in.js +12 -0
  191. package/locales/mn-mn.d.ts +8 -0
  192. package/locales/mn-mn.js +12 -0
  193. package/locales/ms-my.d.ts +8 -0
  194. package/locales/ms-my.js +12 -0
  195. package/locales/nb-no.d.ts +8 -0
  196. package/locales/nb-no.js +12 -0
  197. package/locales/ne-np.d.ts +8 -0
  198. package/locales/ne-np.js +12 -0
  199. package/locales/nl-be.d.ts +8 -0
  200. package/locales/nl-be.js +12 -0
  201. package/locales/nl-nl.d.ts +8 -0
  202. package/locales/nl-nl.js +12 -0
  203. package/locales/pl-pl.d.ts +8 -0
  204. package/locales/pl-pl.js +12 -0
  205. package/locales/pt-br.d.ts +8 -0
  206. package/locales/pt-br.js +12 -0
  207. package/locales/pt-pt.d.ts +8 -0
  208. package/locales/pt-pt.js +12 -0
  209. package/locales/ro-ro.d.ts +8 -0
  210. package/locales/ro-ro.js +12 -0
  211. package/locales/ru-ru.d.ts +8 -0
  212. package/locales/ru-ru.js +12 -0
  213. package/locales/sk-sk.d.ts +8 -0
  214. package/locales/sk-sk.js +12 -0
  215. package/locales/sl-si.d.ts +8 -0
  216. package/locales/sl-si.js +12 -0
  217. package/locales/sr-rs.d.ts +8 -0
  218. package/locales/sr-rs.js +12 -0
  219. package/locales/sv-se.d.ts +8 -0
  220. package/locales/sv-se.js +12 -0
  221. package/locales/ta-in.d.ts +8 -0
  222. package/locales/ta-in.js +12 -0
  223. package/locales/th-th.d.ts +8 -0
  224. package/locales/th-th.js +12 -0
  225. package/locales/tr-tr.d.ts +8 -0
  226. package/locales/tr-tr.js +12 -0
  227. package/locales/uk-ua.d.ts +8 -0
  228. package/locales/uk-ua.js +12 -0
  229. package/locales/ur-pk.d.ts +8 -0
  230. package/locales/ur-pk.js +12 -0
  231. package/locales/vi-vn.d.ts +8 -0
  232. package/locales/vi-vn.js +12 -0
  233. package/locales/zh-cn.d.ts +8 -0
  234. package/locales/zh-cn.js +12 -0
  235. package/locales/zh-hk.d.ts +8 -0
  236. package/locales/zh-hk.js +12 -0
  237. package/locales/zh-tw.d.ts +8 -0
  238. package/locales/zh-tw.js +12 -0
  239. package/mdui.d.ts +5 -0
  240. package/mdui.esm.js +22 -0
  241. package/mdui.global.js +22 -0
  242. package/mdui.js +3 -0
  243. package/package.json +9 -6
  244. package/web-types.en.json +91 -1
  245. package/web-types.zh-cn.json +91 -1
  246. /package/{functions/utils → internal}/colorScheme.d.ts +0 -0
  247. /package/{functions/utils → internal}/colorScheme.js +0 -0
  248. /package/{functions/utils → internal}/theme.d.ts +0 -0
  249. /package/{functions/utils → internal}/theme.js +0 -0
@@ -1,4 +1,6 @@
1
+ import '@mdui/jq/methods/find.js';
1
2
  import '@mdui/jq/methods/on.js';
3
+ import '@mdui/jq/methods/text.js';
2
4
  import type { Dialog } from '../components/dialog.js';
3
5
  interface Options {
4
6
  /**
@@ -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 defaultOptions = {
7
- confirmText: '确定',
8
- onConfirm: returnTrue,
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({}, defaultOptions, options);
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
  };
@@ -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
  /**
@@ -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 defaultOptions = {
7
- confirmText: '确定',
8
- cancelText: '取消',
9
- onConfirm: returnTrue,
10
- onCancel: returnTrue,
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({}, defaultOptions, options);
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,6 @@
1
+ import type { GetLocal } from '../internal/localize.js';
2
+ /**
3
+ * 获取当前的语言代码。如果当前正在加载新的语言包,则该函数仍返回先前的语言代码
4
+ * @return string 当前的语言代码
5
+ */
6
+ export declare const getLocale: GetLocal;
@@ -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
+ };
@@ -1,4 +1,4 @@
1
- import type { Theme } from './utils/theme.js';
1
+ import type { Theme } from '../internal/theme.js';
2
2
  import type { JQ } from '@mdui/jq/shared/core.js';
3
3
  /**
4
4
  * 获取在指定元素上设置的主题。
@@ -0,0 +1,6 @@
1
+ import type { LoadFunc } from '../internal/localize.js';
2
+ /**
3
+ * 加载语言包。参数为一个函数,该函数接收一个语言代码作为参数,返回一个 Promise,resolve 的值为对应的语言包
4
+ * @param loadFunc
5
+ */
6
+ export declare const loadLocale: (loadFunc: LoadFunc) => void;
@@ -0,0 +1,8 @@
1
+ import { initializeLocalize } from '../internal/localize.js';
2
+ /**
3
+ * 加载语言包。参数为一个函数,该函数接收一个语言代码作为参数,返回一个 Promise,resolve 的值为对应的语言包
4
+ * @param loadFunc
5
+ */
6
+ export const loadLocale = (loadFunc) => {
7
+ initializeLocalize(loadFunc);
8
+ };
@@ -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 {
@@ -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 defaultOptions = {
8
- confirmText: '确定',
9
- cancelText: '取消',
10
- onConfirm: returnTrue,
11
- onCancel: returnTrue,
12
- validator: returnTrue,
13
- textFieldOptions: {},
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({}, defaultOptions, options);
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
  };
@@ -1,4 +1,4 @@
1
- import { remove } from './utils/colorScheme.js';
1
+ import { remove } from '../internal/colorScheme.js';
2
2
  /**
3
3
  * 移除指定元素上的配色方案
4
4
  * @param target 要移除配色方案的元素。可以是 CSS 选择器、DOM 元素、或 JQ 对象。默认为 `<html>` 元素
@@ -1,4 +1,4 @@
1
- import type { CustomColor } from './utils/colorScheme.js';
1
+ import type { CustomColor } from '../internal/colorScheme.js';
2
2
  import type { JQ } from '@mdui/jq/shared/core.js';
3
3
  /**
4
4
  * 在指定元素上设置配色方案
@@ -1,5 +1,5 @@
1
1
  import { argbFromHex } from '@material/material-color-utilities';
2
- import { setFromSource } from './utils/colorScheme.js';
2
+ import { setFromSource } from '../internal/colorScheme.js';
3
3
  /**
4
4
  * 在指定元素上设置配色方案
5
5
  * @param hex 十六进制颜色值,如 #f82506
@@ -0,0 +1,6 @@
1
+ import type { SetLocal } from '../internal/localize.js';
2
+ /**
3
+ * 切换到指定的语言。返回 Promise,在新的语言包加载完成后 resolve
4
+ * @param locale 语言代码
5
+ */
6
+ export declare const setLocale: SetLocal;
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import '@mdui/jq/methods/addClass.js';
2
2
  import '@mdui/jq/methods/removeClass.js';
3
- import type { Theme } from './utils/theme.js';
3
+ import type { Theme } from '../internal/theme.js';
4
4
  import type { JQ } from '@mdui/jq/shared/core.js';
5
5
  /**
6
6
  * 在当前页面、或指定元素上设置主题。
@@ -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
+ };
@@ -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
+ };
@@ -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
+ };
@@ -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
+ };
@@ -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
+ };