mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
fix(data-table): require "id" in DataTableRow interface
This commit is contained in:
parent
a450b83bd8
commit
28f2d8190f
5 changed files with 13 additions and 5 deletions
|
@ -779,7 +779,10 @@ export interface DataTableNonEmptyHeader {
|
||||||
|
|
||||||
export type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader;
|
export type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader;
|
||||||
|
|
||||||
export type DataTableRow = Record<DataTableKey, DataTableValue>;
|
export interface DataTableRow {
|
||||||
|
id: any;
|
||||||
|
[key: string]: DataTableValue;
|
||||||
|
}
|
||||||
|
|
||||||
export type DataTableRowId = string;
|
export type DataTableRowId = string;
|
||||||
|
|
||||||
|
|
|
@ -2655,9 +2655,9 @@
|
||||||
"ts": "type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader"
|
"ts": "type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Record<DataTableKey, DataTableValue>",
|
"type": "{ id: any; [key: string]: DataTableValue; }",
|
||||||
"name": "DataTableRow",
|
"name": "DataTableRow",
|
||||||
"ts": "type DataTableRow = Record<DataTableKey, DataTableValue>"
|
"ts": "interface DataTableRow { id: any; [key: string]: DataTableValue; }"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -10,6 +10,8 @@ components: ["DataTable", "Toolbar", "ToolbarContent", "ToolbarSearch", "Toolbar
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
|
The `DataTable` is keyed for both rendering and sorting. You must define a "key" value per object in the `headers` property and an "id" value in `rows`.
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
headers="{[
|
headers="{[
|
||||||
{ key: "name", value: "Name" },
|
{ key: "name", value: "Name" },
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @typedef {{ key: DataTableKey; empty: boolean; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }} DataTableEmptyHeader
|
* @typedef {{ key: DataTableKey; empty: boolean; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }} DataTableEmptyHeader
|
||||||
* @typedef {{ key: DataTableKey; value: DataTableValue; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }} DataTableNonEmptyHeader
|
* @typedef {{ key: DataTableKey; value: DataTableValue; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }} DataTableNonEmptyHeader
|
||||||
* @typedef {DataTableNonEmptyHeader | DataTableEmptyHeader} DataTableHeader
|
* @typedef {DataTableNonEmptyHeader | DataTableEmptyHeader} DataTableHeader
|
||||||
* @typedef {Record<DataTableKey, DataTableValue>} DataTableRow
|
* @typedef {{ id: any; [key: string]: DataTableValue; }} DataTableRow
|
||||||
* @typedef {string} DataTableRowId
|
* @typedef {string} DataTableRowId
|
||||||
* @typedef {{ key: DataTableKey; value: DataTableValue; }} DataTableCell
|
* @typedef {{ key: DataTableKey; value: DataTableValue; }} DataTableCell
|
||||||
* @slot {{ row: DataTableRow; }} expanded-row
|
* @slot {{ row: DataTableRow; }} expanded-row
|
||||||
|
|
5
types/DataTable/DataTable.d.ts
vendored
5
types/DataTable/DataTable.d.ts
vendored
|
@ -22,7 +22,10 @@ export interface DataTableNonEmptyHeader {
|
||||||
|
|
||||||
export type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader;
|
export type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader;
|
||||||
|
|
||||||
export type DataTableRow = Record<DataTableKey, DataTableValue>;
|
export interface DataTableRow {
|
||||||
|
id: any;
|
||||||
|
[key: string]: DataTableValue;
|
||||||
|
}
|
||||||
|
|
||||||
export type DataTableRowId = string;
|
export type DataTableRowId = string;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue