@tanstack/react-table 8.0.0-alpha.8 → 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 +65 -80
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +44 -30
- 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 +1382 -1357
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +337 -321
- package/build/types/core.d.ts +63 -68
- 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 +1395 -1359
- 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 -7
- package/src/core.tsx +189 -522
- package/src/createTable.tsx +133 -191
- 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,323 +59,154 @@ 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
|
-
TFilterFns,
|
|
144
|
-
TSortingFns,
|
|
145
|
-
TAggregationFns
|
|
146
|
-
>[]
|
|
147
|
-
getAllFlatColumnsById: () => Record<
|
|
148
|
-
string,
|
|
149
|
-
Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
150
|
-
>
|
|
151
|
-
getAllLeafColumns: () => Column<
|
|
152
|
-
TData,
|
|
153
|
-
TValue,
|
|
154
|
-
TFilterFns,
|
|
155
|
-
TSortingFns,
|
|
156
|
-
TAggregationFns
|
|
157
|
-
>[]
|
|
158
|
-
getColumn: (
|
|
159
|
-
columnId: string
|
|
160
|
-
) => Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
161
|
-
getColumnWidth: (columnId: string) => number
|
|
162
|
-
getTotalWidth: () => number
|
|
163
|
-
createCell: (
|
|
164
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
165
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
166
|
-
value: any
|
|
167
|
-
) => Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
168
|
-
createRow: (
|
|
169
|
-
id: string,
|
|
170
|
-
original: TData | undefined,
|
|
171
|
-
rowIndex: number,
|
|
172
|
-
depth: number,
|
|
173
|
-
values: Record<string, any>
|
|
174
|
-
) => Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
175
|
-
getCoreRowModel: () => RowModel<
|
|
176
|
-
TData,
|
|
177
|
-
TValue,
|
|
178
|
-
TFilterFns,
|
|
179
|
-
TSortingFns,
|
|
180
|
-
TAggregationFns
|
|
181
|
-
>
|
|
182
|
-
getCoreRows: () => Row<
|
|
183
|
-
TData,
|
|
184
|
-
TValue,
|
|
185
|
-
TFilterFns,
|
|
186
|
-
TSortingFns,
|
|
187
|
-
TAggregationFns
|
|
188
|
-
>[]
|
|
189
|
-
getCoreFlatRows: () => Row<
|
|
190
|
-
TData,
|
|
191
|
-
TValue,
|
|
192
|
-
TFilterFns,
|
|
193
|
-
TSortingFns,
|
|
194
|
-
TAggregationFns
|
|
195
|
-
>[]
|
|
196
|
-
getCoreRowsById: () => Record<
|
|
197
|
-
string,
|
|
198
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
199
|
-
>
|
|
200
|
-
getRowModel: () => RowModel<
|
|
201
|
-
TData,
|
|
202
|
-
TValue,
|
|
203
|
-
TFilterFns,
|
|
204
|
-
TSortingFns,
|
|
205
|
-
TAggregationFns
|
|
206
|
-
>
|
|
207
|
-
getRows: () => Row<
|
|
208
|
-
TData,
|
|
209
|
-
TValue,
|
|
210
|
-
TFilterFns,
|
|
211
|
-
TSortingFns,
|
|
212
|
-
TAggregationFns
|
|
213
|
-
>[]
|
|
214
|
-
getFlatRows: () => Row<
|
|
215
|
-
TData,
|
|
216
|
-
TValue,
|
|
217
|
-
TFilterFns,
|
|
218
|
-
TSortingFns,
|
|
219
|
-
TAggregationFns
|
|
220
|
-
>[]
|
|
221
|
-
getRowsById: () => Record<
|
|
222
|
-
string,
|
|
223
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
224
|
-
>
|
|
225
|
-
getRow: (
|
|
226
|
-
id: string
|
|
227
|
-
) => Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
228
|
-
getCell: (
|
|
229
|
-
rowId: string,
|
|
230
|
-
columnId: string
|
|
231
|
-
) => Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
232
|
-
getTableProps: PropGetter<TableProps>
|
|
233
|
-
getTableBodyProps: PropGetter<TableBodyProps>
|
|
234
|
-
getRowProps: <TGetter extends Getter<RowProps>>(
|
|
235
|
-
rowId: string,
|
|
236
|
-
userProps?: TGetter
|
|
237
|
-
) => undefined | PropGetterValue<RowProps, TGetter>
|
|
238
|
-
getCellProps: <TGetter extends Getter<CellProps>>(
|
|
239
|
-
rowId: string,
|
|
240
|
-
columnId: string,
|
|
241
|
-
userProps?: TGetter
|
|
242
|
-
) => undefined | PropGetterValue<CellProps, TGetter>
|
|
243
|
-
getTableWidth: () => number
|
|
244
|
-
getLeftTableWidth: () => number
|
|
245
|
-
getCenterTableWidth: () => number
|
|
246
|
-
getRightTableWidth: () => number
|
|
247
|
-
}
|
|
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
|
+
}
|
|
248
144
|
|
|
249
|
-
export type CoreRow<
|
|
145
|
+
export type CoreRow<TGenerics extends PartialGenerics> = {
|
|
250
146
|
id: string
|
|
251
147
|
index: number
|
|
252
|
-
original?:
|
|
148
|
+
original?: TGenerics['Row']
|
|
253
149
|
depth: number
|
|
254
150
|
values: RowValues
|
|
255
|
-
leafRows: Row<
|
|
256
|
-
subRows: Row<
|
|
151
|
+
leafRows: Row<TGenerics>[]
|
|
152
|
+
subRows: Row<TGenerics>[]
|
|
257
153
|
getRowProps: PropGetter<RowProps>
|
|
258
|
-
originalSubRows?:
|
|
259
|
-
getAllCells: () => Cell<
|
|
260
|
-
|
|
261
|
-
TValue,
|
|
262
|
-
TFilterFns,
|
|
263
|
-
TSortingFns,
|
|
264
|
-
TAggregationFns
|
|
265
|
-
>[]
|
|
266
|
-
getAllCellsByColumnId: () => Record<
|
|
267
|
-
string,
|
|
268
|
-
Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
269
|
-
>
|
|
154
|
+
originalSubRows?: TGenerics['Row'][]
|
|
155
|
+
getAllCells: () => Cell<TGenerics>[]
|
|
156
|
+
getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>
|
|
270
157
|
}
|
|
271
158
|
|
|
272
|
-
export type CoreColumnDef<
|
|
273
|
-
TData,
|
|
274
|
-
TValue,
|
|
275
|
-
TFilterFns,
|
|
276
|
-
TSortingFns,
|
|
277
|
-
TAggregationFns
|
|
278
|
-
> = {
|
|
159
|
+
export type CoreColumnDef<TGenerics extends PartialGenerics> = {
|
|
279
160
|
id: string
|
|
280
|
-
accessorKey?: string & keyof
|
|
281
|
-
accessorFn?: AccessorFn<
|
|
161
|
+
accessorKey?: string & keyof TGenerics['Row']
|
|
162
|
+
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
282
163
|
header?:
|
|
283
164
|
| string
|
|
284
165
|
| Renderable<{
|
|
285
|
-
instance:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
TFilterFns,
|
|
289
|
-
TSortingFns,
|
|
290
|
-
TAggregationFns
|
|
291
|
-
>
|
|
292
|
-
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
293
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
166
|
+
instance: TableInstance<TGenerics>
|
|
167
|
+
header: Header<TGenerics>
|
|
168
|
+
column: Column<TGenerics>
|
|
294
169
|
}>
|
|
295
|
-
__generated: true
|
|
296
170
|
width?: number
|
|
297
171
|
minWidth?: number
|
|
298
172
|
maxWidth?: number
|
|
299
|
-
columns?: ColumnDef<
|
|
173
|
+
columns?: ColumnDef<TGenerics>[]
|
|
300
174
|
footer?: Renderable<{
|
|
301
|
-
instance:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
TFilterFns,
|
|
305
|
-
TSortingFns,
|
|
306
|
-
TAggregationFns
|
|
307
|
-
>
|
|
308
|
-
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
309
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
175
|
+
instance: TableInstance<TGenerics>
|
|
176
|
+
header: Header<TGenerics>
|
|
177
|
+
column: Column<TGenerics>
|
|
310
178
|
}>
|
|
311
179
|
cell?: Renderable<{
|
|
312
|
-
instance:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
TAggregationFns
|
|
318
|
-
>
|
|
319
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
320
|
-
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
321
|
-
cell: Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
322
|
-
value: TValue
|
|
180
|
+
instance: TableInstance<TGenerics>
|
|
181
|
+
row: Row<TGenerics>
|
|
182
|
+
column: Column<TGenerics>
|
|
183
|
+
cell: Cell<TGenerics>
|
|
184
|
+
value: TGenerics['Value']
|
|
323
185
|
}>
|
|
324
186
|
defaultIsVisible?: boolean
|
|
187
|
+
[Please_use_the_create_table_column_utilities_to_define_columns]: true
|
|
325
188
|
}
|
|
326
189
|
|
|
327
|
-
export type CoreColumn<
|
|
328
|
-
TData,
|
|
329
|
-
TValue,
|
|
330
|
-
TFilterFns,
|
|
331
|
-
TSortingFns,
|
|
332
|
-
TAggregationFns
|
|
333
|
-
> = {
|
|
190
|
+
export type CoreColumn<TGenerics extends PartialGenerics> = {
|
|
334
191
|
id: string
|
|
335
192
|
depth: number
|
|
336
|
-
accessorFn?: AccessorFn<
|
|
337
|
-
columnDef: ColumnDef<
|
|
193
|
+
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
194
|
+
columnDef: ColumnDef<TGenerics>
|
|
338
195
|
getWidth: () => number
|
|
339
|
-
columns: Column<
|
|
340
|
-
parent?: Column<
|
|
341
|
-
getFlatColumns: () => Column<
|
|
342
|
-
|
|
343
|
-
TValue,
|
|
344
|
-
TFilterFns,
|
|
345
|
-
TSortingFns,
|
|
346
|
-
TAggregationFns
|
|
347
|
-
>[]
|
|
348
|
-
getLeafColumns: () => Column<
|
|
349
|
-
TData,
|
|
350
|
-
TValue,
|
|
351
|
-
TFilterFns,
|
|
352
|
-
TSortingFns,
|
|
353
|
-
TAggregationFns
|
|
354
|
-
>[]
|
|
196
|
+
columns: Column<TGenerics>[]
|
|
197
|
+
parent?: Column<TGenerics>
|
|
198
|
+
getFlatColumns: () => Column<TGenerics>[]
|
|
199
|
+
getLeafColumns: () => Column<TGenerics>[]
|
|
355
200
|
}
|
|
356
201
|
|
|
357
|
-
export function createTableInstance<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
TSortingFns,
|
|
362
|
-
TAggregationFns
|
|
363
|
-
>(
|
|
364
|
-
options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
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
|
-
TData,
|
|
372
|
-
TValue,
|
|
373
|
-
TFilterFns,
|
|
374
|
-
TSortingFns,
|
|
375
|
-
TAggregationFns
|
|
376
|
-
>
|
|
209
|
+
let instance = {} as TableInstance<TGenerics>
|
|
377
210
|
|
|
378
211
|
let listeners: (() => void)[] = []
|
|
379
212
|
|
|
@@ -381,12 +214,7 @@ export function createTableInstance<
|
|
|
381
214
|
return Object.assign(obj, (feature as any).getDefaultOptions?.(instance))
|
|
382
215
|
}, {})
|
|
383
216
|
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const buildOptions = (
|
|
387
|
-
options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
388
|
-
) => ({
|
|
389
|
-
state: defaultState,
|
|
217
|
+
const buildOptions = (options: Options<TGenerics>) => ({
|
|
390
218
|
...defaultOptions,
|
|
391
219
|
...options,
|
|
392
220
|
})
|
|
@@ -400,95 +228,54 @@ export function createTableInstance<
|
|
|
400
228
|
...(options.initialState ?? {}),
|
|
401
229
|
} as TableState
|
|
402
230
|
|
|
403
|
-
const finalInstance:
|
|
404
|
-
TData,
|
|
405
|
-
TValue,
|
|
406
|
-
TFilterFns,
|
|
407
|
-
TSortingFns,
|
|
408
|
-
TAggregationFns
|
|
409
|
-
> = {
|
|
231
|
+
const finalInstance: TableInstance<TGenerics> = {
|
|
410
232
|
...instance,
|
|
411
|
-
subscribe: cb => {
|
|
412
|
-
listeners.push(cb)
|
|
413
|
-
return () => {
|
|
414
|
-
listeners = listeners.filter(l => l !== cb)
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
notify: () => {
|
|
418
|
-
listeners.forEach(l => l())
|
|
419
|
-
},
|
|
420
233
|
...features.reduce((obj, feature) => {
|
|
421
234
|
return Object.assign(obj, (feature as any).getInstance?.(instance))
|
|
422
235
|
}, {}),
|
|
423
236
|
initialState,
|
|
424
|
-
internalState: initialState,
|
|
425
237
|
reset: () => {
|
|
426
238
|
instance.setState(instance.initialState)
|
|
427
239
|
},
|
|
428
|
-
|
|
429
|
-
instance.options = buildOptions(
|
|
240
|
+
setOptions: updater => {
|
|
241
|
+
instance.options = buildOptions(
|
|
242
|
+
functionalUpdate(updater, instance.options)
|
|
243
|
+
)
|
|
430
244
|
},
|
|
431
245
|
|
|
432
|
-
getRowId: (
|
|
433
|
-
|
|
434
|
-
index: number,
|
|
435
|
-
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
436
|
-
) => `${parent ? [parent.id, index].join('.') : index}`,
|
|
246
|
+
getRowId: (_: TGenerics['Row'], index: number, parent?: Row<TGenerics>) =>
|
|
247
|
+
`${parent ? [parent.id, index].join('.') : index}`,
|
|
437
248
|
|
|
438
249
|
getState: () => {
|
|
439
|
-
|
|
440
|
-
...instance.internalState,
|
|
441
|
-
...instance.options.state,
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return state
|
|
250
|
+
return instance.options.state as TableState
|
|
445
251
|
},
|
|
446
252
|
|
|
447
253
|
setState: (updater: Updater<TableState>) => {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
let internalState = instance.internalState
|
|
451
|
-
let newState = functionalUpdate(updater, internalState)
|
|
452
|
-
|
|
453
|
-
instance.internalState = newState
|
|
454
|
-
|
|
455
|
-
if (onStateChange) {
|
|
456
|
-
onStateChange(newState)
|
|
457
|
-
return
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
instance.notify()
|
|
254
|
+
instance.options.onStateChange?.(updater)
|
|
461
255
|
},
|
|
462
256
|
|
|
463
257
|
getDefaultColumn: memo(
|
|
464
258
|
() => [instance.options.defaultColumn],
|
|
465
259
|
defaultColumn => {
|
|
466
|
-
defaultColumn = (defaultColumn ?? {}) as Partial<
|
|
467
|
-
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
468
|
-
>
|
|
260
|
+
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
|
|
469
261
|
|
|
470
262
|
return {
|
|
471
|
-
header: (
|
|
472
|
-
props
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
) => props.header.column.id,
|
|
476
|
-
footer: (
|
|
477
|
-
props: HeaderRenderProps<
|
|
478
|
-
Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
479
|
-
>
|
|
480
|
-
) => 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,
|
|
481
267
|
cell: ({ value = '' }: { value: any }): JSX.Element =>
|
|
482
268
|
typeof value === 'boolean' ? value.toString() : value,
|
|
483
269
|
...features.reduce((obj, feature) => {
|
|
484
270
|
return Object.assign(obj, (feature as any).getDefaultColumn?.())
|
|
485
271
|
}, {}),
|
|
486
272
|
...defaultColumn,
|
|
487
|
-
} as Partial<
|
|
488
|
-
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
489
|
-
>
|
|
273
|
+
} as Partial<ColumnDef<TGenerics>>
|
|
490
274
|
},
|
|
491
|
-
{
|
|
275
|
+
{
|
|
276
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
277
|
+
key: 'getDefaultColumn',
|
|
278
|
+
}
|
|
492
279
|
),
|
|
493
280
|
|
|
494
281
|
getColumnDefs: () => instance.options.columns,
|
|
@@ -501,12 +288,12 @@ export function createTableInstance<
|
|
|
501
288
|
columnDef.accessorKey ??
|
|
502
289
|
(typeof columnDef.header === 'string' ? columnDef.header : undefined)
|
|
503
290
|
|
|
504
|
-
let accessorFn: AccessorFn<
|
|
291
|
+
let accessorFn: AccessorFn<TGenerics['Row']> | undefined
|
|
505
292
|
|
|
506
293
|
if (columnDef.accessorFn) {
|
|
507
294
|
accessorFn = columnDef.accessorFn
|
|
508
295
|
} else if (columnDef.accessorKey) {
|
|
509
|
-
accessorFn = (originalRow?:
|
|
296
|
+
accessorFn = (originalRow?: TGenerics['Row']) =>
|
|
510
297
|
(originalRow as any)[columnDef.accessorKey]
|
|
511
298
|
}
|
|
512
299
|
|
|
@@ -521,13 +308,7 @@ export function createTableInstance<
|
|
|
521
308
|
throw new Error()
|
|
522
309
|
}
|
|
523
310
|
|
|
524
|
-
let column: CoreColumn<
|
|
525
|
-
TData,
|
|
526
|
-
TValue,
|
|
527
|
-
TFilterFns,
|
|
528
|
-
TSortingFns,
|
|
529
|
-
TAggregationFns
|
|
530
|
-
> = {
|
|
311
|
+
let column: CoreColumn<TGenerics> = {
|
|
531
312
|
...ColumnSizing.defaultColumnSizing,
|
|
532
313
|
...defaultColumn,
|
|
533
314
|
...columnDef,
|
|
@@ -542,19 +323,14 @@ export function createTableInstance<
|
|
|
542
323
|
() => [true],
|
|
543
324
|
() => {
|
|
544
325
|
return [
|
|
545
|
-
column as Column<
|
|
546
|
-
TData,
|
|
547
|
-
TValue,
|
|
548
|
-
TFilterFns,
|
|
549
|
-
TSortingFns,
|
|
550
|
-
TAggregationFns
|
|
551
|
-
>,
|
|
326
|
+
column as Column<TGenerics>,
|
|
552
327
|
...column.columns?.flatMap(d => d.getFlatColumns()),
|
|
553
328
|
]
|
|
554
329
|
},
|
|
555
330
|
{
|
|
556
331
|
key: 'column.getFlatColumns',
|
|
557
|
-
debug:
|
|
332
|
+
debug: () =>
|
|
333
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
558
334
|
}
|
|
559
335
|
),
|
|
560
336
|
getLeafColumns: memo(
|
|
@@ -568,19 +344,12 @@ export function createTableInstance<
|
|
|
568
344
|
return orderColumns(leafColumns)
|
|
569
345
|
}
|
|
570
346
|
|
|
571
|
-
return [
|
|
572
|
-
column as Column<
|
|
573
|
-
TData,
|
|
574
|
-
TValue,
|
|
575
|
-
TFilterFns,
|
|
576
|
-
TSortingFns,
|
|
577
|
-
TAggregationFns
|
|
578
|
-
>,
|
|
579
|
-
]
|
|
347
|
+
return [column as Column<TGenerics>]
|
|
580
348
|
},
|
|
581
349
|
{
|
|
582
350
|
key: 'column.getLeafColumns',
|
|
583
|
-
debug:
|
|
351
|
+
debug: () =>
|
|
352
|
+
instance.options.debugAll ?? instance.options.debugColumns,
|
|
584
353
|
}
|
|
585
354
|
),
|
|
586
355
|
}
|
|
@@ -593,44 +362,17 @@ export function createTableInstance<
|
|
|
593
362
|
}, column)
|
|
594
363
|
|
|
595
364
|
// Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
596
|
-
return column as Column<
|
|
597
|
-
TData,
|
|
598
|
-
TValue,
|
|
599
|
-
TFilterFns,
|
|
600
|
-
TSortingFns,
|
|
601
|
-
TAggregationFns
|
|
602
|
-
>
|
|
365
|
+
return column as Column<TGenerics>
|
|
603
366
|
},
|
|
604
367
|
|
|
605
368
|
getAllColumns: memo(
|
|
606
369
|
() => [instance.getColumnDefs()],
|
|
607
370
|
columnDefs => {
|
|
608
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
609
|
-
console.info('Building Columns...')
|
|
610
|
-
|
|
611
371
|
const recurseColumns = (
|
|
612
|
-
columnDefs: ColumnDef<
|
|
613
|
-
|
|
614
|
-
TValue,
|
|
615
|
-
TFilterFns,
|
|
616
|
-
TSortingFns,
|
|
617
|
-
TAggregationFns
|
|
618
|
-
>[],
|
|
619
|
-
parent?: Column<
|
|
620
|
-
TData,
|
|
621
|
-
TValue,
|
|
622
|
-
TFilterFns,
|
|
623
|
-
TSortingFns,
|
|
624
|
-
TAggregationFns
|
|
625
|
-
>,
|
|
372
|
+
columnDefs: ColumnDef<TGenerics>[],
|
|
373
|
+
parent?: Column<TGenerics>,
|
|
626
374
|
depth = 0
|
|
627
|
-
): Column<
|
|
628
|
-
TData,
|
|
629
|
-
TValue,
|
|
630
|
-
TFilterFns,
|
|
631
|
-
TSortingFns,
|
|
632
|
-
TAggregationFns
|
|
633
|
-
>[] => {
|
|
375
|
+
): Column<TGenerics>[] => {
|
|
634
376
|
return columnDefs.map(columnDef => {
|
|
635
377
|
const column = instance.createColumn(columnDef, depth, parent)
|
|
636
378
|
|
|
@@ -644,7 +386,10 @@ export function createTableInstance<
|
|
|
644
386
|
|
|
645
387
|
return recurseColumns(columnDefs)
|
|
646
388
|
},
|
|
647
|
-
{
|
|
389
|
+
{
|
|
390
|
+
key: 'getAllColumns',
|
|
391
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
392
|
+
}
|
|
648
393
|
),
|
|
649
394
|
|
|
650
395
|
getAllFlatColumns: memo(
|
|
@@ -654,7 +399,10 @@ export function createTableInstance<
|
|
|
654
399
|
return column.getFlatColumns()
|
|
655
400
|
})
|
|
656
401
|
},
|
|
657
|
-
{
|
|
402
|
+
{
|
|
403
|
+
key: 'getAllFlatColumns',
|
|
404
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
405
|
+
}
|
|
658
406
|
),
|
|
659
407
|
|
|
660
408
|
getAllFlatColumnsById: memo(
|
|
@@ -663,9 +411,12 @@ export function createTableInstance<
|
|
|
663
411
|
return flatColumns.reduce((acc, column) => {
|
|
664
412
|
acc[column.id] = column
|
|
665
413
|
return acc
|
|
666
|
-
}, {} as Record<string, Column<
|
|
414
|
+
}, {} as Record<string, Column<TGenerics>>)
|
|
667
415
|
},
|
|
668
|
-
{
|
|
416
|
+
{
|
|
417
|
+
key: 'getAllFlatColumnsById',
|
|
418
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
419
|
+
}
|
|
669
420
|
),
|
|
670
421
|
|
|
671
422
|
getAllLeafColumns: memo(
|
|
@@ -674,7 +425,10 @@ export function createTableInstance<
|
|
|
674
425
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns())
|
|
675
426
|
return orderColumns(leafColumns)
|
|
676
427
|
},
|
|
677
|
-
{
|
|
428
|
+
{
|
|
429
|
+
key: 'getAllLeafColumns',
|
|
430
|
+
debug: () => instance.options.debugAll ?? instance.options.debugColumns,
|
|
431
|
+
}
|
|
678
432
|
),
|
|
679
433
|
|
|
680
434
|
getColumn: columnId => {
|
|
@@ -711,13 +465,7 @@ export function createTableInstance<
|
|
|
711
465
|
},
|
|
712
466
|
|
|
713
467
|
createCell: (row, column, value) => {
|
|
714
|
-
const cell: Cell<
|
|
715
|
-
TData,
|
|
716
|
-
TValue,
|
|
717
|
-
TFilterFns,
|
|
718
|
-
TSortingFns,
|
|
719
|
-
TAggregationFns
|
|
720
|
-
> = {
|
|
468
|
+
const cell: Cell<TGenerics> = {
|
|
721
469
|
id: `${row.id}_${column.id}`,
|
|
722
470
|
rowId: row.id,
|
|
723
471
|
columnId: column.id,
|
|
@@ -734,16 +482,9 @@ export function createTableInstance<
|
|
|
734
482
|
Object.assign(
|
|
735
483
|
cell,
|
|
736
484
|
(feature as any).createCell?.(
|
|
737
|
-
cell as Cell<
|
|
738
|
-
TData,
|
|
739
|
-
TValue,
|
|
740
|
-
TFilterFns,
|
|
741
|
-
TSortingFns,
|
|
742
|
-
TAggregationFns
|
|
743
|
-
> &
|
|
744
|
-
Grouping.GroupingCell,
|
|
485
|
+
cell as Cell<TGenerics> & Grouping.GroupingCell,
|
|
745
486
|
column,
|
|
746
|
-
row as Row<
|
|
487
|
+
row as Row<TGenerics>,
|
|
747
488
|
instance
|
|
748
489
|
)
|
|
749
490
|
)
|
|
@@ -753,13 +494,7 @@ export function createTableInstance<
|
|
|
753
494
|
},
|
|
754
495
|
|
|
755
496
|
createRow: (id, original, rowIndex, depth, values) => {
|
|
756
|
-
let row: CoreRow<
|
|
757
|
-
TData,
|
|
758
|
-
TValue,
|
|
759
|
-
TFilterFns,
|
|
760
|
-
TSortingFns,
|
|
761
|
-
TAggregationFns
|
|
762
|
-
> = {
|
|
497
|
+
let row: CoreRow<TGenerics> = {
|
|
763
498
|
id,
|
|
764
499
|
index: rowIndex,
|
|
765
500
|
original,
|
|
@@ -777,13 +512,7 @@ export function createTableInstance<
|
|
|
777
512
|
leafColumns => {
|
|
778
513
|
return leafColumns.map(column => {
|
|
779
514
|
return instance.createCell(
|
|
780
|
-
row as Row<
|
|
781
|
-
TData,
|
|
782
|
-
TValue,
|
|
783
|
-
TFilterFns,
|
|
784
|
-
TSortingFns,
|
|
785
|
-
TAggregationFns
|
|
786
|
-
>,
|
|
515
|
+
row as Row<TGenerics>,
|
|
787
516
|
column,
|
|
788
517
|
row.values[column.id]
|
|
789
518
|
)
|
|
@@ -791,7 +520,7 @@ export function createTableInstance<
|
|
|
791
520
|
},
|
|
792
521
|
{
|
|
793
522
|
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
|
|
794
|
-
debug: instance.options.
|
|
523
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
795
524
|
}
|
|
796
525
|
)
|
|
797
526
|
|
|
@@ -801,19 +530,20 @@ export function createTableInstance<
|
|
|
801
530
|
return allCells.reduce((acc, cell) => {
|
|
802
531
|
acc[cell.columnId] = cell
|
|
803
532
|
return acc
|
|
804
|
-
}, {} as Record<string, Cell<
|
|
533
|
+
}, {} as Record<string, Cell<TGenerics>>)
|
|
805
534
|
},
|
|
806
535
|
{
|
|
807
536
|
key: 'row.getAllCellsByColumnId',
|
|
808
|
-
debug: instance.options.
|
|
537
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
809
538
|
}
|
|
810
539
|
)
|
|
811
540
|
|
|
812
|
-
features.
|
|
541
|
+
for (let i = 0; i < features.length; i++) {
|
|
542
|
+
const feature = features[i]
|
|
813
543
|
Object.assign(row, (feature as any).createRow?.(row, instance))
|
|
814
|
-
}
|
|
544
|
+
}
|
|
815
545
|
|
|
816
|
-
return row as Row<
|
|
546
|
+
return row as Row<TGenerics>
|
|
817
547
|
},
|
|
818
548
|
|
|
819
549
|
getCoreRowModel: memo(
|
|
@@ -821,50 +551,23 @@ export function createTableInstance<
|
|
|
821
551
|
(
|
|
822
552
|
data
|
|
823
553
|
): {
|
|
824
|
-
rows: Row<
|
|
825
|
-
flatRows: Row<
|
|
826
|
-
rowsById: Record<
|
|
827
|
-
string,
|
|
828
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
829
|
-
>
|
|
554
|
+
rows: Row<TGenerics>[]
|
|
555
|
+
flatRows: Row<TGenerics>[]
|
|
556
|
+
rowsById: Record<string, Row<TGenerics>>
|
|
830
557
|
} => {
|
|
831
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
832
|
-
console.info('Accessing...')
|
|
833
|
-
|
|
834
558
|
// Access the row model using initial columns
|
|
835
|
-
const rows: Row<
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
TFilterFns,
|
|
839
|
-
TSortingFns,
|
|
840
|
-
TAggregationFns
|
|
841
|
-
>[] = []
|
|
842
|
-
const flatRows: Row<
|
|
843
|
-
TData,
|
|
844
|
-
TValue,
|
|
845
|
-
TFilterFns,
|
|
846
|
-
TSortingFns,
|
|
847
|
-
TAggregationFns
|
|
848
|
-
>[] = []
|
|
849
|
-
const rowsById: Record<
|
|
850
|
-
string,
|
|
851
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
852
|
-
> = {}
|
|
559
|
+
const rows: Row<TGenerics>[] = []
|
|
560
|
+
const flatRows: Row<TGenerics>[] = []
|
|
561
|
+
const rowsById: Record<string, Row<TGenerics>> = {}
|
|
853
562
|
|
|
854
563
|
const leafColumns = instance.getAllLeafColumns()
|
|
855
564
|
|
|
856
565
|
const accessRow = (
|
|
857
|
-
originalRow:
|
|
566
|
+
originalRow: TGenerics['Row'],
|
|
858
567
|
rowIndex: number,
|
|
859
568
|
depth = 0,
|
|
860
|
-
parentRows: Row<
|
|
861
|
-
|
|
862
|
-
TValue,
|
|
863
|
-
TFilterFns,
|
|
864
|
-
TSortingFns,
|
|
865
|
-
TAggregationFns
|
|
866
|
-
>[],
|
|
867
|
-
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
569
|
+
parentRows: Row<TGenerics>[],
|
|
570
|
+
parent?: Row<TGenerics>
|
|
868
571
|
) => {
|
|
869
572
|
const id = instance.getRowId(originalRow, rowIndex, parent)
|
|
870
573
|
|
|
@@ -909,17 +612,11 @@ export function createTableInstance<
|
|
|
909
612
|
// Then recursively access them
|
|
910
613
|
if (originalSubRows?.length) {
|
|
911
614
|
row.originalSubRows = originalSubRows
|
|
912
|
-
const subRows: Row<
|
|
913
|
-
TData,
|
|
914
|
-
TValue,
|
|
915
|
-
TFilterFns,
|
|
916
|
-
TSortingFns,
|
|
917
|
-
TAggregationFns
|
|
918
|
-
>[] = []
|
|
615
|
+
const subRows: Row<TGenerics>[] = []
|
|
919
616
|
|
|
920
617
|
for (let i = 0; i < row.originalSubRows.length; i++) {
|
|
921
618
|
accessRow(
|
|
922
|
-
row.originalSubRows[i] as
|
|
619
|
+
row.originalSubRows[i] as TGenerics['Row'],
|
|
923
620
|
i,
|
|
924
621
|
depth + 1,
|
|
925
622
|
subRows,
|
|
@@ -934,14 +631,14 @@ export function createTableInstance<
|
|
|
934
631
|
}
|
|
935
632
|
|
|
936
633
|
for (let i = 0; i < data.length; i++) {
|
|
937
|
-
accessRow(data[i] as
|
|
634
|
+
accessRow(data[i] as TGenerics['Row'], i, 0, rows)
|
|
938
635
|
}
|
|
939
636
|
|
|
940
637
|
return { rows, flatRows, rowsById }
|
|
941
638
|
},
|
|
942
639
|
{
|
|
943
640
|
key: 'getRowModel',
|
|
944
|
-
debug: instance.options.
|
|
641
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
945
642
|
onChange: () => {
|
|
946
643
|
instance._notifyRowSelectionReset()
|
|
947
644
|
instance._notifyFiltersReset()
|
|
@@ -949,20 +646,6 @@ export function createTableInstance<
|
|
|
949
646
|
}
|
|
950
647
|
),
|
|
951
648
|
|
|
952
|
-
// The standard
|
|
953
|
-
|
|
954
|
-
getCoreRows: () => {
|
|
955
|
-
return instance.getCoreRowModel().rows
|
|
956
|
-
},
|
|
957
|
-
|
|
958
|
-
getCoreFlatRows: () => {
|
|
959
|
-
return instance.getCoreRowModel().flatRows
|
|
960
|
-
},
|
|
961
|
-
|
|
962
|
-
getCoreRowsById: () => {
|
|
963
|
-
return instance.getCoreRowModel().rowsById
|
|
964
|
-
},
|
|
965
|
-
|
|
966
649
|
// The final calls start at the bottom of the model,
|
|
967
650
|
// expanded rows, which then work their way up
|
|
968
651
|
|
|
@@ -970,20 +653,8 @@ export function createTableInstance<
|
|
|
970
653
|
return instance.getPaginationRowModel()
|
|
971
654
|
},
|
|
972
655
|
|
|
973
|
-
getRows: () => {
|
|
974
|
-
return instance.getRowModel().rows
|
|
975
|
-
},
|
|
976
|
-
|
|
977
|
-
getFlatRows: () => {
|
|
978
|
-
return instance.getRowModel().flatRows
|
|
979
|
-
},
|
|
980
|
-
|
|
981
|
-
getRowsById: () => {
|
|
982
|
-
return instance.getRowModel().rowsById
|
|
983
|
-
},
|
|
984
|
-
|
|
985
656
|
getRow: (id: string) => {
|
|
986
|
-
const row = instance.
|
|
657
|
+
const row = instance.getRowModel().rowsById[id]
|
|
987
658
|
|
|
988
659
|
if (!row) {
|
|
989
660
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -1088,9 +759,5 @@ export function createTableInstance<
|
|
|
1088
759
|
|
|
1089
760
|
instance = Object.assign(instance, finalInstance)
|
|
1090
761
|
|
|
1091
|
-
// This won't trigger a rerender yet, but it will force
|
|
1092
|
-
// pagination derivation to run (particularly pageSize detection)
|
|
1093
|
-
instance.setPagination(d => d)
|
|
1094
|
-
|
|
1095
762
|
return instance
|
|
1096
763
|
}
|