@stemy/ngx-dynamic-form 10.2.22 → 10.2.25
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 +123 -36
- package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
- package/bundles/stemy-ngx-dynamic-form.umd.min.js +1 -15
- package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +1 -1
- package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +15 -8
- package/esm2015/ngx-dynamic-form/services/dynamic-form.service.js +36 -14
- package/esm2015/ngx-dynamic-form/utils/validators.js +29 -1
- package/esm2015/stemy-ngx-dynamic-form.js +4 -3
- package/fesm2015/stemy-ngx-dynamic-form.js +76 -19
- package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
- package/ngx-dynamic-form/services/dynamic-form.service.d.ts +2 -0
- package/ngx-dynamic-form/utils/validators.d.ts +5 -1
- package/package.json +3 -3
- package/stemy-ngx-dynamic-form.d.ts +3 -2
- package/stemy-ngx-dynamic-form.metadata.json +1 -1
|
@@ -163,9 +163,37 @@
|
|
|
163
163
|
return Promise.resolve(null);
|
|
164
164
|
var phoneRegexp = /^(?:\d){10,12}$/;
|
|
165
165
|
return phoneRegexp.test(value) ? null : { phone: true };
|
|
166
|
+
}
|
|
167
|
+
function validateItemsMinLength(minLength) {
|
|
168
|
+
return function (control) {
|
|
169
|
+
var value = control.value;
|
|
170
|
+
return (Array.isArray(value) && value.every(function (v) { return typeof v == "string" && v.length >= minLength; }))
|
|
171
|
+
? null : { itemsMinLength: minLength };
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function validateItemsMaxLength(maxLength) {
|
|
175
|
+
return function (control) {
|
|
176
|
+
var value = control.value;
|
|
177
|
+
return (Array.isArray(value) && value.every(function (v) { return typeof v == "string" && v.length <= maxLength; }))
|
|
178
|
+
? null : { itemsMaxLength: maxLength };
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function validateItemsMinValue(min) {
|
|
182
|
+
return function (control) {
|
|
183
|
+
var value = control.value;
|
|
184
|
+
return (Array.isArray(value) && value.every(function (v) { return typeof v == "number" && v >= min; }))
|
|
185
|
+
? null : { itemsMinValue: min };
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function validateItemsMaxValue(max) {
|
|
189
|
+
return function (control) {
|
|
190
|
+
var value = control.value;
|
|
191
|
+
return (Array.isArray(value) && value.every(function (v) { return typeof v == "number" && v <= max; }))
|
|
192
|
+
? null : { itemsMaxValue: max };
|
|
193
|
+
};
|
|
166
194
|
}
|
|
167
195
|
|
|
168
|
-
|
|
196
|
+
/******************************************************************************
|
|
169
197
|
Copyright (c) Microsoft Corporation.
|
|
170
198
|
|
|
171
199
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -189,6 +217,8 @@
|
|
|
189
217
|
return extendStatics(d, b);
|
|
190
218
|
};
|
|
191
219
|
function __extends(d, b) {
|
|
220
|
+
if (typeof b !== "function" && b !== null)
|
|
221
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
192
222
|
extendStatics(d, b);
|
|
193
223
|
function __() { this.constructor = d; }
|
|
194
224
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -325,7 +355,11 @@
|
|
|
325
355
|
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
326
356
|
if (k2 === undefined)
|
|
327
357
|
k2 = k;
|
|
328
|
-
Object.
|
|
358
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
359
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
360
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
361
|
+
}
|
|
362
|
+
Object.defineProperty(o, k2, desc);
|
|
329
363
|
}) : (function (o, m, k, k2) {
|
|
330
364
|
if (k2 === undefined)
|
|
331
365
|
k2 = k;
|
|
@@ -374,11 +408,13 @@
|
|
|
374
408
|
}
|
|
375
409
|
return ar;
|
|
376
410
|
}
|
|
411
|
+
/** @deprecated */
|
|
377
412
|
function __spread() {
|
|
378
413
|
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
379
414
|
ar = ar.concat(__read(arguments[i]));
|
|
380
415
|
return ar;
|
|
381
416
|
}
|
|
417
|
+
/** @deprecated */
|
|
382
418
|
function __spreadArrays() {
|
|
383
419
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
384
420
|
s += arguments[i].length;
|
|
@@ -387,7 +423,17 @@
|
|
|
387
423
|
r[k] = a[j];
|
|
388
424
|
return r;
|
|
389
425
|
}
|
|
390
|
-
|
|
426
|
+
function __spreadArray(to, from, pack) {
|
|
427
|
+
if (pack || arguments.length === 2)
|
|
428
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
429
|
+
if (ar || !(i in from)) {
|
|
430
|
+
if (!ar)
|
|
431
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
432
|
+
ar[i] = from[i];
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
436
|
+
}
|
|
391
437
|
function __await(v) {
|
|
392
438
|
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
393
439
|
}
|
|
@@ -452,18 +498,26 @@
|
|
|
452
498
|
function __importDefault(mod) {
|
|
453
499
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
454
500
|
}
|
|
455
|
-
function __classPrivateFieldGet(receiver,
|
|
456
|
-
if (!
|
|
457
|
-
throw new TypeError("
|
|
458
|
-
|
|
459
|
-
|
|
501
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
502
|
+
if (kind === "a" && !f)
|
|
503
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
504
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
505
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
506
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
460
507
|
}
|
|
461
|
-
function __classPrivateFieldSet(receiver,
|
|
462
|
-
if (
|
|
463
|
-
throw new TypeError("
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
508
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
509
|
+
if (kind === "m")
|
|
510
|
+
throw new TypeError("Private method is not writable");
|
|
511
|
+
if (kind === "a" && !f)
|
|
512
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
513
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
514
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
515
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
516
|
+
}
|
|
517
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
518
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
|
519
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
520
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
467
521
|
}
|
|
468
522
|
|
|
469
523
|
var FormSubject = /** @class */ (function (_super) {
|
|
@@ -599,7 +653,7 @@
|
|
|
599
653
|
});
|
|
600
654
|
};
|
|
601
655
|
DynamicFormService.prototype.serializeRecursive = function (formModel, formGroup) {
|
|
602
|
-
var _a;
|
|
656
|
+
var _a, _b;
|
|
603
657
|
return __awaiter(this, void 0, void 0, function () {
|
|
604
658
|
var result, _c, _d, _i, i, subModel, subControl, serializer, _e, _f, length, subArray, resArray, i_1, itemModel, _g, _h, _j, _k;
|
|
605
659
|
return __generator(this, function (_l) {
|
|
@@ -658,8 +712,7 @@
|
|
|
658
712
|
case 10:
|
|
659
713
|
if (subModel instanceof core.DynamicInputModel && !ngxUtils.ObjectUtils.isNullOrUndefined(subControl.value)) {
|
|
660
714
|
result[subModel.id] = subModel.inputType == "number"
|
|
661
|
-
? parseFloat(("" + subControl.value || "0").replace(/,/gi, "."))
|
|
662
|
-
: subControl.value;
|
|
715
|
+
? (_b = parseFloat(("" + subControl.value || "0").replace(/,/gi, "."))) !== null && _b !== void 0 ? _b : null : subControl.value;
|
|
663
716
|
return [3 /*break*/, 11];
|
|
664
717
|
}
|
|
665
718
|
result[subModel.id] = subControl.value;
|
|
@@ -815,6 +868,7 @@
|
|
|
815
868
|
inputType = "number";
|
|
816
869
|
break;
|
|
817
870
|
}
|
|
871
|
+
var sub = property.type == "array" ? property.items || property : property;
|
|
818
872
|
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
819
873
|
inputType: inputType,
|
|
820
874
|
autoComplete: property.autoComplete || "off",
|
|
@@ -822,9 +876,9 @@
|
|
|
822
876
|
accept: ngxUtils.ObjectUtils.isString(property.accept) ? property.accept : null,
|
|
823
877
|
mask: ngxUtils.ObjectUtils.isString(property.mask) ? property.mask : null,
|
|
824
878
|
pattern: ngxUtils.ObjectUtils.isString(property.pattern) ? property.pattern : null,
|
|
825
|
-
step: isNaN(property.step) ? 1 : property.step,
|
|
826
|
-
min: isNaN(
|
|
827
|
-
max: isNaN(
|
|
879
|
+
step: isNaN(sub.step) ? (isNaN(property.step) ? 1 : property.step) : sub.step,
|
|
880
|
+
min: isNaN(sub.minimum) ? (isNaN(sub.minLength) ? Number.MIN_SAFE_INTEGER : sub.minLength) : sub.minimum,
|
|
881
|
+
max: isNaN(sub.maximum) ? (isNaN(sub.maxLength) ? Number.MAX_SAFE_INTEGER : sub.maxLength) : sub.maximum
|
|
828
882
|
});
|
|
829
883
|
};
|
|
830
884
|
DynamicFormService.prototype.getFormTextareaConfig = function (property, schema) {
|
|
@@ -958,24 +1012,46 @@
|
|
|
958
1012
|
if (ngxUtils.ObjectUtils.isArray(schema.required) && schema.required.indexOf(property.id) >= 0) {
|
|
959
1013
|
validators.required = null;
|
|
960
1014
|
}
|
|
961
|
-
|
|
1015
|
+
this.addPropertyValidators(validators, property);
|
|
1016
|
+
this.addItemsValidators(validators, property.items);
|
|
1017
|
+
return validators;
|
|
1018
|
+
};
|
|
1019
|
+
DynamicFormService.prototype.addPropertyValidators = function (validators, property) {
|
|
1020
|
+
if (!property)
|
|
1021
|
+
return;
|
|
1022
|
+
if (!isNaN(property.minLength)) {
|
|
962
1023
|
validators.minLength = property.minLength;
|
|
963
1024
|
}
|
|
964
|
-
if (property.maxLength) {
|
|
1025
|
+
if (!isNaN(property.maxLength)) {
|
|
965
1026
|
validators.maxLength = property.maxLength;
|
|
966
1027
|
}
|
|
967
|
-
if (property.
|
|
968
|
-
validators.min = property.
|
|
1028
|
+
if (!isNaN(property.minimum)) {
|
|
1029
|
+
validators.min = property.minimum;
|
|
969
1030
|
}
|
|
970
|
-
if (property.
|
|
971
|
-
validators.max = property.
|
|
1031
|
+
if (!isNaN(property.maximum)) {
|
|
1032
|
+
validators.max = property.maximum;
|
|
972
1033
|
}
|
|
973
1034
|
switch (property.format) {
|
|
974
1035
|
case "email":
|
|
975
1036
|
validators.email = null;
|
|
976
1037
|
break;
|
|
977
1038
|
}
|
|
978
|
-
|
|
1039
|
+
};
|
|
1040
|
+
DynamicFormService.prototype.addItemsValidators = function (validators, items) {
|
|
1041
|
+
if (!items)
|
|
1042
|
+
return;
|
|
1043
|
+
if (!isNaN(items.minLength)) {
|
|
1044
|
+
validators.itemsMinLength = items.minLength;
|
|
1045
|
+
}
|
|
1046
|
+
if (!isNaN(items.maxLength)) {
|
|
1047
|
+
validators.itemsMaxLength = items.maxLength;
|
|
1048
|
+
}
|
|
1049
|
+
if (!isNaN(items.minimum)) {
|
|
1050
|
+
validators.itemsMinValue = items.minimum;
|
|
1051
|
+
}
|
|
1052
|
+
if (!isNaN(items.maximum)) {
|
|
1053
|
+
validators.itemsMaxValue = items.maximum;
|
|
1054
|
+
}
|
|
979
1055
|
};
|
|
980
1056
|
return DynamicFormService;
|
|
981
1057
|
}(core.DynamicFormService));
|
|
@@ -1370,10 +1446,14 @@
|
|
|
1370
1446
|
];
|
|
1371
1447
|
// --- Pipes ---
|
|
1372
1448
|
var pipes = [];
|
|
1373
|
-
var ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 =
|
|
1374
|
-
["
|
|
1375
|
-
["
|
|
1376
|
-
["
|
|
1449
|
+
var ɵ0$1 = validateJSON, ɵ1 = validateRequiredTranslation, ɵ2 = validateItemsMinLength, ɵ3 = validateItemsMaxLength, ɵ4 = validateItemsMinValue, ɵ5 = validateItemsMaxValue, ɵ6 = new Map([
|
|
1450
|
+
["json", validateJSON],
|
|
1451
|
+
["requiredTranslation", validateRequiredTranslation],
|
|
1452
|
+
["phone", validatePhone],
|
|
1453
|
+
["itemsMinLength", validateItemsMinLength],
|
|
1454
|
+
["itemsMaxLength", validateItemsMaxLength],
|
|
1455
|
+
["itemsMinValue", validateItemsMinValue],
|
|
1456
|
+
["itemsMaxValue", validateItemsMaxValue],
|
|
1377
1457
|
]);
|
|
1378
1458
|
var NgxDynamicFormModule = /** @class */ (function () {
|
|
1379
1459
|
function NgxDynamicFormModule() {
|
|
@@ -1416,9 +1496,12 @@
|
|
|
1416
1496
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ0$1, multi: true },
|
|
1417
1497
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ1, multi: true },
|
|
1418
1498
|
{ provide: forms.NG_VALIDATORS, useValue: ɵ2, multi: true },
|
|
1499
|
+
{ provide: forms.NG_VALIDATORS, useValue: ɵ3, multi: true },
|
|
1500
|
+
{ provide: forms.NG_VALIDATORS, useValue: ɵ4, multi: true },
|
|
1501
|
+
{ provide: forms.NG_VALIDATORS, useValue: ɵ5, multi: true },
|
|
1419
1502
|
{
|
|
1420
1503
|
provide: core.DYNAMIC_VALIDATORS,
|
|
1421
|
-
useValue: ɵ
|
|
1504
|
+
useValue: ɵ6
|
|
1422
1505
|
}
|
|
1423
1506
|
])
|
|
1424
1507
|
},] }
|
|
@@ -1454,10 +1537,14 @@
|
|
|
1454
1537
|
exports.validateJSON = validateJSON;
|
|
1455
1538
|
exports.validatePhone = validatePhone;
|
|
1456
1539
|
exports.validateRequiredTranslation = validateRequiredTranslation;
|
|
1457
|
-
exports.ɵa =
|
|
1458
|
-
exports.ɵb =
|
|
1459
|
-
exports.ɵc =
|
|
1460
|
-
exports.ɵd =
|
|
1540
|
+
exports.ɵa = validateItemsMinLength;
|
|
1541
|
+
exports.ɵb = validateItemsMaxLength;
|
|
1542
|
+
exports.ɵc = validateItemsMinValue;
|
|
1543
|
+
exports.ɵd = validateItemsMaxValue;
|
|
1544
|
+
exports.ɵe = components;
|
|
1545
|
+
exports.ɵf = directives;
|
|
1546
|
+
exports.ɵg = pipes;
|
|
1547
|
+
exports.ɵh = DynamicFormValidationService;
|
|
1461
1548
|
|
|
1462
1549
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1463
1550
|
|