@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
@@ -1,1405 +1,1448 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@stemy/ngx-utils'), require('rxjs'), require('@angular/core'), require('@ng-dynamic-forms/core'), require('@angular/forms'), require('rxjs/operators'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@stemy/ngx-dynamic-form', ['exports', '@stemy/ngx-utils', 'rxjs', '@angular/core', '@ng-dynamic-forms/core', '@angular/forms', 'rxjs/operators', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy['ngx-dynamic-form'] = {}), global.ngxUtils, global.rxjs, global.ng.core, global.core$1, global.ng.forms, global.rxjs.operators, global.ng.common));
5
- }(this, (function (exports, ngxUtils, rxjs, core, core$1, forms, operators, common) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@stemy/ngx-utils'), require('rxjs'), require('@angular/core'), require('@angular/forms'), require('@ng-dynamic-forms/core'), require('rxjs/operators'), require('@angular/common')) :
3
+ typeof define === 'function' && define.amd ? define('@stemy/ngx-dynamic-form', ['exports', '@stemy/ngx-utils', 'rxjs', '@angular/core', '@angular/forms', '@ng-dynamic-forms/core', 'rxjs/operators', '@angular/common'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy['ngx-dynamic-form'] = {}), global.ngxUtils, global.rxjs, global.ng.core, global.ng.forms, global.core, global.rxjs.operators, global.ng.common));
5
+ }(this, (function (exports, ngxUtils, rxjs, core$1, forms, core, operators, common) { 'use strict';
6
6
 
7
- // --- Decorator functions ---
8
- var emptyArray = [];
9
- var emptyTester = function () {
10
- return Promise.resolve(false);
11
- };
12
- var ɵ0 = emptyTester;
13
- function defaultSerializer(id, parent) {
14
- var control = parent.get(id);
15
- return !control ? null : control.value;
16
- }
17
- function FormSerializable(serializer) {
18
- return function (target, propertyKey) {
19
- ngxUtils.ReflectUtils.defineMetadata("dynamicFormSerializer", serializer || defaultSerializer, target, propertyKey);
20
- };
21
- }
22
- function FormInput(data) {
23
- return function (target, propertyKey) {
24
- var meta = ngxUtils.ReflectUtils.getOwnMetadata("design:type", target, propertyKey);
25
- var type = meta ? meta.name : "";
26
- var inputType = propertyKey.indexOf("password") < 0 ? "text" : "password";
27
- switch (type) {
28
- case "Number":
29
- inputType = "number";
30
- break;
31
- case "Boolean":
32
- inputType = "checkbox";
33
- break;
34
- }
35
- defineFormControl(target, propertyKey, createFormInput(propertyKey, data, inputType));
36
- };
37
- }
38
- function FormSelect(data) {
39
- return function (target, propertyKey) {
40
- defineFormControl(target, propertyKey, createFormSelect(propertyKey, data));
41
- };
42
- }
43
- function FormStatic(data) {
44
- return function (target, propertyKey) {
45
- defineFormControl(target, propertyKey, createFormStatic(propertyKey, data));
46
- };
47
- }
48
- function FormModel(data) {
49
- return function (target, propertyKey) {
50
- defineFormControl(target, propertyKey, createFormModel(propertyKey, data));
51
- };
52
- }
53
- function FormFile(data) {
54
- return function (target, propertyKey) {
55
- defineFormControl(target, propertyKey, createFormFile(propertyKey, data));
56
- };
57
- }
58
- function FormFieldSet(data) {
59
- return function (target) {
60
- var sets = getFormFieldSets(target);
61
- data.classes = data.classes || "";
62
- sets[data.id] = data;
63
- ngxUtils.ReflectUtils.defineMetadata("dynamicFormFieldSets", sets, target);
64
- };
65
- }
66
- function defineFormControl(target, propertyKey, control) {
67
- ngxUtils.ReflectUtils.defineMetadata("dynamicFormControl", control, target, propertyKey);
68
- }
69
- function getFormFieldSets(target) {
70
- return ngxUtils.ReflectUtils.getMetadata("dynamicFormFieldSets", target) || {};
71
- }
72
- function getFormControl(target, propertyKey) {
73
- return ngxUtils.ReflectUtils.getMetadata("dynamicFormControl", target, propertyKey);
74
- }
75
- function getFormSerializer(target, propertyKey) {
76
- return ngxUtils.ReflectUtils.getMetadata("dynamicFormSerializer", target, propertyKey);
77
- }
78
- function createFormControl(id, type, data) {
79
- data = data || {};
80
- data.label = ngxUtils.ObjectUtils.isNullOrUndefined(data.label) ? id : data.label;
81
- data.labelAlign = data.labelAlign || "left";
82
- data.fieldSet = data.fieldSet || ngxUtils.UniqueUtils.uuid();
83
- data.classes = data.classes || "";
84
- data.readonly = data.readonly || emptyTester;
85
- data.hidden = data.hidden || emptyTester;
86
- data.validators = data.validators || emptyArray;
87
- return {
88
- id: id,
89
- type: type,
90
- data: data
91
- };
92
- }
93
- function createFormInput(id, data, type) {
94
- if (type === void 0) { type = "text"; }
95
- var control = createFormControl(id, "input", data);
96
- data = control.data;
97
- data.type = data.type || type;
98
- data.classes = !data.classes ? "form-group-" + data.type : data.classes + " form-group-" + data.type;
99
- data.placeholder = data.placeholder || (data.type == "mask" ? "_" : "");
100
- data.step = data.step || 1;
101
- data.mask = data.mask || [/\w*/gi];
102
- return control;
103
- }
104
- function createFormSelect(id, data) {
105
- var control = createFormControl(id, "select", data);
106
- data = control.data;
107
- data.options = data.options || [];
108
- data.type = data.type || "select";
109
- var classType = data.type == "select" ? "select" : "select-" + data.type;
110
- data.classes = !data.classes ? "form-group-" + classType : data.classes + " form-group-" + classType;
111
- return control;
112
- }
113
- function createFormStatic(id, data) {
114
- var control = createFormControl(id, "static", data);
115
- data = control.data;
116
- data.style = data.style || "table";
117
- return control;
118
- }
119
- function createFormModel(id, data) {
120
- var control = createFormControl(id, "model", data);
121
- data = control.data;
122
- data.name = data.name || "";
123
- return control;
124
- }
125
- function createFormFile(id, data) {
126
- var control = createFormControl(id, "file", data);
127
- data = control.data;
128
- data.accept = data.accept || ".jpg,.jpeg,.png";
129
- data.multi = data.multi || false;
130
- data.baseUrl = ngxUtils.ObjectUtils.isString(data.baseUrl) ? data.baseUrl : "assets/";
131
- data.uploadUrl = ngxUtils.ObjectUtils.isString(data.uploadUrl) ? data.uploadUrl : "assets";
132
- data.createUploadData = data.createUploadData || (function (file) {
133
- var form = new FormData();
134
- form.append("file", file);
135
- return form;
136
- });
137
- return control;
7
+ // --- Decorator functions ---
8
+ var emptyArray = [];
9
+ var emptyTester = function () {
10
+ return Promise.resolve(false);
11
+ };
12
+ var ɵ0 = emptyTester;
13
+ function defaultSerializer(id, parent) {
14
+ var control = parent.get(id);
15
+ return !control ? null : control.value;
16
+ }
17
+ function FormSerializable(serializer) {
18
+ return function (target, propertyKey) {
19
+ ngxUtils.ReflectUtils.defineMetadata("dynamicFormSerializer", serializer || defaultSerializer, target, propertyKey);
20
+ };
21
+ }
22
+ function FormInput(data) {
23
+ return function (target, propertyKey) {
24
+ var meta = ngxUtils.ReflectUtils.getOwnMetadata("design:type", target, propertyKey);
25
+ var type = meta ? meta.name : "";
26
+ var inputType = propertyKey.indexOf("password") < 0 ? "text" : "password";
27
+ switch (type) {
28
+ case "Number":
29
+ inputType = "number";
30
+ break;
31
+ case "Boolean":
32
+ inputType = "checkbox";
33
+ break;
34
+ }
35
+ defineFormControl(target, propertyKey, createFormInput(propertyKey, data, inputType));
36
+ };
37
+ }
38
+ function FormSelect(data) {
39
+ return function (target, propertyKey) {
40
+ defineFormControl(target, propertyKey, createFormSelect(propertyKey, data));
41
+ };
42
+ }
43
+ function FormStatic(data) {
44
+ return function (target, propertyKey) {
45
+ defineFormControl(target, propertyKey, createFormStatic(propertyKey, data));
46
+ };
47
+ }
48
+ function FormModel(data) {
49
+ return function (target, propertyKey) {
50
+ defineFormControl(target, propertyKey, createFormModel(propertyKey, data));
51
+ };
52
+ }
53
+ function FormFile(data) {
54
+ return function (target, propertyKey) {
55
+ defineFormControl(target, propertyKey, createFormFile(propertyKey, data));
56
+ };
57
+ }
58
+ function FormFieldSet(data) {
59
+ return function (target) {
60
+ var sets = getFormFieldSets(target);
61
+ data.classes = data.classes || "";
62
+ sets[data.id] = data;
63
+ ngxUtils.ReflectUtils.defineMetadata("dynamicFormFieldSets", sets, target);
64
+ };
65
+ }
66
+ function defineFormControl(target, propertyKey, control) {
67
+ ngxUtils.ReflectUtils.defineMetadata("dynamicFormControl", control, target, propertyKey);
68
+ }
69
+ function getFormFieldSets(target) {
70
+ return ngxUtils.ReflectUtils.getMetadata("dynamicFormFieldSets", target) || {};
71
+ }
72
+ function getFormControl(target, propertyKey) {
73
+ return ngxUtils.ReflectUtils.getMetadata("dynamicFormControl", target, propertyKey);
74
+ }
75
+ function getFormSerializer(target, propertyKey) {
76
+ return ngxUtils.ReflectUtils.getMetadata("dynamicFormSerializer", target, propertyKey);
77
+ }
78
+ function createFormControl(id, type, data) {
79
+ data = data || {};
80
+ data.label = ngxUtils.ObjectUtils.isNullOrUndefined(data.label) ? id : data.label;
81
+ data.labelAlign = data.labelAlign || "left";
82
+ data.fieldSet = data.fieldSet || ngxUtils.UniqueUtils.uuid();
83
+ data.classes = data.classes || "";
84
+ data.readonly = data.readonly || emptyTester;
85
+ data.hidden = data.hidden || emptyTester;
86
+ data.validators = data.validators || emptyArray;
87
+ return {
88
+ id: id,
89
+ type: type,
90
+ data: data
91
+ };
92
+ }
93
+ function createFormInput(id, data, type) {
94
+ if (type === void 0) { type = "text"; }
95
+ var control = createFormControl(id, "input", data);
96
+ data = control.data;
97
+ data.type = data.type || type;
98
+ data.classes = !data.classes ? "form-group-" + data.type : data.classes + " form-group-" + data.type;
99
+ data.placeholder = data.placeholder || (data.type == "mask" ? "_" : "");
100
+ data.step = data.step || 1;
101
+ data.mask = data.mask || [/\w*/gi];
102
+ return control;
103
+ }
104
+ function createFormSelect(id, data) {
105
+ var control = createFormControl(id, "select", data);
106
+ data = control.data;
107
+ data.options = data.options || [];
108
+ data.type = data.type || "select";
109
+ var classType = data.type == "select" ? "select" : "select-" + data.type;
110
+ data.classes = !data.classes ? "form-group-" + classType : data.classes + " form-group-" + classType;
111
+ return control;
112
+ }
113
+ function createFormStatic(id, data) {
114
+ var control = createFormControl(id, "static", data);
115
+ data = control.data;
116
+ data.style = data.style || "table";
117
+ return control;
118
+ }
119
+ function createFormModel(id, data) {
120
+ var control = createFormControl(id, "model", data);
121
+ data = control.data;
122
+ data.name = data.name || "";
123
+ return control;
124
+ }
125
+ function createFormFile(id, data) {
126
+ var control = createFormControl(id, "file", data);
127
+ data = control.data;
128
+ data.accept = data.accept || ".jpg,.jpeg,.png";
129
+ data.multi = data.multi || false;
130
+ data.baseUrl = ngxUtils.ObjectUtils.isString(data.baseUrl) ? data.baseUrl : "assets/";
131
+ data.uploadUrl = ngxUtils.ObjectUtils.isString(data.uploadUrl) ? data.uploadUrl : "assets";
132
+ data.createUploadData = data.createUploadData || (function (file) {
133
+ var form = new FormData();
134
+ form.append("file", file);
135
+ return form;
136
+ });
137
+ return control;
138
138
  }
139
139
 
140
- function validateJSON(control) {
141
- var value = control.value;
142
- if (!value)
143
- return null;
144
- try {
145
- JSON.parse(value);
146
- return null;
147
- }
148
- catch (e) {
149
- return { json: true };
150
- }
140
+ function validateJSON(control) {
141
+ var value = control.value;
142
+ if (!value)
143
+ return null;
144
+ try {
145
+ JSON.parse(value);
146
+ return null;
147
+ }
148
+ catch (e) {
149
+ return { json: true };
150
+ }
151
+ }
152
+ function validateRequiredTranslation(control) {
153
+ var value = control.value;
154
+ if (!value || value.length == 0)
155
+ return { requiredTranslation: true };
156
+ return value.findIndex(function (t) { return (t.lang == "de" || t.lang == "en") && !t.translation; }) < 0
157
+ ? null
158
+ : { requiredTranslation: true };
159
+ }
160
+ function validatePhone(control) {
161
+ var value = control.value;
162
+ if (!value)
163
+ return Promise.resolve(null);
164
+ var phoneRegexp = /^(?:\d){10,12}$/;
165
+ return phoneRegexp.test(value) ? null : { phone: true };
151
166
  }
152
- function validateRequiredTranslation(control) {
153
- var value = control.value;
154
- if (!value || value.length == 0)
155
- return { requiredTranslation: true };
156
- return value.findIndex(function (t) { return (t.lang == "de" || t.lang == "en") && !t.translation; }) < 0
157
- ? null
158
- : { requiredTranslation: true };
159
- }
160
- function validatePhone(control) {
161
- var value = control.value;
162
- if (!value)
163
- return Promise.resolve(null);
164
- var phoneRegexp = /^(?:\d){10,12}$/;
165
- return phoneRegexp.test(value) ? null : { phone: true };
166
- }
167
-
168
- /*! *****************************************************************************
169
- Copyright (c) Microsoft Corporation.
170
167
 
171
- Permission to use, copy, modify, and/or distribute this software for any
172
- purpose with or without fee is hereby granted.
173
-
174
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
175
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
176
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
177
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
178
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
179
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
180
- PERFORMANCE OF THIS SOFTWARE.
181
- ***************************************************************************** */
182
- /* global Reflect, Promise */
183
- var extendStatics = function (d, b) {
184
- extendStatics = Object.setPrototypeOf ||
185
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
186
- function (d, b) { for (var p in b)
187
- if (Object.prototype.hasOwnProperty.call(b, p))
188
- d[p] = b[p]; };
189
- return extendStatics(d, b);
190
- };
191
- function __extends(d, b) {
192
- extendStatics(d, b);
193
- function __() { this.constructor = d; }
194
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
195
- }
196
- var __assign = function () {
197
- __assign = Object.assign || function __assign(t) {
198
- for (var s, i = 1, n = arguments.length; i < n; i++) {
199
- s = arguments[i];
200
- for (var p in s)
201
- if (Object.prototype.hasOwnProperty.call(s, p))
202
- t[p] = s[p];
203
- }
204
- return t;
205
- };
206
- return __assign.apply(this, arguments);
207
- };
208
- function __rest(s, e) {
209
- var t = {};
210
- for (var p in s)
211
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
212
- t[p] = s[p];
213
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
214
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
215
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
216
- t[p[i]] = s[p[i]];
217
- }
218
- return t;
219
- }
220
- function __decorate(decorators, target, key, desc) {
221
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
222
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
223
- r = Reflect.decorate(decorators, target, key, desc);
224
- else
225
- for (var i = decorators.length - 1; i >= 0; i--)
226
- if (d = decorators[i])
227
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
228
- return c > 3 && r && Object.defineProperty(target, key, r), r;
229
- }
230
- function __param(paramIndex, decorator) {
231
- return function (target, key) { decorator(target, key, paramIndex); };
232
- }
233
- function __metadata(metadataKey, metadataValue) {
234
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
235
- return Reflect.metadata(metadataKey, metadataValue);
236
- }
237
- function __awaiter(thisArg, _arguments, P, generator) {
238
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
239
- return new (P || (P = Promise))(function (resolve, reject) {
240
- function fulfilled(value) { try {
241
- step(generator.next(value));
242
- }
243
- catch (e) {
244
- reject(e);
245
- } }
246
- function rejected(value) { try {
247
- step(generator["throw"](value));
248
- }
249
- catch (e) {
250
- reject(e);
251
- } }
252
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
253
- step((generator = generator.apply(thisArg, _arguments || [])).next());
254
- });
255
- }
256
- function __generator(thisArg, body) {
257
- var _ = { label: 0, sent: function () { if (t[0] & 1)
258
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
259
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
260
- function verb(n) { return function (v) { return step([n, v]); }; }
261
- function step(op) {
262
- if (f)
263
- throw new TypeError("Generator is already executing.");
264
- while (_)
265
- try {
266
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
267
- return t;
268
- if (y = 0, t)
269
- op = [op[0] & 2, t.value];
270
- switch (op[0]) {
271
- case 0:
272
- case 1:
273
- t = op;
274
- break;
275
- case 4:
276
- _.label++;
277
- return { value: op[1], done: false };
278
- case 5:
279
- _.label++;
280
- y = op[1];
281
- op = [0];
282
- continue;
283
- case 7:
284
- op = _.ops.pop();
285
- _.trys.pop();
286
- continue;
287
- default:
288
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
289
- _ = 0;
290
- continue;
291
- }
292
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
293
- _.label = op[1];
294
- break;
295
- }
296
- if (op[0] === 6 && _.label < t[1]) {
297
- _.label = t[1];
298
- t = op;
299
- break;
300
- }
301
- if (t && _.label < t[2]) {
302
- _.label = t[2];
303
- _.ops.push(op);
304
- break;
305
- }
306
- if (t[2])
307
- _.ops.pop();
308
- _.trys.pop();
309
- continue;
310
- }
311
- op = body.call(thisArg, _);
312
- }
313
- catch (e) {
314
- op = [6, e];
315
- y = 0;
316
- }
317
- finally {
318
- f = t = 0;
319
- }
320
- if (op[0] & 5)
321
- throw op[1];
322
- return { value: op[0] ? op[1] : void 0, done: true };
323
- }
324
- }
325
- var __createBinding = Object.create ? (function (o, m, k, k2) {
326
- if (k2 === undefined)
327
- k2 = k;
328
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
329
- }) : (function (o, m, k, k2) {
330
- if (k2 === undefined)
331
- k2 = k;
332
- o[k2] = m[k];
333
- });
334
- function __exportStar(m, o) {
335
- for (var p in m)
336
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
337
- __createBinding(o, m, p);
338
- }
339
- function __values(o) {
340
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
341
- if (m)
342
- return m.call(o);
343
- if (o && typeof o.length === "number")
344
- return {
345
- next: function () {
346
- if (o && i >= o.length)
347
- o = void 0;
348
- return { value: o && o[i++], done: !o };
349
- }
350
- };
351
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
352
- }
353
- function __read(o, n) {
354
- var m = typeof Symbol === "function" && o[Symbol.iterator];
355
- if (!m)
356
- return o;
357
- var i = m.call(o), r, ar = [], e;
358
- try {
359
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
360
- ar.push(r.value);
361
- }
362
- catch (error) {
363
- e = { error: error };
364
- }
365
- finally {
366
- try {
367
- if (r && !r.done && (m = i["return"]))
368
- m.call(i);
369
- }
370
- finally {
371
- if (e)
372
- throw e.error;
373
- }
374
- }
375
- return ar;
376
- }
377
- function __spread() {
378
- for (var ar = [], i = 0; i < arguments.length; i++)
379
- ar = ar.concat(__read(arguments[i]));
380
- return ar;
381
- }
382
- function __spreadArrays() {
383
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
384
- s += arguments[i].length;
385
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
386
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
387
- r[k] = a[j];
388
- return r;
389
- }
390
- ;
391
- function __await(v) {
392
- return this instanceof __await ? (this.v = v, this) : new __await(v);
393
- }
394
- function __asyncGenerator(thisArg, _arguments, generator) {
395
- if (!Symbol.asyncIterator)
396
- throw new TypeError("Symbol.asyncIterator is not defined.");
397
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
398
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
399
- function verb(n) { if (g[n])
400
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
401
- function resume(n, v) { try {
402
- step(g[n](v));
403
- }
404
- catch (e) {
405
- settle(q[0][3], e);
406
- } }
407
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
408
- function fulfill(value) { resume("next", value); }
409
- function reject(value) { resume("throw", value); }
410
- function settle(f, v) { if (f(v), q.shift(), q.length)
411
- resume(q[0][0], q[0][1]); }
412
- }
413
- function __asyncDelegator(o) {
414
- var i, p;
415
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
416
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
417
- }
418
- function __asyncValues(o) {
419
- if (!Symbol.asyncIterator)
420
- throw new TypeError("Symbol.asyncIterator is not defined.");
421
- var m = o[Symbol.asyncIterator], i;
422
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
423
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
424
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
425
- }
426
- function __makeTemplateObject(cooked, raw) {
427
- if (Object.defineProperty) {
428
- Object.defineProperty(cooked, "raw", { value: raw });
429
- }
430
- else {
431
- cooked.raw = raw;
432
- }
433
- return cooked;
434
- }
435
- ;
436
- var __setModuleDefault = Object.create ? (function (o, v) {
437
- Object.defineProperty(o, "default", { enumerable: true, value: v });
438
- }) : function (o, v) {
439
- o["default"] = v;
440
- };
441
- function __importStar(mod) {
442
- if (mod && mod.__esModule)
443
- return mod;
444
- var result = {};
445
- if (mod != null)
446
- for (var k in mod)
447
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
448
- __createBinding(result, mod, k);
449
- __setModuleDefault(result, mod);
450
- return result;
451
- }
452
- function __importDefault(mod) {
453
- return (mod && mod.__esModule) ? mod : { default: mod };
454
- }
455
- function __classPrivateFieldGet(receiver, privateMap) {
456
- if (!privateMap.has(receiver)) {
457
- throw new TypeError("attempted to get private field on non-instance");
458
- }
459
- return privateMap.get(receiver);
460
- }
461
- function __classPrivateFieldSet(receiver, privateMap, value) {
462
- if (!privateMap.has(receiver)) {
463
- throw new TypeError("attempted to set private field on non-instance");
464
- }
465
- privateMap.set(receiver, value);
466
- return value;
168
+ /*! *****************************************************************************
169
+ Copyright (c) Microsoft Corporation.
170
+
171
+ Permission to use, copy, modify, and/or distribute this software for any
172
+ purpose with or without fee is hereby granted.
173
+
174
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
175
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
176
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
177
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
178
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
179
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
180
+ PERFORMANCE OF THIS SOFTWARE.
181
+ ***************************************************************************** */
182
+ /* global Reflect, Promise */
183
+ var extendStatics = function (d, b) {
184
+ extendStatics = Object.setPrototypeOf ||
185
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
186
+ function (d, b) { for (var p in b)
187
+ if (Object.prototype.hasOwnProperty.call(b, p))
188
+ d[p] = b[p]; };
189
+ return extendStatics(d, b);
190
+ };
191
+ function __extends(d, b) {
192
+ if (typeof b !== "function" && b !== null)
193
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
194
+ extendStatics(d, b);
195
+ function __() { this.constructor = d; }
196
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
197
+ }
198
+ var __assign = function () {
199
+ __assign = Object.assign || function __assign(t) {
200
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
201
+ s = arguments[i];
202
+ for (var p in s)
203
+ if (Object.prototype.hasOwnProperty.call(s, p))
204
+ t[p] = s[p];
205
+ }
206
+ return t;
207
+ };
208
+ return __assign.apply(this, arguments);
209
+ };
210
+ function __rest(s, e) {
211
+ var t = {};
212
+ for (var p in s)
213
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
214
+ t[p] = s[p];
215
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
216
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
217
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
218
+ t[p[i]] = s[p[i]];
219
+ }
220
+ return t;
221
+ }
222
+ function __decorate(decorators, target, key, desc) {
223
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
224
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
225
+ r = Reflect.decorate(decorators, target, key, desc);
226
+ else
227
+ for (var i = decorators.length - 1; i >= 0; i--)
228
+ if (d = decorators[i])
229
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
230
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
231
+ }
232
+ function __param(paramIndex, decorator) {
233
+ return function (target, key) { decorator(target, key, paramIndex); };
234
+ }
235
+ function __metadata(metadataKey, metadataValue) {
236
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
237
+ return Reflect.metadata(metadataKey, metadataValue);
238
+ }
239
+ function __awaiter(thisArg, _arguments, P, generator) {
240
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
241
+ return new (P || (P = Promise))(function (resolve, reject) {
242
+ function fulfilled(value) { try {
243
+ step(generator.next(value));
244
+ }
245
+ catch (e) {
246
+ reject(e);
247
+ } }
248
+ function rejected(value) { try {
249
+ step(generator["throw"](value));
250
+ }
251
+ catch (e) {
252
+ reject(e);
253
+ } }
254
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
255
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
256
+ });
257
+ }
258
+ function __generator(thisArg, body) {
259
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
260
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
261
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
262
+ function verb(n) { return function (v) { return step([n, v]); }; }
263
+ function step(op) {
264
+ if (f)
265
+ throw new TypeError("Generator is already executing.");
266
+ while (_)
267
+ try {
268
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
269
+ return t;
270
+ if (y = 0, t)
271
+ op = [op[0] & 2, t.value];
272
+ switch (op[0]) {
273
+ case 0:
274
+ case 1:
275
+ t = op;
276
+ break;
277
+ case 4:
278
+ _.label++;
279
+ return { value: op[1], done: false };
280
+ case 5:
281
+ _.label++;
282
+ y = op[1];
283
+ op = [0];
284
+ continue;
285
+ case 7:
286
+ op = _.ops.pop();
287
+ _.trys.pop();
288
+ continue;
289
+ default:
290
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
291
+ _ = 0;
292
+ continue;
293
+ }
294
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
295
+ _.label = op[1];
296
+ break;
297
+ }
298
+ if (op[0] === 6 && _.label < t[1]) {
299
+ _.label = t[1];
300
+ t = op;
301
+ break;
302
+ }
303
+ if (t && _.label < t[2]) {
304
+ _.label = t[2];
305
+ _.ops.push(op);
306
+ break;
307
+ }
308
+ if (t[2])
309
+ _.ops.pop();
310
+ _.trys.pop();
311
+ continue;
312
+ }
313
+ op = body.call(thisArg, _);
314
+ }
315
+ catch (e) {
316
+ op = [6, e];
317
+ y = 0;
318
+ }
319
+ finally {
320
+ f = t = 0;
321
+ }
322
+ if (op[0] & 5)
323
+ throw op[1];
324
+ return { value: op[0] ? op[1] : void 0, done: true };
325
+ }
326
+ }
327
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
328
+ if (k2 === undefined)
329
+ k2 = k;
330
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
331
+ }) : (function (o, m, k, k2) {
332
+ if (k2 === undefined)
333
+ k2 = k;
334
+ o[k2] = m[k];
335
+ });
336
+ function __exportStar(m, o) {
337
+ for (var p in m)
338
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
339
+ __createBinding(o, m, p);
340
+ }
341
+ function __values(o) {
342
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
343
+ if (m)
344
+ return m.call(o);
345
+ if (o && typeof o.length === "number")
346
+ return {
347
+ next: function () {
348
+ if (o && i >= o.length)
349
+ o = void 0;
350
+ return { value: o && o[i++], done: !o };
351
+ }
352
+ };
353
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
354
+ }
355
+ function __read(o, n) {
356
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
357
+ if (!m)
358
+ return o;
359
+ var i = m.call(o), r, ar = [], e;
360
+ try {
361
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
362
+ ar.push(r.value);
363
+ }
364
+ catch (error) {
365
+ e = { error: error };
366
+ }
367
+ finally {
368
+ try {
369
+ if (r && !r.done && (m = i["return"]))
370
+ m.call(i);
371
+ }
372
+ finally {
373
+ if (e)
374
+ throw e.error;
375
+ }
376
+ }
377
+ return ar;
378
+ }
379
+ /** @deprecated */
380
+ function __spread() {
381
+ for (var ar = [], i = 0; i < arguments.length; i++)
382
+ ar = ar.concat(__read(arguments[i]));
383
+ return ar;
384
+ }
385
+ /** @deprecated */
386
+ function __spreadArrays() {
387
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
388
+ s += arguments[i].length;
389
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
390
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
391
+ r[k] = a[j];
392
+ return r;
393
+ }
394
+ function __spreadArray(to, from, pack) {
395
+ if (pack || arguments.length === 2)
396
+ for (var i = 0, l = from.length, ar; i < l; i++) {
397
+ if (ar || !(i in from)) {
398
+ if (!ar)
399
+ ar = Array.prototype.slice.call(from, 0, i);
400
+ ar[i] = from[i];
401
+ }
402
+ }
403
+ return to.concat(ar || Array.prototype.slice.call(from));
404
+ }
405
+ function __await(v) {
406
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
407
+ }
408
+ function __asyncGenerator(thisArg, _arguments, generator) {
409
+ if (!Symbol.asyncIterator)
410
+ throw new TypeError("Symbol.asyncIterator is not defined.");
411
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
412
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
413
+ function verb(n) { if (g[n])
414
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
415
+ function resume(n, v) { try {
416
+ step(g[n](v));
417
+ }
418
+ catch (e) {
419
+ settle(q[0][3], e);
420
+ } }
421
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
422
+ function fulfill(value) { resume("next", value); }
423
+ function reject(value) { resume("throw", value); }
424
+ function settle(f, v) { if (f(v), q.shift(), q.length)
425
+ resume(q[0][0], q[0][1]); }
426
+ }
427
+ function __asyncDelegator(o) {
428
+ var i, p;
429
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
430
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
431
+ }
432
+ function __asyncValues(o) {
433
+ if (!Symbol.asyncIterator)
434
+ throw new TypeError("Symbol.asyncIterator is not defined.");
435
+ var m = o[Symbol.asyncIterator], i;
436
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
437
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
438
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
439
+ }
440
+ function __makeTemplateObject(cooked, raw) {
441
+ if (Object.defineProperty) {
442
+ Object.defineProperty(cooked, "raw", { value: raw });
443
+ }
444
+ else {
445
+ cooked.raw = raw;
446
+ }
447
+ return cooked;
448
+ }
449
+ ;
450
+ var __setModuleDefault = Object.create ? (function (o, v) {
451
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
452
+ }) : function (o, v) {
453
+ o["default"] = v;
454
+ };
455
+ function __importStar(mod) {
456
+ if (mod && mod.__esModule)
457
+ return mod;
458
+ var result = {};
459
+ if (mod != null)
460
+ for (var k in mod)
461
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
462
+ __createBinding(result, mod, k);
463
+ __setModuleDefault(result, mod);
464
+ return result;
465
+ }
466
+ function __importDefault(mod) {
467
+ return (mod && mod.__esModule) ? mod : { default: mod };
468
+ }
469
+ function __classPrivateFieldGet(receiver, state, kind, f) {
470
+ if (kind === "a" && !f)
471
+ throw new TypeError("Private accessor was defined without a getter");
472
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
473
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
474
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
475
+ }
476
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
477
+ if (kind === "m")
478
+ throw new TypeError("Private method is not writable");
479
+ if (kind === "a" && !f)
480
+ throw new TypeError("Private accessor was defined without a setter");
481
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
482
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
483
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
467
484
  }
468
485
 
469
- var FormSubject = /** @class */ (function (_super) {
470
- __extends(FormSubject, _super);
471
- function FormSubject(notifyCallback) {
472
- var _this = _super.call(this) || this;
473
- _this.notifyCallback = notifyCallback;
474
- return _this;
475
- }
476
- FormSubject.prototype.notify = function (controlModel, control) {
477
- return __awaiter(this, void 0, void 0, function () {
478
- var value;
479
- return __generator(this, function (_a) {
480
- switch (_a.label) {
481
- case 0:
482
- value = this.notifyCallback(controlModel, control);
483
- if (!(value instanceof Promise)) return [3 /*break*/, 2];
484
- return [4 /*yield*/, value];
485
- case 1:
486
- value = _a.sent();
487
- _a.label = 2;
488
- case 2:
489
- this.next(value);
490
- return [2 /*return*/];
491
- }
492
- });
493
- });
494
- };
495
- return FormSubject;
486
+ var FormSubject = /** @class */ (function (_super) {
487
+ __extends(FormSubject, _super);
488
+ function FormSubject(notifyCallback) {
489
+ var _this = _super.call(this) || this;
490
+ _this.notifyCallback = notifyCallback;
491
+ return _this;
492
+ }
493
+ FormSubject.prototype.notify = function (controlModel, control) {
494
+ return __awaiter(this, void 0, void 0, function () {
495
+ var value;
496
+ return __generator(this, function (_a) {
497
+ switch (_a.label) {
498
+ case 0:
499
+ value = this.notifyCallback(controlModel, control);
500
+ if (!(value instanceof Promise)) return [3 /*break*/, 2];
501
+ return [4 /*yield*/, value];
502
+ case 1:
503
+ value = _a.sent();
504
+ _a.label = 2;
505
+ case 2:
506
+ this.next(value);
507
+ return [2 /*return*/];
508
+ }
509
+ });
510
+ });
511
+ };
512
+ return FormSubject;
496
513
  }(rxjs.Subject));
497
514
 
498
- var DynamicFormService = /** @class */ (function (_super) {
499
- __extends(DynamicFormService, _super);
500
- function DynamicFormService(cs, vs, openApi) {
501
- var _this = _super.call(this, cs, vs) || this;
502
- _this.openApi = openApi;
503
- _this.onDetectChanges = new core.EventEmitter();
504
- return _this;
505
- }
506
- Object.defineProperty(DynamicFormService.prototype, "api", {
507
- get: function () {
508
- return this.openApi.api;
509
- },
510
- enumerable: false,
511
- configurable: true
512
- });
513
- Object.defineProperty(DynamicFormService.prototype, "language", {
514
- get: function () {
515
- return this.api.language;
516
- },
517
- enumerable: false,
518
- configurable: true
519
- });
520
- DynamicFormService.prototype.patchGroup = function (value, formModel, formGroup) {
521
- this.patchValueRecursive(value, formModel, formGroup);
522
- this.detectChanges();
523
- formGroup.patchValue(ngxUtils.ObjectUtils.copy(value));
524
- };
525
- DynamicFormService.prototype.patchForm = function (value, component) {
526
- this.patchValueRecursive(value, component.model, component.group);
527
- this.detectChanges(component);
528
- component.group.patchValue(value);
529
- };
530
- DynamicFormService.prototype.serialize = function (formModel, formGroup) {
531
- return this.serializeRecursive(formModel, formGroup);
532
- };
533
- DynamicFormService.prototype.notifyChanges = function (formModel, formGroup) {
534
- this.notifyChangesRecursive(formModel, formGroup);
535
- };
536
- DynamicFormService.prototype.updateSelectOptions = function (formControlModel, formControl) {
537
- if (formControlModel instanceof core$1.DynamicSelectModel) {
538
- var options = formControlModel.options$;
539
- if (options instanceof FormSubject) {
540
- options.notify(formControlModel, formControl);
541
- return;
542
- }
543
- while (options instanceof rxjs.Subject && options.source) {
544
- options = options.source;
545
- if (options instanceof FormSubject) {
546
- options.notify(formControlModel, formControl);
547
- }
548
- }
549
- }
550
- };
551
- DynamicFormService.prototype.showErrors = function (form) {
552
- this.showErrorsForGroup(form.group);
553
- this.detectChanges(form);
554
- };
555
- DynamicFormService.prototype.detectChanges = function (formComponent) {
556
- _super.prototype.detectChanges.call(this, formComponent);
557
- this.onDetectChanges.emit(formComponent);
558
- };
559
- DynamicFormService.prototype.patchValueRecursive = function (value, formModel, formGroup) {
560
- var _this = this;
561
- Object.keys(value).forEach(function (key) {
562
- var subModel = _this.findModelById(key, formModel);
563
- var subValue = value[key];
564
- if (!subModel)
565
- return;
566
- var subControl = _this.findControlByModel(subModel, formGroup);
567
- if (subModel instanceof core$1.DynamicSelectModel && ngxUtils.ObjectUtils.isObject(subValue)) {
568
- value[key] = subValue.id || subValue._id || subValue;
569
- return;
570
- }
571
- if (subModel instanceof core$1.DynamicFormArrayModel) {
572
- var length = Array.isArray(subValue) ? subValue.length : 0;
573
- var subArray = subControl;
574
- while (subModel.size > length) {
575
- _this.removeFormArrayGroup(0, subArray, subModel);
576
- }
577
- while (subModel.size < length) {
578
- _this.insertFormArrayGroup(subModel.size, subArray, subModel);
579
- }
580
- for (var i = 0; i < length; i++) {
581
- var itemModel = subModel.get(i);
582
- _this.patchValueRecursive(subValue[i], itemModel.group, subArray.at(i));
583
- }
584
- return;
585
- }
586
- if (subModel instanceof core$1.DynamicFormGroupModel) {
587
- _this.patchValueRecursive(subValue, subModel.group, subControl);
588
- }
589
- });
590
- };
591
- DynamicFormService.prototype.serializeRecursive = function (formModel, formGroup) {
592
- var _a;
593
- return __awaiter(this, void 0, void 0, function () {
594
- var result, _c, _d, _i, i, subModel, subControl, serializer, _e, _f, length, subArray, resArray, i_1, itemModel, _g, _h, _j, _k;
595
- return __generator(this, function (_l) {
596
- switch (_l.label) {
597
- case 0:
598
- result = {};
599
- if (!formModel || !formGroup || !formGroup.value)
600
- return [2 /*return*/, result];
601
- _c = [];
602
- for (_d in formModel)
603
- _c.push(_d);
604
- _i = 0;
605
- _l.label = 1;
606
- case 1:
607
- if (!(_i < _c.length)) return [3 /*break*/, 12];
608
- i = _c[_i];
609
- subModel = formModel[i];
610
- subControl = this.findControlByModel(subModel, formGroup);
611
- serializer = (_a = subModel.additional) === null || _a === void 0 ? void 0 : _a.serializer;
612
- if (!ngxUtils.ObjectUtils.isFunction(serializer)) return [3 /*break*/, 3];
613
- _e = result;
614
- _f = subModel.id;
615
- return [4 /*yield*/, serializer(subModel, subControl)];
616
- case 2:
617
- _e[_f] = _l.sent();
618
- return [3 /*break*/, 11];
619
- case 3:
620
- if (!(subModel instanceof core$1.DynamicFormArrayModel)) return [3 /*break*/, 8];
621
- length = Array.isArray(subControl.value) ? subControl.value.length : 0;
622
- subArray = subControl;
623
- resArray = [];
624
- i_1 = 0;
625
- _l.label = 4;
626
- case 4:
627
- if (!(i_1 < length)) return [3 /*break*/, 7];
628
- itemModel = subModel.get(i_1);
629
- _h = (_g = resArray).push;
630
- return [4 /*yield*/, this.serializeRecursive(itemModel.group, subArray.at(i_1))];
631
- case 5:
632
- _h.apply(_g, [_l.sent()]);
633
- _l.label = 6;
634
- case 6:
635
- i_1++;
636
- return [3 /*break*/, 4];
637
- case 7:
638
- result[subModel.id] = resArray;
639
- return [3 /*break*/, 11];
640
- case 8:
641
- if (!(subModel instanceof core$1.DynamicFormGroupModel)) return [3 /*break*/, 10];
642
- _j = result;
643
- _k = subModel.id;
644
- return [4 /*yield*/, this.serializeRecursive(subModel.group, subControl)];
645
- case 9:
646
- _j[_k] = _l.sent();
647
- return [3 /*break*/, 11];
648
- case 10:
649
- result[subModel.id] = subControl.value;
650
- _l.label = 11;
651
- case 11:
652
- _i++;
653
- return [3 /*break*/, 1];
654
- case 12: return [2 /*return*/, result];
655
- }
656
- });
657
- });
658
- };
659
- DynamicFormService.prototype.notifyChangesRecursive = function (formModel, formGroup) {
660
- if (!formModel || !formGroup)
661
- return;
662
- for (var i in formModel) {
663
- var subModel = formModel[i];
664
- var subControl = this.findControlByModel(subModel, formGroup);
665
- if (subModel instanceof core$1.DynamicFormArrayModel) {
666
- var length = Array.isArray(subControl.value) ? subControl.value.length : 0;
667
- var subArray = subControl;
668
- for (var i_2 = 0; i_2 < length; i_2++) {
669
- var itemModel = subModel.get(i_2);
670
- this.notifyChangesRecursive(itemModel.group, subArray.at(i_2));
671
- }
672
- continue;
673
- }
674
- if (subModel instanceof core$1.DynamicFormGroupModel) {
675
- this.notifyChangesRecursive(subModel.group, subControl);
676
- continue;
677
- }
678
- this.updateSelectOptions(subModel, subControl);
679
- }
680
- };
681
- DynamicFormService.prototype.showErrorsForGroup = function (formGroup) {
682
- if (!formGroup)
683
- return;
684
- formGroup.markAsTouched({ onlySelf: true });
685
- var controls = Object.keys(formGroup.controls).map(function (id) { return formGroup.controls[id]; });
686
- this.showErrorsForControls(controls);
687
- };
688
- DynamicFormService.prototype.showErrorsForControls = function (controls) {
689
- var _this = this;
690
- controls.forEach(function (control) {
691
- if (control instanceof forms.FormGroup) {
692
- _this.showErrorsForGroup(control);
693
- return;
694
- }
695
- control.markAsTouched({ onlySelf: true });
696
- if (control instanceof forms.FormArray) {
697
- _this.showErrorsForControls(control.controls);
698
- }
699
- });
700
- };
701
- DynamicFormService.prototype.getFormModelForSchema = function (name) {
702
- return __awaiter(this, void 0, void 0, function () {
703
- var _c;
704
- return __generator(this, function (_d) {
705
- switch (_d.label) {
706
- case 0:
707
- this.api.cache = {};
708
- _c = this;
709
- return [4 /*yield*/, this.openApi.getSchemas()];
710
- case 1:
711
- _c.schemas = _d.sent();
712
- return [2 /*return*/, this.getFormModelForSchemaDef(this.schemas[name])];
713
- }
714
- });
715
- });
716
- };
717
- DynamicFormService.prototype.getFormModelForSchemaDef = function (schema) {
718
- var _this = this;
719
- if (!schema)
720
- return [];
721
- return Object.keys(schema.properties || {}).map(function (p) {
722
- var property = schema.properties[p];
723
- return _this.getFormControlModel(property, schema);
724
- }).filter(function (t) { return null !== t; });
725
- };
726
- DynamicFormService.prototype.getFormControlModel = function (property, schema) {
727
- var _a, _b;
728
- if (Array.isArray(property.enum) || ngxUtils.ObjectUtils.isString(property.optionsPath)) {
729
- return new core$1.DynamicSelectModel(this.getFormSelectConfig(property, schema));
730
- }
731
- switch (property.type) {
732
- case "string":
733
- case "number":
734
- return new core$1.DynamicInputModel(this.getFormInputConfig(property, schema));
735
- case "textarea":
736
- return new core$1.DynamicTextAreaModel(this.getFormTextareaConfig(property, schema));
737
- case "boolean":
738
- return new core$1.DynamicCheckboxModel(this.getFormCheckboxConfig(property, schema));
739
- case "list":
740
- return new core$1.DynamicSelectModel(this.getFormSelectConfig(property, schema));
741
- case "array":
742
- if (((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref) {
743
- return new core$1.DynamicFormArrayModel(this.getFormArrayConfig(property, schema));
744
- }
745
- else if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.enum) || property.enum) {
746
- return new core$1.DynamicSelectModel(this.getFormSelectConfig(property, schema));
747
- }
748
- else {
749
- return new core$1.DynamicInputModel(this.getFormInputConfig(property, schema));
750
- }
751
- case "file":
752
- return new core$1.DynamicFileUploadModel(this.getFormUploadConfig(property, schema));
753
- }
754
- if (property.$ref) {
755
- return new core$1.DynamicFormGroupModel(this.getFormGroupConfig(property, schema));
756
- }
757
- return null;
758
- };
759
- DynamicFormService.prototype.getFormControlConfig = function (property, schema) {
760
- var validators = this.getValidators(property, schema);
761
- var errorMessages = Object.keys(validators).reduce(function (res, key) {
762
- res[key] = "error." + key;
763
- return res;
764
- }, {});
765
- return {
766
- id: property.id,
767
- label: ngxUtils.ObjectUtils.isString(property.label) ? property.label : property.id,
768
- hidden: property.hidden,
769
- disabled: property.disabled,
770
- validators: validators,
771
- errorMessages: errorMessages,
772
- additional: Object.assign({}, property)
773
- };
774
- };
775
- DynamicFormService.prototype.getFormArrayConfig = function (property, schema) {
776
- var _this = this;
777
- var _a;
778
- var ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
779
- var subSchema = this.schemas[ref.split("/").pop()];
780
- return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: function () { return _this.getFormModelForSchemaDef(subSchema); } });
781
- };
782
- DynamicFormService.prototype.getFormGroupConfig = function (property, schema) {
783
- var ref = property.$ref || "";
784
- var subSchema = this.schemas[ref.split("/").pop()];
785
- return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
786
- };
787
- DynamicFormService.prototype.getFormInputConfig = function (property, schema) {
788
- var _a;
789
- var inputType = ngxUtils.StringUtils.has(property.id, "password", "Password") ? "password" : (((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
790
- switch (inputType) {
791
- case "boolean":
792
- inputType = "checkbox";
793
- break;
794
- case "textarea":
795
- inputType = "textarea";
796
- break;
797
- }
798
- return Object.assign(this.getFormControlConfig(property, schema), {
799
- inputType: inputType,
800
- autoComplete: property.autoComplete || "off",
801
- multiple: property.type == "array"
802
- });
803
- };
804
- DynamicFormService.prototype.getFormTextareaConfig = function (property, schema) {
805
- return Object.assign(this.getFormControlConfig(property, schema), {
806
- cols: property.cols || null,
807
- rows: property.rows || 10,
808
- wrap: property.wrap || false,
809
- autoComplete: property.autoComplete || "off",
810
- multiple: property.type == "array"
811
- });
812
- };
813
- DynamicFormService.prototype.getFormSelectConfig = function (property, schema) {
814
- return Object.assign(this.getFormControlConfig(property, schema), {
815
- options: this.getFormSelectOptions(property, schema),
816
- multiple: property.type == "array"
817
- });
818
- };
819
- DynamicFormService.prototype.getFormCheckboxConfig = function (property, schema) {
820
- return Object.assign(this.getFormControlConfig(property, schema), {
821
- indeterminate: property.indeterminate === true
822
- });
823
- };
824
- DynamicFormService.prototype.translateOptions = function (options) {
825
- return __awaiter(this, void 0, void 0, function () {
826
- var options_1, options_1_1, option, _c, e_1_1;
827
- var e_1, _d;
828
- return __generator(this, function (_e) {
829
- switch (_e.label) {
830
- case 0:
831
- if (!options)
832
- return [2 /*return*/, []];
833
- _e.label = 1;
834
- case 1:
835
- _e.trys.push([1, 6, 7, 8]);
836
- options_1 = __values(options), options_1_1 = options_1.next();
837
- _e.label = 2;
838
- case 2:
839
- if (!!options_1_1.done) return [3 /*break*/, 5];
840
- option = options_1_1.value;
841
- _c = option;
842
- return [4 /*yield*/, this.language.getTranslation(option.label)];
843
- case 3:
844
- _c.label = _e.sent();
845
- _e.label = 4;
846
- case 4:
847
- options_1_1 = options_1.next();
848
- return [3 /*break*/, 2];
849
- case 5: return [3 /*break*/, 8];
850
- case 6:
851
- e_1_1 = _e.sent();
852
- e_1 = { error: e_1_1 };
853
- return [3 /*break*/, 8];
854
- case 7:
855
- try {
856
- if (options_1_1 && !options_1_1.done && (_d = options_1.return)) _d.call(options_1);
857
- }
858
- finally { if (e_1) throw e_1.error; }
859
- return [7 /*endfinally*/];
860
- case 8: return [2 /*return*/, options];
861
- }
862
- });
863
- });
864
- };
865
- DynamicFormService.prototype.getFormSelectOptions = function (property, schema) {
866
- var _this = this;
867
- var _a;
868
- var $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
869
- if (property.optionsPath) {
870
- return new FormSubject(function (formModel, control) {
871
- var path = property.optionsPath;
872
- var target = control;
873
- if (path.startsWith("$root")) {
874
- path = path.substr(5);
875
- while (target.parent) {
876
- target = target.parent;
877
- }
878
- }
879
- while (path.startsWith(".")) {
880
- path = path.substr(1);
881
- if (target.parent) {
882
- target = target.parent;
883
- }
884
- }
885
- var value = ngxUtils.ObjectUtils.getValue(target.value, path);
886
- var options = (!ngxUtils.ObjectUtils.isArray(value) ? [] : value).map(function (value) { return ({ value: value, label: value }); });
887
- return _this.translateOptions(options);
888
- });
889
- }
890
- if (ngxUtils.ObjectUtils.isArray($enum)) {
891
- return new FormSubject(function () {
892
- var options = $enum.map(function (value) {
893
- var label = property.translatable ? property.id + "." + value : value;
894
- return { value: value, label: label };
895
- });
896
- return _this.translateOptions(options);
897
- });
898
- }
899
- return new FormSubject(function () { return __awaiter(_this, void 0, void 0, function () {
900
- var options;
901
- return __generator(this, function (_c) {
902
- switch (_c.label) {
903
- case 0:
904
- this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(function (result) {
905
- return result.items.map(function (i) {
906
- return { value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id };
907
- });
908
- });
909
- return [4 /*yield*/, this.api.cache[property.endpoint]];
910
- case 1:
911
- options = (_c.sent()).map(function (t) { return Object.assign({}, t); });
912
- return [2 /*return*/, this.translateOptions(options)];
913
- }
914
- });
915
- }); });
916
- };
917
- DynamicFormService.prototype.getFormUploadConfig = function (property, schema) {
918
- var url = this.api.url(property.url || "assets");
919
- var accept = property.accept, autoUpload = property.autoUpload, maxSize = property.maxSize, minSize = property.minSize, removeUrl = property.removeUrl, showFileList = property.showFileList;
920
- return Object.assign(this.getFormControlConfig(property, schema), {
921
- url: url,
922
- accept: accept,
923
- autoUpload: autoUpload,
924
- maxSize: maxSize,
925
- minSize: minSize,
926
- removeUrl: removeUrl,
927
- showFileList: showFileList
928
- });
929
- };
930
- DynamicFormService.prototype.getValidators = function (property, schema) {
931
- var validators = {};
932
- if (schema.required.indexOf(property.id) >= 0) {
933
- validators.required = null;
934
- }
935
- if (property.minLength) {
936
- validators.minLength = property.minLength;
937
- }
938
- if (property.maxLength) {
939
- validators.maxLength = property.maxLength;
940
- }
941
- if (property.min) {
942
- validators.min = property.min;
943
- }
944
- if (property.max) {
945
- validators.max = property.max;
946
- }
947
- switch (property.format) {
948
- case "email":
949
- validators.email = null;
950
- break;
951
- }
952
- return validators;
953
- };
954
- return DynamicFormService;
955
- }(core$1.DynamicFormService));
956
- DynamicFormService.decorators = [
957
- { type: core.Injectable }
958
- ];
959
- DynamicFormService.ctorParameters = function () { return [
960
- { type: core$1.DynamicFormComponentService },
961
- { type: core$1.DynamicFormValidationService },
962
- { type: ngxUtils.OpenApiService }
963
- ]; };
515
+ var DynamicFormArrayModel = /** @class */ (function (_super) {
516
+ __extends(DynamicFormArrayModel, _super);
517
+ function DynamicFormArrayModel(config, layout) {
518
+ var _this = _super.call(this, config, layout) || this;
519
+ _this.additional = config.additional || {};
520
+ return _this;
521
+ }
522
+ return DynamicFormArrayModel;
523
+ }(core.DynamicFormArrayModel));
964
524
 
965
- var AsyncSubmitDirective = /** @class */ (function () {
966
- function AsyncSubmitDirective(toaster, cdr, elem, renderer) {
967
- this.toaster = toaster;
968
- this.cdr = cdr;
969
- this.elem = elem;
970
- this.renderer = renderer;
971
- this.onSuccess = new core.EventEmitter();
972
- this.onError = new core.EventEmitter();
973
- if (elem.nativeElement.tagName !== "BUTTON")
974
- return;
975
- renderer.setAttribute(elem.nativeElement, "type", "button");
976
- }
977
- Object.defineProperty(AsyncSubmitDirective.prototype, "isDisabled", {
978
- get: function () {
979
- return this.disabled;
980
- },
981
- set: function (value) {
982
- this.disabled = value;
983
- if (value) {
984
- this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
985
- return;
986
- }
987
- this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
988
- },
989
- enumerable: false,
990
- configurable: true
991
- });
992
- Object.defineProperty(AsyncSubmitDirective.prototype, "isLoading", {
993
- get: function () {
994
- return this.loading;
995
- },
996
- enumerable: false,
997
- configurable: true
998
- });
999
- AsyncSubmitDirective.prototype.ngOnInit = function () {
1000
- var _this = this;
1001
- if (!this.form)
1002
- return;
1003
- this.isDisabled = this.form.status !== "VALID";
1004
- this.cdr.detectChanges();
1005
- this.onStatusChange = this.form.onStatusChange.subscribe(function () {
1006
- _this.isDisabled = _this.form.status !== "VALID";
1007
- _this.cdr.detectChanges();
1008
- if (!_this.callback || _this.form.status == "PENDING")
1009
- return;
1010
- if (!_this.disabled) {
1011
- _this.callback();
1012
- }
1013
- _this.callback = null;
1014
- });
1015
- this.onSubmit = this.form.onSubmit.subscribe(function () { return _this.callMethod(); });
1016
- };
1017
- AsyncSubmitDirective.prototype.ngOnDestroy = function () {
1018
- if (this.onStatusChange)
1019
- this.onStatusChange.unsubscribe();
1020
- if (this.onSubmit)
1021
- this.onSubmit.unsubscribe();
1022
- };
1023
- AsyncSubmitDirective.prototype.click = function () {
1024
- var _this = this;
1025
- this.callback = function () { return _this.callMethod(); };
1026
- if (this.form.status !== "VALID" && this.form.status !== "INVALID")
1027
- return;
1028
- this.callback();
1029
- this.callback = null;
1030
- };
1031
- AsyncSubmitDirective.prototype.callMethod = function () {
1032
- var _this = this;
1033
- if (this.loading)
1034
- return;
1035
- this.loading = true;
1036
- this.method(this.form, this.context).then(function (result) {
1037
- _this.loading = false;
1038
- if (result) {
1039
- _this.onSuccess.emit(result);
1040
- _this.toaster.success(result.message, result.context);
1041
- }
1042
- }, function (reason) {
1043
- if (!reason || !reason.message)
1044
- throw new Error("Reason must implement IAsyncMessage interface");
1045
- _this.loading = false;
1046
- _this.onError.emit(reason);
1047
- _this.toaster.error(reason.message, reason.context);
1048
- });
1049
- };
1050
- return AsyncSubmitDirective;
1051
- }());
1052
- AsyncSubmitDirective.decorators = [
1053
- { type: core.Directive, args: [{
1054
- selector: "[async-submit]",
1055
- exportAs: "async-submit"
1056
- },] }
1057
- ];
1058
- AsyncSubmitDirective.ctorParameters = function () { return [
1059
- { type: undefined, decorators: [{ type: core.Inject, args: [ngxUtils.TOASTER_SERVICE,] }] },
1060
- { type: core.ChangeDetectorRef },
1061
- { type: core.ElementRef },
1062
- { type: core.Renderer2 }
525
+ var DynamicFormService = /** @class */ (function (_super) {
526
+ __extends(DynamicFormService, _super);
527
+ function DynamicFormService(cs, vs, openApi) {
528
+ var _this = _super.call(this, cs, vs) || this;
529
+ _this.openApi = openApi;
530
+ _this.onDetectChanges = new core$1.EventEmitter();
531
+ return _this;
532
+ }
533
+ Object.defineProperty(DynamicFormService.prototype, "api", {
534
+ get: function () {
535
+ return this.openApi.api;
536
+ },
537
+ enumerable: false,
538
+ configurable: true
539
+ });
540
+ Object.defineProperty(DynamicFormService.prototype, "language", {
541
+ get: function () {
542
+ return this.api.language;
543
+ },
544
+ enumerable: false,
545
+ configurable: true
546
+ });
547
+ DynamicFormService.prototype.patchGroup = function (value, formModel, formGroup) {
548
+ this.patchValueRecursive(value, formModel, formGroup);
549
+ this.detectChanges();
550
+ formGroup.patchValue(ngxUtils.ObjectUtils.copy(value));
551
+ };
552
+ DynamicFormService.prototype.patchForm = function (value, component) {
553
+ this.patchValueRecursive(value, component.model, component.group);
554
+ this.detectChanges(component);
555
+ component.group.patchValue(value);
556
+ };
557
+ DynamicFormService.prototype.serialize = function (formModel, formGroup) {
558
+ return this.serializeRecursive(formModel, formGroup);
559
+ };
560
+ DynamicFormService.prototype.notifyChanges = function (formModel, formGroup) {
561
+ this.notifyChangesRecursive(formModel, formGroup);
562
+ };
563
+ DynamicFormService.prototype.updateSelectOptions = function (formControlModel, formControl) {
564
+ if (formControlModel instanceof core.DynamicSelectModel) {
565
+ var options = formControlModel.options$;
566
+ if (options instanceof FormSubject) {
567
+ options.notify(formControlModel, formControl);
568
+ return;
569
+ }
570
+ while (options instanceof rxjs.Subject && options.source) {
571
+ options = options.source;
572
+ if (options instanceof FormSubject) {
573
+ options.notify(formControlModel, formControl);
574
+ }
575
+ }
576
+ }
577
+ };
578
+ DynamicFormService.prototype.showErrors = function (form) {
579
+ this.showErrorsForGroup(form.group);
580
+ this.detectChanges(form);
581
+ };
582
+ DynamicFormService.prototype.detectChanges = function (formComponent) {
583
+ _super.prototype.detectChanges.call(this, formComponent);
584
+ this.onDetectChanges.emit(formComponent);
585
+ };
586
+ DynamicFormService.prototype.patchValueRecursive = function (value, formModel, formGroup) {
587
+ var _this = this;
588
+ Object.keys(value).forEach(function (key) {
589
+ var subModel = _this.findModelById(key, formModel);
590
+ var subValue = value[key];
591
+ if (!subModel)
592
+ return;
593
+ var subControl = _this.findControlByModel(subModel, formGroup);
594
+ if (subModel instanceof core.DynamicSelectModel && ngxUtils.ObjectUtils.isObject(subValue)) {
595
+ value[key] = subValue.id || subValue._id || subValue;
596
+ return;
597
+ }
598
+ if (subModel instanceof core.DynamicFormArrayModel) {
599
+ var length = Array.isArray(subValue) ? subValue.length : 0;
600
+ var subArray = subControl;
601
+ while (subModel.size > length) {
602
+ _this.removeFormArrayGroup(0, subArray, subModel);
603
+ }
604
+ while (subModel.size < length) {
605
+ _this.insertFormArrayGroup(subModel.size, subArray, subModel);
606
+ }
607
+ for (var i = 0; i < length; i++) {
608
+ var itemModel = subModel.get(i);
609
+ _this.patchValueRecursive(subValue[i], itemModel.group, subArray.at(i));
610
+ }
611
+ return;
612
+ }
613
+ if (subModel instanceof core.DynamicFormGroupModel) {
614
+ _this.patchValueRecursive(subValue, subModel.group, subControl);
615
+ }
616
+ });
617
+ };
618
+ DynamicFormService.prototype.serializeRecursive = function (formModel, formGroup) {
619
+ var _a;
620
+ return __awaiter(this, void 0, void 0, function () {
621
+ var result, _c, _d, _i, i, subModel, subControl, serializer, _e, _f, length, subArray, resArray, i_1, itemModel, _g, _h, _j, _k;
622
+ return __generator(this, function (_l) {
623
+ switch (_l.label) {
624
+ case 0:
625
+ result = {};
626
+ if (!formModel || !formGroup || !formGroup.value)
627
+ return [2 /*return*/, result];
628
+ _c = [];
629
+ for (_d in formModel)
630
+ _c.push(_d);
631
+ _i = 0;
632
+ _l.label = 1;
633
+ case 1:
634
+ if (!(_i < _c.length)) return [3 /*break*/, 12];
635
+ i = _c[_i];
636
+ subModel = formModel[i];
637
+ subControl = this.findControlByModel(subModel, formGroup);
638
+ serializer = (_a = subModel.additional) === null || _a === void 0 ? void 0 : _a.serializer;
639
+ if (!ngxUtils.ObjectUtils.isFunction(serializer)) return [3 /*break*/, 3];
640
+ _e = result;
641
+ _f = subModel.id;
642
+ return [4 /*yield*/, serializer(subModel, subControl)];
643
+ case 2:
644
+ _e[_f] = _l.sent();
645
+ return [3 /*break*/, 11];
646
+ case 3:
647
+ if (!(subModel instanceof core.DynamicFormArrayModel)) return [3 /*break*/, 8];
648
+ length = Array.isArray(subControl.value) ? subControl.value.length : 0;
649
+ subArray = subControl;
650
+ resArray = [];
651
+ i_1 = 0;
652
+ _l.label = 4;
653
+ case 4:
654
+ if (!(i_1 < length)) return [3 /*break*/, 7];
655
+ itemModel = subModel.get(i_1);
656
+ _h = (_g = resArray).push;
657
+ return [4 /*yield*/, this.serializeRecursive(itemModel.group, subArray.at(i_1))];
658
+ case 5:
659
+ _h.apply(_g, [_l.sent()]);
660
+ _l.label = 6;
661
+ case 6:
662
+ i_1++;
663
+ return [3 /*break*/, 4];
664
+ case 7:
665
+ result[subModel.id] = resArray;
666
+ return [3 /*break*/, 11];
667
+ case 8:
668
+ if (!(subModel instanceof core.DynamicFormGroupModel)) return [3 /*break*/, 10];
669
+ _j = result;
670
+ _k = subModel.id;
671
+ return [4 /*yield*/, this.serializeRecursive(subModel.group, subControl)];
672
+ case 9:
673
+ _j[_k] = _l.sent();
674
+ return [3 /*break*/, 11];
675
+ case 10:
676
+ if (subModel instanceof core.DynamicInputModel && !ngxUtils.ObjectUtils.isNullOrUndefined(subControl.value)) {
677
+ result[subModel.id] = subModel.inputType == "number"
678
+ ? parseFloat(("" + subControl.value || "0").replace(/,/gi, ".")) || null
679
+ : subControl.value;
680
+ return [3 /*break*/, 11];
681
+ }
682
+ result[subModel.id] = subControl.value;
683
+ _l.label = 11;
684
+ case 11:
685
+ _i++;
686
+ return [3 /*break*/, 1];
687
+ case 12: return [2 /*return*/, result];
688
+ }
689
+ });
690
+ });
691
+ };
692
+ DynamicFormService.prototype.notifyChangesRecursive = function (formModel, formGroup) {
693
+ if (!formModel || !formGroup)
694
+ return;
695
+ for (var i in formModel) {
696
+ var subModel = formModel[i];
697
+ var subControl = this.findControlByModel(subModel, formGroup);
698
+ if (subModel instanceof core.DynamicFormArrayModel) {
699
+ var length = Array.isArray(subControl.value) ? subControl.value.length : 0;
700
+ var subArray = subControl;
701
+ for (var i_2 = 0; i_2 < length; i_2++) {
702
+ var itemModel = subModel.get(i_2);
703
+ this.notifyChangesRecursive(itemModel.group, subArray.at(i_2));
704
+ }
705
+ continue;
706
+ }
707
+ if (subModel instanceof core.DynamicFormGroupModel) {
708
+ this.notifyChangesRecursive(subModel.group, subControl);
709
+ continue;
710
+ }
711
+ this.updateSelectOptions(subModel, subControl);
712
+ }
713
+ };
714
+ DynamicFormService.prototype.showErrorsForGroup = function (formGroup) {
715
+ if (!formGroup)
716
+ return;
717
+ formGroup.markAsTouched({ onlySelf: true });
718
+ var controls = Object.keys(formGroup.controls).map(function (id) { return formGroup.controls[id]; });
719
+ this.showErrorsForControls(controls);
720
+ };
721
+ DynamicFormService.prototype.showErrorsForControls = function (controls) {
722
+ var _this = this;
723
+ controls.forEach(function (control) {
724
+ if (control instanceof forms.FormGroup) {
725
+ _this.showErrorsForGroup(control);
726
+ return;
727
+ }
728
+ control.markAsTouched({ onlySelf: true });
729
+ if (control instanceof forms.FormArray) {
730
+ _this.showErrorsForControls(control.controls);
731
+ }
732
+ });
733
+ };
734
+ DynamicFormService.prototype.getFormModelForSchema = function (name) {
735
+ return __awaiter(this, void 0, void 0, function () {
736
+ var _c;
737
+ return __generator(this, function (_d) {
738
+ switch (_d.label) {
739
+ case 0:
740
+ this.api.cache = {};
741
+ _c = this;
742
+ return [4 /*yield*/, this.openApi.getSchemas()];
743
+ case 1:
744
+ _c.schemas = _d.sent();
745
+ return [2 /*return*/, this.getFormModelForSchemaDef(this.schemas[name])];
746
+ }
747
+ });
748
+ });
749
+ };
750
+ DynamicFormService.prototype.getFormModelForSchemaDef = function (schema) {
751
+ var _this = this;
752
+ if (!schema)
753
+ return [];
754
+ return Object.keys(schema.properties || {}).map(function (p) {
755
+ var property = schema.properties[p];
756
+ return _this.getFormControlModel(property, schema);
757
+ }).filter(function (t) { return null !== t; });
758
+ };
759
+ DynamicFormService.prototype.getFormControlModel = function (property, schema) {
760
+ var _a, _b;
761
+ if (Array.isArray(property.enum) || ngxUtils.ObjectUtils.isString(property.optionsPath)) {
762
+ return new core.DynamicSelectModel(this.getFormSelectConfig(property, schema));
763
+ }
764
+ switch (property.type) {
765
+ case "string":
766
+ case "number":
767
+ case "integer":
768
+ return new core.DynamicInputModel(this.getFormInputConfig(property, schema));
769
+ case "textarea":
770
+ return new core.DynamicTextAreaModel(this.getFormTextareaConfig(property, schema));
771
+ case "boolean":
772
+ return new core.DynamicCheckboxModel(this.getFormCheckboxConfig(property, schema));
773
+ case "list":
774
+ return new core.DynamicSelectModel(this.getFormSelectConfig(property, schema));
775
+ case "array":
776
+ if (((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref) {
777
+ return new DynamicFormArrayModel(this.getFormArrayConfig(property, schema));
778
+ }
779
+ else if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.enum) || property.enum) {
780
+ return new core.DynamicSelectModel(this.getFormSelectConfig(property, schema));
781
+ }
782
+ else {
783
+ return new core.DynamicInputModel(this.getFormInputConfig(property, schema));
784
+ }
785
+ case "file":
786
+ return new core.DynamicFileUploadModel(this.getFormUploadConfig(property, schema));
787
+ }
788
+ if (property.$ref) {
789
+ return new core.DynamicFormGroupModel(this.getFormGroupConfig(property, schema));
790
+ }
791
+ return null;
792
+ };
793
+ DynamicFormService.prototype.getFormControlConfig = function (property, schema) {
794
+ var validators = this.getValidators(property, schema);
795
+ var errorMessages = Object.keys(validators).reduce(function (res, key) {
796
+ res[key] = "error." + key;
797
+ return res;
798
+ }, {});
799
+ return {
800
+ id: property.id,
801
+ label: ngxUtils.ObjectUtils.isString(property.label) ? property.label : property.id,
802
+ hidden: property.hidden,
803
+ disabled: property.disabled,
804
+ validators: validators,
805
+ errorMessages: errorMessages,
806
+ additional: Object.assign({}, property)
807
+ };
808
+ };
809
+ DynamicFormService.prototype.getFormArrayConfig = function (property, schema) {
810
+ var _this = this;
811
+ var _a;
812
+ var ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
813
+ var subSchema = this.schemas[ref.split("/").pop()];
814
+ return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: function () { return _this.getFormModelForSchemaDef(subSchema); } });
815
+ };
816
+ DynamicFormService.prototype.getFormGroupConfig = function (property, schema) {
817
+ var ref = property.$ref || "";
818
+ var subSchema = this.schemas[ref.split("/").pop()];
819
+ return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
820
+ };
821
+ DynamicFormService.prototype.getFormInputConfig = function (property, schema) {
822
+ var _a;
823
+ var inputType = ngxUtils.StringUtils.has(property.id, "password", "Password") ? "password" : (((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
824
+ switch (inputType) {
825
+ case "boolean":
826
+ inputType = "checkbox";
827
+ break;
828
+ case "textarea":
829
+ inputType = "textarea";
830
+ break;
831
+ case "integer":
832
+ inputType = "number";
833
+ break;
834
+ }
835
+ return Object.assign(this.getFormControlConfig(property, schema), {
836
+ inputType: inputType,
837
+ autoComplete: property.autoComplete || "off",
838
+ multiple: property.type == "array",
839
+ accept: ngxUtils.ObjectUtils.isString(property.accept) ? property.accept : null,
840
+ mask: ngxUtils.ObjectUtils.isString(property.mask) ? property.mask : null,
841
+ pattern: ngxUtils.ObjectUtils.isString(property.pattern) ? property.pattern : null,
842
+ step: isNaN(property.step) ? 1 : property.step,
843
+ min: isNaN(property.min) ? Number.MIN_SAFE_INTEGER : property.min,
844
+ max: isNaN(property.max) ? Number.MAX_SAFE_INTEGER : property.max,
845
+ });
846
+ };
847
+ DynamicFormService.prototype.getFormTextareaConfig = function (property, schema) {
848
+ return Object.assign(this.getFormControlConfig(property, schema), {
849
+ cols: property.cols || null,
850
+ rows: property.rows || 10,
851
+ wrap: property.wrap || false,
852
+ autoComplete: property.autoComplete || "off",
853
+ multiple: property.type == "array"
854
+ });
855
+ };
856
+ DynamicFormService.prototype.getFormSelectConfig = function (property, schema) {
857
+ return Object.assign(this.getFormControlConfig(property, schema), {
858
+ options: this.getFormSelectOptions(property, schema),
859
+ multiple: property.type == "array"
860
+ });
861
+ };
862
+ DynamicFormService.prototype.getFormCheckboxConfig = function (property, schema) {
863
+ return Object.assign(this.getFormControlConfig(property, schema), {
864
+ indeterminate: property.indeterminate === true
865
+ });
866
+ };
867
+ DynamicFormService.prototype.translateOptions = function (options) {
868
+ return __awaiter(this, void 0, void 0, function () {
869
+ var options_1, options_1_1, option, _c, e_1_1;
870
+ var e_1, _d;
871
+ return __generator(this, function (_e) {
872
+ switch (_e.label) {
873
+ case 0:
874
+ if (!options)
875
+ return [2 /*return*/, []];
876
+ _e.label = 1;
877
+ case 1:
878
+ _e.trys.push([1, 6, 7, 8]);
879
+ options_1 = __values(options), options_1_1 = options_1.next();
880
+ _e.label = 2;
881
+ case 2:
882
+ if (!!options_1_1.done) return [3 /*break*/, 5];
883
+ option = options_1_1.value;
884
+ _c = option;
885
+ return [4 /*yield*/, this.language.getTranslation(option.label)];
886
+ case 3:
887
+ _c.label = _e.sent();
888
+ _e.label = 4;
889
+ case 4:
890
+ options_1_1 = options_1.next();
891
+ return [3 /*break*/, 2];
892
+ case 5: return [3 /*break*/, 8];
893
+ case 6:
894
+ e_1_1 = _e.sent();
895
+ e_1 = { error: e_1_1 };
896
+ return [3 /*break*/, 8];
897
+ case 7:
898
+ try {
899
+ if (options_1_1 && !options_1_1.done && (_d = options_1.return)) _d.call(options_1);
900
+ }
901
+ finally { if (e_1) throw e_1.error; }
902
+ return [7 /*endfinally*/];
903
+ case 8: return [2 /*return*/, options];
904
+ }
905
+ });
906
+ });
907
+ };
908
+ DynamicFormService.prototype.getFormSelectOptions = function (property, schema) {
909
+ var _this = this;
910
+ var _a;
911
+ var $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
912
+ if (property.optionsPath) {
913
+ return new FormSubject(function (formModel, control) {
914
+ var path = property.optionsPath;
915
+ var target = control;
916
+ if (path.startsWith("$root")) {
917
+ path = path.substr(5);
918
+ while (target.parent) {
919
+ target = target.parent;
920
+ }
921
+ }
922
+ while (path.startsWith(".")) {
923
+ path = path.substr(1);
924
+ if (target.parent) {
925
+ target = target.parent;
926
+ }
927
+ }
928
+ var value = ngxUtils.ObjectUtils.getValue(target.value, path);
929
+ var options = (!ngxUtils.ObjectUtils.isArray(value) ? [] : value).map(function (value) { return ({ value: value, label: value }); });
930
+ return _this.translateOptions(options);
931
+ });
932
+ }
933
+ if (ngxUtils.ObjectUtils.isArray($enum)) {
934
+ return new FormSubject(function () {
935
+ var options = $enum.map(function (value) {
936
+ var label = property.translatable ? property.id + "." + value : value;
937
+ return { value: value, label: label };
938
+ });
939
+ return _this.translateOptions(options);
940
+ });
941
+ }
942
+ return new FormSubject(function () { return __awaiter(_this, void 0, void 0, function () {
943
+ var options;
944
+ return __generator(this, function (_c) {
945
+ switch (_c.label) {
946
+ case 0:
947
+ this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(function (result) {
948
+ return result.items.map(function (i) {
949
+ return { value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id };
950
+ });
951
+ });
952
+ return [4 /*yield*/, this.api.cache[property.endpoint]];
953
+ case 1:
954
+ options = (_c.sent()).map(function (t) { return Object.assign({}, t); });
955
+ return [2 /*return*/, this.translateOptions(options)];
956
+ }
957
+ });
958
+ }); });
959
+ };
960
+ DynamicFormService.prototype.getFormUploadConfig = function (property, schema) {
961
+ var url = this.api.url(property.url || "assets");
962
+ var accept = property.accept, autoUpload = property.autoUpload, maxSize = property.maxSize, minSize = property.minSize, removeUrl = property.removeUrl, showFileList = property.showFileList;
963
+ return Object.assign(this.getFormControlConfig(property, schema), {
964
+ url: url,
965
+ accept: accept,
966
+ autoUpload: autoUpload,
967
+ maxSize: maxSize,
968
+ minSize: minSize,
969
+ removeUrl: removeUrl,
970
+ showFileList: showFileList
971
+ });
972
+ };
973
+ DynamicFormService.prototype.getValidators = function (property, schema) {
974
+ var validators = {};
975
+ if (ngxUtils.ObjectUtils.isArray(schema.required) && schema.required.indexOf(property.id) >= 0) {
976
+ validators.required = null;
977
+ }
978
+ if (property.minLength) {
979
+ validators.minLength = property.minLength;
980
+ }
981
+ if (property.maxLength) {
982
+ validators.maxLength = property.maxLength;
983
+ }
984
+ if (property.min) {
985
+ validators.min = property.min;
986
+ }
987
+ if (property.max) {
988
+ validators.max = property.max;
989
+ }
990
+ switch (property.format) {
991
+ case "email":
992
+ validators.email = null;
993
+ break;
994
+ }
995
+ return validators;
996
+ };
997
+ return DynamicFormService;
998
+ }(core.DynamicFormService));
999
+ DynamicFormService.decorators = [
1000
+ { type: core$1.Injectable }
1001
+ ];
1002
+ DynamicFormService.ctorParameters = function () { return [
1003
+ { type: core.DynamicFormComponentService },
1004
+ { type: core.DynamicFormValidationService },
1005
+ { type: ngxUtils.OpenApiService }
1063
1006
  ]; };
1064
- AsyncSubmitDirective.propDecorators = {
1065
- method: [{ type: core.Input, args: ["async-submit",] }],
1066
- form: [{ type: core.Input }],
1067
- context: [{ type: core.Input }],
1068
- onSuccess: [{ type: core.Output }],
1069
- onError: [{ type: core.Output }],
1070
- isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
1071
- isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
1072
- click: [{ type: core.HostListener, args: ["click",] }]
1007
+
1008
+ var AsyncSubmitDirective = /** @class */ (function () {
1009
+ function AsyncSubmitDirective(toaster, cdr, elem, renderer) {
1010
+ this.toaster = toaster;
1011
+ this.cdr = cdr;
1012
+ this.elem = elem;
1013
+ this.renderer = renderer;
1014
+ this.onSuccess = new core$1.EventEmitter();
1015
+ this.onError = new core$1.EventEmitter();
1016
+ if (elem.nativeElement.tagName !== "BUTTON")
1017
+ return;
1018
+ renderer.setAttribute(elem.nativeElement, "type", "button");
1019
+ }
1020
+ Object.defineProperty(AsyncSubmitDirective.prototype, "isDisabled", {
1021
+ get: function () {
1022
+ return this.disabled;
1023
+ },
1024
+ set: function (value) {
1025
+ this.disabled = value;
1026
+ if (value) {
1027
+ this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
1028
+ return;
1029
+ }
1030
+ this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
1031
+ },
1032
+ enumerable: false,
1033
+ configurable: true
1034
+ });
1035
+ Object.defineProperty(AsyncSubmitDirective.prototype, "isLoading", {
1036
+ get: function () {
1037
+ return this.loading;
1038
+ },
1039
+ enumerable: false,
1040
+ configurable: true
1041
+ });
1042
+ AsyncSubmitDirective.prototype.ngOnInit = function () {
1043
+ var _this = this;
1044
+ if (!this.form)
1045
+ return;
1046
+ this.isDisabled = this.form.status !== "VALID";
1047
+ this.cdr.detectChanges();
1048
+ this.onStatusChange = this.form.onStatusChange.subscribe(function () {
1049
+ _this.isDisabled = _this.form.status !== "VALID";
1050
+ _this.cdr.detectChanges();
1051
+ if (!_this.callback || _this.form.status == "PENDING")
1052
+ return;
1053
+ if (!_this.disabled) {
1054
+ _this.callback();
1055
+ }
1056
+ _this.callback = null;
1057
+ });
1058
+ this.onSubmit = this.form.onSubmit.subscribe(function () { return _this.callMethod(); });
1059
+ };
1060
+ AsyncSubmitDirective.prototype.ngOnDestroy = function () {
1061
+ if (this.onStatusChange)
1062
+ this.onStatusChange.unsubscribe();
1063
+ if (this.onSubmit)
1064
+ this.onSubmit.unsubscribe();
1065
+ };
1066
+ AsyncSubmitDirective.prototype.click = function () {
1067
+ var _this = this;
1068
+ this.callback = function () { return _this.callMethod(); };
1069
+ if (this.form.status !== "VALID" && this.form.status !== "INVALID")
1070
+ return;
1071
+ this.callback();
1072
+ this.callback = null;
1073
+ };
1074
+ AsyncSubmitDirective.prototype.callMethod = function () {
1075
+ var _this = this;
1076
+ if (this.loading)
1077
+ return;
1078
+ this.loading = true;
1079
+ this.method(this.form, this.context).then(function (result) {
1080
+ _this.loading = false;
1081
+ if (result) {
1082
+ _this.onSuccess.emit(result);
1083
+ _this.toaster.success(result.message, result.context);
1084
+ }
1085
+ }, function (reason) {
1086
+ if (!reason || !reason.message)
1087
+ throw new Error("Reason must implement IAsyncMessage interface");
1088
+ _this.loading = false;
1089
+ _this.onError.emit(reason);
1090
+ _this.toaster.error(reason.message, reason.context);
1091
+ });
1092
+ };
1093
+ return AsyncSubmitDirective;
1094
+ }());
1095
+ AsyncSubmitDirective.decorators = [
1096
+ { type: core$1.Directive, args: [{
1097
+ selector: "[async-submit]",
1098
+ exportAs: "async-submit"
1099
+ },] }
1100
+ ];
1101
+ AsyncSubmitDirective.ctorParameters = function () { return [
1102
+ { type: undefined, decorators: [{ type: core$1.Inject, args: [ngxUtils.TOASTER_SERVICE,] }] },
1103
+ { type: core$1.ChangeDetectorRef },
1104
+ { type: core$1.ElementRef },
1105
+ { type: core$1.Renderer2 }
1106
+ ]; };
1107
+ AsyncSubmitDirective.propDecorators = {
1108
+ method: [{ type: core$1.Input, args: ["async-submit",] }],
1109
+ form: [{ type: core$1.Input }],
1110
+ context: [{ type: core$1.Input }],
1111
+ onSuccess: [{ type: core$1.Output }],
1112
+ onError: [{ type: core$1.Output }],
1113
+ isDisabled: [{ type: core$1.HostBinding, args: ["class.disabled",] }],
1114
+ isLoading: [{ type: core$1.HostBinding, args: ["class.loading",] }],
1115
+ click: [{ type: core$1.HostListener, args: ["click",] }]
1073
1116
  };
1074
1117
 
1075
- var DynamicBaseFormComponent = /** @class */ (function (_super) {
1076
- __extends(DynamicBaseFormComponent, _super);
1077
- function DynamicBaseFormComponent(formService, events, changeDetectorRef, componentService) {
1078
- var _this = _super.call(this, changeDetectorRef, componentService) || this;
1079
- _this.formService = formService;
1080
- _this.events = events;
1081
- _this.blur = new core.EventEmitter();
1082
- _this.change = new core.EventEmitter();
1083
- _this.focus = new core.EventEmitter();
1084
- _this.onStatusChange = new core.EventEmitter();
1085
- _this.onValueChange = new core.EventEmitter();
1086
- _this.onSubmit = new core.EventEmitter();
1087
- _this.templates = new core.QueryList();
1088
- _this.subscription = new rxjs.Subscription();
1089
- _this.groupSubscription = new rxjs.Subscription();
1090
- _this.labelPrefix = "label";
1091
- return _this;
1092
- }
1093
- Object.defineProperty(DynamicBaseFormComponent.prototype, "status", {
1094
- get: function () {
1095
- return !this.group ? null : this.group.status;
1096
- },
1097
- enumerable: false,
1098
- configurable: true
1099
- });
1100
- DynamicBaseFormComponent.prototype.ngOnChanges = function (changes) {
1101
- var _this = this;
1102
- this.groupSubscription.unsubscribe();
1103
- if (this.group) {
1104
- this.groupSubscription = ngxUtils.ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(function () {
1105
- _this.onStatusChange.emit(_this);
1106
- }), this.group.valueChanges.subscribe(function () {
1107
- _this.onValueChange.emit(_this);
1108
- _this.formService.notifyChanges(_this.model, _this.group);
1109
- }));
1110
- }
1111
- };
1112
- DynamicBaseFormComponent.prototype.ngAfterViewInit = function () {
1113
- var _this = this;
1114
- this.subscription = ngxUtils.ObservableUtils.multiSubscription(ngxUtils.ObservableUtils.subscribe({
1115
- subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
1116
- cb: function () {
1117
- var templates = _this.contentTemplates.toArray().concat(_this.viewTemplates.toArray());
1118
- _this.templates.reset(templates);
1119
- }
1120
- }), this.events.languageChanged.subscribe(function () {
1121
- _this.formService.detectChanges(_this);
1122
- }), this.ngForm.ngSubmit.subscribe(function () {
1123
- _this.onSubmit.emit(_this);
1124
- }));
1125
- };
1126
- DynamicBaseFormComponent.prototype.ngOnDestroy = function () {
1127
- _super.prototype.ngOnDestroy.call(this);
1128
- this.subscription.unsubscribe();
1129
- this.groupSubscription.unsubscribe();
1130
- };
1131
- DynamicBaseFormComponent.prototype.insertFormArrayGroup = function (index, formArray, formArrayModel) {
1132
- this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
1133
- this.changeDetectorRef.detectChanges();
1134
- };
1135
- DynamicBaseFormComponent.prototype.removeFormArrayGroup = function (index, formArray, formArrayModel) {
1136
- this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
1137
- this.changeDetectorRef.detectChanges();
1138
- };
1139
- DynamicBaseFormComponent.prototype.moveFormArrayGroup = function (index, step, formArray, formArrayModel) {
1140
- this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
1141
- this.changeDetectorRef.detectChanges();
1142
- };
1143
- DynamicBaseFormComponent.prototype.clearFormArray = function (formArray, formArrayModel) {
1144
- this.formService.clearFormArray(formArray, formArrayModel);
1145
- this.changeDetectorRef.detectChanges();
1146
- };
1147
- DynamicBaseFormComponent.prototype.validate = function (showErrors) {
1148
- var _this = this;
1149
- if (showErrors === void 0) { showErrors = true; }
1150
- if (!this.group)
1151
- return Promise.resolve();
1152
- return new Promise(function (resolve, reject) {
1153
- _this.group.statusChanges.pipe(operators.first(function (status) { return status == "VALID" || status == "INVALID"; })).subscribe(function (status) {
1154
- if (showErrors) {
1155
- _this.formService.showErrors(_this);
1156
- }
1157
- if (status == "VALID") {
1158
- resolve(null);
1159
- return;
1160
- }
1161
- reject(null);
1162
- });
1163
- _this.group.updateValueAndValidity();
1164
- });
1165
- };
1166
- DynamicBaseFormComponent.prototype.serialize = function (validate) {
1167
- return __awaiter(this, void 0, void 0, function () {
1168
- return __generator(this, function (_a) {
1169
- switch (_a.label) {
1170
- case 0:
1171
- if (!this.group)
1172
- return [2 /*return*/, null];
1173
- if (!validate) return [3 /*break*/, 2];
1174
- return [4 /*yield*/, this.validate()];
1175
- case 1:
1176
- _a.sent();
1177
- _a.label = 2;
1178
- case 2: return [4 /*yield*/, this.formService.serialize(this.model, this.group)];
1179
- case 3: return [2 /*return*/, _a.sent()];
1180
- }
1181
- });
1182
- });
1183
- };
1184
- return DynamicBaseFormComponent;
1185
- }(core$1.DynamicFormComponent));
1186
- DynamicBaseFormComponent.decorators = [
1187
- { type: core.Component, args: [{
1188
- selector: "dynamic-base-form",
1189
- template: "",
1190
- changeDetection: core.ChangeDetectionStrategy.Default
1191
- },] }
1192
- ];
1193
- DynamicBaseFormComponent.ctorParameters = function () { return [
1194
- { type: DynamicFormService, decorators: [{ type: core.Inject, args: [DynamicFormService,] }] },
1195
- { type: ngxUtils.EventsService, decorators: [{ type: core.Inject, args: [ngxUtils.EventsService,] }] },
1196
- { type: core.ChangeDetectorRef },
1197
- { type: core$1.DynamicFormComponentService }
1198
- ]; };
1199
- DynamicBaseFormComponent.propDecorators = {
1200
- group: [{ type: core.Input }],
1201
- model: [{ type: core.Input }],
1202
- layout: [{ type: core.Input }],
1203
- labelPrefix: [{ type: core.Input }],
1204
- blur: [{ type: core.Output }],
1205
- change: [{ type: core.Output }],
1206
- focus: [{ type: core.Output }],
1207
- contentTemplates: [{ type: core.ContentChildren, args: [core$1.DynamicTemplateDirective,] }],
1208
- viewTemplates: [{ type: core.ViewChildren, args: [core$1.DynamicTemplateDirective,] }],
1209
- onStatusChange: [{ type: core.Output }],
1210
- onValueChange: [{ type: core.Output }],
1211
- onSubmit: [{ type: core.Output }],
1212
- ngForm: [{ type: core.ViewChild, args: [forms.NgForm,] }]
1118
+ var DynamicBaseFormComponent = /** @class */ (function (_super) {
1119
+ __extends(DynamicBaseFormComponent, _super);
1120
+ function DynamicBaseFormComponent(formService, events, changeDetectorRef, componentService) {
1121
+ var _this = _super.call(this, changeDetectorRef, componentService) || this;
1122
+ _this.formService = formService;
1123
+ _this.events = events;
1124
+ _this.blur = new core$1.EventEmitter();
1125
+ _this.change = new core$1.EventEmitter();
1126
+ _this.focus = new core$1.EventEmitter();
1127
+ _this.onStatusChange = new core$1.EventEmitter();
1128
+ _this.onValueChange = new core$1.EventEmitter();
1129
+ _this.onSubmit = new core$1.EventEmitter();
1130
+ _this.templates = new core$1.QueryList();
1131
+ _this.subscription = new rxjs.Subscription();
1132
+ _this.groupSubscription = new rxjs.Subscription();
1133
+ _this.labelPrefix = "label";
1134
+ return _this;
1135
+ }
1136
+ Object.defineProperty(DynamicBaseFormComponent.prototype, "status", {
1137
+ get: function () {
1138
+ return !this.group ? null : this.group.status;
1139
+ },
1140
+ enumerable: false,
1141
+ configurable: true
1142
+ });
1143
+ DynamicBaseFormComponent.prototype.ngOnChanges = function (changes) {
1144
+ var _this = this;
1145
+ this.groupSubscription.unsubscribe();
1146
+ if (this.group) {
1147
+ this.groupSubscription = ngxUtils.ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(function () {
1148
+ _this.onStatusChange.emit(_this);
1149
+ }), this.group.valueChanges.subscribe(function () {
1150
+ _this.onValueChange.emit(_this);
1151
+ _this.formService.notifyChanges(_this.model, _this.group);
1152
+ }));
1153
+ }
1154
+ };
1155
+ DynamicBaseFormComponent.prototype.ngAfterViewInit = function () {
1156
+ var _this = this;
1157
+ this.subscription = ngxUtils.ObservableUtils.multiSubscription(ngxUtils.ObservableUtils.subscribe({
1158
+ subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
1159
+ cb: function () {
1160
+ var templates = _this.contentTemplates.toArray().concat(_this.viewTemplates.toArray());
1161
+ _this.templates.reset(templates);
1162
+ }
1163
+ }), this.events.languageChanged.subscribe(function () {
1164
+ _this.formService.detectChanges(_this);
1165
+ }), this.ngForm.ngSubmit.subscribe(function () {
1166
+ _this.onSubmit.emit(_this);
1167
+ }));
1168
+ };
1169
+ DynamicBaseFormComponent.prototype.ngOnDestroy = function () {
1170
+ _super.prototype.ngOnDestroy.call(this);
1171
+ this.subscription.unsubscribe();
1172
+ this.groupSubscription.unsubscribe();
1173
+ };
1174
+ DynamicBaseFormComponent.prototype.insertFormArrayGroup = function (index, formArray, formArrayModel) {
1175
+ this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
1176
+ this.changeDetectorRef.detectChanges();
1177
+ };
1178
+ DynamicBaseFormComponent.prototype.removeFormArrayGroup = function (index, formArray, formArrayModel) {
1179
+ this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
1180
+ this.changeDetectorRef.detectChanges();
1181
+ };
1182
+ DynamicBaseFormComponent.prototype.moveFormArrayGroup = function (index, step, formArray, formArrayModel) {
1183
+ this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
1184
+ this.changeDetectorRef.detectChanges();
1185
+ };
1186
+ DynamicBaseFormComponent.prototype.clearFormArray = function (formArray, formArrayModel) {
1187
+ this.formService.clearFormArray(formArray, formArrayModel);
1188
+ this.changeDetectorRef.detectChanges();
1189
+ };
1190
+ DynamicBaseFormComponent.prototype.validate = function (showErrors) {
1191
+ var _this = this;
1192
+ if (showErrors === void 0) { showErrors = true; }
1193
+ if (!this.group)
1194
+ return Promise.resolve();
1195
+ return new Promise(function (resolve, reject) {
1196
+ _this.group.statusChanges.pipe(operators.first(function (status) { return status == "VALID" || status == "INVALID"; })).subscribe(function (status) {
1197
+ if (showErrors) {
1198
+ _this.formService.showErrors(_this);
1199
+ }
1200
+ if (status == "VALID") {
1201
+ resolve(null);
1202
+ return;
1203
+ }
1204
+ reject(null);
1205
+ });
1206
+ _this.group.updateValueAndValidity();
1207
+ });
1208
+ };
1209
+ DynamicBaseFormComponent.prototype.serialize = function (validate) {
1210
+ return __awaiter(this, void 0, void 0, function () {
1211
+ return __generator(this, function (_a) {
1212
+ switch (_a.label) {
1213
+ case 0:
1214
+ if (!this.group)
1215
+ return [2 /*return*/, null];
1216
+ if (!validate) return [3 /*break*/, 2];
1217
+ return [4 /*yield*/, this.validate()];
1218
+ case 1:
1219
+ _a.sent();
1220
+ _a.label = 2;
1221
+ case 2: return [4 /*yield*/, this.formService.serialize(this.model, this.group)];
1222
+ case 3: return [2 /*return*/, _a.sent()];
1223
+ }
1224
+ });
1225
+ });
1226
+ };
1227
+ return DynamicBaseFormComponent;
1228
+ }(core.DynamicFormComponent));
1229
+ DynamicBaseFormComponent.decorators = [
1230
+ { type: core$1.Component, args: [{
1231
+ selector: "dynamic-base-form",
1232
+ template: "",
1233
+ changeDetection: core$1.ChangeDetectionStrategy.Default
1234
+ },] }
1235
+ ];
1236
+ DynamicBaseFormComponent.ctorParameters = function () { return [
1237
+ { type: DynamicFormService, decorators: [{ type: core$1.Inject, args: [DynamicFormService,] }] },
1238
+ { type: ngxUtils.EventsService, decorators: [{ type: core$1.Inject, args: [ngxUtils.EventsService,] }] },
1239
+ { type: core$1.ChangeDetectorRef },
1240
+ { type: core.DynamicFormComponentService }
1241
+ ]; };
1242
+ DynamicBaseFormComponent.propDecorators = {
1243
+ group: [{ type: core$1.Input }],
1244
+ model: [{ type: core$1.Input }],
1245
+ layout: [{ type: core$1.Input }],
1246
+ labelPrefix: [{ type: core$1.Input }],
1247
+ blur: [{ type: core$1.Output }],
1248
+ change: [{ type: core$1.Output }],
1249
+ focus: [{ type: core$1.Output }],
1250
+ contentTemplates: [{ type: core$1.ContentChildren, args: [core.DynamicTemplateDirective,] }],
1251
+ viewTemplates: [{ type: core$1.ViewChildren, args: [core.DynamicTemplateDirective,] }],
1252
+ onStatusChange: [{ type: core$1.Output }],
1253
+ onValueChange: [{ type: core$1.Output }],
1254
+ onSubmit: [{ type: core$1.Output }],
1255
+ ngForm: [{ type: core$1.ViewChild, args: [forms.NgForm,] }]
1213
1256
  };
1214
1257
 
1215
- var DynamicBaseFormControlContainerComponent = /** @class */ (function (_super) {
1216
- __extends(DynamicBaseFormControlContainerComponent, _super);
1217
- function DynamicBaseFormControlContainerComponent(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
1218
- var _this = _super.call(this, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) || this;
1219
- _this.form = form;
1220
- _this.changeDetectorRef = changeDetectorRef;
1221
- _this.componentFactoryResolver = componentFactoryResolver;
1222
- _this.layoutService = layoutService;
1223
- _this.validationService = validationService;
1224
- _this.componentService = componentService;
1225
- _this.relationService = relationService;
1226
- _this.context = null;
1227
- _this.blur = new core.EventEmitter();
1228
- _this.change = new core.EventEmitter();
1229
- _this.focus = new core.EventEmitter();
1230
- return _this;
1231
- }
1232
- Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "componentType", {
1233
- get: function () {
1234
- var _a;
1235
- return (_a = this.componentService.getCustomComponentType(this.model)) !== null && _a !== void 0 ? _a : this.getComponentType(this.model);
1236
- },
1237
- enumerable: false,
1238
- configurable: true
1239
- });
1240
- Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "startTemplate", {
1241
- get: function () {
1242
- return (this.model.type == core$1.DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
1243
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
1244
- : this.layoutService.getStartTemplate(this.model, this.templates);
1245
- },
1246
- enumerable: false,
1247
- configurable: true
1248
- });
1249
- Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "endTemplate", {
1250
- get: function () {
1251
- return (this.model.type == core$1.DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
1252
- ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
1253
- : this.layoutService.getEndTemplate(this.model, this.templates);
1254
- },
1255
- enumerable: false,
1256
- configurable: true
1257
- });
1258
- Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "formService", {
1259
- get: function () {
1260
- return this.form.formService;
1261
- },
1262
- enumerable: false,
1263
- configurable: true
1264
- });
1265
- DynamicBaseFormControlContainerComponent.prototype.ngOnInit = function () {
1266
- var _this = this;
1267
- this.onDetectChanges = this.formService.onDetectChanges.subscribe(function (form) {
1268
- if (form !== _this.form)
1269
- return;
1270
- _this.changeDetectorRef.detectChanges();
1271
- _this.formService.updateSelectOptions(_this.model, _this.control);
1272
- });
1273
- };
1274
- DynamicBaseFormControlContainerComponent.prototype.ngOnDestroy = function () {
1275
- _super.prototype.ngOnDestroy.call(this);
1276
- this.onDetectChanges.unsubscribe();
1277
- };
1278
- DynamicBaseFormControlContainerComponent.prototype.createFormControlComponent = function () {
1279
- var _a;
1280
- _super.prototype.createFormControlComponent.call(this);
1281
- var component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
1282
- if (!component || !ngxUtils.ObjectUtils.isFunction(component.onCreated))
1283
- return;
1284
- component.onCreated();
1285
- };
1286
- DynamicBaseFormControlContainerComponent.prototype.getComponentType = function (model) {
1287
- return null;
1288
- };
1289
- return DynamicBaseFormControlContainerComponent;
1290
- }(core$1.DynamicFormControlContainerComponent));
1291
- DynamicBaseFormControlContainerComponent.decorators = [
1292
- { type: core.Component, args: [{
1293
- selector: "dynamic-base-form-control",
1294
- template: "",
1295
- changeDetection: core.ChangeDetectionStrategy.OnPush
1296
- },] }
1297
- ];
1298
- DynamicBaseFormControlContainerComponent.ctorParameters = function () { return [
1299
- { type: DynamicBaseFormComponent },
1300
- { type: core.ChangeDetectorRef },
1301
- { type: core.ComponentFactoryResolver },
1302
- { type: core$1.DynamicFormLayoutService },
1303
- { type: core$1.DynamicFormValidationService },
1304
- { type: core$1.DynamicFormComponentService },
1305
- { type: core$1.DynamicFormRelationService }
1306
- ]; };
1307
- DynamicBaseFormControlContainerComponent.propDecorators = {
1308
- contentTemplateList: [{ type: core.ContentChildren, args: [core$1.DynamicTemplateDirective,] }],
1309
- klass: [{ type: core.HostBinding, args: ["class",] }],
1310
- context: [{ type: core.Input }],
1311
- group: [{ type: core.Input }],
1312
- hostClass: [{ type: core.Input }],
1313
- inputTemplateList: [{ type: core.Input, args: ["templates",] }],
1314
- layout: [{ type: core.Input }],
1315
- model: [{ type: core.Input }],
1316
- blur: [{ type: core.Output }],
1317
- change: [{ type: core.Output }],
1318
- focus: [{ type: core.Output }],
1319
- componentViewContainerRef: [{ type: core.ViewChild, args: ["componentViewContainer", { read: core.ViewContainerRef, static: true },] }]
1258
+ var DynamicBaseFormControlContainerComponent = /** @class */ (function (_super) {
1259
+ __extends(DynamicBaseFormControlContainerComponent, _super);
1260
+ function DynamicBaseFormControlContainerComponent(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
1261
+ var _this = _super.call(this, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) || this;
1262
+ _this.form = form;
1263
+ _this.changeDetectorRef = changeDetectorRef;
1264
+ _this.componentFactoryResolver = componentFactoryResolver;
1265
+ _this.layoutService = layoutService;
1266
+ _this.validationService = validationService;
1267
+ _this.componentService = componentService;
1268
+ _this.relationService = relationService;
1269
+ _this.context = null;
1270
+ _this.blur = new core$1.EventEmitter();
1271
+ _this.change = new core$1.EventEmitter();
1272
+ _this.focus = new core$1.EventEmitter();
1273
+ return _this;
1274
+ }
1275
+ Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "componentType", {
1276
+ get: function () {
1277
+ var _a;
1278
+ return (_a = this.componentService.getCustomComponentType(this.model)) !== null && _a !== void 0 ? _a : this.getComponentType(this.model);
1279
+ },
1280
+ enumerable: false,
1281
+ configurable: true
1282
+ });
1283
+ Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "startTemplate", {
1284
+ get: function () {
1285
+ return (this.model.type == core.DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
1286
+ ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
1287
+ : this.layoutService.getStartTemplate(this.model, this.templates);
1288
+ },
1289
+ enumerable: false,
1290
+ configurable: true
1291
+ });
1292
+ Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "endTemplate", {
1293
+ get: function () {
1294
+ return (this.model.type == core.DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
1295
+ ? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
1296
+ : this.layoutService.getEndTemplate(this.model, this.templates);
1297
+ },
1298
+ enumerable: false,
1299
+ configurable: true
1300
+ });
1301
+ Object.defineProperty(DynamicBaseFormControlContainerComponent.prototype, "formService", {
1302
+ get: function () {
1303
+ return this.form.formService;
1304
+ },
1305
+ enumerable: false,
1306
+ configurable: true
1307
+ });
1308
+ DynamicBaseFormControlContainerComponent.prototype.ngOnInit = function () {
1309
+ var _this = this;
1310
+ this.onDetectChanges = this.formService.onDetectChanges.subscribe(function (form) {
1311
+ if (form !== _this.form)
1312
+ return;
1313
+ _this.changeDetectorRef.detectChanges();
1314
+ _this.formService.updateSelectOptions(_this.model, _this.control);
1315
+ });
1316
+ };
1317
+ DynamicBaseFormControlContainerComponent.prototype.ngOnDestroy = function () {
1318
+ _super.prototype.ngOnDestroy.call(this);
1319
+ this.onDetectChanges.unsubscribe();
1320
+ };
1321
+ DynamicBaseFormControlContainerComponent.prototype.createFormControlComponent = function () {
1322
+ var _a;
1323
+ _super.prototype.createFormControlComponent.call(this);
1324
+ var component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
1325
+ if (!component || !ngxUtils.ObjectUtils.isFunction(component.onCreated))
1326
+ return;
1327
+ component.onCreated();
1328
+ };
1329
+ DynamicBaseFormControlContainerComponent.prototype.getComponentType = function (model) {
1330
+ return null;
1331
+ };
1332
+ return DynamicBaseFormControlContainerComponent;
1333
+ }(core.DynamicFormControlContainerComponent));
1334
+ DynamicBaseFormControlContainerComponent.decorators = [
1335
+ { type: core$1.Component, args: [{
1336
+ selector: "dynamic-base-form-control",
1337
+ template: "",
1338
+ changeDetection: core$1.ChangeDetectionStrategy.OnPush
1339
+ },] }
1340
+ ];
1341
+ DynamicBaseFormControlContainerComponent.ctorParameters = function () { return [
1342
+ { type: DynamicBaseFormComponent },
1343
+ { type: core$1.ChangeDetectorRef },
1344
+ { type: core$1.ComponentFactoryResolver },
1345
+ { type: core.DynamicFormLayoutService },
1346
+ { type: core.DynamicFormValidationService },
1347
+ { type: core.DynamicFormComponentService },
1348
+ { type: core.DynamicFormRelationService }
1349
+ ]; };
1350
+ DynamicBaseFormControlContainerComponent.propDecorators = {
1351
+ contentTemplateList: [{ type: core$1.ContentChildren, args: [core.DynamicTemplateDirective,] }],
1352
+ klass: [{ type: core$1.HostBinding, args: ["class",] }],
1353
+ context: [{ type: core$1.Input }],
1354
+ group: [{ type: core$1.Input }],
1355
+ hostClass: [{ type: core$1.Input }],
1356
+ inputTemplateList: [{ type: core$1.Input, args: ["templates",] }],
1357
+ layout: [{ type: core$1.Input }],
1358
+ model: [{ type: core$1.Input }],
1359
+ blur: [{ type: core$1.Output }],
1360
+ change: [{ type: core$1.Output }],
1361
+ focus: [{ type: core$1.Output }],
1362
+ componentViewContainerRef: [{ type: core$1.ViewChild, args: ["componentViewContainer", { read: core$1.ViewContainerRef, static: true },] }]
1320
1363
  };
1321
1364
 
1322
- var DynamicFormValidationService = /** @class */ (function (_super) {
1323
- __extends(DynamicFormValidationService, _super);
1324
- function DynamicFormValidationService() {
1325
- return _super !== null && _super.apply(this, arguments) || this;
1326
- }
1327
- DynamicFormValidationService.prototype.showErrorMessages = function (control, model, hasFocus) {
1328
- return _super.prototype.showErrorMessages.call(this, control, model, hasFocus);
1329
- };
1330
- return DynamicFormValidationService;
1331
- }(core$1.DynamicFormValidationService));
1332
- DynamicFormValidationService.decorators = [
1333
- { type: core.Injectable }
1365
+ var DynamicFormValidationService = /** @class */ (function (_super) {
1366
+ __extends(DynamicFormValidationService, _super);
1367
+ function DynamicFormValidationService() {
1368
+ return _super !== null && _super.apply(this, arguments) || this;
1369
+ }
1370
+ DynamicFormValidationService.prototype.showErrorMessages = function (control, model, hasFocus) {
1371
+ return _super.prototype.showErrorMessages.call(this, control, model, hasFocus);
1372
+ };
1373
+ return DynamicFormValidationService;
1374
+ }(core.DynamicFormValidationService));
1375
+ DynamicFormValidationService.decorators = [
1376
+ { type: core$1.Injectable }
1334
1377
  ];
1335
1378
 
1336
- // --- Components ---
1337
- var components = [
1338
- DynamicBaseFormComponent,
1339
- DynamicBaseFormControlContainerComponent
1340
- ];
1341
- // --- Directives ---
1342
- var directives = [
1343
- AsyncSubmitDirective,
1344
- ];
1345
- // --- Pipes ---
1346
- var pipes = [];
1347
- var ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validatePhone, ɵ3 = new Map([
1348
- ["validateJSON", validateJSON],
1349
- ["validateRequiredTranslation", validateRequiredTranslation],
1350
- ["validatePhone", validatePhone],
1351
- ]);
1352
- var NgxDynamicFormModule = /** @class */ (function () {
1353
- function NgxDynamicFormModule() {
1354
- }
1355
- NgxDynamicFormModule.forRoot = function () {
1356
- return {
1357
- ngModule: NgxDynamicFormModule,
1358
- providers: [
1359
- DynamicFormService,
1360
- DynamicFormValidationService,
1361
- {
1362
- provide: core$1.DynamicFormService,
1363
- useExisting: DynamicFormService
1364
- },
1365
- {
1366
- provide: core$1.DynamicFormValidationService,
1367
- useExisting: DynamicFormValidationService
1368
- }
1369
- ]
1370
- };
1371
- };
1372
- return NgxDynamicFormModule;
1373
- }());
1374
- NgxDynamicFormModule.decorators = [
1375
- { type: core.NgModule, args: [{
1376
- declarations: __spread(components, directives, pipes),
1377
- imports: [
1378
- common.CommonModule,
1379
- forms.FormsModule,
1380
- forms.ReactiveFormsModule,
1381
- ngxUtils.NgxUtilsModule
1382
- ],
1383
- exports: __spread(components, directives, pipes, [
1384
- forms.FormsModule,
1385
- forms.ReactiveFormsModule,
1386
- ngxUtils.NgxUtilsModule
1387
- ]),
1388
- entryComponents: components,
1389
- providers: __spread(pipes, [
1390
- { provide: forms.NG_VALIDATORS, useValue: ɵ0$1, multi: true },
1391
- { provide: forms.NG_VALIDATORS, useValue: ɵ1, multi: true },
1392
- { provide: forms.NG_VALIDATORS, useValue: ɵ2, multi: true },
1393
- {
1394
- provide: core$1.DYNAMIC_VALIDATORS,
1395
- useValue: ɵ3
1396
- }
1397
- ])
1398
- },] }
1379
+ // --- Components ---
1380
+ var components = [
1381
+ DynamicBaseFormComponent,
1382
+ DynamicBaseFormControlContainerComponent
1383
+ ];
1384
+ // --- Directives ---
1385
+ var directives = [
1386
+ AsyncSubmitDirective,
1387
+ ];
1388
+ // --- Pipes ---
1389
+ var pipes = [];
1390
+ var ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validatePhone, ɵ3 = new Map([
1391
+ ["validateJSON", validateJSON],
1392
+ ["validateRequiredTranslation", validateRequiredTranslation],
1393
+ ["validatePhone", validatePhone],
1394
+ ]);
1395
+ var NgxDynamicFormModule = /** @class */ (function () {
1396
+ function NgxDynamicFormModule() {
1397
+ }
1398
+ NgxDynamicFormModule.forRoot = function () {
1399
+ return {
1400
+ ngModule: NgxDynamicFormModule,
1401
+ providers: [
1402
+ DynamicFormService,
1403
+ DynamicFormValidationService,
1404
+ {
1405
+ provide: core.DynamicFormService,
1406
+ useExisting: DynamicFormService
1407
+ },
1408
+ {
1409
+ provide: core.DynamicFormValidationService,
1410
+ useExisting: DynamicFormValidationService
1411
+ }
1412
+ ]
1413
+ };
1414
+ };
1415
+ return NgxDynamicFormModule;
1416
+ }());
1417
+ NgxDynamicFormModule.decorators = [
1418
+ { type: core$1.NgModule, args: [{
1419
+ declarations: __spread(components, directives, pipes),
1420
+ imports: [
1421
+ common.CommonModule,
1422
+ forms.FormsModule,
1423
+ forms.ReactiveFormsModule,
1424
+ ngxUtils.NgxUtilsModule
1425
+ ],
1426
+ exports: __spread(components, directives, pipes, [
1427
+ forms.FormsModule,
1428
+ forms.ReactiveFormsModule,
1429
+ ngxUtils.NgxUtilsModule
1430
+ ]),
1431
+ entryComponents: components,
1432
+ providers: __spread(pipes, [
1433
+ { provide: forms.NG_VALIDATORS, useValue: ɵ0$1, multi: true },
1434
+ { provide: forms.NG_VALIDATORS, useValue: ɵ1, multi: true },
1435
+ { provide: forms.NG_VALIDATORS, useValue: ɵ2, multi: true },
1436
+ {
1437
+ provide: core.DYNAMIC_VALIDATORS,
1438
+ useValue: ɵ3
1439
+ }
1440
+ ])
1441
+ },] }
1399
1442
  ];
1400
1443
 
1401
- /**
1402
- * Generated bundle index. Do not edit.
1444
+ /**
1445
+ * Generated bundle index. Do not edit.
1403
1446
  */
1404
1447
 
1405
1448
  exports.AsyncSubmitDirective = AsyncSubmitDirective;