@m3e/menu 1.0.0-rc.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -14,18 +14,18 @@ const C=e=>(t,s)=>{void 0!==s?s.addInitializer(()=>{customElements.define(e,t)})
14
14
  * @license
15
15
  * Copyright 2019 Google LLC
16
16
  * SPDX-License-Identifier: BSD-3-Clause
17
- */let A=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==L)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(x&&void 0===e){const s=void 0!==t&&1===t.length;s&&(e=M.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&M.set(t,e))}return e}toString(){return this.cssText}};const U=(e,t)=>{if(x)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const s of t){const t=document.createElement("style"),i=P.litNonce;void 0!==i&&t.setAttribute("nonce",i),t.textContent=s.cssText,e.appendChild(t)}},O=x?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new A("string"==typeof e?e:e+"",void 0,L))(t)})(e):e,{is:W,defineProperty:T,getOwnPropertyDescriptor:R,getOwnPropertyNames:z,getOwnPropertySymbols:j,getPrototypeOf:D}=Object,q=globalThis,N=q.trustedTypes,I=N?N.emptyScript:"",B=q.reactiveElementPolyfillSupport,H=(e,t)=>e,Y={toAttribute(e,t){switch(t){case Boolean:e=e?I:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},K=(e,t)=>!W(e,t),X={attribute:!0,type:String,converter:Y,reflect:!1,useDefault:!1,hasChanged:K};
17
+ */let U=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==L)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(x&&void 0===e){const s=void 0!==t&&1===t.length;s&&(e=M.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&M.set(t,e))}return e}toString(){return this.cssText}};const A=(e,t)=>{if(x)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const s of t){const t=document.createElement("style"),i=P.litNonce;void 0!==i&&t.setAttribute("nonce",i),t.textContent=s.cssText,e.appendChild(t)}},O=x?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new U("string"==typeof e?e:e+"",void 0,L))(t)})(e):e,{is:W,defineProperty:T,getOwnPropertyDescriptor:R,getOwnPropertyNames:z,getOwnPropertySymbols:j,getPrototypeOf:D}=Object,q=globalThis,N=q.trustedTypes,I=N?N.emptyScript:"",B=q.reactiveElementPolyfillSupport,H=(e,t)=>e,Y={toAttribute(e,t){switch(t){case Boolean:e=e?I:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},K=(e,t)=>!W(e,t),X={attribute:!0,type:String,converter:Y,reflect:!1,useDefault:!1,hasChanged:K};
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */Symbol.metadata??=Symbol("metadata"),q.litPropertyMetadata??=new WeakMap;class Z extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=X){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(e,s,t);void 0!==i&&T(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){const{get:i,set:n}=R(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:i,set(t){const o=i?.call(this);n?.call(this,t),this.requestUpdate(e,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??X}static _$Ei(){if(this.hasOwnProperty(H("elementProperties")))return;const e=D(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(H("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(H("properties"))){const e=this.properties,t=[...z(e),...j(e)];for(const s of t)this.createProperty(s,e[s])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,s]of t)this.elementProperties.set(e,s)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const s=this._$Eu(e,t);void 0!==s&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(O(e))}else void 0!==e&&t.push(O(e));return t}static _$Eu(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return U(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){const s=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:Y).toAttribute(t,s.type);this._$Em=e,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(e,t){const s=this.constructor,i=s._$Eh.get(e);if(void 0!==i&&this._$Em!==i){const e=s.getPropertyOptions(i),n="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:Y;this._$Em=i;const o=n.fromAttribute(t,e.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(e,t,s){if(void 0!==e){const i=this.constructor,n=this[e];if(s??=i.getPropertyOptions(e),!((s.hasChanged??K)(n,t)||s.useDefault&&s.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(i._$Eu(e,s))))return;this.C(e,t,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),!0!==n||void 0!==o)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,s]of e){const{wrapped:e}=s,i=this[t];!0!==e||this._$AL.has(t)||void 0===i||this.C(t,void 0,s,i)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}}Z.elementStyles=[],Z.shadowRootOptions={mode:"open"},Z[H("elementProperties")]=new Map,Z[H("finalized")]=new Map,B?.({ReactiveElement:Z}),(q.reactiveElementVersions??=[]).push("2.1.1");
22
+ */Symbol.metadata??=Symbol("metadata"),q.litPropertyMetadata??=new WeakMap;class Z extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=X){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(e,s,t);void 0!==i&&T(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){const{get:i,set:n}=R(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:i,set(t){const o=i?.call(this);n?.call(this,t),this.requestUpdate(e,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??X}static _$Ei(){if(this.hasOwnProperty(H("elementProperties")))return;const e=D(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(H("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(H("properties"))){const e=this.properties,t=[...z(e),...j(e)];for(const s of t)this.createProperty(s,e[s])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,s]of t)this.elementProperties.set(e,s)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const s=this._$Eu(e,t);void 0!==s&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(O(e))}else void 0!==e&&t.push(O(e));return t}static _$Eu(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return A(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){const s=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:Y).toAttribute(t,s.type);this._$Em=e,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(e,t){const s=this.constructor,i=s._$Eh.get(e);if(void 0!==i&&this._$Em!==i){const e=s.getPropertyOptions(i),n="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:Y;this._$Em=i;const o=n.fromAttribute(t,e.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(e,t,s){if(void 0!==e){const i=this.constructor,n=this[e];if(s??=i.getPropertyOptions(e),!((s.hasChanged??K)(n,t)||s.useDefault&&s.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(i._$Eu(e,s))))return;this.C(e,t,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),!0!==n||void 0!==o)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,s]of e){const{wrapped:e}=s,i=this[t];!0!==e||this._$AL.has(t)||void 0===i||this.C(t,void 0,s,i)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}}Z.elementStyles=[],Z.shadowRootOptions={mode:"open"},Z[H("elementProperties")]=new Map,Z[H("finalized")]=new Map,B?.({ReactiveElement:Z}),(q.reactiveElementVersions??=[]).push("2.1.1");
23
23
  /**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
27
  */
28
- const J={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:K},V=(e=J,t,s)=>{const{kind:i,metadata:n}=s;let o=globalThis.litPropertyMetadata.get(n);if(void 0===o&&globalThis.litPropertyMetadata.set(n,o=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),"accessor"===i){const{name:i}=s;return{set(s){const n=t.get.call(this);t.set.call(this,s),this.requestUpdate(i,n,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=s;return function(s){const n=this[i];t.call(this,s),this.requestUpdate(i,n,e)}}throw Error("Unsupported decorator location: "+i)};function G(e){return(t,s)=>"object"==typeof s?V(e,t,s):((e,t,s)=>{const i=t.hasOwnProperty(s);return t.constructor.createProperty(s,e),i?Object.getOwnPropertyDescriptor(t,s):void 0})(e,t,s)}
28
+ const J={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:K},V=(e=J,t,s)=>{const{kind:i,metadata:n}=s;let o=globalThis.litPropertyMetadata.get(n);if(void 0===o&&globalThis.litPropertyMetadata.set(n,o=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),"accessor"===i){const{name:i}=s;return{set(s){const n=t.get.call(this);t.set.call(this,s),this.requestUpdate(i,n,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=s;return function(s){const n=this[i];t.call(this,s),this.requestUpdate(i,n,e)}}throw Error("Unsupported decorator location: "+i)};function F(e){return(t,s)=>"object"==typeof s?V(e,t,s):((e,t,s)=>{const i=t.hasOwnProperty(s);return t.constructor.createProperty(s,e),i?Object.getOwnPropertyDescriptor(t,s):void 0})(e,t,s)}
29
29
  /**
30
30
  * @license
31
31
  * Copyright 2017 Google LLC
@@ -36,7 +36,7 @@ const J={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:K},V=(e=J,t,
36
36
  * Copyright 2017 Google LLC
37
37
  * SPDX-License-Identifier: BSD-3-Clause
38
38
  */
39
- function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,s),s))(t,s,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}class Q extends(o(r(a(c(e),!0)))){get menu(){return this.closest("m3e-menu")}firstUpdated(e){super.firstUpdated(e),[this._focusRing,this._stateLayer,this._ripple].forEach(e=>e?.attach(this))}render(){return s`<div class="base">
39
+ function G(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,s),s))(t,s,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}class Q extends(o(r(a(c(e),!0)))){get menu(){return this.closest("m3e-menu")}firstUpdated(e){super.firstUpdated(e),[this._focusRing,this._stateLayer,this._ripple].forEach(e=>e?.attach(this))}render(){return s`<div class="base">
40
40
  <m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
41
41
  <m3e-focus-ring class="focus-ring" inward ?disabled="${this.disabled}"></m3e-focus-ring>
42
42
  <m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
@@ -146,7 +146,7 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
146
146
  color: GrayText;
147
147
  }
148
148
  }
149
- `,$([F(".focus-ring")],Q.prototype,"_focusRing",void 0),$([F(".state-layer")],Q.prototype,"_stateLayer",void 0),$([F(".ripple")],Q.prototype,"_ripple",void 0);let ie=class extends(u(e)){constructor(){super(...arguments),ee.add(this),te.set(this,async e=>S(this,ee,"m",se).call(this,e))}get menu(){return"M3E-MENU"===this.control?.tagName?this.control:null}connectedCallback(){super.connectedCallback(),this.parentElement?.addEventListener("click",S(this,te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.parentElement?.removeEventListener("click",S(this,te,"f"))}attach(e){super.attach(e);const t=this.menu;t&&(this.parentElement&&(this.parentElement.ariaHasPopup="menu",this.parentElement.ariaExpanded="false",t.id&&y(this.parentElement,"aria-controls",t.id)),this.closest("m3e-menu")&&(t.submenu=!0))}detach(){if(this.parentElement){this.parentElement.ariaHasPopup=null,this.parentElement.ariaExpanded=null;const e=this.menu;e?.id&&w(this.parentElement,"aria-controls",e.id)}super.detach()}render(){return s`<slot></slot>`}};var ne,oe,re,ae,ce,le,he,de,ue,me,pe,fe;te=new WeakMap,ee=new WeakSet,se=function(e){!e.defaultPrevented&&this.parentElement&&("M3E-MENU-ITEM"===this.parentElement.tagName?this.menu?.show(this.parentElement):this.menu?.toggle(this.parentElement))},ie.styles=i`
149
+ `,$([G(".focus-ring")],Q.prototype,"_focusRing",void 0),$([G(".state-layer")],Q.prototype,"_stateLayer",void 0),$([G(".ripple")],Q.prototype,"_ripple",void 0);let ie=class extends(u(e)){constructor(){super(...arguments),ee.add(this),te.set(this,async e=>S(this,ee,"m",se).call(this,e))}get menu(){return"M3E-MENU"===this.control?.tagName?this.control:null}connectedCallback(){super.connectedCallback(),this.parentElement?.addEventListener("click",S(this,te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.parentElement?.removeEventListener("click",S(this,te,"f"))}attach(e){super.attach(e);const t=this.menu;t&&(this.parentElement&&(this.parentElement.ariaHasPopup="menu",this.parentElement.ariaExpanded="false",t.id&&y(this.parentElement,"aria-controls",t.id)),this.closest("m3e-menu")&&(t.submenu=!0))}detach(){if(this.parentElement){this.parentElement.ariaHasPopup=null,this.parentElement.ariaExpanded=null;const e=this.menu;e?.id&&w(this.parentElement,"aria-controls",e.id)}super.detach()}render(){return s`<slot></slot>`}};var ne,oe,re,ae,ce,le,he,de,ue,me,pe,fe;te=new WeakMap,ee=new WeakSet,se=function(e){!e.defaultPrevented&&this.parentElement&&("M3E-MENU-ITEM"===this.parentElement.tagName?this.menu?.show(this.parentElement):this.menu?.toggle(this.parentElement))},ie.styles=i`
150
150
  :host {
151
151
  display: contents;
152
152
  }
@@ -158,12 +158,12 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
158
158
  ${this._hasSubmenu?s`<svg class="trailing-icon" aria-hidden="true" viewBox="0 -960 960 960" fill="currentColor">
159
159
  <path d="M400-280v-400l200 200-200 200Z" />
160
160
  </svg>`:s`<slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,ne,"m",de)}">
161
- </slot>`}`}};var be,ge,ye,we,Ee,ke,$e,Se,_e,Ce,Pe,xe,Le;oe=new WeakMap,re=new WeakMap,ae=new WeakMap,ce=new WeakMap,ne=new WeakSet,le=function(e){_(this,ce,e.target.assignedElements({flatten:!0}).find(e=>e instanceof ie),"f"),this._hasSubmenu=void 0!==S(this,ce,"f")},he=function(e){this.classList.toggle("-with-icon",v(e.target))},de=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},ue=function(e){e.defaultPrevented||this._hasSubmenu||this.menu?.hideAll(!0)},me=function(e){if(!e.defaultPrevented&&!this.disabled)switch(e.key){case"Right":case"ArrowRight":e.preventDefault(),this.submenu?.show(this)}},pe=function(){this.menu?.items.forEach(e=>{e instanceof fe&&e!==this&&e.submenu?.isOpen&&e.submenu.hide()})},$([function(e){return G({...e,state:!0,attribute:!1})}
161
+ </slot>`}`}};var be,ge,ye,we,Ee,ke,$e,Se,_e,Ce,Pe,xe,Le;oe=new WeakMap,re=new WeakMap,ae=new WeakMap,ce=new WeakMap,ne=new WeakSet,le=function(e){_(this,ce,e.target.assignedElements({flatten:!0}).find(e=>e instanceof ie),"f"),this._hasSubmenu=void 0!==S(this,ce,"f")},he=function(e){this.classList.toggle("-with-icon",v(e.target))},de=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},ue=function(e){e.defaultPrevented||this._hasSubmenu||this.menu?.hideAll(!0)},me=function(e){if(!e.defaultPrevented&&!this.disabled)switch(e.key){case"Right":case"ArrowRight":e.preventDefault(),this.submenu?.show(this)}},pe=function(){this.menu?.items.forEach(e=>{e instanceof fe&&e!==this&&e.submenu?.isOpen&&e.submenu.hide()})},$([function(e){return F({...e,state:!0,attribute:!1})}
162
162
  /**
163
163
  * @license
164
164
  * Copyright 2017 Google LLC
165
165
  * SPDX-License-Identifier: BSD-3-Clause
166
- */()],ve.prototype,"_hasSubmenu",void 0),ve=fe=$([C("m3e-menu-item")],ve);let Me=Le=class extends(p(e,"menu")){constructor(){super(...arguments),be.add(this),ge.set(this,void 0),ye.set(this,void 0),we.set(this,(new E).withWrap().withHomeAndEnd().withVerticalOrientation()),Ee.set(this,e=>S(this,be,"m",Ce).call(this,e)),ke.set(this,e=>S(this,be,"m",Pe).call(this,e)),$e.set(this,new b(this,{target:null,callback:e=>e instanceof Le?e.items.filter(e=>e instanceof ve).forEach(e=>e.submenu?.hide()):this.hideAll()})),Se.set(this,e=>{"closed"===e.newState?(S(this,ye,"f")?.call(this),_(this,ye,void 0,"f")):setTimeout(()=>{S(this,we,"f").setActiveItem(S(this,we,"f").items.find(e=>!e.disabled))},40)}),this.positionX="after",this.positionY="below",this.submenu=!1}get items(){return S(this,we,"f").items}get isOpen(){return void 0!==S(this,ge,"f")}connectedCallback(){super.connectedCallback(),this.tabIndex=-1,this.setAttribute("popover","manual"),this.addEventListener("keydown",S(this,Ee,"f")),this.addEventListener("toggle",S(this,Se,"f")),document.addEventListener("click",S(this,ke,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",S(this,Ee,"f")),this.removeEventListener("toggle",S(this,Se,"f")),document.removeEventListener("click",S(this,ke,"f"))}async show(e){S(this,ge,"f")&&S(this,ge,"f")!==e&&this.hide(),_(this,ye,await k(this,e,{position:this.submenu?"before"===this.positionX?"left-start":"right-start":"above"===this.positionY?"before"===this.positionX?"top-end":"top-start":"before"===this.positionX?"bottom-end":"bottom-start",inline:!0,flip:!0,shift:!0,offset:this.submenu?void 0:4},(e,t,s)=>{if(this.submenu){if(S(this,ge,"f")){const e=S(this,be,"m",xe).call(this,S(this,ge,"f")).y;this.classList.toggle("-shift-down",!1),this.classList.toggle("-shift-up",!1),this.classList.toggle(Math.round(t)===Math.round(e)?"-shift-down":"-shift-up",!0)}}else this.classList.toggle("-top",s.includes("top")),this.classList.toggle("-bottom",s.includes("bottom"));this.style.left=`${e}px`,this.style.top=`${t}px`}),"f"),this.showPopover(),_(this,ge,e,"f"),S(this,ge,"f").ariaExpanded="true",S(this,$e,"f").observe(S(this,ge,"f"))}hide(e=!1){for(const e of S(this,we,"f").items){const t=e.submenu;t&&t.isOpen&&t.hide()}this.hidePopover(),S(this,ge,"f")&&(S(this,ge,"f").ariaExpanded="false",e&&S(this,ge,"f").focus(),S(this,$e,"f").unobserve(S(this,ge,"f")),_(this,ge,void 0,"f"))}hideAll(e=!1){let t=this;for(;S(t,ge,"f");){const e=S(t,ge,"f").closest("m3e-menu");if(!e)break;t=e}t.hide(e)}async toggle(e){S(this,ge,"f")?this.hide():await this.show(e)}render(){return s`<slot @slotchange="${S(this,be,"m",_e)}"></slot>`}};var Ae,Ue,Oe,We,Te,Re,ze,je,De,qe,Ne,Ie;ge=new WeakMap,ye=new WeakMap,we=new WeakMap,Ee=new WeakMap,ke=new WeakMap,$e=new WeakMap,Se=new WeakMap,be=new WeakSet,_e=function(){const{added:e}=S(this,we,"f").setItems([...this.querySelectorAll("m3e-menu-item,m3e-menu-item-checkbox,m3e-menu-item-radio")].filter(e=>e.closest("m3e-menu")===this));S(this,we,"f").activeItem||S(this,we,"f").updateActiveItem(e.find(e=>!e.disabled))},Ce=function(e){switch(e.key){case"Left":case"ArrowLeft":e.preventDefault(),this.hide(!0);break;case"Tab":this.hideAll();break;case"Escape":e.shiftKey||e.ctrlKey||this.hide(!0);break;default:S(this,we,"f").onKeyDown(e)}},Pe=function(e){this.submenu||e.composedPath().some(e=>e instanceof Le||e===S(this,ge,"f"))||this.hide()},xe=function(e){let t=0,s=0;for(let i=e;i;i=i.offsetParent instanceof HTMLElement?i.offsetParent:null)t+=i.offsetLeft-i.scrollLeft+i.clientLeft,s+=i.offsetTop-i.scrollTop+i.clientTop;return{x:t,y:s}},Me.styles=i`
166
+ */()],ve.prototype,"_hasSubmenu",void 0),ve=fe=$([C("m3e-menu-item")],ve);let Me=Le=class extends(p(e,"menu")){constructor(){super(...arguments),be.add(this),ge.set(this,void 0),ye.set(this,void 0),we.set(this,(new E).withWrap().withHomeAndEnd().withVerticalOrientation()),Ee.set(this,e=>S(this,be,"m",Ce).call(this,e)),ke.set(this,e=>S(this,be,"m",Pe).call(this,e)),$e.set(this,new b(this,{target:null,callback:e=>e instanceof Le?e.items.filter(e=>e instanceof ve).forEach(e=>e.submenu?.hide()):this.hideAll()})),Se.set(this,e=>{"closed"===e.newState?(S(this,ye,"f")?.call(this),_(this,ye,void 0,"f")):setTimeout(()=>{S(this,we,"f").setActiveItem(S(this,we,"f").items.find(e=>!e.disabled))},40)}),this.positionX="after",this.positionY="below",this.submenu=!1}get items(){return S(this,we,"f").items}get isOpen(){return void 0!==S(this,ge,"f")}connectedCallback(){super.connectedCallback(),this.tabIndex=-1,this.classList.add("-no-animate"),this.setAttribute("popover","manual"),this.addEventListener("keydown",S(this,Ee,"f")),this.addEventListener("toggle",S(this,Se,"f")),document.addEventListener("click",S(this,ke,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",S(this,Ee,"f")),this.removeEventListener("toggle",S(this,Se,"f")),document.removeEventListener("click",S(this,ke,"f"))}async show(e){S(this,ge,"f")&&S(this,ge,"f")!==e&&this.hide(),_(this,ye,await k(this,e,{position:this.submenu?"before"===this.positionX?"left-start":"right-start":"above"===this.positionY?"before"===this.positionX?"top-end":"top-start":"before"===this.positionX?"bottom-end":"bottom-start",inline:!0,flip:!0,shift:!0,offset:this.submenu?void 0:4},(e,t,s)=>{if(this.submenu){if(S(this,ge,"f")){const e=S(this,be,"m",xe).call(this,S(this,ge,"f")).y;this.classList.toggle("-shift-down",!1),this.classList.toggle("-shift-up",!1),this.classList.toggle(Math.round(t)===Math.round(e)?"-shift-down":"-shift-up",!0)}}else this.classList.toggle("-top",s.includes("top")),this.classList.toggle("-bottom",s.includes("bottom"));this.style.left=`${e}px`,this.style.top=`${t}px`}),"f"),this.showPopover(),_(this,ge,e,"f"),S(this,ge,"f").ariaExpanded="true",S(this,$e,"f").observe(S(this,ge,"f"))}hide(e=!1){for(const e of S(this,we,"f").items){const t=e.submenu;t&&t.isOpen&&t.hide()}this.hidePopover(),S(this,ge,"f")&&(S(this,ge,"f").ariaExpanded="false",e&&S(this,ge,"f").focus(),S(this,$e,"f").unobserve(S(this,ge,"f")),_(this,ge,void 0,"f"))}hideAll(e=!1){let t=this;for(;S(t,ge,"f");){const e=S(t,ge,"f").closest("m3e-menu");if(!e)break;t=e}t.hide(e)}async toggle(e){S(this,ge,"f")?this.hide():await this.show(e)}render(){return s`<slot @slotchange="${S(this,be,"m",_e)}"></slot>`}firstUpdated(e){super.firstUpdated(e),requestAnimationFrame(()=>this.classList.remove("-no-animate"))}};var Ue,Ae,Oe,We,Te,Re,ze,je,De,qe,Ne,Ie;ge=new WeakMap,ye=new WeakMap,we=new WeakMap,Ee=new WeakMap,ke=new WeakMap,$e=new WeakMap,Se=new WeakMap,be=new WeakSet,_e=function(){const{added:e}=S(this,we,"f").setItems([...this.querySelectorAll("m3e-menu-item,m3e-menu-item-checkbox,m3e-menu-item-radio")].filter(e=>e.closest("m3e-menu")===this));S(this,we,"f").activeItem||S(this,we,"f").updateActiveItem(e.find(e=>!e.disabled))},Ce=function(e){switch(e.key){case"Left":case"ArrowLeft":e.preventDefault(),this.hide(!0);break;case"Tab":this.hideAll();break;case"Escape":e.shiftKey||e.ctrlKey||this.hide(!0);break;default:S(this,we,"f").onKeyDown(e)}},Pe=function(e){this.submenu||e.composedPath().some(e=>e instanceof Le||e===S(this,ge,"f"))||this.hide()},xe=function(e){let t=0,s=0;for(let i=e;i;i=i.offsetParent instanceof HTMLElement?i.offsetParent:null)t+=i.offsetLeft-i.scrollLeft+i.clientLeft,s+=i.offsetTop-i.scrollTop+i.clientTop;return{x:t,y:s}},Me.styles=i`
167
167
  :host {
168
168
  position: absolute;
169
169
  flex-direction: column;
@@ -182,6 +182,8 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
182
182
  box-shadow: var(--m3e-menu-container-elevation, ${d.elevation.level3});
183
183
  opacity: 0;
184
184
  display: none;
185
+ }
186
+ :host(:not(.-no-animate)) {
185
187
  transition: ${n(`opacity ${d.motion.duration.short2} ${d.motion.easing.standard}, \n transform ${d.motion.duration.short2} ${d.motion.easing.standard},\n overlay ${d.motion.duration.short2} ${d.motion.easing.standard} allow-discrete,\n display ${d.motion.duration.short2} ${d.motion.easing.standard} allow-discrete`)};
186
188
  }
187
189
  :host(:not([submenu])) {
@@ -221,7 +223,7 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
221
223
  }
222
224
  }
223
225
  @media (prefers-reduced-motion) {
224
- :host {
226
+ :host(:not(.-no-animate)) {
225
227
  transition: none;
226
228
  }
227
229
  }
@@ -232,14 +234,14 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
232
234
  border: 1px solid CanvasText;
233
235
  }
234
236
  }
235
- `,$([G({attribute:"position-x"})],Me.prototype,"positionX",void 0),$([G({attribute:"position-y"})],Me.prototype,"positionY",void 0),$([G({type:Boolean,reflect:!0})],Me.prototype,"submenu",void 0),Me=Le=$([C("m3e-menu")],Me);let Be=class extends(g(p(Q,"menuitemcheckbox"))){constructor(){super(...arguments),Ae.add(this),Ue.set(this,e=>S(this,Ae,"m",De).call(this,e)),Oe.set(this,e=>S(this,Ae,"m",qe).call(this,e)),We.set(this,()=>S(this,Ae,"m",Ne).call(this)),Te.set(this,()=>S(this,Ae,"m",Ie).call(this)),Re.set(this,!1)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",S(this,Ue,"f")),this.addEventListener("keydown",S(this,Oe,"f")),this.addEventListener("keyup",S(this,We,"f")),this.addEventListener("mouseenter",S(this,Te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",S(this,Ue,"f")),this.removeEventListener("keydown",S(this,Oe,"f")),this.removeEventListener("keyup",S(this,We,"f")),this.removeEventListener("mouseenter",S(this,Te,"f"))}_renderContent(){return s` <div class="icon">
237
+ `,$([F({attribute:"position-x"})],Me.prototype,"positionX",void 0),$([F({attribute:"position-y"})],Me.prototype,"positionY",void 0),$([F({type:Boolean,reflect:!0})],Me.prototype,"submenu",void 0),Me=Le=$([C("m3e-menu")],Me);let Be=class extends(g(p(Q,"menuitemcheckbox"))){constructor(){super(...arguments),Ue.add(this),Ae.set(this,e=>S(this,Ue,"m",De).call(this,e)),Oe.set(this,e=>S(this,Ue,"m",qe).call(this,e)),We.set(this,()=>S(this,Ue,"m",Ne).call(this)),Te.set(this,()=>S(this,Ue,"m",Ie).call(this)),Re.set(this,!1)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",S(this,Ae,"f")),this.addEventListener("keydown",S(this,Oe,"f")),this.addEventListener("keyup",S(this,We,"f")),this.addEventListener("mouseenter",S(this,Te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",S(this,Ae,"f")),this.removeEventListener("keydown",S(this,Oe,"f")),this.removeEventListener("keyup",S(this,We,"f")),this.removeEventListener("mouseenter",S(this,Te,"f"))}_renderContent(){return s` <div class="icon">
236
238
  <svg class="check" viewBox="0 -960 960 960" aria-hidden="true">
237
239
  <path fill="currentColor" d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
238
240
  </svg>
239
- <slot name="icon" @slotchange="${S(this,Ae,"m",ze)}"></slot>
241
+ <slot name="icon" @slotchange="${S(this,Ue,"m",ze)}"></slot>
240
242
  </div>
241
243
  <slot></slot>
242
- <slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,Ae,"m",je)}"></slot>`}};Ue=new WeakMap,Oe=new WeakMap,We=new WeakMap,Te=new WeakMap,Re=new WeakMap,Ae=new WeakSet,ze=function(e){this.classList.toggle("-with-icon",v(e.target))},je=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},De=function(e){e.defaultPrevented||(this.checked=!this.checked,this.performUpdate(),S(this,Re,"f")||this.menu?.hideAll(!0))},qe=function(e){_(this,Re," "===e.key,"f")},Ne=function(){_(this,Re,!1,"f")},Ie=function(){this.menu?.items.forEach(e=>{e instanceof ve&&e.submenu?.isOpen&&e.submenu.hide()})},Be.styles=[Q.styles,i`
244
+ <slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,Ue,"m",je)}"></slot>`}};Ae=new WeakMap,Oe=new WeakMap,We=new WeakMap,Te=new WeakMap,Re=new WeakMap,Ue=new WeakSet,ze=function(e){this.classList.toggle("-with-icon",v(e.target))},je=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},De=function(e){e.defaultPrevented||(this.checked=!this.checked,this.performUpdate(),S(this,Re,"f")||this.menu?.hideAll(!0))},qe=function(e){_(this,Re," "===e.key,"f")},Ne=function(){_(this,Re,!1,"f")},Ie=function(){this.menu?.items.forEach(e=>{e instanceof ve&&e.submenu?.isOpen&&e.submenu.hide()})},Be.styles=[Q.styles,i`
243
245
  .icon {
244
246
  display: flex;
245
247
  align-items: center;
@@ -261,7 +263,7 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
261
263
  :host([checked]) ::slotted([slot="icon"]) {
262
264
  display: none !important;
263
265
  }
264
- `],Be=$([C("m3e-menu-item-checkbox")],Be);let He=class extends(p(e,"group")){render(){return s`<slot></slot>`}};var Ye,Ke,Xe,Ze,Je,Ve,Ge,Fe,Qe,et,tt,st;He.styles=i`
266
+ `],Be=$([C("m3e-menu-item-checkbox")],Be);let He=class extends(p(e,"group")){render(){return s`<slot></slot>`}};var Ye,Ke,Xe,Ze,Je,Ve,Fe,Ge,Qe,et,tt,st;He.styles=i`
265
267
  :host {
266
268
  display: contents;
267
269
  }
@@ -269,8 +271,8 @@ function F(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
269
271
  <svg class="check" viewBox="0 -960 960 960" aria-hidden="true">
270
272
  <path fill="currentColor" d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
271
273
  </svg>
272
- <slot name="icon" @slotchange="${S(this,Ye,"m",Ge)}"></slot>
274
+ <slot name="icon" @slotchange="${S(this,Ye,"m",Fe)}"></slot>
273
275
  </div>
274
276
  <slot></slot>
275
- <slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,Ye,"m",Fe)}"></slot>`}};Ke=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Ve=new WeakMap,Ye=new WeakSet,Ge=function(e){this.classList.toggle("-with-icon",v(e.target))},Fe=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},Qe=function(e){e.defaultPrevented||(this.checked=!0,this.performUpdate(),S(this,Ve,"f")||this.menu?.hideAll(!0))},et=function(e){_(this,Ve," "===e.key,"f")},tt=function(){_(this,Ve,!1,"f")},st=function(){this.menu?.items.forEach(e=>{e instanceof ve&&e.submenu?.isOpen&&e.submenu.hide()})},it.styles=Be.styles,it=$([C("m3e-menu-item-radio")],it);export{Me as M3eMenuElement,Be as M3eMenuItemCheckboxElement,ve as M3eMenuItemElement,He as M3eMenuItemGroupElement,it as M3eMenuItemRadioElement,ie as M3eMenuTriggerElement};
277
+ <slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,Ye,"m",Ge)}"></slot>`}};Ke=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Ve=new WeakMap,Ye=new WeakSet,Fe=function(e){this.classList.toggle("-with-icon",v(e.target))},Ge=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},Qe=function(e){e.defaultPrevented||(this.checked=!0,this.performUpdate(),S(this,Ve,"f")||this.menu?.hideAll(!0))},et=function(e){_(this,Ve," "===e.key,"f")},tt=function(){_(this,Ve,!1,"f")},st=function(){this.menu?.items.forEach(e=>{e instanceof ve&&e.submenu?.isOpen&&e.submenu.hide()})},it.styles=Be.styles,it=$([C("m3e-menu-item-radio")],it);export{Me as M3eMenuElement,Be as M3eMenuItemCheckboxElement,ve as M3eMenuItemElement,He as M3eMenuItemGroupElement,it as M3eMenuItemRadioElement,ie as M3eMenuTriggerElement};
276
278
  //# sourceMappingURL=index.min.js.map