mdui 2.0.3 → 2.0.5
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.d.ts +13 -13
- package/components/avatar/index.js +11 -6
- package/components/avatar/style.js +31 -1
- package/components/badge/index.d.ts +7 -6
- package/components/badge/index.js +6 -5
- package/components/badge/style.js +25 -1
- package/components/bottom-app-bar/index.d.ts +4 -3
- package/components/bottom-app-bar/index.js +3 -3
- package/components/bottom-app-bar/style.js +92 -1
- package/components/button/button-base-style.js +28 -1
- package/components/button/button-base.d.ts +43 -44
- package/components/button/button-base.js +28 -21
- package/components/button/index.d.ts +13 -13
- package/components/button/index.js +30 -20
- package/components/button/style.js +111 -2
- package/components/button-icon/index.d.ts +8 -8
- package/components/button-icon/index.js +29 -12
- package/components/button-icon/style.js +103 -2
- package/components/card/index.d.ts +8 -8
- package/components/card/index.js +12 -8
- package/components/card/style.js +72 -1
- package/components/checkbox/index.d.ts +20 -20
- package/components/checkbox/index.js +68 -25
- package/components/checkbox/style.js +131 -1
- package/components/chip/index.d.ts +19 -19
- package/components/chip/index.js +49 -25
- package/components/chip/style.js +205 -2
- package/components/circular-progress/index.d.ts +2 -2
- package/components/circular-progress/index.js +40 -6
- package/components/circular-progress/style.js +136 -1
- package/components/collapse/collapse-item-style.js +21 -1
- package/components/collapse/collapse-item.d.ts +4 -4
- package/components/collapse/collapse-item.js +12 -4
- package/components/collapse/collapse-style.js +5 -1
- package/components/collapse/collapse.d.ts +6 -9
- package/components/collapse/collapse.js +8 -5
- package/components/dialog/index.d.ts +13 -13
- package/components/dialog/index.js +48 -20
- package/components/dialog/style.js +116 -1
- package/components/divider/index.d.ts +3 -3
- package/components/divider/index.js +3 -3
- package/components/divider/style.js +18 -1
- package/components/dropdown/index.d.ts +35 -35
- package/components/dropdown/index.js +41 -34
- package/components/dropdown/style.js +11 -1
- package/components/fab/index.d.ts +6 -6
- package/components/fab/index.js +19 -11
- package/components/fab/style.js +153 -4
- package/components/icon/index.js +5 -1
- package/components/icon/style.js +29 -1
- package/components/layout/layout-item-style.js +6 -1
- package/components/layout/layout-item.d.ts +7 -7
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main-style.js +7 -1
- package/components/layout/layout-main.d.ts +2 -2
- package/components/layout/layout-main.js +2 -2
- package/components/layout/layout-style.js +11 -1
- package/components/layout/layout.d.ts +2 -2
- package/components/layout/layout.js +2 -2
- package/components/linear-progress/index.d.ts +4 -4
- package/components/linear-progress/index.js +9 -5
- package/components/linear-progress/style.js +73 -1
- package/components/list/list-item-style.js +153 -2
- package/components/list/list-item.d.ts +17 -17
- package/components/list/list-item.js +34 -15
- package/components/list/list-style.js +10 -1
- package/components/list/list-subheader-style.js +19 -1
- package/components/list/list-subheader.d.ts +2 -2
- package/components/list/list-subheader.js +2 -2
- package/components/list/list.d.ts +1 -1
- package/components/list/list.js +1 -1
- package/components/menu/menu-item-style.js +125 -1
- package/components/menu/menu-item.d.ts +4 -4
- package/components/menu/menu-item.js +57 -15
- package/components/menu/menu-style.js +19 -1
- package/components/menu/menu.d.ts +15 -18
- package/components/menu/menu.js +13 -9
- package/components/navigation-bar/navigation-bar-item-style.js +132 -1
- package/components/navigation-bar/navigation-bar-item.d.ts +5 -5
- package/components/navigation-bar/navigation-bar-item.js +27 -11
- package/components/navigation-bar/navigation-bar-style.js +28 -1
- package/components/navigation-bar/navigation-bar.d.ts +9 -8
- package/components/navigation-bar/navigation-bar.js +10 -7
- package/components/navigation-drawer/index.d.ts +19 -20
- package/components/navigation-drawer/index.js +56 -31
- package/components/navigation-drawer/style.js +66 -1
- package/components/navigation-rail/navigation-rail-item-style.js +122 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +6 -6
- package/components/navigation-rail/navigation-rail-item.js +30 -11
- package/components/navigation-rail/navigation-rail-style.js +79 -1
- package/components/navigation-rail/navigation-rail.d.ts +10 -11
- package/components/navigation-rail/navigation-rail.js +19 -11
- package/components/radio/radio-group-style.js +20 -1
- package/components/radio/radio-group.d.ts +13 -13
- package/components/radio/radio-group.js +30 -12
- package/components/radio/radio-style.js +107 -1
- package/components/radio/radio.d.ts +3 -3
- package/components/radio/radio.js +26 -8
- package/components/range-slider/index.d.ts +5 -6
- package/components/range-slider/index.js +57 -10
- package/components/ripple/index.js +5 -2
- package/components/ripple/style.js +96 -1
- package/components/segmented-button/segmented-button-group-style.js +28 -1
- package/components/segmented-button/segmented-button-group.d.ts +17 -20
- package/components/segmented-button/segmented-button-group.js +32 -15
- package/components/segmented-button/segmented-button-style.js +81 -2
- package/components/segmented-button/segmented-button.d.ts +3 -3
- package/components/segmented-button/segmented-button.js +30 -14
- package/components/select/index.d.ts +31 -32
- package/components/select/index.js +106 -26
- package/components/select/style.js +27 -1
- package/components/slider/index.d.ts +1 -1
- package/components/slider/index.js +34 -3
- package/components/slider/slider-base-style.js +173 -1
- package/components/slider/slider-base.d.ts +15 -15
- package/components/slider/slider-base.js +19 -14
- package/components/slider/style.js +7 -1
- package/components/snackbar/index.d.ts +21 -21
- package/components/snackbar/index.js +47 -20
- package/components/snackbar/style.js +100 -1
- package/components/switch/index.d.ts +14 -14
- package/components/switch/index.js +51 -17
- package/components/switch/style.js +202 -1
- package/components/tabs/tab-panel-style.js +10 -1
- package/components/tabs/tab-panel.d.ts +3 -3
- package/components/tabs/tab-panel.js +2 -2
- package/components/tabs/tab-style.js +85 -1
- package/components/tabs/tab.d.ts +6 -6
- package/components/tabs/tab.js +29 -9
- package/components/tabs/tabs-style.js +138 -1
- package/components/tabs/tabs.d.ts +19 -19
- package/components/tabs/tabs.js +26 -18
- package/components/text-field/index.d.ts +51 -51
- package/components/text-field/index.js +185 -57
- package/components/text-field/style.js +362 -1
- package/components/tooltip/index.d.ts +31 -31
- package/components/tooltip/index.js +38 -29
- package/components/tooltip/style.js +57 -1
- package/components/top-app-bar/top-app-bar-style.js +78 -1
- package/components/top-app-bar/top-app-bar-title-style.js +81 -1
- package/components/top-app-bar/top-app-bar-title.d.ts +4 -4
- package/components/top-app-bar/top-app-bar-title.js +21 -7
- package/components/top-app-bar/top-app-bar.d.ts +5 -5
- package/components/top-app-bar/top-app-bar.js +4 -4
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +2049 -2049
- package/html-data.en.json +6560 -0
- package/html-data.zh-cn.json +1427 -1433
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/package.json +6 -5
- package/web-types.en.json +11734 -0
- package/web-types.zh-cn.json +3227 -3221
- package/mdui.esm.js +0 -22
- package/mdui.global.js +0 -22
|
@@ -48,9 +48,9 @@ import { style } from './style.js';
|
|
|
48
48
|
* @slot suffix - 右侧文本
|
|
49
49
|
* @slot clear-button - 清空按钮
|
|
50
50
|
* @slot clear-icon - 清空按钮中的图标
|
|
51
|
-
* @slot toggle-password-button -
|
|
52
|
-
* @slot show-password-icon -
|
|
53
|
-
* @slot hide-password-icon -
|
|
51
|
+
* @slot toggle-password-button - 密码显示状态切换按钮
|
|
52
|
+
* @slot show-password-icon - 显示密码状态下,密码显示状态切换按钮中的图标
|
|
53
|
+
* @slot hide-password-icon - 隐藏密码状态下,密码显示状态切换按钮中的图标
|
|
54
54
|
* @slot helper - 底部的帮助文本
|
|
55
55
|
*
|
|
56
56
|
* @csspart container - 文本框容器
|
|
@@ -63,9 +63,9 @@ import { style } from './style.js';
|
|
|
63
63
|
* @csspart input - 内部的 `<input>` 或 `<textarea>` 元素
|
|
64
64
|
* @csspart clear-button - 清空按钮
|
|
65
65
|
* @csspart clear-icon - 清空按钮中的图标
|
|
66
|
-
* @csspart toggle-password-button -
|
|
67
|
-
* @csspart show-password-icon -
|
|
68
|
-
* @csspart hide-password-icon -
|
|
66
|
+
* @csspart toggle-password-button - 密码显示状态切换按钮
|
|
67
|
+
* @csspart show-password-icon - 显示密码状态下,密码显示状态切换按钮中的图标
|
|
68
|
+
* @csspart hide-password-icon - 隐藏密码状态下,密码显示状态切换按钮中的图标
|
|
69
69
|
* @csspart supporting - 底部辅助信息容器,包括 helper、error、counter
|
|
70
70
|
* @csspart helper - 底部的帮助文本
|
|
71
71
|
* @csspart error - 底部的错误描述文本
|
|
@@ -75,14 +75,14 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
75
75
|
constructor() {
|
|
76
76
|
super(...arguments);
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* 文本框的形状。默认为 `filled`。可选值包括:
|
|
79
79
|
*
|
|
80
80
|
* * `filled`:带背景色的文本框,视觉效果较强
|
|
81
81
|
* * `outlined`:带边框的文本框,视觉效果较弱
|
|
82
82
|
*/
|
|
83
83
|
this.variant = 'filled';
|
|
84
84
|
/**
|
|
85
|
-
* 文本框输入类型。默认为 `text
|
|
85
|
+
* 文本框输入类型。默认为 `text`。可选值包括:
|
|
86
86
|
*
|
|
87
87
|
* * `text`:默认值。文本字段
|
|
88
88
|
* * `number`:只能输入数字。拥有动态键盘的设备上会显示数字键盘
|
|
@@ -112,23 +112,23 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
112
112
|
*/
|
|
113
113
|
this.defaultValue = '';
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
115
|
+
* 是否仅在获得焦点时,显示底部的帮助文本
|
|
116
116
|
*/
|
|
117
117
|
this.helperOnFocus = false;
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
119
|
+
* 是否可清空文本框内容
|
|
120
120
|
*/
|
|
121
121
|
this.clearable = false;
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* 是否将文本右对齐
|
|
124
124
|
*/
|
|
125
125
|
this.endAligned = false;
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* 是否为只读模式
|
|
128
128
|
*/
|
|
129
129
|
this.readonly = false;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* 是否禁用输入框
|
|
132
132
|
*/
|
|
133
133
|
this.disabled = false;
|
|
134
134
|
/**
|
|
@@ -136,19 +136,19 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
136
136
|
*/
|
|
137
137
|
this.required = false;
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* 是否根据输入内容自动调整文本框高度
|
|
140
140
|
*/
|
|
141
141
|
this.autosize = false;
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* 是否显示字数统计,只在 `maxlength` 被指定时有效
|
|
144
144
|
*/
|
|
145
145
|
this.counter = false;
|
|
146
146
|
/**
|
|
147
|
-
* `type` 为 `password`
|
|
147
|
+
* `type` 为 `password` 时,设置此属性会添加一个切换按钮,用于在明文和密文之间切换
|
|
148
148
|
*/
|
|
149
149
|
this.togglePassword = false;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* 是否启用拼写检查
|
|
152
152
|
*/
|
|
153
153
|
this.spellcheck = false;
|
|
154
154
|
/**
|
|
@@ -184,13 +184,13 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
184
184
|
this.readonlyButClearable = false;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
187
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
188
188
|
*/
|
|
189
189
|
get validity() {
|
|
190
190
|
return this.inputRef.value.validity;
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
|
-
*
|
|
193
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
194
194
|
*/
|
|
195
195
|
get validationMessage() {
|
|
196
196
|
return this.inputRef.value.validationMessage;
|
|
@@ -298,7 +298,7 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
298
298
|
this.inputRef.value.setSelectionRange(start, end, direction);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
|
-
*
|
|
301
|
+
* 将文本框中特定范围的文本替换为新的文本
|
|
302
302
|
* @param replacement 要插入的字符串
|
|
303
303
|
* @param start 要替换的字符的起止位置的索引。默认为当前用户选中的字符的起始位置的索引
|
|
304
304
|
* @param end 要替换的字符的结束位置的索引。默认为当前用户选中的字符的结束位置的索引
|
|
@@ -318,7 +318,7 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
|
-
*
|
|
321
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
322
322
|
*/
|
|
323
323
|
checkValidity() {
|
|
324
324
|
const valid = this.inputRef.value.checkValidity();
|
|
@@ -332,9 +332,9 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
332
332
|
return valid;
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
|
-
*
|
|
335
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
336
336
|
*
|
|
337
|
-
*
|
|
337
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
338
338
|
*/
|
|
339
339
|
reportValidity() {
|
|
340
340
|
this.invalid = !this.inputRef.value.reportValidity();
|
|
@@ -349,9 +349,9 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
349
349
|
return !this.invalid;
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
|
-
*
|
|
352
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
353
353
|
*
|
|
354
|
-
* @param message
|
|
354
|
+
* @param message 自定义的错误提示文本
|
|
355
355
|
*/
|
|
356
356
|
setCustomValidity(message) {
|
|
357
357
|
this.inputRef.value.setCustomValidity(message);
|
|
@@ -384,9 +384,25 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
384
384
|
'is-firefox': navigator.userAgent.includes('Firefox'),
|
|
385
385
|
...invalidClassNameObj,
|
|
386
386
|
});
|
|
387
|
-
return html `<div part="container" class
|
|
387
|
+
return html `<div part="container" class=${className}>
|
|
388
|
+
${this.renderPrefix()}
|
|
389
|
+
<div class="input-container">
|
|
390
|
+
${this.renderLabel()}
|
|
391
|
+
${this.isTextarea
|
|
388
392
|
? this.renderTextArea(hasInputSlot)
|
|
389
|
-
: this.renderInput(hasInputSlot)}
|
|
393
|
+
: this.renderInput(hasInputSlot)}
|
|
394
|
+
${when(hasInputSlot, () => html `<slot name="input" class="input"></slot>`)}
|
|
395
|
+
</div>
|
|
396
|
+
${this.renderClearButton()}${this.renderTogglePasswordButton()}
|
|
397
|
+
${this.renderSuffix(hasErrorIcon)}
|
|
398
|
+
</div>
|
|
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>`)}`;
|
|
390
406
|
}
|
|
391
407
|
onChange() {
|
|
392
408
|
this.value = this.inputRef.value.value;
|
|
@@ -448,62 +464,168 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
448
464
|
}
|
|
449
465
|
renderLabel() {
|
|
450
466
|
return this.label
|
|
451
|
-
? html `<label
|
|
467
|
+
? html `<label
|
|
468
|
+
part="label"
|
|
469
|
+
class="label"
|
|
470
|
+
${animate({
|
|
452
471
|
keyframeOptions: {
|
|
453
472
|
duration: getDuration(this, 'short4'),
|
|
454
473
|
easing: getEasing(this, 'standard'),
|
|
455
474
|
},
|
|
456
|
-
})}
|
|
475
|
+
})}
|
|
476
|
+
>
|
|
477
|
+
${this.label}
|
|
478
|
+
</label>`
|
|
457
479
|
: nothingTemplate;
|
|
458
480
|
}
|
|
459
481
|
renderPrefix() {
|
|
460
|
-
return html `<slot name="icon" part="icon" class="icon"
|
|
461
|
-
|
|
462
|
-
|
|
482
|
+
return html `<slot name="icon" part="icon" class="icon">
|
|
483
|
+
${this.icon
|
|
484
|
+
? html `<mdui-icon name=${this.icon} class="i"></mdui-icon>`
|
|
485
|
+
: nothingTemplate}
|
|
486
|
+
</slot>
|
|
487
|
+
<slot name="prefix" part="prefix" class="prefix">${this.prefix}</slot>`;
|
|
463
488
|
}
|
|
464
489
|
renderSuffix(hasErrorIcon) {
|
|
465
|
-
return html `<slot name="suffix" part="suffix" class="suffix"
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
490
|
+
return html `<slot name="suffix" part="suffix" class="suffix">
|
|
491
|
+
${this.suffix}
|
|
492
|
+
</slot>
|
|
493
|
+
${hasErrorIcon
|
|
494
|
+
? html `<slot name="error-icon" part="error-icon" class="right-icon">
|
|
495
|
+
${this.errorIcon
|
|
496
|
+
? html `<mdui-icon name=${this.errorIcon} class="i"></mdui-icon>`
|
|
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>`}`;
|
|
472
508
|
}
|
|
473
509
|
renderClearButton() {
|
|
474
510
|
const hasClearButton = this.clearable &&
|
|
475
511
|
!this.disabled &&
|
|
476
512
|
(!this.readonly || this.readonlyButClearable) &&
|
|
477
513
|
(typeof this.value === 'number' || this.value.length > 0);
|
|
478
|
-
return when(hasClearButton, () => html `<slot
|
|
479
|
-
|
|
480
|
-
|
|
514
|
+
return when(hasClearButton, () => html `<slot
|
|
515
|
+
name="clear-button"
|
|
516
|
+
part="clear-button"
|
|
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>`);
|
|
481
530
|
}
|
|
482
531
|
renderTogglePasswordButton() {
|
|
483
532
|
const hasTogglePasswordButton = this.type === 'password' && this.togglePassword && !this.disabled;
|
|
484
|
-
return when(hasTogglePasswordButton, () => html `<slot
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
533
|
+
return when(hasTogglePasswordButton, () => html `<slot
|
|
534
|
+
name="toggle-password-button"
|
|
535
|
+
part="toggle-password-button"
|
|
536
|
+
class="right-icon"
|
|
537
|
+
@click=${this.onTogglePassword}
|
|
538
|
+
>
|
|
539
|
+
<mdui-button-icon tabindex="-1">
|
|
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>`);
|
|
491
563
|
}
|
|
492
564
|
renderInput(hasInputSlot) {
|
|
493
|
-
return html `<input
|
|
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
|
|
494
570
|
? 'text'
|
|
495
|
-
: this.type}
|
|
571
|
+
: this.type}
|
|
572
|
+
name=${ifDefined(this.name)}
|
|
573
|
+
.value=${live(this.value)}
|
|
574
|
+
placeholder=${ifDefined(
|
|
496
575
|
// @ts-ignore
|
|
497
576
|
!this.label || this.isFocusedStyle || this.hasValue
|
|
498
577
|
? this.placeholder
|
|
499
|
-
: undefined)}
|
|
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
|
+
/>`;
|
|
500
599
|
}
|
|
501
600
|
renderTextArea(hasInputSlot) {
|
|
502
|
-
return html `<textarea
|
|
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(
|
|
503
608
|
// @ts-ignore
|
|
504
609
|
!this.label || this.isFocusedStyle || this.hasValue
|
|
505
610
|
? this.placeholder
|
|
506
|
-
: undefined)}
|
|
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>`;
|
|
507
629
|
}
|
|
508
630
|
/**
|
|
509
631
|
* @param hasError 是否包含错误提示
|
|
@@ -511,15 +633,21 @@ let TextField = class TextField extends FocusableMixin(MduiElement) {
|
|
|
511
633
|
*/
|
|
512
634
|
renderHelper(hasError, hasHelper) {
|
|
513
635
|
return hasError
|
|
514
|
-
? html `<div part="error" class="error"
|
|
636
|
+
? html `<div part="error" class="error">
|
|
637
|
+
${this.error || this.inputRef.value.validationMessage}
|
|
638
|
+
</div>`
|
|
515
639
|
: hasHelper
|
|
516
|
-
? html `<slot name="helper" part="helper" class="helper"
|
|
640
|
+
? html `<slot name="helper" part="helper" class="helper">
|
|
641
|
+
${this.helper}
|
|
642
|
+
</slot>`
|
|
517
643
|
: // 右边有 counter,需要占位
|
|
518
644
|
html `<span></span>`;
|
|
519
645
|
}
|
|
520
646
|
renderCounter(hasCounter) {
|
|
521
647
|
return hasCounter
|
|
522
|
-
? html `<div part="counter" class="counter"
|
|
648
|
+
? html `<div part="counter" class="counter">
|
|
649
|
+
${this.value.length}/${this.maxlength}
|
|
650
|
+
</div>`
|
|
523
651
|
: nothingTemplate;
|
|
524
652
|
}
|
|
525
653
|
};
|