@tanstack/svelte-table 9.0.0-alpha.32 → 9.0.0-alpha.33
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { constructReactivityFeature, constructTable, } from '@tanstack/table-core';
|
|
2
|
-
import {
|
|
2
|
+
import { useSelector } from '@tanstack/svelte-store';
|
|
3
3
|
import { untrack } from 'svelte';
|
|
4
4
|
import { mergeObjects } from './merge-objects';
|
|
5
5
|
export function createTable(tableOptions, selector = () => ({})) {
|
|
@@ -24,9 +24,9 @@ export function createTable(tableOptions, selector = () => ({})) {
|
|
|
24
24
|
}, mergedOptions);
|
|
25
25
|
// 5. Construct table
|
|
26
26
|
const table = constructTable(resolvedOptions);
|
|
27
|
-
// 6. Subscribe to all state and options via
|
|
28
|
-
const allState =
|
|
29
|
-
const allOptions =
|
|
27
|
+
// 6. Subscribe to all state and options via useSelector
|
|
28
|
+
const allState = useSelector(table.store, (state) => state);
|
|
29
|
+
const allOptions = useSelector(table.optionsStore, (options) => options);
|
|
30
30
|
// 7. Sync store changes -> notifier.
|
|
31
31
|
// Use $effect.pre so this runs before DOM updates (like Solid's createComputed).
|
|
32
32
|
// Use untrack for the write so the effect only depends on allState/allOptions,
|
|
@@ -63,14 +63,14 @@ export function createTable(tableOptions, selector = () => ({})) {
|
|
|
63
63
|
});
|
|
64
64
|
// 9. Subscribe component
|
|
65
65
|
table.Subscribe = function Subscribe(props) {
|
|
66
|
-
const selected =
|
|
66
|
+
const selected = useSelector(table.store, props.selector);
|
|
67
67
|
if (typeof props.children === 'function') {
|
|
68
68
|
return props.children(selected.current);
|
|
69
69
|
}
|
|
70
70
|
return props.children;
|
|
71
71
|
};
|
|
72
72
|
// 10. State selector
|
|
73
|
-
const stateStore =
|
|
73
|
+
const stateStore = useSelector(table.store, selector);
|
|
74
74
|
Object.defineProperty(table, 'state', {
|
|
75
75
|
get() {
|
|
76
76
|
return stateStore.current;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-table",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.33",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"src"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@tanstack/svelte-store": "^0.
|
|
44
|
-
"@tanstack/table-core": "9.0.0-alpha.
|
|
43
|
+
"@tanstack/svelte-store": "^0.12.0",
|
|
44
|
+
"@tanstack/table-core": "9.0.0-alpha.33"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@sveltejs/package": "^2.5.7",
|
|
48
48
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
49
49
|
"eslint-plugin-svelte": "^3.17.0",
|
|
50
|
-
"svelte": "^5.55.
|
|
50
|
+
"svelte": "^5.55.4",
|
|
51
51
|
"svelte-check": "^4.4.6"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
constructReactivityFeature,
|
|
3
3
|
constructTable,
|
|
4
4
|
} from '@tanstack/table-core'
|
|
5
|
-
import {
|
|
5
|
+
import { useSelector } from '@tanstack/svelte-store'
|
|
6
6
|
import { untrack } from 'svelte'
|
|
7
7
|
import { mergeObjects } from './merge-objects'
|
|
8
8
|
import type {
|
|
@@ -94,9 +94,9 @@ export function createTable<
|
|
|
94
94
|
TSelected
|
|
95
95
|
>
|
|
96
96
|
|
|
97
|
-
// 6. Subscribe to all state and options via
|
|
98
|
-
const allState =
|
|
99
|
-
const allOptions =
|
|
97
|
+
// 6. Subscribe to all state and options via useSelector
|
|
98
|
+
const allState = useSelector(table.store, (state) => state)
|
|
99
|
+
const allOptions = useSelector(table.optionsStore, (options) => options)
|
|
100
100
|
|
|
101
101
|
// 7. Sync store changes -> notifier.
|
|
102
102
|
// Use $effect.pre so this runs before DOM updates (like Solid's createComputed).
|
|
@@ -143,7 +143,7 @@ export function createTable<
|
|
|
143
143
|
selector: (state: TableState<TFeatures>) => TSel
|
|
144
144
|
children: ((state: Readonly<TSel>) => Snippet) | Snippet
|
|
145
145
|
}): any {
|
|
146
|
-
const selected =
|
|
146
|
+
const selected = useSelector(table.store, props.selector)
|
|
147
147
|
if (typeof props.children === 'function') {
|
|
148
148
|
return props.children(selected.current)
|
|
149
149
|
}
|
|
@@ -151,7 +151,7 @@ export function createTable<
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// 10. State selector
|
|
154
|
-
const stateStore =
|
|
154
|
+
const stateStore = useSelector(table.store, selector)
|
|
155
155
|
|
|
156
156
|
Object.defineProperty(table, 'state', {
|
|
157
157
|
get() {
|