@tanstack/table-core 9.0.0-beta.75 → 9.0.0-beta.77
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/createCoreRowModel.js +5 -3
- package/dist/features/column-filtering/createFilteredRowModel.js +2 -2
- package/dist/features/column-grouping/createGroupedRowModel.js +2 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +15 -6
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +39 -15
- package/dist/features/row-pagination/createPaginatedRowModel.js +3 -0
- package/dist/features/row-sorting/createSortedRowModel.js +2 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +9 -3
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +8 -5
- package/dist/features/row-sorting/rowSortingFeature.utils.js +15 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/static-functions.js +1 -1
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +19 -1
- package/dist/worker/createTableWorker.d.ts +2 -0
- package/dist/worker/createTableWorker.js +6 -3
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { makeObjectMap, tableMemo } from "../../utils.js";
|
|
1
|
+
import { makeObjectMap, skipFirstRun, tableMemo } from "../../utils.js";
|
|
2
2
|
import { constructRow } from "../rows/constructRow.js";
|
|
3
3
|
import { table_autoResetCellSelection } from "../../features/cell-selection/cellSelectionFeature.utils.js";
|
|
4
|
+
import { table_autoResetExpanded } from "../../features/row-expanding/rowExpandingFeature.utils.js";
|
|
4
5
|
import { table_autoResetPageIndex } from "../../features/row-pagination/rowPaginationFeature.utils.js";
|
|
5
6
|
import { table_autoResetSorting } from "../../features/row-sorting/rowSortingFeature.utils.js";
|
|
6
7
|
|
|
@@ -18,11 +19,12 @@ function createCoreRowModel() {
|
|
|
18
19
|
fnName: "table.getCoreRowModel",
|
|
19
20
|
memoDeps: () => [table.options.data],
|
|
20
21
|
fn: () => _createCoreRowModel(table, table.options.data),
|
|
21
|
-
onAfterUpdate: () => {
|
|
22
|
+
onAfterUpdate: skipFirstRun(() => {
|
|
23
|
+
table_autoResetExpanded(table);
|
|
22
24
|
table_autoResetPageIndex(table);
|
|
23
25
|
table_autoResetSorting(table);
|
|
24
26
|
table_autoResetCellSelection(table);
|
|
25
|
-
}
|
|
27
|
+
})
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeObjectMap, tableMemo } from "../../utils.js";
|
|
1
|
+
import { makeObjectMap, skipFirstRun, tableMemo } from "../../utils.js";
|
|
2
2
|
import { table_getColumn } from "../../core/columns/coreColumnsFeature.utils.js";
|
|
3
3
|
import { table_autoResetPageIndex } from "../row-pagination/rowPaginationFeature.utils.js";
|
|
4
4
|
import { column_getFilterFn } from "./columnFilteringFeature.utils.js";
|
|
@@ -31,7 +31,7 @@ function createFilteredRowModel() {
|
|
|
31
31
|
table.atoms.globalFilter?.get()
|
|
32
32
|
],
|
|
33
33
|
fn: () => _createFilteredRowModel(table),
|
|
34
|
-
onAfterUpdate: () => table_autoResetPageIndex(table)
|
|
34
|
+
onAfterUpdate: skipFirstRun(() => table_autoResetPageIndex(table))
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { hasOwn, makeObjectMap, tableMemo } from "../../utils.js";
|
|
2
2
|
import { table_getColumn } from "../../core/columns/coreColumnsFeature.utils.js";
|
|
3
3
|
import { constructRow } from "../../core/rows/constructRow.js";
|
|
4
|
+
import { table_autoResetExpanded } from "../row-expanding/rowExpandingFeature.utils.js";
|
|
4
5
|
import { table_autoResetPageIndex } from "../row-pagination/rowPaginationFeature.utils.js";
|
|
5
6
|
import { aggregateColumnValue, normalizeUniqueAggregationRows } from "../row-aggregation/rowAggregationFeature.utils.js";
|
|
6
|
-
import { table_autoResetExpanded } from "../row-expanding/rowExpandingFeature.utils.js";
|
|
7
7
|
|
|
8
8
|
//#region src/features/column-grouping/createGroupedRowModel.ts
|
|
9
9
|
/**
|
|
@@ -33,7 +33,7 @@ function createGroupedRowModel() {
|
|
|
33
33
|
onAfterUpdate: () => {
|
|
34
34
|
const grouping = table.atoms.grouping?.get();
|
|
35
35
|
const preGroupedRowModel = table.getPreGroupedRowModel();
|
|
36
|
-
const rowInputsChanged =
|
|
36
|
+
const rowInputsChanged = hasAutoResetDependencies && (grouping !== previousGrouping || preGroupedRowModel !== previousPreGroupedRowModel);
|
|
37
37
|
previousGrouping = grouping;
|
|
38
38
|
previousPreGroupedRowModel = preGroupedRowModel;
|
|
39
39
|
hasAutoResetDependencies = true;
|
|
@@ -48,6 +48,9 @@ declare function table_setExpanded<TFeatures extends TableFeatures, TData extend
|
|
|
48
48
|
* an empty map. Omitting the value toggles based on whether all rows are
|
|
49
49
|
* currently expanded.
|
|
50
50
|
*
|
|
51
|
+
* The call is a no-op (no `onExpandedChange`) when no row can expand or when
|
|
52
|
+
* the requested state matches the current state exactly.
|
|
53
|
+
*
|
|
51
54
|
* @example
|
|
52
55
|
* ```ts
|
|
53
56
|
* table_toggleAllRowsExpanded(table)
|
|
@@ -100,10 +103,12 @@ declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFe
|
|
|
100
103
|
*/
|
|
101
104
|
declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): boolean;
|
|
102
105
|
/**
|
|
103
|
-
* Checks whether every row in the current row model is expanded.
|
|
106
|
+
* Checks whether every expandable row in the current row model is expanded.
|
|
104
107
|
*
|
|
105
108
|
* The special expanded-all value `true` returns true immediately. Empty
|
|
106
|
-
* expanded state returns false.
|
|
109
|
+
* expanded state returns false. Rows that cannot expand are ignored, so a
|
|
110
|
+
* materialized expanded-all map (which only contains expandable row ids)
|
|
111
|
+
* still counts as all rows expanded.
|
|
107
112
|
*
|
|
108
113
|
* @example
|
|
109
114
|
* ```ts
|
|
@@ -114,8 +119,8 @@ declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TDa
|
|
|
114
119
|
/**
|
|
115
120
|
* Computes the deepest expanded row id depth.
|
|
116
121
|
*
|
|
117
|
-
* Row ids are split on `.`; expanded-all state scans the current row model
|
|
118
|
-
* while explicit expanded state scans its expanded id keys.
|
|
122
|
+
* Row ids are split on `.`; expanded-all state scans the current row model's
|
|
123
|
+
* expandable rows, while explicit expanded state scans its expanded id keys.
|
|
119
124
|
*
|
|
120
125
|
* @example
|
|
121
126
|
* ```ts
|
|
@@ -127,8 +132,12 @@ declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData e
|
|
|
127
132
|
* Expands or collapses this row.
|
|
128
133
|
*
|
|
129
134
|
* Omitting `expanded` toggles the row. If the current state is expanded-all,
|
|
130
|
-
* the function first materializes that state into a row-id map
|
|
131
|
-
* the row-specific change.
|
|
135
|
+
* the function first materializes that state into a row-id map (containing
|
|
136
|
+
* only expandable row ids) before applying the row-specific change.
|
|
137
|
+
*
|
|
138
|
+
* The call is a no-op (no `onExpandedChange`) when the requested state matches
|
|
139
|
+
* the current state, or when expanding a row that cannot expand. Collapsing is
|
|
140
|
+
* always allowed so stale expanded ids can be cleaned up.
|
|
132
141
|
*
|
|
133
142
|
* @example
|
|
134
143
|
* ```ts
|
|
@@ -28,6 +28,7 @@ function getDefaultExpandedState() {
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
function table_autoResetExpanded(table) {
|
|
31
|
+
if (!table.atoms.expanded) return;
|
|
31
32
|
if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) table._reactivity.schedule(() => table_resetExpanded(table));
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -51,14 +52,24 @@ function table_setExpanded(table, updater) {
|
|
|
51
52
|
* an empty map. Omitting the value toggles based on whether all rows are
|
|
52
53
|
* currently expanded.
|
|
53
54
|
*
|
|
55
|
+
* The call is a no-op (no `onExpandedChange`) when no row can expand or when
|
|
56
|
+
* the requested state matches the current state exactly.
|
|
57
|
+
*
|
|
54
58
|
* @example
|
|
55
59
|
* ```ts
|
|
56
60
|
* table_toggleAllRowsExpanded(table)
|
|
57
61
|
* ```
|
|
58
62
|
*/
|
|
59
63
|
function table_toggleAllRowsExpanded(table, expanded) {
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
const currentExpanded = table.atoms.expanded?.get() ?? {};
|
|
65
|
+
if (expanded ?? !table_getIsAllRowsExpanded(table)) {
|
|
66
|
+
if (currentExpanded === true) return;
|
|
67
|
+
if (!table_getCanSomeRowsExpand(table)) return;
|
|
68
|
+
table_setExpanded(table, true);
|
|
69
|
+
} else {
|
|
70
|
+
if (currentExpanded !== true && !Object.keys(currentExpanded).length) return;
|
|
71
|
+
table_setExpanded(table, makeObjectMap());
|
|
72
|
+
}
|
|
62
73
|
}
|
|
63
74
|
/**
|
|
64
75
|
* Resets `expanded` to the configured initial state or feature default.
|
|
@@ -118,10 +129,12 @@ function table_getIsSomeRowsExpanded(table) {
|
|
|
118
129
|
return expanded === true || Object.values(expanded).some(Boolean);
|
|
119
130
|
}
|
|
120
131
|
/**
|
|
121
|
-
* Checks whether every row in the current row model is expanded.
|
|
132
|
+
* Checks whether every expandable row in the current row model is expanded.
|
|
122
133
|
*
|
|
123
134
|
* The special expanded-all value `true` returns true immediately. Empty
|
|
124
|
-
* expanded state returns false.
|
|
135
|
+
* expanded state returns false. Rows that cannot expand are ignored, so a
|
|
136
|
+
* materialized expanded-all map (which only contains expandable row ids)
|
|
137
|
+
* still counts as all rows expanded.
|
|
125
138
|
*
|
|
126
139
|
* @example
|
|
127
140
|
* ```ts
|
|
@@ -132,14 +145,16 @@ function table_getIsAllRowsExpanded(table) {
|
|
|
132
145
|
const expanded = table.atoms.expanded?.get() ?? {};
|
|
133
146
|
if (expanded === true) return true;
|
|
134
147
|
if (!Object.keys(expanded).length) return false;
|
|
135
|
-
|
|
148
|
+
const expandableRows = table.getRowModel().flatRows.filter((row) => row_getCanExpand(row));
|
|
149
|
+
if (!expandableRows.length) return false;
|
|
150
|
+
if (expandableRows.some((row) => !row_getIsExpanded(row))) return false;
|
|
136
151
|
return true;
|
|
137
152
|
}
|
|
138
153
|
/**
|
|
139
154
|
* Computes the deepest expanded row id depth.
|
|
140
155
|
*
|
|
141
|
-
* Row ids are split on `.`; expanded-all state scans the current row model
|
|
142
|
-
* while explicit expanded state scans its expanded id keys.
|
|
156
|
+
* Row ids are split on `.`; expanded-all state scans the current row model's
|
|
157
|
+
* expandable rows, while explicit expanded state scans its expanded id keys.
|
|
143
158
|
*
|
|
144
159
|
* @example
|
|
145
160
|
* ```ts
|
|
@@ -148,7 +163,8 @@ function table_getIsAllRowsExpanded(table) {
|
|
|
148
163
|
*/
|
|
149
164
|
function table_getExpandedDepth(table) {
|
|
150
165
|
let maxDepth = 0;
|
|
151
|
-
|
|
166
|
+
const expanded = table.atoms.expanded?.get();
|
|
167
|
+
(expanded === true ? Object.values(table.getRowModel().rowsById).filter((row) => row_getCanExpand(row)).map((row) => row.id) : Object.keys(expanded ?? {})).forEach((id) => {
|
|
152
168
|
const splitId = id.split(".");
|
|
153
169
|
maxDepth = Math.max(maxDepth, splitId.length);
|
|
154
170
|
});
|
|
@@ -158,8 +174,12 @@ function table_getExpandedDepth(table) {
|
|
|
158
174
|
* Expands or collapses this row.
|
|
159
175
|
*
|
|
160
176
|
* Omitting `expanded` toggles the row. If the current state is expanded-all,
|
|
161
|
-
* the function first materializes that state into a row-id map
|
|
162
|
-
* the row-specific change.
|
|
177
|
+
* the function first materializes that state into a row-id map (containing
|
|
178
|
+
* only expandable row ids) before applying the row-specific change.
|
|
179
|
+
*
|
|
180
|
+
* The call is a no-op (no `onExpandedChange`) when the requested state matches
|
|
181
|
+
* the current state, or when expanding a row that cannot expand. Collapsing is
|
|
182
|
+
* always allowed so stale expanded ids can be cleaned up.
|
|
163
183
|
*
|
|
164
184
|
* @example
|
|
165
185
|
* ```ts
|
|
@@ -167,19 +187,23 @@ function table_getExpandedDepth(table) {
|
|
|
167
187
|
* ```
|
|
168
188
|
*/
|
|
169
189
|
function row_toggleExpanded(row, expanded) {
|
|
190
|
+
const currentExpanded = row.table.atoms.expanded?.get() ?? {};
|
|
191
|
+
const currentExists = currentExpanded === true || isExpandedRowId(currentExpanded, row.id);
|
|
192
|
+
const targetExpanded = expanded ?? !currentExists;
|
|
193
|
+
if (targetExpanded === currentExists) return;
|
|
194
|
+
if (targetExpanded && !row_getCanExpand(row)) return;
|
|
170
195
|
table_setExpanded(row.table, (old) => {
|
|
171
196
|
const exists = old === true ? true : isExpandedRowId(old, row.id);
|
|
172
197
|
let oldExpanded = makeObjectMap();
|
|
173
|
-
if (old === true) Object.
|
|
174
|
-
oldExpanded[
|
|
198
|
+
if (old === true) Object.values(row.table.getRowModel().rowsById).forEach((rowModelRow) => {
|
|
199
|
+
if (row_getCanExpand(rowModelRow)) oldExpanded[rowModelRow.id] = true;
|
|
175
200
|
});
|
|
176
201
|
else oldExpanded = Object.assign(makeObjectMap(), old);
|
|
177
|
-
|
|
178
|
-
if (!exists && expanded) {
|
|
202
|
+
if (!exists && targetExpanded) {
|
|
179
203
|
oldExpanded[row.id] = true;
|
|
180
204
|
return oldExpanded;
|
|
181
205
|
}
|
|
182
|
-
if (exists && !
|
|
206
|
+
if (exists && !targetExpanded) {
|
|
183
207
|
const rest = makeObjectMap();
|
|
184
208
|
const rowIds = Object.keys(oldExpanded);
|
|
185
209
|
for (let i = 0; i < rowIds.length; i++) {
|
|
@@ -45,7 +45,10 @@ function _createPaginatedRowModel(table) {
|
|
|
45
45
|
rowsById
|
|
46
46
|
};
|
|
47
47
|
paginatedRowModel.flatRows = [];
|
|
48
|
+
const seenFlatRows = /* @__PURE__ */ new Set();
|
|
48
49
|
const handleRow = (row) => {
|
|
50
|
+
if (seenFlatRows.has(row.id)) return;
|
|
51
|
+
seenFlatRows.add(row.id);
|
|
49
52
|
paginatedRowModel.flatRows.push(row);
|
|
50
53
|
if (row.subRows.length) row.subRows.forEach(handleRow);
|
|
51
54
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { copyInstancePropertiesWithoutMemos, tableMemo } from "../../utils.js";
|
|
1
|
+
import { copyInstancePropertiesWithoutMemos, skipFirstRun, tableMemo } from "../../utils.js";
|
|
2
2
|
import { table_autoResetPageIndex } from "../row-pagination/rowPaginationFeature.utils.js";
|
|
3
3
|
import { column_getCanSort, column_getSortFn } from "./rowSortingFeature.utils.js";
|
|
4
4
|
|
|
@@ -24,7 +24,7 @@ function createSortedRowModel() {
|
|
|
24
24
|
fnName: "table.getSortedRowModel",
|
|
25
25
|
memoDeps: () => [table.atoms.sorting?.get(), table.getPreSortedRowModel()],
|
|
26
26
|
fn: () => _createSortedRowModel(table),
|
|
27
|
-
onAfterUpdate: () => table_autoResetPageIndex(table)
|
|
27
|
+
onAfterUpdate: skipFirstRun(() => table_autoResetPageIndex(table))
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -89,11 +89,15 @@ interface ColumnDef_RowSorting<in out TFeatures extends TableFeatures, in out TD
|
|
|
89
89
|
/**
|
|
90
90
|
* The priority of undefined values when sorting this column.
|
|
91
91
|
* - `false`
|
|
92
|
-
* - Undefined values will be
|
|
92
|
+
* - Undefined values will be passed to the sorting function like any other value with no special handling; the sorting function is responsible for handling them
|
|
93
93
|
* - `-1`
|
|
94
94
|
* - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)
|
|
95
95
|
* - `1`
|
|
96
96
|
* - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)
|
|
97
|
+
* - `'first'`
|
|
98
|
+
* - Undefined values will be pushed to the beginning of the list regardless of sort direction
|
|
99
|
+
* - `'last'`
|
|
100
|
+
* - Undefined values will be pushed to the end of the list regardless of sort direction
|
|
97
101
|
*/
|
|
98
102
|
sortUndefined?: false | -1 | 1 | 'first' | 'last';
|
|
99
103
|
}
|
|
@@ -127,9 +131,11 @@ interface Column_RowSorting<in out TFeatures extends TableFeatures, in out TData
|
|
|
127
131
|
*/
|
|
128
132
|
getIsSorted: () => false | SortDirection;
|
|
129
133
|
/**
|
|
130
|
-
* Returns the next sorting order.
|
|
134
|
+
* Returns the next sorting order. Pass `multi` to resolve the order for a
|
|
135
|
+
* multi-sort toggle, where `enableMultiRemove` governs whether the cycle can
|
|
136
|
+
* remove the sort.
|
|
131
137
|
*/
|
|
132
|
-
getNextSortingOrder: () => SortDirection | false;
|
|
138
|
+
getNextSortingOrder: (multi?: boolean) => SortDirection | false;
|
|
133
139
|
/**
|
|
134
140
|
* Finds this column's position in the ordered sorting state.
|
|
135
141
|
*/
|
|
@@ -67,10 +67,13 @@ declare function table_autoResetSorting<TFeatures extends TableFeatures, TData e
|
|
|
67
67
|
*/
|
|
68
68
|
declare function column_getAutoSortFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): SortFn<TFeatures, TData>;
|
|
69
69
|
/**
|
|
70
|
-
* Chooses the default first sort direction from
|
|
70
|
+
* Chooses the default first sort direction from sampled filtered row values.
|
|
71
71
|
*
|
|
72
|
-
*
|
|
73
|
-
* types
|
|
72
|
+
* The first non-nullish value among the sampled rows decides: string columns
|
|
73
|
+
* start ascending so alphabetical order is natural; other value types (or
|
|
74
|
+
* columns with no non-nullish sample) start descending. Sampling past leading
|
|
75
|
+
* nullish values keeps the toggle cycle stable when sorting or a data swap
|
|
76
|
+
* moves an empty value into the first row.
|
|
74
77
|
*
|
|
75
78
|
* @example
|
|
76
79
|
* ```ts
|
|
@@ -95,8 +98,8 @@ declare function column_getSortFn<TFeatures extends TableFeatures, TData extends
|
|
|
95
98
|
* Applies the next sorting state for this column.
|
|
96
99
|
*
|
|
97
100
|
* The toggle can add, replace, flip, or remove this column's sort entry. Multi
|
|
98
|
-
* sorting respects `enableMultiSort`, `
|
|
99
|
-
* argument.
|
|
101
|
+
* sorting respects `enableMultiSort`, `enableMultiRemove`,
|
|
102
|
+
* `maxMultiSortColCount`, and the `multi` argument.
|
|
100
103
|
*
|
|
101
104
|
* @example
|
|
102
105
|
* ```ts
|
|
@@ -103,10 +103,13 @@ function column_getAutoSortFn(column) {
|
|
|
103
103
|
return sortFn_basic;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* Chooses the default first sort direction from
|
|
106
|
+
* Chooses the default first sort direction from sampled filtered row values.
|
|
107
107
|
*
|
|
108
|
-
*
|
|
109
|
-
* types
|
|
108
|
+
* The first non-nullish value among the sampled rows decides: string columns
|
|
109
|
+
* start ascending so alphabetical order is natural; other value types (or
|
|
110
|
+
* columns with no non-nullish sample) start descending. Sampling past leading
|
|
111
|
+
* nullish values keeps the toggle cycle stable when sorting or a data swap
|
|
112
|
+
* moves an empty value into the first row.
|
|
110
113
|
*
|
|
111
114
|
* @example
|
|
112
115
|
* ```ts
|
|
@@ -114,8 +117,12 @@ function column_getAutoSortFn(column) {
|
|
|
114
117
|
* ```
|
|
115
118
|
*/
|
|
116
119
|
function column_getAutoSortDir(column) {
|
|
117
|
-
const
|
|
118
|
-
|
|
120
|
+
const firstRows = column.table.getFilteredRowModel().flatRows.slice(0, 10);
|
|
121
|
+
for (let i = 0; i < firstRows.length; i++) {
|
|
122
|
+
const value = firstRows[i].getValue(column.id);
|
|
123
|
+
if (value == null) continue;
|
|
124
|
+
return typeof value === "string" ? "asc" : "desc";
|
|
125
|
+
}
|
|
119
126
|
return "desc";
|
|
120
127
|
}
|
|
121
128
|
/**
|
|
@@ -142,8 +149,8 @@ function column_getSortFn(column) {
|
|
|
142
149
|
* Applies the next sorting state for this column.
|
|
143
150
|
*
|
|
144
151
|
* The toggle can add, replace, flip, or remove this column's sort entry. Multi
|
|
145
|
-
* sorting respects `enableMultiSort`, `
|
|
146
|
-
* argument.
|
|
152
|
+
* sorting respects `enableMultiSort`, `enableMultiRemove`,
|
|
153
|
+
* `maxMultiSortColCount`, and the `multi` argument.
|
|
147
154
|
*
|
|
148
155
|
* @example
|
|
149
156
|
* ```ts
|
|
@@ -151,7 +158,7 @@ function column_getSortFn(column) {
|
|
|
151
158
|
* ```
|
|
152
159
|
*/
|
|
153
160
|
function column_toggleSorting(column, desc, multi) {
|
|
154
|
-
const nextSortingOrder = column_getNextSortingOrder(column);
|
|
161
|
+
const nextSortingOrder = column_getNextSortingOrder(column, multi && column_getCanMultiSort(column));
|
|
155
162
|
const hasManualValue = typeof desc !== "undefined";
|
|
156
163
|
table_setSorting(column.table, (old) => {
|
|
157
164
|
const existingIndex = old.findIndex((d) => d.id === column.id);
|
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ import { ColumnHelper, createColumnHelper } from "./helpers/columnHelper.js";
|
|
|
66
66
|
import { metaHelper } from "./helpers/metaHelper.js";
|
|
67
67
|
import { tableFeatures } from "./helpers/tableFeatures.js";
|
|
68
68
|
import { tableOptions } from "./helpers/tableOptions.js";
|
|
69
|
-
import { API, APIObject, PrototypeAPI, PrototypeAPIObject, assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, tableMemo } from "./utils.js";
|
|
69
|
+
import { API, APIObject, PrototypeAPI, PrototypeAPIObject, assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, skipFirstRun, tableMemo } from "./utils.js";
|
|
70
70
|
import { constructCell } from "./core/cells/constructCell.js";
|
|
71
71
|
import { constructColumn } from "./core/columns/constructColumn.js";
|
|
72
72
|
import { buildHeaderGroups } from "./core/headers/buildHeaderGroups.js";
|
|
@@ -82,4 +82,4 @@ import { createGroupedRowModel } from "./features/column-grouping/createGroupedR
|
|
|
82
82
|
import { createExpandedRowModel, expandRows } from "./features/row-expanding/createExpandedRowModel.js";
|
|
83
83
|
import { createPaginatedRowModel } from "./features/row-pagination/createPaginatedRowModel.js";
|
|
84
84
|
import { createSortedRowModel } from "./features/row-sorting/createSortedRowModel.js";
|
|
85
|
-
export { API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationContext, AggregationFnDef, AggregationFnDescriptor, AggregationFnListItem, AggregationFnOption, AggregationFnRef, AggregationFns, AggregationMergeContext, AggregationResult, AggregationResultOf, AggregationValueContext, AggregationValueOptions, AggregationValueResult, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_FeatureMap, Cell, CellContext, CellData, CellSelectionBounds, CellSelectionDirection, CellSelectionEdges, CellSelectionRange, CellSelectionRangeMode, CellSelectionRangeOperation, CellSelectionState, CellSpanIndex, Cell_Cell, Cell_CellSelection, Cell_CellSpanning, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_FeatureMap, Cell_RowAggregation, ColSpanContext, Column, ColumnAggregationValue, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_CellSelection, ColumnDef_CellSpanning, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_FeatureMap, ColumnDef_GlobalFiltering, ColumnDef_RowAggregation, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFiltersState, ColumnHelper, ColumnIndexes, ColumnMeta, ColumnOffsets, ColumnOffsetsByPosition, ColumnOrderDefaultOptions, ColumnOrderState, ColumnPinningDefaultOptions, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnSizingDefaultOptions, ColumnSizingState, ColumnSort, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_FeatureMap, Column_GlobalFiltering, Column_RowAggregation, Column_RowSorting, CoreFeatures, CreatedFilterFn, CreatedSortFn, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractAggregationFnKeys, ExtractColumnMeta, ExtractFeatureMapTypes, ExtractFilterFnKeys, ExtractFilterMeta, ExtractSortFnKeys, ExtractTableMeta, FeatureSlotPrereqs, FilterFn, FilterFnDef, FilterFnOption, FilterFns, FilterMeta, Getter, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_FeatureMap, Header_Header, IdIdentifier, IdentifiedColumnDef, IsAny, NoInfer, NonFeatureKeys, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedAggregationFn, ResolvedColumnFilter, Row, RowData, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_Core, RowModelFns_FeatureMap, RowModelFns_RowAggregation, RowModelFns_RowSorting, RowPinningDefaultOptions, RowPinningPosition, RowPinningState, RowSelectionState, RowSpanContext, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_FeatureMap, Row_Row, Row_RowAggregation, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SelectCellRangeOptions, SortDirection, SortFn, SortFnDef, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_CellSelection, TableOptions_CellSpanning, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_FeatureMap, TableOptions_GlobalFiltering, TableOptions_RowAggregation, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableState, TableState_All, TableState_CellSelection, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_FeatureMap, TableState_GlobalFiltering, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_CellSelection, Table_CellSpanning, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_FeatureMap, Table_GlobalFiltering, Table_Headers, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, ToggleSelectedOptions, TransformDataValueFn, TransformFilterValueFn, UnionToIntersection, Updater, ValidateFeatureSlots, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cellSelectionFeature, cellSpanningFeature, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructAggregationFn, constructCell, constructColumn, constructFilterFn, constructHeader, constructRow, constructSortFn, constructTable, copyInstancePropertiesWithoutMemos, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, globalFilteringFeature, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, metaHelper, reSplitAlphaNumeric, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
|
85
|
+
export { API, APIObject, AccessorColumnDef, AccessorFn, AccessorFnColumnDef, AccessorFnColumnDefBase, AccessorKeyColumnDef, AccessorKeyColumnDefBase, AggregationContext, AggregationFnDef, AggregationFnDescriptor, AggregationFnListItem, AggregationFnOption, AggregationFnRef, AggregationFns, AggregationMergeContext, AggregationResult, AggregationResultOf, AggregationValueContext, AggregationValueOptions, AggregationValueResult, Atoms, Atoms_All, BaseAtoms, BaseAtoms_All, BuiltInAggregationFn, BuiltInFilterFn, BuiltInSortFn, CachedRowModel_All, CachedRowModel_Core, CachedRowModel_Expanded, CachedRowModel_Faceted, CachedRowModel_Filtered, CachedRowModel_Grouped, CachedRowModel_Paginated, CachedRowModel_Sorted, CachedRowModels, CachedRowModels_FeatureMap, Cell, CellContext, CellData, CellSelectionBounds, CellSelectionDirection, CellSelectionEdges, CellSelectionRange, CellSelectionRangeMode, CellSelectionRangeOperation, CellSelectionState, CellSpanIndex, Cell_Cell, Cell_CellSelection, Cell_CellSpanning, Cell_ColumnGrouping, Cell_Core, Cell_CoreProperties, Cell_FeatureMap, Cell_RowAggregation, ColSpanContext, Column, ColumnAggregationValue, ColumnDef, ColumnDefBase, ColumnDefBase_All, ColumnDefResolved, ColumnDefTemplate, ColumnDef_CellSelection, ColumnDef_CellSpanning, ColumnDef_ColumnFiltering, ColumnDef_ColumnGrouping, ColumnDef_ColumnPinning, ColumnDef_ColumnResizing, ColumnDef_ColumnSizing, ColumnDef_ColumnVisibility, ColumnDef_FeatureMap, ColumnDef_GlobalFiltering, ColumnDef_RowAggregation, ColumnDef_RowSorting, ColumnDefaultOptions, ColumnFilter, ColumnFilterAutoRemoveTestFn, ColumnFiltersState, ColumnHelper, ColumnIndexes, ColumnMeta, ColumnOffsets, ColumnOffsetsByPosition, ColumnOrderDefaultOptions, ColumnOrderState, ColumnPinningDefaultOptions, ColumnPinningPosition, ColumnPinningState, ColumnResizeDirection, ColumnResizeMode, ColumnResizingDefaultOptions, ColumnSizingDefaultOptions, ColumnSizingState, ColumnSort, ColumnVisibilityState, Column_Column, Column_ColumnFaceting, Column_ColumnFiltering, Column_ColumnGrouping, Column_ColumnOrdering, Column_ColumnPinning, Column_ColumnResizing, Column_ColumnSizing, Column_ColumnVisibility, Column_Core, Column_CoreProperties, Column_FeatureMap, Column_GlobalFiltering, Column_RowAggregation, Column_RowSorting, CoreFeatures, CreatedFilterFn, CreatedSortFn, CustomAggregationFns, CustomFilterFns, CustomSortFns, DebugOptions, DeepKeys, DeepValue, DisplayColumnDef, ExpandedState, ExpandedStateList, ExternalAtoms, ExternalAtoms_All, ExtractAggregationFnKeys, ExtractColumnMeta, ExtractFeatureMapTypes, ExtractFilterFnKeys, ExtractFilterMeta, ExtractSortFnKeys, ExtractTableMeta, FeatureSlotPrereqs, FilterFn, FilterFnDef, FilterFnOption, FilterFns, FilterMeta, Getter, GroupColumnDef, GroupingColumnMode, GroupingState, Header, HeaderContext, HeaderGroup, HeaderGroup_Core, HeaderGroup_Header, Header_ColumnResizing, Header_ColumnSizing, Header_Core, Header_CoreProperties, Header_FeatureMap, Header_Header, IdIdentifier, IdentifiedColumnDef, IsAny, NoInfer, NonFeatureKeys, OnChangeFn, PaginationDefaultOptions, PaginationState, PartialKeys, Plugins, Prettify, PrototypeAPI, PrototypeAPIObject, RequiredKeys, ResolvedAggregationFn, ResolvedColumnFilter, Row, RowData, RowModel, RowModelFns, RowModelFns_All, RowModelFns_ColumnFiltering, RowModelFns_Core, RowModelFns_FeatureMap, RowModelFns_RowAggregation, RowModelFns_RowSorting, RowPinningDefaultOptions, RowPinningPosition, RowPinningState, RowSelectionState, RowSpanContext, Row_ColumnFiltering, Row_ColumnGrouping, Row_ColumnPinning, Row_ColumnVisibility, Row_Core, Row_CoreProperties, Row_FeatureMap, Row_Row, Row_RowAggregation, Row_RowExpanding, Row_RowPinning, Row_RowSelection, SelectCellRangeOptions, SortDirection, SortFn, SortFnDef, SortFnOption, SortFns, SortingState, StockFeatures, StringHeaderIdentifier, StringOrTemplateHeader, Table, TableFeature, TableFeatures, TableMeta, TableOptions, TableOptions_All, TableOptions_Cell, TableOptions_CellSelection, TableOptions_CellSpanning, TableOptions_ColumnFiltering, TableOptions_ColumnGrouping, TableOptions_ColumnOrdering, TableOptions_ColumnPinning, TableOptions_ColumnResizing, TableOptions_ColumnSizing, TableOptions_ColumnVisibility, TableOptions_Columns, TableOptions_Core, TableOptions_FeatureMap, TableOptions_GlobalFiltering, TableOptions_RowAggregation, TableOptions_RowExpanding, TableOptions_RowPagination, TableOptions_RowPinning, TableOptions_RowSelection, TableOptions_RowSorting, TableOptions_Rows, TableOptions_Table, TableState, TableState_All, TableState_CellSelection, TableState_ColumnFiltering, TableState_ColumnGrouping, TableState_ColumnOrdering, TableState_ColumnPinning, TableState_ColumnResizing, TableState_ColumnSizing, TableState_ColumnVisibility, TableState_FeatureMap, TableState_GlobalFiltering, TableState_RowExpanding, TableState_RowPagination, TableState_RowPinning, TableState_RowSelection, TableState_RowSorting, Table_CellSelection, Table_CellSpanning, Table_ColumnFaceting, Table_ColumnFiltering, Table_ColumnGrouping, Table_ColumnOrdering, Table_ColumnPinning, Table_ColumnResizing, Table_ColumnSizing, Table_ColumnVisibility, Table_Columns, Table_Core, Table_CoreProperties, Table_FeatureMap, Table_GlobalFiltering, Table_Headers, Table_RowExpanding, Table_RowModels, Table_RowModels_Core, Table_RowModels_Expanded, Table_RowModels_Faceted, Table_RowModels_Filtered, Table_RowModels_Grouped, Table_RowModels_Paginated, Table_RowModels_Sorted, Table_RowPagination, Table_RowPinning, Table_RowSelection, Table_RowSorting, Table_Rows, Table_Table, ToggleSelectedOptions, TransformDataValueFn, TransformFilterValueFn, UnionToIntersection, Updater, ValidateFeatureSlots, VisibilityDefaultOptions, aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cellSelectionFeature, cellSpanningFeature, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnResizingState, columnSizingFeature, columnVisibilityFeature, constructAggregationFn, constructCell, constructColumn, constructFilterFn, constructHeader, constructRow, constructSortFn, constructTable, copyInstancePropertiesWithoutMemos, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, globalFilteringFeature, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, metaHelper, reSplitAlphaNumeric, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, skipFirstRun, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, tableMemo } from "./utils.js";
|
|
1
|
+
import { assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, skipFirstRun, tableMemo } from "./utils.js";
|
|
2
2
|
import { coreCellsFeature } from "./core/cells/coreCellsFeature.js";
|
|
3
3
|
import { constructHeader } from "./core/headers/constructHeader.js";
|
|
4
4
|
import { buildHeaderGroups } from "./core/headers/buildHeaderGroups.js";
|
|
@@ -48,4 +48,4 @@ import { createExpandedRowModel, expandRows } from "./features/row-expanding/cre
|
|
|
48
48
|
import { createPaginatedRowModel } from "./features/row-pagination/createPaginatedRowModel.js";
|
|
49
49
|
import { createSortedRowModel } from "./features/row-sorting/createSortedRowModel.js";
|
|
50
50
|
|
|
51
|
-
export { aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cellSelectionFeature, cellSpanningFeature, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, constructAggregationFn, constructCell, constructColumn, constructFilterFn, constructHeader, constructRow, constructSortFn, constructTable, copyInstancePropertiesWithoutMemos, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, globalFilteringFeature, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, metaHelper, reSplitAlphaNumeric, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
|
51
|
+
export { aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, aggregationFns, assignPrototypeAPIs, assignTableAPIs, buildHeaderGroups, callMemoOrStaticFn, cellSelectionFeature, cellSpanningFeature, cloneState, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, constructAggregationFn, constructCell, constructColumn, constructFilterFn, constructHeader, constructRow, constructSortFn, constructTable, copyInstancePropertiesWithoutMemos, coreCellsFeature, coreColumnsFeature, coreFeatures, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createColumnHelper, createCoreRowModel, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, expandRows, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, filterFns, flattenBy, functionalUpdate, getFunctionNameInfo, getInitialTableState, globalFilteringFeature, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, metaHelper, reSplitAlphaNumeric, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, skipFirstRun, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, sortFns, stockFeatures, tableFeatures, tableMemo, tableOptions };
|
package/dist/static-functions.js
CHANGED
|
@@ -5,6 +5,7 @@ import { column_getIndex, column_getIsFirstColumn, column_getIsLastColumn, getDe
|
|
|
5
5
|
import { column_getFlatColumns, column_getLeafColumns, table_getAllColumns, table_getAllFlatColumns, table_getAllFlatColumnsById, table_getAllLeafColumns, table_getAllLeafColumnsById, table_getColumn, table_getDefaultColumnDef } from "./core/columns/coreColumnsFeature.utils.js";
|
|
6
6
|
import { header_getContext, header_getLeafHeaders, table_getFlatHeaders, table_getFooterGroups, table_getHeaderGroups, table_getLeafHeaders } from "./core/headers/coreHeadersFeature.utils.js";
|
|
7
7
|
import { cell_getCanSelect, cell_getIsFocused, cell_getIsSelected, cell_getSelectionEdges, cell_getSelectionExtendHandler, cell_getSelectionStartHandler, cell_getTabIndex, getDefaultCellSelectionState, table_autoResetCellSelection, table_extendCellSelection, table_getCellSelectionBounds, table_getCellSelectionColumnIds, table_getCellSelectionColumnIndexes, table_getCellSelectionMergeBounds, table_getCellSelectionRowIds, table_getFocusedCell, table_getSelectedCellCount, table_getSelectedCellIds, table_getSelectedCellRangesData, table_moveCellSelection, table_resetCellSelection, table_selectAllCells, table_selectCellRange, table_setCellSelection, table_setFocusedCell } from "./features/cell-selection/cellSelectionFeature.utils.js";
|
|
8
|
+
import { getDefaultExpandedState, row_getCanExpand, row_getIsAllParentsExpanded, row_getIsExpanded, row_getToggleExpandedHandler, row_toggleExpanded, table_autoResetExpanded, table_getCanSomeRowsExpand, table_getExpandedDepth, table_getIsAllRowsExpanded, table_getIsSomeRowsExpanded, table_getToggleAllRowsExpandedHandler, table_resetExpanded, table_setExpanded, table_toggleAllRowsExpanded } from "./features/row-expanding/rowExpandingFeature.utils.js";
|
|
8
9
|
import { getDefaultPaginationState, table_autoResetPageIndex, table_firstPage, table_getCanNextPage, table_getCanPreviousPage, table_getPageCount, table_getPageOptions, table_getRowCount, table_lastPage, table_nextPage, table_previousPage, table_resetPageIndex, table_resetPageSize, table_resetPagination, table_setPageIndex, table_setPageSize, table_setPagination } from "./features/row-pagination/rowPaginationFeature.utils.js";
|
|
9
10
|
import { column_clearSorting, column_getAutoSortDir, column_getAutoSortFn, column_getCanMultiSort, column_getCanSort, column_getFirstSortDir, column_getIsSorted, column_getNextSortingOrder, column_getSortFn, column_getSortIndex, column_getToggleSortingHandler, column_toggleSorting, getDefaultSortingState, table_autoResetSorting, table_resetSorting, table_setSorting } from "./features/row-sorting/rowSortingFeature.utils.js";
|
|
10
11
|
import { table_getCoreRowModel, table_getExpandedRowModel, table_getFilteredRowModel, table_getGroupedRowModel, table_getPaginatedRowModel, table_getPreExpandedRowModel, table_getPreFilteredRowModel, table_getPreGroupedRowModel, table_getPrePaginatedRowModel, table_getPreSortedRowModel, table_getRowModel, table_getSortedRowModel } from "./core/row-models/coreRowModelsFeature.utils.js";
|
|
@@ -18,7 +19,6 @@ import { cell_getIsGrouped, cell_getIsPlaceholder, column_getCanGroup, column_ge
|
|
|
18
19
|
import { column_getAfter, column_getSize, column_getStart, column_resetSize, getDefaultColumnSizingColumnDef, getDefaultColumnSizingState, header_getSize, header_getStart, table_getCenterTotalSize, table_getColumnOffsets, table_getEndTotalSize, table_getStartTotalSize, table_getTotalSize, table_resetColumnSizing, table_setColumnSizing } from "./features/column-sizing/columnSizingFeature.utils.js";
|
|
19
20
|
import { column_getCanResize, column_getIsResizing, getDefaultColumnResizingState, header_getResizeHandler, isTouchStartEvent, passiveEventSupported, table_resetHeaderSizeInfo, table_setColumnResizing } from "./features/column-resizing/columnResizingFeature.utils.js";
|
|
20
21
|
import { column_getCanGlobalFilter, table_getGlobalAutoFilterFn, table_getGlobalFilterFn, table_resetGlobalFilter, table_setGlobalFilter } from "./features/global-filtering/globalFilteringFeature.utils.js";
|
|
21
|
-
import { getDefaultExpandedState, row_getCanExpand, row_getIsAllParentsExpanded, row_getIsExpanded, row_getToggleExpandedHandler, row_toggleExpanded, table_autoResetExpanded, table_getCanSomeRowsExpand, table_getExpandedDepth, table_getIsAllRowsExpanded, table_getIsSomeRowsExpanded, table_getToggleAllRowsExpandedHandler, table_resetExpanded, table_setExpanded, table_toggleAllRowsExpanded } from "./features/row-expanding/rowExpandingFeature.utils.js";
|
|
22
22
|
import { getDefaultRowPinningState, row_getCanPin, row_getIsPinned, row_getPinnedIndex, row_pin, table_getBottomRows, table_getCenterRows, table_getIsSomeRowsPinned, table_getTopRows, table_resetRowPinning, table_setRowPinning } from "./features/row-pinning/rowPinningFeature.utils.js";
|
|
23
23
|
import { getDefaultRowSelectionState, isRowSelected, isSubRowSelected, row_getCanMultiSelect, row_getCanSelect, row_getCanSelectSubRows, row_getIsAllSubRowsSelected, row_getIsSelected, row_getIsSomeSelected, row_getToggleSelectedHandler, row_toggleSelected, selectRowsFn, table_getFilteredSelectedRowModel, table_getGroupedSelectedRowModel, table_getIsAllPageRowsSelected, table_getIsAllRowsSelected, table_getIsSomePageRowsSelected, table_getIsSomeRowsSelected, table_getPreSelectedRowModel, table_getSelectedRowIds, table_getSelectedRowModel, table_getToggleAllPageRowsSelectedHandler, table_getToggleAllRowsSelectedHandler, table_resetRowSelection, table_setRowSelection, table_toggleAllPageRowsSelected, table_toggleAllRowsSelected } from "./features/row-selection/rowSelectionFeature.utils.js";
|
|
24
24
|
|
package/dist/utils.d.ts
CHANGED
|
@@ -68,6 +68,15 @@ interface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {
|
|
|
68
68
|
* The memo recomputes only when its dependency tuple changes and can emit debug timing information.
|
|
69
69
|
*/
|
|
70
70
|
declare const memo: <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({ fn, memoDeps, onAfterCompare, onAfterUpdate, onBeforeCompare, onBeforeUpdate }: MemoOptions<TDeps, TDepArgs, TResult>) => ((depArgs?: TDepArgs) => TResult);
|
|
71
|
+
/**
|
|
72
|
+
* Wraps a callback so that its first invocation is skipped.
|
|
73
|
+
*
|
|
74
|
+
* Row-model `onAfterUpdate` hooks schedule auto-resets when their inputs
|
|
75
|
+
* change. The initial computation of a row model is not a change, so state
|
|
76
|
+
* resets must not fire for it — otherwise merely reading a row model on mount
|
|
77
|
+
* would wipe initial or controlled state.
|
|
78
|
+
*/
|
|
79
|
+
declare function skipFirstRun(fn: () => void): () => void;
|
|
71
80
|
interface TableMemoOptions<TFeatures extends TableFeatures, TDeps extends ReadonlyArray<any>, TDepArgs, TResult> extends MemoOptions<TDeps, TDepArgs, TResult> {
|
|
72
81
|
feature?: keyof TFeatures & string;
|
|
73
82
|
fnName: string;
|
|
@@ -117,4 +126,4 @@ declare function assignPrototypeAPIs<TFeatures extends TableFeatures, TData exte
|
|
|
117
126
|
*/
|
|
118
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;
|
|
119
128
|
//#endregion
|
|
120
|
-
export { API, APIObject, PrototypeAPI, PrototypeAPIObject, assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, tableMemo };
|
|
129
|
+
export { API, APIObject, PrototypeAPI, PrototypeAPIObject, assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, skipFirstRun, tableMemo };
|
package/dist/utils.js
CHANGED
|
@@ -122,6 +122,24 @@ const memo = ({ fn, memoDeps, onAfterCompare, onAfterUpdate, onBeforeCompare, on
|
|
|
122
122
|
};
|
|
123
123
|
return memoizedFn;
|
|
124
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* Wraps a callback so that its first invocation is skipped.
|
|
127
|
+
*
|
|
128
|
+
* Row-model `onAfterUpdate` hooks schedule auto-resets when their inputs
|
|
129
|
+
* change. The initial computation of a row model is not a change, so state
|
|
130
|
+
* resets must not fire for it — otherwise merely reading a row model on mount
|
|
131
|
+
* would wipe initial or controlled state.
|
|
132
|
+
*/
|
|
133
|
+
function skipFirstRun(fn) {
|
|
134
|
+
let hasRun = false;
|
|
135
|
+
return () => {
|
|
136
|
+
if (!hasRun) {
|
|
137
|
+
hasRun = true;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
fn();
|
|
141
|
+
};
|
|
142
|
+
}
|
|
125
143
|
const pad = (str, num) => {
|
|
126
144
|
str = String(str);
|
|
127
145
|
while (str.length < num) str = " " + str;
|
|
@@ -249,4 +267,4 @@ function callMemoOrStaticFn(obj, fnKey, staticFn, ...args) {
|
|
|
249
267
|
}
|
|
250
268
|
|
|
251
269
|
//#endregion
|
|
252
|
-
export { assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, tableMemo };
|
|
270
|
+
export { assignPrototypeAPIs, assignTableAPIs, callMemoOrStaticFn, cloneState, copyInstancePropertiesWithoutMemos, flattenBy, functionalUpdate, getFunctionNameInfo, hasOwn, isFunction, makeObjectMap, makeStateUpdater, memo, skipFirstRun, tableMemo };
|
|
@@ -55,6 +55,8 @@ interface TableWorkerBridge {
|
|
|
55
55
|
results: { [K in TableWorkerStage]?: TableWorkerDataPayload; };
|
|
56
56
|
/** Bumped per stage only when that stage's payload actually changed. */
|
|
57
57
|
stageVersions: { [K in TableWorkerStage]?: number; };
|
|
58
|
+
/** The first applied result is not a change; auto-resets skip it. */
|
|
59
|
+
hasAppliedResults: boolean;
|
|
58
60
|
}
|
|
59
61
|
type AnyTable = Table<any, any>;
|
|
60
62
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { table_autoResetPageIndex } from "../features/row-pagination/rowPaginationFeature.utils.js";
|
|
2
1
|
import { table_autoResetExpanded } from "../features/row-expanding/rowExpandingFeature.utils.js";
|
|
2
|
+
import { table_autoResetPageIndex } from "../features/row-pagination/rowPaginationFeature.utils.js";
|
|
3
3
|
import { tableWorkerPipeline, tableWorkerStageStateDeps } from "./tableWorkerProtocol.js";
|
|
4
4
|
|
|
5
5
|
//#region src/worker/createTableWorker.ts
|
|
@@ -59,7 +59,8 @@ function getTableWorkerBridge(tableWorker, table) {
|
|
|
59
59
|
sentStageCount: 0,
|
|
60
60
|
lastState: {},
|
|
61
61
|
results: {},
|
|
62
|
-
stageVersions: {}
|
|
62
|
+
stageVersions: {},
|
|
63
|
+
hasAppliedResults: false
|
|
63
64
|
};
|
|
64
65
|
tableWorker._bridges.set(table, bridge);
|
|
65
66
|
}
|
|
@@ -123,7 +124,9 @@ function handleResult(table, bridge, message) {
|
|
|
123
124
|
lastComputeMs: message.computeMs,
|
|
124
125
|
lastRoundTripMs: roundTripMs
|
|
125
126
|
}));
|
|
126
|
-
|
|
127
|
+
const isFirstAppliedResult = !bridge.hasAppliedResults;
|
|
128
|
+
bridge.hasAppliedResults = true;
|
|
129
|
+
if (anyChanged && !isFirstAppliedResult) table._reactivity.schedule(() => table._reactivity.untrack(() => {
|
|
127
130
|
if (groupedChanged) table_autoResetExpanded(table);
|
|
128
131
|
table_autoResetPageIndex(table);
|
|
129
132
|
}));
|
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.77'
|
|
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.77'
|
|
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