@tanstack/table-core 8.10.1 → 8.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/columnHelper.js.map +1 -1
- package/build/lib/core/cell.d.ts +36 -6
- package/build/lib/core/cell.js.map +1 -1
- package/build/lib/core/column.d.ts +46 -3
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.d.ts +160 -11
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.d.ts +81 -11
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.d.ts +189 -28
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnSizing.d.ts +140 -20
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/Expanding.d.ts +126 -11
- package/build/lib/features/Expanding.js.map +1 -1
- package/build/lib/features/Filters.d.ts +225 -23
- package/build/lib/features/Filters.js.map +1 -1
- package/build/lib/features/Grouping.d.ts +151 -16
- package/build/lib/features/Grouping.js.map +1 -1
- package/build/lib/features/Ordering.d.ts +17 -2
- package/build/lib/features/Ordering.js.map +1 -1
- package/build/lib/features/Pagination.d.ts +118 -16
- package/build/lib/features/Pagination.js.map +1 -1
- package/build/lib/features/Pinning.d.ts +163 -13
- package/build/lib/features/Pinning.js.map +1 -1
- package/build/lib/features/RowSelection.d.ts +151 -16
- package/build/lib/features/RowSelection.js +5 -2
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/Sorting.d.ts +187 -20
- package/build/lib/features/Sorting.js.map +1 -1
- package/build/lib/features/Visibility.d.ts +95 -12
- package/build/lib/features/Visibility.js.map +1 -1
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.esm.js +5 -2
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +5 -2
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +5 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/columnHelper.ts +2 -2
- package/src/core/cell.ts +36 -6
- package/src/core/column.ts +46 -3
- package/src/core/headers.ts +160 -11
- package/src/core/row.ts +88 -15
- package/src/core/table.ts +189 -28
- package/src/features/ColumnSizing.ts +143 -20
- package/src/features/Expanding.ts +126 -11
- package/src/features/Filters.ts +225 -24
- package/src/features/Grouping.ts +151 -17
- package/src/features/Ordering.ts +17 -2
- package/src/features/Pagination.ts +118 -16
- package/src/features/Pinning.ts +163 -13
- package/src/features/RowSelection.ts +154 -19
- package/src/features/Sorting.ts +187 -20
- package/src/features/Visibility.ts +98 -12
- package/src/filterFns.ts +2 -2
- package/src/types.ts +5 -5
- package/src/utils.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.10.
|
|
4
|
+
"version": "8.10.2",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
package/src/columnHelper.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type ColumnHelper<TData extends RowData> = {
|
|
|
56
56
|
? TReturn
|
|
57
57
|
: TAccessor extends DeepKeys<TData>
|
|
58
58
|
? DeepValue<TData, TAccessor>
|
|
59
|
-
: never
|
|
59
|
+
: never,
|
|
60
60
|
>(
|
|
61
61
|
accessor: TAccessor,
|
|
62
62
|
column: TAccessor extends AccessorFn<TData>
|
|
@@ -68,7 +68,7 @@ export type ColumnHelper<TData extends RowData> = {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export function createColumnHelper<
|
|
71
|
-
TData extends RowData
|
|
71
|
+
TData extends RowData,
|
|
72
72
|
>(): ColumnHelper<TData> {
|
|
73
73
|
return {
|
|
74
74
|
accessor: (accessor, column) => {
|
package/src/core/cell.ts
CHANGED
|
@@ -2,21 +2,51 @@ import { RowData, Cell, Column, Row, Table } from '../types'
|
|
|
2
2
|
import { Getter, memo } from '../utils'
|
|
3
3
|
|
|
4
4
|
export interface CellContext<TData extends RowData, TValue> {
|
|
5
|
-
table: Table<TData>
|
|
6
|
-
column: Column<TData, TValue>
|
|
7
|
-
row: Row<TData>
|
|
8
5
|
cell: Cell<TData, TValue>
|
|
6
|
+
column: Column<TData, TValue>
|
|
9
7
|
getValue: Getter<TValue>
|
|
10
8
|
renderValue: Getter<TValue | null>
|
|
9
|
+
row: Row<TData>
|
|
10
|
+
table: Table<TData>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface CoreCell<TData extends RowData, TValue> {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The associated Column object for the cell.
|
|
16
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#column)
|
|
17
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
18
|
+
*/
|
|
19
|
+
column: Column<TData, TValue>
|
|
20
|
+
/**
|
|
21
|
+
* Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:
|
|
22
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getcontext)
|
|
23
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
24
|
+
*/
|
|
25
|
+
getContext: () => CellContext<TData, TValue>
|
|
26
|
+
/**
|
|
27
|
+
* Returns the value for the cell, accessed via the associated column's accessor key or accessor function.
|
|
28
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getvalue)
|
|
29
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
30
|
+
*/
|
|
15
31
|
getValue: CellContext<TData, TValue>['getValue']
|
|
32
|
+
/**
|
|
33
|
+
* The unique ID for the cell across the entire table.
|
|
34
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#id)
|
|
35
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
36
|
+
*/
|
|
37
|
+
id: string
|
|
38
|
+
/**
|
|
39
|
+
* Renders the value for a cell the same as `getValue`, but will return the `renderFallbackValue` if no value is found.
|
|
40
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#rendervalue)
|
|
41
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
42
|
+
*/
|
|
16
43
|
renderValue: CellContext<TData, TValue>['renderValue']
|
|
44
|
+
/**
|
|
45
|
+
* The associated Row object for the cell.
|
|
46
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#row)
|
|
47
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)
|
|
48
|
+
*/
|
|
17
49
|
row: Row<TData>
|
|
18
|
-
column: Column<TData, TValue>
|
|
19
|
-
getContext: () => CellContext<TData, TValue>
|
|
20
50
|
}
|
|
21
51
|
|
|
22
52
|
export function createCell<TData extends RowData, TValue>(
|
package/src/core/column.ts
CHANGED
|
@@ -9,14 +9,57 @@ import {
|
|
|
9
9
|
import { memo } from '../utils'
|
|
10
10
|
|
|
11
11
|
export interface CoreColumn<TData extends RowData, TValue> {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.
|
|
14
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)
|
|
15
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
16
|
+
*/
|
|
14
17
|
accessorFn?: AccessorFn<TData, TValue>
|
|
18
|
+
/**
|
|
19
|
+
* The original column def used to create the column.
|
|
20
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)
|
|
21
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
22
|
+
*/
|
|
15
23
|
columnDef: ColumnDef<TData, TValue>
|
|
24
|
+
/**
|
|
25
|
+
* The child column (if the column is a group column). Will be an empty array if the column is not a group column.
|
|
26
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)
|
|
27
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
28
|
+
*/
|
|
16
29
|
columns: Column<TData, TValue>[]
|
|
17
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The depth of the column (if grouped) relative to the root column def array.
|
|
32
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)
|
|
33
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
34
|
+
*/
|
|
35
|
+
depth: number
|
|
36
|
+
/**
|
|
37
|
+
* Returns the flattened array of this column and all child/grand-child columns for this column.
|
|
38
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)
|
|
39
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
40
|
+
*/
|
|
18
41
|
getFlatColumns: () => Column<TData, TValue>[]
|
|
42
|
+
/**
|
|
43
|
+
* Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.
|
|
44
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)
|
|
45
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
46
|
+
*/
|
|
19
47
|
getLeafColumns: () => Column<TData, TValue>[]
|
|
48
|
+
/**
|
|
49
|
+
* The resolved unique identifier for the column resolved in this priority:
|
|
50
|
+
- A manual `id` property from the column def
|
|
51
|
+
- The accessor key from the column def
|
|
52
|
+
- The header string from the column def
|
|
53
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)
|
|
54
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
55
|
+
*/
|
|
56
|
+
id: string
|
|
57
|
+
/**
|
|
58
|
+
* The parent column for this column. Will be undefined if this is a root column.
|
|
59
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)
|
|
60
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)
|
|
61
|
+
*/
|
|
62
|
+
parent?: Column<TData, TValue>
|
|
20
63
|
}
|
|
21
64
|
|
|
22
65
|
export function createColumn<TData extends RowData, TValue>(
|
package/src/core/headers.ts
CHANGED
|
@@ -3,51 +3,200 @@ import { memo } from '../utils'
|
|
|
3
3
|
import { TableFeature } from './table'
|
|
4
4
|
|
|
5
5
|
export interface CoreHeaderGroup<TData extends RowData> {
|
|
6
|
-
id: string
|
|
7
6
|
depth: number
|
|
8
7
|
headers: Header<TData, unknown>[]
|
|
8
|
+
id: string
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface HeaderContext<TData, TValue> {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* An instance of a column.
|
|
14
|
+
*/
|
|
14
15
|
column: Column<TData, TValue>
|
|
16
|
+
/**
|
|
17
|
+
* An instance of a header.
|
|
18
|
+
*/
|
|
19
|
+
header: Header<TData, TValue>
|
|
20
|
+
/**
|
|
21
|
+
* The table instance.
|
|
22
|
+
*/
|
|
23
|
+
table: Table<TData>
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
export interface CoreHeader<TData extends RowData, TValue> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
subHeaders: Header<TData, TValue>[]
|
|
27
|
+
/**
|
|
28
|
+
* The col-span for the header.
|
|
29
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#colspan)
|
|
30
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
31
|
+
*/
|
|
24
32
|
colSpan: number
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The header's associated column object.
|
|
35
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#column)
|
|
36
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
37
|
+
*/
|
|
38
|
+
column: Column<TData, TValue>
|
|
39
|
+
/**
|
|
40
|
+
* The depth of the header, zero-indexed based.
|
|
41
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#depth)
|
|
42
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
43
|
+
*/
|
|
44
|
+
depth: number
|
|
45
|
+
/**
|
|
46
|
+
* Returns the rendering context (or props) for column-based components like headers, footers and filters.
|
|
47
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getcontext)
|
|
48
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
49
|
+
*/
|
|
50
|
+
getContext: () => HeaderContext<TData, TValue>
|
|
51
|
+
/**
|
|
52
|
+
* Returns the leaf headers hierarchically nested under this header.
|
|
53
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getleafheaders)
|
|
54
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
55
|
+
*/
|
|
26
56
|
getLeafHeaders: () => Header<TData, unknown>[]
|
|
57
|
+
/**
|
|
58
|
+
* The header's associated header group object.
|
|
59
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#headergroup)
|
|
60
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
61
|
+
*/
|
|
62
|
+
headerGroup: HeaderGroup<TData>
|
|
63
|
+
/**
|
|
64
|
+
* The unique identifier for the header.
|
|
65
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#id)
|
|
66
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
67
|
+
*/
|
|
68
|
+
id: string
|
|
69
|
+
/**
|
|
70
|
+
* The index for the header within the header group.
|
|
71
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#index)
|
|
72
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
73
|
+
*/
|
|
74
|
+
index: number
|
|
75
|
+
/**
|
|
76
|
+
* A boolean denoting if the header is a placeholder header.
|
|
77
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#isplaceholder)
|
|
78
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
79
|
+
*/
|
|
27
80
|
isPlaceholder: boolean
|
|
81
|
+
/**
|
|
82
|
+
* If the header is a placeholder header, this will be a unique header ID that does not conflict with any other headers across the table.
|
|
83
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#placeholderid)
|
|
84
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
85
|
+
*/
|
|
28
86
|
placeholderId?: string
|
|
29
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The row-span for the header.
|
|
89
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#rowspan)
|
|
90
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
91
|
+
*/
|
|
92
|
+
rowSpan: number
|
|
93
|
+
/**
|
|
94
|
+
* The header's hierarchical sub/child headers. Will be empty if the header's associated column is a leaf-column.
|
|
95
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#subheaders)
|
|
96
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
97
|
+
*/
|
|
98
|
+
subHeaders: Header<TData, TValue>[]
|
|
30
99
|
}
|
|
31
100
|
|
|
32
101
|
export interface HeadersInstance<TData extends RowData> {
|
|
102
|
+
/**
|
|
103
|
+
* Returns all header groups for the table.
|
|
104
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getheadergroups)
|
|
105
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
106
|
+
*/
|
|
33
107
|
getHeaderGroups: () => HeaderGroup<TData>[]
|
|
108
|
+
/**
|
|
109
|
+
* If pinning, returns the header groups for the left pinned columns.
|
|
110
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftheadergroups)
|
|
111
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
112
|
+
*/
|
|
34
113
|
getLeftHeaderGroups: () => HeaderGroup<TData>[]
|
|
114
|
+
/**
|
|
115
|
+
* If pinning, returns the header groups for columns that are not pinned.
|
|
116
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterheadergroups)
|
|
117
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
118
|
+
*/
|
|
35
119
|
getCenterHeaderGroups: () => HeaderGroup<TData>[]
|
|
120
|
+
/**
|
|
121
|
+
* If pinning, returns the header groups for the right pinned columns.
|
|
122
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightheadergroups)
|
|
123
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
124
|
+
*/
|
|
36
125
|
getRightHeaderGroups: () => HeaderGroup<TData>[]
|
|
37
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Returns the footer groups for the table.
|
|
129
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getfootergroups)
|
|
130
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
131
|
+
*/
|
|
38
132
|
getFooterGroups: () => HeaderGroup<TData>[]
|
|
133
|
+
/**
|
|
134
|
+
* If pinning, returns the footer groups for the left pinned columns.
|
|
135
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftfootergroups)
|
|
136
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
137
|
+
*/
|
|
39
138
|
getLeftFooterGroups: () => HeaderGroup<TData>[]
|
|
139
|
+
/**
|
|
140
|
+
* If pinning, returns the footer groups for columns that are not pinned.
|
|
141
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterfootergroups)
|
|
142
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
143
|
+
*/
|
|
40
144
|
getCenterFooterGroups: () => HeaderGroup<TData>[]
|
|
145
|
+
/**
|
|
146
|
+
* If pinning, returns the footer groups for the right pinned columns.
|
|
147
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightfootergroups)
|
|
148
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
149
|
+
*/
|
|
41
150
|
getRightFooterGroups: () => HeaderGroup<TData>[]
|
|
42
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Returns headers for all columns in the table, including parent headers.
|
|
154
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getflatheaders)
|
|
155
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
156
|
+
*/
|
|
43
157
|
getFlatHeaders: () => Header<TData, unknown>[]
|
|
158
|
+
/**
|
|
159
|
+
* If pinning, returns headers for all left pinned columns in the table, including parent headers.
|
|
160
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftflatheaders)
|
|
161
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
162
|
+
*/
|
|
44
163
|
getLeftFlatHeaders: () => Header<TData, unknown>[]
|
|
164
|
+
/**
|
|
165
|
+
* If pinning, returns headers for all columns that are not pinned, including parent headers.
|
|
166
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterflatheaders)
|
|
167
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
168
|
+
*/
|
|
45
169
|
getCenterFlatHeaders: () => Header<TData, unknown>[]
|
|
170
|
+
/**
|
|
171
|
+
* If pinning, returns headers for all right pinned columns in the table, including parent headers.
|
|
172
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightflatheaders)
|
|
173
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
174
|
+
*/
|
|
46
175
|
getRightFlatHeaders: () => Header<TData, unknown>[]
|
|
47
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Returns headers for all leaf columns in the table, (not including parent headers).
|
|
179
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleafheaders)
|
|
180
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
181
|
+
*/
|
|
48
182
|
getLeafHeaders: () => Header<TData, unknown>[]
|
|
183
|
+
/**
|
|
184
|
+
* If pinning, returns headers for all left pinned leaf columns in the table, (not including parent headers).
|
|
185
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftleafheaders)
|
|
186
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
187
|
+
*/
|
|
49
188
|
getLeftLeafHeaders: () => Header<TData, unknown>[]
|
|
189
|
+
/**
|
|
190
|
+
* If pinning, returns headers for all columns that are not pinned, (not including parent headers).
|
|
191
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterleafheaders)
|
|
192
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
193
|
+
*/
|
|
50
194
|
getCenterLeafHeaders: () => Header<TData, unknown>[]
|
|
195
|
+
/**
|
|
196
|
+
* If pinning, returns headers for all right pinned leaf columns in the table, (not including parent headers).
|
|
197
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightleafheaders)
|
|
198
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)
|
|
199
|
+
*/
|
|
51
200
|
getRightLeafHeaders: () => Header<TData, unknown>[]
|
|
52
201
|
}
|
|
53
202
|
|
package/src/core/row.ts
CHANGED
|
@@ -3,23 +3,93 @@ import { flattenBy, memo } from '../utils'
|
|
|
3
3
|
import { createCell } from './cell'
|
|
4
4
|
|
|
5
5
|
export interface CoreRow<TData extends RowData> {
|
|
6
|
+
_getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>
|
|
7
|
+
_uniqueValuesCache: Record<string, unknown>
|
|
8
|
+
_valuesCache: Record<string, unknown>
|
|
9
|
+
/**
|
|
10
|
+
* The depth of the row (if nested or grouped) relative to the root row array.
|
|
11
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#depth)
|
|
12
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
13
|
+
*/
|
|
14
|
+
depth: number
|
|
15
|
+
/**
|
|
16
|
+
* Returns all of the cells for the row.
|
|
17
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getallcells)
|
|
18
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
19
|
+
*/
|
|
20
|
+
getAllCells: () => Cell<TData, unknown>[]
|
|
21
|
+
/**
|
|
22
|
+
* Returns the leaf rows for the row, not including any parent rows.
|
|
23
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getleafrows)
|
|
24
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
25
|
+
*/
|
|
26
|
+
getLeafRows: () => Row<TData>[]
|
|
27
|
+
/**
|
|
28
|
+
* Returns the parent row for the row, if it exists.
|
|
29
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrow)
|
|
30
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
31
|
+
*/
|
|
32
|
+
getParentRow: () => Row<TData> | undefined
|
|
33
|
+
/**
|
|
34
|
+
* Returns the parent rows for the row, all the way up to a root row.
|
|
35
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrows)
|
|
36
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
37
|
+
*/
|
|
38
|
+
getParentRows: () => Row<TData>[]
|
|
39
|
+
/**
|
|
40
|
+
* Returns a unique array of values from the row for a given columnId.
|
|
41
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getuniquevalues)
|
|
42
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
43
|
+
*/
|
|
44
|
+
getUniqueValues: <TValue>(columnId: string) => TValue[]
|
|
45
|
+
/**
|
|
46
|
+
* Returns the value from the row for a given columnId.
|
|
47
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getvalue)
|
|
48
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
49
|
+
*/
|
|
50
|
+
getValue: <TValue>(columnId: string) => TValue
|
|
51
|
+
/**
|
|
52
|
+
* The resolved unique identifier for the row resolved via the `options.getRowId` option. Defaults to the row's index (or relative index if it is a subRow).
|
|
53
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#id)
|
|
54
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
55
|
+
*/
|
|
6
56
|
id: string
|
|
57
|
+
/**
|
|
58
|
+
* The index of the row within its parent array (or the root data array).
|
|
59
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#index)
|
|
60
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
61
|
+
*/
|
|
7
62
|
index: number
|
|
63
|
+
/**
|
|
64
|
+
* The original row object provided to the table. If the row is a grouped row, the original row object will be the first original in the group.
|
|
65
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#original)
|
|
66
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
67
|
+
*/
|
|
8
68
|
original: TData
|
|
9
|
-
|
|
69
|
+
/**
|
|
70
|
+
* An array of the original subRows as returned by the `options.getSubRows` option.
|
|
71
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#originalsubrows)
|
|
72
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
73
|
+
*/
|
|
74
|
+
originalSubRows?: TData[]
|
|
75
|
+
/**
|
|
76
|
+
* If nested, this row's parent row id.
|
|
77
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#parentid)
|
|
78
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
79
|
+
*/
|
|
10
80
|
parentId?: string
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Renders the value for the row in a given columnId the same as `getValue`, but will return the `renderFallbackValue` if no value is found.
|
|
83
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#rendervalue)
|
|
84
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
85
|
+
*/
|
|
15
86
|
renderValue: <TValue>(columnId: string) => TValue
|
|
87
|
+
/**
|
|
88
|
+
* An array of subRows for the row as returned and created by the `options.getSubRows` option.
|
|
89
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#subrows)
|
|
90
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)
|
|
91
|
+
*/
|
|
16
92
|
subRows: Row<TData>[]
|
|
17
|
-
getLeafRows: () => Row<TData>[]
|
|
18
|
-
originalSubRows?: TData[]
|
|
19
|
-
getAllCells: () => Cell<TData, unknown>[]
|
|
20
|
-
_getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>
|
|
21
|
-
getParentRow: () => Row<TData> | undefined
|
|
22
|
-
getParentRows: () => Row<TData>[]
|
|
23
93
|
}
|
|
24
94
|
|
|
25
95
|
export const createRow = <TData extends RowData>(
|
|
@@ -112,10 +182,13 @@ export const createRow = <TData extends RowData>(
|
|
|
112
182
|
_getAllCellsByColumnId: memo(
|
|
113
183
|
() => [row.getAllCells()],
|
|
114
184
|
allCells => {
|
|
115
|
-
return allCells.reduce(
|
|
116
|
-
acc
|
|
117
|
-
|
|
118
|
-
|
|
185
|
+
return allCells.reduce(
|
|
186
|
+
(acc, cell) => {
|
|
187
|
+
acc[cell.column.id] = cell
|
|
188
|
+
return acc
|
|
189
|
+
},
|
|
190
|
+
{} as Record<string, Cell<TData, unknown>>
|
|
191
|
+
)
|
|
119
192
|
},
|
|
120
193
|
{
|
|
121
194
|
key:
|