@stemy/ngx-dynamic-form 10.2.19 → 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 (32) hide show
  1. package/README.md +27 -27
  2. package/bundles/stemy-ngx-dynamic-form.umd.js +1417 -1396
  3. package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
  4. package/bundles/stemy-ngx-dynamic-form.umd.min.js +1 -1
  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 -389
  13. package/esm2015/ngx-dynamic-form/utils/dynamic-form-array.model.js +8 -8
  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 +935 -931
  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 -40
  27. package/ngx-dynamic-form/utils/dynamic-form-array.model.d.ts +12 -12
  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
@@ -7,957 +7,961 @@ import { DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormService as
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 DynamicFormArrayModel extends DynamicFormArrayModel$1 {
187
- constructor(config, layout) {
188
- super(config, layout);
189
- this.additional = config.additional || {};
190
- }
186
+ class DynamicFormArrayModel extends DynamicFormArrayModel$1 {
187
+ constructor(config, layout) {
188
+ super(config, layout);
189
+ this.additional = config.additional || {};
190
+ }
191
191
  }
192
192
 
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
- return new DynamicInputModel(this.getFormInputConfig(property, schema));
380
- case "textarea":
381
- return new DynamicTextAreaModel(this.getFormTextareaConfig(property, schema));
382
- case "boolean":
383
- return new DynamicCheckboxModel(this.getFormCheckboxConfig(property, schema));
384
- case "list":
385
- return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
386
- case "array":
387
- if (((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref) {
388
- return new DynamicFormArrayModel(this.getFormArrayConfig(property, schema));
389
- }
390
- else if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.enum) || property.enum) {
391
- return new DynamicSelectModel(this.getFormSelectConfig(property, schema));
392
- }
393
- else {
394
- return new DynamicInputModel(this.getFormInputConfig(property, schema));
395
- }
396
- case "file":
397
- return new DynamicFileUploadModel(this.getFormUploadConfig(property, schema));
398
- }
399
- if (property.$ref) {
400
- return new DynamicFormGroupModel(this.getFormGroupConfig(property, schema));
401
- }
402
- return null;
403
- }
404
- getFormControlConfig(property, schema) {
405
- const validators = this.getValidators(property, schema);
406
- const errorMessages = Object.keys(validators).reduce((res, key) => {
407
- res[key] = `error.${key}`;
408
- return res;
409
- }, {});
410
- return {
411
- id: property.id,
412
- label: ObjectUtils.isString(property.label) ? property.label : property.id,
413
- hidden: property.hidden,
414
- disabled: property.disabled,
415
- validators,
416
- errorMessages,
417
- additional: Object.assign({}, property)
418
- };
419
- }
420
- getFormArrayConfig(property, schema) {
421
- var _a;
422
- const ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
423
- const subSchema = this.schemas[ref.split("/").pop()];
424
- return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: () => this.getFormModelForSchemaDef(subSchema) });
425
- }
426
- getFormGroupConfig(property, schema) {
427
- const ref = property.$ref || "";
428
- const subSchema = this.schemas[ref.split("/").pop()];
429
- return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
430
- }
431
- getFormInputConfig(property, schema) {
432
- var _a;
433
- let inputType = StringUtils.has(property.id, "password", "Password") ? "password" : (((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
434
- switch (inputType) {
435
- case "boolean":
436
- inputType = "checkbox";
437
- break;
438
- case "textarea":
439
- inputType = "textarea";
440
- break;
441
- }
442
- return Object.assign(this.getFormControlConfig(property, schema), {
443
- inputType,
444
- autoComplete: property.autoComplete || "off",
445
- multiple: property.type == "array",
446
- accept: ObjectUtils.isString(property.accept) ? property.accept : null,
447
- mask: ObjectUtils.isString(property.mask) ? property.mask : null,
448
- pattern: ObjectUtils.isString(property.pattern) ? property.pattern : null,
449
- step: isNaN(property.step) ? 1 : property.step,
450
- min: isNaN(property.min) ? Number.MIN_SAFE_INTEGER : property.min,
451
- max: isNaN(property.max) ? Number.MAX_SAFE_INTEGER : property.max,
452
- });
453
- }
454
- getFormTextareaConfig(property, schema) {
455
- return Object.assign(this.getFormControlConfig(property, schema), {
456
- cols: property.cols || null,
457
- rows: property.rows || 10,
458
- wrap: property.wrap || false,
459
- autoComplete: property.autoComplete || "off",
460
- multiple: property.type == "array"
461
- });
462
- }
463
- getFormSelectConfig(property, schema) {
464
- return Object.assign(this.getFormControlConfig(property, schema), {
465
- options: this.getFormSelectOptions(property, schema),
466
- multiple: property.type == "array"
467
- });
468
- }
469
- getFormCheckboxConfig(property, schema) {
470
- return Object.assign(this.getFormControlConfig(property, schema), {
471
- indeterminate: property.indeterminate === true
472
- });
473
- }
474
- translateOptions(options) {
475
- return __awaiter(this, void 0, void 0, function* () {
476
- if (!options)
477
- return [];
478
- for (const option of options) {
479
- option.label = yield this.language.getTranslation(option.label);
480
- }
481
- return options;
482
- });
483
- }
484
- getFormSelectOptions(property, schema) {
485
- var _a;
486
- const $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
487
- if (property.optionsPath) {
488
- return new FormSubject((formModel, control) => {
489
- let path = property.optionsPath;
490
- let target = control;
491
- if (path.startsWith("$root")) {
492
- path = path.substr(5);
493
- while (target.parent) {
494
- target = target.parent;
495
- }
496
- }
497
- while (path.startsWith(".")) {
498
- path = path.substr(1);
499
- if (target.parent) {
500
- target = target.parent;
501
- }
502
- }
503
- const value = ObjectUtils.getValue(target.value, path);
504
- const options = (!ObjectUtils.isArray(value) ? [] : value).map(value => ({ value, label: value }));
505
- return this.translateOptions(options);
506
- });
507
- }
508
- if (ObjectUtils.isArray($enum)) {
509
- return new FormSubject(() => {
510
- const options = $enum.map(value => {
511
- const label = property.translatable ? `${property.id}.${value}` : value;
512
- return { value, label };
513
- });
514
- return this.translateOptions(options);
515
- });
516
- }
517
- return new FormSubject(() => __awaiter(this, void 0, void 0, function* () {
518
- this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(result => {
519
- return result.items.map(i => {
520
- return { value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id };
521
- });
522
- });
523
- const options = (yield this.api.cache[property.endpoint]).map(t => Object.assign({}, t));
524
- return this.translateOptions(options);
525
- }));
526
- }
527
- getFormUploadConfig(property, schema) {
528
- const url = this.api.url(property.url || "assets");
529
- const { accept, autoUpload, maxSize, minSize, removeUrl, showFileList } = property;
530
- return Object.assign(this.getFormControlConfig(property, schema), {
531
- url,
532
- accept,
533
- autoUpload,
534
- maxSize,
535
- minSize,
536
- removeUrl,
537
- showFileList
538
- });
539
- }
540
- getValidators(property, schema) {
541
- const validators = {};
542
- if (schema.required.indexOf(property.id) >= 0) {
543
- validators.required = null;
544
- }
545
- if (property.minLength) {
546
- validators.minLength = property.minLength;
547
- }
548
- if (property.maxLength) {
549
- validators.maxLength = property.maxLength;
550
- }
551
- if (property.min) {
552
- validators.min = property.min;
553
- }
554
- if (property.max) {
555
- validators.max = property.max;
556
- }
557
- switch (property.format) {
558
- case "email":
559
- validators.email = null;
560
- break;
561
- }
562
- return validators;
563
- }
564
- }
565
- DynamicFormService.decorators = [
566
- { type: Injectable }
567
- ];
568
- DynamicFormService.ctorParameters = () => [
569
- { type: DynamicFormComponentService },
570
- { type: DynamicFormValidationService$1 },
571
- { type: OpenApiService }
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 }
572
576
  ];
573
577
 
574
- class AsyncSubmitDirective {
575
- constructor(toaster, cdr, elem, renderer) {
576
- this.toaster = toaster;
577
- this.cdr = cdr;
578
- this.elem = elem;
579
- this.renderer = renderer;
580
- this.onSuccess = new EventEmitter();
581
- this.onError = new EventEmitter();
582
- if (elem.nativeElement.tagName !== "BUTTON")
583
- return;
584
- renderer.setAttribute(elem.nativeElement, "type", "button");
585
- }
586
- get isDisabled() {
587
- return this.disabled;
588
- }
589
- set isDisabled(value) {
590
- this.disabled = value;
591
- if (value) {
592
- this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
593
- return;
594
- }
595
- this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
596
- }
597
- get isLoading() {
598
- return this.loading;
599
- }
600
- ngOnInit() {
601
- if (!this.form)
602
- return;
603
- this.isDisabled = this.form.status !== "VALID";
604
- this.cdr.detectChanges();
605
- this.onStatusChange = this.form.onStatusChange.subscribe(() => {
606
- this.isDisabled = this.form.status !== "VALID";
607
- this.cdr.detectChanges();
608
- if (!this.callback || this.form.status == "PENDING")
609
- return;
610
- if (!this.disabled) {
611
- this.callback();
612
- }
613
- this.callback = null;
614
- });
615
- this.onSubmit = this.form.onSubmit.subscribe(() => this.callMethod());
616
- }
617
- ngOnDestroy() {
618
- if (this.onStatusChange)
619
- this.onStatusChange.unsubscribe();
620
- if (this.onSubmit)
621
- this.onSubmit.unsubscribe();
622
- }
623
- click() {
624
- this.callback = () => this.callMethod();
625
- if (this.form.status !== "VALID" && this.form.status !== "INVALID")
626
- return;
627
- this.callback();
628
- this.callback = null;
629
- }
630
- callMethod() {
631
- if (this.loading)
632
- return;
633
- this.loading = true;
634
- this.method(this.form, this.context).then(result => {
635
- this.loading = false;
636
- if (result) {
637
- this.onSuccess.emit(result);
638
- this.toaster.success(result.message, result.context);
639
- }
640
- }, reason => {
641
- if (!reason || !reason.message)
642
- throw new Error("Reason must implement IAsyncMessage interface");
643
- this.loading = false;
644
- this.onError.emit(reason);
645
- this.toaster.error(reason.message, reason.context);
646
- });
647
- }
648
- }
649
- AsyncSubmitDirective.decorators = [
650
- { type: Directive, args: [{
651
- selector: "[async-submit]",
652
- exportAs: "async-submit"
653
- },] }
654
- ];
655
- AsyncSubmitDirective.ctorParameters = () => [
656
- { type: undefined, decorators: [{ type: Inject, args: [TOASTER_SERVICE,] }] },
657
- { type: ChangeDetectorRef },
658
- { type: ElementRef },
659
- { type: Renderer2 }
660
- ];
661
- AsyncSubmitDirective.propDecorators = {
662
- method: [{ type: Input, args: ["async-submit",] }],
663
- form: [{ type: Input }],
664
- context: [{ type: Input }],
665
- onSuccess: [{ type: Output }],
666
- onError: [{ type: Output }],
667
- isDisabled: [{ type: HostBinding, args: ["class.disabled",] }],
668
- isLoading: [{ type: HostBinding, args: ["class.loading",] }],
669
- click: [{ type: HostListener, args: ["click",] }]
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",] }]
670
674
  };
671
675
 
672
- class DynamicBaseFormComponent extends DynamicFormComponent {
673
- constructor(formService, events, changeDetectorRef, componentService) {
674
- super(changeDetectorRef, componentService);
675
- this.formService = formService;
676
- this.events = events;
677
- this.blur = new EventEmitter();
678
- this.change = new EventEmitter();
679
- this.focus = new EventEmitter();
680
- this.onStatusChange = new EventEmitter();
681
- this.onValueChange = new EventEmitter();
682
- this.onSubmit = new EventEmitter();
683
- this.templates = new QueryList();
684
- this.subscription = new Subscription();
685
- this.groupSubscription = new Subscription();
686
- this.labelPrefix = "label";
687
- }
688
- get status() {
689
- return !this.group ? null : this.group.status;
690
- }
691
- ngOnChanges(changes) {
692
- this.groupSubscription.unsubscribe();
693
- if (this.group) {
694
- this.groupSubscription = ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(() => {
695
- this.onStatusChange.emit(this);
696
- }), this.group.valueChanges.subscribe(() => {
697
- this.onValueChange.emit(this);
698
- this.formService.notifyChanges(this.model, this.group);
699
- }));
700
- }
701
- }
702
- ngAfterViewInit() {
703
- this.subscription = ObservableUtils.multiSubscription(ObservableUtils.subscribe({
704
- subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
705
- cb: () => {
706
- const templates = this.contentTemplates.toArray().concat(this.viewTemplates.toArray());
707
- this.templates.reset(templates);
708
- }
709
- }), this.events.languageChanged.subscribe(() => {
710
- this.formService.detectChanges(this);
711
- }), this.ngForm.ngSubmit.subscribe(() => {
712
- this.onSubmit.emit(this);
713
- }));
714
- }
715
- ngOnDestroy() {
716
- super.ngOnDestroy();
717
- this.subscription.unsubscribe();
718
- this.groupSubscription.unsubscribe();
719
- }
720
- insertFormArrayGroup(index, formArray, formArrayModel) {
721
- this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
722
- this.changeDetectorRef.detectChanges();
723
- }
724
- removeFormArrayGroup(index, formArray, formArrayModel) {
725
- this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
726
- this.changeDetectorRef.detectChanges();
727
- }
728
- moveFormArrayGroup(index, step, formArray, formArrayModel) {
729
- this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
730
- this.changeDetectorRef.detectChanges();
731
- }
732
- clearFormArray(formArray, formArrayModel) {
733
- this.formService.clearFormArray(formArray, formArrayModel);
734
- this.changeDetectorRef.detectChanges();
735
- }
736
- validate(showErrors = true) {
737
- if (!this.group)
738
- return Promise.resolve();
739
- return new Promise((resolve, reject) => {
740
- this.group.statusChanges.pipe(first(status => status == "VALID" || status == "INVALID")).subscribe(status => {
741
- if (showErrors) {
742
- this.formService.showErrors(this);
743
- }
744
- if (status == "VALID") {
745
- resolve(null);
746
- return;
747
- }
748
- reject(null);
749
- });
750
- this.group.updateValueAndValidity();
751
- });
752
- }
753
- serialize(validate) {
754
- return __awaiter(this, void 0, void 0, function* () {
755
- if (!this.group)
756
- return null;
757
- if (validate) {
758
- yield this.validate();
759
- }
760
- return yield this.formService.serialize(this.model, this.group);
761
- });
762
- }
763
- }
764
- DynamicBaseFormComponent.decorators = [
765
- { type: Component, args: [{
766
- selector: "dynamic-base-form",
767
- template: "",
768
- changeDetection: ChangeDetectionStrategy.Default
769
- },] }
770
- ];
771
- DynamicBaseFormComponent.ctorParameters = () => [
772
- { type: DynamicFormService, decorators: [{ type: Inject, args: [DynamicFormService,] }] },
773
- { type: EventsService, decorators: [{ type: Inject, args: [EventsService,] }] },
774
- { type: ChangeDetectorRef },
775
- { type: DynamicFormComponentService }
776
- ];
777
- DynamicBaseFormComponent.propDecorators = {
778
- group: [{ type: Input }],
779
- model: [{ type: Input }],
780
- layout: [{ type: Input }],
781
- labelPrefix: [{ type: Input }],
782
- blur: [{ type: Output }],
783
- change: [{ type: Output }],
784
- focus: [{ type: Output }],
785
- contentTemplates: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
786
- viewTemplates: [{ type: ViewChildren, args: [DynamicTemplateDirective,] }],
787
- onStatusChange: [{ type: Output }],
788
- onValueChange: [{ type: Output }],
789
- onSubmit: [{ type: Output }],
790
- 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,] }]
791
795
  };
792
796
 
793
- class DynamicBaseFormControlContainerComponent extends DynamicFormControlContainerComponent {
794
- constructor(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
795
- super(changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService);
796
- this.form = form;
797
- this.changeDetectorRef = changeDetectorRef;
798
- this.componentFactoryResolver = componentFactoryResolver;
799
- this.layoutService = layoutService;
800
- this.validationService = validationService;
801
- this.componentService = componentService;
802
- this.relationService = relationService;
803
- this.context = null;
804
- this.blur = new EventEmitter();
805
- this.change = new EventEmitter();
806
- this.focus = new EventEmitter();
807
- }
808
- get componentType() {
809
- var _a;
810
- return (_a = this.componentService.getCustomComponentType(this.model)) !== null && _a !== void 0 ? _a : this.getComponentType(this.model);
811
- }
812
- get startTemplate() {
813
- return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
814
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
815
- : this.layoutService.getStartTemplate(this.model, this.templates);
816
- }
817
- get endTemplate() {
818
- return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
819
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
820
- : this.layoutService.getEndTemplate(this.model, this.templates);
821
- }
822
- get formService() {
823
- return this.form.formService;
824
- }
825
- ngOnInit() {
826
- this.onDetectChanges = this.formService.onDetectChanges.subscribe(form => {
827
- if (form !== this.form)
828
- return;
829
- this.changeDetectorRef.detectChanges();
830
- this.formService.updateSelectOptions(this.model, this.control);
831
- });
832
- }
833
- ngOnDestroy() {
834
- super.ngOnDestroy();
835
- this.onDetectChanges.unsubscribe();
836
- }
837
- createFormControlComponent() {
838
- var _a;
839
- super.createFormControlComponent();
840
- const component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
841
- if (!component || !ObjectUtils.isFunction(component.onCreated))
842
- return;
843
- component.onCreated();
844
- }
845
- getComponentType(model) {
846
- return null;
847
- }
848
- }
849
- DynamicBaseFormControlContainerComponent.decorators = [
850
- { type: Component, args: [{
851
- selector: "dynamic-base-form-control",
852
- template: "",
853
- changeDetection: ChangeDetectionStrategy.OnPush
854
- },] }
855
- ];
856
- DynamicBaseFormControlContainerComponent.ctorParameters = () => [
857
- { type: DynamicBaseFormComponent },
858
- { type: ChangeDetectorRef },
859
- { type: ComponentFactoryResolver },
860
- { type: DynamicFormLayoutService },
861
- { type: DynamicFormValidationService$1 },
862
- { type: DynamicFormComponentService },
863
- { type: DynamicFormRelationService }
864
- ];
865
- DynamicBaseFormControlContainerComponent.propDecorators = {
866
- contentTemplateList: [{ type: ContentChildren, args: [DynamicTemplateDirective,] }],
867
- klass: [{ type: HostBinding, args: ["class",] }],
868
- context: [{ type: Input }],
869
- group: [{ type: Input }],
870
- hostClass: [{ type: Input }],
871
- inputTemplateList: [{ type: Input, args: ["templates",] }],
872
- layout: [{ type: Input }],
873
- model: [{ type: Input }],
874
- blur: [{ type: Output }],
875
- change: [{ type: Output }],
876
- focus: [{ type: Output }],
877
- 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 },] }]
878
882
  };
879
883
 
880
- class DynamicFormValidationService extends DynamicFormValidationService$1 {
881
- showErrorMessages(control, model, hasFocus) {
882
- return super.showErrorMessages(control, model, hasFocus);
883
- }
884
- }
885
- DynamicFormValidationService.decorators = [
886
- { 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 }
887
891
  ];
888
892
 
889
- // --- Components ---
890
- const components = [
891
- DynamicBaseFormComponent,
892
- DynamicBaseFormControlContainerComponent
893
- ];
894
- // --- Directives ---
895
- const directives = [
896
- AsyncSubmitDirective,
897
- ];
898
- // --- Pipes ---
899
- const pipes = [];
900
- const ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validatePhone, ɵ3 = new Map([
901
- ["validateJSON", validateJSON],
902
- ["validateRequiredTranslation", validateRequiredTranslation],
903
- ["validatePhone", validatePhone],
904
- ]);
905
- class NgxDynamicFormModule {
906
- static forRoot() {
907
- return {
908
- ngModule: NgxDynamicFormModule,
909
- providers: [
910
- DynamicFormService,
911
- DynamicFormValidationService,
912
- {
913
- provide: DynamicFormService$1,
914
- useExisting: DynamicFormService
915
- },
916
- {
917
- provide: DynamicFormValidationService$1,
918
- useExisting: DynamicFormValidationService
919
- }
920
- ]
921
- };
922
- }
923
- }
924
- NgxDynamicFormModule.decorators = [
925
- { type: NgModule, args: [{
926
- declarations: [
927
- ...components,
928
- ...directives,
929
- ...pipes
930
- ],
931
- imports: [
932
- CommonModule,
933
- FormsModule,
934
- ReactiveFormsModule,
935
- NgxUtilsModule
936
- ],
937
- exports: [
938
- ...components,
939
- ...directives,
940
- ...pipes,
941
- FormsModule,
942
- ReactiveFormsModule,
943
- NgxUtilsModule
944
- ],
945
- entryComponents: components,
946
- providers: [
947
- ...pipes,
948
- { provide: NG_VALIDATORS, useValue: ɵ0$1, multi: true },
949
- { provide: NG_VALIDATORS, useValue: ɵ1, multi: true },
950
- { provide: NG_VALIDATORS, useValue: ɵ2, multi: true },
951
- {
952
- provide: DYNAMIC_VALIDATORS,
953
- useValue: ɵ3
954
- }
955
- ]
956
- },] }
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
+ },] }
957
961
  ];
958
962
 
959
- /**
960
- * Generated bundle index. Do not edit.
963
+ /**
964
+ * Generated bundle index. Do not edit.
961
965
  */
962
966
 
963
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 };