@ngx-formly/core 6.3.9 → 6.3.11

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.
@@ -131,11 +131,12 @@ function isPromise(obj) {
131
131
  return !!obj && typeof obj.then === 'function';
132
132
  }
133
133
  function clone(value) {
134
+ var _a;
134
135
  if (!isObject(value) ||
135
136
  isObservable(value) ||
136
137
  value instanceof TemplateRef ||
137
138
  /* instanceof SafeHtmlImpl */ value.changingThisBreaksApplicationSecurity ||
138
- ['RegExp', 'FileList', 'File', 'Blob'].indexOf(value.constructor.name) !== -1) {
139
+ ['RegExp', 'FileList', 'File', 'Blob'].indexOf((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) !== -1) {
139
140
  return value;
140
141
  }
141
142
  if (value instanceof Set) {
@@ -567,7 +568,7 @@ class FormlyFormBuilder {
567
568
  if (field.parent && isHiddenField(field)) {
568
569
  // when hide is used in expression set defaul value will not be set until detect hide changes
569
570
  // which causes default value not set on new item is added
570
- (_a = options._hiddenFieldsForCheck) === null || _a === void 0 ? void 0 : _a.push(field);
571
+ (_a = options._hiddenFieldsForCheck) === null || _a === void 0 ? void 0 : _a.push({ field, default: false });
571
572
  }
572
573
  (_b = options.checkExpressions) === null || _b === void 0 ? void 0 : _b.call(options, field, true);
573
574
  (_c = options._detectChanges) === null || _c === void 0 ? void 0 : _c.call(options, field);
@@ -1127,16 +1128,15 @@ class FormlyForm {
1127
1128
  }
1128
1129
  });
1129
1130
  }
1130
- let fieldChangesDetection = [];
1131
+ let fieldChangesDetection = [
1132
+ observeDeep(this.field.options, ['formState'], () => this.field.options.detectChanges(this.field)),
1133
+ ];
1131
1134
  const valueChanges = this.field.options.fieldChanges
1132
1135
  .pipe(filter(({ field, type }) => hasKey(field) && type === 'valueChanges'), switchMap(() => (isNoopNgZone(this.ngZone) ? of(null) : this.ngZone.onStable.asObservable().pipe(take(1)))))
1133
1136
  .subscribe(() => this.ngZone.runGuarded(() => {
1134
1137
  // runGuarded is used to keep in sync the expression changes
1135
1138
  // https://github.com/ngx-formly/ngx-formly/issues/2095
1136
1139
  this.checkExpressionChange();
1137
- if (this.field.options) {
1138
- fieldChangesDetection.push(observeDeep(this.field.options, ['formState'], () => this.field.options.detectChanges(this.field)));
1139
- }
1140
1140
  this.modelChange.emit((this._modelChangeValue = clone(this.model)));
1141
1141
  }));
1142
1142
  return () => {
@@ -1583,7 +1583,7 @@ class FieldArrayType extends FieldType {
1583
1583
  }
1584
1584
  (_a = f.fieldGroup) === null || _a === void 0 ? void 0 : _a.forEach((c) => this.markFieldForCheck(c));
1585
1585
  if (f.hide === false) {
1586
- this.options._hiddenFieldsForCheck.push(f);
1586
+ this.options._hiddenFieldsForCheck.push({ field: f });
1587
1587
  }
1588
1588
  }
1589
1589
  }
@@ -1669,7 +1669,7 @@ class FieldExpressionExtension {
1669
1669
  defineHiddenProp(field, '_hide', !!currentValue);
1670
1670
  if (!firstChange || (firstChange && currentValue === true)) {
1671
1671
  field.props.hidden = currentValue;
1672
- field.options._hiddenFieldsForCheck.push(field);
1672
+ field.options._hiddenFieldsForCheck.push({ field });
1673
1673
  }
1674
1674
  });
1675
1675
  if (field.hideExpression) {
@@ -1715,8 +1715,8 @@ class FieldExpressionExtension {
1715
1715
  const fieldChanged = this.checkExpressions(f, ignoreCache);
1716
1716
  const options = field.options;
1717
1717
  options._hiddenFieldsForCheck
1718
- .sort((f) => (f.hide ? -1 : 1))
1719
- .forEach((f) => this.changeHideState(f, f.hide, !ignoreCache));
1718
+ .sort((f) => (f.field.hide ? -1 : 1))
1719
+ .forEach((f) => { var _a; return this.changeHideState(f.field, (_a = f.field.hide) !== null && _a !== void 0 ? _a : f.default, !ignoreCache); });
1720
1720
  options._hiddenFieldsForCheck = [];
1721
1721
  if (fieldChanged) {
1722
1722
  this.checkExpressions(field);