@tanstack/table-core 9.0.0-beta.15 → 9.0.0-beta.17

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.
Files changed (160) hide show
  1. package/dist/core/cells/constructCell.d.cts +2 -2
  2. package/dist/core/cells/constructCell.d.ts +2 -2
  3. package/dist/core/cells/coreCellsFeature.types.d.cts +2 -2
  4. package/dist/core/cells/coreCellsFeature.types.d.ts +2 -2
  5. package/dist/core/cells/coreCellsFeature.utils.d.cts +2 -2
  6. package/dist/core/cells/coreCellsFeature.utils.d.ts +2 -2
  7. package/dist/core/columns/constructColumn.d.cts +2 -2
  8. package/dist/core/columns/constructColumn.d.ts +2 -2
  9. package/dist/core/columns/coreColumnsFeature.types.d.cts +2 -2
  10. package/dist/core/columns/coreColumnsFeature.types.d.ts +2 -2
  11. package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -2
  12. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  13. package/dist/core/columns/coreColumnsFeature.utils.d.cts +8 -8
  14. package/dist/core/columns/coreColumnsFeature.utils.d.ts +8 -8
  15. package/dist/core/columns/coreColumnsFeature.utils.js +3 -3
  16. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  17. package/dist/core/headers/buildHeaderGroups.d.cts +2 -2
  18. package/dist/core/headers/buildHeaderGroups.d.ts +2 -2
  19. package/dist/core/headers/constructHeader.d.cts +2 -2
  20. package/dist/core/headers/constructHeader.d.ts +2 -2
  21. package/dist/core/headers/coreHeadersFeature.utils.d.cts +6 -6
  22. package/dist/core/headers/coreHeadersFeature.utils.d.ts +6 -6
  23. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +13 -13
  24. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +13 -13
  25. package/dist/core/row-models/createCoreRowModel.cjs +1 -1
  26. package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
  27. package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
  28. package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
  29. package/dist/core/row-models/createCoreRowModel.js +2 -2
  30. package/dist/core/row-models/createCoreRowModel.js.map +1 -1
  31. package/dist/core/rows/constructRow.cjs +3 -2
  32. package/dist/core/rows/constructRow.cjs.map +1 -1
  33. package/dist/core/rows/constructRow.d.cts +2 -2
  34. package/dist/core/rows/constructRow.d.ts +2 -2
  35. package/dist/core/rows/constructRow.js +4 -2
  36. package/dist/core/rows/constructRow.js.map +1 -1
  37. package/dist/core/rows/coreRowsFeature.types.d.cts +2 -2
  38. package/dist/core/rows/coreRowsFeature.types.d.ts +2 -2
  39. package/dist/core/rows/coreRowsFeature.utils.cjs +3 -3
  40. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  41. package/dist/core/rows/coreRowsFeature.utils.d.cts +3 -3
  42. package/dist/core/rows/coreRowsFeature.utils.d.ts +3 -3
  43. package/dist/core/rows/coreRowsFeature.utils.js +4 -4
  44. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  45. package/dist/core/table/coreTablesFeature.types.d.cts +1 -1
  46. package/dist/core/table/coreTablesFeature.types.d.ts +1 -1
  47. package/dist/core/table/coreTablesFeature.utils.d.cts +5 -5
  48. package/dist/core/table/coreTablesFeature.utils.d.ts +5 -5
  49. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +8 -8
  50. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +8 -8
  51. package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
  52. package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
  53. package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
  54. package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
  55. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +12 -12
  56. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +12 -12
  57. package/dist/features/column-filtering/createFilteredRowModel.cjs +8 -5
  58. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  59. package/dist/features/column-filtering/createFilteredRowModel.js +9 -6
  60. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  61. package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
  62. package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
  63. package/dist/features/column-filtering/filterRowsUtils.js +3 -2
  64. package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
  65. package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -1
  66. package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
  67. package/dist/features/column-grouping/columnGroupingFeature.js +2 -2
  68. package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
  69. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +3 -3
  70. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  71. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +11 -11
  72. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +11 -11
  73. package/dist/features/column-grouping/columnGroupingFeature.utils.js +4 -4
  74. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  75. package/dist/features/column-grouping/createGroupedRowModel.cjs +4 -5
  76. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  77. package/dist/features/column-grouping/createGroupedRowModel.js +5 -6
  78. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  79. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +9 -9
  80. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +9 -9
  81. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +29 -29
  82. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +29 -29
  83. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +2 -5
  84. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  85. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +6 -6
  86. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +6 -6
  87. package/dist/features/column-resizing/columnResizingFeature.utils.js +3 -6
  88. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  89. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -4
  90. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  91. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +12 -12
  92. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +12 -12
  93. package/dist/features/column-sizing/columnSizingFeature.utils.js +12 -5
  94. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  95. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +12 -9
  96. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  97. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +14 -14
  98. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +14 -14
  99. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +13 -10
  100. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  101. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +6 -6
  102. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +6 -6
  103. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +21 -12
  104. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  105. package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +10 -10
  106. package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +10 -10
  107. package/dist/features/row-expanding/rowExpandingFeature.utils.js +22 -13
  108. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  109. package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +17 -17
  110. package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +17 -17
  111. package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +7 -7
  112. package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +7 -7
  113. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +15 -12
  114. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  115. package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +27 -15
  116. package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +27 -15
  117. package/dist/features/row-selection/rowSelectionFeature.utils.js +16 -13
  118. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  119. package/dist/features/row-sorting/createSortedRowModel.cjs +1 -1
  120. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  121. package/dist/features/row-sorting/createSortedRowModel.js +2 -2
  122. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  123. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +16 -16
  124. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +16 -16
  125. package/dist/index.cjs +2 -0
  126. package/dist/index.d.cts +4 -4
  127. package/dist/index.d.ts +4 -4
  128. package/dist/index.js +2 -2
  129. package/dist/types/Column.d.cts +2 -4
  130. package/dist/types/Column.d.ts +2 -4
  131. package/dist/types/Table.d.cts +3 -16
  132. package/dist/types/Table.d.ts +3 -16
  133. package/dist/types/TableFeatures.d.cts +7 -7
  134. package/dist/types/TableFeatures.d.ts +7 -7
  135. package/dist/utils.cjs +24 -2
  136. package/dist/utils.cjs.map +1 -1
  137. package/dist/utils.d.cts +16 -5
  138. package/dist/utils.d.ts +16 -5
  139. package/dist/utils.js +23 -3
  140. package/dist/utils.js.map +1 -1
  141. package/package.json +2 -2
  142. package/src/core/columns/coreColumnsFeature.utils.ts +3 -3
  143. package/src/core/headers/coreHeadersFeature.types.ts +2 -2
  144. package/src/core/row-models/createCoreRowModel.ts +2 -2
  145. package/src/core/rows/constructRow.ts +3 -2
  146. package/src/core/rows/coreRowsFeature.utils.ts +4 -4
  147. package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
  148. package/src/features/column-filtering/createFilteredRowModel.ts +13 -10
  149. package/src/features/column-filtering/filterRowsUtils.ts +3 -2
  150. package/src/features/column-grouping/columnGroupingFeature.ts +2 -1
  151. package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -2
  152. package/src/features/column-grouping/createGroupedRowModel.ts +10 -5
  153. package/src/features/column-resizing/columnResizingFeature.utils.ts +5 -6
  154. package/src/features/column-sizing/columnSizingFeature.utils.ts +27 -5
  155. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +31 -15
  156. package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
  157. package/src/features/row-selection/rowSelectionFeature.utils.ts +35 -13
  158. package/src/features/row-sorting/createSortedRowModel.ts +6 -9
  159. package/src/types/Column.ts +3 -1
  160. package/src/utils.ts +24 -2
@@ -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 {
@@ -69,8 +70,8 @@ export const columnFilteringFeature: TableFeature = {
69
70
  },
70
71
 
71
72
  initRowInstanceData: (row) => {
72
- ;(row as any).columnFilters = {}
73
- ;(row as any).columnFiltersMeta = {}
73
+ ;(row as any).columnFilters = makeObjectMap()
74
+ ;(row as any).columnFiltersMeta = makeObjectMap()
74
75
  },
75
76
 
76
77
  constructTableAPIs: (table) => {
@@ -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
- ? (row.columnFiltersMeta = {})
133
- : (row.columnFiltersMeta[id] = filterMeta)
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
- ? (row.columnFiltersMeta = {})
152
- : (row.columnFiltersMeta[id] = filterMeta)
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: Record<string, Row<TFeatures, TData>> = {}
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: Record<string, Row<TFeatures, TData>> = {}
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?.hasOwnProperty(columnId)) {
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: Record<string, Row<TFeatures, TData>> = {}
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.hasOwnProperty(colId)) {
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 (row._groupingValuesCache?.hasOwnProperty(colId)) {
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) 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
- ...old,
169
- ...newColumnSizing,
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 { callMemoOrStaticFn, cloneState } from '../../utils'
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 columnSize = column.table.atoms.columnSizing?.get()?.[column.id]
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, ({ [column.id]: _, ...rest }) => {
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 ? {} : cloneState(table.initialState.columnSizing ?? {}),
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 { callMemoOrStaticFn, cloneState } from '../../utils'
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
- ...old,
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
- (childColumns.length
72
- ? childColumns.some((childColumn) =>
73
- callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),
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: Record<string, Cell<TFeatures, TData, unknown>> = {}
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 ? {} : cloneState(table.initialState.columnVisibility ?? {}),
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: Record<string, boolean> = {}
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 ? {} : cloneState(table.initialState.expanded ?? {}),
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 : !!old[row.id]
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
- return {
271
- ...oldExpanded,
272
- [row.id]: true,
273
- }
278
+ oldExpanded[row.id] = true
279
+ return oldExpanded
274
280
  }
275
281
 
276
282
  if (exists && !expanded) {
277
- const { [row.id]: _, ...rest } = oldExpanded
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[row.id])
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
 
@@ -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 ? {} : cloneState(table.initialState.rowSelection ?? {}),
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 = { ...old }
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 = { ...old }
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) => row_getCanSelect(row) && !rowSelection[row.id],
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[row.id])
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 = { ...old }
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: Record<string, Row<TFeatures, TData>> = {}
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() ?? {})[row.id] ?? false
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: Record<
61
- string,
62
- {
63
- sortUndefined?: false | -1 | 1 | 'first' | 'last'
64
- invertSorting?: boolean
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 =
@@ -1,3 +1,4 @@
1
+ import type { Table_Internal } from './Table'
1
2
  import type { Column_RowSorting } from '../features/row-sorting/rowSortingFeature.types'
2
3
  import type { Column_ColumnFaceting } from '../features/column-faceting/columnFacetingFeature.types'
3
4
  import type { Column_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types'
@@ -46,6 +47,7 @@ export interface Column_Internal<
46
47
  in out TFeatures extends TableFeatures,
47
48
  in out TData extends RowData,
48
49
  TValue = unknown,
49
- > extends Omit<Column_Core<TFeatures, TData, TValue>, 'columnDef'> {
50
+ > extends Omit<Column_Core<TFeatures, TData, TValue>, 'columnDef' | 'table'> {
50
51
  columnDef: ColumnDefBase_All<TFeatures, TData, TValue>
52
+ table: Table_Internal<TFeatures, TData>
51
53
  }