@stemy/ngx-dynamic-form 10.2.26 → 10.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/stemy-ngx-dynamic-form.umd.js +221 -112
- package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
- package/bundles/stemy-ngx-dynamic-form.umd.min.js +1 -1
- package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +1 -1
- package/esm2015/ngx-dynamic-form/common-types.js +26 -63
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-array.component.js +53 -0
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.js +13 -2
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-group.component.js +53 -0
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form.component.js +12 -2
- package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +8 -10
- package/esm2015/ngx-dynamic-form/services/dynamic-form.service.js +36 -24
- package/esm2015/ngx-dynamic-form/utils/form-select-subject.js +3 -1
- package/esm2015/ngx-dynamic-form/utils/misc.js +15 -1
- package/esm2015/public_api.js +4 -2
- package/esm2015/stemy-ngx-dynamic-form.js +1 -2
- package/fesm2015/stemy-ngx-dynamic-form.js +201 -102
- package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +25 -95
- package/ngx-dynamic-form/components/base/dynamic-base-form-array.component.d.ts +20 -0
- package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +1 -0
- package/ngx-dynamic-form/components/base/dynamic-base-form-group.component.d.ts +20 -0
- package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +2 -1
- package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +3 -1
- package/ngx-dynamic-form/services/dynamic-form.service.d.ts +6 -5
- package/ngx-dynamic-form/utils/misc.d.ts +2 -0
- package/package.json +1 -1
- package/public_api.d.ts +3 -1
- package/stemy-ngx-dynamic-form.d.ts +0 -1
- package/stemy-ngx-dynamic-form.metadata.json +1 -1
- package/esm2015/ngx-dynamic-form/services/dynamic-form-validation.service.js +0 -11
- package/ngx-dynamic-form/services/dynamic-form-validation.service.d.ts +0 -5
|
@@ -5,11 +5,6 @@
|
|
|
5
5
|
}(this, (function (exports, ngxUtils, rxjs, core$1, forms, core, operators, common) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// --- Decorator functions ---
|
|
8
|
-
var emptyArray = [];
|
|
9
|
-
var emptyTester = function () {
|
|
10
|
-
return Promise.resolve(false);
|
|
11
|
-
};
|
|
12
|
-
var ɵ0 = emptyTester;
|
|
13
8
|
function defaultSerializer(id, parent) {
|
|
14
9
|
var control = parent.get(id);
|
|
15
10
|
return !control ? null : control.value;
|
|
@@ -55,85 +50,54 @@
|
|
|
55
50
|
defineFormControl(target, propertyKey, createFormFile(propertyKey, data));
|
|
56
51
|
};
|
|
57
52
|
}
|
|
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
53
|
function defineFormControl(target, propertyKey, control) {
|
|
67
54
|
ngxUtils.ReflectUtils.defineMetadata("dynamicFormControl", control, target, propertyKey);
|
|
68
55
|
}
|
|
69
|
-
function getFormFieldSets(target) {
|
|
70
|
-
return ngxUtils.ReflectUtils.getMetadata("dynamicFormFieldSets", target) || {};
|
|
71
|
-
}
|
|
72
56
|
function getFormControl(target, propertyKey) {
|
|
73
57
|
return ngxUtils.ReflectUtils.getMetadata("dynamicFormControl", target, propertyKey);
|
|
74
58
|
}
|
|
75
59
|
function getFormSerializer(target, propertyKey) {
|
|
76
60
|
return ngxUtils.ReflectUtils.getMetadata("dynamicFormSerializer", target, propertyKey);
|
|
77
61
|
}
|
|
78
|
-
function createFormControl(id, type,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
data.hidden = data.hidden || emptyTester;
|
|
86
|
-
data.validators = data.validators || emptyArray;
|
|
87
|
-
return {
|
|
88
|
-
id: id,
|
|
89
|
-
type: type,
|
|
90
|
-
data: data
|
|
91
|
-
};
|
|
62
|
+
function createFormControl(id, type, config) {
|
|
63
|
+
config = config || { id: id };
|
|
64
|
+
config.id = id;
|
|
65
|
+
config.label = ngxUtils.ObjectUtils.isNullOrUndefined(config.label) ? id : config.label;
|
|
66
|
+
config.disabled = config.disabled || false;
|
|
67
|
+
config.hidden = config.hidden || false;
|
|
68
|
+
return { id: id, type: type, config: config };
|
|
92
69
|
}
|
|
93
|
-
function createFormInput(id,
|
|
70
|
+
function createFormInput(id, config, type) {
|
|
94
71
|
if (type === void 0) { type = "text"; }
|
|
95
|
-
var control = createFormControl(id, "input",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
data.mask = data.mask || [/\w*/gi];
|
|
72
|
+
var control = createFormControl(id, "input", config);
|
|
73
|
+
config = control.config;
|
|
74
|
+
config.inputType = config.inputType || type;
|
|
75
|
+
config.placeholder = config.placeholder || (config.inputType == "mask" ? "_" : "");
|
|
76
|
+
config.step = config.step || 1;
|
|
77
|
+
config.mask = config.mask || [/\w*/gi];
|
|
102
78
|
return control;
|
|
103
79
|
}
|
|
104
80
|
function createFormSelect(id, data) {
|
|
105
81
|
var control = createFormControl(id, "select", data);
|
|
106
|
-
data = control.
|
|
82
|
+
data = control.config;
|
|
107
83
|
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
84
|
return control;
|
|
112
85
|
}
|
|
113
|
-
function createFormStatic(id,
|
|
114
|
-
|
|
115
|
-
data = control.data;
|
|
116
|
-
data.style = data.style || "table";
|
|
117
|
-
return control;
|
|
86
|
+
function createFormStatic(id, config) {
|
|
87
|
+
return createFormControl(id, "static", config);
|
|
118
88
|
}
|
|
119
89
|
function createFormModel(id, data) {
|
|
120
|
-
var control = createFormControl(id, "
|
|
121
|
-
data = control.
|
|
90
|
+
var control = createFormControl(id, "group", data);
|
|
91
|
+
data = control.config;
|
|
122
92
|
data.name = data.name || "";
|
|
123
93
|
return control;
|
|
124
94
|
}
|
|
125
95
|
function createFormFile(id, data) {
|
|
126
96
|
var control = createFormControl(id, "file", data);
|
|
127
|
-
data = control.
|
|
128
|
-
data.accept = data.accept || "
|
|
129
|
-
data.
|
|
130
|
-
data.
|
|
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
|
-
});
|
|
97
|
+
data = control.config;
|
|
98
|
+
data.accept = data.accept || ["jpg", "jpeg", "png"];
|
|
99
|
+
data.multiple = data.multiple || false;
|
|
100
|
+
data.url = ngxUtils.ObjectUtils.isString(data.url) ? data.url : "assets";
|
|
137
101
|
return control;
|
|
138
102
|
}
|
|
139
103
|
|
|
@@ -555,6 +519,8 @@
|
|
|
555
519
|
val.then(function (options) {
|
|
556
520
|
var _a, _b;
|
|
557
521
|
_this.next(options);
|
|
522
|
+
if (options.length == 0)
|
|
523
|
+
return;
|
|
558
524
|
var currentVal = control.value;
|
|
559
525
|
if (controlModel.multiple) {
|
|
560
526
|
var correctVal = (currentVal || []).filter(function (t) { return options.findIndex(function (o) { return o.value == t; }) >= 0; });
|
|
@@ -574,6 +540,20 @@
|
|
|
574
540
|
|
|
575
541
|
function isStringWithVal(val) {
|
|
576
542
|
return typeof val == "string" && val.length > 0;
|
|
543
|
+
}
|
|
544
|
+
function collectPathAble(start, getter) {
|
|
545
|
+
if (!start || !getter(start))
|
|
546
|
+
return [];
|
|
547
|
+
var parts = [];
|
|
548
|
+
var currentPath = start;
|
|
549
|
+
while (currentPath) {
|
|
550
|
+
var val = getter(currentPath);
|
|
551
|
+
if (val) {
|
|
552
|
+
parts.unshift(val);
|
|
553
|
+
}
|
|
554
|
+
currentPath = currentPath.parent;
|
|
555
|
+
}
|
|
556
|
+
return parts;
|
|
577
557
|
}
|
|
578
558
|
|
|
579
559
|
var DynamicFormArrayModel = /** @class */ (function (_super) {
|
|
@@ -794,9 +774,9 @@
|
|
|
794
774
|
}
|
|
795
775
|
});
|
|
796
776
|
};
|
|
797
|
-
DynamicFormService.prototype.getFormModelForSchema = function (name) {
|
|
777
|
+
DynamicFormService.prototype.getFormModelForSchema = function (name, customizeModel) {
|
|
798
778
|
return __awaiter(this, void 0, void 0, function () {
|
|
799
|
-
var _c;
|
|
779
|
+
var _c, customizeModels;
|
|
800
780
|
return __generator(this, function (_d) {
|
|
801
781
|
switch (_d.label) {
|
|
802
782
|
case 0:
|
|
@@ -805,49 +785,69 @@
|
|
|
805
785
|
return [4 /*yield*/, this.openApi.getSchemas()];
|
|
806
786
|
case 1:
|
|
807
787
|
_c.schemas = _d.sent();
|
|
808
|
-
|
|
788
|
+
customizeModels = function (property, schema, modelType, config) {
|
|
789
|
+
var model = new modelType(config);
|
|
790
|
+
if (!ngxUtils.ObjectUtils.isFunction(customizeModel))
|
|
791
|
+
return [model];
|
|
792
|
+
var res = customizeModel(property, schema, model, config);
|
|
793
|
+
return Array.isArray(res) ? res : [res];
|
|
794
|
+
};
|
|
795
|
+
return [2 /*return*/, this.getFormModelForSchemaDef(this.schemas[name], customizeModels)];
|
|
809
796
|
}
|
|
810
797
|
});
|
|
811
798
|
});
|
|
812
799
|
};
|
|
813
|
-
DynamicFormService.prototype.getFormModelForSchemaDef = function (schema) {
|
|
814
|
-
var
|
|
800
|
+
DynamicFormService.prototype.getFormModelForSchemaDef = function (schema, customizeModels) {
|
|
801
|
+
var e_1, _c;
|
|
815
802
|
if (!schema)
|
|
816
803
|
return [];
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
804
|
+
var keys = Object.keys(schema.properties || {});
|
|
805
|
+
var controls = [];
|
|
806
|
+
try {
|
|
807
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
808
|
+
var p = keys_1_1.value;
|
|
809
|
+
var property = schema.properties[p];
|
|
810
|
+
controls.push.apply(controls, __spread(this.getFormControlModels(property, schema, customizeModels)));
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
814
|
+
finally {
|
|
815
|
+
try {
|
|
816
|
+
if (keys_1_1 && !keys_1_1.done && (_c = keys_1.return)) _c.call(keys_1);
|
|
817
|
+
}
|
|
818
|
+
finally { if (e_1) throw e_1.error; }
|
|
819
|
+
}
|
|
820
|
+
return controls.filter(function (t) { return null !== t; });
|
|
821
821
|
};
|
|
822
|
-
DynamicFormService.prototype.
|
|
822
|
+
DynamicFormService.prototype.getFormControlModels = function (property, schema, customizeModels) {
|
|
823
823
|
var _a, _b;
|
|
824
824
|
var $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
|
|
825
825
|
if (Array.isArray($enum) || isStringWithVal(property.optionsPath) || isStringWithVal(property.endpoint)) {
|
|
826
|
-
return
|
|
826
|
+
return customizeModels(property, schema, core.DynamicSelectModel, this.getFormSelectConfig(property, schema));
|
|
827
827
|
}
|
|
828
828
|
switch (property.type) {
|
|
829
829
|
case "string":
|
|
830
830
|
case "number":
|
|
831
831
|
case "integer":
|
|
832
|
-
return
|
|
832
|
+
return customizeModels(property, schema, core.DynamicInputModel, this.getFormInputConfig(property, schema));
|
|
833
833
|
case "textarea":
|
|
834
|
-
return
|
|
834
|
+
return customizeModels(property, schema, core.DynamicTextAreaModel, this.getFormTextareaConfig(property, schema));
|
|
835
835
|
case "boolean":
|
|
836
|
-
return
|
|
836
|
+
return customizeModels(property, schema, core.DynamicCheckboxModel, this.getFormCheckboxConfig(property, schema));
|
|
837
837
|
case "array":
|
|
838
838
|
if (((_b = property.items) === null || _b === void 0 ? void 0 : _b.$ref) || property.$ref) {
|
|
839
|
-
return
|
|
839
|
+
return customizeModels(property, schema, DynamicFormArrayModel, this.getFormArrayConfig(property, schema, customizeModels));
|
|
840
840
|
}
|
|
841
841
|
else {
|
|
842
|
-
return
|
|
842
|
+
return customizeModels(property, schema, core.DynamicInputModel, this.getFormInputConfig(property, schema));
|
|
843
843
|
}
|
|
844
844
|
case "file":
|
|
845
|
-
return
|
|
845
|
+
return customizeModels(property, schema, core.DynamicFileUploadModel, this.getFormUploadConfig(property, schema));
|
|
846
846
|
}
|
|
847
847
|
if (property.$ref) {
|
|
848
|
-
return
|
|
848
|
+
return customizeModels(property, schema, core.DynamicFormGroupModel, this.getFormGroupConfig(property, schema, customizeModels));
|
|
849
849
|
}
|
|
850
|
-
return
|
|
850
|
+
return [];
|
|
851
851
|
};
|
|
852
852
|
DynamicFormService.prototype.getFormControlConfig = function (property, schema) {
|
|
853
853
|
var validators = this.getValidators(property, schema);
|
|
@@ -865,17 +865,17 @@
|
|
|
865
865
|
additional: Object.assign({}, property)
|
|
866
866
|
};
|
|
867
867
|
};
|
|
868
|
-
DynamicFormService.prototype.getFormArrayConfig = function (property, schema) {
|
|
868
|
+
DynamicFormService.prototype.getFormArrayConfig = function (property, schema, customizeModels) {
|
|
869
869
|
var _this = this;
|
|
870
870
|
var _a;
|
|
871
871
|
var ref = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref) || property.$ref || "";
|
|
872
872
|
var subSchema = this.schemas[ref.split("/").pop()];
|
|
873
|
-
return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: function () { return _this.getFormModelForSchemaDef(subSchema); } });
|
|
873
|
+
return Object.assign(this.getFormControlConfig(property, schema), { groupFactory: function () { return _this.getFormModelForSchemaDef(subSchema, customizeModels); } });
|
|
874
874
|
};
|
|
875
|
-
DynamicFormService.prototype.getFormGroupConfig = function (property, schema) {
|
|
875
|
+
DynamicFormService.prototype.getFormGroupConfig = function (property, schema, customizeModels) {
|
|
876
876
|
var ref = property.$ref || "";
|
|
877
877
|
var subSchema = this.schemas[ref.split("/").pop()];
|
|
878
|
-
return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema) });
|
|
878
|
+
return Object.assign(this.getFormControlConfig(property, schema), { group: this.getFormModelForSchemaDef(subSchema, customizeModels) });
|
|
879
879
|
};
|
|
880
880
|
DynamicFormService.prototype.getFormInputConfig = function (property, schema) {
|
|
881
881
|
var _a;
|
|
@@ -900,8 +900,10 @@
|
|
|
900
900
|
mask: ngxUtils.ObjectUtils.isString(property.mask) ? property.mask : null,
|
|
901
901
|
pattern: ngxUtils.ObjectUtils.isString(property.pattern) ? property.pattern : null,
|
|
902
902
|
step: isNaN(sub.step) ? (isNaN(property.step) ? 1 : property.step) : sub.step,
|
|
903
|
-
min: isNaN(sub.minimum) ?
|
|
904
|
-
max: isNaN(sub.maximum) ?
|
|
903
|
+
min: isNaN(sub.minimum) ? Number.MIN_SAFE_INTEGER : sub.minimum,
|
|
904
|
+
max: isNaN(sub.maximum) ? Number.MAX_SAFE_INTEGER : sub.maximum,
|
|
905
|
+
minLength: isNaN(sub.minLength) ? Number.MIN_SAFE_INTEGER : sub.minLength,
|
|
906
|
+
maxLength: isNaN(sub.maxLength) ? Number.MAX_SAFE_INTEGER : sub.maxLength,
|
|
905
907
|
});
|
|
906
908
|
};
|
|
907
909
|
DynamicFormService.prototype.getFormTextareaConfig = function (property, schema) {
|
|
@@ -926,8 +928,8 @@
|
|
|
926
928
|
};
|
|
927
929
|
DynamicFormService.prototype.translateOptions = function (options) {
|
|
928
930
|
return __awaiter(this, void 0, void 0, function () {
|
|
929
|
-
var options_1, options_1_1, option, _c,
|
|
930
|
-
var
|
|
931
|
+
var options_1, options_1_1, option, _c, e_2_1;
|
|
932
|
+
var e_2, _d;
|
|
931
933
|
return __generator(this, function (_e) {
|
|
932
934
|
switch (_e.label) {
|
|
933
935
|
case 0:
|
|
@@ -951,14 +953,14 @@
|
|
|
951
953
|
return [3 /*break*/, 2];
|
|
952
954
|
case 5: return [3 /*break*/, 8];
|
|
953
955
|
case 6:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
+
e_2_1 = _e.sent();
|
|
957
|
+
e_2 = { error: e_2_1 };
|
|
956
958
|
return [3 /*break*/, 8];
|
|
957
959
|
case 7:
|
|
958
960
|
try {
|
|
959
961
|
if (options_1_1 && !options_1_1.done && (_d = options_1.return)) _d.call(options_1);
|
|
960
962
|
}
|
|
961
|
-
finally { if (
|
|
963
|
+
finally { if (e_2) throw e_2.error; }
|
|
962
964
|
return [7 /*endfinally*/];
|
|
963
965
|
case 8: return [2 /*return*/, options];
|
|
964
966
|
}
|
|
@@ -972,7 +974,7 @@
|
|
|
972
974
|
if (Array.isArray($enum)) {
|
|
973
975
|
return new FormSelectSubject(function () {
|
|
974
976
|
var options = $enum.map(function (value) {
|
|
975
|
-
var label = property.translatable ? property.id + "." + value : value;
|
|
977
|
+
var label = property.translatable ? property.id + "." + value : "" + value;
|
|
976
978
|
return { value: value, label: label };
|
|
977
979
|
});
|
|
978
980
|
return _this.translateOptions(options);
|
|
@@ -1269,6 +1271,15 @@
|
|
|
1269
1271
|
this.formService.clearFormArray(formArray, formArrayModel);
|
|
1270
1272
|
this.changeDetectorRef.detectChanges();
|
|
1271
1273
|
};
|
|
1274
|
+
DynamicBaseFormComponent.prototype.getClass = function (model) {
|
|
1275
|
+
var parts = collectPathAble(model, function (p) { return p.id; });
|
|
1276
|
+
if (parts.length == 0)
|
|
1277
|
+
return "";
|
|
1278
|
+
if (model instanceof core.DynamicFormGroupModel) {
|
|
1279
|
+
return "form-group-" + parts.join("-");
|
|
1280
|
+
}
|
|
1281
|
+
return "form-control-" + parts.join("-");
|
|
1282
|
+
};
|
|
1272
1283
|
DynamicBaseFormComponent.prototype.validate = function (showErrors) {
|
|
1273
1284
|
var _this = this;
|
|
1274
1285
|
if (showErrors === void 0) { showErrors = true; }
|
|
@@ -1337,6 +1348,59 @@
|
|
|
1337
1348
|
ngForm: [{ type: core$1.ViewChild, args: [forms.NgForm,] }]
|
|
1338
1349
|
};
|
|
1339
1350
|
|
|
1351
|
+
var DynamicBaseFormArrayComponent = /** @class */ (function (_super) {
|
|
1352
|
+
__extends(DynamicBaseFormArrayComponent, _super);
|
|
1353
|
+
function DynamicBaseFormArrayComponent(layoutService, validationService) {
|
|
1354
|
+
var _this = _super.call(this, layoutService, validationService) || this;
|
|
1355
|
+
_this.layoutService = layoutService;
|
|
1356
|
+
_this.validationService = validationService;
|
|
1357
|
+
_this.blur = new core$1.EventEmitter();
|
|
1358
|
+
_this.change = new core$1.EventEmitter();
|
|
1359
|
+
_this.customEvent = new core$1.EventEmitter();
|
|
1360
|
+
_this.focus = new core$1.EventEmitter();
|
|
1361
|
+
return _this;
|
|
1362
|
+
}
|
|
1363
|
+
DynamicBaseFormArrayComponent.prototype.getClass = function (context, place, model) {
|
|
1364
|
+
return [
|
|
1365
|
+
context == "element" ? this.getModelClass(model) : null,
|
|
1366
|
+
_super.prototype.getClass.call(this, context, place, model)
|
|
1367
|
+
].filter(function (cls) { return !!cls; }).join(" ");
|
|
1368
|
+
};
|
|
1369
|
+
DynamicBaseFormArrayComponent.prototype.getModelClass = function (model) {
|
|
1370
|
+
var parts = collectPathAble(model, function (p) { return p.id; });
|
|
1371
|
+
if (parts.length == 0)
|
|
1372
|
+
return "";
|
|
1373
|
+
if (model instanceof core.DynamicFormGroupModel) {
|
|
1374
|
+
return "form-group-" + parts.join("-");
|
|
1375
|
+
}
|
|
1376
|
+
return "form-control-" + parts.join("-");
|
|
1377
|
+
};
|
|
1378
|
+
return DynamicBaseFormArrayComponent;
|
|
1379
|
+
}(core.DynamicFormArrayComponent));
|
|
1380
|
+
DynamicBaseFormArrayComponent.decorators = [
|
|
1381
|
+
{ type: core$1.Component, args: [{
|
|
1382
|
+
selector: "dynamic-base-form-array",
|
|
1383
|
+
template: "",
|
|
1384
|
+
changeDetection: core$1.ChangeDetectionStrategy.OnPush
|
|
1385
|
+
},] }
|
|
1386
|
+
];
|
|
1387
|
+
DynamicBaseFormArrayComponent.ctorParameters = function () { return [
|
|
1388
|
+
{ type: core.DynamicFormLayoutService },
|
|
1389
|
+
{ type: core.DynamicFormValidationService }
|
|
1390
|
+
]; };
|
|
1391
|
+
DynamicBaseFormArrayComponent.propDecorators = {
|
|
1392
|
+
formLayout: [{ type: core$1.Input }],
|
|
1393
|
+
group: [{ type: core$1.Input }],
|
|
1394
|
+
layout: [{ type: core$1.Input }],
|
|
1395
|
+
model: [{ type: core$1.Input }],
|
|
1396
|
+
templates: [{ type: core$1.Input }],
|
|
1397
|
+
blur: [{ type: core$1.Output }],
|
|
1398
|
+
change: [{ type: core$1.Output }],
|
|
1399
|
+
customEvent: [{ type: core$1.Output }],
|
|
1400
|
+
focus: [{ type: core$1.Output }],
|
|
1401
|
+
components: [{ type: core$1.ViewChildren, args: [core$1.forwardRef(function () { return core.DynamicFormControlContainerComponent; }),] }]
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1340
1404
|
var DynamicBaseFormControlContainerComponent = /** @class */ (function (_super) {
|
|
1341
1405
|
__extends(DynamicBaseFormControlContainerComponent, _super);
|
|
1342
1406
|
function DynamicBaseFormControlContainerComponent(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
|
|
@@ -1400,6 +1464,16 @@
|
|
|
1400
1464
|
_super.prototype.ngOnDestroy.call(this);
|
|
1401
1465
|
this.onDetectChanges.unsubscribe();
|
|
1402
1466
|
};
|
|
1467
|
+
DynamicBaseFormControlContainerComponent.prototype.getLabel = function () {
|
|
1468
|
+
var _a;
|
|
1469
|
+
var label = collectPathAble(this.model, function (p) { return p.label; });
|
|
1470
|
+
if (label.length == 0)
|
|
1471
|
+
return "";
|
|
1472
|
+
if ((_a = this.form) === null || _a === void 0 ? void 0 : _a.labelPrefix) {
|
|
1473
|
+
label.unshift(this.form.labelPrefix);
|
|
1474
|
+
}
|
|
1475
|
+
return label.join(".");
|
|
1476
|
+
};
|
|
1403
1477
|
DynamicBaseFormControlContainerComponent.prototype.createFormControlComponent = function () {
|
|
1404
1478
|
var _a;
|
|
1405
1479
|
_super.prototype.createFormControlComponent.call(this);
|
|
@@ -1444,24 +1518,65 @@
|
|
|
1444
1518
|
componentViewContainerRef: [{ type: core$1.ViewChild, args: ["componentViewContainer", { read: core$1.ViewContainerRef, static: true },] }]
|
|
1445
1519
|
};
|
|
1446
1520
|
|
|
1447
|
-
var
|
|
1448
|
-
__extends(
|
|
1449
|
-
function
|
|
1450
|
-
|
|
1521
|
+
var DynamicBaseFormGroupComponent = /** @class */ (function (_super) {
|
|
1522
|
+
__extends(DynamicBaseFormGroupComponent, _super);
|
|
1523
|
+
function DynamicBaseFormGroupComponent(layoutService, validationService) {
|
|
1524
|
+
var _this = _super.call(this, layoutService, validationService) || this;
|
|
1525
|
+
_this.layoutService = layoutService;
|
|
1526
|
+
_this.validationService = validationService;
|
|
1527
|
+
_this.blur = new core$1.EventEmitter();
|
|
1528
|
+
_this.change = new core$1.EventEmitter();
|
|
1529
|
+
_this.customEvent = new core$1.EventEmitter();
|
|
1530
|
+
_this.focus = new core$1.EventEmitter();
|
|
1531
|
+
return _this;
|
|
1451
1532
|
}
|
|
1452
|
-
|
|
1453
|
-
return
|
|
1533
|
+
DynamicBaseFormGroupComponent.prototype.getClass = function (context, place, model) {
|
|
1534
|
+
return [
|
|
1535
|
+
context == "element" ? this.getModelClass(model) : null,
|
|
1536
|
+
_super.prototype.getClass.call(this, context, place, model)
|
|
1537
|
+
].filter(function (cls) { return !!cls; }).join(" ");
|
|
1454
1538
|
};
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1539
|
+
DynamicBaseFormGroupComponent.prototype.getModelClass = function (model) {
|
|
1540
|
+
var parts = collectPathAble(model, function (p) { return p.id; });
|
|
1541
|
+
if (parts.length == 0)
|
|
1542
|
+
return "";
|
|
1543
|
+
if (model instanceof core.DynamicFormGroupModel) {
|
|
1544
|
+
return "form-group-" + parts.join("-");
|
|
1545
|
+
}
|
|
1546
|
+
return "form-control-" + parts.join("-");
|
|
1547
|
+
};
|
|
1548
|
+
return DynamicBaseFormGroupComponent;
|
|
1549
|
+
}(core.DynamicFormGroupComponent));
|
|
1550
|
+
DynamicBaseFormGroupComponent.decorators = [
|
|
1551
|
+
{ type: core$1.Component, args: [{
|
|
1552
|
+
selector: "dynamic-base-form-group",
|
|
1553
|
+
template: "",
|
|
1554
|
+
changeDetection: core$1.ChangeDetectionStrategy.OnPush
|
|
1555
|
+
},] }
|
|
1556
|
+
];
|
|
1557
|
+
DynamicBaseFormGroupComponent.ctorParameters = function () { return [
|
|
1558
|
+
{ type: core.DynamicFormLayoutService },
|
|
1559
|
+
{ type: core.DynamicFormValidationService }
|
|
1560
|
+
]; };
|
|
1561
|
+
DynamicBaseFormGroupComponent.propDecorators = {
|
|
1562
|
+
formLayout: [{ type: core$1.Input }],
|
|
1563
|
+
group: [{ type: core$1.Input }],
|
|
1564
|
+
layout: [{ type: core$1.Input }],
|
|
1565
|
+
model: [{ type: core$1.Input }],
|
|
1566
|
+
templates: [{ type: core$1.Input }],
|
|
1567
|
+
blur: [{ type: core$1.Output }],
|
|
1568
|
+
change: [{ type: core$1.Output }],
|
|
1569
|
+
customEvent: [{ type: core$1.Output }],
|
|
1570
|
+
focus: [{ type: core$1.Output }],
|
|
1571
|
+
components: [{ type: core$1.ViewChildren, args: [core$1.forwardRef(function () { return core.DynamicFormControlContainerComponent; }),] }]
|
|
1572
|
+
};
|
|
1460
1573
|
|
|
1461
1574
|
// --- Components ---
|
|
1462
1575
|
var components = [
|
|
1463
1576
|
DynamicBaseFormComponent,
|
|
1464
|
-
|
|
1577
|
+
DynamicBaseFormArrayComponent,
|
|
1578
|
+
DynamicBaseFormControlContainerComponent,
|
|
1579
|
+
DynamicBaseFormGroupComponent
|
|
1465
1580
|
];
|
|
1466
1581
|
// --- Directives ---
|
|
1467
1582
|
var directives = [
|
|
@@ -1469,7 +1584,7 @@
|
|
|
1469
1584
|
];
|
|
1470
1585
|
// --- Pipes ---
|
|
1471
1586
|
var pipes = [];
|
|
1472
|
-
var ɵ0
|
|
1587
|
+
var ɵ0 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validateItemsMinLength, ɵ3 = validateItemsMaxLength, ɵ4 = validateItemsMinValue, ɵ5 = validateItemsMaxValue, ɵ6 = new Map([
|
|
1473
1588
|
["json", validateJSON],
|
|
1474
1589
|
["requiredTranslation", validateRequiredTranslation],
|
|
1475
1590
|
["phone", validatePhone],
|
|
@@ -1486,14 +1601,9 @@
|
|
|
1486
1601
|
ngModule: NgxDynamicFormModule,
|
|
1487
1602
|
providers: [
|
|
1488
1603
|
DynamicFormService,
|
|
1489
|
-
DynamicFormValidationService,
|
|
1490
1604
|
{
|
|
1491
1605
|
provide: core.DynamicFormService,
|
|
1492
1606
|
useExisting: DynamicFormService
|
|
1493
|
-
},
|
|
1494
|
-
{
|
|
1495
|
-
provide: core.DynamicFormValidationService,
|
|
1496
|
-
useExisting: DynamicFormValidationService
|
|
1497
1607
|
}
|
|
1498
1608
|
]
|
|
1499
1609
|
};
|
|
@@ -1516,7 +1626,7 @@
|
|
|
1516
1626
|
]),
|
|
1517
1627
|
entryComponents: components,
|
|
1518
1628
|
providers: __spread(pipes, [
|
|
1519
|
-
{ provide: forms.NG_VALIDATORS, useValue: ɵ0
|
|
1629
|
+
{ provide: forms.NG_VALIDATORS, useValue: ɵ0, multi: true },
|
|
1520
1630
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ1, multi: true },
|
|
1521
1631
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ2, multi: true },
|
|
1522
1632
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ3, multi: true },
|
|
@@ -1535,10 +1645,11 @@
|
|
|
1535
1645
|
*/
|
|
1536
1646
|
|
|
1537
1647
|
exports.AsyncSubmitDirective = AsyncSubmitDirective;
|
|
1648
|
+
exports.DynamicBaseFormArrayComponent = DynamicBaseFormArrayComponent;
|
|
1538
1649
|
exports.DynamicBaseFormComponent = DynamicBaseFormComponent;
|
|
1539
1650
|
exports.DynamicBaseFormControlContainerComponent = DynamicBaseFormControlContainerComponent;
|
|
1651
|
+
exports.DynamicBaseFormGroupComponent = DynamicBaseFormGroupComponent;
|
|
1540
1652
|
exports.DynamicFormService = DynamicFormService;
|
|
1541
|
-
exports.FormFieldSet = FormFieldSet;
|
|
1542
1653
|
exports.FormFile = FormFile;
|
|
1543
1654
|
exports.FormInput = FormInput;
|
|
1544
1655
|
exports.FormModel = FormModel;
|
|
@@ -1556,7 +1667,6 @@
|
|
|
1556
1667
|
exports.defaultSerializer = defaultSerializer;
|
|
1557
1668
|
exports.defineFormControl = defineFormControl;
|
|
1558
1669
|
exports.getFormControl = getFormControl;
|
|
1559
|
-
exports.getFormFieldSets = getFormFieldSets;
|
|
1560
1670
|
exports.getFormSerializer = getFormSerializer;
|
|
1561
1671
|
exports.validateItemsMaxLength = validateItemsMaxLength;
|
|
1562
1672
|
exports.validateItemsMaxValue = validateItemsMaxValue;
|
|
@@ -1568,7 +1678,6 @@
|
|
|
1568
1678
|
exports.ɵa = components;
|
|
1569
1679
|
exports.ɵb = directives;
|
|
1570
1680
|
exports.ɵc = pipes;
|
|
1571
|
-
exports.ɵd = DynamicFormValidationService;
|
|
1572
1681
|
|
|
1573
1682
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1574
1683
|
|