@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/src/core/table.ts
CHANGED
|
@@ -34,14 +34,14 @@ import { Sorting } from '../features/Sorting'
|
|
|
34
34
|
import { Visibility } from '../features/Visibility'
|
|
35
35
|
|
|
36
36
|
export interface TableFeature {
|
|
37
|
-
|
|
38
|
-
getInitialState?: (initialState?: InitialTableState) => any
|
|
39
|
-
createTable?: (table: any) => any
|
|
40
|
-
getDefaultColumnDef?: () => any
|
|
37
|
+
createCell?: (cell: any, column: any, row: any, table: any) => any
|
|
41
38
|
createColumn?: (column: any, table: any) => any
|
|
42
39
|
createHeader?: (column: any, table: any) => any
|
|
43
|
-
createCell?: (cell: any, column: any, row: any, table: any) => any
|
|
44
40
|
createRow?: (row: any, table: any) => any
|
|
41
|
+
createTable?: (table: any) => any
|
|
42
|
+
getDefaultColumnDef?: () => any
|
|
43
|
+
getDefaultOptions?: (table: any) => any
|
|
44
|
+
getInitialState?: (initialState?: InitialTableState) => any
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const features = [
|
|
@@ -63,50 +63,211 @@ const features = [
|
|
|
63
63
|
export interface CoreTableState {}
|
|
64
64
|
|
|
65
65
|
export interface CoreOptions<TData extends RowData> {
|
|
66
|
+
/**
|
|
67
|
+
* Set this option to override any of the `autoReset...` feature options.
|
|
68
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#autoresetall)
|
|
69
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
70
|
+
*/
|
|
71
|
+
autoResetAll?: boolean
|
|
72
|
+
/**
|
|
73
|
+
* The array of column defs to use for the table.
|
|
74
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#columns)
|
|
75
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
76
|
+
*/
|
|
77
|
+
columns: ColumnDef<TData, any>[]
|
|
78
|
+
/**
|
|
79
|
+
* The data for the table to display. This array should match the type you provided to `table.setRowType<...>`. Columns can access this data via string/index or a functional accessor. When the `data` option changes reference, the table will reprocess the data.
|
|
80
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#data)
|
|
81
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
82
|
+
*/
|
|
66
83
|
data: TData[]
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Set this option to `true` to output all debugging information to the console.
|
|
86
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugall)
|
|
87
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
88
|
+
*/
|
|
69
89
|
debugAll?: boolean
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Set this option to `true` to output column debugging information to the console.
|
|
92
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugcolumns)
|
|
93
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
94
|
+
*/
|
|
72
95
|
debugColumns?: boolean
|
|
96
|
+
/**
|
|
97
|
+
* Set this option to `true` to output header debugging information to the console.
|
|
98
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugheaders)
|
|
99
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
100
|
+
*/
|
|
101
|
+
debugHeaders?: boolean
|
|
102
|
+
/**
|
|
103
|
+
* Set this option to `true` to output row debugging information to the console.
|
|
104
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugrows)
|
|
105
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
106
|
+
*/
|
|
73
107
|
debugRows?: boolean
|
|
108
|
+
/**
|
|
109
|
+
* Set this option to `true` to output table debugging information to the console.
|
|
110
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugtable)
|
|
111
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
112
|
+
*/
|
|
113
|
+
debugTable?: boolean
|
|
114
|
+
/**
|
|
115
|
+
* Default column options to use for all column defs supplied to the table.
|
|
116
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#defaultcolumn)
|
|
117
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
118
|
+
*/
|
|
119
|
+
defaultColumn?: Partial<ColumnDef<TData, unknown>>
|
|
120
|
+
/**
|
|
121
|
+
* This required option is a factory for a function that computes and returns the core row model for the table.
|
|
122
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)
|
|
123
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
124
|
+
*/
|
|
125
|
+
getCoreRowModel: (table: Table<any>) => () => RowModel<any>
|
|
126
|
+
/**
|
|
127
|
+
* This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.
|
|
128
|
+
* @example getRowId: row => row.userId
|
|
129
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowid)
|
|
130
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
131
|
+
*/
|
|
132
|
+
getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string
|
|
133
|
+
/**
|
|
134
|
+
* This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row.
|
|
135
|
+
* @example getSubRows: row => row.subRows
|
|
136
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getsubrows)
|
|
137
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
138
|
+
*/
|
|
139
|
+
getSubRows?: (originalRow: TData, index: number) => undefined | TData[]
|
|
140
|
+
/**
|
|
141
|
+
* Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state.
|
|
142
|
+
*
|
|
143
|
+
* Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable.
|
|
144
|
+
*
|
|
145
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)
|
|
146
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
147
|
+
*/
|
|
74
148
|
initialState?: InitialTableState
|
|
75
|
-
|
|
149
|
+
/**
|
|
150
|
+
* This option is used to optionally implement the merging of table options.
|
|
151
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#mergeoptions)
|
|
152
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
153
|
+
*/
|
|
76
154
|
mergeOptions?: (
|
|
77
155
|
defaultOptions: TableOptions<TData>,
|
|
78
156
|
options: Partial<TableOptions<TData>>
|
|
79
157
|
) => TableOptions<TData>
|
|
158
|
+
/**
|
|
159
|
+
* You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`.
|
|
160
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#meta)
|
|
161
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
162
|
+
*/
|
|
80
163
|
meta?: TableMeta<TData>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
164
|
+
/**
|
|
165
|
+
* The `onStateChange` option can be used to optionally listen to state changes within the table.
|
|
166
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#onstatechange)
|
|
167
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
168
|
+
*/
|
|
169
|
+
onStateChange: (updater: Updater<TableState>) => void
|
|
170
|
+
/**
|
|
171
|
+
* Value used when the desired value is not found in the data.
|
|
172
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#renderfallbackvalue)
|
|
173
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
174
|
+
*/
|
|
86
175
|
renderFallbackValue: any
|
|
176
|
+
/**
|
|
177
|
+
* The `state` option can be used to optionally _control_ part or all of the table state. The state you pass here will merge with and overwrite the internal automatically-managed state to produce the final state for the table. You can also listen to state changes via the `onStateChange` option.
|
|
178
|
+
* > Note: Any state passed in here will override both the internal state and any other `initialState` you provide.
|
|
179
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#state)
|
|
180
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
181
|
+
*/
|
|
182
|
+
state: Partial<TableState>
|
|
87
183
|
}
|
|
88
184
|
|
|
89
185
|
export interface CoreInstance<TData extends RowData> {
|
|
90
|
-
initialState: TableState
|
|
91
|
-
reset: () => void
|
|
92
|
-
options: RequiredKeys<TableOptionsResolved<TData>, 'state'>
|
|
93
|
-
setOptions: (newOptions: Updater<TableOptionsResolved<TData>>) => void
|
|
94
|
-
getState: () => TableState
|
|
95
|
-
setState: (updater: Updater<TableState>) => void
|
|
96
186
|
_features: readonly TableFeature[]
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
getCoreRowModel: () => RowModel<TData>
|
|
187
|
+
_getAllFlatColumnsById: () => Record<string, Column<TData, unknown>>
|
|
188
|
+
_getColumnDefs: () => ColumnDef<TData, unknown>[]
|
|
100
189
|
_getCoreRowModel?: () => RowModel<TData>
|
|
101
|
-
getRowModel: () => RowModel<TData>
|
|
102
|
-
getRow: (id: string, searchAll?: boolean) => Row<TData>
|
|
103
190
|
_getDefaultColumnDef: () => Partial<ColumnDef<TData, unknown>>
|
|
104
|
-
|
|
105
|
-
|
|
191
|
+
_getRowId: (_: TData, index: number, parent?: Row<TData>) => string
|
|
192
|
+
_queue: (cb: () => void) => void
|
|
193
|
+
/**
|
|
194
|
+
* Returns all columns in the table in their normalized and nested hierarchy.
|
|
195
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallcolumns)
|
|
196
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
197
|
+
*/
|
|
106
198
|
getAllColumns: () => Column<TData, unknown>[]
|
|
199
|
+
/**
|
|
200
|
+
* Returns all columns in the table flattened to a single level.
|
|
201
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallflatcolumns)
|
|
202
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
203
|
+
*/
|
|
107
204
|
getAllFlatColumns: () => Column<TData, unknown>[]
|
|
205
|
+
/**
|
|
206
|
+
* Returns all leaf-node columns in the table flattened to a single level. This does not include parent columns.
|
|
207
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallleafcolumns)
|
|
208
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
209
|
+
*/
|
|
108
210
|
getAllLeafColumns: () => Column<TData, unknown>[]
|
|
211
|
+
/**
|
|
212
|
+
* Returns a single column by its ID.
|
|
213
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcolumn)
|
|
214
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
215
|
+
*/
|
|
109
216
|
getColumn: (columnId: string) => Column<TData, unknown> | undefined
|
|
217
|
+
/**
|
|
218
|
+
* Returns the core row model before any processing has been applied.
|
|
219
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)
|
|
220
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
221
|
+
*/
|
|
222
|
+
getCoreRowModel: () => RowModel<TData>
|
|
223
|
+
/**
|
|
224
|
+
* Returns the row with the given ID.
|
|
225
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrow)
|
|
226
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
227
|
+
*/
|
|
228
|
+
getRow: (id: string, searchAll?: boolean) => Row<TData>
|
|
229
|
+
/**
|
|
230
|
+
* Returns the final model after all processing from other used features has been applied. This is the row model that is most commonly used for rendering.
|
|
231
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowmodel)
|
|
232
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
233
|
+
*/
|
|
234
|
+
getRowModel: () => RowModel<TData>
|
|
235
|
+
/**
|
|
236
|
+
* Call this function to get the table's current state. It's recommended to use this function and its state, especially when managing the table state manually. It is the exact same state used internally by the table for every feature and function it provides.
|
|
237
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getstate)
|
|
238
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
239
|
+
*/
|
|
240
|
+
getState: () => TableState
|
|
241
|
+
/**
|
|
242
|
+
* This is the resolved initial state of the table.
|
|
243
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)
|
|
244
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
245
|
+
*/
|
|
246
|
+
initialState: TableState
|
|
247
|
+
/**
|
|
248
|
+
* A read-only reference to the table's current options.
|
|
249
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#options)
|
|
250
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
251
|
+
*/
|
|
252
|
+
options: RequiredKeys<TableOptionsResolved<TData>, 'state'>
|
|
253
|
+
/**
|
|
254
|
+
* Call this function to reset the table state to the initial state.
|
|
255
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#reset)
|
|
256
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
257
|
+
*/
|
|
258
|
+
reset: () => void
|
|
259
|
+
/**
|
|
260
|
+
* This function can be used to update the table options.
|
|
261
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setoptions)
|
|
262
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
263
|
+
*/
|
|
264
|
+
setOptions: (newOptions: Updater<TableOptionsResolved<TData>>) => void
|
|
265
|
+
/**
|
|
266
|
+
* Call this function to update the table state.
|
|
267
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setstate)
|
|
268
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
|
|
269
|
+
*/
|
|
270
|
+
setState: (updater: Updater<TableState>) => void
|
|
110
271
|
}
|
|
111
272
|
|
|
112
273
|
export function createTable<TData extends RowData>(
|
|
@@ -13,59 +13,182 @@ export interface ColumnSizingTableState {
|
|
|
13
13
|
export type ColumnSizingState = Record<string, number>
|
|
14
14
|
|
|
15
15
|
export interface ColumnSizingInfoState {
|
|
16
|
-
|
|
17
|
-
startSize: null | number
|
|
16
|
+
columnSizingStart: [string, number][]
|
|
18
17
|
deltaOffset: null | number
|
|
19
18
|
deltaPercentage: null | number
|
|
20
19
|
isResizingColumn: false | string
|
|
21
|
-
|
|
20
|
+
startOffset: null | number
|
|
21
|
+
startSize: null | number
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export type ColumnResizeMode = 'onChange' | 'onEnd'
|
|
25
25
|
|
|
26
26
|
export interface ColumnSizingOptions {
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Determines when the columnSizing state is updated. `onChange` updates the state when the user is dragging the resize handle. `onEnd` updates the state when the user releases the resize handle.
|
|
29
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#columnresizemode)
|
|
30
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
31
|
+
*/
|
|
28
32
|
columnResizeMode?: ColumnResizeMode
|
|
33
|
+
/**
|
|
34
|
+
* Enables or disables column resizing for the column.
|
|
35
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#enablecolumnresizing)
|
|
36
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
37
|
+
*/
|
|
38
|
+
enableColumnResizing?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* If provided, this function will be called with an `updaterFn` when `state.columnSizing` changes. This overrides the default internal state management, so you will also need to supply `state.columnSizing` from your own managed state.
|
|
41
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#oncolumnsizingchange)
|
|
42
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
43
|
+
*/
|
|
29
44
|
onColumnSizingChange?: OnChangeFn<ColumnSizingState>
|
|
45
|
+
/**
|
|
46
|
+
* If provided, this function will be called with an `updaterFn` when `state.columnSizingInfo` changes. This overrides the default internal state management, so you will also need to supply `state.columnSizingInfo` from your own managed state.
|
|
47
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#oncolumnsizinginfochange)
|
|
48
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
49
|
+
*/
|
|
30
50
|
onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState>
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
onColumnSizingChange
|
|
36
|
-
|
|
37
|
-
}
|
|
53
|
+
export type ColumnSizingDefaultOptions = Pick<
|
|
54
|
+
ColumnSizingOptions,
|
|
55
|
+
'columnResizeMode' | 'onColumnSizingChange' | 'onColumnSizingInfoChange'
|
|
56
|
+
>
|
|
38
57
|
|
|
39
58
|
export interface ColumnSizingInstance {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
getLeftTotalSize: () => number
|
|
59
|
+
/**
|
|
60
|
+
* If pinning, returns the total size of the center portion of the table by calculating the sum of the sizes of all unpinned/center leaf-columns.
|
|
61
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getcentertotalsize)
|
|
62
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
63
|
+
*/
|
|
46
64
|
getCenterTotalSize: () => number
|
|
65
|
+
/**
|
|
66
|
+
* Returns the total size of the left portion of the table by calculating the sum of the sizes of all left leaf-columns.
|
|
67
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getlefttotalsize)
|
|
68
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
69
|
+
*/
|
|
70
|
+
getLeftTotalSize: () => number
|
|
71
|
+
/**
|
|
72
|
+
* Returns the total size of the right portion of the table by calculating the sum of the sizes of all right leaf-columns.
|
|
73
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getrighttotalsize)
|
|
74
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
75
|
+
*/
|
|
47
76
|
getRightTotalSize: () => number
|
|
77
|
+
/**
|
|
78
|
+
* Returns the total size of the table by calculating the sum of the sizes of all leaf-columns.
|
|
79
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#gettotalsize)
|
|
80
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
81
|
+
*/
|
|
82
|
+
getTotalSize: () => number
|
|
83
|
+
/**
|
|
84
|
+
* Resets column sizing to its initial state. If `defaultState` is `true`, the default state for the table will be used instead of the initialValue provided to the table.
|
|
85
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetcolumnsizing)
|
|
86
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
87
|
+
*/
|
|
88
|
+
resetColumnSizing: (defaultState?: boolean) => void
|
|
89
|
+
/**
|
|
90
|
+
* Resets column sizing info to its initial state. If `defaultState` is `true`, the default state for the table will be used instead of the initialValue provided to the table.
|
|
91
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetheadersizeinfo)
|
|
92
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
93
|
+
*/
|
|
94
|
+
resetHeaderSizeInfo: (defaultState?: boolean) => void
|
|
95
|
+
/**
|
|
96
|
+
* Sets the column sizing state using an updater function or a value. This will trigger the underlying `onColumnSizingChange` function if one is passed to the table options, otherwise the state will be managed automatically by the table.
|
|
97
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#setcolumnsizing)
|
|
98
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
99
|
+
*/
|
|
100
|
+
setColumnSizing: (updater: Updater<ColumnSizingState>) => void
|
|
101
|
+
/**
|
|
102
|
+
* Sets the column sizing info state using an updater function or a value. This will trigger the underlying `onColumnSizingInfoChange` function if one is passed to the table options, otherwise the state will be managed automatically by the table.
|
|
103
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#setcolumnsizinginfo)
|
|
104
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
105
|
+
*/
|
|
106
|
+
setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void
|
|
48
107
|
}
|
|
49
108
|
|
|
50
109
|
export interface ColumnSizingColumnDef {
|
|
110
|
+
/**
|
|
111
|
+
* Enables or disables column resizing for the column.
|
|
112
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#enableresizing)
|
|
113
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
114
|
+
*/
|
|
51
115
|
enableResizing?: boolean
|
|
52
|
-
|
|
53
|
-
|
|
116
|
+
/**
|
|
117
|
+
* The maximum allowed size for the column
|
|
118
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#maxsize)
|
|
119
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
120
|
+
*/
|
|
54
121
|
maxSize?: number
|
|
122
|
+
/**
|
|
123
|
+
* The minimum allowed size for the column
|
|
124
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#minsize)
|
|
125
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
126
|
+
*/
|
|
127
|
+
minSize?: number
|
|
128
|
+
/**
|
|
129
|
+
* The desired size for the column
|
|
130
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#size)
|
|
131
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
132
|
+
*/
|
|
133
|
+
size?: number
|
|
55
134
|
}
|
|
56
135
|
|
|
57
136
|
export interface ColumnSizingColumn {
|
|
58
|
-
|
|
59
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Returns `true` if the column can be resized.
|
|
139
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getcanresize)
|
|
140
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
141
|
+
*/
|
|
60
142
|
getCanResize: () => boolean
|
|
143
|
+
/**
|
|
144
|
+
* Returns `true` if the column is currently being resized.
|
|
145
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getisresizing)
|
|
146
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
147
|
+
*/
|
|
61
148
|
getIsResizing: () => boolean
|
|
149
|
+
/**
|
|
150
|
+
* Returns the current size of the column.
|
|
151
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getsize)
|
|
152
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
153
|
+
*/
|
|
154
|
+
getSize: () => number
|
|
155
|
+
/**
|
|
156
|
+
* Returns the offset measurement along the row-axis (usually the x-axis for standard tables) for the header. This is effectively a sum of the offset measurements of all preceding headers.
|
|
157
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getstart)
|
|
158
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
159
|
+
*/
|
|
160
|
+
getStart: (position?: ColumnPinningPosition) => number
|
|
161
|
+
/**
|
|
162
|
+
* Resets the column to its initial size.
|
|
163
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetsize)
|
|
164
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
165
|
+
*/
|
|
62
166
|
resetSize: () => void
|
|
63
167
|
}
|
|
64
168
|
|
|
65
169
|
export interface ColumnSizingHeader {
|
|
170
|
+
/**
|
|
171
|
+
* Returns an event handler function that can be used to resize the header. It can be used as an:
|
|
172
|
+
* - `onMouseDown` handler
|
|
173
|
+
* - `onTouchStart` handler
|
|
174
|
+
*
|
|
175
|
+
* The dragging and release events are automatically handled for you.
|
|
176
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getresizehandler)
|
|
177
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
178
|
+
*/
|
|
179
|
+
getResizeHandler: () => (event: unknown) => void
|
|
180
|
+
/**
|
|
181
|
+
* Returns the current size of the header.
|
|
182
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getsize)
|
|
183
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
184
|
+
*/
|
|
66
185
|
getSize: () => number
|
|
186
|
+
/**
|
|
187
|
+
* Returns the offset measurement along the row-axis (usually the x-axis for standard tables) for the header. This is effectively a sum of the offset measurements of all preceding headers.
|
|
188
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getstart)
|
|
189
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
190
|
+
*/
|
|
67
191
|
getStart: (position?: ColumnPinningPosition) => number
|
|
68
|
-
getResizeHandler: () => (event: unknown) => void
|
|
69
192
|
}
|
|
70
193
|
|
|
71
194
|
//
|
|
@@ -10,37 +10,152 @@ export interface ExpandedTableState {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface ExpandedRow {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Returns whether the row can be expanded.
|
|
15
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getcanexpand)
|
|
16
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
17
|
+
*/
|
|
15
18
|
getCanExpand: () => boolean
|
|
19
|
+
/**
|
|
20
|
+
* Returns whether all parent rows of the row are expanded.
|
|
21
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisallparentsexpanded)
|
|
22
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
23
|
+
*/
|
|
16
24
|
getIsAllParentsExpanded: () => boolean
|
|
25
|
+
/**
|
|
26
|
+
* Returns whether the row is expanded.
|
|
27
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisexpanded)
|
|
28
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
29
|
+
*/
|
|
30
|
+
getIsExpanded: () => boolean
|
|
31
|
+
/**
|
|
32
|
+
* Returns a function that can be used to toggle the expanded state of the row. This function can be used to bind to an event handler to a button.
|
|
33
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#gettoggleexpandedhandler)
|
|
34
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
35
|
+
*/
|
|
17
36
|
getToggleExpandedHandler: () => () => void
|
|
37
|
+
/**
|
|
38
|
+
* Toggles the expanded state (or sets it if `expanded` is provided) for the row.
|
|
39
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#toggleexpanded)
|
|
40
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
41
|
+
*/
|
|
42
|
+
toggleExpanded: (expanded?: boolean) => void
|
|
18
43
|
}
|
|
19
44
|
|
|
20
45
|
export interface ExpandedOptions<TData extends RowData> {
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Enable this setting to automatically reset the expanded state of the table when expanding state changes.
|
|
48
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#autoresetexpanded)
|
|
49
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
50
|
+
*/
|
|
23
51
|
autoResetExpanded?: boolean
|
|
52
|
+
/**
|
|
53
|
+
* Enable/disable expanding for all rows.
|
|
54
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#enableexpanding)
|
|
55
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
56
|
+
*/
|
|
24
57
|
enableExpanding?: boolean
|
|
58
|
+
/**
|
|
59
|
+
* This function is responsible for returning the expanded row model. If this function is not provided, the table will not expand rows. You can use the default exported `getExpandedRowModel` function to get the expanded row model or implement your own.
|
|
60
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandedrowmodel)
|
|
61
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
62
|
+
*/
|
|
25
63
|
getExpandedRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
64
|
+
/**
|
|
65
|
+
* If provided, allows you to override the default behavior of determining whether a row is currently expanded.
|
|
66
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisrowexpanded)
|
|
67
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
68
|
+
*/
|
|
26
69
|
getIsRowExpanded?: (row: Row<TData>) => boolean
|
|
70
|
+
/**
|
|
71
|
+
* If provided, allows you to override the default behavior of determining whether a row can be expanded.
|
|
72
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getrowcanexpand)
|
|
73
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
74
|
+
*/
|
|
27
75
|
getRowCanExpand?: (row: Row<TData>) => boolean
|
|
76
|
+
/**
|
|
77
|
+
* Enables manual row expansion. If this is set to `true`, `getExpandedRowModel` will not be used to expand rows and you would be expected to perform the expansion in your own data model. This is useful if you are doing server-side expansion.
|
|
78
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#manualexpanding)
|
|
79
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
80
|
+
*/
|
|
81
|
+
manualExpanding?: boolean
|
|
82
|
+
/**
|
|
83
|
+
* This function is called when the `expanded` table state changes. If a function is provided, you will be responsible for managing this state on your own. To pass the managed state back to the table, use the `tableOptions.state.expanded` option.
|
|
84
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#onexpandedchange)
|
|
85
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
86
|
+
*/
|
|
87
|
+
onExpandedChange?: OnChangeFn<ExpandedState>
|
|
88
|
+
/**
|
|
89
|
+
* If `true` expanded rows will be paginated along with the rest of the table (which means expanded rows may span multiple pages). If `false` expanded rows will not be considered for pagination (which means expanded rows will always render on their parents page. This also means more rows will be rendered than the set page size)
|
|
90
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#paginateexpandedrows)
|
|
91
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
92
|
+
*/
|
|
28
93
|
paginateExpandedRows?: boolean
|
|
29
94
|
}
|
|
30
95
|
|
|
31
96
|
export interface ExpandedInstance<TData extends RowData> {
|
|
32
97
|
_autoResetExpanded: () => void
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
98
|
+
_getExpandedRowModel?: () => RowModel<TData>
|
|
99
|
+
/**
|
|
100
|
+
* Returns whether there are any rows that can be expanded.
|
|
101
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getcansomerowsexpand)
|
|
102
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
103
|
+
*/
|
|
36
104
|
getCanSomeRowsExpand: () => boolean
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Returns the maximum depth of the expanded rows.
|
|
107
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandeddepth)
|
|
108
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
109
|
+
*/
|
|
40
110
|
getExpandedDepth: () => number
|
|
111
|
+
/**
|
|
112
|
+
* Returns the row model after expansion has been applied.
|
|
113
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandedrowmodel)
|
|
114
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
115
|
+
*/
|
|
41
116
|
getExpandedRowModel: () => RowModel<TData>
|
|
42
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Returns whether all rows are currently expanded.
|
|
119
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisallrowsexpanded)
|
|
120
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
121
|
+
*/
|
|
122
|
+
getIsAllRowsExpanded: () => boolean
|
|
123
|
+
/**
|
|
124
|
+
* Returns whether there are any rows that are currently expanded.
|
|
125
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getissomerowsexpanded)
|
|
126
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
127
|
+
*/
|
|
128
|
+
getIsSomeRowsExpanded: () => boolean
|
|
129
|
+
/**
|
|
130
|
+
* Returns the row model before expansion has been applied.
|
|
131
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getpreexpandedrowmodel)
|
|
132
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
133
|
+
*/
|
|
43
134
|
getPreExpandedRowModel: () => RowModel<TData>
|
|
135
|
+
/**
|
|
136
|
+
* Returns a handler that can be used to toggle the expanded state of all rows. This handler is meant to be used with an `input[type=checkbox]` element.
|
|
137
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#gettoggleallrowsexpandedhandler)
|
|
138
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
139
|
+
*/
|
|
140
|
+
getToggleAllRowsExpandedHandler: () => (event: unknown) => void
|
|
141
|
+
/**
|
|
142
|
+
* Resets the expanded state of the table to the initial state.
|
|
143
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#resetexpanded)
|
|
144
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
145
|
+
*/
|
|
146
|
+
resetExpanded: (defaultState?: boolean) => void
|
|
147
|
+
/**
|
|
148
|
+
* Updates the expanded state of the table via an update function or value.
|
|
149
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#setexpanded)
|
|
150
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
151
|
+
*/
|
|
152
|
+
setExpanded: (updater: Updater<ExpandedState>) => void
|
|
153
|
+
/**
|
|
154
|
+
* Toggles the expanded state for all rows.
|
|
155
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#toggleallrowsexpanded)
|
|
156
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
|
|
157
|
+
*/
|
|
158
|
+
toggleAllRowsExpanded: (expanded?: boolean) => void
|
|
44
159
|
}
|
|
45
160
|
|
|
46
161
|
//
|