@tanstack/react-table 8.0.0-alpha.1 → 8.0.0-alpha.4
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 +118 -59
- 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 +317 -0
- package/build/cjs/features/ColumnSizing.js.map +1 -0
- 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 +88 -22
- 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 +198 -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/index.js +2 -0
- package/build/cjs/index.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/paginateRowsFn.js +44 -0
- package/build/cjs/utils/paginateRowsFn.js.map +1 -0
- 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 +1613 -225
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +363 -217
- package/build/types/core.d.ts +14 -25
- package/build/types/createTable.d.ts +21 -3
- package/build/types/features/ColumnSizing.d.ts +67 -0
- 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 +44 -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/index.d.ts +1 -0
- package/build/types/sortTypes.d.ts +5 -4
- package/build/types/types.d.ts +13 -8
- 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 +7 -3
- package/build/umd/index.development.js +1613 -224
- 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 +252 -265
- package/src/createTable.tsx +69 -9
- package/src/features/ColumnSizing.ts +453 -0
- package/src/features/Expanding.ts +27 -11
- package/src/features/Filters.ts +75 -20
- package/src/features/Grouping.ts +27 -12
- package/src/features/Headers.ts +55 -50
- package/src/features/Ordering.ts +2 -3
- package/src/features/Pagination.ts +327 -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/index.tsx +1 -0
- package/src/sortTypes.ts +1 -1
- package/src/types.ts +55 -9
- 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 +20 -6
- package/src/features/withColumnResizing.oldts +0 -281
- package/src/features/withPagination.oldts +0 -208
- package/src/features/withRowSelection.oldts +0 -467
package/src/core.tsx
CHANGED
|
@@ -38,11 +38,24 @@ import * as Filters from './features/Filters'
|
|
|
38
38
|
import * as Sorting from './features/Sorting'
|
|
39
39
|
import * as Grouping from './features/Grouping'
|
|
40
40
|
import * as Expanding from './features/Expanding'
|
|
41
|
+
import * as ColumnSizing from './features/ColumnSizing'
|
|
42
|
+
import * as Pagination from './features/Pagination'
|
|
43
|
+
import * as RowSelection from './features/RowSelection'
|
|
41
44
|
import { RowModel } from '.'
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
]
|
|
46
59
|
|
|
47
60
|
export type CoreOptions<
|
|
48
61
|
TData,
|
|
@@ -66,6 +79,7 @@ export type CoreOptions<
|
|
|
66
79
|
parent?: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
67
80
|
) => string
|
|
68
81
|
onStateChange?: (newState: TableState) => void
|
|
82
|
+
autoResetAll?: boolean
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
export type TableCore<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> =
|
|
@@ -225,6 +239,10 @@ export type TableCore<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> =
|
|
|
225
239
|
columnId: string,
|
|
226
240
|
userProps?: TGetter
|
|
227
241
|
) => undefined | PropGetterValue<CellProps, TGetter>
|
|
242
|
+
getTableWidth: () => number
|
|
243
|
+
getLeftTableWidth: () => number
|
|
244
|
+
getCenterTableWidth: () => number
|
|
245
|
+
getRightTableWidth: () => number
|
|
228
246
|
}
|
|
229
247
|
|
|
230
248
|
export type CoreRow<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> = {
|
|
@@ -256,93 +274,138 @@ export type CoreColumnDef<
|
|
|
256
274
|
TFilterFns,
|
|
257
275
|
TSortingFns,
|
|
258
276
|
TAggregationFns
|
|
259
|
-
> =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
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
|
+
} & // instance: ReactTable< // | Renderable<{ // | string // header?: // accessorKey?: never // id: string // accessorFn: AccessorFn<TData> // | {
|
|
295
|
+
// TData,
|
|
296
|
+
// TValue,
|
|
297
|
+
// TFilterFns,
|
|
298
|
+
// TSortingFns,
|
|
299
|
+
// TAggregationFns
|
|
300
|
+
// >
|
|
301
|
+
// header: Header<
|
|
302
|
+
// TData,
|
|
303
|
+
// TValue,
|
|
304
|
+
// TFilterFns,
|
|
305
|
+
// TSortingFns,
|
|
306
|
+
// TAggregationFns
|
|
307
|
+
// >
|
|
308
|
+
// column: Column<
|
|
309
|
+
// TData,
|
|
310
|
+
// TValue,
|
|
311
|
+
// TFilterFns,
|
|
312
|
+
// TSortingFns,
|
|
313
|
+
// TAggregationFns
|
|
314
|
+
// >
|
|
315
|
+
// }>
|
|
316
|
+
// }
|
|
317
|
+
// | {
|
|
318
|
+
// accessorKey: string & keyof TData
|
|
319
|
+
// id?: string
|
|
320
|
+
// accessorFn?: never
|
|
321
|
+
// header?:
|
|
322
|
+
// | string
|
|
323
|
+
// | Renderable<{
|
|
324
|
+
// instance: ReactTable<
|
|
325
|
+
// TData,
|
|
326
|
+
// TValue,
|
|
327
|
+
// TFilterFns,
|
|
328
|
+
// TSortingFns,
|
|
329
|
+
// TAggregationFns
|
|
330
|
+
// >
|
|
331
|
+
// header: Header<
|
|
332
|
+
// TData,
|
|
333
|
+
// TValue,
|
|
334
|
+
// TFilterFns,
|
|
335
|
+
// TSortingFns,
|
|
336
|
+
// TAggregationFns
|
|
337
|
+
// >
|
|
338
|
+
// column: Column<
|
|
339
|
+
// TData,
|
|
340
|
+
// TValue,
|
|
341
|
+
// TFilterFns,
|
|
342
|
+
// TSortingFns,
|
|
343
|
+
// TAggregationFns
|
|
344
|
+
// >
|
|
345
|
+
// }>
|
|
346
|
+
// }
|
|
347
|
+
// | {
|
|
348
|
+
// id: string
|
|
349
|
+
// accessorKey?: never
|
|
350
|
+
// accessorFn?: never
|
|
351
|
+
// header?:
|
|
352
|
+
// | string
|
|
353
|
+
// | Renderable<{
|
|
354
|
+
// instance: ReactTable<
|
|
355
|
+
// TData,
|
|
356
|
+
// TValue,
|
|
357
|
+
// TFilterFns,
|
|
358
|
+
// TSortingFns,
|
|
359
|
+
// TAggregationFns
|
|
360
|
+
// >
|
|
361
|
+
// header: Header<
|
|
362
|
+
// TData,
|
|
363
|
+
// TValue,
|
|
364
|
+
// TFilterFns,
|
|
365
|
+
// TSortingFns,
|
|
366
|
+
// TAggregationFns
|
|
367
|
+
// >
|
|
368
|
+
// column: Column<
|
|
369
|
+
// TData,
|
|
370
|
+
// TValue,
|
|
371
|
+
// TFilterFns,
|
|
372
|
+
// TSortingFns,
|
|
373
|
+
// TAggregationFns
|
|
374
|
+
// >
|
|
375
|
+
// }>
|
|
376
|
+
// }
|
|
377
|
+
// | {
|
|
378
|
+
// header: string
|
|
379
|
+
// id?: string
|
|
380
|
+
// accessorKey?: never
|
|
381
|
+
// accessorFn?: never
|
|
382
|
+
// }
|
|
383
|
+
{
|
|
336
384
|
__generated: true
|
|
337
385
|
width?: number
|
|
338
386
|
minWidth?: number
|
|
339
387
|
maxWidth?: number
|
|
340
388
|
columns?: ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[]
|
|
341
389
|
footer?: Renderable<{
|
|
390
|
+
instance: ReactTable<
|
|
391
|
+
TData,
|
|
392
|
+
TValue,
|
|
393
|
+
TFilterFns,
|
|
394
|
+
TSortingFns,
|
|
395
|
+
TAggregationFns
|
|
396
|
+
>
|
|
342
397
|
header: Header<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
343
398
|
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
344
399
|
}>
|
|
345
400
|
cell?: Renderable<{
|
|
401
|
+
instance: ReactTable<
|
|
402
|
+
TData,
|
|
403
|
+
TValue,
|
|
404
|
+
TFilterFns,
|
|
405
|
+
TSortingFns,
|
|
406
|
+
TAggregationFns
|
|
407
|
+
>
|
|
408
|
+
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
346
409
|
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
347
410
|
cell: Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
348
411
|
value: TValue
|
|
@@ -402,15 +465,9 @@ export function createTableInstance<
|
|
|
402
465
|
TAggregationFns
|
|
403
466
|
>
|
|
404
467
|
|
|
405
|
-
const defaultOptions = {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
...Pinning.getDefaultOptions(instance),
|
|
409
|
-
...Filters.getDefaultOptions(instance),
|
|
410
|
-
...Sorting.getDefaultOptions(instance),
|
|
411
|
-
...Grouping.getDefaultOptions(instance),
|
|
412
|
-
...Expanding.getDefaultOptions(instance),
|
|
413
|
-
}
|
|
468
|
+
const defaultOptions = features.reduce((obj, feature) => {
|
|
469
|
+
return Object.assign(obj, (feature as any).getDefaultOptions?.(instance))
|
|
470
|
+
}, {})
|
|
414
471
|
|
|
415
472
|
const defaultState = {}
|
|
416
473
|
|
|
@@ -425,15 +482,11 @@ export function createTableInstance<
|
|
|
425
482
|
instance.options = buildOptions(options)
|
|
426
483
|
|
|
427
484
|
const initialState = {
|
|
428
|
-
...
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
...Filters.getInitialState(),
|
|
432
|
-
...Sorting.getInitialState(),
|
|
433
|
-
...Grouping.getInitialState(),
|
|
434
|
-
...Expanding.getInitialState(),
|
|
485
|
+
...features.reduce((obj, feature) => {
|
|
486
|
+
return Object.assign(obj, (feature as any).getInitialState?.())
|
|
487
|
+
}, {}),
|
|
435
488
|
...(options.initialState ?? {}),
|
|
436
|
-
}
|
|
489
|
+
} as TableState
|
|
437
490
|
|
|
438
491
|
const finalInstance: ReactTable<
|
|
439
492
|
TData,
|
|
@@ -443,14 +496,9 @@ export function createTableInstance<
|
|
|
443
496
|
TAggregationFns
|
|
444
497
|
> = {
|
|
445
498
|
...instance,
|
|
446
|
-
...
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
...Headers.getInstance(instance),
|
|
450
|
-
...Filters.getInstance(instance),
|
|
451
|
-
...Sorting.getInstance(instance),
|
|
452
|
-
...Grouping.getInstance(instance),
|
|
453
|
-
...Expanding.getInstance(instance),
|
|
499
|
+
...features.reduce((obj, feature) => {
|
|
500
|
+
return Object.assign(obj, (feature as any).getInstance?.(instance))
|
|
501
|
+
}, {}),
|
|
454
502
|
rerender,
|
|
455
503
|
initialState,
|
|
456
504
|
internalState: initialState,
|
|
@@ -468,19 +516,23 @@ export function createTableInstance<
|
|
|
468
516
|
) => `${parent ? [parent.id, index].join('.') : index}`,
|
|
469
517
|
|
|
470
518
|
getState: () => {
|
|
471
|
-
|
|
519
|
+
let state = {
|
|
472
520
|
...instance.internalState,
|
|
473
521
|
...instance.options.state,
|
|
474
522
|
}
|
|
523
|
+
|
|
524
|
+
return state
|
|
475
525
|
},
|
|
476
526
|
|
|
477
527
|
setState: (
|
|
478
528
|
updater: Updater<TableState>,
|
|
479
529
|
shouldRerender: boolean = true
|
|
480
530
|
) => {
|
|
481
|
-
const newState = functionalUpdate(updater, instance.internalState)
|
|
482
531
|
const onStateChange = instance.options.onStateChange
|
|
483
532
|
|
|
533
|
+
let internalState = instance.internalState
|
|
534
|
+
let newState = functionalUpdate(updater, internalState)
|
|
535
|
+
|
|
484
536
|
instance.internalState = newState
|
|
485
537
|
|
|
486
538
|
if (onStateChange) {
|
|
@@ -513,17 +565,15 @@ export function createTableInstance<
|
|
|
513
565
|
) => props.header.column.id,
|
|
514
566
|
cell: ({ value = '' }: { value: any }): JSX.Element =>
|
|
515
567
|
typeof value === 'boolean' ? value.toString() : value,
|
|
516
|
-
...
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
...Grouping.getDefaultColumn(),
|
|
568
|
+
...features.reduce((obj, feature) => {
|
|
569
|
+
return Object.assign(obj, (feature as any).getDefaultColumn?.())
|
|
570
|
+
}, {}),
|
|
520
571
|
...defaultColumn,
|
|
521
572
|
} as Partial<
|
|
522
573
|
ColumnDef<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
523
574
|
>
|
|
524
575
|
},
|
|
525
|
-
'getDefaultColumn'
|
|
526
|
-
instance.options.debug
|
|
576
|
+
{ debug: instance.options.debug, key: 'getDefaultColumn' }
|
|
527
577
|
),
|
|
528
578
|
|
|
529
579
|
getColumnDefs: () => instance.options.columns,
|
|
@@ -563,9 +613,7 @@ export function createTableInstance<
|
|
|
563
613
|
TSortingFns,
|
|
564
614
|
TAggregationFns
|
|
565
615
|
> = {
|
|
566
|
-
|
|
567
|
-
minWidth: 20,
|
|
568
|
-
maxWidth: Number.MAX_SAFE_INTEGER,
|
|
616
|
+
...ColumnSizing.defaultColumnSizing,
|
|
569
617
|
...defaultColumn,
|
|
570
618
|
...columnDef,
|
|
571
619
|
id: `${id}`,
|
|
@@ -589,8 +637,10 @@ export function createTableInstance<
|
|
|
589
637
|
...column.columns?.flatMap(d => d.getFlatColumns()),
|
|
590
638
|
]
|
|
591
639
|
},
|
|
592
|
-
|
|
593
|
-
|
|
640
|
+
{
|
|
641
|
+
key: 'column.getFlatColumns',
|
|
642
|
+
debug: instance.options.debug,
|
|
643
|
+
}
|
|
594
644
|
),
|
|
595
645
|
getLeafColumns: memo(
|
|
596
646
|
() => [instance.getOrderColumnsFn()],
|
|
@@ -613,64 +663,19 @@ export function createTableInstance<
|
|
|
613
663
|
>,
|
|
614
664
|
]
|
|
615
665
|
},
|
|
616
|
-
|
|
617
|
-
|
|
666
|
+
{
|
|
667
|
+
key: 'column.getLeafColumns',
|
|
668
|
+
debug: instance.options.debug,
|
|
669
|
+
}
|
|
618
670
|
),
|
|
619
671
|
}
|
|
620
672
|
|
|
621
|
-
column =
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
TData,
|
|
626
|
-
TValue,
|
|
627
|
-
TFilterFns,
|
|
628
|
-
TSortingFns,
|
|
629
|
-
TAggregationFns
|
|
630
|
-
>,
|
|
631
|
-
instance
|
|
632
|
-
),
|
|
633
|
-
Pinning.createColumn(
|
|
634
|
-
column as Column<
|
|
635
|
-
TData,
|
|
636
|
-
TValue,
|
|
637
|
-
TFilterFns,
|
|
638
|
-
TSortingFns,
|
|
639
|
-
TAggregationFns
|
|
640
|
-
>,
|
|
641
|
-
instance
|
|
642
|
-
),
|
|
643
|
-
Filters.createColumn(
|
|
644
|
-
column as Column<
|
|
645
|
-
TData,
|
|
646
|
-
TValue,
|
|
647
|
-
TFilterFns,
|
|
648
|
-
TSortingFns,
|
|
649
|
-
TAggregationFns
|
|
650
|
-
>,
|
|
651
|
-
instance
|
|
652
|
-
),
|
|
653
|
-
Sorting.createColumn(
|
|
654
|
-
column as Column<
|
|
655
|
-
TData,
|
|
656
|
-
TValue,
|
|
657
|
-
TFilterFns,
|
|
658
|
-
TSortingFns,
|
|
659
|
-
TAggregationFns
|
|
660
|
-
>,
|
|
661
|
-
instance
|
|
662
|
-
),
|
|
663
|
-
Grouping.createColumn(
|
|
664
|
-
column as Column<
|
|
665
|
-
TData,
|
|
666
|
-
TValue,
|
|
667
|
-
TFilterFns,
|
|
668
|
-
TSortingFns,
|
|
669
|
-
TAggregationFns
|
|
670
|
-
>,
|
|
671
|
-
instance
|
|
673
|
+
column = features.reduce((obj, feature) => {
|
|
674
|
+
return Object.assign(
|
|
675
|
+
obj,
|
|
676
|
+
(feature as any).createColumn?.(column, instance)
|
|
672
677
|
)
|
|
673
|
-
)
|
|
678
|
+
}, column)
|
|
674
679
|
|
|
675
680
|
// Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
676
681
|
return column as Column<
|
|
@@ -724,8 +729,7 @@ export function createTableInstance<
|
|
|
724
729
|
|
|
725
730
|
return recurseColumns(columnDefs)
|
|
726
731
|
},
|
|
727
|
-
'getAllColumns',
|
|
728
|
-
instance.options.debug
|
|
732
|
+
{ key: 'getAllColumns', debug: instance.options.debug }
|
|
729
733
|
),
|
|
730
734
|
|
|
731
735
|
getAllFlatColumns: memo(
|
|
@@ -735,8 +739,7 @@ export function createTableInstance<
|
|
|
735
739
|
return column.getFlatColumns()
|
|
736
740
|
})
|
|
737
741
|
},
|
|
738
|
-
'getAllFlatColumns',
|
|
739
|
-
instance.options.debug
|
|
742
|
+
{ key: 'getAllFlatColumns', debug: instance.options.debug }
|
|
740
743
|
),
|
|
741
744
|
|
|
742
745
|
getAllFlatColumnsById: memo(
|
|
@@ -747,8 +750,7 @@ export function createTableInstance<
|
|
|
747
750
|
return acc
|
|
748
751
|
}, {} as Record<string, Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>>)
|
|
749
752
|
},
|
|
750
|
-
'getAllFlatColumnsById',
|
|
751
|
-
instance.options.debug
|
|
753
|
+
{ key: 'getAllFlatColumnsById', debug: instance.options.debug }
|
|
752
754
|
),
|
|
753
755
|
|
|
754
756
|
getAllLeafColumns: memo(
|
|
@@ -757,8 +759,7 @@ export function createTableInstance<
|
|
|
757
759
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns())
|
|
758
760
|
return orderColumns(leafColumns)
|
|
759
761
|
},
|
|
760
|
-
'getAllLeafColumns',
|
|
761
|
-
instance.options.debug
|
|
762
|
+
{ key: 'getAllLeafColumns', debug: instance.options.debug }
|
|
762
763
|
),
|
|
763
764
|
|
|
764
765
|
getColumn: columnId => {
|
|
@@ -783,9 +784,14 @@ export function createTableInstance<
|
|
|
783
784
|
throw new Error()
|
|
784
785
|
}
|
|
785
786
|
|
|
787
|
+
const columnSize = instance.getState().columnSizing[column.id]
|
|
788
|
+
|
|
786
789
|
return Math.min(
|
|
787
|
-
Math.max(
|
|
788
|
-
|
|
790
|
+
Math.max(
|
|
791
|
+
column.minWidth ?? ColumnSizing.defaultColumnSizing.minWidth,
|
|
792
|
+
columnSize ?? column.width ?? ColumnSizing.defaultColumnSizing.width
|
|
793
|
+
),
|
|
794
|
+
column.maxWidth ?? ColumnSizing.defaultColumnSizing.maxWidth
|
|
789
795
|
)
|
|
790
796
|
},
|
|
791
797
|
|
|
@@ -805,24 +811,28 @@ export function createTableInstance<
|
|
|
805
811
|
value,
|
|
806
812
|
getCellProps: userProps =>
|
|
807
813
|
instance.getCellProps(row.id, column.id, userProps)!,
|
|
808
|
-
renderCell: () =>
|
|
814
|
+
renderCell: () =>
|
|
815
|
+
flexRender(column.cell, { instance, column, row, cell, value }),
|
|
809
816
|
}
|
|
810
817
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
cell
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
818
|
+
features.forEach(feature => {
|
|
819
|
+
Object.assign(
|
|
820
|
+
cell,
|
|
821
|
+
(feature as any).createCell?.(
|
|
822
|
+
cell as Cell<
|
|
823
|
+
TData,
|
|
824
|
+
TValue,
|
|
825
|
+
TFilterFns,
|
|
826
|
+
TSortingFns,
|
|
827
|
+
TAggregationFns
|
|
828
|
+
> &
|
|
829
|
+
Grouping.GroupingCell,
|
|
830
|
+
column,
|
|
831
|
+
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
832
|
+
instance
|
|
833
|
+
)
|
|
834
|
+
)
|
|
835
|
+
}, {})
|
|
826
836
|
|
|
827
837
|
return cell
|
|
828
838
|
},
|
|
@@ -864,8 +874,10 @@ export function createTableInstance<
|
|
|
864
874
|
)
|
|
865
875
|
})
|
|
866
876
|
},
|
|
867
|
-
|
|
868
|
-
|
|
877
|
+
{
|
|
878
|
+
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
|
|
879
|
+
debug: instance.options.debug,
|
|
880
|
+
}
|
|
869
881
|
)
|
|
870
882
|
|
|
871
883
|
row.getAllCellsByColumnId = memo(
|
|
@@ -876,25 +888,15 @@ export function createTableInstance<
|
|
|
876
888
|
return acc
|
|
877
889
|
}, {} as Record<string, Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>>)
|
|
878
890
|
},
|
|
879
|
-
|
|
880
|
-
|
|
891
|
+
{
|
|
892
|
+
key: 'row.getAllCellsByColumnId',
|
|
893
|
+
debug: instance.options.debug,
|
|
894
|
+
}
|
|
881
895
|
)
|
|
882
896
|
|
|
883
|
-
|
|
884
|
-
row,
|
|
885
|
-
|
|
886
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
887
|
-
instance
|
|
888
|
-
),
|
|
889
|
-
Grouping.createRow(
|
|
890
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
891
|
-
instance
|
|
892
|
-
),
|
|
893
|
-
Expanding.createRow(
|
|
894
|
-
row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
895
|
-
instance
|
|
896
|
-
)
|
|
897
|
-
)
|
|
897
|
+
features.forEach(feature => {
|
|
898
|
+
Object.assign(row, (feature as any).createRow?.(row, instance))
|
|
899
|
+
})
|
|
898
900
|
|
|
899
901
|
return row as Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
900
902
|
},
|
|
@@ -914,50 +916,6 @@ export function createTableInstance<
|
|
|
914
916
|
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
915
917
|
console.info('Accessing...')
|
|
916
918
|
|
|
917
|
-
// Auto-reset data-dependent states if configured
|
|
918
|
-
if (
|
|
919
|
-
instance.options.autoResetColumnFilters &&
|
|
920
|
-
// @ts-ignore
|
|
921
|
-
instance.getRowModelNonFirst
|
|
922
|
-
) {
|
|
923
|
-
instance.resetColumnFilters()
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
if (
|
|
927
|
-
instance.options.autoResetGlobalFilter &&
|
|
928
|
-
// @ts-ignore
|
|
929
|
-
instance.getRowModelNonFirst
|
|
930
|
-
) {
|
|
931
|
-
instance.resetGlobalFilter()
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
if (
|
|
935
|
-
instance.options.autoResetSorting &&
|
|
936
|
-
// @ts-ignore
|
|
937
|
-
instance.getRowModelNonFirst
|
|
938
|
-
) {
|
|
939
|
-
instance.resetSorting()
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
if (
|
|
943
|
-
instance.options.autoResetGrouping &&
|
|
944
|
-
// @ts-ignore
|
|
945
|
-
instance.getRowModelNonFirst
|
|
946
|
-
) {
|
|
947
|
-
instance.resetGrouping()
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
if (
|
|
951
|
-
instance.options.autoResetExpanded &&
|
|
952
|
-
// @ts-ignore
|
|
953
|
-
instance.getRowModelNonFirst
|
|
954
|
-
) {
|
|
955
|
-
instance.resetExpanded()
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// @ts-ignore
|
|
959
|
-
instance.getRowModelNonFirst = true
|
|
960
|
-
|
|
961
919
|
// Access the row model using initial columns
|
|
962
920
|
const rows: Row<
|
|
963
921
|
TData,
|
|
@@ -1066,8 +1024,14 @@ export function createTableInstance<
|
|
|
1066
1024
|
|
|
1067
1025
|
return { rows, flatRows, rowsById }
|
|
1068
1026
|
},
|
|
1069
|
-
|
|
1070
|
-
|
|
1027
|
+
{
|
|
1028
|
+
key: 'getRowModel',
|
|
1029
|
+
debug: instance.options.debug,
|
|
1030
|
+
onChange: () => {
|
|
1031
|
+
instance._notifyRowSelectionReset()
|
|
1032
|
+
instance._notifyFiltersReset()
|
|
1033
|
+
},
|
|
1034
|
+
}
|
|
1071
1035
|
),
|
|
1072
1036
|
|
|
1073
1037
|
// The standard
|
|
@@ -1088,7 +1052,7 @@ export function createTableInstance<
|
|
|
1088
1052
|
// expanded rows, which then work their way up
|
|
1089
1053
|
|
|
1090
1054
|
getRowModel: () => {
|
|
1091
|
-
return instance.
|
|
1055
|
+
return instance.getPaginationRowModel()
|
|
1092
1056
|
},
|
|
1093
1057
|
|
|
1094
1058
|
getRows: () => {
|
|
@@ -1188,7 +1152,30 @@ export function createTableInstance<
|
|
|
1188
1152
|
userProps
|
|
1189
1153
|
)
|
|
1190
1154
|
},
|
|
1155
|
+
|
|
1156
|
+
getTableWidth: () =>
|
|
1157
|
+
instance.getHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1158
|
+
return sum + header.getWidth()
|
|
1159
|
+
}, 0) ?? 0,
|
|
1160
|
+
getLeftTableWidth: () =>
|
|
1161
|
+
instance.getLeftHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1162
|
+
return sum + header.getWidth()
|
|
1163
|
+
}, 0) ?? 0,
|
|
1164
|
+
getCenterTableWidth: () =>
|
|
1165
|
+
instance.getCenterHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1166
|
+
return sum + header.getWidth()
|
|
1167
|
+
}, 0) ?? 0,
|
|
1168
|
+
getRightTableWidth: () =>
|
|
1169
|
+
instance.getRightHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1170
|
+
return sum + header.getWidth()
|
|
1171
|
+
}, 0) ?? 0,
|
|
1191
1172
|
}
|
|
1192
1173
|
|
|
1193
|
-
|
|
1174
|
+
instance = Object.assign(instance, finalInstance)
|
|
1175
|
+
|
|
1176
|
+
// This won't trigger a rerender yet, but it will force
|
|
1177
|
+
// pagination derivation to run (particularly pageSize detection)
|
|
1178
|
+
instance.setPagination(d => d)
|
|
1179
|
+
|
|
1180
|
+
return instance
|
|
1194
1181
|
}
|