mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
parent
1545da8f9f
commit
0a6b8fc112
2 changed files with 14 additions and 10 deletions
|
@ -195,14 +195,18 @@
|
|||
$: if (radio || batchSelection) selectable = true;
|
||||
$: tableSortable.set(sortable);
|
||||
$: headerKeys = headers.map(({ key }) => key);
|
||||
$: $tableRows = rows.map((row) => ({
|
||||
...row,
|
||||
cells: headerKeys.map((key, index) => ({
|
||||
key,
|
||||
value: resolvePath(row, key),
|
||||
display: headers[index].display,
|
||||
})),
|
||||
}));
|
||||
$: tableCellsByRowId = rows.reduce(
|
||||
(rows, row) => ({
|
||||
...rows,
|
||||
[row.id]: headerKeys.map((key, index) => ({
|
||||
key,
|
||||
value: resolvePath(row, key),
|
||||
display: headers[index].display,
|
||||
})),
|
||||
}),
|
||||
{}
|
||||
);
|
||||
$: $tableRows = rows;
|
||||
$: sortedRows = [...$tableRows];
|
||||
$: ascending = $sortHeader.sortDirection === "ascending";
|
||||
$: sortKey = $sortHeader.key;
|
||||
|
@ -464,7 +468,7 @@
|
|||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{#each row.cells as cell, j (cell.key)}
|
||||
{#each tableCellsByRowId[row.id] as cell, j (cell.key)}
|
||||
{#if headers[j].empty}
|
||||
<td class:bx--table-column-menu="{headers[j].columnMenu}">
|
||||
<slot
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
if (shouldFilterRows === true) {
|
||||
rows = rows.filter((row) => {
|
||||
return Object.entries(row)
|
||||
.filter(([key]) => !["cells", "id"].includes(key))
|
||||
.filter(([key]) => key !== "id")
|
||||
.some(([key, _value]) => {
|
||||
if (typeof _value === "string" || typeof _value === "number") {
|
||||
return (_value + "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue