@gravitee/ui-particles-angular 7.27.0 → 7.28.0
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.
- package/esm2020/lib/gio-form-json-schema/gio-formly-json-schema.service.mjs +17 -1
- package/esm2020/lib/gio-form-json-schema/model/GioJsonSchema.mjs +1 -1
- package/esm2020/lib/gio-form-tags-input/gio-form-tags-input.component.mjs +47 -8
- package/fesm2015/gravitee-ui-particles-angular.mjs +60 -7
- package/fesm2015/gravitee-ui-particles-angular.mjs.map +1 -1
- package/fesm2020/gravitee-ui-particles-angular.mjs +60 -6
- package/fesm2020/gravitee-ui-particles-angular.mjs.map +1 -1
- package/lib/gio-form-json-schema/gio-formly-json-schema.service.d.ts +1 -0
- package/lib/gio-form-json-schema/model/GioJsonSchema.d.ts +1 -0
- package/lib/gio-form-tags-input/gio-form-tags-input.component.d.ts +17 -4
- package/package.json +1 -1
|
@@ -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,
|
|
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([]),
|
|
693
|
-
|
|
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
|
|
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
|
|
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)
|
|
@@ -3153,6 +3192,7 @@ class GioFormlyJsonSchemaService {
|
|
|
3153
3192
|
mappedField = this.bannerMap(mappedField, mapSource);
|
|
3154
3193
|
mappedField = this.toggleMap(mappedField, mapSource);
|
|
3155
3194
|
mappedField = this.disabledMap(mappedField, mapSource);
|
|
3195
|
+
mappedField = this.enumLabelMap(mappedField, mapSource);
|
|
3156
3196
|
return mappedField;
|
|
3157
3197
|
},
|
|
3158
3198
|
});
|
|
@@ -3214,6 +3254,20 @@ class GioFormlyJsonSchemaService {
|
|
|
3214
3254
|
};
|
|
3215
3255
|
return mappedField;
|
|
3216
3256
|
}
|
|
3257
|
+
enumLabelMap(mappedField, mapSource) {
|
|
3258
|
+
if (mapSource.enum && !isEmpty(mapSource.enum) && mapSource.gioConfig?.enumLabelMap && isArray(mappedField.props?.options)) {
|
|
3259
|
+
mappedField.props = {
|
|
3260
|
+
...mappedField.props,
|
|
3261
|
+
options: mappedField.props?.options?.map(({ value }) => {
|
|
3262
|
+
return {
|
|
3263
|
+
label: value ? mapSource.gioConfig?.enumLabelMap?.[value] : value,
|
|
3264
|
+
value: value,
|
|
3265
|
+
};
|
|
3266
|
+
}),
|
|
3267
|
+
};
|
|
3268
|
+
}
|
|
3269
|
+
return mappedField;
|
|
3270
|
+
}
|
|
3217
3271
|
}
|
|
3218
3272
|
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 });
|
|
3219
3273
|
GioFormlyJsonSchemaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormlyJsonSchemaService });
|