@tanstack/table-core 9.0.0-beta.47 → 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 +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +1 -1
- package/dist/{fns → features/column-filtering}/filterFns.cjs +1 -1
- package/dist/features/column-filtering/filterFns.cjs.map +1 -0
- package/dist/{fns → features/column-filtering}/filterFns.d.cts +4 -4
- package/dist/{fns → features/column-filtering}/filterFns.d.ts +4 -4
- package/dist/{fns → features/column-filtering}/filterFns.js +1 -1
- 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 -87
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -87
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +0 -64
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -44
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -44
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +2 -63
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +23 -16
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +2 -6
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +2 -6
- package/dist/features/column-grouping/createGroupedRowModel.js +25 -18
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/{fns → features/row-sorting}/sortFns.cjs +1 -1
- package/dist/{fns/sortFns.js.map → features/row-sorting/sortFns.cjs.map} +1 -1
- package/dist/{fns → features/row-sorting}/sortFns.d.cts +4 -4
- package/dist/{fns → features/row-sorting}/sortFns.d.ts +4 -4
- package/dist/{fns → features/row-sorting}/sortFns.js +1 -1
- 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/index.cjs +7 -4
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- 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 +4 -4
- package/dist/types/TableFeatures.d.ts +4 -4
- 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/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 +1 -1
- package/skills/column-filtering/SKILL.md +1 -1
- 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 +1 -1
- package/skills/grouping/SKILL.md +12 -18
- package/skills/migrate-v8-to-v9/SKILL.md +15 -2
- 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 +1 -1
- package/skills/table-features/SKILL.md +5 -2
- 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 +1 -1
- package/src/{fns → features/column-filtering}/filterFns.ts +4 -4
- package/src/features/column-grouping/columnGroupingFeature.ts +1 -20
- package/src/features/column-grouping/columnGroupingFeature.types.ts +4 -141
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +1 -122
- package/src/features/column-grouping/createGroupedRowModel.ts +32 -41
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +1 -1
- package/src/features/row-sorting/rowSortingFeature.types.ts +1 -1
- package/src/features/row-sorting/rowSortingFeature.utils.ts +1 -1
- package/src/{fns → features/row-sorting}/sortFns.ts +4 -7
- package/src/features/stockFeatures.ts +3 -0
- 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 +4 -4
- package/src/types/TableOptions.ts +5 -1
- package/src/worker/initTableWorker.ts +1 -1
- package/dist/fns/aggregationFns.cjs +0 -234
- package/dist/fns/aggregationFns.cjs.map +0 -1
- package/dist/fns/aggregationFns.d.cts +0 -139
- package/dist/fns/aggregationFns.d.ts +0 -139
- package/dist/fns/aggregationFns.js +0 -221
- package/dist/fns/aggregationFns.js.map +0 -1
- package/dist/fns/filterFns.cjs.map +0 -1
- package/dist/fns/filterFns.js.map +0 -1
- package/dist/fns/sortFns.cjs.map +0 -1
- package/src/fns/aggregationFns.ts +0 -303
|
@@ -2,7 +2,7 @@ import { CellData, RowData, UnionToIntersection } from "./type-utils.js";
|
|
|
2
2
|
import { CoreFeatures } from "../core/coreFeatures.js";
|
|
3
3
|
import { SortFn } from "../features/row-sorting/rowSortingFeature.types.js";
|
|
4
4
|
import { ColumnDefBase_All } from "./ColumnDef.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AggregationFnDef } from "../features/aggregation/aggregationFeature.types.js";
|
|
6
6
|
import { Row } from "./Row.js";
|
|
7
7
|
import { FilterFn } from "../features/column-filtering/columnFilteringFeature.types.js";
|
|
8
8
|
import { RowModel } from "../core/row-models/coreRowModelsFeature.types.js";
|
|
@@ -61,9 +61,9 @@ type NonFeatureKeys = 'aggregationFns' | 'columnMeta' | 'coreRowModel' | 'expand
|
|
|
61
61
|
*/
|
|
62
62
|
interface FeatureSlotPrereqs {
|
|
63
63
|
/**
|
|
64
|
-
* Named aggregation functions
|
|
64
|
+
* Named aggregation functions require the independent aggregation feature.
|
|
65
65
|
*/
|
|
66
|
-
aggregationFns: '
|
|
66
|
+
aggregationFns: 'aggregationFeature';
|
|
67
67
|
/**
|
|
68
68
|
* Column resizing builds on the column sizing state and APIs.
|
|
69
69
|
*/
|
|
@@ -146,7 +146,7 @@ interface TableFeatures extends Partial<CoreFeatures>, Partial<StockFeatures>, P
|
|
|
146
146
|
* Spreading the exported `aggregationFns` registry also works, but puts
|
|
147
147
|
* every built-in aggregation function in your bundle.
|
|
148
148
|
*/
|
|
149
|
-
aggregationFns?: Record<string,
|
|
149
|
+
aggregationFns?: Record<string, AggregationFnDef<any, any, any, any>>;
|
|
150
150
|
/**
|
|
151
151
|
* Type-only slot for declaring the type of `columnDef.meta` for all columns
|
|
152
152
|
* of this table.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { RowData, UnionToIntersection } from "./type-utils.cjs";
|
|
2
2
|
import { CoreFeatures } from "../core/coreFeatures.cjs";
|
|
3
|
+
import { TableOptions_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.cjs";
|
|
3
4
|
import { TableOptions_Cell } from "../core/cells/coreCellsFeature.types.cjs";
|
|
4
5
|
import { TableOptions_ColumnPinning } from "../features/column-pinning/columnPinningFeature.types.cjs";
|
|
5
6
|
import { TableOptions_ColumnSizing } from "../features/column-sizing/columnSizingFeature.types.cjs";
|
|
6
7
|
import { TableOptions_ColumnResizing } from "../features/column-resizing/columnResizingFeature.types.cjs";
|
|
7
8
|
import { TableOptions_GlobalFiltering } from "../features/global-filtering/globalFilteringFeature.types.cjs";
|
|
8
9
|
import { TableOptions_RowSorting } from "../features/row-sorting/rowSortingFeature.types.cjs";
|
|
9
|
-
import {
|
|
10
|
+
import { TableOptions_Aggregation } from "../features/aggregation/aggregationFeature.types.cjs";
|
|
10
11
|
import { TableOptions_ColumnVisibility } from "../features/column-visibility/columnVisibilityFeature.types.cjs";
|
|
11
12
|
import { TableOptions_RowExpanding } from "../features/row-expanding/rowExpandingFeature.types.cjs";
|
|
12
13
|
import { TableOptions_RowPinning } from "../features/row-pinning/rowPinningFeature.types.cjs";
|
|
@@ -36,6 +37,7 @@ type DebugOptions<TFeatures extends TableFeatures> = {
|
|
|
36
37
|
debugTable?: boolean;
|
|
37
38
|
} & DebugKeysFor<CoreFeatures & TFeatures>;
|
|
38
39
|
interface TableOptions_FeatureMap<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
40
|
+
aggregationFeature: TableOptions_Aggregation;
|
|
39
41
|
columnFilteringFeature: TableOptions_ColumnFiltering<TFeatures, TData>;
|
|
40
42
|
columnGroupingFeature: TableOptions_ColumnGrouping;
|
|
41
43
|
columnOrderingFeature: TableOptions_ColumnOrdering;
|
|
@@ -50,7 +52,7 @@ interface TableOptions_FeatureMap<in out TFeatures extends TableFeatures, in out
|
|
|
50
52
|
rowSelectionFeature: TableOptions_RowSelection<TFeatures, TData>;
|
|
51
53
|
rowSortingFeature: TableOptions_RowSorting;
|
|
52
54
|
}
|
|
53
|
-
type TableOptions_StockFeatureKeys = 'columnFilteringFeature' | 'columnGroupingFeature' | 'columnOrderingFeature' | 'columnPinningFeature' | 'columnResizingFeature' | 'columnSizingFeature' | 'columnVisibilityFeature' | 'globalFilteringFeature' | 'rowExpandingFeature' | 'rowPaginationFeature' | 'rowPinningFeature' | 'rowSelectionFeature' | 'rowSortingFeature';
|
|
55
|
+
type TableOptions_StockFeatureKeys = 'aggregationFeature' | 'columnFilteringFeature' | 'columnGroupingFeature' | 'columnOrderingFeature' | 'columnPinningFeature' | 'columnResizingFeature' | 'columnSizingFeature' | 'columnVisibilityFeature' | 'globalFilteringFeature' | 'rowExpandingFeature' | 'rowPaginationFeature' | 'rowPinningFeature' | 'rowSelectionFeature' | 'rowSortingFeature';
|
|
54
56
|
/**
|
|
55
57
|
* Plugin entries declaration-merged into `TableOptions_FeatureMap`, i.e. keys
|
|
56
58
|
* beyond the stock set. Resolves to `unknown` (an intersection no-op) when no
|
|
@@ -69,7 +71,7 @@ type TableOptions<TFeatures extends TableFeatures, TData extends RowData> = Tabl
|
|
|
69
71
|
* Internal broad option shape used where feature code may need to read options
|
|
70
72
|
* from features that are not present in the current generic feature set.
|
|
71
73
|
*/
|
|
72
|
-
type TableOptions_All<TFeatures extends TableFeatures, TData extends RowData> = TableOptions_Core<TFeatures, TData> & Partial<TableOptions_ColumnFiltering<TFeatures, TData> & TableOptions_ColumnGrouping & TableOptions_ColumnOrdering & TableOptions_ColumnPinning & TableOptions_ColumnResizing & TableOptions_ColumnSizing & TableOptions_ColumnVisibility & TableOptions_GlobalFiltering<TFeatures, TData> & TableOptions_RowExpanding<TFeatures, TData> & TableOptions_RowPagination & TableOptions_RowPinning<TFeatures, TData> & TableOptions_RowSelection<TFeatures, TData> & TableOptions_RowSorting & TableOptions_PluginFeatureMapTypes<TFeatures, TData>>;
|
|
74
|
+
type TableOptions_All<TFeatures extends TableFeatures, TData extends RowData> = TableOptions_Core<TFeatures, TData> & Partial<TableOptions_Aggregation & TableOptions_ColumnFiltering<TFeatures, TData> & TableOptions_ColumnGrouping & TableOptions_ColumnOrdering & TableOptions_ColumnPinning & TableOptions_ColumnResizing & TableOptions_ColumnSizing & TableOptions_ColumnVisibility & TableOptions_GlobalFiltering<TFeatures, TData> & TableOptions_RowExpanding<TFeatures, TData> & TableOptions_RowPagination & TableOptions_RowPinning<TFeatures, TData> & TableOptions_RowSelection<TFeatures, TData> & TableOptions_RowSorting & TableOptions_PluginFeatureMapTypes<TFeatures, TData>>;
|
|
73
75
|
//#endregion
|
|
74
76
|
export { DebugOptions, TableOptions, TableOptions_All, TableOptions_Core, TableOptions_FeatureMap };
|
|
75
77
|
//# sourceMappingURL=TableOptions.d.cts.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { RowData, UnionToIntersection } from "./type-utils.js";
|
|
2
2
|
import { CoreFeatures } from "../core/coreFeatures.js";
|
|
3
|
+
import { TableOptions_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.js";
|
|
3
4
|
import { TableOptions_Cell } from "../core/cells/coreCellsFeature.types.js";
|
|
4
5
|
import { TableOptions_ColumnPinning } from "../features/column-pinning/columnPinningFeature.types.js";
|
|
5
6
|
import { TableOptions_ColumnSizing } from "../features/column-sizing/columnSizingFeature.types.js";
|
|
6
7
|
import { TableOptions_ColumnResizing } from "../features/column-resizing/columnResizingFeature.types.js";
|
|
7
8
|
import { TableOptions_GlobalFiltering } from "../features/global-filtering/globalFilteringFeature.types.js";
|
|
8
9
|
import { TableOptions_RowSorting } from "../features/row-sorting/rowSortingFeature.types.js";
|
|
9
|
-
import {
|
|
10
|
+
import { TableOptions_Aggregation } from "../features/aggregation/aggregationFeature.types.js";
|
|
10
11
|
import { TableOptions_ColumnVisibility } from "../features/column-visibility/columnVisibilityFeature.types.js";
|
|
11
12
|
import { TableOptions_RowExpanding } from "../features/row-expanding/rowExpandingFeature.types.js";
|
|
12
13
|
import { TableOptions_RowPinning } from "../features/row-pinning/rowPinningFeature.types.js";
|
|
@@ -36,6 +37,7 @@ type DebugOptions<TFeatures extends TableFeatures> = {
|
|
|
36
37
|
debugTable?: boolean;
|
|
37
38
|
} & DebugKeysFor<CoreFeatures & TFeatures>;
|
|
38
39
|
interface TableOptions_FeatureMap<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
40
|
+
aggregationFeature: TableOptions_Aggregation;
|
|
39
41
|
columnFilteringFeature: TableOptions_ColumnFiltering<TFeatures, TData>;
|
|
40
42
|
columnGroupingFeature: TableOptions_ColumnGrouping;
|
|
41
43
|
columnOrderingFeature: TableOptions_ColumnOrdering;
|
|
@@ -50,7 +52,7 @@ interface TableOptions_FeatureMap<in out TFeatures extends TableFeatures, in out
|
|
|
50
52
|
rowSelectionFeature: TableOptions_RowSelection<TFeatures, TData>;
|
|
51
53
|
rowSortingFeature: TableOptions_RowSorting;
|
|
52
54
|
}
|
|
53
|
-
type TableOptions_StockFeatureKeys = 'columnFilteringFeature' | 'columnGroupingFeature' | 'columnOrderingFeature' | 'columnPinningFeature' | 'columnResizingFeature' | 'columnSizingFeature' | 'columnVisibilityFeature' | 'globalFilteringFeature' | 'rowExpandingFeature' | 'rowPaginationFeature' | 'rowPinningFeature' | 'rowSelectionFeature' | 'rowSortingFeature';
|
|
55
|
+
type TableOptions_StockFeatureKeys = 'aggregationFeature' | 'columnFilteringFeature' | 'columnGroupingFeature' | 'columnOrderingFeature' | 'columnPinningFeature' | 'columnResizingFeature' | 'columnSizingFeature' | 'columnVisibilityFeature' | 'globalFilteringFeature' | 'rowExpandingFeature' | 'rowPaginationFeature' | 'rowPinningFeature' | 'rowSelectionFeature' | 'rowSortingFeature';
|
|
54
56
|
/**
|
|
55
57
|
* Plugin entries declaration-merged into `TableOptions_FeatureMap`, i.e. keys
|
|
56
58
|
* beyond the stock set. Resolves to `unknown` (an intersection no-op) when no
|
|
@@ -69,7 +71,7 @@ type TableOptions<TFeatures extends TableFeatures, TData extends RowData> = Tabl
|
|
|
69
71
|
* Internal broad option shape used where feature code may need to read options
|
|
70
72
|
* from features that are not present in the current generic feature set.
|
|
71
73
|
*/
|
|
72
|
-
type TableOptions_All<TFeatures extends TableFeatures, TData extends RowData> = TableOptions_Core<TFeatures, TData> & Partial<TableOptions_ColumnFiltering<TFeatures, TData> & TableOptions_ColumnGrouping & TableOptions_ColumnOrdering & TableOptions_ColumnPinning & TableOptions_ColumnResizing & TableOptions_ColumnSizing & TableOptions_ColumnVisibility & TableOptions_GlobalFiltering<TFeatures, TData> & TableOptions_RowExpanding<TFeatures, TData> & TableOptions_RowPagination & TableOptions_RowPinning<TFeatures, TData> & TableOptions_RowSelection<TFeatures, TData> & TableOptions_RowSorting & TableOptions_PluginFeatureMapTypes<TFeatures, TData>>;
|
|
74
|
+
type TableOptions_All<TFeatures extends TableFeatures, TData extends RowData> = TableOptions_Core<TFeatures, TData> & Partial<TableOptions_Aggregation & TableOptions_ColumnFiltering<TFeatures, TData> & TableOptions_ColumnGrouping & TableOptions_ColumnOrdering & TableOptions_ColumnPinning & TableOptions_ColumnResizing & TableOptions_ColumnSizing & TableOptions_ColumnVisibility & TableOptions_GlobalFiltering<TFeatures, TData> & TableOptions_RowExpanding<TFeatures, TData> & TableOptions_RowPagination & TableOptions_RowPinning<TFeatures, TData> & TableOptions_RowSelection<TFeatures, TData> & TableOptions_RowSorting & TableOptions_PluginFeatureMapTypes<TFeatures, TData>>;
|
|
73
75
|
//#endregion
|
|
74
76
|
export { DebugOptions, TableOptions, TableOptions_All, TableOptions_Core, TableOptions_FeatureMap };
|
|
75
77
|
//# sourceMappingURL=TableOptions.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { TableState_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.cjs";
|
|
1
2
|
import { TableState_ColumnPinning } from "../features/column-pinning/columnPinningFeature.types.cjs";
|
|
2
3
|
import { TableState_ColumnSizing } from "../features/column-sizing/columnSizingFeature.types.cjs";
|
|
3
4
|
import { TableState_ColumnResizing } from "../features/column-resizing/columnResizingFeature.types.cjs";
|
|
4
5
|
import { TableState_GlobalFiltering } from "../features/global-filtering/globalFilteringFeature.types.cjs";
|
|
5
6
|
import { TableState_RowSorting } from "../features/row-sorting/rowSortingFeature.types.cjs";
|
|
6
|
-
import { TableState_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.cjs";
|
|
7
7
|
import { TableState_ColumnVisibility } from "../features/column-visibility/columnVisibilityFeature.types.cjs";
|
|
8
8
|
import { TableState_RowExpanding } from "../features/row-expanding/rowExpandingFeature.types.cjs";
|
|
9
9
|
import { TableState_RowPinning } from "../features/row-pinning/rowPinningFeature.types.cjs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { TableState_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.js";
|
|
1
2
|
import { TableState_ColumnPinning } from "../features/column-pinning/columnPinningFeature.types.js";
|
|
2
3
|
import { TableState_ColumnSizing } from "../features/column-sizing/columnSizingFeature.types.js";
|
|
3
4
|
import { TableState_ColumnResizing } from "../features/column-resizing/columnResizingFeature.types.js";
|
|
4
5
|
import { TableState_GlobalFiltering } from "../features/global-filtering/globalFilteringFeature.types.js";
|
|
5
6
|
import { TableState_RowSorting } from "../features/row-sorting/rowSortingFeature.types.js";
|
|
6
|
-
import { TableState_ColumnGrouping } from "../features/column-grouping/columnGroupingFeature.types.js";
|
|
7
7
|
import { TableState_ColumnVisibility } from "../features/column-visibility/columnVisibilityFeature.types.js";
|
|
8
8
|
import { TableState_RowExpanding } from "../features/row-expanding/rowExpandingFeature.types.js";
|
|
9
9
|
import { TableState_RowPinning } from "../features/row-pinning/rowPinningFeature.types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initTableWorker.cjs","names":["makeObjectMap","constructTable","storeReactivityBindings","serializeRowModel"],"sources":["../../src/worker/initTableWorker.ts"],"sourcesContent":["import { constructTable } from '../core/table/constructTable'\nimport { storeReactivityBindings } from '../store-reactivity-bindings'\nimport { makeObjectMap } from '../utils'\nimport { serializeRowModel } from './serializeRowModel'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { TableOptions } from '../types/TableOptions'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRequest,\n TableWorkerResult,\n TableWorkerStage,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\nexport type TableWorkerConfig<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Omit<TableOptions<TFeatures, TData>, 'data'>\n\nfunction capitalize(stage: string) {\n return stage.charAt(0).toUpperCase() + stage.slice(1)\n}\n\n/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */\nfunction flattenColumnDefs(defs: Array<any>): Array<any> {\n return defs.flatMap((def) =>\n def.columns ? flattenColumnDefs(def.columns) : [def],\n )\n}\n\n/**\n * Runs a headless \"shadow table\" inside a dedicated Web Worker.\n *\n * Call this from a user-authored worker entry file, passing the same columns\n * and processing features used on the main thread. The shadow table runs the\n * real table-core row model pipeline (real fns, real Row objects) off the\n * main thread and posts back one payload per stage the main thread requested:\n * a transferable index permutation for flat results, a serialized row tree\n * (with eagerly computed aggregates) when grouping produces synthetic rows.\n *\n * Everything passed here must be thread-portable: `accessorKey` columns or\n * accessors defined in a shared module, and fns from registries or shared\n * modules (no closures over app state).\n *\n * @example\n * ```ts\n * // table.worker.ts\n * import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'\n * import { columns, sharedFeatures } from './tableConfig'\n *\n * initTableWorker({ features: sharedFeatures, columns })\n * ```\n */\nexport function initTableWorker<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(config: TableWorkerConfig<TFeatures, TData>): void {\n let table: Table_Internal<TFeatures, TData> | undefined\n let dataVersion = 0\n let coreIndexById: Record<string, number> = makeObjectMap()\n let aggregateColumnIds: Array<string> = []\n // Last-sent model identity per stage: the memoized getters return stable\n // objects when their inputs did not change, so identity equality is exactly\n // \"this stage's result is unchanged\".\n let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}\n\n self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {\n const message = event.data\n\n if (message.type === 'data') {\n dataVersion = message.dataVersion\n lastSentModels = {}\n if (!table) {\n table = constructTable<TFeatures, TData>({\n ...(config as TableOptions<TFeatures, TData>),\n features: {\n coreReactivityFeature: storeReactivityBindings(),\n ...config.features,\n },\n data: message.data,\n })\n // Only columns with an explicit aggregation get eagerly aggregated\n // per group. Sync tables aggregate lazily (visible cells only), so\n // auto-aggregating every column would explode on high-cardinality\n // grouping for values nothing renders. Read the RAW column defs:\n //
|
|
1
|
+
{"version":3,"file":"initTableWorker.cjs","names":["makeObjectMap","constructTable","storeReactivityBindings","serializeRowModel"],"sources":["../../src/worker/initTableWorker.ts"],"sourcesContent":["import { constructTable } from '../core/table/constructTable'\nimport { storeReactivityBindings } from '../store-reactivity-bindings'\nimport { makeObjectMap } from '../utils'\nimport { serializeRowModel } from './serializeRowModel'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { TableOptions } from '../types/TableOptions'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRequest,\n TableWorkerResult,\n TableWorkerStage,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\nexport type TableWorkerConfig<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Omit<TableOptions<TFeatures, TData>, 'data'>\n\nfunction capitalize(stage: string) {\n return stage.charAt(0).toUpperCase() + stage.slice(1)\n}\n\n/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */\nfunction flattenColumnDefs(defs: Array<any>): Array<any> {\n return defs.flatMap((def) =>\n def.columns ? flattenColumnDefs(def.columns) : [def],\n )\n}\n\n/**\n * Runs a headless \"shadow table\" inside a dedicated Web Worker.\n *\n * Call this from a user-authored worker entry file, passing the same columns\n * and processing features used on the main thread. The shadow table runs the\n * real table-core row model pipeline (real fns, real Row objects) off the\n * main thread and posts back one payload per stage the main thread requested:\n * a transferable index permutation for flat results, a serialized row tree\n * (with eagerly computed aggregates) when grouping produces synthetic rows.\n *\n * Everything passed here must be thread-portable: `accessorKey` columns or\n * accessors defined in a shared module, and fns from registries or shared\n * modules (no closures over app state).\n *\n * @example\n * ```ts\n * // table.worker.ts\n * import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'\n * import { columns, sharedFeatures } from './tableConfig'\n *\n * initTableWorker({ features: sharedFeatures, columns })\n * ```\n */\nexport function initTableWorker<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(config: TableWorkerConfig<TFeatures, TData>): void {\n let table: Table_Internal<TFeatures, TData> | undefined\n let dataVersion = 0\n let coreIndexById: Record<string, number> = makeObjectMap()\n let aggregateColumnIds: Array<string> = []\n // Last-sent model identity per stage: the memoized getters return stable\n // objects when their inputs did not change, so identity equality is exactly\n // \"this stage's result is unchanged\".\n let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}\n\n self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {\n const message = event.data\n\n if (message.type === 'data') {\n dataVersion = message.dataVersion\n lastSentModels = {}\n if (!table) {\n table = constructTable<TFeatures, TData>({\n ...(config as TableOptions<TFeatures, TData>),\n features: {\n coreReactivityFeature: storeReactivityBindings(),\n ...config.features,\n },\n data: message.data,\n })\n // Only columns with an explicit aggregation get eagerly aggregated\n // per group. Sync tables aggregate lazily (visible cells only), so\n // auto-aggregating every column would explode on high-cardinality\n // grouping for values nothing renders. Read the RAW column defs:\n // aggregationFeature injects default aggregatedCell/aggregationFn\n // into every resolved columnDef, so the resolved defs can't tell\n // explicit from default.\n aggregateColumnIds = flattenColumnDefs(config.columns as Array<any>)\n .filter(\n (def) => def.aggregationFn != null || def.aggregatedCell != null,\n )\n .map(\n (def) =>\n def.id ??\n (typeof def.accessorKey === 'string'\n ? def.accessorKey.replaceAll('.', '_')\n : undefined),\n )\n .filter((id): id is string => id != null)\n } else {\n table.setOptions((prev) => ({ ...prev, data: message.data }))\n }\n // Map row ids to data positions once per dataset; serialization uses it\n // to express every stage result in terms of core row positions.\n const coreFlatRows = table.getCoreRowModel().flatRows\n coreIndexById = makeObjectMap()\n for (let i = 0; i < coreFlatRows.length; i++) {\n coreIndexById[coreFlatRows[i]!.id] = i\n }\n return\n }\n\n if (!table) return\n\n const start = performance.now()\n\n // Apply the serializable state slices to the shadow table's base atoms.\n table._reactivity.batch(() => {\n for (const [key, value] of Object.entries(message.state)) {\n const baseAtom = (table!.baseAtoms as Record<string, any>)[key]\n if (baseAtom && value !== undefined) {\n baseAtom.set(value)\n }\n }\n })\n\n // Compute exactly the stages the main thread requested, skipping any this\n // shadow table has no row model factory for (the main thread warns).\n const stages: { [K in TableWorkerStage]?: TableWorkerStagePayload } = {}\n const transfer: Array<Transferable> = []\n\n for (const stage of message.stages) {\n if (!(config.features as Record<string, unknown>)[`${stage}RowModel`]) {\n continue\n }\n const model = (table as any)[`get${capitalize(stage)}RowModel`]()\n // Memoized getters return the same object when inputs are unchanged;\n // skip re-serializing (and the main thread skips rebuilding). Safe under\n // single-flight: results are never dropped within a dataVersion.\n if (lastSentModels[stage] === model) {\n stages[stage] = { kind: 'unchanged' }\n continue\n }\n lastSentModels[stage] = model\n stages[stage] = serializeRowModel(\n model,\n coreIndexById,\n aggregateColumnIds,\n transfer,\n )\n }\n\n const response: TableWorkerResult = {\n type: 'result',\n requestId: message.requestId,\n dataVersion,\n stages,\n computeMs: performance.now() - start,\n }\n postMessage(response, { transfer })\n }\n}\n"],"mappings":";;;;;;AAoBA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACtD;;AAGA,SAAS,kBAAkB,MAA8B;CACvD,OAAO,KAAK,SAAS,QACnB,IAAI,UAAU,kBAAkB,IAAI,OAAO,IAAI,CAAC,GAAG,CACrD;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,gBAGd,QAAmD;CACnD,IAAI;CACJ,IAAI,cAAc;CAClB,IAAI,gBAAwCA,4BAAc;CAC1D,IAAI,qBAAoC,CAAC;CAIzC,IAAI,iBAAwD,CAAC;CAE7D,KAAK,aAAa,UAAmD;EACnE,MAAM,UAAU,MAAM;EAEtB,IAAI,QAAQ,SAAS,QAAQ;GAC3B,cAAc,QAAQ;GACtB,iBAAiB,CAAC;GAClB,IAAI,CAAC,OAAO;IACV,QAAQC,sCAAiC;KACvC,GAAI;KACJ,UAAU;MACR,uBAAuBC,0DAAwB;MAC/C,GAAG,OAAO;KACZ;KACA,MAAM,QAAQ;IAChB,CAAC;IAQD,qBAAqB,kBAAkB,OAAO,OAAqB,CAAC,CACjE,QACE,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB,IAC9D,CAAC,CACA,KACE,QACC,IAAI,OACH,OAAO,IAAI,gBAAgB,WACxB,IAAI,YAAY,WAAW,KAAK,GAAG,IACnC,OACR,CAAC,CACA,QAAQ,OAAqB,MAAM,IAAI;GAC5C,OACE,MAAM,YAAY,UAAU;IAAE,GAAG;IAAM,MAAM,QAAQ;GAAK,EAAE;GAI9D,MAAM,eAAe,MAAM,gBAAgB,CAAC,CAAC;GAC7C,gBAAgBF,4BAAc;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,cAAc,aAAa,EAAE,CAAE,MAAM;GAEvC;EACF;EAEA,IAAI,CAAC,OAAO;EAEZ,MAAM,QAAQ,YAAY,IAAI;EAG9B,MAAM,YAAY,YAAY;GAC5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,KAAK,GAAG;IACxD,MAAM,WAAY,MAAO,UAAkC;IAC3D,IAAI,YAAY,UAAU,QACxB,SAAS,IAAI,KAAK;GAEtB;EACF,CAAC;EAID,MAAM,SAAgE,CAAC;EACvE,MAAM,WAAgC,CAAC;EAEvC,KAAK,MAAM,SAAS,QAAQ,QAAQ;GAClC,IAAI,CAAE,OAAO,SAAqC,GAAG,MAAM,YACzD;GAEF,MAAM,QAAS,MAAc,MAAM,WAAW,KAAK,EAAE,UAAU,CAAC;GAIhE,IAAI,eAAe,WAAW,OAAO;IACnC,OAAO,SAAS,EAAE,MAAM,YAAY;IACpC;GACF;GACA,eAAe,SAAS;GACxB,OAAO,SAASG,4CACd,OACA,eACA,oBACA,QACF;EACF;EAEA,MAAM,WAA8B;GAClC,MAAM;GACN,WAAW,QAAQ;GACnB;GACA;GACA,WAAW,YAAY,IAAI,IAAI;EACjC;EACA,YAAY,UAAU,EAAE,SAAS,CAAC;CACpC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initTableWorker.js","names":[],"sources":["../../src/worker/initTableWorker.ts"],"sourcesContent":["import { constructTable } from '../core/table/constructTable'\nimport { storeReactivityBindings } from '../store-reactivity-bindings'\nimport { makeObjectMap } from '../utils'\nimport { serializeRowModel } from './serializeRowModel'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { TableOptions } from '../types/TableOptions'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRequest,\n TableWorkerResult,\n TableWorkerStage,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\nexport type TableWorkerConfig<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Omit<TableOptions<TFeatures, TData>, 'data'>\n\nfunction capitalize(stage: string) {\n return stage.charAt(0).toUpperCase() + stage.slice(1)\n}\n\n/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */\nfunction flattenColumnDefs(defs: Array<any>): Array<any> {\n return defs.flatMap((def) =>\n def.columns ? flattenColumnDefs(def.columns) : [def],\n )\n}\n\n/**\n * Runs a headless \"shadow table\" inside a dedicated Web Worker.\n *\n * Call this from a user-authored worker entry file, passing the same columns\n * and processing features used on the main thread. The shadow table runs the\n * real table-core row model pipeline (real fns, real Row objects) off the\n * main thread and posts back one payload per stage the main thread requested:\n * a transferable index permutation for flat results, a serialized row tree\n * (with eagerly computed aggregates) when grouping produces synthetic rows.\n *\n * Everything passed here must be thread-portable: `accessorKey` columns or\n * accessors defined in a shared module, and fns from registries or shared\n * modules (no closures over app state).\n *\n * @example\n * ```ts\n * // table.worker.ts\n * import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'\n * import { columns, sharedFeatures } from './tableConfig'\n *\n * initTableWorker({ features: sharedFeatures, columns })\n * ```\n */\nexport function initTableWorker<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(config: TableWorkerConfig<TFeatures, TData>): void {\n let table: Table_Internal<TFeatures, TData> | undefined\n let dataVersion = 0\n let coreIndexById: Record<string, number> = makeObjectMap()\n let aggregateColumnIds: Array<string> = []\n // Last-sent model identity per stage: the memoized getters return stable\n // objects when their inputs did not change, so identity equality is exactly\n // \"this stage's result is unchanged\".\n let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}\n\n self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {\n const message = event.data\n\n if (message.type === 'data') {\n dataVersion = message.dataVersion\n lastSentModels = {}\n if (!table) {\n table = constructTable<TFeatures, TData>({\n ...(config as TableOptions<TFeatures, TData>),\n features: {\n coreReactivityFeature: storeReactivityBindings(),\n ...config.features,\n },\n data: message.data,\n })\n // Only columns with an explicit aggregation get eagerly aggregated\n // per group. Sync tables aggregate lazily (visible cells only), so\n // auto-aggregating every column would explode on high-cardinality\n // grouping for values nothing renders. Read the RAW column defs:\n //
|
|
1
|
+
{"version":3,"file":"initTableWorker.js","names":[],"sources":["../../src/worker/initTableWorker.ts"],"sourcesContent":["import { constructTable } from '../core/table/constructTable'\nimport { storeReactivityBindings } from '../store-reactivity-bindings'\nimport { makeObjectMap } from '../utils'\nimport { serializeRowModel } from './serializeRowModel'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { TableOptions } from '../types/TableOptions'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRequest,\n TableWorkerResult,\n TableWorkerStage,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\nexport type TableWorkerConfig<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Omit<TableOptions<TFeatures, TData>, 'data'>\n\nfunction capitalize(stage: string) {\n return stage.charAt(0).toUpperCase() + stage.slice(1)\n}\n\n/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */\nfunction flattenColumnDefs(defs: Array<any>): Array<any> {\n return defs.flatMap((def) =>\n def.columns ? flattenColumnDefs(def.columns) : [def],\n )\n}\n\n/**\n * Runs a headless \"shadow table\" inside a dedicated Web Worker.\n *\n * Call this from a user-authored worker entry file, passing the same columns\n * and processing features used on the main thread. The shadow table runs the\n * real table-core row model pipeline (real fns, real Row objects) off the\n * main thread and posts back one payload per stage the main thread requested:\n * a transferable index permutation for flat results, a serialized row tree\n * (with eagerly computed aggregates) when grouping produces synthetic rows.\n *\n * Everything passed here must be thread-portable: `accessorKey` columns or\n * accessors defined in a shared module, and fns from registries or shared\n * modules (no closures over app state).\n *\n * @example\n * ```ts\n * // table.worker.ts\n * import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'\n * import { columns, sharedFeatures } from './tableConfig'\n *\n * initTableWorker({ features: sharedFeatures, columns })\n * ```\n */\nexport function initTableWorker<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(config: TableWorkerConfig<TFeatures, TData>): void {\n let table: Table_Internal<TFeatures, TData> | undefined\n let dataVersion = 0\n let coreIndexById: Record<string, number> = makeObjectMap()\n let aggregateColumnIds: Array<string> = []\n // Last-sent model identity per stage: the memoized getters return stable\n // objects when their inputs did not change, so identity equality is exactly\n // \"this stage's result is unchanged\".\n let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}\n\n self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {\n const message = event.data\n\n if (message.type === 'data') {\n dataVersion = message.dataVersion\n lastSentModels = {}\n if (!table) {\n table = constructTable<TFeatures, TData>({\n ...(config as TableOptions<TFeatures, TData>),\n features: {\n coreReactivityFeature: storeReactivityBindings(),\n ...config.features,\n },\n data: message.data,\n })\n // Only columns with an explicit aggregation get eagerly aggregated\n // per group. Sync tables aggregate lazily (visible cells only), so\n // auto-aggregating every column would explode on high-cardinality\n // grouping for values nothing renders. Read the RAW column defs:\n // aggregationFeature injects default aggregatedCell/aggregationFn\n // into every resolved columnDef, so the resolved defs can't tell\n // explicit from default.\n aggregateColumnIds = flattenColumnDefs(config.columns as Array<any>)\n .filter(\n (def) => def.aggregationFn != null || def.aggregatedCell != null,\n )\n .map(\n (def) =>\n def.id ??\n (typeof def.accessorKey === 'string'\n ? def.accessorKey.replaceAll('.', '_')\n : undefined),\n )\n .filter((id): id is string => id != null)\n } else {\n table.setOptions((prev) => ({ ...prev, data: message.data }))\n }\n // Map row ids to data positions once per dataset; serialization uses it\n // to express every stage result in terms of core row positions.\n const coreFlatRows = table.getCoreRowModel().flatRows\n coreIndexById = makeObjectMap()\n for (let i = 0; i < coreFlatRows.length; i++) {\n coreIndexById[coreFlatRows[i]!.id] = i\n }\n return\n }\n\n if (!table) return\n\n const start = performance.now()\n\n // Apply the serializable state slices to the shadow table's base atoms.\n table._reactivity.batch(() => {\n for (const [key, value] of Object.entries(message.state)) {\n const baseAtom = (table!.baseAtoms as Record<string, any>)[key]\n if (baseAtom && value !== undefined) {\n baseAtom.set(value)\n }\n }\n })\n\n // Compute exactly the stages the main thread requested, skipping any this\n // shadow table has no row model factory for (the main thread warns).\n const stages: { [K in TableWorkerStage]?: TableWorkerStagePayload } = {}\n const transfer: Array<Transferable> = []\n\n for (const stage of message.stages) {\n if (!(config.features as Record<string, unknown>)[`${stage}RowModel`]) {\n continue\n }\n const model = (table as any)[`get${capitalize(stage)}RowModel`]()\n // Memoized getters return the same object when inputs are unchanged;\n // skip re-serializing (and the main thread skips rebuilding). Safe under\n // single-flight: results are never dropped within a dataVersion.\n if (lastSentModels[stage] === model) {\n stages[stage] = { kind: 'unchanged' }\n continue\n }\n lastSentModels[stage] = model\n stages[stage] = serializeRowModel(\n model,\n coreIndexById,\n aggregateColumnIds,\n transfer,\n )\n }\n\n const response: TableWorkerResult = {\n type: 'result',\n requestId: message.requestId,\n dataVersion,\n stages,\n computeMs: performance.now() - start,\n }\n postMessage(response, { transfer })\n }\n}\n"],"mappings":";;;;;;AAoBA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACtD;;AAGA,SAAS,kBAAkB,MAA8B;CACvD,OAAO,KAAK,SAAS,QACnB,IAAI,UAAU,kBAAkB,IAAI,OAAO,IAAI,CAAC,GAAG,CACrD;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,gBAGd,QAAmD;CACnD,IAAI;CACJ,IAAI,cAAc;CAClB,IAAI,gBAAwC,cAAc;CAC1D,IAAI,qBAAoC,CAAC;CAIzC,IAAI,iBAAwD,CAAC;CAE7D,KAAK,aAAa,UAAmD;EACnE,MAAM,UAAU,MAAM;EAEtB,IAAI,QAAQ,SAAS,QAAQ;GAC3B,cAAc,QAAQ;GACtB,iBAAiB,CAAC;GAClB,IAAI,CAAC,OAAO;IACV,QAAQ,eAAiC;KACvC,GAAI;KACJ,UAAU;MACR,uBAAuB,wBAAwB;MAC/C,GAAG,OAAO;KACZ;KACA,MAAM,QAAQ;IAChB,CAAC;IAQD,qBAAqB,kBAAkB,OAAO,OAAqB,CAAC,CACjE,QACE,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB,IAC9D,CAAC,CACA,KACE,QACC,IAAI,OACH,OAAO,IAAI,gBAAgB,WACxB,IAAI,YAAY,WAAW,KAAK,GAAG,IACnC,OACR,CAAC,CACA,QAAQ,OAAqB,MAAM,IAAI;GAC5C,OACE,MAAM,YAAY,UAAU;IAAE,GAAG;IAAM,MAAM,QAAQ;GAAK,EAAE;GAI9D,MAAM,eAAe,MAAM,gBAAgB,CAAC,CAAC;GAC7C,gBAAgB,cAAc;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,cAAc,aAAa,EAAE,CAAE,MAAM;GAEvC;EACF;EAEA,IAAI,CAAC,OAAO;EAEZ,MAAM,QAAQ,YAAY,IAAI;EAG9B,MAAM,YAAY,YAAY;GAC5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,KAAK,GAAG;IACxD,MAAM,WAAY,MAAO,UAAkC;IAC3D,IAAI,YAAY,UAAU,QACxB,SAAS,IAAI,KAAK;GAEtB;EACF,CAAC;EAID,MAAM,SAAgE,CAAC;EACvE,MAAM,WAAgC,CAAC;EAEvC,KAAK,MAAM,SAAS,QAAQ,QAAQ;GAClC,IAAI,CAAE,OAAO,SAAqC,GAAG,MAAM,YACzD;GAEF,MAAM,QAAS,MAAc,MAAM,WAAW,KAAK,EAAE,UAAU,CAAC;GAIhE,IAAI,eAAe,WAAW,OAAO;IACnC,OAAO,SAAS,EAAE,MAAM,YAAY;IACpC;GACF;GACA,eAAe,SAAS;GACxB,OAAO,SAAS,kBACd,OACA,eACA,oBACA,QACF;EACF;EAEA,MAAM,WAA8B;GAClC,MAAM;GACN,WAAW,QAAQ;GACnB;GACA;GACA,WAAW,YAAY,IAAI,IAAI;EACjC;EACA,YAAY,UAAU,EAAE,SAAS,CAAC;CACpC;AACF"}
|
package/package.json
CHANGED
|
@@ -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.
|
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'
|
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
|
-
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.
|
|
49
|
-
? '
|
|
50
|
-
:
|
|
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
|
|
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
|
|
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/`
|
|
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.
|