tuain-ng-forms-lib 0.12.32 → 0.12.36

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 (34) hide show
  1. package/bundles/tuain-ng-forms-lib.umd.js +322 -291
  2. package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
  3. package/esm2015/lib/classes/forms/action.js +5 -5
  4. package/esm2015/lib/classes/forms/element.js +6 -7
  5. package/esm2015/lib/classes/forms/field.js +166 -146
  6. package/esm2015/lib/classes/forms/form.constants.js +82 -11
  7. package/esm2015/lib/classes/forms/form.js +10 -10
  8. package/esm2015/lib/classes/forms/subsection.js +6 -6
  9. package/esm2015/lib/classes/forms/table/column.js +5 -5
  10. package/esm2015/lib/classes/forms/table/row-data.js +4 -6
  11. package/esm2015/lib/classes/forms/table/table.js +13 -15
  12. package/esm2015/lib/components/elements/action.component.js +1 -3
  13. package/esm2015/lib/components/elements/field.component.js +7 -45
  14. package/esm2015/lib/components/elements/layout/element.component.js +6 -3
  15. package/esm2015/lib/components/elements/layout/form-error.component.js +1 -1
  16. package/esm2015/lib/components/elements/tables/table.component.js +7 -7
  17. package/esm2015/lib/components/forms/basic-form.js +23 -25
  18. package/fesm2015/tuain-ng-forms-lib.js +326 -285
  19. package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
  20. package/lib/classes/forms/action.d.ts +1 -1
  21. package/lib/classes/forms/element.d.ts +2 -3
  22. package/lib/classes/forms/field.d.ts +14 -20
  23. package/lib/classes/forms/form.constants.d.ts +74 -10
  24. package/lib/classes/forms/form.d.ts +2 -3
  25. package/lib/classes/forms/table/column.d.ts +1 -2
  26. package/lib/classes/forms/table/table.d.ts +1 -1
  27. package/lib/components/elements/action.component.d.ts +0 -1
  28. package/lib/components/elements/field.component.d.ts +2 -17
  29. package/lib/components/elements/layout/element.component.d.ts +2 -1
  30. package/lib/components/elements/layout/form-error.component.d.ts +1 -0
  31. package/lib/components/elements/tables/table.component.d.ts +0 -1
  32. package/lib/components/forms/basic-form.d.ts +2 -3
  33. package/package.json +1 -1
  34. package/tuain-ng-forms-lib.metadata.json +1 -1
@@ -12,8 +12,6 @@ class ActionComponent {
12
12
  this.showLabel = true;
13
13
  }
14
14
  ngOnInit() {
15
- var _a;
16
- this.formConfig = (_a = this.actionObject) === null || _a === void 0 ? void 0 : _a._formConfig;
17
15
  this.start();
18
16
  }
19
17
  start() { }
@@ -51,52 +49,106 @@ ActionComponent.propDecorators = {
51
49
  showLabel: [{ type: Input }]
52
50
  };
53
51
 
54
- const MONITORED_ATTRIBUTES = {
55
- _maxLength: 'maxLength',
56
- _onValidation: 'onValidation',
57
- _fieldValue: 'value',
58
- captureType: 'captureType',
59
- fieldTitle: 'title',
60
- fieldType: 'type',
61
- errorMessage: 'errorMessage',
62
- errorType: 'errorType',
63
- errorCode: 'errorCode',
64
- visibleLabel: 'visibleLabel',
65
- fieldRequired: 'required',
66
- fieldOptions: 'options',
52
+ const componentConstants = {
53
+ recordsPerPage: 10,
54
+ // Constantes para el despliegue de formularios
55
+ ELEMENTTYPE_ACTION: 'ACTION',
56
+ ELEMENTTYPE_FIELD: 'FIELD',
57
+ ELEMENTTYPE_TABLE: 'TABLE',
58
+ // Acciones de formularios
59
+ FORMACTION_TABLEACTION: 'TABLEACTION',
60
+ FORMACTION_GETDATA: 'GETDATA',
61
+ FORMACTION_GETTABLEDATA: 'GETTABLEDATA',
62
+ FORMACTION_VALIDATE: 'VALIDATE',
63
+ // Errores etándar de formularios
64
+ FORMERROR_VALIDATION_CODE: '13',
65
+ FORMERROR_TYPE_WARNING: 'WARNING',
66
+ FORMERROR_REQUIRED_FIELDS: 'Todos los campos requeridos deben ser diligenciados',
67
+ FORMERROR_VALIDATION_TITLE: 'Advertencia',
68
+ FORMERROR_VALIDATION_FIELDS: 'Existen campos con problemas de validación',
69
+ // Valores para los controles de navegació
70
+ FORMNAVIGATION_FIRST: 'first',
71
+ FORMNAVIGATION_PREVGROUP: 'prevgroup',
72
+ FORMNAVIGATION_NEXTGROUP: 'nextgroup',
73
+ FORMNAVIGATION_LAST: 'last',
74
+ FIELDTYPE_ARRAY: 'ARRAY',
75
+ FIELDTYPE_CHECK: 'CHECK',
76
+ FIELDTYPE_DATE: 'DATE',
77
+ FIELDTYPE_MAP: 'MAP',
78
+ FIELDTYPE_CURRENCY: 'CURRENCY',
79
+ FIELDTYPE_SELECT: 'SELECT',
80
+ FIELDTYPE_TEXT: 'TEXT',
81
+ FIELD_REQUIRED_MESSAGE: 'Campo requerido',
82
+ FORMTABLEACTION_SORT: 'SORT',
83
+ FORMTABLEACTION_REFRESH: 'REFRESH',
84
+ FORMTABLEACTION_NAVIGATE: 'NAVIGATE',
85
+ FORMTABLEACTION_INLINE: 'INLINE',
86
+ FORMTABLEACTION_GLOBAL: 'GLOBAL',
87
+ FORMTABLEACTION_ROWSELECTION: 'ROWSELECTION',
88
+ FORMTABLEACTION_SELECTION: 'SELECTION',
89
+ TABLE_SORT_ASCENDING: 'asc',
90
+ TABLE_SORT_DESCENDING: 'desc',
91
+ SERVICE_ERRORCODE_NOERROR: '00',
67
92
  };
93
+ const operators = {
94
+ G: '>',
95
+ L: '<',
96
+ GE: '>=',
97
+ LE: '<=',
98
+ EQ: '==',
99
+ NOT_EQ: '!=',
100
+ CONTENT: 'Contiene',
101
+ NOT_CONTENT: 'No Contiene',
102
+ BETWEEN: 'Entre',
103
+ };
104
+ const tableFieldStyles = {
105
+ TEXT: {
106
+ 'text-align': 'left'
107
+ },
108
+ TITLE: {
109
+ 'text-align': 'left'
110
+ },
111
+ LABEL: {
112
+ 'text-align': 'left'
113
+ },
114
+ MESSAGE: {
115
+ 'text-align': 'left'
116
+ },
117
+ NUMBER: {
118
+ 'text-align': 'right'
119
+ },
120
+ DATE: {
121
+ 'text-align': 'right'
122
+ },
123
+ CHECK: {
124
+ 'text-align': 'center'
125
+ },
126
+ ARRAY: {
127
+ 'text-align': 'left'
128
+ },
129
+ SELECT: {
130
+ 'text-align': 'left'
131
+ }
132
+ };
133
+ const DEFAULT_STATE_FLOW = {
134
+ defaultState: 'CREATE',
135
+ states: ['CREATE', 'EDIT', 'VIEW'],
136
+ transitions: [
137
+ { name: 'VIEW1', origin: 'CREATE', destination: 'VIEW' },
138
+ { name: 'VIEW2', origin: 'EDIT', destination: 'VIEW' },
139
+ { name: 'EDIT1', origin: 'CREATE', destination: 'EDIT' },
140
+ { name: 'EDIT2', origin: 'VIEW', destination: 'EDIT' },
141
+ { name: 'CREATE1', origin: 'EDIT', destination: 'CREATE' },
142
+ { name: 'CREATE2', origin: 'VIEW', destination: 'CREATE' },
143
+ ]
144
+ };
145
+
68
146
  class FieldComponent {
147
+ constructor() {
148
+ this.componentConstants = Object.assign({}, componentConstants);
149
+ }
69
150
  ngOnInit() {
70
- var _a;
71
- if (this.fieldObject) {
72
- this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
73
- // Atributos estáticos
74
- this.code = this.fieldObject.fieldCode;
75
- this.fieldInfo = this.fieldObject.fieldInfo;
76
- this.fieldAlignment = this.fieldObject.fieldAlignment;
77
- this.tooltipText = this.fieldObject.tooltipText;
78
- // Cargue inicial
79
- this.maxLength = this.fieldObject._maxLength;
80
- this.onValidation = this.fieldObject._onValidation;
81
- this.value = this.fieldObject._fieldValue;
82
- this.captureType = this.fieldObject.captureType;
83
- this.title = this.fieldObject.fieldTitle;
84
- this.type = this.fieldObject.fieldType;
85
- this.errorMessage = this.fieldObject.errorMessage;
86
- this.errorType = this.fieldObject.errorType;
87
- this.errorCode = this.fieldObject.errorCode;
88
- this.visibleLabel = this.fieldObject.visibleLabel;
89
- this.required = this.fieldObject.fieldRequired;
90
- this.options = this.fieldObject.fieldOptions;
91
- this.fieldObject.widget = this;
92
- // Atributos dinámicos
93
- this.fieldObject.attributeChange.subscribe(event => {
94
- const { name, value } = event;
95
- if (this[MONITORED_ATTRIBUTES[name]]) {
96
- this[MONITORED_ATTRIBUTES[name]] = value;
97
- }
98
- });
99
- }
151
+ this.fieldObject.widget = this;
100
152
  this.start();
101
153
  }
102
154
  start() { }
@@ -121,15 +173,17 @@ FieldComponent.decorators = [
121
173
  template: `<ng-content></ng-content>`
122
174
  },] }
123
175
  ];
176
+ FieldComponent.ctorParameters = () => [];
124
177
  FieldComponent.propDecorators = {
125
178
  fieldObject: [{ type: Input }],
126
179
  disabled: [{ type: Input }]
127
180
  };
128
181
 
129
182
  class ElementComponent {
183
+ constructor() {
184
+ this.componentConstants = Object.assign({}, componentConstants);
185
+ }
130
186
  ngOnInit() {
131
- var _a;
132
- this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
133
187
  this.start();
134
188
  }
135
189
  start() { }
@@ -150,6 +204,7 @@ ElementComponent.decorators = [
150
204
  template: `<ng-content></ng-content>`
151
205
  },] }
152
206
  ];
207
+ ElementComponent.ctorParameters = () => [];
153
208
  ElementComponent.propDecorators = {
154
209
  formElement: [{ type: Input }],
155
210
  formManager: [{ type: Input }]
@@ -245,33 +300,9 @@ class Filter {
245
300
  }
246
301
  }
247
302
 
248
- const elementTypes = {
249
- action: 'ACTION',
250
- field: 'FIELD',
251
- table: 'TABLE',
252
- };
253
- const formActions = {
254
- tableAction: 'TABLEACTION',
255
- getData: 'GETDATA',
256
- getTableData: 'GETTABLEDATA',
257
- validate: 'VALIDATE',
258
- };
259
- const operators = {
260
- G: '>',
261
- L: '<',
262
- GE: '>=',
263
- LE: '<=',
264
- EQ: '==',
265
- NOT_EQ: '!=',
266
- CONTENT: 'Contiene',
267
- NOT_CONTENT: 'No Contiene',
268
- BETWEEN: 'Entre',
269
- };
270
-
271
303
  class FormElement {
272
- constructor(elementDefinition, formConfig) {
304
+ constructor(elementDefinition) {
273
305
  var _a, _b;
274
- this._formConfig = formConfig;
275
306
  this._isForced = false;
276
307
  this.setVisibleStates(elementDefinition.visibleStates);
277
308
  this.setEnabledStates(elementDefinition.enabledStates);
@@ -280,9 +311,9 @@ class FormElement {
280
311
  this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
281
312
  this.widget = null;
282
313
  }
283
- isField() { return this.elementType === elementTypes.field; }
284
- isAction() { return this.elementType === elementTypes.action; }
285
- isTable() { return this.elementType === elementTypes.table; }
314
+ isField() { return this.type === componentConstants.ELEMENTTYPE_FIELD; }
315
+ isAction() { return this.type === componentConstants.ELEMENTTYPE_ACTION; }
316
+ isTable() { return this.type === componentConstants.ELEMENTTYPE_TABLE; }
286
317
  setVisibleStates(newStates) {
287
318
  const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
288
319
  ? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
@@ -328,14 +359,13 @@ class FormElement {
328
359
  }
329
360
 
330
361
  class RecordTableColumn {
331
- constructor(recTableColReceived, formConfig) {
362
+ constructor(recTableColReceived) {
332
363
  var _a, _b, _c;
333
- this._formConfig = formConfig;
334
364
  if (recTableColReceived) {
335
365
  this.fieldCode = recTableColReceived.fieldCode;
336
366
  this.fieldTitle = recTableColReceived.fieldTitle;
337
- this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
338
- const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
367
+ this.fieldType = recTableColReceived.fieldTypeCode || componentConstants.FIELDTYPE_TEXT;
368
+ const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
339
369
  this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
340
370
  this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
341
371
  this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
@@ -422,8 +452,6 @@ function formatCurrency(inputValue) {
422
452
  return outputValue;
423
453
  }
424
454
 
425
- const DATE_TYPE = 'DATE';
426
- const CURRENCY_TYPE = 'CURRENCY';
427
455
  class TableRecordData {
428
456
  constructor(recordReceived, recordDefinition, selectionFieldName = null) {
429
457
  this.recordData = {};
@@ -458,10 +486,10 @@ class TableRecordData {
458
486
  }
459
487
  }
460
488
  formatFieldValue(fieldType, fieldValue) {
461
- if (fieldType === CURRENCY_TYPE) {
489
+ if (fieldType === componentConstants.FIELDTYPE_CURRENCY) {
462
490
  return formatCurrency(fieldValue);
463
491
  }
464
- else if (fieldType === DATE_TYPE && fieldValue) {
492
+ else if (fieldType === componentConstants.FIELDTYPE_DATE && fieldValue) {
465
493
  return new Date(fieldValue).toISOString().split('T')[0];
466
494
  }
467
495
  return fieldValue || '';
@@ -545,8 +573,6 @@ class TableRecordData {
545
573
  }
546
574
  }
547
575
 
548
- const TABLE_SORT_ASCENDING = 'asc';
549
- const TABLE_SORT_DESCENDING = 'desc';
550
576
  const TABLE_FILTER_TYPES = {
551
577
  simpleFilterChange: 'SIMPLE_CHANGE',
552
578
  simpleFilterFinish: 'SIMPLE_FINISH',
@@ -554,9 +580,9 @@ const TABLE_FILTER_TYPES = {
554
580
  complexFilterRemove: 'COMPLEX_REMOVE',
555
581
  };
556
582
  class RecordTable extends FormElement {
557
- constructor(tableReceived, formConfig) {
583
+ constructor(tableReceived) {
558
584
  var _a, _b, _c, _d, _e, _f, _g;
559
- super(tableReceived, formConfig);
585
+ super(tableReceived);
560
586
  this._inlineActionTrigger = new Subject();
561
587
  this._globalActionTrigger = new Subject();
562
588
  this._recordSelectionTrigger = new Subject();
@@ -566,7 +592,7 @@ class RecordTable extends FormElement {
566
592
  this._tableColumnObj = {};
567
593
  this._actionsObj = {};
568
594
  this.allSelected = false;
569
- this.elementType = elementTypes.table;
595
+ this.type = componentConstants.ELEMENTTYPE_TABLE;
570
596
  this.waiting = false;
571
597
  this.complexFilter = false;
572
598
  this.currentPage = 1;
@@ -589,10 +615,10 @@ class RecordTable extends FormElement {
589
615
  this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
590
616
  this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
591
617
  this.sorting = { columnName: '', direction: '' };
592
- this.recordsPerPage = formConfig.defaultRecordsPerPage;
618
+ this.recordsPerPage = componentConstants.recordsPerPage;
593
619
  if (tableReceived.fields) {
594
620
  for (const columnReceived of tableReceived.fields) {
595
- const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
621
+ const columnDefinition = new RecordTableColumn(columnReceived);
596
622
  this.columns.push(columnDefinition);
597
623
  this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
598
624
  }
@@ -769,7 +795,7 @@ class RecordTable extends FormElement {
769
795
  return (this._actionsObj && actionCode && this._actionsObj[actionCode])
770
796
  ? this._actionsObj[actionCode] : null;
771
797
  }
772
- getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
798
+ getActions(actionClass = componentConstants.FORMTABLEACTION_INLINE, actionTypes = null) {
773
799
  return this._actions.filter(actionDef => {
774
800
  const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
775
801
  return actionDef.actionClass === actionClass && typeIncluded;
@@ -830,14 +856,14 @@ class RecordTable extends FormElement {
830
856
  setRequiredOrder(columnField) {
831
857
  if (columnField !== this.sorting.columnName) {
832
858
  this.sorting.columnName = columnField;
833
- this.sorting.direction = TABLE_SORT_ASCENDING;
859
+ this.sorting.direction = componentConstants.TABLE_SORT_ASCENDING;
834
860
  }
835
861
  else {
836
- if (this.sorting.direction === TABLE_SORT_ASCENDING) {
837
- this.sorting.direction = TABLE_SORT_DESCENDING;
862
+ if (this.sorting.direction === componentConstants.TABLE_SORT_ASCENDING) {
863
+ this.sorting.direction = componentConstants.TABLE_SORT_DESCENDING;
838
864
  }
839
865
  else {
840
- this.sorting.direction = TABLE_SORT_ASCENDING;
866
+ this.sorting.direction = componentConstants.TABLE_SORT_ASCENDING;
841
867
  }
842
868
  }
843
869
  }
@@ -858,7 +884,7 @@ class RecordTable extends FormElement {
858
884
  else if (recordAColumn > recordBColumn) {
859
885
  result = 1;
860
886
  }
861
- return direction === TABLE_SORT_ASCENDING ? result : -result;
887
+ return direction === componentConstants.TABLE_SORT_ASCENDING ? result : -result;
862
888
  }
863
889
  }
864
890
 
@@ -1014,15 +1040,13 @@ class LibTableComponent {
1014
1040
  this.hasActions = false;
1015
1041
  }
1016
1042
  ngOnInit() {
1017
- var _a;
1018
- this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
1019
- this.tableFieldStyles = this.formConfig.tableFieldStyles;
1043
+ this.tableFieldStyles = tableFieldStyles;
1020
1044
  this.selectable = this.tableObject.selectable;
1021
1045
  this.hasActions = this.tableObject.hasActions;
1022
1046
  this.tableObject.widget = this;
1023
- this.inlineActions = this.tableObject.getActions(this.formConfig.tableActions.inline);
1024
- this.globalActions = this.tableObject.getActions(this.formConfig.tableActions.global);
1025
- this.selectionActions = this.tableObject.getActions(this.formConfig.tableActions.selection);
1047
+ this.inlineActions = this.tableObject.getActions(componentConstants.FORMTABLEACTION_INLINE);
1048
+ this.globalActions = this.tableObject.getActions(componentConstants.FORMTABLEACTION_GLOBAL);
1049
+ this.selectionActions = this.tableObject.getActions(componentConstants.FORMTABLEACTION_SELECTION);
1026
1050
  this.start();
1027
1051
  }
1028
1052
  start() { }
@@ -1132,21 +1156,21 @@ class RecordFormSubSection {
1132
1156
  let arrayToAdd = null;
1133
1157
  const { type, code } = receivedElement;
1134
1158
  switch (type) {
1135
- case elementTypes.field:
1159
+ case componentConstants.ELEMENTTYPE_FIELD:
1136
1160
  elementObject = formObject.getFieldObject(code);
1137
1161
  arrayToAdd = this.subSectionFields;
1138
1162
  break;
1139
- case elementTypes.table:
1163
+ case componentConstants.ELEMENTTYPE_TABLE:
1140
1164
  elementObject = formObject.getTableObject(code);
1141
1165
  arrayToAdd = this.subSectionTables;
1142
1166
  break;
1143
- case elementTypes.action:
1167
+ case componentConstants.ELEMENTTYPE_ACTION:
1144
1168
  elementObject = formObject.getActionObject(code);
1145
1169
  arrayToAdd = this.subSectionActions;
1146
1170
  break;
1147
1171
  }
1148
1172
  if (elementObject) {
1149
- elementObject.elementType = type;
1173
+ elementObject.type = type;
1150
1174
  arrayToAdd.push(elementObject);
1151
1175
  this.subSectionElements.push(elementObject);
1152
1176
  this.elementsArray[code] = elementObject;
@@ -1278,12 +1302,12 @@ class RecordFormSection {
1278
1302
 
1279
1303
  const HEADER$1 = 'HEADER';
1280
1304
  class FormAction extends FormElement {
1281
- constructor(actionDefinition, formConfig) {
1305
+ constructor(actionDefinition) {
1282
1306
  var _a, _b;
1283
- super(actionDefinition, formConfig);
1307
+ super(actionDefinition);
1284
1308
  this._actionActivated = new Subject();
1285
1309
  this.inProgress = false;
1286
- this.elementType = elementTypes.action;
1310
+ this.type = componentConstants.ELEMENTTYPE_ACTION;
1287
1311
  this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
1288
1312
  this.actionName = actionDefinition.actionTitle;
1289
1313
  this.iconName = actionDefinition.iconName || this.actionCode;
@@ -1311,103 +1335,104 @@ class FormAction extends FormElement {
1311
1335
  }
1312
1336
 
1313
1337
  const UNDEFINED = 'undefined';
1314
- const DEFAULT_ERROR_TYPE = 'error';
1315
- const DEFAULT_CAPTURE_TYPE = 'INPUT';
1316
- const DEFAULT_ALIGNMENT = 'left';
1338
+ const FIELD_VALUE = 'fieldValue';
1339
+ const FIELD_OPTIONS = 'fieldOptions';
1340
+ const FIELD_TITLE = 'fieldTitle';
1341
+ const FIELD_CAPTURE_TYPE = 'captureType';
1342
+ const FIELD_TYPE = 'fieldTypeCode';
1343
+ const FIELD_MAX_LENGTH = 'maxLength';
1344
+ const FIELD_VISIBLE = 'visible';
1345
+ const FIELD_LABEL_VISIBLE = 'visibleLabel';
1346
+ const FIELD_REQUIRED = 'required';
1347
+ const FIELD_ERR_CODE = 'errorCode';
1348
+ const FIELD_ERR_MSG = 'errorMessage';
1349
+ const FIELD_TOOLTIP = 'tooltipText';
1350
+ const FIELD_INFO = 'info';
1351
+ const FIELD_EDITABLE = 'editable';
1352
+ const FIELD_TYPES = {
1353
+ array: 'ARRAY',
1354
+ check: 'CHECK',
1355
+ date: 'DATE',
1356
+ daterange: 'DATERANGE',
1357
+ time: 'TIME',
1358
+ timerange: 'TIMERANGE',
1359
+ map: 'MAP',
1360
+ number: 'NUMBER',
1361
+ decimal: 'DECIMAL',
1362
+ currency: 'CURRENCY',
1363
+ select: 'SELECT',
1364
+ typeahead: 'TYPEAHEAD',
1365
+ text: 'TEXT',
1366
+ password: 'PASSWORD',
1367
+ label: 'LABEL',
1368
+ html: 'HTML',
1369
+ title: 'TITLE',
1370
+ message: 'MESSAGE',
1371
+ link: 'LINK',
1372
+ warning: 'WARNING',
1373
+ avatar: 'AVATAR',
1374
+ email: 'EMAIL',
1375
+ phone: 'PHONE',
1376
+ };
1377
+ const FIELD_TYPES_FORMATS = {
1378
+ EMAIL: '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$',
1379
+ };
1317
1380
  const STD_MAX_LENGTH = 50;
1318
1381
  const BIG_MAX_LENGTH = 500;
1319
- const fldAttr = {
1320
- validateOnServer: 'validateOnServer',
1321
- value: '_fieldValue',
1322
- minValue: '_minValue',
1323
- maxValue: '_maxValue',
1324
- maxLength: '_maxLength',
1325
- onValidation: '_onValidation',
1326
- intrinsicErrorMessage: '_intrinsicErrorMessage',
1327
- code: 'fieldCode',
1328
- info: 'fieldInfo',
1329
- defaultValue: 'defaultValue',
1330
- defaultEditable: 'defaultEditable',
1331
- customAttributes: 'customAttributes',
1332
- visibleLabel: 'visibleLabel',
1333
- required: 'fieldRequired',
1334
- hasChanged: 'hasChanged',
1335
- outputOnly: 'outputOnly',
1336
- captureType: 'captureType',
1337
- title: 'fieldTitle',
1338
- type: 'fieldType',
1339
- alignment: 'fieldAlignment',
1340
- format: 'fieldFormat',
1341
- externalValue: 'externalValue',
1342
- tooltipText: 'tooltipText',
1343
- errorType: 'errorType',
1344
- errorCode: 'errorCode',
1345
- errorMessage: 'errorMessage',
1346
- options: 'fieldOptions',
1347
- };
1348
1382
  class FieldDescriptor extends FormElement {
1349
- constructor(inputFieldReceived, formConfig) {
1350
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1351
- super(inputFieldReceived, formConfig);
1383
+ constructor(inputFieldReceived) {
1384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1385
+ super(inputFieldReceived);
1352
1386
  this._editionFinish = new Subject();
1353
1387
  this._editionPartial = new Subject();
1354
1388
  this._detailRequest = new Subject();
1355
- this._attributeChange = new Subject();
1356
- this.elementType = elementTypes.field;
1357
- const fld = (inputFieldReceived) ? inputFieldReceived : {};
1358
- this.setAttr(fldAttr.code, fld.fieldCode);
1359
- this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
1360
- this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
1361
- this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
1362
- const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
1363
- ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
1364
- const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
1365
- this.setAttr(fldAttr.alignment, fieldAlignment);
1366
- this.setAttr(fldAttr.info, fld.info || '');
1367
- let fieldFormat;
1368
- try {
1369
- fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
1370
- }
1371
- catch (e) {
1372
- fieldFormat = null;
1373
- }
1374
- this.setAttr(fldAttr.format, fieldFormat);
1375
- this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
1376
- this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
1377
- this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
1378
- this.setAttr(fldAttr.defaultEditable, this.enabled);
1379
- this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
1380
- this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
1381
- this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
1382
- const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1383
- this.setAttr(fldAttr.maxLength, maxLength);
1384
- this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
1385
- this.setFieldType(fld.fieldTypeCode);
1386
- this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
1387
- this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
1388
- this.setVisibility(fld.visible);
1389
- this.setFieldOptions(fld.fieldOptions);
1390
- this.setValue(fld.fieldValue || this.defaultValue || '');
1389
+ this.type = componentConstants.ELEMENTTYPE_FIELD;
1390
+ const fieldReceived = (inputFieldReceived) ? inputFieldReceived : {};
1391
+ this.setEditable((_a = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.editable) !== null && _a !== void 0 ? _a : true);
1392
+ this.fieldCode = fieldReceived.fieldCode;
1393
+ this.fieldTitle = fieldReceived.fieldTitle || this.fieldCode;
1394
+ this.captureType = fieldReceived.captureType || 'INPUT';
1395
+ this.setFieldType(fieldReceived.fieldTypeCode);
1396
+ this.defaultValue = fieldReceived.defaultValue || null;
1397
+ this._maxLength = (_b = fieldReceived.maxLength) !== null && _b !== void 0 ? _b : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1398
+ this.setValue(fieldReceived.fieldValue || this.defaultValue || '');
1399
+ const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
1400
+ this.fieldAlignment = (fieldReceived.alignment != null) ? fieldReceived.alignment.toLowerCase() : defaultTypeAlignment;
1401
+ this.fieldInfo = fieldReceived.info || '';
1402
+ this.fieldFormat = fieldReceived.format || null;
1403
+ this.validateOnServer = (_c = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.serverAction) !== null && _c !== void 0 ? _c : false;
1404
+ this.customAttributes = (_d = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.customAttributes) !== null && _d !== void 0 ? _d : null;
1405
+ this.setVisibility(fieldReceived.visible);
1406
+ this.visibleLabel = (_e = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.visibleLabel) !== null && _e !== void 0 ? _e : true;
1407
+ this.tooltipText = fieldReceived.tooltip || '';
1408
+ this.defaultEditable = this.enabled;
1409
+ this.fieldRequired = (_f = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.required) !== null && _f !== void 0 ? _f : false;
1410
+ this.errorMessage = fieldReceived.errorMessage || '';
1411
+ this.errorCode = (_g = fieldReceived.errorCode) !== null && _g !== void 0 ? _g : '00';
1412
+ this.outputOnly = (_h = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.outputOnly) !== null && _h !== void 0 ? _h : false;
1413
+ this.setFieldOptions(fieldReceived.fieldOptions);
1414
+ this._intrinsicErrorMessage = (this.fieldType === FIELD_TYPES.email)
1415
+ ? `El valor de ${this.fieldTitle} no corresponde a un correo válido`
1416
+ : `El valor de ${this.fieldTitle} no se ajusta al formato establecido`;
1391
1417
  }
1392
1418
  get name() { return this.fieldCode; }
1393
1419
  get editionFinish() { return this._editionFinish; }
1394
- get attributeChange() { return this._attributeChange; }
1395
1420
  get editionPartial() { return this._editionPartial; }
1396
1421
  get detailRequest() { return this._detailRequest; }
1397
1422
  get validating() { return this._onValidation; }
1398
- set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
1399
- setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
1423
+ set validating(isValidating) { this._onValidation = isValidating; }
1424
+ setIntrinsicErrorMessage(message) { this._intrinsicErrorMessage = message; }
1400
1425
  set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
1401
1426
  get fieldValue() { return this.getValue(); }
1402
1427
  get required() { return this.fieldRequired; }
1403
- set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
1428
+ set required(required) { this.fieldRequired = required !== null && required !== void 0 ? required : false; }
1404
1429
  get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
1405
1430
  set maxLength(requiredMaxLength) {
1406
1431
  if (typeof requiredMaxLength === 'string') {
1407
- this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
1432
+ this._maxLength = parseInt(requiredMaxLength, 10);
1408
1433
  }
1409
1434
  else if (typeof requiredMaxLength === 'number') {
1410
- this.setAttr(fldAttr.maxLength, requiredMaxLength);
1435
+ this._maxLength = requiredMaxLength;
1411
1436
  }
1412
1437
  }
1413
1438
  get value() { return this.getValue(); }
@@ -1417,48 +1442,41 @@ class FieldDescriptor extends FormElement {
1417
1442
  this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
1418
1443
  }
1419
1444
  notifyEditionFinish() {
1420
- var _a, _b, _c, _d, _e;
1445
+ var _a, _b;
1421
1446
  let intrinsicValidation = true;
1422
- const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
1447
+ const fieldDefaultFormat = (FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType])
1448
+ ? new RegExp(FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType]) : null;
1449
+ const fieldFormat = (this.fieldFormat) ? new RegExp(this.fieldFormat) : null;
1423
1450
  const fieldValue = this.getValue();
1424
- if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
1425
- intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
1426
- && ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
1451
+ if (fieldValue && (fieldDefaultFormat || fieldFormat)) {
1452
+ intrinsicValidation = ((_a = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _a !== void 0 ? _a : true)
1453
+ && ((_b = fieldFormat === null || fieldFormat === void 0 ? void 0 : fieldFormat.test(fieldValue)) !== null && _b !== void 0 ? _b : true);
1427
1454
  if (!intrinsicValidation) {
1428
1455
  this.setError('99', this._intrinsicErrorMessage);
1429
1456
  }
1430
1457
  }
1431
1458
  this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
1432
1459
  }
1433
- setAttr(name, value) {
1434
- this[name] = value;
1435
- if (this._formConfig.monitoredFieldAttributes.includes(name)) {
1436
- this._attributeChange.next({ name, value });
1437
- }
1438
- }
1439
1460
  notifyEditionDetailRequest() {
1440
1461
  this._detailRequest.next(this.fieldCode);
1441
1462
  }
1442
- getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
1443
- setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
1444
- showLabel() { this.setVisibleLabel(true); }
1445
- hideLabel() { this.setVisibleLabel(false); }
1446
- setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
1447
- changed() { this.setChanged(true); }
1463
+ showLabel() { this.visibleLabel = true; }
1464
+ hideLabel() { this.visibleLabel = false; }
1465
+ changed() { this.hasChanged = true; }
1448
1466
  getRawValue() { return this._fieldValue; }
1449
- setLabel(label) { this.setAttr(fldAttr.title, label); }
1467
+ setLabel(label) { this.fieldTitle = label; }
1450
1468
  clean() { this.setValue(this.defaultValue || ''); }
1451
1469
  get backend() { return this.validateOnServer; }
1470
+ setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
1452
1471
  setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
1453
- hasError() { return this.errorCode !== '00'; }
1454
- setError(code, message, type = DEFAULT_ERROR_TYPE) {
1455
- this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
1456
- this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
1457
- this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
1472
+ setError(code, message, type = 'error') {
1473
+ this.errorType = (code === '00') ? '' : type;
1474
+ this.errorCode = code;
1475
+ this.errorMessage = message;
1458
1476
  }
1459
1477
  getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
1460
1478
  get error() { return this.getError(); }
1461
- set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
1479
+ set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); }
1462
1480
  getErrorCode() { return this.getError().code; }
1463
1481
  setErrorCode(code) { this.setError(code, this.errorMessage); }
1464
1482
  getErrorMessage() { return this.getError().message; }
@@ -1468,7 +1486,7 @@ class FieldDescriptor extends FormElement {
1468
1486
  if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
1469
1487
  return true;
1470
1488
  }
1471
- if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
1489
+ if ((this.fieldType === FIELD_TYPES.array || this.fieldType === FIELD_TYPES.phone)
1472
1490
  && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
1473
1491
  return true;
1474
1492
  }
@@ -1478,10 +1496,10 @@ class FieldDescriptor extends FormElement {
1478
1496
  getValue() {
1479
1497
  var _a;
1480
1498
  switch (this.fieldType) {
1481
- case this._formConfig.fieldTypes.check:
1499
+ case componentConstants.FIELDTYPE_CHECK:
1482
1500
  return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
1483
1501
  break;
1484
- case this._formConfig.fieldTypes.currency:
1502
+ case componentConstants.FIELDTYPE_CURRENCY:
1485
1503
  return this._fieldValue.replace(',', '');
1486
1504
  break;
1487
1505
  default:
@@ -1491,39 +1509,68 @@ class FieldDescriptor extends FormElement {
1491
1509
  }
1492
1510
  updateFromServer(fld) {
1493
1511
  var _a;
1494
- const fieldKeys = Object.keys(fld);
1495
- for (let index = 0; index < fieldKeys.length; index++) {
1496
- const attrName = fieldKeys[index];
1497
- const attrValue = fld[attrName];
1498
- (attrName === this._formConfig.apifieldattrs.visible) && this.setVisibility(attrValue);
1499
- (attrName === this._formConfig.apifieldattrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
1500
- (attrName === this._formConfig.apifieldattrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
1501
- (attrName === this._formConfig.apifieldattrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
1502
- (attrName === this._formConfig.apifieldattrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
1503
- (attrName === this._formConfig.apifieldattrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
1504
- (attrName === this._formConfig.apifieldattrs.info) && this.setAttr(fldAttr.info, fld.info);
1505
- (attrName === this._formConfig.apifieldattrs.editable) && this.setEditable(fld.editable);
1506
- (attrName === this._formConfig.apifieldattrs.title) && this.setLabel(fld.fieldTitle.toString());
1507
- (attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld._fieldValue) && this.setChanged(false));
1508
- (attrName === this._formConfig.apifieldattrs.options) && this.setFieldOptions(fld.fieldOptions);
1509
- (attrName === this._formConfig.apifieldattrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
1510
- (attrName === this._formConfig.apifieldattrs.type) && this.setFieldType(fld.fieldTypeCode);
1511
- (attrName === this._formConfig.apifieldattrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
1512
+ if (FIELD_VISIBLE in fld) {
1513
+ this.setVisibility(fld.visible);
1514
+ }
1515
+ if (FIELD_LABEL_VISIBLE in fld) {
1516
+ this.setVisibleLabel(fld.visibleLabel);
1517
+ }
1518
+ if (FIELD_REQUIRED in fld) {
1519
+ this.fieldRequired = (_a = fld.required) !== null && _a !== void 0 ? _a : false;
1520
+ }
1521
+ if (FIELD_ERR_CODE in fld) {
1522
+ (this.errorCode = fld.errorCode);
1523
+ }
1524
+ if (FIELD_ERR_MSG in fld) {
1525
+ (this.errorMessage = fld.errorMessage);
1526
+ }
1527
+ if (FIELD_TOOLTIP in fld) {
1528
+ (this.tooltipText = fld.tooltip);
1529
+ }
1530
+ if (FIELD_INFO in fld) {
1531
+ (this.fieldInfo = fld.info);
1532
+ }
1533
+ if (FIELD_EDITABLE in fld) {
1534
+ this.setEditable(fld.editable);
1535
+ }
1536
+ if (FIELD_TITLE in fld) {
1537
+ this.setLabel(fld.fieldTitle.toString());
1538
+ }
1539
+ if (FIELD_VALUE in fld) {
1540
+ this.hasChanged = false;
1541
+ this.setValue(fld.fieldValue);
1542
+ }
1543
+ if (FIELD_OPTIONS in fld) {
1544
+ this.setFieldOptions(fld.fieldOptions);
1545
+ }
1546
+ if (FIELD_CAPTURE_TYPE in fld) {
1547
+ this.captureType = fld.captureType || 'INPUT';
1548
+ }
1549
+ if (FIELD_TYPE in fld) {
1550
+ this.setFieldType(fld.fieldTypeCode);
1551
+ }
1552
+ if (FIELD_MAX_LENGTH in fld) {
1553
+ this.maxLength = fld.maxLength;
1512
1554
  }
1513
1555
  }
1514
1556
  setFieldType(inputFieldType) {
1515
- this.setAttr(fldAttr.type, inputFieldType);
1557
+ this.fieldType = inputFieldType;
1558
+ /**
1559
+ * Se elimina la validación de que sea un tipo conocido
1560
+ * this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
1561
+ * ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
1562
+ */
1516
1563
  }
1517
1564
  format() {
1518
- if (this.fieldType === this._formConfig.fieldTypes.currency) {
1519
- this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
1565
+ if (this.fieldType === componentConstants.FIELDTYPE_CURRENCY) {
1566
+ this._fieldValue = formatCurrency(this._fieldValue);
1520
1567
  }
1521
1568
  }
1522
1569
  setMinValue(minValue) {
1523
1570
  var _a, _b, _c;
1524
- if (this.fieldType === this._formConfig.fieldTypes.date
1571
+ if (this.fieldType === componentConstants.FIELDTYPE_DATE
1525
1572
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
1526
- this.setAttr(fldAttr.minValue, minValue);
1573
+ this._minValue = minValue;
1527
1574
  if (!minValue) {
1528
1575
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
1529
1576
  }
@@ -1535,9 +1582,9 @@ class FieldDescriptor extends FormElement {
1535
1582
  }
1536
1583
  setMaxValue(maxValue) {
1537
1584
  var _a, _b, _c;
1538
- if (this.fieldType === this._formConfig.fieldTypes.date
1585
+ if (this.fieldType === componentConstants.FIELDTYPE_DATE
1539
1586
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
1540
- this.setAttr(fldAttr.maxValue, maxValue);
1587
+ this._maxValue = maxValue;
1541
1588
  if (!maxValue) {
1542
1589
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
1543
1590
  }
@@ -1557,23 +1604,21 @@ class FieldDescriptor extends FormElement {
1557
1604
  || !Array.isArray(newOptions)) {
1558
1605
  return;
1559
1606
  }
1560
- let fieldOptions = newOptions.map(option => {
1607
+ const fieldOptions = newOptions.map(option => {
1561
1608
  if (option.text !== undefined && option.text !== null
1562
1609
  && option.value !== undefined && option.value !== null) {
1563
1610
  return { fieldOptionValue: option.text, fieldOptionId: option.value };
1564
1611
  }
1565
1612
  return Object.assign({}, option);
1566
1613
  });
1567
- fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
1614
+ this.fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
1568
1615
  && fieldOptions.length > 0) ? fieldOptions : [];
1569
- this.setAttr(fldAttr.options, fieldOptions);
1570
- if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
1616
+ if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && this.widget) {
1571
1617
  return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
1572
1618
  }
1573
1619
  if (this._fieldValue) {
1574
- if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
1575
- const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1576
- this.setAttr(fldAttr.value, fieldValue);
1620
+ if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && Array.isArray(this._fieldValue)) {
1621
+ this._fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1577
1622
  }
1578
1623
  else {
1579
1624
  const valInOptions = this.fieldOptions
@@ -1593,17 +1638,17 @@ class FieldDescriptor extends FormElement {
1593
1638
  setValue(newValue, widgetUpdate = true) {
1594
1639
  var _a;
1595
1640
  if (typeof newValue === UNDEFINED || newValue === null) {
1596
- return true;
1641
+ return;
1597
1642
  }
1598
1643
  let newFinalValue;
1599
1644
  switch (this.fieldType) {
1600
1645
  case 'BOOLEAN':
1601
1646
  newFinalValue = !!newValue;
1602
1647
  break;
1603
- case this._formConfig.fieldTypes.check:
1648
+ case componentConstants.FIELDTYPE_CHECK:
1604
1649
  newFinalValue = !!newValue;
1605
1650
  break;
1606
- case this._formConfig.fieldTypes.array:
1651
+ case componentConstants.FIELDTYPE_ARRAY:
1607
1652
  if (newValue === null || newValue === '') {
1608
1653
  newFinalValue = [];
1609
1654
  }
@@ -1617,7 +1662,7 @@ class FieldDescriptor extends FormElement {
1617
1662
  newFinalValue = newValue;
1618
1663
  }
1619
1664
  break;
1620
- case this._formConfig.fieldTypes.map:
1665
+ case componentConstants.FIELDTYPE_MAP:
1621
1666
  newFinalValue = newValue;
1622
1667
  if (newFinalValue && this.widget && widgetUpdate) {
1623
1668
  const latitude = parseFloat(newFinalValue[0]);
@@ -1625,7 +1670,7 @@ class FieldDescriptor extends FormElement {
1625
1670
  (_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
1626
1671
  }
1627
1672
  break;
1628
- case this._formConfig.fieldTypes.currency:
1673
+ case componentConstants.FIELDTYPE_CURRENCY:
1629
1674
  newFinalValue = formatCurrency(this._fieldValue);
1630
1675
  break;
1631
1676
  default:
@@ -1633,24 +1678,22 @@ class FieldDescriptor extends FormElement {
1633
1678
  break;
1634
1679
  }
1635
1680
  if (this._fieldValue !== newFinalValue) {
1636
- this.setChanged(true);
1637
- this.setAttr(fldAttr.value, newFinalValue);
1681
+ this.hasChanged = true;
1682
+ this._fieldValue = newFinalValue;
1638
1683
  }
1639
- return true;
1640
1684
  }
1641
1685
  }
1642
1686
 
1643
1687
  const HEADER = 'HEADER';
1644
1688
  const NO_ERROR = '00';
1645
1689
  class FormStructureAndData {
1646
- constructor(definitionReceived, formConfig) {
1690
+ constructor(definitionReceived) {
1647
1691
  this._fieldsObj = {};
1648
1692
  this._actionsObj = {};
1649
1693
  this._tableObj = {};
1650
1694
  this._sectionsObj = {};
1651
1695
  this._immutableData = {};
1652
1696
  this._extraInfo = {};
1653
- this._formConfig = formConfig;
1654
1697
  this.state = '';
1655
1698
  this._actions = [];
1656
1699
  this._fields = [];
@@ -1684,7 +1727,7 @@ class FormStructureAndData {
1684
1727
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
1685
1728
  });
1686
1729
  for (const actionReceived of formActions) {
1687
- const globalAction = new FormAction(actionReceived, this._formConfig);
1730
+ const globalAction = new FormAction(actionReceived);
1688
1731
  const globalActionCode = globalAction.actionCode;
1689
1732
  if (globalActionCode) {
1690
1733
  this._actions.push(globalAction);
@@ -1705,7 +1748,7 @@ class FormStructureAndData {
1705
1748
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
1706
1749
  });
1707
1750
  for (const fieldReceived of formFields) {
1708
- const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
1751
+ const fieldToAdd = new FieldDescriptor(fieldReceived);
1709
1752
  const fieldCode = fieldToAdd.fieldCode;
1710
1753
  if (fieldCode) {
1711
1754
  this._fields.push(fieldToAdd);
@@ -1724,12 +1767,12 @@ class FormStructureAndData {
1724
1767
  enabledStates = [...visibleStates];
1725
1768
  }
1726
1769
  if (!visibleStates || visibleStates.length === 0) {
1727
- visibleStates = this._formConfig.defaultStateFlow.states;
1770
+ visibleStates = DEFAULT_STATE_FLOW.states;
1728
1771
  }
1729
1772
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
1730
1773
  });
1731
1774
  for (const tableReceived of tables) {
1732
- const tableToAdd = new RecordTable(tableReceived, this._formConfig);
1775
+ const tableToAdd = new RecordTable(tableReceived);
1733
1776
  const tableCode = tableToAdd.tableCode;
1734
1777
  if (tableCode) {
1735
1778
  this._tables.push(tableToAdd);
@@ -1781,7 +1824,7 @@ class FormStructureAndData {
1781
1824
  }
1782
1825
  setStateFlow(states, transitions, defaultState) {
1783
1826
  if (!states || !transitions) {
1784
- this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
1827
+ this._stateFlow = JSON.parse(JSON.stringify(DEFAULT_STATE_FLOW));
1785
1828
  return;
1786
1829
  }
1787
1830
  this._stateFlow.states = states;
@@ -2007,8 +2050,8 @@ class FormStructureAndData {
2007
2050
  const fieldObject = this.getFieldObject(fieldCode);
2008
2051
  return (fieldObject) ? fieldObject.setValue(fieldValue) : null;
2009
2052
  }
2010
- setFieldError(code, message, type = 'error') {
2011
- const fieldObject = this.getFieldObject(code);
2053
+ setFieldError(fieldCode, code, message, type = 'error') {
2054
+ const fieldObject = this.getFieldObject(fieldCode);
2012
2055
  return (fieldObject) ? fieldObject.setError(code, message, type) : null;
2013
2056
  }
2014
2057
  setFieldIntrinsicErrorMessage(code, message) {
@@ -2322,6 +2365,7 @@ class BasicFormComponent {
2322
2365
  this.transitionToken = null;
2323
2366
  this.inputDataFields = [];
2324
2367
  this.extraData = null;
2368
+ this.componentConstants = componentConstants;
2325
2369
  this.definitionObtained = false;
2326
2370
  this.formVisible = false;
2327
2371
  this.inServerProcess = false;
@@ -2343,9 +2387,6 @@ class BasicFormComponent {
2343
2387
  this.cleanStart();
2344
2388
  this.customPreProcessing();
2345
2389
  }
2346
- setConfig(formConfig) {
2347
- this.formConfig = formConfig;
2348
- }
2349
2390
  cleanStart() {
2350
2391
  this._errorType = '';
2351
2392
  this.errorCode = '';
@@ -2397,7 +2438,7 @@ class BasicFormComponent {
2397
2438
  setFieldValue(fieldCode, fieldValue) { return this.formStructure.setFieldValue(fieldCode, fieldValue); }
2398
2439
  setFieldRequired(fieldCode, required) { return this.formStructure.setFieldRequired(fieldCode, required); }
2399
2440
  setFieldErrorMessage(fieldCode, errorMessage) { return this.formStructure.setFieldErrorMessage(fieldCode, errorMessage); }
2400
- setFieldError(code, message, type = 'error') { return this.formStructure.setFieldError(code, message, type); }
2441
+ setFieldError(fieldCode, code, message, type = 'error') { return this.formStructure.setFieldError(fieldCode, code, message, type); }
2401
2442
  setFieldIntrinsicErrorMessage(code, message) { return this.formStructure.setFieldIntrinsicErrorMessage(code, message); }
2402
2443
  setFieldOptions(fieldCode, optionsArray, idAttribute, nameAttribute) {
2403
2444
  return this.formStructure.setFieldOptions(fieldCode, optionsArray, idAttribute, nameAttribute);
@@ -2634,7 +2675,7 @@ class BasicFormComponent {
2634
2675
  this.inServerProcess = true;
2635
2676
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2636
2677
  this.inServerProcess = false;
2637
- this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2678
+ this.formStructure = new FormStructureAndData(formDefinition);
2638
2679
  this.definitionObtained = true;
2639
2680
  }
2640
2681
  else {
@@ -2660,7 +2701,7 @@ class BasicFormComponent {
2660
2701
  this.setFieldValue(fieldCode, fieldValue);
2661
2702
  }
2662
2703
  }
2663
- const recordResponse = yield this.requestFormAction(formActions.getData);
2704
+ const recordResponse = yield this.requestFormAction(componentConstants.FORMACTION_GETDATA);
2664
2705
  this.checkErrorRecordReceived(recordResponse);
2665
2706
  this.formVisible = true;
2666
2707
  this.subscribeSectionActivation();
@@ -2680,7 +2721,7 @@ class BasicFormComponent {
2680
2721
  this.errorDetail = recordResponse.errorDetail;
2681
2722
  }
2682
2723
  errorOccured() {
2683
- return (this.errorCode !== '00');
2724
+ return (this.errorCode !== componentConstants.SERVICE_ERRORCODE_NOERROR);
2684
2725
  }
2685
2726
  changeState(state) { return this.formStructure.changeState(state); }
2686
2727
  changeFormMode(state) { return this.changeState(state); }
@@ -2961,7 +3002,7 @@ class BasicFormComponent {
2961
3002
  if (fieldObj.backend) {
2962
3003
  fieldObj.validating = true;
2963
3004
  validationResult = yield this
2964
- .requestFormAction(formActions.validate, fieldObj.fieldCode);
3005
+ .requestFormAction(componentConstants.FORMACTION_VALIDATE, fieldObj.fieldCode);
2965
3006
  finish = !this.errorOccured();
2966
3007
  }
2967
3008
  if (finish) {
@@ -3150,7 +3191,7 @@ class BasicFormComponent {
3150
3191
  actionCode
3151
3192
  };
3152
3193
  actionResult = yield this
3153
- .requestFormAction(formActions.tableAction, actionSubject);
3194
+ .requestFormAction(componentConstants.FORMACTION_TABLEACTION, actionSubject);
3154
3195
  finish = !this.errorOccured();
3155
3196
  }
3156
3197
  if (finish) {
@@ -3227,13 +3268,13 @@ class BasicFormComponent {
3227
3268
  if (action.backend) {
3228
3269
  const actionSubject = {
3229
3270
  tableCode,
3230
- actionType: this.formConfig.tableActions.inline,
3271
+ actionType: componentConstants.FORMTABLEACTION_INLINE,
3231
3272
  actionCode,
3232
3273
  tableRecordId: recordId,
3233
3274
  tableRecordData: recordData
3234
3275
  };
3235
3276
  actionResult = yield this
3236
- .requestFormAction(formActions.tableAction, actionSubject);
3277
+ .requestFormAction(componentConstants.FORMACTION_TABLEACTION, actionSubject);
3237
3278
  finish = !this.errorOccured();
3238
3279
  }
3239
3280
  if (finish) {
@@ -3306,13 +3347,13 @@ class BasicFormComponent {
3306
3347
  if (tableObject.selectionBackend) {
3307
3348
  const actionSubject = {
3308
3349
  tableCode,
3309
- actionType: this.formConfig.tableActions.rowSelection,
3350
+ actionType: componentConstants.FORMTABLEACTION_ROWSELECTION,
3310
3351
  actionCode: null,
3311
3352
  tableRecordId: recordId,
3312
3353
  tableRecordData: recordData
3313
3354
  };
3314
3355
  actionResult = yield this
3315
- .requestFormAction(formActions.tableAction, actionSubject);
3356
+ .requestFormAction(componentConstants.FORMACTION_TABLEACTION, actionSubject);
3316
3357
  finish = !this.errorOccured();
3317
3358
  }
3318
3359
  if (finish) {
@@ -3386,12 +3427,12 @@ class BasicFormComponent {
3386
3427
  if (action.backend) {
3387
3428
  const actionSubject = {
3388
3429
  tableCode,
3389
- actionType: this.formConfig.tableActions.selection,
3430
+ actionType: componentConstants.FORMTABLEACTION_SELECTION,
3390
3431
  actionCode,
3391
3432
  selectedRecords
3392
3433
  };
3393
3434
  actionResult = yield this
3394
- .requestFormAction(formActions.tableAction, actionSubject);
3435
+ .requestFormAction(componentConstants.FORMACTION_TABLEACTION, actionSubject);
3395
3436
  finish = !this.errorOccured();
3396
3437
  }
3397
3438
  if (finish) {
@@ -3449,7 +3490,7 @@ class BasicFormComponent {
3449
3490
  tableObject.putOnWait();
3450
3491
  const actionSubject = { tableCode };
3451
3492
  const actionResult = yield this
3452
- .requestFormAction(formActions.getTableData, actionSubject);
3493
+ .requestFormAction(componentConstants.FORMACTION_GETTABLEDATA, actionSubject);
3453
3494
  if (this.errorOccured()) {
3454
3495
  this.displayTableServerError();
3455
3496
  }
@@ -3483,15 +3524,15 @@ class BasicFormComponent {
3483
3524
  this.resetError();
3484
3525
  const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
3485
3526
  if (!completeFields) {
3486
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3527
+ this.setError(componentConstants.FORMERROR_TYPE_WARNING, componentConstants.FORMERROR_VALIDATION_TITLE, componentConstants.FORMERROR_REQUIRED_FIELDS);
3487
3528
  return;
3488
3529
  }
3489
3530
  let validationError = false;
3490
3531
  const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
3491
3532
  if (requiredEmptyFields.length > 0) {
3492
3533
  validationError = true;
3493
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3494
- this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
3534
+ this.setError(componentConstants.FORMERROR_TYPE_WARNING, componentConstants.FORMERROR_VALIDATION_TITLE, componentConstants.FORMERROR_REQUIRED_FIELDS);
3535
+ this.tagFieldsWithError(requiredEmptyFields, null, componentConstants.FIELD_REQUIRED_MESSAGE);
3495
3536
  for (const fieldCode of requiredEmptyFields) {
3496
3537
  const requiredEmptyField = this.getField(fieldCode);
3497
3538
  if (requiredEmptyField && requiredEmptyField.widget
@@ -3504,7 +3545,7 @@ class BasicFormComponent {
3504
3545
  const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
3505
3546
  if (!validationError && validationIssueFields.length > 0) {
3506
3547
  validationError = true;
3507
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3548
+ this.setError(componentConstants.FORMERROR_TYPE_WARNING, componentConstants.FORMERROR_VALIDATION_TITLE, componentConstants.FORMERROR_VALIDATION_FIELDS);
3508
3549
  for (const fieldCode of validationIssueFields) {
3509
3550
  const validationIssueField = this.getField(fieldCode);
3510
3551
  if (validationIssueField && validationIssueField.widget
@@ -3620,13 +3661,13 @@ class BasicFormComponent {
3620
3661
  const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
3621
3662
  if (requiredEmptyFields.length > 0) {
3622
3663
  validationOk = false;
3623
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3624
- this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
3664
+ this.setError(componentConstants.FORMERROR_TYPE_WARNING, componentConstants.FORMERROR_VALIDATION_TITLE, componentConstants.FORMERROR_REQUIRED_FIELDS);
3665
+ this.tagFieldsWithError(requiredEmptyFields, null, componentConstants.FIELD_REQUIRED_MESSAGE);
3625
3666
  }
3626
3667
  const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
3627
3668
  if (validationIssueFields.length > 0) {
3628
3669
  validationOk = false;
3629
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3670
+ this.setError(componentConstants.FORMERROR_TYPE_WARNING, componentConstants.FORMERROR_VALIDATION_TITLE, componentConstants.FORMERROR_VALIDATION_FIELDS);
3630
3671
  }
3631
3672
  return validationOk;
3632
3673
  }