tuain-ng-forms-lib 17.1.36 → 17.1.38
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/esm2022/lib/classes/forms/field.mjs +6 -1
- package/esm2022/lib/components/forms/basic-form.mjs +32 -1
- package/fesm2022/tuain-ng-forms-lib.mjs +36 -0
- package/fesm2022/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/field.d.ts +3 -0
- package/lib/components/forms/basic-form.d.ts +3 -0
- package/package.json +1 -1
|
@@ -933,6 +933,7 @@ const attrs$1 = {
|
|
|
933
933
|
visibleLabel: { name: '_visibleLabel', propagate: 'visibleLabel' },
|
|
934
934
|
};
|
|
935
935
|
class FieldDescriptor extends FormElement {
|
|
936
|
+
_customEvent = new Subject();
|
|
936
937
|
_editionFinish = new Subject();
|
|
937
938
|
_editionPartial = new Subject();
|
|
938
939
|
_detailRequest = new Subject();
|
|
@@ -1029,6 +1030,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1029
1030
|
get defaultEditable() { return this._defaultEditable; }
|
|
1030
1031
|
set defaultEditable(editable) { this.setAttr(attrs$1.defaultEditable, editable); }
|
|
1031
1032
|
get detailRequest() { return this._detailRequest; }
|
|
1033
|
+
get customEvent() { return this._customEvent; }
|
|
1032
1034
|
get editionFinish() { return this._editionFinish; }
|
|
1033
1035
|
get editionPartial() { return this._editionPartial; }
|
|
1034
1036
|
get empty() {
|
|
@@ -1246,6 +1248,9 @@ class FieldDescriptor extends FormElement {
|
|
|
1246
1248
|
this.resetError();
|
|
1247
1249
|
this._editionPartial.next({ code: this._fieldCode, intrinsicValidation: true });
|
|
1248
1250
|
}
|
|
1251
|
+
triggerCustomEvent(eventName, eventData) {
|
|
1252
|
+
this._customEvent.next({ code: this._fieldCode, eventName, eventData });
|
|
1253
|
+
}
|
|
1249
1254
|
notifyEditionFinish() {
|
|
1250
1255
|
const fieldValue = this.value;
|
|
1251
1256
|
this.resetError();
|
|
@@ -3096,6 +3101,7 @@ class BasicFormComponent extends FormStructureAndData {
|
|
|
3096
3101
|
_formSectionsInactivate = {};
|
|
3097
3102
|
_formActionsStart = {};
|
|
3098
3103
|
_formActionsFinish = {};
|
|
3104
|
+
_fieldCustomeEvent = {};
|
|
3099
3105
|
_fieldInputValidation = {};
|
|
3100
3106
|
_fieldValidationsStart = {};
|
|
3101
3107
|
_fieldValidationsFinish = {};
|
|
@@ -3155,6 +3161,7 @@ class BasicFormComponent extends FormStructureAndData {
|
|
|
3155
3161
|
this._formSectionsInactivate = {};
|
|
3156
3162
|
this._formActionsStart = {};
|
|
3157
3163
|
this._formActionsFinish = {};
|
|
3164
|
+
this._fieldCustomeEvent = {};
|
|
3158
3165
|
this._fieldInputValidation = {};
|
|
3159
3166
|
this._fieldValidationsStart = {};
|
|
3160
3167
|
this._fieldValidationsFinish = {};
|
|
@@ -3266,6 +3273,10 @@ class BasicFormComponent extends FormStructureAndData {
|
|
|
3266
3273
|
const formFields = this.getFields();
|
|
3267
3274
|
if (Array.isArray(formFields)) {
|
|
3268
3275
|
formFields.forEach(field => {
|
|
3276
|
+
field.customEvent.subscribe(event => {
|
|
3277
|
+
const { code, eventName, eventData } = event;
|
|
3278
|
+
this.startFieldCustomEvent(code, eventName, eventData);
|
|
3279
|
+
});
|
|
3269
3280
|
field.editionFinish.subscribe(event => {
|
|
3270
3281
|
const { code, intrinsicValidation } = event;
|
|
3271
3282
|
this.startFieldValidation(code, intrinsicValidation);
|
|
@@ -3626,6 +3637,15 @@ class BasicFormComponent extends FormStructureAndData {
|
|
|
3626
3637
|
this._fieldInputValidation[code].push({ callback, properties });
|
|
3627
3638
|
});
|
|
3628
3639
|
}
|
|
3640
|
+
onFieldCustomEvent(codes, callback, properties = null) {
|
|
3641
|
+
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3642
|
+
fieldSet.forEach((code) => {
|
|
3643
|
+
if (!this._fieldCustomeEvent[code]) {
|
|
3644
|
+
this._fieldCustomeEvent[code] = [];
|
|
3645
|
+
}
|
|
3646
|
+
this._fieldCustomeEvent[code].push({ callback, properties });
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3629
3649
|
onFieldValidationStart(codes, callback, properties = null) {
|
|
3630
3650
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3631
3651
|
fieldSet.forEach((code) => {
|
|
@@ -3662,6 +3682,22 @@ class BasicFormComponent extends FormStructureAndData {
|
|
|
3662
3682
|
}
|
|
3663
3683
|
return true;
|
|
3664
3684
|
}
|
|
3685
|
+
async startFieldCustomEvent(code, eventName, eventData) {
|
|
3686
|
+
this.notifyFormActivity();
|
|
3687
|
+
const fieldToTrigger = this.getField(code);
|
|
3688
|
+
if (!fieldToTrigger) {
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
const eventHandlerCallbacks = this._fieldCustomeEvent[code];
|
|
3692
|
+
if (eventHandlerCallbacks) {
|
|
3693
|
+
const clientEventPromises = [];
|
|
3694
|
+
for (const eventHandlerMethod of eventHandlerCallbacks) {
|
|
3695
|
+
const { callback, properties } = eventHandlerMethod;
|
|
3696
|
+
const clientEventPromise = callback(eventName, eventData, fieldToTrigger);
|
|
3697
|
+
clientEventPromises.push(clientEventPromise);
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3665
3701
|
async startFieldValidation(code, intrinsicValidation = true) {
|
|
3666
3702
|
this.notifyFormActivity();
|
|
3667
3703
|
const fieldToValidate = this.getField(code);
|