@ngx-formly/core 5.10.21 → 5.10.25

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 (33) hide show
  1. package/bundles/ngx-formly-core-json-schema.umd.js +15 -13
  2. package/bundles/ngx-formly-core-json-schema.umd.js.map +1 -1
  3. package/bundles/ngx-formly-core-json-schema.umd.min.js +1 -1
  4. package/bundles/ngx-formly-core-json-schema.umd.min.js.map +1 -1
  5. package/bundles/ngx-formly-core.umd.js +77 -34
  6. package/bundles/ngx-formly-core.umd.js.map +1 -1
  7. package/bundles/ngx-formly-core.umd.min.js +1 -1
  8. package/bundles/ngx-formly-core.umd.min.js.map +1 -1
  9. package/esm2015/json-schema/formly-json-schema.service.js +16 -14
  10. package/esm2015/lib/components/formly.attributes.js +8 -3
  11. package/esm2015/lib/components/formly.field.js +24 -2
  12. package/esm2015/lib/components/formly.form.js +2 -2
  13. package/esm2015/lib/extensions/field-expression/field-expression.js +35 -16
  14. package/esm2015/lib/extensions/field-form/field-form.js +19 -17
  15. package/esm2015/lib/utils.js +3 -1
  16. package/esm5/json-schema/formly-json-schema.service.js +16 -14
  17. package/esm5/lib/components/formly.attributes.js +8 -3
  18. package/esm5/lib/components/formly.field.js +24 -2
  19. package/esm5/lib/components/formly.form.js +2 -2
  20. package/esm5/lib/extensions/field-expression/field-expression.js +35 -16
  21. package/esm5/lib/extensions/field-form/field-form.js +19 -17
  22. package/esm5/lib/utils.js +3 -1
  23. package/fesm2015/ngx-formly-core-json-schema.js +15 -13
  24. package/fesm2015/ngx-formly-core-json-schema.js.map +1 -1
  25. package/fesm2015/ngx-formly-core.js +79 -35
  26. package/fesm2015/ngx-formly-core.js.map +1 -1
  27. package/fesm5/ngx-formly-core-json-schema.js +15 -13
  28. package/fesm5/ngx-formly-core-json-schema.js.map +1 -1
  29. package/fesm5/ngx-formly-core.js +79 -35
  30. package/fesm5/ngx-formly-core.js.map +1 -1
  31. package/lib/components/formly.field.d.ts +1 -0
  32. package/ngx-formly-core.metadata.json +1 -1
  33. package/package.json +1 -1
@@ -350,6 +350,7 @@
350
350
  function clone(value) {
351
351
  if (!isObject(value)
352
352
  || rxjs.isObservable(value)
353
+ || (value instanceof i0.TemplateRef)
353
354
  || /* instanceof SafeHtmlImpl */ value.changingThisBreaksApplicationSecurity
354
355
  || ['RegExp', 'FileList', 'File', 'Blob'].indexOf(value.constructor.name) !== -1) {
355
356
  return value;
@@ -1473,7 +1474,7 @@
1473
1474
  * @param {?} field
1474
1475
  * @return {?}
1475
1476
  */function (field) {
1476
- if (field.key && !field.fieldGroup) {
1477
+ if (field.key && !field.fieldGroup && field.formControl) {
1477
1478
  /** @type {?} */
1478
1479
  var control_1 = field.formControl;
1479
1480
  /** @type {?} */
@@ -1589,6 +1590,7 @@
1589
1590
  this.hostObservers = [];
1590
1591
  this.componentRefs = [];
1591
1592
  this.hooksObservers = [];
1593
+ this.detectFieldBuild = false;
1592
1594
  this.warnDeprecation = hideDeprecation === null;
1593
1595
  }
1594
1596
  Object.defineProperty(FormlyField.prototype, "model", {
@@ -1665,6 +1667,9 @@
1665
1667
  */
1666
1668
  function () {
1667
1669
  this.triggerHook('doCheck');
1670
+ if (this.detectFieldBuild && (this.field && this.field.options)) {
1671
+ this.render();
1672
+ }
1668
1673
  };
1669
1674
  /**
1670
1675
  * @return {?}
@@ -1828,6 +1833,12 @@
1828
1833
  if (!this.field) {
1829
1834
  return;
1830
1835
  }
1836
+ // require Formly build
1837
+ if (!this.field.options) {
1838
+ this.detectFieldBuild = true;
1839
+ return;
1840
+ }
1841
+ this.detectFieldBuild = false;
1831
1842
  this.hostObservers.forEach(( /**
1832
1843
  * @param {?} unsubscribe
1833
1844
  * @return {?}
@@ -1847,9 +1858,15 @@
1847
1858
  else {
1848
1859
  if (currentValue) {
1849
1860
  _this.containerRef.clear();
1861
+ if (_this.field.className) {
1862
+ _this.renderer.removeAttribute(_this.elementRef.nativeElement, 'class');
1863
+ }
1850
1864
  }
1851
1865
  else {
1852
1866
  _this.renderField(_this.containerRef, _this.field);
1867
+ if (_this.field.className) {
1868
+ _this.renderer.setAttribute(_this.elementRef.nativeElement, 'class', _this.field.className);
1869
+ }
1853
1870
  }
1854
1871
  }
1855
1872
  })),
@@ -1858,7 +1875,8 @@
1858
1875
  * @return {?}
1859
1876
  */function (_a) {
1860
1877
  var firstChange = _a.firstChange, currentValue = _a.currentValue;
1861
- if (!firstChange || (firstChange && currentValue)) {
1878
+ if ((!firstChange || (firstChange && currentValue))
1879
+ && (!_this.formlyConfig.extras.lazyRender || (_this.field.hide !== true))) {
1862
1880
  _this.renderer.setAttribute(_this.elementRef.nativeElement, 'class', currentValue);
1863
1881
  }
1864
1882
  })),
@@ -2006,7 +2024,11 @@
2006
2024
  Object.keys(currentValue).forEach(( /**
2007
2025
  * @param {?} attr
2008
2026
  * @return {?}
2009
- */function (attr) { return _this.setAttribute(attr, currentValue[attr]); }));
2027
+ */function (attr) {
2028
+ if (currentValue[attr] != null) {
2029
+ _this.setAttribute(attr, currentValue[attr]);
2030
+ }
2031
+ }));
2010
2032
  }
2011
2033
  }));
2012
2034
  }
@@ -2061,7 +2083,8 @@
2061
2083
  */function (attr) {
2062
2084
  /** @type {?} */
2063
2085
  var value = _this.to[attr];
2064
- if (_this.uiAttributesCache[attr] !== value) {
2086
+ if (_this.uiAttributesCache[attr] !== value
2087
+ && (!_this.to.attributes || !_this.to.attributes.hasOwnProperty(attr.toLowerCase()))) {
2065
2088
  _this.uiAttributesCache[attr] = value;
2066
2089
  if (value || value === 0) {
2067
2090
  _this.setAttribute(attr, value === true ? attr : "" + value);
@@ -2890,7 +2913,8 @@
2890
2913
  if (ignoreCache === void 0) {
2891
2914
  ignoreCache = false;
2892
2915
  }
2893
- this._checkField(field, ignoreCache);
2916
+ /** @type {?} */
2917
+ var fieldChanged = this._checkField(field, ignoreCache);
2894
2918
  field.options._hiddenFieldsForCheck
2895
2919
  .sort(( /**
2896
2920
  * @param {?} f
@@ -2901,6 +2925,12 @@
2901
2925
  * @return {?}
2902
2926
  */function (f) { return _this.toggleFormControl(f, !!f.hide, !ignoreCache); }));
2903
2927
  field.options._hiddenFieldsForCheck = [];
2928
+ if (fieldChanged) {
2929
+ this.checkField(field);
2930
+ if (field.options && field.options._markForCheck) {
2931
+ field.options._markForCheck(field);
2932
+ }
2933
+ }
2904
2934
  };
2905
2935
  /**
2906
2936
  * @private
@@ -2920,23 +2950,24 @@
2920
2950
  ignoreCache = false;
2921
2951
  }
2922
2952
  /** @type {?} */
2923
- var markForCheck = false;
2953
+ var fieldChanged = false;
2924
2954
  field.fieldGroup.forEach(( /**
2925
2955
  * @param {?} f
2926
2956
  * @return {?}
2927
2957
  */function (f) {
2928
- _this.checkFieldExpressionChange(f, ignoreCache) && (markForCheck = true);
2958
+ if (!f.options) {
2959
+ return;
2960
+ }
2961
+ _this.checkFieldExpressionChange(f, ignoreCache) && (fieldChanged = true);
2929
2962
  if (_this.checkFieldVisibilityChange(f, ignoreCache)) {
2930
2963
  field.options._hiddenFieldsForCheck.push(f);
2931
- markForCheck = true;
2964
+ fieldChanged = true;
2932
2965
  }
2933
2966
  if (f.fieldGroup && f.fieldGroup.length > 0) {
2934
- _this._checkField(f, ignoreCache);
2967
+ _this._checkField(f, ignoreCache) && (fieldChanged = true);
2935
2968
  }
2936
2969
  }));
2937
- if (markForCheck && field.options && field.options._markForCheck) {
2938
- field.options._markForCheck(field);
2939
- }
2970
+ return fieldChanged;
2940
2971
  };
2941
2972
  /**
2942
2973
  * @private
@@ -2965,7 +2996,9 @@
2965
2996
  expressionValue = !!expressionValue;
2966
2997
  }
2967
2998
  if (ignoreCache || (expressionProperties[key].expressionValue !== expressionValue
2968
- && (!isObject(expressionValue) || JSON.stringify(expressionValue) !== JSON.stringify(expressionProperties[key].expressionValue)))) {
2999
+ && (!isObject(expressionValue)
3000
+ || rxjs.isObservable(expressionValue)
3001
+ || JSON.stringify(expressionValue) !== JSON.stringify(expressionProperties[key].expressionValue)))) {
2969
3002
  markForCheck = true;
2970
3003
  expressionProperties[key].expressionValue = expressionValue;
2971
3004
  this.setExprValue(field, key, expressionValue);
@@ -3050,13 +3083,13 @@
3050
3083
  defineHiddenProp(field, '_hide', !!(hide || field.hide));
3051
3084
  /** @type {?} */
3052
3085
  var c = field.formControl;
3053
- if (c['_fields'].length > 1) {
3086
+ if (c['_fields'] && c['_fields'].length > 1) {
3054
3087
  updateValidity(c);
3055
3088
  }
3056
- if (hide === true && c['_fields'].every(( /**
3089
+ if (hide === true && (!c['_fields'] || c['_fields'].every(( /**
3057
3090
  * @param {?} f
3058
3091
  * @return {?}
3059
- */function (f) { return !!f._hide; }))) {
3092
+ */function (f) { return !!f._hide; })))) {
3060
3093
  unregisterControl(field, true);
3061
3094
  if (resetOnHide && field.resetOnHide) {
3062
3095
  field.formControl.reset({ value: undefined, disabled: field.formControl.disabled });
@@ -3112,7 +3145,15 @@
3112
3145
  /** @type {?} */
3113
3146
  var target = field;
3114
3147
  /** @type {?} */
3115
- var paths = (prop.indexOf('[') === -1 ? prop : prop.replace(/\[(\w+)\]/g, '.$1')).split('.');
3148
+ var paths = prop.indexOf('[') === -1
3149
+ ? prop.split('.')
3150
+ : prop
3151
+ .replace(/\'|\"/g, '')
3152
+ .split(/[[\]]{1,2}/) // https://stackoverflow.com/a/20198206
3153
+ .filter(( /**
3154
+ * @param {?} v
3155
+ * @return {?}
3156
+ */function (v) { return v; }));
3116
3157
  /** @type {?} */
3117
3158
  var lastIndex = paths.length - 1;
3118
3159
  for (var i = 0; i < lastIndex; i++) {
@@ -3135,7 +3176,7 @@
3135
3176
  if (control
3136
3177
  && !(isNullOrUndefined(control.value) && isNullOrUndefined(value))
3137
3178
  && control.value !== value) {
3138
- control.patchValue(value, { emitEvent: false });
3179
+ control.patchValue(value);
3139
3180
  }
3140
3181
  }
3141
3182
  this.emitExpressionChanges(field, prop, value);
@@ -3546,25 +3587,27 @@
3546
3587
  var c_1 = field.formControl;
3547
3588
  /** @type {?} */
3548
3589
  var disabled = field.templateOptions ? field.templateOptions.disabled : false;
3549
- if (disabled && c_1.enabled) {
3550
- c_1.disable({ emitEvent: false, onlySelf: true });
3551
- if (!c_1.parent) {
3552
- updateValidity(c_1);
3553
- }
3554
- else {
3555
- updateValidity$$1 = true;
3556
- }
3557
- }
3558
- if (!disabled && c_1.disabled) {
3559
- c_1.enable({ emitEvent: false, onlySelf: true });
3560
- if (!c_1.parent) {
3561
- updateValidity(c_1);
3590
+ if (field.key && c_1) {
3591
+ if (disabled && c_1.enabled) {
3592
+ c_1.disable({ emitEvent: false, onlySelf: true });
3593
+ if (!c_1.parent) {
3594
+ updateValidity(c_1);
3595
+ }
3596
+ else {
3597
+ updateValidity$$1 = true;
3598
+ }
3562
3599
  }
3563
- else {
3564
- updateValidity$$1 = true;
3600
+ if (!disabled && c_1.disabled) {
3601
+ c_1.enable({ emitEvent: false, onlySelf: true });
3602
+ if (!c_1.parent) {
3603
+ updateValidity(c_1);
3604
+ }
3605
+ else {
3606
+ updateValidity$$1 = true;
3607
+ }
3565
3608
  }
3566
3609
  }
3567
- if (null === c_1.validator || null === c_1.asyncValidator) {
3610
+ if (c_1 && (null === c_1.validator || null === c_1.asyncValidator)) {
3568
3611
  c_1.setValidators(( /**
3569
3612
  * @return {?}
3570
3613
  */function () {