@abp/ng.components 10.0.3 → 10.1.0-rc.2
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/fesm2022/abp-ng.components-chart.js.mjs +7 -7
- package/fesm2022/abp-ng.components-chart.js.mjs.map +1 -1
- package/fesm2022/abp-ng.components-dynamic-form.mjs +635 -0
- package/fesm2022/abp-ng.components-dynamic-form.mjs.map +1 -0
- package/fesm2022/abp-ng.components-extensible.mjs +53 -53
- package/fesm2022/abp-ng.components-extensible.mjs.map +1 -1
- package/fesm2022/abp-ng.components-lookup.mjs +107 -0
- package/fesm2022/abp-ng.components-lookup.mjs.map +1 -0
- package/fesm2022/abp-ng.components-page.mjs +19 -19
- package/fesm2022/abp-ng.components-page.mjs.map +1 -1
- package/fesm2022/abp-ng.components-tree.mjs +14 -14
- package/fesm2022/abp-ng.components-tree.mjs.map +1 -1
- package/fesm2022/abp-ng.components.mjs.map +1 -1
- package/package.json +20 -12
- package/types/abp-ng.components-dynamic-form.d.ts +200 -0
- package/{extensible/index.d.ts → types/abp-ng.components-extensible.d.ts} +2 -2
- package/types/abp-ng.components-lookup.d.ts +46 -0
- /package/{chart.js/index.d.ts → types/abp-ng.components-chart.js.d.ts} +0 -0
- /package/{page/index.d.ts → types/abp-ng.components-page.d.ts} +0 -0
- /package/{tree/index.d.ts → types/abp-ng.components-tree.d.ts} +0 -0
- /package/{index.d.ts → types/abp-ng.components.d.ts} +0 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable, InjectionToken, forwardRef, input, ChangeDetectorRef, DestroyRef, Injector, ChangeDetectionStrategy, Component, effect, ViewContainerRef, ViewChild, output } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/forms';
|
|
4
|
+
import { FormBuilder, FormControl, Validators, NG_VALUE_ACCESSOR, NgControl, FormGroupDirective, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import * as i1 from '@angular/common';
|
|
6
|
+
import { NgTemplateOutlet, AsyncPipe, CommonModule } from '@angular/common';
|
|
7
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
|
+
import { RestService, LocalizationPipe } from '@abp/ng.core';
|
|
9
|
+
import { FormCheckboxComponent } from '@abp/ng.theme.shared';
|
|
10
|
+
import { of } from 'rxjs';
|
|
11
|
+
|
|
12
|
+
class DynamicFormService {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.formBuilder = inject(FormBuilder);
|
|
15
|
+
this.restService = inject(RestService);
|
|
16
|
+
this.apiName = 'DynamicFormService';
|
|
17
|
+
}
|
|
18
|
+
createFormGroup(fields) {
|
|
19
|
+
const group = {};
|
|
20
|
+
fields.forEach(field => {
|
|
21
|
+
// Nested Group
|
|
22
|
+
if (field.type === 'group') {
|
|
23
|
+
group[field.key] = this.createFormGroup(field.children || []);
|
|
24
|
+
}
|
|
25
|
+
// Nested Array
|
|
26
|
+
else if (field.type === 'array') {
|
|
27
|
+
group[field.key] = this.createFormArray(field);
|
|
28
|
+
}
|
|
29
|
+
// Regular Field
|
|
30
|
+
else {
|
|
31
|
+
const validators = this.buildValidators(field.validators || []);
|
|
32
|
+
const initialValue = this.getInitialValue(field);
|
|
33
|
+
group[field.key] = new FormControl({
|
|
34
|
+
value: initialValue,
|
|
35
|
+
disabled: field.disabled || false
|
|
36
|
+
}, validators);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return this.formBuilder.group(group);
|
|
40
|
+
}
|
|
41
|
+
createFormArray(arrayConfig) {
|
|
42
|
+
const items = [];
|
|
43
|
+
const minItems = arrayConfig.minItems || 0;
|
|
44
|
+
// Create minimum required items
|
|
45
|
+
for (let i = 0; i < minItems; i++) {
|
|
46
|
+
items.push(this.createFormGroup(arrayConfig.children || []));
|
|
47
|
+
}
|
|
48
|
+
return this.formBuilder.array(items);
|
|
49
|
+
}
|
|
50
|
+
getInitialValues(fields) {
|
|
51
|
+
const initialValues = {};
|
|
52
|
+
fields.forEach(field => {
|
|
53
|
+
if (field.type === 'group') {
|
|
54
|
+
initialValues[field.key] = this.getInitialValues(field.children || []);
|
|
55
|
+
}
|
|
56
|
+
else if (field.type === 'array') {
|
|
57
|
+
initialValues[field.key] = [];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
initialValues[field.key] = this.getInitialValue(field);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return initialValues;
|
|
64
|
+
}
|
|
65
|
+
getOptions(url, apiName) {
|
|
66
|
+
return this.restService.request({
|
|
67
|
+
method: 'GET',
|
|
68
|
+
url,
|
|
69
|
+
}, { apiName: apiName || this.apiName });
|
|
70
|
+
}
|
|
71
|
+
buildValidators(validatorConfigs) {
|
|
72
|
+
return validatorConfigs.map(config => {
|
|
73
|
+
switch (config.type) {
|
|
74
|
+
case 'required':
|
|
75
|
+
return Validators.required;
|
|
76
|
+
case 'email':
|
|
77
|
+
return Validators.email;
|
|
78
|
+
case 'minLength':
|
|
79
|
+
return Validators.minLength(config.value);
|
|
80
|
+
case 'maxLength':
|
|
81
|
+
return Validators.maxLength(config.value);
|
|
82
|
+
case 'pattern':
|
|
83
|
+
return Validators.pattern(config.value);
|
|
84
|
+
case 'min':
|
|
85
|
+
return Validators.min(config.value);
|
|
86
|
+
case 'max':
|
|
87
|
+
return Validators.max(config.value);
|
|
88
|
+
case 'requiredTrue':
|
|
89
|
+
return Validators.requiredTrue;
|
|
90
|
+
default:
|
|
91
|
+
return Validators.nullValidator;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getInitialValue(field) {
|
|
96
|
+
if (field.value !== undefined) {
|
|
97
|
+
return field.value;
|
|
98
|
+
}
|
|
99
|
+
switch (field.type) {
|
|
100
|
+
case 'checkbox':
|
|
101
|
+
return false;
|
|
102
|
+
case 'number':
|
|
103
|
+
return 0;
|
|
104
|
+
case 'group':
|
|
105
|
+
return this.getInitialValues(field.children || []);
|
|
106
|
+
case 'array':
|
|
107
|
+
return [];
|
|
108
|
+
default:
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
113
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormService, providedIn: 'root' }); }
|
|
114
|
+
}
|
|
115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormService, decorators: [{
|
|
116
|
+
type: Injectable,
|
|
117
|
+
args: [{
|
|
118
|
+
providedIn: 'root'
|
|
119
|
+
}]
|
|
120
|
+
}] });
|
|
121
|
+
|
|
122
|
+
var ConditionalAction;
|
|
123
|
+
(function (ConditionalAction) {
|
|
124
|
+
ConditionalAction["SHOW"] = "show";
|
|
125
|
+
ConditionalAction["HIDE"] = "hide";
|
|
126
|
+
ConditionalAction["ENABLE"] = "enable";
|
|
127
|
+
ConditionalAction["DISABLE"] = "disable";
|
|
128
|
+
})(ConditionalAction || (ConditionalAction = {}));
|
|
129
|
+
|
|
130
|
+
const ABP_DYNAMIC_FORM_FIELD = new InjectionToken('AbpDynamicFormField');
|
|
131
|
+
const DYNAMIC_FORM_FIELD_CONTROL_VALUE_ACCESSOR = {
|
|
132
|
+
provide: NG_VALUE_ACCESSOR,
|
|
133
|
+
useExisting: forwardRef(() => DynamicFormFieldComponent),
|
|
134
|
+
multi: true,
|
|
135
|
+
};
|
|
136
|
+
class DynamicFormFieldComponent {
|
|
137
|
+
// Accessibility: Generate unique IDs for ARIA
|
|
138
|
+
get fieldId() {
|
|
139
|
+
return `field-${this.field().key}`;
|
|
140
|
+
}
|
|
141
|
+
get errorId() {
|
|
142
|
+
return `${this.fieldId}-error`;
|
|
143
|
+
}
|
|
144
|
+
get helpTextId() {
|
|
145
|
+
return `${this.fieldId}-help`;
|
|
146
|
+
}
|
|
147
|
+
constructor() {
|
|
148
|
+
this.field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
|
|
149
|
+
this.visible = input(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
|
|
150
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
151
|
+
this.destroyRef = inject(DestroyRef);
|
|
152
|
+
this.injector = inject(Injector);
|
|
153
|
+
this.formBuilder = inject(FormBuilder);
|
|
154
|
+
this.dynamicFormService = inject(DynamicFormService);
|
|
155
|
+
this.options$ = of([]);
|
|
156
|
+
this.onChange = () => { };
|
|
157
|
+
this.onTouched = () => { };
|
|
158
|
+
this.fieldFormGroup = this.formBuilder.group({
|
|
159
|
+
value: [{ value: '' }],
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
ngOnInit() {
|
|
163
|
+
const ngControl = this.injector.get(NgControl, null);
|
|
164
|
+
if (ngControl) {
|
|
165
|
+
this.control = this.injector.get(FormGroupDirective).getControl(ngControl);
|
|
166
|
+
}
|
|
167
|
+
this.value.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => {
|
|
168
|
+
this.onChange(value);
|
|
169
|
+
});
|
|
170
|
+
const options = this.field().options;
|
|
171
|
+
if (options?.url) {
|
|
172
|
+
this.options$ = this.dynamicFormService.getOptions(options.url, options.apiName);
|
|
173
|
+
}
|
|
174
|
+
else if (options?.defaultValues?.length) {
|
|
175
|
+
this.options$ = of(options.defaultValues.map(item => {
|
|
176
|
+
return {
|
|
177
|
+
key: item[options.valueProp || 'key'] || item,
|
|
178
|
+
value: item[options.labelProp || 'value'] || item
|
|
179
|
+
};
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.options$ = of([]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
writeValue(value) {
|
|
187
|
+
this.value.setValue(value || '');
|
|
188
|
+
this.changeDetectorRef.markForCheck();
|
|
189
|
+
}
|
|
190
|
+
registerOnChange(fn) {
|
|
191
|
+
this.onChange = fn;
|
|
192
|
+
}
|
|
193
|
+
registerOnTouched(fn) {
|
|
194
|
+
this.onTouched = fn;
|
|
195
|
+
}
|
|
196
|
+
setDisabledState(isDisabled) {
|
|
197
|
+
if (isDisabled) {
|
|
198
|
+
this.value.disable();
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
this.value.enable();
|
|
202
|
+
}
|
|
203
|
+
this.changeDetectorRef.markForCheck();
|
|
204
|
+
}
|
|
205
|
+
get isInvalid() {
|
|
206
|
+
if (this.control) {
|
|
207
|
+
return this.control.invalid && (this.control.dirty || this.control.touched);
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
get errors() {
|
|
212
|
+
if (!this.control?.errors)
|
|
213
|
+
return [];
|
|
214
|
+
if (this.control && this.control.errors) {
|
|
215
|
+
const errorKeys = Object.keys(this.control.errors);
|
|
216
|
+
const validators = this.field().validators || [];
|
|
217
|
+
return errorKeys.map(key => {
|
|
218
|
+
const validator = validators.find(v => v.type.toLowerCase() === key.toLowerCase());
|
|
219
|
+
if (validator && validator.message) {
|
|
220
|
+
return validator.message;
|
|
221
|
+
}
|
|
222
|
+
// Fallback error messages
|
|
223
|
+
if (key === 'required')
|
|
224
|
+
return `${this.field().label} is required`;
|
|
225
|
+
if (key === 'email')
|
|
226
|
+
return 'Please enter a valid email address';
|
|
227
|
+
if (key === 'minlength')
|
|
228
|
+
return `Minimum length is ${this.control.errors[key].requiredLength}`;
|
|
229
|
+
if (key === 'maxlength')
|
|
230
|
+
return `Maximum length is ${this.control.errors[key].requiredLength}`;
|
|
231
|
+
return `${this.field().label} is invalid due to ${key} validation.`;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
get value() {
|
|
237
|
+
return this.fieldFormGroup.get('value');
|
|
238
|
+
}
|
|
239
|
+
onFileChange(event) {
|
|
240
|
+
const input = event.target;
|
|
241
|
+
if (input.files) {
|
|
242
|
+
const files = Array.from(input.files);
|
|
243
|
+
const value = this.field().multiple ? files : files[0];
|
|
244
|
+
this.value.setValue(value);
|
|
245
|
+
this.onChange(value);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
249
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: DynamicFormFieldComponent, isStandalone: true, selector: "abp-dynamic-form-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "abp-dynamic-form-field" }, providers: [
|
|
250
|
+
{ provide: ABP_DYNAMIC_FORM_FIELD, useExisting: DynamicFormFieldComponent },
|
|
251
|
+
DYNAMIC_FORM_FIELD_CONTROL_VALUE_ACCESSOR,
|
|
252
|
+
], exportAs: ["abpDynamicFormField"], ngImport: i0, template: "@if (visible()) {\r\n<div [formGroup]=\"fieldFormGroup\" role=\"group\" [attr.aria-labelledby]=\"fieldId + '-label'\">\r\n \r\n <!-- NOTE: Group and Array types are NOT rendered here, they should be rendered at parent level -->\r\n <!-- This component only handles leaf/primitive field types -->\r\n \r\n @if (field().type === 'text') {\r\n <!-- Text Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n [id]=\"fieldId\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'select') {\r\n <!-- Select Dropdown -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <select \r\n [id]=\"fieldId\"\r\n formControlName=\"value\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n <option value=\"\">{{ '::Select' | abpLocalization }}</option>\r\n @for (option of options$ | async; track option.key) {\r\n <option [value]=\"option.key\">\r\n {{ option.value | abpLocalization }}\r\n </option>\r\n }\r\n </select>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'checkbox') {\r\n <!-- Checkbox -->\r\n <div class=\"form-group form-check mb-3\" role=\"group\">\r\n <abp-checkbox \r\n [label]=\"field().label | abpLocalization\" \r\n formControlName=\"value\" \r\n [id]=\"fieldId\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\" />\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'email') {\r\n <!-- Email Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"email\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"email\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'textarea') {\r\n <!-- Textarea -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <textarea \r\n [id]=\"fieldId\"\r\n formControlName=\"value\" \r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\"\r\n [class.is-invalid]=\"isInvalid\" \r\n rows=\"4\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n </textarea>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'number') {\r\n <!-- Number Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"number\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.step]=\"field().step || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'date') {\r\n <!-- Date Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"date\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'datetime-local') {\r\n <!-- DateTime Local Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"datetime-local\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'time') {\r\n <!-- Time Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"time\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.step]=\"field().step || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'password') {\r\n <!-- Password Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"password\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.minlength]=\"field().minLength || null\"\r\n [attr.maxlength]=\"field().maxLength || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"new-password\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'tel') {\r\n <!-- Tel Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"tel\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.pattern]=\"field().pattern || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"tel\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'url') {\r\n <!-- URL Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"url\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"url\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'radio') {\r\n <!-- Radio Group -->\r\n <div class=\"form-group mb-3\" role=\"radiogroup\" [attr.aria-labelledby]=\"fieldId + '-label'\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"radio-group\">\r\n @for (option of options$ | async; track option.key) {\r\n <div class=\"form-check\">\r\n <input \r\n type=\"radio\" \r\n [id]=\"fieldId + '-' + option.key\"\r\n [value]=\"option.key\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-check-input\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\">\r\n <label [for]=\"fieldId + '-' + option.key\" class=\"form-check-label\">\r\n {{ option.value | abpLocalization }}\r\n </label>\r\n </div>\r\n }\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'file') {\r\n <!-- File Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"file\" \r\n [id]=\"fieldId\"\r\n (change)=\"onFileChange($event)\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.accept]=\"field().accept || null\"\r\n [attr.multiple]=\"field().multiple || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'range') {\r\n <!-- Range Slider -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"d-flex align-items-center gap-3\">\r\n <input \r\n type=\"range\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-range flex-grow-1\"\r\n [attr.min]=\"field().min || 0\"\r\n [attr.max]=\"field().max || 100\"\r\n [attr.step]=\"field().step || 1\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n [attr.aria-valuenow]=\"value.value\"\r\n [attr.aria-valuemin]=\"field().min || 0\"\r\n [attr.aria-valuemax]=\"field().max || 100\">\r\n <output [for]=\"fieldId\" class=\"badge bg-primary\">{{ value.value }}</output>\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'color') {\r\n <!-- Color Picker -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"d-flex align-items-center gap-3\">\r\n <input \r\n type=\"color\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control form-control-color\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n <code class=\"text-muted\">{{ value.value || '#000000' }}</code>\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n }\r\n</div>\r\n}\r\n\r\n<ng-template #labelTemplate>\r\n <label \r\n [for]=\"fieldId\"\r\n [id]=\"fieldId + '-label'\"\r\n [class.required]=\"field().required\">\r\n {{ field().label | abpLocalization }}\r\n @if (field().required) {\r\n <span class=\"text-danger\" aria-label=\"required\">*</span>\r\n }\r\n </label>\r\n</ng-template>\r\n\r\n<ng-template #errorTemplate>\r\n <div \r\n class=\"invalid-feedback\" \r\n [id]=\"errorId\"\r\n role=\"alert\"\r\n aria-live=\"polite\"\r\n aria-atomic=\"true\">\r\n @for (error of errors; track error) {\r\n <div>{{ error | abpLocalization }}</div>\r\n }\r\n </div>\r\n</ng-template>", styles: [".form-group{display:flex;flex-direction:column}.form-group .radio-group{display:flex;flex-direction:column;gap:.5rem}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.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: i2.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i2.RangeValueAccessor, selector: "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: FormCheckboxComponent, selector: "abp-checkbox", inputs: ["label", "labelClass", "checkboxId", "checkboxStyle", "checkboxClass", "checkboxReadonly"], outputs: ["checkboxBlur", "checkboxFocus"] }, { kind: "pipe", type: LocalizationPipe, name: "abpLocalization" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
253
|
+
}
|
|
254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
|
|
255
|
+
type: Component,
|
|
256
|
+
args: [{ selector: 'abp-dynamic-form-field', providers: [
|
|
257
|
+
{ provide: ABP_DYNAMIC_FORM_FIELD, useExisting: DynamicFormFieldComponent },
|
|
258
|
+
DYNAMIC_FORM_FIELD_CONTROL_VALUE_ACCESSOR,
|
|
259
|
+
], host: { class: 'abp-dynamic-form-field' }, exportAs: 'abpDynamicFormField', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, LocalizationPipe, ReactiveFormsModule, FormCheckboxComponent, AsyncPipe], template: "@if (visible()) {\r\n<div [formGroup]=\"fieldFormGroup\" role=\"group\" [attr.aria-labelledby]=\"fieldId + '-label'\">\r\n \r\n <!-- NOTE: Group and Array types are NOT rendered here, they should be rendered at parent level -->\r\n <!-- This component only handles leaf/primitive field types -->\r\n \r\n @if (field().type === 'text') {\r\n <!-- Text Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n [id]=\"fieldId\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'select') {\r\n <!-- Select Dropdown -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <select \r\n [id]=\"fieldId\"\r\n formControlName=\"value\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n <option value=\"\">{{ '::Select' | abpLocalization }}</option>\r\n @for (option of options$ | async; track option.key) {\r\n <option [value]=\"option.key\">\r\n {{ option.value | abpLocalization }}\r\n </option>\r\n }\r\n </select>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'checkbox') {\r\n <!-- Checkbox -->\r\n <div class=\"form-group form-check mb-3\" role=\"group\">\r\n <abp-checkbox \r\n [label]=\"field().label | abpLocalization\" \r\n formControlName=\"value\" \r\n [id]=\"fieldId\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\" />\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'email') {\r\n <!-- Email Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"email\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"email\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'textarea') {\r\n <!-- Textarea -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <textarea \r\n [id]=\"fieldId\"\r\n formControlName=\"value\" \r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\"\r\n [class.is-invalid]=\"isInvalid\" \r\n rows=\"4\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n </textarea>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'number') {\r\n <!-- Number Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"number\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.step]=\"field().step || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'date') {\r\n <!-- Date Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"date\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'datetime-local') {\r\n <!-- DateTime Local Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"datetime-local\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'time') {\r\n <!-- Time Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"time\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.min]=\"field().min || null\"\r\n [attr.max]=\"field().max || null\"\r\n [attr.step]=\"field().step || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'password') {\r\n <!-- Password Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"password\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.minlength]=\"field().minLength || null\"\r\n [attr.maxlength]=\"field().maxLength || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"new-password\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'tel') {\r\n <!-- Tel Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"tel\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.pattern]=\"field().pattern || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"tel\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'url') {\r\n <!-- URL Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"url\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [placeholder]=\"(field().placeholder || '') | abpLocalization\" \r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n autocomplete=\"url\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'radio') {\r\n <!-- Radio Group -->\r\n <div class=\"form-group mb-3\" role=\"radiogroup\" [attr.aria-labelledby]=\"fieldId + '-label'\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"radio-group\">\r\n @for (option of options$ | async; track option.key) {\r\n <div class=\"form-check\">\r\n <input \r\n type=\"radio\" \r\n [id]=\"fieldId + '-' + option.key\"\r\n [value]=\"option.key\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-check-input\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\">\r\n <label [for]=\"fieldId + '-' + option.key\" class=\"form-check-label\">\r\n {{ option.value | abpLocalization }}\r\n </label>\r\n </div>\r\n }\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'file') {\r\n <!-- File Input -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <input \r\n type=\"file\" \r\n [id]=\"fieldId\"\r\n (change)=\"onFileChange($event)\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control\"\r\n [attr.accept]=\"field().accept || null\"\r\n [attr.multiple]=\"field().multiple || null\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'range') {\r\n <!-- Range Slider -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"d-flex align-items-center gap-3\">\r\n <input \r\n type=\"range\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-range flex-grow-1\"\r\n [attr.min]=\"field().min || 0\"\r\n [attr.max]=\"field().max || 100\"\r\n [attr.step]=\"field().step || 1\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\"\r\n [attr.aria-valuenow]=\"value.value\"\r\n [attr.aria-valuemin]=\"field().min || 0\"\r\n [attr.aria-valuemax]=\"field().max || 100\">\r\n <output [for]=\"fieldId\" class=\"badge bg-primary\">{{ value.value }}</output>\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n } @else if (field().type === 'color') {\r\n <!-- Color Picker -->\r\n <div class=\"form-group mb-3\">\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\r\n <div class=\"d-flex align-items-center gap-3\">\r\n <input \r\n type=\"color\" \r\n [id]=\"fieldId\"\r\n formControlName=\"value\"\r\n [class.is-invalid]=\"isInvalid\" \r\n class=\"form-control form-control-color\"\r\n [attr.aria-required]=\"field().required || null\"\r\n [attr.aria-invalid]=\"isInvalid || null\"\r\n [attr.aria-describedby]=\"isInvalid ? errorId : null\"\r\n [attr.aria-label]=\"field().label | abpLocalization\">\r\n <code class=\"text-muted\">{{ value.value || '#000000' }}</code>\r\n </div>\r\n @if (isInvalid) {\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\" />\r\n }\r\n </div>\r\n }\r\n</div>\r\n}\r\n\r\n<ng-template #labelTemplate>\r\n <label \r\n [for]=\"fieldId\"\r\n [id]=\"fieldId + '-label'\"\r\n [class.required]=\"field().required\">\r\n {{ field().label | abpLocalization }}\r\n @if (field().required) {\r\n <span class=\"text-danger\" aria-label=\"required\">*</span>\r\n }\r\n </label>\r\n</ng-template>\r\n\r\n<ng-template #errorTemplate>\r\n <div \r\n class=\"invalid-feedback\" \r\n [id]=\"errorId\"\r\n role=\"alert\"\r\n aria-live=\"polite\"\r\n aria-atomic=\"true\">\r\n @for (error of errors; track error) {\r\n <div>{{ error | abpLocalization }}</div>\r\n }\r\n </div>\r\n</ng-template>", styles: [".form-group{display:flex;flex-direction:column}.form-group .radio-group{display:flex;flex-direction:column;gap:.5rem}\n"] }]
|
|
260
|
+
}], ctorParameters: () => [], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }] } });
|
|
261
|
+
|
|
262
|
+
class DynamicFieldHostComponent {
|
|
263
|
+
constructor() {
|
|
264
|
+
this.component = input(...(ngDevMode ? [undefined, { debugName: "component" }] : []));
|
|
265
|
+
this.inputs = input({}, ...(ngDevMode ? [{ debugName: "inputs" }] : []));
|
|
266
|
+
this.disabled = false;
|
|
267
|
+
// if child has not implemented ControlValueAccessor. Create form control
|
|
268
|
+
this.innerControl = new FormControl(null);
|
|
269
|
+
this.destroyRef = inject(DestroyRef);
|
|
270
|
+
this.onChange = () => { };
|
|
271
|
+
this.onTouched = () => { };
|
|
272
|
+
effect(() => {
|
|
273
|
+
if (this.component()) {
|
|
274
|
+
this.createChild();
|
|
275
|
+
}
|
|
276
|
+
else if (this.componentRef && this.inputs()) {
|
|
277
|
+
this.applyInputs();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
createChild() {
|
|
282
|
+
this.viewContainerRef.clear();
|
|
283
|
+
if (!this.component())
|
|
284
|
+
return;
|
|
285
|
+
this.componentRef = this.viewContainerRef.createComponent(this.component());
|
|
286
|
+
this.applyInputs();
|
|
287
|
+
const instance = this.componentRef.instance;
|
|
288
|
+
if (this.isCVA(instance)) {
|
|
289
|
+
// Child CVA ise wrapper -> child delege
|
|
290
|
+
instance.registerOnChange?.((v) => this.onChange(v));
|
|
291
|
+
instance.registerOnTouched?.(() => this.onTouched());
|
|
292
|
+
if (this.disabled && instance.setDisabledState) {
|
|
293
|
+
instance.setDisabledState(true);
|
|
294
|
+
}
|
|
295
|
+
// set initial value
|
|
296
|
+
if (this.value !== undefined) {
|
|
297
|
+
instance.writeValue?.(this.value);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// No CVA -> use form control
|
|
302
|
+
if ('formControl' in instance) {
|
|
303
|
+
instance.formControl = this.innerControl;
|
|
304
|
+
// apply initial value/disabled state
|
|
305
|
+
if (this.value !== undefined) {
|
|
306
|
+
this.innerControl.setValue(this.value, { emitEvent: false });
|
|
307
|
+
}
|
|
308
|
+
this.innerControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(v => this.onChange(v));
|
|
309
|
+
this.innerControl.disabled ? null : (this.disabled && this.innerControl.disable({ emitEvent: false }));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
applyInputs() {
|
|
314
|
+
if (!this.componentRef)
|
|
315
|
+
return;
|
|
316
|
+
const inst = this.componentRef.instance;
|
|
317
|
+
for (const [k, v] of Object.entries(this.inputs ?? {})) {
|
|
318
|
+
inst[k] = v;
|
|
319
|
+
}
|
|
320
|
+
this.componentRef.changeDetectorRef?.markForCheck?.();
|
|
321
|
+
}
|
|
322
|
+
isCVA(obj) {
|
|
323
|
+
return obj && typeof obj.writeValue === 'function' && typeof obj.registerOnChange === 'function';
|
|
324
|
+
}
|
|
325
|
+
writeValue(obj) {
|
|
326
|
+
this.value = obj;
|
|
327
|
+
if (!this.componentRef)
|
|
328
|
+
return;
|
|
329
|
+
const inst = this.componentRef.instance;
|
|
330
|
+
if (this.isCVA(inst)) {
|
|
331
|
+
inst.writeValue?.(obj);
|
|
332
|
+
}
|
|
333
|
+
else if ('formControl' in inst && inst.formControl instanceof FormControl) {
|
|
334
|
+
inst.formControl.setValue(obj, { emitEvent: false });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
registerOnChange(fn) { this.onChange = fn; }
|
|
338
|
+
registerOnTouched(fn) { this.onTouched = fn; }
|
|
339
|
+
setDisabledState(isDisabled) {
|
|
340
|
+
this.disabled = isDisabled;
|
|
341
|
+
if (!this.componentRef)
|
|
342
|
+
return;
|
|
343
|
+
const inst = this.componentRef.instance;
|
|
344
|
+
if (this.isCVA(inst) && inst.setDisabledState) {
|
|
345
|
+
inst.setDisabledState(isDisabled);
|
|
346
|
+
}
|
|
347
|
+
else if ('formControl' in inst && inst.formControl instanceof FormControl) {
|
|
348
|
+
isDisabled ? inst.formControl.disable({ emitEvent: false }) : inst.formControl.enable({ emitEvent: false });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFieldHostComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
352
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: DynamicFieldHostComponent, isStandalone: true, selector: "abp-dynamic-form-field-host", inputs: { component: { classPropertyName: "component", publicName: "component", isSignal: true, isRequired: false, transformFunction: null }, inputs: { classPropertyName: "inputs", publicName: "inputs", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{
|
|
353
|
+
provide: NG_VALUE_ACCESSOR,
|
|
354
|
+
useExisting: forwardRef(() => DynamicFieldHostComponent),
|
|
355
|
+
multi: true
|
|
356
|
+
}], viewQueries: [{ propertyName: "viewContainerRef", first: true, predicate: ["vcRef"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `<ng-template #vcRef></ng-template>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
357
|
+
}
|
|
358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFieldHostComponent, decorators: [{
|
|
359
|
+
type: Component,
|
|
360
|
+
args: [{
|
|
361
|
+
selector: 'abp-dynamic-form-field-host',
|
|
362
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
363
|
+
template: `<ng-template #vcRef></ng-template>`,
|
|
364
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
365
|
+
providers: [{
|
|
366
|
+
provide: NG_VALUE_ACCESSOR,
|
|
367
|
+
useExisting: forwardRef(() => DynamicFieldHostComponent),
|
|
368
|
+
multi: true
|
|
369
|
+
}]
|
|
370
|
+
}]
|
|
371
|
+
}], ctorParameters: () => [], propDecorators: { component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: false }] }], inputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputs", required: false }] }], viewContainerRef: [{
|
|
372
|
+
type: ViewChild,
|
|
373
|
+
args: ['vcRef', { read: ViewContainerRef, static: true }]
|
|
374
|
+
}] } });
|
|
375
|
+
|
|
376
|
+
class DynamicFormArrayComponent {
|
|
377
|
+
constructor() {
|
|
378
|
+
this.arrayConfig = input.required(...(ngDevMode ? [{ debugName: "arrayConfig" }] : []));
|
|
379
|
+
this.formGroup = input.required(...(ngDevMode ? [{ debugName: "formGroup" }] : []));
|
|
380
|
+
this.visible = input(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
|
|
381
|
+
this.fb = inject(FormBuilder);
|
|
382
|
+
this.dynamicFormService = inject(DynamicFormService);
|
|
383
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
384
|
+
}
|
|
385
|
+
get formArray() {
|
|
386
|
+
return this.formGroup().get(this.arrayConfig().key);
|
|
387
|
+
}
|
|
388
|
+
get sortedChildren() {
|
|
389
|
+
const children = this.arrayConfig().children || [];
|
|
390
|
+
return children.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
391
|
+
}
|
|
392
|
+
get canAddItem() {
|
|
393
|
+
const maxItems = this.arrayConfig().maxItems;
|
|
394
|
+
return maxItems ? this.formArray.length < maxItems : true;
|
|
395
|
+
}
|
|
396
|
+
get canRemoveItem() {
|
|
397
|
+
const minItems = this.arrayConfig().minItems || 0;
|
|
398
|
+
return this.formArray.length > minItems;
|
|
399
|
+
}
|
|
400
|
+
addItem() {
|
|
401
|
+
if (!this.canAddItem)
|
|
402
|
+
return;
|
|
403
|
+
const itemGroup = this.dynamicFormService.createFormGroup(this.arrayConfig().children || []);
|
|
404
|
+
this.formArray.push(itemGroup);
|
|
405
|
+
this.cdr.markForCheck();
|
|
406
|
+
}
|
|
407
|
+
removeItem(index) {
|
|
408
|
+
if (!this.canRemoveItem)
|
|
409
|
+
return;
|
|
410
|
+
this.formArray.removeAt(index);
|
|
411
|
+
this.cdr.markForCheck();
|
|
412
|
+
}
|
|
413
|
+
getItemFormGroup(index) {
|
|
414
|
+
return this.formArray.at(index);
|
|
415
|
+
}
|
|
416
|
+
getNestedFormGroup(index, key) {
|
|
417
|
+
return this.getItemFormGroup(index).get(key);
|
|
418
|
+
}
|
|
419
|
+
trackByIndex(index) {
|
|
420
|
+
return index;
|
|
421
|
+
}
|
|
422
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormArrayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
423
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: DynamicFormArrayComponent, isStandalone: true, selector: "abp-dynamic-form-array", inputs: { arrayConfig: { classPropertyName: "arrayConfig", publicName: "arrayConfig", isSignal: true, isRequired: true, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: true, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (visible()) {\r\n <div class=\"form-array-container\" role=\"region\" [attr.aria-label]=\"arrayConfig().label | abpLocalization\">\r\n \r\n <!-- Header with Add Button -->\r\n <div class=\"array-header d-flex justify-content-between align-items-center mb-3\">\r\n <label class=\"form-array-label\">\r\n {{ arrayConfig().label | abpLocalization }}\r\n @if (arrayConfig().required) {\r\n <span class=\"text-danger\" aria-label=\"required\">*</span>\r\n }\r\n </label>\r\n <button \r\n type=\"button\" \r\n class=\"btn btn-sm btn-primary\"\r\n (click)=\"addItem()\"\r\n [disabled]=\"!canAddItem\"\r\n [attr.aria-label]=\"'Add ' + (arrayConfig().label | abpLocalization)\">\r\n <i class=\"fa fa-plus me-1\"></i>\r\n {{ '::Add' | abpLocalization }}\r\n </button>\r\n </div>\r\n\r\n <!-- Array Items -->\r\n <div class=\"array-items\" role=\"list\">\r\n @for (item of formArray.controls; track trackByIndex($index)) {\r\n <div class=\"array-item border rounded p-3 mb-3\" role=\"listitem\" [formGroup]=\"getItemFormGroup($index)\">\r\n \r\n <!-- Item Header -->\r\n <div class=\"item-header d-flex justify-content-between align-items-center mb-3\">\r\n <strong class=\"item-title\">\r\n {{ arrayConfig().label | abpLocalization }} #{{ $index + 1 }}\r\n </strong>\r\n <button \r\n type=\"button\" \r\n class=\"btn btn-sm btn-danger\"\r\n (click)=\"removeItem($index)\"\r\n [disabled]=\"!canRemoveItem\"\r\n [attr.aria-label]=\"'Remove ' + (arrayConfig().label | abpLocalization) + ' #' + ($index + 1)\">\r\n <i class=\"fa fa-trash me-1\"></i>\r\n {{ '::Remove' | abpLocalization }}\r\n </button>\r\n </div>\r\n\r\n <!-- Item Fields -->\r\n <div class=\"row\">\r\n @for (field of sortedChildren; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Nested Group -->\r\n @if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getNestedFormGroup($index, field.key)\" />\r\n }\r\n \r\n <!-- Nested Array (recursive) -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"getItemFormGroup($index)\" />\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\" />\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"alert alert-info\" role=\"status\">\r\n <i class=\"fa fa-info-circle me-2\"></i>\r\n {{ '::NoItemsAdded' | abpLocalization }}\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Item Count -->\r\n <div class=\"array-footer text-muted small\" aria-live=\"polite\" aria-atomic=\"true\">\r\n {{ formArray.length }} {{ '::Items' | abpLocalization }}\r\n @if (arrayConfig().minItems) {\r\n ({{ '::Min' | abpLocalization }}: {{ arrayConfig().minItems }})\r\n }\r\n @if (arrayConfig().maxItems) {\r\n ({{ '::Max' | abpLocalization }}: {{ arrayConfig().maxItems }})\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [".form-array-container{margin-bottom:1.5rem}.array-header{border-bottom:2px solid var(--bs-primary, #007bff);padding-bottom:.5rem}.form-array-label{font-size:1.1rem;font-weight:600;color:var(--bs-dark, #212529);margin-bottom:0}.array-items{margin-top:1rem}.array-item{background-color:var(--bs-white, #fff);transition:all .2s ease;position:relative}.array-item:hover{box-shadow:0 .125rem .25rem #00000013;transform:translateY(-1px)}.array-item .array-item{background-color:var(--bs-light, #f8f9fa)}.item-header{border-bottom:1px solid var(--bs-border-color, #dee2e6);padding-bottom:.75rem}.item-title{color:var(--bs-primary, #007bff);font-size:.95rem}.array-footer{margin-top:.5rem;padding-top:.5rem;border-top:1px solid var(--bs-border-color, #dee2e6)}button:focus-visible{outline:2px solid var(--bs-primary, #007bff);outline-offset:2px}@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.array-item{animation:slideIn .3s ease}\n"], dependencies: [{ kind: "component", type: i0.forwardRef(() => DynamicFormArrayComponent), selector: "abp-dynamic-form-array", inputs: ["arrayConfig", "formGroup", "visible"] }, { kind: "ngmodule", type: i0.forwardRef(() => CommonModule) }, { kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: i0.forwardRef(() => ReactiveFormsModule) }, { kind: "directive", type: i0.forwardRef(() => i2.NgControlStatus), selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i0.forwardRef(() => i2.NgControlStatusGroup), selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i0.forwardRef(() => i2.FormGroupDirective), selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i0.forwardRef(() => i2.FormControlName), selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i0.forwardRef(() => DynamicFormFieldComponent), selector: "abp-dynamic-form-field", inputs: ["field", "visible"], exportAs: ["abpDynamicFormField"] }, { kind: "component", type: i0.forwardRef(() => DynamicFormGroupComponent), selector: "abp-dynamic-form-group", inputs: ["groupConfig", "formGroup", "visible"] }, { kind: "pipe", type: i0.forwardRef(() => LocalizationPipe), name: "abpLocalization" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
424
|
+
}
|
|
425
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
|
|
426
|
+
type: Component,
|
|
427
|
+
args: [{ selector: 'abp-dynamic-form-array', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
428
|
+
CommonModule,
|
|
429
|
+
ReactiveFormsModule,
|
|
430
|
+
LocalizationPipe,
|
|
431
|
+
DynamicFormFieldComponent,
|
|
432
|
+
DynamicFormGroupComponent,
|
|
433
|
+
forwardRef(() => DynamicFormArrayComponent), // Self reference for recursion
|
|
434
|
+
], template: "@if (visible()) {\r\n <div class=\"form-array-container\" role=\"region\" [attr.aria-label]=\"arrayConfig().label | abpLocalization\">\r\n \r\n <!-- Header with Add Button -->\r\n <div class=\"array-header d-flex justify-content-between align-items-center mb-3\">\r\n <label class=\"form-array-label\">\r\n {{ arrayConfig().label | abpLocalization }}\r\n @if (arrayConfig().required) {\r\n <span class=\"text-danger\" aria-label=\"required\">*</span>\r\n }\r\n </label>\r\n <button \r\n type=\"button\" \r\n class=\"btn btn-sm btn-primary\"\r\n (click)=\"addItem()\"\r\n [disabled]=\"!canAddItem\"\r\n [attr.aria-label]=\"'Add ' + (arrayConfig().label | abpLocalization)\">\r\n <i class=\"fa fa-plus me-1\"></i>\r\n {{ '::Add' | abpLocalization }}\r\n </button>\r\n </div>\r\n\r\n <!-- Array Items -->\r\n <div class=\"array-items\" role=\"list\">\r\n @for (item of formArray.controls; track trackByIndex($index)) {\r\n <div class=\"array-item border rounded p-3 mb-3\" role=\"listitem\" [formGroup]=\"getItemFormGroup($index)\">\r\n \r\n <!-- Item Header -->\r\n <div class=\"item-header d-flex justify-content-between align-items-center mb-3\">\r\n <strong class=\"item-title\">\r\n {{ arrayConfig().label | abpLocalization }} #{{ $index + 1 }}\r\n </strong>\r\n <button \r\n type=\"button\" \r\n class=\"btn btn-sm btn-danger\"\r\n (click)=\"removeItem($index)\"\r\n [disabled]=\"!canRemoveItem\"\r\n [attr.aria-label]=\"'Remove ' + (arrayConfig().label | abpLocalization) + ' #' + ($index + 1)\">\r\n <i class=\"fa fa-trash me-1\"></i>\r\n {{ '::Remove' | abpLocalization }}\r\n </button>\r\n </div>\r\n\r\n <!-- Item Fields -->\r\n <div class=\"row\">\r\n @for (field of sortedChildren; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Nested Group -->\r\n @if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getNestedFormGroup($index, field.key)\" />\r\n }\r\n \r\n <!-- Nested Array (recursive) -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"getItemFormGroup($index)\" />\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\" />\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n </div>\r\n } @empty {\r\n <div class=\"alert alert-info\" role=\"status\">\r\n <i class=\"fa fa-info-circle me-2\"></i>\r\n {{ '::NoItemsAdded' | abpLocalization }}\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Item Count -->\r\n <div class=\"array-footer text-muted small\" aria-live=\"polite\" aria-atomic=\"true\">\r\n {{ formArray.length }} {{ '::Items' | abpLocalization }}\r\n @if (arrayConfig().minItems) {\r\n ({{ '::Min' | abpLocalization }}: {{ arrayConfig().minItems }})\r\n }\r\n @if (arrayConfig().maxItems) {\r\n ({{ '::Max' | abpLocalization }}: {{ arrayConfig().maxItems }})\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [".form-array-container{margin-bottom:1.5rem}.array-header{border-bottom:2px solid var(--bs-primary, #007bff);padding-bottom:.5rem}.form-array-label{font-size:1.1rem;font-weight:600;color:var(--bs-dark, #212529);margin-bottom:0}.array-items{margin-top:1rem}.array-item{background-color:var(--bs-white, #fff);transition:all .2s ease;position:relative}.array-item:hover{box-shadow:0 .125rem .25rem #00000013;transform:translateY(-1px)}.array-item .array-item{background-color:var(--bs-light, #f8f9fa)}.item-header{border-bottom:1px solid var(--bs-border-color, #dee2e6);padding-bottom:.75rem}.item-title{color:var(--bs-primary, #007bff);font-size:.95rem}.array-footer{margin-top:.5rem;padding-top:.5rem;border-top:1px solid var(--bs-border-color, #dee2e6)}button:focus-visible{outline:2px solid var(--bs-primary, #007bff);outline-offset:2px}@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.array-item{animation:slideIn .3s ease}\n"] }]
|
|
435
|
+
}], propDecorators: { arrayConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrayConfig", required: true }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }] } });
|
|
436
|
+
|
|
437
|
+
class DynamicFormGroupComponent {
|
|
438
|
+
constructor() {
|
|
439
|
+
this.groupConfig = input.required(...(ngDevMode ? [{ debugName: "groupConfig" }] : []));
|
|
440
|
+
this.formGroup = input.required(...(ngDevMode ? [{ debugName: "formGroup" }] : []));
|
|
441
|
+
this.visible = input(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
|
|
442
|
+
}
|
|
443
|
+
get sortedChildren() {
|
|
444
|
+
const children = this.groupConfig().children || [];
|
|
445
|
+
return children.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
446
|
+
}
|
|
447
|
+
getChildFormGroup(key) {
|
|
448
|
+
return this.formGroup().get(key);
|
|
449
|
+
}
|
|
450
|
+
getChildControl(key) {
|
|
451
|
+
return this.formGroup().get(key);
|
|
452
|
+
}
|
|
453
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
454
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: DynamicFormGroupComponent, isStandalone: true, selector: "abp-dynamic-form-group", inputs: { groupConfig: { classPropertyName: "groupConfig", publicName: "groupConfig", isSignal: true, isRequired: true, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: true, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (visible()) {\r\n <fieldset class=\"form-group-container\" [formGroup]=\"formGroup()\" role=\"group\" [attr.aria-labelledby]=\"groupConfig().key + '-legend'\">\r\n <legend [id]=\"groupConfig().key + '-legend'\" class=\"form-group-legend\">\r\n {{ groupConfig().label | abpLocalization }}\r\n </legend>\r\n \r\n <div class=\"row\">\r\n @for (field of sortedChildren; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Nested Group (Recursive) -->\r\n @if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getChildFormGroup(field.key)\" />\r\n }\r\n \r\n <!-- Nested Array -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"formGroup()\" />\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\" />\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n </fieldset>\r\n}\r\n", styles: [".form-group-container{border-left:3px solid var(--bs-primary, #007bff);padding-left:1rem;margin-bottom:1.5rem;border:1px solid var(--bs-border-color, #dee2e6);border-radius:.375rem;padding:1rem;background-color:var(--bs-light, #f8f9fa)}.form-group-container .form-group-container{border-left-color:var(--bs-secondary, #6c757d);padding-left:.75rem;background-color:var(--bs-white, #fff)}.form-group-legend{font-size:1.1rem;font-weight:600;color:var(--bs-primary, #007bff);margin-bottom:1rem;padding:0 .5rem;float:none;width:auto}\n"], dependencies: [{ kind: "component", type: i0.forwardRef(() => DynamicFormGroupComponent), selector: "abp-dynamic-form-group", inputs: ["groupConfig", "formGroup", "visible"] }, { kind: "ngmodule", type: i0.forwardRef(() => CommonModule) }, { kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: i0.forwardRef(() => ReactiveFormsModule) }, { kind: "directive", type: i0.forwardRef(() => i2.NgControlStatus), selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i0.forwardRef(() => i2.NgControlStatusGroup), selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i0.forwardRef(() => i2.FormGroupDirective), selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i0.forwardRef(() => i2.FormControlName), selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i0.forwardRef(() => DynamicFormFieldComponent), selector: "abp-dynamic-form-field", inputs: ["field", "visible"], exportAs: ["abpDynamicFormField"] }, { kind: "component", type: i0.forwardRef(() => DynamicFormArrayComponent), selector: "abp-dynamic-form-array", inputs: ["arrayConfig", "formGroup", "visible"] }, { kind: "pipe", type: i0.forwardRef(() => LocalizationPipe), name: "abpLocalization" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
455
|
+
}
|
|
456
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormGroupComponent, decorators: [{
|
|
457
|
+
type: Component,
|
|
458
|
+
args: [{ selector: 'abp-dynamic-form-group', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
459
|
+
CommonModule,
|
|
460
|
+
ReactiveFormsModule,
|
|
461
|
+
LocalizationPipe,
|
|
462
|
+
DynamicFormFieldComponent,
|
|
463
|
+
forwardRef(() => DynamicFormArrayComponent),
|
|
464
|
+
forwardRef(() => DynamicFormGroupComponent), // Self reference for recursion
|
|
465
|
+
], template: "@if (visible()) {\r\n <fieldset class=\"form-group-container\" [formGroup]=\"formGroup()\" role=\"group\" [attr.aria-labelledby]=\"groupConfig().key + '-legend'\">\r\n <legend [id]=\"groupConfig().key + '-legend'\" class=\"form-group-legend\">\r\n {{ groupConfig().label | abpLocalization }}\r\n </legend>\r\n \r\n <div class=\"row\">\r\n @for (field of sortedChildren; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Nested Group (Recursive) -->\r\n @if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getChildFormGroup(field.key)\" />\r\n }\r\n \r\n <!-- Nested Array -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"formGroup()\" />\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\" />\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n </fieldset>\r\n}\r\n", styles: [".form-group-container{border-left:3px solid var(--bs-primary, #007bff);padding-left:1rem;margin-bottom:1.5rem;border:1px solid var(--bs-border-color, #dee2e6);border-radius:.375rem;padding:1rem;background-color:var(--bs-light, #f8f9fa)}.form-group-container .form-group-container{border-left-color:var(--bs-secondary, #6c757d);padding-left:.75rem;background-color:var(--bs-white, #fff)}.form-group-legend{font-size:1.1rem;font-weight:600;color:var(--bs-primary, #007bff);margin-bottom:1rem;padding:0 .5rem;float:none;width:auto}\n"] }]
|
|
466
|
+
}], propDecorators: { groupConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupConfig", required: true }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: true }] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }] } });
|
|
467
|
+
|
|
468
|
+
class DynamicFormComponent {
|
|
469
|
+
constructor() {
|
|
470
|
+
this.fields = input([], ...(ngDevMode ? [{ debugName: "fields" }] : []));
|
|
471
|
+
this.values = input(...(ngDevMode ? [undefined, { debugName: "values" }] : []));
|
|
472
|
+
this.submitButtonText = input('Submit', ...(ngDevMode ? [{ debugName: "submitButtonText" }] : []));
|
|
473
|
+
this.submitInProgress = input(false, ...(ngDevMode ? [{ debugName: "submitInProgress" }] : []));
|
|
474
|
+
this.showCancelButton = input(false, ...(ngDevMode ? [{ debugName: "showCancelButton" }] : []));
|
|
475
|
+
this.onSubmit = output();
|
|
476
|
+
this.formCancel = output();
|
|
477
|
+
this.dynamicFormService = inject(DynamicFormService);
|
|
478
|
+
this.destroyRef = inject(DestroyRef);
|
|
479
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
480
|
+
this.fieldVisibility = {};
|
|
481
|
+
}
|
|
482
|
+
ngOnInit() {
|
|
483
|
+
this.setupFormAndLogic();
|
|
484
|
+
}
|
|
485
|
+
get sortedFields() {
|
|
486
|
+
return this.fields().sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
487
|
+
}
|
|
488
|
+
submit() {
|
|
489
|
+
if (this.dynamicForm.valid) {
|
|
490
|
+
this.onSubmit.emit(this.dynamicForm.getRawValue());
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
this.markAllFieldsAsTouched();
|
|
494
|
+
this.focusFirstInvalidField();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
onCancel() {
|
|
498
|
+
this.formCancel.emit();
|
|
499
|
+
}
|
|
500
|
+
onFieldChange(event) {
|
|
501
|
+
this.evaluateConditionalLogic(event.fieldKey);
|
|
502
|
+
}
|
|
503
|
+
isFieldVisible(field) {
|
|
504
|
+
return this.fieldVisibility[field.key] !== false;
|
|
505
|
+
}
|
|
506
|
+
getChildFormGroup(key) {
|
|
507
|
+
return this.dynamicForm.get(key);
|
|
508
|
+
}
|
|
509
|
+
resetForm() {
|
|
510
|
+
const initialValues = this.dynamicFormService.getInitialValues(this.fields());
|
|
511
|
+
this.dynamicForm.reset({ ...initialValues });
|
|
512
|
+
this.dynamicForm.markAsUntouched();
|
|
513
|
+
this.dynamicForm.markAsPristine();
|
|
514
|
+
this.changeDetectorRef.markForCheck();
|
|
515
|
+
}
|
|
516
|
+
initializeFieldVisibility() {
|
|
517
|
+
this.fields().forEach(field => {
|
|
518
|
+
this.fieldVisibility = {
|
|
519
|
+
...this.fieldVisibility,
|
|
520
|
+
[field.key]: !field.conditionalLogic?.length,
|
|
521
|
+
};
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
setupConditionalLogic() {
|
|
525
|
+
this.fields().forEach(field => {
|
|
526
|
+
if (field.conditionalLogic) {
|
|
527
|
+
field.conditionalLogic.forEach(rule => {
|
|
528
|
+
const dependentControl = this.dynamicForm.get(rule.dependsOn);
|
|
529
|
+
if (dependentControl) {
|
|
530
|
+
this.evaluateConditionalLogic(field.key);
|
|
531
|
+
dependentControl.valueChanges
|
|
532
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
533
|
+
.subscribe(() => {
|
|
534
|
+
this.evaluateConditionalLogic(field.key);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
evaluateConditionalLogic(fieldKey) {
|
|
542
|
+
const field = this.fields().find(f => f.key === fieldKey);
|
|
543
|
+
if (!field?.conditionalLogic)
|
|
544
|
+
return;
|
|
545
|
+
field.conditionalLogic.forEach(rule => {
|
|
546
|
+
const dependentValue = this.dynamicForm.get(rule.dependsOn)?.value;
|
|
547
|
+
const conditionMet = this.evaluateCondition(dependentValue, rule.condition, rule.value);
|
|
548
|
+
this.applyConditionalAction(fieldKey, rule.action, conditionMet);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
evaluateCondition(fieldValue, condition, ruleValue) {
|
|
552
|
+
switch (condition) {
|
|
553
|
+
case 'equals':
|
|
554
|
+
return fieldValue === ruleValue;
|
|
555
|
+
case 'notEquals':
|
|
556
|
+
return fieldValue !== ruleValue;
|
|
557
|
+
case 'contains':
|
|
558
|
+
return fieldValue && fieldValue.includes && fieldValue.includes(ruleValue);
|
|
559
|
+
case 'greaterThan':
|
|
560
|
+
return Number(fieldValue) > Number(ruleValue);
|
|
561
|
+
case 'lessThan':
|
|
562
|
+
return Number(fieldValue) < Number(ruleValue);
|
|
563
|
+
default:
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
applyConditionalAction(fieldKey, action, shouldApply) {
|
|
568
|
+
const control = this.dynamicForm.get(fieldKey);
|
|
569
|
+
switch (action) {
|
|
570
|
+
case ConditionalAction.SHOW:
|
|
571
|
+
this.fieldVisibility = { ...this.fieldVisibility, [fieldKey]: shouldApply };
|
|
572
|
+
break;
|
|
573
|
+
case ConditionalAction.HIDE:
|
|
574
|
+
this.fieldVisibility = { ...this.fieldVisibility, [fieldKey]: !shouldApply };
|
|
575
|
+
break;
|
|
576
|
+
case ConditionalAction.ENABLE:
|
|
577
|
+
if (control) {
|
|
578
|
+
shouldApply ? control.enable() : control.disable();
|
|
579
|
+
}
|
|
580
|
+
break;
|
|
581
|
+
case ConditionalAction.DISABLE:
|
|
582
|
+
if (control) {
|
|
583
|
+
shouldApply ? control.disable() : control.enable();
|
|
584
|
+
}
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
setupFormAndLogic() {
|
|
589
|
+
this.dynamicForm = this.dynamicFormService.createFormGroup(this.fields());
|
|
590
|
+
this.initializeFieldVisibility();
|
|
591
|
+
this.setupConditionalLogic();
|
|
592
|
+
this.changeDetectorRef.markForCheck();
|
|
593
|
+
}
|
|
594
|
+
markAllFieldsAsTouched() {
|
|
595
|
+
Object.keys(this.dynamicForm.controls).forEach(key => {
|
|
596
|
+
this.dynamicForm.get(key)?.markAsTouched();
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
focusFirstInvalidField() {
|
|
600
|
+
// Accessibility: Focus first invalid field for screen readers
|
|
601
|
+
const firstInvalidField = this.sortedFields.find(field => {
|
|
602
|
+
const control = this.dynamicForm.get(field.key);
|
|
603
|
+
return control && control.invalid && control.touched;
|
|
604
|
+
});
|
|
605
|
+
if (firstInvalidField) {
|
|
606
|
+
setTimeout(() => {
|
|
607
|
+
const element = document.getElementById(`field-${firstInvalidField.key}`);
|
|
608
|
+
if (element) {
|
|
609
|
+
element.focus();
|
|
610
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
611
|
+
}
|
|
612
|
+
}, 100);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
616
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: DynamicFormComponent, isStandalone: true, selector: "abp-dynamic-form", inputs: { fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null }, values: { classPropertyName: "values", publicName: "values", isSignal: true, isRequired: false, transformFunction: null }, submitButtonText: { classPropertyName: "submitButtonText", publicName: "submitButtonText", isSignal: true, isRequired: false, transformFunction: null }, submitInProgress: { classPropertyName: "submitInProgress", publicName: "submitInProgress", isSignal: true, isRequired: false, transformFunction: null }, showCancelButton: { classPropertyName: "showCancelButton", publicName: "showCancelButton", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSubmit: "onSubmit", formCancel: "formCancel" }, host: { classAttribute: "abp-dynamic-form" }, exportAs: ["abpDynamicForm"], ngImport: i0, template: "<div class=\"form-wrapper\">\r\n<form \r\n [formGroup]=\"dynamicForm\" \r\n (ngSubmit)=\"submit()\" \r\n class=\"dynamic-form\"\r\n role=\"form\"\r\n [attr.aria-label]=\"'Dynamic Form'\">\r\n <div class=\"row\" role=\"group\">\r\n @for (field of sortedFields; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Custom Component -->\r\n @if (field.component) {\r\n <abp-dynamic-form-field-host\r\n [component]=\"field.component\"\r\n [inputs]=\"{ field: field, visible: isFieldVisible(field) }\"\r\n formControlName=\"{{ field.key }}\">\r\n </abp-dynamic-form-field-host>\r\n }\r\n \r\n <!-- Nested Group -->\r\n @else if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getChildFormGroup(field.key)\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-group>\r\n }\r\n \r\n <!-- Nested Array -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"dynamicForm\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-array>\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-field>\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n <ng-content select=\"[actions]\">\r\n <ng-container [ngTemplateOutlet]=\"defaultActions\"></ng-container>\r\n </ng-content>\r\n\r\n</form>\r\n\r\n<ng-template #defaultActions>\r\n <div class=\"form-actions\" role=\"group\" aria-label=\"Form actions\">\r\n @if (showCancelButton()) {\r\n <button\r\n type=\"button\"\r\n class=\"btn btn-secondary\"\r\n (click)=\"onCancel()\"\r\n aria-label=\"Cancel form\">\r\n Cancel\r\n </button>\r\n }\r\n <button\r\n type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"!dynamicForm.valid || submitInProgress()\"\r\n [attr.aria-busy]=\"submitInProgress() || null\"\r\n [attr.aria-label]=\"submitInProgress() ? 'Submitting form...' : submitButtonText()\">\r\n {{ submitButtonText() }}\r\n </button>\r\n </div>\r\n</ng-template>\r\n</div>\r\n", styles: [":host(.abp-dynamic-form) form{display:flex;flex-direction:column;gap:.5rem}:host(.abp-dynamic-form) .form-wrapper{text-align:left}.form-actions{display:flex;justify-content:flex-end;gap:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: DynamicFormFieldComponent, selector: "abp-dynamic-form-field", inputs: ["field", "visible"], exportAs: ["abpDynamicFormField"] }, { kind: "component", type: DynamicFormGroupComponent, selector: "abp-dynamic-form-group", inputs: ["groupConfig", "formGroup", "visible"] }, { kind: "component", type: DynamicFormArrayComponent, selector: "abp-dynamic-form-array", inputs: ["arrayConfig", "formGroup", "visible"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: DynamicFieldHostComponent, selector: "abp-dynamic-form-field-host", inputs: ["component", "inputs"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
617
|
+
}
|
|
618
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
619
|
+
type: Component,
|
|
620
|
+
args: [{ selector: 'abp-dynamic-form', host: { class: 'abp-dynamic-form' }, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'abpDynamicForm', imports: [
|
|
621
|
+
CommonModule,
|
|
622
|
+
DynamicFormFieldComponent,
|
|
623
|
+
DynamicFormGroupComponent,
|
|
624
|
+
DynamicFormArrayComponent,
|
|
625
|
+
ReactiveFormsModule,
|
|
626
|
+
DynamicFieldHostComponent,
|
|
627
|
+
], template: "<div class=\"form-wrapper\">\r\n<form \r\n [formGroup]=\"dynamicForm\" \r\n (ngSubmit)=\"submit()\" \r\n class=\"dynamic-form\"\r\n role=\"form\"\r\n [attr.aria-label]=\"'Dynamic Form'\">\r\n <div class=\"row\" role=\"group\">\r\n @for (field of sortedFields; track field.key) {\r\n <div [ngClass]=\"'col-md-' + (field.gridSize || 12)\">\r\n \r\n <!-- Custom Component -->\r\n @if (field.component) {\r\n <abp-dynamic-form-field-host\r\n [component]=\"field.component\"\r\n [inputs]=\"{ field: field, visible: isFieldVisible(field) }\"\r\n formControlName=\"{{ field.key }}\">\r\n </abp-dynamic-form-field-host>\r\n }\r\n \r\n <!-- Nested Group -->\r\n @else if (field.type === 'group') {\r\n <abp-dynamic-form-group\r\n [groupConfig]=\"field\"\r\n [formGroup]=\"getChildFormGroup(field.key)\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-group>\r\n }\r\n \r\n <!-- Nested Array -->\r\n @else if (field.type === 'array') {\r\n <abp-dynamic-form-array\r\n [arrayConfig]=\"field\"\r\n [formGroup]=\"dynamicForm\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-array>\r\n }\r\n \r\n <!-- Regular Field -->\r\n @else {\r\n <abp-dynamic-form-field\r\n [field]=\"field\"\r\n [formControlName]=\"field.key\"\r\n [visible]=\"isFieldVisible(field)\">\r\n </abp-dynamic-form-field>\r\n }\r\n \r\n </div>\r\n }\r\n </div>\r\n <ng-content select=\"[actions]\">\r\n <ng-container [ngTemplateOutlet]=\"defaultActions\"></ng-container>\r\n </ng-content>\r\n\r\n</form>\r\n\r\n<ng-template #defaultActions>\r\n <div class=\"form-actions\" role=\"group\" aria-label=\"Form actions\">\r\n @if (showCancelButton()) {\r\n <button\r\n type=\"button\"\r\n class=\"btn btn-secondary\"\r\n (click)=\"onCancel()\"\r\n aria-label=\"Cancel form\">\r\n Cancel\r\n </button>\r\n }\r\n <button\r\n type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"!dynamicForm.valid || submitInProgress()\"\r\n [attr.aria-busy]=\"submitInProgress() || null\"\r\n [attr.aria-label]=\"submitInProgress() ? 'Submitting form...' : submitButtonText()\">\r\n {{ submitButtonText() }}\r\n </button>\r\n </div>\r\n</ng-template>\r\n</div>\r\n", styles: [":host(.abp-dynamic-form) form{display:flex;flex-direction:column;gap:.5rem}:host(.abp-dynamic-form) .form-wrapper{text-align:left}.form-actions{display:flex;justify-content:flex-end;gap:.5rem}\n"] }]
|
|
628
|
+
}], propDecorators: { fields: [{ type: i0.Input, args: [{ isSignal: true, alias: "fields", required: false }] }], values: [{ type: i0.Input, args: [{ isSignal: true, alias: "values", required: false }] }], submitButtonText: [{ type: i0.Input, args: [{ isSignal: true, alias: "submitButtonText", required: false }] }], submitInProgress: [{ type: i0.Input, args: [{ isSignal: true, alias: "submitInProgress", required: false }] }], showCancelButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCancelButton", required: false }] }], onSubmit: [{ type: i0.Output, args: ["onSubmit"] }], formCancel: [{ type: i0.Output, args: ["formCancel"] }] } });
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Generated bundle index. Do not edit.
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
export { ABP_DYNAMIC_FORM_FIELD, ConditionalAction, DynamicFieldHostComponent, DynamicFormArrayComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormGroupComponent, DynamicFormService };
|
|
635
|
+
//# sourceMappingURL=abp-ng.components-dynamic-form.mjs.map
|