@tanstack/svelte-table 9.0.0-alpha.42 → 9.0.0-alpha.44
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/dist/index.d.ts +1 -1
- package/dist/reactivity.svelte.js +3 -1
- package/dist/subscribe.d.ts +7 -7
- package/dist/subscribe.js +2 -7
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/reactivity.svelte.ts +3 -1
- package/src/subscribe.ts +24 -16
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export { createTableHook } from './createTableHook.svelte';
|
|
|
5
5
|
export type { AppCellContext, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderContext, AppSvelteTable, ComponentType, CreateTableHookOptions, } from './createTableHook.svelte';
|
|
6
6
|
export { createTableState } from './createTableState.svelte';
|
|
7
7
|
export { default as FlexRender } from './FlexRender.svelte';
|
|
8
|
-
export { subscribeTable } from './subscribe';
|
|
8
|
+
export { subscribeTable, type SubscribeSource } from './subscribe';
|
|
9
9
|
export { renderComponent, renderSnippet } from './render-component';
|
|
@@ -8,13 +8,15 @@ function subscribeToRune(getValue, observerOrNext) {
|
|
|
8
8
|
const callback = observerToCallback(observerOrNext);
|
|
9
9
|
const unsubscribe = $effect.root(() => {
|
|
10
10
|
$effect(() => {
|
|
11
|
-
|
|
11
|
+
const value = getValue();
|
|
12
|
+
untrack(() => callback(value));
|
|
12
13
|
});
|
|
13
14
|
});
|
|
14
15
|
return { unsubscribe };
|
|
15
16
|
}
|
|
16
17
|
export function svelteReactivity() {
|
|
17
18
|
return {
|
|
19
|
+
createOptionsStore: true,
|
|
18
20
|
createReadonlyAtom: (fn, _options) => {
|
|
19
21
|
const value = $derived.by(fn);
|
|
20
22
|
return {
|
package/dist/subscribe.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useSelector } from '@tanstack/svelte-store';
|
|
2
|
+
import type { Atom, ReadonlyAtom, ReadonlyStore, Store } from '@tanstack/svelte-store';
|
|
3
|
+
export type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
|
|
2
4
|
/**
|
|
3
|
-
* Fine-grained subscription to
|
|
4
|
-
* comparison.
|
|
5
|
-
* (same inference model as React’s `Subscribe` / `table.Subscribe`).
|
|
5
|
+
* Fine-grained subscription to a source using `useSelector` with shallow
|
|
6
|
+
* comparison. Omit `selector` to subscribe to the source value directly.
|
|
6
7
|
*/
|
|
7
|
-
export declare function subscribeTable<
|
|
8
|
-
|
|
9
|
-
};
|
|
8
|
+
export declare function subscribeTable<TSourceValue>(source: SubscribeSource<TSourceValue>): ReturnType<typeof useSelector<TSourceValue>>;
|
|
9
|
+
export declare function subscribeTable<TSourceValue, TSelected>(source: SubscribeSource<TSourceValue>, selector: (state: TSourceValue) => TSelected): ReturnType<typeof useSelector<TSourceValue, TSelected>>;
|
package/dist/subscribe.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { shallow, useSelector } from '@tanstack/svelte-store';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* comparison. Call from `<script>` so the selector is contextually typed
|
|
5
|
-
* (same inference model as React’s `Subscribe` / `table.Subscribe`).
|
|
6
|
-
*/
|
|
7
|
-
export function subscribeTable(table, selector) {
|
|
8
|
-
return useSelector(table.store, selector, { compare: shallow });
|
|
2
|
+
export function subscribeTable(source, selector) {
|
|
3
|
+
return useSelector(source, selector, { compare: shallow });
|
|
9
4
|
}
|
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.44",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@tanstack/svelte-store": "^0.12.0",
|
|
54
|
-
"@tanstack/table-core": "9.0.0-alpha.
|
|
54
|
+
"@tanstack/table-core": "9.0.0-alpha.43"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@sveltejs/package": "^2.5.7",
|
package/src/index.ts
CHANGED
|
@@ -17,5 +17,5 @@ export type {
|
|
|
17
17
|
} from './createTableHook.svelte'
|
|
18
18
|
export { createTableState } from './createTableState.svelte'
|
|
19
19
|
export { default as FlexRender } from './FlexRender.svelte'
|
|
20
|
-
export { subscribeTable } from './subscribe'
|
|
20
|
+
export { subscribeTable, type SubscribeSource } from './subscribe'
|
|
21
21
|
export { renderComponent, renderSnippet } from './render-component'
|
package/src/reactivity.svelte.ts
CHANGED
|
@@ -20,7 +20,8 @@ function subscribeToRune<T>(
|
|
|
20
20
|
const callback = observerToCallback(observerOrNext)
|
|
21
21
|
const unsubscribe = $effect.root(() => {
|
|
22
22
|
$effect(() => {
|
|
23
|
-
|
|
23
|
+
const value = getValue()
|
|
24
|
+
untrack(() => callback(value))
|
|
24
25
|
})
|
|
25
26
|
})
|
|
26
27
|
|
|
@@ -29,6 +30,7 @@ function subscribeToRune<T>(
|
|
|
29
30
|
|
|
30
31
|
export function svelteReactivity(): TableReactivityBindings {
|
|
31
32
|
return {
|
|
33
|
+
createOptionsStore: true,
|
|
32
34
|
createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {
|
|
33
35
|
const value = $derived.by(fn)
|
|
34
36
|
|
package/src/subscribe.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { shallow, useSelector } from '@tanstack/svelte-store'
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@tanstack/
|
|
3
|
+
Atom,
|
|
4
|
+
ReadonlyAtom,
|
|
5
|
+
ReadonlyStore,
|
|
6
|
+
Store,
|
|
7
|
+
} from '@tanstack/svelte-store'
|
|
8
|
+
|
|
9
|
+
export type SubscribeSource<TValue> =
|
|
10
|
+
| Atom<TValue>
|
|
11
|
+
| ReadonlyAtom<TValue>
|
|
12
|
+
| Store<TValue>
|
|
13
|
+
| ReadonlyStore<TValue>
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
|
-
* Fine-grained subscription to
|
|
11
|
-
* comparison.
|
|
12
|
-
* (same inference model as React’s `Subscribe` / `table.Subscribe`).
|
|
16
|
+
* Fine-grained subscription to a source using `useSelector` with shallow
|
|
17
|
+
* comparison. Omit `selector` to subscribe to the source value directly.
|
|
13
18
|
*/
|
|
14
|
-
export function subscribeTable<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export function subscribeTable<TSourceValue>(
|
|
20
|
+
source: SubscribeSource<TSourceValue>,
|
|
21
|
+
): ReturnType<typeof useSelector<TSourceValue>>
|
|
22
|
+
export function subscribeTable<TSourceValue, TSelected>(
|
|
23
|
+
source: SubscribeSource<TSourceValue>,
|
|
24
|
+
selector: (state: TSourceValue) => TSelected,
|
|
25
|
+
): ReturnType<typeof useSelector<TSourceValue, TSelected>>
|
|
26
|
+
export function subscribeTable<TSourceValue, TSelected>(
|
|
27
|
+
source: SubscribeSource<TSourceValue>,
|
|
28
|
+
selector?: (state: TSourceValue) => TSelected,
|
|
21
29
|
) {
|
|
22
|
-
return useSelector(
|
|
30
|
+
return useSelector(source, selector, { compare: shallow })
|
|
23
31
|
}
|