@tanstack/table-core 8.19.2 → 8.19.3
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/build/lib/index.esm.js +8 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +8 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/getGroupedRowModel.d.ts +1 -1
- package/build/lib/utils/getGroupedRowModel.js +8 -1
- package/build/lib/utils/getGroupedRowModel.js.map +1 -1
- package/build/umd/index.development.js +8 -1
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/getGroupedRowModel.ts +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRow } from '../core/row'
|
|
2
|
-
import {
|
|
2
|
+
import { Row, RowData, RowModel, Table } from '../types'
|
|
3
3
|
import { flattenBy, getMemoOptions, memo } from '../utils'
|
|
4
|
+
import { GroupingState } from '../features/ColumnGrouping'
|
|
4
5
|
|
|
5
6
|
export function getGroupedRowModel<TData extends RowData>(): (
|
|
6
7
|
table: Table<TData>
|
|
@@ -10,6 +11,10 @@ export function getGroupedRowModel<TData extends RowData>(): (
|
|
|
10
11
|
() => [table.getState().grouping, table.getPreGroupedRowModel()],
|
|
11
12
|
(grouping, rowModel) => {
|
|
12
13
|
if (!rowModel.rows.length || !grouping.length) {
|
|
14
|
+
rowModel.rows.forEach(row => {
|
|
15
|
+
row.depth = 0
|
|
16
|
+
row.parentId = undefined
|
|
17
|
+
})
|
|
13
18
|
return rowModel
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -53,7 +58,7 @@ export function getGroupedRowModel<TData extends RowData>(): (
|
|
|
53
58
|
// Group the rows together for this level
|
|
54
59
|
const rowGroupsMap = groupBy(rows, columnId)
|
|
55
60
|
|
|
56
|
-
//
|
|
61
|
+
// Perform aggregations for each group
|
|
57
62
|
const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map(
|
|
58
63
|
([groupingValue, groupedRows], index) => {
|
|
59
64
|
let id = `${columnId}:${groupingValue}`
|
|
@@ -62,6 +67,10 @@ export function getGroupedRowModel<TData extends RowData>(): (
|
|
|
62
67
|
// First, Recurse to group sub rows before aggregation
|
|
63
68
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id)
|
|
64
69
|
|
|
70
|
+
subRows.forEach(subRow => {
|
|
71
|
+
subRow.parentId = id
|
|
72
|
+
})
|
|
73
|
+
|
|
65
74
|
// Flatten the leaf rows of the rows in this group
|
|
66
75
|
const leafRows = depth
|
|
67
76
|
? flattenBy(groupedRows, row => row.subRows)
|