@ngx-formly/core 5.10.22 → 5.10.26

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 (31) hide show
  1. package/bundles/ngx-formly-core-json-schema.umd.js +12 -9
  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 +54 -24
  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 +13 -10
  10. package/esm2015/lib/components/formly.field.js +24 -2
  11. package/esm2015/lib/components/formly.form.js +2 -2
  12. package/esm2015/lib/extensions/field-expression/field-expression.js +29 -21
  13. package/esm2015/lib/extensions/field-form/field-form.js +3 -3
  14. package/esm2015/lib/utils.js +3 -1
  15. package/esm5/json-schema/formly-json-schema.service.js +13 -10
  16. package/esm5/lib/components/formly.field.js +24 -2
  17. package/esm5/lib/components/formly.form.js +2 -2
  18. package/esm5/lib/extensions/field-expression/field-expression.js +34 -21
  19. package/esm5/lib/extensions/field-form/field-form.js +3 -3
  20. package/esm5/lib/utils.js +3 -1
  21. package/fesm2015/ngx-formly-core-json-schema.js +12 -9
  22. package/fesm2015/ngx-formly-core-json-schema.js.map +1 -1
  23. package/fesm2015/ngx-formly-core.js +51 -25
  24. package/fesm2015/ngx-formly-core.js.map +1 -1
  25. package/fesm5/ngx-formly-core-json-schema.js +12 -9
  26. package/fesm5/ngx-formly-core-json-schema.js.map +1 -1
  27. package/fesm5/ngx-formly-core.js +56 -26
  28. package/fesm5/ngx-formly-core.js.map +1 -1
  29. package/lib/components/formly.field.d.ts +1 -0
  30. package/ngx-formly-core.metadata.json +1 -1
  31. 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
  })),
@@ -2856,11 +2874,13 @@
2856
2874
  */
2857
2875
  function (prop, expression, parentExpression) {
2858
2876
  return ( /**
2859
- * @param {?} model
2860
- * @param {?} formState
2861
- * @param {?} field
2877
+ * @param {...?} args
2862
2878
  * @return {?}
2863
- */function (model, formState, field) {
2879
+ */function () {
2880
+ var args = [];
2881
+ for (var _i = 0; _i < arguments.length; _i++) {
2882
+ args[_i] = arguments[_i];
2883
+ }
2864
2884
  try {
2865
2885
  if (typeof expression === 'string') {
2866
2886
  expression = evalStringExpression(expression, ['model', 'formState', 'field']);
@@ -2870,7 +2890,7 @@
2870
2890
  * @return {?}
2871
2891
  */function () { return !!expression; });
2872
2892
  }
2873
- return (parentExpression && parentExpression()) || expression(model, formState, field);
2893
+ return (parentExpression && parentExpression()) || expression.apply(void 0, __spread(args));
2874
2894
  }
2875
2895
  catch (error) {
2876
2896
  error.message = "[Formly Error] [Expression \"" + prop + "\"] " + error.message;
@@ -2895,7 +2915,8 @@
2895
2915
  if (ignoreCache === void 0) {
2896
2916
  ignoreCache = false;
2897
2917
  }
2898
- this._checkField(field, ignoreCache);
2918
+ /** @type {?} */
2919
+ var fieldChanged = this._checkField(field, ignoreCache);
2899
2920
  field.options._hiddenFieldsForCheck
2900
2921
  .sort(( /**
2901
2922
  * @param {?} f
@@ -2906,6 +2927,12 @@
2906
2927
  * @return {?}
2907
2928
  */function (f) { return _this.toggleFormControl(f, !!f.hide, !ignoreCache); }));
2908
2929
  field.options._hiddenFieldsForCheck = [];
2930
+ if (fieldChanged) {
2931
+ this.checkField(field);
2932
+ if (field.options && field.options._markForCheck) {
2933
+ field.options._markForCheck(field);
2934
+ }
2935
+ }
2909
2936
  };
2910
2937
  /**
2911
2938
  * @private
@@ -2925,23 +2952,24 @@
2925
2952
  ignoreCache = false;
2926
2953
  }
2927
2954
  /** @type {?} */
2928
- var markForCheck = false;
2955
+ var fieldChanged = false;
2929
2956
  field.fieldGroup.forEach(( /**
2930
2957
  * @param {?} f
2931
2958
  * @return {?}
2932
2959
  */function (f) {
2933
- _this.checkFieldExpressionChange(f, ignoreCache) && (markForCheck = true);
2960
+ if (!f.options) {
2961
+ return;
2962
+ }
2963
+ _this.checkFieldExpressionChange(f, ignoreCache) && (fieldChanged = true);
2934
2964
  if (_this.checkFieldVisibilityChange(f, ignoreCache)) {
2935
2965
  field.options._hiddenFieldsForCheck.push(f);
2936
- markForCheck = true;
2966
+ fieldChanged = true;
2937
2967
  }
2938
2968
  if (f.fieldGroup && f.fieldGroup.length > 0) {
2939
- _this._checkField(f, ignoreCache);
2969
+ _this._checkField(f, ignoreCache) && (fieldChanged = true);
2940
2970
  }
2941
2971
  }));
2942
- if (markForCheck && field.options && field.options._markForCheck) {
2943
- field.options._markForCheck(field);
2944
- }
2972
+ return fieldChanged;
2945
2973
  };
2946
2974
  /**
2947
2975
  * @private
@@ -2965,12 +2993,14 @@
2965
2993
  var expressionProperties = field._expressionProperties;
2966
2994
  for (var key in expressionProperties) {
2967
2995
  /** @type {?} */
2968
- var expressionValue = evalExpression(expressionProperties[key].expression, { field: field }, [field.model, field.options.formState, field]);
2996
+ var expressionValue = evalExpression(expressionProperties[key].expression, { field: field }, [field.model, field.options.formState, field, ignoreCache]);
2969
2997
  if (key === 'templateOptions.disabled') {
2970
2998
  expressionValue = !!expressionValue;
2971
2999
  }
2972
3000
  if (ignoreCache || (expressionProperties[key].expressionValue !== expressionValue
2973
- && (!isObject(expressionValue)
3001
+ && (!(isObject(expressionValue) || isFunction(expressionValue))
3002
+ || (isFunction(expressionValue)
3003
+ && ('' + expressionProperties[key].expressionValue !== '' + expressionValue))
2974
3004
  || rxjs.isObservable(expressionValue)
2975
3005
  || JSON.stringify(expressionValue) !== JSON.stringify(expressionProperties[key].expressionValue)))) {
2976
3006
  markForCheck = true;
@@ -2997,7 +3027,7 @@
2997
3027
  return false;
2998
3028
  }
2999
3029
  /** @type {?} */
3000
- var hideExpressionResult = !!evalExpression(field.hideExpression, { field: field }, [field.model, field.options.formState, field]);
3030
+ var hideExpressionResult = !!evalExpression(field.hideExpression, { field: field }, [field.model, field.options.formState, field, ignoreCache]);
3001
3031
  /** @type {?} */
3002
3032
  var markForCheck = false;
3003
3033
  if (hideExpressionResult !== field.hide || ignoreCache) {
@@ -3057,13 +3087,13 @@
3057
3087
  defineHiddenProp(field, '_hide', !!(hide || field.hide));
3058
3088
  /** @type {?} */
3059
3089
  var c = field.formControl;
3060
- if (c['_fields'].length > 1) {
3090
+ if (c['_fields'] && c['_fields'].length > 1) {
3061
3091
  updateValidity(c);
3062
3092
  }
3063
- if (hide === true && c['_fields'].every(( /**
3093
+ if (hide === true && (!c['_fields'] || c['_fields'].every(( /**
3064
3094
  * @param {?} f
3065
3095
  * @return {?}
3066
- */function (f) { return !!f._hide; }))) {
3096
+ */function (f) { return !!f._hide; })))) {
3067
3097
  unregisterControl(field, true);
3068
3098
  if (resetOnHide && field.resetOnHide) {
3069
3099
  field.formControl.reset({ value: undefined, disabled: field.formControl.disabled });
@@ -3150,7 +3180,7 @@
3150
3180
  if (control
3151
3181
  && !(isNullOrUndefined(control.value) && isNullOrUndefined(value))
3152
3182
  && control.value !== value) {
3153
- control.patchValue(value, { emitEvent: false });
3183
+ control.patchValue(value);
3154
3184
  }
3155
3185
  }
3156
3186
  this.emitExpressionChanges(field, prop, value);
@@ -3561,7 +3591,7 @@
3561
3591
  var c_1 = field.formControl;
3562
3592
  /** @type {?} */
3563
3593
  var disabled = field.templateOptions ? field.templateOptions.disabled : false;
3564
- if (field.key) {
3594
+ if (field.key && c_1) {
3565
3595
  if (disabled && c_1.enabled) {
3566
3596
  c_1.disable({ emitEvent: false, onlySelf: true });
3567
3597
  if (!c_1.parent) {
@@ -3581,7 +3611,7 @@
3581
3611
  }
3582
3612
  }
3583
3613
  }
3584
- if (null === c_1.validator || null === c_1.asyncValidator) {
3614
+ if (c_1 && (null === c_1.validator || null === c_1.asyncValidator)) {
3585
3615
  c_1.setValidators(( /**
3586
3616
  * @return {?}
3587
3617
  */function () {