export const ONCE = { once: true }; export class Dialog { protected dialog: HTMLDialogElement; constructor(dialog: HTMLDialogElement) { this.dialog = dialog; } /** * A function that should only be called once that has permanent effects on the DOM */ protected initializeDOM() { } open() { this.dialog.showModal(); } close() { this.dialog.close(); } }; export class FormDialog extends Dialog { protected form: HTMLFormElement; constructor(dialog: HTMLDialogElement, form: HTMLFormElement) { super(dialog); this.form = form; } protected override initializeDOM() { super.initializeDOM(); this.dialog.addEventListener("close", e => this.reset()); } reset() { this.form.reset(); } }