diff --git a/docs/framework/angular/reference/functions/injectTable.md b/docs/framework/angular/reference/functions/injectTable.md index 905f444505..f6b3ded2f1 100644 --- a/docs/framework/angular/reference/functions/injectTable.md +++ b/docs/framework/angular/reference/functions/injectTable.md @@ -9,7 +9,7 @@ title: injectTable function injectTable(options, selector): AngularTable; ``` -Defined in: [injectTable.ts:125](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L125) +Defined in: [injectTable.ts:124](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L124) Creates and returns an Angular-reactive table instance. diff --git a/docs/framework/angular/reference/interfaces/AngularTableComputed.md b/docs/framework/angular/reference/interfaces/AngularTableComputed.md index 67c9c4413f..99495d91b7 100644 --- a/docs/framework/angular/reference/interfaces/AngularTableComputed.md +++ b/docs/framework/angular/reference/interfaces/AngularTableComputed.md @@ -5,7 +5,7 @@ title: AngularTableComputed # Interface: AngularTableComputed()\ -Defined in: [injectTable.ts:32](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L32) +Defined in: [injectTable.ts:28](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L28) Store mode: pass `selector` (required) to project from full table state. Source mode: pass `source` (atom or store); omit `selector` for the whole value @@ -24,7 +24,7 @@ inference. AngularTableComputed(props): Signal>; ``` -Defined in: [injectTable.ts:33](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L33) +Defined in: [injectTable.ts:29](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L29) Store mode: pass `selector` (required) to project from full table state. Source mode: pass `source` (atom or store); omit `selector` for the whole value @@ -63,7 +63,7 @@ inference. AngularTableComputed(props): Signal>; ``` -Defined in: [injectTable.ts:38](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L38) +Defined in: [injectTable.ts:34](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L34) Store mode: pass `selector` (required) to project from full table state. Source mode: pass `source` (atom or store); omit `selector` for the whole value @@ -106,7 +106,7 @@ inference. AngularTableComputed(props): Signal>; ``` -Defined in: [injectTable.ts:43](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L43) +Defined in: [injectTable.ts:39](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L39) Store mode: pass `selector` (required) to project from full table state. Source mode: pass `source` (atom or store); omit `selector` for the whole value diff --git a/docs/framework/angular/reference/type-aliases/AngularTable.md b/docs/framework/angular/reference/type-aliases/AngularTable.md index 511f50b724..d58e3ccafa 100644 --- a/docs/framework/angular/reference/type-aliases/AngularTable.md +++ b/docs/framework/angular/reference/type-aliases/AngularTable.md @@ -9,17 +9,41 @@ title: AngularTable type AngularTable = Table & object; ``` -Defined in: [injectTable.ts:49](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L49) +Defined in: [injectTable.ts:45](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L45) ## Type Declaration -### computed +### computed() ```ts -computed: AngularTableComputed; +computed: (props) => Signal>; ``` -Alias: **`Subscribe`** — same function reference as `computed` (naming parity with other adapters). +Creates a computed that subscribe to changes in the table store with a custom selector. +Default equality function is "shallow". + +#### Type Parameters + +##### TSubSelected + +`TSubSelected` = \{ +\} + +#### Parameters + +##### props + +###### equal? + +`ValueEqualityFn`\<`TSubSelected`\> + +###### selector + +(`state`) => `TSubSelected` + +#### Returns + +`Signal`\<`Readonly`\<`TSubSelected`\>\> ### state @@ -29,12 +53,6 @@ readonly state: Signal>; The selected state from the table store, based on the selector provided. -### Subscribe - -```ts -Subscribe: AngularTableComputed; -``` - ### value ```ts diff --git a/docs/framework/react/reference/index/functions/useTable.md b/docs/framework/react/reference/index/functions/useTable.md index 50d38700ac..562026f411 100644 --- a/docs/framework/react/reference/index/functions/useTable.md +++ b/docs/framework/react/reference/index/functions/useTable.md @@ -9,7 +9,7 @@ title: useTable function useTable(tableOptions, selector): ReactTable; ``` -Defined in: [useTable.ts:114](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L114) +Defined in: [useTable.ts:112](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L112) ## Type Parameters diff --git a/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md b/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md index 182e8b3cc5..450dc39ea0 100644 --- a/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md @@ -55,7 +55,7 @@ Defined in: [createTableHook.tsx:321](https://github.com/TanStack/table/blob/mai ##### cell -`Cell_Cell`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\<`"columnGroupingFeature"` *extends* keyof `TFeatures` ? `Cell_ColumnGrouping` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: TFeatures\[K\] extends TableFeature\ ? "Cell" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof FeatureConstructorOptions & "Cell"\] : never : any \}\[keyof `TFeatures`\]\> & `Cell_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `TCellComponents` & `object` +`Cell_Cell`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\<`"columnGroupingFeature"` *extends* keyof `TFeatures` ? `Cell_ColumnGrouping` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: K extends "coreReativityFeature" ? never : TFeatures\[K\] extends TableFeature\ ? "Cell" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof (...) & "Cell"\] : never : any \}\[keyof `TFeatures`\]\> & `Cell_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `TCellComponents` & `object` ##### state diff --git a/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md b/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md index 31282d47c5..be593f57dc 100644 --- a/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md @@ -51,7 +51,7 @@ Defined in: [createTableHook.tsx:303](https://github.com/TanStack/table/blob/mai ##### cell -`Cell_Cell`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\<`"columnGroupingFeature"` *extends* keyof `TFeatures` ? `Cell_ColumnGrouping` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: TFeatures\[K\] extends TableFeature\ ? "Cell" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof FeatureConstructorOptions & "Cell"\] : never : any \}\[keyof `TFeatures`\]\> & `Cell_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `TCellComponents` & `object` +`Cell_Cell`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\<`"columnGroupingFeature"` *extends* keyof `TFeatures` ? `Cell_ColumnGrouping` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: K extends "coreReativityFeature" ? never : TFeatures\[K\] extends TableFeature\ ? "Cell" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof (...) & "Cell"\] : never : any \}\[keyof `TFeatures`\]\> & `Cell_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `TCellComponents` & `object` #### Returns diff --git a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md index a56d2653d0..2aa3f06cc6 100644 --- a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md @@ -47,7 +47,7 @@ Defined in: [createTableHook.tsx:357](https://github.com/TanStack/table/blob/mai `Header_Core`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\< \| `"columnSizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnSizing` : `never` - \| `"columnResizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnResizing` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: TFeatures\[K\] extends TableFeature\ ? "Header" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof FeatureConstructorOptions & "Header"\] : never : any \}\[keyof `TFeatures`\]\> & `Header_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `THeaderComponents` & `object` + \| `"columnResizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnResizing` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: K extends "coreReativityFeature" ? never : TFeatures\[K\] extends TableFeature\ ? "Header" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof (...) & "Header"\] : never : any \}\[keyof `TFeatures`\]\> & `Header_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `THeaderComponents` & `object` ##### state diff --git a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md index 63a9566390..4636e9a882 100644 --- a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md @@ -43,7 +43,7 @@ Defined in: [createTableHook.tsx:339](https://github.com/TanStack/table/blob/mai `Header_Core`\<`TFeatures`, `TData`, `TValue`\> & `UnionToIntersection`\< \| `"columnSizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnSizing` : `never` - \| `"columnResizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnResizing` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: TFeatures\[K\] extends TableFeature\ ? "Header" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof FeatureConstructorOptions & "Header"\] : never : any \}\[keyof `TFeatures`\]\> & `Header_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `THeaderComponents` & `object` + \| `"columnResizingFeature"` *extends* keyof `TFeatures` ? `Header_ColumnResizing` : `never`\> & `UnionToIntersection`\<\{ \[K in string \| number \| symbol\]: K extends "coreReativityFeature" ? never : TFeatures\[K\] extends TableFeature\ ? "Header" extends keyof FeatureConstructorOptions ? FeatureConstructorOptions\[keyof (...) & "Header"\] : never : any \}\[keyof `TFeatures`\]\> & `Header_Plugins`\<`TFeatures`, `TData`, `TValue`\> & `THeaderComponents` & `object` #### Returns diff --git a/docs/framework/react/reference/index/type-aliases/ReactTable.md b/docs/framework/react/reference/index/type-aliases/ReactTable.md index 35de60ea19..1620c2cb3b 100644 --- a/docs/framework/react/reference/index/type-aliases/ReactTable.md +++ b/docs/framework/react/reference/index/type-aliases/ReactTable.md @@ -9,7 +9,7 @@ title: ReactTable type ReactTable = Table & object; ``` -Defined in: [useTable.ts:21](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L21) +Defined in: [useTable.ts:22](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L22) ## Type Declaration @@ -56,25 +56,11 @@ flexRender(footer.column.columnDef.footer, footer.getContext()) ### state ```ts -readonly state: Readonly & object; +readonly state: Readonly; ``` 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 `useTable`. -#### Type Declaration - -##### columns - -```ts -columns: TableOptions["columns"]; -``` - -##### data - -```ts -data: TableOptions["data"]; -``` - #### Example ```ts diff --git a/docs/reference/functions/constructReactivityFeature.md b/docs/reference/functions/constructReactivityFeature.md deleted file mode 100644 index 873ea5a330..0000000000 --- a/docs/reference/functions/constructReactivityFeature.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -id: constructReactivityFeature -title: constructReactivityFeature ---- - -# Function: constructReactivityFeature() - -```ts -function constructReactivityFeature(bindings): TableFeature>; -``` - -Defined in: [features/table-reactivity/tableReactivityFeature.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/table-reactivity/tableReactivityFeature.ts#L10) - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### bindings - -#### optionsNotifier? - -() => `unknown` - -#### stateNotifier? - -() => `unknown` - -## Returns - -[`TableFeature`](../interfaces/TableFeature.md)\<[`TableReactivityFeatureConstructors`](../interfaces/TableReactivityFeatureConstructors.md)\<`TFeatures`, `TData`\>\> diff --git a/docs/reference/functions/constructTable.md b/docs/reference/functions/constructTable.md index 7f120c21d5..5a64c614c5 100644 --- a/docs/reference/functions/constructTable.md +++ b/docs/reference/functions/constructTable.md @@ -9,7 +9,7 @@ title: constructTable function constructTable(tableOptions): Table; ``` -Defined in: [core/table/constructTable.ts:20](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/constructTable.ts#L20) +Defined in: [core/table/constructTable.ts:21](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/constructTable.ts#L21) ## Type Parameters diff --git a/docs/reference/functions/getInitialTableState.md b/docs/reference/functions/getInitialTableState.md index 62c995128e..59c05d8c1e 100644 --- a/docs/reference/functions/getInitialTableState.md +++ b/docs/reference/functions/getInitialTableState.md @@ -9,7 +9,7 @@ title: getInitialTableState function getInitialTableState(features, initialState): TableState; ``` -Defined in: [core/table/constructTable.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/constructTable.ts#L10) +Defined in: [core/table/constructTable.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/constructTable.ts#L11) ## Type Parameters diff --git a/docs/reference/functions/tableOptions.md b/docs/reference/functions/tableOptions.md index 46944ecc2d..42ca2e12ff 100644 --- a/docs/reference/functions/tableOptions.md +++ b/docs/reference/functions/tableOptions.md @@ -64,7 +64,7 @@ Defined in: [helpers/tableOptions.ts:16](https://github.com/TanStack/table/blob/ ## Call Signature ```ts -function tableOptions(options): Omit, "_features">; +function tableOptions(options): Omit, "_features" | "data" | "columns"> & object; ``` Defined in: [helpers/tableOptions.ts:27](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L27) @@ -83,19 +83,19 @@ Defined in: [helpers/tableOptions.ts:27](https://github.com/TanStack/table/blob/ #### options -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"`\> & `object` ### Returns -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"` \| `"data"` \| `"columns"`\> & `object` ## Call Signature ```ts -function tableOptions(options): Omit, "_features" | "data" | "columns"> & object; +function tableOptions(options): TableOptions; ``` -Defined in: [helpers/tableOptions.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L34) +Defined in: [helpers/tableOptions.ts:38](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L38) ### Type Parameters @@ -111,19 +111,19 @@ Defined in: [helpers/tableOptions.ts:34](https://github.com/TanStack/table/blob/ #### options -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"`\> & `object` +[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\> ### Returns -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"` \| `"data"` \| `"columns"`\> & `object` +[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\> ## Call Signature ```ts -function tableOptions(options): Omit, "data" | "_features">; +function tableOptions(options): Omit, "_features">; ``` -Defined in: [helpers/tableOptions.ts:45](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L45) +Defined in: [helpers/tableOptions.ts:43](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L43) ### Type Parameters @@ -139,19 +139,19 @@ Defined in: [helpers/tableOptions.ts:45](https://github.com/TanStack/table/blob/ #### options -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"`\> ### Returns -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"_features"`\> ## Call Signature ```ts -function tableOptions(options): Omit, "columns" | "_features">; +function tableOptions(options): Omit, "data" | "_features">; ``` -Defined in: [helpers/tableOptions.ts:52](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L52) +Defined in: [helpers/tableOptions.ts:50](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L50) ### Type Parameters @@ -167,19 +167,19 @@ Defined in: [helpers/tableOptions.ts:52](https://github.com/TanStack/table/blob/ #### options -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"columns"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"_features"`\> ### Returns -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"columns"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"_features"`\> ## Call Signature ```ts -function tableOptions(options): Omit, "data" | "columns" | "_features">; +function tableOptions(options): Omit, "columns" | "_features">; ``` -Defined in: [helpers/tableOptions.ts:59](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L59) +Defined in: [helpers/tableOptions.ts:57](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L57) ### Type Parameters @@ -195,19 +195,19 @@ Defined in: [helpers/tableOptions.ts:59](https://github.com/TanStack/table/blob/ #### options -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"columns"` \| `"_features"`\> ### Returns -`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"` \| `"_features"`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"columns"` \| `"_features"`\> ## Call Signature ```ts -function tableOptions(options): TableOptions; +function tableOptions(options): Omit, "data" | "columns" | "_features">; ``` -Defined in: [helpers/tableOptions.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L69) +Defined in: [helpers/tableOptions.ts:64](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableOptions.ts#L64) ### Type Parameters @@ -223,8 +223,8 @@ Defined in: [helpers/tableOptions.ts:69](https://github.com/TanStack/table/blob/ #### options -[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"` \| `"_features"`\> ### Returns -[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\> +`Omit`\<[`TableOptions`](../type-aliases/TableOptions.md)\<`TFeatures`, `TData`\>, `"data"` \| `"columns"` \| `"_features"`\> diff --git a/docs/reference/index.md b/docs/reference/index.md index f03e4f0f14..51dc18ef70 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -194,7 +194,6 @@ title: "@tanstack/table-core" - [TableOptions\_RowSelection](interfaces/TableOptions_RowSelection.md) - [TableOptions\_RowSorting](interfaces/TableOptions_RowSorting.md) - [TableOptions\_Table](interfaces/TableOptions_Table.md) -- [TableReactivityFeatureConstructors](interfaces/TableReactivityFeatureConstructors.md) - [TableState\_ColumnFiltering](interfaces/TableState_ColumnFiltering.md) - [TableState\_ColumnGrouping](interfaces/TableState_ColumnGrouping.md) - [TableState\_ColumnOrdering](interfaces/TableState_ColumnOrdering.md) @@ -397,7 +396,6 @@ title: "@tanstack/table-core" - [constructCoreTablesFeature](functions/constructCoreTablesFeature.md) - [constructGlobalFilteringFeature](functions/constructGlobalFilteringFeature.md) - [constructHeader](functions/constructHeader.md) -- [constructReactivityFeature](functions/constructReactivityFeature.md) - [constructRow](functions/constructRow.md) - [constructRowExpandingFeature](functions/constructRowExpandingFeature.md) - [constructRowPaginationFeature](functions/constructRowPaginationFeature.md) diff --git a/docs/reference/interfaces/CoreFeatures.md b/docs/reference/interfaces/CoreFeatures.md index 1491971a10..d3bde6f41f 100644 --- a/docs/reference/interfaces/CoreFeatures.md +++ b/docs/reference/interfaces/CoreFeatures.md @@ -5,7 +5,7 @@ title: CoreFeatures # Interface: CoreFeatures -Defined in: [core/coreFeatures.ts:8](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L8) +Defined in: [core/coreFeatures.ts:9](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L9) ## Properties @@ -15,7 +15,7 @@ Defined in: [core/coreFeatures.ts:8](https://github.com/TanStack/table/blob/main coreCellsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:9](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L9) +Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L11) *** @@ -25,7 +25,7 @@ Defined in: [core/coreFeatures.ts:9](https://github.com/TanStack/table/blob/main coreColumnsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L10) +Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L12) *** @@ -35,7 +35,17 @@ Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/mai coreHeadersFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L11) +Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L13) + +*** + +### coreReativityFeature? + +```ts +optional coreReativityFeature: TableReactivityBindings; +``` + +Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L10) *** @@ -45,7 +55,7 @@ Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/mai coreRowModelsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L12) +Defined in: [core/coreFeatures.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L14) *** @@ -55,7 +65,7 @@ Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/mai coreRowsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L13) +Defined in: [core/coreFeatures.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L15) *** @@ -65,4 +75,4 @@ Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/mai coreTablesFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L14) +Defined in: [core/coreFeatures.ts:16](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L16) diff --git a/docs/reference/interfaces/TableFeatures.md b/docs/reference/interfaces/TableFeatures.md index 5d052fa608..6204ceb9ea 100644 --- a/docs/reference/interfaces/TableFeatures.md +++ b/docs/reference/interfaces/TableFeatures.md @@ -131,7 +131,7 @@ Defined in: [features/stockFeatures.ts:24](https://github.com/TanStack/table/blo optional coreCellsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:9](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L9) +Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L11) #### Inherited from @@ -145,7 +145,7 @@ Defined in: [core/coreFeatures.ts:9](https://github.com/TanStack/table/blob/main optional coreColumnsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L10) +Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L12) #### Inherited from @@ -159,7 +159,7 @@ Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/mai optional coreHeadersFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L11) +Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L13) #### Inherited from @@ -167,13 +167,27 @@ Defined in: [core/coreFeatures.ts:11](https://github.com/TanStack/table/blob/mai *** +### coreReativityFeature? + +```ts +optional coreReativityFeature: TableReactivityBindings; +``` + +Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L10) + +#### Inherited from + +[`CoreFeatures`](CoreFeatures.md).[`coreReativityFeature`](CoreFeatures.md#corereativityfeature) + +*** + ### coreRowModelsFeature? ```ts optional coreRowModelsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L12) +Defined in: [core/coreFeatures.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L14) #### Inherited from @@ -187,7 +201,7 @@ Defined in: [core/coreFeatures.ts:12](https://github.com/TanStack/table/blob/mai optional coreRowsFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L13) +Defined in: [core/coreFeatures.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L15) #### Inherited from @@ -201,7 +215,7 @@ Defined in: [core/coreFeatures.ts:13](https://github.com/TanStack/table/blob/mai optional coreTablesFeature: TableFeature>; ``` -Defined in: [core/coreFeatures.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L14) +Defined in: [core/coreFeatures.ts:16](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L16) #### Inherited from diff --git a/docs/reference/interfaces/TableMeta.md b/docs/reference/interfaces/TableMeta.md index 97579c5732..22408a0d51 100644 --- a/docs/reference/interfaces/TableMeta.md +++ b/docs/reference/interfaces/TableMeta.md @@ -5,7 +5,7 @@ title: TableMeta # Interface: TableMeta\ -Defined in: [core/table/coreTablesFeature.types.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L10) +Defined in: [core/table/coreTablesFeature.types.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L11) ## Type Parameters diff --git a/docs/reference/interfaces/TableOptions_Core.md b/docs/reference/interfaces/TableOptions_Core.md index 35d868cf9f..57b8978816 100644 --- a/docs/reference/interfaces/TableOptions_Core.md +++ b/docs/reference/interfaces/TableOptions_Core.md @@ -26,10 +26,10 @@ Defined in: [types/TableOptions.ts:27](https://github.com/TanStack/table/blob/ma ### \_features ```ts -_features: TFeatures; +readonly _features: TFeatures; ``` -Defined in: [core/table/coreTablesFeature.types.ts:70](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L70) +Defined in: [core/table/coreTablesFeature.types.ts:71](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L71) The features that you want to enable for the table. @@ -42,10 +42,10 @@ The features that you want to enable for the table. ### \_rowModels? ```ts -optional _rowModels: CreateRowModels_All; +readonly optional _rowModels: CreateRowModels_All; ``` -Defined in: [core/table/coreTablesFeature.types.ts:74](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L74) +Defined in: [core/table/coreTablesFeature.types.ts:75](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L75) The row model options that you want to enable for the table. @@ -58,10 +58,10 @@ The row model options that you want to enable for the table. ### atoms? ```ts -optional atoms: Partial<{ [K in string | number | symbol]: Atom[K]> }>; +readonly optional atoms: Partial<{ [K in string | number | symbol]: Atom[K]> }>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:82](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L82) +Defined in: [core/table/coreTablesFeature.types.ts:83](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L83) Optionally, provide your own external writable atoms for individual state slices. When an atom is provided for a given slice, it takes precedence over `options.state[key]` @@ -78,10 +78,10 @@ mirroring changes back to their external atom via the corresponding `onXChange` ### autoResetAll? ```ts -optional autoResetAll: boolean; +readonly optional autoResetAll: boolean; ``` -Defined in: [core/table/coreTablesFeature.types.ts:86](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L86) +Defined in: [core/table/coreTablesFeature.types.ts:87](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L87) Set this option to override any of the `autoReset...` feature options. @@ -110,10 +110,10 @@ The array of column defs to use for the table. ### data ```ts -data: readonly TData[]; +readonly data: readonly TData[]; ``` -Defined in: [core/table/coreTablesFeature.types.ts:90](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L90) +Defined in: [core/table/coreTablesFeature.types.ts:91](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L91) The data for the table to display. When the `data` option changes reference, the table will reprocess the data. @@ -218,10 +218,10 @@ getSubRows: row => row.subRows ### initialState? ```ts -optional initialState: Partial>; +readonly optional initialState: Partial>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:95](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L95) +Defined in: [core/table/coreTablesFeature.types.ts:96](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L96) Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state. Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable. @@ -235,10 +235,10 @@ Table state will not be reset when this object changes, which also means that th ### mergeOptions()? ```ts -optional mergeOptions: (defaultOptions, options) => TableOptions; +readonly optional mergeOptions: (defaultOptions, options) => TableOptions; ``` -Defined in: [core/table/coreTablesFeature.types.ts:99](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L99) +Defined in: [core/table/coreTablesFeature.types.ts:100](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L100) This option is used to optionally implement the merging of table options. @@ -265,10 +265,10 @@ This option is used to optionally implement the merging of table options. ### meta? ```ts -optional meta: TableMeta; +readonly optional meta: TableMeta; ``` -Defined in: [core/table/coreTablesFeature.types.ts:106](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L106) +Defined in: [core/table/coreTablesFeature.types.ts:107](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L107) You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`. @@ -297,10 +297,10 @@ Value used when the desired value is not found in the data. ### state? ```ts -optional state: Partial>; +readonly optional state: Partial>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:110](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L110) +Defined in: [core/table/coreTablesFeature.types.ts:111](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L111) Pass in individual self-managed state to the table. diff --git a/docs/reference/interfaces/TableOptions_Table.md b/docs/reference/interfaces/TableOptions_Table.md index 1a3d8c2b25..0177be2231 100644 --- a/docs/reference/interfaces/TableOptions_Table.md +++ b/docs/reference/interfaces/TableOptions_Table.md @@ -5,7 +5,7 @@ title: TableOptions_Table # Interface: TableOptions\_Table\ -Defined in: [core/table/coreTablesFeature.types.ts:63](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L63) +Defined in: [core/table/coreTablesFeature.types.ts:64](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L64) ## Extended by @@ -26,10 +26,10 @@ Defined in: [core/table/coreTablesFeature.types.ts:63](https://github.com/TanSta ### \_features ```ts -_features: TFeatures; +readonly _features: TFeatures; ``` -Defined in: [core/table/coreTablesFeature.types.ts:70](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L70) +Defined in: [core/table/coreTablesFeature.types.ts:71](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L71) The features that you want to enable for the table. @@ -38,10 +38,10 @@ The features that you want to enable for the table. ### \_rowModels? ```ts -optional _rowModels: CreateRowModels_All; +readonly optional _rowModels: CreateRowModels_All; ``` -Defined in: [core/table/coreTablesFeature.types.ts:74](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L74) +Defined in: [core/table/coreTablesFeature.types.ts:75](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L75) The row model options that you want to enable for the table. @@ -50,10 +50,10 @@ The row model options that you want to enable for the table. ### atoms? ```ts -optional atoms: Partial<{ [K in string | number | symbol]: Atom[K]> }>; +readonly optional atoms: Partial<{ [K in string | number | symbol]: Atom[K]> }>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:82](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L82) +Defined in: [core/table/coreTablesFeature.types.ts:83](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L83) Optionally, provide your own external writable atoms for individual state slices. When an atom is provided for a given slice, it takes precedence over `options.state[key]` @@ -66,10 +66,10 @@ mirroring changes back to their external atom via the corresponding `onXChange` ### autoResetAll? ```ts -optional autoResetAll: boolean; +readonly optional autoResetAll: boolean; ``` -Defined in: [core/table/coreTablesFeature.types.ts:86](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L86) +Defined in: [core/table/coreTablesFeature.types.ts:87](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L87) Set this option to override any of the `autoReset...` feature options. @@ -78,10 +78,10 @@ Set this option to override any of the `autoReset...` feature options. ### data ```ts -data: readonly TData[]; +readonly data: readonly TData[]; ``` -Defined in: [core/table/coreTablesFeature.types.ts:90](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L90) +Defined in: [core/table/coreTablesFeature.types.ts:91](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L91) The data for the table to display. When the `data` option changes reference, the table will reprocess the data. @@ -90,10 +90,10 @@ The data for the table to display. When the `data` option changes reference, the ### initialState? ```ts -optional initialState: Partial>; +readonly optional initialState: Partial>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:95](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L95) +Defined in: [core/table/coreTablesFeature.types.ts:96](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L96) Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state. Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable. @@ -103,10 +103,10 @@ Table state will not be reset when this object changes, which also means that th ### mergeOptions()? ```ts -optional mergeOptions: (defaultOptions, options) => TableOptions; +readonly optional mergeOptions: (defaultOptions, options) => TableOptions; ``` -Defined in: [core/table/coreTablesFeature.types.ts:99](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L99) +Defined in: [core/table/coreTablesFeature.types.ts:100](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L100) This option is used to optionally implement the merging of table options. @@ -129,10 +129,10 @@ This option is used to optionally implement the merging of table options. ### meta? ```ts -optional meta: TableMeta; +readonly optional meta: TableMeta; ``` -Defined in: [core/table/coreTablesFeature.types.ts:106](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L106) +Defined in: [core/table/coreTablesFeature.types.ts:107](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L107) You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`. @@ -141,9 +141,9 @@ You can pass any object to `options.meta` and access it anywhere the `table` is ### state? ```ts -optional state: Partial>; +readonly optional state: Partial>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:110](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L110) +Defined in: [core/table/coreTablesFeature.types.ts:111](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L111) Pass in individual self-managed state to the table. diff --git a/docs/reference/interfaces/TableReactivityFeatureConstructors.md b/docs/reference/interfaces/TableReactivityFeatureConstructors.md deleted file mode 100644 index 619d7fd035..0000000000 --- a/docs/reference/interfaces/TableReactivityFeatureConstructors.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: TableReactivityFeatureConstructors -title: TableReactivityFeatureConstructors ---- - -# Interface: TableReactivityFeatureConstructors\ - -Defined in: [features/table-reactivity/tableReactivityFeature.ts:5](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/table-reactivity/tableReactivityFeature.ts#L5) - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) diff --git a/docs/reference/interfaces/Table_CoreProperties.md b/docs/reference/interfaces/Table_CoreProperties.md index 52320376fe..d888eb7fcd 100644 --- a/docs/reference/interfaces/Table_CoreProperties.md +++ b/docs/reference/interfaces/Table_CoreProperties.md @@ -5,7 +5,7 @@ title: Table_CoreProperties # Interface: Table\_CoreProperties\ -Defined in: [core/table/coreTablesFeature.types.ts:113](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L113) +Defined in: [core/table/coreTablesFeature.types.ts:114](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L114) ## Extended by @@ -29,7 +29,7 @@ Defined in: [core/table/coreTablesFeature.types.ts:113](https://github.com/TanSt optional _cellPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:124](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L124) +Defined in: [core/table/coreTablesFeature.types.ts:125](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L125) Prototype cache for Cell objects - shared by all cells in this table @@ -41,7 +41,7 @@ Prototype cache for Cell objects - shared by all cells in this table optional _columnPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:128](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L128) +Defined in: [core/table/coreTablesFeature.types.ts:129](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L129) Prototype cache for Column objects - shared by all columns in this table @@ -50,10 +50,10 @@ Prototype cache for Column objects - shared by all columns in this table ### \_features ```ts -_features: Partial & TFeatures; +readonly _features: Partial & TFeatures; ``` -Defined in: [core/table/coreTablesFeature.types.ts:120](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L120) +Defined in: [core/table/coreTablesFeature.types.ts:133](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L133) The features that are enabled for the table. @@ -65,19 +65,31 @@ The features that are enabled for the table. optional _headerPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:132](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L132) +Defined in: [core/table/coreTablesFeature.types.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L137) Prototype cache for Header objects - shared by all headers in this table *** +### \_reactivity + +```ts +readonly _reactivity: TableReactivityBindings; +``` + +Defined in: [core/table/coreTablesFeature.types.ts:121](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L121) + +Table reactivity bindings for interacting with TanStack Store. + +*** + ### \_rowModelFns ```ts -_rowModelFns: RowModelFns; +readonly _rowModelFns: RowModelFns; ``` -Defined in: [core/table/coreTablesFeature.types.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L136) +Defined in: [core/table/coreTablesFeature.types.ts:141](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L141) The row model processing functions that are used to process the data by features. @@ -86,10 +98,10 @@ The row model processing functions that are used to process the data by features ### \_rowModels ```ts -_rowModels: CachedRowModels; +readonly _rowModels: CachedRowModels; ``` -Defined in: [core/table/coreTablesFeature.types.ts:140](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L140) +Defined in: [core/table/coreTablesFeature.types.ts:145](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L145) The row models that are enabled for the table. @@ -101,7 +113,7 @@ The row models that are enabled for the table. optional _rowPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:144](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L144) +Defined in: [core/table/coreTablesFeature.types.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L149) Prototype cache for Row objects - shared by all rows in this table @@ -110,7 +122,7 @@ Prototype cache for Row objects - shared by all rows in this table ### atoms ```ts -atoms: Atoms; +readonly atoms: Atoms; ``` Defined in: [core/table/coreTablesFeature.types.ts:155](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L155) @@ -124,10 +136,10 @@ external state value (precedence: external atom > external state > base atom). ### baseAtoms ```ts -baseAtoms: BaseAtoms; +readonly baseAtoms: BaseAtoms; ``` -Defined in: [core/table/coreTablesFeature.types.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L149) +Defined in: [core/table/coreTablesFeature.types.ts:160](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L160) The internal writable atoms for each `TableState` slice. This is the library's single write surface — all state mutations from features land here. @@ -137,10 +149,10 @@ single write surface — all state mutations from features land here. ### initialState ```ts -initialState: TableState; +readonly initialState: TableState; ``` -Defined in: [core/table/coreTablesFeature.types.ts:163](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L163) +Defined in: [core/table/coreTablesFeature.types.ts:164](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L164) This is the resolved initial state of the table. @@ -152,31 +164,34 @@ This is the resolved initial state of the table. readonly options: TableOptions; ``` -Defined in: [core/table/coreTablesFeature.types.ts:167](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L167) +Defined in: [core/table/coreTablesFeature.types.ts:168](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L168) A read-only reference to the table's current options. *** -### optionsStore +### optionsStore? ```ts -optionsStore: Store>; +readonly optional optionsStore: Atom>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:159](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L159) +Defined in: [core/table/coreTablesFeature.types.ts:175](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L175) -The base store for the table options. +Writable atom for table options. Only created when `createOptionsStore` is true +on `coreReativityFeature` (e.g. Lit, Vue, Solid). React/Preact use `createOptionsStore: false`: +options are held as plain data with a lightweight revision + subscribe source; there is +no writable atom backing the full options object. Use getTableOptionsStore to subscribe. *** ### store ```ts -store: ReadonlyStore>; +readonly store: ReadonlyStore>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:172](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L172) +Defined in: [core/table/coreTablesFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L180) The readonly flat store for the table state. Derives from `table.atoms` only; never reads external state directly. diff --git a/docs/reference/interfaces/Table_Table.md b/docs/reference/interfaces/Table_Table.md index 3463b4aad6..91361b5bbb 100644 --- a/docs/reference/interfaces/Table_Table.md +++ b/docs/reference/interfaces/Table_Table.md @@ -5,7 +5,7 @@ title: Table_Table # Interface: Table\_Table\ -Defined in: [core/table/coreTablesFeature.types.ts:175](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L175) +Defined in: [core/table/coreTablesFeature.types.ts:183](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L183) ## Extends @@ -29,7 +29,7 @@ Defined in: [core/table/coreTablesFeature.types.ts:175](https://github.com/TanSt optional _cellPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:124](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L124) +Defined in: [core/table/coreTablesFeature.types.ts:125](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L125) Prototype cache for Cell objects - shared by all cells in this table @@ -45,7 +45,7 @@ Prototype cache for Cell objects - shared by all cells in this table optional _columnPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:128](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L128) +Defined in: [core/table/coreTablesFeature.types.ts:129](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L129) Prototype cache for Column objects - shared by all columns in this table @@ -58,10 +58,10 @@ Prototype cache for Column objects - shared by all columns in this table ### \_features ```ts -_features: Partial & TFeatures; +readonly _features: Partial & TFeatures; ``` -Defined in: [core/table/coreTablesFeature.types.ts:120](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L120) +Defined in: [core/table/coreTablesFeature.types.ts:133](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L133) The features that are enabled for the table. @@ -77,7 +77,7 @@ The features that are enabled for the table. optional _headerPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:132](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L132) +Defined in: [core/table/coreTablesFeature.types.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L137) Prototype cache for Header objects - shared by all headers in this table @@ -87,13 +87,29 @@ Prototype cache for Header objects - shared by all headers in this table *** +### \_reactivity + +```ts +readonly _reactivity: TableReactivityBindings; +``` + +Defined in: [core/table/coreTablesFeature.types.ts:121](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L121) + +Table reactivity bindings for interacting with TanStack Store. + +#### Inherited from + +[`Table_CoreProperties`](Table_CoreProperties.md).[`_reactivity`](Table_CoreProperties.md#_reactivity) + +*** + ### \_rowModelFns ```ts -_rowModelFns: RowModelFns; +readonly _rowModelFns: RowModelFns; ``` -Defined in: [core/table/coreTablesFeature.types.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L136) +Defined in: [core/table/coreTablesFeature.types.ts:141](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L141) The row model processing functions that are used to process the data by features. @@ -106,10 +122,10 @@ The row model processing functions that are used to process the data by features ### \_rowModels ```ts -_rowModels: CachedRowModels; +readonly _rowModels: CachedRowModels; ``` -Defined in: [core/table/coreTablesFeature.types.ts:140](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L140) +Defined in: [core/table/coreTablesFeature.types.ts:145](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L145) The row models that are enabled for the table. @@ -125,7 +141,7 @@ The row models that are enabled for the table. optional _rowPrototype: object; ``` -Defined in: [core/table/coreTablesFeature.types.ts:144](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L144) +Defined in: [core/table/coreTablesFeature.types.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L149) Prototype cache for Row objects - shared by all rows in this table @@ -138,7 +154,7 @@ Prototype cache for Row objects - shared by all rows in this table ### atoms ```ts -atoms: Atoms; +readonly atoms: Atoms; ``` Defined in: [core/table/coreTablesFeature.types.ts:155](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L155) @@ -156,10 +172,10 @@ external state value (precedence: external atom > external state > base atom). ### baseAtoms ```ts -baseAtoms: BaseAtoms; +readonly baseAtoms: BaseAtoms; ``` -Defined in: [core/table/coreTablesFeature.types.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L149) +Defined in: [core/table/coreTablesFeature.types.ts:160](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L160) The internal writable atoms for each `TableState` slice. This is the library's single write surface — all state mutations from features land here. @@ -173,10 +189,10 @@ single write surface — all state mutations from features land here. ### initialState ```ts -initialState: TableState; +readonly initialState: TableState; ``` -Defined in: [core/table/coreTablesFeature.types.ts:163](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L163) +Defined in: [core/table/coreTablesFeature.types.ts:164](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L164) This is the resolved initial state of the table. @@ -192,7 +208,7 @@ This is the resolved initial state of the table. readonly options: TableOptions; ``` -Defined in: [core/table/coreTablesFeature.types.ts:167](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L167) +Defined in: [core/table/coreTablesFeature.types.ts:168](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L168) A read-only reference to the table's current options. @@ -202,15 +218,18 @@ A read-only reference to the table's current options. *** -### optionsStore +### optionsStore? ```ts -optionsStore: Store>; +readonly optional optionsStore: Atom>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:159](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L159) +Defined in: [core/table/coreTablesFeature.types.ts:175](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L175) -The base store for the table options. +Writable atom for table options. Only created when `createOptionsStore` is true +on `coreReativityFeature` (e.g. Lit, Vue, Solid). React/Preact use `createOptionsStore: false`: +options are held as plain data with a lightweight revision + subscribe source; there is +no writable atom backing the full options object. Use getTableOptionsStore to subscribe. #### Inherited from @@ -224,7 +243,7 @@ The base store for the table options. reset: () => void; ``` -Defined in: [core/table/coreTablesFeature.types.ts:182](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L182) +Defined in: [core/table/coreTablesFeature.types.ts:190](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L190) Call this function to reset the table state to the initial state. @@ -240,7 +259,7 @@ Call this function to reset the table state to the initial state. setOptions: (newOptions) => void; ``` -Defined in: [core/table/coreTablesFeature.types.ts:186](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L186) +Defined in: [core/table/coreTablesFeature.types.ts:194](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L194) This function can be used to update the table options. @@ -259,10 +278,10 @@ This function can be used to update the table options. ### store ```ts -store: ReadonlyStore>; +readonly store: ReadonlyStore>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:172](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L172) +Defined in: [core/table/coreTablesFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L180) The readonly flat store for the table state. Derives from `table.atoms` only; never reads external state directly. diff --git a/docs/reference/type-aliases/Atoms.md b/docs/reference/type-aliases/Atoms.md index 0c1dde197e..9da5ac26dc 100644 --- a/docs/reference/type-aliases/Atoms.md +++ b/docs/reference/type-aliases/Atoms.md @@ -9,7 +9,7 @@ title: Atoms type Atoms = { [K in keyof TableState]-?: ReadonlyAtom[K]> }; ``` -Defined in: [core/table/coreTablesFeature.types.ts:30](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L30) +Defined in: [core/table/coreTablesFeature.types.ts:31](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L31) A map of readonly derived atoms, one per `TableState` slice. Each derives from its corresponding `baseAtom` plus, optionally, a per-slice external diff --git a/docs/reference/type-aliases/Atoms_All.md b/docs/reference/type-aliases/Atoms_All.md index 7cd734c98c..a37531b870 100644 --- a/docs/reference/type-aliases/Atoms_All.md +++ b/docs/reference/type-aliases/Atoms_All.md @@ -9,4 +9,4 @@ title: Atoms_All type Atoms_All = { [K in keyof TableState_All]?: ReadonlyAtom }; ``` -Defined in: [core/table/coreTablesFeature.types.ts:56](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L56) +Defined in: [core/table/coreTablesFeature.types.ts:57](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L57) diff --git a/docs/reference/type-aliases/BaseAtoms.md b/docs/reference/type-aliases/BaseAtoms.md index 2f4e8b55bd..4afcd76bf4 100644 --- a/docs/reference/type-aliases/BaseAtoms.md +++ b/docs/reference/type-aliases/BaseAtoms.md @@ -9,7 +9,7 @@ title: BaseAtoms type BaseAtoms = { [K in keyof TableState]-?: Atom[K]> }; ``` -Defined in: [core/table/coreTablesFeature.types.ts:19](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L19) +Defined in: [core/table/coreTablesFeature.types.ts:20](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L20) A map of writable atoms, one per `TableState` slice. These are the internal writable atoms that the library always writes to via `makeStateUpdater`. diff --git a/docs/reference/type-aliases/BaseAtoms_All.md b/docs/reference/type-aliases/BaseAtoms_All.md index 2adbc02d94..54deb43741 100644 --- a/docs/reference/type-aliases/BaseAtoms_All.md +++ b/docs/reference/type-aliases/BaseAtoms_All.md @@ -9,7 +9,7 @@ title: BaseAtoms_All type BaseAtoms_All = { [K in keyof TableState_All]?: Atom }; ``` -Defined in: [core/table/coreTablesFeature.types.ts:53](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L53) +Defined in: [core/table/coreTablesFeature.types.ts:54](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L54) Internal "all features" flat variants of the atom types. `Table_Internal` uses these so feature code (written generically over `TFeatures`) can access diff --git a/docs/reference/type-aliases/ExternalAtoms.md b/docs/reference/type-aliases/ExternalAtoms.md index 9cc9dce8e3..65d08a4bec 100644 --- a/docs/reference/type-aliases/ExternalAtoms.md +++ b/docs/reference/type-aliases/ExternalAtoms.md @@ -9,7 +9,7 @@ title: ExternalAtoms type ExternalAtoms = Partial<{ [K in keyof TableState]: Atom[K]> }>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:39](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L39) +Defined in: [core/table/coreTablesFeature.types.ts:40](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L40) A map of optional external atoms, one per `TableState` slice. Consumers can provide their own writable atom for any state slice to take over ownership diff --git a/docs/reference/type-aliases/ExternalAtoms_All.md b/docs/reference/type-aliases/ExternalAtoms_All.md index ce4850c510..154e3515c5 100644 --- a/docs/reference/type-aliases/ExternalAtoms_All.md +++ b/docs/reference/type-aliases/ExternalAtoms_All.md @@ -9,4 +9,4 @@ title: ExternalAtoms_All type ExternalAtoms_All = Partial<{ [K in keyof TableState_All]: Atom }>; ``` -Defined in: [core/table/coreTablesFeature.types.ts:59](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L59) +Defined in: [core/table/coreTablesFeature.types.ts:60](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table/coreTablesFeature.types.ts#L60) diff --git a/docs/reference/type-aliases/ExtractFeatureTypes.md b/docs/reference/type-aliases/ExtractFeatureTypes.md index 157333d5ba..47dc2e13ae 100644 --- a/docs/reference/type-aliases/ExtractFeatureTypes.md +++ b/docs/reference/type-aliases/ExtractFeatureTypes.md @@ -6,7 +6,7 @@ title: ExtractFeatureTypes # Type Alias: ExtractFeatureTypes\ ```ts -type ExtractFeatureTypes = UnionToIntersection<{ [K in keyof TFeatures]: TFeatures[K] extends TableFeature ? TKey extends keyof FeatureConstructorOptions ? FeatureConstructorOptions[TKey] : never : any }[keyof TFeatures]>; +type ExtractFeatureTypes = UnionToIntersection<{ [K in keyof TFeatures]: K extends "coreReativityFeature" ? never : TFeatures[K] extends TableFeature ? TKey extends keyof FeatureConstructorOptions ? FeatureConstructorOptions[TKey] : never : any }[keyof TFeatures]>; ``` Defined in: [types/TableFeatures.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L10) diff --git a/docs/reference/variables/coreFeatures.md b/docs/reference/variables/coreFeatures.md index 281500dbe2..905a40fc6d 100644 --- a/docs/reference/variables/coreFeatures.md +++ b/docs/reference/variables/coreFeatures.md @@ -9,4 +9,4 @@ title: coreFeatures const coreFeatures: CoreFeatures; ``` -Defined in: [core/coreFeatures.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L17) +Defined in: [core/coreFeatures.ts:19](https://github.com/TanStack/table/blob/main/packages/table-core/src/core/coreFeatures.ts#L19) diff --git a/examples/react/basic-external-state/src/main.tsx b/examples/react/basic-external-state/src/main.tsx index 4d0eab276a..d5ee468e57 100644 --- a/examples/react/basic-external-state/src/main.tsx +++ b/examples/react/basic-external-state/src/main.tsx @@ -69,8 +69,8 @@ function App() { pageSize: 10, }) - console.log('sorting', sorting) - console.log('pagination', pagination) + // console.log('sorting', sorting) + // console.log('pagination', pagination) // Create the table and pass state + onChange handlers const table = useTable({ diff --git a/examples/vanilla/basic/src/main.ts b/examples/vanilla/basic/src/main.ts index e98242af72..3c5164ca6e 100644 --- a/examples/vanilla/basic/src/main.ts +++ b/examples/vanilla/basic/src/main.ts @@ -5,12 +5,15 @@ import { tableFeatures, } from '@tanstack/table-core' import { FlexRender } from '@tanstack/table-core/flex-render' +import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings' import { makeData } from './makeData' import type { Person } from './makeData' let data = makeData(20) -const _features = tableFeatures({}) +const _features = tableFeatures({ + coreReativityFeature: storeReactivityBindings(), +}) const columnHelper = createColumnHelper() diff --git a/examples/vanilla/pagination/src/main.ts b/examples/vanilla/pagination/src/main.ts index a2012350dc..6c5832ad1f 100644 --- a/examples/vanilla/pagination/src/main.ts +++ b/examples/vanilla/pagination/src/main.ts @@ -8,6 +8,7 @@ import { tableFeatures, } from '@tanstack/table-core' import { FlexRender } from '@tanstack/table-core/flex-render' +import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings' import { makeData } from './makeData' import type { Person } from './makeData' import type { Table } from '@tanstack/table-core' @@ -16,6 +17,7 @@ let data = makeData(200_000) const _features = tableFeatures({ rowPaginationFeature, + coreReativityFeature: storeReactivityBindings(), }) const columnHelper = createColumnHelper() diff --git a/examples/vanilla/sorting/src/main.ts b/examples/vanilla/sorting/src/main.ts index 2b5eb71305..6319551908 100644 --- a/examples/vanilla/sorting/src/main.ts +++ b/examples/vanilla/sorting/src/main.ts @@ -8,6 +8,7 @@ import { tableFeatures, } from '@tanstack/table-core' import { FlexRender } from '@tanstack/table-core/flex-render' +import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings' import { makeData } from './makeData' import type { SortFn } from '@tanstack/table-core' import type { Person } from './makeData' @@ -16,6 +17,7 @@ let data = makeData(1_000) const _features = tableFeatures({ rowSortingFeature, + coreReativityFeature: storeReactivityBindings(), }) // Custom sorting logic for one of our enum columns diff --git a/packages/angular-table/src/injectTable.ts b/packages/angular-table/src/injectTable.ts index 4a12ee11fe..e374f4dee4 100644 --- a/packages/angular-table/src/injectTable.ts +++ b/packages/angular-table/src/injectTable.ts @@ -177,7 +177,7 @@ export function injectTable< value: computed( () => { table.store.get() - table.optionsStore.get() + table.optionsStore!.get() return table }, { equal: () => false }, diff --git a/packages/angular-table/src/reactivity.ts b/packages/angular-table/src/reactivity.ts index 71ed087f62..98566eef35 100644 --- a/packages/angular-table/src/reactivity.ts +++ b/packages/angular-table/src/reactivity.ts @@ -42,6 +42,7 @@ function signalToWritableAtom( export function angularReactivity(injector: Injector): TableReactivityBindings { return { + createOptionsStore: true, createReadonlyAtom: (fn: () => T, options?: TableAtomOptions) => { const signal = computed(() => fn(), { equal: options?.compare, diff --git a/packages/lit-table/src/TableController.ts b/packages/lit-table/src/TableController.ts index b759d572db..195afb643f 100644 --- a/packages/lit-table/src/TableController.ts +++ b/packages/lit-table/src/TableController.ts @@ -1,5 +1,5 @@ import { constructTable } from '@tanstack/table-core' -import { constructReactivityBindings } from '@tanstack/table-core/reactivity' +import { litReactivity } from './reactivity' import { FlexRender } from './flexRender' import type { Atom, ReadonlyAtom } from '@tanstack/store' import type { @@ -147,7 +147,7 @@ export class TableController< const mergedOptions: TableOptions = { ...tableOptions, _features: { - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: litReactivity(), ...tableOptions._features, }, mergeOptions: ( @@ -215,7 +215,8 @@ export class TableController< this.host.requestUpdate() }) - this._optionsSubscription = this._table.optionsStore.subscribe(() => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + this._optionsSubscription = this._table.optionsStore!.subscribe(() => { this._notifier++ this.host.requestUpdate() }) diff --git a/packages/lit-table/src/reactivity.ts b/packages/lit-table/src/reactivity.ts new file mode 100644 index 0000000000..68bfdf4ed3 --- /dev/null +++ b/packages/lit-table/src/reactivity.ts @@ -0,0 +1,23 @@ +import { batch, createAtom } from '@tanstack/store' +import type { + TableAtomOptions, + TableReactivityBindings, +} from '@tanstack/table-core/reactivity' + +export function litReactivity(): TableReactivityBindings { + return { + createOptionsStore: true, + batch, + untrack: (fn) => fn(), + createReadonlyAtom: (fn: () => T, options?: TableAtomOptions) => { + return createAtom(() => fn(), { + compare: options?.compare, + }) + }, + createWritableAtom: (value: T, options?: TableAtomOptions) => { + return createAtom(value, { + compare: options?.compare, + }) + }, + } +} diff --git a/packages/preact-table/package.json b/packages/preact-table/package.json index ef00f977c5..812513d15a 100644 --- a/packages/preact-table/package.json +++ b/packages/preact-table/package.json @@ -57,7 +57,6 @@ "build": "tsdown" }, "dependencies": { - "@preact/signals": "^2.9.0", "@tanstack/preact-store": "^0.13.0", "@tanstack/table-core": "workspace:*" }, diff --git a/packages/preact-table/src/reactivity.ts b/packages/preact-table/src/reactivity.ts index 08ac3488ea..24cf62e91a 100644 --- a/packages/preact-table/src/reactivity.ts +++ b/packages/preact-table/src/reactivity.ts @@ -1,63 +1,87 @@ -// TOTO - re-explore preact signals for reactivity -import { batch, computed, signal, untracked } from '@preact/signals' +import { batch, createAtom } from '@tanstack/preact-store' import type { TableAtomOptions, TableReactivityBindings, } from '@tanstack/table-core/reactivity' -import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store' - -function observerToCallback( - observerOrNext: Observer | ((value: T) => void), -): (value: T) => void { - return typeof observerOrNext === 'function' - ? observerOrNext - : (value) => observerOrNext.next?.(value) -} - -function signalToReadonlyAtom(source: { - value: T - subscribe: (observer: (value: T) => void) => () => void -}): ReadonlyAtom { - return Object.assign(source, { - get: () => source.value, - subscribe: ((observerOrNext: Observer | ((value: T) => void)) => { - const unsubscribe = source.subscribe(observerToCallback(observerOrNext)) - return { unsubscribe } - }) as ReadonlyAtom['subscribe'], - }) -} - -function signalToWritableAtom(source: { - value: T - subscribe: (observer: (value: T) => void) => () => void -}): Atom { - return Object.assign(source, { - set: (updater: T | ((prevVal: T) => T)) => { - source.value = - typeof updater === 'function' - ? (updater as (prevVal: T) => T)(source.value) - : updater - }, - get: () => source.value, - subscribe: ((observerOrNext: Observer | ((value: T) => void)) => { - const unsubscribe = source.subscribe(observerToCallback(observerOrNext)) - return { unsubscribe } - }) as Atom['subscribe'], - }) -} export function preactReactivity(): TableReactivityBindings { return { - createReadonlyAtom: (fn: () => T, _options?: TableAtomOptions) => { - return signalToReadonlyAtom(computed(fn)) + createOptionsStore: false, + batch, + untrack: (fn) => fn(), + createReadonlyAtom: (fn: () => T, options?: TableAtomOptions) => { + return createAtom(() => fn(), { + compare: options?.compare, + }) }, - createWritableAtom: ( - value: T, - _options?: TableAtomOptions, - ): Atom => { - return signalToWritableAtom(signal(value)) + createWritableAtom: (value: T, options?: TableAtomOptions) => { + return createAtom(value, { + compare: options?.compare, + }) }, - untrack: untracked, - batch: batch, } } + +// // TOTO - re-explore preact signals for reactivity +// import { batch, computed, signal, untracked } from '@preact/signals' +// import type { +// TableAtomOptions, +// TableReactivityBindings, +// } from '@tanstack/table-core/reactivity' +// import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store' + +// function observerToCallback( +// observerOrNext: Observer | ((value: T) => void), +// ): (value: T) => void { +// return typeof observerOrNext === 'function' +// ? observerOrNext +// : (value) => observerOrNext.next?.(value) +// } + +// function signalToReadonlyAtom(source: { +// value: T +// subscribe: (observer: (value: T) => void) => () => void +// }): ReadonlyAtom { +// return Object.assign(source, { +// get: () => source.value, +// subscribe: ((observerOrNext: Observer | ((value: T) => void)) => { +// const unsubscribe = source.subscribe(observerToCallback(observerOrNext)) +// return { unsubscribe } +// }) as ReadonlyAtom['subscribe'], +// }) +// } + +// function signalToWritableAtom(source: { +// value: T +// subscribe: (observer: (value: T) => void) => () => void +// }): Atom { +// return Object.assign(source, { +// set: (updater: T | ((prevVal: T) => T)) => { +// source.value = +// typeof updater === 'function' +// ? (updater as (prevVal: T) => T)(source.value) +// : updater +// }, +// get: () => source.value, +// subscribe: ((observerOrNext: Observer | ((value: T) => void)) => { +// const unsubscribe = source.subscribe(observerToCallback(observerOrNext)) +// return { unsubscribe } +// }) as Atom['subscribe'], +// }) +// } + +// export function preactReactivity(): TableReactivityBindings { +// return { +// createReadonlyAtom: (fn: () => T, _options?: TableAtomOptions) => { +// return signalToReadonlyAtom(computed(fn)) +// }, +// createWritableAtom: ( +// value: T, +// _options?: TableAtomOptions, +// ): Atom => { +// return signalToWritableAtom(signal(value)) +// }, +// untrack: untracked, +// batch: batch, +// } +// } diff --git a/packages/preact-table/src/useTable.ts b/packages/preact-table/src/useTable.ts index 977d7a7431..5c213052d6 100644 --- a/packages/preact-table/src/useTable.ts +++ b/packages/preact-table/src/useTable.ts @@ -1,10 +1,9 @@ -import { useEffect, useMemo, useState } from 'preact/hooks' +import { useMemo, useState } from 'preact/hooks' import { constructTable } from '@tanstack/table-core' import { shallow, useSelector } from '@tanstack/preact-store' -import { constructReactivityBindings } from '@tanstack/table-core/reactivity' +import { preactReactivity } from './reactivity' import { FlexRender } from './FlexRender' import { Subscribe } from './Subscribe' -// import { preactReactivity } from './reactivity' import type { CellData, RowData, @@ -78,10 +77,7 @@ export type PreactTable< /** * 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 `useTable`. */ - readonly state: Readonly & { - columns: TableOptions['columns'] - data: TableOptions['data'] - } + readonly state: Readonly } export function useTable< @@ -97,7 +93,7 @@ export function useTable< const tableInstance = constructTable({ ...tableOptions, _features: { - coreReativityFeature: constructReactivityBindings(), // preactReactivity() currently causes infinite re-renders + coreReativityFeature: preactReactivity(), ...tableOptions._features, }, }) as PreactTable @@ -114,24 +110,20 @@ export function useTable< return tableInstance }) - useEffect(() => { - table.setOptions((prev) => ({ - ...prev, - ...tableOptions, - })) - }, [table, tableOptions]) + // sync options on every render + table.setOptions((prev) => ({ + ...prev, + ...tableOptions, + })) const state = useSelector(table.store, selector, { compare: shallow }) - const options = useSelector(table.optionsStore, (options) => options, { - compare: shallow, - }) return useMemo( () => ({ ...table, - options, + options: tableOptions, state, }), - [table, options, state], - ) as PreactTable + [table, tableOptions, state], + ) } diff --git a/packages/preact-table/tests/unit/signals.test.ts b/packages/preact-table/tests/unit/signals.test.ts index 6706b4b07c..d7f1cb7022 100644 --- a/packages/preact-table/tests/unit/signals.test.ts +++ b/packages/preact-table/tests/unit/signals.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest' import { preactReactivity } from '../../src/reactivity' describe('preactReactivity', () => { - test('creates writable and readonly atoms from Preact signals', () => { + test('creates writable and readonly atoms from TanStack Store', () => { const reactivity = preactReactivity() const count = reactivity.createWritableAtom(1, { debugName: 'count' }) const doubled = reactivity.createReadonlyAtom(() => count.get() * 2, { diff --git a/packages/react-table/src/reactivity.ts b/packages/react-table/src/reactivity.ts new file mode 100644 index 0000000000..1336c42fc4 --- /dev/null +++ b/packages/react-table/src/reactivity.ts @@ -0,0 +1,23 @@ +import { batch, createAtom } from '@tanstack/react-store' +import type { + TableAtomOptions, + TableReactivityBindings, +} from '@tanstack/table-core/reactivity' + +export function reactReactivity(): TableReactivityBindings { + return { + createOptionsStore: false, + batch, + untrack: (fn) => fn(), + createReadonlyAtom: (fn: () => T, options?: TableAtomOptions) => { + return createAtom(() => fn(), { + compare: options?.compare, + }) + }, + createWritableAtom: (value: T, options?: TableAtomOptions) => { + return createAtom(value, { + compare: options?.compare, + }) + }, + } +} diff --git a/packages/react-table/src/useTable.ts b/packages/react-table/src/useTable.ts index aea2b679a7..e1bd8f0076 100644 --- a/packages/react-table/src/useTable.ts +++ b/packages/react-table/src/useTable.ts @@ -1,9 +1,9 @@ 'use client' -import { useEffect, useMemo, useState } from 'react' +import { useMemo, useState } from 'react' import { constructTable } from '@tanstack/table-core' import { shallow, useSelector } from '@tanstack/react-store' -import { constructReactivityBindings } from '@tanstack/table-core/reactivity' +import { reactReactivity } from './reactivity' import { FlexRender } from './FlexRender' import { Subscribe } from './Subscribe' import type { Atom, ReadonlyAtom } from '@tanstack/react-store' @@ -106,10 +106,7 @@ export type ReactTable< * * console.log(table.state.globalFilter) */ - readonly state: Readonly & { - columns: TableOptions['columns'] - data: TableOptions['data'] - } + readonly state: Readonly } export function useTable< @@ -125,7 +122,7 @@ export function useTable< const tableInstance = constructTable({ ...tableOptions, _features: { - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: reactReactivity(), ...tableOptions._features, }, }) as ReactTable @@ -142,26 +139,22 @@ export function useTable< return tableInstance }) - useEffect(() => { - table.setOptions((prev) => ({ - ...prev, - ...tableOptions, - })) - }, [table, tableOptions]) + // sync options on every render + table.setOptions((prev) => ({ + ...prev, + ...tableOptions, + })) const state = useSelector(table.store, selector, { compare: shallow }) - const options = useSelector(table.optionsStore, (options) => options, { - compare: shallow, - }) // we know this is not the most efficient way to return the table, // but it is required for the react compiler to work return useMemo( () => ({ ...table, - options, + options: tableOptions, state, }), - [table, options, state], - ) as ReactTable + [table, tableOptions, state], + ) } diff --git a/packages/solid-table/src/reactivity.ts b/packages/solid-table/src/reactivity.ts index 1b3cb44366..13007c1ee7 100644 --- a/packages/solid-table/src/reactivity.ts +++ b/packages/solid-table/src/reactivity.ts @@ -45,6 +45,7 @@ function signalToWritableAtom( export function solidReactivity(owner: Owner): TableReactivityBindings { return { + createOptionsStore: true, createReadonlyAtom: (fn: () => T, options?: TableAtomOptions) => { const signal = createMemo(() => fn(), { equals: options?.compare, diff --git a/packages/svelte-table/src/reactivity.svelte.ts b/packages/svelte-table/src/reactivity.svelte.ts index 0238b914c2..53192360b3 100644 --- a/packages/svelte-table/src/reactivity.svelte.ts +++ b/packages/svelte-table/src/reactivity.svelte.ts @@ -20,7 +20,8 @@ function subscribeToRune( const callback = observerToCallback(observerOrNext) const unsubscribe = $effect.root(() => { $effect(() => { - callback(getValue()) + const value = getValue() + untrack(() => callback(value)) }) }) @@ -29,6 +30,7 @@ function subscribeToRune( export function svelteReactivity(): TableReactivityBindings { return { + createOptionsStore: true, createReadonlyAtom: (fn: () => T, _options?: TableAtomOptions) => { const value = $derived.by(fn) diff --git a/packages/table-core/package.json b/packages/table-core/package.json index 81c6cea5f3..51ad0aaeeb 100644 --- a/packages/table-core/package.json +++ b/packages/table-core/package.json @@ -46,6 +46,10 @@ "import": "./dist/static-functions.js", "require": "./dist/static-functions.cjs" }, + "./store-reactivity-bindings": { + "import": "./dist/store-reactivity-bindings.js", + "require": "./dist/store-reactivity-bindings.cjs" + }, "./package.json": "./package.json" }, "sideEffects": false, diff --git a/packages/table-core/src/core/reactivity/constructReactivityBindings.ts b/packages/table-core/src/core/reactivity/constructReactivityBindings.ts deleted file mode 100644 index 2c94853904..0000000000 --- a/packages/table-core/src/core/reactivity/constructReactivityBindings.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { batch, createAtom } from '@tanstack/store' -import type { TableReactivityBindings } from './coreReactivityFeature.types' - -export function constructReactivityBindings(): TableReactivityBindings { - return { - batch: batch, - untrack: (fn) => fn(), - createReadonlyAtom: (fn, options) => { - return createAtom(() => fn(), { - compare: options?.compare, - }) - }, - createWritableAtom: (value, options) => { - return createAtom(value, { - compare: options?.compare, - }) - }, - } -} diff --git a/packages/table-core/src/core/reactivity/coreReactivityFeature.types.ts b/packages/table-core/src/core/reactivity/coreReactivityFeature.types.ts index 8e323c1c4c..f59d3be92a 100644 --- a/packages/table-core/src/core/reactivity/coreReactivityFeature.types.ts +++ b/packages/table-core/src/core/reactivity/coreReactivityFeature.types.ts @@ -15,6 +15,7 @@ export interface TableAtomOptions extends AtomOptions { * scheduling primitives. */ export interface TableReactivityBindings { + createOptionsStore: boolean /** * Creates a writable atom with an initial value. */ diff --git a/packages/table-core/src/core/table/constructTable.ts b/packages/table-core/src/core/table/constructTable.ts index be14a21389..b2b48503f1 100644 --- a/packages/table-core/src/core/table/constructTable.ts +++ b/packages/table-core/src/core/table/constructTable.ts @@ -1,6 +1,7 @@ import { coreFeatures } from '../coreFeatures' import { cloneState } from '../../utils' import { atomToStore } from '../reactivity/coreReactivityFeature.utils' +import { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils' import type { RowData } from '../../types/type-utils' import type { TableFeature, TableFeatures } from '../../types/TableFeatures' import type { Table, Table_Internal } from '../../types/Table' @@ -28,12 +29,6 @@ export function constructTable< _features: { ...coreFeatures, ...tableOptions._features }, _rowModels: {}, _rowModelFns: {}, - get options() { - return this.optionsStore.get() - }, - set options(value) { - this.optionsStore.set(() => value) - }, baseAtoms: {}, atoms: {}, } as Table_Internal @@ -44,10 +39,26 @@ export function constructTable< return Object.assign(obj, feature.getDefaultTableOptions?.(table)) }, {}) as TableOptions - // @ts-ignore - direct set - table.optionsStore = _reactivity.createWritableAtom< - TableOptions - >({ ...defaultOptions, ...tableOptions }, { debugName: 'table/optionsStore' }) + const mergedOptions = { ...defaultOptions, ...tableOptions } + + if (_reactivity.createOptionsStore) { + // @ts-ignore - direct set + table.optionsStore = _reactivity.createWritableAtom< + TableOptions + >(mergedOptions, { debugName: 'table/optionsStore' }) + Object.defineProperty(table, 'options', { + configurable: true, + enumerable: true, + get() { + return table.optionsStore!.get() + }, + set(value) { + table.optionsStore!.set(() => value) // or your real update shape + }, + }) + } else { + table.options = mergedOptions + } table.initialState = getInitialTableState( table._features, @@ -67,16 +78,10 @@ export function constructTable< }, ) as any - // create readonly derived atom: on each get(), read current options (state, then external atom, then base) + // create readonly derived atom: on each get(), read either external atom or base atom ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom( () => { - // Reading optionsStore.get() keeps this reactive to setOptions - const opts = table.optionsStore.get() - const state = opts.state - if (key in (state ?? {})) { - return state![key] - } - const externalAtom = opts.atoms?.[key] + const externalAtom = table.options.atoms?.[key] if (externalAtom) { return externalAtom.get() } @@ -86,6 +91,8 @@ export function constructTable< ) } + table_syncExternalStateToBaseAtoms(table) + table.store = atomToStore( _reactivity.createReadonlyAtom( () => { @@ -114,7 +121,8 @@ export function constructTable< Row Models: ${rowModels.length ? rowModels.join('\n ') : '(none)'} - States: ${states.join('\n ')}`, + States: ${states.join('\n ')}\n`, + { table }, ) } diff --git a/packages/table-core/src/core/table/coreTablesFeature.types.ts b/packages/table-core/src/core/table/coreTablesFeature.types.ts index 5e0bcab3e3..00666f743f 100644 --- a/packages/table-core/src/core/table/coreTablesFeature.types.ts +++ b/packages/table-core/src/core/table/coreTablesFeature.types.ts @@ -167,9 +167,12 @@ export interface Table_CoreProperties< */ readonly options: TableOptions /** - * The base store for the table options. + * Writable atom for table options. Only created when `createOptionsStore` is true + * on `coreReativityFeature` (e.g. Lit, Vue, Solid). React/Preact use `createOptionsStore: false`: + * options are held as plain data with a lightweight revision + subscribe source; there is + * no writable atom backing the full options object. Use {@link getTableOptionsStore} to subscribe. */ - readonly optionsStore: Atom> + readonly optionsStore?: Atom> | undefined /** * The readonly flat store for the table state. Derives from `table.atoms` * only; never reads external state directly. diff --git a/packages/table-core/src/core/table/coreTablesFeature.utils.ts b/packages/table-core/src/core/table/coreTablesFeature.utils.ts index 01872f17ed..cc3bd126f0 100644 --- a/packages/table-core/src/core/table/coreTablesFeature.utils.ts +++ b/packages/table-core/src/core/table/coreTablesFeature.utils.ts @@ -4,6 +4,30 @@ import type { TableFeatures } from '../../types/TableFeatures' import type { Table_Internal } from '../../types/Table' import type { TableOptions } from '../../types/TableOptions' +export function table_syncExternalStateToBaseAtoms< + TFeatures extends TableFeatures, + TData extends RowData, +>(table: Table_Internal): void { + const state = table.options.state + if (!state) { + return + } + + table._reactivity.batch(() => { + for (const key in state) { + const baseAtom = (table.baseAtoms as Record)[key] + if (!baseAtom) { + continue + } + + const externalState = state[key as keyof typeof state] + if (externalState !== baseAtom.get()) { + baseAtom.set(() => externalState) + } + } + }) +} + export function table_reset< TFeatures extends TableFeatures, TData extends RowData, @@ -42,5 +66,10 @@ export function table_setOptions< ): void { const newOptions = functionalUpdate(updater, table.options) const mergedOptions = table_mergeOptions(table, newOptions) - table.optionsStore.set(() => mergedOptions) + if (table.optionsStore) { + table.optionsStore.set(() => mergedOptions) + } else { + table.options = mergedOptions + } + table_syncExternalStateToBaseAtoms(table) } diff --git a/packages/table-core/src/reactivity.ts b/packages/table-core/src/reactivity.ts index 86ad4e0347..83329678f6 100644 --- a/packages/table-core/src/reactivity.ts +++ b/packages/table-core/src/reactivity.ts @@ -1,3 +1,2 @@ export * from './core/reactivity/coreReactivityFeature.types' -export * from './core/reactivity/constructReactivityBindings' export * from './core/reactivity/coreReactivityFeature.utils' diff --git a/packages/table-core/src/store-reactivity-bindings.ts b/packages/table-core/src/store-reactivity-bindings.ts new file mode 100644 index 0000000000..197342eaae --- /dev/null +++ b/packages/table-core/src/store-reactivity-bindings.ts @@ -0,0 +1,35 @@ +import { batch, createAtom } from '@tanstack/store' +import type { TableReactivityBindings } from './core/reactivity/coreReactivityFeature.types' + +/** + * TanStack Store–based reactivity for vanilla / non-framework use of `constructTable`, + * with `createOptionsStore: true` so `table.optionsStore` is available for subscriptions. + * + * @example + * ```ts + * import { constructTable, tableFeatures } from '@tanstack/table-core' + * import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings' + * + * const table = constructTable({ + * _features: tableFeatures({ coreReativityFeature: storeReactivityBindings() }), + * // ... + * }) + * ``` + */ +export function storeReactivityBindings(): TableReactivityBindings { + return { + createOptionsStore: true, + batch, + untrack: (fn) => fn(), + createReadonlyAtom: (fn, options) => { + return createAtom(() => fn(), { + compare: options?.compare, + }) + }, + createWritableAtom: (value, options) => { + return createAtom(value, { + compare: options?.compare, + }) + }, + } +} diff --git a/packages/table-core/src/types/Table.ts b/packages/table-core/src/types/Table.ts index e2be6d1d29..6c27d25a17 100644 --- a/packages/table-core/src/types/Table.ts +++ b/packages/table-core/src/types/Table.ts @@ -1,4 +1,4 @@ -import type { ReadonlyAtom, ReadonlyStore } from '@tanstack/store' +import type { ReadonlyStore } from '@tanstack/store' import type { Table_ColumnFaceting } from '../features/column-faceting/columnFacetingFeature.types' import type { Table_ColumnResizing } from '../features/column-resizing/columnResizingFeature.types' import type { Table_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' diff --git a/packages/table-core/tests/helpers/generateTestTable.ts b/packages/table-core/tests/helpers/generateTestTable.ts index 3f47ee2141..937eb5bc4e 100644 --- a/packages/table-core/tests/helpers/generateTestTable.ts +++ b/packages/table-core/tests/helpers/generateTestTable.ts @@ -1,7 +1,7 @@ import { constructTable, coreFeatures } from '../../src' import { generateTestColumnDefs } from '../fixtures/data/generateTestColumnDefs' import { generateTestData } from '../fixtures/data/generateTestData' -import { constructReactivityBindings } from '../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../src/store-reactivity-bindings' import type { Row, Table, @@ -32,7 +32,7 @@ export function generateTestTableWithData( _features: { ...coreFeatures, ...options?._features, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, } as any) } @@ -49,7 +49,7 @@ export function generateTestTableFromData( _features: { ...coreFeatures, ...options?._features, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, } as any) } diff --git a/packages/table-core/tests/helpers/rowPinningHelpers.ts b/packages/table-core/tests/helpers/rowPinningHelpers.ts index 8537623555..e0656a77a9 100644 --- a/packages/table-core/tests/helpers/rowPinningHelpers.ts +++ b/packages/table-core/tests/helpers/rowPinningHelpers.ts @@ -7,7 +7,7 @@ import { rowPinningFeature, } from '../../src' import { generateTestData } from '../fixtures/data/generateTestData' -import { constructReactivityBindings } from '../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../src/store-reactivity-bindings' import { generateTestTableWithData } from './generateTestTable' import type { ColumnDef, RowPinningState, TableOptions } from '../../src' import type { Person } from '../fixtures/data/types' @@ -16,7 +16,7 @@ import type { Person } from '../fixtures/data/types' const _features = { ...coreFeatures, rowPinningFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), } as any type personKeys = keyof Person diff --git a/packages/table-core/tests/implementation/features/row-pinning/rowPinningFeature.test.ts b/packages/table-core/tests/implementation/features/row-pinning/rowPinningFeature.test.ts index c5e4570e71..cda2ac5b91 100644 --- a/packages/table-core/tests/implementation/features/row-pinning/rowPinningFeature.test.ts +++ b/packages/table-core/tests/implementation/features/row-pinning/rowPinningFeature.test.ts @@ -12,7 +12,7 @@ import { createTableWithMockOnPinningChange, } from '../../../helpers/rowPinningHelpers' import { generateTestData } from '../../../fixtures/data/generateTestData' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' import type { ColumnDef, Row } from '../../../../src' import type { Person } from '../../../fixtures/data/types' @@ -20,7 +20,7 @@ import type { Person } from '../../../fixtures/data/types' const _features = { ...coreFeatures, rowPinningFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), } type personKeys = keyof Person @@ -171,7 +171,7 @@ describe('table methods', () => { ...coreFeatures, rowPinningFeature, rowPaginationFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), } const table = constructTable({ @@ -211,7 +211,7 @@ describe('table methods', () => { ...coreFeatures, rowPinningFeature, rowPaginationFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), } const table = constructTable({ diff --git a/packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts b/packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts index e5d661d2d3..b69114f45c 100644 --- a/packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts +++ b/packages/table-core/tests/implementation/features/row-selection/rowSelectionFeature.test.ts @@ -7,7 +7,7 @@ import { } from '../../../../src' import * as RowSelectionUtils from '../../../../src/features/row-selection/rowSelectionFeature.utils' import { generateTestData } from '../../../fixtures/data/generateTestData' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' import type { Person } from '../../../fixtures/data/types' import type { ColumnDef, Row } from '../../../../src' @@ -16,7 +16,7 @@ import type { ColumnDef, Row } from '../../../../src' const _features = { ...coreFeatures, rowSelectionFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), } type personKeys = keyof Person diff --git a/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts b/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts index 89525337d3..954c064eb8 100644 --- a/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts +++ b/packages/table-core/tests/performance/features/column-grouping/columnGroupingFeature.test.ts @@ -8,7 +8,7 @@ import { } from '../../../../src' import { createColumnHelper } from '../../../../src/helpers/columnHelper' import { generateTestData } from '../../../fixtures/data/generateTestData' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' import type { Person } from '../../../fixtures/data/types' import type { ColumnDef } from '../../../../src' @@ -46,7 +46,7 @@ describe('#getGroupedRowModel', () => { _features: { columnGroupingFeature, ...coreFeatures, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, _rowModels: { groupedRowModel: createGroupedRowModel(aggregationFns), diff --git a/packages/table-core/tests/unit/core/columns/constructColumn.test.ts b/packages/table-core/tests/unit/core/columns/constructColumn.test.ts index cab80dec67..13ade2c73f 100644 --- a/packages/table-core/tests/unit/core/columns/constructColumn.test.ts +++ b/packages/table-core/tests/unit/core/columns/constructColumn.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest' import { coreColumnsFeature } from '../../../../src/core/columns/coreColumnsFeature' import { constructColumn } from '../../../../src/core/columns/constructColumn' import { constructTable } from '../../../../src' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' import type { ColumnDef } from '../../../../src/types/ColumnDef' describe('constructColumn', () => { @@ -10,7 +10,7 @@ describe('constructColumn', () => { const table = constructTable({ _features: { coreColumnsFeature, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, columns: [] as Array, data: [] as Array, diff --git a/packages/table-core/tests/unit/core/table/constructTable.test.ts b/packages/table-core/tests/unit/core/table/constructTable.test.ts index cf9a489d95..3eb1b3bad1 100644 --- a/packages/table-core/tests/unit/core/table/constructTable.test.ts +++ b/packages/table-core/tests/unit/core/table/constructTable.test.ts @@ -1,13 +1,13 @@ import { describe, expect, it } from 'vitest' import { constructTable, coreFeatures } from '../../../../src' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' describe('constructTable', () => { it('should create a table with all core table APIs and properties', () => { const table = constructTable({ _features: { ...coreFeatures, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, columns: [], data: [], diff --git a/packages/table-core/tests/unit/core/table/stockFeaturesInitialState.test.ts b/packages/table-core/tests/unit/core/table/stockFeaturesInitialState.test.ts index e14704da3e..3ed2418890 100644 --- a/packages/table-core/tests/unit/core/table/stockFeaturesInitialState.test.ts +++ b/packages/table-core/tests/unit/core/table/stockFeaturesInitialState.test.ts @@ -1,13 +1,13 @@ import { describe, expect, it } from 'vitest' import { constructTable, stockFeatures } from '../../../../src' -import { constructReactivityBindings } from '../../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../../src/store-reactivity-bindings' describe('constructTable with stockFeatures', () => { it('should include all feature states in initial state', () => { const table = constructTable({ _features: { ...stockFeatures, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, columns: [], data: [], diff --git a/packages/table-core/tests/unit/core/tableAtoms.test.ts b/packages/table-core/tests/unit/core/tableAtoms.test.ts index b10ba9f200..b22d6bee61 100644 --- a/packages/table-core/tests/unit/core/tableAtoms.test.ts +++ b/packages/table-core/tests/unit/core/tableAtoms.test.ts @@ -7,7 +7,7 @@ import { rowSelectionFeature, rowSortingFeature, } from '../../../src' -import { constructReactivityBindings } from '../../../src/core/reactivity/constructReactivityBindings' +import { storeReactivityBindings } from '../../../src/store-reactivity-bindings' import type { PaginationState, SortingState, @@ -25,7 +25,7 @@ function makeTable(options: any = {}) { _features: { ...coreFeatures, ..._features, - coreReativityFeature: constructReactivityBindings(), + coreReativityFeature: storeReactivityBindings(), }, _rowModels: {}, columns: [], @@ -61,17 +61,15 @@ describe('three-layer atom architecture', () => { expect(table.atoms.sorting.get()).toEqual([{ id: 'age', desc: true }]) }) - it('options.state[key] takes precedence over baseAtoms', () => { + it('options.state[key] syncs into baseAtoms', () => { const external: SortingState = [{ id: 'external', desc: false }] const table = makeTable({ state: { sorting: external } }) - // baseAtoms still holds the default - expect(table.baseAtoms.sorting.get()).toEqual([]) - // but atoms (and downstream store) see the external value + expect(table.baseAtoms.sorting.get()).toEqual(external) expect(table.atoms.sorting.get()).toEqual(external) expect(table.store.state.sorting).toEqual(external) }) - it('options.state[key] takes precedence over options.atoms[key] when the key is present', () => { + it('options.atoms[key] takes precedence over options.state[key] when both are present', () => { const externalAtom = createAtom([ { id: 'fromAtom', desc: true }, ]) @@ -79,12 +77,11 @@ describe('three-layer atom architecture', () => { state: { sorting: [{ id: 'fromState', desc: false }] }, atoms: { sorting: externalAtom }, }) - // key is in `state` → that slice wins, even if an external atom is also set expect(table.atoms.sorting.get()).toEqual([ - { id: 'fromState', desc: false }, + { id: 'fromAtom', desc: true }, ]) expect(table.store.state.sorting).toEqual([ - { id: 'fromState', desc: false }, + { id: 'fromAtom', desc: true }, ]) }) diff --git a/packages/table-core/tsdown.config.ts b/packages/table-core/tsdown.config.ts index ff0c1b884d..b51e4fcc41 100644 --- a/packages/table-core/tsdown.config.ts +++ b/packages/table-core/tsdown.config.ts @@ -6,6 +6,7 @@ export default defineConfig({ './src/static-functions.ts', './src/flex-render.ts', './src/reactivity.ts', + './src/store-reactivity-bindings.ts', ], format: ['esm', 'cjs'], unbundle: true, diff --git a/packages/table-devtools/package.json b/packages/table-devtools/package.json index 145de72eab..5a507255c3 100644 --- a/packages/table-devtools/package.json +++ b/packages/table-devtools/package.json @@ -56,6 +56,7 @@ "@tanstack/table-core": "workspace:*" }, "devDependencies": { + "@tanstack/table-core": "workspace:*", "vite-plugin-solid": "^2.11.12" } } diff --git a/packages/table-devtools/src/components/OptionsPanel.tsx b/packages/table-devtools/src/components/OptionsPanel.tsx index a515c3049c..ab1c6165d6 100644 --- a/packages/table-devtools/src/components/OptionsPanel.tsx +++ b/packages/table-devtools/src/components/OptionsPanel.tsx @@ -1,26 +1,35 @@ import { JsonTree } from '@tanstack/devtools-ui' import { useSelector } from '@tanstack/solid-store' import { useTableDevtoolsContext } from '../TableContextProvider' +import { useTableStore } from '../useTableStore' import { useStyles } from '../styles/use-styles' import { NoTableConnected } from './NoTableConnected' import { ResizableSplit } from './ResizableSplit' +function projectOptionsForTree(full: unknown) { + const { + state: _s, + data: _d, + _features: _f, + _rowModels: _r, + ...options + } = full as Record + return options +} + export function OptionsPanel() { const styles = useStyles() const { table } = useTableDevtoolsContext() const tableInstance = table() const tableState = tableInstance - ? useSelector(tableInstance.optionsStore, (state: unknown) => { - const { - state: _s, - data: _d, - _features: _f, - _rowModels: _r, - ...options - } = state as Record - return options - }) + ? tableInstance.optionsStore + ? useSelector(tableInstance.optionsStore, (state: unknown) => + projectOptionsForTree(state), + ) + : useTableStore(tableInstance.store, () => + projectOptionsForTree(tableInstance.options as unknown), + ) : undefined if (!tableInstance) { diff --git a/packages/table-devtools/src/components/StatePanel.tsx b/packages/table-devtools/src/components/StatePanel.tsx index 5fd2bd4513..2b03b5320c 100644 --- a/packages/table-devtools/src/components/StatePanel.tsx +++ b/packages/table-devtools/src/components/StatePanel.tsx @@ -1,6 +1,6 @@ import { For, createSignal } from 'solid-js' import { JsonTree } from '@tanstack/devtools-ui' -import { batch } from '@tanstack/solid-store' +import { batch, useSelector } from '@tanstack/solid-store' import { useTableDevtoolsContext } from '../TableContextProvider' import { useTableStore } from '../useTableStore' import { useStyles } from '../styles/use-styles' @@ -29,10 +29,11 @@ export function StatePanel() { tableInstance ? tableInstance.store : undefined, (state) => state, ) - const tableOptions = useTableStore( - tableInstance ? tableInstance.optionsStore : undefined, - (opts) => opts, - ) + const tableOptions = tableInstance + ? tableInstance.optionsStore + ? useSelector(tableInstance.optionsStore, (opts) => opts) + : useTableStore(tableInstance.store, () => tableInstance.options) + : undefined if (!tableInstance) { return diff --git a/packages/vue-table/src/reactivity.ts b/packages/vue-table/src/reactivity.ts index 7c1ba3788c..f68d5bb008 100644 --- a/packages/vue-table/src/reactivity.ts +++ b/packages/vue-table/src/reactivity.ts @@ -48,6 +48,7 @@ function refToWritableAtom(source: ShallowRef): Atom { export function vueReactivity(): TableReactivityBindings { return { + createOptionsStore: true, createReadonlyAtom: (fn: () => T, _options?: TableAtomOptions) => { return refToReadonlyAtom(computed(fn)) }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce66694895..ba13750853 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7139,9 +7139,6 @@ importers: packages/preact-table: dependencies: - '@preact/signals': - specifier: ^2.9.0 - version: 2.9.0(preact@10.29.1) '@tanstack/preact-store': specifier: ^0.13.0 version: 0.13.0(preact@10.29.1) @@ -7323,9 +7320,6 @@ importers: '@tanstack/solid-store': specifier: ^0.11.0 version: 0.11.0(solid-js@1.9.12) - '@tanstack/table-core': - specifier: workspace:* - version: link:../table-core goober: specifier: ^2.1.18 version: 2.1.18(csstype@3.2.3) @@ -7333,6 +7327,9 @@ importers: specifier: ^1.9.12 version: 1.9.12 devDependencies: + '@tanstack/table-core': + specifier: workspace:* + version: link:../table-core vite-plugin-solid: specifier: ^2.11.12 version: 2.11.12(@testing-library/jest-dom@6.9.1)(solid-js@1.9.12)(vite@8.0.10(@types/node@25.6.0)(esbuild@0.28.0)(jiti@2.6.1)(less@4.6.4)(sass@1.99.0)(sugarss@5.0.1(postcss@8.5.13))(terser@5.46.0)(yaml@2.8.3)) @@ -10381,14 +10378,6 @@ packages: '@babel/core': 7.x vite: 2.x || 3.x || 4.x || 5.x || 6.x || 7.x || 8.x - '@preact/signals-core@1.14.1': - resolution: {integrity: sha512-vxPpfXqrwUe9lpjqfYNjAF/0RF/eFGeLgdJzdmIIZjpOnTmGmAB4BjWone562mJGMRP4frU6iZ6ei3PDsu52Ng==} - - '@preact/signals@2.9.0': - resolution: {integrity: sha512-hYrY0KyUqkDgOl1qba/JGn6y81pXnurn21PMaxfcMwdncdZ3M/oVdmpTvEnsGjh48dIwDVc7bjWHqIsngSjYug==} - peerDependencies: - preact: '>= 10.25.0 || >=11.0.0-0' - '@prefresh/babel-plugin@0.5.3': resolution: {integrity: sha512-57LX2SHs4BX2s1IwCjNzTE2OJeEepRCNf1VTEpbNcUyHfMO68eeOWGDIt4ob9aYlW6PEWZ1SuwNikuoIXANDtQ==} @@ -19968,13 +19957,6 @@ snapshots: - rollup - supports-color - '@preact/signals-core@1.14.1': {} - - '@preact/signals@2.9.0(preact@10.29.1)': - dependencies: - '@preact/signals-core': 1.14.1 - preact: 10.29.1 - '@prefresh/babel-plugin@0.5.3': {} '@prefresh/core@1.5.9(preact@10.29.1)':