@tanstack/table-core 9.0.0-beta.78 → 9.0.0-beta.80
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/README.md +16 -2
- package/dist/core/columns/coreColumnsFeature.d.ts +1 -1
- package/dist/core/columns/coreColumnsFeature.js +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +1 -1
- package/dist/features/cell-selection/cellSelectionFeature.utils.js +13 -7
- package/dist/features/column-grouping/createGroupedRowModel.js +9 -4
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +4 -4
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/skills/aggregation/SKILL.md +1 -1
- package/skills/api-not-found/SKILL.md +1 -1
- package/skills/cell-selection/SKILL.md +1 -1
- package/skills/cell-spanning/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 +1 -1
- package/skills/migrate-v8-to-v9/SKILL.md +1 -1
- 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 +1 -1
- package/skills/typescript/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/table.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/table.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/table.png"
|
|
13
|
+
alt="TanStack Table"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
3
17
|
</div>
|
|
4
18
|
|
|
5
19
|
<br />
|
|
@@ -61,7 +75,7 @@ TanStack Table ships [TanStack Intent](https://github.com/TanStack/intent) skill
|
|
|
61
75
|
npx @tanstack/intent@latest install
|
|
62
76
|
```
|
|
63
77
|
|
|
64
|
-
to add skill-loading guidance for your agent (Claude Code, Cursor, Copilot, etc.). The same CLI also exposes `intent list` to browse available skills and `intent load <skill>` to print one for inspection. Skills
|
|
78
|
+
to add skill-loading guidance for your agent (Claude Code, Cursor, Copilot, etc.). The same CLI also exposes `intent list` to browse available skills and `intent load <skill>` to print one for inspection. Skills are versioned with the library — your agent gets guidance that matches the version of `@tanstack/<framework>-table` you installed. Only available for v9 and above.
|
|
65
79
|
|
|
66
80
|
## Get Involved
|
|
67
81
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TableFeature } from "../../types/TableFeatures.js";
|
|
2
2
|
//#region src/core/columns/coreColumnsFeature.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Core feature that builds the column tree and exposes table/column
|
|
4
|
+
* Core feature that builds the column tree and exposes table/column APIs.
|
|
5
5
|
*/
|
|
6
6
|
declare const coreColumnsFeature: TableFeature;
|
|
7
7
|
//#endregion
|
|
@@ -3,7 +3,7 @@ import { column_getFlatColumns, column_getLeafColumns, table_getAllColumns, tabl
|
|
|
3
3
|
|
|
4
4
|
//#region src/core/columns/coreColumnsFeature.ts
|
|
5
5
|
/**
|
|
6
|
-
* Core feature that builds the column tree and exposes table/column
|
|
6
|
+
* Core feature that builds the column tree and exposes table/column APIs.
|
|
7
7
|
*/
|
|
8
8
|
const coreColumnsFeature = {
|
|
9
9
|
assignColumnPrototype: (prototype, table) => {
|
|
@@ -49,7 +49,7 @@ interface Header_CoreProperties<in out TFeatures extends TableFeatures, in out T
|
|
|
49
49
|
*/
|
|
50
50
|
column: Column<TFeatures, TData, TValue>;
|
|
51
51
|
/**
|
|
52
|
-
* The depth of the header, zero-indexed
|
|
52
|
+
* The depth of the header, zero-indexed.
|
|
53
53
|
*/
|
|
54
54
|
depth: number;
|
|
55
55
|
/**
|
|
@@ -95,7 +95,7 @@ interface Row_Row<in out TFeatures extends TableFeatures, in out TData extends R
|
|
|
95
95
|
}
|
|
96
96
|
interface TableOptions_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
97
97
|
/**
|
|
98
|
-
* This optional function is used to derive a unique ID for any given row. If not provided the
|
|
98
|
+
* This optional function is used to derive a unique ID for any given row. If not provided the row's index is used (nested rows join together with `.` using their grandparents' index e.g. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity e.g. a userId, taskId, database ID field, etc.
|
|
99
99
|
* @example getRowId: row => row.userId
|
|
100
100
|
*/
|
|
101
101
|
getRowId?: (originalRow: TData, index: number, parent?: Row<TFeatures, TData>) => string;
|
|
@@ -512,15 +512,15 @@ function getDirectionDelta(direction) {
|
|
|
512
512
|
* step would leave the grid or find no selectable column.
|
|
513
513
|
*/
|
|
514
514
|
function stepCoordinate(table, rowId, columnId, direction) {
|
|
515
|
-
const rows = table.
|
|
515
|
+
const rows = table.getRowModel().rows;
|
|
516
516
|
const columns = getDisplayOrderedColumns(table);
|
|
517
517
|
if (!rows.length || !columns.length) return null;
|
|
518
518
|
const { rowDelta, columnDelta } = getDirectionDelta(direction);
|
|
519
|
-
const rowIndex =
|
|
519
|
+
const rowIndex = rows.findIndex((row) => row.id === rowId);
|
|
520
520
|
const columnIndex = columns.findIndex((column) => column.id === columnId);
|
|
521
521
|
if (rowIndex < 0 || columnIndex < 0) return null;
|
|
522
522
|
const merges = callMemoOrStaticFn(table, "getCellSelectionMergeBounds", table_getCellSelectionMergeBounds);
|
|
523
|
-
let fromRowIndex = rowIndex;
|
|
523
|
+
let fromRowIndex = rows[rowIndex].getDisplayIndex();
|
|
524
524
|
let fromColumnIndex = columnIndex;
|
|
525
525
|
if (merges.length) {
|
|
526
526
|
const startMerge = findMergeBoundsAt(merges, rowIndex, columnIndex);
|
|
@@ -531,7 +531,12 @@ function stepCoordinate(table, rowId, columnId, direction) {
|
|
|
531
531
|
if (columnDelta < 0) fromColumnIndex = startMerge.minColumnIndex;
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
|
|
534
|
+
let nextRowIndex = rowIndex + rowDelta;
|
|
535
|
+
if (rowDelta && fromRowIndex !== rows[rowIndex].getDisplayIndex()) {
|
|
536
|
+
const edgeRowIndex = rows.findIndex((row) => row.getDisplayIndex() === fromRowIndex);
|
|
537
|
+
if (edgeRowIndex < 0) return null;
|
|
538
|
+
nextRowIndex = edgeRowIndex + rowDelta;
|
|
539
|
+
}
|
|
535
540
|
if (nextRowIndex < 0 || nextRowIndex >= rows.length) return null;
|
|
536
541
|
const selectableColumnIds = new Set(getSelectableColumns(table).map((column) => column.id));
|
|
537
542
|
if (!selectableColumnIds.size) return null;
|
|
@@ -555,9 +560,10 @@ function stepCoordinate(table, rowId, columnId, direction) {
|
|
|
555
560
|
let landingRowIndex = nextRowIndex;
|
|
556
561
|
let landingColumnIndex = nextColumnIndex;
|
|
557
562
|
if (merges.length) {
|
|
558
|
-
const landingMerge = findMergeBoundsAt(merges, nextRowIndex, nextColumnIndex);
|
|
563
|
+
const landingMerge = findMergeBoundsAt(merges, rows[nextRowIndex].getDisplayIndex(), nextColumnIndex);
|
|
559
564
|
if (landingMerge) {
|
|
560
|
-
landingRowIndex = landingMerge.minRowIndex;
|
|
565
|
+
landingRowIndex = rows.findIndex((row) => row.getDisplayIndex() === landingMerge.minRowIndex);
|
|
566
|
+
if (landingRowIndex < 0) return null;
|
|
561
567
|
landingColumnIndex = landingMerge.minColumnIndex;
|
|
562
568
|
}
|
|
563
569
|
}
|
|
@@ -584,7 +590,7 @@ function table_moveCellSelection(table, direction) {
|
|
|
584
590
|
const ranges = table.atoms.cellSelection?.get();
|
|
585
591
|
const active = ranges?.[ranges.length - 1];
|
|
586
592
|
if (!active) {
|
|
587
|
-
const rows = table.
|
|
593
|
+
const rows = table.getRowModel().rows;
|
|
588
594
|
const columns = getSelectableColumns(table);
|
|
589
595
|
if (!rows.length || !columns.length) return;
|
|
590
596
|
table_setFocusedCell(table, rows[0].id, columns[0].id);
|
|
@@ -49,10 +49,7 @@ function _createGroupedRowModel(table) {
|
|
|
49
49
|
const rowModel = table.getPreGroupedRowModel();
|
|
50
50
|
const grouping = table.atoms.grouping?.get();
|
|
51
51
|
if (!rowModel.rows.length || !grouping?.length) {
|
|
52
|
-
rowModel.rows
|
|
53
|
-
row.depth = 0;
|
|
54
|
-
row.parentId = void 0;
|
|
55
|
-
});
|
|
52
|
+
resetRowRelationships(rowModel.rows, 0, void 0);
|
|
56
53
|
return rowModel;
|
|
57
54
|
}
|
|
58
55
|
const existingGrouping = grouping.filter((columnId) => table_getColumn(table, columnId));
|
|
@@ -127,6 +124,14 @@ function _createGroupedRowModel(table) {
|
|
|
127
124
|
rowsById: groupedRowsById
|
|
128
125
|
};
|
|
129
126
|
}
|
|
127
|
+
function resetRowRelationships(rows, depth, parentId) {
|
|
128
|
+
for (let i = 0; i < rows.length; i++) {
|
|
129
|
+
const row = rows[i];
|
|
130
|
+
row.depth = depth;
|
|
131
|
+
row.parentId = parentId;
|
|
132
|
+
if (row.subRows.length) resetRowRelationships(row.subRows, depth + 1, row.id);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
130
135
|
function groupBy(table, rows, columnId) {
|
|
131
136
|
const groupMap = /* @__PURE__ */ new Map();
|
|
132
137
|
const getGroupingValue = table_getColumn(table, columnId)?.columnDef.getGroupingValue;
|
|
@@ -58,7 +58,7 @@ interface TableOptions_RowExpanding<in out TFeatures extends TableFeatures, in o
|
|
|
58
58
|
*/
|
|
59
59
|
onExpandedChange?: OnChangeFn<ExpandedState>;
|
|
60
60
|
/**
|
|
61
|
-
* If `true` expanded rows will be paginated along with the rest of the table (which means expanded rows may span multiple pages). If `false` expanded rows will not be considered for pagination (which means expanded rows will always render on their
|
|
61
|
+
* If `true` expanded rows will be paginated along with the rest of the table (which means expanded rows may span multiple pages). If `false` expanded rows will not be considered for pagination (which means expanded rows will always render on their parent's page). This also means more rows will be rendered than the set page size.
|
|
62
62
|
*/
|
|
63
63
|
paginateExpandedRows?: boolean;
|
|
64
64
|
}
|
|
@@ -11,7 +11,7 @@ interface TableState_RowPagination {
|
|
|
11
11
|
}
|
|
12
12
|
interface TableOptions_RowPagination {
|
|
13
13
|
/**
|
|
14
|
-
* If set to `true`, pagination will be reset to the first page when page-altering state changes
|
|
14
|
+
* If set to `true`, pagination will be reset to the first page when page-altering state changes e.g. `data` is updated, filters change, grouping changes, etc.
|
|
15
15
|
*/
|
|
16
16
|
autoResetPageIndex?: boolean;
|
|
17
17
|
/**
|
|
@@ -73,7 +73,7 @@ interface ColumnDef_RowSorting<in out TFeatures extends TableFeatures, in out TD
|
|
|
73
73
|
*/
|
|
74
74
|
enableSorting?: boolean;
|
|
75
75
|
/**
|
|
76
|
-
* Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better,
|
|
76
|
+
* Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better, e.g. a ranking (1st, 2nd, 3rd) or golf-like scoring
|
|
77
77
|
*/
|
|
78
78
|
invertSorting?: boolean;
|
|
79
79
|
/**
|
|
@@ -149,7 +149,7 @@ interface Column_RowSorting<in out TFeatures extends TableFeatures, in out TData
|
|
|
149
149
|
*/
|
|
150
150
|
getToggleSortingHandler: () => undefined | ((event: unknown) => void);
|
|
151
151
|
/**
|
|
152
|
-
* Toggles this
|
|
152
|
+
* Toggles this column's sorting state. If `desc` is provided, it will force the sort direction to that value. If `isMulti` is provided, it will additively multi-sort the column (or toggle it if it is already sorted).
|
|
153
153
|
*/
|
|
154
154
|
toggleSorting: (desc?: boolean, isMulti?: boolean) => void;
|
|
155
155
|
}
|
|
@@ -175,8 +175,8 @@ interface TableOptions_RowSorting {
|
|
|
175
175
|
enableSorting?: boolean;
|
|
176
176
|
/**
|
|
177
177
|
* Enables/Disables the ability to remove sorting for the table.
|
|
178
|
-
* - If `true` then changing sort order will
|
|
179
|
-
* - If `false` then changing sort order will
|
|
178
|
+
* - If `true` then changing sort order will cycle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...
|
|
179
|
+
* - If `false` then changing sort order will cycle like: 'none' -> 'desc' -> 'asc' -> 'desc' -> 'asc' -> ...
|
|
180
180
|
*/
|
|
181
181
|
enableSortingRemoval?: boolean;
|
|
182
182
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ type PrototypeAPIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<str
|
|
|
122
122
|
*/
|
|
123
123
|
declare function assignPrototypeAPIs<TFeatures extends TableFeatures, TData extends RowData, TDeps extends ReadonlyArray<any>, TDepArgs>(feature: keyof TFeatures & string, prototype: Record<string, any>, table: Table<TFeatures, TData>, apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>): void;
|
|
124
124
|
/**
|
|
125
|
-
* Looks to run the memoized function with the builder pattern on the object if it exists, otherwise
|
|
125
|
+
* Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fall back to the static method passed in.
|
|
126
126
|
*/
|
|
127
127
|
declare function callMemoOrStaticFn<TObject extends Record<string, any>, TArgs extends Array<any>, TReturn>(obj: TObject, fnKey: string, staticFn: (obj: TObject, ...args: TArgs) => TReturn, ...args: TArgs): TReturn;
|
|
128
128
|
//#endregion
|
package/dist/utils.js
CHANGED
|
@@ -260,7 +260,7 @@ function assignPrototypeAPIs(feature, prototype, table, apis) {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
|
-
* Looks to run the memoized function with the builder pattern on the object if it exists, otherwise
|
|
263
|
+
* Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fall back to the static method passed in.
|
|
264
264
|
*/
|
|
265
265
|
function callMemoOrStaticFn(obj, fnKey, staticFn, ...args) {
|
|
266
266
|
return obj[fnKey]?.(...args) ?? staticFn(obj, ...args);
|
package/package.json
CHANGED
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.80'
|
|
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
|
@@ -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.80'
|
|
9
9
|
requires: ['core', 'table-features', 'typescript']
|
|
10
10
|
sources:
|
|
11
11
|
- 'TanStack/table:docs/framework/react/guide/migrating.md'
|
package/skills/sorting/SKILL.md
CHANGED