@ngx-formly/core 5.10.29 → 5.10.33
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/ngx-formly-core.umd.js +104 -98
- package/bundles/ngx-formly-core.umd.js.map +1 -1
- package/bundles/ngx-formly-core.umd.min.js +1 -1
- package/bundles/ngx-formly-core.umd.min.js.map +1 -1
- package/esm2015/lib/components/formly.attributes.js +45 -22
- package/esm2015/lib/extensions/field-expression/field-expression.js +3 -6
- package/esm2015/lib/extensions/field-form/field-form.js +23 -55
- package/esm2015/lib/extensions/field-form/utils.js +9 -3
- package/esm2015/lib/services/formly.form.builder.js +3 -3
- package/esm2015/lib/utils.js +21 -21
- package/esm5/lib/components/formly.attributes.js +51 -19
- package/esm5/lib/extensions/field-expression/field-expression.js +3 -6
- package/esm5/lib/extensions/field-form/field-form.js +25 -55
- package/esm5/lib/extensions/field-form/utils.js +10 -3
- package/esm5/lib/services/formly.form.builder.js +3 -3
- package/esm5/lib/utils.js +21 -24
- package/fesm2015/ngx-formly-core.js +96 -102
- package/fesm2015/ngx-formly-core.js.map +1 -1
- package/fesm5/ngx-formly-core.js +106 -103
- package/fesm5/ngx-formly-core.js.map +1 -1
- package/lib/components/formly.attributes.d.ts +1 -0
- package/lib/extensions/field-form/utils.d.ts +1 -1
- package/lib/utils.d.ts +1 -1
- package/ngx-formly-core.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -102,6 +102,20 @@
|
|
|
102
102
|
* @fileoverview added by tsickle
|
|
103
103
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
104
104
|
*/
|
|
105
|
+
/**
|
|
106
|
+
* @param {?} form
|
|
107
|
+
* @param {?} callback
|
|
108
|
+
* @return {?}
|
|
109
|
+
*/
|
|
110
|
+
function disableTreeValidityCall(form, callback) {
|
|
111
|
+
/** @type {?} */
|
|
112
|
+
var _updateTreeValidity = form._updateTreeValidity.bind(form);
|
|
113
|
+
form._updateTreeValidity = ( /**
|
|
114
|
+
* @return {?}
|
|
115
|
+
*/function () { });
|
|
116
|
+
callback();
|
|
117
|
+
form._updateTreeValidity = _updateTreeValidity;
|
|
118
|
+
}
|
|
105
119
|
/**
|
|
106
120
|
* @param {?} formId
|
|
107
121
|
* @param {?} field
|
|
@@ -113,8 +127,12 @@
|
|
|
113
127
|
return field.id;
|
|
114
128
|
/** @type {?} */
|
|
115
129
|
var type = field.type;
|
|
116
|
-
if (!type && field.template)
|
|
130
|
+
if (!type && field.template) {
|
|
117
131
|
type = 'template';
|
|
132
|
+
}
|
|
133
|
+
if (isFunction(type)) {
|
|
134
|
+
type = (( /** @type {?} */(type))).prototype.constructor.name;
|
|
135
|
+
}
|
|
118
136
|
return [formId, type, field.key, index].join('_');
|
|
119
137
|
}
|
|
120
138
|
/**
|
|
@@ -421,27 +439,6 @@
|
|
|
421
439
|
* @return {?}
|
|
422
440
|
*/function () { return fns.splice(fns.indexOf(setFn), 1); });
|
|
423
441
|
}
|
|
424
|
-
/**
|
|
425
|
-
* @param {?} form
|
|
426
|
-
* @param {?} action
|
|
427
|
-
* @return {?}
|
|
428
|
-
*/
|
|
429
|
-
function reduceFormUpdateValidityCalls(form, action) {
|
|
430
|
-
/** @type {?} */
|
|
431
|
-
var updateValidity = form._updateTreeValidity.bind(form);
|
|
432
|
-
/** @type {?} */
|
|
433
|
-
var updateValidityArgs = { called: false, emitEvent: false };
|
|
434
|
-
form._updateTreeValidity = ( /**
|
|
435
|
-
* @param {?=} __0
|
|
436
|
-
* @return {?}
|
|
437
|
-
*/function (_a) {
|
|
438
|
-
var emitEvent = (_a === void 0 ? { emitEvent: true } : _a).emitEvent;
|
|
439
|
-
return updateValidityArgs = { called: true, emitEvent: emitEvent || updateValidityArgs.emitEvent };
|
|
440
|
-
});
|
|
441
|
-
action();
|
|
442
|
-
updateValidityArgs.called && updateValidity({ emitEvent: updateValidityArgs.emitEvent });
|
|
443
|
-
form._updateTreeValidity = updateValidity;
|
|
444
|
-
}
|
|
445
442
|
|
|
446
443
|
/**
|
|
447
444
|
* @fileoverview added by tsickle
|
|
@@ -825,7 +822,7 @@
|
|
|
825
822
|
}
|
|
826
823
|
/** @type {?} */
|
|
827
824
|
var field = { fieldGroup: fieldGroup, model: model, formControl: formControl, options: this._setOptions(options) };
|
|
828
|
-
|
|
825
|
+
disableTreeValidityCall(formControl, ( /**
|
|
829
826
|
* @return {?}
|
|
830
827
|
*/function () { return _this._buildForm(field); }));
|
|
831
828
|
field.options._checkField(field, true);
|
|
@@ -1101,15 +1098,24 @@
|
|
|
1101
1098
|
}
|
|
1102
1099
|
/**
|
|
1103
1100
|
* @param {?} c
|
|
1101
|
+
* @param {?=} onlySelf
|
|
1104
1102
|
* @return {?}
|
|
1105
1103
|
*/
|
|
1106
|
-
function updateValidity(c) {
|
|
1104
|
+
function updateValidity(c, onlySelf) {
|
|
1105
|
+
if (onlySelf === void 0) {
|
|
1106
|
+
onlySelf = false;
|
|
1107
|
+
}
|
|
1107
1108
|
/** @type {?} */
|
|
1108
1109
|
var status = c.status;
|
|
1109
|
-
|
|
1110
|
+
/** @type {?} */
|
|
1111
|
+
var value = c.value;
|
|
1112
|
+
c.updateValueAndValidity({ emitEvent: false, onlySelf: onlySelf });
|
|
1110
1113
|
if (status !== c.status) {
|
|
1111
1114
|
(( /** @type {?} */(c.statusChanges))).emit(c.status);
|
|
1112
1115
|
}
|
|
1116
|
+
if (value !== c.value) {
|
|
1117
|
+
(( /** @type {?} */(c.valueChanges))).emit(c.value);
|
|
1118
|
+
}
|
|
1113
1119
|
}
|
|
1114
1120
|
/**
|
|
1115
1121
|
* @param {?} form
|
|
@@ -1909,16 +1915,11 @@
|
|
|
1909
1915
|
*/
|
|
1910
1916
|
var FormlyAttributes = /** @class */ (function () {
|
|
1911
1917
|
function FormlyAttributes(renderer, elementRef, _document) {
|
|
1918
|
+
var _this = this;
|
|
1912
1919
|
this.renderer = renderer;
|
|
1913
1920
|
this.elementRef = elementRef;
|
|
1914
1921
|
this.uiAttributesCache = {};
|
|
1915
|
-
this.uiAttributes =
|
|
1916
|
-
'tabindex',
|
|
1917
|
-
'placeholder',
|
|
1918
|
-
'readonly',
|
|
1919
|
-
'disabled',
|
|
1920
|
-
'step',
|
|
1921
|
-
]);
|
|
1922
|
+
this.uiAttributes = null;
|
|
1922
1923
|
/**
|
|
1923
1924
|
* HostBinding doesn't register listeners conditionally which may produce some perf issues.
|
|
1924
1925
|
*
|
|
@@ -1926,12 +1927,23 @@
|
|
|
1926
1927
|
*/
|
|
1927
1928
|
this.uiEvents = {
|
|
1928
1929
|
listeners: [],
|
|
1929
|
-
events: [
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1930
|
+
events: ['click', 'keyup', 'keydown', 'keypress', 'focus', 'blur', 'change'],
|
|
1931
|
+
callback: ( /**
|
|
1932
|
+
* @param {?} eventName
|
|
1933
|
+
* @param {?} $event
|
|
1934
|
+
* @return {?}
|
|
1935
|
+
*/function (eventName, $event) {
|
|
1936
|
+
switch (eventName) {
|
|
1937
|
+
case 'focus':
|
|
1938
|
+
return _this.onFocus($event);
|
|
1939
|
+
case 'blur':
|
|
1940
|
+
return _this.onBlur($event);
|
|
1941
|
+
case 'change':
|
|
1942
|
+
return _this.onChange($event);
|
|
1943
|
+
default:
|
|
1944
|
+
return _this.to[eventName](_this.field, $event);
|
|
1945
|
+
}
|
|
1946
|
+
}),
|
|
1935
1947
|
};
|
|
1936
1948
|
this.document = _document;
|
|
1937
1949
|
}
|
|
@@ -1970,11 +1982,11 @@
|
|
|
1970
1982
|
* @param {?} eventName
|
|
1971
1983
|
* @return {?}
|
|
1972
1984
|
*/function (eventName) {
|
|
1973
|
-
if (_this.to && _this.to[eventName]) {
|
|
1985
|
+
if ((_this.to && _this.to[eventName]) || ['focus', 'blur', 'change'].indexOf(eventName) !== -1) {
|
|
1974
1986
|
_this.uiEvents.listeners.push(_this.renderer.listen(_this.elementRef.nativeElement, eventName, ( /**
|
|
1975
1987
|
* @param {?} e
|
|
1976
1988
|
* @return {?}
|
|
1977
|
-
*/function (e) { return _this.
|
|
1989
|
+
*/function (e) { return _this.uiEvents.callback(eventName, e); })));
|
|
1978
1990
|
}
|
|
1979
1991
|
}));
|
|
1980
1992
|
if (this.to && this.to.attributes) {
|
|
@@ -2046,6 +2058,14 @@
|
|
|
2046
2058
|
*/
|
|
2047
2059
|
function () {
|
|
2048
2060
|
var _this = this;
|
|
2061
|
+
if (!this.uiAttributes) {
|
|
2062
|
+
/** @type {?} */
|
|
2063
|
+
var element_1 = ( /** @type {?} */(this.elementRef.nativeElement));
|
|
2064
|
+
this.uiAttributes = __spread(FORMLY_VALIDATORS, ['tabindex', 'placeholder', 'readonly', 'disabled', 'step']).filter(( /**
|
|
2065
|
+
* @param {?} attr
|
|
2066
|
+
* @return {?}
|
|
2067
|
+
*/function (attr) { return !element_1.hasAttribute || !element_1.hasAttribute(attr); }));
|
|
2068
|
+
}
|
|
2049
2069
|
this.uiAttributes.forEach(( /**
|
|
2050
2070
|
* @param {?} attr
|
|
2051
2071
|
* @return {?}
|
|
@@ -2137,6 +2157,24 @@
|
|
|
2137
2157
|
this.to.blur(this.field, $event);
|
|
2138
2158
|
}
|
|
2139
2159
|
};
|
|
2160
|
+
// handle custom `change` event, for regular ones rely on DOM listener
|
|
2161
|
+
// handle custom `change` event, for regular ones rely on DOM listener
|
|
2162
|
+
/**
|
|
2163
|
+
* @param {?} $event
|
|
2164
|
+
* @return {?}
|
|
2165
|
+
*/
|
|
2166
|
+
FormlyAttributes.prototype.onHostChange =
|
|
2167
|
+
// handle custom `change` event, for regular ones rely on DOM listener
|
|
2168
|
+
/**
|
|
2169
|
+
* @param {?} $event
|
|
2170
|
+
* @return {?}
|
|
2171
|
+
*/
|
|
2172
|
+
function ($event) {
|
|
2173
|
+
if ($event instanceof Event) {
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
this.onChange($event);
|
|
2177
|
+
};
|
|
2140
2178
|
/**
|
|
2141
2179
|
* @param {?} $event
|
|
2142
2180
|
* @return {?}
|
|
@@ -2223,9 +2261,7 @@
|
|
|
2223
2261
|
{ type: i0.Directive, args: [{
|
|
2224
2262
|
selector: '[formlyAttributes]',
|
|
2225
2263
|
host: {
|
|
2226
|
-
'(
|
|
2227
|
-
'(blur)': 'onBlur($event)',
|
|
2228
|
-
'(change)': 'onChange($event)',
|
|
2264
|
+
'(change)': 'onHostChange($event)',
|
|
2229
2265
|
},
|
|
2230
2266
|
},] }
|
|
2231
2267
|
];
|
|
@@ -2719,9 +2755,7 @@
|
|
|
2719
2755
|
*/function (f, ignoreCache) {
|
|
2720
2756
|
if (!checkLocked) {
|
|
2721
2757
|
checkLocked = true;
|
|
2722
|
-
|
|
2723
|
-
* @return {?}
|
|
2724
|
-
*/function () { return _this.checkField(f, ignoreCache); }));
|
|
2758
|
+
_this.checkField(f, ignoreCache);
|
|
2725
2759
|
checkLocked = false;
|
|
2726
2760
|
}
|
|
2727
2761
|
});
|
|
@@ -3499,22 +3533,7 @@
|
|
|
3499
3533
|
if (field.parent) {
|
|
3500
3534
|
return;
|
|
3501
3535
|
}
|
|
3502
|
-
|
|
3503
|
-
var fieldsToUpdate = this.setValidators(field);
|
|
3504
|
-
if (fieldsToUpdate.length === 0) {
|
|
3505
|
-
return;
|
|
3506
|
-
}
|
|
3507
|
-
if (fieldsToUpdate.length === 1) {
|
|
3508
|
-
/** @type {?} */
|
|
3509
|
-
var control = fieldsToUpdate[0].formControl;
|
|
3510
|
-
while (control) {
|
|
3511
|
-
(( /** @type {?} */(control)))._updateTreeValidity({ onlySelf: true });
|
|
3512
|
-
control = control.parent;
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
else {
|
|
3516
|
-
(( /** @type {?} */(field.formControl)))._updateTreeValidity();
|
|
3517
|
-
}
|
|
3536
|
+
this.setValidators(field);
|
|
3518
3537
|
};
|
|
3519
3538
|
/**
|
|
3520
3539
|
* @private
|
|
@@ -3555,39 +3574,40 @@
|
|
|
3555
3574
|
/**
|
|
3556
3575
|
* @private
|
|
3557
3576
|
* @param {?} field
|
|
3577
|
+
* @param {?=} disabled
|
|
3558
3578
|
* @return {?}
|
|
3559
3579
|
*/
|
|
3560
3580
|
FieldFormExtension.prototype.setValidators = /**
|
|
3561
3581
|
* @private
|
|
3562
3582
|
* @param {?} field
|
|
3583
|
+
* @param {?=} disabled
|
|
3563
3584
|
* @return {?}
|
|
3564
3585
|
*/
|
|
3565
|
-
function (field) {
|
|
3586
|
+
function (field, disabled) {
|
|
3566
3587
|
var _this = this;
|
|
3588
|
+
if (disabled === void 0) {
|
|
3589
|
+
disabled = false;
|
|
3590
|
+
}
|
|
3567
3591
|
/** @type {?} */
|
|
3568
|
-
var
|
|
3592
|
+
var markForCheck = false;
|
|
3593
|
+
if (disabled === false && field.key && field.templateOptions && field.templateOptions.disabled) {
|
|
3594
|
+
disabled = true;
|
|
3595
|
+
}
|
|
3596
|
+
(field.fieldGroup || []).forEach(( /**
|
|
3597
|
+
* @param {?} f
|
|
3598
|
+
* @return {?}
|
|
3599
|
+
*/function (f) { return _this.setValidators(f, disabled) && (markForCheck = true); }));
|
|
3569
3600
|
if (field.key || !field.parent || (!field.key && !field.fieldGroup)) {
|
|
3570
3601
|
var c_1 = field.formControl;
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
if (field.key && c_1) {
|
|
3602
|
+
field.templateOptions = field.templateOptions || {};
|
|
3603
|
+
if (field.key && c_1 && c_1 instanceof forms.FormControl) {
|
|
3574
3604
|
if (disabled && c_1.enabled) {
|
|
3575
3605
|
c_1.disable({ emitEvent: false, onlySelf: true });
|
|
3576
|
-
|
|
3577
|
-
updateValidity(c_1);
|
|
3578
|
-
}
|
|
3579
|
-
else {
|
|
3580
|
-
updateValidity$$1 = true;
|
|
3581
|
-
}
|
|
3606
|
+
markForCheck = true;
|
|
3582
3607
|
}
|
|
3583
3608
|
if (!disabled && c_1.disabled) {
|
|
3584
3609
|
c_1.enable({ emitEvent: false, onlySelf: true });
|
|
3585
|
-
|
|
3586
|
-
updateValidity(c_1);
|
|
3587
|
-
}
|
|
3588
|
-
else {
|
|
3589
|
-
updateValidity$$1 = true;
|
|
3590
|
-
}
|
|
3610
|
+
markForCheck = true;
|
|
3591
3611
|
}
|
|
3592
3612
|
}
|
|
3593
3613
|
if (c_1 && (null === c_1.validator || null === c_1.asyncValidator)) {
|
|
@@ -3605,27 +3625,13 @@
|
|
|
3605
3625
|
var v = forms.Validators.composeAsync(_this.mergeValidators(field, '_asyncValidators'));
|
|
3606
3626
|
return v ? v(c_1) : rxjs.of(null);
|
|
3607
3627
|
}));
|
|
3608
|
-
|
|
3609
|
-
updateValidity(c_1);
|
|
3610
|
-
}
|
|
3611
|
-
else {
|
|
3612
|
-
updateValidity$$1 = true;
|
|
3613
|
-
}
|
|
3628
|
+
markForCheck = true;
|
|
3614
3629
|
}
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
var fieldsToUpdate = updateValidity$$1 ? [field] : [];
|
|
3618
|
-
(field.fieldGroup || []).forEach(( /**
|
|
3619
|
-
* @param {?} f
|
|
3620
|
-
* @return {?}
|
|
3621
|
-
*/function (f) {
|
|
3622
|
-
/** @type {?} */
|
|
3623
|
-
var childrenToUpdate = _this.setValidators(f);
|
|
3624
|
-
if (!updateValidity$$1) {
|
|
3625
|
-
fieldsToUpdate.push.apply(fieldsToUpdate, __spread(childrenToUpdate));
|
|
3630
|
+
if (markForCheck) {
|
|
3631
|
+
updateValidity(c_1, true);
|
|
3626
3632
|
}
|
|
3627
|
-
}
|
|
3628
|
-
return
|
|
3633
|
+
}
|
|
3634
|
+
return markForCheck;
|
|
3629
3635
|
};
|
|
3630
3636
|
/**
|
|
3631
3637
|
* @private
|