@tanstack/table-core 9.0.0-alpha.33 → 9.0.0-alpha.36

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 (203) hide show
  1. package/dist/core/columns/coreColumnsFeature.cjs +18 -12
  2. package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
  3. package/dist/core/columns/coreColumnsFeature.js +18 -12
  4. package/dist/core/columns/coreColumnsFeature.js.map +1 -1
  5. package/dist/core/headers/coreHeadersFeature.cjs +11 -8
  6. package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
  7. package/dist/core/headers/coreHeadersFeature.js +11 -8
  8. package/dist/core/headers/coreHeadersFeature.js.map +1 -1
  9. package/dist/core/headers/coreHeadersFeature.utils.cjs +2 -1
  10. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  11. package/dist/core/headers/coreHeadersFeature.utils.js +2 -1
  12. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  13. package/dist/core/table/constructTable.cjs +21 -11
  14. package/dist/core/table/constructTable.cjs.map +1 -1
  15. package/dist/core/table/constructTable.d.cts +1 -3
  16. package/dist/core/table/constructTable.d.ts +1 -3
  17. package/dist/core/table/constructTable.js +23 -12
  18. package/dist/core/table/constructTable.js.map +1 -1
  19. package/dist/core/table/coreTablesFeature.types.d.cts +54 -10
  20. package/dist/core/table/coreTablesFeature.types.d.ts +54 -10
  21. package/dist/core/table/coreTablesFeature.utils.cjs +5 -1
  22. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  23. package/dist/core/table/coreTablesFeature.utils.js +6 -2
  24. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  25. package/dist/features/column-faceting/columnFacetingFeature.cjs +18 -12
  26. package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
  27. package/dist/features/column-faceting/columnFacetingFeature.js +18 -12
  28. package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
  29. package/dist/features/column-faceting/createFacetedRowModel.cjs +9 -6
  30. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  31. package/dist/features/column-faceting/createFacetedRowModel.js +9 -6
  32. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  33. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +6 -6
  34. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  35. package/dist/features/column-filtering/columnFilteringFeature.utils.js +7 -7
  36. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  37. package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -6
  38. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  39. package/dist/features/column-filtering/createFilteredRowModel.js +11 -6
  40. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  41. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +6 -6
  42. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  43. package/dist/features/column-grouping/columnGroupingFeature.utils.js +7 -7
  44. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  45. package/dist/features/column-grouping/createGroupedRowModel.cjs +6 -2
  46. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  47. package/dist/features/column-grouping/createGroupedRowModel.js +6 -2
  48. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  49. package/dist/features/column-ordering/columnOrderingFeature.cjs +17 -11
  50. package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
  51. package/dist/features/column-ordering/columnOrderingFeature.js +17 -11
  52. package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
  53. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +8 -5
  54. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  55. package/dist/features/column-ordering/columnOrderingFeature.utils.js +8 -5
  56. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  57. package/dist/features/column-pinning/columnPinningFeature.cjs +72 -45
  58. package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
  59. package/dist/features/column-pinning/columnPinningFeature.js +72 -45
  60. package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
  61. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +27 -16
  62. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  63. package/dist/features/column-pinning/columnPinningFeature.utils.js +28 -17
  64. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  65. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +6 -5
  66. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  67. package/dist/features/column-resizing/columnResizingFeature.utils.js +6 -5
  68. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  69. package/dist/features/column-sizing/columnSizingFeature.cjs +16 -10
  70. package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
  71. package/dist/features/column-sizing/columnSizingFeature.js +16 -10
  72. package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
  73. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +6 -6
  74. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  75. package/dist/features/column-sizing/columnSizingFeature.utils.js +7 -7
  76. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  77. package/dist/features/column-visibility/columnVisibilityFeature.cjs +28 -16
  78. package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
  79. package/dist/features/column-visibility/columnVisibilityFeature.js +28 -16
  80. package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
  81. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +4 -4
  82. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  83. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +5 -5
  84. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  85. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +1 -1
  86. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  87. package/dist/features/global-filtering/globalFilteringFeature.utils.js +2 -2
  88. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  89. package/dist/features/row-expanding/createExpandedRowModel.cjs +10 -6
  90. package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
  91. package/dist/features/row-expanding/createExpandedRowModel.js +10 -6
  92. package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
  93. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +11 -7
  94. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  95. package/dist/features/row-expanding/rowExpandingFeature.utils.js +12 -7
  96. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  97. package/dist/features/row-pagination/createPaginatedRowModel.cjs +10 -6
  98. package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
  99. package/dist/features/row-pagination/createPaginatedRowModel.js +10 -6
  100. package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
  101. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +19 -13
  102. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
  103. package/dist/features/row-pagination/rowPaginationFeature.utils.js +20 -14
  104. package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
  105. package/dist/features/row-pinning/rowPinningFeature.cjs +12 -6
  106. package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
  107. package/dist/features/row-pinning/rowPinningFeature.js +12 -6
  108. package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
  109. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +11 -8
  110. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  111. package/dist/features/row-pinning/rowPinningFeature.utils.js +12 -9
  112. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  113. package/dist/features/row-selection/rowSelectionFeature.cjs +12 -3
  114. package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
  115. package/dist/features/row-selection/rowSelectionFeature.js +12 -3
  116. package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
  117. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +1 -1
  118. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +1 -1
  119. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +17 -9
  120. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  121. package/dist/features/row-selection/rowSelectionFeature.utils.js +18 -9
  122. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  123. package/dist/features/row-sorting/createSortedRowModel.cjs +6 -2
  124. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  125. package/dist/features/row-sorting/createSortedRowModel.js +6 -2
  126. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  127. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +6 -6
  128. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  129. package/dist/features/row-sorting/rowSortingFeature.utils.js +7 -7
  130. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  131. package/dist/features/table-reactivity/tableReactivityFeature.cjs +23 -1
  132. package/dist/features/table-reactivity/tableReactivityFeature.cjs.map +1 -1
  133. package/dist/features/table-reactivity/tableReactivityFeature.js +23 -1
  134. package/dist/features/table-reactivity/tableReactivityFeature.js.map +1 -1
  135. package/dist/flex-render.cjs +19 -0
  136. package/dist/flex-render.cjs.map +1 -0
  137. package/dist/flex-render.d.cts +24 -0
  138. package/dist/flex-render.d.ts +24 -0
  139. package/dist/flex-render.js +16 -0
  140. package/dist/flex-render.js.map +1 -0
  141. package/dist/index.cjs +2 -263
  142. package/dist/index.d.cts +4 -25
  143. package/dist/index.d.ts +4 -25
  144. package/dist/index.js +3 -24
  145. package/dist/static-functions.cjs +261 -0
  146. package/dist/static-functions.d.cts +21 -0
  147. package/dist/static-functions.d.ts +21 -0
  148. package/dist/static-functions.js +22 -0
  149. package/dist/types/Table.d.cts +5 -3
  150. package/dist/types/Table.d.ts +5 -3
  151. package/dist/utils.cjs +14 -6
  152. package/dist/utils.cjs.map +1 -1
  153. package/dist/utils.d.cts +2 -1
  154. package/dist/utils.d.ts +2 -1
  155. package/dist/utils.js +14 -7
  156. package/dist/utils.js.map +1 -1
  157. package/package.json +9 -1
  158. package/src/core/columns/coreColumnsFeature.ts +4 -4
  159. package/src/core/headers/coreHeadersFeature.ts +4 -4
  160. package/src/core/headers/coreHeadersFeature.utils.ts +1 -1
  161. package/src/core/table/constructTable.ts +33 -16
  162. package/src/core/table/coreTablesFeature.types.ts +69 -9
  163. package/src/core/table/coreTablesFeature.utils.ts +8 -2
  164. package/src/features/column-faceting/columnFacetingFeature.ts +4 -4
  165. package/src/features/column-faceting/createFacetedRowModel.ts +2 -2
  166. package/src/features/column-filtering/columnFilteringFeature.utils.ts +9 -8
  167. package/src/features/column-filtering/createFilteredRowModel.ts +4 -3
  168. package/src/features/column-grouping/columnGroupingFeature.utils.ts +5 -5
  169. package/src/features/column-grouping/createGroupedRowModel.ts +2 -2
  170. package/src/features/column-ordering/columnOrderingFeature.ts +5 -5
  171. package/src/features/column-ordering/columnOrderingFeature.utils.ts +6 -5
  172. package/src/features/column-pinning/columnPinningFeature.ts +22 -21
  173. package/src/features/column-pinning/columnPinningFeature.utils.ts +18 -16
  174. package/src/features/column-resizing/columnResizingFeature.utils.ts +9 -4
  175. package/src/features/column-sizing/columnSizingFeature.ts +2 -2
  176. package/src/features/column-sizing/columnSizingFeature.utils.ts +6 -6
  177. package/src/features/column-visibility/columnVisibilityFeature.ts +6 -6
  178. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +4 -4
  179. package/src/features/global-filtering/globalFilteringFeature.utils.ts +2 -2
  180. package/src/features/row-expanding/createExpandedRowModel.ts +2 -2
  181. package/src/features/row-expanding/rowExpandingFeature.utils.ts +8 -7
  182. package/src/features/row-pagination/createPaginatedRowModel.ts +3 -3
  183. package/src/features/row-pagination/rowPaginationFeature.utils.ts +23 -19
  184. package/src/features/row-pinning/rowPinningFeature.ts +4 -4
  185. package/src/features/row-pinning/rowPinningFeature.utils.ts +10 -8
  186. package/src/features/row-selection/rowSelectionFeature.ts +3 -3
  187. package/src/features/row-selection/rowSelectionFeature.types.ts +1 -1
  188. package/src/features/row-selection/rowSelectionFeature.utils.ts +13 -10
  189. package/src/features/row-sorting/createSortedRowModel.ts +5 -2
  190. package/src/features/row-sorting/rowSortingFeature.utils.ts +8 -7
  191. package/src/features/table-reactivity/tableReactivityFeature.ts +46 -1
  192. package/src/flex-render.ts +60 -0
  193. package/src/index.ts +0 -21
  194. package/src/static-functions.ts +31 -0
  195. package/src/types/Table.ts +10 -3
  196. package/src/utils.ts +27 -8
  197. package/dist/helpers/tableHelper.cjs +0 -21
  198. package/dist/helpers/tableHelper.cjs.map +0 -1
  199. package/dist/helpers/tableHelper.d.cts +0 -30
  200. package/dist/helpers/tableHelper.d.ts +0 -30
  201. package/dist/helpers/tableHelper.js +0 -21
  202. package/dist/helpers/tableHelper.js.map +0 -1
  203. package/src/helpers/tableHelper.ts +0 -61
@@ -4,6 +4,7 @@ import {
4
4
  table_setColumnSizing,
5
5
  } from '../column-sizing/columnSizingFeature.utils'
6
6
  import { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'
7
+ import { cloneState } from '../../utils'
7
8
  import type { CellData, RowData, Updater } from '../../types/type-utils'
8
9
  import type { TableFeatures } from '../../types/TableFeatures'
9
10
  import type { Table_Internal } from '../../types/Table'
@@ -13,14 +14,14 @@ import type { ColumnSizingState } from '../column-sizing/columnSizingFeature.typ
13
14
  import type { columnResizingState } from './columnResizingFeature.types'
14
15
 
15
16
  export function getDefaultColumnResizingState(): columnResizingState {
16
- return structuredClone({
17
+ return {
17
18
  startOffset: null,
18
19
  startSize: null,
19
20
  deltaOffset: null,
20
21
  deltaPercentage: null,
21
22
  isResizingColumn: false,
22
23
  columnSizingStart: [],
23
- })
24
+ }
24
25
  }
25
26
 
26
27
  export function column_getCanResize<
@@ -39,7 +40,9 @@ export function column_getIsResizing<
39
40
  TData extends RowData,
40
41
  TValue extends CellData = CellData,
41
42
  >(column: Column_Internal<TFeatures, TData, TValue>) {
42
- return column.table.store.state.columnResizing?.isResizingColumn === column.id
43
+ return (
44
+ column.table.atoms.columnResizing?.get()?.isResizingColumn === column.id
45
+ )
43
46
  }
44
47
 
45
48
  export function header_getResizeHandler<
@@ -237,7 +240,9 @@ export function table_resetHeaderSizeInfo<
237
240
  table,
238
241
  defaultState
239
242
  ? getDefaultColumnResizingState()
240
- : (table.initialState.columnResizing ?? getDefaultColumnResizingState()),
243
+ : cloneState(
244
+ table.initialState.columnResizing ?? getDefaultColumnResizingState(),
245
+ ),
241
246
  )
242
247
  }
243
248
 
@@ -81,7 +81,7 @@ export function constructColumnSizingFeature<
81
81
  table_getPinnedVisibleLeafColumns,
82
82
  position,
83
83
  ),
84
- column.table.store.state.columnSizing,
84
+ column.table.atoms.columnSizing?.get(),
85
85
  ],
86
86
  },
87
87
  column_getAfter: {
@@ -94,7 +94,7 @@ export function constructColumnSizingFeature<
94
94
  table_getPinnedVisibleLeafColumns,
95
95
  position,
96
96
  ),
97
- column.table.store.state.columnSizing,
97
+ column.table.atoms.columnSizing?.get(),
98
98
  ],
99
99
  },
100
100
  column_resetSize: {
@@ -5,7 +5,7 @@ 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 } from '../../utils'
8
+ import { callMemoOrStaticFn, cloneState } from '../../utils'
9
9
  import type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'
10
10
  import type { CellData, RowData, Updater } from '../../types/type-utils'
11
11
  import type { TableFeatures } from '../../types/TableFeatures'
@@ -15,15 +15,15 @@ import type { Column_Internal } from '../../types/Column'
15
15
  import type { ColumnSizingState } from './columnSizingFeature.types'
16
16
 
17
17
  export function getDefaultColumnSizingState(): ColumnSizingState {
18
- return structuredClone({})
18
+ return {}
19
19
  }
20
20
 
21
21
  export function getDefaultColumnSizingColumnDef() {
22
- return structuredClone({
22
+ return {
23
23
  size: 150,
24
24
  minSize: 20,
25
25
  maxSize: Number.MAX_SAFE_INTEGER,
26
- })
26
+ }
27
27
  }
28
28
 
29
29
  export function column_getSize<
@@ -32,7 +32,7 @@ export function column_getSize<
32
32
  TValue extends CellData = CellData,
33
33
  >(column: Column_Internal<TFeatures, TData, TValue>): number {
34
34
  const defaultSizes = getDefaultColumnSizingColumnDef()
35
- const columnSize = column.table.store.state.columnSizing?.[column.id]
35
+ const columnSize = column.table.atoms.columnSizing?.get()?.[column.id]
36
36
 
37
37
  return Math.min(
38
38
  Math.max(
@@ -150,7 +150,7 @@ export function table_resetColumnSizing<
150
150
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
151
151
  table_setColumnSizing(
152
152
  table,
153
- defaultState ? {} : (table.initialState.columnSizing ?? {}),
153
+ defaultState ? {} : cloneState(table.initialState.columnSizing ?? {}),
154
154
  )
155
155
  }
156
156
 
@@ -72,7 +72,7 @@ export function constructColumnVisibilityFeature<
72
72
  fn: (column) => column_getIsVisible(column),
73
73
  memoDeps: (column) => [
74
74
  column.table.options.columns,
75
- column.table.store.state.columnVisibility,
75
+ column.table.atoms.columnVisibility?.get(),
76
76
  column.columns,
77
77
  ],
78
78
  },
@@ -94,7 +94,7 @@ export function constructColumnVisibilityFeature<
94
94
  fn: (row) => row_getAllVisibleCells(row),
95
95
  memoDeps: (row) => [
96
96
  row.getAllCells(),
97
- row.table.store.state.columnVisibility,
97
+ row.table.atoms.columnVisibility?.get(),
98
98
  ],
99
99
  },
100
100
  row_getVisibleCells: {
@@ -114,16 +114,16 @@ export function constructColumnVisibilityFeature<
114
114
  table_getVisibleFlatColumns: {
115
115
  fn: () => table_getVisibleFlatColumns(table),
116
116
  memoDeps: () => [
117
- table.store.state.columnVisibility,
118
- table.store.state.columnOrder,
117
+ table.atoms.columnVisibility?.get(),
118
+ table.atoms.columnOrder?.get(),
119
119
  table.options.columns,
120
120
  ],
121
121
  },
122
122
  table_getVisibleLeafColumns: {
123
123
  fn: () => table_getVisibleLeafColumns(table),
124
124
  memoDeps: () => [
125
- table.store.state.columnVisibility,
126
- table.store.state.columnOrder,
125
+ table.atoms.columnVisibility?.get(),
126
+ table.atoms.columnOrder?.get(),
127
127
  table.options.columns,
128
128
  ],
129
129
  },
@@ -1,4 +1,4 @@
1
- import { callMemoOrStaticFn } from '../../utils'
1
+ import { callMemoOrStaticFn, cloneState } from '../../utils'
2
2
  import type { CellData, RowData, Updater } from '../../types/type-utils'
3
3
  import type { TableFeatures } from '../../types/TableFeatures'
4
4
  import type { Table_Internal } from '../../types/Table'
@@ -8,7 +8,7 @@ import type { ColumnVisibilityState } from './columnVisibilityFeature.types'
8
8
  import type { Row } from '../../types/Row'
9
9
 
10
10
  export function getDefaultColumnVisibilityState(): ColumnVisibilityState {
11
- return structuredClone({})
11
+ return {}
12
12
  }
13
13
 
14
14
  export function column_toggleVisibility<
@@ -37,7 +37,7 @@ export function column_getIsVisible<
37
37
  ? childColumns.some((childColumn) =>
38
38
  callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),
39
39
  )
40
- : column.table.store.state.columnVisibility?.[column.id]) ?? true
40
+ : column.table.atoms.columnVisibility?.get()?.[column.id]) ?? true
41
41
  )
42
42
  }
43
43
 
@@ -125,7 +125,7 @@ export function table_resetColumnVisibility<
125
125
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
126
126
  table_setColumnVisibility(
127
127
  table,
128
- defaultState ? {} : (table.initialState.columnVisibility ?? {}),
128
+ defaultState ? {} : cloneState(table.initialState.columnVisibility ?? {}),
129
129
  )
130
130
  }
131
131
 
@@ -1,5 +1,5 @@
1
1
  import { filterFn_includesString } from '../../fns/filterFns'
2
- import { isFunction } from '../../utils'
2
+ import { cloneState, isFunction } from '../../utils'
3
3
  import type { Column_Internal } from '../../types/Column'
4
4
  import type { FilterFn } from '../column-filtering/columnFilteringFeature.types'
5
5
  import type { CellData, RowData } from '../../types/type-utils'
@@ -55,6 +55,6 @@ export function table_resetGlobalFilter<
55
55
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
56
56
  table_setGlobalFilter(
57
57
  table,
58
- defaultState ? undefined : table.initialState.globalFilter,
58
+ defaultState ? undefined : cloneState(table.initialState.globalFilter),
59
59
  )
60
60
  }
@@ -17,7 +17,7 @@ export function createExpandedRowModel<
17
17
  table,
18
18
  fnName: 'table.getExpandedRowModel',
19
19
  memoDeps: () => [
20
- table.store.state.expanded,
20
+ table.atoms.expanded?.get(),
21
21
  table.getPreExpandedRowModel(),
22
22
  table.options.paginateExpandedRows,
23
23
  ],
@@ -31,7 +31,7 @@ function _createExpandedRowModel<
31
31
  TData extends RowData = any,
32
32
  >(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {
33
33
  const rowModel = table.getPreExpandedRowModel()
34
- const expanded = table.store.state.expanded
34
+ const expanded = table.atoms.expanded?.get()
35
35
 
36
36
  if (
37
37
  !rowModel.rows.length ||
@@ -1,3 +1,4 @@
1
+ import { cloneState } from '../../utils'
1
2
  import type { RowData, Updater } from '../../types/type-utils'
2
3
  import type { TableFeatures } from '../../types/TableFeatures'
3
4
  import type { Table_Internal } from '../../types/Table'
@@ -8,7 +9,7 @@ import type {
8
9
  } from './rowExpandingFeature.types'
9
10
 
10
11
  export function getDefaultExpandedState(): ExpandedState {
11
- return structuredClone({})
12
+ return {}
12
13
  }
13
14
 
14
15
  export function table_autoResetExpanded<
@@ -48,7 +49,7 @@ export function table_resetExpanded<
48
49
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
49
50
  table_setExpanded(
50
51
  table,
51
- defaultState ? {} : (table.initialState.expanded ?? {}),
52
+ defaultState ? {} : cloneState(table.initialState.expanded ?? {}),
52
53
  )
53
54
  }
54
55
 
@@ -75,7 +76,7 @@ export function table_getIsSomeRowsExpanded<
75
76
  TFeatures extends TableFeatures,
76
77
  TData extends RowData,
77
78
  >(table: Table_Internal<TFeatures, TData>) {
78
- const expanded = table.store.state.expanded ?? {}
79
+ const expanded = table.atoms.expanded?.get() ?? {}
79
80
  return expanded === true || Object.values(expanded).some(Boolean)
80
81
  }
81
82
 
@@ -83,7 +84,7 @@ export function table_getIsAllRowsExpanded<
83
84
  TFeatures extends TableFeatures,
84
85
  TData extends RowData,
85
86
  >(table: Table_Internal<TFeatures, TData>) {
86
- const expanded = table.store.state.expanded ?? {}
87
+ const expanded = table.atoms.expanded?.get() ?? {}
87
88
 
88
89
  // If expanded is true, save some cycles and return true
89
90
  if (expanded === true) {
@@ -110,9 +111,9 @@ export function table_getExpandedDepth<
110
111
  let maxDepth = 0
111
112
 
112
113
  const rowIds =
113
- table.store.state.expanded === true
114
+ table.atoms.expanded?.get() === true
114
115
  ? Object.keys(table.getRowModel().rowsById)
115
- : Object.keys(table.store.state.expanded ?? {})
116
+ : Object.keys(table.atoms.expanded?.get() ?? {})
116
117
 
117
118
  rowIds.forEach((id) => {
118
119
  const splitId = id.split('.')
@@ -161,7 +162,7 @@ export function row_getIsExpanded<
161
162
  TFeatures extends TableFeatures,
162
163
  TData extends RowData,
163
164
  >(row: Row<TFeatures, TData>) {
164
- const expanded = row.table.store.state.expanded ?? ({} as ExpandedState)
165
+ const expanded = row.table.atoms.expanded?.get() ?? ({} as ExpandedState)
165
166
 
166
167
  return !!(
167
168
  row.table.options.getIsRowExpanded?.(row) ??
@@ -19,9 +19,9 @@ export function createPaginatedRowModel<
19
19
  fnName: 'table.getPaginatedRowModel',
20
20
  memoDeps: () => [
21
21
  table.getPrePaginatedRowModel(),
22
- table.store.state.pagination,
22
+ table.atoms.pagination?.get(),
23
23
  table.options.paginateExpandedRows
24
- ? table.store.state.expanded
24
+ ? table.atoms.expanded?.get()
25
25
  : undefined,
26
26
  ],
27
27
  fn: () => _createPaginatedRowModel(table),
@@ -34,7 +34,7 @@ function _createPaginatedRowModel<
34
34
  TData extends RowData = any,
35
35
  >(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {
36
36
  const prePaginatedRowModel = table.getPrePaginatedRowModel()
37
- const pagination = table.store.state.pagination
37
+ const pagination = table.atoms.pagination?.get()
38
38
 
39
39
  if (!prePaginatedRowModel.rows.length) {
40
40
  return prePaginatedRowModel
@@ -1,4 +1,4 @@
1
- import { functionalUpdate } from '../../utils'
1
+ import { cloneState, functionalUpdate } 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'
@@ -8,10 +8,10 @@ const defaultPageIndex = 0
8
8
  const defaultPageSize = 10
9
9
 
10
10
  export function getDefaultPaginationState(): PaginationState {
11
- return structuredClone({
11
+ return {
12
12
  pageIndex: defaultPageIndex,
13
13
  pageSize: defaultPageSize,
14
- })
14
+ }
15
15
  }
16
16
 
17
17
  export function table_autoResetPageIndex<
@@ -48,7 +48,9 @@ export function table_resetPagination<
48
48
  table,
49
49
  defaultState
50
50
  ? getDefaultPaginationState()
51
- : (table.initialState.pagination ?? getDefaultPaginationState()),
51
+ : cloneState(
52
+ table.initialState.pagination ?? getDefaultPaginationState(),
53
+ ),
52
54
  )
53
55
  }
54
56
 
@@ -78,24 +80,26 @@ export function table_resetPageIndex<
78
80
  TFeatures extends TableFeatures,
79
81
  TData extends RowData,
80
82
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
81
- table_setPageIndex(
82
- table,
83
- defaultState
84
- ? defaultPageIndex
85
- : (table.initialState.pagination?.pageIndex ?? defaultPageIndex),
86
- )
83
+ const currentPageIndex =
84
+ table.atoms.pagination?.get()?.pageIndex ?? defaultPageIndex
85
+ const newPageIndex = defaultState
86
+ ? defaultPageIndex
87
+ : (table.initialState.pagination?.pageIndex ?? defaultPageIndex)
88
+ if (newPageIndex === currentPageIndex) return
89
+ table_setPageIndex(table, newPageIndex)
87
90
  }
88
91
 
89
92
  export function table_resetPageSize<
90
93
  TFeatures extends TableFeatures,
91
94
  TData extends RowData,
92
95
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
93
- table_setPageSize(
94
- table,
95
- defaultState
96
- ? defaultPageSize
97
- : (table.initialState.pagination?.pageSize ?? defaultPageSize),
98
- )
96
+ const currentPageSize =
97
+ table.atoms.pagination?.get()?.pageSize ?? defaultPageSize
98
+ const newPageSize = defaultState
99
+ ? defaultPageSize
100
+ : (table.initialState.pagination?.pageSize ?? defaultPageSize)
101
+ if (newPageSize === currentPageSize) return
102
+ table_setPageSize(table, newPageSize)
99
103
  }
100
104
 
101
105
  export function table_setPageSize<
@@ -131,14 +135,14 @@ export function table_getCanPreviousPage<
131
135
  TFeatures extends TableFeatures,
132
136
  TData extends RowData,
133
137
  >(table: Table_Internal<TFeatures, TData>) {
134
- return (table.store.state.pagination?.pageIndex ?? 0) > 0
138
+ return (table.atoms.pagination?.get()?.pageIndex ?? 0) > 0
135
139
  }
136
140
 
137
141
  export function table_getCanNextPage<
138
142
  TFeatures extends TableFeatures,
139
143
  TData extends RowData,
140
144
  >(table: Table_Internal<TFeatures, TData>) {
141
- const pageIndex = table.store.state.pagination?.pageIndex ?? defaultPageIndex
145
+ const pageIndex = table.atoms.pagination?.get()?.pageIndex ?? defaultPageIndex
142
146
 
143
147
  const pageCount = table_getPageCount(table)
144
148
 
@@ -191,7 +195,7 @@ export function table_getPageCount<
191
195
  table.options.pageCount ??
192
196
  Math.ceil(
193
197
  table_getRowCount(table) /
194
- (table.store.state.pagination?.pageSize ?? defaultPageSize),
198
+ (table.atoms.pagination?.get()?.pageSize ?? defaultPageSize),
195
199
  )
196
200
  )
197
201
  }
@@ -68,7 +68,7 @@ export function constructRowPinningFeature<
68
68
  fn: (row) => row_getPinnedIndex(row),
69
69
  memoDeps: (row) => [
70
70
  row.table.getRowModel().rows,
71
- row.table.store.state.rowPinning,
71
+ row.table.atoms.rowPinning?.get(),
72
72
  ],
73
73
  },
74
74
  row_pin: {
@@ -93,21 +93,21 @@ export function constructRowPinningFeature<
93
93
  fn: () => table_getTopRows(table),
94
94
  memoDeps: () => [
95
95
  table.getRowModel().rows,
96
- table.store.state.rowPinning?.top,
96
+ table.atoms.rowPinning?.get()?.top,
97
97
  ],
98
98
  },
99
99
  table_getBottomRows: {
100
100
  fn: () => table_getBottomRows(table),
101
101
  memoDeps: () => [
102
102
  table.getRowModel().rows,
103
- table.store.state.rowPinning?.bottom,
103
+ table.atoms.rowPinning?.get()?.bottom,
104
104
  ],
105
105
  },
106
106
  table_getCenterRows: {
107
107
  fn: () => table_getCenterRows(table),
108
108
  memoDeps: () => [
109
109
  table.getRowModel().rows,
110
- table.store.state.rowPinning,
110
+ table.atoms.rowPinning?.get(),
111
111
  ],
112
112
  },
113
113
  })
@@ -1,5 +1,5 @@
1
1
  import { row_getIsAllParentsExpanded } from '../row-expanding/rowExpandingFeature.utils'
2
- import { callMemoOrStaticFn } from '../../utils'
2
+ import { callMemoOrStaticFn, cloneState } from '../../utils'
3
3
  import type { RowData, Updater } from '../../types/type-utils'
4
4
  import type { TableFeatures } from '../../types/TableFeatures'
5
5
  import type { Table_Internal } from '../../types/Table'
@@ -12,10 +12,10 @@ import type {
12
12
  // State Utils
13
13
 
14
14
  export function getDefaultRowPinningState(): RowPinningState {
15
- return structuredClone({
15
+ return {
16
16
  top: [],
17
17
  bottom: [],
18
- })
18
+ }
19
19
  }
20
20
 
21
21
  export function table_setRowPinning<
@@ -36,7 +36,9 @@ export function table_resetRowPinning<
36
36
  table,
37
37
  defaultState
38
38
  ? getDefaultRowPinningState()
39
- : (table.initialState.rowPinning ?? getDefaultRowPinningState()),
39
+ : cloneState(
40
+ table.initialState.rowPinning ?? getDefaultRowPinningState(),
41
+ ),
40
42
  )
41
43
  }
42
44
 
@@ -49,7 +51,7 @@ export function table_getIsSomeRowsPinned<
49
51
  table: Table_Internal<TFeatures, TData>,
50
52
  position?: RowPinningPosition,
51
53
  ): boolean {
52
- const rowPinning = table.store.state.rowPinning
54
+ const rowPinning = table.atoms.rowPinning?.get()
53
55
 
54
56
  if (!position) {
55
57
  return Boolean(rowPinning?.top.length || rowPinning?.bottom.length)
@@ -65,7 +67,7 @@ function table_getPinnedRows<
65
67
  position: 'top' | 'bottom',
66
68
  ): Array<Row<TFeatures, TData>> {
67
69
  const visibleRows = table.getRowModel().rows
68
- const pinnedRowIds = table.store.state.rowPinning?.[position] ?? []
70
+ const pinnedRowIds = table.atoms.rowPinning?.get()?.[position] ?? []
69
71
 
70
72
  const rows =
71
73
  (table.options.keepPinnedRows ?? true)
@@ -107,7 +109,7 @@ export function table_getCenterRows<
107
109
  TData extends RowData,
108
110
  >(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>> {
109
111
  const { top, bottom } =
110
- table.store.state.rowPinning ?? getDefaultRowPinningState()
112
+ table.atoms.rowPinning?.get() ?? getDefaultRowPinningState()
111
113
  const allRows = table.getRowModel().rows
112
114
 
113
115
  const topAndBottom = new Set([...top, ...bottom])
@@ -132,7 +134,7 @@ export function row_getIsPinned<
132
134
  TData extends RowData,
133
135
  >(row: Row<TFeatures, TData>): RowPinningPosition {
134
136
  const { top, bottom } =
135
- row.table.store.state.rowPinning ?? getDefaultRowPinningState()
137
+ row.table.atoms.rowPinning?.get() ?? getDefaultRowPinningState()
136
138
 
137
139
  return top.includes(row.id)
138
140
  ? 'top'
@@ -117,21 +117,21 @@ export function constructRowSelectionFeature<
117
117
  table_getSelectedRowModel: {
118
118
  fn: () => table_getSelectedRowModel(table),
119
119
  memoDeps: () => [
120
- table.store.state.rowSelection,
120
+ table.atoms.rowSelection?.get(),
121
121
  table.getCoreRowModel(),
122
122
  ],
123
123
  },
124
124
  table_getFilteredSelectedRowModel: {
125
125
  fn: () => table_getFilteredSelectedRowModel(table),
126
126
  memoDeps: () => [
127
- table.store.state.rowSelection,
127
+ table.atoms.rowSelection?.get(),
128
128
  table.getFilteredRowModel(),
129
129
  ],
130
130
  },
131
131
  table_getGroupedSelectedRowModel: {
132
132
  fn: () => table_getGroupedSelectedRowModel(table),
133
133
  memoDeps: () => [
134
- table.store.state.rowSelection,
134
+ table.atoms.rowSelection?.get(),
135
135
  table.getSortedRowModel(),
136
136
  ],
137
137
  },
@@ -3,7 +3,7 @@ import type { TableFeatures } from '../../types/TableFeatures'
3
3
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
4
4
  import type { Row } from '../../types/Row'
5
5
 
6
- export type RowSelectionState = Record<string, boolean>
6
+ export type RowSelectionState = Record<string, boolean | undefined>
7
7
 
8
8
  export interface TableState_RowSelection {
9
9
  rowSelection: RowSelectionState
@@ -1,3 +1,4 @@
1
+ import { cloneState } from '../../utils'
1
2
  import type { RowData, Updater } from '../../types/type-utils'
2
3
  import type { TableFeatures } from '../../types/TableFeatures'
3
4
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
@@ -8,7 +9,7 @@ import type { RowSelectionState } from './rowSelectionFeature.types'
8
9
  // State APIs
9
10
 
10
11
  export function getDefaultRowSelectionState(): RowSelectionState {
11
- return structuredClone({})
12
+ return {}
12
13
  }
13
14
 
14
15
  export function table_setRowSelection<
@@ -27,7 +28,7 @@ export function table_resetRowSelection<
27
28
  >(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
28
29
  table_setRowSelection(
29
30
  table,
30
- defaultState ? {} : (table.initialState.rowSelection ?? {}),
31
+ defaultState ? {} : cloneState(table.initialState.rowSelection ?? {}),
31
32
  )
32
33
  }
33
34
 
@@ -97,7 +98,7 @@ export function table_getSelectedRowModel<
97
98
  >(table: Table_Internal<TFeatures, TData>) {
98
99
  const rowModel = table.getCoreRowModel()
99
100
 
100
- if (!Object.keys(table.store.state.rowSelection ?? {}).length) {
101
+ if (!Object.keys(table.atoms.rowSelection?.get() ?? {}).length) {
101
102
  return {
102
103
  rows: [],
103
104
  flatRows: [],
@@ -114,7 +115,7 @@ export function table_getFilteredSelectedRowModel<
114
115
  >(table: Table_Internal<TFeatures, TData>) {
115
116
  const rowModel = table.getCoreRowModel()
116
117
 
117
- if (!Object.keys(table.store.state.rowSelection ?? {}).length) {
118
+ if (!Object.keys(table.atoms.rowSelection?.get() ?? {}).length) {
118
119
  return {
119
120
  rows: [],
120
121
  flatRows: [],
@@ -131,7 +132,7 @@ export function table_getGroupedSelectedRowModel<
131
132
  >(table: Table_Internal<TFeatures, TData>) {
132
133
  const rowModel = table.getCoreRowModel()
133
134
 
134
- if (!Object.keys(table.store.state.rowSelection ?? {}).length) {
135
+ if (!Object.keys(table.atoms.rowSelection?.get() ?? {}).length) {
135
136
  return {
136
137
  rows: [],
137
138
  flatRows: [],
@@ -148,7 +149,7 @@ export function table_getIsAllRowsSelected<
148
149
  >(table: Table_Internal<TFeatures, TData>) {
149
150
  const preGroupedFlatRows = table.getFilteredRowModel().flatRows
150
151
  const rowSelection =
151
- table.store.state.rowSelection ?? ({} as RowSelectionState)
152
+ table.atoms.rowSelection?.get() ?? ({} as RowSelectionState)
152
153
 
153
154
  let isAllRowsSelected = Boolean(
154
155
  preGroupedFlatRows.length && Object.keys(rowSelection).length,
@@ -175,7 +176,7 @@ export function table_getIsAllPageRowsSelected<
175
176
  .getPaginatedRowModel()
176
177
  .flatRows.filter((row) => row_getCanSelect(row))
177
178
  const rowSelection =
178
- table.store.state.rowSelection ?? ({} as RowSelectionState)
179
+ table.atoms.rowSelection?.get() ?? ({} as RowSelectionState)
179
180
 
180
181
  let isAllPageRowsSelected = !!paginationFlatRows.length
181
182
 
@@ -193,7 +194,9 @@ export function table_getIsSomeRowsSelected<
193
194
  TFeatures extends TableFeatures,
194
195
  TData extends RowData,
195
196
  >(table: Table_Internal<TFeatures, TData>) {
196
- const totalSelected = Object.keys(table.store.state.rowSelection ?? {}).length
197
+ const totalSelected = Object.keys(
198
+ table.atoms.rowSelection?.get() ?? {},
199
+ ).length
197
200
  return (
198
201
  totalSelected > 0 &&
199
202
  totalSelected < table.getFilteredRowModel().flatRows.length
@@ -347,7 +350,7 @@ const mutateRowIsSelected = <
347
350
  TFeatures extends TableFeatures,
348
351
  TData extends RowData,
349
352
  >(
350
- selectedRowIds: Record<string, boolean>,
353
+ selectedRowIds: Record<string, boolean | undefined>,
351
354
  rowId: string,
352
355
  value: boolean,
353
356
  includeChildren: boolean,
@@ -419,7 +422,7 @@ export function isRowSelected<
419
422
  TFeatures extends TableFeatures,
420
423
  TData extends RowData,
421
424
  >(row: Row<TFeatures, TData>): boolean {
422
- return (row.table.store.state.rowSelection ?? {})[row.id] ?? false
425
+ return (row.table.atoms.rowSelection?.get() ?? {})[row.id] ?? false
423
426
  }
424
427
 
425
428
  export function isSubRowSelected<
@@ -22,7 +22,10 @@ export function createSortedRowModel<
22
22
  feature: 'rowSortingFeature',
23
23
  table,
24
24
  fnName: 'table.getSortedRowModel',
25
- memoDeps: () => [table.store.state.sorting, table.getPreSortedRowModel()],
25
+ memoDeps: () => [
26
+ table.atoms.sorting?.get(),
27
+ table.getPreSortedRowModel(),
28
+ ],
26
29
  fn: () => _createSortedRowModel(table),
27
30
  onAfterUpdate: () => table_autoResetPageIndex(table),
28
31
  })
@@ -34,7 +37,7 @@ function _createSortedRowModel<
34
37
  TData extends RowData = any,
35
38
  >(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {
36
39
  const preSortedRowModel = table.getPreSortedRowModel()
37
- const sorting = table.store.state.sorting
40
+ const sorting = table.atoms.sorting?.get()
38
41
 
39
42
  if (!preSortedRowModel.rows.length || !sorting?.length) {
40
43
  return preSortedRowModel