tuain-ng-forms-lib 14.1.2 → 14.2.14

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 (35) hide show
  1. package/esm2020/lib/classes/forms/element.mjs +9 -3
  2. package/esm2020/lib/classes/forms/field.mjs +325 -243
  3. package/esm2020/lib/classes/forms/form.mjs +26 -26
  4. package/esm2020/lib/classes/forms/subsection.mjs +2 -2
  5. package/esm2020/lib/components/elements/action.component.mjs +3 -3
  6. package/esm2020/lib/components/elements/field.component.mjs +20 -15
  7. package/esm2020/lib/components/elements/layout/element.component.mjs +3 -3
  8. package/esm2020/lib/components/elements/layout/form-error.component.mjs +3 -3
  9. package/esm2020/lib/components/elements/layout/form-header.component.mjs +3 -3
  10. package/esm2020/lib/components/elements/layout/section.component.mjs +3 -3
  11. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +3 -3
  12. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +3 -3
  13. package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +3 -3
  14. package/esm2020/lib/components/elements/tables/table.component.mjs +3 -3
  15. package/esm2020/lib/components/forms/basic-form.mjs +65 -37
  16. package/esm2020/lib/tuain-ng-forms-lib.module.mjs +7 -9
  17. package/fesm2015/tuain-ng-forms-lib.mjs +479 -357
  18. package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
  19. package/fesm2020/tuain-ng-forms-lib.mjs +474 -354
  20. package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
  21. package/lib/classes/forms/element.d.ts +7 -6
  22. package/lib/classes/forms/field.d.ts +168 -72
  23. package/lib/classes/forms/form.d.ts +1 -1
  24. package/lib/components/elements/action.component.d.ts +1 -1
  25. package/lib/components/elements/field.component.d.ts +5 -5
  26. package/lib/components/elements/layout/element.component.d.ts +1 -1
  27. package/lib/components/elements/layout/form-error.component.d.ts +1 -1
  28. package/lib/components/elements/layout/form-header.component.d.ts +1 -1
  29. package/lib/components/elements/layout/section.component.d.ts +1 -1
  30. package/lib/components/elements/layout/sub-section.component.d.ts +1 -1
  31. package/lib/components/elements/tables/table-record-action.component.d.ts +1 -1
  32. package/lib/components/elements/tables/table-record-field.component.d.ts +1 -1
  33. package/lib/components/elements/tables/table.component.d.ts +1 -1
  34. package/lib/components/forms/basic-form.d.ts +8 -5
  35. package/package.json +1 -1
@@ -47,9 +47,9 @@ class ActionComponent {
47
47
  return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
48
48
  }
49
49
  }
50
- ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
51
- ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", state: "state", style: "style", showLabel: "showLabel" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
52
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ActionComponent, decorators: [{
50
+ ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
51
+ ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", state: "state", style: "style", showLabel: "showLabel" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
52
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
53
53
  type: Component,
54
54
  args: [{
55
55
  selector: 'lib-action',
@@ -72,26 +72,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
72
72
  const VALUE = 'value';
73
73
  const FOCUS = 'focus';
74
74
  class FieldComponent {
75
+ constructor() {
76
+ // Atributos obtenidos estáticamente
77
+ this.code = '';
78
+ this.info = '';
79
+ this.alignment = '';
80
+ this.tooltip = '';
81
+ this.field = null;
82
+ }
75
83
  ngOnInit() {
76
84
  var _a, _b;
77
85
  if (this.field) {
78
86
  this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
79
87
  // Inicialización
80
- const mapping = Object.entries(this.formConfig.componentFieldAttrMap);
88
+ const mapping = this.formConfig.fieldPropagateAttributes;
81
89
  for (let index = 0; index < mapping.length; index++) {
82
- const [fieldAttr1, compAttr1] = mapping[index];
83
- const compAttr = compAttr1.toString();
84
- const fieldAttr = fieldAttr1.toString();
85
- const attributeValue = (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr];
86
- this.dafaultProcessFieldChange(compAttr, attributeValue);
87
- this.processFieldChange(compAttr, attributeValue);
90
+ const attrName = mapping[index].toString();
91
+ const attributeValue = (_b = this.field) === null || _b === void 0 ? void 0 : _b[attrName];
92
+ this.dafaultProcessFieldChange(attrName, attributeValue);
93
+ this.processFieldChange(attrName, attributeValue);
88
94
  }
89
95
  // Subscripción a cambios en atributos
90
96
  this.field.attributeChange.subscribe(event => {
91
- const { name: fieldAttr, value } = event;
92
- const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
93
- this.dafaultProcessFieldChange(compAttr, value);
94
- this.processFieldChange(compAttr, value);
97
+ const { name: attrName, value } = event;
98
+ this.dafaultProcessFieldChange(attrName, value);
99
+ this.processFieldChange(attrName, value);
95
100
  });
96
101
  }
97
102
  this.start();
@@ -146,9 +151,9 @@ class FieldComponent {
146
151
  return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
147
152
  }
148
153
  }
149
- FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
150
- FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: FieldComponent, selector: "lib-field", inputs: { field: "field", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
151
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FieldComponent, decorators: [{
154
+ FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
155
+ FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, decorators: [{
152
157
  type: Component,
153
158
  args: [{
154
159
  selector: 'lib-field',
@@ -176,9 +181,9 @@ class ElementComponent {
176
181
  return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
177
182
  }
178
183
  }
179
- ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
180
- ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: ElementComponent, decorators: [{
184
+ ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
185
+ ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
186
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
182
187
  type: Component,
183
188
  args: [{
184
189
  selector: 'lib-element',
@@ -194,9 +199,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
194
199
 
195
200
  class FormErrorComponent {
196
201
  }
197
- FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
198
- FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: FormErrorComponent, selector: "lib-form-error", inputs: { errorTitle: "errorTitle", errorMessage: "errorMessage", errorType: "errorType" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
199
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FormErrorComponent, decorators: [{
202
+ FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
203
+ FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormErrorComponent, selector: "lib-form-error", inputs: { errorTitle: "errorTitle", errorMessage: "errorMessage", errorType: "errorType" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, decorators: [{
200
205
  type: Component,
201
206
  args: [{
202
207
  selector: 'lib-form-error',
@@ -219,9 +224,9 @@ class FormHeaderComponent {
219
224
  this.goBackEvent.emit();
220
225
  }
221
226
  }
222
- FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
223
- FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: FormHeaderComponent, selector: "lib-form-header", inputs: { formManager: "formManager", goBackAction: "goBackAction", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
224
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: FormHeaderComponent, decorators: [{
227
+ FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
228
+ FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { formManager: "formManager", goBackAction: "goBackAction", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
225
230
  type: Component,
226
231
  args: [{
227
232
  selector: 'lib-form-header',
@@ -245,9 +250,9 @@ class SectionComponent {
245
250
  }
246
251
  start() { }
247
252
  }
248
- SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
249
- SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SectionComponent, selector: "lib-section", inputs: { section: "section", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
250
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SectionComponent, decorators: [{
253
+ SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
254
+ SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
251
256
  type: Component,
252
257
  args: [{
253
258
  selector: 'lib-section',
@@ -265,9 +270,9 @@ class SubSectionComponent {
265
270
  }
266
271
  start() { }
267
272
  }
268
- SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SubSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
269
- SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", showHeader: "showHeader", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
270
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SubSectionComponent, decorators: [{
273
+ SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
274
+ SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", showHeader: "showHeader", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
275
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
271
276
  type: Component,
272
277
  args: [{
273
278
  selector: 'lib-subsection',
@@ -300,9 +305,9 @@ class LibTableRecordActionComponent {
300
305
  }
301
306
  class() { }
302
307
  }
303
- LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableRecordActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
304
- LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: LibTableRecordActionComponent, selector: "lib-table-record-action", inputs: { recordId: "recordId", recordData: "recordData", action: "action" }, outputs: { actionSelected: "actionSelected" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
305
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
308
+ LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
309
+ LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordActionComponent, selector: "lib-table-record-action", inputs: { recordId: "recordId", recordData: "recordData", action: "action" }, outputs: { actionSelected: "actionSelected" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
310
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
306
311
  type: Component,
307
312
  args: [{
308
313
  selector: 'lib-table-record-action',
@@ -325,9 +330,9 @@ class LibTableRecordFieldComponent {
325
330
  }
326
331
  start() { }
327
332
  }
328
- LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
329
- LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
330
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
333
+ LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
334
+ LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
335
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
331
336
  type: Component,
332
337
  args: [{
333
338
  selector: 'lib-table-record-field',
@@ -417,9 +422,9 @@ class LibTableComponent {
417
422
  }
418
423
  }
419
424
  }
420
- LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
421
- LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", tableRecords: "tableRecords", disabled: "disabled", state: "state", waiting: "waiting" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
422
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: LibTableComponent, decorators: [{
425
+ LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
426
+ LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", tableRecords: "tableRecords", disabled: "disabled", state: "state", waiting: "waiting" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
427
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
423
428
  type: Component,
424
429
  args: [{
425
430
  selector: 'lib-table',
@@ -467,6 +472,10 @@ const operators = {
467
472
  class FormElement {
468
473
  constructor(elementDefinition, formConfig) {
469
474
  var _a, _b, _c;
475
+ this._visible = true;
476
+ this.visibleStates = null;
477
+ this.enabledStates = null;
478
+ this.elementType = null;
470
479
  this._formConfig = formConfig;
471
480
  this._isForced = false;
472
481
  this.setVisibleStates(elementDefinition.visibleStates);
@@ -476,6 +485,7 @@ class FormElement {
476
485
  this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
477
486
  this.customAttributes = (_c = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
478
487
  }
488
+ ;
479
489
  getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
480
490
  setCustomAttribute(name, value) {
481
491
  if (name) {
@@ -522,14 +532,14 @@ class FormElement {
522
532
  this._isForced = forced;
523
533
  }
524
534
  }
525
- show(forced) {
535
+ show(forced = null) {
526
536
  this._visible = true;
527
537
  if (forced !== null) {
528
538
  this._isForced = forced;
529
539
  this._visibleForced = true;
530
540
  }
531
541
  }
532
- hide(forced) {
542
+ hide(forced = null) {
533
543
  this._visible = false;
534
544
  if (forced !== null) {
535
545
  this._isForced = forced;
@@ -540,6 +550,7 @@ class FormElement {
540
550
  disable() { this.disabled = true; }
541
551
  get enabled() { return !this.disabled; }
542
552
  get editable() { return !this.disabled; }
553
+ set editable(editable) { this.disabled = !editable; }
543
554
  }
544
555
 
545
556
  const HEADER = 'HEADER';
@@ -581,35 +592,40 @@ const DEFAULT_CAPTURE_TYPE = 'INPUT';
581
592
  const DEFAULT_ALIGNMENT = 'left';
582
593
  const STD_MAX_LENGTH = 50;
583
594
  const BIG_MAX_LENGTH = 500;
584
- const fldAttr = {
585
- validateOnServer: 'validateOnServer',
586
- value: '_value',
587
- minValue: '_minValue',
588
- maxValue: '_maxValue',
589
- maxLength: '_maxLength',
590
- minLength: '_minLength',
591
- onValidation: '_onValidation',
592
- focus: 'focus',
593
- intrinsicErrorMessage: '_intrinsicErrorMessage',
594
- code: 'fieldCode',
595
- info: 'fieldInfo',
596
- defaultValue: 'defaultValue',
597
- defaultEditable: 'defaultEditable',
598
- visibleLabel: 'visibleLabel',
599
- required: 'fieldRequired',
600
- hasChanged: 'hasChanged',
601
- outputOnly: 'outputOnly',
602
- captureType: 'captureType',
603
- title: 'fieldTitle',
604
- type: 'fieldType',
605
- alignment: 'fieldAlignment',
606
- format: 'fieldFormat',
607
- externalValue: 'externalValue',
608
- tooltipText: 'tooltipText',
609
- errorType: 'errorType',
610
- errorCode: 'errorCode',
611
- errorMessage: 'errorMessage',
612
- options: 'fieldOptions',
595
+ const directChanges = [
596
+ 'defaultEditable', 'defaultValue', 'alignment', 'required', 'errorCode', 'errorMessage', 'errorType',
597
+ 'tooltip', 'info', 'format', 'intrinsicErrorMessage', 'outputOnly', 'captureType', 'title', 'type',
598
+ 'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
599
+ 'options',
600
+ ];
601
+ const attrs = {
602
+ _captureType: { name: '_captureType', propagate: 'captureType' },
603
+ _errorCode: { name: '_errorCode', propagate: 'errorCode' },
604
+ _errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
605
+ _errorType: { name: '_errorType', propagate: 'errorType' },
606
+ _defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
607
+ _defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
608
+ _fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
609
+ _fieldCode: { name: '_fieldCode', propagate: 'code' },
610
+ _fieldInfo: { name: '_fieldInfo', propagate: 'info' },
611
+ _fieldRequired: { name: '_fieldRequired', propagate: 'required' },
612
+ _fieldTitle: { name: '_fieldTitle', propagate: 'title' },
613
+ _fieldType: { name: '_fieldType', propagate: 'type' },
614
+ _fieldFormat: { name: '_fieldFormat', propagate: 'format' },
615
+ _fieldOptions: { name: '_fieldOptions', propagate: 'options' },
616
+ _focus: { name: '_focus', propagate: 'focus' },
617
+ _hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
618
+ _intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
619
+ _maxLength: { name: '_maxLength', propagate: 'maxLength' },
620
+ _maxValue: { name: '_maxValue', propagate: 'maxValue' },
621
+ _minLength: { name: '_minLength', propagate: 'minLength' },
622
+ _minValue: { name: '_minValue', propagate: 'minValue' },
623
+ _onValidation: { name: '_onValidation', propagate: 'onValidation' },
624
+ _outputOnly: { name: '_outputOnly', propagate: 'outputOnly' },
625
+ _tooltipText: { name: '_tooltipText', propagate: 'tooltip' },
626
+ _validateOnServer: { name: '_validateOnServer', propagate: 'validateOnServer' },
627
+ _value: { name: '_value', propagate: 'value' },
628
+ _visibleLabel: { name: '_visibleLabel', propagate: 'visibleLabel' },
613
629
  };
614
630
  class FieldDescriptor extends FormElement {
615
631
  constructor(inputFieldReceived, formConfig) {
@@ -619,48 +635,48 @@ class FieldDescriptor extends FormElement {
619
635
  this._editionPartial = new Subject();
620
636
  this._detailRequest = new Subject();
621
637
  this._attributeChange = new Subject();
622
- this.validateOnServer = false;
623
- this._focus = false;
638
+ this._errorType = '';
639
+ this._errorCode = '';
640
+ this._errorMessage = '';
641
+ this._fieldCode = '';
642
+ this._intrinsicErrorMessage = '';
624
643
  this._maxLength = 0;
625
644
  this._minLength = 0;
645
+ this._focus = false;
626
646
  this._onValidation = false;
627
- this._intrinsicErrorMessage = '';
628
- this.fieldCode = '';
629
- this.fieldInfo = '';
630
- this.defaultValue = '';
631
- this.defaultEditable = false;
632
- this.visibleLabel = false;
633
- this.fieldRequired = false;
634
- this.hasChanged = false;
635
- this.outputOnly = false;
636
- this.captureType = '';
637
- this.fieldTitle = '';
638
- this.fieldType = '';
639
- this.fieldAlignment = '';
640
- this.fieldFormat = null;
641
- this.tooltipText = '';
642
- this.errorType = '';
643
- this.errorCode = '';
644
- this.errorMessage = '';
645
- this.fieldOptions = null;
647
+ this._validateOnServer = false;
648
+ this._visibleLabel = false;
649
+ this._captureType = '';
650
+ this._defaultValue = '';
651
+ this._defaultEditable = false;
652
+ this._fieldAlignment = '';
653
+ this._fieldInfo = '';
654
+ this._fieldRequired = false;
655
+ this._fieldTitle = '';
656
+ this._fieldType = '';
657
+ this._fieldFormat = null;
658
+ this._fieldOptions = null;
659
+ this._hasChanged = false;
660
+ this._outputOnly = false;
661
+ this._tooltipText = '';
646
662
  this.elementType = elementTypes.field;
647
663
  const fld = (inputFieldReceived) ? inputFieldReceived : {};
648
- this.setAttr(fldAttr.code, fld.fieldCode);
649
- this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
650
- this.setAttr(fldAttr.type, fld.fieldTypeCode);
651
- this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
664
+ this.setAttr(attrs._fieldCode, fld.fieldCode);
665
+ this.title = (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this._fieldCode;
666
+ this.type = fld.fieldTypeCode;
667
+ this.captureType = (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE;
652
668
  const defaultValue = (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null;
653
- if (this.fieldType === this._formConfig.fieldTypes.boolean) {
654
- this.setAttr(fldAttr.defaultValue, defaultValue !== null && defaultValue !== void 0 ? defaultValue : false);
669
+ if (this._fieldType === this._formConfig.fieldTypes.boolean) {
670
+ this.defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : false;
655
671
  }
656
672
  else {
657
- this.setAttr(fldAttr.defaultValue, defaultValue);
673
+ this.defaultValue = defaultValue;
658
674
  }
659
- const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
660
- ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
675
+ const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this._fieldType] != null)
676
+ ? this._formConfig.tableFieldStyles[this._fieldType]['text-align'] : DEFAULT_ALIGNMENT;
661
677
  const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
662
- this.setAttr(fldAttr.alignment, fieldAlignment);
663
- this.setAttr(fldAttr.info, fld.info || '');
678
+ this.alignment = fieldAlignment;
679
+ this.info = fld.info || '';
664
680
  let fieldFormat;
665
681
  try {
666
682
  fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
@@ -668,70 +684,256 @@ class FieldDescriptor extends FormElement {
668
684
  catch (e) {
669
685
  fieldFormat = null;
670
686
  }
671
- this.setAttr(fldAttr.format, fieldFormat);
672
- this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
673
- this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
674
- this.setAttr(fldAttr.defaultEditable, this.enabled);
675
- this.setAttr(fldAttr.required, (_e = fld.required) !== null && _e !== void 0 ? _e : false);
676
- this.setError(fld.errorCode, fld.errorMessage, (_f = fld.errorType) !== null && _f !== void 0 ? _f : DEFAULT_ERROR_TYPE);
677
- this.setAttr(fldAttr.outputOnly, (_g = fld.outputOnly) !== null && _g !== void 0 ? _g : false);
678
- const maxLength = (_h = fld.maxLength) !== null && _h !== void 0 ? _h : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
679
- this.setAttr(fldAttr.maxLength, maxLength);
680
- 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 : '';
681
- this.setAttr(fldAttr.intrinsicErrorMessage, intrinsicErrorMessage);
687
+ this.format = fieldFormat;
688
+ this.validateOnServer = (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false;
689
+ this.tooltip = fld.tooltip || '';
690
+ this.defaultEditable = this.enabled;
691
+ this.required = (_e = fld.required) !== null && _e !== void 0 ? _e : false;
692
+ this.outputOnly = (_f = fld.outputOnly) !== null && _f !== void 0 ? _f : false;
693
+ this.maxLength = (_g = fld.maxLength) !== null && _g !== void 0 ? _g : (this._captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
694
+ this.intrinsicErrorMessage = (_q = (_l = (_k = (_j = (_h = this._formConfig) === null || _h === void 0 ? void 0 : _h.fieldValidations) === null || _j === void 0 ? void 0 : _j[this._fieldType]) === null || _k === void 0 ? void 0 : _k.message) !== null && _l !== void 0 ? _l : (_p = (_o = (_m = this._formConfig) === null || _m === void 0 ? void 0 : _m.fieldValidations) === null || _o === void 0 ? void 0 : _o.DEFAULT) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : '';
695
+ this.setError(fld.errorCode, fld.errorMessage, (_r = fld.errorType) !== null && _r !== void 0 ? _r : DEFAULT_ERROR_TYPE);
682
696
  this.setEditable((_s = fld.editable) !== null && _s !== void 0 ? _s : true);
683
- this.setVisibleLabel((_t = fld.visibleLabel) !== null && _t !== void 0 ? _t : true);
697
+ this.visibleLabel = (_t = fld.visibleLabel) !== null && _t !== void 0 ? _t : true;
684
698
  this.setVisibility(fld.visible);
685
- this.setFieldOptions(fld.fieldOptions);
686
- this.setValue((_v = (_u = fld.fieldValue) !== null && _u !== void 0 ? _u : this.defaultValue) !== null && _v !== void 0 ? _v : '');
699
+ this.options = fld.fieldOptions;
700
+ this._setValue((_v = (_u = fld.fieldValue) !== null && _u !== void 0 ? _u : this._defaultValue) !== null && _v !== void 0 ? _v : '');
687
701
  }
688
- get name() { return this.fieldCode; }
689
- get editionFinish() { return this._editionFinish; }
702
+ get alignment() { return this._fieldAlignment; }
703
+ set alignment(alignment) { this.setAttr(attrs._fieldAlignment, alignment); }
690
704
  get attributeChange() { return this._attributeChange; }
691
- get editionPartial() { return this._editionPartial; }
705
+ get backend() { return this._validateOnServer; }
706
+ get captureType() { return this._captureType; }
707
+ set captureType(captureType) { this.setAttr(attrs._captureType, captureType); }
708
+ get code() { return this._fieldCode; }
709
+ get fieldCode() { return this._fieldCode; }
710
+ get defaultValue() { return this._defaultValue; }
711
+ set defaultValue(defaultValue) { this.setAttr(attrs._defaultValue, defaultValue); }
712
+ get defaultEditable() { return this._defaultEditable; }
713
+ set defaultEditable(editable) { this.setAttr(attrs._defaultEditable, editable); }
692
714
  get detailRequest() { return this._detailRequest; }
693
- get info() { return this.fieldInfo; }
694
- get validating() { return this._onValidation; }
695
- set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
696
- focus() { this.setAttr(fldAttr.focus, true); }
697
- setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
698
- set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
699
- get fieldValue() { return this.getValue(); }
700
- getRequired() { return this.required; }
701
- setRequired(required) { this.required = required; }
702
- get required() { return this.fieldRequired; }
703
- set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
704
- get minLength() { return this._minLength; }
705
- set minLength(requiredMinLength) {
706
- this.setAttr(fldAttr.minLength, requiredMinLength);
715
+ get editionFinish() { return this._editionFinish; }
716
+ get editionPartial() { return this._editionPartial; }
717
+ get empty() {
718
+ const fieldCurrentValue = this.value;
719
+ if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
720
+ return true;
721
+ }
722
+ if (this._fieldType === this._formConfig.fieldTypes.array
723
+ && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
724
+ return true;
725
+ }
726
+ ;
727
+ if (this._fieldType === this._formConfig.fieldTypes.phone) {
728
+ if (!Array.isArray(fieldCurrentValue)) {
729
+ return true;
730
+ }
731
+ if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
732
+ return true;
733
+ }
734
+ return false;
735
+ }
736
+ ;
737
+ return fieldCurrentValue === '';
707
738
  }
739
+ get error() { return { type: this._errorType, code: this._errorCode, message: this._errorMessage }; }
740
+ set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
741
+ get errorCode() { return this._errorCode; }
742
+ set errorCode(code) { this.setError(code, this._errorMessage); }
743
+ get errorMessage() { return this._errorMessage; }
744
+ set errorMessage(msg) { this.setError(this._errorCode, msg); }
745
+ get errorType() { return this._errorType; }
746
+ get externalValue() { return this._externalValue; }
747
+ get format() { return this._fieldFormat; }
748
+ set format(format) { this.setAttr(attrs._fieldFormat, format); }
749
+ get hasChanged() { return this._hasChanged; }
750
+ set hasChanged(hasChanged) { this.setAttr(attrs._hasChanged, hasChanged); }
751
+ get info() { return this._fieldInfo; }
752
+ set info(newInfo) { this.setAttr(attrs._fieldInfo, newInfo); }
753
+ set intrinsicErrorMessage(message) { this.setAttr(attrs._intrinsicErrorMessage, message); }
708
754
  get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
709
- set maxLength(requiredMaxLength) {
710
- if (typeof requiredMaxLength === 'string') {
711
- this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
755
+ set maxLength(requiredMaxLength) { this.setAttr(attrs._maxLength, +requiredMaxLength); }
756
+ get maxValue() { return this._maxValue; }
757
+ set maxValue(inputMaxValue) {
758
+ let maxValue = inputMaxValue;
759
+ if (this._fieldType === this._formConfig.fieldTypes.date) {
760
+ maxValue = new Date(maxValue);
761
+ }
762
+ this.setAttr(attrs._maxValue, maxValue);
763
+ }
764
+ get minLength() { return this._minLength; }
765
+ set minLength(requiredMinLength) { this.setAttr(attrs._minLength, +requiredMinLength); }
766
+ get minValue() { return this._minValue; }
767
+ set minValue(inputMinValue) {
768
+ let minValue = inputMinValue;
769
+ if (this._fieldType === this._formConfig.fieldTypes.date) {
770
+ minValue = new Date(minValue);
771
+ }
772
+ this.setAttr(attrs._minValue, minValue);
773
+ }
774
+ get name() { return this._fieldCode; }
775
+ get options() {
776
+ var _a, _b;
777
+ return (_b = (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.map(option => {
778
+ const optionCopy = Object.assign({}, option);
779
+ return optionCopy;
780
+ })) !== null && _b !== void 0 ? _b : null;
781
+ }
782
+ set options(newOptions) {
783
+ var _a, _b, _c, _d;
784
+ if ((!this._formConfig.captureTypesWithOptions.includes(this._captureType))
785
+ || typeof newOptions === UNDEFINED || !newOptions
786
+ || !Array.isArray(newOptions)) {
787
+ return;
788
+ }
789
+ let fieldOptions = newOptions.map((option) => {
790
+ if (option.text !== undefined && option.text !== null
791
+ && option.value !== undefined && option.value !== null) {
792
+ return { fieldOptionValue: option.text, fieldOptionId: option.value };
793
+ }
794
+ return option;
795
+ });
796
+ fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
797
+ && fieldOptions.length > 0) ? fieldOptions : [];
798
+ this.setAttr(attrs._fieldOptions, fieldOptions);
799
+ if (this._value) {
800
+ if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
801
+ const fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(item => { var _a; return (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.find(opt => opt.fieldOptionId === item); });
802
+ this.setAttr(attrs._value, fieldValue);
803
+ }
804
+ else {
805
+ const valInOptions = (_b = this._fieldOptions) === null || _b === void 0 ? void 0 : _b.find(item => item.fieldOptionId === this._value);
806
+ if (!valInOptions) {
807
+ this._setValue('');
808
+ }
809
+ }
712
810
  }
713
- else if (typeof requiredMaxLength === 'number') {
714
- this.setAttr(fldAttr.maxLength, requiredMaxLength);
811
+ if (this._fieldRequired && ((_c = this._fieldOptions) === null || _c === void 0 ? void 0 : _c.length) === 1) {
812
+ this._setValue((_d = this._fieldOptions) === null || _d === void 0 ? void 0 : _d[0].fieldOptionId);
813
+ this.notifyEditionFinish();
715
814
  }
716
815
  }
717
- get value() { return this.getValue(); }
718
- set value(newValue) { this.setValue(newValue); }
816
+ get optionText() { var _a, _b, _c; return (_c = (_b = (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.find(item => item.fieldOptionId === this._value)) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null; }
817
+ get outputOnly() { return this._outputOnly; }
818
+ set outputOnly(outputOnly) { this.setAttr(attrs._outputOnly, outputOnly); }
819
+ get required() { return this._fieldRequired; }
820
+ set required(required) { this.setAttr(attrs._fieldRequired, required !== null && required !== void 0 ? required : false); }
821
+ get title() { return this._fieldTitle; }
822
+ set title(title) { this.setAttr(attrs._fieldTitle, title.toString()); }
823
+ get tooltip() { return this._tooltipText; }
824
+ set tooltip(tooltip) { this.setAttr(attrs._tooltipText, tooltip); }
825
+ get type() { return this._fieldType; }
826
+ set type(fieldType) { this.setAttr(attrs._fieldType, fieldType); }
827
+ get validating() { return this._onValidation; }
828
+ set validating(isValidating) { this.setAttr(attrs._onValidation, isValidating); }
829
+ get value() {
830
+ return (this._fieldType === this._formConfig.fieldTypes.boolean
831
+ || this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
832
+ }
833
+ get validateOnServer() { return this._validateOnServer; }
834
+ set validateOnServer(validateOnServer) { this.setAttr(attrs._validateOnServer, validateOnServer); }
835
+ get serverAction() { return this._validateOnServer; }
836
+ set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
837
+ set value(newValue) { this._setValue(newValue); }
838
+ get visibleLabel() { return this._visibleLabel; }
839
+ set visibleLabel(visibleLabel) { this.setAttr(attrs._visibleLabel, visibleLabel); }
840
+ /**
841
+ * @deprecated Use options
842
+ */
843
+ get fieldOptions() { return this._fieldOptions; }
844
+ /**
845
+ * @deprecated Use options
846
+ */
847
+ set fieldOptions(options) { this.options = options; }
848
+ /**
849
+ * @deprecated Use value
850
+ */
851
+ get fieldValue() { return this.value; }
852
+ /**
853
+ * @deprecated Use hasChanged
854
+ */
855
+ changed(hasChanged = true) { this.hasChanged = hasChanged; }
856
+ clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
857
+ focus() { this.setAttr(attrs._focus, true); }
858
+ getErrorCode() { return this.error.code; }
859
+ setErrorCode(code) { this.setError(code, this._errorMessage); }
860
+ getErrorMessage() { return this.error.message; }
861
+ setErrorMessage(msg) { this.setError(this._errorCode, msg); }
862
+ getRequired() { return this.required; }
863
+ hasError() { return this._errorCode !== NO_ERROR; }
864
+ hideLabel() { this.visibleLabel = false; }
865
+ resetError() { (this._errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
866
+ setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
867
+ setValue(newValue, widgetUpdate = true) { this._setValue(newValue, widgetUpdate); }
868
+ showLabel() { this.visibleLabel = true; }
869
+ /**
870
+ * @deprecated Use title
871
+ */
872
+ setLabel(label) { this.title = label; }
873
+ /**
874
+ * @deprecated Use required
875
+ */
876
+ setRequired(required) { this.required = required; }
877
+ /**
878
+ * @deprecated Use changed
879
+ */
880
+ setChanged(hasChanged) { this.changed(hasChanged); }
881
+ /**
882
+ * @deprecated Use value
883
+ */
884
+ getValue() { return this.value; }
885
+ /**
886
+ * @deprecated Use empty
887
+ */
888
+ isEmpty() { return this.empty; }
889
+ /**
890
+ * @deprecated Use error
891
+ */
892
+ getError() { return this.error; }
893
+ /**
894
+ * @deprecated Use optionText
895
+ */
896
+ getOptionText() { return this.optionText; }
897
+ /**
898
+ * @deprecated Use options
899
+ */
900
+ getFieldOptions() { return this.options; }
901
+ /**
902
+ * @deprecated Use options
903
+ */
904
+ setFieldOptions(newOptions) { return this.options = newOptions; }
905
+ /**
906
+ * @deprecated Use intrinsicErrorMessage
907
+ */
908
+ setIntrinsicErrorMessage(message) { this.intrinsicErrorMessage = message; }
909
+ /**
910
+ * @deprecated Use maxValue
911
+ */
912
+ setMaxValue(inputMaxValue) { this.maxValue = inputMaxValue; }
913
+ /**
914
+ * @deprecated Use minValue
915
+ */
916
+ setMinValue(inputMinValue) { this.minValue = inputMinValue; }
917
+ /**
918
+ * @deprecated Use showLabel
919
+ */
920
+ setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
719
921
  notifyEditionPartial() {
720
922
  this.resetError();
721
- this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
923
+ this._editionPartial.next({ code: this._fieldCode, intrinsicValidation: true });
722
924
  }
723
925
  notifyEditionFinish() {
724
926
  var _a, _b, _c, _d, _e;
725
- const fieldValue = this.getValue();
927
+ const fieldValue = this.value;
726
928
  this.resetError();
727
- const validationConfig = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : {};
929
+ const validationConfig = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this._fieldType]) !== null && _b !== void 0 ? _b : {};
728
930
  const { type, validation } = validationConfig;
729
931
  let message = validationConfig === null || validationConfig === void 0 ? void 0 : validationConfig.message;
730
932
  let intrinsicValidation = true;
731
- if (fieldValue && (validation || this.fieldFormat)) {
933
+ if (fieldValue && (validation || this._fieldFormat)) {
732
934
  if (type === 'regexp') {
733
935
  intrinsicValidation = ((_c = validation === null || validation === void 0 ? void 0 : validation.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
734
- && ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
936
+ && ((_e = (_d = this._fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
735
937
  }
736
938
  else if (type === 'function' && typeof validation === 'function') {
737
939
  const { valid, message: customMessage } = validation(fieldValue, this);
@@ -753,158 +955,48 @@ class FieldDescriptor extends FormElement {
753
955
  if (intrinsicValidation && fieldValue && typeof fieldValue === 'string'
754
956
  && this._minLength && (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.length) < this._minLength) {
755
957
  intrinsicValidation = false;
756
- this.setError('99', `Longitud de ${this.fieldTitle} debe ser de al menos ${this._minLength}`);
757
- }
758
- this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
759
- }
760
- setAttr(name, value) {
761
- this[name] = value;
762
- if (this._formConfig.monitoredFieldAttributes.includes(name)) {
763
- this._attributeChange.next({ name, value });
958
+ this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
764
959
  }
960
+ this._editionFinish.next({ code: this._fieldCode, intrinsicValidation });
765
961
  }
766
962
  notifyEditionDetailRequest(detail) {
767
- const detailEvent = {
768
- code: this.fieldCode,
769
- detail,
770
- };
963
+ const detailEvent = { code: this._fieldCode, detail };
771
964
  this._detailRequest.next(detailEvent);
772
965
  }
773
- setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
774
- showLabel() { this.setVisibleLabel(true); }
775
- hideLabel() { this.setVisibleLabel(false); }
776
- setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
777
- changed() { this.setChanged(true); }
778
- setLabel(label) { this.setAttr(fldAttr.title, label); }
779
- clean() { this.setValue(this.defaultValue || ''); this.resetError(); }
780
- get backend() { return this.validateOnServer; }
781
- setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
782
- hasError() { return this.errorCode !== NO_ERROR; }
783
- resetError() { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
784
- setError(code, message, type = DEFAULT_ERROR_TYPE) {
785
- this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
786
- this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
787
- this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
788
- }
789
- getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
790
- get error() { return this.getError(); }
791
- set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
792
- getErrorCode() { return this.getError().code; }
793
- setErrorCode(code) { this.setError(code, this.errorMessage); }
794
- getErrorMessage() { return this.getError().message; }
795
- setErrorMessage(msg) { this.setError(this.errorCode, msg); }
796
- get empty() { return this.isEmpty(); }
797
- isEmpty() {
798
- const fieldCurrentValue = this.getValue();
799
- if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
800
- return true;
801
- }
802
- if (this.fieldType === this._formConfig.fieldTypes.array
803
- && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
804
- return true;
805
- }
806
- ;
807
- if (this.fieldType === this._formConfig.fieldTypes.phone) {
808
- if (!Array.isArray(fieldCurrentValue)) {
809
- return true;
810
- }
811
- if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
812
- return true;
813
- }
814
- return false;
815
- }
816
- ;
817
- return fieldCurrentValue === '';
818
- }
819
- getValue() {
820
- if (this.fieldType === this._formConfig.fieldTypes.boolean
821
- || this.fieldType === this._formConfig.fieldTypes.check) {
822
- return yn(this._value);
823
- }
824
- return this._value;
966
+ setAttr(attr, value) {
967
+ const { name: attrName, propagate: name } = attr;
968
+ this[attrName] = value;
969
+ name && this._attributeChange.next({ name, value });
825
970
  }
826
- getOptionText() {
827
- var _a, _b, _c;
828
- return (_c = (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.find(item => item.fieldOptionId === this._value)) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null;
971
+ setError(code, message, type = DEFAULT_ERROR_TYPE) {
972
+ this.setAttr(attrs._errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
973
+ this.setAttr(attrs._errorType, (this._errorCode === NO_ERROR) ? '' : type);
974
+ this.setAttr(attrs._errorMessage, message !== null && message !== void 0 ? message : '');
829
975
  }
830
976
  updateFromServer(fld) {
831
- var _a;
832
977
  const fieldKeys = Object.keys(fld);
833
978
  for (let index = 0; index < fieldKeys.length; index++) {
834
979
  const attrName = fieldKeys[index];
835
980
  const attrValue = fld[attrName];
836
- (attrName === this._formConfig.apiFieldAttrs.visible) && this.setVisibility(attrValue);
837
- (attrName === this._formConfig.apiFieldAttrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
838
- (attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
839
- (attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
840
- (attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
841
- (attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
842
- (attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
843
- (attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
844
- (attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
845
- (attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
846
- (attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
847
- (attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
848
- (attrName === this._formConfig.apiFieldAttrs.type) && this.setAttr(fldAttr.type, fld.fieldTypeCode);
849
- (attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
850
- }
851
- }
852
- setMinValue(inputMinValue) {
853
- let minValue = inputMinValue;
854
- if (this.fieldType === this._formConfig.fieldTypes.date) {
855
- minValue = new Date(minValue);
856
- }
857
- this.setAttr(fldAttr.minValue, minValue);
858
- }
859
- setMaxValue(inputMaxValue) {
860
- let maxValue = inputMaxValue;
861
- if (this.fieldType === this._formConfig.fieldTypes.date) {
862
- maxValue = new Date(maxValue);
863
- }
864
- this.setAttr(fldAttr.maxValue, maxValue);
865
- }
866
- getFieldOptions() {
867
- return this.fieldOptions.map(option => {
868
- const optionCopy = Object.assign({}, option);
869
- return optionCopy;
870
- });
871
- }
872
- setFieldOptions(newOptions) {
873
- var _a;
874
- if ((!this._formConfig.captureTypesWithOptions.includes(this.captureType))
875
- || typeof newOptions === UNDEFINED || !newOptions
876
- || !Array.isArray(newOptions)) {
877
- return;
878
- }
879
- let fieldOptions = newOptions.map(option => {
880
- if (option.text !== undefined && option.text !== null
881
- && option.value !== undefined && option.value !== null) {
882
- return { fieldOptionValue: option.text, fieldOptionId: option.value };
883
- }
884
- return Object.assign({}, option);
885
- });
886
- fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
887
- && fieldOptions.length > 0) ? fieldOptions : [];
888
- this.setAttr(fldAttr.options, fieldOptions);
889
- if (this._value) {
890
- if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
891
- const fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
892
- this.setAttr(fldAttr.value, fieldValue);
981
+ if (directChanges.includes(attrName)) {
982
+ this[attrName] = attrValue;
893
983
  }
894
984
  else {
895
- const valInOptions = this.fieldOptions
896
- .find(item => item.fieldOptionId === this._value);
897
- if (!valInOptions) {
898
- this.setValue('');
899
- }
985
+ (attrName === 'label') && (this.title = attrValue);
986
+ (attrName === 'labelVisible') && (this.visibleLabel = attrValue);
987
+ (attrName === 'editable') && this.setEditable(attrValue);
988
+ (attrName === 'visible') && this.setVisibility(attrValue);
989
+ (attrName === 'value') && (this._setValue(attrValue) && (this.hasChanged = false));
990
+ (attrName === 'fieldValue') && (this._setValue(attrValue) && (this.hasChanged = false));
991
+ (attrName === 'fieldOptions') && (this.options = attrValue);
992
+ (attrName === 'fieldTitle') && (this.title = attrValue);
993
+ (attrName === 'fieldTypeCode') && (this.type = attrValue);
994
+ (attrName === 'fieldType') && (this.type = attrValue);
995
+ (attrName === 'tooltipText') && (this.tooltip = attrValue);
900
996
  }
901
997
  }
902
- if (this.fieldRequired && this.fieldOptions.length === 1) {
903
- this.setValue(this.fieldOptions[0].fieldOptionId);
904
- this.notifyEditionFinish();
905
- }
906
998
  }
907
- setValue(newValue, widgetUpdate = true) {
999
+ _setValue(newValue, widgetUpdate = true) {
908
1000
  var _a;
909
1001
  if (typeof newValue === UNDEFINED) {
910
1002
  return true;
@@ -913,12 +1005,12 @@ class FieldDescriptor extends FormElement {
913
1005
  return true;
914
1006
  }
915
1007
  let newFinalValue;
916
- if (this.fieldType === this._formConfig.fieldTypes.boolean
917
- || this.fieldType === this._formConfig.fieldTypes.check) {
1008
+ if (this._fieldType === this._formConfig.fieldTypes.boolean
1009
+ || this._fieldType === this._formConfig.fieldTypes.check) {
918
1010
  newFinalValue = (_a = yn(newValue)) !== null && _a !== void 0 ? _a : false;
919
1011
  }
920
- else if (this.fieldType === this._formConfig.fieldTypes.array
921
- || this.fieldType === this._formConfig.fieldTypes.map) {
1012
+ else if (this._fieldType === this._formConfig.fieldTypes.array
1013
+ || this._fieldType === this._formConfig.fieldTypes.map) {
922
1014
  if (newValue === null || newValue === '') {
923
1015
  newFinalValue = [];
924
1016
  }
@@ -933,9 +1025,9 @@ class FieldDescriptor extends FormElement {
933
1025
  newFinalValue = newValue;
934
1026
  }
935
1027
  if (this._value !== newFinalValue) {
936
- this.setChanged(true);
1028
+ this.hasChanged = true;
937
1029
  if (widgetUpdate) {
938
- this.setAttr(fldAttr.value, newFinalValue);
1030
+ this.setAttr(attrs._value, newFinalValue);
939
1031
  }
940
1032
  else {
941
1033
  this._value = newFinalValue;
@@ -1583,7 +1675,7 @@ class RecordFormSubSection {
1583
1675
  return this.subSectionFields;
1584
1676
  }
1585
1677
  getFieldNames() {
1586
- return this.subSectionFields.map(field => field.fieldCode);
1678
+ return this.subSectionFields.map(field => field.code);
1587
1679
  }
1588
1680
  getActions() {
1589
1681
  return this.subSectionActions;
@@ -1800,7 +1892,7 @@ class FormStructureAndData {
1800
1892
  });
1801
1893
  for (const fieldReceived of formFields) {
1802
1894
  const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
1803
- const fieldCode = fieldToAdd.fieldCode;
1895
+ const fieldCode = fieldToAdd.code;
1804
1896
  if (fieldCode) {
1805
1897
  this._fieldArray.push(fieldToAdd);
1806
1898
  this._fields[fieldCode] = fieldToAdd;
@@ -1895,13 +1987,13 @@ class FormStructureAndData {
1895
1987
  get fields() { return this._fields; }
1896
1988
  get fieldNames() { return this.getFieldNames(); }
1897
1989
  getFields() { return this._fieldArray; }
1898
- getFieldNames() { return this._fieldArray.map(field => field.fieldCode); }
1990
+ getFieldNames() { return this._fieldArray.map(field => field.code); }
1899
1991
  getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
1900
1992
  enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
1901
1993
  disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
1902
- getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
1903
- getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getOptionText(); }
1904
- getFieldOptions(code) { var _a, _b; return (_b = (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getFieldOptions()) !== null && _b !== void 0 ? _b : null; }
1994
+ getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.value; }
1995
+ getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.optionText; }
1996
+ getFieldOptions(code) { var _a, _b; return (_b = (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null; }
1905
1997
  setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
1906
1998
  setFieldError(code, errorCode, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(errorCode, message, type); }
1907
1999
  setFieldIntrinsicErrorMessage(code, message) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setIntrinsicErrorMessage(message); }
@@ -1910,7 +2002,8 @@ class FormStructureAndData {
1910
2002
  const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null);
1911
2003
  for (const code of codes) {
1912
2004
  try {
1913
- (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setRequired(required);
2005
+ const field = (_a = this.getField(code)) !== null && _a !== void 0 ? _a : null;
2006
+ field && (field.required = required);
1914
2007
  }
1915
2008
  catch (e) {
1916
2009
  console.log(`Error modificando campo ${code}: ${e}`);
@@ -1971,28 +2064,28 @@ class FormStructureAndData {
1971
2064
  return processedFields;
1972
2065
  }
1973
2066
  enableFields(codes, secCode, subCode) {
1974
- return this.applyOnFields(fld => fld.enable(), codes, secCode, subCode);
2067
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.enable(), codes, secCode, subCode);
1975
2068
  }
1976
2069
  showFields(codes, secCode, subCode) {
1977
- return this.applyOnFields(fld => fld.show(), codes, secCode, subCode);
2070
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.show(), codes, secCode, subCode);
1978
2071
  }
1979
2072
  hideFields(codes, secCode, subCode) {
1980
- return this.applyOnFields(fld => fld.hide(), codes, secCode, subCode);
2073
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hide(), codes, secCode, subCode);
1981
2074
  }
1982
2075
  showLabelFields(codes, secCode, subCode) {
1983
- return this.applyOnFields(fld => fld.showLablel(), codes, secCode, subCode);
2076
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.showLablel(), codes, secCode, subCode);
1984
2077
  }
1985
2078
  hideLabelFields(codes, secCode, subCode) {
1986
- return this.applyOnFields(fld => fld.hideLabel(), codes, secCode, subCode);
2079
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hideLabel(), codes, secCode, subCode);
1987
2080
  }
1988
2081
  disableFields(codes, secCode, subCode) {
1989
- return this.applyOnFields(fld => fld.disable(), codes, secCode, subCode);
2082
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.disable(), codes, secCode, subCode);
1990
2083
  }
1991
2084
  cleanFields(codes, secCode, subCode) {
1992
- return this.applyOnFields(fld => fld.clean(), codes, secCode, subCode);
2085
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.clean(), codes, secCode, subCode);
1993
2086
  }
1994
2087
  tagFieldsWithError(message, codes, secCode, subCode) {
1995
- return this.applyOnFields(fld => fld.setErrorMessage(message), codes, secCode, subCode);
2088
+ return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.setErrorMessage(message), codes, secCode, subCode);
1996
2089
  }
1997
2090
  cleanErrorFields(codes, secCode, subCode) {
1998
2091
  return this.tagFieldsWithError('', codes, secCode, subCode);
@@ -2001,16 +2094,16 @@ class FormStructureAndData {
2001
2094
  return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
2002
2095
  }
2003
2096
  getRequiredFields(codes, secCode, subCode) {
2004
- return this.getFieldSet(fld => fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2097
+ return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2005
2098
  }
2006
2099
  getRequiredEmptyFields(codes, secCode, subCode) {
2007
- return this.getFieldSet(fld => fld.required && fld.empty, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2100
+ return this.getFieldSet(fld => (fld === null || fld === void 0 ? void 0 : fld.required) && (fld === null || fld === void 0 ? void 0 : fld.empty), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2008
2101
  }
2009
2102
  getChangedFields(codes, secCode, subCode) {
2010
- return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2103
+ return this.getFieldSet(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly) && (fld === null || fld === void 0 ? void 0 : fld.hasChanged()), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2011
2104
  }
2012
2105
  getFieldsWithValidationIssues(codes, secCode, subCode) {
2013
- return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2106
+ return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.hasError(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
2014
2107
  }
2015
2108
  getFieldsValues(inputCodes, secCode, subCode) {
2016
2109
  var _a, _b, _c;
@@ -2128,14 +2221,14 @@ class FormStructureAndData {
2128
2221
  fields: [],
2129
2222
  tables: [],
2130
2223
  };
2131
- formData.fields = this.getFields().filter(fld => !fld.outputOnly)
2224
+ formData.fields = this.getFields().filter(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly))
2132
2225
  .map(fld => {
2133
2226
  const fieldPayload = {
2134
- fieldCode: fld.fieldCode,
2135
- fieldValue: fld.getValue(),
2136
- editable: !fld.disabled,
2137
- visible: fld.visible,
2138
- required: fld.required,
2227
+ fieldCode: fld === null || fld === void 0 ? void 0 : fld.code,
2228
+ fieldValue: fld === null || fld === void 0 ? void 0 : fld.value,
2229
+ editable: !(fld === null || fld === void 0 ? void 0 : fld.disabled),
2230
+ visible: fld === null || fld === void 0 ? void 0 : fld.visible,
2231
+ required: fld === null || fld === void 0 ? void 0 : fld.required,
2139
2232
  fieldOptions: '',
2140
2233
  };
2141
2234
  return fieldPayload;
@@ -2281,6 +2374,7 @@ class BasicFormComponent {
2281
2374
  this._formRoute = null;
2282
2375
  this._definitionObtained = false;
2283
2376
  // Eventos de acciones y campos
2377
+ this._formSectionsCanDeactivate = {};
2284
2378
  this._formSectionsActivate = {};
2285
2379
  this._formSectionsInactivate = {};
2286
2380
  this._formActionsStart = {};
@@ -2581,6 +2675,7 @@ class BasicFormComponent {
2581
2675
  // Se limpian los manejadores de eventos
2582
2676
  this.visible = false;
2583
2677
  this.busy = false;
2678
+ this._formSectionsCanDeactivate = {};
2584
2679
  this._formSectionsActivate = {};
2585
2680
  this._formSectionsInactivate = {};
2586
2681
  this._formActionsStart = {};
@@ -2623,7 +2718,7 @@ class BasicFormComponent {
2623
2718
  displayActionServerError() { }
2624
2719
  displayValidationServerError() { }
2625
2720
  displayTableServerError() { }
2626
- showFieldInfo(fieldCode, detail) { }
2721
+ showFieldInfo(code, detail) { }
2627
2722
  showModalDialog(title, body, options, callback, params) { }
2628
2723
  openUploadDialog(title, body, options, callback, params) { }
2629
2724
  /**
@@ -2800,9 +2895,9 @@ class BasicFormComponent {
2800
2895
  (_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
2801
2896
  const inputFieldNames = Object.keys(this.inputDataFields);
2802
2897
  for (let index = 0; index < inputFieldNames.length; index++) {
2803
- const fieldCode = inputFieldNames[index];
2804
- const fieldValue = this.inputDataFields[fieldCode];
2805
- this.setFieldValue(fieldCode, fieldValue);
2898
+ const code = inputFieldNames[index];
2899
+ const fieldValue = this.inputDataFields[code];
2900
+ this.setFieldValue(code, fieldValue);
2806
2901
  }
2807
2902
  const recordResponse = yield this.requestFormAction(formActions.getData);
2808
2903
  this.checkErrorRecordReceived(recordResponse);
@@ -2930,6 +3025,15 @@ class BasicFormComponent {
2930
3025
  /**
2931
3026
  * Manejo de event handlers para acciones sobre el formulario
2932
3027
  */
3028
+ onSectionCanDeactivate(codes, callback, properties = null) {
3029
+ const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
3030
+ sectionSet.forEach((sectionName) => {
3031
+ if (!this._formSectionsCanDeactivate[sectionName]) {
3032
+ this._formSectionsCanDeactivate[sectionName] = [];
3033
+ }
3034
+ this._formSectionsCanDeactivate[sectionName].push({ callback, properties });
3035
+ });
3036
+ }
2933
3037
  onSectionActivation(codes, callback, properties = null) {
2934
3038
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2935
3039
  sectionSet.forEach((sectionName) => {
@@ -2966,6 +3070,26 @@ class BasicFormComponent {
2966
3070
  this._formActionsFinish[actionName].push({ callback, properties });
2967
3071
  });
2968
3072
  }
3073
+ verifySectionActivation(code) {
3074
+ var _a;
3075
+ return __awaiter(this, void 0, void 0, function* () {
3076
+ const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
3077
+ if (!sectionObject) {
3078
+ return false;
3079
+ }
3080
+ const clientSectionMethods = this._formSectionsCanDeactivate[code];
3081
+ if (clientSectionMethods) {
3082
+ for (const clientSectionMethod of clientSectionMethods) {
3083
+ const { callback, properties } = clientSectionMethod;
3084
+ const canActivate = callback(sectionObject);
3085
+ if (canActivate === false) {
3086
+ return false;
3087
+ }
3088
+ }
3089
+ }
3090
+ return true;
3091
+ });
3092
+ }
2969
3093
  launchSectionActivation(code) {
2970
3094
  var _a;
2971
3095
  return __awaiter(this, void 0, void 0, function* () {
@@ -3072,38 +3196,38 @@ class BasicFormComponent {
3072
3196
  */
3073
3197
  onFieldInput(codes, callback, properties = null) {
3074
3198
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
3075
- fieldSet.forEach((fieldCode) => {
3076
- if (!this._fieldInputValidation[fieldCode]) {
3077
- this._fieldInputValidation[fieldCode] = [];
3199
+ fieldSet.forEach((code) => {
3200
+ if (!this._fieldInputValidation[code]) {
3201
+ this._fieldInputValidation[code] = [];
3078
3202
  }
3079
- this._fieldInputValidation[fieldCode].push({ callback, properties });
3203
+ this._fieldInputValidation[code].push({ callback, properties });
3080
3204
  });
3081
3205
  }
3082
3206
  onFieldValidationStart(codes, callback, properties = null) {
3083
3207
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
3084
- fieldSet.forEach((fieldCode) => {
3085
- if (!this._fieldValidationsStart[fieldCode]) {
3086
- this._fieldValidationsStart[fieldCode] = [];
3208
+ fieldSet.forEach((code) => {
3209
+ if (!this._fieldValidationsStart[code]) {
3210
+ this._fieldValidationsStart[code] = [];
3087
3211
  }
3088
- this._fieldValidationsStart[fieldCode].push({ callback, properties });
3212
+ this._fieldValidationsStart[code].push({ callback, properties });
3089
3213
  });
3090
3214
  }
3091
3215
  onFieldValidationFinish(codes, callback, properties = null) {
3092
3216
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
3093
- fieldSet.forEach((fieldCode) => {
3094
- if (!this._fieldValidationsFinish[fieldCode]) {
3095
- this._fieldValidationsFinish[fieldCode] = [];
3217
+ fieldSet.forEach((code) => {
3218
+ if (!this._fieldValidationsFinish[code]) {
3219
+ this._fieldValidationsFinish[code] = [];
3096
3220
  }
3097
- this._fieldValidationsFinish[fieldCode].push({ callback, properties });
3221
+ this._fieldValidationsFinish[code].push({ callback, properties });
3098
3222
  });
3099
3223
  }
3100
- startFieldInputValidation(fieldCode, intrinsicValidation = true) {
3224
+ startFieldInputValidation(code, intrinsicValidation = true) {
3101
3225
  return __awaiter(this, void 0, void 0, function* () {
3102
- const fieldToValidate = this.getField(fieldCode);
3226
+ const fieldToValidate = this.getField(code);
3103
3227
  if (!fieldToValidate) {
3104
3228
  return false;
3105
3229
  }
3106
- const validationCallbacks = this._fieldInputValidation[fieldCode];
3230
+ const validationCallbacks = this._fieldInputValidation[code];
3107
3231
  if (validationCallbacks) {
3108
3232
  const clientValidationPromises = [];
3109
3233
  for (const validationMethod of validationCallbacks) {
@@ -3116,13 +3240,13 @@ class BasicFormComponent {
3116
3240
  return true;
3117
3241
  });
3118
3242
  }
3119
- startFieldValidation(fieldCode, intrinsicValidation = true) {
3243
+ startFieldValidation(code, intrinsicValidation = true) {
3120
3244
  return __awaiter(this, void 0, void 0, function* () {
3121
- const fieldToValidate = this.getField(fieldCode);
3245
+ const fieldToValidate = this.getField(code);
3122
3246
  if (!fieldToValidate) {
3123
3247
  return;
3124
3248
  }
3125
- const validationCallbacks = this._fieldValidationsStart[fieldCode];
3249
+ const validationCallbacks = this._fieldValidationsStart[code];
3126
3250
  if (validationCallbacks) {
3127
3251
  const clientValidationPromises = [];
3128
3252
  for (const validationMethod of validationCallbacks) {
@@ -3153,10 +3277,9 @@ class BasicFormComponent {
3153
3277
  if (fieldObj.backend) {
3154
3278
  fieldObj.validating = true;
3155
3279
  validationResult = yield this
3156
- .requestFormAction(formActions.validate, fieldObj.fieldCode);
3280
+ .requestFormAction(formActions.validate, fieldObj.code);
3157
3281
  serverError = !!this.errorOccured();
3158
3282
  }
3159
- yield this.finishFieldValidation(fieldObj, validationResult, serverError);
3160
3283
  if (serverError) {
3161
3284
  fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
3162
3285
  fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
@@ -3165,13 +3288,14 @@ class BasicFormComponent {
3165
3288
  callback(fieldObj);
3166
3289
  }
3167
3290
  }
3291
+ yield this.finishFieldValidation(fieldObj, validationResult, serverError);
3168
3292
  fieldObj.validating = false;
3169
3293
  });
3170
3294
  }
3171
3295
  finishFieldValidation(fieldObject, validationResult, serverError = false) {
3172
3296
  var _a;
3173
3297
  return __awaiter(this, void 0, void 0, function* () {
3174
- const validationCallbacks = this._fieldValidationsFinish[fieldObject.fieldCode];
3298
+ const validationCallbacks = this._fieldValidationsFinish[fieldObject.code];
3175
3299
  if (validationCallbacks) {
3176
3300
  const clientActionPromises = [];
3177
3301
  for (const validationMethod of validationCallbacks) {
@@ -3185,9 +3309,9 @@ class BasicFormComponent {
3185
3309
  }
3186
3310
  });
3187
3311
  }
3188
- continueFieldValidation(fieldCode) {
3312
+ continueFieldValidation(code) {
3189
3313
  return __awaiter(this, void 0, void 0, function* () {
3190
- return this.startServerFieldValidation(fieldCode);
3314
+ return this.startServerFieldValidation(code);
3191
3315
  });
3192
3316
  }
3193
3317
  /**
@@ -3722,8 +3846,8 @@ class BasicFormComponent {
3722
3846
  validationError = true;
3723
3847
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3724
3848
  this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
3725
- for (const fieldCode of requiredEmptyFields) {
3726
- const requiredEmptyField = this.getField(fieldCode);
3849
+ for (const code of requiredEmptyFields) {
3850
+ const requiredEmptyField = this.getField(code);
3727
3851
  requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
3728
3852
  break;
3729
3853
  }
@@ -3732,8 +3856,8 @@ class BasicFormComponent {
3732
3856
  if (!validationError && validationIssueFields.length > 0) {
3733
3857
  validationError = true;
3734
3858
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3735
- for (const fieldCode of validationIssueFields) {
3736
- const validationIssueField = this.getField(fieldCode);
3859
+ for (const code of validationIssueFields) {
3860
+ const validationIssueField = this.getField(code);
3737
3861
  if (validationIssueField) {
3738
3862
  validationIssueField.focus();
3739
3863
  }
@@ -3750,8 +3874,8 @@ class BasicFormComponent {
3750
3874
  if (tableRecord && columnNames) {
3751
3875
  for (const columnName of columnNames) {
3752
3876
  const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
3753
- const fieldCode = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
3754
- this.setFieldValue(fieldCode, columnValue);
3877
+ const code = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
3878
+ this.setFieldValue(code, columnValue);
3755
3879
  }
3756
3880
  return true;
3757
3881
  }
@@ -3839,9 +3963,9 @@ class BasicFormComponent {
3839
3963
  return this.onTableGetDataFinish(code, callback, properties);
3840
3964
  }
3841
3965
  }
3842
- BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
3843
- BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: BasicFormComponent, selector: "ng-component", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
3844
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: BasicFormComponent, decorators: [{
3966
+ BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
3967
+ BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
3968
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
3845
3969
  type: Component,
3846
3970
  args: [{
3847
3971
  template: `<ng-content></ng-content>`
@@ -3863,8 +3987,8 @@ const COMPONENTS = [
3863
3987
  ];
3864
3988
  class TuainNgFormsLibModule {
3865
3989
  }
3866
- TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: TuainNgFormsLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3867
- TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: TuainNgFormsLibModule, declarations: [BasicFormComponent,
3990
+ TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3991
+ TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, declarations: [BasicFormComponent,
3868
3992
  ActionComponent,
3869
3993
  FieldComponent,
3870
3994
  ElementComponent,
@@ -3887,12 +4011,10 @@ TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
3887
4011
  LibTableRecordActionComponent,
3888
4012
  LibTableRecordFieldComponent,
3889
4013
  LibTableComponent] });
3890
- TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: TuainNgFormsLibModule, imports: [[
3891
- CommonModule,
3892
- RouterModule,
3893
- FormsModule,
3894
- ]] });
3895
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
4014
+ TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, imports: [CommonModule,
4015
+ RouterModule,
4016
+ FormsModule] });
4017
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
3896
4018
  type: NgModule,
3897
4019
  args: [{
3898
4020
  declarations: COMPONENTS,