@tanstack/table-core 8.0.0-alpha.80 → 8.0.0-alpha.84

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 (110) hide show
  1. package/build/cjs/core/cell.js +38 -0
  2. package/build/cjs/core/cell.js.map +1 -0
  3. package/build/cjs/core/column.js +88 -0
  4. package/build/cjs/core/column.js.map +1 -0
  5. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  6. package/build/cjs/core/headers.js.map +1 -0
  7. package/build/cjs/core/instance.js +255 -0
  8. package/build/cjs/core/instance.js.map +1 -0
  9. package/build/cjs/core/row.js +77 -0
  10. package/build/cjs/core/row.js.map +1 -0
  11. package/build/cjs/createTable.js +4 -2
  12. package/build/cjs/createTable.js.map +1 -1
  13. package/build/cjs/features/ColumnSizing.js +5 -5
  14. package/build/cjs/features/ColumnSizing.js.map +1 -1
  15. package/build/cjs/features/Expanding.js.map +1 -1
  16. package/build/cjs/features/Filters.js +12 -7
  17. package/build/cjs/features/Filters.js.map +1 -1
  18. package/build/cjs/features/Grouping.js +5 -5
  19. package/build/cjs/features/Grouping.js.map +1 -1
  20. package/build/cjs/features/Ordering.js.map +1 -1
  21. package/build/cjs/features/Pagination.js.map +1 -1
  22. package/build/cjs/features/Pinning.js +17 -11
  23. package/build/cjs/features/Pinning.js.map +1 -1
  24. package/build/cjs/features/RowSelection.js.map +1 -1
  25. package/build/cjs/features/Sorting.js +9 -9
  26. package/build/cjs/features/Sorting.js.map +1 -1
  27. package/build/cjs/features/Visibility.js +3 -3
  28. package/build/cjs/features/Visibility.js.map +1 -1
  29. package/build/cjs/index.js +17 -5
  30. package/build/cjs/index.js.map +1 -1
  31. package/build/cjs/utils/filterRowsUtils.js +23 -21
  32. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  33. package/build/cjs/utils/getCoreRowModel.js +9 -8
  34. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  35. package/build/cjs/utils/getFacetedRowModel.js +1 -1
  36. package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
  37. package/build/cjs/utils/getFilteredRowModel.js +20 -9
  38. package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
  39. package/build/cjs/utils/getGroupedRowModel.js +14 -13
  40. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  41. package/build/cjs/utils/getSortedRowModel.js +2 -2
  42. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  43. package/build/esm/index.js +731 -810
  44. package/build/esm/index.js.map +1 -1
  45. package/build/stats-html.html +1 -1
  46. package/build/stats-react.json +418 -377
  47. package/build/types/core/cell.d.ts +9 -0
  48. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  49. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  50. package/build/types/core/instance.d.ts +57 -0
  51. package/build/types/core/row.d.ts +15 -0
  52. package/build/types/createTable.d.ts +8 -5
  53. package/build/types/features/ColumnSizing.d.ts +2 -1
  54. package/build/types/features/Expanding.d.ts +2 -1
  55. package/build/types/features/Filters.d.ts +5 -3
  56. package/build/types/features/Grouping.d.ts +3 -2
  57. package/build/types/features/Ordering.d.ts +2 -1
  58. package/build/types/features/Pagination.d.ts +2 -1
  59. package/build/types/features/Pinning.d.ts +3 -2
  60. package/build/types/features/RowSelection.d.ts +2 -1
  61. package/build/types/features/Sorting.d.ts +2 -1
  62. package/build/types/features/Visibility.d.ts +2 -1
  63. package/build/types/index.d.ts +7 -2
  64. package/build/types/sortingFns.d.ts +4 -4
  65. package/build/types/types.d.ts +13 -53
  66. package/build/umd/index.development.js +738 -806
  67. package/build/umd/index.development.js.map +1 -1
  68. package/build/umd/index.production.js +1 -1
  69. package/build/umd/index.production.js.map +1 -1
  70. package/package.json +1 -1
  71. package/src/core/cell.ts +47 -0
  72. package/src/core/column.ts +148 -0
  73. package/src/{features/Headers.ts → core/headers.ts} +98 -99
  74. package/src/core/instance.ts +361 -0
  75. package/src/core/row.ts +85 -0
  76. package/src/createTable.ts +14 -7
  77. package/src/features/ColumnSizing.ts +6 -6
  78. package/src/features/Expanding.ts +1 -2
  79. package/src/features/Filters.ts +20 -8
  80. package/src/features/Grouping.ts +7 -6
  81. package/src/features/Ordering.ts +1 -1
  82. package/src/features/Pagination.ts +1 -1
  83. package/src/features/Pinning.ts +18 -9
  84. package/src/features/RowSelection.ts +1 -1
  85. package/src/features/Sorting.ts +11 -11
  86. package/src/features/Visibility.ts +3 -3
  87. package/src/index.ts +7 -8
  88. package/src/types.ts +17 -64
  89. package/src/utils/filterRowsUtils.ts +5 -3
  90. package/src/utils/getCoreRowModel.ts +4 -2
  91. package/src/utils/getFacetedRowModel.ts +1 -1
  92. package/src/utils/getFilteredRowModel.ts +24 -13
  93. package/src/utils/getGroupedRowModel.ts +9 -8
  94. package/src/utils/getSortedRowModel.ts +2 -2
  95. package/build/cjs/core.js +0 -168
  96. package/build/cjs/core.js.map +0 -1
  97. package/build/cjs/features/Cells.js +0 -101
  98. package/build/cjs/features/Cells.js.map +0 -1
  99. package/build/cjs/features/Columns.js +0 -189
  100. package/build/cjs/features/Columns.js.map +0 -1
  101. package/build/cjs/features/Headers.js.map +0 -1
  102. package/build/cjs/features/Rows.js +0 -94
  103. package/build/cjs/features/Rows.js.map +0 -1
  104. package/build/types/core.d.ts +0 -30
  105. package/build/types/features/Cells.d.ts +0 -13
  106. package/build/types/features/Rows.d.ts +0 -28
  107. package/src/core.ts +0 -246
  108. package/src/features/Cells.ts +0 -128
  109. package/src/features/Columns.ts +0 -289
  110. package/src/features/Rows.ts +0 -142
@@ -1,5 +1,6 @@
1
1
  import { RowModel } from '..'
2
2
  import { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'
3
+ import { TableFeature } from '../core/instance'
3
4
  import {
4
5
  Cell,
5
6
  Column,
@@ -9,15 +10,14 @@ import {
9
10
  Updater,
10
11
  Renderable,
11
12
  TableGenerics,
12
- TableFeature,
13
13
  } from '../types'
14
14
  import { isFunction, makeStateUpdater, Overwrite } from '../utils'
15
15
 
16
16
  export type GroupingState = string[]
17
17
 
18
18
  export type AggregationFn<TGenerics extends TableGenerics> = (
19
- getLeafValues: () => TGenerics['Row'][],
20
- getChildValues: () => TGenerics['Row'][]
19
+ getLeafValues: () => TGenerics['Value'][],
20
+ getChildValues: () => TGenerics['Value'][]
21
21
  ) => any
22
22
 
23
23
  export type CustomAggregationFns<TGenerics extends TableGenerics> = Record<
@@ -108,7 +108,7 @@ export type GroupingInstance<TGenerics extends TableGenerics> = {
108
108
  //
109
109
 
110
110
  export const Grouping: TableFeature = {
111
- getDefaultColumn: <
111
+ getDefaultColumnDef: <
112
112
  TGenerics extends TableGenerics
113
113
  >(): GroupingColumnDef<TGenerics> => {
114
114
  return {
@@ -150,7 +150,7 @@ export const Grouping: TableFeature = {
150
150
 
151
151
  getCanGroup: () => {
152
152
  return (
153
- column.enableGrouping ??
153
+ column.columnDef.enableGrouping ??
154
154
  true ??
155
155
  instance.options.enableGrouping ??
156
156
  true ??
@@ -264,7 +264,8 @@ export const Grouping: TableFeature = {
264
264
  !cell.getIsPlaceholder() &&
265
265
  row.subRows?.length > 1,
266
266
  renderAggregatedCell: () => {
267
- const template = column.aggregatedCell ?? column.cell
267
+ const template =
268
+ column.columnDef.aggregatedCell ?? column.columnDef.cell
268
269
 
269
270
  return template
270
271
  ? instance._render(template, {
@@ -6,10 +6,10 @@ import {
6
6
  Updater,
7
7
  Column,
8
8
  TableGenerics,
9
- TableFeature,
10
9
  } from '../types'
11
10
 
12
11
  import { Grouping, orderColumns } from './Grouping'
12
+ import { TableFeature } from '../core/instance'
13
13
 
14
14
  export type ColumnOrderTableState = {
15
15
  columnOrder: ColumnOrderState
@@ -1,10 +1,10 @@
1
+ import { TableFeature } from '../core/instance'
1
2
  import {
2
3
  OnChangeFn,
3
4
  TableGenerics,
4
5
  TableInstance,
5
6
  RowModel,
6
7
  Updater,
7
- TableFeature,
8
8
  } from '../types'
9
9
  import { functionalUpdate, makeStateUpdater, memo } from '../utils'
10
10
 
@@ -1,3 +1,4 @@
1
+ import { TableFeature } from '../core/instance'
1
2
  import {
2
3
  OnChangeFn,
3
4
  Updater,
@@ -6,7 +7,6 @@ import {
6
7
  TableGenerics,
7
8
  Row,
8
9
  Cell,
9
- TableFeature,
10
10
  } from '../types'
11
11
  import { makeStateUpdater, memo } from '../utils'
12
12
 
@@ -50,7 +50,7 @@ export type ColumnPinningRow<TGenerics extends TableGenerics> = {
50
50
  export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
51
51
  setColumnPinning: (updater: Updater<ColumnPinningState>) => void
52
52
  resetColumnPinning: (defaultState?: boolean) => void
53
- getIsSomeColumnsPinned: () => boolean
53
+ getIsSomeColumnsPinned: (position?: ColumnPinningPosition) => boolean
54
54
  getLeftLeafColumns: () => Column<TGenerics>[]
55
55
  getRightLeafColumns: () => Column<TGenerics>[]
56
56
  getCenterLeafColumns: () => Column<TGenerics>[]
@@ -123,7 +123,7 @@ export const Pinning: TableFeature = {
123
123
 
124
124
  return leafColumns.some(
125
125
  d =>
126
- (d.enablePinning ?? true) &&
126
+ (d.columnDef.enablePinning ?? true) &&
127
127
  (instance.options.enablePinning ?? true)
128
128
  )
129
129
  },
@@ -164,7 +164,7 @@ export const Pinning: TableFeature = {
164
164
  (allCells, left, right) => {
165
165
  const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
166
166
 
167
- return allCells.filter(d => !leftAndRight.includes(d.columnId))
167
+ return allCells.filter(d => !leftAndRight.includes(d.column.id))
168
168
  },
169
169
  {
170
170
  key:
@@ -181,7 +181,9 @@ export const Pinning: TableFeature = {
181
181
  ],
182
182
  (allCells, left) => {
183
183
  const cells = (left ?? [])
184
- .map(columnId => allCells.find(cell => cell.columnId === columnId)!)
184
+ .map(
185
+ columnId => allCells.find(cell => cell.column.id === columnId)!
186
+ )
185
187
  .filter(Boolean)
186
188
  .map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
187
189
 
@@ -200,7 +202,9 @@ export const Pinning: TableFeature = {
200
202
  ],
201
203
  (allCells, right) => {
202
204
  const cells = (right ?? [])
203
- .map(columnId => allCells.find(cell => cell.columnId === columnId)!)
205
+ .map(
206
+ columnId => allCells.find(cell => cell.column.id === columnId)!
207
+ )
204
208
  .filter(Boolean)
205
209
  .map(d => ({ ...d, position: 'left' } as Cell<TGenerics>))
206
210
 
@@ -229,10 +233,15 @@ export const Pinning: TableFeature = {
229
233
  : instance.initialState?.columnPinning ?? getDefaultPinningState()
230
234
  ),
231
235
 
232
- getIsSomeColumnsPinned: () => {
233
- const { left, right } = instance.getState().columnPinning
236
+ getIsSomeColumnsPinned: position => {
237
+ const pinningState = instance.getState().columnPinning
234
238
 
235
- return Boolean(left?.length || right?.length)
239
+ if (!position) {
240
+ return Boolean(
241
+ pinningState.left?.length || pinningState.right?.length
242
+ )
243
+ }
244
+ return Boolean(pinningState[position]?.length)
236
245
  },
237
246
 
238
247
  getLeftLeafColumns: memo(
@@ -1,3 +1,4 @@
1
+ import { TableFeature } from '../core/instance'
1
2
  import {
2
3
  OnChangeFn,
3
4
  TableGenerics,
@@ -5,7 +6,6 @@ import {
5
6
  Row,
6
7
  RowModel,
7
8
  Updater,
8
- TableFeature,
9
9
  } from '../types'
10
10
  import { makeStateUpdater, memo } from '../utils'
11
11
 
@@ -1,4 +1,5 @@
1
1
  import { RowModel } from '..'
2
+ import { TableFeature } from '../core/instance'
2
3
  import {
3
4
  BuiltInSortingFn,
4
5
  reSplitAlphaNumeric,
@@ -12,7 +13,6 @@ import {
12
13
  TableInstance,
13
14
  Row,
14
15
  Updater,
15
- TableFeature,
16
16
  } from '../types'
17
17
 
18
18
  import { isFunction, makeStateUpdater, Overwrite } from '../utils'
@@ -101,7 +101,7 @@ export const Sorting: TableFeature = {
101
101
  }
102
102
  },
103
103
 
104
- getDefaultColumn: <
104
+ getDefaultColumnDef: <
105
105
  TGenerics extends TableGenerics
106
106
  >(): SortingColumnDef<TGenerics> => {
107
107
  return {
@@ -126,7 +126,7 @@ export const Sorting: TableFeature = {
126
126
  ): SortingColumn<TGenerics> => {
127
127
  return {
128
128
  getAutoSortingFn: () => {
129
- const firstRows = instance.getFilteredRowModel().flatRows.slice(100)
129
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(10)
130
130
 
131
131
  let isString = false
132
132
 
@@ -170,15 +170,15 @@ export const Sorting: TableFeature = {
170
170
  throw new Error()
171
171
  }
172
172
 
173
- return isFunction(column.sortingFn)
174
- ? column.sortingFn
175
- : column.sortingFn === 'auto'
173
+ return isFunction(column.columnDef.sortingFn)
174
+ ? column.columnDef.sortingFn
175
+ : column.columnDef.sortingFn === 'auto'
176
176
  ? column.getAutoSortingFn()
177
177
  : (userSortingFn as Record<string, any>)?.[
178
- column.sortingFn as string
178
+ column.columnDef.sortingFn as string
179
179
  ] ??
180
180
  (sortingFns[
181
- column.sortingFn as BuiltInSortingFn
181
+ column.columnDef.sortingFn as BuiltInSortingFn
182
182
  ] as SortingFn<TGenerics>)
183
183
  },
184
184
  toggleSorting: (desc, multi) => {
@@ -220,7 +220,7 @@ export const Sorting: TableFeature = {
220
220
  }
221
221
 
222
222
  const sortDescFirst =
223
- column.sortDescFirst ??
223
+ column.columnDef.sortDescFirst ??
224
224
  instance.options.sortDescFirst ??
225
225
  column.getAutoSortDir() === 'desc'
226
226
 
@@ -280,7 +280,7 @@ export const Sorting: TableFeature = {
280
280
 
281
281
  getCanSort: () => {
282
282
  return (
283
- (column.enableSorting ?? true) &&
283
+ (column.columnDef.enableSorting ?? true) &&
284
284
  (instance.options.enableSorting ?? true) &&
285
285
  !!column.accessorFn
286
286
  )
@@ -288,7 +288,7 @@ export const Sorting: TableFeature = {
288
288
 
289
289
  getCanMultiSort: () => {
290
290
  return (
291
- column.enableMultiSort ??
291
+ column.columnDef.enableMultiSort ??
292
292
  instance.options.enableMultiSort ??
293
293
  !!column.accessorFn
294
294
  )
@@ -1,3 +1,4 @@
1
+ import { TableFeature } from '../core/instance'
1
2
  import {
2
3
  Cell,
3
4
  Column,
@@ -6,7 +7,6 @@ import {
6
7
  TableInstance,
7
8
  Updater,
8
9
  Row,
9
- TableFeature,
10
10
  } from '../types'
11
11
  import { makeStateUpdater, memo } from '../utils'
12
12
 
@@ -76,7 +76,7 @@ export const Visibility: TableFeature = {
76
76
  }
77
77
  },
78
78
 
79
- getDefaultColumn: () => {
79
+ getDefaultColumnDef: () => {
80
80
  return {
81
81
  defaultIsVisible: true,
82
82
  }
@@ -101,7 +101,7 @@ export const Visibility: TableFeature = {
101
101
 
102
102
  getCanHide: () => {
103
103
  return (
104
- (column.enableHiding ?? true) &&
104
+ (column.columnDef.enableHiding ?? true) &&
105
105
  (instance.options.enableHiding ?? true)
106
106
  )
107
107
  },
package/src/index.ts CHANGED
@@ -1,12 +1,14 @@
1
- export * from './core'
1
+ export * from './core/instance'
2
2
  export * from './types'
3
3
  export * from './createTable'
4
+ export * from './core/column'
5
+ export * from './core/headers'
6
+ export * from './core/row'
4
7
  export * from './features/ColumnSizing'
5
8
  export * from './features/ColumnSizing'
6
9
  export * from './features/Expanding'
7
10
  export * from './features/Filters'
8
11
  export * from './features/Grouping'
9
- export * from './features/Headers'
10
12
  export * from './features/Ordering'
11
13
  export * from './features/Pagination'
12
14
  export * from './features/Pinning'
@@ -14,6 +16,9 @@ export * from './features/RowSelection'
14
16
  export * from './features/Sorting'
15
17
  export * from './features/Visibility'
16
18
  export * from './features/Expanding'
19
+ export * from './filterFns'
20
+ export * from './sortingFns'
21
+ export * from './aggregationFns'
17
22
  export * from './utils'
18
23
  export * from './utils/getCoreRowModel'
19
24
  export * from './utils/getFilteredRowModel'
@@ -24,9 +29,3 @@ export * from './utils/getSortedRowModel'
24
29
  export * from './utils/getGroupedRowModel'
25
30
  export * from './utils/getExpandedRowModel'
26
31
  export * from './utils/getPaginationRowModel'
27
- // Experimental Async
28
- // export * from './utils/getCoreRowModelAsync'
29
- // export * from './utils/getFilteredRowModelAsync'
30
- // export * from './utils/getFacetedRowModelAsync'
31
- // export * from './utils/getFacetedUniqueValuesAsync'
32
- // export * from './utils/getFacetedMinMaxValuesAsync'
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CoreOptions, CoreTableState, CoreInstance } from './core'
2
- import { ColumnsOptions, CoreColumn, CoreColumnDef } from './features/Columns'
1
+ import { CoreOptions, CoreTableState, CoreInstance } from './core/instance'
2
+ import { CoreColumn, CoreColumnDef } from './core/column'
3
3
  import {
4
4
  VisibilityInstance,
5
5
  VisibilityTableState,
@@ -18,11 +18,10 @@ import {
18
18
  ColumnPinningColumnDef,
19
19
  ColumnPinningInstance,
20
20
  ColumnPinningOptions,
21
- ColumnPinningPosition,
22
21
  ColumnPinningRow,
23
22
  ColumnPinningTableState,
24
23
  } from './features/Pinning'
25
- import { HeadersInstance } from './features/Headers'
24
+ import { CoreHeader, CoreHeaderGroup, HeadersInstance } from './core/headers'
26
25
  import {
27
26
  FiltersColumn,
28
27
  FiltersColumnDef,
@@ -53,7 +52,6 @@ import {
53
52
  ExpandedTableState,
54
53
  ExpandedRow,
55
54
  } from './features/Expanding'
56
- import { Overwrite } from './utils'
57
55
  import {
58
56
  ColumnSizingColumn,
59
57
  ColumnSizingColumnDef,
@@ -74,9 +72,9 @@ import {
74
72
  RowSelectionRow,
75
73
  RowSelectionTableState,
76
74
  } from './features/RowSelection'
77
- import { ColumnsInstance } from './features/Columns'
78
- import { CellsInstance, CellsRow } from './features/Cells'
79
- import { CoreRow, RowsInstance, RowsOptions } from './features/Rows'
75
+ import { CoreRow } from './core/row'
76
+ import { PartialKeys } from './utils'
77
+ import { CoreCell } from './core/cell'
80
78
 
81
79
  export type Updater<T> = T | ((old: T) => T)
82
80
  export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void
@@ -91,30 +89,17 @@ export type TableGenerics = {
91
89
  Rendered?: any
92
90
  ColumnMeta?: any
93
91
  TableMeta?: any
92
+ FilterMeta?: any
94
93
  }
95
94
 
96
95
  export type AnyRender = (Comp: any, props: any) => any
97
96
 
98
- export type TableFeature = {
99
- getDefaultOptions?: (instance: any) => any
100
- getInitialState?: (initialState?: InitialTableState) => any
101
- createInstance?: (instance: any) => any
102
- getDefaultColumn?: () => any
103
- createColumn?: (column: any, instance: any) => any
104
- createHeader?: (column: any, instance: any) => any
105
- createCell?: (cell: any, column: any, row: any, instance: any) => any
106
- createRow?: (row: any, instance: any) => any
107
- }
108
-
109
97
  export type TableInstance<TGenerics extends TableGenerics> =
110
98
  CoreInstance<TGenerics> &
111
- ColumnsInstance<TGenerics> &
112
- RowsInstance<TGenerics> &
113
- CellsInstance<TGenerics> &
99
+ HeadersInstance<TGenerics> &
114
100
  VisibilityInstance<TGenerics> &
115
101
  ColumnOrderInstance<TGenerics> &
116
102
  ColumnPinningInstance<TGenerics> &
117
- HeadersInstance<TGenerics> &
118
103
  FiltersInstance<TGenerics> &
119
104
  SortingInstance<TGenerics> &
120
105
  GroupingInstance<TGenerics> &
@@ -123,10 +108,8 @@ export type TableInstance<TGenerics extends TableGenerics> =
123
108
  PaginationInstance<TGenerics> &
124
109
  RowSelectionInstance<TGenerics>
125
110
 
126
- export type TableOptions<TGenerics extends TableGenerics> =
111
+ export type TableOptionsResolved<TGenerics extends TableGenerics> =
127
112
  CoreOptions<TGenerics> &
128
- ColumnsOptions<TGenerics> &
129
- RowsOptions<TGenerics> &
130
113
  VisibilityOptions &
131
114
  ColumnOrderOptions &
132
115
  ColumnPinningOptions &
@@ -138,6 +121,11 @@ export type TableOptions<TGenerics extends TableGenerics> =
138
121
  PaginationOptions<TGenerics> &
139
122
  RowSelectionOptions<TGenerics>
140
123
 
124
+ export type TableOptions<TGenerics extends TableGenerics> = Omit<
125
+ PartialKeys<TableOptionsResolved<TGenerics>, 'state' | 'onStateChange'>,
126
+ 'render'
127
+ >
128
+
141
129
  export type TableState = CoreTableState &
142
130
  VisibilityTableState &
143
131
  ColumnOrderTableState &
@@ -165,7 +153,6 @@ export type InitialTableState = Partial<
165
153
  >
166
154
 
167
155
  export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> &
168
- CellsRow<TGenerics> &
169
156
  VisibilityRow<TGenerics> &
170
157
  ColumnPinningRow<TGenerics> &
171
158
  FiltersRow<TGenerics> &
@@ -198,8 +185,7 @@ export type ColumnDef<TGenerics extends TableGenerics> =
198
185
  GroupingColumnDef<TGenerics> &
199
186
  ColumnSizingColumnDef
200
187
 
201
- export type Column<TGenerics extends TableGenerics> = ColumnDef<TGenerics> &
202
- CoreColumn<TGenerics> &
188
+ export type Column<TGenerics extends TableGenerics> = CoreColumn<TGenerics> &
203
189
  ColumnVisibilityColumn &
204
190
  ColumnPinningColumn &
205
191
  FiltersColumn<TGenerics> &
@@ -210,43 +196,10 @@ export type Column<TGenerics extends TableGenerics> = ColumnDef<TGenerics> &
210
196
  export type Cell<TGenerics extends TableGenerics> = CoreCell<TGenerics> &
211
197
  GroupingCell<TGenerics>
212
198
 
213
- export type CoreCell<TGenerics extends TableGenerics> = {
214
- id: string
215
- rowId: string
216
- columnId: string
217
- getValue: () => TGenerics['Value']
218
- row: Row<TGenerics>
219
- column: Column<TGenerics>
220
- renderCell: () => string | null | TGenerics['Rendered']
221
- }
222
-
223
199
  export type Header<TGenerics extends TableGenerics> = CoreHeader<TGenerics> &
224
200
  ColumnSizingHeader<TGenerics>
225
201
 
226
- export type CoreHeader<TGenerics extends TableGenerics> = {
227
- id: string
228
- index: number
229
- depth: number
230
- column: Column<TGenerics>
231
- headerGroup: HeaderGroup<TGenerics>
232
- subHeaders: Header<TGenerics>[]
233
- colSpan?: number
234
- rowSpan?: number
235
- getLeafHeaders: () => Header<TGenerics>[]
236
- isPlaceholder?: boolean
237
- placeholderId?: string
238
- renderHeader: (options?: {
239
- renderPlaceholder?: boolean
240
- }) => string | null | TGenerics['Rendered']
241
- renderFooter: (options?: {
242
- renderPlaceholder?: boolean
243
- }) => string | null | TGenerics['Rendered']
244
- }
245
-
246
- export type HeaderGroup<TGenerics extends TableGenerics> = {
247
- id: string
248
- depth: number
249
- headers: Header<TGenerics>[]
250
- }
202
+ export type HeaderGroup<TGenerics extends TableGenerics> =
203
+ CoreHeaderGroup<TGenerics>
251
204
 
252
205
  export type NoInfer<A extends any> = [A][A extends any ? 0 : never]
@@ -1,3 +1,4 @@
1
+ import { createRow } from '../core/row'
1
2
  import { TableGenerics, Row, RowModel, TableInstance } from '../types'
2
3
 
3
4
  export function filterRows<TGenerics extends TableGenerics>(
@@ -31,8 +32,8 @@ export function filterRowModelFromLeafs<TGenerics extends TableGenerics>(
31
32
  row = rowsToFilter[i]!
32
33
 
33
34
  if (row.subRows?.length) {
34
- newRow = instance.createRow(row.id, row.original, row.index, row.depth)
35
- newRow.columnFilterMap = row.columnFilterMap
35
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth)
36
+ newRow.columnFilters = row.columnFilters
36
37
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
37
38
  if (!newRow.subRows.length) {
38
39
  continue
@@ -83,7 +84,8 @@ export function filterRowModelFromRoot<TGenerics extends TableGenerics>(
83
84
 
84
85
  if (pass) {
85
86
  if (row.subRows?.length) {
86
- newRow = instance.createRow(
87
+ newRow = createRow(
88
+ instance,
87
89
  row.id,
88
90
  row.original,
89
91
  row.index,
@@ -1,3 +1,4 @@
1
+ import { createRow } from '../core/row'
1
2
  import { TableInstance, Row, RowModel, TableGenerics } from '../types'
2
3
  import { memo } from '../utils'
3
4
 
@@ -42,8 +43,9 @@ export function getCoreRowModel<TGenerics extends TableGenerics>(): (
42
43
  // }
43
44
 
44
45
  // Make the row
45
- row = instance.createRow(
46
- instance.getRowId(originalRow, i, parent),
46
+ row = createRow(
47
+ instance,
48
+ instance._getRowId(originalRow, i, parent),
47
49
  originalRow,
48
50
  i,
49
51
  depth
@@ -30,7 +30,7 @@ export function getFacetedRowModel<TGenerics extends TableGenerics>(): (
30
30
  const filterRowsImpl = (row: Row<TGenerics>) => {
31
31
  // Horizontally filter rows through each column
32
32
  for (let i = 0; i < filterableIds.length; i++) {
33
- if (row.columnFilterMap[filterableIds[i]!] === false) {
33
+ if (row.columnFilters[filterableIds[i]!] === false) {
34
34
  return false
35
35
  }
36
36
  }
@@ -18,6 +18,10 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
18
18
  !rowModel.rows.length ||
19
19
  (!columnFilters?.length && !globalFilter)
20
20
  ) {
21
+ for (let i = 0; i < rowModel.flatRows.length; i++) {
22
+ rowModel.flatRows[i]!.columnFilters = {}
23
+ rowModel.flatRows[i]!.columnFiltersMeta = {}
24
+ }
21
25
  return rowModel
22
26
  }
23
27
 
@@ -86,40 +90,47 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
86
90
  for (let j = 0; j < rowModel.flatRows.length; j++) {
87
91
  const row = rowModel.flatRows[j]!
88
92
 
89
- row.columnFilterMap = {}
93
+ row.columnFilters = {}
90
94
 
91
95
  if (resolvedColumnFilters.length) {
92
96
  for (let i = 0; i < resolvedColumnFilters.length; i++) {
93
97
  currentColumnFilter = resolvedColumnFilters[i]!
98
+ const id = currentColumnFilter.id
94
99
 
95
100
  // Tag the row with the column filter state
96
- row.columnFilterMap[currentColumnFilter.id] =
97
- currentColumnFilter.filterFn(
98
- row,
99
- currentColumnFilter.id,
100
- currentColumnFilter.resolvedValue
101
- )
101
+ row.columnFilters[id] = currentColumnFilter.filterFn(
102
+ row,
103
+ id,
104
+ currentColumnFilter.resolvedValue,
105
+ filterMeta => {
106
+ row.columnFiltersMeta[id] = filterMeta
107
+ }
108
+ )
102
109
  }
103
110
  }
104
111
 
105
112
  if (resolvedGlobalFilters.length) {
106
113
  for (let i = 0; i < resolvedGlobalFilters.length; i++) {
107
114
  currentGlobalFilter = resolvedGlobalFilters[i]!
115
+ const id = currentGlobalFilter.id
108
116
  // Tag the row with the first truthy global filter state
109
117
  if (
110
118
  currentGlobalFilter.filterFn(
111
119
  row,
112
- currentGlobalFilter.id,
113
- currentGlobalFilter.resolvedValue
120
+ id,
121
+ currentGlobalFilter.resolvedValue,
122
+ filterMeta => {
123
+ row.columnFiltersMeta[id] = filterMeta
124
+ }
114
125
  )
115
126
  ) {
116
- row.columnFilterMap.__global__ = true
127
+ row.columnFilters.__global__ = true
117
128
  break
118
129
  }
119
130
  }
120
131
 
121
- if (row.columnFilterMap.__global__ !== true) {
122
- row.columnFilterMap.__global__ = false
132
+ if (row.columnFilters.__global__ !== true) {
133
+ row.columnFilters.__global__ = false
123
134
  }
124
135
  }
125
136
  }
@@ -127,7 +138,7 @@ export function getFilteredRowModel<TGenerics extends TableGenerics>(): (
127
138
  const filterRowsImpl = (row: Row<TGenerics>) => {
128
139
  // Horizontally filter rows through each column
129
140
  for (let i = 0; i < filterableIds.length; i++) {
130
- if (row.columnFilterMap[filterableIds[i]!] === false) {
141
+ if (row.columnFilters[filterableIds[i]!] === false) {
131
142
  return false
132
143
  }
133
144
  }
@@ -1,4 +1,4 @@
1
- import { CoreRow } from '../features/Rows'
1
+ import { createRow } from '../core/row'
2
2
  import { TableInstance, Row, RowModel, TableGenerics } from '../types'
3
3
  import { flattenBy, memo } from '../utils'
4
4
 
@@ -55,7 +55,7 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
55
55
  ? flattenBy(groupedRows, row => row.subRows)
56
56
  : groupedRows
57
57
 
58
- const row = instance.createRow(id, undefined, index, depth)
58
+ const row = createRow(instance, id, undefined, index, depth)
59
59
 
60
60
  Object.assign(row, {
61
61
  groupingColumnId: columnId,
@@ -65,16 +65,16 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
65
65
  getValue: (columnId: string) => {
66
66
  // Don't aggregate columns that are in the grouping
67
67
  if (existingGrouping.includes(columnId)) {
68
- if (row.valuesCache.hasOwnProperty(columnId)) {
69
- return row.valuesCache[columnId]
68
+ if (row._valuesCache.hasOwnProperty(columnId)) {
69
+ return row._valuesCache[columnId]
70
70
  }
71
71
 
72
72
  if (groupedRows[0]) {
73
- row.valuesCache[columnId] =
73
+ row._valuesCache[columnId] =
74
74
  groupedRows[0].getValue(columnId) ?? undefined
75
75
  }
76
76
 
77
- return row.valuesCache[columnId]
77
+ return row._valuesCache[columnId]
78
78
  }
79
79
 
80
80
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -91,8 +91,9 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
91
91
  leafRows.map(row => {
92
92
  let columnValue = row.getValue(columnId)
93
93
 
94
- if (!depth && column.aggregateValue) {
95
- columnValue = column.aggregateValue(columnValue)
94
+ if (!depth && column.columnDef.aggregateValue) {
95
+ columnValue =
96
+ column.columnDef.aggregateValue(columnValue)
96
97
  }
97
98
 
98
99
  return columnValue
@@ -35,8 +35,8 @@ export function getSortedRowModel<TGenerics extends TableGenerics>(): (
35
35
  const column = instance.getColumn(sortEntry.id)
36
36
 
37
37
  columnInfoById[sortEntry.id] = {
38
- sortUndefined: column.sortUndefined,
39
- invertSorting: column.invertSorting,
38
+ sortUndefined: column.columnDef.sortUndefined,
39
+ invertSorting: column.columnDef.invertSorting,
40
40
  sortingFn: column.getSortingFn(),
41
41
  }
42
42
  })