@gravitee/ui-particles-angular 7.24.2-json-schema-2fee57d → 7.24.2-json-schema-4047714

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.
@@ -4,7 +4,7 @@ import * as i0 from '@angular/core';
4
4
  import { Injectable, SecurityContext, APP_ID, Component, Inject, Input, NgModule, EventEmitter, HostBinding, Output, HostListener, Optional, Self, ViewChild, Directive, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, Host, ContentChild, InjectionToken } from '@angular/core';
5
5
  import * as i4 from '@angular/common/http';
6
6
  import { HttpClientModule } from '@angular/common/http';
7
- import { shareReplay, switchMap, catchError, takeUntil, startWith, map, distinctUntilChanged, tap, debounce, delay, filter, take, debounceTime } from 'rxjs/operators';
7
+ import { shareReplay, switchMap, catchError, takeUntil, tap, startWith, map, distinctUntilChanged, debounce, delay, filter, take, debounceTime } from 'rxjs/operators';
8
8
  import { Observable, of, ReplaySubject, Subject, forkJoin, timer, fromEvent, BehaviorSubject, merge } from 'rxjs';
9
9
  import * as i3 from '@angular/platform-browser';
10
10
  import { trigger, transition, style, animate } from '@angular/animations';
@@ -550,6 +550,7 @@ class GioFormTagsInputComponent {
550
550
  this.focused = false;
551
551
  this._required = false;
552
552
  this._disabled = false;
553
+ this.displayValueCache = {};
553
554
  // From ControlValueAccessor interface
554
555
  this.describedBy = '';
555
556
  // Replace the provider from above with this.
@@ -569,6 +570,21 @@ class GioFormTagsInputComponent {
569
570
  this._autocompleteOptions = v;
570
571
  this.initAutocomplete();
571
572
  }
573
+ /**
574
+ * Get the label of an option value.
575
+ * To use with autocompleteOptions label & value mode.
576
+ * Function called each time a tag needs to be displayed id defined.
577
+ */
578
+ set displayValueWith(displayValueWith) {
579
+ this._displayValueWith = (value) => {
580
+ if (this.displayValueCache[value]) {
581
+ return of(this.displayValueCache[value]);
582
+ }
583
+ return displayValueWith(value).pipe(tap(label => {
584
+ this.displayValueCache[value] = label;
585
+ }));
586
+ };
587
+ }
572
588
  set tagInput(v) {
573
589
  this._tagInput = v;
574
590
  this.initAutocomplete();
@@ -689,8 +705,17 @@ class GioFormTagsInputComponent {
689
705
  }
690
706
  initAutocomplete() {
691
707
  if (this._autocompleteOptions && this._tagInput?.nativeElement) {
692
- this.autocompleteFilteredOptions$ = fromEvent(this._tagInput.nativeElement, 'keyup').pipe(startWith([]), map(() => {
693
- return (this._autocompleteOptions ?? []).filter(defaultHeader => defaultHeader.toLowerCase().includes((this._tagInput?.nativeElement.value ?? '').toLowerCase()));
708
+ this.autocompleteFilteredOptions$ = fromEvent(this._tagInput.nativeElement, 'keyup').pipe(startWith([]), switchMap(() => {
709
+ if (typeof this._autocompleteOptions === 'function') {
710
+ return this._autocompleteOptions(this._tagInput?.nativeElement.value ?? '').pipe(map(options => sanitizeAutocompleteOptions(options)),
711
+ // Add options to displayValueCache to avoid call on select
712
+ tap(options => {
713
+ options.forEach(option => {
714
+ this.displayValueCache[option.value] = option.label;
715
+ });
716
+ }));
717
+ }
718
+ return of(defaultAutocompleteFilter(this._autocompleteOptions ?? [], this._tagInput?.nativeElement.value ?? ''));
694
719
  }), distinctUntilChanged());
695
720
  this.changeDetectorRef.detectChanges();
696
721
  }
@@ -698,12 +723,12 @@ class GioFormTagsInputComponent {
698
723
  }
699
724
  GioFormTagsInputComponent.nextId = 0;
700
725
  GioFormTagsInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormTagsInputComponent, deps: [{ token: i7.NgControl, optional: true, self: true }, { token: i0.ElementRef }, { token: i2$2.FocusMonitor }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
701
- GioFormTagsInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormTagsInputComponent, selector: "gio-form-tags-input", inputs: { ariaLabel: ["aria-label", "ariaLabel"], addOnBlur: "addOnBlur", tagValidationHook: "tagValidationHook", autocompleteOptions: "autocompleteOptions", placeholder: "placeholder", required: "required", disabled: "disabled" }, host: { properties: { "id": "this.id", "class.floating": "this.shouldLabelFloat", "attr.aria-describedby": "this.describedBy" } }, providers: [
726
+ GioFormTagsInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormTagsInputComponent, selector: "gio-form-tags-input", inputs: { ariaLabel: ["aria-label", "ariaLabel"], addOnBlur: "addOnBlur", tagValidationHook: "tagValidationHook", autocompleteOptions: "autocompleteOptions", displayValueWith: "displayValueWith", placeholder: "placeholder", required: "required", disabled: "disabled" }, host: { properties: { "id": "this.id", "class.floating": "this.shouldLabelFloat", "attr.aria-describedby": "this.describedBy" } }, providers: [
702
727
  {
703
728
  provide: MatFormFieldControl,
704
729
  useExisting: GioFormTagsInputComponent,
705
730
  },
706
- ], viewQueries: [{ propertyName: "tagInput", first: true, predicate: ["tagInput"], descendants: true }], ngImport: i0, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<mat-chip-list #tagChipList [attr.aria-label]=\"ariaLabel\" multiple [disabled]=\"disabled\">\n <mat-chip *ngFor=\"let tag of value\" [selectable]=\"false\" [removable]=\"!disabled\" (removed)=\"removeChipToFormControl(tag)\">\n {{ tag }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input\n *ngIf=\"!disabled\"\n #tagInput\n [matAutocompleteDisabled]=\"!_autocompleteOptions\"\n [matAutocomplete]=\"auto\"\n [placeholder]=\"placeholder\"\n [matChipInputFor]=\"tagChipList\"\n [matChipInputAddOnBlur]=\"addOnBlur\"\n (matChipInputTokenEnd)=\"onMatChipTokenEnd()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onAutocompleteSelect($event)\">\n <mat-option *ngFor=\"let value of autocompleteFilteredOptions$ | async\" [value]=\"value\">\n {{ value }}\n </mat-option>\n </mat-autocomplete>\n</mat-chip-list>\n", styles: [""], components: [{ type: i3$1.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i1$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i2$3.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3$1.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disableRipple", "tabIndex", "selected", "value", "selectable", "disabled", "removable"], outputs: ["selectionChange", "destroyed", "removed"], exportAs: ["matChip"] }, { type: i3$1.MatChipRemove, selector: "[matChipRemove]" }, { type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i3$1.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }], pipes: { "async": i2$1.AsyncPipe } });
731
+ ], viewQueries: [{ propertyName: "tagInput", first: true, predicate: ["tagInput"], descendants: true }], ngImport: i0, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<mat-chip-list #tagChipList [attr.aria-label]=\"ariaLabel\" multiple [disabled]=\"disabled\">\n <mat-chip *ngFor=\"let tag of value\" [selectable]=\"false\" [removable]=\"!disabled\" (removed)=\"removeChipToFormControl(tag)\">\n {{ _displayValueWith ? (_displayValueWith(tag) | async) : tag }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input\n *ngIf=\"!disabled\"\n #tagInput\n [matAutocompleteDisabled]=\"!_autocompleteOptions\"\n [matAutocomplete]=\"auto\"\n [placeholder]=\"placeholder\"\n [matChipInputFor]=\"tagChipList\"\n [matChipInputAddOnBlur]=\"addOnBlur\"\n (matChipInputTokenEnd)=\"onMatChipTokenEnd()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onAutocompleteSelect($event)\">\n <mat-option *ngFor=\"let option of autocompleteFilteredOptions$ | async\" [value]=\"option.value\">\n {{ option.label }}\n </mat-option>\n </mat-autocomplete>\n</mat-chip-list>\n", styles: [""], components: [{ type: i3$1.MatChipList, selector: "mat-chip-list", inputs: ["errorStateMatcher", "multiple", "compareWith", "value", "required", "placeholder", "disabled", "aria-orientation", "selectable", "tabIndex"], outputs: ["change", "valueChange"], exportAs: ["matChipList"] }, { type: i1$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple"], exportAs: ["matAutocomplete"] }, { type: i2$3.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3$1.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disableRipple", "tabIndex", "selected", "value", "selectable", "disabled", "removable"], outputs: ["selectionChange", "destroyed", "removed"], exportAs: ["matChip"] }, { type: i3$1.MatChipRemove, selector: "[matChipRemove]" }, { type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { type: i3$1.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }], pipes: { "async": i2$1.AsyncPipe } });
707
732
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormTagsInputComponent, decorators: [{
708
733
  type: Component,
709
734
  args: [{ selector: 'gio-form-tags-input', providers: [
@@ -711,7 +736,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
711
736
  provide: MatFormFieldControl,
712
737
  useExisting: GioFormTagsInputComponent,
713
738
  },
714
- ], template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<mat-chip-list #tagChipList [attr.aria-label]=\"ariaLabel\" multiple [disabled]=\"disabled\">\n <mat-chip *ngFor=\"let tag of value\" [selectable]=\"false\" [removable]=\"!disabled\" (removed)=\"removeChipToFormControl(tag)\">\n {{ tag }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input\n *ngIf=\"!disabled\"\n #tagInput\n [matAutocompleteDisabled]=\"!_autocompleteOptions\"\n [matAutocomplete]=\"auto\"\n [placeholder]=\"placeholder\"\n [matChipInputFor]=\"tagChipList\"\n [matChipInputAddOnBlur]=\"addOnBlur\"\n (matChipInputTokenEnd)=\"onMatChipTokenEnd()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onAutocompleteSelect($event)\">\n <mat-option *ngFor=\"let value of autocompleteFilteredOptions$ | async\" [value]=\"value\">\n {{ value }}\n </mat-option>\n </mat-autocomplete>\n</mat-chip-list>\n", styles: [""] }]
739
+ ], template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<mat-chip-list #tagChipList [attr.aria-label]=\"ariaLabel\" multiple [disabled]=\"disabled\">\n <mat-chip *ngFor=\"let tag of value\" [selectable]=\"false\" [removable]=\"!disabled\" (removed)=\"removeChipToFormControl(tag)\">\n {{ _displayValueWith ? (_displayValueWith(tag) | async) : tag }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip>\n <input\n *ngIf=\"!disabled\"\n #tagInput\n [matAutocompleteDisabled]=\"!_autocompleteOptions\"\n [matAutocomplete]=\"auto\"\n [placeholder]=\"placeholder\"\n [matChipInputFor]=\"tagChipList\"\n [matChipInputAddOnBlur]=\"addOnBlur\"\n (matChipInputTokenEnd)=\"onMatChipTokenEnd()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onAutocompleteSelect($event)\">\n <mat-option *ngFor=\"let option of autocompleteFilteredOptions$ | async\" [value]=\"option.value\">\n {{ option.label }}\n </mat-option>\n </mat-autocomplete>\n</mat-chip-list>\n", styles: [""] }]
715
740
  }], ctorParameters: function () { return [{ type: i7.NgControl, decorators: [{
716
741
  type: Optional
717
742
  }, {
@@ -725,6 +750,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
725
750
  type: Input
726
751
  }], autocompleteOptions: [{
727
752
  type: Input
753
+ }], displayValueWith: [{
754
+ type: Input
728
755
  }], tagInput: [{
729
756
  type: ViewChild,
730
757
  args: ['tagInput']
@@ -744,6 +771,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
744
771
  type: HostBinding,
745
772
  args: ['attr.aria-describedby']
746
773
  }] } });
774
+ const defaultAutocompleteFilter = (options, search) => {
775
+ return sanitizeAutocompleteOptions(options).filter(defaultHeader => defaultHeader.label.toLowerCase().includes((search ?? '').toLowerCase()) ||
776
+ defaultHeader.value.toLowerCase().includes((search ?? '').toLowerCase()));
777
+ };
778
+ const sanitizeAutocompleteOptions = (options) => {
779
+ return options.map(option => {
780
+ if (option && typeof option !== 'string' && 'value' in option && 'label' in option) {
781
+ return option;
782
+ }
783
+ return { value: option, label: option };
784
+ });
785
+ };
747
786
 
748
787
  /*
749
788
  * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
@@ -3131,6 +3170,7 @@ class GioFormlyJsonSchemaService {
3131
3170
  mappedField = this.bannerMap(mappedField, mapSource);
3132
3171
  mappedField = this.toggleMap(mappedField, mapSource);
3133
3172
  mappedField = this.disabledMap(mappedField, mapSource);
3173
+ mappedField = this.enumLabelMap(mappedField, mapSource);
3134
3174
  return mappedField;
3135
3175
  },
3136
3176
  });
@@ -3192,6 +3232,20 @@ class GioFormlyJsonSchemaService {
3192
3232
  };
3193
3233
  return mappedField;
3194
3234
  }
3235
+ enumLabelMap(mappedField, mapSource) {
3236
+ if (mapSource.enum && !isEmpty(mapSource.enum) && mapSource.gioConfig?.enumLabelMap && isArray(mappedField.props?.options)) {
3237
+ mappedField.props = {
3238
+ ...mappedField.props,
3239
+ options: mappedField.props?.options?.map(({ value }) => {
3240
+ return {
3241
+ label: value ? mapSource.gioConfig?.enumLabelMap?.[value] : value,
3242
+ value: value,
3243
+ };
3244
+ }),
3245
+ };
3246
+ }
3247
+ return mappedField;
3248
+ }
3195
3249
  }
3196
3250
  GioFormlyJsonSchemaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormlyJsonSchemaService, deps: [{ token: i1$3.FormlyJsonschema }, { token: i1$4.FormlyFormBuilder }], target: i0.ɵɵFactoryTarget.Injectable });
3197
3251
  GioFormlyJsonSchemaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormlyJsonSchemaService });
@@ -5098,10 +5152,10 @@ class GioClipboardComponent {
5098
5152
  }, 2500);
5099
5153
  }
5100
5154
  }
5101
- GioClipboardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioClipboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5102
- GioClipboardComponent.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioClipboardComponent });
5155
+ GioClipboardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioClipboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
5156
+ GioClipboardComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: GioClipboardComponent, inputs: { contentToCopy: "contentToCopy", alwaysVisible: "alwaysVisible" }, ngImport: i0 });
5103
5157
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioClipboardComponent, decorators: [{
5104
- type: Injectable
5158
+ type: Directive
5105
5159
  }], propDecorators: { contentToCopy: [{
5106
5160
  type: Input
5107
5161
  }], alwaysVisible: [{