mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
feat(data-table): add nonExpandableRowIds prop #861
This commit is contained in:
parent
f64b021a94
commit
cab576c335
4 changed files with 64 additions and 38 deletions
|
@ -977,7 +977,7 @@ export interface DataTableCell {
|
|||
### Props
|
||||
|
||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------- | :--------------- | :------- | :------------------------------------------------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| :------------------ | :--------------- | :------- | :------------------------------------------------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| selectedRowIds | <code>let</code> | Yes | <code>DataTableRowId[]</code> | <code>[]</code> | Specify the row ids to be selected |
|
||||
| selectable | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` for the selectable variant<br />Automatically set to `true` if `radio` or `batchSelection` are `true` |
|
||||
| expandedRowIds | <code>let</code> | Yes | <code>DataTableRowId[]</code> | <code>[]</code> | Specify the row ids to be expanded |
|
||||
|
@ -990,6 +990,7 @@ export interface DataTableCell {
|
|||
| zebra | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use zebra styles |
|
||||
| sortable | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the sortable variant |
|
||||
| batchExpansion | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch expansion |
|
||||
| nonExpandableRowIds | <code>let</code> | No | <code>DataTableRowId[]</code> | <code>[]</code> | Specify the ids for rows that should not be expandable |
|
||||
| radio | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` for the radio selection variant |
|
||||
| batchSelection | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable batch selection |
|
||||
| stickyHeader | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable a sticky header |
|
||||
|
|
|
@ -2287,6 +2287,17 @@
|
|||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "nonExpandableRowIds",
|
||||
"kind": "let",
|
||||
"description": "Specify the ids for rows that should not be expandable",
|
||||
"type": "DataTableRowId[]",
|
||||
"value": "[]",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "radio",
|
||||
"kind": "let",
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
*/
|
||||
export let expandedRowIds = [];
|
||||
|
||||
/**
|
||||
* Specify the ids for rows that should not be expandable
|
||||
* @type {DataTableRowId[]}
|
||||
*/
|
||||
export let nonExpandableRowIds = [];
|
||||
|
||||
/** Set to `true` for the radio selection variant */
|
||||
export let radio = false;
|
||||
|
||||
|
@ -343,6 +349,7 @@
|
|||
? 'collapsed'
|
||||
: undefined}"
|
||||
>
|
||||
{#if !nonExpandableRowIds.includes(row.id)}
|
||||
<button
|
||||
type="button"
|
||||
class:bx--table-expand__button="{true}"
|
||||
|
@ -364,6 +371,7 @@
|
|||
>
|
||||
<ChevronRight16 class="bx--table-expand__svg" />
|
||||
</button>
|
||||
{/if}
|
||||
</TableCell>
|
||||
{/if}
|
||||
{#if selectable}
|
||||
|
@ -418,7 +426,7 @@
|
|||
{/each}
|
||||
</TableRow>
|
||||
|
||||
{#if expandable && expandedRows[row.id]}
|
||||
{#if expandable && expandedRows[row.id] && !nonExpandableRowIds.includes(row.id)}
|
||||
<tr
|
||||
data-child-row
|
||||
class:bx--expandable-row="{true}"
|
||||
|
|
6
types/DataTable/DataTable.svelte.d.ts
vendored
6
types/DataTable/DataTable.svelte.d.ts
vendored
|
@ -99,6 +99,12 @@ export interface DataTableProps
|
|||
*/
|
||||
expandedRowIds?: DataTableRowId[];
|
||||
|
||||
/**
|
||||
* Specify the ids for rows that should not be expandable
|
||||
* @default []
|
||||
*/
|
||||
nonExpandableRowIds?: DataTableRowId[];
|
||||
|
||||
/**
|
||||
* Set to `true` for the radio selection variant
|
||||
* @default false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue