mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
Tweaks to DataTable generics (#1968)
Adjust DataTable types. - Make key in `cell` slot prop less strict to prevent type errors in markup. - Resolve property path names up to one level deep for header keys.
This commit is contained in:
parent
140e8ff468
commit
e49369ef02
7 changed files with 79 additions and 27 deletions
|
@ -2,14 +2,34 @@
|
|||
/**
|
||||
* @generics {Row extends DataTableRow = DataTableRow} Row
|
||||
* @template {DataTableRow} Row
|
||||
* @typedef {Exclude<keyof Row, "id">} DataTableKey<Row=DataTableRow>
|
||||
* @typedef {import('./DataTableTypes.d.ts').PropertyPath<Row>} DataTableKey<Row=DataTableRow>
|
||||
* @typedef {any} DataTableValue
|
||||
* @typedef {{ key: DataTableKey<Row>; empty: boolean; display?: (item: DataTableValue, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }} DataTableEmptyHeader<Row=DataTableRow>
|
||||
* @typedef {{ key: DataTableKey<Row>; value: DataTableValue; display?: (item: DataTableValue, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }} DataTableNonEmptyHeader<Row=DataTableRow>
|
||||
* @typedef {{
|
||||
* key: DataTableKey<Row>;
|
||||
* empty: boolean;
|
||||
* display?: (item: Value, row: Row) => DataTableValue;
|
||||
* sort?: false | ((a: DataTableValue, b: DataTableValue) => number);
|
||||
* columnMenu?: boolean;
|
||||
* width?: string;
|
||||
* minWidth?: string;
|
||||
* }} DataTableEmptyHeader<Row=DataTableRow>
|
||||
* @typedef {{
|
||||
* key: DataTableKey<Row>;
|
||||
* value: DataTableValue;
|
||||
* display?: (item: Value, row: Row) => DataTableValue;
|
||||
* sort?: false | ((a: DataTableValue, b: DataTableValue) => number);
|
||||
* columnMenu?: boolean;
|
||||
* width?: string;
|
||||
* minWidth?: string;
|
||||
* }} DataTableNonEmptyHeader<Row=DataTableRow>
|
||||
* @typedef {DataTableNonEmptyHeader<Row> | DataTableEmptyHeader<Row>} DataTableHeader<Row=DataTableRow>
|
||||
* @typedef {{ id: any; [key: string]: DataTableValue; }} DataTableRow
|
||||
* @typedef {any} DataTableRowId
|
||||
* @typedef {{ key: DataTableKey<Row>; value: DataTableValue; display?: (item: DataTableValue, row: DataTableRow) => DataTableValue; }} DataTableCell<Row=DataTableRow>
|
||||
* @typedef {{
|
||||
* key: DataTableKey<Row> | (string & {});
|
||||
* value: DataTableValue;
|
||||
* display?: (item: Value, row: DataTableRow) => DataTableValue;
|
||||
* }} DataTableCell<Row=DataTableRow>
|
||||
* @slot {{ row: Row; }} expanded-row
|
||||
* @slot {{ header: DataTableNonEmptyHeader; }} cell-header
|
||||
* @slot {{ row: Row; cell: DataTableCell<Row>; rowIndex: number; cellIndex: number; }} cell
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue