@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
|
@@ -2,8 +2,9 @@ import React, { MouseEvent, TouchEvent } from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
Getter,
|
|
4
4
|
OnChangeFn,
|
|
5
|
+
PartialGenerics,
|
|
5
6
|
PropGetterValue,
|
|
6
|
-
|
|
7
|
+
TableInstance,
|
|
7
8
|
Row,
|
|
8
9
|
RowModel,
|
|
9
10
|
Updater,
|
|
@@ -16,47 +17,29 @@ export type RowSelectionTableState = {
|
|
|
16
17
|
rowSelection: RowSelectionState
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export type RowSelectionOptions<
|
|
20
|
-
TData,
|
|
21
|
-
TValue,
|
|
22
|
-
TFilterFns,
|
|
23
|
-
TSortingFns,
|
|
24
|
-
TAggregationFns
|
|
25
|
-
> = {
|
|
20
|
+
export type RowSelectionOptions<TGenerics extends PartialGenerics> = {
|
|
26
21
|
onRowSelectionChange?: OnChangeFn<RowSelectionState>
|
|
27
22
|
autoResetRowSelection?: boolean
|
|
28
|
-
enableRowSelection?:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
32
|
-
) => boolean)
|
|
33
|
-
enableMultiRowSelection?:
|
|
34
|
-
| boolean
|
|
35
|
-
| ((
|
|
36
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
37
|
-
) => boolean)
|
|
38
|
-
enableSubRowSelection?:
|
|
39
|
-
| boolean
|
|
40
|
-
| ((
|
|
41
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
42
|
-
) => boolean)
|
|
23
|
+
enableRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
24
|
+
enableMultiRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
25
|
+
enableSubRowSelection?: boolean | ((row: Row<TGenerics>) => boolean)
|
|
43
26
|
// enableGroupingRowSelection?:
|
|
44
27
|
// | boolean
|
|
45
28
|
// | ((
|
|
46
|
-
// row: Row<
|
|
29
|
+
// row: Row<TGenerics>
|
|
47
30
|
// ) => boolean)
|
|
48
31
|
// isAdditiveSelectEvent?: (e: MouseEvent | TouchEvent) => boolean
|
|
49
32
|
// isInclusiveSelectEvent?: (e: MouseEvent | TouchEvent) => boolean
|
|
50
33
|
// selectRowsFn?: (
|
|
51
|
-
// instance:
|
|
34
|
+
// instance: TableInstance<
|
|
52
35
|
// TData,
|
|
53
36
|
// TValue,
|
|
54
37
|
// TFilterFns,
|
|
55
38
|
// TSortingFns,
|
|
56
39
|
// TAggregationFns
|
|
57
40
|
// >,
|
|
58
|
-
// rowModel: RowModel<
|
|
59
|
-
// ) => RowModel<
|
|
41
|
+
// rowModel: RowModel<TGenerics>
|
|
42
|
+
// ) => RowModel<TGenerics>
|
|
60
43
|
}
|
|
61
44
|
|
|
62
45
|
type ToggleRowSelectedProps = {
|
|
@@ -77,13 +60,7 @@ export type RowSelectionRow = {
|
|
|
77
60
|
) => undefined | PropGetterValue<ToggleRowSelectedProps, TGetter>
|
|
78
61
|
}
|
|
79
62
|
|
|
80
|
-
export type RowSelectionInstance<
|
|
81
|
-
TData,
|
|
82
|
-
TValue,
|
|
83
|
-
TFilterFns,
|
|
84
|
-
TSortingFns,
|
|
85
|
-
TAggregationFns
|
|
86
|
-
> = {
|
|
63
|
+
export type RowSelectionInstance<TGenerics extends PartialGenerics> = {
|
|
87
64
|
_notifyRowSelectionReset: () => void
|
|
88
65
|
getToggleRowSelectedProps: <TGetter extends Getter<ToggleRowSelectedProps>>(
|
|
89
66
|
rowId: string,
|
|
@@ -114,81 +91,10 @@ export type RowSelectionInstance<
|
|
|
114
91
|
getIsSomePageRowsSelected: () => boolean
|
|
115
92
|
toggleAllRowsSelected: (value: boolean) => void
|
|
116
93
|
toggleAllPageRowsSelected: (value: boolean) => void
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
TSortingFns,
|
|
122
|
-
TAggregationFns
|
|
123
|
-
>
|
|
124
|
-
getSelectedRows: () => Row<
|
|
125
|
-
TData,
|
|
126
|
-
TValue,
|
|
127
|
-
TFilterFns,
|
|
128
|
-
TSortingFns,
|
|
129
|
-
TAggregationFns
|
|
130
|
-
>[]
|
|
131
|
-
getSelectedFlatRows: () => Row<
|
|
132
|
-
TData,
|
|
133
|
-
TValue,
|
|
134
|
-
TFilterFns,
|
|
135
|
-
TSortingFns,
|
|
136
|
-
TAggregationFns
|
|
137
|
-
>[]
|
|
138
|
-
getSelectedRowsById: () => Record<
|
|
139
|
-
string,
|
|
140
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
141
|
-
>
|
|
142
|
-
getFilteredSelectedRowModel: () => RowModel<
|
|
143
|
-
TData,
|
|
144
|
-
TValue,
|
|
145
|
-
TFilterFns,
|
|
146
|
-
TSortingFns,
|
|
147
|
-
TAggregationFns
|
|
148
|
-
>
|
|
149
|
-
getFilteredSelectedRows: () => Row<
|
|
150
|
-
TData,
|
|
151
|
-
TValue,
|
|
152
|
-
TFilterFns,
|
|
153
|
-
TSortingFns,
|
|
154
|
-
TAggregationFns
|
|
155
|
-
>[]
|
|
156
|
-
getFilteredSelectedFlatRows: () => Row<
|
|
157
|
-
TData,
|
|
158
|
-
TValue,
|
|
159
|
-
TFilterFns,
|
|
160
|
-
TSortingFns,
|
|
161
|
-
TAggregationFns
|
|
162
|
-
>[]
|
|
163
|
-
getFilteredSelectedRowsById: () => Record<
|
|
164
|
-
string,
|
|
165
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
166
|
-
>
|
|
167
|
-
getGroupedSelectedRowModel: () => RowModel<
|
|
168
|
-
TData,
|
|
169
|
-
TValue,
|
|
170
|
-
TFilterFns,
|
|
171
|
-
TSortingFns,
|
|
172
|
-
TAggregationFns
|
|
173
|
-
>
|
|
174
|
-
getGroupedSelectedRows: () => Row<
|
|
175
|
-
TData,
|
|
176
|
-
TValue,
|
|
177
|
-
TFilterFns,
|
|
178
|
-
TSortingFns,
|
|
179
|
-
TAggregationFns
|
|
180
|
-
>[]
|
|
181
|
-
getGroupedSelectedFlatRows: () => Row<
|
|
182
|
-
TData,
|
|
183
|
-
TValue,
|
|
184
|
-
TFilterFns,
|
|
185
|
-
TSortingFns,
|
|
186
|
-
TAggregationFns
|
|
187
|
-
>[]
|
|
188
|
-
getGroupedSelectedRowsById: () => Record<
|
|
189
|
-
string,
|
|
190
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
191
|
-
>
|
|
94
|
+
getPreSelectedRowModel: () => RowModel<TGenerics>
|
|
95
|
+
getSelectedRowModel: () => RowModel<TGenerics>
|
|
96
|
+
getFilteredSelectedRowModel: () => RowModel<TGenerics>
|
|
97
|
+
getGroupedSelectedRowModel: () => RowModel<TGenerics>
|
|
192
98
|
}
|
|
193
99
|
|
|
194
100
|
//
|
|
@@ -199,21 +105,9 @@ export function getInitialState(): RowSelectionTableState {
|
|
|
199
105
|
}
|
|
200
106
|
}
|
|
201
107
|
|
|
202
|
-
export function getDefaultOptions<
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
TFilterFns,
|
|
206
|
-
TSortingFns,
|
|
207
|
-
TAggregationFns
|
|
208
|
-
>(
|
|
209
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
210
|
-
): RowSelectionOptions<
|
|
211
|
-
TData,
|
|
212
|
-
TValue,
|
|
213
|
-
TFilterFns,
|
|
214
|
-
TSortingFns,
|
|
215
|
-
TAggregationFns
|
|
216
|
-
> {
|
|
108
|
+
export function getDefaultOptions<TGenerics extends PartialGenerics>(
|
|
109
|
+
instance: TableInstance<TGenerics>
|
|
110
|
+
): RowSelectionOptions<TGenerics> {
|
|
217
111
|
return {
|
|
218
112
|
onRowSelectionChange: makeStateUpdater('rowSelection', instance),
|
|
219
113
|
autoResetRowSelection: true,
|
|
@@ -226,21 +120,9 @@ export function getDefaultOptions<
|
|
|
226
120
|
}
|
|
227
121
|
}
|
|
228
122
|
|
|
229
|
-
export function getInstance<
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
TFilterFns,
|
|
233
|
-
TSortingFns,
|
|
234
|
-
TAggregationFns
|
|
235
|
-
>(
|
|
236
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
237
|
-
): RowSelectionInstance<
|
|
238
|
-
TData,
|
|
239
|
-
TValue,
|
|
240
|
-
TFilterFns,
|
|
241
|
-
TSortingFns,
|
|
242
|
-
TAggregationFns
|
|
243
|
-
> {
|
|
123
|
+
export function getInstance<TGenerics extends PartialGenerics>(
|
|
124
|
+
instance: TableInstance<TGenerics>
|
|
125
|
+
): RowSelectionInstance<TGenerics> {
|
|
244
126
|
let registered = false
|
|
245
127
|
|
|
246
128
|
// const pageRows = instance.getPageRows()
|
|
@@ -281,7 +163,7 @@ export function getInstance<
|
|
|
281
163
|
// Leave all the other rows that are selected alone.
|
|
282
164
|
const rowSelection = Object.assign({}, old)
|
|
283
165
|
|
|
284
|
-
const preGroupedFlatRows = instance.
|
|
166
|
+
const preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows
|
|
285
167
|
|
|
286
168
|
// We don't use `mutateRowIsSelected` here for performance reasons.
|
|
287
169
|
// All of the rows are flat already, so it wouldn't be worth it
|
|
@@ -307,7 +189,7 @@ export function getInstance<
|
|
|
307
189
|
|
|
308
190
|
const rowSelection: RowSelectionState = { ...old }
|
|
309
191
|
|
|
310
|
-
instance.
|
|
192
|
+
instance.getRowModel().rows.forEach(row => {
|
|
311
193
|
mutateRowIsSelected(rowSelection, row.id, value, instance)
|
|
312
194
|
})
|
|
313
195
|
|
|
@@ -389,6 +271,7 @@ export function getInstance<
|
|
|
389
271
|
|
|
390
272
|
// instance.setRowSelection(selectedRowIds)
|
|
391
273
|
// },
|
|
274
|
+
getPreSelectedRowModel: () => instance.getCoreRowModel(),
|
|
392
275
|
getSelectedRowModel: memo(
|
|
393
276
|
() => [instance.getState().rowSelection, instance.getCoreRowModel()],
|
|
394
277
|
(rowSelection, rowModel) => {
|
|
@@ -400,20 +283,14 @@ export function getInstance<
|
|
|
400
283
|
}
|
|
401
284
|
}
|
|
402
285
|
|
|
403
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
404
|
-
console.info('Selecting...')
|
|
405
|
-
|
|
406
286
|
return selectRowsFn(instance, rowModel)
|
|
407
287
|
},
|
|
408
288
|
{
|
|
409
289
|
key: 'getSelectedRowModel',
|
|
410
|
-
debug: instance.options.
|
|
290
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
411
291
|
onChange: () => instance._notifyExpandedReset(),
|
|
412
292
|
}
|
|
413
293
|
),
|
|
414
|
-
getSelectedRows: () => instance.getSelectedRowModel().rows,
|
|
415
|
-
getSelectedFlatRows: () => instance.getSelectedRowModel().flatRows,
|
|
416
|
-
getSelectedRowsById: () => instance.getSelectedRowModel().rowsById,
|
|
417
294
|
|
|
418
295
|
getFilteredSelectedRowModel: memo(
|
|
419
296
|
() => [
|
|
@@ -429,22 +306,14 @@ export function getInstance<
|
|
|
429
306
|
}
|
|
430
307
|
}
|
|
431
308
|
|
|
432
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
433
|
-
console.info('Selecting...')
|
|
434
|
-
|
|
435
309
|
return selectRowsFn(instance, rowModel)
|
|
436
310
|
},
|
|
437
311
|
{
|
|
438
312
|
key: 'getFilteredSelectedRowModel',
|
|
439
|
-
debug: instance.options.
|
|
313
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
440
314
|
onChange: () => instance._notifyExpandedReset(),
|
|
441
315
|
}
|
|
442
316
|
),
|
|
443
|
-
getFilteredSelectedRows: () => instance.getFilteredSelectedRowModel().rows,
|
|
444
|
-
getFilteredSelectedFlatRows: () =>
|
|
445
|
-
instance.getFilteredSelectedRowModel().flatRows,
|
|
446
|
-
getFilteredSelectedRowsById: () =>
|
|
447
|
-
instance.getFilteredSelectedRowModel().rowsById,
|
|
448
317
|
|
|
449
318
|
getGroupedSelectedRowModel: memo(
|
|
450
319
|
() => [instance.getState().rowSelection, instance.getGroupedRowModel()],
|
|
@@ -457,22 +326,14 @@ export function getInstance<
|
|
|
457
326
|
}
|
|
458
327
|
}
|
|
459
328
|
|
|
460
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
461
|
-
console.info('Selecting...')
|
|
462
|
-
|
|
463
329
|
return selectRowsFn(instance, rowModel)
|
|
464
330
|
},
|
|
465
331
|
{
|
|
466
332
|
key: 'getGroupedSelectedRowModel',
|
|
467
|
-
debug: instance.options.
|
|
333
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
468
334
|
onChange: () => instance._notifyExpandedReset(),
|
|
469
335
|
}
|
|
470
336
|
),
|
|
471
|
-
getGroupedSelectedRows: () => instance.getGroupedSelectedRowModel().rows,
|
|
472
|
-
getGroupedSelectedFlatRows: () =>
|
|
473
|
-
instance.getGroupedSelectedRowModel().flatRows,
|
|
474
|
-
getGroupedSelectedRowsById: () =>
|
|
475
|
-
instance.getGroupedSelectedRowModel().rowsById,
|
|
476
337
|
|
|
477
338
|
///
|
|
478
339
|
|
|
@@ -555,7 +416,8 @@ export function getInstance<
|
|
|
555
416
|
// },
|
|
556
417
|
|
|
557
418
|
getIsAllRowsSelected: () => {
|
|
558
|
-
const preFilteredFlatRows =
|
|
419
|
+
const preFilteredFlatRows =
|
|
420
|
+
instance.getPreGlobalFilteredRowModel().flatRows
|
|
559
421
|
const { rowSelection } = instance.getState()
|
|
560
422
|
|
|
561
423
|
let isAllRowsSelected = Boolean(
|
|
@@ -572,7 +434,7 @@ export function getInstance<
|
|
|
572
434
|
},
|
|
573
435
|
|
|
574
436
|
getIsAllPageRowsSelected: () => {
|
|
575
|
-
const paginationFlatRows = instance.
|
|
437
|
+
const paginationFlatRows = instance.getPaginationRowModel().flatRows
|
|
576
438
|
const { rowSelection } = instance.getState()
|
|
577
439
|
|
|
578
440
|
let isAllPageRowsSelected = !!paginationFlatRows.length
|
|
@@ -595,7 +457,7 @@ export function getInstance<
|
|
|
595
457
|
},
|
|
596
458
|
|
|
597
459
|
getIsSomePageRowsSelected: () => {
|
|
598
|
-
const paginationFlatRows = instance.
|
|
460
|
+
const paginationFlatRows = instance.getPaginationRowModel().flatRows
|
|
599
461
|
return instance.getIsAllPageRowsSelected()
|
|
600
462
|
? false
|
|
601
463
|
: !!paginationFlatRows?.length
|
|
@@ -672,15 +534,9 @@ export function getInstance<
|
|
|
672
534
|
}
|
|
673
535
|
}
|
|
674
536
|
|
|
675
|
-
export function createRow<
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
TFilterFns,
|
|
679
|
-
TSortingFns,
|
|
680
|
-
TAggregationFns
|
|
681
|
-
>(
|
|
682
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
683
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
537
|
+
export function createRow<TGenerics extends PartialGenerics>(
|
|
538
|
+
row: Row<TGenerics>,
|
|
539
|
+
instance: TableInstance<TGenerics>
|
|
684
540
|
): RowSelectionRow {
|
|
685
541
|
return {
|
|
686
542
|
getIsSelected: () => instance.getRowIsSelected(row.id),
|
|
@@ -693,17 +549,11 @@ export function createRow<
|
|
|
693
549
|
}
|
|
694
550
|
}
|
|
695
551
|
|
|
696
|
-
const mutateRowIsSelected = <
|
|
697
|
-
TData,
|
|
698
|
-
TValue,
|
|
699
|
-
TFilterFns,
|
|
700
|
-
TSortingFns,
|
|
701
|
-
TAggregationFns
|
|
702
|
-
>(
|
|
552
|
+
const mutateRowIsSelected = <TGenerics extends PartialGenerics>(
|
|
703
553
|
selectedRowIds: Record<string, boolean>,
|
|
704
554
|
id: string,
|
|
705
555
|
value: boolean,
|
|
706
|
-
instance:
|
|
556
|
+
instance: TableInstance<TGenerics>
|
|
707
557
|
) => {
|
|
708
558
|
const row = instance.getRow(id)
|
|
709
559
|
|
|
@@ -727,35 +577,17 @@ const mutateRowIsSelected = <
|
|
|
727
577
|
}
|
|
728
578
|
}
|
|
729
579
|
|
|
730
|
-
export function selectRowsFn<
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
TSortingFns,
|
|
735
|
-
TAggregationFns
|
|
736
|
-
>(
|
|
737
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
738
|
-
rowModel: RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
739
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
580
|
+
export function selectRowsFn<TGenerics extends PartialGenerics>(
|
|
581
|
+
instance: TableInstance<TGenerics>,
|
|
582
|
+
rowModel: RowModel<TGenerics>
|
|
583
|
+
): RowModel<TGenerics> {
|
|
740
584
|
const rowSelection = instance.getState().rowSelection
|
|
741
585
|
|
|
742
|
-
const newSelectedFlatRows: Row<
|
|
743
|
-
|
|
744
|
-
TValue,
|
|
745
|
-
TFilterFns,
|
|
746
|
-
TSortingFns,
|
|
747
|
-
TAggregationFns
|
|
748
|
-
>[] = []
|
|
749
|
-
const newSelectedRowsById: Record<
|
|
750
|
-
string,
|
|
751
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
752
|
-
> = {}
|
|
586
|
+
const newSelectedFlatRows: Row<TGenerics>[] = []
|
|
587
|
+
const newSelectedRowsById: Record<string, Row<TGenerics>> = {}
|
|
753
588
|
|
|
754
589
|
// Filters top level and nested rows
|
|
755
|
-
const recurseRows = (
|
|
756
|
-
rows: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[],
|
|
757
|
-
depth = 0
|
|
758
|
-
) => {
|
|
590
|
+
const recurseRows = (rows: Row<TGenerics>[], depth = 0) => {
|
|
759
591
|
return rows
|
|
760
592
|
.map(row => {
|
|
761
593
|
const isSelected = isRowSelected(row, rowSelection, instance) === true
|
|
@@ -776,13 +608,7 @@ export function selectRowsFn<
|
|
|
776
608
|
return row
|
|
777
609
|
}
|
|
778
610
|
})
|
|
779
|
-
.filter(Boolean) as Row<
|
|
780
|
-
TData,
|
|
781
|
-
TValue,
|
|
782
|
-
TFilterFns,
|
|
783
|
-
TSortingFns,
|
|
784
|
-
TAggregationFns
|
|
785
|
-
>[]
|
|
611
|
+
.filter(Boolean) as Row<TGenerics>[]
|
|
786
612
|
}
|
|
787
613
|
|
|
788
614
|
return {
|
|
@@ -792,16 +618,10 @@ export function selectRowsFn<
|
|
|
792
618
|
}
|
|
793
619
|
}
|
|
794
620
|
|
|
795
|
-
export function isRowSelected<
|
|
796
|
-
|
|
797
|
-
TValue,
|
|
798
|
-
TFilterFns,
|
|
799
|
-
TSortingFns,
|
|
800
|
-
TAggregationFns
|
|
801
|
-
>(
|
|
802
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
621
|
+
export function isRowSelected<TGenerics extends PartialGenerics>(
|
|
622
|
+
row: Row<TGenerics>,
|
|
803
623
|
selection: Record<string, boolean>,
|
|
804
|
-
instance:
|
|
624
|
+
instance: TableInstance<TGenerics>
|
|
805
625
|
): boolean | 'some' {
|
|
806
626
|
if (selection[row.id]) {
|
|
807
627
|
return true
|