@tanstack/ember-table 9.0.0-beta.52 → 9.0.0-beta.54

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.
@@ -125,4 +125,3 @@ class FlexRenderFooter extends Component {
125
125
  }
126
126
 
127
127
  export { FlexRenderCell as F, FlexRenderComponentConfig as a, FlexRenderFooter as b, FlexRenderHeader as c, flexRenderComponent as f };
128
- //# sourceMappingURL=FlexRender-fkWv7pUy.js.map
@@ -1,2 +1 @@
1
1
  export * from '@tanstack/table-core/experimental-worker-plugin';
2
- //# sourceMappingURL=experimental-worker-plugin.js.map
@@ -1,3 +1,2 @@
1
1
  export { F as FlexRenderCell, a as FlexRenderComponentConfig, b as FlexRenderFooter, c as FlexRenderHeader, f as flexRenderComponent } from './FlexRender-fkWv7pUy.js';
2
2
  export { flexRender } from '@tanstack/table-core/flex-render';
3
- //# sourceMappingURL=flex-render.js.map
package/dist/index.js CHANGED
@@ -283,4 +283,3 @@ function createTableHook({
283
283
  }
284
284
 
285
285
  export { ComputedSignal, Signal, computed, createAtom, createTableHook, emberReactivity, signal, useTable };
286
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export * from '@tanstack/table-core/static-functions';
2
- //# sourceMappingURL=static-functions.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ember-table",
3
- "version": "9.0.0-beta.52",
3
+ "version": "9.0.0-beta.54",
4
4
  "description": "Headless UI for building powerful tables & datagrids for Ember.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -53,14 +53,13 @@
53
53
  "addon-main.cjs",
54
54
  "declarations",
55
55
  "dist",
56
- "src",
57
56
  "skills"
58
57
  ],
59
58
  "dependencies": {
60
59
  "@embroider/addon-shim": "^1.8.9",
61
60
  "@tanstack/store": "^0.11.0",
62
61
  "decorator-transforms": "2.4.0",
63
- "@tanstack/table-core": "9.0.0-beta.52"
62
+ "@tanstack/table-core": "9.0.0-beta.54"
64
63
  },
65
64
  "devDependencies": {
66
65
  "@babel/core": "7.29.7",
@@ -6,7 +6,7 @@ metadata:
6
6
  type: framework
7
7
  library: '@tanstack/ember-table'
8
8
  framework: ember
9
- library_version: '9.0.0-beta.52'
9
+ library_version: '9.0.0-beta.54'
10
10
  requires:
11
11
  - '@tanstack/table-core#core'
12
12
  - getting-started
@@ -114,4 +114,4 @@ Use `createAppColumnHelper<Person>()`; do not thread `typeof features` through e
114
114
 
115
115
  ## API Discovery
116
116
 
117
- Inspect `node_modules/@tanstack/ember-table/src/create-table-hook.ts` for the installed factory return shape, omitted options, and merge precedence. Inspect `use-table.ts` for thunk reactivity and `node_modules/@tanstack/table-core/src/features/<feature>/` for the shared feature APIs. Do not infer Ember component/context behavior from another adapter's createTableHook.
117
+ Inspect `node_modules/@tanstack/ember-table/declarations/create-table-hook.d.ts` for the installed factory return shape, omitted options, and merge precedence. Inspect `use-table.d.ts` for thunk reactivity and `node_modules/@tanstack/table-core/dist/features/<feature>/` for the shared feature APIs. Do not infer Ember component/context behavior from another adapter's createTableHook.
@@ -6,7 +6,7 @@ metadata:
6
6
  type: framework
7
7
  library: '@tanstack/ember-table'
8
8
  framework: ember
9
- library_version: '9.0.0-beta.52'
9
+ library_version: '9.0.0-beta.54'
10
10
  requires:
11
11
  - '@tanstack/table-core#core'
12
12
  - '@tanstack/table-core#table-features'
@@ -157,4 +157,4 @@ With `tableFeatures({})`, render `row.getAllCells()`. Add `columnVisibilityFeatu
157
157
 
158
158
  ## API Discovery
159
159
 
160
- Inspect `node_modules/@tanstack/ember-table/src/index.ts` for exports, `use-table.ts` for options/reactivity behavior, `FlexRender.gts` and `flex-render.ts` for renderer contracts, and `node_modules/@tanstack/table-core/src/features/<feature>/` for feature-gated APIs. Do not substitute React hooks, subscriptions, or component signatures.
160
+ Inspect `node_modules/@tanstack/ember-table/declarations/index.d.ts` for exports, `use-table.d.ts` for options/reactivity behavior, `FlexRender.d.ts` and `flex-render.d.ts` for renderer contracts, and `node_modules/@tanstack/table-core/dist/features/<feature>/` for feature-gated APIs. Do not substitute React hooks, subscriptions, or component signatures.
@@ -6,7 +6,7 @@ metadata:
6
6
  type: framework
7
7
  library: '@tanstack/ember-table'
8
8
  framework: ember
9
- library_version: '9.0.0-beta.52'
9
+ library_version: '9.0.0-beta.54'
10
10
  requires:
11
11
  - '@tanstack/table-core#core'
12
12
  - getting-started
@@ -184,4 +184,4 @@ When `atoms.pagination` owns the slice, changing `baseAtoms.pagination` does not
184
184
 
185
185
  ## API Discovery
186
186
 
187
- Inspect `node_modules/@tanstack/ember-table/src/use-table.ts` for option/state precedence and the Glimmer bridge, `signal.ts` for `createAtom` behavior, and `reactivity.ts` for scheduling/tracking. Inspect the registered feature under `node_modules/@tanstack/table-core/src/features/<feature>/` for its state type, update API, and reset semantics.
187
+ Inspect `node_modules/@tanstack/ember-table/declarations/use-table.d.ts` for option/state precedence and the Glimmer bridge, `signal.d.ts` for `createAtom` behavior, and `reactivity.d.ts` for scheduling/tracking. Inspect the registered feature under `node_modules/@tanstack/table-core/dist/features/<feature>/` for its state type, update API, and reset semantics.
@@ -1 +0,0 @@
1
- {"version":3,"file":"FlexRender-fkWv7pUy.js","sources":["../src/flex-render-helpers.ts","../src/FlexRender.gts"],"sourcesContent":["import type { ComponentLike } from '@glint/template'\nimport type {\n CellContext,\n CellData,\n HeaderContext,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nexport { flexRender } from '@tanstack/table-core/flex-render'\n\nexport type FlexRenderContext<\n TFeatures extends TableFeatures = TableFeatures,\n TData extends RowData = RowData,\n TValue extends CellData = CellData,\n> =\n | CellContext<TFeatures, TData, TValue>\n | HeaderContext<TFeatures, TData, TValue>\n\nexport interface FlexRenderableSignature<\n TFeatures extends TableFeatures = TableFeatures,\n TData extends RowData = RowData,\n TValue extends CellData = CellData,\n TOptions = undefined,\n> {\n Args: {\n ctx: FlexRenderContext<TFeatures, TData, TValue>\n options?: TOptions\n }\n}\n\nexport interface CellRenderableSignature<\n TFeatures extends TableFeatures = TableFeatures,\n TData extends RowData = RowData,\n TValue extends CellData = CellData,\n TOptions = undefined,\n> {\n Args: {\n ctx: CellContext<TFeatures, TData, TValue>\n options?: TOptions\n }\n}\n\ntype FlexRenderableComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TOptions,\n> =\n | ComponentLike<FlexRenderableSignature<TFeatures, TData, TValue, TOptions>>\n | ComponentLike<CellRenderableSignature<TFeatures, TData, TValue, TOptions>>\n\nexport class FlexRenderComponentConfig<\n TFeatures extends TableFeatures = TableFeatures,\n TData extends RowData = RowData,\n TValue extends CellData = CellData,\n TOptions = undefined,\n> {\n readonly component: FlexRenderableComponent<\n TFeatures,\n TData,\n TValue,\n TOptions\n >\n readonly options?: TOptions\n\n constructor(\n component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,\n options?: TOptions,\n ) {\n this.component = component\n this.options = options\n }\n}\n\nexport function flexRenderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n>(\n component: FlexRenderableComponent<TFeatures, TData, TValue, undefined>,\n): FlexRenderComponentConfig<TFeatures, TData, TValue, undefined>\n\nexport function flexRenderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TOptions,\n>(\n component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,\n options: TOptions,\n): FlexRenderComponentConfig<TFeatures, TData, TValue, TOptions>\n\nexport function flexRenderComponent<\n TFeatures extends TableFeatures = TableFeatures,\n TData extends RowData = RowData,\n TValue extends CellData = CellData,\n TOptions = undefined,\n>(\n component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,\n options?: TOptions,\n): FlexRenderComponentConfig<TFeatures, TData, TValue, TOptions> {\n return new FlexRenderComponentConfig(component, options)\n}\n","import Component from '@glimmer/component'\nimport { FlexRenderComponentConfig } from './flex-render-helpers.ts'\nimport { flexRender } from '@tanstack/table-core/flex-render'\nimport type {\n Cell_Core,\n CellContext,\n CellData,\n Header_Core,\n HeaderContext,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentLike, ContentValue } from '@glint/template'\n\ntype RenderOptions = Record<string, unknown> | undefined\n\ntype CellRenderResult<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | string\n | number\n | null\n | FlexRenderComponentConfig<TFeatures, TData, TValue, RenderOptions>\n\ntype HeaderRenderResult<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | string\n | number\n | null\n | FlexRenderComponentConfig<TFeatures, TData, TValue, RenderOptions>\n\ninterface CellRenderSignature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n> {\n Args: {\n ctx: CellContext<TFeatures, TData, TValue>\n options?: Record<string, unknown>\n }\n}\n\ninterface HeaderRenderSignature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n> {\n Args: {\n ctx: HeaderContext<TFeatures, TData, TValue>\n options?: Record<string, unknown>\n }\n}\n\n// --- FlexRenderCell ---\n\nexport interface FlexRenderCellSignature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> {\n Args: {\n cell: Cell_Core<TFeatures, TData, TValue>\n }\n Element: null\n}\n\nexport class FlexRenderCell<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> extends Component<FlexRenderCellSignature<TFeatures, TData, TValue>> {\n get result(): CellRenderResult<TFeatures, TData, TValue> {\n const cell = this.args.cell\n return flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n ) as CellRenderResult<TFeatures, TData, TValue>\n }\n\n get resolvedContext(): CellContext<TFeatures, TData, TValue> {\n return this.args.cell.getContext()\n }\n\n get isComponent(): boolean {\n return this.result instanceof FlexRenderComponentConfig\n }\n\n get componentToRender():\n | ComponentLike<CellRenderSignature<TFeatures, TData, TValue>>\n | undefined {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.component\n }\n return undefined\n }\n\n get componentOptions(): RenderOptions {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.options\n }\n return undefined\n }\n\n get content(): ContentValue {\n return this.result as ContentValue\n }\n\n <template>\n {{#if this.isComponent}}\n <this.componentToRender\n @ctx={{this.resolvedContext}}\n @options={{this.componentOptions}}\n />\n {{else}}\n {{this.content}}\n {{/if}}\n </template>\n}\n\n// --- FlexRenderHeader ---\n\nexport interface FlexRenderHeaderSignature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> {\n Args: {\n header: Header_Core<TFeatures, TData, TValue>\n }\n Element: null\n}\n\nexport class FlexRenderHeader<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> extends Component<FlexRenderHeaderSignature<TFeatures, TData, TValue>> {\n get result(): HeaderRenderResult<TFeatures, TData, TValue> {\n const header = this.args.header\n if (header.isPlaceholder) return null\n return flexRender(\n header.column.columnDef.header,\n header.getContext(),\n ) as HeaderRenderResult<TFeatures, TData, TValue>\n }\n\n get resolvedContext(): HeaderContext<TFeatures, TData, TValue> {\n return this.args.header.getContext()\n }\n\n get isComponent(): boolean {\n return this.result instanceof FlexRenderComponentConfig\n }\n\n get componentToRender():\n | ComponentLike<HeaderRenderSignature<TFeatures, TData, TValue>>\n | undefined {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.component as unknown as ComponentLike<\n HeaderRenderSignature<TFeatures, TData, TValue>\n >\n }\n return undefined\n }\n\n get componentOptions(): RenderOptions {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.options\n }\n return undefined\n }\n\n get content(): ContentValue {\n return this.result as ContentValue\n }\n\n <template>\n {{#if this.isComponent}}\n <this.componentToRender\n @ctx={{this.resolvedContext}}\n @options={{this.componentOptions}}\n />\n {{else}}\n {{this.content}}\n {{/if}}\n </template>\n}\n\n// --- FlexRenderFooter ---\n\nexport interface FlexRenderFooterSignature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> {\n Args: {\n footer: Header_Core<TFeatures, TData, TValue>\n }\n Element: null\n}\n\nexport class FlexRenderFooter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> extends Component<FlexRenderFooterSignature<TFeatures, TData, TValue>> {\n get result(): HeaderRenderResult<TFeatures, TData, TValue> {\n const footer = this.args.footer\n if (footer.isPlaceholder) return null\n return flexRender(\n footer.column.columnDef.footer,\n footer.getContext(),\n ) as HeaderRenderResult<TFeatures, TData, TValue>\n }\n\n get resolvedContext(): HeaderContext<TFeatures, TData, TValue> {\n return this.args.footer.getContext()\n }\n\n get isComponent(): boolean {\n return this.result instanceof FlexRenderComponentConfig\n }\n\n get componentToRender():\n | ComponentLike<HeaderRenderSignature<TFeatures, TData, TValue>>\n | undefined {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.component as unknown as ComponentLike<\n HeaderRenderSignature<TFeatures, TData, TValue>\n >\n }\n return undefined\n }\n\n get componentOptions(): RenderOptions {\n const result = this.result\n if (result instanceof FlexRenderComponentConfig) {\n return result.options\n }\n return undefined\n }\n\n get content(): ContentValue {\n return this.result as ContentValue\n }\n\n <template>\n {{#if this.isComponent}}\n <this.componentToRender\n @ctx={{this.resolvedContext}}\n @options={{this.componentOptions}}\n />\n {{else}}\n {{this.content}}\n {{/if}}\n </template>\n}\n"],"names":["FlexRenderComponentConfig","component","options","constructor","flexRenderComponent","FlexRenderCell","Component","result","cell","args","flexRender","column","columnDef","getContext","resolvedContext","isComponent","componentToRender","undefined","componentOptions","content","setComponentTemplate","precompileTemplate","strictMode","FlexRenderHeader","header","isPlaceholder","FlexRenderFooter","footer"],"mappings":";;;;;AAmDO,MAAMA,yBAAyB,CAKpC;EACSC,SAAS;EAMTC,OAAO;AAEhBC,EAAAA,WAAWA,CACTF,SAAsE,EACtEC,OAAkB,EAClB;IACA,IAAI,C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A,CAAOF,aAAa,EAAE,OAAO,IAAA;AACjC,IAAA,OAAOf,UAAA,CACLiB,MAAA,CAAOhB,MAAM,CAACC,SAAS,CAACe,MAAM,EAC9BA,MAAA,CAAOd,UAAU,EAAA,CAAA;AAErB,EAAA;EAEA,IAAIC,eAAAA,GAA2D;IAC7D,OAAO,IAAI,CAACL,IAAI,CAACkB,MAAM,CAACd,UAAU,EAAA;AACpC,EAAA;EAEA,IAAIE,WAAAA,GAAuB;AACzB,IAAA,OAAO,IAAI,CAACR,MAAM,YAAYP,yBAAA;AAChC,EAAA;EAEA,IAAIgB,oBAEU;AACZ,IAAA,MAAMT,MAAA,GAAS,IAAI,CAACA,MAAM;IAC1B,IAAIA,kBAAkBP,yBAAA,EAA2B;MAC/C,OAAOO,MAAA,CAAON,SAAS;AAGzB,IAAA;AACA,IAAA,OAAOgB,SAAA;AACT,EAAA;EAEA,IAAIC,mBAAkC;AACpC,IAAA,MAAMX,MAAA,GAAS,IAAI,CAACA,MAAM;IAC1B,IAAIA,kBAAkBP,yBAAA,EAA2B;MAC/C,OAAOO,OAAOL,OAAO;AACvB,IAAA;AACA,IAAA,OAAOe,SAAA;AACT,EAAA;EAEA,IAAIE,UAAwB;IAC1B,OAAO,IAAI,CAACZ,MAAM;AACpB,EAAA;AAEA,EAAA;IAAAa,oBAAA,CAAAC,kBAAA,CAAA,gKAAA,EASA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"experimental-worker-plugin.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flex-render.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/signal.ts","../src/reactivity.ts","../src/use-table.ts","../src/create-table-hook.ts"],"sourcesContent":["import type { Atom, AtomOptions, Observer, Subscription } from '@tanstack/store'\n\nimport { tracked, cached } from '@glimmer/tracking'\nimport { untrack } from '@glimmer/validator'\n\nexport function subscribeNoEffect(): Subscription {\n return null as unknown as Subscription\n}\n\n/**\n * Ember-native signal implementation.\n * In future ember >7.3 `tracked` will be available by itself\n * so the class wrapper will not be needed for those versions\n */\nexport class Signal<T> {\n @tracked _value\n\n #options: AtomOptions<T> | undefined\n\n // Ember reads are tag-tracked; this observer list exists for the plain-JS\n // subscribers core wires up (external-atom sync in constructTable, the\n // inspector), which have no access to framework tracking.\n #listeners = new Set<(value: T) => void>()\n\n constructor(value: T, options: AtomOptions<T> | undefined) {\n this._value = value\n this.#options = options\n }\n\n subscribe(\n listenerOrObserver: Observer<T> | ((value: T) => void),\n ): Subscription {\n const listener =\n typeof listenerOrObserver === 'function'\n ? listenerOrObserver\n : listenerOrObserver.next\n\n if (!listener) {\n return { unsubscribe: () => {} }\n }\n\n this.#listeners.add(listener)\n return { unsubscribe: () => this.#listeners.delete(listener) }\n }\n\n get() {\n return this.value\n }\n set(value: T | ((prev: T) => T)) {\n if (typeof value === 'function') {\n return this.update(value as unknown as (prev: T) => T)\n }\n\n this.value = value\n }\n\n get value() {\n return this._value\n }\n\n set value(next: T) {\n const prev = untrack(() => this._value)\n\n const isEqual = this.#options?.compare\n ? this.#options.compare(prev, next)\n : prev === next\n if (isEqual) {\n return\n }\n\n this._value = next\n\n for (const listener of this.#listeners) {\n listener(next)\n }\n }\n\n update(fn: (value: T) => T) {\n const original = untrack(() => this._value)\n\n this.value = fn(original)\n }\n}\n\nexport class ComputedSignal<T> {\n #compute\n\n constructor(compute: () => T) {\n this.#compute = compute\n }\n\n get() {\n return this.value\n }\n\n subscribe = subscribeNoEffect\n\n @cached\n get value() {\n return this.#compute()\n }\n}\n\nexport function signal<T>(value: T, options: AtomOptions<T> | undefined) {\n return new Signal(value, options)\n}\n\n/**\n * Creates an Ember-native writable atom, satisfying the `@tanstack/store`\n * `Atom` contract so it can be passed to `options.atoms`. Because it is backed\n * by a `@tracked` Signal, reading `atom.get()` directly in a template or\n * getter is reactive — unlike a foreign `@tanstack/store` atom, whose reads\n * create no Glimmer tag dependency.\n *\n * Takes a plain initial value only; there is no derived/function overload.\n */\nexport function createAtom<T>(\n initialValue: T,\n options?: AtomOptions<T>,\n): Atom<T> {\n return signal(initialValue, options)\n}\n\nexport function computed<T>(fn: () => T) {\n return new ComputedSignal(fn)\n}\n","import type { Subscription } from '@tanstack/store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\nimport { untrack } from '@glimmer/validator'\nimport { computed, signal } from './signal.ts'\n\nexport function emberReactivity(): TableReactivityBindings {\n const subscriptions = new Set<Subscription>()\n\n return {\n createOptionsStore: true,\n wrapExternalAtoms: true,\n\n // timing is not important, but the main thing is that the work does *not*\n // happen during the render phase.\n schedule: (fn) => queueMicrotask(() => fn()),\n batch: (fn) => fn(),\n untrack,\n // @cached\n createReadonlyAtom: <T>(fn: () => T) => {\n return computed(fn)\n },\n // @tracked\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return signal(value, options)\n },\n // Not for the ember integration, but for the tanstack inspector\n addSubscription: (subscription) => {\n subscriptions.add(subscription)\n },\n unmount: () => {\n subscriptions.forEach((s) => s.unsubscribe())\n subscriptions.clear()\n },\n }\n}\n","import { constructTable } from '@tanstack/table-core'\nimport { untrack } from '@glimmer/validator'\nimport { emberReactivity } from './reactivity.ts'\nimport { computed, subscribeNoEffect } from './signal.ts'\nimport type {\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { Atom, ReadonlyAtom, ReadonlyStore } from '@tanstack/store'\n\n// Internal table slots used by the pull-based options/state wiring below.\n// `Table_Internal` is not exported from the table-core build, so the shape is\n// declared structurally here.\ninterface TableInternals<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n optionsStore?: {\n get(): TableOptions<TFeatures, TData>\n set(value: () => TableOptions<TFeatures, TData>): void\n }\n baseAtoms: Record<string, { get(): unknown }>\n atoms: Record<string, unknown>\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(getOptions: () => TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const reactivity = emberReactivity()\n\n // Creates reactive read only signal for options\n const userOptions = computed(getOptions)\n\n // Untracked to prevent possible \"set on same computation as read\" errors in Ember.\n const initialOptions = untrack(() => userOptions.get())\n\n const table = constructTable<TFeatures, TData>({\n ...initialOptions,\n features: {\n coreReactivityFeature: reactivity,\n ...initialOptions.features,\n },\n mergeOptions: (\n defaultOptions: TableOptions<TFeatures, TData>,\n newOptions: Partial<TableOptions<TFeatures, TData>>,\n ) => ({\n ...defaultOptions,\n ...newOptions,\n }),\n }) as Table<TFeatures, TData> & TableInternals<TFeatures, TData>\n\n const optionsStore = table.optionsStore!\n\n const liveOptions = computed(() => {\n const stored = optionsStore.get()\n return {\n ...stored,\n ...userOptions.get(),\n // stored options carry construct-time normalization (the reactivity\n // feature, wrapped external atoms) that must win over the raw user\n // options.\n features: stored.features,\n atoms: stored.atoms,\n }\n })\n\n /**\n * This is to get around core table not using lazy access so we need to re-wrap\n *\n * Similar to other reactive signal frameworks (solid, angular, svelte)\n */\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get: () => liveOptions.get(),\n set: (value: TableOptions<TFeatures, TData>) => {\n optionsStore.set(() => value)\n },\n })\n\n const atoms: Record<string, ReadonlyAtom<unknown>> = table.atoms\n const stateKeys = Object.keys(table.baseAtoms)\n\n for (const key of stateKeys) {\n const baseAtom = (table.baseAtoms as Record<string, ReadonlyAtom<unknown>>)[\n key\n ]!\n\n /**\n * Original atoms could cause effects for top level properties\n *\n * Core table should migrate to pure derived data which would boost render\n * performance for both signal and non-signal frameworks.\n */\n atoms[key] = reactivity.createReadonlyAtom(\n () => {\n const externalAtom = (\n table.options.atoms as Record<string, Atom<unknown>> | undefined\n )?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n const stateSlice = (\n table.options.state as Record<string, unknown> | undefined\n )?.[key]\n if (stateSlice !== undefined) {\n return stateSlice\n }\n return baseAtom.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n const stateProxy: TableState<TFeatures> = new Proxy(\n {},\n {\n get: (_target, key) =>\n typeof key === 'string' ? atoms[key]?.get() : undefined,\n has: (_target, key) => typeof key === 'string' && stateKeys.includes(key),\n ownKeys: () => stateKeys,\n getOwnPropertyDescriptor: (_target, key) =>\n typeof key === 'string' && stateKeys.includes(key)\n ? {\n enumerable: true,\n configurable: true,\n value: atoms[key]!.get(),\n }\n : undefined,\n },\n ) as TableState<TFeatures>\n\n /**\n * Store is reasigned to point to proxy object to allow individual state slices to be independently reactive.\n *\n * Type cast is needed because we are setting during construction\n * Table store is readonly after first initialization.\n */\n ;(\n table as { store: Omit<ReadonlyStore<TableState<TFeatures>>, 'atom'> }\n ).store = {\n get: () => stateProxy,\n get state() {\n return stateProxy\n },\n subscribe: subscribeNoEffect,\n }\n\n return table\n}\n","import { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useTable } from './use-table.ts'\nimport type {\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n} from '@tanstack/table-core'\n\nexport type CreateTableHookOptions<TFeatures extends TableFeatures> = Omit<\n // `any` (not `RowData`) is intentional and matches the other adapters'\n // createTableHook: shared defaults are declared before any specific TData is\n // known, and TData-dependent options like `getRowId` and `meta` are\n // contravariant in TData, so a narrower type would reject them here.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'state'\n>\n\nexport type AppEmberTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Table<TFeatures, TData>\n\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = ReturnType<typeof coreCreateColumnHelper<TFeatures, TData>>\n\n/**\n * Bundles a feature set and shared default options once so every table in your\n * app can be created without repeating them. Returns a typed column helper\n * factory and a `createAppTable` that wraps {@link useTable}.\n *\n * Unlike the React adapter's hook, this does not pre-bind cell/header\n * components onto the table; render with the `FlexRenderCell`,\n * `FlexRenderHeader`, and `FlexRenderFooter` components as usual.\n *\n * @example\n * ```ts\n * const { createAppTable, createAppColumnHelper } = createTableHook({\n * features: tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns }),\n * })\n *\n * const columnHelper = createAppColumnHelper<Person>()\n * const columns = columnHelper.columns([...])\n *\n * // inside a Glimmer component; options stay a thunk so tracked reads are reactive\n * table = createAppTable(() => ({ columns, data: this.data }))\n * ```\n */\nexport function createTableHook<TFeatures extends TableFeatures>({\n ...defaultTableOptions\n}: CreateTableHookOptions<TFeatures>) {\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData\n > {\n return coreCreateColumnHelper<TFeatures, TData>()\n }\n\n function createAppTable<TData extends RowData>(\n getTableOptions: () => Omit<TableOptions<TFeatures, TData>, 'features'>,\n ): AppEmberTable<TFeatures, TData> {\n // Keep options a thunk: the merge runs inside `useTable`'s options thunk,\n // so tracked properties read in `getTableOptions` stay reactive. Per-table\n // options take precedence over the shared defaults (except `features`,\n // which only the hook provides).\n return useTable<TFeatures, TData>(\n () =>\n ({\n ...defaultTableOptions,\n ...getTableOptions(),\n }) as TableOptions<TFeatures, TData>,\n )\n }\n\n return {\n appFeatures: defaultTableOptions.features as TFeatures,\n createAppColumnHelper,\n createAppTable,\n }\n}\n"],"names":["subscribeNoEffect","Signal","g","prototype","tracked","i","Set","constructor","value","options","_value","subscribe","listenerOrObserver","listener","next","unsubscribe","add","delete","get","set","update","prev","untrack","isEqual","compare","fn","original","ComputedSignal","compute","n","cached","signal","createAtom","initialValue","computed","emberReactivity","subscriptions","createOptionsStore","wrapExternalAtoms","schedule","queueMicrotask","batch","createReadonlyAtom","createWritableAtom","addSubscription","subscription","unmount","forEach","s","clear","useTable","getOptions","reactivity","userOptions","initialOptions","table","constructTable","features","coreReactivityFeature","mergeOptions","defaultOptions","newOptions","optionsStore","liveOptions","stored","atoms","Object","defineProperty","configurable","enumerable","stateKeys","keys","baseAtoms","key","baseAtom","externalAtom","stateSlice","state","undefined","debugName","stateProxy","Proxy","_target","has","includes","ownKeys","getOwnPropertyDescriptor","store","createTableHook","defaultTableOptions","createAppColumnHelper","coreCreateColumnHelper","createAppTable","getTableOptions","appFeatures"],"mappings":";;;;;;;;AAKO,SAASA,iBAAiBA,GAAiB;AAChD,EAAA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,CAAI;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CACpBC,OAAO,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAER,EAAA,QAAQ;;AAER;AACA;AACA;AACA,EAAA,UAAU,GAAG,IAAIC,GAAG,EAAsB;AAE1CC,EAAAA,WAAWA,CAACC,KAAQ,EAAEC,OAAmC,EAAE;IACzD,IAAI,CAACC,MAAM,GAAGF,KAAK;AACnB,IAAA,IAAI,CAAC,QAAQ,GAAGC,OAAO;AACzB,EAAA;EAEAE,SAASA,CACPC,kBAAsD,EACxC;IACd,MAAMC,QAAQ,GACZ,OAAOD,kBAAkB,KAAK,UAAU,GACpCA,kBAAkB,GAClBA,kBAAkB,CAACE,IAAI;IAE7B,IAAI,CAACD,QAAQ,EAAE;MACb,OAAO;QAAEE,WAAW,EAAEA,MAAM,CAAC;OAAG;AAClC,IAAA;AAEA,IAAA,IAAI,CAAC,UAAU,CAACC,GAAG,CAACH,QAAQ,CAAC;IAC7B,OAAO;MAAEE,WAAW,EAAEA,MAAM,IAAI,CAAC,UAAU,CAACE,MAAM,CAACJ,QAAQ;KAAG;AAChE,EAAA;AAEAK,EAAAA,GAAGA,GAAG;IACJ,OAAO,IAAI,CAACV,KAAK;AACnB,EAAA;EACAW,GAAG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AIH,SAAS,CAACc,QAAQ,CAACX,GAAG,CAAC;IACzEY,OAAO,EAAEA,MAAMf,SAAS;AACxBgB,IAAAA,wBAAwB,EAAEA,CAACJ,OAAO,EAAET,GAAG,KACrC,OAAOA,GAAG,KAAK,QAAQ,IAAIH,SAAS,CAACc,QAAQ,CAACX,GAAG,CAAC,GAC9C;AACEJ,MAAAA,UAAU,EAAE,IAAI;AAChBD,MAAAA,YAAY,EAAE,IAAI;AAClB5D,MAAAA,KAAK,EAAEyD,KAAK,CAACQ,GAAG,CAAC,CAAEvD,GAAG;AACxB,KAAC,GACD4D;GAEV;;AAEA;AACF;AACA;AACA;AACA;AACA;EAEIvB,KAAK,CACLgC,KAAK,GAAG;IACRrE,GAAG,EAAEA,MAAM8D,UAAU;IACrB,IAAIH,KAAKA,GAAG;AACV,MAAA,OAAOG,UAAU;IACnB,CAAC;AACDrE,IAAAA,SAAS,EAAEX;GACZ;AAED,EAAA,OAAOuD,KAAK;AACd;;AC5HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiC,eAAeA,CAAkC;EAC/D,GAAGC;AAC8B,CAAC,EAAE;EACpC,SAASC,qBAAqBA,GAG5B;IACA,OAAOC,kBAAsB,EAAoB;AACnD,EAAA;EAEA,SAASC,cAAcA,CACrBC,eAAuE,EACtC;AACjC;AACA;AACA;AACA;IACA,OAAO3C,QAAQ,CACb,OACG;AACC,MAAA,GAAGuC,mBAAmB;AACtB,MAAA,GAAGI,eAAe;AACpB,KAAC,CACL,CAAC;AACH,EAAA;EAEA,OAAO;IACLC,WAAW,EAAEL,mBAAmB,CAAChC,QAAqB;IACtDiC,qBAAqB;AACrBE,IAAAA;GACD;AACH;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-functions.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,267 +0,0 @@
1
- import Component from '@glimmer/component'
2
- import { FlexRenderComponentConfig } from './flex-render-helpers.ts'
3
- import { flexRender } from '@tanstack/table-core/flex-render'
4
- import type {
5
- Cell_Core,
6
- CellContext,
7
- CellData,
8
- Header_Core,
9
- HeaderContext,
10
- RowData,
11
- TableFeatures,
12
- } from '@tanstack/table-core'
13
- import type { ComponentLike, ContentValue } from '@glint/template'
14
-
15
- type RenderOptions = Record<string, unknown> | undefined
16
-
17
- type CellRenderResult<
18
- TFeatures extends TableFeatures,
19
- TData extends RowData,
20
- TValue extends CellData = CellData,
21
- > =
22
- | string
23
- | number
24
- | null
25
- | FlexRenderComponentConfig<TFeatures, TData, TValue, RenderOptions>
26
-
27
- type HeaderRenderResult<
28
- TFeatures extends TableFeatures,
29
- TData extends RowData,
30
- TValue extends CellData = CellData,
31
- > =
32
- | string
33
- | number
34
- | null
35
- | FlexRenderComponentConfig<TFeatures, TData, TValue, RenderOptions>
36
-
37
- interface CellRenderSignature<
38
- TFeatures extends TableFeatures,
39
- TData extends RowData,
40
- TValue extends CellData,
41
- > {
42
- Args: {
43
- ctx: CellContext<TFeatures, TData, TValue>
44
- options?: Record<string, unknown>
45
- }
46
- }
47
-
48
- interface HeaderRenderSignature<
49
- TFeatures extends TableFeatures,
50
- TData extends RowData,
51
- TValue extends CellData,
52
- > {
53
- Args: {
54
- ctx: HeaderContext<TFeatures, TData, TValue>
55
- options?: Record<string, unknown>
56
- }
57
- }
58
-
59
- // --- FlexRenderCell ---
60
-
61
- export interface FlexRenderCellSignature<
62
- TFeatures extends TableFeatures,
63
- TData extends RowData,
64
- TValue extends CellData = CellData,
65
- > {
66
- Args: {
67
- cell: Cell_Core<TFeatures, TData, TValue>
68
- }
69
- Element: null
70
- }
71
-
72
- export class FlexRenderCell<
73
- TFeatures extends TableFeatures,
74
- TData extends RowData,
75
- TValue extends CellData = CellData,
76
- > extends Component<FlexRenderCellSignature<TFeatures, TData, TValue>> {
77
- get result(): CellRenderResult<TFeatures, TData, TValue> {
78
- const cell = this.args.cell
79
- return flexRender(
80
- cell.column.columnDef.cell,
81
- cell.getContext(),
82
- ) as CellRenderResult<TFeatures, TData, TValue>
83
- }
84
-
85
- get resolvedContext(): CellContext<TFeatures, TData, TValue> {
86
- return this.args.cell.getContext()
87
- }
88
-
89
- get isComponent(): boolean {
90
- return this.result instanceof FlexRenderComponentConfig
91
- }
92
-
93
- get componentToRender():
94
- | ComponentLike<CellRenderSignature<TFeatures, TData, TValue>>
95
- | undefined {
96
- const result = this.result
97
- if (result instanceof FlexRenderComponentConfig) {
98
- return result.component
99
- }
100
- return undefined
101
- }
102
-
103
- get componentOptions(): RenderOptions {
104
- const result = this.result
105
- if (result instanceof FlexRenderComponentConfig) {
106
- return result.options
107
- }
108
- return undefined
109
- }
110
-
111
- get content(): ContentValue {
112
- return this.result as ContentValue
113
- }
114
-
115
- <template>
116
- {{#if this.isComponent}}
117
- <this.componentToRender
118
- @ctx={{this.resolvedContext}}
119
- @options={{this.componentOptions}}
120
- />
121
- {{else}}
122
- {{this.content}}
123
- {{/if}}
124
- </template>
125
- }
126
-
127
- // --- FlexRenderHeader ---
128
-
129
- export interface FlexRenderHeaderSignature<
130
- TFeatures extends TableFeatures,
131
- TData extends RowData,
132
- TValue extends CellData = CellData,
133
- > {
134
- Args: {
135
- header: Header_Core<TFeatures, TData, TValue>
136
- }
137
- Element: null
138
- }
139
-
140
- export class FlexRenderHeader<
141
- TFeatures extends TableFeatures,
142
- TData extends RowData,
143
- TValue extends CellData = CellData,
144
- > extends Component<FlexRenderHeaderSignature<TFeatures, TData, TValue>> {
145
- get result(): HeaderRenderResult<TFeatures, TData, TValue> {
146
- const header = this.args.header
147
- if (header.isPlaceholder) return null
148
- return flexRender(
149
- header.column.columnDef.header,
150
- header.getContext(),
151
- ) as HeaderRenderResult<TFeatures, TData, TValue>
152
- }
153
-
154
- get resolvedContext(): HeaderContext<TFeatures, TData, TValue> {
155
- return this.args.header.getContext()
156
- }
157
-
158
- get isComponent(): boolean {
159
- return this.result instanceof FlexRenderComponentConfig
160
- }
161
-
162
- get componentToRender():
163
- | ComponentLike<HeaderRenderSignature<TFeatures, TData, TValue>>
164
- | undefined {
165
- const result = this.result
166
- if (result instanceof FlexRenderComponentConfig) {
167
- return result.component as unknown as ComponentLike<
168
- HeaderRenderSignature<TFeatures, TData, TValue>
169
- >
170
- }
171
- return undefined
172
- }
173
-
174
- get componentOptions(): RenderOptions {
175
- const result = this.result
176
- if (result instanceof FlexRenderComponentConfig) {
177
- return result.options
178
- }
179
- return undefined
180
- }
181
-
182
- get content(): ContentValue {
183
- return this.result as ContentValue
184
- }
185
-
186
- <template>
187
- {{#if this.isComponent}}
188
- <this.componentToRender
189
- @ctx={{this.resolvedContext}}
190
- @options={{this.componentOptions}}
191
- />
192
- {{else}}
193
- {{this.content}}
194
- {{/if}}
195
- </template>
196
- }
197
-
198
- // --- FlexRenderFooter ---
199
-
200
- export interface FlexRenderFooterSignature<
201
- TFeatures extends TableFeatures,
202
- TData extends RowData,
203
- TValue extends CellData = CellData,
204
- > {
205
- Args: {
206
- footer: Header_Core<TFeatures, TData, TValue>
207
- }
208
- Element: null
209
- }
210
-
211
- export class FlexRenderFooter<
212
- TFeatures extends TableFeatures,
213
- TData extends RowData,
214
- TValue extends CellData = CellData,
215
- > extends Component<FlexRenderFooterSignature<TFeatures, TData, TValue>> {
216
- get result(): HeaderRenderResult<TFeatures, TData, TValue> {
217
- const footer = this.args.footer
218
- if (footer.isPlaceholder) return null
219
- return flexRender(
220
- footer.column.columnDef.footer,
221
- footer.getContext(),
222
- ) as HeaderRenderResult<TFeatures, TData, TValue>
223
- }
224
-
225
- get resolvedContext(): HeaderContext<TFeatures, TData, TValue> {
226
- return this.args.footer.getContext()
227
- }
228
-
229
- get isComponent(): boolean {
230
- return this.result instanceof FlexRenderComponentConfig
231
- }
232
-
233
- get componentToRender():
234
- | ComponentLike<HeaderRenderSignature<TFeatures, TData, TValue>>
235
- | undefined {
236
- const result = this.result
237
- if (result instanceof FlexRenderComponentConfig) {
238
- return result.component as unknown as ComponentLike<
239
- HeaderRenderSignature<TFeatures, TData, TValue>
240
- >
241
- }
242
- return undefined
243
- }
244
-
245
- get componentOptions(): RenderOptions {
246
- const result = this.result
247
- if (result instanceof FlexRenderComponentConfig) {
248
- return result.options
249
- }
250
- return undefined
251
- }
252
-
253
- get content(): ContentValue {
254
- return this.result as ContentValue
255
- }
256
-
257
- <template>
258
- {{#if this.isComponent}}
259
- <this.componentToRender
260
- @ctx={{this.resolvedContext}}
261
- @options={{this.componentOptions}}
262
- />
263
- {{else}}
264
- {{this.content}}
265
- {{/if}}
266
- </template>
267
- }
@@ -1,83 +0,0 @@
1
- import { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'
2
- import { useTable } from './use-table.ts'
3
- import type {
4
- RowData,
5
- Table,
6
- TableFeatures,
7
- TableOptions,
8
- } from '@tanstack/table-core'
9
-
10
- export type CreateTableHookOptions<TFeatures extends TableFeatures> = Omit<
11
- // `any` (not `RowData`) is intentional and matches the other adapters'
12
- // createTableHook: shared defaults are declared before any specific TData is
13
- // known, and TData-dependent options like `getRowId` and `meta` are
14
- // contravariant in TData, so a narrower type would reject them here.
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- TableOptions<TFeatures, any>,
17
- 'columns' | 'data' | 'state'
18
- >
19
-
20
- export type AppEmberTable<
21
- TFeatures extends TableFeatures,
22
- TData extends RowData,
23
- > = Table<TFeatures, TData>
24
-
25
- export type AppColumnHelper<
26
- TFeatures extends TableFeatures,
27
- TData extends RowData,
28
- > = ReturnType<typeof coreCreateColumnHelper<TFeatures, TData>>
29
-
30
- /**
31
- * Bundles a feature set and shared default options once so every table in your
32
- * app can be created without repeating them. Returns a typed column helper
33
- * factory and a `createAppTable` that wraps {@link useTable}.
34
- *
35
- * Unlike the React adapter's hook, this does not pre-bind cell/header
36
- * components onto the table; render with the `FlexRenderCell`,
37
- * `FlexRenderHeader`, and `FlexRenderFooter` components as usual.
38
- *
39
- * @example
40
- * ```ts
41
- * const { createAppTable, createAppColumnHelper } = createTableHook({
42
- * features: tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns }),
43
- * })
44
- *
45
- * const columnHelper = createAppColumnHelper<Person>()
46
- * const columns = columnHelper.columns([...])
47
- *
48
- * // inside a Glimmer component; options stay a thunk so tracked reads are reactive
49
- * table = createAppTable(() => ({ columns, data: this.data }))
50
- * ```
51
- */
52
- export function createTableHook<TFeatures extends TableFeatures>({
53
- ...defaultTableOptions
54
- }: CreateTableHookOptions<TFeatures>) {
55
- function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<
56
- TFeatures,
57
- TData
58
- > {
59
- return coreCreateColumnHelper<TFeatures, TData>()
60
- }
61
-
62
- function createAppTable<TData extends RowData>(
63
- getTableOptions: () => Omit<TableOptions<TFeatures, TData>, 'features'>,
64
- ): AppEmberTable<TFeatures, TData> {
65
- // Keep options a thunk: the merge runs inside `useTable`'s options thunk,
66
- // so tracked properties read in `getTableOptions` stay reactive. Per-table
67
- // options take precedence over the shared defaults (except `features`,
68
- // which only the hook provides).
69
- return useTable<TFeatures, TData>(
70
- () =>
71
- ({
72
- ...defaultTableOptions,
73
- ...getTableOptions(),
74
- }) as TableOptions<TFeatures, TData>,
75
- )
76
- }
77
-
78
- return {
79
- appFeatures: defaultTableOptions.features as TFeatures,
80
- createAppColumnHelper,
81
- createAppTable,
82
- }
83
- }
@@ -1 +0,0 @@
1
- export * from '@tanstack/table-core/experimental-worker-plugin'
@@ -1,103 +0,0 @@
1
- import type { ComponentLike } from '@glint/template'
2
- import type {
3
- CellContext,
4
- CellData,
5
- HeaderContext,
6
- RowData,
7
- TableFeatures,
8
- } from '@tanstack/table-core'
9
- export { flexRender } from '@tanstack/table-core/flex-render'
10
-
11
- export type FlexRenderContext<
12
- TFeatures extends TableFeatures = TableFeatures,
13
- TData extends RowData = RowData,
14
- TValue extends CellData = CellData,
15
- > =
16
- | CellContext<TFeatures, TData, TValue>
17
- | HeaderContext<TFeatures, TData, TValue>
18
-
19
- export interface FlexRenderableSignature<
20
- TFeatures extends TableFeatures = TableFeatures,
21
- TData extends RowData = RowData,
22
- TValue extends CellData = CellData,
23
- TOptions = undefined,
24
- > {
25
- Args: {
26
- ctx: FlexRenderContext<TFeatures, TData, TValue>
27
- options?: TOptions
28
- }
29
- }
30
-
31
- export interface CellRenderableSignature<
32
- TFeatures extends TableFeatures = TableFeatures,
33
- TData extends RowData = RowData,
34
- TValue extends CellData = CellData,
35
- TOptions = undefined,
36
- > {
37
- Args: {
38
- ctx: CellContext<TFeatures, TData, TValue>
39
- options?: TOptions
40
- }
41
- }
42
-
43
- type FlexRenderableComponent<
44
- TFeatures extends TableFeatures,
45
- TData extends RowData,
46
- TValue extends CellData,
47
- TOptions,
48
- > =
49
- | ComponentLike<FlexRenderableSignature<TFeatures, TData, TValue, TOptions>>
50
- | ComponentLike<CellRenderableSignature<TFeatures, TData, TValue, TOptions>>
51
-
52
- export class FlexRenderComponentConfig<
53
- TFeatures extends TableFeatures = TableFeatures,
54
- TData extends RowData = RowData,
55
- TValue extends CellData = CellData,
56
- TOptions = undefined,
57
- > {
58
- readonly component: FlexRenderableComponent<
59
- TFeatures,
60
- TData,
61
- TValue,
62
- TOptions
63
- >
64
- readonly options?: TOptions
65
-
66
- constructor(
67
- component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,
68
- options?: TOptions,
69
- ) {
70
- this.component = component
71
- this.options = options
72
- }
73
- }
74
-
75
- export function flexRenderComponent<
76
- TFeatures extends TableFeatures,
77
- TData extends RowData,
78
- TValue extends CellData,
79
- >(
80
- component: FlexRenderableComponent<TFeatures, TData, TValue, undefined>,
81
- ): FlexRenderComponentConfig<TFeatures, TData, TValue, undefined>
82
-
83
- export function flexRenderComponent<
84
- TFeatures extends TableFeatures,
85
- TData extends RowData,
86
- TValue extends CellData,
87
- TOptions,
88
- >(
89
- component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,
90
- options: TOptions,
91
- ): FlexRenderComponentConfig<TFeatures, TData, TValue, TOptions>
92
-
93
- export function flexRenderComponent<
94
- TFeatures extends TableFeatures = TableFeatures,
95
- TData extends RowData = RowData,
96
- TValue extends CellData = CellData,
97
- TOptions = undefined,
98
- >(
99
- component: FlexRenderableComponent<TFeatures, TData, TValue, TOptions>,
100
- options?: TOptions,
101
- ): FlexRenderComponentConfig<TFeatures, TData, TValue, TOptions> {
102
- return new FlexRenderComponentConfig(component, options)
103
- }
@@ -1,6 +0,0 @@
1
- export * from './flex-render-helpers.ts'
2
- export {
3
- FlexRenderCell,
4
- FlexRenderHeader,
5
- FlexRenderFooter,
6
- } from './FlexRender.gts'
package/src/index.ts DELETED
@@ -1,31 +0,0 @@
1
- export * from '@tanstack/table-core'
2
- export { useTable } from './use-table.ts'
3
- export { createTableHook } from './create-table-hook.ts'
4
- export type {
5
- CreateTableHookOptions,
6
- AppEmberTable,
7
- AppColumnHelper,
8
- } from './create-table-hook.ts'
9
- export {
10
- flexRender,
11
- flexRenderComponent,
12
- FlexRenderComponentConfig,
13
- } from './flex-render.ts'
14
- export type {
15
- FlexRenderableSignature,
16
- CellRenderableSignature,
17
- FlexRenderContext,
18
- } from './flex-render.ts'
19
- export {
20
- FlexRenderCell,
21
- FlexRenderHeader,
22
- FlexRenderFooter,
23
- } from './FlexRender.gts'
24
- export { emberReactivity } from './reactivity.ts'
25
- export {
26
- computed,
27
- signal,
28
- createAtom,
29
- Signal,
30
- ComputedSignal,
31
- } from './signal.ts'
package/src/reactivity.ts DELETED
@@ -1,39 +0,0 @@
1
- import type { Subscription } from '@tanstack/store'
2
- import type {
3
- TableAtomOptions,
4
- TableReactivityBindings,
5
- } from '@tanstack/table-core/reactivity'
6
-
7
- import { untrack } from '@glimmer/validator'
8
- import { computed, signal } from './signal.ts'
9
-
10
- export function emberReactivity(): TableReactivityBindings {
11
- const subscriptions = new Set<Subscription>()
12
-
13
- return {
14
- createOptionsStore: true,
15
- wrapExternalAtoms: true,
16
-
17
- // timing is not important, but the main thing is that the work does *not*
18
- // happen during the render phase.
19
- schedule: (fn) => queueMicrotask(() => fn()),
20
- batch: (fn) => fn(),
21
- untrack,
22
- // @cached
23
- createReadonlyAtom: <T>(fn: () => T) => {
24
- return computed(fn)
25
- },
26
- // @tracked
27
- createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {
28
- return signal(value, options)
29
- },
30
- // Not for the ember integration, but for the tanstack inspector
31
- addSubscription: (subscription) => {
32
- subscriptions.add(subscription)
33
- },
34
- unmount: () => {
35
- subscriptions.forEach((s) => s.unsubscribe())
36
- subscriptions.clear()
37
- },
38
- }
39
- }
package/src/signal.ts DELETED
@@ -1,126 +0,0 @@
1
- import type { Atom, AtomOptions, Observer, Subscription } from '@tanstack/store'
2
-
3
- import { tracked, cached } from '@glimmer/tracking'
4
- import { untrack } from '@glimmer/validator'
5
-
6
- export function subscribeNoEffect(): Subscription {
7
- return null as unknown as Subscription
8
- }
9
-
10
- /**
11
- * Ember-native signal implementation.
12
- * In future ember >7.3 `tracked` will be available by itself
13
- * so the class wrapper will not be needed for those versions
14
- */
15
- export class Signal<T> {
16
- @tracked _value
17
-
18
- #options: AtomOptions<T> | undefined
19
-
20
- // Ember reads are tag-tracked; this observer list exists for the plain-JS
21
- // subscribers core wires up (external-atom sync in constructTable, the
22
- // inspector), which have no access to framework tracking.
23
- #listeners = new Set<(value: T) => void>()
24
-
25
- constructor(value: T, options: AtomOptions<T> | undefined) {
26
- this._value = value
27
- this.#options = options
28
- }
29
-
30
- subscribe(
31
- listenerOrObserver: Observer<T> | ((value: T) => void),
32
- ): Subscription {
33
- const listener =
34
- typeof listenerOrObserver === 'function'
35
- ? listenerOrObserver
36
- : listenerOrObserver.next
37
-
38
- if (!listener) {
39
- return { unsubscribe: () => {} }
40
- }
41
-
42
- this.#listeners.add(listener)
43
- return { unsubscribe: () => this.#listeners.delete(listener) }
44
- }
45
-
46
- get() {
47
- return this.value
48
- }
49
- set(value: T | ((prev: T) => T)) {
50
- if (typeof value === 'function') {
51
- return this.update(value as unknown as (prev: T) => T)
52
- }
53
-
54
- this.value = value
55
- }
56
-
57
- get value() {
58
- return this._value
59
- }
60
-
61
- set value(next: T) {
62
- const prev = untrack(() => this._value)
63
-
64
- const isEqual = this.#options?.compare
65
- ? this.#options.compare(prev, next)
66
- : prev === next
67
- if (isEqual) {
68
- return
69
- }
70
-
71
- this._value = next
72
-
73
- for (const listener of this.#listeners) {
74
- listener(next)
75
- }
76
- }
77
-
78
- update(fn: (value: T) => T) {
79
- const original = untrack(() => this._value)
80
-
81
- this.value = fn(original)
82
- }
83
- }
84
-
85
- export class ComputedSignal<T> {
86
- #compute
87
-
88
- constructor(compute: () => T) {
89
- this.#compute = compute
90
- }
91
-
92
- get() {
93
- return this.value
94
- }
95
-
96
- subscribe = subscribeNoEffect
97
-
98
- @cached
99
- get value() {
100
- return this.#compute()
101
- }
102
- }
103
-
104
- export function signal<T>(value: T, options: AtomOptions<T> | undefined) {
105
- return new Signal(value, options)
106
- }
107
-
108
- /**
109
- * Creates an Ember-native writable atom, satisfying the `@tanstack/store`
110
- * `Atom` contract so it can be passed to `options.atoms`. Because it is backed
111
- * by a `@tracked` Signal, reading `atom.get()` directly in a template or
112
- * getter is reactive — unlike a foreign `@tanstack/store` atom, whose reads
113
- * create no Glimmer tag dependency.
114
- *
115
- * Takes a plain initial value only; there is no derived/function overload.
116
- */
117
- export function createAtom<T>(
118
- initialValue: T,
119
- options?: AtomOptions<T>,
120
- ): Atom<T> {
121
- return signal(initialValue, options)
122
- }
123
-
124
- export function computed<T>(fn: () => T) {
125
- return new ComputedSignal(fn)
126
- }
@@ -1 +0,0 @@
1
- export * from '@tanstack/table-core/static-functions'
package/src/use-table.ts DELETED
@@ -1,154 +0,0 @@
1
- import { constructTable } from '@tanstack/table-core'
2
- import { untrack } from '@glimmer/validator'
3
- import { emberReactivity } from './reactivity.ts'
4
- import { computed, subscribeNoEffect } from './signal.ts'
5
- import type {
6
- RowData,
7
- Table,
8
- TableFeatures,
9
- TableOptions,
10
- TableState,
11
- } from '@tanstack/table-core'
12
- import type { Atom, ReadonlyAtom, ReadonlyStore } from '@tanstack/store'
13
-
14
- // Internal table slots used by the pull-based options/state wiring below.
15
- // `Table_Internal` is not exported from the table-core build, so the shape is
16
- // declared structurally here.
17
- interface TableInternals<
18
- TFeatures extends TableFeatures,
19
- TData extends RowData,
20
- > {
21
- optionsStore?: {
22
- get(): TableOptions<TFeatures, TData>
23
- set(value: () => TableOptions<TFeatures, TData>): void
24
- }
25
- baseAtoms: Record<string, { get(): unknown }>
26
- atoms: Record<string, unknown>
27
- }
28
-
29
- export function useTable<
30
- TFeatures extends TableFeatures,
31
- TData extends RowData,
32
- >(getOptions: () => TableOptions<TFeatures, TData>): Table<TFeatures, TData> {
33
- const reactivity = emberReactivity()
34
-
35
- // Creates reactive read only signal for options
36
- const userOptions = computed(getOptions)
37
-
38
- // Untracked to prevent possible "set on same computation as read" errors in Ember.
39
- const initialOptions = untrack(() => userOptions.get())
40
-
41
- const table = constructTable<TFeatures, TData>({
42
- ...initialOptions,
43
- features: {
44
- coreReactivityFeature: reactivity,
45
- ...initialOptions.features,
46
- },
47
- mergeOptions: (
48
- defaultOptions: TableOptions<TFeatures, TData>,
49
- newOptions: Partial<TableOptions<TFeatures, TData>>,
50
- ) => ({
51
- ...defaultOptions,
52
- ...newOptions,
53
- }),
54
- }) as Table<TFeatures, TData> & TableInternals<TFeatures, TData>
55
-
56
- const optionsStore = table.optionsStore!
57
-
58
- const liveOptions = computed(() => {
59
- const stored = optionsStore.get()
60
- return {
61
- ...stored,
62
- ...userOptions.get(),
63
- // stored options carry construct-time normalization (the reactivity
64
- // feature, wrapped external atoms) that must win over the raw user
65
- // options.
66
- features: stored.features,
67
- atoms: stored.atoms,
68
- }
69
- })
70
-
71
- /**
72
- * This is to get around core table not using lazy access so we need to re-wrap
73
- *
74
- * Similar to other reactive signal frameworks (solid, angular, svelte)
75
- */
76
- Object.defineProperty(table, 'options', {
77
- configurable: true,
78
- enumerable: true,
79
- get: () => liveOptions.get(),
80
- set: (value: TableOptions<TFeatures, TData>) => {
81
- optionsStore.set(() => value)
82
- },
83
- })
84
-
85
- const atoms: Record<string, ReadonlyAtom<unknown>> = table.atoms
86
- const stateKeys = Object.keys(table.baseAtoms)
87
-
88
- for (const key of stateKeys) {
89
- const baseAtom = (table.baseAtoms as Record<string, ReadonlyAtom<unknown>>)[
90
- key
91
- ]!
92
-
93
- /**
94
- * Original atoms could cause effects for top level properties
95
- *
96
- * Core table should migrate to pure derived data which would boost render
97
- * performance for both signal and non-signal frameworks.
98
- */
99
- atoms[key] = reactivity.createReadonlyAtom(
100
- () => {
101
- const externalAtom = (
102
- table.options.atoms as Record<string, Atom<unknown>> | undefined
103
- )?.[key]
104
- if (externalAtom) {
105
- return externalAtom.get()
106
- }
107
- const stateSlice = (
108
- table.options.state as Record<string, unknown> | undefined
109
- )?.[key]
110
- if (stateSlice !== undefined) {
111
- return stateSlice
112
- }
113
- return baseAtom.get()
114
- },
115
- { debugName: `table/atoms/${key}` },
116
- )
117
- }
118
-
119
- const stateProxy: TableState<TFeatures> = new Proxy(
120
- {},
121
- {
122
- get: (_target, key) =>
123
- typeof key === 'string' ? atoms[key]?.get() : undefined,
124
- has: (_target, key) => typeof key === 'string' && stateKeys.includes(key),
125
- ownKeys: () => stateKeys,
126
- getOwnPropertyDescriptor: (_target, key) =>
127
- typeof key === 'string' && stateKeys.includes(key)
128
- ? {
129
- enumerable: true,
130
- configurable: true,
131
- value: atoms[key]!.get(),
132
- }
133
- : undefined,
134
- },
135
- ) as TableState<TFeatures>
136
-
137
- /**
138
- * Store is reasigned to point to proxy object to allow individual state slices to be independently reactive.
139
- *
140
- * Type cast is needed because we are setting during construction
141
- * Table store is readonly after first initialization.
142
- */
143
- ;(
144
- table as { store: Omit<ReadonlyStore<TableState<TFeatures>>, 'atom'> }
145
- ).store = {
146
- get: () => stateProxy,
147
- get state() {
148
- return stateProxy
149
- },
150
- subscribe: subscribeNoEffect,
151
- }
152
-
153
- return table
154
- }