ng2-iq-select2-exe 16.2.0 → 16.2.2
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/README.md +2 -2
- package/esm2022/lib/iq-select2/iq-select2.component.mjs +40 -67
- package/esm2022/lib/iq-select2/messages.mjs +6 -7
- package/esm2022/lib/iq-select2-results/iq-select2-results.component.mjs +32 -18
- package/esm2022/public_api.mjs +1 -2
- package/fesm2022/ng2-iq-select2-exe.mjs +74 -89
- package/fesm2022/ng2-iq-select2-exe.mjs.map +1 -1
- package/lib/iq-select2/iq-select2.component.d.ts +10 -16
- package/lib/iq-select2/messages.d.ts +5 -8
- package/lib/iq-select2-results/iq-select2-results.component.d.ts +11 -6
- package/package.json +1 -1
- package/public_api.d.ts +0 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, Output, TemplateRef } from '@angular/core';
|
|
1
|
+
import { Component, ElementRef, EventEmitter, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
|
2
|
+
import Messages from "../iq-select2/messages";
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
import * as i1 from "@angular/common";
|
|
4
5
|
export class IqSelect2ResultsComponent {
|
|
5
6
|
constructor() {
|
|
6
|
-
this.
|
|
7
|
+
this.items = [];
|
|
8
|
+
this.onItemSelected = new EventEmitter();
|
|
7
9
|
this.activeIndex = 0;
|
|
8
|
-
this.
|
|
10
|
+
this.usingKeys = false;
|
|
9
11
|
}
|
|
10
12
|
ngOnInit() {
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
+
selectItem(item) {
|
|
15
|
+
this.onItemSelected.emit(item);
|
|
14
16
|
}
|
|
15
17
|
activeNext() {
|
|
16
18
|
if (this.activeIndex >= this.items.length - 1) {
|
|
@@ -20,7 +22,7 @@ export class IqSelect2ResultsComponent {
|
|
|
20
22
|
this.activeIndex++;
|
|
21
23
|
}
|
|
22
24
|
this.scrollToElement();
|
|
23
|
-
this.
|
|
25
|
+
this.usingKeys = true;
|
|
24
26
|
}
|
|
25
27
|
activePrevious() {
|
|
26
28
|
if (this.activeIndex - 1 < 0) {
|
|
@@ -30,28 +32,27 @@ export class IqSelect2ResultsComponent {
|
|
|
30
32
|
this.activeIndex--;
|
|
31
33
|
}
|
|
32
34
|
this.scrollToElement();
|
|
33
|
-
this.
|
|
35
|
+
this.usingKeys = true;
|
|
34
36
|
}
|
|
35
37
|
scrollToElement() {
|
|
36
38
|
const element = document.getElementById('item_' + this.activeIndex);
|
|
37
|
-
const container = document.getElementById('resultsContainer');
|
|
38
39
|
if (element) {
|
|
39
|
-
container.scrollTop = element.offsetTop;
|
|
40
|
+
this.container.nativeElement.scrollTop = element.offsetTop;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
selectCurrentItem() {
|
|
43
44
|
if (this.items[this.activeIndex]) {
|
|
44
|
-
this.
|
|
45
|
+
this.selectItem(this.items[this.activeIndex]);
|
|
45
46
|
this.activeIndex = 0;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
onMouseOver(index) {
|
|
49
|
-
if (!this.
|
|
50
|
+
if (!this.usingKeys) {
|
|
50
51
|
this.activeIndex = index;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
onHovering(event) {
|
|
54
|
-
this.
|
|
55
|
+
this.usingKeys = false;
|
|
55
56
|
}
|
|
56
57
|
isSelected(currentItem) {
|
|
57
58
|
let result = false;
|
|
@@ -62,21 +63,34 @@ export class IqSelect2ResultsComponent {
|
|
|
62
63
|
});
|
|
63
64
|
return result;
|
|
64
65
|
}
|
|
66
|
+
getCountMessage() {
|
|
67
|
+
return this.messageMoreResults.replace(Messages.VISIBLE_COUNT_VAR, String(this.maxResults))
|
|
68
|
+
.replace(Messages.MAX_COUNT_VAR, String(this.items.length + this.selectedItems.length));
|
|
69
|
+
}
|
|
65
70
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2ResultsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
66
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2ResultsComponent, selector: "iq-select2-results", inputs: { items: "items",
|
|
71
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2ResultsComponent, selector: "iq-select2-results", inputs: { items: "items", maxResults: "maxResults", messageMoreResults: "messageMoreResults", messageNoResults: "messageNoResults", resultsVisible: "resultsVisible", selectedItems: "selectedItems", templateRef: "templateRef" }, outputs: { onItemSelected: "onItemSelected" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: "<div #container class=\"select2-dropdown\" [attr.data-visible]=\"resultsVisible\">\r\n <div *ngIf=\"maxResults && items.length + selectedItems.length > maxResults\" class=\"select2-message\">\r\n {{getCountMessage()}}\r\n </div>\r\n\r\n <div *ngIf=\"items.length === 0\" class=\"select2-message no-results\">\r\n {{messageNoResults}}\r\n </div>\r\n\r\n <div *ngFor=\"let item of items | slice:0:maxResults; let i = index;\" id=\"item_{{i}}\" [attr.data-item-id]=\"item.id\" [title]=\"item.text\"\r\n class=\"select2-dropdown-item\" [class.selected]=\"isSelected(item)\" [class.active]=\"i === activeIndex\"\r\n (mousedown)=\"selectItem(item)\" (mouseover)=\"onMouseOver(i)\" (mouseenter)=\"onHovering($event)\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{$item:item, $entity: item.entity, $id:item.id, $index:i}\"></ng-container>\r\n <ng-container *ngIf=\"!templateRef\">{{item.text}}</ng-container>\r\n </div>\r\n</div>\r\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:var(--select2-color-scrollbar-track)}::-webkit-scrollbar-thumb{background-color:var(--select2-color-scrollbar-thumb);border-radius:1em;border:transparent}.select2-dropdown{position:absolute;top:100%;width:100%;z-index:10;border:1px solid var(--select2-color-border);background-color:var(--select2-color-background);padding:.1em;max-height:20vh;overflow-x:hidden;overflow-y:auto}.select2-dropdown[data-visible=false]{display:none;visibility:hidden}.select2-message{font-size:.8em}.select2-dropdown-item{width:100%;padding:.2em;cursor:pointer;overflow-wrap:break-word;word-break:break-word}.selected{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-list-selected)}.active{color:var(--select2-color-item-text);background-color:var(--select2-color-list-active)}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.SlicePipe, name: "slice" }] }); }
|
|
67
72
|
}
|
|
68
73
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2ResultsComponent, decorators: [{
|
|
69
74
|
type: Component,
|
|
70
|
-
args: [{ selector: 'iq-select2-results', template: "<div class=\"select2-
|
|
71
|
-
}], ctorParameters: function () { return []; }, propDecorators: {
|
|
75
|
+
args: [{ selector: 'iq-select2-results', template: "<div #container class=\"select2-dropdown\" [attr.data-visible]=\"resultsVisible\">\r\n <div *ngIf=\"maxResults && items.length + selectedItems.length > maxResults\" class=\"select2-message\">\r\n {{getCountMessage()}}\r\n </div>\r\n\r\n <div *ngIf=\"items.length === 0\" class=\"select2-message no-results\">\r\n {{messageNoResults}}\r\n </div>\r\n\r\n <div *ngFor=\"let item of items | slice:0:maxResults; let i = index;\" id=\"item_{{i}}\" [attr.data-item-id]=\"item.id\" [title]=\"item.text\"\r\n class=\"select2-dropdown-item\" [class.selected]=\"isSelected(item)\" [class.active]=\"i === activeIndex\"\r\n (mousedown)=\"selectItem(item)\" (mouseover)=\"onMouseOver(i)\" (mouseenter)=\"onHovering($event)\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{$item:item, $entity: item.entity, $id:item.id, $index:i}\"></ng-container>\r\n <ng-container *ngIf=\"!templateRef\">{{item.text}}</ng-container>\r\n </div>\r\n</div>\r\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:var(--select2-color-scrollbar-track)}::-webkit-scrollbar-thumb{background-color:var(--select2-color-scrollbar-thumb);border-radius:1em;border:transparent}.select2-dropdown{position:absolute;top:100%;width:100%;z-index:10;border:1px solid var(--select2-color-border);background-color:var(--select2-color-background);padding:.1em;max-height:20vh;overflow-x:hidden;overflow-y:auto}.select2-dropdown[data-visible=false]{display:none;visibility:hidden}.select2-message{font-size:.8em}.select2-dropdown-item{width:100%;padding:.2em;cursor:pointer;overflow-wrap:break-word;word-break:break-word}.selected{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-list-selected)}.active{color:var(--select2-color-item-text);background-color:var(--select2-color-list-active)}\n"] }]
|
|
76
|
+
}], ctorParameters: function () { return []; }, propDecorators: { container: [{
|
|
77
|
+
type: ViewChild,
|
|
78
|
+
args: ['container']
|
|
79
|
+
}], items: [{
|
|
80
|
+
type: Input
|
|
81
|
+
}], maxResults: [{
|
|
82
|
+
type: Input
|
|
83
|
+
}], messageMoreResults: [{
|
|
84
|
+
type: Input
|
|
85
|
+
}], messageNoResults: [{
|
|
72
86
|
type: Input
|
|
73
|
-
}],
|
|
87
|
+
}], resultsVisible: [{
|
|
74
88
|
type: Input
|
|
75
89
|
}], selectedItems: [{
|
|
76
90
|
type: Input
|
|
77
91
|
}], templateRef: [{
|
|
78
92
|
type: Input
|
|
79
|
-
}],
|
|
93
|
+
}], onItemSelected: [{
|
|
80
94
|
type: Output
|
|
81
95
|
}] } });
|
|
82
|
-
//# sourceMappingURL=data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ICA8L2Rpdj5cclxuXHJcbiAgPGRpdiAqbmdGb3I9XCJsZXQgaXRlbSBvZiBpdGVtcyB8IHNsaWNlOjA6bWF4UmVzdWx0czsgbGV0IGkgPSBpbmRleDtcIiBpZD1cIml0ZW1fe3tpfX1cIiBbYXR0ci5kYXRhLWl0ZW0taWRdPVwiaXRlbS5pZFwiIFt0aXRsZV09XCJpdGVtLnRleHRcIlxyXG4gICAgICAgY2xhc3M9XCJzZWxlY3QyLWRyb3Bkb3duLWl0ZW1cIiBbY2xhc3Muc2VsZWN0ZWRdPVwiaXNTZWxlY3RlZChpdGVtKVwiIFtjbGFzcy5hY3RpdmVdPVwiaSA9PT0gYWN0aXZlSW5kZXhcIlxyXG4gICAgICAgKG1vdXNlZG93bik9XCJzZWxlY3RJdGVtKGl0ZW0pXCIgKG1vdXNlb3Zlcik9XCJvbk1vdXNlT3ZlcihpKVwiIChtb3VzZWVudGVyKT1cIm9uSG92ZXJpbmcoJGV2ZW50KVwiXHJcbiAgPlxyXG4gICAgPG5nLWNvbnRhaW5lciBbbmdUZW1wbGF0ZU91dGxldF09XCJ0ZW1wbGF0ZVJlZlwiIFtuZ1RlbXBsYXRlT3V0bGV0Q29udGV4dF09XCJ7JGl0ZW06aXRlbSwgJGVudGl0eTogaXRlbS5lbnRpdHksICRpZDppdGVtLmlkLCAkaW5kZXg6aX1cIj48L25nLWNvbnRhaW5lcj5cclxuICAgIDxuZy1jb250YWluZXIgKm5nSWY9XCIhdGVtcGxhdGVSZWZcIj57e2l0ZW0udGV4dH19PC9uZy1jb250YWluZXI+XHJcbiAgPC9kaXY+XHJcbjwvZGl2PlxyXG4iXX0=
|
package/esm2022/public_api.mjs
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
export * from './lib/iq-select2.module';
|
|
5
5
|
export * from './lib/iq-select2/iq-select2.component';
|
|
6
6
|
export * from './lib/iq-select2/iq-select2-item';
|
|
7
|
-
export * from './lib/iq-select2/messages';
|
|
8
7
|
export * from './lib/iq-select2-results/iq-select2-results.component';
|
|
9
8
|
export * from './lib/iq-select2-template/iq-select2-template.directive';
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL25nMi1pcS1zZWxlY3QyL3NyYy9wdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLHVDQUF1QyxDQUFDO0FBQ3RELGNBQWMsa0NBQWtDLENBQUM7QUFDakQsY0FBYyx1REFBdUQsQ0FBQztBQUN0RSxjQUFjLHlEQUF5RCxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcclxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIG5nMi1pcS1zZWxlY3QyXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvaXEtc2VsZWN0Mi5tb2R1bGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9pcS1zZWxlY3QyL2lxLXNlbGVjdDIuY29tcG9uZW50JztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvaXEtc2VsZWN0Mi9pcS1zZWxlY3QyLWl0ZW0nO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9pcS1zZWxlY3QyLXJlc3VsdHMvaXEtc2VsZWN0Mi1yZXN1bHRzLmNvbXBvbmVudCc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2lxLXNlbGVjdDItdGVtcGxhdGUvaXEtc2VsZWN0Mi10ZW1wbGF0ZS5kaXJlY3RpdmUnO1xyXG4iXX0=
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, Input, Output, forwardRef,
|
|
2
|
+
import { EventEmitter, Component, ViewChild, Input, Output, forwardRef, Directive, Host, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i2 from '@angular/forms';
|
|
@@ -8,16 +8,24 @@ import { of } from 'rxjs';
|
|
|
8
8
|
import { debounceTime, distinctUntilChanged, tap, filter, switchMap, map, mergeMap } from 'rxjs/operators';
|
|
9
9
|
import { HttpClientModule } from '@angular/common/http';
|
|
10
10
|
|
|
11
|
+
class Messages {
|
|
12
|
+
static { this.VISIBLE_COUNT_VAR = '%VISIBLE_COUNT%'; }
|
|
13
|
+
static { this.MAX_COUNT_VAR = '%MAX_COUNT%'; }
|
|
14
|
+
static { this.MORE_RESULTS = 'Showing ' + this.VISIBLE_COUNT_VAR + ' of ' + this.MAX_COUNT_VAR + ' results. Refine your search to show more results.'; }
|
|
15
|
+
static { this.NO_RESULTS = 'No results available'; }
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
class IqSelect2ResultsComponent {
|
|
12
19
|
constructor() {
|
|
13
|
-
this.
|
|
20
|
+
this.items = [];
|
|
21
|
+
this.onItemSelected = new EventEmitter();
|
|
14
22
|
this.activeIndex = 0;
|
|
15
|
-
this.
|
|
23
|
+
this.usingKeys = false;
|
|
16
24
|
}
|
|
17
25
|
ngOnInit() {
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
this.
|
|
27
|
+
selectItem(item) {
|
|
28
|
+
this.onItemSelected.emit(item);
|
|
21
29
|
}
|
|
22
30
|
activeNext() {
|
|
23
31
|
if (this.activeIndex >= this.items.length - 1) {
|
|
@@ -27,7 +35,7 @@ class IqSelect2ResultsComponent {
|
|
|
27
35
|
this.activeIndex++;
|
|
28
36
|
}
|
|
29
37
|
this.scrollToElement();
|
|
30
|
-
this.
|
|
38
|
+
this.usingKeys = true;
|
|
31
39
|
}
|
|
32
40
|
activePrevious() {
|
|
33
41
|
if (this.activeIndex - 1 < 0) {
|
|
@@ -37,28 +45,27 @@ class IqSelect2ResultsComponent {
|
|
|
37
45
|
this.activeIndex--;
|
|
38
46
|
}
|
|
39
47
|
this.scrollToElement();
|
|
40
|
-
this.
|
|
48
|
+
this.usingKeys = true;
|
|
41
49
|
}
|
|
42
50
|
scrollToElement() {
|
|
43
51
|
const element = document.getElementById('item_' + this.activeIndex);
|
|
44
|
-
const container = document.getElementById('resultsContainer');
|
|
45
52
|
if (element) {
|
|
46
|
-
container.scrollTop = element.offsetTop;
|
|
53
|
+
this.container.nativeElement.scrollTop = element.offsetTop;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
selectCurrentItem() {
|
|
50
57
|
if (this.items[this.activeIndex]) {
|
|
51
|
-
this.
|
|
58
|
+
this.selectItem(this.items[this.activeIndex]);
|
|
52
59
|
this.activeIndex = 0;
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
onMouseOver(index) {
|
|
56
|
-
if (!this.
|
|
63
|
+
if (!this.usingKeys) {
|
|
57
64
|
this.activeIndex = index;
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
onHovering(event) {
|
|
61
|
-
this.
|
|
68
|
+
this.usingKeys = false;
|
|
62
69
|
}
|
|
63
70
|
isSelected(currentItem) {
|
|
64
71
|
let result = false;
|
|
@@ -69,32 +76,37 @@ class IqSelect2ResultsComponent {
|
|
|
69
76
|
});
|
|
70
77
|
return result;
|
|
71
78
|
}
|
|
79
|
+
getCountMessage() {
|
|
80
|
+
return this.messageMoreResults.replace(Messages.VISIBLE_COUNT_VAR, String(this.maxResults))
|
|
81
|
+
.replace(Messages.MAX_COUNT_VAR, String(this.items.length + this.selectedItems.length));
|
|
82
|
+
}
|
|
72
83
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2ResultsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
73
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2ResultsComponent, selector: "iq-select2-results", inputs: { items: "items",
|
|
84
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2ResultsComponent, selector: "iq-select2-results", inputs: { items: "items", maxResults: "maxResults", messageMoreResults: "messageMoreResults", messageNoResults: "messageNoResults", resultsVisible: "resultsVisible", selectedItems: "selectedItems", templateRef: "templateRef" }, outputs: { onItemSelected: "onItemSelected" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: "<div #container class=\"select2-dropdown\" [attr.data-visible]=\"resultsVisible\">\r\n <div *ngIf=\"maxResults && items.length + selectedItems.length > maxResults\" class=\"select2-message\">\r\n {{getCountMessage()}}\r\n </div>\r\n\r\n <div *ngIf=\"items.length === 0\" class=\"select2-message no-results\">\r\n {{messageNoResults}}\r\n </div>\r\n\r\n <div *ngFor=\"let item of items | slice:0:maxResults; let i = index;\" id=\"item_{{i}}\" [attr.data-item-id]=\"item.id\" [title]=\"item.text\"\r\n class=\"select2-dropdown-item\" [class.selected]=\"isSelected(item)\" [class.active]=\"i === activeIndex\"\r\n (mousedown)=\"selectItem(item)\" (mouseover)=\"onMouseOver(i)\" (mouseenter)=\"onHovering($event)\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{$item:item, $entity: item.entity, $id:item.id, $index:i}\"></ng-container>\r\n <ng-container *ngIf=\"!templateRef\">{{item.text}}</ng-container>\r\n </div>\r\n</div>\r\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:var(--select2-color-scrollbar-track)}::-webkit-scrollbar-thumb{background-color:var(--select2-color-scrollbar-thumb);border-radius:1em;border:transparent}.select2-dropdown{position:absolute;top:100%;width:100%;z-index:10;border:1px solid var(--select2-color-border);background-color:var(--select2-color-background);padding:.1em;max-height:20vh;overflow-x:hidden;overflow-y:auto}.select2-dropdown[data-visible=false]{display:none;visibility:hidden}.select2-message{font-size:.8em}.select2-dropdown-item{width:100%;padding:.2em;cursor:pointer;overflow-wrap:break-word;word-break:break-word}.selected{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-list-selected)}.active{color:var(--select2-color-item-text);background-color:var(--select2-color-list-active)}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.SlicePipe, name: "slice" }] }); }
|
|
74
85
|
}
|
|
75
86
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2ResultsComponent, decorators: [{
|
|
76
87
|
type: Component,
|
|
77
|
-
args: [{ selector: 'iq-select2-results', template: "<div class=\"select2-
|
|
78
|
-
}], ctorParameters: function () { return []; }, propDecorators: {
|
|
88
|
+
args: [{ selector: 'iq-select2-results', template: "<div #container class=\"select2-dropdown\" [attr.data-visible]=\"resultsVisible\">\r\n <div *ngIf=\"maxResults && items.length + selectedItems.length > maxResults\" class=\"select2-message\">\r\n {{getCountMessage()}}\r\n </div>\r\n\r\n <div *ngIf=\"items.length === 0\" class=\"select2-message no-results\">\r\n {{messageNoResults}}\r\n </div>\r\n\r\n <div *ngFor=\"let item of items | slice:0:maxResults; let i = index;\" id=\"item_{{i}}\" [attr.data-item-id]=\"item.id\" [title]=\"item.text\"\r\n class=\"select2-dropdown-item\" [class.selected]=\"isSelected(item)\" [class.active]=\"i === activeIndex\"\r\n (mousedown)=\"selectItem(item)\" (mouseover)=\"onMouseOver(i)\" (mouseenter)=\"onHovering($event)\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{$item:item, $entity: item.entity, $id:item.id, $index:i}\"></ng-container>\r\n <ng-container *ngIf=\"!templateRef\">{{item.text}}</ng-container>\r\n </div>\r\n</div>\r\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:var(--select2-color-scrollbar-track)}::-webkit-scrollbar-thumb{background-color:var(--select2-color-scrollbar-thumb);border-radius:1em;border:transparent}.select2-dropdown{position:absolute;top:100%;width:100%;z-index:10;border:1px solid var(--select2-color-border);background-color:var(--select2-color-background);padding:.1em;max-height:20vh;overflow-x:hidden;overflow-y:auto}.select2-dropdown[data-visible=false]{display:none;visibility:hidden}.select2-message{font-size:.8em}.select2-dropdown-item{width:100%;padding:.2em;cursor:pointer;overflow-wrap:break-word;word-break:break-word}.selected{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-list-selected)}.active{color:var(--select2-color-item-text);background-color:var(--select2-color-list-active)}\n"] }]
|
|
89
|
+
}], ctorParameters: function () { return []; }, propDecorators: { container: [{
|
|
90
|
+
type: ViewChild,
|
|
91
|
+
args: ['container']
|
|
92
|
+
}], items: [{
|
|
93
|
+
type: Input
|
|
94
|
+
}], maxResults: [{
|
|
95
|
+
type: Input
|
|
96
|
+
}], messageMoreResults: [{
|
|
97
|
+
type: Input
|
|
98
|
+
}], messageNoResults: [{
|
|
79
99
|
type: Input
|
|
80
|
-
}],
|
|
100
|
+
}], resultsVisible: [{
|
|
81
101
|
type: Input
|
|
82
102
|
}], selectedItems: [{
|
|
83
103
|
type: Input
|
|
84
104
|
}], templateRef: [{
|
|
85
105
|
type: Input
|
|
86
|
-
}],
|
|
106
|
+
}], onItemSelected: [{
|
|
87
107
|
type: Output
|
|
88
108
|
}] } });
|
|
89
109
|
|
|
90
|
-
/**
|
|
91
|
-
* Created by diego on 3/13/17.
|
|
92
|
-
*/
|
|
93
|
-
class Messages {
|
|
94
|
-
static { this.PARTIAL_COUNT_VAR = '%PARTIAL_COUNT%'; }
|
|
95
|
-
static { this.TOTAL_COUNT_VAR = '%TOTAL_COUNT%'; }
|
|
96
|
-
}
|
|
97
|
-
|
|
98
110
|
const KEY_CODE_DOWN_ARROW = 40;
|
|
99
111
|
const KEY_CODE_UP_ARROW = 38;
|
|
100
112
|
const KEY_CODE_ENTER = 13;
|
|
@@ -105,33 +117,31 @@ const VALUE_ACCESSOR = {
|
|
|
105
117
|
useExisting: forwardRef(() => IqSelect2Component),
|
|
106
118
|
multi: true
|
|
107
119
|
};
|
|
108
|
-
const noop = () => {
|
|
109
|
-
};
|
|
110
120
|
class IqSelect2Component {
|
|
111
121
|
constructor() {
|
|
112
|
-
this.MORE_RESULTS_MSG = 'Showing ' + Messages.PARTIAL_COUNT_VAR + ' of ' + Messages.TOTAL_COUNT_VAR + ' results. Refine your search to show more results.';
|
|
113
|
-
this.NO_RESULTS_MSG = 'No results available';
|
|
114
122
|
this.referenceMode = 'id';
|
|
115
123
|
this.multiple = false;
|
|
116
|
-
this.searchDelay = 250;
|
|
117
124
|
this.placeholder = '';
|
|
118
|
-
this.minimumInputLength = 2;
|
|
119
125
|
this.disabled = false;
|
|
120
|
-
this.messages = {
|
|
121
|
-
moreResultsAvailableMsg: this.MORE_RESULTS_MSG,
|
|
122
|
-
noResultsAvailableMsg: this.NO_RESULTS_MSG
|
|
123
|
-
};
|
|
124
126
|
this.clientMode = false;
|
|
125
127
|
this.badgeColor = 'info';
|
|
128
|
+
this.wrapSelectedText = 'nowrap';
|
|
129
|
+
this.debounceDelay = 250;
|
|
130
|
+
this.debounceLength = 2;
|
|
131
|
+
this.iconCaret = '▼';
|
|
132
|
+
this.iconDelete = '×';
|
|
133
|
+
this.messageMoreResults = Messages.MORE_RESULTS;
|
|
134
|
+
this.messageNoResults = Messages.NO_RESULTS;
|
|
126
135
|
this.onSelect = new EventEmitter();
|
|
127
136
|
this.onRemove = new EventEmitter();
|
|
128
137
|
this.term = new UntypedFormControl();
|
|
129
138
|
this.resultsVisible = false;
|
|
139
|
+
this.listData = [];
|
|
130
140
|
this.selectedItems = [];
|
|
131
141
|
this.searchFocused = false;
|
|
132
142
|
this.placeholderSelected = '';
|
|
133
|
-
this.onTouchedCallback =
|
|
134
|
-
this.onChangeCallback =
|
|
143
|
+
this.onTouchedCallback = () => false;
|
|
144
|
+
this.onChangeCallback = () => false;
|
|
135
145
|
}
|
|
136
146
|
ngAfterViewInit() {
|
|
137
147
|
this.subscribeToChangesAndLoadDataFromObservable();
|
|
@@ -160,11 +170,10 @@ class IqSelect2Component {
|
|
|
160
170
|
this.disabled = isDisabled;
|
|
161
171
|
}
|
|
162
172
|
subscribeToChangesAndLoadDataFromObservable() {
|
|
163
|
-
|
|
164
|
-
this.subscribeToResults(observable);
|
|
173
|
+
this.subscribeToResults(this.term.valueChanges.pipe(debounceTime(this.debounceDelay), distinctUntilChanged()));
|
|
165
174
|
}
|
|
166
175
|
subscribeToResults(observable) {
|
|
167
|
-
observable.pipe(tap(() => this.resultsVisible = false), filter((term) => term.length >= this.
|
|
176
|
+
observable.pipe(tap(() => this.resultsVisible = false), filter((term) => term.length >= this.debounceLength), switchMap(term => this.loadDataFromObservable(term)), map(items => items.filter(item => !(this.multiple && this.alreadySelected(item)))), tap(() => this.resultsVisible = this.searchFocused)).subscribe((items) => this.listData = items);
|
|
168
177
|
}
|
|
169
178
|
loadDataFromObservable(term) {
|
|
170
179
|
return this.clientMode ? this.fetchAndfilterLocalData(term) : this.fetchData(term);
|
|
@@ -187,15 +196,7 @@ class IqSelect2Component {
|
|
|
187
196
|
return item.text.toUpperCase().indexOf(term.toUpperCase()) !== -1;
|
|
188
197
|
}
|
|
189
198
|
fetchData(term) {
|
|
190
|
-
return this
|
|
191
|
-
.dataSourceProvider(term, this.buildValue())
|
|
192
|
-
.pipe(map((items) => this.adaptItems(items)));
|
|
193
|
-
}
|
|
194
|
-
adaptItems(items) {
|
|
195
|
-
const convertedItems = [];
|
|
196
|
-
items.map((item) => this.iqSelect2ItemAdapter(item))
|
|
197
|
-
.forEach((iqSelect2Item) => convertedItems.push(iqSelect2Item));
|
|
198
|
-
return convertedItems;
|
|
199
|
+
return this.dataSourceProvider(term, this.buildValue()).pipe(map((items) => items.map((item) => this.iqSelect2ItemAdapter(item))));
|
|
199
200
|
}
|
|
200
201
|
populateItemsFromEntities(selectedValues) {
|
|
201
202
|
if (this.multiple) {
|
|
@@ -281,9 +282,7 @@ class IqSelect2Component {
|
|
|
281
282
|
}
|
|
282
283
|
getSelectedIds() {
|
|
283
284
|
if (this.multiple) {
|
|
284
|
-
|
|
285
|
-
this.selectedItems.forEach(item => ids.push(item.id));
|
|
286
|
-
return ids;
|
|
285
|
+
return this.selectedItems.map(item => item.id);
|
|
287
286
|
}
|
|
288
287
|
else {
|
|
289
288
|
return this.selectedItems.length === 0 ? null : this.selectedItems[0].id;
|
|
@@ -291,11 +290,7 @@ class IqSelect2Component {
|
|
|
291
290
|
}
|
|
292
291
|
getEntities() {
|
|
293
292
|
if (this.multiple) {
|
|
294
|
-
|
|
295
|
-
this.selectedItems.forEach(item => {
|
|
296
|
-
entities.push(item.entity);
|
|
297
|
-
});
|
|
298
|
-
return entities;
|
|
293
|
+
return this.selectedItems.map(item => item.entity);
|
|
299
294
|
}
|
|
300
295
|
else {
|
|
301
296
|
return this.selectedItems.length === 0 ? null : this.selectedItems[0].entity;
|
|
@@ -351,7 +346,7 @@ class IqSelect2Component {
|
|
|
351
346
|
}
|
|
352
347
|
}
|
|
353
348
|
else {
|
|
354
|
-
if (this.
|
|
349
|
+
if (this.debounceLength === 0) {
|
|
355
350
|
if (ev.keyCode === KEY_CODE_ENTER || ev.keyCode === KEY_CODE_DOWN_ARROW) {
|
|
356
351
|
this.focusAndShowResults();
|
|
357
352
|
}
|
|
@@ -359,6 +354,9 @@ class IqSelect2Component {
|
|
|
359
354
|
}
|
|
360
355
|
}
|
|
361
356
|
onKeyDown(ev) {
|
|
357
|
+
if (ev.keyCode === KEY_CODE_ENTER) {
|
|
358
|
+
ev.preventDefault();
|
|
359
|
+
}
|
|
362
360
|
if (this.results) {
|
|
363
361
|
if (ev.keyCode === KEY_CODE_TAB) {
|
|
364
362
|
this.results.selectCurrentItem();
|
|
@@ -371,32 +369,15 @@ class IqSelect2Component {
|
|
|
371
369
|
}
|
|
372
370
|
}
|
|
373
371
|
}
|
|
374
|
-
onKeyPress(ev) {
|
|
375
|
-
if (ev.keyCode === KEY_CODE_ENTER) {
|
|
376
|
-
ev.preventDefault();
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
getCss() {
|
|
380
|
-
return 'select2-selection-container ' + (this.css === undefined ? '' : this.css);
|
|
381
|
-
}
|
|
382
372
|
getPlaceholder() {
|
|
383
373
|
return this.selectedItems.length > 0 ? this.placeholderSelected : this.placeholder;
|
|
384
374
|
}
|
|
385
|
-
getCountMessage() {
|
|
386
|
-
let msg = this.messages && this.messages.moreResultsAvailableMsg ? this.messages.moreResultsAvailableMsg : this.MORE_RESULTS_MSG;
|
|
387
|
-
msg = msg.replace(Messages.PARTIAL_COUNT_VAR, String(this.listData.length));
|
|
388
|
-
msg = msg.replace(Messages.TOTAL_COUNT_VAR, String(this.resultsCount - this.selectedItems.length));
|
|
389
|
-
return msg;
|
|
390
|
-
}
|
|
391
|
-
getBadgeColor() {
|
|
392
|
-
return this.multiple ? 'bg-' + this.badgeColor : '';
|
|
393
|
-
}
|
|
394
375
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2Component, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
395
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2Component, selector: "iq-select2", inputs: { dataSourceProvider: "dataSourceProvider", selectedProvider: "selectedProvider", iqSelect2ItemAdapter: "iqSelect2ItemAdapter", referenceMode: "referenceMode", multiple: "multiple",
|
|
376
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.4", type: IqSelect2Component, selector: "iq-select2", inputs: { dataSourceProvider: "dataSourceProvider", selectedProvider: "selectedProvider", iqSelect2ItemAdapter: "iqSelect2ItemAdapter", referenceMode: "referenceMode", multiple: "multiple", inputContainerClass: "inputContainerClass", placeholder: "placeholder", disabled: "disabled", maxResults: "maxResults", clientMode: "clientMode", badgeColor: "badgeColor", wrapSelectedText: "wrapSelectedText", debounceDelay: "debounceDelay", debounceLength: "debounceLength", iconCaret: "iconCaret", iconDelete: "iconDelete", messageMoreResults: "messageMoreResults", messageNoResults: "messageNoResults" }, outputs: { onSelect: "onSelect", onRemove: "onRemove" }, providers: [VALUE_ACCESSOR], viewQueries: [{ propertyName: "termInput", first: true, predicate: ["termInput"], descendants: true }, { propertyName: "results", first: true, predicate: ["results"], descendants: true }], ngImport: i0, template: "<div class=\"select2-container\">\r\n <div\r\n class=\"select2-inner-container\" [ngClass]=\"inputContainerClass ? inputContainerClass : ''\"\r\n [class.simple-selection]=\"!multiple\" [class.multiple-selection]=\"multiple\"\r\n [class.search-focused]=\"searchFocused\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!searchFocused || multiple\">\r\n <li *ngFor=\"let item of selectedItems\" class=\"select2-selected\">\r\n <span class=\"select2-selected-item\" [ngStyle]=\"{whitespace: wrapSelectedText}\" [title]=\"item.text\">{{item.text}}</span>\r\n <button *ngIf=\"!disabled\" class=\"select2-icon\" aria-label=\"Close\" (click)=\"removeItem(item)\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n </ng-container>\r\n\r\n <li class=\"select2-input-container\">\r\n <input #termInput *ngIf=\"!disabled\" [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\"\r\n [class.transparent]=\"!multiple && selectedItems.length > 0 && !searchFocused\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\"\r\n (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ul>\r\n\r\n <div *ngIf=\"(multiple || (!multiple && selectedItems.length === 0))\" class=\"select2-icon\">\r\n <span class=\"select2-selection-caret\" [innerHTML]=\"iconCaret\"></span>\r\n </div>\r\n </div>\r\n\r\n <iq-select2-results *ngIf=\"!disabled\" #results [resultsVisible]=\"resultsVisible\"\r\n [items]=\"listData\" [selectedItems]=\"selectedItems\" [maxResults]=\"maxResults\"\r\n [messageMoreResults]=\"messageMoreResults\" [messageNoResults]=\"messageNoResults\"\r\n [templateRef]=\"templateRef\" (onItemSelected)=\"onItemSelected($event);\"\r\n >\r\n </iq-select2-results>\r\n</div>\r\n", styles: [".select2-container{position:relative;width:100%;--select2-color-background: hsl(0, 0%, 96%);--select2-color-border: hsl(0, 0%, 90%);--select2-color-disabled: hsl(220, 20%, 90%);--select2-color-focused-border: hsl(220, 100%, 80%);--select2-color-focused-shadow: hsla(220, 80%, 40%);--select2-color-scrollbar-track: hsl(0, 0%, 90%);--select2-color-scrollbar-thumb: hsl(220, 25%, 25%);--select2-color-item-text: hsl(0, 0%, 96%);--select2-color-item-background: hsl(200, 90%, 50%);--select2-color-list-active: hsl(200, 70%, 70%);--select2-color-list-selected: hsl(200, 70%, 50%)}.select2-inner-container{display:grid;grid-template-columns:1fr min-content;gap:.2em}.select2-inner-container.search-focused{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-background);border-color:var(--select2-color-focused-border);outline:0;box-shadow:0 0 0 .1rem var(--select2-color-focused-shadow)}.simple-selection .select2-selection-container{display:grid;grid-auto-columns:100%}.simple-selection .select2-selection-container>*{grid-area:1 / 1}.simple-selection .select2-selected{width:100%;padding:0}.simple-selection input.transparent{opacity:0}.multiple-selection .select2-selected{color:var(--select2-color-item-text);background-color:var(--select2-color-item-background);padding:.1em .4em;border-radius:.25em;max-width:100%}.select2-selection-container{width:100%;display:flex;flex-flow:row wrap;align-items:baseline;justify-content:flex-start;gap:.2em;overflow:hidden;list-style-type:none;padding:0;margin:0}.select2-selected{display:inline-flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em;padding:.25em}.select2-input-container{flex-grow:1}.select2-input-container input{background-color:transparent;border:none;outline:none;padding:0;width:100%}.select2-icon{color:inherit;font-size:1em;z-index:5;display:grid}.select2-icon:is(button){background-color:transparent;border:0;outline:0;padding:0}:not(.readonly)>.select2-icon{cursor:pointer}.select2-selected-item{width:100%;overflow:hidden;text-overflow:ellipsis}.readonly{background-color:var(--select2-color-disabled);cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: IqSelect2ResultsComponent, selector: "iq-select2-results", inputs: ["items", "maxResults", "messageMoreResults", "messageNoResults", "resultsVisible", "selectedItems", "templateRef"], outputs: ["onItemSelected"] }] }); }
|
|
396
377
|
}
|
|
397
378
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: IqSelect2Component, decorators: [{
|
|
398
379
|
type: Component,
|
|
399
|
-
args: [{ selector: 'iq-select2', providers: [VALUE_ACCESSOR], template: "<div class=\"select2-container\">\r\n
|
|
380
|
+
args: [{ selector: 'iq-select2', providers: [VALUE_ACCESSOR], template: "<div class=\"select2-container\">\r\n <div\r\n class=\"select2-inner-container\" [ngClass]=\"inputContainerClass ? inputContainerClass : ''\"\r\n [class.simple-selection]=\"!multiple\" [class.multiple-selection]=\"multiple\"\r\n [class.search-focused]=\"searchFocused\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!searchFocused || multiple\">\r\n <li *ngFor=\"let item of selectedItems\" class=\"select2-selected\">\r\n <span class=\"select2-selected-item\" [ngStyle]=\"{whitespace: wrapSelectedText}\" [title]=\"item.text\">{{item.text}}</span>\r\n <button *ngIf=\"!disabled\" class=\"select2-icon\" aria-label=\"Close\" (click)=\"removeItem(item)\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n </ng-container>\r\n\r\n <li class=\"select2-input-container\">\r\n <input #termInput *ngIf=\"!disabled\" [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\"\r\n [class.transparent]=\"!multiple && selectedItems.length > 0 && !searchFocused\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\"\r\n (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ul>\r\n\r\n <div *ngIf=\"(multiple || (!multiple && selectedItems.length === 0))\" class=\"select2-icon\">\r\n <span class=\"select2-selection-caret\" [innerHTML]=\"iconCaret\"></span>\r\n </div>\r\n </div>\r\n\r\n <iq-select2-results *ngIf=\"!disabled\" #results [resultsVisible]=\"resultsVisible\"\r\n [items]=\"listData\" [selectedItems]=\"selectedItems\" [maxResults]=\"maxResults\"\r\n [messageMoreResults]=\"messageMoreResults\" [messageNoResults]=\"messageNoResults\"\r\n [templateRef]=\"templateRef\" (onItemSelected)=\"onItemSelected($event);\"\r\n >\r\n </iq-select2-results>\r\n</div>\r\n", styles: [".select2-container{position:relative;width:100%;--select2-color-background: hsl(0, 0%, 96%);--select2-color-border: hsl(0, 0%, 90%);--select2-color-disabled: hsl(220, 20%, 90%);--select2-color-focused-border: hsl(220, 100%, 80%);--select2-color-focused-shadow: hsla(220, 80%, 40%);--select2-color-scrollbar-track: hsl(0, 0%, 90%);--select2-color-scrollbar-thumb: hsl(220, 25%, 25%);--select2-color-item-text: hsl(0, 0%, 96%);--select2-color-item-background: hsl(200, 90%, 50%);--select2-color-list-active: hsl(200, 70%, 70%);--select2-color-list-selected: hsl(200, 70%, 50%)}.select2-inner-container{display:grid;grid-template-columns:1fr min-content;gap:.2em}.select2-inner-container.search-focused{color:invert(var(--select2-color-item-text));background-color:var(--select2-color-background);border-color:var(--select2-color-focused-border);outline:0;box-shadow:0 0 0 .1rem var(--select2-color-focused-shadow)}.simple-selection .select2-selection-container{display:grid;grid-auto-columns:100%}.simple-selection .select2-selection-container>*{grid-area:1 / 1}.simple-selection .select2-selected{width:100%;padding:0}.simple-selection input.transparent{opacity:0}.multiple-selection .select2-selected{color:var(--select2-color-item-text);background-color:var(--select2-color-item-background);padding:.1em .4em;border-radius:.25em;max-width:100%}.select2-selection-container{width:100%;display:flex;flex-flow:row wrap;align-items:baseline;justify-content:flex-start;gap:.2em;overflow:hidden;list-style-type:none;padding:0;margin:0}.select2-selected{display:inline-flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em;padding:.25em}.select2-input-container{flex-grow:1}.select2-input-container input{background-color:transparent;border:none;outline:none;padding:0;width:100%}.select2-icon{color:inherit;font-size:1em;z-index:5;display:grid}.select2-icon:is(button){background-color:transparent;border:0;outline:0;padding:0}:not(.readonly)>.select2-icon{cursor:pointer}.select2-selected-item{width:100%;overflow:hidden;text-overflow:ellipsis}.readonly{background-color:var(--select2-color-disabled);cursor:not-allowed}\n"] }]
|
|
400
381
|
}], ctorParameters: function () { return []; }, propDecorators: { dataSourceProvider: [{
|
|
401
382
|
type: Input
|
|
402
383
|
}], selectedProvider: [{
|
|
@@ -407,27 +388,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
407
388
|
type: Input
|
|
408
389
|
}], multiple: [{
|
|
409
390
|
type: Input
|
|
410
|
-
}],
|
|
411
|
-
type: Input
|
|
412
|
-
}], css: [{
|
|
391
|
+
}], inputContainerClass: [{
|
|
413
392
|
type: Input
|
|
414
393
|
}], placeholder: [{
|
|
415
394
|
type: Input
|
|
416
|
-
}], minimumInputLength: [{
|
|
417
|
-
type: Input
|
|
418
395
|
}], disabled: [{
|
|
419
396
|
type: Input
|
|
420
|
-
}],
|
|
397
|
+
}], maxResults: [{
|
|
421
398
|
type: Input
|
|
422
|
-
}],
|
|
399
|
+
}], clientMode: [{
|
|
423
400
|
type: Input
|
|
424
|
-
}],
|
|
401
|
+
}], badgeColor: [{
|
|
425
402
|
type: Input
|
|
426
|
-
}],
|
|
403
|
+
}], wrapSelectedText: [{
|
|
427
404
|
type: Input
|
|
428
|
-
}],
|
|
405
|
+
}], debounceDelay: [{
|
|
429
406
|
type: Input
|
|
430
|
-
}],
|
|
407
|
+
}], debounceLength: [{
|
|
408
|
+
type: Input
|
|
409
|
+
}], iconCaret: [{
|
|
410
|
+
type: Input
|
|
411
|
+
}], iconDelete: [{
|
|
412
|
+
type: Input
|
|
413
|
+
}], messageMoreResults: [{
|
|
414
|
+
type: Input
|
|
415
|
+
}], messageNoResults: [{
|
|
431
416
|
type: Input
|
|
432
417
|
}], onSelect: [{
|
|
433
418
|
type: Output
|
|
@@ -507,5 +492,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
507
492
|
* Generated bundle index. Do not edit.
|
|
508
493
|
*/
|
|
509
494
|
|
|
510
|
-
export { IqSelect2Component, IqSelect2Module, IqSelect2ResultsComponent, IqSelect2TemplateDirective
|
|
495
|
+
export { IqSelect2Component, IqSelect2Module, IqSelect2ResultsComponent, IqSelect2TemplateDirective };
|
|
511
496
|
//# sourceMappingURL=ng2-iq-select2-exe.mjs.map
|