@gravitee/ui-particles-angular 5.14.0-showcase-http-proxy-28de21a → 5.15.0-showcase-http-proxy-fa50d15

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,7 +1,7 @@
1
1
  import { trigger, transition, style, animate } from '@angular/animations';
2
2
  import * as i0 from '@angular/core';
3
3
  import { EventEmitter, Component, HostBinding, Input, Output, HostListener, NgModule, Optional, Self, ViewChild, Directive, Inject, forwardRef, ChangeDetectionStrategy, Injectable, ViewEncapsulation, ContentChildren, Host, ContentChild, InjectionToken } from '@angular/core';
4
- import { timer, Subject, fromEvent, of, BehaviorSubject, ReplaySubject } from 'rxjs';
4
+ import { timer, Subject, fromEvent, of, BehaviorSubject, combineLatest, ReplaySubject } from 'rxjs';
5
5
  import * as i1 from '@angular/material/card';
6
6
  import { MatCardModule } from '@angular/material/card';
7
7
  import * as i2 from '@angular/material/button';
@@ -2797,6 +2797,7 @@ class GioFormlyJsonSchemaService {
2797
2797
  return this.formlyJsonschema.toFieldConfig(jsonSchema, {
2798
2798
  map: (mappedField, mapSource) => {
2799
2799
  mappedField = this.uiTypeMap(mappedField, mapSource);
2800
+ mappedField = this.formatMap(mappedField, mapSource);
2800
2801
  mappedField = this.bannerMap(mappedField, mapSource);
2801
2802
  mappedField = this.toggleMap(mappedField, mapSource);
2802
2803
  return mappedField;
@@ -2807,6 +2808,22 @@ class GioFormlyJsonSchemaService {
2807
2808
  mappedField.type = mapSource.gioConfig?.uiType ?? mappedField.type;
2808
2809
  return mappedField;
2809
2810
  }
2811
+ formatMap(mappedField, mapSource) {
2812
+ if (mapSource.type === 'string' && mapSource.format === 'text') {
2813
+ mappedField.type = 'textarea';
2814
+ mappedField.props = {
2815
+ ...mappedField.props,
2816
+ autosize: true,
2817
+ };
2818
+ }
2819
+ else if (mapSource.type === 'string' && mapSource.format === 'password') {
2820
+ mappedField.props = {
2821
+ ...mappedField.props,
2822
+ type: 'password',
2823
+ };
2824
+ }
2825
+ return mappedField;
2826
+ }
2810
2827
  bannerMap(mappedField, mapSource) {
2811
2828
  mappedField.props = {
2812
2829
  ...mappedField.props,
@@ -2863,6 +2880,7 @@ class GioFormJsonSchemaComponent {
2863
2880
  this._onChange = () => ({});
2864
2881
  this._onTouched = () => ({});
2865
2882
  this.touched = false;
2883
+ this.stateChanges$ = new Subject();
2866
2884
  if (ngControl) {
2867
2885
  // Setting the value accessor directly (instead of using
2868
2886
  // the providers `NG_VALUE_ACCESSOR`) to avoid running into a circular import.
@@ -2882,27 +2900,38 @@ class GioFormJsonSchemaComponent {
2882
2900
  }
2883
2901
  }
2884
2902
  ngOnInit() {
2885
- // When the parent form is touched, mark all the sub formGroup as touched
2903
+ // When the parent form is touched, mark all the sub formGroup as touched ony once
2886
2904
  const parentControl = this.ngControl?.control?.parent;
2887
2905
  parentControl?.statusChanges
2888
- ?.pipe(takeUntil(this.unsubscribe$), map(() => parentControl?.touched), filter(touched => touched === true), tap(() => this.formGroup.markAllAsTouched()))
2889
- .subscribe();
2890
- this.formGroup.statusChanges.pipe(takeUntil(this.unsubscribe$)).subscribe(status => {
2891
- if (status === 'VALID') {
2892
- this.ngControl?.control?.setErrors(null);
2893
- }
2894
- if (status === 'INVALID') {
2895
- this.ngControl?.control?.setErrors({ invalid: true });
2896
- }
2906
+ ?.pipe(takeUntil(this.unsubscribe$), map(() => parentControl?.touched), filter(touched => touched === true), distinctUntilChanged())
2907
+ .subscribe(() => {
2908
+ this.formGroup.markAllAsTouched();
2909
+ this.stateChanges$.next();
2897
2910
  });
2898
2911
  // To simulate the behavior of classic form controls, emit value only when the form is touched
2899
2912
  // Allow to keep the formControl pristine until the user interact with it
2900
- this.formGroup.valueChanges
2913
+ combineLatest([this.formGroup.statusChanges, this.formGroup.valueChanges])
2901
2914
  .pipe(takeUntil(this.unsubscribe$),
2902
2915
  // Group all valueChanges events emit by formly in a single one
2903
- debounceTime(200), filter(() => this.touched))
2904
- .subscribe(value => {
2905
- this._onChange(value);
2916
+ debounceTime(100))
2917
+ .subscribe(() => {
2918
+ this.stateChanges$.next();
2919
+ });
2920
+ this.stateChanges$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2921
+ const { status, value, touched } = this.formGroup;
2922
+ if (touched) {
2923
+ this._onTouched();
2924
+ this.touched = true;
2925
+ }
2926
+ if (this.touched) {
2927
+ this._onChange(value);
2928
+ if (status === 'VALID') {
2929
+ this.ngControl?.control?.setErrors(null);
2930
+ }
2931
+ if (status === 'INVALID') {
2932
+ this.ngControl?.control?.setErrors({ invalid: true });
2933
+ }
2934
+ }
2906
2935
  });
2907
2936
  }
2908
2937
  ngOnDestroy() {
@@ -3354,7 +3383,7 @@ GioFjsMultiSchemaTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
3354
3383
  </div>
3355
3384
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3356
3385
  </div>
3357
- `, isInline: true, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__title{font-size:16px;font-weight:500;line-height:24px;font:600 14px/20px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:4px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}\n"], components: [{ type: i1$4.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3386
+ `, isInline: true, styles: [".wrapper__title{font-size:16px;font-weight:500;line-height:24px;font:600 14px/20px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:4px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}\n"], components: [{ type: i1$4.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3358
3387
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsMultiSchemaTypeComponent, decorators: [{
3359
3388
  type: Component,
3360
3389
  args: [{ selector: 'gio-fjs-multi-schema-type', template: `
@@ -3366,7 +3395,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3366
3395
  </div>
3367
3396
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3368
3397
  </div>
3369
- `, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__title{font-size:16px;font-weight:500;line-height:24px;font:600 14px/20px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:4px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}\n"] }]
3398
+ `, styles: [".wrapper__title{font-size:16px;font-weight:500;line-height:24px;font:600 14px/20px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:4px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}\n"] }]
3370
3399
  }] });
3371
3400
 
3372
3401
  /*
@@ -3504,6 +3533,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3504
3533
  `, styles: [".wrapper{display:flex;flex-direction:column;padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__header{display:flex}.wrapper__header__text{flex:1 1 auto}.wrapper__header__text__title{font:600 16px/24px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:8px}.wrapper__header__collapse{flex:0 0 auto}.wrapper__header__collapse .collapse-open{transform:rotate(180deg);transition:transform 225ms cubic-bezier(.4,0,.2,1)}.wrapper__header__collapse .collapse-close{transform:rotate(0);transition:transform 225ms cubic-bezier(.4,0,.2,1)}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}\n"] }]
3505
3534
  }] });
3506
3535
 
3536
+ /*
3537
+ * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
3538
+ *
3539
+ * Licensed under the Apache License, Version 2.0 (the "License");
3540
+ * you may not use this file except in compliance with the License.
3541
+ * You may obtain a copy of the License at
3542
+ *
3543
+ * http://www.apache.org/licenses/LICENSE-2.0
3544
+ *
3545
+ * Unless required by applicable law or agreed to in writing, software
3546
+ * distributed under the License is distributed on an "AS IS" BASIS,
3547
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3548
+ * See the License for the specific language governing permissions and
3549
+ * limitations under the License.
3550
+ */
3551
+ class GioPasswordEyeWrapperComponent extends FieldWrapper {
3552
+ constructor() {
3553
+ super(...arguments);
3554
+ this.hide = true;
3555
+ }
3556
+ ngAfterViewInit() {
3557
+ if (this.matSuffix) {
3558
+ this.props.suffix = this.matSuffix;
3559
+ }
3560
+ }
3561
+ addonEyeClick($event) {
3562
+ $event.stopPropagation();
3563
+ this.hide = !this.hide;
3564
+ this.props.type = this.hide ? 'password' : 'text';
3565
+ }
3566
+ }
3567
+ GioPasswordEyeWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioPasswordEyeWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
3568
+ GioPasswordEyeWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioPasswordEyeWrapperComponent, selector: "gio-password-eye-wrapper", viewQueries: [{ propertyName: "matSuffix", first: true, predicate: ["matSuffix"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
3569
+ <ng-container #fieldComponent></ng-container>
3570
+
3571
+ <ng-template #matSuffix>
3572
+ <span style="cursor: pointer" (click)="addonEyeClick($event)">
3573
+ <mat-icon [svgIcon]="hide ? 'gio:eye-empty' : 'gio:eye-off'"></mat-icon>
3574
+ </span>
3575
+ </ng-template>
3576
+ `, isInline: true, components: [{ type: i1$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
3577
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioPasswordEyeWrapperComponent, decorators: [{
3578
+ type: Component,
3579
+ args: [{
3580
+ selector: 'gio-password-eye-wrapper',
3581
+ template: `
3582
+ <ng-container #fieldComponent></ng-container>
3583
+
3584
+ <ng-template #matSuffix>
3585
+ <span style="cursor: pointer" (click)="addonEyeClick($event)">
3586
+ <mat-icon [svgIcon]="hide ? 'gio:eye-empty' : 'gio:eye-off'"></mat-icon>
3587
+ </span>
3588
+ </ng-template>
3589
+ `,
3590
+ }]
3591
+ }], propDecorators: { matSuffix: [{
3592
+ type: ViewChild,
3593
+ args: ['matSuffix', { static: true }]
3594
+ }] } });
3595
+ function passwordEyeExtension(field) {
3596
+ if (!field.props || (field.wrappers && field.wrappers.indexOf('gio-password-eye') !== -1)) {
3597
+ return;
3598
+ }
3599
+ if (field.props.type === 'password') {
3600
+ field.wrappers = [...(field.wrappers || []), 'gio-password-eye'];
3601
+ }
3602
+ }
3603
+
3507
3604
  /*
3508
3605
  * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3509
3606
  *
@@ -3529,7 +3626,8 @@ GioFormJsonSchemaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
3529
3626
  GioFjsArrayTypeComponent,
3530
3627
  GioFjsToggleTypeComponent,
3531
3628
  GioFjsHeadersTypeComponent,
3532
- GioFormFieldWrapperComponent], imports: [CommonModule,
3629
+ GioFormFieldWrapperComponent,
3630
+ GioPasswordEyeWrapperComponent], imports: [CommonModule,
3533
3631
  A11yModule,
3534
3632
  ReactiveFormsModule, i1$4.FormlyModule, FormlyMaterialModule,
3535
3633
  GioIconsModule,
@@ -3557,7 +3655,10 @@ GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
3557
3655
  { name: 'uniqueItems', message: 'Should NOT have duplicate items' },
3558
3656
  { name: 'const', message: constValidationMessage },
3559
3657
  ],
3560
- wrappers: [{ name: 'gio-with-banner', component: GioFormFieldWrapperComponent }],
3658
+ wrappers: [
3659
+ { name: 'gio-with-banner', component: GioFormFieldWrapperComponent },
3660
+ { name: 'gio-password-eye', component: GioPasswordEyeWrapperComponent },
3661
+ ],
3561
3662
  types: [
3562
3663
  { name: 'null', component: GioFjsNullTypeComponent, wrappers: ['form-field'] },
3563
3664
  { name: 'array', component: GioFjsArrayTypeComponent },
@@ -3572,7 +3673,10 @@ GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
3572
3673
  component: GioFjsHeadersTypeComponent,
3573
3674
  },
3574
3675
  ],
3575
- extensions: [{ name: 'banner', extension: { onPopulate: bannerExtension } }],
3676
+ extensions: [
3677
+ { name: 'banner', extension: { onPopulate: bannerExtension } },
3678
+ { name: 'password-eye', extension: { onPopulate: passwordEyeExtension } },
3679
+ ],
3576
3680
  extras: {
3577
3681
  checkExpressionOn: 'changeDetectionCheck',
3578
3682
  },
@@ -3596,6 +3700,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3596
3700
  GioFjsToggleTypeComponent,
3597
3701
  GioFjsHeadersTypeComponent,
3598
3702
  GioFormFieldWrapperComponent,
3703
+ GioPasswordEyeWrapperComponent,
3599
3704
  ],
3600
3705
  imports: [
3601
3706
  CommonModule,
@@ -3617,7 +3722,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3617
3722
  { name: 'uniqueItems', message: 'Should NOT have duplicate items' },
3618
3723
  { name: 'const', message: constValidationMessage },
3619
3724
  ],
3620
- wrappers: [{ name: 'gio-with-banner', component: GioFormFieldWrapperComponent }],
3725
+ wrappers: [
3726
+ { name: 'gio-with-banner', component: GioFormFieldWrapperComponent },
3727
+ { name: 'gio-password-eye', component: GioPasswordEyeWrapperComponent },
3728
+ ],
3621
3729
  types: [
3622
3730
  { name: 'null', component: GioFjsNullTypeComponent, wrappers: ['form-field'] },
3623
3731
  { name: 'array', component: GioFjsArrayTypeComponent },
@@ -3632,7 +3740,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3632
3740
  component: GioFjsHeadersTypeComponent,
3633
3741
  },
3634
3742
  ],
3635
- extensions: [{ name: 'banner', extension: { onPopulate: bannerExtension } }],
3743
+ extensions: [
3744
+ { name: 'banner', extension: { onPopulate: bannerExtension } },
3745
+ { name: 'password-eye', extension: { onPopulate: passwordEyeExtension } },
3746
+ ],
3636
3747
  extras: {
3637
3748
  checkExpressionOn: 'changeDetectionCheck',
3638
3749
  },
@@ -3688,17 +3799,17 @@ class GioFormFocusInvalidDirective {
3688
3799
  onFormSubmit() {
3689
3800
  const selector = '.ng-invalid[formControlName],input.ng-invalid,mat-select.ng-invalid,textarea.ng-invalid,.gio-ng-invalid';
3690
3801
  try {
3802
+ // Mark all controls as touched to display errors
3803
+ if (this.formGroupDirective) {
3804
+ this.formGroupDirective.control.markAllAsTouched();
3805
+ this.formGroupDirective.control.updateValueAndValidity();
3806
+ }
3691
3807
  let invalidControl = this.renderer.selectRootElement(selector, true);
3692
3808
  // If the form is a GioFormJsonSchema, we need to focus the first invalid control inside
3693
3809
  if (invalidControl.tagName === 'GIO-FORM-JSON-SCHEMA') {
3694
3810
  invalidControl = invalidControl.querySelector(selector);
3695
3811
  }
3696
3812
  if (invalidControl) {
3697
- // Mark all controls as touched to display errors
3698
- if (this.formGroupDirective) {
3699
- this.formGroupDirective.control.markAllAsTouched();
3700
- this.formGroupDirective.control.updateValueAndValidity();
3701
- }
3702
3813
  invalidControl.scrollIntoView({ behavior: 'smooth', block: 'center' });
3703
3814
  invalidControl.focus({ preventScroll: true });
3704
3815
  }