@tanstack/react-table 8.0.0-alpha.6 → 8.0.0-alpha.9
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/cjs/core.js +66 -73
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +47 -33
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +23 -22
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +10 -22
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +27 -58
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +10 -27
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +108 -28
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +2 -2
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +24 -29
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +23 -38
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +10 -22
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +10 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterTypes.js.map +1 -1
- package/build/cjs/index.js +12 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/types.js +22 -0
- package/build/cjs/types.js.map +1 -0
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +44 -18
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +1388 -1355
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +337 -307
- package/build/types/core.d.ts +63 -67
- package/build/types/createTable.d.ts +34 -44
- package/build/types/features/ColumnSizing.d.ts +13 -7
- package/build/types/features/Expanding.d.ts +11 -16
- package/build/types/features/Filters.d.ts +39 -47
- package/build/types/features/Grouping.d.ts +28 -27
- package/build/types/features/Headers.d.ts +30 -30
- package/build/types/features/Ordering.d.ts +5 -5
- package/build/types/features/Pagination.d.ts +11 -16
- package/build/types/features/Pinning.d.ts +5 -5
- package/build/types/features/RowSelection.d.ts +15 -23
- package/build/types/features/Sorting.d.ts +26 -25
- package/build/types/features/Visibility.d.ts +9 -9
- package/build/types/filterTypes.d.ts +10 -10
- package/build/types/index.d.ts +1 -0
- package/build/types/sortTypes.d.ts +7 -7
- package/build/types/types.d.ts +34 -23
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -2
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +5 -6
- package/build/umd/index.development.js +1397 -1354
- 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/core.tsx +192 -520
- package/src/createTable.tsx +137 -192
- package/src/features/ColumnSizing.ts +48 -77
- package/src/features/Expanding.ts +25 -113
- package/src/features/Filters.ts +91 -293
- package/src/features/Grouping.ts +60 -165
- package/src/features/Headers.ts +148 -331
- package/src/features/Ordering.ts +19 -42
- package/src/features/Pagination.ts +35 -110
- package/src/features/Pinning.ts +16 -40
- package/src/features/RowSelection.ts +47 -227
- package/src/features/Sorting.ts +49 -143
- package/src/features/Visibility.ts +23 -64
- package/src/filterTypes.ts +19 -82
- package/src/index.tsx +1 -0
- package/src/sortTypes.ts +19 -31
- package/src/types.ts +80 -100
- package/src/utils/columnFilterRowsFn.ts +11 -53
- package/src/utils/expandRowsFn.ts +7 -27
- package/src/utils/globalFilterRowsFn.ts +10 -43
- package/src/utils/groupRowsFn.ts +13 -37
- package/src/utils/paginateRowsFn.ts +5 -11
- package/src/utils/sortRowsFn.ts +8 -28
- package/src/utils.tsx +61 -35
package/src/core.tsx
CHANGED
|
@@ -25,9 +25,11 @@ import {
|
|
|
25
25
|
Getter,
|
|
26
26
|
RowProps,
|
|
27
27
|
CellProps,
|
|
28
|
-
|
|
28
|
+
TableInstance,
|
|
29
29
|
RowValues,
|
|
30
30
|
Renderable,
|
|
31
|
+
Please_use_the_create_table_column_utilities_to_define_columns,
|
|
32
|
+
PartialGenerics,
|
|
31
33
|
} from './types'
|
|
32
34
|
|
|
33
35
|
import * as Visibility from './features/Visibility'
|
|
@@ -57,334 +59,162 @@ const features = [
|
|
|
57
59
|
RowSelection,
|
|
58
60
|
]
|
|
59
61
|
|
|
60
|
-
export type CoreOptions<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
defaultColumn?: Partial<
|
|
71
|
-
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
72
|
-
>
|
|
62
|
+
export type CoreOptions<TGenerics extends PartialGenerics> = {
|
|
63
|
+
data: TGenerics['Row'][]
|
|
64
|
+
columns: ColumnDef<TGenerics>[]
|
|
65
|
+
state: Partial<TableState>
|
|
66
|
+
onStateChange: (updater: Updater<TableState>) => void
|
|
67
|
+
debugAll?: boolean
|
|
68
|
+
debugTable?: boolean
|
|
69
|
+
debugHeaders?: boolean
|
|
70
|
+
debugColumns?: boolean
|
|
71
|
+
debugRows?: boolean
|
|
72
|
+
defaultColumn?: Partial<ColumnDef<TGenerics>>
|
|
73
73
|
initialState?: Partial<TableState>
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
getSubRows?: (
|
|
75
|
+
originalRow: TGenerics['Row'],
|
|
76
|
+
index: number
|
|
77
|
+
) => TGenerics['Row'][]
|
|
76
78
|
getRowId?: (
|
|
77
|
-
originalRow:
|
|
79
|
+
originalRow: TGenerics['Row'],
|
|
78
80
|
index: number,
|
|
79
|
-
parent?: Row<
|
|
81
|
+
parent?: Row<TGenerics>
|
|
80
82
|
) => string
|
|
81
|
-
onStateChange?: (newState: TableState) => void
|
|
82
83
|
autoResetAll?: boolean
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export type TableCore<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
TSortingFns,
|
|
144
|
-
TAggregationFns
|
|
145
|
-
>[]
|
|
146
|
-
getAllFlatColumnsById: () => Record<
|
|
147
|
-
string,
|
|
148
|
-
Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
149
|
-
>
|
|
150
|
-
getAllLeafColumns: () => Column<
|
|
151
|
-
TData,
|
|
152
|
-
TValue,
|
|
153
|
-
TFilterFns,
|
|
154
|
-
TSortingFns,
|
|
155
|
-
TAggregationFns
|
|
156
|
-
>[]
|
|
157
|
-
getColumn: (
|
|
158
|
-
columnId: string
|
|
159
|
-
) => Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
160
|
-
getColumnWidth: (columnId: string) => number
|
|
161
|
-
getTotalWidth: () => number
|
|
162
|
-
createCell: (
|
|
163
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
164
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
165
|
-
value: any
|
|
166
|
-
) => Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
167
|
-
createRow: (
|
|
168
|
-
id: string,
|
|
169
|
-
original: TData | undefined,
|
|
170
|
-
rowIndex: number,
|
|
171
|
-
depth: number,
|
|
172
|
-
values: Record<string, any>
|
|
173
|
-
) => Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
174
|
-
getCoreRowModel: () => RowModel<
|
|
175
|
-
TData,
|
|
176
|
-
TValue,
|
|
177
|
-
TFilterFns,
|
|
178
|
-
TSortingFns,
|
|
179
|
-
TAggregationFns
|
|
180
|
-
>
|
|
181
|
-
getCoreRows: () => Row<
|
|
182
|
-
TData,
|
|
183
|
-
TValue,
|
|
184
|
-
TFilterFns,
|
|
185
|
-
TSortingFns,
|
|
186
|
-
TAggregationFns
|
|
187
|
-
>[]
|
|
188
|
-
getCoreFlatRows: () => Row<
|
|
189
|
-
TData,
|
|
190
|
-
TValue,
|
|
191
|
-
TFilterFns,
|
|
192
|
-
TSortingFns,
|
|
193
|
-
TAggregationFns
|
|
194
|
-
>[]
|
|
195
|
-
getCoreRowsById: () => Record<
|
|
196
|
-
string,
|
|
197
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
198
|
-
>
|
|
199
|
-
getRowModel: () => RowModel<
|
|
200
|
-
TData,
|
|
201
|
-
TValue,
|
|
202
|
-
TFilterFns,
|
|
203
|
-
TSortingFns,
|
|
204
|
-
TAggregationFns
|
|
205
|
-
>
|
|
206
|
-
getRows: () => Row<
|
|
207
|
-
TData,
|
|
208
|
-
TValue,
|
|
209
|
-
TFilterFns,
|
|
210
|
-
TSortingFns,
|
|
211
|
-
TAggregationFns
|
|
212
|
-
>[]
|
|
213
|
-
getFlatRows: () => Row<
|
|
214
|
-
TData,
|
|
215
|
-
TValue,
|
|
216
|
-
TFilterFns,
|
|
217
|
-
TSortingFns,
|
|
218
|
-
TAggregationFns
|
|
219
|
-
>[]
|
|
220
|
-
getRowsById: () => Record<
|
|
221
|
-
string,
|
|
222
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
223
|
-
>
|
|
224
|
-
getRow: (
|
|
225
|
-
id: string
|
|
226
|
-
) => Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
227
|
-
getCell: (
|
|
228
|
-
rowId: string,
|
|
229
|
-
columnId: string
|
|
230
|
-
) => Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
231
|
-
getTableProps: PropGetter<TableProps>
|
|
232
|
-
getTableBodyProps: PropGetter<TableBodyProps>
|
|
233
|
-
getRowProps: <TGetter extends Getter<RowProps>>(
|
|
234
|
-
rowId: string,
|
|
235
|
-
userProps?: TGetter
|
|
236
|
-
) => undefined | PropGetterValue<RowProps, TGetter>
|
|
237
|
-
getCellProps: <TGetter extends Getter<CellProps>>(
|
|
238
|
-
rowId: string,
|
|
239
|
-
columnId: string,
|
|
240
|
-
userProps?: TGetter
|
|
241
|
-
) => undefined | PropGetterValue<CellProps, TGetter>
|
|
242
|
-
getTableWidth: () => number
|
|
243
|
-
getLeftTableWidth: () => number
|
|
244
|
-
getCenterTableWidth: () => number
|
|
245
|
-
getRightTableWidth: () => number
|
|
246
|
-
}
|
|
86
|
+
export type TableCore<TGenerics extends PartialGenerics> = {
|
|
87
|
+
initialState: TableState
|
|
88
|
+
reset: () => void
|
|
89
|
+
options: RequiredKeys<Options<TGenerics>, 'state'>
|
|
90
|
+
setOptions: (newOptions: Updater<Options<TGenerics>>) => void
|
|
91
|
+
getRowId: (
|
|
92
|
+
_: TGenerics['Row'],
|
|
93
|
+
index: number,
|
|
94
|
+
parent?: Row<TGenerics>
|
|
95
|
+
) => string
|
|
96
|
+
getState: () => TableState
|
|
97
|
+
setState: (updater: Updater<TableState>) => void
|
|
98
|
+
getDefaultColumn: () => Partial<ColumnDef<TGenerics>>
|
|
99
|
+
getColumnDefs: () => ColumnDef<TGenerics>[]
|
|
100
|
+
createColumn: (
|
|
101
|
+
columnDef: ColumnDef<TGenerics>,
|
|
102
|
+
depth: number,
|
|
103
|
+
parent?: Column<TGenerics>
|
|
104
|
+
) => Column<TGenerics>
|
|
105
|
+
getAllColumns: () => Column<TGenerics>[]
|
|
106
|
+
getAllFlatColumns: () => Column<TGenerics>[]
|
|
107
|
+
getAllFlatColumnsById: () => Record<string, Column<TGenerics>>
|
|
108
|
+
getAllLeafColumns: () => Column<TGenerics>[]
|
|
109
|
+
getColumn: (columnId: string) => Column<TGenerics>
|
|
110
|
+
getColumnWidth: (columnId: string) => number
|
|
111
|
+
getTotalWidth: () => number
|
|
112
|
+
createCell: (
|
|
113
|
+
row: Row<TGenerics>,
|
|
114
|
+
column: Column<TGenerics>,
|
|
115
|
+
value: any
|
|
116
|
+
) => Cell<TGenerics>
|
|
117
|
+
createRow: (
|
|
118
|
+
id: string,
|
|
119
|
+
original: TGenerics['Row'] | undefined,
|
|
120
|
+
rowIndex: number,
|
|
121
|
+
depth: number,
|
|
122
|
+
values: Record<string, any>
|
|
123
|
+
) => Row<TGenerics>
|
|
124
|
+
getCoreRowModel: () => RowModel<TGenerics>
|
|
125
|
+
getRowModel: () => RowModel<TGenerics>
|
|
126
|
+
getRow: (id: string) => Row<TGenerics>
|
|
127
|
+
getCell: (rowId: string, columnId: string) => Cell<TGenerics>
|
|
128
|
+
getTableProps: PropGetter<TableProps>
|
|
129
|
+
getTableBodyProps: PropGetter<TableBodyProps>
|
|
130
|
+
getRowProps: <TGetter extends Getter<RowProps>>(
|
|
131
|
+
rowId: string,
|
|
132
|
+
userProps?: TGetter
|
|
133
|
+
) => undefined | PropGetterValue<RowProps, TGetter>
|
|
134
|
+
getCellProps: <TGetter extends Getter<CellProps>>(
|
|
135
|
+
rowId: string,
|
|
136
|
+
columnId: string,
|
|
137
|
+
userProps?: TGetter
|
|
138
|
+
) => undefined | PropGetterValue<CellProps, TGetter>
|
|
139
|
+
getTableWidth: () => number
|
|
140
|
+
getLeftTableWidth: () => number
|
|
141
|
+
getCenterTableWidth: () => number
|
|
142
|
+
getRightTableWidth: () => number
|
|
143
|
+
}
|
|
247
144
|
|
|
248
|
-
export type CoreRow<
|
|
145
|
+
export type CoreRow<TGenerics extends PartialGenerics> = {
|
|
249
146
|
id: string
|
|
250
147
|
index: number
|
|
251
|
-
original?:
|
|
148
|
+
original?: TGenerics['Row']
|
|
252
149
|
depth: number
|
|
253
150
|
values: RowValues
|
|
254
|
-
leafRows: Row<
|
|
255
|
-
subRows: Row<
|
|
151
|
+
leafRows: Row<TGenerics>[]
|
|
152
|
+
subRows: Row<TGenerics>[]
|
|
256
153
|
getRowProps: PropGetter<RowProps>
|
|
257
|
-
originalSubRows?:
|
|
258
|
-
getAllCells: () => Cell<
|
|
259
|
-
|
|
260
|
-
TValue,
|
|
261
|
-
TFilterFns,
|
|
262
|
-
TSortingFns,
|
|
263
|
-
TAggregationFns
|
|
264
|
-
>[]
|
|
265
|
-
getAllCellsByColumnId: () => Record<
|
|
266
|
-
string,
|
|
267
|
-
Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
268
|
-
>
|
|
154
|
+
originalSubRows?: TGenerics['Row'][]
|
|
155
|
+
getAllCells: () => Cell<TGenerics>[]
|
|
156
|
+
getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>
|
|
269
157
|
}
|
|
270
158
|
|
|
271
|
-
export type CoreColumnDef<
|
|
272
|
-
TData,
|
|
273
|
-
TValue,
|
|
274
|
-
TFilterFns,
|
|
275
|
-
TSortingFns,
|
|
276
|
-
TAggregationFns
|
|
277
|
-
> = {
|
|
159
|
+
export type CoreColumnDef<TGenerics extends PartialGenerics> = {
|
|
278
160
|
id: string
|
|
279
|
-
accessorKey?: string & keyof
|
|
280
|
-
accessorFn?: AccessorFn<
|
|
161
|
+
accessorKey?: string & keyof TGenerics['Row']
|
|
162
|
+
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
281
163
|
header?:
|
|
282
164
|
| string
|
|
283
165
|
| Renderable<{
|
|
284
|
-
instance:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
TFilterFns,
|
|
288
|
-
TSortingFns,
|
|
289
|
-
TAggregationFns
|
|
290
|
-
>
|
|
291
|
-
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
292
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
166
|
+
instance: TableInstance<TGenerics>
|
|
167
|
+
header: Header<TGenerics>
|
|
168
|
+
column: Column<TGenerics>
|
|
293
169
|
}>
|
|
294
|
-
__generated: true
|
|
295
170
|
width?: number
|
|
296
171
|
minWidth?: number
|
|
297
172
|
maxWidth?: number
|
|
298
|
-
columns?: ColumnDef<
|
|
173
|
+
columns?: ColumnDef<TGenerics>[]
|
|
299
174
|
footer?: Renderable<{
|
|
300
|
-
instance:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
TFilterFns,
|
|
304
|
-
TSortingFns,
|
|
305
|
-
TAggregationFns
|
|
306
|
-
>
|
|
307
|
-
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
308
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
175
|
+
instance: TableInstance<TGenerics>
|
|
176
|
+
header: Header<TGenerics>
|
|
177
|
+
column: Column<TGenerics>
|
|
309
178
|
}>
|
|
310
179
|
cell?: Renderable<{
|
|
311
|
-
instance:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
TAggregationFns
|
|
317
|
-
>
|
|
318
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
319
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
320
|
-
cell: Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
321
|
-
value: TValue
|
|
180
|
+
instance: TableInstance<TGenerics>
|
|
181
|
+
row: Row<TGenerics>
|
|
182
|
+
column: Column<TGenerics>
|
|
183
|
+
cell: Cell<TGenerics>
|
|
184
|
+
value: TGenerics['Value']
|
|
322
185
|
}>
|
|
323
186
|
defaultIsVisible?: boolean
|
|
187
|
+
[Please_use_the_create_table_column_utilities_to_define_columns]: true
|
|
324
188
|
}
|
|
325
189
|
|
|
326
|
-
export type CoreColumn<
|
|
327
|
-
TData,
|
|
328
|
-
TValue,
|
|
329
|
-
TFilterFns,
|
|
330
|
-
TSortingFns,
|
|
331
|
-
TAggregationFns
|
|
332
|
-
> = {
|
|
190
|
+
export type CoreColumn<TGenerics extends PartialGenerics> = {
|
|
333
191
|
id: string
|
|
334
192
|
depth: number
|
|
335
|
-
accessorFn?: AccessorFn<
|
|
336
|
-
columnDef: ColumnDef<
|
|
193
|
+
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
194
|
+
columnDef: ColumnDef<TGenerics>
|
|
337
195
|
getWidth: () => number
|
|
338
|
-
columns: Column<
|
|
339
|
-
parent?: Column<
|
|
340
|
-
getFlatColumns: () => Column<
|
|
341
|
-
|
|
342
|
-
TValue,
|
|
343
|
-
TFilterFns,
|
|
344
|
-
TSortingFns,
|
|
345
|
-
TAggregationFns
|
|
346
|
-
>[]
|
|
347
|
-
getLeafColumns: () => Column<
|
|
348
|
-
TData,
|
|
349
|
-
TValue,
|
|
350
|
-
TFilterFns,
|
|
351
|
-
TSortingFns,
|
|
352
|
-
TAggregationFns
|
|
353
|
-
>[]
|
|
196
|
+
columns: Column<TGenerics>[]
|
|
197
|
+
parent?: Column<TGenerics>
|
|
198
|
+
getFlatColumns: () => Column<TGenerics>[]
|
|
199
|
+
getLeafColumns: () => Column<TGenerics>[]
|
|
354
200
|
}
|
|
355
201
|
|
|
356
|
-
export function createTableInstance<
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
TSortingFns,
|
|
361
|
-
TAggregationFns
|
|
362
|
-
>(
|
|
363
|
-
options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
364
|
-
rerender: () => void
|
|
365
|
-
): ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
366
|
-
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
202
|
+
export function createTableInstance<TGenerics extends PartialGenerics>(
|
|
203
|
+
options: Options<TGenerics>
|
|
204
|
+
): TableInstance<TGenerics> {
|
|
205
|
+
if (options.debugAll || options.debugTable) {
|
|
367
206
|
console.info('Creating React Table Instance...')
|
|
368
207
|
}
|
|
369
208
|
|
|
370
|
-
let instance = {} as
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
TFilterFns,
|
|
374
|
-
TSortingFns,
|
|
375
|
-
TAggregationFns
|
|
376
|
-
>
|
|
209
|
+
let instance = {} as TableInstance<TGenerics>
|
|
210
|
+
|
|
211
|
+
let listeners: (() => void)[] = []
|
|
377
212
|
|
|
378
213
|
const defaultOptions = features.reduce((obj, feature) => {
|
|
379
214
|
return Object.assign(obj, (feature as any).getDefaultOptions?.(instance))
|
|
380
215
|
}, {})
|
|
381
216
|
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
const buildOptions = (
|
|
385
|
-
options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
386
|
-
) => ({
|
|
387
|
-
state: defaultState,
|
|
217
|
+
const buildOptions = (options: Options<TGenerics>) => ({
|
|
388
218
|
...defaultOptions,
|
|
389
219
|
...options,
|
|
390
220
|
})
|
|
@@ -398,92 +228,54 @@ export function createTableInstance<
|
|
|
398
228
|
...(options.initialState ?? {}),
|
|
399
229
|
} as TableState
|
|
400
230
|
|
|
401
|
-
const finalInstance:
|
|
402
|
-
TData,
|
|
403
|
-
TValue,
|
|
404
|
-
TFilterFns,
|
|
405
|
-
TSortingFns,
|
|
406
|
-
TAggregationFns
|
|
407
|
-
> = {
|
|
231
|
+
const finalInstance: TableInstance<TGenerics> = {
|
|
408
232
|
...instance,
|
|
409
233
|
...features.reduce((obj, feature) => {
|
|
410
234
|
return Object.assign(obj, (feature as any).getInstance?.(instance))
|
|
411
235
|
}, {}),
|
|
412
|
-
rerender,
|
|
413
236
|
initialState,
|
|
414
|
-
internalState: initialState,
|
|
415
237
|
reset: () => {
|
|
416
238
|
instance.setState(instance.initialState)
|
|
417
239
|
},
|
|
418
|
-
|
|
419
|
-
instance.options = buildOptions(
|
|
240
|
+
setOptions: updater => {
|
|
241
|
+
instance.options = buildOptions(
|
|
242
|
+
functionalUpdate(updater, instance.options)
|
|
243
|
+
)
|
|
420
244
|
},
|
|
421
245
|
|
|
422
|
-
getRowId: (
|
|
423
|
-
|
|
424
|
-
index: number,
|
|
425
|
-
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
426
|
-
) => `${parent ? [parent.id, index].join('.') : index}`,
|
|
246
|
+
getRowId: (_: TGenerics['Row'], index: number, parent?: Row<TGenerics>) =>
|
|
247
|
+
`${parent ? [parent.id, index].join('.') : index}`,
|
|
427
248
|
|
|
428
249
|
getState: () => {
|
|
429
|
-
|
|
430
|
-
...instance.internalState,
|
|
431
|
-
...instance.options.state,
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return state
|
|
250
|
+
return instance.options.state as TableState
|
|
435
251
|
},
|
|
436
252
|
|
|
437
|
-
setState: (
|
|
438
|
-
updater
|
|
439
|
-
shouldRerender: boolean = true
|
|
440
|
-
) => {
|
|
441
|
-
const onStateChange = instance.options.onStateChange
|
|
442
|
-
|
|
443
|
-
let internalState = instance.internalState
|
|
444
|
-
let newState = functionalUpdate(updater, internalState)
|
|
445
|
-
|
|
446
|
-
instance.internalState = newState
|
|
447
|
-
|
|
448
|
-
if (onStateChange) {
|
|
449
|
-
onStateChange(newState)
|
|
450
|
-
return
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (shouldRerender) {
|
|
454
|
-
instance.rerender()
|
|
455
|
-
}
|
|
253
|
+
setState: (updater: Updater<TableState>) => {
|
|
254
|
+
instance.options.onStateChange?.(updater)
|
|
456
255
|
},
|
|
457
256
|
|
|
458
257
|
getDefaultColumn: memo(
|
|
459
258
|
() => [instance.options.defaultColumn],
|
|
460
259
|
defaultColumn => {
|
|
461
|
-
defaultColumn = (defaultColumn ?? {}) as Partial<
|
|
462
|
-
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
463
|
-
>
|
|
260
|
+
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
|
|
464
261
|
|
|
465
262
|
return {
|
|
466
|
-
header: (
|
|
467
|
-
props
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
) => props.header.column.id,
|
|
471
|
-
footer: (
|
|
472
|
-
props: HeaderRenderProps<
|
|
473
|
-
Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
474
|
-
>
|
|
475
|
-
) => props.header.column.id,
|
|
263
|
+
header: (props: HeaderRenderProps<Header<TGenerics>>) =>
|
|
264
|
+
props.header.column.id,
|
|
265
|
+
footer: (props: HeaderRenderProps<Header<TGenerics>>) =>
|
|
266
|
+
props.header.column.id,
|
|
476
267
|
cell: ({ value = '' }: { value: any }): JSX.Element =>
|
|
477
268
|
typeof value === 'boolean' ? value.toString() : value,
|
|
478
269
|
...features.reduce((obj, feature) => {
|
|
479
270
|
return Object.assign(obj, (feature as any).getDefaultColumn?.())
|
|
480
271
|
}, {}),
|
|
481
272
|
...defaultColumn,
|
|
482
|
-
} as Partial<
|
|
483
|
-
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
484
|
-
>
|
|
273
|
+
} as Partial<ColumnDef<TGenerics>>
|
|
485
274
|
},
|
|
486
|
-
{
|
|
275
|
+
{
|
|
276
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
277
|
+
key: 'getDefaultColumn',
|
|
278
|
+
}
|
|
487
279
|
),
|
|
488
280
|
|
|
489
281
|
getColumnDefs: () => instance.options.columns,
|
|
@@ -496,12 +288,12 @@ export function createTableInstance<
|
|
|
496
288
|
columnDef.accessorKey ??
|
|
497
289
|
(typeof columnDef.header === 'string' ? columnDef.header : undefined)
|
|
498
290
|
|
|
499
|
-
let accessorFn: AccessorFn<
|
|
291
|
+
let accessorFn: AccessorFn<TGenerics['Row']> | undefined
|
|
500
292
|
|
|
501
293
|
if (columnDef.accessorFn) {
|
|
502
294
|
accessorFn = columnDef.accessorFn
|
|
503
295
|
} else if (columnDef.accessorKey) {
|
|
504
|
-
accessorFn = (originalRow?:
|
|
296
|
+
accessorFn = (originalRow?: TGenerics['Row']) =>
|
|
505
297
|
(originalRow as any)[columnDef.accessorKey]
|
|
506
298
|
}
|
|
507
299
|
|
|
@@ -516,13 +308,7 @@ export function createTableInstance<
|
|
|
516
308
|
throw new Error()
|
|
517
309
|
}
|
|
518
310
|
|
|
519
|
-
let column: CoreColumn<
|
|
520
|
-
TData,
|
|
521
|
-
TValue,
|
|
522
|
-
TFilterFns,
|
|
523
|
-
TSortingFns,
|
|
524
|
-
TAggregationFns
|
|
525
|
-
> = {
|
|
311
|
+
let column: CoreColumn<TGenerics> = {
|
|
526
312
|
...ColumnSizing.defaultColumnSizing,
|
|
527
313
|
...defaultColumn,
|
|
528
314
|
...columnDef,
|
|
@@ -537,19 +323,14 @@ export function createTableInstance<
|
|
|
537
323
|
() => [true],
|
|
538
324
|
() => {
|
|
539
325
|
return [
|
|
540
|
-
column as Column<
|
|
541
|
-
TData,
|
|
542
|
-
TValue,
|
|
543
|
-
TFilterFns,
|
|
544
|
-
TSortingFns,
|
|
545
|
-
TAggregationFns
|
|
546
|
-
>,
|
|
326
|
+
column as Column<TGenerics>,
|
|
547
327
|
...column.columns?.flatMap(d => d.getFlatColumns()),
|
|
548
328
|
]
|
|
549
329
|
},
|
|
550
330
|
{
|
|
551
331
|
key: 'column.getFlatColumns',
|
|
552
|
-
debug:
|
|
332
|
+
debug: () =>
|
|
333
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
553
334
|
}
|
|
554
335
|
),
|
|
555
336
|
getLeafColumns: memo(
|
|
@@ -563,19 +344,12 @@ export function createTableInstance<
|
|
|
563
344
|
return orderColumns(leafColumns)
|
|
564
345
|
}
|
|
565
346
|
|
|
566
|
-
return [
|
|
567
|
-
column as Column<
|
|
568
|
-
TData,
|
|
569
|
-
TValue,
|
|
570
|
-
TFilterFns,
|
|
571
|
-
TSortingFns,
|
|
572
|
-
TAggregationFns
|
|
573
|
-
>,
|
|
574
|
-
]
|
|
347
|
+
return [column as Column<TGenerics>]
|
|
575
348
|
},
|
|
576
349
|
{
|
|
577
350
|
key: 'column.getLeafColumns',
|
|
578
|
-
debug:
|
|
351
|
+
debug: () =>
|
|
352
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
579
353
|
}
|
|
580
354
|
),
|
|
581
355
|
}
|
|
@@ -588,44 +362,17 @@ export function createTableInstance<
|
|
|
588
362
|
}, column)
|
|
589
363
|
|
|
590
364
|
// Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
591
|
-
return column as Column<
|
|
592
|
-
TData,
|
|
593
|
-
TValue,
|
|
594
|
-
TFilterFns,
|
|
595
|
-
TSortingFns,
|
|
596
|
-
TAggregationFns
|
|
597
|
-
>
|
|
365
|
+
return column as Column<TGenerics>
|
|
598
366
|
},
|
|
599
367
|
|
|
600
368
|
getAllColumns: memo(
|
|
601
369
|
() => [instance.getColumnDefs()],
|
|
602
370
|
columnDefs => {
|
|
603
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
604
|
-
console.info('Building Columns...')
|
|
605
|
-
|
|
606
371
|
const recurseColumns = (
|
|
607
|
-
columnDefs: ColumnDef<
|
|
608
|
-
|
|
609
|
-
TValue,
|
|
610
|
-
TFilterFns,
|
|
611
|
-
TSortingFns,
|
|
612
|
-
TAggregationFns
|
|
613
|
-
>[],
|
|
614
|
-
parent?: Column<
|
|
615
|
-
TData,
|
|
616
|
-
TValue,
|
|
617
|
-
TFilterFns,
|
|
618
|
-
TSortingFns,
|
|
619
|
-
TAggregationFns
|
|
620
|
-
>,
|
|
372
|
+
columnDefs: ColumnDef<TGenerics>[],
|
|
373
|
+
parent?: Column<TGenerics>,
|
|
621
374
|
depth = 0
|
|
622
|
-
): Column<
|
|
623
|
-
TData,
|
|
624
|
-
TValue,
|
|
625
|
-
TFilterFns,
|
|
626
|
-
TSortingFns,
|
|
627
|
-
TAggregationFns
|
|
628
|
-
>[] => {
|
|
375
|
+
): Column<TGenerics>[] => {
|
|
629
376
|
return columnDefs.map(columnDef => {
|
|
630
377
|
const column = instance.createColumn(columnDef, depth, parent)
|
|
631
378
|
|
|
@@ -639,7 +386,10 @@ export function createTableInstance<
|
|
|
639
386
|
|
|
640
387
|
return recurseColumns(columnDefs)
|
|
641
388
|
},
|
|
642
|
-
{
|
|
389
|
+
{
|
|
390
|
+
key: 'getAllColumns',
|
|
391
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
392
|
+
}
|
|
643
393
|
),
|
|
644
394
|
|
|
645
395
|
getAllFlatColumns: memo(
|
|
@@ -649,7 +399,10 @@ export function createTableInstance<
|
|
|
649
399
|
return column.getFlatColumns()
|
|
650
400
|
})
|
|
651
401
|
},
|
|
652
|
-
{
|
|
402
|
+
{
|
|
403
|
+
key: 'getAllFlatColumns',
|
|
404
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
405
|
+
}
|
|
653
406
|
),
|
|
654
407
|
|
|
655
408
|
getAllFlatColumnsById: memo(
|
|
@@ -658,9 +411,12 @@ export function createTableInstance<
|
|
|
658
411
|
return flatColumns.reduce((acc, column) => {
|
|
659
412
|
acc[column.id] = column
|
|
660
413
|
return acc
|
|
661
|
-
}, {} as Record<string, Column<
|
|
414
|
+
}, {} as Record<string, Column<TGenerics>>)
|
|
662
415
|
},
|
|
663
|
-
{
|
|
416
|
+
{
|
|
417
|
+
key: 'getAllFlatColumnsById',
|
|
418
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
419
|
+
}
|
|
664
420
|
),
|
|
665
421
|
|
|
666
422
|
getAllLeafColumns: memo(
|
|
@@ -669,7 +425,10 @@ export function createTableInstance<
|
|
|
669
425
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns())
|
|
670
426
|
return orderColumns(leafColumns)
|
|
671
427
|
},
|
|
672
|
-
{
|
|
428
|
+
{
|
|
429
|
+
key: 'getAllLeafColumns',
|
|
430
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
431
|
+
}
|
|
673
432
|
),
|
|
674
433
|
|
|
675
434
|
getColumn: columnId => {
|
|
@@ -706,13 +465,7 @@ export function createTableInstance<
|
|
|
706
465
|
},
|
|
707
466
|
|
|
708
467
|
createCell: (row, column, value) => {
|
|
709
|
-
const cell: Cell<
|
|
710
|
-
TData,
|
|
711
|
-
TValue,
|
|
712
|
-
TFilterFns,
|
|
713
|
-
TSortingFns,
|
|
714
|
-
TAggregationFns
|
|
715
|
-
> = {
|
|
468
|
+
const cell: Cell<TGenerics> = {
|
|
716
469
|
id: `${row.id}_${column.id}`,
|
|
717
470
|
rowId: row.id,
|
|
718
471
|
columnId: column.id,
|
|
@@ -729,16 +482,9 @@ export function createTableInstance<
|
|
|
729
482
|
Object.assign(
|
|
730
483
|
cell,
|
|
731
484
|
(feature as any).createCell?.(
|
|
732
|
-
cell as Cell<
|
|
733
|
-
TData,
|
|
734
|
-
TValue,
|
|
735
|
-
TFilterFns,
|
|
736
|
-
TSortingFns,
|
|
737
|
-
TAggregationFns
|
|
738
|
-
> &
|
|
739
|
-
Grouping.GroupingCell,
|
|
485
|
+
cell as Cell<TGenerics> & Grouping.GroupingCell,
|
|
740
486
|
column,
|
|
741
|
-
row as Row<
|
|
487
|
+
row as Row<TGenerics>,
|
|
742
488
|
instance
|
|
743
489
|
)
|
|
744
490
|
)
|
|
@@ -748,13 +494,7 @@ export function createTableInstance<
|
|
|
748
494
|
},
|
|
749
495
|
|
|
750
496
|
createRow: (id, original, rowIndex, depth, values) => {
|
|
751
|
-
let row: CoreRow<
|
|
752
|
-
TData,
|
|
753
|
-
TValue,
|
|
754
|
-
TFilterFns,
|
|
755
|
-
TSortingFns,
|
|
756
|
-
TAggregationFns
|
|
757
|
-
> = {
|
|
497
|
+
let row: CoreRow<TGenerics> = {
|
|
758
498
|
id,
|
|
759
499
|
index: rowIndex,
|
|
760
500
|
original,
|
|
@@ -772,13 +512,7 @@ export function createTableInstance<
|
|
|
772
512
|
leafColumns => {
|
|
773
513
|
return leafColumns.map(column => {
|
|
774
514
|
return instance.createCell(
|
|
775
|
-
row as Row<
|
|
776
|
-
TData,
|
|
777
|
-
TValue,
|
|
778
|
-
TFilterFns,
|
|
779
|
-
TSortingFns,
|
|
780
|
-
TAggregationFns
|
|
781
|
-
>,
|
|
515
|
+
row as Row<TGenerics>,
|
|
782
516
|
column,
|
|
783
517
|
row.values[column.id]
|
|
784
518
|
)
|
|
@@ -786,7 +520,7 @@ export function createTableInstance<
|
|
|
786
520
|
},
|
|
787
521
|
{
|
|
788
522
|
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
|
|
789
|
-
debug: instance.options.
|
|
523
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
790
524
|
}
|
|
791
525
|
)
|
|
792
526
|
|
|
@@ -796,19 +530,20 @@ export function createTableInstance<
|
|
|
796
530
|
return allCells.reduce((acc, cell) => {
|
|
797
531
|
acc[cell.columnId] = cell
|
|
798
532
|
return acc
|
|
799
|
-
}, {} as Record<string, Cell<
|
|
533
|
+
}, {} as Record<string, Cell<TGenerics>>)
|
|
800
534
|
},
|
|
801
535
|
{
|
|
802
536
|
key: 'row.getAllCellsByColumnId',
|
|
803
|
-
debug: instance.options.
|
|
537
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
804
538
|
}
|
|
805
539
|
)
|
|
806
540
|
|
|
807
|
-
features.
|
|
541
|
+
for (let i = 0; i < features.length; i++) {
|
|
542
|
+
const feature = features[i]
|
|
808
543
|
Object.assign(row, (feature as any).createRow?.(row, instance))
|
|
809
|
-
}
|
|
544
|
+
}
|
|
810
545
|
|
|
811
|
-
return row as Row<
|
|
546
|
+
return row as Row<TGenerics>
|
|
812
547
|
},
|
|
813
548
|
|
|
814
549
|
getCoreRowModel: memo(
|
|
@@ -816,50 +551,23 @@ export function createTableInstance<
|
|
|
816
551
|
(
|
|
817
552
|
data
|
|
818
553
|
): {
|
|
819
|
-
rows: Row<
|
|
820
|
-
flatRows: Row<
|
|
821
|
-
rowsById: Record<
|
|
822
|
-
string,
|
|
823
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
824
|
-
>
|
|
554
|
+
rows: Row<TGenerics>[]
|
|
555
|
+
flatRows: Row<TGenerics>[]
|
|
556
|
+
rowsById: Record<string, Row<TGenerics>>
|
|
825
557
|
} => {
|
|
826
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
827
|
-
console.info('Accessing...')
|
|
828
|
-
|
|
829
558
|
// Access the row model using initial columns
|
|
830
|
-
const rows: Row<
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
TFilterFns,
|
|
834
|
-
TSortingFns,
|
|
835
|
-
TAggregationFns
|
|
836
|
-
>[] = []
|
|
837
|
-
const flatRows: Row<
|
|
838
|
-
TData,
|
|
839
|
-
TValue,
|
|
840
|
-
TFilterFns,
|
|
841
|
-
TSortingFns,
|
|
842
|
-
TAggregationFns
|
|
843
|
-
>[] = []
|
|
844
|
-
const rowsById: Record<
|
|
845
|
-
string,
|
|
846
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
847
|
-
> = {}
|
|
559
|
+
const rows: Row<TGenerics>[] = []
|
|
560
|
+
const flatRows: Row<TGenerics>[] = []
|
|
561
|
+
const rowsById: Record<string, Row<TGenerics>> = {}
|
|
848
562
|
|
|
849
563
|
const leafColumns = instance.getAllLeafColumns()
|
|
850
564
|
|
|
851
565
|
const accessRow = (
|
|
852
|
-
originalRow:
|
|
566
|
+
originalRow: TGenerics['Row'],
|
|
853
567
|
rowIndex: number,
|
|
854
568
|
depth = 0,
|
|
855
|
-
parentRows: Row<
|
|
856
|
-
|
|
857
|
-
TValue,
|
|
858
|
-
TFilterFns,
|
|
859
|
-
TSortingFns,
|
|
860
|
-
TAggregationFns
|
|
861
|
-
>[],
|
|
862
|
-
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
569
|
+
parentRows: Row<TGenerics>[],
|
|
570
|
+
parent?: Row<TGenerics>
|
|
863
571
|
) => {
|
|
864
572
|
const id = instance.getRowId(originalRow, rowIndex, parent)
|
|
865
573
|
|
|
@@ -904,17 +612,11 @@ export function createTableInstance<
|
|
|
904
612
|
// Then recursively access them
|
|
905
613
|
if (originalSubRows?.length) {
|
|
906
614
|
row.originalSubRows = originalSubRows
|
|
907
|
-
const subRows: Row<
|
|
908
|
-
TData,
|
|
909
|
-
TValue,
|
|
910
|
-
TFilterFns,
|
|
911
|
-
TSortingFns,
|
|
912
|
-
TAggregationFns
|
|
913
|
-
>[] = []
|
|
615
|
+
const subRows: Row<TGenerics>[] = []
|
|
914
616
|
|
|
915
617
|
for (let i = 0; i < row.originalSubRows.length; i++) {
|
|
916
618
|
accessRow(
|
|
917
|
-
row.originalSubRows[i] as
|
|
619
|
+
row.originalSubRows[i] as TGenerics['Row'],
|
|
918
620
|
i,
|
|
919
621
|
depth + 1,
|
|
920
622
|
subRows,
|
|
@@ -929,14 +631,14 @@ export function createTableInstance<
|
|
|
929
631
|
}
|
|
930
632
|
|
|
931
633
|
for (let i = 0; i < data.length; i++) {
|
|
932
|
-
accessRow(data[i] as
|
|
634
|
+
accessRow(data[i] as TGenerics['Row'], i, 0, rows)
|
|
933
635
|
}
|
|
934
636
|
|
|
935
637
|
return { rows, flatRows, rowsById }
|
|
936
638
|
},
|
|
937
639
|
{
|
|
938
640
|
key: 'getRowModel',
|
|
939
|
-
debug: instance.options.
|
|
641
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
940
642
|
onChange: () => {
|
|
941
643
|
instance._notifyRowSelectionReset()
|
|
942
644
|
instance._notifyFiltersReset()
|
|
@@ -944,20 +646,6 @@ export function createTableInstance<
|
|
|
944
646
|
}
|
|
945
647
|
),
|
|
946
648
|
|
|
947
|
-
// The standard
|
|
948
|
-
|
|
949
|
-
getCoreRows: () => {
|
|
950
|
-
return instance.getCoreRowModel().rows
|
|
951
|
-
},
|
|
952
|
-
|
|
953
|
-
getCoreFlatRows: () => {
|
|
954
|
-
return instance.getCoreRowModel().flatRows
|
|
955
|
-
},
|
|
956
|
-
|
|
957
|
-
getCoreRowsById: () => {
|
|
958
|
-
return instance.getCoreRowModel().rowsById
|
|
959
|
-
},
|
|
960
|
-
|
|
961
649
|
// The final calls start at the bottom of the model,
|
|
962
650
|
// expanded rows, which then work their way up
|
|
963
651
|
|
|
@@ -965,20 +653,8 @@ export function createTableInstance<
|
|
|
965
653
|
return instance.getPaginationRowModel()
|
|
966
654
|
},
|
|
967
655
|
|
|
968
|
-
getRows: () => {
|
|
969
|
-
return instance.getRowModel().rows
|
|
970
|
-
},
|
|
971
|
-
|
|
972
|
-
getFlatRows: () => {
|
|
973
|
-
return instance.getRowModel().flatRows
|
|
974
|
-
},
|
|
975
|
-
|
|
976
|
-
getRowsById: () => {
|
|
977
|
-
return instance.getRowModel().rowsById
|
|
978
|
-
},
|
|
979
|
-
|
|
980
656
|
getRow: (id: string) => {
|
|
981
|
-
const row = instance.
|
|
657
|
+
const row = instance.getRowModel().rowsById[id]
|
|
982
658
|
|
|
983
659
|
if (!row) {
|
|
984
660
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -1083,9 +759,5 @@ export function createTableInstance<
|
|
|
1083
759
|
|
|
1084
760
|
instance = Object.assign(instance, finalInstance)
|
|
1085
761
|
|
|
1086
|
-
// This won't trigger a rerender yet, but it will force
|
|
1087
|
-
// pagination derivation to run (particularly pageSize detection)
|
|
1088
|
-
instance.setPagination(d => d)
|
|
1089
|
-
|
|
1090
762
|
return instance
|
|
1091
763
|
}
|