@ng-select/ng-select 5.0.14 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bundles/ng-select-ng-select.umd.js +147 -1981
- package/bundles/ng-select-ng-select.umd.js.map +1 -1
- package/bundles/ng-select-ng-select.umd.min.js +2 -2
- package/bundles/ng-select-ng-select.umd.min.js.map +1 -1
- package/esm2015/lib/config.service.js +2 -31
- package/esm2015/lib/console.service.js +2 -11
- package/esm2015/lib/id.js +3 -16
- package/esm2015/lib/items-list.js +47 -353
- package/esm2015/lib/ng-dropdown-panel.component.js +25 -347
- package/esm2015/lib/ng-dropdown-panel.service.js +1 -72
- package/esm2015/lib/ng-option.component.js +2 -54
- package/esm2015/lib/ng-select.component.js +49 -717
- package/esm2015/lib/ng-select.module.js +1 -6
- package/esm2015/lib/ng-select.types.js +11 -49
- package/esm2015/lib/ng-templates.directive.js +1 -113
- package/esm2015/lib/search-helper.js +3 -18
- package/esm2015/lib/selection-model.js +11 -134
- package/esm2015/lib/value-utils.js +2 -34
- package/esm2015/ng-select-ng-select.js +2 -7
- package/esm2015/public-api.js +1 -6
- package/fesm2015/ng-select-ng-select.js +152 -1950
- package/fesm2015/ng-select-ng-select.js.map +1 -1
- package/lib/config.service.d.ts +1 -0
- package/ng-select-ng-select.metadata.json +1 -1
- package/package.json +4 -4
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { Directive, ElementRef, Input, TemplateRef,
|
|
1
|
+
import { Directive, ElementRef, Input, TemplateRef, ɵɵdefineInjectable, Injectable, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, NgZone, Optional, Inject, Output, ViewChild, HostListener, InjectionToken, forwardRef, Attribute, ChangeDetectorRef, HostBinding, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
|
2
2
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
3
|
import { takeUntil, auditTime, startWith, tap, debounceTime, filter, map } from 'rxjs/operators';
|
|
4
4
|
import { animationFrameScheduler, asapScheduler, Subject, fromEvent, merge } from 'rxjs';
|
|
5
5
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* Generated from: lib/value-utils.ts
|
|
10
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
11
|
-
*/
|
|
12
|
-
/** @type {?} */
|
|
13
7
|
const unescapedHTMLExp = /[&<>"']/g;
|
|
14
|
-
/** @type {?} */
|
|
15
8
|
const hasUnescapedHTMLExp = RegExp(unescapedHTMLExp.source);
|
|
16
|
-
/** @type {?} */
|
|
17
9
|
const htmlEscapes = {
|
|
18
10
|
'&': '&',
|
|
19
11
|
'<': '<',
|
|
@@ -21,65 +13,29 @@ const htmlEscapes = {
|
|
|
21
13
|
'"': '"',
|
|
22
14
|
'\'': '''
|
|
23
15
|
};
|
|
24
|
-
/**
|
|
25
|
-
* @param {?} string
|
|
26
|
-
* @return {?}
|
|
27
|
-
*/
|
|
28
16
|
function escapeHTML(string) {
|
|
29
17
|
return (string && hasUnescapedHTMLExp.test(string)) ?
|
|
30
|
-
string.replace(unescapedHTMLExp,
|
|
31
|
-
* @param {?} chr
|
|
32
|
-
* @return {?}
|
|
33
|
-
*/
|
|
34
|
-
chr => htmlEscapes[chr])) :
|
|
18
|
+
string.replace(unescapedHTMLExp, chr => htmlEscapes[chr]) :
|
|
35
19
|
string;
|
|
36
20
|
}
|
|
37
|
-
/**
|
|
38
|
-
* @param {?} value
|
|
39
|
-
* @return {?}
|
|
40
|
-
*/
|
|
41
21
|
function isDefined(value) {
|
|
42
22
|
return value !== undefined && value !== null;
|
|
43
23
|
}
|
|
44
|
-
/**
|
|
45
|
-
* @param {?} value
|
|
46
|
-
* @return {?}
|
|
47
|
-
*/
|
|
48
24
|
function isObject(value) {
|
|
49
25
|
return typeof value === 'object' && isDefined(value);
|
|
50
26
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @param {?} value
|
|
53
|
-
* @return {?}
|
|
54
|
-
*/
|
|
55
27
|
function isPromise(value) {
|
|
56
28
|
return value instanceof Promise;
|
|
57
29
|
}
|
|
58
|
-
/**
|
|
59
|
-
* @param {?} value
|
|
60
|
-
* @return {?}
|
|
61
|
-
*/
|
|
62
30
|
function isFunction(value) {
|
|
63
31
|
return value instanceof Function;
|
|
64
32
|
}
|
|
65
33
|
|
|
66
|
-
/**
|
|
67
|
-
* @fileoverview added by tsickle
|
|
68
|
-
* Generated from: lib/ng-templates.directive.ts
|
|
69
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
70
|
-
*/
|
|
71
34
|
class NgItemLabelDirective {
|
|
72
|
-
/**
|
|
73
|
-
* @param {?} element
|
|
74
|
-
*/
|
|
75
35
|
constructor(element) {
|
|
76
36
|
this.element = element;
|
|
77
37
|
this.escape = true;
|
|
78
38
|
}
|
|
79
|
-
/**
|
|
80
|
-
* @param {?} changes
|
|
81
|
-
* @return {?}
|
|
82
|
-
*/
|
|
83
39
|
ngOnChanges(changes) {
|
|
84
40
|
this.element.nativeElement.innerHTML = this.escape ?
|
|
85
41
|
escapeHTML(this.ngItemLabel) :
|
|
@@ -89,7 +45,6 @@ class NgItemLabelDirective {
|
|
|
89
45
|
NgItemLabelDirective.decorators = [
|
|
90
46
|
{ type: Directive, args: [{ selector: '[ngItemLabel]' },] }
|
|
91
47
|
];
|
|
92
|
-
/** @nocollapse */
|
|
93
48
|
NgItemLabelDirective.ctorParameters = () => [
|
|
94
49
|
{ type: ElementRef }
|
|
95
50
|
];
|
|
@@ -97,21 +52,7 @@ NgItemLabelDirective.propDecorators = {
|
|
|
97
52
|
ngItemLabel: [{ type: Input }],
|
|
98
53
|
escape: [{ type: Input }]
|
|
99
54
|
};
|
|
100
|
-
if (false) {
|
|
101
|
-
/** @type {?} */
|
|
102
|
-
NgItemLabelDirective.prototype.ngItemLabel;
|
|
103
|
-
/** @type {?} */
|
|
104
|
-
NgItemLabelDirective.prototype.escape;
|
|
105
|
-
/**
|
|
106
|
-
* @type {?}
|
|
107
|
-
* @private
|
|
108
|
-
*/
|
|
109
|
-
NgItemLabelDirective.prototype.element;
|
|
110
|
-
}
|
|
111
55
|
class NgOptionTemplateDirective {
|
|
112
|
-
/**
|
|
113
|
-
* @param {?} template
|
|
114
|
-
*/
|
|
115
56
|
constructor(template) {
|
|
116
57
|
this.template = template;
|
|
117
58
|
}
|
|
@@ -119,18 +60,10 @@ class NgOptionTemplateDirective {
|
|
|
119
60
|
NgOptionTemplateDirective.decorators = [
|
|
120
61
|
{ type: Directive, args: [{ selector: '[ng-option-tmp]' },] }
|
|
121
62
|
];
|
|
122
|
-
/** @nocollapse */
|
|
123
63
|
NgOptionTemplateDirective.ctorParameters = () => [
|
|
124
64
|
{ type: TemplateRef }
|
|
125
65
|
];
|
|
126
|
-
if (false) {
|
|
127
|
-
/** @type {?} */
|
|
128
|
-
NgOptionTemplateDirective.prototype.template;
|
|
129
|
-
}
|
|
130
66
|
class NgOptgroupTemplateDirective {
|
|
131
|
-
/**
|
|
132
|
-
* @param {?} template
|
|
133
|
-
*/
|
|
134
67
|
constructor(template) {
|
|
135
68
|
this.template = template;
|
|
136
69
|
}
|
|
@@ -138,18 +71,10 @@ class NgOptgroupTemplateDirective {
|
|
|
138
71
|
NgOptgroupTemplateDirective.decorators = [
|
|
139
72
|
{ type: Directive, args: [{ selector: '[ng-optgroup-tmp]' },] }
|
|
140
73
|
];
|
|
141
|
-
/** @nocollapse */
|
|
142
74
|
NgOptgroupTemplateDirective.ctorParameters = () => [
|
|
143
75
|
{ type: TemplateRef }
|
|
144
76
|
];
|
|
145
|
-
if (false) {
|
|
146
|
-
/** @type {?} */
|
|
147
|
-
NgOptgroupTemplateDirective.prototype.template;
|
|
148
|
-
}
|
|
149
77
|
class NgLabelTemplateDirective {
|
|
150
|
-
/**
|
|
151
|
-
* @param {?} template
|
|
152
|
-
*/
|
|
153
78
|
constructor(template) {
|
|
154
79
|
this.template = template;
|
|
155
80
|
}
|
|
@@ -157,18 +82,10 @@ class NgLabelTemplateDirective {
|
|
|
157
82
|
NgLabelTemplateDirective.decorators = [
|
|
158
83
|
{ type: Directive, args: [{ selector: '[ng-label-tmp]' },] }
|
|
159
84
|
];
|
|
160
|
-
/** @nocollapse */
|
|
161
85
|
NgLabelTemplateDirective.ctorParameters = () => [
|
|
162
86
|
{ type: TemplateRef }
|
|
163
87
|
];
|
|
164
|
-
if (false) {
|
|
165
|
-
/** @type {?} */
|
|
166
|
-
NgLabelTemplateDirective.prototype.template;
|
|
167
|
-
}
|
|
168
88
|
class NgMultiLabelTemplateDirective {
|
|
169
|
-
/**
|
|
170
|
-
* @param {?} template
|
|
171
|
-
*/
|
|
172
89
|
constructor(template) {
|
|
173
90
|
this.template = template;
|
|
174
91
|
}
|
|
@@ -176,18 +93,10 @@ class NgMultiLabelTemplateDirective {
|
|
|
176
93
|
NgMultiLabelTemplateDirective.decorators = [
|
|
177
94
|
{ type: Directive, args: [{ selector: '[ng-multi-label-tmp]' },] }
|
|
178
95
|
];
|
|
179
|
-
/** @nocollapse */
|
|
180
96
|
NgMultiLabelTemplateDirective.ctorParameters = () => [
|
|
181
97
|
{ type: TemplateRef }
|
|
182
98
|
];
|
|
183
|
-
if (false) {
|
|
184
|
-
/** @type {?} */
|
|
185
|
-
NgMultiLabelTemplateDirective.prototype.template;
|
|
186
|
-
}
|
|
187
99
|
class NgHeaderTemplateDirective {
|
|
188
|
-
/**
|
|
189
|
-
* @param {?} template
|
|
190
|
-
*/
|
|
191
100
|
constructor(template) {
|
|
192
101
|
this.template = template;
|
|
193
102
|
}
|
|
@@ -195,18 +104,10 @@ class NgHeaderTemplateDirective {
|
|
|
195
104
|
NgHeaderTemplateDirective.decorators = [
|
|
196
105
|
{ type: Directive, args: [{ selector: '[ng-header-tmp]' },] }
|
|
197
106
|
];
|
|
198
|
-
/** @nocollapse */
|
|
199
107
|
NgHeaderTemplateDirective.ctorParameters = () => [
|
|
200
108
|
{ type: TemplateRef }
|
|
201
109
|
];
|
|
202
|
-
if (false) {
|
|
203
|
-
/** @type {?} */
|
|
204
|
-
NgHeaderTemplateDirective.prototype.template;
|
|
205
|
-
}
|
|
206
110
|
class NgFooterTemplateDirective {
|
|
207
|
-
/**
|
|
208
|
-
* @param {?} template
|
|
209
|
-
*/
|
|
210
111
|
constructor(template) {
|
|
211
112
|
this.template = template;
|
|
212
113
|
}
|
|
@@ -214,18 +115,10 @@ class NgFooterTemplateDirective {
|
|
|
214
115
|
NgFooterTemplateDirective.decorators = [
|
|
215
116
|
{ type: Directive, args: [{ selector: '[ng-footer-tmp]' },] }
|
|
216
117
|
];
|
|
217
|
-
/** @nocollapse */
|
|
218
118
|
NgFooterTemplateDirective.ctorParameters = () => [
|
|
219
119
|
{ type: TemplateRef }
|
|
220
120
|
];
|
|
221
|
-
if (false) {
|
|
222
|
-
/** @type {?} */
|
|
223
|
-
NgFooterTemplateDirective.prototype.template;
|
|
224
|
-
}
|
|
225
121
|
class NgNotFoundTemplateDirective {
|
|
226
|
-
/**
|
|
227
|
-
* @param {?} template
|
|
228
|
-
*/
|
|
229
122
|
constructor(template) {
|
|
230
123
|
this.template = template;
|
|
231
124
|
}
|
|
@@ -233,18 +126,10 @@ class NgNotFoundTemplateDirective {
|
|
|
233
126
|
NgNotFoundTemplateDirective.decorators = [
|
|
234
127
|
{ type: Directive, args: [{ selector: '[ng-notfound-tmp]' },] }
|
|
235
128
|
];
|
|
236
|
-
/** @nocollapse */
|
|
237
129
|
NgNotFoundTemplateDirective.ctorParameters = () => [
|
|
238
130
|
{ type: TemplateRef }
|
|
239
131
|
];
|
|
240
|
-
if (false) {
|
|
241
|
-
/** @type {?} */
|
|
242
|
-
NgNotFoundTemplateDirective.prototype.template;
|
|
243
|
-
}
|
|
244
132
|
class NgTypeToSearchTemplateDirective {
|
|
245
|
-
/**
|
|
246
|
-
* @param {?} template
|
|
247
|
-
*/
|
|
248
133
|
constructor(template) {
|
|
249
134
|
this.template = template;
|
|
250
135
|
}
|
|
@@ -252,18 +137,10 @@ class NgTypeToSearchTemplateDirective {
|
|
|
252
137
|
NgTypeToSearchTemplateDirective.decorators = [
|
|
253
138
|
{ type: Directive, args: [{ selector: '[ng-typetosearch-tmp]' },] }
|
|
254
139
|
];
|
|
255
|
-
/** @nocollapse */
|
|
256
140
|
NgTypeToSearchTemplateDirective.ctorParameters = () => [
|
|
257
141
|
{ type: TemplateRef }
|
|
258
142
|
];
|
|
259
|
-
if (false) {
|
|
260
|
-
/** @type {?} */
|
|
261
|
-
NgTypeToSearchTemplateDirective.prototype.template;
|
|
262
|
-
}
|
|
263
143
|
class NgLoadingTextTemplateDirective {
|
|
264
|
-
/**
|
|
265
|
-
* @param {?} template
|
|
266
|
-
*/
|
|
267
144
|
constructor(template) {
|
|
268
145
|
this.template = template;
|
|
269
146
|
}
|
|
@@ -271,18 +148,10 @@ class NgLoadingTextTemplateDirective {
|
|
|
271
148
|
NgLoadingTextTemplateDirective.decorators = [
|
|
272
149
|
{ type: Directive, args: [{ selector: '[ng-loadingtext-tmp]' },] }
|
|
273
150
|
];
|
|
274
|
-
/** @nocollapse */
|
|
275
151
|
NgLoadingTextTemplateDirective.ctorParameters = () => [
|
|
276
152
|
{ type: TemplateRef }
|
|
277
153
|
];
|
|
278
|
-
if (false) {
|
|
279
|
-
/** @type {?} */
|
|
280
|
-
NgLoadingTextTemplateDirective.prototype.template;
|
|
281
|
-
}
|
|
282
154
|
class NgTagTemplateDirective {
|
|
283
|
-
/**
|
|
284
|
-
* @param {?} template
|
|
285
|
-
*/
|
|
286
155
|
constructor(template) {
|
|
287
156
|
this.template = template;
|
|
288
157
|
}
|
|
@@ -290,18 +159,10 @@ class NgTagTemplateDirective {
|
|
|
290
159
|
NgTagTemplateDirective.decorators = [
|
|
291
160
|
{ type: Directive, args: [{ selector: '[ng-tag-tmp]' },] }
|
|
292
161
|
];
|
|
293
|
-
/** @nocollapse */
|
|
294
162
|
NgTagTemplateDirective.ctorParameters = () => [
|
|
295
163
|
{ type: TemplateRef }
|
|
296
164
|
];
|
|
297
|
-
if (false) {
|
|
298
|
-
/** @type {?} */
|
|
299
|
-
NgTagTemplateDirective.prototype.template;
|
|
300
|
-
}
|
|
301
165
|
class NgLoadingSpinnerTemplateDirective {
|
|
302
|
-
/**
|
|
303
|
-
* @param {?} template
|
|
304
|
-
*/
|
|
305
166
|
constructor(template) {
|
|
306
167
|
this.template = template;
|
|
307
168
|
}
|
|
@@ -309,62 +170,29 @@ class NgLoadingSpinnerTemplateDirective {
|
|
|
309
170
|
NgLoadingSpinnerTemplateDirective.decorators = [
|
|
310
171
|
{ type: Directive, args: [{ selector: '[ng-loadingspinner-tmp]' },] }
|
|
311
172
|
];
|
|
312
|
-
/** @nocollapse */
|
|
313
173
|
NgLoadingSpinnerTemplateDirective.ctorParameters = () => [
|
|
314
174
|
{ type: TemplateRef }
|
|
315
175
|
];
|
|
316
|
-
if (false) {
|
|
317
|
-
/** @type {?} */
|
|
318
|
-
NgLoadingSpinnerTemplateDirective.prototype.template;
|
|
319
|
-
}
|
|
320
176
|
|
|
321
|
-
/**
|
|
322
|
-
* @fileoverview added by tsickle
|
|
323
|
-
* Generated from: lib/console.service.ts
|
|
324
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
325
|
-
*/
|
|
326
177
|
class ConsoleService {
|
|
327
|
-
/**
|
|
328
|
-
* @param {?} message
|
|
329
|
-
* @return {?}
|
|
330
|
-
*/
|
|
331
178
|
warn(message) {
|
|
332
179
|
console.warn(message);
|
|
333
180
|
}
|
|
334
181
|
}
|
|
182
|
+
ConsoleService.ɵprov = ɵɵdefineInjectable({ factory: function ConsoleService_Factory() { return new ConsoleService(); }, token: ConsoleService, providedIn: "root" });
|
|
335
183
|
ConsoleService.decorators = [
|
|
336
184
|
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
337
185
|
];
|
|
338
|
-
/** @nocollapse */ ConsoleService.ɵprov = ɵɵdefineInjectable({ factory: function ConsoleService_Factory() { return new ConsoleService(); }, token: ConsoleService, providedIn: "root" });
|
|
339
186
|
|
|
340
|
-
/**
|
|
341
|
-
* @fileoverview added by tsickle
|
|
342
|
-
* Generated from: lib/id.ts
|
|
343
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
344
|
-
*/
|
|
345
|
-
/**
|
|
346
|
-
* @return {?}
|
|
347
|
-
*/
|
|
348
187
|
function newId() {
|
|
349
188
|
// First character is an 'a', it's good practice to tag id to begin with a letter
|
|
350
|
-
return 'axxxxxxxxxxx'.replace(/[x]/g, (
|
|
351
|
-
* @param {?} _
|
|
352
|
-
* @return {?}
|
|
353
|
-
*/
|
|
354
|
-
function (_) {
|
|
189
|
+
return 'axxxxxxxxxxx'.replace(/[x]/g, function (_) {
|
|
355
190
|
// tslint:disable-next-line:no-bitwise
|
|
356
|
-
/** @type {?} */
|
|
357
191
|
const val = Math.random() * 16 | 0;
|
|
358
192
|
return val.toString(16);
|
|
359
|
-
})
|
|
193
|
+
});
|
|
360
194
|
}
|
|
361
195
|
|
|
362
|
-
/**
|
|
363
|
-
* @fileoverview added by tsickle
|
|
364
|
-
* Generated from: lib/search-helper.ts
|
|
365
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
366
|
-
*/
|
|
367
|
-
/** @type {?} */
|
|
368
196
|
const diacritics = {
|
|
369
197
|
'\u24B6': 'A',
|
|
370
198
|
'\uFF21': 'A',
|
|
@@ -1206,32 +1034,14 @@ const diacritics = {
|
|
|
1206
1034
|
'\u03C9': '\u03C9',
|
|
1207
1035
|
'\u03C2': '\u03C3'
|
|
1208
1036
|
};
|
|
1209
|
-
/**
|
|
1210
|
-
* @param {?} text
|
|
1211
|
-
* @return {?}
|
|
1212
|
-
*/
|
|
1213
1037
|
function stripSpecialChars(text) {
|
|
1214
|
-
|
|
1215
|
-
const match = (/**
|
|
1216
|
-
* @param {?} a
|
|
1217
|
-
* @return {?}
|
|
1218
|
-
*/
|
|
1219
|
-
(a) => {
|
|
1038
|
+
const match = (a) => {
|
|
1220
1039
|
return diacritics[a] || a;
|
|
1221
|
-
}
|
|
1040
|
+
};
|
|
1222
1041
|
return text.replace(/[^\u0000-\u007E]/g, match);
|
|
1223
1042
|
}
|
|
1224
1043
|
|
|
1225
|
-
/**
|
|
1226
|
-
* @fileoverview added by tsickle
|
|
1227
|
-
* Generated from: lib/items-list.ts
|
|
1228
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1229
|
-
*/
|
|
1230
1044
|
class ItemsList {
|
|
1231
|
-
/**
|
|
1232
|
-
* @param {?} _ngSelect
|
|
1233
|
-
* @param {?} _selectionModel
|
|
1234
|
-
*/
|
|
1235
1045
|
constructor(_ngSelect, _selectionModel) {
|
|
1236
1046
|
this._ngSelect = _ngSelect;
|
|
1237
1047
|
this._selectionModel = _selectionModel;
|
|
@@ -1239,56 +1049,30 @@ class ItemsList {
|
|
|
1239
1049
|
this._filteredItems = [];
|
|
1240
1050
|
this._markedIndex = -1;
|
|
1241
1051
|
}
|
|
1242
|
-
/**
|
|
1243
|
-
* @return {?}
|
|
1244
|
-
*/
|
|
1245
1052
|
get items() {
|
|
1246
1053
|
return this._items;
|
|
1247
1054
|
}
|
|
1248
|
-
/**
|
|
1249
|
-
* @return {?}
|
|
1250
|
-
*/
|
|
1251
1055
|
get filteredItems() {
|
|
1252
1056
|
return this._filteredItems;
|
|
1253
1057
|
}
|
|
1254
|
-
/**
|
|
1255
|
-
* @return {?}
|
|
1256
|
-
*/
|
|
1257
1058
|
get markedIndex() {
|
|
1258
1059
|
return this._markedIndex;
|
|
1259
1060
|
}
|
|
1260
|
-
/**
|
|
1261
|
-
* @return {?}
|
|
1262
|
-
*/
|
|
1263
1061
|
get selectedItems() {
|
|
1264
1062
|
return this._selectionModel.value;
|
|
1265
1063
|
}
|
|
1266
|
-
/**
|
|
1267
|
-
* @return {?}
|
|
1268
|
-
*/
|
|
1269
1064
|
get markedItem() {
|
|
1270
1065
|
return this._filteredItems[this._markedIndex];
|
|
1271
1066
|
}
|
|
1272
|
-
/**
|
|
1273
|
-
* @return {?}
|
|
1274
|
-
*/
|
|
1275
1067
|
get noItemsToSelect() {
|
|
1276
1068
|
return this._ngSelect.hideSelected && this._items.length === this.selectedItems.length;
|
|
1277
1069
|
}
|
|
1278
|
-
/**
|
|
1279
|
-
* @return {?}
|
|
1280
|
-
*/
|
|
1281
1070
|
get maxItemsSelected() {
|
|
1282
1071
|
return this._ngSelect.multiple && this._ngSelect.maxSelectedItems <= this.selectedItems.length;
|
|
1283
1072
|
}
|
|
1284
|
-
/**
|
|
1285
|
-
* @return {?}
|
|
1286
|
-
*/
|
|
1287
1073
|
get lastSelectedItem() {
|
|
1288
|
-
/** @type {?} */
|
|
1289
1074
|
let i = this.selectedItems.length - 1;
|
|
1290
1075
|
for (; i >= 0; i--) {
|
|
1291
|
-
/** @type {?} */
|
|
1292
1076
|
let item = this.selectedItems[i];
|
|
1293
1077
|
if (!item.disabled) {
|
|
1294
1078
|
return item;
|
|
@@ -1296,17 +1080,8 @@ class ItemsList {
|
|
|
1296
1080
|
}
|
|
1297
1081
|
return null;
|
|
1298
1082
|
}
|
|
1299
|
-
/**
|
|
1300
|
-
* @param {?} items
|
|
1301
|
-
* @return {?}
|
|
1302
|
-
*/
|
|
1303
1083
|
setItems(items) {
|
|
1304
|
-
this._items = items.map((
|
|
1305
|
-
* @param {?} item
|
|
1306
|
-
* @param {?} index
|
|
1307
|
-
* @return {?}
|
|
1308
|
-
*/
|
|
1309
|
-
(item, index) => this.mapItem(item, index)));
|
|
1084
|
+
this._items = items.map((item, index) => this.mapItem(item, index));
|
|
1310
1085
|
if (this._ngSelect.groupBy) {
|
|
1311
1086
|
this._groups = this._groupBy(this._items, this._ngSelect.groupBy);
|
|
1312
1087
|
this._items = this._flatten(this._groups);
|
|
@@ -1317,15 +1092,10 @@ class ItemsList {
|
|
|
1317
1092
|
}
|
|
1318
1093
|
this._filteredItems = [...this._items];
|
|
1319
1094
|
}
|
|
1320
|
-
/**
|
|
1321
|
-
* @param {?} item
|
|
1322
|
-
* @return {?}
|
|
1323
|
-
*/
|
|
1324
1095
|
select(item) {
|
|
1325
1096
|
if (item.selected || this.maxItemsSelected) {
|
|
1326
1097
|
return;
|
|
1327
1098
|
}
|
|
1328
|
-
/** @type {?} */
|
|
1329
1099
|
const multiple = this._ngSelect.multiple;
|
|
1330
1100
|
if (!multiple) {
|
|
1331
1101
|
this.clearSelected();
|
|
@@ -1335,10 +1105,6 @@ class ItemsList {
|
|
|
1335
1105
|
this._hideSelected(item);
|
|
1336
1106
|
}
|
|
1337
1107
|
}
|
|
1338
|
-
/**
|
|
1339
|
-
* @param {?} item
|
|
1340
|
-
* @return {?}
|
|
1341
|
-
*/
|
|
1342
1108
|
unselect(item) {
|
|
1343
1109
|
if (!item.selected) {
|
|
1344
1110
|
return;
|
|
@@ -1348,90 +1114,43 @@ class ItemsList {
|
|
|
1348
1114
|
this._showSelected(item);
|
|
1349
1115
|
}
|
|
1350
1116
|
}
|
|
1351
|
-
/**
|
|
1352
|
-
* @param {?} value
|
|
1353
|
-
* @return {?}
|
|
1354
|
-
*/
|
|
1355
1117
|
findItem(value) {
|
|
1356
|
-
/** @type {?} */
|
|
1357
1118
|
let findBy;
|
|
1358
1119
|
if (this._ngSelect.compareWith) {
|
|
1359
|
-
findBy = (
|
|
1360
|
-
* @param {?} item
|
|
1361
|
-
* @return {?}
|
|
1362
|
-
*/
|
|
1363
|
-
item => this._ngSelect.compareWith(item.value, value));
|
|
1120
|
+
findBy = item => this._ngSelect.compareWith(item.value, value);
|
|
1364
1121
|
}
|
|
1365
1122
|
else if (this._ngSelect.bindValue) {
|
|
1366
|
-
findBy = (
|
|
1367
|
-
* @param {?} item
|
|
1368
|
-
* @return {?}
|
|
1369
|
-
*/
|
|
1370
|
-
item => !item.children && this.resolveNested(item.value, this._ngSelect.bindValue) === value);
|
|
1123
|
+
findBy = item => !item.children && this.resolveNested(item.value, this._ngSelect.bindValue) === value;
|
|
1371
1124
|
}
|
|
1372
1125
|
else {
|
|
1373
|
-
findBy =
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
!item.children && item.label && item.label === this.resolveNested(value, this._ngSelect.bindLabel));
|
|
1379
|
-
}
|
|
1380
|
-
return this._items.find((/**
|
|
1381
|
-
* @param {?} item
|
|
1382
|
-
* @return {?}
|
|
1383
|
-
*/
|
|
1384
|
-
item => findBy(item)));
|
|
1385
|
-
}
|
|
1386
|
-
/**
|
|
1387
|
-
* @param {?} item
|
|
1388
|
-
* @return {?}
|
|
1389
|
-
*/
|
|
1126
|
+
findBy = item => item.value === value ||
|
|
1127
|
+
!item.children && item.label && item.label === this.resolveNested(value, this._ngSelect.bindLabel);
|
|
1128
|
+
}
|
|
1129
|
+
return this._items.find(item => findBy(item));
|
|
1130
|
+
}
|
|
1390
1131
|
addItem(item) {
|
|
1391
|
-
/** @type {?} */
|
|
1392
1132
|
const option = this.mapItem(item, this._items.length);
|
|
1393
1133
|
this._items.push(option);
|
|
1394
1134
|
this._filteredItems.push(option);
|
|
1395
1135
|
return option;
|
|
1396
1136
|
}
|
|
1397
|
-
/**
|
|
1398
|
-
* @param {?=} keepDisabled
|
|
1399
|
-
* @return {?}
|
|
1400
|
-
*/
|
|
1401
1137
|
clearSelected(keepDisabled = false) {
|
|
1402
1138
|
this._selectionModel.clear(keepDisabled);
|
|
1403
|
-
this._items.forEach(
|
|
1404
|
-
* @param {?} item
|
|
1405
|
-
* @return {?}
|
|
1406
|
-
*/
|
|
1407
|
-
item => {
|
|
1139
|
+
this._items.forEach(item => {
|
|
1408
1140
|
item.selected = keepDisabled && item.selected && item.disabled;
|
|
1409
1141
|
item.marked = false;
|
|
1410
|
-
})
|
|
1142
|
+
});
|
|
1411
1143
|
if (this._ngSelect.hideSelected) {
|
|
1412
1144
|
this.resetFilteredItems();
|
|
1413
1145
|
}
|
|
1414
1146
|
}
|
|
1415
|
-
/**
|
|
1416
|
-
* @param {?} term
|
|
1417
|
-
* @return {?}
|
|
1418
|
-
*/
|
|
1419
1147
|
findByLabel(term) {
|
|
1420
1148
|
term = stripSpecialChars(term).toLocaleLowerCase();
|
|
1421
|
-
return this.filteredItems.find(
|
|
1422
|
-
* @param {?} item
|
|
1423
|
-
* @return {?}
|
|
1424
|
-
*/
|
|
1425
|
-
item => {
|
|
1426
|
-
/** @type {?} */
|
|
1149
|
+
return this.filteredItems.find(item => {
|
|
1427
1150
|
const label = stripSpecialChars(item.label).toLocaleLowerCase();
|
|
1428
1151
|
return label.substr(0, term.length) === term;
|
|
1429
|
-
})
|
|
1152
|
+
});
|
|
1430
1153
|
}
|
|
1431
|
-
/**
|
|
1432
|
-
* @param {?} term
|
|
1433
|
-
* @return {?}
|
|
1434
|
-
*/
|
|
1435
1154
|
filter(term) {
|
|
1436
1155
|
if (!term) {
|
|
1437
1156
|
this.resetFilteredItems();
|
|
@@ -1439,18 +1158,14 @@ class ItemsList {
|
|
|
1439
1158
|
}
|
|
1440
1159
|
this._filteredItems = [];
|
|
1441
1160
|
term = this._ngSelect.searchFn ? term : stripSpecialChars(term).toLocaleLowerCase();
|
|
1442
|
-
/** @type {?} */
|
|
1443
1161
|
const match = this._ngSelect.searchFn || this._defaultSearchFn;
|
|
1444
|
-
/** @type {?} */
|
|
1445
1162
|
const hideSelected = this._ngSelect.hideSelected;
|
|
1446
1163
|
for (const key of Array.from(this._groups.keys())) {
|
|
1447
|
-
/** @type {?} */
|
|
1448
1164
|
const matchedItems = [];
|
|
1449
1165
|
for (const item of this._groups.get(key)) {
|
|
1450
1166
|
if (hideSelected && (item.parent && item.parent.selected || item.selected)) {
|
|
1451
1167
|
continue;
|
|
1452
1168
|
}
|
|
1453
|
-
/** @type {?} */
|
|
1454
1169
|
const searchItem = this._ngSelect.searchFn ? item.value : item;
|
|
1455
1170
|
if (match(term, searchItem)) {
|
|
1456
1171
|
matchedItems.push(item);
|
|
@@ -1459,87 +1174,48 @@ class ItemsList {
|
|
|
1459
1174
|
if (matchedItems.length > 0) {
|
|
1460
1175
|
const [last] = matchedItems.slice(-1);
|
|
1461
1176
|
if (last.parent) {
|
|
1462
|
-
|
|
1463
|
-
const head = this._items.find((/**
|
|
1464
|
-
* @param {?} x
|
|
1465
|
-
* @return {?}
|
|
1466
|
-
*/
|
|
1467
|
-
x => x === last.parent));
|
|
1177
|
+
const head = this._items.find(x => x === last.parent);
|
|
1468
1178
|
this._filteredItems.push(head);
|
|
1469
1179
|
}
|
|
1470
1180
|
this._filteredItems.push(...matchedItems);
|
|
1471
1181
|
}
|
|
1472
1182
|
}
|
|
1473
1183
|
}
|
|
1474
|
-
/**
|
|
1475
|
-
* @return {?}
|
|
1476
|
-
*/
|
|
1477
1184
|
resetFilteredItems() {
|
|
1478
1185
|
if (this._filteredItems.length === this._items.length) {
|
|
1479
1186
|
return;
|
|
1480
1187
|
}
|
|
1481
1188
|
if (this._ngSelect.hideSelected && this.selectedItems.length > 0) {
|
|
1482
|
-
this._filteredItems = this._items.filter(
|
|
1483
|
-
* @param {?} x
|
|
1484
|
-
* @return {?}
|
|
1485
|
-
*/
|
|
1486
|
-
x => !x.selected));
|
|
1189
|
+
this._filteredItems = this._items.filter(x => !x.selected);
|
|
1487
1190
|
}
|
|
1488
1191
|
else {
|
|
1489
1192
|
this._filteredItems = this._items;
|
|
1490
1193
|
}
|
|
1491
1194
|
}
|
|
1492
|
-
/**
|
|
1493
|
-
* @return {?}
|
|
1494
|
-
*/
|
|
1495
1195
|
unmarkItem() {
|
|
1496
1196
|
this._markedIndex = -1;
|
|
1497
1197
|
}
|
|
1498
|
-
/**
|
|
1499
|
-
* @return {?}
|
|
1500
|
-
*/
|
|
1501
1198
|
markNextItem() {
|
|
1502
1199
|
this._stepToItem(+1);
|
|
1503
1200
|
}
|
|
1504
|
-
/**
|
|
1505
|
-
* @return {?}
|
|
1506
|
-
*/
|
|
1507
1201
|
markPreviousItem() {
|
|
1508
1202
|
this._stepToItem(-1);
|
|
1509
1203
|
}
|
|
1510
|
-
/**
|
|
1511
|
-
* @param {?} item
|
|
1512
|
-
* @return {?}
|
|
1513
|
-
*/
|
|
1514
1204
|
markItem(item) {
|
|
1515
1205
|
this._markedIndex = this._filteredItems.indexOf(item);
|
|
1516
1206
|
}
|
|
1517
|
-
/**
|
|
1518
|
-
* @param {?=} markDefault
|
|
1519
|
-
* @return {?}
|
|
1520
|
-
*/
|
|
1521
1207
|
markSelectedOrDefault(markDefault) {
|
|
1522
1208
|
if (this._filteredItems.length === 0) {
|
|
1523
1209
|
return;
|
|
1524
1210
|
}
|
|
1525
|
-
/** @type {?} */
|
|
1526
1211
|
const lastMarkedIndex = this._getLastMarkedIndex();
|
|
1527
1212
|
if (lastMarkedIndex > -1) {
|
|
1528
1213
|
this._markedIndex = lastMarkedIndex;
|
|
1529
1214
|
}
|
|
1530
1215
|
else {
|
|
1531
|
-
this._markedIndex = markDefault ? this.filteredItems.findIndex(
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
*/
|
|
1535
|
-
x => !x.disabled)) : -1;
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
/**
|
|
1539
|
-
* @param {?} option
|
|
1540
|
-
* @param {?} key
|
|
1541
|
-
* @return {?}
|
|
1542
|
-
*/
|
|
1216
|
+
this._markedIndex = markDefault ? this.filteredItems.findIndex(x => !x.disabled) : -1;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1543
1219
|
resolveNested(option, key) {
|
|
1544
1220
|
if (!isObject(option)) {
|
|
1545
1221
|
return option;
|
|
@@ -1548,9 +1224,7 @@ class ItemsList {
|
|
|
1548
1224
|
return option[key];
|
|
1549
1225
|
}
|
|
1550
1226
|
else {
|
|
1551
|
-
/** @type {?} */
|
|
1552
1227
|
let keys = key.split('.');
|
|
1553
|
-
/** @type {?} */
|
|
1554
1228
|
let value = option;
|
|
1555
1229
|
for (let i = 0, len = keys.length; i < len; ++i) {
|
|
1556
1230
|
if (value == null) {
|
|
@@ -1561,15 +1235,8 @@ class ItemsList {
|
|
|
1561
1235
|
return value;
|
|
1562
1236
|
}
|
|
1563
1237
|
}
|
|
1564
|
-
/**
|
|
1565
|
-
* @param {?} item
|
|
1566
|
-
* @param {?} index
|
|
1567
|
-
* @return {?}
|
|
1568
|
-
*/
|
|
1569
1238
|
mapItem(item, index) {
|
|
1570
|
-
/** @type {?} */
|
|
1571
1239
|
const label = isDefined(item.$ngOptionLabel) ? item.$ngOptionLabel : this.resolveNested(item, this._ngSelect.bindLabel);
|
|
1572
|
-
/** @type {?} */
|
|
1573
1240
|
const value = isDefined(item.$ngOptionValue) ? item.$ngOptionValue : item;
|
|
1574
1241
|
return {
|
|
1575
1242
|
index: index,
|
|
@@ -1579,44 +1246,23 @@ class ItemsList {
|
|
|
1579
1246
|
htmlId: `${this._ngSelect.dropdownId}-${index}`,
|
|
1580
1247
|
};
|
|
1581
1248
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* @return {?}
|
|
1584
|
-
*/
|
|
1585
1249
|
mapSelectedItems() {
|
|
1586
|
-
/** @type {?} */
|
|
1587
1250
|
const multiple = this._ngSelect.multiple;
|
|
1588
1251
|
for (const selected of this.selectedItems) {
|
|
1589
|
-
/** @type {?} */
|
|
1590
1252
|
const value = this._ngSelect.bindValue ? this.resolveNested(selected.value, this._ngSelect.bindValue) : selected.value;
|
|
1591
|
-
/** @type {?} */
|
|
1592
1253
|
const item = isDefined(value) ? this.findItem(value) : null;
|
|
1593
1254
|
this._selectionModel.unselect(selected, multiple);
|
|
1594
1255
|
this._selectionModel.select(item || selected, multiple, this._ngSelect.selectableGroupAsModel);
|
|
1595
1256
|
}
|
|
1596
1257
|
if (this._ngSelect.hideSelected) {
|
|
1597
|
-
this._filteredItems = this.filteredItems.filter((
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
*/
|
|
1601
|
-
x => this.selectedItems.indexOf(x) === -1));
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* @private
|
|
1606
|
-
* @param {?} item
|
|
1607
|
-
* @return {?}
|
|
1608
|
-
*/
|
|
1258
|
+
this._filteredItems = this.filteredItems.filter(x => this.selectedItems.indexOf(x) === -1);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1609
1261
|
_showSelected(item) {
|
|
1610
1262
|
this._filteredItems.push(item);
|
|
1611
1263
|
if (item.parent) {
|
|
1612
|
-
/** @type {?} */
|
|
1613
1264
|
const parent = item.parent;
|
|
1614
|
-
|
|
1615
|
-
const parentExists = this._filteredItems.find((/**
|
|
1616
|
-
* @param {?} x
|
|
1617
|
-
* @return {?}
|
|
1618
|
-
*/
|
|
1619
|
-
x => x === parent));
|
|
1265
|
+
const parentExists = this._filteredItems.find(x => x === parent);
|
|
1620
1266
|
if (!parentExists) {
|
|
1621
1267
|
this._filteredItems.push(parent);
|
|
1622
1268
|
}
|
|
@@ -1627,80 +1273,32 @@ class ItemsList {
|
|
|
1627
1273
|
this._filteredItems.push(child);
|
|
1628
1274
|
}
|
|
1629
1275
|
}
|
|
1630
|
-
this._filteredItems = [...this._filteredItems.sort((
|
|
1631
|
-
|
|
1632
|
-
* @param {?} b
|
|
1633
|
-
* @return {?}
|
|
1634
|
-
*/
|
|
1635
|
-
(a, b) => (a.index - b.index)))];
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* @private
|
|
1639
|
-
* @param {?} item
|
|
1640
|
-
* @return {?}
|
|
1641
|
-
*/
|
|
1276
|
+
this._filteredItems = [...this._filteredItems.sort((a, b) => (a.index - b.index))];
|
|
1277
|
+
}
|
|
1642
1278
|
_hideSelected(item) {
|
|
1643
|
-
this._filteredItems = this._filteredItems.filter(
|
|
1644
|
-
* @param {?} x
|
|
1645
|
-
* @return {?}
|
|
1646
|
-
*/
|
|
1647
|
-
x => x !== item));
|
|
1279
|
+
this._filteredItems = this._filteredItems.filter(x => x !== item);
|
|
1648
1280
|
if (item.parent) {
|
|
1649
|
-
/** @type {?} */
|
|
1650
1281
|
const children = item.parent.children;
|
|
1651
|
-
if (children.every(
|
|
1652
|
-
|
|
1653
|
-
* @return {?}
|
|
1654
|
-
*/
|
|
1655
|
-
x => x.selected))) {
|
|
1656
|
-
this._filteredItems = this._filteredItems.filter((/**
|
|
1657
|
-
* @param {?} x
|
|
1658
|
-
* @return {?}
|
|
1659
|
-
*/
|
|
1660
|
-
x => x !== item.parent));
|
|
1282
|
+
if (children.every(x => x.selected)) {
|
|
1283
|
+
this._filteredItems = this._filteredItems.filter(x => x !== item.parent);
|
|
1661
1284
|
}
|
|
1662
1285
|
}
|
|
1663
1286
|
else if (item.children) {
|
|
1664
|
-
this._filteredItems = this.filteredItems.filter(
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
*/
|
|
1668
|
-
x => x.parent !== item));
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* @private
|
|
1673
|
-
* @param {?} search
|
|
1674
|
-
* @param {?} opt
|
|
1675
|
-
* @return {?}
|
|
1676
|
-
*/
|
|
1287
|
+
this._filteredItems = this.filteredItems.filter(x => x.parent !== item);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1677
1290
|
_defaultSearchFn(search, opt) {
|
|
1678
|
-
/** @type {?} */
|
|
1679
1291
|
const label = stripSpecialChars(opt.label).toLocaleLowerCase();
|
|
1680
1292
|
return label.indexOf(search) > -1;
|
|
1681
1293
|
}
|
|
1682
|
-
/**
|
|
1683
|
-
* @private
|
|
1684
|
-
* @param {?} steps
|
|
1685
|
-
* @return {?}
|
|
1686
|
-
*/
|
|
1687
1294
|
_getNextItemIndex(steps) {
|
|
1688
1295
|
if (steps > 0) {
|
|
1689
1296
|
return (this._markedIndex >= this._filteredItems.length - 1) ? 0 : (this._markedIndex + 1);
|
|
1690
1297
|
}
|
|
1691
1298
|
return (this._markedIndex <= 0) ? (this._filteredItems.length - 1) : (this._markedIndex - 1);
|
|
1692
1299
|
}
|
|
1693
|
-
/**
|
|
1694
|
-
* @private
|
|
1695
|
-
* @param {?} steps
|
|
1696
|
-
* @return {?}
|
|
1697
|
-
*/
|
|
1698
1300
|
_stepToItem(steps) {
|
|
1699
|
-
if (this._filteredItems.length === 0 || this._filteredItems.every(
|
|
1700
|
-
* @param {?} x
|
|
1701
|
-
* @return {?}
|
|
1702
|
-
*/
|
|
1703
|
-
x => x.disabled))) {
|
|
1301
|
+
if (this._filteredItems.length === 0 || this._filteredItems.every(x => x.disabled)) {
|
|
1704
1302
|
return;
|
|
1705
1303
|
}
|
|
1706
1304
|
this._markedIndex = this._getNextItemIndex(steps);
|
|
@@ -1708,10 +1306,6 @@ class ItemsList {
|
|
|
1708
1306
|
this._stepToItem(steps);
|
|
1709
1307
|
}
|
|
1710
1308
|
}
|
|
1711
|
-
/**
|
|
1712
|
-
* @private
|
|
1713
|
-
* @return {?}
|
|
1714
|
-
*/
|
|
1715
1309
|
_getLastMarkedIndex() {
|
|
1716
1310
|
if (this._ngSelect.hideSelected) {
|
|
1717
1311
|
return -1;
|
|
@@ -1719,56 +1313,33 @@ class ItemsList {
|
|
|
1719
1313
|
if (this._markedIndex > -1 && this.markedItem === undefined) {
|
|
1720
1314
|
return -1;
|
|
1721
1315
|
}
|
|
1722
|
-
/** @type {?} */
|
|
1723
1316
|
const selectedIndex = this._filteredItems.indexOf(this.lastSelectedItem);
|
|
1724
1317
|
if (this.lastSelectedItem && selectedIndex < 0) {
|
|
1725
1318
|
return -1;
|
|
1726
1319
|
}
|
|
1727
1320
|
return Math.max(this.markedIndex, selectedIndex);
|
|
1728
1321
|
}
|
|
1729
|
-
/**
|
|
1730
|
-
* @private
|
|
1731
|
-
* @param {?} items
|
|
1732
|
-
* @param {?} prop
|
|
1733
|
-
* @return {?}
|
|
1734
|
-
*/
|
|
1735
1322
|
_groupBy(items, prop) {
|
|
1736
|
-
/** @type {?} */
|
|
1737
1323
|
const groups = new Map();
|
|
1738
1324
|
if (items.length === 0) {
|
|
1739
1325
|
return groups;
|
|
1740
1326
|
}
|
|
1741
1327
|
// Check if items are already grouped by given key.
|
|
1742
|
-
if (Array.isArray(items[0].value[
|
|
1328
|
+
if (Array.isArray(items[0].value[prop])) {
|
|
1743
1329
|
for (const item of items) {
|
|
1744
|
-
|
|
1745
|
-
const children = (item.value[(/** @type {?} */ (prop))] || []).map((/**
|
|
1746
|
-
* @param {?} x
|
|
1747
|
-
* @param {?} index
|
|
1748
|
-
* @return {?}
|
|
1749
|
-
*/
|
|
1750
|
-
(x, index) => this.mapItem(x, index)));
|
|
1330
|
+
const children = (item.value[prop] || []).map((x, index) => this.mapItem(x, index));
|
|
1751
1331
|
groups.set(item, children);
|
|
1752
1332
|
}
|
|
1753
1333
|
return groups;
|
|
1754
1334
|
}
|
|
1755
|
-
/** @type {?} */
|
|
1756
1335
|
const isFnKey = isFunction(this._ngSelect.groupBy);
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
* @param {?} item
|
|
1760
|
-
* @return {?}
|
|
1761
|
-
*/
|
|
1762
|
-
(item) => {
|
|
1763
|
-
/** @type {?} */
|
|
1764
|
-
let key = isFnKey ? ((/** @type {?} */ (prop)))(item.value) : item.value[(/** @type {?} */ (prop))];
|
|
1336
|
+
const keyFn = (item) => {
|
|
1337
|
+
let key = isFnKey ? prop(item.value) : item.value[prop];
|
|
1765
1338
|
return isDefined(key) ? key : undefined;
|
|
1766
|
-
}
|
|
1339
|
+
};
|
|
1767
1340
|
// Group items by key.
|
|
1768
1341
|
for (const item of items) {
|
|
1769
|
-
/** @type {?} */
|
|
1770
1342
|
let key = keyFn(item);
|
|
1771
|
-
/** @type {?} */
|
|
1772
1343
|
const group = groups.get(key);
|
|
1773
1344
|
if (group) {
|
|
1774
1345
|
group.push(item);
|
|
@@ -1779,32 +1350,20 @@ class ItemsList {
|
|
|
1779
1350
|
}
|
|
1780
1351
|
return groups;
|
|
1781
1352
|
}
|
|
1782
|
-
/**
|
|
1783
|
-
* @private
|
|
1784
|
-
* @param {?} groups
|
|
1785
|
-
* @return {?}
|
|
1786
|
-
*/
|
|
1787
1353
|
_flatten(groups) {
|
|
1788
|
-
/** @type {?} */
|
|
1789
1354
|
const isGroupByFn = isFunction(this._ngSelect.groupBy);
|
|
1790
|
-
/** @type {?} */
|
|
1791
1355
|
const items = [];
|
|
1792
1356
|
for (const key of Array.from(groups.keys())) {
|
|
1793
|
-
/** @type {?} */
|
|
1794
1357
|
let i = items.length;
|
|
1795
1358
|
if (key === undefined) {
|
|
1796
|
-
/** @type {?} */
|
|
1797
1359
|
const withoutGroup = groups.get(undefined) || [];
|
|
1798
|
-
items.push(...withoutGroup.map(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
x => (Object.assign(Object.assign({}, x), { index: i++ })))));
|
|
1360
|
+
items.push(...withoutGroup.map(x => {
|
|
1361
|
+
x.index = i++;
|
|
1362
|
+
return x;
|
|
1363
|
+
}));
|
|
1803
1364
|
continue;
|
|
1804
1365
|
}
|
|
1805
|
-
/** @type {?} */
|
|
1806
1366
|
const isObjectKey = isObject(key);
|
|
1807
|
-
/** @type {?} */
|
|
1808
1367
|
const parent = {
|
|
1809
1368
|
label: isObjectKey ? '' : String(key),
|
|
1810
1369
|
children: undefined,
|
|
@@ -1813,153 +1372,39 @@ class ItemsList {
|
|
|
1813
1372
|
disabled: !this._ngSelect.selectableGroup,
|
|
1814
1373
|
htmlId: newId(),
|
|
1815
1374
|
};
|
|
1816
|
-
|
|
1817
|
-
const
|
|
1818
|
-
/** @type {?} */
|
|
1819
|
-
const groupValue = this._ngSelect.groupValue || ((/**
|
|
1820
|
-
* @return {?}
|
|
1821
|
-
*/
|
|
1822
|
-
() => {
|
|
1375
|
+
const groupKey = isGroupByFn ? this._ngSelect.bindLabel : this._ngSelect.groupBy;
|
|
1376
|
+
const groupValue = this._ngSelect.groupValue || (() => {
|
|
1823
1377
|
if (isObjectKey) {
|
|
1824
|
-
return
|
|
1378
|
+
return key.value;
|
|
1825
1379
|
}
|
|
1826
1380
|
return { [groupKey]: key };
|
|
1827
|
-
})
|
|
1828
|
-
|
|
1829
|
-
const children = groups.get(key).map((/**
|
|
1830
|
-
* @param {?} x
|
|
1831
|
-
* @return {?}
|
|
1832
|
-
*/
|
|
1833
|
-
x => {
|
|
1381
|
+
});
|
|
1382
|
+
const children = groups.get(key).map(x => {
|
|
1834
1383
|
x.parent = parent;
|
|
1835
1384
|
x.children = undefined;
|
|
1836
1385
|
x.index = i++;
|
|
1837
1386
|
return x;
|
|
1838
|
-
})
|
|
1387
|
+
});
|
|
1839
1388
|
parent.children = children;
|
|
1840
|
-
parent.value = groupValue(key, children.map(
|
|
1841
|
-
* @param {?} x
|
|
1842
|
-
* @return {?}
|
|
1843
|
-
*/
|
|
1844
|
-
x => x.value)));
|
|
1389
|
+
parent.value = groupValue(key, children.map(x => x.value));
|
|
1845
1390
|
items.push(parent);
|
|
1846
1391
|
items.push(...children);
|
|
1847
1392
|
}
|
|
1848
1393
|
return items;
|
|
1849
1394
|
}
|
|
1850
1395
|
}
|
|
1851
|
-
if (false) {
|
|
1852
|
-
/**
|
|
1853
|
-
* @type {?}
|
|
1854
|
-
* @private
|
|
1855
|
-
*/
|
|
1856
|
-
ItemsList.prototype._groups;
|
|
1857
|
-
/**
|
|
1858
|
-
* @type {?}
|
|
1859
|
-
* @private
|
|
1860
|
-
*/
|
|
1861
|
-
ItemsList.prototype._items;
|
|
1862
|
-
/**
|
|
1863
|
-
* @type {?}
|
|
1864
|
-
* @private
|
|
1865
|
-
*/
|
|
1866
|
-
ItemsList.prototype._filteredItems;
|
|
1867
|
-
/**
|
|
1868
|
-
* @type {?}
|
|
1869
|
-
* @private
|
|
1870
|
-
*/
|
|
1871
|
-
ItemsList.prototype._markedIndex;
|
|
1872
|
-
/**
|
|
1873
|
-
* @type {?}
|
|
1874
|
-
* @private
|
|
1875
|
-
*/
|
|
1876
|
-
ItemsList.prototype._ngSelect;
|
|
1877
|
-
/**
|
|
1878
|
-
* @type {?}
|
|
1879
|
-
* @private
|
|
1880
|
-
*/
|
|
1881
|
-
ItemsList.prototype._selectionModel;
|
|
1882
|
-
}
|
|
1883
1396
|
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
/** @type {?|undefined} */
|
|
1895
|
-
NgOption.prototype.index;
|
|
1896
|
-
/** @type {?|undefined} */
|
|
1897
|
-
NgOption.prototype.htmlId;
|
|
1898
|
-
/** @type {?|undefined} */
|
|
1899
|
-
NgOption.prototype.selected;
|
|
1900
|
-
/** @type {?|undefined} */
|
|
1901
|
-
NgOption.prototype.disabled;
|
|
1902
|
-
/** @type {?|undefined} */
|
|
1903
|
-
NgOption.prototype.marked;
|
|
1904
|
-
/** @type {?|undefined} */
|
|
1905
|
-
NgOption.prototype.label;
|
|
1906
|
-
/** @type {?|undefined} */
|
|
1907
|
-
NgOption.prototype.value;
|
|
1908
|
-
/** @type {?|undefined} */
|
|
1909
|
-
NgOption.prototype.parent;
|
|
1910
|
-
/** @type {?|undefined} */
|
|
1911
|
-
NgOption.prototype.children;
|
|
1912
|
-
/* Skipping unhandled member: [name: string]: any;*/
|
|
1913
|
-
}
|
|
1914
|
-
/** @enum {number} */
|
|
1915
|
-
const KeyCode = {
|
|
1916
|
-
Tab: 9,
|
|
1917
|
-
Enter: 13,
|
|
1918
|
-
Esc: 27,
|
|
1919
|
-
Space: 32,
|
|
1920
|
-
ArrowUp: 38,
|
|
1921
|
-
ArrowDown: 40,
|
|
1922
|
-
Backspace: 8,
|
|
1923
|
-
};
|
|
1924
|
-
KeyCode[KeyCode.Tab] = 'Tab';
|
|
1925
|
-
KeyCode[KeyCode.Enter] = 'Enter';
|
|
1926
|
-
KeyCode[KeyCode.Esc] = 'Esc';
|
|
1927
|
-
KeyCode[KeyCode.Space] = 'Space';
|
|
1928
|
-
KeyCode[KeyCode.ArrowUp] = 'ArrowUp';
|
|
1929
|
-
KeyCode[KeyCode.ArrowDown] = 'ArrowDown';
|
|
1930
|
-
KeyCode[KeyCode.Backspace] = 'Backspace';
|
|
1397
|
+
var KeyCode;
|
|
1398
|
+
(function (KeyCode) {
|
|
1399
|
+
KeyCode[KeyCode["Tab"] = 9] = "Tab";
|
|
1400
|
+
KeyCode[KeyCode["Enter"] = 13] = "Enter";
|
|
1401
|
+
KeyCode[KeyCode["Esc"] = 27] = "Esc";
|
|
1402
|
+
KeyCode[KeyCode["Space"] = 32] = "Space";
|
|
1403
|
+
KeyCode[KeyCode["ArrowUp"] = 38] = "ArrowUp";
|
|
1404
|
+
KeyCode[KeyCode["ArrowDown"] = 40] = "ArrowDown";
|
|
1405
|
+
KeyCode[KeyCode["Backspace"] = 8] = "Backspace";
|
|
1406
|
+
})(KeyCode || (KeyCode = {}));
|
|
1931
1407
|
|
|
1932
|
-
/**
|
|
1933
|
-
* @fileoverview added by tsickle
|
|
1934
|
-
* Generated from: lib/ng-dropdown-panel.service.ts
|
|
1935
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1936
|
-
*/
|
|
1937
|
-
/**
|
|
1938
|
-
* @record
|
|
1939
|
-
*/
|
|
1940
|
-
function ItemsRangeResult() { }
|
|
1941
|
-
if (false) {
|
|
1942
|
-
/** @type {?} */
|
|
1943
|
-
ItemsRangeResult.prototype.scrollHeight;
|
|
1944
|
-
/** @type {?} */
|
|
1945
|
-
ItemsRangeResult.prototype.topPadding;
|
|
1946
|
-
/** @type {?} */
|
|
1947
|
-
ItemsRangeResult.prototype.start;
|
|
1948
|
-
/** @type {?} */
|
|
1949
|
-
ItemsRangeResult.prototype.end;
|
|
1950
|
-
}
|
|
1951
|
-
/**
|
|
1952
|
-
* @record
|
|
1953
|
-
*/
|
|
1954
|
-
function PanelDimensions() { }
|
|
1955
|
-
if (false) {
|
|
1956
|
-
/** @type {?} */
|
|
1957
|
-
PanelDimensions.prototype.itemHeight;
|
|
1958
|
-
/** @type {?} */
|
|
1959
|
-
PanelDimensions.prototype.panelHeight;
|
|
1960
|
-
/** @type {?} */
|
|
1961
|
-
PanelDimensions.prototype.itemsPerViewport;
|
|
1962
|
-
}
|
|
1963
1408
|
class NgDropdownPanelService {
|
|
1964
1409
|
constructor() {
|
|
1965
1410
|
this._dimensions = {
|
|
@@ -1968,36 +1413,18 @@ class NgDropdownPanelService {
|
|
|
1968
1413
|
itemsPerViewport: 0
|
|
1969
1414
|
};
|
|
1970
1415
|
}
|
|
1971
|
-
/**
|
|
1972
|
-
* @return {?}
|
|
1973
|
-
*/
|
|
1974
1416
|
get dimensions() {
|
|
1975
1417
|
return this._dimensions;
|
|
1976
1418
|
}
|
|
1977
|
-
/**
|
|
1978
|
-
* @param {?} scrollPos
|
|
1979
|
-
* @param {?} itemsLength
|
|
1980
|
-
* @param {?} buffer
|
|
1981
|
-
* @return {?}
|
|
1982
|
-
*/
|
|
1983
1419
|
calculateItems(scrollPos, itemsLength, buffer) {
|
|
1984
|
-
/** @type {?} */
|
|
1985
1420
|
const d = this._dimensions;
|
|
1986
|
-
/** @type {?} */
|
|
1987
1421
|
const scrollHeight = d.itemHeight * itemsLength;
|
|
1988
|
-
/** @type {?} */
|
|
1989
1422
|
const scrollTop = Math.max(0, scrollPos);
|
|
1990
|
-
/** @type {?} */
|
|
1991
1423
|
const indexByScrollTop = scrollTop / scrollHeight * itemsLength;
|
|
1992
|
-
/** @type {?} */
|
|
1993
1424
|
let end = Math.min(itemsLength, Math.ceil(indexByScrollTop) + (d.itemsPerViewport + 1));
|
|
1994
|
-
/** @type {?} */
|
|
1995
1425
|
const maxStartEnd = end;
|
|
1996
|
-
/** @type {?} */
|
|
1997
1426
|
const maxStart = Math.max(0, maxStartEnd - d.itemsPerViewport);
|
|
1998
|
-
/** @type {?} */
|
|
1999
1427
|
let start = Math.min(maxStart, Math.floor(indexByScrollTop));
|
|
2000
|
-
/** @type {?} */
|
|
2001
1428
|
let topPadding = d.itemHeight * Math.ceil(start) - (d.itemHeight * Math.min(start, buffer));
|
|
2002
1429
|
topPadding = !isNaN(topPadding) ? topPadding : 0;
|
|
2003
1430
|
start = !isNaN(start) ? start : -1;
|
|
@@ -2013,13 +1440,7 @@ class NgDropdownPanelService {
|
|
|
2013
1440
|
end
|
|
2014
1441
|
};
|
|
2015
1442
|
}
|
|
2016
|
-
/**
|
|
2017
|
-
* @param {?} itemHeight
|
|
2018
|
-
* @param {?} panelHeight
|
|
2019
|
-
* @return {?}
|
|
2020
|
-
*/
|
|
2021
1443
|
setDimensions(itemHeight, panelHeight) {
|
|
2022
|
-
/** @type {?} */
|
|
2023
1444
|
const itemsPerViewport = Math.max(1, Math.floor(panelHeight / itemHeight));
|
|
2024
1445
|
this._dimensions = {
|
|
2025
1446
|
itemHeight,
|
|
@@ -2027,19 +1448,10 @@ class NgDropdownPanelService {
|
|
|
2027
1448
|
itemsPerViewport
|
|
2028
1449
|
};
|
|
2029
1450
|
}
|
|
2030
|
-
/**
|
|
2031
|
-
* @param {?} itemTop
|
|
2032
|
-
* @param {?} itemHeight
|
|
2033
|
-
* @param {?} lastScroll
|
|
2034
|
-
* @return {?}
|
|
2035
|
-
*/
|
|
2036
1451
|
getScrollTo(itemTop, itemHeight, lastScroll) {
|
|
2037
1452
|
const { panelHeight } = this.dimensions;
|
|
2038
|
-
/** @type {?} */
|
|
2039
1453
|
const itemBottom = itemTop + itemHeight;
|
|
2040
|
-
/** @type {?} */
|
|
2041
1454
|
const top = lastScroll;
|
|
2042
|
-
/** @type {?} */
|
|
2043
1455
|
const bottom = top + panelHeight;
|
|
2044
1456
|
if (panelHeight >= itemBottom && lastScroll === itemTop) {
|
|
2045
1457
|
return null;
|
|
@@ -2056,33 +1468,11 @@ class NgDropdownPanelService {
|
|
|
2056
1468
|
NgDropdownPanelService.decorators = [
|
|
2057
1469
|
{ type: Injectable }
|
|
2058
1470
|
];
|
|
2059
|
-
if (false) {
|
|
2060
|
-
/**
|
|
2061
|
-
* @type {?}
|
|
2062
|
-
* @private
|
|
2063
|
-
*/
|
|
2064
|
-
NgDropdownPanelService.prototype._dimensions;
|
|
2065
|
-
}
|
|
2066
1471
|
|
|
2067
|
-
/**
|
|
2068
|
-
* @fileoverview added by tsickle
|
|
2069
|
-
* Generated from: lib/ng-dropdown-panel.component.ts
|
|
2070
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2071
|
-
*/
|
|
2072
|
-
/** @type {?} */
|
|
2073
1472
|
const TOP_CSS_CLASS = 'ng-select-top';
|
|
2074
|
-
/** @type {?} */
|
|
2075
1473
|
const BOTTOM_CSS_CLASS = 'ng-select-bottom';
|
|
2076
|
-
/** @type {?} */
|
|
2077
1474
|
const SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;
|
|
2078
1475
|
class NgDropdownPanelComponent {
|
|
2079
|
-
/**
|
|
2080
|
-
* @param {?} _renderer
|
|
2081
|
-
* @param {?} _zone
|
|
2082
|
-
* @param {?} _panelService
|
|
2083
|
-
* @param {?} _elementRef
|
|
2084
|
-
* @param {?} _document
|
|
2085
|
-
*/
|
|
2086
1476
|
constructor(_renderer, _zone, _panelService, _elementRef, _document) {
|
|
2087
1477
|
this._renderer = _renderer;
|
|
2088
1478
|
this._zone = _zone;
|
|
@@ -2102,58 +1492,33 @@ class NgDropdownPanelComponent {
|
|
|
2102
1492
|
this._lastScrollPosition = 0;
|
|
2103
1493
|
this._dropdown = _elementRef.nativeElement;
|
|
2104
1494
|
}
|
|
2105
|
-
/**
|
|
2106
|
-
* @return {?}
|
|
2107
|
-
*/
|
|
2108
1495
|
get currentPosition() {
|
|
2109
1496
|
return this._currentPosition;
|
|
2110
1497
|
}
|
|
2111
|
-
/**
|
|
2112
|
-
* @private
|
|
2113
|
-
* @return {?}
|
|
2114
|
-
*/
|
|
2115
1498
|
get itemsLength() {
|
|
2116
1499
|
return this._itemsLength;
|
|
2117
1500
|
}
|
|
2118
|
-
/**
|
|
2119
|
-
* @private
|
|
2120
|
-
* @param {?} value
|
|
2121
|
-
* @return {?}
|
|
2122
|
-
*/
|
|
2123
1501
|
set itemsLength(value) {
|
|
2124
1502
|
if (value !== this._itemsLength) {
|
|
2125
1503
|
this._itemsLength = value;
|
|
2126
1504
|
this._onItemsLengthChanged();
|
|
2127
1505
|
}
|
|
2128
1506
|
}
|
|
2129
|
-
/**
|
|
2130
|
-
* @private
|
|
2131
|
-
* @return {?}
|
|
2132
|
-
*/
|
|
2133
1507
|
get _startOffset() {
|
|
2134
1508
|
if (this.markedItem) {
|
|
2135
1509
|
const { itemHeight, panelHeight } = this._panelService.dimensions;
|
|
2136
|
-
/** @type {?} */
|
|
2137
1510
|
const offset = this.markedItem.index * itemHeight;
|
|
2138
1511
|
return panelHeight > offset ? 0 : offset;
|
|
2139
1512
|
}
|
|
2140
1513
|
return 0;
|
|
2141
1514
|
}
|
|
2142
|
-
/**
|
|
2143
|
-
* @param {?} $event
|
|
2144
|
-
* @return {?}
|
|
2145
|
-
*/
|
|
2146
1515
|
handleMousedown($event) {
|
|
2147
|
-
|
|
2148
|
-
const target = (/** @type {?} */ ($event.target));
|
|
1516
|
+
const target = $event.target;
|
|
2149
1517
|
if (target.tagName === 'INPUT') {
|
|
2150
1518
|
return;
|
|
2151
1519
|
}
|
|
2152
1520
|
$event.preventDefault();
|
|
2153
1521
|
}
|
|
2154
|
-
/**
|
|
2155
|
-
* @return {?}
|
|
2156
|
-
*/
|
|
2157
1522
|
ngOnInit() {
|
|
2158
1523
|
this._select = this._dropdown.parentElement;
|
|
2159
1524
|
this._virtualPadding = this.paddingElementRef.nativeElement;
|
|
@@ -2163,20 +1528,12 @@ class NgDropdownPanelComponent {
|
|
|
2163
1528
|
this._handleOutsideClick();
|
|
2164
1529
|
this._appendDropdown();
|
|
2165
1530
|
}
|
|
2166
|
-
/**
|
|
2167
|
-
* @param {?} changes
|
|
2168
|
-
* @return {?}
|
|
2169
|
-
*/
|
|
2170
1531
|
ngOnChanges(changes) {
|
|
2171
1532
|
if (changes.items) {
|
|
2172
|
-
/** @type {?} */
|
|
2173
1533
|
const change = changes.items;
|
|
2174
1534
|
this._onItemsChange(change.currentValue, change.firstChange);
|
|
2175
1535
|
}
|
|
2176
1536
|
}
|
|
2177
|
-
/**
|
|
2178
|
-
* @return {?}
|
|
2179
|
-
*/
|
|
2180
1537
|
ngOnDestroy() {
|
|
2181
1538
|
this._destroy$.next();
|
|
2182
1539
|
this._destroy$.complete();
|
|
@@ -2185,31 +1542,21 @@ class NgDropdownPanelComponent {
|
|
|
2185
1542
|
this._renderer.removeChild(this._dropdown.parentNode, this._dropdown);
|
|
2186
1543
|
}
|
|
2187
1544
|
}
|
|
2188
|
-
/**
|
|
2189
|
-
* @param {?} option
|
|
2190
|
-
* @param {?=} startFromOption
|
|
2191
|
-
* @return {?}
|
|
2192
|
-
*/
|
|
2193
1545
|
scrollTo(option, startFromOption = false) {
|
|
2194
1546
|
if (!option) {
|
|
2195
1547
|
return;
|
|
2196
1548
|
}
|
|
2197
|
-
/** @type {?} */
|
|
2198
1549
|
const index = this.items.indexOf(option);
|
|
2199
1550
|
if (index < 0 || index >= this.itemsLength) {
|
|
2200
1551
|
return;
|
|
2201
1552
|
}
|
|
2202
|
-
/** @type {?} */
|
|
2203
1553
|
let scrollTo;
|
|
2204
1554
|
if (this.virtualScroll) {
|
|
2205
|
-
/** @type {?} */
|
|
2206
1555
|
const itemHeight = this._panelService.dimensions.itemHeight;
|
|
2207
1556
|
scrollTo = this._panelService.getScrollTo(index * itemHeight, itemHeight, this._lastScrollPosition);
|
|
2208
1557
|
}
|
|
2209
1558
|
else {
|
|
2210
|
-
/** @type {?} */
|
|
2211
1559
|
const item = this._dropdown.querySelector(`#${option.htmlId}`);
|
|
2212
|
-
/** @type {?} */
|
|
2213
1560
|
const lastScroll = startFromOption ? item.offsetTop : this._lastScrollPosition;
|
|
2214
1561
|
scrollTo = this._panelService.getScrollTo(item.offsetTop, item.clientHeight, lastScroll);
|
|
2215
1562
|
}
|
|
@@ -2217,24 +1564,13 @@ class NgDropdownPanelComponent {
|
|
|
2217
1564
|
this._scrollablePanel.scrollTop = scrollTo;
|
|
2218
1565
|
}
|
|
2219
1566
|
}
|
|
2220
|
-
/**
|
|
2221
|
-
* @return {?}
|
|
2222
|
-
*/
|
|
2223
1567
|
scrollToTag() {
|
|
2224
|
-
/** @type {?} */
|
|
2225
1568
|
const panel = this._scrollablePanel;
|
|
2226
1569
|
panel.scrollTop = panel.scrollHeight - panel.clientHeight;
|
|
2227
1570
|
}
|
|
2228
|
-
/**
|
|
2229
|
-
* @return {?}
|
|
2230
|
-
*/
|
|
2231
1571
|
adjustPosition() {
|
|
2232
1572
|
this._updateYPosition();
|
|
2233
1573
|
}
|
|
2234
|
-
/**
|
|
2235
|
-
* @private
|
|
2236
|
-
* @return {?}
|
|
2237
|
-
*/
|
|
2238
1574
|
_handleDropdownPosition() {
|
|
2239
1575
|
this._currentPosition = this._calculateCurrentPosition(this._dropdown);
|
|
2240
1576
|
if (this._currentPosition === 'top') {
|
|
@@ -2254,75 +1590,36 @@ class NgDropdownPanelComponent {
|
|
|
2254
1590
|
}
|
|
2255
1591
|
this._dropdown.style.opacity = '1';
|
|
2256
1592
|
}
|
|
2257
|
-
/**
|
|
2258
|
-
* @private
|
|
2259
|
-
* @return {?}
|
|
2260
|
-
*/
|
|
2261
1593
|
_handleScroll() {
|
|
2262
|
-
this._zone.runOutsideAngular((
|
|
2263
|
-
* @return {?}
|
|
2264
|
-
*/
|
|
2265
|
-
() => {
|
|
1594
|
+
this._zone.runOutsideAngular(() => {
|
|
2266
1595
|
fromEvent(this.scrollElementRef.nativeElement, 'scroll')
|
|
2267
1596
|
.pipe(takeUntil(this._destroy$), auditTime(0, SCROLL_SCHEDULER))
|
|
2268
|
-
.subscribe((
|
|
2269
|
-
* @param {?} e
|
|
2270
|
-
* @return {?}
|
|
2271
|
-
*/
|
|
2272
|
-
(e) => {
|
|
2273
|
-
/** @type {?} */
|
|
1597
|
+
.subscribe((e) => {
|
|
2274
1598
|
const path = e.path || (e.composedPath && e.composedPath());
|
|
2275
|
-
/** @type {?} */
|
|
2276
1599
|
const scrollTop = !path || path.length === 0 ? e.target.scrollTop : path[0].scrollTop;
|
|
2277
1600
|
this._onContentScrolled(scrollTop);
|
|
2278
|
-
})
|
|
2279
|
-
})
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
2280
1603
|
}
|
|
2281
|
-
/**
|
|
2282
|
-
* @private
|
|
2283
|
-
* @return {?}
|
|
2284
|
-
*/
|
|
2285
1604
|
_handleOutsideClick() {
|
|
2286
1605
|
if (!this._document) {
|
|
2287
1606
|
return;
|
|
2288
1607
|
}
|
|
2289
|
-
this._zone.runOutsideAngular((
|
|
2290
|
-
* @return {?}
|
|
2291
|
-
*/
|
|
2292
|
-
() => {
|
|
1608
|
+
this._zone.runOutsideAngular(() => {
|
|
2293
1609
|
merge(fromEvent(this._document, 'touchstart', { capture: true }), fromEvent(this._document, 'mousedown', { capture: true })).pipe(takeUntil(this._destroy$))
|
|
2294
|
-
.subscribe((
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
*/
|
|
2298
|
-
$event => this._checkToClose($event)));
|
|
2299
|
-
}));
|
|
2300
|
-
}
|
|
2301
|
-
/**
|
|
2302
|
-
* @private
|
|
2303
|
-
* @param {?} $event
|
|
2304
|
-
* @return {?}
|
|
2305
|
-
*/
|
|
1610
|
+
.subscribe($event => this._checkToClose($event));
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
2306
1613
|
_checkToClose($event) {
|
|
2307
1614
|
if (this._select.contains($event.target) || this._dropdown.contains($event.target)) {
|
|
2308
1615
|
return;
|
|
2309
1616
|
}
|
|
2310
|
-
/** @type {?} */
|
|
2311
1617
|
const path = $event.path || ($event.composedPath && $event.composedPath());
|
|
2312
1618
|
if ($event.target && $event.target.shadowRoot && path && path[0] && this._select.contains(path[0])) {
|
|
2313
1619
|
return;
|
|
2314
1620
|
}
|
|
2315
|
-
this._zone.run((
|
|
2316
|
-
|
|
2317
|
-
*/
|
|
2318
|
-
() => this.outsideClick.emit()));
|
|
2319
|
-
}
|
|
2320
|
-
/**
|
|
2321
|
-
* @private
|
|
2322
|
-
* @param {?} items
|
|
2323
|
-
* @param {?} firstChange
|
|
2324
|
-
* @return {?}
|
|
2325
|
-
*/
|
|
1621
|
+
this._zone.run(() => this.outsideClick.emit());
|
|
1622
|
+
}
|
|
2326
1623
|
_onItemsChange(items, firstChange) {
|
|
2327
1624
|
this.items = items || [];
|
|
2328
1625
|
this._scrollToEndFired = false;
|
|
@@ -2335,46 +1632,23 @@ class NgDropdownPanelComponent {
|
|
|
2335
1632
|
this._updateItems(firstChange);
|
|
2336
1633
|
}
|
|
2337
1634
|
}
|
|
2338
|
-
/**
|
|
2339
|
-
* @private
|
|
2340
|
-
* @param {?} firstChange
|
|
2341
|
-
* @return {?}
|
|
2342
|
-
*/
|
|
2343
1635
|
_updateItems(firstChange) {
|
|
2344
1636
|
this.update.emit(this.items);
|
|
2345
1637
|
if (firstChange === false) {
|
|
2346
1638
|
return;
|
|
2347
1639
|
}
|
|
2348
|
-
this._zone.runOutsideAngular((
|
|
2349
|
-
|
|
2350
|
-
*/
|
|
2351
|
-
() => {
|
|
2352
|
-
Promise.resolve().then((/**
|
|
2353
|
-
* @return {?}
|
|
2354
|
-
*/
|
|
2355
|
-
() => {
|
|
2356
|
-
/** @type {?} */
|
|
1640
|
+
this._zone.runOutsideAngular(() => {
|
|
1641
|
+
Promise.resolve().then(() => {
|
|
2357
1642
|
const panelHeight = this._scrollablePanel.clientHeight;
|
|
2358
1643
|
this._panelService.setDimensions(0, panelHeight);
|
|
2359
1644
|
this._handleDropdownPosition();
|
|
2360
1645
|
this.scrollTo(this.markedItem, firstChange);
|
|
2361
|
-
})
|
|
2362
|
-
})
|
|
1646
|
+
});
|
|
1647
|
+
});
|
|
2363
1648
|
}
|
|
2364
|
-
/**
|
|
2365
|
-
* @private
|
|
2366
|
-
* @param {?} firstChange
|
|
2367
|
-
* @return {?}
|
|
2368
|
-
*/
|
|
2369
1649
|
_updateItemsRange(firstChange) {
|
|
2370
|
-
this._zone.runOutsideAngular((
|
|
2371
|
-
|
|
2372
|
-
*/
|
|
2373
|
-
() => {
|
|
2374
|
-
this._measureDimensions().then((/**
|
|
2375
|
-
* @return {?}
|
|
2376
|
-
*/
|
|
2377
|
-
() => {
|
|
1650
|
+
this._zone.runOutsideAngular(() => {
|
|
1651
|
+
this._measureDimensions().then(() => {
|
|
2378
1652
|
if (firstChange) {
|
|
2379
1653
|
this._renderItemsRange(this._startOffset);
|
|
2380
1654
|
this._handleDropdownPosition();
|
|
@@ -2382,14 +1656,9 @@ class NgDropdownPanelComponent {
|
|
|
2382
1656
|
else {
|
|
2383
1657
|
this._renderItemsRange();
|
|
2384
1658
|
}
|
|
2385
|
-
})
|
|
2386
|
-
})
|
|
1659
|
+
});
|
|
1660
|
+
});
|
|
2387
1661
|
}
|
|
2388
|
-
/**
|
|
2389
|
-
* @private
|
|
2390
|
-
* @param {?} scrollTop
|
|
2391
|
-
* @return {?}
|
|
2392
|
-
*/
|
|
2393
1662
|
_onContentScrolled(scrollTop) {
|
|
2394
1663
|
if (this.virtualScroll) {
|
|
2395
1664
|
this._renderItemsRange(scrollTop);
|
|
@@ -2397,124 +1666,73 @@ class NgDropdownPanelComponent {
|
|
|
2397
1666
|
this._lastScrollPosition = scrollTop;
|
|
2398
1667
|
this._fireScrollToEnd(scrollTop);
|
|
2399
1668
|
}
|
|
2400
|
-
/**
|
|
2401
|
-
* @private
|
|
2402
|
-
* @param {?} height
|
|
2403
|
-
* @return {?}
|
|
2404
|
-
*/
|
|
2405
1669
|
_updateVirtualHeight(height) {
|
|
2406
1670
|
if (this._updateScrollHeight) {
|
|
2407
1671
|
this._virtualPadding.style.height = `${height}px`;
|
|
2408
1672
|
this._updateScrollHeight = false;
|
|
2409
1673
|
}
|
|
2410
1674
|
}
|
|
2411
|
-
/**
|
|
2412
|
-
* @private
|
|
2413
|
-
* @return {?}
|
|
2414
|
-
*/
|
|
2415
1675
|
_setVirtualHeight() {
|
|
2416
1676
|
if (!this._virtualPadding) {
|
|
2417
1677
|
return;
|
|
2418
1678
|
}
|
|
2419
1679
|
this._virtualPadding.style.height = `0px`;
|
|
2420
1680
|
}
|
|
2421
|
-
/**
|
|
2422
|
-
* @private
|
|
2423
|
-
* @return {?}
|
|
2424
|
-
*/
|
|
2425
1681
|
_onItemsLengthChanged() {
|
|
2426
1682
|
this._updateScrollHeight = true;
|
|
2427
1683
|
}
|
|
2428
|
-
/**
|
|
2429
|
-
* @private
|
|
2430
|
-
* @param {?=} scrollTop
|
|
2431
|
-
* @return {?}
|
|
2432
|
-
*/
|
|
2433
1684
|
_renderItemsRange(scrollTop = null) {
|
|
2434
1685
|
if (scrollTop && this._lastScrollPosition === scrollTop) {
|
|
2435
1686
|
return;
|
|
2436
1687
|
}
|
|
2437
1688
|
scrollTop = scrollTop || this._scrollablePanel.scrollTop;
|
|
2438
|
-
/** @type {?} */
|
|
2439
1689
|
const range = this._panelService.calculateItems(scrollTop, this.itemsLength, this.bufferAmount);
|
|
2440
1690
|
this._updateVirtualHeight(range.scrollHeight);
|
|
2441
1691
|
this._contentPanel.style.transform = `translateY(${range.topPadding}px)`;
|
|
2442
|
-
this._zone.run((
|
|
2443
|
-
* @return {?}
|
|
2444
|
-
*/
|
|
2445
|
-
() => {
|
|
1692
|
+
this._zone.run(() => {
|
|
2446
1693
|
this.update.emit(this.items.slice(range.start, range.end));
|
|
2447
1694
|
this.scroll.emit({ start: range.start, end: range.end });
|
|
2448
|
-
})
|
|
1695
|
+
});
|
|
2449
1696
|
if (isDefined(scrollTop) && this._lastScrollPosition === 0) {
|
|
2450
1697
|
this._scrollablePanel.scrollTop = scrollTop;
|
|
2451
1698
|
this._lastScrollPosition = scrollTop;
|
|
2452
1699
|
}
|
|
2453
1700
|
}
|
|
2454
|
-
/**
|
|
2455
|
-
* @private
|
|
2456
|
-
* @return {?}
|
|
2457
|
-
*/
|
|
2458
1701
|
_measureDimensions() {
|
|
2459
1702
|
if (this._panelService.dimensions.itemHeight > 0 || this.itemsLength === 0) {
|
|
2460
1703
|
return Promise.resolve(this._panelService.dimensions);
|
|
2461
1704
|
}
|
|
2462
1705
|
const [first] = this.items;
|
|
2463
1706
|
this.update.emit([first]);
|
|
2464
|
-
return Promise.resolve().then((
|
|
2465
|
-
* @return {?}
|
|
2466
|
-
*/
|
|
2467
|
-
() => {
|
|
2468
|
-
/** @type {?} */
|
|
1707
|
+
return Promise.resolve().then(() => {
|
|
2469
1708
|
const option = this._dropdown.querySelector(`#${first.htmlId}`);
|
|
2470
|
-
/** @type {?} */
|
|
2471
1709
|
const optionHeight = option.clientHeight;
|
|
2472
1710
|
this._virtualPadding.style.height = `${optionHeight * this.itemsLength}px`;
|
|
2473
|
-
/** @type {?} */
|
|
2474
1711
|
const panelHeight = this._scrollablePanel.clientHeight;
|
|
2475
1712
|
this._panelService.setDimensions(optionHeight, panelHeight);
|
|
2476
1713
|
return this._panelService.dimensions;
|
|
2477
|
-
})
|
|
1714
|
+
});
|
|
2478
1715
|
}
|
|
2479
|
-
/**
|
|
2480
|
-
* @private
|
|
2481
|
-
* @param {?} scrollTop
|
|
2482
|
-
* @return {?}
|
|
2483
|
-
*/
|
|
2484
1716
|
_fireScrollToEnd(scrollTop) {
|
|
2485
1717
|
if (this._scrollToEndFired || scrollTop === 0) {
|
|
2486
1718
|
return;
|
|
2487
1719
|
}
|
|
2488
|
-
/** @type {?} */
|
|
2489
1720
|
const padding = this.virtualScroll ?
|
|
2490
1721
|
this._virtualPadding :
|
|
2491
1722
|
this._contentPanel;
|
|
2492
1723
|
if (scrollTop + this._dropdown.clientHeight >= padding.clientHeight) {
|
|
2493
|
-
this._zone.run((
|
|
2494
|
-
* @return {?}
|
|
2495
|
-
*/
|
|
2496
|
-
() => this.scrollToEnd.emit()));
|
|
1724
|
+
this._zone.run(() => this.scrollToEnd.emit());
|
|
2497
1725
|
this._scrollToEndFired = true;
|
|
2498
1726
|
}
|
|
2499
1727
|
}
|
|
2500
|
-
/**
|
|
2501
|
-
* @private
|
|
2502
|
-
* @param {?} dropdownEl
|
|
2503
|
-
* @return {?}
|
|
2504
|
-
*/
|
|
2505
1728
|
_calculateCurrentPosition(dropdownEl) {
|
|
2506
1729
|
if (this.position !== 'auto') {
|
|
2507
1730
|
return this.position;
|
|
2508
1731
|
}
|
|
2509
|
-
/** @type {?} */
|
|
2510
1732
|
const selectRect = this._select.getBoundingClientRect();
|
|
2511
|
-
/** @type {?} */
|
|
2512
1733
|
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
2513
|
-
/** @type {?} */
|
|
2514
1734
|
const offsetTop = selectRect.top + window.pageYOffset;
|
|
2515
|
-
/** @type {?} */
|
|
2516
1735
|
const height = selectRect.height;
|
|
2517
|
-
/** @type {?} */
|
|
2518
1736
|
const dropdownHeight = dropdownEl.getBoundingClientRect().height;
|
|
2519
1737
|
if (offsetTop + height + dropdownHeight > scrollTop + document.documentElement.clientHeight) {
|
|
2520
1738
|
return 'top';
|
|
@@ -2523,10 +1741,6 @@ class NgDropdownPanelComponent {
|
|
|
2523
1741
|
return 'bottom';
|
|
2524
1742
|
}
|
|
2525
1743
|
}
|
|
2526
|
-
/**
|
|
2527
|
-
* @private
|
|
2528
|
-
* @return {?}
|
|
2529
|
-
*/
|
|
2530
1744
|
_appendDropdown() {
|
|
2531
1745
|
if (!this.appendTo) {
|
|
2532
1746
|
return;
|
|
@@ -2538,40 +1752,24 @@ class NgDropdownPanelComponent {
|
|
|
2538
1752
|
this._updateXPosition();
|
|
2539
1753
|
this._parent.appendChild(this._dropdown);
|
|
2540
1754
|
}
|
|
2541
|
-
/**
|
|
2542
|
-
* @private
|
|
2543
|
-
* @return {?}
|
|
2544
|
-
*/
|
|
2545
1755
|
_updateXPosition() {
|
|
2546
|
-
/** @type {?} */
|
|
2547
1756
|
const select = this._select.getBoundingClientRect();
|
|
2548
|
-
/** @type {?} */
|
|
2549
1757
|
const parent = this._parent.getBoundingClientRect();
|
|
2550
|
-
/** @type {?} */
|
|
2551
1758
|
const offsetLeft = select.left - parent.left;
|
|
2552
1759
|
this._dropdown.style.left = offsetLeft + 'px';
|
|
2553
1760
|
this._dropdown.style.width = select.width + 'px';
|
|
2554
1761
|
this._dropdown.style.minWidth = select.width + 'px';
|
|
2555
1762
|
}
|
|
2556
|
-
/**
|
|
2557
|
-
* @private
|
|
2558
|
-
* @return {?}
|
|
2559
|
-
*/
|
|
2560
1763
|
_updateYPosition() {
|
|
2561
|
-
/** @type {?} */
|
|
2562
1764
|
const select = this._select.getBoundingClientRect();
|
|
2563
|
-
/** @type {?} */
|
|
2564
1765
|
const parent = this._parent.getBoundingClientRect();
|
|
2565
|
-
/** @type {?} */
|
|
2566
1766
|
const delta = select.height;
|
|
2567
1767
|
if (this._currentPosition === 'top') {
|
|
2568
|
-
/** @type {?} */
|
|
2569
1768
|
const offsetBottom = parent.bottom - select.bottom;
|
|
2570
1769
|
this._dropdown.style.bottom = offsetBottom + delta + 'px';
|
|
2571
1770
|
this._dropdown.style.top = 'auto';
|
|
2572
1771
|
}
|
|
2573
1772
|
else if (this._currentPosition === 'bottom') {
|
|
2574
|
-
/** @type {?} */
|
|
2575
1773
|
const offsetTop = select.top - parent.top;
|
|
2576
1774
|
this._dropdown.style.top = offsetTop + delta + 'px';
|
|
2577
1775
|
this._dropdown.style.bottom = 'auto';
|
|
@@ -2597,9 +1795,8 @@ NgDropdownPanelComponent.decorators = [
|
|
|
2597
1795
|
<ng-container [ngTemplateOutlet]="footerTemplate" [ngTemplateOutletContext]="{ searchTerm: filterValue }"></ng-container>
|
|
2598
1796
|
</div>
|
|
2599
1797
|
`
|
|
2600
|
-
}] }
|
|
1798
|
+
},] }
|
|
2601
1799
|
];
|
|
2602
|
-
/** @nocollapse */
|
|
2603
1800
|
NgDropdownPanelComponent.ctorParameters = () => [
|
|
2604
1801
|
{ type: Renderer2 },
|
|
2605
1802
|
{ type: NgZone },
|
|
@@ -2626,154 +1823,18 @@ NgDropdownPanelComponent.propDecorators = {
|
|
|
2626
1823
|
paddingElementRef: [{ type: ViewChild, args: ['padding', { read: ElementRef, static: true },] }],
|
|
2627
1824
|
handleMousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }]
|
|
2628
1825
|
};
|
|
2629
|
-
if (false) {
|
|
2630
|
-
/** @type {?} */
|
|
2631
|
-
NgDropdownPanelComponent.prototype.items;
|
|
2632
|
-
/** @type {?} */
|
|
2633
|
-
NgDropdownPanelComponent.prototype.markedItem;
|
|
2634
|
-
/** @type {?} */
|
|
2635
|
-
NgDropdownPanelComponent.prototype.position;
|
|
2636
|
-
/** @type {?} */
|
|
2637
|
-
NgDropdownPanelComponent.prototype.appendTo;
|
|
2638
|
-
/** @type {?} */
|
|
2639
|
-
NgDropdownPanelComponent.prototype.bufferAmount;
|
|
2640
|
-
/** @type {?} */
|
|
2641
|
-
NgDropdownPanelComponent.prototype.virtualScroll;
|
|
2642
|
-
/** @type {?} */
|
|
2643
|
-
NgDropdownPanelComponent.prototype.headerTemplate;
|
|
2644
|
-
/** @type {?} */
|
|
2645
|
-
NgDropdownPanelComponent.prototype.footerTemplate;
|
|
2646
|
-
/** @type {?} */
|
|
2647
|
-
NgDropdownPanelComponent.prototype.filterValue;
|
|
2648
|
-
/** @type {?} */
|
|
2649
|
-
NgDropdownPanelComponent.prototype.update;
|
|
2650
|
-
/** @type {?} */
|
|
2651
|
-
NgDropdownPanelComponent.prototype.scroll;
|
|
2652
|
-
/** @type {?} */
|
|
2653
|
-
NgDropdownPanelComponent.prototype.scrollToEnd;
|
|
2654
|
-
/** @type {?} */
|
|
2655
|
-
NgDropdownPanelComponent.prototype.outsideClick;
|
|
2656
|
-
/** @type {?} */
|
|
2657
|
-
NgDropdownPanelComponent.prototype.contentElementRef;
|
|
2658
|
-
/** @type {?} */
|
|
2659
|
-
NgDropdownPanelComponent.prototype.scrollElementRef;
|
|
2660
|
-
/** @type {?} */
|
|
2661
|
-
NgDropdownPanelComponent.prototype.paddingElementRef;
|
|
2662
|
-
/**
|
|
2663
|
-
* @type {?}
|
|
2664
|
-
* @private
|
|
2665
|
-
*/
|
|
2666
|
-
NgDropdownPanelComponent.prototype._destroy$;
|
|
2667
|
-
/**
|
|
2668
|
-
* @type {?}
|
|
2669
|
-
* @private
|
|
2670
|
-
*/
|
|
2671
|
-
NgDropdownPanelComponent.prototype._dropdown;
|
|
2672
|
-
/**
|
|
2673
|
-
* @type {?}
|
|
2674
|
-
* @private
|
|
2675
|
-
*/
|
|
2676
|
-
NgDropdownPanelComponent.prototype._virtualPadding;
|
|
2677
|
-
/**
|
|
2678
|
-
* @type {?}
|
|
2679
|
-
* @private
|
|
2680
|
-
*/
|
|
2681
|
-
NgDropdownPanelComponent.prototype._scrollablePanel;
|
|
2682
|
-
/**
|
|
2683
|
-
* @type {?}
|
|
2684
|
-
* @private
|
|
2685
|
-
*/
|
|
2686
|
-
NgDropdownPanelComponent.prototype._contentPanel;
|
|
2687
|
-
/**
|
|
2688
|
-
* @type {?}
|
|
2689
|
-
* @private
|
|
2690
|
-
*/
|
|
2691
|
-
NgDropdownPanelComponent.prototype._select;
|
|
2692
|
-
/**
|
|
2693
|
-
* @type {?}
|
|
2694
|
-
* @private
|
|
2695
|
-
*/
|
|
2696
|
-
NgDropdownPanelComponent.prototype._parent;
|
|
2697
|
-
/**
|
|
2698
|
-
* @type {?}
|
|
2699
|
-
* @private
|
|
2700
|
-
*/
|
|
2701
|
-
NgDropdownPanelComponent.prototype._scrollToEndFired;
|
|
2702
|
-
/**
|
|
2703
|
-
* @type {?}
|
|
2704
|
-
* @private
|
|
2705
|
-
*/
|
|
2706
|
-
NgDropdownPanelComponent.prototype._updateScrollHeight;
|
|
2707
|
-
/**
|
|
2708
|
-
* @type {?}
|
|
2709
|
-
* @private
|
|
2710
|
-
*/
|
|
2711
|
-
NgDropdownPanelComponent.prototype._lastScrollPosition;
|
|
2712
|
-
/**
|
|
2713
|
-
* @type {?}
|
|
2714
|
-
* @private
|
|
2715
|
-
*/
|
|
2716
|
-
NgDropdownPanelComponent.prototype._currentPosition;
|
|
2717
|
-
/**
|
|
2718
|
-
* @type {?}
|
|
2719
|
-
* @private
|
|
2720
|
-
*/
|
|
2721
|
-
NgDropdownPanelComponent.prototype._itemsLength;
|
|
2722
|
-
/**
|
|
2723
|
-
* @type {?}
|
|
2724
|
-
* @private
|
|
2725
|
-
*/
|
|
2726
|
-
NgDropdownPanelComponent.prototype._renderer;
|
|
2727
|
-
/**
|
|
2728
|
-
* @type {?}
|
|
2729
|
-
* @private
|
|
2730
|
-
*/
|
|
2731
|
-
NgDropdownPanelComponent.prototype._zone;
|
|
2732
|
-
/**
|
|
2733
|
-
* @type {?}
|
|
2734
|
-
* @private
|
|
2735
|
-
*/
|
|
2736
|
-
NgDropdownPanelComponent.prototype._panelService;
|
|
2737
|
-
/**
|
|
2738
|
-
* @type {?}
|
|
2739
|
-
* @private
|
|
2740
|
-
*/
|
|
2741
|
-
NgDropdownPanelComponent.prototype._document;
|
|
2742
|
-
}
|
|
2743
1826
|
|
|
2744
|
-
/**
|
|
2745
|
-
* @fileoverview added by tsickle
|
|
2746
|
-
* Generated from: lib/ng-option.component.ts
|
|
2747
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2748
|
-
*/
|
|
2749
1827
|
class NgOptionComponent {
|
|
2750
|
-
/**
|
|
2751
|
-
* @param {?} elementRef
|
|
2752
|
-
*/
|
|
2753
1828
|
constructor(elementRef) {
|
|
2754
1829
|
this.elementRef = elementRef;
|
|
2755
1830
|
this.stateChange$ = new Subject();
|
|
2756
1831
|
this._disabled = false;
|
|
2757
1832
|
}
|
|
2758
|
-
/**
|
|
2759
|
-
* @return {?}
|
|
2760
|
-
*/
|
|
2761
1833
|
get disabled() { return this._disabled; }
|
|
2762
|
-
/**
|
|
2763
|
-
* @param {?} value
|
|
2764
|
-
* @return {?}
|
|
2765
|
-
*/
|
|
2766
1834
|
set disabled(value) { this._disabled = this._isDisabled(value); }
|
|
2767
|
-
/**
|
|
2768
|
-
* @return {?}
|
|
2769
|
-
*/
|
|
2770
1835
|
get label() {
|
|
2771
1836
|
return (this.elementRef.nativeElement.textContent || '').trim();
|
|
2772
1837
|
}
|
|
2773
|
-
/**
|
|
2774
|
-
* @param {?} changes
|
|
2775
|
-
* @return {?}
|
|
2776
|
-
*/
|
|
2777
1838
|
ngOnChanges(changes) {
|
|
2778
1839
|
if (changes.disabled) {
|
|
2779
1840
|
this.stateChange$.next({
|
|
@@ -2782,9 +1843,6 @@ class NgOptionComponent {
|
|
|
2782
1843
|
});
|
|
2783
1844
|
}
|
|
2784
1845
|
}
|
|
2785
|
-
/**
|
|
2786
|
-
* @return {?}
|
|
2787
|
-
*/
|
|
2788
1846
|
ngAfterViewChecked() {
|
|
2789
1847
|
if (this.label !== this._previousLabel) {
|
|
2790
1848
|
this._previousLabel = this.label;
|
|
@@ -2795,17 +1853,9 @@ class NgOptionComponent {
|
|
|
2795
1853
|
});
|
|
2796
1854
|
}
|
|
2797
1855
|
}
|
|
2798
|
-
/**
|
|
2799
|
-
* @return {?}
|
|
2800
|
-
*/
|
|
2801
1856
|
ngOnDestroy() {
|
|
2802
1857
|
this.stateChange$.complete();
|
|
2803
1858
|
}
|
|
2804
|
-
/**
|
|
2805
|
-
* @private
|
|
2806
|
-
* @param {?} value
|
|
2807
|
-
* @return {?}
|
|
2808
|
-
*/
|
|
2809
1859
|
_isDisabled(value) {
|
|
2810
1860
|
return value != null && `${value}` !== 'false';
|
|
2811
1861
|
}
|
|
@@ -2815,9 +1865,8 @@ NgOptionComponent.decorators = [
|
|
|
2815
1865
|
selector: 'ng-option',
|
|
2816
1866
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2817
1867
|
template: `<ng-content></ng-content>`
|
|
2818
|
-
}] }
|
|
1868
|
+
},] }
|
|
2819
1869
|
];
|
|
2820
|
-
/** @nocollapse */
|
|
2821
1870
|
NgOptionComponent.ctorParameters = () => [
|
|
2822
1871
|
{ type: ElementRef }
|
|
2823
1872
|
];
|
|
@@ -2825,30 +1874,7 @@ NgOptionComponent.propDecorators = {
|
|
|
2825
1874
|
value: [{ type: Input }],
|
|
2826
1875
|
disabled: [{ type: Input }]
|
|
2827
1876
|
};
|
|
2828
|
-
if (false) {
|
|
2829
|
-
/** @type {?} */
|
|
2830
|
-
NgOptionComponent.prototype.value;
|
|
2831
|
-
/** @type {?} */
|
|
2832
|
-
NgOptionComponent.prototype.stateChange$;
|
|
2833
|
-
/**
|
|
2834
|
-
* @type {?}
|
|
2835
|
-
* @private
|
|
2836
|
-
*/
|
|
2837
|
-
NgOptionComponent.prototype._disabled;
|
|
2838
|
-
/**
|
|
2839
|
-
* @type {?}
|
|
2840
|
-
* @private
|
|
2841
|
-
*/
|
|
2842
|
-
NgOptionComponent.prototype._previousLabel;
|
|
2843
|
-
/** @type {?} */
|
|
2844
|
-
NgOptionComponent.prototype.elementRef;
|
|
2845
|
-
}
|
|
2846
1877
|
|
|
2847
|
-
/**
|
|
2848
|
-
* @fileoverview added by tsickle
|
|
2849
|
-
* Generated from: lib/config.service.ts
|
|
2850
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2851
|
-
*/
|
|
2852
1878
|
class NgSelectConfig {
|
|
2853
1879
|
constructor() {
|
|
2854
1880
|
this.notFoundText = 'No items found';
|
|
@@ -2861,52 +1887,13 @@ class NgSelectConfig {
|
|
|
2861
1887
|
this.appearance = 'underline';
|
|
2862
1888
|
}
|
|
2863
1889
|
}
|
|
1890
|
+
NgSelectConfig.ɵprov = ɵɵdefineInjectable({ factory: function NgSelectConfig_Factory() { return new NgSelectConfig(); }, token: NgSelectConfig, providedIn: "root" });
|
|
2864
1891
|
NgSelectConfig.decorators = [
|
|
2865
1892
|
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
2866
1893
|
];
|
|
2867
|
-
/** @nocollapse */ NgSelectConfig.ɵprov = ɵɵdefineInjectable({ factory: function NgSelectConfig_Factory() { return new NgSelectConfig(); }, token: NgSelectConfig, providedIn: "root" });
|
|
2868
|
-
if (false) {
|
|
2869
|
-
/** @type {?} */
|
|
2870
|
-
NgSelectConfig.prototype.placeholder;
|
|
2871
|
-
/** @type {?} */
|
|
2872
|
-
NgSelectConfig.prototype.notFoundText;
|
|
2873
|
-
/** @type {?} */
|
|
2874
|
-
NgSelectConfig.prototype.typeToSearchText;
|
|
2875
|
-
/** @type {?} */
|
|
2876
|
-
NgSelectConfig.prototype.addTagText;
|
|
2877
|
-
/** @type {?} */
|
|
2878
|
-
NgSelectConfig.prototype.loadingText;
|
|
2879
|
-
/** @type {?} */
|
|
2880
|
-
NgSelectConfig.prototype.clearAllText;
|
|
2881
|
-
/** @type {?} */
|
|
2882
|
-
NgSelectConfig.prototype.disableVirtualScroll;
|
|
2883
|
-
/** @type {?} */
|
|
2884
|
-
NgSelectConfig.prototype.openOnEnter;
|
|
2885
|
-
/** @type {?} */
|
|
2886
|
-
NgSelectConfig.prototype.appendTo;
|
|
2887
|
-
/** @type {?} */
|
|
2888
|
-
NgSelectConfig.prototype.bindValue;
|
|
2889
|
-
/** @type {?} */
|
|
2890
|
-
NgSelectConfig.prototype.appearance;
|
|
2891
|
-
}
|
|
2892
1894
|
|
|
2893
|
-
/**
|
|
2894
|
-
* @fileoverview added by tsickle
|
|
2895
|
-
* Generated from: lib/ng-select.component.ts
|
|
2896
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2897
|
-
*/
|
|
2898
|
-
/** @type {?} */
|
|
2899
1895
|
const SELECTION_MODEL_FACTORY = new InjectionToken('ng-select-selection-model');
|
|
2900
1896
|
class NgSelectComponent {
|
|
2901
|
-
/**
|
|
2902
|
-
* @param {?} classes
|
|
2903
|
-
* @param {?} autoFocus
|
|
2904
|
-
* @param {?} config
|
|
2905
|
-
* @param {?} newSelectionModel
|
|
2906
|
-
* @param {?} _elementRef
|
|
2907
|
-
* @param {?} _cd
|
|
2908
|
-
* @param {?} _console
|
|
2909
|
-
*/
|
|
2910
1897
|
constructor(classes, autoFocus, config, newSelectionModel, _elementRef, _cd, _console) {
|
|
2911
1898
|
this.classes = classes;
|
|
2912
1899
|
this.autoFocus = autoFocus;
|
|
@@ -2930,11 +1917,7 @@ class NgSelectComponent {
|
|
|
2930
1917
|
this.searchWhileComposing = true;
|
|
2931
1918
|
this.minTermLength = 0;
|
|
2932
1919
|
this.editableSearchTerm = false;
|
|
2933
|
-
this.keyDownFn = (
|
|
2934
|
-
* @param {?} _
|
|
2935
|
-
* @return {?}
|
|
2936
|
-
*/
|
|
2937
|
-
(_) => true);
|
|
1920
|
+
this.keyDownFn = (_) => true;
|
|
2938
1921
|
this.multiple = false;
|
|
2939
1922
|
this.addTag = false;
|
|
2940
1923
|
this.searchable = true;
|
|
@@ -2963,143 +1946,68 @@ class NgSelectComponent {
|
|
|
2963
1946
|
this._isComposing = false;
|
|
2964
1947
|
this._destroy$ = new Subject();
|
|
2965
1948
|
this._keyPress$ = new Subject();
|
|
2966
|
-
this._onChange = (
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
(_) => { });
|
|
2971
|
-
this._onTouched = (/**
|
|
2972
|
-
* @return {?}
|
|
2973
|
-
*/
|
|
2974
|
-
() => { });
|
|
2975
|
-
this.clearItem = (/**
|
|
2976
|
-
* @param {?} item
|
|
2977
|
-
* @return {?}
|
|
2978
|
-
*/
|
|
2979
|
-
(item) => {
|
|
2980
|
-
/** @type {?} */
|
|
2981
|
-
const option = this.selectedItems.find((/**
|
|
2982
|
-
* @param {?} x
|
|
2983
|
-
* @return {?}
|
|
2984
|
-
*/
|
|
2985
|
-
x => x.value === item));
|
|
1949
|
+
this._onChange = (_) => { };
|
|
1950
|
+
this._onTouched = () => { };
|
|
1951
|
+
this.clearItem = (item) => {
|
|
1952
|
+
const option = this.selectedItems.find(x => x.value === item);
|
|
2986
1953
|
this.unselect(option);
|
|
2987
|
-
}
|
|
2988
|
-
this.trackByOption = (
|
|
2989
|
-
* @param {?} _
|
|
2990
|
-
* @param {?} item
|
|
2991
|
-
* @return {?}
|
|
2992
|
-
*/
|
|
2993
|
-
(_, item) => {
|
|
1954
|
+
};
|
|
1955
|
+
this.trackByOption = (_, item) => {
|
|
2994
1956
|
if (this.trackByFn) {
|
|
2995
1957
|
return this.trackByFn(item.value);
|
|
2996
1958
|
}
|
|
2997
1959
|
return item;
|
|
2998
|
-
}
|
|
1960
|
+
};
|
|
2999
1961
|
this._mergeGlobalConfig(config);
|
|
3000
1962
|
this.itemsList = new ItemsList(this, newSelectionModel());
|
|
3001
1963
|
this.element = _elementRef.nativeElement;
|
|
3002
1964
|
}
|
|
3003
|
-
/**
|
|
3004
|
-
* @return {?}
|
|
3005
|
-
*/
|
|
3006
1965
|
get items() { return this._items; }
|
|
3007
1966
|
;
|
|
3008
|
-
/**
|
|
3009
|
-
* @param {?} value
|
|
3010
|
-
* @return {?}
|
|
3011
|
-
*/
|
|
3012
1967
|
set items(value) {
|
|
3013
1968
|
this._itemsAreUsed = true;
|
|
3014
1969
|
this._items = value;
|
|
3015
1970
|
}
|
|
3016
1971
|
;
|
|
3017
|
-
/**
|
|
3018
|
-
* @return {?}
|
|
3019
|
-
*/
|
|
3020
1972
|
get compareWith() { return this._compareWith; }
|
|
3021
|
-
/**
|
|
3022
|
-
* @param {?} fn
|
|
3023
|
-
* @return {?}
|
|
3024
|
-
*/
|
|
3025
1973
|
set compareWith(fn) {
|
|
3026
|
-
if (!isFunction(fn)) {
|
|
1974
|
+
if (fn !== undefined && fn !== null && !isFunction(fn)) {
|
|
3027
1975
|
throw Error('`compareWith` must be a function.');
|
|
3028
1976
|
}
|
|
3029
1977
|
this._compareWith = fn;
|
|
3030
1978
|
}
|
|
3031
|
-
/**
|
|
3032
|
-
* @return {?}
|
|
3033
|
-
*/
|
|
3034
1979
|
get clearSearchOnAdd() { return isDefined(this._clearSearchOnAdd) ? this._clearSearchOnAdd : this.closeOnSelect; }
|
|
3035
1980
|
;
|
|
3036
|
-
/**
|
|
3037
|
-
* @param {?} value
|
|
3038
|
-
* @return {?}
|
|
3039
|
-
*/
|
|
3040
1981
|
set clearSearchOnAdd(value) {
|
|
3041
1982
|
this._clearSearchOnAdd = value;
|
|
3042
1983
|
}
|
|
3043
1984
|
;
|
|
3044
|
-
/**
|
|
3045
|
-
* @return {?}
|
|
3046
|
-
*/
|
|
3047
1985
|
get disabled() { return this.readonly || this._disabled; }
|
|
3048
1986
|
;
|
|
3049
|
-
/**
|
|
3050
|
-
* @return {?}
|
|
3051
|
-
*/
|
|
3052
1987
|
get filtered() { return (!!this.searchTerm && this.searchable || this._isComposing); }
|
|
3053
1988
|
;
|
|
3054
|
-
/**
|
|
3055
|
-
* @private
|
|
3056
|
-
* @return {?}
|
|
3057
|
-
*/
|
|
3058
1989
|
get _editableSearchTerm() {
|
|
3059
1990
|
return this.editableSearchTerm && !this.multiple;
|
|
3060
1991
|
}
|
|
3061
|
-
/**
|
|
3062
|
-
* @return {?}
|
|
3063
|
-
*/
|
|
3064
1992
|
get selectedItems() {
|
|
3065
1993
|
return this.itemsList.selectedItems;
|
|
3066
1994
|
}
|
|
3067
|
-
/**
|
|
3068
|
-
* @return {?}
|
|
3069
|
-
*/
|
|
3070
1995
|
get selectedValues() {
|
|
3071
|
-
return this.selectedItems.map(
|
|
3072
|
-
|
|
3073
|
-
* @return {?}
|
|
3074
|
-
*/
|
|
3075
|
-
x => x.value));
|
|
3076
|
-
}
|
|
3077
|
-
/**
|
|
3078
|
-
* @return {?}
|
|
3079
|
-
*/
|
|
1996
|
+
return this.selectedItems.map(x => x.value);
|
|
1997
|
+
}
|
|
3080
1998
|
get hasValue() {
|
|
3081
1999
|
return this.selectedItems.length > 0;
|
|
3082
2000
|
}
|
|
3083
|
-
/**
|
|
3084
|
-
* @return {?}
|
|
3085
|
-
*/
|
|
3086
2001
|
get currentPanelPosition() {
|
|
3087
2002
|
if (this.dropdownPanel) {
|
|
3088
2003
|
return this.dropdownPanel.currentPosition;
|
|
3089
2004
|
}
|
|
3090
2005
|
return undefined;
|
|
3091
2006
|
}
|
|
3092
|
-
/**
|
|
3093
|
-
* @return {?}
|
|
3094
|
-
*/
|
|
3095
2007
|
ngOnInit() {
|
|
3096
2008
|
this._handleKeyPresses();
|
|
3097
2009
|
this._setInputAttributes();
|
|
3098
2010
|
}
|
|
3099
|
-
/**
|
|
3100
|
-
* @param {?} changes
|
|
3101
|
-
* @return {?}
|
|
3102
|
-
*/
|
|
3103
2011
|
ngOnChanges(changes) {
|
|
3104
2012
|
if (changes.multiple) {
|
|
3105
2013
|
this.itemsList.clearSelected();
|
|
@@ -3111,9 +2019,6 @@ class NgSelectComponent {
|
|
|
3111
2019
|
this._manualOpen = isDefined(changes.isOpen.currentValue);
|
|
3112
2020
|
}
|
|
3113
2021
|
}
|
|
3114
|
-
/**
|
|
3115
|
-
* @return {?}
|
|
3116
|
-
*/
|
|
3117
2022
|
ngAfterViewInit() {
|
|
3118
2023
|
if (!this._itemsAreUsed) {
|
|
3119
2024
|
this.escapeHTML = false;
|
|
@@ -3123,19 +2028,11 @@ class NgSelectComponent {
|
|
|
3123
2028
|
this.focus();
|
|
3124
2029
|
}
|
|
3125
2030
|
}
|
|
3126
|
-
/**
|
|
3127
|
-
* @return {?}
|
|
3128
|
-
*/
|
|
3129
2031
|
ngOnDestroy() {
|
|
3130
2032
|
this._destroy$.next();
|
|
3131
2033
|
this._destroy$.complete();
|
|
3132
2034
|
}
|
|
3133
|
-
/**
|
|
3134
|
-
* @param {?} $event
|
|
3135
|
-
* @return {?}
|
|
3136
|
-
*/
|
|
3137
2035
|
handleKeyDown($event) {
|
|
3138
|
-
/** @type {?} */
|
|
3139
2036
|
const keyCode = KeyCode[$event.which];
|
|
3140
2037
|
if (keyCode) {
|
|
3141
2038
|
if (this.keyDownFn($event) === false) {
|
|
@@ -3147,10 +2044,6 @@ class NgSelectComponent {
|
|
|
3147
2044
|
this._keyPress$.next($event.key.toLocaleLowerCase());
|
|
3148
2045
|
}
|
|
3149
2046
|
}
|
|
3150
|
-
/**
|
|
3151
|
-
* @param {?} $event
|
|
3152
|
-
* @return {?}
|
|
3153
|
-
*/
|
|
3154
2047
|
handleKeyCode($event) {
|
|
3155
2048
|
switch ($event.which) {
|
|
3156
2049
|
case KeyCode.ArrowDown:
|
|
@@ -3177,13 +2070,8 @@ class NgSelectComponent {
|
|
|
3177
2070
|
break;
|
|
3178
2071
|
}
|
|
3179
2072
|
}
|
|
3180
|
-
/**
|
|
3181
|
-
* @param {?} $event
|
|
3182
|
-
* @return {?}
|
|
3183
|
-
*/
|
|
3184
2073
|
handleMousedown($event) {
|
|
3185
|
-
|
|
3186
|
-
const target = (/** @type {?} */ ($event.target));
|
|
2074
|
+
const target = $event.target;
|
|
3187
2075
|
if (target.tagName !== 'INPUT') {
|
|
3188
2076
|
$event.preventDefault();
|
|
3189
2077
|
}
|
|
@@ -3208,9 +2096,6 @@ class NgSelectComponent {
|
|
|
3208
2096
|
this.toggle();
|
|
3209
2097
|
}
|
|
3210
2098
|
}
|
|
3211
|
-
/**
|
|
3212
|
-
* @return {?}
|
|
3213
|
-
*/
|
|
3214
2099
|
handleArrowClick() {
|
|
3215
2100
|
if (this.isOpen) {
|
|
3216
2101
|
this.close();
|
|
@@ -3219,9 +2104,6 @@ class NgSelectComponent {
|
|
|
3219
2104
|
this.open();
|
|
3220
2105
|
}
|
|
3221
2106
|
}
|
|
3222
|
-
/**
|
|
3223
|
-
* @return {?}
|
|
3224
|
-
*/
|
|
3225
2107
|
handleClearClick() {
|
|
3226
2108
|
if (this.hasValue) {
|
|
3227
2109
|
this.itemsList.clearSelected(true);
|
|
@@ -3232,9 +2114,6 @@ class NgSelectComponent {
|
|
|
3232
2114
|
this.clearEvent.emit();
|
|
3233
2115
|
this._onSelectionChanged();
|
|
3234
2116
|
}
|
|
3235
|
-
/**
|
|
3236
|
-
* @return {?}
|
|
3237
|
-
*/
|
|
3238
2117
|
clearModel() {
|
|
3239
2118
|
if (!this.clearable) {
|
|
3240
2119
|
return;
|
|
@@ -3242,40 +2121,21 @@ class NgSelectComponent {
|
|
|
3242
2121
|
this.itemsList.clearSelected();
|
|
3243
2122
|
this._updateNgModel();
|
|
3244
2123
|
}
|
|
3245
|
-
/**
|
|
3246
|
-
* @param {?} value
|
|
3247
|
-
* @return {?}
|
|
3248
|
-
*/
|
|
3249
2124
|
writeValue(value) {
|
|
3250
2125
|
this.itemsList.clearSelected();
|
|
3251
2126
|
this._handleWriteValue(value);
|
|
3252
2127
|
this._cd.markForCheck();
|
|
3253
2128
|
}
|
|
3254
|
-
/**
|
|
3255
|
-
* @param {?} fn
|
|
3256
|
-
* @return {?}
|
|
3257
|
-
*/
|
|
3258
2129
|
registerOnChange(fn) {
|
|
3259
2130
|
this._onChange = fn;
|
|
3260
2131
|
}
|
|
3261
|
-
/**
|
|
3262
|
-
* @param {?} fn
|
|
3263
|
-
* @return {?}
|
|
3264
|
-
*/
|
|
3265
2132
|
registerOnTouched(fn) {
|
|
3266
2133
|
this._onTouched = fn;
|
|
3267
2134
|
}
|
|
3268
|
-
/**
|
|
3269
|
-
* @param {?} state
|
|
3270
|
-
* @return {?}
|
|
3271
|
-
*/
|
|
3272
2135
|
setDisabledState(state) {
|
|
3273
2136
|
this._disabled = state;
|
|
3274
2137
|
this._cd.markForCheck();
|
|
3275
2138
|
}
|
|
3276
|
-
/**
|
|
3277
|
-
* @return {?}
|
|
3278
|
-
*/
|
|
3279
2139
|
toggle() {
|
|
3280
2140
|
if (!this.isOpen) {
|
|
3281
2141
|
this.open();
|
|
@@ -3284,9 +2144,6 @@ class NgSelectComponent {
|
|
|
3284
2144
|
this.close();
|
|
3285
2145
|
}
|
|
3286
2146
|
}
|
|
3287
|
-
/**
|
|
3288
|
-
* @return {?}
|
|
3289
|
-
*/
|
|
3290
2147
|
open() {
|
|
3291
2148
|
if (this.disabled || this.isOpen || this.itemsList.maxItemsSelected || this._manualOpen) {
|
|
3292
2149
|
return;
|
|
@@ -3302,9 +2159,6 @@ class NgSelectComponent {
|
|
|
3302
2159
|
}
|
|
3303
2160
|
this.detectChanges();
|
|
3304
2161
|
}
|
|
3305
|
-
/**
|
|
3306
|
-
* @return {?}
|
|
3307
|
-
*/
|
|
3308
2162
|
close() {
|
|
3309
2163
|
if (!this.isOpen || this._manualOpen) {
|
|
3310
2164
|
return;
|
|
@@ -3322,10 +2176,6 @@ class NgSelectComponent {
|
|
|
3322
2176
|
this.closeEvent.emit();
|
|
3323
2177
|
this._cd.markForCheck();
|
|
3324
2178
|
}
|
|
3325
|
-
/**
|
|
3326
|
-
* @param {?} item
|
|
3327
|
-
* @return {?}
|
|
3328
|
-
*/
|
|
3329
2179
|
toggleItem(item) {
|
|
3330
2180
|
if (!item || item.disabled || this.disabled) {
|
|
3331
2181
|
return;
|
|
@@ -3341,10 +2191,6 @@ class NgSelectComponent {
|
|
|
3341
2191
|
}
|
|
3342
2192
|
this._onSelectionChanged();
|
|
3343
2193
|
}
|
|
3344
|
-
/**
|
|
3345
|
-
* @param {?} item
|
|
3346
|
-
* @return {?}
|
|
3347
|
-
*/
|
|
3348
2194
|
select(item) {
|
|
3349
2195
|
if (!item.selected) {
|
|
3350
2196
|
this.itemsList.select(item);
|
|
@@ -3360,22 +2206,12 @@ class NgSelectComponent {
|
|
|
3360
2206
|
this.close();
|
|
3361
2207
|
}
|
|
3362
2208
|
}
|
|
3363
|
-
/**
|
|
3364
|
-
* @return {?}
|
|
3365
|
-
*/
|
|
3366
2209
|
focus() {
|
|
3367
2210
|
this.searchInput.nativeElement.focus();
|
|
3368
2211
|
}
|
|
3369
|
-
/**
|
|
3370
|
-
* @return {?}
|
|
3371
|
-
*/
|
|
3372
2212
|
blur() {
|
|
3373
2213
|
this.searchInput.nativeElement.blur();
|
|
3374
2214
|
}
|
|
3375
|
-
/**
|
|
3376
|
-
* @param {?} item
|
|
3377
|
-
* @return {?}
|
|
3378
|
-
*/
|
|
3379
2215
|
unselect(item) {
|
|
3380
2216
|
if (!item) {
|
|
3381
2217
|
return;
|
|
@@ -3385,94 +2221,48 @@ class NgSelectComponent {
|
|
|
3385
2221
|
this._updateNgModel();
|
|
3386
2222
|
this.removeEvent.emit(item);
|
|
3387
2223
|
}
|
|
3388
|
-
/**
|
|
3389
|
-
* @return {?}
|
|
3390
|
-
*/
|
|
3391
2224
|
selectTag() {
|
|
3392
|
-
/** @type {?} */
|
|
3393
2225
|
let tag;
|
|
3394
2226
|
if (isFunction(this.addTag)) {
|
|
3395
|
-
tag =
|
|
2227
|
+
tag = this.addTag(this.searchTerm);
|
|
3396
2228
|
}
|
|
3397
2229
|
else {
|
|
3398
2230
|
tag = this._primitive ? this.searchTerm : { [this.bindLabel]: this.searchTerm };
|
|
3399
2231
|
}
|
|
3400
|
-
|
|
3401
|
-
const handleTag = (/**
|
|
3402
|
-
* @param {?} item
|
|
3403
|
-
* @return {?}
|
|
3404
|
-
*/
|
|
3405
|
-
(item) => this._isTypeahead || !this.isOpen ? this.itemsList.mapItem(item, null) : this.itemsList.addItem(item));
|
|
2232
|
+
const handleTag = (item) => this._isTypeahead || !this.isOpen ? this.itemsList.mapItem(item, null) : this.itemsList.addItem(item);
|
|
3406
2233
|
if (isPromise(tag)) {
|
|
3407
|
-
tag.then((
|
|
3408
|
-
* @param {?} item
|
|
3409
|
-
* @return {?}
|
|
3410
|
-
*/
|
|
3411
|
-
item => this.select(handleTag(item)))).catch((/**
|
|
3412
|
-
* @return {?}
|
|
3413
|
-
*/
|
|
3414
|
-
() => { }));
|
|
2234
|
+
tag.then(item => this.select(handleTag(item))).catch(() => { });
|
|
3415
2235
|
}
|
|
3416
2236
|
else if (tag) {
|
|
3417
2237
|
this.select(handleTag(tag));
|
|
3418
2238
|
}
|
|
3419
2239
|
}
|
|
3420
|
-
/**
|
|
3421
|
-
* @return {?}
|
|
3422
|
-
*/
|
|
3423
2240
|
showClear() {
|
|
3424
2241
|
return this.clearable && (this.hasValue || this.searchTerm) && !this.disabled;
|
|
3425
2242
|
}
|
|
3426
|
-
/**
|
|
3427
|
-
* @return {?}
|
|
3428
|
-
*/
|
|
3429
2243
|
get showAddTag() {
|
|
3430
2244
|
if (!this._validTerm) {
|
|
3431
2245
|
return false;
|
|
3432
2246
|
}
|
|
3433
|
-
/** @type {?} */
|
|
3434
2247
|
const term = this.searchTerm.toLowerCase().trim();
|
|
3435
2248
|
return this.addTag &&
|
|
3436
|
-
(!this.itemsList.filteredItems.some((
|
|
3437
|
-
|
|
3438
|
-
* @return {?}
|
|
3439
|
-
*/
|
|
3440
|
-
x => x.label.toLowerCase() === term)) &&
|
|
3441
|
-
(!this.hideSelected && this.isOpen || !this.selectedItems.some((/**
|
|
3442
|
-
* @param {?} x
|
|
3443
|
-
* @return {?}
|
|
3444
|
-
*/
|
|
3445
|
-
x => x.label.toLowerCase() === term)))) &&
|
|
2249
|
+
(!this.itemsList.filteredItems.some(x => x.label.toLowerCase() === term) &&
|
|
2250
|
+
(!this.hideSelected && this.isOpen || !this.selectedItems.some(x => x.label.toLowerCase() === term))) &&
|
|
3446
2251
|
!this.loading;
|
|
3447
2252
|
}
|
|
3448
|
-
/**
|
|
3449
|
-
* @return {?}
|
|
3450
|
-
*/
|
|
3451
2253
|
showNoItemsFound() {
|
|
3452
|
-
/** @type {?} */
|
|
3453
2254
|
const empty = this.itemsList.filteredItems.length === 0;
|
|
3454
2255
|
return ((empty && !this._isTypeahead && !this.loading) ||
|
|
3455
2256
|
(empty && this._isTypeahead && this._validTerm && !this.loading)) &&
|
|
3456
2257
|
!this.showAddTag;
|
|
3457
2258
|
}
|
|
3458
|
-
/**
|
|
3459
|
-
* @return {?}
|
|
3460
|
-
*/
|
|
3461
2259
|
showTypeToSearch() {
|
|
3462
|
-
/** @type {?} */
|
|
3463
2260
|
const empty = this.itemsList.filteredItems.length === 0;
|
|
3464
2261
|
return empty && this._isTypeahead && !this._validTerm && !this.loading;
|
|
3465
2262
|
}
|
|
3466
|
-
/**
|
|
3467
|
-
* @return {?}
|
|
3468
|
-
*/
|
|
3469
2263
|
onCompositionStart() {
|
|
3470
2264
|
this._isComposing = true;
|
|
3471
2265
|
}
|
|
3472
|
-
/**
|
|
3473
|
-
* @param {?} term
|
|
3474
|
-
* @return {?}
|
|
3475
|
-
*/
|
|
3476
2266
|
onCompositionEnd(term) {
|
|
3477
2267
|
this._isComposing = false;
|
|
3478
2268
|
if (this.searchWhileComposing) {
|
|
@@ -3480,10 +2270,6 @@ class NgSelectComponent {
|
|
|
3480
2270
|
}
|
|
3481
2271
|
this.filter(term);
|
|
3482
2272
|
}
|
|
3483
|
-
/**
|
|
3484
|
-
* @param {?} term
|
|
3485
|
-
* @return {?}
|
|
3486
|
-
*/
|
|
3487
2273
|
filter(term) {
|
|
3488
2274
|
if (this._isComposing && !this.searchWhileComposing) {
|
|
3489
2275
|
return;
|
|
@@ -3498,17 +2284,9 @@ class NgSelectComponent {
|
|
|
3498
2284
|
this.itemsList.markSelectedOrDefault(this.markFirst);
|
|
3499
2285
|
}
|
|
3500
2286
|
}
|
|
3501
|
-
this.searchEvent.emit({ term, items: this.itemsList.filteredItems.map(
|
|
3502
|
-
* @param {?} x
|
|
3503
|
-
* @return {?}
|
|
3504
|
-
*/
|
|
3505
|
-
x => x.value)) });
|
|
2287
|
+
this.searchEvent.emit({ term, items: this.itemsList.filteredItems.map(x => x.value) });
|
|
3506
2288
|
this.open();
|
|
3507
2289
|
}
|
|
3508
|
-
/**
|
|
3509
|
-
* @param {?} $event
|
|
3510
|
-
* @return {?}
|
|
3511
|
-
*/
|
|
3512
2290
|
onInputFocus($event) {
|
|
3513
2291
|
if (this.focused) {
|
|
3514
2292
|
return;
|
|
@@ -3520,10 +2298,6 @@ class NgSelectComponent {
|
|
|
3520
2298
|
this.focusEvent.emit($event);
|
|
3521
2299
|
this.focused = true;
|
|
3522
2300
|
}
|
|
3523
|
-
/**
|
|
3524
|
-
* @param {?} $event
|
|
3525
|
-
* @return {?}
|
|
3526
|
-
*/
|
|
3527
2301
|
onInputBlur($event) {
|
|
3528
2302
|
this.element.classList.remove('ng-select-focused');
|
|
3529
2303
|
this.blurEvent.emit($event);
|
|
@@ -3535,40 +2309,22 @@ class NgSelectComponent {
|
|
|
3535
2309
|
}
|
|
3536
2310
|
this.focused = false;
|
|
3537
2311
|
}
|
|
3538
|
-
/**
|
|
3539
|
-
* @param {?} item
|
|
3540
|
-
* @return {?}
|
|
3541
|
-
*/
|
|
3542
2312
|
onItemHover(item) {
|
|
3543
2313
|
if (item.disabled) {
|
|
3544
2314
|
return;
|
|
3545
2315
|
}
|
|
3546
2316
|
this.itemsList.markItem(item);
|
|
3547
2317
|
}
|
|
3548
|
-
/**
|
|
3549
|
-
* @return {?}
|
|
3550
|
-
*/
|
|
3551
2318
|
detectChanges() {
|
|
3552
|
-
if (!
|
|
2319
|
+
if (!this._cd.destroyed) {
|
|
3553
2320
|
this._cd.detectChanges();
|
|
3554
2321
|
}
|
|
3555
2322
|
}
|
|
3556
|
-
/**
|
|
3557
|
-
* @private
|
|
3558
|
-
* @return {?}
|
|
3559
|
-
*/
|
|
3560
2323
|
_setSearchTermFromItems() {
|
|
3561
|
-
/** @type {?} */
|
|
3562
2324
|
const selected = this.selectedItems && this.selectedItems[0];
|
|
3563
2325
|
this.searchTerm = (selected && selected.label) || null;
|
|
3564
2326
|
}
|
|
3565
|
-
/**
|
|
3566
|
-
* @private
|
|
3567
|
-
* @param {?} items
|
|
3568
|
-
* @return {?}
|
|
3569
|
-
*/
|
|
3570
2327
|
_setItems(items) {
|
|
3571
|
-
/** @type {?} */
|
|
3572
2328
|
const firstItem = items[0];
|
|
3573
2329
|
this.bindLabel = this.bindLabel || this._defaultLabel;
|
|
3574
2330
|
this._primitive = isDefined(firstItem) ? !isObject(firstItem) : this._primitive || this.bindLabel === this._defaultLabel;
|
|
@@ -3583,129 +2339,71 @@ class NgSelectComponent {
|
|
|
3583
2339
|
this.itemsList.markSelectedOrDefault(this.markFirst);
|
|
3584
2340
|
}
|
|
3585
2341
|
}
|
|
3586
|
-
/**
|
|
3587
|
-
* @private
|
|
3588
|
-
* @return {?}
|
|
3589
|
-
*/
|
|
3590
2342
|
_setItemsFromNgOptions() {
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
* @param {?} options
|
|
3594
|
-
* @return {?}
|
|
3595
|
-
*/
|
|
3596
|
-
(options) => {
|
|
3597
|
-
this.items = options.map((/**
|
|
3598
|
-
* @param {?} option
|
|
3599
|
-
* @return {?}
|
|
3600
|
-
*/
|
|
3601
|
-
option => ({
|
|
2343
|
+
const mapNgOptions = (options) => {
|
|
2344
|
+
this.items = options.map(option => ({
|
|
3602
2345
|
$ngOptionValue: option.value,
|
|
3603
2346
|
$ngOptionLabel: option.elementRef.nativeElement.innerHTML,
|
|
3604
2347
|
disabled: option.disabled
|
|
3605
|
-
}))
|
|
2348
|
+
}));
|
|
3606
2349
|
this.itemsList.setItems(this.items);
|
|
3607
2350
|
if (this.hasValue) {
|
|
3608
2351
|
this.itemsList.mapSelectedItems();
|
|
3609
2352
|
}
|
|
3610
2353
|
this.detectChanges();
|
|
3611
|
-
}
|
|
3612
|
-
|
|
3613
|
-
const handleOptionChange = (/**
|
|
3614
|
-
* @return {?}
|
|
3615
|
-
*/
|
|
3616
|
-
() => {
|
|
3617
|
-
/** @type {?} */
|
|
2354
|
+
};
|
|
2355
|
+
const handleOptionChange = () => {
|
|
3618
2356
|
const changedOrDestroyed = merge(this.ngOptions.changes, this._destroy$);
|
|
3619
|
-
merge(...this.ngOptions.map(
|
|
3620
|
-
* @param {?} option
|
|
3621
|
-
* @return {?}
|
|
3622
|
-
*/
|
|
3623
|
-
option => option.stateChange$)))
|
|
2357
|
+
merge(...this.ngOptions.map(option => option.stateChange$))
|
|
3624
2358
|
.pipe(takeUntil(changedOrDestroyed))
|
|
3625
|
-
.subscribe(
|
|
3626
|
-
* @param {?} option
|
|
3627
|
-
* @return {?}
|
|
3628
|
-
*/
|
|
3629
|
-
option => {
|
|
3630
|
-
/** @type {?} */
|
|
2359
|
+
.subscribe(option => {
|
|
3631
2360
|
const item = this.itemsList.findItem(option.value);
|
|
3632
2361
|
item.disabled = option.disabled;
|
|
3633
2362
|
item.label = option.label || item.label;
|
|
3634
2363
|
this._cd.detectChanges();
|
|
3635
|
-
})
|
|
3636
|
-
}
|
|
2364
|
+
});
|
|
2365
|
+
};
|
|
3637
2366
|
this.ngOptions.changes
|
|
3638
2367
|
.pipe(startWith(this.ngOptions), takeUntil(this._destroy$))
|
|
3639
|
-
.subscribe(
|
|
3640
|
-
* @param {?} options
|
|
3641
|
-
* @return {?}
|
|
3642
|
-
*/
|
|
3643
|
-
options => {
|
|
2368
|
+
.subscribe(options => {
|
|
3644
2369
|
this.bindLabel = this._defaultLabel;
|
|
3645
2370
|
mapNgOptions(options);
|
|
3646
2371
|
handleOptionChange();
|
|
3647
|
-
})
|
|
2372
|
+
});
|
|
3648
2373
|
}
|
|
3649
|
-
/**
|
|
3650
|
-
* @private
|
|
3651
|
-
* @param {?} value
|
|
3652
|
-
* @return {?}
|
|
3653
|
-
*/
|
|
3654
2374
|
_isValidWriteValue(value) {
|
|
3655
2375
|
if (!isDefined(value) || (this.multiple && value === '') || Array.isArray(value) && value.length === 0) {
|
|
3656
2376
|
return false;
|
|
3657
2377
|
}
|
|
3658
|
-
|
|
3659
|
-
const validateBinding = (/**
|
|
3660
|
-
* @param {?} item
|
|
3661
|
-
* @return {?}
|
|
3662
|
-
*/
|
|
3663
|
-
(item) => {
|
|
2378
|
+
const validateBinding = (item) => {
|
|
3664
2379
|
if (!isDefined(this.compareWith) && isObject(item) && this.bindValue) {
|
|
3665
2380
|
this._console.warn(`Setting object(${JSON.stringify(item)}) as your model with bindValue is not allowed unless [compareWith] is used.`);
|
|
3666
2381
|
return false;
|
|
3667
2382
|
}
|
|
3668
2383
|
return true;
|
|
3669
|
-
}
|
|
2384
|
+
};
|
|
3670
2385
|
if (this.multiple) {
|
|
3671
2386
|
if (!Array.isArray(value)) {
|
|
3672
2387
|
this._console.warn('Multiple select ngModel should be array.');
|
|
3673
2388
|
return false;
|
|
3674
2389
|
}
|
|
3675
|
-
return value.every((
|
|
3676
|
-
* @param {?} item
|
|
3677
|
-
* @return {?}
|
|
3678
|
-
*/
|
|
3679
|
-
item => validateBinding(item)));
|
|
2390
|
+
return value.every(item => validateBinding(item));
|
|
3680
2391
|
}
|
|
3681
2392
|
else {
|
|
3682
2393
|
return validateBinding(value);
|
|
3683
2394
|
}
|
|
3684
2395
|
}
|
|
3685
|
-
/**
|
|
3686
|
-
* @private
|
|
3687
|
-
* @param {?} ngModel
|
|
3688
|
-
* @return {?}
|
|
3689
|
-
*/
|
|
3690
2396
|
_handleWriteValue(ngModel) {
|
|
3691
2397
|
if (!this._isValidWriteValue(ngModel)) {
|
|
3692
2398
|
return;
|
|
3693
2399
|
}
|
|
3694
|
-
|
|
3695
|
-
const select = (/**
|
|
3696
|
-
* @param {?} val
|
|
3697
|
-
* @return {?}
|
|
3698
|
-
*/
|
|
3699
|
-
(val) => {
|
|
3700
|
-
/** @type {?} */
|
|
2400
|
+
const select = (val) => {
|
|
3701
2401
|
let item = this.itemsList.findItem(val);
|
|
3702
2402
|
if (item) {
|
|
3703
2403
|
this.itemsList.select(item);
|
|
3704
2404
|
}
|
|
3705
2405
|
else {
|
|
3706
|
-
/** @type {?} */
|
|
3707
2406
|
const isValObject = isObject(val);
|
|
3708
|
-
/** @type {?} */
|
|
3709
2407
|
const isPrimitive = !isValObject && !this.bindValue;
|
|
3710
2408
|
if ((isValObject || isPrimitive)) {
|
|
3711
2409
|
this.itemsList.select(this.itemsList.mapItem(val, null));
|
|
@@ -3718,44 +2416,21 @@ class NgSelectComponent {
|
|
|
3718
2416
|
this.itemsList.select(this.itemsList.mapItem(item, null));
|
|
3719
2417
|
}
|
|
3720
2418
|
}
|
|
3721
|
-
}
|
|
2419
|
+
};
|
|
3722
2420
|
if (this.multiple) {
|
|
3723
|
-
(
|
|
3724
|
-
* @param {?} item
|
|
3725
|
-
* @return {?}
|
|
3726
|
-
*/
|
|
3727
|
-
item => select(item)));
|
|
2421
|
+
ngModel.forEach(item => select(item));
|
|
3728
2422
|
}
|
|
3729
2423
|
else {
|
|
3730
2424
|
select(ngModel);
|
|
3731
2425
|
}
|
|
3732
2426
|
}
|
|
3733
|
-
/**
|
|
3734
|
-
* @private
|
|
3735
|
-
* @return {?}
|
|
3736
|
-
*/
|
|
3737
2427
|
_handleKeyPresses() {
|
|
3738
2428
|
if (this.searchable) {
|
|
3739
2429
|
return;
|
|
3740
2430
|
}
|
|
3741
2431
|
this._keyPress$
|
|
3742
|
-
.pipe(takeUntil(this._destroy$), tap((
|
|
3743
|
-
|
|
3744
|
-
* @return {?}
|
|
3745
|
-
*/
|
|
3746
|
-
letter => this._pressedKeys.push(letter))), debounceTime(200), filter((/**
|
|
3747
|
-
* @return {?}
|
|
3748
|
-
*/
|
|
3749
|
-
() => this._pressedKeys.length > 0)), map((/**
|
|
3750
|
-
* @return {?}
|
|
3751
|
-
*/
|
|
3752
|
-
() => this._pressedKeys.join(''))))
|
|
3753
|
-
.subscribe((/**
|
|
3754
|
-
* @param {?} term
|
|
3755
|
-
* @return {?}
|
|
3756
|
-
*/
|
|
3757
|
-
term => {
|
|
3758
|
-
/** @type {?} */
|
|
2432
|
+
.pipe(takeUntil(this._destroy$), tap(letter => this._pressedKeys.push(letter)), debounceTime(200), filter(() => this._pressedKeys.length > 0), map(() => this._pressedKeys.join('')))
|
|
2433
|
+
.subscribe(term => {
|
|
3759
2434
|
const item = this.itemsList.findByLabel(term);
|
|
3760
2435
|
if (item) {
|
|
3761
2436
|
if (this.isOpen) {
|
|
@@ -3768,36 +2443,23 @@ class NgSelectComponent {
|
|
|
3768
2443
|
}
|
|
3769
2444
|
}
|
|
3770
2445
|
this._pressedKeys = [];
|
|
3771
|
-
})
|
|
2446
|
+
});
|
|
3772
2447
|
}
|
|
3773
|
-
/**
|
|
3774
|
-
* @private
|
|
3775
|
-
* @return {?}
|
|
3776
|
-
*/
|
|
3777
2448
|
_setInputAttributes() {
|
|
3778
|
-
/** @type {?} */
|
|
3779
2449
|
const input = this.searchInput.nativeElement;
|
|
3780
|
-
/** @type {?} */
|
|
3781
2450
|
const attributes = Object.assign({ type: 'text', autocorrect: 'off', autocapitalize: 'off', autocomplete: this.labelForId ? 'off' : this.dropdownId }, this.inputAttrs);
|
|
3782
2451
|
for (const key of Object.keys(attributes)) {
|
|
3783
2452
|
input.setAttribute(key, attributes[key]);
|
|
3784
2453
|
}
|
|
3785
2454
|
}
|
|
3786
|
-
/**
|
|
3787
|
-
* @private
|
|
3788
|
-
* @return {?}
|
|
3789
|
-
*/
|
|
3790
2455
|
_updateNgModel() {
|
|
3791
|
-
/** @type {?} */
|
|
3792
2456
|
const model = [];
|
|
3793
2457
|
for (const item of this.selectedItems) {
|
|
3794
2458
|
if (this.bindValue) {
|
|
3795
|
-
/** @type {?} */
|
|
3796
2459
|
let value = null;
|
|
3797
2460
|
if (item.children) {
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
value = item.value[groupKey || (/** @type {?} */ (this.groupBy))];
|
|
2461
|
+
const groupKey = this.groupValue ? this.bindValue : this.groupBy;
|
|
2462
|
+
value = item.value[groupKey || this.groupBy];
|
|
3801
2463
|
}
|
|
3802
2464
|
else {
|
|
3803
2465
|
value = this.itemsList.resolveNested(item.value, this.bindValue);
|
|
@@ -3808,12 +2470,7 @@ class NgSelectComponent {
|
|
|
3808
2470
|
model.push(item.value);
|
|
3809
2471
|
}
|
|
3810
2472
|
}
|
|
3811
|
-
|
|
3812
|
-
const selected = this.selectedItems.map((/**
|
|
3813
|
-
* @param {?} x
|
|
3814
|
-
* @return {?}
|
|
3815
|
-
*/
|
|
3816
|
-
x => x.value));
|
|
2473
|
+
const selected = this.selectedItems.map(x => x.value);
|
|
3817
2474
|
if (this.multiple) {
|
|
3818
2475
|
this._onChange(model);
|
|
3819
2476
|
this.changeEvent.emit(selected);
|
|
@@ -3824,10 +2481,6 @@ class NgSelectComponent {
|
|
|
3824
2481
|
}
|
|
3825
2482
|
this._cd.markForCheck();
|
|
3826
2483
|
}
|
|
3827
|
-
/**
|
|
3828
|
-
* @private
|
|
3829
|
-
* @return {?}
|
|
3830
|
-
*/
|
|
3831
2484
|
_clearSearch() {
|
|
3832
2485
|
if (!this.searchTerm) {
|
|
3833
2486
|
return;
|
|
@@ -3835,41 +2488,24 @@ class NgSelectComponent {
|
|
|
3835
2488
|
this._changeSearch(null);
|
|
3836
2489
|
this.itemsList.resetFilteredItems();
|
|
3837
2490
|
}
|
|
3838
|
-
/**
|
|
3839
|
-
* @private
|
|
3840
|
-
* @param {?} searchTerm
|
|
3841
|
-
* @return {?}
|
|
3842
|
-
*/
|
|
3843
2491
|
_changeSearch(searchTerm) {
|
|
3844
2492
|
this.searchTerm = searchTerm;
|
|
3845
2493
|
if (this._isTypeahead) {
|
|
3846
2494
|
this.typeahead.next(searchTerm);
|
|
3847
2495
|
}
|
|
3848
2496
|
}
|
|
3849
|
-
/**
|
|
3850
|
-
* @private
|
|
3851
|
-
* @return {?}
|
|
3852
|
-
*/
|
|
3853
2497
|
_scrollToMarked() {
|
|
3854
2498
|
if (!this.isOpen || !this.dropdownPanel) {
|
|
3855
2499
|
return;
|
|
3856
2500
|
}
|
|
3857
2501
|
this.dropdownPanel.scrollTo(this.itemsList.markedItem);
|
|
3858
2502
|
}
|
|
3859
|
-
/**
|
|
3860
|
-
* @private
|
|
3861
|
-
* @return {?}
|
|
3862
|
-
*/
|
|
3863
2503
|
_scrollToTag() {
|
|
3864
2504
|
if (!this.isOpen || !this.dropdownPanel) {
|
|
3865
2505
|
return;
|
|
3866
2506
|
}
|
|
3867
2507
|
this.dropdownPanel.scrollToTag();
|
|
3868
2508
|
}
|
|
3869
|
-
/**
|
|
3870
|
-
* @private
|
|
3871
|
-
* @return {?}
|
|
3872
|
-
*/
|
|
3873
2509
|
_onSelectionChanged() {
|
|
3874
2510
|
if (this.isOpen && this.multiple && this.appendTo) {
|
|
3875
2511
|
// Make sure items are rendered.
|
|
@@ -3877,11 +2513,6 @@ class NgSelectComponent {
|
|
|
3877
2513
|
this.dropdownPanel.adjustPosition();
|
|
3878
2514
|
}
|
|
3879
2515
|
}
|
|
3880
|
-
/**
|
|
3881
|
-
* @private
|
|
3882
|
-
* @param {?} $event
|
|
3883
|
-
* @return {?}
|
|
3884
|
-
*/
|
|
3885
2516
|
_handleTab($event) {
|
|
3886
2517
|
if (this.isOpen === false && !this.addTag) {
|
|
3887
2518
|
return;
|
|
@@ -3903,11 +2534,6 @@ class NgSelectComponent {
|
|
|
3903
2534
|
this.close();
|
|
3904
2535
|
}
|
|
3905
2536
|
}
|
|
3906
|
-
/**
|
|
3907
|
-
* @private
|
|
3908
|
-
* @param {?} $event
|
|
3909
|
-
* @return {?}
|
|
3910
|
-
*/
|
|
3911
2537
|
_handleEnter($event) {
|
|
3912
2538
|
if (this.isOpen || this._manualOpen) {
|
|
3913
2539
|
if (this.itemsList.markedItem) {
|
|
@@ -3925,11 +2551,6 @@ class NgSelectComponent {
|
|
|
3925
2551
|
}
|
|
3926
2552
|
$event.preventDefault();
|
|
3927
2553
|
}
|
|
3928
|
-
/**
|
|
3929
|
-
* @private
|
|
3930
|
-
* @param {?} $event
|
|
3931
|
-
* @return {?}
|
|
3932
|
-
*/
|
|
3933
2554
|
_handleSpace($event) {
|
|
3934
2555
|
if (this.isOpen || this._manualOpen) {
|
|
3935
2556
|
return;
|
|
@@ -3937,11 +2558,6 @@ class NgSelectComponent {
|
|
|
3937
2558
|
this.open();
|
|
3938
2559
|
$event.preventDefault();
|
|
3939
2560
|
}
|
|
3940
|
-
/**
|
|
3941
|
-
* @private
|
|
3942
|
-
* @param {?} $event
|
|
3943
|
-
* @return {?}
|
|
3944
|
-
*/
|
|
3945
2561
|
_handleArrowDown($event) {
|
|
3946
2562
|
if (this._nextItemIsTag(+1)) {
|
|
3947
2563
|
this.itemsList.unmarkItem();
|
|
@@ -3954,11 +2570,6 @@ class NgSelectComponent {
|
|
|
3954
2570
|
this.open();
|
|
3955
2571
|
$event.preventDefault();
|
|
3956
2572
|
}
|
|
3957
|
-
/**
|
|
3958
|
-
* @private
|
|
3959
|
-
* @param {?} $event
|
|
3960
|
-
* @return {?}
|
|
3961
|
-
*/
|
|
3962
2573
|
_handleArrowUp($event) {
|
|
3963
2574
|
if (!this.isOpen) {
|
|
3964
2575
|
return;
|
|
@@ -3973,22 +2584,12 @@ class NgSelectComponent {
|
|
|
3973
2584
|
}
|
|
3974
2585
|
$event.preventDefault();
|
|
3975
2586
|
}
|
|
3976
|
-
/**
|
|
3977
|
-
* @private
|
|
3978
|
-
* @param {?} nextStep
|
|
3979
|
-
* @return {?}
|
|
3980
|
-
*/
|
|
3981
2587
|
_nextItemIsTag(nextStep) {
|
|
3982
|
-
/** @type {?} */
|
|
3983
2588
|
const nextIndex = this.itemsList.markedIndex + nextStep;
|
|
3984
2589
|
return this.addTag && this.searchTerm
|
|
3985
2590
|
&& this.itemsList.markedItem
|
|
3986
2591
|
&& (nextIndex < 0 || nextIndex === this.itemsList.filteredItems.length);
|
|
3987
2592
|
}
|
|
3988
|
-
/**
|
|
3989
|
-
* @private
|
|
3990
|
-
* @return {?}
|
|
3991
|
-
*/
|
|
3992
2593
|
_handleBackspace() {
|
|
3993
2594
|
if (this.searchTerm || !this.clearable || !this.clearOnBackspace || !this.hasValue) {
|
|
3994
2595
|
return;
|
|
@@ -4000,27 +2601,13 @@ class NgSelectComponent {
|
|
|
4000
2601
|
this.clearModel();
|
|
4001
2602
|
}
|
|
4002
2603
|
}
|
|
4003
|
-
/**
|
|
4004
|
-
* @private
|
|
4005
|
-
* @return {?}
|
|
4006
|
-
*/
|
|
4007
2604
|
get _isTypeahead() {
|
|
4008
2605
|
return this.typeahead && this.typeahead.observers.length > 0;
|
|
4009
2606
|
}
|
|
4010
|
-
/**
|
|
4011
|
-
* @private
|
|
4012
|
-
* @return {?}
|
|
4013
|
-
*/
|
|
4014
2607
|
get _validTerm() {
|
|
4015
|
-
/** @type {?} */
|
|
4016
2608
|
const term = this.searchTerm && this.searchTerm.trim();
|
|
4017
2609
|
return term && term.length >= this.minTermLength;
|
|
4018
2610
|
}
|
|
4019
|
-
/**
|
|
4020
|
-
* @private
|
|
4021
|
-
* @param {?} config
|
|
4022
|
-
* @return {?}
|
|
4023
|
-
*/
|
|
4024
2611
|
_mergeGlobalConfig(config) {
|
|
4025
2612
|
this.placeholder = this.placeholder || config.placeholder;
|
|
4026
2613
|
this.notFoundText = this.notFoundText || config.notFoundText;
|
|
@@ -4034,19 +2621,17 @@ class NgSelectComponent {
|
|
|
4034
2621
|
this.openOnEnter = isDefined(this.openOnEnter) ? this.openOnEnter : config.openOnEnter;
|
|
4035
2622
|
this.appendTo = this.appendTo || config.appendTo;
|
|
4036
2623
|
this.bindValue = this.bindValue || config.bindValue;
|
|
2624
|
+
this.bindLabel = this.bindLabel || config.bindLabel;
|
|
4037
2625
|
this.appearance = this.appearance || config.appearance;
|
|
4038
2626
|
}
|
|
4039
2627
|
}
|
|
4040
2628
|
NgSelectComponent.decorators = [
|
|
4041
2629
|
{ type: Component, args: [{
|
|
4042
2630
|
selector: 'ng-select',
|
|
4043
|
-
template: "<div\n (mousedown)=\"handleMousedown($event)\"\n [class.ng-appearance-outline]=\"appearance === 'outline'\"\n [class.ng-has-value]=\"hasValue\"\n class=\"ng-select-container\">\n\n <div class=\"ng-value-container\">\n <div class=\"ng-placeholder\">{{placeholder}}</div>\n\n <ng-container *ngIf=\"!multiLabelTemplate && selectedItems.length > 0\">\n <div [class.ng-value-disabled]=\"item.disabled\" class=\"ng-value\" *ngFor=\"let item of selectedItems; trackBy: trackByOption\">\n <ng-template #defaultLabelTemplate>\n <span class=\"ng-value-icon left\" (click)=\"unselect(item);\" aria-hidden=\"true\">\u00D7</span>\n <span class=\"ng-value-label\" [ngItemLabel]=\"item.label\" [escape]=\"escapeHTML\"></span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"labelTemplate || defaultLabelTemplate\"\n [ngTemplateOutletContext]=\"{ item: item.value, clear: clearItem, label: item.label }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-template *ngIf=\"multiLabelTemplate && selectedValues.length > 0\"\n [ngTemplateOutlet]=\"multiLabelTemplate\"\n [ngTemplateOutletContext]=\"{ items: selectedValues, clear: clearItem }\">\n </ng-template>\n\n <div class=\"ng-input\"\n role=\"combobox\" \n [attr.aria-expanded]=\"isOpen\" \n [attr.aria-owns]=\"isOpen ? dropdownId : null\" \n aria-haspopup=\"listbox\">\n\n <input #searchInput\n [attr.id]=\"labelForId\"\n [attr.tabindex]=\"tabIndex\"\n [readOnly]=\"!searchable || itemsList.maxItemsSelected\"\n [disabled]=\"disabled\"\n [value]=\"searchTerm ? searchTerm : ''\"\n (input)=\"filter(searchInput.value)\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd(searchInput.value)\"\n (focus)=\"onInputFocus($event)\"\n (blur)=\"onInputBlur($event)\"\n (change)=\"$event.stopPropagation()\"\n [attr.aria-activedescendant]=\"isOpen ? itemsList?.markedItem?.htmlId : null\"\n aria-autocomplete=\"list\"\n [attr.aria-controls]=\"isOpen ? dropdownId : null\">\n </div>\n </div>\n\n <ng-container *ngIf=\"loading\">\n <ng-template #defaultLoadingSpinnerTemplate>\n <div class=\"ng-spinner-loader\"></div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingSpinnerTemplate || defaultLoadingSpinnerTemplate\">\n </ng-template>\n </ng-container>\n\n <span *ngIf=\"showClear()\" class=\"ng-clear-wrapper\" title=\"{{clearAllText}}\">\n <span class=\"ng-clear\" aria-hidden=\"true\">\u00D7</span>\n </span>\n\n <span class=\"ng-arrow-wrapper\">\n <span class=\"ng-arrow\"></span>\n </span>\n</div>\n\n<ng-dropdown-panel *ngIf=\"isOpen\"\n class=\"ng-dropdown-panel\"\n [virtualScroll]=\"virtualScroll\"\n [bufferAmount]=\"bufferAmount\"\n [appendTo]=\"appendTo\"\n [position]=\"dropdownPosition\"\n [headerTemplate]=\"headerTemplate\"\n [footerTemplate]=\"footerTemplate\"\n [filterValue]=\"searchTerm\"\n [items]=\"itemsList.filteredItems\"\n [markedItem]=\"itemsList.markedItem\"\n (update)=\"viewPortItems = $event\"\n (scroll)=\"scroll.emit($event)\"\n (scrollToEnd)=\"scrollToEnd.emit($event)\"\n (outsideClick)=\"close()\"\n [class.ng-select-multiple]=\"multiple\"\n [ngClass]=\"appendTo ? classes : null\"\n [id]=\"dropdownId\"\n role=\"listbox\"\n aria-label=\"Options list\">\n\n <ng-container>\n <div class=\"ng-option\" [attr.role]=\"item.children ? 'group' : 'option'\" (click)=\"toggleItem(item)\" (mouseover)=\"onItemHover(item)\"\n *ngFor=\"let item of viewPortItems; trackBy: trackByOption\"\n [class.ng-option-disabled]=\"item.disabled\"\n [class.ng-option-selected]=\"item.selected\"\n [class.ng-optgroup]=\"item.children\"\n [class.ng-option]=\"!item.children\"\n [class.ng-option-child]=\"!!item.parent\"\n [class.ng-option-marked]=\"item === itemsList.markedItem\"\n [attr.aria-selected]=\"item.selected\"\n [attr.id]=\"item?.htmlId\">\n\n <ng-template #defaultOptionTemplate>\n <span class=\"ng-option-label\" [ngItemLabel]=\"item.label\" [escape]=\"escapeHTML\"></span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"item.children ? (optgroupTemplate || defaultOptionTemplate) : (optionTemplate || defaultOptionTemplate)\"\n [ngTemplateOutletContext]=\"{ item: item.value, item$:item, index: item.index, searchTerm: searchTerm }\">\n </ng-template>\n </div>\n\n <div class=\"ng-option\" [class.ng-option-marked]=\"!itemsList.markedItem\" (mouseover)=\"itemsList.unmarkItem()\" role=\"option\" (click)=\"selectTag()\" *ngIf=\"showAddTag\">\n <ng-template #defaultTagTemplate>\n <span><span class=\"ng-tag-label\">{{addTagText}}</span>\"{{searchTerm}}\"</span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"tagTemplate || defaultTagTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-container *ngIf=\"showNoItemsFound()\">\n <ng-template #defaultNotFoundTemplate>\n <div class=\"ng-option ng-option-disabled\">{{notFoundText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"notFoundTemplate || defaultNotFoundTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"showTypeToSearch()\">\n <ng-template #defaultTypeToSearchTemplate>\n <div class=\"ng-option ng-option-disabled\">{{typeToSearchText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"typeToSearchTemplate || defaultTypeToSearchTemplate\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"loading && itemsList.filteredItems.length === 0\">\n <ng-template #defaultLoadingTextTemplate>\n <div class=\"ng-option ng-option-disabled\">{{loadingText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingTextTemplate || defaultLoadingTextTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n</ng-dropdown-panel>\n",
|
|
2631
|
+
template: "<div\n (mousedown)=\"handleMousedown($event)\"\n [class.ng-appearance-outline]=\"appearance === 'outline'\"\n [class.ng-has-value]=\"hasValue\"\n class=\"ng-select-container\">\n\n <div class=\"ng-value-container\">\n <div class=\"ng-placeholder\">{{placeholder}}</div>\n\n <ng-container *ngIf=\"(!multiLabelTemplate || !multiple ) && selectedItems.length > 0\">\n <div [class.ng-value-disabled]=\"item.disabled\" class=\"ng-value\" *ngFor=\"let item of selectedItems; trackBy: trackByOption\">\n <ng-template #defaultLabelTemplate>\n <span class=\"ng-value-icon left\" (click)=\"unselect(item);\" aria-hidden=\"true\">\u00D7</span>\n <span class=\"ng-value-label\" [ngItemLabel]=\"item.label\" [escape]=\"escapeHTML\"></span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"labelTemplate || defaultLabelTemplate\"\n [ngTemplateOutletContext]=\"{ item: item.value, clear: clearItem, label: item.label }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-template *ngIf=\"multiple && multiLabelTemplate && selectedValues.length > 0\"\n [ngTemplateOutlet]=\"multiLabelTemplate\"\n [ngTemplateOutletContext]=\"{ items: selectedValues, clear: clearItem }\">\n </ng-template>\n\n <div class=\"ng-input\"\n role=\"combobox\" \n [attr.aria-expanded]=\"isOpen\" \n [attr.aria-owns]=\"isOpen ? dropdownId : null\" \n aria-haspopup=\"listbox\">\n\n <input #searchInput\n [attr.id]=\"labelForId\"\n [attr.tabindex]=\"tabIndex\"\n [readOnly]=\"!searchable || itemsList.maxItemsSelected\"\n [disabled]=\"disabled\"\n [value]=\"searchTerm ? searchTerm : ''\"\n (input)=\"filter(searchInput.value)\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd(searchInput.value)\"\n (focus)=\"onInputFocus($event)\"\n (blur)=\"onInputBlur($event)\"\n (change)=\"$event.stopPropagation()\"\n [attr.aria-activedescendant]=\"isOpen ? itemsList?.markedItem?.htmlId : null\"\n aria-autocomplete=\"list\"\n [attr.aria-controls]=\"isOpen ? dropdownId : null\">\n </div>\n </div>\n\n <ng-container *ngIf=\"loading\">\n <ng-template #defaultLoadingSpinnerTemplate>\n <div class=\"ng-spinner-loader\"></div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingSpinnerTemplate || defaultLoadingSpinnerTemplate\">\n </ng-template>\n </ng-container>\n\n <span *ngIf=\"showClear()\" class=\"ng-clear-wrapper\" title=\"{{clearAllText}}\">\n <span class=\"ng-clear\" aria-hidden=\"true\">\u00D7</span>\n </span>\n\n <span class=\"ng-arrow-wrapper\">\n <span class=\"ng-arrow\"></span>\n </span>\n</div>\n\n<ng-dropdown-panel *ngIf=\"isOpen\"\n class=\"ng-dropdown-panel\"\n [virtualScroll]=\"virtualScroll\"\n [bufferAmount]=\"bufferAmount\"\n [appendTo]=\"appendTo\"\n [position]=\"dropdownPosition\"\n [headerTemplate]=\"headerTemplate\"\n [footerTemplate]=\"footerTemplate\"\n [filterValue]=\"searchTerm\"\n [items]=\"itemsList.filteredItems\"\n [markedItem]=\"itemsList.markedItem\"\n (update)=\"viewPortItems = $event\"\n (scroll)=\"scroll.emit($event)\"\n (scrollToEnd)=\"scrollToEnd.emit($event)\"\n (outsideClick)=\"close()\"\n [class.ng-select-multiple]=\"multiple\"\n [ngClass]=\"appendTo ? classes : null\"\n [id]=\"dropdownId\"\n role=\"listbox\"\n aria-label=\"Options list\">\n\n <ng-container>\n <div class=\"ng-option\" [attr.role]=\"item.children ? 'group' : 'option'\" (click)=\"toggleItem(item)\" (mouseover)=\"onItemHover(item)\"\n *ngFor=\"let item of viewPortItems; trackBy: trackByOption\"\n [class.ng-option-disabled]=\"item.disabled\"\n [class.ng-option-selected]=\"item.selected\"\n [class.ng-optgroup]=\"item.children\"\n [class.ng-option]=\"!item.children\"\n [class.ng-option-child]=\"!!item.parent\"\n [class.ng-option-marked]=\"item === itemsList.markedItem\"\n [attr.aria-selected]=\"item.selected\"\n [attr.id]=\"item?.htmlId\">\n\n <ng-template #defaultOptionTemplate>\n <span class=\"ng-option-label\" [ngItemLabel]=\"item.label\" [escape]=\"escapeHTML\"></span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"item.children ? (optgroupTemplate || defaultOptionTemplate) : (optionTemplate || defaultOptionTemplate)\"\n [ngTemplateOutletContext]=\"{ item: item.value, item$:item, index: item.index, searchTerm: searchTerm }\">\n </ng-template>\n </div>\n\n <div class=\"ng-option\" [class.ng-option-marked]=\"!itemsList.markedItem\" (mouseover)=\"itemsList.unmarkItem()\" role=\"option\" (click)=\"selectTag()\" *ngIf=\"showAddTag\">\n <ng-template #defaultTagTemplate>\n <span><span class=\"ng-tag-label\">{{addTagText}}</span>\"{{searchTerm}}\"</span>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"tagTemplate || defaultTagTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </div>\n </ng-container>\n\n <ng-container *ngIf=\"showNoItemsFound()\">\n <ng-template #defaultNotFoundTemplate>\n <div class=\"ng-option ng-option-disabled\">{{notFoundText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"notFoundTemplate || defaultNotFoundTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"showTypeToSearch()\">\n <ng-template #defaultTypeToSearchTemplate>\n <div class=\"ng-option ng-option-disabled\">{{typeToSearchText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"typeToSearchTemplate || defaultTypeToSearchTemplate\">\n </ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"loading && itemsList.filteredItems.length === 0\">\n <ng-template #defaultLoadingTextTemplate>\n <div class=\"ng-option ng-option-disabled\">{{loadingText}}</div>\n </ng-template>\n\n <ng-template\n [ngTemplateOutlet]=\"loadingTextTemplate || defaultLoadingTextTemplate\"\n [ngTemplateOutletContext]=\"{ searchTerm: searchTerm }\">\n </ng-template>\n </ng-container>\n\n</ng-dropdown-panel>\n",
|
|
4044
2632
|
providers: [{
|
|
4045
2633
|
provide: NG_VALUE_ACCESSOR,
|
|
4046
|
-
useExisting: forwardRef((
|
|
4047
|
-
* @return {?}
|
|
4048
|
-
*/
|
|
4049
|
-
() => NgSelectComponent)),
|
|
2634
|
+
useExisting: forwardRef(() => NgSelectComponent),
|
|
4050
2635
|
multi: true
|
|
4051
2636
|
}, NgDropdownPanelService],
|
|
4052
2637
|
encapsulation: ViewEncapsulation.None,
|
|
@@ -4056,9 +2641,8 @@ NgSelectComponent.decorators = [
|
|
|
4056
2641
|
'[class.ng-select-single]': '!multiple',
|
|
4057
2642
|
},
|
|
4058
2643
|
styles: [".ng-select{display:block;position:relative}.ng-select,.ng-select div,.ng-select input,.ng-select span{box-sizing:border-box}.ng-select [hidden]{display:none}.ng-select.ng-select-searchable .ng-select-container .ng-value-container .ng-input{opacity:1}.ng-select.ng-select-opened .ng-select-container{z-index:1001}.ng-select.ng-select-disabled .ng-select-container .ng-value-container .ng-placeholder,.ng-select.ng-select-disabled .ng-select-container .ng-value-container .ng-value{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;cursor:default;user-select:none}.ng-select.ng-select-disabled .ng-arrow-wrapper{cursor:default}.ng-select.ng-select-filtered .ng-placeholder{display:none}.ng-select .ng-select-container{cursor:default;display:flex;outline:none;overflow:hidden;position:relative;width:100%}.ng-select .ng-select-container .ng-value-container{display:flex;flex:1}.ng-select .ng-select-container .ng-value-container .ng-input{opacity:0}.ng-select .ng-select-container .ng-value-container .ng-input>input{background:none transparent;border:0;box-shadow:none;box-sizing:content-box;cursor:default;outline:none;padding:0;width:100%}.ng-select .ng-select-container .ng-value-container .ng-input>input::-ms-clear{display:none}.ng-select .ng-select-container .ng-value-container .ng-input>input[readonly]{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;padding:0;user-select:none;width:0}.ng-select.ng-select-single.ng-select-filtered .ng-select-container .ng-value-container .ng-value{visibility:hidden}.ng-select.ng-select-single .ng-select-container .ng-value-container,.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-value .ng-value-icon{display:none}.ng-select.ng-select-single .ng-select-container .ng-value-container .ng-input{left:0;position:absolute;width:100%}.ng-select.ng-select-multiple.ng-select-disabled>.ng-select-container .ng-value-container .ng-value .ng-value-icon{display:none}.ng-select.ng-select-multiple .ng-select-container .ng-value-container{flex-wrap:wrap}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-placeholder{position:absolute}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value{white-space:nowrap}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value.ng-value-disabled .ng-value-icon{display:none}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-value .ng-value-icon{cursor:pointer}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-input{flex:1;z-index:2}.ng-select.ng-select-multiple .ng-select-container .ng-value-container .ng-placeholder{z-index:1}.ng-select .ng-clear-wrapper{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;cursor:pointer;position:relative;user-select:none;width:17px}.ng-select .ng-clear-wrapper .ng-clear{display:inline-block;font-size:18px;line-height:1;pointer-events:none}.ng-select .ng-spinner-loader{-webkit-animation:load8 .8s linear infinite;animation:load8 .8s linear infinite;border:2px solid rgba(66,66,66,.2);border-left-color:#424242;border-radius:50%;font-size:10px;height:17px;margin-right:5px;position:relative;text-indent:-9999em;transform:translateZ(0);width:17px}.ng-select .ng-spinner-loader:after{border-radius:50%;height:17px;width:17px}@-webkit-keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.ng-select .ng-arrow-wrapper{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;cursor:pointer;position:relative;text-align:center;user-select:none}.ng-select .ng-arrow-wrapper .ng-arrow{display:inline-block;height:0;pointer-events:none;position:relative;width:0}.ng-dropdown-panel{-webkit-overflow-scrolling:touch;box-sizing:border-box;opacity:0;position:absolute;width:100%;z-index:1050}.ng-dropdown-panel .ng-dropdown-panel-items{box-sizing:border-box;display:block;height:auto;max-height:240px;overflow-y:auto}.ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup,.ng-dropdown-panel .ng-dropdown-panel-items .ng-option{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option{box-sizing:border-box;cursor:pointer;display:block}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option .ng-option-label:empty:before{content:\"\\200b\"}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option .highlighted{font-weight:700;text-decoration:underline}.ng-dropdown-panel .ng-dropdown-panel-items .ng-option.disabled{cursor:default}.ng-dropdown-panel .scroll-host{-webkit-overflow-scrolling:touch;display:block;overflow:hidden;overflow-y:auto;position:relative}.ng-dropdown-panel .scrollable-content{height:100%;left:0;position:absolute;top:0;width:100%}.ng-dropdown-panel .total-padding{opacity:0;width:1px}"]
|
|
4059
|
-
}] }
|
|
2644
|
+
},] }
|
|
4060
2645
|
];
|
|
4061
|
-
/** @nocollapse */
|
|
4062
2646
|
NgSelectComponent.ctorParameters = () => [
|
|
4063
2647
|
{ type: String, decorators: [{ type: Attribute, args: ['class',] }] },
|
|
4064
2648
|
{ type: undefined, decorators: [{ type: Attribute, args: ['autofocus',] }] },
|
|
@@ -4135,317 +2719,24 @@ NgSelectComponent.propDecorators = {
|
|
|
4135
2719
|
loadingTextTemplate: [{ type: ContentChild, args: [NgLoadingTextTemplateDirective, { read: TemplateRef },] }],
|
|
4136
2720
|
tagTemplate: [{ type: ContentChild, args: [NgTagTemplateDirective, { read: TemplateRef },] }],
|
|
4137
2721
|
loadingSpinnerTemplate: [{ type: ContentChild, args: [NgLoadingSpinnerTemplateDirective, { read: TemplateRef },] }],
|
|
4138
|
-
dropdownPanel: [{ type: ViewChild, args: [forwardRef((
|
|
4139
|
-
* @return {?}
|
|
4140
|
-
*/
|
|
4141
|
-
() => NgDropdownPanelComponent)),] }],
|
|
2722
|
+
dropdownPanel: [{ type: ViewChild, args: [forwardRef(() => NgDropdownPanelComponent),] }],
|
|
4142
2723
|
searchInput: [{ type: ViewChild, args: ['searchInput', { static: true },] }],
|
|
4143
2724
|
ngOptions: [{ type: ContentChildren, args: [NgOptionComponent, { descendants: true },] }],
|
|
4144
2725
|
disabled: [{ type: HostBinding, args: ['class.ng-select-disabled',] }],
|
|
4145
2726
|
filtered: [{ type: HostBinding, args: ['class.ng-select-filtered',] }],
|
|
4146
2727
|
handleKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }]
|
|
4147
2728
|
};
|
|
4148
|
-
if (false) {
|
|
4149
|
-
/** @type {?} */
|
|
4150
|
-
NgSelectComponent.prototype.bindLabel;
|
|
4151
|
-
/** @type {?} */
|
|
4152
|
-
NgSelectComponent.prototype.bindValue;
|
|
4153
|
-
/** @type {?} */
|
|
4154
|
-
NgSelectComponent.prototype.markFirst;
|
|
4155
|
-
/** @type {?} */
|
|
4156
|
-
NgSelectComponent.prototype.placeholder;
|
|
4157
|
-
/** @type {?} */
|
|
4158
|
-
NgSelectComponent.prototype.notFoundText;
|
|
4159
|
-
/** @type {?} */
|
|
4160
|
-
NgSelectComponent.prototype.typeToSearchText;
|
|
4161
|
-
/** @type {?} */
|
|
4162
|
-
NgSelectComponent.prototype.addTagText;
|
|
4163
|
-
/** @type {?} */
|
|
4164
|
-
NgSelectComponent.prototype.loadingText;
|
|
4165
|
-
/** @type {?} */
|
|
4166
|
-
NgSelectComponent.prototype.clearAllText;
|
|
4167
|
-
/** @type {?} */
|
|
4168
|
-
NgSelectComponent.prototype.appearance;
|
|
4169
|
-
/** @type {?} */
|
|
4170
|
-
NgSelectComponent.prototype.dropdownPosition;
|
|
4171
|
-
/** @type {?} */
|
|
4172
|
-
NgSelectComponent.prototype.appendTo;
|
|
4173
|
-
/** @type {?} */
|
|
4174
|
-
NgSelectComponent.prototype.loading;
|
|
4175
|
-
/** @type {?} */
|
|
4176
|
-
NgSelectComponent.prototype.closeOnSelect;
|
|
4177
|
-
/** @type {?} */
|
|
4178
|
-
NgSelectComponent.prototype.hideSelected;
|
|
4179
|
-
/** @type {?} */
|
|
4180
|
-
NgSelectComponent.prototype.selectOnTab;
|
|
4181
|
-
/** @type {?} */
|
|
4182
|
-
NgSelectComponent.prototype.openOnEnter;
|
|
4183
|
-
/** @type {?} */
|
|
4184
|
-
NgSelectComponent.prototype.maxSelectedItems;
|
|
4185
|
-
/** @type {?} */
|
|
4186
|
-
NgSelectComponent.prototype.groupBy;
|
|
4187
|
-
/** @type {?} */
|
|
4188
|
-
NgSelectComponent.prototype.groupValue;
|
|
4189
|
-
/** @type {?} */
|
|
4190
|
-
NgSelectComponent.prototype.bufferAmount;
|
|
4191
|
-
/** @type {?} */
|
|
4192
|
-
NgSelectComponent.prototype.virtualScroll;
|
|
4193
|
-
/** @type {?} */
|
|
4194
|
-
NgSelectComponent.prototype.selectableGroup;
|
|
4195
|
-
/** @type {?} */
|
|
4196
|
-
NgSelectComponent.prototype.selectableGroupAsModel;
|
|
4197
|
-
/** @type {?} */
|
|
4198
|
-
NgSelectComponent.prototype.searchFn;
|
|
4199
|
-
/** @type {?} */
|
|
4200
|
-
NgSelectComponent.prototype.trackByFn;
|
|
4201
|
-
/** @type {?} */
|
|
4202
|
-
NgSelectComponent.prototype.clearOnBackspace;
|
|
4203
|
-
/** @type {?} */
|
|
4204
|
-
NgSelectComponent.prototype.labelForId;
|
|
4205
|
-
/** @type {?} */
|
|
4206
|
-
NgSelectComponent.prototype.inputAttrs;
|
|
4207
|
-
/** @type {?} */
|
|
4208
|
-
NgSelectComponent.prototype.tabIndex;
|
|
4209
|
-
/** @type {?} */
|
|
4210
|
-
NgSelectComponent.prototype.readonly;
|
|
4211
|
-
/** @type {?} */
|
|
4212
|
-
NgSelectComponent.prototype.searchWhileComposing;
|
|
4213
|
-
/** @type {?} */
|
|
4214
|
-
NgSelectComponent.prototype.minTermLength;
|
|
4215
|
-
/** @type {?} */
|
|
4216
|
-
NgSelectComponent.prototype.editableSearchTerm;
|
|
4217
|
-
/** @type {?} */
|
|
4218
|
-
NgSelectComponent.prototype.keyDownFn;
|
|
4219
|
-
/** @type {?} */
|
|
4220
|
-
NgSelectComponent.prototype.typeahead;
|
|
4221
|
-
/** @type {?} */
|
|
4222
|
-
NgSelectComponent.prototype.multiple;
|
|
4223
|
-
/** @type {?} */
|
|
4224
|
-
NgSelectComponent.prototype.addTag;
|
|
4225
|
-
/** @type {?} */
|
|
4226
|
-
NgSelectComponent.prototype.searchable;
|
|
4227
|
-
/** @type {?} */
|
|
4228
|
-
NgSelectComponent.prototype.clearable;
|
|
4229
|
-
/** @type {?} */
|
|
4230
|
-
NgSelectComponent.prototype.isOpen;
|
|
4231
|
-
/** @type {?} */
|
|
4232
|
-
NgSelectComponent.prototype.blurEvent;
|
|
4233
|
-
/** @type {?} */
|
|
4234
|
-
NgSelectComponent.prototype.focusEvent;
|
|
4235
|
-
/** @type {?} */
|
|
4236
|
-
NgSelectComponent.prototype.changeEvent;
|
|
4237
|
-
/** @type {?} */
|
|
4238
|
-
NgSelectComponent.prototype.openEvent;
|
|
4239
|
-
/** @type {?} */
|
|
4240
|
-
NgSelectComponent.prototype.closeEvent;
|
|
4241
|
-
/** @type {?} */
|
|
4242
|
-
NgSelectComponent.prototype.searchEvent;
|
|
4243
|
-
/** @type {?} */
|
|
4244
|
-
NgSelectComponent.prototype.clearEvent;
|
|
4245
|
-
/** @type {?} */
|
|
4246
|
-
NgSelectComponent.prototype.addEvent;
|
|
4247
|
-
/** @type {?} */
|
|
4248
|
-
NgSelectComponent.prototype.removeEvent;
|
|
4249
|
-
/** @type {?} */
|
|
4250
|
-
NgSelectComponent.prototype.scroll;
|
|
4251
|
-
/** @type {?} */
|
|
4252
|
-
NgSelectComponent.prototype.scrollToEnd;
|
|
4253
|
-
/** @type {?} */
|
|
4254
|
-
NgSelectComponent.prototype.optionTemplate;
|
|
4255
|
-
/** @type {?} */
|
|
4256
|
-
NgSelectComponent.prototype.optgroupTemplate;
|
|
4257
|
-
/** @type {?} */
|
|
4258
|
-
NgSelectComponent.prototype.labelTemplate;
|
|
4259
|
-
/** @type {?} */
|
|
4260
|
-
NgSelectComponent.prototype.multiLabelTemplate;
|
|
4261
|
-
/** @type {?} */
|
|
4262
|
-
NgSelectComponent.prototype.headerTemplate;
|
|
4263
|
-
/** @type {?} */
|
|
4264
|
-
NgSelectComponent.prototype.footerTemplate;
|
|
4265
|
-
/** @type {?} */
|
|
4266
|
-
NgSelectComponent.prototype.notFoundTemplate;
|
|
4267
|
-
/** @type {?} */
|
|
4268
|
-
NgSelectComponent.prototype.typeToSearchTemplate;
|
|
4269
|
-
/** @type {?} */
|
|
4270
|
-
NgSelectComponent.prototype.loadingTextTemplate;
|
|
4271
|
-
/** @type {?} */
|
|
4272
|
-
NgSelectComponent.prototype.tagTemplate;
|
|
4273
|
-
/** @type {?} */
|
|
4274
|
-
NgSelectComponent.prototype.loadingSpinnerTemplate;
|
|
4275
|
-
/** @type {?} */
|
|
4276
|
-
NgSelectComponent.prototype.dropdownPanel;
|
|
4277
|
-
/** @type {?} */
|
|
4278
|
-
NgSelectComponent.prototype.searchInput;
|
|
4279
|
-
/** @type {?} */
|
|
4280
|
-
NgSelectComponent.prototype.ngOptions;
|
|
4281
|
-
/** @type {?} */
|
|
4282
|
-
NgSelectComponent.prototype.itemsList;
|
|
4283
|
-
/** @type {?} */
|
|
4284
|
-
NgSelectComponent.prototype.viewPortItems;
|
|
4285
|
-
/** @type {?} */
|
|
4286
|
-
NgSelectComponent.prototype.searchTerm;
|
|
4287
|
-
/** @type {?} */
|
|
4288
|
-
NgSelectComponent.prototype.dropdownId;
|
|
4289
|
-
/** @type {?} */
|
|
4290
|
-
NgSelectComponent.prototype.element;
|
|
4291
|
-
/** @type {?} */
|
|
4292
|
-
NgSelectComponent.prototype.focused;
|
|
4293
|
-
/** @type {?} */
|
|
4294
|
-
NgSelectComponent.prototype.escapeHTML;
|
|
4295
|
-
/** @type {?} */
|
|
4296
|
-
NgSelectComponent.prototype.useDefaultClass;
|
|
4297
|
-
/**
|
|
4298
|
-
* @type {?}
|
|
4299
|
-
* @private
|
|
4300
|
-
*/
|
|
4301
|
-
NgSelectComponent.prototype._items;
|
|
4302
|
-
/**
|
|
4303
|
-
* @type {?}
|
|
4304
|
-
* @private
|
|
4305
|
-
*/
|
|
4306
|
-
NgSelectComponent.prototype._itemsAreUsed;
|
|
4307
|
-
/**
|
|
4308
|
-
* @type {?}
|
|
4309
|
-
* @private
|
|
4310
|
-
*/
|
|
4311
|
-
NgSelectComponent.prototype._defaultLabel;
|
|
4312
|
-
/**
|
|
4313
|
-
* @type {?}
|
|
4314
|
-
* @private
|
|
4315
|
-
*/
|
|
4316
|
-
NgSelectComponent.prototype._primitive;
|
|
4317
|
-
/**
|
|
4318
|
-
* @type {?}
|
|
4319
|
-
* @private
|
|
4320
|
-
*/
|
|
4321
|
-
NgSelectComponent.prototype._manualOpen;
|
|
4322
|
-
/**
|
|
4323
|
-
* @type {?}
|
|
4324
|
-
* @private
|
|
4325
|
-
*/
|
|
4326
|
-
NgSelectComponent.prototype._disabled;
|
|
4327
|
-
/**
|
|
4328
|
-
* @type {?}
|
|
4329
|
-
* @private
|
|
4330
|
-
*/
|
|
4331
|
-
NgSelectComponent.prototype._pressedKeys;
|
|
4332
|
-
/**
|
|
4333
|
-
* @type {?}
|
|
4334
|
-
* @private
|
|
4335
|
-
*/
|
|
4336
|
-
NgSelectComponent.prototype._compareWith;
|
|
4337
|
-
/**
|
|
4338
|
-
* @type {?}
|
|
4339
|
-
* @private
|
|
4340
|
-
*/
|
|
4341
|
-
NgSelectComponent.prototype._clearSearchOnAdd;
|
|
4342
|
-
/**
|
|
4343
|
-
* @type {?}
|
|
4344
|
-
* @private
|
|
4345
|
-
*/
|
|
4346
|
-
NgSelectComponent.prototype._isComposing;
|
|
4347
|
-
/**
|
|
4348
|
-
* @type {?}
|
|
4349
|
-
* @private
|
|
4350
|
-
*/
|
|
4351
|
-
NgSelectComponent.prototype._destroy$;
|
|
4352
|
-
/**
|
|
4353
|
-
* @type {?}
|
|
4354
|
-
* @private
|
|
4355
|
-
*/
|
|
4356
|
-
NgSelectComponent.prototype._keyPress$;
|
|
4357
|
-
/**
|
|
4358
|
-
* @type {?}
|
|
4359
|
-
* @private
|
|
4360
|
-
*/
|
|
4361
|
-
NgSelectComponent.prototype._onChange;
|
|
4362
|
-
/**
|
|
4363
|
-
* @type {?}
|
|
4364
|
-
* @private
|
|
4365
|
-
*/
|
|
4366
|
-
NgSelectComponent.prototype._onTouched;
|
|
4367
|
-
/** @type {?} */
|
|
4368
|
-
NgSelectComponent.prototype.clearItem;
|
|
4369
|
-
/** @type {?} */
|
|
4370
|
-
NgSelectComponent.prototype.trackByOption;
|
|
4371
|
-
/** @type {?} */
|
|
4372
|
-
NgSelectComponent.prototype.classes;
|
|
4373
|
-
/**
|
|
4374
|
-
* @type {?}
|
|
4375
|
-
* @private
|
|
4376
|
-
*/
|
|
4377
|
-
NgSelectComponent.prototype.autoFocus;
|
|
4378
|
-
/**
|
|
4379
|
-
* @type {?}
|
|
4380
|
-
* @private
|
|
4381
|
-
*/
|
|
4382
|
-
NgSelectComponent.prototype._cd;
|
|
4383
|
-
/**
|
|
4384
|
-
* @type {?}
|
|
4385
|
-
* @private
|
|
4386
|
-
*/
|
|
4387
|
-
NgSelectComponent.prototype._console;
|
|
4388
|
-
/* Skipping unhandled member: ;*/
|
|
4389
|
-
/* Skipping unhandled member: ;*/
|
|
4390
|
-
/* Skipping unhandled member: ;*/
|
|
4391
|
-
/* Skipping unhandled member: ;*/
|
|
4392
|
-
/* Skipping unhandled member: ;*/
|
|
4393
|
-
/* Skipping unhandled member: ;*/
|
|
4394
|
-
}
|
|
4395
2729
|
|
|
4396
|
-
/**
|
|
4397
|
-
* @fileoverview added by tsickle
|
|
4398
|
-
* Generated from: lib/selection-model.ts
|
|
4399
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4400
|
-
*/
|
|
4401
|
-
/**
|
|
4402
|
-
* @return {?}
|
|
4403
|
-
*/
|
|
4404
2730
|
function DefaultSelectionModelFactory() {
|
|
4405
2731
|
return new DefaultSelectionModel();
|
|
4406
2732
|
}
|
|
4407
|
-
/**
|
|
4408
|
-
* @record
|
|
4409
|
-
*/
|
|
4410
|
-
function SelectionModel() { }
|
|
4411
|
-
if (false) {
|
|
4412
|
-
/** @type {?} */
|
|
4413
|
-
SelectionModel.prototype.value;
|
|
4414
|
-
/**
|
|
4415
|
-
* @param {?} item
|
|
4416
|
-
* @param {?} multiple
|
|
4417
|
-
* @param {?} selectableGroupAsModel
|
|
4418
|
-
* @return {?}
|
|
4419
|
-
*/
|
|
4420
|
-
SelectionModel.prototype.select = function (item, multiple, selectableGroupAsModel) { };
|
|
4421
|
-
/**
|
|
4422
|
-
* @param {?} item
|
|
4423
|
-
* @param {?} multiple
|
|
4424
|
-
* @return {?}
|
|
4425
|
-
*/
|
|
4426
|
-
SelectionModel.prototype.unselect = function (item, multiple) { };
|
|
4427
|
-
/**
|
|
4428
|
-
* @param {?} keepDisabled
|
|
4429
|
-
* @return {?}
|
|
4430
|
-
*/
|
|
4431
|
-
SelectionModel.prototype.clear = function (keepDisabled) { };
|
|
4432
|
-
}
|
|
4433
2733
|
class DefaultSelectionModel {
|
|
4434
2734
|
constructor() {
|
|
4435
2735
|
this._selected = [];
|
|
4436
2736
|
}
|
|
4437
|
-
/**
|
|
4438
|
-
* @return {?}
|
|
4439
|
-
*/
|
|
4440
2737
|
get value() {
|
|
4441
2738
|
return this._selected;
|
|
4442
2739
|
}
|
|
4443
|
-
/**
|
|
4444
|
-
* @param {?} item
|
|
4445
|
-
* @param {?} multiple
|
|
4446
|
-
* @param {?} groupAsModel
|
|
4447
|
-
* @return {?}
|
|
4448
|
-
*/
|
|
4449
2740
|
select(item, multiple, groupAsModel) {
|
|
4450
2741
|
item.selected = true;
|
|
4451
2742
|
if (!item.children || (!multiple && groupAsModel)) {
|
|
@@ -4453,59 +2744,31 @@ class DefaultSelectionModel {
|
|
|
4453
2744
|
}
|
|
4454
2745
|
if (multiple) {
|
|
4455
2746
|
if (item.parent) {
|
|
4456
|
-
/** @type {?} */
|
|
4457
2747
|
const childrenCount = item.parent.children.length;
|
|
4458
|
-
|
|
4459
|
-
const selectedCount = item.parent.children.filter((/**
|
|
4460
|
-
* @param {?} x
|
|
4461
|
-
* @return {?}
|
|
4462
|
-
*/
|
|
4463
|
-
x => x.selected)).length;
|
|
2748
|
+
const selectedCount = item.parent.children.filter(x => x.selected).length;
|
|
4464
2749
|
item.parent.selected = childrenCount === selectedCount;
|
|
4465
2750
|
}
|
|
4466
2751
|
else if (item.children) {
|
|
4467
2752
|
this._setChildrenSelectedState(item.children, true);
|
|
4468
2753
|
this._removeChildren(item);
|
|
4469
2754
|
if (groupAsModel && this._activeChildren(item)) {
|
|
4470
|
-
this._selected = [...this._selected.filter(
|
|
4471
|
-
* @param {?} x
|
|
4472
|
-
* @return {?}
|
|
4473
|
-
*/
|
|
4474
|
-
x => x.parent !== item)), item];
|
|
2755
|
+
this._selected = [...this._selected.filter(x => x.parent !== item), item];
|
|
4475
2756
|
}
|
|
4476
2757
|
else {
|
|
4477
|
-
this._selected = [...this._selected, ...item.children.filter(
|
|
4478
|
-
* @param {?} x
|
|
4479
|
-
* @return {?}
|
|
4480
|
-
*/
|
|
4481
|
-
x => !x.disabled))];
|
|
2758
|
+
this._selected = [...this._selected, ...item.children.filter(x => !x.disabled)];
|
|
4482
2759
|
}
|
|
4483
2760
|
}
|
|
4484
2761
|
}
|
|
4485
2762
|
}
|
|
4486
|
-
/**
|
|
4487
|
-
* @param {?} item
|
|
4488
|
-
* @param {?} multiple
|
|
4489
|
-
* @return {?}
|
|
4490
|
-
*/
|
|
4491
2763
|
unselect(item, multiple) {
|
|
4492
|
-
this._selected = this._selected.filter(
|
|
4493
|
-
* @param {?} x
|
|
4494
|
-
* @return {?}
|
|
4495
|
-
*/
|
|
4496
|
-
x => x !== item));
|
|
2764
|
+
this._selected = this._selected.filter(x => x !== item);
|
|
4497
2765
|
item.selected = false;
|
|
4498
2766
|
if (multiple) {
|
|
4499
2767
|
if (item.parent && item.parent.selected) {
|
|
4500
|
-
/** @type {?} */
|
|
4501
2768
|
const children = item.parent.children;
|
|
4502
2769
|
this._removeParent(item.parent);
|
|
4503
2770
|
this._removeChildren(item.parent);
|
|
4504
|
-
this._selected.push(...children.filter(
|
|
4505
|
-
* @param {?} x
|
|
4506
|
-
* @return {?}
|
|
4507
|
-
*/
|
|
4508
|
-
x => x !== item && !x.disabled)));
|
|
2771
|
+
this._selected.push(...children.filter(x => x !== item && !x.disabled));
|
|
4509
2772
|
item.parent.selected = false;
|
|
4510
2773
|
}
|
|
4511
2774
|
else if (item.children) {
|
|
@@ -4514,23 +2777,9 @@ class DefaultSelectionModel {
|
|
|
4514
2777
|
}
|
|
4515
2778
|
}
|
|
4516
2779
|
}
|
|
4517
|
-
/**
|
|
4518
|
-
* @param {?} keepDisabled
|
|
4519
|
-
* @return {?}
|
|
4520
|
-
*/
|
|
4521
2780
|
clear(keepDisabled) {
|
|
4522
|
-
this._selected = keepDisabled ? this._selected.filter(
|
|
4523
|
-
|
|
4524
|
-
* @return {?}
|
|
4525
|
-
*/
|
|
4526
|
-
x => x.disabled)) : [];
|
|
4527
|
-
}
|
|
4528
|
-
/**
|
|
4529
|
-
* @private
|
|
4530
|
-
* @param {?} children
|
|
4531
|
-
* @param {?} selected
|
|
4532
|
-
* @return {?}
|
|
4533
|
-
*/
|
|
2781
|
+
this._selected = keepDisabled ? this._selected.filter(x => x.disabled) : [];
|
|
2782
|
+
}
|
|
4534
2783
|
_setChildrenSelectedState(children, selected) {
|
|
4535
2784
|
for (const child of children) {
|
|
4536
2785
|
if (child.disabled) {
|
|
@@ -4540,63 +2789,20 @@ class DefaultSelectionModel {
|
|
|
4540
2789
|
}
|
|
4541
2790
|
;
|
|
4542
2791
|
}
|
|
4543
|
-
/**
|
|
4544
|
-
* @private
|
|
4545
|
-
* @param {?} parent
|
|
4546
|
-
* @return {?}
|
|
4547
|
-
*/
|
|
4548
2792
|
_removeChildren(parent) {
|
|
4549
2793
|
this._selected = [
|
|
4550
|
-
...this._selected.filter(
|
|
4551
|
-
|
|
4552
|
-
* @return {?}
|
|
4553
|
-
*/
|
|
4554
|
-
x => x.parent !== parent)),
|
|
4555
|
-
...parent.children.filter((/**
|
|
4556
|
-
* @param {?} x
|
|
4557
|
-
* @return {?}
|
|
4558
|
-
*/
|
|
4559
|
-
x => x.parent === parent && x.disabled && x.selected))
|
|
2794
|
+
...this._selected.filter(x => x.parent !== parent),
|
|
2795
|
+
...parent.children.filter(x => x.parent === parent && x.disabled && x.selected)
|
|
4560
2796
|
];
|
|
4561
2797
|
}
|
|
4562
|
-
/**
|
|
4563
|
-
* @private
|
|
4564
|
-
* @param {?} parent
|
|
4565
|
-
* @return {?}
|
|
4566
|
-
*/
|
|
4567
2798
|
_removeParent(parent) {
|
|
4568
|
-
this._selected = this._selected.filter(
|
|
4569
|
-
|
|
4570
|
-
* @return {?}
|
|
4571
|
-
*/
|
|
4572
|
-
x => x !== parent));
|
|
4573
|
-
}
|
|
4574
|
-
/**
|
|
4575
|
-
* @private
|
|
4576
|
-
* @param {?} item
|
|
4577
|
-
* @return {?}
|
|
4578
|
-
*/
|
|
2799
|
+
this._selected = this._selected.filter(x => x !== parent);
|
|
2800
|
+
}
|
|
4579
2801
|
_activeChildren(item) {
|
|
4580
|
-
return item.children.every(
|
|
4581
|
-
* @param {?} x
|
|
4582
|
-
* @return {?}
|
|
4583
|
-
*/
|
|
4584
|
-
x => !x.disabled || x.selected));
|
|
2802
|
+
return item.children.every(x => !x.disabled || x.selected);
|
|
4585
2803
|
}
|
|
4586
2804
|
}
|
|
4587
|
-
if (false) {
|
|
4588
|
-
/**
|
|
4589
|
-
* @type {?}
|
|
4590
|
-
* @private
|
|
4591
|
-
*/
|
|
4592
|
-
DefaultSelectionModel.prototype._selected;
|
|
4593
|
-
}
|
|
4594
2805
|
|
|
4595
|
-
/**
|
|
4596
|
-
* @fileoverview added by tsickle
|
|
4597
|
-
* Generated from: lib/ng-select.module.ts
|
|
4598
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4599
|
-
*/
|
|
4600
2806
|
const ɵ0 = DefaultSelectionModelFactory;
|
|
4601
2807
|
class NgSelectModule {
|
|
4602
2808
|
}
|
|
@@ -4643,16 +2849,12 @@ NgSelectModule.decorators = [
|
|
|
4643
2849
|
},] }
|
|
4644
2850
|
];
|
|
4645
2851
|
|
|
4646
|
-
|
|
4647
|
-
*
|
|
4648
|
-
* Generated from: public-api.ts
|
|
4649
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2852
|
+
/*
|
|
2853
|
+
* Public API Surface of ng-select
|
|
4650
2854
|
*/
|
|
4651
2855
|
|
|
4652
2856
|
/**
|
|
4653
|
-
*
|
|
4654
|
-
* Generated from: ng-select-ng-select.ts
|
|
4655
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2857
|
+
* Generated bundle index. Do not edit.
|
|
4656
2858
|
*/
|
|
4657
2859
|
|
|
4658
2860
|
export { NgSelectComponent, NgSelectConfig, NgSelectModule, SELECTION_MODEL_FACTORY, DefaultSelectionModelFactory as ɵb, DefaultSelectionModel as ɵc, NgDropdownPanelService as ɵd, NgItemLabelDirective as ɵe, NgOptionTemplateDirective as ɵf, NgOptgroupTemplateDirective as ɵg, NgLabelTemplateDirective as ɵh, NgMultiLabelTemplateDirective as ɵi, NgHeaderTemplateDirective as ɵj, NgFooterTemplateDirective as ɵk, NgNotFoundTemplateDirective as ɵl, NgTypeToSearchTemplateDirective as ɵm, NgLoadingTextTemplateDirective as ɵn, NgTagTemplateDirective as ɵo, NgLoadingSpinnerTemplateDirective as ɵp, NgDropdownPanelComponent as ɵq, NgOptionComponent as ɵr, ConsoleService as ɵs };
|