ngx-dropdown-list 1.1.2 → 21.0.1

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