@tanstack/table-core 9.0.0-beta.16 → 9.0.0-beta.18
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/cells/constructCell.d.cts +1 -1
- package/dist/core/cells/constructCell.d.ts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.ts +1 -1
- package/dist/core/columns/constructColumn.d.cts +1 -1
- package/dist/core/columns/constructColumn.d.ts +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.ts +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -2
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js +3 -3
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +1 -1
- package/dist/core/headers/buildHeaderGroups.d.ts +1 -1
- package/dist/core/headers/constructHeader.d.cts +1 -1
- package/dist/core/headers/constructHeader.d.ts +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +1 -1
- package/dist/core/row-models/createCoreRowModel.d.ts +1 -1
- package/dist/core/row-models/createCoreRowModel.js +2 -2
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +3 -2
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.d.cts +1 -1
- package/dist/core/rows/constructRow.d.ts +1 -1
- package/dist/core/rows/constructRow.js +4 -2
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.cjs +3 -3
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.js +4 -4
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +2 -2
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
- package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +2 -2
- package/dist/features/column-filtering/createFilteredRowModel.cjs +8 -5
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +9 -6
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.js +3 -2
- package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +3 -3
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +4 -5
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +5 -6
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +2 -2
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +2 -5
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +2 -2
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +2 -2
- package/dist/features/column-resizing/columnResizingFeature.utils.js +3 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -4
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +2 -2
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +2 -2
- package/dist/features/column-sizing/columnSizingFeature.utils.js +12 -5
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +12 -9
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +13 -10
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +2 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +21 -12
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +22 -13
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +15 -12
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +16 -4
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +16 -4
- package/dist/features/row-selection/rowSelectionFeature.utils.js +16 -13
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +2 -2
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/types/Column.d.cts +1 -1
- package/dist/types/Column.d.ts +1 -1
- package/dist/types/TableFeatures.d.cts +1 -1
- package/dist/types/TableFeatures.d.ts +1 -1
- package/dist/utils.cjs +24 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +13 -2
- package/dist/utils.d.ts +13 -2
- package/dist/utils.js +23 -3
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/columns/coreColumnsFeature.utils.ts +3 -3
- package/src/core/row-models/createCoreRowModel.ts +2 -2
- package/src/core/rows/constructRow.ts +3 -2
- package/src/core/rows/coreRowsFeature.utils.ts +4 -4
- package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
- package/src/features/column-filtering/createFilteredRowModel.ts +13 -10
- package/src/features/column-filtering/filterRowsUtils.ts +3 -2
- package/src/features/column-grouping/columnGroupingFeature.ts +2 -1
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -2
- package/src/features/column-grouping/createGroupedRowModel.ts +10 -5
- package/src/features/column-resizing/columnResizingFeature.utils.ts +5 -6
- package/src/features/column-sizing/columnSizingFeature.utils.ts +27 -5
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +31 -15
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
- package/src/features/row-pagination/createPaginatedRowModel.ts +1 -1
- package/src/features/row-selection/rowSelectionFeature.utils.ts +35 -13
- package/src/features/row-sorting/createSortedRowModel.ts +6 -9
- package/src/utils.ts +24 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tableMemo } from '../../utils'
|
|
1
|
+
import { makeObjectMap, tableMemo } from '../../utils'
|
|
2
2
|
import { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'
|
|
3
3
|
import {
|
|
4
4
|
column_getCanGlobalFilter,
|
|
@@ -60,8 +60,8 @@ function _createFilteredRowModel<
|
|
|
60
60
|
>
|
|
61
61
|
for (let i = 0; i < flatRows.length; i++) {
|
|
62
62
|
const row = flatRows[i]!
|
|
63
|
-
row.columnFilters =
|
|
64
|
-
row.columnFiltersMeta =
|
|
63
|
+
row.columnFilters = makeObjectMap()
|
|
64
|
+
row.columnFiltersMeta = makeObjectMap()
|
|
65
65
|
}
|
|
66
66
|
return rowModel
|
|
67
67
|
}
|
|
@@ -115,7 +115,8 @@ function _createFilteredRowModel<
|
|
|
115
115
|
>
|
|
116
116
|
for (let i = 0; i < flatRows.length; i++) {
|
|
117
117
|
const row = flatRows[i]!
|
|
118
|
-
row.columnFilters =
|
|
118
|
+
row.columnFilters = makeObjectMap()
|
|
119
|
+
row.columnFiltersMeta = makeObjectMap()
|
|
119
120
|
|
|
120
121
|
if (resolvedColumnFilters.length) {
|
|
121
122
|
for (let j = 0; j < resolvedColumnFilters.length; j++) {
|
|
@@ -128,9 +129,10 @@ function _createFilteredRowModel<
|
|
|
128
129
|
id,
|
|
129
130
|
currentColumnFilter.resolvedValue,
|
|
130
131
|
(filterMeta) => {
|
|
131
|
-
!row.columnFiltersMeta
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
if (!row.columnFiltersMeta) {
|
|
133
|
+
row.columnFiltersMeta = makeObjectMap()
|
|
134
|
+
}
|
|
135
|
+
row.columnFiltersMeta[id] = filterMeta
|
|
134
136
|
},
|
|
135
137
|
)
|
|
136
138
|
}
|
|
@@ -147,9 +149,10 @@ function _createFilteredRowModel<
|
|
|
147
149
|
id,
|
|
148
150
|
currentGlobalFilter.resolvedValue,
|
|
149
151
|
(filterMeta) => {
|
|
150
|
-
!row.columnFiltersMeta
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
if (!row.columnFiltersMeta) {
|
|
153
|
+
row.columnFiltersMeta = makeObjectMap()
|
|
154
|
+
}
|
|
155
|
+
row.columnFiltersMeta[id] = filterMeta
|
|
153
156
|
},
|
|
154
157
|
)
|
|
155
158
|
) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { constructRow } from '../../core/rows/constructRow'
|
|
2
|
+
import { makeObjectMap } from '../../utils'
|
|
2
3
|
import type { Row_ColumnFiltering } from './columnFilteringFeature.types'
|
|
3
4
|
import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
|
|
4
5
|
import type { Row } from '../../types/Row'
|
|
@@ -37,7 +38,7 @@ function filterRowModelFromLeafs<
|
|
|
37
38
|
table: Table_Internal<TFeatures, TData>,
|
|
38
39
|
): RowModel<TFeatures, TData> {
|
|
39
40
|
const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []
|
|
40
|
-
const newFilteredRowsById
|
|
41
|
+
const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()
|
|
41
42
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100
|
|
42
43
|
|
|
43
44
|
const recurseFilterRows = (
|
|
@@ -109,7 +110,7 @@ function filterRowModelFromRoot<
|
|
|
109
110
|
table: Table_Internal<TFeatures, TData>,
|
|
110
111
|
): RowModel<TFeatures, TData> {
|
|
111
112
|
const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []
|
|
112
|
-
const newFilteredRowsById
|
|
113
|
+
const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()
|
|
113
114
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100
|
|
114
115
|
|
|
115
116
|
// Filters top level and nested rows
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assignPrototypeAPIs,
|
|
3
3
|
assignTableAPIs,
|
|
4
|
+
makeObjectMap,
|
|
4
5
|
makeStateUpdater,
|
|
5
6
|
} from '../../utils'
|
|
6
7
|
import {
|
|
@@ -99,7 +100,7 @@ export const columnGroupingFeature: TableFeature = {
|
|
|
99
100
|
},
|
|
100
101
|
|
|
101
102
|
initRowInstanceData: (row) => {
|
|
102
|
-
;(row as any)._groupingValuesCache =
|
|
103
|
+
;(row as any)._groupingValuesCache = makeObjectMap()
|
|
103
104
|
},
|
|
104
105
|
|
|
105
106
|
constructTableAPIs: (table) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneState, isFunction } from '../../utils'
|
|
1
|
+
import { cloneState, hasOwn, isFunction } from '../../utils'
|
|
2
2
|
import type { Column_Internal } from '../../types/Column'
|
|
3
3
|
import type { CellData, RowData, Updater } from '../../types/type-utils'
|
|
4
4
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
@@ -268,7 +268,7 @@ export function row_getGroupingValue<
|
|
|
268
268
|
TFeatures extends TableFeatures,
|
|
269
269
|
TData extends RowData,
|
|
270
270
|
>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {
|
|
271
|
-
if (row._groupingValuesCache
|
|
271
|
+
if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {
|
|
272
272
|
return row._groupingValuesCache[columnId]
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flattenBy, tableMemo } from '../../utils'
|
|
1
|
+
import { flattenBy, hasOwn, makeObjectMap, tableMemo } from '../../utils'
|
|
2
2
|
import { constructRow } from '../../core/rows/constructRow'
|
|
3
3
|
import { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'
|
|
4
4
|
import { table_autoResetExpanded } from '../row-expanding/rowExpandingFeature.utils'
|
|
@@ -69,7 +69,7 @@ function _createGroupedRowModel<
|
|
|
69
69
|
|
|
70
70
|
const groupedFlatRows: Array<Row<TFeatures, TData>> &
|
|
71
71
|
Partial<Row_ColumnGrouping> = []
|
|
72
|
-
const groupedRowsById
|
|
72
|
+
const groupedRowsById = makeObjectMap<Row<TFeatures, TData>>()
|
|
73
73
|
|
|
74
74
|
// Recursively group the data
|
|
75
75
|
const groupUpRecursively = (
|
|
@@ -135,7 +135,7 @@ function _createGroupedRowModel<
|
|
|
135
135
|
getValue: (colId: string) => {
|
|
136
136
|
// Don't aggregate columns that are in the grouping
|
|
137
137
|
if (existingGrouping.includes(colId)) {
|
|
138
|
-
if (row._valuesCache
|
|
138
|
+
if (hasOwn(row._valuesCache, colId)) {
|
|
139
139
|
return row._valuesCache[colId]
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -147,7 +147,10 @@ function _createGroupedRowModel<
|
|
|
147
147
|
return row._valuesCache[colId]
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
if (
|
|
150
|
+
if (
|
|
151
|
+
row._groupingValuesCache &&
|
|
152
|
+
hasOwn(row._groupingValuesCache, colId)
|
|
153
|
+
) {
|
|
151
154
|
return row._groupingValuesCache[colId]
|
|
152
155
|
}
|
|
153
156
|
|
|
@@ -157,7 +160,9 @@ function _createGroupedRowModel<
|
|
|
157
160
|
column as Column<TFeatures, TData, unknown>,
|
|
158
161
|
)
|
|
159
162
|
|
|
160
|
-
if (!row._groupingValuesCache)
|
|
163
|
+
if (!row._groupingValuesCache) {
|
|
164
|
+
row._groupingValuesCache = makeObjectMap()
|
|
165
|
+
}
|
|
161
166
|
|
|
162
167
|
if (aggregateFn) {
|
|
163
168
|
row._groupingValuesCache[colId] = aggregateFn(
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
header_getSize,
|
|
4
4
|
table_setColumnSizing,
|
|
5
5
|
} from '../column-sizing/columnSizingFeature.utils'
|
|
6
|
-
import { cloneState } from '../../utils'
|
|
6
|
+
import { cloneState, makeObjectMap } from '../../utils'
|
|
7
7
|
import type { CellData, RowData, Updater } from '../../types/type-utils'
|
|
8
8
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
9
9
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -123,7 +123,7 @@ export function header_getResizeHandler<
|
|
|
123
123
|
? Math.round(event.touches[0]!.clientX)
|
|
124
124
|
: (event as MouseEvent).clientX
|
|
125
125
|
|
|
126
|
-
const newColumnSizing: ColumnSizingState =
|
|
126
|
+
const newColumnSizing: ColumnSizingState = makeObjectMap()
|
|
127
127
|
|
|
128
128
|
const updateOffset = (eventType: 'move' | 'end', clientXPos?: number) => {
|
|
129
129
|
if (typeof clientXPos !== 'number') {
|
|
@@ -164,10 +164,9 @@ export function header_getResizeHandler<
|
|
|
164
164
|
column.table.options.columnResizeMode === 'onChange' ||
|
|
165
165
|
eventType === 'end'
|
|
166
166
|
) {
|
|
167
|
-
table_setColumnSizing(column.table, (old) =>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}))
|
|
167
|
+
table_setColumnSizing(column.table, (old) =>
|
|
168
|
+
Object.assign(makeObjectMap<number>(), old, newColumnSizing),
|
|
169
|
+
)
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
|
|
@@ -5,7 +5,12 @@ import {
|
|
|
5
5
|
table_getRightHeaderGroups,
|
|
6
6
|
} from '../column-pinning/columnPinningFeature.utils'
|
|
7
7
|
import { column_getIndex } from '../column-ordering/columnOrderingFeature.utils'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
callMemoOrStaticFn,
|
|
10
|
+
cloneState,
|
|
11
|
+
hasOwn,
|
|
12
|
+
makeObjectMap,
|
|
13
|
+
} from '../../utils'
|
|
9
14
|
import type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'
|
|
10
15
|
import type { CellData, RowData, Updater } from '../../types/type-utils'
|
|
11
16
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
@@ -26,7 +31,7 @@ import type { ColumnSizingState } from './columnSizingFeature.types'
|
|
|
26
31
|
* ```
|
|
27
32
|
*/
|
|
28
33
|
export function getDefaultColumnSizingState(): ColumnSizingState {
|
|
29
|
-
return
|
|
34
|
+
return makeObjectMap()
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
/**
|
|
@@ -66,7 +71,11 @@ export function column_getSize<
|
|
|
66
71
|
TValue extends CellData = CellData,
|
|
67
72
|
>(column: Column_Internal<TFeatures, TData, TValue>): number {
|
|
68
73
|
const defaultSizes = getDefaultColumnSizingColumnDef()
|
|
69
|
-
const
|
|
74
|
+
const columnSizing = column.table.atoms.columnSizing?.get()
|
|
75
|
+
const columnSize =
|
|
76
|
+
columnSizing && hasOwn(columnSizing, column.id)
|
|
77
|
+
? columnSizing[column.id]
|
|
78
|
+
: undefined
|
|
70
79
|
|
|
71
80
|
return Math.min(
|
|
72
81
|
Math.max(
|
|
@@ -174,7 +183,15 @@ export function column_resetSize<
|
|
|
174
183
|
TData extends RowData,
|
|
175
184
|
TValue extends CellData = CellData,
|
|
176
185
|
>(column: Column_Internal<TFeatures, TData, TValue>) {
|
|
177
|
-
table_setColumnSizing(column.table, (
|
|
186
|
+
table_setColumnSizing(column.table, (old) => {
|
|
187
|
+
const rest = makeObjectMap<number>()
|
|
188
|
+
const columnIds = Object.keys(old)
|
|
189
|
+
for (let i = 0; i < columnIds.length; i++) {
|
|
190
|
+
const columnId = columnIds[i]!
|
|
191
|
+
if (columnId !== column.id) {
|
|
192
|
+
rest[columnId] = old[columnId]!
|
|
193
|
+
}
|
|
194
|
+
}
|
|
178
195
|
return rest
|
|
179
196
|
})
|
|
180
197
|
}
|
|
@@ -280,7 +297,12 @@ export function table_resetColumnSizing<
|
|
|
280
297
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
281
298
|
table_setColumnSizing(
|
|
282
299
|
table,
|
|
283
|
-
defaultState
|
|
300
|
+
defaultState
|
|
301
|
+
? makeObjectMap()
|
|
302
|
+
: Object.assign(
|
|
303
|
+
makeObjectMap<number>(),
|
|
304
|
+
cloneState(table.initialState.columnSizing ?? {}),
|
|
305
|
+
),
|
|
284
306
|
)
|
|
285
307
|
}
|
|
286
308
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
callMemoOrStaticFn,
|
|
3
|
+
cloneState,
|
|
4
|
+
hasOwn,
|
|
5
|
+
makeObjectMap,
|
|
6
|
+
} from '../../utils'
|
|
2
7
|
import { getDefaultColumnPinningState } from '../column-pinning/columnPinningFeature.utils'
|
|
3
8
|
import type { CellData, RowData, Updater } from '../../types/type-utils'
|
|
4
9
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
@@ -20,7 +25,7 @@ import type { Row } from '../../types/Row'
|
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
27
|
export function getDefaultColumnVisibilityState(): ColumnVisibilityState {
|
|
23
|
-
return
|
|
28
|
+
return makeObjectMap()
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
/**
|
|
@@ -40,12 +45,13 @@ export function column_toggleVisibility<
|
|
|
40
45
|
TValue extends CellData = CellData,
|
|
41
46
|
>(column: Column_Internal<TFeatures, TData, TValue>, visible?: boolean): void {
|
|
42
47
|
if (column_getCanHide(column)) {
|
|
43
|
-
table_setColumnVisibility(column.table, (old) =>
|
|
44
|
-
|
|
45
|
-
[column.id]
|
|
48
|
+
table_setColumnVisibility(column.table, (old) => {
|
|
49
|
+
const next = Object.assign(makeObjectMap<boolean>(), old)
|
|
50
|
+
next[column.id] =
|
|
46
51
|
visible ??
|
|
47
|
-
!callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
48
|
-
|
|
52
|
+
!callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
53
|
+
return next
|
|
54
|
+
})
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
|
|
@@ -67,12 +73,17 @@ export function column_getIsVisible<
|
|
|
67
73
|
TValue extends CellData = CellData,
|
|
68
74
|
>(column: Column_Internal<TFeatures, TData, TValue>): boolean {
|
|
69
75
|
const childColumns = column.columns
|
|
76
|
+
if (childColumns.length) {
|
|
77
|
+
return childColumns.some((childColumn) =>
|
|
78
|
+
callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const columnVisibility = column.table.atoms.columnVisibility?.get()
|
|
70
83
|
return (
|
|
71
|
-
(
|
|
72
|
-
?
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
: column.table.atoms.columnVisibility?.get()?.[column.id]) ?? true
|
|
84
|
+
(columnVisibility && hasOwn(columnVisibility, column.id)
|
|
85
|
+
? columnVisibility[column.id]
|
|
86
|
+
: undefined) ?? true
|
|
76
87
|
)
|
|
77
88
|
}
|
|
78
89
|
|
|
@@ -192,7 +203,7 @@ export function row_getVisibleCellsByColumnId<
|
|
|
192
203
|
TFeatures extends TableFeatures,
|
|
193
204
|
TData extends RowData,
|
|
194
205
|
>(row: Row<TFeatures, TData>): Record<string, Cell<TFeatures, TData, unknown>> {
|
|
195
|
-
const result
|
|
206
|
+
const result = makeObjectMap<Cell<TFeatures, TData, unknown>>()
|
|
196
207
|
const allCells = row.getAllCells()
|
|
197
208
|
for (let i = 0; i < allCells.length; i++) {
|
|
198
209
|
const cell = allCells[i]!
|
|
@@ -286,7 +297,12 @@ export function table_resetColumnVisibility<
|
|
|
286
297
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
287
298
|
table_setColumnVisibility(
|
|
288
299
|
table,
|
|
289
|
-
defaultState
|
|
300
|
+
defaultState
|
|
301
|
+
? makeObjectMap()
|
|
302
|
+
: Object.assign(
|
|
303
|
+
makeObjectMap<boolean>(),
|
|
304
|
+
cloneState(table.initialState.columnVisibility ?? {}),
|
|
305
|
+
),
|
|
290
306
|
)
|
|
291
307
|
}
|
|
292
308
|
|
|
@@ -306,7 +322,7 @@ export function table_toggleAllColumnsVisible<
|
|
|
306
322
|
>(table: Table_Internal<TFeatures, TData>, value?: boolean) {
|
|
307
323
|
value = value ?? !table_getIsAllColumnsVisible(table)
|
|
308
324
|
|
|
309
|
-
const visibility
|
|
325
|
+
const visibility = makeObjectMap<boolean>()
|
|
310
326
|
const leafColumns = table.getAllLeafColumns()
|
|
311
327
|
for (let i = 0; i < leafColumns.length; i++) {
|
|
312
328
|
const column = leafColumns[i]!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneState } from '../../utils'
|
|
1
|
+
import { cloneState, hasOwn, makeObjectMap } from '../../utils'
|
|
2
2
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
3
3
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
4
4
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export function getDefaultExpandedState(): ExpandedState {
|
|
23
|
-
return
|
|
23
|
+
return makeObjectMap()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -85,7 +85,7 @@ export function table_toggleAllRowsExpanded<
|
|
|
85
85
|
if (expanded ?? !table_getIsAllRowsExpanded(table)) {
|
|
86
86
|
table_setExpanded(table, true)
|
|
87
87
|
} else {
|
|
88
|
-
table_setExpanded(table,
|
|
88
|
+
table_setExpanded(table, makeObjectMap())
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -105,9 +105,17 @@ export function table_resetExpanded<
|
|
|
105
105
|
TFeatures extends TableFeatures,
|
|
106
106
|
TData extends RowData,
|
|
107
107
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
108
|
+
const initialExpanded = table.initialState.expanded
|
|
108
109
|
table_setExpanded(
|
|
109
110
|
table,
|
|
110
|
-
defaultState
|
|
111
|
+
defaultState
|
|
112
|
+
? makeObjectMap()
|
|
113
|
+
: initialExpanded === true
|
|
114
|
+
? true
|
|
115
|
+
: Object.assign(
|
|
116
|
+
makeObjectMap<boolean | undefined>(),
|
|
117
|
+
cloneState(initialExpanded ?? {}),
|
|
118
|
+
),
|
|
111
119
|
)
|
|
112
120
|
}
|
|
113
121
|
|
|
@@ -252,29 +260,34 @@ export function row_toggleExpanded<
|
|
|
252
260
|
TData extends RowData,
|
|
253
261
|
>(row: Row<TFeatures, TData>, expanded?: boolean) {
|
|
254
262
|
table_setExpanded(row.table, (old) => {
|
|
255
|
-
const exists = old === true ? true :
|
|
263
|
+
const exists = old === true ? true : isExpandedRowId(old, row.id)
|
|
256
264
|
|
|
257
|
-
let oldExpanded: ExpandedStateList =
|
|
265
|
+
let oldExpanded: ExpandedStateList = makeObjectMap()
|
|
258
266
|
|
|
259
267
|
if (old === true) {
|
|
260
268
|
Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {
|
|
261
269
|
oldExpanded[rowId] = true
|
|
262
270
|
})
|
|
263
271
|
} else {
|
|
264
|
-
oldExpanded = old
|
|
272
|
+
oldExpanded = Object.assign(makeObjectMap<boolean | undefined>(), old)
|
|
265
273
|
}
|
|
266
274
|
|
|
267
275
|
expanded = expanded ?? !exists
|
|
268
276
|
|
|
269
277
|
if (!exists && expanded) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
[row.id]: true,
|
|
273
|
-
}
|
|
278
|
+
oldExpanded[row.id] = true
|
|
279
|
+
return oldExpanded
|
|
274
280
|
}
|
|
275
281
|
|
|
276
282
|
if (exists && !expanded) {
|
|
277
|
-
const
|
|
283
|
+
const rest: ExpandedStateList = makeObjectMap()
|
|
284
|
+
const rowIds = Object.keys(oldExpanded)
|
|
285
|
+
for (let i = 0; i < rowIds.length; i++) {
|
|
286
|
+
const rowId = rowIds[i]!
|
|
287
|
+
if (rowId !== row.id && oldExpanded[rowId]) {
|
|
288
|
+
rest[rowId] = true
|
|
289
|
+
}
|
|
290
|
+
}
|
|
278
291
|
return rest
|
|
279
292
|
}
|
|
280
293
|
|
|
@@ -301,7 +314,19 @@ export function row_getIsExpanded<
|
|
|
301
314
|
|
|
302
315
|
return !!(
|
|
303
316
|
row.table.options.getIsRowExpanded?.(row) ??
|
|
304
|
-
(expanded === true || expanded
|
|
317
|
+
(expanded === true || isExpandedRowId(expanded, row.id))
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function isExpandedRowId(
|
|
322
|
+
expanded: ExpandedState | undefined,
|
|
323
|
+
rowId: string,
|
|
324
|
+
): boolean {
|
|
325
|
+
return !!(
|
|
326
|
+
expanded &&
|
|
327
|
+
expanded !== true &&
|
|
328
|
+
hasOwn(expanded, rowId) &&
|
|
329
|
+
expanded[rowId]
|
|
305
330
|
)
|
|
306
331
|
}
|
|
307
332
|
|
|
@@ -25,7 +25,7 @@ export function createPaginatedRowModel<
|
|
|
25
25
|
memoDeps: () => [
|
|
26
26
|
table.getPrePaginatedRowModel(),
|
|
27
27
|
table.atoms.pagination?.get(),
|
|
28
|
-
table.options.paginateExpandedRows
|
|
28
|
+
!table.options.paginateExpandedRows
|
|
29
29
|
? table.atoms.expanded?.get()
|
|
30
30
|
: undefined,
|
|
31
31
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneState } from '../../utils'
|
|
1
|
+
import { cloneState, hasOwn, makeObjectMap } from '../../utils'
|
|
2
2
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
3
3
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
4
4
|
import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
|
|
@@ -20,7 +20,7 @@ import type { RowSelectionState } from './rowSelectionFeature.types'
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export function getDefaultRowSelectionState(): RowSelectionState {
|
|
23
|
-
return
|
|
23
|
+
return makeObjectMap()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -62,7 +62,12 @@ export function table_resetRowSelection<
|
|
|
62
62
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
63
63
|
table_setRowSelection(
|
|
64
64
|
table,
|
|
65
|
-
defaultState
|
|
65
|
+
defaultState
|
|
66
|
+
? makeObjectMap()
|
|
67
|
+
: Object.assign(
|
|
68
|
+
makeObjectMap<boolean | undefined>(),
|
|
69
|
+
cloneState(table.initialState.rowSelection ?? {}),
|
|
70
|
+
),
|
|
66
71
|
)
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -87,7 +92,10 @@ export function table_toggleAllRowsSelected<
|
|
|
87
92
|
value =
|
|
88
93
|
typeof value !== 'undefined' ? value : !table_getIsAllRowsSelected(table)
|
|
89
94
|
|
|
90
|
-
const rowSelection =
|
|
95
|
+
const rowSelection = Object.assign(
|
|
96
|
+
makeObjectMap<boolean | undefined>(),
|
|
97
|
+
old,
|
|
98
|
+
)
|
|
91
99
|
|
|
92
100
|
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows
|
|
93
101
|
|
|
@@ -131,7 +139,10 @@ export function table_toggleAllPageRowsSelected<
|
|
|
131
139
|
? value
|
|
132
140
|
: !table_getIsAllPageRowsSelected(table)
|
|
133
141
|
|
|
134
|
-
const rowSelection: RowSelectionState =
|
|
142
|
+
const rowSelection: RowSelectionState = Object.assign(
|
|
143
|
+
makeObjectMap<boolean | undefined>(),
|
|
144
|
+
old,
|
|
145
|
+
)
|
|
135
146
|
|
|
136
147
|
table.getRowModel().rows.forEach((row) => {
|
|
137
148
|
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table)
|
|
@@ -180,7 +191,7 @@ export function table_getSelectedRowModel<
|
|
|
180
191
|
return {
|
|
181
192
|
rows: [],
|
|
182
193
|
flatRows: [],
|
|
183
|
-
rowsById:
|
|
194
|
+
rowsById: makeObjectMap(),
|
|
184
195
|
}
|
|
185
196
|
}
|
|
186
197
|
|
|
@@ -208,7 +219,7 @@ export function table_getFilteredSelectedRowModel<
|
|
|
208
219
|
return {
|
|
209
220
|
rows: [],
|
|
210
221
|
flatRows: [],
|
|
211
|
-
rowsById:
|
|
222
|
+
rowsById: makeObjectMap(),
|
|
212
223
|
}
|
|
213
224
|
}
|
|
214
225
|
|
|
@@ -236,7 +247,7 @@ export function table_getGroupedSelectedRowModel<
|
|
|
236
247
|
return {
|
|
237
248
|
rows: [],
|
|
238
249
|
flatRows: [],
|
|
239
|
-
rowsById:
|
|
250
|
+
rowsById: makeObjectMap(),
|
|
240
251
|
}
|
|
241
252
|
}
|
|
242
253
|
|
|
@@ -268,7 +279,8 @@ export function table_getIsAllRowsSelected<
|
|
|
268
279
|
if (isAllRowsSelected) {
|
|
269
280
|
if (
|
|
270
281
|
preGroupedFlatRows.some(
|
|
271
|
-
(row) =>
|
|
282
|
+
(row) =>
|
|
283
|
+
row_getCanSelect(row) && !isRowIdSelected(rowSelection, row.id),
|
|
272
284
|
)
|
|
273
285
|
) {
|
|
274
286
|
isAllRowsSelected = false
|
|
@@ -301,7 +313,7 @@ export function table_getIsAllPageRowsSelected<
|
|
|
301
313
|
|
|
302
314
|
if (
|
|
303
315
|
isAllPageRowsSelected &&
|
|
304
|
-
paginationFlatRows.some((row) => !rowSelection
|
|
316
|
+
paginationFlatRows.some((row) => !isRowIdSelected(rowSelection, row.id))
|
|
305
317
|
) {
|
|
306
318
|
isAllPageRowsSelected = false
|
|
307
319
|
}
|
|
@@ -434,7 +446,10 @@ export function row_toggleSelected<
|
|
|
434
446
|
return old
|
|
435
447
|
}
|
|
436
448
|
|
|
437
|
-
const selectedRowIds =
|
|
449
|
+
const selectedRowIds = Object.assign(
|
|
450
|
+
makeObjectMap<boolean | undefined>(),
|
|
451
|
+
old,
|
|
452
|
+
)
|
|
438
453
|
|
|
439
454
|
mutateRowIsSelected(
|
|
440
455
|
selectedRowIds,
|
|
@@ -640,7 +655,7 @@ export function selectRowsFn<
|
|
|
640
655
|
TData extends RowData,
|
|
641
656
|
>(rowModel: RowModel<TFeatures, TData>): RowModel<TFeatures, TData> {
|
|
642
657
|
const newSelectedFlatRows: Array<Row<TFeatures, TData>> = []
|
|
643
|
-
const newSelectedRowsById
|
|
658
|
+
const newSelectedRowsById = makeObjectMap<Row<TFeatures, TData>>()
|
|
644
659
|
|
|
645
660
|
// Filters top level and nested rows.
|
|
646
661
|
const recurseRows = (
|
|
@@ -695,7 +710,14 @@ export function isRowSelected<
|
|
|
695
710
|
TFeatures extends TableFeatures,
|
|
696
711
|
TData extends RowData,
|
|
697
712
|
>(row: Row<TFeatures, TData>): boolean {
|
|
698
|
-
return (row.table.atoms.rowSelection?.get()
|
|
713
|
+
return isRowIdSelected(row.table.atoms.rowSelection?.get(), row.id)
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function isRowIdSelected(
|
|
717
|
+
rowSelection: RowSelectionState | undefined,
|
|
718
|
+
rowId: string,
|
|
719
|
+
): boolean {
|
|
720
|
+
return !!(rowSelection && hasOwn(rowSelection, rowId) && rowSelection[rowId])
|
|
699
721
|
}
|
|
700
722
|
|
|
701
723
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tableMemo } from '../../utils'
|
|
1
|
+
import { makeObjectMap, tableMemo } from '../../utils'
|
|
2
2
|
import { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'
|
|
3
3
|
import { column_getCanSort, column_getSortFn } from './rowSortingFeature.utils'
|
|
4
4
|
import type { Column_Internal } from '../../types/Column'
|
|
@@ -57,14 +57,11 @@ function _createSortedRowModel<
|
|
|
57
57
|
),
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
const columnInfoById
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
sortFn: SortFn<TFeatures, TData>
|
|
66
|
-
}
|
|
67
|
-
> = {}
|
|
60
|
+
const columnInfoById = makeObjectMap<{
|
|
61
|
+
sortUndefined?: false | -1 | 1 | 'first' | 'last'
|
|
62
|
+
invertSorting?: boolean
|
|
63
|
+
sortFn: SortFn<TFeatures, TData>
|
|
64
|
+
}>()
|
|
68
65
|
|
|
69
66
|
availableSorting.forEach((sortEntry) => {
|
|
70
67
|
const column: Column_Internal<TFeatures, TData> | undefined =
|
package/src/utils.ts
CHANGED
|
@@ -31,12 +31,17 @@ export function cloneState<T>(value: T): T {
|
|
|
31
31
|
return value
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const copy: Record<string, unknown> = {}
|
|
34
|
+
const copy: Record<string, unknown> = proto === null ? makeObjectMap() : {}
|
|
35
35
|
const keys = Object.keys(value)
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i < keys.length; i++) {
|
|
38
38
|
const key = keys[i]!
|
|
39
|
-
copy
|
|
39
|
+
Object.defineProperty(copy, key, {
|
|
40
|
+
configurable: true,
|
|
41
|
+
enumerable: true,
|
|
42
|
+
value: cloneState((value as Record<string, unknown>)[key]),
|
|
43
|
+
writable: true,
|
|
44
|
+
})
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
return copy as T
|
|
@@ -45,6 +50,23 @@ export function cloneState<T>(value: T): T {
|
|
|
45
50
|
return value
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Creates an object intended only for string-keyed dictionary lookups.
|
|
55
|
+
*
|
|
56
|
+
* The null prototype keeps user-controlled ids such as `__proto__` and
|
|
57
|
+
* `hasOwnProperty` as plain data keys.
|
|
58
|
+
*/
|
|
59
|
+
export function makeObjectMap<TValue = unknown>(): Record<string, TValue> {
|
|
60
|
+
return Object.create(null) as Record<string, TValue>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Checks whether an object owns a key, including null-prototype dictionaries.
|
|
65
|
+
*/
|
|
66
|
+
export function hasOwn(obj: object, key: PropertyKey): boolean {
|
|
67
|
+
return Object.prototype.hasOwnProperty.call(obj, key)
|
|
68
|
+
}
|
|
69
|
+
|
|
48
70
|
/**
|
|
49
71
|
* Creates a table state updater for a single state slice.
|
|
50
72
|
*
|