@tanstack/vue-table 9.0.0-beta.6 → 9.0.0-beta.61

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 (61) hide show
  1. package/README.md +2 -0
  2. package/dist/FlexRender.d.ts +1 -2
  3. package/dist/FlexRender.js +5 -5
  4. package/dist/createTableHook.d.ts +39 -13
  5. package/dist/createTableHook.js +8 -23
  6. package/dist/experimental-worker-plugin.d.ts +1 -0
  7. package/dist/experimental-worker-plugin.js +3 -0
  8. package/dist/index.d.ts +2 -2
  9. package/dist/merge-proxy.js +1 -2
  10. package/dist/reactivity.js +3 -8
  11. package/dist/useTable.d.ts +2 -10
  12. package/dist/useTable.js +4 -9
  13. package/package.json +12 -20
  14. package/skills/create-table-hook/SKILL.md +146 -0
  15. package/skills/getting-started/SKILL.md +144 -0
  16. package/skills/migrate-v8-to-v9/SKILL.md +185 -0
  17. package/skills/table-state/SKILL.md +191 -0
  18. package/skills/with-tanstack-query/SKILL.md +127 -0
  19. package/skills/with-tanstack-virtual/SKILL.md +116 -0
  20. package/dist/FlexRender.cjs +0 -80
  21. package/dist/FlexRender.cjs.map +0 -1
  22. package/dist/FlexRender.d.cts +0 -63
  23. package/dist/FlexRender.js.map +0 -1
  24. package/dist/createTableHook.cjs +0 -194
  25. package/dist/createTableHook.cjs.map +0 -1
  26. package/dist/createTableHook.d.cts +0 -135
  27. package/dist/createTableHook.js.map +0 -1
  28. package/dist/flex-render.cjs +0 -5
  29. package/dist/flex-render.d.cts +0 -2
  30. package/dist/index.cjs +0 -17
  31. package/dist/index.d.cts +0 -5
  32. package/dist/merge-proxy.cjs +0 -77
  33. package/dist/merge-proxy.cjs.map +0 -1
  34. package/dist/merge-proxy.js.map +0 -1
  35. package/dist/reactivity.cjs +0 -64
  36. package/dist/reactivity.cjs.map +0 -1
  37. package/dist/reactivity.js.map +0 -1
  38. package/dist/static-functions.cjs +0 -9
  39. package/dist/static-functions.d.cts +0 -1
  40. package/dist/useTable.cjs +0 -76
  41. package/dist/useTable.cjs.map +0 -1
  42. package/dist/useTable.d.cts +0 -43
  43. package/dist/useTable.js.map +0 -1
  44. package/skills/vue/client-to-server/SKILL.md +0 -365
  45. package/skills/vue/compose-with-tanstack-form/SKILL.md +0 -369
  46. package/skills/vue/compose-with-tanstack-pacer/SKILL.md +0 -318
  47. package/skills/vue/compose-with-tanstack-query/SKILL.md +0 -385
  48. package/skills/vue/compose-with-tanstack-store/SKILL.md +0 -301
  49. package/skills/vue/compose-with-tanstack-virtual/SKILL.md +0 -340
  50. package/skills/vue/getting-started/SKILL.md +0 -409
  51. package/skills/vue/migrate-v8-to-v9/SKILL.md +0 -375
  52. package/skills/vue/production-readiness/SKILL.md +0 -271
  53. package/skills/vue/table-state/SKILL.md +0 -403
  54. package/src/FlexRender.ts +0 -138
  55. package/src/createTableHook.ts +0 -534
  56. package/src/flex-render.ts +0 -1
  57. package/src/index.ts +0 -4
  58. package/src/merge-proxy.ts +0 -132
  59. package/src/reactivity.ts +0 -89
  60. package/src/static-functions.ts +0 -1
  61. package/src/useTable.ts +0 -181
@@ -1,365 +0,0 @@
1
- ---
2
- name: vue/client-to-server
3
- description: >
4
- Convert a client-side `@tanstack/vue-table` to server-side. Set `manualPagination` /
5
- `manualSorting` / `manualFiltering` / `manualGrouping` / `manualExpanding` for whichever
6
- slices the server owns; drop the matching `rowModels` factories (don't ship
7
- `paginatedRowModel` when the server paginates); supply `rowCount` so `table.getPageCount()`
8
- works; own the relevant state slices via either external atoms (`@tanstack/vue-store`
9
- `createAtom` + `options.atoms`) or `state` + `on[State]Change` with getter wrappers. Key any
10
- data fetch (TanStack Query / fetch / rxResource alternative) on the controlled state and use
11
- `placeholderData: keepPreviousData` (or equivalent) to avoid a 0-rows flash between pages.
12
- type: lifecycle
13
- library: tanstack-table
14
- framework: vue
15
- library_version: '9.0.0-alpha.48'
16
- requires:
17
- - state-management
18
- - pagination
19
- - filtering
20
- - sorting
21
- sources:
22
- - examples/vue/basic-external-atoms/
23
- - examples/vue/basic-external-state/
24
- - examples/vue/with-tanstack-query/
25
- - docs/framework/vue/guide/table-state.md
26
- ---
27
-
28
- # Client-to-Server Conversion (Vue)
29
-
30
- ## Dependencies
31
-
32
- ```bash
33
- pnpm add @tanstack/vue-table @tanstack/vue-store
34
- # Recommended fetch layer:
35
- pnpm add @tanstack/vue-query
36
- ```
37
-
38
- External atoms (`@tanstack/vue-store`) are recommended for server-managed slices. They cut the
39
- `on[State]Change` plumbing entirely — the table writes to the atom; the query keys on the atom.
40
-
41
- ## Setup — minimal server-paginated table
42
-
43
- ```vue
44
- <script setup lang="ts">
45
- import { computed, ref, watchEffect } from 'vue'
46
- import { createAtom, useSelector } from '@tanstack/vue-store'
47
- import { keepPreviousData, useQuery } from '@tanstack/vue-query'
48
- import {
49
- FlexRender,
50
- createColumnHelper,
51
- rowPaginationFeature,
52
- tableFeatures,
53
- useTable,
54
- type PaginationState,
55
- } from '@tanstack/vue-table'
56
- import { fetchPeople } from './api'
57
-
58
- type Person = { firstName: string; lastName: string; age: number }
59
-
60
- const features = tableFeatures({ rowPaginationFeature })
61
- const columnHelper = createColumnHelper<typeof features, Person>()
62
- const columns = columnHelper.columns([
63
- columnHelper.accessor('firstName', { header: 'First' }),
64
- columnHelper.accessor('lastName', { header: 'Last' }),
65
- columnHelper.accessor('age', { header: 'Age' }),
66
- ])
67
-
68
- // 1) Own pagination in an external atom. Cheap for the table to write through.
69
- const paginationAtom = createAtom<PaginationState>({
70
- pageIndex: 0,
71
- pageSize: 10,
72
- })
73
- const pagination = useSelector(paginationAtom)
74
-
75
- // 2) Key the query on the atom value. table.setPageIndex(...) writes to the atom
76
- // → useSelector re-evaluates → useQuery refetches.
77
- const dataQuery = useQuery(() => ({
78
- queryKey: ['people', pagination.value],
79
- queryFn: () => fetchPeople(pagination.value),
80
- placeholderData: keepPreviousData, // avoid "0 rows" flash between pages
81
- }))
82
-
83
- const tableData = computed<Person[]>(() => dataQuery.data.value?.rows ?? [])
84
- const rowCount = ref(0)
85
- watchEffect(() => {
86
- const next = dataQuery.data.value?.rowCount
87
- if (next != null) rowCount.value = next // keep last known total for pager UI
88
- })
89
-
90
- // 3) Manual pagination + `rowCount`. NO paginatedRowModel in `rowModels` — server paginates.
91
- const table = useTable({
92
- features,
93
- rowModels: {},
94
- columns,
95
- data: tableData,
96
- rowCount,
97
- atoms: { pagination: paginationAtom },
98
- manualPagination: true,
99
- })
100
- </script>
101
- ```
102
-
103
- Source: `examples/vue/with-tanstack-query/src/App.tsx`, `examples/vue/basic-external-atoms/`.
104
-
105
- ## Core Patterns
106
-
107
- ### 1. The `manual*` flag + `rowModels` drop pair
108
-
109
- Pick which slices live server-side and flip the matching `manual*` flag. **Also drop the
110
- matching `rowModels` factory** — otherwise the table re-processes server-processed rows.
111
-
112
- | Server owns | Set | Drop from `rowModels` |
113
- | ----------- | ------------------------ | --------------------- |
114
- | Pagination | `manualPagination: true` | `paginatedRowModel` |
115
- | Sorting | `manualSorting: true` | `sortedRowModel` |
116
- | Filtering | `manualFiltering: true` | `filteredRowModel` |
117
- | Grouping | `manualGrouping: true` | `groupedRowModel` |
118
- | Expanding | `manualExpanding: true` | `expandedRowModel` |
119
-
120
- Column visibility / ordering / pinning / row selection are client-side state and stay as-is.
121
-
122
- ### 2. `rowCount` so `getPageCount()` works
123
-
124
- Without `rowCount`, `getPageCount()` falls back to `Math.ceil(data.length / pageSize)` — i.e.
125
- `1` if the server already paginated. The pager locks at "Page 1 of 1".
126
-
127
- ```ts
128
- useTable({
129
- features,
130
- rowModels: {},
131
- columns,
132
- data: tableData,
133
- rowCount: dataQuery.data.value?.rowCount, // or a stable ref/computed
134
- atoms: { pagination: paginationAtom },
135
- manualPagination: true,
136
- })
137
- ```
138
-
139
- If `rowCount` isn't immediately available, hold the last known value in a `ref` and update via
140
- `watchEffect` so the pager doesn't reset to 0 during refetches.
141
-
142
- ### 3. Two state-ownership shapes (pick one per slice)
143
-
144
- **External atoms (recommended with Query).** Table writes through to the atom. No
145
- `on[State]Change` needed.
146
-
147
- ```ts
148
- const paginationAtom = createAtom<PaginationState>({
149
- pageIndex: 0,
150
- pageSize: 10,
151
- })
152
- useTable({
153
- features,
154
- rowModels: {},
155
- columns,
156
- data,
157
- rowCount,
158
- atoms: { pagination: paginationAtom },
159
- manualPagination: true,
160
- })
161
- ```
162
-
163
- **Classic `state` + `on[State]Change` with getters.** Required when migrating from v8 or
164
- integrating with existing Vue ref-based state. Each slice must be a getter so Vue tracks
165
- `.value`.
166
-
167
- ```ts
168
- const pagination = ref<PaginationState>({ pageIndex: 0, pageSize: 10 })
169
-
170
- useTable({
171
- features,
172
- rowModels: {},
173
- columns,
174
- data,
175
- rowCount,
176
- state: {
177
- get pagination() {
178
- return pagination.value
179
- },
180
- },
181
- onPaginationChange: (u) => {
182
- pagination.value = typeof u === 'function' ? u(pagination.value) : u
183
- },
184
- manualPagination: true,
185
- })
186
- ```
187
-
188
- **Precedence:** `atoms[slice]` > `state[slice]` > internal `baseAtoms[slice]`. Don't pass the
189
- same slice through both — the atoms wins silently.
190
-
191
- ### 4. Cache keys must include controlled state
192
-
193
- ```ts
194
- const sortingAtom = createAtom<SortingState>([])
195
- const paginationAtom = createAtom<PaginationState>({
196
- pageIndex: 0,
197
- pageSize: 10,
198
- })
199
- const sorting = useSelector(sortingAtom)
200
- const pagination = useSelector(paginationAtom)
201
-
202
- const dataQuery = useQuery(() => ({
203
- queryKey: [
204
- 'people',
205
- { sorting: sorting.value, pagination: pagination.value },
206
- ],
207
- queryFn: () =>
208
- fetchPeople({ sorting: sorting.value, pagination: pagination.value }),
209
- placeholderData: keepPreviousData,
210
- }))
211
- ```
212
-
213
- If pagination/sort/filter aren't in `queryKey`, Query won't refetch when the user clicks a
214
- pager button — the buttons "do nothing" from the user's POV.
215
-
216
- ### 5. Mixed client + server features still work
217
-
218
- Column visibility, ordering, pinning, and row selection are client state — they don't depend
219
- on the row model and continue to function with `manualPagination`/`manualSorting`/`manualFiltering`.
220
- You can have a server-paginated table where the user pins or hides columns locally.
221
-
222
- ## Common Mistakes
223
-
224
- ### Forgetting `manualPagination` / `manualSorting` / `manualFiltering` (CRITICAL)
225
-
226
- The table double-processes server-processed rows. If the server returned page 2 of 50,
227
- the table will paginate that 10-row slice again and show "Page 1 of 1".
228
-
229
- ```ts
230
- // ❌
231
- useTable({
232
- features,
233
- rowModels: {},
234
- columns,
235
- data: serverPage.rows,
236
- rowCount,
237
- atoms: { pagination: paginationAtom },
238
- // missing: manualPagination: true
239
- })
240
- ```
241
-
242
- ### Leaving `paginatedRowModel` registered when server paginates (CRITICAL)
243
-
244
- ```ts
245
- // ❌ Factory ships for nothing AND the table re-paginates server-sliced data.
246
- rowModels: {
247
- paginatedRowModel: createPaginatedRowModel()
248
- }
249
-
250
- // ✅
251
- rowModels: {
252
- }
253
- ```
254
-
255
- Same applies to `sortedRowModel`, `filteredRowModel`, `groupedRowModel`, `expandedRowModel`
256
- when the server owns the slice.
257
-
258
- ### Omitting `rowCount` (CRITICAL)
259
-
260
- `getPageCount()` returns `1` if the server already paginated. The pager UI locks at
261
- "Page 1 of 1" and users can't navigate.
262
-
263
- ### Passing `state.pagination` without `onPaginationChange` (CRITICAL)
264
-
265
- ```ts
266
- // ❌ table.setPageIndex(2) is a no-op — no writeback handler.
267
- const pagination = ref({ pageIndex: 0, pageSize: 10 })
268
- useTable({
269
- features,
270
- rowModels: {},
271
- columns,
272
- data,
273
- rowCount,
274
- state: {
275
- get pagination() {
276
- return pagination.value
277
- },
278
- },
279
- manualPagination: true,
280
- })
281
-
282
- // ✅ Either pair `state` with `on[State]Change`, OR use `atoms`.
283
- ```
284
-
285
- ### Mixing `state.pagination` AND `atoms.pagination` for the same slice (HIGH)
286
-
287
- ```ts
288
- useTable({
289
- // ...
290
- state: {
291
- get pagination() {
292
- return localPagination.value
293
- },
294
- }, // silently ignored
295
- onPaginationChange: setLocalPagination, // silently ignored
296
- atoms: { pagination: paginationAtom }, // wins
297
- })
298
- ```
299
-
300
- Atoms beat `state`; the `state` plumbing is dead but lingering in the code. Pick one mechanism.
301
-
302
- ### Forgetting to include controlled state in `queryKey` (CRITICAL)
303
-
304
- ```ts
305
- // ❌ Never refetches when pagination changes.
306
- useQuery(() => ({
307
- queryKey: ['people'],
308
- queryFn: () => fetchPeople(pagination.value),
309
- }))
310
-
311
- // ✅
312
- useQuery(() => ({
313
- queryKey: ['people', pagination.value],
314
- queryFn: () => fetchPeople(pagination.value),
315
- }))
316
- ```
317
-
318
- ### Skipping `placeholderData: keepPreviousData` (HIGH)
319
-
320
- Between fetches the table collapses to 0 rows, the row container collapses, and scroll
321
- position jumps. `keepPreviousData` keeps the previous page visible during the refetch.
322
-
323
- ### Passing a raw `ref` to `state.pagination` without a getter (CRITICAL — Vue-specific)
324
-
325
- ```ts
326
- // ❌ Vue can't track .value changes on the captured ref object.
327
- state: { pagination: pagination }
328
-
329
- // ✅
330
- state: { get pagination() { return pagination.value } }
331
- ```
332
-
333
- ### Hand-rolling sort/page state instead of using the API (CRITICAL — #1 AI tell)
334
-
335
- ```ts
336
- // ❌ Manual state machine.
337
- const pageIndex = ref(0)
338
- const next = () => {
339
- pageIndex.value++
340
- refetch()
341
- }
342
-
343
- // ✅ Built-ins.
344
- table.nextPage()
345
- table.setPageIndex(0)
346
- table.setSorting([{ id: 'age', desc: true }])
347
- table.setColumnFilters(/* ... */)
348
- ```
349
-
350
- ### "API missing" because the feature isn't in `features` (CRITICAL — v9-specific)
351
-
352
- Server-side pagination still needs `rowPaginationFeature` in `tableFeatures({...})` — that's
353
- what surfaces `table.setPageIndex`, `table.nextPage`, `table.getPageCount`. The factory in
354
- `rowModels` is what you drop; the feature stays.
355
-
356
- ```ts
357
- const features = tableFeatures({ rowPaginationFeature }) // ✅ even with manualPagination
358
- ```
359
-
360
- ## See Also
361
-
362
- - `tanstack-table/vue/compose-with-tanstack-query` — the Query-specific wiring
363
- - `tanstack-table/vue/compose-with-tanstack-store` — external atoms in depth
364
- - `tanstack-table/vue/table-state` — getter rule, atom precedence
365
- - `tanstack-table/table-core/pagination` — `manualPagination` / `rowCount` semantics