import{r as t,h as s,e as i,c as a}from"./p-5da71329.js";import{c as e}from"./p-8099c3d0.js";const o=".sc-stencila-menu-default-h,stencila-menu.sc-stencila-menu-default{display:inline-block;position:relative}.sc-stencila-menu-default-h ul.sc-stencila-menu-default,stencila-menu.sc-stencila-menu-default ul.sc-stencila-menu-default{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);background-color:#fff;background-color:var(--color-stock,#fff);border:1px solid #cfd2e1;border-color:var(--color-neutral-100,#cfd2e1);border-radius:.25rem;-webkit-box-shadow:0 0 #0000,0 0 #0000,var(--tw-shadow);box-shadow:0 0 #0000,0 0 #0000,var(--tw-shadow);-webkit-box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);display:inline-block;left:100%;margin:0;min-width:112px;padding:0;position:absolute;top:0;z-index:30}.sc-stencila-menu-default-h ul[aria-hidden].sc-stencila-menu-default,stencila-menu.sc-stencila-menu-default ul[aria-hidden].sc-stencila-menu-default{display:none}.sc-stencila-menu-default-h ul.sc-stencila-menu-default-s>:not(:last-child),stencila-menu ul.sc-stencila-menu-default-s>:not(:last-child){border:0 solid #cfd2e1;border-color:var(--color-neutral-100,#cfd2e1);border-bottom:1px solid var(--color-neutral-100,#cfd2e1)}";const r=".sc-stencila-menu-material-h ul.sc-stencila-menu-material{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);background-color:#fff;background-color:var(--color-stock,#fff);border:1px solid #cfd2e1;border-color:var(--color-neutral-100,#cfd2e1);border-radius:.25rem;-webkit-box-shadow:0 0 #0000,0 0 #0000,var(--tw-shadow);box-shadow:0 0 #0000,0 0 #0000,var(--tw-shadow);-webkit-box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);display:inline-block;margin:0;min-width:112px;padding:0;position:absolute;z-index:30}.sc-stencila-menu-material-h ul[aria-hidden].sc-stencila-menu-material{display:none}";let l=0;let n=class{constructor(s){t(this,s);this.popperRef=null;this.isOpen=false;this.autoClose=true;this.autoOpen=false;this.menuPosition="right-start";this.initMenu=()=>{if(this.menuEl){this.popperRef=e(this.el,this.menuEl,{placement:this.menuPosition,strategy:"fixed",modifiers:[{name:"preventOverflow"}]})}};this.computeMenuLocation=()=>{this.popperRef?this.popperRef.update():this.initMenu()};this.toggleMenu=t=>{t.preventDefault();if(this.autoClose){t.stopPropagation()}this.isOpen?this.isOpen=false:this.openMenu()};this.openMenu=()=>{this.computeMenuLocation();this.isOpen=true};this.closeMenu=()=>{if(this.autoClose){this.isOpen=false}};this.closeOnBlur=t=>{if(this.isOpen&&!this.el.contains(t.relatedTarget)){this.autoCloseTimeoutRef=window.setTimeout(this.closeMenu,250)}};this.clearTimeout=()=>{window.clearTimeout(this.autoCloseTimeoutRef)};this.menuId=`stencila-menu-${l++}`}componentWillLoad(){if(this.autoClose){this.el.addEventListener("mouseout",this.closeOnBlur);this.el.addEventListener("mouseenter",this.clearTimeout)}if(this.autoOpen){this.el.addEventListener("mouseenter",this.openMenu);this.el.addEventListener("focus",this.openMenu)}}disconnectedCallback(){this.el.removeEventListener("mouseout",this.closeOnBlur);this.el.removeEventListener("mouseenter",this.clearTimeout);this.el.removeEventListener("mouseenter",this.openMenu);this.el.removeEventListener("focus",this.openMenu);if(this.popperRef){this.popperRef.destroy();this.popperRef=null}}render(){return s(i,null,s("span",{onClick:this.toggleMenu,"aria-controls":this.menuId,"aria-expanded":this.isOpen?"true":"false"},s("slot",{name:"toggle"})),s("ul",{role:"menu","aria-hidden":!this.isOpen,"aria-orientation":"vertical",tabindex:"-1",id:this.menuId,onClick:this.closeMenu,ref:t=>this.menuEl=t},s("slot",null)))}get el(){return a(this)}};n.style={default:o,material:r};export{n as stencila_menu};
//# sourceMappingURL=p-7dd49a54.entry.js.map