{"version":3,"file":"dynamicModal-077fee0d.js","sources":["../../../../../../src/scripts/modules/dynamicModal.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\nclass HtmlTemplateModals extends Component {\n setupDefaults(): void {\n this.dom = {\n closeBtn: this.el.querySelector('.modal-close a'),\n modalContainer: this.el.querySelector('.modal-container'),\n modalContentBox: this.el.querySelector('.modal-content-box'),\n modalContents: this.el.querySelectorAll('div[id]')\n };\n\n (this.dom.modalContents as NodeListOf).forEach(content => {\n content.hidden = true;\n });\n }\n\n addListeners(): void {\n document.body.querySelectorAll('a.launch-modal').forEach(trigger => {\n trigger.addEventListener('click', this.handleClickModal.bind(this));\n });\n\n (this.dom.closeBtn as HTMLElement)?.addEventListener('click', this.handleCloseModal.bind(this));\n }\n\n handleCloseModal() {\n console.log('close');\n const body = document.querySelector('body') as HTMLElement;\n body.style.removeProperty('overflow');\n (this.dom.modalContentBox as HTMLElement).innerHTML = '';\n (this.el as HTMLDialogElement).close();\n }\n\n handleClickModal(e: Event) {\n const body = document.querySelector('body') as HTMLElement;\n body.style.overflow = 'hidden';\n const modalTrigger = e.currentTarget as HTMLElement;\n const modalData = modalTrigger.dataset.target;\n if (!modalData) return;\n const modal = this.el.querySelector(modalData);\n if (!modal) return;\n const modalCopy = modal.cloneNode(true) as HTMLElement;\n modalCopy.hidden = false;\n (this.dom.modalContentBox as HTMLElement)?.appendChild(modalCopy);\n (this.el as HTMLDialogElement).showModal();\n e.preventDefault();\n }\n}\n\nexport default HtmlTemplateModals;\n"],"names":["HtmlTemplateModals","Component","content","trigger","_a","body","modalData","modal","modalCopy"],"mappings":"oCAEA,MAAMA,UAA2BC,CAAU,CACzC,eAAsB,CACpB,KAAK,IAAM,CACT,SAAU,KAAK,GAAG,cAA2B,gBAAgB,EAC7D,eAAgB,KAAK,GAAG,cAA2B,kBAAkB,EACrE,gBAAiB,KAAK,GAAG,cAA2B,oBAAoB,EACxE,cAAe,KAAK,GAAG,iBAAiB,SAAS,CAAA,EAGlD,KAAK,IAAI,cAA0C,QAAmBC,GAAA,CACrEA,EAAQ,OAAS,EAAA,CAClB,CACH,CAEA,cAAqB,OACnB,SAAS,KAAK,iBAAiB,gBAAgB,EAAE,QAAmBC,GAAA,CAClEA,EAAQ,iBAAiB,QAAS,KAAK,iBAAiB,KAAK,IAAI,CAAC,CAAA,CACnE,GAEAC,EAAA,KAAK,IAAI,WAAT,MAAAA,EAAmC,iBAAiB,QAAS,KAAK,iBAAiB,KAAK,IAAI,EAC/F,CAEA,kBAAmB,CACjB,QAAQ,IAAI,OAAO,EACN,SAAS,cAAc,MAAM,EACrC,MAAM,eAAe,UAAU,EACnC,KAAK,IAAI,gBAAgC,UAAY,GACrD,KAAK,GAAyB,OACjC,CAEA,iBAAiB,EAAU,OACnB,MAAAC,EAAO,SAAS,cAAc,MAAM,EAC1CA,EAAK,MAAM,SAAW,SAEhB,MAAAC,EADe,EAAE,cACQ,QAAQ,OACvC,GAAI,CAACA,EAAW,OAChB,MAAMC,EAAQ,KAAK,GAAG,cAAcD,CAAS,EAC7C,GAAI,CAACC,EAAO,OACN,MAAAC,EAAYD,EAAM,UAAU,EAAI,EACtCC,EAAU,OAAS,IAClBJ,EAAA,KAAK,IAAI,kBAAT,MAAAA,EAA0C,YAAYI,GACtD,KAAK,GAAyB,YAC/B,EAAE,eAAe,CACnB,CACF"}