fg-dynamic-component 1.0.1 → 1.1.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.
@@ -2,6 +2,9 @@ import * as i0 from '@angular/core';
2
2
  import { input, model, viewChild, ViewContainerRef, viewChildren, ElementRef, inject, Renderer2, Injector, EventEmitter, Component, ChangeDetectionStrategy } from '@angular/core';
3
3
  import { FormControlDirective, NgControl, FormControl, Validators, NG_VALUE_ACCESSOR } from '@angular/forms';
4
4
 
5
+ /**
6
+ * Declare components to dynamically load in static and/or dynamic way using the FGDynamicService.
7
+ */
5
8
  class FGDynamicService {
6
9
  static { this._components = {}; }
7
10
  static registerComponent(name, type) {
@@ -13,6 +16,10 @@ class FGDynamicService {
13
16
  return FGDynamicService._components[name];
14
17
  }
15
18
  }
19
+ /**
20
+ * Create a standalone signals based dynamic components tree through a JSON configuration with full
21
+ * life-cycle support for inputs, outputs, attributes, reactive forms and expressions binding evaluation.
22
+ */
16
23
  class FGDynamicComponent {
17
24
  constructor() {
18
25
  this.configuration = input.required();
@@ -29,29 +36,65 @@ class FGDynamicComponent {
29
36
  this._outputsSubscriptions = [];
30
37
  this._injector = inject(Injector);
31
38
  }
39
+ /**
40
+ * A callback method that is invoked immediately after the default change
41
+ * detector has checked data-bound properties if at least one has changed,
42
+ * and before the view and content children are checked.
43
+ */
32
44
  async ngOnChanges() {
45
+ // Lazy-load a component.
33
46
  await this.loadComponentAsync();
47
+ // Instantiates a single component and inserts its host view into this container.
34
48
  this.createComponent();
49
+ // Remove the fg-dynamic tag.
50
+ this.removeHostElement();
51
+ // Updates specified input names to new values.
35
52
  this.setInputs();
36
- this.setAttributes();
53
+ // Disables/enables the control.
37
54
  this.setFormControlStatus();
55
+ // Add synchronous validators to this control.
38
56
  this.setFormControlValidators();
57
+ // Set attribute values for an element in the DOM.
58
+ this.setAttributes();
39
59
  }
60
+ /**
61
+ * A method to lazy-load a component.
62
+ */
40
63
  async loadComponentAsync() {
41
64
  if (this.configuration().type != null && !this._component) {
65
+ let type;
42
66
  if (typeof (this.configuration().type) === 'string') {
43
- this._component = await FGDynamicService.getComponent(this.configuration().type);
67
+ type = FGDynamicService.getComponent(this.configuration().type);
44
68
  }
45
69
  else {
46
- this._component = await this.configuration().type;
70
+ type = this.configuration().type;
71
+ }
72
+ try {
73
+ type = type();
74
+ }
75
+ catch {
76
+ type = type;
77
+ }
78
+ finally {
79
+ if (type instanceof Promise) {
80
+ this._component = await type;
81
+ }
82
+ else {
83
+ this._component = type;
84
+ }
47
85
  }
48
86
  }
49
87
  }
88
+ /**
89
+ * Instantiates a single component and inserts its host view into this container.
90
+ */
50
91
  createComponent() {
51
- if (this._component && !this._componentRef && this._viewContainerRef()) {
92
+ if (this._component && !this._componentRef && this._viewContainerRef() && !this._formControlDirective) {
52
93
  let injector;
53
- if (this.formGroup() && this.configuration()?.attributes && this.configuration()?.attributes['name'] && this.viewModel()) {
94
+ if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof (this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel()) {
95
+ // Synchronizes a standalone FormControl instance to a form control element.
54
96
  this._formControlDirective = new FormControlDirective(null, null, null, null);
97
+ // Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.
55
98
  injector = Injector.create({
56
99
  providers: [{
57
100
  provide: NgControl,
@@ -60,18 +103,26 @@ class FGDynamicComponent {
60
103
  parent: this._injector
61
104
  });
62
105
  }
106
+ // Instantiates a single component and inserts its host view into this container.
63
107
  this._componentRef = this._viewContainerRef().createComponent(this._component, {
64
108
  projectableNodes: this._dynamicItems()?.length > 0 ? [this._dynamicItems().map((e) => e.nativeElement)] : undefined,
65
109
  injector: injector
66
110
  });
111
+ // When a view uses the ChangeDetectionStrategy#OnPush (checkOnce) change detection strategy, explicitly marks the view as changed so that it can be checked again.
112
+ // Components are normally marked as dirty (in need of rerendering) when inputs have changed or events have fired in the view.
113
+ // Call this method to ensure that a component is checked even if these triggers have not occurred.
67
114
  if (this._componentRef?.changeDetectorRef) {
68
115
  this._componentRef.changeDetectorRef.markForCheck();
69
116
  }
70
- this.removeHostElement();
117
+ // Register handlers for those events by subscribing to an instance.
71
118
  this.handleOutputs();
119
+ // Construct a FormControl with an initial value.
72
120
  this.createFormControl();
73
121
  }
74
122
  }
123
+ /**
124
+ * A method to remove the fg-dynamic tag.
125
+ */
75
126
  removeHostElement() {
76
127
  if (this._elementRef?.nativeElement?.parentElement) {
77
128
  const nativeElement = this._elementRef.nativeElement;
@@ -84,14 +135,18 @@ class FGDynamicComponent {
84
135
  parentElement.removeChild(nativeElement);
85
136
  }
86
137
  }
138
+ /**
139
+ * Register handlers for those events by subscribing to an instance.
140
+ */
87
141
  handleOutputs() {
88
- this._outputsSubscriptions?.forEach((s) => s.unsubscribe());
89
- if (this.configuration()?.outputs && this._componentRef?.instance) {
142
+ if (this.configuration()?.outputs && Object.keys(this.configuration().outputs).length > 0 && this._componentRef?.instance) {
90
143
  for (const outputName in this.configuration().outputs) {
91
144
  if (this._componentRef.instance[outputName] instanceof EventEmitter) {
92
- this._outputsSubscriptions?.push(this._componentRef.instance[outputName].subscribe(($event) => {
145
+ this._outputsSubscriptions.push(this._componentRef.instance[outputName].subscribe(($event) => {
146
+ // Evaluates JavaScript code and executes it.
93
147
  const result = this.evaluateExpression(this.configuration().outputs[outputName], this.viewModel, $event);
94
148
  if (result instanceof Function) {
149
+ // Executes a function.
95
150
  result($event);
96
151
  }
97
152
  }));
@@ -99,84 +154,125 @@ class FGDynamicComponent {
99
154
  }
100
155
  }
101
156
  }
157
+ /**
158
+ * Construct a FormControl with an initial value.
159
+ */
102
160
  createFormControl() {
103
- if (this.formGroup() && this.configuration()?.attributes && this.configuration()?.attributes['name'] && this.viewModel()) {
104
- this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), this.configuration().attributes['name'], null));
105
- this.formGroup().addControl(this.configuration().attributes['name'], this._formControl);
106
- this._formGroupSubscription?.unsubscribe();
107
- this._formGroupSubscription = this.formGroup().valueChanges.subscribe(() => {
108
- const model = this.formGroup().getRawValue();
109
- if (model) {
110
- const value = model[this.configuration().attributes['name']] ?? null;
161
+ if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel()) {
162
+ // Evaluates JavaScript code and executes it.
163
+ const name = this.evaluateExpression(this.configuration().attributes['name'], this.viewModel);
164
+ if (typeof (name) === 'string') {
165
+ // Construct a FormControl with an initial value.
166
+ this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), name, null));
167
+ // Add a control to this group. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).
168
+ // If a control with a given name already exists, it would not be replaced with a new one.
169
+ // If you want to replace an existing control, use the FormGroup#setControl setControl method instead.
170
+ // This method also updates the value and validity of the control.
171
+ this.formGroup().addControl(name, this._formControl);
172
+ // A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically.
173
+ this._formControlSubscription = this._formControl.valueChanges.subscribe((value) => {
174
+ // Creates a deep clone of an object.
111
175
  const viewModel = structuredClone(this.viewModel());
112
- this.setModelPropertyValue(viewModel, this.configuration().attributes['name'], value);
176
+ // Sets the value at path of object.
177
+ // If a portion of path doesn't exist, it's created.
178
+ // Arrays are created for missing index properties while objects are created for all other missing properties.
179
+ // This method mutates object.
180
+ this.setModelPropertyValue(viewModel, name, value);
181
+ // Directly set the signal to a new value, and notify any dependents.
113
182
  this.viewModel.set(viewModel);
114
- }
115
- });
116
- this.attachFormControlDirective();
183
+ });
184
+ // Synchronizes a standalone FormControl instance to a form control element.
185
+ this.attachFormControlDirective();
186
+ }
117
187
  }
118
188
  }
189
+ /**
190
+ * Disables/enables the control.
191
+ */
119
192
  setFormControlStatus() {
120
193
  if (this._formControl && this.configuration().attributes && this.configuration().attributes['disabled'] != null) {
194
+ // Evaluates JavaScript code and executes it.
121
195
  const isDisabled = this.evaluateExpression(this.configuration().attributes['disabled'], this.viewModel);
122
- if (isDisabled) {
123
- this._formControl.disable({
124
- onlySelf: true,
125
- emitEvent: false
126
- });
127
- }
128
- else {
129
- this._formControl.enable({
130
- onlySelf: true,
131
- emitEvent: false
132
- });
196
+ if (typeof (isDisabled) === 'boolean' && ((isDisabled && this._formControl.enabled) || (!isDisabled && this._formControl.disabled))) {
197
+ if (isDisabled) {
198
+ // Disables the control.
199
+ this._formControl.disable({
200
+ onlySelf: true,
201
+ emitEvent: false
202
+ });
203
+ }
204
+ else {
205
+ // Enables the control.
206
+ this._formControl.enable({
207
+ onlySelf: true,
208
+ emitEvent: false
209
+ });
210
+ }
133
211
  }
134
212
  }
135
213
  }
214
+ /**
215
+ * Add synchronous validators to this control.
216
+ */
136
217
  setFormControlValidators() {
137
- if (this._formControl && this.configuration()?.attributes) {
138
- this._formControl.clearValidators();
218
+ if (this._formControl && this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {
139
219
  const validators = [];
220
+ // Validator that requires the control's value to be greater than or equal to the provided number.
140
221
  const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel);
141
- if (typeof (min) === 'number') {
222
+ if (typeof (min) === 'number' && min.toString() !== this._componentRef.location.nativeElement.getAttribute('min')) {
142
223
  validators.push(Validators.min(min));
143
224
  }
225
+ // Validator that requires the control's value to be less than or equal to the provided number.
144
226
  const max = this.evaluateExpression(this.configuration().attributes['max'], this.viewModel);
145
- if (typeof (max) === 'number') {
227
+ if (typeof (max) === 'number' && max.toString() !== this._componentRef.location.nativeElement.getAttribute('max')) {
146
228
  validators.push(Validators.max(max));
147
229
  }
230
+ // Validator that requires the control have a non-empty value.
148
231
  const required = this.evaluateExpression(this.configuration().attributes['required'], this.viewModel);
149
- if (required === true) {
232
+ if (required === true && required.toString() !== this._componentRef.location.nativeElement.getAttribute('required')) {
150
233
  validators.push(Validators.required);
151
234
  }
235
+ // Validator that requires the control's value pass an email validation test.
152
236
  const email = this.evaluateExpression(this.configuration().attributes['email'], this.viewModel);
153
- if (email === true) {
237
+ if (email === true && email.toString() !== this._componentRef.location.nativeElement.getAttribute('email')) {
154
238
  validators.push(Validators.email);
155
239
  }
240
+ // Validator that requires the length of the control's value to be less than or equal to the provided maximum length.
156
241
  const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel);
157
- if (maxLength > 0) {
242
+ if (maxLength > 0 && maxLength.toString() !== this._componentRef.location.nativeElement.getAttribute('maxlength')) {
158
243
  validators.push(Validators.maxLength(maxLength));
159
244
  }
245
+ // Validator that requires the length of the control's value to be greater than or equal to the provided minimum length.
160
246
  const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel);
161
- if (minLength > 0) {
247
+ if (minLength > 0 && minLength.toString() !== this._componentRef.location.nativeElement.getAttribute('minlength')) {
162
248
  validators.push(Validators.minLength(minLength));
163
249
  }
250
+ // Validator that requires the control's value to match a regex pattern.
164
251
  const pattern = this.evaluateExpression(this.configuration().attributes['pattern'], this.viewModel);
165
- if (typeof (pattern) === 'string' || pattern instanceof RegExp) {
252
+ if (typeof (pattern) === 'string' && pattern !== this._componentRef.location.nativeElement.getAttribute('pattern')) {
166
253
  validators.push(Validators.pattern(pattern));
167
254
  }
168
- this._formControl.addValidators(validators);
169
- this._formControl.updateValueAndValidity({
170
- onlySelf: true,
171
- emitEvent: false
172
- });
255
+ if (validators.length > 0) {
256
+ // Empties out the synchronous validator list.
257
+ this._formControl.clearValidators();
258
+ // Add a synchronous validator or validators to this control, without affecting other validators.
259
+ this._formControl.addValidators(validators);
260
+ // Recalculates the value and validation status of the control.
261
+ this._formControl.updateValueAndValidity({
262
+ onlySelf: true,
263
+ emitEvent: false
264
+ });
265
+ }
173
266
  }
174
267
  }
268
+ /**
269
+ * Synchronizes a standalone FormControl instance to a form control element.
270
+ */
175
271
  attachFormControlDirective() {
176
272
  if (this._formControlDirective && this._componentRef?.injector && this._formControl) {
177
- const valueAccessor = this._componentRef.injector.get(NG_VALUE_ACCESSOR, null)?.find((_) => true);
178
- this._formControlDirective.valueAccessor = valueAccessor;
273
+ this._formControlDirective.valueAccessor = this._componentRef.injector.get(NG_VALUE_ACCESSOR, null)?.find((_) => true);
179
274
  this._formControlDirective.form = this._formControl;
275
+ // 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.
180
276
  this._formControlDirective.ngOnChanges({
181
277
  form: {
182
278
  firstChange: true,
@@ -187,6 +283,12 @@ class FGDynamicComponent {
187
283
  });
188
284
  }
189
285
  }
286
+ /**
287
+ * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
288
+ * @param model The object.
289
+ * @param property The path.
290
+ * @param defaultValue The resolved value.
291
+ */
190
292
  getModelPropertyValue(model, property, defaultValue) {
191
293
  // If path is not defined or it has false value
192
294
  if (!property) {
@@ -199,6 +301,14 @@ class FGDynamicComponent {
199
301
  // If found value is undefined return default value; otherwise return the value
200
302
  return result != null ? result : defaultValue;
201
303
  }
304
+ /**
305
+ * Sets the value at path of object. If a portion of path doesn't exist, it's created.
306
+ * Arrays are created for missing index properties while objects are created for all other missing properties.
307
+ * This method mutates object.
308
+ * @param model The object.
309
+ * @param property The path.
310
+ * @param value The value.
311
+ */
202
312
  setModelPropertyValue(model, property, value) {
203
313
  const pathArray = Array.isArray(property) ? property : property.match(/([^[.\]])+/g);
204
314
  pathArray.reduce((acc, key, i) => {
@@ -211,32 +321,63 @@ class FGDynamicComponent {
211
321
  return acc[key];
212
322
  }, model);
213
323
  }
324
+ /**
325
+ * Updates specified input names to new values.
326
+ */
214
327
  setInputs() {
215
- if (this.configuration()?.inputs && this._componentRef) {
328
+ if (this.configuration()?.inputs && Object.keys(this.configuration().inputs).length > 0 && this._componentRef) {
216
329
  for (const inputName in this.configuration().inputs) {
330
+ // Updates a specified input name to a new value.
331
+ // Using this method will properly mark for check component using the OnPush change detection strategy.
332
+ // It will also assure that the OnChanges lifecycle hook runs when a dynamically created component is change-detected.
217
333
  this._componentRef.setInput(inputName, this.evaluateExpression(this.configuration().inputs[inputName], this.viewModel));
218
334
  }
219
335
  }
220
336
  }
337
+ /**
338
+ * Set attribute values for an element in the DOM.
339
+ */
221
340
  setAttributes() {
222
- if (this.configuration()?.attributes && this._componentRef) {
341
+ if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {
223
342
  for (const attributeName in this.configuration().attributes) {
224
- this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel));
343
+ // Evaluates JavaScript code and executes it.
344
+ const value = this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel);
345
+ // Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.
346
+ if (value !== this._componentRef.location.nativeElement.getAttribute(attributeName)) {
347
+ // Implement this callback to set an attribute value for an element in the DOM.
348
+ this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, value);
349
+ }
225
350
  }
226
351
  }
227
352
  }
353
+ /**
354
+ * Evaluates JavaScript code and executes it.
355
+ * @param value The JavaScript code.
356
+ * @param $vm The view model.
357
+ * @param $event The event.
358
+ * @returns Evaluated expression.
359
+ */
228
360
  evaluateExpression(value, $vm, $event) {
229
- if (typeof (value) === 'string' && ((value.includes('$vm') && $vm() != null) || (value.includes('$event') && $event != null))) {
361
+ if (typeof (value) === 'string' && ((value.includes('$vm') && $vm != null && $vm() != null) || (value.includes('$event') && $event != null))) {
362
+ // Evaluates JavaScript code and executes it.
230
363
  return eval(value);
231
364
  }
232
365
  else {
233
366
  return value;
234
367
  }
235
368
  }
369
+ /**
370
+ * A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
371
+ */
236
372
  ngOnDestroy() {
373
+ // Performs the specified action for each element in an array (Disposes the resources held by the subscription).
237
374
  this._outputsSubscriptions?.forEach((s) => s.unsubscribe());
238
- this._formGroupSubscription?.unsubscribe();
375
+ // Disposes the resources held by the subscription.
376
+ // May, for instance, cancel an ongoing Observable execution or cancel any other type of work that started when the Subscription was created.
377
+ this._formControlSubscription?.unsubscribe();
378
+ // A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
239
379
  this._formControlDirective?.ngOnDestroy();
380
+ // Destroys the component instance and all of the data structures associated with it.
240
381
  this._componentRef?.destroy();
241
382
  }
242
383
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: FGDynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
@@ -1 +1 @@
1
- {"version":3,"file":"fg-dynamic-component.mjs","sources":["../../../projects/fg-dynamic-component/src/lib/fg-dynamic.component.ts","../../../projects/fg-dynamic-component/src/public-api.ts","../../../projects/fg-dynamic-component/src/fg-dynamic-component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ComponentRef, ElementRef, EventEmitter, Injector, InputSignal, ModelSignal, OnDestroy, Renderer2, Signal, Type, ViewContainerRef, inject, input, model, viewChild, viewChildren } from '@angular/core';\nimport { ControlValueAccessor, FormControl, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, NgControl, ValidatorFn, Validators } from '@angular/forms';\nimport { Subscription } from 'rxjs';\n\nexport interface FGDynamicItem {\n type?: string | Type<unknown> | Promise<Type<unknown>>;\n inputs?: Record<string, string | unknown>;\n outputs?: Record<string, string | Function>;\n attributes?: Record<string, string | unknown>;\n items?: FGDynamicItem[];\n}\n\nexport class FGDynamicService {\n private static _components: Record<string, Type<unknown> | Promise<Type<unknown>>> = {};\n\n static registerComponent(name: string, type: Type<unknown> | Promise<Type<unknown>>): void {\n if (name && type) {\n FGDynamicService._components[name] = type;\n }\n }\n\n static getComponent(name: string): Type<unknown> | Promise<Type<unknown>> {\n return FGDynamicService._components[name];\n }\n}\n\n@Component({\n\tselector: 'fg-dynamic',\n\ttemplate: `\n <ng-container #viewContainer></ng-container>\n @for (item of configuration()?.items; track $index) {\n <fg-dynamic #dynamicItem [configuration]=\"item\" [(viewModel)]=\"viewModel\" [formGroup]=\"formGroup()\" />\n }\n `,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tstandalone: true\n})\nexport class FGDynamicComponent implements OnDestroy {\n\tconfiguration: InputSignal<FGDynamicItem> = input.required<FGDynamicItem>();\n\tviewModel: ModelSignal<unknown> = model<unknown>();\n\tformGroup: InputSignal<FormGroup> = input<FormGroup>();\n\n\tprivate _viewContainerRef: Signal<ViewContainerRef> = viewChild.required('viewContainer', {\n read: ViewContainerRef\n });\n private _dynamicItems: Signal<readonly ElementRef<unknown>[]> = viewChildren('dynamicItem', {\n read: ElementRef\n });\n\tprivate _componentRef: ComponentRef<unknown>;\n private _elementRef: ElementRef<HTMLElement> = inject(ElementRef);\n private _renderer: Renderer2 = inject(Renderer2);\n private _outputsSubscriptions: Subscription[] = [];\n private _formControl: FormControl;\n private _formControlDirective: FormControlDirective;\n private _formGroupSubscription: Subscription;\n private _component: Type<unknown>;\n private _injector: Injector = inject(Injector);\n\n async ngOnChanges(): Promise<void> {\n await this.loadComponentAsync();\n this.createComponent();\n this.setInputs();\n this.setAttributes();\n this.setFormControlStatus();\n this.setFormControlValidators();\n }\n\n private async loadComponentAsync(): Promise<void> {\n if (this.configuration().type != null && !this._component) {\n if (typeof(this.configuration().type) === 'string') {\n this._component = await FGDynamicService.getComponent(this.configuration().type as string);\n } else {\n this._component = await (this.configuration().type as (Type<unknown> | Promise<Type<unknown>>));\n }\n }\n }\n\n private createComponent(): void {\n if (this._component && !this._componentRef && this._viewContainerRef()) {\n let injector: Injector;\n\n if (this.formGroup() && this.configuration()?.attributes && this.configuration()?.attributes['name'] && this.viewModel()) {\n this._formControlDirective = new FormControlDirective(null, null, null, null);\n\n injector = Injector.create({\n providers: [{\n provide: NgControl,\n useValue: this._formControlDirective\n }],\n parent: this._injector\n });\n }\n\n this._componentRef = this._viewContainerRef().createComponent(this._component, {\n projectableNodes: this._dynamicItems()?.length > 0 ? [this._dynamicItems().map((e: ElementRef<unknown>): Node => e.nativeElement as Node)] : undefined,\n injector: injector\n });\n\n if (this._componentRef?.changeDetectorRef) {\n this._componentRef.changeDetectorRef.markForCheck();\n }\n\n this.removeHostElement();\n this.handleOutputs();\n this.createFormControl();\n }\n }\n\n private removeHostElement(): void {\n if (this._elementRef?.nativeElement?.parentElement) {\n const nativeElement: HTMLElement = this._elementRef.nativeElement;\n const parentElement: HTMLElement = nativeElement.parentElement;\n\n // Move all children out of the element\n while (nativeElement.firstChild) {\n parentElement.insertBefore(nativeElement.firstChild, nativeElement);\n }\n\n // Remove the empty element (the host)\n parentElement.removeChild(nativeElement);\n }\n }\n\n private handleOutputs(): void {\n this._outputsSubscriptions?.forEach((s: Subscription): void => s.unsubscribe());\n\n if (this.configuration()?.outputs && this._componentRef?.instance) {\n for (const outputName in this.configuration().outputs) {\n if (this._componentRef.instance[outputName] instanceof EventEmitter) {\n this._outputsSubscriptions?.push(this._componentRef.instance[outputName].subscribe(($event: unknown): void => {\n const result: unknown = this.evaluateExpression(this.configuration().outputs[outputName], this.viewModel, $event);\n\n if (result instanceof Function) {\n result($event)\n }\n }));\n }\n }\n }\n }\n\n private createFormControl(): void {\n if (this.formGroup() && this.configuration()?.attributes && this.configuration()?.attributes['name'] && this.viewModel()) {\n this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), this.configuration().attributes['name'] as string, null));\n\n this.formGroup().addControl(this.configuration().attributes['name'] as string, this._formControl);\n this._formGroupSubscription?.unsubscribe();\n\n this._formGroupSubscription = this.formGroup().valueChanges.subscribe((): void => {\n const model: unknown = this.formGroup().getRawValue();\n\n if (model) {\n const value: unknown = model[this.configuration().attributes['name'] as string] ?? null;\n const viewModel: unknown = structuredClone(this.viewModel());\n\n this.setModelPropertyValue(viewModel, this.configuration().attributes['name'] as string, value);\n this.viewModel.set(viewModel);\n }\n });\n\n this.attachFormControlDirective();\n }\n }\n\n private setFormControlStatus(): void {\n if (this._formControl && this.configuration().attributes && this.configuration().attributes['disabled'] != null) {\n const isDisabled: boolean = this.evaluateExpression(this.configuration().attributes['disabled'], this.viewModel) as boolean;\n\n if (isDisabled) {\n this._formControl.disable({\n onlySelf: true,\n emitEvent: false\n });\n } else {\n this._formControl.enable({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n\n private setFormControlValidators(): void {\n if (this._formControl && this.configuration()?.attributes) {\n this._formControl.clearValidators();\n\n const validators: ValidatorFn[] = [];\n const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel) as number;\n\n if (typeof(min) === 'number') {\n validators.push(Validators.min(min));\n }\n\n const max = this.evaluateExpression(this.configuration().attributes['max'], this.viewModel) as number;\n\n if (typeof(max) === 'number') {\n validators.push(Validators.max(max));\n }\n\n const required = this.evaluateExpression(this.configuration().attributes['required'], this.viewModel) as boolean;\n\n if (required === true) {\n validators.push(Validators.required);\n }\n\n const email = this.evaluateExpression(this.configuration().attributes['email'], this.viewModel) as boolean;\n\n if (email === true) {\n validators.push(Validators.email);\n }\n\n const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel) as number;\n\n if (maxLength > 0) {\n validators.push(Validators.maxLength(maxLength));\n }\n\n const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel) as number;\n\n if (minLength > 0) {\n validators.push(Validators.minLength(minLength));\n }\n\n const pattern = this.evaluateExpression(this.configuration().attributes['pattern'], this.viewModel) as (string | RegExp);\n\n if (typeof(pattern) === 'string' || pattern instanceof RegExp) {\n validators.push(Validators.pattern(pattern));\n }\n\n this._formControl.addValidators(validators);\n this._formControl.updateValueAndValidity({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n\n private attachFormControlDirective(): void {\n if (this._formControlDirective && this._componentRef?.injector && this._formControl) {\n const valueAccessor: ControlValueAccessor = this._componentRef.injector.get<ControlValueAccessor[]>(NG_VALUE_ACCESSOR, null)?.find((_: ControlValueAccessor): true => true);\n\n this._formControlDirective.valueAccessor = valueAccessor;\n this._formControlDirective.form = this._formControl;\n\n this._formControlDirective.ngOnChanges({\n form: {\n firstChange: true,\n currentValue: this._formControl,\n previousValue: undefined,\n isFirstChange: (): true => true\n }\n });\n }\n }\n\n private getModelPropertyValue(model: unknown, property: Array<string> | string, defaultValue: unknown): unknown {\n // If path is not defined or it has false value\n if (!property) {\n return undefined\n }\n\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n // Find value\n const result: unknown = pathArray.reduce((prevObj: unknown, key: string): unknown => prevObj && prevObj[key], model);\n\n // If found value is undefined return default value; otherwise return the value\n return result != null ? result : defaultValue\n }\n\n private setModelPropertyValue(model: unknown, property: Array<string> | string, value: unknown): void {\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n\n pathArray.reduce((acc: unknown, key: string, i: number): unknown => {\n if (acc[key] === undefined) {\n acc[key] = {};\n }\n\n if (i === pathArray.length - 1) {\n acc[key] = value;\n }\n\n return acc[key]\n }, model);\n }\n\n private setInputs(): void {\n if (this.configuration()?.inputs && this._componentRef) {\n for (const inputName in this.configuration().inputs) {\n this._componentRef.setInput(inputName, this.evaluateExpression(this.configuration().inputs[inputName], this.viewModel));\n }\n }\n }\n\n private setAttributes(): void {\n if (this.configuration()?.attributes && this._componentRef) {\n for (const attributeName in this.configuration().attributes) {\n this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel) as string);\n }\n }\n }\n\n private evaluateExpression(value: unknown, $vm?: ModelSignal<unknown>, $event?: unknown): unknown {\n if (typeof(value) === 'string' && ((value.includes('$vm') && $vm() != null) || (value.includes('$event') && $event != null))) {\n return eval(value);\n } else {\n return value;\n }\n }\n\n\tngOnDestroy(): void {\n this._outputsSubscriptions?.forEach((s: Subscription): void => s.unsubscribe());\n this._formGroupSubscription?.unsubscribe();\n this._formControlDirective?.ngOnDestroy();\n this._componentRef?.destroy();\n\t}\n}\n","/*\n * Public API Surface of fg-dynamic-component\n */\n\nexport * from './lib/fg-dynamic.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Ae,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,UAAU,EAAE,IAAI;AAChB,iBAAA,CAAA;;;ACpCD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"fg-dynamic-component.mjs","sources":["../../../projects/fg-dynamic-component/src/lib/fg-dynamic.component.ts","../../../projects/fg-dynamic-component/src/public-api.ts","../../../projects/fg-dynamic-component/src/fg-dynamic-component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ComponentRef, ElementRef, EventEmitter, Injector, InputSignal, ModelSignal, OnChanges, OnDestroy, Renderer2, Signal, Type, ViewContainerRef, inject, input, model, viewChild, viewChildren } from '@angular/core';\nimport { ControlValueAccessor, FormControl, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, NgControl, ValidatorFn, Validators } from '@angular/forms';\nimport { Subscription } from 'rxjs';\n\nexport interface FGDynamicItem {\n type?: string | Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n inputs?: Record<string, string | unknown>;\n outputs?: Record<string, string | Function>;\n attributes?: Record<string, string | unknown>;\n items?: FGDynamicItem[];\n}\n\n/**\n * Declare components to dynamically load in static and/or dynamic way using the FGDynamicService.\n */\nexport class FGDynamicService {\n private static _components: Record<string, Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)> = {};\n\n static registerComponent(name: string, type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)): void {\n if (name && type) {\n FGDynamicService._components[name] = type;\n }\n }\n\n static getComponent(name: string): Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>) {\n return FGDynamicService._components[name];\n }\n}\n\n/**\n * Create a standalone signals based dynamic components tree through a JSON configuration with full\n * life-cycle support for inputs, outputs, attributes, reactive forms and expressions binding evaluation.\n */\n@Component({\n\tselector: 'fg-dynamic',\n\ttemplate: `\n <ng-container #viewContainer></ng-container>\n @for (item of configuration()?.items; track $index) {\n <fg-dynamic #dynamicItem [configuration]=\"item\" [(viewModel)]=\"viewModel\" [formGroup]=\"formGroup()\" />\n }\n `,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tstandalone: true\n})\nexport class FGDynamicComponent implements OnChanges, OnDestroy {\n\tconfiguration: InputSignal<FGDynamicItem> = input.required<FGDynamicItem>();\n\tviewModel: ModelSignal<unknown> = model<unknown>();\n\tformGroup: InputSignal<FormGroup> = input<FormGroup>();\n\n\tprivate _viewContainerRef: Signal<ViewContainerRef> = viewChild.required('viewContainer', {\n read: ViewContainerRef\n });\n private _dynamicItems: Signal<readonly ElementRef<unknown>[]> = viewChildren('dynamicItem', {\n read: ElementRef\n });\n\tprivate _componentRef: ComponentRef<unknown>;\n private _elementRef: ElementRef<HTMLElement> = inject(ElementRef);\n private _renderer: Renderer2 = inject(Renderer2);\n private _outputsSubscriptions: Subscription[] = [];\n private _formControl: FormControl;\n private _formControlDirective: FormControlDirective;\n private _formControlSubscription: Subscription;\n private _component: Type<unknown>;\n private _injector: Injector = inject(Injector);\n\n /**\n * A callback method that is invoked immediately after the default change\n * detector has checked data-bound properties if at least one has changed,\n * and before the view and content children are checked.\n */\n async ngOnChanges(): Promise<void> {\n // Lazy-load a component.\n await this.loadComponentAsync();\n // Instantiates a single component and inserts its host view into this container.\n this.createComponent();\n // Remove the fg-dynamic tag.\n this.removeHostElement();\n // Updates specified input names to new values.\n this.setInputs();\n // Disables/enables the control.\n this.setFormControlStatus();\n // Add synchronous validators to this control.\n this.setFormControlValidators();\n // Set attribute values for an element in the DOM.\n this.setAttributes();\n }\n\n /**\n * A method to lazy-load a component.\n */\n private async loadComponentAsync(): Promise<void> {\n if (this.configuration().type != null && !this._component) {\n let type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n\n if (typeof(this.configuration().type) === 'string') {\n type = FGDynamicService.getComponent(this.configuration().type as string);\n } else {\n type = this.configuration().type as Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n }\n\n try {\n type = (type as () => Promise<Type<unknown>>)();\n } catch {\n type = type;\n } finally {\n if (type instanceof Promise) {\n this._component = await type;\n } else {\n this._component = type as Type<unknown>;\n }\n }\n }\n }\n\n /**\n * Instantiates a single component and inserts its host view into this container.\n */\n private createComponent(): void {\n if (this._component && !this._componentRef && this._viewContainerRef() && !this._formControlDirective) {\n let injector: Injector;\n\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof(this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel()) {\n // Synchronizes a standalone FormControl instance to a form control element.\n this._formControlDirective = new FormControlDirective(null, null, null, null);\n\n // Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.\n injector = Injector.create({\n providers: [{\n provide: NgControl,\n useValue: this._formControlDirective\n }],\n parent: this._injector\n });\n }\n\n // Instantiates a single component and inserts its host view into this container.\n this._componentRef = this._viewContainerRef().createComponent(this._component, {\n projectableNodes: this._dynamicItems()?.length > 0 ? [this._dynamicItems().map((e: ElementRef<unknown>): Node => e.nativeElement as Node)] : undefined,\n injector: injector\n });\n\n // When a view uses the ChangeDetectionStrategy#OnPush (checkOnce) change detection strategy, explicitly marks the view as changed so that it can be checked again.\n // Components are normally marked as dirty (in need of rerendering) when inputs have changed or events have fired in the view.\n // Call this method to ensure that a component is checked even if these triggers have not occurred.\n if (this._componentRef?.changeDetectorRef) {\n this._componentRef.changeDetectorRef.markForCheck();\n }\n\n // Register handlers for those events by subscribing to an instance.\n this.handleOutputs();\n // Construct a FormControl with an initial value.\n this.createFormControl();\n }\n }\n\n /**\n * A method to remove the fg-dynamic tag.\n */\n private removeHostElement(): void {\n if (this._elementRef?.nativeElement?.parentElement) {\n const nativeElement: HTMLElement = this._elementRef.nativeElement;\n const parentElement: HTMLElement = nativeElement.parentElement;\n\n // Move all children out of the element\n while (nativeElement.firstChild) {\n parentElement.insertBefore(nativeElement.firstChild, nativeElement);\n }\n\n // Remove the empty element (the host)\n parentElement.removeChild(nativeElement);\n }\n }\n\n /**\n * Register handlers for those events by subscribing to an instance.\n */\n private handleOutputs(): void {\n if (this.configuration()?.outputs && Object.keys(this.configuration().outputs).length > 0 && this._componentRef?.instance) {\n for (const outputName in this.configuration().outputs) {\n if (this._componentRef.instance[outputName] instanceof EventEmitter) {\n this._outputsSubscriptions.push(this._componentRef.instance[outputName].subscribe(($event: unknown): void => {\n // Evaluates JavaScript code and executes it.\n const result: unknown = this.evaluateExpression(this.configuration().outputs[outputName], this.viewModel, $event);\n\n if (result instanceof Function) {\n // Executes a function.\n result($event);\n }\n }));\n }\n }\n }\n }\n\n /**\n * Construct a FormControl with an initial value.\n */\n private createFormControl(): void {\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel()) {\n // Evaluates JavaScript code and executes it.\n const name = this.evaluateExpression(this.configuration().attributes['name'], this.viewModel) as string;\n\n if (typeof(name) === 'string') {\n // Construct a FormControl with an initial value.\n this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), name, null));\n\n // Add a control to this group. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).\n // If a control with a given name already exists, it would not be replaced with a new one.\n // If you want to replace an existing control, use the FormGroup#setControl setControl method instead.\n // This method also updates the value and validity of the control.\n this.formGroup().addControl(name, this._formControl);\n\n // A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically.\n this._formControlSubscription = this._formControl.valueChanges.subscribe((value: unknown): void => {\n // Creates a deep clone of an object.\n const viewModel: unknown = structuredClone(this.viewModel());\n\n // Sets the value at path of object.\n // If a portion of path doesn't exist, it's created.\n // Arrays are created for missing index properties while objects are created for all other missing properties.\n // This method mutates object.\n this.setModelPropertyValue(viewModel, name, value);\n // Directly set the signal to a new value, and notify any dependents.\n this.viewModel.set(viewModel);\n });\n\n // Synchronizes a standalone FormControl instance to a form control element.\n this.attachFormControlDirective();\n }\n }\n }\n\n /**\n * Disables/enables the control.\n */\n private setFormControlStatus(): void {\n if (this._formControl && this.configuration().attributes && this.configuration().attributes['disabled'] != null) {\n // Evaluates JavaScript code and executes it.\n const isDisabled: boolean = this.evaluateExpression(this.configuration().attributes['disabled'], this.viewModel) as boolean;\n\n if (typeof(isDisabled) === 'boolean' && ((isDisabled && this._formControl.enabled) || (!isDisabled && this._formControl.disabled))) {\n if (isDisabled) {\n // Disables the control.\n this._formControl.disable({\n onlySelf: true,\n emitEvent: false\n });\n } else {\n // Enables the control.\n this._formControl.enable({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n }\n\n /**\n * Add synchronous validators to this control.\n */\n private setFormControlValidators(): void {\n if (this._formControl && this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n const validators: ValidatorFn[] = [];\n // Validator that requires the control's value to be greater than or equal to the provided number.\n const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel) as number;\n\n if (typeof(min) === 'number' && min.toString() !== this._componentRef.location.nativeElement.getAttribute('min')) {\n validators.push(Validators.min(min));\n }\n\n // Validator that requires the control's value to be less than or equal to the provided number.\n const max = this.evaluateExpression(this.configuration().attributes['max'], this.viewModel) as number;\n\n if (typeof(max) === 'number' && max.toString() !== this._componentRef.location.nativeElement.getAttribute('max')) {\n validators.push(Validators.max(max));\n }\n\n // Validator that requires the control have a non-empty value.\n const required = this.evaluateExpression(this.configuration().attributes['required'], this.viewModel) as boolean;\n\n if (required === true && required.toString() !== this._componentRef.location.nativeElement.getAttribute('required')) {\n validators.push(Validators.required);\n }\n\n // Validator that requires the control's value pass an email validation test.\n const email = this.evaluateExpression(this.configuration().attributes['email'], this.viewModel) as boolean;\n\n if (email === true && email.toString() !== this._componentRef.location.nativeElement.getAttribute('email')) {\n validators.push(Validators.email);\n }\n\n // Validator that requires the length of the control's value to be less than or equal to the provided maximum length.\n const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel) as number;\n\n if (maxLength > 0 && maxLength.toString() !== this._componentRef.location.nativeElement.getAttribute('maxlength')) {\n validators.push(Validators.maxLength(maxLength));\n }\n\n // Validator that requires the length of the control's value to be greater than or equal to the provided minimum length.\n const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel) as number;\n\n if (minLength > 0 && minLength.toString() !== this._componentRef.location.nativeElement.getAttribute('minlength')) {\n validators.push(Validators.minLength(minLength));\n }\n\n // Validator that requires the control's value to match a regex pattern.\n const pattern = this.evaluateExpression(this.configuration().attributes['pattern'], this.viewModel) as string;\n\n if (typeof(pattern) === 'string' && pattern !== this._componentRef.location.nativeElement.getAttribute('pattern')) {\n validators.push(Validators.pattern(pattern));\n }\n\n if (validators.length > 0) {\n // Empties out the synchronous validator list.\n this._formControl.clearValidators();\n // Add a synchronous validator or validators to this control, without affecting other validators.\n this._formControl.addValidators(validators);\n // Recalculates the value and validation status of the control.\n this._formControl.updateValueAndValidity({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n\n /**\n * Synchronizes a standalone FormControl instance to a form control element.\n */\n private attachFormControlDirective(): void {\n if (this._formControlDirective && this._componentRef?.injector && this._formControl) {\n this._formControlDirective.valueAccessor = this._componentRef.injector.get<ControlValueAccessor[]>(NG_VALUE_ACCESSOR, null)?.find((_: ControlValueAccessor): true => true);\n this._formControlDirective.form = this._formControl;\n\n // 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.\n this._formControlDirective.ngOnChanges({\n form: {\n firstChange: true,\n currentValue: this._formControl,\n previousValue: undefined,\n isFirstChange: (): true => true\n }\n });\n }\n }\n\n /**\n * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.\n * @param model The object.\n * @param property The path.\n * @param defaultValue The resolved value.\n */\n private getModelPropertyValue(model: unknown, property: Array<string> | string, defaultValue: unknown): unknown {\n // If path is not defined or it has false value\n if (!property) {\n return undefined\n }\n\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n // Find value\n const result: unknown = pathArray.reduce((prevObj: unknown, key: string): unknown => prevObj && prevObj[key], model);\n\n // If found value is undefined return default value; otherwise return the value\n return result != null ? result : defaultValue\n }\n\n /**\n * Sets the value at path of object. If a portion of path doesn't exist, it's created.\n * Arrays are created for missing index properties while objects are created for all other missing properties.\n * This method mutates object.\n * @param model The object.\n * @param property The path.\n * @param value The value.\n */\n private setModelPropertyValue(model: unknown, property: Array<string> | string, value: unknown): void {\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n\n pathArray.reduce((acc: unknown, key: string, i: number): unknown => {\n if (acc[key] === undefined) {\n acc[key] = {};\n }\n\n if (i === pathArray.length - 1) {\n acc[key] = value;\n }\n\n return acc[key]\n }, model);\n }\n\n /**\n * Updates specified input names to new values.\n */\n private setInputs(): void {\n if (this.configuration()?.inputs && Object.keys(this.configuration().inputs).length > 0 && this._componentRef) {\n for (const inputName in this.configuration().inputs) {\n // Updates a specified input name to a new value.\n // Using this method will properly mark for check component using the OnPush change detection strategy.\n // It will also assure that the OnChanges lifecycle hook runs when a dynamically created component is change-detected.\n this._componentRef.setInput(inputName, this.evaluateExpression(this.configuration().inputs[inputName], this.viewModel));\n }\n }\n }\n\n /**\n * Set attribute values for an element in the DOM.\n */\n private setAttributes(): void {\n if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n for (const attributeName in this.configuration().attributes) {\n // Evaluates JavaScript code and executes it.\n const value = this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel) as string;\n\n // Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.\n if (value !== this._componentRef.location.nativeElement.getAttribute(attributeName)) {\n // Implement this callback to set an attribute value for an element in the DOM.\n this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, value);\n }\n }\n }\n }\n\n /**\n * Evaluates JavaScript code and executes it.\n * @param value The JavaScript code.\n * @param $vm The view model.\n * @param $event The event.\n * @returns Evaluated expression.\n */\n private evaluateExpression(value: unknown, $vm?: ModelSignal<unknown>, $event?: unknown): unknown {\n if (typeof(value) === 'string' && ((value.includes('$vm') && $vm != null && $vm() != null) || (value.includes('$event') && $event != null))) {\n // Evaluates JavaScript code and executes it.\n return eval(value);\n } else {\n return value;\n }\n }\n\n /**\n * A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n */\n\tngOnDestroy(): void {\n // Performs the specified action for each element in an array (Disposes the resources held by the subscription).\n this._outputsSubscriptions?.forEach((s: Subscription): void => s.unsubscribe());\n // Disposes the resources held by the subscription.\n // May, for instance, cancel an ongoing Observable execution or cancel any other type of work that started when the Subscription was created.\n this._formControlSubscription?.unsubscribe();\n // A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n this._formControlDirective?.ngOnDestroy();\n // Destroys the component instance and all of the data structures associated with it.\n this._componentRef?.destroy();\n\t}\n}\n","/*\n * Public API Surface of fg-dynamic-component\n */\n\nexport * from './lib/fg-dynamic.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAYA;;AAEG;MACU,gBAAgB,CAAA;aACV,IAAW,CAAA,WAAA,GAA4F,EAAE,CAAC,EAAA;AAEzH,IAAA,OAAO,iBAAiB,CAAC,IAAY,EAAE,IAA6E,EAAA;AAChH,QAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AACd,YAAA,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;SAC7C;KACJ;IAED,OAAO,YAAY,CAAC,IAAY,EAAA;AAC5B,QAAA,OAAO,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KAC7C;;AAGL;;;AAGG;MAYU,kBAAkB,CAAA;AAX/B,IAAA,WAAA,GAAA;AAYC,QAAA,IAAA,CAAA,aAAa,GAA+B,KAAK,CAAC,QAAQ,EAAiB,CAAC;QAC5E,IAAS,CAAA,SAAA,GAAyB,KAAK,EAAW,CAAC;QACnD,IAAS,CAAA,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