@bsachref/ng-form 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/app/base.component.d.ts +23 -0
- package/app/default-forms/default-forms.component.d.ts +3 -19
- package/app/material-form/material-form.component.d.ts +3 -16
- package/app/prime-form/prime-form.component.d.ts +3 -19
- package/esm2022/app/base.component.mjs +113 -0
- package/esm2022/app/default-forms/default-forms.component.mjs +9 -87
- package/esm2022/app/formControlConfig.mjs +1 -1
- package/esm2022/app/material-form/material-form.component.mjs +12 -78
- package/esm2022/app/prime-form/prime-form.component.mjs +14 -103
- package/esm2022/app/validation-messages/validation-messages.component.mjs +2 -2
- package/esm2022/public-api.mjs +1 -1
- package/fesm2022/bsachref-ng-form.mjs +116 -292
- package/fesm2022/bsachref-ng-form.mjs.map +1 -1
- package/package.json +20 -3
- package/app/file-upload-accessor.directive.d.ts +0 -13
- package/esm2022/app/file-upload-accessor.directive.mjs +0 -52
@@ -1,9 +1,9 @@
|
|
1
|
-
import * as
|
1
|
+
import * as i1$1 from '@angular/common';
|
2
2
|
import { CommonModule } from '@angular/common';
|
3
3
|
import * as i0 from '@angular/core';
|
4
|
-
import {
|
4
|
+
import { Input, Component, input, output, ChangeDetectionStrategy } from '@angular/core';
|
5
5
|
import * as i1 from '@angular/forms';
|
6
|
-
import { Validators, ReactiveFormsModule, FormsModule
|
6
|
+
import { Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
7
7
|
import { BehaviorSubject } from 'rxjs';
|
8
8
|
import * as i3 from '@angular/material/input';
|
9
9
|
import { MatInputModule } from '@angular/material/input';
|
@@ -33,7 +33,6 @@ import * as i7$1 from 'primeng/radiobutton';
|
|
33
33
|
import { RadioButtonModule } from 'primeng/radiobutton';
|
34
34
|
import * as i9$1 from 'primeng/togglebutton';
|
35
35
|
import { ToggleButtonModule } from 'primeng/togglebutton';
|
36
|
-
import * as i1$1 from 'primeng/fileupload';
|
37
36
|
import { FileUploadModule } from 'primeng/fileupload';
|
38
37
|
import * as i10$1 from 'primeng/slider';
|
39
38
|
import { SliderModule } from 'primeng/slider';
|
@@ -58,7 +57,7 @@ class ValidationMessagesComponent {
|
|
58
57
|
return null;
|
59
58
|
}
|
60
59
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ValidationMessagesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
61
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: ValidationMessagesComponent, isStandalone: true, selector: "validation-messages", inputs: { control: "control", controlName: "controlName", config: "config" }, ngImport: i0, template: "@if (control?.invalid && control?.touched) {\n <section class=\"error-messages\" style=\"color: red\">\n @if (control?.errors?.[\"required\"]) {\n <small>{{ controlName }} is required</small>\n }\n @if (control?.errors?.[\"minlength\"]) {\n <small\n >Minimum length:\n {{ getValidatorValue(\"minlength\", \"requiredLength\") }}</small\n >\n }\n @if (control?.errors?.[\"maxlength\"]) {\n <small\n >Maximum length:\n {{ getValidatorValue(\"maxlength\", \"requiredLength\") }}</small\n >\n }\n @if (control?.errors?.[\"pattern\"]) {\n <small>Invalid format</small>\n }\n @if (control?.errors?.[\"email\"]) {\n <small>Invalid email address</small>\n }\n @if (control?.errors?.[\"min\"]) {\n <small\n >Value must be at least {{ getValidatorValue(\"min\", \"min\") }}</small\n >\n }\n @if (control?.errors?.[\"max\"]) {\n <small>Value must not exceed {{ getValidatorValue(\"max\", \"max\") }}</small>\n }\n @if (control?.errors?.[\"custom\"]) {\n <small>{{ getCustomErrorMessage() }}</small>\n }\n </section>\n}\n"
|
60
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: ValidationMessagesComponent, isStandalone: true, selector: "validation-messages", inputs: { control: "control", controlName: "controlName", config: "config" }, ngImport: i0, template: "@if (control?.invalid && control?.touched) {\n <section class=\"error-messages\" style=\"color: red\">\n @if (control?.errors?.[\"required\"]) {\n <small>{{ controlName }} is required</small>\n }\n @if (control?.errors?.[\"minlength\"]) {\n <small\n >Minimum length:\n {{ getValidatorValue(\"minlength\", \"requiredLength\") }}</small\n >\n }\n @if (control?.errors?.[\"maxlength\"]) {\n <small\n >Maximum length:\n {{ getValidatorValue(\"maxlength\", \"requiredLength\") }}</small\n >\n }\n @if (control?.errors?.[\"pattern\"]) {\n <small>Invalid format</small>\n }\n @if (control?.errors?.[\"email\"]) {\n <small>Invalid email address</small>\n }\n @if (control?.errors?.[\"min\"]) {\n <small\n >Value must be at least {{ getValidatorValue(\"min\", \"min\") }}</small\n >\n }\n @if (control?.errors?.[\"max\"]) {\n <small>Value must not exceed {{ getValidatorValue(\"max\", \"max\") }}</small>\n }\n @if (control?.errors?.[\"custom\"]) {\n <small>{{ getCustomErrorMessage() }}</small>\n }\n </section>\n}\n" });
|
62
61
|
}
|
63
62
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ValidationMessagesComponent, decorators: [{
|
64
63
|
type: Component,
|
@@ -71,69 +70,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
71
70
|
type: Input
|
72
71
|
}] } });
|
73
72
|
|
74
|
-
|
75
|
-
* @component DefaultFormsComponent
|
76
|
-
* @description
|
77
|
-
* The `DefaultFormsComponent` is an Angular standalone component that provides a dynamic form generation
|
78
|
-
* based on the provided configuration. It uses reactive forms to handle form controls and their validations.
|
79
|
-
* The component is designed to be highly configurable and supports various types of form validators.
|
80
|
-
*
|
81
|
-
* @selector default-forms
|
82
|
-
* @standalone true
|
83
|
-
* @imports
|
84
|
-
* - ReactiveFormsModule
|
85
|
-
* - CommonModule
|
86
|
-
* - FormsModule
|
87
|
-
* - ValidationMessagesComponent
|
88
|
-
* @templateUrl ./default-forms.component.html
|
89
|
-
* @styleUrl ./default-forms.component.css
|
90
|
-
* @changeDetection ChangeDetectionStrategy.OnPush
|
91
|
-
*
|
92
|
-
* @input
|
93
|
-
* - `formName: string` - The name of the form.
|
94
|
-
* - `controls: FormControlConfig[]` - An array of form control configurations.
|
95
|
-
*
|
96
|
-
* @output
|
97
|
-
* - `formSubmit: EventEmitter<Record<string, any>>` - Emits the form value when the form is submitted.
|
98
|
-
*
|
99
|
-
* @class DefaultFormsComponent
|
100
|
-
* @implements OnInit
|
101
|
-
*
|
102
|
-
* @property {string} formName - The name of the form.
|
103
|
-
* @property {FormControlConfig[]} controls - The configuration for the form controls.
|
104
|
-
* @property {EventEmitter<Record<string, any>>} formSubmit - Event emitter for form submission.
|
105
|
-
* @property {FormGroup} form - The reactive form group instance.
|
106
|
-
* @property {BehaviorSubject<boolean>} formChanges$ - A subject to track form changes.
|
107
|
-
*
|
108
|
-
* @constructor
|
109
|
-
* @param {FormBuilder} fb - Angular's FormBuilder service to create form controls.
|
110
|
-
* @param {ChangeDetectorRef} cdr - Angular's ChangeDetectorRef service to manually trigger change detection.
|
111
|
-
*
|
112
|
-
* @method ngOnInit
|
113
|
-
* @description Lifecycle hook that is called after the component's view has been initialized. It initializes the form.
|
114
|
-
*
|
115
|
-
* @method initializeForm
|
116
|
-
* @description Initializes the form by creating form controls based on the provided configuration and sets up value change subscriptions.
|
117
|
-
*
|
118
|
-
* @method getValidators
|
119
|
-
* @param {FormControlConfig} control - The configuration for a form control.
|
120
|
-
* @returns {ValidatorFn[]} An array of validators for the form control.
|
121
|
-
* @description Generates an array of validators based on the provided control configuration.
|
122
|
-
*
|
123
|
-
* @method updateValidators
|
124
|
-
* @param {AbstractControl} control - The form control to update validators for.
|
125
|
-
* @param {any} value - The current value of the form control.
|
126
|
-
* @description Updates the validators for a form control based on its current value.
|
127
|
-
*
|
128
|
-
* @method shouldRequireValidation
|
129
|
-
* @param {any} value - The value to check for validation requirement.
|
130
|
-
* @returns {boolean} Whether the value requires validation.
|
131
|
-
* @description Determines if a value should require validation.
|
132
|
-
*
|
133
|
-
* @method onSubmit
|
134
|
-
* @description Handles the form submission. Marks the form as touched and dirty, validates the form, emits the form value if valid, and resets the form.
|
135
|
-
*/
|
136
|
-
class DefaultFormsComponent {
|
73
|
+
class BaseFormsComponent {
|
137
74
|
fb;
|
138
75
|
cdr;
|
139
76
|
formName = input.required();
|
@@ -161,7 +98,10 @@ class DefaultFormsComponent {
|
|
161
98
|
const formControl = this.form.get(control.name);
|
162
99
|
if (formControl) {
|
163
100
|
formControl.valueChanges.subscribe((value) => {
|
164
|
-
|
101
|
+
// Only update validators if the value actually changes
|
102
|
+
if (formControl.value !== value) {
|
103
|
+
this.updateValidators(formControl, value);
|
104
|
+
}
|
165
105
|
});
|
166
106
|
}
|
167
107
|
});
|
@@ -188,13 +128,17 @@ class DefaultFormsComponent {
|
|
188
128
|
return validators;
|
189
129
|
}
|
190
130
|
updateValidators(control, value) {
|
191
|
-
|
131
|
+
const requiresValidation = this.shouldRequireValidation(value);
|
132
|
+
// Check if the validators need to be updated
|
133
|
+
const hasRequiredValidator = control.hasValidator(Validators.required);
|
134
|
+
if (requiresValidation && !hasRequiredValidator) {
|
192
135
|
control.addValidators(Validators.required);
|
136
|
+
control.updateValueAndValidity();
|
193
137
|
}
|
194
|
-
else {
|
138
|
+
else if (!requiresValidation && hasRequiredValidator) {
|
195
139
|
control.removeValidators(Validators.required);
|
140
|
+
control.updateValueAndValidity();
|
196
141
|
}
|
197
|
-
control.updateValueAndValidity();
|
198
142
|
this.formChanges$.next(true);
|
199
143
|
}
|
200
144
|
shouldRequireValidation(value) {
|
@@ -213,18 +157,101 @@ class DefaultFormsComponent {
|
|
213
157
|
}
|
214
158
|
this.formChanges$.next(true);
|
215
159
|
}
|
216
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type:
|
217
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
160
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BaseFormsComponent, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
161
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.13", type: BaseFormsComponent, isStandalone: true, selector: "base-forms", inputs: { formName: { classPropertyName: "formName", publicName: "formName", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { formSubmit: "formSubmit" }, ngImport: i0, template: '', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: FormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
162
|
+
}
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BaseFormsComponent, decorators: [{
|
164
|
+
type: Component,
|
165
|
+
args: [{
|
166
|
+
selector: 'base-forms',
|
167
|
+
standalone: true,
|
168
|
+
imports: [
|
169
|
+
CommonModule,
|
170
|
+
ReactiveFormsModule,
|
171
|
+
FormsModule,
|
172
|
+
ValidationMessagesComponent,
|
173
|
+
],
|
174
|
+
template: '',
|
175
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
176
|
+
}]
|
177
|
+
}], ctorParameters: () => [{ type: i1.FormBuilder }, { type: i0.ChangeDetectorRef }] });
|
178
|
+
|
179
|
+
/**
|
180
|
+
* @component DefaultFormsComponent
|
181
|
+
* @description
|
182
|
+
* The `DefaultFormsComponent` is an Angular standalone component that provides a dynamic form generation
|
183
|
+
* based on the provided configuration. It uses reactive forms to handle form controls and their validations.
|
184
|
+
* The component is designed to be highly configurable and supports various types of form validators.
|
185
|
+
*
|
186
|
+
* @selector default-forms
|
187
|
+
* @standalone true
|
188
|
+
* @imports
|
189
|
+
* - ReactiveFormsModule
|
190
|
+
* - CommonModule
|
191
|
+
* - FormsModule
|
192
|
+
* - ValidationMessagesComponent
|
193
|
+
* @templateUrl ./default-forms.component.html
|
194
|
+
* @styleUrl ./default-forms.component.css
|
195
|
+
* @changeDetection ChangeDetectionStrategy.OnPush
|
196
|
+
*
|
197
|
+
* @input
|
198
|
+
* - `formName: string` - The name of the form.
|
199
|
+
* - `controls: FormControlConfig[]` - An array of form control configurations.
|
200
|
+
*
|
201
|
+
* @output
|
202
|
+
* - `formSubmit: EventEmitter<Record<string, any>>` - Emits the form value when the form is submitted.
|
203
|
+
*
|
204
|
+
* @class DefaultFormsComponent
|
205
|
+
* @implements OnInit
|
206
|
+
*
|
207
|
+
* @property {string} formName - The name of the form.
|
208
|
+
* @property {FormControlConfig[]} controls - The configuration for the form controls.
|
209
|
+
* @property {EventEmitter<Record<string, any>>} formSubmit - Event emitter for form submission.
|
210
|
+
* @property {FormGroup} form - The reactive form group instance.
|
211
|
+
* @property {BehaviorSubject<boolean>} formChanges$ - A subject to track form changes.
|
212
|
+
*
|
213
|
+
* @constructor
|
214
|
+
* @param {FormBuilder} fb - Angular's FormBuilder service to create form controls.
|
215
|
+
* @param {ChangeDetectorRef} cdr - Angular's ChangeDetectorRef service to manually trigger change detection.
|
216
|
+
*
|
217
|
+
* @method ngOnInit
|
218
|
+
* @description Lifecycle hook that is called after the component's view has been initialized. It initializes the form.
|
219
|
+
*
|
220
|
+
* @method initializeForm
|
221
|
+
* @description Initializes the form by creating form controls based on the provided configuration and sets up value change subscriptions.
|
222
|
+
*
|
223
|
+
* @method getValidators
|
224
|
+
* @param {FormControlConfig} control - The configuration for a form control.
|
225
|
+
* @returns {ValidatorFn[]} An array of validators for the form control.
|
226
|
+
* @description Generates an array of validators based on the provided control configuration.
|
227
|
+
*
|
228
|
+
* @method updateValidators
|
229
|
+
* @param {AbstractControl} control - The form control to update validators for.
|
230
|
+
* @param {any} value - The current value of the form control.
|
231
|
+
* @description Updates the validators for a form control based on its current value.
|
232
|
+
*
|
233
|
+
* @method shouldRequireValidation
|
234
|
+
* @param {any} value - The value to check for validation requirement.
|
235
|
+
* @returns {boolean} Whether the value requires validation.
|
236
|
+
* @description Determines if a value should require validation.
|
237
|
+
*
|
238
|
+
* @method onSubmit
|
239
|
+
* @description Handles the form submission. Marks the form as touched and dirty, validates the form, emits the form value if valid, and resets the form.
|
240
|
+
*/
|
241
|
+
class DefaultFormsComponent extends BaseFormsComponent {
|
242
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DefaultFormsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
243
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DefaultFormsComponent, isStandalone: true, selector: "default-forms", usesInheritance: true, ngImport: i0, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"default\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.label) {\n <label\n [attr.for]=\"control.name\"\n [ngClass]=\"control.labelClass\"\n [ngStyle]=\"control.labelStyle\"\n >\n {{ control.label }}\n </label>\n }\n\n @if (control.type === \"input\") {\n <input\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n type=\"text\"\n />\n }\n @if (control.type === \"select\") {\n <select [formControlName]=\"control.name\" [id]=\"control.name\">\n @for (option of control.options; track $index) {\n <option [value]=\"option\">{{ option }}</option>\n }\n </select>\n }\n @if (control.type === \"textarea\") {\n <textarea\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n ></textarea>\n }\n @if (control.type === \"checkbox\") {\n <input\n type=\"checkbox\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n />\n }\n @if (control.type === \"radio\") {\n @for (option of control.options ?? []; track $index) {\n <div>\n <input\n type=\"radio\"\n [formControlName]=\"control.name\"\n [id]=\"control.name + '-' + option\"\n [value]=\"option\"\n />\n <label [for]=\"control.name + '-' + option\">{{ option }}</label>\n </div>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button type=\"submit\" [disabled]=\"form.invalid\">Submit</button>\n</form>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.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: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: ValidationMessagesComponent, selector: "validation-messages", inputs: ["control", "controlName", "config"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
218
244
|
}
|
219
245
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DefaultFormsComponent, decorators: [{
|
220
246
|
type: Component,
|
221
247
|
args: [{ selector: 'default-forms', standalone: true, imports: [
|
248
|
+
BaseFormsComponent,
|
222
249
|
ReactiveFormsModule,
|
223
250
|
CommonModule,
|
224
251
|
FormsModule,
|
225
252
|
ValidationMessagesComponent,
|
226
253
|
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"default\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.label) {\n <label\n [attr.for]=\"control.name\"\n [ngClass]=\"control.labelClass\"\n [ngStyle]=\"control.labelStyle\"\n >\n {{ control.label }}\n </label>\n }\n\n @if (control.type === \"input\") {\n <input\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n type=\"text\"\n />\n }\n @if (control.type === \"select\") {\n <select [formControlName]=\"control.name\" [id]=\"control.name\">\n @for (option of control.options; track $index) {\n <option [value]=\"option\">{{ option }}</option>\n }\n </select>\n }\n @if (control.type === \"textarea\") {\n <textarea\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n ></textarea>\n }\n @if (control.type === \"checkbox\") {\n <input\n type=\"checkbox\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n />\n }\n @if (control.type === \"radio\") {\n @for (option of control.options ?? []; track $index) {\n <div>\n <input\n type=\"radio\"\n [formControlName]=\"control.name\"\n [id]=\"control.name + '-' + option\"\n [value]=\"option\"\n />\n <label [for]=\"control.name + '-' + option\">{{ option }}</label>\n </div>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button type=\"submit\" [disabled]=\"form.invalid\">Submit</button>\n</form>\n" }]
|
227
|
-
}]
|
254
|
+
}] });
|
228
255
|
|
229
256
|
/**
|
230
257
|
* @component
|
@@ -291,81 +318,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
291
318
|
* Handles the form submission. Marks all controls as touched and dirty, updates the form's validity,
|
292
319
|
* emits the form values if the form is valid, and resets the form. Triggers change detection.
|
293
320
|
*/
|
294
|
-
class MaterialFormsComponent {
|
295
|
-
|
296
|
-
|
297
|
-
formName = input.required();
|
298
|
-
controls = input.required();
|
299
|
-
formSubmit = output();
|
300
|
-
form;
|
301
|
-
constructor(fb, cdr) {
|
302
|
-
this.fb = fb;
|
303
|
-
this.cdr = cdr;
|
304
|
-
}
|
305
|
-
ngOnInit() {
|
306
|
-
this.initializeForm();
|
307
|
-
}
|
308
|
-
initializeForm() {
|
309
|
-
const formControls = {};
|
310
|
-
this.controls().forEach((control) => {
|
311
|
-
if (control.type === 'datepicker' && control.datePickerMode === 'range') {
|
312
|
-
formControls[`${control.name}_Start`] = [
|
313
|
-
control.value?.start ?? '',
|
314
|
-
this.getValidators(control),
|
315
|
-
];
|
316
|
-
formControls[`${control.name}_End`] = [
|
317
|
-
control.value?.end ?? '',
|
318
|
-
this.getValidators(control),
|
319
|
-
];
|
320
|
-
}
|
321
|
-
else {
|
322
|
-
formControls[control.name] = [
|
323
|
-
control.value ?? '',
|
324
|
-
this.getValidators(control),
|
325
|
-
];
|
326
|
-
}
|
327
|
-
});
|
328
|
-
this.form = this.fb.group(formControls);
|
329
|
-
}
|
330
|
-
getValidators(control) {
|
331
|
-
const validators = [];
|
332
|
-
if (control.validators) {
|
333
|
-
control.validators.forEach((validator) => {
|
334
|
-
if (validator.required)
|
335
|
-
validators.push(Validators.required);
|
336
|
-
if (validator.minlength)
|
337
|
-
validators.push(Validators.minLength(validator.minlength));
|
338
|
-
if (validator.maxlength)
|
339
|
-
validators.push(Validators.maxLength(validator.maxlength));
|
340
|
-
if (validator.pattern)
|
341
|
-
validators.push(Validators.pattern(validator.pattern));
|
342
|
-
if (validator.email)
|
343
|
-
validators.push(Validators.email);
|
344
|
-
if (validator.custom)
|
345
|
-
validators.push(validator.custom);
|
346
|
-
});
|
347
|
-
}
|
348
|
-
return validators;
|
349
|
-
}
|
350
|
-
onSubmit() {
|
351
|
-
this.form.markAllAsTouched();
|
352
|
-
this.form.markAsDirty();
|
353
|
-
this.form.updateValueAndValidity();
|
354
|
-
if (this.form.valid) {
|
355
|
-
this.formSubmit.emit(this.form.value);
|
356
|
-
this.form.reset();
|
357
|
-
}
|
358
|
-
else {
|
359
|
-
console.error('Form Invalid');
|
360
|
-
}
|
361
|
-
this.cdr.markForCheck();
|
362
|
-
}
|
363
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MaterialFormsComponent, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
364
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MaterialFormsComponent, isStandalone: true, selector: "material-forms", inputs: { formName: { classPropertyName: "formName", publicName: "formName", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { formSubmit: "formSubmit" }, providers: [provideNativeDateAdapter()], ngImport: i0, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"material\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.type === \"input\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <input\n matInput\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n type=\"text\"\n />\n </mat-form-field>\n }\n @if (control.type === \"select\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <mat-select [formControlName]=\"control.name\" [id]=\"control.name\">\n @for (option of control.options ?? []; track $index) {\n <mat-option [value]=\"option\">{{ option }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n @if (control.type === \"checkbox\") {\n <mat-checkbox [formControlName]=\"control.name\" [id]=\"control.name\">\n {{ control.label }}\n </mat-checkbox>\n }\n @if (control.type === \"radio\") {\n @for (option of control.options ?? []; track $index) {\n <mat-radio-group [formControlName]=\"control.name\">\n <mat-radio-button\n [id]=\"control.name + '-' + option\"\n [value]=\"option\"\n >\n {{ option }}\n </mat-radio-button>\n </mat-radio-group>\n }\n }\n @if (control.type === \"datepicker\") {\n @if (control.datePickerMode === \"single\") {\n <mat-form-field appearance=\"outline\">\n <mat-label>Choose a date</mat-label>\n <input\n matInput\n [matDatepicker]=\"datepicker\"\n [formControlName]=\"control.name\"\n />\n <mat-datepicker-toggle\n matIconSuffix\n [for]=\"datepicker\"\n ></mat-datepicker-toggle>\n <mat-datepicker #datepicker></mat-datepicker>\n </mat-form-field>\n } @else if (control.datePickerMode === \"range\") {\n <mat-form-field>\n <mat-label>Enter a date range</mat-label>\n <mat-date-range-input\n [rangePicker]=\"picker\"\n [formGroup]=\"form\"\n ]\n >\n <input\n matStartDate\n formControlName=\"{{ control.name }}_Start\"\n placeholder=\"Start date\"\n />\n <input\n matEndDate\n formControlName=\"{{ control.name }}_End\"\n placeholder=\"End date\"\n />\n </mat-date-range-input>\n <mat-datepicker-toggle\n matIconSuffix\n [for]=\"picker\"\n ></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <!-- @if (form.controls.start.hasError('matStartDateInvalid')) {\n <mat-error>Invalid start date</mat-error>\n }\n @if (form.controls.end.hasError('matEndDateInvalid')) {\n <mat-error>Invalid end date</mat-error>\n } -->\n </mat-form-field>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button\n mat-raised-button\n color=\"primary\"\n type=\"submit\"\n [disabled]=\"form.invalid\"\n >\n Submit\n </button>\n</form>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i5.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i6.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i7.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatRadioModule }, { kind: "directive", type: i8.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i8.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color"], outputs: ["change"], exportAs: ["matRadioButton"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i9.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: ValidationMessagesComponent, selector: "validation-messages", inputs: ["control", "controlName", "config"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i10.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i10.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i10.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "component", type: i10.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { kind: "directive", type: i10.MatStartDate, selector: "input[matStartDate]", outputs: ["dateChange", "dateInput"] }, { kind: "directive", type: i10.MatEndDate, selector: "input[matEndDate]", outputs: ["dateChange", "dateInput"] }, { kind: "component", type: i10.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }, { kind: "ngmodule", type: MatFormFieldModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
321
|
+
class MaterialFormsComponent extends BaseFormsComponent {
|
322
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MaterialFormsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
323
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MaterialFormsComponent, isStandalone: true, selector: "material-forms", providers: [provideNativeDateAdapter()], usesInheritance: true, ngImport: i0, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"material\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.type === \"input\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <input matInput [formControlName]=\"control.name\" [id]=\"control.name\" type=\"text\" />\n </mat-form-field>\n }\n @if (control.type === \"select\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <mat-select [formControlName]=\"control.name\" [id]=\"control.name\">\n @for (option of control.options ?? []; track $index) {\n <mat-option [value]=\"option\">{{ option }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n @if (control.type === \"checkbox\") {\n <mat-checkbox [formControlName]=\"control.name\" [id]=\"control.name\">\n {{ control.label }}\n </mat-checkbox>\n }\n @if (control.type === \"radio\") {\n <mat-radio-group [formControlName]=\"control.name\">\n @for (option of control.options ?? []; track $index) {\n <mat-radio-button [id]=\"control.name + '-' + option\" [value]=\"option\">\n {{ option }}\n </mat-radio-button>\n }\n </mat-radio-group>\n }\n @if (control.type === \"datepicker\") {\n @if (control.datePickerMode === \"single\") {\n <mat-form-field appearance=\"outline\">\n <mat-label>Choose a date</mat-label>\n <input matInput [matDatepicker]=\"datepicker\" [formControlName]=\"control.name\" />\n <mat-datepicker-toggle matIconSuffix [for]=\"datepicker\"></mat-datepicker-toggle>\n <mat-datepicker #datepicker></mat-datepicker>\n </mat-form-field>\n } @else if (control.datePickerMode === \"range\") {\n <mat-form-field>\n <mat-label>Enter a date range</mat-label>\n <mat-date-range-input [rangePicker]=\"picker\" [formGroup]=\"form\" ]>\n <input matStartDate formControlName=\"{{ control.name }}_Start\" placeholder=\"Start date\" />\n <input matEndDate formControlName=\"{{ control.name }}_End\" placeholder=\"End date\" />\n </mat-date-range-input>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <!-- @if (form.controls.start.hasError('matStartDateInvalid')) {\n <mat-error>Invalid start date</mat-error>\n }\n @if (form.controls.end.hasError('matEndDateInvalid')) {\n <mat-error>Invalid end date</mat-error>\n } -->\n </mat-form-field>\n }\n }\n\n <validation-messages [control]=\"form.get(control.name)\" [controlName]=\"control.name\"\n [config]=\"control\"></validation-messages>\n </section>\n }\n }\n }\n <button mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"form.invalid\">\n Submit\n </button>\n</form>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i5.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i6.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i7.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatRadioModule }, { kind: "directive", type: i8.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i8.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioButton"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i9.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: ValidationMessagesComponent, selector: "validation-messages", inputs: ["control", "controlName", "config"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i10.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i10.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i10.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "component", type: i10.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { kind: "directive", type: i10.MatStartDate, selector: "input[matStartDate]", outputs: ["dateChange", "dateInput"] }, { kind: "directive", type: i10.MatEndDate, selector: "input[matEndDate]", outputs: ["dateChange", "dateInput"] }, { kind: "component", type: i10.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }, { kind: "ngmodule", type: MatFormFieldModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
365
324
|
}
|
366
325
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MaterialFormsComponent, decorators: [{
|
367
326
|
type: Component,
|
368
327
|
args: [{ selector: 'material-forms', standalone: true, imports: [
|
328
|
+
BaseFormsComponent,
|
369
329
|
CommonModule,
|
370
330
|
ReactiveFormsModule,
|
371
331
|
MatInputModule,
|
@@ -376,56 +336,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
376
336
|
ValidationMessagesComponent,
|
377
337
|
MatDatepickerModule,
|
378
338
|
MatFormFieldModule,
|
379
|
-
], providers: [provideNativeDateAdapter()], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n
|
380
|
-
}]
|
381
|
-
|
382
|
-
class FileUploadValueAccessor {
|
383
|
-
host;
|
384
|
-
constructor(host) {
|
385
|
-
this.host = host;
|
386
|
-
}
|
387
|
-
writeValue(value) {
|
388
|
-
if (value) {
|
389
|
-
this.host.files = value;
|
390
|
-
}
|
391
|
-
else {
|
392
|
-
this.host.clear();
|
393
|
-
}
|
394
|
-
}
|
395
|
-
registerOnChange(fn) {
|
396
|
-
this.host.onUpload.subscribe((event) => {
|
397
|
-
fn(event.files);
|
398
|
-
});
|
399
|
-
}
|
400
|
-
registerOnTouched(fn) {
|
401
|
-
// this.host.onBlur.subscribe(fn);
|
402
|
-
}
|
403
|
-
setDisabledState(isDisabled) {
|
404
|
-
this.host.disabled = isDisabled;
|
405
|
-
}
|
406
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FileUploadValueAccessor, deps: [{ token: i1$1.FileUpload }], target: i0.ɵɵFactoryTarget.Directive });
|
407
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: FileUploadValueAccessor, isStandalone: true, selector: "p-fileUpload[formControlName], p-fileUpload[formControl], p-fileUpload[ngModel]", providers: [
|
408
|
-
{
|
409
|
-
provide: NG_VALUE_ACCESSOR,
|
410
|
-
useExisting: forwardRef(() => FileUploadValueAccessor),
|
411
|
-
multi: true,
|
412
|
-
},
|
413
|
-
], ngImport: i0 });
|
414
|
-
}
|
415
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FileUploadValueAccessor, decorators: [{
|
416
|
-
type: Directive,
|
417
|
-
args: [{
|
418
|
-
standalone: true,
|
419
|
-
selector: 'p-fileUpload[formControlName], p-fileUpload[formControl], p-fileUpload[ngModel]',
|
420
|
-
providers: [
|
421
|
-
{
|
422
|
-
provide: NG_VALUE_ACCESSOR,
|
423
|
-
useExisting: forwardRef(() => FileUploadValueAccessor),
|
424
|
-
multi: true,
|
425
|
-
},
|
426
|
-
],
|
427
|
-
}]
|
428
|
-
}], ctorParameters: () => [{ type: i1$1.FileUpload }] });
|
339
|
+
], providers: [provideNativeDateAdapter()], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"material\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.type === \"input\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <input matInput [formControlName]=\"control.name\" [id]=\"control.name\" type=\"text\" />\n </mat-form-field>\n }\n @if (control.type === \"select\") {\n <mat-form-field appearance=\"outline\">\n @if (control.label) {\n <mat-label>{{ control.label }}</mat-label>\n }\n <mat-select [formControlName]=\"control.name\" [id]=\"control.name\">\n @for (option of control.options ?? []; track $index) {\n <mat-option [value]=\"option\">{{ option }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n @if (control.type === \"checkbox\") {\n <mat-checkbox [formControlName]=\"control.name\" [id]=\"control.name\">\n {{ control.label }}\n </mat-checkbox>\n }\n @if (control.type === \"radio\") {\n <mat-radio-group [formControlName]=\"control.name\">\n @for (option of control.options ?? []; track $index) {\n <mat-radio-button [id]=\"control.name + '-' + option\" [value]=\"option\">\n {{ option }}\n </mat-radio-button>\n }\n </mat-radio-group>\n }\n @if (control.type === \"datepicker\") {\n @if (control.datePickerMode === \"single\") {\n <mat-form-field appearance=\"outline\">\n <mat-label>Choose a date</mat-label>\n <input matInput [matDatepicker]=\"datepicker\" [formControlName]=\"control.name\" />\n <mat-datepicker-toggle matIconSuffix [for]=\"datepicker\"></mat-datepicker-toggle>\n <mat-datepicker #datepicker></mat-datepicker>\n </mat-form-field>\n } @else if (control.datePickerMode === \"range\") {\n <mat-form-field>\n <mat-label>Enter a date range</mat-label>\n <mat-date-range-input [rangePicker]=\"picker\" [formGroup]=\"form\" ]>\n <input matStartDate formControlName=\"{{ control.name }}_Start\" placeholder=\"Start date\" />\n <input matEndDate formControlName=\"{{ control.name }}_End\" placeholder=\"End date\" />\n </mat-date-range-input>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-date-range-picker #picker></mat-date-range-picker>\n\n <!-- @if (form.controls.start.hasError('matStartDateInvalid')) {\n <mat-error>Invalid start date</mat-error>\n }\n @if (form.controls.end.hasError('matEndDateInvalid')) {\n <mat-error>Invalid end date</mat-error>\n } -->\n </mat-form-field>\n }\n }\n\n <validation-messages [control]=\"form.get(control.name)\" [controlName]=\"control.name\"\n [config]=\"control\"></validation-messages>\n </section>\n }\n }\n }\n <button mat-raised-button color=\"primary\" type=\"submit\" [disabled]=\"form.invalid\">\n Submit\n </button>\n</form>" }]
|
340
|
+
}] });
|
429
341
|
|
430
342
|
/**
|
431
343
|
* PrimeNgFormsComponent is a standalone Angular component that dynamically generates
|
@@ -482,112 +394,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
482
394
|
* @param {string} controlName - The name of the form control.
|
483
395
|
* @method onSubmit - Handles form submission, validates the form, and emits the form value.
|
484
396
|
*/
|
485
|
-
class PrimeNgFormsComponent {
|
486
|
-
fb;
|
487
|
-
cdr;
|
488
|
-
formName = input.required();
|
489
|
-
controls = input.required();
|
490
|
-
formSubmit = output();
|
491
|
-
form;
|
492
|
-
formChanges$ = new BehaviorSubject(false);
|
493
|
-
constructor(fb, cdr) {
|
494
|
-
this.fb = fb;
|
495
|
-
this.cdr = cdr;
|
496
|
-
}
|
497
|
-
ngOnInit() {
|
498
|
-
this.initializeForm();
|
499
|
-
}
|
500
|
-
initializeForm() {
|
501
|
-
const formControls = {};
|
502
|
-
this.controls().forEach((control) => {
|
503
|
-
formControls[control.name] = [
|
504
|
-
control.value ?? null,
|
505
|
-
this.getValidators(control),
|
506
|
-
];
|
507
|
-
});
|
508
|
-
this.form = this.fb.group(formControls);
|
509
|
-
this.controls().forEach((control) => {
|
510
|
-
const formControl = this.form.get(control.name);
|
511
|
-
if (formControl) {
|
512
|
-
formControl.valueChanges.subscribe((value) => {
|
513
|
-
this.updateValidators(formControl, value);
|
514
|
-
});
|
515
|
-
}
|
516
|
-
});
|
517
|
-
this.formChanges$.subscribe(() => this.cdr.markForCheck());
|
518
|
-
}
|
519
|
-
getValidators(control) {
|
520
|
-
const validators = [];
|
521
|
-
if (control.validators) {
|
522
|
-
control.validators.forEach((validator) => {
|
523
|
-
if (validator.required)
|
524
|
-
validators.push(Validators.required);
|
525
|
-
if (validator.minlength)
|
526
|
-
validators.push(Validators.minLength(validator.minlength));
|
527
|
-
if (validator.maxlength)
|
528
|
-
validators.push(Validators.maxLength(validator.maxlength));
|
529
|
-
if (validator.pattern)
|
530
|
-
validators.push(Validators.pattern(validator.pattern));
|
531
|
-
if (validator.email)
|
532
|
-
validators.push(Validators.email);
|
533
|
-
if (validator.custom)
|
534
|
-
validators.push(validator.custom);
|
535
|
-
});
|
536
|
-
}
|
537
|
-
return validators;
|
538
|
-
}
|
539
|
-
updateValidators(control, value) {
|
540
|
-
if (this.shouldRequireValidation(value)) {
|
541
|
-
control.addValidators(Validators.required);
|
542
|
-
}
|
543
|
-
else {
|
544
|
-
control.removeValidators(Validators.required);
|
545
|
-
}
|
546
|
-
control.updateValueAndValidity();
|
547
|
-
this.formChanges$.next(true);
|
548
|
-
}
|
549
|
-
shouldRequireValidation(value) {
|
550
|
-
return value !== null && value !== '';
|
551
|
-
}
|
397
|
+
class PrimeNgFormsComponent extends BaseFormsComponent {
|
552
398
|
onFileSelect(event, controlName) {
|
553
|
-
const file = event.files[0];
|
399
|
+
const file = event.files[0];
|
554
400
|
if (file) {
|
555
|
-
console.log(`Selected file for ${controlName}:`, file);
|
556
|
-
console.log(this.form.get(controlName)?.value);
|
557
401
|
this.form.get(controlName)?.setValue(file);
|
558
|
-
|
559
|
-
this.
|
560
|
-
// Emit the onUpload event if defined
|
561
|
-
const controlConfig = this.controls().find(control => control.name === controlName);
|
402
|
+
this.form.get(controlName)?.updateValueAndValidity();
|
403
|
+
const controlConfig = this.controls().find((control) => control.name === controlName);
|
562
404
|
if (controlConfig?.events?.onUpload) {
|
563
405
|
controlConfig.events.onUpload(event);
|
564
406
|
}
|
565
407
|
}
|
566
408
|
}
|
567
|
-
|
568
|
-
this.form.markAllAsTouched();
|
569
|
-
this.form.markAsDirty();
|
570
|
-
this.form.updateValueAndValidity();
|
571
|
-
if (this.form.valid) {
|
572
|
-
this.formSubmit.emit(this.form.value);
|
573
|
-
this.form.reset();
|
574
|
-
// Clear the file input
|
575
|
-
const fileInput = document.querySelector('input[type="file"]');
|
576
|
-
if (fileInput) {
|
577
|
-
fileInput.value = '';
|
578
|
-
}
|
579
|
-
}
|
580
|
-
else {
|
581
|
-
console.error('Form Invalid');
|
582
|
-
}
|
583
|
-
this.formChanges$.next(true);
|
584
|
-
}
|
585
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PrimeNgFormsComponent, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
586
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: PrimeNgFormsComponent, isStandalone: true, selector: "primeng-forms", inputs: { formName: { classPropertyName: "formName", publicName: "formName", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { formSubmit: "formSubmit" }, ngImport: i0, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"primeng\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.label) {\n <label\n [attr.for]=\"control.name\"\n [ngClass]=\"control.labelClass\"\n [ngStyle]=\"control.labelStyle\"\n >\n {{ control.label }}\n </label>\n }\n\n @switch (control.type) {\n @case (\"text\") {\n <input\n pInputText\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"number\") {\n <input\n pInputText\n type=\"number\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"password\") {\n <input\n pInputText\n type=\"password\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"email\") {\n <input\n pInputText\n type=\"email\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"select\") {\n <p-select\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"multi-select\") {\n <p-multiSelect\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-multiSelect>\n }\n @case (\"textarea\") {\n <textarea\n pTextarea\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n ></textarea>\n }\n @case (\"checkbox\") {\n <p-checkbox\n [binary]=\"true\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-checkbox>\n }\n @case (\"radio\") {\n @for (option of control.options ?? []; track $index) {\n <div>\n <p-radioButton\n [name]=\"control.name\"\n [formControlName]=\"control.name\"\n [value]=\"option\"\n [inputId]=\"'radio-' + option\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-radioButton>\n <label [for]=\"'radio-' + option\">{{ option }}</label>\n </div>\n }\n }\n @case (\"date\") {\n <p-datepicker\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"toggle\") {\n <p-toggleButton\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-toggleButton>\n }\n <!-- @case (\"file\") {\n <p-fileUpload \n [customUpload]=\"true\"\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n\n <p-fileUpload\n [customUpload]=\"true\"\n (onUpload)=\"onFileSelect($event, control.name)\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n [chooseLabel]=\"control.primeng?.chooseLabel\"\n [uploadLabel]=\"control.primeng?.uploadLabel\"\n [cancelLabel]=\"control.primeng?.cancelLabel\"\n [auto]=\"control.primeng?.auto\"\n [url]=\"control.primeng?.url\"\n [withCredentials]=\"control.primeng?.withCredentials\"\n [multiple]=\"control.primeng?.multiple\"\n [maxFileSize]=\"control.primeng?.maxFileSize\"\n [customUpload]=\"control.primeng?.customUpload\"\n [showUploadButton]=\"control.primeng?.showUploadButton\"\n [showCancelButton]=\"control.primeng?.showCancelButton\"\n [accept]=\"control.primeng?.accept\"\n [mode]=\"control.primeng?.mode\"\n [previewWidth]=\"control.primeng?.previewWidth\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n <ng-template pTemplate=\"content\">\n <p-button label=\"Choose File\" icon=\"pi pi-upload\"></p-button>\n </ng-template>\n </p-fileUpload>\n } -->\n @case (\"slider\") {\n <p-slider\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onSlideEnd)=\"control.events?.onSlideEnd?.($event)\"\n ></p-slider>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button\n pButton\n type=\"submit\"\n [disabled]=\"form.invalid\"\n label=\"Submit\"\n ></button>\n</form>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.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: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: ValidationMessagesComponent, selector: "validation-messages", inputs: ["control", "controlName", "config"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i3$1.InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }, { kind: "ngmodule", type: MultiSelectModule }, { kind: "component", type: i4$1.MultiSelect, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: ["id", "ariaLabel", "style", "styleClass", "panelStyle", "panelStyleClass", "inputId", "disabled", "fluid", "readonly", "group", "filter", "filterPlaceHolder", "filterLocale", "overlayVisible", "tabindex", "variant", "appendTo", "dataKey", "name", "ariaLabelledBy", "displaySelectedLabel", "maxSelectedLabels", "selectionLimit", "selectedItemsLabel", "showToggleAll", "emptyFilterMessage", "emptyMessage", "resetFilterOnHide", "dropdownIcon", "chipIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "showHeader", "filterBy", "scrollHeight", "lazy", "virtualScroll", "loading", "virtualScrollItemSize", "loadingIcon", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "display", "autocomplete", "size", "showClear", "autofocus", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "defaultLabel", "placeholder", "options", "filterValue", "itemSize", "selectAll", "focusOnHover", "filterFields", "selectOnFocus", "autoOptionFocus"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onClear", "onPanelShow", "onPanelHide", "onLazyLoad", "onRemove", "onSelectAllChange"] }, { kind: "ngmodule", type: TextareaModule }, { kind: "directive", type: i5$1.Textarea, selector: "[pTextarea]", inputs: ["autoResize", "variant", "fluid", "pSize"], outputs: ["onResize"] }, { kind: "ngmodule", type: CheckboxModule }, { kind: "component", type: i6$1.Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["value", "name", "disabled", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "style", "inputStyle", "styleClass", "inputClass", "indeterminate", "size", "formControl", "checkboxIcon", "readonly", "required", "autofocus", "trueValue", "falseValue", "variant"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: RadioButtonModule }, { kind: "component", type: i7$1.RadioButton, selector: "p-radioButton, p-radiobutton, p-radio-button", inputs: ["value", "formControlName", "name", "disabled", "variant", "size", "tabindex", "inputId", "ariaLabelledBy", "ariaLabel", "style", "styleClass", "autofocus", "binary"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: DatePickerModule }, { kind: "component", type: i8$1.DatePicker, selector: "p-datePicker, p-datepicker, p-date-picker", inputs: ["iconDisplay", "style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "fluid", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "variant", "size", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "locale", "view", "defaultDate"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { kind: "ngmodule", type: ToggleButtonModule }, { kind: "component", type: i9$1.ToggleButton, selector: "p-toggleButton, p-togglebutton, p-toggle-button", inputs: ["onLabel", "offLabel", "onIcon", "offIcon", "ariaLabel", "ariaLabelledBy", "disabled", "style", "styleClass", "inputId", "tabindex", "size", "iconPos", "autofocus", "allowEmpty"], outputs: ["onChange"] }, { kind: "ngmodule", type: FileUploadModule }, { kind: "ngmodule", type: SliderModule }, { kind: "component", type: i10$1.Slider, selector: "p-slider", inputs: ["animate", "disabled", "min", "max", "orientation", "step", "range", "style", "styleClass", "ariaLabel", "ariaLabelledBy", "tabindex", "autofocus"], outputs: ["onChange", "onSlideEnd"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i11.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i12.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "size", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
409
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PrimeNgFormsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
410
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: PrimeNgFormsComponent, isStandalone: true, selector: "primeng-forms", usesInheritance: true, ngImport: i0, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"primeng\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.label) {\n <label\n [attr.for]=\"control.name\"\n [ngClass]=\"control.labelClass\"\n [ngStyle]=\"control.labelStyle\"\n >\n {{ control.label }}\n </label>\n }\n\n @switch (control.type) {\n @case (\"text\") {\n <input\n pInputText\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"number\") {\n <input\n pInputText\n type=\"number\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"password\") {\n <input\n pInputText\n type=\"password\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"email\") {\n <input\n pInputText\n type=\"email\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"select\") {\n <p-select\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"multi-select\") {\n <p-multiSelect\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-multiSelect>\n }\n @case (\"textarea\") {\n <textarea\n pTextarea\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n ></textarea>\n }\n @case (\"checkbox\") {\n <p-checkbox\n [binary]=\"true\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-checkbox>\n }\n @case (\"radio\") {\n @for (option of control.options ?? []; track $index) {\n <div>\n <p-radioButton\n [name]=\"control.name\"\n [formControlName]=\"control.name\"\n [value]=\"option\"\n [inputId]=\"'radio-' + option\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-radioButton>\n <label [for]=\"'radio-' + option\">{{ option }}</label>\n </div>\n }\n }\n @case (\"date\") {\n <p-datepicker\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"toggle\") {\n <p-toggleButton\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-toggleButton>\n }\n <!-- @case (\"file\") {\n <p-fileUpload \n [customUpload]=\"true\"\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n\n <p-fileUpload\n [customUpload]=\"true\"\n (onUpload)=\"onFileSelect($event, control.name)\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n [chooseLabel]=\"control.primeng?.chooseLabel\"\n [uploadLabel]=\"control.primeng?.uploadLabel\"\n [cancelLabel]=\"control.primeng?.cancelLabel\"\n [auto]=\"control.primeng?.auto\"\n [url]=\"control.primeng?.url\"\n [withCredentials]=\"control.primeng?.withCredentials\"\n [multiple]=\"control.primeng?.multiple\"\n [maxFileSize]=\"control.primeng?.maxFileSize\"\n [customUpload]=\"control.primeng?.customUpload\"\n [showUploadButton]=\"control.primeng?.showUploadButton\"\n [showCancelButton]=\"control.primeng?.showCancelButton\"\n [accept]=\"control.primeng?.accept\"\n [mode]=\"control.primeng?.mode\"\n [previewWidth]=\"control.primeng?.previewWidth\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n <ng-template pTemplate=\"content\">\n <p-button label=\"Choose File\" icon=\"pi pi-upload\"></p-button>\n </ng-template>\n </p-fileUpload>\n } -->\n @case (\"slider\") {\n <p-slider\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onSlideEnd)=\"control.events?.onSlideEnd?.($event)\"\n ></p-slider>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button\n pButton\n type=\"submit\"\n [disabled]=\"form.invalid\"\n label=\"Submit\"\n ></button>\n</form>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.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: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: ValidationMessagesComponent, selector: "validation-messages", inputs: ["control", "controlName", "config"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i3$1.InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }, { kind: "ngmodule", type: MultiSelectModule }, { kind: "component", type: i4$1.MultiSelect, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: ["id", "ariaLabel", "style", "styleClass", "panelStyle", "panelStyleClass", "inputId", "disabled", "fluid", "readonly", "group", "filter", "filterPlaceHolder", "filterLocale", "overlayVisible", "tabindex", "variant", "appendTo", "dataKey", "name", "ariaLabelledBy", "displaySelectedLabel", "maxSelectedLabels", "selectionLimit", "selectedItemsLabel", "showToggleAll", "emptyFilterMessage", "emptyMessage", "resetFilterOnHide", "dropdownIcon", "chipIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "showHeader", "filterBy", "scrollHeight", "lazy", "virtualScroll", "loading", "virtualScrollItemSize", "loadingIcon", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "display", "autocomplete", "size", "showClear", "autofocus", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "defaultLabel", "placeholder", "options", "filterValue", "itemSize", "selectAll", "focusOnHover", "filterFields", "selectOnFocus", "autoOptionFocus"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onClear", "onPanelShow", "onPanelHide", "onLazyLoad", "onRemove", "onSelectAllChange"] }, { kind: "ngmodule", type: TextareaModule }, { kind: "directive", type: i5$1.Textarea, selector: "[pTextarea]", inputs: ["autoResize", "variant", "fluid", "pSize"], outputs: ["onResize"] }, { kind: "ngmodule", type: CheckboxModule }, { kind: "component", type: i6$1.Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["value", "name", "disabled", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "style", "inputStyle", "styleClass", "inputClass", "indeterminate", "size", "formControl", "checkboxIcon", "readonly", "required", "autofocus", "trueValue", "falseValue", "variant"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: RadioButtonModule }, { kind: "component", type: i7$1.RadioButton, selector: "p-radioButton, p-radiobutton, p-radio-button", inputs: ["value", "formControlName", "name", "disabled", "variant", "size", "tabindex", "inputId", "ariaLabelledBy", "ariaLabel", "style", "styleClass", "autofocus", "binary"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: DatePickerModule }, { kind: "component", type: i8$1.DatePicker, selector: "p-datePicker, p-datepicker, p-date-picker", inputs: ["iconDisplay", "style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "fluid", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "variant", "size", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "locale", "view", "defaultDate"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { kind: "ngmodule", type: ToggleButtonModule }, { kind: "component", type: i9$1.ToggleButton, selector: "p-toggleButton, p-togglebutton, p-toggle-button", inputs: ["onLabel", "offLabel", "onIcon", "offIcon", "ariaLabel", "ariaLabelledBy", "disabled", "style", "styleClass", "inputId", "tabindex", "size", "iconPos", "autofocus", "allowEmpty"], outputs: ["onChange"] }, { kind: "ngmodule", type: FileUploadModule }, { kind: "ngmodule", type: SliderModule }, { kind: "component", type: i10$1.Slider, selector: "p-slider", inputs: ["animate", "disabled", "min", "max", "orientation", "step", "range", "style", "styleClass", "ariaLabel", "ariaLabelledBy", "tabindex", "autofocus"], outputs: ["onChange", "onSlideEnd"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i11.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i12.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "size", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
587
411
|
}
|
588
412
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PrimeNgFormsComponent, decorators: [{
|
589
413
|
type: Component,
|
590
414
|
args: [{ selector: 'primeng-forms', standalone: true, imports: [
|
415
|
+
BaseFormsComponent,
|
591
416
|
CommonModule,
|
592
417
|
FormsModule,
|
593
418
|
ReactiveFormsModule,
|
@@ -603,9 +428,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
603
428
|
SliderModule,
|
604
429
|
ButtonModule,
|
605
430
|
SelectModule,
|
606
|
-
FileUploadValueAccessor
|
607
431
|
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\" [attr.name]=\"formName()\" (ngSubmit)=\"onSubmit()\">\n @for (control of controls(); track $index) {\n @if (control.uiFramework === \"primeng\" || !control.uiFramework) {\n @if (form.get(control.name)) {\n <section [ngClass]=\"control.class\" [ngStyle]=\"control.style\">\n @if (control.label) {\n <label\n [attr.for]=\"control.name\"\n [ngClass]=\"control.labelClass\"\n [ngStyle]=\"control.labelStyle\"\n >\n {{ control.label }}\n </label>\n }\n\n @switch (control.type) {\n @case (\"text\") {\n <input\n pInputText\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"number\") {\n <input\n pInputText\n type=\"number\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"password\") {\n <input\n pInputText\n type=\"password\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"email\") {\n <input\n pInputText\n type=\"email\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n />\n }\n @case (\"select\") {\n <p-select\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"multi-select\") {\n <p-multiSelect\n [options]=\"control.options\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-multiSelect>\n }\n @case (\"textarea\") {\n <textarea\n pTextarea\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n (change)=\"control.events?.onChange?.($event)\"\n (focus)=\"control.events?.onFocus?.($event)\"\n (blur)=\"control.events?.onBlur?.($event)\"\n (keyup)=\"control.events?.onKeyUp?.($event)\"\n (keydown)=\"control.events?.onKeyDown?.($event)\"\n (paste)=\"control.events?.onPaste?.($event)\"\n ></textarea>\n }\n @case (\"checkbox\") {\n <p-checkbox\n [binary]=\"true\"\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-checkbox>\n }\n @case (\"radio\") {\n @for (option of control.options ?? []; track $index) {\n <div>\n <p-radioButton\n [name]=\"control.name\"\n [formControlName]=\"control.name\"\n [value]=\"option\"\n [inputId]=\"'radio-' + option\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-radioButton>\n <label [for]=\"'radio-' + option\">{{ option }}</label>\n </div>\n }\n }\n @case (\"date\") {\n <p-datepicker\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n />\n }\n @case (\"toggle\") {\n <p-toggleButton\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onFocus)=\"control.events?.onFocus?.($event)\"\n (onBlur)=\"control.events?.onBlur?.($event)\"\n ></p-toggleButton>\n }\n <!-- @case (\"file\") {\n <p-fileUpload \n [customUpload]=\"true\"\n [formControlName]=\"control.name\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n\n <p-fileUpload\n [customUpload]=\"true\"\n (onUpload)=\"onFileSelect($event, control.name)\"\n [formControlName]=\"control.name\"\n [id]=\"control.name\"\n [chooseLabel]=\"control.primeng?.chooseLabel\"\n [uploadLabel]=\"control.primeng?.uploadLabel\"\n [cancelLabel]=\"control.primeng?.cancelLabel\"\n [auto]=\"control.primeng?.auto\"\n [url]=\"control.primeng?.url\"\n [withCredentials]=\"control.primeng?.withCredentials\"\n [multiple]=\"control.primeng?.multiple\"\n [maxFileSize]=\"control.primeng?.maxFileSize\"\n [customUpload]=\"control.primeng?.customUpload\"\n [showUploadButton]=\"control.primeng?.showUploadButton\"\n [showCancelButton]=\"control.primeng?.showCancelButton\"\n [accept]=\"control.primeng?.accept\"\n [mode]=\"control.primeng?.mode\"\n [previewWidth]=\"control.primeng?.previewWidth\"\n (onSelect)=\"control.events?.onSelect?.($event)\"\n (onClear)=\"control.events?.onClear?.($event)\"\n (onRemove)=\"control.events?.onRemove?.($event)\"\n (onError)=\"control.events?.onError?.($event)\"\n (onBeforeUpload)=\"control.events?.onBeforeUpload?.($event)\"\n (onProgress)=\"control.events?.onProgress?.($event)\"\n (onUpload)=\"control.events?.onUpload?.($event)\"\n >\n <ng-template pTemplate=\"content\">\n <p-button label=\"Choose File\" icon=\"pi pi-upload\"></p-button>\n </ng-template>\n </p-fileUpload>\n } -->\n @case (\"slider\") {\n <p-slider\n [formControlName]=\"control.name\"\n (onChange)=\"control.events?.onChange?.($event)\"\n (onSlideEnd)=\"control.events?.onSlideEnd?.($event)\"\n ></p-slider>\n }\n }\n\n <validation-messages\n [control]=\"form.get(control.name)\"\n [controlName]=\"control.name\"\n [config]=\"control\"\n ></validation-messages>\n </section>\n }\n }\n }\n <button\n pButton\n type=\"submit\"\n [disabled]=\"form.invalid\"\n label=\"Submit\"\n ></button>\n</form>\n" }]
|
608
|
-
}]
|
432
|
+
}] });
|
609
433
|
|
610
434
|
/**
|
611
435
|
* Generated bundle index. Do not edit.
|