blob: 98bba021a0b76d1c65d9248540da883b19c51b90 [file] [log] [blame]
{
"version": 3,
"sources": ["modal.ts"],
"sourcesContent": ["/**\n * @license\n * Copyright 2021 The Go Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n/**\n * ModalController registers a dialog element with the polyfill if\n * necessary for the current browser, add adds event listeners to\n * close and open modals.\n */\nexport class ModalController {\n constructor(private el: HTMLDialogElement) {\n // Only load the dialog polyfill if necessary for the environment.\n if (!window.HTMLDialogElement && !el.showModal) {\n import('../../../third_party/dialog-polyfill/dialog-polyfill.esm.js').then(\n ({ default: polyfill }) => {\n polyfill.registerDialog(el);\n }\n );\n }\n const id = el.id;\n const button = document.querySelector<HTMLButtonElement>(`[aria-controls=\"${id}\"]`);\n if (button) {\n button.addEventListener('click', () => {\n if (this.el.showModal) {\n this.el.showModal();\n } else {\n this.el.open = true;\n }\n el.querySelector('input')?.focus();\n });\n }\n for (const close of this.el.querySelectorAll<HTMLButtonElement>('[data-modal-close]')) {\n close.addEventListener('click', () => {\n if (this.el.close) {\n this.el.close();\n } else {\n this.el.open = false;\n }\n });\n }\n }\n}\n"],
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAYO,4BAAsB,CAC3B,YAAoB,EAAuB,CAAvB,UAElB,AAAI,CAAC,OAAO,mBAAqB,CAAC,EAAG,WACnC,AAAO,sEAA+D,KACpE,CAAC,CAAE,QAAS,KAAe,CACzB,EAAS,eAAe,KAI9B,KAAM,GAAK,EAAG,GACR,EAAS,SAAS,cAAiC,mBAAmB,OAC5E,AAAI,GACF,EAAO,iBAAiB,QAAS,IAAM,CACrC,AAAI,KAAK,GAAG,UACV,KAAK,GAAG,YAER,KAAK,GAAG,KAAO,GAEjB,EAAG,cAAc,UAAU,UAG/B,SAAW,KAAS,MAAK,GAAG,iBAAoC,sBAC9D,EAAM,iBAAiB,QAAS,IAAM,CACpC,AAAI,KAAK,GAAG,MACV,KAAK,GAAG,QAER,KAAK,GAAG,KAAO",
"names": []
}