@m3e/form-field 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,969 @@
1
+ /**
2
+ * @license MIT
3
+ * Copyright (c) 2025 matraic
4
+ * See LICENSE file in the project root for full license text.
5
+ */
6
+ import { LitElement, nothing, html, unsafeCSS, css } from 'lit';
7
+ import { AttachInternals, Role, MutationController, ResizeController, FocusController, HoverController, PressedController, isReadOnlyMixin, DesignToken, hasAssignedNodes, getTextContent } from '@m3e/core';
8
+ import { M3eAriaDescriber } from '@m3e/core/a11y';
9
+
10
+ /**
11
+ * Adapted from Angular Material Form Field Control
12
+ * Source: https://github.com/angular/components/blob/main/src/material/form-field/form-field-control.ts
13
+ *
14
+ * @license MIT
15
+ * Copyright (c) 2025 Google LLC
16
+ * See LICENSE file in the project root for full license text.
17
+ */
18
+ const KNOWN_FORM_FIELD_TAGS = ["m3e-input-chip-set", "m3e-select"];
19
+ /**
20
+ * Determines whether a value is a `FormFieldControl`.
21
+ * @param {unknown} value The value to test.
22
+ * @returns {value is FormFieldControl} A value indicating whether `value` is a `FormFieldControl`.
23
+ */
24
+ function isFormFieldControl(value) {
25
+ return (value instanceof HTMLElement &&
26
+ (value instanceof HTMLInputElement ||
27
+ value instanceof HTMLTextAreaElement ||
28
+ value instanceof HTMLSelectElement ||
29
+ KNOWN_FORM_FIELD_TAGS.includes(value.tagName.toLowerCase())));
30
+ }
31
+ /**
32
+ * Locates the first `FormFieldControl` in a given slot.
33
+ * @param {HTMLSlotElement} slot The slot in which to locate a `FormFieldControl`.
34
+ * @returns {FormFieldControl | null} The `FormFieldControl` located in `slot`.
35
+ */
36
+ function findFormFieldControl(slot) {
37
+ for (const element of slot.assignedElements({ flatten: true })) {
38
+ if (isFormFieldControl(element)) {
39
+ return element;
40
+ }
41
+ const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT);
42
+ while (walker.nextNode()) {
43
+ if (isFormFieldControl(walker.currentNode)) {
44
+ return walker.currentNode;
45
+ }
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+
51
+ /******************************************************************************
52
+ Copyright (c) Microsoft Corporation.
53
+
54
+ Permission to use, copy, modify, and/or distribute this software for any
55
+ purpose with or without fee is hereby granted.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
58
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
59
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
60
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
61
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
62
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
63
+ PERFORMANCE OF THIS SOFTWARE.
64
+ ***************************************************************************** */
65
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
66
+
67
+
68
+ function __decorate(decorators, target, key, desc) {
69
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
70
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
71
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
73
+ }
74
+
75
+ function __classPrivateFieldGet(receiver, state, kind, f) {
76
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
77
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
78
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
79
+ }
80
+
81
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
82
+ if (kind === "m") throw new TypeError("Private method is not writable");
83
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
84
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
85
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
86
+ }
87
+
88
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
89
+ var e = new Error(message);
90
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
91
+ };
92
+
93
+ /**
94
+ * @license
95
+ * Copyright 2017 Google LLC
96
+ * SPDX-License-Identifier: BSD-3-Clause
97
+ */
98
+ const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
99
+
100
+ /**
101
+ * @license
102
+ * Copyright 2019 Google LLC
103
+ * SPDX-License-Identifier: BSD-3-Clause
104
+ */
105
+ const t=globalThis,e$3=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o$2=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$3&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$3)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$1=e$3?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
106
+
107
+ /**
108
+ * @license
109
+ * Copyright 2017 Google LLC
110
+ * SPDX-License-Identifier: BSD-3-Clause
111
+ */const{is:i,defineProperty:e$2,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$2,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f=(t,s)=>!i(t,s),b={attribute:true,type:String,converter:u,reflect:false,useDefault:false,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$2(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r$2(t),...o$1(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$1(s));}else void 0!==s&&i.push(c$1(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.1");
112
+
113
+ /**
114
+ * @license
115
+ * Copyright 2017 Google LLC
116
+ * SPDX-License-Identifier: BSD-3-Clause
117
+ */const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r$1=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
118
+
119
+ /**
120
+ * @license
121
+ * Copyright 2017 Google LLC
122
+ * SPDX-License-Identifier: BSD-3-Clause
123
+ */function r(r){return n({...r,state:true,attribute:false})}
124
+
125
+ /**
126
+ * @license
127
+ * Copyright 2017 Google LLC
128
+ * SPDX-License-Identifier: BSD-3-Clause
129
+ */
130
+ const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
131
+
132
+ /**
133
+ * @license
134
+ * Copyright 2017 Google LLC
135
+ * SPDX-License-Identifier: BSD-3-Clause
136
+ */function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$1(n,s,{get(){return o(this)}})}}
137
+
138
+ /**
139
+ * Adapted from Angular Material Form Field
140
+ * Source: https://github.com/angular/components/blob/main/src/material/form-field/form-field.ts
141
+ *
142
+ * @license MIT
143
+ * Copyright (c) 2025 Google LLC
144
+ * See LICENSE file in the project root for full license text.
145
+ */
146
+ var _M3eFormFieldElement_instances, _M3eFormFieldElement_control, _M3eFormFieldElement_formResetHandler, _M3eFormFieldElement_controlInvalidHandler, _M3eFormFieldElement_controlMutationController, _M3eFormFieldElement_resizeController, _M3eFormFieldElement_focusController, _M3eFormFieldElement_hintMutationController, _M3eFormFieldElement_errorMutationController, _M3eFormFieldElement_focused, _M3eFormFieldElement_hintText, _M3eFormFieldElement_errorText, _M3eFormFieldElement_shouldFloatLabel_get, _M3eFormFieldElement_stopPropagation, _M3eFormFieldElement_handleLabelSlotChange, _M3eFormFieldElement_handlePrefixSlotChange, _M3eFormFieldElement_handleSuffixSlotChange, _M3eFormFieldElement_handlePrefixResize, _M3eFormFieldElement_handleSlotChange, _M3eFormFieldElement_handleContainerClick, _M3eFormFieldElement_handleControlInvalid, _M3eFormFieldElement_handleControlChange, _M3eFormFieldElement_handleFormReset, _M3eFormFieldElement_changeControl, _M3eFormFieldElement_handleHintChange, _M3eFormFieldElement_handleErrorChange;
147
+ /**
148
+ * @summary
149
+ * A container for form controls that applies Material Design styling and behavior.
150
+ *
151
+ * @description
152
+ * The `m3e-form-field` component is a semantic, expressive container for form controls that anchors
153
+ * label behavior, subscript messaging, and variant-specific layout. Designed according to Material Design 3
154
+ * guidelines, it supports two visual variants—`outlined` and `filled`—each with dynamic elevation,
155
+ * shape transitions, and adaptive color theming. The component responds to control state changes
156
+ * (focus, hover, press, disabled, invalid) with smooth motion and semantic clarity, ensuring
157
+ * visual hierarchy and emotional resonance.
158
+
159
+ * The component is accessible by default, with ARIA annotations, contrast-safe color tokens,
160
+ * and dynamic descriptions for hint and error messaging. It supports prefix and suffix content,
161
+ * floating labels, and adaptive subscript visibility. When hosting a control with validation,
162
+ * error messages are surfaced with `aria-invalid` and described for assistive technology.
163
+
164
+ * Native form controls may not expose full state or messaging on their own. `m3e-form-field` bridges
165
+ * these gaps by coordinating label floating, container styling, and subscript feedback.
166
+ *
167
+ * @example
168
+ * The following example illustrates a basic usage of the `m3e-form-field`.
169
+ * ```html
170
+ * <m3e-form-field>
171
+ * <label slot="label" for="field">Text field</label>
172
+ * <input id="field" />
173
+ * </m3e-form-field>
174
+ * ```
175
+ *
176
+ * @tag m3e-form-field
177
+ *
178
+ * @slot - Renders the control of the field.
179
+ * @slot prefix - Renders content before the fields's control.
180
+ * @slot prefix-text - Renders text before the fields's control.
181
+ * @slot suffix - Renders content after the fields's control.
182
+ * @slot suffix-text - Renders text after the fields's control.
183
+ * @slot hint - Renders hint text in the fields's subscript, when the control is valid.
184
+ * @slot error - Renders error text in the fields's subscript, when the control is invalid.
185
+ *
186
+ * @attr float-label - Specifies whether the label should float always or only when necessary.
187
+ * @attr hide-required-marker - Whether the required marker should be hidden.
188
+ * @attr hide-subscript - Whether subscript content is hidden.
189
+ * @attr variant - The appearance variant of the field.
190
+ *
191
+ * @cssprop --m3e-form-field-font-size - Font size for the form field container text.
192
+ * @cssprop --m3e-form-field-font-weight - Font weight for the form field container text.
193
+ * @cssprop --m3e-form-field-line-height - Line height for the form field container text.
194
+ * @cssprop --m3e-form-field-tracking - Letter spacing for the form field container text.
195
+ * @cssprop --m3e-form-field-label-font-size - Font size for the floating label.
196
+ * @cssprop --m3e-form-field-label-font-weight - Font weight for the floating label.
197
+ * @cssprop --m3e-form-field-label-line-height - Line height for the floating label.
198
+ * @cssprop --m3e-form-field-label-tracking - Letter spacing for the floating label.
199
+ * @cssprop --m3e-form-field-subscript-font-size - Font size for hint and error text.
200
+ * @cssprop --m3e-form-field-subscript-font-weight - Font weight for hint and error text.
201
+ * @cssprop --m3e-form-field-subscript-line-height - Line height for hint and error text.
202
+ * @cssprop --m3e-form-field-subscript-tracking - Letter spacing for hint and error text.
203
+ * @cssprop --m3e-form-field-color - Text color for the form field container.
204
+ * @cssprop --m3e-form-field-subscript-color - Color for hint and error text.
205
+ * @cssprop --m3e-form-field-invalid-color - Color used when the control is invalid.
206
+ * @cssprop --m3e-form-field-focused-outline-color - Outline color when focused.
207
+ * @cssprop --m3e-form-field-focused-color - Label color when focused.
208
+ * @cssprop --m3e-form-field-outline-color - Outline color in outlined variant.
209
+ * @cssprop --m3e-form-field-container-color - Background color in filled variant.
210
+ * @cssprop --m3e-form-field-hover-container-color - Hover background color in filled variant.
211
+ * @cssprop --m3e-form-field-width - Width of the form field container.
212
+ * @cssprop --m3e-form-field-icon-size - Size of prefix and suffix icons.
213
+ * @cssprop --m3e-outlined-form-field-container-shape - Corner radius for outlined container.
214
+ * @cssprop --m3e-form-field-container-shape - Corner radius for filled container.
215
+ * @cssprop --m3e-form-field-hover-container-opacity - Opacity for hover background in filled variant.
216
+ * @cssprop --m3e-form-field-disabled-opacity - Opacity for disabled text.
217
+ * @cssprop --m3e-form-field-disabled-container-opacity - Opacity for disabled container background.
218
+ */
219
+ let M3eFormFieldElement = class M3eFormFieldElement extends AttachInternals(Role(LitElement, "none")) {
220
+ constructor() {
221
+ super();
222
+ _M3eFormFieldElement_instances.add(this);
223
+ /** @private */ _M3eFormFieldElement_control.set(this, null);
224
+ /** @private */ _M3eFormFieldElement_formResetHandler.set(this, () => __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleFormReset).call(this));
225
+ /** @private */ _M3eFormFieldElement_controlInvalidHandler.set(this, () => __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleControlInvalid).call(this));
226
+ /** @private */
227
+ _M3eFormFieldElement_controlMutationController.set(this, new MutationController(this, {
228
+ target: null,
229
+ config: { attributeFilter: ["disabled", "readonly", "required"] },
230
+ callback: () => this.notifyControlStateChange(),
231
+ }));
232
+ /** @private */
233
+ _M3eFormFieldElement_resizeController.set(this, new ResizeController(this, {
234
+ target: null,
235
+ callback: () => __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handlePrefixResize).call(this),
236
+ }));
237
+ /** @private */
238
+ _M3eFormFieldElement_focusController.set(this, new FocusController(this, {
239
+ target: null,
240
+ callback: (focused) => {
241
+ focused = focused && !(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.disabled ?? true);
242
+ this.classList.toggle("-no-animate", false);
243
+ __classPrivateFieldSet(this, _M3eFormFieldElement_focused, focused, "f");
244
+ if (focused) {
245
+ this.classList.toggle("-float-label", true);
246
+ }
247
+ else {
248
+ this._invalid = !(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.checkValidity?.() ?? true);
249
+ this.notifyControlStateChange();
250
+ }
251
+ },
252
+ }));
253
+ /** @private */
254
+ _M3eFormFieldElement_hintMutationController.set(this, new MutationController(this, {
255
+ target: null,
256
+ config: { childList: true, subtree: true },
257
+ callback: () => __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleHintChange).call(this),
258
+ }));
259
+ /** @private */
260
+ _M3eFormFieldElement_errorMutationController.set(this, new MutationController(this, {
261
+ target: null,
262
+ config: { childList: true, subtree: true },
263
+ callback: () => __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleErrorChange).call(this),
264
+ }));
265
+ /** @private */ _M3eFormFieldElement_focused.set(this, false);
266
+ /** @private */ this._pseudoLabel = "";
267
+ /** @private */ this._required = false;
268
+ /** @private */ this._invalid = false;
269
+ /** @private */ this._validationMessage = "";
270
+ /** @private */ _M3eFormFieldElement_hintText.set(this, "");
271
+ /** @private */ _M3eFormFieldElement_errorText.set(this, "");
272
+ /**
273
+ * The appearance variant of the field.
274
+ * @default "outlined"
275
+ */
276
+ this.variant = "outlined";
277
+ /**
278
+ * Whether the required marker should be hidden.
279
+ * @default false
280
+ */
281
+ this.hideRequiredMarker = false;
282
+ /**
283
+ * Whether subscript content is hidden.
284
+ * @default "auto"
285
+ */
286
+ this.hideSubscript = "auto";
287
+ /**
288
+ * Specifies whether the label should float always or only when necessary.
289
+ * @default "auto"
290
+ */
291
+ this.floatLabel = "auto";
292
+ new HoverController(this, { callback: () => this.classList.toggle("-no-animate", false) });
293
+ new PressedController(this, {
294
+ callback: (pressed) => this.classList.toggle("-pressed", pressed && !(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.disabled ?? true)),
295
+ });
296
+ }
297
+ /** A reference to the hosted form field control. */
298
+ get control() {
299
+ return __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f");
300
+ }
301
+ /**
302
+ * Notifies the form field that the state of the hosted `control` has changed.
303
+ * @param [checkValidity=false] Whether to check validity.
304
+ */
305
+ notifyControlStateChange(checkValidity = false) {
306
+ this._required = __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.required === true;
307
+ this.classList.toggle("-required", this._required);
308
+ this.classList.toggle("-disabled", __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.disabled === true);
309
+ this.classList.toggle("-readonly", isReadOnlyMixin(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")) && __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").readOnly === true);
310
+ if (this.floatLabel === "auto") {
311
+ this.classList.toggle("-float-label", __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "a", _M3eFormFieldElement_shouldFloatLabel_get) || __classPrivateFieldGet(this, _M3eFormFieldElement_focused, "f"));
312
+ }
313
+ if (checkValidity) {
314
+ this._invalid = !(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.checkValidity?.() ?? true);
315
+ }
316
+ this.classList.toggle("-invalid", this._invalid);
317
+ this._validationMessage = __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.validationMessage ?? "";
318
+ if (!this.isUpdatePending) {
319
+ this.performUpdate();
320
+ }
321
+ }
322
+ /** @inheritdoc */
323
+ connectedCallback() {
324
+ super.connectedCallback();
325
+ // Label animations are disabled on initial paint.
326
+ this.classList.toggle("-no-animate", true);
327
+ }
328
+ /** @inheritdoc */
329
+ disconnectedCallback() {
330
+ super.disconnectedCallback();
331
+ __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_changeControl).call(this, null);
332
+ }
333
+ /** @private */
334
+ firstUpdated(_changedProperties) {
335
+ super.firstUpdated(_changedProperties);
336
+ __classPrivateFieldGet(this, _M3eFormFieldElement_focusController, "f").observe(this._base);
337
+ __classPrivateFieldGet(this, _M3eFormFieldElement_hintMutationController, "f").observe(this._hint);
338
+ __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleHintChange).call(this);
339
+ __classPrivateFieldGet(this, _M3eFormFieldElement_errorMutationController, "f").observe(this._error);
340
+ __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleErrorChange).call(this);
341
+ }
342
+ /** @inheritdoc */
343
+ update(changedProperties) {
344
+ super.update(changedProperties);
345
+ if (changedProperties.has("_invalid") && __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")) {
346
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").ariaInvalid = this._invalid ? "true" : null;
347
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f")) {
348
+ if (this._invalid) {
349
+ M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
350
+ }
351
+ else {
352
+ M3eAriaDescriber.removeDescription(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
353
+ }
354
+ }
355
+ }
356
+ }
357
+ /** @inheritdoc */
358
+ render() {
359
+ return html `<div class="base" @click="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleContainerClick)}">
360
+ ${this.variant === "outlined"
361
+ ? html `<div class="outline" aria-hidden="true">
362
+ <div class="outline-start"></div>
363
+ <div class="outline-notch">
364
+ <div class="pseudo-label">
365
+ ${this._pseudoLabel} ${!this.hideRequiredMarker && this._required ? html `&nbsp;*` : nothing}
366
+ </div>
367
+ </div>
368
+ <div class="outline-end"></div>
369
+ </div>`
370
+ : nothing}
371
+ <div class="prefix">
372
+ <slot name="prefix" @slotchange="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handlePrefixSlotChange)}"></slot>
373
+ </div>
374
+ <div class="content">
375
+ <span class="prefix-text"><slot name="prefix-text"></slot></span>
376
+ <span class="input">
377
+ <slot @slotchange="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleSlotChange)}" @change="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleControlChange)}"></slot>
378
+ </span>
379
+ <span class="suffix-text"><slot name="suffix-text"></slot></span>
380
+ <span class="label">
381
+ <slot name="label" @slotchange="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleLabelSlotChange)}"></slot>
382
+ ${!this.hideRequiredMarker && this._required
383
+ ? html `<span class="required-marker" aria-hidden="true">&nbsp;*</span>`
384
+ : nothing}
385
+ </span>
386
+ </div>
387
+ <div class="suffix" @click="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_stopPropagation)}">
388
+ <slot name="suffix" @slotchange="${__classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_handleSuffixSlotChange)}"></slot>
389
+ </div>
390
+ </div>
391
+ <span class="subscript" aria-hidden="true">
392
+ <span class="error"><slot name="error">${this._validationMessage}</slot></span>
393
+ <span class="hint"><slot name="hint"></slot></span>
394
+ </span>`;
395
+ }
396
+ };
397
+ _M3eFormFieldElement_control = new WeakMap();
398
+ _M3eFormFieldElement_formResetHandler = new WeakMap();
399
+ _M3eFormFieldElement_controlInvalidHandler = new WeakMap();
400
+ _M3eFormFieldElement_controlMutationController = new WeakMap();
401
+ _M3eFormFieldElement_resizeController = new WeakMap();
402
+ _M3eFormFieldElement_focusController = new WeakMap();
403
+ _M3eFormFieldElement_hintMutationController = new WeakMap();
404
+ _M3eFormFieldElement_errorMutationController = new WeakMap();
405
+ _M3eFormFieldElement_focused = new WeakMap();
406
+ _M3eFormFieldElement_hintText = new WeakMap();
407
+ _M3eFormFieldElement_errorText = new WeakMap();
408
+ _M3eFormFieldElement_instances = new WeakSet();
409
+ _M3eFormFieldElement_shouldFloatLabel_get = function _M3eFormFieldElement_shouldFloatLabel_get() {
410
+ return __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.shouldLabelFloat !== undefined
411
+ ? __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").shouldLabelFloat === true
412
+ : typeof __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.value == "string" && __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").value.length > 0;
413
+ };
414
+ _M3eFormFieldElement_stopPropagation = function _M3eFormFieldElement_stopPropagation(e) {
415
+ e.stopImmediatePropagation();
416
+ e.stopPropagation();
417
+ };
418
+ _M3eFormFieldElement_handleLabelSlotChange = function _M3eFormFieldElement_handleLabelSlotChange(e) {
419
+ const assignedElements = e.target.assignedElements({ flatten: true });
420
+ this.classList.toggle("-with-label", assignedElements.length > 0);
421
+ this._pseudoLabel = assignedElements[0]?.textContent ?? "";
422
+ };
423
+ _M3eFormFieldElement_handlePrefixSlotChange = function _M3eFormFieldElement_handlePrefixSlotChange(e) {
424
+ this.classList.toggle("-with-prefix", hasAssignedNodes(e.target));
425
+ __classPrivateFieldGet(this, _M3eFormFieldElement_resizeController, "f").observe(this._prefix);
426
+ };
427
+ _M3eFormFieldElement_handleSuffixSlotChange = function _M3eFormFieldElement_handleSuffixSlotChange(e) {
428
+ this.classList.toggle("-with-suffix", hasAssignedNodes(e.target));
429
+ };
430
+ _M3eFormFieldElement_handlePrefixResize = function _M3eFormFieldElement_handlePrefixResize() {
431
+ if (this.variant === "outlined") {
432
+ this._base.style.setProperty("--_prefix-width", `${this._prefix.clientWidth}px`);
433
+ }
434
+ };
435
+ _M3eFormFieldElement_handleSlotChange = function _M3eFormFieldElement_handleSlotChange(e) {
436
+ __classPrivateFieldGet(this, _M3eFormFieldElement_instances, "m", _M3eFormFieldElement_changeControl).call(this, findFormFieldControl(e.target));
437
+ };
438
+ _M3eFormFieldElement_handleContainerClick = function _M3eFormFieldElement_handleContainerClick(e) {
439
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") && !__classPrivateFieldGet(this, _M3eFormFieldElement_focused, "f") && !__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").disabled) {
440
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").onContainerClick) {
441
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").onContainerClick(e);
442
+ }
443
+ else {
444
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").focus();
445
+ }
446
+ }
447
+ };
448
+ _M3eFormFieldElement_handleControlInvalid = function _M3eFormFieldElement_handleControlInvalid() {
449
+ this._invalid = true;
450
+ this.notifyControlStateChange();
451
+ };
452
+ _M3eFormFieldElement_handleControlChange = function _M3eFormFieldElement_handleControlChange() {
453
+ this._invalid = !(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.checkValidity?.() ?? true);
454
+ this.notifyControlStateChange();
455
+ };
456
+ _M3eFormFieldElement_handleFormReset = function _M3eFormFieldElement_handleFormReset() {
457
+ this._invalid = false;
458
+ this.notifyControlStateChange();
459
+ };
460
+ _M3eFormFieldElement_changeControl = function _M3eFormFieldElement_changeControl(control) {
461
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") === control)
462
+ return;
463
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")) {
464
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f")) {
465
+ M3eAriaDescriber.removeDescription(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f"));
466
+ }
467
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f")) {
468
+ M3eAriaDescriber.removeDescription(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
469
+ }
470
+ __classPrivateFieldGet(this, _M3eFormFieldElement_controlMutationController, "f").unobserve(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"));
471
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").removeEventListener("invalid", __classPrivateFieldGet(this, _M3eFormFieldElement_controlInvalidHandler, "f"));
472
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").form?.removeEventListener("reset", __classPrivateFieldGet(this, _M3eFormFieldElement_formResetHandler, "f"));
473
+ }
474
+ __classPrivateFieldSet(this, _M3eFormFieldElement_control, control, "f");
475
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")) {
476
+ __classPrivateFieldGet(this, _M3eFormFieldElement_controlMutationController, "f").observe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"));
477
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").addEventListener("invalid", __classPrivateFieldGet(this, _M3eFormFieldElement_controlInvalidHandler, "f"));
478
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").form?.addEventListener("reset", __classPrivateFieldGet(this, _M3eFormFieldElement_formResetHandler, "f"));
479
+ __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f").removeAttribute("aria-invalid");
480
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f")) {
481
+ M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f"));
482
+ }
483
+ this.notifyControlStateChange();
484
+ }
485
+ };
486
+ _M3eFormFieldElement_handleHintChange = function _M3eFormFieldElement_handleHintChange() {
487
+ const hintText = getTextContent(this._hint, true);
488
+ if (hintText === __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f"))
489
+ return;
490
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") && __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f")) {
491
+ M3eAriaDescriber.removeDescription(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f"));
492
+ }
493
+ __classPrivateFieldSet(this, _M3eFormFieldElement_hintText, hintText, "f");
494
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") && __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f")) {
495
+ M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_hintText, "f"));
496
+ }
497
+ };
498
+ _M3eFormFieldElement_handleErrorChange = function _M3eFormFieldElement_handleErrorChange() {
499
+ const errorText = getTextContent(this._error, true);
500
+ if (errorText === __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"))
501
+ return;
502
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") && __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f")) {
503
+ M3eAriaDescriber.removeDescription(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
504
+ }
505
+ __classPrivateFieldSet(this, _M3eFormFieldElement_errorText, errorText, "f");
506
+ if (__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f") && __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f") && this._invalid) {
507
+ M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
508
+ }
509
+ };
510
+ /** The styles of the element. */
511
+ M3eFormFieldElement.styles = css `
512
+ :host {
513
+ display: inline-flex;
514
+ flex-direction: column;
515
+ vertical-align: middle;
516
+ font-size: var(--m3e-form-field-font-size, ${DesignToken.typescale.standard.body.large.fontSize});
517
+ font-weight: var(--m3e-form-field-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});
518
+ line-height: var(--m3e-form-field-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});
519
+ letter-spacing: var(--m3e-form-field-tracking, ${DesignToken.typescale.standard.body.large.tracking});
520
+ width: var(--m3e-form-field-width, 14.5rem);
521
+ color: var(--_form-field-color);
522
+ }
523
+ .base {
524
+ display: flex;
525
+ align-items: center;
526
+ position: relative;
527
+ min-height: calc(3.5rem + ${DesignToken.density.calc(-2)});
528
+ --_form-field-label-font-size: var(
529
+ --m3e-form-field-label-font-size,
530
+ ${DesignToken.typescale.standard.body.small.fontSize}
531
+ );
532
+ --_form-field-label-line-height: var(
533
+ --m3e-form-field-label-line-height,
534
+ ${DesignToken.typescale.standard.body.small.lineHeight}
535
+ );
536
+ }
537
+ .content {
538
+ display: flex;
539
+ align-items: center;
540
+ position: relative;
541
+ flex: 1 1 auto;
542
+ min-width: 0;
543
+ min-height: var(--m3e-form-field-icon-size, 1.5rem);
544
+ }
545
+ .prefix,
546
+ .suffix {
547
+ display: flex;
548
+ align-items: center;
549
+ position: relative;
550
+ user-select: none;
551
+ flex: none;
552
+ font-size: var(--m3e-form-field-icon-size, 1.5rem);
553
+ }
554
+ .prefix-text,
555
+ .suffix-text {
556
+ opacity: 1;
557
+ transition: opacity ${DesignToken.motion.duration.extraLong1};
558
+ user-select: none;
559
+ flex: none;
560
+ }
561
+ .input {
562
+ display: inline-flex;
563
+ flex-wrap: wrap;
564
+ flex: 1 1 auto;
565
+ min-width: 0;
566
+ }
567
+ .label {
568
+ display: flex;
569
+ position: absolute;
570
+ pointer-events: none;
571
+ user-select: none;
572
+ top: 0;
573
+ left: 0;
574
+ right: 0;
575
+ font-size: var(--m3e-form-field-label-font-size, ${DesignToken.typescale.standard.body.small.fontSize});
576
+ font-weight: var(--m3e-form-field-label-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight});
577
+ line-height: var(--m3e-form-field-label-line-height, ${DesignToken.typescale.standard.body.small.lineHeight});
578
+ letter-spacing: var(--m3e-form-field-label-tracking, ${DesignToken.typescale.standard.body.small.tracking});
579
+ color: var(--_form-field-label-color, inherit);
580
+ transition: ${unsafeCSS(`top ${DesignToken.motion.duration.short4},
581
+ font-size ${DesignToken.motion.duration.short4},
582
+ line-height ${DesignToken.motion.duration.short4}`)};
583
+ }
584
+ :host(.-with-select) .label {
585
+ margin-right: 1.5rem;
586
+ }
587
+ ::slotted([slot="label"]) {
588
+ white-space: nowrap;
589
+ overflow: hidden;
590
+ text-overflow: ellipsis;
591
+ }
592
+ .subscript {
593
+ display: inline-flex;
594
+ width: 100%;
595
+ margin-top: 0.25rem;
596
+ font-size: var(--m3e-form-field-subscript-font-size, ${DesignToken.typescale.standard.body.small.fontSize});
597
+ font-weight: var(--m3e-form-field-subscript-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight});
598
+ line-height: var(--m3e-form-field-subscript-line-height, ${DesignToken.typescale.standard.body.small.lineHeight});
599
+ letter-spacing: var(--m3e-form-field-subscript-tracking, ${DesignToken.typescale.standard.body.small.tracking});
600
+ min-height: var(--m3e-form-field-subscript-line-height, ${DesignToken.typescale.standard.body.small.lineHeight});
601
+ color: var(--m3e-form-field-subscript-color, ${DesignToken.color.onSurfaceVariant});
602
+ }
603
+ .error,
604
+ .hint {
605
+ flex: 1 1 auto;
606
+ }
607
+ :host([hide-subscript="always"]) .subscript {
608
+ display: none;
609
+ }
610
+ :host([hide-subscript="auto"]:not(.-invalid)) .subscript {
611
+ opacity: 0;
612
+ margin-top: 0px;
613
+ margin-bottom: 0.25rem;
614
+ transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short4},
615
+ margin-top ${DesignToken.motion.duration.short4},
616
+ margin-bottom ${DesignToken.motion.duration.short4}`)};
617
+ }
618
+ :host([hide-subscript="auto"]:not(.-invalid):focus-within) .subscript,
619
+ :host([hide-subscript="auto"]:not(.-invalid).-pressed) .subscript {
620
+ opacity: 1;
621
+ margin-top: 0.25rem;
622
+ margin-bottom: 0;
623
+ }
624
+ :host(.-invalid) .hint {
625
+ display: none;
626
+ }
627
+ :host(:not(.-invalid)) .error {
628
+ display: none;
629
+ }
630
+ ::slotted(input),
631
+ ::slotted(textarea),
632
+ ::slotted(select) {
633
+ outline: unset;
634
+ border: unset;
635
+ background-color: transparent;
636
+ box-shadow: none;
637
+ font-family: inherit;
638
+ font-size: inherit;
639
+ line-height: initial;
640
+ letter-spacing: inherit;
641
+ color: var(--_form-field-input-color, inherit);
642
+ flex: 1 1 auto;
643
+ min-width: 0;
644
+ padding: unset;
645
+ }
646
+ ::slotted(textarea) {
647
+ scrollbar-width: ${DesignToken.scrollbar.thinWidth};
648
+ scrollbar-color: ${DesignToken.scrollbar.color};
649
+ }
650
+ ::slotted(m3e-select),
651
+ ::slotted(m3e-input-chip-set) {
652
+ flex: 1 1 auto;
653
+ min-width: 0;
654
+ }
655
+ :host([variant="outlined"]) ::slotted(m3e-input-chip-set) {
656
+ margin-block: calc(calc(3.5rem + ${DesignToken.density.calc(-2)}) / 4);
657
+ }
658
+ ::slotted(:not([slot])::part(focus-ring)) {
659
+ display: none;
660
+ }
661
+ ::slotted(input)::placeholder,
662
+ ::slotted(textarea)::placeholder {
663
+ user-select: none;
664
+ color: currentColor;
665
+ transition: opacity ${DesignToken.motion.duration.extraLong1};
666
+ }
667
+ :host([float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
668
+ font-size: inherit;
669
+ }
670
+ :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(input)::placeholder,
671
+ :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(textarea)::placeholder,
672
+ :host([float-label="auto"]:not(.-float-label).-with-label) .prefix-text,
673
+ :host([float-label="auto"]:not(.-float-label).-with-label) .suffix-text {
674
+ opacity: 0;
675
+ transition: opacity 0s;
676
+ }
677
+ .prefix {
678
+ margin-left: 1rem;
679
+ }
680
+ :host(.-with-prefix) .prefix {
681
+ margin-right: 1rem;
682
+ margin-left: 0.75rem;
683
+ }
684
+ .suffix {
685
+ margin-right: 1rem;
686
+ }
687
+ :host(.-with-suffix) .suffix {
688
+ margin-left: 1rem;
689
+ margin-right: 0.75rem;
690
+ }
691
+ :host(.-with-suffix.-with-select) .suffix {
692
+ margin-left: unset;
693
+ }
694
+ :host(.-with-select) .suffix-text {
695
+ display: none;
696
+ }
697
+ :host([variant="outlined"]) .label {
698
+ margin-top: calc(0px - var(--_form-field-label-line-height) / 2);
699
+ }
700
+ :host([variant="outlined"]) .outline {
701
+ position: absolute;
702
+ display: flex;
703
+ pointer-events: none;
704
+ left: 0;
705
+ top: 0;
706
+ bottom: 0;
707
+ right: 0;
708
+ }
709
+ :host([variant="outlined"]) .pseudo-label {
710
+ visibility: hidden;
711
+ margin-right: 0.25rem;
712
+ font-size: var(--_form-field-label-font-size);
713
+ line-height: var(--_form-field-label-line-height);
714
+ letter-spacing: var(--_form-field-label-tracking);
715
+ max-width: 100%;
716
+ transition-property: max-width, margin-right;
717
+ transition-duration: 1ms;
718
+ }
719
+ :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .pseudo-label {
720
+ max-width: 0;
721
+ margin-right: 0px;
722
+ transition-delay: ${DesignToken.motion.duration.short2};
723
+ }
724
+ :host([variant="outlined"]) .outline-start,
725
+ :host([variant="outlined"]) .outline-notch,
726
+ :host([variant="outlined"]) .outline-end {
727
+ box-sizing: border-box;
728
+ border-width: var(--_form-field-outline-size, 0.0625rem);
729
+ border-color: var(--_form-field-outline-color);
730
+ transition: border-color ${DesignToken.motion.duration.short4};
731
+ }
732
+ :host([variant="outlined"]:not(.-with-label)) .outline-notch {
733
+ display: none;
734
+ }
735
+ :host([variant="outlined"].-with-suffix:not(.-with-select)) .outline-notch {
736
+ margin-right: -0.75rem;
737
+ }
738
+ :host([variant="outlined"]) .outline-start {
739
+ min-width: 0.75rem;
740
+ border-top-style: solid;
741
+ border-left-style: solid;
742
+ border-bottom-style: solid;
743
+ border-radius: var(--m3e-outlined-form-field-container-shape, ${DesignToken.shape.corner.extraSmall}) 0 0
744
+ var(--m3e-outlined-form-field-container-shape, ${DesignToken.shape.corner.extraSmall});
745
+ }
746
+ :host([variant="outlined"]) .outline-notch {
747
+ border-bottom-style: solid;
748
+ }
749
+ :host([variant="outlined"]) .outline-end {
750
+ flex-grow: 1;
751
+ min-width: 1rem;
752
+ border-top-style: solid;
753
+ border-right-style: solid;
754
+ border-bottom-style: solid;
755
+ border-radius: 0 var(--m3e-outlined-form-field-container-shape, ${DesignToken.shape.corner.extraSmall})
756
+ var(--m3e-outlined-form-field-container-shape, ${DesignToken.shape.corner.extraSmall}) 0;
757
+ }
758
+ :host([variant="outlined"].-with-prefix) .outline-start {
759
+ min-width: calc(1.25rem + var(--_prefix-width, 0px) + 0.25rem);
760
+ }
761
+ :host([variant="outlined"]:not(.-disabled)) .base:hover .outline,
762
+ :host([variant="outlined"]:not(.-disabled):focus-within) .outline,
763
+ :host([variant="outlined"]:not(.-disabled).-pressed) .outline {
764
+ --_form-field-outline-size: 0.125rem;
765
+ }
766
+ :host([variant="outlined"]) .subscript {
767
+ margin-inline: 1rem;
768
+ width: calc(100% - 2rem);
769
+ }
770
+ :host([variant="outlined"]) .content {
771
+ min-height: calc(3.5rem + ${DesignToken.density.calc(-2)});
772
+ --_form-field-label-font-size: var(
773
+ --m3e-form-field-label-font-size,
774
+ ${DesignToken.typescale.standard.body.small.fontSize}
775
+ );
776
+ }
777
+ :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
778
+ margin-top: unset;
779
+ line-height: calc(3.5rem + ${DesignToken.density.calc(-2)});
780
+ --_form-field-label-font-size: var(
781
+ --m3e-form-field-label-font-size,
782
+ ${DesignToken.typescale.standard.body.small.fontSize}
783
+ );
784
+ }
785
+ :host([variant="filled"]) .base {
786
+ --_select-arrow-margin-top: calc(
787
+ 0px - calc(1rem / max(calc(0 - calc(var(--m3e-density-scale, 0) + var(--m3e-density-scale, 0))), 1))
788
+ );
789
+ }
790
+ :host([variant="filled"]) .base::before {
791
+ content: "";
792
+ box-sizing: border-box;
793
+ position: absolute;
794
+ pointer-events: none;
795
+ top: 0;
796
+ left: 0;
797
+ right: 0;
798
+ bottom: 0;
799
+ border-bottom-style: solid;
800
+ border-width: 0.0625rem;
801
+ border-radius: var(--m3e-form-field-container-shape, ${DesignToken.shape.corner.extraSmallTop});
802
+ border-color: var(--_form-field-outline-color);
803
+ background-color: var(--_form-field-container-color);
804
+ }
805
+ :host([variant="filled"]:not(.-disabled)) .base:hover::before,
806
+ :host([variant="filled"]:not(.-disabled):focus-within) .base::before,
807
+ :host([variant="filled"]:not(.-disabled).-pressed) .base::before {
808
+ border-width: 0.1875rem;
809
+ }
810
+ :host([variant="filled"]) .base::after {
811
+ content: "";
812
+ box-sizing: border-box;
813
+ position: absolute;
814
+ pointer-events: none;
815
+ top: 0;
816
+ left: 0;
817
+ right: 0;
818
+ bottom: 0;
819
+ background-color: var(--_form-field-hover-container-color);
820
+ transition: background-color ${DesignToken.motion.duration.short4};
821
+ }
822
+ :host([variant="filled"]) .subscript {
823
+ margin-inline: 1rem;
824
+ width: calc(100% - 2rem);
825
+ }
826
+ :host([variant="filled"]) .content {
827
+ padding-top: calc(1.5rem + ${DesignToken.density.calc(-2)});
828
+ margin-bottom: 0.5rem;
829
+ }
830
+ :host([variant="filled"]) .label {
831
+ top: calc(0.5rem + ${DesignToken.density.calc(-2)});
832
+ }
833
+ :host([variant="filled"][float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
834
+ top: 0px;
835
+ line-height: calc(3.5rem + ${DesignToken.density.calc(-2)} - 0.0625rem);
836
+ --_form-field-label-font-size: var(
837
+ --m3e-form-field-label-font-size,
838
+ ${DesignToken.typescale.standard.body.small.fontSize}
839
+ );
840
+ }
841
+ :host(:not(.-disabled):not(:focus-within):not(.-pressed)) .base:hover {
842
+ --_form-field-hover-container-color: color-mix(
843
+ in srgb,
844
+ var(--m3e-form-field-hover-container-color, ${DesignToken.color.onSurface})
845
+ var(--m3e-form-field-hover-container-opacity, 8%),
846
+ transparent
847
+ );
848
+ }
849
+ :host(:not(.-disabled):not(.-invalid)) {
850
+ color: var(--m3e-form-field-color, ${DesignToken.color.onSurface});
851
+ }
852
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid)) .base {
853
+ --_form-field-outline-color: var(--m3e-form-field-outline-color, ${DesignToken.color.outline});
854
+ }
855
+ :host([variant="filled"]:not(.-disabled):not(.-invalid)) .base {
856
+ --_form-field-outline-color: var(--m3e-form-field-outline-color, ${DesignToken.color.onSurfaceVariant});
857
+ }
858
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid):focus-within) .base,
859
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid).-pressed) .base,
860
+ :host([variant="filled"]:not(.-disabled):not(.-invalid):focus-within) .base,
861
+ :host([variant="filled"]:not(.-disabled):not(.-invalid).-pressed) .base {
862
+ --_form-field-outline-color: var(--m3e-form-field-focused-outline-color, ${DesignToken.color.primary});
863
+ --_form-field-label-color: var(--m3e-form-field-focused-color, ${DesignToken.color.primary});
864
+ }
865
+ :host(:not(.-disabled)) .base {
866
+ --_form-field-container-color: var(
867
+ --m3e-form-field-container-color,
868
+ ${DesignToken.color.surfaceContainerHighest}
869
+ );
870
+ }
871
+ :host(:not(.-disabled).-invalid) .base {
872
+ --_form-field-label-color: var(--m3e-form-field-invalid-color, ${DesignToken.color.error});
873
+ --_form-field-outline-color: var(--m3e-form-field-invalid-color, ${DesignToken.color.error});
874
+ }
875
+ :host(:not(.-disabled).-invalid) .subscript {
876
+ color: var(--m3e-form-field-invalid-color, ${DesignToken.color.error});
877
+ }
878
+ :host(.-disabled) {
879
+ color: color-mix(
880
+ in srgb,
881
+ var(--m3e-form-field-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-form-field-disabled-opacity, 38%),
882
+ transparent
883
+ );
884
+ }
885
+ :host(.-disabled) .base {
886
+ --_form-field-container-color: color-mix(
887
+ in srgb,
888
+ var(--m3e-form-field-disabled-container-color, ${DesignToken.color.onSurface})
889
+ var(--m3e-form-field-disabled-container-opacity, 4%),
890
+ transparent
891
+ );
892
+ }
893
+ :host(.-no-animate) *,
894
+ :host(.-no-animate) *::before,
895
+ :host(.-no-animate) *::after {
896
+ transition: none !important;
897
+ }
898
+ @media (forced-colors: active) {
899
+ :host([variant="filled"]) .base::after {
900
+ transition: none;
901
+ }
902
+ :host {
903
+ --_form-field-outline-color: CanvasText;
904
+ }
905
+ :host(.-disabled) {
906
+ --_form-field-input-color: GrayText;
907
+ --_form-field-color: GrayText;
908
+ --_form-field-label-color: GrayText;
909
+ --_form-field-outline-color: GrayText;
910
+ }
911
+ }
912
+ @media (prefers-reduced-motion) {
913
+ .base::before,
914
+ .prefix-text,
915
+ .suffix-text,
916
+ .label,
917
+ .subscript,
918
+ .outline-start,
919
+ .outline-notch,
920
+ .outline-end,
921
+ .pseudo-label,
922
+ ::slotted(input)::placeholder,
923
+ ::slotted(textarea)::placeholder {
924
+ transition: none !important;
925
+ }
926
+ }
927
+ `;
928
+ __decorate([
929
+ e(".base")
930
+ ], M3eFormFieldElement.prototype, "_base", void 0);
931
+ __decorate([
932
+ e(".prefix")
933
+ ], M3eFormFieldElement.prototype, "_prefix", void 0);
934
+ __decorate([
935
+ e(".error")
936
+ ], M3eFormFieldElement.prototype, "_error", void 0);
937
+ __decorate([
938
+ e(".hint")
939
+ ], M3eFormFieldElement.prototype, "_hint", void 0);
940
+ __decorate([
941
+ r()
942
+ ], M3eFormFieldElement.prototype, "_pseudoLabel", void 0);
943
+ __decorate([
944
+ r()
945
+ ], M3eFormFieldElement.prototype, "_required", void 0);
946
+ __decorate([
947
+ r()
948
+ ], M3eFormFieldElement.prototype, "_invalid", void 0);
949
+ __decorate([
950
+ r()
951
+ ], M3eFormFieldElement.prototype, "_validationMessage", void 0);
952
+ __decorate([
953
+ n({ reflect: true })
954
+ ], M3eFormFieldElement.prototype, "variant", void 0);
955
+ __decorate([
956
+ n({ attribute: "hide-required-marker", type: Boolean, reflect: true })
957
+ ], M3eFormFieldElement.prototype, "hideRequiredMarker", void 0);
958
+ __decorate([
959
+ n({ attribute: "hide-subscript", reflect: true })
960
+ ], M3eFormFieldElement.prototype, "hideSubscript", void 0);
961
+ __decorate([
962
+ n({ attribute: "float-label", reflect: true })
963
+ ], M3eFormFieldElement.prototype, "floatLabel", void 0);
964
+ M3eFormFieldElement = __decorate([
965
+ t$1("m3e-form-field")
966
+ ], M3eFormFieldElement);
967
+
968
+ export { M3eFormFieldElement, findFormFieldControl, isFormFieldControl };
969
+ //# sourceMappingURL=index.js.map