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

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 (46) hide show
  1. package/build/cjs/aggregationFns.js +50 -51
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/features/Expanding.js +0 -1
  4. package/build/cjs/features/Expanding.js.map +1 -1
  5. package/build/cjs/features/Filters.js +1 -2
  6. package/build/cjs/features/Filters.js.map +1 -1
  7. package/build/cjs/features/Grouping.js +5 -5
  8. package/build/cjs/features/Grouping.js.map +1 -1
  9. package/build/cjs/features/Sorting.js.map +1 -1
  10. package/build/cjs/features/Visibility.js +0 -5
  11. package/build/cjs/features/Visibility.js.map +1 -1
  12. package/build/cjs/index.js +0 -1
  13. package/build/cjs/index.js.map +1 -1
  14. package/build/cjs/sortingFns.js +53 -51
  15. package/build/cjs/sortingFns.js.map +1 -1
  16. package/build/cjs/utils/getExpandedRowModel.js +2 -2
  17. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  18. package/build/cjs/utils/getGroupedRowModel.js +5 -13
  19. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  20. package/build/cjs/utils/getPaginationRowModel.js +1 -1
  21. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  22. package/build/esm/index.js +118 -131
  23. package/build/esm/index.js.map +1 -1
  24. package/build/stats-html.html +1 -1
  25. package/build/stats-react.json +324 -324
  26. package/build/types/aggregationFns.d.ts +10 -19
  27. package/build/types/features/Expanding.d.ts +0 -1
  28. package/build/types/features/Filters.d.ts +0 -2
  29. package/build/types/features/Grouping.d.ts +6 -8
  30. package/build/types/features/Sorting.d.ts +3 -3
  31. package/build/types/features/Visibility.d.ts +5 -6
  32. package/build/types/sortingFns.d.ts +7 -14
  33. package/build/umd/index.development.js +117 -131
  34. package/build/umd/index.development.js.map +1 -1
  35. package/build/umd/index.production.js +1 -1
  36. package/build/umd/index.production.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/aggregationFns.ts +44 -40
  39. package/src/features/Expanding.ts +0 -2
  40. package/src/features/Filters.ts +0 -5
  41. package/src/features/Grouping.ts +15 -18
  42. package/src/features/Sorting.ts +4 -4
  43. package/src/features/Visibility.ts +7 -16
  44. package/src/sortingFns.ts +59 -81
  45. package/src/utils/getExpandedRowModel.ts +1 -5
  46. package/src/utils/getGroupedRowModel.ts +8 -17
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.0.0-alpha.84",
4
+ "version": "8.0.0-alpha.87",
5
5
  "description": "Hooks for building lightweight, fast and extendable datagrids for React",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/react-table#readme",
@@ -1,64 +1,53 @@
1
- export const aggregationFns = {
2
- sum,
3
- min,
4
- max,
5
- extent,
6
- mean,
7
- median,
8
- unique,
9
- uniqueCount,
10
- count,
11
- }
1
+ import { AggregationFn } from './features/Grouping'
12
2
 
13
- export type BuiltInAggregationFn = keyof typeof aggregationFns
14
-
15
- function sum(_getLeafValues: () => unknown[], getChildValues: () => unknown[]) {
3
+ const sum: AggregationFn<any> = (columnId, _leafRows, childRows) => {
16
4
  // It's faster to just add the aggregations together instead of
17
5
  // process leaf nodes individually
18
- return getChildValues().reduce(
6
+ return childRows.reduce(
19
7
  (sum: number, next: unknown) => sum + (typeof next === 'number' ? next : 0),
20
8
  0
21
9
  )
22
10
  }
23
11
 
24
- function min(_getLeafValues: () => unknown[], getChildValues: () => unknown[]) {
12
+ const min: AggregationFn<any> = (columnId, _leafRows, childRows) => {
25
13
  let min: number | undefined
26
14
 
27
- for (const value of getChildValues() as number[]) {
15
+ childRows.forEach(row => {
16
+ const value = row.getValue(columnId)
17
+
28
18
  if (
29
19
  value != null &&
30
20
  (min! > value || (min === undefined && value >= value))
31
21
  ) {
32
22
  min = value
33
23
  }
34
- }
24
+ })
35
25
 
36
26
  return min
37
27
  }
38
28
 
39
- function max(_getLeafValues: () => unknown[], getChildValues: () => unknown[]) {
29
+ const max: AggregationFn<any> = (columnId, _leafRows, childRows) => {
40
30
  let max: number | undefined
41
31
 
42
- for (const value of getChildValues() as number[]) {
32
+ childRows.forEach(row => {
33
+ const value = row.getValue(columnId)
43
34
  if (
44
35
  value != null &&
45
36
  (max! < value || (max === undefined && value >= value))
46
37
  ) {
47
38
  max = value
48
39
  }
49
- }
40
+ })
50
41
 
51
42
  return max
52
43
  }
53
44
 
54
- function extent(
55
- _getLeafValues: () => unknown[],
56
- getChildValues: () => unknown[]
57
- ) {
45
+ const extent: AggregationFn<any> = (columnId, _leafRows, childRows) => {
58
46
  let min: number | undefined
59
47
  let max: number | undefined
60
48
 
61
- for (const value of getChildValues() as number[]) {
49
+ childRows.forEach(row => {
50
+ const value = row.getValue(columnId)
62
51
  if (value != null) {
63
52
  if (min === undefined) {
64
53
  if (value >= value) min = max = value
@@ -67,36 +56,37 @@ function extent(
67
56
  if (max! < value) max = value
68
57
  }
69
58
  }
70
- }
59
+ })
71
60
 
72
61
  return [min, max]
73
62
  }
74
63
 
75
- export function mean(getLeafValues: () => unknown[]) {
64
+ const mean: AggregationFn<any> = (columnId, leafRows) => {
76
65
  let count = 0
77
66
  let sum = 0
78
67
 
79
- for (let value of getLeafValues() as number[]) {
68
+ leafRows.forEach(row => {
69
+ let value = row.getValue(columnId)
80
70
  if (value != null && (value = +value) >= value) {
81
71
  ++count, (sum += value)
82
72
  }
83
- }
73
+ })
84
74
 
85
75
  if (count) return sum / count
86
76
 
87
77
  return
88
78
  }
89
79
 
90
- function median(getLeafValues: () => unknown[]) {
91
- const leafValues = getLeafValues()
92
- if (!leafValues.length) {
80
+ const median: AggregationFn<any> = (columnId, leafRows) => {
81
+ if (!leafRows.length) {
93
82
  return
94
83
  }
95
84
 
96
85
  let min = 0
97
86
  let max = 0
98
87
 
99
- leafValues.forEach(value => {
88
+ leafRows.forEach(row => {
89
+ let value = row.getValue(columnId)
100
90
  if (typeof value === 'number') {
101
91
  min = Math.min(min, value)
102
92
  max = Math.max(max, value)
@@ -106,14 +96,28 @@ function median(getLeafValues: () => unknown[]) {
106
96
  return (min + max) / 2
107
97
  }
108
98
 
109
- function unique<T>(getLeafValues: () => T[]) {
110
- return Array.from(new Set(getLeafValues()).values())
99
+ const unique: AggregationFn<any> = (columnId, leafRows) => {
100
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values())
111
101
  }
112
102
 
113
- function uniqueCount(getLeafValues: () => unknown[]) {
114
- return new Set(getLeafValues()).size
103
+ const uniqueCount: AggregationFn<any> = (columnId, leafRows) => {
104
+ return new Set(leafRows.map(d => d.getValue(columnId))).size
115
105
  }
116
106
 
117
- function count(getLeafValues: () => unknown[]) {
118
- return getLeafValues().length
107
+ const count: AggregationFn<any> = (_columnId, leafRows) => {
108
+ return leafRows.length
109
+ }
110
+
111
+ export const aggregationFns = {
112
+ sum,
113
+ min,
114
+ max,
115
+ extent,
116
+ mean,
117
+ median,
118
+ unique,
119
+ uniqueCount,
120
+ count,
119
121
  }
122
+
123
+ export type BuiltInAggregationFn = keyof typeof aggregationFns
@@ -30,7 +30,6 @@ export type ExpandedOptions<TGenerics extends TableGenerics> = {
30
30
  getExpandedRowModel?: (
31
31
  instance: TableInstance<TGenerics>
32
32
  ) => () => RowModel<TGenerics>
33
- expandSubRows?: boolean
34
33
  getIsRowExpanded?: (row: Row<TGenerics>) => boolean
35
34
  getRowCanExpand?: (row: Row<TGenerics>) => boolean
36
35
  paginateExpandedRows?: boolean
@@ -67,7 +66,6 @@ export const Expanding: TableFeature = {
67
66
  return {
68
67
  onExpandedChange: makeStateUpdater('expanded', instance),
69
68
  autoResetExpanded: true,
70
- expandSubRows: true,
71
69
  paginateExpandedRows: true,
72
70
  }
73
71
  },
@@ -20,8 +20,6 @@ import {
20
20
  export type FiltersTableState = {
21
21
  columnFilters: ColumnFiltersState
22
22
  globalFilter: any
23
- // filtersProgress: number
24
- // facetProgress: Record<string, number>
25
23
  }
26
24
 
27
25
  export type ColumnFiltersState = ColumnFilter[]
@@ -74,7 +72,6 @@ export type FiltersColumnDef<TGenerics extends TableGenerics> = {
74
72
  filterFn?: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
75
73
  enableColumnFilter?: boolean
76
74
  enableGlobalFilter?: boolean
77
- enableFaceting?: boolean
78
75
  }
79
76
 
80
77
  export type FiltersColumn<TGenerics extends TableGenerics> = {
@@ -98,7 +95,6 @@ export type FiltersColumn<TGenerics extends TableGenerics> = {
98
95
  export type FiltersRow<TGenerics extends TableGenerics> = {
99
96
  columnFilters: Record<string, boolean>
100
97
  columnFiltersMeta: Record<string, TGenerics['FilterMeta']>
101
- subRowsByFacetId: Record<string, Row<TGenerics>[]>
102
98
  }
103
99
 
104
100
  export type FiltersOptions<TGenerics extends TableGenerics> = {
@@ -356,7 +352,6 @@ export const Filters: TableFeature = {
356
352
  return {
357
353
  columnFilters: {},
358
354
  columnFiltersMeta: {},
359
- subRowsByFacetId: {},
360
355
  }
361
356
  },
362
357
 
@@ -15,9 +15,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
 
@@ -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
 
@@ -26,6 +26,10 @@ export type ColumnSort = {
26
26
 
27
27
  export type SortingState = ColumnSort[]
28
28
 
29
+ export type SortingTableState = {
30
+ sorting: SortingState
31
+ }
32
+
29
33
  export type SortingFn<TGenerics extends TableGenerics> = {
30
34
  (rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number
31
35
  }
@@ -35,10 +39,6 @@ export type CustomSortingFns<TGenerics extends TableGenerics> = Record<
35
39
  SortingFn<TGenerics>
36
40
  >
37
41
 
38
- export type SortingTableState = {
39
- sorting: SortingState
40
- }
41
-
42
42
  export type SortingFnOption<TGenerics extends TableGenerics> =
43
43
  | 'auto'
44
44
  | BuiltInSortingFn
@@ -10,6 +10,12 @@ import {
10
10
  } from '../types'
11
11
  import { makeStateUpdater, memo } from '../utils'
12
12
 
13
+ export type VisibilityState = Record<string, boolean>
14
+
15
+ export type VisibilityTableState = {
16
+ columnVisibility: VisibilityState
17
+ }
18
+
13
19
  export type VisibilityOptions = {
14
20
  onColumnVisibilityChange?: OnChangeFn<VisibilityState>
15
21
  enableHiding?: boolean
@@ -19,12 +25,6 @@ export type VisibilityDefaultOptions = {
19
25
  onColumnVisibilityChange: OnChangeFn<VisibilityState>
20
26
  }
21
27
 
22
- export type VisibilityState = Record<string, boolean>
23
-
24
- export type VisibilityTableState = {
25
- columnVisibility: VisibilityState
26
- }
27
-
28
28
  export type VisibilityInstance<TGenerics extends TableGenerics> = {
29
29
  getVisibleFlatColumns: () => Column<TGenerics>[]
30
30
  getVisibleLeafColumns: () => Column<TGenerics>[]
@@ -36,14 +36,11 @@ export type VisibilityInstance<TGenerics extends TableGenerics> = {
36
36
  toggleAllColumnsVisible: (value?: boolean) => void
37
37
  getIsAllColumnsVisible: () => boolean
38
38
  getIsSomeColumnsVisible: () => boolean
39
- getToggleAllColumnsVisibilityHandler: () =>
40
- | undefined
41
- | ((event: unknown) => void)
39
+ getToggleAllColumnsVisibilityHandler: () => (event: unknown) => void
42
40
  }
43
41
 
44
42
  export type VisibilityColumnDef = {
45
43
  enableHiding?: boolean
46
- defaultIsVisible?: boolean
47
44
  }
48
45
 
49
46
  export type VisibilityRow<TGenerics extends TableGenerics> = {
@@ -76,12 +73,6 @@ export const Visibility: TableFeature = {
76
73
  }
77
74
  },
78
75
 
79
- getDefaultColumnDef: () => {
80
- return {
81
- defaultIsVisible: true,
82
- }
83
- },
84
-
85
76
  createColumn: <TGenerics extends TableGenerics>(
86
77
  column: Column<TGenerics>,
87
78
  instance: TableInstance<TGenerics>
package/src/sortingFns.ts CHANGED
@@ -1,40 +1,69 @@
1
- import { TableGenerics, Row } from './types'
1
+ import { SortingFn } from './features/Sorting'
2
2
 
3
3
  export const reSplitAlphaNumeric = /([0-9]+)/gm
4
4
 
5
- export const sortingFns = {
6
- alphanumeric,
7
- alphanumericCaseSensitive,
8
- text,
9
- textCaseSensitive,
10
- datetime,
11
- basic,
5
+ const alphanumeric: SortingFn<any> = (rowA, rowB, columnId) => {
6
+ return compareAlphanumeric(
7
+ toString(rowA.getValue(columnId)).toLowerCase(),
8
+ toString(rowB.getValue(columnId)).toLowerCase()
9
+ )
12
10
  }
13
11
 
14
- export type BuiltInSortingFn = keyof typeof sortingFns
15
-
16
- function alphanumeric<TGenerics extends TableGenerics>(
17
- rowA: Row<TGenerics>,
18
- rowB: Row<TGenerics>,
19
- columnId: string
20
- ) {
12
+ const alphanumericCaseSensitive: SortingFn<any> = (rowA, rowB, columnId) => {
21
13
  return compareAlphanumeric(
14
+ toString(rowA.getValue(columnId)),
15
+ toString(rowB.getValue(columnId))
16
+ )
17
+ }
18
+
19
+ // The text filter is more basic (less numeric support)
20
+ // but is much faster
21
+ const text: SortingFn<any> = (rowA, rowB, columnId) => {
22
+ return compareBasic(
22
23
  toString(rowA.getValue(columnId)).toLowerCase(),
23
24
  toString(rowB.getValue(columnId)).toLowerCase()
24
25
  )
25
26
  }
26
27
 
27
- function alphanumericCaseSensitive<TGenerics extends TableGenerics>(
28
- rowA: Row<TGenerics>,
29
- rowB: Row<TGenerics>,
30
- columnId: string
31
- ) {
32
- return compareAlphanumeric(
28
+ // The text filter is more basic (less numeric support)
29
+ // but is much faster
30
+ const textCaseSensitive: SortingFn<any> = (rowA, rowB, columnId) => {
31
+ return compareBasic(
33
32
  toString(rowA.getValue(columnId)),
34
33
  toString(rowB.getValue(columnId))
35
34
  )
36
35
  }
37
36
 
37
+ const datetime: SortingFn<any> = (rowA, rowB, columnId) => {
38
+ return compareBasic(
39
+ (rowA.getValue(columnId) as Date).getTime(),
40
+ (rowB.getValue(columnId) as Date).getTime()
41
+ )
42
+ }
43
+
44
+ const basic: SortingFn<any> = (rowA, rowB, columnId) => {
45
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId))
46
+ }
47
+
48
+ // Utils
49
+
50
+ function compareBasic(a: any, b: any) {
51
+ return a === b ? 0 : a > b ? 1 : -1
52
+ }
53
+
54
+ function toString(a: any) {
55
+ if (typeof a === 'number') {
56
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
57
+ return ''
58
+ }
59
+ return String(a)
60
+ }
61
+ if (typeof a === 'string') {
62
+ return a
63
+ }
64
+ return ''
65
+ }
66
+
38
67
  // Mixed sorting is slow, but very inclusive of many edge cases.
39
68
  // It handles numbers, mixed alphanumeric combinations, and even
40
69
  // null, undefined, and Infinity
@@ -82,66 +111,15 @@ function compareAlphanumeric(aStr: string, bStr: string) {
82
111
  return a.length - b.length
83
112
  }
84
113
 
85
- // The text filter is more basic (less numeric support)
86
- // but is much faster
87
- function text<TGenerics extends TableGenerics>(
88
- rowA: Row<TGenerics>,
89
- rowB: Row<TGenerics>,
90
- columnId: string
91
- ) {
92
- return compareBasic(
93
- toString(rowA.getValue(columnId)).toLowerCase(),
94
- toString(rowB.getValue(columnId)).toLowerCase()
95
- )
96
- }
97
-
98
- // The text filter is more basic (less numeric support)
99
- // but is much faster
100
- function textCaseSensitive<TGenerics extends TableGenerics>(
101
- rowA: Row<TGenerics>,
102
- rowB: Row<TGenerics>,
103
- columnId: string
104
- ) {
105
- return compareBasic(
106
- toString(rowA.getValue(columnId)),
107
- toString(rowB.getValue(columnId))
108
- )
109
- }
110
-
111
- function datetime<TGenerics extends TableGenerics>(
112
- rowA: Row<TGenerics>,
113
- rowB: Row<TGenerics>,
114
- columnId: string
115
- ) {
116
- return compareBasic(
117
- (rowA.getValue(columnId) as Date).getTime(),
118
- (rowB.getValue(columnId) as Date).getTime()
119
- )
120
- }
121
-
122
- function basic<TGenerics extends TableGenerics>(
123
- rowA: Row<TGenerics>,
124
- rowB: Row<TGenerics>,
125
- columnId: string
126
- ) {
127
- return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId))
128
- }
129
-
130
- // Utils
114
+ // Exports
131
115
 
132
- function compareBasic(a: any, b: any) {
133
- return a === b ? 0 : a > b ? 1 : -1
116
+ export const sortingFns = {
117
+ alphanumeric,
118
+ alphanumericCaseSensitive,
119
+ text,
120
+ textCaseSensitive,
121
+ datetime,
122
+ basic,
134
123
  }
135
124
 
136
- function toString(a: any) {
137
- if (typeof a === 'number') {
138
- if (isNaN(a) || a === Infinity || a === -Infinity) {
139
- return ''
140
- }
141
- return String(a)
142
- }
143
- if (typeof a === 'string') {
144
- return a
145
- }
146
- return ''
147
- }
125
+ export type BuiltInSortingFn = keyof typeof sortingFns
@@ -39,11 +39,7 @@ export function expandRows<TGenerics extends TableGenerics>(
39
39
  const handleRow = (row: Row<TGenerics>) => {
40
40
  expandedRows.push(row)
41
41
 
42
- if (
43
- instance.options.expandSubRows &&
44
- row.subRows?.length &&
45
- row.getIsExpanded()
46
- ) {
42
+ if (row.subRows?.length && row.getIsExpanded()) {
47
43
  row.subRows.forEach(handleRow)
48
44
  }
49
45
  }
@@ -77,31 +77,22 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
77
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.columnDef.aggregateValue) {
95
- columnValue =
96
- column.columnDef.aggregateValue(columnValue)
97
- }
98
-
99
- return columnValue
100
- }),
101
- () => groupedRows.map(row => row.getValue(columnId))
89
+ row._groupingValuesCache[columnId] = aggregateFn(
90
+ columnId,
91
+ leafRows,
92
+ groupedRows
102
93
  )
103
94
 
104
- return row.groupingValuesCache[columnId]
95
+ return row._groupingValuesCache[columnId]
105
96
  } else if (column.aggregationFn) {
106
97
  console.info({ column })
107
98
  throw new Error(