{#each headers as header, i (header.key)} { dispatch('click', { header }); dispatch('click:header', header); let active = header.key === $sortHeader.key; let currentSortDirection = active ? $sortHeader.sortDirection : 'none'; let sortDirection = sortDirectionMap[currentSortDirection]; sortHeader.set({ id: sortDirection === 'none' ? null : $thKeys[header.key], key: header.key, sortDirection }); }}> {header.value} {/each} {#each sorting ? sortedRows : rows as row, i (row.id)} { dispatch('click', { row }); dispatch('click:row', row); }}> {#each row.cells as cell, j (cell.key)} { dispatch('click', { row, cell }); dispatch('click:cell', cell); }}> {cell.value} {/each} {/each}