@tanstack/table-core 8.0.0-beta.4 → 8.0.0-beta.7
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/features/Expanding.js +4 -7
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Grouping.js +2 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/RowSelection.js +4 -4
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +19 -5
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +30 -19
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +316 -316
- package/build/types/features/RowSelection.d.ts +2 -2
- package/build/umd/index.development.js +30 -19
- 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/features/Expanding.ts +4 -8
- package/src/features/Grouping.ts +2 -2
- package/src/features/RowSelection.ts +8 -6
- package/src/features/Sorting.ts +1 -3
- package/src/utils/getPaginationRowModel.ts +21 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-beta.
|
|
4
|
+
"version": "8.0.0-beta.7",
|
|
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",
|
|
@@ -63,7 +63,6 @@ export const Expanding: TableFeature = {
|
|
|
63
63
|
): ExpandedOptions<TGenerics> => {
|
|
64
64
|
return {
|
|
65
65
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
66
|
-
autoResetExpanded: true,
|
|
67
66
|
paginateExpandedRows: true,
|
|
68
67
|
}
|
|
69
68
|
},
|
|
@@ -83,13 +82,10 @@ export const Expanding: TableFeature = {
|
|
|
83
82
|
return
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
if (instance.options.autoResetAll === false) {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
85
|
if (
|
|
91
|
-
instance.options.autoResetAll
|
|
92
|
-
instance.options.autoResetExpanded
|
|
86
|
+
instance.options.autoResetAll ??
|
|
87
|
+
instance.options.autoResetExpanded ??
|
|
88
|
+
!instance.options.manualExpanding
|
|
93
89
|
) {
|
|
94
90
|
if (queued) return
|
|
95
91
|
queued = true
|
|
@@ -160,7 +156,7 @@ export const Expanding: TableFeature = {
|
|
|
160
156
|
|
|
161
157
|
return maxDepth
|
|
162
158
|
},
|
|
163
|
-
getPreExpandedRowModel: () => instance.
|
|
159
|
+
getPreExpandedRowModel: () => instance.getSortedRowModel(),
|
|
164
160
|
getExpandedRowModel: () => {
|
|
165
161
|
if (
|
|
166
162
|
!instance._getExpandedRowModel &&
|
package/src/features/Grouping.ts
CHANGED
|
@@ -214,7 +214,7 @@ export const Grouping: TableFeature = {
|
|
|
214
214
|
)
|
|
215
215
|
},
|
|
216
216
|
|
|
217
|
-
getPreGroupedRowModel: () => instance.
|
|
217
|
+
getPreGroupedRowModel: () => instance.getFilteredRowModel(),
|
|
218
218
|
getGroupedRowModel: () => {
|
|
219
219
|
if (
|
|
220
220
|
!instance._getGroupedRowModel &&
|
|
@@ -258,7 +258,7 @@ export const Grouping: TableFeature = {
|
|
|
258
258
|
getIsAggregated: () =>
|
|
259
259
|
!cell.getIsGrouped() &&
|
|
260
260
|
!cell.getIsPlaceholder() &&
|
|
261
|
-
row.subRows?.length
|
|
261
|
+
!!row.subRows?.length,
|
|
262
262
|
renderAggregatedCell: () => {
|
|
263
263
|
if (process.env.NODE_ENV === 'development') {
|
|
264
264
|
if (!column.columnDef.aggregatedCell) {
|
|
@@ -58,8 +58,8 @@ export type RowSelectionInstance<TGenerics extends TableGenerics> = {
|
|
|
58
58
|
getIsAllPageRowsSelected: () => boolean
|
|
59
59
|
getIsSomeRowsSelected: () => boolean
|
|
60
60
|
getIsSomePageRowsSelected: () => boolean
|
|
61
|
-
toggleAllRowsSelected: (value
|
|
62
|
-
toggleAllPageRowsSelected: (value
|
|
61
|
+
toggleAllRowsSelected: (value?: boolean) => void
|
|
62
|
+
toggleAllPageRowsSelected: (value?: boolean) => void
|
|
63
63
|
getPreSelectedRowModel: () => RowModel<TGenerics>
|
|
64
64
|
getSelectedRowModel: () => RowModel<TGenerics>
|
|
65
65
|
getFilteredSelectedRowModel: () => RowModel<TGenerics>
|
|
@@ -128,7 +128,7 @@ export const RowSelection: TableFeature = {
|
|
|
128
128
|
},
|
|
129
129
|
toggleAllPageRowsSelected: value =>
|
|
130
130
|
instance.setRowSelection(old => {
|
|
131
|
-
const
|
|
131
|
+
const resolvedValue =
|
|
132
132
|
typeof value !== 'undefined'
|
|
133
133
|
? value
|
|
134
134
|
: !instance.getIsAllPageRowsSelected()
|
|
@@ -136,7 +136,7 @@ export const RowSelection: TableFeature = {
|
|
|
136
136
|
const rowSelection: RowSelectionState = { ...old }
|
|
137
137
|
|
|
138
138
|
instance.getRowModel().rows.forEach(row => {
|
|
139
|
-
mutateRowIsSelected(rowSelection, row.id,
|
|
139
|
+
mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance)
|
|
140
140
|
})
|
|
141
141
|
|
|
142
142
|
return rowSelection
|
|
@@ -245,7 +245,7 @@ export const RowSelection: TableFeature = {
|
|
|
245
245
|
),
|
|
246
246
|
|
|
247
247
|
getGroupedSelectedRowModel: memo(
|
|
248
|
-
() => [instance.getState().rowSelection, instance.
|
|
248
|
+
() => [instance.getState().rowSelection, instance.getSortedRowModel()],
|
|
249
249
|
(rowSelection, rowModel) => {
|
|
250
250
|
if (!Object.keys(rowSelection).length) {
|
|
251
251
|
return {
|
|
@@ -325,7 +325,9 @@ export const RowSelection: TableFeature = {
|
|
|
325
325
|
const paginationFlatRows = instance.getPaginationRowModel().flatRows
|
|
326
326
|
return instance.getIsAllPageRowsSelected()
|
|
327
327
|
? false
|
|
328
|
-
:
|
|
328
|
+
: paginationFlatRows.some(
|
|
329
|
+
d => d.getIsSelected() || d.getIsSomeSelected()
|
|
330
|
+
)
|
|
329
331
|
},
|
|
330
332
|
|
|
331
333
|
getToggleAllRowsSelectedHandler: () => {
|
package/src/features/Sorting.ts
CHANGED
|
@@ -345,8 +345,6 @@ export const Sorting: TableFeature = {
|
|
|
345
345
|
createInstance: <TGenerics extends TableGenerics>(
|
|
346
346
|
instance: TableInstance<TGenerics>
|
|
347
347
|
): SortingInstance<TGenerics> => {
|
|
348
|
-
let registered = false
|
|
349
|
-
|
|
350
348
|
return {
|
|
351
349
|
setSorting: updater => instance.options.onSortingChange?.(updater),
|
|
352
350
|
resetSorting: defaultState => {
|
|
@@ -354,7 +352,7 @@ export const Sorting: TableFeature = {
|
|
|
354
352
|
defaultState ? [] : instance.initialState?.sorting ?? []
|
|
355
353
|
)
|
|
356
354
|
},
|
|
357
|
-
getPreSortedRowModel: () => instance.
|
|
355
|
+
getPreSortedRowModel: () => instance.getGroupedRowModel(),
|
|
358
356
|
getSortedRowModel: () => {
|
|
359
357
|
if (
|
|
360
358
|
!instance._getSortedRowModel &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TableInstance, RowModel, TableGenerics } from '../types'
|
|
1
|
+
import { TableInstance, RowModel, TableGenerics, Row } from '../types'
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
import { expandRows } from './getExpandedRowModel'
|
|
4
4
|
|
|
@@ -23,8 +23,10 @@ export function getPaginationRowModel<TGenerics extends TableGenerics>(opts?: {
|
|
|
23
23
|
|
|
24
24
|
rows = rows.slice(pageStart, pageEnd)
|
|
25
25
|
|
|
26
|
+
let paginatedRowModel: RowModel<TGenerics>
|
|
27
|
+
|
|
26
28
|
if (!instance.options.paginateExpandedRows) {
|
|
27
|
-
|
|
29
|
+
paginatedRowModel = expandRows(
|
|
28
30
|
{
|
|
29
31
|
rows,
|
|
30
32
|
flatRows,
|
|
@@ -32,13 +34,26 @@ export function getPaginationRowModel<TGenerics extends TableGenerics>(opts?: {
|
|
|
32
34
|
},
|
|
33
35
|
instance
|
|
34
36
|
)
|
|
37
|
+
} else {
|
|
38
|
+
paginatedRowModel = {
|
|
39
|
+
rows,
|
|
40
|
+
flatRows,
|
|
41
|
+
rowsById,
|
|
42
|
+
}
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
paginatedRowModel.flatRows = []
|
|
46
|
+
|
|
47
|
+
const handleRow = (row: Row<TGenerics>) => {
|
|
48
|
+
paginatedRowModel.flatRows.push(row)
|
|
49
|
+
if (row.subRows.length) {
|
|
50
|
+
row.subRows.forEach(handleRow)
|
|
51
|
+
}
|
|
41
52
|
}
|
|
53
|
+
|
|
54
|
+
paginatedRowModel.rows.forEach(handleRow)
|
|
55
|
+
|
|
56
|
+
return paginatedRowModel
|
|
42
57
|
},
|
|
43
58
|
{
|
|
44
59
|
key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
|