mdui 2.0.2 → 2.0.4
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 +17 -15
- package/components/avatar/index.js +7 -6
- package/components/badge/index.d.ts +11 -8
- package/components/badge/index.js +9 -7
- package/components/bottom-app-bar/index.d.ts +11 -4
- package/components/bottom-app-bar/index.js +8 -9
- package/components/button/button-base-style.js +1 -1
- package/components/button/button-base.d.ts +46 -47
- package/components/button/button-base.js +27 -25
- package/components/button/index.d.ts +19 -14
- package/components/button/index.js +12 -12
- package/components/button-icon/index.d.ts +15 -9
- package/components/button-icon/index.js +8 -9
- package/components/card/index.d.ts +15 -11
- package/components/card/index.js +10 -9
- package/components/checkbox/index.d.ts +30 -23
- package/components/checkbox/index.js +25 -25
- package/components/chip/index.d.ts +27 -20
- package/components/chip/index.js +19 -20
- package/components/circular-progress/index.d.ts +6 -4
- package/components/circular-progress/index.js +4 -3
- package/components/collapse/collapse-item.d.ts +17 -6
- package/components/collapse/collapse-item.js +7 -7
- package/components/collapse/collapse.d.ts +16 -11
- package/components/collapse/collapse.js +10 -10
- package/components/dialog/index.d.ts +22 -15
- package/components/dialog/index.js +23 -27
- package/components/divider/index.d.ts +7 -5
- package/components/divider/index.js +6 -5
- package/components/dropdown/index.d.ts +44 -37
- package/components/dropdown/index.js +50 -48
- package/components/fab/index.d.ts +12 -7
- package/components/fab/index.js +6 -6
- package/components/icon/index.d.ts +4 -2
- package/components/icon/index.js +3 -2
- package/components/layout/layout-item-base.d.ts +3 -2
- package/components/layout/layout-item-base.js +2 -2
- package/components/layout/layout-item.d.ts +11 -10
- package/components/layout/layout-item.js +6 -6
- package/components/layout/layout-main.d.ts +6 -4
- package/components/layout/layout-main.js +5 -4
- package/components/layout/layout.d.ts +6 -4
- package/components/layout/layout.js +5 -4
- package/components/linear-progress/index.d.ts +8 -6
- package/components/linear-progress/index.js +6 -5
- package/components/list/list-item-style.js +1 -1
- package/components/list/list-item.d.ts +24 -20
- package/components/list/list-item.js +10 -9
- package/components/list/list-subheader.d.ts +6 -4
- package/components/list/list-subheader.js +5 -4
- package/components/list/list.d.ts +5 -3
- package/components/list/list.js +4 -3
- package/components/menu/menu-item.d.ts +15 -7
- package/components/menu/menu-item.js +11 -15
- package/components/menu/menu.d.ts +20 -20
- package/components/menu/menu.js +13 -13
- package/components/navigation-bar/navigation-bar-item.d.ts +12 -8
- package/components/navigation-bar/navigation-bar-item.js +7 -6
- package/components/navigation-bar/navigation-bar.d.ts +17 -9
- package/components/navigation-bar/navigation-bar.js +15 -13
- package/components/navigation-drawer/index.d.ts +27 -21
- package/components/navigation-drawer/index.js +51 -38
- package/components/navigation-drawer/style.js +1 -1
- package/components/navigation-rail/navigation-rail-item.d.ts +13 -9
- package/components/navigation-rail/navigation-rail-item.js +7 -6
- package/components/navigation-rail/navigation-rail.d.ts +14 -12
- package/components/navigation-rail/navigation-rail.js +13 -12
- package/components/radio/radio-group.d.ts +20 -15
- package/components/radio/radio-group.js +21 -24
- package/components/radio/radio.d.ts +11 -6
- package/components/radio/radio.js +7 -7
- package/components/range-slider/index.d.ts +13 -8
- package/components/range-slider/index.js +10 -7
- package/components/ripple/index.d.ts +4 -2
- package/components/ripple/index.js +3 -2
- package/components/ripple/ripple-mixin.d.ts +1 -1
- package/components/ripple/ripple-mixin.js +0 -1
- package/components/segmented-button/segmented-button-group-style.js +1 -1
- package/components/segmented-button/segmented-button-group.d.ts +23 -22
- package/components/segmented-button/segmented-button-group.js +20 -23
- package/components/segmented-button/segmented-button.d.ts +9 -4
- package/components/segmented-button/segmented-button.js +3 -3
- package/components/select/index.d.ts +42 -35
- package/components/select/index.js +24 -25
- package/components/slider/index.d.ts +9 -2
- package/components/slider/index.js +5 -10
- package/components/slider/slider-base.d.ts +22 -18
- package/components/slider/slider-base.js +40 -21
- package/components/snackbar/index.d.ts +30 -23
- package/components/snackbar/index.js +25 -25
- package/components/switch/index.d.ts +24 -17
- package/components/switch/index.js +18 -18
- package/components/tabs/tab-panel.d.ts +7 -5
- package/components/tabs/tab-panel.js +5 -4
- package/components/tabs/tab.d.ts +13 -9
- package/components/tabs/tab.js +8 -7
- package/components/tabs/tabs.d.ts +24 -21
- package/components/tabs/tabs.js +24 -21
- package/components/text-field/index.d.ts +62 -54
- package/components/text-field/index.js +37 -37
- package/components/tooltip/index.d.ts +40 -33
- package/components/tooltip/index.js +45 -43
- package/components/top-app-bar/top-app-bar-title.d.ts +8 -6
- package/components/top-app-bar/top-app-bar-title.js +7 -6
- package/components/top-app-bar/top-app-bar.d.ts +12 -6
- package/components/top-app-bar/top-app-bar.js +9 -10
- package/css-data.en.json +2826 -0
- package/css-data.zh-cn.json +374 -367
- package/custom-elements.json +3844 -3824
- package/html-data.en.json +6551 -0
- package/html-data.zh-cn.json +1621 -1636
- package/jsx.en.d.ts +3303 -0
- package/jsx.zh-cn.d.ts +3351 -0
- package/mdui.esm.js +9 -9
- package/mdui.global.js +9 -9
- package/package.json +7 -5
- package/web-types.en.json +11718 -0
- package/web-types.zh-cn.json +3613 -3623
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import '@mdui/jq/methods/css.js';
|
|
2
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
3
3
|
import '@mdui/shared/icons/cancel--outlined.js';
|
|
4
4
|
import '@mdui/shared/icons/error.js';
|
|
5
5
|
import '@mdui/shared/icons/visibility-off.js';
|
|
@@ -8,7 +8,7 @@ import '../button-icon.js';
|
|
|
8
8
|
import '../icon.js';
|
|
9
9
|
import type { FormControl } from '@mdui/jq/shared/form.js';
|
|
10
10
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
11
|
-
declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof
|
|
11
|
+
declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof MduiElement;
|
|
12
12
|
/**
|
|
13
13
|
* @summary 文本框组件
|
|
14
14
|
*
|
|
@@ -30,9 +30,9 @@ declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import
|
|
|
30
30
|
* @slot suffix - 右侧文本
|
|
31
31
|
* @slot clear-button - 清空按钮
|
|
32
32
|
* @slot clear-icon - 清空按钮中的图标
|
|
33
|
-
* @slot toggle-password-button -
|
|
34
|
-
* @slot show-password-icon -
|
|
35
|
-
* @slot hide-password-icon -
|
|
33
|
+
* @slot toggle-password-button - 密码显示状态切换按钮
|
|
34
|
+
* @slot show-password-icon - 显示密码状态下,密码显示状态切换按钮中的图标
|
|
35
|
+
* @slot hide-password-icon - 隐藏密码状态下,密码显示状态切换按钮中的图标
|
|
36
36
|
* @slot helper - 底部的帮助文本
|
|
37
37
|
*
|
|
38
38
|
* @csspart container - 文本框容器
|
|
@@ -45,25 +45,25 @@ declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import
|
|
|
45
45
|
* @csspart input - 内部的 `<input>` 或 `<textarea>` 元素
|
|
46
46
|
* @csspart clear-button - 清空按钮
|
|
47
47
|
* @csspart clear-icon - 清空按钮中的图标
|
|
48
|
-
* @csspart toggle-password-button -
|
|
49
|
-
* @csspart show-password-icon -
|
|
50
|
-
* @csspart hide-password-icon -
|
|
48
|
+
* @csspart toggle-password-button - 密码显示状态切换按钮
|
|
49
|
+
* @csspart show-password-icon - 显示密码状态下,密码显示状态切换按钮中的图标
|
|
50
|
+
* @csspart hide-password-icon - 隐藏密码状态下,密码显示状态切换按钮中的图标
|
|
51
51
|
* @csspart supporting - 底部辅助信息容器,包括 helper、error、counter
|
|
52
52
|
* @csspart helper - 底部的帮助文本
|
|
53
53
|
* @csspart error - 底部的错误描述文本
|
|
54
54
|
* @csspart counter - 底部右侧的字数统计
|
|
55
55
|
*/
|
|
56
|
-
export declare class TextField extends TextField_base implements FormControl {
|
|
56
|
+
export declare class TextField extends TextField_base<TextFieldEventMap> implements FormControl {
|
|
57
57
|
static styles: CSSResultGroup;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* 文本框的形状。默认为 `filled`。可选值包括:
|
|
60
60
|
*
|
|
61
61
|
* * `filled`:带背景色的文本框,视觉效果较强
|
|
62
62
|
* * `outlined`:带边框的文本框,视觉效果较弱
|
|
63
63
|
*/
|
|
64
64
|
variant: /*带背景色的文本框,视觉效果较强*/ 'filled' | /*带边框的文本框,视觉效果较弱*/ 'outlined';
|
|
65
65
|
/**
|
|
66
|
-
* 文本框输入类型。默认为 `text
|
|
66
|
+
* 文本框输入类型。默认为 `text`。可选值包括:
|
|
67
67
|
*
|
|
68
68
|
* * `text`:默认值。文本字段
|
|
69
69
|
* * `number`:只能输入数字。拥有动态键盘的设备上会显示数字键盘
|
|
@@ -97,7 +97,7 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
97
97
|
*/
|
|
98
98
|
label?: string;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* 占位符文本
|
|
101
101
|
*/
|
|
102
102
|
placeholder?: string;
|
|
103
103
|
/**
|
|
@@ -105,11 +105,11 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
105
105
|
*/
|
|
106
106
|
helper?: string;
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
108
|
+
* 是否仅在获得焦点时,显示底部的帮助文本
|
|
109
109
|
*/
|
|
110
110
|
helperOnFocus: boolean;
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* 是否可清空文本框内容
|
|
113
113
|
*/
|
|
114
114
|
clearable: boolean;
|
|
115
115
|
/**
|
|
@@ -117,15 +117,15 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
117
117
|
*/
|
|
118
118
|
clearIcon?: string;
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
120
|
+
* 是否将文本右对齐
|
|
121
121
|
*/
|
|
122
122
|
endAligned: boolean;
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* 文本框的前缀文本。只在文本框聚焦或有值时显示。也可以通过 `slot="prefix"` 设置
|
|
125
125
|
*/
|
|
126
126
|
prefix: string;
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* 文本框的后缀文本。只在文本框聚焦或有值时显示。也可以通过 `slot="suffix"` 设置
|
|
129
129
|
*/
|
|
130
130
|
suffix?: string;
|
|
131
131
|
/**
|
|
@@ -141,17 +141,17 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
141
141
|
*/
|
|
142
142
|
errorIcon?: string;
|
|
143
143
|
/**
|
|
144
|
-
* 关联的
|
|
144
|
+
* 关联的 `<form>` 元素。此属性值应为同一页面中的一个 `<form>` 元素的 `id`。
|
|
145
145
|
*
|
|
146
|
-
*
|
|
146
|
+
* 如果未指定此属性,则该元素必须是 `<form>` 元素的子元素。通过此属性,你可以将元素放置在页面的任何位置,而不仅仅是 `<form>` 元素的子元素。
|
|
147
147
|
*/
|
|
148
148
|
form?: string;
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
150
|
+
* 是否为只读模式
|
|
151
151
|
*/
|
|
152
152
|
readonly: boolean;
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* 是否禁用输入框
|
|
155
155
|
*/
|
|
156
156
|
disabled: boolean;
|
|
157
157
|
/**
|
|
@@ -159,19 +159,19 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
159
159
|
*/
|
|
160
160
|
required: boolean;
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
162
|
+
* 文本框的固定显示行数
|
|
163
163
|
*/
|
|
164
164
|
rows?: number;
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
166
|
+
* 是否根据输入内容自动调整文本框高度
|
|
167
167
|
*/
|
|
168
168
|
autosize: boolean;
|
|
169
169
|
/**
|
|
170
|
-
* `autosize` 为 `true`
|
|
170
|
+
* `autosize` 为 `true` 时,文本框的最小行数
|
|
171
171
|
*/
|
|
172
172
|
minRows?: number;
|
|
173
173
|
/**
|
|
174
|
-
* `autosize` 为 `true`
|
|
174
|
+
* `autosize` 为 `true` 时,文本框的最大行数
|
|
175
175
|
*/
|
|
176
176
|
maxRows?: number;
|
|
177
177
|
/**
|
|
@@ -183,7 +183,7 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
183
183
|
*/
|
|
184
184
|
maxlength?: number;
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
186
|
+
* 是否显示字数统计,只在 `maxlength` 被指定时有效
|
|
187
187
|
*/
|
|
188
188
|
counter: boolean;
|
|
189
189
|
/**
|
|
@@ -195,7 +195,7 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
195
195
|
*/
|
|
196
196
|
max?: number;
|
|
197
197
|
/**
|
|
198
|
-
* `type` 为 `number`
|
|
198
|
+
* `type` 为 `number` 时,数值增减的步长
|
|
199
199
|
*/
|
|
200
200
|
step?: number;
|
|
201
201
|
/**
|
|
@@ -203,55 +203,55 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
203
203
|
*/
|
|
204
204
|
pattern?: string;
|
|
205
205
|
/**
|
|
206
|
-
* `type` 为 `password`
|
|
206
|
+
* `type` 为 `password` 时,设置此属性会添加一个切换按钮,用于在明文和密文之间切换
|
|
207
207
|
*/
|
|
208
208
|
togglePassword: boolean;
|
|
209
209
|
/**
|
|
210
|
-
*
|
|
210
|
+
* 密码切换按钮的 Material Icons 图标,当密码为明文时显示。也可以通过 `slot="show-password-icon"` 设置
|
|
211
211
|
*/
|
|
212
212
|
showPasswordIcon?: string;
|
|
213
213
|
/**
|
|
214
|
-
*
|
|
214
|
+
* 密码切换按钮的 Material Icons 图标,当密码为密文时显示。也可以通过 `slot="hide-password-icon"` 设置
|
|
215
215
|
*/
|
|
216
216
|
hidePasswordIcon?: string;
|
|
217
217
|
/**
|
|
218
|
-
* iOS
|
|
218
|
+
* iOS 的非标准属性,用于控制文本首字母是否自动大写。在 iOS5 及以后的版本上有效。可选值包括:
|
|
219
219
|
*
|
|
220
220
|
* * `none`:禁用首字母大写
|
|
221
|
-
* * `sentences
|
|
222
|
-
* * `words
|
|
223
|
-
* * `characters
|
|
221
|
+
* * `sentences`:句子首字母大写
|
|
222
|
+
* * `words`:单词首字母大写
|
|
223
|
+
* * `characters`:所有字母大写
|
|
224
224
|
*/
|
|
225
|
-
autocapitalize: /*禁用首字母大写*/ 'none' |
|
|
225
|
+
autocapitalize: /*禁用首字母大写*/ 'none' | /*句子首字母大写*/ 'sentences' | /*单词首字母大写*/ 'words' | /*所有字母大写*/ 'characters';
|
|
226
226
|
/**
|
|
227
227
|
* `input` 元素的 `autocorrect` 属性
|
|
228
228
|
*/
|
|
229
229
|
autocorrect?: string;
|
|
230
230
|
/**
|
|
231
|
-
*
|
|
231
|
+
* 是否使用浏览器的自动填充功能。可选值包括:
|
|
232
232
|
*
|
|
233
|
-
* * `off
|
|
233
|
+
* * `off`:禁用浏览器的自动填充,使用者必须输入他们想要输入的所有内容。或者网页提供了自己的自动填充方法
|
|
234
234
|
* * `on`:浏览器根据用户之前输入的内容或者习惯,在用户输入的时候给出相应输入提示
|
|
235
235
|
*/
|
|
236
|
-
autocomplete?:
|
|
236
|
+
autocomplete?: /*禁用浏览器的自动填充,使用者必须输入他们想要输入的所有内容。或者网页提供了自己的自动填充方法*/ 'off' | /*浏览器根据用户之前输入的内容或者习惯,在用户输入的时候给出相应输入提示*/ 'on';
|
|
237
237
|
/**
|
|
238
|
-
* `input` 元素的 `enterkeyhint`
|
|
238
|
+
* `input` 元素的 `enterkeyhint` 属性,用于定制虚拟键盘上的 Enter 键的显示文本或图标。具体显示效果取决于用户使用的设备和语言。可选值包括:
|
|
239
239
|
*
|
|
240
|
-
* * `enter
|
|
241
|
-
* * `done
|
|
242
|
-
* * `go
|
|
240
|
+
* * `enter`:插入新行
|
|
241
|
+
* * `done`:完成输入,关闭虚拟键盘
|
|
242
|
+
* * `go`:导航到输入文本的目标
|
|
243
243
|
* * `next`:移动到下一个输入项
|
|
244
244
|
* * `previous`:移动到上一个输入项
|
|
245
|
-
* * `search
|
|
245
|
+
* * `search`:导航到搜索结果
|
|
246
246
|
* * `send`:发送文本信息
|
|
247
247
|
*/
|
|
248
|
-
enterkeyhint?:
|
|
248
|
+
enterkeyhint?: /*插入新行*/ 'enter' | /*完成输入,关闭虚拟键盘*/ 'done' | /*导航到输入文本的目标*/ 'go' | /*移动到下一个输入项*/ 'next' | /*移动到上一个输入项*/ 'previous' | /*导航到搜索结果*/ 'search' | /*发送文本信息*/ 'send';
|
|
249
249
|
/**
|
|
250
|
-
*
|
|
250
|
+
* 是否启用拼写检查
|
|
251
251
|
*/
|
|
252
252
|
spellcheck: boolean;
|
|
253
253
|
/**
|
|
254
|
-
* `input` 元素的 `inputmode`
|
|
254
|
+
* `input` 元素的 `inputmode` 属性,用于定制虚拟键盘的类型。可选值包括:
|
|
255
255
|
*
|
|
256
256
|
* * `none`:无虚拟键盘。在需要实现自己的键盘输入控件时很有用
|
|
257
257
|
* * `text`:标准文本输入键盘
|
|
@@ -296,11 +296,11 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
296
296
|
*/
|
|
297
297
|
private readonlyButClearable;
|
|
298
298
|
/**
|
|
299
|
-
*
|
|
299
|
+
* 表单验证状态对象,具体参见 [`ValidityState`](https://developer.mozilla.org/zh-CN/docs/Web/API/ValidityState)
|
|
300
300
|
*/
|
|
301
301
|
get validity(): ValidityState;
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
303
|
+
* 如果表单验证未通过,此属性将包含提示信息。如果验证通过,此属性将为空字符串
|
|
304
304
|
*/
|
|
305
305
|
get validationMessage(): string;
|
|
306
306
|
/**
|
|
@@ -338,7 +338,7 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
338
338
|
*/
|
|
339
339
|
setSelectionRange(start: number, end: number, direction?: 'forward' | 'backward' | 'none'): void;
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
341
|
+
* 将文本框中特定范围的文本替换为新的文本
|
|
342
342
|
* @param replacement 要插入的字符串
|
|
343
343
|
* @param start 要替换的字符的起止位置的索引。默认为当前用户选中的字符的起始位置的索引
|
|
344
344
|
* @param end 要替换的字符的结束位置的索引。默认为当前用户选中的字符的结束位置的索引
|
|
@@ -350,19 +350,19 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
350
350
|
*/
|
|
351
351
|
setRangeText(replacement: string, start: number, end: number, selectMode?: 'select' | 'start' | 'end' | 'preserve'): void;
|
|
352
352
|
/**
|
|
353
|
-
*
|
|
353
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
354
354
|
*/
|
|
355
355
|
checkValidity(): boolean;
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`。
|
|
358
358
|
*
|
|
359
|
-
*
|
|
359
|
+
* 如果验证未通过,还会在组件上显示验证失败的提示。
|
|
360
360
|
*/
|
|
361
361
|
reportValidity(): boolean;
|
|
362
362
|
/**
|
|
363
|
-
*
|
|
363
|
+
* 设置自定义的错误提示文本。只要这个文本不为空,就表示字段未通过验证
|
|
364
364
|
*
|
|
365
|
-
* @param message
|
|
365
|
+
* @param message 自定义的错误提示文本
|
|
366
366
|
*/
|
|
367
367
|
setCustomValidity(message: string): void;
|
|
368
368
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
@@ -392,6 +392,14 @@ export declare class TextField extends TextField_base implements FormControl {
|
|
|
392
392
|
private renderHelper;
|
|
393
393
|
private renderCounter;
|
|
394
394
|
}
|
|
395
|
+
export interface TextFieldEventMap {
|
|
396
|
+
focus: FocusEvent;
|
|
397
|
+
blur: FocusEvent;
|
|
398
|
+
change: CustomEvent<void>;
|
|
399
|
+
input: CustomEvent<void>;
|
|
400
|
+
invalid: CustomEvent<void>;
|
|
401
|
+
clear: CustomEvent<void>;
|
|
402
|
+
}
|
|
395
403
|
declare global {
|
|
396
404
|
interface HTMLElementTagNameMap {
|
|
397
405
|
'mdui-text-field': TextField;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -9,12 +9,12 @@ import { when } from 'lit/directives/when.js';
|
|
|
9
9
|
import { animate } from '@lit-labs/motion';
|
|
10
10
|
import { $ } from '@mdui/jq/$.js';
|
|
11
11
|
import '@mdui/jq/methods/css.js';
|
|
12
|
+
import { MduiElement } from '@mdui/shared/base/mdui-element.js';
|
|
12
13
|
import { FormController, formResets } from '@mdui/shared/controllers/form.js';
|
|
13
14
|
import { HasSlotController } from '@mdui/shared/controllers/has-slot.js';
|
|
14
15
|
import { defaultValue } from '@mdui/shared/decorators/default-value.js';
|
|
15
16
|
import { watch } from '@mdui/shared/decorators/watch.js';
|
|
16
17
|
import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
|
|
17
|
-
import { emit } from '@mdui/shared/helpers/event.js';
|
|
18
18
|
import { getDuration, getEasing } from '@mdui/shared/helpers/motion.js';
|
|
19
19
|
import { observeResize } from '@mdui/shared/helpers/observeResize.js';
|
|
20
20
|
import { nothingTemplate } from '@mdui/shared/helpers/template.js';
|
|
@@ -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,26 +63,26 @@ 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 - 底部的错误描述文本
|
|
72
72
|
* @csspart counter - 底部右侧的字数统计
|
|
73
73
|
*/
|
|
74
|
-
let TextField = class TextField extends FocusableMixin(
|
|
74
|
+
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(LitElement) {
|
|
|
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(LitElement) {
|
|
|
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(LitElement) {
|
|
|
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(LitElement) {
|
|
|
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 要替换的字符的结束位置的索引。默认为当前用户选中的字符的结束位置的索引
|
|
@@ -313,17 +313,17 @@ let TextField = class TextField extends FocusableMixin(LitElement) {
|
|
|
313
313
|
if (this.value !== this.inputRef.value.value) {
|
|
314
314
|
this.value = this.inputRef.value.value;
|
|
315
315
|
this.setTextareaHeight();
|
|
316
|
-
emit(
|
|
317
|
-
emit(
|
|
316
|
+
this.emit('input');
|
|
317
|
+
this.emit('change');
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
|
-
*
|
|
321
|
+
* 检查表单字段是否通过验证。如果未通过,返回 `false` 并触发 `invalid` 事件;如果通过,返回 `true`
|
|
322
322
|
*/
|
|
323
323
|
checkValidity() {
|
|
324
324
|
const valid = this.inputRef.value.checkValidity();
|
|
325
325
|
if (!valid) {
|
|
326
|
-
emit(
|
|
326
|
+
this.emit('invalid', {
|
|
327
327
|
bubbles: false,
|
|
328
328
|
cancelable: true,
|
|
329
329
|
composed: false,
|
|
@@ -332,14 +332,14 @@ let TextField = class TextField extends FocusableMixin(LitElement) {
|
|
|
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();
|
|
341
341
|
if (this.invalid) {
|
|
342
|
-
emit(
|
|
342
|
+
this.emit('invalid', {
|
|
343
343
|
bubbles: false,
|
|
344
344
|
cancelable: true,
|
|
345
345
|
composed: false,
|
|
@@ -349,9 +349,9 @@ let TextField = class TextField extends FocusableMixin(LitElement) {
|
|
|
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);
|
|
@@ -393,13 +393,13 @@ let TextField = class TextField extends FocusableMixin(LitElement) {
|
|
|
393
393
|
if (this.isTextarea) {
|
|
394
394
|
this.setTextareaHeight();
|
|
395
395
|
}
|
|
396
|
-
emit(
|
|
396
|
+
this.emit('change');
|
|
397
397
|
}
|
|
398
398
|
onClear(event) {
|
|
399
399
|
this.value = '';
|
|
400
|
-
emit(
|
|
401
|
-
emit(
|
|
402
|
-
emit(
|
|
400
|
+
this.emit('clear');
|
|
401
|
+
this.emit('input');
|
|
402
|
+
this.emit('change');
|
|
403
403
|
this.focus();
|
|
404
404
|
event.stopPropagation();
|
|
405
405
|
}
|
|
@@ -408,7 +408,7 @@ let TextField = class TextField extends FocusableMixin(LitElement) {
|
|
|
408
408
|
if (this.isTextarea) {
|
|
409
409
|
this.setTextareaHeight();
|
|
410
410
|
}
|
|
411
|
-
emit(
|
|
411
|
+
this.emit('input');
|
|
412
412
|
}
|
|
413
413
|
onInvalid(event) {
|
|
414
414
|
event.preventDefault();
|