@tanstack/table-core 8.0.0-alpha.82 → 8.0.0-alpha.85

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 (108) hide show
  1. package/build/cjs/aggregationFns.js +50 -51
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/core/cell.js +38 -0
  4. package/build/cjs/core/cell.js.map +1 -0
  5. package/build/cjs/core/column.js +88 -0
  6. package/build/cjs/core/column.js.map +1 -0
  7. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  8. package/build/cjs/core/headers.js.map +1 -0
  9. package/build/cjs/core/instance.js +255 -0
  10. package/build/cjs/core/instance.js.map +1 -0
  11. package/build/cjs/core/row.js +77 -0
  12. package/build/cjs/core/row.js.map +1 -0
  13. package/build/cjs/createTable.js +3 -2
  14. package/build/cjs/createTable.js.map +1 -1
  15. package/build/cjs/features/ColumnSizing.js +5 -5
  16. package/build/cjs/features/ColumnSizing.js.map +1 -1
  17. package/build/cjs/features/Expanding.js.map +1 -1
  18. package/build/cjs/features/Filters.js +11 -8
  19. package/build/cjs/features/Filters.js.map +1 -1
  20. package/build/cjs/features/Grouping.js +10 -10
  21. package/build/cjs/features/Grouping.js.map +1 -1
  22. package/build/cjs/features/Ordering.js.map +1 -1
  23. package/build/cjs/features/Pagination.js.map +1 -1
  24. package/build/cjs/features/Pinning.js +17 -11
  25. package/build/cjs/features/Pinning.js.map +1 -1
  26. package/build/cjs/features/RowSelection.js.map +1 -1
  27. package/build/cjs/features/Sorting.js +8 -8
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +3 -3
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/index.js +9 -6
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +23 -21
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModel.js +9 -8
  36. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  37. package/build/cjs/utils/getGroupedRowModel.js +13 -20
  38. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getSortedRowModel.js +2 -2
  40. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  41. package/build/esm/index.js +764 -865
  42. package/build/esm/index.js.map +1 -1
  43. package/build/stats-html.html +1 -1
  44. package/build/stats-react.json +404 -381
  45. package/build/types/aggregationFns.d.ts +10 -19
  46. package/build/types/core/cell.d.ts +9 -0
  47. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  48. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  49. package/build/types/core/instance.d.ts +57 -0
  50. package/build/types/core/row.d.ts +15 -0
  51. package/build/types/createTable.d.ts +4 -4
  52. package/build/types/features/ColumnSizing.d.ts +2 -1
  53. package/build/types/features/Expanding.d.ts +2 -1
  54. package/build/types/features/Filters.d.ts +2 -3
  55. package/build/types/features/Grouping.d.ts +8 -9
  56. package/build/types/features/Ordering.d.ts +2 -1
  57. package/build/types/features/Pagination.d.ts +2 -1
  58. package/build/types/features/Pinning.d.ts +3 -2
  59. package/build/types/features/RowSelection.d.ts +2 -1
  60. package/build/types/features/Sorting.d.ts +2 -1
  61. package/build/types/features/Visibility.d.ts +2 -1
  62. package/build/types/index.d.ts +4 -2
  63. package/build/types/sortingFns.d.ts +4 -4
  64. package/build/types/types.d.ts +12 -53
  65. package/build/umd/index.development.js +767 -863
  66. package/build/umd/index.development.js.map +1 -1
  67. package/build/umd/index.production.js +1 -1
  68. package/build/umd/index.production.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/aggregationFns.ts +44 -40
  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 +7 -4
  77. package/src/features/ColumnSizing.ts +6 -6
  78. package/src/features/Expanding.ts +1 -2
  79. package/src/features/Filters.ts +9 -10
  80. package/src/features/Grouping.ts +20 -22
  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 +10 -10
  86. package/src/features/Visibility.ts +3 -3
  87. package/src/index.ts +4 -8
  88. package/src/types.ts +16 -64
  89. package/src/utils/filterRowsUtils.ts +4 -2
  90. package/src/utils/getCoreRowModel.ts +4 -2
  91. package/src/utils/getGroupedRowModel.ts +14 -22
  92. package/src/utils/getSortedRowModel.ts +2 -2
  93. package/build/cjs/core.js +0 -168
  94. package/build/cjs/core.js.map +0 -1
  95. package/build/cjs/features/Cells.js +0 -101
  96. package/build/cjs/features/Cells.js.map +0 -1
  97. package/build/cjs/features/Columns.js +0 -189
  98. package/build/cjs/features/Columns.js.map +0 -1
  99. package/build/cjs/features/Headers.js.map +0 -1
  100. package/build/cjs/features/Rows.js +0 -94
  101. package/build/cjs/features/Rows.js.map +0 -1
  102. package/build/types/core.d.ts +0 -30
  103. package/build/types/features/Cells.d.ts +0 -13
  104. package/build/types/features/Rows.d.ts +0 -28
  105. package/src/core.ts +0 -246
  106. package/src/features/Cells.ts +0 -128
  107. package/src/features/Columns.ts +0 -289
  108. 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,19 @@ 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
+ export type GroupingTableState = {
19
+ grouping: GroupingState
20
+ }
21
+
18
22
  export type AggregationFn<TGenerics extends TableGenerics> = (
19
- getLeafValues: () => TGenerics['Value'][],
20
- getChildValues: () => TGenerics['Value'][]
23
+ columnId: string,
24
+ leafRows: Row<TGenerics>[],
25
+ childRows: Row<TGenerics>[]
21
26
  ) => any
22
27
 
23
28
  export type CustomAggregationFns<TGenerics extends TableGenerics> = Record<
@@ -31,13 +36,8 @@ export type AggregationFnOption<TGenerics extends TableGenerics> =
31
36
  | keyof TGenerics['AggregationFns']
32
37
  | AggregationFn<TGenerics>
33
38
 
34
- export type GroupingTableState = {
35
- grouping: GroupingState
36
- }
37
-
38
39
  export type GroupingColumnDef<TGenerics extends TableGenerics> = {
39
40
  aggregationFn?: AggregationFnOption<Overwrite<TGenerics, { Value: any }>>
40
- aggregateValue?: (columnValue: unknown) => any
41
41
  aggregatedCell?: Renderable<
42
42
  TGenerics,
43
43
  {
@@ -58,15 +58,15 @@ export type GroupingColumn<TGenerics extends TableGenerics> = {
58
58
  getGroupedIndex: () => number
59
59
  toggleGrouping: () => void
60
60
  getToggleGroupingHandler: () => () => void
61
- getColumnAutoAggregationFn: () => AggregationFn<TGenerics> | undefined
62
- getColumnAggregationFn: () => AggregationFn<TGenerics> | undefined
61
+ getAutoAggregationFn: () => AggregationFn<TGenerics> | undefined
62
+ getAggregationFn: () => AggregationFn<TGenerics> | undefined
63
63
  }
64
64
 
65
65
  export type GroupingRow = {
66
66
  groupingColumnId?: string
67
67
  groupingValue?: any
68
68
  getIsGrouped: () => boolean
69
- groupingValuesCache: Record<string, any>
69
+ _groupingValuesCache: Record<string, any>
70
70
  }
71
71
 
72
72
  export type GroupingCell<TGenerics extends TableGenerics> = {
@@ -87,11 +87,9 @@ export type GroupingOptions<TGenerics extends TableGenerics> = {
87
87
  aggregationFns?: TGenerics['AggregationFns']
88
88
  onGroupingChange?: OnChangeFn<GroupingState>
89
89
  enableGrouping?: boolean
90
- enableGroupingRemoval?: boolean
91
90
  getGroupedRowModel?: (
92
91
  instance: TableInstance<TGenerics>
93
92
  ) => () => RowModel<TGenerics>
94
-
95
93
  groupedColumnMode?: false | 'reorder' | 'remove'
96
94
  }
97
95
 
@@ -108,7 +106,7 @@ export type GroupingInstance<TGenerics extends TableGenerics> = {
108
106
  //
109
107
 
110
108
  export const Grouping: TableFeature = {
111
- getDefaultColumn: <
109
+ getDefaultColumnDef: <
112
110
  TGenerics extends TableGenerics
113
111
  >(): GroupingColumnDef<TGenerics> => {
114
112
  return {
@@ -150,7 +148,7 @@ export const Grouping: TableFeature = {
150
148
 
151
149
  getCanGroup: () => {
152
150
  return (
153
- column.enableGrouping ??
151
+ column.columnDef.enableGrouping ??
154
152
  true ??
155
153
  instance.options.enableGrouping ??
156
154
  true ??
@@ -172,7 +170,7 @@ export const Grouping: TableFeature = {
172
170
  column.toggleGrouping()
173
171
  }
174
172
  },
175
- getColumnAutoAggregationFn: () => {
173
+ getAutoAggregationFn: () => {
176
174
  const firstRow = instance.getCoreRowModel().flatRows[0]
177
175
 
178
176
  const value = firstRow?.getValue(column.id)
@@ -187,7 +185,7 @@ export const Grouping: TableFeature = {
187
185
 
188
186
  return aggregationFns.count
189
187
  },
190
- getColumnAggregationFn: () => {
188
+ getAggregationFn: () => {
191
189
  const userAggregationFns = instance.options.aggregationFns
192
190
 
193
191
  if (!column) {
@@ -197,7 +195,7 @@ export const Grouping: TableFeature = {
197
195
  return isFunction(column.aggregationFn)
198
196
  ? column.aggregationFn
199
197
  : column.aggregationFn === 'auto'
200
- ? column.getColumnAutoAggregationFn()
198
+ ? column.getAutoAggregationFn()
201
199
  : (userAggregationFns as Record<string, any>)?.[
202
200
  column.aggregationFn as string
203
201
  ] ??
@@ -240,12 +238,11 @@ export const Grouping: TableFeature = {
240
238
  },
241
239
 
242
240
  createRow: <TGenerics extends TableGenerics>(
243
- row: Row<TGenerics>,
244
- instance: TableInstance<TGenerics>
241
+ row: Row<TGenerics>
245
242
  ): GroupingRow => {
246
243
  return {
247
244
  getIsGrouped: () => !!row.groupingColumnId,
248
- groupingValuesCache: {},
245
+ _groupingValuesCache: {},
249
246
  }
250
247
  },
251
248
 
@@ -264,7 +261,8 @@ export const Grouping: TableFeature = {
264
261
  !cell.getIsPlaceholder() &&
265
262
  row.subRows?.length > 1,
266
263
  renderAggregatedCell: () => {
267
- const template = column.aggregatedCell ?? column.cell
264
+ const template =
265
+ column.columnDef.aggregatedCell ?? column.columnDef.cell
268
266
 
269
267
  return template
270
268
  ? 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 {
@@ -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'
@@ -27,9 +29,3 @@ export * from './utils/getSortedRowModel'
27
29
  export * from './utils/getGroupedRowModel'
28
30
  export * from './utils/getExpandedRowModel'
29
31
  export * from './utils/getPaginationRowModel'
30
- // Experimental Async
31
- // export * from './utils/getCoreRowModelAsync'
32
- // export * from './utils/getFilteredRowModelAsync'
33
- // export * from './utils/getFacetedRowModelAsync'
34
- // export * from './utils/getFacetedUniqueValuesAsync'
35
- // 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
@@ -96,26 +94,12 @@ export type TableGenerics = {
96
94
 
97
95
  export type AnyRender = (Comp: any, props: any) => any
98
96
 
99
- export type TableFeature = {
100
- getDefaultOptions?: (instance: any) => any
101
- getInitialState?: (initialState?: InitialTableState) => any
102
- createInstance?: (instance: any) => any
103
- getDefaultColumn?: () => any
104
- createColumn?: (column: any, instance: any) => any
105
- createHeader?: (column: any, instance: any) => any
106
- createCell?: (cell: any, column: any, row: any, instance: any) => any
107
- createRow?: (row: any, instance: any) => any
108
- }
109
-
110
97
  export type TableInstance<TGenerics extends TableGenerics> =
111
98
  CoreInstance<TGenerics> &
112
- ColumnsInstance<TGenerics> &
113
- RowsInstance<TGenerics> &
114
- CellsInstance<TGenerics> &
99
+ HeadersInstance<TGenerics> &
115
100
  VisibilityInstance<TGenerics> &
116
101
  ColumnOrderInstance<TGenerics> &
117
102
  ColumnPinningInstance<TGenerics> &
118
- HeadersInstance<TGenerics> &
119
103
  FiltersInstance<TGenerics> &
120
104
  SortingInstance<TGenerics> &
121
105
  GroupingInstance<TGenerics> &
@@ -124,10 +108,8 @@ export type TableInstance<TGenerics extends TableGenerics> =
124
108
  PaginationInstance<TGenerics> &
125
109
  RowSelectionInstance<TGenerics>
126
110
 
127
- export type TableOptions<TGenerics extends TableGenerics> =
111
+ export type TableOptionsResolved<TGenerics extends TableGenerics> =
128
112
  CoreOptions<TGenerics> &
129
- ColumnsOptions<TGenerics> &
130
- RowsOptions<TGenerics> &
131
113
  VisibilityOptions &
132
114
  ColumnOrderOptions &
133
115
  ColumnPinningOptions &
@@ -139,6 +121,11 @@ export type TableOptions<TGenerics extends TableGenerics> =
139
121
  PaginationOptions<TGenerics> &
140
122
  RowSelectionOptions<TGenerics>
141
123
 
124
+ export type TableOptions<TGenerics extends TableGenerics> = Omit<
125
+ PartialKeys<TableOptionsResolved<TGenerics>, 'state' | 'onStateChange'>,
126
+ 'render'
127
+ >
128
+
142
129
  export type TableState = CoreTableState &
143
130
  VisibilityTableState &
144
131
  ColumnOrderTableState &
@@ -166,7 +153,6 @@ export type InitialTableState = Partial<
166
153
  >
167
154
 
168
155
  export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> &
169
- CellsRow<TGenerics> &
170
156
  VisibilityRow<TGenerics> &
171
157
  ColumnPinningRow<TGenerics> &
172
158
  FiltersRow<TGenerics> &
@@ -199,8 +185,7 @@ export type ColumnDef<TGenerics extends TableGenerics> =
199
185
  GroupingColumnDef<TGenerics> &
200
186
  ColumnSizingColumnDef
201
187
 
202
- export type Column<TGenerics extends TableGenerics> = ColumnDef<TGenerics> &
203
- CoreColumn<TGenerics> &
188
+ export type Column<TGenerics extends TableGenerics> = CoreColumn<TGenerics> &
204
189
  ColumnVisibilityColumn &
205
190
  ColumnPinningColumn &
206
191
  FiltersColumn<TGenerics> &
@@ -211,43 +196,10 @@ export type Column<TGenerics extends TableGenerics> = ColumnDef<TGenerics> &
211
196
  export type Cell<TGenerics extends TableGenerics> = CoreCell<TGenerics> &
212
197
  GroupingCell<TGenerics>
213
198
 
214
- export type CoreCell<TGenerics extends TableGenerics> = {
215
- id: string
216
- rowId: string
217
- columnId: string
218
- getValue: () => TGenerics['Value']
219
- row: Row<TGenerics>
220
- column: Column<TGenerics>
221
- renderCell: () => string | null | TGenerics['Rendered']
222
- }
223
-
224
199
  export type Header<TGenerics extends TableGenerics> = CoreHeader<TGenerics> &
225
200
  ColumnSizingHeader<TGenerics>
226
201
 
227
- export type CoreHeader<TGenerics extends TableGenerics> = {
228
- id: string
229
- index: number
230
- depth: number
231
- column: Column<TGenerics>
232
- headerGroup: HeaderGroup<TGenerics>
233
- subHeaders: Header<TGenerics>[]
234
- colSpan?: number
235
- rowSpan?: number
236
- getLeafHeaders: () => Header<TGenerics>[]
237
- isPlaceholder?: boolean
238
- placeholderId?: string
239
- renderHeader: (options?: {
240
- renderPlaceholder?: boolean
241
- }) => string | null | TGenerics['Rendered']
242
- renderFooter: (options?: {
243
- renderPlaceholder?: boolean
244
- }) => string | null | TGenerics['Rendered']
245
- }
246
-
247
- export type HeaderGroup<TGenerics extends TableGenerics> = {
248
- id: string
249
- depth: number
250
- headers: Header<TGenerics>[]
251
- }
202
+ export type HeaderGroup<TGenerics extends TableGenerics> =
203
+ CoreHeaderGroup<TGenerics>
252
204
 
253
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,7 +32,7 @@ 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 = createRow(instance, row.id, row.original, row.index, row.depth)
35
36
  newRow.columnFilters = row.columnFilters
36
37
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
37
38
  if (!newRow.subRows.length) {
@@ -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
@@ -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,42 +65,34 @@ 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
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
81
- return row.groupingValuesCache[columnId]
80
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
81
+ return row._groupingValuesCache[columnId]
82
82
  }
83
83
 
84
84
  // Aggregate the values
85
85
  const column = instance.getColumn(columnId)
86
- const aggregateFn = column.getColumnAggregationFn()
86
+ const aggregateFn = column.getAggregationFn()
87
87
 
88
88
  if (aggregateFn) {
89
- row.groupingValuesCache[columnId] = aggregateFn(
90
- () =>
91
- leafRows.map(row => {
92
- let columnValue = row.getValue(columnId)
93
-
94
- if (!depth && column.aggregateValue) {
95
- columnValue = column.aggregateValue(columnValue)
96
- }
97
-
98
- return columnValue
99
- }),
100
- () => groupedRows.map(row => row.getValue(columnId))
89
+ row._groupingValuesCache[columnId] = aggregateFn(
90
+ columnId,
91
+ leafRows,
92
+ groupedRows
101
93
  )
102
94
 
103
- return row.groupingValuesCache[columnId]
95
+ return row._groupingValuesCache[columnId]
104
96
  } else if (column.aggregationFn) {
105
97
  console.info({ column })
106
98
  throw new Error(
@@ -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
  })