@tanstack/table-core 8.0.13 → 8.0.14

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.
Files changed (96) hide show
  1. package/build/cjs/core/cell.js +13 -13
  2. package/build/cjs/core/cell.js.map +1 -1
  3. package/build/cjs/core/column.js +20 -21
  4. package/build/cjs/core/column.js.map +1 -1
  5. package/build/cjs/core/headers.js +63 -68
  6. package/build/cjs/core/headers.js.map +1 -1
  7. package/build/cjs/core/row.js +16 -11
  8. package/build/cjs/core/row.js.map +1 -1
  9. package/build/cjs/core/{instance.js → table.js} +46 -57
  10. package/build/cjs/core/table.js.map +1 -0
  11. package/build/cjs/features/ColumnSizing.js +36 -36
  12. package/build/cjs/features/ColumnSizing.js.map +1 -1
  13. package/build/cjs/features/Expanding.js +34 -34
  14. package/build/cjs/features/Expanding.js.map +1 -1
  15. package/build/cjs/features/Filters.js +46 -52
  16. package/build/cjs/features/Filters.js.map +1 -1
  17. package/build/cjs/features/Grouping.js +24 -49
  18. package/build/cjs/features/Grouping.js.map +1 -1
  19. package/build/cjs/features/Ordering.js +8 -8
  20. package/build/cjs/features/Ordering.js.map +1 -1
  21. package/build/cjs/features/Pagination.js +37 -37
  22. package/build/cjs/features/Pagination.js.map +1 -1
  23. package/build/cjs/features/Pinning.js +33 -33
  24. package/build/cjs/features/Pinning.js.map +1 -1
  25. package/build/cjs/features/RowSelection.js +67 -67
  26. package/build/cjs/features/RowSelection.js.map +1 -1
  27. package/build/cjs/features/Sorting.js +36 -40
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +30 -30
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/index.js +2 -4
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +8 -8
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModel.js +8 -8
  36. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  37. package/build/cjs/utils/getExpandedRowModel.js +4 -4
  38. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getFacetedMinMaxValues.js +3 -3
  40. package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -1
  41. package/build/cjs/utils/getFacetedRowModel.js +4 -4
  42. package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
  43. package/build/cjs/utils/getFacetedUniqueValues.js +3 -3
  44. package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -1
  45. package/build/cjs/utils/getFilteredRowModel.js +8 -8
  46. package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
  47. package/build/cjs/utils/getGroupedRowModel.js +9 -9
  48. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  49. package/build/cjs/utils/getPaginationRowModel.js +4 -4
  50. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  51. package/build/cjs/utils/getSortedRowModel.js +7 -7
  52. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  53. package/build/cjs/utils.js +2 -2
  54. package/build/cjs/utils.js.map +1 -1
  55. package/build/esm/index.js +567 -670
  56. package/build/esm/index.js.map +1 -1
  57. package/build/stats-html.html +1 -1
  58. package/build/stats-react.json +352 -377
  59. package/build/types/index.d.ts +284 -360
  60. package/build/umd/index.development.js +567 -671
  61. package/build/umd/index.development.js.map +1 -1
  62. package/build/umd/index.production.js +1 -1
  63. package/build/umd/index.production.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/core/cell.ts +34 -28
  66. package/src/core/column.ts +83 -72
  67. package/src/core/headers.ts +118 -149
  68. package/src/core/row.ts +31 -25
  69. package/src/core/{instance.ts → table.ts} +85 -116
  70. package/src/features/ColumnSizing.ts +45 -47
  71. package/src/features/Expanding.ts +53 -59
  72. package/src/features/Filters.ts +112 -132
  73. package/src/features/Grouping.ts +63 -112
  74. package/src/features/Ordering.ts +19 -21
  75. package/src/features/Pagination.ts +54 -55
  76. package/src/features/Pinning.ts +49 -61
  77. package/src/features/RowSelection.ts +97 -108
  78. package/src/features/Sorting.ts +57 -72
  79. package/src/features/Visibility.ts +48 -48
  80. package/src/index.ts +1 -2
  81. package/src/types.ts +64 -69
  82. package/src/utils/filterRowsUtils.ts +33 -28
  83. package/src/utils/getCoreRowModel.ts +22 -22
  84. package/src/utils/getExpandedRowModel.ts +15 -15
  85. package/src/utils/getFacetedMinMaxValues.ts +6 -6
  86. package/src/utils/getFacetedRowModel.ts +12 -12
  87. package/src/utils/getFacetedUniqueValues.ts +6 -6
  88. package/src/utils/getFilteredRowModel.ts +17 -17
  89. package/src/utils/getGroupedRowModel.ts +18 -21
  90. package/src/utils/getPaginationRowModel.ts +10 -13
  91. package/src/utils/getSortedRowModel.ts +14 -14
  92. package/src/utils.ts +8 -2
  93. package/build/cjs/core/instance.js.map +0 -1
  94. package/build/cjs/createTable.js +0 -72
  95. package/build/cjs/createTable.js.map +0 -1
  96. package/src/createTable.ts +0 -188
@@ -1,11 +1,12 @@
1
- import { TableFeature } from '../core/instance'
1
+ import { TableFeature } from '../core/table'
2
2
  import {
3
3
  OnChangeFn,
4
4
  TableGenerics,
5
- TableInstance,
5
+ Table,
6
6
  Row,
7
7
  RowModel,
8
8
  Updater,
9
+ RowData,
9
10
  } from '../types'
10
11
  import { makeStateUpdater, memo } from '../utils'
11
12
 
@@ -15,28 +16,22 @@ export type RowSelectionTableState = {
15
16
  rowSelection: RowSelectionState
16
17
  }
17
18
 
18
- export type RowSelectionOptions<TGenerics extends TableGenerics> = {
19
- enableRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
20
- enableMultiRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
21
- enableSubRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
19
+ export type RowSelectionOptions<TData extends RowData> = {
20
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean)
21
+ enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)
22
+ enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)
22
23
  onRowSelectionChange?: OnChangeFn<RowSelectionState>
23
24
  // enableGroupingRowSelection?:
24
25
  // | boolean
25
26
  // | ((
26
- // row: Row<TGenerics>
27
+ // row: Row<TData>
27
28
  // ) => boolean)
28
29
  // isAdditiveSelectEvent?: (e: unknown) => boolean
29
30
  // isInclusiveSelectEvent?: (e: unknown) => boolean
30
31
  // selectRowsFn?: (
31
- // instance: TableInstance<
32
- // TData,
33
- // TValue,
34
- // TFilterFns,
35
- // TSortingFns,
36
- // TAggregationFns
37
- // >,
38
- // rowModel: RowModel<TGenerics>
39
- // ) => RowModel<TGenerics>
32
+ // table: Table<TData>,
33
+ // rowModel: RowModel<TData>
34
+ // ) => RowModel<TData>
40
35
  }
41
36
 
42
37
  export type RowSelectionRow = {
@@ -49,7 +44,7 @@ export type RowSelectionRow = {
49
44
  getToggleSelectedHandler: () => (event: unknown) => void
50
45
  }
51
46
 
52
- export type RowSelectionInstance<TGenerics extends TableGenerics> = {
47
+ export type RowSelectionInstance<TData extends RowData> = {
53
48
  getToggleAllRowsSelectedHandler: () => (event: unknown) => void
54
49
  getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void
55
50
  setRowSelection: (updater: Updater<RowSelectionState>) => void
@@ -60,10 +55,10 @@ export type RowSelectionInstance<TGenerics extends TableGenerics> = {
60
55
  getIsSomePageRowsSelected: () => boolean
61
56
  toggleAllRowsSelected: (value?: boolean) => void
62
57
  toggleAllPageRowsSelected: (value?: boolean) => void
63
- getPreSelectedRowModel: () => RowModel<TGenerics>
64
- getSelectedRowModel: () => RowModel<TGenerics>
65
- getFilteredSelectedRowModel: () => RowModel<TGenerics>
66
- getGroupedSelectedRowModel: () => RowModel<TGenerics>
58
+ getPreSelectedRowModel: () => RowModel<TData>
59
+ getSelectedRowModel: () => RowModel<TData>
60
+ getFilteredSelectedRowModel: () => RowModel<TData>
61
+ getGroupedSelectedRowModel: () => RowModel<TData>
67
62
  }
68
63
 
69
64
  //
@@ -76,11 +71,11 @@ export const RowSelection: TableFeature = {
76
71
  }
77
72
  },
78
73
 
79
- getDefaultOptions: <TGenerics extends TableGenerics>(
80
- instance: TableInstance<TGenerics>
81
- ): RowSelectionOptions<TGenerics> => {
74
+ getDefaultOptions: <TData extends RowData>(
75
+ table: Table<TData>
76
+ ): RowSelectionOptions<TData> => {
82
77
  return {
83
- onRowSelectionChange: makeStateUpdater('rowSelection', instance),
78
+ onRowSelectionChange: makeStateUpdater('rowSelection', table),
84
79
  enableRowSelection: true,
85
80
  enableMultiRowSelection: true,
86
81
  enableSubRowSelection: true,
@@ -90,26 +85,23 @@ export const RowSelection: TableFeature = {
90
85
  }
91
86
  },
92
87
 
93
- createInstance: <TGenerics extends TableGenerics>(
94
- instance: TableInstance<TGenerics>
95
- ): RowSelectionInstance<TGenerics> => {
88
+ createTable: <TData extends RowData>(
89
+ table: Table<TData>
90
+ ): RowSelectionInstance<TData> => {
96
91
  return {
97
- setRowSelection: updater =>
98
- instance.options.onRowSelectionChange?.(updater),
92
+ setRowSelection: updater => table.options.onRowSelectionChange?.(updater),
99
93
  resetRowSelection: defaultState =>
100
- instance.setRowSelection(
101
- defaultState ? {} : instance.initialState.rowSelection ?? {}
94
+ table.setRowSelection(
95
+ defaultState ? {} : table.initialState.rowSelection ?? {}
102
96
  ),
103
97
  toggleAllRowsSelected: value => {
104
- instance.setRowSelection(old => {
98
+ table.setRowSelection(old => {
105
99
  value =
106
- typeof value !== 'undefined'
107
- ? value
108
- : !instance.getIsAllRowsSelected()
100
+ typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected()
109
101
 
110
102
  const rowSelection = { ...old }
111
103
 
112
- const preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows
104
+ const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows
113
105
 
114
106
  // We don't use `mutateRowIsSelected` here for performance reasons.
115
107
  // All of the rows are flat already, so it wouldn't be worth it
@@ -127,16 +119,16 @@ export const RowSelection: TableFeature = {
127
119
  })
128
120
  },
129
121
  toggleAllPageRowsSelected: value =>
130
- instance.setRowSelection(old => {
122
+ table.setRowSelection(old => {
131
123
  const resolvedValue =
132
124
  typeof value !== 'undefined'
133
125
  ? value
134
- : !instance.getIsAllPageRowsSelected()
126
+ : !table.getIsAllPageRowsSelected()
135
127
 
136
128
  const rowSelection: RowSelectionState = { ...old }
137
129
 
138
- instance.getRowModel().rows.forEach(row => {
139
- mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance)
130
+ table.getRowModel().rows.forEach(row => {
131
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, table)
140
132
  })
141
133
 
142
134
  return rowSelection
@@ -147,7 +139,7 @@ export const RowSelection: TableFeature = {
147
139
  // rows,
148
140
  // rowsById,
149
141
  // options: { selectGroupingRows, selectSubRows },
150
- // } = instance
142
+ // } = table
151
143
 
152
144
  // const findSelectedRow = (rows: Row[]) => {
153
145
  // let found
@@ -180,7 +172,7 @@ export const RowSelection: TableFeature = {
180
172
  // })
181
173
  // }
182
174
 
183
- // instance.rows.forEach(row => {
175
+ // table.rows.forEach(row => {
184
176
  // const isFirstRow = row.id === firstRow.id
185
177
  // const isLastRow = row.id === lastRow.id
186
178
 
@@ -198,11 +190,11 @@ export const RowSelection: TableFeature = {
198
190
  // }
199
191
  // })
200
192
 
201
- // instance.setRowSelection(selectedRowIds)
193
+ // table.setRowSelection(selectedRowIds)
202
194
  // },
203
- getPreSelectedRowModel: () => instance.getCoreRowModel(),
195
+ getPreSelectedRowModel: () => table.getCoreRowModel(),
204
196
  getSelectedRowModel: memo(
205
- () => [instance.getState().rowSelection, instance.getCoreRowModel()],
197
+ () => [table.getState().rowSelection, table.getCoreRowModel()],
206
198
  (rowSelection, rowModel) => {
207
199
  if (!Object.keys(rowSelection).length) {
208
200
  return {
@@ -212,19 +204,16 @@ export const RowSelection: TableFeature = {
212
204
  }
213
205
  }
214
206
 
215
- return selectRowsFn(instance, rowModel)
207
+ return selectRowsFn(table, rowModel)
216
208
  },
217
209
  {
218
210
  key: process.env.NODE_ENV === 'development' && 'getSelectedRowModel',
219
- debug: () => instance.options.debugAll ?? instance.options.debugTable,
211
+ debug: () => table.options.debugAll ?? table.options.debugTable,
220
212
  }
221
213
  ),
222
214
 
223
215
  getFilteredSelectedRowModel: memo(
224
- () => [
225
- instance.getState().rowSelection,
226
- instance.getFilteredRowModel(),
227
- ],
216
+ () => [table.getState().rowSelection, table.getFilteredRowModel()],
228
217
  (rowSelection, rowModel) => {
229
218
  if (!Object.keys(rowSelection).length) {
230
219
  return {
@@ -234,18 +223,18 @@ export const RowSelection: TableFeature = {
234
223
  }
235
224
  }
236
225
 
237
- return selectRowsFn(instance, rowModel)
226
+ return selectRowsFn(table, rowModel)
238
227
  },
239
228
  {
240
229
  key:
241
230
  process.env.NODE_ENV === 'production' &&
242
231
  'getFilteredSelectedRowModel',
243
- debug: () => instance.options.debugAll ?? instance.options.debugTable,
232
+ debug: () => table.options.debugAll ?? table.options.debugTable,
244
233
  }
245
234
  ),
246
235
 
247
236
  getGroupedSelectedRowModel: memo(
248
- () => [instance.getState().rowSelection, instance.getSortedRowModel()],
237
+ () => [table.getState().rowSelection, table.getSortedRowModel()],
249
238
  (rowSelection, rowModel) => {
250
239
  if (!Object.keys(rowSelection).length) {
251
240
  return {
@@ -255,35 +244,35 @@ export const RowSelection: TableFeature = {
255
244
  }
256
245
  }
257
246
 
258
- return selectRowsFn(instance, rowModel)
247
+ return selectRowsFn(table, rowModel)
259
248
  },
260
249
  {
261
250
  key:
262
251
  process.env.NODE_ENV === 'production' &&
263
252
  'getGroupedSelectedRowModel',
264
- debug: () => instance.options.debugAll ?? instance.options.debugTable,
253
+ debug: () => table.options.debugAll ?? table.options.debugTable,
265
254
  }
266
255
  ),
267
256
 
268
257
  ///
269
258
 
270
259
  // getGroupingRowCanSelect: rowId => {
271
- // const row = instance.getRow(rowId)
260
+ // const row = table.getRow(rowId)
272
261
 
273
262
  // if (!row) {
274
263
  // throw new Error()
275
264
  // }
276
265
 
277
- // if (typeof instance.options.enableGroupingRowSelection === 'function') {
278
- // return instance.options.enableGroupingRowSelection(row)
266
+ // if (typeof table.options.enableGroupingRowSelection === 'function') {
267
+ // return table.options.enableGroupingRowSelection(row)
279
268
  // }
280
269
 
281
- // return instance.options.enableGroupingRowSelection ?? false
270
+ // return table.options.enableGroupingRowSelection ?? false
282
271
  // },
283
272
 
284
273
  getIsAllRowsSelected: () => {
285
- const preFilteredFlatRows = instance.getPreFilteredRowModel().flatRows
286
- const { rowSelection } = instance.getState()
274
+ const preFilteredFlatRows = table.getPreFilteredRowModel().flatRows
275
+ const { rowSelection } = table.getState()
287
276
 
288
277
  let isAllRowsSelected = Boolean(
289
278
  preFilteredFlatRows.length && Object.keys(rowSelection).length
@@ -299,8 +288,8 @@ export const RowSelection: TableFeature = {
299
288
  },
300
289
 
301
290
  getIsAllPageRowsSelected: () => {
302
- const paginationFlatRows = instance.getPaginationRowModel().flatRows
303
- const { rowSelection } = instance.getState()
291
+ const paginationFlatRows = table.getPaginationRowModel().flatRows
292
+ const { rowSelection } = table.getState()
304
293
 
305
294
  let isAllPageRowsSelected = !!paginationFlatRows.length
306
295
 
@@ -316,14 +305,14 @@ export const RowSelection: TableFeature = {
316
305
 
317
306
  getIsSomeRowsSelected: () => {
318
307
  return (
319
- !instance.getIsAllRowsSelected() &&
320
- !!Object.keys(instance.getState().rowSelection ?? {}).length
308
+ !table.getIsAllRowsSelected() &&
309
+ !!Object.keys(table.getState().rowSelection ?? {}).length
321
310
  )
322
311
  },
323
312
 
324
313
  getIsSomePageRowsSelected: () => {
325
- const paginationFlatRows = instance.getPaginationRowModel().flatRows
326
- return instance.getIsAllPageRowsSelected()
314
+ const paginationFlatRows = table.getPaginationRowModel().flatRows
315
+ return table.getIsAllPageRowsSelected()
327
316
  ? false
328
317
  : paginationFlatRows.some(
329
318
  d => d.getIsSelected() || d.getIsSomeSelected()
@@ -332,7 +321,7 @@ export const RowSelection: TableFeature = {
332
321
 
333
322
  getToggleAllRowsSelectedHandler: () => {
334
323
  return (e: unknown) => {
335
- instance.toggleAllRowsSelected(
324
+ table.toggleAllRowsSelected(
336
325
  ((e as MouseEvent).target as HTMLInputElement).checked
337
326
  )
338
327
  }
@@ -340,7 +329,7 @@ export const RowSelection: TableFeature = {
340
329
 
341
330
  getToggleAllPageRowsSelectedHandler: () => {
342
331
  return (e: unknown) => {
343
- instance.toggleAllPageRowsSelected(
332
+ table.toggleAllPageRowsSelected(
344
333
  ((e as MouseEvent).target as HTMLInputElement).checked
345
334
  )
346
335
  }
@@ -348,15 +337,15 @@ export const RowSelection: TableFeature = {
348
337
  }
349
338
  },
350
339
 
351
- createRow: <TGenerics extends TableGenerics>(
352
- row: Row<TGenerics>,
353
- instance: TableInstance<TGenerics>
340
+ createRow: <TData extends RowData>(
341
+ row: Row<TData>,
342
+ table: Table<TData>
354
343
  ): RowSelectionRow => {
355
344
  return {
356
345
  toggleSelected: value => {
357
346
  const isSelected = row.getIsSelected()
358
347
 
359
- instance.setRowSelection(old => {
348
+ table.setRowSelection(old => {
360
349
  value = typeof value !== 'undefined' ? value : !isSelected
361
350
 
362
351
  if (isSelected === value) {
@@ -365,43 +354,43 @@ export const RowSelection: TableFeature = {
365
354
 
366
355
  const selectedRowIds = { ...old }
367
356
 
368
- mutateRowIsSelected(selectedRowIds, row.id, value, instance)
357
+ mutateRowIsSelected(selectedRowIds, row.id, value, table)
369
358
 
370
359
  return selectedRowIds
371
360
  })
372
361
  },
373
362
  getIsSelected: () => {
374
- const { rowSelection } = instance.getState()
375
- return isRowSelected(row, rowSelection, instance) === true
363
+ const { rowSelection } = table.getState()
364
+ return isRowSelected(row, rowSelection, table) === true
376
365
  },
377
366
 
378
367
  getIsSomeSelected: () => {
379
- const { rowSelection } = instance.getState()
380
- return isRowSelected(row, rowSelection, instance) === 'some'
368
+ const { rowSelection } = table.getState()
369
+ return isRowSelected(row, rowSelection, table) === 'some'
381
370
  },
382
371
 
383
372
  getCanSelect: () => {
384
- if (typeof instance.options.enableRowSelection === 'function') {
385
- return instance.options.enableRowSelection(row)
373
+ if (typeof table.options.enableRowSelection === 'function') {
374
+ return table.options.enableRowSelection(row)
386
375
  }
387
376
 
388
- return instance.options.enableRowSelection ?? true
377
+ return table.options.enableRowSelection ?? true
389
378
  },
390
379
 
391
380
  getCanSelectSubRows: () => {
392
- if (typeof instance.options.enableSubRowSelection === 'function') {
393
- return instance.options.enableSubRowSelection(row)
381
+ if (typeof table.options.enableSubRowSelection === 'function') {
382
+ return table.options.enableSubRowSelection(row)
394
383
  }
395
384
 
396
- return instance.options.enableSubRowSelection ?? true
385
+ return table.options.enableSubRowSelection ?? true
397
386
  },
398
387
 
399
388
  getCanMultiSelect: () => {
400
- if (typeof instance.options.enableMultiRowSelection === 'function') {
401
- return instance.options.enableMultiRowSelection(row)
389
+ if (typeof table.options.enableMultiRowSelection === 'function') {
390
+ return table.options.enableMultiRowSelection(row)
402
391
  }
403
392
 
404
- return instance.options.enableMultiRowSelection ?? true
393
+ return table.options.enableMultiRowSelection ?? true
405
394
  },
406
395
  getToggleSelectedHandler: () => {
407
396
  const canSelect = row.getCanSelect()
@@ -417,19 +406,19 @@ export const RowSelection: TableFeature = {
417
406
  },
418
407
  }
419
408
 
420
- const mutateRowIsSelected = <TGenerics extends TableGenerics>(
409
+ const mutateRowIsSelected = <TData extends RowData>(
421
410
  selectedRowIds: Record<string, boolean>,
422
411
  id: string,
423
412
  value: boolean,
424
- instance: TableInstance<TGenerics>
413
+ table: Table<TData>
425
414
  ) => {
426
- const row = instance.getRow(id)
415
+ const row = table.getRow(id)
427
416
 
428
417
  const isGrouped = row.getIsGrouped()
429
418
 
430
419
  // if ( // TODO: enforce grouping row selection rules
431
420
  // !isGrouped ||
432
- // (isGrouped && instance.options.enableGroupingRowSelection)
421
+ // (isGrouped && table.options.enableGroupingRowSelection)
433
422
  // ) {
434
423
  if (value) {
435
424
  selectedRowIds[id] = true
@@ -440,25 +429,25 @@ const mutateRowIsSelected = <TGenerics extends TableGenerics>(
440
429
 
441
430
  if (row.subRows?.length && row.getCanSelectSubRows()) {
442
431
  row.subRows.forEach(row =>
443
- mutateRowIsSelected(selectedRowIds, row.id, value, instance)
432
+ mutateRowIsSelected(selectedRowIds, row.id, value, table)
444
433
  )
445
434
  }
446
435
  }
447
436
 
448
- export function selectRowsFn<TGenerics extends TableGenerics>(
449
- instance: TableInstance<TGenerics>,
450
- rowModel: RowModel<TGenerics>
451
- ): RowModel<TGenerics> {
452
- const rowSelection = instance.getState().rowSelection
437
+ export function selectRowsFn<TData extends RowData>(
438
+ table: Table<TData>,
439
+ rowModel: RowModel<TData>
440
+ ): RowModel<TData> {
441
+ const rowSelection = table.getState().rowSelection
453
442
 
454
- const newSelectedFlatRows: Row<TGenerics>[] = []
455
- const newSelectedRowsById: Record<string, Row<TGenerics>> = {}
443
+ const newSelectedFlatRows: Row<TData>[] = []
444
+ const newSelectedRowsById: Record<string, Row<TData>> = {}
456
445
 
457
446
  // Filters top level and nested rows
458
- const recurseRows = (rows: Row<TGenerics>[], depth = 0): Row<TGenerics>[] => {
447
+ const recurseRows = (rows: Row<TData>[], depth = 0): Row<TData>[] => {
459
448
  return rows
460
449
  .map(row => {
461
- const isSelected = isRowSelected(row, rowSelection, instance) === true
450
+ const isSelected = isRowSelected(row, rowSelection, table) === true
462
451
 
463
452
  if (isSelected) {
464
453
  newSelectedFlatRows.push(row)
@@ -476,7 +465,7 @@ export function selectRowsFn<TGenerics extends TableGenerics>(
476
465
  return row
477
466
  }
478
467
  })
479
- .filter(Boolean) as Row<TGenerics>[]
468
+ .filter(Boolean) as Row<TData>[]
480
469
  }
481
470
 
482
471
  return {
@@ -486,10 +475,10 @@ export function selectRowsFn<TGenerics extends TableGenerics>(
486
475
  }
487
476
  }
488
477
 
489
- export function isRowSelected<TGenerics extends TableGenerics>(
490
- row: Row<TGenerics>,
478
+ export function isRowSelected<TData extends RowData>(
479
+ row: Row<TData>,
491
480
  selection: Record<string, boolean>,
492
- instance: TableInstance<TGenerics>
481
+ table: Table<TData>
493
482
  ): boolean | 'some' {
494
483
  if (selection[row.id]) {
495
484
  return true
@@ -505,7 +494,7 @@ export function isRowSelected<TGenerics extends TableGenerics>(
505
494
  return
506
495
  }
507
496
 
508
- if (isRowSelected(subRow, selection, instance)) {
497
+ if (isRowSelected(subRow, selection, table)) {
509
498
  someSelected = true
510
499
  } else {
511
500
  allChildrenSelected = false