@tanstack/svelte-table 9.0.0-alpha.44 → 9.0.0-alpha.46
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/createTable.svelte.d.ts +27 -2
- package/dist/createTable.svelte.js +26 -1
- package/dist/createTableHook.svelte.d.ts +1 -1
- package/dist/createTableState.svelte.d.ts +15 -0
- package/dist/createTableState.svelte.js +15 -0
- package/dist/reactivity.svelte.d.ts +7 -0
- package/dist/reactivity.svelte.js +7 -0
- package/dist/render-component.d.ts +7 -5
- package/dist/render-component.js +7 -5
- package/dist/subscribe.d.ts +17 -2
- package/package.json +4 -4
- package/src/createTable.svelte.ts +28 -4
- package/src/createTableHook.svelte.ts +4 -1
- package/src/createTableState.svelte.ts +15 -0
- package/src/reactivity.svelte.ts +7 -0
- package/src/render-component.ts +7 -5
- package/src/subscribe.ts +17 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RowData, Table, TableFeatures, TableOptions, TableState } from '@tanstack/table-core';
|
|
2
|
-
export type SvelteTable<TFeatures extends TableFeatures, TData extends RowData, TSelected =
|
|
2
|
+
export type SvelteTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Table<TFeatures, TData> & {
|
|
3
3
|
/**
|
|
4
4
|
* The selected state of the table. This state may not match the structure of `table.store.state` because it is selected by the `selector` function that you pass as the 2nd argument to `createTable`.
|
|
5
5
|
*
|
|
@@ -10,4 +10,29 @@ export type SvelteTable<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
10
10
|
*/
|
|
11
11
|
readonly state: Readonly<TSelected>;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Svelte 5 table instance backed by rune-aware TanStack Store atoms.
|
|
15
|
+
*
|
|
16
|
+
* The optional selector projects from `table.store`; the selected value is
|
|
17
|
+
* exposed on `table.state`. The adapter syncs options in `$effect.pre`, so
|
|
18
|
+
* reactive option getters and external `$state` values are applied before DOM
|
|
19
|
+
* updates read table APIs such as `getRowModel()`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```svelte
|
|
23
|
+
* <script lang="ts">
|
|
24
|
+
* const table = createTable(
|
|
25
|
+
* {
|
|
26
|
+
* _features,
|
|
27
|
+
* _rowModels: {},
|
|
28
|
+
* columns,
|
|
29
|
+
* data,
|
|
30
|
+
* },
|
|
31
|
+
* (state) => ({ pagination: state.pagination }),
|
|
32
|
+
* )
|
|
33
|
+
* </script>
|
|
34
|
+
*
|
|
35
|
+
* {table.state.pagination.pageIndex}
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>>(tableOptions: TableOptions<TFeatures, TData>, selector?: (state: TableState<TFeatures>) => TSelected): SvelteTable<TFeatures, TData, TSelected>;
|
|
@@ -3,7 +3,32 @@ import { useSelector } from '@tanstack/svelte-store';
|
|
|
3
3
|
import { untrack } from 'svelte';
|
|
4
4
|
import { mergeObjects } from './merge-objects';
|
|
5
5
|
import { svelteReactivity } from './reactivity.svelte';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Svelte 5 table instance backed by rune-aware TanStack Store atoms.
|
|
8
|
+
*
|
|
9
|
+
* The optional selector projects from `table.store`; the selected value is
|
|
10
|
+
* exposed on `table.state`. The adapter syncs options in `$effect.pre`, so
|
|
11
|
+
* reactive option getters and external `$state` values are applied before DOM
|
|
12
|
+
* updates read table APIs such as `getRowModel()`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```svelte
|
|
16
|
+
* <script lang="ts">
|
|
17
|
+
* const table = createTable(
|
|
18
|
+
* {
|
|
19
|
+
* _features,
|
|
20
|
+
* _rowModels: {},
|
|
21
|
+
* columns,
|
|
22
|
+
* data,
|
|
23
|
+
* },
|
|
24
|
+
* (state) => ({ pagination: state.pagination }),
|
|
25
|
+
* )
|
|
26
|
+
* </script>
|
|
27
|
+
*
|
|
28
|
+
* {table.state.pagination.pageIndex}
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function createTable(tableOptions, selector) {
|
|
7
32
|
// 1. Merge reactivity into options using mergeObjects (preserves getters)
|
|
8
33
|
const mergedOptions = mergeObjects(tableOptions, {
|
|
9
34
|
_features: {
|
|
@@ -228,7 +228,7 @@ export type AppSvelteTable<TFeatures extends TableFeatures, TData extends RowDat
|
|
|
228
228
|
export declare function createTableHook<TFeatures extends TableFeatures, const TTableComponents extends Record<string, ComponentType<any>>, const TCellComponents extends Record<string, ComponentType<any>>, const THeaderComponents extends Record<string, ComponentType<any>>>({ tableComponents, cellComponents, headerComponents, ...defaultTableOptions }: CreateTableHookOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>): {
|
|
229
229
|
appFeatures: TFeatures;
|
|
230
230
|
createAppColumnHelper: <TData extends RowData>() => AppColumnHelper<TFeatures, TData, TCellComponents, THeaderComponents>;
|
|
231
|
-
createAppTable: <TData extends RowData, TSelected =
|
|
231
|
+
createAppTable: <TData extends RowData, TSelected = TableState<TFeatures>>(tableOptions: Omit<TableOptions<TFeatures, TData>, "_features" | "_rowModels">, selector?: (state: TableState<TFeatures>) => TSelected) => AppSvelteTable<TFeatures, TData, TSelected, TTableComponents, TCellComponents, THeaderComponents>;
|
|
232
232
|
useTableContext: <TData extends RowData = RowData>() => SvelteTable<TFeatures, TData>;
|
|
233
233
|
useCellContext: <TValue extends CellData = unknown>() => Cell<TFeatures, any, TValue>;
|
|
234
234
|
useHeaderContext: <TValue extends CellData = unknown>() => Header<TFeatures, any, TValue>;
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
import type { Updater } from '@tanstack/table-core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a small Svelte 5 state holder that accepts TanStack Table updaters.
|
|
4
|
+
*
|
|
5
|
+
* This is useful when a table state slice should be owned outside the table
|
|
6
|
+
* with `$state`, but still needs to accept both value and functional updater
|
|
7
|
+
* forms from `on[State]Change` callbacks.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const [pagination, setPagination] = createTableState({
|
|
12
|
+
* pageIndex: 0,
|
|
13
|
+
* pageSize: 10,
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
export declare function createTableState<TState>(initialValue: TState): [() => TState, (updater: Updater<TState>) => void];
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a small Svelte 5 state holder that accepts TanStack Table updaters.
|
|
3
|
+
*
|
|
4
|
+
* This is useful when a table state slice should be owned outside the table
|
|
5
|
+
* with `$state`, but still needs to accept both value and functional updater
|
|
6
|
+
* forms from `on[State]Change` callbacks.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const [pagination, setPagination] = createTableState({
|
|
11
|
+
* pageIndex: 0,
|
|
12
|
+
* pageSize: 10,
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export function createTableState(initialValue) {
|
|
2
17
|
let value = $state(initialValue);
|
|
3
18
|
return [
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { TableReactivityBindings } from '@tanstack/table-core/reactivity';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the table-core reactivity bindings used by the Svelte adapter.
|
|
4
|
+
*
|
|
5
|
+
* Readonly table atoms are backed by `$derived.by`, writable atoms by `$state`,
|
|
6
|
+
* and subscriptions bridge through rune effects so table APIs participate in
|
|
7
|
+
* Svelte dependency tracking.
|
|
8
|
+
*/
|
|
2
9
|
export declare function svelteReactivity(): TableReactivityBindings;
|
|
@@ -14,6 +14,13 @@ function subscribeToRune(getValue, observerOrNext) {
|
|
|
14
14
|
});
|
|
15
15
|
return { unsubscribe };
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates the table-core reactivity bindings used by the Svelte adapter.
|
|
19
|
+
*
|
|
20
|
+
* Readonly table atoms are backed by `$derived.by`, writable atoms by `$state`,
|
|
21
|
+
* and subscriptions bridge through rune effects so table APIs participate in
|
|
22
|
+
* Svelte dependency tracking.
|
|
23
|
+
*/
|
|
17
24
|
export function svelteReactivity() {
|
|
18
25
|
return {
|
|
19
26
|
createOptionsStore: true,
|
|
@@ -41,7 +41,8 @@ export declare class RenderSnippetConfig<TProps> {
|
|
|
41
41
|
constructor(snippet: Snippet<[TProps]>, params?: TProps | undefined);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Wraps a Svelte component so it can be returned from a column definition
|
|
45
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
45
46
|
*
|
|
46
47
|
* This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
|
|
47
48
|
*
|
|
@@ -64,15 +65,16 @@ export declare class RenderSnippetConfig<TProps> {
|
|
|
64
65
|
*/
|
|
65
66
|
export declare const renderComponent: <TComponent extends Component<any>, TProps extends ComponentProps<TComponent>>(component: TComponent, props?: TProps) => RenderComponentConfig<TComponent>;
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
+
* Wraps a Svelte snippet so it can be returned from a column definition
|
|
69
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
68
70
|
*
|
|
69
71
|
* *The snippet must only take one parameter.*
|
|
70
72
|
*
|
|
71
73
|
* This is only to be used with Snippets - use `renderComponent` for Svelte Components.
|
|
72
74
|
*
|
|
73
|
-
* @param snippet
|
|
74
|
-
* @param params
|
|
75
|
-
* @returns
|
|
75
|
+
* @param snippet The snippet to render.
|
|
76
|
+
* @param params The single parameter object passed to the snippet.
|
|
77
|
+
* @returns A `RenderSnippetConfig` consumed by the Svelte `FlexRender` component.
|
|
76
78
|
* @example
|
|
77
79
|
* ```ts
|
|
78
80
|
* // +page.svelte
|
package/dist/render-component.js
CHANGED
|
@@ -42,7 +42,8 @@ export class RenderSnippetConfig {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Wraps a Svelte component so it can be returned from a column definition
|
|
46
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
46
47
|
*
|
|
47
48
|
* This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
|
|
48
49
|
*
|
|
@@ -65,15 +66,16 @@ export class RenderSnippetConfig {
|
|
|
65
66
|
*/
|
|
66
67
|
export const renderComponent = (component, props) => new RenderComponentConfig(component, props);
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
+
* Wraps a Svelte snippet so it can be returned from a column definition
|
|
70
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
69
71
|
*
|
|
70
72
|
* *The snippet must only take one parameter.*
|
|
71
73
|
*
|
|
72
74
|
* This is only to be used with Snippets - use `renderComponent` for Svelte Components.
|
|
73
75
|
*
|
|
74
|
-
* @param snippet
|
|
75
|
-
* @param params
|
|
76
|
-
* @returns
|
|
76
|
+
* @param snippet The snippet to render.
|
|
77
|
+
* @param params The single parameter object passed to the snippet.
|
|
78
|
+
* @returns A `RenderSnippetConfig` consumed by the Svelte `FlexRender` component.
|
|
77
79
|
* @example
|
|
78
80
|
* ```ts
|
|
79
81
|
* // +page.svelte
|
package/dist/subscribe.d.ts
CHANGED
|
@@ -2,8 +2,23 @@ import { useSelector } from '@tanstack/svelte-store';
|
|
|
2
2
|
import type { Atom, ReadonlyAtom, ReadonlyStore, Store } from '@tanstack/svelte-store';
|
|
3
3
|
export type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Creates a fine-grained Svelte subscription to a TanStack Store source.
|
|
6
|
+
*
|
|
7
|
+
* Pass a table atom or store and optionally project it with a selector. The
|
|
8
|
+
* returned selector store exposes `.current`, making it useful for reading
|
|
9
|
+
* focused table state outside the broad `createTable` selector.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```svelte
|
|
13
|
+
* <script lang="ts">
|
|
14
|
+
* const selected = subscribeTable(
|
|
15
|
+
* table.atoms.rowSelection,
|
|
16
|
+
* (rowSelection) => rowSelection[row.id],
|
|
17
|
+
* )
|
|
18
|
+
* </script>
|
|
19
|
+
*
|
|
20
|
+
* <input type="checkbox" checked={!!selected.current} />
|
|
21
|
+
* ```
|
|
7
22
|
*/
|
|
8
23
|
export declare function subscribeTable<TSourceValue>(source: SubscribeSource<TSourceValue>): ReturnType<typeof useSelector<TSourceValue>>;
|
|
9
24
|
export declare function subscribeTable<TSourceValue, TSelected>(source: SubscribeSource<TSourceValue>, selector: (state: TSourceValue) => TSelected): ReturnType<typeof useSelector<TSourceValue, TSelected>>;
|
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.46",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,14 +51,14 @@
|
|
|
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.46"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@sveltejs/package": "^2.5.7",
|
|
58
|
-
"@sveltejs/vite-plugin-svelte": "^7.
|
|
58
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
59
59
|
"eslint-plugin-svelte": "^3.17.1",
|
|
60
60
|
"svelte": "^5.55.5",
|
|
61
|
-
"svelte-check": "^4.4.
|
|
61
|
+
"svelte-check": "^4.4.8"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"svelte": "^5.0.0"
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
export type SvelteTable<
|
|
15
15
|
TFeatures extends TableFeatures,
|
|
16
16
|
TData extends RowData,
|
|
17
|
-
TSelected =
|
|
17
|
+
TSelected = TableState<TFeatures>,
|
|
18
18
|
> = Table<TFeatures, TData> & {
|
|
19
19
|
/**
|
|
20
20
|
* The selected state of the table. This state may not match the structure of `table.store.state` because it is selected by the `selector` function that you pass as the 2nd argument to `createTable`.
|
|
@@ -27,14 +27,38 @@ export type SvelteTable<
|
|
|
27
27
|
readonly state: Readonly<TSelected>
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Creates a Svelte 5 table instance backed by rune-aware TanStack Store atoms.
|
|
32
|
+
*
|
|
33
|
+
* The optional selector projects from `table.store`; the selected value is
|
|
34
|
+
* exposed on `table.state`. The adapter syncs options in `$effect.pre`, so
|
|
35
|
+
* reactive option getters and external `$state` values are applied before DOM
|
|
36
|
+
* updates read table APIs such as `getRowModel()`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```svelte
|
|
40
|
+
* <script lang="ts">
|
|
41
|
+
* const table = createTable(
|
|
42
|
+
* {
|
|
43
|
+
* _features,
|
|
44
|
+
* _rowModels: {},
|
|
45
|
+
* columns,
|
|
46
|
+
* data,
|
|
47
|
+
* },
|
|
48
|
+
* (state) => ({ pagination: state.pagination }),
|
|
49
|
+
* )
|
|
50
|
+
* </script>
|
|
51
|
+
*
|
|
52
|
+
* {table.state.pagination.pageIndex}
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
30
55
|
export function createTable<
|
|
31
56
|
TFeatures extends TableFeatures,
|
|
32
57
|
TData extends RowData,
|
|
33
|
-
TSelected =
|
|
58
|
+
TSelected = TableState<TFeatures>,
|
|
34
59
|
>(
|
|
35
60
|
tableOptions: TableOptions<TFeatures, TData>,
|
|
36
|
-
selector
|
|
37
|
-
({}) as TSelected,
|
|
61
|
+
selector?: (state: TableState<TFeatures>) => TSelected,
|
|
38
62
|
): SvelteTable<TFeatures, TData, TSelected> {
|
|
39
63
|
// 1. Merge reactivity into options using mergeObjects (preserves getters)
|
|
40
64
|
const mergedOptions = mergeObjects(tableOptions, {
|
|
@@ -523,7 +523,10 @@ export function createTableHook<
|
|
|
523
523
|
*
|
|
524
524
|
* TFeatures is already known from the createTableHook call; TData is inferred from the data prop.
|
|
525
525
|
*/
|
|
526
|
-
function createAppTable<
|
|
526
|
+
function createAppTable<
|
|
527
|
+
TData extends RowData,
|
|
528
|
+
TSelected = TableState<TFeatures>,
|
|
529
|
+
>(
|
|
527
530
|
tableOptions: Omit<
|
|
528
531
|
TableOptions<TFeatures, TData>,
|
|
529
532
|
'_features' | '_rowModels'
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { Updater } from '@tanstack/table-core'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates a small Svelte 5 state holder that accepts TanStack Table updaters.
|
|
5
|
+
*
|
|
6
|
+
* This is useful when a table state slice should be owned outside the table
|
|
7
|
+
* with `$state`, but still needs to accept both value and functional updater
|
|
8
|
+
* forms from `on[State]Change` callbacks.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const [pagination, setPagination] = createTableState({
|
|
13
|
+
* pageIndex: 0,
|
|
14
|
+
* pageSize: 10,
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
3
18
|
export function createTableState<TState>(
|
|
4
19
|
initialValue: TState,
|
|
5
20
|
): [() => TState, (updater: Updater<TState>) => void] {
|
package/src/reactivity.svelte.ts
CHANGED
|
@@ -28,6 +28,13 @@ function subscribeToRune<T>(
|
|
|
28
28
|
return { unsubscribe }
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Creates the table-core reactivity bindings used by the Svelte adapter.
|
|
33
|
+
*
|
|
34
|
+
* Readonly table atoms are backed by `$derived.by`, writable atoms by `$state`,
|
|
35
|
+
* and subscriptions bridge through rune effects so table APIs participate in
|
|
36
|
+
* Svelte dependency tracking.
|
|
37
|
+
*/
|
|
31
38
|
export function svelteReactivity(): TableReactivityBindings {
|
|
32
39
|
return {
|
|
33
40
|
createOptionsStore: true,
|
package/src/render-component.ts
CHANGED
|
@@ -46,7 +46,8 @@ export class RenderSnippetConfig<TProps> {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Wraps a Svelte component so it can be returned from a column definition
|
|
50
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
50
51
|
*
|
|
51
52
|
* This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
|
|
52
53
|
*
|
|
@@ -76,15 +77,16 @@ export const renderComponent = <
|
|
|
76
77
|
) => new RenderComponentConfig(component, props)
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
+
* Wraps a Svelte snippet so it can be returned from a column definition
|
|
81
|
+
* renderer such as `cell`, `header`, or `footer`.
|
|
80
82
|
*
|
|
81
83
|
* *The snippet must only take one parameter.*
|
|
82
84
|
*
|
|
83
85
|
* This is only to be used with Snippets - use `renderComponent` for Svelte Components.
|
|
84
86
|
*
|
|
85
|
-
* @param snippet
|
|
86
|
-
* @param params
|
|
87
|
-
* @returns
|
|
87
|
+
* @param snippet The snippet to render.
|
|
88
|
+
* @param params The single parameter object passed to the snippet.
|
|
89
|
+
* @returns A `RenderSnippetConfig` consumed by the Svelte `FlexRender` component.
|
|
88
90
|
* @example
|
|
89
91
|
* ```ts
|
|
90
92
|
* // +page.svelte
|
package/src/subscribe.ts
CHANGED
|
@@ -13,8 +13,23 @@ export type SubscribeSource<TValue> =
|
|
|
13
13
|
| ReadonlyStore<TValue>
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Creates a fine-grained Svelte subscription to a TanStack Store source.
|
|
17
|
+
*
|
|
18
|
+
* Pass a table atom or store and optionally project it with a selector. The
|
|
19
|
+
* returned selector store exposes `.current`, making it useful for reading
|
|
20
|
+
* focused table state outside the broad `createTable` selector.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```svelte
|
|
24
|
+
* <script lang="ts">
|
|
25
|
+
* const selected = subscribeTable(
|
|
26
|
+
* table.atoms.rowSelection,
|
|
27
|
+
* (rowSelection) => rowSelection[row.id],
|
|
28
|
+
* )
|
|
29
|
+
* </script>
|
|
30
|
+
*
|
|
31
|
+
* <input type="checkbox" checked={!!selected.current} />
|
|
32
|
+
* ```
|
|
18
33
|
*/
|
|
19
34
|
export function subscribeTable<TSourceValue>(
|
|
20
35
|
source: SubscribeSource<TSourceValue>,
|