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
|
@@ -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);
|
|
@@ -384,25 +388,14 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
384
388
|
'is-firefox': navigator.userAgent.includes('Firefox'),
|
|
385
389
|
...invalidClassNameObj,
|
|
386
390
|
});
|
|
387
|
-
return html `<div part="container" class
|
|
388
|
-
${this.renderPrefix()}
|
|
389
|
-
<div class="input-container">
|
|
390
|
-
${this.renderLabel()}
|
|
391
|
-
${this.isTextarea
|
|
391
|
+
return html `<div part="container" class="${className}">${this.renderPrefix()}<div class="input-container">${this.renderLabel()} ${this.isTextarea
|
|
392
392
|
? this.renderTextArea(hasInputSlot)
|
|
393
|
-
: this.renderInput(hasInputSlot)}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
${when(hasError || hasHelper || hasCounter, () => html `<div
|
|
400
|
-
part="supporting"
|
|
401
|
-
class=${classMap({ supporting: true, ...invalidClassNameObj })}
|
|
402
|
-
>
|
|
403
|
-
${this.renderHelper(hasError, hasHelper)}
|
|
404
|
-
${this.renderCounter(hasCounter)}
|
|
405
|
-
</div>`)}`;
|
|
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>`)}`;
|
|
394
|
+
}
|
|
395
|
+
setCustomValidityInternal(message) {
|
|
396
|
+
this.inputRef.value.setCustomValidity(message);
|
|
397
|
+
this.invalid = !this.inputRef.value.checkValidity();
|
|
398
|
+
this.requestUpdate();
|
|
406
399
|
}
|
|
407
400
|
onChange() {
|
|
408
401
|
this.value = this.inputRef.value.value;
|
|
@@ -447,12 +440,26 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
447
440
|
if (this.pattern) {
|
|
448
441
|
const patternRegex = new RegExp(this.pattern);
|
|
449
442
|
const hasError = this.value && !this.value.match(patternRegex);
|
|
450
|
-
|
|
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
|
+
}
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
onTogglePassword() {
|
|
454
456
|
this.isPasswordVisible = !this.isPasswordVisible;
|
|
455
457
|
}
|
|
458
|
+
getPatternErrorMsg() {
|
|
459
|
+
return msg('Please match the requested format.', {
|
|
460
|
+
id: 'components.textField.patternError',
|
|
461
|
+
});
|
|
462
|
+
}
|
|
456
463
|
setTextareaHeight() {
|
|
457
464
|
if (this.autosize) {
|
|
458
465
|
this.inputRef.value.style.height = 'auto';
|
|
@@ -464,168 +471,62 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
464
471
|
}
|
|
465
472
|
renderLabel() {
|
|
466
473
|
return this.label
|
|
467
|
-
? html `<label
|
|
468
|
-
part="label"
|
|
469
|
-
class="label"
|
|
470
|
-
${animate({
|
|
474
|
+
? html `<label part="label" class="label" ${animate({
|
|
471
475
|
keyframeOptions: {
|
|
472
476
|
duration: getDuration(this, 'short4'),
|
|
473
477
|
easing: getEasing(this, 'standard'),
|
|
474
478
|
},
|
|
475
|
-
})}
|
|
476
|
-
>
|
|
477
|
-
${this.label}
|
|
478
|
-
</label>`
|
|
479
|
+
})}>${this.label}</label>`
|
|
479
480
|
: nothingTemplate;
|
|
480
481
|
}
|
|
481
482
|
renderPrefix() {
|
|
482
|
-
return html `<slot name="icon" part="icon" class="icon"
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
: nothingTemplate}
|
|
486
|
-
</slot>
|
|
487
|
-
<slot name="prefix" part="prefix" class="prefix">${this.prefix}</slot>`;
|
|
483
|
+
return html `<slot name="icon" part="icon" class="icon">${this.icon
|
|
484
|
+
? html `<mdui-icon name="${this.icon}" class="i"></mdui-icon>`
|
|
485
|
+
: nothingTemplate}</slot><slot name="prefix" part="prefix" class="prefix">${this.prefix}</slot>`;
|
|
488
486
|
}
|
|
489
487
|
renderSuffix(hasErrorIcon) {
|
|
490
|
-
return html `<slot name="suffix" part="suffix" class="suffix"
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
: html `<mdui-icon-error class="i"></mdui-icon-error>`}
|
|
498
|
-
</slot>`
|
|
499
|
-
: html `<slot
|
|
500
|
-
name="end-icon"
|
|
501
|
-
part="end-icon"
|
|
502
|
-
class="end-icon right-icon"
|
|
503
|
-
>
|
|
504
|
-
${this.endIcon
|
|
505
|
-
? html `<mdui-icon name=${this.endIcon} class="i"></mdui-icon>`
|
|
506
|
-
: nothingTemplate}
|
|
507
|
-
</slot>`}`;
|
|
488
|
+
return html `<slot name="suffix" part="suffix" class="suffix">${this.suffix}</slot>${hasErrorIcon
|
|
489
|
+
? html `<slot name="error-icon" part="error-icon" class="right-icon">${this.errorIcon
|
|
490
|
+
? html `<mdui-icon name="${this.errorIcon}" class="i"></mdui-icon>`
|
|
491
|
+
: html `<mdui-icon-error class="i"></mdui-icon-error>`}</slot>`
|
|
492
|
+
: html `<slot name="end-icon" part="end-icon" class="end-icon right-icon">${this.endIcon
|
|
493
|
+
? html `<mdui-icon name="${this.endIcon}" class="i"></mdui-icon>`
|
|
494
|
+
: nothingTemplate}</slot>`}`;
|
|
508
495
|
}
|
|
509
496
|
renderClearButton() {
|
|
510
497
|
const hasClearButton = this.clearable &&
|
|
511
498
|
!this.disabled &&
|
|
512
499
|
(!this.readonly || this.readonlyButClearable) &&
|
|
513
500
|
(typeof this.value === 'number' || this.value.length > 0);
|
|
514
|
-
return when(hasClearButton, () => html `<slot
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
class="right-icon"
|
|
518
|
-
@click=${this.onClear}
|
|
519
|
-
>
|
|
520
|
-
<mdui-button-icon tabindex="-1">
|
|
521
|
-
<slot name="clear-icon" part="clear-icon">
|
|
522
|
-
${this.clearIcon
|
|
523
|
-
? html `<mdui-icon name=${this.clearIcon} class="i"></mdui-icon>`
|
|
524
|
-
: html `<mdui-icon-cancel--outlined
|
|
525
|
-
class="i"
|
|
526
|
-
></mdui-icon-cancel--outlined>`}
|
|
527
|
-
</slot>
|
|
528
|
-
</mdui-button-icon>
|
|
529
|
-
</slot>`);
|
|
501
|
+
return when(hasClearButton, () => html `<slot name="clear-button" part="clear-button" class="right-icon" @click="${this.onClear}"><mdui-button-icon tabindex="-1"><slot name="clear-icon" part="clear-icon">${this.clearIcon
|
|
502
|
+
? html `<mdui-icon name="${this.clearIcon}" class="i"></mdui-icon>`
|
|
503
|
+
: html `<mdui-icon-cancel--outlined class="i"></mdui-icon-cancel--outlined>`}</slot></mdui-button-icon></slot>`);
|
|
530
504
|
}
|
|
531
505
|
renderTogglePasswordButton() {
|
|
532
506
|
const hasTogglePasswordButton = this.type === 'password' && this.togglePassword && !this.disabled;
|
|
533
|
-
return when(hasTogglePasswordButton, () => html `<slot
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
${this.isPasswordVisible
|
|
541
|
-
? html `<slot name="show-password-icon" part="show-password-icon">
|
|
542
|
-
${this.showPasswordIcon
|
|
543
|
-
? html `<mdui-icon
|
|
544
|
-
name=${this.showPasswordIcon}
|
|
545
|
-
class="i"
|
|
546
|
-
></mdui-icon>`
|
|
547
|
-
: html `<mdui-icon-visibility-off
|
|
548
|
-
class="i"
|
|
549
|
-
></mdui-icon-visibility-off>`}
|
|
550
|
-
</slot>`
|
|
551
|
-
: html `<slot name="hide-password-icon" part="hide-password-icon">
|
|
552
|
-
${this.hidePasswordIcon
|
|
553
|
-
? html `<mdui-icon
|
|
554
|
-
name=${this.hidePasswordIcon}
|
|
555
|
-
class="i"
|
|
556
|
-
></mdui-icon>`
|
|
557
|
-
: html `<mdui-icon-visibility
|
|
558
|
-
class="i"
|
|
559
|
-
></mdui-icon-visibility>`}
|
|
560
|
-
</slot>`}
|
|
561
|
-
</mdui-button-icon>
|
|
562
|
-
</slot>`);
|
|
507
|
+
return when(hasTogglePasswordButton, () => html `<slot name="toggle-password-button" part="toggle-password-button" class="right-icon" @click="${this.onTogglePassword}"><mdui-button-icon tabindex="-1">${this.isPasswordVisible
|
|
508
|
+
? html `<slot name="show-password-icon" part="show-password-icon">${this.showPasswordIcon
|
|
509
|
+
? html `<mdui-icon name="${this.showPasswordIcon}" class="i"></mdui-icon>`
|
|
510
|
+
: html `<mdui-icon-visibility-off class="i"></mdui-icon-visibility-off>`}</slot>`
|
|
511
|
+
: html `<slot name="hide-password-icon" part="hide-password-icon">${this.hidePasswordIcon
|
|
512
|
+
? html `<mdui-icon name="${this.hidePasswordIcon}" class="i"></mdui-icon>`
|
|
513
|
+
: html `<mdui-icon-visibility class="i"></mdui-icon-visibility>`}</slot>`}</mdui-button-icon></slot>`);
|
|
563
514
|
}
|
|
564
515
|
renderInput(hasInputSlot) {
|
|
565
|
-
return html `<input
|
|
566
|
-
${ref(this.inputRef)}
|
|
567
|
-
part="input"
|
|
568
|
-
class="input ${classMap({ 'hide-input': hasInputSlot })}"
|
|
569
|
-
type=${this.type === 'password' && this.isPasswordVisible
|
|
516
|
+
return html `<input ${ref(this.inputRef)} part="input" class="input ${classMap({ 'hide-input': hasInputSlot })}" type="${this.type === 'password' && this.isPasswordVisible
|
|
570
517
|
? 'text'
|
|
571
|
-
: this.type}
|
|
572
|
-
name=${ifDefined(this.name)}
|
|
573
|
-
.value=${live(this.value)}
|
|
574
|
-
placeholder=${ifDefined(
|
|
518
|
+
: this.type}" name="${ifDefined(this.name)}" .value="${live(this.value)}" placeholder="${ifDefined(
|
|
575
519
|
// @ts-ignore
|
|
576
520
|
!this.label || this.isFocusedStyle || this.hasValue
|
|
577
521
|
? this.placeholder
|
|
578
|
-
: undefined)}
|
|
579
|
-
?readonly=${this.readonly}
|
|
580
|
-
?disabled=${this.disabled}
|
|
581
|
-
?required=${this.required}
|
|
582
|
-
minlength=${ifDefined(this.minlength)}
|
|
583
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
584
|
-
min=${ifDefined(this.min)}
|
|
585
|
-
max=${ifDefined(this.max)}
|
|
586
|
-
step=${ifDefined(this.step)}
|
|
587
|
-
autocapitalize=${ifDefined(this.type === 'password' ? 'off' : this.autocapitalize)}
|
|
588
|
-
autocomplete=${ifDefined(this.type === 'password' ? 'off' : this.autocomplete)}
|
|
589
|
-
autocorrect=${ifDefined(this.type === 'password' ? 'off' : this.autocorrect)}
|
|
590
|
-
spellcheck=${ifDefined(this.spellcheck)}
|
|
591
|
-
pattern=${ifDefined(this.pattern)}
|
|
592
|
-
enterkeyhint=${ifDefined(this.enterkeyhint)}
|
|
593
|
-
inputmode=${ifDefined(this.inputmode)}
|
|
594
|
-
@change=${this.onChange}
|
|
595
|
-
@input=${this.onInput}
|
|
596
|
-
@invalid=${this.onInvalid}
|
|
597
|
-
@keydown=${this.onKeyDown}
|
|
598
|
-
/>`;
|
|
522
|
+
: undefined)}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ?required="${this.required}" minlength="${ifDefined(this.minlength)}" maxlength="${ifDefined(this.maxlength)}" min="${ifDefined(this.min)}" max="${ifDefined(this.max)}" step="${ifDefined(this.step)}" autocapitalize="${ifDefined(this.type === 'password' ? 'off' : this.autocapitalize)}" autocomplete="${ifDefined(this.type === 'password' ? 'off' : this.autocomplete)}" autocorrect="${ifDefined(this.type === 'password' ? 'off' : this.autocorrect)}" spellcheck="${ifDefined(this.spellcheck)}" pattern="${ifDefined(this.pattern)}" enterkeyhint="${ifDefined(this.enterkeyhint)}" inputmode="${ifDefined(this.inputmode)}" @change="${this.onChange}" @input="${this.onInput}" @invalid="${this.onInvalid}" @keydown="${this.onKeyDown}">`;
|
|
599
523
|
}
|
|
600
524
|
renderTextArea(hasInputSlot) {
|
|
601
|
-
return html `<textarea
|
|
602
|
-
${ref(this.inputRef)}
|
|
603
|
-
part="input"
|
|
604
|
-
class="input ${classMap({ 'hide-input': hasInputSlot })}"
|
|
605
|
-
name=${ifDefined(this.name)}
|
|
606
|
-
.value=${live(this.value)}
|
|
607
|
-
placeholder=${ifDefined(
|
|
525
|
+
return html `<textarea ${ref(this.inputRef)} part="input" class="input ${classMap({ 'hide-input': hasInputSlot })}" name="${ifDefined(this.name)}" .value="${live(this.value)}" placeholder="${ifDefined(
|
|
608
526
|
// @ts-ignore
|
|
609
527
|
!this.label || this.isFocusedStyle || this.hasValue
|
|
610
528
|
? this.placeholder
|
|
611
|
-
: undefined)}
|
|
612
|
-
?readonly=${this.readonly}
|
|
613
|
-
?disabled=${this.disabled}
|
|
614
|
-
?required=${this.required}
|
|
615
|
-
minlength=${ifDefined(this.minlength)}
|
|
616
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
617
|
-
rows=${this.rows ?? 1}
|
|
618
|
-
autocapitalize=${ifDefined(this.autocapitalize)}
|
|
619
|
-
autocorrect=${ifDefined(this.autocorrect)}
|
|
620
|
-
spellcheck=${ifDefined(this.spellcheck)}
|
|
621
|
-
enterkeyhint=${ifDefined(this.enterkeyhint)}
|
|
622
|
-
inputmode=${ifDefined(this.inputmode)}
|
|
623
|
-
@change=${this.onChange}
|
|
624
|
-
@input=${this.onInput}
|
|
625
|
-
@invalid=${this.onInvalid}
|
|
626
|
-
@keydown=${this.onKeyDown}
|
|
627
|
-
@keyup=${this.onTextAreaKeyUp}
|
|
628
|
-
></textarea>`;
|
|
529
|
+
: undefined)}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ?required="${this.required}" minlength="${ifDefined(this.minlength)}" maxlength="${ifDefined(this.maxlength)}" rows="${this.rows ?? 1}" autocapitalize="${ifDefined(this.autocapitalize)}" autocorrect="${ifDefined(this.autocorrect)}" spellcheck="${ifDefined(this.spellcheck)}" enterkeyhint="${ifDefined(this.enterkeyhint)}" inputmode="${ifDefined(this.inputmode)}" @change="${this.onChange}" @input="${this.onInput}" @invalid="${this.onInvalid}" @keydown="${this.onKeyDown}" @keyup="${this.onTextAreaKeyUp}"></textarea>`;
|
|
629
530
|
}
|
|
630
531
|
/**
|
|
631
532
|
* @param hasError 是否包含错误提示
|
|
@@ -633,21 +534,15 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
633
534
|
*/
|
|
634
535
|
renderHelper(hasError, hasHelper) {
|
|
635
536
|
return hasError
|
|
636
|
-
? html `<div part="error" class="error"
|
|
637
|
-
${this.error || this.inputRef.value.validationMessage}
|
|
638
|
-
</div>`
|
|
537
|
+
? html `<div part="error" class="error">${this.error || this.inputRef.value.validationMessage}</div>`
|
|
639
538
|
: hasHelper
|
|
640
|
-
? html `<slot name="helper" part="helper" class="helper"
|
|
641
|
-
${this.helper}
|
|
642
|
-
</slot>`
|
|
539
|
+
? html `<slot name="helper" part="helper" class="helper">${this.helper}</slot>`
|
|
643
540
|
: // 右边有 counter,需要占位
|
|
644
541
|
html `<span></span>`;
|
|
645
542
|
}
|
|
646
543
|
renderCounter(hasCounter) {
|
|
647
544
|
return hasCounter
|
|
648
|
-
? html `<div part="counter" class="counter"
|
|
649
|
-
${this.value.length}/${this.maxlength}
|
|
650
|
-
</div>`
|
|
545
|
+
? html `<div part="counter" class="counter">${this.value.length}/${this.maxlength}</div>`
|
|
651
546
|
: nothingTemplate;
|
|
652
547
|
}
|
|
653
548
|
};
|