@m3e/select 1.0.6

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,610 @@
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, html, css } from 'lit';
7
+ import { Focusable, Labelled, RequiredConstraintValidation, Dirty, Touched, Required, ConstraintValidation, FormAssociated, Disabled, AttachInternals, Role, ResizeController, formValue, DesignToken, scrollIntoViewIfNeeded, prefersReducedMotion, forcedColorsActive } from '@m3e/core';
8
+ import { ListKeyManager } from '@m3e/core/a11y';
9
+
10
+ /******************************************************************************
11
+ Copyright (c) Microsoft Corporation.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
+ PERFORMANCE OF THIS SOFTWARE.
23
+ ***************************************************************************** */
24
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
+
26
+
27
+ function __decorate(decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ 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;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ }
33
+
34
+ function __classPrivateFieldGet(receiver, state, kind, f) {
35
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
+ 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");
37
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
+ }
39
+
40
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
41
+ if (kind === "m") throw new TypeError("Private method is not writable");
42
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
43
+ 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");
44
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
45
+ }
46
+
47
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48
+ var e = new Error(message);
49
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
50
+ };
51
+
52
+ /**
53
+ * @license
54
+ * Copyright 2017 Google LLC
55
+ * SPDX-License-Identifier: BSD-3-Clause
56
+ */
57
+ const t$3=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
58
+
59
+ /**
60
+ * @license
61
+ * Copyright 2019 Google LLC
62
+ * SPDX-License-Identifier: BSD-3-Clause
63
+ */
64
+ const t$2=globalThis,e$6=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$4=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$1)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$6&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),S$1=(s,o)=>{if(e$6)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$6?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
65
+
66
+ /**
67
+ * @license
68
+ * Copyright 2017 Google LLC
69
+ * SPDX-License-Identifier: BSD-3-Clause
70
+ */const{is:i$2,defineProperty:e$5,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$2,getOwnPropertySymbols:o$3,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1: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$1=(t,s)=>!i$2(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.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$5(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(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$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$2(t),...o$3(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$2(s));}else void 0!==s&&i.push(c$2(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$1(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$1).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$1;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$1)(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$1("elementProperties")]=new Map,y[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
71
+
72
+ /**
73
+ * @license
74
+ * Copyright 2017 Google LLC
75
+ * SPDX-License-Identifier: BSD-3-Clause
76
+ */const o$2={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$1=(t=o$2,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$1(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)}
77
+
78
+ /**
79
+ * @license
80
+ * Copyright 2017 Google LLC
81
+ * SPDX-License-Identifier: BSD-3-Clause
82
+ */
83
+ const e$4=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
84
+
85
+ /**
86
+ * @license
87
+ * Copyright 2017 Google LLC
88
+ * SPDX-License-Identifier: BSD-3-Clause
89
+ */function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$4(n,s,{get(){return o(this)}})}}
90
+
91
+ /**
92
+ * @license
93
+ * Copyright 2017 Google LLC
94
+ * SPDX-License-Identifier: BSD-3-Clause
95
+ */
96
+ const t$1=globalThis,i$1=t$1.trustedTypes,s=i$1?i$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$2="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$1="?"+h,n=`<${o$1}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e$2+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$2)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$1?i$1.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.3.1");
97
+
98
+ /**
99
+ * @license
100
+ * Copyright 2017 Google LLC
101
+ * SPDX-License-Identifier: BSD-3-Clause
102
+ */
103
+ const t={CHILD:2},e$1=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
104
+
105
+ /**
106
+ * @license
107
+ * Copyright 2017 Google LLC
108
+ * SPDX-License-Identifier: BSD-3-Clause
109
+ */class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$1(e);
110
+
111
+ var _M3eSelectElement_instances, _M3eSelectElement_menu, _M3eSelectElement_ignoreKeyUp, _M3eSelectElement_ignoreFocusVisible, _M3eSelectElement_id, _M3eSelectElement_listId, _M3eSelectElement_clickHandler, _M3eSelectElement_keyDownHandler, _M3eSelectElement_keyUpHandler, _M3eSelectElement_menuToggleHandler, _M3eSelectElement_menuPointerDownHandler, _M3eSelectElement_minMenuWidth_get, _M3eSelectElement_formField_get, _M3eSelectElement_handleSlotChange, _M3eSelectElement_handleClick, _M3eSelectElement_handleKeyDown, _M3eSelectElement_handleKeyUp, _M3eSelectElement_handleMenuPointerDown, _M3eSelectElement_handleMenuToggle, _M3eSelectElement_destroyMenu, _M3eSelectElement_toggleMenu, _M3eSelectElement_showMenu, _M3eSelectElement_hideMenu, _M3eSelectElement_activateOption, _M3eSelectElement_selectOption;
112
+ var M3eSelectElement_1;
113
+ /**
114
+ * A form control that allows users to select a value from a set of predefined options.
115
+ *
116
+ * @description
117
+ * The `m3e-select` component follows Material Design 3 principles and provides a comprehensive
118
+ * selection interface for capturing user input. It supports both single and multiple selection modes,
119
+ * customizable validation states, and accessible keyboard navigation. The component integrates seamlessly
120
+ * with form field containers and dynamically positions its option list menu to ensure optimal viewport
121
+ * visibility. Selection changes are communicated through standard form events, enabling predictable integration
122
+ * with form submission and reactive state management systems.
123
+ *
124
+ * @example
125
+ * The following demonstrates a `m3e-select` component wrapped in a `m3e-form-field` with a slotted label.
126
+ * The label is associated with the select via the `for` and `id` attributes, ensuring accessible form semantics.
127
+ * Each `m3e-option` defines an option within the dropdown.
128
+ *
129
+ * ```html
130
+ * <m3e-form-field>
131
+ * <label slot="label" for="select">Choose your favorite fruit</label>
132
+ * <m3e-select id="select">
133
+ * <m3e-option>Apples</m3e-option>
134
+ * <m3e-option>Oranges</m3e-option>
135
+ * <m3e-option>Bananas</m3e-option>
136
+ * <m3e-option>Grapes</m3e-option>
137
+ * </m3e-select>
138
+ * </m3e-form-field>
139
+ * ```
140
+ *
141
+ * @tag m3e-select
142
+ *
143
+ * @slot - Renders the options of the select.
144
+ * @slot arrow - Renders the dropdown arrow.
145
+ * @slot value - Renders the selected value(s).
146
+ *
147
+ * @attr disabled - Whether the element is disabled.
148
+ * @attr hide-selection-indicator - Whether to hide the selection indicator for single select options.
149
+ * @attr multi - Whether multiple options can be selected.
150
+ * @attr name - The name that identifies the element when submitting the associated form.
151
+ * @attr required - Whether the element is required.
152
+ *
153
+ * @fires input - Emitted when the selected state changes.
154
+ * @fires change - Emitted when the selected state changes.
155
+ *
156
+ * @cssprop --m3e-form-field-font-size - The font size of the select control.
157
+ * @cssprop --m3e-form-field-font-weight - The font weight of the select control.
158
+ * @cssprop --m3e-form-field-line-height - The line height of the select control.
159
+ * @cssprop --m3e-form-field-tracking - The letter spacing of the select control.
160
+ * @cssprop --m3e-select-container-shape - The corner radius of the select container.
161
+ * @cssprop --m3e-select-disabled-color - The text color when the select is disabled.
162
+ * @cssprop --m3e-select-disabled-color-opacity - The opacity level applied to the disabled text color.
163
+ * @cssprop --m3e-select-icon-size - The size of the dropdown arrow icon.
164
+ */
165
+ let M3eSelectElement = M3eSelectElement_1 = class M3eSelectElement extends Focusable(Labelled(RequiredConstraintValidation(Dirty(Touched(Required(ConstraintValidation(FormAssociated(Disabled(AttachInternals(Role(LitElement, "combobox"))))))))))) {
166
+ constructor() {
167
+ super();
168
+ _M3eSelectElement_instances.add(this);
169
+ /** @private */ _M3eSelectElement_menu.set(this, void 0);
170
+ /** @private */ _M3eSelectElement_ignoreKeyUp.set(this, false);
171
+ /** @private */ _M3eSelectElement_ignoreFocusVisible.set(this, false);
172
+ /** @private */ _M3eSelectElement_id.set(this, `m3e-select-${M3eSelectElement_1.__nextId++}`);
173
+ /** @private */ _M3eSelectElement_listId.set(this, `${__classPrivateFieldGet(this, _M3eSelectElement_id, "f")}-list`);
174
+ /** @private */ _M3eSelectElement_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleClick).call(this, e));
175
+ /** @private */ _M3eSelectElement_keyDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleKeyDown).call(this, e));
176
+ /** @private */ _M3eSelectElement_keyUpHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleKeyUp).call(this, e));
177
+ /** @private */ _M3eSelectElement_menuToggleHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleMenuToggle).call(this, e));
178
+ /** @private */ _M3eSelectElement_menuPointerDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleMenuPointerDown).call(this, e));
179
+ /** @private */ this._listKeyManager = new ListKeyManager()
180
+ .withWrap()
181
+ .withHomeAndEnd()
182
+ .withPageUpAndDown()
183
+ .withVerticalOrientation()
184
+ .withTypeahead()
185
+ .onActiveItemChange(() => {
186
+ if (this._listKeyManager.activeItem) {
187
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_activateOption).call(this, this._listKeyManager.activeItem);
188
+ }
189
+ });
190
+ /**
191
+ * Whether to hide the selection indicator for single select options.
192
+ * @default false
193
+ */
194
+ this.hideSelectionIndicator = false;
195
+ /**
196
+ * Whether multiple options can be selected.
197
+ * @default false
198
+ */
199
+ this.multi = false;
200
+ new ResizeController(this, {
201
+ callback: () => {
202
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f")) {
203
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").style.minWidth = __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_minMenuWidth_get);
204
+ }
205
+ },
206
+ });
207
+ }
208
+ /** The selected option(s). */
209
+ get selected() {
210
+ return this.options.filter((x) => x.selected);
211
+ }
212
+ /** The options that can be selected. */
213
+ get options() {
214
+ return this._listKeyManager?.items ?? [];
215
+ }
216
+ /** The selected value(s). */
217
+ get value() {
218
+ const values = this.selected.map((x) => x.value);
219
+ switch (values.length) {
220
+ case 0:
221
+ return null;
222
+ case 1:
223
+ return values[0];
224
+ default:
225
+ return values;
226
+ }
227
+ }
228
+ /** @inheritdoc @internal */
229
+ get [(_M3eSelectElement_menu = new WeakMap(), _M3eSelectElement_ignoreKeyUp = new WeakMap(), _M3eSelectElement_ignoreFocusVisible = new WeakMap(), _M3eSelectElement_id = new WeakMap(), _M3eSelectElement_listId = new WeakMap(), _M3eSelectElement_clickHandler = new WeakMap(), _M3eSelectElement_keyDownHandler = new WeakMap(), _M3eSelectElement_keyUpHandler = new WeakMap(), _M3eSelectElement_menuToggleHandler = new WeakMap(), _M3eSelectElement_menuPointerDownHandler = new WeakMap(), _M3eSelectElement_instances = new WeakSet(), formValue)]() {
230
+ const values = this.value;
231
+ if (Array.isArray(values)) {
232
+ const data = new FormData();
233
+ for (const value of values) {
234
+ data.append(this.name, value);
235
+ }
236
+ return data;
237
+ }
238
+ return values;
239
+ }
240
+ /** @inheritdoc */
241
+ get shouldLabelFloat() {
242
+ return this.selected.filter((x) => !x.isEmpty).length > 0;
243
+ }
244
+ /** @inheritdoc */
245
+ onContainerClick() {
246
+ __classPrivateFieldSet(this, _M3eSelectElement_ignoreFocusVisible, true, "f");
247
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_toggleMenu).call(this);
248
+ this.focus({ preventScroll: true });
249
+ }
250
+ /**
251
+ * Clears the value of the element.
252
+ * @param [restoreFocus=false] Whether to restore input focus.
253
+ */
254
+ clear(restoreFocus = false) {
255
+ const selected = this.selected;
256
+ const willChange = selected.length > 0;
257
+ if (willChange) {
258
+ selected.forEach((x) => (x.selected = false));
259
+ this.requestUpdate();
260
+ }
261
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_hideMenu).call(this);
262
+ if (willChange) {
263
+ this.dispatchEvent(new Event("change", { bubbles: true }));
264
+ }
265
+ if (restoreFocus) {
266
+ this.focus();
267
+ }
268
+ }
269
+ /** @inheritdoc */
270
+ connectedCallback() {
271
+ super.connectedCallback();
272
+ this.ariaHasPopup = "listbox";
273
+ this.ariaExpanded = "false";
274
+ this.addEventListener("click", __classPrivateFieldGet(this, _M3eSelectElement_clickHandler, "f"));
275
+ this.addEventListener("keydown", __classPrivateFieldGet(this, _M3eSelectElement_keyDownHandler, "f"));
276
+ this.addEventListener("keyup", __classPrivateFieldGet(this, _M3eSelectElement_keyUpHandler, "f"));
277
+ }
278
+ /** @inheritdoc */
279
+ disconnectedCallback() {
280
+ super.disconnectedCallback();
281
+ this.removeEventListener("click", __classPrivateFieldGet(this, _M3eSelectElement_clickHandler, "f"));
282
+ this.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eSelectElement_keyDownHandler, "f"));
283
+ this.removeEventListener("keyup", __classPrivateFieldGet(this, _M3eSelectElement_keyUpHandler, "f"));
284
+ }
285
+ /** @inheritdoc */
286
+ update(changedProperties) {
287
+ super.update(changedProperties);
288
+ if (changedProperties.has("hideSelectionIndicator")) {
289
+ this.options.forEach((x) => x.classList.toggle("-hide-selection-indicator", this.hideSelectionIndicator));
290
+ }
291
+ }
292
+ /** @inheritdoc */
293
+ firstUpdated(_changedProperties) {
294
+ super.firstUpdated(_changedProperties);
295
+ this._focusRing?.attach(this);
296
+ if (__classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get) && this._focusRing) {
297
+ this._focusRing.style.display = "none";
298
+ }
299
+ }
300
+ /** @inheritdoc */
301
+ render() {
302
+ return html ` <m3e-focus-ring class="focus-ring"></m3e-focus-ring>
303
+ <div class="base">
304
+ <m3e-text-overflow>
305
+ <slot name="value">
306
+ ${this.selected
307
+ .filter((x) => !x.isEmpty)
308
+ .map((x, i) => (i > 0 ? html `<span>, </span>${o(x.innerHTML)}` : o(x.innerHTML)))}
309
+ </slot>
310
+ </m3e-text-overflow>
311
+ <div class="arrow-wrapper" aria-hidden="true">
312
+ <slot name="arrow">
313
+ <svg class="arrow" viewBox="0 -960 960 960" fill="currentColor">
314
+ <path d="M480-360 280-560h400L480-360Z" />
315
+ </svg>
316
+ </slot>
317
+ </div>
318
+ </div>
319
+ <div class="options" role="listbox" aria-multiselectable="${this.multi}">
320
+ <slot @slotchange="${__classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_handleSlotChange)}"></slot>
321
+ </div>`;
322
+ }
323
+ };
324
+ _M3eSelectElement_minMenuWidth_get = function _M3eSelectElement_minMenuWidth_get() {
325
+ const formField = __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get);
326
+ return `${formField ? formField.menuAnchor.clientWidth : this.clientWidth}px`;
327
+ };
328
+ _M3eSelectElement_formField_get = function _M3eSelectElement_formField_get() {
329
+ return this.closest("m3e-form-field");
330
+ };
331
+ _M3eSelectElement_handleSlotChange = function _M3eSelectElement_handleSlotChange() {
332
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f"))
333
+ return;
334
+ const { added } = this._listKeyManager.setItems([...this.querySelectorAll("m3e-option")]);
335
+ added.forEach((x) => {
336
+ x.id = x.id || `${__classPrivateFieldGet(this, _M3eSelectElement_id, "f")}-option-${this._listKeyManager.items.indexOf(x)}`;
337
+ x.classList.toggle("-multi", this.multi);
338
+ x.classList.toggle("-hide-selection-indicator", this.hideSelectionIndicator);
339
+ });
340
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get)?.notifyControlStateChange();
341
+ };
342
+ _M3eSelectElement_handleClick = function _M3eSelectElement_handleClick(e) {
343
+ if (e.defaultPrevented || this.disabled)
344
+ return;
345
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_toggleMenu).call(this);
346
+ };
347
+ _M3eSelectElement_handleKeyDown = function _M3eSelectElement_handleKeyDown(e) {
348
+ if (e.defaultPrevented)
349
+ return;
350
+ __classPrivateFieldSet(this, _M3eSelectElement_ignoreFocusVisible, false, "f");
351
+ switch (e.key) {
352
+ case " ":
353
+ case "Enter":
354
+ e.preventDefault();
355
+ if (!this.multi) {
356
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f") && this._listKeyManager.activeItem) {
357
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_selectOption).call(this, this._listKeyManager.activeItem);
358
+ }
359
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_toggleMenu).call(this);
360
+ }
361
+ else if (!__classPrivateFieldGet(this, _M3eSelectElement_menu, "f")) {
362
+ __classPrivateFieldSet(this, _M3eSelectElement_ignoreKeyUp, true, "f");
363
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_toggleMenu).call(this);
364
+ }
365
+ break;
366
+ case "Escape":
367
+ case "Tab":
368
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_hideMenu).call(this);
369
+ break;
370
+ case "Down":
371
+ case "ArrowDown":
372
+ if (this.multi && !__classPrivateFieldGet(this, _M3eSelectElement_menu, "f")) {
373
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_toggleMenu).call(this);
374
+ }
375
+ else {
376
+ this._listKeyManager.onKeyDown(e);
377
+ if (!__classPrivateFieldGet(this, _M3eSelectElement_menu, "f") && this._listKeyManager.activeItem) {
378
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_selectOption).call(this, this._listKeyManager.activeItem);
379
+ }
380
+ }
381
+ break;
382
+ default:
383
+ this._listKeyManager.onKeyDown(e);
384
+ if (!this.multi && !__classPrivateFieldGet(this, _M3eSelectElement_menu, "f") && this._listKeyManager.activeItem) {
385
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_selectOption).call(this, this._listKeyManager.activeItem);
386
+ }
387
+ break;
388
+ }
389
+ };
390
+ _M3eSelectElement_handleKeyUp = function _M3eSelectElement_handleKeyUp(e) {
391
+ if (e.defaultPrevented)
392
+ return;
393
+ if (__classPrivateFieldGet(this, _M3eSelectElement_ignoreKeyUp, "f")) {
394
+ __classPrivateFieldSet(this, _M3eSelectElement_ignoreKeyUp, false, "f");
395
+ return;
396
+ }
397
+ switch (e.key) {
398
+ case " ":
399
+ case "Enter":
400
+ if (!this.multi)
401
+ return;
402
+ e.preventDefault();
403
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f") && this._listKeyManager.activeItem) {
404
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_selectOption).call(this, this._listKeyManager.activeItem);
405
+ }
406
+ break;
407
+ }
408
+ };
409
+ _M3eSelectElement_handleMenuPointerDown = function _M3eSelectElement_handleMenuPointerDown(e) {
410
+ e.preventDefault();
411
+ e.stopImmediatePropagation();
412
+ const option = (e.composedPath().find((x) => x instanceof HTMLElement && x.tagName === "M3E-OPTION"));
413
+ if (option && !option.disabled) {
414
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_selectOption).call(this, option);
415
+ this._listKeyManager.setActiveItem(option);
416
+ if (!this.multi) {
417
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_hideMenu).call(this);
418
+ }
419
+ else {
420
+ this.requestUpdate();
421
+ }
422
+ }
423
+ };
424
+ _M3eSelectElement_handleMenuToggle = function _M3eSelectElement_handleMenuToggle(e) {
425
+ if (!__classPrivateFieldGet(this, _M3eSelectElement_menu, "f"))
426
+ return;
427
+ if (e.newState !== "closed") {
428
+ const option = this.selected.find((x) => !x.disabled) ?? this._listKeyManager.items.find((x) => !x.disabled);
429
+ this._listKeyManager.setActiveItem(option);
430
+ if (option) {
431
+ scrollIntoViewIfNeeded(option, __classPrivateFieldGet(this, _M3eSelectElement_menu, "f"), { block: "nearest", behavior: "instant" });
432
+ }
433
+ this.dispatchEvent(new ToggleEvent("toggle", {
434
+ oldState: e.oldState,
435
+ newState: e.newState,
436
+ }));
437
+ }
438
+ else {
439
+ if (prefersReducedMotion()) {
440
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_destroyMenu).call(this, e);
441
+ }
442
+ else {
443
+ // NOTE: use transitionend is preferred but doesn't fire when used here.
444
+ // This is a workaround until that is fixed.
445
+ setTimeout(() => __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_destroyMenu).call(this, e), 100);
446
+ }
447
+ }
448
+ };
449
+ _M3eSelectElement_destroyMenu = function _M3eSelectElement_destroyMenu(e) {
450
+ if (!__classPrivateFieldGet(this, _M3eSelectElement_menu, "f"))
451
+ return;
452
+ [...__classPrivateFieldGet(this, _M3eSelectElement_menu, "f").childNodes].forEach((x) => this.append(x));
453
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").remove();
454
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").removeEventListener("toggle", __classPrivateFieldGet(this, _M3eSelectElement_menuToggleHandler, "f"));
455
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").removeEventListener("pointerdown", __classPrivateFieldGet(this, _M3eSelectElement_menuPointerDownHandler, "f"));
456
+ __classPrivateFieldSet(this, _M3eSelectElement_menu, undefined, "f");
457
+ this.ariaExpanded = "false";
458
+ this.removeAttribute("aria-controls");
459
+ this.removeAttribute("aria-owns");
460
+ this.requestUpdate();
461
+ this.classList.toggle("-open", false);
462
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get)?.notifyControlStateChange();
463
+ this.dispatchEvent(new ToggleEvent("toggle", {
464
+ oldState: e.oldState,
465
+ newState: e.newState,
466
+ }));
467
+ };
468
+ _M3eSelectElement_toggleMenu = function _M3eSelectElement_toggleMenu() {
469
+ if (this.disabled)
470
+ return;
471
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f")) {
472
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_hideMenu).call(this);
473
+ }
474
+ else {
475
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "m", _M3eSelectElement_showMenu).call(this);
476
+ }
477
+ };
478
+ _M3eSelectElement_showMenu = function _M3eSelectElement_showMenu() {
479
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f"))
480
+ return;
481
+ __classPrivateFieldSet(this, _M3eSelectElement_menu, document.createElement("m3e-option-panel"), "f");
482
+ if (this.multi) {
483
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").ariaMultiSelectable = "true";
484
+ }
485
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").id = __classPrivateFieldGet(this, _M3eSelectElement_listId, "f");
486
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").style.overflowX = "hidden";
487
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").style.minWidth = __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_minMenuWidth_get);
488
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").addEventListener("toggle", __classPrivateFieldGet(this, _M3eSelectElement_menuToggleHandler, "f"));
489
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").addEventListener("pointerdown", __classPrivateFieldGet(this, _M3eSelectElement_menuPointerDownHandler, "f"));
490
+ for (const node of [...this.childNodes]) {
491
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").append(node);
492
+ }
493
+ (__classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get) ?? this).insertAdjacentElement("afterend", __classPrivateFieldGet(this, _M3eSelectElement_menu, "f"));
494
+ this.ariaExpanded = "true";
495
+ this.setAttribute("aria-controls", __classPrivateFieldGet(this, _M3eSelectElement_listId, "f"));
496
+ this.setAttribute("aria-owns", __classPrivateFieldGet(this, _M3eSelectElement_listId, "f"));
497
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get)?.notifyControlStateChange();
498
+ setTimeout(() => {
499
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f")?.show(this, __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get)?.menuAnchor);
500
+ this.classList.toggle("-open", true);
501
+ });
502
+ };
503
+ _M3eSelectElement_hideMenu = function _M3eSelectElement_hideMenu() {
504
+ if (!__classPrivateFieldGet(this, _M3eSelectElement_menu, "f"))
505
+ return;
506
+ __classPrivateFieldGet(this, _M3eSelectElement_menu, "f").hide();
507
+ this.removeAttribute("aria-activedescendant");
508
+ this.classList.toggle("-open", false);
509
+ };
510
+ _M3eSelectElement_activateOption = function _M3eSelectElement_activateOption(option) {
511
+ this.setAttribute("aria-activedescendant", option.id);
512
+ if (__classPrivateFieldGet(this, _M3eSelectElement_menu, "f")) {
513
+ scrollIntoViewIfNeeded(option, __classPrivateFieldGet(this, _M3eSelectElement_menu, "f"), { block: "nearest", behavior: "instant" });
514
+ const focusVisible = !__classPrivateFieldGet(this, _M3eSelectElement_ignoreFocusVisible, "f") && (this.matches(":focus-visible") || forcedColorsActive());
515
+ this.options.forEach((x) => {
516
+ const active = x === option && focusVisible;
517
+ if (active) {
518
+ x.focusRing?.show();
519
+ x.stateLayer?.show("focused");
520
+ }
521
+ else {
522
+ x.focusRing?.hide();
523
+ x.stateLayer?.hide("focused");
524
+ }
525
+ });
526
+ }
527
+ };
528
+ _M3eSelectElement_selectOption = function _M3eSelectElement_selectOption(option) {
529
+ const selected = this.multi ? !option.selected : true;
530
+ if (option.selected === selected)
531
+ return;
532
+ option.selected = selected;
533
+ if (this.dispatchEvent(new Event("input", { bubbles: true, composed: true, cancelable: true }))) {
534
+ if (!this.multi) {
535
+ this.selected.filter((x) => x !== option).forEach((x) => (x.selected = false));
536
+ }
537
+ this.requestUpdate();
538
+ __classPrivateFieldGet(this, _M3eSelectElement_instances, "a", _M3eSelectElement_formField_get)?.notifyControlStateChange();
539
+ this.dispatchEvent(new Event("change", { bubbles: true }));
540
+ }
541
+ else {
542
+ option.selected = !selected;
543
+ }
544
+ };
545
+ /** The styles of the element. */
546
+ M3eSelectElement.styles = css `
547
+ :host {
548
+ display: inline-flex;
549
+ vertical-align: middle;
550
+ outline: none;
551
+ position: relative;
552
+ font-size: var(--m3e-form-field-font-size, ${DesignToken.typescale.standard.body.large.fontSize});
553
+ font-weight: var(--m3e-form-field-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});
554
+ line-height: var(--m3e-form-field-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});
555
+ letter-spacing: var(--m3e-form-field-tracking, ${DesignToken.typescale.standard.body.large.tracking});
556
+ min-height: var(--m3e-form-field-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});
557
+ border-radius: var(--m3e-select-container-shape, ${DesignToken.shape.corner.extraSmall});
558
+ }
559
+ :host(:not(:disabled)) {
560
+ cursor: pointer;
561
+ }
562
+ :host(:disabled) {
563
+ color: color-mix(
564
+ in srgb,
565
+ var(--m3e-select-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-select-disabled-color-opacity, 38%),
566
+ transparent
567
+ );
568
+ }
569
+ .options {
570
+ display: none;
571
+ }
572
+ .base {
573
+ flex: 1 1 auto;
574
+ display: inline-flex;
575
+ align-items: center;
576
+ overflow: hidden;
577
+ }
578
+ .arrow-wrapper {
579
+ display: flex;
580
+ align-items: center;
581
+ justify-content: center;
582
+ margin-top: var(--_select-arrow-margin-top);
583
+ }
584
+ ::slotted([slot="arrow"]),
585
+ .arrow {
586
+ vertical-align: middle;
587
+ width: 1em;
588
+ height: 1em;
589
+ font-size: var(--m3e-select-icon-size, 1.5rem);
590
+ }
591
+ :host(.-open) .focus-ring {
592
+ display: none;
593
+ }
594
+ `;
595
+ /** @private */ M3eSelectElement.__nextId = 0;
596
+ __decorate([
597
+ e$3(".focus-ring")
598
+ ], M3eSelectElement.prototype, "_focusRing", void 0);
599
+ __decorate([
600
+ n$1({ attribute: "hide-selection-indicator", type: Boolean })
601
+ ], M3eSelectElement.prototype, "hideSelectionIndicator", void 0);
602
+ __decorate([
603
+ n$1({ type: Boolean })
604
+ ], M3eSelectElement.prototype, "multi", void 0);
605
+ M3eSelectElement = M3eSelectElement_1 = __decorate([
606
+ t$3("m3e-select")
607
+ ], M3eSelectElement);
608
+
609
+ export { M3eSelectElement };
610
+ //# sourceMappingURL=index.js.map