@ngx-formly/core 5.10.29 → 5.10.30

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.
@@ -1,5 +1,5 @@
1
1
  import { DOCUMENT, CommonModule } from '@angular/common';
2
- import { TemplateRef, Injectable, InjectionToken, NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, Inject, Optional, Component, Input, ChangeDetectionStrategy, EventEmitter, Output, Attribute, ViewChild, ElementRef, NgZone, Directive, Renderer2, ViewContainerRef, ComponentFactoryResolver, Injector, ChangeDetectorRef, defineInjectable, inject, INJECTOR } from '@angular/core';
2
+ import { TemplateRef, Injectable, InjectionToken, NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, Inject, Optional, Component, Input, ChangeDetectionStrategy, EventEmitter, Output, Attribute, ViewChild, ElementRef, NgZone, ViewContainerRef, ComponentFactoryResolver, Renderer2, Directive, Injector, ChangeDetectorRef, defineInjectable, inject, INJECTOR } from '@angular/core';
3
3
  import { DomSanitizer } from '@angular/platform-browser';
4
4
  import { __rest } from 'tslib';
5
5
  import { debounceTime, switchMap, distinctUntilChanged, take, startWith, filter, map } from 'rxjs/operators';
@@ -316,25 +316,6 @@ function wrapProperty(o, prop, setFn) {
316
316
  */
317
317
  () => fns.splice(fns.indexOf(setFn), 1));
318
318
  }
319
- /**
320
- * @param {?} form
321
- * @param {?} action
322
- * @return {?}
323
- */
324
- function reduceFormUpdateValidityCalls(form, action) {
325
- /** @type {?} */
326
- const updateValidity = form._updateTreeValidity.bind(form);
327
- /** @type {?} */
328
- let updateValidityArgs = { called: false, emitEvent: false };
329
- form._updateTreeValidity = (/**
330
- * @param {?=} __0
331
- * @return {?}
332
- */
333
- ({ emitEvent } = { emitEvent: true }) => updateValidityArgs = { called: true, emitEvent: emitEvent || updateValidityArgs.emitEvent });
334
- action();
335
- updateValidityArgs.called && updateValidity({ emitEvent: updateValidityArgs.emitEvent });
336
- form._updateTreeValidity = updateValidity;
337
- }
338
319
 
339
320
  /**
340
321
  * @fileoverview added by tsickle
@@ -651,10 +632,7 @@ class FormlyFormBuilder {
651
632
  }
652
633
  /** @type {?} */
653
634
  const field = { fieldGroup, model, formControl, options: this._setOptions(options) };
654
- reduceFormUpdateValidityCalls(formControl, (/**
655
- * @return {?}
656
- */
657
- () => this._buildForm(field)));
635
+ this._buildForm(field);
658
636
  field.options._checkField(field, true);
659
637
  }
660
638
  /**
@@ -914,15 +892,21 @@ function registerControl(field, control, emitEvent = false) {
914
892
  }
915
893
  /**
916
894
  * @param {?} c
895
+ * @param {?=} onlySelf
917
896
  * @return {?}
918
897
  */
919
- function updateValidity(c) {
898
+ function updateValidity(c, onlySelf = false) {
920
899
  /** @type {?} */
921
900
  const status = c.status;
922
- c.updateValueAndValidity({ emitEvent: false });
901
+ /** @type {?} */
902
+ const value = c.value;
903
+ c.updateValueAndValidity({ emitEvent: false, onlySelf });
923
904
  if (status !== c.status) {
924
905
  ((/** @type {?} */ (c.statusChanges))).emit(c.status);
925
906
  }
907
+ if (value !== c.value) {
908
+ ((/** @type {?} */ (c.valueChanges))).emit(c.value);
909
+ }
926
910
  }
927
911
  /**
928
912
  * @param {?} form
@@ -2306,10 +2290,7 @@ class FieldExpressionExtension {
2306
2290
  (f, ignoreCache) => {
2307
2291
  if (!checkLocked) {
2308
2292
  checkLocked = true;
2309
- reduceFormUpdateValidityCalls(f.formControl, (/**
2310
- * @return {?}
2311
- */
2312
- () => this.checkField(f, ignoreCache)));
2293
+ this.checkField(f, ignoreCache);
2313
2294
  checkLocked = false;
2314
2295
  }
2315
2296
  });
@@ -2982,22 +2963,7 @@ class FieldFormExtension {
2982
2963
  if (field.parent) {
2983
2964
  return;
2984
2965
  }
2985
- /** @type {?} */
2986
- const fieldsToUpdate = this.setValidators(field);
2987
- if (fieldsToUpdate.length === 0) {
2988
- return;
2989
- }
2990
- if (fieldsToUpdate.length === 1) {
2991
- /** @type {?} */
2992
- let control = fieldsToUpdate[0].formControl;
2993
- while (control) {
2994
- ((/** @type {?} */ (control)))._updateTreeValidity({ onlySelf: true });
2995
- control = control.parent;
2996
- }
2997
- }
2998
- else {
2999
- ((/** @type {?} */ (field.formControl)))._updateTreeValidity();
3000
- }
2966
+ this.setValidators(field);
3001
2967
  }
3002
2968
  /**
3003
2969
  * @private
@@ -3037,7 +3003,12 @@ class FieldFormExtension {
3037
3003
  */
3038
3004
  setValidators(field) {
3039
3005
  /** @type {?} */
3040
- let updateValidity$$1 = false;
3006
+ let markForCheck = false;
3007
+ (field.fieldGroup || []).forEach((/**
3008
+ * @param {?} f
3009
+ * @return {?}
3010
+ */
3011
+ f => this.setValidators(f) && (markForCheck = true)));
3041
3012
  if (field.key || !field.parent || (!field.key && !field.fieldGroup)) {
3042
3013
  const { formControl: c } = field;
3043
3014
  /** @type {?} */
@@ -3045,21 +3016,11 @@ class FieldFormExtension {
3045
3016
  if (field.key && c) {
3046
3017
  if (disabled && c.enabled) {
3047
3018
  c.disable({ emitEvent: false, onlySelf: true });
3048
- if (!c.parent) {
3049
- updateValidity(c);
3050
- }
3051
- else {
3052
- updateValidity$$1 = true;
3053
- }
3019
+ markForCheck = true;
3054
3020
  }
3055
3021
  if (!disabled && c.disabled) {
3056
3022
  c.enable({ emitEvent: false, onlySelf: true });
3057
- if (!c.parent) {
3058
- updateValidity(c);
3059
- }
3060
- else {
3061
- updateValidity$$1 = true;
3062
- }
3023
+ markForCheck = true;
3063
3024
  }
3064
3025
  }
3065
3026
  if (c && (null === c.validator || null === c.asyncValidator)) {
@@ -3079,28 +3040,13 @@ class FieldFormExtension {
3079
3040
  const v = Validators.composeAsync(this.mergeValidators(field, '_asyncValidators'));
3080
3041
  return v ? v(c) : of(null);
3081
3042
  }));
3082
- if (!c.parent) {
3083
- updateValidity(c);
3084
- }
3085
- else {
3086
- updateValidity$$1 = true;
3087
- }
3043
+ markForCheck = true;
3088
3044
  }
3089
- }
3090
- /** @type {?} */
3091
- const fieldsToUpdate = updateValidity$$1 ? [field] : [];
3092
- (field.fieldGroup || []).forEach((/**
3093
- * @param {?} f
3094
- * @return {?}
3095
- */
3096
- f => {
3097
- /** @type {?} */
3098
- const childrenToUpdate = this.setValidators(f);
3099
- if (!updateValidity$$1) {
3100
- fieldsToUpdate.push(...childrenToUpdate);
3045
+ if (markForCheck) {
3046
+ updateValidity(c, true);
3101
3047
  }
3102
- }));
3103
- return fieldsToUpdate;
3048
+ }
3049
+ return markForCheck;
3104
3050
  }
3105
3051
  /**
3106
3052
  * @private