@tanstack/svelte-table 9.0.0-alpha.44 → 9.0.0-alpha.45
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 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,4 @@ export type SvelteTable<TFeatures extends TableFeatures, TData extends RowData,
|
|
|
10
10
|
*/
|
|
11
11
|
readonly state: Readonly<TSelected>;
|
|
12
12
|
};
|
|
13
|
-
export declare function createTable<TFeatures extends TableFeatures, TData extends RowData, TSelected =
|
|
13
|
+
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,7 @@ 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
|
-
export function createTable(tableOptions, selector
|
|
6
|
+
export function createTable(tableOptions, selector) {
|
|
7
7
|
// 1. Merge reactivity into options using mergeObjects (preserves getters)
|
|
8
8
|
const mergedOptions = mergeObjects(tableOptions, {
|
|
9
9
|
_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>;
|
package/package.json
CHANGED
|
@@ -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`.
|
|
@@ -30,11 +30,10 @@ export type SvelteTable<
|
|
|
30
30
|
export function createTable<
|
|
31
31
|
TFeatures extends TableFeatures,
|
|
32
32
|
TData extends RowData,
|
|
33
|
-
TSelected =
|
|
33
|
+
TSelected = TableState<TFeatures>,
|
|
34
34
|
>(
|
|
35
35
|
tableOptions: TableOptions<TFeatures, TData>,
|
|
36
|
-
selector
|
|
37
|
-
({}) as TSelected,
|
|
36
|
+
selector?: (state: TableState<TFeatures>) => TSelected,
|
|
38
37
|
): SvelteTable<TFeatures, TData, TSelected> {
|
|
39
38
|
// 1. Merge reactivity into options using mergeObjects (preserves getters)
|
|
40
39
|
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'
|