ng-select2-component 8.0.6 → 10.0.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +46 -38
  3. package/esm2020/lib/select2-const.mjs +48 -0
  4. package/esm2020/lib/select2-hint.component.mjs +11 -0
  5. package/esm2020/lib/select2-interfaces.mjs +2 -0
  6. package/esm2020/lib/select2-label.component.mjs +11 -0
  7. package/esm2020/lib/select2-utils.mjs +280 -0
  8. package/esm2020/lib/select2.component.mjs +871 -0
  9. package/esm2020/lib/select2.module.mjs +23 -0
  10. package/esm2020/ng-select2-component.mjs +5 -0
  11. package/esm2020/public_api.mjs +12 -0
  12. package/fesm2015/ng-select2-component.mjs +1241 -0
  13. package/fesm2015/ng-select2-component.mjs.map +1 -0
  14. package/fesm2020/ng-select2-component.mjs +1242 -0
  15. package/fesm2020/ng-select2-component.mjs.map +1 -0
  16. package/index.d.ts +6 -0
  17. package/lib/select2-const.d.ts +1 -0
  18. package/lib/select2-const.d.ts.map +1 -0
  19. package/lib/select2-hint.component.d.ts +4 -0
  20. package/lib/select2-hint.component.d.ts.map +1 -0
  21. package/lib/select2-interfaces.d.ts +1 -0
  22. package/lib/select2-interfaces.d.ts.map +1 -0
  23. package/lib/select2-label.component.d.ts +4 -0
  24. package/lib/select2-label.component.d.ts.map +1 -0
  25. package/lib/select2-utils.d.ts +11 -6
  26. package/lib/select2-utils.d.ts.map +1 -0
  27. package/lib/select2.component.d.ts +15 -6
  28. package/lib/select2.component.d.ts.map +1 -0
  29. package/lib/select2.module.d.ts +12 -0
  30. package/lib/select2.module.d.ts.map +1 -0
  31. package/ng-select2-component.d.ts.map +1 -0
  32. package/package.json +26 -14
  33. package/public_api.d.ts +1 -0
  34. package/public_api.d.ts.map +1 -0
  35. package/bundles/ng-select2-component.umd.js +0 -2587
  36. package/bundles/ng-select2-component.umd.js.map +0 -1
  37. package/bundles/ng-select2-component.umd.min.js +0 -2
  38. package/bundles/ng-select2-component.umd.min.js.map +0 -1
  39. package/esm2015/lib/select2-const.js +0 -57
  40. package/esm2015/lib/select2-hint.component.js +0 -12
  41. package/esm2015/lib/select2-interfaces.js +0 -134
  42. package/esm2015/lib/select2-label.component.js +0 -12
  43. package/esm2015/lib/select2-utils.js +0 -388
  44. package/esm2015/lib/select2.component.js +0 -1500
  45. package/esm2015/lib/select2.module.js +0 -23
  46. package/esm2015/ng-select2-component.js +0 -10
  47. package/esm2015/public_api.js +0 -17
  48. package/fesm2015/ng-select2-component.js +0 -2130
  49. package/fesm2015/ng-select2-component.js.map +0 -1
  50. package/ng-select2-component.d.ts +0 -4
  51. package/ng-select2-component.metadata.json +0 -1
@@ -1,2130 +0,0 @@
1
- import { CdkConnectedOverlay, OverlayModule } from '@angular/cdk/overlay';
2
- import { ViewportRuler } from '@angular/cdk/scrolling';
3
- import { EventEmitter, TemplateRef, Component, ChangeDetectorRef, Optional, Self, Attribute, Input, Output, HostBinding, ViewChild, ViewChildren, Directive, NgModule } from '@angular/core';
4
- import { NgForm, FormGroupDirective, NgControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
- import { Subject } from 'rxjs';
6
- import { CommonModule } from '@angular/common';
7
- import { InfiniteScrollModule } from 'ngx-infinite-scroll';
8
-
9
- /**
10
- * @fileoverview added by tsickle
11
- * Generated from: lib/select2-interfaces.ts
12
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
13
- */
14
- /**
15
- * @record
16
- */
17
- function Select2Group() { }
18
- if (false) {
19
- /**
20
- * label of group
21
- * @type {?}
22
- */
23
- Select2Group.prototype.label;
24
- /**
25
- * options list
26
- * @type {?}
27
- */
28
- Select2Group.prototype.options;
29
- /**
30
- * add classes
31
- * @type {?|undefined}
32
- */
33
- Select2Group.prototype.classes;
34
- /**
35
- * template id
36
- * @type {?|undefined}
37
- */
38
- Select2Group.prototype.templateId;
39
- /**
40
- * template data
41
- * @type {?|undefined}
42
- */
43
- Select2Group.prototype.data;
44
- }
45
- /**
46
- * @record
47
- */
48
- function Select2Option() { }
49
- if (false) {
50
- /**
51
- * value
52
- * @type {?}
53
- */
54
- Select2Option.prototype.value;
55
- /**
56
- * label of option
57
- * @type {?}
58
- */
59
- Select2Option.prototype.label;
60
- /**
61
- * no selectable is disabled
62
- * @type {?|undefined}
63
- */
64
- Select2Option.prototype.disabled;
65
- /**
66
- * for identification
67
- * @type {?|undefined}
68
- */
69
- Select2Option.prototype.id;
70
- /**
71
- * add classes
72
- * @type {?|undefined}
73
- */
74
- Select2Option.prototype.classes;
75
- /**
76
- * template id
77
- * @type {?|undefined}
78
- */
79
- Select2Option.prototype.templateId;
80
- /**
81
- * template data
82
- * @type {?|undefined}
83
- */
84
- Select2Option.prototype.data;
85
- /**
86
- * hide this option
87
- * @type {?|undefined}
88
- */
89
- Select2Option.prototype.hide;
90
- }
91
- /**
92
- * @record
93
- * @template U
94
- */
95
- function Select2UpdateEvent() { }
96
- if (false) {
97
- /** @type {?} */
98
- Select2UpdateEvent.prototype.component;
99
- /** @type {?} */
100
- Select2UpdateEvent.prototype.value;
101
- /** @type {?} */
102
- Select2UpdateEvent.prototype.options;
103
- }
104
- /**
105
- * @record
106
- * @template U
107
- */
108
- function Select2SearchEvent() { }
109
- if (false) {
110
- /** @type {?} */
111
- Select2SearchEvent.prototype.component;
112
- /** @type {?} */
113
- Select2SearchEvent.prototype.value;
114
- /** @type {?} */
115
- Select2SearchEvent.prototype.search;
116
- }
117
- /**
118
- * @record
119
- * @template U
120
- */
121
- function Select2RemoveEvent() { }
122
- if (false) {
123
- /** @type {?} */
124
- Select2RemoveEvent.prototype.component;
125
- /** @type {?} */
126
- Select2RemoveEvent.prototype.value;
127
- /** @type {?} */
128
- Select2RemoveEvent.prototype.removedOption;
129
- }
130
- /**
131
- * @record
132
- */
133
- function Select2ScrollEvent() { }
134
- if (false) {
135
- /** @type {?} */
136
- Select2ScrollEvent.prototype.component;
137
- /** @type {?} */
138
- Select2ScrollEvent.prototype.way;
139
- /** @type {?} */
140
- Select2ScrollEvent.prototype.search;
141
- }
142
-
143
- /**
144
- * @fileoverview added by tsickle
145
- * Generated from: lib/select2-const.ts
146
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
147
- */
148
- /** @type {?} */
149
- const timeout = 200;
150
- /** @type {?} */
151
- const unicodePatterns = [
152
- { l: 'a', s: /[ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ]/gi },
153
- { l: 'aa', s: /ꜳ/gi },
154
- { l: 'ae', s: /[æǽǣ]/gi },
155
- { l: 'ao', s: /ꜵ/gi },
156
- { l: 'au', s: /ꜷ/gi },
157
- { l: 'av', s: /[ꜹꜻ]/gi },
158
- { l: 'ay', s: /ꜽ/gi },
159
- { l: 'b', s: /[ⓑbḃḅḇƀƃɓ]/gi },
160
- { l: 'c', s: /[ⓒcćĉċčçḉƈȼꜿↄ]/gi },
161
- { l: 'd', s: /[ⓓdḋďḍḑḓḏđƌɖɗꝺ]/gi },
162
- { l: 'dz', s: /[dzdž]/gi },
163
- { l: 'e', s: /[ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ]/gi },
164
- { l: 'f', s: /[ⓕfḟƒꝼ]/gi },
165
- { l: 'g', s: /[ⓖgǵĝḡğġǧģǥɠꞡᵹꝿ]/gi },
166
- { l: 'h', s: /[ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ]/gi },
167
- { l: 'hv', s: /ƕ/gi },
168
- { l: 'i', s: /[ⓘiìíîĩīĭİïḯỉǐȉȋịįḭɨı]/gi },
169
- { l: 'j', s: /[ⓙjĵǰɉ]/gi },
170
- { l: 'k', s: /[ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ]/gi },
171
- { l: 'l', s: /[ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇꝆ]/gi },
172
- { l: 'lj', s: /lj/gi },
173
- { l: 'm', s: /[ⓜmḿṁṃɱɯ]/gi },
174
- { l: 'n', s: /[ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ]/gi },
175
- { l: 'nj', s: /nj/gi },
176
- { l: 'o', s: /[ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔƟꝋꝍɵ]/gi },
177
- { l: 'oi', s: /ƣ/gi },
178
- { l: 'oe', s: /œ/gi },
179
- { l: 'oo', s: /ꝏ/gi },
180
- { l: 'ou', s: /ȣ/gi },
181
- { l: 'p', s: /[ⓟpṕṗƥᵽꝑꝓꝕ]/gi },
182
- { l: 'q', s: /[ⓠqɋꝗꝙ]/gi },
183
- { l: 'r', s: /[ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ]/gi },
184
- { l: 's', s: /[ⓢsßẞśṥŝṡšṧṣṩșşȿꞩꞅẛ]/gi },
185
- { l: 't', s: /[ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ]/gi },
186
- { l: 'tz', s: /ꜩ/gi },
187
- { l: 'u', s: /[ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ]/gi },
188
- { l: 'v', s: /[ⓥvṽṿʋꝟʌ]/gi },
189
- { l: 'vy', s: /ꝡ/gi },
190
- { l: 'w', s: /[ⓦwẁẃŵẇẅẘẉⱳ]/gi },
191
- { l: 'x', s: /[ⓧxẋẍ]/gi },
192
- { l: 'y', s: /[ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ]/gi },
193
- { l: 'z', s: /[ⓩzźẑżžẓẕƶȥɀⱬꝣ]/gi },
194
- ];
195
- /** @type {?} */
196
- const defaultMinCountForSearch = 6;
197
- /** @type {?} */
198
- const protectRegexp = new RegExp('[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]', 'g');
199
-
200
- /**
201
- * @fileoverview added by tsickle
202
- * Generated from: lib/select2-utils.ts
203
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
204
- */
205
- class Select2Utils {
206
- /**
207
- * @param {?} data
208
- * @param {?} value
209
- * @return {?}
210
- */
211
- static getOptionByValue(data, value) {
212
- if (Array.isArray(data)) {
213
- for (const groupOrOption of data) {
214
- /** @type {?} */
215
- const options = ((/** @type {?} */ (groupOrOption))).options;
216
- if (options) {
217
- for (const option of options) {
218
- if (option.value === value) {
219
- return option;
220
- }
221
- }
222
- }
223
- else {
224
- if (((/** @type {?} */ (groupOrOption))).value === value) {
225
- return (/** @type {?} */ (groupOrOption));
226
- }
227
- }
228
- }
229
- }
230
- return null;
231
- }
232
- /**
233
- * @param {?} data
234
- * @param {?} value
235
- * @param {?} multiple
236
- * @return {?}
237
- */
238
- static getOptionsByValue(data, value, multiple) {
239
- if (multiple) {
240
- /** @type {?} */
241
- const values = Array.isArray(value) ? value : [];
242
- /** @type {?} */
243
- const result = [];
244
- for (const v of values) {
245
- /** @type {?} */
246
- const option = Select2Utils.getOptionByValue(data, v);
247
- if (option) {
248
- result.push(option);
249
- }
250
- }
251
- return result;
252
- }
253
- return Select2Utils.getOptionByValue(data, (/** @type {?} */ (value)));
254
- }
255
- /**
256
- * @param {?} data
257
- * @return {?}
258
- */
259
- static getFirstAvailableOption(data) {
260
- if (Array.isArray(data)) {
261
- for (const groupOrOption of data) {
262
- /** @type {?} */
263
- const options = ((/** @type {?} */ (groupOrOption))).options;
264
- if (options) {
265
- for (const option of options) {
266
- if (!option.disabled) {
267
- return option.value;
268
- }
269
- }
270
- }
271
- else {
272
- /** @type {?} */
273
- const option = (/** @type {?} */ (groupOrOption));
274
- if (!option.disabled) {
275
- return option.value;
276
- }
277
- }
278
- }
279
- }
280
- return null;
281
- }
282
- /**
283
- * @private
284
- * @param {?} data
285
- * @return {?}
286
- */
287
- static getOptionsCount(data) {
288
- /** @type {?} */
289
- let count = 0;
290
- if (Array.isArray(data)) {
291
- for (const groupOrOption of data) {
292
- /** @type {?} */
293
- const options = ((/** @type {?} */ (groupOrOption))).options;
294
- if (options) {
295
- count += options.length;
296
- }
297
- else {
298
- count++;
299
- }
300
- }
301
- }
302
- return count;
303
- }
304
- /**
305
- * @param {?} filteredData
306
- * @param {?} value
307
- * @return {?}
308
- */
309
- static valueIsNotInFilteredData(filteredData, value) {
310
- if (Select2Utils.isNullOrUndefined(value)) {
311
- return true;
312
- }
313
- for (const groupOrOption of filteredData) {
314
- /** @type {?} */
315
- const options = ((/** @type {?} */ (groupOrOption))).options;
316
- if (options) {
317
- for (const option of options) {
318
- if (option.value === value) {
319
- return false;
320
- }
321
- }
322
- }
323
- else {
324
- if (((/** @type {?} */ (groupOrOption))).value === value) {
325
- return false;
326
- }
327
- }
328
- }
329
- return true;
330
- }
331
- // tslint:disable-next-line:cognitive-complexity
332
- /**
333
- * @param {?} filteredData
334
- * @param {?} hoveringValue
335
- * @return {?}
336
- */
337
- static getPreviousOption(filteredData, hoveringValue) {
338
- /** @type {?} */
339
- let findIt = Select2Utils.isNullOrUndefined(hoveringValue);
340
- for (let i = filteredData.length - 1; i >= 0; i--) {
341
- /** @type {?} */
342
- const groupOrOption = filteredData[i];
343
- /** @type {?} */
344
- const options = ((/** @type {?} */ (groupOrOption))).options;
345
- if (options) {
346
- for (let j = options.length - 1; j >= 0; j--) {
347
- /** @type {?} */
348
- const option = options[j];
349
- if (findIt) {
350
- if (!option.disabled && !option.hide) {
351
- return option;
352
- }
353
- }
354
- if (!findIt) {
355
- findIt = option.value === hoveringValue;
356
- }
357
- }
358
- }
359
- else {
360
- /** @type {?} */
361
- const option = (/** @type {?} */ (groupOrOption));
362
- if (findIt) {
363
- if (!option.disabled && !option.hide) {
364
- return option;
365
- }
366
- }
367
- if (!findIt) {
368
- findIt = option.value === hoveringValue;
369
- }
370
- }
371
- }
372
- return null;
373
- }
374
- // tslint:disable-next-line:cognitive-complexity
375
- /**
376
- * @param {?} filteredData
377
- * @param {?} hoveringValue
378
- * @return {?}
379
- */
380
- static getNextOption(filteredData, hoveringValue) {
381
- /** @type {?} */
382
- let findIt = Select2Utils.isNullOrUndefined(hoveringValue);
383
- for (const groupOrOption of filteredData) {
384
- /** @type {?} */
385
- const options = ((/** @type {?} */ (groupOrOption))).options;
386
- if (options) {
387
- for (const option of options) {
388
- if (findIt) {
389
- if (!option.disabled && !option.hide) {
390
- return option;
391
- }
392
- }
393
- else if (!findIt) {
394
- findIt = option.value === hoveringValue;
395
- }
396
- }
397
- }
398
- else {
399
- /** @type {?} */
400
- const option = (/** @type {?} */ (groupOrOption));
401
- if (findIt) {
402
- if (!option.disabled && !option.hide) {
403
- return option;
404
- }
405
- }
406
- else if (!findIt) {
407
- findIt = option.value === hoveringValue;
408
- }
409
- }
410
- }
411
- return null;
412
- }
413
- /**
414
- * @private
415
- * @param {?} value
416
- * @return {?}
417
- */
418
- static isNullOrUndefined(value) {
419
- return value === null || value === undefined;
420
- }
421
- /**
422
- * @private
423
- * @param {?} label
424
- * @param {?} searchText
425
- * @param {?} editPattern
426
- * @return {?}
427
- */
428
- static containSearchText(label, searchText, editPattern) {
429
- return searchText
430
- ? Select2Utils.formatSansUnicode(label).match(new RegExp(Select2Utils.formatPattern(searchText, editPattern), 'i')) !== null
431
- : true;
432
- }
433
- /**
434
- * @private
435
- * @param {?} str
436
- * @return {?}
437
- */
438
- static protectPattern(str) {
439
- return str.replace(protectRegexp, '\\$&');
440
- }
441
- /**
442
- * @private
443
- * @param {?} str
444
- * @return {?}
445
- */
446
- static formatSansUnicode(str) {
447
- for (const unicodePattern of unicodePatterns) {
448
- str = str.replace(unicodePattern.s, unicodePattern.l);
449
- }
450
- return str;
451
- }
452
- /**
453
- * @private
454
- * @param {?} str
455
- * @param {?} editPattern
456
- * @return {?}
457
- */
458
- static formatPattern(str, editPattern) {
459
- str = Select2Utils.formatSansUnicode(Select2Utils.protectPattern(str));
460
- if (editPattern && typeof editPattern === 'function') {
461
- str = editPattern(str);
462
- }
463
- return str;
464
- }
465
- /**
466
- * @param {?} data
467
- * @param {?} searchText
468
- * @param {?=} editPattern
469
- * @return {?}
470
- */
471
- static getFilteredData(data, searchText, editPattern) {
472
- if (searchText) {
473
- /** @type {?} */
474
- const result = [];
475
- for (const groupOrOption of data) {
476
- /** @type {?} */
477
- const options = ((/** @type {?} */ (groupOrOption))).options;
478
- if (options) {
479
- if (options.some((/**
480
- * @param {?} group
481
- * @return {?}
482
- */
483
- group => Select2Utils.containSearchText(group.label, searchText, editPattern)))) {
484
- /** @type {?} */
485
- const filteredOptions = options.filter((/**
486
- * @param {?} group
487
- * @return {?}
488
- */
489
- group => Select2Utils.containSearchText(group.label, searchText, editPattern)));
490
- result.push({
491
- label: groupOrOption.label,
492
- options: filteredOptions,
493
- });
494
- }
495
- }
496
- else if (Select2Utils.containSearchText(groupOrOption.label, searchText, editPattern)) {
497
- result.push(groupOrOption);
498
- }
499
- }
500
- return result;
501
- }
502
- else {
503
- return data;
504
- }
505
- }
506
- /**
507
- * @param {?} data
508
- * @param {?} selectedOptions
509
- * @return {?}
510
- */
511
- static getFilteredSelectedData(data, selectedOptions) {
512
- /** @type {?} */
513
- const result = [];
514
- for (const groupOrOption of data) {
515
- /** @type {?} */
516
- const options = ((/** @type {?} */ (groupOrOption))).options;
517
- if (options) {
518
- /** @type {?} */
519
- const filteredOptions = options.filter((/**
520
- * @param {?} group
521
- * @return {?}
522
- */
523
- group => Select2Utils.isSelected(selectedOptions, group, true) === 'false'));
524
- if (filteredOptions.length) {
525
- result.push({
526
- label: groupOrOption.label,
527
- options: filteredOptions,
528
- });
529
- }
530
- }
531
- else if (Select2Utils.isSelected(selectedOptions, (/** @type {?} */ (groupOrOption)), true) === 'false') {
532
- result.push(groupOrOption);
533
- }
534
- }
535
- return result;
536
- }
537
- /**
538
- * @param {?} data
539
- * @param {?=} minCountForSearch
540
- * @return {?}
541
- */
542
- static isSearchboxHiddex(data, minCountForSearch) {
543
- if (minCountForSearch === '' ||
544
- minCountForSearch === undefined ||
545
- minCountForSearch === null ||
546
- isNaN(+minCountForSearch)) {
547
- minCountForSearch = defaultMinCountForSearch;
548
- }
549
- /** @type {?} */
550
- const optionCount = Select2Utils.getOptionsCount(data);
551
- return optionCount < +minCountForSearch;
552
- }
553
- /**
554
- * @param {?} options
555
- * @param {?} option
556
- * @param {?} multiple
557
- * @return {?}
558
- */
559
- static isSelected(options, option, multiple) {
560
- return multiple
561
- ? options && ((/** @type {?} */ (options))).some((/**
562
- * @param {?} op
563
- * @return {?}
564
- */
565
- op => op.value === option.value))
566
- ? 'true'
567
- : 'false'
568
- : options && option.value === ((/** @type {?} */ (options))).value
569
- ? 'true'
570
- : 'false';
571
- }
572
- /**
573
- * @param {?} options
574
- * @param {?} option
575
- * @return {?}
576
- */
577
- static removeSelection(options, option) {
578
- for (let i = 0; i < ((/** @type {?} */ (options))).length; i++) {
579
- if (((/** @type {?} */ (options)))[i].value === option.value) {
580
- ((/** @type {?} */ (options))).splice(i, 1);
581
- return;
582
- }
583
- }
584
- }
585
- }
586
-
587
- /**
588
- * @fileoverview added by tsickle
589
- * Generated from: lib/select2.component.ts
590
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
591
- */
592
- /** @type {?} */
593
- let nextUniqueId = 0;
594
- /** @type {?} */
595
- const displaySearchStatusList = ['default', 'hidden', 'always'];
596
- class Select2 {
597
- /**
598
- * @param {?} _viewportRuler
599
- * @param {?} _changeDetectorRef
600
- * @param {?} _parentForm
601
- * @param {?} _parentFormGroup
602
- * @param {?} _control
603
- * @param {?} tabIndex
604
- */
605
- constructor(_viewportRuler, _changeDetectorRef, _parentForm, _parentFormGroup, _control, tabIndex) {
606
- this._viewportRuler = _viewportRuler;
607
- this._changeDetectorRef = _changeDetectorRef;
608
- this._parentForm = _parentForm;
609
- this._parentFormGroup = _parentFormGroup;
610
- this._control = _control;
611
- this.minCharForSearch = 0;
612
- this.limitSelection = 0;
613
- this.listPosition = 'below';
614
- /**
615
- * use the material style
616
- */
617
- this.styleMode = 'default';
618
- /**
619
- * infinite scroll distance
620
- */
621
- this.infiniteScrollDistance = 1.5;
622
- /**
623
- * infinite scroll distance
624
- */
625
- this.infiniteScrollThrottle = 150;
626
- /**
627
- * the max height of the results container when opening the select
628
- */
629
- this.resultMaxHeight = '200px';
630
- this.update = new EventEmitter();
631
- this.open = new EventEmitter();
632
- this.close = new EventEmitter();
633
- this.focus = new EventEmitter();
634
- this.blur = new EventEmitter();
635
- this.search = new EventEmitter();
636
- this.scroll = new EventEmitter();
637
- this.removeOption = new EventEmitter();
638
- this.option = null;
639
- this.isOpen = false;
640
- /**
641
- * Whether the element is focused or not.
642
- */
643
- this.focused = false;
644
- this.hoveringValue = null;
645
- this.innerSearchText = '';
646
- this._stateChanges = new Subject();
647
- this._disabled = false;
648
- this._required = false;
649
- this._readonly = false;
650
- this._multiple = false;
651
- this._overlay = false;
652
- this._resettable = false;
653
- this._hideSelectedItems = false;
654
- this._clickDetection = false;
655
- this._uid = `select2-${nextUniqueId++}`;
656
- this._infiniteScroll = true;
657
- /**
658
- * View -> model callback called when select has been touched
659
- */
660
- this._onTouched = (/**
661
- * @return {?}
662
- */
663
- () => {
664
- // do nothing
665
- });
666
- /**
667
- * View -> model callback called when value changes
668
- */
669
- this._onChange = (/**
670
- * @return {?}
671
- */
672
- () => {
673
- // do nothing
674
- });
675
- this.id = this.id;
676
- this._tabIndex = parseInt(tabIndex, 10) || 0;
677
- if (this._control) {
678
- this._control.valueAccessor = this;
679
- }
680
- this._clickDetectionFc = this.clickDetection.bind(this);
681
- }
682
- /**
683
- * data of options & optiongrps
684
- * @param {?} data
685
- * @return {?}
686
- */
687
- set data(data) {
688
- this._data = data;
689
- this.updateFilteredData();
690
- }
691
- /**
692
- * @return {?}
693
- */
694
- get multiple() {
695
- return this._multiple;
696
- }
697
- /**
698
- * @param {?} value
699
- * @return {?}
700
- */
701
- set multiple(value) {
702
- this._multiple = this._coerceBooleanProperty(value);
703
- this.ngOnInit();
704
- }
705
- /**
706
- * use the material style
707
- * @return {?}
708
- */
709
- get overlay() {
710
- return this._overlay;
711
- }
712
- /**
713
- * @param {?} value
714
- * @return {?}
715
- */
716
- set overlay(value) {
717
- this._overlay = this._coerceBooleanProperty(value);
718
- }
719
- /**
720
- * infinite scroll activated
721
- * @return {?}
722
- */
723
- get infiniteScroll() {
724
- return this._infiniteScroll;
725
- }
726
- /**
727
- * @param {?} value
728
- * @return {?}
729
- */
730
- set infiniteScroll(value) {
731
- this._infiniteScroll = this._coerceBooleanProperty(value);
732
- }
733
- /**
734
- * @return {?}
735
- */
736
- get select2Options() {
737
- return this.multiple ? ((/** @type {?} */ (this.option))) : null;
738
- }
739
- /**
740
- * @return {?}
741
- */
742
- get select2Option() {
743
- return this.multiple ? null : ((/** @type {?} */ (this.option)));
744
- }
745
- /**
746
- * @return {?}
747
- */
748
- get searchText() {
749
- return this.innerSearchText;
750
- }
751
- /**
752
- * @param {?} text
753
- * @return {?}
754
- */
755
- set searchText(text) {
756
- if (this.customSearchEnabled) {
757
- this.search.emit({
758
- component: this,
759
- value: this._value,
760
- search: text,
761
- });
762
- }
763
- this.innerSearchText = text;
764
- }
765
- /**
766
- * minimal data of show the search field
767
- * @return {?}
768
- */
769
- get minCountForSearch() {
770
- return this._minCountForSearch;
771
- }
772
- /**
773
- * @param {?} value
774
- * @return {?}
775
- */
776
- set minCountForSearch(value) {
777
- this._minCountForSearch = value;
778
- this.updateSearchBox();
779
- }
780
- /**
781
- * Unique id of the element.
782
- * @return {?}
783
- */
784
- get id() {
785
- return this._id;
786
- }
787
- /**
788
- * @param {?} value
789
- * @return {?}
790
- */
791
- set id(value) {
792
- this._id = value || this._uid;
793
- }
794
- /**
795
- * Whether the element is required.
796
- * @return {?}
797
- */
798
- get required() {
799
- return this._required;
800
- }
801
- /**
802
- * @param {?} value
803
- * @return {?}
804
- */
805
- set required(value) {
806
- this._required = this._coerceBooleanProperty(value);
807
- }
808
- /**
809
- * Whether selected items should be hidden.
810
- * @return {?}
811
- */
812
- get disabled() {
813
- return this._control ? this._control.disabled : this._disabled;
814
- }
815
- /**
816
- * @param {?} value
817
- * @return {?}
818
- */
819
- set disabled(value) {
820
- this._disabled = this._coerceBooleanProperty(value);
821
- }
822
- /**
823
- * Whether items are hidden when has.
824
- * @return {?}
825
- */
826
- get hideSelectedItems() {
827
- return this._hideSelectedItems;
828
- }
829
- /**
830
- * @param {?} value
831
- * @return {?}
832
- */
833
- set hideSelectedItems(value) {
834
- this._hideSelectedItems = this._coerceBooleanProperty(value);
835
- }
836
- /**
837
- * Whether the element is readonly.
838
- * @return {?}
839
- */
840
- get readonly() {
841
- return this._readonly;
842
- }
843
- /**
844
- * @param {?} value
845
- * @return {?}
846
- */
847
- set readonly(value) {
848
- this._readonly = this._coerceBooleanProperty(value);
849
- }
850
- /**
851
- * The input element's value.
852
- * @return {?}
853
- */
854
- get value() {
855
- return this._value;
856
- }
857
- /**
858
- * @param {?} value
859
- * @return {?}
860
- */
861
- set value(value) {
862
- if (this.testValueChange(this._value, value)) {
863
- setTimeout((/**
864
- * @return {?}
865
- */
866
- () => {
867
- this._value = value;
868
- this.writeValue(value);
869
- }), 10);
870
- }
871
- }
872
- /**
873
- * Tab index for the select2 element.
874
- * @return {?}
875
- */
876
- get tabIndex() {
877
- return this.disabled ? -1 : this._tabIndex;
878
- }
879
- /**
880
- * @param {?} value
881
- * @return {?}
882
- */
883
- set tabIndex(value) {
884
- if (typeof value !== 'undefined') {
885
- this._tabIndex = value;
886
- }
887
- }
888
- /**
889
- * reset with no selected value
890
- * @return {?}
891
- */
892
- get resettable() {
893
- return this._resettable;
894
- }
895
- /**
896
- * @param {?} value
897
- * @return {?}
898
- */
899
- set resettable(value) {
900
- this._resettable = this._coerceBooleanProperty(value);
901
- }
902
- /**
903
- * @return {?}
904
- */
905
- get ariaInvalid() {
906
- return this._isErrorState();
907
- }
908
- /**
909
- * @return {?}
910
- */
911
- get classMaterial() {
912
- return this.styleMode === 'material';
913
- }
914
- /**
915
- * @return {?}
916
- */
917
- get classNostyle() {
918
- return this.styleMode === 'noStyle';
919
- }
920
- /**
921
- * @return {?}
922
- */
923
- get select2above() {
924
- return !this.overlay ? this.listPosition === 'above' : this._isAbobeOverlay();
925
- }
926
- /**
927
- * @return {?}
928
- */
929
- get _positions() {
930
- if (this.listPosition === 'auto') {
931
- [
932
- {
933
- originX: 'start',
934
- originY: 'bottom',
935
- overlayX: 'start',
936
- overlayY: 'bottom',
937
- },
938
- {
939
- originX: 'start',
940
- originY: 'top',
941
- overlayX: 'start',
942
- overlayY: 'top',
943
- },
944
- ];
945
- }
946
- else {
947
- return null;
948
- }
949
- }
950
- /**
951
- * @private
952
- * @return {?}
953
- */
954
- get resultsElement() {
955
- var _a;
956
- return (_a = this.resultContainer) === null || _a === void 0 ? void 0 : _a.nativeElement;
957
- }
958
- /**
959
- * @return {?}
960
- */
961
- ngOnInit() {
962
- this._viewportRuler.change(100).subscribe((/**
963
- * @return {?}
964
- */
965
- () => {
966
- if (this.isOpen) {
967
- this.triggerRect();
968
- }
969
- }));
970
- /** @type {?} */
971
- const option = Select2Utils.getOptionsByValue(this._data, this._control ? this._control.value : this.value, this.multiple);
972
- if (option !== null) {
973
- this.option = option;
974
- }
975
- if (!Array.isArray(option)) {
976
- this.hoveringValue = (/** @type {?} */ (this.value));
977
- }
978
- this.updateSearchBox();
979
- }
980
- /**
981
- * @return {?}
982
- */
983
- ngAfterViewInit() {
984
- this.cdkConnectedOverlay.positionChange.subscribe((/**
985
- * @param {?} posChange
986
- * @return {?}
987
- */
988
- (posChange) => {
989
- var _a;
990
- if (this.listPosition === 'auto' && ((_a = posChange.connectionPair) === null || _a === void 0 ? void 0 : _a.originY) &&
991
- this._overlayPosition !== posChange.connectionPair.originY) {
992
- this.triggerRect();
993
- this._overlayPosition = posChange.connectionPair.originY;
994
- this._changeDetectorRef.detectChanges();
995
- }
996
- }));
997
- this.selectionElement = this.selection.nativeElement;
998
- this.triggerRect();
999
- }
1000
- /**
1001
- * @return {?}
1002
- */
1003
- ngDoCheck() {
1004
- var _a;
1005
- this.updateSearchBox();
1006
- this._dirtyCheckNativeValue();
1007
- if (this._triggerRect) {
1008
- if (this.overlayWidth !== this._triggerRect.width) {
1009
- this.overlayWidth = this._triggerRect.width;
1010
- }
1011
- if (((_a = this._dropdownRect) === null || _a === void 0 ? void 0 : _a.height) > 0 && this.overlayHeight !== this._dropdownRect.height) {
1012
- this.overlayHeight = this.listPosition === 'auto' ? this._dropdownRect.height : 0;
1013
- }
1014
- }
1015
- }
1016
- /**
1017
- * @return {?}
1018
- */
1019
- ngOnDestroy() {
1020
- window.document.body.removeEventListener('click', this._clickDetectionFc);
1021
- }
1022
- /**
1023
- * @return {?}
1024
- */
1025
- updateSearchBox() {
1026
- /** @type {?} */
1027
- const hidden = this.customSearchEnabled
1028
- ? false
1029
- : Select2Utils.isSearchboxHiddex(this._data, this._minCountForSearch);
1030
- if (this.isSearchboxHidden !== hidden) {
1031
- this.isSearchboxHidden = hidden;
1032
- }
1033
- }
1034
- /**
1035
- * @return {?}
1036
- */
1037
- hideSearch() {
1038
- /** @type {?} */
1039
- const displaySearchStatus = displaySearchStatusList.indexOf(this.displaySearchStatus) > -1 ? this.displaySearchStatus : 'default';
1040
- return (displaySearchStatus === 'default' && this.isSearchboxHidden) || displaySearchStatus === 'hidden';
1041
- }
1042
- /**
1043
- * @param {?} option
1044
- * @return {?}
1045
- */
1046
- getOptionStyle(option) {
1047
- return ('select2-results__option ' +
1048
- (option.hide ? 'select2-results__option--hide ' : '') +
1049
- (option.value === this.hoveringValue ? 'select2-results__option--highlighted ' : '') +
1050
- (option.classes || ''));
1051
- }
1052
- /**
1053
- * @param {?} option
1054
- * @return {?}
1055
- */
1056
- mouseenter(option) {
1057
- if (!option.disabled) {
1058
- this.hoveringValue = option.value;
1059
- }
1060
- }
1061
- /**
1062
- * @param {?} option
1063
- * @return {?}
1064
- */
1065
- click(option) {
1066
- if (this.testSelection(option)) {
1067
- this.select(option);
1068
- }
1069
- }
1070
- /**
1071
- * @param {?} e
1072
- * @return {?}
1073
- */
1074
- reset(e) {
1075
- this.select(null);
1076
- e.preventDefault();
1077
- e.stopPropagation();
1078
- }
1079
- /**
1080
- * @param {?} event
1081
- * @return {?}
1082
- */
1083
- prevChange(event) {
1084
- event.stopPropagation();
1085
- }
1086
- /**
1087
- * @return {?}
1088
- */
1089
- toggleOpenAndClose() {
1090
- if (this.disabled) {
1091
- return;
1092
- }
1093
- this._focus(true);
1094
- this.isOpen = !this.isOpen;
1095
- if (this.isOpen) {
1096
- this.innerSearchText = '';
1097
- this.updateFilteredData();
1098
- this._focusSearchboxOrResultsElement();
1099
- setTimeout((/**
1100
- * @return {?}
1101
- */
1102
- () => {
1103
- if (this.option) {
1104
- /** @type {?} */
1105
- const option = this.option instanceof Array ? this.option[0] : this.option;
1106
- this.updateScrollFromOption(option);
1107
- }
1108
- else if (this.resultsElement) {
1109
- this.resultsElement.scrollTop = 0;
1110
- }
1111
- setTimeout((/**
1112
- * @return {?}
1113
- */
1114
- () => {
1115
- var _a, _b;
1116
- this.triggerRect();
1117
- (_b = (_a = this.cdkConnectedOverlay) === null || _a === void 0 ? void 0 : _a.overlayRef) === null || _b === void 0 ? void 0 : _b.updatePosition();
1118
- }), 100);
1119
- }));
1120
- this.open.emit(this);
1121
- }
1122
- else {
1123
- this.close.emit(this);
1124
- }
1125
- if (this.isOpen && !this._clickDetection) {
1126
- setTimeout((/**
1127
- * @return {?}
1128
- */
1129
- () => {
1130
- window.document.body.addEventListener('click', this._clickDetectionFc, false);
1131
- this._clickDetection = true;
1132
- }), timeout);
1133
- }
1134
- this._changeDetectorRef.markForCheck();
1135
- }
1136
- /**
1137
- * @param {?} option
1138
- * @param {?} defaut
1139
- * @return {?}
1140
- */
1141
- hasTemplate(option, defaut) {
1142
- var _a, _b;
1143
- return (this.templates instanceof TemplateRef ||
1144
- ((_a = this.templates) === null || _a === void 0 ? void 0 : _a[option.templateId]) instanceof TemplateRef ||
1145
- ((_b = this.templates) === null || _b === void 0 ? void 0 : _b[defaut]) instanceof TemplateRef);
1146
- }
1147
- /**
1148
- * @param {?} option
1149
- * @param {?} defaut
1150
- * @return {?}
1151
- */
1152
- getTemplate(option, defaut) {
1153
- return this.hasTemplate(option, defaut)
1154
- ? this.templates[option.templateId] || this.templates[defaut] || this.templates
1155
- : undefined;
1156
- }
1157
- /**
1158
- * @return {?}
1159
- */
1160
- triggerRect() {
1161
- var _a;
1162
- this._triggerRect = this.selectionElement.getBoundingClientRect();
1163
- this._dropdownRect = ((_a = this.dropdown) === null || _a === void 0 ? void 0 : _a.nativeElement) ? this.dropdown.nativeElement.getBoundingClientRect()
1164
- : undefined;
1165
- }
1166
- /**
1167
- * @private
1168
- * @param {?} option
1169
- * @return {?}
1170
- */
1171
- testSelection(option) {
1172
- if (option.disabled) {
1173
- return false;
1174
- }
1175
- if (!this.multiple ||
1176
- !this.limitSelection ||
1177
- (Array.isArray(this._value) && this._value.length < this.limitSelection)) {
1178
- return true;
1179
- }
1180
- return false;
1181
- }
1182
- /**
1183
- * @private
1184
- * @param {?} value1
1185
- * @param {?} value2
1186
- * @return {?}
1187
- */
1188
- testValueChange(value1, value2) {
1189
- var _a, _b;
1190
- if (((value1 === null || value1 === undefined) && (value2 === null || value2 === undefined)) ||
1191
- value1 === value2) {
1192
- return false;
1193
- }
1194
- if (this.multiple && ((_a = ((/** @type {?} */ (value1)))) === null || _a === void 0 ? void 0 : _a.length) && ((_b = ((/** @type {?} */ (value2)))) === null || _b === void 0 ? void 0 : _b.length) &&
1195
- ((/** @type {?} */ (value1))).length === ((/** @type {?} */ (value2))).length) {
1196
- for (const e1 of (/** @type {?} */ (value1))) {
1197
- /** @type {?} */
1198
- const test = ((/** @type {?} */ (value2))).indexOf(e1) > -1;
1199
- if (!test) {
1200
- return true;
1201
- }
1202
- }
1203
- return false;
1204
- }
1205
- return true;
1206
- }
1207
- /**
1208
- * @private
1209
- * @return {?}
1210
- */
1211
- updateFilteredData() {
1212
- setTimeout((/**
1213
- * @return {?}
1214
- */
1215
- () => {
1216
- /** @type {?} */
1217
- let result = this._data;
1218
- if (this.multiple && this.hideSelectedItems) {
1219
- result = Select2Utils.getFilteredSelectedData(result, this.option);
1220
- }
1221
- if (!this.customSearchEnabled && this.searchText && this.searchText.length >= +this.minCharForSearch) {
1222
- result = Select2Utils.getFilteredData(result, this.searchText, this.editPattern);
1223
- }
1224
- if (Select2Utils.valueIsNotInFilteredData(result, this.hoveringValue)) {
1225
- this.hoveringValue = Select2Utils.getFirstAvailableOption(result);
1226
- }
1227
- this.filteredData = result;
1228
- this._changeDetectorRef.markForCheck();
1229
- }));
1230
- }
1231
- /**
1232
- * @private
1233
- * @param {?} e
1234
- * @return {?}
1235
- */
1236
- clickDetection(e) {
1237
- if (!this.ifParentContainsClass((/** @type {?} */ (e.target)), 'selection')) {
1238
- if (this.isOpen && !this.ifParentContainsClass((/** @type {?} */ (e.target)), 'select2-dropdown')) {
1239
- this.toggleOpenAndClose();
1240
- }
1241
- if (!this.ifParentContainsId((/** @type {?} */ (e.target)), this._id)) {
1242
- this.clickExit();
1243
- }
1244
- }
1245
- else if (this.isOpen && !this.ifParentContainsId((/** @type {?} */ (e.target)), this._id)) {
1246
- this.toggleOpenAndClose();
1247
- this.clickExit();
1248
- }
1249
- }
1250
- /**
1251
- * @private
1252
- * @return {?}
1253
- */
1254
- clickExit() {
1255
- this._focus(false);
1256
- window.document.body.removeEventListener('click', this._clickDetectionFc);
1257
- this._clickDetection = false;
1258
- }
1259
- /**
1260
- * @private
1261
- * @param {?} element
1262
- * @param {?} cssClass
1263
- * @return {?}
1264
- */
1265
- ifParentContainsClass(element, cssClass) {
1266
- return this.getParentElementByClass(element, cssClass) !== null;
1267
- }
1268
- /**
1269
- * @private
1270
- * @param {?} element
1271
- * @param {?} id
1272
- * @return {?}
1273
- */
1274
- ifParentContainsId(element, id) {
1275
- return this.getParentElementById(element, id) !== null;
1276
- }
1277
- /**
1278
- * @private
1279
- * @param {?} element
1280
- * @param {?} cssClass
1281
- * @return {?}
1282
- */
1283
- getParentElementByClass(element, cssClass) {
1284
- if (this.containClasses(element, cssClass.trim().split(/\s+/))) {
1285
- return element;
1286
- }
1287
- return element.parentElement ? this.getParentElementByClass(element.parentElement, cssClass) : null;
1288
- }
1289
- /**
1290
- * @private
1291
- * @param {?} element
1292
- * @param {?} id
1293
- * @return {?}
1294
- */
1295
- getParentElementById(element, id) {
1296
- if (element.id === id) {
1297
- return element;
1298
- }
1299
- return element.parentElement ? this.getParentElementById(element.parentElement, id) : null;
1300
- }
1301
- /**
1302
- * @private
1303
- * @param {?} element
1304
- * @param {?} cssClasses
1305
- * @return {?}
1306
- */
1307
- containClasses(element, cssClasses) {
1308
- if (!element.classList) {
1309
- return false;
1310
- }
1311
- for (const cssClass of cssClasses) {
1312
- if (!element.classList.contains(cssClass)) {
1313
- return false;
1314
- }
1315
- }
1316
- return true;
1317
- }
1318
- /**
1319
- * @return {?}
1320
- */
1321
- focusin() {
1322
- if (this.disabled) {
1323
- return;
1324
- }
1325
- this._focus(true);
1326
- }
1327
- /**
1328
- * @return {?}
1329
- */
1330
- focusout() {
1331
- if (this.selectionElement && !this.selectionElement.classList.contains('select2-focused')) {
1332
- this._focus(false);
1333
- this._onTouched();
1334
- }
1335
- }
1336
- /**
1337
- * @private
1338
- * @return {?}
1339
- */
1340
- moveUp() {
1341
- this.updateScrollFromOption(Select2Utils.getPreviousOption(this.filteredData, this.hoveringValue));
1342
- }
1343
- /**
1344
- * @private
1345
- * @return {?}
1346
- */
1347
- moveDown() {
1348
- this.updateScrollFromOption(Select2Utils.getNextOption(this.filteredData, this.hoveringValue));
1349
- }
1350
- /**
1351
- * @private
1352
- * @param {?} option
1353
- * @return {?}
1354
- */
1355
- updateScrollFromOption(option) {
1356
- if (option) {
1357
- this.hoveringValue = option.value;
1358
- /** @type {?} */
1359
- const domElement = this.results.find((/**
1360
- * @param {?} r
1361
- * @return {?}
1362
- */
1363
- r => r.nativeElement.innerText.trim() === option.label));
1364
- if (domElement && this.resultsElement) {
1365
- this.resultsElement.scrollTop = 0;
1366
- /** @type {?} */
1367
- const listClientRect = this.resultsElement.getBoundingClientRect();
1368
- /** @type {?} */
1369
- const optionClientRect = domElement.nativeElement.getBoundingClientRect();
1370
- this.resultsElement.scrollTop = optionClientRect.top - listClientRect.top;
1371
- }
1372
- }
1373
- }
1374
- /**
1375
- * @private
1376
- * @return {?}
1377
- */
1378
- selectByEnter() {
1379
- if (this.hoveringValue) {
1380
- /** @type {?} */
1381
- const option = Select2Utils.getOptionByValue(this._data, this.hoveringValue);
1382
- this.select(option);
1383
- }
1384
- }
1385
- /**
1386
- * @param {?} option
1387
- * @return {?}
1388
- */
1389
- select(option) {
1390
- /** @type {?} */
1391
- let value;
1392
- if (option !== null) {
1393
- if (this.multiple) {
1394
- /** @type {?} */
1395
- const options = (/** @type {?} */ (this.option));
1396
- /** @type {?} */
1397
- const index = options.findIndex((/**
1398
- * @param {?} op
1399
- * @return {?}
1400
- */
1401
- op => op.value === option.value));
1402
- if (index === -1) {
1403
- options.push(option);
1404
- }
1405
- else {
1406
- options.splice(index, 1);
1407
- }
1408
- value = ((/** @type {?} */ (this.option))).map((/**
1409
- * @param {?} op
1410
- * @return {?}
1411
- */
1412
- op => op.value));
1413
- }
1414
- else {
1415
- this.option = option;
1416
- if (this.isOpen) {
1417
- this.isOpen = false;
1418
- this.close.emit(this);
1419
- if (this.selectionElement) {
1420
- this.selectionElement.focus();
1421
- }
1422
- }
1423
- value = this.option.value;
1424
- }
1425
- }
1426
- else {
1427
- this.option = null;
1428
- }
1429
- if (this.multiple && this.hideSelectedItems) {
1430
- this.updateFilteredData();
1431
- }
1432
- if (this._control) {
1433
- this._onChange(value);
1434
- }
1435
- else {
1436
- this._value = value;
1437
- }
1438
- this.update.emit({
1439
- component: this,
1440
- value: value,
1441
- options: Array.isArray(this.option) ? this.option : this.option ? [this.option] : null,
1442
- });
1443
- }
1444
- /**
1445
- * @param {?} e
1446
- * @return {?}
1447
- */
1448
- keyDown(e) {
1449
- if (this._testKey(e, ['ArrowDown', 40])) {
1450
- this.moveDown();
1451
- e.preventDefault();
1452
- }
1453
- else if (this._testKey(e, ['ArrowUp', 38])) {
1454
- this.moveUp();
1455
- e.preventDefault();
1456
- }
1457
- else if (this._testKey(e, ['Enter', 13])) {
1458
- this.selectByEnter();
1459
- e.preventDefault();
1460
- }
1461
- else if (this._testKey(e, ['Escape', 'Tab', 9, 27]) && this.isOpen) {
1462
- this.toggleOpenAndClose();
1463
- this._focus(false);
1464
- }
1465
- }
1466
- /**
1467
- * @param {?} e
1468
- * @return {?}
1469
- */
1470
- openKey(e) {
1471
- if (this._testKey(e, ['ArrowDown', 'ArrowUp', 'Enter', 40, 38, 13])) {
1472
- this.toggleOpenAndClose();
1473
- e.preventDefault();
1474
- }
1475
- else if (this._testKey(e, ['Escape', 'Tab', 9, 27])) {
1476
- this._focus(false);
1477
- this._onTouched();
1478
- }
1479
- }
1480
- /**
1481
- * @param {?} _index
1482
- * @param {?} item
1483
- * @return {?}
1484
- */
1485
- trackBy(_index, item) {
1486
- return item.value;
1487
- }
1488
- /**
1489
- * @param {?} e
1490
- * @return {?}
1491
- */
1492
- searchUpdate(e) {
1493
- this.searchText = ((/** @type {?} */ (e.target))).value;
1494
- this.updateFilteredData();
1495
- }
1496
- /**
1497
- * @param {?} option
1498
- * @return {?}
1499
- */
1500
- isSelected(option) {
1501
- return Select2Utils.isSelected(this.option, option, this.multiple);
1502
- }
1503
- /**
1504
- * @param {?} option
1505
- * @return {?}
1506
- */
1507
- isDisabled(option) {
1508
- return option.disabled ? 'true' : 'false';
1509
- }
1510
- /**
1511
- * @param {?} e
1512
- * @param {?} option
1513
- * @return {?}
1514
- */
1515
- removeSelection(e, option) {
1516
- Select2Utils.removeSelection(this.option, option);
1517
- if (this.multiple && this.hideSelectedItems) {
1518
- this.updateFilteredData();
1519
- }
1520
- /** @type {?} */
1521
- const value = ((/** @type {?} */ (this.option))).map((/**
1522
- * @param {?} op
1523
- * @return {?}
1524
- */
1525
- op => op.value));
1526
- if (this._control) {
1527
- this._onChange(value);
1528
- }
1529
- else {
1530
- this._value = value;
1531
- }
1532
- this.update.emit({
1533
- component: this,
1534
- value: value,
1535
- options: Array.isArray(this.option) ? this.option : this.option ? [this.option] : null,
1536
- });
1537
- this.removeOption.emit({
1538
- component: this,
1539
- value: value,
1540
- removedOption: option,
1541
- });
1542
- e.preventDefault();
1543
- e.stopPropagation();
1544
- if (this.isOpen) {
1545
- this._focusSearchboxOrResultsElement();
1546
- }
1547
- }
1548
- /**
1549
- * Sets the model value. Implemented as part of ControlValueAccessor.
1550
- * @param {?} value
1551
- * @return {?}
1552
- */
1553
- writeValue(value) {
1554
- this._setSelectionByValue(value);
1555
- }
1556
- /**
1557
- * Saves a callback function to be invoked when the select's value
1558
- * changes from user input. Part of the ControlValueAccessor interface
1559
- * required to integrate with Angular's core forms API.
1560
- *
1561
- * @param {?} fn Callback to be triggered when the value changes.
1562
- * @return {?}
1563
- */
1564
- registerOnChange(fn) {
1565
- this._onChange = fn;
1566
- }
1567
- /**
1568
- * Saves a callback function to be invoked when the select is blurred
1569
- * by the user. Part of the ControlValueAccessor interface required
1570
- * to integrate with Angular's core forms API.
1571
- *
1572
- * @param {?} fn Callback to be triggered when the component has been touched.
1573
- * @return {?}
1574
- */
1575
- registerOnTouched(fn) {
1576
- this._onTouched = fn;
1577
- }
1578
- /**
1579
- * Sets whether the component should be disabled.
1580
- * Implemented as part of ControlValueAccessor.
1581
- * @param {?} isDisabled
1582
- * @return {?}
1583
- */
1584
- setDisabledState(isDisabled) {
1585
- this.disabled = isDisabled;
1586
- }
1587
- /**
1588
- * @param {?} way
1589
- * @return {?}
1590
- */
1591
- onScroll(way) {
1592
- this.scroll.emit({
1593
- component: this,
1594
- way,
1595
- search: this.innerSearchText,
1596
- });
1597
- }
1598
- /**
1599
- * @return {?}
1600
- */
1601
- _isErrorState() {
1602
- /** @type {?} */
1603
- const isInvalid = this._control && this._control.invalid;
1604
- /** @type {?} */
1605
- const isTouched = this._control && this._control.touched;
1606
- /** @type {?} */
1607
- const isSubmitted = (this._parentFormGroup && this._parentFormGroup.submitted) ||
1608
- (this._parentForm && this._parentForm.submitted);
1609
- return !!(isInvalid && (isTouched || isSubmitted));
1610
- }
1611
- /**
1612
- * @private
1613
- * @param {?} event
1614
- * @param {?=} refs
1615
- * @return {?}
1616
- */
1617
- _testKey(event, refs = []) {
1618
- return this._isKey(this._getKey(event), refs);
1619
- }
1620
- /**
1621
- * @private
1622
- * @param {?} event
1623
- * @return {?}
1624
- */
1625
- _getKey(event) {
1626
- /** @type {?} */
1627
- let code;
1628
- if (event.key !== undefined) {
1629
- code = event.key;
1630
- }
1631
- else if (event['keyIdentifier'] !== undefined) {
1632
- code = event['keyIdentifier'];
1633
- }
1634
- else if (event['keyCode'] !== undefined) {
1635
- code = event['keyCode'];
1636
- }
1637
- else {
1638
- event.preventDefault();
1639
- }
1640
- return code;
1641
- }
1642
- /**
1643
- * @private
1644
- * @param {?} code
1645
- * @param {?=} refs
1646
- * @return {?}
1647
- */
1648
- _isKey(code, refs = []) {
1649
- return refs && refs.length > 0 ? refs.indexOf(code) !== -1 : false;
1650
- }
1651
- /**
1652
- * Sets the selected option based on a value. If no option can be
1653
- * found with the designated value, the select trigger is cleared.
1654
- * @private
1655
- * @param {?} value
1656
- * @return {?}
1657
- */
1658
- _setSelectionByValue(value) {
1659
- if (this.option || (value !== undefined && value !== null)) {
1660
- /** @type {?} */
1661
- const isArray = Array.isArray(value);
1662
- if (this.multiple && value && !isArray) {
1663
- throw new Error('Non array value.');
1664
- }
1665
- else if (this._data) {
1666
- if (this.multiple) {
1667
- this.option = []; // if value is null, then empty option and return
1668
- if (isArray) {
1669
- // value is not null. Preselect value
1670
- /** @type {?} */
1671
- const selectedValues = Select2Utils.getOptionsByValue(this._data, value, this.multiple);
1672
- selectedValues.map((/**
1673
- * @param {?} item
1674
- * @return {?}
1675
- */
1676
- item => this.select(item)));
1677
- }
1678
- }
1679
- else {
1680
- this.select(Select2Utils.getOptionByValue(this._data, value));
1681
- }
1682
- }
1683
- else if (this._control) {
1684
- this._control.viewToModelUpdate(value);
1685
- }
1686
- this._changeDetectorRef.markForCheck();
1687
- }
1688
- }
1689
- /**
1690
- * Does some manual dirty checking on the native input `value` property.
1691
- * @private
1692
- * @return {?}
1693
- */
1694
- _dirtyCheckNativeValue() {
1695
- /** @type {?} */
1696
- const newValue = this.value;
1697
- if (this._previousNativeValue !== newValue) {
1698
- this._previousNativeValue = newValue;
1699
- this._stateChanges.next();
1700
- }
1701
- }
1702
- /**
1703
- * @private
1704
- * @param {?} value
1705
- * @return {?}
1706
- */
1707
- _coerceBooleanProperty(value) {
1708
- return value != null && `${value}` !== 'false';
1709
- }
1710
- /**
1711
- * @private
1712
- * @return {?}
1713
- */
1714
- _focusSearchboxOrResultsElement() {
1715
- if (!this.isSearchboxHidden) {
1716
- setTimeout((/**
1717
- * @return {?}
1718
- */
1719
- () => {
1720
- if (this.searchInput && this.searchInput.nativeElement) {
1721
- this.searchInput.nativeElement.focus();
1722
- }
1723
- }));
1724
- }
1725
- else if (this.resultsElement) {
1726
- this.resultsElement.focus();
1727
- }
1728
- }
1729
- /**
1730
- * @private
1731
- * @param {?} state
1732
- * @return {?}
1733
- */
1734
- _focus(state) {
1735
- if (!state && this.focused) {
1736
- this.focused = state;
1737
- this.blur.emit(this);
1738
- }
1739
- else if (state && !this.focused) {
1740
- this.focused = state;
1741
- this.focus.emit(this);
1742
- }
1743
- }
1744
- /**
1745
- * @private
1746
- * @return {?}
1747
- */
1748
- _isAbobeOverlay() {
1749
- return this.overlay && this._overlayPosition && this.listPosition === 'auto'
1750
- ? this._overlayPosition === 'top'
1751
- : this.listPosition === 'above';
1752
- }
1753
- }
1754
- Select2.decorators = [
1755
- { type: Component, args: [{
1756
- selector: 'select2',
1757
- template: "<div class=\"select2-label\" (click)=\"toggleOpenAndClose()\">\n <ng-content select=\"select2-label\"></ng-content>\n <span *ngIf=\"required\" class=\"select2-required\"></span>\n</div>\n<div\n class=\"select2 select2-container select2-container--default select2-container--focus\"\n [class.select2-container--below]=\"!select2above\"\n [class.select2-container--above]=\"select2above\"\n [class.select2-container--open]=\"isOpen\"\n [class.select2-container--disabled]=\"disabled\"\n>\n <div\n class=\"selection\"\n #selection\n #trigger=\"cdkOverlayOrigin\"\n [attr.tabindex]=\"!this.isOpen ? tabIndex : '-1'\"\n (click)=\"toggleOpenAndClose()\"\n (focus)=\"focusin()\"\n (blur)=\"focusout()\"\n (keydown)=\"openKey($event)\"\n cdkOverlayOrigin\n [class.select2-focused]=\"focused\"\n >\n <div\n class=\"select2-selection\"\n [class.select2-selection--multiple]=\"multiple\"\n [class.select2-selection--single]=\"!multiple\"\n role=\"combobox\"\n >\n <span *ngIf=\"!multiple\" class=\"select2-selection__rendered\" [title]=\"select2Option?.label || ''\">\n <span *ngIf=\"!select2Option\">&nbsp;</span>\n <span *ngIf=\"select2Option\" [innerHTML]=\"select2Option.label\"></span>\n <span [class.select2-selection__placeholder__option]=\"option\" class=\"select2-selection__placeholder\">{{\n placeholder\n }}</span>\n </span>\n <span\n (click)=\"reset($event)\"\n *ngIf=\"!multiple && resettable && select2Option && !(disabled || readonly)\"\n class=\"select2-selection__reset\"\n role=\"presentation\"\n >\u00D7</span\n >\n <span *ngIf=\"!multiple\" class=\"select2-selection__arrow\" role=\"presentation\"> </span>\n <ul *ngIf=\"multiple\" class=\"select2-selection__rendered\">\n <span\n [class.select2-selection__placeholder__option]=\"select2Options?.length > 0\"\n class=\"select2-selection__placeholder\"\n >{{ placeholder }}</span\n >\n <li *ngFor=\"let op of option; trackBy: trackBy\" class=\"select2-selection__choice\" [title]=\"op.label\">\n <span\n *ngIf=\"!(disabled || readonly)\"\n (click)=\"removeSelection($event, op)\"\n class=\"select2-selection__choice__remove\"\n role=\"presentation\"\n >\u00D7</span\n >\n <span [innerHTML]=\"op.label\"></span>\n </li>\n </ul>\n </div>\n </div>\n <ng-container *ngIf=\"!overlay\">\n <ng-container *ngTemplateOutlet=\"containerTemplate\"></ng-container>\n </ng-container>\n\n <div class=\"select2-subscript-wrapper\">\n <ng-content select=\"select2-hint\"></ng-content>\n </div>\n</div>\n\n<ng-template\n cdkConnectedOverlay\n cdkConnectedOverlayHasBackdrop\n cdkConnectedOverlayBackdropClass=\"select2-overlay-backdrop\"\n [cdkConnectedOverlayOrigin]=\"trigger\"\n [cdkConnectedOverlayOpen]=\"this.isOpen && overlay\"\n [cdkConnectedOverlayMinWidth]=\"overlayWidth\"\n [cdkConnectedOverlayHeight]=\"overlayHeight\"\n [cdkConnectedOverlayPositions]=\"_positions\"\n (backdropClick)=\"toggleOpenAndClose()\"\n>\n <ng-container *ngTemplateOutlet=\"containerTemplate\"></ng-container>\n</ng-template>\n\n<ng-template #containerTemplate>\n <div\n class=\"select2-container select2-container--default select2-container-dropdown\"\n [class.select2-container--open]=\"isOpen\"\n [class.select2-overlay]=\"overlay\"\n [class.select2-position-auto]=\"listPosition === 'auto'\"\n >\n <div\n #dropdown\n class=\"select2-dropdown\"\n [class.select2-dropdown--below]=\"!select2above\"\n [class.select2-dropdown--above]=\"select2above\"\n >\n <div class=\"select2-search select2-search--dropdown\" [class.select2-search--hide]=\"hideSearch()\">\n <input\n #searchInput\n [id]=\"id + '-search-field'\"\n [value]=\"searchText\"\n (keydown)=\"keyDown($event)\"\n (keyup)=\"searchUpdate($event)\"\n (change)=\"prevChange($event)\"\n class=\"select2-search__field\"\n type=\"search\"\n role=\"textbox\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [attr.tabindex]=\"this.isOpen ? tabIndex : '-1'\"\n />\n </div>\n <div class=\"select2-results\">\n <ul\n #results\n class=\"select2-results__options\"\n [style.max-height]=\"resultMaxHeight\"\n role=\"tree\"\n tabindex=\"-1\"\n infiniteScroll\n [infiniteScrollDisabled]=\"!infiniteScroll && !isOpen\"\n [infiniteScrollDistance]=\"infiniteScrollDistance\"\n [infiniteScrollThrottle]=\"infiniteScrollThrottle\"\n [infiniteScrollContainer]=\"results\"\n (scrolled)=\"onScroll('down')\"\n (scrolledUp)=\"onScroll('up')\"\n (keydown)=\"keyDown($event)\"\n >\n <ng-container *ngFor=\"let groupOrOption of filteredData; index as i; trackBy: trackBy\">\n <li *ngIf=\"groupOrOption.options\" class=\"select2-results__option\" role=\"group\">\n <strong\n *ngIf=\"!hasTemplate(groupOrOption, 'group'); else optGroup\"\n [attr.class]=\"\n 'select2-results__group' +\n (groupOrOption.classes ? ' ' + groupOrOption.classes : '')\n \"\n [innerHTML]=\"groupOrOption.label\"\n ></strong>\n <ng-template #optGroup>\n <ng-container\n *ngTemplateOutlet=\"getTemplate(groupOrOption, 'group'); context: groupOrOption\"\n >\n </ng-container>\n </ng-template>\n\n <ul class=\"select2-results__options select2-results__options--nested\">\n <li\n *ngFor=\"let option of groupOrOption.options; index as j; trackBy: trackBy\"\n #result\n [id]=\"option.id || id + '-option-' + i + '-' + j\"\n [class]=\"getOptionStyle(option)\"\n role=\"treeitem\"\n [attr.aria-selected]=\"isSelected(option)\"\n [attr.aria-disabled]=\"isDisabled(option)\"\n (mouseenter)=\"mouseenter(option)\"\n (click)=\"click(option)\"\n >\n <div\n *ngIf=\"!hasTemplate(option, 'option'); else liGroup\"\n class=\"select2-label-content\"\n [innerHTML]=\"option.label\"\n ></div>\n <ng-template #liGroup>\n <ng-container\n *ngTemplateOutlet=\"getTemplate(option, 'option'); context: option\"\n >\n </ng-container>\n </ng-template>\n </li>\n </ul>\n </li>\n <li\n *ngIf=\"!groupOrOption.options\"\n #result\n [id]=\"groupOrOption.id || id + '-option-' + i\"\n [class]=\"getOptionStyle(groupOrOption)\"\n role=\"treeitem\"\n [attr.aria-selected]=\"isSelected(groupOrOption)\"\n [attr.aria-disabled]=\"isDisabled(groupOrOption)\"\n (mouseenter)=\"mouseenter(groupOrOption)\"\n (click)=\"click(groupOrOption)\"\n >\n <div\n *ngIf=\"!hasTemplate(groupOrOption, 'option'); else li\"\n [innerHTML]=\"groupOrOption.label\"\n class=\"select2-label-content\"\n ></div>\n <ng-template #li>\n <ng-container\n *ngTemplateOutlet=\"getTemplate(groupOrOption, 'option'); context: groupOrOption\"\n >\n </ng-container>\n </ng-template>\n </li>\n </ng-container>\n <li\n class=\"select2-no-result select2-results__option\"\n *ngIf=\"!filteredData?.length && noResultMessage\"\n [innerHTML]=\"noResultMessage\"\n ></li>\n </ul>\n </div>\n </div>\n </div>\n</ng-template>\n",
1758
- styles: [".select2-label{color:#000;color:var(--select2-label-text-color,#000)}.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle;width:100%}.select2-container .select2-container-dropdown{opacity:0;position:absolute;width:0}.select2-container .select2-selection--single{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;flex:1 1 auto;overflow:hidden;padding:0 0 0 8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container .select2-selection--multiple{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{border:none;box-sizing:border-box;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background:#fff;background:var(--select2-dropdown-background,#fff);border:1px solid #aaa;border:1px solid var(--select2-dropdown-border-color,#aaa);border-radius:4px;border-radius:var(--select2-selection-border-radius,4px);box-sizing:border-box;display:block;height:0;overflow:hidden;position:absolute;width:100%;z-index:1051}.select2-dropdown .select2-label-content{display:contents}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;color:#000;color:var(--select2-option-text-color,#000);padding:6px;user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container.select2-container-dropdown.select2-container--open{opacity:1;width:100%}.select2-container--open .select2-dropdown{height:auto;overflow:auto}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;bottom:27px;display:flex;flex-direction:column-reverse}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{box-sizing:border-box;padding:4px;width:100%}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{background:#fff;border:0;display:block;filter:alpha(opacity=0);height:auto;left:0;margin:0;min-height:100%;min-width:100%;opacity:0;padding:0;position:fixed;top:0;width:auto;z-index:99}.select2-required:before{color:red;color:var(--select2-required-color,red);content:\"*\"}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important}.select2-container--default .select2-selection--single{background:#fff;background:var(--select2-selection-background,#fff);border:1px solid #aaa;border:1px solid var(--select2-selection-border-color,#aaa);border-radius:4px;border-radius:var(--select2-selection-border-radius,4px);display:flex}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;color:var(--select2-selection-text-color,#444);line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:700}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999;color:var(--select2-placeholder-color,#999)}.select2-container--default .select2-selection--single .select2-selection__placeholder span{overflow:hidden;text-overflow:ellipsis;text-overflow:var(--select2-placeholder-overflow,ellipsis);white-space:nowrap}.select2-container--default .select2-selection--single .select2-selection__placeholder__option{display:none}.select2-container--default .select2-selection--single .select2-selection__arrow,.select2-container--default .select2-selection--single .select2-selection__reset{align-items:center;display:flex;justify-content:center;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow:before{border-bottom:0 solid var(--select2-arrow-color,#888);border-color:#888 transparent;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid var(--select2-arrow-color,#888);content:\" \";height:0;width:0}.select2-container--default .select2-selection--single .select2-selection__reset{color:#999;color:var(--select2-reset-color,#999)}.select2-container--default.select2-container--disabled .select2-selection--single{background:#eee;background:var(--select2-selection-disabled-background,#eee);cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow:before{border-bottom-color:var(--select2-arrow-color,#888);border-color:transparent transparent #888;border-right-color:transparent;border-top-color:transparent;border-width:0 4px 5px}.select2-container--default .select2-selection--multiple{background:#fff;background:var(--select2-selection-background,#fff);border:1px solid #aaa;border:1px solid var(--select2-selection-border-color,#aaa);border-radius:4px;border-radius:var(--select2-selection-border-radius,4px);cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;flex:1 1 auto;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;color:var(--select2-placeholder-color,#999);display:block;float:left;margin-top:5px;overflow:hidden;text-overflow:ellipsis;text-overflow:var(--select2-placeholder-overflow,ellipsis);white-space:nowrap;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__placeholder__option{display:none}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-right:10px;margin-top:5px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background:#e4e4e4;background:var(--select2-selection-choice-background,#e4e4e4);border:1px solid #aaa;border:1px solid var(--select2-selection-choice-border-color,#aaa);border-radius:4px;border-radius:var(--select2-selection-border-radius,4px);color:#000;color:var(--select2-selection-choice-text-color,#000);cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;color:var(--select2-selection-choice-close-color,#999);cursor:pointer;display:inline-block;font-weight:700;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333;color:var(--select2-selection-choice-hover-close-color,#333)}.select2-container--default.select2-container--focused .select2-selection--multiple,.select2-container--default:not(.select2-container--open) .select2-focused .select2-selection--multiple,.select2-container--default:not(.select2-container--open) .select2-focused .select2-selection--single{border:1px solid #000;border:1px solid var(--select2-selection-focus-border-color,#000);outline:none}.select2-container--default.select2-container--disabled .select2-selection--multiple{background:#eee;background:var(--select2-selection-disabled-background,#eee);cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple,.select2-container--default.select2-container--open.select2-container--above .select2-selection--single{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple,.select2-container--default.select2-container--open.select2-container--below .select2-selection--single{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{background:#fff;background:1px solid var(--select2-search-background,#fff);border:1px solid #aaa;border:1px solid var(--select2-search-border-color,#aaa);border-radius:0;border-radius:var(--select2-search-border-radius,0)}.select2-container--default .select2-search--inline .select2-search__field{-webkit-appearance:textfield;background:transparent;border:none;box-shadow:none;outline:none}.select2-container--default .select2-results>.select2-results__options{overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{background:transparent;background:var(--select2-option-disabled-background,transparent);color:#999;color:var(--select2-option-disabled-text-color,#999)}.select2-container--default .select2-results__option[aria-selected=true]{background:#ddd;background:var(--select2-option-selected-background,#ddd);color:#000;color:var(--select2-option-selected-text-color,#000)}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background:#5897fb;background:var(--select2-option-highlighted-background,#5897fb);color:#fff;color:var(--select2-option-highlighted-text-color,#fff)}.select2-container--default .select2-results__option--hide{display:none}.select2-container--default .select2-results__group{background:transparent;background:var(--select2-option-group-background,transparent);color:grey;color:var(--select2-option-group-text-color,grey);cursor:default;display:block;padding:6px}.select2-no-result{color:#888;color:var(--select2-no-result-color,#888);font-style:italic;font-style:var(--select2-font-style-color,italic)}:host.nostyle .select2-dropdown{border-color:transparent}:host.nostyle .select2-container--default .select2-focused .select2-selection--multiple,:host.nostyle .select2-container--default .select2-focused .select2-selection--single,:host.nostyle .select2-container--default:not(.select2-container--open) .select2-focused .select2-selection--multiple,:host.nostyle .select2-container--default:not(.select2-container--open) .select2-focused .select2-selection--single,:host.nostyle .select2-selection--multiple,:host.nostyle .select2-selection--single{background:transparent;border-color:transparent}:host.material{display:inline-block;width:300px}:host.material>.select2-container{padding-bottom:1.29688em;vertical-align:inherit}:host.material>.select2-container .selection{align-items:baseline;border-top:.84375em solid transparent;display:inline-flex;height:auto;padding:.4375em 0;width:100%}:host.material .select2-container--default .select2-selection--multiple,:host.material .select2-container--default .select2-selection--single{border:0;border-radius:0;box-sizing:border-box;height:24px;width:100%}:host.material .select2-container--default .select2-selection--multiple:before,:host.material .select2-container--default .select2-selection--single:before{background:#ddd;background:var(--select2-material-underline,#ddd);bottom:1.65em;content:\" \";display:block;height:1px;position:absolute;width:100%}:host.material .select2-container--default .select2-selection--multiple:after,:host.material .select2-container--default .select2-selection--single:after{background:#5a419e;background:var(--select2-material-underline-active,#5a419e);bottom:1.63em;content:\" \";display:block;height:2px;left:50%;position:absolute;transition:none;width:0}:host.material .select2-container--default .select2-selection--multiple .select2-selection__rendered,:host.material .select2-container--default .select2-selection--single .select2-selection__rendered{line-height:inherit;padding-left:1px}:host.material .select2-container--default .select2-selection--multiple .select2-selection__placeholder,:host.material .select2-container--default .select2-selection--single .select2-selection__placeholder{color:rgba(0,0,0,.38);color:var(--select2-material-placeholder-color,rgba(0,0,0,.38));display:block;left:0;position:absolute;top:20px;transform-origin:0 21px;transition:transform .3s}:host.material .select2-container--default .select2-container--open{bottom:1.6em;left:0}:host.material .select2-container--default .select2-selection__placeholder__option{transform:translateY(-1.5em) scale(.75) perspective(100px) translateZ(.001px);width:133.33333%}:host.material .select2-container--default .select2-selection__arrow{top:20px}:host.material .select2-container--default.select2-container--open .select2-selection--multiple:after,:host.material .select2-container--default.select2-container--open .select2-selection--single:after,:host.material .select2-container--default .select2-focused .select2-selection--multiple:after,:host.material .select2-container--default .select2-focused .select2-selection--single:after{left:0;transition:width .3s cubic-bezier(.12,1,.77,1),left .3s cubic-bezier(.12,1,.77,1);width:100%}:host.material .select2-container--default .select2-dropdown{border:0;border-radius:0;box-shadow:0 5px 5px rgba(0,0,0,.5)}:host.material .select2-container--default .select2-results__option--highlighted[aria-selected],:host.material .select2-container--default .select2-results__option[aria-selected=true]{background:rgba(0,0,0,.04);background:var(--select2-material-option-selected-background,rgba(0,0,0,.04));color:#000;color:var(--select2-material-option-highlighted-text-color,#000)}:host.material .select2-container--default .select2-results__option[aria-selected=true]{color:#ff5722;color:var(--select2-material-option-selected-text-color,#ff5722)}:host.material .select2-container--default.select2-container--disabled .select2-selection--multiple,:host.material .select2-container--default.select2-container--disabled .select2-selection--single{background:transparent}:host.material .select2-container--default.select2-container--disabled .select2-selection--multiple:before,:host.material .select2-container--default.select2-container--disabled .select2-selection--single:before{background:linear-gradient(90deg,rgba(0,0,0,.26) 0,rgba(0,0,0,.26) 33%,transparent 0);background:var(--select2-material-underline-disabled,linear-gradient(90deg,rgba(0,0,0,.26) 0,rgba(0,0,0,.26) 33%,transparent 0));background-position:0 bottom;background-repeat:repeat-x;background-size:4px 1px}:host.material.ng-invalid.ng-touched .select2-container--default .select2-selection--multiple:after,:host.material.ng-invalid.ng-touched .select2-container--default .select2-selection--multiple:before,:host.material.ng-invalid.ng-touched .select2-container--default .select2-selection--single:after,:host.material.ng-invalid.ng-touched .select2-container--default .select2-selection--single:before{background:red;background:var(--select2-material-underline-invalid,red)}:host.material:not(.select2-container--open) .select2-focused .select2-selection--multiple,:host.material:not(.select2-container--open) .select2-focused .select2-selection--single{border:0}:host.material .select2-subscript-wrapper{color:#888;color:var(--select2-hint-text-color,#888);font-size:75%;position:absolute;top:calc(100% - 1.72917em)}::ng-deep .select2-overlay-backdrop{background:rgba(0,0,0,.32);background:var(--select2-overlay-backdrop,transparent)}::ng-deep .cdk-overlay-container .select2-container .select2-dropdown.select2-dropdown--above{bottom:28px}::ng-deep .cdk-overlay-container .select2-container--open.select2-position-auto .select2-dropdown{margin-bottom:28px}::ng-deep .cdk-overlay-container .select2-container--open.select2-position-auto .select2-dropdown.select2-dropdown--above{bottom:0;margin-bottom:0;margin-top:28px}@supports (-moz-appearance:none){select2.material .select2-container--default .select2-selection--multiple,select2.material .select2-container--default .select2-selection--single{height:26px}}@supports (-ms-scroll-limit:0){select2.material .select2-container--default .select2-selection--multiple,select2.material .select2-container--default .select2-selection--single{height:25px}}"]
1759
- }] }
1760
- ];
1761
- /** @nocollapse */
1762
- Select2.ctorParameters = () => [
1763
- { type: ViewportRuler },
1764
- { type: ChangeDetectorRef },
1765
- { type: NgForm, decorators: [{ type: Optional }] },
1766
- { type: FormGroupDirective, decorators: [{ type: Optional }] },
1767
- { type: NgControl, decorators: [{ type: Self }, { type: Optional }] },
1768
- { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] }
1769
- ];
1770
- Select2.propDecorators = {
1771
- data: [{ type: Input }],
1772
- minCharForSearch: [{ type: Input }],
1773
- displaySearchStatus: [{ type: Input }],
1774
- placeholder: [{ type: Input }],
1775
- customSearchEnabled: [{ type: Input }],
1776
- limitSelection: [{ type: Input }],
1777
- listPosition: [{ type: Input }],
1778
- multiple: [{ type: Input }],
1779
- overlay: [{ type: Input }],
1780
- styleMode: [{ type: Input }],
1781
- noResultMessage: [{ type: Input }],
1782
- infiniteScrollDistance: [{ type: Input }],
1783
- infiniteScrollThrottle: [{ type: Input }],
1784
- infiniteScroll: [{ type: Input }],
1785
- editPattern: [{ type: Input }],
1786
- templates: [{ type: Input }],
1787
- resultMaxHeight: [{ type: Input }],
1788
- update: [{ type: Output }],
1789
- open: [{ type: Output }],
1790
- close: [{ type: Output }],
1791
- focus: [{ type: Output }],
1792
- blur: [{ type: Output }],
1793
- search: [{ type: Output }],
1794
- scroll: [{ type: Output }],
1795
- removeOption: [{ type: Output }],
1796
- minCountForSearch: [{ type: Input }],
1797
- id: [{ type: Input }, { type: HostBinding, args: ['id',] }],
1798
- required: [{ type: Input }],
1799
- disabled: [{ type: Input }],
1800
- hideSelectedItems: [{ type: Input }],
1801
- readonly: [{ type: Input }],
1802
- value: [{ type: Input }],
1803
- tabIndex: [{ type: Input }],
1804
- resettable: [{ type: Input }],
1805
- ariaInvalid: [{ type: HostBinding, args: ['attr.aria-invalid',] }],
1806
- classMaterial: [{ type: HostBinding, args: ['class.material',] }],
1807
- classNostyle: [{ type: HostBinding, args: ['class.nostyle',] }],
1808
- select2above: [{ type: HostBinding, args: ['class.select2-above',] }],
1809
- cdkConnectedOverlay: [{ type: ViewChild, args: [CdkConnectedOverlay,] }],
1810
- selection: [{ type: ViewChild, args: ['selection', { static: true },] }],
1811
- resultContainer: [{ type: ViewChild, args: ['results',] }],
1812
- results: [{ type: ViewChildren, args: ['result',] }],
1813
- searchInput: [{ type: ViewChild, args: ['searchInput',] }],
1814
- dropdown: [{ type: ViewChild, args: ['dropdown',] }]
1815
- };
1816
- if (false) {
1817
- /** @type {?} */
1818
- Select2.prototype._data;
1819
- /** @type {?} */
1820
- Select2.prototype.minCharForSearch;
1821
- /** @type {?} */
1822
- Select2.prototype.displaySearchStatus;
1823
- /** @type {?} */
1824
- Select2.prototype.placeholder;
1825
- /** @type {?} */
1826
- Select2.prototype.customSearchEnabled;
1827
- /** @type {?} */
1828
- Select2.prototype.limitSelection;
1829
- /** @type {?} */
1830
- Select2.prototype.listPosition;
1831
- /**
1832
- * use the material style
1833
- * @type {?}
1834
- */
1835
- Select2.prototype.styleMode;
1836
- /**
1837
- * message when no result
1838
- * @type {?}
1839
- */
1840
- Select2.prototype.noResultMessage;
1841
- /**
1842
- * infinite scroll distance
1843
- * @type {?}
1844
- */
1845
- Select2.prototype.infiniteScrollDistance;
1846
- /**
1847
- * infinite scroll distance
1848
- * @type {?}
1849
- */
1850
- Select2.prototype.infiniteScrollThrottle;
1851
- /**
1852
- * use it for change the pattern of the filter search
1853
- * @type {?}
1854
- */
1855
- Select2.prototype.editPattern;
1856
- /**
1857
- * template for formating
1858
- * @type {?}
1859
- */
1860
- Select2.prototype.templates;
1861
- /**
1862
- * the max height of the results container when opening the select
1863
- * @type {?}
1864
- */
1865
- Select2.prototype.resultMaxHeight;
1866
- /** @type {?} */
1867
- Select2.prototype.update;
1868
- /** @type {?} */
1869
- Select2.prototype.open;
1870
- /** @type {?} */
1871
- Select2.prototype.close;
1872
- /** @type {?} */
1873
- Select2.prototype.focus;
1874
- /** @type {?} */
1875
- Select2.prototype.blur;
1876
- /** @type {?} */
1877
- Select2.prototype.search;
1878
- /** @type {?} */
1879
- Select2.prototype.scroll;
1880
- /** @type {?} */
1881
- Select2.prototype.removeOption;
1882
- /** @type {?} */
1883
- Select2.prototype.option;
1884
- /** @type {?} */
1885
- Select2.prototype.isOpen;
1886
- /** @type {?} */
1887
- Select2.prototype.searchStyle;
1888
- /**
1889
- * Whether the element is focused or not.
1890
- * @type {?}
1891
- */
1892
- Select2.prototype.focused;
1893
- /** @type {?} */
1894
- Select2.prototype.filteredData;
1895
- /** @type {?} */
1896
- Select2.prototype.overlayWidth;
1897
- /** @type {?} */
1898
- Select2.prototype.overlayHeight;
1899
- /** @type {?} */
1900
- Select2.prototype._triggerRect;
1901
- /** @type {?} */
1902
- Select2.prototype._dropdownRect;
1903
- /**
1904
- * @type {?}
1905
- * @private
1906
- */
1907
- Select2.prototype._minCountForSearch;
1908
- /**
1909
- * @type {?}
1910
- * @private
1911
- */
1912
- Select2.prototype.cdkConnectedOverlay;
1913
- /**
1914
- * @type {?}
1915
- * @private
1916
- */
1917
- Select2.prototype.selection;
1918
- /**
1919
- * @type {?}
1920
- * @private
1921
- */
1922
- Select2.prototype.resultContainer;
1923
- /**
1924
- * @type {?}
1925
- * @private
1926
- */
1927
- Select2.prototype.results;
1928
- /**
1929
- * @type {?}
1930
- * @private
1931
- */
1932
- Select2.prototype.searchInput;
1933
- /**
1934
- * @type {?}
1935
- * @private
1936
- */
1937
- Select2.prototype.dropdown;
1938
- /**
1939
- * @type {?}
1940
- * @private
1941
- */
1942
- Select2.prototype.hoveringValue;
1943
- /**
1944
- * @type {?}
1945
- * @private
1946
- */
1947
- Select2.prototype.innerSearchText;
1948
- /**
1949
- * @type {?}
1950
- * @private
1951
- */
1952
- Select2.prototype.isSearchboxHidden;
1953
- /**
1954
- * @type {?}
1955
- * @private
1956
- */
1957
- Select2.prototype.selectionElement;
1958
- /**
1959
- * @type {?}
1960
- * @private
1961
- */
1962
- Select2.prototype._stateChanges;
1963
- /**
1964
- * Tab index for the element.
1965
- * @type {?}
1966
- * @private
1967
- */
1968
- Select2.prototype._tabIndex;
1969
- /**
1970
- * @type {?}
1971
- * @private
1972
- */
1973
- Select2.prototype._disabled;
1974
- /**
1975
- * @type {?}
1976
- * @private
1977
- */
1978
- Select2.prototype._required;
1979
- /**
1980
- * @type {?}
1981
- * @private
1982
- */
1983
- Select2.prototype._readonly;
1984
- /**
1985
- * @type {?}
1986
- * @private
1987
- */
1988
- Select2.prototype._multiple;
1989
- /**
1990
- * @type {?}
1991
- * @private
1992
- */
1993
- Select2.prototype._overlay;
1994
- /**
1995
- * @type {?}
1996
- * @private
1997
- */
1998
- Select2.prototype._resettable;
1999
- /**
2000
- * @type {?}
2001
- * @private
2002
- */
2003
- Select2.prototype._hideSelectedItems;
2004
- /**
2005
- * @type {?}
2006
- * @private
2007
- */
2008
- Select2.prototype._clickDetection;
2009
- /**
2010
- * @type {?}
2011
- * @private
2012
- */
2013
- Select2.prototype._clickDetectionFc;
2014
- /**
2015
- * @type {?}
2016
- * @private
2017
- */
2018
- Select2.prototype._id;
2019
- /**
2020
- * @type {?}
2021
- * @private
2022
- */
2023
- Select2.prototype._uid;
2024
- /**
2025
- * @type {?}
2026
- * @private
2027
- */
2028
- Select2.prototype._value;
2029
- /**
2030
- * @type {?}
2031
- * @private
2032
- */
2033
- Select2.prototype._previousNativeValue;
2034
- /**
2035
- * @type {?}
2036
- * @private
2037
- */
2038
- Select2.prototype._infiniteScroll;
2039
- /**
2040
- * @type {?}
2041
- * @private
2042
- */
2043
- Select2.prototype._overlayPosition;
2044
- /**
2045
- * View -> model callback called when select has been touched
2046
- * @type {?}
2047
- * @private
2048
- */
2049
- Select2.prototype._onTouched;
2050
- /**
2051
- * View -> model callback called when value changes
2052
- * @type {?}
2053
- * @private
2054
- */
2055
- Select2.prototype._onChange;
2056
- /**
2057
- * @type {?}
2058
- * @protected
2059
- */
2060
- Select2.prototype._viewportRuler;
2061
- /**
2062
- * @type {?}
2063
- * @private
2064
- */
2065
- Select2.prototype._changeDetectorRef;
2066
- /**
2067
- * @type {?}
2068
- * @private
2069
- */
2070
- Select2.prototype._parentForm;
2071
- /**
2072
- * @type {?}
2073
- * @private
2074
- */
2075
- Select2.prototype._parentFormGroup;
2076
- /** @type {?} */
2077
- Select2.prototype._control;
2078
- }
2079
-
2080
- /**
2081
- * @fileoverview added by tsickle
2082
- * Generated from: lib/select2-hint.component.ts
2083
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2084
- */
2085
- class Select2Hint {
2086
- }
2087
- Select2Hint.decorators = [
2088
- { type: Directive, args: [{ selector: 'select2-hint' },] }
2089
- ];
2090
-
2091
- /**
2092
- * @fileoverview added by tsickle
2093
- * Generated from: lib/select2-label.component.ts
2094
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2095
- */
2096
- class Select2Label {
2097
- }
2098
- Select2Label.decorators = [
2099
- { type: Directive, args: [{ selector: 'select2-label' },] }
2100
- ];
2101
-
2102
- /**
2103
- * @fileoverview added by tsickle
2104
- * Generated from: lib/select2.module.ts
2105
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2106
- */
2107
- class Select2Module {
2108
- }
2109
- Select2Module.decorators = [
2110
- { type: NgModule, args: [{
2111
- imports: [CommonModule, FormsModule, OverlayModule, ReactiveFormsModule, InfiniteScrollModule],
2112
- declarations: [Select2Hint, Select2Label, Select2],
2113
- exports: [FormsModule, ReactiveFormsModule, Select2Hint, Select2Label, Select2],
2114
- },] }
2115
- ];
2116
-
2117
- /**
2118
- * @fileoverview added by tsickle
2119
- * Generated from: public_api.ts
2120
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2121
- */
2122
-
2123
- /**
2124
- * @fileoverview added by tsickle
2125
- * Generated from: ng-select2-component.ts
2126
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2127
- */
2128
-
2129
- export { Select2, Select2Hint, Select2Label, Select2Module, Select2Utils, defaultMinCountForSearch, protectRegexp, timeout, unicodePatterns };
2130
- //# sourceMappingURL=ng-select2-component.js.map