feat(data-table): dispatch row mouseenter, mouseleave events

Add a row id for easier querying.
Add missing selected row class.
This commit is contained in:
Eric Liu 2020-10-24 13:58:49 -07:00
commit 73036aea4a

View file

@ -268,11 +268,18 @@
<TableBody> <TableBody>
{#each sorting ? sortedRows : rows as row, i (row.id)} {#each sorting ? sortedRows : rows as row, i (row.id)}
<TableRow <TableRow
class="{expandedRows[row.id] ? 'bx--expandable-row' : ''} {expandable ? 'bx--parent-row' : ''} {expandable && parentRowId === row.id ? 'bx--expandable-row--hover' : ''}" id="row-{row.id}"
class="{selectedRowIds.includes(row.id) ? 'bx--data-table--selected' : ''} {expandedRows[row.id] ? 'bx--expandable-row' : ''} {expandable ? 'bx--parent-row' : ''} {expandable && parentRowId === row.id ? 'bx--expandable-row--hover' : ''}"
on:click="{() => { on:click="{() => {
dispatch('click', { row }); dispatch('click', { row });
dispatch('click:row', row); dispatch('click:row', row);
}}" }}"
on:mouseenter="{() => {
dispatch('mouseenter:row', row);
}}"
on:mouseleave="{() => {
dispatch('mouseleave:row', row);
}}"
> >
{#if expandable} {#if expandable}
<TableCell <TableCell