tuain-ng-forms-lib 14.0.7 → 14.0.9
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/esm2020/lib/classes/forms/field.mjs +46 -7
- package/esm2020/lib/components/forms/basic-form.mjs +1 -3
- package/fesm2015/tuain-ng-forms-lib.mjs +48 -12
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +45 -8
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/field.d.ts +5 -2
- package/package.json +1 -1
|
@@ -611,12 +611,36 @@ const fldAttr = {
|
|
|
611
611
|
};
|
|
612
612
|
class FieldDescriptor extends FormElement {
|
|
613
613
|
constructor(inputFieldReceived, formConfig) {
|
|
614
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
614
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
615
615
|
super(inputFieldReceived, formConfig);
|
|
616
616
|
this._editionFinish = new Subject();
|
|
617
617
|
this._editionPartial = new Subject();
|
|
618
618
|
this._detailRequest = new Subject();
|
|
619
619
|
this._attributeChange = new Subject();
|
|
620
|
+
this.validateOnServer = false;
|
|
621
|
+
this._focus = false;
|
|
622
|
+
this._maxLength = 0;
|
|
623
|
+
this._minLength = 0;
|
|
624
|
+
this._onValidation = false;
|
|
625
|
+
this._intrinsicErrorMessage = '';
|
|
626
|
+
this.fieldCode = '';
|
|
627
|
+
this.fieldInfo = '';
|
|
628
|
+
this.defaultValue = '';
|
|
629
|
+
this.defaultEditable = false;
|
|
630
|
+
this.visibleLabel = false;
|
|
631
|
+
this.fieldRequired = false;
|
|
632
|
+
this.hasChanged = false;
|
|
633
|
+
this.outputOnly = false;
|
|
634
|
+
this.captureType = '';
|
|
635
|
+
this.fieldTitle = '';
|
|
636
|
+
this.fieldType = '';
|
|
637
|
+
this.fieldAlignment = '';
|
|
638
|
+
this.fieldFormat = null;
|
|
639
|
+
this.tooltipText = '';
|
|
640
|
+
this.errorType = '';
|
|
641
|
+
this.errorCode = '';
|
|
642
|
+
this.errorMessage = '';
|
|
643
|
+
this.fieldOptions = null;
|
|
620
644
|
this.elementType = elementTypes.field;
|
|
621
645
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
622
646
|
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
@@ -651,12 +675,13 @@ class FieldDescriptor extends FormElement {
|
|
|
651
675
|
this.setAttr(fldAttr.outputOnly, (_g = fld.outputOnly) !== null && _g !== void 0 ? _g : false);
|
|
652
676
|
const maxLength = (_h = fld.maxLength) !== null && _h !== void 0 ? _h : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
653
677
|
this.setAttr(fldAttr.maxLength, maxLength);
|
|
654
|
-
|
|
655
|
-
this.
|
|
656
|
-
this.
|
|
678
|
+
const intrinsicErrorMessage = (_r = (_m = (_l = (_k = (_j = this._formConfig) === null || _j === void 0 ? void 0 : _j.fieldValidations) === null || _k === void 0 ? void 0 : _k[this.fieldType]) === null || _l === void 0 ? void 0 : _l.message) !== null && _m !== void 0 ? _m : (_q = (_p = (_o = this._formConfig) === null || _o === void 0 ? void 0 : _o.fieldValidations) === null || _p === void 0 ? void 0 : _p.DEFAULT) === null || _q === void 0 ? void 0 : _q.message) !== null && _r !== void 0 ? _r : '';
|
|
679
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, intrinsicErrorMessage);
|
|
680
|
+
this.setEditable((_s = fld.editable) !== null && _s !== void 0 ? _s : true);
|
|
681
|
+
this.setVisibleLabel((_t = fld.visibleLabel) !== null && _t !== void 0 ? _t : true);
|
|
657
682
|
this.setVisibility(fld.visible);
|
|
658
683
|
this.setFieldOptions(fld.fieldOptions);
|
|
659
|
-
this.setValue((
|
|
684
|
+
this.setValue((_v = (_u = fld.fieldValue) !== null && _u !== void 0 ? _u : this.defaultValue) !== null && _v !== void 0 ? _v : '');
|
|
660
685
|
}
|
|
661
686
|
get name() { return this.fieldCode; }
|
|
662
687
|
get editionFinish() { return this._editionFinish; }
|
|
@@ -674,6 +699,12 @@ class FieldDescriptor extends FormElement {
|
|
|
674
699
|
setRequired(required) { this.required = required; }
|
|
675
700
|
get required() { return this.fieldRequired; }
|
|
676
701
|
set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
|
|
702
|
+
get minLength() { return (this._minLength > 0) ? this._minLength.toString() : ''; }
|
|
703
|
+
set minLength(requiredMinLength) {
|
|
704
|
+
let newMinLength = +requiredMinLength;
|
|
705
|
+
newMinLength = (isNaN(newMinLength) || newMinLength < 0) ? 0 : newMinLength;
|
|
706
|
+
this.setAttr(fldAttr.maxLength, +requiredMinLength);
|
|
707
|
+
}
|
|
677
708
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
678
709
|
set maxLength(requiredMaxLength) {
|
|
679
710
|
if (typeof requiredMaxLength === 'string') {
|
|
@@ -686,16 +717,23 @@ class FieldDescriptor extends FormElement {
|
|
|
686
717
|
get value() { return this.getValue(); }
|
|
687
718
|
set value(newValue) { this.setValue(newValue); }
|
|
688
719
|
notifyEditionPartial() {
|
|
720
|
+
this.resetError();
|
|
689
721
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
|
|
690
722
|
}
|
|
691
723
|
notifyEditionFinish() {
|
|
692
724
|
var _a, _b, _c, _d, _e;
|
|
693
|
-
let intrinsicValidation = true;
|
|
694
|
-
const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
|
|
695
725
|
const fieldValue = this.getValue();
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
726
|
+
this.resetError();
|
|
727
|
+
const { type, validation, message } = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : {};
|
|
728
|
+
let intrinsicValidation = true;
|
|
729
|
+
if (fieldValue && (validation || this.fieldFormat)) {
|
|
730
|
+
if (type === 'regexp') {
|
|
731
|
+
intrinsicValidation = ((_c = validation === null || validation === void 0 ? void 0 : validation.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
732
|
+
&& ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
733
|
+
}
|
|
734
|
+
else if (type === 'function' && typeof fieldValue === 'function') {
|
|
735
|
+
intrinsicValidation = validation(fieldValue);
|
|
736
|
+
}
|
|
699
737
|
if (!intrinsicValidation) {
|
|
700
738
|
this.setError('99', this._intrinsicErrorMessage);
|
|
701
739
|
}
|
|
@@ -3047,7 +3085,6 @@ class BasicFormComponent {
|
|
|
3047
3085
|
if (!fieldToValidate) {
|
|
3048
3086
|
return false;
|
|
3049
3087
|
}
|
|
3050
|
-
fieldToValidate.resetError();
|
|
3051
3088
|
const validationCallbacks = this._fieldInputValidation[fieldCode];
|
|
3052
3089
|
if (validationCallbacks) {
|
|
3053
3090
|
const clientValidationPromises = [];
|
|
@@ -3067,7 +3104,6 @@ class BasicFormComponent {
|
|
|
3067
3104
|
if (!fieldToValidate) {
|
|
3068
3105
|
return;
|
|
3069
3106
|
}
|
|
3070
|
-
fieldToValidate.resetError();
|
|
3071
3107
|
const validationCallbacks = this._fieldValidationsStart[fieldCode];
|
|
3072
3108
|
if (validationCallbacks) {
|
|
3073
3109
|
const clientValidationPromises = [];
|