@tanstack/vue-table 9.0.0-beta.7 → 9.0.0-beta.71

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 +5 -1
  2. package/dist/FlexRender.d.ts +1 -2
  3. package/dist/FlexRender.js +5 -5
  4. package/dist/createTableHook.d.ts +40 -20
  5. package/dist/createTableHook.js +10 -24
  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 +3 -12
  12. package/dist/useTable.js +7 -11
  13. package/package.json +14 -22
  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,409 +0,0 @@
1
- ---
2
- name: vue/getting-started
3
- description: >
4
- End-to-end first-table walkthrough for `@tanstack/vue-table` v9. Install the adapter, declare
5
- `features` via `tableFeatures({})`, declare `rowModels` with their `*Fns` parameters
6
- (`createSortedRowModel(sortFns)`, `createPaginatedRowModel()`, …), build a column helper with
7
- both `TFeatures` and `TData` generics, instantiate `useTable(options, selector?)` from a
8
- `<script setup>` block, and render with `<FlexRender :cell="cell" />` / `:header="header"`.
9
- New users land here, not on legacy v8 names like `useVueTable`.
10
- type: lifecycle
11
- library: tanstack-table
12
- framework: vue
13
- library_version: '9.0.0-alpha.48'
14
- requires:
15
- - setup
16
- - column-definitions
17
- - state-management
18
- - vue/table-state
19
- sources:
20
- - docs/installation.md
21
- - docs/framework/vue/vue-table.md
22
- - docs/framework/vue/guide/table-state.md
23
- - examples/vue/basic-use-table/
24
- - examples/vue/basic-use-app-table/
25
- - packages/vue-table/src/useTable.ts
26
- ---
27
-
28
- # Getting Started with @tanstack/vue-table v9
29
-
30
- ## Dependencies
31
-
32
- ```bash
33
- pnpm add @tanstack/vue-table vue
34
- # Optional: external atoms / shared state
35
- pnpm add @tanstack/vue-store
36
- ```
37
-
38
- Vue 3 only. There is no `/legacy` entrypoint for Vue (that exists only for React); migrating
39
- from v8 is a direct rewrite — see `tanstack-table/vue/migrate-v8-to-v9`.
40
-
41
- ## Setup — minimum viable table
42
-
43
- ```vue
44
- <script setup lang="ts">
45
- import { ref } from 'vue'
46
- import {
47
- FlexRender,
48
- createColumnHelper,
49
- tableFeatures,
50
- useTable,
51
- } from '@tanstack/vue-table'
52
-
53
- type Person = { firstName: string; lastName: string; age: number }
54
-
55
- // Stable identities — declare at module scope (outside <script setup> blocks).
56
- const features = tableFeatures({}) // required — even when no features are used
57
- const columnHelper = createColumnHelper<typeof features, Person>() // note: TWO generics
58
-
59
- const columns = columnHelper.columns([
60
- columnHelper.accessor('firstName', { header: 'First' }),
61
- columnHelper.accessor('lastName', { header: 'Last' }),
62
- columnHelper.accessor('age', { header: 'Age' }),
63
- ])
64
-
65
- const data = ref<Person[]>([
66
- { firstName: 'tanner', lastName: 'linsley', age: 24 },
67
- { firstName: 'kevin', lastName: 'vandy', age: 28 },
68
- ])
69
-
70
- const table = useTable({
71
- features,
72
- rowModels: {}, // required — core row model is automatic
73
- columns,
74
- data,
75
- })
76
- </script>
77
-
78
- <template>
79
- <table>
80
- <thead>
81
- <tr v-for="hg in table.getHeaderGroups()" :key="hg.id">
82
- <th v-for="h in hg.headers" :key="h.id">
83
- <FlexRender v-if="!h.isPlaceholder" :header="h" />
84
- </th>
85
- </tr>
86
- </thead>
87
- <tbody>
88
- <tr v-for="row in table.getRowModel().rows" :key="row.id">
89
- <td v-for="cell in row.getAllCells()" :key="cell.id">
90
- <FlexRender :cell="cell" />
91
- </td>
92
- </tr>
93
- </tbody>
94
- </table>
95
- </template>
96
- ```
97
-
98
- Source: `examples/vue/basic-use-table/src/App.tsx`, `docs/framework/vue/vue-table.md`.
99
-
100
- ### What's mandatory in v9
101
-
102
- - `features` — built via `tableFeatures({...})`. Empty object is fine for a no-features table,
103
- but the option key must exist.
104
- - `rowModels` — `{}` is fine (core row model is automatic). Register factories per feature.
105
- - `createColumnHelper<typeof features, Person>()` — two generics, in that order. The v8 single
106
- generic does not compile.
107
-
108
- ## Core Patterns
109
-
110
- ### 1. Add a feature: sorting
111
-
112
- ```vue
113
- <script setup lang="ts">
114
- import { ref } from 'vue'
115
- import {
116
- FlexRender,
117
- createColumnHelper,
118
- createSortedRowModel,
119
- rowSortingFeature,
120
- sortFns,
121
- tableFeatures,
122
- useTable,
123
- } from '@tanstack/vue-table'
124
-
125
- const features = tableFeatures({ rowSortingFeature })
126
- const columnHelper = createColumnHelper<typeof features, Person>()
127
- const columns = columnHelper.columns([
128
- columnHelper.accessor('firstName', { header: 'First' }),
129
- columnHelper.accessor('age', { header: 'Age' }),
130
- ])
131
-
132
- const data = ref<Person[]>([])
133
-
134
- const table = useTable({
135
- features,
136
- rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
137
- columns,
138
- data,
139
- })
140
- </script>
141
-
142
- <template>
143
- <thead>
144
- <tr v-for="hg in table.getHeaderGroups()" :key="hg.id">
145
- <th
146
- v-for="h in hg.headers"
147
- :key="h.id"
148
- :class="{ sortable: h.column.getCanSort() }"
149
- @click="h.column.getToggleSortingHandler()?.($event)"
150
- >
151
- <FlexRender v-if="!h.isPlaceholder" :header="h" />
152
- <span v-if="h.column.getIsSorted() === 'asc'"> 🔼</span>
153
- <span v-if="h.column.getIsSorted() === 'desc'"> 🔽</span>
154
- </th>
155
- </tr>
156
- </thead>
157
- </template>
158
- ```
159
-
160
- Three rules:
161
-
162
- 1. Register the feature in `features` (`rowSortingFeature`).
163
- 2. Provide the matching row model factory in `rowModels`
164
- (`sortedRowModel: createSortedRowModel(sortFns)`). The factory **requires its `*Fns`
165
- parameter** in v9 — this is what makes filter/sort registries tree-shakeable.
166
- 3. Wire UI to the built-in API: `column.getToggleSortingHandler()`, `column.getIsSorted()`.
167
- Do not reimplement sort logic.
168
-
169
- Source: `docs/framework/vue/vue-table.md`, `examples/vue/sorting/`.
170
-
171
- ### 2. Compose features: pagination + filtering on top of sorting
172
-
173
- ```ts
174
- import {
175
- columnFilteringFeature,
176
- createFilteredRowModel,
177
- createPaginatedRowModel,
178
- createSortedRowModel,
179
- filterFns,
180
- rowPaginationFeature,
181
- rowSortingFeature,
182
- sortFns,
183
- tableFeatures,
184
- } from '@tanstack/vue-table'
185
-
186
- const features = tableFeatures({
187
- rowSortingFeature,
188
- rowPaginationFeature,
189
- columnFilteringFeature,
190
- })
191
-
192
- const rowModels = {
193
- sortedRowModel: createSortedRowModel(sortFns),
194
- filteredRowModel: createFilteredRowModel(filterFns),
195
- paginatedRowModel: createPaginatedRowModel(),
196
- }
197
- ```
198
-
199
- Then use `table.nextPage()`, `table.setPageIndex(0)`, `table.setColumnFilters(...)`,
200
- `table.setSorting(...)`. The library exposes a state-transition API for every feature — use it.
201
-
202
- ### 3. App-scoped tables with `createTableHook`
203
-
204
- If multiple tables in your app share `features`, `rowModels`, and conventions, prefer
205
- `createTableHook`. The hook factory returns `useAppTable`, `createAppColumnHelper`, plus
206
- context helpers (`useTableContext`, `useCellContext`, `useHeaderContext`).
207
-
208
- ```ts
209
- // src/hooks/table.ts
210
- import {
211
- createPaginatedRowModel,
212
- createSortedRowModel,
213
- createTableHook,
214
- rowPaginationFeature,
215
- rowSortingFeature,
216
- sortFns,
217
- tableFeatures,
218
- } from '@tanstack/vue-table'
219
-
220
- const features = tableFeatures({ rowSortingFeature, rowPaginationFeature })
221
-
222
- export const { useAppTable, createAppColumnHelper } = createTableHook({
223
- features,
224
- rowModels: {
225
- sortedRowModel: createSortedRowModel(sortFns),
226
- paginatedRowModel: createPaginatedRowModel(),
227
- },
228
- })
229
- ```
230
-
231
- ```vue
232
- <script setup lang="ts">
233
- import { useAppTable, createAppColumnHelper } from '@/hooks/table'
234
- import { ref } from 'vue'
235
-
236
- const columnHelper = createAppColumnHelper<Person>()
237
- const columns = columnHelper.columns([
238
- columnHelper.accessor('firstName', { header: 'First' }),
239
- ])
240
-
241
- const data = ref<Person[]>([])
242
- const table = useAppTable({ columns, data })
243
- </script>
244
-
245
- <template>
246
- <table>
247
- <thead>
248
- <tr v-for="hg in table.getHeaderGroups()" :key="hg.id">
249
- <th v-for="h in hg.headers" :key="h.id">
250
- <component :is="table.FlexRender" :header="h" />
251
- </th>
252
- </tr>
253
- </thead>
254
- </table>
255
- </template>
256
- ```
257
-
258
- Source: `examples/vue/basic-use-app-table/src/App.vue`,
259
- `examples/vue/composable-tables/src/hooks/table.ts`.
260
-
261
- ### 4. JSX render functions when templates get noisy
262
-
263
- Vue's JSX support is fine — pass `cell`/`header` props to `<FlexRender>` and the rest is the same.
264
-
265
- ```tsx
266
- // App.tsx
267
- import { defineComponent, ref } from 'vue'
268
- import { FlexRender, tableFeatures, useTable } from '@tanstack/vue-table'
269
-
270
- const features = tableFeatures({})
271
-
272
- export default defineComponent({
273
- setup() {
274
- const data = ref<Person[]>([])
275
- const table = useTable({
276
- features,
277
- rowModels: {},
278
- columns,
279
- get data() {
280
- return data.value
281
- },
282
- })
283
-
284
- return () => (
285
- <table>
286
- <tbody>
287
- {table.getRowModel().rows.map((row) => (
288
- <tr key={row.id}>
289
- {row.getAllCells().map((cell) => (
290
- <td key={cell.id}>
291
- <FlexRender cell={cell} />
292
- </td>
293
- ))}
294
- </tr>
295
- ))}
296
- </tbody>
297
- </table>
298
- )
299
- },
300
- })
301
- ```
302
-
303
- Source: `examples/vue/basic-use-table/src/App.tsx`.
304
-
305
- ## Common Mistakes
306
-
307
- ### Omitting `features` or `rowModels` (CRITICAL)
308
-
309
- ```ts
310
- // ❌ TS error: Property 'features' is missing in type ...
311
- const table = useTable({ columns, data })
312
-
313
- // ✅
314
- const features = tableFeatures({})
315
- const table = useTable({ features, rowModels: {}, columns, data })
316
- ```
317
-
318
- Both keys are required even for the simplest table.
319
-
320
- ### Wrong `createColumnHelper` arity (CRITICAL)
321
-
322
- ```ts
323
- // ❌ v8 single-generic shape — does not compile in v9.
324
- const columnHelper = createColumnHelper<Person>()
325
-
326
- // ✅ v9 — TFeatures FIRST, then TData.
327
- const columnHelper = createColumnHelper<typeof features, Person>()
328
- ```
329
-
330
- ### Calling row-model factories without their `*Fns` parameter (CRITICAL)
331
-
332
- ```ts
333
- // ❌ TS error / runtime missing fns.
334
- rowModels: {
335
- sortedRowModel: createSortedRowModel(),
336
- filteredRowModel: createFilteredRowModel(),
337
- }
338
-
339
- // ✅ Pass the matching registry.
340
- rowModels: {
341
- sortedRowModel: createSortedRowModel(sortFns),
342
- filteredRowModel: createFilteredRowModel(filterFns),
343
- }
344
- ```
345
-
346
- This is what makes v9 tree-shakeable. Filter/sort/aggregation registries are open-ended — do
347
- not cite a number of built-in fns; just pass `filterFns` / `sortFns` / `aggregationFns`.
348
-
349
- ### "API missing" because the feature is not in `features` (CRITICAL, v9-specific)
350
-
351
- ```ts
352
- // ❌ `rowSortingFeature` not registered → `table.setSorting` is `undefined` and a TS error.
353
- const features = tableFeatures({})
354
- const table = useTable({ features, rowModels: {}, columns, data })
355
- table.setSorting([{ id: 'age', desc: true }]) // missing
356
-
357
- // ✅ Register the feature AND its row model.
358
- const features = tableFeatures({ rowSortingFeature })
359
- const table = useTable({
360
- features,
361
- rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
362
- columns,
363
- data,
364
- })
365
- ```
366
-
367
- This is the #1 v9-specific failure mode — features must be declared to surface their APIs.
368
-
369
- ### Reaching for `useVueTable` (HIGH — pre-v9 hallucination)
370
-
371
- `useVueTable` was the v8 name. v9 renamed every adapter to `useTable`. There is no Vue
372
- `/legacy` entrypoint — migration is a rewrite.
373
-
374
- ### Reimplementing built-in state transitions (CRITICAL — #1 AI tell)
375
-
376
- ```ts
377
- // ❌ Hand-rolled sort state.
378
- const sorting = ref<SortingState>([])
379
- const sorted = computed(() => [...data.value].sort(/* … */))
380
-
381
- // ✅ Use the API: table.setSorting / table.toggleSorting / column.getToggleSortingHandler.
382
- ```
383
-
384
- TanStack Table IS the state coordinator. Built-in APIs handle invariants, reset semantics, and
385
- multi-sort correctly.
386
-
387
- ### Unstable references for `features`, `columns`, `data`
388
-
389
- ```vue
390
- <script setup>
391
- // ❌ New identity every component mount, breaks internal memoization.
392
- const features = tableFeatures({ rowSortingFeature })
393
- const columns = [...]
394
- </script>
395
- ```
396
-
397
- Declare `features`, `columnHelper`, and `columns` at **module scope** (top of file, outside
398
- `<script setup>`). For `data`, a stable `ref` is fine — the adapter watches its `.value`.
399
-
400
- ### Using `useReactTable` / `getCoreRowModel()` as an option (CRITICAL — v8 muscle memory)
401
-
402
- Pure v8. Doesn't exist in `@tanstack/vue-table`. See `migrate-v8-to-v9`.
403
-
404
- ## See Also
405
-
406
- - `tanstack-table/vue/table-state` — the reactivity model you'll use as soon as you add features
407
- - `tanstack-table/vue/production-readiness` — once it works, optimize bundle + re-renders
408
- - `tanstack-table/vue/migrate-v8-to-v9` — coming from `useVueTable`
409
- - `tanstack-table/table-core/column-definitions` — column helper deep dive