@tanstack/react-table 8.0.0-alpha.2 → 8.0.0-alpha.3
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 +84 -51
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +11 -6
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +2 -16
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +23 -2
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +54 -5
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +23 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +87 -24
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +4 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +194 -0
- package/build/cjs/features/Pagination.js.map +1 -0
- package/build/cjs/features/Pinning.js +0 -14
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +541 -0
- package/build/cjs/features/RowSelection.js.map +1 -0
- package/build/cjs/features/Sorting.js +76 -18
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +8 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/sortTypes.js +1 -0
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +3 -2
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js +2 -2
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js +3 -2
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +4 -3
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js +3 -2
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +6 -3
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +2608 -1583
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +318 -248
- package/build/types/core.d.ts +10 -25
- package/build/types/createTable.d.ts +20 -2
- package/build/types/features/ColumnSizing.d.ts +4 -10
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +7 -2
- package/build/types/features/Grouping.d.ts +2 -2
- package/build/types/features/Ordering.d.ts +1 -1
- package/build/types/features/Pagination.d.ts +43 -0
- package/build/types/features/Pinning.d.ts +3 -3
- package/build/types/features/RowSelection.d.ts +66 -0
- package/build/types/features/Sorting.d.ts +5 -2
- package/build/types/sortTypes.d.ts +1 -0
- package/build/types/types.d.ts +9 -6
- 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 -0
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +5 -1
- package/build/umd/index.development.js +2608 -1583
- 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 +222 -272
- package/src/createTable.tsx +68 -8
- package/src/features/ColumnSizing.ts +8 -37
- package/src/features/Expanding.ts +27 -11
- package/src/features/Filters.ts +74 -19
- package/src/features/Grouping.ts +27 -12
- package/src/features/Headers.ts +26 -58
- package/src/features/Ordering.ts +2 -3
- package/src/features/Pagination.ts +314 -0
- package/src/features/Pinning.ts +3 -16
- package/src/features/RowSelection.ts +831 -0
- package/src/features/Sorting.ts +82 -22
- package/src/features/Visibility.ts +2 -4
- package/src/sortTypes.ts +1 -1
- package/src/types.ts +25 -8
- package/src/utils/columnFilterRowsFn.ts +5 -12
- package/src/utils/expandRowsFn.ts +2 -5
- package/src/utils/globalFilterRowsFn.ts +3 -10
- package/src/utils/groupRowsFn.ts +3 -5
- package/src/utils/paginateRowsFn.ts +34 -0
- package/src/utils/sortRowsFn.ts +5 -5
- package/src/utils.tsx +12 -4
- package/src/features/withPagination.oldts +0 -208
- package/src/features/withRowSelection.oldts +0 -467
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-table",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.3",
|
|
5
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
package/src/core.tsx
CHANGED
|
@@ -39,11 +39,23 @@ import * as Sorting from './features/Sorting'
|
|
|
39
39
|
import * as Grouping from './features/Grouping'
|
|
40
40
|
import * as Expanding from './features/Expanding'
|
|
41
41
|
import * as ColumnSizing from './features/ColumnSizing'
|
|
42
|
+
import * as Pagination from './features/Pagination'
|
|
43
|
+
import * as RowSelection from './features/RowSelection'
|
|
42
44
|
import { RowModel } from '.'
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const features = [
|
|
47
|
+
Visibility,
|
|
48
|
+
Ordering,
|
|
49
|
+
Pinning,
|
|
50
|
+
Headers,
|
|
51
|
+
Filters,
|
|
52
|
+
Sorting,
|
|
53
|
+
Grouping,
|
|
54
|
+
Expanding,
|
|
55
|
+
ColumnSizing,
|
|
56
|
+
Pagination,
|
|
57
|
+
RowSelection,
|
|
58
|
+
]
|
|
47
59
|
|
|
48
60
|
export type CoreOptions<
|
|
49
61
|
TData,
|
|
@@ -67,6 +79,7 @@ export type CoreOptions<
|
|
|
67
79
|
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
68
80
|
) => string
|
|
69
81
|
onStateChange?: (newState: TableState) => void
|
|
82
|
+
autoResetAll?: boolean
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
export type TableCore<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> =
|
|
@@ -261,93 +274,139 @@ export type CoreColumnDef<
|
|
|
261
274
|
TFilterFns,
|
|
262
275
|
TSortingFns,
|
|
263
276
|
TAggregationFns
|
|
264
|
-
> =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
277
|
+
> = {
|
|
278
|
+
id: string
|
|
279
|
+
accessorKey?: string & keyof TData
|
|
280
|
+
accessorFn?: AccessorFn<TData>
|
|
281
|
+
header?:
|
|
282
|
+
| string
|
|
283
|
+
| Renderable<{
|
|
284
|
+
instance: ReactTable<
|
|
285
|
+
TData,
|
|
286
|
+
TValue,
|
|
287
|
+
TFilterFns,
|
|
288
|
+
TSortingFns,
|
|
289
|
+
TAggregationFns
|
|
290
|
+
>
|
|
291
|
+
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
292
|
+
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
293
|
+
}>
|
|
294
|
+
} & // | Renderable<{ // | string // header?: // accessorKey?: never // id: string // accessorFn: AccessorFn<TData> // | {
|
|
295
|
+
// instance: ReactTable<
|
|
296
|
+
// TData,
|
|
297
|
+
// TValue,
|
|
298
|
+
// TFilterFns,
|
|
299
|
+
// TSortingFns,
|
|
300
|
+
// TAggregationFns
|
|
301
|
+
// >
|
|
302
|
+
// header: Header<
|
|
303
|
+
// TData,
|
|
304
|
+
// TValue,
|
|
305
|
+
// TFilterFns,
|
|
306
|
+
// TSortingFns,
|
|
307
|
+
// TAggregationFns
|
|
308
|
+
// >
|
|
309
|
+
// column: Column<
|
|
310
|
+
// TData,
|
|
311
|
+
// TValue,
|
|
312
|
+
// TFilterFns,
|
|
313
|
+
// TSortingFns,
|
|
314
|
+
// TAggregationFns
|
|
315
|
+
// >
|
|
316
|
+
// }>
|
|
317
|
+
// }
|
|
318
|
+
// | {
|
|
319
|
+
// accessorKey: string & keyof TData
|
|
320
|
+
// id?: string
|
|
321
|
+
// accessorFn?: never
|
|
322
|
+
// header?:
|
|
323
|
+
// | string
|
|
324
|
+
// | Renderable<{
|
|
325
|
+
// instance: ReactTable<
|
|
326
|
+
// TData,
|
|
327
|
+
// TValue,
|
|
328
|
+
// TFilterFns,
|
|
329
|
+
// TSortingFns,
|
|
330
|
+
// TAggregationFns
|
|
331
|
+
// >
|
|
332
|
+
// header: Header<
|
|
333
|
+
// TData,
|
|
334
|
+
// TValue,
|
|
335
|
+
// TFilterFns,
|
|
336
|
+
// TSortingFns,
|
|
337
|
+
// TAggregationFns
|
|
338
|
+
// >
|
|
339
|
+
// column: Column<
|
|
340
|
+
// TData,
|
|
341
|
+
// TValue,
|
|
342
|
+
// TFilterFns,
|
|
343
|
+
// TSortingFns,
|
|
344
|
+
// TAggregationFns
|
|
345
|
+
// >
|
|
346
|
+
// }>
|
|
347
|
+
// }
|
|
348
|
+
// | {
|
|
349
|
+
// id: string
|
|
350
|
+
// accessorKey?: never
|
|
351
|
+
// accessorFn?: never
|
|
352
|
+
// header?:
|
|
353
|
+
// | string
|
|
354
|
+
// | Renderable<{
|
|
355
|
+
// instance: ReactTable<
|
|
356
|
+
// TData,
|
|
357
|
+
// TValue,
|
|
358
|
+
// TFilterFns,
|
|
359
|
+
// TSortingFns,
|
|
360
|
+
// TAggregationFns
|
|
361
|
+
// >
|
|
362
|
+
// header: Header<
|
|
363
|
+
// TData,
|
|
364
|
+
// TValue,
|
|
365
|
+
// TFilterFns,
|
|
366
|
+
// TSortingFns,
|
|
367
|
+
// TAggregationFns
|
|
368
|
+
// >
|
|
369
|
+
// column: Column<
|
|
370
|
+
// TData,
|
|
371
|
+
// TValue,
|
|
372
|
+
// TFilterFns,
|
|
373
|
+
// TSortingFns,
|
|
374
|
+
// TAggregationFns
|
|
375
|
+
// >
|
|
376
|
+
// }>
|
|
377
|
+
// }
|
|
378
|
+
// | {
|
|
379
|
+
// header: string
|
|
380
|
+
// id?: string
|
|
381
|
+
// accessorKey?: never
|
|
382
|
+
// accessorFn?: never
|
|
383
|
+
// }
|
|
384
|
+
{
|
|
341
385
|
__generated: true
|
|
342
386
|
width?: number
|
|
343
387
|
minWidth?: number
|
|
344
388
|
maxWidth?: number
|
|
345
389
|
columns?: ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[]
|
|
346
390
|
footer?: Renderable<{
|
|
391
|
+
instance: ReactTable<
|
|
392
|
+
TData,
|
|
393
|
+
TValue,
|
|
394
|
+
TFilterFns,
|
|
395
|
+
TSortingFns,
|
|
396
|
+
TAggregationFns
|
|
397
|
+
>
|
|
347
398
|
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
348
399
|
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
349
400
|
}>
|
|
350
401
|
cell?: Renderable<{
|
|
402
|
+
instance: ReactTable<
|
|
403
|
+
TData,
|
|
404
|
+
TValue,
|
|
405
|
+
TFilterFns,
|
|
406
|
+
TSortingFns,
|
|
407
|
+
TAggregationFns
|
|
408
|
+
>
|
|
409
|
+
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
351
410
|
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
352
411
|
cell: Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
353
412
|
value: TValue
|
|
@@ -407,16 +466,9 @@ export function createTableInstance<
|
|
|
407
466
|
TAggregationFns
|
|
408
467
|
>
|
|
409
468
|
|
|
410
|
-
const defaultOptions = {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
...Pinning.getDefaultOptions(instance),
|
|
414
|
-
...Filters.getDefaultOptions(instance),
|
|
415
|
-
...Sorting.getDefaultOptions(instance),
|
|
416
|
-
...Grouping.getDefaultOptions(instance),
|
|
417
|
-
...Expanding.getDefaultOptions(instance),
|
|
418
|
-
...ColumnSizing.getDefaultOptions(instance),
|
|
419
|
-
}
|
|
469
|
+
const defaultOptions = features.reduce((obj, feature) => {
|
|
470
|
+
return Object.assign(obj, (feature as any).getDefaultOptions?.(instance))
|
|
471
|
+
}, {})
|
|
420
472
|
|
|
421
473
|
const defaultState = {}
|
|
422
474
|
|
|
@@ -431,16 +483,11 @@ export function createTableInstance<
|
|
|
431
483
|
instance.options = buildOptions(options)
|
|
432
484
|
|
|
433
485
|
const initialState = {
|
|
434
|
-
...
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
...Filters.getInitialState(),
|
|
438
|
-
...Sorting.getInitialState(),
|
|
439
|
-
...Grouping.getInitialState(),
|
|
440
|
-
...Expanding.getInitialState(),
|
|
441
|
-
...ColumnSizing.getInitialState(),
|
|
486
|
+
...features.reduce((obj, feature) => {
|
|
487
|
+
return Object.assign(obj, (feature as any).getInitialState?.())
|
|
488
|
+
}, {}),
|
|
442
489
|
...(options.initialState ?? {}),
|
|
443
|
-
}
|
|
490
|
+
} as TableState
|
|
444
491
|
|
|
445
492
|
const finalInstance: ReactTable<
|
|
446
493
|
TData,
|
|
@@ -450,15 +497,9 @@ export function createTableInstance<
|
|
|
450
497
|
TAggregationFns
|
|
451
498
|
> = {
|
|
452
499
|
...instance,
|
|
453
|
-
...
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
...Headers.getInstance(instance),
|
|
457
|
-
...Filters.getInstance(instance),
|
|
458
|
-
...Sorting.getInstance(instance),
|
|
459
|
-
...Grouping.getInstance(instance),
|
|
460
|
-
...Expanding.getInstance(instance),
|
|
461
|
-
...ColumnSizing.getInstance(instance),
|
|
500
|
+
...features.reduce((obj, feature) => {
|
|
501
|
+
return Object.assign(obj, (feature as any).getInstance?.(instance))
|
|
502
|
+
}, {}),
|
|
462
503
|
rerender,
|
|
463
504
|
initialState,
|
|
464
505
|
internalState: initialState,
|
|
@@ -476,19 +517,23 @@ export function createTableInstance<
|
|
|
476
517
|
) => `${parent ? [parent.id, index].join('.') : index}`,
|
|
477
518
|
|
|
478
519
|
getState: () => {
|
|
479
|
-
|
|
520
|
+
let state = {
|
|
480
521
|
...instance.internalState,
|
|
481
522
|
...instance.options.state,
|
|
482
523
|
}
|
|
524
|
+
|
|
525
|
+
return state
|
|
483
526
|
},
|
|
484
527
|
|
|
485
528
|
setState: (
|
|
486
529
|
updater: Updater<TableState>,
|
|
487
530
|
shouldRerender: boolean = true
|
|
488
531
|
) => {
|
|
489
|
-
const newState = functionalUpdate(updater, instance.internalState)
|
|
490
532
|
const onStateChange = instance.options.onStateChange
|
|
491
533
|
|
|
534
|
+
let internalState = instance.internalState
|
|
535
|
+
let newState = functionalUpdate(updater, internalState)
|
|
536
|
+
|
|
492
537
|
instance.internalState = newState
|
|
493
538
|
|
|
494
539
|
if (onStateChange) {
|
|
@@ -521,17 +566,15 @@ export function createTableInstance<
|
|
|
521
566
|
) => props.header.column.id,
|
|
522
567
|
cell: ({ value = '' }: { value: any }): JSX.Element =>
|
|
523
568
|
typeof value === 'boolean' ? value.toString() : value,
|
|
524
|
-
...
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
...Grouping.getDefaultColumn(),
|
|
569
|
+
...features.reduce((obj, feature) => {
|
|
570
|
+
return Object.assign(obj, (feature as any).getDefaultColumn?.())
|
|
571
|
+
}, {}),
|
|
528
572
|
...defaultColumn,
|
|
529
573
|
} as Partial<
|
|
530
574
|
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
531
575
|
>
|
|
532
576
|
},
|
|
533
|
-
'getDefaultColumn'
|
|
534
|
-
instance.options.debug
|
|
577
|
+
{ debug: instance.options.debug, key: 'getDefaultColumn' }
|
|
535
578
|
),
|
|
536
579
|
|
|
537
580
|
getColumnDefs: () => instance.options.columns,
|
|
@@ -595,8 +638,10 @@ export function createTableInstance<
|
|
|
595
638
|
...column.columns?.flatMap(d => d.getFlatColumns()),
|
|
596
639
|
]
|
|
597
640
|
},
|
|
598
|
-
|
|
599
|
-
|
|
641
|
+
{
|
|
642
|
+
key: 'column.getFlatColumns',
|
|
643
|
+
debug: instance.options.debug,
|
|
644
|
+
}
|
|
600
645
|
),
|
|
601
646
|
getLeafColumns: memo(
|
|
602
647
|
() => [instance.getOrderColumnsFn()],
|
|
@@ -619,74 +664,19 @@ export function createTableInstance<
|
|
|
619
664
|
>,
|
|
620
665
|
]
|
|
621
666
|
},
|
|
622
|
-
|
|
623
|
-
|
|
667
|
+
{
|
|
668
|
+
key: 'column.getLeafColumns',
|
|
669
|
+
debug: instance.options.debug,
|
|
670
|
+
}
|
|
624
671
|
),
|
|
625
672
|
}
|
|
626
673
|
|
|
627
|
-
column =
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
TData,
|
|
632
|
-
TValue,
|
|
633
|
-
TFilterFns,
|
|
634
|
-
TSortingFns,
|
|
635
|
-
TAggregationFns
|
|
636
|
-
>,
|
|
637
|
-
instance
|
|
638
|
-
),
|
|
639
|
-
Pinning.createColumn(
|
|
640
|
-
column as Column<
|
|
641
|
-
TData,
|
|
642
|
-
TValue,
|
|
643
|
-
TFilterFns,
|
|
644
|
-
TSortingFns,
|
|
645
|
-
TAggregationFns
|
|
646
|
-
>,
|
|
647
|
-
instance
|
|
648
|
-
),
|
|
649
|
-
Filters.createColumn(
|
|
650
|
-
column as Column<
|
|
651
|
-
TData,
|
|
652
|
-
TValue,
|
|
653
|
-
TFilterFns,
|
|
654
|
-
TSortingFns,
|
|
655
|
-
TAggregationFns
|
|
656
|
-
>,
|
|
657
|
-
instance
|
|
658
|
-
),
|
|
659
|
-
Sorting.createColumn(
|
|
660
|
-
column as Column<
|
|
661
|
-
TData,
|
|
662
|
-
TValue,
|
|
663
|
-
TFilterFns,
|
|
664
|
-
TSortingFns,
|
|
665
|
-
TAggregationFns
|
|
666
|
-
>,
|
|
667
|
-
instance
|
|
668
|
-
),
|
|
669
|
-
Grouping.createColumn(
|
|
670
|
-
column as Column<
|
|
671
|
-
TData,
|
|
672
|
-
TValue,
|
|
673
|
-
TFilterFns,
|
|
674
|
-
TSortingFns,
|
|
675
|
-
TAggregationFns
|
|
676
|
-
>,
|
|
677
|
-
instance
|
|
678
|
-
),
|
|
679
|
-
ColumnSizing.createColumn(
|
|
680
|
-
column as Column<
|
|
681
|
-
TData,
|
|
682
|
-
TValue,
|
|
683
|
-
TFilterFns,
|
|
684
|
-
TSortingFns,
|
|
685
|
-
TAggregationFns
|
|
686
|
-
>,
|
|
687
|
-
instance
|
|
674
|
+
column = features.reduce((obj, feature) => {
|
|
675
|
+
return Object.assign(
|
|
676
|
+
obj,
|
|
677
|
+
(feature as any).createColumn?.(column, instance)
|
|
688
678
|
)
|
|
689
|
-
)
|
|
679
|
+
}, column)
|
|
690
680
|
|
|
691
681
|
// Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
692
682
|
return column as Column<
|
|
@@ -740,8 +730,7 @@ export function createTableInstance<
|
|
|
740
730
|
|
|
741
731
|
return recurseColumns(columnDefs)
|
|
742
732
|
},
|
|
743
|
-
'getAllColumns',
|
|
744
|
-
instance.options.debug
|
|
733
|
+
{ key: 'getAllColumns', debug: instance.options.debug }
|
|
745
734
|
),
|
|
746
735
|
|
|
747
736
|
getAllFlatColumns: memo(
|
|
@@ -751,8 +740,7 @@ export function createTableInstance<
|
|
|
751
740
|
return column.getFlatColumns()
|
|
752
741
|
})
|
|
753
742
|
},
|
|
754
|
-
'getAllFlatColumns',
|
|
755
|
-
instance.options.debug
|
|
743
|
+
{ key: 'getAllFlatColumns', debug: instance.options.debug }
|
|
756
744
|
),
|
|
757
745
|
|
|
758
746
|
getAllFlatColumnsById: memo(
|
|
@@ -763,8 +751,7 @@ export function createTableInstance<
|
|
|
763
751
|
return acc
|
|
764
752
|
}, {} as Record<string, Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>>)
|
|
765
753
|
},
|
|
766
|
-
'getAllFlatColumnsById',
|
|
767
|
-
instance.options.debug
|
|
754
|
+
{ key: 'getAllFlatColumnsById', debug: instance.options.debug }
|
|
768
755
|
),
|
|
769
756
|
|
|
770
757
|
getAllLeafColumns: memo(
|
|
@@ -773,8 +760,7 @@ export function createTableInstance<
|
|
|
773
760
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns())
|
|
774
761
|
return orderColumns(leafColumns)
|
|
775
762
|
},
|
|
776
|
-
'getAllLeafColumns',
|
|
777
|
-
instance.options.debug
|
|
763
|
+
{ key: 'getAllLeafColumns', debug: instance.options.debug }
|
|
778
764
|
),
|
|
779
765
|
|
|
780
766
|
getColumn: columnId => {
|
|
@@ -826,24 +812,28 @@ export function createTableInstance<
|
|
|
826
812
|
value,
|
|
827
813
|
getCellProps: userProps =>
|
|
828
814
|
instance.getCellProps(row.id, column.id, userProps)!,
|
|
829
|
-
renderCell: () =>
|
|
815
|
+
renderCell: () =>
|
|
816
|
+
flexRender(column.cell, { instance, column, row, cell, value }),
|
|
830
817
|
}
|
|
831
818
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
cell
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
819
|
+
features.forEach(feature => {
|
|
820
|
+
Object.assign(
|
|
821
|
+
cell,
|
|
822
|
+
(feature as any).createCell?.(
|
|
823
|
+
cell as Cell<
|
|
824
|
+
TData,
|
|
825
|
+
TValue,
|
|
826
|
+
TFilterFns,
|
|
827
|
+
TSortingFns,
|
|
828
|
+
TAggregationFns
|
|
829
|
+
> &
|
|
830
|
+
Grouping.GroupingCell,
|
|
831
|
+
column,
|
|
832
|
+
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
833
|
+
instance
|
|
834
|
+
)
|
|
835
|
+
)
|
|
836
|
+
}, {})
|
|
847
837
|
|
|
848
838
|
return cell
|
|
849
839
|
},
|
|
@@ -885,8 +875,10 @@ export function createTableInstance<
|
|
|
885
875
|
)
|
|
886
876
|
})
|
|
887
877
|
},
|
|
888
|
-
|
|
889
|
-
|
|
878
|
+
{
|
|
879
|
+
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
|
|
880
|
+
debug: instance.options.debug,
|
|
881
|
+
}
|
|
890
882
|
)
|
|
891
883
|
|
|
892
884
|
row.getAllCellsByColumnId = memo(
|
|
@@ -897,25 +889,15 @@ export function createTableInstance<
|
|
|
897
889
|
return acc
|
|
898
890
|
}, {} as Record<string, Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>>)
|
|
899
891
|
},
|
|
900
|
-
|
|
901
|
-
|
|
892
|
+
{
|
|
893
|
+
key: 'row.getAllCellsByColumnId',
|
|
894
|
+
debug: instance.options.debug,
|
|
895
|
+
}
|
|
902
896
|
)
|
|
903
897
|
|
|
904
|
-
|
|
905
|
-
row,
|
|
906
|
-
|
|
907
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
908
|
-
instance
|
|
909
|
-
),
|
|
910
|
-
Grouping.createRow(
|
|
911
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
912
|
-
instance
|
|
913
|
-
),
|
|
914
|
-
Expanding.createRow(
|
|
915
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
916
|
-
instance
|
|
917
|
-
)
|
|
918
|
-
)
|
|
898
|
+
features.forEach(feature => {
|
|
899
|
+
Object.assign(row, (feature as any).createRow?.(row, instance))
|
|
900
|
+
})
|
|
919
901
|
|
|
920
902
|
return row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
921
903
|
},
|
|
@@ -935,50 +917,6 @@ export function createTableInstance<
|
|
|
935
917
|
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
936
918
|
console.info('Accessing...')
|
|
937
919
|
|
|
938
|
-
// Auto-reset data-dependent states if configured
|
|
939
|
-
if (
|
|
940
|
-
instance.options.autoResetColumnFilters &&
|
|
941
|
-
// @ts-ignore
|
|
942
|
-
instance.getRowModelNonFirst
|
|
943
|
-
) {
|
|
944
|
-
instance.resetColumnFilters()
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
if (
|
|
948
|
-
instance.options.autoResetGlobalFilter &&
|
|
949
|
-
// @ts-ignore
|
|
950
|
-
instance.getRowModelNonFirst
|
|
951
|
-
) {
|
|
952
|
-
instance.resetGlobalFilter()
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
if (
|
|
956
|
-
instance.options.autoResetSorting &&
|
|
957
|
-
// @ts-ignore
|
|
958
|
-
instance.getRowModelNonFirst
|
|
959
|
-
) {
|
|
960
|
-
instance.resetSorting()
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
if (
|
|
964
|
-
instance.options.autoResetGrouping &&
|
|
965
|
-
// @ts-ignore
|
|
966
|
-
instance.getRowModelNonFirst
|
|
967
|
-
) {
|
|
968
|
-
instance.resetGrouping()
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
if (
|
|
972
|
-
instance.options.autoResetExpanded &&
|
|
973
|
-
// @ts-ignore
|
|
974
|
-
instance.getRowModelNonFirst
|
|
975
|
-
) {
|
|
976
|
-
instance.resetExpanded()
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
// @ts-ignore
|
|
980
|
-
instance.getRowModelNonFirst = true
|
|
981
|
-
|
|
982
920
|
// Access the row model using initial columns
|
|
983
921
|
const rows: Row<
|
|
984
922
|
TData,
|
|
@@ -1087,8 +1025,14 @@ export function createTableInstance<
|
|
|
1087
1025
|
|
|
1088
1026
|
return { rows, flatRows, rowsById }
|
|
1089
1027
|
},
|
|
1090
|
-
|
|
1091
|
-
|
|
1028
|
+
{
|
|
1029
|
+
key: 'getRowModel',
|
|
1030
|
+
debug: instance.options.debug,
|
|
1031
|
+
onChange: () => {
|
|
1032
|
+
instance._notifyRowSelectionReset()
|
|
1033
|
+
instance._notifyFiltersReset()
|
|
1034
|
+
},
|
|
1035
|
+
}
|
|
1092
1036
|
),
|
|
1093
1037
|
|
|
1094
1038
|
// The standard
|
|
@@ -1228,5 +1172,11 @@ export function createTableInstance<
|
|
|
1228
1172
|
}, 0) ?? 0,
|
|
1229
1173
|
}
|
|
1230
1174
|
|
|
1231
|
-
|
|
1175
|
+
instance = Object.assign(instance, finalInstance)
|
|
1176
|
+
|
|
1177
|
+
// This won't trigger a rerender yet, but it will force
|
|
1178
|
+
// pagination derivation to run (particularly pageSize detection)
|
|
1179
|
+
instance.setPagination(d => d)
|
|
1180
|
+
|
|
1181
|
+
return instance
|
|
1232
1182
|
}
|