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