// Tag Item Component class TagItem extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.render(); this.setupEventListeners(); } static get observedAttributes() { return ['tag-id', 'tag-name', 'tag-color']; } attributeChangedCallback() { this.render(); } render() { const tagName = this.getAttribute('tag-name') || ''; const tagColor = this.getAttribute('tag-color') || '#f97316'; const tagId = this.getAttribute('tag-id') || ''; this.shadowRoot.innerHTML = `
${tagName}
`; // Replace feather icon const iconEl = this.shadowRoot.querySelector('i[data-feather]'); if (iconEl) { iconEl.outerHTML = feather.icons.x.toSvg({ width: 14, height: 14 }); } } setupEventListeners() { this.shadowRoot.addEventListener('click', (e) => { const deleteBtn = e.target.closest('.delete-btn'); if (deleteBtn) { e.stopPropagation(); this.handleDelete(e); } }); } handleDelete(e) { if (confirm('Tag wirklich löschen?')) { this.dispatchEvent(new CustomEvent('delete', { bubbles: true, detail: { tagId: this.getAttribute('tag-id') } })); } } } customElements.define('tag-item', TagItem);