@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.
@@ -0,0 +1,504 @@
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 as t,nothing as e,html as i,unsafeCSS as o,css as s}from"lit";import{AttachInternals as r,Role as a,MutationController as n,ResizeController as l,FocusController as d,HoverController as h,PressedController as c,isReadOnlyMixin as f,DesignToken as p,hasAssignedNodes as u,getTextContent as m}from"@m3e/core";import{M3eAriaDescriber as b}from"@m3e/core/a11y";
7
+ /**
8
+ * Adapted from Angular Material Form Field Control
9
+ * Source: https://github.com/angular/components/blob/main/src/material/form-field/form-field-control.ts
10
+ *
11
+ * @license MIT
12
+ * Copyright (c) 2025 Google LLC
13
+ * See LICENSE file in the project root for full license text.
14
+ */const v=["m3e-input-chip-set","m3e-select"];function g(t){return t instanceof HTMLElement&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||v.includes(t.tagName.toLowerCase()))}function y(t){for(const e of t.assignedElements({flatten:!0})){if(g(e))return e;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t.nextNode();)if(g(t.currentNode))return t.currentNode}return null}function w(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function _(t,e,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(t):o?o.value:e.get(t)}function $(t,e,i,o,s){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?s.call(t,i):s?s.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
15
+ /**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */
20
+ const x=globalThis,S=x.ShadowRoot&&(void 0===x.ShadyCSS||x.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,E=Symbol(),k=new WeakMap;
21
+ /**
22
+ * @license
23
+ * Copyright 2019 Google LLC
24
+ * SPDX-License-Identifier: BSD-3-Clause
25
+ */let C=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==E)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(S&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=k.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&k.set(e,t))}return t}toString(){return this.cssText}};const P=(t,e)=>{if(S)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),o=x.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=i.cssText,t.appendChild(e)}},z=S?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new C("string"==typeof t?t:t+"",void 0,E))(e)})(t):t,{is:M,defineProperty:L,getOwnPropertyDescriptor:U,getOwnPropertyNames:O,getOwnPropertySymbols:T,getPrototypeOf:A}=Object,R=globalThis,q=R.trustedTypes,W=q?q.emptyScript:"",j=R.reactiveElementPolyfillSupport,D=(t,e)=>t,H={toAttribute(t,e){switch(e){case Boolean:t=t?W:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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}},N=(t,e)=>!M(t,e),V={attribute:!0,type:String,converter:H,reflect:!1,useDefault:!1,hasChanged:N};
26
+ /**
27
+ * @license
28
+ * Copyright 2017 Google LLC
29
+ * SPDX-License-Identifier: BSD-3-Clause
30
+ */Symbol.metadata??=Symbol("metadata"),R.litPropertyMetadata??=new WeakMap;class I 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,e=V){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(t,i,e);void 0!==o&&L(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){const{get:o,set:s}=U(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);s?.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??V}static _$Ei(){if(this.hasOwnProperty(D("elementProperties")))return;const t=A(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=!0,this._$Ei(),this.hasOwnProperty(D("properties"))){const t=this.properties,e=[...O(t),...T(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(z(t))}else void 0!==t&&e.push(z(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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,e=this.constructor.elementProperties;for(const i of e.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 P(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,i);if(void 0!==o&&!0===i.reflect){const s=(void 0!==i.converter?.toAttribute?i.converter:H).toAttribute(e,i.type);this._$Em=t,null==s?this.removeAttribute(o):this.setAttribute(o,s),this._$Em=null}}_$AK(t,e){const i=this.constructor,o=i._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=i.getPropertyOptions(o),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:H;this._$Em=o;const r=s.fromAttribute(e,t.type);this[o]=r??this._$Ej?.get(o)??r,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const o=this.constructor,s=this[t];if(i??=o.getPropertyOptions(t),!((i.hasChanged??N)(s,e)||i.useDefault&&i.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:o,wrapped:s},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==s||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===o&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,i,o)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[D("elementProperties")]=new Map,I[D("finalized")]=new Map,j?.({ReactiveElement:I}),(R.reactiveElementVersions??=[]).push("2.1.1");
31
+ /**
32
+ * @license
33
+ * Copyright 2017 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ */
36
+ const F={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:N},G=(t=F,e,i)=>{const{kind:o,metadata:s}=i;let r=globalThis.litPropertyMetadata.get(s);if(void 0===r&&globalThis.litPropertyMetadata.set(s,r=new Map),"setter"===o&&((t=Object.create(t)).wrapped=!0),r.set(i.name,t),"accessor"===o){const{name:o}=i;return{set(i){const s=e.get.call(this);e.set.call(this,i),this.requestUpdate(o,s,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===o){const{name:o}=i;return function(i){const s=this[o];e.call(this,i),this.requestUpdate(o,s,t)}}throw Error("Unsupported decorator location: "+o)};function B(t){return(e,i)=>"object"==typeof i?G(t,e,i):((t,e,i)=>{const o=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),o?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}
37
+ /**
38
+ * @license
39
+ * Copyright 2017 Google LLC
40
+ * SPDX-License-Identifier: BSD-3-Clause
41
+ */function J(t){return B({...t,state:!0,attribute:!1})}
42
+ /**
43
+ * @license
44
+ * Copyright 2017 Google LLC
45
+ * SPDX-License-Identifier: BSD-3-Clause
46
+ */
47
+ /**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ * SPDX-License-Identifier: BSD-3-Clause
51
+ */
52
+ function K(t,e){return(e,i,o)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i))(e,i,{get(){return(e=>e.renderRoot?.querySelector(t)??null)(this)}})}
53
+ /**
54
+ * Adapted from Angular Material Form Field
55
+ * Source: https://github.com/angular/components/blob/main/src/material/form-field/form-field.ts
56
+ *
57
+ * @license MIT
58
+ * Copyright (c) 2025 Google LLC
59
+ * See LICENSE file in the project root for full license text.
60
+ */var Q,X,Y,Z,tt,et,it,ot,st,rt,at,nt,lt,dt,ht,ct,ft,pt,ut,mt,bt,vt,gt,yt,wt,_t;let $t=class extends(r(a(t,"none"))){constructor(){super(),Q.add(this),X.set(this,null),Y.set(this,()=>_(this,Q,"m",gt).call(this)),Z.set(this,()=>_(this,Q,"m",bt).call(this)),tt.set(this,new n(this,{target:null,config:{attributeFilter:["disabled","readonly","required"]},callback:()=>this.notifyControlStateChange()})),et.set(this,new l(this,{target:null,callback:()=>_(this,Q,"m",pt).call(this)})),it.set(this,new d(this,{target:null,callback:t=>{t=t&&!(_(this,X,"f")?.disabled??1),this.classList.toggle("-no-animate",!1),$(this,rt,t,"f"),t?this.classList.toggle("-float-label",!0):(this._invalid=!(_(this,X,"f")?.checkValidity?.()??1),this.notifyControlStateChange())}})),ot.set(this,new n(this,{target:null,config:{childList:!0,subtree:!0},callback:()=>_(this,Q,"m",wt).call(this)})),st.set(this,new n(this,{target:null,config:{childList:!0,subtree:!0},callback:()=>_(this,Q,"m",_t).call(this)})),rt.set(this,!1),this._pseudoLabel="",this._required=!1,this._invalid=!1,this._validationMessage="",at.set(this,""),nt.set(this,""),this.variant="outlined",this.hideRequiredMarker=!1,this.hideSubscript="auto",this.floatLabel="auto",new h(this,{callback:()=>this.classList.toggle("-no-animate",!1)}),new c(this,{callback:t=>this.classList.toggle("-pressed",t&&!(_(this,X,"f")?.disabled??1))})}get control(){return _(this,X,"f")}notifyControlStateChange(t=!1){this._required=!0===_(this,X,"f")?.required,this.classList.toggle("-required",this._required),this.classList.toggle("-disabled",!0===_(this,X,"f")?.disabled),this.classList.toggle("-readonly",f(_(this,X,"f"))&&!0===_(this,X,"f").readOnly),"auto"===this.floatLabel&&this.classList.toggle("-float-label",_(this,Q,"a",lt)||_(this,rt,"f")),t&&(this._invalid=!(_(this,X,"f")?.checkValidity?.()??1)),this.classList.toggle("-invalid",this._invalid),this._validationMessage=_(this,X,"f")?.validationMessage??"",this.isUpdatePending||this.performUpdate()}connectedCallback(){super.connectedCallback(),this.classList.toggle("-no-animate",!0)}disconnectedCallback(){super.disconnectedCallback(),_(this,Q,"m",yt).call(this,null)}firstUpdated(t){super.firstUpdated(t),_(this,it,"f").observe(this._base),_(this,ot,"f").observe(this._hint),_(this,Q,"m",wt).call(this),_(this,st,"f").observe(this._error),_(this,Q,"m",_t).call(this)}update(t){super.update(t),t.has("_invalid")&&_(this,X,"f")&&(_(this,X,"f").ariaInvalid=this._invalid?"true":null,_(this,nt,"f")&&(this._invalid?b.describe(_(this,X,"f"),_(this,nt,"f")):b.removeDescription(_(this,X,"f"),_(this,nt,"f"))))}render(){return i`<div class="base" @click="${_(this,Q,"m",mt)}">
61
+ ${"outlined"===this.variant?i`<div class="outline" aria-hidden="true">
62
+ <div class="outline-start"></div>
63
+ <div class="outline-notch">
64
+ <div class="pseudo-label">
65
+ ${this._pseudoLabel} ${!this.hideRequiredMarker&&this._required?i`&nbsp;*`:e}
66
+ </div>
67
+ </div>
68
+ <div class="outline-end"></div>
69
+ </div>`:e}
70
+ <div class="prefix">
71
+ <slot name="prefix" @slotchange="${_(this,Q,"m",ct)}"></slot>
72
+ </div>
73
+ <div class="content">
74
+ <span class="prefix-text"><slot name="prefix-text"></slot></span>
75
+ <span class="input">
76
+ <slot @slotchange="${_(this,Q,"m",ut)}" @change="${_(this,Q,"m",vt)}"></slot>
77
+ </span>
78
+ <span class="suffix-text"><slot name="suffix-text"></slot></span>
79
+ <span class="label">
80
+ <slot name="label" @slotchange="${_(this,Q,"m",ht)}"></slot>
81
+ ${!this.hideRequiredMarker&&this._required?i`<span class="required-marker" aria-hidden="true">&nbsp;*</span>`:e}
82
+ </span>
83
+ </div>
84
+ <div class="suffix" @click="${_(this,Q,"m",dt)}">
85
+ <slot name="suffix" @slotchange="${_(this,Q,"m",ft)}"></slot>
86
+ </div>
87
+ </div>
88
+ <span class="subscript" aria-hidden="true">
89
+ <span class="error"><slot name="error">${this._validationMessage}</slot></span>
90
+ <span class="hint"><slot name="hint"></slot></span>
91
+ </span>`}};X=new WeakMap,Y=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,it=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,nt=new WeakMap,Q=new WeakSet,lt=function(){return void 0!==_(this,X,"f")?.shouldLabelFloat?!0===_(this,X,"f").shouldLabelFloat:"string"==typeof _(this,X,"f")?.value&&_(this,X,"f").value.length>0},dt=function(t){t.stopImmediatePropagation(),t.stopPropagation()},ht=function(t){const e=t.target.assignedElements({flatten:!0});this.classList.toggle("-with-label",e.length>0),this._pseudoLabel=e[0]?.textContent??""},ct=function(t){this.classList.toggle("-with-prefix",u(t.target)),_(this,et,"f").observe(this._prefix)},ft=function(t){this.classList.toggle("-with-suffix",u(t.target))},pt=function(){"outlined"===this.variant&&this._base.style.setProperty("--_prefix-width",`${this._prefix.clientWidth}px`)},ut=function(t){_(this,Q,"m",yt).call(this,y(t.target))},mt=function(t){!_(this,X,"f")||_(this,rt,"f")||_(this,X,"f").disabled||(_(this,X,"f").onContainerClick?_(this,X,"f").onContainerClick(t):_(this,X,"f").focus())},bt=function(){this._invalid=!0,this.notifyControlStateChange()},vt=function(){this._invalid=!(_(this,X,"f")?.checkValidity?.()??1),this.notifyControlStateChange()},gt=function(){this._invalid=!1,this.notifyControlStateChange()},yt=function(t){_(this,X,"f")!==t&&(_(this,X,"f")&&(_(this,at,"f")&&b.removeDescription(_(this,X,"f"),_(this,at,"f")),_(this,nt,"f")&&b.removeDescription(_(this,X,"f"),_(this,nt,"f")),_(this,tt,"f").unobserve(_(this,X,"f")),_(this,X,"f").removeEventListener("invalid",_(this,Z,"f")),_(this,X,"f").form?.removeEventListener("reset",_(this,Y,"f"))),$(this,X,t,"f"),_(this,X,"f")&&(_(this,tt,"f").observe(_(this,X,"f")),_(this,X,"f").addEventListener("invalid",_(this,Z,"f")),_(this,X,"f").form?.addEventListener("reset",_(this,Y,"f")),_(this,X,"f").removeAttribute("aria-invalid"),_(this,at,"f")&&b.describe(_(this,X,"f"),_(this,at,"f")),this.notifyControlStateChange()))},wt=function(){const t=m(this._hint,!0);t!==_(this,at,"f")&&(_(this,X,"f")&&_(this,at,"f")&&b.removeDescription(_(this,X,"f"),_(this,at,"f")),$(this,at,t,"f"),_(this,X,"f")&&_(this,at,"f")&&b.describe(_(this,X,"f"),_(this,at,"f")))},_t=function(){const t=m(this._error,!0);t!==_(this,nt,"f")&&(_(this,X,"f")&&_(this,nt,"f")&&b.removeDescription(_(this,X,"f"),_(this,nt,"f")),$(this,nt,t,"f"),_(this,X,"f")&&_(this,nt,"f")&&this._invalid&&b.describe(_(this,X,"f"),_(this,nt,"f")))},$t.styles=s`
92
+ :host {
93
+ display: inline-flex;
94
+ flex-direction: column;
95
+ vertical-align: middle;
96
+ font-size: var(--m3e-form-field-font-size, ${p.typescale.standard.body.large.fontSize});
97
+ font-weight: var(--m3e-form-field-font-weight, ${p.typescale.standard.body.large.fontWeight});
98
+ line-height: var(--m3e-form-field-line-height, ${p.typescale.standard.body.large.lineHeight});
99
+ letter-spacing: var(--m3e-form-field-tracking, ${p.typescale.standard.body.large.tracking});
100
+ width: var(--m3e-form-field-width, 14.5rem);
101
+ color: var(--_form-field-color);
102
+ }
103
+ .base {
104
+ display: flex;
105
+ align-items: center;
106
+ position: relative;
107
+ min-height: calc(3.5rem + ${p.density.calc(-2)});
108
+ --_form-field-label-font-size: var(
109
+ --m3e-form-field-label-font-size,
110
+ ${p.typescale.standard.body.small.fontSize}
111
+ );
112
+ --_form-field-label-line-height: var(
113
+ --m3e-form-field-label-line-height,
114
+ ${p.typescale.standard.body.small.lineHeight}
115
+ );
116
+ }
117
+ .content {
118
+ display: flex;
119
+ align-items: center;
120
+ position: relative;
121
+ flex: 1 1 auto;
122
+ min-width: 0;
123
+ min-height: var(--m3e-form-field-icon-size, 1.5rem);
124
+ }
125
+ .prefix,
126
+ .suffix {
127
+ display: flex;
128
+ align-items: center;
129
+ position: relative;
130
+ user-select: none;
131
+ flex: none;
132
+ font-size: var(--m3e-form-field-icon-size, 1.5rem);
133
+ }
134
+ .prefix-text,
135
+ .suffix-text {
136
+ opacity: 1;
137
+ transition: opacity ${p.motion.duration.extraLong1};
138
+ user-select: none;
139
+ flex: none;
140
+ }
141
+ .input {
142
+ display: inline-flex;
143
+ flex-wrap: wrap;
144
+ flex: 1 1 auto;
145
+ min-width: 0;
146
+ }
147
+ .label {
148
+ display: flex;
149
+ position: absolute;
150
+ pointer-events: none;
151
+ user-select: none;
152
+ top: 0;
153
+ left: 0;
154
+ right: 0;
155
+ font-size: var(--m3e-form-field-label-font-size, ${p.typescale.standard.body.small.fontSize});
156
+ font-weight: var(--m3e-form-field-label-font-weight, ${p.typescale.standard.body.small.fontWeight});
157
+ line-height: var(--m3e-form-field-label-line-height, ${p.typescale.standard.body.small.lineHeight});
158
+ letter-spacing: var(--m3e-form-field-label-tracking, ${p.typescale.standard.body.small.tracking});
159
+ color: var(--_form-field-label-color, inherit);
160
+ transition: ${o(`top ${p.motion.duration.short4}, \n font-size ${p.motion.duration.short4}, \n line-height ${p.motion.duration.short4}`)};
161
+ }
162
+ :host(.-with-select) .label {
163
+ margin-right: 1.5rem;
164
+ }
165
+ ::slotted([slot="label"]) {
166
+ white-space: nowrap;
167
+ overflow: hidden;
168
+ text-overflow: ellipsis;
169
+ }
170
+ .subscript {
171
+ display: inline-flex;
172
+ width: 100%;
173
+ margin-top: 0.25rem;
174
+ font-size: var(--m3e-form-field-subscript-font-size, ${p.typescale.standard.body.small.fontSize});
175
+ font-weight: var(--m3e-form-field-subscript-font-weight, ${p.typescale.standard.body.small.fontWeight});
176
+ line-height: var(--m3e-form-field-subscript-line-height, ${p.typescale.standard.body.small.lineHeight});
177
+ letter-spacing: var(--m3e-form-field-subscript-tracking, ${p.typescale.standard.body.small.tracking});
178
+ min-height: var(--m3e-form-field-subscript-line-height, ${p.typescale.standard.body.small.lineHeight});
179
+ color: var(--m3e-form-field-subscript-color, ${p.color.onSurfaceVariant});
180
+ }
181
+ .error,
182
+ .hint {
183
+ flex: 1 1 auto;
184
+ }
185
+ :host([hide-subscript="always"]) .subscript {
186
+ display: none;
187
+ }
188
+ :host([hide-subscript="auto"]:not(.-invalid)) .subscript {
189
+ opacity: 0;
190
+ margin-top: 0px;
191
+ margin-bottom: 0.25rem;
192
+ transition: ${o(`opacity ${p.motion.duration.short4}, \n margin-top ${p.motion.duration.short4}, \n margin-bottom ${p.motion.duration.short4}`)};
193
+ }
194
+ :host([hide-subscript="auto"]:not(.-invalid):focus-within) .subscript,
195
+ :host([hide-subscript="auto"]:not(.-invalid).-pressed) .subscript {
196
+ opacity: 1;
197
+ margin-top: 0.25rem;
198
+ margin-bottom: 0;
199
+ }
200
+ :host(.-invalid) .hint {
201
+ display: none;
202
+ }
203
+ :host(:not(.-invalid)) .error {
204
+ display: none;
205
+ }
206
+ ::slotted(input),
207
+ ::slotted(textarea),
208
+ ::slotted(select) {
209
+ outline: unset;
210
+ border: unset;
211
+ background-color: transparent;
212
+ box-shadow: none;
213
+ font-family: inherit;
214
+ font-size: inherit;
215
+ line-height: initial;
216
+ letter-spacing: inherit;
217
+ color: var(--_form-field-input-color, inherit);
218
+ flex: 1 1 auto;
219
+ min-width: 0;
220
+ padding: unset;
221
+ }
222
+ ::slotted(textarea) {
223
+ scrollbar-width: ${p.scrollbar.thinWidth};
224
+ scrollbar-color: ${p.scrollbar.color};
225
+ }
226
+ ::slotted(m3e-select),
227
+ ::slotted(m3e-input-chip-set) {
228
+ flex: 1 1 auto;
229
+ min-width: 0;
230
+ }
231
+ :host([variant="outlined"]) ::slotted(m3e-input-chip-set) {
232
+ margin-block: calc(calc(3.5rem + ${p.density.calc(-2)}) / 4);
233
+ }
234
+ ::slotted(:not([slot])::part(focus-ring)) {
235
+ display: none;
236
+ }
237
+ ::slotted(input)::placeholder,
238
+ ::slotted(textarea)::placeholder {
239
+ user-select: none;
240
+ color: currentColor;
241
+ transition: opacity ${p.motion.duration.extraLong1};
242
+ }
243
+ :host([float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
244
+ font-size: inherit;
245
+ }
246
+ :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(input)::placeholder,
247
+ :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(textarea)::placeholder,
248
+ :host([float-label="auto"]:not(.-float-label).-with-label) .prefix-text,
249
+ :host([float-label="auto"]:not(.-float-label).-with-label) .suffix-text {
250
+ opacity: 0;
251
+ transition: opacity 0s;
252
+ }
253
+ .prefix {
254
+ margin-left: 1rem;
255
+ }
256
+ :host(.-with-prefix) .prefix {
257
+ margin-right: 1rem;
258
+ margin-left: 0.75rem;
259
+ }
260
+ .suffix {
261
+ margin-right: 1rem;
262
+ }
263
+ :host(.-with-suffix) .suffix {
264
+ margin-left: 1rem;
265
+ margin-right: 0.75rem;
266
+ }
267
+ :host(.-with-suffix.-with-select) .suffix {
268
+ margin-left: unset;
269
+ }
270
+ :host(.-with-select) .suffix-text {
271
+ display: none;
272
+ }
273
+ :host([variant="outlined"]) .label {
274
+ margin-top: calc(0px - var(--_form-field-label-line-height) / 2);
275
+ }
276
+ :host([variant="outlined"]) .outline {
277
+ position: absolute;
278
+ display: flex;
279
+ pointer-events: none;
280
+ left: 0;
281
+ top: 0;
282
+ bottom: 0;
283
+ right: 0;
284
+ }
285
+ :host([variant="outlined"]) .pseudo-label {
286
+ visibility: hidden;
287
+ margin-right: 0.25rem;
288
+ font-size: var(--_form-field-label-font-size);
289
+ line-height: var(--_form-field-label-line-height);
290
+ letter-spacing: var(--_form-field-label-tracking);
291
+ max-width: 100%;
292
+ transition-property: max-width, margin-right;
293
+ transition-duration: 1ms;
294
+ }
295
+ :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .pseudo-label {
296
+ max-width: 0;
297
+ margin-right: 0px;
298
+ transition-delay: ${p.motion.duration.short2};
299
+ }
300
+ :host([variant="outlined"]) .outline-start,
301
+ :host([variant="outlined"]) .outline-notch,
302
+ :host([variant="outlined"]) .outline-end {
303
+ box-sizing: border-box;
304
+ border-width: var(--_form-field-outline-size, 0.0625rem);
305
+ border-color: var(--_form-field-outline-color);
306
+ transition: border-color ${p.motion.duration.short4};
307
+ }
308
+ :host([variant="outlined"]:not(.-with-label)) .outline-notch {
309
+ display: none;
310
+ }
311
+ :host([variant="outlined"].-with-suffix:not(.-with-select)) .outline-notch {
312
+ margin-right: -0.75rem;
313
+ }
314
+ :host([variant="outlined"]) .outline-start {
315
+ min-width: 0.75rem;
316
+ border-top-style: solid;
317
+ border-left-style: solid;
318
+ border-bottom-style: solid;
319
+ border-radius: var(--m3e-outlined-form-field-container-shape, ${p.shape.corner.extraSmall}) 0 0
320
+ var(--m3e-outlined-form-field-container-shape, ${p.shape.corner.extraSmall});
321
+ }
322
+ :host([variant="outlined"]) .outline-notch {
323
+ border-bottom-style: solid;
324
+ }
325
+ :host([variant="outlined"]) .outline-end {
326
+ flex-grow: 1;
327
+ min-width: 1rem;
328
+ border-top-style: solid;
329
+ border-right-style: solid;
330
+ border-bottom-style: solid;
331
+ border-radius: 0 var(--m3e-outlined-form-field-container-shape, ${p.shape.corner.extraSmall})
332
+ var(--m3e-outlined-form-field-container-shape, ${p.shape.corner.extraSmall}) 0;
333
+ }
334
+ :host([variant="outlined"].-with-prefix) .outline-start {
335
+ min-width: calc(1.25rem + var(--_prefix-width, 0px) + 0.25rem);
336
+ }
337
+ :host([variant="outlined"]:not(.-disabled)) .base:hover .outline,
338
+ :host([variant="outlined"]:not(.-disabled):focus-within) .outline,
339
+ :host([variant="outlined"]:not(.-disabled).-pressed) .outline {
340
+ --_form-field-outline-size: 0.125rem;
341
+ }
342
+ :host([variant="outlined"]) .subscript {
343
+ margin-inline: 1rem;
344
+ width: calc(100% - 2rem);
345
+ }
346
+ :host([variant="outlined"]) .content {
347
+ min-height: calc(3.5rem + ${p.density.calc(-2)});
348
+ --_form-field-label-font-size: var(
349
+ --m3e-form-field-label-font-size,
350
+ ${p.typescale.standard.body.small.fontSize}
351
+ );
352
+ }
353
+ :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
354
+ margin-top: unset;
355
+ line-height: calc(3.5rem + ${p.density.calc(-2)});
356
+ --_form-field-label-font-size: var(
357
+ --m3e-form-field-label-font-size,
358
+ ${p.typescale.standard.body.small.fontSize}
359
+ );
360
+ }
361
+ :host([variant="filled"]) .base {
362
+ --_select-arrow-margin-top: calc(
363
+ 0px - calc(1rem / max(calc(0 - calc(var(--m3e-density-scale, 0) + var(--m3e-density-scale, 0))), 1))
364
+ );
365
+ }
366
+ :host([variant="filled"]) .base::before {
367
+ content: "";
368
+ box-sizing: border-box;
369
+ position: absolute;
370
+ pointer-events: none;
371
+ top: 0;
372
+ left: 0;
373
+ right: 0;
374
+ bottom: 0;
375
+ border-bottom-style: solid;
376
+ border-width: 0.0625rem;
377
+ border-radius: var(--m3e-form-field-container-shape, ${p.shape.corner.extraSmallTop});
378
+ border-color: var(--_form-field-outline-color);
379
+ background-color: var(--_form-field-container-color);
380
+ }
381
+ :host([variant="filled"]:not(.-disabled)) .base:hover::before,
382
+ :host([variant="filled"]:not(.-disabled):focus-within) .base::before,
383
+ :host([variant="filled"]:not(.-disabled).-pressed) .base::before {
384
+ border-width: 0.1875rem;
385
+ }
386
+ :host([variant="filled"]) .base::after {
387
+ content: "";
388
+ box-sizing: border-box;
389
+ position: absolute;
390
+ pointer-events: none;
391
+ top: 0;
392
+ left: 0;
393
+ right: 0;
394
+ bottom: 0;
395
+ background-color: var(--_form-field-hover-container-color);
396
+ transition: background-color ${p.motion.duration.short4};
397
+ }
398
+ :host([variant="filled"]) .subscript {
399
+ margin-inline: 1rem;
400
+ width: calc(100% - 2rem);
401
+ }
402
+ :host([variant="filled"]) .content {
403
+ padding-top: calc(1.5rem + ${p.density.calc(-2)});
404
+ margin-bottom: 0.5rem;
405
+ }
406
+ :host([variant="filled"]) .label {
407
+ top: calc(0.5rem + ${p.density.calc(-2)});
408
+ }
409
+ :host([variant="filled"][float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
410
+ top: 0px;
411
+ line-height: calc(3.5rem + ${p.density.calc(-2)} - 0.0625rem);
412
+ --_form-field-label-font-size: var(
413
+ --m3e-form-field-label-font-size,
414
+ ${p.typescale.standard.body.small.fontSize}
415
+ );
416
+ }
417
+ :host(:not(.-disabled):not(:focus-within):not(.-pressed)) .base:hover {
418
+ --_form-field-hover-container-color: color-mix(
419
+ in srgb,
420
+ var(--m3e-form-field-hover-container-color, ${p.color.onSurface})
421
+ var(--m3e-form-field-hover-container-opacity, 8%),
422
+ transparent
423
+ );
424
+ }
425
+ :host(:not(.-disabled):not(.-invalid)) {
426
+ color: var(--m3e-form-field-color, ${p.color.onSurface});
427
+ }
428
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid)) .base {
429
+ --_form-field-outline-color: var(--m3e-form-field-outline-color, ${p.color.outline});
430
+ }
431
+ :host([variant="filled"]:not(.-disabled):not(.-invalid)) .base {
432
+ --_form-field-outline-color: var(--m3e-form-field-outline-color, ${p.color.onSurfaceVariant});
433
+ }
434
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid):focus-within) .base,
435
+ :host([variant="outlined"]:not(.-disabled):not(.-invalid).-pressed) .base,
436
+ :host([variant="filled"]:not(.-disabled):not(.-invalid):focus-within) .base,
437
+ :host([variant="filled"]:not(.-disabled):not(.-invalid).-pressed) .base {
438
+ --_form-field-outline-color: var(--m3e-form-field-focused-outline-color, ${p.color.primary});
439
+ --_form-field-label-color: var(--m3e-form-field-focused-color, ${p.color.primary});
440
+ }
441
+ :host(:not(.-disabled)) .base {
442
+ --_form-field-container-color: var(
443
+ --m3e-form-field-container-color,
444
+ ${p.color.surfaceContainerHighest}
445
+ );
446
+ }
447
+ :host(:not(.-disabled).-invalid) .base {
448
+ --_form-field-label-color: var(--m3e-form-field-invalid-color, ${p.color.error});
449
+ --_form-field-outline-color: var(--m3e-form-field-invalid-color, ${p.color.error});
450
+ }
451
+ :host(:not(.-disabled).-invalid) .subscript {
452
+ color: var(--m3e-form-field-invalid-color, ${p.color.error});
453
+ }
454
+ :host(.-disabled) {
455
+ color: color-mix(
456
+ in srgb,
457
+ var(--m3e-form-field-disabled-color, ${p.color.onSurface}) var(--m3e-form-field-disabled-opacity, 38%),
458
+ transparent
459
+ );
460
+ }
461
+ :host(.-disabled) .base {
462
+ --_form-field-container-color: color-mix(
463
+ in srgb,
464
+ var(--m3e-form-field-disabled-container-color, ${p.color.onSurface})
465
+ var(--m3e-form-field-disabled-container-opacity, 4%),
466
+ transparent
467
+ );
468
+ }
469
+ :host(.-no-animate) *,
470
+ :host(.-no-animate) *::before,
471
+ :host(.-no-animate) *::after {
472
+ transition: none !important;
473
+ }
474
+ @media (forced-colors: active) {
475
+ :host([variant="filled"]) .base::after {
476
+ transition: none;
477
+ }
478
+ :host {
479
+ --_form-field-outline-color: CanvasText;
480
+ }
481
+ :host(.-disabled) {
482
+ --_form-field-input-color: GrayText;
483
+ --_form-field-color: GrayText;
484
+ --_form-field-label-color: GrayText;
485
+ --_form-field-outline-color: GrayText;
486
+ }
487
+ }
488
+ @media (prefers-reduced-motion) {
489
+ .base::before,
490
+ .prefix-text,
491
+ .suffix-text,
492
+ .label,
493
+ .subscript,
494
+ .outline-start,
495
+ .outline-notch,
496
+ .outline-end,
497
+ .pseudo-label,
498
+ ::slotted(input)::placeholder,
499
+ ::slotted(textarea)::placeholder {
500
+ transition: none !important;
501
+ }
502
+ }
503
+ `,w([K(".base")],$t.prototype,"_base",void 0),w([K(".prefix")],$t.prototype,"_prefix",void 0),w([K(".error")],$t.prototype,"_error",void 0),w([K(".hint")],$t.prototype,"_hint",void 0),w([J()],$t.prototype,"_pseudoLabel",void 0),w([J()],$t.prototype,"_required",void 0),w([J()],$t.prototype,"_invalid",void 0),w([J()],$t.prototype,"_validationMessage",void 0),w([B({reflect:!0})],$t.prototype,"variant",void 0),w([B({attribute:"hide-required-marker",type:Boolean,reflect:!0})],$t.prototype,"hideRequiredMarker",void 0),w([B({attribute:"hide-subscript",reflect:!0})],$t.prototype,"hideSubscript",void 0),w([B({attribute:"float-label",reflect:!0})],$t.prototype,"floatLabel",void 0),$t=w([(t=>(e,i)=>{void 0!==i?i.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})("m3e-form-field")],$t);export{$t as M3eFormFieldElement,y as findFormFieldControl,g as isFormFieldControl};
504
+ //# sourceMappingURL=index.min.js.map