1import{c as s,d as i,e as o}from"./app-CcjeUuLl.js";import{c as n}from"./focus-trap.esm-D053jUyE.js";import{c as e}from"./customEvents-5NGEJRS1.js";const h=s("Modal",{toggle(t){t.preventDefault(),t.stopPropagation(),this._data.isActive?this.close(t):this.open(t)},close(t){t?.preventDefault(),t?.stopPropagation(),this._data.isActive&&(this.$node.removeAttribute("data-active"),this._data.focusTrap.deactivate(),this._data.isActive=!1,setTimeout(()=>{this.$scroller&&o(this.$scroller)},200),this.$node.dispatchEvent(new CustomEvent(e.MODAL_NODE_CLOSED)),document.dispatchEvent(new CustomEvent(e.MODAL_CLOSED)),this.disposeOpenEvents())},openFromOutside(t){t.detail?.modalId===this.$modalId&&!this._data.isActive&&(t.preventDefault(),t.stopPropagation(),this.open())},open(){document.dispatchEvent(new CustomEvent(e.MODAL_CLOSE_ALL)),document.dispatchEvent(new CustomEvent(e.MODAL_OPENED)),this.$node.dispatchEvent(new CustomEvent(e.MODAL_NODE_OPENED)),i(this.$scroller,{reserveScrollBarGap:!0}),this.$node.setAttribute("data-init","true"),this.$node.setAttribute("data-active","true"),this._data.isActive=!0,this.registerOpenEvents(),this._data.focusTrap.activate()},handleEsc(t){t.key==="Escape"&&this.close()},handleClickOutside(t){this._data.isActive&&!this.$focusTrap.contains(t.target)&&this.close(t)},registerOpenEvents(){this.$clickOutside&&(document.addEventListener("click",this.handleClickOutside,!1),this.$node.addEventListener("click",this.handleClickOutside,!1))},disposeOpenEvents(){this.$clickOutside&&(this.$focusTrap.removeEventListener("click",this.handleCloseInside,!1),document.removeEventListener("click",this.handleClickOutside,!1),this.$node.removeEventListener("click",this.handleClickOutside,!1))}},{init(){this.$focusTrap=this.getChild("focus-trap"),this.$scroller=this.getChild("scroller")?this.getChild("scroller"):this.$focusTrap,this.$closeButtons=this.getChildren("close-trigger"),this.$initialFocus=this.getChild("initial-focus"),this.$clickOutside=this.options.panel||this.options.clickoutside,this.$initialFocus||console.warn("No initial focus element found. Add a `h1` with the attribute `data-Modal-initial-focus`. The `h1` should also have an id that matches the modal id with `_title` appended"),this._data.focusTrap=n(this.$focusTrap,{initialFocus:this.$initialFocus,fallbackFocus:this.$node,clickOutsideDeactivates:this.$clickOutside}),this._data.isActive=!1,this.$closeButtons&&this.$closeButtons.forEach(t=>{t.addEventListener("click",this.close,!1)}),this.$node.addEventListener(e.MODAL_NODE_OPEN,this.open,!1),this.$node.addEventListener(e.MODAL_NODE_TOGGLE,this.toggle,!1),this.$node.addEventListener(e.MODAL_NODE_CLOSE,this.close,!1),document.addEventListener(e.MODAL_OPEN_BY_ID,this.openFromOutside,!1),document.addEventListener(e.MODAL_CLOSE_ALL,this.close,!1),document.addEventListener("keyup",this.handleEsc,!1),this.$modalId=this.$node.getAttribute("id"),this.$triggers=document.querySelectorAll(`[data-modal-target="#${this.$modalId}"]`),this.$triggers?.forEach(t=>{t.addEventListener("click",this.toggle)}),this.options.open&&this.open()},destroy(){this.close(),this.$closeButtons&&this.$closeButtons.forEach(t=>{t.removeEventListener("click",this.close)}),this.$node.removeEventListener(e.MODAL_NODE_OPEN,this.open),this.$node.removeEventListener(e.MODAL_NODE_TOGGLE,this.toggle),this.$node.removeEventListener(e.MODAL_NODE_CLOSE,this.close),this.$node.removeEventListener("click",this.handleClickOutside),document.removeEventListener(e.MODAL_OPEN_BY_ID,this.openFromOutside),document.removeEventListener(e.MODAL_CLOSE_ALL,this.close),document.removeEventListener("keyup",this.handleEsc),this.$triggers?.forEach(t=>{t.removeEventListener("click",this.toggle)}),this.disposeOpenEvents()}});
1export{h as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.