@tanstack/angular-table 9.0.0-alpha.4 → 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 (43) hide show
  1. package/README.md +117 -0
  2. package/dist/README.md +117 -0
  3. package/dist/fesm2022/tanstack-angular-table-static-functions.mjs +6 -0
  4. package/dist/fesm2022/tanstack-angular-table-static-functions.mjs.map +1 -0
  5. package/dist/fesm2022/tanstack-angular-table.mjs +1233 -252
  6. package/dist/fesm2022/tanstack-angular-table.mjs.map +1 -1
  7. package/dist/types/tanstack-angular-table-static-functions.d.ts +1 -0
  8. package/dist/types/tanstack-angular-table.d.ts +798 -0
  9. package/package.json +36 -18
  10. package/src/flex-render/context.ts +14 -0
  11. package/src/flex-render/flags.ts +34 -0
  12. package/src/flex-render/flexRenderComponent.ts +288 -0
  13. package/src/flex-render/flexRenderComponentFactory.ts +241 -0
  14. package/src/flex-render/renderer.ts +393 -0
  15. package/src/flex-render/view.ts +207 -0
  16. package/src/flexRender.ts +124 -0
  17. package/src/helpers/cell.ts +104 -0
  18. package/src/helpers/createTableHook.ts +483 -0
  19. package/src/helpers/flexRenderCell.ts +136 -0
  20. package/src/helpers/header.ts +99 -0
  21. package/src/helpers/table.ts +87 -0
  22. package/src/index.ts +21 -70
  23. package/src/injectTable.ts +189 -0
  24. package/src/{lazy-signal-initializer.ts → lazySignalInitializer.ts} +2 -2
  25. package/src/reactivity.ts +65 -0
  26. package/static-functions/index.ts +1 -0
  27. package/static-functions/ng-package.json +6 -0
  28. package/dist/esm2022/flex-render.mjs +0 -150
  29. package/dist/esm2022/index.mjs +0 -48
  30. package/dist/esm2022/lazy-signal-initializer.mjs +0 -43
  31. package/dist/esm2022/proxy.mjs +0 -83
  32. package/dist/esm2022/tanstack-angular-table.mjs +0 -5
  33. package/dist/flex-render.d.ts +0 -31
  34. package/dist/index.d.ts +0 -5
  35. package/dist/lazy-signal-initializer.d.ts +0 -5
  36. package/dist/proxy.d.ts +0 -3
  37. package/src/__tests__/createAngularTable.test.ts +0 -95
  38. package/src/__tests__/flex-render.test.ts +0 -178
  39. package/src/__tests__/lazy-init.test.ts +0 -124
  40. package/src/__tests__/test-setup.ts +0 -12
  41. package/src/__tests__/test-utils.ts +0 -62
  42. package/src/flex-render.ts +0 -187
  43. package/src/proxy.ts +0 -97
@@ -0,0 +1,798 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Type, ComponentMirror, OutputEmitterRef, InputSignal, Injector, createComponent, Binding, TemplateRef, InjectionToken, Signal, ValueEqualityFn } from '@angular/core';
3
+ import { TableFeatures, RowData, CellData, Cell, Header, CellContext, HeaderContext, TableState, Table, TableOptions, Column, Row, IdentifiedColumnDef, AccessorFn, DeepKeys, DeepValue, AccessorFnColumnDef, AccessorKeyColumnDef, ColumnDef, DisplayColumnDef, GroupColumnDef } from '@tanstack/table-core';
4
+ export * from '@tanstack/table-core';
5
+ import { Atom, ReadonlyAtom } from '@tanstack/angular-store';
6
+
7
+ /**
8
+ * Simplified directive wrapper of `*flexRender`.
9
+ *
10
+ * Use this utility component to render headers, cells, or footers with custom markup.
11
+ *
12
+ * Only one prop (`cell`, `header`, or `footer`) may be passed based on the used selector.
13
+ *
14
+ * @example
15
+ * ```html
16
+ * <td *flexRenderCell="cell; let cell">{{cell}}</td>
17
+ * <th *flexRenderHeader="header; let header">{{header}}</th>
18
+ * <th *flexRenderFooter="footer; let footer">{{footer}}</th>
19
+ * ```
20
+ *
21
+ * This replaces calling `*flexRender` directly like this:
22
+ * ```html
23
+ * <td *flexRender="cell.column.columnDef.cell; props: cell.getContext(); let cell">{{cell}}</td>
24
+ * <td *flexRender="header.column.columnDef.header; props: header.getContext(); let header">{{header}}</td>
25
+ * <td *flexRender="footer.column.columnDef.footer; props: footer.getContext(); let footer">{{footer}}</td>
26
+ * ```
27
+ *
28
+ * Can be imported through {@link FlexRenderCell} or {@link FlexRender} import,
29
+ * which the latter is preferred.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import {FlexRender} from '@tanstack/angular-table
34
+ *
35
+ * @Component({
36
+ * // ...
37
+ * imports: [
38
+ * FlexRender
39
+ * ]
40
+ * })
41
+ * ```
42
+ */
43
+ declare class FlexRenderCell<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData> {
44
+ #private;
45
+ readonly cell: i0.InputSignal<Cell<TFeatures, TData, TValue> | undefined>;
46
+ readonly header: i0.InputSignal<Header<TFeatures, TData, TValue> | undefined>;
47
+ readonly footer: i0.InputSignal<Header<TFeatures, TData, TValue> | undefined>;
48
+ constructor();
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<FlexRenderCell<any, any, any>, never>;
50
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FlexRenderCell<any, any, any>, "ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]", never, { "cell": { "alias": "flexRenderCell"; "required": false; "isSignal": true; }; "header": { "alias": "flexRenderHeader"; "required": false; "isSignal": true; }; "footer": { "alias": "flexRenderFooter"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
51
+ }
52
+
53
+ type CreateComponentOptions = Parameters<typeof createComponent>[1];
54
+ type CreateComponentBindings = CreateComponentOptions['bindings'];
55
+ type CreateComponentDirectives = CreateComponentOptions['directives'];
56
+ interface FlexRenderOptions<TInputs extends Record<string, any>, TOutputs extends Record<string, any>> {
57
+ /**
58
+ * Native Angular bindings applied at component creation time via `createComponent`.
59
+ * Use this option to set inputs, outputs, or two-way bindings at creation time.
60
+ * Shouldn't be used together with {@link FlexRenderOptions#inputs} or {@link FlexRenderOptions#outputs} option.
61
+ *
62
+ * Binding input/outputs at creation time: {@link https://angular.dev/guide/components/programmatic-rendering#binding-inputs-outputs-and-setting-host-directives-at-creation}
63
+ *
64
+ * Two-way binding: {@link https://angular.dev/api/core/twoWayBinding}
65
+ *
66
+ * Output binding: {@link https://angular.dev/api/core/outputBinding}
67
+ *
68
+ * Input binding: {@link https://angular.dev/api/core/inputBinding}
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import {flexRenderComponent} from '@tanstack/angular-table';
73
+ * flexRenderComponent(MyComponent, {
74
+ * bindings: [
75
+ * // Will update `value` input every time `mySignalValue` changes
76
+ * inputBinding('value', mySignalValue),
77
+ * // Set myProperty to 1 when the component is created
78
+ * inputBinding('myProperty', () => 1),
79
+ * // Callback called every time `valueChange` output emit
80
+ * outputBinding('valueChange', value => {
81
+ * console.log("my value changed to", value)
82
+ * }),
83
+ * // Two-way binding between `value` input and `valueChange` output
84
+ * // Useful while using `model` inputs.
85
+ * twoWayBinding('value', mySignal)
86
+ * ]
87
+ * })
88
+ * ```
89
+ */
90
+ readonly bindings?: Array<Binding>;
91
+ /**
92
+ * Directives to apply to the component at creation time.
93
+ *
94
+ * Binding directives at creation time: {@link https://angular.dev/guide/components/programmatic-rendering#binding-inputs-outputs-and-setting-host-directives-at-creation}
95
+ *
96
+ * Two-way binding: {@link https://angular.dev/api/core/twoWayBinding}
97
+ *
98
+ * Output binding: {@link https://angular.dev/api/core/outputBinding}
99
+ *
100
+ * Input binding: {@link https://angular.dev/api/core/inputBinding}
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import {flexRenderComponent} from '@tanstack/angular-table';
105
+ * flexRenderComponent(MyComponent, {
106
+ * bindings: [
107
+ * // ...
108
+ * ],
109
+ * directives: [
110
+ * DirectiveA,
111
+ * {
112
+ * type: DirectiveB,
113
+ * bindings: [
114
+ * inputBinding('value', mySignalValue),
115
+ * // ...
116
+ * ]
117
+ * }
118
+ * ]
119
+ * })
120
+ * ```
121
+ */
122
+ readonly directives?: CreateComponentDirectives;
123
+ /**
124
+ * Component instance inputs.
125
+ *
126
+ * These values are assigned after the component has been created using
127
+ * [componentRef.setInput API](https://angular.dev/api/core/ComponentRef#setInput).
128
+ *
129
+ * Shouldn't be used together with {@link FlexRenderOptions#bindings} option
130
+ */
131
+ readonly inputs?: TInputs;
132
+ /**
133
+ * Component instance outputs.
134
+ *
135
+ * Outputs are wired imperatively after component creation using {@link OutputEmitterRef#subscribe}.
136
+ *
137
+ * Shouldn't be used together with {@link FlexRenderOptions#bindings} option
138
+ */
139
+ readonly outputs?: TOutputs;
140
+ /**
141
+ * Optional {@link Injector} that will be used when rendering the component
142
+ */
143
+ readonly injector?: Injector;
144
+ }
145
+ type Inputs<T> = {
146
+ [K in keyof T as T[K] extends InputSignal<infer R> ? K : never]?: T[K] extends InputSignal<infer R> ? R : never;
147
+ };
148
+ type Outputs<T> = {
149
+ [K in keyof T as T[K] extends OutputEmitterRef<infer R> ? K : never]?: T[K] extends OutputEmitterRef<infer R> ? OutputEmitterRef<R>['emit'] : never;
150
+ };
151
+ /**
152
+ * Helper function to create a {@link FlexRenderComponent} instance, with better type-safety.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import {flexRenderComponent} from '@tanstack/angular-table'
157
+ * import {inputBinding, outputBinding} from '@angular/core';
158
+ *
159
+ * const columns = [
160
+ * {
161
+ * cell: ({ row }) => {
162
+ * return flexRenderComponent(MyComponent, {
163
+ * inputs: { value: mySignalValue() },
164
+ * outputs: { valueChange: (val) => {} }
165
+ * // or using angular native createComponent#binding api
166
+ * bindings: [
167
+ * inputBinding('value', mySignalValue),
168
+ * outputBinding('valueChange', value => {
169
+ * console.log("my value changed to", value)
170
+ * })
171
+ * ]
172
+ * })
173
+ * },
174
+ * },
175
+ * ]
176
+ * ```
177
+ */
178
+ declare function flexRenderComponent<TComponent = any>(component: Type<TComponent>, options?: FlexRenderOptions<Inputs<TComponent>, Outputs<TComponent>>): FlexRenderComponent<TComponent>;
179
+ /**
180
+ * Wrapper interface for a component that will be used as content for {@link FlexRenderDirective}.
181
+ * Can be created using {@link flexRenderComponent} helper.
182
+ *
183
+ * @example
184
+ *
185
+ * ```ts
186
+ * import {flexRenderComponent} from '@tanstack/angular-table'
187
+ *
188
+ * // Usage in cell/header/footer definition
189
+ * const columns = [
190
+ * {
191
+ * cell: ({ row }) => {
192
+ * return flexRenderComponent(MyComponent, {
193
+ * inputs: { value: mySignalValue() },
194
+ * outputs: { valueChange: (val) => {} }
195
+ * // or using angular createComponent#bindings api
196
+ * bindings: [
197
+ * inputBinding('value', mySignalValue),
198
+ * outputBinding('valueChange', value => {
199
+ * console.log("my value changed to", value)
200
+ * })
201
+ * ]
202
+ * })
203
+ * },
204
+ * },
205
+ * ]
206
+ *
207
+ * import {input, output} from '@angular/core';
208
+ *
209
+ * @Component({
210
+ * selector: 'my-component',
211
+ * })
212
+ * class MyComponent {
213
+ * readonly value = input(0);
214
+ * readonly valueChange = output<number>();
215
+ * }
216
+ *
217
+ * ```
218
+ */
219
+ interface FlexRenderComponent<TComponent = any> {
220
+ /**
221
+ * The component type
222
+ */
223
+ readonly component: Type<TComponent>;
224
+ /**
225
+ * Reflected metadata about the component.
226
+ */
227
+ readonly mirror: ComponentMirror<TComponent>;
228
+ /**
229
+ * List of allowed input names.
230
+ */
231
+ readonly allowedInputNames: Array<string>;
232
+ /**
233
+ * List of allowed output names.
234
+ */
235
+ readonly allowedOutputNames: Array<string>;
236
+ /**
237
+ * Component instance outputs. Subscribed via {@link OutputEmitterRef#subscribe}
238
+ *
239
+ * @see {@link FlexRenderOptions#outputs}
240
+ */
241
+ readonly outputs?: Outputs<TComponent>;
242
+ /**
243
+ * Component instance inputs. Set via [componentRef.setInput API](https://angular.dev/api/core/ComponentRef#setInput))
244
+ *
245
+ * @see {@link FlexRenderOptions#inputs}
246
+ */
247
+ readonly inputs?: Inputs<TComponent>;
248
+ /**
249
+ * Optional {@link Injector} that will be used when rendering the component.
250
+ *
251
+ * @see {@link FlexRenderOptions#injector}
252
+ */
253
+ readonly injector?: Injector;
254
+ /**
255
+ * Bindings to apply to the root component
256
+ *
257
+ * @see {@link FlexRenderOptions#bindings}
258
+ */
259
+ bindings?: CreateComponentBindings;
260
+ /**
261
+ * Directives that should be applied to the component.
262
+ *
263
+ * @see {FlexRenderOptions#directives}
264
+ */
265
+ directives?: CreateComponentDirectives;
266
+ }
267
+ /**
268
+ * Wrapper class for a component that will be used as content for {@link FlexRenderDirective}
269
+ *
270
+ * Prefer {@link flexRenderComponent} helper for better type-safety
271
+ */
272
+ declare class FlexRenderComponentInstance<TComponent = any> implements FlexRenderComponent<TComponent> {
273
+ readonly component: Type<TComponent>;
274
+ readonly inputs?: Inputs<TComponent> | undefined;
275
+ readonly injector?: Injector | undefined;
276
+ readonly outputs?: Outputs<TComponent> | undefined;
277
+ readonly directives?: CreateComponentDirectives;
278
+ readonly bindings?: CreateComponentBindings;
279
+ readonly mirror: ComponentMirror<TComponent>;
280
+ readonly allowedInputNames: Array<string>;
281
+ readonly allowedOutputNames: Array<string>;
282
+ constructor(component: Type<TComponent>, inputs?: Inputs<TComponent> | undefined, injector?: Injector | undefined, outputs?: Outputs<TComponent> | undefined, directives?: CreateComponentDirectives, bindings?: CreateComponentBindings);
283
+ }
284
+
285
+ /**
286
+ * Content supported by the `flexRender` directive when declaring
287
+ * a table column header/cell.
288
+ */
289
+ type FlexRenderContent<TProps extends NonNullable<unknown>> = string | number | Type<TProps> | FlexRenderComponent<TProps> | TemplateRef<{
290
+ $implicit: TProps;
291
+ }> | null | Record<any, any> | undefined;
292
+ /**
293
+ * Input content supported by the `flexRender` directives.
294
+ */
295
+ type FlexRenderInputContent<TProps extends NonNullable<unknown>> = number | string | ((props: TProps) => FlexRenderContent<TProps>) | null | undefined;
296
+
297
+ declare const FlexRenderComponentProps: InjectionToken<{}>;
298
+ /**
299
+ * Inject the flex render context props.
300
+ *
301
+ * Can be used in components rendered via FlexRender directives.
302
+ */
303
+ declare function injectFlexRenderContext<T extends NonNullable<unknown>>(): T;
304
+
305
+ /**
306
+ * Use this utility directive to render headers, cells, or footers with custom markup.
307
+ *
308
+ * Note: If you are rendering cell, header, or footer without custom context or other props,
309
+ * you can use the {@link FlexRenderCell} directive as shorthand instead .
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * import {FlexRender} from '@tanstack/angular-table';
314
+ *
315
+ * @Component({
316
+ * imports: [FlexRender],
317
+ * template: `
318
+ * <td
319
+ * *flexRender="
320
+ * cell.column.columnDef.cell;
321
+ * props: cell.getContext();
322
+ * let cell"
323
+ * >
324
+ * {{cell}}
325
+ * </td>
326
+ *
327
+ * <th
328
+ * *flexRender="
329
+ * header.column.columnDef.header;
330
+ * props: header.getContext();
331
+ * let header"
332
+ * >
333
+ * {{header}}
334
+ * </td>
335
+ *
336
+ * <td
337
+ * *flexRender="
338
+ * footer.column.columnDef.footer;
339
+ * props: footer.getContext();
340
+ * let footer"
341
+ * >
342
+ * {{footer}}
343
+ * </td>
344
+ * `,
345
+ * })
346
+ * class App {
347
+ * }
348
+ * ```
349
+ *
350
+ * Can be imported through {@link FlexRenderDirective} or {@link FlexRender} import,
351
+ * which the latter is preferred.
352
+ */
353
+ declare class FlexRenderDirective<TFeatures extends TableFeatures, TRowData extends RowData, TValue extends CellData, TProps extends NonNullable<unknown> | CellContext<TFeatures, TRowData, TValue> | HeaderContext<TFeatures, TRowData, TValue>> {
354
+ #private;
355
+ readonly content: InputSignal<FlexRenderInputContent<TProps>>;
356
+ readonly props: InputSignal<TProps>;
357
+ readonly injector: InputSignal<Injector>;
358
+ constructor();
359
+ static ɵfac: i0.ɵɵFactoryDeclaration<FlexRenderDirective<any, any, any, any>, never>;
360
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FlexRenderDirective<any, any, any, any>, "ng-template[flexRender]", never, { "content": { "alias": "flexRender"; "required": false; "isSignal": true; }; "props": { "alias": "flexRenderProps"; "required": false; "isSignal": true; }; "injector": { "alias": "flexRenderInjector"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
361
+ }
362
+
363
+ /**
364
+ * Store mode: pass `selector` (required) to project from full table state.
365
+ * Source mode: pass `source` (atom or store); omit `selector` for the whole value
366
+ * (identity), or pass `selector` to project. Split overloads match React `Subscribe`
367
+ * inference.
368
+ */
369
+ interface AngularTableComputed<TFeatures extends TableFeatures> {
370
+ <TSourceValue>(props: {
371
+ source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
372
+ selector?: undefined;
373
+ equal?: ValueEqualityFn<TSourceValue>;
374
+ }): Signal<Readonly<TSourceValue>>;
375
+ <TSourceValue, TSubSelected>(props: {
376
+ source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>;
377
+ selector: (state: TSourceValue) => TSubSelected;
378
+ equal?: ValueEqualityFn<TSubSelected>;
379
+ }): Signal<Readonly<TSubSelected>>;
380
+ <TSubSelected>(props: {
381
+ selector: (state: TableState<TFeatures>) => TSubSelected;
382
+ equal?: ValueEqualityFn<TSubSelected>;
383
+ }): Signal<Readonly<TSubSelected>>;
384
+ }
385
+ type AngularTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Table<TFeatures, TData> & {
386
+ /**
387
+ * The selected state from the table store, based on the selector provided.
388
+ */
389
+ readonly state: Signal<Readonly<TSelected>>;
390
+ /**
391
+ * A signal that returns the entire table instance. Will update on table/options change.
392
+ */
393
+ readonly value: Signal<AngularTable<TFeatures, TData, TSelected>>;
394
+ /**
395
+ * Creates a computed that subscribe to changes in the table store with a custom selector.
396
+ * Default equality function is "shallow".
397
+ */
398
+ computed: <TSubSelected = {}>(props: {
399
+ selector: (state: TableState<TFeatures>) => TSubSelected;
400
+ equal?: ValueEqualityFn<TSubSelected>;
401
+ }) => Signal<Readonly<TSubSelected>>;
402
+ };
403
+ /**
404
+ * Creates and returns an Angular-reactive table instance.
405
+ *
406
+ * The initializer is intentionally re-evaluated whenever any signal read inside it changes.
407
+ * This is how the adapter keeps the table in sync with Angular's reactivity model.
408
+ *
409
+ * Because of that behavior, keep expensive/static values (for example `columns`, feature setup, row models)
410
+ * as stable references outside the initializer, and only read reactive state (`data()`, pagination/filter/sorting signals, etc.)
411
+ * inside it.
412
+ *
413
+ * The returned table is also signal-reactive: table state and table APIs are wired for Angular signals, so you can safely consume table methods inside `computed(...)` and `effect(...)`.
414
+ *
415
+ * @example
416
+ * 1. Register the table features you need
417
+ * ```ts
418
+ * // Register only the features you need
419
+ * import {tableFeatures, rowPaginationFeature} from '@tanstack/angular-table';
420
+ * const _features = tableFeatures({
421
+ * rowPaginationFeature,
422
+ * // ...all other features you need
423
+ * })
424
+ *
425
+ * // Use all table core features
426
+ * import {stockFeatures} from '@tanstack/angular-table';
427
+ * const _features = tableFeatures(stockFeatures);
428
+ * ```
429
+ * 2. Prepare the table columns
430
+ * ```ts
431
+ * import {ColumnDef} from '@tanstack/angular-table';
432
+ *
433
+ * type MyData = {}
434
+ *
435
+ * const columns: ColumnDef<typeof _features, MyData>[] = [
436
+ * // ...column definitions
437
+ * ]
438
+ *
439
+ * // or using createColumnHelper
440
+ * import {createColumnHelper} from '@tanstack/angular-table';
441
+ * const columnHelper = createColumnHelper<typeof _features, MyData>();
442
+ * const columns = columnHelper.columns([
443
+ * columnHelper.accessor(...),
444
+ * // ...other columns
445
+ * ])
446
+ * ```
447
+ * 3. Create the table instance with `injectTable`
448
+ * ```ts
449
+ * const table = injectTable(() => {
450
+ * // ...table options,
451
+ * _features,
452
+ * columns: columns,
453
+ * data: myDataSignal(),
454
+ * })
455
+ * ```
456
+ *
457
+ * @returns An Angular-reactive TanStack Table instance.
458
+ */
459
+ declare function injectTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>>(options: () => TableOptions<TFeatures, TData>, selector?: (state: TableState<TFeatures>) => TSelected): AngularTable<TFeatures, TData, TSelected>;
460
+
461
+ /**
462
+ * DI context shape for a TanStack Table cell.
463
+ *
464
+ * This exists to make the current `Cell` injectable by any nested component/directive
465
+ * without having to pass it through inputs/props manually.
466
+ */
467
+ interface TanStackTableCellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData> {
468
+ /** Signal that returns the current cell instance. */
469
+ cell: Signal<Cell<TFeatures, TData, TValue>>;
470
+ }
471
+ /**
472
+ * Injection token that provides access to the current cell.
473
+ *
474
+ * This token is provided by the {@link TanStackTableCell} directive.
475
+ */
476
+ declare const TanStackTableCellToken: InjectionToken<Signal<any>>;
477
+ /**
478
+ * Provides a TanStack Table `Cell` instance in Angular DI.
479
+ *
480
+ * The cell can be injected by:
481
+ * - any descendant of an element using `[tanStackTableCell]="..."`
482
+ * - any component instantiated by `*flexRender` when the render props contains `cell`
483
+ *
484
+ * @example
485
+ * Inject from the nearest `[tanStackTableCell]`:
486
+ * ```html
487
+ * <td [tanStackTableCell]="cell">
488
+ * <app-cell-actions />
489
+ * </td>
490
+ * ```
491
+ *
492
+ * ```ts
493
+ * @Component({
494
+ * selector: 'app-cell-actions',
495
+ * template: `{{ cell().id }}`,
496
+ * })
497
+ * export class CellActionsComponent {
498
+ * readonly cell = injectTableCellContext()
499
+ * }
500
+ * ```
501
+ *
502
+ * @example
503
+ * Inject inside a component rendered via `flexRender`:
504
+ * ```ts
505
+ * @Component({
506
+ * selector: 'app-price-cell',
507
+ * template: `{{ cell().getValue() }}`,
508
+ * })
509
+ * export class PriceCellComponent {
510
+ * readonly cell = injectTableCellContext()
511
+ * }
512
+ * ```
513
+ */
514
+ declare class TanStackTableCell<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData> implements TanStackTableCellContext<TFeatures, TData, TValue> {
515
+ /**
516
+ * The current TanStack Table cell.
517
+ *
518
+ * Provided as a required signal input so DI consumers always read the latest value.
519
+ */
520
+ readonly cell: i0.InputSignal<Cell<TFeatures, TData, TValue>>;
521
+ static ɵfac: i0.ɵɵFactoryDeclaration<TanStackTableCell<any, any, any>, never>;
522
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TanStackTableCell<any, any, any>, "[tanStackTableCell]", ["cell"], { "cell": { "alias": "tanStackTableCell"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
523
+ }
524
+ /**
525
+ * Injects the current TanStack Table cell signal.
526
+ *
527
+ * Available when:
528
+ * - there is a nearest `[tanStackTableCell]` directive in the DI tree, or
529
+ * - the caller is rendered via `*flexRender` with render props containing `cell`
530
+ */
531
+ declare function injectTableCellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData>(): TanStackTableCellContext<TFeatures, TData, TValue>['cell'];
532
+
533
+ /**
534
+ * DI context shape for a TanStack Table header.
535
+ *
536
+ * This exists to make the current `Header` injectable by any nested component/directive
537
+ * without passing it through inputs/props.
538
+ */
539
+ interface TanStackTableHeaderContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData> {
540
+ /** Signal that returns the current header instance. */
541
+ header: Signal<Header<TFeatures, TData, TValue>>;
542
+ }
543
+ /**
544
+ * Injection token that provides access to the current header.
545
+ *
546
+ * This token is provided by the {@link TanStackTableHeader} directive.
547
+ */
548
+ declare const TanStackTableHeaderToken: InjectionToken<Signal<any>>;
549
+ /**
550
+ * Provides a TanStack Table `Header` instance in Angular DI.
551
+ *
552
+ * The header can be injected by:
553
+ * - any descendant of an element using `[tanStackTableHeader]="..."`
554
+ * - any component instantiated by `*flexRender` when the render props contains `header`
555
+ *
556
+ * @example
557
+ * ```html
558
+ * <th [tanStackTableHeader]="header">
559
+ * <app-sort-indicator />
560
+ * </th>
561
+ * ```
562
+ *
563
+ * ```ts
564
+ * @Component({
565
+ * selector: 'app-sort-indicator',
566
+ * template: `
567
+ * <button (click)="toggle()">
568
+ * {{ header().column.id }}
569
+ * </button>
570
+ * `,
571
+ * })
572
+ * export class SortIndicatorComponent {
573
+ * readonly header = injectTableHeaderContext()
574
+ *
575
+ * toggle() {
576
+ * this.header().column.toggleSorting()
577
+ * }
578
+ * }
579
+ * ```
580
+ */
581
+ declare class TanStackTableHeader<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData> implements TanStackTableHeaderContext<TFeatures, TData, TValue> {
582
+ /**
583
+ * The current TanStack Table header.
584
+ *
585
+ * Provided as a required signal input so DI consumers always read the latest value.
586
+ */
587
+ readonly header: i0.InputSignal<Header<TFeatures, TData, TValue>>;
588
+ static ɵfac: i0.ɵɵFactoryDeclaration<TanStackTableHeader<any, any, any>, never>;
589
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TanStackTableHeader<any, any, any>, "[tanStackTableHeader]", ["header"], { "header": { "alias": "tanStackTableHeader"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
590
+ }
591
+ /**
592
+ * Injects the current TanStack Table header signal.
593
+ *
594
+ * Available when:
595
+ * - there is a nearest `[tanStackTableHeader]` directive in the DI tree, or
596
+ * - the caller is rendered via `*flexRender` with render props containing `header`
597
+ */
598
+ declare function injectTableHeaderContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData>(): TanStackTableHeaderContext<TFeatures, TData, TValue>['header'];
599
+
600
+ /**
601
+ * Injection token that provides access to the current {@link AngularTable} instance.
602
+ *
603
+ * This token is provided by the {@link TanStackTable} directive.
604
+ */
605
+ declare const TanStackTableToken: InjectionToken<Signal<any>>;
606
+ /**
607
+ * Provides a TanStack Table instance (`AngularTable`) in Angular DI.
608
+ *
609
+ * The table can be injected by:
610
+ * - any descendant of an element using `[tanStackTable]="..."`
611
+ * - any component instantiated by `*flexRender` when the render props contains `table`
612
+ *
613
+ * @example
614
+ * ```html
615
+ * <div [tanStackTable]="table">
616
+ * <app-pagination />
617
+ * </div>
618
+ * ```
619
+ *
620
+ * ```ts
621
+ * @Component({
622
+ * selector: 'app-pagination',
623
+ * template: `
624
+ * <button (click)="prev()" [disabled]="!table().getCanPreviousPage()">Prev</button>
625
+ * <button (click)="next()" [disabled]="!table().getCanNextPage()">Next</button>
626
+ * `,
627
+ * })
628
+ * export class PaginationComponent {
629
+ * readonly table = injectTableContext()
630
+ *
631
+ * prev() {
632
+ * this.table().previousPage()
633
+ * }
634
+ * next() {
635
+ * this.table().nextPage()
636
+ * }
637
+ * }
638
+ * ```
639
+ */
640
+ declare class TanStackTable<TFeatures extends TableFeatures, TData extends RowData, TSelected extends {} = TableState<TFeatures>> {
641
+ /**
642
+ * The current TanStack Table instance.
643
+ *
644
+ * Provided as a required signal input so DI consumers always read the latest value.
645
+ */
646
+ readonly table: i0.InputSignal<AngularTable<TFeatures, TData, TSelected>>;
647
+ static ɵfac: i0.ɵɵFactoryDeclaration<TanStackTable<any, any, any>, never>;
648
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TanStackTable<any, any, any>, "[tanStackTable]", ["table"], { "table": { "alias": "tanStackTable"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
649
+ }
650
+ /**
651
+ * Injects the current TanStack Table instance signal.
652
+ *
653
+ * Available when:
654
+ * - there is a nearest `[tanStackTable]` directive in the DI tree, or
655
+ * - the caller is rendered via `*flexRender` with render props containing `table`
656
+ */
657
+ declare function injectTableContext<TFeatures extends TableFeatures, TData extends RowData, TSelected extends {} = TableState<TFeatures>>(): Signal<AngularTable<TFeatures, TData, TSelected>>;
658
+
659
+ type RenderableComponent = Type<any> | (<T extends NonNullable<unknown>>(props: T) => FlexRenderContent<T>);
660
+ /**
661
+ * Enhanced CellContext with pre-bound cell components.
662
+ * The `cell` property includes the registered cellComponents.
663
+ */
664
+ type AppCellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData, TCellComponents extends Record<string, RenderableComponent>> = {
665
+ cell: Cell<TFeatures, TData, TValue> & TCellComponents & {
666
+ FlexRender: () => unknown;
667
+ };
668
+ column: Column<TFeatures, TData, TValue>;
669
+ getValue: CellContext<TFeatures, TData, TValue>['getValue'];
670
+ renderValue: CellContext<TFeatures, TData, TValue>['renderValue'];
671
+ row: Row<TFeatures, TData>;
672
+ table: Table<TFeatures, TData>;
673
+ };
674
+ /**
675
+ * Enhanced HeaderContext with pre-bound header components.
676
+ * The `header` property includes the registered headerComponents.
677
+ */
678
+ type AppHeaderContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData, THeaderComponents extends Record<string, RenderableComponent>> = {
679
+ column: Column<TFeatures, TData, TValue>;
680
+ header: Header<TFeatures, TData, TValue> & THeaderComponents & {
681
+ FlexRender: () => unknown;
682
+ };
683
+ table: Table<TFeatures, TData>;
684
+ };
685
+ /**
686
+ * Template type for column definitions that can be a string or a function.
687
+ */
688
+ type AppColumnDefTemplate<TProps extends object> = string | ((props: TProps) => any);
689
+ /**
690
+ * Enhanced column definition base with pre-bound components in cell/header/footer contexts.
691
+ */
692
+ type AppColumnDefBase<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = Omit<IdentifiedColumnDef<TFeatures, TData, TValue>, 'cell' | 'header' | 'footer'> & {
693
+ cell?: AppColumnDefTemplate<AppCellContext<TFeatures, TData, TValue, TCellComponents>>;
694
+ header?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>>;
695
+ footer?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>>;
696
+ };
697
+ /**
698
+ * Enhanced display column definition with pre-bound components.
699
+ */
700
+ type AppDisplayColumnDef<TFeatures extends TableFeatures, TData extends RowData, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = Omit<DisplayColumnDef<TFeatures, TData, unknown>, 'cell' | 'header' | 'footer'> & {
701
+ cell?: AppColumnDefTemplate<AppCellContext<TFeatures, TData, unknown, TCellComponents>>;
702
+ header?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
703
+ footer?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
704
+ };
705
+ /**
706
+ * Enhanced group column definition with pre-bound components.
707
+ */
708
+ type AppGroupColumnDef<TFeatures extends TableFeatures, TData extends RowData, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = Omit<GroupColumnDef<TFeatures, TData, unknown>, 'cell' | 'header' | 'footer' | 'columns'> & {
709
+ cell?: AppColumnDefTemplate<AppCellContext<TFeatures, TData, unknown, TCellComponents>>;
710
+ header?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
711
+ footer?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
712
+ columns?: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>;
713
+ };
714
+ /**
715
+ * Enhanced column helper with pre-bound components in cell/header/footer contexts.
716
+ * This enables TypeScript to know about the registered components when defining columns.
717
+ */
718
+ type AppColumnHelper<TFeatures extends TableFeatures, TData extends RowData, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = {
719
+ /**
720
+ * Creates a data column definition with an accessor key or function.
721
+ * The cell, header, and footer contexts include pre-bound components.
722
+ */
723
+ accessor: <TAccessor extends AccessorFn<TData> | DeepKeys<TData>, TValue extends TAccessor extends AccessorFn<TData, infer TReturn> ? TReturn : TAccessor extends DeepKeys<TData> ? DeepValue<TData, TAccessor> : never>(accessor: TAccessor, column: TAccessor extends AccessorFn<TData> ? AppColumnDefBase<TFeatures, TData, TValue, TCellComponents, THeaderComponents> & {
724
+ id: string;
725
+ } : AppColumnDefBase<TFeatures, TData, TValue, TCellComponents, THeaderComponents>) => TAccessor extends AccessorFn<TData> ? AccessorFnColumnDef<TFeatures, TData, TValue> : AccessorKeyColumnDef<TFeatures, TData, TValue>;
726
+ /**
727
+ * Wraps an array of column definitions to preserve each column's individual TValue type.
728
+ */
729
+ columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(columns: [...TColumns]) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns];
730
+ /**
731
+ * Creates a display column definition for non-data columns.
732
+ * The cell, header, and footer contexts include pre-bound components.
733
+ */
734
+ display: (column: AppDisplayColumnDef<TFeatures, TData, TCellComponents, THeaderComponents>) => DisplayColumnDef<TFeatures, TData, unknown>;
735
+ /**
736
+ * Creates a group column definition with nested child columns.
737
+ * The cell, header, and footer contexts include pre-bound components.
738
+ */
739
+ group: (column: AppGroupColumnDef<TFeatures, TData, TCellComponents, THeaderComponents>) => GroupColumnDef<TFeatures, TData, unknown>;
740
+ };
741
+ /**
742
+ * Extended table API returned by useAppTable with all App wrapper components
743
+ */
744
+ type AppAngularTable<TFeatures extends TableFeatures, TData extends RowData, TSelected, TTableComponents extends Record<string, RenderableComponent>, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = AngularTable<TFeatures, TData, TSelected> & NoInfer<TTableComponents> & {
745
+ appCell: <TValue>(cell: Cell<TFeatures, TData, TValue>) => Cell<TFeatures, TData, TValue> & NoInfer<TCellComponents>;
746
+ appHeader: <TValue>(header: Header<TFeatures, TData, TValue>) => Header<TFeatures, TData, TValue> & NoInfer<THeaderComponents>;
747
+ appFooter: <TValue>(footer: Header<TFeatures, TData, TValue>) => Header<TFeatures, TData, TValue> & NoInfer<THeaderComponents>;
748
+ };
749
+ /**
750
+ * Options for creating a table hook with pre-bound components and default table options.
751
+ * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.
752
+ */
753
+ type CreateTableContextOptions<TFeatures extends TableFeatures, TTableComponents extends Record<string, RenderableComponent>, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = Omit<TableOptions<TFeatures, any>, 'columns' | 'data' | 'store' | 'state' | 'initialState'> & {
754
+ /**
755
+ * Table-level components that need access to the table instance.
756
+ * These are available directly on the table object returned by useAppTable.
757
+ * Use `useTableContext()` inside these components.
758
+ * @example { PaginationControls, GlobalFilter, RowCount }
759
+ */
760
+ tableComponents?: TTableComponents;
761
+ /**
762
+ * Cell-level components that need access to the cell instance.
763
+ * These are available on the cell object passed to AppCell's children.
764
+ * Use `useCellContext()` inside these components.
765
+ * @example { TextCell, NumberCell, DateCell, CurrencyCell }
766
+ */
767
+ cellComponents?: TCellComponents;
768
+ /**
769
+ * Header-level components that need access to the header instance.
770
+ * These are available on the header object passed to AppHeader/AppFooter's children.
771
+ * Use `useHeaderContext()` inside these components.
772
+ * @example { SortIndicator, ColumnFilter, ResizeHandle }
773
+ */
774
+ headerComponents?: THeaderComponents;
775
+ };
776
+ type CreateTableHookResult<TFeatures extends TableFeatures, TTableComponents extends Record<string, RenderableComponent>, TCellComponents extends Record<string, RenderableComponent>, THeaderComponents extends Record<string, RenderableComponent>> = {
777
+ createAppColumnHelper: <TData extends RowData>() => AppColumnHelper<TFeatures, TData, TCellComponents, THeaderComponents>;
778
+ injectTableContext: <TData extends RowData = RowData>() => Signal<AngularTable<TFeatures, TData>>;
779
+ injectTableHeaderContext: <TValue extends CellData = CellData, TRowData extends RowData = RowData>() => Signal<Header<TFeatures, TRowData, TValue>>;
780
+ injectTableCellContext: <TValue extends CellData = CellData, TRowData extends RowData = RowData>() => Signal<Cell<TFeatures, TRowData, TValue>>;
781
+ injectFlexRenderHeaderContext: <TData extends RowData, TValue extends CellData>() => HeaderContext<TFeatures, TData, TValue>;
782
+ injectFlexRenderCellContext: <TData extends RowData, TValue extends CellData>() => CellContext<TFeatures, TData, TValue>;
783
+ injectAppTable: <TData extends RowData, TSelected = TableState<TFeatures>>(tableOptions: () => Omit<TableOptions<TFeatures, TData>, '_features' | '_rowModels'>, selector?: (state: TableState<TFeatures>) => TSelected) => AppAngularTable<TFeatures, TData, TSelected, TTableComponents, TCellComponents, THeaderComponents>;
784
+ };
785
+ declare function createTableHook<TFeatures extends TableFeatures, const TTableComponents extends Record<string, RenderableComponent>, const TCellComponents extends Record<string, RenderableComponent>, const THeaderComponents extends Record<string, RenderableComponent>>({ tableComponents, cellComponents, headerComponents, ...defaultTableOptions }: CreateTableContextOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>): CreateTableHookResult<TFeatures, TTableComponents, TCellComponents, THeaderComponents>;
786
+
787
+ /**
788
+ * Constant helper to import FlexRender directives.
789
+ *
790
+ * You should prefer to use this constant over importing the directives separately,
791
+ * as it ensures you always have the correct set of directives over library updates.
792
+ *
793
+ * @see {@link FlexRenderDirective} and {@link FlexRenderCell} for more details on the directives included in this export.
794
+ */
795
+ declare const FlexRender: readonly [typeof FlexRenderDirective, typeof FlexRenderCell];
796
+
797
+ export { FlexRender, FlexRenderCell, FlexRenderComponentInstance, FlexRenderComponentProps, FlexRenderDirective, TanStackTable, TanStackTableCell, TanStackTableCellToken, TanStackTableHeader, TanStackTableHeaderToken, TanStackTableToken, createTableHook, flexRenderComponent, injectFlexRenderContext, injectTable, injectTableCellContext, injectTableContext, injectTableHeaderContext };
798
+ export type { AngularTable, AngularTableComputed, AppAngularTable, AppCellContext, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppGroupColumnDef, AppHeaderContext, CreateTableContextOptions, CreateTableHookResult, FlexRenderComponent, FlexRenderContent, FlexRenderInputContent, RenderableComponent, TanStackTableCellContext, TanStackTableHeaderContext };