ngx-dropdown-list 1.1.2 → 1.2.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 (66) hide show
  1. package/README.md +2 -2
  2. package/esm2020/ngx-dropdown-list.mjs +5 -0
  3. package/esm2020/public_api.mjs +2 -0
  4. package/esm2020/src/ngx-dropdown-list/anchor/anchor.component.mjs +149 -0
  5. package/esm2020/src/ngx-dropdown-list/dropdown/dropdown.component.mjs +252 -0
  6. package/esm2020/src/ngx-dropdown-list/dropdown-list.component.mjs +233 -0
  7. package/esm2020/src/ngx-dropdown-list/dropdown-list.module.mjs +38 -0
  8. package/esm2020/src/ngx-dropdown-list/filter/input-filter.component.mjs +44 -0
  9. package/esm2020/src/ngx-dropdown-list/group-item/group-item.component.mjs +25 -0
  10. package/esm2020/src/ngx-dropdown-list/index.mjs +3 -0
  11. package/esm2020/src/ngx-dropdown-list/item/item.component.mjs +77 -0
  12. package/esm2020/src/ngx-dropdown-list/types/index.mjs +3 -0
  13. package/esm2020/src/ngx-dropdown-list/types/selection-group-items.types.mjs +2 -0
  14. package/esm2020/src/ngx-dropdown-list/types/selection-item.types.mjs +2 -0
  15. package/esm2020/src/ngx-dropdown-list/utils/util.mjs +59 -0
  16. package/fesm2015/ngx-dropdown-list.mjs +854 -0
  17. package/fesm2015/ngx-dropdown-list.mjs.map +1 -0
  18. package/fesm2020/ngx-dropdown-list.mjs +854 -0
  19. package/fesm2020/ngx-dropdown-list.mjs.map +1 -0
  20. package/ngx-dropdown-list.d.ts +1 -5
  21. package/package.json +26 -48
  22. package/src/ngx-dropdown-list/anchor/anchor.component.d.ts +6 -3
  23. package/src/ngx-dropdown-list/dropdown/dropdown.component.d.ts +5 -2
  24. package/src/ngx-dropdown-list/dropdown-list.component.d.ts +7 -4
  25. package/src/ngx-dropdown-list/dropdown-list.module.d.ts +12 -0
  26. package/src/ngx-dropdown-list/filter/input-filter.component.d.ts +3 -0
  27. package/src/ngx-dropdown-list/group-item/group-item.component.d.ts +3 -0
  28. package/src/ngx-dropdown-list/item/item.component.d.ts +3 -0
  29. package/bundles/ngx-dropdown-list.umd.js +0 -1212
  30. package/bundles/ngx-dropdown-list.umd.js.map +0 -1
  31. package/bundles/ngx-dropdown-list.umd.min.js +0 -2
  32. package/bundles/ngx-dropdown-list.umd.min.js.map +0 -1
  33. package/esm2015/ngx-dropdown-list.js +0 -14
  34. package/esm2015/public_api.js +0 -6
  35. package/esm2015/src/ngx-dropdown-list/anchor/anchor.component.js +0 -226
  36. package/esm2015/src/ngx-dropdown-list/dropdown/dropdown.component.js +0 -351
  37. package/esm2015/src/ngx-dropdown-list/dropdown-list.component.js +0 -290
  38. package/esm2015/src/ngx-dropdown-list/dropdown-list.module.js +0 -32
  39. package/esm2015/src/ngx-dropdown-list/filter/input-filter.component.js +0 -64
  40. package/esm2015/src/ngx-dropdown-list/group-item/group-item.component.js +0 -37
  41. package/esm2015/src/ngx-dropdown-list/index.js +0 -7
  42. package/esm2015/src/ngx-dropdown-list/item/item.component.js +0 -104
  43. package/esm2015/src/ngx-dropdown-list/types/index.js +0 -7
  44. package/esm2015/src/ngx-dropdown-list/types/selection-group-items.types.js +0 -16
  45. package/esm2015/src/ngx-dropdown-list/types/selection-item.types.js +0 -20
  46. package/esm2015/src/ngx-dropdown-list/utils/util.js +0 -101
  47. package/esm5/ngx-dropdown-list.js +0 -14
  48. package/esm5/public_api.js +0 -6
  49. package/esm5/src/ngx-dropdown-list/anchor/anchor.component.js +0 -272
  50. package/esm5/src/ngx-dropdown-list/dropdown/dropdown.component.js +0 -420
  51. package/esm5/src/ngx-dropdown-list/dropdown-list.component.js +0 -361
  52. package/esm5/src/ngx-dropdown-list/dropdown-list.module.js +0 -36
  53. package/esm5/src/ngx-dropdown-list/filter/input-filter.component.js +0 -79
  54. package/esm5/src/ngx-dropdown-list/group-item/group-item.component.js +0 -47
  55. package/esm5/src/ngx-dropdown-list/index.js +0 -7
  56. package/esm5/src/ngx-dropdown-list/item/item.component.js +0 -120
  57. package/esm5/src/ngx-dropdown-list/types/index.js +0 -7
  58. package/esm5/src/ngx-dropdown-list/types/selection-group-items.types.js +0 -16
  59. package/esm5/src/ngx-dropdown-list/types/selection-item.types.js +0 -20
  60. package/esm5/src/ngx-dropdown-list/utils/util.js +0 -124
  61. package/fesm2015/ngx-dropdown-list.js +0 -930
  62. package/fesm2015/ngx-dropdown-list.js.map +0 -1
  63. package/fesm5/ngx-dropdown-list.js +0 -1177
  64. package/fesm5/ngx-dropdown-list.js.map +0 -1
  65. package/ngx-dropdown-list-1.1.2.tgz +0 -0
  66. package/ngx-dropdown-list.metadata.json +0 -1
@@ -1,930 +0,0 @@
1
- import { FormsModule } from '@angular/forms';
2
- import { DecimalPipe, CommonModule } from '@angular/common';
3
- import { Component, ElementRef, EventEmitter, Input, Output, ViewChild, NgModule } from '@angular/core';
4
-
5
- /**
6
- * @fileoverview added by tsickle
7
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
8
- */
9
- /**
10
- * check whether the provided items contains group
11
- * @param {?} items
12
- * @return {?}
13
- */
14
- function hasGroup(items) {
15
- return items ? (items.find((/**
16
- * @param {?} item
17
- * @return {?}
18
- */
19
- item => item.group)) != null) : false;
20
- }
21
- /**
22
- * clear all selections from the provide items.
23
- * @param {?} items the dropdown items, can be group or item
24
- * @return {?}
25
- */
26
- function clearAllSelection(items) {
27
- if (hasGroup(items)) {
28
- for (const groupItem of items) {
29
- if (groupItem.items) {
30
- groupItem.items.filter((/**
31
- * @param {?} item
32
- * @return {?}
33
- */
34
- item => item.selected)).forEach((/**
35
- * @param {?} item
36
- * @return {?}
37
- */
38
- item => item.selected = false));
39
- }
40
- }
41
- }
42
- else {
43
- // clear the selection of previous selected item
44
- items.filter((/**
45
- * @param {?} item
46
- * @return {?}
47
- */
48
- item => item.selected)).forEach((/**
49
- * @param {?} item
50
- * @return {?}
51
- */
52
- item => item.selected = false));
53
- }
54
- }
55
- /**
56
- * stop all propagation and default actions
57
- * @param {?} event
58
- * @return {?}
59
- */
60
- function stopPropagationAndDefault(event) {
61
- event.stopImmediatePropagation();
62
- event.stopPropagation();
63
- event.preventDefault();
64
- }
65
- /**
66
- * check whether the provided value is number of not
67
- * @param {?} value
68
- * @return {?}
69
- */
70
- function isNumber(value) {
71
- return !(value == null || isNaN(value) || value.length === 0);
72
- }
73
- /**
74
- * get the selected item from the items list (including item and group)
75
- * @param {?} items
76
- * @return {?}
77
- */
78
- function getFirstSelectedItem(items) {
79
- if (!items) {
80
- return undefined;
81
- }
82
- /** @type {?} */
83
- let selectedItem;
84
- if (hasGroup(items)) {
85
- for (const item of items) {
86
- selectedItem = item.items ? item.items.find((/**
87
- * @param {?} subItem
88
- * @return {?}
89
- */
90
- subItem => subItem.selected)) : undefined;
91
- if (selectedItem) {
92
- break;
93
- }
94
- }
95
- }
96
- else {
97
- selectedItem = items ? items.find((/**
98
- * @param {?} item
99
- * @return {?}
100
- */
101
- item => item.selected)) : undefined;
102
- }
103
- return selectedItem;
104
- }
105
-
106
- /**
107
- * @fileoverview added by tsickle
108
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
109
- */
110
- class DropdownListComponent {
111
- constructor() {
112
- /**
113
- * bind to [multiSelection], the flag for multi-select (checkbox) mode.
114
- */
115
- this.multiSelection = false;
116
- /**
117
- * bind to [filterBox] for displaying the filter input text box
118
- */
119
- this.filterBox = false;
120
- /**
121
- * bind to [allowClear] for enabling the clearance (clearance is not avaiable when checkbox is enabled)
122
- */
123
- this.allowClear = true;
124
- /**
125
- * bind to [formatNumber] for show formatted number text
126
- */
127
- this.formatNumber = false;
128
- /**
129
- * for 2-way binding of [selectedValue], using async event to
130
- * prevent "ExpressionChangedAfterItHasBeenCheckedError".
131
- */
132
- this.selectedValueChange = new EventEmitter(true);
133
- /**
134
- * [selectionChange] event that will be triggered when changing of the selection.
135
- * Using async event to prevent "ExpressionChangedAfterItHasBeenCheckedError".
136
- */
137
- this.selectionChange = new EventEmitter(true);
138
- /**
139
- * visibility flag of drop down
140
- */
141
- this.dropdownVisibility = false;
142
- }
143
- /**
144
- * current selected text
145
- * @return {?}
146
- */
147
- get selectedText() {
148
- if (!this.multiSelection) {
149
- /** @type {?} */
150
- const selectedItem = getFirstSelectedItem(this.items);
151
- return selectedItem ? selectedItem.text : undefined;
152
- }
153
- }
154
- /**
155
- * triggered with (selectionChange) event, emits (selectedValueChange) and (selectionChange)
156
- * @param {?} event
157
- * @return {?}
158
- */
159
- onSelectionChange(event) {
160
- this.selectedValueChange.emit(event);
161
- this.selectionChange.emit(event);
162
- }
163
- /**
164
- * triggered with (anchorClick) event, controlling the "open" and "close" of the dropdown
165
- * @param {?} event
166
- * @return {?}
167
- */
168
- onAnchorClick(event) {
169
- if (this.disabled) {
170
- stopPropagationAndDefault(event);
171
- return;
172
- }
173
- if (this._isSelectionOpen()) {
174
- this._hideItemList();
175
- }
176
- else {
177
- this._showItemsList();
178
- }
179
- stopPropagationAndDefault(event);
180
- }
181
- /**
182
- * triggered with (itemClick) event, closes the dropdown in non-checkbox mode
183
- * @return {?}
184
- */
185
- onItemClick() {
186
- if (!this.multiSelection) {
187
- this._hideItemList();
188
- }
189
- }
190
- /**
191
- * triggered with (clearanceClick) event, clearing all selections
192
- * and emits (selectedValueChange) and (selectionChange) event for empty value
193
- * @param {?} event
194
- * @return {?}
195
- */
196
- onClearanceClick(event) {
197
- if (!this.multiSelection) {
198
- this.selectedValue = void 0;
199
- this.selectedValueChange.emit(undefined);
200
- this.selectionChange.emit(undefined);
201
- clearAllSelection(this.items);
202
- }
203
- stopPropagationAndDefault(event);
204
- }
205
- /**
206
- * triggered with (dropdownBlur) event, closes the dropdown
207
- * @return {?}
208
- */
209
- onItemsBlur() {
210
- if (this._isSelectionOpen()) {
211
- this._hideItemList();
212
- }
213
- }
214
- /**
215
- * close the dropdown
216
- * @private
217
- * @return {?}
218
- */
219
- _hideItemList() {
220
- // hide the dropdown element (has some problem for using CSS directly, using this as a workaround)
221
- this._dropdownElement.classList.remove('visible');
222
- this._dropdownElement.style.display = 'none';
223
- this.dropdownVisibility = false;
224
- }
225
- /**
226
- * open the dropdown
227
- * @private
228
- * @return {?}
229
- */
230
- _showItemsList() {
231
- // display the dropdown element (has some problem for using CSS directly, using this as a workaround)
232
- this._dropdownElement.classList.add('visible');
233
- this._dropdownElement.style.display = 'block';
234
- this.dropdownVisibility = true;
235
- // scrolling to the selected item
236
- if (this._selectedElement) {
237
- this._selectedElement.scrollIntoView({ behavior: 'instant', block: 'center' });
238
- }
239
- // setting the focus
240
- if (this.filterBox && !this.multiSelection) {
241
- this._filterInputElement.focus();
242
- }
243
- else {
244
- this._dropdownElement.focus();
245
- }
246
- }
247
- /**
248
- * visibility status of dropdown
249
- * @private
250
- * @return {?}
251
- */
252
- _isSelectionOpen() {
253
- return this.dropdownVisibility;
254
- }
255
- /**
256
- * get the real dropdown element (for focusing and visibility controlling), the <span> not the <dropdown>
257
- * @private
258
- * @return {?}
259
- */
260
- get _dropdownElement() {
261
- return this.dropdownRef ? this.dropdownRef.nativeElement ? this.dropdownRef.nativeElement.firstElementChild : null : null;
262
- }
263
- /**
264
- * get the real filter element (for focusing), the <input> not the <input-filter>
265
- * @private
266
- * @return {?}
267
- */
268
- get _filterInputElement() {
269
- return this._dropdownElement ?
270
- this._dropdownElement.firstElementChild ? this._dropdownElement.firstElementChild.firstElementChild : null : null;
271
- }
272
- /**
273
- * get the HTMLElement of selected item, for doing (scrollIntoView) scrolling to the selected item
274
- * @private
275
- * @return {?}
276
- */
277
- get _selectedElement() {
278
- /** @type {?} */
279
- const selectedItem = getFirstSelectedItem(this.items);
280
- return selectedItem ? (/** @type {?} */ (document.getElementById(selectedItem.id))) : undefined;
281
- }
282
- }
283
- DropdownListComponent.decorators = [
284
- { type: Component, args: [{
285
- selector: 'ngx-dropdown-list',
286
- template: `
287
- <span class="ngx-select">
288
- <anchor (anchorClick)="onAnchorClick($event)" (clearanceClick)="onClearanceClick($event)"
289
- [checkbox]="multiSelection"
290
- [formatNumber]="formatNumber"
291
- [suffixText]="suffixText"
292
- [placeHolder]="placeHolder"
293
- [allowClear]="allowClear"
294
- [openStatus]="dropdownVisibility"
295
- [selectedText]="selectedText"
296
- [disabled]="disabled">
297
- </anchor>
298
- <dropdown #dropdown (dropdownBlur) = "onItemsBlur()" (selectionChange)="onSelectionChange($event)"
299
- [items]="items"
300
- [checkbox]="multiSelection"
301
- [filterBox]="filterBox"
302
- [formatNumber]="formatNumber"
303
- [suffixText]="suffixText"
304
- [(selectedValue)]="selectedValue"
305
- (itemClick) = "onItemClick()"
306
- [disabled]="disabled">
307
- </dropdown>
308
- </span>
309
- `,
310
- styles: [":host *,:host :after,:host :before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}:host .ngx-select{border-radius:4px;font-size:14px;position:relative;display:inline-block;width:100%;height:34px;background:#fff;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}"]
311
- }] }
312
- ];
313
- DropdownListComponent.propDecorators = {
314
- dropdownRef: [{ type: ViewChild, args: ['dropdown', { read: ElementRef },] }],
315
- placeHolder: [{ type: Input }],
316
- items: [{ type: Input }],
317
- multiSelection: [{ type: Input }],
318
- selectedValue: [{ type: Input }],
319
- filterBox: [{ type: Input }],
320
- suffixText: [{ type: Input }],
321
- disabled: [{ type: Input }],
322
- allowClear: [{ type: Input }],
323
- formatNumber: [{ type: Input }],
324
- selectedValueChange: [{ type: Output }],
325
- selectionChange: [{ type: Output }]
326
- };
327
-
328
- /**
329
- * @fileoverview added by tsickle
330
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
331
- */
332
- class ItemComponent {
333
- constructor() {
334
- /**
335
- * bind to [formatNumber], the flag for formatting the number
336
- */
337
- this.formatNumber = false;
338
- /**
339
- * bind to [itemClick] event, triggers when clicking the item of dropdown
340
- */
341
- this.itemClick = new EventEmitter();
342
- /**
343
- * bind to [checkStatusChange] event, triggers when check status is changed in checkbox mode.
344
- */
345
- this.checkStatusChange = new EventEmitter();
346
- }
347
- /**
348
- * check whether needs to format number for the provided text
349
- * @param {?} value
350
- * @return {?}
351
- */
352
- needFormatNumber(value) {
353
- return isNumber(value) && this.formatNumber;
354
- }
355
- /**
356
- * triggered when clicking the item, emits the [itemClick] event
357
- * @param {?} item
358
- * @return {?}
359
- */
360
- onItemClick(item) {
361
- this.itemClick.emit(item);
362
- }
363
- /**
364
- * triggered when checking status changed in checkbox mode, emits the [checkStatusChange] event
365
- * @param {?} item
366
- * @return {?}
367
- */
368
- onCheckStatusChange(item) {
369
- this.checkStatusChange.emit(item);
370
- }
371
- }
372
- ItemComponent.decorators = [
373
- { type: Component, args: [{
374
- selector: 'item',
375
- template: `
376
- <label [class.container-checkbox]="checkbox"
377
- [class.container-selection]="!checkbox && !item.selected"
378
- [class.container-selection-selected]="!checkbox && item.selected"
379
- [id]="item.id" (mousedown)="onItemClick(item)">
380
- {{needFormatNumber(item.text)? (item.text | number:'1.0-2') : item.text}}{{suffixText? suffixText : ''}}
381
- <ng-container *ngIf="checkbox">
382
- <input type='checkbox' [id]="'checkbox-'+item.text" (change)="onCheckStatusChange(item)" [checked]="item.selected">
383
- <span class="checkmark" [id]="'checkmark-'+item.text"></span>
384
- </ng-container>
385
- </label>`,
386
- styles: ["*,:after,:before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}.container-checkbox,.container-selection,.container-selection-selected,.dropdown-item{background:0 0;display:list-item;list-style:none;position:relative;width:100%;height:auto;cursor:pointer;color:#495057;padding-bottom:5px;padding-top:5px;padding-left:12px}.container-checkbox{padding-left:35px}.container-checkbox input{position:absolute;opacity:0;cursor:pointer}.container-checkbox .checkmark{position:absolute;top:5px;left:10px;height:15px;width:15px;border:1px solid rgba(0,0,0,.3);background-color:#fff;border-radius:4px}.container-checkbox .checkmark:after{content:\"\";position:absolute;display:none;left:5px;top:2px;width:4px;height:7px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}.container-checkbox:hover input~.checkmark{background-color:#ccc}.container-checkbox input:checked~.checkmark{background-color:#2196f3;border:1px solid #2196f3}.container-checkbox input:checked~.checkmark:after{display:block}.container-checkbox:hover{color:#66afe9}.container-selection,.container-selection-selected{padding-left:12px}.container-selection-selected:hover,.container-selection:hover{color:#495057;background:#e0ffff}.container-selection-selected{color:#fff;background:#6495ed}"]
387
- }] }
388
- ];
389
- ItemComponent.propDecorators = {
390
- checkbox: [{ type: Input }],
391
- item: [{ type: Input }],
392
- formatNumber: [{ type: Input }],
393
- suffixText: [{ type: Input }],
394
- itemClick: [{ type: Output }],
395
- checkStatusChange: [{ type: Output }]
396
- };
397
-
398
- /**
399
- * @fileoverview added by tsickle
400
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
401
- */
402
- class GroupItemComponent {
403
- /**
404
- * prevent all clicking event from happening
405
- * @param {?} event
406
- * @return {?}
407
- */
408
- onItemGroupClick(event) {
409
- event.stopImmediatePropagation();
410
- event.stopPropagation();
411
- event.preventDefault();
412
- }
413
- }
414
- GroupItemComponent.decorators = [
415
- { type: Component, args: [{
416
- selector: 'group-item',
417
- template: `
418
- <label class="dropdown-item dropdown-item-group" (mousedown)="onItemGroupClick($event)">{{item.group}}</label>
419
- `,
420
- styles: ["*,:after,:before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}.container-checkbox,.container-selection,.container-selection-selected,.dropdown-item{background:0 0;display:list-item;list-style:none;position:relative;width:100%;height:auto;cursor:pointer;color:#495057;padding-bottom:5px;padding-top:5px;padding-left:12px}.container-checkbox{padding-left:35px}.container-checkbox input{position:absolute;opacity:0;cursor:pointer}.container-checkbox .checkmark{position:absolute;top:5px;left:10px;height:15px;width:15px;border:1px solid rgba(0,0,0,.3);background-color:#fff;border-radius:4px}.container-checkbox .checkmark:after{content:\"\";position:absolute;display:none;left:5px;top:2px;width:4px;height:7px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}.container-checkbox:hover input~.checkmark{background-color:#ccc}.container-checkbox input:checked~.checkmark{background-color:#2196f3;border:1px solid #2196f3}.container-checkbox input:checked~.checkmark:after{display:block}.container-checkbox:hover{color:#66afe9}.container-selection,.container-selection-selected{padding-left:12px}.container-selection-selected:hover,.container-selection:hover{color:#495057;background:#e0ffff}.container-selection-selected{color:#fff;background:#6495ed}.dropdown-item-group{font-weight:700}.dropdown-item-group:hover{cursor:default}"]
421
- }] }
422
- ];
423
- GroupItemComponent.propDecorators = {
424
- item: [{ type: Input }]
425
- };
426
-
427
- /**
428
- * @fileoverview added by tsickle
429
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
430
- */
431
- class InputFilterComponent {
432
- constructor() {
433
- /**
434
- * bind to [inputFilterBlur], emits with (blur) of filter input box
435
- */
436
- this.inputFilterBlur = new EventEmitter();
437
- /**
438
- * bind to [filterValueChange], for 2-way binding of filterValue
439
- */
440
- this.filterValueChange = new EventEmitter();
441
- }
442
- /**
443
- * triggers with (blur) event, emits the (inputFilterBlur) event
444
- * @param {?} event
445
- * @return {?}
446
- */
447
- onFilterTextBlur(event) {
448
- this.inputFilterBlur.emit(event);
449
- }
450
- /**
451
- * triggers with (input) event, emits the (filterValueChange) event for 2-way binding of filterValue
452
- * @return {?}
453
- */
454
- onChange() {
455
- this.filterValueChange.emit(this.filterValue);
456
- }
457
- }
458
- InputFilterComponent.decorators = [
459
- { type: Component, args: [{
460
- selector: 'input-filter',
461
- template: `
462
- <input type="text" class="filter-box" [(ngModel)]="filterValue" (input)="onChange()" (blur)="onFilterTextBlur($event)">
463
- `,
464
- styles: ["*,:after,:before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}.filter-box{width:calc(100% - 10px);height:28px;border-radius:4px;border:1px solid #ccc;margin:1px 5px 5px;padding-left:5px;font-size:12px;box-sizing:border-box;color:#495057}.filter-box:focus{outline:0;border-color:#ccc}"]
465
- }] }
466
- ];
467
- InputFilterComponent.propDecorators = {
468
- filterValue: [{ type: Input }],
469
- inputFilterBlur: [{ type: Output }],
470
- filterValueChange: [{ type: Output }]
471
- };
472
-
473
- /**
474
- * @fileoverview added by tsickle
475
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
476
- */
477
- class AnchorComponent {
478
- /**
479
- * @param {?} _decimalPipe
480
- */
481
- constructor(_decimalPipe) {
482
- this._decimalPipe = _decimalPipe;
483
- /**
484
- * bind to [checkbox] for checking whether the clearance flag should be shown or not.
485
- */
486
- this.checkbox = false;
487
- /**
488
- * bind to [allowClear] for enabling the clearance (clearance is not avaiable when checkbox is enabled)
489
- */
490
- this.allowClear = true;
491
- /**
492
- * bind to [openStatus], it's the visibility status of dropdown, for showing the arrow on anchor
493
- */
494
- this.openStatus = false;
495
- /**
496
- * bind to [disabled] for disabling the anchor
497
- */
498
- this.disabled = false;
499
- /**
500
- * will be triggered when clicking the anchor
501
- */
502
- this.anchorClick = new EventEmitter();
503
- /**
504
- * will be triggered when clicking the clearance
505
- */
506
- this.clearanceClick = new EventEmitter();
507
- }
508
- /**
509
- * flag for showing the clearance flag
510
- * @return {?}
511
- */
512
- get showClearanceFlag() {
513
- return !this.checkbox && this.selectedText && this.allowClear;
514
- }
515
- /**
516
- * the text displays on anchor
517
- * @return {?}
518
- */
519
- get anchorDisplayText() {
520
- /** @type {?} */
521
- let anchorDisplayText = this.selectedText ? (this.formatNumber ? (isNumber(this.selectedText) ?
522
- this._decimalPipe.transform(this.selectedText, '1.0-2') : this.selectedText) :
523
- this.selectedText) + (this.suffixText ? this.suffixText : '') : this.placeHolder;
524
- /** @type {?} */
525
- let charLength = 1;
526
- if (this.showClearanceFlag && this.anchorLength > 0) {
527
- charLength = Math.floor((this.anchorLength - 50) / 7);
528
- }
529
- else {
530
- charLength = Math.floor((this.anchorLength - 50) / 7);
531
- }
532
- if (anchorDisplayText.length > charLength) {
533
- anchorDisplayText = anchorDisplayText.slice(0, charLength - 2) + '...';
534
- }
535
- return anchorDisplayText;
536
- }
537
- /**
538
- * anchor CSS class
539
- * @return {?}
540
- */
541
- get anchorClass() {
542
- /** @type {?} */
543
- let anchorClassStatusPart;
544
- /** @type {?} */
545
- let anchorClassFontColor;
546
- if (this.disabled) {
547
- anchorClassStatusPart = 'selection-anchor-disabled';
548
- anchorClassFontColor = 'place-holder';
549
- }
550
- else {
551
- if (this.openStatus) {
552
- anchorClassStatusPart = 'selection-anchor-open';
553
- }
554
- else {
555
- anchorClassStatusPart = 'selection-anchor-close';
556
- }
557
- if (this.selectedText != null) {
558
- anchorClassFontColor = 'selected-item';
559
- }
560
- else {
561
- anchorClassFontColor = 'place-holder';
562
- }
563
- }
564
- return `${anchorClassStatusPart} ${anchorClassFontColor}`;
565
- }
566
- /**
567
- * triggered when clicking the anchor
568
- * @param {?} event
569
- * @return {?}
570
- */
571
- onAnchorClick(event) {
572
- this.anchorClick.emit(event);
573
- }
574
- /**
575
- * triggered with (blur) of anchor
576
- * @param {?} event
577
- * @return {?}
578
- */
579
- onAnchorBlur(event) {
580
- stopPropagationAndDefault(event);
581
- }
582
- /**
583
- * triggered when clicking the clearance
584
- * @param {?} event
585
- * @return {?}
586
- */
587
- onClearanceClick(event) {
588
- this.clearanceClick.emit(event);
589
- }
590
- /**
591
- * triggered when resizing, get the clientWidth of anchor
592
- * @return {?}
593
- */
594
- onResize() {
595
- this.anchorLength = this.anchorRef ? this.anchorRef.nativeElement ? this.anchorRef.nativeElement.clientWidth : 0 : 0;
596
- }
597
- }
598
- AnchorComponent.decorators = [
599
- { type: Component, args: [{
600
- selector: 'anchor',
601
- template: `
602
- <span #anchor tabindex="2" [ngClass]="anchorClass" (window:resize)="onResize()"
603
- (mousedown)="onAnchorClick($event)" (blur)="onAnchorBlur($event)"> {{anchorDisplayText}}
604
- <span #selectionClearance class="selection-clearance" (mousedown)="onClearanceClick($event)" *ngIf="showClearanceFlag">&times;</span>
605
- </span>
606
- `,
607
- providers: [DecimalPipe],
608
- styles: ["*,:after,:before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}.selection-anchor-close:after,.selection-anchor-disabled:after,.selection-anchor-open:after,.vertical-center{position:absolute;top:50%;transform:translateY(-50%)}.hover-box,.selection-anchor-close:hover{outline:0;box-shadow:0 0 6px #23adff;border-radius:4px}.anchor-box,.selection-anchor,.selection-anchor-close,.selection-anchor-disabled,.selection-anchor-open{height:100%;border-radius:4px;width:100%;position:relative;display:inline-block;padding:8px 12px 5px;border:1px solid;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-sizing:border-box;white-space:nowrap}.selection-anchor,.selection-anchor-close,.selection-anchor-open{cursor:pointer}.selection-anchor .selection-clearance,.selection-anchor-close .selection-clearance,.selection-anchor-open .selection-clearance{position:absolute;right:35px;font-weight:700}.selection-anchor .selection-clearance:hover,.selection-anchor-close .selection-clearance:hover,.selection-anchor-open .selection-clearance:hover{color:#000}.selection-anchor-close:focus,.selection-anchor-open:focus,.selection-anchor:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;border-color:#66afe9}.selection-anchor-disabled{border-color:#ccc;cursor:default;pointer-events:none;background:#f8f8f8;filter:opacity(50%)}.selection-anchor-disabled:after{font-size:9px;content:'\\0025BC';right:10px;padding-bottom:3px}.selection-anchor-open{border-bottom:none;border-bottom-right-radius:0;border-bottom-left-radius:0;border-color:#66afe9}.selection-anchor-open:after{font-size:9px;content:'\\0025B2';right:10px;padding-bottom:3px}.selection-anchor-close{border-color:#ccc}.selection-anchor-close:after{font-size:9px;content:'\\0025BC';right:10px;padding-bottom:3px}.place-holder{color:#999}.selected-item{color:#495057}"]
609
- }] }
610
- ];
611
- /** @nocollapse */
612
- AnchorComponent.ctorParameters = () => [
613
- { type: DecimalPipe }
614
- ];
615
- AnchorComponent.propDecorators = {
616
- anchorRef: [{ type: ViewChild, args: ['anchor', { read: ElementRef },] }],
617
- placeHolder: [{ type: Input }],
618
- checkbox: [{ type: Input }],
619
- suffixText: [{ type: Input }],
620
- allowClear: [{ type: Input }],
621
- formatNumber: [{ type: Input }],
622
- selectedText: [{ type: Input }],
623
- openStatus: [{ type: Input }],
624
- disabled: [{ type: Input }],
625
- anchorClick: [{ type: Output }],
626
- clearanceClick: [{ type: Output }]
627
- };
628
-
629
- /**
630
- * @fileoverview added by tsickle
631
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
632
- */
633
- class DropdownComponent {
634
- constructor() {
635
- /**
636
- * bind to [checkbox], the flag for multi-select (checkbox) mode.
637
- */
638
- this.checkbox = false;
639
- /**
640
- * bind to [filterBox] for displaying the filter input text box
641
- */
642
- this.filterBox = false;
643
- /**
644
- * bind to [allowClear] for enabling the clearance (clearance is not avaiable when checkbox is enabled)
645
- */
646
- this.allowClear = true;
647
- /**
648
- * bind to [formatNumber] for show formatted number text
649
- */
650
- this.formatNumber = false;
651
- /**
652
- * for 2-way binding of [selectedValue]
653
- */
654
- this.selectedValueChange = new EventEmitter(true);
655
- /**
656
- * [selectionChange] event that will be triggered when changing of the selection
657
- */
658
- this.selectionChange = new EventEmitter(true);
659
- /**
660
- * [dropdownBlur] event that will be triggered with (blur) of dropdown
661
- */
662
- this.dropdownBlur = new EventEmitter();
663
- /**
664
- * [itemClick] event that will be triggered when clicking the option of dropdown
665
- */
666
- this.itemClick = new EventEmitter();
667
- /**
668
- * flag of clicking dropdown. It's to prevent (blur) of dropdown from happening in checkbox mode.
669
- */
670
- this._clickedItems = false;
671
- }
672
- /**
673
- * @param {?} changes
674
- * @return {?}
675
- */
676
- ngOnChanges(changes) {
677
- if (changes.items) {
678
- this._checkSelectionChange(changes.items.previousValue, changes.items.currentValue);
679
- }
680
- }
681
- /**
682
- * triggered when clicking the dropdown
683
- * @param {?} event
684
- * @return {?}
685
- */
686
- onItemsClick(event) {
687
- if (event.offsetX > (event.target.clientWidth + event.target.clientLeft)) {
688
- stopPropagationAndDefault(event);
689
- return;
690
- }
691
- // should ignore clicking on filter
692
- if (this.checkbox && event.target.type !== 'text') {
693
- this._clickedItems = true;
694
- }
695
- }
696
- /**
697
- * triggered when clicking the item
698
- * @param {?} currentItem
699
- * @return {?}
700
- */
701
- onItemClick(currentItem) {
702
- if (!this.checkbox) {
703
- this.selectedValue = this._getItemValue(currentItem); // currentItem.value != null ? currentItem.value : currentItem.text;
704
- clearAllSelection(this.items);
705
- // set the selection of current one
706
- currentItem.selected = true;
707
- this.itemClick.emit(currentItem);
708
- this._onSelectionChange(this.selectedValue);
709
- }
710
- }
711
- /**
712
- * triggers with (blur) event of filter input box
713
- * @param {?} event
714
- * @return {?}
715
- */
716
- onFilterTextBlur(event) {
717
- this.dropdownBlur.emit(event);
718
- }
719
- /**
720
- * triggers with (blur) event of dropdown
721
- * @param {?} event
722
- * @return {?}
723
- */
724
- onItemsBlur(event) {
725
- if (this.checkbox) {
726
- if (this._clickedItems) {
727
- // in checkbox mode, this blur event will be ignored when clicking the dropdown (check the checkbox)
728
- event.target.focus();
729
- this._clickedItems = false;
730
- return;
731
- }
732
- }
733
- this.dropdownBlur.emit(event);
734
- }
735
- /**
736
- * toggle the selection when checking status changed (in checkbox mode)
737
- * @param {?} item
738
- * @return {?}
739
- */
740
- toggleSelection(item) {
741
- item.selected = !item.selected;
742
- this.selectionChange.emit(this._getItemValue(item)); // item.value != null ? item.value : item.text);
743
- }
744
- /**
745
- * items values list after applying the filter
746
- * @return {?}
747
- */
748
- get itemsValues() {
749
- /** @type {?} */
750
- let filter;
751
- if (this.filterValue) {
752
- filter = this.filterValue.toUpperCase();
753
- }
754
- if (filter == null) {
755
- return this.items;
756
- }
757
- if (!this.items || this.items.length === 0) {
758
- return [];
759
- }
760
- if (hasGroup(this.items)) {
761
- /** @type {?} */
762
- const items = [];
763
- this.items.forEach((/**
764
- * @param {?} groupItem
765
- * @return {?}
766
- */
767
- groupItem => {
768
- if (groupItem.group != null && groupItem.group.toString().toUpperCase().includes(filter)) {
769
- // if groupItem contains the filters, the groupItem needs to be displayed as well
770
- items.push(groupItem);
771
- }
772
- else {
773
- /** @type {?} */
774
- const filteredItems = groupItem.items.filter((/**
775
- * @param {?} item
776
- * @return {?}
777
- */
778
- item => item.text != null && item.text.toString().toUpperCase().includes(filter)));
779
- if (filteredItems && filteredItems.length > 0) {
780
- items.push({ group: groupItem.group, items: filteredItems });
781
- }
782
- }
783
- }));
784
- return items;
785
- }
786
- else {
787
- return this.items.filter((/**
788
- * @param {?} item
789
- * @return {?}
790
- */
791
- item => (item.text != null && item.text.toString().toUpperCase().includes(filter))));
792
- }
793
- }
794
- /**
795
- * options CSS class
796
- * @return {?}
797
- */
798
- get optionsClass() {
799
- if (this.filterBox && !this.checkbox) {
800
- return 'options with-filter';
801
- }
802
- else {
803
- return 'options no-filter';
804
- }
805
- }
806
- /**
807
- * get item value. Return text if value is not available
808
- * @private
809
- * @param {?} item
810
- * @return {?}
811
- */
812
- _getItemValue(item) {
813
- return item ? item.value != null ? item.value : item.text : undefined;
814
- }
815
- /**
816
- * selection changed, emits events: (selectedValueChange) and (selectionChange);
817
- * @private
818
- * @param {?} value
819
- * @return {?}
820
- */
821
- _onSelectionChange(value) {
822
- this.selectedValueChange.emit(value);
823
- this.selectionChange.emit(value);
824
- }
825
- /**
826
- * check whether the selection is changed. Emits relative events when if changed.
827
- * @private
828
- * @param {?} previousValue
829
- * @param {?} currentValue
830
- * @return {?}
831
- */
832
- _checkSelectionChange(previousValue, currentValue) {
833
- /** @type {?} */
834
- const curSelectedItem = getFirstSelectedItem(currentValue);
835
- /** @type {?} */
836
- const lastSelectedItem = getFirstSelectedItem(previousValue);
837
- /** @type {?} */
838
- const curSelectedItemId = curSelectedItem ? curSelectedItem.id : undefined;
839
- /** @type {?} */
840
- const lastSelectedItemId = lastSelectedItem ? lastSelectedItem.id : undefined;
841
- if (curSelectedItemId !== lastSelectedItemId && !this.checkbox) {
842
- this._onSelectionChange(this._getItemValue(curSelectedItem));
843
- }
844
- }
845
- }
846
- DropdownComponent.decorators = [
847
- { type: Component, args: [{
848
- selector: 'dropdown',
849
- template: `
850
- <span #dropdown class="dropdown" tabindex="3" (mousedown)="onItemsClick($event)" (blur)="onItemsBlur($event)" *ngIf="!disabled" >
851
- <input-filter #filterInput tabindex="4" *ngIf="filterBox && !checkbox" [(filterValue)]="filterValue" (inputFilterBlur)="onFilterTextBlur($event)"></input-filter>
852
- <span #selectionOptions [ngClass]="optionsClass">
853
- <ng-container *ngFor="let item of itemsValues" >
854
- <ng-container *ngIf="item && item.group">
855
- <group-item [item]="item"></group-item>
856
- <item *ngFor="let subItem of item.items" (itemClick)="onItemClick(subItem)" (checkStatusChange)="toggleSelection(subItem)"
857
- [item]="subItem" [checkbox]="checkbox" [formatNumber]="formatNumber" [suffixText]="suffixText">
858
- </item>
859
- </ng-container>
860
- <ng-container *ngIf="item && !item.group">
861
- <item (itemClick)="onItemClick(item)" (checkStatusChange)="toggleSelection(item)"
862
- [item]="item" [checkbox]="checkbox" [formatNumber]="formatNumber" [suffixText]="suffixText">
863
- </item>
864
- </ng-container>
865
- </ng-container>
866
- </span>
867
- </span>
868
- `,
869
- styles: ["*,:after,:before{font-size:inherit;font-weight:inherit;font-family:inherit;box-sizing:inherit;background:inherit}.dropdown{width:100%;padding:0;display:none;margin:0;border:1px solid #66afe9;border-top:none;border-bottom:none;border-top-right-radius:0;border-top-left-radius:0;box-sizing:border-box;position:relative;z-index:999}.dropdown:focus{outline:0}.dropdown .options{width:calc(100% + 2px);left:0;box-sizing:border-box;background:#fff;position:absolute;max-height:228px;overflow-y:auto;overflow-x:hidden;border:1px solid #66afe9;border-top:none;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-left:-1px;margin-right:-1px}.dropdown .with-filter{top:32px}.dropdown .no-filter{top:0}"]
870
- }] }
871
- ];
872
- DropdownComponent.propDecorators = {
873
- dropdownRef: [{ type: ViewChild, args: ['dropdown', { read: ElementRef },] }],
874
- filterInputRef: [{ type: ViewChild, args: ['filterInput', { read: ElementRef },] }],
875
- placeHolder: [{ type: Input }],
876
- items: [{ type: Input }],
877
- checkbox: [{ type: Input }],
878
- selectedValue: [{ type: Input }],
879
- filterBox: [{ type: Input }],
880
- suffixText: [{ type: Input }],
881
- disabled: [{ type: Input }],
882
- allowClear: [{ type: Input }],
883
- formatNumber: [{ type: Input }],
884
- selectedValueChange: [{ type: Output }],
885
- selectionChange: [{ type: Output }],
886
- dropdownBlur: [{ type: Output }],
887
- itemClick: [{ type: Output }]
888
- };
889
-
890
- /**
891
- * @fileoverview added by tsickle
892
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
893
- */
894
- class DropdownListModule {
895
- }
896
- DropdownListModule.decorators = [
897
- { type: NgModule, args: [{
898
- declarations: [
899
- DropdownListComponent,
900
- ItemComponent,
901
- GroupItemComponent,
902
- InputFilterComponent,
903
- AnchorComponent,
904
- DropdownComponent
905
- ],
906
- exports: [DropdownListComponent],
907
- imports: [CommonModule, FormsModule],
908
- providers: [],
909
- bootstrap: [],
910
- },] }
911
- ];
912
-
913
- /**
914
- * @fileoverview added by tsickle
915
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
916
- */
917
-
918
- /**
919
- * @fileoverview added by tsickle
920
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
921
- */
922
-
923
- /**
924
- * @fileoverview added by tsickle
925
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
926
- */
927
-
928
- export { DropdownListComponent, DropdownListModule, AnchorComponent as ɵd, DropdownComponent as ɵe, InputFilterComponent as ɵc, GroupItemComponent as ɵb, ItemComponent as ɵa };
929
-
930
- //# sourceMappingURL=ngx-dropdown-list.js.map