@m3e/nav-menu 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -248,7 +248,7 @@ function q(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
248
248
  * @license
249
249
  * Copyright 2017 Google LLC
250
250
  * SPDX-License-Identifier: BSD-3-Clause
251
- */()],Ne.prototype,"_hasChildItems",void 0),v([B({type:Boolean,reflect:!0})],Ne.prototype,"open",void 0),Ne=Le=v([b("m3e-nav-menu-item")],Ne);let et=Ye=class extends(l(e,"tree")){constructor(){super(),je.add(this),We.set(this,!1),De.set(this,!1),this[Xe]=(new f).withVerticalOrientation().withHomeAndEnd().withTypeahead().withSkipPredicate(e=>e.disabled||!e.visible).disableRovingTabIndex().onActiveItemChange(()=>{this[u].activeItem&&g(this,je,"m",Je).call(this,this[u].activeItem)}).onSelectedItemsChange(()=>{const e=this.selected;for(const t of this.items)t!==e&&g(this,je,"m",Qe).call(this,t,!1,!1);e?.label&&d(e.label,this,{block:"start",behavior:"smooth"})}),ze.set(this,e=>g(this,je,"m",Ke).call(this,e)),Be.set(this,e=>g(this,je,"m",Ze).call(this,e)),qe.set(this,e=>g(this,je,"m",Fe).call(this,e)),new m(this,{callback:e=>$(this,De,e,"f")}),new p(this,{callback:()=>{g(this,De,"f")||g(this,je,"m",Ge).call(this)}})}get selected(){return this[u].selectedItems[0]??null}get items(){return this[u].items}expand(e){(e??this[u].items).forEach(e=>e.expand())}collapse(e){(e??this[u].items).forEach(e=>e.collapse());const t=this[u].activeItem;if(t&&!t.visible)for(let e=t.parentItem;e;e=e.parentItem)if(e.visible){this[u].setActiveItem(e);break}}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.addEventListener("keydown",g(this,ze,"f")),this.addEventListener("keyup",g(this,Be,"f")),this.addEventListener("pointerdown",g(this,qe,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",g(this,ze,"f")),this.removeEventListener("keyup",g(this,Be,"f")),this.removeEventListener("pointerdown",g(this,qe,"f"))}render(){return t`<slot @slotchange="${g(this,je,"m",Ve)}"></slot>`}};var tt,st,it,nt,ot;We=new WeakMap,De=new WeakMap,ze=new WeakMap,Be=new WeakMap,qe=new WeakMap,je=new WeakSet,Xe=u,Ve=function(){for(const e of this.querySelectorAll("m3e-divider"))e.ariaHidden="true";const{added:e}=this[u].setItems([...this.querySelectorAll("m3e-nav-menu-item")]);for(const t of e)t.id=t.id||"m3e-nav-menu-item-"+Ye.__nextId++;this[u].activeItem?(this.setAttribute("aria-activedescendant",this[u].activeItem.id),g(this,je,"m",Ge).call(this)):this.removeAttribute("aria-activedescendant")},Ke=function(e){$(this,We,!1,"f"),g(this,je,"m",Ge).call(this);const t=this[u].activeItem;if(!e.defaultPrevented&&t&&!t.disabled)switch(e.key){case"Enter":case" ":e.preventDefault(),t.ripple&&!t.ripple.visible&&t.ripple.show(0,0,!0),t.hasChildItems?t.toggle():t.selected||(this[u].select(t),t.link?.click());break;case"*":e.preventDefault(),t.expand(!0);break;case"Left":case"ArrowLeft":if(e.preventDefault(),t.hasChildItems&&t.open)t.collapse();else{const e=t.parentItem;e&&(e.collapse(),this[u].setActiveItem(e))}break;case"Right":case"ArrowRight":if(t.hasChildItems)if(t.open)try{this[u].vertical=!1,this[u].onKeyDown(e)}finally{this[u].vertical=!0}else e.preventDefault(),t.expand();else e.preventDefault();break;default:this[u].onKeyDown(e)}},Ze=function(e){const t=this[u].activeItem;if(!e.defaultPrevented&&t&&!t.disabled)switch(e.key){case"Enter":case" ":t.ripple?.hide()}},Fe=function(e){if(!e.defaultPrevented&&!g(this,We,"f")){$(this,We,!0,"f");const t=e.composedPath().reverse().find(e=>e instanceof Ne);t&&!t.disabled&&g(this,je,"m",Qe).call(this,t,!0,!1)}},Je=function(e){this.setAttribute("aria-activedescendant",e.id),e.label&&d(e.label,this,{block:"nearest",behavior:"smooth"}),g(this,je,"m",Ge).call(this)},Ge=function(){const e=this.matches(":focus")||this.matches(":focus-within"),t=!g(this,We,"f")&&this.matches(":focus-visible");this[u].items.forEach(s=>{const i=s===this[u].activeItem;g(this,je,"m",Qe).call(this,s,i&&e,i&&t)})},Qe=function(e,t,s){t&&s?e.stateLayer?.show("focused"):e.stateLayer?.hide("focused"),s?e.focusRing?.show():e.focusRing?.hide()},et.styles=i`
251
+ */()],Ne.prototype,"_hasChildItems",void 0),v([B({type:Boolean,reflect:!0})],Ne.prototype,"open",void 0),Ne=Le=v([b("m3e-nav-menu-item")],Ne);let et=Ye=class extends(l(e,"tree")){constructor(){super(),je.add(this),We.set(this,!1),De.set(this,!1),this[Xe]=(new f).withVerticalOrientation().withHomeAndEnd().withTypeahead().withSkipPredicate(e=>e.disabled||!e.visible).disableRovingTabIndex().onActiveItemChange(()=>{this[u].activeItem&&g(this,je,"m",Je).call(this,this[u].activeItem)}).onSelectedItemsChange(()=>{const e=this.selected;for(const t of this.items)t!==e&&g(this,je,"m",Qe).call(this,t,!1,!1);e?.label&&d(e.label,this,{block:"start",behavior:"smooth"})}),ze.set(this,e=>g(this,je,"m",Ke).call(this,e)),Be.set(this,e=>g(this,je,"m",Ze).call(this,e)),qe.set(this,e=>g(this,je,"m",Fe).call(this,e)),new m(this,{callback:e=>$(this,De,e,"f")}),new p(this,{callback:()=>{g(this,De,"f")||g(this,je,"m",Ge).call(this)}})}get selected(){return this[u].selectedItems[0]??null}get items(){return this[u].items}expand(e){(e??this[u].items).forEach(e=>e.expand())}collapse(e){(e??this[u].items).forEach(e=>e.collapse());const t=this[u].activeItem;if(t&&!t.visible)for(let e=t.parentItem;e;e=e.parentItem)if(e.visible){this[u].setActiveItem(e);break}}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.addEventListener("keydown",g(this,ze,"f")),this.addEventListener("keyup",g(this,Be,"f")),this.addEventListener("pointerdown",g(this,qe,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",g(this,ze,"f")),this.removeEventListener("keyup",g(this,Be,"f")),this.removeEventListener("pointerdown",g(this,qe,"f"))}render(){return t`<slot @slotchange="${g(this,je,"m",Ve)}"></slot>`}};var tt,st,it,nt,ot;We=new WeakMap,De=new WeakMap,ze=new WeakMap,Be=new WeakMap,qe=new WeakMap,je=new WeakSet,Xe=u,Ve=function(){for(const e of this.querySelectorAll("m3e-divider"))e.ariaHidden="true";const{added:e}=this[u].setItems([...this.querySelectorAll("m3e-nav-menu-item")]);for(const t of e)t.id=t.id||"m3e-nav-menu-item-"+Ye.__nextId++;this[u].activeItem?(this.setAttribute("aria-activedescendant",this[u].activeItem.id),g(this,je,"m",Ge).call(this)):this.removeAttribute("aria-activedescendant")},Ke=function(e){$(this,We,!1,"f"),g(this,je,"m",Ge).call(this);const t=this[u].activeItem;if(!e.defaultPrevented&&t&&!t.disabled)switch(e.key){case"Enter":case" ":e.preventDefault()," "===e.key&&t.ripple&&!t.ripple.visible&&t.ripple.show(0,0,!0),t.hasChildItems?t.toggle():t.selected||(this[u].select(t),t.link?.click());break;case"*":e.preventDefault(),t.expand(!0);break;case"Left":case"ArrowLeft":if(e.preventDefault(),t.hasChildItems&&t.open)t.collapse();else{const e=t.parentItem;e&&(e.collapse(),this[u].setActiveItem(e))}break;case"Right":case"ArrowRight":if(t.hasChildItems)if(t.open)try{this[u].vertical=!1,this[u].onKeyDown(e)}finally{this[u].vertical=!0}else e.preventDefault(),t.expand();else e.preventDefault();break;default:this[u].onKeyDown(e)}},Ze=function(e){const t=this[u].activeItem;e.defaultPrevented||!t||t.disabled||" "!==e.key||t.ripple?.hide()},Fe=function(e){if(!e.defaultPrevented&&!g(this,We,"f")){$(this,We,!0,"f");const t=e.composedPath().reverse().find(e=>e instanceof Ne);t&&!t.disabled&&g(this,je,"m",Qe).call(this,t,!0,!1)}},Je=function(e){this.setAttribute("aria-activedescendant",e.id),e.label&&d(e.label,this,{block:"nearest",behavior:"smooth"}),g(this,je,"m",Ge).call(this)},Ge=function(){const e=this.matches(":focus")||this.matches(":focus-within"),t=!g(this,We,"f")&&this.matches(":focus-visible");this[u].items.forEach(s=>{const i=s===this[u].activeItem;g(this,je,"m",Qe).call(this,s,i&&e,i&&t)})},Qe=function(e,t,s){t&&s?e.stateLayer?.show("focused"):e.stateLayer?.hide("focused"),s?e.focusRing?.show():e.focusRing?.hide()},et.styles=i`
252
252
  :host {
253
253
  display: flex;
254
254
  flex-direction: column;