@tanstack/table-core 8.11.8 → 8.13.0

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 (86) hide show
  1. package/build/lib/core/cell.js +1 -4
  2. package/build/lib/core/cell.js.map +1 -1
  3. package/build/lib/core/column.js +2 -14
  4. package/build/lib/core/column.js.map +1 -1
  5. package/build/lib/core/headers.js +17 -112
  6. package/build/lib/core/headers.js.map +1 -1
  7. package/build/lib/core/row.js +2 -14
  8. package/build/lib/core/row.js.map +1 -1
  9. package/build/lib/core/table.d.ts +6 -0
  10. package/build/lib/core/table.js +5 -35
  11. package/build/lib/core/table.js.map +1 -1
  12. package/build/lib/features/ColumnSizing.d.ts +6 -2
  13. package/build/lib/features/ColumnSizing.js +3 -9
  14. package/build/lib/features/ColumnSizing.js.map +1 -1
  15. package/build/lib/features/Ordering.d.ts +21 -0
  16. package/build/lib/features/Ordering.js +15 -4
  17. package/build/lib/features/Ordering.js.map +1 -1
  18. package/build/lib/features/Pagination.d.ts +26 -4
  19. package/build/lib/features/Pagination.js +13 -8
  20. package/build/lib/features/Pagination.js.map +1 -1
  21. package/build/lib/features/Pinning.js +10 -58
  22. package/build/lib/features/Pinning.js.map +1 -1
  23. package/build/lib/features/RowSelection.js +3 -21
  24. package/build/lib/features/RowSelection.js.map +1 -1
  25. package/build/lib/features/Visibility.d.ts +8 -1
  26. package/build/lib/features/Visibility.js +7 -21
  27. package/build/lib/features/Visibility.js.map +1 -1
  28. package/build/lib/index.esm.js +102 -384
  29. package/build/lib/index.esm.js.map +1 -1
  30. package/build/lib/index.js +2 -0
  31. package/build/lib/index.js.map +1 -1
  32. package/build/lib/index.mjs +102 -384
  33. package/build/lib/index.mjs.map +1 -1
  34. package/build/lib/types.d.ts +2 -2
  35. package/build/lib/utils/filterRowsUtils.d.ts +0 -2
  36. package/build/lib/utils/filterRowsUtils.js +0 -2
  37. package/build/lib/utils/filterRowsUtils.js.map +1 -1
  38. package/build/lib/utils/getCoreRowModel.js +1 -10
  39. package/build/lib/utils/getCoreRowModel.js.map +1 -1
  40. package/build/lib/utils/getExpandedRowModel.js +1 -7
  41. package/build/lib/utils/getExpandedRowModel.js.map +1 -1
  42. package/build/lib/utils/getFacetedMinMaxValues.js +1 -8
  43. package/build/lib/utils/getFacetedMinMaxValues.js.map +1 -1
  44. package/build/lib/utils/getFacetedRowModel.js +1 -8
  45. package/build/lib/utils/getFacetedRowModel.js.map +1 -1
  46. package/build/lib/utils/getFacetedUniqueValues.js +1 -8
  47. package/build/lib/utils/getFacetedUniqueValues.js.map +1 -1
  48. package/build/lib/utils/getFilteredRowModel.js +1 -10
  49. package/build/lib/utils/getFilteredRowModel.js.map +1 -1
  50. package/build/lib/utils/getGroupedRowModel.js +6 -13
  51. package/build/lib/utils/getGroupedRowModel.js.map +1 -1
  52. package/build/lib/utils/getPaginationRowModel.js +1 -7
  53. package/build/lib/utils/getPaginationRowModel.js.map +1 -1
  54. package/build/lib/utils/getSortedRowModel.js +1 -10
  55. package/build/lib/utils/getSortedRowModel.js.map +1 -1
  56. package/build/lib/utils.d.ts +8 -3
  57. package/build/lib/utils.js +13 -2
  58. package/build/lib/utils.js.map +1 -1
  59. package/build/umd/index.development.js +103 -383
  60. package/build/umd/index.development.js.map +1 -1
  61. package/build/umd/index.production.js +1 -1
  62. package/build/umd/index.production.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/core/cell.ts +2 -5
  65. package/src/core/column.ts +3 -9
  66. package/src/core/headers.ts +19 -65
  67. package/src/core/row.ts +3 -10
  68. package/src/core/table.ts +12 -21
  69. package/src/features/ColumnSizing.ts +33 -20
  70. package/src/features/Ordering.ts +74 -35
  71. package/src/features/Pagination.ts +49 -13
  72. package/src/features/Pinning.ts +35 -61
  73. package/src/features/RowSelection.ts +4 -16
  74. package/src/features/Visibility.ts +23 -13
  75. package/src/types.ts +3 -1
  76. package/src/utils/filterRowsUtils.ts +2 -2
  77. package/src/utils/getCoreRowModel.ts +4 -8
  78. package/src/utils/getExpandedRowModel.ts +2 -5
  79. package/src/utils/getFacetedMinMaxValues.ts +2 -8
  80. package/src/utils/getFacetedRowModel.ts +2 -8
  81. package/src/utils/getFacetedUniqueValues.ts +6 -8
  82. package/src/utils/getFilteredRowModel.ts +4 -8
  83. package/src/utils/getGroupedRowModel.ts +7 -11
  84. package/src/utils/getPaginationRowModel.ts +2 -5
  85. package/src/utils/getSortedRowModel.ts +4 -8
  86. package/src/utils.ts +25 -6
@@ -1,6 +1,11 @@
1
1
  import { TableFeature } from '../core/table'
2
2
  import { OnChangeFn, Table, RowModel, Updater, RowData } from '../types'
3
- import { functionalUpdate, makeStateUpdater, memo } from '../utils'
3
+ import {
4
+ functionalUpdate,
5
+ getMemoOptions,
6
+ makeStateUpdater,
7
+ memo,
8
+ } from '../utils'
4
9
 
5
10
  export interface PaginationState {
6
11
  pageIndex: number
@@ -43,11 +48,17 @@ export interface PaginationOptions {
43
48
  */
44
49
  onPaginationChange?: OnChangeFn<PaginationState>
45
50
  /**
46
- * When manually controlling pagination, you should supply a total `pageCount` value to the table if you know it. If you do not know how many pages there are, you can set this to `-1`.
51
+ * When manually controlling pagination, you can supply a total `pageCount` value to the table if you know it (Or supply a `rowCount` and `pageCount` will be calculated). If you do not know how many pages there are, you can set this to `-1`.
47
52
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#pagecount)
48
53
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
49
54
  */
50
55
  pageCount?: number
56
+ /**
57
+ * When manually controlling pagination, you can supply a total `rowCount` value to the table if you know it. The `pageCount` can be calculated from this value and the `pageSize`.
58
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#rowcount)
59
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
60
+ */
61
+ rowCount?: number
51
62
  }
52
63
 
53
64
  export interface PaginationDefaultOptions {
@@ -75,6 +86,12 @@ export interface PaginationInstance<TData extends RowData> {
75
86
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
76
87
  */
77
88
  getPageCount: () => number
89
+ /**
90
+ * Returns the row count. If manually paginating or controlling the pagination state, this will come directly from the `options.rowCount` table option, otherwise it will be calculated from the table data.
91
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getrowcount)
92
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
93
+ */
94
+ getRowCount: () => number
78
95
  /**
79
96
  * Returns an array of page options (zero-index-based) for the current page size.
80
97
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpageoptions)
@@ -105,6 +122,18 @@ export interface PaginationInstance<TData extends RowData> {
105
122
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
106
123
  */
107
124
  previousPage: () => void
125
+ /**
126
+ * Sets the page index to `0`.
127
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#firstpage)
128
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
129
+ */
130
+ firstPage: () => void
131
+ /**
132
+ * Sets the page index to the last page.
133
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#lastpage)
134
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
135
+ */
136
+ lastPage: () => void
108
137
  /**
109
138
  * Resets the page index to its initial state. If `defaultState` is `true`, the page index will be reset to `0` regardless of initial state.
110
139
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpageindex)
@@ -124,9 +153,7 @@ export interface PaginationInstance<TData extends RowData> {
124
153
  */
125
154
  resetPagination: (defaultState?: boolean) => void
126
155
  /**
127
- * Updates the page count using the provided function or value.
128
- * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagecount)
129
- * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
156
+ * @deprecated The page count no longer exists in the pagination state. Just pass as a table option instead.
130
157
  */
131
158
  setPageCount: (updater: Updater<number>) => void
132
159
  /**
@@ -264,6 +291,7 @@ export const Pagination: TableFeature = {
264
291
  }
265
292
  })
266
293
  }
294
+ //deprecated
267
295
  table.setPageCount = updater =>
268
296
  table.setPagination(old => {
269
297
  let newPageCount = functionalUpdate(
@@ -290,10 +318,7 @@ export const Pagination: TableFeature = {
290
318
  }
291
319
  return pageOptions
292
320
  },
293
- {
294
- key: process.env.NODE_ENV === 'development' && 'getPageOptions',
295
- debug: () => table.options.debugAll ?? table.options.debugTable,
296
- }
321
+ getMemoOptions(table.options, 'debugTable', 'getPageOptions')
297
322
  )
298
323
 
299
324
  table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0
@@ -324,6 +349,14 @@ export const Pagination: TableFeature = {
324
349
  })
325
350
  }
326
351
 
352
+ table.firstPage = () => {
353
+ return table.setPageIndex(0)
354
+ }
355
+
356
+ table.lastPage = () => {
357
+ return table.setPageIndex(table.getPageCount() - 1)
358
+ }
359
+
327
360
  table.getPrePaginationRowModel = () => table.getExpandedRowModel()
328
361
  table.getPaginationRowModel = () => {
329
362
  if (
@@ -344,10 +377,13 @@ export const Pagination: TableFeature = {
344
377
  table.getPageCount = () => {
345
378
  return (
346
379
  table.options.pageCount ??
347
- Math.ceil(
348
- table.getPrePaginationRowModel().rows.length /
349
- table.getState().pagination.pageSize
350
- )
380
+ Math.ceil(table.getRowCount() / table.getState().pagination.pageSize)
381
+ )
382
+ }
383
+
384
+ table.getRowCount = () => {
385
+ return (
386
+ table.options.rowCount ?? table.getPrePaginationRowModel().rows.length
351
387
  )
352
388
  }
353
389
  },
@@ -8,7 +8,7 @@ import {
8
8
  Cell,
9
9
  RowData,
10
10
  } from '../types'
11
- import { makeStateUpdater, memo } from '../utils'
11
+ import { getMemoOptions, makeStateUpdater, memo } from '../utils'
12
12
 
13
13
  export type ColumnPinningPosition = false | 'left' | 'right'
14
14
  export type RowPinningPosition = false | 'top' | 'bottom'
@@ -426,14 +426,10 @@ export const Pinning: TableFeature = {
426
426
 
427
427
  return allCells.filter(d => !leftAndRight.includes(d.column.id))
428
428
  },
429
- {
430
- key:
431
- process.env.NODE_ENV === 'development' && 'row.getCenterVisibleCells',
432
- debug: () => table.options.debugAll ?? table.options.debugRows,
433
- }
429
+ getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells')
434
430
  )
435
431
  row.getLeftVisibleCells = memo(
436
- () => [row._getAllVisibleCells(), table.getState().columnPinning.left, ,],
432
+ () => [row._getAllVisibleCells(), table.getState().columnPinning.left],
437
433
  (allCells, left) => {
438
434
  const cells = (left ?? [])
439
435
  .map(columnId => allCells.find(cell => cell.column.id === columnId)!)
@@ -442,11 +438,7 @@ export const Pinning: TableFeature = {
442
438
 
443
439
  return cells
444
440
  },
445
- {
446
- key:
447
- process.env.NODE_ENV === 'development' && 'row.getLeftVisibleCells',
448
- debug: () => table.options.debugAll ?? table.options.debugRows,
449
- }
441
+ getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells')
450
442
  )
451
443
  row.getRightVisibleCells = memo(
452
444
  () => [row._getAllVisibleCells(), table.getState().columnPinning.right],
@@ -458,11 +450,7 @@ export const Pinning: TableFeature = {
458
450
 
459
451
  return cells
460
452
  },
461
- {
462
- key:
463
- process.env.NODE_ENV === 'development' && 'row.getRightVisibleCells',
464
- debug: () => table.options.debugAll ?? table.options.debugRows,
465
- }
453
+ getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells')
466
454
  )
467
455
  },
468
456
 
@@ -493,10 +481,7 @@ export const Pinning: TableFeature = {
493
481
  .map(columnId => allColumns.find(column => column.id === columnId)!)
494
482
  .filter(Boolean)
495
483
  },
496
- {
497
- key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
498
- debug: () => table.options.debugAll ?? table.options.debugColumns,
499
- }
484
+ getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns')
500
485
  )
501
486
 
502
487
  table.getRightLeafColumns = memo(
@@ -506,10 +491,7 @@ export const Pinning: TableFeature = {
506
491
  .map(columnId => allColumns.find(column => column.id === columnId)!)
507
492
  .filter(Boolean)
508
493
  },
509
- {
510
- key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
511
- debug: () => table.options.debugAll ?? table.options.debugColumns,
512
- }
494
+ getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns')
513
495
  )
514
496
 
515
497
  table.getCenterLeafColumns = memo(
@@ -523,10 +505,7 @@ export const Pinning: TableFeature = {
523
505
 
524
506
  return allColumns.filter(d => !leftAndRight.includes(d.id))
525
507
  },
526
- {
527
- key: process.env.NODE_ENV === 'development' && 'getCenterLeafColumns',
528
- debug: () => table.options.debugAll ?? table.options.debugColumns,
529
- }
508
+ getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns')
530
509
  )
531
510
 
532
511
  table.setRowPinning = updater => table.options.onRowPinningChange?.(updater)
@@ -547,34 +526,32 @@ export const Pinning: TableFeature = {
547
526
  return Boolean(pinningState[position]?.length)
548
527
  }
549
528
 
550
- table._getPinnedRows = (position: 'top' | 'bottom') =>
551
- memo(
552
- () => [table.getRowModel().rows, table.getState().rowPinning[position]],
553
- (visibleRows, pinnedRowIds) => {
554
- const rows =
555
- table.options.keepPinnedRows ?? true
556
- ? //get all rows that are pinned even if they would not be otherwise visible
557
- //account for expanded parent rows, but not pagination or filtering
558
- (pinnedRowIds ?? []).map(rowId => {
559
- const row = table.getRow(rowId, true)
560
- return row.getIsAllParentsExpanded() ? row : null
561
- })
562
- : //else get only visible rows that are pinned
563
- (pinnedRowIds ?? []).map(
564
- rowId => visibleRows.find(row => row.id === rowId)!
565
- )
566
-
567
- return rows
568
- .filter(Boolean)
569
- .map(d => ({ ...d, position })) as Row<TData>[]
570
- },
571
- {
572
- key:
573
- process.env.NODE_ENV === 'development' &&
574
- `row.get${position === 'top' ? 'Top' : 'Bottom'}Rows`,
575
- debug: () => table.options.debugAll ?? table.options.debugRows,
576
- }
577
- )()
529
+ table._getPinnedRows = memo(
530
+ position => [
531
+ table.getRowModel().rows,
532
+ table.getState().rowPinning[position!],
533
+ position,
534
+ ],
535
+ (visibleRows, pinnedRowIds, position) => {
536
+ const rows =
537
+ table.options.keepPinnedRows ?? true
538
+ ? //get all rows that are pinned even if they would not be otherwise visible
539
+ //account for expanded parent rows, but not pagination or filtering
540
+ (pinnedRowIds ?? []).map(rowId => {
541
+ const row = table.getRow(rowId, true)
542
+ return row.getIsAllParentsExpanded() ? row : null
543
+ })
544
+ : //else get only visible rows that are pinned
545
+ (pinnedRowIds ?? []).map(
546
+ rowId => visibleRows.find(row => row.id === rowId)!
547
+ )
548
+
549
+ return rows
550
+ .filter(Boolean)
551
+ .map(d => ({ ...d, position })) as Row<TData>[]
552
+ },
553
+ getMemoOptions(table.options, 'debugRows', '_getPinnedRows')
554
+ )
578
555
 
579
556
  table.getTopRows = () => table._getPinnedRows('top')
580
557
 
@@ -590,10 +567,7 @@ export const Pinning: TableFeature = {
590
567
  const topAndBottom = new Set([...(top ?? []), ...(bottom ?? [])])
591
568
  return allRows.filter(d => !topAndBottom.has(d.id))
592
569
  },
593
- {
594
- key: process.env.NODE_ENV === 'development' && 'row.getCenterRows',
595
- debug: () => table.options.debugAll ?? table.options.debugRows,
596
- }
570
+ getMemoOptions(table.options, 'debugRows', 'getCenterRows')
597
571
  )
598
572
  },
599
573
  }
@@ -1,6 +1,6 @@
1
1
  import { TableFeature } from '../core/table'
2
2
  import { OnChangeFn, Table, Row, RowModel, Updater, RowData } from '../types'
3
- import { makeStateUpdater, memo } from '../utils'
3
+ import { getMemoOptions, makeStateUpdater, memo } from '../utils'
4
4
 
5
5
  export type RowSelectionState = Record<string, boolean>
6
6
 
@@ -333,10 +333,7 @@ export const RowSelection: TableFeature = {
333
333
 
334
334
  return selectRowsFn(table, rowModel)
335
335
  },
336
- {
337
- key: process.env.NODE_ENV === 'development' && 'getSelectedRowModel',
338
- debug: () => table.options.debugAll ?? table.options.debugTable,
339
- }
336
+ getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel')
340
337
  )
341
338
 
342
339
  table.getFilteredSelectedRowModel = memo(
@@ -352,12 +349,7 @@ export const RowSelection: TableFeature = {
352
349
 
353
350
  return selectRowsFn(table, rowModel)
354
351
  },
355
- {
356
- key:
357
- process.env.NODE_ENV === 'production' &&
358
- 'getFilteredSelectedRowModel',
359
- debug: () => table.options.debugAll ?? table.options.debugTable,
360
- }
352
+ getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel')
361
353
  )
362
354
 
363
355
  table.getGroupedSelectedRowModel = memo(
@@ -373,11 +365,7 @@ export const RowSelection: TableFeature = {
373
365
 
374
366
  return selectRowsFn(table, rowModel)
375
367
  },
376
- {
377
- key:
378
- process.env.NODE_ENV === 'production' && 'getGroupedSelectedRowModel',
379
- debug: () => table.options.debugAll ?? table.options.debugTable,
380
- }
368
+ getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel')
381
369
  )
382
370
 
383
371
  ///
@@ -1,3 +1,4 @@
1
+ import { ColumnPinningPosition } from '..'
1
2
  import { TableFeature } from '../core/table'
2
3
  import {
3
4
  Cell,
@@ -8,7 +9,7 @@ import {
8
9
  Row,
9
10
  RowData,
10
11
  } from '../types'
11
- import { makeStateUpdater, memo } from '../utils'
12
+ import { getMemoOptions, makeStateUpdater, memo } from '../utils'
12
13
 
13
14
  export type VisibilityState = Record<string, boolean>
14
15
 
@@ -17,6 +18,11 @@ export interface VisibilityTableState {
17
18
  }
18
19
 
19
20
  export interface VisibilityOptions {
21
+ /**
22
+ * Whether to enable column hiding. Defaults to `true`.
23
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#enablehiding)
24
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
25
+ */
20
26
  enableHiding?: boolean
21
27
  /**
22
28
  * If provided, this function will be called with an `updaterFn` when `state.columnVisibility` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
@@ -199,10 +205,7 @@ export const Visibility: TableFeature = {
199
205
  cells => {
200
206
  return cells.filter(cell => cell.column.getIsVisible())
201
207
  },
202
- {
203
- key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
204
- debug: () => table.options.debugAll ?? table.options.debugRows,
205
- }
208
+ getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells')
206
209
  )
207
210
  row.getVisibleCells = memo(
208
211
  () => [
@@ -211,10 +214,7 @@ export const Visibility: TableFeature = {
211
214
  row.getRightVisibleCells(),
212
215
  ],
213
216
  (left, center, right) => [...left, ...center, ...right],
214
- {
215
- key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
216
- debug: () => table.options.debugAll ?? table.options.debugRows,
217
- }
217
+ getMemoOptions(table.options, 'debugRows', 'getVisibleCells')
218
218
  )
219
219
  },
220
220
 
@@ -234,10 +234,7 @@ export const Visibility: TableFeature = {
234
234
  columns => {
235
235
  return columns.filter(d => d.getIsVisible?.())
236
236
  },
237
- {
238
- key,
239
- debug: () => table.options.debugAll ?? table.options.debugColumns,
240
- }
237
+ getMemoOptions(table.options, 'debugColumns', key)
241
238
  )
242
239
  }
243
240
 
@@ -300,3 +297,16 @@ export const Visibility: TableFeature = {
300
297
  }
301
298
  },
302
299
  }
300
+
301
+ export function _getVisibleLeafColumns<TData extends RowData>(
302
+ table: Table<TData>,
303
+ position?: ColumnPinningPosition | 'center'
304
+ ) {
305
+ return !position
306
+ ? table.getVisibleLeafColumns()
307
+ : position === 'center'
308
+ ? table.getCenterVisibleLeafColumns()
309
+ : position === 'left'
310
+ ? table.getLeftVisibleLeafColumns()
311
+ : table.getRightVisibleLeafColumns()
312
+ }
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  VisibilityRow,
9
9
  } from './features/Visibility'
10
10
  import {
11
+ ColumnOrderColumn,
11
12
  ColumnOrderInstance,
12
13
  ColumnOrderOptions,
13
14
  ColumnOrderTableState,
@@ -304,7 +305,8 @@ export interface Column<TData extends RowData, TValue = unknown>
304
305
  FiltersColumn<TData>,
305
306
  SortingColumn<TData>,
306
307
  GroupingColumn<TData>,
307
- ColumnSizingColumn {}
308
+ ColumnSizingColumn,
309
+ ColumnOrderColumn {}
308
310
 
309
311
  export interface Cell<TData extends RowData, TValue>
310
312
  extends CoreCell<TData, TValue>,
@@ -13,7 +13,7 @@ export function filterRows<TData extends RowData>(
13
13
  return filterRowModelFromRoot(rows, filterRowImpl, table)
14
14
  }
15
15
 
16
- export function filterRowModelFromLeafs<TData extends RowData>(
16
+ function filterRowModelFromLeafs<TData extends RowData>(
17
17
  rowsToFilter: Row<TData>[],
18
18
  filterRow: (row: Row<TData>) => Row<TData>[],
19
19
  table: Table<TData>
@@ -77,7 +77,7 @@ export function filterRowModelFromLeafs<TData extends RowData>(
77
77
  }
78
78
  }
79
79
 
80
- export function filterRowModelFromRoot<TData extends RowData>(
80
+ function filterRowModelFromRoot<TData extends RowData>(
81
81
  rowsToFilter: Row<TData>[],
82
82
  filterRow: (row: Row<TData>) => any,
83
83
  table: Table<TData>
@@ -1,6 +1,6 @@
1
1
  import { createRow } from '../core/row'
2
2
  import { Table, Row, RowModel, RowData } from '../types'
3
- import { memo } from '../utils'
3
+ import { getMemoOptions, memo } from '../utils'
4
4
 
5
5
  export function getCoreRowModel<TData extends RowData>(): (
6
6
  table: Table<TData>
@@ -75,12 +75,8 @@ export function getCoreRowModel<TData extends RowData>(): (
75
75
 
76
76
  return rowModel
77
77
  },
78
- {
79
- key: process.env.NODE_ENV === 'development' && 'getRowModel',
80
- debug: () => table.options.debugAll ?? table.options.debugTable,
81
- onChange: () => {
82
- table._autoResetPageIndex()
83
- },
84
- }
78
+ getMemoOptions(table.options, 'debugTable', 'getRowModel', () =>
79
+ table._autoResetPageIndex()
80
+ )
85
81
  )
86
82
  }
@@ -1,5 +1,5 @@
1
1
  import { Table, Row, RowModel, RowData } from '../types'
2
- import { memo } from '../utils'
2
+ import { getMemoOptions, memo } from '../utils'
3
3
 
4
4
  export function getExpandedRowModel<TData extends RowData>(): (
5
5
  table: Table<TData>
@@ -26,10 +26,7 @@ export function getExpandedRowModel<TData extends RowData>(): (
26
26
 
27
27
  return expandRows(rowModel)
28
28
  },
29
- {
30
- key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
31
- debug: () => table.options.debugAll ?? table.options.debugTable,
32
- }
29
+ getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel')
33
30
  )
34
31
  }
35
32
 
@@ -1,5 +1,5 @@
1
1
  import { Table, RowData } from '../types'
2
- import { memo } from '../utils'
2
+ import { getMemoOptions, memo } from '../utils'
3
3
 
4
4
  export function getFacetedMinMaxValues<TData extends RowData>(): (
5
5
  table: Table<TData>,
@@ -37,12 +37,6 @@ export function getFacetedMinMaxValues<TData extends RowData>(): (
37
37
 
38
38
  return facetedMinMaxValues
39
39
  },
40
- {
41
- key:
42
- process.env.NODE_ENV === 'development' &&
43
- 'getFacetedMinMaxValues_' + columnId,
44
- debug: () => table.options.debugAll ?? table.options.debugTable,
45
- onChange: () => {},
46
- }
40
+ getMemoOptions(table.options, 'debugTable', 'getFacetedMinMaxValues')
47
41
  )
48
42
  }
@@ -1,5 +1,5 @@
1
1
  import { Table, RowModel, Row, RowData } from '../types'
2
- import { memo } from '../utils'
2
+ import { getMemoOptions, memo } from '../utils'
3
3
  import { filterRows } from './filterRowsUtils'
4
4
 
5
5
  export function getFacetedRowModel<TData extends RowData>(): (
@@ -39,12 +39,6 @@ export function getFacetedRowModel<TData extends RowData>(): (
39
39
 
40
40
  return filterRows(preRowModel.rows, filterRowsImpl, table)
41
41
  },
42
- {
43
- key:
44
- process.env.NODE_ENV === 'development' &&
45
- 'getFacetedRowModel_' + columnId,
46
- debug: () => table.options.debugAll ?? table.options.debugTable,
47
- onChange: () => {},
48
- }
42
+ getMemoOptions(table.options, 'debugTable', 'getFacetedRowModel')
49
43
  )
50
44
  }
@@ -1,5 +1,5 @@
1
1
  import { Table, RowData } from '../types'
2
- import { memo } from '../utils'
2
+ import { getMemoOptions, memo } from '../utils'
3
3
 
4
4
  export function getFacetedUniqueValues<TData extends RowData>(): (
5
5
  table: Table<TData>,
@@ -33,12 +33,10 @@ export function getFacetedUniqueValues<TData extends RowData>(): (
33
33
 
34
34
  return facetedUniqueValues
35
35
  },
36
- {
37
- key:
38
- process.env.NODE_ENV === 'development' &&
39
- 'getFacetedUniqueValues_' + columnId,
40
- debug: () => table.options.debugAll ?? table.options.debugTable,
41
- onChange: () => {},
42
- }
36
+ getMemoOptions(
37
+ table.options,
38
+ 'debugTable',
39
+ `getFacetedUniqueValues_${columnId}`
40
+ )
43
41
  )
44
42
  }
@@ -1,6 +1,6 @@
1
1
  import { ResolvedColumnFilter } from '../features/Filters'
2
2
  import { Table, RowModel, Row, RowData } from '../types'
3
- import { memo } from '../utils'
3
+ import { getMemoOptions, memo } from '../utils'
4
4
  import { filterRows } from './filterRowsUtils'
5
5
 
6
6
  export function getFilteredRowModel<TData extends RowData>(): (
@@ -144,12 +144,8 @@ export function getFilteredRowModel<TData extends RowData>(): (
144
144
  // Filter final rows using all of the active filters
145
145
  return filterRows(rowModel.rows, filterRowsImpl, table)
146
146
  },
147
- {
148
- key: process.env.NODE_ENV === 'development' && 'getFilteredRowModel',
149
- debug: () => table.options.debugAll ?? table.options.debugTable,
150
- onChange: () => {
151
- table._autoResetPageIndex()
152
- },
153
- }
147
+ getMemoOptions(table.options, 'debugTable', 'getFilteredRowModel', () =>
148
+ table._autoResetPageIndex()
149
+ )
154
150
  )
155
151
  }
@@ -1,6 +1,6 @@
1
1
  import { createRow } from '../core/row'
2
2
  import { Table, Row, RowModel, RowData } from '../types'
3
- import { flattenBy, memo } from '../utils'
3
+ import { flattenBy, getMemoOptions, memo } from '../utils'
4
4
 
5
5
  export function getGroupedRowModel<TData extends RowData>(): (
6
6
  table: Table<TData>
@@ -156,16 +156,12 @@ export function getGroupedRowModel<TData extends RowData>(): (
156
156
  rowsById: groupedRowsById,
157
157
  }
158
158
  },
159
- {
160
- key: process.env.NODE_ENV === 'development' && 'getGroupedRowModel',
161
- debug: () => table.options.debugAll ?? table.options.debugTable,
162
- onChange: () => {
163
- table._queue(() => {
164
- table._autoResetExpanded()
165
- table._autoResetPageIndex()
166
- })
167
- },
168
- }
159
+ getMemoOptions(table.options, 'debugTable', 'getGroupedRowModel', () => {
160
+ table._queue(() => {
161
+ table._autoResetExpanded()
162
+ table._autoResetPageIndex()
163
+ })
164
+ })
169
165
  )
170
166
  }
171
167
 
@@ -1,5 +1,5 @@
1
1
  import { Table, RowModel, Row, RowData } from '../types'
2
- import { memo } from '../utils'
2
+ import { getMemoOptions, memo } from '../utils'
3
3
  import { expandRows } from './getExpandedRowModel'
4
4
 
5
5
  export function getPaginationRowModel<TData extends RowData>(opts?: {
@@ -55,9 +55,6 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
55
55
 
56
56
  return paginatedRowModel
57
57
  },
58
- {
59
- key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
60
- debug: () => table.options.debugAll ?? table.options.debugTable,
61
- }
58
+ getMemoOptions(table.options, 'debugTable', 'getPaginationRowModel')
62
59
  )
63
60
  }
@@ -1,6 +1,6 @@
1
1
  import { Table, Row, RowModel, RowData } from '../types'
2
2
  import { SortingFn } from '../features/Sorting'
3
- import { memo } from '../utils'
3
+ import { getMemoOptions, memo } from '../utils'
4
4
 
5
5
  export function getSortedRowModel<TData extends RowData>(): (
6
6
  table: Table<TData>
@@ -111,12 +111,8 @@ export function getSortedRowModel<TData extends RowData>(): (
111
111
  rowsById: rowModel.rowsById,
112
112
  }
113
113
  },
114
- {
115
- key: process.env.NODE_ENV === 'development' && 'getSortedRowModel',
116
- debug: () => table.options.debugAll ?? table.options.debugTable,
117
- onChange: () => {
118
- table._autoResetPageIndex()
119
- },
120
- }
114
+ getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () =>
115
+ table._autoResetPageIndex()
116
+ )
121
117
  )
122
118
  }