@ngx-formly/core 5.10.30 → 5.10.31

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.
@@ -10,6 +10,21 @@ import { __extends, __assign, __spread, __rest, __values, __read } from 'tslib';
10
10
  * @fileoverview added by tsickle
11
11
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
12
12
  */
13
+ /**
14
+ * @param {?} form
15
+ * @param {?} callback
16
+ * @return {?}
17
+ */
18
+ function disableTreeValidityCall(form, callback) {
19
+ /** @type {?} */
20
+ var _updateTreeValidity = form._updateTreeValidity.bind(form);
21
+ form._updateTreeValidity = (/**
22
+ * @return {?}
23
+ */
24
+ function () { });
25
+ callback();
26
+ form._updateTreeValidity = _updateTreeValidity;
27
+ }
13
28
  /**
14
29
  * @param {?} formId
15
30
  * @param {?} field
@@ -712,13 +727,17 @@ var FormlyFormBuilder = /** @class */ (function () {
712
727
  * @return {?}
713
728
  */
714
729
  function (formControl, fieldGroup, model, options) {
730
+ var _this = this;
715
731
  if (fieldGroup === void 0) { fieldGroup = []; }
716
732
  if (!this.formlyConfig.extensions.core) {
717
733
  throw new Error('NgxFormly: missing `forRoot()` call. use `forRoot()` when registering the `FormlyModule`.');
718
734
  }
719
735
  /** @type {?} */
720
736
  var field = { fieldGroup: fieldGroup, model: model, formControl: formControl, options: this._setOptions(options) };
721
- this._buildForm(field);
737
+ disableTreeValidityCall(formControl, (/**
738
+ * @return {?}
739
+ */
740
+ function () { return _this._buildForm(field); }));
722
741
  field.options._checkField(field, true);
723
742
  };
724
743
  /**
@@ -1841,16 +1860,11 @@ var FormlyField = /** @class */ (function () {
1841
1860
  */
1842
1861
  var FormlyAttributes = /** @class */ (function () {
1843
1862
  function FormlyAttributes(renderer, elementRef, _document) {
1863
+ var _this = this;
1844
1864
  this.renderer = renderer;
1845
1865
  this.elementRef = elementRef;
1846
1866
  this.uiAttributesCache = {};
1847
- this.uiAttributes = __spread(FORMLY_VALIDATORS, [
1848
- 'tabindex',
1849
- 'placeholder',
1850
- 'readonly',
1851
- 'disabled',
1852
- 'step',
1853
- ]);
1867
+ this.uiAttributes = null;
1854
1868
  /**
1855
1869
  * HostBinding doesn't register listeners conditionally which may produce some perf issues.
1856
1870
  *
@@ -1858,12 +1872,24 @@ var FormlyAttributes = /** @class */ (function () {
1858
1872
  */
1859
1873
  this.uiEvents = {
1860
1874
  listeners: [],
1861
- events: [
1862
- 'click',
1863
- 'keyup',
1864
- 'keydown',
1865
- 'keypress',
1866
- ],
1875
+ events: ['click', 'keyup', 'keydown', 'keypress', 'focus', 'blur', 'change'],
1876
+ callback: (/**
1877
+ * @param {?} eventName
1878
+ * @param {?} $event
1879
+ * @return {?}
1880
+ */
1881
+ function (eventName, $event) {
1882
+ switch (eventName) {
1883
+ case 'focus':
1884
+ return _this.onFocus($event);
1885
+ case 'blur':
1886
+ return _this.onBlur($event);
1887
+ case 'change':
1888
+ return _this.onChange($event);
1889
+ default:
1890
+ return _this.to[eventName](_this.field, $event);
1891
+ }
1892
+ }),
1867
1893
  };
1868
1894
  this.document = _document;
1869
1895
  }
@@ -1906,12 +1932,12 @@ var FormlyAttributes = /** @class */ (function () {
1906
1932
  * @return {?}
1907
1933
  */
1908
1934
  function (eventName) {
1909
- if (_this.to && _this.to[eventName]) {
1935
+ if ((_this.to && _this.to[eventName]) || ['focus', 'blur', 'change'].indexOf(eventName) !== -1) {
1910
1936
  _this.uiEvents.listeners.push(_this.renderer.listen(_this.elementRef.nativeElement, eventName, (/**
1911
1937
  * @param {?} e
1912
1938
  * @return {?}
1913
1939
  */
1914
- function (e) { return _this.to[eventName](_this.field, e); })));
1940
+ function (e) { return _this.uiEvents.callback(eventName, e); })));
1915
1941
  }
1916
1942
  }));
1917
1943
  if (this.to && this.to.attributes) {
@@ -1987,6 +2013,15 @@ var FormlyAttributes = /** @class */ (function () {
1987
2013
  */
1988
2014
  function () {
1989
2015
  var _this = this;
2016
+ if (!this.uiAttributes) {
2017
+ /** @type {?} */
2018
+ var element_1 = (/** @type {?} */ (this.elementRef.nativeElement));
2019
+ this.uiAttributes = __spread(FORMLY_VALIDATORS, ['tabindex', 'placeholder', 'readonly', 'disabled', 'step']).filter((/**
2020
+ * @param {?} attr
2021
+ * @return {?}
2022
+ */
2023
+ function (attr) { return !element_1.hasAttribute || !element_1.hasAttribute(attr); }));
2024
+ }
1990
2025
  this.uiAttributes.forEach((/**
1991
2026
  * @param {?} attr
1992
2027
  * @return {?}
@@ -2166,11 +2201,6 @@ var FormlyAttributes = /** @class */ (function () {
2166
2201
  FormlyAttributes.decorators = [
2167
2202
  { type: Directive, args: [{
2168
2203
  selector: '[formlyAttributes]',
2169
- host: {
2170
- '(focus)': 'onFocus($event)',
2171
- '(blur)': 'onBlur($event)',
2172
- '(change)': 'onChange($event)',
2173
- },
2174
2204
  },] }
2175
2205
  ];
2176
2206
  /** @nocollapse */