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.
Files changed (156) hide show
  1. package/components/avatar/index.d.ts +13 -13
  2. package/components/avatar/index.js +11 -6
  3. package/components/avatar/style.js +31 -1
  4. package/components/badge/index.d.ts +7 -6
  5. package/components/badge/index.js +6 -5
  6. package/components/badge/style.js +25 -1
  7. package/components/bottom-app-bar/index.d.ts +4 -3
  8. package/components/bottom-app-bar/index.js +3 -3
  9. package/components/bottom-app-bar/style.js +92 -1
  10. package/components/button/button-base-style.js +28 -1
  11. package/components/button/button-base.d.ts +43 -44
  12. package/components/button/button-base.js +28 -21
  13. package/components/button/index.d.ts +13 -13
  14. package/components/button/index.js +30 -20
  15. package/components/button/style.js +111 -2
  16. package/components/button-icon/index.d.ts +8 -8
  17. package/components/button-icon/index.js +29 -12
  18. package/components/button-icon/style.js +103 -2
  19. package/components/card/index.d.ts +8 -8
  20. package/components/card/index.js +12 -8
  21. package/components/card/style.js +72 -1
  22. package/components/checkbox/index.d.ts +20 -20
  23. package/components/checkbox/index.js +68 -25
  24. package/components/checkbox/style.js +131 -1
  25. package/components/chip/index.d.ts +19 -19
  26. package/components/chip/index.js +49 -25
  27. package/components/chip/style.js +205 -2
  28. package/components/circular-progress/index.d.ts +2 -2
  29. package/components/circular-progress/index.js +40 -6
  30. package/components/circular-progress/style.js +136 -1
  31. package/components/collapse/collapse-item-style.js +21 -1
  32. package/components/collapse/collapse-item.d.ts +4 -4
  33. package/components/collapse/collapse-item.js +12 -4
  34. package/components/collapse/collapse-style.js +5 -1
  35. package/components/collapse/collapse.d.ts +6 -9
  36. package/components/collapse/collapse.js +8 -5
  37. package/components/dialog/index.d.ts +13 -13
  38. package/components/dialog/index.js +48 -20
  39. package/components/dialog/style.js +116 -1
  40. package/components/divider/index.d.ts +3 -3
  41. package/components/divider/index.js +3 -3
  42. package/components/divider/style.js +18 -1
  43. package/components/dropdown/index.d.ts +35 -35
  44. package/components/dropdown/index.js +41 -34
  45. package/components/dropdown/style.js +11 -1
  46. package/components/fab/index.d.ts +6 -6
  47. package/components/fab/index.js +19 -11
  48. package/components/fab/style.js +153 -4
  49. package/components/icon/index.js +5 -1
  50. package/components/icon/style.js +29 -1
  51. package/components/layout/layout-item-style.js +6 -1
  52. package/components/layout/layout-item.d.ts +7 -7
  53. package/components/layout/layout-item.js +6 -6
  54. package/components/layout/layout-main-style.js +7 -1
  55. package/components/layout/layout-main.d.ts +2 -2
  56. package/components/layout/layout-main.js +2 -2
  57. package/components/layout/layout-style.js +11 -1
  58. package/components/layout/layout.d.ts +2 -2
  59. package/components/layout/layout.js +2 -2
  60. package/components/linear-progress/index.d.ts +4 -4
  61. package/components/linear-progress/index.js +9 -5
  62. package/components/linear-progress/style.js +73 -1
  63. package/components/list/list-item-style.js +153 -2
  64. package/components/list/list-item.d.ts +17 -17
  65. package/components/list/list-item.js +34 -15
  66. package/components/list/list-style.js +10 -1
  67. package/components/list/list-subheader-style.js +19 -1
  68. package/components/list/list-subheader.d.ts +2 -2
  69. package/components/list/list-subheader.js +2 -2
  70. package/components/list/list.d.ts +1 -1
  71. package/components/list/list.js +1 -1
  72. package/components/menu/menu-item-style.js +125 -1
  73. package/components/menu/menu-item.d.ts +4 -4
  74. package/components/menu/menu-item.js +57 -15
  75. package/components/menu/menu-style.js +19 -1
  76. package/components/menu/menu.d.ts +15 -18
  77. package/components/menu/menu.js +13 -9
  78. package/components/navigation-bar/navigation-bar-item-style.js +132 -1
  79. package/components/navigation-bar/navigation-bar-item.d.ts +5 -5
  80. package/components/navigation-bar/navigation-bar-item.js +27 -11
  81. package/components/navigation-bar/navigation-bar-style.js +28 -1
  82. package/components/navigation-bar/navigation-bar.d.ts +9 -8
  83. package/components/navigation-bar/navigation-bar.js +10 -7
  84. package/components/navigation-drawer/index.d.ts +19 -20
  85. package/components/navigation-drawer/index.js +56 -31
  86. package/components/navigation-drawer/style.js +66 -1
  87. package/components/navigation-rail/navigation-rail-item-style.js +122 -1
  88. package/components/navigation-rail/navigation-rail-item.d.ts +6 -6
  89. package/components/navigation-rail/navigation-rail-item.js +30 -11
  90. package/components/navigation-rail/navigation-rail-style.js +79 -1
  91. package/components/navigation-rail/navigation-rail.d.ts +10 -11
  92. package/components/navigation-rail/navigation-rail.js +19 -11
  93. package/components/radio/radio-group-style.js +20 -1
  94. package/components/radio/radio-group.d.ts +13 -13
  95. package/components/radio/radio-group.js +30 -12
  96. package/components/radio/radio-style.js +107 -1
  97. package/components/radio/radio.d.ts +3 -3
  98. package/components/radio/radio.js +26 -8
  99. package/components/range-slider/index.d.ts +5 -6
  100. package/components/range-slider/index.js +57 -10
  101. package/components/ripple/index.js +5 -2
  102. package/components/ripple/style.js +96 -1
  103. package/components/segmented-button/segmented-button-group-style.js +28 -1
  104. package/components/segmented-button/segmented-button-group.d.ts +17 -20
  105. package/components/segmented-button/segmented-button-group.js +32 -15
  106. package/components/segmented-button/segmented-button-style.js +81 -2
  107. package/components/segmented-button/segmented-button.d.ts +3 -3
  108. package/components/segmented-button/segmented-button.js +30 -14
  109. package/components/select/index.d.ts +31 -32
  110. package/components/select/index.js +106 -26
  111. package/components/select/style.js +27 -1
  112. package/components/slider/index.d.ts +1 -1
  113. package/components/slider/index.js +34 -3
  114. package/components/slider/slider-base-style.js +173 -1
  115. package/components/slider/slider-base.d.ts +15 -15
  116. package/components/slider/slider-base.js +19 -14
  117. package/components/slider/style.js +7 -1
  118. package/components/snackbar/index.d.ts +21 -21
  119. package/components/snackbar/index.js +47 -20
  120. package/components/snackbar/style.js +100 -1
  121. package/components/switch/index.d.ts +14 -14
  122. package/components/switch/index.js +51 -17
  123. package/components/switch/style.js +202 -1
  124. package/components/tabs/tab-panel-style.js +10 -1
  125. package/components/tabs/tab-panel.d.ts +3 -3
  126. package/components/tabs/tab-panel.js +2 -2
  127. package/components/tabs/tab-style.js +85 -1
  128. package/components/tabs/tab.d.ts +6 -6
  129. package/components/tabs/tab.js +29 -9
  130. package/components/tabs/tabs-style.js +138 -1
  131. package/components/tabs/tabs.d.ts +19 -19
  132. package/components/tabs/tabs.js +26 -18
  133. package/components/text-field/index.d.ts +51 -51
  134. package/components/text-field/index.js +185 -57
  135. package/components/text-field/style.js +362 -1
  136. package/components/tooltip/index.d.ts +31 -31
  137. package/components/tooltip/index.js +38 -29
  138. package/components/tooltip/style.js +57 -1
  139. package/components/top-app-bar/top-app-bar-style.js +78 -1
  140. package/components/top-app-bar/top-app-bar-title-style.js +81 -1
  141. package/components/top-app-bar/top-app-bar-title.d.ts +4 -4
  142. package/components/top-app-bar/top-app-bar-title.js +21 -7
  143. package/components/top-app-bar/top-app-bar.d.ts +5 -5
  144. package/components/top-app-bar/top-app-bar.js +4 -4
  145. package/css-data.en.json +2826 -0
  146. package/css-data.zh-cn.json +374 -367
  147. package/custom-elements.json +2049 -2049
  148. package/html-data.en.json +6560 -0
  149. package/html-data.zh-cn.json +1427 -1433
  150. package/jsx.en.d.ts +3303 -0
  151. package/jsx.zh-cn.d.ts +3351 -0
  152. package/package.json +6 -5
  153. package/web-types.en.json +11734 -0
  154. package/web-types.zh-cn.json +3227 -3221
  155. package/mdui.esm.js +0 -22
  156. 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
- * 文本框形状。默认为 `filled`。可选值为:
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
- * 是否显示字数统计。必须指定了 `maxlength` 时,该参数才有效
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
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`
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
- * 检查表单字段是否验证通过。若未通过则返回 `false`,并触发 `invalid` 事件;若验证通过,则返回 `true`。
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="${className}">${this.renderPrefix()}<div class="input-container">${this.renderLabel()} ${this.isTextarea
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)} ${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>`)}`;
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 part="label" class="label" ${animate({
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
- })}>${this.label}</label>`
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">${this.icon
461
- ? html `<mdui-icon name="${this.icon}" class="i"></mdui-icon>`
462
- : nothingTemplate}</slot><slot name="prefix" part="prefix" class="prefix">${this.prefix}</slot>`;
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">${this.suffix}</slot>${hasErrorIcon
466
- ? html `<slot name="error-icon" part="error-icon" class="right-icon">${this.errorIcon
467
- ? html `<mdui-icon name="${this.errorIcon}" class="i"></mdui-icon>`
468
- : html `<mdui-icon-error class="i"></mdui-icon-error>`}</slot>`
469
- : html `<slot name="end-icon" part="end-icon" class="end-icon right-icon">${this.endIcon
470
- ? html `<mdui-icon name="${this.endIcon}" class="i"></mdui-icon>`
471
- : nothingTemplate}</slot>`}`;
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 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
479
- ? html `<mdui-icon name="${this.clearIcon}" class="i"></mdui-icon>`
480
- : html `<mdui-icon-cancel--outlined class="i"></mdui-icon-cancel--outlined>`}</slot></mdui-button-icon></slot>`);
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 name="toggle-password-button" part="toggle-password-button" class="right-icon" @click="${this.onTogglePassword}"><mdui-button-icon tabindex="-1">${this.isPasswordVisible
485
- ? html `<slot name="show-password-icon" part="show-password-icon">${this.showPasswordIcon
486
- ? html `<mdui-icon name="${this.showPasswordIcon}" class="i"></mdui-icon>`
487
- : html `<mdui-icon-visibility-off class="i"></mdui-icon-visibility-off>`}</slot>`
488
- : html `<slot name="hide-password-icon" part="hide-password-icon">${this.hidePasswordIcon
489
- ? html `<mdui-icon name="${this.hidePasswordIcon}" class="i"></mdui-icon>`
490
- : html `<mdui-icon-visibility class="i"></mdui-icon-visibility>`}</slot>`}</mdui-button-icon></slot>`);
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 ${ref(this.inputRef)} part="input" class="input ${classMap({ 'hide-input': hasInputSlot })}" type="${this.type === 'password' && this.isPasswordVisible
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}" name="${ifDefined(this.name)}" .value="${live(this.value)}" placeholder="${ifDefined(
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)}" ?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}">`;
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 ${ref(this.inputRef)} part="input" class="input ${classMap({ 'hide-input': hasInputSlot })}" name="${ifDefined(this.name)}" .value="${live(this.value)}" placeholder="${ifDefined(
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)}" ?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>`;
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">${this.error || this.inputRef.value.validationMessage}</div>`
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">${this.helper}</slot>`
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">${this.value.length}/${this.maxlength}</div>`
648
+ ? html `<div part="counter" class="counter">
649
+ ${this.value.length}/${this.maxlength}
650
+ </div>`
523
651
  : nothingTemplate;
524
652
  }
525
653
  };