class ConfirmationDialog extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.render();
}
render() {
this.shadowRoot.innerHTML = `
`;
this.confirmationDialog = this.shadowRoot.getElementById('confirmationDialog');
this.overlay = this.shadowRoot.getElementById('overlay');
this.confirmButton = this.shadowRoot.getElementById('confirmButton');
this.cancelButton = this.shadowRoot.getElementById('cancelButton');
this.confirmationMessageElement = this.shadowRoot.getElementById('confirmationMessage');
this.cancelButton.onclick = () => this.hide();
this.overlay.onclick = () => this.hide();
}
showDialog(message, onConfirm) {
this.confirmationMessageElement.textContent = message;
this.confirmationDialog.style.display = 'block';
this.overlay.style.display = 'block';
this.confirmButton.onclick = () => {
onConfirm();
this.hide();
};
}
hide() {
this.confirmationDialog.style.display = 'none';
this.overlay.style.display = 'none';
}
}
customElements.define('confirmation-dialog', ConfirmationDialog);