@tanstack/table-core 9.0.0-alpha.46 → 9.0.0-alpha.48

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 (339) hide show
  1. package/README.md +10 -0
  2. package/dist/core/cells/constructCell.cjs +4 -3
  3. package/dist/core/cells/constructCell.cjs.map +1 -1
  4. package/dist/core/cells/constructCell.js +4 -3
  5. package/dist/core/cells/constructCell.js.map +1 -1
  6. package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
  7. package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
  8. package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
  9. package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
  10. package/dist/core/cells/coreCellsFeature.utils.js +11 -8
  11. package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
  12. package/dist/core/columns/constructColumn.cjs +6 -4
  13. package/dist/core/columns/constructColumn.cjs.map +1 -1
  14. package/dist/core/columns/constructColumn.js +6 -4
  15. package/dist/core/columns/constructColumn.js.map +1 -1
  16. package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
  17. package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
  18. package/dist/core/columns/coreColumnsFeature.utils.cjs +47 -29
  19. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  20. package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
  21. package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
  22. package/dist/core/columns/coreColumnsFeature.utils.js +47 -29
  23. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  24. package/dist/core/headers/buildHeaderGroups.cjs +27 -19
  25. package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
  26. package/dist/core/headers/buildHeaderGroups.js +27 -19
  27. package/dist/core/headers/buildHeaderGroups.js.map +1 -1
  28. package/dist/core/headers/constructHeader.cjs +4 -3
  29. package/dist/core/headers/constructHeader.cjs.map +1 -1
  30. package/dist/core/headers/constructHeader.js +4 -3
  31. package/dist/core/headers/constructHeader.js.map +1 -1
  32. package/dist/core/headers/coreHeadersFeature.cjs +1 -6
  33. package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
  34. package/dist/core/headers/coreHeadersFeature.js +2 -7
  35. package/dist/core/headers/coreHeadersFeature.js.map +1 -1
  36. package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
  37. package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
  38. package/dist/core/headers/coreHeadersFeature.utils.cjs +43 -36
  39. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  40. package/dist/core/headers/coreHeadersFeature.utils.d.cts +24 -19
  41. package/dist/core/headers/coreHeadersFeature.utils.d.ts +24 -19
  42. package/dist/core/headers/coreHeadersFeature.utils.js +44 -37
  43. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  44. package/dist/core/reactivity/coreReactivityFeature.types.d.cts +4 -0
  45. package/dist/core/reactivity/coreReactivityFeature.types.d.ts +4 -0
  46. package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
  47. package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
  48. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
  49. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
  50. package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
  51. package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
  52. package/dist/core/rows/constructRow.cjs +8 -6
  53. package/dist/core/rows/constructRow.cjs.map +1 -1
  54. package/dist/core/rows/constructRow.js +8 -6
  55. package/dist/core/rows/constructRow.js.map +1 -1
  56. package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
  57. package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
  58. package/dist/core/rows/coreRowsFeature.utils.cjs +43 -32
  59. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  60. package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
  61. package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
  62. package/dist/core/rows/coreRowsFeature.utils.js +43 -32
  63. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  64. package/dist/core/table/constructTable.cjs +9 -5
  65. package/dist/core/table/constructTable.cjs.map +1 -1
  66. package/dist/core/table/constructTable.js +9 -5
  67. package/dist/core/table/constructTable.js.map +1 -1
  68. package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
  69. package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
  70. package/dist/core/table/coreTablesFeature.utils.cjs +7 -3
  71. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  72. package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
  73. package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
  74. package/dist/core/table/coreTablesFeature.utils.js +7 -3
  75. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  76. package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
  77. package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
  78. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
  79. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
  80. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
  81. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
  82. package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
  83. package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
  84. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +8 -5
  85. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
  86. package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
  87. package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
  88. package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -3
  89. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  90. package/dist/features/column-faceting/createFacetedRowModel.js +8 -3
  91. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  92. package/dist/features/column-faceting/createFacetedUniqueValues.cjs +7 -4
  93. package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
  94. package/dist/features/column-faceting/createFacetedUniqueValues.js +7 -4
  95. package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
  96. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
  97. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
  98. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
  99. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  100. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
  101. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
  102. package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
  103. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  104. package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -5
  105. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  106. package/dist/features/column-filtering/createFilteredRowModel.js +11 -5
  107. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  108. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
  109. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
  110. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
  111. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  112. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
  113. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
  114. package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
  115. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  116. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
  117. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
  118. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +46 -29
  119. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  120. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
  121. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
  122. package/dist/features/column-ordering/columnOrderingFeature.utils.js +46 -29
  123. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  124. package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
  125. package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
  126. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +152 -115
  127. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  128. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +116 -95
  129. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +116 -95
  130. package/dist/features/column-pinning/columnPinningFeature.utils.js +153 -116
  131. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  132. package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
  133. package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
  134. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
  135. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  136. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
  137. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
  138. package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
  139. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  140. package/dist/features/column-sizing/columnSizingFeature.cjs +28 -4
  141. package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
  142. package/dist/features/column-sizing/columnSizingFeature.js +28 -4
  143. package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
  144. package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
  145. package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
  146. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
  147. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  148. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
  149. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
  150. package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
  151. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  152. package/dist/features/column-visibility/columnVisibilityFeature.cjs +23 -14
  153. package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
  154. package/dist/features/column-visibility/columnVisibilityFeature.js +24 -15
  155. package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
  156. package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +19 -12
  157. package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +19 -12
  158. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +91 -52
  159. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  160. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +63 -40
  161. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +63 -40
  162. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +91 -53
  163. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  164. package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
  165. package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
  166. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
  167. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  168. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
  169. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
  170. package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
  171. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  172. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
  173. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
  174. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +58 -43
  175. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  176. package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
  177. package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
  178. package/dist/features/row-expanding/rowExpandingFeature.utils.js +58 -43
  179. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  180. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
  181. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
  182. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
  183. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
  184. package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
  185. package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
  186. package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
  187. package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
  188. package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
  189. package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
  190. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +52 -36
  191. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  192. package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
  193. package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
  194. package/dist/features/row-pinning/rowPinningFeature.utils.js +52 -36
  195. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  196. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
  197. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
  198. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +95 -72
  199. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  200. package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
  201. package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
  202. package/dist/features/row-selection/rowSelectionFeature.utils.js +95 -72
  203. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  204. package/dist/features/row-sorting/createSortedRowModel.cjs +13 -8
  205. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  206. package/dist/features/row-sorting/createSortedRowModel.js +13 -8
  207. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  208. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
  209. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
  210. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +63 -46
  211. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  212. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
  213. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
  214. package/dist/features/row-sorting/rowSortingFeature.utils.js +63 -46
  215. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  216. package/dist/fns/aggregationFns.cjs +47 -16
  217. package/dist/fns/aggregationFns.cjs.map +1 -1
  218. package/dist/fns/aggregationFns.d.cts +33 -9
  219. package/dist/fns/aggregationFns.d.ts +33 -9
  220. package/dist/fns/aggregationFns.js +47 -17
  221. package/dist/fns/aggregationFns.js.map +1 -1
  222. package/dist/fns/filterFns.cjs +48 -17
  223. package/dist/fns/filterFns.cjs.map +1 -1
  224. package/dist/fns/filterFns.d.cts +42 -15
  225. package/dist/fns/filterFns.d.ts +42 -15
  226. package/dist/fns/filterFns.js +48 -17
  227. package/dist/fns/filterFns.js.map +1 -1
  228. package/dist/helpers/columnHelper.cjs +9 -4
  229. package/dist/helpers/columnHelper.cjs.map +1 -1
  230. package/dist/helpers/columnHelper.d.cts +9 -4
  231. package/dist/helpers/columnHelper.d.ts +9 -4
  232. package/dist/helpers/columnHelper.js +9 -4
  233. package/dist/helpers/columnHelper.js.map +1 -1
  234. package/dist/helpers/tableOptions.cjs.map +1 -1
  235. package/dist/helpers/tableOptions.d.cts +12 -9
  236. package/dist/helpers/tableOptions.d.ts +12 -9
  237. package/dist/helpers/tableOptions.js.map +1 -1
  238. package/dist/index.cjs +0 -4
  239. package/dist/index.d.cts +2 -2
  240. package/dist/index.d.ts +2 -2
  241. package/dist/index.js +2 -2
  242. package/dist/static-functions.cjs +1 -0
  243. package/dist/static-functions.d.cts +2 -2
  244. package/dist/static-functions.d.ts +2 -2
  245. package/dist/static-functions.js +2 -2
  246. package/dist/store-reactivity-bindings.cjs +1 -0
  247. package/dist/store-reactivity-bindings.cjs.map +1 -1
  248. package/dist/store-reactivity-bindings.js +1 -0
  249. package/dist/store-reactivity-bindings.js.map +1 -1
  250. package/dist/types/ColumnDef.d.cts +38 -0
  251. package/dist/types/ColumnDef.d.ts +38 -0
  252. package/dist/types/TableOptions.d.cts +15 -0
  253. package/dist/types/TableOptions.d.ts +15 -0
  254. package/dist/types/TableState.d.cts +12 -0
  255. package/dist/types/TableState.d.ts +12 -0
  256. package/dist/utils.cjs +18 -39
  257. package/dist/utils.cjs.map +1 -1
  258. package/dist/utils.d.cts +1 -23
  259. package/dist/utils.d.ts +1 -23
  260. package/dist/utils.js +19 -36
  261. package/dist/utils.js.map +1 -1
  262. package/package.json +5 -3
  263. package/skills/column-definitions/SKILL.md +333 -0
  264. package/skills/column-layout/SKILL.md +328 -0
  265. package/skills/column-layout/references/subsystems.md +220 -0
  266. package/skills/customizing-feature-behavior/SKILL.md +416 -0
  267. package/skills/filtering/SKILL.md +357 -0
  268. package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
  269. package/skills/grouping/SKILL.md +448 -0
  270. package/skills/migrate-v8-to-v9/SKILL.md +495 -0
  271. package/skills/pagination/SKILL.md +385 -0
  272. package/skills/row-expanding/SKILL.md +348 -0
  273. package/skills/row-pinning/SKILL.md +269 -0
  274. package/skills/row-selection/SKILL.md +391 -0
  275. package/skills/setup/SKILL.md +400 -0
  276. package/skills/sorting/SKILL.md +344 -0
  277. package/skills/state-management/SKILL.md +388 -0
  278. package/src/core/cells/constructCell.ts +3 -2
  279. package/src/core/cells/coreCellsFeature.utils.ts +11 -8
  280. package/src/core/columns/constructColumn.ts +5 -3
  281. package/src/core/columns/coreColumnsFeature.types.ts +7 -6
  282. package/src/core/columns/coreColumnsFeature.utils.ts +43 -29
  283. package/src/core/headers/buildHeaderGroups.ts +29 -30
  284. package/src/core/headers/constructHeader.ts +3 -2
  285. package/src/core/headers/coreHeadersFeature.ts +2 -27
  286. package/src/core/headers/coreHeadersFeature.types.ts +6 -4
  287. package/src/core/headers/coreHeadersFeature.utils.ts +52 -61
  288. package/src/core/reactivity/coreReactivityFeature.types.ts +4 -0
  289. package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
  290. package/src/core/rows/constructRow.ts +6 -4
  291. package/src/core/rows/coreRowsFeature.types.ts +4 -4
  292. package/src/core/rows/coreRowsFeature.utils.ts +45 -32
  293. package/src/core/table/constructTable.ts +6 -4
  294. package/src/core/table/coreTablesFeature.types.ts +6 -2
  295. package/src/core/table/coreTablesFeature.utils.ts +5 -3
  296. package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
  297. package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
  298. package/src/features/column-faceting/createFacetedMinMaxValues.ts +8 -10
  299. package/src/features/column-faceting/createFacetedRowModel.ts +10 -6
  300. package/src/features/column-faceting/createFacetedUniqueValues.ts +4 -3
  301. package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
  302. package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
  303. package/src/features/column-filtering/createFilteredRowModel.ts +14 -8
  304. package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
  305. package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
  306. package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
  307. package/src/features/column-ordering/columnOrderingFeature.utils.ts +44 -29
  308. package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
  309. package/src/features/column-pinning/columnPinningFeature.utils.ts +164 -128
  310. package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
  311. package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
  312. package/src/features/column-sizing/columnSizingFeature.ts +16 -0
  313. package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
  314. package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
  315. package/src/features/column-visibility/columnVisibilityFeature.ts +8 -0
  316. package/src/features/column-visibility/columnVisibilityFeature.types.ts +22 -12
  317. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +101 -56
  318. package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
  319. package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
  320. package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
  321. package/src/features/row-expanding/rowExpandingFeature.utils.ts +58 -43
  322. package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
  323. package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
  324. package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
  325. package/src/features/row-pinning/rowPinningFeature.utils.ts +59 -47
  326. package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
  327. package/src/features/row-selection/rowSelectionFeature.utils.ts +109 -88
  328. package/src/features/row-sorting/createSortedRowModel.ts +16 -13
  329. package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
  330. package/src/features/row-sorting/rowSortingFeature.utils.ts +63 -46
  331. package/src/fns/aggregationFns.ts +53 -17
  332. package/src/fns/filterFns.ts +48 -17
  333. package/src/helpers/columnHelper.ts +9 -4
  334. package/src/helpers/tableOptions.ts +12 -9
  335. package/src/store-reactivity-bindings.ts +1 -0
  336. package/src/types/ColumnDef.ts +38 -0
  337. package/src/types/TableOptions.ts +15 -0
  338. package/src/types/TableState.ts +12 -0
  339. package/src/utils.ts +19 -46
@@ -6,20 +6,23 @@ import { Table_Internal } from "../../types/Table.js";
6
6
 
7
7
  //#region src/features/row-expanding/rowExpandingFeature.utils.d.ts
8
8
  /**
9
- * Returns the default expanded state.
9
+ * Creates the default expanded state.
10
10
  *
11
- * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.
11
+ * The feature default is an empty map, meaning no rows are expanded. Reset APIs
12
+ * use this value when `defaultState` is `true`.
12
13
  *
13
14
  * @example
14
15
  * ```ts
15
- * const initialValue = getDefaultExpandedState()
16
+ * const expanded = getDefaultExpandedState()
16
17
  * ```
17
18
  */
18
19
  declare function getDefaultExpandedState(): ExpandedState;
19
20
  /**
20
- * Schedules an automatic reset for expanded.
21
+ * Schedules an expanded-state reset after row-structure changes.
21
22
  *
22
- * The reset only runs when the related feature options allow automatic resets for the current table state change.
23
+ * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default
24
+ * client-side expanding behavior allows it. Manual expanding opts out unless
25
+ * the reset options explicitly opt back in.
23
26
  *
24
27
  * @example
25
28
  * ```ts
@@ -28,20 +31,23 @@ declare function getDefaultExpandedState(): ExpandedState;
28
31
  */
29
32
  declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
30
33
  /**
31
- * Updates the table's expanded state slice.
34
+ * Routes an expanded-state updater through the table's expanded change handler.
32
35
  *
33
- * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.
36
+ * The updater may be `true`, a row-id map, or a function of the previous
37
+ * expanded state, matching the instance `table.setExpanded` behavior.
34
38
  *
35
39
  * @example
36
40
  * ```ts
37
- * table_setExpanded(table, (old) => old)
41
+ * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
38
42
  * ```
39
43
  */
40
44
  declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>): void;
41
45
  /**
42
- * Toggles all rows expanded for the table.
46
+ * Expands or collapses every row.
43
47
  *
44
- * This is the table-level convenience API used by UI controls that affect many columns or rows at once.
48
+ * Passing `true` stores the special expanded-all state. Passing `false` stores
49
+ * an empty map. Omitting the value toggles based on whether all rows are
50
+ * currently expanded.
45
51
  *
46
52
  * @example
47
53
  * ```ts
@@ -50,9 +56,10 @@ declare function table_setExpanded<TFeatures extends TableFeatures, TData extend
50
56
  */
51
57
  declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, expanded?: boolean): void;
52
58
  /**
53
- * Resets the table's expanded state slice.
59
+ * Resets `expanded` to the configured initial state or feature default.
54
60
  *
55
- * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.
61
+ * With no argument, the reset clones `table.initialState.expanded` when it
62
+ * exists. Passing `true` ignores initial state and resets to `{}`.
56
63
  *
57
64
  * @example
58
65
  * ```ts
@@ -62,64 +69,70 @@ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TD
62
69
  */
63
70
  declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
64
71
  /**
65
- * Returns can some rows expand for the table.
72
+ * Checks whether at least one pre-paginated row can expand.
66
73
  *
67
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
74
+ * Pagination is intentionally ignored so controls can reflect expandable rows
75
+ * that may not be on the current page.
68
76
  *
69
77
  * @example
70
78
  * ```ts
71
- * const value = table_getCanSomeRowsExpand(table)
79
+ * const canExpand = table_getCanSomeRowsExpand(table)
72
80
  * ```
73
81
  */
74
82
  declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
75
83
  /**
76
- * Returns an event handler for all rows expanded handler.
84
+ * Creates an event handler that toggles all rows expanded.
77
85
  *
78
- * The handler calls the matching table toggle API and can be attached directly to checkbox or button UI.
86
+ * React-style synthetic events are persisted when present before the table state
87
+ * is toggled.
79
88
  *
80
89
  * @example
81
90
  * ```ts
82
- * const value = table_getToggleAllRowsExpandedHandler(table)
91
+ * const onClick = table_getToggleAllRowsExpandedHandler(table)
83
92
  * ```
84
93
  */
85
94
  declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (e: unknown) => void;
86
95
  /**
87
- * Returns is some rows expanded for the table.
96
+ * Checks whether any row is expanded.
88
97
  *
89
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
98
+ * The special expanded-all value `true` counts as some rows expanded.
90
99
  *
91
100
  * @example
92
101
  * ```ts
93
- * const value = table_getIsSomeRowsExpanded(table)
102
+ * const someExpanded = table_getIsSomeRowsExpanded(table)
94
103
  * ```
95
104
  */
96
105
  declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
97
106
  /**
98
- * Returns is all rows expanded for the table.
107
+ * Checks whether every row in the current row model is expanded.
99
108
  *
100
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
109
+ * The special expanded-all value `true` returns true immediately. Empty
110
+ * expanded state returns false.
101
111
  *
102
112
  * @example
103
113
  * ```ts
104
- * const value = table_getIsAllRowsExpanded(table)
114
+ * const allExpanded = table_getIsAllRowsExpanded(table)
105
115
  * ```
106
116
  */
107
117
  declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
108
118
  /**
109
- * Returns expanded depth for the table.
119
+ * Computes the deepest expanded row id depth.
110
120
  *
111
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
121
+ * Row ids are split on `.`; expanded-all state scans the current row model,
122
+ * while explicit expanded state scans its expanded id keys.
112
123
  *
113
124
  * @example
114
125
  * ```ts
115
- * const value = table_getExpandedDepth(table)
126
+ * const depth = table_getExpandedDepth(table)
116
127
  * ```
117
128
  */
118
129
  declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
119
130
  /**
120
- * Toggles expanded for a row.
131
+ * Expands or collapses this row.
121
132
  *
122
- * The update is routed through the table state updater for the owning feature state slice.
133
+ * Omitting `expanded` toggles the row. If the current state is expanded-all,
134
+ * the function first materializes that state into a row-id map before applying
135
+ * the row-specific change.
123
136
  *
124
137
  * @example
125
138
  * ```ts
@@ -128,46 +141,48 @@ declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData e
128
141
  */
129
142
  declare function row_toggleExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>, expanded?: boolean): void;
130
143
  /**
131
- * Returns is expanded for a row.
144
+ * Checks whether this row is expanded.
132
145
  *
133
- * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.
146
+ * `options.getIsRowExpanded` can override state-derived behavior. Otherwise
147
+ * the row is expanded when expanded state is `true` or contains this row id.
134
148
  *
135
149
  * @example
136
150
  * ```ts
137
- * const value = row_getIsExpanded(row)
151
+ * const expanded = row_getIsExpanded(row)
138
152
  * ```
139
153
  */
140
154
  declare function row_getIsExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
141
155
  /**
142
- * Returns whether a row can use expand.
156
+ * Checks whether this row can be expanded.
143
157
  *
144
- * This evaluates row data, table options, and feature-specific enablement rules.
158
+ * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when
159
+ * expanding is enabled and the row has subRows.
145
160
  *
146
161
  * @example
147
162
  * ```ts
148
- * const value = row_getCanExpand(row)
163
+ * const canExpand = row_getCanExpand(row)
149
164
  * ```
150
165
  */
151
166
  declare function row_getCanExpand<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
152
167
  /**
153
- * Returns is all parents expanded for a row.
168
+ * Checks whether every ancestor of this row is expanded.
154
169
  *
155
- * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.
170
+ * The current row is not considered; only its parent chain is walked.
156
171
  *
157
172
  * @example
158
173
  * ```ts
159
- * const value = row_getIsAllParentsExpanded(row)
174
+ * const parentsExpanded = row_getIsAllParentsExpanded(row)
160
175
  * ```
161
176
  */
162
177
  declare function row_getIsAllParentsExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
163
178
  /**
164
- * Returns an event handler for toggling expanded handler.
179
+ * Creates a row control handler that toggles this row's expanded state.
165
180
  *
166
- * The handler is intended for direct use in row-level controls such as expansion or selection buttons.
181
+ * The handler is a no-op when the row cannot expand.
167
182
  *
168
183
  * @example
169
184
  * ```ts
170
- * const value = row_getToggleExpandedHandler(row)
185
+ * const onClick = row_getToggleExpandedHandler(row)
171
186
  * ```
172
187
  */
173
188
  declare function row_getToggleExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): () => void;
@@ -2,22 +2,25 @@ import { cloneState } from "../../utils.js";
2
2
 
3
3
  //#region src/features/row-expanding/rowExpandingFeature.utils.ts
4
4
  /**
5
- * Returns the default expanded state.
5
+ * Creates the default expanded state.
6
6
  *
7
- * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.
7
+ * The feature default is an empty map, meaning no rows are expanded. Reset APIs
8
+ * use this value when `defaultState` is `true`.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
- * const initialValue = getDefaultExpandedState()
12
+ * const expanded = getDefaultExpandedState()
12
13
  * ```
13
14
  */
14
15
  function getDefaultExpandedState() {
15
16
  return {};
16
17
  }
17
18
  /**
18
- * Schedules an automatic reset for expanded.
19
+ * Schedules an expanded-state reset after row-structure changes.
19
20
  *
20
- * The reset only runs when the related feature options allow automatic resets for the current table state change.
21
+ * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default
22
+ * client-side expanding behavior allows it. Manual expanding opts out unless
23
+ * the reset options explicitly opt back in.
21
24
  *
22
25
  * @example
23
26
  * ```ts
@@ -25,16 +28,17 @@ function getDefaultExpandedState() {
25
28
  * ```
26
29
  */
27
30
  function table_autoResetExpanded(table) {
28
- if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) queueMicrotask(() => table_resetExpanded(table));
31
+ if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) table._reactivity.schedule(() => table_resetExpanded(table));
29
32
  }
30
33
  /**
31
- * Updates the table's expanded state slice.
34
+ * Routes an expanded-state updater through the table's expanded change handler.
32
35
  *
33
- * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.
36
+ * The updater may be `true`, a row-id map, or a function of the previous
37
+ * expanded state, matching the instance `table.setExpanded` behavior.
34
38
  *
35
39
  * @example
36
40
  * ```ts
37
- * table_setExpanded(table, (old) => old)
41
+ * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
38
42
  * ```
39
43
  */
40
44
  function table_setExpanded(table, updater) {
@@ -42,9 +46,11 @@ function table_setExpanded(table, updater) {
42
46
  (_table$options$onExpa = (_table$options = table.options).onExpandedChange) === null || _table$options$onExpa === void 0 || _table$options$onExpa.call(_table$options, updater);
43
47
  }
44
48
  /**
45
- * Toggles all rows expanded for the table.
49
+ * Expands or collapses every row.
46
50
  *
47
- * This is the table-level convenience API used by UI controls that affect many columns or rows at once.
51
+ * Passing `true` stores the special expanded-all state. Passing `false` stores
52
+ * an empty map. Omitting the value toggles based on whether all rows are
53
+ * currently expanded.
48
54
  *
49
55
  * @example
50
56
  * ```ts
@@ -56,9 +62,10 @@ function table_toggleAllRowsExpanded(table, expanded) {
56
62
  else table_setExpanded(table, {});
57
63
  }
58
64
  /**
59
- * Resets the table's expanded state slice.
65
+ * Resets `expanded` to the configured initial state or feature default.
60
66
  *
61
- * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.
67
+ * With no argument, the reset clones `table.initialState.expanded` when it
68
+ * exists. Passing `true` ignores initial state and resets to `{}`.
62
69
  *
63
70
  * @example
64
71
  * ```ts
@@ -70,26 +77,28 @@ function table_resetExpanded(table, defaultState) {
70
77
  table_setExpanded(table, defaultState ? {} : cloneState(table.initialState.expanded ?? {}));
71
78
  }
72
79
  /**
73
- * Returns can some rows expand for the table.
80
+ * Checks whether at least one pre-paginated row can expand.
74
81
  *
75
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
82
+ * Pagination is intentionally ignored so controls can reflect expandable rows
83
+ * that may not be on the current page.
76
84
  *
77
85
  * @example
78
86
  * ```ts
79
- * const value = table_getCanSomeRowsExpand(table)
87
+ * const canExpand = table_getCanSomeRowsExpand(table)
80
88
  * ```
81
89
  */
82
90
  function table_getCanSomeRowsExpand(table) {
83
91
  return table.getPrePaginatedRowModel().flatRows.some((row) => row_getCanExpand(row));
84
92
  }
85
93
  /**
86
- * Returns an event handler for all rows expanded handler.
94
+ * Creates an event handler that toggles all rows expanded.
87
95
  *
88
- * The handler calls the matching table toggle API and can be attached directly to checkbox or button UI.
96
+ * React-style synthetic events are persisted when present before the table state
97
+ * is toggled.
89
98
  *
90
99
  * @example
91
100
  * ```ts
92
- * const value = table_getToggleAllRowsExpandedHandler(table)
101
+ * const onClick = table_getToggleAllRowsExpandedHandler(table)
93
102
  * ```
94
103
  */
95
104
  function table_getToggleAllRowsExpandedHandler(table) {
@@ -100,13 +109,13 @@ function table_getToggleAllRowsExpandedHandler(table) {
100
109
  };
101
110
  }
102
111
  /**
103
- * Returns is some rows expanded for the table.
112
+ * Checks whether any row is expanded.
104
113
  *
105
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
114
+ * The special expanded-all value `true` counts as some rows expanded.
106
115
  *
107
116
  * @example
108
117
  * ```ts
109
- * const value = table_getIsSomeRowsExpanded(table)
118
+ * const someExpanded = table_getIsSomeRowsExpanded(table)
110
119
  * ```
111
120
  */
112
121
  function table_getIsSomeRowsExpanded(table) {
@@ -115,13 +124,14 @@ function table_getIsSomeRowsExpanded(table) {
115
124
  return expanded === true || Object.values(expanded).some(Boolean);
116
125
  }
117
126
  /**
118
- * Returns is all rows expanded for the table.
127
+ * Checks whether every row in the current row model is expanded.
119
128
  *
120
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
129
+ * The special expanded-all value `true` returns true immediately. Empty
130
+ * expanded state returns false.
121
131
  *
122
132
  * @example
123
133
  * ```ts
124
- * const value = table_getIsAllRowsExpanded(table)
134
+ * const allExpanded = table_getIsAllRowsExpanded(table)
125
135
  * ```
126
136
  */
127
137
  function table_getIsAllRowsExpanded(table) {
@@ -133,13 +143,14 @@ function table_getIsAllRowsExpanded(table) {
133
143
  return true;
134
144
  }
135
145
  /**
136
- * Returns expanded depth for the table.
146
+ * Computes the deepest expanded row id depth.
137
147
  *
138
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
148
+ * Row ids are split on `.`; expanded-all state scans the current row model,
149
+ * while explicit expanded state scans its expanded id keys.
139
150
  *
140
151
  * @example
141
152
  * ```ts
142
- * const value = table_getExpandedDepth(table)
153
+ * const depth = table_getExpandedDepth(table)
143
154
  * ```
144
155
  */
145
156
  function table_getExpandedDepth(table) {
@@ -152,9 +163,11 @@ function table_getExpandedDepth(table) {
152
163
  return maxDepth;
153
164
  }
154
165
  /**
155
- * Toggles expanded for a row.
166
+ * Expands or collapses this row.
156
167
  *
157
- * The update is routed through the table state updater for the owning feature state slice.
168
+ * Omitting `expanded` toggles the row. If the current state is expanded-all,
169
+ * the function first materializes that state into a row-id map before applying
170
+ * the row-specific change.
158
171
  *
159
172
  * @example
160
173
  * ```ts
@@ -182,13 +195,14 @@ function row_toggleExpanded(row, expanded) {
182
195
  });
183
196
  }
184
197
  /**
185
- * Returns is expanded for a row.
198
+ * Checks whether this row is expanded.
186
199
  *
187
- * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.
200
+ * `options.getIsRowExpanded` can override state-derived behavior. Otherwise
201
+ * the row is expanded when expanded state is `true` or contains this row id.
188
202
  *
189
203
  * @example
190
204
  * ```ts
191
- * const value = row_getIsExpanded(row)
205
+ * const expanded = row_getIsExpanded(row)
192
206
  * ```
193
207
  */
194
208
  function row_getIsExpanded(row) {
@@ -197,13 +211,14 @@ function row_getIsExpanded(row) {
197
211
  return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || expanded[row.id]));
198
212
  }
199
213
  /**
200
- * Returns whether a row can use expand.
214
+ * Checks whether this row can be expanded.
201
215
  *
202
- * This evaluates row data, table options, and feature-specific enablement rules.
216
+ * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when
217
+ * expanding is enabled and the row has subRows.
203
218
  *
204
219
  * @example
205
220
  * ```ts
206
- * const value = row_getCanExpand(row)
221
+ * const canExpand = row_getCanExpand(row)
207
222
  * ```
208
223
  */
209
224
  function row_getCanExpand(row) {
@@ -211,13 +226,13 @@ function row_getCanExpand(row) {
211
226
  return ((_row$table$options$ge2 = (_row$table$options2 = row.table.options).getRowCanExpand) === null || _row$table$options$ge2 === void 0 ? void 0 : _row$table$options$ge2.call(_row$table$options2, row)) ?? ((row.table.options.enableExpanding ?? true) && !!row.subRows.length);
212
227
  }
213
228
  /**
214
- * Returns is all parents expanded for a row.
229
+ * Checks whether every ancestor of this row is expanded.
215
230
  *
216
- * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.
231
+ * The current row is not considered; only its parent chain is walked.
217
232
  *
218
233
  * @example
219
234
  * ```ts
220
- * const value = row_getIsAllParentsExpanded(row)
235
+ * const parentsExpanded = row_getIsAllParentsExpanded(row)
221
236
  * ```
222
237
  */
223
238
  function row_getIsAllParentsExpanded(row) {
@@ -225,18 +240,18 @@ function row_getIsAllParentsExpanded(row) {
225
240
  let currentRow = row;
226
241
  while (isFullyExpanded && currentRow.parentId) {
227
242
  currentRow = row.table.getRow(currentRow.parentId, true);
228
- isFullyExpanded = row_getIsExpanded(row);
243
+ isFullyExpanded = row_getIsExpanded(currentRow);
229
244
  }
230
245
  return isFullyExpanded;
231
246
  }
232
247
  /**
233
- * Returns an event handler for toggling expanded handler.
248
+ * Creates a row control handler that toggles this row's expanded state.
234
249
  *
235
- * The handler is intended for direct use in row-level controls such as expansion or selection buttons.
250
+ * The handler is a no-op when the row cannot expand.
236
251
  *
237
252
  * @example
238
253
  * ```ts
239
- * const value = row_getToggleExpandedHandler(row)
254
+ * const onClick = row_getToggleExpandedHandler(row)
240
255
  * ```
241
256
  */
242
257
  function row_getToggleExpandedHandler(row) {
@@ -1 +1 @@
1
- {"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Returns the default expanded state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an automatic reset for expanded.\n *\n * The reset only runs when the related feature options allow automatic resets for the current table state change.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n queueMicrotask(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Updates the table's expanded state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => old)\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Toggles all rows expanded for the table.\n *\n * This is the table-level convenience API used by UI controls that affect many columns or rows at once.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets the table's expanded state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Returns can some rows expand for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Returns an event handler for all rows expanded handler.\n *\n * The handler calls the matching table toggle API and can be attached directly to checkbox or button UI.\n *\n * @example\n * ```ts\n * const value = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Returns is some rows expanded for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Returns is all rows expanded for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Returns expanded depth for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Toggles expanded for a row.\n *\n * The update is routed through the table state updater for the owning feature state slice.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Returns is expanded for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Returns whether a row can use expand.\n *\n * This evaluates row data, table options, and feature-specific enablement rules.\n *\n * @example\n * ```ts\n * const value = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Returns is all parents expanded for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(row)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Returns an event handler for toggling expanded handler.\n *\n * The handler is intended for direct use in row-level controls such as expansion or selection buttons.\n *\n * @example\n * ```ts\n * const value = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":"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"}
@@ -41,23 +41,26 @@ interface PaginationDefaultOptions {
41
41
  interface Table_RowPagination<TFeatures extends TableFeatures, TData extends RowData> {
42
42
  _autoResetPageIndex: () => void;
43
43
  /**
44
- * Returns whether the table can go to the next page.
44
+ * Checks whether the current page index can move forward.
45
45
  */
46
46
  getCanNextPage: () => boolean;
47
47
  /**
48
- * Returns whether the table can go to the previous page.
48
+ * Checks whether the current page index can move backward.
49
49
  */
50
50
  getCanPreviousPage: () => boolean;
51
51
  /**
52
- * Returns the page count. If manually paginating or controlling the pagination state, this will come directly from the `options.pageCount` table option, otherwise it will be calculated from the table data using the total row count and current page size.
52
+ * Resolves the current page count from `options.pageCount` or row count and
53
+ * page size.
53
54
  */
54
55
  getPageCount: () => number;
55
56
  /**
56
- * Returns the row count. If manually paginating or controlling the pagination state, this will come directly from the `options.rowCount` table option, otherwise it will be calculated from the table data.
57
+ * Resolves the row count used for pagination math.
58
+ *
59
+ * `options.rowCount` wins; otherwise the pre-paginated row model is counted.
57
60
  */
58
61
  getRowCount: () => number;
59
62
  /**
60
- * Returns an array of page options (zero-index-based) for the current page size.
63
+ * Builds zero-based page indexes for the current page count.
61
64
  */
62
65
  getPageOptions: () => Array<number>;
63
66
  /**
@@ -77,16 +80,20 @@ interface Table_RowPagination<TFeatures extends TableFeatures, TData extends Row
77
80
  */
78
81
  lastPage: () => void;
79
82
  /**
80
- * Resets the page index to its initial state. If `defaultState` is `true`, the page index will be reset to `0` regardless of initial state.
83
+ * Resets `pagination.pageIndex` to initial state, or to `0` when
84
+ * `defaultState` is `true`.
81
85
  */
82
86
  resetPageIndex: (defaultState?: boolean) => void;
83
87
  /**
84
- * Resets the page size to its initial state. If `defaultState` is `true`, the page size will be reset to `10` regardless of initial state.
88
+ * Resets `pagination.pageSize` to initial state, or to `10` when
89
+ * `defaultState` is `true`.
85
90
  */
86
91
  resetPageSize: (defaultState?: boolean) => void;
87
92
  /**
88
- * Resets pagination state to `initialState.pagination`. Pass `true` to reset
89
- * to the feature default of `{ pageIndex: 0, pageSize: 10 }`.
93
+ * Resets `pagination` to `initialState.pagination`.
94
+ *
95
+ * Pass `true` to ignore initial state and reset to
96
+ * `{ pageIndex: 0, pageSize: 10 }`.
90
97
  */
91
98
  resetPagination: (defaultState?: boolean) => void;
92
99
  /**
@@ -98,17 +105,17 @@ interface Table_RowPagination<TFeatures extends TableFeatures, TData extends Row
98
105
  */
99
106
  setPageSize: (updater: Updater<number>) => void;
100
107
  /**
101
- * Sets pagination state using a value or updater.
108
+ * Updates pagination state with a next state or updater function.
102
109
  */
103
110
  setPagination: (updater: Updater<PaginationState>) => void;
104
111
  }
105
112
  interface Table_RowModels_Paginated<TFeatures extends TableFeatures, TData extends RowData> {
106
113
  /**
107
- * Returns the row model for the table after pagination has been applied.
114
+ * Resolves the row model after pagination has sliced the current page.
108
115
  */
109
116
  getPaginatedRowModel: () => RowModel<TFeatures, TData>;
110
117
  /**
111
- * Returns the row model for the table before any pagination has been applied.
118
+ * Reads the row model immediately before pagination.
112
119
  */
113
120
  getPrePaginatedRowModel: () => RowModel<TFeatures, TData>;
114
121
  }