@tanstack/table-core 9.0.0-beta.47 → 9.0.0-beta.49

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 (186) hide show
  1. package/dist/core/row-models/coreRowModelsFeature.types.d.cts +1 -1
  2. package/dist/core/row-models/coreRowModelsFeature.types.d.ts +1 -1
  3. package/dist/core/row-models/coreRowModelsFeature.utils.cjs +1 -1
  4. package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
  5. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +1 -1
  6. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +1 -1
  7. package/dist/core/row-models/coreRowModelsFeature.utils.js +1 -1
  8. package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
  9. package/dist/features/aggregation/aggregationFeature.cjs +38 -0
  10. package/dist/features/aggregation/aggregationFeature.cjs.map +1 -0
  11. package/dist/features/aggregation/aggregationFeature.d.cts +10 -0
  12. package/dist/features/aggregation/aggregationFeature.d.ts +10 -0
  13. package/dist/features/aggregation/aggregationFeature.js +38 -0
  14. package/dist/features/aggregation/aggregationFeature.js.map +1 -0
  15. package/dist/features/aggregation/aggregationFeature.types.cjs +13 -0
  16. package/dist/features/aggregation/aggregationFeature.types.cjs.map +1 -0
  17. package/dist/features/aggregation/aggregationFeature.types.d.cts +172 -0
  18. package/dist/features/aggregation/aggregationFeature.types.d.ts +172 -0
  19. package/dist/features/aggregation/aggregationFeature.types.js +12 -0
  20. package/dist/features/aggregation/aggregationFeature.types.js.map +1 -0
  21. package/dist/features/aggregation/aggregationFeature.utils.cjs +198 -0
  22. package/dist/features/aggregation/aggregationFeature.utils.cjs.map +1 -0
  23. package/dist/features/aggregation/aggregationFeature.utils.d.cts +33 -0
  24. package/dist/features/aggregation/aggregationFeature.utils.d.ts +33 -0
  25. package/dist/features/aggregation/aggregationFeature.utils.js +192 -0
  26. package/dist/features/aggregation/aggregationFeature.utils.js.map +1 -0
  27. package/dist/features/aggregation/aggregationFns.cjs +240 -0
  28. package/dist/features/aggregation/aggregationFns.cjs.map +1 -0
  29. package/dist/features/aggregation/aggregationFns.d.cts +67 -0
  30. package/dist/features/aggregation/aggregationFns.d.ts +67 -0
  31. package/dist/features/aggregation/aggregationFns.js +229 -0
  32. package/dist/features/aggregation/aggregationFns.js.map +1 -0
  33. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +7 -4
  34. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
  35. package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
  36. package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
  37. package/dist/features/column-faceting/createFacetedRowModel.cjs +1 -1
  38. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  39. package/dist/features/column-faceting/createFacetedRowModel.js +1 -1
  40. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  41. package/dist/features/column-faceting/createFacetedUniqueValues.cjs +8 -4
  42. package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
  43. package/dist/features/column-faceting/createFacetedUniqueValues.js +9 -5
  44. package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
  45. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +1 -1
  46. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +1 -1
  47. package/dist/{fns → features/column-filtering}/filterFns.cjs +1 -1
  48. package/dist/features/column-filtering/filterFns.cjs.map +1 -0
  49. package/dist/{fns → features/column-filtering}/filterFns.d.cts +4 -4
  50. package/dist/{fns → features/column-filtering}/filterFns.d.ts +4 -4
  51. package/dist/{fns → features/column-filtering}/filterFns.js +1 -1
  52. package/dist/features/column-filtering/filterFns.js.map +1 -0
  53. package/dist/features/column-grouping/columnGroupingFeature.cjs +3 -12
  54. package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
  55. package/dist/features/column-grouping/columnGroupingFeature.d.cts +1 -1
  56. package/dist/features/column-grouping/columnGroupingFeature.d.ts +1 -1
  57. package/dist/features/column-grouping/columnGroupingFeature.js +4 -13
  58. package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
  59. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +6 -87
  60. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -87
  61. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +0 -64
  62. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  63. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -44
  64. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -44
  65. package/dist/features/column-grouping/columnGroupingFeature.utils.js +2 -63
  66. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  67. package/dist/features/column-grouping/createGroupedRowModel.cjs +23 -16
  68. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  69. package/dist/features/column-grouping/createGroupedRowModel.d.cts +2 -6
  70. package/dist/features/column-grouping/createGroupedRowModel.d.ts +2 -6
  71. package/dist/features/column-grouping/createGroupedRowModel.js +25 -18
  72. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  73. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +1 -1
  74. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  75. package/dist/features/global-filtering/globalFilteringFeature.utils.js +1 -1
  76. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  77. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
  78. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
  79. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +1 -1
  80. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  81. package/dist/features/row-sorting/rowSortingFeature.utils.js +1 -1
  82. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  83. package/dist/{fns → features/row-sorting}/sortFns.cjs +1 -1
  84. package/dist/{fns/sortFns.js.map → features/row-sorting/sortFns.cjs.map} +1 -1
  85. package/dist/{fns → features/row-sorting}/sortFns.d.cts +4 -4
  86. package/dist/{fns → features/row-sorting}/sortFns.d.ts +4 -4
  87. package/dist/{fns → features/row-sorting}/sortFns.js +1 -1
  88. package/dist/features/row-sorting/sortFns.js.map +1 -0
  89. package/dist/features/stockFeatures.cjs +2 -0
  90. package/dist/features/stockFeatures.cjs.map +1 -1
  91. package/dist/features/stockFeatures.d.cts +2 -0
  92. package/dist/features/stockFeatures.d.ts +2 -0
  93. package/dist/features/stockFeatures.js +2 -0
  94. package/dist/features/stockFeatures.js.map +1 -1
  95. package/dist/index.cjs +7 -4
  96. package/dist/index.d.cts +7 -5
  97. package/dist/index.d.ts +7 -5
  98. package/dist/index.js +6 -4
  99. package/dist/static-functions.cjs +8 -3
  100. package/dist/static-functions.d.cts +3 -2
  101. package/dist/static-functions.d.ts +3 -2
  102. package/dist/static-functions.js +3 -2
  103. package/dist/types/Cell.d.cts +3 -1
  104. package/dist/types/Cell.d.ts +3 -1
  105. package/dist/types/Column.d.cts +4 -2
  106. package/dist/types/Column.d.ts +4 -2
  107. package/dist/types/ColumnDef.d.cts +5 -3
  108. package/dist/types/ColumnDef.d.ts +5 -3
  109. package/dist/types/Row.d.cts +3 -1
  110. package/dist/types/Row.d.ts +3 -1
  111. package/dist/types/RowModel.d.cts +1 -1
  112. package/dist/types/RowModel.d.ts +1 -1
  113. package/dist/types/RowModelFns.d.cts +3 -3
  114. package/dist/types/RowModelFns.d.ts +3 -3
  115. package/dist/types/Table.d.cts +1 -1
  116. package/dist/types/Table.d.ts +1 -1
  117. package/dist/types/TableFeatures.d.cts +4 -4
  118. package/dist/types/TableFeatures.d.ts +4 -4
  119. package/dist/types/TableOptions.d.cts +5 -3
  120. package/dist/types/TableOptions.d.ts +5 -3
  121. package/dist/types/TableState.d.cts +1 -1
  122. package/dist/types/TableState.d.ts +1 -1
  123. package/dist/worker/initTableWorker.cjs.map +1 -1
  124. package/dist/worker/initTableWorker.js.map +1 -1
  125. package/package.json +1 -1
  126. package/skills/aggregation/SKILL.md +131 -0
  127. package/skills/api-not-found/SKILL.md +1 -1
  128. package/skills/client-vs-server/SKILL.md +1 -1
  129. package/skills/column-faceting/SKILL.md +1 -1
  130. package/skills/column-filtering/SKILL.md +1 -1
  131. package/skills/column-ordering/SKILL.md +1 -1
  132. package/skills/column-pinning/SKILL.md +1 -1
  133. package/skills/column-resizing/SKILL.md +1 -1
  134. package/skills/column-sizing/SKILL.md +1 -1
  135. package/skills/column-visibility/SKILL.md +1 -1
  136. package/skills/core/SKILL.md +1 -1
  137. package/skills/custom-features/SKILL.md +1 -1
  138. package/skills/expanding/SKILL.md +1 -1
  139. package/skills/global-filtering/SKILL.md +1 -1
  140. package/skills/grouping/SKILL.md +12 -18
  141. package/skills/migrate-v8-to-v9/SKILL.md +15 -2
  142. package/skills/pagination/SKILL.md +1 -1
  143. package/skills/row-pinning/SKILL.md +1 -1
  144. package/skills/row-selection/SKILL.md +1 -1
  145. package/skills/sorting/SKILL.md +1 -1
  146. package/skills/table-features/SKILL.md +5 -2
  147. package/skills/typescript/SKILL.md +1 -1
  148. package/src/core/row-models/coreRowModelsFeature.utils.ts +1 -1
  149. package/src/features/aggregation/aggregationFeature.ts +59 -0
  150. package/src/features/aggregation/aggregationFeature.types.ts +312 -0
  151. package/src/features/aggregation/aggregationFeature.utils.ts +401 -0
  152. package/src/features/aggregation/aggregationFns.ts +336 -0
  153. package/src/features/column-faceting/createFacetedMinMaxValues.ts +33 -7
  154. package/src/features/column-faceting/createFacetedRowModel.ts +4 -1
  155. package/src/features/column-faceting/createFacetedUniqueValues.ts +45 -11
  156. package/src/features/column-filtering/columnFilteringFeature.types.ts +1 -1
  157. package/src/{fns → features/column-filtering}/filterFns.ts +4 -4
  158. package/src/features/column-grouping/columnGroupingFeature.ts +1 -20
  159. package/src/features/column-grouping/columnGroupingFeature.types.ts +4 -141
  160. package/src/features/column-grouping/columnGroupingFeature.utils.ts +1 -122
  161. package/src/features/column-grouping/createGroupedRowModel.ts +32 -41
  162. package/src/features/global-filtering/globalFilteringFeature.utils.ts +1 -1
  163. package/src/features/row-sorting/rowSortingFeature.types.ts +1 -1
  164. package/src/features/row-sorting/rowSortingFeature.utils.ts +1 -1
  165. package/src/{fns → features/row-sorting}/sortFns.ts +4 -7
  166. package/src/features/stockFeatures.ts +3 -0
  167. package/src/index.ts +7 -8
  168. package/src/static-functions.ts +1 -0
  169. package/src/types/Cell.ts +2 -0
  170. package/src/types/Column.ts +3 -1
  171. package/src/types/ColumnDef.ts +6 -3
  172. package/src/types/Row.ts +2 -0
  173. package/src/types/RowModelFns.ts +3 -3
  174. package/src/types/TableFeatures.ts +4 -4
  175. package/src/types/TableOptions.ts +5 -1
  176. package/src/worker/initTableWorker.ts +1 -1
  177. package/dist/fns/aggregationFns.cjs +0 -234
  178. package/dist/fns/aggregationFns.cjs.map +0 -1
  179. package/dist/fns/aggregationFns.d.cts +0 -139
  180. package/dist/fns/aggregationFns.d.ts +0 -139
  181. package/dist/fns/aggregationFns.js +0 -221
  182. package/dist/fns/aggregationFns.js.map +0 -1
  183. package/dist/fns/filterFns.cjs.map +0 -1
  184. package/dist/fns/filterFns.js.map +0 -1
  185. package/dist/fns/sortFns.cjs.map +0 -1
  186. package/src/fns/aggregationFns.ts +0 -303
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: aggregation
3
+ description: >
4
+ Aggregate TanStack Table columns independently of grouping, including grand totals, caller-selected row totals, multiple keyed aggregations, custom context-based definitions, grouped merges, manual values, and worker constraints.
5
+ metadata:
6
+ {
7
+ type: sub-skill,
8
+ library: '@tanstack/table-core',
9
+ library_version: '9.0.0-beta.49',
10
+ }
11
+ requires: ['core', 'table-features']
12
+ sources:
13
+ - 'TanStack/table:docs/guide/aggregation.md'
14
+ - 'TanStack/table:docs/framework/react/guide/aggregation.md'
15
+ - 'TanStack/table:packages/table-core/src/features/aggregation'
16
+ - 'TanStack/table:examples/react/aggregation'
17
+ - 'TanStack/table:examples/react/grouped-aggregation'
18
+ ---
19
+
20
+ This skill builds on `core` and `table-features`. Aggregation is independent
21
+ from grouping: use it alone for totals, or combine it with the `grouping` skill
22
+ for synthetic grouped rows.
23
+
24
+ ## Setup
25
+
26
+ <!-- skill-snippet:check -->
27
+
28
+ ```ts
29
+ import {
30
+ aggregationFeature,
31
+ aggregationFn_mean,
32
+ aggregationFn_sum,
33
+ tableFeatures,
34
+ } from '@tanstack/table-core'
35
+
36
+ export const features = tableFeatures({
37
+ aggregationFeature,
38
+ aggregationFns: {
39
+ mean: aggregationFn_mean,
40
+ sum: aggregationFn_sum,
41
+ },
42
+ })
43
+ ```
44
+
45
+ ## Core Patterns
46
+
47
+ ### Grand total and selected row scopes
48
+
49
+ ```ts
50
+ const grandTotal = salaryColumn.getAggregationValue()
51
+ const filteredTotal = salaryColumn.getAggregationValue(
52
+ table.getFilteredRowModel().rows,
53
+ )
54
+ ```
55
+
56
+ The default uses the pre-grouped row model. Explicit rows can come from any row
57
+ model or caller-selected subset. Hierarchical inputs are normalized to unique
58
+ terminal rows. Default calls are cached; explicit-row calls intentionally are
59
+ not because array identity and contents are caller-owned.
60
+
61
+ ### Multiple aggregations
62
+
63
+ ```ts
64
+ columnHelper.accessor('salary', {
65
+ aggregationFn: ['mean', { id: 'range', aggregationFn: 'extent' }],
66
+ })
67
+
68
+ const value = salaryColumn.getAggregationValue<{
69
+ mean: number
70
+ range: [number, number]
71
+ }>()
72
+ ```
73
+
74
+ A scalar option returns a scalar. An array returns a keyed object. Named
75
+ functions use their registry name; descriptors provide a stable `id`, which is
76
+ required for inline definitions in an array.
77
+
78
+ ### Custom definitions
79
+
80
+ ```ts
81
+ const weightedMean = constructAggregationFn({
82
+ aggregate: ({ rows, getValue }) => {
83
+ const total = rows.reduce((sum, row) => sum + Number(getValue(row)), 0)
84
+ return rows.length ? total / rows.length : undefined
85
+ },
86
+ })
87
+ ```
88
+
89
+ The context provides `rows`, `getValue`, `column`, `columnId`, `table`, and an
90
+ optional `groupingRow`. Add `merge({ childResults, childRows, ...context })`
91
+ when nested groups can efficiently combine child results; otherwise the engine
92
+ re-runs `aggregate` over normalized terminal rows.
93
+
94
+ ### Manual or remote values
95
+
96
+ Set a column definition's `getAggregationValue(context)` to return `{ value }`
97
+ for requests handled by a server or another execution environment. Returning
98
+ `undefined` falls back to the local definition. `manualAggregation: true`
99
+ disables that local fallback.
100
+
101
+ ## Common Mistakes
102
+
103
+ ### [HIGH] Adding grouping for a grand total
104
+
105
+ Wrong: registering `columnGroupingFeature` solely to total a column.
106
+
107
+ Correct: register `aggregationFeature` and call
108
+ `column.getAggregationValue()`. Grouping is only required for grouped rows.
109
+
110
+ ### [HIGH] Passing a scope label and rows
111
+
112
+ There is no scope option. Call `getAggregationValue()` for the default or pass
113
+ the exact rows from the desired row model.
114
+
115
+ ### [HIGH] Reusing the legacy callable signature
116
+
117
+ Wrong: `(columnId, leafRows, childRows) => result`.
118
+
119
+ Correct: `constructAggregationFn({ aggregate: ({ rows, getValue }) => result })`.
120
+
121
+ ### [MEDIUM] Assuming arbitrary totals run in the worker
122
+
123
+ The experimental worker computes grouped row-model aggregates. Public
124
+ `getAggregationValue(rows?)` totals execute on the main thread, and custom
125
+ grouped results sent by the worker must be structured-cloneable.
126
+
127
+ ## API Discovery
128
+
129
+ Inspect `node_modules/@tanstack/table-core/src/features/aggregation/` and the
130
+ Aggregation Guide. Use `Column_Aggregation`, `AggregationFnDef`,
131
+ `AggregationContext`, and `AggregationResult` for the typed public surface.
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core', 'table-features']
10
10
  sources:
11
11
  - 'TanStack/table:packages/table-core/src/index.ts'
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core', 'table-features']
10
10
  sources:
11
11
  - 'TanStack/table:docs/guide/row-models.md'
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'column-filtering']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'column-sizing']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'column-sizing']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: core
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  sources:
10
10
  - 'TanStack/table:docs/overview.md'
11
11
  - 'TanStack/table:docs/guide/tables.md'
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core', 'table-features', 'typescript']
10
10
  sources:
11
11
  - 'TanStack/table:docs/framework/react/guide/custom-features.md'
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server', 'column-filtering']
12
12
  sources:
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: grouping
3
3
  description: >
4
- Group and aggregate rows with columnGroupingFeature, groupedRowModel, aggregationFns, groupedColumnMode, and manualGrouping. Load for grouped, placeholder, or aggregated cells and grouping interactions with expansion or pagination.
4
+ Group rows with columnGroupingFeature, groupedRowModel, groupedColumnMode, and manualGrouping. Load for grouped or placeholder cells and grouping interactions with expansion or pagination.
5
5
  metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -15,13 +15,12 @@ sources:
15
15
  - 'TanStack/table:examples/react/grouping'
16
16
  ---
17
17
 
18
- This skill builds on `core`, `table-features`, and `client-vs-server`. Grouping creates row structure and aggregate values; the renderer chooses grouped-cell UI.
18
+ This skill builds on `core`, `table-features`, and `client-vs-server`. Grouping creates row structure and the renderer chooses grouped-cell UI. Load the separate `aggregation` skill when grouped rows should also calculate values.
19
19
 
20
20
  ## Setup
21
21
 
22
22
  ```ts
23
23
  import {
24
- aggregationFn_sum,
25
24
  columnGroupingFeature,
26
25
  createGroupedRowModel,
27
26
  tableFeatures,
@@ -30,26 +29,18 @@ import {
30
29
  export const features = tableFeatures({
31
30
  columnGroupingFeature,
32
31
  groupedRowModel: createGroupedRowModel(),
33
- aggregationFns: { sum: aggregationFn_sum },
34
32
  })
35
33
  ```
36
34
 
37
- Import individual `aggregationFn_*` built-ins and register only those your
38
- columns reference by string name or that `aggregationFn: 'auto'` should
39
- resolve (numbers resolve to `sum`, dates to `extent`). The full
40
- `aggregationFns` registry object still works but bundles every built-in.
41
-
42
35
  ## Core Patterns
43
36
 
44
37
  ```ts
45
38
  const options = { groupedColumnMode: 'reorder' as const }
46
39
  const mode = cell.getIsGrouped()
47
40
  ? 'grouped'
48
- : cell.getIsAggregated()
49
- ? 'aggregated'
50
- : cell.getIsPlaceholder()
51
- ? 'placeholder'
52
- : 'value'
41
+ : cell.getIsPlaceholder()
42
+ ? 'placeholder'
43
+ : 'value'
53
44
  ```
54
45
 
55
46
  Render these cell modes deliberately.
@@ -62,7 +53,7 @@ Wrong: `tableFeatures({ groupedRowModel: createGroupedRowModel() })`
62
53
 
63
54
  Correct: `tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel() })`
64
55
 
65
- The grouped slot and aggregation registry require `columnGroupingFeature`.
56
+ The grouped row-model slot requires `columnGroupingFeature`.
66
57
 
67
58
  Source: `packages/table-core/src/types/TableFeatures.ts#FeatureSlotPrereqs`
68
59
 
@@ -95,10 +86,13 @@ Wrong: `render(cell.getValue())`
95
86
 
96
87
  Correct: `render(cell.getIsPlaceholder() ? null : cell.getValue())`
97
88
 
98
- Placeholder and aggregated cells do not represent ordinary leaf values.
89
+ Placeholder cells do not represent ordinary leaf values. Group rows should
90
+ only render their grouped cell when aggregation is not enabled.
99
91
 
100
92
  Source: `examples/react/grouping/src/main.tsx`
101
93
 
102
94
  ## API Discovery
103
95
 
104
- Inspect `node_modules/@tanstack/table-core/src/features/column-grouping/` and `src/fns/aggregationFns.ts`.
96
+ Inspect `node_modules/@tanstack/table-core/src/features/column-grouping/` for
97
+ grouping. Load the `aggregation` skill when totals, multiple aggregations,
98
+ grouped aggregate values, or custom definitions are part of the task.
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: lifecycle
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core', 'table-features', 'typescript']
10
10
  sources:
11
11
  - 'TanStack/table:docs/framework/react/guide/migrating.md'
@@ -70,7 +70,8 @@ V8 bundled all stock features. V9 exposes an API only when its feature is presen
70
70
  | --------------------------- | ------------------------- |
71
71
  | Column faceting | `columnFacetingFeature` |
72
72
  | Column filtering | `columnFilteringFeature` |
73
- | Grouping and aggregation | `columnGroupingFeature` |
73
+ | Aggregation | `aggregationFeature` |
74
+ | Grouping | `columnGroupingFeature` |
74
75
  | Column ordering | `columnOrderingFeature` |
75
76
  | Column pinning | `columnPinningFeature` |
76
77
  | Interactive column resizing | `columnResizingFeature` |
@@ -90,6 +91,7 @@ Honor feature prerequisites in the same `tableFeatures` call:
90
91
  - `columnResizingFeature` requires `columnSizingFeature`.
91
92
  - `globalFilteringFeature` requires `columnFilteringFeature`.
92
93
  - Every row-model or function-registry slot requires its associated feature.
94
+ - `aggregationFns` requires `aggregationFeature`; grouped aggregation uses both `aggregationFeature` and `columnGroupingFeature`.
93
95
  - Put prerequisite feature properties before dependent slots so inference and diagnostics remain clear.
94
96
 
95
97
  ### 2. Move row models into feature slots and rename factories
@@ -120,6 +122,16 @@ Move registries from table options or factory arguments into these feature slots
120
122
 
121
123
  Register only the built-ins the table references by string name, importing each individually (`filterFn_includesString`, `sortFn_alphanumeric`, `aggregationFn_sum`, and so on) alongside any custom functions. The full registry objects (`filterFns`, `sortFns`, `aggregationFns` exports) still work but bundle every built-in. A slot's keys become the valid string names in column definitions, and `'auto'` resolves only registered functions.
122
124
 
125
+ Aggregation is independent from grouping. Add `aggregationFeature` for
126
+ `aggregationFn`, `aggregatedCell`, `column.getAggregationValue(rows?)`, and
127
+ `cell.getIsAggregated`. A root total does not require grouping. Convert legacy
128
+ custom callables `(columnId, leafRows, childRows) => result` to
129
+ `constructAggregationFn({ aggregate: (context) => result, merge? })`
130
+ definitions. Replace `column.getAggregationFn()` with
131
+ `column.getAggregationFns()`; arrays in `aggregationFn` return keyed objects.
132
+ Replace the old `AggregationFn` and `CreatedAggregationFn` types with
133
+ `AggregationFnDef`.
134
+
123
135
  ### 3. Migrate state reads and whole-state observation
124
136
 
125
137
  `table.getState()` and the top-level `onStateChange` option are removed. Individual `on[Slice]Change` callbacks remain.
@@ -280,6 +292,7 @@ Do not confuse new capabilities with required breakages. After the table works,
280
292
  - [ ] Move all remaining `get*RowModel()` options or earlier-beta `rowModels` entries to `create*RowModel()` feature slots.
281
293
  - [ ] Register each dependent feature before its row-model slot.
282
294
  - [ ] Move `filterFns`, `sortingFns`/`sortFns`, and `aggregationFns` into feature slots, registering individually imported built-ins; pass no registries to factories.
295
+ - [ ] Register `aggregationFeature` independently and migrate custom aggregation callables to context-based `AggregationFnDef` definitions.
283
296
  - [ ] Register `columnFilteringFeature` before global filtering and filter/facet dependencies.
284
297
  - [ ] Register `columnSizingFeature` before `columnResizingFeature`.
285
298
  - [ ] Replace `table.getState()` and top-level `onStateChange` according to the adapter state guide.
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.47',
9
+ library_version: '9.0.0-beta.49',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core']
10
10
  sources:
11
11
  - 'TanStack/table:docs/guide/row-models.md'
@@ -22,6 +22,7 @@ This skill builds on `core`. Read it first for the headless model and stable inp
22
22
 
23
23
  ```ts
24
24
  import {
25
+ aggregationFeature,
25
26
  aggregationFn_sum,
26
27
  columnGroupingFeature,
27
28
  createFilteredRowModel,
@@ -37,6 +38,7 @@ export const features = tableFeatures({
37
38
  columnFilteringFeature,
38
39
  filteredRowModel: createFilteredRowModel(),
39
40
  filterFns: { includesString: filterFn_includesString },
41
+ aggregationFeature,
40
42
  columnGroupingFeature,
41
43
  aggregationFns: { sum: aggregationFn_sum },
42
44
  rowSortingFeature,
@@ -66,6 +68,7 @@ const features = tableFeatures({
66
68
  filterFns: { includesString: filterFn_includesString },
67
69
  rowSortingFeature,
68
70
  sortFns: { alphanumeric: sortFn_alphanumeric },
71
+ aggregationFeature,
69
72
  columnGroupingFeature,
70
73
  aggregationFns: { sum: aggregationFn_sum },
71
74
  })
@@ -73,7 +76,7 @@ const features = tableFeatures({
73
76
 
74
77
  `filterFns`, `sortFns`, and `aggregationFns` are feature slots, not table
75
78
  options. They respectively require `columnFilteringFeature`,
76
- `rowSortingFeature`, and `columnGroupingFeature`. Import individual built-ins
79
+ `rowSortingFeature`, and `aggregationFeature`. Import individual built-ins
77
80
  (`filterFn_*`, `sortFn_*`, `aggregationFn_*`) and register them under their
78
81
  conventional keys; the full registry objects (`filterFns`, `sortFns`,
79
82
  `aggregationFns` exports) still work but bundle every built-in. A registered
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.47'
8
+ library_version: '9.0.0-beta.49'
9
9
  requires: ['core', 'table-features']
10
10
  sources:
11
11
  - 'TanStack/table:docs/guide/helpers.md'
@@ -92,7 +92,7 @@ export function table_getPreGroupedRowModel<
92
92
  }
93
93
 
94
94
  /**
95
- * Resolves the row model after grouping has produced grouped and aggregated rows.
95
+ * Resolves the row model after grouping has produced grouped rows.
96
96
  *
97
97
  * When `manualGrouping` is enabled, or no grouped row-model factory was
98
98
  * registered, this returns the pre-grouped row model unchanged.
@@ -0,0 +1,59 @@
1
+ import { assignPrototypeAPIs, makeObjectMap } from '../../utils'
2
+ import {
3
+ cell_getIsAggregated,
4
+ column_getAggregationFns,
5
+ column_getAggregationValue,
6
+ column_getAutoAggregationFn,
7
+ formatAggregatedCellValue,
8
+ } from './aggregationFeature.utils'
9
+ import type { TableFeature } from '../../types/TableFeatures'
10
+
11
+ /**
12
+ * Independent aggregation feature for grouped values and root/custom-row totals.
13
+ */
14
+ export const aggregationFeature: TableFeature = {
15
+ getDefaultColumnDef: () => ({
16
+ aggregatedCell: ({ column, getValue }: any) =>
17
+ formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),
18
+ aggregationFn: 'auto',
19
+ }),
20
+
21
+ getDefaultTableOptions: () => ({
22
+ manualAggregation: false,
23
+ }),
24
+
25
+ assignCellPrototype: (prototype, table) => {
26
+ assignPrototypeAPIs('aggregationFeature', prototype, table, {
27
+ cell_getIsAggregated: {
28
+ fn: (cell) => cell_getIsAggregated(cell),
29
+ },
30
+ })
31
+ },
32
+
33
+ assignColumnPrototype: (prototype, table) => {
34
+ assignPrototypeAPIs('aggregationFeature', prototype, table, {
35
+ column_getAggregationFns: {
36
+ fn: (column) => column_getAggregationFns(column),
37
+ },
38
+ column_getAggregationValue: {
39
+ fn: (column, rows) => column_getAggregationValue(column, rows),
40
+ },
41
+ column_getAutoAggregationFn: {
42
+ fn: (column) => column_getAutoAggregationFn(column),
43
+ memoDeps: (column) => [
44
+ column.table.getCoreRowModel(),
45
+ column.table._rowModelFns.aggregationFns,
46
+ ],
47
+ },
48
+ })
49
+ },
50
+
51
+ initColumnInstanceData: (column) => {
52
+ ;(column as any)._aggregationValueCache = undefined
53
+ ;(column as any)._resolvedAggregationFnsCache = undefined
54
+ },
55
+
56
+ initRowInstanceData: (row) => {
57
+ ;(row as any)._aggregationValuesCache = makeObjectMap()
58
+ },
59
+ }