mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
parent
47866b1d51
commit
5c48fe76d1
1 changed files with 34 additions and 23 deletions
|
@ -94,6 +94,12 @@
|
|||
*/
|
||||
export let selectedRowIds = [];
|
||||
|
||||
/**
|
||||
* Specify the ids of rows that should not be selectable
|
||||
* @type {DataTableRowId[]}
|
||||
*/
|
||||
export let nonSelectableRowIds = [];
|
||||
|
||||
/** Set to `true` to enable a sticky header */
|
||||
export let stickyHeader = false;
|
||||
|
||||
|
@ -171,6 +177,9 @@
|
|||
$: expandableRowIds = rows
|
||||
.map((row) => row.id)
|
||||
.filter((id) => !nonExpandableRowIds.includes(id));
|
||||
$: selectableRowIds = rows
|
||||
.map((row) => row.id)
|
||||
.filter((id) => !nonSelectableRowIds.includes(id));
|
||||
$: indeterminate =
|
||||
selectedRowIds.length > 0 && selectedRowIds.length < rows.length;
|
||||
$: if (batchExpansion) {
|
||||
|
@ -293,7 +302,7 @@
|
|||
}
|
||||
|
||||
if (e.target.checked) {
|
||||
selectedRowIds = rows.map((row) => row.id);
|
||||
selectedRowIds = selectableRowIds;
|
||||
} else {
|
||||
selectedRowIds = [];
|
||||
}
|
||||
|
@ -405,6 +414,7 @@
|
|||
class:bx--table-column-checkbox="{true}"
|
||||
class:bx--table-column-radio="{radio}"
|
||||
>
|
||||
{#if !nonSelectableRowIds.includes(row.id)}
|
||||
{#if radio}
|
||||
<RadioButton
|
||||
name="select-row-{row.id}"
|
||||
|
@ -428,6 +438,7 @@
|
|||
}}"
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{#each row.cells as cell, j (cell.key)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue