@tanstack/svelte-table 9.0.0-beta.51 → 9.0.0-beta.53
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/package.json +2 -3
- package/skills/create-table-hook/SKILL.md +2 -2
- package/skills/getting-started/SKILL.md +2 -2
- package/skills/migrate-v8-to-v9/SKILL.md +2 -2
- package/skills/table-state/SKILL.md +2 -2
- package/skills/with-tanstack-query/SKILL.md +2 -2
- package/skills/with-tanstack-virtual/SKILL.md +2 -2
- 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 -136
- package/src/createTableHook.svelte.ts +0 -745
- package/src/createTableState.svelte.ts +0 -30
- package/src/experimental-worker-plugin.ts +0 -1
- package/src/flex-render.ts +0 -3
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -22
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-table",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.53",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,12 +53,11 @@
|
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist",
|
|
56
|
-
"src",
|
|
57
56
|
"skills"
|
|
58
57
|
],
|
|
59
58
|
"dependencies": {
|
|
60
59
|
"@tanstack/svelte-store": "^0.12.0",
|
|
61
|
-
"@tanstack/table-core": "9.0.0-beta.
|
|
60
|
+
"@tanstack/table-core": "9.0.0-beta.53"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@sveltejs/package": "^2.5.8",
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: framework
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#core'
|
|
12
12
|
- getting-started
|
|
@@ -165,4 +165,4 @@ Source: `docs/framework/svelte/guide/composable-tables.md`
|
|
|
165
165
|
|
|
166
166
|
## API Discovery
|
|
167
167
|
|
|
168
|
-
Inspect `node_modules/@tanstack/svelte-table/
|
|
168
|
+
Inspect `node_modules/@tanstack/svelte-table/dist/createTableHook.svelte.d.ts` and the `App*.svelte` wrappers for exact returned helpers and component contracts.
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: framework
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#core'
|
|
12
12
|
- '@tanstack/table-core#table-features'
|
|
@@ -169,4 +169,4 @@ Source: `docs/framework/svelte/guide/migrating.md`
|
|
|
169
169
|
|
|
170
170
|
## API Discovery
|
|
171
171
|
|
|
172
|
-
Inspect `node_modules/@tanstack/svelte-table/
|
|
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>/`.
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: lifecycle
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#migrate-v8-to-v9'
|
|
12
12
|
- getting-started
|
|
@@ -192,4 +192,4 @@ Keep calls bound to row/cell/column/header instances; shallow copies do not cont
|
|
|
192
192
|
|
|
193
193
|
## API Discovery
|
|
194
194
|
|
|
195
|
-
Verify the installed target in `node_modules/@tanstack/svelte-table/
|
|
195
|
+
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.
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: framework
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#core'
|
|
12
12
|
- getting-started
|
|
@@ -202,4 +202,4 @@ Source: `docs/framework/svelte/guide/pagination.md`
|
|
|
202
202
|
|
|
203
203
|
## API Discovery
|
|
204
204
|
|
|
205
|
-
Inspect `node_modules/@tanstack/svelte-table/
|
|
205
|
+
Inspect `node_modules/@tanstack/svelte-table/dist/createTable.svelte.d.ts`, `createTableState.svelte.d.ts`, and `subscribe.d.ts`; inspect registered state slices in the matching core feature source.
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: composition
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#client-vs-server'
|
|
12
12
|
- getting-started
|
|
@@ -144,4 +144,4 @@ Source: `docs/framework/svelte/guide/pagination.md`
|
|
|
144
144
|
|
|
145
145
|
## API Discovery
|
|
146
146
|
|
|
147
|
-
Inspect `node_modules/@tanstack/svelte-table/
|
|
147
|
+
Inspect `node_modules/@tanstack/svelte-table/dist/index.d.ts` for adapter APIs and installed `@tanstack/svelte-query/dist/` for the exact Query version. Table manual-stage options live in the matching core feature source.
|
|
@@ -6,7 +6,7 @@ metadata:
|
|
|
6
6
|
type: composition
|
|
7
7
|
library: '@tanstack/svelte-table'
|
|
8
8
|
framework: svelte
|
|
9
|
-
library_version: '9.0.0-beta.
|
|
9
|
+
library_version: '9.0.0-beta.53'
|
|
10
10
|
requires:
|
|
11
11
|
- '@tanstack/table-core#core'
|
|
12
12
|
- getting-started
|
|
@@ -147,4 +147,4 @@ Source: `docs/framework/svelte/guide/virtualization.md`
|
|
|
147
147
|
|
|
148
148
|
## API Discovery
|
|
149
149
|
|
|
150
|
-
Inspect installed `@tanstack/svelte-table/
|
|
150
|
+
Inspect installed `@tanstack/svelte-table/dist/` for Table APIs and `@tanstack/svelte-virtual/dist/` for the exact virtualizer options. Use the maintained Svelte examples for layout combinations.
|
package/src/AppCell.svelte
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
cell: any
|
|
6
|
-
cellComponents: any
|
|
7
|
-
children: Snippet<[any]>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let { children, cell, cellComponents }: Props = $props()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
{@render children?.(Object.assign(cell, cellComponents))}
|
package/src/AppHeader.svelte
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
header: any
|
|
6
|
-
headerComponents: any
|
|
7
|
-
children: Snippet<[any]>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let { children, header, headerComponents }: Props = $props()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
{@render children?.(Object.assign(header, headerComponents))}
|
package/src/AppTable.svelte
DELETED
package/src/FlexRender.svelte
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<script
|
|
2
|
-
lang="ts"
|
|
3
|
-
generics="TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData"
|
|
4
|
-
>
|
|
5
|
-
import { isFunction } from '@tanstack/table-core'
|
|
6
|
-
import {
|
|
7
|
-
RenderComponentConfig,
|
|
8
|
-
RenderSnippetConfig,
|
|
9
|
-
} from './render-component'
|
|
10
|
-
import type {
|
|
11
|
-
Cell,
|
|
12
|
-
CellContext,
|
|
13
|
-
CellData,
|
|
14
|
-
ColumnDefTemplate,
|
|
15
|
-
Header,
|
|
16
|
-
HeaderContext,
|
|
17
|
-
RowData,
|
|
18
|
-
TableFeatures,
|
|
19
|
-
} from '@tanstack/table-core'
|
|
20
|
-
|
|
21
|
-
type Props =
|
|
22
|
-
| {
|
|
23
|
-
/** The cell or header field of the current cell's column definition. */
|
|
24
|
-
content?: ColumnDefTemplate<
|
|
25
|
-
| HeaderContext<TFeatures, TData, TValue>
|
|
26
|
-
| CellContext<TFeatures, TData, TValue>
|
|
27
|
-
>
|
|
28
|
-
/** The result of the `getContext()` function of the header or cell */
|
|
29
|
-
context:
|
|
30
|
-
| HeaderContext<TFeatures, TData, TValue>
|
|
31
|
-
| CellContext<TFeatures, TData, TValue>
|
|
32
|
-
cell?: never
|
|
33
|
-
header?: never
|
|
34
|
-
footer?: never
|
|
35
|
-
}
|
|
36
|
-
| {
|
|
37
|
-
cell: Cell<TFeatures, TData, TValue>
|
|
38
|
-
content?: never
|
|
39
|
-
context?: never
|
|
40
|
-
header?: never
|
|
41
|
-
footer?: never
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
header: Header<TFeatures, TData, TValue>
|
|
45
|
-
content?: never
|
|
46
|
-
context?: never
|
|
47
|
-
cell?: never
|
|
48
|
-
footer?: never
|
|
49
|
-
}
|
|
50
|
-
| {
|
|
51
|
-
footer: Header<TFeatures, TData, TValue>
|
|
52
|
-
content?: never
|
|
53
|
-
context?: never
|
|
54
|
-
cell?: never
|
|
55
|
-
header?: never
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let props: Props = $props()
|
|
59
|
-
|
|
60
|
-
// Resolve content and context from either the new cell/header/footer props
|
|
61
|
-
// or the legacy content/context props.
|
|
62
|
-
const resolved = $derived.by(() => {
|
|
63
|
-
if ('cell' in props && props.cell) {
|
|
64
|
-
return {
|
|
65
|
-
content: props.cell.column.columnDef.cell,
|
|
66
|
-
context: props.cell.getContext(),
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if ('header' in props && props.header) {
|
|
70
|
-
return {
|
|
71
|
-
content: props.header.column.columnDef.header,
|
|
72
|
-
context: props.header.getContext(),
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if ('footer' in props && props.footer) {
|
|
76
|
-
return {
|
|
77
|
-
content: props.footer.column.columnDef.footer,
|
|
78
|
-
context: props.footer.getContext(),
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
content: props.content,
|
|
83
|
-
context: props.context,
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
// Compute the render result reactively
|
|
88
|
-
const result = $derived(
|
|
89
|
-
isFunction(resolved.content)
|
|
90
|
-
? resolved.content(resolved.context as any)
|
|
91
|
-
: undefined,
|
|
92
|
-
)
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
|
-
{#if typeof resolved.content === 'string'}
|
|
96
|
-
{resolved.content}
|
|
97
|
-
{:else if result instanceof RenderComponentConfig}
|
|
98
|
-
<result.component {...result.props} />
|
|
99
|
-
{:else if result instanceof RenderSnippetConfig}
|
|
100
|
-
{@render result.snippet(result.params)}
|
|
101
|
-
{:else if result !== undefined}
|
|
102
|
-
{result}
|
|
103
|
-
{/if}
|
package/src/context-keys.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { constructTable } from '@tanstack/table-core'
|
|
2
|
-
import { useSelector } from '@tanstack/svelte-store'
|
|
3
|
-
import { untrack } from 'svelte'
|
|
4
|
-
import { flatMerge, mergeObjects } from './merge-objects'
|
|
5
|
-
import { svelteReactivity } from './reactivity.svelte'
|
|
6
|
-
import type {
|
|
7
|
-
RowData,
|
|
8
|
-
Table,
|
|
9
|
-
TableFeatures,
|
|
10
|
-
TableOptions,
|
|
11
|
-
TableState,
|
|
12
|
-
} from '@tanstack/table-core'
|
|
13
|
-
|
|
14
|
-
export type SvelteTable<
|
|
15
|
-
TFeatures extends TableFeatures,
|
|
16
|
-
TData extends RowData,
|
|
17
|
-
TSelected = TableState<TFeatures>,
|
|
18
|
-
> = Omit<Table<TFeatures, TData>, 'store'> & {
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Prefer `table.state` for render reads,
|
|
21
|
-
* `table.atoms.<slice>.get()` for slice snapshots, or
|
|
22
|
-
* `useSelector(table.store, selector)` for explicit subscriptions.
|
|
23
|
-
* `table.store.state` is a current-value snapshot and is easy to misuse in
|
|
24
|
-
* render code.
|
|
25
|
-
*/
|
|
26
|
-
readonly store: Table<TFeatures, TData>['store']
|
|
27
|
-
/**
|
|
28
|
-
* The selected state of the table. This state may not match the structure of
|
|
29
|
-
* the full table state because it is selected by the selector function that
|
|
30
|
-
* you pass as the 2nd argument to `createTable`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const table = createTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state
|
|
34
|
-
*
|
|
35
|
-
* console.log(table.state.globalFilter)
|
|
36
|
-
*/
|
|
37
|
-
readonly state: Readonly<TSelected>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a Svelte 5 table instance backed by rune-aware TanStack Store atoms.
|
|
42
|
-
*
|
|
43
|
-
* The optional selector projects from `table.store`; the selected value is
|
|
44
|
-
* exposed on `table.state`. The adapter syncs options in `$effect.pre`, so
|
|
45
|
-
* reactive option getters and external `$state` values are applied before DOM
|
|
46
|
-
* updates read table APIs such as `getRowModel()`.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```svelte
|
|
50
|
-
* <script lang="ts">
|
|
51
|
-
* const table = createTable(
|
|
52
|
-
* {
|
|
53
|
-
* features,
|
|
54
|
-
* columns,
|
|
55
|
-
* data,
|
|
56
|
-
* },
|
|
57
|
-
* (state) => ({ pagination: state.pagination }),
|
|
58
|
-
* )
|
|
59
|
-
* </script>
|
|
60
|
-
*
|
|
61
|
-
* {table.state.pagination.pageIndex}
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export function createTable<
|
|
65
|
-
TFeatures extends TableFeatures,
|
|
66
|
-
TData extends RowData,
|
|
67
|
-
TSelected = TableState<TFeatures>,
|
|
68
|
-
>(
|
|
69
|
-
tableOptions: TableOptions<TFeatures, TData>,
|
|
70
|
-
selector?: (state: TableState<TFeatures>) => TSelected,
|
|
71
|
-
): SvelteTable<TFeatures, TData, TSelected> {
|
|
72
|
-
// 1. Merge reactivity into options using mergeObjects (preserves getters)
|
|
73
|
-
const mergedOptions = mergeObjects(tableOptions, {
|
|
74
|
-
features: {
|
|
75
|
-
coreReactivityFeature: svelteReactivity(),
|
|
76
|
-
...tableOptions.features,
|
|
77
|
-
},
|
|
78
|
-
}) as TableOptions<TFeatures, TData>
|
|
79
|
-
|
|
80
|
-
// 2. Set up resolved options with mergeOptions handler
|
|
81
|
-
const resolvedOptions = mergeObjects(
|
|
82
|
-
{
|
|
83
|
-
mergeOptions: (
|
|
84
|
-
defaultOptions: TableOptions<TFeatures, TData>,
|
|
85
|
-
newOptions: Partial<TableOptions<TFeatures, TData>>,
|
|
86
|
-
) => {
|
|
87
|
-
return flatMerge(defaultOptions, newOptions)
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
mergedOptions,
|
|
91
|
-
) as TableOptions<TFeatures, TData>
|
|
92
|
-
|
|
93
|
-
// 3. Construct table
|
|
94
|
-
const table = constructTable(resolvedOptions) as unknown as SvelteTable<
|
|
95
|
-
TFeatures,
|
|
96
|
-
TData,
|
|
97
|
-
TSelected
|
|
98
|
-
>
|
|
99
|
-
|
|
100
|
-
// 4. Sync options reactively. When controlled state changes (e.g., $state
|
|
101
|
-
// inside createTableState), the effect re-runs and calls setOptions.
|
|
102
|
-
// Use $effect.pre so the table sees updated options BEFORE the DOM renders,
|
|
103
|
-
// ensuring getRowModel() returns current data (not stale, one-frame-behind data).
|
|
104
|
-
// The reactive reads (state getters, data getter) happen OUTSIDE untrack
|
|
105
|
-
// so they become dependencies. The setOptions call is INSIDE untrack so
|
|
106
|
-
// option writes do not subscribe this effect to table internals.
|
|
107
|
-
$effect.pre(() => {
|
|
108
|
-
// Read reactive getters to create $effect dependencies on external state
|
|
109
|
-
const state: Record<string, unknown> | undefined = mergedOptions.state
|
|
110
|
-
if (state) {
|
|
111
|
-
for (const key in state) {
|
|
112
|
-
void state[key]
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
void mergedOptions.data
|
|
116
|
-
|
|
117
|
-
untrack(() => {
|
|
118
|
-
table.setOptions((prev) => {
|
|
119
|
-
return flatMerge(prev, mergedOptions)
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
// 5. State selector
|
|
125
|
-
const stateStore = useSelector(table.store, selector)
|
|
126
|
-
|
|
127
|
-
Object.defineProperty(table, 'state', {
|
|
128
|
-
get() {
|
|
129
|
-
return stateStore.current
|
|
130
|
-
},
|
|
131
|
-
configurable: true,
|
|
132
|
-
enumerable: true,
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
return table
|
|
136
|
-
}
|