@tanstack/table-core 9.0.0-alpha.41 → 9.0.0-alpha.42

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.
Files changed (57) hide show
  1. package/dist/core/coreFeatures.cjs.map +1 -1
  2. package/dist/core/coreFeatures.d.cts +2 -1
  3. package/dist/core/coreFeatures.d.ts +2 -1
  4. package/dist/core/coreFeatures.js.map +1 -1
  5. package/dist/core/reactivity/constructReactivityBindings.cjs +19 -0
  6. package/dist/core/reactivity/constructReactivityBindings.cjs.map +1 -0
  7. package/dist/core/reactivity/constructReactivityBindings.d.cts +7 -0
  8. package/dist/core/reactivity/constructReactivityBindings.d.ts +7 -0
  9. package/dist/core/reactivity/constructReactivityBindings.js +19 -0
  10. package/dist/core/reactivity/constructReactivityBindings.js.map +1 -0
  11. package/dist/core/reactivity/coreReactivityFeature.types.d.cts +37 -0
  12. package/dist/core/reactivity/coreReactivityFeature.types.d.ts +37 -0
  13. package/dist/core/reactivity/coreReactivityFeature.utils.cjs +19 -0
  14. package/dist/core/reactivity/coreReactivityFeature.utils.cjs.map +1 -0
  15. package/dist/core/reactivity/coreReactivityFeature.utils.d.cts +14 -0
  16. package/dist/core/reactivity/coreReactivityFeature.utils.d.ts +14 -0
  17. package/dist/core/reactivity/coreReactivityFeature.utils.js +18 -0
  18. package/dist/core/reactivity/coreReactivityFeature.utils.js.map +1 -0
  19. package/dist/core/table/constructTable.cjs +18 -15
  20. package/dist/core/table/constructTable.cjs.map +1 -1
  21. package/dist/core/table/constructTable.js +18 -15
  22. package/dist/core/table/constructTable.js.map +1 -1
  23. package/dist/core/table/coreTablesFeature.types.d.cts +29 -24
  24. package/dist/core/table/coreTablesFeature.types.d.ts +29 -24
  25. package/dist/core/table/coreTablesFeature.utils.cjs +2 -3
  26. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  27. package/dist/core/table/coreTablesFeature.utils.js +2 -3
  28. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  29. package/dist/index.cjs +0 -2
  30. package/dist/index.d.cts +1 -2
  31. package/dist/index.d.ts +1 -2
  32. package/dist/index.js +1 -2
  33. package/dist/reactivity.cjs +6 -0
  34. package/dist/reactivity.d.cts +4 -0
  35. package/dist/reactivity.d.ts +4 -0
  36. package/dist/reactivity.js +4 -0
  37. package/dist/types/TableFeatures.d.cts +1 -1
  38. package/dist/types/TableFeatures.d.ts +1 -1
  39. package/package.json +5 -1
  40. package/src/core/coreFeatures.ts +2 -0
  41. package/src/core/reactivity/constructReactivityBindings.ts +19 -0
  42. package/src/core/reactivity/coreReactivityFeature.types.ts +40 -0
  43. package/src/core/reactivity/coreReactivityFeature.utils.ts +29 -0
  44. package/src/core/table/constructTable.ts +44 -28
  45. package/src/core/table/coreTablesFeature.types.ts +29 -24
  46. package/src/core/table/coreTablesFeature.utils.ts +2 -3
  47. package/src/index.ts +0 -3
  48. package/src/reactivity.ts +3 -0
  49. package/src/types/Table.ts +1 -1
  50. package/src/types/TableFeatures.ts +7 -7
  51. package/dist/features/table-reactivity/tableReactivityFeature.cjs +0 -46
  52. package/dist/features/table-reactivity/tableReactivityFeature.cjs.map +0 -1
  53. package/dist/features/table-reactivity/tableReactivityFeature.d.cts +0 -12
  54. package/dist/features/table-reactivity/tableReactivityFeature.d.ts +0 -12
  55. package/dist/features/table-reactivity/tableReactivityFeature.js +0 -45
  56. package/dist/features/table-reactivity/tableReactivityFeature.js.map +0 -1
  57. package/src/features/table-reactivity/tableReactivityFeature.ts +0 -92
@@ -1 +1 @@
1
- {"version":3,"file":"coreFeatures.cjs","names":[],"sources":["../../src/core/coreFeatures.ts"],"sourcesContent":["import { coreCellsFeature } from './cells/coreCellsFeature'\nimport { coreColumnsFeature } from './columns/coreColumnsFeature'\nimport { coreHeadersFeature } from './headers/coreHeadersFeature'\nimport { coreRowModelsFeature } from './row-models/coreRowModelsFeature'\nimport { coreRowsFeature } from './rows/coreRowsFeature'\nimport { coreTablesFeature } from './table/coreTablesFeature'\n\nexport interface CoreFeatures {\n coreCellsFeature: typeof coreCellsFeature\n coreColumnsFeature: typeof coreColumnsFeature\n coreHeadersFeature: typeof coreHeadersFeature\n coreRowModelsFeature: typeof coreRowModelsFeature\n coreRowsFeature: typeof coreRowsFeature\n coreTablesFeature: typeof coreTablesFeature\n}\n\nexport const coreFeatures: CoreFeatures = {\n coreCellsFeature,\n coreColumnsFeature,\n coreHeadersFeature,\n coreRowModelsFeature,\n coreRowsFeature,\n coreTablesFeature,\n}\n"],"mappings":";;;;;;;;AAgBA,MAAa,eAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"coreFeatures.cjs","names":[],"sources":["../../src/core/coreFeatures.ts"],"sourcesContent":["import { coreCellsFeature } from './cells/coreCellsFeature'\nimport { coreColumnsFeature } from './columns/coreColumnsFeature'\nimport { coreHeadersFeature } from './headers/coreHeadersFeature'\nimport { coreRowModelsFeature } from './row-models/coreRowModelsFeature'\nimport { coreRowsFeature } from './rows/coreRowsFeature'\nimport { coreTablesFeature } from './table/coreTablesFeature'\nimport type { TableReactivityBindings } from '../reactivity'\n\nexport interface CoreFeatures {\n coreReativityFeature?: TableReactivityBindings\n coreCellsFeature: typeof coreCellsFeature\n coreColumnsFeature: typeof coreColumnsFeature\n coreHeadersFeature: typeof coreHeadersFeature\n coreRowModelsFeature: typeof coreRowModelsFeature\n coreRowsFeature: typeof coreRowsFeature\n coreTablesFeature: typeof coreTablesFeature\n}\n\nexport const coreFeatures: CoreFeatures = {\n coreCellsFeature,\n coreColumnsFeature,\n coreHeadersFeature,\n coreRowModelsFeature,\n coreRowsFeature,\n coreTablesFeature,\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,eAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -4,9 +4,10 @@ import { coreHeadersFeature } from "./headers/coreHeadersFeature.cjs";
4
4
  import { coreRowModelsFeature } from "./row-models/coreRowModelsFeature.cjs";
5
5
  import { coreRowsFeature } from "./rows/coreRowsFeature.cjs";
6
6
  import { coreTablesFeature } from "./table/coreTablesFeature.cjs";
7
-
7
+ import { TableReactivityBindings } from "./reactivity/coreReactivityFeature.types.cjs";
8
8
  //#region src/core/coreFeatures.d.ts
9
9
  interface CoreFeatures {
10
+ coreReativityFeature?: TableReactivityBindings;
10
11
  coreCellsFeature: typeof coreCellsFeature;
11
12
  coreColumnsFeature: typeof coreColumnsFeature;
12
13
  coreHeadersFeature: typeof coreHeadersFeature;
@@ -4,9 +4,10 @@ import { coreHeadersFeature } from "./headers/coreHeadersFeature.js";
4
4
  import { coreRowModelsFeature } from "./row-models/coreRowModelsFeature.js";
5
5
  import { coreRowsFeature } from "./rows/coreRowsFeature.js";
6
6
  import { coreTablesFeature } from "./table/coreTablesFeature.js";
7
-
7
+ import { TableReactivityBindings } from "./reactivity/coreReactivityFeature.types.js";
8
8
  //#region src/core/coreFeatures.d.ts
9
9
  interface CoreFeatures {
10
+ coreReativityFeature?: TableReactivityBindings;
10
11
  coreCellsFeature: typeof coreCellsFeature;
11
12
  coreColumnsFeature: typeof coreColumnsFeature;
12
13
  coreHeadersFeature: typeof coreHeadersFeature;
@@ -1 +1 @@
1
- {"version":3,"file":"coreFeatures.js","names":[],"sources":["../../src/core/coreFeatures.ts"],"sourcesContent":["import { coreCellsFeature } from './cells/coreCellsFeature'\nimport { coreColumnsFeature } from './columns/coreColumnsFeature'\nimport { coreHeadersFeature } from './headers/coreHeadersFeature'\nimport { coreRowModelsFeature } from './row-models/coreRowModelsFeature'\nimport { coreRowsFeature } from './rows/coreRowsFeature'\nimport { coreTablesFeature } from './table/coreTablesFeature'\n\nexport interface CoreFeatures {\n coreCellsFeature: typeof coreCellsFeature\n coreColumnsFeature: typeof coreColumnsFeature\n coreHeadersFeature: typeof coreHeadersFeature\n coreRowModelsFeature: typeof coreRowModelsFeature\n coreRowsFeature: typeof coreRowsFeature\n coreTablesFeature: typeof coreTablesFeature\n}\n\nexport const coreFeatures: CoreFeatures = {\n coreCellsFeature,\n coreColumnsFeature,\n coreHeadersFeature,\n coreRowModelsFeature,\n coreRowsFeature,\n coreTablesFeature,\n}\n"],"mappings":";;;;;;;;AAgBA,MAAa,eAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"coreFeatures.js","names":[],"sources":["../../src/core/coreFeatures.ts"],"sourcesContent":["import { coreCellsFeature } from './cells/coreCellsFeature'\nimport { coreColumnsFeature } from './columns/coreColumnsFeature'\nimport { coreHeadersFeature } from './headers/coreHeadersFeature'\nimport { coreRowModelsFeature } from './row-models/coreRowModelsFeature'\nimport { coreRowsFeature } from './rows/coreRowsFeature'\nimport { coreTablesFeature } from './table/coreTablesFeature'\nimport type { TableReactivityBindings } from '../reactivity'\n\nexport interface CoreFeatures {\n coreReativityFeature?: TableReactivityBindings\n coreCellsFeature: typeof coreCellsFeature\n coreColumnsFeature: typeof coreColumnsFeature\n coreHeadersFeature: typeof coreHeadersFeature\n coreRowModelsFeature: typeof coreRowModelsFeature\n coreRowsFeature: typeof coreRowsFeature\n coreTablesFeature: typeof coreTablesFeature\n}\n\nexport const coreFeatures: CoreFeatures = {\n coreCellsFeature,\n coreColumnsFeature,\n coreHeadersFeature,\n coreRowModelsFeature,\n coreRowsFeature,\n coreTablesFeature,\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,eAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -0,0 +1,19 @@
1
+ let _tanstack_store = require("@tanstack/store");
2
+
3
+ //#region src/core/reactivity/constructReactivityBindings.ts
4
+ function constructReactivityBindings() {
5
+ return {
6
+ batch: _tanstack_store.batch,
7
+ untrack: (fn) => fn(),
8
+ createReadonlyAtom: (fn, options) => {
9
+ return (0, _tanstack_store.createAtom)(() => fn(), { compare: options === null || options === void 0 ? void 0 : options.compare });
10
+ },
11
+ createWritableAtom: (value, options) => {
12
+ return (0, _tanstack_store.createAtom)(value, { compare: options === null || options === void 0 ? void 0 : options.compare });
13
+ }
14
+ };
15
+ }
16
+
17
+ //#endregion
18
+ exports.constructReactivityBindings = constructReactivityBindings;
19
+ //# sourceMappingURL=constructReactivityBindings.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructReactivityBindings.cjs","names":["batch"],"sources":["../../../src/core/reactivity/constructReactivityBindings.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/store'\nimport type { TableReactivityBindings } from './coreReactivityFeature.types'\n\nexport function constructReactivityBindings(): TableReactivityBindings {\n return {\n batch: batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: (fn, options) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: (value, options) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":";;;AAGA,SAAgB,8BAAuD;AACrE,QAAO;EACL,OAAOA;EACP,UAAU,OAAO,IAAI;EACrB,qBAAqB,IAAI,YAAY;AACnC,gDAAwB,IAAI,EAAE,EAC5B,2DAAS,QAAS,SACnB,CAAC;;EAEJ,qBAAqB,OAAO,YAAY;AACtC,0CAAkB,OAAO,EACvB,2DAAS,QAAS,SACnB,CAAC;;EAEL"}
@@ -0,0 +1,7 @@
1
+ import { TableReactivityBindings } from "./coreReactivityFeature.types.cjs";
2
+
3
+ //#region src/core/reactivity/constructReactivityBindings.d.ts
4
+ declare function constructReactivityBindings(): TableReactivityBindings;
5
+ //#endregion
6
+ export { constructReactivityBindings };
7
+ //# sourceMappingURL=constructReactivityBindings.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { TableReactivityBindings } from "./coreReactivityFeature.types.js";
2
+
3
+ //#region src/core/reactivity/constructReactivityBindings.d.ts
4
+ declare function constructReactivityBindings(): TableReactivityBindings;
5
+ //#endregion
6
+ export { constructReactivityBindings };
7
+ //# sourceMappingURL=constructReactivityBindings.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { batch, createAtom } from "@tanstack/store";
2
+
3
+ //#region src/core/reactivity/constructReactivityBindings.ts
4
+ function constructReactivityBindings() {
5
+ return {
6
+ batch,
7
+ untrack: (fn) => fn(),
8
+ createReadonlyAtom: (fn, options) => {
9
+ return createAtom(() => fn(), { compare: options === null || options === void 0 ? void 0 : options.compare });
10
+ },
11
+ createWritableAtom: (value, options) => {
12
+ return createAtom(value, { compare: options === null || options === void 0 ? void 0 : options.compare });
13
+ }
14
+ };
15
+ }
16
+
17
+ //#endregion
18
+ export { constructReactivityBindings };
19
+ //# sourceMappingURL=constructReactivityBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructReactivityBindings.js","names":[],"sources":["../../../src/core/reactivity/constructReactivityBindings.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/store'\nimport type { TableReactivityBindings } from './coreReactivityFeature.types'\n\nexport function constructReactivityBindings(): TableReactivityBindings {\n return {\n batch: batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: (fn, options) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: (value, options) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":";;;AAGA,SAAgB,8BAAuD;AACrE,QAAO;EACE;EACP,UAAU,OAAO,IAAI;EACrB,qBAAqB,IAAI,YAAY;AACnC,UAAO,iBAAiB,IAAI,EAAE,EAC5B,2DAAS,QAAS,SACnB,CAAC;;EAEJ,qBAAqB,OAAO,YAAY;AACtC,UAAO,WAAW,OAAO,EACvB,2DAAS,QAAS,SACnB,CAAC;;EAEL"}
@@ -0,0 +1,37 @@
1
+ import { Atom, AtomOptions, ReadonlyAtom } from "@tanstack/store";
2
+
3
+ //#region src/core/reactivity/coreReactivityFeature.types.d.ts
4
+ interface TableAtomOptions<T> extends AtomOptions<T> {
5
+ /**
6
+ * A debug name for the atom, useful for debugging.
7
+ */
8
+ debugName: string;
9
+ }
10
+ /**
11
+ * Framework reactivity bindings used by table-core.
12
+ *
13
+ * Adapters (React, Solid, Vue, etc.) provide concrete implementations so
14
+ * core features can create derived/writable atoms and integrate with their
15
+ * scheduling primitives.
16
+ */
17
+ interface TableReactivityBindings {
18
+ /**
19
+ * Creates a writable atom with an initial value.
20
+ */
21
+ createWritableAtom: <T>(initialValue: T, options?: TableAtomOptions<T>) => Atom<T>;
22
+ /**
23
+ * Creates a readonly/derived atom from a compute function.
24
+ */
25
+ createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => ReadonlyAtom<T>;
26
+ /**
27
+ * Evaluates a function without tracking reactive dependencies.
28
+ */
29
+ untrack: <T>(fn: () => T) => T;
30
+ /**
31
+ * Batches reactive updates to avoid intermediate recomputation.
32
+ */
33
+ batch: (fn: () => void) => void;
34
+ }
35
+ //#endregion
36
+ export { TableAtomOptions, TableReactivityBindings };
37
+ //# sourceMappingURL=coreReactivityFeature.types.d.cts.map
@@ -0,0 +1,37 @@
1
+ import { Atom, AtomOptions, ReadonlyAtom } from "@tanstack/store";
2
+
3
+ //#region src/core/reactivity/coreReactivityFeature.types.d.ts
4
+ interface TableAtomOptions<T> extends AtomOptions<T> {
5
+ /**
6
+ * A debug name for the atom, useful for debugging.
7
+ */
8
+ debugName: string;
9
+ }
10
+ /**
11
+ * Framework reactivity bindings used by table-core.
12
+ *
13
+ * Adapters (React, Solid, Vue, etc.) provide concrete implementations so
14
+ * core features can create derived/writable atoms and integrate with their
15
+ * scheduling primitives.
16
+ */
17
+ interface TableReactivityBindings {
18
+ /**
19
+ * Creates a writable atom with an initial value.
20
+ */
21
+ createWritableAtom: <T>(initialValue: T, options?: TableAtomOptions<T>) => Atom<T>;
22
+ /**
23
+ * Creates a readonly/derived atom from a compute function.
24
+ */
25
+ createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => ReadonlyAtom<T>;
26
+ /**
27
+ * Evaluates a function without tracking reactive dependencies.
28
+ */
29
+ untrack: <T>(fn: () => T) => T;
30
+ /**
31
+ * Batches reactive updates to avoid intermediate recomputation.
32
+ */
33
+ batch: (fn: () => void) => void;
34
+ }
35
+ //#endregion
36
+ export { TableAtomOptions, TableReactivityBindings };
37
+ //# sourceMappingURL=coreReactivityFeature.types.d.ts.map
@@ -0,0 +1,19 @@
1
+
2
+ //#region src/core/reactivity/coreReactivityFeature.utils.ts
3
+ /**
4
+ * Bridges atom instances to the `Store`/`ReadonlyStore` API by exposing
5
+ * a `state` getter backed by `atom.get()`, and wiring `setState` for
6
+ * writable atoms.
7
+ */
8
+ function atomToStore(atom) {
9
+ const store = atom;
10
+ Object.defineProperty(atom, "state", { get() {
11
+ return atom.get();
12
+ } });
13
+ if ("set" in atom) store.setState = atom.set.bind(atom);
14
+ return store;
15
+ }
16
+
17
+ //#endregion
18
+ exports.atomToStore = atomToStore;
19
+ //# sourceMappingURL=coreReactivityFeature.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coreReactivityFeature.utils.cjs","names":[],"sources":["../../../src/core/reactivity/coreReactivityFeature.utils.ts"],"sourcesContent":["import type { Atom, ReadonlyAtom, ReadonlyStore, Store } from '@tanstack/store'\n\n/**\n * Converts a writable atom to the store-compatible shape expected by core.\n */\nexport function atomToStore<T>(atom: Atom<T>): Store<T>\n/**\n * Converts a readonly atom to a readonly store-compatible shape.\n */\nexport function atomToStore<T>(atom: ReadonlyAtom<T>): ReadonlyStore<T>\n/**\n * Bridges atom instances to the `Store`/`ReadonlyStore` API by exposing\n * a `state` getter backed by `atom.get()`, and wiring `setState` for\n * writable atoms.\n */\nexport function atomToStore<T>(\n atom: Atom<T> | ReadonlyAtom<T>,\n): Store<T> | ReadonlyStore<T> {\n const store: Store<T> = atom as Store<T>\n Object.defineProperty(atom, 'state', {\n get() {\n return atom.get()\n },\n })\n if ('set' in atom) {\n store.setState = atom.set.bind(atom)\n }\n return store\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,YACd,MAC6B;CAC7B,MAAM,QAAkB;AACxB,QAAO,eAAe,MAAM,SAAS,EACnC,MAAM;AACJ,SAAO,KAAK,KAAK;IAEpB,CAAC;AACF,KAAI,SAAS,KACX,OAAM,WAAW,KAAK,IAAI,KAAK,KAAK;AAEtC,QAAO"}
@@ -0,0 +1,14 @@
1
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/store";
2
+
3
+ //#region src/core/reactivity/coreReactivityFeature.utils.d.ts
4
+ /**
5
+ * Converts a writable atom to the store-compatible shape expected by core.
6
+ */
7
+ declare function atomToStore<T>(atom: Atom<T>): Store<T>;
8
+ /**
9
+ * Converts a readonly atom to a readonly store-compatible shape.
10
+ */
11
+ declare function atomToStore<T>(atom: ReadonlyAtom<T>): ReadonlyStore<T>;
12
+ //#endregion
13
+ export { atomToStore };
14
+ //# sourceMappingURL=coreReactivityFeature.utils.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/store";
2
+
3
+ //#region src/core/reactivity/coreReactivityFeature.utils.d.ts
4
+ /**
5
+ * Converts a writable atom to the store-compatible shape expected by core.
6
+ */
7
+ declare function atomToStore<T>(atom: Atom<T>): Store<T>;
8
+ /**
9
+ * Converts a readonly atom to a readonly store-compatible shape.
10
+ */
11
+ declare function atomToStore<T>(atom: ReadonlyAtom<T>): ReadonlyStore<T>;
12
+ //#endregion
13
+ export { atomToStore };
14
+ //# sourceMappingURL=coreReactivityFeature.utils.d.ts.map
@@ -0,0 +1,18 @@
1
+ //#region src/core/reactivity/coreReactivityFeature.utils.ts
2
+ /**
3
+ * Bridges atom instances to the `Store`/`ReadonlyStore` API by exposing
4
+ * a `state` getter backed by `atom.get()`, and wiring `setState` for
5
+ * writable atoms.
6
+ */
7
+ function atomToStore(atom) {
8
+ const store = atom;
9
+ Object.defineProperty(atom, "state", { get() {
10
+ return atom.get();
11
+ } });
12
+ if ("set" in atom) store.setState = atom.set.bind(atom);
13
+ return store;
14
+ }
15
+
16
+ //#endregion
17
+ export { atomToStore };
18
+ //# sourceMappingURL=coreReactivityFeature.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coreReactivityFeature.utils.js","names":[],"sources":["../../../src/core/reactivity/coreReactivityFeature.utils.ts"],"sourcesContent":["import type { Atom, ReadonlyAtom, ReadonlyStore, Store } from '@tanstack/store'\n\n/**\n * Converts a writable atom to the store-compatible shape expected by core.\n */\nexport function atomToStore<T>(atom: Atom<T>): Store<T>\n/**\n * Converts a readonly atom to a readonly store-compatible shape.\n */\nexport function atomToStore<T>(atom: ReadonlyAtom<T>): ReadonlyStore<T>\n/**\n * Bridges atom instances to the `Store`/`ReadonlyStore` API by exposing\n * a `state` getter backed by `atom.get()`, and wiring `setState` for\n * writable atoms.\n */\nexport function atomToStore<T>(\n atom: Atom<T> | ReadonlyAtom<T>,\n): Store<T> | ReadonlyStore<T> {\n const store: Store<T> = atom as Store<T>\n Object.defineProperty(atom, 'state', {\n get() {\n return atom.get()\n },\n })\n if ('set' in atom) {\n store.setState = atom.set.bind(atom)\n }\n return store\n}\n"],"mappings":";;;;;;AAeA,SAAgB,YACd,MAC6B;CAC7B,MAAM,QAAkB;AACxB,QAAO,eAAe,MAAM,SAAS,EACnC,MAAM;AACJ,SAAO,KAAK,KAAK;IAEpB,CAAC;AACF,KAAI,SAAS,KACX,OAAM,WAAW,KAAK,IAAI,KAAK,KAAK;AAEtC,QAAO"}
@@ -1,6 +1,6 @@
1
1
  const require_utils = require('../../utils.cjs');
2
2
  const require_coreFeatures = require('../coreFeatures.cjs');
3
- let _tanstack_store = require("@tanstack/store");
3
+ const require_coreReactivityFeature_utils = require('../reactivity/coreReactivityFeature.utils.cjs');
4
4
 
5
5
  //#region src/core/table/constructTable.ts
6
6
  function getInitialTableState(features, initialState = {}) {
@@ -11,7 +11,9 @@ function getInitialTableState(features, initialState = {}) {
11
11
  return require_utils.cloneState(initialState);
12
12
  }
13
13
  function constructTable(tableOptions) {
14
+ const _reactivity = tableOptions._features.coreReativityFeature;
14
15
  const table = {
16
+ _reactivity,
15
17
  _features: {
16
18
  ...require_coreFeatures.coreFeatures,
17
19
  ...tableOptions._features
@@ -19,41 +21,42 @@ function constructTable(tableOptions) {
19
21
  _rowModels: {},
20
22
  _rowModelFns: {},
21
23
  get options() {
22
- return this.optionsStore.state;
24
+ return this.optionsStore.get();
23
25
  },
24
26
  set options(value) {
25
- this.optionsStore.setState(() => value);
27
+ this.optionsStore.set(() => value);
26
28
  },
27
29
  baseAtoms: {},
28
30
  atoms: {}
29
31
  };
30
32
  const featuresList = Object.values(table._features);
31
- table.optionsStore = (0, _tanstack_store.createStore)({
32
- ...featuresList.reduce((obj, feature) => {
33
- var _feature$getDefaultTa;
34
- return Object.assign(obj, (_feature$getDefaultTa = feature.getDefaultTableOptions) === null || _feature$getDefaultTa === void 0 ? void 0 : _feature$getDefaultTa.call(feature, table));
35
- }, {}),
33
+ const defaultOptions = featuresList.reduce((obj, feature) => {
34
+ var _feature$getDefaultTa;
35
+ return Object.assign(obj, (_feature$getDefaultTa = feature.getDefaultTableOptions) === null || _feature$getDefaultTa === void 0 ? void 0 : _feature$getDefaultTa.call(feature, table));
36
+ }, {});
37
+ table.optionsStore = _reactivity.createWritableAtom({
38
+ ...defaultOptions,
36
39
  ...tableOptions
37
- });
40
+ }, { debugName: "table/optionsStore" });
38
41
  table.initialState = getInitialTableState(table._features, table.options.initialState);
39
42
  const stateKeys = Object.keys(table.initialState);
40
43
  for (const key of stateKeys) {
41
- table.baseAtoms[key] = (0, _tanstack_store.createAtom)(table.initialState[key]);
42
- table.atoms[key] = (0, _tanstack_store.createAtom)(() => {
44
+ table.baseAtoms[key] = _reactivity.createWritableAtom(table.initialState[key], { debugName: `table/baseAtoms/${key}` });
45
+ table.atoms[key] = _reactivity.createReadonlyAtom(() => {
43
46
  var _opts$atoms;
44
- const opts = table.optionsStore.state;
47
+ const opts = table.optionsStore.get();
45
48
  const state = opts.state;
46
49
  if (key in (state ?? {})) return state[key];
47
50
  const externalAtom = (_opts$atoms = opts.atoms) === null || _opts$atoms === void 0 ? void 0 : _opts$atoms[key];
48
51
  if (externalAtom) return externalAtom.get();
49
52
  return table.baseAtoms[key].get();
50
- });
53
+ }, { debugName: `table/atoms/${key}` });
51
54
  }
52
- table.store = (0, _tanstack_store.createStore)(() => {
55
+ table.store = require_coreReactivityFeature_utils.atomToStore(_reactivity.createReadonlyAtom(() => {
53
56
  const snapshot = {};
54
57
  for (const key of stateKeys) snapshot[key] = table.atoms[key].get();
55
58
  return snapshot;
56
- });
59
+ }, { debugName: "table/store" }));
57
60
  if (process.env.NODE_ENV === "development" && (tableOptions.debugAll || tableOptions.debugTable)) {
58
61
  const features = Object.keys(table._features);
59
62
  const rowModels = Object.keys(table.options._rowModels || {});
@@ -1 +1 @@
1
- {"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { createAtom, createStore } from '@tanstack/store'\nimport { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState } from '../../types/TableState'\n\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const table = {\n _features: { ...coreFeatures, ...tableOptions._features },\n _rowModels: {},\n _rowModelFns: {},\n get options() {\n return this.optionsStore.state\n },\n set options(value) {\n this.optionsStore.setState(() => value)\n },\n baseAtoms: {},\n atoms: {},\n } as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature<{}>> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n table.optionsStore = createStore({\n ...defaultOptions,\n ...tableOptions,\n })\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState<TFeatures>\n >\n\n for (const key of stateKeys) {\n // create writable base atom\n table.baseAtoms[key] = createAtom(table.initialState[key]) as any\n\n // create readonly derived atom: on each get(), read current options (state, then external atom, then base)\n ;(table.atoms as any)[key] = createAtom(() => {\n // Reading optionsStore.state keeps this reactive to setOptions\n const opts = table.optionsStore.state\n const state = opts.state\n if (key in (state ?? {})) {\n return state![key]\n }\n const externalAtom = opts.atoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key].get()\n })\n }\n\n table.store = createStore(() => {\n const snapshot = {} as TableState<TFeatures>\n for (const key of stateKeys) {\n snapshot[key] = table.atoms[key].get()\n }\n return snapshot\n })\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.keys(table.options._rowModels || {})\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}`,\n )\n }\n\n for (const feature of featuresList) {\n feature.constructTableAPIs?.(table)\n }\n\n return table\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,eAA2D,EAAE,EACtC;AACvB,QAAO,OAAO,SAAS,CAAC,SAAS,YAAY;;AAC3C,2CAAe,QAAQ,6GAAkB,aAAa,KAAI;GAC1D;AACF,QAAOA,yBAAW,aAAa;;AAGjC,SAAgB,eAGd,cAAuE;CACvE,MAAM,QAAQ;EACZ,WAAW;GAAE,GAAGC;GAAc,GAAG,aAAa;GAAW;EACzD,YAAY,EAAE;EACd,cAAc,EAAE;EAChB,IAAI,UAAU;AACZ,UAAO,KAAK,aAAa;;EAE3B,IAAI,QAAQ,OAAO;AACjB,QAAK,aAAa,eAAe,MAAM;;EAEzC,WAAW,EAAE;EACb,OAAO,EAAE;EACV;CAED,MAAM,eAAwC,OAAO,OAAO,MAAM,UAAU;AAM5E,OAAM,gDAA2B;EAC/B,GALqB,aAAa,QAAQ,KAAK,YAAY;;AAC3D,UAAO,OAAO,OAAO,8BAAK,QAAQ,oHAAyB,MAAM,CAAC;KACjE,EAAE,CAGc;EACjB,GAAG;EACJ,CAAC;AAEF,OAAM,eAAe,qBACnB,MAAM,WACN,MAAM,QAAQ,aACf;CAED,MAAM,YAAY,OAAO,KAAK,MAAM,aAAa;AAIjD,MAAK,MAAM,OAAO,WAAW;AAE3B,QAAM,UAAU,uCAAkB,MAAM,aAAa,KAAK;AAGzD,EAAC,MAAM,MAAc,6CAAwB;;GAE5C,MAAM,OAAO,MAAM,aAAa;GAChC,MAAM,QAAQ,KAAK;AACnB,OAAI,QAAQ,SAAS,EAAE,EACrB,QAAO,MAAO;GAEhB,MAAM,8BAAe,KAAK,iEAAQ;AAClC,OAAI,aACF,QAAO,aAAa,KAAK;AAE3B,UAAO,MAAM,UAAU,KAAK,KAAK;IACjC;;AAGJ,OAAM,+CAA0B;EAC9B,MAAM,WAAW,EAAE;AACnB,OAAK,MAAM,OAAO,UAChB,UAAS,OAAO,MAAM,MAAM,KAAK,KAAK;AAExC,SAAO;GACP;AAEF,KACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,UAAU;EAC7C,MAAM,YAAY,OAAO,KAAK,MAAM,QAAQ,cAAc,EAAE,CAAC;EAC7D,MAAM,SAAS,OAAO,KAAK,MAAM,aAAa;AAE9C,UAAQ,IACN;;gBAEU,SAAS,KAAK,mBAAmB,CAAC;;gBAElC,UAAU,SAAS,UAAU,KAAK,mBAAmB,GAAG,SAAS;;gBAEjE,OAAO,KAAK,mBAAmB,GAC1C;;AAGH,MAAK,MAAM,WAAW,cAAc;;AAClC,mCAAQ,wGAAqB,MAAM;;AAGrC,QAAO"}
1
+ {"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures","atomToStore"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState } from '../../types/TableState'\n\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions._features.coreReativityFeature!\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...tableOptions._features },\n _rowModels: {},\n _rowModelFns: {},\n get options() {\n return this.optionsStore.get()\n },\n set options(value) {\n this.optionsStore.set(() => value)\n },\n baseAtoms: {},\n atoms: {},\n } as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature<{}>> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >({ ...defaultOptions, ...tableOptions }, { debugName: 'table/optionsStore' })\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState<TFeatures>\n >\n\n for (const key of stateKeys) {\n // create writable base atom\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read current options (state, then external atom, then base)\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n // Reading optionsStore.get() keeps this reactive to setOptions\n const opts = table.optionsStore.get()\n const state = opts.state\n if (key in (state ?? {})) {\n return state![key]\n }\n const externalAtom = opts.atoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key].get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures>\n for (const key of stateKeys) {\n snapshot[key] = table.atoms[key].get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.keys(table.options._rowModels || {})\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}`,\n )\n }\n\n for (const feature of featuresList) {\n feature.constructTableAPIs?.(table)\n }\n\n return table\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,eAA2D,EAAE,EACtC;AACvB,QAAO,OAAO,SAAS,CAAC,SAAS,YAAY;;AAC3C,2CAAe,QAAQ,6GAAkB,aAAa,KAAI;GAC1D;AACF,QAAOA,yBAAW,aAAa;;AAGjC,SAAgB,eAGd,cAAuE;CACvE,MAAM,cAAc,aAAa,UAAU;CAE3C,MAAM,QAAQ;EACZ;EACA,WAAW;GAAE,GAAGC;GAAc,GAAG,aAAa;GAAW;EACzD,YAAY,EAAE;EACd,cAAc,EAAE;EAChB,IAAI,UAAU;AACZ,UAAO,KAAK,aAAa,KAAK;;EAEhC,IAAI,QAAQ,OAAO;AACjB,QAAK,aAAa,UAAU,MAAM;;EAEpC,WAAW,EAAE;EACb,OAAO,EAAE;EACV;CAED,MAAM,eAAwC,OAAO,OAAO,MAAM,UAAU;CAE5E,MAAM,iBAAiB,aAAa,QAAQ,KAAK,YAAY;;AAC3D,SAAO,OAAO,OAAO,8BAAK,QAAQ,oHAAyB,MAAM,CAAC;IACjE,EAAE,CAAC;AAGN,OAAM,eAAe,YAAY,mBAE/B;EAAE,GAAG;EAAgB,GAAG;EAAc,EAAE,EAAE,WAAW,sBAAsB,CAAC;AAE9E,OAAM,eAAe,qBACnB,MAAM,WACN,MAAM,QAAQ,aACf;CAED,MAAM,YAAY,OAAO,KAAK,MAAM,aAAa;AAIjD,MAAK,MAAM,OAAO,WAAW;AAE3B,QAAM,UAAU,OAAO,YAAY,mBACjC,MAAM,aAAa,MACnB,EACE,WAAW,mBAAmB,OAC/B,CACF;AAGA,EAAC,MAAM,MAAc,OAAO,YAAY,yBACjC;;GAEJ,MAAM,OAAO,MAAM,aAAa,KAAK;GACrC,MAAM,QAAQ,KAAK;AACnB,OAAI,QAAQ,SAAS,EAAE,EACrB,QAAO,MAAO;GAEhB,MAAM,8BAAe,KAAK,iEAAQ;AAClC,OAAI,aACF,QAAO,aAAa,KAAK;AAE3B,UAAO,MAAM,UAAU,KAAK,KAAK;KAEnC,EAAE,WAAW,eAAe,OAAO,CACpC;;AAGH,OAAM,QAAQC,gDACZ,YAAY,yBACJ;EACJ,MAAM,WAAW,EAAE;AACnB,OAAK,MAAM,OAAO,UAChB,UAAS,OAAO,MAAM,MAAM,KAAK,KAAK;AAExC,SAAO;IAET,EAAE,WAAW,eAAe,CAC7B,CACF;AAED,KACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,UAAU;EAC7C,MAAM,YAAY,OAAO,KAAK,MAAM,QAAQ,cAAc,EAAE,CAAC;EAC7D,MAAM,SAAS,OAAO,KAAK,MAAM,aAAa;AAE9C,UAAQ,IACN;;gBAEU,SAAS,KAAK,mBAAmB,CAAC;;gBAElC,UAAU,SAAS,UAAU,KAAK,mBAAmB,GAAG,SAAS;;gBAEjE,OAAO,KAAK,mBAAmB,GAC1C;;AAGH,MAAK,MAAM,WAAW,cAAc;;AAClC,mCAAQ,wGAAqB,MAAM;;AAGrC,QAAO"}
@@ -1,6 +1,6 @@
1
1
  import { cloneState } from "../../utils.js";
2
2
  import { coreFeatures } from "../coreFeatures.js";
3
- import { createAtom, createStore } from "@tanstack/store";
3
+ import { atomToStore } from "../reactivity/coreReactivityFeature.utils.js";
4
4
 
5
5
  //#region src/core/table/constructTable.ts
6
6
  function getInitialTableState(features, initialState = {}) {
@@ -11,7 +11,9 @@ function getInitialTableState(features, initialState = {}) {
11
11
  return cloneState(initialState);
12
12
  }
13
13
  function constructTable(tableOptions) {
14
+ const _reactivity = tableOptions._features.coreReativityFeature;
14
15
  const table = {
16
+ _reactivity,
15
17
  _features: {
16
18
  ...coreFeatures,
17
19
  ...tableOptions._features
@@ -19,41 +21,42 @@ function constructTable(tableOptions) {
19
21
  _rowModels: {},
20
22
  _rowModelFns: {},
21
23
  get options() {
22
- return this.optionsStore.state;
24
+ return this.optionsStore.get();
23
25
  },
24
26
  set options(value) {
25
- this.optionsStore.setState(() => value);
27
+ this.optionsStore.set(() => value);
26
28
  },
27
29
  baseAtoms: {},
28
30
  atoms: {}
29
31
  };
30
32
  const featuresList = Object.values(table._features);
31
- table.optionsStore = createStore({
32
- ...featuresList.reduce((obj, feature) => {
33
- var _feature$getDefaultTa;
34
- return Object.assign(obj, (_feature$getDefaultTa = feature.getDefaultTableOptions) === null || _feature$getDefaultTa === void 0 ? void 0 : _feature$getDefaultTa.call(feature, table));
35
- }, {}),
33
+ const defaultOptions = featuresList.reduce((obj, feature) => {
34
+ var _feature$getDefaultTa;
35
+ return Object.assign(obj, (_feature$getDefaultTa = feature.getDefaultTableOptions) === null || _feature$getDefaultTa === void 0 ? void 0 : _feature$getDefaultTa.call(feature, table));
36
+ }, {});
37
+ table.optionsStore = _reactivity.createWritableAtom({
38
+ ...defaultOptions,
36
39
  ...tableOptions
37
- });
40
+ }, { debugName: "table/optionsStore" });
38
41
  table.initialState = getInitialTableState(table._features, table.options.initialState);
39
42
  const stateKeys = Object.keys(table.initialState);
40
43
  for (const key of stateKeys) {
41
- table.baseAtoms[key] = createAtom(table.initialState[key]);
42
- table.atoms[key] = createAtom(() => {
44
+ table.baseAtoms[key] = _reactivity.createWritableAtom(table.initialState[key], { debugName: `table/baseAtoms/${key}` });
45
+ table.atoms[key] = _reactivity.createReadonlyAtom(() => {
43
46
  var _opts$atoms;
44
- const opts = table.optionsStore.state;
47
+ const opts = table.optionsStore.get();
45
48
  const state = opts.state;
46
49
  if (key in (state ?? {})) return state[key];
47
50
  const externalAtom = (_opts$atoms = opts.atoms) === null || _opts$atoms === void 0 ? void 0 : _opts$atoms[key];
48
51
  if (externalAtom) return externalAtom.get();
49
52
  return table.baseAtoms[key].get();
50
- });
53
+ }, { debugName: `table/atoms/${key}` });
51
54
  }
52
- table.store = createStore(() => {
55
+ table.store = atomToStore(_reactivity.createReadonlyAtom(() => {
53
56
  const snapshot = {};
54
57
  for (const key of stateKeys) snapshot[key] = table.atoms[key].get();
55
58
  return snapshot;
56
- });
59
+ }, { debugName: "table/store" }));
57
60
  if (process.env.NODE_ENV === "development" && (tableOptions.debugAll || tableOptions.debugTable)) {
58
61
  const features = Object.keys(table._features);
59
62
  const rowModels = Object.keys(table.options._rowModels || {});
@@ -1 +1 @@
1
- {"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { createAtom, createStore } from '@tanstack/store'\nimport { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState } from '../../types/TableState'\n\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const table = {\n _features: { ...coreFeatures, ...tableOptions._features },\n _rowModels: {},\n _rowModelFns: {},\n get options() {\n return this.optionsStore.state\n },\n set options(value) {\n this.optionsStore.setState(() => value)\n },\n baseAtoms: {},\n atoms: {},\n } as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature<{}>> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n table.optionsStore = createStore({\n ...defaultOptions,\n ...tableOptions,\n })\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState<TFeatures>\n >\n\n for (const key of stateKeys) {\n // create writable base atom\n table.baseAtoms[key] = createAtom(table.initialState[key]) as any\n\n // create readonly derived atom: on each get(), read current options (state, then external atom, then base)\n ;(table.atoms as any)[key] = createAtom(() => {\n // Reading optionsStore.state keeps this reactive to setOptions\n const opts = table.optionsStore.state\n const state = opts.state\n if (key in (state ?? {})) {\n return state![key]\n }\n const externalAtom = opts.atoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key].get()\n })\n }\n\n table.store = createStore(() => {\n const snapshot = {} as TableState<TFeatures>\n for (const key of stateKeys) {\n snapshot[key] = table.atoms[key].get()\n }\n return snapshot\n })\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.keys(table.options._rowModels || {})\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}`,\n )\n }\n\n for (const feature of featuresList) {\n feature.constructTableAPIs?.(table)\n }\n\n return table\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,eAA2D,EAAE,EACtC;AACvB,QAAO,OAAO,SAAS,CAAC,SAAS,YAAY;;AAC3C,2CAAe,QAAQ,6GAAkB,aAAa,KAAI;GAC1D;AACF,QAAO,WAAW,aAAa;;AAGjC,SAAgB,eAGd,cAAuE;CACvE,MAAM,QAAQ;EACZ,WAAW;GAAE,GAAG;GAAc,GAAG,aAAa;GAAW;EACzD,YAAY,EAAE;EACd,cAAc,EAAE;EAChB,IAAI,UAAU;AACZ,UAAO,KAAK,aAAa;;EAE3B,IAAI,QAAQ,OAAO;AACjB,QAAK,aAAa,eAAe,MAAM;;EAEzC,WAAW,EAAE;EACb,OAAO,EAAE;EACV;CAED,MAAM,eAAwC,OAAO,OAAO,MAAM,UAAU;AAM5E,OAAM,eAAe,YAAY;EAC/B,GALqB,aAAa,QAAQ,KAAK,YAAY;;AAC3D,UAAO,OAAO,OAAO,8BAAK,QAAQ,oHAAyB,MAAM,CAAC;KACjE,EAAE,CAGc;EACjB,GAAG;EACJ,CAAC;AAEF,OAAM,eAAe,qBACnB,MAAM,WACN,MAAM,QAAQ,aACf;CAED,MAAM,YAAY,OAAO,KAAK,MAAM,aAAa;AAIjD,MAAK,MAAM,OAAO,WAAW;AAE3B,QAAM,UAAU,OAAO,WAAW,MAAM,aAAa,KAAK;AAGzD,EAAC,MAAM,MAAc,OAAO,iBAAiB;;GAE5C,MAAM,OAAO,MAAM,aAAa;GAChC,MAAM,QAAQ,KAAK;AACnB,OAAI,QAAQ,SAAS,EAAE,EACrB,QAAO,MAAO;GAEhB,MAAM,8BAAe,KAAK,iEAAQ;AAClC,OAAI,aACF,QAAO,aAAa,KAAK;AAE3B,UAAO,MAAM,UAAU,KAAK,KAAK;IACjC;;AAGJ,OAAM,QAAQ,kBAAkB;EAC9B,MAAM,WAAW,EAAE;AACnB,OAAK,MAAM,OAAO,UAChB,UAAS,OAAO,MAAM,MAAM,KAAK,KAAK;AAExC,SAAO;GACP;AAEF,KACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,UAAU;EAC7C,MAAM,YAAY,OAAO,KAAK,MAAM,QAAQ,cAAc,EAAE,CAAC;EAC7D,MAAM,SAAS,OAAO,KAAK,MAAM,aAAa;AAE9C,UAAQ,IACN;;gBAEU,SAAS,KAAK,mBAAmB,CAAC;;gBAElC,UAAU,SAAS,UAAU,KAAK,mBAAmB,GAAG,SAAS;;gBAEjE,OAAO,KAAK,mBAAmB,GAC1C;;AAGH,MAAK,MAAM,WAAW,cAAc;;AAClC,mCAAQ,wGAAqB,MAAM;;AAGrC,QAAO"}
1
+ {"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState } from '../../types/TableState'\n\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions._features.coreReativityFeature!\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...tableOptions._features },\n _rowModels: {},\n _rowModelFns: {},\n get options() {\n return this.optionsStore.get()\n },\n set options(value) {\n this.optionsStore.set(() => value)\n },\n baseAtoms: {},\n atoms: {},\n } as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature<{}>> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >({ ...defaultOptions, ...tableOptions }, { debugName: 'table/optionsStore' })\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState<TFeatures>\n >\n\n for (const key of stateKeys) {\n // create writable base atom\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read current options (state, then external atom, then base)\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n // Reading optionsStore.get() keeps this reactive to setOptions\n const opts = table.optionsStore.get()\n const state = opts.state\n if (key in (state ?? {})) {\n return state![key]\n }\n const externalAtom = opts.atoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key].get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures>\n for (const key of stateKeys) {\n snapshot[key] = table.atoms[key].get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.keys(table.options._rowModels || {})\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}`,\n )\n }\n\n for (const feature of featuresList) {\n feature.constructTableAPIs?.(table)\n }\n\n return table\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,eAA2D,EAAE,EACtC;AACvB,QAAO,OAAO,SAAS,CAAC,SAAS,YAAY;;AAC3C,2CAAe,QAAQ,6GAAkB,aAAa,KAAI;GAC1D;AACF,QAAO,WAAW,aAAa;;AAGjC,SAAgB,eAGd,cAAuE;CACvE,MAAM,cAAc,aAAa,UAAU;CAE3C,MAAM,QAAQ;EACZ;EACA,WAAW;GAAE,GAAG;GAAc,GAAG,aAAa;GAAW;EACzD,YAAY,EAAE;EACd,cAAc,EAAE;EAChB,IAAI,UAAU;AACZ,UAAO,KAAK,aAAa,KAAK;;EAEhC,IAAI,QAAQ,OAAO;AACjB,QAAK,aAAa,UAAU,MAAM;;EAEpC,WAAW,EAAE;EACb,OAAO,EAAE;EACV;CAED,MAAM,eAAwC,OAAO,OAAO,MAAM,UAAU;CAE5E,MAAM,iBAAiB,aAAa,QAAQ,KAAK,YAAY;;AAC3D,SAAO,OAAO,OAAO,8BAAK,QAAQ,oHAAyB,MAAM,CAAC;IACjE,EAAE,CAAC;AAGN,OAAM,eAAe,YAAY,mBAE/B;EAAE,GAAG;EAAgB,GAAG;EAAc,EAAE,EAAE,WAAW,sBAAsB,CAAC;AAE9E,OAAM,eAAe,qBACnB,MAAM,WACN,MAAM,QAAQ,aACf;CAED,MAAM,YAAY,OAAO,KAAK,MAAM,aAAa;AAIjD,MAAK,MAAM,OAAO,WAAW;AAE3B,QAAM,UAAU,OAAO,YAAY,mBACjC,MAAM,aAAa,MACnB,EACE,WAAW,mBAAmB,OAC/B,CACF;AAGA,EAAC,MAAM,MAAc,OAAO,YAAY,yBACjC;;GAEJ,MAAM,OAAO,MAAM,aAAa,KAAK;GACrC,MAAM,QAAQ,KAAK;AACnB,OAAI,QAAQ,SAAS,EAAE,EACrB,QAAO,MAAO;GAEhB,MAAM,8BAAe,KAAK,iEAAQ;AAClC,OAAI,aACF,QAAO,aAAa,KAAK;AAE3B,UAAO,MAAM,UAAU,KAAK,KAAK;KAEnC,EAAE,WAAW,eAAe,OAAO,CACpC;;AAGH,OAAM,QAAQ,YACZ,YAAY,yBACJ;EACJ,MAAM,WAAW,EAAE;AACnB,OAAK,MAAM,OAAO,UAChB,UAAS,OAAO,MAAM,MAAM,KAAK,KAAK;AAExC,SAAO;IAET,EAAE,WAAW,eAAe,CAC7B,CACF;AAED,KACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,UAAU;EAC7C,MAAM,YAAY,OAAO,KAAK,MAAM,QAAQ,cAAc,EAAE,CAAC;EAC7D,MAAM,SAAS,OAAO,KAAK,MAAM,aAAa;AAE9C,UAAQ,IACN;;gBAEU,SAAS,KAAK,mBAAmB,CAAC;;gBAElC,UAAU,SAAS,UAAU,KAAK,mBAAmB,GAAG,SAAS;;gBAEjE,OAAO,KAAK,mBAAmB,GAC1C;;AAGH,MAAK,MAAM,WAAW,cAAc;;AAClC,mCAAQ,wGAAqB,MAAM;;AAGrC,QAAO"}
@@ -1,11 +1,12 @@
1
1
  import { RowData, Updater } from "../../types/type-utils.cjs";
2
+ import { TableReactivityBindings } from "../reactivity/coreReactivityFeature.types.cjs";
2
3
  import { CoreFeatures } from "../coreFeatures.cjs";
3
4
  import { RowModelFns } from "../../types/RowModelFns.cjs";
4
5
  import { CachedRowModels, CreateRowModels_All } from "../../types/RowModel.cjs";
5
6
  import { TableState, TableState_All } from "../../types/TableState.cjs";
6
7
  import { TableOptions } from "../../types/TableOptions.cjs";
7
8
  import { TableFeatures } from "../../types/TableFeatures.cjs";
8
- import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/store";
9
+ import { Atom, ReadonlyAtom, ReadonlyStore } from "@tanstack/store";
9
10
 
10
11
  //#region src/core/table/coreTablesFeature.types.d.ts
11
12
  interface TableMeta<TFeatures extends TableFeatures, TData extends RowData> {}
@@ -45,11 +46,11 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
45
46
  /**
46
47
  * The features that you want to enable for the table.
47
48
  */
48
- _features: TFeatures;
49
+ readonly _features: TFeatures;
49
50
  /**
50
51
  * The row model options that you want to enable for the table.
51
52
  */
52
- _rowModels?: CreateRowModels_All<TFeatures, TData>;
53
+ readonly _rowModels?: CreateRowModels_All<TFeatures, TData>;
53
54
  /**
54
55
  * Optionally, provide your own external writable atoms for individual state slices.
55
56
  * When an atom is provided for a given slice, it takes precedence over `options.state[key]`
@@ -57,38 +58,38 @@ interface TableOptions_Table<TFeatures extends TableFeatures, TData extends RowD
57
58
  * still routed through the internal base atom; consumers are responsible for
58
59
  * mirroring changes back to their external atom via the corresponding `onXChange` callback.
59
60
  */
60
- atoms?: ExternalAtoms<TFeatures>;
61
+ readonly atoms?: ExternalAtoms<TFeatures>;
61
62
  /**
62
63
  * Set this option to override any of the `autoReset...` feature options.
63
64
  */
64
- autoResetAll?: boolean;
65
+ readonly autoResetAll?: boolean;
65
66
  /**
66
67
  * The data for the table to display. When the `data` option changes reference, the table will reprocess the data.
67
68
  */
68
- data: ReadonlyArray<TData>;
69
+ readonly data: ReadonlyArray<TData>;
69
70
  /**
70
71
  * 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.
71
72
  * Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable.
72
73
  */
73
- initialState?: Partial<TableState<TFeatures>>;
74
+ readonly initialState?: Partial<TableState<TFeatures>>;
74
75
  /**
75
76
  * This option is used to optionally implement the merging of table options.
76
77
  */
77
- mergeOptions?: (defaultOptions: TableOptions<TFeatures, TData>, options: Partial<TableOptions<TFeatures, TData>>) => TableOptions<TFeatures, TData>;
78
+ readonly mergeOptions?: (defaultOptions: TableOptions<TFeatures, TData>, options: Partial<TableOptions<TFeatures, TData>>) => TableOptions<TFeatures, TData>;
78
79
  /**
79
80
  * You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`.
80
81
  */
81
- meta?: TableMeta<TFeatures, TData>;
82
+ readonly meta?: TableMeta<TFeatures, TData>;
82
83
  /**
83
84
  * Pass in individual self-managed state to the table.
84
85
  */
85
- state?: Partial<TableState<TFeatures>>;
86
+ readonly state?: Partial<TableState<TFeatures>>;
86
87
  }
87
88
  interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends RowData> {
88
89
  /**
89
- * The features that are enabled for the table.
90
+ * Table reactivity bindings for interacting with TanStack Store.
90
91
  */
91
- _features: Partial<CoreFeatures> & TFeatures;
92
+ readonly _reactivity: TableReactivityBindings;
92
93
  /**
93
94
  * Prototype cache for Cell objects - shared by all cells in this table
94
95
  */
@@ -97,6 +98,10 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
97
98
  * Prototype cache for Column objects - shared by all columns in this table
98
99
  */
99
100
  _columnPrototype?: object;
101
+ /**
102
+ * The features that are enabled for the table.
103
+ */
104
+ readonly _features: Partial<CoreFeatures> & TFeatures;
100
105
  /**
101
106
  * Prototype cache for Header objects - shared by all headers in this table
102
107
  */
@@ -104,43 +109,43 @@ interface Table_CoreProperties<TFeatures extends TableFeatures, TData extends Ro
104
109
  /**
105
110
  * The row model processing functions that are used to process the data by features.
106
111
  */
107
- _rowModelFns: RowModelFns<TFeatures, TData>;
112
+ readonly _rowModelFns: RowModelFns<TFeatures, TData>;
108
113
  /**
109
114
  * The row models that are enabled for the table.
110
115
  */
111
- _rowModels: CachedRowModels<TFeatures, TData>;
116
+ readonly _rowModels: CachedRowModels<TFeatures, TData>;
112
117
  /**
113
118
  * Prototype cache for Row objects - shared by all rows in this table
114
119
  */
115
120
  _rowPrototype?: object;
116
- /**
117
- * The internal writable atoms for each `TableState` slice. This is the library's
118
- * single write surface — all state mutations from features land here.
119
- */
120
- baseAtoms: BaseAtoms<TFeatures>;
121
121
  /**
122
122
  * The readonly derived atoms for each `TableState` slice. Each derives from
123
123
  * its corresponding `baseAtom` plus, optionally, a per-slice external atom or
124
124
  * external state value (precedence: external atom > external state > base atom).
125
125
  */
126
- atoms: Atoms<TFeatures>;
126
+ readonly atoms: Atoms<TFeatures>;
127
127
  /**
128
- * The base store for the table options.
128
+ * The internal writable atoms for each `TableState` slice. This is the library's
129
+ * single write surface — all state mutations from features land here.
129
130
  */
130
- optionsStore: Store<TableOptions<TFeatures, TData>>;
131
+ readonly baseAtoms: BaseAtoms<TFeatures>;
131
132
  /**
132
133
  * This is the resolved initial state of the table.
133
134
  */
134
- initialState: TableState<TFeatures>;
135
+ readonly initialState: TableState<TFeatures>;
135
136
  /**
136
137
  * A read-only reference to the table's current options.
137
138
  */
138
139
  readonly options: TableOptions<TFeatures, TData>;
140
+ /**
141
+ * The base store for the table options.
142
+ */
143
+ readonly optionsStore: Atom<TableOptions<TFeatures, TData>>;
139
144
  /**
140
145
  * The readonly flat store for the table state. Derives from `table.atoms`
141
146
  * only; never reads external state directly.
142
147
  */
143
- store: ReadonlyStore<TableState<TFeatures>>;
148
+ readonly store: ReadonlyStore<TableState<TFeatures>>;
144
149
  }
145
150
  interface Table_Table<TFeatures extends TableFeatures, TData extends RowData> extends Table_CoreProperties<TFeatures, TData> {
146
151
  /**