${this.announcement}
${!this.hideIcon ? html`
`
: ''}
${!this.loading ? html`
${this.content ? html`${this.content}` : ''}
` : html`
Loading...`}
${this.cancelText}
${this.confirmText}
${this.footerText}
`;
}
submitDialog() {
// get the form from the slot
let form = this.querySelector('form');
if (!form && this.action) {
form = document.createElement('form') as HTMLFormElement;
form.action = this.action;
form.method = 'POST';
// copy data-attributes from the confirm element to the form
Array.from(this.attributes).forEach(attr => {
if (attr.name.startsWith('data-')) {
form?.setAttribute(attr.name, attr.value);
}
});
this.querySelectorAll('input').forEach((el: HTMLInputElement) => {
form?.appendChild(el.cloneNode() as Node);
})
this.appendChild(form);
}
if (form && form.reportValidity()) {
document.dispatchEvent(new CustomEvent('zn-register-element', {
detail: {element: form}
}))
form.requestSubmit();
if (!this.showLoading) {
this.hide();
} else {
this.loading = true;
this.dialog.closer.disabled = true;
}
}
}
}