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.
Files changed (249) hide show
  1. package/components/avatar/index.js +2 -7
  2. package/components/avatar/style.js +1 -31
  3. package/components/badge/style.js +1 -25
  4. package/components/bottom-app-bar/style.js +1 -92
  5. package/components/button/button-base-style.js +1 -28
  6. package/components/button/button-base.js +1 -8
  7. package/components/button/index.js +8 -18
  8. package/components/button/style.js +2 -111
  9. package/components/button-icon/index.js +5 -22
  10. package/components/button-icon/style.js +2 -103
  11. package/components/card/index.js +1 -5
  12. package/components/card/style.js +1 -72
  13. package/components/checkbox/index.js +7 -50
  14. package/components/checkbox/style.js +1 -131
  15. package/components/chip/index.js +9 -33
  16. package/components/chip/style.js +2 -205
  17. package/components/circular-progress/index.js +5 -39
  18. package/components/circular-progress/style.js +1 -136
  19. package/components/collapse/collapse-item-style.js +1 -21
  20. package/components/collapse/collapse-item.js +2 -10
  21. package/components/collapse/collapse-style.js +1 -5
  22. package/components/collapse/collapse.js +1 -4
  23. package/components/dialog/index.js +10 -35
  24. package/components/dialog/style.js +1 -116
  25. package/components/divider/style.js +1 -18
  26. package/components/dropdown/index.js +1 -8
  27. package/components/dropdown/style.js +1 -11
  28. package/components/fab/index.js +5 -13
  29. package/components/fab/style.js +4 -153
  30. package/components/icon/index.js +1 -5
  31. package/components/icon/style.js +1 -29
  32. package/components/layout/layout-item-style.js +1 -6
  33. package/components/layout/layout-main-style.js +1 -7
  34. package/components/layout/layout-style.js +1 -11
  35. package/components/linear-progress/index.js +2 -6
  36. package/components/linear-progress/style.js +1 -73
  37. package/components/list/list-item-style.js +2 -153
  38. package/components/list/list-item.js +8 -27
  39. package/components/list/list-style.js +1 -10
  40. package/components/list/list-subheader-style.js +1 -19
  41. package/components/menu/menu-item-style.js +1 -125
  42. package/components/menu/menu-item.js +13 -55
  43. package/components/menu/menu-style.js +1 -19
  44. package/components/menu/menu.js +1 -5
  45. package/components/navigation-bar/navigation-bar-item-style.js +1 -132
  46. package/components/navigation-bar/navigation-bar-item.js +7 -23
  47. package/components/navigation-bar/navigation-bar-style.js +1 -28
  48. package/components/navigation-bar/navigation-bar.js +1 -4
  49. package/components/navigation-drawer/index.js +1 -12
  50. package/components/navigation-drawer/style.js +1 -66
  51. package/components/navigation-rail/navigation-rail-item-style.js +1 -122
  52. package/components/navigation-rail/navigation-rail-item.js +7 -26
  53. package/components/navigation-rail/navigation-rail-style.js +1 -79
  54. package/components/navigation-rail/navigation-rail.js +1 -10
  55. package/components/radio/radio-group-style.js +1 -20
  56. package/components/radio/radio-group.js +1 -19
  57. package/components/radio/radio-style.js +1 -107
  58. package/components/radio/radio.js +5 -23
  59. package/components/range-slider/index.d.ts +1 -1
  60. package/components/range-slider/index.js +5 -53
  61. package/components/ripple/index.js +2 -5
  62. package/components/ripple/style.js +1 -96
  63. package/components/segmented-button/segmented-button-group-style.js +1 -28
  64. package/components/segmented-button/segmented-button-group.js +1 -21
  65. package/components/segmented-button/segmented-button-style.js +2 -81
  66. package/components/segmented-button/segmented-button.js +11 -27
  67. package/components/select/index.d.ts +18 -0
  68. package/components/select/index.js +42 -87
  69. package/components/select/style.js +1 -27
  70. package/components/slider/index.js +2 -33
  71. package/components/slider/slider-base-style.js +1 -173
  72. package/components/slider/slider-base.js +1 -6
  73. package/components/slider/style.js +1 -7
  74. package/components/snackbar/index.js +5 -32
  75. package/components/snackbar/style.js +1 -100
  76. package/components/switch/index.js +6 -40
  77. package/components/switch/style.js +1 -202
  78. package/components/tabs/tab-panel-style.js +1 -10
  79. package/components/tabs/tab-style.js +1 -85
  80. package/components/tabs/tab.js +4 -24
  81. package/components/tabs/tabs-style.js +1 -138
  82. package/components/tabs/tabs.js +1 -9
  83. package/components/text-field/index.d.ts +2 -0
  84. package/components/text-field/index.js +58 -163
  85. package/components/text-field/style.js +1 -362
  86. package/components/tooltip/index.js +1 -10
  87. package/components/tooltip/style.js +1 -57
  88. package/components/top-app-bar/top-app-bar-style.js +1 -78
  89. package/components/top-app-bar/top-app-bar-title-style.js +1 -81
  90. package/components/top-app-bar/top-app-bar-title.js +3 -17
  91. package/custom-elements.json +1194 -1099
  92. package/functions/alert.d.ts +2 -0
  93. package/functions/alert.js +19 -4
  94. package/functions/confirm.d.ts +4 -0
  95. package/functions/confirm.js +33 -6
  96. package/functions/getLocale.d.ts +6 -0
  97. package/functions/getLocale.js +11 -0
  98. package/functions/getTheme.d.ts +1 -1
  99. package/functions/loadLocale.d.ts +6 -0
  100. package/functions/loadLocale.js +8 -0
  101. package/functions/prompt.d.ts +4 -0
  102. package/functions/prompt.js +35 -8
  103. package/functions/removeColorScheme.js +1 -1
  104. package/functions/setColorScheme.d.ts +1 -1
  105. package/functions/setColorScheme.js +1 -1
  106. package/functions/setLocale.d.ts +6 -0
  107. package/functions/setLocale.js +11 -0
  108. package/functions/setTheme.d.ts +1 -1
  109. package/internal/localeCodes.d.ts +13 -0
  110. package/internal/localeCodes.js +144 -0
  111. package/internal/localize.d.ts +32 -0
  112. package/internal/localize.js +55 -0
  113. package/locales/ar-eg.d.ts +8 -0
  114. package/locales/ar-eg.js +12 -0
  115. package/locales/az-az.d.ts +8 -0
  116. package/locales/az-az.js +12 -0
  117. package/locales/be-by.d.ts +8 -0
  118. package/locales/be-by.js +12 -0
  119. package/locales/bg-bg.d.ts +8 -0
  120. package/locales/bg-bg.js +12 -0
  121. package/locales/bn-bd.d.ts +8 -0
  122. package/locales/bn-bd.js +12 -0
  123. package/locales/ca-es.d.ts +8 -0
  124. package/locales/ca-es.js +12 -0
  125. package/locales/cs-cz.d.ts +8 -0
  126. package/locales/cs-cz.js +12 -0
  127. package/locales/da-dk.d.ts +8 -0
  128. package/locales/da-dk.js +12 -0
  129. package/locales/de-de.d.ts +8 -0
  130. package/locales/de-de.js +12 -0
  131. package/locales/el-gr.d.ts +8 -0
  132. package/locales/el-gr.js +12 -0
  133. package/locales/en-gb.d.ts +8 -0
  134. package/locales/en-gb.js +12 -0
  135. package/locales/es-es.d.ts +8 -0
  136. package/locales/es-es.js +12 -0
  137. package/locales/et-ee.d.ts +8 -0
  138. package/locales/et-ee.js +12 -0
  139. package/locales/fa-ir.d.ts +8 -0
  140. package/locales/fa-ir.js +12 -0
  141. package/locales/fi-fi.d.ts +8 -0
  142. package/locales/fi-fi.js +12 -0
  143. package/locales/fr-be.d.ts +8 -0
  144. package/locales/fr-be.js +12 -0
  145. package/locales/fr-ca.d.ts +8 -0
  146. package/locales/fr-ca.js +12 -0
  147. package/locales/fr-fr.d.ts +8 -0
  148. package/locales/fr-fr.js +12 -0
  149. package/locales/ga-ie.d.ts +8 -0
  150. package/locales/ga-ie.js +12 -0
  151. package/locales/gl-es.d.ts +8 -0
  152. package/locales/gl-es.js +12 -0
  153. package/locales/he-il.d.ts +8 -0
  154. package/locales/he-il.js +12 -0
  155. package/locales/hi-in.d.ts +8 -0
  156. package/locales/hi-in.js +12 -0
  157. package/locales/hr-hr.d.ts +8 -0
  158. package/locales/hr-hr.js +12 -0
  159. package/locales/hu-hu.d.ts +8 -0
  160. package/locales/hu-hu.js +12 -0
  161. package/locales/hy-am.d.ts +8 -0
  162. package/locales/hy-am.js +12 -0
  163. package/locales/id-id.d.ts +8 -0
  164. package/locales/id-id.js +12 -0
  165. package/locales/is-is.d.ts +8 -0
  166. package/locales/is-is.js +12 -0
  167. package/locales/it-it.d.ts +8 -0
  168. package/locales/it-it.js +12 -0
  169. package/locales/ja-jp.d.ts +8 -0
  170. package/locales/ja-jp.js +12 -0
  171. package/locales/ka-ge.d.ts +8 -0
  172. package/locales/ka-ge.js +12 -0
  173. package/locales/kk-kz.d.ts +8 -0
  174. package/locales/kk-kz.js +12 -0
  175. package/locales/km-kh.d.ts +8 -0
  176. package/locales/km-kh.js +12 -0
  177. package/locales/kmr-iq.d.ts +8 -0
  178. package/locales/kmr-iq.js +12 -0
  179. package/locales/kn-in.d.ts +8 -0
  180. package/locales/kn-in.js +12 -0
  181. package/locales/ko-kr.d.ts +8 -0
  182. package/locales/ko-kr.js +12 -0
  183. package/locales/lt-lt.d.ts +8 -0
  184. package/locales/lt-lt.js +12 -0
  185. package/locales/lv-lv.d.ts +8 -0
  186. package/locales/lv-lv.js +12 -0
  187. package/locales/mk-mk.d.ts +8 -0
  188. package/locales/mk-mk.js +12 -0
  189. package/locales/ml-in.d.ts +8 -0
  190. package/locales/ml-in.js +12 -0
  191. package/locales/mn-mn.d.ts +8 -0
  192. package/locales/mn-mn.js +12 -0
  193. package/locales/ms-my.d.ts +8 -0
  194. package/locales/ms-my.js +12 -0
  195. package/locales/nb-no.d.ts +8 -0
  196. package/locales/nb-no.js +12 -0
  197. package/locales/ne-np.d.ts +8 -0
  198. package/locales/ne-np.js +12 -0
  199. package/locales/nl-be.d.ts +8 -0
  200. package/locales/nl-be.js +12 -0
  201. package/locales/nl-nl.d.ts +8 -0
  202. package/locales/nl-nl.js +12 -0
  203. package/locales/pl-pl.d.ts +8 -0
  204. package/locales/pl-pl.js +12 -0
  205. package/locales/pt-br.d.ts +8 -0
  206. package/locales/pt-br.js +12 -0
  207. package/locales/pt-pt.d.ts +8 -0
  208. package/locales/pt-pt.js +12 -0
  209. package/locales/ro-ro.d.ts +8 -0
  210. package/locales/ro-ro.js +12 -0
  211. package/locales/ru-ru.d.ts +8 -0
  212. package/locales/ru-ru.js +12 -0
  213. package/locales/sk-sk.d.ts +8 -0
  214. package/locales/sk-sk.js +12 -0
  215. package/locales/sl-si.d.ts +8 -0
  216. package/locales/sl-si.js +12 -0
  217. package/locales/sr-rs.d.ts +8 -0
  218. package/locales/sr-rs.js +12 -0
  219. package/locales/sv-se.d.ts +8 -0
  220. package/locales/sv-se.js +12 -0
  221. package/locales/ta-in.d.ts +8 -0
  222. package/locales/ta-in.js +12 -0
  223. package/locales/th-th.d.ts +8 -0
  224. package/locales/th-th.js +12 -0
  225. package/locales/tr-tr.d.ts +8 -0
  226. package/locales/tr-tr.js +12 -0
  227. package/locales/uk-ua.d.ts +8 -0
  228. package/locales/uk-ua.js +12 -0
  229. package/locales/ur-pk.d.ts +8 -0
  230. package/locales/ur-pk.js +12 -0
  231. package/locales/vi-vn.d.ts +8 -0
  232. package/locales/vi-vn.js +12 -0
  233. package/locales/zh-cn.d.ts +8 -0
  234. package/locales/zh-cn.js +12 -0
  235. package/locales/zh-hk.d.ts +8 -0
  236. package/locales/zh-hk.js +12 -0
  237. package/locales/zh-tw.d.ts +8 -0
  238. package/locales/zh-tw.js +12 -0
  239. package/mdui.d.ts +5 -0
  240. package/mdui.esm.js +22 -0
  241. package/mdui.global.js +22 -0
  242. package/mdui.js +3 -0
  243. package/package.json +9 -6
  244. package/web-types.en.json +91 -1
  245. package/web-types.zh-cn.json +91 -1
  246. /package/{functions/utils → internal}/colorScheme.d.ts +0 -0
  247. /package/{functions/utils → internal}/colorScheme.js +0 -0
  248. /package/{functions/utils → internal}/theme.d.ts +0 -0
  249. /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.inputRef.value.setCustomValidity(message);
358
- this.invalid = !this.inputRef.value.checkValidity();
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=${className}>
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
- ${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>`)}`;
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
- this.setCustomValidity(hasError ? '请与请求的格式匹配。' : '');
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
- ${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>`;
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
- ${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>`}`;
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
- 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>`);
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
- 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>`);
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
  };