@tanstack/svelte-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.
- package/README.md +5 -1
- package/dist/FlexRender.svelte +15 -1
- package/dist/createTable.svelte.d.ts +26 -36
- package/dist/createTable.svelte.js +27 -32
- package/dist/createTableHook.svelte.d.ts +51 -18
- package/dist/createTableHook.svelte.js +18 -10
- package/dist/experimental-worker-plugin.d.ts +1 -0
- package/dist/experimental-worker-plugin.js +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/reactivity.svelte.d.ts +3 -1
- package/dist/reactivity.svelte.js +6 -1
- package/dist/render-component.js +4 -0
- package/package.json +16 -9
- package/skills/create-table-hook/SKILL.md +168 -0
- package/skills/getting-started/SKILL.md +172 -0
- package/skills/migrate-v8-to-v9/SKILL.md +201 -0
- package/skills/table-state/SKILL.md +262 -0
- package/skills/with-tanstack-query/SKILL.md +149 -0
- package/skills/with-tanstack-virtual/SKILL.md +150 -0
- package/dist/subscribe.d.ts +0 -24
- package/dist/subscribe.js +0 -4
- package/skills/svelte/client-to-server/SKILL.md +0 -238
- package/skills/svelte/compose-with-tanstack-form/SKILL.md +0 -295
- package/skills/svelte/compose-with-tanstack-pacer/SKILL.md +0 -176
- package/skills/svelte/compose-with-tanstack-query/SKILL.md +0 -299
- package/skills/svelte/compose-with-tanstack-store/SKILL.md +0 -277
- package/skills/svelte/compose-with-tanstack-virtual/SKILL.md +0 -286
- package/skills/svelte/getting-started/SKILL.md +0 -340
- package/skills/svelte/migrate-v8-to-v9/SKILL.md +0 -256
- package/skills/svelte/production-readiness/SKILL.md +0 -256
- package/skills/svelte/table-state/SKILL.md +0 -441
- package/src/AppCell.svelte +0 -13
- package/src/AppHeader.svelte +0 -13
- package/src/AppTable.svelte +0 -11
- package/src/FlexRender.svelte +0 -103
- package/src/context-keys.ts +0 -3
- package/src/createTable.svelte.ts +0 -137
- package/src/createTableHook.svelte.ts +0 -639
- package/src/createTableState.svelte.ts +0 -30
- package/src/flex-render.ts +0 -3
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -21
- package/src/merge-objects.ts +0 -79
- package/src/reactivity.svelte.ts +0 -118
- package/src/render-component.ts +0 -107
- package/src/static-functions.ts +0 -1
- package/src/subscribe.ts +0 -46
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-table-hook
|
|
3
|
+
description: >
|
|
4
|
+
Define a Svelte createAppTable/createAppColumnHelper using the adapter's rune-capable createTableHook implementation, shared features/defaults, reactive per-table getters, optional App component registries, and typed table/cell/header context hooks.
|
|
5
|
+
metadata:
|
|
6
|
+
type: framework
|
|
7
|
+
library: '@tanstack/svelte-table'
|
|
8
|
+
framework: svelte
|
|
9
|
+
library_version: '9.0.0-beta.71'
|
|
10
|
+
requires:
|
|
11
|
+
- '@tanstack/table-core#core'
|
|
12
|
+
- getting-started
|
|
13
|
+
- table-state
|
|
14
|
+
sources:
|
|
15
|
+
- 'TanStack/table:docs/framework/svelte/guide/composable-tables.md'
|
|
16
|
+
- 'TanStack/table:examples/svelte/composable-tables'
|
|
17
|
+
- 'TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
This skill builds on `@tanstack/table-core#core`, `getting-started`, and `table-state`. Use it when multiple tables share conventions; keep one-off tables on `createTable`.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
Use the shipped `createTableHook`; its implementation is rune-capable. The app hook module itself may be a normal `.ts` module, as in the maintained example.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import {
|
|
28
|
+
createTableHook,
|
|
29
|
+
rowSortingFeature,
|
|
30
|
+
tableFeatures,
|
|
31
|
+
} from '@tanstack/svelte-table'
|
|
32
|
+
|
|
33
|
+
export const {
|
|
34
|
+
createAppTable,
|
|
35
|
+
createAppColumnHelper,
|
|
36
|
+
useTableContext,
|
|
37
|
+
useCellContext,
|
|
38
|
+
useHeaderContext,
|
|
39
|
+
} = createTableHook({
|
|
40
|
+
features: tableFeatures({ rowSortingFeature }),
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```svelte
|
|
45
|
+
<script lang="ts">
|
|
46
|
+
import { createAppColumnHelper, createAppTable } from './app-table.svelte'
|
|
47
|
+
type Person = { name: string }
|
|
48
|
+
const helper = createAppColumnHelper<Person>()
|
|
49
|
+
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])
|
|
50
|
+
let data = $state<Person[]>([{ name: 'Ada' }])
|
|
51
|
+
const table = createAppTable({
|
|
52
|
+
columns,
|
|
53
|
+
get data() {
|
|
54
|
+
return data
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Core Patterns
|
|
61
|
+
|
|
62
|
+
### Register reusable components once
|
|
63
|
+
|
|
64
|
+
Pass stable `tableComponents`, `cellComponents`, and `headerComponents` to `createTableHook`. Render them through the returned `AppTable`, `AppCell`, and `AppHeader` wrappers so their typed context hooks have a provider.
|
|
65
|
+
|
|
66
|
+
### Prefer context inside registered components
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { useCellContext } from './app-table.svelte'
|
|
70
|
+
|
|
71
|
+
const cell = useCellContext<string>()
|
|
72
|
+
const value = cell.getValue()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This avoids prop drilling and keeps feature/component types bound to the app hook.
|
|
76
|
+
|
|
77
|
+
## Common Mistakes
|
|
78
|
+
|
|
79
|
+
### CRITICAL Reimplementing the rune-aware hook
|
|
80
|
+
|
|
81
|
+
Wrong:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
// app-table.ts
|
|
85
|
+
export function createAppTable(options) {
|
|
86
|
+
return constructTable(options)
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Correct:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// app-table.ts
|
|
94
|
+
export const { createAppTable } = createTableHook({ features })
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The shipped implementation supplies Svelte rune reactivity, option synchronization, wrappers, and context plumbing that a plain core wrapper omits.
|
|
98
|
+
|
|
99
|
+
Source: `packages/svelte-table/src/createTableHook.svelte.ts`
|
|
100
|
+
|
|
101
|
+
### HIGH Freezing per-table rune inputs
|
|
102
|
+
|
|
103
|
+
Wrong:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const table = createAppTable({ columns, data })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Correct:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const table = createAppTable({
|
|
113
|
+
columns,
|
|
114
|
+
get data() {
|
|
115
|
+
return data
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Shared defaults are static, but each table must still expose current reactive values.
|
|
121
|
+
|
|
122
|
+
Source: `docs/framework/svelte/guide/composable-tables.md`
|
|
123
|
+
|
|
124
|
+
### HIGH Reading context outside its wrapper
|
|
125
|
+
|
|
126
|
+
Wrong:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const cell = useCellContext()
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Correct:
|
|
133
|
+
|
|
134
|
+
```svelte
|
|
135
|
+
<table.AppCell {cell}><cell.TextCell /></table.AppCell>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Context helpers require the matching App wrapper in the rendered ancestor tree.
|
|
139
|
+
|
|
140
|
+
Source: `packages/svelte-table/src/createTableHook.svelte.ts`
|
|
141
|
+
|
|
142
|
+
### MEDIUM Abstracting a single table too early
|
|
143
|
+
|
|
144
|
+
Wrong:
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const hook = createTableHook({ features: tableFeatures({}) })
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Correct:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const table = createTable({
|
|
154
|
+
features: tableFeatures({}),
|
|
155
|
+
columns,
|
|
156
|
+
get data() {
|
|
157
|
+
return data
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use the hook for recurring app conventions, not merely to rename standalone construction.
|
|
163
|
+
|
|
164
|
+
Source: `docs/framework/svelte/guide/composable-tables.md`
|
|
165
|
+
|
|
166
|
+
## API Discovery
|
|
167
|
+
|
|
168
|
+
Inspect `node_modules/@tanstack/svelte-table/dist/createTableHook.svelte.d.ts` and the `App*.svelte` wrappers for exact returned helpers and component contracts.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: getting-started
|
|
3
|
+
description: >
|
|
4
|
+
Create a Svelte 5 TanStack Table v9 table with createTable, explicit tableFeatures, rune-backed data getters, stable static inputs, FlexRender, and headless markup. Load when replacing createSvelteTable or pre-rune patterns.
|
|
5
|
+
metadata:
|
|
6
|
+
type: framework
|
|
7
|
+
library: '@tanstack/svelte-table'
|
|
8
|
+
framework: svelte
|
|
9
|
+
library_version: '9.0.0-beta.71'
|
|
10
|
+
requires:
|
|
11
|
+
- '@tanstack/table-core#core'
|
|
12
|
+
- '@tanstack/table-core#table-features'
|
|
13
|
+
sources:
|
|
14
|
+
- 'TanStack/table:docs/framework/svelte/guide/migrating.md'
|
|
15
|
+
- 'TanStack/table:examples/svelte/basic-create-table'
|
|
16
|
+
- 'TanStack/table:packages/svelte-table/src/index.ts'
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
This skill builds on `@tanstack/table-core#core` and `@tanstack/table-core#table-features`. Read them first for the headless model and feature registration.
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
Keep features and columns outside reactive work; expose changing rune values through getters.
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import {
|
|
28
|
+
createTable,
|
|
29
|
+
FlexRender,
|
|
30
|
+
tableFeatures,
|
|
31
|
+
} from '@tanstack/svelte-table'
|
|
32
|
+
|
|
33
|
+
type Person = { firstName: string; age: number }
|
|
34
|
+
const features = tableFeatures({})
|
|
35
|
+
const columns = [
|
|
36
|
+
{ accessorKey: 'firstName', header: 'First name' },
|
|
37
|
+
{ accessorKey: 'age', header: 'Age' },
|
|
38
|
+
]
|
|
39
|
+
let data = $state<Person[]>([{ firstName: 'Ada', age: 36 }])
|
|
40
|
+
|
|
41
|
+
const table = createTable({
|
|
42
|
+
features,
|
|
43
|
+
columns,
|
|
44
|
+
get data() {
|
|
45
|
+
return data
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<table>
|
|
51
|
+
<thead>
|
|
52
|
+
{#each table.getHeaderGroups() as group (group.id)}
|
|
53
|
+
<tr
|
|
54
|
+
>{#each group.headers as header (header.id)}<th
|
|
55
|
+
>{#if !header.isPlaceholder}<FlexRender {header} />{/if}</th
|
|
56
|
+
>{/each}</tr
|
|
57
|
+
>
|
|
58
|
+
{/each}
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody>
|
|
61
|
+
{#each table.getRowModel().rows as row (row.id)}
|
|
62
|
+
<tr
|
|
63
|
+
>{#each row.getAllCells() as cell (cell.id)}<td
|
|
64
|
+
><FlexRender {cell} /></td
|
|
65
|
+
>{/each}</tr
|
|
66
|
+
>
|
|
67
|
+
{/each}
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Core Patterns
|
|
73
|
+
|
|
74
|
+
### Add only the processing feature you need
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import {
|
|
78
|
+
createSortedRowModel,
|
|
79
|
+
rowSortingFeature,
|
|
80
|
+
sortFn_alphanumeric,
|
|
81
|
+
tableFeatures,
|
|
82
|
+
} from '@tanstack/svelte-table'
|
|
83
|
+
|
|
84
|
+
export const features = tableFeatures({
|
|
85
|
+
rowSortingFeature,
|
|
86
|
+
sortedRowModel: createSortedRowModel(),
|
|
87
|
+
sortFns: { alphanumeric: sortFn_alphanumeric },
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The row-model slot follows its prerequisite feature in the same call. Import individual `sortFn_*` built-ins and register only the ones your columns reference; the full `sortFns` registry object still works but bundles every built-in.
|
|
92
|
+
|
|
93
|
+
### Treat markup and styles as application code
|
|
94
|
+
|
|
95
|
+
With core-only `tableFeatures({})`, render `row.getAllCells()`. Use visibility-aware APIs such as `row.getVisibleCells()` only after registering `columnVisibilityFeature`. Call feature APIs from real Svelte event handlers. Table supplies no component-library markup, CSS, or accessibility behavior.
|
|
96
|
+
|
|
97
|
+
## Common Mistakes
|
|
98
|
+
|
|
99
|
+
### HIGH Passing a rune snapshot as data
|
|
100
|
+
|
|
101
|
+
Wrong:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
const table = createTable({ features, columns, data })
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Correct:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const table = createTable({
|
|
111
|
+
features,
|
|
112
|
+
columns,
|
|
113
|
+
get data() {
|
|
114
|
+
return data
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The getter makes `$effect.pre` observe current rune data rather than the value captured at construction.
|
|
120
|
+
|
|
121
|
+
Source: `packages/svelte-table/src/createTable.svelte.ts`
|
|
122
|
+
|
|
123
|
+
### HIGH Using the removed v8 constructor
|
|
124
|
+
|
|
125
|
+
Wrong:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const table = createSvelteTable({
|
|
129
|
+
data,
|
|
130
|
+
columns,
|
|
131
|
+
getCoreRowModel: getCoreRowModel(),
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Correct:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
const table = createTable({
|
|
139
|
+
features,
|
|
140
|
+
columns,
|
|
141
|
+
get data() {
|
|
142
|
+
return data
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
V9 requires Svelte 5, `createTable`, and explicit features; the core row model is automatic.
|
|
148
|
+
|
|
149
|
+
Source: `docs/framework/svelte/guide/migrating.md`
|
|
150
|
+
|
|
151
|
+
### HIGH Omitting a feature behind an API
|
|
152
|
+
|
|
153
|
+
Wrong:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const features = tableFeatures({})
|
|
157
|
+
table.setSorting([{ id: 'age', desc: true }])
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Correct:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
const features = tableFeatures({ rowSortingFeature })
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Feature state and APIs exist only when that feature is registered.
|
|
167
|
+
|
|
168
|
+
Source: `docs/framework/svelte/guide/migrating.md`
|
|
169
|
+
|
|
170
|
+
## API Discovery
|
|
171
|
+
|
|
172
|
+
Inspect `node_modules/@tanstack/svelte-table/dist/index.d.ts`, then the exported implementation. Inspect core and feature APIs through `node_modules/@tanstack/table-core/dist/index.d.ts` and `dist/features/<feature>/`.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrate-v8-to-v9
|
|
3
|
+
description: >
|
|
4
|
+
Complete Svelte v8-to-v9 migration reference: Svelte 5, createTable, beta.59 selector removal, explicit features and row-model slots, atom/rune state, rendering helpers, prototype methods, type generics, sorting, sizing, selection, and logical pinning.
|
|
5
|
+
metadata:
|
|
6
|
+
type: lifecycle
|
|
7
|
+
library: '@tanstack/svelte-table'
|
|
8
|
+
framework: svelte
|
|
9
|
+
library_version: '9.0.0-beta.71'
|
|
10
|
+
requires:
|
|
11
|
+
- '@tanstack/table-core#migrate-v8-to-v9'
|
|
12
|
+
- getting-started
|
|
13
|
+
- table-state
|
|
14
|
+
sources:
|
|
15
|
+
- 'TanStack/table:docs/framework/svelte/guide/migrating.md'
|
|
16
|
+
- 'TanStack/table:packages/svelte-table/src/index.ts'
|
|
17
|
+
- 'TanStack/table:examples/svelte/basic-create-table'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Use this as the complete breaking-change checklist, not merely a quick start. V9 is treated as the current API. Migrate the app to Svelte 5 before migrating Table; the v9 adapter has no Svelte 3/4 compatibility layer.
|
|
21
|
+
|
|
22
|
+
Framework prerequisite: Svelte 5 (`svelte ^5.0.0`).
|
|
23
|
+
|
|
24
|
+
## Recommended Migration Order
|
|
25
|
+
|
|
26
|
+
1. Upgrade to Svelte 5 and replace v8 stores with runes/getters.
|
|
27
|
+
2. Rename `createSvelteTable` to `createTable`.
|
|
28
|
+
3. Define explicit `tableFeatures`, then move row models and registries into it.
|
|
29
|
+
4. Update state reads/ownership and rendering.
|
|
30
|
+
5. Apply every shared API and type rename below.
|
|
31
|
+
6. Use `stockFeatures` only as a temporary audit bridge; explicit features are the production target.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const features = tableFeatures({
|
|
35
|
+
rowSortingFeature,
|
|
36
|
+
sortedRowModel: createSortedRowModel(),
|
|
37
|
+
sortFns: { alphanumeric: sortFn_alphanumeric },
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const table = createTable({
|
|
41
|
+
features,
|
|
42
|
+
columns,
|
|
43
|
+
get data() {
|
|
44
|
+
return data
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Construction and Feature Registration
|
|
50
|
+
|
|
51
|
+
| v8 | v9 |
|
|
52
|
+
| -------------------------------------------- | ---------------------------------------------------------- |
|
|
53
|
+
| `createSvelteTable(options)` | `createTable(options)` |
|
|
54
|
+
| All features bundled | Required `features: tableFeatures({...})` |
|
|
55
|
+
| `getCoreRowModel()` option | Remove; the core row model is automatic |
|
|
56
|
+
| `get*RowModel()` table options | `create*RowModel()` slots in `tableFeatures` |
|
|
57
|
+
| `sortingFns` table option | `sortFns` feature slot |
|
|
58
|
+
| `filterFns` / `aggregationFns` table options | Same-named feature slots |
|
|
59
|
+
| Top-level `onStateChange` | Per-slice callbacks, external atoms, or store subscription |
|
|
60
|
+
|
|
61
|
+
Available feature imports are `cellSelectionFeature`, `columnFilteringFeature`, `globalFilteringFeature`, `rowSortingFeature`, `rowPaginationFeature`, `rowSelectionFeature`, `rowExpandingFeature`, `rowPinningFeature`, `columnPinningFeature`, `columnVisibilityFeature`, `columnOrderingFeature`, `columnSizingFeature`, `columnResizingFeature`, `rowAggregationFeature`, `columnGroupingFeature`, and `columnFacetingFeature`. An API does not exist unless its feature is registered. Put a feature before its dependent slot in the same `tableFeatures` call. Aggregation is independent from grouping: register `rowAggregationFeature` for aggregation APIs and add `columnGroupingFeature` only for grouped rows.
|
|
62
|
+
|
|
63
|
+
### Row-model mapping
|
|
64
|
+
|
|
65
|
+
| v8 option | v9 slot and factory |
|
|
66
|
+
| -------------------------- | ------------------------------------------------------------------- |
|
|
67
|
+
| `getFilteredRowModel()` | `filteredRowModel: createFilteredRowModel()` after column filtering |
|
|
68
|
+
| `getSortedRowModel()` | `sortedRowModel: createSortedRowModel()` after row sorting |
|
|
69
|
+
| `getPaginationRowModel()` | `paginatedRowModel: createPaginatedRowModel()` after pagination |
|
|
70
|
+
| `getExpandedRowModel()` | `expandedRowModel: createExpandedRowModel()` after expanding |
|
|
71
|
+
| `getGroupedRowModel()` | `groupedRowModel: createGroupedRowModel()` after grouping |
|
|
72
|
+
| `getFacetedRowModel()` | `facetedRowModel: createFacetedRowModel()` after faceting |
|
|
73
|
+
| `getFacetedMinMaxValues()` | `facetedMinMaxValues: createFacetedMinMaxValues()` |
|
|
74
|
+
| `getFacetedUniqueValues()` | `facetedUniqueValues: createFacetedUniqueValues()` |
|
|
75
|
+
|
|
76
|
+
Factories take no arguments. Register `filterFns`, `sortFns`, and `aggregationFns` as sibling feature slots holding individually imported built-ins (`filterFn_includesString`, `sortFn_alphanumeric`, `aggregationFn_sum`) under their conventional keys. The full registry objects still work but bundle every built-in.
|
|
77
|
+
|
|
78
|
+
## Svelte State Migration
|
|
79
|
+
|
|
80
|
+
- Reactive option inputs must remain live: use getters for rune values such as `data` and controlled state slices.
|
|
81
|
+
- `table.getState().sorting` becomes the narrow `table.atoms.sorting.get()` read. Use `table.store.get()` when code intentionally needs the complete state.
|
|
82
|
+
- Table atom, store, and API reads become reactive inside templates, `$derived`, `$derived.by`, and `$effect`; use native `$derived` values for projections.
|
|
83
|
+
- Starting in beta.59, remove second-argument selectors from `createTable` and `createAppTable`, replace `table.state`, and remove `subscribeTable` / `SubscribeSource` imports.
|
|
84
|
+
- `SvelteTable` now has two generic parameters, `AppSvelteTable` has five, and `useTableContext` no longer accepts a selected-state generic.
|
|
85
|
+
- For Svelte-owned controlled slices, use `createTableState` and matching `onSortingChange`, `onPaginationChange`, and other per-slice callbacks.
|
|
86
|
+
- For shared ownership, provide atoms created by `@tanstack/svelte-store` through `atoms`. Never provide both `atoms.pagination` and `state.pagination`.
|
|
87
|
+
- Subscribe to `table.store` to observe every state change. Do not port the removed top-level `onStateChange`.
|
|
88
|
+
- Treat `table.baseAtoms` as internal writable state; prefer feature APIs or external atoms.
|
|
89
|
+
|
|
90
|
+
## Rendering and Composition
|
|
91
|
+
|
|
92
|
+
| v8 | v9 |
|
|
93
|
+
| ---------------------------------------- | -------------------------------------------------------------------------------- |
|
|
94
|
+
| `flexRender(...)` / `<svelte:component>` | `<FlexRender {cell} />`, `<FlexRender {header} />`, or `<FlexRender {footer} />` |
|
|
95
|
+
| Component returned directly | `renderComponent(Component, props)` |
|
|
96
|
+
| Svelte snippet content | `renderSnippet(snippet, props)` |
|
|
97
|
+
| Repeated raw options | `tableOptions(...)` composition |
|
|
98
|
+
| Repeated table conventions | `createTableHook({ features, ... })` and its pre-bound helpers |
|
|
99
|
+
|
|
100
|
+
`createTableHook` returns a feature-bound table creator and column helper; use it for application-wide conventions, not as a required migration step.
|
|
101
|
+
|
|
102
|
+
## Complete Shared Breaking-Change Map
|
|
103
|
+
|
|
104
|
+
### Instance methods
|
|
105
|
+
|
|
106
|
+
Row, cell, column, header, and related object methods now live on shared prototypes and use `this`. Call `row.getValue(...)`, `cell.getContext()`, `column.getCanSort()`, and `header.getContext()` on their instances. Do not destructure them or pass them as bare callbacks. They are not own enumerable properties, so object spread, `Object.keys`, and JSON serialization do not preserve them. Table methods are not affected.
|
|
107
|
+
|
|
108
|
+
### Logical column pinning
|
|
109
|
+
|
|
110
|
+
There are no `left`/`right` aliases in beta.38.
|
|
111
|
+
|
|
112
|
+
| old | new |
|
|
113
|
+
| -------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
114
|
+
| `columnPinning.left` / `.right` | `.start` / `.end` |
|
|
115
|
+
| `column.pin('left' \| 'right')` | `column.pin('start' \| 'end')` |
|
|
116
|
+
| `getIsPinned() === 'left' \| 'right'` | `'start' \| 'end'` |
|
|
117
|
+
| `row.getLeftVisibleCells()` / `getRightVisibleCells()` | `getStartVisibleCells()` / `getEndVisibleCells()` |
|
|
118
|
+
| `getLeftHeaderGroups()` / `getRightHeaderGroups()` | `getStartHeaderGroups()` / `getEndHeaderGroups()` |
|
|
119
|
+
| `getLeftFooterGroups()` / `getRightFooterGroups()` | `getStartFooterGroups()` / `getEndFooterGroups()` |
|
|
120
|
+
| `getLeftFlatHeaders()` / `getRightFlatHeaders()` | `getStartFlatHeaders()` / `getEndFlatHeaders()` |
|
|
121
|
+
| `getLeftLeafHeaders()` / `getRightLeafHeaders()` | `getStartLeafHeaders()` / `getEndLeafHeaders()` |
|
|
122
|
+
| `getLeftLeafColumns()` / `getRightLeafColumns()` | `getStartLeafColumns()` / `getEndLeafColumns()` |
|
|
123
|
+
| `getLeftVisibleLeafColumns()` / `getRightVisibleLeafColumns()` | `getStartVisibleLeafColumns()` / `getEndVisibleLeafColumns()` |
|
|
124
|
+
| `getLeftTotalSize()` / `getRightTotalSize()` | `getStartTotalSize()` / `getEndTotalSize()` |
|
|
125
|
+
| `column.getStart('left')` | `column.getStart('start')` |
|
|
126
|
+
| `column.getAfter('right')` | `column.getAfter('end')` |
|
|
127
|
+
| `column.getIndex('left' \| 'right')` | `column.getIndex('start' \| 'end')` |
|
|
128
|
+
|
|
129
|
+
This is logical region naming, not automatic DOM direction handling. Prefer CSS `inset-inline-start`/`inset-inline-end`. `columnResizeDirection` is unchanged.
|
|
130
|
+
|
|
131
|
+
### Feature and state splits
|
|
132
|
+
|
|
133
|
+
- `enablePinning` splits into `enableColumnPinning` and `enableRowPinning`.
|
|
134
|
+
- Interactive resizing requires both `columnSizingFeature` and `columnResizingFeature`; fixed widths need only sizing.
|
|
135
|
+
- `columnSizingInfo` becomes `columnResizing`.
|
|
136
|
+
- `setColumnSizingInfo()` becomes `setColumnResizing()`.
|
|
137
|
+
- `onColumnSizingInfoChange` becomes `onColumnResizingChange`.
|
|
138
|
+
|
|
139
|
+
### Sorting, rows, and selection
|
|
140
|
+
|
|
141
|
+
| v8 | v9 |
|
|
142
|
+
| ------------------------------ | ----------------------------- |
|
|
143
|
+
| `sortingFn` | `sortFn` |
|
|
144
|
+
| `sortingFns` | `sortFns` |
|
|
145
|
+
| `getSortingFn()` | `getSortFn()` |
|
|
146
|
+
| `getAutoSortingFn()` | `getAutoSortFn()` |
|
|
147
|
+
| `SortingFn` / `SortingFns` | `SortFn` / `SortFns` |
|
|
148
|
+
| `row._getAllCellsByColumnId()` | `row.getAllCellsByColumnId()` |
|
|
149
|
+
|
|
150
|
+
All other `_`-prefixed internal APIs are removed, including `_getPinnedRows`, `_getFacetedRowModel`, `_getFacetedMinMaxValues`, and `_getFacetedUniqueValues`; do not seek replacements unless a public API is documented.
|
|
151
|
+
|
|
152
|
+
`getIsSomeRowsSelected()` and `getIsSomePageRowsSelected()` now mean at least one, including all. For an indeterminate checkbox, combine “some” with `!getIsAllRowsSelected()` or `!getIsAllPageRowsSelected()`.
|
|
153
|
+
|
|
154
|
+
## TypeScript Migration
|
|
155
|
+
|
|
156
|
+
- Core types now take `TFeatures` first: `ColumnDef<typeof features, Person>`, `Column<typeof features, Person>`, `Row<typeof features, Person>`, `Table<typeof features, Person>`.
|
|
157
|
+
- Replace `createColumnHelper<Person>()` with `createColumnHelper<typeof features, Person>()`; wrap arrays in `columnHelper.columns([...])` for inference.
|
|
158
|
+
- With `stockFeatures`, use `StockFeatures` as the feature type.
|
|
159
|
+
- `TableMeta` and `ColumnMeta` declaration merging still works only after adding `TFeatures` first. Prefer per-table `tableMeta`/`columnMeta: metaHelper<...>()` slots.
|
|
160
|
+
- Replace global `FilterFns`, `SortFns`, `AggregationFns`, and `FilterMeta` augmentation with `filterFns`, `sortFns`, `aggregationFns`, and `filterMeta: metaHelper<...>()` slots. Registered keys become valid string references.
|
|
161
|
+
- Prefer explicit object row types; `RowData` is restricted to records or arrays.
|
|
162
|
+
|
|
163
|
+
## Common Migration Failures
|
|
164
|
+
|
|
165
|
+
### CRITICAL: Running v9 on Svelte 3/4
|
|
166
|
+
|
|
167
|
+
Upgrade to Svelte 5 first. Writable-store-era table setup is not a supported v9 adapter contract.
|
|
168
|
+
|
|
169
|
+
### HIGH: Moving the feature but not its row model
|
|
170
|
+
|
|
171
|
+
Register both the feature and its `create*RowModel()` slot. Leaving `get*RowModel` on table options silently leaves the v9 processing pipeline incomplete.
|
|
172
|
+
|
|
173
|
+
### HIGH: Snapshotting a rune value
|
|
174
|
+
|
|
175
|
+
Use `get data() { return data }`; a one-time `data` snapshot does not remain reactive.
|
|
176
|
+
|
|
177
|
+
### HIGH: Keeping beta.58 Svelte selectors
|
|
178
|
+
|
|
179
|
+
Remove second arguments from `createTable` and `createAppTable`, replace selected `table.state` reads with `table.atoms.<slice>.get()` or `table.store.get()`, and remove `subscribeTable`, `SubscribeSource`, and selected-state generic parameters. Beta.59 intentionally has no compatibility layer for these APIs.
|
|
180
|
+
|
|
181
|
+
### HIGH: Destructuring instance methods
|
|
182
|
+
|
|
183
|
+
Keep calls bound to row/cell/column/header instances; shallow copies do not contain prototype methods.
|
|
184
|
+
|
|
185
|
+
## Final Checklist
|
|
186
|
+
|
|
187
|
+
- [ ] Svelte is version 5+; old writable-store patterns are removed.
|
|
188
|
+
- [ ] `createSvelteTable` is replaced by `createTable`.
|
|
189
|
+
- [ ] Explicit features, row models, and function registries are in `tableFeatures`.
|
|
190
|
+
- [ ] `getCoreRowModel` and the separate `rowModels` shape are removed.
|
|
191
|
+
- [ ] Reactive inputs and controlled slices use getters/runes; state reads use v9 surfaces.
|
|
192
|
+
- [ ] Svelte creation selectors, `table.state`, `subscribeTable`, `SubscribeSource`, and selected-state generic parameters are removed.
|
|
193
|
+
- [ ] `onStateChange` is replaced; atom/state ownership does not overlap.
|
|
194
|
+
- [ ] Rendering uses `FlexRender`, `renderComponent`, or `renderSnippet`.
|
|
195
|
+
- [ ] Prototype method calls, pinning, sizing/resizing, sorting, row, and selection semantics are audited.
|
|
196
|
+
- [ ] Helpers, types, meta, registries, and `RowData` use the v9 generic/slot shapes.
|
|
197
|
+
- [ ] Temporary `stockFeatures` usage has an explicit removal plan.
|
|
198
|
+
|
|
199
|
+
## API Discovery
|
|
200
|
+
|
|
201
|
+
Verify the installed target in `node_modules/@tanstack/svelte-table/dist/index.d.ts` and its adapter sources. Verify feature slots and exact beta APIs in `node_modules/@tanstack/table-core/dist/`; do not reconstruct v9 APIs from v8 memory.
|