ng2-iq-select2-exe 16.2.13 → 18.2.14
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/esm2022/lib/iq-select2/iq-select2-item.mjs +1 -1
- package/esm2022/lib/iq-select2/iq-select2.component.mjs +367 -367
- package/esm2022/lib/iq-select2/messages.mjs +6 -6
- package/esm2022/lib/iq-select2-results/iq-select2-results.component.mjs +96 -96
- package/esm2022/lib/iq-select2-template/iq-select2-template.directive.mjs +25 -25
- package/esm2022/lib/iq-select2.module.mjs +45 -45
- package/esm2022/ng2-iq-select2-exe.mjs +4 -4
- package/esm2022/public_api.mjs +8 -8
- package/fesm2022/ng2-iq-select2-exe.mjs +509 -509
- package/fesm2022/ng2-iq-select2-exe.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/iq-select2/iq-select2-item.d.ts +5 -5
- package/lib/iq-select2/iq-select2.component.d.ts +78 -78
- package/lib/iq-select2/messages.d.ts +6 -6
- package/lib/iq-select2-results/iq-select2-results.component.d.ts +29 -29
- package/lib/iq-select2-template/iq-select2-template.directive.d.ts +13 -13
- package/lib/iq-select2.module.d.ts +12 -12
- package/package.json +3 -3
- package/public_api.d.ts +5 -5
|
@@ -8,526 +8,526 @@ 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'; }
|
|
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
16
|
}
|
|
17
17
|
|
|
18
|
-
class IqSelect2ResultsComponent {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.items = [];
|
|
21
|
-
this.onItemSelected = new EventEmitter();
|
|
22
|
-
this.activeIndex = 0;
|
|
23
|
-
this.usingKeys = false;
|
|
24
|
-
}
|
|
25
|
-
ngOnInit() {
|
|
26
|
-
}
|
|
27
|
-
selectItem(item) {
|
|
28
|
-
this.onItemSelected.emit(item);
|
|
29
|
-
}
|
|
30
|
-
activeNext() {
|
|
31
|
-
if (this.activeIndex >= (this.maxResults ?? this.items.length) - 1) {
|
|
32
|
-
this.activeIndex = 0;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.activeIndex++;
|
|
36
|
-
}
|
|
37
|
-
this.scrollToElement();
|
|
38
|
-
this.usingKeys = true;
|
|
39
|
-
}
|
|
40
|
-
activePrevious() {
|
|
41
|
-
if (this.activeIndex - 1 < 0) {
|
|
42
|
-
this.activeIndex = this.items.length - 1;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.activeIndex--;
|
|
46
|
-
}
|
|
47
|
-
this.scrollToElement();
|
|
48
|
-
this.usingKeys = true;
|
|
49
|
-
}
|
|
50
|
-
scrollToElement() {
|
|
51
|
-
const element = document.getElementById('item_' + this.activeIndex);
|
|
52
|
-
if (element) {
|
|
53
|
-
this.container.nativeElement.scrollTop = element.offsetTop;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
selectCurrentItem() {
|
|
57
|
-
if (this.items[this.activeIndex]) {
|
|
58
|
-
this.selectItem(this.items[this.activeIndex]);
|
|
59
|
-
this.activeIndex = 0;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
onMouseOver(index) {
|
|
63
|
-
if (!this.usingKeys) {
|
|
64
|
-
this.activeIndex = index;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
onHovering(event) {
|
|
68
|
-
this.usingKeys = false;
|
|
69
|
-
}
|
|
70
|
-
isSelected(currentItem) {
|
|
71
|
-
let result = false;
|
|
72
|
-
this.selectedItems.forEach(item => {
|
|
73
|
-
if (item.id === currentItem.id) {
|
|
74
|
-
result = true;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return result;
|
|
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
|
-
}
|
|
83
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
84
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
85
|
-
}
|
|
86
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
87
|
-
type: Component,
|
|
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 (click)=\"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:100;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{width:100%;padding:.2em}.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:
|
|
90
|
-
type: ViewChild,
|
|
91
|
-
args: ['container']
|
|
92
|
-
}], items: [{
|
|
93
|
-
type: Input
|
|
94
|
-
}], maxResults: [{
|
|
95
|
-
type: Input
|
|
96
|
-
}], messageMoreResults: [{
|
|
97
|
-
type: Input
|
|
98
|
-
}], messageNoResults: [{
|
|
99
|
-
type: Input
|
|
100
|
-
}], resultsVisible: [{
|
|
101
|
-
type: Input
|
|
102
|
-
}], selectedItems: [{
|
|
103
|
-
type: Input
|
|
104
|
-
}], templateRef: [{
|
|
105
|
-
type: Input
|
|
106
|
-
}], onItemSelected: [{
|
|
107
|
-
type: Output
|
|
18
|
+
class IqSelect2ResultsComponent {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.items = [];
|
|
21
|
+
this.onItemSelected = new EventEmitter();
|
|
22
|
+
this.activeIndex = 0;
|
|
23
|
+
this.usingKeys = false;
|
|
24
|
+
}
|
|
25
|
+
ngOnInit() {
|
|
26
|
+
}
|
|
27
|
+
selectItem(item) {
|
|
28
|
+
this.onItemSelected.emit(item);
|
|
29
|
+
}
|
|
30
|
+
activeNext() {
|
|
31
|
+
if (this.activeIndex >= (this.maxResults ?? this.items.length) - 1) {
|
|
32
|
+
this.activeIndex = 0;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.activeIndex++;
|
|
36
|
+
}
|
|
37
|
+
this.scrollToElement();
|
|
38
|
+
this.usingKeys = true;
|
|
39
|
+
}
|
|
40
|
+
activePrevious() {
|
|
41
|
+
if (this.activeIndex - 1 < 0) {
|
|
42
|
+
this.activeIndex = this.items.length - 1;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.activeIndex--;
|
|
46
|
+
}
|
|
47
|
+
this.scrollToElement();
|
|
48
|
+
this.usingKeys = true;
|
|
49
|
+
}
|
|
50
|
+
scrollToElement() {
|
|
51
|
+
const element = document.getElementById('item_' + this.activeIndex);
|
|
52
|
+
if (element) {
|
|
53
|
+
this.container.nativeElement.scrollTop = element.offsetTop;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
selectCurrentItem() {
|
|
57
|
+
if (this.items[this.activeIndex]) {
|
|
58
|
+
this.selectItem(this.items[this.activeIndex]);
|
|
59
|
+
this.activeIndex = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
onMouseOver(index) {
|
|
63
|
+
if (!this.usingKeys) {
|
|
64
|
+
this.activeIndex = index;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
onHovering(event) {
|
|
68
|
+
this.usingKeys = false;
|
|
69
|
+
}
|
|
70
|
+
isSelected(currentItem) {
|
|
71
|
+
let result = false;
|
|
72
|
+
this.selectedItems.forEach(item => {
|
|
73
|
+
if (item.id === currentItem.id) {
|
|
74
|
+
result = true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return result;
|
|
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
|
+
}
|
|
83
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2ResultsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
84
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", 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 (click)=\"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:100;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{width:100%;padding:.2em}.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" }] }); }
|
|
85
|
+
}
|
|
86
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2ResultsComponent, decorators: [{
|
|
87
|
+
type: Component,
|
|
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 (click)=\"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:100;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{width:100%;padding:.2em}.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: () => [], 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: [{
|
|
99
|
+
type: Input
|
|
100
|
+
}], resultsVisible: [{
|
|
101
|
+
type: Input
|
|
102
|
+
}], selectedItems: [{
|
|
103
|
+
type: Input
|
|
104
|
+
}], templateRef: [{
|
|
105
|
+
type: Input
|
|
106
|
+
}], onItemSelected: [{
|
|
107
|
+
type: Output
|
|
108
108
|
}] } });
|
|
109
109
|
|
|
110
|
-
const KEY_CODE_DOWN_ARROW = 'ArrowDown';
|
|
111
|
-
const KEY_CODE_UP_ARROW = 'ArrowUp';
|
|
112
|
-
const KEY_CODE_ENTER = 'Enter';
|
|
113
|
-
const KEY_CODE_ESCAPE = 'Escape';
|
|
114
|
-
const KEY_CODE_DELETE = 'Delete';
|
|
115
|
-
class IqSelect2Component {
|
|
116
|
-
constructor() {
|
|
117
|
-
this.referenceMode = 'id';
|
|
118
|
-
this.multiple = false;
|
|
119
|
-
this.placeholder = '';
|
|
120
|
-
this.disabled = false;
|
|
121
|
-
this.clientMode = false;
|
|
122
|
-
this.badgeColor = 'info';
|
|
123
|
-
this.wrapSelectedText = 'nowrap';
|
|
124
|
-
this.preventDeselect = false;
|
|
125
|
-
this.consecutiveMultipleSelection = this.multiple;
|
|
126
|
-
this.debounceDelay = 250;
|
|
127
|
-
this.debounceLength = 2;
|
|
128
|
-
this.iconCaret = '▼';
|
|
129
|
-
this.iconDelete = '×';
|
|
130
|
-
this.messageMoreResults = Messages.MORE_RESULTS;
|
|
131
|
-
this.messageNoResults = Messages.NO_RESULTS;
|
|
132
|
-
this.onSelect = new EventEmitter();
|
|
133
|
-
this.onRemove = new EventEmitter();
|
|
134
|
-
this.term = new UntypedFormControl();
|
|
135
|
-
this.resultsVisible = false;
|
|
136
|
-
this.searchFocused = false;
|
|
137
|
-
this.listData = [];
|
|
138
|
-
this.selectedItems = [];
|
|
139
|
-
this.placeholderSelected = '';
|
|
140
|
-
this.onTouchedCallback = () => false;
|
|
141
|
-
this.onChangeCallback = () => false;
|
|
142
|
-
this.handleClickOutside = event => {
|
|
143
|
-
if (!this.container.nativeElement.contains(event.target)) {
|
|
144
|
-
this.resultsVisible = false;
|
|
145
|
-
this.searchFocused = false;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
ngAfterViewInit() {
|
|
150
|
-
this.subscribeToChangesAndLoadDataFromObservable();
|
|
151
|
-
document.addEventListener("mousedown", this.handleClickOutside);
|
|
152
|
-
}
|
|
153
|
-
ngOnDestroy() {
|
|
154
|
-
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
155
|
-
}
|
|
156
|
-
writeValue(selectedValues) {
|
|
157
|
-
if (selectedValues) {
|
|
158
|
-
if (this.referenceMode === 'id') {
|
|
159
|
-
this.populateItemsFromIds(selectedValues);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.populateItemsFromEntities(selectedValues);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
this.placeholderSelected = '';
|
|
167
|
-
this.selectedItems = [];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
registerOnChange(fn) {
|
|
171
|
-
this.onChangeCallback = fn;
|
|
172
|
-
}
|
|
173
|
-
registerOnTouched(fn) {
|
|
174
|
-
this.onTouchedCallback = fn;
|
|
175
|
-
}
|
|
176
|
-
setDisabledState(isDisabled) {
|
|
177
|
-
this.disabled = isDisabled;
|
|
178
|
-
}
|
|
179
|
-
subscribeToChangesAndLoadDataFromObservable() {
|
|
180
|
-
this.subscribeToResults(this.term.valueChanges.pipe(debounceTime(this.debounceDelay), distinctUntilChanged()));
|
|
181
|
-
}
|
|
182
|
-
subscribeToResults(observable) {
|
|
183
|
-
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);
|
|
184
|
-
}
|
|
185
|
-
loadDataFromObservable(term) {
|
|
186
|
-
return this.clientMode ? this.fetchAndFilterLocalData(term) : this.fetchData(term);
|
|
187
|
-
}
|
|
188
|
-
fetchAndFilterLocalData(term) {
|
|
189
|
-
if (!this.fullDataList) {
|
|
190
|
-
return this.fetchData('').pipe(mergeMap((items) => {
|
|
191
|
-
this.fullDataList = items;
|
|
192
|
-
return this.filterLocalData(term);
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
return this.filterLocalData(term);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
filterLocalData(term) {
|
|
200
|
-
return of(this.fullDataList.filter(item => item.text.toLowerCase().includes(term.toLowerCase())));
|
|
201
|
-
}
|
|
202
|
-
fetchData(term) {
|
|
203
|
-
return this.dataSourceProvider(term, this.buildValue()).pipe(map((items) => items.map((item) => this.iqSelect2ItemAdapter(item))));
|
|
204
|
-
}
|
|
205
|
-
populateItemsFromEntities(selectedValues) {
|
|
206
|
-
if (this.multiple) {
|
|
207
|
-
this.handleMultipleWithEntities(selectedValues);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
const iqSelect2Item = this.iqSelect2ItemAdapter(selectedValues);
|
|
211
|
-
this.selectedItems = [iqSelect2Item];
|
|
212
|
-
this.placeholderSelected = iqSelect2Item.text;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
handleMultipleWithEntities(selectedValues) {
|
|
216
|
-
this.selectedItems = [];
|
|
217
|
-
selectedValues.forEach((entity) => {
|
|
218
|
-
const item = this.iqSelect2ItemAdapter(entity);
|
|
219
|
-
const ids = this.getSelectedIds();
|
|
220
|
-
if (ids.indexOf(item.id) === -1) {
|
|
221
|
-
this.selectedItems.push(item);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
populateItemsFromIds(selectedValues) {
|
|
226
|
-
if (this.multiple) {
|
|
227
|
-
this.handleMultipleWithIds(selectedValues);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
this.handleSingleWithId(selectedValues);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
handleMultipleWithIds(selectedValues) {
|
|
234
|
-
if (selectedValues !== undefined && this.selectedProvider !== undefined) {
|
|
235
|
-
const uniqueIds = [];
|
|
236
|
-
selectedValues.forEach((id) => {
|
|
237
|
-
if (uniqueIds.indexOf(id) === -1) {
|
|
238
|
-
uniqueIds.push(id);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
this.selectedProvider(uniqueIds).subscribe((items) => {
|
|
242
|
-
this.selectedItems = items.map(this.iqSelect2ItemAdapter);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
handleSingleWithId(id) {
|
|
247
|
-
if (id !== undefined && this.selectedProvider !== undefined) {
|
|
248
|
-
this.selectedProvider([id]).subscribe((items) => {
|
|
249
|
-
items.forEach((item) => {
|
|
250
|
-
const iqSelect2Item = this.iqSelect2ItemAdapter(item);
|
|
251
|
-
this.selectedItems = [iqSelect2Item];
|
|
252
|
-
this.placeholderSelected = iqSelect2Item.text;
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
alreadySelected(item) {
|
|
258
|
-
let result = false;
|
|
259
|
-
this.selectedItems.forEach(selectedItem => {
|
|
260
|
-
if (selectedItem.id === item.id) {
|
|
261
|
-
result = true;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
return result;
|
|
265
|
-
}
|
|
266
|
-
onItemSelected(item) {
|
|
267
|
-
if (this.multiple) {
|
|
268
|
-
this.selectedItems.push(item);
|
|
269
|
-
const index = this.listData.indexOf(item, 0);
|
|
270
|
-
if (index > -1) {
|
|
271
|
-
this.listData.splice(index, 1);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
this.selectedItems.length = 0;
|
|
276
|
-
this.selectedItems.push(item);
|
|
277
|
-
}
|
|
278
|
-
this.onChangeCallback(this.buildValue());
|
|
279
|
-
this.term.patchValue('', { emitEvent: false });
|
|
280
|
-
if (this.multiple) {
|
|
281
|
-
if (!this.consecutiveMultipleSelection) {
|
|
282
|
-
this.afterItemSet();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else if (!this.multiple) {
|
|
286
|
-
this.placeholderSelected = item.text;
|
|
287
|
-
this.afterItemSet();
|
|
288
|
-
}
|
|
289
|
-
this.onSelect.emit(item);
|
|
290
|
-
}
|
|
291
|
-
getSelectedIds() {
|
|
292
|
-
if (this.multiple) {
|
|
293
|
-
return this.selectedItems.map(item => item.id);
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
return this.selectedItems.length === 0 ? null : this.selectedItems[0].id;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
getEntities() {
|
|
300
|
-
if (this.multiple) {
|
|
301
|
-
return this.selectedItems.map(item => item.entity);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
return this.selectedItems.length === 0 ? null : this.selectedItems[0].entity;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
removeItem(item) {
|
|
308
|
-
const index = this.selectedItems.indexOf(item, 0);
|
|
309
|
-
if (index > -1) {
|
|
310
|
-
this.selectedItems.splice(index, 1);
|
|
311
|
-
}
|
|
312
|
-
this.onChangeCallback(this.buildValue());
|
|
313
|
-
this.onRemove.emit(item);
|
|
314
|
-
if (!this.multiple) {
|
|
315
|
-
this.placeholderSelected = '';
|
|
316
|
-
}
|
|
317
|
-
this.afterItemSet();
|
|
318
|
-
}
|
|
319
|
-
afterItemSet() {
|
|
320
|
-
this.searchFocused = false;
|
|
321
|
-
this.resultsVisible = false;
|
|
322
|
-
this.termInput.nativeElement.blur();
|
|
323
|
-
}
|
|
324
|
-
buildValue() {
|
|
325
|
-
return 'id' === this.referenceMode ? this.getSelectedIds() : this.getEntities();
|
|
326
|
-
}
|
|
327
|
-
onFocus() {
|
|
328
|
-
this.searchFocused = true;
|
|
329
|
-
}
|
|
330
|
-
onBlur() {
|
|
331
|
-
this.term.patchValue('', { emitEvent: false });
|
|
332
|
-
this.onTouchedCallback();
|
|
333
|
-
}
|
|
334
|
-
focus() {
|
|
335
|
-
if (!this.disabled) {
|
|
336
|
-
this.termInput.nativeElement.focus();
|
|
337
|
-
this.resultsVisible = false;
|
|
338
|
-
}
|
|
339
|
-
this.searchFocused = !this.disabled;
|
|
340
|
-
}
|
|
341
|
-
focusAndShowResults() {
|
|
342
|
-
if (!this.disabled) {
|
|
343
|
-
this.termInput.nativeElement.focus();
|
|
344
|
-
this.subscribeToResults(of(''));
|
|
345
|
-
}
|
|
346
|
-
this.searchFocused = !this.disabled;
|
|
347
|
-
}
|
|
348
|
-
onKeyUp(event) {
|
|
349
|
-
if (this.results) {
|
|
350
|
-
if (event.key === KEY_CODE_ENTER) {
|
|
351
|
-
this.results.selectCurrentItem();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
if (this.debounceLength === 0) {
|
|
356
|
-
if (event.key === KEY_CODE_ENTER || event.key === KEY_CODE_DOWN_ARROW) {
|
|
357
|
-
this.focusAndShowResults();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
onKeyDown(event) {
|
|
363
|
-
if (event.key === KEY_CODE_ENTER) {
|
|
364
|
-
event.preventDefault();
|
|
365
|
-
}
|
|
366
|
-
if (!this.resultsVisible && event.key.includes('Arrow')) {
|
|
367
|
-
this.resultsVisible = true;
|
|
368
|
-
}
|
|
369
|
-
if (event.key === KEY_CODE_ESCAPE) {
|
|
370
|
-
this.resultsVisible = false;
|
|
371
|
-
}
|
|
372
|
-
if (event.key === KEY_CODE_DELETE) {
|
|
373
|
-
const textEntered = !this.term.value || this.term.value.length === 0;
|
|
374
|
-
if (textEntered && this.selectedItems.length > 0) {
|
|
375
|
-
this.removeItem(this.selectedItems[this.selectedItems.length - 1]);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (this.results) {
|
|
379
|
-
if (event.key === KEY_CODE_DOWN_ARROW) {
|
|
380
|
-
this.results.activeNext();
|
|
381
|
-
}
|
|
382
|
-
else if (event.key === KEY_CODE_UP_ARROW) {
|
|
383
|
-
this.results.activePrevious();
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
getPlaceholder() {
|
|
388
|
-
if (this.selectedItems.length > 0) {
|
|
389
|
-
if (!this.multiple && !this.searchFocused) {
|
|
390
|
-
return '';
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
return this.placeholderSelected;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return this.placeholder;
|
|
397
|
-
}
|
|
398
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
399
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
400
|
-
provide: NG_VALUE_ACCESSOR,
|
|
401
|
-
useExisting: forwardRef(() => IqSelect2Component),
|
|
402
|
-
multi: true
|
|
403
|
-
}], viewQueries: [{ propertyName: "container", first: true, predicate: ["selectContainer"], descendants: true }, { propertyName: "termInput", first: true, predicate: ["termInput"], descendants: true }, { propertyName: "results", first: true, predicate: ["results"], descendants: true }], ngImport: i0, template: "<div #selectContainer 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\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!multiple; then input\"></ng-container>\r\n\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 type=\"button\" *ngIf=\"!preventDeselect && !disabled\" class=\"select2-icon select2-remove-button\" (click)=\"removeItem(item); $event.stopPropagation()\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n\r\n <ng-container *ngIf=\"multiple; then input\"></ng-container>\r\n\r\n <ng-template #input>\r\n <li *ngIf=\"!disabled\" class=\"select2-input-container\">\r\n <input #termInput [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\" autocomplete=\"off\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\" (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ng-template>\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:flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em
|
|
404
|
-
}
|
|
405
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
406
|
-
type: Component,
|
|
407
|
-
args: [{ selector: 'iq-select2', providers: [{
|
|
408
|
-
provide: NG_VALUE_ACCESSOR,
|
|
409
|
-
useExisting: forwardRef(() => IqSelect2Component),
|
|
410
|
-
multi: true
|
|
411
|
-
}], template: "<div #selectContainer 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\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!multiple; then input\"></ng-container>\r\n\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 type=\"button\" *ngIf=\"!preventDeselect && !disabled\" class=\"select2-icon select2-remove-button\" (click)=\"removeItem(item); $event.stopPropagation()\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n\r\n <ng-container *ngIf=\"multiple; then input\"></ng-container>\r\n\r\n <ng-template #input>\r\n <li *ngIf=\"!disabled\" class=\"select2-input-container\">\r\n <input #termInput [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\" autocomplete=\"off\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\" (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ng-template>\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:flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em
|
|
412
|
-
}], ctorParameters:
|
|
413
|
-
type: Input
|
|
414
|
-
}], selectedProvider: [{
|
|
415
|
-
type: Input
|
|
416
|
-
}], iqSelect2ItemAdapter: [{
|
|
417
|
-
type: Input
|
|
418
|
-
}], referenceMode: [{
|
|
419
|
-
type: Input
|
|
420
|
-
}], multiple: [{
|
|
421
|
-
type: Input
|
|
422
|
-
}], inputContainerClass: [{
|
|
423
|
-
type: Input
|
|
424
|
-
}], placeholder: [{
|
|
425
|
-
type: Input
|
|
426
|
-
}], disabled: [{
|
|
427
|
-
type: Input
|
|
428
|
-
}], maxResults: [{
|
|
429
|
-
type: Input
|
|
430
|
-
}], clientMode: [{
|
|
431
|
-
type: Input
|
|
432
|
-
}], badgeColor: [{
|
|
433
|
-
type: Input
|
|
434
|
-
}], wrapSelectedText: [{
|
|
435
|
-
type: Input
|
|
436
|
-
}], preventDeselect: [{
|
|
437
|
-
type: Input
|
|
438
|
-
}], consecutiveMultipleSelection: [{
|
|
439
|
-
type: Input
|
|
440
|
-
}], debounceDelay: [{
|
|
441
|
-
type: Input
|
|
442
|
-
}], debounceLength: [{
|
|
443
|
-
type: Input
|
|
444
|
-
}], iconCaret: [{
|
|
445
|
-
type: Input
|
|
446
|
-
}], iconDelete: [{
|
|
447
|
-
type: Input
|
|
448
|
-
}], messageMoreResults: [{
|
|
449
|
-
type: Input
|
|
450
|
-
}], messageNoResults: [{
|
|
451
|
-
type: Input
|
|
452
|
-
}], onSelect: [{
|
|
453
|
-
type: Output
|
|
454
|
-
}], onRemove: [{
|
|
455
|
-
type: Output
|
|
456
|
-
}], container: [{
|
|
457
|
-
type: ViewChild,
|
|
458
|
-
args: ['selectContainer']
|
|
459
|
-
}], termInput: [{
|
|
460
|
-
type: ViewChild,
|
|
461
|
-
args: ['termInput']
|
|
462
|
-
}], results: [{
|
|
463
|
-
type: ViewChild,
|
|
464
|
-
args: ['results']
|
|
110
|
+
const KEY_CODE_DOWN_ARROW = 'ArrowDown';
|
|
111
|
+
const KEY_CODE_UP_ARROW = 'ArrowUp';
|
|
112
|
+
const KEY_CODE_ENTER = 'Enter';
|
|
113
|
+
const KEY_CODE_ESCAPE = 'Escape';
|
|
114
|
+
const KEY_CODE_DELETE = 'Delete';
|
|
115
|
+
class IqSelect2Component {
|
|
116
|
+
constructor() {
|
|
117
|
+
this.referenceMode = 'id';
|
|
118
|
+
this.multiple = false;
|
|
119
|
+
this.placeholder = '';
|
|
120
|
+
this.disabled = false;
|
|
121
|
+
this.clientMode = false;
|
|
122
|
+
this.badgeColor = 'info';
|
|
123
|
+
this.wrapSelectedText = 'nowrap';
|
|
124
|
+
this.preventDeselect = false;
|
|
125
|
+
this.consecutiveMultipleSelection = this.multiple;
|
|
126
|
+
this.debounceDelay = 250;
|
|
127
|
+
this.debounceLength = 2;
|
|
128
|
+
this.iconCaret = '▼';
|
|
129
|
+
this.iconDelete = '×';
|
|
130
|
+
this.messageMoreResults = Messages.MORE_RESULTS;
|
|
131
|
+
this.messageNoResults = Messages.NO_RESULTS;
|
|
132
|
+
this.onSelect = new EventEmitter();
|
|
133
|
+
this.onRemove = new EventEmitter();
|
|
134
|
+
this.term = new UntypedFormControl();
|
|
135
|
+
this.resultsVisible = false;
|
|
136
|
+
this.searchFocused = false;
|
|
137
|
+
this.listData = [];
|
|
138
|
+
this.selectedItems = [];
|
|
139
|
+
this.placeholderSelected = '';
|
|
140
|
+
this.onTouchedCallback = () => false;
|
|
141
|
+
this.onChangeCallback = () => false;
|
|
142
|
+
this.handleClickOutside = event => {
|
|
143
|
+
if (!this.container.nativeElement.contains(event.target)) {
|
|
144
|
+
this.resultsVisible = false;
|
|
145
|
+
this.searchFocused = false;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
ngAfterViewInit() {
|
|
150
|
+
this.subscribeToChangesAndLoadDataFromObservable();
|
|
151
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
152
|
+
}
|
|
153
|
+
ngOnDestroy() {
|
|
154
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
155
|
+
}
|
|
156
|
+
writeValue(selectedValues) {
|
|
157
|
+
if (selectedValues) {
|
|
158
|
+
if (this.referenceMode === 'id') {
|
|
159
|
+
this.populateItemsFromIds(selectedValues);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.populateItemsFromEntities(selectedValues);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.placeholderSelected = '';
|
|
167
|
+
this.selectedItems = [];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
registerOnChange(fn) {
|
|
171
|
+
this.onChangeCallback = fn;
|
|
172
|
+
}
|
|
173
|
+
registerOnTouched(fn) {
|
|
174
|
+
this.onTouchedCallback = fn;
|
|
175
|
+
}
|
|
176
|
+
setDisabledState(isDisabled) {
|
|
177
|
+
this.disabled = isDisabled;
|
|
178
|
+
}
|
|
179
|
+
subscribeToChangesAndLoadDataFromObservable() {
|
|
180
|
+
this.subscribeToResults(this.term.valueChanges.pipe(debounceTime(this.debounceDelay), distinctUntilChanged()));
|
|
181
|
+
}
|
|
182
|
+
subscribeToResults(observable) {
|
|
183
|
+
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);
|
|
184
|
+
}
|
|
185
|
+
loadDataFromObservable(term) {
|
|
186
|
+
return this.clientMode ? this.fetchAndFilterLocalData(term) : this.fetchData(term);
|
|
187
|
+
}
|
|
188
|
+
fetchAndFilterLocalData(term) {
|
|
189
|
+
if (!this.fullDataList) {
|
|
190
|
+
return this.fetchData('').pipe(mergeMap((items) => {
|
|
191
|
+
this.fullDataList = items;
|
|
192
|
+
return this.filterLocalData(term);
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return this.filterLocalData(term);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
filterLocalData(term) {
|
|
200
|
+
return of(this.fullDataList.filter(item => item.text.toLowerCase().includes(term.toLowerCase())));
|
|
201
|
+
}
|
|
202
|
+
fetchData(term) {
|
|
203
|
+
return this.dataSourceProvider(term, this.buildValue()).pipe(map((items) => items.map((item) => this.iqSelect2ItemAdapter(item))));
|
|
204
|
+
}
|
|
205
|
+
populateItemsFromEntities(selectedValues) {
|
|
206
|
+
if (this.multiple) {
|
|
207
|
+
this.handleMultipleWithEntities(selectedValues);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const iqSelect2Item = this.iqSelect2ItemAdapter(selectedValues);
|
|
211
|
+
this.selectedItems = [iqSelect2Item];
|
|
212
|
+
this.placeholderSelected = iqSelect2Item.text;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
handleMultipleWithEntities(selectedValues) {
|
|
216
|
+
this.selectedItems = [];
|
|
217
|
+
selectedValues.forEach((entity) => {
|
|
218
|
+
const item = this.iqSelect2ItemAdapter(entity);
|
|
219
|
+
const ids = this.getSelectedIds();
|
|
220
|
+
if (ids.indexOf(item.id) === -1) {
|
|
221
|
+
this.selectedItems.push(item);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
populateItemsFromIds(selectedValues) {
|
|
226
|
+
if (this.multiple) {
|
|
227
|
+
this.handleMultipleWithIds(selectedValues);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.handleSingleWithId(selectedValues);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
handleMultipleWithIds(selectedValues) {
|
|
234
|
+
if (selectedValues !== undefined && this.selectedProvider !== undefined) {
|
|
235
|
+
const uniqueIds = [];
|
|
236
|
+
selectedValues.forEach((id) => {
|
|
237
|
+
if (uniqueIds.indexOf(id) === -1) {
|
|
238
|
+
uniqueIds.push(id);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
this.selectedProvider(uniqueIds).subscribe((items) => {
|
|
242
|
+
this.selectedItems = items.map(this.iqSelect2ItemAdapter);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
handleSingleWithId(id) {
|
|
247
|
+
if (id !== undefined && this.selectedProvider !== undefined) {
|
|
248
|
+
this.selectedProvider([id]).subscribe((items) => {
|
|
249
|
+
items.forEach((item) => {
|
|
250
|
+
const iqSelect2Item = this.iqSelect2ItemAdapter(item);
|
|
251
|
+
this.selectedItems = [iqSelect2Item];
|
|
252
|
+
this.placeholderSelected = iqSelect2Item.text;
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
alreadySelected(item) {
|
|
258
|
+
let result = false;
|
|
259
|
+
this.selectedItems.forEach(selectedItem => {
|
|
260
|
+
if (selectedItem.id === item.id) {
|
|
261
|
+
result = true;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
onItemSelected(item) {
|
|
267
|
+
if (this.multiple) {
|
|
268
|
+
this.selectedItems.push(item);
|
|
269
|
+
const index = this.listData.indexOf(item, 0);
|
|
270
|
+
if (index > -1) {
|
|
271
|
+
this.listData.splice(index, 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this.selectedItems.length = 0;
|
|
276
|
+
this.selectedItems.push(item);
|
|
277
|
+
}
|
|
278
|
+
this.onChangeCallback(this.buildValue());
|
|
279
|
+
this.term.patchValue('', { emitEvent: false });
|
|
280
|
+
if (this.multiple) {
|
|
281
|
+
if (!this.consecutiveMultipleSelection) {
|
|
282
|
+
this.afterItemSet();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (!this.multiple) {
|
|
286
|
+
this.placeholderSelected = item.text;
|
|
287
|
+
this.afterItemSet();
|
|
288
|
+
}
|
|
289
|
+
this.onSelect.emit(item);
|
|
290
|
+
}
|
|
291
|
+
getSelectedIds() {
|
|
292
|
+
if (this.multiple) {
|
|
293
|
+
return this.selectedItems.map(item => item.id);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
return this.selectedItems.length === 0 ? null : this.selectedItems[0].id;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
getEntities() {
|
|
300
|
+
if (this.multiple) {
|
|
301
|
+
return this.selectedItems.map(item => item.entity);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
return this.selectedItems.length === 0 ? null : this.selectedItems[0].entity;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
removeItem(item) {
|
|
308
|
+
const index = this.selectedItems.indexOf(item, 0);
|
|
309
|
+
if (index > -1) {
|
|
310
|
+
this.selectedItems.splice(index, 1);
|
|
311
|
+
}
|
|
312
|
+
this.onChangeCallback(this.buildValue());
|
|
313
|
+
this.onRemove.emit(item);
|
|
314
|
+
if (!this.multiple) {
|
|
315
|
+
this.placeholderSelected = '';
|
|
316
|
+
}
|
|
317
|
+
this.afterItemSet();
|
|
318
|
+
}
|
|
319
|
+
afterItemSet() {
|
|
320
|
+
this.searchFocused = false;
|
|
321
|
+
this.resultsVisible = false;
|
|
322
|
+
this.termInput.nativeElement.blur();
|
|
323
|
+
}
|
|
324
|
+
buildValue() {
|
|
325
|
+
return 'id' === this.referenceMode ? this.getSelectedIds() : this.getEntities();
|
|
326
|
+
}
|
|
327
|
+
onFocus() {
|
|
328
|
+
this.searchFocused = true;
|
|
329
|
+
}
|
|
330
|
+
onBlur() {
|
|
331
|
+
this.term.patchValue('', { emitEvent: false });
|
|
332
|
+
this.onTouchedCallback();
|
|
333
|
+
}
|
|
334
|
+
focus() {
|
|
335
|
+
if (!this.disabled) {
|
|
336
|
+
this.termInput.nativeElement.focus();
|
|
337
|
+
this.resultsVisible = false;
|
|
338
|
+
}
|
|
339
|
+
this.searchFocused = !this.disabled;
|
|
340
|
+
}
|
|
341
|
+
focusAndShowResults() {
|
|
342
|
+
if (!this.disabled) {
|
|
343
|
+
this.termInput.nativeElement.focus();
|
|
344
|
+
this.subscribeToResults(of(''));
|
|
345
|
+
}
|
|
346
|
+
this.searchFocused = !this.disabled;
|
|
347
|
+
}
|
|
348
|
+
onKeyUp(event) {
|
|
349
|
+
if (this.results) {
|
|
350
|
+
if (event.key === KEY_CODE_ENTER) {
|
|
351
|
+
this.results.selectCurrentItem();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
if (this.debounceLength === 0) {
|
|
356
|
+
if (event.key === KEY_CODE_ENTER || event.key === KEY_CODE_DOWN_ARROW) {
|
|
357
|
+
this.focusAndShowResults();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
onKeyDown(event) {
|
|
363
|
+
if (event.key === KEY_CODE_ENTER) {
|
|
364
|
+
event.preventDefault();
|
|
365
|
+
}
|
|
366
|
+
if (!this.resultsVisible && event.key.includes('Arrow')) {
|
|
367
|
+
this.resultsVisible = true;
|
|
368
|
+
}
|
|
369
|
+
if (event.key === KEY_CODE_ESCAPE) {
|
|
370
|
+
this.resultsVisible = false;
|
|
371
|
+
}
|
|
372
|
+
if (event.key === KEY_CODE_DELETE) {
|
|
373
|
+
const textEntered = !this.term.value || this.term.value.length === 0;
|
|
374
|
+
if (textEntered && this.selectedItems.length > 0) {
|
|
375
|
+
this.removeItem(this.selectedItems[this.selectedItems.length - 1]);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (this.results) {
|
|
379
|
+
if (event.key === KEY_CODE_DOWN_ARROW) {
|
|
380
|
+
this.results.activeNext();
|
|
381
|
+
}
|
|
382
|
+
else if (event.key === KEY_CODE_UP_ARROW) {
|
|
383
|
+
this.results.activePrevious();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
getPlaceholder() {
|
|
388
|
+
if (this.selectedItems.length > 0) {
|
|
389
|
+
if (!this.multiple && !this.searchFocused) {
|
|
390
|
+
return '';
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
return this.placeholderSelected;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return this.placeholder;
|
|
397
|
+
}
|
|
398
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Component, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
399
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", 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", preventDeselect: "preventDeselect", consecutiveMultipleSelection: "consecutiveMultipleSelection", debounceDelay: "debounceDelay", debounceLength: "debounceLength", iconCaret: "iconCaret", iconDelete: "iconDelete", messageMoreResults: "messageMoreResults", messageNoResults: "messageNoResults" }, outputs: { onSelect: "onSelect", onRemove: "onRemove" }, providers: [{
|
|
400
|
+
provide: NG_VALUE_ACCESSOR,
|
|
401
|
+
useExisting: forwardRef(() => IqSelect2Component),
|
|
402
|
+
multi: true
|
|
403
|
+
}], viewQueries: [{ propertyName: "container", first: true, predicate: ["selectContainer"], descendants: true }, { propertyName: "termInput", first: true, predicate: ["termInput"], descendants: true }, { propertyName: "results", first: true, predicate: ["results"], descendants: true }], ngImport: i0, template: "<div #selectContainer 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\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!multiple; then input\"></ng-container>\r\n\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 type=\"button\" *ngIf=\"!preventDeselect && !disabled\" class=\"select2-icon select2-remove-button\" (click)=\"removeItem(item); $event.stopPropagation()\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n\r\n <ng-container *ngIf=\"multiple; then input\"></ng-container>\r\n\r\n <ng-template #input>\r\n <li *ngIf=\"!disabled\" class=\"select2-input-container\">\r\n <input #termInput [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\" autocomplete=\"off\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\" (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ng-template>\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:flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em;&:focus-within{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%;padding-right:.1em;>*{grid-area:1 / 1}}&:focus-within{.select2-selected-item{opacity:0}}.select2-selected{width:100%;padding: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;& input{background-color:transparent;border:none;outline:none;padding:0;width:100%}}.select2-icon{color:inherit;font-size:1em;width:1em;height:1em;z-index:10;display:grid;place-content:center;&:is(button){background-color:transparent;border:0;outline:0;&:focus{border:1px solid var(--select2-color-focused-border);border-radius:50%;box-shadow:0 0 0 .1rem var(--select2-color-focused-shadow)}}}: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"] }] }); }
|
|
404
|
+
}
|
|
405
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Component, decorators: [{
|
|
406
|
+
type: Component,
|
|
407
|
+
args: [{ selector: 'iq-select2', providers: [{
|
|
408
|
+
provide: NG_VALUE_ACCESSOR,
|
|
409
|
+
useExisting: forwardRef(() => IqSelect2Component),
|
|
410
|
+
multi: true
|
|
411
|
+
}], template: "<div #selectContainer 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\" [class.readonly]=\"disabled\"\r\n (click)=\"focusAndShowResults()\"\r\n >\r\n <ul class=\"select2-selection-container\">\r\n <ng-container *ngIf=\"!multiple; then input\"></ng-container>\r\n\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 type=\"button\" *ngIf=\"!preventDeselect && !disabled\" class=\"select2-icon select2-remove-button\" (click)=\"removeItem(item); $event.stopPropagation()\">\r\n <span class=\"select2-selection-remove\" [innerHTML]=\"iconDelete\"></span>\r\n </button>\r\n </li>\r\n\r\n <ng-container *ngIf=\"multiple; then input\"></ng-container>\r\n\r\n <ng-template #input>\r\n <li *ngIf=\"!disabled\" class=\"select2-input-container\">\r\n <input #termInput [formControl]=\"term\" type=\"text\" [placeholder]=\"getPlaceholder()\" autocomplete=\"off\"\r\n (focus)=\"onFocus()\" (blur)=\"onBlur()\" (keyup)=\"onKeyUp($event)\" (keydown)=\"onKeyDown($event)\"\r\n />\r\n </li>\r\n </ng-template>\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:flex;flex-flow:row nowrap;align-items:baseline;justify-content:space-between;gap:.2em;&:focus-within{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%;padding-right:.1em;>*{grid-area:1 / 1}}&:focus-within{.select2-selected-item{opacity:0}}.select2-selected{width:100%;padding: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;& input{background-color:transparent;border:none;outline:none;padding:0;width:100%}}.select2-icon{color:inherit;font-size:1em;width:1em;height:1em;z-index:10;display:grid;place-content:center;&:is(button){background-color:transparent;border:0;outline:0;&:focus{border:1px solid var(--select2-color-focused-border);border-radius:50%;box-shadow:0 0 0 .1rem var(--select2-color-focused-shadow)}}}: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"] }]
|
|
412
|
+
}], ctorParameters: () => [], propDecorators: { dataSourceProvider: [{
|
|
413
|
+
type: Input
|
|
414
|
+
}], selectedProvider: [{
|
|
415
|
+
type: Input
|
|
416
|
+
}], iqSelect2ItemAdapter: [{
|
|
417
|
+
type: Input
|
|
418
|
+
}], referenceMode: [{
|
|
419
|
+
type: Input
|
|
420
|
+
}], multiple: [{
|
|
421
|
+
type: Input
|
|
422
|
+
}], inputContainerClass: [{
|
|
423
|
+
type: Input
|
|
424
|
+
}], placeholder: [{
|
|
425
|
+
type: Input
|
|
426
|
+
}], disabled: [{
|
|
427
|
+
type: Input
|
|
428
|
+
}], maxResults: [{
|
|
429
|
+
type: Input
|
|
430
|
+
}], clientMode: [{
|
|
431
|
+
type: Input
|
|
432
|
+
}], badgeColor: [{
|
|
433
|
+
type: Input
|
|
434
|
+
}], wrapSelectedText: [{
|
|
435
|
+
type: Input
|
|
436
|
+
}], preventDeselect: [{
|
|
437
|
+
type: Input
|
|
438
|
+
}], consecutiveMultipleSelection: [{
|
|
439
|
+
type: Input
|
|
440
|
+
}], debounceDelay: [{
|
|
441
|
+
type: Input
|
|
442
|
+
}], debounceLength: [{
|
|
443
|
+
type: Input
|
|
444
|
+
}], iconCaret: [{
|
|
445
|
+
type: Input
|
|
446
|
+
}], iconDelete: [{
|
|
447
|
+
type: Input
|
|
448
|
+
}], messageMoreResults: [{
|
|
449
|
+
type: Input
|
|
450
|
+
}], messageNoResults: [{
|
|
451
|
+
type: Input
|
|
452
|
+
}], onSelect: [{
|
|
453
|
+
type: Output
|
|
454
|
+
}], onRemove: [{
|
|
455
|
+
type: Output
|
|
456
|
+
}], container: [{
|
|
457
|
+
type: ViewChild,
|
|
458
|
+
args: ['selectContainer']
|
|
459
|
+
}], termInput: [{
|
|
460
|
+
type: ViewChild,
|
|
461
|
+
args: ['termInput']
|
|
462
|
+
}], results: [{
|
|
463
|
+
type: ViewChild,
|
|
464
|
+
args: ['results']
|
|
465
465
|
}] } });
|
|
466
466
|
|
|
467
|
-
/**
|
|
468
|
-
* @author:msms
|
|
469
|
-
* 11-Jun-17
|
|
470
|
-
*/
|
|
471
|
-
class IqSelect2TemplateDirective {
|
|
472
|
-
constructor(templateRef, host) {
|
|
473
|
-
this.templateRef = templateRef;
|
|
474
|
-
if (host instanceof IqSelect2Component) {
|
|
475
|
-
host.templateRef = templateRef;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
479
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
480
|
-
}
|
|
481
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
482
|
-
type: Directive,
|
|
483
|
-
args: [{ selector: '[iq-select2-template]' }]
|
|
484
|
-
}], ctorParameters:
|
|
485
|
-
type: Host
|
|
486
|
-
}] }]
|
|
467
|
+
/**
|
|
468
|
+
* @author:msms
|
|
469
|
+
* 11-Jun-17
|
|
470
|
+
*/
|
|
471
|
+
class IqSelect2TemplateDirective {
|
|
472
|
+
constructor(templateRef, host) {
|
|
473
|
+
this.templateRef = templateRef;
|
|
474
|
+
if (host instanceof IqSelect2Component) {
|
|
475
|
+
host.templateRef = templateRef;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2TemplateDirective, deps: [{ token: i0.TemplateRef }, { token: IqSelect2Component, host: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
479
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: IqSelect2TemplateDirective, selector: "[iq-select2-template]", ngImport: i0 }); }
|
|
480
|
+
}
|
|
481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2TemplateDirective, decorators: [{
|
|
482
|
+
type: Directive,
|
|
483
|
+
args: [{ selector: '[iq-select2-template]' }]
|
|
484
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: IqSelect2Component, decorators: [{
|
|
485
|
+
type: Host
|
|
486
|
+
}] }] });
|
|
487
487
|
|
|
488
|
-
class IqSelect2Module {
|
|
489
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
490
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
491
|
-
IqSelect2ResultsComponent,
|
|
492
|
-
IqSelect2TemplateDirective], imports: [CommonModule,
|
|
493
|
-
FormsModule,
|
|
494
|
-
HttpClientModule,
|
|
495
|
-
ReactiveFormsModule], exports: [IqSelect2Component,
|
|
496
|
-
IqSelect2ResultsComponent,
|
|
497
|
-
IqSelect2TemplateDirective] }); }
|
|
498
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
499
|
-
FormsModule,
|
|
500
|
-
HttpClientModule,
|
|
501
|
-
ReactiveFormsModule] }); }
|
|
502
|
-
}
|
|
503
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
504
|
-
type: NgModule,
|
|
505
|
-
args: [{
|
|
506
|
-
imports: [
|
|
507
|
-
CommonModule,
|
|
508
|
-
FormsModule,
|
|
509
|
-
HttpClientModule,
|
|
510
|
-
ReactiveFormsModule
|
|
511
|
-
],
|
|
512
|
-
declarations: [
|
|
513
|
-
IqSelect2Component,
|
|
514
|
-
IqSelect2ResultsComponent,
|
|
515
|
-
IqSelect2TemplateDirective
|
|
516
|
-
],
|
|
517
|
-
exports: [
|
|
518
|
-
IqSelect2Component,
|
|
519
|
-
IqSelect2ResultsComponent,
|
|
520
|
-
IqSelect2TemplateDirective
|
|
521
|
-
]
|
|
522
|
-
}]
|
|
488
|
+
class IqSelect2Module {
|
|
489
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Module, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
490
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Module, declarations: [IqSelect2Component,
|
|
491
|
+
IqSelect2ResultsComponent,
|
|
492
|
+
IqSelect2TemplateDirective], imports: [CommonModule,
|
|
493
|
+
FormsModule,
|
|
494
|
+
HttpClientModule,
|
|
495
|
+
ReactiveFormsModule], exports: [IqSelect2Component,
|
|
496
|
+
IqSelect2ResultsComponent,
|
|
497
|
+
IqSelect2TemplateDirective] }); }
|
|
498
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Module, imports: [CommonModule,
|
|
499
|
+
FormsModule,
|
|
500
|
+
HttpClientModule,
|
|
501
|
+
ReactiveFormsModule] }); }
|
|
502
|
+
}
|
|
503
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IqSelect2Module, decorators: [{
|
|
504
|
+
type: NgModule,
|
|
505
|
+
args: [{
|
|
506
|
+
imports: [
|
|
507
|
+
CommonModule,
|
|
508
|
+
FormsModule,
|
|
509
|
+
HttpClientModule,
|
|
510
|
+
ReactiveFormsModule
|
|
511
|
+
],
|
|
512
|
+
declarations: [
|
|
513
|
+
IqSelect2Component,
|
|
514
|
+
IqSelect2ResultsComponent,
|
|
515
|
+
IqSelect2TemplateDirective
|
|
516
|
+
],
|
|
517
|
+
exports: [
|
|
518
|
+
IqSelect2Component,
|
|
519
|
+
IqSelect2ResultsComponent,
|
|
520
|
+
IqSelect2TemplateDirective
|
|
521
|
+
]
|
|
522
|
+
}]
|
|
523
523
|
}] });
|
|
524
524
|
|
|
525
|
-
/*
|
|
526
|
-
* Public API Surface of ng2-iq-select2
|
|
525
|
+
/*
|
|
526
|
+
* Public API Surface of ng2-iq-select2
|
|
527
527
|
*/
|
|
528
528
|
|
|
529
|
-
/**
|
|
530
|
-
* Generated bundle index. Do not edit.
|
|
529
|
+
/**
|
|
530
|
+
* Generated bundle index. Do not edit.
|
|
531
531
|
*/
|
|
532
532
|
|
|
533
533
|
export { IqSelect2Component, IqSelect2Module, IqSelect2ResultsComponent, IqSelect2TemplateDirective };
|