@tanstack/angular-table 9.0.0-alpha.1 → 9.0.0-alpha.11

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