@ngx-formly/core 6.3.3 → 6.3.5

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.
@@ -3,9 +3,9 @@ import { Type, TemplateRef, ComponentRef, ChangeDetectorRef, ɵNoopNgZone, Injec
3
3
  import * as i2 from '@angular/forms';
4
4
  import { AbstractControl, FormGroup, FormArray, FormControl, NgControl, Validators } from '@angular/forms';
5
5
  import { isObservable, of, merge, Observable, Subject } from 'rxjs';
6
- import { distinctUntilChanged, startWith, debounceTime, filter, switchMap, take, tap, map } from 'rxjs/operators';
6
+ import { distinctUntilChanged, map, startWith, debounceTime, filter, switchMap, take, tap } from 'rxjs/operators';
7
7
  import * as i2$1 from '@angular/common';
8
- import { DOCUMENT, CommonModule } from '@angular/common';
8
+ import { VERSION, DOCUMENT, CommonModule } from '@angular/common';
9
9
  import * as i1 from '@angular/platform-browser';
10
10
  import { __rest } from 'tslib';
11
11
 
@@ -915,8 +915,17 @@ class FormlyField {
915
915
  this.elementRef && this.renderer.setAttribute(this.elementRef.nativeElement, 'class', currentValue);
916
916
  }
917
917
  }),
918
- ...['touched', 'pristine', 'status'].map((prop) => observe(this.field, ['formControl', prop], ({ firstChange }) => !firstChange && markFieldForCheck(this.field))),
919
918
  ];
919
+ const isSignalRequired = +VERSION.major >= 18 && +VERSION.minor >= 1;
920
+ if (!isSignalRequired) {
921
+ ['touched', 'pristine', 'status'].forEach((prop) => this.hostObservers.push(observe(this.field, ['formControl', prop], ({ firstChange }) => !firstChange && markFieldForCheck(this.field))));
922
+ }
923
+ else if (this.field.formControl) {
924
+ const statusChanges = this.field.formControl.statusChanges
925
+ .pipe(distinctUntilChanged())
926
+ .subscribe(() => markFieldForCheck(this.field));
927
+ this.hostObservers.push(statusChanges);
928
+ }
920
929
  }
921
930
  resetRefs(field) {
922
931
  if (field) {
@@ -967,7 +976,14 @@ class FormlyField {
967
976
  }
968
977
  if (field.formControl && !field.fieldGroup) {
969
978
  const control = field.formControl;
970
- let valueChanges = control.valueChanges.pipe(distinctUntilChanged((x, y) => {
979
+ let valueChanges = control.valueChanges.pipe(map((value) => {
980
+ var _a;
981
+ (_a = field.parsers) === null || _a === void 0 ? void 0 : _a.map((parserFn) => (value = parserFn(value, field)));
982
+ if (!Object.is(value, field.formControl.value)) {
983
+ field.formControl.setValue(value);
984
+ }
985
+ return value;
986
+ }), distinctUntilChanged((x, y) => {
971
987
  if (x !== y || Array.isArray(x) || isObject(x)) {
972
988
  return false;
973
989
  }
@@ -981,16 +997,11 @@ class FormlyField {
981
997
  valueChanges = control.valueChanges.pipe(debounceTime(debounce.default));
982
998
  }
983
999
  const sub = valueChanges.subscribe((value) => {
984
- var _a, _b;
1000
+ var _a;
985
1001
  // workaround for https://github.com/angular/angular/issues/13792
986
1002
  if (((_a = control._fields) === null || _a === void 0 ? void 0 : _a.length) > 1 && control instanceof FormControl) {
987
1003
  control.patchValue(value, { emitEvent: false, onlySelf: true });
988
1004
  }
989
- (_b = field.parsers) === null || _b === void 0 ? void 0 : _b.forEach((parserFn) => (value = parserFn(value)));
990
- if (value !== field.formControl.value) {
991
- field.formControl.setValue(value);
992
- return;
993
- }
994
1005
  if (hasKey(field)) {
995
1006
  assignFieldValue(field, value);
996
1007
  }