fg-dynamic-component 1.1.1 → 2.0.0
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 +9 -8
- package/fesm2022/fg-dynamic-component.mjs +146 -96
- package/fesm2022/fg-dynamic-component.mjs.map +1 -1
- package/package.json +9 -10
- package/{lib/fg-dynamic.component.d.ts → types/fg-dynamic-component.d.ts} +17 -12
- package/esm2022/fg-dynamic-component.mjs +0 -5
- package/esm2022/lib/fg-dynamic.component.mjs +0 -404
- package/esm2022/public-api.mjs +0 -5
- package/index.d.ts +0 -5
- package/public-api.d.ts +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Create an Angular standalone signals based dynamic components tree through a JSO
|
|
|
7
7
|
|
|
8
8
|
| Angular | fg-dynamic-component | NPM package |
|
|
9
9
|
| ------- | -------------------- | ----------------------------- |
|
|
10
|
+
| 22.1.6 | 2.0.0 | `fg-dynamic-component@^2.0.0` |
|
|
10
11
|
| 17.2.4 | 1.1.1 | `fg-dynamic-component@^1.1.1` |
|
|
11
12
|
| 17.2.4 | 1.1.0 | `fg-dynamic-component@^1.1.0` |
|
|
12
13
|
| 17.2.4 | 1.0.2 | `fg-dynamic-component@^1.0.2` |
|
|
@@ -39,7 +40,7 @@ Then in your component's template include `<fg-dynamic>` where you want to rende
|
|
|
39
40
|
and bind from your component class type of component to render:
|
|
40
41
|
|
|
41
42
|
```ts
|
|
42
|
-
import { FGDynamicService,
|
|
43
|
+
import { FGDynamicService, IFGDynamicItem } from "fg-dynamic-component";
|
|
43
44
|
|
|
44
45
|
FGDynamicService.registerComponent("MyDynamicComponent1", MyDynamicComponent1);
|
|
45
46
|
FGDynamicService.registerComponent("MyDynamicComponent4", import("...").then(m => m.MyDynamicComponent4));
|
|
@@ -72,7 +73,7 @@ class MyComponent {
|
|
|
72
73
|
type: () => import("...").then(m => m.MyDynamicComponent7)
|
|
73
74
|
}
|
|
74
75
|
]
|
|
75
|
-
} as
|
|
76
|
+
} as IFGDynamicItem);
|
|
76
77
|
}
|
|
77
78
|
```
|
|
78
79
|
|
|
@@ -81,7 +82,7 @@ class MyComponent {
|
|
|
81
82
|
You may use `<fg-dynamic>` as a standalone component:
|
|
82
83
|
|
|
83
84
|
```ts
|
|
84
|
-
import { FGDynamicComponent, FGDynamicService,
|
|
85
|
+
import { FGDynamicComponent, FGDynamicService, IFGDynamicItem } from "fg-dynamic-component";
|
|
85
86
|
|
|
86
87
|
FGDynamicService.registerComponent("MyDynamicComponent4", import("...").then(m => m.MyDynamicComponent4));
|
|
87
88
|
FGDynamicService.registerComponent("MyDynamicComponent5", async () => (await import("...")).MyDynamicComponent5);
|
|
@@ -114,7 +115,7 @@ class MyComponent {
|
|
|
114
115
|
type: () => import("...").then(m => m.MyDynamicComponent7)
|
|
115
116
|
}
|
|
116
117
|
]
|
|
117
|
-
} as
|
|
118
|
+
} as IFGDynamicItem);
|
|
118
119
|
}
|
|
119
120
|
```
|
|
120
121
|
|
|
@@ -141,7 +142,7 @@ class MyComponent {
|
|
|
141
142
|
outputs: {
|
|
142
143
|
onSomething: (type) => alert(type)
|
|
143
144
|
}
|
|
144
|
-
} as
|
|
145
|
+
} as IFGDynamicItem);
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
@Component({
|
|
@@ -177,7 +178,7 @@ class MyComponent {
|
|
|
177
178
|
outputs: {
|
|
178
179
|
onSomething: '$vm.update(viewModel => { ...viewModel, message: $event, count: viewModel.count + 1 })'
|
|
179
180
|
}
|
|
180
|
-
} as
|
|
181
|
+
} as IFGDynamicItem);
|
|
181
182
|
viewModel = model({ message: 'Hello World!', count: 0 });
|
|
182
183
|
}
|
|
183
184
|
|
|
@@ -212,7 +213,7 @@ class MyComponent {
|
|
|
212
213
|
class: "some classes",
|
|
213
214
|
disabled: "$vm().isDisabled"
|
|
214
215
|
}
|
|
215
|
-
} as
|
|
216
|
+
} as IFGDynamicItem);
|
|
216
217
|
viewModel = model({ isDisabled: true });
|
|
217
218
|
}
|
|
218
219
|
```
|
|
@@ -247,7 +248,7 @@ class MyComponent {
|
|
|
247
248
|
maxlength: 20,
|
|
248
249
|
required: true
|
|
249
250
|
}
|
|
250
|
-
} as
|
|
251
|
+
} as IFGDynamicItem);
|
|
251
252
|
viewModel = model({ data: { firstName: "Jhon" }, metadata: { firstName: { disabled: false } } });
|
|
252
253
|
formGroup = signal(new FormGroup({}));
|
|
253
254
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, model, viewChild, ViewContainerRef, viewChildren, ElementRef, inject, Renderer2, Injector, EventEmitter,
|
|
2
|
+
import { input, model, viewChild, ViewContainerRef, viewChildren, ElementRef, inject, Renderer2, Injector, EventEmitter, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { FormControlDirective, NgControl, FormControl, Validators, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -22,18 +22,17 @@ class FGDynamicService {
|
|
|
22
22
|
*/
|
|
23
23
|
class FGDynamicComponent {
|
|
24
24
|
constructor() {
|
|
25
|
-
this.configuration = input.required(
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
this._elementRef = inject(ElementRef);
|
|
25
|
+
this.configuration = input.required(/* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "configuration" }] : /* istanbul ignore next */ []));
|
|
27
|
+
this.viewModel = model(/* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [undefined, { debugName: "viewModel" }] : /* istanbul ignore next */ []));
|
|
29
|
+
this.formGroup = input(/* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [undefined, { debugName: "formGroup" }] : /* istanbul ignore next */ []));
|
|
31
|
+
this._viewContainerRef = viewChild.required('viewContainer', { ...(ngDevMode ? { debugName: "_viewContainerRef" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
|
|
32
|
+
this._dynamicItems = viewChildren('dynamicItem', { ...(ngDevMode ? { debugName: "_dynamicItems" } : /* istanbul ignore next */ {}), read: ElementRef });
|
|
35
33
|
this._renderer = inject(Renderer2);
|
|
36
34
|
this._outputsSubscriptions = [];
|
|
35
|
+
this._managedValidatorFns = [];
|
|
37
36
|
this._injector = inject(Injector);
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
@@ -42,46 +41,58 @@ class FGDynamicComponent {
|
|
|
42
41
|
* and before the view and content children are checked.
|
|
43
42
|
*/
|
|
44
43
|
async ngOnChanges() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
try {
|
|
45
|
+
// Lazy-load a component.
|
|
46
|
+
await this.loadComponentAsync();
|
|
47
|
+
// Instantiates a single component and inserts its host view into this container.
|
|
48
|
+
this.createComponent();
|
|
49
|
+
// Updates specified input names to new values.
|
|
50
|
+
this.setInputs();
|
|
51
|
+
// Disables/enables the control.
|
|
52
|
+
this.setFormControlStatus();
|
|
53
|
+
// Add synchronous validators to this control.
|
|
54
|
+
this.setFormControlValidators();
|
|
55
|
+
// Set attribute values for an element in the DOM.
|
|
56
|
+
this.setAttributes();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error('[fg-dynamic] Error during component initialization:', error);
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* A method to lazy-load a component.
|
|
62
64
|
*/
|
|
63
65
|
async loadComponentAsync() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const configurationType = this.configuration().type;
|
|
67
|
+
if (configurationType != null) {
|
|
68
|
+
const requestedType = typeof configurationType === 'string'
|
|
69
|
+
? FGDynamicService.getComponent(configurationType)
|
|
70
|
+
: configurationType;
|
|
71
|
+
if (requestedType == null) {
|
|
72
|
+
return;
|
|
68
73
|
}
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
let resolvedType;
|
|
75
|
+
if (typeof requestedType === 'function') {
|
|
76
|
+
// Try to invoke as a lazy loader function: () => Promise<Type<unknown>>
|
|
77
|
+
try {
|
|
78
|
+
const result = requestedType();
|
|
79
|
+
resolvedType = result instanceof Promise ? await result : result;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Not a lazy loader function, treat it as a direct Type
|
|
83
|
+
resolvedType = requestedType;
|
|
84
|
+
}
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
else if (requestedType instanceof Promise) {
|
|
87
|
+
resolvedType = await requestedType;
|
|
74
88
|
}
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
else {
|
|
90
|
+
resolvedType = requestedType;
|
|
77
91
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
else {
|
|
83
|
-
this._component = type;
|
|
84
|
-
}
|
|
92
|
+
// Only re-assign when the resolved type actually changed, so that subsequent
|
|
93
|
+
// input/attribute updates don't tear down the already-instantiated component.
|
|
94
|
+
if (this._component !== resolvedType) {
|
|
95
|
+
this._component = resolvedType;
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
}
|
|
@@ -89,9 +100,13 @@ class FGDynamicComponent {
|
|
|
89
100
|
* Instantiates a single component and inserts its host view into this container.
|
|
90
101
|
*/
|
|
91
102
|
createComponent() {
|
|
103
|
+
// If the component type changed, clean up and recreate it.
|
|
104
|
+
if (this._componentRef && this._component !== this._componentRef.componentType) {
|
|
105
|
+
this.cleanup();
|
|
106
|
+
}
|
|
92
107
|
if (this._component && !this._componentRef && this._viewContainerRef() && !this._formControlDirective) {
|
|
93
108
|
let injector;
|
|
94
|
-
if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof (this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel()) {
|
|
109
|
+
if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof (this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel() != null) {
|
|
95
110
|
// Synchronizes a standalone FormControl instance to a form control element.
|
|
96
111
|
this._formControlDirective = new FormControlDirective(null, null, null, null);
|
|
97
112
|
// Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.
|
|
@@ -120,21 +135,6 @@ class FGDynamicComponent {
|
|
|
120
135
|
this.createFormControl();
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
|
-
/**
|
|
124
|
-
* A method to remove the fg-dynamic tag.
|
|
125
|
-
*/
|
|
126
|
-
removeHostElement() {
|
|
127
|
-
if (this._elementRef?.nativeElement?.parentElement) {
|
|
128
|
-
const nativeElement = this._elementRef.nativeElement;
|
|
129
|
-
const parentElement = nativeElement.parentElement;
|
|
130
|
-
// Move all children out of the element
|
|
131
|
-
while (nativeElement.firstChild) {
|
|
132
|
-
parentElement.insertBefore(nativeElement.firstChild, nativeElement);
|
|
133
|
-
}
|
|
134
|
-
// Remove the empty element (the host)
|
|
135
|
-
parentElement.removeChild(nativeElement);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
138
|
/**
|
|
139
139
|
* Register handlers for those events by subscribing to an instance.
|
|
140
140
|
*/
|
|
@@ -158,7 +158,7 @@ class FGDynamicComponent {
|
|
|
158
158
|
* Construct a FormControl with an initial value.
|
|
159
159
|
*/
|
|
160
160
|
createFormControl() {
|
|
161
|
-
if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel()) {
|
|
161
|
+
if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel() != null) {
|
|
162
162
|
// Evaluates JavaScript code and executes it.
|
|
163
163
|
const name = this.evaluateExpression(this.configuration().attributes['name'], this.viewModel);
|
|
164
164
|
if (typeof (name) === 'string') {
|
|
@@ -171,8 +171,15 @@ class FGDynamicComponent {
|
|
|
171
171
|
this.formGroup().addControl(name, this._formControl);
|
|
172
172
|
// A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically.
|
|
173
173
|
this._formControlSubscription = this._formControl.valueChanges.subscribe((value) => {
|
|
174
|
-
// Creates a deep clone of an object
|
|
175
|
-
|
|
174
|
+
// Creates a deep clone of an object, falling back to a JSON round-trip
|
|
175
|
+
// when the view model contains non-cloneable values (functions, DOM nodes, ...).
|
|
176
|
+
let viewModel;
|
|
177
|
+
try {
|
|
178
|
+
viewModel = structuredClone(this.viewModel());
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
viewModel = JSON.parse(JSON.stringify(this.viewModel()));
|
|
182
|
+
}
|
|
176
183
|
// Sets the value at path of object.
|
|
177
184
|
// If a portion of path doesn't exist, it's created.
|
|
178
185
|
// Arrays are created for missing index properties while objects are created for all other missing properties.
|
|
@@ -215,7 +222,20 @@ class FGDynamicComponent {
|
|
|
215
222
|
* Add synchronous validators to this control.
|
|
216
223
|
*/
|
|
217
224
|
setFormControlValidators() {
|
|
218
|
-
if (this._formControl
|
|
225
|
+
if (!this._formControl) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
// Always remove previously managed validators, even when the current
|
|
229
|
+
// configuration has no validator-bearing attributes.
|
|
230
|
+
if (this._managedValidatorFns.length > 0) {
|
|
231
|
+
this._formControl.removeValidators(this._managedValidatorFns);
|
|
232
|
+
this._managedValidatorFns = [];
|
|
233
|
+
this._formControl.updateValueAndValidity({
|
|
234
|
+
onlySelf: true,
|
|
235
|
+
emitEvent: false
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {
|
|
219
239
|
const validators = [];
|
|
220
240
|
// Validator that requires the control's value to be greater than or equal to the provided number.
|
|
221
241
|
const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel);
|
|
@@ -239,12 +259,12 @@ class FGDynamicComponent {
|
|
|
239
259
|
}
|
|
240
260
|
// Validator that requires the length of the control's value to be less than or equal to the provided maximum length.
|
|
241
261
|
const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel);
|
|
242
|
-
if (maxLength
|
|
262
|
+
if (maxLength >= 0 && maxLength.toString() !== this._componentRef.location.nativeElement.getAttribute('maxlength')) {
|
|
243
263
|
validators.push(Validators.maxLength(maxLength));
|
|
244
264
|
}
|
|
245
265
|
// Validator that requires the length of the control's value to be greater than or equal to the provided minimum length.
|
|
246
266
|
const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel);
|
|
247
|
-
if (minLength
|
|
267
|
+
if (minLength >= 0 && minLength.toString() !== this._componentRef.location.nativeElement.getAttribute('minlength')) {
|
|
248
268
|
validators.push(Validators.minLength(minLength));
|
|
249
269
|
}
|
|
250
270
|
// Validator that requires the control's value to match a regex pattern.
|
|
@@ -252,17 +272,15 @@ class FGDynamicComponent {
|
|
|
252
272
|
if (typeof (pattern) === 'string' && pattern !== this._componentRef.location.nativeElement.getAttribute('pattern')) {
|
|
253
273
|
validators.push(Validators.pattern(pattern));
|
|
254
274
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
});
|
|
265
|
-
}
|
|
275
|
+
// Track and add the newly built managed validators.
|
|
276
|
+
this._managedValidatorFns = validators;
|
|
277
|
+
this._formControl.addValidators(this._managedValidatorFns);
|
|
278
|
+
// Recalculates the value and validation status of the control whenever the
|
|
279
|
+
// managed validator set changes (including when it becomes empty).
|
|
280
|
+
this._formControl.updateValueAndValidity({
|
|
281
|
+
onlySelf: true,
|
|
282
|
+
emitEvent: false
|
|
283
|
+
});
|
|
266
284
|
}
|
|
267
285
|
}
|
|
268
286
|
/**
|
|
@@ -270,7 +288,8 @@ class FGDynamicComponent {
|
|
|
270
288
|
*/
|
|
271
289
|
attachFormControlDirective() {
|
|
272
290
|
if (this._formControlDirective && this._componentRef?.injector && this._formControl) {
|
|
273
|
-
|
|
291
|
+
const valueAccessors = this._componentRef.injector.get(NG_VALUE_ACCESSOR, null);
|
|
292
|
+
this._formControlDirective.valueAccessor = Array.isArray(valueAccessors) && valueAccessors.length > 0 ? valueAccessors[0] : null;
|
|
274
293
|
this._formControlDirective.form = this._formControl;
|
|
275
294
|
// A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.
|
|
276
295
|
this._formControlDirective.ngOnChanges({
|
|
@@ -342,10 +361,17 @@ class FGDynamicComponent {
|
|
|
342
361
|
for (const attributeName in this.configuration().attributes) {
|
|
343
362
|
// Evaluates JavaScript code and executes it.
|
|
344
363
|
const value = this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel);
|
|
364
|
+
// Convert non-string values to their string form; null/undefined mean "remove the attribute".
|
|
365
|
+
const stringValue = value != null ? String(value) : null;
|
|
345
366
|
// Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.
|
|
346
|
-
if (
|
|
367
|
+
if (stringValue !== this._componentRef.location.nativeElement.getAttribute(attributeName)) {
|
|
347
368
|
// Implement this callback to set an attribute value for an element in the DOM.
|
|
348
|
-
|
|
369
|
+
if (stringValue != null) {
|
|
370
|
+
this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, stringValue);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this._renderer.removeAttribute(this._componentRef.location.nativeElement, attributeName);
|
|
374
|
+
}
|
|
349
375
|
}
|
|
350
376
|
}
|
|
351
377
|
}
|
|
@@ -359,7 +385,8 @@ class FGDynamicComponent {
|
|
|
359
385
|
*/
|
|
360
386
|
evaluateExpression(value, $vm, $event) {
|
|
361
387
|
if (typeof (value) === 'string' && ((value.includes('$vm') && $vm != null && $vm() != null) || (value.includes('$event') && $event != null))) {
|
|
362
|
-
//
|
|
388
|
+
// NOTE: This uses eval() by design to support expression binding via the $vm and $event placeholders.
|
|
389
|
+
// Only evaluate expressions from trusted configuration sources — arbitrary JavaScript can be executed here.
|
|
363
390
|
return eval(value);
|
|
364
391
|
}
|
|
365
392
|
else {
|
|
@@ -367,41 +394,64 @@ class FGDynamicComponent {
|
|
|
367
394
|
}
|
|
368
395
|
}
|
|
369
396
|
/**
|
|
370
|
-
*
|
|
397
|
+
* Cleans up every dynamically created resource: subscriptions, form control, value accessor directive and component reference.
|
|
398
|
+
* Used both on component type change and on destroy.
|
|
371
399
|
*/
|
|
372
|
-
|
|
373
|
-
//
|
|
400
|
+
cleanup() {
|
|
401
|
+
// Disposes the resources held by the output subscriptions.
|
|
374
402
|
this._outputsSubscriptions?.forEach((s) => s.unsubscribe());
|
|
375
|
-
|
|
376
|
-
//
|
|
403
|
+
this._outputsSubscriptions = [];
|
|
404
|
+
// Disposes the resources held by the form control subscription.
|
|
377
405
|
this._formControlSubscription?.unsubscribe();
|
|
406
|
+
this._formControlSubscription = undefined;
|
|
407
|
+
// Remove the managed control from the form group.
|
|
408
|
+
if (this._formControl && this.formGroup()) {
|
|
409
|
+
const attributeName = this.configuration()?.attributes?.['name'];
|
|
410
|
+
if (attributeName) {
|
|
411
|
+
const controlName = this.evaluateExpression(attributeName, this.viewModel);
|
|
412
|
+
// Only remove the control if it is the one this component created, so that
|
|
413
|
+
// a pre-existing control registered under the same name is left untouched.
|
|
414
|
+
if (typeof controlName === 'string' && this.formGroup().get(controlName) === this._formControl) {
|
|
415
|
+
this.formGroup().removeControl(controlName);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
this._formControl = undefined;
|
|
420
|
+
this._managedValidatorFns = [];
|
|
378
421
|
// A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
|
|
379
422
|
this._formControlDirective?.ngOnDestroy();
|
|
423
|
+
this._formControlDirective = undefined;
|
|
380
424
|
// Destroys the component instance and all of the data structures associated with it.
|
|
381
425
|
this._componentRef?.destroy();
|
|
426
|
+
this._componentRef = undefined;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
|
|
430
|
+
*/
|
|
431
|
+
ngOnDestroy() {
|
|
432
|
+
this.cleanup();
|
|
382
433
|
}
|
|
383
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
384
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
434
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: FGDynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
435
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: FGDynamicComponent, isStandalone: true, selector: "fg-dynamic", inputs: { configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: true, transformFunction: null }, viewModel: { classPropertyName: "viewModel", publicName: "viewModel", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { viewModel: "viewModelChange" }, viewQueries: [{ propertyName: "_viewContainerRef", first: true, predicate: ["viewContainer"], descendants: true, read: ViewContainerRef, isSignal: true }, { propertyName: "_dynamicItems", predicate: ["dynamicItem"], descendants: true, read: ElementRef, isSignal: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
385
436
|
<ng-container #viewContainer></ng-container>
|
|
386
437
|
@for (item of configuration()?.items; track $index) {
|
|
387
438
|
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" />
|
|
388
439
|
}
|
|
389
|
-
`, isInline: true, dependencies: [{ kind: "component", type: FGDynamicComponent, selector: "fg-dynamic", inputs: ["configuration", "viewModel", "formGroup"], outputs: ["viewModelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
440
|
+
`, isInline: true, styles: [":host{display:contents}\n"], dependencies: [{ kind: "component", type: FGDynamicComponent, selector: "fg-dynamic", inputs: ["configuration", "viewModel", "formGroup"], outputs: ["viewModelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
390
441
|
}
|
|
391
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: FGDynamicComponent, decorators: [{
|
|
392
443
|
type: Component,
|
|
393
|
-
args: [{
|
|
394
|
-
selector: 'fg-dynamic',
|
|
395
|
-
template: `
|
|
444
|
+
args: [{ selector: 'fg-dynamic', template: `
|
|
396
445
|
<ng-container #viewContainer></ng-container>
|
|
397
446
|
@for (item of configuration()?.items; track $index) {
|
|
398
447
|
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" />
|
|
399
448
|
}
|
|
400
|
-
`,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
449
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, styles: [":host{display:contents}\n"] }]
|
|
450
|
+
}], propDecorators: { configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: true }] }], viewModel: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewModel", required: false }] }, { type: i0.Output, args: ["viewModelChange"] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], _viewContainerRef: [{ type: i0.ViewChild, args: ['viewContainer', { ...{
|
|
451
|
+
read: ViewContainerRef
|
|
452
|
+
}, isSignal: true }] }], _dynamicItems: [{ type: i0.ViewChildren, args: ['dynamicItem', { ...{
|
|
453
|
+
read: ElementRef
|
|
454
|
+
}, isSignal: true }] }] } });
|
|
405
455
|
|
|
406
456
|
/*
|
|
407
457
|
* Public API Surface of fg-dynamic-component
|