/** * ErrorModal Web Component * A reusable error modal component without shadow DOM for Tailwind compatibility */ class ErrorModal extends HTMLElement { constructor() { super(); // No shadow DOM - use regular DOM for Tailwind styling this.innerHTML = `
`; this.modal = this.querySelector('#error-modal'); this.errorContent = this.querySelector('.error-content'); this.closeButtons = this.querySelectorAll('.close-btn'); this.setupEventListeners(); } setupEventListeners() { // Close button clicks this.closeButtons.forEach(btn => { btn.addEventListener('click', () => this.close()); }); // Close on ESC key document.addEventListener('keydown', (event) => { if (event.key === 'Escape' && !this.modal.classList.contains('hidden')) { this.close(); } }); // Close when clicking outside modal this.modal.addEventListener('click', (event) => { if (event.target === this.modal) { this.close(); } }); } show(content) { this.errorContent.innerHTML = content; this.modal.classList.remove('hidden'); } close() { this.modal.classList.add('hidden'); } // Global helper functions for backward compatibility connectedCallback() { // Make functions globally available window.showErrorModal = (content) => this.show(content); window.closeErrorModal = () => this.close(); } } // Define the custom element customElements.define('error-modal', ErrorModal); export { ErrorModal };