@tanstack/vue-table 9.0.0-beta.4 → 9.0.0-beta.40
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.
- package/README.md +1 -0
- package/dist/FlexRender.cjs +2 -3
- package/dist/FlexRender.cjs.map +1 -1
- package/dist/FlexRender.d.cts +30 -12
- package/dist/FlexRender.d.ts +30 -12
- package/dist/FlexRender.js +2 -3
- package/dist/FlexRender.js.map +1 -1
- package/dist/createTableHook.cjs +4 -9
- package/dist/createTableHook.cjs.map +1 -1
- package/dist/createTableHook.d.cts +49 -21
- package/dist/createTableHook.d.ts +49 -21
- package/dist/createTableHook.js +4 -9
- package/dist/createTableHook.js.map +1 -1
- package/dist/experimental-worker-plugin.cjs +9 -0
- package/dist/experimental-worker-plugin.d.cts +1 -0
- package/dist/experimental-worker-plugin.d.ts +1 -0
- package/dist/experimental-worker-plugin.js +3 -0
- package/dist/flex-render.d.cts +2 -2
- package/dist/flex-render.d.ts +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/reactivity.cjs +2 -6
- package/dist/reactivity.cjs.map +1 -1
- package/dist/reactivity.js +2 -6
- package/dist/reactivity.js.map +1 -1
- package/dist/useTable.cjs +3 -7
- package/dist/useTable.cjs.map +1 -1
- package/dist/useTable.d.cts +1 -8
- package/dist/useTable.d.ts +1 -8
- package/dist/useTable.js +3 -7
- package/dist/useTable.js.map +1 -1
- package/package.json +8 -4
- package/skills/vue/client-to-server/SKILL.md +21 -26
- package/skills/vue/compose-with-tanstack-form/SKILL.md +4 -4
- package/skills/vue/compose-with-tanstack-pacer/SKILL.md +6 -3
- package/skills/vue/compose-with-tanstack-query/SKILL.md +18 -20
- package/skills/vue/compose-with-tanstack-store/SKILL.md +7 -6
- package/skills/vue/compose-with-tanstack-virtual/SKILL.md +8 -4
- package/skills/vue/getting-started/SKILL.md +55 -49
- package/skills/vue/migrate-v8-to-v9/SKILL.md +50 -32
- package/skills/vue/production-readiness/SKILL.md +28 -21
- package/skills/vue/table-state/SKILL.md +22 -26
- package/src/FlexRender.ts +28 -13
- package/src/createTableHook.ts +112 -20
- package/src/experimental-worker-plugin.ts +1 -0
- package/src/reactivity.ts +1 -2
- package/src/useTable.ts +3 -11
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
name: vue/migrate-v8-to-v9
|
|
3
3
|
description: >
|
|
4
4
|
Mechanical breaking-change migration from `@tanstack/vue-table` v8 to v9. Rename `useVueTable`
|
|
5
|
-
→ `useTable`, move `getCoreRowModel`/`getSortedRowModel`/etc. options into `
|
|
6
|
-
|
|
7
|
-
`createColumnHelper<TData>()` → `createColumnHelper<typeof features, TData>()`, rename
|
|
5
|
+
→ `useTable`, move `getCoreRowModel`/`getSortedRowModel`/etc. options into the `tableFeatures`
|
|
6
|
+
object as row model factory slots, add the mandatory `features` via `tableFeatures({...})`,
|
|
7
|
+
update `createColumnHelper<TData>()` → `createColumnHelper<typeof features, TData>()`, rename
|
|
8
8
|
`sortingFn`/`sortingFns` → `sortFn`/`sortFns`, swap `table.getState()` for `table.state`
|
|
9
|
-
/ `table.state` / `table.atoms.<slice>.get()`, and prefer `<FlexRender :cell="cell" />` over
|
|
10
|
-
legacy `:render`/`:props` shape. Vue has NO `/legacy` entrypoint — migration is a direct
|
|
9
|
+
/ `table.state` / `table.atoms.<slice>.get()`, and prefer `<FlexRender :cell="cell" />` over
|
|
10
|
+
the legacy `:render`/`:props` shape. Vue has NO `/legacy` entrypoint — migration is a direct
|
|
11
11
|
rewrite. The Vue adapter installs `vueReactivity()` automatically.
|
|
12
12
|
type: lifecycle
|
|
13
13
|
library: tanstack-table
|
|
@@ -89,7 +89,13 @@ import {
|
|
|
89
89
|
useTable,
|
|
90
90
|
} from '@tanstack/vue-table'
|
|
91
91
|
|
|
92
|
-
const features = tableFeatures({
|
|
92
|
+
const features = tableFeatures({
|
|
93
|
+
rowSortingFeature,
|
|
94
|
+
rowPaginationFeature,
|
|
95
|
+
sortedRowModel: createSortedRowModel(),
|
|
96
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
97
|
+
sortFns,
|
|
98
|
+
})
|
|
93
99
|
const columnHelper = createColumnHelper<typeof features, Person>()
|
|
94
100
|
const columns = columnHelper.columns([
|
|
95
101
|
columnHelper.accessor('age', { header: 'Age', sortFn: 'alphanumeric' }), // sortingFn → sortFn
|
|
@@ -97,10 +103,6 @@ const columns = columnHelper.columns([
|
|
|
97
103
|
|
|
98
104
|
const table = useTable({
|
|
99
105
|
features,
|
|
100
|
-
rowModels: {
|
|
101
|
-
sortedRowModel: createSortedRowModel(sortFns),
|
|
102
|
-
paginatedRowModel: createPaginatedRowModel(),
|
|
103
|
-
},
|
|
104
106
|
columns,
|
|
105
107
|
data,
|
|
106
108
|
})
|
|
@@ -118,10 +120,10 @@ const table = useTable({
|
|
|
118
120
|
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
119
121
|
| `useVueTable(opts)` | `useTable(opts, selector?)` |
|
|
120
122
|
| `getCoreRowModel: getCoreRowModel()` | implicit; not an option |
|
|
121
|
-
| `getSortedRowModel: getSortedRowModel()` | `
|
|
122
|
-
| `getFilteredRowModel: getFilteredRowModel()` | `
|
|
123
|
-
| `getPaginationRowModel: getPaginationRowModel()` | `
|
|
124
|
-
| `getGroupedRowModel: getGroupedRowModel()` | `
|
|
123
|
+
| `getSortedRowModel: getSortedRowModel()` | `tableFeatures({ sortedRowModel: createSortedRowModel(), sortFns })` |
|
|
124
|
+
| `getFilteredRowModel: getFilteredRowModel()` | `tableFeatures({ filteredRowModel: createFilteredRowModel(), filterFns })` |
|
|
125
|
+
| `getPaginationRowModel: getPaginationRowModel()` | `tableFeatures({ paginatedRowModel: createPaginatedRowModel() })` |
|
|
126
|
+
| `getGroupedRowModel: getGroupedRowModel()` | `tableFeatures({ groupedRowModel: createGroupedRowModel(), aggregationFns })` |
|
|
125
127
|
| `createColumnHelper<TData>()` | `createColumnHelper<typeof features, TData>()` |
|
|
126
128
|
| `ColumnDef<TData, TValue>` | `ColumnDef<TFeatures, TData, TValue>` |
|
|
127
129
|
| `Column<TData, TValue>` / `Row<TData>` / `Cell<TData, TValue>` | `…<TFeatures, TData, TValue>` |
|
|
@@ -143,19 +145,28 @@ non-Vue-specific renames are shared across adapters).
|
|
|
143
145
|
|
|
144
146
|
## Core Patterns
|
|
145
147
|
|
|
146
|
-
### 1. Convert `getXRowModel` options to
|
|
148
|
+
### 1. Convert `getXRowModel` options to features-slot factories
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
tree-shakeable
|
|
150
|
+
Row model factories now live on the `tableFeatures({...})` object alongside the feature
|
|
151
|
+
they belong to. The `*Fns` registries move there too — this is what makes them tree-shakeable
|
|
152
|
+
in v9.
|
|
150
153
|
|
|
151
154
|
```ts
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
const features = tableFeatures({
|
|
156
|
+
rowSortingFeature,
|
|
157
|
+
columnFilteringFeature,
|
|
158
|
+
rowPaginationFeature,
|
|
159
|
+
rowGroupingFeature,
|
|
160
|
+
rowExpandingFeature,
|
|
161
|
+
sortedRowModel: createSortedRowModel(),
|
|
162
|
+
filteredRowModel: createFilteredRowModel(),
|
|
155
163
|
paginatedRowModel: createPaginatedRowModel(),
|
|
156
|
-
groupedRowModel:
|
|
157
|
-
expandedRowModel:
|
|
158
|
-
|
|
164
|
+
groupedRowModel: createGroupedRowModel(),
|
|
165
|
+
expandedRowModel: createExpandedRowModel(),
|
|
166
|
+
sortFns,
|
|
167
|
+
filterFns,
|
|
168
|
+
aggregationFns,
|
|
169
|
+
})
|
|
159
170
|
```
|
|
160
171
|
|
|
161
172
|
The `*Fns` registries are open-ended; do not cite a number of built-in fns.
|
|
@@ -214,7 +225,6 @@ const sorting = ref<SortingState>([])
|
|
|
214
225
|
|
|
215
226
|
const table = useTable({
|
|
216
227
|
features,
|
|
217
|
-
rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
|
|
218
228
|
columns,
|
|
219
229
|
data,
|
|
220
230
|
state: {
|
|
@@ -276,14 +286,15 @@ const table = useTable({
|
|
|
276
286
|
getCoreRowModel: getCoreRowModel(),
|
|
277
287
|
})
|
|
278
288
|
|
|
279
|
-
// ✅ Core row model is implicit. `rowModels
|
|
280
|
-
const table = useTable({ features,
|
|
289
|
+
// ✅ Core row model is implicit. No `rowModels` option needed.
|
|
290
|
+
const table = useTable({ features, columns, data })
|
|
281
291
|
```
|
|
282
292
|
|
|
283
293
|
### Forgetting `features` (CRITICAL)
|
|
284
294
|
|
|
285
295
|
`features` is required even for a no-features migration. Pass `tableFeatures({})` for empty,
|
|
286
|
-
or list everything you use
|
|
296
|
+
or list everything you use (features + row model factories + fn registries). Without it:
|
|
297
|
+
`'features' is missing in type`.
|
|
287
298
|
|
|
288
299
|
### Wrong `createColumnHelper` generic arity (CRITICAL)
|
|
289
300
|
|
|
@@ -298,14 +309,21 @@ const columnHelper = createColumnHelper<typeof features, Person>()
|
|
|
298
309
|
Same applies to type annotations: `ColumnDef<typeof features, Person>`,
|
|
299
310
|
`Row<typeof features, Person>`, `Cell<typeof features, Person, unknown>`.
|
|
300
311
|
|
|
301
|
-
### Forgetting to
|
|
312
|
+
### Forgetting to register `sortFns` / `filterFns` in the features object (CRITICAL)
|
|
302
313
|
|
|
303
314
|
```ts
|
|
304
315
|
// ❌ Runtime: no sort fns registered, sort is a no-op.
|
|
305
|
-
|
|
316
|
+
const features = tableFeatures({
|
|
317
|
+
rowSortingFeature,
|
|
318
|
+
sortedRowModel: createSortedRowModel(),
|
|
319
|
+
})
|
|
306
320
|
|
|
307
|
-
// ✅
|
|
308
|
-
|
|
321
|
+
// ✅ Register the fn map as a slot on the features object.
|
|
322
|
+
const features = tableFeatures({
|
|
323
|
+
rowSortingFeature,
|
|
324
|
+
sortedRowModel: createSortedRowModel(),
|
|
325
|
+
sortFns,
|
|
326
|
+
})
|
|
309
327
|
```
|
|
310
328
|
|
|
311
329
|
### Missed `sortingFn` → `sortFn` rename (HIGH)
|
|
@@ -371,5 +389,5 @@ etc.
|
|
|
371
389
|
- `tanstack-table/vue/getting-started` — the v9 minimum-viable shape
|
|
372
390
|
- `tanstack-table/vue/table-state` — reactivity model + reading state
|
|
373
391
|
- `tanstack-table/vue/production-readiness` — finish the migration with bundle + identity audits
|
|
374
|
-
- `tanstack-table/table-core/setup` — `features` /
|
|
392
|
+
- `tanstack-table/table-core/setup` — `features` / row model factory slots deep dive
|
|
375
393
|
- `tanstack-table/table-core/column-definitions` — column helper + generics
|
|
@@ -3,13 +3,14 @@ name: vue/production-readiness
|
|
|
3
3
|
description: >
|
|
4
4
|
Ship-ready optimizations for `@tanstack/vue-table` v9. Tree-shake by listing ONLY the
|
|
5
5
|
`features` you actually render — never default to `stockFeatures`. Keep `features`,
|
|
6
|
-
`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`
|
|
12
|
-
|
|
6
|
+
`columnHelper`, and `columns` at module scope for stable identity (Vue re-evaluates the
|
|
7
|
+
`<script setup>` block per component instance — declare these outside or in a const). Row
|
|
8
|
+
model factories and fn registries live as slots on the `tableFeatures({...})` object, not as
|
|
9
|
+
a separate `rowModels` option. Use the `useTable(opts, selector)` second argument or per-slice
|
|
10
|
+
`computed(() => table.atoms.<slice>.get())` / `useSelector(table.atoms.<slice>)` from
|
|
11
|
+
`@tanstack/vue-store` to narrow re-renders. Vue's reactivity already evaluates only dirty
|
|
12
|
+
computed deps, so `table.Subscribe` is NOT the React-Compiler workaround it is in React;
|
|
13
|
+
reach for fine-grained reads (`computed`, `useSelector`) first.
|
|
13
14
|
type: lifecycle
|
|
14
15
|
library: tanstack-table
|
|
15
16
|
framework: vue
|
|
@@ -52,26 +53,24 @@ import {
|
|
|
52
53
|
export const features = tableFeatures({
|
|
53
54
|
rowSortingFeature,
|
|
54
55
|
rowPaginationFeature,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export const rowModels = {
|
|
58
|
-
sortedRowModel: createSortedRowModel(sortFns),
|
|
56
|
+
sortedRowModel: createSortedRowModel(),
|
|
59
57
|
paginatedRowModel: createPaginatedRowModel(),
|
|
60
|
-
|
|
58
|
+
sortFns,
|
|
59
|
+
})
|
|
61
60
|
```
|
|
62
61
|
|
|
63
62
|
```vue
|
|
64
63
|
<script setup lang="ts">
|
|
65
64
|
import { ref } from 'vue'
|
|
66
65
|
import { useTable } from '@tanstack/vue-table'
|
|
67
|
-
import { features
|
|
66
|
+
import { features } from './table-setup'
|
|
68
67
|
import { columns } from './columns'
|
|
69
68
|
|
|
70
69
|
const props = defineProps<{ data: Person[] }>()
|
|
71
70
|
const data = ref(props.data)
|
|
72
71
|
|
|
73
72
|
// Narrow selector — table.state only carries what we actually render at this level.
|
|
74
|
-
const table = useTable({ features,
|
|
73
|
+
const table = useTable({ features, columns, data }, (state) => ({
|
|
75
74
|
pagination: state.pagination,
|
|
76
75
|
sorting: state.sorting,
|
|
77
76
|
}))
|
|
@@ -95,12 +94,16 @@ const features = tableFeatures({ rowSortingFeature })
|
|
|
95
94
|
isn't wired into a column def or UI handler, drop it. v9 is tree-shakeable specifically so you
|
|
96
95
|
only pay for what you use.
|
|
97
96
|
|
|
98
|
-
### 2. Module-scope `features` / `
|
|
97
|
+
### 2. Module-scope `features` / `columnHelper` / `columns`
|
|
99
98
|
|
|
100
99
|
```ts
|
|
101
100
|
// ❌ Inside <script setup> — every component instance creates new identities, which churns
|
|
102
101
|
// the table's option-watcher and triggers a `setOptions` on every reactive tick.
|
|
103
|
-
const features = tableFeatures({
|
|
102
|
+
const features = tableFeatures({
|
|
103
|
+
rowSortingFeature,
|
|
104
|
+
sortedRowModel: createSortedRowModel(),
|
|
105
|
+
sortFns,
|
|
106
|
+
})
|
|
104
107
|
const columnHelper = createColumnHelper<typeof features, Person>()
|
|
105
108
|
const columns = columnHelper.columns([
|
|
106
109
|
/* ... */
|
|
@@ -109,7 +112,11 @@ const columns = columnHelper.columns([
|
|
|
109
112
|
|
|
110
113
|
```ts
|
|
111
114
|
// ✅ Module scope — one identity, shared across instances, GC-friendly.
|
|
112
|
-
const features = tableFeatures({
|
|
115
|
+
const features = tableFeatures({
|
|
116
|
+
rowSortingFeature,
|
|
117
|
+
sortedRowModel: createSortedRowModel(),
|
|
118
|
+
sortFns,
|
|
119
|
+
})
|
|
113
120
|
const columnHelper = createColumnHelper<typeof features, Person>()
|
|
114
121
|
export const columns = columnHelper.columns([
|
|
115
122
|
/* ... */
|
|
@@ -124,11 +131,11 @@ write `data: ref([...])` inline in the table options (a fresh ref each render).
|
|
|
124
131
|
```ts
|
|
125
132
|
// ❌ Default selector — table.state contains every registered slice; any state change re-renders
|
|
126
133
|
// every consumer of table.state.
|
|
127
|
-
const table = useTable({ features,
|
|
134
|
+
const table = useTable({ features, columns, data })
|
|
128
135
|
|
|
129
136
|
// ✅ Project only what THIS component renders. Other slices still drive table internals; you
|
|
130
137
|
// just don't subscribe to them at the component level.
|
|
131
|
-
const table = useTable({ features,
|
|
138
|
+
const table = useTable({ features, columns, data }, (state) => ({
|
|
132
139
|
pagination: state.pagination,
|
|
133
140
|
sorting: state.sorting,
|
|
134
141
|
}))
|
|
@@ -191,7 +198,7 @@ Use `table.Subscribe` only for cross-store source subscription (`<table.Subscrib
|
|
|
191
198
|
Defeats the entire reason v9 is tree-shakeable. Replace with an explicit
|
|
192
199
|
`tableFeatures({...})` listing only the features your UI renders.
|
|
193
200
|
|
|
194
|
-
### Re-declaring `features` / `
|
|
201
|
+
### Re-declaring `features` / `columns` inside `<script setup>` (HIGH)
|
|
195
202
|
|
|
196
203
|
Vue runs `<script setup>` once per component instance, but that's still per-page-navigation in
|
|
197
204
|
SPAs and per-instance in any reusable component. Module scope is cheapest and shared.
|
|
@@ -217,7 +224,7 @@ watchEffect(() => {
|
|
|
217
224
|
|
|
218
225
|
```ts
|
|
219
226
|
// ❌ Whole table re-evaluates table.state on every keystroke in a column filter.
|
|
220
|
-
const table = useTable({ features,
|
|
227
|
+
const table = useTable({ features, columns, data })
|
|
221
228
|
|
|
222
229
|
// ✅
|
|
223
230
|
const table = useTable(opts, (s) => ({ pagination: s.pagination }))
|
|
@@ -41,9 +41,10 @@ v8 name `useVueTable` no longer exists.
|
|
|
41
41
|
|
|
42
42
|
## Setup
|
|
43
43
|
|
|
44
|
-
Every Vue table call requires `features` (built from `tableFeatures({...})`)
|
|
45
|
-
|
|
46
|
-
use the matching
|
|
44
|
+
Every Vue table call requires `features` (built from `tableFeatures({...})`). Row model
|
|
45
|
+
factories now live on the features object alongside the feature itself. Core row model is
|
|
46
|
+
automatic; only register `paginatedRowModel`, `sortedRowModel`, etc. when you use the matching
|
|
47
|
+
feature.
|
|
47
48
|
|
|
48
49
|
```vue
|
|
49
50
|
<script setup lang="ts">
|
|
@@ -61,7 +62,11 @@ import {
|
|
|
61
62
|
type Person = { firstName: string; lastName: string; age: number }
|
|
62
63
|
|
|
63
64
|
// Stable identity — declare outside the component or at module scope.
|
|
64
|
-
const features = tableFeatures({
|
|
65
|
+
const features = tableFeatures({
|
|
66
|
+
rowSortingFeature,
|
|
67
|
+
sortedRowModel: createSortedRowModel(),
|
|
68
|
+
sortFns,
|
|
69
|
+
})
|
|
65
70
|
const columnHelper = createColumnHelper<typeof features, Person>()
|
|
66
71
|
const columns = columnHelper.columns([
|
|
67
72
|
columnHelper.accessor('firstName', { header: 'First' }),
|
|
@@ -73,7 +78,6 @@ const data = ref<Person[]>([])
|
|
|
73
78
|
|
|
74
79
|
const table = useTable({
|
|
75
80
|
features,
|
|
76
|
-
rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
|
|
77
81
|
columns,
|
|
78
82
|
// Reactive data: pass the ref directly OR a getter — the adapter unwraps.
|
|
79
83
|
data,
|
|
@@ -102,7 +106,7 @@ const table = useTable({
|
|
|
102
106
|
|
|
103
107
|
### Why this works
|
|
104
108
|
|
|
105
|
-
The Vue adapter calls `vueReactivity()` and installs it as `
|
|
109
|
+
The Vue adapter calls `vueReactivity()` and installs it as `coreReactivityFeature` automatically
|
|
106
110
|
(see `packages/vue-table/src/useTable.ts`):
|
|
107
111
|
|
|
108
112
|
- Readonly atoms back onto `computed()` refs.
|
|
@@ -133,7 +137,6 @@ const snapshot = table.state
|
|
|
133
137
|
const table = useTable(
|
|
134
138
|
{
|
|
135
139
|
features,
|
|
136
|
-
rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
|
|
137
140
|
columns,
|
|
138
141
|
data,
|
|
139
142
|
},
|
|
@@ -155,12 +158,11 @@ The adapter accepts a `ref`/`computed` for any option. The idiomatic shapes are:
|
|
|
155
158
|
```ts
|
|
156
159
|
// (a) Pass the ref directly — adapter unwraps via `unref()`
|
|
157
160
|
const data = ref(makeData(100))
|
|
158
|
-
const table = useTable({ features,
|
|
161
|
+
const table = useTable({ features, columns, data })
|
|
159
162
|
|
|
160
163
|
// (b) Use a getter when `data` is owned by a parent object
|
|
161
164
|
const table = useTable({
|
|
162
165
|
features,
|
|
163
|
-
rowModels: {},
|
|
164
166
|
columns,
|
|
165
167
|
get data() {
|
|
166
168
|
return data.value
|
|
@@ -171,7 +173,6 @@ const table = useTable({
|
|
|
171
173
|
const filtered = computed(() => data.value.filter(/* … */))
|
|
172
174
|
const table = useTable({
|
|
173
175
|
features,
|
|
174
|
-
rowModels: {},
|
|
175
176
|
columns,
|
|
176
177
|
get data() {
|
|
177
178
|
return filtered.value
|
|
@@ -199,7 +200,10 @@ import {
|
|
|
199
200
|
type PaginationState,
|
|
200
201
|
} from '@tanstack/vue-table'
|
|
201
202
|
|
|
202
|
-
const features = tableFeatures({
|
|
203
|
+
const features = tableFeatures({
|
|
204
|
+
rowPaginationFeature,
|
|
205
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
206
|
+
})
|
|
203
207
|
|
|
204
208
|
const paginationAtom = createAtom<PaginationState>({
|
|
205
209
|
pageIndex: 0,
|
|
@@ -210,7 +214,6 @@ const pagination = useSelector(paginationAtom) // reactive ref-like
|
|
|
210
214
|
const data = ref([] as Person[])
|
|
211
215
|
const table = useTable({
|
|
212
216
|
features,
|
|
213
|
-
rowModels: { paginatedRowModel: createPaginatedRowModel() },
|
|
214
217
|
columns,
|
|
215
218
|
data,
|
|
216
219
|
atoms: { pagination: paginationAtom },
|
|
@@ -240,10 +243,6 @@ const pagination = ref<PaginationState>({ pageIndex: 0, pageSize: 10 })
|
|
|
240
243
|
|
|
241
244
|
const table = useTable({
|
|
242
245
|
features,
|
|
243
|
-
rowModels: {
|
|
244
|
-
sortedRowModel: createSortedRowModel(sortFns),
|
|
245
|
-
paginatedRowModel: createPaginatedRowModel(),
|
|
246
|
-
},
|
|
247
246
|
columns,
|
|
248
247
|
data,
|
|
249
248
|
state: {
|
|
@@ -302,7 +301,6 @@ return () => (
|
|
|
302
301
|
const pagination = ref<PaginationState>({ pageIndex: 0, pageSize: 10 })
|
|
303
302
|
const table = useTable({
|
|
304
303
|
features,
|
|
305
|
-
rowModels: {},
|
|
306
304
|
columns,
|
|
307
305
|
data,
|
|
308
306
|
state: { pagination },
|
|
@@ -311,7 +309,6 @@ const table = useTable({
|
|
|
311
309
|
// ✅ Use a getter so Vue tracks `.value`.
|
|
312
310
|
const table = useTable({
|
|
313
311
|
features,
|
|
314
|
-
rowModels: {},
|
|
315
312
|
columns,
|
|
316
313
|
data,
|
|
317
314
|
state: {
|
|
@@ -355,17 +352,16 @@ import { useTable } from '@tanstack/vue-table'
|
|
|
355
352
|
```ts
|
|
356
353
|
// ❌ `rowSortingFeature` not registered → `table.setSorting` and `table.atoms.sorting` do not exist.
|
|
357
354
|
const features = tableFeatures({})
|
|
358
|
-
const table = useTable({ features,
|
|
355
|
+
const table = useTable({ features, columns, data })
|
|
359
356
|
table.setSorting([{ id: 'age', desc: true }]) // TS error / runtime no-op
|
|
360
357
|
|
|
361
|
-
// ✅ Register the feature
|
|
362
|
-
const features = tableFeatures({
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
columns,
|
|
367
|
-
data,
|
|
358
|
+
// ✅ Register the feature and its matching row model factory inside tableFeatures.
|
|
359
|
+
const features = tableFeatures({
|
|
360
|
+
rowSortingFeature,
|
|
361
|
+
sortedRowModel: createSortedRowModel(),
|
|
362
|
+
sortFns,
|
|
368
363
|
})
|
|
364
|
+
const table = useTable({ features, columns, data })
|
|
369
365
|
```
|
|
370
366
|
|
|
371
367
|
### Reimplementing built-in state transitions (CRITICAL — #1 AI tell)
|
package/src/FlexRender.ts
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { defineComponent, h, isVNode } from 'vue'
|
|
2
2
|
import type { PropType } from 'vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
3
|
+
|
|
4
|
+
export interface FlexRenderCell {
|
|
5
|
+
column: {
|
|
6
|
+
columnDef: {
|
|
7
|
+
aggregatedCell?: any
|
|
8
|
+
cell?: any
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
getContext: () => any
|
|
12
|
+
getIsAggregated?: () => boolean
|
|
13
|
+
getIsPlaceholder?: () => boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface FlexRenderHeader {
|
|
17
|
+
column: {
|
|
18
|
+
columnDef: {
|
|
19
|
+
footer?: any
|
|
20
|
+
header?: any
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getContext: () => any
|
|
24
|
+
}
|
|
10
25
|
|
|
11
26
|
/**
|
|
12
27
|
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
@@ -60,24 +75,24 @@ export const FlexRender = defineComponent({
|
|
|
60
75
|
default: undefined,
|
|
61
76
|
},
|
|
62
77
|
cell: {
|
|
63
|
-
type: Object as PropType<
|
|
78
|
+
type: Object as PropType<FlexRenderCell>,
|
|
64
79
|
default: undefined,
|
|
65
80
|
},
|
|
66
81
|
header: {
|
|
67
|
-
type: Object as PropType<
|
|
82
|
+
type: Object as PropType<FlexRenderHeader>,
|
|
68
83
|
default: undefined,
|
|
69
84
|
},
|
|
70
85
|
footer: {
|
|
71
|
-
type: Object as PropType<
|
|
86
|
+
type: Object as PropType<FlexRenderHeader>,
|
|
72
87
|
default: undefined,
|
|
73
88
|
},
|
|
74
89
|
},
|
|
75
90
|
setup: (props: {
|
|
76
91
|
render?: any
|
|
77
92
|
props?: any
|
|
78
|
-
cell?:
|
|
79
|
-
header?:
|
|
80
|
-
footer?:
|
|
93
|
+
cell?: FlexRenderCell
|
|
94
|
+
header?: FlexRenderHeader
|
|
95
|
+
footer?: FlexRenderHeader
|
|
81
96
|
}) => {
|
|
82
97
|
return () => {
|
|
83
98
|
// New shorthand pattern: extract render and props from cell/header/footer
|