@stemy/ngx-dynamic-form 10.2.16 → 10.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +27 -27
  2. package/bundles/stemy-ngx-dynamic-form.umd.js +1423 -1380
  3. package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
  4. package/bundles/stemy-ngx-dynamic-form.umd.min.js +2 -2
  5. package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +1 -1
  6. package/esm2015/ngx-dynamic-form/common-types.js +134 -134
  7. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.js +91 -91
  8. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form.component.js +129 -129
  9. package/esm2015/ngx-dynamic-form/directives/async-submit.directive.js +100 -100
  10. package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +82 -82
  11. package/esm2015/ngx-dynamic-form/services/dynamic-form-validation.service.js +11 -11
  12. package/esm2015/ngx-dynamic-form/services/dynamic-form.service.js +393 -376
  13. package/esm2015/ngx-dynamic-form/utils/dynamic-form-array.model.js +8 -0
  14. package/esm2015/ngx-dynamic-form/utils/form-subject.js +18 -18
  15. package/esm2015/ngx-dynamic-form/utils/validators.js +28 -28
  16. package/esm2015/public_api.js +9 -9
  17. package/esm2015/stemy-ngx-dynamic-form.js +6 -6
  18. package/fesm2015/stemy-ngx-dynamic-form.js +937 -914
  19. package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
  20. package/ngx-dynamic-form/common-types.d.ts +148 -148
  21. package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +37 -37
  22. package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +37 -37
  23. package/ngx-dynamic-form/directives/async-submit.directive.d.ts +27 -27
  24. package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +10 -10
  25. package/ngx-dynamic-form/services/dynamic-form-validation.service.d.ts +5 -5
  26. package/ngx-dynamic-form/services/dynamic-form.service.d.ts +40 -39
  27. package/ngx-dynamic-form/utils/dynamic-form-array.model.d.ts +12 -0
  28. package/ngx-dynamic-form/utils/form-subject.d.ts +8 -8
  29. package/ngx-dynamic-form/utils/validators.d.ts +4 -4
  30. package/package.json +11 -11
  31. package/public_api.d.ts +8 -8
  32. package/stemy-ngx-dynamic-form.d.ts +6 -6
  33. package/stemy-ngx-dynamic-form.metadata.json +1 -1
@@ -2,943 +2,966 @@ import { ReflectUtils, ObjectUtils, UniqueUtils, StringUtils, OpenApiService, TO
2
2
  import { __awaiter } from 'tslib';
3
3
  import { Subject, Subscription } from 'rxjs';
4
4
  import { EventEmitter, Injectable, Directive, Inject, ChangeDetectorRef, ElementRef, Renderer2, Input, Output, HostBinding, HostListener, QueryList, Component, ChangeDetectionStrategy, ContentChildren, ViewChildren, ViewChild, ComponentFactoryResolver, ViewContainerRef, NgModule } from '@angular/core';
5
- import { DynamicFormService as DynamicFormService$1, DynamicSelectModel, DynamicFormArrayModel, DynamicFormGroupModel, DynamicFileUploadModel, DynamicInputModel, DynamicCheckboxModel, DynamicTextAreaModel, DynamicFormComponentService, DynamicFormValidationService as DynamicFormValidationService$1, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormLayoutService, DynamicFormRelationService, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
6
5
  import { FormGroup, FormArray, NgForm, FormsModule, ReactiveFormsModule, NG_VALIDATORS } from '@angular/forms';
6
+ import { DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormService as DynamicFormService$1, DynamicSelectModel, DynamicFormGroupModel, DynamicInputModel, DynamicFileUploadModel, DynamicCheckboxModel, DynamicTextAreaModel, DynamicFormComponentService, DynamicFormValidationService as DynamicFormValidationService$1, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormLayoutService, DynamicFormRelationService, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
7
7
  import { first } from 'rxjs/operators';
8
8
  import { CommonModule } from '@angular/common';
9
9
 
10
- // --- Decorator functions ---
11
- const emptyArray = [];
12
- const emptyTester = () => {
13
- return Promise.resolve(false);
14
- };
15
- const ɵ0 = emptyTester;
16
- function defaultSerializer(id, parent) {
17
- const control = parent.get(id);
18
- return !control ? null : control.value;
19
- }
20
- function FormSerializable(serializer) {
21
- return (target, propertyKey) => {
22
- ReflectUtils.defineMetadata("dynamicFormSerializer", serializer || defaultSerializer, target, propertyKey);
23
- };
24
- }
25
- function FormInput(data) {
26
- return (target, propertyKey) => {
27
- const meta = ReflectUtils.getOwnMetadata("design:type", target, propertyKey);
28
- const type = meta ? meta.name : "";
29
- let inputType = propertyKey.indexOf("password") < 0 ? "text" : "password";
30
- switch (type) {
31
- case "Number":
32
- inputType = "number";
33
- break;
34
- case "Boolean":
35
- inputType = "checkbox";
36
- break;
37
- }
38
- defineFormControl(target, propertyKey, createFormInput(propertyKey, data, inputType));
39
- };
40
- }
41
- function FormSelect(data) {
42
- return (target, propertyKey) => {
43
- defineFormControl(target, propertyKey, createFormSelect(propertyKey, data));
44
- };
45
- }
46
- function FormStatic(data) {
47
- return (target, propertyKey) => {
48
- defineFormControl(target, propertyKey, createFormStatic(propertyKey, data));
49
- };
50
- }
51
- function FormModel(data) {
52
- return (target, propertyKey) => {
53
- defineFormControl(target, propertyKey, createFormModel(propertyKey, data));
54
- };
55
- }
56
- function FormFile(data) {
57
- return (target, propertyKey) => {
58
- defineFormControl(target, propertyKey, createFormFile(propertyKey, data));
59
- };
60
- }
61
- function FormFieldSet(data) {
62
- return (target) => {
63
- const sets = getFormFieldSets(target);
64
- data.classes = data.classes || "";
65
- sets[data.id] = data;
66
- ReflectUtils.defineMetadata("dynamicFormFieldSets", sets, target);
67
- };
68
- }
69
- function defineFormControl(target, propertyKey, control) {
70
- ReflectUtils.defineMetadata("dynamicFormControl", control, target, propertyKey);
71
- }
72
- function getFormFieldSets(target) {
73
- return ReflectUtils.getMetadata("dynamicFormFieldSets", target) || {};
74
- }
75
- function getFormControl(target, propertyKey) {
76
- return ReflectUtils.getMetadata("dynamicFormControl", target, propertyKey);
77
- }
78
- function getFormSerializer(target, propertyKey) {
79
- return ReflectUtils.getMetadata("dynamicFormSerializer", target, propertyKey);
80
- }
81
- function createFormControl(id, type, data) {
82
- data = data || {};
83
- data.label = ObjectUtils.isNullOrUndefined(data.label) ? id : data.label;
84
- data.labelAlign = data.labelAlign || "left";
85
- data.fieldSet = data.fieldSet || UniqueUtils.uuid();
86
- data.classes = data.classes || "";
87
- data.readonly = data.readonly || emptyTester;
88
- data.hidden = data.hidden || emptyTester;
89
- data.validators = data.validators || emptyArray;
90
- return {
91
- id: id,
92
- type: type,
93
- data: data
94
- };
95
- }
96
- function createFormInput(id, data, type = "text") {
97
- const control = createFormControl(id, "input", data);
98
- data = control.data;
99
- data.type = data.type || type;
100
- data.classes = !data.classes ? `form-group-${data.type}` : `${data.classes} form-group-${data.type}`;
101
- data.placeholder = data.placeholder || (data.type == "mask" ? "_" : "");
102
- data.step = data.step || 1;
103
- data.mask = data.mask || [/\w*/gi];
104
- return control;
105
- }
106
- function createFormSelect(id, data) {
107
- const control = createFormControl(id, "select", data);
108
- data = control.data;
109
- data.options = data.options || [];
110
- data.type = data.type || "select";
111
- const classType = data.type == "select" ? "select" : `select-${data.type}`;
112
- data.classes = !data.classes ? `form-group-${classType}` : `${data.classes} form-group-${classType}`;
113
- return control;
114
- }
115
- function createFormStatic(id, data) {
116
- const control = createFormControl(id, "static", data);
117
- data = control.data;
118
- data.style = data.style || "table";
119
- return control;
120
- }
121
- function createFormModel(id, data) {
122
- const control = createFormControl(id, "model", data);
123
- data = control.data;
124
- data.name = data.name || "";
125
- return control;
126
- }
127
- function createFormFile(id, data) {
128
- const control = createFormControl(id, "file", data);
129
- data = control.data;
130
- data.accept = data.accept || ".jpg,.jpeg,.png";
131
- data.multi = data.multi || false;
132
- data.baseUrl = ObjectUtils.isString(data.baseUrl) ? data.baseUrl : "assets/";
133
- data.uploadUrl = ObjectUtils.isString(data.uploadUrl) ? data.uploadUrl : "assets";
134
- data.createUploadData = data.createUploadData || ((file) => {
135
- const form = new FormData();
136
- form.append("file", file);
137
- return form;
138
- });
139
- return control;
10
+ // --- Decorator functions ---
11
+ const emptyArray = [];
12
+ const emptyTester = () => {
13
+ return Promise.resolve(false);
14
+ };
15
+ const ɵ0 = emptyTester;
16
+ function defaultSerializer(id, parent) {
17
+ const control = parent.get(id);
18
+ return !control ? null : control.value;
19
+ }
20
+ function FormSerializable(serializer) {
21
+ return (target, propertyKey) => {
22
+ ReflectUtils.defineMetadata("dynamicFormSerializer", serializer || defaultSerializer, target, propertyKey);
23
+ };
24
+ }
25
+ function FormInput(data) {
26
+ return (target, propertyKey) => {
27
+ const meta = ReflectUtils.getOwnMetadata("design:type", target, propertyKey);
28
+ const type = meta ? meta.name : "";
29
+ let inputType = propertyKey.indexOf("password") < 0 ? "text" : "password";
30
+ switch (type) {
31
+ case "Number":
32
+ inputType = "number";
33
+ break;
34
+ case "Boolean":
35
+ inputType = "checkbox";
36
+ break;
37
+ }
38
+ defineFormControl(target, propertyKey, createFormInput(propertyKey, data, inputType));
39
+ };
40
+ }
41
+ function FormSelect(data) {
42
+ return (target, propertyKey) => {
43
+ defineFormControl(target, propertyKey, createFormSelect(propertyKey, data));
44
+ };
45
+ }
46
+ function FormStatic(data) {
47
+ return (target, propertyKey) => {
48
+ defineFormControl(target, propertyKey, createFormStatic(propertyKey, data));
49
+ };
50
+ }
51
+ function FormModel(data) {
52
+ return (target, propertyKey) => {
53
+ defineFormControl(target, propertyKey, createFormModel(propertyKey, data));
54
+ };
55
+ }
56
+ function FormFile(data) {
57
+ return (target, propertyKey) => {
58
+ defineFormControl(target, propertyKey, createFormFile(propertyKey, data));
59
+ };
60
+ }
61
+ function FormFieldSet(data) {
62
+ return (target) => {
63
+ const sets = getFormFieldSets(target);
64
+ data.classes = data.classes || "";
65
+ sets[data.id] = data;
66
+ ReflectUtils.defineMetadata("dynamicFormFieldSets", sets, target);
67
+ };
68
+ }
69
+ function defineFormControl(target, propertyKey, control) {
70
+ ReflectUtils.defineMetadata("dynamicFormControl", control, target, propertyKey);
71
+ }
72
+ function getFormFieldSets(target) {
73
+ return ReflectUtils.getMetadata("dynamicFormFieldSets", target) || {};
74
+ }
75
+ function getFormControl(target, propertyKey) {
76
+ return ReflectUtils.getMetadata("dynamicFormControl", target, propertyKey);
77
+ }
78
+ function getFormSerializer(target, propertyKey) {
79
+ return ReflectUtils.getMetadata("dynamicFormSerializer", target, propertyKey);
80
+ }
81
+ function createFormControl(id, type, data) {
82
+ data = data || {};
83
+ data.label = ObjectUtils.isNullOrUndefined(data.label) ? id : data.label;
84
+ data.labelAlign = data.labelAlign || "left";
85
+ data.fieldSet = data.fieldSet || UniqueUtils.uuid();
86
+ data.classes = data.classes || "";
87
+ data.readonly = data.readonly || emptyTester;
88
+ data.hidden = data.hidden || emptyTester;
89
+ data.validators = data.validators || emptyArray;
90
+ return {
91
+ id: id,
92
+ type: type,
93
+ data: data
94
+ };
95
+ }
96
+ function createFormInput(id, data, type = "text") {
97
+ const control = createFormControl(id, "input", data);
98
+ data = control.data;
99
+ data.type = data.type || type;
100
+ data.classes = !data.classes ? `form-group-${data.type}` : `${data.classes} form-group-${data.type}`;
101
+ data.placeholder = data.placeholder || (data.type == "mask" ? "_" : "");
102
+ data.step = data.step || 1;
103
+ data.mask = data.mask || [/\w*/gi];
104
+ return control;
105
+ }
106
+ function createFormSelect(id, data) {
107
+ const control = createFormControl(id, "select", data);
108
+ data = control.data;
109
+ data.options = data.options || [];
110
+ data.type = data.type || "select";
111
+ const classType = data.type == "select" ? "select" : `select-${data.type}`;
112
+ data.classes = !data.classes ? `form-group-${classType}` : `${data.classes} form-group-${classType}`;
113
+ return control;
114
+ }
115
+ function createFormStatic(id, data) {
116
+ const control = createFormControl(id, "static", data);
117
+ data = control.data;
118
+ data.style = data.style || "table";
119
+ return control;
120
+ }
121
+ function createFormModel(id, data) {
122
+ const control = createFormControl(id, "model", data);
123
+ data = control.data;
124
+ data.name = data.name || "";
125
+ return control;
126
+ }
127
+ function createFormFile(id, data) {
128
+ const control = createFormControl(id, "file", data);
129
+ data = control.data;
130
+ data.accept = data.accept || ".jpg,.jpeg,.png";
131
+ data.multi = data.multi || false;
132
+ data.baseUrl = ObjectUtils.isString(data.baseUrl) ? data.baseUrl : "assets/";
133
+ data.uploadUrl = ObjectUtils.isString(data.uploadUrl) ? data.uploadUrl : "assets";
134
+ data.createUploadData = data.createUploadData || ((file) => {
135
+ const form = new FormData();
136
+ form.append("file", file);
137
+ return form;
138
+ });
139
+ return control;
140
140
  }
141
141
 
142
- function validateJSON(control) {
143
- const value = control.value;
144
- if (!value)
145
- return null;
146
- try {
147
- JSON.parse(value);
148
- return null;
149
- }
150
- catch (e) {
151
- return { json: true };
152
- }
153
- }
154
- function validateRequiredTranslation(control) {
155
- const value = control.value;
156
- if (!value || value.length == 0)
157
- return { requiredTranslation: true };
158
- return value.findIndex(t => (t.lang == "de" || t.lang == "en") && !t.translation) < 0
159
- ? null
160
- : { requiredTranslation: true };
161
- }
162
- function validatePhone(control) {
163
- const value = control.value;
164
- if (!value)
165
- return Promise.resolve(null);
166
- const phoneRegexp = /^(?:\d){10,12}$/;
167
- return phoneRegexp.test(value) ? null : { phone: true };
142
+ function validateJSON(control) {
143
+ const value = control.value;
144
+ if (!value)
145
+ return null;
146
+ try {
147
+ JSON.parse(value);
148
+ return null;
149
+ }
150
+ catch (e) {
151
+ return { json: true };
152
+ }
153
+ }
154
+ function validateRequiredTranslation(control) {
155
+ const value = control.value;
156
+ if (!value || value.length == 0)
157
+ return { requiredTranslation: true };
158
+ return value.findIndex(t => (t.lang == "de" || t.lang == "en") && !t.translation) < 0
159
+ ? null
160
+ : { requiredTranslation: true };
161
+ }
162
+ function validatePhone(control) {
163
+ const value = control.value;
164
+ if (!value)
165
+ return Promise.resolve(null);
166
+ const phoneRegexp = /^(?:\d){10,12}$/;
167
+ return phoneRegexp.test(value) ? null : { phone: true };
168
168
  }
169
169
 
170
- class FormSubject extends Subject {
171
- constructor(notifyCallback) {
172
- super();
173
- this.notifyCallback = notifyCallback;
174
- }
175
- notify(controlModel, control) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- let value = this.notifyCallback(controlModel, control);
178
- if (value instanceof Promise) {
179
- value = yield value;
180
- }
181
- this.next(value);
182
- });
183
- }
170
+ class FormSubject extends Subject {
171
+ constructor(notifyCallback) {
172
+ super();
173
+ this.notifyCallback = notifyCallback;
174
+ }
175
+ notify(controlModel, control) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ let value = this.notifyCallback(controlModel, control);
178
+ if (value instanceof Promise) {
179
+ value = yield value;
180
+ }
181
+ this.next(value);
182
+ });
183
+ }
184
184
  }
185
185
 
186
- class DynamicFormService extends DynamicFormService$1 {
187
- constructor(cs, vs, openApi) {
188
- super(cs, vs);
189
- this.openApi = openApi;
190
- this.onDetectChanges = new EventEmitter();
191
- }
192
- get api() {
193
- return this.openApi.api;
194
- }
195
- get language() {
196
- return this.api.language;
197
- }
198
- patchGroup(value, formModel, formGroup) {
199
- this.patchValueRecursive(value, formModel, formGroup);
200
- this.detectChanges();
201
- formGroup.patchValue(ObjectUtils.copy(value));
202
- }
203
- patchForm(value, component) {
204
- this.patchValueRecursive(value, component.model, component.group);
205
- this.detectChanges(component);
206
- component.group.patchValue(value);
207
- }
208
- serialize(formModel, formGroup) {
209
- return this.serializeRecursive(formModel, formGroup);
210
- }
211
- notifyChanges(formModel, formGroup) {
212
- this.notifyChangesRecursive(formModel, formGroup);
213
- }
214
- updateSelectOptions(formControlModel, formControl) {
215
- if (formControlModel instanceof DynamicSelectModel) {
216
- let options = formControlModel.options$;
217
- if (options instanceof FormSubject) {
218
- options.notify(formControlModel, formControl);
219
- return;
220
- }
221
- while (options instanceof Subject && options.source) {
222
- options = options.source;
223
- if (options instanceof FormSubject) {
224
- options.notify(formControlModel, formControl);
225
- }
226
- }
227
- }
228
- }
229
- showErrors(form) {
230
- this.showErrorsForGroup(form.group);
231
- this.detectChanges(form);
232
- }
233
- detectChanges(formComponent) {
234
- super.detectChanges(formComponent);
235
- this.onDetectChanges.emit(formComponent);
236
- }
237
- patchValueRecursive(value, formModel, formGroup) {
238
- Object.keys(value).forEach(key => {
239
- const subModel = this.findModelById(key, formModel);
240
- const subValue = value[key];
241
- if (!subModel)
242
- return;
243
- const subControl = this.findControlByModel(subModel, formGroup);
244
- if (subModel instanceof DynamicSelectModel && ObjectUtils.isObject(subValue)) {
245
- value[key] = subValue.id || subValue._id || subValue;
246
- return;
247
- }
248
- if (subModel instanceof DynamicFormArrayModel) {
249
- const length = Array.isArray(subValue) ? subValue.length : 0;
250
- const subArray = subControl;
251
- while (subModel.size > length) {
252
- this.removeFormArrayGroup(0, subArray, subModel);
253
- }
254
- while (subModel.size < length) {
255
- this.insertFormArrayGroup(subModel.size, subArray, subModel);
256
- }
257
- for (let i = 0; i < length; i++) {
258
- const itemModel = subModel.get(i);
259
- this.patchValueRecursive(subValue[i], itemModel.group, subArray.at(i));
260
- }
261
- return;
262
- }
263
- if (subModel instanceof DynamicFormGroupModel) {
264
- this.patchValueRecursive(subValue, subModel.group, subControl);
265
- }
266
- });
267
- }
268
- serializeRecursive(formModel, formGroup) {
269
- var _a;
270
- return __awaiter(this, void 0, void 0, function* () {
271
- const result = {};
272
- if (!formModel || !formGroup || !formGroup.value)
273
- return result;
274
- for (const i in formModel) {
275
- const subModel = formModel[i];
276
- const subControl = this.findControlByModel(subModel, formGroup);
277
- const serializer = (_a = subModel.additional) === null || _a === void 0 ? void 0 : _a.serializer;
278
- if (ObjectUtils.isFunction(serializer)) {
279
- result[subModel.id] = yield serializer(subModel, subControl);
280
- continue;
281
- }
282
- if (subModel instanceof DynamicFormArrayModel) {
283
- const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
284
- const subArray = subControl;
285
- const resArray = [];
286
- for (let i = 0; i < length; i++) {
287
- const itemModel = subModel.get(i);
288
- resArray.push(yield this.serializeRecursive(itemModel.group, subArray.at(i)));
289
- }
290
- result[subModel.id] = resArray;
291
- continue;
292
- }
293
- if (subModel instanceof DynamicFormGroupModel) {
294
- result[subModel.id] = yield this.serializeRecursive(subModel.group, subControl);
295
- continue;
296
- }
297
- result[subModel.id] = subControl.value;
298
- }
299
- return result;
300
- });
301
- }
302
- notifyChangesRecursive(formModel, formGroup) {
303
- if (!formModel || !formGroup)
304
- return;
305
- for (const i in formModel) {
306
- const subModel = formModel[i];
307
- const subControl = this.findControlByModel(subModel, formGroup);
308
- if (subModel instanceof DynamicFormArrayModel) {
309
- const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
310
- const subArray = subControl;
311
- for (let i = 0; i < length; i++) {
312
- const itemModel = subModel.get(i);
313
- this.notifyChangesRecursive(itemModel.group, subArray.at(i));
314
- }
315
- continue;
316
- }
317
- if (subModel instanceof DynamicFormGroupModel) {
318
- this.notifyChangesRecursive(subModel.group, subControl);
319
- continue;
320
- }
321
- this.updateSelectOptions(subModel, subControl);
322
- }
323
- }
324
- showErrorsForGroup(formGroup) {
325
- if (!formGroup)
326
- return;
327
- formGroup.markAsTouched({ onlySelf: true });
328
- const controls = Object.keys(formGroup.controls).map(id => formGroup.controls[id]);
329
- this.showErrorsForControls(controls);
330
- }
331
- showErrorsForControls(controls) {
332
- controls.forEach(control => {
333
- if (control instanceof FormGroup) {
334
- this.showErrorsForGroup(control);
335
- return;
336
- }
337
- control.markAsTouched({ onlySelf: true });
338
- if (control instanceof FormArray) {
339
- this.showErrorsForControls(control.controls);
340
- }
341
- });
342
- }
343
- getFormModelForSchema(name) {
344
- return __awaiter(this, void 0, void 0, function* () {
345
- this.api.cache = {};
346
- this.schemas = yield this.openApi.getSchemas();
347
- return this.getFormModelForSchemaDef(this.schemas[name]);
348
- });
349
- }
350
- getFormModelForSchemaDef(schema) {
351
- if (!schema)
352
- return [];
353
- return Object.keys(schema.properties || {}).map(p => {
354
- const property = schema.properties[p];
355
- return this.getFormControlModel(property, schema);
356
- }).filter(t => null !== t);
357
- }
358
- getFormControlModel(property, schema) {
359
- var _a, _b;
360
- if (Array.isArray(property.enum) || ObjectUtils.isString(property.optionsPath)) {
361
- return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
362
- }
363
- switch (property.type) {
364
- case "string":
365
- case "number":
366
- return new DynamicInputModel(this.getFormInputConfig(property, schema));
367
- case "textarea":
368
- return new DynamicTextAreaModel(this.getFormTextareaConfig(property, schema));
369
- case "boolean":
370
- return new DynamicCheckboxModel(this.getFormCheckboxConfig(property, schema));
371
- case "list":
372
- return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
373
- case "array":
374
- if (((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref) {
375
- return new DynamicFormArrayModel(this.getFormArrayConfig(property, schema));
376
- }
377
- else if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.enum) || property.enum) {
378
- return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
379
- }
380
- else {
381
- return new DynamicInputModel(this.getFormInputConfig(property, schema));
382
- }
383
- case "file":
384
- return new DynamicFileUploadModel(this.getFormUploadConfig(property, schema));
385
- }
386
- if (property.$ref) {
387
- return new DynamicFormGroupModel(this.getFormGroupConfig(property, schema));
388
- }
389
- return null;
390
- }
391
- getFormControlConfig(property, schema) {
392
- const validators = this.getValidators(property, schema);
393
- const errorMessages = Object.keys(validators).reduce((res, key) => {
394
- res[key] = `error.${key}`;
395
- return res;
396
- }, {});
397
- return {
398
- id: property.id,
399
- label: ObjectUtils.isString(property.label) ? property.label : property.id,
400
- hidden: property.hidden,
401
- disabled: property.disabled,
402
- validators,
403
- errorMessages,
404
- additional: Object.assign({}, property)
405
- };
406
- }
407
- getFormArrayConfig(property, schema) {
408
- var _a;
409
- const ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
410
- const subSchema = this.schemas[ref.split("/").pop()];
411
- return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: () => this.getFormModelForSchemaDef(subSchema) });
412
- }
413
- getFormGroupConfig(property, schema) {
414
- const ref = property.$ref || "";
415
- const subSchema = this.schemas[ref.split("/").pop()];
416
- return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
417
- }
418
- getFormInputConfig(property, schema) {
419
- var _a;
420
- let inputType = StringUtils.has(property.id, "password", "Password") ? "password" : (((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
421
- switch (inputType) {
422
- case "boolean":
423
- inputType = "checkbox";
424
- break;
425
- case "textarea":
426
- inputType = "textarea";
427
- break;
428
- }
429
- return Object.assign(this.getFormControlConfig(property, schema), {
430
- inputType,
431
- autoComplete: property.autoComplete || "off",
432
- multiple: property.type == "array"
433
- });
434
- }
435
- getFormTextareaConfig(property, schema) {
436
- return Object.assign(this.getFormControlConfig(property, schema), {
437
- cols: property.cols || null,
438
- rows: property.rows || 10,
439
- wrap: property.wrap || false,
440
- autoComplete: property.autoComplete || "off",
441
- multiple: property.type == "array"
442
- });
443
- }
444
- getFormSelectConfig(property, schema) {
445
- return Object.assign(this.getFormControlConfig(property, schema), {
446
- options: this.getFormSelectOptions(property, schema),
447
- multiple: property.type == "array"
448
- });
449
- }
450
- getFormCheckboxConfig(property, schema) {
451
- return Object.assign(this.getFormControlConfig(property, schema), {
452
- indeterminate: property.indeterminate === true
453
- });
454
- }
455
- translateOptions(options) {
456
- return __awaiter(this, void 0, void 0, function* () {
457
- if (!options)
458
- return [];
459
- for (const option of options) {
460
- option.label = yield this.language.getTranslation(option.label);
461
- }
462
- return options;
463
- });
464
- }
465
- getFormSelectOptions(property, schema) {
466
- var _a;
467
- const $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
468
- if (property.optionsPath) {
469
- return new FormSubject((formModel, control) => {
470
- let path = property.optionsPath;
471
- let target = control;
472
- if (path.startsWith("$root")) {
473
- path = path.substr(5);
474
- while (target.parent) {
475
- target = target.parent;
476
- }
477
- }
478
- while (path.startsWith(".")) {
479
- path = path.substr(1);
480
- if (target.parent) {
481
- target = target.parent;
482
- }
483
- }
484
- const value = ObjectUtils.getValue(target.value, path);
485
- const options = (!ObjectUtils.isArray(value) ? [] : value).map(value => ({ value, label: value }));
486
- return this.translateOptions(options);
487
- });
488
- }
489
- if (ObjectUtils.isArray($enum)) {
490
- return new FormSubject(() => {
491
- const options = $enum.map(value => {
492
- const label = property.translatable ? `${property.id}.${value}` : value;
493
- return { value, label };
494
- });
495
- return this.translateOptions(options);
496
- });
497
- }
498
- return new FormSubject(() => __awaiter(this, void 0, void 0, function* () {
499
- this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(result => {
500
- return result.items.map(i => {
501
- return { value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id };
502
- });
503
- });
504
- const options = (yield this.api.cache[property.endpoint]).map(t => Object.assign({}, t));
505
- return this.translateOptions(options);
506
- }));
507
- }
508
- getFormUploadConfig(property, schema) {
509
- const url = this.api.url(property.url || "assets");
510
- const { accept, autoUpload, maxSize, minSize, removeUrl, showFileList } = property;
511
- return Object.assign(this.getFormControlConfig(property, schema), {
512
- url,
513
- accept,
514
- autoUpload,
515
- maxSize,
516
- minSize,
517
- removeUrl,
518
- showFileList
519
- });
520
- }
521
- getValidators(property, schema) {
522
- const validators = {};
523
- if (schema.required.indexOf(property.id) >= 0) {
524
- validators.required = null;
525
- }
526
- if (property.minLength) {
527
- validators.minLength = property.minLength;
528
- }
529
- if (property.maxLength) {
530
- validators.maxLength = property.maxLength;
531
- }
532
- if (property.min) {
533
- validators.min = property.min;
534
- }
535
- if (property.max) {
536
- validators.max = property.max;
537
- }
538
- switch (property.format) {
539
- case "email":
540
- validators.email = null;
541
- break;
542
- }
543
- return validators;
544
- }
186
+ class DynamicFormArrayModel extends DynamicFormArrayModel$1 {
187
+ constructor(config, layout) {
188
+ super(config, layout);
189
+ this.additional = config.additional || {};
190
+ }
545
191
  }
546
- DynamicFormService.decorators = [
547
- { type: Injectable }
548
- ];
549
- DynamicFormService.ctorParameters = () => [
550
- { type: DynamicFormComponentService },
551
- { type: DynamicFormValidationService$1 },
552
- { type: OpenApiService }
553
- ];
554
192
 
555
- class AsyncSubmitDirective {
556
- constructor(toaster, cdr, elem, renderer) {
557
- this.toaster = toaster;
558
- this.cdr = cdr;
559
- this.elem = elem;
560
- this.renderer = renderer;
561
- this.onSuccess = new EventEmitter();
562
- this.onError = new EventEmitter();
563
- if (elem.nativeElement.tagName !== "BUTTON")
564
- return;
565
- renderer.setAttribute(elem.nativeElement, "type", "button");
566
- }
567
- get isDisabled() {
568
- return this.disabled;
569
- }
570
- set isDisabled(value) {
571
- this.disabled = value;
572
- if (value) {
573
- this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
574
- return;
575
- }
576
- this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
577
- }
578
- get isLoading() {
579
- return this.loading;
580
- }
581
- ngOnInit() {
582
- if (!this.form)
583
- return;
584
- this.isDisabled = this.form.status !== "VALID";
585
- this.cdr.detectChanges();
586
- this.onStatusChange = this.form.onStatusChange.subscribe(() => {
587
- this.isDisabled = this.form.status !== "VALID";
588
- this.cdr.detectChanges();
589
- if (!this.callback || this.form.status == "PENDING")
590
- return;
591
- if (!this.disabled) {
592
- this.callback();
593
- }
594
- this.callback = null;
595
- });
596
- this.onSubmit = this.form.onSubmit.subscribe(() => this.callMethod());
597
- }
598
- ngOnDestroy() {
599
- if (this.onStatusChange)
600
- this.onStatusChange.unsubscribe();
601
- if (this.onSubmit)
602
- this.onSubmit.unsubscribe();
603
- }
604
- click() {
605
- this.callback = () => this.callMethod();
606
- if (this.form.status !== "VALID" && this.form.status !== "INVALID")
607
- return;
608
- this.callback();
609
- this.callback = null;
610
- }
611
- callMethod() {
612
- if (this.loading)
613
- return;
614
- this.loading = true;
615
- this.method(this.form, this.context).then(result => {
616
- this.loading = false;
617
- if (result) {
618
- this.onSuccess.emit(result);
619
- this.toaster.success(result.message, result.context);
620
- }
621
- }, reason => {
622
- if (!reason || !reason.message)
623
- throw new Error("Reason must implement IAsyncMessage interface");
624
- this.loading = false;
625
- this.onError.emit(reason);
626
- this.toaster.error(reason.message, reason.context);
627
- });
628
- }
629
- }
630
- AsyncSubmitDirective.decorators = [
631
- { type: Directive, args: [{
632
- selector: "[async-submit]",
633
- exportAs: "async-submit"
634
- },] }
193
+ class DynamicFormService extends DynamicFormService$1 {
194
+ constructor(cs, vs, openApi) {
195
+ super(cs, vs);
196
+ this.openApi = openApi;
197
+ this.onDetectChanges = new EventEmitter();
198
+ }
199
+ get api() {
200
+ return this.openApi.api;
201
+ }
202
+ get language() {
203
+ return this.api.language;
204
+ }
205
+ patchGroup(value, formModel, formGroup) {
206
+ this.patchValueRecursive(value, formModel, formGroup);
207
+ this.detectChanges();
208
+ formGroup.patchValue(ObjectUtils.copy(value));
209
+ }
210
+ patchForm(value, component) {
211
+ this.patchValueRecursive(value, component.model, component.group);
212
+ this.detectChanges(component);
213
+ component.group.patchValue(value);
214
+ }
215
+ serialize(formModel, formGroup) {
216
+ return this.serializeRecursive(formModel, formGroup);
217
+ }
218
+ notifyChanges(formModel, formGroup) {
219
+ this.notifyChangesRecursive(formModel, formGroup);
220
+ }
221
+ updateSelectOptions(formControlModel, formControl) {
222
+ if (formControlModel instanceof DynamicSelectModel) {
223
+ let options = formControlModel.options$;
224
+ if (options instanceof FormSubject) {
225
+ options.notify(formControlModel, formControl);
226
+ return;
227
+ }
228
+ while (options instanceof Subject && options.source) {
229
+ options = options.source;
230
+ if (options instanceof FormSubject) {
231
+ options.notify(formControlModel, formControl);
232
+ }
233
+ }
234
+ }
235
+ }
236
+ showErrors(form) {
237
+ this.showErrorsForGroup(form.group);
238
+ this.detectChanges(form);
239
+ }
240
+ detectChanges(formComponent) {
241
+ super.detectChanges(formComponent);
242
+ this.onDetectChanges.emit(formComponent);
243
+ }
244
+ patchValueRecursive(value, formModel, formGroup) {
245
+ Object.keys(value).forEach(key => {
246
+ const subModel = this.findModelById(key, formModel);
247
+ const subValue = value[key];
248
+ if (!subModel)
249
+ return;
250
+ const subControl = this.findControlByModel(subModel, formGroup);
251
+ if (subModel instanceof DynamicSelectModel && ObjectUtils.isObject(subValue)) {
252
+ value[key] = subValue.id || subValue._id || subValue;
253
+ return;
254
+ }
255
+ if (subModel instanceof DynamicFormArrayModel$1) {
256
+ const length = Array.isArray(subValue) ? subValue.length : 0;
257
+ const subArray = subControl;
258
+ while (subModel.size > length) {
259
+ this.removeFormArrayGroup(0, subArray, subModel);
260
+ }
261
+ while (subModel.size < length) {
262
+ this.insertFormArrayGroup(subModel.size, subArray, subModel);
263
+ }
264
+ for (let i = 0; i < length; i++) {
265
+ const itemModel = subModel.get(i);
266
+ this.patchValueRecursive(subValue[i], itemModel.group, subArray.at(i));
267
+ }
268
+ return;
269
+ }
270
+ if (subModel instanceof DynamicFormGroupModel) {
271
+ this.patchValueRecursive(subValue, subModel.group, subControl);
272
+ }
273
+ });
274
+ }
275
+ serializeRecursive(formModel, formGroup) {
276
+ var _a;
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ const result = {};
279
+ if (!formModel || !formGroup || !formGroup.value)
280
+ return result;
281
+ for (const i in formModel) {
282
+ const subModel = formModel[i];
283
+ const subControl = this.findControlByModel(subModel, formGroup);
284
+ const serializer = (_a = subModel.additional) === null || _a === void 0 ? void 0 : _a.serializer;
285
+ if (ObjectUtils.isFunction(serializer)) {
286
+ result[subModel.id] = yield serializer(subModel, subControl);
287
+ continue;
288
+ }
289
+ if (subModel instanceof DynamicFormArrayModel$1) {
290
+ const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
291
+ const subArray = subControl;
292
+ const resArray = [];
293
+ for (let i = 0; i < length; i++) {
294
+ const itemModel = subModel.get(i);
295
+ resArray.push(yield this.serializeRecursive(itemModel.group, subArray.at(i)));
296
+ }
297
+ result[subModel.id] = resArray;
298
+ continue;
299
+ }
300
+ if (subModel instanceof DynamicFormGroupModel) {
301
+ result[subModel.id] = yield this.serializeRecursive(subModel.group, subControl);
302
+ continue;
303
+ }
304
+ if (subModel instanceof DynamicInputModel && !ObjectUtils.isNullOrUndefined(subControl.value)) {
305
+ result[subModel.id] = subModel.inputType == "number"
306
+ ? parseFloat((`${subControl.value}` || "0").replace(/,/gi, ".")) || null
307
+ : subControl.value;
308
+ continue;
309
+ }
310
+ result[subModel.id] = subControl.value;
311
+ }
312
+ return result;
313
+ });
314
+ }
315
+ notifyChangesRecursive(formModel, formGroup) {
316
+ if (!formModel || !formGroup)
317
+ return;
318
+ for (const i in formModel) {
319
+ const subModel = formModel[i];
320
+ const subControl = this.findControlByModel(subModel, formGroup);
321
+ if (subModel instanceof DynamicFormArrayModel$1) {
322
+ const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
323
+ const subArray = subControl;
324
+ for (let i = 0; i < length; i++) {
325
+ const itemModel = subModel.get(i);
326
+ this.notifyChangesRecursive(itemModel.group, subArray.at(i));
327
+ }
328
+ continue;
329
+ }
330
+ if (subModel instanceof DynamicFormGroupModel) {
331
+ this.notifyChangesRecursive(subModel.group, subControl);
332
+ continue;
333
+ }
334
+ this.updateSelectOptions(subModel, subControl);
335
+ }
336
+ }
337
+ showErrorsForGroup(formGroup) {
338
+ if (!formGroup)
339
+ return;
340
+ formGroup.markAsTouched({ onlySelf: true });
341
+ const controls = Object.keys(formGroup.controls).map(id => formGroup.controls[id]);
342
+ this.showErrorsForControls(controls);
343
+ }
344
+ showErrorsForControls(controls) {
345
+ controls.forEach(control => {
346
+ if (control instanceof FormGroup) {
347
+ this.showErrorsForGroup(control);
348
+ return;
349
+ }
350
+ control.markAsTouched({ onlySelf: true });
351
+ if (control instanceof FormArray) {
352
+ this.showErrorsForControls(control.controls);
353
+ }
354
+ });
355
+ }
356
+ getFormModelForSchema(name) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ this.api.cache = {};
359
+ this.schemas = yield this.openApi.getSchemas();
360
+ return this.getFormModelForSchemaDef(this.schemas[name]);
361
+ });
362
+ }
363
+ getFormModelForSchemaDef(schema) {
364
+ if (!schema)
365
+ return [];
366
+ return Object.keys(schema.properties || {}).map(p => {
367
+ const property = schema.properties[p];
368
+ return this.getFormControlModel(property, schema);
369
+ }).filter(t => null !== t);
370
+ }
371
+ getFormControlModel(property, schema) {
372
+ var _a, _b;
373
+ if (Array.isArray(property.enum) || ObjectUtils.isString(property.optionsPath)) {
374
+ return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
375
+ }
376
+ switch (property.type) {
377
+ case "string":
378
+ case "number":
379
+ case "integer":
380
+ return new DynamicInputModel(this.getFormInputConfig(property, schema));
381
+ case "textarea":
382
+ return new DynamicTextAreaModel(this.getFormTextareaConfig(property, schema));
383
+ case "boolean":
384
+ return new DynamicCheckboxModel(this.getFormCheckboxConfig(property, schema));
385
+ case "list":
386
+ return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
387
+ case "array":
388
+ if (((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref) {
389
+ return new DynamicFormArrayModel(this.getFormArrayConfig(property, schema));
390
+ }
391
+ else if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.enum) || property.enum) {
392
+ return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
393
+ }
394
+ else {
395
+ return new DynamicInputModel(this.getFormInputConfig(property, schema));
396
+ }
397
+ case "file":
398
+ return new DynamicFileUploadModel(this.getFormUploadConfig(property, schema));
399
+ }
400
+ if (property.$ref) {
401
+ return new DynamicFormGroupModel(this.getFormGroupConfig(property, schema));
402
+ }
403
+ return null;
404
+ }
405
+ getFormControlConfig(property, schema) {
406
+ const validators = this.getValidators(property, schema);
407
+ const errorMessages = Object.keys(validators).reduce((res, key) => {
408
+ res[key] = `error.${key}`;
409
+ return res;
410
+ }, {});
411
+ return {
412
+ id: property.id,
413
+ label: ObjectUtils.isString(property.label) ? property.label : property.id,
414
+ hidden: property.hidden,
415
+ disabled: property.disabled,
416
+ validators,
417
+ errorMessages,
418
+ additional: Object.assign({}, property)
419
+ };
420
+ }
421
+ getFormArrayConfig(property, schema) {
422
+ var _a;
423
+ const ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
424
+ const subSchema = this.schemas[ref.split("/").pop()];
425
+ return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: () => this.getFormModelForSchemaDef(subSchema) });
426
+ }
427
+ getFormGroupConfig(property, schema) {
428
+ const ref = property.$ref || "";
429
+ const subSchema = this.schemas[ref.split("/").pop()];
430
+ return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
431
+ }
432
+ getFormInputConfig(property, schema) {
433
+ var _a;
434
+ let inputType = StringUtils.has(property.id, "password", "Password") ? "password" : (((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
435
+ switch (inputType) {
436
+ case "boolean":
437
+ inputType = "checkbox";
438
+ break;
439
+ case "textarea":
440
+ inputType = "textarea";
441
+ break;
442
+ case "integer":
443
+ inputType = "number";
444
+ break;
445
+ }
446
+ return Object.assign(this.getFormControlConfig(property, schema), {
447
+ inputType,
448
+ autoComplete: property.autoComplete || "off",
449
+ multiple: property.type == "array",
450
+ accept: ObjectUtils.isString(property.accept) ? property.accept : null,
451
+ mask: ObjectUtils.isString(property.mask) ? property.mask : null,
452
+ pattern: ObjectUtils.isString(property.pattern) ? property.pattern : null,
453
+ step: isNaN(property.step) ? 1 : property.step,
454
+ min: isNaN(property.min) ? Number.MIN_SAFE_INTEGER : property.min,
455
+ max: isNaN(property.max) ? Number.MAX_SAFE_INTEGER : property.max,
456
+ });
457
+ }
458
+ getFormTextareaConfig(property, schema) {
459
+ return Object.assign(this.getFormControlConfig(property, schema), {
460
+ cols: property.cols || null,
461
+ rows: property.rows || 10,
462
+ wrap: property.wrap || false,
463
+ autoComplete: property.autoComplete || "off",
464
+ multiple: property.type == "array"
465
+ });
466
+ }
467
+ getFormSelectConfig(property, schema) {
468
+ return Object.assign(this.getFormControlConfig(property, schema), {
469
+ options: this.getFormSelectOptions(property, schema),
470
+ multiple: property.type == "array"
471
+ });
472
+ }
473
+ getFormCheckboxConfig(property, schema) {
474
+ return Object.assign(this.getFormControlConfig(property, schema), {
475
+ indeterminate: property.indeterminate === true
476
+ });
477
+ }
478
+ translateOptions(options) {
479
+ return __awaiter(this, void 0, void 0, function* () {
480
+ if (!options)
481
+ return [];
482
+ for (const option of options) {
483
+ option.label = yield this.language.getTranslation(option.label);
484
+ }
485
+ return options;
486
+ });
487
+ }
488
+ getFormSelectOptions(property, schema) {
489
+ var _a;
490
+ const $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
491
+ if (property.optionsPath) {
492
+ return new FormSubject((formModel, control) => {
493
+ let path = property.optionsPath;
494
+ let target = control;
495
+ if (path.startsWith("$root")) {
496
+ path = path.substr(5);
497
+ while (target.parent) {
498
+ target = target.parent;
499
+ }
500
+ }
501
+ while (path.startsWith(".")) {
502
+ path = path.substr(1);
503
+ if (target.parent) {
504
+ target = target.parent;
505
+ }
506
+ }
507
+ const value = ObjectUtils.getValue(target.value, path);
508
+ const options = (!ObjectUtils.isArray(value) ? [] : value).map(value => ({ value, label: value }));
509
+ return this.translateOptions(options);
510
+ });
511
+ }
512
+ if (ObjectUtils.isArray($enum)) {
513
+ return new FormSubject(() => {
514
+ const options = $enum.map(value => {
515
+ const label = property.translatable ? `${property.id}.${value}` : value;
516
+ return { value, label };
517
+ });
518
+ return this.translateOptions(options);
519
+ });
520
+ }
521
+ return new FormSubject(() => __awaiter(this, void 0, void 0, function* () {
522
+ this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(result => {
523
+ return result.items.map(i => {
524
+ return { value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id };
525
+ });
526
+ });
527
+ const options = (yield this.api.cache[property.endpoint]).map(t => Object.assign({}, t));
528
+ return this.translateOptions(options);
529
+ }));
530
+ }
531
+ getFormUploadConfig(property, schema) {
532
+ const url = this.api.url(property.url || "assets");
533
+ const { accept, autoUpload, maxSize, minSize, removeUrl, showFileList } = property;
534
+ return Object.assign(this.getFormControlConfig(property, schema), {
535
+ url,
536
+ accept,
537
+ autoUpload,
538
+ maxSize,
539
+ minSize,
540
+ removeUrl,
541
+ showFileList
542
+ });
543
+ }
544
+ getValidators(property, schema) {
545
+ const validators = {};
546
+ if (ObjectUtils.isArray(schema.required) && schema.required.indexOf(property.id) >= 0) {
547
+ validators.required = null;
548
+ }
549
+ if (property.minLength) {
550
+ validators.minLength = property.minLength;
551
+ }
552
+ if (property.maxLength) {
553
+ validators.maxLength = property.maxLength;
554
+ }
555
+ if (property.min) {
556
+ validators.min = property.min;
557
+ }
558
+ if (property.max) {
559
+ validators.max = property.max;
560
+ }
561
+ switch (property.format) {
562
+ case "email":
563
+ validators.email = null;
564
+ break;
565
+ }
566
+ return validators;
567
+ }
568
+ }
569
+ DynamicFormService.decorators = [
570
+ { type: Injectable }
571
+ ];
572
+ DynamicFormService.ctorParameters = () => [
573
+ { type: DynamicFormComponentService },
574
+ { type: DynamicFormValidationService$1 },
575
+ { type: OpenApiService }
635
576
  ];
636
- AsyncSubmitDirective.ctorParameters = () => [
637
- { type: undefined, decorators: [{ type: Inject, args: [TOASTER_SERVICE,] }] },
638
- { type: ChangeDetectorRef },
639
- { type: ElementRef },
640
- { type: Renderer2 }
641
- ];
642
- AsyncSubmitDirective.propDecorators = {
643
- method: [{ type: Input, args: ["async-submit",] }],
644
- form: [{ type: Input }],
645
- context: [{ type: Input }],
646
- onSuccess: [{ type: Output }],
647
- onError: [{ type: Output }],
648
- isDisabled: [{ type: HostBinding, args: ["class.disabled",] }],
649
- isLoading: [{ type: HostBinding, args: ["class.loading",] }],
650
- click: [{ type: HostListener, args: ["click",] }]
577
+
578
+ class AsyncSubmitDirective {
579
+ constructor(toaster, cdr, elem, renderer) {
580
+ this.toaster = toaster;
581
+ this.cdr = cdr;
582
+ this.elem = elem;
583
+ this.renderer = renderer;
584
+ this.onSuccess = new EventEmitter();
585
+ this.onError = new EventEmitter();
586
+ if (elem.nativeElement.tagName !== "BUTTON")
587
+ return;
588
+ renderer.setAttribute(elem.nativeElement, "type", "button");
589
+ }
590
+ get isDisabled() {
591
+ return this.disabled;
592
+ }
593
+ set isDisabled(value) {
594
+ this.disabled = value;
595
+ if (value) {
596
+ this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
597
+ return;
598
+ }
599
+ this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
600
+ }
601
+ get isLoading() {
602
+ return this.loading;
603
+ }
604
+ ngOnInit() {
605
+ if (!this.form)
606
+ return;
607
+ this.isDisabled = this.form.status !== "VALID";
608
+ this.cdr.detectChanges();
609
+ this.onStatusChange = this.form.onStatusChange.subscribe(() => {
610
+ this.isDisabled = this.form.status !== "VALID";
611
+ this.cdr.detectChanges();
612
+ if (!this.callback || this.form.status == "PENDING")
613
+ return;
614
+ if (!this.disabled) {
615
+ this.callback();
616
+ }
617
+ this.callback = null;
618
+ });
619
+ this.onSubmit = this.form.onSubmit.subscribe(() => this.callMethod());
620
+ }
621
+ ngOnDestroy() {
622
+ if (this.onStatusChange)
623
+ this.onStatusChange.unsubscribe();
624
+ if (this.onSubmit)
625
+ this.onSubmit.unsubscribe();
626
+ }
627
+ click() {
628
+ this.callback = () => this.callMethod();
629
+ if (this.form.status !== "VALID" && this.form.status !== "INVALID")
630
+ return;
631
+ this.callback();
632
+ this.callback = null;
633
+ }
634
+ callMethod() {
635
+ if (this.loading)
636
+ return;
637
+ this.loading = true;
638
+ this.method(this.form, this.context).then(result => {
639
+ this.loading = false;
640
+ if (result) {
641
+ this.onSuccess.emit(result);
642
+ this.toaster.success(result.message, result.context);
643
+ }
644
+ }, reason => {
645
+ if (!reason || !reason.message)
646
+ throw new Error("Reason must implement IAsyncMessage interface");
647
+ this.loading = false;
648
+ this.onError.emit(reason);
649
+ this.toaster.error(reason.message, reason.context);
650
+ });
651
+ }
652
+ }
653
+ AsyncSubmitDirective.decorators = [
654
+ { type: Directive, args: [{
655
+ selector: "[async-submit]",
656
+ exportAs: "async-submit"
657
+ },] }
658
+ ];
659
+ AsyncSubmitDirective.ctorParameters = () => [
660
+ { type: undefined, decorators: [{ type: Inject, args: [TOASTER_SERVICE,] }] },
661
+ { type: ChangeDetectorRef },
662
+ { type: ElementRef },
663
+ { type: Renderer2 }
664
+ ];
665
+ AsyncSubmitDirective.propDecorators = {
666
+ method: [{ type: Input, args: ["async-submit",] }],
667
+ form: [{ type: Input }],
668
+ context: [{ type: Input }],
669
+ onSuccess: [{ type: Output }],
670
+ onError: [{ type: Output }],
671
+ isDisabled: [{ type: HostBinding, args: ["class.disabled",] }],
672
+ isLoading: [{ type: HostBinding, args: ["class.loading",] }],
673
+ click: [{ type: HostListener, args: ["click",] }]
651
674
  };
652
675
 
653
- class DynamicBaseFormComponent extends DynamicFormComponent {
654
- constructor(formService, events, changeDetectorRef, componentService) {
655
- super(changeDetectorRef, componentService);
656
- this.formService = formService;
657
- this.events = events;
658
- this.blur = new EventEmitter();
659
- this.change = new EventEmitter();
660
- this.focus = new EventEmitter();
661
- this.onStatusChange = new EventEmitter();
662
- this.onValueChange = new EventEmitter();
663
- this.onSubmit = new EventEmitter();
664
- this.templates = new QueryList();
665
- this.subscription = new Subscription();
666
- this.groupSubscription = new Subscription();
667
- this.labelPrefix = "label";
668
- }
669
- get status() {
670
- return !this.group ? null : this.group.status;
671
- }
672
- ngOnChanges(changes) {
673
- this.groupSubscription.unsubscribe();
674
- if (this.group) {
675
- this.groupSubscription = ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(() => {
676
- this.onStatusChange.emit(this);
677
- }), this.group.valueChanges.subscribe(() => {
678
- this.onValueChange.emit(this);
679
- this.formService.notifyChanges(this.model, this.group);
680
- }));
681
- }
682
- }
683
- ngAfterViewInit() {
684
- this.subscription = ObservableUtils.multiSubscription(ObservableUtils.subscribe({
685
- subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
686
- cb: () => {
687
- const templates = this.contentTemplates.toArray().concat(this.viewTemplates.toArray());
688
- this.templates.reset(templates);
689
- }
690
- }), this.events.languageChanged.subscribe(() => {
691
- this.formService.detectChanges(this);
692
- }), this.ngForm.ngSubmit.subscribe(() => {
693
- this.onSubmit.emit(this);
694
- }));
695
- }
696
- ngOnDestroy() {
697
- super.ngOnDestroy();
698
- this.subscription.unsubscribe();
699
- this.groupSubscription.unsubscribe();
700
- }
701
- insertFormArrayGroup(index, formArray, formArrayModel) {
702
- this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
703
- this.changeDetectorRef.detectChanges();
704
- }
705
- removeFormArrayGroup(index, formArray, formArrayModel) {
706
- this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
707
- this.changeDetectorRef.detectChanges();
708
- }
709
- moveFormArrayGroup(index, step, formArray, formArrayModel) {
710
- this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
711
- this.changeDetectorRef.detectChanges();
712
- }
713
- clearFormArray(formArray, formArrayModel) {
714
- this.formService.clearFormArray(formArray, formArrayModel);
715
- this.changeDetectorRef.detectChanges();
716
- }
717
- validate(showErrors = true) {
718
- if (!this.group)
719
- return Promise.resolve();
720
- return new Promise((resolve, reject) => {
721
- this.group.statusChanges.pipe(first(status => status == "VALID" || status == "INVALID")).subscribe(status => {
722
- if (showErrors) {
723
- this.formService.showErrors(this);
724
- }
725
- if (status == "VALID") {
726
- resolve(null);
727
- return;
728
- }
729
- reject(null);
730
- });
731
- this.group.updateValueAndValidity();
732
- });
733
- }
734
- serialize(validate) {
735
- return __awaiter(this, void 0, void 0, function* () {
736
- if (!this.group)
737
- return null;
738
- if (validate) {
739
- yield this.validate();
740
- }
741
- return yield this.formService.serialize(this.model, this.group);
742
- });
743
- }
744
- }
745
- DynamicBaseFormComponent.decorators = [
746
- { type: Component, args: [{
747
- selector: "dynamic-base-form",
748
- template: "",
749
- changeDetection: ChangeDetectionStrategy.Default
750
- },] }
751
- ];
752
- DynamicBaseFormComponent.ctorParameters = () => [
753
- { type: DynamicFormService, decorators: [{ type: Inject, args: [DynamicFormService,] }] },
754
- { type: EventsService, decorators: [{ type: Inject, args: [EventsService,] }] },
755
- { type: ChangeDetectorRef },
756
- { type: DynamicFormComponentService }
757
- ];
758
- DynamicBaseFormComponent.propDecorators = {
759
- group: [{ type: Input }],
760
- model: [{ type: Input }],
761
- layout: [{ type: Input }],
762
- labelPrefix: [{ type: Input }],
763
- blur: [{ type: Output }],
764
- change: [{ type: Output }],
765
- focus: [{ type: Output }],
766
- contentTemplates: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
767
- viewTemplates: [{ type: ViewChildren, args: [DynamicTemplateDirective,] }],
768
- onStatusChange: [{ type: Output }],
769
- onValueChange: [{ type: Output }],
770
- onSubmit: [{ type: Output }],
771
- ngForm: [{ type: ViewChild, args: [NgForm,] }]
676
+ class DynamicBaseFormComponent extends DynamicFormComponent {
677
+ constructor(formService, events, changeDetectorRef, componentService) {
678
+ super(changeDetectorRef, componentService);
679
+ this.formService = formService;
680
+ this.events = events;
681
+ this.blur = new EventEmitter();
682
+ this.change = new EventEmitter();
683
+ this.focus = new EventEmitter();
684
+ this.onStatusChange = new EventEmitter();
685
+ this.onValueChange = new EventEmitter();
686
+ this.onSubmit = new EventEmitter();
687
+ this.templates = new QueryList();
688
+ this.subscription = new Subscription();
689
+ this.groupSubscription = new Subscription();
690
+ this.labelPrefix = "label";
691
+ }
692
+ get status() {
693
+ return !this.group ? null : this.group.status;
694
+ }
695
+ ngOnChanges(changes) {
696
+ this.groupSubscription.unsubscribe();
697
+ if (this.group) {
698
+ this.groupSubscription = ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(() => {
699
+ this.onStatusChange.emit(this);
700
+ }), this.group.valueChanges.subscribe(() => {
701
+ this.onValueChange.emit(this);
702
+ this.formService.notifyChanges(this.model, this.group);
703
+ }));
704
+ }
705
+ }
706
+ ngAfterViewInit() {
707
+ this.subscription = ObservableUtils.multiSubscription(ObservableUtils.subscribe({
708
+ subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
709
+ cb: () => {
710
+ const templates = this.contentTemplates.toArray().concat(this.viewTemplates.toArray());
711
+ this.templates.reset(templates);
712
+ }
713
+ }), this.events.languageChanged.subscribe(() => {
714
+ this.formService.detectChanges(this);
715
+ }), this.ngForm.ngSubmit.subscribe(() => {
716
+ this.onSubmit.emit(this);
717
+ }));
718
+ }
719
+ ngOnDestroy() {
720
+ super.ngOnDestroy();
721
+ this.subscription.unsubscribe();
722
+ this.groupSubscription.unsubscribe();
723
+ }
724
+ insertFormArrayGroup(index, formArray, formArrayModel) {
725
+ this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
726
+ this.changeDetectorRef.detectChanges();
727
+ }
728
+ removeFormArrayGroup(index, formArray, formArrayModel) {
729
+ this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
730
+ this.changeDetectorRef.detectChanges();
731
+ }
732
+ moveFormArrayGroup(index, step, formArray, formArrayModel) {
733
+ this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
734
+ this.changeDetectorRef.detectChanges();
735
+ }
736
+ clearFormArray(formArray, formArrayModel) {
737
+ this.formService.clearFormArray(formArray, formArrayModel);
738
+ this.changeDetectorRef.detectChanges();
739
+ }
740
+ validate(showErrors = true) {
741
+ if (!this.group)
742
+ return Promise.resolve();
743
+ return new Promise((resolve, reject) => {
744
+ this.group.statusChanges.pipe(first(status => status == "VALID" || status == "INVALID")).subscribe(status => {
745
+ if (showErrors) {
746
+ this.formService.showErrors(this);
747
+ }
748
+ if (status == "VALID") {
749
+ resolve(null);
750
+ return;
751
+ }
752
+ reject(null);
753
+ });
754
+ this.group.updateValueAndValidity();
755
+ });
756
+ }
757
+ serialize(validate) {
758
+ return __awaiter(this, void 0, void 0, function* () {
759
+ if (!this.group)
760
+ return null;
761
+ if (validate) {
762
+ yield this.validate();
763
+ }
764
+ return yield this.formService.serialize(this.model, this.group);
765
+ });
766
+ }
767
+ }
768
+ DynamicBaseFormComponent.decorators = [
769
+ { type: Component, args: [{
770
+ selector: "dynamic-base-form",
771
+ template: "",
772
+ changeDetection: ChangeDetectionStrategy.Default
773
+ },] }
774
+ ];
775
+ DynamicBaseFormComponent.ctorParameters = () => [
776
+ { type: DynamicFormService, decorators: [{ type: Inject, args: [DynamicFormService,] }] },
777
+ { type: EventsService, decorators: [{ type: Inject, args: [EventsService,] }] },
778
+ { type: ChangeDetectorRef },
779
+ { type: DynamicFormComponentService }
780
+ ];
781
+ DynamicBaseFormComponent.propDecorators = {
782
+ group: [{ type: Input }],
783
+ model: [{ type: Input }],
784
+ layout: [{ type: Input }],
785
+ labelPrefix: [{ type: Input }],
786
+ blur: [{ type: Output }],
787
+ change: [{ type: Output }],
788
+ focus: [{ type: Output }],
789
+ contentTemplates: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
790
+ viewTemplates: [{ type: ViewChildren, args: [DynamicTemplateDirective,] }],
791
+ onStatusChange: [{ type: Output }],
792
+ onValueChange: [{ type: Output }],
793
+ onSubmit: [{ type: Output }],
794
+ ngForm: [{ type: ViewChild, args: [NgForm,] }]
772
795
  };
773
796
 
774
- class DynamicBaseFormControlContainerComponent extends DynamicFormControlContainerComponent {
775
- constructor(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
776
- super(changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService);
777
- this.form = form;
778
- this.changeDetectorRef = changeDetectorRef;
779
- this.componentFactoryResolver = componentFactoryResolver;
780
- this.layoutService = layoutService;
781
- this.validationService = validationService;
782
- this.componentService = componentService;
783
- this.relationService = relationService;
784
- this.context = null;
785
- this.blur = new EventEmitter();
786
- this.change = new EventEmitter();
787
- this.focus = new EventEmitter();
788
- }
789
- get componentType() {
790
- var _a;
791
- return (_a = this.componentService.getCustomComponentType(this.model)) !== null && _a !== void 0 ? _a : this.getComponentType(this.model);
792
- }
793
- get startTemplate() {
794
- return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
795
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
796
- : this.layoutService.getStartTemplate(this.model, this.templates);
797
- }
798
- get endTemplate() {
799
- return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
800
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
801
- : this.layoutService.getEndTemplate(this.model, this.templates);
802
- }
803
- get formService() {
804
- return this.form.formService;
805
- }
806
- ngOnInit() {
807
- this.onDetectChanges = this.formService.onDetectChanges.subscribe(form => {
808
- if (form !== this.form)
809
- return;
810
- this.changeDetectorRef.detectChanges();
811
- this.formService.updateSelectOptions(this.model, this.control);
812
- });
813
- }
814
- ngOnDestroy() {
815
- super.ngOnDestroy();
816
- this.onDetectChanges.unsubscribe();
817
- }
818
- createFormControlComponent() {
819
- var _a;
820
- super.createFormControlComponent();
821
- const component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
822
- if (!component || !ObjectUtils.isFunction(component.onCreated))
823
- return;
824
- component.onCreated();
825
- }
826
- getComponentType(model) {
827
- return null;
828
- }
829
- }
830
- DynamicBaseFormControlContainerComponent.decorators = [
831
- { type: Component, args: [{
832
- selector: "dynamic-base-form-control",
833
- template: "",
834
- changeDetection: ChangeDetectionStrategy.OnPush
835
- },] }
836
- ];
837
- DynamicBaseFormControlContainerComponent.ctorParameters = () => [
838
- { type: DynamicBaseFormComponent },
839
- { type: ChangeDetectorRef },
840
- { type: ComponentFactoryResolver },
841
- { type: DynamicFormLayoutService },
842
- { type: DynamicFormValidationService$1 },
843
- { type: DynamicFormComponentService },
844
- { type: DynamicFormRelationService }
845
- ];
846
- DynamicBaseFormControlContainerComponent.propDecorators = {
847
- contentTemplateList: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
848
- klass: [{ type: HostBinding, args: ["class",] }],
849
- context: [{ type: Input }],
850
- group: [{ type: Input }],
851
- hostClass: [{ type: Input }],
852
- inputTemplateList: [{ type: Input, args: ["templates",] }],
853
- layout: [{ type: Input }],
854
- model: [{ type: Input }],
855
- blur: [{ type: Output }],
856
- change: [{ type: Output }],
857
- focus: [{ type: Output }],
858
- componentViewContainerRef: [{ type: ViewChild, args: ["componentViewContainer", { read: ViewContainerRef, static: true },] }]
797
+ class DynamicBaseFormControlContainerComponent extends DynamicFormControlContainerComponent {
798
+ constructor(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
799
+ super(changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService);
800
+ this.form = form;
801
+ this.changeDetectorRef = changeDetectorRef;
802
+ this.componentFactoryResolver = componentFactoryResolver;
803
+ this.layoutService = layoutService;
804
+ this.validationService = validationService;
805
+ this.componentService = componentService;
806
+ this.relationService = relationService;
807
+ this.context = null;
808
+ this.blur = new EventEmitter();
809
+ this.change = new EventEmitter();
810
+ this.focus = new EventEmitter();
811
+ }
812
+ get componentType() {
813
+ var _a;
814
+ return (_a = this.componentService.getCustomComponentType(this.model)) !== null && _a !== void 0 ? _a : this.getComponentType(this.model);
815
+ }
816
+ get startTemplate() {
817
+ return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
818
+ ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
819
+ : this.layoutService.getStartTemplate(this.model, this.templates);
820
+ }
821
+ get endTemplate() {
822
+ return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
823
+ ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
824
+ : this.layoutService.getEndTemplate(this.model, this.templates);
825
+ }
826
+ get formService() {
827
+ return this.form.formService;
828
+ }
829
+ ngOnInit() {
830
+ this.onDetectChanges = this.formService.onDetectChanges.subscribe(form => {
831
+ if (form !== this.form)
832
+ return;
833
+ this.changeDetectorRef.detectChanges();
834
+ this.formService.updateSelectOptions(this.model, this.control);
835
+ });
836
+ }
837
+ ngOnDestroy() {
838
+ super.ngOnDestroy();
839
+ this.onDetectChanges.unsubscribe();
840
+ }
841
+ createFormControlComponent() {
842
+ var _a;
843
+ super.createFormControlComponent();
844
+ const component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
845
+ if (!component || !ObjectUtils.isFunction(component.onCreated))
846
+ return;
847
+ component.onCreated();
848
+ }
849
+ getComponentType(model) {
850
+ return null;
851
+ }
852
+ }
853
+ DynamicBaseFormControlContainerComponent.decorators = [
854
+ { type: Component, args: [{
855
+ selector: "dynamic-base-form-control",
856
+ template: "",
857
+ changeDetection: ChangeDetectionStrategy.OnPush
858
+ },] }
859
+ ];
860
+ DynamicBaseFormControlContainerComponent.ctorParameters = () => [
861
+ { type: DynamicBaseFormComponent },
862
+ { type: ChangeDetectorRef },
863
+ { type: ComponentFactoryResolver },
864
+ { type: DynamicFormLayoutService },
865
+ { type: DynamicFormValidationService$1 },
866
+ { type: DynamicFormComponentService },
867
+ { type: DynamicFormRelationService }
868
+ ];
869
+ DynamicBaseFormControlContainerComponent.propDecorators = {
870
+ contentTemplateList: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
871
+ klass: [{ type: HostBinding, args: ["class",] }],
872
+ context: [{ type: Input }],
873
+ group: [{ type: Input }],
874
+ hostClass: [{ type: Input }],
875
+ inputTemplateList: [{ type: Input, args: ["templates",] }],
876
+ layout: [{ type: Input }],
877
+ model: [{ type: Input }],
878
+ blur: [{ type: Output }],
879
+ change: [{ type: Output }],
880
+ focus: [{ type: Output }],
881
+ componentViewContainerRef: [{ type: ViewChild, args: ["componentViewContainer", { read: ViewContainerRef, static: true },] }]
859
882
  };
860
883
 
861
- class DynamicFormValidationService extends DynamicFormValidationService$1 {
862
- showErrorMessages(control, model, hasFocus) {
863
- return super.showErrorMessages(control, model, hasFocus);
864
- }
865
- }
866
- DynamicFormValidationService.decorators = [
867
- { type: Injectable }
884
+ class DynamicFormValidationService extends DynamicFormValidationService$1 {
885
+ showErrorMessages(control, model, hasFocus) {
886
+ return super.showErrorMessages(control, model, hasFocus);
887
+ }
888
+ }
889
+ DynamicFormValidationService.decorators = [
890
+ { type: Injectable }
868
891
  ];
869
892
 
870
- // --- Components ---
871
- const components = [
872
- DynamicBaseFormComponent,
873
- DynamicBaseFormControlContainerComponent
874
- ];
875
- // --- Directives ---
876
- const directives = [
877
- AsyncSubmitDirective,
878
- ];
879
- // --- Pipes ---
880
- const pipes = [];
881
- const ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validatePhone, ɵ3 = new Map([
882
- ["validateJSON", validateJSON],
883
- ["validateRequiredTranslation", validateRequiredTranslation],
884
- ["validatePhone", validatePhone],
885
- ]);
886
- class NgxDynamicFormModule {
887
- static forRoot() {
888
- return {
889
- ngModule: NgxDynamicFormModule,
890
- providers: [
891
- DynamicFormService,
892
- DynamicFormValidationService,
893
- {
894
- provide: DynamicFormService$1,
895
- useExisting: DynamicFormService
896
- },
897
- {
898
- provide: DynamicFormValidationService$1,
899
- useExisting: DynamicFormValidationService
900
- }
901
- ]
902
- };
903
- }
904
- }
905
- NgxDynamicFormModule.decorators = [
906
- { type: NgModule, args: [{
907
- declarations: [
908
- ...components,
909
- ...directives,
910
- ...pipes
911
- ],
912
- imports: [
913
- CommonModule,
914
- FormsModule,
915
- ReactiveFormsModule,
916
- NgxUtilsModule
917
- ],
918
- exports: [
919
- ...components,
920
- ...directives,
921
- ...pipes,
922
- FormsModule,
923
- ReactiveFormsModule,
924
- NgxUtilsModule
925
- ],
926
- entryComponents: components,
927
- providers: [
928
- ...pipes,
929
- { provide: NG_VALIDATORS, useValue: ɵ0$1, multi: true },
930
- { provide: NG_VALIDATORS, useValue: ɵ1, multi: true },
931
- { provide: NG_VALIDATORS, useValue: ɵ2, multi: true },
932
- {
933
- provide: DYNAMIC_VALIDATORS,
934
- useValue: ɵ3
935
- }
936
- ]
937
- },] }
893
+ // --- Components ---
894
+ const components = [
895
+ DynamicBaseFormComponent,
896
+ DynamicBaseFormControlContainerComponent
897
+ ];
898
+ // --- Directives ---
899
+ const directives = [
900
+ AsyncSubmitDirective,
901
+ ];
902
+ // --- Pipes ---
903
+ const pipes = [];
904
+ const ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validatePhone, ɵ3 = new Map([
905
+ ["validateJSON", validateJSON],
906
+ ["validateRequiredTranslation", validateRequiredTranslation],
907
+ ["validatePhone", validatePhone],
908
+ ]);
909
+ class NgxDynamicFormModule {
910
+ static forRoot() {
911
+ return {
912
+ ngModule: NgxDynamicFormModule,
913
+ providers: [
914
+ DynamicFormService,
915
+ DynamicFormValidationService,
916
+ {
917
+ provide: DynamicFormService$1,
918
+ useExisting: DynamicFormService
919
+ },
920
+ {
921
+ provide: DynamicFormValidationService$1,
922
+ useExisting: DynamicFormValidationService
923
+ }
924
+ ]
925
+ };
926
+ }
927
+ }
928
+ NgxDynamicFormModule.decorators = [
929
+ { type: NgModule, args: [{
930
+ declarations: [
931
+ ...components,
932
+ ...directives,
933
+ ...pipes
934
+ ],
935
+ imports: [
936
+ CommonModule,
937
+ FormsModule,
938
+ ReactiveFormsModule,
939
+ NgxUtilsModule
940
+ ],
941
+ exports: [
942
+ ...components,
943
+ ...directives,
944
+ ...pipes,
945
+ FormsModule,
946
+ ReactiveFormsModule,
947
+ NgxUtilsModule
948
+ ],
949
+ entryComponents: components,
950
+ providers: [
951
+ ...pipes,
952
+ { provide: NG_VALIDATORS, useValue: ɵ0$1, multi: true },
953
+ { provide: NG_VALIDATORS, useValue: ɵ1, multi: true },
954
+ { provide: NG_VALIDATORS, useValue: ɵ2, multi: true },
955
+ {
956
+ provide: DYNAMIC_VALIDATORS,
957
+ useValue: ɵ3
958
+ }
959
+ ]
960
+ },] }
938
961
  ];
939
962
 
940
- /**
941
- * Generated bundle index. Do not edit.
963
+ /**
964
+ * Generated bundle index. Do not edit.
942
965
  */
943
966
 
944
967
  export { AsyncSubmitDirective, DynamicBaseFormComponent, DynamicBaseFormControlContainerComponent, DynamicFormService, FormFieldSet, FormFile, FormInput, FormModel, FormSelect, FormSerializable, FormStatic, FormSubject, NgxDynamicFormModule, createFormControl, createFormInput, createFormModel, createFormSelect, createFormStatic, defaultSerializer, defineFormControl, getFormControl, getFormFieldSets, getFormSerializer, validateJSON, validatePhone, validateRequiredTranslation, components as ɵa, directives as ɵb, pipes as ɵc, DynamicFormValidationService as ɵd };