@tanstack/table-core 9.0.0-alpha.47 → 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 (246) hide show
  1. package/README.md +10 -0
  2. package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
  3. package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
  4. package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
  5. package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
  6. package/dist/core/cells/coreCellsFeature.utils.js +11 -8
  7. package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
  8. package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
  9. package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
  10. package/dist/core/columns/coreColumnsFeature.utils.cjs +37 -27
  11. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  12. package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
  13. package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
  14. package/dist/core/columns/coreColumnsFeature.utils.js +37 -27
  15. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  16. package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
  17. package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
  18. package/dist/core/headers/coreHeadersFeature.utils.cjs +23 -18
  19. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  20. package/dist/core/headers/coreHeadersFeature.utils.d.cts +23 -18
  21. package/dist/core/headers/coreHeadersFeature.utils.d.ts +23 -18
  22. package/dist/core/headers/coreHeadersFeature.utils.js +23 -18
  23. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  24. package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
  25. package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
  26. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
  27. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
  28. package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
  29. package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
  30. package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
  31. package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
  32. package/dist/core/rows/coreRowsFeature.utils.cjs +34 -28
  33. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  34. package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
  35. package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
  36. package/dist/core/rows/coreRowsFeature.utils.js +34 -28
  37. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  38. package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
  39. package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
  40. package/dist/core/table/coreTablesFeature.utils.cjs +2 -2
  41. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  42. package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
  43. package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
  44. package/dist/core/table/coreTablesFeature.utils.js +2 -2
  45. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  46. package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
  47. package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
  48. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
  49. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
  50. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
  51. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
  52. package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
  53. package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
  54. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
  55. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
  56. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
  57. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  58. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
  59. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
  60. package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
  61. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  62. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
  63. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
  64. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
  65. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  66. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
  67. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
  68. package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
  69. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  70. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
  71. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
  72. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +30 -23
  73. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  74. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
  75. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
  76. package/dist/features/column-ordering/columnOrderingFeature.utils.js +30 -23
  77. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  78. package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
  79. package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
  80. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +111 -91
  81. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  82. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +111 -91
  83. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +111 -91
  84. package/dist/features/column-pinning/columnPinningFeature.utils.js +111 -91
  85. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  86. package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
  87. package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
  88. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
  89. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  90. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
  91. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
  92. package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
  93. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  94. package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
  95. package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
  96. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
  97. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  98. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
  99. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
  100. package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
  101. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  102. package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +16 -13
  103. package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +16 -13
  104. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +54 -42
  105. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  106. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +54 -42
  107. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +54 -42
  108. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +54 -42
  109. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  110. package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
  111. package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
  112. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
  113. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  114. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
  115. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
  116. package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
  117. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  118. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
  119. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
  120. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +56 -41
  121. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  122. package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
  123. package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
  124. package/dist/features/row-expanding/rowExpandingFeature.utils.js +56 -41
  125. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  126. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
  127. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
  128. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
  129. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
  130. package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
  131. package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
  132. package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
  133. package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
  134. package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
  135. package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
  136. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +39 -29
  137. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  138. package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
  139. package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
  140. package/dist/features/row-pinning/rowPinningFeature.utils.js +39 -29
  141. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  142. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
  143. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
  144. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +89 -69
  145. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  146. package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
  147. package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
  148. package/dist/features/row-selection/rowSelectionFeature.utils.js +89 -69
  149. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  150. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
  151. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
  152. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +61 -44
  153. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  154. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
  155. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
  156. package/dist/features/row-sorting/rowSortingFeature.utils.js +61 -44
  157. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  158. package/dist/fns/aggregationFns.cjs +33 -9
  159. package/dist/fns/aggregationFns.cjs.map +1 -1
  160. package/dist/fns/aggregationFns.d.cts +33 -9
  161. package/dist/fns/aggregationFns.d.ts +33 -9
  162. package/dist/fns/aggregationFns.js +33 -9
  163. package/dist/fns/aggregationFns.js.map +1 -1
  164. package/dist/fns/filterFns.cjs +48 -17
  165. package/dist/fns/filterFns.cjs.map +1 -1
  166. package/dist/fns/filterFns.d.cts +42 -15
  167. package/dist/fns/filterFns.d.ts +42 -15
  168. package/dist/fns/filterFns.js +48 -17
  169. package/dist/fns/filterFns.js.map +1 -1
  170. package/dist/helpers/columnHelper.cjs +9 -4
  171. package/dist/helpers/columnHelper.cjs.map +1 -1
  172. package/dist/helpers/columnHelper.d.cts +9 -4
  173. package/dist/helpers/columnHelper.d.ts +9 -4
  174. package/dist/helpers/columnHelper.js +9 -4
  175. package/dist/helpers/columnHelper.js.map +1 -1
  176. package/dist/helpers/tableOptions.cjs.map +1 -1
  177. package/dist/helpers/tableOptions.d.cts +12 -9
  178. package/dist/helpers/tableOptions.d.ts +12 -9
  179. package/dist/helpers/tableOptions.js.map +1 -1
  180. package/dist/types/ColumnDef.d.cts +38 -0
  181. package/dist/types/ColumnDef.d.ts +38 -0
  182. package/dist/types/TableOptions.d.cts +15 -0
  183. package/dist/types/TableOptions.d.ts +15 -0
  184. package/dist/types/TableState.d.cts +12 -0
  185. package/dist/types/TableState.d.ts +12 -0
  186. package/package.json +5 -3
  187. package/skills/column-definitions/SKILL.md +333 -0
  188. package/skills/column-layout/SKILL.md +328 -0
  189. package/skills/column-layout/references/subsystems.md +220 -0
  190. package/skills/customizing-feature-behavior/SKILL.md +416 -0
  191. package/skills/filtering/SKILL.md +357 -0
  192. package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
  193. package/skills/grouping/SKILL.md +448 -0
  194. package/skills/migrate-v8-to-v9/SKILL.md +495 -0
  195. package/skills/pagination/SKILL.md +385 -0
  196. package/skills/row-expanding/SKILL.md +348 -0
  197. package/skills/row-pinning/SKILL.md +269 -0
  198. package/skills/row-selection/SKILL.md +391 -0
  199. package/skills/setup/SKILL.md +400 -0
  200. package/skills/sorting/SKILL.md +344 -0
  201. package/skills/state-management/SKILL.md +388 -0
  202. package/src/core/cells/coreCellsFeature.utils.ts +11 -8
  203. package/src/core/columns/coreColumnsFeature.types.ts +7 -6
  204. package/src/core/columns/coreColumnsFeature.utils.ts +37 -27
  205. package/src/core/headers/coreHeadersFeature.types.ts +6 -4
  206. package/src/core/headers/coreHeadersFeature.utils.ts +23 -18
  207. package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
  208. package/src/core/rows/coreRowsFeature.types.ts +4 -4
  209. package/src/core/rows/coreRowsFeature.utils.ts +34 -28
  210. package/src/core/table/coreTablesFeature.types.ts +6 -2
  211. package/src/core/table/coreTablesFeature.utils.ts +2 -2
  212. package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
  213. package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
  214. package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
  215. package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
  216. package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
  217. package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
  218. package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
  219. package/src/features/column-ordering/columnOrderingFeature.utils.ts +30 -23
  220. package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
  221. package/src/features/column-pinning/columnPinningFeature.utils.ts +111 -91
  222. package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
  223. package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
  224. package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
  225. package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
  226. package/src/features/column-visibility/columnVisibilityFeature.types.ts +16 -13
  227. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +54 -42
  228. package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
  229. package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
  230. package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
  231. package/src/features/row-expanding/rowExpandingFeature.utils.ts +56 -41
  232. package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
  233. package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
  234. package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
  235. package/src/features/row-pinning/rowPinningFeature.utils.ts +39 -29
  236. package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
  237. package/src/features/row-selection/rowSelectionFeature.utils.ts +89 -69
  238. package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
  239. package/src/features/row-sorting/rowSortingFeature.utils.ts +61 -44
  240. package/src/fns/aggregationFns.ts +33 -9
  241. package/src/fns/filterFns.ts +48 -17
  242. package/src/helpers/columnHelper.ts +9 -4
  243. package/src/helpers/tableOptions.ts +12 -9
  244. package/src/types/ColumnDef.ts +38 -0
  245. package/src/types/TableOptions.ts +15 -0
  246. package/src/types/TableState.ts +12 -0
@@ -0,0 +1,388 @@
1
+ ---
2
+ name: state-management
3
+ description: >
4
+ Coordinate TanStack Table v9 state across `initialState`, controlled
5
+ `state`+`on*Change`, and external `atoms`. Covers the atom model
6
+ (`table.atoms.<slice>`, `table.baseAtoms.<slice>`, `table.store`, `table.state`),
7
+ per-slice precedence (atoms beat state beat initialState beat baseAtoms),
8
+ `manualSorting` / `manualFiltering` / `manualPagination` / `manualGrouping` /
9
+ `manualExpanding` for server-side data, `autoResetPageIndex` / `autoResetAll`,
10
+ reset APIs (`resetSorting`, `resetPagination`, `reset()`), and the
11
+ `SortingState` / `PaginationState` / `RowSelectionState` / `ColumnFiltersState` /
12
+ `GroupingState` shapes. Foundational for every other skill.
13
+ type: core
14
+ library: tanstack-table
15
+ library_version: '9.0.0-alpha.47'
16
+ sources:
17
+ - TanStack/table:docs/framework/vanilla/guide/table-state.md
18
+ - TanStack/table:docs/framework/react/guide/table-state.md
19
+ - TanStack/table:packages/table-core/src/store-reactivity-bindings.ts
20
+ - TanStack/table:packages/table-core/src/reactivity.ts
21
+ - TanStack/table:packages/table-core/src/core/table/constructTable.ts
22
+ ---
23
+
24
+ ## Setup
25
+
26
+ TanStack Table v9 is built on TanStack Store. Each state slice (sorting, pagination, columnFilters, rowSelection, columnVisibility, …) is a separate atom. There are four ownership patterns, and the table reads from them in a fixed precedence.
27
+
28
+ ```ts
29
+ import {
30
+ constructTable,
31
+ tableFeatures,
32
+ rowSortingFeature,
33
+ rowPaginationFeature,
34
+ createSortedRowModel,
35
+ createPaginatedRowModel,
36
+ sortFns,
37
+ } from '@tanstack/table-core'
38
+
39
+ const _features = tableFeatures({ rowSortingFeature, rowPaginationFeature })
40
+
41
+ const table = constructTable({
42
+ _features,
43
+ _rowModels: {
44
+ sortedRowModel: createSortedRowModel(sortFns),
45
+ paginatedRowModel: createPaginatedRowModel(),
46
+ },
47
+ columns,
48
+ data,
49
+ // 1. initialState — set starting values; read once at construction
50
+ initialState: {
51
+ sorting: [{ id: 'lastName', desc: false }],
52
+ pagination: { pageIndex: 0, pageSize: 10 },
53
+ },
54
+ })
55
+
56
+ // Read APIs:
57
+ table.store.state // flat snapshot of every slice (no subscription)
58
+ table.atoms.sorting.get() // single-slice atom read (no subscription)
59
+ table.state // typed output of the `useTable` selector (framework adapters)
60
+
61
+ // Write APIs use the feature setters — they're atom-aware:
62
+ table.setSorting([{ id: 'firstName', desc: true }])
63
+ table.setPageIndex(2)
64
+ ```
65
+
66
+ The four ownership patterns per slice:
67
+
68
+ | Pattern | When to use | Wins over |
69
+ | ----------------------------------- | ---------------------------------------------------- | ------------------------------- |
70
+ | internal (default) | Most slices in a simple table | nothing — baseline |
71
+ | `initialState.<slice>` | Set starting value only | internal default |
72
+ | `state.<slice>` + `on<Slice>Change` | v8-style controlled state | `initialState` |
73
+ | `atoms.<slice>` | v9 preferred — share with other components / queries | `state`+`on*Change` (silently!) |
74
+
75
+ ## Core Patterns
76
+
77
+ ### Internal state with `initialState`
78
+
79
+ ```ts
80
+ const table = constructTable({
81
+ _features,
82
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
83
+ columns,
84
+ data,
85
+ initialState: { sorting: [{ id: 'age', desc: false }] },
86
+ })
87
+ // State lives entirely inside the table.
88
+ table.setSorting([{ id: 'firstName', desc: true }])
89
+ ```
90
+
91
+ ### Controlled state with `state` + `on*Change` (v8-style)
92
+
93
+ ```tsx
94
+ const [sorting, setSorting] = React.useState<SortingState>([])
95
+
96
+ const table = useTable({
97
+ _features,
98
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
99
+ columns,
100
+ data,
101
+ state: { sorting },
102
+ onSortingChange: setSorting,
103
+ })
104
+ ```
105
+
106
+ `state` and `on*Change` must be paired. Without the callback the table cannot update React state, so toggling sort appears to do nothing.
107
+
108
+ ### External atom (v9 preferred for shared slices)
109
+
110
+ ```tsx
111
+ import { useCreateAtom } from '@tanstack/react-store'
112
+
113
+ function MyTable() {
114
+ // Hoist or pass via context to share with queries / other components.
115
+ const paginationAtom = useCreateAtom<PaginationState>({
116
+ pageIndex: 0,
117
+ pageSize: 10,
118
+ })
119
+
120
+ const table = useTable({
121
+ _features,
122
+ _rowModels: { paginatedRowModel: createPaginatedRowModel() },
123
+ columns,
124
+ data,
125
+ atoms: { pagination: paginationAtom },
126
+ // no state.pagination, no onPaginationChange needed
127
+ })
128
+
129
+ return <Pager paginationAtom={paginationAtom} />
130
+ }
131
+ ```
132
+
133
+ The atom IS the source of truth; `table.atoms.pagination` derives from it.
134
+
135
+ ### Server-side / manual mode
136
+
137
+ ```tsx
138
+ const [pagination, setPagination] = React.useState({
139
+ pageIndex: 0,
140
+ pageSize: 10,
141
+ })
142
+ const dataQuery = useQuery({
143
+ queryKey: ['rows', pagination],
144
+ queryFn: () => fetchPage(pagination),
145
+ })
146
+
147
+ const table = useTable({
148
+ _features: tableFeatures({ rowPaginationFeature }),
149
+ _rowModels: {}, // can drop paginatedRowModel — server paginates
150
+ columns,
151
+ data: dataQuery.data?.rows ?? EMPTY,
152
+ rowCount: dataQuery.data?.rowCount, // server tells the table the total
153
+ state: { pagination },
154
+ onPaginationChange: setPagination,
155
+ manualPagination: true, // ← tell the table to NOT re-paginate
156
+ })
157
+ ```
158
+
159
+ The same shape applies to `manualSorting`, `manualFiltering`, `manualGrouping`, `manualExpanding`. Without the flag, the table re-applies its client-side pipeline on top of already-prepared server data.
160
+
161
+ ## Common Mistakes
162
+
163
+ ### [CRITICAL] Passing both `state.<slice>` and `atoms.<slice>`
164
+
165
+ Wrong:
166
+
167
+ ```tsx
168
+ // both ownership paths for the same slice
169
+ const paginationAtom = useCreateAtom<PaginationState>({ pageIndex: 0, pageSize: 10 })
170
+ const [pagination, setPagination] = React.useState(...)
171
+
172
+ const table = useTable({
173
+ _features, _rowModels: {...}, columns, data,
174
+ state: { pagination }, // ignored
175
+ onPaginationChange: setPagination,
176
+ atoms: { pagination: paginationAtom }, // wins
177
+ })
178
+ ```
179
+
180
+ Correct:
181
+
182
+ ```tsx
183
+ // pick one ownership path per slice — here, external atoms
184
+ const paginationAtom = useCreateAtom<PaginationState>({ pageIndex: 0, pageSize: 10 })
185
+
186
+ const table = useTable({
187
+ _features, _rowModels: {...}, columns, data,
188
+ atoms: { pagination: paginationAtom },
189
+ })
190
+ ```
191
+
192
+ When both are supplied, the external atom wins silently. `state.pagination` becomes dead config and `setPagination` writes never reach the table.
193
+
194
+ Source: docs/framework/react/guide/table-state.md; packages/table-core/src/core/table/constructTable.ts
195
+
196
+ ### [CRITICAL] Using external `state` without the matching `on*Change` callback
197
+
198
+ Wrong:
199
+
200
+ ```tsx
201
+ const [sorting, setSorting] = React.useState<SortingState>([])
202
+ const table = useTable({
203
+ _features,
204
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
205
+ columns,
206
+ data,
207
+ state: { sorting }, // no onSortingChange
208
+ })
209
+ ```
210
+
211
+ Correct:
212
+
213
+ ```tsx
214
+ const [sorting, setSorting] = React.useState<SortingState>([])
215
+ const table = useTable({
216
+ _features,
217
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
218
+ columns,
219
+ data,
220
+ state: { sorting },
221
+ onSortingChange: setSorting,
222
+ })
223
+ ```
224
+
225
+ The table keeps reading from `state.sorting`, so the UI looks stuck — sort toggles never make it back into React state.
226
+
227
+ Source: docs/framework/react/guide/table-state.md; examples/react/basic-external-state/src/main.tsx
228
+
229
+ ### [HIGH] Using `initialState` to control or update state
230
+
231
+ Wrong:
232
+
233
+ ```tsx
234
+ // updates to initialState are ignored after first render
235
+ function MyTable({ defaultSort }: { defaultSort: SortingState }) {
236
+ const table = useTable({
237
+ _features,
238
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
239
+ columns,
240
+ data,
241
+ initialState: { sorting: defaultSort }, // later changes never sync
242
+ })
243
+ }
244
+ ```
245
+
246
+ Correct:
247
+
248
+ ```tsx
249
+ function MyTable({ defaultSort }: { defaultSort: SortingState }) {
250
+ const [sorting, setSorting] = React.useState(defaultSort)
251
+ const table = useTable({
252
+ _features,
253
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
254
+ columns,
255
+ data,
256
+ state: { sorting },
257
+ onSortingChange: setSorting,
258
+ })
259
+ }
260
+ ```
261
+
262
+ `initialState` is read once at construction to seed `baseAtoms`. Mutating it later does nothing.
263
+
264
+ Source: docs/framework/vanilla/guide/table-state.md; docs/framework/react/guide/table-state.md
265
+
266
+ ### [HIGH] Writing to `table.baseAtoms.<slice>` while `atoms.<slice>` owns the slice
267
+
268
+ Wrong:
269
+
270
+ ```ts
271
+ const paginationAtom = useCreateAtom<PaginationState>({ pageIndex: 0, pageSize: 10 })
272
+ const table = useTable({ _features, _rowModels: {...}, columns, data, atoms: { pagination: paginationAtom } })
273
+
274
+ table.baseAtoms.pagination.set((old) => ({ ...old, pageIndex: 0 }))
275
+ // baseAtom updated, but table.atoms.pagination still reads from paginationAtom
276
+ ```
277
+
278
+ Correct:
279
+
280
+ ```ts
281
+ // Write to the external atom directly, OR use the feature's setter API
282
+ paginationAtom.set((old) => ({ ...old, pageIndex: 0 }))
283
+ // or
284
+ table.setPageIndex(0) // setter writes through the slice's updater (atom-aware)
285
+ ```
286
+
287
+ When an external atom owns a slice, `table.atoms.<slice>` derives from it — not from `baseAtoms`. Direct base-atom writes drift and never surface in the UI.
288
+
289
+ Source: docs/framework/vanilla/guide/table-state.md; packages/table-core/src/core/table/constructTable.ts
290
+
291
+ ### [CRITICAL] Forgetting `manualSorting` / `manualFiltering` / `manualPagination` for server-side data
292
+
293
+ Wrong:
294
+
295
+ ```tsx
296
+ // data is already paginated server-side, but table still slices it
297
+ const dataQuery = useQuery({
298
+ queryKey: ['data', pagination],
299
+ queryFn: fetchPage,
300
+ })
301
+ const table = useTable({
302
+ _features,
303
+ _rowModels: { paginatedRowModel: createPaginatedRowModel() },
304
+ columns,
305
+ data: dataQuery.data?.rows ?? [],
306
+ rowCount: dataQuery.data?.rowCount,
307
+ atoms: { pagination: paginationAtom },
308
+ // ❌ missing manualPagination: true
309
+ })
310
+ ```
311
+
312
+ Correct:
313
+
314
+ ```tsx
315
+ const table = useTable({
316
+ _features,
317
+ _rowModels: {}, // drop paginatedRowModel if fully server-side
318
+ columns,
319
+ data: dataQuery.data?.rows ?? [],
320
+ rowCount: dataQuery.data?.rowCount,
321
+ atoms: { pagination: paginationAtom },
322
+ manualPagination: true,
323
+ })
324
+ ```
325
+
326
+ Without the manual flag, the table re-applies its client-side row models on top of already-prepared server data — wrong rows, broken page math, blank pages.
327
+
328
+ Source: docs/framework/react/guide/table-state.md; packages/table-core/src/features/row-pagination/rowPaginationFeature.types.ts
329
+
330
+ ### [HIGH] Using `table.reset()` to clear externally owned state
331
+
332
+ Wrong:
333
+
334
+ ```ts
335
+ // external atom keeps its current value; only baseAtoms reset
336
+ const sortingAtom = useCreateAtom<SortingState>([])
337
+ const table = useTable({
338
+ _features, _rowModels: {...}, columns, data,
339
+ atoms: { sorting: sortingAtom },
340
+ })
341
+ table.reset() // sortingAtom is NOT cleared
342
+ ```
343
+
344
+ Correct:
345
+
346
+ ```ts
347
+ // Use feature-specific reset — atom-aware
348
+ table.resetSorting()
349
+ // or, to clear the external atom specifically:
350
+ sortingAtom.set([])
351
+ ```
352
+
353
+ `table.reset()` only resets `baseAtoms` to `initialState`; slices owned by external atoms or external `state` are untouched. The atom split makes `reset()` less safe than v8.
354
+
355
+ Source: docs/framework/vanilla/guide/table-state.md; packages/table-core/src/core/table/coreTablesFeature.utils.ts
356
+
357
+ ### [CRITICAL] Reimplementing what built-in setters provide
358
+
359
+ Wrong:
360
+
361
+ ```ts
362
+ // Reimplements sorting state manually instead of using the API
363
+ const [sorting, setSorting] = useState([])
364
+ const sortedData = useMemo(() => [...data].sort(/* ... */), [data, sorting])
365
+ // then uses sortedData directly, bypassing the table
366
+ ```
367
+
368
+ Correct:
369
+
370
+ ```ts
371
+ const table = useTable({
372
+ _features: tableFeatures({ rowSortingFeature }),
373
+ _rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
374
+ columns,
375
+ data,
376
+ })
377
+ // table.setSorting(...), column.toggleSorting(), header.getToggleSortingHandler()
378
+ ```
379
+
380
+ The setters honor reset behavior, multi-sort, internal invariants. Hand-rolled state loops skip all of that.
381
+
382
+ Source: maintainer interview (Phase 4, 2026-05-17)
383
+
384
+ ## See also
385
+
386
+ - `tanstack-table/setup` — how `_features` and `_rowModels` are wired
387
+ - `tanstack-table/pagination`, `tanstack-table/sorting`, `tanstack-table/filtering` — feature-specific `manual*` and reset semantics
388
+ - `tanstack-table/migrate-v8-to-v9` — `table.getState()` → `table.store.state` / `table.atoms.<slice>.get()`
@@ -3,9 +3,10 @@ import type { TableFeatures } from '../../types/TableFeatures'
3
3
  import type { Cell } from '../../types/Cell'
4
4
 
5
5
  /**
6
- * Returns value for a cell.
6
+ * Reads this cell's accessor value from its owning row and column.
7
7
  *
8
- * This is the static implementation behind the matching cell instance API and uses the owning row and column context.
8
+ * This is the standalone implementation behind `cell.getValue()`, useful when
9
+ * importing static APIs instead of calling methods from the cell prototype.
9
10
  *
10
11
  * @example
11
12
  * ```ts
@@ -21,13 +22,14 @@ export function cell_getValue<
21
22
  }
22
23
 
23
24
  /**
24
- * Returns value for a cell.
25
+ * Reads the value that should be rendered for this cell.
25
26
  *
26
- * This is the static implementation behind the matching cell instance API and uses the owning row and column context.
27
+ * Nullish accessor values are replaced with `table.options.renderFallbackValue`,
28
+ * matching the behavior of `cell.renderValue()`.
27
29
  *
28
30
  * @example
29
31
  * ```ts
30
- * const value = cell_renderValue(cell)
32
+ * const rendered = cell_renderValue(cell)
31
33
  * ```
32
34
  */
33
35
  export function cell_renderValue<
@@ -39,13 +41,14 @@ export function cell_renderValue<
39
41
  }
40
42
 
41
43
  /**
42
- * Returns context for a cell.
44
+ * Builds the render context passed to a column's `cell` template.
43
45
  *
44
- * This is the static implementation behind the matching cell instance API and uses the owning row and column context.
46
+ * The returned object includes stable references to the table, row, column, and
47
+ * cell, plus bound `getValue` and `renderValue` helpers for render functions.
45
48
  *
46
49
  * @example
47
50
  * ```ts
48
- * const value = cell_getContext(cell)
51
+ * const context = cell_getContext(cell)
49
52
  * ```
50
53
  */
51
54
  export function cell_getContext<
@@ -48,11 +48,12 @@ export interface Column_Column<
48
48
  TValue extends CellData = CellData,
49
49
  > extends Column_CoreProperties<TFeatures, TData, TValue> {
50
50
  /**
51
- * Returns the flattened array of this column and all child/grand-child columns for this column.
51
+ * Flattens this column and every descendant column into a single array.
52
52
  */
53
53
  getFlatColumns: () => Array<Column<TFeatures, TData, TValue>>
54
54
  /**
55
- * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.
55
+ * Collects the terminal leaf columns below this column, or the column itself
56
+ * when it has no children.
56
57
  */
57
58
  getLeafColumns: () => Array<Column<TFeatures, TData, TValue>>
58
59
  }
@@ -81,19 +82,19 @@ export interface Table_Columns<
81
82
  */
82
83
  getAllFlatColumnsById: () => Record<string, Column<TFeatures, TData, unknown>>
83
84
  /**
84
- * Returns the default column options to use for all column defs supplied to the table.
85
+ * Resolves built-in, feature-level, and user-defined default column options.
85
86
  */
86
87
  getDefaultColumnDef: () => Partial<ColumnDef<TFeatures, TData, unknown>>
87
88
  /**
88
- * Returns all columns in the table in their normalized and nested hierarchy.
89
+ * Normalizes `options.columns` into the table's nested column hierarchy.
89
90
  */
90
91
  getAllColumns: () => Array<Column<TFeatures, TData, unknown>>
91
92
  /**
92
- * Returns all columns in the table flattened to a single level.
93
+ * Flattens the nested column hierarchy, including parent/group columns.
93
94
  */
94
95
  getAllFlatColumns: () => Array<Column<TFeatures, TData, unknown>>
95
96
  /**
96
- * Returns all leaf-node columns in the table flattened to a single level. This does not include parent columns.
97
+ * Collects all terminal leaf columns, excluding parent/group columns.
97
98
  */
98
99
  getAllLeafColumns: () => Array<Column<TFeatures, TData, unknown>>
99
100
  /**
@@ -12,13 +12,14 @@ import type {
12
12
  import type { Column } from '../../types/Column'
13
13
 
14
14
  /**
15
- * Returns flat columns for a column.
15
+ * Flattens this column and every descendant column into a single array.
16
16
  *
17
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
17
+ * Group columns appear before their child columns, which matches the normalized
18
+ * column hierarchy produced during table construction.
18
19
  *
19
20
  * @example
20
21
  * ```ts
21
- * const value = column_getFlatColumns(column)
22
+ * const flatColumns = column_getFlatColumns(column)
22
23
  * ```
23
24
  */
24
25
  export function column_getFlatColumns<
@@ -32,13 +33,14 @@ export function column_getFlatColumns<
32
33
  }
33
34
 
34
35
  /**
35
- * Returns leaf columns for a column.
36
+ * Collects the terminal leaf columns below this column.
36
37
  *
37
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
38
+ * Group columns return their ordered descendants. Non-group columns return an
39
+ * array containing only the column itself.
38
40
  *
39
41
  * @example
40
42
  * ```ts
41
- * const value = column_getLeafColumns(column)
43
+ * const leafColumns = column_getLeafColumns(column)
42
44
  * ```
43
45
  */
44
46
  export function column_getLeafColumns<
@@ -64,13 +66,15 @@ export function column_getLeafColumns<
64
66
  }
65
67
 
66
68
  /**
67
- * Returns default column def for the table.
69
+ * Merges built-in, feature, and user default column definitions.
68
70
  *
69
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
71
+ * Built-in defaults provide a header and fallback cell renderer, feature
72
+ * defaults can add feature-specific column options, and
73
+ * `options.defaultColumn` wins last.
70
74
  *
71
75
  * @example
72
76
  * ```ts
73
- * const value = table_getDefaultColumnDef(table)
77
+ * const defaultColumn = table_getDefaultColumnDef(table)
74
78
  * ```
75
79
  */
76
80
  export function table_getDefaultColumnDef<
@@ -103,13 +107,14 @@ export function table_getDefaultColumnDef<
103
107
  }
104
108
 
105
109
  /**
106
- * Returns all columns for the table.
110
+ * Normalizes `options.columns` into the table's nested column tree.
107
111
  *
108
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
112
+ * Each column definition is constructed with its parent and depth, and group
113
+ * column children are recursively constructed.
109
114
  *
110
115
  * @example
111
116
  * ```ts
112
- * const value = table_getAllColumns(table)
117
+ * const columns = table_getAllColumns(table)
113
118
  * ```
114
119
  */
115
120
  export function table_getAllColumns<
@@ -144,13 +149,14 @@ export function table_getAllColumns<
144
149
  }
145
150
 
146
151
  /**
147
- * Returns all flat columns for the table.
152
+ * Flattens every table column, including group columns and leaf columns.
148
153
  *
149
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
154
+ * Use this when parent/group columns must be included in addition to data leaf
155
+ * columns.
150
156
  *
151
157
  * @example
152
158
  * ```ts
153
- * const value = table_getAllFlatColumns(table)
159
+ * const flatColumns = table_getAllFlatColumns(table)
154
160
  * ```
155
161
  */
156
162
  export function table_getAllFlatColumns<
@@ -163,13 +169,14 @@ export function table_getAllFlatColumns<
163
169
  }
164
170
 
165
171
  /**
166
- * Returns all flat columns by id for the table.
172
+ * Builds an id lookup for every flat column in the table.
167
173
  *
168
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
174
+ * Group columns and leaf columns are included. Later columns with the same id
175
+ * replace earlier entries.
169
176
  *
170
177
  * @example
171
178
  * ```ts
172
- * const value = table_getAllFlatColumnsById(table)
179
+ * const columnsById = table_getAllFlatColumnsById(table)
173
180
  * ```
174
181
  */
175
182
  export function table_getAllFlatColumnsById<
@@ -188,13 +195,14 @@ export function table_getAllFlatColumnsById<
188
195
  }
189
196
 
190
197
  /**
191
- * Returns all leaf columns for the table.
198
+ * Collects all terminal leaf columns in their current table order.
192
199
  *
193
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
200
+ * Column ordering features can reorder the collected leaves before the result
201
+ * is returned.
194
202
  *
195
203
  * @example
196
204
  * ```ts
197
- * const value = table_getAllLeafColumns(table)
205
+ * const leafColumns = table_getAllLeafColumns(table)
198
206
  * ```
199
207
  */
200
208
  export function table_getAllLeafColumns<
@@ -214,13 +222,14 @@ export function table_getAllLeafColumns<
214
222
  }
215
223
 
216
224
  /**
217
- * Returns all leaf columns by id for the table.
225
+ * Builds an id lookup for terminal leaf columns only.
218
226
  *
219
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
227
+ * Parent/group columns are excluded, making this lookup appropriate for row
228
+ * cells and feature state keyed by data columns.
220
229
  *
221
230
  * @example
222
231
  * ```ts
223
- * const value = table_getAllLeafColumnsById(table)
232
+ * const leavesById = table_getAllLeafColumnsById(table)
224
233
  * ```
225
234
  */
226
235
  export function table_getAllLeafColumnsById<
@@ -239,13 +248,14 @@ export function table_getAllLeafColumnsById<
239
248
  }
240
249
 
241
250
  /**
242
- * Returns column for the table.
251
+ * Looks up a column by id from the flat column map.
243
252
  *
244
- * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.
253
+ * The lookup can return group columns or leaf columns. In development, a
254
+ * missing id logs a warning to help catch stale column references.
245
255
  *
246
256
  * @example
247
257
  * ```ts
248
- * const value = table_getColumn(table)
258
+ * const column = table_getColumn(table, 'firstName')
249
259
  * ```
250
260
  */
251
261
  export function table_getColumn<
@@ -10,19 +10,21 @@ export interface Table_Headers<
10
10
  TData extends RowData,
11
11
  > {
12
12
  /**
13
- * Returns all header groups for the table.
13
+ * Builds the visible header groups for the current column tree, visibility,
14
+ * and pinning state.
14
15
  */
15
16
  getHeaderGroups: () => Array<HeaderGroup<TFeatures, TData>>
16
17
  /**
17
- * Returns the footer groups for the table.
18
+ * Builds footer groups by reversing the current header group order.
18
19
  */
19
20
  getFooterGroups: () => Array<HeaderGroup<TFeatures, TData>>
20
21
  /**
21
- * Returns headers for all columns in the table, including parent headers.
22
+ * Flattens every header from every header group, including parent and
23
+ * placeholder headers.
22
24
  */
23
25
  getFlatHeaders: () => Array<Header<TFeatures, TData, unknown>>
24
26
  /**
25
- * Returns headers for all leaf columns in the table, (not including parent headers).
27
+ * Collects only leaf headers, excluding parent/group headers.
26
28
  */
27
29
  getLeafHeaders: () => Array<Header<TFeatures, TData, unknown>>
28
30
  }