@tanstack/table-core 8.5.8 → 8.5.11
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/cjs/utils/getExpandedRowModel.js +7 -3
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +1 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +8 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +312 -312
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +8 -4
- 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/types.ts +1 -1
- package/src/utils/getExpandedRowModel.ts +7 -7
- package/src/utils/getPaginationRowModel.ts +12 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.5.
|
|
4
|
+
"version": "8.5.11",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
package/src/types.ts
CHANGED
|
@@ -242,7 +242,7 @@ export type AccessorKeyColumnDef<TData extends RowData, TValue = unknown> = {
|
|
|
242
242
|
id?: string
|
|
243
243
|
} & Partial<ColumnIdentifiers<TData, TValue>> &
|
|
244
244
|
ColumnDefBase<TData, TValue> & {
|
|
245
|
-
accessorKey:
|
|
245
|
+
accessorKey: string | keyof TData
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
export type AccessorColumnDef<TData extends RowData, TValue = unknown> =
|
|
@@ -14,14 +14,17 @@ export function getExpandedRowModel<TData extends RowData>(): (
|
|
|
14
14
|
(expanded, rowModel, paginateExpandedRows) => {
|
|
15
15
|
if (
|
|
16
16
|
!rowModel.rows.length ||
|
|
17
|
-
// Do not expand if rows are not included in pagination
|
|
18
|
-
!paginateExpandedRows ||
|
|
19
17
|
(expanded !== true && !Object.keys(expanded ?? {}).length)
|
|
20
18
|
) {
|
|
21
19
|
return rowModel
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
if (!paginateExpandedRows) {
|
|
23
|
+
// Only expand rows at this point if they are being paginated
|
|
24
|
+
return rowModel
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return expandRows(rowModel)
|
|
25
28
|
},
|
|
26
29
|
{
|
|
27
30
|
key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
|
|
@@ -30,10 +33,7 @@ export function getExpandedRowModel<TData extends RowData>(): (
|
|
|
30
33
|
)
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
export function expandRows<TData extends RowData>(
|
|
34
|
-
rowModel: RowModel<TData>,
|
|
35
|
-
table: Table<TData>
|
|
36
|
-
) {
|
|
36
|
+
export function expandRows<TData extends RowData>(rowModel: RowModel<TData>) {
|
|
37
37
|
const expandedRows: Row<TData>[] = []
|
|
38
38
|
|
|
39
39
|
const handleRow = (row: Row<TData>) => {
|
|
@@ -7,7 +7,13 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
|
|
|
7
7
|
}): (table: Table<TData>) => () => RowModel<TData> {
|
|
8
8
|
return table =>
|
|
9
9
|
memo(
|
|
10
|
-
() => [
|
|
10
|
+
() => [
|
|
11
|
+
table.getState().pagination,
|
|
12
|
+
table.getPrePaginationRowModel(),
|
|
13
|
+
table.options.paginateExpandedRows
|
|
14
|
+
? undefined
|
|
15
|
+
: table.getState().expanded,
|
|
16
|
+
],
|
|
11
17
|
(pagination, rowModel) => {
|
|
12
18
|
if (!rowModel.rows.length) {
|
|
13
19
|
return rowModel
|
|
@@ -23,14 +29,11 @@ export function getPaginationRowModel<TData extends RowData>(opts?: {
|
|
|
23
29
|
let paginatedRowModel: RowModel<TData>
|
|
24
30
|
|
|
25
31
|
if (!table.options.paginateExpandedRows) {
|
|
26
|
-
paginatedRowModel = expandRows(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
table
|
|
33
|
-
)
|
|
32
|
+
paginatedRowModel = expandRows({
|
|
33
|
+
rows,
|
|
34
|
+
flatRows,
|
|
35
|
+
rowsById,
|
|
36
|
+
})
|
|
34
37
|
} else {
|
|
35
38
|
paginatedRowModel = {
|
|
36
39
|
rows,
|