mdui 2.0.1 → 2.0.3

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 (127) hide show
  1. package/LICENSE +21 -21
  2. package/components/avatar/index.d.ts +4 -2
  3. package/components/avatar/index.js +4 -2
  4. package/components/badge/index.d.ts +4 -2
  5. package/components/badge/index.js +4 -2
  6. package/components/bottom-app-bar/index.d.ts +9 -3
  7. package/components/bottom-app-bar/index.js +9 -9
  8. package/components/button/button-base.d.ts +5 -5
  9. package/components/button/button-base.js +22 -19
  10. package/components/button/index.d.ts +6 -1
  11. package/components/button/index.js +2 -1
  12. package/components/button-icon/index.d.ts +7 -1
  13. package/components/button-icon/index.js +3 -3
  14. package/components/card/index.d.ts +8 -4
  15. package/components/card/index.js +7 -3
  16. package/components/checkbox/index.d.ts +10 -3
  17. package/components/checkbox/index.js +13 -16
  18. package/components/checkbox/style.js +1 -1
  19. package/components/chip/index.d.ts +8 -1
  20. package/components/chip/index.js +5 -5
  21. package/components/circular-progress/index.d.ts +4 -2
  22. package/components/circular-progress/index.js +5 -4
  23. package/components/collapse/collapse-item-style.js +1 -1
  24. package/components/collapse/collapse-item.d.ts +15 -3
  25. package/components/collapse/collapse-item.js +26 -23
  26. package/components/collapse/collapse.d.ts +16 -8
  27. package/components/collapse/collapse.js +61 -38
  28. package/components/dialog/index.d.ts +12 -4
  29. package/components/dialog/index.js +36 -36
  30. package/components/divider/index.d.ts +4 -2
  31. package/components/divider/index.js +4 -2
  32. package/components/dropdown/index.d.ts +13 -7
  33. package/components/dropdown/index.js +70 -63
  34. package/components/fab/index.d.ts +7 -1
  35. package/components/fab/index.js +10 -5
  36. package/components/icon/index.d.ts +4 -2
  37. package/components/icon/index.js +4 -2
  38. package/components/layout/helper.d.ts +5 -6
  39. package/components/layout/helper.js +42 -48
  40. package/components/layout/layout-item-base.d.ts +3 -2
  41. package/components/layout/layout-item-base.js +3 -4
  42. package/components/layout/layout-item.d.ts +4 -3
  43. package/components/layout/layout-item.js +3 -3
  44. package/components/layout/layout-main.d.ts +4 -2
  45. package/components/layout/layout-main.js +4 -2
  46. package/components/layout/layout.d.ts +4 -2
  47. package/components/layout/layout.js +4 -2
  48. package/components/linear-progress/index.d.ts +4 -2
  49. package/components/linear-progress/index.js +5 -4
  50. package/components/list/list-item-style.js +1 -1
  51. package/components/list/list-item.d.ts +7 -3
  52. package/components/list/list-item.js +5 -3
  53. package/components/list/list-subheader.d.ts +4 -2
  54. package/components/list/list-subheader.js +4 -2
  55. package/components/list/list.d.ts +4 -2
  56. package/components/list/list.js +4 -2
  57. package/components/menu/menu-item.d.ts +12 -3
  58. package/components/menu/menu-item.js +53 -40
  59. package/components/menu/menu.d.ts +9 -3
  60. package/components/menu/menu.js +85 -59
  61. package/components/navigation-bar/navigation-bar-item-style.js +1 -1
  62. package/components/navigation-bar/navigation-bar-item.d.ts +13 -5
  63. package/components/navigation-bar/navigation-bar-item.js +28 -11
  64. package/components/navigation-bar/navigation-bar.d.ts +14 -7
  65. package/components/navigation-bar/navigation-bar.js +58 -49
  66. package/components/navigation-drawer/index.d.ts +13 -2
  67. package/components/navigation-drawer/index.js +69 -49
  68. package/components/navigation-drawer/style.js +1 -1
  69. package/components/navigation-rail/navigation-rail-item-style.js +1 -1
  70. package/components/navigation-rail/navigation-rail-item.d.ts +13 -5
  71. package/components/navigation-rail/navigation-rail-item.js +22 -9
  72. package/components/navigation-rail/navigation-rail.d.ts +8 -6
  73. package/components/navigation-rail/navigation-rail.js +55 -46
  74. package/components/radio/radio-group.d.ts +13 -6
  75. package/components/radio/radio-group.js +69 -59
  76. package/components/radio/radio-style.js +1 -1
  77. package/components/radio/radio.d.ts +11 -5
  78. package/components/radio/radio.js +26 -19
  79. package/components/range-slider/index.d.ts +9 -3
  80. package/components/range-slider/index.js +13 -11
  81. package/components/ripple/index.d.ts +4 -2
  82. package/components/ripple/index.js +4 -2
  83. package/components/ripple/ripple-mixin.d.ts +1 -1
  84. package/components/ripple/ripple-mixin.js +0 -1
  85. package/components/segmented-button/segmented-button-group-style.js +1 -1
  86. package/components/segmented-button/segmented-button-group.d.ts +12 -5
  87. package/components/segmented-button/segmented-button-group.js +92 -77
  88. package/components/segmented-button/segmented-button.d.ts +8 -3
  89. package/components/segmented-button/segmented-button.js +5 -4
  90. package/components/select/index.d.ts +13 -5
  91. package/components/select/index.js +30 -28
  92. package/components/slider/index.d.ts +8 -1
  93. package/components/slider/index.js +11 -18
  94. package/components/slider/slider-base-style.js +1 -1
  95. package/components/slider/slider-base.d.ts +7 -3
  96. package/components/slider/slider-base.js +28 -13
  97. package/components/snackbar/index.d.ts +9 -2
  98. package/components/snackbar/index.js +11 -10
  99. package/components/switch/index.d.ts +10 -3
  100. package/components/switch/index.js +12 -15
  101. package/components/switch/style.js +1 -1
  102. package/components/tabs/tab-panel.d.ts +4 -2
  103. package/components/tabs/tab-panel.js +4 -2
  104. package/components/tabs/tab-style.js +1 -1
  105. package/components/tabs/tab.d.ts +7 -3
  106. package/components/tabs/tab.js +12 -6
  107. package/components/tabs/tabs-style.js +1 -1
  108. package/components/tabs/tabs.d.ts +11 -7
  109. package/components/tabs/tabs.js +57 -40
  110. package/components/text-field/index.d.ts +13 -5
  111. package/components/text-field/index.js +43 -65
  112. package/components/text-field/style.js +1 -1
  113. package/components/tooltip/index.d.ts +14 -7
  114. package/components/tooltip/index.js +45 -38
  115. package/components/top-app-bar/top-app-bar-title-style.js +1 -1
  116. package/components/top-app-bar/top-app-bar-title.d.ts +4 -2
  117. package/components/top-app-bar/top-app-bar-title.js +18 -13
  118. package/components/top-app-bar/top-app-bar.d.ts +9 -3
  119. package/components/top-app-bar/top-app-bar.js +11 -10
  120. package/custom-elements.json +904 -546
  121. package/functions/getTheme.js +3 -3
  122. package/functions/snackbar.js +1 -2
  123. package/functions/utils/colorScheme.js +2 -2
  124. package/mdui.esm.js +8 -8
  125. package/mdui.global.js +8 -8
  126. package/package.json +8 -7
  127. package/web-types.zh-cn.json +1 -1
@@ -1,2 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const tabsStyle = css `:host{position:relative;display:flex}:host([placement^=top]){flex-direction:column}:host([placement^=bottom]){flex-direction:column-reverse}:host([placement^=left]){flex-direction:row}:host([placement^=right]){flex-direction:row-reverse}.container{position:relative;display:flex;flex:0 0 auto;overflow-x:auto;background-color:rgb(var(--mdui-color-surface))}:host([placement^=bottom]) .container,:host([placement^=top]) .container{flex-direction:row}:host([placement^=left]) .container,:host([placement^=right]) .container{flex-direction:column}:host([placement$='-start']) .container{justify-content:flex-start}:host([placement=bottom]) .container,:host([placement=left]) .container,:host([placement=right]) .container,:host([placement=top]) .container{justify-content:center}:host([placement$='-end']) .container{justify-content:flex-end}.container::after{content:' ';position:absolute;background-color:rgb(var(--mdui-color-surface-variant))}:host([placement^=bottom]) .container::after,:host([placement^=top]) .container::after{left:0;width:100%;height:.0625rem}:host([placement^=top]) .container::after{bottom:0}:host([placement^=bottom]) .container::after{top:0}:host([placement^=left]) .container::after,:host([placement^=right]) .container::after{top:0;height:100%;width:.0625rem}:host([placement^=left]) .container::after{right:0}:host([placement^=right]) .container::after{left:0}.indicator{position:absolute;z-index:1;transition-duration:var(--mdui-motion-duration-medium2);transition-timing-function:var(--mdui-motion-easing-standard-decelerate);background-color:rgb(var(--mdui-color-primary))}:host([placement^=bottom]) .indicator,:host([placement^=top]) .indicator{transition-property:transform,left,width}:host([placement^=left]) .indicator,:host([placement^=right]) .indicator{transition-property:transform,top,height}:host([placement^=top]) .indicator{bottom:0}:host([placement^=bottom]) .indicator{top:0}:host([placement^=left]) .indicator{right:0}:host([placement^=right]) .indicator{left:0}:host([placement^=bottom][variant=primary]) .indicator,:host([placement^=top][variant=primary]) .indicator{height:.1875rem}:host([placement^=bottom][variant=secondary]) .indicator,:host([placement^=top][variant=secondary]) .indicator{height:.125rem}:host([placement^=left][variant=primary]) .indicator,:host([placement^=right][variant=primary]) .indicator{width:.1875rem}:host([placement^=left][variant=secondary]) .indicator,:host([placement^=right][variant=secondary]) .indicator{width:.125rem}:host([placement^=top][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-top-right-radius:.1875rem}:host([placement^=bottom][variant=primary]) .indicator{border-bottom-right-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=left][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=right][variant=primary]) .indicator{border-top-right-radius:.1875rem;border-bottom-right-radius:.1875rem}:host([full-width]) ::slotted(mdui-tab){flex:1}`;
2
+ export const tabsStyle = css `:host{position:relative;display:flex}:host([placement^=top]){flex-direction:column}:host([placement^=bottom]){flex-direction:column-reverse}:host([placement^=left]){flex-direction:row}:host([placement^=right]){flex-direction:row-reverse}.container{position:relative;display:flex;flex:0 0 auto;overflow-x:auto;background-color:rgb(var(--mdui-color-surface))}:host([placement^=bottom]) .container,:host([placement^=top]) .container{flex-direction:row}:host([placement^=left]) .container,:host([placement^=right]) .container{flex-direction:column}:host([placement$='-start']) .container{justify-content:flex-start}:host([placement=bottom]) .container,:host([placement=left]) .container,:host([placement=right]) .container,:host([placement=top]) .container{justify-content:center}:host([placement$='-end']) .container{justify-content:flex-end}.container::after{content:' ';position:absolute;background-color:rgb(var(--mdui-color-surface-variant))}:host([placement^=bottom]) .container::after,:host([placement^=top]) .container::after{left:0;width:100%;height:.0625rem}:host([placement^=top]) .container::after{bottom:0}:host([placement^=bottom]) .container::after{top:0}:host([placement^=left]) .container::after,:host([placement^=right]) .container::after{top:0;height:100%;width:.0625rem}:host([placement^=left]) .container::after{right:0}:host([placement^=right]) .container::after{left:0}.indicator{position:absolute;z-index:1;background-color:rgb(var(--mdui-color-primary))}.container:not(.initial) .indicator{transition-duration:var(--mdui-motion-duration-medium2);transition-timing-function:var(--mdui-motion-easing-standard-decelerate)}:host([placement^=bottom]) .indicator,:host([placement^=top]) .indicator{transition-property:transform,left,width}:host([placement^=left]) .indicator,:host([placement^=right]) .indicator{transition-property:transform,top,height}:host([placement^=top]) .indicator{bottom:0}:host([placement^=bottom]) .indicator{top:0}:host([placement^=left]) .indicator{right:0}:host([placement^=right]) .indicator{left:0}:host([placement^=bottom][variant=primary]) .indicator,:host([placement^=top][variant=primary]) .indicator{height:.1875rem}:host([placement^=bottom][variant=secondary]) .indicator,:host([placement^=top][variant=secondary]) .indicator{height:.125rem}:host([placement^=left][variant=primary]) .indicator,:host([placement^=right][variant=primary]) .indicator{width:.1875rem}:host([placement^=left][variant=secondary]) .indicator,:host([placement^=right][variant=secondary]) .indicator{width:.125rem}:host([placement^=top][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-top-right-radius:.1875rem}:host([placement^=bottom][variant=primary]) .indicator{border-bottom-right-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=left][variant=primary]) .indicator{border-top-left-radius:.1875rem;border-bottom-left-radius:.1875rem}:host([placement^=right][variant=primary]) .indicator{border-top-right-radius:.1875rem;border-bottom-right-radius:.1875rem}:host([full-width]) ::slotted(mdui-tab){flex:1}`;
@@ -1,9 +1,9 @@
1
- import { LitElement } from 'lit';
2
1
  import '@mdui/jq/methods/children.js';
3
2
  import '@mdui/jq/methods/css.js';
4
3
  import '@mdui/jq/methods/find.js';
5
4
  import '@mdui/jq/methods/get.js';
6
- import type { CSSResultGroup, TemplateResult } from 'lit';
5
+ import { MduiElement } from '@mdui/shared/base/mdui-element.js';
6
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
7
7
  /**
8
8
  * @summary 选项卡组件。需与 `<mdui-tab>` 和 `<mdui-tab-panel>` 组件配合使用
9
9
  *
@@ -27,7 +27,7 @@ import type { CSSResultGroup, TemplateResult } from 'lit';
27
27
  * @csspart container - `<mdui-tab>` 元素的容器
28
28
  * @csspart indicator - 激活状态指示器
29
29
  */
30
- export declare class Tabs extends LitElement {
30
+ export declare class Tabs extends MduiElement<TabsEventMap> {
31
31
  static styles: CSSResultGroup;
32
32
  /**
33
33
  * 选项卡形状。可选值为:
@@ -62,24 +62,28 @@ export declare class Tabs extends LitElement {
62
62
  */
63
63
  fullWidth: boolean;
64
64
  private activeKey;
65
+ private isInitial;
66
+ private readonly tabs;
67
+ private readonly panels;
65
68
  private activeTab?;
66
69
  private observeResize?;
67
- private tabs;
68
- private panels;
69
70
  private readonly containerRef;
70
71
  private readonly indicatorRef;
72
+ private readonly definedController;
71
73
  private onActiveKeyChange;
72
74
  private onValueChange;
73
75
  private onIndicatorChange;
74
- connectedCallback(): void;
75
76
  disconnectedCallback(): void;
77
+ protected firstUpdated(_changedProperties: PropertyValues): void;
76
78
  protected render(): TemplateResult;
77
- private syncTabsAndPanels;
78
79
  private onSlotChange;
79
80
  private onClick;
80
81
  private updateActive;
81
82
  private updateIndicator;
82
83
  }
84
+ export interface TabsEventMap {
85
+ change: CustomEvent<void>;
86
+ }
83
87
  declare global {
84
88
  interface HTMLElementTagNameMap {
85
89
  'mdui-tabs': Tabs;
@@ -1,15 +1,17 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, LitElement } from 'lit';
3
- import { customElement, property, state } from 'lit/decorators.js';
2
+ import { html } from 'lit';
3
+ import { customElement, property, queryAssignedElements, state, } from 'lit/decorators.js';
4
+ import { classMap } from 'lit/directives/class-map.js';
4
5
  import { createRef, ref } from 'lit/directives/ref.js';
5
6
  import { $ } from '@mdui/jq/$.js';
6
7
  import '@mdui/jq/methods/children.js';
7
8
  import '@mdui/jq/methods/css.js';
8
9
  import '@mdui/jq/methods/find.js';
9
10
  import '@mdui/jq/methods/get.js';
11
+ import { MduiElement } from '@mdui/shared/base/mdui-element.js';
12
+ import { DefinedController } from '@mdui/shared/controllers/defined.js';
10
13
  import { watch } from '@mdui/shared/decorators/watch.js';
11
14
  import { booleanConverter } from '@mdui/shared/helpers/decorator.js';
12
- import { emit } from '@mdui/shared/helpers/event.js';
13
15
  import { observeResize } from '@mdui/shared/helpers/observeResize.js';
14
16
  import { componentStyle } from '@mdui/shared/lit-styles/component-style.js';
15
17
  import { tabsStyle } from './tabs-style.js';
@@ -36,7 +38,7 @@ import { tabsStyle } from './tabs-style.js';
36
38
  * @csspart container - `<mdui-tab>` 元素的容器
37
39
  * @csspart indicator - 激活状态指示器
38
40
  */
39
- export let Tabs = class Tabs extends LitElement {
41
+ let Tabs = class Tabs extends MduiElement {
40
42
  constructor() {
41
43
  super(...arguments);
42
44
  /**
@@ -69,59 +71,61 @@ export let Tabs = class Tabs extends LitElement {
69
71
  this.fullWidth = false;
70
72
  // 因为 tab 的 value 可能会重复,所以在每个 tab 元素上都添加了一个唯一的 key,通过 activeKey 来记录激活状态的 key
71
73
  this.activeKey = 0;
72
- this.tabs = [];
73
- this.panels = [];
74
+ // 是否为初始状态,初始状态不触发 change 事件
75
+ this.isInitial = true;
74
76
  this.containerRef = createRef();
75
77
  this.indicatorRef = createRef();
78
+ this.definedController = new DefinedController(this, {
79
+ relatedElements: ['mdui-tab', 'mdui-tab-panel'],
80
+ });
76
81
  }
77
- onActiveKeyChange() {
78
- var _a;
82
+ async onActiveKeyChange() {
83
+ await this.definedController.whenDefined();
79
84
  // 根据 activeKey 读取对应 tab 的值
80
- this.value = (_a = this.tabs.find((tab) => tab.key === this.activeKey)) === null || _a === void 0 ? void 0 : _a.value;
81
- emit(this, 'change');
85
+ this.value = this.tabs.find((tab) => tab.key === this.activeKey)?.value;
86
+ this.updateActive();
87
+ if (!this.isInitial) {
88
+ this.emit('change');
89
+ }
82
90
  }
83
- onValueChange() {
84
- var _a;
91
+ async onValueChange() {
92
+ this.isInitial = !this.hasUpdated;
93
+ await this.definedController.whenDefined();
85
94
  const tab = this.tabs.find((tab) => tab.value === this.value);
86
- this.activeKey = (_a = tab === null || tab === void 0 ? void 0 : tab.key) !== null && _a !== void 0 ? _a : 0;
87
- this.updateActive();
95
+ this.activeKey = tab?.key ?? 0;
88
96
  }
89
- onIndicatorChange() {
97
+ async onIndicatorChange() {
98
+ await this.updateComplete;
90
99
  this.updateIndicator();
91
100
  }
92
- connectedCallback() {
93
- super.connectedCallback();
94
- this.syncTabsAndPanels();
95
- this.updateComplete.then(() => {
96
- this.observeResize = observeResize(this.containerRef.value, () => this.updateIndicator());
97
- });
98
- }
99
101
  disconnectedCallback() {
100
- var _a;
101
102
  super.disconnectedCallback();
102
- (_a = this.observeResize) === null || _a === void 0 ? void 0 : _a.unobserve();
103
+ this.observeResize?.unobserve();
103
104
  }
104
- render() {
105
- return html `<div ${ref(this.containerRef)} part="container" class="container"><slot @slotchange="${this.onSlotChange}" @click="${this.onClick}"></slot><div ${ref(this.indicatorRef)} part="indicator" class="indicator"></div></div><slot name="panel" @slotchange="${this.onSlotChange}"></slot>`;
105
+ firstUpdated(_changedProperties) {
106
+ super.firstUpdated(_changedProperties);
107
+ this.observeResize = observeResize(this.containerRef.value, () => this.updateIndicator());
106
108
  }
107
- syncTabsAndPanels() {
108
- this.tabs = $(this).find('mdui-tab').get();
109
- this.panels = $(this)
110
- .find('mdui-tab-panel[slot="panel"]')
111
- .get();
109
+ render() {
110
+ return html `<div ${ref(this.containerRef)} part="container" class="container ${classMap({ initial: this.isInitial })}"><slot @slotchange="${this.onSlotChange}" @click="${this.onClick}"></slot><div ${ref(this.indicatorRef)} part="indicator" class="indicator"></div></div><slot name="panel" @slotchange="${this.onSlotChange}"></slot>`;
112
111
  }
113
- onSlotChange() {
114
- this.syncTabsAndPanels();
112
+ async onSlotChange() {
113
+ await this.definedController.whenDefined();
115
114
  this.updateActive();
116
115
  }
117
- onClick(event) {
116
+ async onClick(event) {
118
117
  // event.button 为 0 时,为鼠标左键点击。忽略鼠标中键和右键
119
118
  if (event.button) {
120
119
  return;
121
120
  }
121
+ await this.definedController.whenDefined();
122
122
  const target = event.target;
123
123
  const tab = target.closest('mdui-tab');
124
+ if (!tab) {
125
+ return;
126
+ }
124
127
  this.activeKey = tab.key;
128
+ this.isInitial = false;
125
129
  this.updateActive();
126
130
  }
127
131
  updateActive() {
@@ -131,11 +135,10 @@ export let Tabs = class Tabs extends LitElement {
131
135
  return tab;
132
136
  })
133
137
  .find((tab) => tab.active);
134
- this.panels.forEach((panel) => { var _a; return (panel.active = panel.value === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.value)); });
138
+ this.panels.forEach((panel) => (panel.active = panel.value === this.activeTab?.value));
135
139
  this.updateIndicator();
136
140
  }
137
- async updateIndicator() {
138
- await this.updateComplete;
141
+ updateIndicator() {
139
142
  const activeTab = this.activeTab;
140
143
  const $indicator = $(this.indicatorRef.value);
141
144
  const isVertical = this.placement.startsWith('left') || this.placement.startsWith('right');
@@ -154,9 +157,9 @@ export let Tabs = class Tabs extends LitElement {
154
157
  : { transform: 'scaleX(1)', height: '', top: '' };
155
158
  let shownStyle = {};
156
159
  if (this.variant === 'primary') {
157
- const customSlots = $activeTab.find(':scope > [slot="custom"]').get();
158
- const children = customSlots.length
159
- ? customSlots
160
+ const $customSlots = $activeTab.find(':scope > [slot="custom"]');
161
+ const children = $customSlots.length
162
+ ? $customSlots.get()
160
163
  : $(activeTab.renderRoot)
161
164
  .find('slot[name="custom"]')
162
165
  .children()
@@ -205,6 +208,19 @@ __decorate([
205
208
  __decorate([
206
209
  state()
207
210
  ], Tabs.prototype, "activeKey", void 0);
211
+ __decorate([
212
+ state()
213
+ ], Tabs.prototype, "isInitial", void 0);
214
+ __decorate([
215
+ queryAssignedElements({ selector: 'mdui-tab', flatten: true })
216
+ ], Tabs.prototype, "tabs", void 0);
217
+ __decorate([
218
+ queryAssignedElements({
219
+ selector: 'mdui-tab-panel',
220
+ slot: 'panel',
221
+ flatten: true,
222
+ })
223
+ ], Tabs.prototype, "panels", void 0);
208
224
  __decorate([
209
225
  watch('activeKey', true)
210
226
  ], Tabs.prototype, "onActiveKeyChange", null);
@@ -219,3 +235,4 @@ __decorate([
219
235
  Tabs = __decorate([
220
236
  customElement('mdui-tabs')
221
237
  ], Tabs);
238
+ export { Tabs };
@@ -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';
@@ -7,8 +7,8 @@ import '@mdui/shared/icons/visibility.js';
7
7
  import '../button-icon.js';
8
8
  import '../icon.js';
9
9
  import type { FormControl } from '@mdui/jq/shared/form.js';
10
- import type { CSSResultGroup, TemplateResult } from 'lit';
11
- declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import("@mdui/shared/mixins/focusable.js").FocusableMixinInterface> & typeof LitElement;
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 MduiElement;
12
12
  /**
13
13
  * @summary 文本框组件
14
14
  *
@@ -53,7 +53,7 @@ declare const TextField_base: import("@open-wc/dedupe-mixin").Constructor<import
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`。可选值为:
@@ -324,7 +324,6 @@ export declare class TextField extends TextField_base implements FormControl {
324
324
  private onRowsChange;
325
325
  private onMaxRowsChange;
326
326
  private onMinRowsChange;
327
- connectedCallback(): void;
328
327
  disconnectedCallback(): void;
329
328
  /**
330
329
  * 选中文本框中的文本
@@ -366,6 +365,7 @@ export declare class TextField extends TextField_base implements FormControl {
366
365
  * @param message 自定义的提示文本
367
366
  */
368
367
  setCustomValidity(message: string): void;
368
+ protected firstUpdated(_changedProperties: PropertyValues): void;
369
369
  protected render(): TemplateResult;
370
370
  private onChange;
371
371
  private onClear;
@@ -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, LitElement } from 'lit';
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';
@@ -71,7 +71,7 @@ import { style } from './style.js';
71
71
  * @csspart error - 底部的错误描述文本
72
72
  * @csspart counter - 底部右侧的字数统计
73
73
  */
74
- export let TextField = class TextField extends FocusableMixin(LitElement) {
74
+ let TextField = class TextField extends FocusableMixin(MduiElement) {
75
75
  constructor() {
76
76
  super(...arguments);
77
77
  /**
@@ -200,8 +200,8 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
200
200
  * 如果值无法被转换为 `number` 类型,则会返回 `NaN`。
201
201
  */
202
202
  get valueAsNumber() {
203
- var _a, _b;
204
- return ((_b = (_a = this.inputRef.value) === null || _a === void 0 ? void 0 : _a.valueAsNumber) !== null && _b !== void 0 ? _b : parseFloat(this.value));
203
+ return (this.inputRef.value?.valueAsNumber ??
204
+ parseFloat(this.value));
205
205
  }
206
206
  set valueAsNumber(newValue) {
207
207
  const input = document.createElement('input');
@@ -234,13 +234,12 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
234
234
  this.invalid = !this.inputRef.value.checkValidity();
235
235
  }
236
236
  async onValueChange() {
237
- var _a;
238
237
  this.hasValue = !!this.value;
239
238
  if (this.hasUpdated) {
240
239
  await this.updateComplete;
241
240
  // reset 引起的值变更,不执行验证;直接修改值引起的变更,需要进行验证
242
241
  const form = this.formController.getForm();
243
- if (form && ((_a = formResets.get(form)) === null || _a === void 0 ? void 0 : _a.has(this))) {
242
+ if (form && formResets.get(form)?.has(this)) {
244
243
  this.invalid = false;
245
244
  formResets.get(form).delete(this);
246
245
  }
@@ -256,53 +255,31 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
256
255
  if (!this.autosize) {
257
256
  return;
258
257
  }
259
- // 设置最大高度,为 line-height * maxRows + padding-top + padding-bottom
260
- const setMaxHeight = () => {
261
- var _a;
262
- const $input = $(this.inputRef.value);
263
- $input.css('max-height', parseFloat($input.css('line-height')) * ((_a = this.maxRows) !== null && _a !== void 0 ? _a : 1) +
264
- parseFloat($input.css('padding-top')) +
265
- parseFloat($input.css('padding-bottom')));
266
- };
267
- if (this.hasUpdated) {
268
- setMaxHeight();
269
- }
270
- else {
258
+ if (!this.hasUpdated) {
271
259
  await this.updateComplete;
272
- setMaxHeight();
273
260
  }
261
+ // 设置最大高度,为 line-height * maxRows + padding-top + padding-bottom
262
+ const $input = $(this.inputRef.value);
263
+ $input.css('max-height', parseFloat($input.css('line-height')) * (this.maxRows ?? 1) +
264
+ parseFloat($input.css('padding-top')) +
265
+ parseFloat($input.css('padding-bottom')));
274
266
  }
275
267
  async onMinRowsChange() {
276
268
  if (!this.autosize) {
277
269
  return;
278
270
  }
279
- // 设置最小高度,为 line-height * minRows + padding-top + padding-bottom
280
- const setMinHeight = () => {
281
- var _a;
282
- const $input = $(this.inputRef.value);
283
- $input.css('min-height', parseFloat($input.css('line-height')) * ((_a = this.minRows) !== null && _a !== void 0 ? _a : 1) +
284
- parseFloat($input.css('padding-top')) +
285
- parseFloat($input.css('padding-bottom')));
286
- };
287
- if (this.hasUpdated) {
288
- setMinHeight();
289
- }
290
- else {
271
+ if (!this.hasUpdated) {
291
272
  await this.updateComplete;
292
- setMinHeight();
293
273
  }
294
- }
295
- connectedCallback() {
296
- super.connectedCallback();
297
- this.updateComplete.then(() => {
298
- this.setTextareaHeight();
299
- this.observeResize = observeResize(this.inputRef.value, () => this.setTextareaHeight());
300
- });
274
+ // 设置最小高度,为 line-height * minRows + padding-top + padding-bottom
275
+ const $input = $(this.inputRef.value);
276
+ $input.css('min-height', parseFloat($input.css('line-height')) * (this.minRows ?? 1) +
277
+ parseFloat($input.css('padding-top')) +
278
+ parseFloat($input.css('padding-bottom')));
301
279
  }
302
280
  disconnectedCallback() {
303
- var _a;
304
281
  super.disconnectedCallback();
305
- (_a = this.observeResize) === null || _a === void 0 ? void 0 : _a.unobserve();
282
+ this.observeResize?.unobserve();
306
283
  }
307
284
  /**
308
285
  * 选中文本框中的文本
@@ -336,8 +313,8 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
336
313
  if (this.value !== this.inputRef.value.value) {
337
314
  this.value = this.inputRef.value.value;
338
315
  this.setTextareaHeight();
339
- emit(this, 'input');
340
- emit(this, 'change');
316
+ this.emit('input');
317
+ this.emit('change');
341
318
  }
342
319
  }
343
320
  /**
@@ -346,7 +323,7 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
346
323
  checkValidity() {
347
324
  const valid = this.inputRef.value.checkValidity();
348
325
  if (!valid) {
349
- emit(this, 'invalid', {
326
+ this.emit('invalid', {
350
327
  bubbles: false,
351
328
  cancelable: true,
352
329
  composed: false,
@@ -362,7 +339,7 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
362
339
  reportValidity() {
363
340
  this.invalid = !this.inputRef.value.reportValidity();
364
341
  if (this.invalid) {
365
- emit(this, 'invalid', {
342
+ this.emit('invalid', {
366
343
  bubbles: false,
367
344
  cancelable: true,
368
345
  composed: false,
@@ -380,6 +357,11 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
380
357
  this.inputRef.value.setCustomValidity(message);
381
358
  this.invalid = !this.inputRef.value.checkValidity();
382
359
  }
360
+ firstUpdated(_changedProperties) {
361
+ super.firstUpdated(_changedProperties);
362
+ this.setTextareaHeight();
363
+ this.observeResize = observeResize(this.inputRef.value, () => this.setTextareaHeight());
364
+ }
383
365
  render() {
384
366
  const hasIcon = !!this.icon || this.hasSlotController.test('icon');
385
367
  const hasEndIcon = !!this.endIcon || this.hasSlotController.test('end-icon');
@@ -389,6 +371,10 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
389
371
  const hasCounter = this.counter && !!this.maxlength;
390
372
  // 存在 input slot 时,隐藏组件内部的 .input 元素,使用 slot 代替
391
373
  const hasInputSlot = this.hasSlotController.test('input');
374
+ const invalidClassNameObj = {
375
+ invalid: this.invalid,
376
+ 'invalid-style': this.invalidStyle,
377
+ };
392
378
  const className = classMap({
393
379
  container: true,
394
380
  'has-value': this.hasValue,
@@ -396,23 +382,24 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
396
382
  'has-end-icon': hasEndIcon,
397
383
  'has-error-icon': hasErrorIcon,
398
384
  'is-firefox': navigator.userAgent.includes('Firefox'),
385
+ ...invalidClassNameObj,
399
386
  });
400
387
  return html `<div part="container" class="${className}">${this.renderPrefix()}<div class="input-container">${this.renderLabel()} ${this.isTextarea
401
388
  ? this.renderTextArea(hasInputSlot)
402
- : 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="supporting">${this.renderHelper(hasError, hasHelper)} ${this.renderCounter(hasCounter)}</div>`)}`;
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>`)}`;
403
390
  }
404
391
  onChange() {
405
392
  this.value = this.inputRef.value.value;
406
393
  if (this.isTextarea) {
407
394
  this.setTextareaHeight();
408
395
  }
409
- emit(this, 'change');
396
+ this.emit('change');
410
397
  }
411
398
  onClear(event) {
412
399
  this.value = '';
413
- emit(this, 'clear');
414
- emit(this, 'input');
415
- emit(this, 'change');
400
+ this.emit('clear');
401
+ this.emit('input');
402
+ this.emit('change');
416
403
  this.focus();
417
404
  event.stopPropagation();
418
405
  }
@@ -421,7 +408,7 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
421
408
  if (this.isTextarea) {
422
409
  this.setTextareaHeight();
423
410
  }
424
- emit(this, 'input');
411
+ this.emit('input');
425
412
  }
426
413
  onInvalid(event) {
427
414
  event.preventDefault();
@@ -512,12 +499,11 @@ export let TextField = class TextField extends FocusableMixin(LitElement) {
512
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}">`;
513
500
  }
514
501
  renderTextArea(hasInputSlot) {
515
- var _a;
516
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(
517
503
  // @ts-ignore
518
504
  !this.label || this.isFocusedStyle || this.hasValue
519
505
  ? this.placeholder
520
- : undefined)}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" ?required="${this.required}" minlength="${ifDefined(this.minlength)}" maxlength="${ifDefined(this.maxlength)}" rows="${(_a = this.rows) !== null && _a !== void 0 ? _a : 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>`;
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>`;
521
507
  }
522
508
  /**
523
509
  * @param hasError 是否包含错误提示
@@ -701,19 +687,10 @@ __decorate([
701
687
  property({ reflect: true })
702
688
  ], TextField.prototype, "inputmode", void 0);
703
689
  __decorate([
704
- property({
705
- type: Boolean,
706
- reflect: true,
707
- converter: booleanConverter,
708
- })
690
+ state()
709
691
  ], TextField.prototype, "invalid", void 0);
710
692
  __decorate([
711
- property({
712
- type: Boolean,
713
- reflect: true,
714
- converter: booleanConverter,
715
- attribute: 'invalid-style',
716
- })
693
+ state()
717
694
  ], TextField.prototype, "invalidStyle", void 0);
718
695
  __decorate([
719
696
  property({
@@ -750,3 +727,4 @@ __decorate([
750
727
  TextField = __decorate([
751
728
  customElement('mdui-text-field')
752
729
  ], TextField);
730
+ export { TextField };
@@ -1,2 +1,2 @@
1
1
  import { css } from 'lit';
2
- export const style = css `:host{display:inline-block;width:100%}:host([disabled]){pointer-events:none}:host([type=hidden]){display:none}.container{position:relative;display:flex;align-items:center;transition:box-shadow var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard);padding:0 1rem}.container.has-icon{padding-left:.75rem}.container.has-end-icon,.container.has-error-icon{padding-right:.75rem}:host([variant=filled]) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-surface-variant));background-color:rgb(var(--mdui-color-surface-container-highest));border-radius:var(--mdui-shape-corner-extra-small) var(--mdui-shape-corner-extra-small) 0 0}:host([variant=filled][invalid-style]) .container,:host([variant=filled][invalid]) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-error))}:host([variant=filled]:hover) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-surface))}:host([variant=filled][invalid-style]:hover) .container,:host([variant=filled][invalid]:hover) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-error-container))}:host([variant=filled][focused-style]) .container,:host([variant=filled][focused]) .container{box-shadow:inset 0 -.125rem 0 0 rgb(var(--mdui-color-primary))}:host([variant=filled][focused-style][invalid-style]) .container,:host([variant=filled][focused-style][invalid]) .container,:host([variant=filled][focused][invalid-style]) .container,:host([variant=filled][focused][invalid]) .container{box-shadow:inset 0 -.125rem 0 0 rgb(var(--mdui-color-error))}:host([variant=filled][disabled]) .container{box-shadow:inset 0 -.0625rem 0 0 rgba(var(--mdui-color-on-surface),38%);background-color:rgba(var(--mdui-color-on-surface),4%)}:host([variant=outlined]) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-outline));border-radius:var(--mdui-shape-corner-extra-small)}:host([variant=outlined][invalid-style]) .container,:host([variant=outlined][invalid]) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-error))}:host([variant=outlined]:hover) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-on-surface))}:host([variant=outlined][invalid-style]:hover) .container,:host([variant=outlined][invalid]:hover) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-on-error-container))}:host([variant=outlined][focused-style]) .container,:host([variant=outlined][focused]) .container{box-shadow:inset 0 0 0 .125rem rgb(var(--mdui-color-primary))}:host([variant=outlined][focused-style][invalid-style]) .container,:host([variant=outlined][focused-style][invalid]) .container,:host([variant=outlined][focused][invalid-style]) .container,:host([variant=outlined][focused][invalid]) .container{box-shadow:inset 0 0 0 .125rem rgb(var(--mdui-color-error))}:host([variant=outlined][disabled]) .container{box-shadow:inset 0 0 0 .125rem rgba(var(--mdui-color-on-surface),12%)}.icon,.prefix,.right-icon,.suffix{display:flex;-webkit-user-select:none;user-select:none;color:rgb(var(--mdui-color-on-surface-variant))}:host([disabled]) .icon,:host([disabled]) .prefix,:host([disabled]) .right-icon,:host([disabled]) .suffix{color:rgba(var(--mdui-color-on-surface),38%)}:host([invalid-style]) .right-icon,:host([invalid-style]) .suffix,:host([invalid]) .right-icon,:host([invalid]) .suffix{color:rgb(var(--mdui-color-error))}:host([invalid-style]:hover) .right-icon,:host([invalid-style]:hover) .suffix,:host([invalid]:hover) .right-icon,:host([invalid]:hover) .suffix{color:rgb(var(--mdui-color-on-error-container))}:host([focused-style][invalid-style]) .right-icon,:host([focused-style][invalid-style]) .suffix,:host([focused-style][invalid]) .right-icon,:host([focused-style][invalid]) .suffix,:host([focused][invalid-style]) .right-icon,:host([focused][invalid-style]) .suffix,:host([focused][invalid]) .right-icon,:host([focused][invalid]) .suffix{color:rgb(var(--mdui-color-error))}.icon,.right-icon{font-size:1.5rem}.icon mdui-button-icon,.right-icon mdui-button-icon,::slotted(mdui-button-icon[slot]){margin-left:-.5rem;margin-right:-.5rem}.icon .i,.right-icon .i,::slotted([slot$=icon]){font-size:inherit}.has-icon .icon{margin-right:1rem}.has-end-icon .end-icon,.right-icon:not(.end-icon){margin-left:1rem}.prefix,.suffix{display:none;font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height)}:host([variant=filled][label]) .prefix,:host([variant=filled][label]) .suffix{padding-top:1rem}.has-value .prefix,.has-value .suffix,:host([focused-style]) .prefix,:host([focused-style]) .suffix,:host([focused]) .prefix,:host([focused]) .suffix{display:flex}.prefix{padding-right:.125rem}.suffix{padding-left:.125rem}.input-container{width:100%}.label{position:absolute;pointer-events:none;max-width:calc(100% - 1rem);display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;top:1rem;color:rgb(var(--mdui-color-on-surface-variant));font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height)}:host([invalid-style]) .label,:host([invalid]) .label{color:rgb(var(--mdui-color-error))}:host([variant=outlined]) .label{padding:0 .25rem;margin:0 -.25rem}:host([variant=outlined]:hover) .label{color:rgb(var(--mdui-color-on-surface))}:host([variant=filled][invalid-style]:hover) .label,:host([variant=filled][invalid]:hover) .label,:host([variant=outlined][invalid-style]:hover) .label,:host([variant=outlined][invalid]:hover) .label{color:rgb(var(--mdui-color-on-error-container))}:host([variant=filled][focused-style]) .label,:host([variant=filled][focused]) .label,:host([variant=outlined][focused-style]) .label,:host([variant=outlined][focused]) .label{color:rgb(var(--mdui-color-primary))}:host([variant=filled]) .has-value .label,:host([variant=filled][focused-style]) .label,:host([variant=filled][focused]) .label,:host([variant=filled][type=date]) .label,:host([variant=filled][type=datetime-local]) .label,:host([variant=filled][type=month]) .label,:host([variant=filled][type=time]) .label,:host([variant=filled][type=week]) .label{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height);top:.25rem}:host([variant=outlined]) .has-value .label,:host([variant=outlined][focused-style]) .label,:host([variant=outlined][focused]) .label,:host([variant=outlined][type=date]) .label,:host([variant=outlined][type=datetime-local]) .label,:host([variant=outlined][type=month]) .label,:host([variant=outlined][type=time]) .label,:host([variant=outlined][type=week]) .label{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height);top:-.5rem;left:.75rem;background-color:rgb(var(--mdui-color-background))}:host([variant=filled][focused-style][invalid-style]) .label,:host([variant=filled][focused-style][invalid]) .label,:host([variant=filled][focused][invalid-style]) .label,:host([variant=filled][focused][invalid]) .label,:host([variant=outlined][focused-style][invalid-style]) .label,:host([variant=outlined][focused-style][invalid]) .label,:host([variant=outlined][focused][invalid-style]) .label,:host([variant=outlined][focused][invalid]) .label{color:rgb(var(--mdui-color-error))}:host([variant=filled][disabled]) .label,:host([variant=outlined][disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}.input{display:flex;flex-wrap:wrap;width:100%;border:none;outline:0;background:0 0;-webkit-appearance:none;appearance:none;resize:none;cursor:inherit;font-family:inherit;padding:1rem 0;font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height);color:rgb(var(--mdui-color-on-surface));caret-color:rgb(var(--mdui-color-primary))}.input.hide-input{opacity:0;height:0;padding:0!important;overflow:hidden}.input::placeholder{color:rgb(var(--mdui-color-on-surface-variant))}:host([invalid-style]) .input,:host([invalid]) .input{caret-color:rgb(var(--mdui-color-error))}:host([disabled]) .input{color:rgba(var(--mdui-color-on-surface),38%)}:host([end-aligned]) .input{text-align:right}:host([variant=filled]) .label+.input{padding:1.5rem 0 .5rem 0}.supporting{display:flex;justify-content:space-between;padding:.25rem 1rem;color:rgb(var(--mdui-color-on-surface-variant))}:host([invalid-style]) .supporting,:host([invalid]) .supporting{color:rgb(var(--mdui-color-error))}.helper{display:block;opacity:1;transition:opacity var(--mdui-motion-duration-short4) var(--mdui-motion-easing-linear);font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}:host([disabled]) .helper{color:rgba(var(--mdui-color-on-surface),38%)}:host([helper-on-focus]) .helper{opacity:0}:host([helper-on-focus][focused-style]) .helper,:host([helper-on-focus][focused]) .helper{opacity:1}.error{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}.counter{flex-wrap:nowrap;padding-left:1rem;font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}::-ms-reveal{display:none}.is-firefox .input[type=date],.is-firefox .input[type=datetime-local],.is-firefox .input[type=time]{-webkit-clip-path:inset(0 2em 0 0);clip-path:inset(0 2em 0 0)}.input[type=number]::-webkit-inner-spin-button,.input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;display:none}.input[type=number]{-moz-appearance:textfield}.input[type=search]::-webkit-search-cancel-button{-webkit-appearance:none}`;
2
+ export const style = css `:host{display:inline-block;width:100%}:host([disabled]){pointer-events:none}:host([type=hidden]){display:none}.container{position:relative;display:flex;align-items:center;transition:box-shadow var(--mdui-motion-duration-short4) var(--mdui-motion-easing-standard);padding:0 1rem}.container.has-icon{padding-left:.75rem}.container.has-end-icon,.container.has-error-icon{padding-right:.75rem}:host([variant=filled]) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-surface-variant));background-color:rgb(var(--mdui-color-surface-container-highest));border-radius:var(--mdui-shape-corner-extra-small) var(--mdui-shape-corner-extra-small) 0 0}:host([variant=filled]) .container.invalid,:host([variant=filled]) .container.invalid-style{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-error))}:host([variant=filled]:hover) .container{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-surface))}:host([variant=filled]:hover) .container.invalid,:host([variant=filled]:hover) .container.invalid-style{box-shadow:inset 0 -.0625rem 0 0 rgb(var(--mdui-color-on-error-container))}:host([variant=filled][focused-style]) .container,:host([variant=filled][focused]) .container{box-shadow:inset 0 -.125rem 0 0 rgb(var(--mdui-color-primary))}:host([variant=filled][focused-style]) .container.invalid,:host([variant=filled][focused-style]) .container.invalid-style,:host([variant=filled][focused]) .container.invalid,:host([variant=filled][focused]) .container.invalid-style{box-shadow:inset 0 -.125rem 0 0 rgb(var(--mdui-color-error))}:host([variant=filled][disabled]) .container{box-shadow:inset 0 -.0625rem 0 0 rgba(var(--mdui-color-on-surface),38%);background-color:rgba(var(--mdui-color-on-surface),4%)}:host([variant=outlined]) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-outline));border-radius:var(--mdui-shape-corner-extra-small)}:host([variant=outlined]) .container.invalid,:host([variant=outlined]) .container.invalid-style{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-error))}:host([variant=outlined]:hover) .container{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-on-surface))}:host([variant=outlined]:hover) .container.invalid,:host([variant=outlined]:hover) .container.invalid-style{box-shadow:inset 0 0 0 .0625rem rgb(var(--mdui-color-on-error-container))}:host([variant=outlined][focused-style]) .container,:host([variant=outlined][focused]) .container{box-shadow:inset 0 0 0 .125rem rgb(var(--mdui-color-primary))}:host([variant=outlined][focused-style]) .container.invalid,:host([variant=outlined][focused-style]) .container.invalid-style,:host([variant=outlined][focused]) .container.invalid,:host([variant=outlined][focused]) .container.invalid-style{box-shadow:inset 0 0 0 .125rem rgb(var(--mdui-color-error))}:host([variant=outlined][disabled]) .container{box-shadow:inset 0 0 0 .125rem rgba(var(--mdui-color-on-surface),12%)}.icon,.prefix,.right-icon,.suffix{display:flex;-webkit-user-select:none;user-select:none;color:rgb(var(--mdui-color-on-surface-variant))}:host([disabled]) .icon,:host([disabled]) .prefix,:host([disabled]) .right-icon,:host([disabled]) .suffix{color:rgba(var(--mdui-color-on-surface),38%)}.invalid .right-icon,.invalid .suffix,.invalid-style .right-icon,.invalid-style .suffix{color:rgb(var(--mdui-color-error))}:host(:hover) .invalid .right-icon,:host(:hover) .invalid .suffix,:host(:hover) .invalid-style .right-icon,:host(:hover) .invalid-style .suffix{color:rgb(var(--mdui-color-on-error-container))}:host([focused-style]) .invalid .right-icon,:host([focused-style]) .invalid .suffix,:host([focused-style]) .invalid-style .right-icon,:host([focused-style]) .invalid-style .suffix,:host([focused]) .invalid .right-icon,:host([focused]) .invalid .suffix,:host([focused]) .invalid-style .right-icon,:host([focused]) .invalid-style .suffix{color:rgb(var(--mdui-color-error))}.icon,.right-icon{font-size:1.5rem}.icon mdui-button-icon,.right-icon mdui-button-icon,::slotted(mdui-button-icon[slot]){margin-left:-.5rem;margin-right:-.5rem}.icon .i,.right-icon .i,::slotted([slot$=icon]){font-size:inherit}.has-icon .icon{margin-right:1rem}.has-end-icon .end-icon,.right-icon:not(.end-icon){margin-left:1rem}.prefix,.suffix{display:none;font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height)}:host([variant=filled][label]) .prefix,:host([variant=filled][label]) .suffix{padding-top:1rem}.has-value .prefix,.has-value .suffix,:host([focused-style]) .prefix,:host([focused-style]) .suffix,:host([focused]) .prefix,:host([focused]) .suffix{display:flex}.prefix{padding-right:.125rem}.suffix{padding-left:.125rem}.input-container{width:100%}.label{position:absolute;pointer-events:none;max-width:calc(100% - 1rem);display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;top:1rem;color:rgb(var(--mdui-color-on-surface-variant));font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height)}.invalid .label,.invalid-style .label{color:rgb(var(--mdui-color-error))}:host([variant=outlined]) .label{padding:0 .25rem;margin:0 -.25rem}:host([variant=outlined]:hover) .label{color:rgb(var(--mdui-color-on-surface))}:host([variant=filled]:hover) .invalid .label,:host([variant=filled]:hover) .invalid-style .label,:host([variant=outlined]:hover) .invalid .label,:host([variant=outlined]:hover) .invalid-style .label{color:rgb(var(--mdui-color-on-error-container))}:host([variant=filled][focused-style]) .label,:host([variant=filled][focused]) .label,:host([variant=outlined][focused-style]) .label,:host([variant=outlined][focused]) .label{color:rgb(var(--mdui-color-primary))}:host([variant=filled]) .has-value .label,:host([variant=filled][focused-style]) .label,:host([variant=filled][focused]) .label,:host([variant=filled][type=date]) .label,:host([variant=filled][type=datetime-local]) .label,:host([variant=filled][type=month]) .label,:host([variant=filled][type=time]) .label,:host([variant=filled][type=week]) .label{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height);top:.25rem}:host([variant=outlined]) .has-value .label,:host([variant=outlined][focused-style]) .label,:host([variant=outlined][focused]) .label,:host([variant=outlined][type=date]) .label,:host([variant=outlined][type=datetime-local]) .label,:host([variant=outlined][type=month]) .label,:host([variant=outlined][type=time]) .label,:host([variant=outlined][type=week]) .label{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height);top:-.5rem;left:.75rem;background-color:rgb(var(--mdui-color-background))}:host([variant=filled][focused-style]) .invalid .label,:host([variant=filled][focused-style]) .invalid-style .label,:host([variant=filled][focused]) .invalid .label,:host([variant=filled][focused]) .invalid-style .label,:host([variant=outlined][focused-style]) .invalid .label,:host([variant=outlined][focused-style]) .invalid-style .label,:host([variant=outlined][focused]) .invalid .label,:host([variant=outlined][focused]) .invalid-style .label{color:rgb(var(--mdui-color-error))}:host([variant=filled][disabled]) .label,:host([variant=outlined][disabled]) .label{color:rgba(var(--mdui-color-on-surface),38%)}.input{display:flex;flex-wrap:wrap;width:100%;border:none;outline:0;background:0 0;-webkit-appearance:none;appearance:none;resize:none;cursor:inherit;font-family:inherit;padding:1rem 0;font-size:var(--mdui-typescale-body-large-size);font-weight:var(--mdui-typescale-body-large-weight);letter-spacing:var(--mdui-typescale-body-large-tracking);line-height:var(--mdui-typescale-body-large-line-height);color:rgb(var(--mdui-color-on-surface));caret-color:rgb(var(--mdui-color-primary))}.input.hide-input{opacity:0;height:0;padding:0!important;overflow:hidden}.input::placeholder{color:rgb(var(--mdui-color-on-surface-variant))}.invalid .input,.invalid-style .input{caret-color:rgb(var(--mdui-color-error))}:host([disabled]) .input{color:rgba(var(--mdui-color-on-surface),38%)}:host([end-aligned]) .input{text-align:right}:host([variant=filled]) .label+.input{padding:1.5rem 0 .5rem 0}.supporting{display:flex;justify-content:space-between;padding:.25rem 1rem;color:rgb(var(--mdui-color-on-surface-variant))}.supporting.invalid,.supporting.invalid-style{color:rgb(var(--mdui-color-error))}.helper{display:block;opacity:1;transition:opacity var(--mdui-motion-duration-short4) var(--mdui-motion-easing-linear);font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}:host([disabled]) .helper{color:rgba(var(--mdui-color-on-surface),38%)}:host([helper-on-focus]) .helper{opacity:0}:host([helper-on-focus][focused-style]) .helper,:host([helper-on-focus][focused]) .helper{opacity:1}.error{font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}.counter{flex-wrap:nowrap;padding-left:1rem;font-size:var(--mdui-typescale-body-small-size);font-weight:var(--mdui-typescale-body-small-weight);letter-spacing:var(--mdui-typescale-body-small-tracking);line-height:var(--mdui-typescale-body-small-line-height)}::-ms-reveal{display:none}.is-firefox .input[type=date],.is-firefox .input[type=datetime-local],.is-firefox .input[type=time]{-webkit-clip-path:inset(0 2em 0 0);clip-path:inset(0 2em 0 0)}.input[type=number]::-webkit-inner-spin-button,.input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;display:none}.input[type=number]{-moz-appearance:textfield}.input[type=search]::-webkit-search-cancel-button{-webkit-appearance:none}`;