54 lines
27 KiB
JavaScript
54 lines
27 KiB
JavaScript
"use strict";const n=require("./class-map-DV5418hw.js");require("./elevation-CqmyG_RP.js");require("./ripple-DoKzzEey.js");const k=require("./animation-A38fZ1oY.js"),j=require("./query-assigned-elements-BYttmtWz.js"),Z=require("./style-map-Bzw6qQ8K.js"),w=require("./item-DvSwYnPq.js");/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/function Q(y,e){return new CustomEvent("close-menu",{bubbles:!0,composed:!0,detail:{initiator:y,reason:e,itemPath:[y]}})}const q=Q;function J(){return new Event("deactivate-typeahead",{bubbles:!0,composed:!0})}function ee(){return new Event("activate-typeahead",{bubbles:!0,composed:!0})}const te={UP:"ArrowUp",DOWN:"ArrowDown",RIGHT:"ArrowRight",LEFT:"ArrowLeft"},F={SPACE:"Space",ENTER:"Enter"},K={CLICK_SELECTION:"click-selection",KEYDOWN:"keydown"},Y={ESCAPE:"Escape",SPACE:F.SPACE,ENTER:F.ENTER};function G(y){return Object.values(Y).some(e=>e===y)}function ie(y){return Object.values(F).some(e=>e===y)}function $(y,e){const t=new Event("md-contains",{bubbles:!0,composed:!0});let i=[];const s=u=>{i=u.composedPath()};return e.addEventListener("md-contains",s),y.dispatchEvent(t),e.removeEventListener("md-contains",s),i.length>0}const L={NONE:"none",LIST_ROOT:"list-root",FIRST_ITEM:"first-item",LAST_ITEM:"last-item"};/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/const H={END_START:"end-start",END_END:"end-end",START_START:"start-start",START_END:"start-end"};class ne{constructor(e,t){this.host=e,this.getProperties=t,this.surfaceStylesInternal={display:"none"},this.lastValues={isOpen:!1},this.host.addController(this)}get surfaceStyles(){return this.surfaceStylesInternal}async position(){const{surfaceEl:e,anchorEl:t,anchorCorner:i,surfaceCorner:s,positioning:o,xOffset:u,yOffset:r,disableBlockFlip:a,disableInlineFlip:p,repositionStrategy:g}=this.getProperties(),I=i.toLowerCase().trim(),C=s.toLowerCase().trim();if(!e||!t)return;const E=window.innerWidth,T=window.innerHeight,c=document.createElement("div");c.style.opacity="0",c.style.position="fixed",c.style.display="block",c.style.inset="0",document.body.appendChild(c);const m=c.getBoundingClientRect();c.remove();const A=window.innerHeight-m.bottom,d=window.innerWidth-m.right;this.surfaceStylesInternal={display:"block",opacity:"0"},this.host.requestUpdate(),await this.host.updateComplete,e.popover&&e.isConnected&&e.showPopover();const v=e.getSurfacePositionClientRect?e.getSurfacePositionClientRect():e.getBoundingClientRect(),f=t.getSurfacePositionClientRect?t.getSurfacePositionClientRect():t.getBoundingClientRect(),[h,O]=C.split("-"),[S,_]=I.split("-"),N=getComputedStyle(e).direction==="ltr";let{blockInset:P,blockOutOfBoundsCorrection:x,surfaceBlockProperty:z}=this.calculateBlock({surfaceRect:v,anchorRect:f,anchorBlock:S,surfaceBlock:h,yOffset:r,positioning:o,windowInnerHeight:T,blockScrollbarHeight:A});if(x&&!a){const M=h==="start"?"end":"start",U=S==="start"?"end":"start",R=this.calculateBlock({surfaceRect:v,anchorRect:f,anchorBlock:U,surfaceBlock:M,yOffset:r,positioning:o,windowInnerHeight:T,blockScrollbarHeight:A});x>R.blockOutOfBoundsCorrection&&(P=R.blockInset,x=R.blockOutOfBoundsCorrection,z=R.surfaceBlockProperty)}let{inlineInset:B,inlineOutOfBoundsCorrection:D,surfaceInlineProperty:W}=this.calculateInline({surfaceRect:v,anchorRect:f,anchorInline:_,surfaceInline:O,xOffset:u,positioning:o,isLTR:N,windowInnerWidth:E,inlineScrollbarWidth:d});if(D&&!p){const M=O==="start"?"end":"start",U=_==="start"?"end":"start",R=this.calculateInline({surfaceRect:v,anchorRect:f,anchorInline:U,surfaceInline:M,xOffset:u,positioning:o,isLTR:N,windowInnerWidth:E,inlineScrollbarWidth:d});Math.abs(D)>Math.abs(R.inlineOutOfBoundsCorrection)&&(B=R.inlineInset,D=R.inlineOutOfBoundsCorrection,W=R.surfaceInlineProperty)}g==="move"&&(P=P-x,B=B-D),this.surfaceStylesInternal={display:"block",opacity:"1",[z]:`${P}px`,[W]:`${B}px`},g==="resize"&&(x&&(this.surfaceStylesInternal.height=`${v.height-x}px`),D&&(this.surfaceStylesInternal.width=`${v.width-D}px`)),this.host.requestUpdate()}calculateBlock(e){const{surfaceRect:t,anchorRect:i,anchorBlock:s,surfaceBlock:o,yOffset:u,positioning:r,windowInnerHeight:a,blockScrollbarHeight:p}=e,g=r==="fixed"||r==="document"?1:0,I=r==="document"?1:0,C=o==="start"?1:0,E=o==="end"?1:0,c=(s!==o?1:0)*i.height+u,m=C*i.top+E*(a-i.bottom-p),A=C*window.scrollY-E*window.scrollY,d=Math.abs(Math.min(0,a-m-c-t.height));return{blockInset:g*m+I*A+c,blockOutOfBoundsCorrection:d,surfaceBlockProperty:o==="start"?"inset-block-start":"inset-block-end"}}calculateInline(e){const{isLTR:t,surfaceInline:i,anchorInline:s,anchorRect:o,surfaceRect:u,xOffset:r,positioning:a,windowInnerWidth:p,inlineScrollbarWidth:g}=e,I=a==="fixed"||a==="document"?1:0,C=a==="document"?1:0,E=t?1:0,T=t?0:1,c=i==="start"?1:0,m=i==="end"?1:0,d=(s!==i?1:0)*o.width+r,v=c*o.left+m*(p-o.right-g),f=c*(p-o.right-g)+m*o.left,h=E*v+T*f,O=c*window.scrollX-m*window.scrollX,S=m*window.scrollX-c*window.scrollX,_=E*O+T*S,N=Math.abs(Math.min(0,p-h-d-u.width)),P=I*h+d+C*_;let x=i==="start"?"inset-inline-start":"inset-inline-end";return(a==="document"||a==="fixed")&&(i==="start"&&t||i==="end"&&!t?x="left":x="right"),{inlineInset:P,inlineOutOfBoundsCorrection:N,surfaceInlineProperty:x}}hostUpdate(){this.onUpdate()}hostUpdated(){this.onUpdate()}async onUpdate(){const e=this.getProperties();let t=!1;for(const[u,r]of Object.entries(e))if(t=t||r!==this.lastValues[u],t)break;const i=this.lastValues.isOpen!==e.isOpen,s=!!e.anchorEl,o=!!e.surfaceEl;t&&s&&o&&(this.lastValues.isOpen=e.isOpen,e.isOpen?(this.lastValues=e,await this.position(),e.onOpen()):i&&(await e.beforeClose(),this.close(),e.onClose()))}close(){this.surfaceStylesInternal={display:"none"},this.host.requestUpdate();const e=this.getProperties().surfaceEl;e!=null&&e.popover&&(e!=null&&e.isConnected)&&e.hidePopover()}}/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/const b={INDEX:0,ITEM:1,TEXT:2};class oe{constructor(e){this.getProperties=e,this.typeaheadRecords=[],this.typaheadBuffer="",this.cancelTypeaheadTimeout=0,this.isTypingAhead=!1,this.lastActiveRecord=null,this.onKeydown=t=>{this.isTypingAhead?this.typeahead(t):this.beginTypeahead(t)},this.endTypeahead=()=>{this.isTypingAhead=!1,this.typaheadBuffer="",this.typeaheadRecords=[]}}get items(){return this.getProperties().getItems()}get active(){return this.getProperties().active}beginTypeahead(e){this.active&&(e.code==="Space"||e.code==="Enter"||e.code.startsWith("Arrow")||e.code==="Escape"||(this.isTypingAhead=!0,this.typeaheadRecords=this.items.map((t,i)=>[i,t,t.typeaheadText.trim().toLowerCase()]),this.lastActiveRecord=this.typeaheadRecords.find(t=>t[b.ITEM].tabIndex===0)??null,this.lastActiveRecord&&(this.lastActiveRecord[b.ITEM].tabIndex=-1),this.typeahead(e)))}typeahead(e){if(e.defaultPrevented)return;if(clearTimeout(this.cancelTypeaheadTimeout),e.code==="Enter"||e.code.startsWith("Arrow")||e.code==="Escape"){this.endTypeahead(),this.lastActiveRecord&&(this.lastActiveRecord[b.ITEM].tabIndex=-1);return}e.code==="Space"&&e.preventDefault(),this.cancelTypeaheadTimeout=setTimeout(this.endTypeahead,this.getProperties().typeaheadBufferTime),this.typaheadBuffer+=e.key.toLowerCase();const t=this.lastActiveRecord?this.lastActiveRecord[b.INDEX]:-1,i=this.typeaheadRecords.length,s=a=>(a[b.INDEX]+i-t)%i,o=this.typeaheadRecords.filter(a=>!a[b.ITEM].disabled&&a[b.TEXT].startsWith(this.typaheadBuffer)).sort((a,p)=>s(a)-s(p));if(o.length===0){clearTimeout(this.cancelTypeaheadTimeout),this.lastActiveRecord&&(this.lastActiveRecord[b.ITEM].tabIndex=-1),this.endTypeahead();return}const u=this.typaheadBuffer.length===1;let r;this.lastActiveRecord===o[0]&&u?r=o[1]??o[0]:r=o[0],this.lastActiveRecord&&(this.lastActiveRecord[b.ITEM].tabIndex=-1),this.lastActiveRecord=r,r[b.ITEM].tabIndex=0,r[b.ITEM].focus()}}/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/const X=200,V=new Set([w.NavigableKeys.ArrowDown,w.NavigableKeys.ArrowUp,w.NavigableKeys.Home,w.NavigableKeys.End]),se=new Set([w.NavigableKeys.ArrowLeft,w.NavigableKeys.ArrowRight,...V]);function ae(y=document){var t;let e=y.activeElement;for(;e&&((t=e==null?void 0:e.shadowRoot)!=null&&t.activeElement);)e=e.shadowRoot.activeElement;return e}class l extends n.r{get openDirection(){return this.menuCorner.split("-")[0]==="start"?"DOWN":"UP"}get anchorElement(){return this.anchor?this.getRootNode().querySelector(`#${this.anchor}`):this.currentAnchorElement}set anchorElement(e){this.currentAnchorElement=e,this.requestUpdate("anchorElement")}constructor(){super(),this.anchor="",this.positioning="absolute",this.quick=!1,this.hasOverflow=!1,this.open=!1,this.xOffset=0,this.yOffset=0,this.noHorizontalFlip=!1,this.noVerticalFlip=!1,this.typeaheadDelay=X,this.anchorCorner=H.END_START,this.menuCorner=H.START_START,this.stayOpenOnOutsideClick=!1,this.stayOpenOnFocusout=!1,this.skipRestoreFocus=!1,this.defaultFocus=L.FIRST_ITEM,this.noNavigationWrap=!1,this.typeaheadActive=!0,this.isSubmenu=!1,this.pointerPath=[],this.isRepositioning=!1,this.openCloseAnimationSignal=k.createAnimationSignal(),this.listController=new w.ListController({isItem:e=>e.hasAttribute("md-menu-item"),getPossibleItems:()=>this.slotItems,isRtl:()=>getComputedStyle(this).direction==="rtl",deactivateItem:e=>{e.selected=!1,e.tabIndex=-1},activateItem:e=>{e.selected=!0,e.tabIndex=0},isNavigableKey:e=>{if(!this.isSubmenu)return se.has(e);const i=getComputedStyle(this).direction==="rtl"?w.NavigableKeys.ArrowLeft:w.NavigableKeys.ArrowRight;return e===i?!0:V.has(e)},wrapNavigation:()=>!this.noNavigationWrap}),this.lastFocusedElement=null,this.typeaheadController=new oe(()=>({getItems:()=>this.items,typeaheadBufferTime:this.typeaheadDelay,active:this.typeaheadActive})),this.currentAnchorElement=null,this.internals=this.attachInternals(),this.menuPositionController=new ne(this,()=>({anchorCorner:this.anchorCorner,surfaceCorner:this.menuCorner,surfaceEl:this.surfaceEl,anchorEl:this.anchorElement,positioning:this.positioning==="popover"?"document":this.positioning,isOpen:this.open,xOffset:this.xOffset,yOffset:this.yOffset,disableBlockFlip:this.noVerticalFlip,disableInlineFlip:this.noHorizontalFlip,onOpen:this.onOpened,beforeClose:this.beforeClose,onClose:this.onClosed,repositionStrategy:this.hasOverflow&&this.positioning!=="popover"?"move":"resize"})),this.onWindowResize=()=>{this.isRepositioning||this.positioning!=="document"&&this.positioning!=="fixed"&&this.positioning!=="popover"||(this.isRepositioning=!0,this.reposition(),this.isRepositioning=!1)},this.handleFocusout=async e=>{const t=this.anchorElement;if(this.stayOpenOnFocusout||!this.open||this.pointerPath.includes(t))return;if(e.relatedTarget){if($(e.relatedTarget,this)||this.pointerPath.length!==0&&$(e.relatedTarget,t))return}else if(this.pointerPath.includes(this))return;const i=this.skipRestoreFocus;this.skipRestoreFocus=!0,this.close(),await this.updateComplete,this.skipRestoreFocus=i},this.onOpened=async()=>{this.lastFocusedElement=ae();const e=this.items,t=w.getActiveItem(e);t&&this.defaultFocus!==L.NONE&&(t.item.tabIndex=-1);let i=!this.quick;switch(this.quick?this.dispatchEvent(new Event("opening")):i=!!await this.animateOpen(),this.defaultFocus){case L.FIRST_ITEM:const s=w.getFirstActivatableItem(e);s&&(s.tabIndex=0,s.focus(),await s.updateComplete);break;case L.LAST_ITEM:const o=w.getLastActivatableItem(e);o&&(o.tabIndex=0,o.focus(),await o.updateComplete);break;case L.LIST_ROOT:this.focus();break;default:case L.NONE:break}i||this.dispatchEvent(new Event("opened"))},this.beforeClose=async()=>{var e,t;this.open=!1,this.skipRestoreFocus||(t=(e=this.lastFocusedElement)==null?void 0:e.focus)==null||t.call(e),this.quick||await this.animateClose()},this.onClosed=()=>{this.quick&&(this.dispatchEvent(new Event("closing")),this.dispatchEvent(new Event("closed")))},this.onWindowPointerdown=e=>{this.pointerPath=e.composedPath()},this.onDocumentClick=e=>{if(!this.open)return;const t=e.composedPath();!this.stayOpenOnOutsideClick&&!t.includes(this)&&!t.includes(this.anchorElement)&&(this.open=!1)},this.internals.role="menu",this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keydown",this.captureKeydown,{capture:!0}),this.addEventListener("focusout",this.handleFocusout)}get items(){return this.listController.items}willUpdate(e){if(e.has("open")){if(this.open){this.removeAttribute("aria-hidden");return}this.setAttribute("aria-hidden","true")}}update(e){e.has("open")&&(this.open?this.setUpGlobalEventListeners():this.cleanUpGlobalEventListeners()),e.has("positioning")&&this.positioning==="popover"&&!this.showPopover&&(this.positioning="fixed"),super.update(e)}connectedCallback(){super.connectedCallback(),this.open&&this.setUpGlobalEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.cleanUpGlobalEventListeners()}getBoundingClientRect(){return this.surfaceEl?this.surfaceEl.getBoundingClientRect():super.getBoundingClientRect()}getClientRects(){return this.surfaceEl?this.surfaceEl.getClientRects():super.getClientRects()}render(){return this.renderSurface()}renderSurface(){return n.x`
|
|
<div
|
|
class="menu ${n.e$1(this.getSurfaceClasses())}"
|
|
style=${Z.o(this.menuPositionController.surfaceStyles)}
|
|
popover=${this.positioning==="popover"?"manual":n.E}>
|
|
${this.renderElevation()}
|
|
<div class="items">
|
|
<div class="item-padding"> ${this.renderMenuItems()} </div>
|
|
</div>
|
|
</div>
|
|
`}renderMenuItems(){return n.x`<slot
|
|
@close-menu=${this.onCloseMenu}
|
|
@deactivate-items=${this.onDeactivateItems}
|
|
@request-activation=${this.onRequestActivation}
|
|
@deactivate-typeahead=${this.handleDeactivateTypeahead}
|
|
@activate-typeahead=${this.handleActivateTypeahead}
|
|
@stay-open-on-focusout=${this.handleStayOpenOnFocusout}
|
|
@close-on-focusout=${this.handleCloseOnFocusout}
|
|
@slotchange=${this.listController.onSlotchange}></slot>`}renderElevation(){return n.x`<md-elevation part="elevation"></md-elevation>`}getSurfaceClasses(){return{open:this.open,fixed:this.positioning==="fixed","has-overflow":this.hasOverflow}}captureKeydown(e){e.target===this&&!e.defaultPrevented&&G(e.code)&&(e.preventDefault(),this.close()),this.typeaheadController.onKeydown(e)}async animateOpen(){const e=this.surfaceEl,t=this.slotEl;if(!e||!t)return!0;const i=this.openDirection;this.dispatchEvent(new Event("opening")),e.classList.toggle("animating",!0);const s=this.openCloseAnimationSignal.start(),o=e.offsetHeight,u=i==="UP",r=this.items,a=500,p=50,g=250,I=(a-g)/r.length,C=e.animate([{height:"0px"},{height:`${o}px`}],{duration:a,easing:k.EASING.EMPHASIZED}),E=t.animate([{transform:u?`translateY(-${o}px)`:""},{transform:""}],{duration:a,easing:k.EASING.EMPHASIZED}),T=e.animate([{opacity:0},{opacity:1}],p),c=[];for(let d=0;d<r.length;d++){const v=u?r.length-1-d:d,f=r[v],h=f.animate([{opacity:0},{opacity:1}],{duration:g,delay:I*d});f.classList.toggle("md-menu-hidden",!0),h.addEventListener("finish",()=>{f.classList.toggle("md-menu-hidden",!1)}),c.push([f,h])}let m=d=>{};const A=new Promise(d=>{m=d});return s.addEventListener("abort",()=>{C.cancel(),E.cancel(),T.cancel(),c.forEach(([d,v])=>{d.classList.toggle("md-menu-hidden",!1),v.cancel()}),m(!0)}),C.addEventListener("finish",()=>{e.classList.toggle("animating",!1),this.openCloseAnimationSignal.finish(),m(!1)}),await A}animateClose(){let e;const t=new Promise(h=>{e=h}),i=this.surfaceEl,s=this.slotEl;if(!i||!s)return e(!1),t;const u=this.openDirection==="UP";this.dispatchEvent(new Event("closing")),i.classList.toggle("animating",!0);const r=this.openCloseAnimationSignal.start(),a=i.offsetHeight,p=this.items,g=150,I=50,C=g-I,E=50,T=50,c=.35,m=(g-T-E)/p.length,A=i.animate([{height:`${a}px`},{height:`${a*c}px`}],{duration:g,easing:k.EASING.EMPHASIZED_ACCELERATE}),d=s.animate([{transform:""},{transform:u?`translateY(-${a*(1-c)}px)`:""}],{duration:g,easing:k.EASING.EMPHASIZED_ACCELERATE}),v=i.animate([{opacity:1},{opacity:0}],{duration:I,delay:C}),f=[];for(let h=0;h<p.length;h++){const O=u?h:p.length-1-h,S=p[O],_=S.animate([{opacity:1},{opacity:0}],{duration:E,delay:T+m*h});_.addEventListener("finish",()=>{S.classList.toggle("md-menu-hidden",!0)}),f.push([S,_])}return r.addEventListener("abort",()=>{A.cancel(),d.cancel(),v.cancel(),f.forEach(([h,O])=>{O.cancel(),h.classList.toggle("md-menu-hidden",!1)}),e(!1)}),A.addEventListener("finish",()=>{i.classList.toggle("animating",!1),f.forEach(([h])=>{h.classList.toggle("md-menu-hidden",!1)}),this.openCloseAnimationSignal.finish(),this.dispatchEvent(new Event("closed")),e(!0)}),t}handleKeydown(e){this.pointerPath=[],this.listController.handleKeydown(e)}setUpGlobalEventListeners(){document.addEventListener("click",this.onDocumentClick,{capture:!0}),window.addEventListener("pointerdown",this.onWindowPointerdown),document.addEventListener("resize",this.onWindowResize,{passive:!0}),window.addEventListener("resize",this.onWindowResize,{passive:!0})}cleanUpGlobalEventListeners(){document.removeEventListener("click",this.onDocumentClick,{capture:!0}),window.removeEventListener("pointerdown",this.onWindowPointerdown),document.removeEventListener("resize",this.onWindowResize),window.removeEventListener("resize",this.onWindowResize)}onCloseMenu(){this.close()}onDeactivateItems(e){e.stopPropagation(),this.listController.onDeactivateItems()}onRequestActivation(e){e.stopPropagation(),this.listController.onRequestActivation(e)}handleDeactivateTypeahead(e){e.stopPropagation(),this.typeaheadActive=!1}handleActivateTypeahead(e){e.stopPropagation(),this.typeaheadActive=!0}handleStayOpenOnFocusout(e){e.stopPropagation(),this.stayOpenOnFocusout=!0}handleCloseOnFocusout(e){e.stopPropagation(),this.stayOpenOnFocusout=!1}close(){this.open=!1,this.slotItems.forEach(t=>{var i;(i=t.close)==null||i.call(t)})}show(){this.open=!0}activateNextItem(){return this.listController.activateNextItem()??null}activatePreviousItem(){return this.listController.activatePreviousItem()??null}reposition(){this.open&&this.menuPositionController.position()}}n.__decorate([k.e$1(".menu")],l.prototype,"surfaceEl",void 0);n.__decorate([k.e$1("slot")],l.prototype,"slotEl",void 0);n.__decorate([n.n()],l.prototype,"anchor",void 0);n.__decorate([n.n()],l.prototype,"positioning",void 0);n.__decorate([n.n({type:Boolean})],l.prototype,"quick",void 0);n.__decorate([n.n({type:Boolean,attribute:"has-overflow"})],l.prototype,"hasOverflow",void 0);n.__decorate([n.n({type:Boolean,reflect:!0})],l.prototype,"open",void 0);n.__decorate([n.n({type:Number,attribute:"x-offset"})],l.prototype,"xOffset",void 0);n.__decorate([n.n({type:Number,attribute:"y-offset"})],l.prototype,"yOffset",void 0);n.__decorate([n.n({type:Boolean,attribute:"no-horizontal-flip"})],l.prototype,"noHorizontalFlip",void 0);n.__decorate([n.n({type:Boolean,attribute:"no-vertical-flip"})],l.prototype,"noVerticalFlip",void 0);n.__decorate([n.n({type:Number,attribute:"typeahead-delay"})],l.prototype,"typeaheadDelay",void 0);n.__decorate([n.n({attribute:"anchor-corner"})],l.prototype,"anchorCorner",void 0);n.__decorate([n.n({attribute:"menu-corner"})],l.prototype,"menuCorner",void 0);n.__decorate([n.n({type:Boolean,attribute:"stay-open-on-outside-click"})],l.prototype,"stayOpenOnOutsideClick",void 0);n.__decorate([n.n({type:Boolean,attribute:"stay-open-on-focusout"})],l.prototype,"stayOpenOnFocusout",void 0);n.__decorate([n.n({type:Boolean,attribute:"skip-restore-focus"})],l.prototype,"skipRestoreFocus",void 0);n.__decorate([n.n({attribute:"default-focus"})],l.prototype,"defaultFocus",void 0);n.__decorate([n.n({type:Boolean,attribute:"no-navigation-wrap"})],l.prototype,"noNavigationWrap",void 0);n.__decorate([j.o({flatten:!0})],l.prototype,"slotItems",void 0);n.__decorate([k.r()],l.prototype,"typeaheadActive",void 0);/**
|
|
* @license
|
|
* Copyright 2024 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/const re=n.i$1`:host{--md-elevation-level: var(--md-menu-container-elevation, 2);--md-elevation-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));min-width:112px;color:unset;display:contents}md-focus-ring{--md-focus-ring-shape: var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px))}.menu{border-radius:var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px));display:none;inset:auto;border:none;padding:0px;overflow:visible;background-color:rgba(0,0,0,0);color:inherit;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit;min-width:inherit;max-width:inherit;scrollbar-width:inherit}.menu::backdrop{display:none}.fixed{position:fixed}.items{display:block;list-style-type:none;margin:0;outline:none;box-sizing:border-box;background-color:var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));height:inherit;max-height:inherit;overflow:auto;min-width:inherit;max-width:inherit;border-radius:inherit;scrollbar-width:inherit}.item-padding{padding-block:8px}.has-overflow:not([popover]) .items{overflow:visible}.has-overflow.animating .items,.animating .items{overflow:hidden}.has-overflow.animating .items{pointer-events:none}.animating ::slotted(.md-menu-hidden){opacity:0}slot{display:block;height:inherit;max-height:inherit}::slotted(:is(md-divider,[role=separator])){margin:8px 0}@media(forced-colors: active){.menu{border-style:solid;border-color:CanvasText;border-width:1px}}
|
|
`;/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/exports.MdMenu=class extends l{};exports.MdMenu.styles=[re];exports.MdMenu=n.__decorate([n.t$1("md-menu")],exports.MdMenu);/**
|
|
* @license
|
|
* Copyright 2024 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/const le=n.i$1`:host{display:flex;--md-ripple-hover-color: var(--md-menu-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-menu-item-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-menu-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-opacity: var(--md-menu-item-pressed-state-layer-opacity, 0.12)}:host([disabled]){opacity:var(--md-menu-item-disabled-opacity, 0.3);pointer-events:none}md-focus-ring{z-index:1;--md-focus-ring-shape: 8px}a,button,li{background:none;border:none;padding:0;margin:0;text-align:unset;text-decoration:none}.list-item{border-radius:inherit;display:flex;flex:1;max-width:inherit;min-width:inherit;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.list-item:not(.disabled){cursor:pointer}[slot=container]{pointer-events:none}md-ripple{border-radius:inherit}md-item{border-radius:inherit;flex:1;color:var(--md-menu-item-label-text-color, var(--md-sys-color-on-surface, #1d1b20));font-family:var(--md-menu-item-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));line-height:var(--md-menu-item-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));font-weight:var(--md-menu-item-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));min-height:var(--md-menu-item-one-line-container-height, 56px);padding-top:var(--md-menu-item-top-space, 12px);padding-bottom:var(--md-menu-item-bottom-space, 12px);padding-inline-start:var(--md-menu-item-leading-space, 16px);padding-inline-end:var(--md-menu-item-trailing-space, 16px)}md-item[multiline]{min-height:var(--md-menu-item-two-line-container-height, 72px)}[slot=supporting-text]{color:var(--md-menu-item-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-supporting-text-font, var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-supporting-text-size, var(--md-sys-typescale-body-medium-size, 0.875rem));line-height:var(--md-menu-item-supporting-text-line-height, var(--md-sys-typescale-body-medium-line-height, 1.25rem));font-weight:var(--md-menu-item-supporting-text-weight, var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400)))}[slot=trailing-supporting-text]{color:var(--md-menu-item-trailing-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-trailing-supporting-text-font, var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-trailing-supporting-text-size, var(--md-sys-typescale-label-small-size, 0.6875rem));line-height:var(--md-menu-item-trailing-supporting-text-line-height, var(--md-sys-typescale-label-small-line-height, 1rem));font-weight:var(--md-menu-item-trailing-supporting-text-weight, var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500)))}:is([slot=start],[slot=end])::slotted(*){fill:currentColor}[slot=start]{color:var(--md-menu-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}[slot=end]{color:var(--md-menu-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}.list-item{background-color:var(--md-menu-item-container-color, transparent)}.list-item.selected{background-color:var(--md-menu-item-selected-container-color, var(--md-sys-color-secondary-container, #e8def8))}.selected:not(.disabled) ::slotted(*){color:var(--md-menu-item-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b))}@media(forced-colors: active){:host([disabled]),:host([disabled]) slot{color:GrayText;opacity:1}.list-item{position:relative}.list-item.selected::before{content:"";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}
|
|
`;/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/class ce{constructor(e,t){this.host=e,this.internalTypeaheadText=null,this.onClick=()=>{this.host.keepOpen||this.host.dispatchEvent(q(this.host,{kind:K.CLICK_SELECTION}))},this.onKeydown=i=>{if(this.host.href&&i.code==="Enter"){const o=this.getInteractiveElement();o instanceof HTMLAnchorElement&&o.click()}if(i.defaultPrevented)return;const s=i.code;this.host.keepOpen&&s!=="Escape"||G(s)&&(i.preventDefault(),this.host.dispatchEvent(q(this.host,{kind:K.KEYDOWN,key:s})))},this.getHeadlineElements=t.getHeadlineElements,this.getSupportingTextElements=t.getSupportingTextElements,this.getDefaultElements=t.getDefaultElements,this.getInteractiveElement=t.getInteractiveElement,this.host.addController(this)}get typeaheadText(){if(this.internalTypeaheadText!==null)return this.internalTypeaheadText;const e=this.getHeadlineElements(),t=[];return e.forEach(i=>{i.textContent&&i.textContent.trim()&&t.push(i.textContent.trim())}),t.length===0&&this.getDefaultElements().forEach(i=>{i.textContent&&i.textContent.trim()&&t.push(i.textContent.trim())}),t.length===0&&this.getSupportingTextElements().forEach(i=>{i.textContent&&i.textContent.trim()&&t.push(i.textContent.trim())}),t.join(" ")}get tagName(){switch(this.host.type){case"link":return"a";case"button":return"button";default:case"menuitem":case"option":return"li"}}get role(){return this.host.type==="option"?"option":"menuitem"}hostConnected(){this.host.toggleAttribute("md-menu-item",!0)}hostUpdate(){this.host.href&&(this.host.type="link")}setTypeaheadText(e){this.internalTypeaheadText=e}}exports.CloseReason=K;exports.Corner=H;exports.DEFAULT_TYPEAHEAD_BUFFER_TIME=X;exports.FocusState=L;exports.KeydownCloseKey=Y;exports.MenuItemController=ce;exports.NavigableKey=te;exports.SelectionKey=F;exports.TYPEAHEAD_RECORD=b;exports.createActivateTypeaheadEvent=ee;exports.createDeactivateTypeaheadEvent=J;exports.isElementInSubtree=$;exports.isSelectableKey=ie;exports.styles=le;
|