@ngx-formly/core 5.10.23 → 5.10.27

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.
@@ -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;
@@ -1006,13 +1007,18 @@
1006
1007
  emitEvent = false;
1007
1008
  }
1008
1009
  /** @type {?} */
1009
- var form = ( /** @type {?} */(field.formControl.parent));
1010
+ var control = field.formControl;
1011
+ /** @type {?} */
1012
+ var fieldIndex = control['_fields'] ? control['_fields'].indexOf(field) : -1;
1013
+ if (fieldIndex !== -1) {
1014
+ control['_fields'].splice(fieldIndex, 1);
1015
+ }
1016
+ /** @type {?} */
1017
+ var form = ( /** @type {?} */(control.parent));
1010
1018
  if (!form) {
1011
1019
  return;
1012
1020
  }
1013
1021
  /** @type {?} */
1014
- var control = field.formControl;
1015
- /** @type {?} */
1016
1022
  var opts = { emitEvent: emitEvent };
1017
1023
  if (form instanceof forms.FormArray) {
1018
1024
  /** @type {?} */
@@ -1191,6 +1197,8 @@
1191
1197
  */
1192
1198
  function clearControl(form) {
1193
1199
  form['_fields'] && delete form['_fields'];
1200
+ form.setValidators(null);
1201
+ form.setAsyncValidators(null);
1194
1202
  if (form instanceof forms.FormGroup || form instanceof forms.FormArray) {
1195
1203
  Object.keys(form.controls)
1196
1204
  .forEach(( /**
@@ -1857,9 +1865,15 @@
1857
1865
  else {
1858
1866
  if (currentValue) {
1859
1867
  _this.containerRef.clear();
1868
+ if (_this.field.className) {
1869
+ _this.renderer.removeAttribute(_this.elementRef.nativeElement, 'class');
1870
+ }
1860
1871
  }
1861
1872
  else {
1862
1873
  _this.renderField(_this.containerRef, _this.field);
1874
+ if (_this.field.className) {
1875
+ _this.renderer.setAttribute(_this.elementRef.nativeElement, 'class', _this.field.className);
1876
+ }
1863
1877
  }
1864
1878
  }
1865
1879
  })),
@@ -1868,7 +1882,8 @@
1868
1882
  * @return {?}
1869
1883
  */function (_a) {
1870
1884
  var firstChange = _a.firstChange, currentValue = _a.currentValue;
1871
- if (!firstChange || (firstChange && currentValue)) {
1885
+ if ((!firstChange || (firstChange && currentValue))
1886
+ && (!_this.formlyConfig.extras.lazyRender || (_this.field.hide !== true))) {
1872
1887
  _this.renderer.setAttribute(_this.elementRef.nativeElement, 'class', currentValue);
1873
1888
  }
1874
1889
  })),
@@ -2866,11 +2881,13 @@
2866
2881
  */
2867
2882
  function (prop, expression, parentExpression) {
2868
2883
  return ( /**
2869
- * @param {?} model
2870
- * @param {?} formState
2871
- * @param {?} field
2884
+ * @param {...?} args
2872
2885
  * @return {?}
2873
- */function (model, formState, field) {
2886
+ */function () {
2887
+ var args = [];
2888
+ for (var _i = 0; _i < arguments.length; _i++) {
2889
+ args[_i] = arguments[_i];
2890
+ }
2874
2891
  try {
2875
2892
  if (typeof expression === 'string') {
2876
2893
  expression = evalStringExpression(expression, ['model', 'formState', 'field']);
@@ -2880,7 +2897,7 @@
2880
2897
  * @return {?}
2881
2898
  */function () { return !!expression; });
2882
2899
  }
2883
- return (parentExpression && parentExpression()) || expression(model, formState, field);
2900
+ return (parentExpression && parentExpression()) || expression.apply(void 0, __spread(args));
2884
2901
  }
2885
2902
  catch (error) {
2886
2903
  error.message = "[Formly Error] [Expression \"" + prop + "\"] " + error.message;
@@ -2983,12 +3000,14 @@
2983
3000
  var expressionProperties = field._expressionProperties;
2984
3001
  for (var key in expressionProperties) {
2985
3002
  /** @type {?} */
2986
- var expressionValue = evalExpression(expressionProperties[key].expression, { field: field }, [field.model, field.options.formState, field]);
3003
+ var expressionValue = evalExpression(expressionProperties[key].expression, { field: field }, [field.model, field.options.formState, field, ignoreCache]);
2987
3004
  if (key === 'templateOptions.disabled') {
2988
3005
  expressionValue = !!expressionValue;
2989
3006
  }
2990
3007
  if (ignoreCache || (expressionProperties[key].expressionValue !== expressionValue
2991
- && (!isObject(expressionValue)
3008
+ && (!(isObject(expressionValue) || isFunction(expressionValue))
3009
+ || (isFunction(expressionValue)
3010
+ && ('' + expressionProperties[key].expressionValue !== '' + expressionValue))
2992
3011
  || rxjs.isObservable(expressionValue)
2993
3012
  || JSON.stringify(expressionValue) !== JSON.stringify(expressionProperties[key].expressionValue)))) {
2994
3013
  markForCheck = true;
@@ -3015,7 +3034,7 @@
3015
3034
  return false;
3016
3035
  }
3017
3036
  /** @type {?} */
3018
- var hideExpressionResult = !!evalExpression(field.hideExpression, { field: field }, [field.model, field.options.formState, field]);
3037
+ var hideExpressionResult = !!evalExpression(field.hideExpression, { field: field }, [field.model, field.options.formState, field, ignoreCache]);
3019
3038
  /** @type {?} */
3020
3039
  var markForCheck = false;
3021
3040
  if (hideExpressionResult !== field.hide || ignoreCache) {
@@ -3071,6 +3090,17 @@
3071
3090
  */
3072
3091
  function (field, hide, resetOnHide) {
3073
3092
  var _this = this;
3093
+ if (field.fieldGroup) {
3094
+ field.fieldGroup
3095
+ .filter(( /**
3096
+ * @param {?} f
3097
+ * @return {?}
3098
+ */function (f) { return !f.hideExpression; }))
3099
+ .forEach(( /**
3100
+ * @param {?} f
3101
+ * @return {?}
3102
+ */function (f) { return _this.toggleFormControl(f, hide, resetOnHide); }));
3103
+ }
3074
3104
  if (field.formControl && field.key) {
3075
3105
  defineHiddenProp(field, '_hide', !!(hide || field.hide));
3076
3106
  /** @type {?} */
@@ -3103,17 +3133,6 @@
3103
3133
  }
3104
3134
  }
3105
3135
  }
3106
- if (field.fieldGroup) {
3107
- field.fieldGroup
3108
- .filter(( /**
3109
- * @param {?} f
3110
- * @return {?}
3111
- */function (f) { return !f.hideExpression; }))
3112
- .forEach(( /**
3113
- * @param {?} f
3114
- * @return {?}
3115
- */function (f) { return _this.toggleFormControl(f, hide, resetOnHide); }));
3116
- }
3117
3136
  if (field.options.fieldChanges) {
3118
3137
  field.options.fieldChanges.next(( /** @type {?} */({ field: field, type: 'hidden', value: hide })));
3119
3138
  }