/** * Loading States Component * Provides loading spinners and skeleton screens */ export class Loading { /** * Show loading spinner in container */ static show(containerId, message = 'Loading...') { const container = document.getElementById(containerId); if (!container) { console.warn(`[Loading] Container not found: ${containerId}`); return; } const spinner = document.createElement('div'); spinner.className = 'loading-container'; spinner.innerHTML = `

${message}

`; container.innerHTML = ''; container.appendChild(spinner); } /** * Hide loading spinner */ static hide(containerId) { const container = document.getElementById(containerId); if (!container) return; const spinner = container.querySelector('.loading-container'); if (spinner) { spinner.remove(); } } /** * Generate skeleton rows for tables */ static skeletonRows(count = 5, columns = 5) { let html = ''; for (let i = 0; i < count; i++) { html += ''; for (let j = 0; j < columns; j++) { html += '
'; } html += ''; } return html; } /** * Generate skeleton cards */ static skeletonCards(count = 4) { let html = ''; for (let i = 0; i < count; i++) { html += `
`; } return html; } /** * Add skeleton class to elements */ static addSkeleton(selector) { document.querySelectorAll(selector).forEach(el => { el.classList.add('skeleton'); }); } /** * Remove skeleton class */ static removeSkeleton(selector) { document.querySelectorAll(selector).forEach(el => { el.classList.remove('skeleton'); }); } } export default Loading;