@gravitee/ui-particles-angular 7.36.0 → 7.37.0-fix-ps-v2-de33006

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.
@@ -3333,9 +3333,12 @@ class GioFormJsonSchemaComponent {
3333
3333
  this.gioFormFocusInvalidIgnore = true;
3334
3334
  this.formGroup = new FormGroup({});
3335
3335
  this.options = {};
3336
+ // When true the form is ready and control status are up-to-date
3337
+ // Useful to know when initial control status can be used
3338
+ this.ready = new EventEmitter();
3339
+ this.isReady = false;
3336
3340
  this.model = {};
3337
3341
  this.fields = [];
3338
- this.loading = true;
3339
3342
  this.isDisabled = false;
3340
3343
  this._onChange = () => ({});
3341
3344
  this._onTouched = () => ({});
@@ -3367,6 +3370,12 @@ class GioFormJsonSchemaComponent {
3367
3370
  this.fields = [this.gioFormlyJsonSchema.toFormlyFieldConfig(jsonSchema)];
3368
3371
  }
3369
3372
  }
3373
+ ngOnChanges(changes) {
3374
+ if (changes.jsonSchema) {
3375
+ this.isReady = false;
3376
+ this.ready.next(false);
3377
+ }
3378
+ }
3370
3379
  ngOnInit() {
3371
3380
  // When the parent form is touched, mark all the sub formGroup as touched if not already touched
3372
3381
  const parentControl = this.ngControl?.control?.parent;
@@ -3383,6 +3392,14 @@ class GioFormJsonSchemaComponent {
3383
3392
  this.ngControl?.control?.addAsyncValidators(() => {
3384
3393
  return this.isValid$.pipe(take(1), map(isValid => (isValid ? null : { invalid: true })), takeUntil(this.unsubscribe$));
3385
3394
  });
3395
+ // Init control value with default value without emit event
3396
+ this.formGroup.valueChanges.pipe(take(1), takeUntil(this.unsubscribe$)).subscribe(value => {
3397
+ this.ngControl?.control?.reset(value, { emitEvent: false });
3398
+ this.changeDetectorRef.markForCheck();
3399
+ this.changeDetectorRef.detectChanges();
3400
+ });
3401
+ this.changeDetectorRef.markForCheck();
3402
+ this.changeDetectorRef.detectChanges();
3386
3403
  // Subscribe to state changes to manage touches, status and value
3387
3404
  this.stateChanges$
3388
3405
  .pipe(tap(() => {
@@ -3412,16 +3429,22 @@ class GioFormJsonSchemaComponent {
3412
3429
  this.ngControl?.control?.updateValueAndValidity({
3413
3430
  emitEvent: false,
3414
3431
  });
3432
+ // After the first state change, the form is ready
3433
+ if (!this.isReady) {
3434
+ this.isReady = true;
3435
+ this.ready.emit(true);
3436
+ }
3415
3437
  });
3416
3438
  }
3417
3439
  ngAfterViewInit() {
3418
3440
  // Group all valueChanges events emit by formly in a single one
3419
3441
  merge(this.formGroup.statusChanges, this.formGroup.valueChanges)
3420
- .pipe(debounceTime(100), takeUntil(this.unsubscribe$))
3442
+ .pipe(
3443
+ // Force fist stateChanges$
3444
+ startWith({}), debounceTime(100), takeUntil(this.unsubscribe$))
3421
3445
  .subscribe(() => {
3422
3446
  this.stateChanges$.next();
3423
3447
  });
3424
- this.stateChanges$.next();
3425
3448
  }
3426
3449
  ngOnDestroy() {
3427
3450
  this.unsubscribe$.next();
@@ -3456,7 +3479,7 @@ class GioFormJsonSchemaComponent {
3456
3479
  }
3457
3480
  }
3458
3481
  GioFormJsonSchemaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, deps: [{ token: GioFormlyJsonSchemaService }, { token: i0.ElementRef }, { token: i1$1.FocusMonitor }, { token: i0.ChangeDetectorRef }, { token: i7.NgControl, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Component });
3459
- GioFormJsonSchemaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormJsonSchemaComponent, selector: "gio-form-json-schema", inputs: { jsonSchema: "jsonSchema", options: "options" }, host: { properties: { "attr.gioFormFocusInvalidIgnore": "this.gioFormFocusInvalidIgnore" } }, ngImport: i0, template: `<formly-form *ngIf="formGroup" [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`, isInline: true, styles: ["::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{margin-bottom:-1.34375em}\n"], components: [{ type: i1$5.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3482
+ GioFormJsonSchemaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormJsonSchemaComponent, selector: "gio-form-json-schema", inputs: { jsonSchema: "jsonSchema", options: "options" }, outputs: { ready: "ready" }, host: { properties: { "attr.gioFormFocusInvalidIgnore": "this.gioFormFocusInvalidIgnore" } }, usesOnChanges: true, ngImport: i0, template: `<formly-form *ngIf="formGroup" [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`, isInline: true, styles: ["::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{margin-bottom:-1.34375em}\n"], components: [{ type: i1$5.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3460
3483
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, decorators: [{
3461
3484
  type: Component,
3462
3485
  args: [{ selector: 'gio-form-json-schema', template: `<formly-form *ngIf="formGroup" [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`, styles: ["::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-outline:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)){padding-bottom:0}::ng-deep gio-form-json-schema .mat-form-field.mat-form-field-appearance-fill:not(::ng-deep :has(mat-hint),::ng-deep :has(mat-error)) .mat-form-field-wrapper{margin-bottom:-1.34375em}\n"] }]
@@ -3471,6 +3494,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3471
3494
  type: Input
3472
3495
  }], options: [{
3473
3496
  type: Input
3497
+ }], ready: [{
3498
+ type: Output
3474
3499
  }] } });
3475
3500
 
3476
3501
  /*