mdui 2.0.6 → 2.1.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/components/dialog/index.js +3 -0
- package/components/select/index.d.ts +18 -0
- package/components/select/index.js +38 -2
- package/components/text-field/index.d.ts +2 -0
- package/components/text-field/index.js +26 -3
- package/custom-elements.json +95 -0
- 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 +8 -8
- package/mdui.global.js +6 -6
- package/mdui.js +3 -0
- package/package.json +7 -4
- 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
|
@@ -15,6 +15,7 @@ import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
|
15
15
|
import { lockScreen, unlockScreen } from '@mdui/shared/helpers/scroll.js';
|
|
16
16
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
17
17
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
18
|
+
import { offLocaleReady } from '../../internal/localize.js';
|
|
18
19
|
import '../icon.js';
|
|
19
20
|
import { style } from './style.js';
|
|
20
21
|
/**
|
|
@@ -199,6 +200,8 @@ let Dialog = class Dialog extends MduiElement {
|
|
|
199
200
|
disconnectedCallback() {
|
|
200
201
|
super.disconnectedCallback();
|
|
201
202
|
unlockScreen(this);
|
|
203
|
+
// alert, confirm, prompt 函数支持 localize。这里确保在组件销毁时,取消监听 localize ready 事件
|
|
204
|
+
offLocaleReady(this);
|
|
202
205
|
}
|
|
203
206
|
firstUpdated(_changedProperties) {
|
|
204
207
|
super.firstUpdated(_changedProperties);
|
|
@@ -33,7 +33,25 @@ declare const Select_base: import("@open-wc/dedupe-mixin").Constructor<import("@
|
|
|
33
33
|
* @slot clear-icon - 清空按钮中的图标
|
|
34
34
|
* @slot helper - 底部的帮助文本
|
|
35
35
|
*
|
|
36
|
+
* @csspart chips - 多选时,放置选中值对应的 chip 的容器
|
|
37
|
+
* @csspart chip - 多选时,每一个选中的值对应的 chip
|
|
38
|
+
* @csspart chip__button - chip 内部的 `<button>` 元素
|
|
39
|
+
* @csspart chip__label - chip 内部的文本
|
|
40
|
+
* @csspart chip__delete-icon - chip 内部的删除图标
|
|
36
41
|
* @csspart text-field - 文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素
|
|
42
|
+
* @csspart text-field__container - text-field 内部的文本框容器
|
|
43
|
+
* @csspart text-field__icon - text-field 内部的左侧图标
|
|
44
|
+
* @csspart text-field__end-icon - text-field 内部的右侧图标
|
|
45
|
+
* @csspart text-field__error-icon - text-field 内部的验证失败状态的右侧图标
|
|
46
|
+
* @csspart text-field__prefix - text-field 内部的左侧文本
|
|
47
|
+
* @csspart text-field__suffix - text-field 内部的右侧文本
|
|
48
|
+
* @csspart text-field__label - text-field 内部的标签文本
|
|
49
|
+
* @csspart text-field__input - text-field 内部的 `<input>` 元素
|
|
50
|
+
* @csspart text-field__clear-button - text-field 内部的清空按钮
|
|
51
|
+
* @csspart text-field__clear-icon - text-field 内部的清空按钮中的图标
|
|
52
|
+
* @csspart text-field__supporting - text-field 内部的底部辅助信息容器,包括 helper 和 error
|
|
53
|
+
* @csspart text-field__helper - text-field 内部的底部帮助文本
|
|
54
|
+
* @csspart text-field__error - text-field 内部的底部错误描述文本
|
|
37
55
|
* @csspart menu - 下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素
|
|
38
56
|
*/
|
|
39
57
|
export declare class Select extends Select_base<SelectEventMap> implements FormControl {
|
|
@@ -46,7 +46,25 @@ import { style } from './style.js';
|
|
|
46
46
|
* @slot clear-icon - 清空按钮中的图标
|
|
47
47
|
* @slot helper - 底部的帮助文本
|
|
48
48
|
*
|
|
49
|
+
* @csspart chips - 多选时,放置选中值对应的 chip 的容器
|
|
50
|
+
* @csspart chip - 多选时,每一个选中的值对应的 chip
|
|
51
|
+
* @csspart chip__button - chip 内部的 `<button>` 元素
|
|
52
|
+
* @csspart chip__label - chip 内部的文本
|
|
53
|
+
* @csspart chip__delete-icon - chip 内部的删除图标
|
|
49
54
|
* @csspart text-field - 文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素
|
|
55
|
+
* @csspart text-field__container - text-field 内部的文本框容器
|
|
56
|
+
* @csspart text-field__icon - text-field 内部的左侧图标
|
|
57
|
+
* @csspart text-field__end-icon - text-field 内部的右侧图标
|
|
58
|
+
* @csspart text-field__error-icon - text-field 内部的验证失败状态的右侧图标
|
|
59
|
+
* @csspart text-field__prefix - text-field 内部的左侧文本
|
|
60
|
+
* @csspart text-field__suffix - text-field 内部的右侧文本
|
|
61
|
+
* @csspart text-field__label - text-field 内部的标签文本
|
|
62
|
+
* @csspart text-field__input - text-field 内部的 `<input>` 元素
|
|
63
|
+
* @csspart text-field__clear-button - text-field 内部的清空按钮
|
|
64
|
+
* @csspart text-field__clear-icon - text-field 内部的清空按钮中的图标
|
|
65
|
+
* @csspart text-field__supporting - text-field 内部的底部辅助信息容器,包括 helper 和 error
|
|
66
|
+
* @csspart text-field__helper - text-field 内部的底部帮助文本
|
|
67
|
+
* @csspart text-field__error - text-field 内部的底部错误描述文本
|
|
50
68
|
* @csspart menu - 下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素
|
|
51
69
|
*/
|
|
52
70
|
let Select = class Select extends FocusableMixin(MduiElement) {
|
|
@@ -209,7 +227,23 @@ let Select = class Select extends FocusableMixin(MduiElement) {
|
|
|
209
227
|
? 'top-start'
|
|
210
228
|
: this.placement === 'bottom'
|
|
211
229
|
? 'bottom-start'
|
|
212
|
-
: 'auto'}" @open="${this.onDropdownOpen}" @close="${this.onDropdownClose}"><mdui-text-field ${ref(this.textFieldRef)} slot="trigger" part="text-field" class="text-field"
|
|
230
|
+
: 'auto'}" @open="${this.onDropdownOpen}" @close="${this.onDropdownClose}"><mdui-text-field ${ref(this.textFieldRef)} slot="trigger" part="text-field" class="text-field" exportparts="${[
|
|
231
|
+
'container',
|
|
232
|
+
'icon',
|
|
233
|
+
'end-icon',
|
|
234
|
+
'error-icon',
|
|
235
|
+
'prefix',
|
|
236
|
+
'suffix',
|
|
237
|
+
'label',
|
|
238
|
+
'input',
|
|
239
|
+
'clear-button',
|
|
240
|
+
'clear-icon',
|
|
241
|
+
'supporting',
|
|
242
|
+
'helper',
|
|
243
|
+
'error',
|
|
244
|
+
]
|
|
245
|
+
.map((v) => `${v}:text-field__${v}`)
|
|
246
|
+
.join(',')}" readonly="readonly" .readonlyButClearable="${true}" .variant="${this.variant}" .name="${this.name}" .value="${this.multiple
|
|
213
247
|
? this.value.length
|
|
214
248
|
? ' '
|
|
215
249
|
: ''
|
|
@@ -224,7 +258,9 @@ let Select = class Select extends FocusableMixin(MduiElement) {
|
|
|
224
258
|
'helper',
|
|
225
259
|
], (slotName) => this.hasSlotController.test(slotName)
|
|
226
260
|
? html `<slot name="${slotName}" slot="${slotName}"></slot>`
|
|
227
|
-
: nothing)} ${when(this.multiple && this.value.length, () => html `<div slot="input" class="chips">${map(this.value, (valueItem) => html `<mdui-chip class="chip"
|
|
261
|
+
: nothing)} ${when(this.multiple && this.value.length, () => html `<div slot="input" class="chips" part="chips">${map(this.value, (valueItem) => html `<mdui-chip class="chip" part="chip" exportparts="${['button', 'label', 'delete-icon']
|
|
262
|
+
.map((v) => `${v}:chip__${v}`)
|
|
263
|
+
.join(',')}" variant="input" deletable tabindex="-1" @delete="${() => this.onDeleteOneValue(valueItem)}">${this.getMenuItemLabelByValue(valueItem)}</mdui-chip>`)}</div>`)}</mdui-text-field><mdui-menu ${ref(this.menuRef)} part="menu" .selects="${this.multiple ? 'multiple' : 'single'}" .value="${this.value}" @change="${this.onValueChange}"><slot></slot></mdui-menu></mdui-dropdown>`;
|
|
228
264
|
}
|
|
229
265
|
getMenuItemLabelByValue(valueItem) {
|
|
230
266
|
if (!this.menuItems.length) {
|
|
@@ -367,6 +367,7 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
367
367
|
setCustomValidity(message: string): void;
|
|
368
368
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
369
369
|
protected render(): TemplateResult;
|
|
370
|
+
private setCustomValidityInternal;
|
|
370
371
|
private onChange;
|
|
371
372
|
private onClear;
|
|
372
373
|
private onInput;
|
|
@@ -377,6 +378,7 @@ export declare class TextField extends TextField_base<TextFieldEventMap> impleme
|
|
|
377
378
|
*/
|
|
378
379
|
private onTextAreaKeyUp;
|
|
379
380
|
private onTogglePassword;
|
|
381
|
+
private getPatternErrorMsg;
|
|
380
382
|
private setTextareaHeight;
|
|
381
383
|
private renderLabel;
|
|
382
384
|
private renderPrefix;
|
|
@@ -6,6 +6,7 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
6
6
|
import { live } from 'lit/directives/live.js';
|
|
7
7
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
8
8
|
import { when } from 'lit/directives/when.js';
|
|
9
|
+
import { msg } from '@lit/localize';
|
|
9
10
|
import { animate } from '@lit-labs/motion';
|
|
10
11
|
import { $ } from '@mdui/jq/$.js';
|
|
11
12
|
import '@mdui/jq/methods/css.js';
|
|
@@ -24,6 +25,7 @@ import '@mdui/shared/icons/visibility-off.js';
|
|
|
24
25
|
import '@mdui/shared/icons/visibility.js';
|
|
25
26
|
import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
|
|
26
27
|
import { FocusableMixin } from '@mdui/shared/mixins/focusable.js';
|
|
28
|
+
import { onLocaleReady, offLocaleReady } from '../../internal/localize.js';
|
|
27
29
|
import '../button-icon.js';
|
|
28
30
|
import '../icon.js';
|
|
29
31
|
import { style } from './style.js';
|
|
@@ -280,6 +282,7 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
280
282
|
disconnectedCallback() {
|
|
281
283
|
super.disconnectedCallback();
|
|
282
284
|
this.observeResize?.unobserve();
|
|
285
|
+
offLocaleReady(this);
|
|
283
286
|
}
|
|
284
287
|
/**
|
|
285
288
|
* 选中文本框中的文本
|
|
@@ -354,8 +357,9 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
354
357
|
* @param message 自定义的错误提示文本
|
|
355
358
|
*/
|
|
356
359
|
setCustomValidity(message) {
|
|
357
|
-
this.
|
|
358
|
-
|
|
360
|
+
this.setCustomValidityInternal(message);
|
|
361
|
+
// 外部调用 setCustomValidity 时,不再使用内置的验证规则,所以需要移除监听语言变更事件
|
|
362
|
+
offLocaleReady(this);
|
|
359
363
|
}
|
|
360
364
|
firstUpdated(_changedProperties) {
|
|
361
365
|
super.firstUpdated(_changedProperties);
|
|
@@ -388,6 +392,11 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
388
392
|
? this.renderTextArea(hasInputSlot)
|
|
389
393
|
: this.renderInput(hasInputSlot)} ${when(hasInputSlot, () => html `<slot name="input" class="input"></slot>`)}</div>${this.renderClearButton()}${this.renderTogglePasswordButton()} ${this.renderSuffix(hasErrorIcon)}</div>${when(hasError || hasHelper || hasCounter, () => html `<div part="supporting" class="${classMap({ supporting: true, ...invalidClassNameObj })}">${this.renderHelper(hasError, hasHelper)} ${this.renderCounter(hasCounter)}</div>`)}`;
|
|
390
394
|
}
|
|
395
|
+
setCustomValidityInternal(message) {
|
|
396
|
+
this.inputRef.value.setCustomValidity(message);
|
|
397
|
+
this.invalid = !this.inputRef.value.checkValidity();
|
|
398
|
+
this.requestUpdate();
|
|
399
|
+
}
|
|
391
400
|
onChange() {
|
|
392
401
|
this.value = this.inputRef.value.value;
|
|
393
402
|
if (this.isTextarea) {
|
|
@@ -431,12 +440,26 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
431
440
|
if (this.pattern) {
|
|
432
441
|
const patternRegex = new RegExp(this.pattern);
|
|
433
442
|
const hasError = this.value && !this.value.match(patternRegex);
|
|
434
|
-
|
|
443
|
+
if (hasError) {
|
|
444
|
+
this.setCustomValidityInternal(this.getPatternErrorMsg());
|
|
445
|
+
onLocaleReady(this, () => {
|
|
446
|
+
this.setCustomValidityInternal(this.getPatternErrorMsg());
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
this.setCustomValidityInternal('');
|
|
451
|
+
offLocaleReady(this);
|
|
452
|
+
}
|
|
435
453
|
}
|
|
436
454
|
}
|
|
437
455
|
onTogglePassword() {
|
|
438
456
|
this.isPasswordVisible = !this.isPasswordVisible;
|
|
439
457
|
}
|
|
458
|
+
getPatternErrorMsg() {
|
|
459
|
+
return msg('Please match the requested format.', {
|
|
460
|
+
id: 'components.textField.patternError',
|
|
461
|
+
});
|
|
462
|
+
}
|
|
440
463
|
setTextareaHeight() {
|
|
441
464
|
if (this.autosize) {
|
|
442
465
|
this.inputRef.value.style.height = 'auto';
|
package/custom-elements.json
CHANGED
|
@@ -19517,10 +19517,82 @@
|
|
|
19517
19517
|
"description": "",
|
|
19518
19518
|
"name": "Select",
|
|
19519
19519
|
"cssParts": [
|
|
19520
|
+
{
|
|
19521
|
+
"description": "多选时,放置选中值对应的 chip 的容器",
|
|
19522
|
+
"name": "chips"
|
|
19523
|
+
},
|
|
19524
|
+
{
|
|
19525
|
+
"description": "多选时,每一个选中的值对应的 chip",
|
|
19526
|
+
"name": "chip"
|
|
19527
|
+
},
|
|
19528
|
+
{
|
|
19529
|
+
"description": "chip 内部的 `<button>` 元素",
|
|
19530
|
+
"name": "chip__button"
|
|
19531
|
+
},
|
|
19532
|
+
{
|
|
19533
|
+
"description": "chip 内部的文本",
|
|
19534
|
+
"name": "chip__label"
|
|
19535
|
+
},
|
|
19536
|
+
{
|
|
19537
|
+
"description": "chip 内部的删除图标",
|
|
19538
|
+
"name": "chip__delete-icon"
|
|
19539
|
+
},
|
|
19520
19540
|
{
|
|
19521
19541
|
"description": "文本框,即 [`<mdui-text-field>`](/docs/2/components/text-field) 元素",
|
|
19522
19542
|
"name": "text-field"
|
|
19523
19543
|
},
|
|
19544
|
+
{
|
|
19545
|
+
"description": "text-field 内部的文本框容器",
|
|
19546
|
+
"name": "text-field__container"
|
|
19547
|
+
},
|
|
19548
|
+
{
|
|
19549
|
+
"description": "text-field 内部的左侧图标",
|
|
19550
|
+
"name": "text-field__icon"
|
|
19551
|
+
},
|
|
19552
|
+
{
|
|
19553
|
+
"description": "text-field 内部的右侧图标",
|
|
19554
|
+
"name": "text-field__end-icon"
|
|
19555
|
+
},
|
|
19556
|
+
{
|
|
19557
|
+
"description": "text-field 内部的验证失败状态的右侧图标",
|
|
19558
|
+
"name": "text-field__error-icon"
|
|
19559
|
+
},
|
|
19560
|
+
{
|
|
19561
|
+
"description": "text-field 内部的左侧文本",
|
|
19562
|
+
"name": "text-field__prefix"
|
|
19563
|
+
},
|
|
19564
|
+
{
|
|
19565
|
+
"description": "text-field 内部的右侧文本",
|
|
19566
|
+
"name": "text-field__suffix"
|
|
19567
|
+
},
|
|
19568
|
+
{
|
|
19569
|
+
"description": "text-field 内部的标签文本",
|
|
19570
|
+
"name": "text-field__label"
|
|
19571
|
+
},
|
|
19572
|
+
{
|
|
19573
|
+
"description": "text-field 内部的 `<input>` 元素",
|
|
19574
|
+
"name": "text-field__input"
|
|
19575
|
+
},
|
|
19576
|
+
{
|
|
19577
|
+
"description": "text-field 内部的清空按钮",
|
|
19578
|
+
"name": "text-field__clear-button"
|
|
19579
|
+
},
|
|
19580
|
+
{
|
|
19581
|
+
"description": "text-field 内部的清空按钮中的图标",
|
|
19582
|
+
"name": "text-field__clear-icon"
|
|
19583
|
+
},
|
|
19584
|
+
{
|
|
19585
|
+
"description": "text-field 内部的底部辅助信息容器,包括 helper 和 error",
|
|
19586
|
+
"name": "text-field__supporting"
|
|
19587
|
+
},
|
|
19588
|
+
{
|
|
19589
|
+
"description": "text-field 内部的底部帮助文本",
|
|
19590
|
+
"name": "text-field__helper"
|
|
19591
|
+
},
|
|
19592
|
+
{
|
|
19593
|
+
"description": "text-field 内部的底部错误描述文本",
|
|
19594
|
+
"name": "text-field__error"
|
|
19595
|
+
},
|
|
19524
19596
|
{
|
|
19525
19597
|
"description": "下拉菜单,即 [`<mdui-menu>`](/docs/2/components/menu) 元素",
|
|
19526
19598
|
"name": "menu"
|
|
@@ -25281,6 +25353,24 @@
|
|
|
25281
25353
|
],
|
|
25282
25354
|
"description": "设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证"
|
|
25283
25355
|
},
|
|
25356
|
+
{
|
|
25357
|
+
"kind": "method",
|
|
25358
|
+
"name": "setCustomValidityInternal",
|
|
25359
|
+
"privacy": "private",
|
|
25360
|
+
"return": {
|
|
25361
|
+
"type": {
|
|
25362
|
+
"text": "void"
|
|
25363
|
+
}
|
|
25364
|
+
},
|
|
25365
|
+
"parameters": [
|
|
25366
|
+
{
|
|
25367
|
+
"name": "message",
|
|
25368
|
+
"type": {
|
|
25369
|
+
"text": "string"
|
|
25370
|
+
}
|
|
25371
|
+
}
|
|
25372
|
+
]
|
|
25373
|
+
},
|
|
25284
25374
|
{
|
|
25285
25375
|
"kind": "method",
|
|
25286
25376
|
"name": "onChange",
|
|
@@ -25341,6 +25431,11 @@
|
|
|
25341
25431
|
"name": "onTogglePassword",
|
|
25342
25432
|
"privacy": "private"
|
|
25343
25433
|
},
|
|
25434
|
+
{
|
|
25435
|
+
"kind": "method",
|
|
25436
|
+
"name": "getPatternErrorMsg",
|
|
25437
|
+
"privacy": "private"
|
|
25438
|
+
},
|
|
25344
25439
|
{
|
|
25345
25440
|
"kind": "method",
|
|
25346
25441
|
"name": "setTextareaHeight",
|
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.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 { 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.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 { 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"];
|