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