tuain-ng-forms-lib 12.0.32 → 12.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tuain-ng-forms-lib.umd.js +83 -123
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/element.js +1 -2
- package/esm2015/lib/classes/forms/field.js +48 -90
- package/esm2015/lib/components/elements/field.component.js +26 -19
- package/esm2015/lib/components/elements/tables/table.component.js +1 -2
- package/esm2015/lib/components/forms/basic-form.js +5 -11
- package/fesm2015/tuain-ng-forms-lib.js +76 -119
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/element.d.ts +0 -1
- package/lib/classes/forms/field.d.ts +6 -5
- package/lib/components/elements/field.component.d.ts +2 -0
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('nanoid'), require('@angular/common'), require('@angular/router'), require('@angular/forms')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('tuain-ng-forms-lib', ['exports', '@angular/core', 'rxjs', 'nanoid', '@angular/common', '@angular/router', '@angular/forms'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['tuain-ng-forms-lib'] = {}, global.ng.core, global.rxjs, global.nanoid, global.ng.common, global.ng.router, global.ng.forms));
|
|
5
|
-
}(this, (function (exports, core, rxjs, nanoid, common, router, forms) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('yn'), require('nanoid'), require('@angular/common'), require('@angular/router'), require('@angular/forms')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('tuain-ng-forms-lib', ['exports', '@angular/core', 'rxjs', 'yn', 'nanoid', '@angular/common', '@angular/router', '@angular/forms'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['tuain-ng-forms-lib'] = {}, global.ng.core, global.rxjs, global.yn, global.nanoid, global.ng.common, global.ng.router, global.ng.forms));
|
|
5
|
+
}(this, (function (exports, core, rxjs, yn, nanoid, common, router, forms) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var yn__default = /*#__PURE__*/_interopDefaultLegacy(yn);
|
|
6
10
|
|
|
7
11
|
var ActionComponent = /** @class */ (function () {
|
|
8
12
|
function ActionComponent() {
|
|
@@ -384,7 +388,8 @@
|
|
|
384
388
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
385
389
|
}
|
|
386
390
|
|
|
387
|
-
var VALUE = '';
|
|
391
|
+
var VALUE = 'value';
|
|
392
|
+
var FOCUS = 'focus';
|
|
388
393
|
var FieldComponent = /** @class */ (function () {
|
|
389
394
|
function FieldComponent() {
|
|
390
395
|
}
|
|
@@ -396,44 +401,50 @@
|
|
|
396
401
|
// Inicialización
|
|
397
402
|
var mapping = Object.entries(this.formConfig.componentFieldAttrMap);
|
|
398
403
|
for (var index = 0; index < mapping.length; index++) {
|
|
399
|
-
var _c = __read(mapping[index], 2),
|
|
404
|
+
var _c = __read(mapping[index], 2), fieldAttr1 = _c[0], compAttr1 = _c[1];
|
|
400
405
|
var compAttr = compAttr1.toString();
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
this[compAttr] = (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
|
|
406
|
-
}
|
|
406
|
+
var fieldAttr = fieldAttr1.toString();
|
|
407
|
+
var attributeValue = (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr];
|
|
408
|
+
this.dafaultProcessFieldChange(compAttr, attributeValue);
|
|
409
|
+
this.processFieldChange(compAttr, attributeValue);
|
|
407
410
|
}
|
|
408
411
|
// Subscripción a cambios en atributos
|
|
409
412
|
this.field.attributeChange.subscribe(function (event) {
|
|
410
413
|
var fieldAttr = event.name, value = event.value;
|
|
411
414
|
var compAttr = _this.formConfig.componentFieldAttrMap[fieldAttr];
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
_this[compAttr] = value;
|
|
417
|
-
}
|
|
415
|
+
_this.dafaultProcessFieldChange(compAttr, value);
|
|
416
|
+
_this.processFieldChange(compAttr, value);
|
|
418
417
|
});
|
|
419
418
|
}
|
|
420
419
|
this.start();
|
|
421
420
|
};
|
|
421
|
+
FieldComponent.prototype.dafaultProcessFieldChange = function (attribute, value) {
|
|
422
|
+
if (attribute === VALUE) {
|
|
423
|
+
this.updateValue();
|
|
424
|
+
}
|
|
425
|
+
else if (attribute === FOCUS) {
|
|
426
|
+
this.focus();
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
this[attribute] = value;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
FieldComponent.prototype.processFieldChange = function (attribute, value) { };
|
|
422
433
|
FieldComponent.prototype.start = function () { };
|
|
423
434
|
FieldComponent.prototype.focus = function () { };
|
|
424
435
|
FieldComponent.prototype.updateObject = function () {
|
|
425
|
-
this.field.
|
|
436
|
+
this.field.setValue(this.value);
|
|
426
437
|
};
|
|
427
438
|
FieldComponent.prototype.inputChanged = function () {
|
|
428
|
-
this.field.
|
|
439
|
+
this.field.setValue(this.value);
|
|
429
440
|
this.onChangeContent();
|
|
430
441
|
};
|
|
431
442
|
FieldComponent.prototype.inputTyped = function () {
|
|
432
|
-
this.field.
|
|
443
|
+
this.field.setValue(this.value);
|
|
433
444
|
this.onInputChange();
|
|
434
445
|
};
|
|
435
446
|
FieldComponent.prototype.updateValue = function () {
|
|
436
|
-
this.value = this.field.
|
|
447
|
+
this.value = this.field.getValue();
|
|
437
448
|
};
|
|
438
449
|
FieldComponent.prototype.onInputChange = function () {
|
|
439
450
|
var _this = this;
|
|
@@ -656,7 +667,6 @@
|
|
|
656
667
|
this._visibleForced = false;
|
|
657
668
|
this.disabled = (_a = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.disabled) !== null && _a !== void 0 ? _a : false;
|
|
658
669
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
659
|
-
this.widget = null;
|
|
660
670
|
this.customAttributes = (_c = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
|
|
661
671
|
}
|
|
662
672
|
FormElement.prototype.getCustomAttribute = function (name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; };
|
|
@@ -1519,7 +1529,6 @@
|
|
|
1519
1529
|
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1520
1530
|
this.selectable = this.table.selectable;
|
|
1521
1531
|
this.hasActions = this.table.hasActions;
|
|
1522
|
-
this.table.widget = this;
|
|
1523
1532
|
this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
|
|
1524
1533
|
this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
|
|
1525
1534
|
this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
|
|
@@ -1691,11 +1700,12 @@
|
|
|
1691
1700
|
var BIG_MAX_LENGTH = 500;
|
|
1692
1701
|
var fldAttr = {
|
|
1693
1702
|
validateOnServer: 'validateOnServer',
|
|
1694
|
-
value: '
|
|
1703
|
+
value: '_value',
|
|
1695
1704
|
minValue: '_minValue',
|
|
1696
1705
|
maxValue: '_maxValue',
|
|
1697
1706
|
maxLength: '_maxLength',
|
|
1698
1707
|
onValidation: '_onValidation',
|
|
1708
|
+
focus: 'focus',
|
|
1699
1709
|
intrinsicErrorMessage: '_intrinsicErrorMessage',
|
|
1700
1710
|
code: 'fieldCode',
|
|
1701
1711
|
info: 'fieldInfo',
|
|
@@ -1799,6 +1809,7 @@
|
|
|
1799
1809
|
enumerable: false,
|
|
1800
1810
|
configurable: true
|
|
1801
1811
|
});
|
|
1812
|
+
FieldDescriptor.prototype.focus = function () { this.setAttr(fldAttr.focus, true); };
|
|
1802
1813
|
FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); };
|
|
1803
1814
|
Object.defineProperty(FieldDescriptor.prototype, "intrinsicErrorMessage", {
|
|
1804
1815
|
set: function (message) { this.setIntrinsicErrorMessage(message); },
|
|
@@ -1869,7 +1880,6 @@
|
|
|
1869
1880
|
FieldDescriptor.prototype.hideLabel = function () { this.setVisibleLabel(false); };
|
|
1870
1881
|
FieldDescriptor.prototype.setChanged = function (hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); };
|
|
1871
1882
|
FieldDescriptor.prototype.changed = function () { this.setChanged(true); };
|
|
1872
|
-
FieldDescriptor.prototype.getRawValue = function () { return this._fieldValue; };
|
|
1873
1883
|
FieldDescriptor.prototype.setLabel = function (label) { this.setAttr(fldAttr.title, label); };
|
|
1874
1884
|
FieldDescriptor.prototype.clean = function () { this.setValue(this.defaultValue || ''); this.resetError(); };
|
|
1875
1885
|
Object.defineProperty(FieldDescriptor.prototype, "backend", {
|
|
@@ -1918,22 +1928,11 @@
|
|
|
1918
1928
|
return fieldCurrentValue === '';
|
|
1919
1929
|
};
|
|
1920
1930
|
FieldDescriptor.prototype.getValue = function () {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1925
|
-
break;
|
|
1926
|
-
case this._formConfig.fieldTypes.check:
|
|
1927
|
-
return (_b = this._fieldValue) !== null && _b !== void 0 ? _b : false;
|
|
1928
|
-
break;
|
|
1929
|
-
case this._formConfig.fieldTypes.currency:
|
|
1930
|
-
return (typeof this._fieldValue === 'string')
|
|
1931
|
-
? this._fieldValue.replace(',', '') : this._fieldValue;
|
|
1932
|
-
break;
|
|
1933
|
-
default:
|
|
1934
|
-
return this._fieldValue;
|
|
1935
|
-
break;
|
|
1931
|
+
if (this.fieldType === this._formConfig.fieldTypes.boolean
|
|
1932
|
+
|| this.fieldType === this._formConfig.fieldTypes.check) {
|
|
1933
|
+
return yn__default['default'](this._value);
|
|
1936
1934
|
}
|
|
1935
|
+
return this._value;
|
|
1937
1936
|
};
|
|
1938
1937
|
FieldDescriptor.prototype.updateFromServer = function (fld) {
|
|
1939
1938
|
var _a;
|
|
@@ -1960,40 +1959,26 @@
|
|
|
1960
1959
|
FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
|
|
1961
1960
|
this.setAttr(fldAttr.type, inputFieldType);
|
|
1962
1961
|
};
|
|
1963
|
-
FieldDescriptor.prototype.setMinValue = function (
|
|
1964
|
-
var
|
|
1965
|
-
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1966
|
-
|
|
1967
|
-
this.setAttr(fldAttr.minValue, minValue);
|
|
1968
|
-
if (!minValue) {
|
|
1969
|
-
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
|
|
1970
|
-
}
|
|
1971
|
-
else {
|
|
1972
|
-
var minDate = new Date(minValue);
|
|
1973
|
-
(_c = this.widget) === null || _c === void 0 ? void 0 : _c.setMinValue(minDate);
|
|
1974
|
-
}
|
|
1962
|
+
FieldDescriptor.prototype.setMinValue = function (inputMinValue) {
|
|
1963
|
+
var minValue = inputMinValue;
|
|
1964
|
+
if (this.fieldType === this._formConfig.fieldTypes.date) {
|
|
1965
|
+
minValue = new Date(minValue);
|
|
1975
1966
|
}
|
|
1967
|
+
this.setAttr(fldAttr.minValue, minValue);
|
|
1976
1968
|
};
|
|
1977
|
-
FieldDescriptor.prototype.setMaxValue = function (
|
|
1978
|
-
var
|
|
1979
|
-
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1980
|
-
|
|
1981
|
-
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1982
|
-
if (!maxValue) {
|
|
1983
|
-
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
|
|
1984
|
-
}
|
|
1985
|
-
else {
|
|
1986
|
-
var maxDate = new Date(maxValue);
|
|
1987
|
-
(_c = this.widget) === null || _c === void 0 ? void 0 : _c.setMaxValue(maxDate);
|
|
1988
|
-
}
|
|
1969
|
+
FieldDescriptor.prototype.setMaxValue = function (inputMaxValue) {
|
|
1970
|
+
var maxValue = inputMaxValue;
|
|
1971
|
+
if (this.fieldType === this._formConfig.fieldTypes.date) {
|
|
1972
|
+
maxValue = new Date(maxValue);
|
|
1989
1973
|
}
|
|
1974
|
+
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1990
1975
|
};
|
|
1991
1976
|
FieldDescriptor.prototype.getFieldOptions = function () {
|
|
1992
1977
|
return JSON.parse(JSON.stringify(this.fieldOptions));
|
|
1993
1978
|
};
|
|
1994
1979
|
FieldDescriptor.prototype.setFieldOptions = function (newOptions) {
|
|
1995
1980
|
var _this = this;
|
|
1996
|
-
var _a
|
|
1981
|
+
var _a;
|
|
1997
1982
|
if ((this.captureType !== 'LIST' && this.captureType !== 'RADIO')
|
|
1998
1983
|
|| typeof newOptions === UNDEFINED || !newOptions
|
|
1999
1984
|
|| !Array.isArray(newOptions)) {
|
|
@@ -2009,17 +1994,14 @@
|
|
|
2009
1994
|
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
2010
1995
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
2011
1996
|
this.setAttr(fldAttr.options, fieldOptions);
|
|
2012
|
-
if (this.
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
if (this._fieldValue) {
|
|
2016
|
-
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
|
|
2017
|
-
var fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
|
|
1997
|
+
if (this._value) {
|
|
1998
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
1999
|
+
var fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
|
|
2018
2000
|
this.setAttr(fldAttr.value, fieldValue);
|
|
2019
2001
|
}
|
|
2020
2002
|
else {
|
|
2021
2003
|
var valInOptions = this.fieldOptions
|
|
2022
|
-
.find(function (item) { return item.fieldOptionId === _this.
|
|
2004
|
+
.find(function (item) { return item.fieldOptionId === _this._value; });
|
|
2023
2005
|
if (!valInOptions) {
|
|
2024
2006
|
this.setValue('');
|
|
2025
2007
|
}
|
|
@@ -2027,57 +2009,41 @@
|
|
|
2027
2009
|
}
|
|
2028
2010
|
if (this.fieldRequired && this.fieldOptions.length === 1) {
|
|
2029
2011
|
this.setValue(this.fieldOptions[0].fieldOptionId);
|
|
2030
|
-
if ((_c = this.widget) === null || _c === void 0 ? void 0 : _c.onChangeContent) {
|
|
2031
|
-
(_d = this.widget) === null || _d === void 0 ? void 0 : _d.onChangeContent();
|
|
2032
|
-
}
|
|
2033
2012
|
}
|
|
2034
2013
|
};
|
|
2035
2014
|
FieldDescriptor.prototype.setValue = function (newValue, widgetUpdate) {
|
|
2036
2015
|
if (widgetUpdate === void 0) { widgetUpdate = true; }
|
|
2037
|
-
var _a;
|
|
2038
2016
|
if (typeof newValue === UNDEFINED || newValue === null) {
|
|
2039
2017
|
return true;
|
|
2040
2018
|
}
|
|
2041
2019
|
var newFinalValue;
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
case this._formConfig.fieldTypes.array:
|
|
2053
|
-
if (newValue === null || newValue === '') {
|
|
2054
|
-
newFinalValue = [];
|
|
2055
|
-
}
|
|
2056
|
-
else if (!Array.isArray(newValue)) {
|
|
2057
|
-
if (typeof (newValue) !== 'string') {
|
|
2058
|
-
newValue = newValue.toString();
|
|
2059
|
-
}
|
|
2060
|
-
newFinalValue = newValue.split(',');
|
|
2061
|
-
}
|
|
2062
|
-
else {
|
|
2063
|
-
newFinalValue = newValue;
|
|
2064
|
-
}
|
|
2065
|
-
break;
|
|
2066
|
-
case this._formConfig.fieldTypes.map:
|
|
2067
|
-
newFinalValue = newValue;
|
|
2068
|
-
if (newFinalValue && this.widget && widgetUpdate) {
|
|
2069
|
-
var latitude = parseFloat(newFinalValue[0]);
|
|
2070
|
-
var longitude = parseFloat(newFinalValue[1]);
|
|
2071
|
-
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
2072
|
-
}
|
|
2073
|
-
break;
|
|
2074
|
-
default:
|
|
2020
|
+
if (this.fieldType === this._formConfig.fieldTypes.boolean
|
|
2021
|
+
|| this.fieldType === this._formConfig.fieldTypes.check) {
|
|
2022
|
+
newFinalValue = yn__default['default'](newValue);
|
|
2023
|
+
}
|
|
2024
|
+
else if (this.fieldType === this._formConfig.fieldTypes.array
|
|
2025
|
+
|| this.fieldType === this._formConfig.fieldTypes.map) {
|
|
2026
|
+
if (newValue === null || newValue === '') {
|
|
2027
|
+
newFinalValue = [];
|
|
2028
|
+
}
|
|
2029
|
+
else if (Array.isArray(newValue)) {
|
|
2075
2030
|
newFinalValue = newValue;
|
|
2076
|
-
|
|
2031
|
+
}
|
|
2032
|
+
else {
|
|
2033
|
+
newFinalValue = newValue.toString().split(',');
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
else {
|
|
2037
|
+
newFinalValue = newValue;
|
|
2077
2038
|
}
|
|
2078
|
-
if (this.
|
|
2039
|
+
if (this._value !== newFinalValue) {
|
|
2079
2040
|
this.setChanged(true);
|
|
2080
|
-
|
|
2041
|
+
if (widgetUpdate) {
|
|
2042
|
+
this.setAttr(fldAttr.value, newFinalValue);
|
|
2043
|
+
}
|
|
2044
|
+
else {
|
|
2045
|
+
this._value = newFinalValue;
|
|
2046
|
+
}
|
|
2081
2047
|
}
|
|
2082
2048
|
return true;
|
|
2083
2049
|
};
|
|
@@ -4934,11 +4900,8 @@
|
|
|
4934
4900
|
for (var requiredEmptyFields_1 = __values(requiredEmptyFields), requiredEmptyFields_1_1 = requiredEmptyFields_1.next(); !requiredEmptyFields_1_1.done; requiredEmptyFields_1_1 = requiredEmptyFields_1.next()) {
|
|
4935
4901
|
var fieldCode = requiredEmptyFields_1_1.value;
|
|
4936
4902
|
var requiredEmptyField = this.getField(fieldCode);
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
requiredEmptyField.widget.focus();
|
|
4940
|
-
break;
|
|
4941
|
-
}
|
|
4903
|
+
requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
|
|
4904
|
+
break;
|
|
4942
4905
|
}
|
|
4943
4906
|
}
|
|
4944
4907
|
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
@@ -4957,11 +4920,8 @@
|
|
|
4957
4920
|
for (var validationIssueFields_1 = __values(validationIssueFields), validationIssueFields_1_1 = validationIssueFields_1.next(); !validationIssueFields_1_1.done; validationIssueFields_1_1 = validationIssueFields_1.next()) {
|
|
4958
4921
|
var fieldCode = validationIssueFields_1_1.value;
|
|
4959
4922
|
var validationIssueField = this.getField(fieldCode);
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
validationIssueField.widget.focus();
|
|
4963
|
-
break;
|
|
4964
|
-
}
|
|
4923
|
+
validationIssueField.focus();
|
|
4924
|
+
break;
|
|
4965
4925
|
}
|
|
4966
4926
|
}
|
|
4967
4927
|
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|