@gravitee/ui-particles-angular 7.16.1 → 7.17.1-fix-ps-2-d72beaa

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.
@@ -13,7 +13,7 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion';
13
13
  import * as i3$1 from '@angular/material/form-field';
14
14
  import { MatFormFieldControl, MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
15
15
  import { isEmpty, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, uniqueId, set } from 'lodash';
16
- import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap, take, debounceTime } from 'rxjs/operators';
16
+ import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap, debounceTime, take } from 'rxjs/operators';
17
17
  import * as i7 from '@angular/forms';
18
18
  import { FormsModule, FormArray, FormGroup, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule, NgControl } from '@angular/forms';
19
19
  import * as i2$2 from '@angular/cdk/a11y';
@@ -2974,13 +2974,32 @@ class GioFormJsonSchemaComponent {
2974
2974
  }
2975
2975
  }
2976
2976
  ngOnInit() {
2977
- // Invalid by default.
2977
+ // When the parent form is touched, mark all the sub formGroup as touched if not already touched
2978
+ const parentControl = this.ngControl?.control?.parent;
2979
+ parentControl?.statusChanges
2980
+ ?.pipe(takeUntil(this.unsubscribe$), map(() => parentControl?.touched), filter(touched => touched === true), distinctUntilChanged())
2981
+ .subscribe(() => {
2982
+ if (this.isDisabled) {
2983
+ return;
2984
+ }
2985
+ this.formGroup.markAllAsTouched();
2986
+ this.stateChanges$.next();
2987
+ });
2988
+ // Group all valueChanges events emit by formly in a single one
2989
+ merge(this.formGroup.statusChanges, this.formGroup.valueChanges)
2990
+ .pipe(takeUntil(this.unsubscribe$), debounceTime(100))
2991
+ .subscribe(() => {
2992
+ this.stateChanges$.next();
2993
+ });
2994
+ }
2995
+ ngAfterViewInit() {
2996
+ // Add async validator to the parent
2978
2997
  this.ngControl?.control?.addAsyncValidators(() => {
2979
2998
  return this.isValid$.pipe(takeUntil(this.unsubscribe$), take(1), map(isValid => (isValid ? null : { invalid: true })));
2980
2999
  });
2981
3000
  this.ngControl?.control?.updateValueAndValidity({ emitEvent: false });
2982
3001
  // Subscribe to state changes to manage touches, status and value
2983
- this.stateChanges$.pipe(takeUntil(this.unsubscribe$), debounceTime(100)).subscribe(() => {
3002
+ this.stateChanges$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2984
3003
  const { status, value, touched } = this.formGroup;
2985
3004
  if (this.isDisabled) {
2986
3005
  return;
@@ -3003,25 +3022,6 @@ class GioFormJsonSchemaComponent {
3003
3022
  this.ngControl?.control?.updateValueAndValidity({ emitEvent: false });
3004
3023
  this.changeDetectorRef.detectChanges();
3005
3024
  });
3006
- // When the parent form is touched, mark all the sub formGroup as touched if not already touched
3007
- const parentControl = this.ngControl?.control?.parent;
3008
- parentControl?.statusChanges
3009
- ?.pipe(takeUntil(this.unsubscribe$), map(() => parentControl?.touched), filter(touched => touched === true), distinctUntilChanged())
3010
- .subscribe(() => {
3011
- if (this.isDisabled) {
3012
- return;
3013
- }
3014
- this.formGroup.markAllAsTouched();
3015
- this.stateChanges$.next();
3016
- });
3017
- // Group all valueChanges events emit by formly in a single one
3018
- merge(this.formGroup.statusChanges, this.formGroup.valueChanges)
3019
- .pipe(takeUntil(this.unsubscribe$))
3020
- .subscribe(() => {
3021
- this.stateChanges$.next();
3022
- });
3023
- }
3024
- ngAfterViewInit() {
3025
3025
  this.stateChanges$.next();
3026
3026
  }
3027
3027
  ngOnDestroy() {