@tanstack/preact-table 9.0.0-alpha.42 → 9.0.0-alpha.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,8 @@ let _tanstack_preact_store = require("@tanstack/preact-store");
2
2
 
3
3
  //#region src/Subscribe.ts
4
4
  function Subscribe(props) {
5
- const selected = (0, _tanstack_preact_store.useSelector)("source" in props ? props.source : props.table.store, "source" in props ? props.selector ?? ((x) => x) : props.selector, { compare: _tanstack_preact_store.shallow });
5
+ const selectFn = props.selector ?? ((x) => x);
6
+ const selected = (0, _tanstack_preact_store.useSelector)(props.source, selectFn, { compare: _tanstack_preact_store.shallow });
6
7
  return typeof props.children === "function" ? props.children(selected) : props.children;
7
8
  }
8
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { shallow, useSelector } from '@tanstack/preact-store'\nimport type { Atom, ReadonlyAtom } from '@tanstack/preact-store'\nimport type {\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n> = {\n table: Table<TFeatures, TData>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n> = {\n table: Table<TFeatures, TData>\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store).\n */\nexport type SubscribePropsWithSourceWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected,\n> = {\n table: Table<TFeatures, TData>\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected).\n */\nexport type SubscribePropsWithSource<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected = TSourceValue,\n> =\n | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>\n | SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TData, TSelected>\n | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>\n | SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >\n\n/**\n * A Preact component that allows you to subscribe to the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so\n * JSX contextual typing works. This standalone component uses a union `props` type.\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n>(\n props: SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected,\n>(\n props: SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n>(\n props: SubscribePropsWithStore<TFeatures, TData, TSelected>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TData, TSelected, TSourceValue>,\n): ComponentChildren {\n const source = 'source' in props ? props.source : props.table.store\n const selectFn =\n 'source' in props ? (props.selector ?? ((x: unknown) => x)) : props.selector\n\n const selected = useSelector(\n source as never,\n selectFn as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ComponentChildren)(selected)\n : props.children\n}\n"],"mappings":";;;AA+HA,SAAgB,UAMd,OACmB;CAKnB,MAAM,mDAJS,YAAY,QAAQ,MAAM,SAAS,MAAM,MAAM,OAE5D,YAAY,QAAS,MAAM,cAAc,MAAe,KAAM,MAAM,UAKpE,EACE,SAASA,gCACV,CACF;AAED,QAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAAqD,SAAS,GACrE,MAAM"}
1
+ {"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { shallow, useSelector } from '@tanstack/preact-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/preact-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store).\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected).\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\n/**\n * A Preact component that allows you to subscribe to the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so\n * JSX contextual typing works. This standalone component uses a union `props` type.\n */\nexport function Subscribe<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ComponentChildren\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ComponentChildren\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ComponentChildren {\n const selectFn = props.selector ?? ((x: unknown) => x)\n\n const selected = useSelector(\n props.source as never,\n selectFn as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ComponentChildren)(selected)\n : props.children\n}\n"],"mappings":";;;AAuFA,SAAgB,UAKd,OACmB;CACnB,MAAM,WAAW,MAAM,cAAc,MAAe;CAEpD,MAAM,mDACJ,MAAM,QACN,UACA,EACE,SAASA,gCACV,CACF;AAED,QAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAAqD,SAAS,GACrE,MAAM"}
@@ -1,14 +1,15 @@
1
- import { RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
1
+ import { TableFeatures, TableState } from "@tanstack/table-core";
2
2
  import { ComponentChildren } from "preact";
3
- import { Atom, ReadonlyAtom } from "@tanstack/preact-store";
3
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/preact-store";
4
4
 
5
5
  //#region src/Subscribe.d.ts
6
+ type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
6
7
  /**
7
8
  * Subscribe to `table.store` (full table state). The selector receives the full
8
9
  * {@link TableState}.
9
10
  */
10
- type SubscribePropsWithStore<TFeatures extends TableFeatures, TData extends RowData, TSelected> = {
11
- table: Table<TFeatures, TData>;
11
+ type SubscribePropsWithStore<TFeatures extends TableFeatures, TSelected> = {
12
+ source: SubscribeSource<TableState<TFeatures>>;
12
13
  /**
13
14
  * Select from full table state. Re-renders when the selected value changes
14
15
  * (shallow compare).
@@ -24,35 +25,33 @@ type SubscribePropsWithStore<TFeatures extends TableFeatures, TData extends RowD
24
25
  * `table.optionsStore`). Omitting `selector` is equivalent to the identity
25
26
  * selector — children receive `TSourceValue`.
26
27
  */
27
- type SubscribePropsWithSourceIdentity<TFeatures extends TableFeatures, TData extends RowData, TSourceValue> = {
28
- table: Table<TFeatures, TData>;
29
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
28
+ type SubscribePropsWithSourceIdentity<TSourceValue> = {
29
+ source: SubscribeSource<TSourceValue>;
30
30
  selector?: undefined;
31
31
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren;
32
32
  };
33
33
  /**
34
34
  * Subscribe to a projected value from a source (atom or store).
35
35
  */
36
- type SubscribePropsWithSourceWithSelector<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected> = {
37
- table: Table<TFeatures, TData>;
38
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
36
+ type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {
37
+ source: SubscribeSource<TSourceValue>;
39
38
  selector: (state: TSourceValue) => TSelected;
40
39
  children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
41
40
  };
42
41
  /**
43
42
  * Subscribe to a single source — atom or store (identity or projected).
44
43
  */
45
- type SubscribePropsWithSource<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue> | SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>;
46
- type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TData, TSelected> | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue> | SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>;
44
+ type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
45
+ type SubscribeProps<TFeatures extends TableFeatures, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TSelected> | SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
47
46
  /**
48
47
  * A Preact component that allows you to subscribe to the table state.
49
48
  *
50
49
  * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so
51
50
  * JSX contextual typing works. This standalone component uses a union `props` type.
52
51
  */
53
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSourceValue>(props: SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>): ComponentChildren;
54
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>): ComponentChildren;
55
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected>(props: SubscribePropsWithStore<TFeatures, TData, TSelected>): ComponentChildren;
52
+ declare function Subscribe<TSourceValue>(props: SubscribePropsWithSourceIdentity<TSourceValue>): ComponentChildren;
53
+ declare function Subscribe<TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>): ComponentChildren;
54
+ declare function Subscribe<TFeatures extends TableFeatures, TSelected>(props: SubscribePropsWithStore<TFeatures, TSelected>): ComponentChildren;
56
55
  //#endregion
57
- export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore };
56
+ export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource };
58
57
  //# sourceMappingURL=Subscribe.d.cts.map
@@ -1,14 +1,15 @@
1
- import { RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
2
- import { Atom, ReadonlyAtom } from "@tanstack/preact-store";
1
+ import { TableFeatures, TableState } from "@tanstack/table-core";
2
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/preact-store";
3
3
  import { ComponentChildren } from "preact";
4
4
 
5
5
  //#region src/Subscribe.d.ts
6
+ type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
6
7
  /**
7
8
  * Subscribe to `table.store` (full table state). The selector receives the full
8
9
  * {@link TableState}.
9
10
  */
10
- type SubscribePropsWithStore<TFeatures extends TableFeatures, TData extends RowData, TSelected> = {
11
- table: Table<TFeatures, TData>;
11
+ type SubscribePropsWithStore<TFeatures extends TableFeatures, TSelected> = {
12
+ source: SubscribeSource<TableState<TFeatures>>;
12
13
  /**
13
14
  * Select from full table state. Re-renders when the selected value changes
14
15
  * (shallow compare).
@@ -24,35 +25,33 @@ type SubscribePropsWithStore<TFeatures extends TableFeatures, TData extends RowD
24
25
  * `table.optionsStore`). Omitting `selector` is equivalent to the identity
25
26
  * selector — children receive `TSourceValue`.
26
27
  */
27
- type SubscribePropsWithSourceIdentity<TFeatures extends TableFeatures, TData extends RowData, TSourceValue> = {
28
- table: Table<TFeatures, TData>;
29
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
28
+ type SubscribePropsWithSourceIdentity<TSourceValue> = {
29
+ source: SubscribeSource<TSourceValue>;
30
30
  selector?: undefined;
31
31
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren;
32
32
  };
33
33
  /**
34
34
  * Subscribe to a projected value from a source (atom or store).
35
35
  */
36
- type SubscribePropsWithSourceWithSelector<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected> = {
37
- table: Table<TFeatures, TData>;
38
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
36
+ type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {
37
+ source: SubscribeSource<TSourceValue>;
39
38
  selector: (state: TSourceValue) => TSelected;
40
39
  children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
41
40
  };
42
41
  /**
43
42
  * Subscribe to a single source — atom or store (identity or projected).
44
43
  */
45
- type SubscribePropsWithSource<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue> | SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>;
46
- type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TData, TSelected> | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue> | SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>;
44
+ type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
45
+ type SubscribeProps<TFeatures extends TableFeatures, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TSelected> | SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
47
46
  /**
48
47
  * A Preact component that allows you to subscribe to the table state.
49
48
  *
50
49
  * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so
51
50
  * JSX contextual typing works. This standalone component uses a union `props` type.
52
51
  */
53
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSourceValue>(props: SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>): ComponentChildren;
54
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TFeatures, TData, TSourceValue, TSelected>): ComponentChildren;
55
- declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected>(props: SubscribePropsWithStore<TFeatures, TData, TSelected>): ComponentChildren;
52
+ declare function Subscribe<TSourceValue>(props: SubscribePropsWithSourceIdentity<TSourceValue>): ComponentChildren;
53
+ declare function Subscribe<TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>): ComponentChildren;
54
+ declare function Subscribe<TFeatures extends TableFeatures, TSelected>(props: SubscribePropsWithStore<TFeatures, TSelected>): ComponentChildren;
56
55
  //#endregion
57
- export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore };
56
+ export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource };
58
57
  //# sourceMappingURL=Subscribe.d.ts.map
package/dist/Subscribe.js CHANGED
@@ -2,7 +2,8 @@ import { shallow, useSelector } from "@tanstack/preact-store";
2
2
 
3
3
  //#region src/Subscribe.ts
4
4
  function Subscribe(props) {
5
- const selected = useSelector("source" in props ? props.source : props.table.store, "source" in props ? props.selector ?? ((x) => x) : props.selector, { compare: shallow });
5
+ const selectFn = props.selector ?? ((x) => x);
6
+ const selected = useSelector(props.source, selectFn, { compare: shallow });
6
7
  return typeof props.children === "function" ? props.children(selected) : props.children;
7
8
  }
8
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { shallow, useSelector } from '@tanstack/preact-store'\nimport type { Atom, ReadonlyAtom } from '@tanstack/preact-store'\nimport type {\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n> = {\n table: Table<TFeatures, TData>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n> = {\n table: Table<TFeatures, TData>\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store).\n */\nexport type SubscribePropsWithSourceWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected,\n> = {\n table: Table<TFeatures, TData>\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected).\n */\nexport type SubscribePropsWithSource<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected = TSourceValue,\n> =\n | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>\n | SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TData, TSelected>\n | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>\n | SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >\n\n/**\n * A Preact component that allows you to subscribe to the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so\n * JSX contextual typing works. This standalone component uses a union `props` type.\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n>(\n props: SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSourceValue,\n TSelected,\n>(\n props: SubscribePropsWithSourceWithSelector<\n TFeatures,\n TData,\n TSourceValue,\n TSelected\n >,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n>(\n props: SubscribePropsWithStore<TFeatures, TData, TSelected>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TData, TSelected, TSourceValue>,\n): ComponentChildren {\n const source = 'source' in props ? props.source : props.table.store\n const selectFn =\n 'source' in props ? (props.selector ?? ((x: unknown) => x)) : props.selector\n\n const selected = useSelector(\n source as never,\n selectFn as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ComponentChildren)(selected)\n : props.children\n}\n"],"mappings":";;;AA+HA,SAAgB,UAMd,OACmB;CAKnB,MAAM,WAAW,YAJF,YAAY,QAAQ,MAAM,SAAS,MAAM,MAAM,OAE5D,YAAY,QAAS,MAAM,cAAc,MAAe,KAAM,MAAM,UAKpE,EACE,SAAS,SACV,CACF;AAED,QAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAAqD,SAAS,GACrE,MAAM"}
1
+ {"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { shallow, useSelector } from '@tanstack/preact-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/preact-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store).\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected).\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\n/**\n * A Preact component that allows you to subscribe to the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so\n * JSX contextual typing works. This standalone component uses a union `props` type.\n */\nexport function Subscribe<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ComponentChildren\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ComponentChildren\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ComponentChildren\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ComponentChildren {\n const selectFn = props.selector ?? ((x: unknown) => x)\n\n const selected = useSelector(\n props.source as never,\n selectFn as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ComponentChildren)(selected)\n : props.children\n}\n"],"mappings":";;;AAuFA,SAAgB,UAKd,OACmB;CACnB,MAAM,WAAW,MAAM,cAAc,MAAe;CAEpD,MAAM,WAAW,YACf,MAAM,QACN,UACA,EACE,SAAS,SACV,CACF;AAED,QAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAAqD,SAAS,GACrE,MAAM"}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlexRender, FlexRenderProps, Renderable, flexRender } from "./FlexRender.cjs";
2
- import { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore } from "./Subscribe.cjs";
2
+ import { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource } from "./Subscribe.cjs";
3
3
  import { PreactTable, useTable } from "./useTable.cjs";
4
4
  import { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, createTableHook } from "./createTableHook.cjs";
5
5
  export * from "@tanstack/table-core";
6
- export { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, FlexRender, FlexRenderProps, PreactTable, Renderable, Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, createTableHook, flexRender, useTable };
6
+ export { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, FlexRender, FlexRenderProps, PreactTable, Renderable, Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource, createTableHook, flexRender, useTable };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlexRender, FlexRenderProps, Renderable, flexRender } from "./FlexRender.js";
2
- import { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore } from "./Subscribe.js";
2
+ import { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource } from "./Subscribe.js";
3
3
  import { PreactTable, useTable } from "./useTable.js";
4
4
  import { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, createTableHook } from "./createTableHook.js";
5
5
  export * from "@tanstack/table-core";
6
- export { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, FlexRender, FlexRenderProps, PreactTable, Renderable, Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, createTableHook, flexRender, useTable };
6
+ export { AppCellComponent, AppCellContext, AppCellPropsWithSelector, AppCellPropsWithoutSelector, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderComponent, AppHeaderContext, AppHeaderPropsWithSelector, AppHeaderPropsWithoutSelector, AppPreactTable, AppTableComponent, AppTablePropsWithSelector, AppTablePropsWithoutSelector, CreateTableHookOptions, FlexRender, FlexRenderProps, PreactTable, Renderable, Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource, createTableHook, flexRender, useTable };
@@ -0,0 +1,20 @@
1
+ let _tanstack_preact_store = require("@tanstack/preact-store");
2
+
3
+ //#region src/reactivity.ts
4
+ function preactReactivity() {
5
+ return {
6
+ createOptionsStore: false,
7
+ batch: _tanstack_preact_store.batch,
8
+ untrack: (fn) => fn(),
9
+ createReadonlyAtom: (fn, options) => {
10
+ return (0, _tanstack_preact_store.createAtom)(() => fn(), { compare: options === null || options === void 0 ? void 0 : options.compare });
11
+ },
12
+ createWritableAtom: (value, options) => {
13
+ return (0, _tanstack_preact_store.createAtom)(value, { compare: options === null || options === void 0 ? void 0 : options.compare });
14
+ }
15
+ };
16
+ }
17
+
18
+ //#endregion
19
+ exports.preactReactivity = preactReactivity;
20
+ //# sourceMappingURL=reactivity.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactivity.cjs","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/preact-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\nexport function preactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n\n// // TOTO - re-explore preact signals for reactivity\n// import { batch, computed, signal, untracked } from '@preact/signals'\n// import type {\n// TableAtomOptions,\n// TableReactivityBindings,\n// } from '@tanstack/table-core/reactivity'\n// import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store'\n\n// function observerToCallback<T>(\n// observerOrNext: Observer<T> | ((value: T) => void),\n// ): (value: T) => void {\n// return typeof observerOrNext === 'function'\n// ? observerOrNext\n// : (value) => observerOrNext.next?.(value)\n// }\n\n// function signalToReadonlyAtom<T>(source: {\n// value: T\n// subscribe: (observer: (value: T) => void) => () => void\n// }): ReadonlyAtom<T> {\n// return Object.assign(source, {\n// get: () => source.value,\n// subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {\n// const unsubscribe = source.subscribe(observerToCallback(observerOrNext))\n// return { unsubscribe }\n// }) as ReadonlyAtom<T>['subscribe'],\n// })\n// }\n\n// function signalToWritableAtom<T>(source: {\n// value: T\n// subscribe: (observer: (value: T) => void) => () => void\n// }): Atom<T> {\n// return Object.assign(source, {\n// set: (updater: T | ((prevVal: T) => T)) => {\n// source.value =\n// typeof updater === 'function'\n// ? (updater as (prevVal: T) => T)(source.value)\n// : updater\n// },\n// get: () => source.value,\n// subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {\n// const unsubscribe = source.subscribe(observerToCallback(observerOrNext))\n// return { unsubscribe }\n// }) as Atom<T>['subscribe'],\n// })\n// }\n\n// export function preactReactivity(): TableReactivityBindings {\n// return {\n// createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {\n// return signalToReadonlyAtom(computed(fn))\n// },\n// createWritableAtom: <T>(\n// value: T,\n// _options?: TableAtomOptions<T>,\n// ): Atom<T> => {\n// return signalToWritableAtom(signal(value))\n// },\n// untrack: untracked,\n// batch: batch,\n// }\n// }\n"],"mappings":";;;AAMA,SAAgB,mBAA4C;AAC1D,QAAO;EACL,oBAAoB;EACpB;EACA,UAAU,OAAO,IAAI;EACrB,qBAAwB,IAAa,YAAkC;AACrE,uDAAwB,IAAI,EAAE,EAC5B,2DAAS,QAAS,SACnB,CAAC;;EAEJ,qBAAwB,OAAU,YAAkC;AAClE,iDAAkB,OAAO,EACvB,2DAAS,QAAS,SACnB,CAAC;;EAEL"}
@@ -0,0 +1,20 @@
1
+ import { batch, createAtom } from "@tanstack/preact-store";
2
+
3
+ //#region src/reactivity.ts
4
+ function preactReactivity() {
5
+ return {
6
+ createOptionsStore: false,
7
+ batch,
8
+ untrack: (fn) => fn(),
9
+ createReadonlyAtom: (fn, options) => {
10
+ return createAtom(() => fn(), { compare: options === null || options === void 0 ? void 0 : options.compare });
11
+ },
12
+ createWritableAtom: (value, options) => {
13
+ return createAtom(value, { compare: options === null || options === void 0 ? void 0 : options.compare });
14
+ }
15
+ };
16
+ }
17
+
18
+ //#endregion
19
+ export { preactReactivity };
20
+ //# sourceMappingURL=reactivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactivity.js","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/preact-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\nexport function preactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n\n// // TOTO - re-explore preact signals for reactivity\n// import { batch, computed, signal, untracked } from '@preact/signals'\n// import type {\n// TableAtomOptions,\n// TableReactivityBindings,\n// } from '@tanstack/table-core/reactivity'\n// import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store'\n\n// function observerToCallback<T>(\n// observerOrNext: Observer<T> | ((value: T) => void),\n// ): (value: T) => void {\n// return typeof observerOrNext === 'function'\n// ? observerOrNext\n// : (value) => observerOrNext.next?.(value)\n// }\n\n// function signalToReadonlyAtom<T>(source: {\n// value: T\n// subscribe: (observer: (value: T) => void) => () => void\n// }): ReadonlyAtom<T> {\n// return Object.assign(source, {\n// get: () => source.value,\n// subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {\n// const unsubscribe = source.subscribe(observerToCallback(observerOrNext))\n// return { unsubscribe }\n// }) as ReadonlyAtom<T>['subscribe'],\n// })\n// }\n\n// function signalToWritableAtom<T>(source: {\n// value: T\n// subscribe: (observer: (value: T) => void) => () => void\n// }): Atom<T> {\n// return Object.assign(source, {\n// set: (updater: T | ((prevVal: T) => T)) => {\n// source.value =\n// typeof updater === 'function'\n// ? (updater as (prevVal: T) => T)(source.value)\n// : updater\n// },\n// get: () => source.value,\n// subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {\n// const unsubscribe = source.subscribe(observerToCallback(observerOrNext))\n// return { unsubscribe }\n// }) as Atom<T>['subscribe'],\n// })\n// }\n\n// export function preactReactivity(): TableReactivityBindings {\n// return {\n// createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {\n// return signalToReadonlyAtom(computed(fn))\n// },\n// createWritableAtom: <T>(\n// value: T,\n// _options?: TableAtomOptions<T>,\n// ): Atom<T> => {\n// return signalToWritableAtom(signal(value))\n// },\n// untrack: untracked,\n// batch: batch,\n// }\n// }\n"],"mappings":";;;AAMA,SAAgB,mBAA4C;AAC1D,QAAO;EACL,oBAAoB;EACpB;EACA,UAAU,OAAO,IAAI;EACrB,qBAAwB,IAAa,YAAkC;AACrE,UAAO,iBAAiB,IAAI,EAAE,EAC5B,2DAAS,QAAS,SACnB,CAAC;;EAEJ,qBAAwB,OAAU,YAAkC;AAClE,UAAO,WAAW,OAAO,EACvB,2DAAS,QAAS,SACnB,CAAC;;EAEL"}
package/dist/useTable.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  const require_FlexRender = require('./FlexRender.cjs');
2
2
  const require_Subscribe = require('./Subscribe.cjs');
3
+ const require_reactivity = require('./reactivity.cjs');
3
4
  let _tanstack_table_core = require("@tanstack/table-core");
4
5
  let _tanstack_preact_store = require("@tanstack/preact-store");
5
6
  let preact_hooks = require("preact/hooks");
6
- let _tanstack_table_core_reactivity = require("@tanstack/table-core/reactivity");
7
7
 
8
8
  //#region src/useTable.ts
9
9
  function useTable(tableOptions, selector = () => ({})) {
@@ -11,34 +11,32 @@ function useTable(tableOptions, selector = () => ({})) {
11
11
  const tableInstance = (0, _tanstack_table_core.constructTable)({
12
12
  ...tableOptions,
13
13
  _features: {
14
- coreReativityFeature: (0, _tanstack_table_core_reactivity.constructReactivityBindings)(),
14
+ coreReativityFeature: require_reactivity.preactReactivity(),
15
15
  ...tableOptions._features
16
16
  }
17
17
  });
18
18
  tableInstance.Subscribe = ((props) => {
19
+ const source = props.source ?? tableInstance.store;
19
20
  return require_Subscribe.Subscribe({
20
21
  ...props,
21
- table: tableInstance
22
+ source
22
23
  });
23
24
  });
24
25
  tableInstance.FlexRender = require_FlexRender.FlexRender;
25
26
  return tableInstance;
26
27
  });
27
- (0, preact_hooks.useEffect)(() => {
28
- table.setOptions((prev) => ({
29
- ...prev,
30
- ...tableOptions
31
- }));
32
- }, [table, tableOptions]);
28
+ table.setOptions((prev) => ({
29
+ ...prev,
30
+ ...tableOptions
31
+ }));
33
32
  const state = (0, _tanstack_preact_store.useSelector)(table.store, selector, { compare: _tanstack_preact_store.shallow });
34
- const options = (0, _tanstack_preact_store.useSelector)(table.optionsStore, (options) => options, { compare: _tanstack_preact_store.shallow });
35
33
  return (0, preact_hooks.useMemo)(() => ({
36
34
  ...table,
37
- options,
35
+ options: tableOptions,
38
36
  state
39
37
  }), [
40
38
  table,
41
- options,
39
+ tableOptions,
42
40
  state
43
41
  ]);
44
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.cjs","names":["Subscribe","FlexRender","shallow"],"sources":["../src/useTable.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'preact/hooks'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/preact-store'\nimport { constructReactivityBindings } from '@tanstack/table-core/reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\n// import { preactReactivity } from './reactivity'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { Atom, ReadonlyAtom } from '@tanstack/preact-store'\nimport type { ComponentChildren } from 'preact'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore } from './Subscribe'\n\nexport type PreactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A Preact HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (source first, then store) so JSX contextual typing works for both modes.\n * Source without `selector` is separate so children infer `TSourceValue` (identity projection).\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSourceValue, TSubSelected>(props: {\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSubSelected>(\n props: Omit<\n SubscribePropsWithStore<TFeatures, TData, TSubSelected>,\n 'table'\n >,\n ): ComponentChildren\n }\n /**\n * A Preact component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ComponentChildren\n /**\n * 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`.\n */\n readonly state: Readonly<TSelected> & {\n columns: TableOptions<TFeatures, TData>['columns']\n data: TableOptions<TFeatures, TData>['data']\n }\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): PreactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: constructReactivityBindings(), // preactReactivity() currently causes infinite re-renders\n ...tableOptions._features,\n },\n }) as PreactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n return Subscribe({\n ...props,\n table: tableInstance,\n })\n }) as PreactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n useEffect(() => {\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n }, [table, tableOptions])\n\n const state = useSelector(table.store, selector, { compare: shallow })\n const options = useSelector(table.optionsStore, (options) => options, {\n compare: shallow,\n })\n\n return useMemo(\n () => ({\n ...table,\n options,\n state,\n }),\n [table, options, state],\n ) as PreactTable<TFeatures, TData, TSelected>\n}\n"],"mappings":";;;;;;;;AAsFA,SAAgB,SAKd,cACA,kBACG,EAAE,GACqC;CAC1C,MAAM,CAAC,0CAAwB;EAC7B,MAAM,yDAA+B;GACnC,GAAG;GACH,WAAW;IACT,wFAAmD;IACnD,GAAG,aAAa;IACjB;GACF,CAAC;AAEF,gBAAc,cAAc,UAAe;AACzC,UAAOA,4BAAU;IACf,GAAG;IACH,OAAO;IACR,CAAC;;AAGJ,gBAAc,aAAaC;AAE3B,SAAO;GACP;AAEF,mCAAgB;AACd,QAAM,YAAY,UAAU;GAC1B,GAAG;GACH,GAAG;GACJ,EAAE;IACF,CAAC,OAAO,aAAa,CAAC;CAEzB,MAAM,gDAAoB,MAAM,OAAO,UAAU,EAAE,SAASC,gCAAS,CAAC;CACtE,MAAM,kDAAsB,MAAM,eAAe,YAAY,SAAS,EACpE,SAASA,gCACV,CAAC;AAEF,yCACS;EACL,GAAG;EACH;EACA;EACD,GACD;EAAC;EAAO;EAAS;EAAM,CACxB"}
1
+ {"version":3,"file":"useTable.cjs","names":["preactReactivity","Subscribe","FlexRender","shallow"],"sources":["../src/useTable.ts"],"sourcesContent":["import { useMemo, useState } from 'preact/hooks'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/preact-store'\nimport { preactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\n\nexport type PreactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A Preact HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (source first, then store) so JSX contextual typing works for both modes.\n * Source without `selector` is separate so children infer `TSourceValue` (identity projection).\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ComponentChildren\n }\n /**\n * A Preact component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ComponentChildren\n /**\n * 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`.\n */\n readonly state: Readonly<TSelected>\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): PreactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: preactReactivity(),\n ...tableOptions._features,\n },\n }) as PreactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n const source = props.source ?? tableInstance.store\n\n return Subscribe({\n ...props,\n source,\n })\n }) as PreactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n const state = useSelector(table.store, selector, { compare: shallow })\n\n return useMemo(\n () => ({\n ...table,\n options: tableOptions,\n state,\n }),\n [table, tableOptions, state],\n )\n}\n"],"mappings":";;;;;;;;AA8EA,SAAgB,SAKd,cACA,kBACG,EAAE,GACqC;CAC1C,MAAM,CAAC,0CAAwB;EAC7B,MAAM,yDAA+B;GACnC,GAAG;GACH,WAAW;IACT,sBAAsBA,qCAAkB;IACxC,GAAG,aAAa;IACjB;GACF,CAAC;AAEF,gBAAc,cAAc,UAAe;GACzC,MAAM,SAAS,MAAM,UAAU,cAAc;AAE7C,UAAOC,4BAAU;IACf,GAAG;IACH;IACD,CAAC;;AAGJ,gBAAc,aAAaC;AAE3B,SAAO;GACP;AAGF,OAAM,YAAY,UAAU;EAC1B,GAAG;EACH,GAAG;EACJ,EAAE;CAEH,MAAM,gDAAoB,MAAM,OAAO,UAAU,EAAE,SAASC,gCAAS,CAAC;AAEtE,yCACS;EACL,GAAG;EACH,SAAS;EACT;EACD,GACD;EAAC;EAAO;EAAc;EAAM,CAC7B"}
@@ -1,8 +1,7 @@
1
1
  import { FlexRenderProps } from "./FlexRender.cjs";
2
- import { SubscribePropsWithStore } from "./Subscribe.cjs";
2
+ import { SubscribePropsWithStore, SubscribeSource } from "./Subscribe.cjs";
3
3
  import { CellData, RowData, Table, TableFeatures, TableOptions, TableState } from "@tanstack/table-core";
4
4
  import { ComponentChildren } from "preact";
5
- import { Atom, ReadonlyAtom } from "@tanstack/preact-store";
6
5
 
7
6
  //#region src/useTable.d.ts
8
7
  type PreactTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}> = Table<TFeatures, TData> & {
@@ -35,16 +34,16 @@ type PreactTable<TFeatures extends TableFeatures, TData extends RowData, TSelect
35
34
  */
36
35
  Subscribe: {
37
36
  <TSourceValue>(props: {
38
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
37
+ source: SubscribeSource<TSourceValue>;
39
38
  selector?: undefined;
40
39
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren;
41
40
  }): ComponentChildren;
42
41
  <TSourceValue, TSubSelected>(props: {
43
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
42
+ source: SubscribeSource<TSourceValue>;
44
43
  selector: (state: TSourceValue) => TSubSelected;
45
44
  children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren;
46
45
  }): ComponentChildren;
47
- <TSubSelected>(props: Omit<SubscribePropsWithStore<TFeatures, TData, TSubSelected>, 'table'>): ComponentChildren;
46
+ <TSubSelected>(props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>): ComponentChildren;
48
47
  };
49
48
  /**
50
49
  * A Preact component that renders headers, cells, or footers with custom markup.
@@ -54,10 +53,7 @@ type PreactTable<TFeatures extends TableFeatures, TData extends RowData, TSelect
54
53
  /**
55
54
  * 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`.
56
55
  */
57
- readonly state: Readonly<TSelected> & {
58
- columns: TableOptions<TFeatures, TData>['columns'];
59
- data: TableOptions<TFeatures, TData>['data'];
60
- };
56
+ readonly state: Readonly<TSelected>;
61
57
  };
62
58
  declare function useTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(tableOptions: TableOptions<TFeatures, TData>, selector?: (state: TableState<TFeatures>) => TSelected): PreactTable<TFeatures, TData, TSelected>;
63
59
  //#endregion
@@ -1,7 +1,6 @@
1
1
  import { FlexRenderProps } from "./FlexRender.js";
2
- import { SubscribePropsWithStore } from "./Subscribe.js";
2
+ import { SubscribePropsWithStore, SubscribeSource } from "./Subscribe.js";
3
3
  import { CellData, RowData, Table, TableFeatures, TableOptions, TableState } from "@tanstack/table-core";
4
- import { Atom, ReadonlyAtom } from "@tanstack/preact-store";
5
4
  import { ComponentChildren } from "preact";
6
5
 
7
6
  //#region src/useTable.d.ts
@@ -35,16 +34,16 @@ type PreactTable<TFeatures extends TableFeatures, TData extends RowData, TSelect
35
34
  */
36
35
  Subscribe: {
37
36
  <TSourceValue>(props: {
38
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
37
+ source: SubscribeSource<TSourceValue>;
39
38
  selector?: undefined;
40
39
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren;
41
40
  }): ComponentChildren;
42
41
  <TSourceValue, TSubSelected>(props: {
43
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
42
+ source: SubscribeSource<TSourceValue>;
44
43
  selector: (state: TSourceValue) => TSubSelected;
45
44
  children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren;
46
45
  }): ComponentChildren;
47
- <TSubSelected>(props: Omit<SubscribePropsWithStore<TFeatures, TData, TSubSelected>, 'table'>): ComponentChildren;
46
+ <TSubSelected>(props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>): ComponentChildren;
48
47
  };
49
48
  /**
50
49
  * A Preact component that renders headers, cells, or footers with custom markup.
@@ -54,10 +53,7 @@ type PreactTable<TFeatures extends TableFeatures, TData extends RowData, TSelect
54
53
  /**
55
54
  * 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`.
56
55
  */
57
- readonly state: Readonly<TSelected> & {
58
- columns: TableOptions<TFeatures, TData>['columns'];
59
- data: TableOptions<TFeatures, TData>['data'];
60
- };
56
+ readonly state: Readonly<TSelected>;
61
57
  };
62
58
  declare function useTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(tableOptions: TableOptions<TFeatures, TData>, selector?: (state: TableState<TFeatures>) => TSelected): PreactTable<TFeatures, TData, TSelected>;
63
59
  //#endregion
package/dist/useTable.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { FlexRender } from "./FlexRender.js";
2
2
  import { Subscribe } from "./Subscribe.js";
3
+ import { preactReactivity } from "./reactivity.js";
3
4
  import { constructTable } from "@tanstack/table-core";
4
5
  import { shallow, useSelector } from "@tanstack/preact-store";
5
- import { useEffect, useMemo, useState } from "preact/hooks";
6
- import { constructReactivityBindings } from "@tanstack/table-core/reactivity";
6
+ import { useMemo, useState } from "preact/hooks";
7
7
 
8
8
  //#region src/useTable.ts
9
9
  function useTable(tableOptions, selector = () => ({})) {
@@ -11,34 +11,32 @@ function useTable(tableOptions, selector = () => ({})) {
11
11
  const tableInstance = constructTable({
12
12
  ...tableOptions,
13
13
  _features: {
14
- coreReativityFeature: constructReactivityBindings(),
14
+ coreReativityFeature: preactReactivity(),
15
15
  ...tableOptions._features
16
16
  }
17
17
  });
18
18
  tableInstance.Subscribe = ((props) => {
19
+ const source = props.source ?? tableInstance.store;
19
20
  return Subscribe({
20
21
  ...props,
21
- table: tableInstance
22
+ source
22
23
  });
23
24
  });
24
25
  tableInstance.FlexRender = FlexRender;
25
26
  return tableInstance;
26
27
  });
27
- useEffect(() => {
28
- table.setOptions((prev) => ({
29
- ...prev,
30
- ...tableOptions
31
- }));
32
- }, [table, tableOptions]);
28
+ table.setOptions((prev) => ({
29
+ ...prev,
30
+ ...tableOptions
31
+ }));
33
32
  const state = useSelector(table.store, selector, { compare: shallow });
34
- const options = useSelector(table.optionsStore, (options) => options, { compare: shallow });
35
33
  return useMemo(() => ({
36
34
  ...table,
37
- options,
35
+ options: tableOptions,
38
36
  state
39
37
  }), [
40
38
  table,
41
- options,
39
+ tableOptions,
42
40
  state
43
41
  ]);
44
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","names":[],"sources":["../src/useTable.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'preact/hooks'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/preact-store'\nimport { constructReactivityBindings } from '@tanstack/table-core/reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\n// import { preactReactivity } from './reactivity'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { Atom, ReadonlyAtom } from '@tanstack/preact-store'\nimport type { ComponentChildren } from 'preact'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore } from './Subscribe'\n\nexport type PreactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A Preact HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (source first, then store) so JSX contextual typing works for both modes.\n * Source without `selector` is separate so children infer `TSourceValue` (identity projection).\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSourceValue, TSubSelected>(props: {\n source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSubSelected>(\n props: Omit<\n SubscribePropsWithStore<TFeatures, TData, TSubSelected>,\n 'table'\n >,\n ): ComponentChildren\n }\n /**\n * A Preact component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ComponentChildren\n /**\n * 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`.\n */\n readonly state: Readonly<TSelected> & {\n columns: TableOptions<TFeatures, TData>['columns']\n data: TableOptions<TFeatures, TData>['data']\n }\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): PreactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: constructReactivityBindings(), // preactReactivity() currently causes infinite re-renders\n ...tableOptions._features,\n },\n }) as PreactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n return Subscribe({\n ...props,\n table: tableInstance,\n })\n }) as PreactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n useEffect(() => {\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n }, [table, tableOptions])\n\n const state = useSelector(table.store, selector, { compare: shallow })\n const options = useSelector(table.optionsStore, (options) => options, {\n compare: shallow,\n })\n\n return useMemo(\n () => ({\n ...table,\n options,\n state,\n }),\n [table, options, state],\n ) as PreactTable<TFeatures, TData, TSelected>\n}\n"],"mappings":";;;;;;;;AAsFA,SAAgB,SAKd,cACA,kBACG,EAAE,GACqC;CAC1C,MAAM,CAAC,SAAS,eAAe;EAC7B,MAAM,gBAAgB,eAAe;GACnC,GAAG;GACH,WAAW;IACT,sBAAsB,6BAA6B;IACnD,GAAG,aAAa;IACjB;GACF,CAAC;AAEF,gBAAc,cAAc,UAAe;AACzC,UAAO,UAAU;IACf,GAAG;IACH,OAAO;IACR,CAAC;;AAGJ,gBAAc,aAAa;AAE3B,SAAO;GACP;AAEF,iBAAgB;AACd,QAAM,YAAY,UAAU;GAC1B,GAAG;GACH,GAAG;GACJ,EAAE;IACF,CAAC,OAAO,aAAa,CAAC;CAEzB,MAAM,QAAQ,YAAY,MAAM,OAAO,UAAU,EAAE,SAAS,SAAS,CAAC;CACtE,MAAM,UAAU,YAAY,MAAM,eAAe,YAAY,SAAS,EACpE,SAAS,SACV,CAAC;AAEF,QAAO,eACE;EACL,GAAG;EACH;EACA;EACD,GACD;EAAC;EAAO;EAAS;EAAM,CACxB"}
1
+ {"version":3,"file":"useTable.js","names":[],"sources":["../src/useTable.ts"],"sourcesContent":["import { useMemo, useState } from 'preact/hooks'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/preact-store'\nimport { preactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\n\nexport type PreactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A Preact HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (source first, then store) so JSX contextual typing works for both modes.\n * Source without `selector` is separate so children infer `TSourceValue` (identity projection).\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren\n }): ComponentChildren\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ComponentChildren\n }\n /**\n * A Preact component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ComponentChildren\n /**\n * 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`.\n */\n readonly state: Readonly<TSelected>\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): PreactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: preactReactivity(),\n ...tableOptions._features,\n },\n }) as PreactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n const source = props.source ?? tableInstance.store\n\n return Subscribe({\n ...props,\n source,\n })\n }) as PreactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n const state = useSelector(table.store, selector, { compare: shallow })\n\n return useMemo(\n () => ({\n ...table,\n options: tableOptions,\n state,\n }),\n [table, tableOptions, state],\n )\n}\n"],"mappings":";;;;;;;;AA8EA,SAAgB,SAKd,cACA,kBACG,EAAE,GACqC;CAC1C,MAAM,CAAC,SAAS,eAAe;EAC7B,MAAM,gBAAgB,eAAe;GACnC,GAAG;GACH,WAAW;IACT,sBAAsB,kBAAkB;IACxC,GAAG,aAAa;IACjB;GACF,CAAC;AAEF,gBAAc,cAAc,UAAe;GACzC,MAAM,SAAS,MAAM,UAAU,cAAc;AAE7C,UAAO,UAAU;IACf,GAAG;IACH;IACD,CAAC;;AAGJ,gBAAc,aAAa;AAE3B,SAAO;GACP;AAGF,OAAM,YAAY,UAAU;EAC1B,GAAG;EACH,GAAG;EACJ,EAAE;CAEH,MAAM,QAAQ,YAAY,MAAM,OAAO,UAAU,EAAE,SAAS,SAAS,CAAC;AAEtE,QAAO,eACE;EACL,GAAG;EACH,SAAS;EACT;EACD,GACD;EAAC;EAAO;EAAc;EAAM,CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/preact-table",
3
- "version": "9.0.0-alpha.42",
3
+ "version": "9.0.0-alpha.44",
4
4
  "description": "Headless UI for building powerful tables & datagrids for Preact.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -48,9 +48,8 @@
48
48
  "src"
49
49
  ],
50
50
  "dependencies": {
51
- "@preact/signals": "^2.9.0",
52
51
  "@tanstack/preact-store": "^0.13.0",
53
- "@tanstack/table-core": "9.0.0-alpha.42"
52
+ "@tanstack/table-core": "9.0.0-alpha.43"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@preact/preset-vite": "^2.10.5",
package/src/Subscribe.ts CHANGED
@@ -1,23 +1,28 @@
1
1
  import { shallow, useSelector } from '@tanstack/preact-store'
2
- import type { Atom, ReadonlyAtom } from '@tanstack/preact-store'
3
2
  import type {
4
- RowData,
5
- Table,
6
- TableFeatures,
7
- TableState,
8
- } from '@tanstack/table-core'
3
+ Atom,
4
+ ReadonlyAtom,
5
+ ReadonlyStore,
6
+ Store,
7
+ } from '@tanstack/preact-store'
8
+ import type { TableFeatures, TableState } from '@tanstack/table-core'
9
9
  import type { ComponentChildren } from 'preact'
10
10
 
11
+ export type SubscribeSource<TValue> =
12
+ | Atom<TValue>
13
+ | ReadonlyAtom<TValue>
14
+ | Store<TValue>
15
+ | ReadonlyStore<TValue>
16
+
11
17
  /**
12
18
  * Subscribe to `table.store` (full table state). The selector receives the full
13
19
  * {@link TableState}.
14
20
  */
15
21
  export type SubscribePropsWithStore<
16
22
  TFeatures extends TableFeatures,
17
- TData extends RowData,
18
23
  TSelected,
19
24
  > = {
20
- table: Table<TFeatures, TData>
25
+ source: SubscribeSource<TableState<TFeatures>>
21
26
  /**
22
27
  * Select from full table state. Re-renders when the selected value changes
23
28
  * (shallow compare).
@@ -34,13 +39,8 @@ export type SubscribePropsWithStore<
34
39
  * `table.optionsStore`). Omitting `selector` is equivalent to the identity
35
40
  * selector — children receive `TSourceValue`.
36
41
  */
37
- export type SubscribePropsWithSourceIdentity<
38
- TFeatures extends TableFeatures,
39
- TData extends RowData,
40
- TSourceValue,
41
- > = {
42
- table: Table<TFeatures, TData>
43
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
42
+ export type SubscribePropsWithSourceIdentity<TSourceValue> = {
43
+ source: SubscribeSource<TSourceValue>
44
44
  selector?: undefined
45
45
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren
46
46
  }
@@ -48,14 +48,8 @@ export type SubscribePropsWithSourceIdentity<
48
48
  /**
49
49
  * Subscribe to a projected value from a source (atom or store).
50
50
  */
51
- export type SubscribePropsWithSourceWithSelector<
52
- TFeatures extends TableFeatures,
53
- TData extends RowData,
54
- TSourceValue,
55
- TSelected,
56
- > = {
57
- table: Table<TFeatures, TData>
58
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
51
+ export type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {
52
+ source: SubscribeSource<TSourceValue>
59
53
  selector: (state: TSourceValue) => TSelected
60
54
  children: ((state: TSelected) => ComponentChildren) | ComponentChildren
61
55
  }
@@ -63,34 +57,18 @@ export type SubscribePropsWithSourceWithSelector<
63
57
  /**
64
58
  * Subscribe to a single source — atom or store (identity or projected).
65
59
  */
66
- export type SubscribePropsWithSource<
67
- TFeatures extends TableFeatures,
68
- TData extends RowData,
69
- TSourceValue,
70
- TSelected = TSourceValue,
71
- > =
72
- | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>
73
- | SubscribePropsWithSourceWithSelector<
74
- TFeatures,
75
- TData,
76
- TSourceValue,
77
- TSelected
78
- >
60
+ export type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =
61
+ | SubscribePropsWithSourceIdentity<TSourceValue>
62
+ | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>
79
63
 
80
64
  export type SubscribeProps<
81
65
  TFeatures extends TableFeatures,
82
- TData extends RowData,
83
66
  TSelected = unknown,
84
67
  TSourceValue = unknown,
85
68
  > =
86
- | SubscribePropsWithStore<TFeatures, TData, TSelected>
87
- | SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>
88
- | SubscribePropsWithSourceWithSelector<
89
- TFeatures,
90
- TData,
91
- TSourceValue,
92
- TSelected
93
- >
69
+ | SubscribePropsWithStore<TFeatures, TSelected>
70
+ | SubscribePropsWithSourceIdentity<TSourceValue>
71
+ | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>
94
72
 
95
73
  /**
96
74
  * A Preact component that allows you to subscribe to the table state.
@@ -98,47 +76,26 @@ export type SubscribeProps<
98
76
  * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so
99
77
  * JSX contextual typing works. This standalone component uses a union `props` type.
100
78
  */
101
- export function Subscribe<
102
- TFeatures extends TableFeatures,
103
- TData extends RowData,
104
- TSourceValue,
105
- >(
106
- props: SubscribePropsWithSourceIdentity<TFeatures, TData, TSourceValue>,
79
+ export function Subscribe<TSourceValue>(
80
+ props: SubscribePropsWithSourceIdentity<TSourceValue>,
107
81
  ): ComponentChildren
108
- export function Subscribe<
109
- TFeatures extends TableFeatures,
110
- TData extends RowData,
111
- TSourceValue,
112
- TSelected,
113
- >(
114
- props: SubscribePropsWithSourceWithSelector<
115
- TFeatures,
116
- TData,
117
- TSourceValue,
118
- TSelected
119
- >,
82
+ export function Subscribe<TSourceValue, TSelected>(
83
+ props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,
120
84
  ): ComponentChildren
121
- export function Subscribe<
122
- TFeatures extends TableFeatures,
123
- TData extends RowData,
124
- TSelected,
125
- >(
126
- props: SubscribePropsWithStore<TFeatures, TData, TSelected>,
85
+ export function Subscribe<TFeatures extends TableFeatures, TSelected>(
86
+ props: SubscribePropsWithStore<TFeatures, TSelected>,
127
87
  ): ComponentChildren
128
88
  export function Subscribe<
129
89
  TFeatures extends TableFeatures,
130
- TData extends RowData,
131
90
  TSelected,
132
91
  TSourceValue,
133
92
  >(
134
- props: SubscribeProps<TFeatures, TData, TSelected, TSourceValue>,
93
+ props: SubscribeProps<TFeatures, TSelected, TSourceValue>,
135
94
  ): ComponentChildren {
136
- const source = 'source' in props ? props.source : props.table.store
137
- const selectFn =
138
- 'source' in props ? (props.selector ?? ((x: unknown) => x)) : props.selector
95
+ const selectFn = props.selector ?? ((x: unknown) => x)
139
96
 
140
97
  const selected = useSelector(
141
- source as never,
98
+ props.source as never,
142
99
  selectFn as Parameters<typeof useSelector>[1],
143
100
  {
144
101
  compare: shallow,
package/src/reactivity.ts CHANGED
@@ -1,63 +1,87 @@
1
- // TOTO - re-explore preact signals for reactivity
2
- import { batch, computed, signal, untracked } from '@preact/signals'
1
+ import { batch, createAtom } from '@tanstack/preact-store'
3
2
  import type {
4
3
  TableAtomOptions,
5
4
  TableReactivityBindings,
6
5
  } from '@tanstack/table-core/reactivity'
7
- import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store'
8
-
9
- function observerToCallback<T>(
10
- observerOrNext: Observer<T> | ((value: T) => void),
11
- ): (value: T) => void {
12
- return typeof observerOrNext === 'function'
13
- ? observerOrNext
14
- : (value) => observerOrNext.next?.(value)
15
- }
16
-
17
- function signalToReadonlyAtom<T>(source: {
18
- value: T
19
- subscribe: (observer: (value: T) => void) => () => void
20
- }): ReadonlyAtom<T> {
21
- return Object.assign(source, {
22
- get: () => source.value,
23
- subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
24
- const unsubscribe = source.subscribe(observerToCallback(observerOrNext))
25
- return { unsubscribe }
26
- }) as ReadonlyAtom<T>['subscribe'],
27
- })
28
- }
29
-
30
- function signalToWritableAtom<T>(source: {
31
- value: T
32
- subscribe: (observer: (value: T) => void) => () => void
33
- }): Atom<T> {
34
- return Object.assign(source, {
35
- set: (updater: T | ((prevVal: T) => T)) => {
36
- source.value =
37
- typeof updater === 'function'
38
- ? (updater as (prevVal: T) => T)(source.value)
39
- : updater
40
- },
41
- get: () => source.value,
42
- subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
43
- const unsubscribe = source.subscribe(observerToCallback(observerOrNext))
44
- return { unsubscribe }
45
- }) as Atom<T>['subscribe'],
46
- })
47
- }
48
6
 
49
7
  export function preactReactivity(): TableReactivityBindings {
50
8
  return {
51
- createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {
52
- return signalToReadonlyAtom(computed(fn))
9
+ createOptionsStore: false,
10
+ batch,
11
+ untrack: (fn) => fn(),
12
+ createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {
13
+ return createAtom(() => fn(), {
14
+ compare: options?.compare,
15
+ })
53
16
  },
54
- createWritableAtom: <T>(
55
- value: T,
56
- _options?: TableAtomOptions<T>,
57
- ): Atom<T> => {
58
- return signalToWritableAtom(signal(value))
17
+ createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {
18
+ return createAtom(value, {
19
+ compare: options?.compare,
20
+ })
59
21
  },
60
- untrack: untracked,
61
- batch: batch,
62
22
  }
63
23
  }
24
+
25
+ // // TOTO - re-explore preact signals for reactivity
26
+ // import { batch, computed, signal, untracked } from '@preact/signals'
27
+ // import type {
28
+ // TableAtomOptions,
29
+ // TableReactivityBindings,
30
+ // } from '@tanstack/table-core/reactivity'
31
+ // import type { Atom, Observer, ReadonlyAtom } from '@tanstack/preact-store'
32
+
33
+ // function observerToCallback<T>(
34
+ // observerOrNext: Observer<T> | ((value: T) => void),
35
+ // ): (value: T) => void {
36
+ // return typeof observerOrNext === 'function'
37
+ // ? observerOrNext
38
+ // : (value) => observerOrNext.next?.(value)
39
+ // }
40
+
41
+ // function signalToReadonlyAtom<T>(source: {
42
+ // value: T
43
+ // subscribe: (observer: (value: T) => void) => () => void
44
+ // }): ReadonlyAtom<T> {
45
+ // return Object.assign(source, {
46
+ // get: () => source.value,
47
+ // subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
48
+ // const unsubscribe = source.subscribe(observerToCallback(observerOrNext))
49
+ // return { unsubscribe }
50
+ // }) as ReadonlyAtom<T>['subscribe'],
51
+ // })
52
+ // }
53
+
54
+ // function signalToWritableAtom<T>(source: {
55
+ // value: T
56
+ // subscribe: (observer: (value: T) => void) => () => void
57
+ // }): Atom<T> {
58
+ // return Object.assign(source, {
59
+ // set: (updater: T | ((prevVal: T) => T)) => {
60
+ // source.value =
61
+ // typeof updater === 'function'
62
+ // ? (updater as (prevVal: T) => T)(source.value)
63
+ // : updater
64
+ // },
65
+ // get: () => source.value,
66
+ // subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
67
+ // const unsubscribe = source.subscribe(observerToCallback(observerOrNext))
68
+ // return { unsubscribe }
69
+ // }) as Atom<T>['subscribe'],
70
+ // })
71
+ // }
72
+
73
+ // export function preactReactivity(): TableReactivityBindings {
74
+ // return {
75
+ // createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {
76
+ // return signalToReadonlyAtom(computed(fn))
77
+ // },
78
+ // createWritableAtom: <T>(
79
+ // value: T,
80
+ // _options?: TableAtomOptions<T>,
81
+ // ): Atom<T> => {
82
+ // return signalToWritableAtom(signal(value))
83
+ // },
84
+ // untrack: untracked,
85
+ // batch: batch,
86
+ // }
87
+ // }
package/src/useTable.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { useEffect, useMemo, useState } from 'preact/hooks'
1
+ import { useMemo, useState } from 'preact/hooks'
2
2
  import { constructTable } from '@tanstack/table-core'
3
3
  import { shallow, useSelector } from '@tanstack/preact-store'
4
- import { constructReactivityBindings } from '@tanstack/table-core/reactivity'
4
+ import { preactReactivity } from './reactivity'
5
5
  import { FlexRender } from './FlexRender'
6
6
  import { Subscribe } from './Subscribe'
7
- // import { preactReactivity } from './reactivity'
8
7
  import type {
9
8
  CellData,
10
9
  RowData,
@@ -13,10 +12,9 @@ import type {
13
12
  TableOptions,
14
13
  TableState,
15
14
  } from '@tanstack/table-core'
16
- import type { Atom, ReadonlyAtom } from '@tanstack/preact-store'
17
15
  import type { ComponentChildren } from 'preact'
18
16
  import type { FlexRenderProps } from './FlexRender'
19
- import type { SubscribePropsWithStore } from './Subscribe'
17
+ import type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'
20
18
 
21
19
  export type PreactTable<
22
20
  TFeatures extends TableFeatures,
@@ -52,20 +50,17 @@ export type PreactTable<
52
50
  */
53
51
  Subscribe: {
54
52
  <TSourceValue>(props: {
55
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
53
+ source: SubscribeSource<TSourceValue>
56
54
  selector?: undefined
57
55
  children: ((state: TSourceValue) => ComponentChildren) | ComponentChildren
58
56
  }): ComponentChildren
59
57
  <TSourceValue, TSubSelected>(props: {
60
- source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
58
+ source: SubscribeSource<TSourceValue>
61
59
  selector: (state: TSourceValue) => TSubSelected
62
60
  children: ((state: TSubSelected) => ComponentChildren) | ComponentChildren
63
61
  }): ComponentChildren
64
62
  <TSubSelected>(
65
- props: Omit<
66
- SubscribePropsWithStore<TFeatures, TData, TSubSelected>,
67
- 'table'
68
- >,
63
+ props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,
69
64
  ): ComponentChildren
70
65
  }
71
66
  /**
@@ -78,10 +73,7 @@ export type PreactTable<
78
73
  /**
79
74
  * 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`.
80
75
  */
81
- readonly state: Readonly<TSelected> & {
82
- columns: TableOptions<TFeatures, TData>['columns']
83
- data: TableOptions<TFeatures, TData>['data']
84
- }
76
+ readonly state: Readonly<TSelected>
85
77
  }
86
78
 
87
79
  export function useTable<
@@ -97,15 +89,17 @@ export function useTable<
97
89
  const tableInstance = constructTable({
98
90
  ...tableOptions,
99
91
  _features: {
100
- coreReativityFeature: constructReactivityBindings(), // preactReactivity() currently causes infinite re-renders
92
+ coreReativityFeature: preactReactivity(),
101
93
  ...tableOptions._features,
102
94
  },
103
95
  }) as PreactTable<TFeatures, TData, TSelected>
104
96
 
105
97
  tableInstance.Subscribe = ((props: any) => {
98
+ const source = props.source ?? tableInstance.store
99
+
106
100
  return Subscribe({
107
101
  ...props,
108
- table: tableInstance,
102
+ source,
109
103
  })
110
104
  }) as PreactTable<TFeatures, TData, TSelected>['Subscribe']
111
105
 
@@ -114,24 +108,20 @@ export function useTable<
114
108
  return tableInstance
115
109
  })
116
110
 
117
- useEffect(() => {
118
- table.setOptions((prev) => ({
119
- ...prev,
120
- ...tableOptions,
121
- }))
122
- }, [table, tableOptions])
111
+ // sync options on every render
112
+ table.setOptions((prev) => ({
113
+ ...prev,
114
+ ...tableOptions,
115
+ }))
123
116
 
124
117
  const state = useSelector(table.store, selector, { compare: shallow })
125
- const options = useSelector(table.optionsStore, (options) => options, {
126
- compare: shallow,
127
- })
128
118
 
129
119
  return useMemo(
130
120
  () => ({
131
121
  ...table,
132
- options,
122
+ options: tableOptions,
133
123
  state,
134
124
  }),
135
- [table, options, state],
136
- ) as PreactTable<TFeatures, TData, TSelected>
125
+ [table, tableOptions, state],
126
+ )
137
127
  }