@tanstack/table-core 9.0.0-beta.61 → 9.0.0-beta.62
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/columns/coreColumnsFeature.utils.js +13 -9
- package/dist/core/headers/buildHeaderGroups.js +93 -83
- package/dist/core/headers/coreHeadersFeature.utils.js +5 -5
- package/dist/features/column-sizing/columnSizingFeature.utils.js +7 -7
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js +19 -19
- package/dist/features/row-selection/rowSelectionFeature.utils.js +22 -22
- 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/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
|
@@ -62,6 +62,18 @@ function table_getDefaultColumnDef(table) {
|
|
|
62
62
|
...table.options.defaultColumn
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
+
function constructColumns(table, columnDefs, parent, depth = 0) {
|
|
66
|
+
const columns = new Array(columnDefs.length);
|
|
67
|
+
for (let i = 0; i < columnDefs.length; i++) {
|
|
68
|
+
if (!(i in columnDefs)) continue;
|
|
69
|
+
const columnDef = columnDefs[i];
|
|
70
|
+
const column = constructColumn(table, columnDef, depth, parent);
|
|
71
|
+
const groupingColumnDef = columnDef;
|
|
72
|
+
column.columns = groupingColumnDef.columns ? constructColumns(table, groupingColumnDef.columns, column, depth + 1) : [];
|
|
73
|
+
columns[i] = column;
|
|
74
|
+
}
|
|
75
|
+
return columns;
|
|
76
|
+
}
|
|
65
77
|
/**
|
|
66
78
|
* Normalizes `options.columns` into the table's nested column tree.
|
|
67
79
|
*
|
|
@@ -74,15 +86,7 @@ function table_getDefaultColumnDef(table) {
|
|
|
74
86
|
* ```
|
|
75
87
|
*/
|
|
76
88
|
function table_getAllColumns(table) {
|
|
77
|
-
|
|
78
|
-
return colDefs.map((columnDef) => {
|
|
79
|
-
const column = constructColumn(table, columnDef, depth, parent);
|
|
80
|
-
const groupingColumnDef = columnDef;
|
|
81
|
-
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
82
|
-
return column;
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
return recurseColumns(table.options.columns);
|
|
89
|
+
return constructColumns(table, table.options.columns);
|
|
86
90
|
}
|
|
87
91
|
/**
|
|
88
92
|
* Flattens every table column, including group columns and leaf columns.
|
|
@@ -3,99 +3,109 @@ import { column_getIsVisible } from "../../features/column-visibility/columnVisi
|
|
|
3
3
|
import { constructHeader } from "./constructHeader.js";
|
|
4
4
|
|
|
5
5
|
//#region src/core/headers/buildHeaderGroups.ts
|
|
6
|
+
function getMaxHeaderDepth(columns, depth = 1) {
|
|
7
|
+
let maxDepth = depth;
|
|
8
|
+
for (let i = 0; i < columns.length; i++) {
|
|
9
|
+
const column = columns[i];
|
|
10
|
+
if (callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible) && column.columns.length) maxDepth = Math.max(maxDepth, getMaxHeaderDepth(column.columns, depth + 1));
|
|
11
|
+
}
|
|
12
|
+
return maxDepth;
|
|
13
|
+
}
|
|
14
|
+
function formatHeaderGroupId(headerFamily, depth) {
|
|
15
|
+
return headerFamily ? `${headerFamily}_${depth}` : String(depth);
|
|
16
|
+
}
|
|
17
|
+
function formatHeaderId(headerFamily, depth, columnId, childHeaderId) {
|
|
18
|
+
let id = headerFamily ?? "";
|
|
19
|
+
if (depth) id = id ? `${id}_${depth}` : String(depth);
|
|
20
|
+
if (columnId) id = id ? `${id}_${columnId}` : columnId;
|
|
21
|
+
if (childHeaderId) id = id ? `${id}_${childHeaderId}` : childHeaderId;
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
24
|
+
function countPendingHeadersForColumn(headers, column) {
|
|
25
|
+
let count = 0;
|
|
26
|
+
for (let i = 0; i < headers.length; i++) if (headers[i].column === column) count++;
|
|
27
|
+
return count;
|
|
28
|
+
}
|
|
29
|
+
function constructHeaderGroup(headersToGroup, depth, table, headerFamily, headerGroups, headerGroupInitFns) {
|
|
30
|
+
const headerGroup = {
|
|
31
|
+
depth,
|
|
32
|
+
id: formatHeaderGroupId(headerFamily, depth),
|
|
33
|
+
headers: []
|
|
34
|
+
};
|
|
35
|
+
const pendingParentHeaders = [];
|
|
36
|
+
for (let i = 0; i < headersToGroup.length; i++) {
|
|
37
|
+
if (!(i in headersToGroup)) continue;
|
|
38
|
+
const headerToGroup = headersToGroup[i];
|
|
39
|
+
const latestPendingParentHeader = pendingParentHeaders[pendingParentHeaders.length - 1];
|
|
40
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
41
|
+
let column;
|
|
42
|
+
let isPlaceholder = false;
|
|
43
|
+
if (isLeafHeader && headerToGroup.column.parent) column = headerToGroup.column.parent;
|
|
44
|
+
else {
|
|
45
|
+
column = headerToGroup.column;
|
|
46
|
+
isPlaceholder = true;
|
|
47
|
+
}
|
|
48
|
+
if (latestPendingParentHeader && latestPendingParentHeader.column === column) latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
49
|
+
else {
|
|
50
|
+
const header = constructHeader(table, column, {
|
|
51
|
+
id: formatHeaderId(headerFamily, depth, column.id, headerToGroup.id),
|
|
52
|
+
isPlaceholder,
|
|
53
|
+
placeholderId: isPlaceholder ? String(countPendingHeadersForColumn(pendingParentHeaders, column)) : void 0,
|
|
54
|
+
depth,
|
|
55
|
+
index: pendingParentHeaders.length
|
|
56
|
+
});
|
|
57
|
+
header.subHeaders.push(headerToGroup);
|
|
58
|
+
pendingParentHeaders.push(header);
|
|
59
|
+
}
|
|
60
|
+
headerGroup.headers.push(headerToGroup);
|
|
61
|
+
headerToGroup.headerGroup = headerGroup;
|
|
62
|
+
}
|
|
63
|
+
for (let i = 0; i < headerGroupInitFns.length; i++) headerGroupInitFns[i](headerGroup);
|
|
64
|
+
headerGroups.push(headerGroup);
|
|
65
|
+
if (depth > 0) constructHeaderGroup(pendingParentHeaders, depth - 1, table, headerFamily, headerGroups, headerGroupInitFns);
|
|
66
|
+
}
|
|
67
|
+
function updateHeaderSpans(headers) {
|
|
68
|
+
for (let i = 0; i < headers.length; i++) {
|
|
69
|
+
const header = headers[i];
|
|
70
|
+
if (!callMemoOrStaticFn(header.column, "getIsVisible", column_getIsVisible)) continue;
|
|
71
|
+
let colSpan = 0;
|
|
72
|
+
let minChildRowSpan = Infinity;
|
|
73
|
+
if (header.subHeaders.length) {
|
|
74
|
+
updateHeaderSpans(header.subHeaders);
|
|
75
|
+
for (let j = 0; j < header.subHeaders.length; j++) {
|
|
76
|
+
const child = header.subHeaders[j];
|
|
77
|
+
if (!callMemoOrStaticFn(child.column, "getIsVisible", column_getIsVisible)) continue;
|
|
78
|
+
colSpan += child.colSpan;
|
|
79
|
+
if (child.rowSpan < minChildRowSpan) minChildRowSpan = child.rowSpan;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
colSpan = 1;
|
|
83
|
+
minChildRowSpan = 0;
|
|
84
|
+
}
|
|
85
|
+
header.colSpan = colSpan;
|
|
86
|
+
header.rowSpan = minChildRowSpan;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
6
89
|
/**
|
|
7
90
|
* Builds the nested header group structure for a table.
|
|
8
91
|
*
|
|
9
92
|
* The result accounts for visible leaf columns, pinned column groups, and placeholder headers needed to render multi-level headers.
|
|
10
93
|
*/
|
|
11
94
|
function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
12
|
-
|
|
13
|
-
const findMaxDepth = (columns, depth = 1) => {
|
|
14
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
15
|
-
for (let i = 0; i < columns.length; i++) {
|
|
16
|
-
const column = columns[i];
|
|
17
|
-
if (callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible)) {
|
|
18
|
-
if (column.columns.length) findMaxDepth(column.columns, depth + 1);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
findMaxDepth(allColumns);
|
|
95
|
+
const maxDepth = getMaxHeaderDepth(allColumns);
|
|
23
96
|
const headerGroups = [];
|
|
24
97
|
const headerGroupInitFns = table._headerGroupInstanceInitFns;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const pendingParentHeaders = [];
|
|
32
|
-
headersToGroup.forEach((headerToGroup) => {
|
|
33
|
-
const latestPendingParentHeader = pendingParentHeaders[pendingParentHeaders.length - 1];
|
|
34
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
35
|
-
let column;
|
|
36
|
-
let isPlaceholder = false;
|
|
37
|
-
if (isLeafHeader && headerToGroup.column.parent) column = headerToGroup.column.parent;
|
|
38
|
-
else {
|
|
39
|
-
column = headerToGroup.column;
|
|
40
|
-
isPlaceholder = true;
|
|
41
|
-
}
|
|
42
|
-
if (latestPendingParentHeader && latestPendingParentHeader.column === column) latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
43
|
-
else {
|
|
44
|
-
const header = constructHeader(table, column, {
|
|
45
|
-
id: [
|
|
46
|
-
headerFamily,
|
|
47
|
-
depth,
|
|
48
|
-
column.id,
|
|
49
|
-
headerToGroup.id
|
|
50
|
-
].filter(Boolean).join("_"),
|
|
51
|
-
isPlaceholder,
|
|
52
|
-
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter((d) => d.column === column).length}` : void 0,
|
|
53
|
-
depth,
|
|
54
|
-
index: pendingParentHeaders.length
|
|
55
|
-
});
|
|
56
|
-
header.subHeaders.push(headerToGroup);
|
|
57
|
-
pendingParentHeaders.push(header);
|
|
58
|
-
}
|
|
59
|
-
headerGroup.headers.push(headerToGroup);
|
|
60
|
-
headerToGroup.headerGroup = headerGroup;
|
|
98
|
+
const bottomHeaders = new Array(columnsToGroup.length);
|
|
99
|
+
for (let i = 0; i < columnsToGroup.length; i++) {
|
|
100
|
+
if (!(i in columnsToGroup)) continue;
|
|
101
|
+
bottomHeaders[i] = constructHeader(table, columnsToGroup[i], {
|
|
102
|
+
depth: maxDepth,
|
|
103
|
+
index: i
|
|
61
104
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (depth > 0) constructHeaderGroup(pendingParentHeaders, depth - 1);
|
|
65
|
-
};
|
|
66
|
-
constructHeaderGroup(columnsToGroup.map((column, index) => constructHeader(table, column, {
|
|
67
|
-
depth: maxDepth,
|
|
68
|
-
index
|
|
69
|
-
})), maxDepth - 1);
|
|
105
|
+
}
|
|
106
|
+
constructHeaderGroup(bottomHeaders, maxDepth - 1, table, headerFamily, headerGroups, headerGroupInitFns);
|
|
70
107
|
headerGroups.reverse();
|
|
71
|
-
|
|
72
|
-
const results = [];
|
|
73
|
-
for (let i = 0; i < headers.length; i++) {
|
|
74
|
-
const header = headers[i];
|
|
75
|
-
if (!callMemoOrStaticFn(header.column, "getIsVisible", column_getIsVisible)) continue;
|
|
76
|
-
let colSpan = 0;
|
|
77
|
-
let minChildRowSpan = Infinity;
|
|
78
|
-
if (header.subHeaders.length) {
|
|
79
|
-
const childSpans = recurseHeadersForSpans(header.subHeaders);
|
|
80
|
-
for (let j = 0; j < childSpans.length; j++) {
|
|
81
|
-
const child = childSpans[j];
|
|
82
|
-
colSpan += child.colSpan;
|
|
83
|
-
if (child.rowSpan < minChildRowSpan) minChildRowSpan = child.rowSpan;
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
colSpan = 1;
|
|
87
|
-
minChildRowSpan = 0;
|
|
88
|
-
}
|
|
89
|
-
header.colSpan = colSpan;
|
|
90
|
-
header.rowSpan = minChildRowSpan;
|
|
91
|
-
results.push({
|
|
92
|
-
colSpan,
|
|
93
|
-
rowSpan: header.rowSpan
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return results;
|
|
97
|
-
};
|
|
98
|
-
recurseHeadersForSpans(headerGroups[0]?.headers ?? []);
|
|
108
|
+
updateHeaderSpans(headerGroups[0]?.headers ?? []);
|
|
99
109
|
return headerGroups;
|
|
100
110
|
}
|
|
101
111
|
|
|
@@ -4,6 +4,10 @@ import { buildHeaderGroups } from "./buildHeaderGroups.js";
|
|
|
4
4
|
import { getDefaultColumnPinningState } from "../../features/column-pinning/columnPinningFeature.utils.js";
|
|
5
5
|
|
|
6
6
|
//#region src/core/headers/coreHeadersFeature.utils.ts
|
|
7
|
+
function collectLeafHeaders(header, leafHeaders) {
|
|
8
|
+
for (let i = 0; i < header.subHeaders.length; i++) collectLeafHeaders(header.subHeaders[i], leafHeaders);
|
|
9
|
+
leafHeaders.push(header);
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
12
|
* Walks a header tree and collects all descendant leaf headers.
|
|
9
13
|
*
|
|
@@ -17,11 +21,7 @@ import { getDefaultColumnPinningState } from "../../features/column-pinning/colu
|
|
|
17
21
|
*/
|
|
18
22
|
function header_getLeafHeaders(header) {
|
|
19
23
|
const leafHeaders = [];
|
|
20
|
-
|
|
21
|
-
if (h.subHeaders.length) h.subHeaders.map(recurseHeader);
|
|
22
|
-
leafHeaders.push(h);
|
|
23
|
-
};
|
|
24
|
-
recurseHeader(header);
|
|
24
|
+
collectLeafHeaders(header, leafHeaders);
|
|
25
25
|
return leafHeaders;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -152,6 +152,12 @@ function column_resetSize(column) {
|
|
|
152
152
|
return rest;
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
+
function sumHeaderSize(header) {
|
|
156
|
+
if (!header.subHeaders.length) return column_getSize(header.column);
|
|
157
|
+
let sum = 0;
|
|
158
|
+
for (let i = 0; i < header.subHeaders.length; i++) sum += sumHeaderSize(header.subHeaders[i]);
|
|
159
|
+
return sum;
|
|
160
|
+
}
|
|
155
161
|
/**
|
|
156
162
|
* Computes a header's rendered size from its leaf headers.
|
|
157
163
|
*
|
|
@@ -164,13 +170,7 @@ function column_resetSize(column) {
|
|
|
164
170
|
* ```
|
|
165
171
|
*/
|
|
166
172
|
function header_getSize(header) {
|
|
167
|
-
|
|
168
|
-
const recurse = (h) => {
|
|
169
|
-
if (h.subHeaders.length) h.subHeaders.forEach(recurse);
|
|
170
|
-
else sum += column_getSize(h.column);
|
|
171
|
-
};
|
|
172
|
-
recurse(header);
|
|
173
|
-
return sum;
|
|
173
|
+
return sumHeaderSize(header);
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Computes a header's offset from the start of its header group.
|
|
@@ -13,6 +13,23 @@ function warn(message) {
|
|
|
13
13
|
function resolveMaxAggregationDepth(maxDepth) {
|
|
14
14
|
return maxDepth === void 0 || Number.isNaN(maxDepth) ? 0 : Math.max(0, Math.floor(maxDepth));
|
|
15
15
|
}
|
|
16
|
+
function collectNormalizedAggregationRow(row, depth, maxDepth, seen, result) {
|
|
17
|
+
if (row.subRows.length && depth < maxDepth) {
|
|
18
|
+
for (let i = 0; i < row.subRows.length; i++) collectNormalizedAggregationRow(row.subRows[i], depth + 1, maxDepth, seen, result);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!seen.has(row.id)) {
|
|
22
|
+
seen.add(row.id);
|
|
23
|
+
result.push(row);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function collectUniqueAggregationRow(row, depth, maxDepth, result) {
|
|
27
|
+
if (row.subRows.length && depth < maxDepth) {
|
|
28
|
+
for (let i = 0; i < row.subRows.length; i++) collectUniqueAggregationRow(row.subRows[i], depth + 1, maxDepth, result);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
result.push(row);
|
|
32
|
+
}
|
|
16
33
|
/**
|
|
17
34
|
* Selects unique rows at a maximum relative depth in encounter order.
|
|
18
35
|
* Branches that end before the requested depth contribute their deepest row.
|
|
@@ -21,17 +38,7 @@ function normalizeAggregationRows(rows, maxDepth = 0) {
|
|
|
21
38
|
const result = [];
|
|
22
39
|
const seen = /* @__PURE__ */ new Set();
|
|
23
40
|
const normalizedMaxDepth = resolveMaxAggregationDepth(maxDepth);
|
|
24
|
-
|
|
25
|
-
if (row.subRows.length && depth < normalizedMaxDepth) {
|
|
26
|
-
for (let i = 0; i < row.subRows.length; i++) visit(row.subRows[i], depth + 1);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (!seen.has(row.id)) {
|
|
30
|
-
seen.add(row.id);
|
|
31
|
-
result.push(row);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
for (let i = 0; i < rows.length; i++) visit(rows[i], 0);
|
|
41
|
+
for (let i = 0; i < rows.length; i++) collectNormalizedAggregationRow(rows[i], 0, normalizedMaxDepth, seen, result);
|
|
35
42
|
return result;
|
|
36
43
|
}
|
|
37
44
|
/**
|
|
@@ -52,14 +59,7 @@ function normalizeUniqueAggregationRows(rows, maxDepth = 0) {
|
|
|
52
59
|
}
|
|
53
60
|
if (!needsDescent) return rows;
|
|
54
61
|
const result = [];
|
|
55
|
-
|
|
56
|
-
if (row.subRows.length && depth < normalizedMaxDepth) {
|
|
57
|
-
for (let i = 0; i < row.subRows.length; i++) visit(row.subRows[i], depth + 1);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
result.push(row);
|
|
61
|
-
};
|
|
62
|
-
for (let i = 0; i < rows.length; i++) visit(rows[i], 0);
|
|
62
|
+
for (let i = 0; i < rows.length; i++) collectUniqueAggregationRow(rows[i], 0, normalizedMaxDepth, result);
|
|
63
63
|
return result;
|
|
64
64
|
}
|
|
65
65
|
function getAutoAggregationFnName(value) {
|
|
@@ -453,6 +453,27 @@ const mutateRowIsSelected = (rowSelection, rowId, value, includeChildren, table)
|
|
|
453
453
|
} else delete rowSelection[rowId];
|
|
454
454
|
if (includeChildren && row.subRows.length && row_getCanSelectSubRows(row)) row.subRows.forEach((r) => mutateRowIsSelected(rowSelection, r.id, value, includeChildren, table));
|
|
455
455
|
};
|
|
456
|
+
function selectRowsRecursively(rows, rowSelection, selectedFlatRows, selectedRowsById) {
|
|
457
|
+
const result = [];
|
|
458
|
+
for (let i = 0; i < rows.length; i++) {
|
|
459
|
+
const row = rows[i];
|
|
460
|
+
const isSelected = isRowSelected(row, rowSelection);
|
|
461
|
+
if (isSelected) {
|
|
462
|
+
selectedFlatRows.push(row);
|
|
463
|
+
selectedRowsById[row.id] = row;
|
|
464
|
+
}
|
|
465
|
+
if (row.subRows.length) {
|
|
466
|
+
const newSubRows = selectRowsRecursively(row.subRows, rowSelection, selectedFlatRows, selectedRowsById);
|
|
467
|
+
if (isSelected) {
|
|
468
|
+
const cloned = Object.create(Object.getPrototypeOf(row));
|
|
469
|
+
copyInstancePropertiesWithoutMemos(cloned, row);
|
|
470
|
+
cloned.subRows = newSubRows;
|
|
471
|
+
result.push(cloned);
|
|
472
|
+
}
|
|
473
|
+
} else if (isSelected) result.push(row);
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
456
477
|
/**
|
|
457
478
|
* Builds a row model containing rows selected by the current row selection state.
|
|
458
479
|
*
|
|
@@ -468,29 +489,8 @@ function selectRowsFn(rowModel, table) {
|
|
|
468
489
|
const newSelectedFlatRows = [];
|
|
469
490
|
const newSelectedRowsById = makeObjectMap();
|
|
470
491
|
const rowSelection = table.atoms.rowSelection?.get() ?? {};
|
|
471
|
-
const recurseRows = (rows, depth = 0) => {
|
|
472
|
-
const result = [];
|
|
473
|
-
for (let i = 0; i < rows.length; i++) {
|
|
474
|
-
const row = rows[i];
|
|
475
|
-
const isSelected = isRowSelected(row, rowSelection);
|
|
476
|
-
if (isSelected) {
|
|
477
|
-
newSelectedFlatRows.push(row);
|
|
478
|
-
newSelectedRowsById[row.id] = row;
|
|
479
|
-
}
|
|
480
|
-
if (row.subRows.length) {
|
|
481
|
-
const newSubRows = recurseRows(row.subRows, depth + 1);
|
|
482
|
-
if (isSelected) {
|
|
483
|
-
const cloned = Object.create(Object.getPrototypeOf(row));
|
|
484
|
-
copyInstancePropertiesWithoutMemos(cloned, row);
|
|
485
|
-
cloned.subRows = newSubRows;
|
|
486
|
-
result.push(cloned);
|
|
487
|
-
}
|
|
488
|
-
} else if (isSelected) result.push(row);
|
|
489
|
-
}
|
|
490
|
-
return result;
|
|
491
|
-
};
|
|
492
492
|
return {
|
|
493
|
-
rows:
|
|
493
|
+
rows: selectRowsRecursively(rowModel.rows, rowSelection, newSelectedFlatRows, newSelectedRowsById),
|
|
494
494
|
flatRows: newSelectedFlatRows,
|
|
495
495
|
rowsById: newSelectedRowsById
|
|
496
496
|
};
|
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.62'
|
|
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.62'
|
|
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