@bcweed/dynamic-form-lib 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +19 -15
  2. package/fesm2022/bcweed-dynamic-form-lib.mjs +938 -0
  3. package/fesm2022/bcweed-dynamic-form-lib.mjs.map +1 -0
  4. package/index.d.ts +254 -0
  5. package/package.json +37 -65
  6. package/.editorconfig +0 -17
  7. package/.postcssrc.json +0 -5
  8. package/.vscode/extensions.json +0 -4
  9. package/.vscode/launch.json +0 -20
  10. package/.vscode/tasks.json +0 -42
  11. package/AngularDynamicFormLibrary.esproj +0 -13
  12. package/CHANGELOG.md +0 -16
  13. package/angular.json +0 -169
  14. package/aspnetcore-https.js +0 -37
  15. package/karma.conf.js +0 -44
  16. package/obj/Debug/AngularDynamicFormLibrary.esproj.CoreCompileInputs.cache +0 -0
  17. package/obj/Debug/AngularDynamicFormLibrary.esproj.FileListAbsolute.txt +0 -1
  18. package/obj/Debug/package.g.props +0 -56
  19. package/postcss.config.js +0 -6
  20. package/projects/dynamic-form-lib/.postcssrc.json +0 -5
  21. package/projects/dynamic-form-lib/README.md +0 -63
  22. package/projects/dynamic-form-lib/ng-package.json +0 -10
  23. package/projects/dynamic-form-lib/package.json +0 -27
  24. package/projects/dynamic-form-lib/src/lib/README.md +0 -424
  25. package/projects/dynamic-form-lib/src/lib/SUMMARY.md +0 -159
  26. package/projects/dynamic-form-lib/src/lib/directives/dynamic-ref-directive.ts +0 -13
  27. package/projects/dynamic-form-lib/src/lib/dynamic-form-demo/dynamic-form-demo.component.html +0 -75
  28. package/projects/dynamic-form-lib/src/lib/dynamic-form-demo/dynamic-form-demo.component.scss +0 -127
  29. package/projects/dynamic-form-lib/src/lib/dynamic-form-demo/dynamic-form-demo.component.ts +0 -50
  30. package/projects/dynamic-form-lib/src/lib/dynamic-form-field/dynamic-form-field.component.html +0 -234
  31. package/projects/dynamic-form-lib/src/lib/dynamic-form-field/dynamic-form-field.component.scss +0 -315
  32. package/projects/dynamic-form-lib/src/lib/dynamic-form-field/dynamic-form-field.component.ts +0 -219
  33. package/projects/dynamic-form-lib/src/lib/dynamic-form.component.html +0 -137
  34. package/projects/dynamic-form-lib/src/lib/dynamic-form.component.scss +0 -141
  35. package/projects/dynamic-form-lib/src/lib/dynamic-form.component.ts +0 -366
  36. package/projects/dynamic-form-lib/src/lib/helpers/component-helper.ts +0 -54
  37. package/projects/dynamic-form-lib/src/lib/index.ts +0 -10
  38. package/projects/dynamic-form-lib/src/lib/models/dynamic-form-interfaces.ts +0 -117
  39. package/projects/dynamic-form-lib/src/lib/services/dynamic-form.service.spec.ts +0 -302
  40. package/projects/dynamic-form-lib/src/lib/services/dynamic-form.service.ts +0 -325
  41. package/projects/dynamic-form-lib/src/lib/style.scss +0 -3
  42. package/projects/dynamic-form-lib/src/lib/tailwind-output.css +0 -0
  43. package/projects/dynamic-form-lib/src/lib/validators/compare-validator.ts +0 -26
  44. package/projects/dynamic-form-lib/src/public-api.css +0 -1
  45. package/projects/dynamic-form-lib/src/public-api.ts +0 -10
  46. package/projects/dynamic-form-lib/tailwind.config.js +0 -10
  47. package/projects/dynamic-form-lib/tsconfig.lib.json +0 -15
  48. package/projects/dynamic-form-lib/tsconfig.lib.prod.json +0 -11
  49. package/projects/dynamic-form-lib/tsconfig.spec.json +0 -15
  50. package/public/favicon.ico +0 -0
  51. package/src/app/app-routing.module.ts +0 -10
  52. package/src/app/app.component.css +0 -0
  53. package/src/app/app.component.html +0 -18
  54. package/src/app/app.component.spec.ts +0 -35
  55. package/src/app/app.component.ts +0 -1038
  56. package/src/app/app.config.ts +0 -45
  57. package/src/app/app.module.ts +0 -46
  58. package/src/app/app.routes.ts +0 -8
  59. package/src/index.html +0 -13
  60. package/src/main.ts +0 -16
  61. package/src/styles.css +0 -2
  62. package/tailwind.config.js +0 -10
  63. package/tsconfig.app.json +0 -15
  64. package/tsconfig.json +0 -32
  65. package/tsconfig.spec.json +0 -15
  66. /package/{projects/dynamic-form-lib/src → src}/lib/style.css +0 -0
@@ -0,0 +1,938 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Input, Directive, ViewChild, Component, Injectable, inject, EventEmitter, ViewChildren, Output } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i3 from '@angular/forms';
6
+ import { ReactiveFormsModule, Validators, FormBuilder } from '@angular/forms';
7
+ import { Subject } from 'rxjs';
8
+ import { takeUntil } from 'rxjs/operators';
9
+ import * as i4 from 'primeng/inputtext';
10
+ import { InputTextModule } from 'primeng/inputtext';
11
+ import * as i5 from 'primeng/textarea';
12
+ import { TextareaModule } from 'primeng/textarea';
13
+ import * as i6 from 'primeng/inputnumber';
14
+ import { InputNumberModule } from 'primeng/inputnumber';
15
+ import * as i7 from 'primeng/checkbox';
16
+ import { CheckboxModule } from 'primeng/checkbox';
17
+ import * as i8 from 'primeng/radiobutton';
18
+ import { RadioButtonModule, RadioButton } from 'primeng/radiobutton';
19
+ import * as i9 from 'primeng/select';
20
+ import { SelectModule } from 'primeng/select';
21
+ import * as i10 from 'primeng/datepicker';
22
+ import { DatePickerModule } from 'primeng/datepicker';
23
+ import * as i11 from 'primeng/message';
24
+ import { MessageModule } from 'primeng/message';
25
+ import * as i12 from 'primeng/tooltip';
26
+ import { TooltipModule } from 'primeng/tooltip';
27
+ import * as i13 from 'primeng/scrollpanel';
28
+ import { ScrollPanelModule } from 'primeng/scrollpanel';
29
+ import * as i14 from 'primeng/popover';
30
+ import { PopoverModule } from 'primeng/popover';
31
+ import * as i15 from 'primeng/drawer';
32
+ import { DrawerModule } from 'primeng/drawer';
33
+ import * as i16 from 'primeng/inputmask';
34
+ import { InputMaskModule } from 'primeng/inputmask';
35
+ import * as i1 from '@angular/cdk/layout';
36
+ import { Breakpoints } from '@angular/cdk/layout';
37
+ import * as i4$1 from 'primeng/button';
38
+ import { ButtonModule } from 'primeng/button';
39
+
40
+ class DynamicRefDirective {
41
+ el;
42
+ refKey;
43
+ constructor(el) {
44
+ this.el = el;
45
+ const t = this.refKey;
46
+ }
47
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicRefDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
48
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.18", type: DynamicRefDirective, isStandalone: true, selector: "[dynamicRef]", inputs: { refKey: "refKey" }, ngImport: i0 });
49
+ }
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicRefDirective, decorators: [{
51
+ type: Directive,
52
+ args: [{
53
+ selector: '[dynamicRef]',
54
+ standalone: true
55
+ }]
56
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { refKey: [{
57
+ type: Input
58
+ }] } });
59
+
60
+ class DynamicFormFieldComponent {
61
+ responsive;
62
+ field;
63
+ form;
64
+ errors = [];
65
+ allowHelpOverlay = false;
66
+ allowHelpSideBar = false;
67
+ ref;
68
+ elementRef = null;
69
+ radioButton;
70
+ helpSideBarVisible = false;
71
+ shouldDisable = true;
72
+ isExpanded = false;
73
+ isSmallMedia = false;
74
+ isMediumMedia = false;
75
+ constructor(responsive) {
76
+ this.responsive = responsive;
77
+ }
78
+ ngOnInit() {
79
+ this.responsive.observe([Breakpoints.Medium, Breakpoints.Small, Breakpoints.XSmall])
80
+ .subscribe(result => {
81
+ if (result.matches) {
82
+ this.isSmallMedia = true;
83
+ }
84
+ else {
85
+ this.isSmallMedia = false;
86
+ }
87
+ });
88
+ if (!this.field || !this.form) {
89
+ console.error('DynamicFormFieldComponent requires field and form inputs');
90
+ }
91
+ }
92
+ ngAfterViewInit() {
93
+ if (this.radioButton) {
94
+ this.elementRef = this.radioButton.inputViewChild;
95
+ }
96
+ if (this.ref) {
97
+ this.elementRef = this.ref.el;
98
+ }
99
+ if ((this.field.conditionalDisabled && this.field.conditionalDisabled()) || this.field.disabled) {
100
+ this.form.controls[this.field.id].disable();
101
+ }
102
+ }
103
+ get isValid() {
104
+ const control = this.form.get(this.field.id);
105
+ return control ? control.valid : true;
106
+ }
107
+ get isTouched() {
108
+ const control = this.form.get(this.field.id);
109
+ return control ? control.touched : false;
110
+ }
111
+ get isDirty() {
112
+ const control = this.form.get(this.field.id);
113
+ return control ? control.dirty : false;
114
+ }
115
+ get showError() {
116
+ return !this.isValid && (this.isTouched || this.isDirty);
117
+ }
118
+ get fieldClasses() {
119
+ const classes = ['form-group'];
120
+ if (this.showError) {
121
+ if (!this.field.disabled) {
122
+ classes.push('field-error');
123
+ }
124
+ }
125
+ else if (this.isValid && (this.isTouched || this.isDirty)) {
126
+ classes.push('field-valid');
127
+ }
128
+ if (this.field.disabled) {
129
+ classes.push('field-disabled');
130
+ }
131
+ if (this.field.required) {
132
+ classes.push('field-required');
133
+ }
134
+ return classes.join(' ');
135
+ }
136
+ get successIndicatorClass() {
137
+ if (this.field.type == 'select') {
138
+ return "valid-indicator-select";
139
+ }
140
+ else if (this.field.type == 'date') {
141
+ return "valid-indicator-calendar";
142
+ }
143
+ else {
144
+ return "valid-indicator";
145
+ }
146
+ }
147
+ get controlName() {
148
+ return this.field.id;
149
+ }
150
+ focusOn() {
151
+ if (this.elementRef) {
152
+ this.elementRef.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
153
+ this.elementRef.nativeElement.focus();
154
+ }
155
+ }
156
+ onBlur() {
157
+ const control = this.form.get(this.field.id);
158
+ if (control) {
159
+ control.markAsTouched();
160
+ }
161
+ }
162
+ displayRadioError(option) {
163
+ if (option.displayError && typeof option.displayError === 'function') {
164
+ return option.displayError();
165
+ }
166
+ return false;
167
+ }
168
+ onClick(event) {
169
+ if (typeof this.field.onClick === 'function') {
170
+ this.field.onClick(event.target.value, this.form);
171
+ }
172
+ }
173
+ labelWidthStyle() {
174
+ return this.isSmallMedia ? '100%' : this.field.labelWidth ? this.field.labelWidth : '100%';
175
+ }
176
+ fieldWidthStyle() {
177
+ return this.isSmallMedia ? '100%' : this.field.fieldWidth ? this.field.fieldWidth : '100%';
178
+ }
179
+ inputWidthStyle() {
180
+ return this.isSmallMedia ? '100%' : this.field.inputWidth ? this.field.inputWidth : '100%';
181
+ }
182
+ trackByFn(index, item) {
183
+ return item.value;
184
+ }
185
+ get getMinValue() {
186
+ if (this.field.type === 'number' && this.field.min !== undefined) {
187
+ return this.field.min;
188
+ }
189
+ return null;
190
+ }
191
+ get getMaxValue() {
192
+ if (this.field.type === 'number' && this.field.max !== undefined) {
193
+ return this.field.max;
194
+ }
195
+ return null;
196
+ }
197
+ get getDecimalPlace() {
198
+ if (this.field.type === 'number' && this.field.decimals !== undefined) {
199
+ return this.field.decimals;
200
+ }
201
+ return 0;
202
+ }
203
+ isFieldDisabled() {
204
+ const t = (this.field.conditionalDisabled && this.field.conditionalDisabled()) ? '' : null;
205
+ return t;
206
+ }
207
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormFieldComponent, deps: [{ token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
208
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: DynamicFormFieldComponent, isStandalone: true, selector: "app-dynamic-form-field", inputs: { field: "field", form: "form", errors: "errors", allowHelpOverlay: "allowHelpOverlay", allowHelpSideBar: "allowHelpSideBar" }, viewQueries: [{ propertyName: "ref", first: true, predicate: DynamicRefDirective, descendants: true }, { propertyName: "radioButton", first: true, predicate: RadioButton, descendants: true }], ngImport: i0, template: "\r\n<div [ngClass]=\"fieldClasses\" [formGroup]=\"form\">\r\n <div [ngStyle]=\"{ width: fieldWidthStyle(), position: 'relative' }\">\r\n <!-- Label -->\r\n <div *ngIf=\"field.leftPreInput\" class=\"left-pre-input\">\r\n <span [innerHTML]=\"field.leftPreInput\" class=\"left-pre-input-text\">\r\n </span>\r\n\r\n </div>\r\n <div #field_container class=\"input-container\">\r\n <div class=\"label-row\" [ngStyle]=\"{ width: labelWidthStyle() }\">\r\n <label [attr.for]=\"field.id\" class=\"control-label\">\r\n {{ field.label }}\r\n <span *ngIf=\"field.required\" class=\"required-indicator\">*</span>\r\n </label>\r\n <div class=\"help-icons\">\r\n <i (click)=\"helpSideBarVisible = true\" class=\"pi pi-question-circle\" *ngIf=\"allowHelpSideBar && field.popInfo\"></i>\r\n <i (click)=\"popover.toggle($event)\" class=\"pi pi-question-circle\" *ngIf=\"allowHelpOverlay && field.popInfo\"></i>\r\n </div>\r\n </div>\r\n <!-- Text Input -->\r\n <input *ngIf=\"field.type === 'text'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n class=\"form-control\"\r\n type=\"text\"\r\n pInputText\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\" />\r\n <!-- Email Input -->\r\n <input *ngIf=\"field.type === 'email'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n class=\"form-control\"\r\n type=\"email\"\r\n pInputText\r\n pTooltip=\"{{field.toolTip}}\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\" />\r\n <!-- Number Input -->\r\n <p-inputNumber *ngIf=\"field.type === 'number'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [inputId]=\"field.id\"\r\n [useGrouping]=\"false\"\r\n [minFractionDigits]=\"getDecimalPlace\"\r\n [min]=\"getMinValue\"\r\n [max]=\"getMaxValue\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n styleClass=\"form-control\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-inputNumber>\r\n\r\n\r\n <!-- phone -->\r\n\r\n <p-inputMask *ngIf=\"field.type === 'phone'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n mask=\"(999) 999-9999\"\r\n unmask=\"true\"\r\n styleClass=\"form-control-phone\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-inputMask>\r\n <!-- Textarea -->\r\n <textarea *ngIf=\"field.type === 'textarea'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n [rows]=\"5\"\r\n class=\"form-control\"\r\n pInputTextarea\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></textarea>\r\n\r\n <!-- Date Picker -->\r\n <p-datepicker *ngIf=\"field.type === 'date'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [inputId]=\"field.id\"\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n styleClass=\"form-control-datepicker\"\r\n dateFormat=\"DD MM yy\"\r\n [showIcon]=\"true\"\r\n [style]=\"{ width: inputWidthStyle() }\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-datepicker>\r\n\r\n <!-- Select Dropdown -->\r\n <p-select *ngIf=\"field.type === 'select'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [inputId]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [id]=\"field.id\"\r\n appendTo=\"body\"\r\n [options]=\"field.options || []\"\r\n [placeholder]=\"field.placeholder || 'Select an option'\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n styleClass=\"form-control-select\"\r\n [showClear]=\"!field.required\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-select>\r\n\r\n <!-- Checkbox -->\r\n <div *ngIf=\"field.type === 'checkbox'\" class=\"checkbox-wrapper\">\r\n <p-checkbox [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [inputId]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [style]=\"{ width: inputWidthStyle() }\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n [binary]=\"true\"\r\n tooltipPosition=\"right\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-checkbox>\r\n </div>\r\n\r\n <!-- Radio Buttons -->\r\n <div *ngIf=\"field.type === 'radio'\" class=\"radio-group\">\r\n <div *ngFor=\"let option of field.options; trackBy: trackByFn; let first = first\"\r\n class=\"radio-option\" tooltipPosition=\"right\" pTooltip=\"{{option.toolTip}}\">\r\n\r\n <p-radioButton *ngIf=\"first\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [inputId]=\"field.id + '_' + option.value\"\r\n [id]=\"field.id + '_' + option.value\"\r\n [name]=\"field.id\"\r\n [value]=\"option.value\"\r\n [formControlName]=\"controlName\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event.originalEvent)\"></p-radioButton>\r\n <p-radioButton *ngIf=\"!first\"\r\n [inputId]=\"field.id + '_' + option.value\"\r\n [id]=\"field.id + '_' + option.value\"\r\n [name]=\"field.id\"\r\n [value]=\"option.value\"\r\n [formControlName]=\"controlName\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event.originalEvent)\"></p-radioButton>\r\n <label [for]=\"field.id + '_' + option.value\" class=\"radio-label\">\r\n {{ option.label }}\r\n </label>\r\n <div *ngIf=\"option.helpInfo\" class=\"radio-message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"option.helpInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"option.errorInfo && displayRadioError(option)\" class=\"radio-message-container\">\r\n <p-message severity=\"error\">\r\n <div [innerHTML]=\"option.errorInfo\"></div>\r\n </p-message>\r\n </div>\r\n <small class=\"radion-hint\" *ngIf=\"option.hint\" id=\"field.id + '_' + option.value + '-help'\">{{option.hint}}</small>\r\n\r\n\r\n </div>\r\n </div>\r\n <small class=\"field-hint\" *ngIf=\"field.hint\" id=\"field.id + '-help'\">{{field.hint}}</small>\r\n </div>\r\n <!-- Error Messages -->\r\n <div *ngIf=\"showError\" class=\"error-messages\">\r\n <p-message *ngFor=\"let error of errors\"\r\n severity=\"error\"\r\n [text]=\"error\"></p-message>\r\n </div>\r\n\r\n <div *ngIf=\"field.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"field.postInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"field.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"field.postWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <!-- Valid Indicator (optional) -->\r\n <div *ngIf=\"isValid && isTouched && field.required\" [ngClass]=\"successIndicatorClass\">\r\n <i class=\"pi pi-check-circle\"></i>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<p-popover appendTo=\"body\" styleClass=\"form-pop-info\" #popover>\r\n <h4>{{field.label}}</h4>\r\n <div [innerHTML]=\"field.popInfo\"></div>\r\n</p-popover>\r\n@if (allowHelpSideBar && field.popInfo) {\r\n <p-drawer header=\"{{field.label}}\" autoZIndex=\"false\" baseZIndex=\"10000\" [ngStyle]=\"{'z-index': '10000', 'top': '65px'}\" position=\"right\" styleClass=\"form-pop-info\" appendTo=\"body\" [(visible)]=\"helpSideBarVisible\">\r\n <p-scrollPanel [ngStyle]=\"{height: '100%'}\">\r\n <div [innerHTML]=\"field.popInfo\"></div>\r\n </p-scrollPanel>\r\n </p-drawer>\r\n}\r\n", styles: [".p-overlay-mask,.p-drawer .p-drawer.form-pop-info{z-index:10000!important}.p-drawer-right,.p-drawer.form-pop-info.p-drawer-right{top:65px}p-message .p-message.light-font .p-message-text{font-weight:400}.form-group{margin-bottom:1rem;position:relative;transition:all .3s ease;display:flex;flex-wrap:wrap;gap:.75rem}.form-group .left-pre-input{display:flex;flex-direction:column;justify-content:flex-end;align-items:flex-end;flex-basis:40%;flex-shrink:0;flex-grow:0}.form-group .left-pre-input .left-pre-input-text{text-align:right;width:100%;margin-bottom:10px;font-weight:600}.form-group .input-container{flex-grow:1;flex-shrink:1;min-width:0}.form-group .label-row{display:flex;justify-content:space-between;align-items:start;margin-bottom:.5rem}.form-group .help-icons{display:flex;gap:.5rem;margin-left:.5rem}.form-group .help-icons i{cursor:pointer;color:#6c757d;transition:color .2s ease}.form-group .help-icons i:hover{color:#007bff}.form-group .control-label{display:block;font-weight:500;color:#333}.form-group .control-label .required-indicator{color:#dc3545;margin-left:.25rem}.form-group .form-control{width:100%;transition:border-color .3s ease,box-shadow .3s ease}.form-group .field-hint{display:block;margin-top:.25rem;font-size:.875rem;color:#6c757d}.form-group .checkbox-wrapper{padding:.5rem 0}.form-group .radio-group{display:flex;flex-direction:column;gap:.75rem}.form-group .radio-group .radio-option{display:flex;align-items:center;flex-wrap:wrap}.form-group .radio-group .radio-option .radio-label{margin:0;cursor:pointer;font-weight:400}.form-group .radio-group .radio-option .radion-hint{flex-basis:100%;width:100%;display:block;margin-left:36px;font-size:.875rem;color:#6c757d}.form-group .radio-group .radio-option .radio-message-container{flex-basis:100%;width:100%;margin-top:.25rem;margin-left:36px}.form-group .error-messages{margin-top:.5rem;flex-basis:100%;width:100%;animation:slideDown .3s ease}.form-group .error-messages ::ng-deep .p-message{margin-bottom:.25rem}.form-group .error-messages ::ng-deep .p-message:last-child{margin-bottom:0}.form-group .valid-indicator,.form-group .valid-indicator-select,.form-group .valid-indicator-calendar{position:absolute;color:#28a745;font-size:1.2rem;animation:fadeIn .3s ease}.form-group .valid-indicator i,.form-group .valid-indicator-select i,.form-group .valid-indicator-calendar i{display:block}.form-group .valid-indicator{right:10px;top:38px}.form-group .valid-indicator-select,.form-group .valid-indicator-calendar{right:80px;top:38px}.form-group .p-select,.form-group ::ng-deep .p-datepicker,.form-group .p-inputnumber{padding:0}.form-group .p-datepicker>span>input,.form-group .p-inputnumber{border:none!important}.form-group.field-error .form-control,.form-group.field-error ::ng-deep .p-inputtext,.form-group.field-error ::ng-deep .p-select,.form-group.field-error ::ng-deep .p-datepicker,.form-group.field-error ::ng-deep .p-inputnumber input{border-color:#dc3545!important}.form-group.field-error .form-control:focus,.form-group.field-error ::ng-deep .p-inputtext:focus,.form-group.field-error ::ng-deep .p-select:focus,.form-group.field-error ::ng-deep .p-datepicker:focus,.form-group.field-error ::ng-deep .p-inputnumber input:focus{box-shadow:0 0 0 .2rem #dc354540}.form-group.field-error .p-datepicker>span>input{border:none!important}.form-group.field-error .control-label{color:#dc3545}.form-group.field-valid .form-control,.form-group.field-valid ::ng-deep .p-inputtext,.form-group.field-valid ::ng-deep .p-select,.form-group.field-valid ::ng-deep .p-datepicker,.form-group.field-valid ::ng-deep .p-inputnumber input{border-color:#28a745}.form-group.field-valid .form-control:focus,.form-group.field-valid ::ng-deep .p-inputtext:focus,.form-group.field-valid ::ng-deep .p-select:focus,.form-group.field-valid ::ng-deep .p-datepicker:focus,.form-group.field-valid ::ng-deep .p-inputnumber input:focus{box-shadow:0 0 0 .2rem #28a74540}.form-group.field-valid .p-datepicker>span>input{border:none!important}.form-group.field-disabled{opacity:.6;pointer-events:none}.form-group.field-disabled .control-label{color:#6c757d}.form-group.field-error{padding:12px;border:1px solid #dc3545;background-color:var(--p-red-100);box-shadow:0 0 10px #00000080;border-radius:10px}@keyframes slideDown{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}::ng-deep .p-inputtext,::ng-deep .p-select,::ng-deep .p-datepicker .p-inputtext,::ng-deep .p-inputnumber-input{width:100%}::ng-deep .p-select{display:flex}::ng-deep .p-datepicker{width:100%}::ng-deep .p-datepicker .p-inputtext{width:100%}::ng-deep .p-inputnumber{width:100%}::ng-deep .p-checkbox{margin-right:.5rem}::ng-deep .p-radiobutton{margin-right:.5rem}@media (max-width: 768px){.form-group .radio-group .radio-option{flex-direction:row;align-items:flex-start}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i4.InputText, selector: "[pInputText]", inputs: ["hostName", "ptInputText", "pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: TextareaModule }, { kind: "directive", type: i5.Textarea, selector: "[pTextarea], [pInputTextarea]", inputs: ["autoResize", "pSize", "variant", "fluid", "invalid"], outputs: ["onResize"] }, { kind: "ngmodule", type:
209
+ //InputTextarea,
210
+ InputNumberModule }, { kind: "component", type: i6.InputNumber, selector: "p-inputNumber, p-inputnumber, p-input-number", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "placeholder", "tabindex", "title", "ariaLabelledBy", "ariaDescribedBy", "ariaLabel", "ariaRequired", "autocomplete", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "showClear", "autofocus"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown", "onClear"] }, { kind: "ngmodule", type: CheckboxModule }, { kind: "component", type: i7.Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["hostName", "value", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "inputStyle", "styleClass", "inputClass", "indeterminate", "formControl", "checkboxIcon", "readonly", "autofocus", "trueValue", "falseValue", "variant", "size"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: RadioButtonModule }, { kind: "component", type: i8.RadioButton, selector: "p-radioButton, p-radiobutton, p-radio-button", inputs: ["value", "tabindex", "inputId", "ariaLabelledBy", "ariaLabel", "styleClass", "autofocus", "binary", "variant", "size"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i9.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "panelStyle", "styleClass", "panelStyleClass", "readonly", "editable", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "filterValue", "options", "appendTo"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "ngmodule", type:
211
+ //DropdownModule,
212
+ DatePickerModule }, { kind: "component", type: i10.DatePicker, selector: "p-datePicker, p-datepicker, p-date-picker", inputs: ["iconDisplay", "styleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "icon", "readonlyInput", "shortYearCutoff", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "minDate", "maxDate", "disabledDates", "disabledDays", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "view", "defaultDate", "appendTo"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { kind: "ngmodule", type:
213
+ //CalendarModule,
214
+ MessageModule }, { kind: "component", type: i11.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant"], outputs: ["onClose"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i12.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip"] }, { kind: "directive", type: DynamicRefDirective, selector: "[dynamicRef]", inputs: ["refKey"] }, { kind: "ngmodule", type: ScrollPanelModule }, { kind: "component", type: i13.ScrollPanel, selector: "p-scroll-panel, p-scrollPanel, p-scrollpanel", inputs: ["styleClass", "step"] }, { kind: "ngmodule", type: PopoverModule }, { kind: "component", type: i14.Popover, selector: "p-popover", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions"], outputs: ["onShow", "onHide"] }, { kind: "ngmodule", type: DrawerModule }, { kind: "component", type: i15.Drawer, selector: "p-drawer", inputs: ["appendTo", "blockScroll", "style", "styleClass", "ariaCloseLabel", "autoZIndex", "baseZIndex", "modal", "closeButtonProps", "dismissible", "showCloseIcon", "closeOnEscape", "transitionOptions", "visible", "position", "fullScreen", "header", "maskStyle", "closable"], outputs: ["onShow", "onHide", "visibleChange"] }, { kind: "ngmodule", type: InputMaskModule }, { kind: "component", type: i16.InputMask, selector: "p-inputmask, p-inputMask, p-input-mask", inputs: ["type", "slotChar", "autoClear", "showClear", "style", "inputId", "styleClass", "placeholder", "tabindex", "title", "ariaLabel", "ariaLabelledBy", "ariaRequired", "readonly", "unmask", "characterPattern", "autofocus", "autocomplete", "keepBuffer", "mask"], outputs: ["onComplete", "onFocus", "onBlur", "onInput", "onKeydown", "onClear"] }] });
215
+ }
216
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
217
+ type: Component,
218
+ args: [{ selector: 'app-dynamic-form-field', standalone: true, imports: [
219
+ CommonModule,
220
+ ReactiveFormsModule,
221
+ InputTextModule,
222
+ TextareaModule,
223
+ //InputTextarea,
224
+ InputNumberModule,
225
+ CheckboxModule,
226
+ RadioButtonModule,
227
+ SelectModule,
228
+ //DropdownModule,
229
+ DatePickerModule,
230
+ //CalendarModule,
231
+ MessageModule,
232
+ TooltipModule,
233
+ DynamicRefDirective,
234
+ ScrollPanelModule,
235
+ PopoverModule,
236
+ DrawerModule,
237
+ InputMaskModule
238
+ ], template: "\r\n<div [ngClass]=\"fieldClasses\" [formGroup]=\"form\">\r\n <div [ngStyle]=\"{ width: fieldWidthStyle(), position: 'relative' }\">\r\n <!-- Label -->\r\n <div *ngIf=\"field.leftPreInput\" class=\"left-pre-input\">\r\n <span [innerHTML]=\"field.leftPreInput\" class=\"left-pre-input-text\">\r\n </span>\r\n\r\n </div>\r\n <div #field_container class=\"input-container\">\r\n <div class=\"label-row\" [ngStyle]=\"{ width: labelWidthStyle() }\">\r\n <label [attr.for]=\"field.id\" class=\"control-label\">\r\n {{ field.label }}\r\n <span *ngIf=\"field.required\" class=\"required-indicator\">*</span>\r\n </label>\r\n <div class=\"help-icons\">\r\n <i (click)=\"helpSideBarVisible = true\" class=\"pi pi-question-circle\" *ngIf=\"allowHelpSideBar && field.popInfo\"></i>\r\n <i (click)=\"popover.toggle($event)\" class=\"pi pi-question-circle\" *ngIf=\"allowHelpOverlay && field.popInfo\"></i>\r\n </div>\r\n </div>\r\n <!-- Text Input -->\r\n <input *ngIf=\"field.type === 'text'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n class=\"form-control\"\r\n type=\"text\"\r\n pInputText\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\" />\r\n <!-- Email Input -->\r\n <input *ngIf=\"field.type === 'email'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n class=\"form-control\"\r\n type=\"email\"\r\n pInputText\r\n pTooltip=\"{{field.toolTip}}\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\" />\r\n <!-- Number Input -->\r\n <p-inputNumber *ngIf=\"field.type === 'number'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [inputId]=\"field.id\"\r\n [useGrouping]=\"false\"\r\n [minFractionDigits]=\"getDecimalPlace\"\r\n [min]=\"getMinValue\"\r\n [max]=\"getMaxValue\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n styleClass=\"form-control\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-inputNumber>\r\n\r\n\r\n <!-- phone -->\r\n\r\n <p-inputMask *ngIf=\"field.type === 'phone'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n mask=\"(999) 999-9999\"\r\n unmask=\"true\"\r\n styleClass=\"form-control-phone\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-inputMask>\r\n <!-- Textarea -->\r\n <textarea *ngIf=\"field.type === 'textarea'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n [rows]=\"5\"\r\n class=\"form-control\"\r\n pInputTextarea\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (blur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></textarea>\r\n\r\n <!-- Date Picker -->\r\n <p-datepicker *ngIf=\"field.type === 'date'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [inputId]=\"field.id\"\r\n [id]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [placeholder]=\"field.placeholder || ''\"\r\n styleClass=\"form-control-datepicker\"\r\n dateFormat=\"DD MM yy\"\r\n [showIcon]=\"true\"\r\n [style]=\"{ width: inputWidthStyle() }\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-datepicker>\r\n\r\n <!-- Select Dropdown -->\r\n <p-select *ngIf=\"field.type === 'select'\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [inputId]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [id]=\"field.id\"\r\n appendTo=\"body\"\r\n [options]=\"field.options || []\"\r\n [placeholder]=\"field.placeholder || 'Select an option'\"\r\n optionLabel=\"label\"\r\n optionValue=\"value\"\r\n styleClass=\"form-control-select\"\r\n [showClear]=\"!field.required\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n tooltipPosition=\"bottom\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-select>\r\n\r\n <!-- Checkbox -->\r\n <div *ngIf=\"field.type === 'checkbox'\" class=\"checkbox-wrapper\">\r\n <p-checkbox [attr.data-dynamic-id]=\"field.id\"\r\n [refKey]=\"field.id\" dynamicRef\r\n [id]=\"field.id\"\r\n [inputId]=\"field.id\"\r\n [formControlName]=\"controlName\"\r\n [style]=\"{ width: inputWidthStyle() }\"\r\n [ngStyle]=\"{ width: inputWidthStyle() }\"\r\n [binary]=\"true\"\r\n tooltipPosition=\"right\"\r\n pTooltip=\"{{field.toolTip}}\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event)\"></p-checkbox>\r\n </div>\r\n\r\n <!-- Radio Buttons -->\r\n <div *ngIf=\"field.type === 'radio'\" class=\"radio-group\">\r\n <div *ngFor=\"let option of field.options; trackBy: trackByFn; let first = first\"\r\n class=\"radio-option\" tooltipPosition=\"right\" pTooltip=\"{{option.toolTip}}\">\r\n\r\n <p-radioButton *ngIf=\"first\"\r\n [attr.data-dynamic-id]=\"field.id\"\r\n [inputId]=\"field.id + '_' + option.value\"\r\n [id]=\"field.id + '_' + option.value\"\r\n [name]=\"field.id\"\r\n [value]=\"option.value\"\r\n [formControlName]=\"controlName\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event.originalEvent)\"></p-radioButton>\r\n <p-radioButton *ngIf=\"!first\"\r\n [inputId]=\"field.id + '_' + option.value\"\r\n [id]=\"field.id + '_' + option.value\"\r\n [name]=\"field.id\"\r\n [value]=\"option.value\"\r\n [formControlName]=\"controlName\"\r\n (onBlur)=\"onBlur()\"\r\n (onClick)=\"onClick($event.originalEvent)\"></p-radioButton>\r\n <label [for]=\"field.id + '_' + option.value\" class=\"radio-label\">\r\n {{ option.label }}\r\n </label>\r\n <div *ngIf=\"option.helpInfo\" class=\"radio-message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"option.helpInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"option.errorInfo && displayRadioError(option)\" class=\"radio-message-container\">\r\n <p-message severity=\"error\">\r\n <div [innerHTML]=\"option.errorInfo\"></div>\r\n </p-message>\r\n </div>\r\n <small class=\"radion-hint\" *ngIf=\"option.hint\" id=\"field.id + '_' + option.value + '-help'\">{{option.hint}}</small>\r\n\r\n\r\n </div>\r\n </div>\r\n <small class=\"field-hint\" *ngIf=\"field.hint\" id=\"field.id + '-help'\">{{field.hint}}</small>\r\n </div>\r\n <!-- Error Messages -->\r\n <div *ngIf=\"showError\" class=\"error-messages\">\r\n <p-message *ngFor=\"let error of errors\"\r\n severity=\"error\"\r\n [text]=\"error\"></p-message>\r\n </div>\r\n\r\n <div *ngIf=\"field.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"field.postInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"field.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"field.postWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <!-- Valid Indicator (optional) -->\r\n <div *ngIf=\"isValid && isTouched && field.required\" [ngClass]=\"successIndicatorClass\">\r\n <i class=\"pi pi-check-circle\"></i>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<p-popover appendTo=\"body\" styleClass=\"form-pop-info\" #popover>\r\n <h4>{{field.label}}</h4>\r\n <div [innerHTML]=\"field.popInfo\"></div>\r\n</p-popover>\r\n@if (allowHelpSideBar && field.popInfo) {\r\n <p-drawer header=\"{{field.label}}\" autoZIndex=\"false\" baseZIndex=\"10000\" [ngStyle]=\"{'z-index': '10000', 'top': '65px'}\" position=\"right\" styleClass=\"form-pop-info\" appendTo=\"body\" [(visible)]=\"helpSideBarVisible\">\r\n <p-scrollPanel [ngStyle]=\"{height: '100%'}\">\r\n <div [innerHTML]=\"field.popInfo\"></div>\r\n </p-scrollPanel>\r\n </p-drawer>\r\n}\r\n", styles: [".p-overlay-mask,.p-drawer .p-drawer.form-pop-info{z-index:10000!important}.p-drawer-right,.p-drawer.form-pop-info.p-drawer-right{top:65px}p-message .p-message.light-font .p-message-text{font-weight:400}.form-group{margin-bottom:1rem;position:relative;transition:all .3s ease;display:flex;flex-wrap:wrap;gap:.75rem}.form-group .left-pre-input{display:flex;flex-direction:column;justify-content:flex-end;align-items:flex-end;flex-basis:40%;flex-shrink:0;flex-grow:0}.form-group .left-pre-input .left-pre-input-text{text-align:right;width:100%;margin-bottom:10px;font-weight:600}.form-group .input-container{flex-grow:1;flex-shrink:1;min-width:0}.form-group .label-row{display:flex;justify-content:space-between;align-items:start;margin-bottom:.5rem}.form-group .help-icons{display:flex;gap:.5rem;margin-left:.5rem}.form-group .help-icons i{cursor:pointer;color:#6c757d;transition:color .2s ease}.form-group .help-icons i:hover{color:#007bff}.form-group .control-label{display:block;font-weight:500;color:#333}.form-group .control-label .required-indicator{color:#dc3545;margin-left:.25rem}.form-group .form-control{width:100%;transition:border-color .3s ease,box-shadow .3s ease}.form-group .field-hint{display:block;margin-top:.25rem;font-size:.875rem;color:#6c757d}.form-group .checkbox-wrapper{padding:.5rem 0}.form-group .radio-group{display:flex;flex-direction:column;gap:.75rem}.form-group .radio-group .radio-option{display:flex;align-items:center;flex-wrap:wrap}.form-group .radio-group .radio-option .radio-label{margin:0;cursor:pointer;font-weight:400}.form-group .radio-group .radio-option .radion-hint{flex-basis:100%;width:100%;display:block;margin-left:36px;font-size:.875rem;color:#6c757d}.form-group .radio-group .radio-option .radio-message-container{flex-basis:100%;width:100%;margin-top:.25rem;margin-left:36px}.form-group .error-messages{margin-top:.5rem;flex-basis:100%;width:100%;animation:slideDown .3s ease}.form-group .error-messages ::ng-deep .p-message{margin-bottom:.25rem}.form-group .error-messages ::ng-deep .p-message:last-child{margin-bottom:0}.form-group .valid-indicator,.form-group .valid-indicator-select,.form-group .valid-indicator-calendar{position:absolute;color:#28a745;font-size:1.2rem;animation:fadeIn .3s ease}.form-group .valid-indicator i,.form-group .valid-indicator-select i,.form-group .valid-indicator-calendar i{display:block}.form-group .valid-indicator{right:10px;top:38px}.form-group .valid-indicator-select,.form-group .valid-indicator-calendar{right:80px;top:38px}.form-group .p-select,.form-group ::ng-deep .p-datepicker,.form-group .p-inputnumber{padding:0}.form-group .p-datepicker>span>input,.form-group .p-inputnumber{border:none!important}.form-group.field-error .form-control,.form-group.field-error ::ng-deep .p-inputtext,.form-group.field-error ::ng-deep .p-select,.form-group.field-error ::ng-deep .p-datepicker,.form-group.field-error ::ng-deep .p-inputnumber input{border-color:#dc3545!important}.form-group.field-error .form-control:focus,.form-group.field-error ::ng-deep .p-inputtext:focus,.form-group.field-error ::ng-deep .p-select:focus,.form-group.field-error ::ng-deep .p-datepicker:focus,.form-group.field-error ::ng-deep .p-inputnumber input:focus{box-shadow:0 0 0 .2rem #dc354540}.form-group.field-error .p-datepicker>span>input{border:none!important}.form-group.field-error .control-label{color:#dc3545}.form-group.field-valid .form-control,.form-group.field-valid ::ng-deep .p-inputtext,.form-group.field-valid ::ng-deep .p-select,.form-group.field-valid ::ng-deep .p-datepicker,.form-group.field-valid ::ng-deep .p-inputnumber input{border-color:#28a745}.form-group.field-valid .form-control:focus,.form-group.field-valid ::ng-deep .p-inputtext:focus,.form-group.field-valid ::ng-deep .p-select:focus,.form-group.field-valid ::ng-deep .p-datepicker:focus,.form-group.field-valid ::ng-deep .p-inputnumber input:focus{box-shadow:0 0 0 .2rem #28a74540}.form-group.field-valid .p-datepicker>span>input{border:none!important}.form-group.field-disabled{opacity:.6;pointer-events:none}.form-group.field-disabled .control-label{color:#6c757d}.form-group.field-error{padding:12px;border:1px solid #dc3545;background-color:var(--p-red-100);box-shadow:0 0 10px #00000080;border-radius:10px}@keyframes slideDown{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}::ng-deep .p-inputtext,::ng-deep .p-select,::ng-deep .p-datepicker .p-inputtext,::ng-deep .p-inputnumber-input{width:100%}::ng-deep .p-select{display:flex}::ng-deep .p-datepicker{width:100%}::ng-deep .p-datepicker .p-inputtext{width:100%}::ng-deep .p-inputnumber{width:100%}::ng-deep .p-checkbox{margin-right:.5rem}::ng-deep .p-radiobutton{margin-right:.5rem}@media (max-width: 768px){.form-group .radio-group .radio-option{flex-direction:row;align-items:flex-start}}\n"] }]
239
+ }], ctorParameters: () => [{ type: i1.BreakpointObserver }], propDecorators: { field: [{
240
+ type: Input
241
+ }], form: [{
242
+ type: Input
243
+ }], errors: [{
244
+ type: Input
245
+ }], allowHelpOverlay: [{
246
+ type: Input
247
+ }], allowHelpSideBar: [{
248
+ type: Input
249
+ }], ref: [{
250
+ type: ViewChild,
251
+ args: [DynamicRefDirective]
252
+ }], radioButton: [{
253
+ type: ViewChild,
254
+ args: [RadioButton]
255
+ }] } });
256
+
257
+ function compareValidator(matchingControlName) {
258
+ return (control) => {
259
+ const group = control.parent;
260
+ if (!group) {
261
+ return null;
262
+ }
263
+ const matchingControl = group.get(matchingControlName);
264
+ if (!matchingControl) {
265
+ return null;
266
+ }
267
+ // Return error on the current control instead of modifying the other
268
+ if (control.value !== matchingControl.value) {
269
+ return { compare: true };
270
+ }
271
+ return null;
272
+ };
273
+ }
274
+
275
+ class DynamicFormService {
276
+ constructor() { }
277
+ /**
278
+ * Gets the validators for a specific field based on its validations
279
+ */
280
+ getValidators(fieldOrValidations) {
281
+ let validations = [];
282
+ if (!Array.isArray(fieldOrValidations)) {
283
+ if (!fieldOrValidations.validations || fieldOrValidations.validations.length === 0) {
284
+ return [];
285
+ }
286
+ validations = fieldOrValidations.validations;
287
+ }
288
+ else {
289
+ validations = fieldOrValidations;
290
+ }
291
+ const validators = [];
292
+ validations.forEach(validation => {
293
+ const validator = this.createValidator(validation);
294
+ if (validator) {
295
+ validators.push(validator);
296
+ }
297
+ });
298
+ return validators;
299
+ }
300
+ /**
301
+ * Creates a validator function based on validation type
302
+ */
303
+ createValidator(validation) {
304
+ switch (validation.type) {
305
+ case 'required':
306
+ return Validators.required;
307
+ case 'minLength':
308
+ return validation.value ? Validators.minLength(validation.value) : null;
309
+ case 'maxLength':
310
+ return validation.value ? Validators.maxLength(validation.value) : null;
311
+ case 'min':
312
+ return validation.value !== undefined ? Validators.min(validation.value) : null;
313
+ case 'max':
314
+ return validation.value !== undefined ? Validators.max(validation.value) : null;
315
+ case 'compare':
316
+ return validation.compareToField !== undefined ? compareValidator(validation.compareToField) : null;
317
+ case 'email':
318
+ return Validators.email;
319
+ case 'pattern':
320
+ return validation.value ? Validators.pattern(validation.value) : null;
321
+ case 'custom':
322
+ return validation.validator ? this.customValidator(validation) : null;
323
+ default:
324
+ return null;
325
+ }
326
+ }
327
+ /**
328
+ * Creates a custom validator wrapper
329
+ */
330
+ customValidator(validation) {
331
+ return (control) => {
332
+ if (!validation.validator) {
333
+ return null;
334
+ }
335
+ const isValid = validation.validator(control.value);
336
+ return isValid ? null : { custom: { message: validation.message } };
337
+ };
338
+ }
339
+ /**
340
+ * Gets error messages for a field based on its validation errors
341
+ */
342
+ getErrorMessages(field, errors) {
343
+ if (!errors || !field.validations) {
344
+ return [];
345
+ }
346
+ const errorMessages = [];
347
+ field.validations.forEach(validation => {
348
+ const errorKey = this.getErrorKey(validation.type);
349
+ if (errors[errorKey]) {
350
+ errorMessages.push({
351
+ fieldId: field.id,
352
+ message: validation.message
353
+ });
354
+ }
355
+ });
356
+ return errorMessages;
357
+ }
358
+ /**
359
+ * Maps validation type to Angular error key
360
+ */
361
+ getErrorKey(validationType) {
362
+ switch (validationType) {
363
+ case 'required':
364
+ return 'required';
365
+ case 'minLength':
366
+ return 'minlength';
367
+ case 'maxLength':
368
+ return 'maxlength';
369
+ case 'min':
370
+ return 'min';
371
+ case 'max':
372
+ return 'max';
373
+ case 'email':
374
+ return 'email';
375
+ case 'pattern':
376
+ return 'pattern';
377
+ case 'custom':
378
+ return 'custom';
379
+ case 'compare':
380
+ return 'compare';
381
+ default:
382
+ return validationType;
383
+ }
384
+ }
385
+ /**
386
+ * Validates a complete form configuration
387
+ */
388
+ validateFormConfig(config) {
389
+ if (!config || !config.id || !config.frames) {
390
+ console.error('Invalid form config: missing required properties');
391
+ return false;
392
+ }
393
+ if (!Array.isArray(config.frames) || config.frames.length === 0) {
394
+ console.error('Invalid form config: frames must be a non-empty array');
395
+ return false;
396
+ }
397
+ for (const frame of config.frames) {
398
+ if (!Array.isArray(frame.sections) || frame.sections.length === 0) {
399
+ console.error('Invalid form config: sections must be a non-empty array');
400
+ return false;
401
+ }
402
+ }
403
+ if (!Array.isArray(config.frames[0].sections) || config.frames[0].sections.length === 0 || !Array.isArray(config.frames[0].sections[0].fields) || config.frames[0].sections[0].fields.length === 0) {
404
+ console.error('Invalid form config: fields must be a non-empty array');
405
+ return false;
406
+ }
407
+ for (const frame of config.frames) {
408
+ for (const section of frame.sections) {
409
+ for (const field of section.fields) {
410
+ if (!field.id || !field.label || !field.type) {
411
+ console.error('Invalid field config: missing required properties', field);
412
+ return false;
413
+ }
414
+ const validTypes = ['text', 'number', 'email', 'select', 'checkbox', 'radio', 'date', 'textarea'];
415
+ if (!validTypes.includes(field.type)) {
416
+ console.error(`Invalid field type: ${field.type}`, field);
417
+ return false;
418
+ }
419
+ if ((field.type === 'select' || field.type === 'radio') && (!field.options || field.options.length === 0)) {
420
+ console.error(`Field type ${field.type} requires options`, field);
421
+ return false;
422
+ }
423
+ }
424
+ }
425
+ }
426
+ return true;
427
+ }
428
+ /**
429
+ * Creates a sample form configuration for testing
430
+ */
431
+ createSampleConfig() {
432
+ return {
433
+ id: 'sample-form',
434
+ title: 'Sample Dynamic Form',
435
+ description: 'This is a sample form configuration demonstrating all field types.',
436
+ sections: [
437
+ {
438
+ id: 'sample-form',
439
+ title: 'Sample Dynamic Form',
440
+ description: 'This is a sample form configuration demonstrating all field types.',
441
+ fields: [
442
+ {
443
+ id: 'firstName',
444
+ label: 'First Name',
445
+ type: 'text',
446
+ placeholder: 'Enter your first name',
447
+ required: true,
448
+ order: 1,
449
+ validations: [
450
+ {
451
+ type: 'required',
452
+ message: 'First name is required'
453
+ },
454
+ {
455
+ type: 'minLength',
456
+ value: 2,
457
+ message: 'First name must be at least 2 characters'
458
+ }
459
+ ]
460
+ },
461
+ {
462
+ id: 'email',
463
+ label: 'Email Address',
464
+ type: 'email',
465
+ placeholder: 'Enter your email',
466
+ required: true,
467
+ order: 2,
468
+ validations: [
469
+ {
470
+ type: 'required',
471
+ message: 'Email is required'
472
+ },
473
+ {
474
+ type: 'email',
475
+ message: 'Please enter a valid email address'
476
+ }
477
+ ]
478
+ },
479
+ {
480
+ id: 'age',
481
+ label: 'Age',
482
+ type: 'number',
483
+ placeholder: 'Enter your age',
484
+ order: 3,
485
+ validations: [
486
+ {
487
+ type: 'min',
488
+ value: 18,
489
+ message: 'You must be at least 18 years old'
490
+ },
491
+ {
492
+ type: 'max',
493
+ value: 120,
494
+ message: 'Age must be less than 120'
495
+ }
496
+ ]
497
+ },
498
+ {
499
+ id: 'country',
500
+ label: 'Country',
501
+ type: 'select',
502
+ placeholder: 'Select your country',
503
+ required: true,
504
+ order: 4,
505
+ options: [
506
+ { label: 'United States', value: 'US' },
507
+ { label: 'Canada', value: 'CA' },
508
+ { label: 'United Kingdom', value: 'UK' },
509
+ { label: 'Australia', value: 'AU' }
510
+ ],
511
+ validations: [
512
+ {
513
+ type: 'required',
514
+ message: 'Country is required'
515
+ }
516
+ ]
517
+ },
518
+ {
519
+ id: 'gender',
520
+ label: 'Gender',
521
+ type: 'radio',
522
+ order: 5,
523
+ options: [
524
+ { label: 'Male', value: 'male' },
525
+ { label: 'Female', value: 'female' },
526
+ { label: 'Other', value: 'other' }
527
+ ]
528
+ },
529
+ {
530
+ id: 'newsletter',
531
+ label: 'Subscribe to newsletter',
532
+ type: 'checkbox',
533
+ order: 6,
534
+ value: false
535
+ },
536
+ {
537
+ id: 'birthDate',
538
+ label: 'Birth Date',
539
+ type: 'date',
540
+ placeholder: 'Select your birth date',
541
+ order: 7
542
+ },
543
+ {
544
+ id: 'comments',
545
+ label: 'Comments',
546
+ type: 'textarea',
547
+ placeholder: 'Enter any additional comments',
548
+ order: 8,
549
+ validations: [
550
+ {
551
+ type: 'maxLength',
552
+ value: 500,
553
+ message: 'Comments must be less than 500 characters'
554
+ }
555
+ ]
556
+ }
557
+ ],
558
+ }
559
+ ],
560
+ submitLabel: 'Submit Form',
561
+ cancelLabel: 'Cancel'
562
+ };
563
+ }
564
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
565
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormService, providedIn: 'root' });
566
+ }
567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormService, decorators: [{
568
+ type: Injectable,
569
+ args: [{
570
+ providedIn: 'root'
571
+ }]
572
+ }], ctorParameters: () => [] });
573
+
574
+ class DynamicFormComponent {
575
+ responsive;
576
+ // Inject dependencies using field initializers (this IS the injection context)
577
+ fb = inject(FormBuilder);
578
+ dynamicFormService = inject(DynamicFormService);
579
+ config;
580
+ initialValues;
581
+ allowHelpOverlay = false;
582
+ allowHelpSideBar = false;
583
+ formSubmit = new EventEmitter();
584
+ formCancel = new EventEmitter();
585
+ formStateChange = new EventEmitter();
586
+ fieldComponents;
587
+ componentMap;
588
+ fieldMap;
589
+ form;
590
+ formState;
591
+ sortedFields = [];
592
+ sortedSections = [];
593
+ sortedFrames = [];
594
+ destroy$ = new Subject();
595
+ isExpanded = false;
596
+ isSmallMedia = false;
597
+ isMediumMedia = false;
598
+ // Empty constructor - no code needed here
599
+ constructor(responsive) {
600
+ this.responsive = responsive;
601
+ }
602
+ ngOnInit() {
603
+ this.responsive.observe([Breakpoints.Medium, Breakpoints.Small, Breakpoints.XSmall])
604
+ .subscribe(result => {
605
+ if (result.matches) {
606
+ this.isSmallMedia = true;
607
+ }
608
+ else {
609
+ this.isSmallMedia = false;
610
+ }
611
+ });
612
+ this.initializeForm();
613
+ this.subscribeToFormChanges();
614
+ }
615
+ ngOnDestroy() {
616
+ this.destroy$.next();
617
+ this.destroy$.complete();
618
+ }
619
+ ngAfterViewInit() {
620
+ this.componentMap = new Map(this.fieldComponents.map(comp => [comp.field.id, comp]));
621
+ }
622
+ initializeForm() {
623
+ //sort frames
624
+ // Sort sections and fields by order
625
+ this.sortedFrames = [...this.config.frames].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
626
+ this.sortedFrames.forEach((frame) => {
627
+ frame.sections = [...frame.sections].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
628
+ frame.sections.forEach((section) => {
629
+ section.fields = [...section.fields].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
630
+ });
631
+ });
632
+ // Build field map for O(1) lookup
633
+ this.fieldMap = new Map();
634
+ this.sortedFrames.forEach(frame => {
635
+ frame.sections.forEach(section => {
636
+ section.fields.forEach(field => {
637
+ this.fieldMap.set(field.id, field);
638
+ });
639
+ });
640
+ });
641
+ // Build form controls
642
+ const group = {};
643
+ this.sortedFrames.forEach(frame => {
644
+ frame.sections.forEach(section => {
645
+ section.fields.forEach(field => {
646
+ const validators = field.disabled === true ? [] : this.dynamicFormService.getValidators(field);
647
+ const initialValue = this.getInitialValue(field);
648
+ group[field.id] = [
649
+ { value: initialValue, disabled: field.disabled ?? false },
650
+ validators
651
+ ];
652
+ });
653
+ });
654
+ });
655
+ this.form = this.fb.group(group);
656
+ // Trigger all click events on form controls
657
+ this.triggerAllClickEvents();
658
+ // Initialize form state
659
+ this.formState = {
660
+ values: this.form.value,
661
+ errors: [],
662
+ touched: {},
663
+ isSubmitting: false,
664
+ isValid: this.form.valid
665
+ };
666
+ if (this.form.valid) {
667
+ this.markAllAsTouched();
668
+ }
669
+ this.emitFormState();
670
+ }
671
+ triggerAllClickEvents() {
672
+ this.sortedFrames.forEach(frame => {
673
+ frame.sections.forEach(section => {
674
+ section.fields.forEach(field => {
675
+ const control = this.form.get(field.id);
676
+ if (control && field.onClick) {
677
+ // Trigger the onClick event with current control value
678
+ field.onClick(control.value, this.form);
679
+ }
680
+ });
681
+ });
682
+ });
683
+ }
684
+ getInitialValue(field) {
685
+ if (this.initialValues && this.initialValues[field.id] !== undefined) {
686
+ //return this.initialValues[field.id];
687
+ if (field.type == "date") {
688
+ if (this.initialValues[field.id] instanceof Date && !isNaN(this.initialValues[field.id].getTime())) {
689
+ console.log(field.id + " is already a valid Date object");
690
+ return this.initialValues[field.id];
691
+ }
692
+ else {
693
+ console.log(field.id + " is not a valid Date object, attempting to parse");
694
+ return new Date(this.initialValues[field.id]);
695
+ }
696
+ }
697
+ else {
698
+ return this.initialValues[field.id];
699
+ }
700
+ }
701
+ return field.value ?? this.getDefaultValue(field.type);
702
+ }
703
+ getDefaultValue(type) {
704
+ switch (type) {
705
+ case 'checkbox':
706
+ return null;
707
+ case 'number':
708
+ return null;
709
+ case 'hidden':
710
+ return 0;
711
+ default:
712
+ return '';
713
+ }
714
+ }
715
+ subscribeToFormChanges() {
716
+ this.form.valueChanges
717
+ .pipe(takeUntil(this.destroy$))
718
+ .subscribe(values => {
719
+ this.updateFormState();
720
+ });
721
+ this.form.statusChanges
722
+ .pipe(takeUntil(this.destroy$))
723
+ .subscribe(() => {
724
+ this.updateFormState();
725
+ });
726
+ }
727
+ updateFormState() {
728
+ const touched = {};
729
+ const errors = [];
730
+ this.fieldMap.forEach((field, fieldId) => {
731
+ const control = this.form.get(fieldId);
732
+ if (control) {
733
+ touched[fieldId] = control.touched;
734
+ if (control.invalid && control.touched) {
735
+ const fieldErrors = this.dynamicFormService.getErrorMessages(field, control.errors);
736
+ errors.push(...fieldErrors);
737
+ }
738
+ }
739
+ });
740
+ this.formState = {
741
+ values: this.form.value,
742
+ errors,
743
+ touched,
744
+ isSubmitting: this.formState.isSubmitting,
745
+ isValid: this.form.valid
746
+ };
747
+ this.emitFormState();
748
+ }
749
+ emitFormState() {
750
+ this.formStateChange.emit({ ...this.formState });
751
+ }
752
+ showCancelButton() {
753
+ if (!this.config.hideCancelButton) {
754
+ return true;
755
+ }
756
+ return !this.config.hideCancelButton();
757
+ }
758
+ showSubmitButton() {
759
+ if (!this.config.hideSubmitButton) {
760
+ return true;
761
+ }
762
+ return !this.config.hideSubmitButton();
763
+ }
764
+ isFieldVisible(field) {
765
+ if (!field.conditionalDisplay) {
766
+ return true;
767
+ }
768
+ return field.conditionalDisplay(this.form.value);
769
+ }
770
+ isSectionVisible(section) {
771
+ if (!section.conditionalDisplay) {
772
+ return true;
773
+ }
774
+ return section.conditionalDisplay(this.form.value);
775
+ }
776
+ isFrameVisible(frame) {
777
+ if (!frame.conditionalDisplay) {
778
+ return true;
779
+ }
780
+ return frame.conditionalDisplay(this.form.value);
781
+ }
782
+ onSubmit() {
783
+ if (this.form.invalid) {
784
+ this.markAllAsTouched();
785
+ this.updateFormState();
786
+ for (const frame of this.sortedFrames) {
787
+ for (const section of frame.sections) {
788
+ for (const field of section.fields) {
789
+ const control = this.form.get(field.id);
790
+ if (control && !control.valid) {
791
+ const component = this.componentMap.get(field.id);
792
+ if (component) {
793
+ component.focusOn();
794
+ return;
795
+ }
796
+ }
797
+ }
798
+ }
799
+ }
800
+ return;
801
+ }
802
+ this.formState.isSubmitting = true;
803
+ this.emitFormState();
804
+ const formValue = this.form.value;
805
+ this.formSubmit.emit(formValue);
806
+ // Reset submitting state after emission
807
+ setTimeout(() => {
808
+ this.formState.isSubmitting = false;
809
+ this.emitFormState();
810
+ }, 0);
811
+ }
812
+ onCancel() {
813
+ this.formCancel.emit();
814
+ }
815
+ markAllAsTouched() {
816
+ Object.keys(this.form.controls).forEach(key => {
817
+ const control = this.form.get(key);
818
+ control?.markAsTouched();
819
+ });
820
+ }
821
+ getFieldErrors(fieldId) {
822
+ const control = this.form.get(fieldId);
823
+ if (!control || !control.errors || !control.touched) {
824
+ return [];
825
+ }
826
+ const field = this.fieldMap.get(fieldId);
827
+ if (!field) {
828
+ return [];
829
+ }
830
+ return this.dynamicFormService.getErrorMessages(field, control.errors).map(e => e.message);
831
+ }
832
+ reset() {
833
+ this.form.reset();
834
+ this.formState = {
835
+ values: this.form.value,
836
+ errors: [],
837
+ touched: {},
838
+ isSubmitting: false,
839
+ isValid: this.form.valid
840
+ };
841
+ this.emitFormState();
842
+ }
843
+ patchValues(values) {
844
+ this.form.patchValue(values);
845
+ if (this.form.valid) {
846
+ this.markAllAsTouched();
847
+ }
848
+ }
849
+ getFormValue() {
850
+ return this.form.value;
851
+ }
852
+ get submitLabel() {
853
+ return this.config.submitLabel ?? 'Submit';
854
+ }
855
+ get cancelLabel() {
856
+ return this.config.cancelLabel ?? 'Cancel';
857
+ }
858
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormComponent, deps: [{ token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
859
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: DynamicFormComponent, isStandalone: true, selector: "app-dynamic-form", inputs: { config: "config", initialValues: "initialValues", allowHelpOverlay: "allowHelpOverlay", allowHelpSideBar: "allowHelpSideBar" }, outputs: { formSubmit: "formSubmit", formCancel: "formCancel", formStateChange: "formStateChange" }, viewQueries: [{ propertyName: "fieldComponents", predicate: DynamicFormFieldComponent, descendants: true }], ngImport: i0, template: "@if (config) {\r\n <div class=\"dynamic-form-container\">\r\n @if (config.title || config.description) {\r\n <div class=\"form-title\">\r\n <div class=\"title-container\">\r\n @if (config.title) {\r\n <h4>{{ config.title }}</h4>\r\n }\r\n @if (config.description) {\r\n <p class=\"form-description\">{{ config.description }}</p>\r\n }\r\n <hr class=\"title-subline\" />\r\n </div>\r\n </div>\r\n }\r\n <form [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\" novalidate>\r\n <div *ngIf=\"config.preInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"config.preInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"config.preWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"config.preWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <ng-container *ngFor=\"let frame of sortedFrames\">\r\n <div [ngClass]=\"frame.cssClass\" *ngIf=\"isFrameVisible(frame)\">\r\n <div [ngClass]=\"frame.innerFrameCssClass\">\r\n <div *ngIf=\"frame.title\" [ngClass]=\"frame.titleContainerCssClass\">\r\n <span *ngIf=\"frame.titlePrefix\" [ngClass]=\"frame.titlePrefixCssClass\">{{frame.titlePrefix}}</span>\r\n <h3 [ngClass]=\"frame.titleCssClass\">{{frame.title}}</h3>\r\n </div>\r\n <div *ngIf=\"frame.description\" class=\"frame-description\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"frame.description\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <ng-container *ngFor=\"let section of frame.sections\">\r\n <div class=\"section-wrapper\" *ngIf=\"isSectionVisible(section)\">\r\n <div class=\"section-content\">\r\n\r\n <h5 *ngIf=\"section.title != null\" class=\"section-title\">{{section.title}}</h5>\r\n <div *ngIf=\"section.preInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"section.preInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"section.preWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"section.preWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <div class=\"fields-wrapper\">\r\n <div class=\"fields-grid\">\r\n <ng-container *ngFor=\"let field of section.fields\">\r\n <ng-container *ngIf=\"field.type == 'hidden'\" [formGroup]=\"form\">\r\n <input type=\"hidden\" [formControlName]=\"field.id\" />\r\n\r\n </ng-container>\r\n <ng-container *ngIf=\"field.type != 'hidden'\">\r\n\r\n <div class=\"field-container\" [ngClass]=\"field.cssClass\" *ngIf=\"isFieldVisible(field)\">\r\n <app-dynamic-form-field [field]=\"field\"\r\n [form]=\"form\"\r\n [errors]=\"getFieldErrors(field.id)\"\r\n [allowHelpOverlay]=\"allowHelpOverlay\"\r\n [allowHelpSideBar]=\"allowHelpSideBar\">\r\n </app-dynamic-form-field>\r\n\r\n </div>\r\n </ng-container>\r\n\r\n </ng-container>\r\n </div>\r\n </div>\r\n\r\n <div *ngIf=\"section.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"section.postInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"section.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"section.postWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n\r\n <ng-content></ng-content>\r\n <div id=\"buttoncont\" class=\"button-container\">\r\n <div class=\"button-group\">\r\n @if (showCancelButton()) {\r\n <button pButton\r\n type=\"button\"\r\n class=\"btn-cancel\"\r\n icon=\"{{config.cancelIcon ? config.cancelIcon : 'pi pi-times'}}\"\r\n iconPos=\"left\"\r\n [label]=\"cancelLabel\"\r\n [disabled]=\"formState.isSubmitting\"\r\n (click)=\"onCancel()\">\r\n </button>\r\n }\r\n @if (showSubmitButton()) {\r\n <button pButton\r\n type=\"submit\"\r\n class=\"\"\r\n icon=\"{{config.submitIcon ? config.submitIcon : 'pi pi-check'}}\"\r\n iconPos=\"right\"\r\n [label]=\"submitLabel\"\r\n [disabled]=\"formState.isSubmitting\"\r\n [loading]=\"formState.isSubmitting\">\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n <div *ngIf=\"config.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">{{config.postInfo}}</p-message>\r\n </div>\r\n <div *ngIf=\"config.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">{{config.postWarning}}</p-message>\r\n </div>\r\n\r\n </form>\r\n </div>\r\n}\r\n", styles: [".dynamic-form-container{width:100%}.dynamic-form-container p-message .p-message.light-font .p-message-text{font-weight:400}.dynamic-form-container .form-description{color:#666;margin-bottom:1rem}.dynamic-form-container .form-fields-container{margin-bottom:1rem}.dynamic-form-container .form-fields-container .row{margin-bottom:.5rem}.dynamic-form-container .form-actions{margin-top:2rem;padding-top:1rem;border-top:1px solid #dee2e6}.dynamic-form-container .form-actions button{margin-left:.5rem}.dynamic-form-container .form-actions .btn-cancel{background-color:#6c757d;border-color:#6c757d}.dynamic-form-container .form-actions .btn-cancel:hover{background-color:#5a6268;border-color:#545b62}.dynamic-form-container .section-wrapper{width:100%;display:flex;justify-content:center}.dynamic-form-container .section-content{width:100%;display:flex;flex-wrap:wrap;gap:1rem;justify-content:center;padding-top:16px}.dynamic-form-container .section-title{width:100%;text-align:left;font-size:24px;font-weight:600;margin-top:8px;margin-bottom:16px}.dynamic-form-container .message-container{width:100%;display:block;margin-top:.5rem;margin-bottom:.5rem;text-align:left}.dynamic-form-container .fields-wrapper{width:100%;display:flex;justify-content:center}.dynamic-form-container .fields-grid{width:100%;display:flex;flex-wrap:wrap;gap:1rem;justify-content:left}.dynamic-form-container .field-container,.dynamic-form-container .field-container-2col,.dynamic-form-container .field-container-1col{width:100%;text-align:left}.dynamic-form-container .button-container{width:100%;display:flex;justify-content:flex-end}.dynamic-form-container .button-group{display:flex;gap:.5rem}@media (min-width: 1024px){.dynamic-form-container .field-container,.dynamic-form-container .field-container-2col{width:calc(50% - .5rem)}.dynamic-form-container .field-container-1col{width:100%}}@media (max-width: 768px){.dynamic-form-container .form-actions button{width:100%;margin:.25rem 0}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: DynamicFormFieldComponent, selector: "app-dynamic-form-field", inputs: ["field", "form", "errors", "allowHelpOverlay", "allowHelpSideBar"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i4$1.ButtonDirective, selector: "[pButton]", inputs: ["ptButtonDirective", "hostName", "text", "plain", "raised", "size", "outlined", "rounded", "iconPos", "loadingIcon", "fluid", "label", "icon", "loading", "buttonProps", "severity"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i11.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant"], outputs: ["onClose"] }] });
860
+ }
861
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DynamicFormComponent, decorators: [{
862
+ type: Component,
863
+ args: [{ selector: 'app-dynamic-form', standalone: true, imports: [CommonModule, ReactiveFormsModule, DynamicFormFieldComponent, ButtonModule, MessageModule], template: "@if (config) {\r\n <div class=\"dynamic-form-container\">\r\n @if (config.title || config.description) {\r\n <div class=\"form-title\">\r\n <div class=\"title-container\">\r\n @if (config.title) {\r\n <h4>{{ config.title }}</h4>\r\n }\r\n @if (config.description) {\r\n <p class=\"form-description\">{{ config.description }}</p>\r\n }\r\n <hr class=\"title-subline\" />\r\n </div>\r\n </div>\r\n }\r\n <form [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\" novalidate>\r\n <div *ngIf=\"config.preInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"config.preInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"config.preWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"config.preWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <ng-container *ngFor=\"let frame of sortedFrames\">\r\n <div [ngClass]=\"frame.cssClass\" *ngIf=\"isFrameVisible(frame)\">\r\n <div [ngClass]=\"frame.innerFrameCssClass\">\r\n <div *ngIf=\"frame.title\" [ngClass]=\"frame.titleContainerCssClass\">\r\n <span *ngIf=\"frame.titlePrefix\" [ngClass]=\"frame.titlePrefixCssClass\">{{frame.titlePrefix}}</span>\r\n <h3 [ngClass]=\"frame.titleCssClass\">{{frame.title}}</h3>\r\n </div>\r\n <div *ngIf=\"frame.description\" class=\"frame-description\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"frame.description\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <ng-container *ngFor=\"let section of frame.sections\">\r\n <div class=\"section-wrapper\" *ngIf=\"isSectionVisible(section)\">\r\n <div class=\"section-content\">\r\n\r\n <h5 *ngIf=\"section.title != null\" class=\"section-title\">{{section.title}}</h5>\r\n <div *ngIf=\"section.preInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"section.preInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"section.preWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"section.preWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n <div class=\"fields-wrapper\">\r\n <div class=\"fields-grid\">\r\n <ng-container *ngFor=\"let field of section.fields\">\r\n <ng-container *ngIf=\"field.type == 'hidden'\" [formGroup]=\"form\">\r\n <input type=\"hidden\" [formControlName]=\"field.id\" />\r\n\r\n </ng-container>\r\n <ng-container *ngIf=\"field.type != 'hidden'\">\r\n\r\n <div class=\"field-container\" [ngClass]=\"field.cssClass\" *ngIf=\"isFieldVisible(field)\">\r\n <app-dynamic-form-field [field]=\"field\"\r\n [form]=\"form\"\r\n [errors]=\"getFieldErrors(field.id)\"\r\n [allowHelpOverlay]=\"allowHelpOverlay\"\r\n [allowHelpSideBar]=\"allowHelpSideBar\">\r\n </app-dynamic-form-field>\r\n\r\n </div>\r\n </ng-container>\r\n\r\n </ng-container>\r\n </div>\r\n </div>\r\n\r\n <div *ngIf=\"section.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">\r\n <div [innerHTML]=\"section.postInfo\"></div>\r\n </p-message>\r\n </div>\r\n <div *ngIf=\"section.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">\r\n <div [innerHTML]=\"section.postWarning\"></div>\r\n </p-message>\r\n </div>\r\n\r\n\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n\r\n <ng-content></ng-content>\r\n <div id=\"buttoncont\" class=\"button-container\">\r\n <div class=\"button-group\">\r\n @if (showCancelButton()) {\r\n <button pButton\r\n type=\"button\"\r\n class=\"btn-cancel\"\r\n icon=\"{{config.cancelIcon ? config.cancelIcon : 'pi pi-times'}}\"\r\n iconPos=\"left\"\r\n [label]=\"cancelLabel\"\r\n [disabled]=\"formState.isSubmitting\"\r\n (click)=\"onCancel()\">\r\n </button>\r\n }\r\n @if (showSubmitButton()) {\r\n <button pButton\r\n type=\"submit\"\r\n class=\"\"\r\n icon=\"{{config.submitIcon ? config.submitIcon : 'pi pi-check'}}\"\r\n iconPos=\"right\"\r\n [label]=\"submitLabel\"\r\n [disabled]=\"formState.isSubmitting\"\r\n [loading]=\"formState.isSubmitting\">\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n <div *ngIf=\"config.postInfo\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"info\">{{config.postInfo}}</p-message>\r\n </div>\r\n <div *ngIf=\"config.postWarning\" class=\"message-container\">\r\n <p-message styleClass=\"light-font\" severity=\"warn\">{{config.postWarning}}</p-message>\r\n </div>\r\n\r\n </form>\r\n </div>\r\n}\r\n", styles: [".dynamic-form-container{width:100%}.dynamic-form-container p-message .p-message.light-font .p-message-text{font-weight:400}.dynamic-form-container .form-description{color:#666;margin-bottom:1rem}.dynamic-form-container .form-fields-container{margin-bottom:1rem}.dynamic-form-container .form-fields-container .row{margin-bottom:.5rem}.dynamic-form-container .form-actions{margin-top:2rem;padding-top:1rem;border-top:1px solid #dee2e6}.dynamic-form-container .form-actions button{margin-left:.5rem}.dynamic-form-container .form-actions .btn-cancel{background-color:#6c757d;border-color:#6c757d}.dynamic-form-container .form-actions .btn-cancel:hover{background-color:#5a6268;border-color:#545b62}.dynamic-form-container .section-wrapper{width:100%;display:flex;justify-content:center}.dynamic-form-container .section-content{width:100%;display:flex;flex-wrap:wrap;gap:1rem;justify-content:center;padding-top:16px}.dynamic-form-container .section-title{width:100%;text-align:left;font-size:24px;font-weight:600;margin-top:8px;margin-bottom:16px}.dynamic-form-container .message-container{width:100%;display:block;margin-top:.5rem;margin-bottom:.5rem;text-align:left}.dynamic-form-container .fields-wrapper{width:100%;display:flex;justify-content:center}.dynamic-form-container .fields-grid{width:100%;display:flex;flex-wrap:wrap;gap:1rem;justify-content:left}.dynamic-form-container .field-container,.dynamic-form-container .field-container-2col,.dynamic-form-container .field-container-1col{width:100%;text-align:left}.dynamic-form-container .button-container{width:100%;display:flex;justify-content:flex-end}.dynamic-form-container .button-group{display:flex;gap:.5rem}@media (min-width: 1024px){.dynamic-form-container .field-container,.dynamic-form-container .field-container-2col{width:calc(50% - .5rem)}.dynamic-form-container .field-container-1col{width:100%}}@media (max-width: 768px){.dynamic-form-container .form-actions button{width:100%;margin:.25rem 0}}\n"] }]
864
+ }], ctorParameters: () => [{ type: i1.BreakpointObserver }], propDecorators: { config: [{
865
+ type: Input
866
+ }], initialValues: [{
867
+ type: Input
868
+ }], allowHelpOverlay: [{
869
+ type: Input
870
+ }], allowHelpSideBar: [{
871
+ type: Input
872
+ }], formSubmit: [{
873
+ type: Output
874
+ }], formCancel: [{
875
+ type: Output
876
+ }], formStateChange: [{
877
+ type: Output
878
+ }], fieldComponents: [{
879
+ type: ViewChildren,
880
+ args: [DynamicFormFieldComponent]
881
+ }] } });
882
+
883
+ function getComponentFromElement(el, injector, componentType) {
884
+ try {
885
+ // Get the native element
886
+ const nativeElement = el.nativeElement;
887
+ // Access Angular's internal context from the element
888
+ const context = nativeElement.__ngContext__;
889
+ if (!context) {
890
+ return null;
891
+ }
892
+ // The context is an array or number that references the LView
893
+ // We need to traverse up to find the component instance
894
+ let lView;
895
+ if (typeof context === 'number') {
896
+ // Context is an index into the LView array
897
+ lView = nativeElement.__ngContext__;
898
+ }
899
+ else if (Array.isArray(context)) {
900
+ lView = context;
901
+ }
902
+ // Try to find the parent component by traversing the DOM tree
903
+ let currentElement = nativeElement.parentElement;
904
+ while (currentElement) {
905
+ const elementContext = currentElement.__ngContext__;
906
+ if (elementContext) {
907
+ // Check if this element has a component instance
908
+ const lViewArray = Array.isArray(elementContext) ? elementContext : null;
909
+ if (lViewArray) {
910
+ // LView[8] typically contains the component instance
911
+ for (let i = 8; i < lViewArray.length; i++) {
912
+ const item = lViewArray[i];
913
+ if (item && item instanceof componentType) {
914
+ return item;
915
+ }
916
+ }
917
+ }
918
+ }
919
+ currentElement = currentElement.parentElement;
920
+ }
921
+ return null;
922
+ }
923
+ catch (error) {
924
+ console.error('Error getting component from element:', error);
925
+ return null;
926
+ }
927
+ }
928
+
929
+ /*
930
+ * Public API Surface of dynamic-form-lib
931
+ */
932
+
933
+ /**
934
+ * Generated bundle index. Do not edit.
935
+ */
936
+
937
+ export { DynamicFormComponent, DynamicFormFieldComponent, DynamicFormService, DynamicRefDirective, getComponentFromElement };
938
+ //# sourceMappingURL=bcweed-dynamic-form-lib.mjs.map