@tanstack/angular-table 9.0.0-alpha.21 → 9.0.0-alpha.24
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.
|
@@ -1,88 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, input, inject, Directive, reflectComponentType,
|
|
2
|
+
import { InjectionToken, input, inject, Directive, reflectComponentType, Injectable, KeyValueDiffers, ChangeDetectorRef, OutputEmitterRef, TemplateRef, Type, runInInjectionContext, computed, effect, untracked, Injector, ViewContainerRef, DestroyRef, assertInInjectionContext, signal } from '@angular/core';
|
|
3
3
|
import { constructReactivityFeature, constructTable, createColumnHelper } from '@tanstack/table-core';
|
|
4
4
|
export * from '@tanstack/table-core';
|
|
5
5
|
import { injectStore } from '@tanstack/angular-store';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Injection token that provides access to the current {@link AngularTable} instance.
|
|
9
|
-
*
|
|
10
|
-
* This token is provided by the {@link TanStackTable} directive.
|
|
11
|
-
*/
|
|
12
|
-
const TanStackTableToken = new InjectionToken('[TanStack Table] Table Context');
|
|
13
|
-
/**
|
|
14
|
-
* Provides a TanStack Table instance (`AngularTable`) in Angular DI.
|
|
15
|
-
*
|
|
16
|
-
* The table can be injected by:
|
|
17
|
-
* - any descendant of an element using `[tanStackTable]="..."`
|
|
18
|
-
* - any component instantiated by `*flexRender` when the render props contains `table`
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```html
|
|
22
|
-
* <div [tanStackTable]="table">
|
|
23
|
-
* <app-pagination />
|
|
24
|
-
* </div>
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* ```ts
|
|
28
|
-
* @Component({
|
|
29
|
-
* selector: 'app-pagination',
|
|
30
|
-
* template: `
|
|
31
|
-
* <button (click)="prev()" [disabled]="!table().getCanPreviousPage()">Prev</button>
|
|
32
|
-
* <button (click)="next()" [disabled]="!table().getCanNextPage()">Next</button>
|
|
33
|
-
* `,
|
|
34
|
-
* })
|
|
35
|
-
* export class PaginationComponent {
|
|
36
|
-
* readonly table = injectTableContext()
|
|
37
|
-
*
|
|
38
|
-
* prev() {
|
|
39
|
-
* this.table().previousPage()
|
|
40
|
-
* }
|
|
41
|
-
* next() {
|
|
42
|
-
* this.table().nextPage()
|
|
43
|
-
* }
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
class TanStackTable {
|
|
48
|
-
/**
|
|
49
|
-
* The current TanStack Table instance.
|
|
50
|
-
*
|
|
51
|
-
* Provided as a required signal input so DI consumers always read the latest value.
|
|
52
|
-
*/
|
|
53
|
-
table = input.required({ ...(ngDevMode ? { debugName: "table" } : {}), alias: 'tanStackTable' });
|
|
54
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TanStackTable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
55
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: TanStackTable, isStandalone: true, selector: "[tanStackTable]", inputs: { table: { classPropertyName: "table", publicName: "tanStackTable", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
|
|
56
|
-
{
|
|
57
|
-
provide: TanStackTableToken,
|
|
58
|
-
useFactory: () => inject(TanStackTable).table,
|
|
59
|
-
},
|
|
60
|
-
], exportAs: ["table"], ngImport: i0 });
|
|
61
|
-
}
|
|
62
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TanStackTable, decorators: [{
|
|
63
|
-
type: Directive,
|
|
64
|
-
args: [{
|
|
65
|
-
selector: '[tanStackTable]',
|
|
66
|
-
exportAs: 'table',
|
|
67
|
-
providers: [
|
|
68
|
-
{
|
|
69
|
-
provide: TanStackTableToken,
|
|
70
|
-
useFactory: () => inject(TanStackTable).table,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
}]
|
|
74
|
-
}], propDecorators: { table: [{ type: i0.Input, args: [{ isSignal: true, alias: "tanStackTable", required: true }] }] } });
|
|
75
|
-
/**
|
|
76
|
-
* Injects the current TanStack Table instance signal.
|
|
77
|
-
*
|
|
78
|
-
* Available when:
|
|
79
|
-
* - there is a nearest `[tanStackTable]` directive in the DI tree, or
|
|
80
|
-
* - the caller is rendered via `*flexRender` with render props containing `table`
|
|
81
|
-
*/
|
|
82
|
-
function injectTableContext() {
|
|
83
|
-
return inject(TanStackTableToken);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
7
|
/**
|
|
87
8
|
* Injection token that provides access to the current cell.
|
|
88
9
|
*
|
|
@@ -132,16 +53,16 @@ class TanStackTableCell {
|
|
|
132
53
|
*
|
|
133
54
|
* Provided as a required signal input so DI consumers always read the latest value.
|
|
134
55
|
*/
|
|
135
|
-
cell = input.required({ ...(ngDevMode ? { debugName: "cell" } : {}), alias: 'tanStackTableCell' });
|
|
136
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
137
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
56
|
+
cell = input.required({ ...(ngDevMode ? { debugName: "cell" } : /* istanbul ignore next */ {}), alias: 'tanStackTableCell' });
|
|
57
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTableCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
58
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.7", type: TanStackTableCell, isStandalone: true, selector: "[tanStackTableCell]", inputs: { cell: { classPropertyName: "cell", publicName: "tanStackTableCell", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
|
|
138
59
|
{
|
|
139
60
|
provide: TanStackTableCellToken,
|
|
140
61
|
useFactory: () => inject(TanStackTableCell).cell,
|
|
141
62
|
},
|
|
142
63
|
], exportAs: ["cell"], ngImport: i0 });
|
|
143
64
|
}
|
|
144
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTableCell, decorators: [{
|
|
145
66
|
type: Directive,
|
|
146
67
|
args: [{
|
|
147
68
|
selector: '[tanStackTableCell]',
|
|
@@ -209,16 +130,16 @@ class TanStackTableHeader {
|
|
|
209
130
|
*
|
|
210
131
|
* Provided as a required signal input so DI consumers always read the latest value.
|
|
211
132
|
*/
|
|
212
|
-
header = input.required({ ...(ngDevMode ? { debugName: "header" } : {}), alias: 'tanStackTableHeader' });
|
|
213
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
214
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
133
|
+
header = input.required({ ...(ngDevMode ? { debugName: "header" } : /* istanbul ignore next */ {}), alias: 'tanStackTableHeader' });
|
|
134
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTableHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
135
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.7", type: TanStackTableHeader, isStandalone: true, selector: "[tanStackTableHeader]", inputs: { header: { classPropertyName: "header", publicName: "tanStackTableHeader", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
|
|
215
136
|
{
|
|
216
137
|
provide: TanStackTableHeaderToken,
|
|
217
138
|
useFactory: () => inject(TanStackTableHeader).header,
|
|
218
139
|
},
|
|
219
140
|
], exportAs: ["header"], ngImport: i0 });
|
|
220
141
|
}
|
|
221
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTableHeader, decorators: [{
|
|
222
143
|
type: Directive,
|
|
223
144
|
args: [{
|
|
224
145
|
selector: '[tanStackTableHeader]',
|
|
@@ -242,6 +163,85 @@ function injectTableHeaderContext() {
|
|
|
242
163
|
return inject(TanStackTableHeaderToken);
|
|
243
164
|
}
|
|
244
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Injection token that provides access to the current {@link AngularTable} instance.
|
|
168
|
+
*
|
|
169
|
+
* This token is provided by the {@link TanStackTable} directive.
|
|
170
|
+
*/
|
|
171
|
+
const TanStackTableToken = new InjectionToken('[TanStack Table] Table Context');
|
|
172
|
+
/**
|
|
173
|
+
* Provides a TanStack Table instance (`AngularTable`) in Angular DI.
|
|
174
|
+
*
|
|
175
|
+
* The table can be injected by:
|
|
176
|
+
* - any descendant of an element using `[tanStackTable]="..."`
|
|
177
|
+
* - any component instantiated by `*flexRender` when the render props contains `table`
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```html
|
|
181
|
+
* <div [tanStackTable]="table">
|
|
182
|
+
* <app-pagination />
|
|
183
|
+
* </div>
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* @Component({
|
|
188
|
+
* selector: 'app-pagination',
|
|
189
|
+
* template: `
|
|
190
|
+
* <button (click)="prev()" [disabled]="!table().getCanPreviousPage()">Prev</button>
|
|
191
|
+
* <button (click)="next()" [disabled]="!table().getCanNextPage()">Next</button>
|
|
192
|
+
* `,
|
|
193
|
+
* })
|
|
194
|
+
* export class PaginationComponent {
|
|
195
|
+
* readonly table = injectTableContext()
|
|
196
|
+
*
|
|
197
|
+
* prev() {
|
|
198
|
+
* this.table().previousPage()
|
|
199
|
+
* }
|
|
200
|
+
* next() {
|
|
201
|
+
* this.table().nextPage()
|
|
202
|
+
* }
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
class TanStackTable {
|
|
207
|
+
/**
|
|
208
|
+
* The current TanStack Table instance.
|
|
209
|
+
*
|
|
210
|
+
* Provided as a required signal input so DI consumers always read the latest value.
|
|
211
|
+
*/
|
|
212
|
+
table = input.required({ ...(ngDevMode ? { debugName: "table" } : /* istanbul ignore next */ {}), alias: 'tanStackTable' });
|
|
213
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
214
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.7", type: TanStackTable, isStandalone: true, selector: "[tanStackTable]", inputs: { table: { classPropertyName: "table", publicName: "tanStackTable", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
|
|
215
|
+
{
|
|
216
|
+
provide: TanStackTableToken,
|
|
217
|
+
useFactory: () => inject(TanStackTable).table,
|
|
218
|
+
},
|
|
219
|
+
], exportAs: ["table"], ngImport: i0 });
|
|
220
|
+
}
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: TanStackTable, decorators: [{
|
|
222
|
+
type: Directive,
|
|
223
|
+
args: [{
|
|
224
|
+
selector: '[tanStackTable]',
|
|
225
|
+
exportAs: 'table',
|
|
226
|
+
providers: [
|
|
227
|
+
{
|
|
228
|
+
provide: TanStackTableToken,
|
|
229
|
+
useFactory: () => inject(TanStackTable).table,
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
}]
|
|
233
|
+
}], propDecorators: { table: [{ type: i0.Input, args: [{ isSignal: true, alias: "tanStackTable", required: true }] }] } });
|
|
234
|
+
/**
|
|
235
|
+
* Injects the current TanStack Table instance signal.
|
|
236
|
+
*
|
|
237
|
+
* Available when:
|
|
238
|
+
* - there is a nearest `[tanStackTable]` directive in the DI tree, or
|
|
239
|
+
* - the caller is rendered via `*flexRender` with render props containing `table`
|
|
240
|
+
*/
|
|
241
|
+
function injectTableContext() {
|
|
242
|
+
return inject(TanStackTableToken);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
245
|
const FlexRenderComponentProps = new InjectionToken('[@tanstack/angular-table] Flex render component context props');
|
|
246
246
|
/**
|
|
247
247
|
* Inject the flex render context props.
|
|
@@ -354,112 +354,6 @@ class FlexRenderComponentInstance {
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
function mapToFlexRenderTypedContent(content) {
|
|
358
|
-
if (content === null || content === undefined) {
|
|
359
|
-
return { kind: 'null' };
|
|
360
|
-
}
|
|
361
|
-
if (typeof content === 'string' || typeof content === 'number') {
|
|
362
|
-
return { kind: 'primitive', content };
|
|
363
|
-
}
|
|
364
|
-
if (content instanceof FlexRenderComponentInstance) {
|
|
365
|
-
return { kind: 'flexRenderComponent', content };
|
|
366
|
-
}
|
|
367
|
-
else if (content instanceof TemplateRef) {
|
|
368
|
-
return { kind: 'templateRef', content };
|
|
369
|
-
}
|
|
370
|
-
else if (content instanceof Type) {
|
|
371
|
-
return { kind: 'component', content };
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
return { kind: 'primitive', content };
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
class FlexRenderView {
|
|
378
|
-
view;
|
|
379
|
-
#previousContent;
|
|
380
|
-
#content;
|
|
381
|
-
constructor(initialContent, view) {
|
|
382
|
-
this.#content = initialContent;
|
|
383
|
-
this.view = view;
|
|
384
|
-
}
|
|
385
|
-
get previousContent() {
|
|
386
|
-
return this.#previousContent ?? { kind: 'null' };
|
|
387
|
-
}
|
|
388
|
-
get content() {
|
|
389
|
-
return this.#content;
|
|
390
|
-
}
|
|
391
|
-
set content(content) {
|
|
392
|
-
this.#previousContent = this.#content;
|
|
393
|
-
this.#content = content;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
class FlexRenderTemplateView extends FlexRenderView {
|
|
397
|
-
constructor(initialContent, view) {
|
|
398
|
-
super(initialContent, view);
|
|
399
|
-
}
|
|
400
|
-
updateProps(props) {
|
|
401
|
-
this.view.markForCheck();
|
|
402
|
-
}
|
|
403
|
-
dirtyCheck() {
|
|
404
|
-
// Basically a no-op. When the view is created via EmbeddedViewRef, we don't need to do any manual update
|
|
405
|
-
// since this type of content has a proxy as a context, then every time the root component is checked for changes,
|
|
406
|
-
// the property getter will be re-evaluated.
|
|
407
|
-
//
|
|
408
|
-
// If in a future we need to manually mark the view as dirty, just uncomment next line
|
|
409
|
-
// this.view.markForCheck()
|
|
410
|
-
}
|
|
411
|
-
unmount() {
|
|
412
|
-
this.view.destroy();
|
|
413
|
-
}
|
|
414
|
-
onDestroy(callback) {
|
|
415
|
-
this.view.onDestroy(callback);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
class FlexRenderComponentView extends FlexRenderView {
|
|
419
|
-
constructor(initialContent, view) {
|
|
420
|
-
super(initialContent, view);
|
|
421
|
-
}
|
|
422
|
-
updateProps(props) {
|
|
423
|
-
switch (this.content.kind) {
|
|
424
|
-
case 'component': {
|
|
425
|
-
this.view.setInputs(props);
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
case 'flexRenderComponent': {
|
|
429
|
-
// No-op. When FlexRenderFlags.PropsReferenceChanged is set,
|
|
430
|
-
// FlexRenderComponent will be updated into `dirtyCheck`.
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
dirtyCheck() {
|
|
436
|
-
switch (this.content.kind) {
|
|
437
|
-
case 'component': {
|
|
438
|
-
// Component context is currently valuated with the cell context. Since it's reference
|
|
439
|
-
// shouldn't change, we force mark the component as dirty in order to re-evaluate function invocation in view.
|
|
440
|
-
// NOTE: this should behave like having a component with ChangeDetectionStrategy.Default
|
|
441
|
-
this.view.markAsDirty();
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
case 'flexRenderComponent': {
|
|
445
|
-
// Given context instance will always have a different reference than the previous one,
|
|
446
|
-
// so instead of recreating the entire view, we will only update the current view
|
|
447
|
-
if (this.view.eqType(this.content.content)) {
|
|
448
|
-
this.view.update(this.content.content);
|
|
449
|
-
}
|
|
450
|
-
this.view.markAsDirty();
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
unmount() {
|
|
456
|
-
this.view.componentRef.destroy();
|
|
457
|
-
}
|
|
458
|
-
onDestroy(callback) {
|
|
459
|
-
this.view.componentRef.onDestroy(callback);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
357
|
class FlexRenderComponentFactory {
|
|
464
358
|
#viewContainerRef;
|
|
465
359
|
constructor(viewContainerRef) {
|
|
@@ -479,10 +373,10 @@ class FlexRenderComponentFactory {
|
|
|
479
373
|
view.setOutputs(outputs);
|
|
480
374
|
return view;
|
|
481
375
|
}
|
|
482
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
483
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.
|
|
376
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderComponentFactory, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
377
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderComponentFactory });
|
|
484
378
|
}
|
|
485
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderComponentFactory, decorators: [{
|
|
486
380
|
type: Injectable
|
|
487
381
|
}], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
|
488
382
|
class FlexRenderComponentRef {
|
|
@@ -636,6 +530,128 @@ class FlexRenderComponentOutputManager {
|
|
|
636
530
|
}
|
|
637
531
|
}
|
|
638
532
|
|
|
533
|
+
function mapToFlexRenderTypedContent(content) {
|
|
534
|
+
if (content === null || content === undefined) {
|
|
535
|
+
return { kind: 'null' };
|
|
536
|
+
}
|
|
537
|
+
if (typeof content === 'string' || typeof content === 'number') {
|
|
538
|
+
return { kind: 'primitive', content };
|
|
539
|
+
}
|
|
540
|
+
if (content instanceof FlexRenderComponentInstance) {
|
|
541
|
+
return { kind: 'flexRenderComponent', content };
|
|
542
|
+
}
|
|
543
|
+
else if (content instanceof TemplateRef) {
|
|
544
|
+
return { kind: 'templateRef', content };
|
|
545
|
+
}
|
|
546
|
+
else if (content instanceof Type) {
|
|
547
|
+
return { kind: 'component', content };
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
return { kind: 'primitive', content };
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
class FlexRenderView {
|
|
554
|
+
view;
|
|
555
|
+
#previousContent;
|
|
556
|
+
#content;
|
|
557
|
+
constructor(initialContent, view) {
|
|
558
|
+
this.#content = initialContent;
|
|
559
|
+
this.view = view;
|
|
560
|
+
}
|
|
561
|
+
get previousContent() {
|
|
562
|
+
return this.#previousContent ?? { kind: 'null' };
|
|
563
|
+
}
|
|
564
|
+
get content() {
|
|
565
|
+
return this.#content;
|
|
566
|
+
}
|
|
567
|
+
set content(content) {
|
|
568
|
+
this.#previousContent = this.#content;
|
|
569
|
+
this.#content = content;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
class FlexRenderTemplateView extends FlexRenderView {
|
|
573
|
+
constructor(initialContent, view) {
|
|
574
|
+
super(initialContent, view);
|
|
575
|
+
}
|
|
576
|
+
updateProps(props) {
|
|
577
|
+
this.view.markForCheck();
|
|
578
|
+
}
|
|
579
|
+
dirtyCheck() {
|
|
580
|
+
// Basically a no-op. When the view is created via EmbeddedViewRef, we don't need to do any manual update
|
|
581
|
+
// since this type of content has a proxy as a context, then every time the root component is checked for changes,
|
|
582
|
+
// the property getter will be re-evaluated.
|
|
583
|
+
//
|
|
584
|
+
// If in a future we need to manually mark the view as dirty, just uncomment next line
|
|
585
|
+
// this.view.markForCheck()
|
|
586
|
+
}
|
|
587
|
+
unmount() {
|
|
588
|
+
this.view.destroy();
|
|
589
|
+
}
|
|
590
|
+
onDestroy(callback) {
|
|
591
|
+
this.view.onDestroy(callback);
|
|
592
|
+
}
|
|
593
|
+
eq(compare) {
|
|
594
|
+
return ((this.content.kind === 'primitive' &&
|
|
595
|
+
compare.kind === 'primitive' &&
|
|
596
|
+
this.content.content === compare.content) ||
|
|
597
|
+
(this.content.kind === 'templateRef' &&
|
|
598
|
+
compare.kind === 'templateRef' &&
|
|
599
|
+
this.content.content === compare.content));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
class FlexRenderComponentView extends FlexRenderView {
|
|
603
|
+
constructor(initialContent, view) {
|
|
604
|
+
super(initialContent, view);
|
|
605
|
+
}
|
|
606
|
+
updateProps(props) {
|
|
607
|
+
switch (this.content.kind) {
|
|
608
|
+
case 'component': {
|
|
609
|
+
this.view.setInputs(props);
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
case 'flexRenderComponent': {
|
|
613
|
+
// No-op. When FlexRenderFlags.PropsReferenceChanged is set,
|
|
614
|
+
// FlexRenderComponent will be updated into `dirtyCheck`.
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
dirtyCheck() {
|
|
620
|
+
switch (this.content.kind) {
|
|
621
|
+
case 'component': {
|
|
622
|
+
// Component context is currently valuated with the cell context. Since it's reference
|
|
623
|
+
// shouldn't change, we force mark the component as dirty in order to re-evaluate function invocation in view.
|
|
624
|
+
// NOTE: this should behave like having a component with ChangeDetectionStrategy.Default
|
|
625
|
+
this.view.markAsDirty();
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
case 'flexRenderComponent': {
|
|
629
|
+
// Given context instance will always have a different reference than the previous one,
|
|
630
|
+
// so instead of recreating the entire view, we will only update the current view
|
|
631
|
+
if (this.view.eqType(this.content.content)) {
|
|
632
|
+
this.view.update(this.content.content);
|
|
633
|
+
}
|
|
634
|
+
this.view.markAsDirty();
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
unmount() {
|
|
640
|
+
this.view.componentRef.destroy();
|
|
641
|
+
}
|
|
642
|
+
onDestroy(callback) {
|
|
643
|
+
this.view.componentRef.onDestroy(callback);
|
|
644
|
+
}
|
|
645
|
+
eq(compare) {
|
|
646
|
+
return ((this.content.kind === 'component' &&
|
|
647
|
+
compare.kind === 'component' &&
|
|
648
|
+
this.content.content === compare.content) ||
|
|
649
|
+
(this.content.kind === 'flexRenderComponent' &&
|
|
650
|
+
compare.kind === 'flexRenderComponent' &&
|
|
651
|
+
this.content.content.component === compare.content.component));
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
639
655
|
/**
|
|
640
656
|
* Internal view renderer used by Angular TanStack Table to implement `flexRender` directives.
|
|
641
657
|
*
|
|
@@ -658,11 +674,11 @@ class FlexViewRenderer {
|
|
|
658
674
|
? content
|
|
659
675
|
: runInInjectionContext(this.#injector(), () => content(props));
|
|
660
676
|
};
|
|
661
|
-
#latestContent = computed(() => this.#getLatestContentValue(), ...(ngDevMode ? [{ debugName: "#latestContent" }] : []));
|
|
677
|
+
#latestContent = computed(() => this.#getLatestContentValue(), ...(ngDevMode ? [{ debugName: "#latestContent" }] : /* istanbul ignore next */ []));
|
|
662
678
|
#getContentValue = computed(() => {
|
|
663
679
|
const latestContent = this.#latestContent();
|
|
664
680
|
return mapToFlexRenderTypedContent(latestContent);
|
|
665
|
-
}, ...(ngDevMode ? [{ debugName: "#getContentValue" }] : []));
|
|
681
|
+
}, ...(ngDevMode ? [{ debugName: "#getContentValue" }] : /* istanbul ignore next */ []));
|
|
666
682
|
constructor(options) {
|
|
667
683
|
this.#content = options.content;
|
|
668
684
|
this.#props = options.props;
|
|
@@ -752,7 +768,7 @@ class FlexViewRenderer {
|
|
|
752
768
|
}
|
|
753
769
|
this.#renderFlags |= FlexRenderFlags.Dirty;
|
|
754
770
|
this.#doCheck();
|
|
755
|
-
}, { ...(ngDevMode ? { debugName: "#currentRenderEffectRef" } : {}), injector: this.#viewContainerRef.injector });
|
|
771
|
+
}, { ...(ngDevMode ? { debugName: "#currentRenderEffectRef" } : /* istanbul ignore next */ {}), injector: this.#viewContainerRef.injector });
|
|
756
772
|
}
|
|
757
773
|
}
|
|
758
774
|
#shouldRecreateEntireView() {
|
|
@@ -766,11 +782,12 @@ class FlexViewRenderer {
|
|
|
766
782
|
this.#renderFlags |= FlexRenderFlags.ContentChanged;
|
|
767
783
|
}
|
|
768
784
|
else {
|
|
769
|
-
this.#renderView.content
|
|
770
|
-
|
|
771
|
-
|
|
785
|
+
const { kind: currentKind } = this.#renderView.content;
|
|
786
|
+
if (latestContent.kind !== currentKind ||
|
|
787
|
+
!this.#renderView.eq(latestContent)) {
|
|
772
788
|
this.#renderFlags |= FlexRenderFlags.ContentChanged;
|
|
773
789
|
}
|
|
790
|
+
this.#renderView.content = latestContent;
|
|
774
791
|
}
|
|
775
792
|
this.#update();
|
|
776
793
|
}
|
|
@@ -899,9 +916,9 @@ class FlexViewRenderer {
|
|
|
899
916
|
* ```
|
|
900
917
|
*/
|
|
901
918
|
class FlexRenderCell {
|
|
902
|
-
cell = input(undefined, { ...(ngDevMode ? { debugName: "cell" } : {}), alias: 'flexRenderCell' });
|
|
903
|
-
header = input(undefined, { ...(ngDevMode ? { debugName: "header" } : {}), alias: 'flexRenderHeader' });
|
|
904
|
-
footer = input(undefined, { ...(ngDevMode ? { debugName: "footer" } : {}), alias: 'flexRenderFooter' });
|
|
919
|
+
cell = input(undefined, { ...(ngDevMode ? { debugName: "cell" } : /* istanbul ignore next */ {}), alias: 'flexRenderCell' });
|
|
920
|
+
header = input(undefined, { ...(ngDevMode ? { debugName: "header" } : /* istanbul ignore next */ {}), alias: 'flexRenderHeader' });
|
|
921
|
+
footer = input(undefined, { ...(ngDevMode ? { debugName: "footer" } : /* istanbul ignore next */ {}), alias: 'flexRenderFooter' });
|
|
905
922
|
#renderData = computed(() => {
|
|
906
923
|
const cell = this.cell();
|
|
907
924
|
const header = this.header();
|
|
@@ -916,15 +933,15 @@ class FlexRenderCell {
|
|
|
916
933
|
return [footer.column.columnDef.footer, footer.getContext()];
|
|
917
934
|
}
|
|
918
935
|
return [null, null];
|
|
919
|
-
}, { ...(ngDevMode ? { debugName: "#renderData" } : {}), equal: (a, b) => {
|
|
936
|
+
}, { ...(ngDevMode ? { debugName: "#renderData" } : /* istanbul ignore next */ {}), equal: (a, b) => {
|
|
920
937
|
return a[0] === b[0] && a[1] === b[1];
|
|
921
938
|
} });
|
|
922
939
|
#injector = inject(Injector);
|
|
923
940
|
#templateRef = inject(TemplateRef);
|
|
924
941
|
#viewContainerRef = inject(ViewContainerRef);
|
|
925
942
|
constructor() {
|
|
926
|
-
const content = computed(() => this.#renderData()[0], ...(ngDevMode ? [{ debugName: "content" }] : []));
|
|
927
|
-
const props = computed(() => this.#renderData()[1], ...(ngDevMode ? [{ debugName: "props" }] : []));
|
|
943
|
+
const content = computed(() => this.#renderData()[0], ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
944
|
+
const props = computed(() => this.#renderData()[1], ...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
928
945
|
const renderer = new FlexViewRenderer({
|
|
929
946
|
content: content,
|
|
930
947
|
props: props,
|
|
@@ -937,10 +954,10 @@ class FlexRenderCell {
|
|
|
937
954
|
renderer.destroy();
|
|
938
955
|
});
|
|
939
956
|
}
|
|
940
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
941
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
957
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
958
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.7", type: FlexRenderCell, isStandalone: true, selector: "ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]", inputs: { cell: { classPropertyName: "cell", publicName: "flexRenderCell", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "flexRenderHeader", isSignal: true, isRequired: false, transformFunction: null }, footer: { classPropertyName: "footer", publicName: "flexRenderFooter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
942
959
|
}
|
|
943
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
960
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderCell, decorators: [{
|
|
944
961
|
type: Directive,
|
|
945
962
|
args: [{
|
|
946
963
|
selector: 'ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]',
|
|
@@ -996,9 +1013,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
996
1013
|
* which the latter is preferred.
|
|
997
1014
|
*/
|
|
998
1015
|
class FlexRenderDirective {
|
|
999
|
-
content = input(undefined, { ...(ngDevMode ? { debugName: "content" } : {}), alias: 'flexRender' });
|
|
1000
|
-
props = input({}, { ...(ngDevMode ? { debugName: "props" } : {}), alias: 'flexRenderProps' });
|
|
1001
|
-
injector = input(inject(Injector), { ...(ngDevMode ? { debugName: "injector" } : {}), alias: 'flexRenderInjector' });
|
|
1016
|
+
content = input(undefined, { ...(ngDevMode ? { debugName: "content" } : /* istanbul ignore next */ {}), alias: 'flexRender' });
|
|
1017
|
+
props = input({}, { ...(ngDevMode ? { debugName: "props" } : /* istanbul ignore next */ {}), alias: 'flexRenderProps' });
|
|
1018
|
+
injector = input(inject(Injector), { ...(ngDevMode ? { debugName: "injector" } : /* istanbul ignore next */ {}), alias: 'flexRenderInjector' });
|
|
1002
1019
|
#viewContainerRef = inject(ViewContainerRef);
|
|
1003
1020
|
#templateRef = inject(TemplateRef);
|
|
1004
1021
|
constructor() {
|
|
@@ -1014,10 +1031,10 @@ class FlexRenderDirective {
|
|
|
1014
1031
|
renderer.destroy();
|
|
1015
1032
|
});
|
|
1016
1033
|
}
|
|
1017
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
1018
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
1034
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1035
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.7", type: FlexRenderDirective, isStandalone: true, selector: "ng-template[flexRender]", inputs: { content: { classPropertyName: "content", publicName: "flexRender", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "flexRenderProps", isSignal: true, isRequired: false, transformFunction: null }, injector: { classPropertyName: "injector", publicName: "flexRenderInjector", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
1019
1036
|
}
|
|
1020
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
1037
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: FlexRenderDirective, decorators: [{
|
|
1021
1038
|
type: Directive,
|
|
1022
1039
|
args: [{
|
|
1023
1040
|
selector: 'ng-template[flexRender]',
|
|
@@ -1125,7 +1142,7 @@ function lazyInit(initializer) {
|
|
|
1125
1142
|
function injectTable(options, selector = (state) => state) {
|
|
1126
1143
|
assertInInjectionContext(injectTable);
|
|
1127
1144
|
const injector = inject(Injector);
|
|
1128
|
-
const stateNotifier = signal(0, ...(ngDevMode ? [{ debugName: "stateNotifier" }] : []));
|
|
1145
|
+
const stateNotifier = signal(0, ...(ngDevMode ? [{ debugName: "stateNotifier" }] : /* istanbul ignore next */ []));
|
|
1129
1146
|
const angularReactivityFeature = constructReactivityFeature({
|
|
1130
1147
|
stateNotifier: () => stateNotifier(),
|
|
1131
1148
|
});
|
|
@@ -1153,7 +1170,7 @@ function injectTable(options, selector = (state) => state) {
|
|
|
1153
1170
|
result.state = tableOptionsValue.state;
|
|
1154
1171
|
}
|
|
1155
1172
|
return result;
|
|
1156
|
-
}, ...(ngDevMode ? [{ debugName: "updatedOptions" }] : []));
|
|
1173
|
+
}, ...(ngDevMode ? [{ debugName: "updatedOptions" }] : /* istanbul ignore next */ []));
|
|
1157
1174
|
effect(() => {
|
|
1158
1175
|
const newOptions = updatedOptions();
|
|
1159
1176
|
untracked(() => table.setOptions(newOptions));
|