@tanstack/table-core 9.0.0-beta.46 → 9.0.0-beta.48
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.
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.js +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/features/aggregation/aggregationFeature.cjs +38 -0
- package/dist/features/aggregation/aggregationFeature.cjs.map +1 -0
- package/dist/features/aggregation/aggregationFeature.d.cts +10 -0
- package/dist/features/aggregation/aggregationFeature.d.ts +10 -0
- package/dist/features/aggregation/aggregationFeature.js +38 -0
- package/dist/features/aggregation/aggregationFeature.js.map +1 -0
- package/dist/features/aggregation/aggregationFeature.types.cjs +13 -0
- package/dist/features/aggregation/aggregationFeature.types.cjs.map +1 -0
- package/dist/features/aggregation/aggregationFeature.types.d.cts +172 -0
- package/dist/features/aggregation/aggregationFeature.types.d.ts +172 -0
- package/dist/features/aggregation/aggregationFeature.types.js +12 -0
- package/dist/features/aggregation/aggregationFeature.types.js.map +1 -0
- package/dist/features/aggregation/aggregationFeature.utils.cjs +198 -0
- package/dist/features/aggregation/aggregationFeature.utils.cjs.map +1 -0
- package/dist/features/aggregation/aggregationFeature.utils.d.cts +33 -0
- package/dist/features/aggregation/aggregationFeature.utils.d.ts +33 -0
- package/dist/features/aggregation/aggregationFeature.utils.js +192 -0
- package/dist/features/aggregation/aggregationFeature.utils.js.map +1 -0
- package/dist/features/aggregation/aggregationFns.cjs +240 -0
- package/dist/features/aggregation/aggregationFns.cjs.map +1 -0
- package/dist/features/aggregation/aggregationFns.d.cts +67 -0
- package/dist/features/aggregation/aggregationFns.d.ts +67 -0
- package/dist/features/aggregation/aggregationFns.js +229 -0
- package/dist/features/aggregation/aggregationFns.js.map +1 -0
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +43 -3
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +43 -3
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +18 -9
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +6 -2
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +6 -2
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +18 -9
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +7 -2
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +6 -2
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +6 -2
- package/dist/features/column-filtering/createFilteredRowModel.js +7 -2
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterFns.cjs +399 -0
- package/dist/features/column-filtering/filterFns.cjs.map +1 -0
- package/dist/features/column-filtering/filterFns.d.cts +210 -0
- package/dist/features/column-filtering/filterFns.d.ts +210 -0
- package/dist/features/column-filtering/filterFns.js +375 -0
- package/dist/features/column-filtering/filterFns.js.map +1 -0
- package/dist/features/column-grouping/columnGroupingFeature.cjs +3 -12
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.cts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +4 -13
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +6 -49
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +0 -50
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -39
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -39
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +2 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +23 -13
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +2 -3
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +2 -3
- package/dist/features/column-grouping/createGroupedRowModel.js +25 -15
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +4 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +2 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +2 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +4 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +6 -2
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +6 -2
- package/dist/features/row-sorting/createSortedRowModel.d.ts +6 -2
- package/dist/features/row-sorting/createSortedRowModel.js +6 -2
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +32 -3
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +32 -3
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +20 -5
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +20 -5
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/{fns → features/row-sorting}/sortFns.cjs +69 -22
- package/dist/features/row-sorting/sortFns.cjs.map +1 -0
- package/dist/features/row-sorting/sortFns.d.cts +98 -0
- package/dist/features/row-sorting/sortFns.d.ts +98 -0
- package/dist/{fns → features/row-sorting}/sortFns.js +69 -23
- package/dist/features/row-sorting/sortFns.js.map +1 -0
- package/dist/features/stockFeatures.cjs +2 -0
- package/dist/features/stockFeatures.cjs.map +1 -1
- package/dist/features/stockFeatures.d.cts +2 -0
- package/dist/features/stockFeatures.d.ts +2 -0
- package/dist/features/stockFeatures.js +2 -0
- package/dist/features/stockFeatures.js.map +1 -1
- package/dist/helpers/tableFeatures.cjs +5 -4
- package/dist/helpers/tableFeatures.cjs.map +1 -1
- package/dist/helpers/tableFeatures.d.cts +5 -4
- package/dist/helpers/tableFeatures.d.ts +5 -4
- package/dist/helpers/tableFeatures.js +5 -4
- package/dist/helpers/tableFeatures.js.map +1 -1
- package/dist/index.cjs +18 -3
- package/dist/index.d.cts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +6 -4
- package/dist/static-functions.cjs +8 -3
- package/dist/static-functions.d.cts +3 -2
- package/dist/static-functions.d.ts +3 -2
- package/dist/static-functions.js +3 -2
- package/dist/types/Cell.d.cts +3 -1
- package/dist/types/Cell.d.ts +3 -1
- package/dist/types/Column.d.cts +4 -2
- package/dist/types/Column.d.ts +4 -2
- package/dist/types/ColumnDef.d.cts +5 -3
- package/dist/types/ColumnDef.d.ts +5 -3
- package/dist/types/Row.d.cts +3 -1
- package/dist/types/Row.d.ts +3 -1
- package/dist/types/RowModel.d.cts +1 -1
- package/dist/types/RowModel.d.ts +1 -1
- package/dist/types/RowModelFns.d.cts +3 -3
- package/dist/types/RowModelFns.d.ts +3 -3
- package/dist/types/Table.d.cts +1 -1
- package/dist/types/Table.d.ts +1 -1
- package/dist/types/TableFeatures.d.cts +19 -11
- package/dist/types/TableFeatures.d.ts +19 -11
- package/dist/types/TableOptions.d.cts +5 -3
- package/dist/types/TableOptions.d.ts +5 -3
- package/dist/types/TableState.d.cts +1 -1
- package/dist/types/TableState.d.ts +1 -1
- package/dist/types/type-utils.d.cts +8 -1
- package/dist/types/type-utils.d.ts +8 -1
- package/dist/worker/initTableWorker.cjs.map +1 -1
- package/dist/worker/initTableWorker.js.map +1 -1
- package/package.json +1 -1
- package/skills/aggregation/SKILL.md +131 -0
- package/skills/api-not-found/SKILL.md +1 -1
- package/skills/client-vs-server/SKILL.md +1 -1
- package/skills/column-faceting/SKILL.md +11 -5
- package/skills/column-filtering/SKILL.md +8 -3
- package/skills/column-ordering/SKILL.md +1 -1
- package/skills/column-pinning/SKILL.md +1 -1
- package/skills/column-resizing/SKILL.md +1 -1
- package/skills/column-sizing/SKILL.md +1 -1
- package/skills/column-visibility/SKILL.md +1 -1
- package/skills/core/SKILL.md +1 -1
- package/skills/custom-features/SKILL.md +1 -1
- package/skills/expanding/SKILL.md +1 -1
- package/skills/global-filtering/SKILL.md +3 -3
- package/skills/grouping/SKILL.md +12 -13
- package/skills/migrate-v8-to-v9/SKILL.md +21 -8
- package/skills/pagination/SKILL.md +1 -1
- package/skills/row-pinning/SKILL.md +1 -1
- package/skills/row-selection/SKILL.md +1 -1
- package/skills/sorting/SKILL.md +9 -3
- package/skills/table-features/SKILL.md +19 -13
- package/skills/typescript/SKILL.md +1 -1
- package/src/core/row-models/coreRowModelsFeature.utils.ts +1 -1
- package/src/features/aggregation/aggregationFeature.ts +59 -0
- package/src/features/aggregation/aggregationFeature.types.ts +312 -0
- package/src/features/aggregation/aggregationFeature.utils.ts +401 -0
- package/src/features/aggregation/aggregationFns.ts +336 -0
- package/src/features/column-filtering/columnFilteringFeature.types.ts +61 -1
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +33 -19
- package/src/features/column-filtering/createFilteredRowModel.ts +13 -3
- package/src/features/column-filtering/filterFns.ts +533 -0
- package/src/features/column-grouping/columnGroupingFeature.ts +1 -20
- package/src/features/column-grouping/columnGroupingFeature.types.ts +4 -86
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +1 -88
- package/src/features/column-grouping/createGroupedRowModel.ts +32 -38
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +9 -1
- package/src/features/row-sorting/createSortedRowModel.ts +6 -2
- package/src/features/row-sorting/rowSortingFeature.types.ts +54 -2
- package/src/features/row-sorting/rowSortingFeature.utils.ts +46 -14
- package/src/{fns → features/row-sorting}/sortFns.ts +95 -81
- package/src/features/stockFeatures.ts +3 -0
- package/src/helpers/tableFeatures.ts +5 -4
- package/src/index.ts +7 -8
- package/src/static-functions.ts +1 -0
- package/src/types/Cell.ts +2 -0
- package/src/types/Column.ts +3 -1
- package/src/types/ColumnDef.ts +6 -3
- package/src/types/Row.ts +2 -0
- package/src/types/RowModelFns.ts +3 -3
- package/src/types/TableFeatures.ts +19 -11
- package/src/types/TableOptions.ts +5 -1
- package/src/types/type-utils.ts +8 -0
- package/src/worker/initTableWorker.ts +1 -1
- package/dist/fns/aggregationFns.cjs +0 -163
- package/dist/fns/aggregationFns.cjs.map +0 -1
- package/dist/fns/aggregationFns.d.cts +0 -85
- package/dist/fns/aggregationFns.d.ts +0 -85
- package/dist/fns/aggregationFns.js +0 -153
- package/dist/fns/aggregationFns.js.map +0 -1
- package/dist/fns/filterFns.cjs +0 -242
- package/dist/fns/filterFns.cjs.map +0 -1
- package/dist/fns/filterFns.d.cts +0 -178
- package/dist/fns/filterFns.d.ts +0 -178
- package/dist/fns/filterFns.js +0 -226
- package/dist/fns/filterFns.js.map +0 -1
- package/dist/fns/sortFns.cjs.map +0 -1
- package/dist/fns/sortFns.d.cts +0 -65
- package/dist/fns/sortFns.d.ts +0 -65
- package/dist/fns/sortFns.js.map +0 -1
- package/src/fns/aggregationFns.ts +0 -245
- package/src/fns/filterFns.ts +0 -455
|
@@ -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.48',
|
|
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.
|
|
@@ -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.
|
|
9
|
+
library_version: '9.0.0-beta.48',
|
|
10
10
|
}
|
|
11
11
|
requires: ['core', 'table-features', 'column-filtering']
|
|
12
12
|
sources:
|
|
@@ -27,14 +27,18 @@ import {
|
|
|
27
27
|
createFacetedRowModel,
|
|
28
28
|
createFacetedUniqueValues,
|
|
29
29
|
createFilteredRowModel,
|
|
30
|
-
|
|
30
|
+
filterFn_includesString,
|
|
31
|
+
filterFn_inNumberRange,
|
|
31
32
|
tableFeatures,
|
|
32
33
|
} from '@tanstack/table-core'
|
|
33
34
|
|
|
34
35
|
export const features = tableFeatures({
|
|
35
36
|
columnFilteringFeature,
|
|
36
37
|
filteredRowModel: createFilteredRowModel(),
|
|
37
|
-
filterFns
|
|
38
|
+
filterFns: {
|
|
39
|
+
includesString: filterFn_includesString,
|
|
40
|
+
inNumberRange: filterFn_inNumberRange,
|
|
41
|
+
},
|
|
38
42
|
columnFacetingFeature,
|
|
39
43
|
facetedRowModel: createFacetedRowModel(),
|
|
40
44
|
facetedUniqueValues: createFacetedUniqueValues(),
|
|
@@ -51,8 +55,10 @@ const range = table.getColumn('age')?.getFacetedMinMaxValues()
|
|
|
51
55
|
|
|
52
56
|
Use unique values for discrete controls and min/max only for numeric ranges.
|
|
53
57
|
The filtered model makes facets respond to the table's other active filters.
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
Register individually imported built-ins under their conventional keys so
|
|
59
|
+
columns can reference them by string name; a column may instead receive a
|
|
60
|
+
filter function directly without registering it. The full `filterFns` registry
|
|
61
|
+
object still works but bundles every built-in.
|
|
56
62
|
|
|
57
63
|
## Common Mistakes
|
|
58
64
|
|
|
@@ -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.
|
|
9
|
+
library_version: '9.0.0-beta.48',
|
|
10
10
|
}
|
|
11
11
|
requires: ['core', 'table-features', 'client-vs-server']
|
|
12
12
|
sources:
|
|
@@ -23,17 +23,22 @@ This skill builds on `core`, `table-features`, and `client-vs-server`. Filtering
|
|
|
23
23
|
import {
|
|
24
24
|
columnFilteringFeature,
|
|
25
25
|
createFilteredRowModel,
|
|
26
|
-
|
|
26
|
+
filterFn_includesString,
|
|
27
27
|
tableFeatures,
|
|
28
28
|
} from '@tanstack/table-core'
|
|
29
29
|
|
|
30
30
|
export const features = tableFeatures({
|
|
31
31
|
columnFilteringFeature,
|
|
32
32
|
filteredRowModel: createFilteredRowModel(),
|
|
33
|
-
filterFns,
|
|
33
|
+
filterFns: { includesString: filterFn_includesString },
|
|
34
34
|
})
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
Import individual `filterFn_*` built-ins and register only those your columns
|
|
38
|
+
reference by string name or that `filterFn: 'auto'` should resolve for your
|
|
39
|
+
data types. The full `filterFns` registry object still works but bundles every
|
|
40
|
+
built-in.
|
|
41
|
+
|
|
37
42
|
## Core Patterns
|
|
38
43
|
|
|
39
44
|
```ts
|
package/skills/core/SKILL.md
CHANGED
|
@@ -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.
|
|
8
|
+
library_version: '9.0.0-beta.48'
|
|
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.
|
|
9
|
+
library_version: '9.0.0-beta.48',
|
|
10
10
|
}
|
|
11
11
|
requires: ['core', 'table-features', 'client-vs-server', 'column-filtering']
|
|
12
12
|
sources:
|
|
@@ -23,7 +23,7 @@ This skill builds on `core`, `table-features`, `client-vs-server`, and `column-f
|
|
|
23
23
|
import {
|
|
24
24
|
columnFilteringFeature,
|
|
25
25
|
createFilteredRowModel,
|
|
26
|
-
|
|
26
|
+
filterFn_includesString,
|
|
27
27
|
globalFilteringFeature,
|
|
28
28
|
tableFeatures,
|
|
29
29
|
} from '@tanstack/table-core'
|
|
@@ -32,7 +32,7 @@ export const features = tableFeatures({
|
|
|
32
32
|
columnFilteringFeature,
|
|
33
33
|
globalFilteringFeature,
|
|
34
34
|
filteredRowModel: createFilteredRowModel(),
|
|
35
|
-
filterFns,
|
|
35
|
+
filterFns: { includesString: filterFn_includesString },
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
package/skills/grouping/SKILL.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: grouping
|
|
3
3
|
description: >
|
|
4
|
-
Group
|
|
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.
|
|
9
|
+
library_version: '9.0.0-beta.48',
|
|
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
|
|
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
|
-
aggregationFns,
|
|
25
24
|
columnGroupingFeature,
|
|
26
25
|
createGroupedRowModel,
|
|
27
26
|
tableFeatures,
|
|
@@ -30,7 +29,6 @@ import {
|
|
|
30
29
|
export const features = tableFeatures({
|
|
31
30
|
columnGroupingFeature,
|
|
32
31
|
groupedRowModel: createGroupedRowModel(),
|
|
33
|
-
aggregationFns,
|
|
34
32
|
})
|
|
35
33
|
```
|
|
36
34
|
|
|
@@ -40,11 +38,9 @@ export const features = tableFeatures({
|
|
|
40
38
|
const options = { groupedColumnMode: 'reorder' as const }
|
|
41
39
|
const mode = cell.getIsGrouped()
|
|
42
40
|
? 'grouped'
|
|
43
|
-
: cell.
|
|
44
|
-
? '
|
|
45
|
-
:
|
|
46
|
-
? 'placeholder'
|
|
47
|
-
: 'value'
|
|
41
|
+
: cell.getIsPlaceholder()
|
|
42
|
+
? 'placeholder'
|
|
43
|
+
: 'value'
|
|
48
44
|
```
|
|
49
45
|
|
|
50
46
|
Render these cell modes deliberately.
|
|
@@ -57,7 +53,7 @@ Wrong: `tableFeatures({ groupedRowModel: createGroupedRowModel() })`
|
|
|
57
53
|
|
|
58
54
|
Correct: `tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel() })`
|
|
59
55
|
|
|
60
|
-
The grouped slot
|
|
56
|
+
The grouped row-model slot requires `columnGroupingFeature`.
|
|
61
57
|
|
|
62
58
|
Source: `packages/table-core/src/types/TableFeatures.ts#FeatureSlotPrereqs`
|
|
63
59
|
|
|
@@ -90,10 +86,13 @@ Wrong: `render(cell.getValue())`
|
|
|
90
86
|
|
|
91
87
|
Correct: `render(cell.getIsPlaceholder() ? null : cell.getValue())`
|
|
92
88
|
|
|
93
|
-
Placeholder
|
|
89
|
+
Placeholder cells do not represent ordinary leaf values. Group rows should
|
|
90
|
+
only render their grouped cell when aggregation is not enabled.
|
|
94
91
|
|
|
95
92
|
Source: `examples/react/grouping/src/main.tsx`
|
|
96
93
|
|
|
97
94
|
## API Discovery
|
|
98
95
|
|
|
99
|
-
Inspect `node_modules/@tanstack/table-core/src/features/column-grouping/`
|
|
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.
|
|
8
|
+
library_version: '9.0.0-beta.48'
|
|
9
9
|
requires: ['core', 'table-features', 'typescript']
|
|
10
10
|
sources:
|
|
11
11
|
- 'TanStack/table:docs/framework/react/guide/migrating.md'
|
|
@@ -42,9 +42,9 @@ import {
|
|
|
42
42
|
createFilteredRowModel,
|
|
43
43
|
createSortedRowModel,
|
|
44
44
|
columnFilteringFeature,
|
|
45
|
-
|
|
45
|
+
filterFn_includesString,
|
|
46
46
|
rowSortingFeature,
|
|
47
|
-
|
|
47
|
+
sortFn_alphanumeric,
|
|
48
48
|
tableFeatures,
|
|
49
49
|
} from '@tanstack/table-core'
|
|
50
50
|
|
|
@@ -53,8 +53,8 @@ export const features = tableFeatures({
|
|
|
53
53
|
rowSortingFeature,
|
|
54
54
|
filteredRowModel: createFilteredRowModel(),
|
|
55
55
|
sortedRowModel: createSortedRowModel(),
|
|
56
|
-
filterFns,
|
|
57
|
-
sortFns,
|
|
56
|
+
filterFns: { includesString: filterFn_includesString },
|
|
57
|
+
sortFns: { alphanumeric: sortFn_alphanumeric },
|
|
58
58
|
})
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -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
|
-
|
|
|
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
|
|
@@ -118,7 +120,17 @@ Move registries from table options or factory arguments into these feature slots
|
|
|
118
120
|
| `filterFns` | `filterFns` |
|
|
119
121
|
| `aggregationFns` | `aggregationFns` |
|
|
120
122
|
|
|
121
|
-
Register built-ins
|
|
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.
|
|
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`.
|
|
122
134
|
|
|
123
135
|
### 3. Migrate state reads and whole-state observation
|
|
124
136
|
|
|
@@ -279,7 +291,8 @@ Do not confuse new capabilities with required breakages. After the table works,
|
|
|
279
291
|
- [ ] Remove `getCoreRowModel()` unless supplying a deliberate custom `coreRowModel` slot.
|
|
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
|
-
- [ ] Move `filterFns`, `sortingFns`/`sortFns`, and `aggregationFns` into feature slots; pass no registries to factories.
|
|
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.
|
package/skills/sorting/SKILL.md
CHANGED
|
@@ -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.
|
|
9
|
+
library_version: '9.0.0-beta.48',
|
|
10
10
|
}
|
|
11
11
|
requires: ['core', 'table-features', 'client-vs-server']
|
|
12
12
|
sources:
|
|
@@ -23,17 +23,23 @@ This skill builds on `core`, `table-features`, and `client-vs-server`. Sorting s
|
|
|
23
23
|
import {
|
|
24
24
|
createSortedRowModel,
|
|
25
25
|
rowSortingFeature,
|
|
26
|
-
|
|
26
|
+
sortFn_alphanumeric,
|
|
27
|
+
sortFn_text,
|
|
27
28
|
tableFeatures,
|
|
28
29
|
} from '@tanstack/table-core'
|
|
29
30
|
|
|
30
31
|
export const features = tableFeatures({
|
|
31
32
|
rowSortingFeature,
|
|
32
33
|
sortedRowModel: createSortedRowModel(),
|
|
33
|
-
sortFns,
|
|
34
|
+
sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text },
|
|
34
35
|
})
|
|
35
36
|
```
|
|
36
37
|
|
|
38
|
+
Import individual `sortFn_*` built-ins and register only those your columns
|
|
39
|
+
reference by string name or that `sortFn: 'auto'` should resolve for your data
|
|
40
|
+
types. The full `sortFns` registry object still works but bundles every
|
|
41
|
+
built-in; numeric columns fall back to a basic comparator without registration.
|
|
42
|
+
|
|
37
43
|
## Core Patterns
|
|
38
44
|
|
|
39
45
|
```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.
|
|
8
|
+
library_version: '9.0.0-beta.48'
|
|
9
9
|
requires: ['core']
|
|
10
10
|
sources:
|
|
11
11
|
- 'TanStack/table:docs/guide/row-models.md'
|
|
@@ -22,26 +22,28 @@ This skill builds on `core`. Read it first for the headless model and stable inp
|
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import {
|
|
25
|
-
|
|
25
|
+
aggregationFeature,
|
|
26
|
+
aggregationFn_sum,
|
|
26
27
|
columnGroupingFeature,
|
|
27
28
|
createFilteredRowModel,
|
|
28
29
|
createSortedRowModel,
|
|
29
30
|
columnFilteringFeature,
|
|
30
|
-
|
|
31
|
+
filterFn_includesString,
|
|
31
32
|
rowSortingFeature,
|
|
32
|
-
|
|
33
|
+
sortFn_alphanumeric,
|
|
33
34
|
tableFeatures,
|
|
34
35
|
} from '@tanstack/table-core'
|
|
35
36
|
|
|
36
37
|
export const features = tableFeatures({
|
|
37
38
|
columnFilteringFeature,
|
|
38
39
|
filteredRowModel: createFilteredRowModel(),
|
|
39
|
-
filterFns,
|
|
40
|
+
filterFns: { includesString: filterFn_includesString },
|
|
41
|
+
aggregationFeature,
|
|
40
42
|
columnGroupingFeature,
|
|
41
|
-
aggregationFns,
|
|
43
|
+
aggregationFns: { sum: aggregationFn_sum },
|
|
42
44
|
rowSortingFeature,
|
|
43
45
|
sortedRowModel: createSortedRowModel(),
|
|
44
|
-
sortFns,
|
|
46
|
+
sortFns: { alphanumeric: sortFn_alphanumeric },
|
|
45
47
|
})
|
|
46
48
|
```
|
|
47
49
|
|
|
@@ -63,19 +65,23 @@ const features = tableFeatures({
|
|
|
63
65
|
```ts
|
|
64
66
|
const features = tableFeatures({
|
|
65
67
|
columnFilteringFeature,
|
|
66
|
-
filterFns,
|
|
68
|
+
filterFns: { includesString: filterFn_includesString },
|
|
67
69
|
rowSortingFeature,
|
|
68
|
-
sortFns,
|
|
70
|
+
sortFns: { alphanumeric: sortFn_alphanumeric },
|
|
71
|
+
aggregationFeature,
|
|
69
72
|
columnGroupingFeature,
|
|
70
|
-
aggregationFns,
|
|
73
|
+
aggregationFns: { sum: aggregationFn_sum },
|
|
71
74
|
})
|
|
72
75
|
```
|
|
73
76
|
|
|
74
77
|
`filterFns`, `sortFns`, and `aggregationFns` are feature slots, not table
|
|
75
78
|
options. They respectively require `columnFilteringFeature`,
|
|
76
|
-
`rowSortingFeature`, and `
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
`rowSortingFeature`, and `aggregationFeature`. Import individual built-ins
|
|
80
|
+
(`filterFn_*`, `sortFn_*`, `aggregationFn_*`) and register them under their
|
|
81
|
+
conventional keys; the full registry objects (`filterFns`, `sortFns`,
|
|
82
|
+
`aggregationFns` exports) still work but bundle every built-in. A registered
|
|
83
|
+
key can be used as a typed string name, and `'auto'` resolves only registered
|
|
84
|
+
functions; pass a function directly when no registry name is needed.
|
|
79
85
|
|
|
80
86
|
### Prefer explicit features
|
|
81
87
|
|
|
@@ -92,7 +92,7 @@ export function table_getPreGroupedRowModel<
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Resolves the row model after grouping has produced grouped
|
|
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.
|