@amro93/ngb-select 0.1.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.
- package/README.md +64 -0
- package/fesm2022/amro93-ngb-select.mjs +925 -0
- package/fesm2022/amro93-ngb-select.mjs.map +1 -0
- package/package.json +56 -0
- package/types/amro93-ngb-select.d.ts +221 -0
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, model, output, computed, signal, effect, forwardRef, HostListener, ViewChild, ContentChild, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
|
+
|
|
7
|
+
const NGB_SELECT_VERSION = '0.1.1';
|
|
8
|
+
|
|
9
|
+
class NgbSelectComponent {
|
|
10
|
+
elementRef;
|
|
11
|
+
cdr;
|
|
12
|
+
static VERSION = NGB_SELECT_VERSION;
|
|
13
|
+
// --- Basic & Data Inputs ---
|
|
14
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
15
|
+
optionLabel = input('label', ...(ngDevMode ? [{ debugName: "optionLabel" }] : /* istanbul ignore next */ []));
|
|
16
|
+
optionValue = input('value', ...(ngDevMode ? [{ debugName: "optionValue" }] : /* istanbul ignore next */ []));
|
|
17
|
+
optionDisabled = input('disabled', ...(ngDevMode ? [{ debugName: "optionDisabled" }] : /* istanbul ignore next */ []));
|
|
18
|
+
optionGroupLabel = input('label', ...(ngDevMode ? [{ debugName: "optionGroupLabel" }] : /* istanbul ignore next */ []));
|
|
19
|
+
optionGroupChildren = input('items', ...(ngDevMode ? [{ debugName: "optionGroupChildren" }] : /* istanbul ignore next */ []));
|
|
20
|
+
group = input(false, ...(ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []));
|
|
21
|
+
dataKey = input(undefined, ...(ngDevMode ? [{ debugName: "dataKey" }] : /* istanbul ignore next */ []));
|
|
22
|
+
placeholder = input(undefined, ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
23
|
+
// --- Multi-Select Inputs ---
|
|
24
|
+
multiple = input(false, ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
25
|
+
display = input('comma', ...(ngDevMode ? [{ debugName: "display" }] : /* istanbul ignore next */ []));
|
|
26
|
+
showSelectAll = input(false, ...(ngDevMode ? [{ debugName: "showSelectAll" }] : /* istanbul ignore next */ []));
|
|
27
|
+
maxSelectedLabels = input(3, ...(ngDevMode ? [{ debugName: "maxSelectedLabels" }] : /* istanbul ignore next */ []));
|
|
28
|
+
selectedItemsLabel = input('{0} items selected', ...(ngDevMode ? [{ debugName: "selectedItemsLabel" }] : /* istanbul ignore next */ []));
|
|
29
|
+
selectionLimit = input(undefined, ...(ngDevMode ? [{ debugName: "selectionLimit" }] : /* istanbul ignore next */ []));
|
|
30
|
+
closeOnSelect = input(false, ...(ngDevMode ? [{ debugName: "closeOnSelect" }] : /* istanbul ignore next */ []));
|
|
31
|
+
// --- Filtering Inputs ---
|
|
32
|
+
filter = input(false, ...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
|
|
33
|
+
filterBy = input(undefined, ...(ngDevMode ? [{ debugName: "filterBy" }] : /* istanbul ignore next */ []));
|
|
34
|
+
filterMatchMode = input('contains', ...(ngDevMode ? [{ debugName: "filterMatchMode" }] : /* istanbul ignore next */ []));
|
|
35
|
+
filterLocale = input(undefined, ...(ngDevMode ? [{ debugName: "filterLocale" }] : /* istanbul ignore next */ []));
|
|
36
|
+
filterNormalizeArabic = input(true, ...(ngDevMode ? [{ debugName: "filterNormalizeArabic" }] : /* istanbul ignore next */ []));
|
|
37
|
+
filterPlaceholder = input(undefined, ...(ngDevMode ? [{ debugName: "filterPlaceholder" }] : /* istanbul ignore next */ []));
|
|
38
|
+
searchPlaceholder = input(undefined, ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
|
|
39
|
+
filterInTrigger = input(false, ...(ngDevMode ? [{ debugName: "filterInTrigger" }] : /* istanbul ignore next */ []));
|
|
40
|
+
resetFilterOnHide = input(false, ...(ngDevMode ? [{ debugName: "resetFilterOnHide" }] : /* istanbul ignore next */ []));
|
|
41
|
+
emptyMessage = input('No results found', ...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
42
|
+
emptyFilterMessage = input('No results found', ...(ngDevMode ? [{ debugName: "emptyFilterMessage" }] : /* istanbul ignore next */ []));
|
|
43
|
+
// --- State & Form Inputs ---
|
|
44
|
+
disabled = model(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
45
|
+
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
46
|
+
loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
47
|
+
showClear = input(false, ...(ngDevMode ? [{ debugName: "showClear" }] : /* istanbul ignore next */ []));
|
|
48
|
+
invalid = input(false, ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
49
|
+
floatLabel = input(false, ...(ngDevMode ? [{ debugName: "floatLabel" }] : /* istanbul ignore next */ []));
|
|
50
|
+
floatLabelVariant = input('on', ...(ngDevMode ? [{ debugName: "floatLabelVariant" }] : /* istanbul ignore next */ []));
|
|
51
|
+
autofocus = input(false, ...(ngDevMode ? [{ debugName: "autofocus" }] : /* istanbul ignore next */ []));
|
|
52
|
+
tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []));
|
|
53
|
+
id = input(undefined, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
54
|
+
ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
55
|
+
ariaLabelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
|
|
56
|
+
dir = input(undefined, ...(ngDevMode ? [{ debugName: "dir" }] : /* istanbul ignore next */ []));
|
|
57
|
+
// --- Display & Styling Inputs ---
|
|
58
|
+
dropdownPosition = input('auto', ...(ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []));
|
|
59
|
+
dropdownDirection = input(undefined, ...(ngDevMode ? [{ debugName: "dropdownDirection" }] : /* istanbul ignore next */ []));
|
|
60
|
+
direction = input(undefined, ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
61
|
+
size = input(undefined, ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
62
|
+
variant = input('outlined', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
63
|
+
fluid = input(false, ...(ngDevMode ? [{ debugName: "fluid" }] : /* istanbul ignore next */ []));
|
|
64
|
+
scrollHeight = input('200px', ...(ngDevMode ? [{ debugName: "scrollHeight" }] : /* istanbul ignore next */ []));
|
|
65
|
+
style = input(undefined, ...(ngDevMode ? [{ debugName: "style" }] : /* istanbul ignore next */ []));
|
|
66
|
+
styleClass = input(undefined, ...(ngDevMode ? [{ debugName: "styleClass" }] : /* istanbul ignore next */ []));
|
|
67
|
+
panelStyle = input(undefined, ...(ngDevMode ? [{ debugName: "panelStyle" }] : /* istanbul ignore next */ []));
|
|
68
|
+
panelStyleClass = input(undefined, ...(ngDevMode ? [{ debugName: "panelStyleClass" }] : /* istanbul ignore next */ []));
|
|
69
|
+
appendTo = input(undefined, ...(ngDevMode ? [{ debugName: "appendTo" }] : /* istanbul ignore next */ []));
|
|
70
|
+
// --- Modal / Popup Window Inputs ---
|
|
71
|
+
modal = input(false, ...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
|
|
72
|
+
popup = input(false, ...(ngDevMode ? [{ debugName: "popup" }] : /* istanbul ignore next */ []));
|
|
73
|
+
touchUI = input(false, ...(ngDevMode ? [{ debugName: "touchUI" }] : /* istanbul ignore next */ []));
|
|
74
|
+
popupTitle = input(undefined, ...(ngDevMode ? [{ debugName: "popupTitle" }] : /* istanbul ignore next */ []));
|
|
75
|
+
modalTitle = input(undefined, ...(ngDevMode ? [{ debugName: "modalTitle" }] : /* istanbul ignore next */ []));
|
|
76
|
+
// --- Advanced Features ---
|
|
77
|
+
editable = input(false, ...(ngDevMode ? [{ debugName: "editable" }] : /* istanbul ignore next */ []));
|
|
78
|
+
maxLength = input(undefined, ...(ngDevMode ? [{ debugName: "maxLength" }] : /* istanbul ignore next */ []));
|
|
79
|
+
selectOnFocus = input(false, ...(ngDevMode ? [{ debugName: "selectOnFocus" }] : /* istanbul ignore next */ []));
|
|
80
|
+
autoOptionFocus = input(true, ...(ngDevMode ? [{ debugName: "autoOptionFocus" }] : /* istanbul ignore next */ []));
|
|
81
|
+
focusOnOpen = input(undefined, ...(ngDevMode ? [{ debugName: "focusOnOpen" }] : /* istanbul ignore next */ []));
|
|
82
|
+
focusOnOpenStrategy = input('always', ...(ngDevMode ? [{ debugName: "focusOnOpenStrategy" }] : /* istanbul ignore next */ []));
|
|
83
|
+
lazy = input(false, ...(ngDevMode ? [{ debugName: "lazy" }] : /* istanbul ignore next */ []));
|
|
84
|
+
// --- Two-way Overlay Visibility Binding ---
|
|
85
|
+
overlayVisible = model(false, ...(ngDevMode ? [{ debugName: "overlayVisible" }] : /* istanbul ignore next */ []));
|
|
86
|
+
// --- Event Outputs ---
|
|
87
|
+
onChange = output();
|
|
88
|
+
onFilter = output();
|
|
89
|
+
onFocus = output();
|
|
90
|
+
onBlur = output();
|
|
91
|
+
onShow = output();
|
|
92
|
+
onHide = output();
|
|
93
|
+
onClear = output();
|
|
94
|
+
onSelectAllChange = output();
|
|
95
|
+
onRemoveChip = output();
|
|
96
|
+
onLazyLoad = output();
|
|
97
|
+
// --- Custom Content Templates ---
|
|
98
|
+
itemTemplate;
|
|
99
|
+
selectedItemTemplate;
|
|
100
|
+
labelTemplate;
|
|
101
|
+
chipTemplate;
|
|
102
|
+
headerCheckboxTemplate;
|
|
103
|
+
headerTemplate;
|
|
104
|
+
footerTemplate;
|
|
105
|
+
groupTemplate;
|
|
106
|
+
emptyTemplate;
|
|
107
|
+
clearIconTemplate;
|
|
108
|
+
dropdownIconTemplate;
|
|
109
|
+
filterIconTemplate;
|
|
110
|
+
// --- View References ---
|
|
111
|
+
filterInputElement;
|
|
112
|
+
triggerFilterInputElement;
|
|
113
|
+
editableInputElement;
|
|
114
|
+
dropdownMenuElement;
|
|
115
|
+
effectiveSearchPlaceholder = computed(() => {
|
|
116
|
+
return this.searchPlaceholder() || this.filterPlaceholder() || this.placeholder() || 'Search...';
|
|
117
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveSearchPlaceholder" }] : /* istanbul ignore next */ []));
|
|
118
|
+
effectiveDropdownPosition = computed(() => {
|
|
119
|
+
return this.dropdownDirection() || this.direction() || this.dropdownPosition() || 'auto';
|
|
120
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveDropdownPosition" }] : /* istanbul ignore next */ []));
|
|
121
|
+
currentPlacement = signal('bottom', ...(ngDevMode ? [{ debugName: "currentPlacement" }] : /* istanbul ignore next */ []));
|
|
122
|
+
isDropup = computed(() => this.currentPlacement() === 'top', ...(ngDevMode ? [{ debugName: "isDropup" }] : /* istanbul ignore next */ []));
|
|
123
|
+
isModalMode = computed(() => this.modal() || this.popup() || this.touchUI(), ...(ngDevMode ? [{ debugName: "isModalMode" }] : /* istanbul ignore next */ []));
|
|
124
|
+
effectivePopupTitle = computed(() => {
|
|
125
|
+
return this.popupTitle() || this.modalTitle() || this.placeholder() || 'Select an Option';
|
|
126
|
+
}, ...(ngDevMode ? [{ debugName: "effectivePopupTitle" }] : /* istanbul ignore next */ []));
|
|
127
|
+
effectiveFilterValue = computed(() => {
|
|
128
|
+
return this.overlayVisible()
|
|
129
|
+
? this.filterValue()
|
|
130
|
+
: this.hasSelectedValue()
|
|
131
|
+
? ''
|
|
132
|
+
: this.filterValue();
|
|
133
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveFilterValue" }] : /* istanbul ignore next */ []));
|
|
134
|
+
// --- Internal State ---
|
|
135
|
+
value = signal(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
136
|
+
filteredOptions = signal([], ...(ngDevMode ? [{ debugName: "filteredOptions" }] : /* istanbul ignore next */ []));
|
|
137
|
+
filterValue = signal('', ...(ngDevMode ? [{ debugName: "filterValue" }] : /* istanbul ignore next */ []));
|
|
138
|
+
focusedIndex = signal(-1, ...(ngDevMode ? [{ debugName: "focusedIndex" }] : /* istanbul ignore next */ []));
|
|
139
|
+
selectAll = signal(null, ...(ngDevMode ? [{ debugName: "selectAll" }] : /* istanbul ignore next */ []));
|
|
140
|
+
// --- ControlValueAccessor Callbacks ---
|
|
141
|
+
onModelChange = () => { };
|
|
142
|
+
onModelTouched = () => { };
|
|
143
|
+
constructor(elementRef, cdr) {
|
|
144
|
+
this.elementRef = elementRef;
|
|
145
|
+
this.cdr = cdr;
|
|
146
|
+
effect(() => {
|
|
147
|
+
// React to options or group changes
|
|
148
|
+
this.options();
|
|
149
|
+
this.group();
|
|
150
|
+
this.updateFilteredOptions();
|
|
151
|
+
this.updateSelectAllState();
|
|
152
|
+
});
|
|
153
|
+
effect(() => {
|
|
154
|
+
// React to overlayVisible changes
|
|
155
|
+
const visible = this.overlayVisible();
|
|
156
|
+
if (visible) {
|
|
157
|
+
this.openOverlay();
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this.closeOverlay();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
ngOnInit() {
|
|
165
|
+
if (this.autofocus()) {
|
|
166
|
+
setTimeout(() => this.focus());
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
ngOnDestroy() {
|
|
170
|
+
this.cleanAppendTo();
|
|
171
|
+
}
|
|
172
|
+
safeOptions = computed(() => {
|
|
173
|
+
const opts = this.options();
|
|
174
|
+
return Array.isArray(opts) ? opts : [];
|
|
175
|
+
}, ...(ngDevMode ? [{ debugName: "safeOptions" }] : /* istanbul ignore next */ []));
|
|
176
|
+
writeValue(obj) {
|
|
177
|
+
if (this.multiple()) {
|
|
178
|
+
this.value.set(Array.isArray(obj) ? [...obj] : []);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.value.set(obj !== undefined ? obj : null);
|
|
182
|
+
}
|
|
183
|
+
this.updateSelectAllState();
|
|
184
|
+
this.cdr.markForCheck();
|
|
185
|
+
}
|
|
186
|
+
registerOnChange(fn) {
|
|
187
|
+
this.onModelChange = fn;
|
|
188
|
+
}
|
|
189
|
+
registerOnTouched(fn) {
|
|
190
|
+
this.onModelTouched = fn;
|
|
191
|
+
}
|
|
192
|
+
setDisabledState(isDisabled) {
|
|
193
|
+
this.disabled.set(isDisabled);
|
|
194
|
+
this.cdr.markForCheck();
|
|
195
|
+
}
|
|
196
|
+
hasSelectedValue = computed(() => {
|
|
197
|
+
const val = this.value();
|
|
198
|
+
if (this.multiple()) {
|
|
199
|
+
return Array.isArray(val) && val.length > 0;
|
|
200
|
+
}
|
|
201
|
+
return val !== null && val !== undefined && val !== '';
|
|
202
|
+
}, ...(ngDevMode ? [{ debugName: "hasSelectedValue" }] : /* istanbul ignore next */ []));
|
|
203
|
+
getDisplayLabel() {
|
|
204
|
+
if (!this.hasSelectedValue()) {
|
|
205
|
+
return '';
|
|
206
|
+
}
|
|
207
|
+
if (this.multiple()) {
|
|
208
|
+
const selectedList = Array.isArray(this.value()) ? this.value() : [];
|
|
209
|
+
if (selectedList.length > this.maxSelectedLabels()) {
|
|
210
|
+
return this.selectedItemsLabel().replace('{0}', String(selectedList.length));
|
|
211
|
+
}
|
|
212
|
+
return selectedList.map((val) => this.resolveOptionLabelByValue(val)).join(', ');
|
|
213
|
+
}
|
|
214
|
+
if (this.editable() && typeof this.value() === 'string') {
|
|
215
|
+
return this.value();
|
|
216
|
+
}
|
|
217
|
+
return this.resolveOptionLabelByValue(this.value());
|
|
218
|
+
}
|
|
219
|
+
resolveOptionLabelByValue(val) {
|
|
220
|
+
const selectedOpt = this.findOptionByValue(val);
|
|
221
|
+
if (selectedOpt !== undefined && selectedOpt !== null) {
|
|
222
|
+
return this.resolveOptionLabel(selectedOpt);
|
|
223
|
+
}
|
|
224
|
+
return this.resolveOptionLabel(val);
|
|
225
|
+
}
|
|
226
|
+
resolveOptionLabel(option) {
|
|
227
|
+
if (option === null || option === undefined)
|
|
228
|
+
return '';
|
|
229
|
+
if (typeof option === 'object') {
|
|
230
|
+
if (this.optionLabel() && option[this.optionLabel()] !== undefined) {
|
|
231
|
+
return String(option[this.optionLabel()]);
|
|
232
|
+
}
|
|
233
|
+
if (option.label !== undefined) {
|
|
234
|
+
return String(option.label);
|
|
235
|
+
}
|
|
236
|
+
return JSON.stringify(option);
|
|
237
|
+
}
|
|
238
|
+
return String(option);
|
|
239
|
+
}
|
|
240
|
+
resolveOptionValue(option) {
|
|
241
|
+
if (option === null || option === undefined)
|
|
242
|
+
return null;
|
|
243
|
+
if (typeof option === 'object') {
|
|
244
|
+
if (this.optionValue() && option[this.optionValue()] !== undefined) {
|
|
245
|
+
return option[this.optionValue()];
|
|
246
|
+
}
|
|
247
|
+
if (option.value !== undefined) {
|
|
248
|
+
return option.value;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return option;
|
|
252
|
+
}
|
|
253
|
+
isOptionDisabled(option) {
|
|
254
|
+
if (this.disabled())
|
|
255
|
+
return true;
|
|
256
|
+
if (option && typeof option === 'object') {
|
|
257
|
+
if (this.optionDisabled() && option[this.optionDisabled()] !== undefined) {
|
|
258
|
+
return Boolean(option[this.optionDisabled()]);
|
|
259
|
+
}
|
|
260
|
+
return Boolean(option.disabled);
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
resolveOptionGroupLabel(groupOption) {
|
|
265
|
+
if (!groupOption)
|
|
266
|
+
return '';
|
|
267
|
+
if (this.optionGroupLabel() && groupOption[this.optionGroupLabel()] !== undefined) {
|
|
268
|
+
return String(groupOption[this.optionGroupLabel()]);
|
|
269
|
+
}
|
|
270
|
+
return String(groupOption.label || '');
|
|
271
|
+
}
|
|
272
|
+
resolveOptionGroupChildren(groupOption) {
|
|
273
|
+
if (!groupOption)
|
|
274
|
+
return [];
|
|
275
|
+
if (this.optionGroupChildren() && Array.isArray(groupOption[this.optionGroupChildren()])) {
|
|
276
|
+
return groupOption[this.optionGroupChildren()];
|
|
277
|
+
}
|
|
278
|
+
return Array.isArray(groupOption.items) ? groupOption.items : [];
|
|
279
|
+
}
|
|
280
|
+
findOptionByValue(val) {
|
|
281
|
+
if (val === null || val === undefined)
|
|
282
|
+
return undefined;
|
|
283
|
+
if (this.group()) {
|
|
284
|
+
for (const grp of this.safeOptions()) {
|
|
285
|
+
const children = this.resolveOptionGroupChildren(grp);
|
|
286
|
+
const match = children.find((opt) => this.areValuesEqual(this.resolveOptionValue(opt), val));
|
|
287
|
+
if (match !== undefined)
|
|
288
|
+
return match;
|
|
289
|
+
}
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
return this.safeOptions().find((opt) => this.areValuesEqual(this.resolveOptionValue(opt), val));
|
|
293
|
+
}
|
|
294
|
+
areValuesEqual(val1, val2) {
|
|
295
|
+
if (val1 === val2)
|
|
296
|
+
return true;
|
|
297
|
+
if (val1 === null || val1 === undefined || val2 === null || val2 === undefined)
|
|
298
|
+
return false;
|
|
299
|
+
if (typeof val1 === 'object' && typeof val2 === 'object') {
|
|
300
|
+
const dataKey = this.dataKey();
|
|
301
|
+
if (dataKey && val1[dataKey] !== undefined && val2[dataKey] !== undefined) {
|
|
302
|
+
return val1[dataKey] === val2[dataKey];
|
|
303
|
+
}
|
|
304
|
+
if (this.optionValue() &&
|
|
305
|
+
val1[this.optionValue()] !== undefined &&
|
|
306
|
+
val2[this.optionValue()] !== undefined) {
|
|
307
|
+
return val1[this.optionValue()] === val2[this.optionValue()];
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
return JSON.stringify(val1) === JSON.stringify(val2);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
isSelected(option) {
|
|
319
|
+
const optVal = this.resolveOptionValue(option);
|
|
320
|
+
if (this.multiple() && Array.isArray(this.value())) {
|
|
321
|
+
return this.value().some((item) => this.areValuesEqual(item, optVal));
|
|
322
|
+
}
|
|
323
|
+
return this.areValuesEqual(this.value(), optVal);
|
|
324
|
+
}
|
|
325
|
+
isOptionsEmpty() {
|
|
326
|
+
if (this.filteredOptions().length === 0)
|
|
327
|
+
return true;
|
|
328
|
+
if (this.group()) {
|
|
329
|
+
return this.filteredOptions().every((grp) => this.resolveOptionGroupChildren(grp).length === 0);
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
onTriggerClick(event) {
|
|
334
|
+
if (this.disabled() || this.readonly())
|
|
335
|
+
return;
|
|
336
|
+
this.toggleOverlay(event);
|
|
337
|
+
}
|
|
338
|
+
calculateDropdownPosition() {
|
|
339
|
+
const pref = this.effectiveDropdownPosition();
|
|
340
|
+
if (pref === 'top' || pref === 'up') {
|
|
341
|
+
this.currentPlacement.set('top');
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (pref === 'bottom' || pref === 'down') {
|
|
345
|
+
this.currentPlacement.set('bottom');
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
// Auto positioning based on viewport space
|
|
349
|
+
if (typeof window === 'undefined' || !this.elementRef?.nativeElement) {
|
|
350
|
+
this.currentPlacement.set('bottom');
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const triggerRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
354
|
+
const spaceBelow = window.innerHeight - triggerRect.bottom;
|
|
355
|
+
const spaceAbove = triggerRect.top;
|
|
356
|
+
let panelHeight = 200;
|
|
357
|
+
if (this.dropdownMenuElement?.nativeElement?.offsetHeight) {
|
|
358
|
+
panelHeight = this.dropdownMenuElement.nativeElement.offsetHeight;
|
|
359
|
+
}
|
|
360
|
+
else if (this.scrollHeight()) {
|
|
361
|
+
const parsed = parseInt(this.scrollHeight(), 10);
|
|
362
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
363
|
+
panelHeight = parsed;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (spaceBelow < panelHeight && spaceAbove > spaceBelow) {
|
|
367
|
+
this.currentPlacement.set('top');
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
this.currentPlacement.set('bottom');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
toggleOverlay(event) {
|
|
374
|
+
if (this.overlayVisible()) {
|
|
375
|
+
this.closeOverlay(event);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
this.openOverlay(event);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
openOverlay(event) {
|
|
382
|
+
if (this.disabled() || this.readonly() || this.overlayVisible())
|
|
383
|
+
return;
|
|
384
|
+
this.calculateDropdownPosition();
|
|
385
|
+
this.overlayVisible.set(true);
|
|
386
|
+
this.onShow.emit(event || null);
|
|
387
|
+
this.onModelTouched();
|
|
388
|
+
setTimeout(() => {
|
|
389
|
+
this.calculateDropdownPosition();
|
|
390
|
+
if (this.filterInTrigger() && this.triggerFilterInputElement) {
|
|
391
|
+
this.triggerFilterInputElement.nativeElement.focus();
|
|
392
|
+
}
|
|
393
|
+
else if (this.filter() && this.filterInputElement) {
|
|
394
|
+
this.filterInputElement.nativeElement.focus();
|
|
395
|
+
}
|
|
396
|
+
this.handleFocusOnOpen();
|
|
397
|
+
this.handleAppendTo();
|
|
398
|
+
this.cdr.markForCheck();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
closeOverlay(event) {
|
|
402
|
+
if (!this.overlayVisible())
|
|
403
|
+
return;
|
|
404
|
+
this.overlayVisible.set(false);
|
|
405
|
+
this.onHide.emit(event || null);
|
|
406
|
+
if (this.resetFilterOnHide() && this.filterValue()) {
|
|
407
|
+
this.filterValue.set('');
|
|
408
|
+
this.updateFilteredOptions();
|
|
409
|
+
}
|
|
410
|
+
this.focusedIndex.set(-1);
|
|
411
|
+
this.cdr.markForCheck();
|
|
412
|
+
}
|
|
413
|
+
handleFocusOnOpen() {
|
|
414
|
+
const flatItems = this.getFlatFilteredOptions();
|
|
415
|
+
let targetIndex = -1;
|
|
416
|
+
const hasSelection = this.hasSelectedValue();
|
|
417
|
+
const selectedIdx = flatItems.findIndex((opt) => this.isSelected(opt));
|
|
418
|
+
const focusOnOpen = this.focusOnOpen();
|
|
419
|
+
if (focusOnOpen !== undefined &&
|
|
420
|
+
focusOnOpen >= 0 &&
|
|
421
|
+
focusOnOpen < flatItems.length) {
|
|
422
|
+
if (this.focusOnOpenStrategy() === 'notSelected' && hasSelection && selectedIdx !== -1) {
|
|
423
|
+
targetIndex = selectedIdx;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
targetIndex = focusOnOpen;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else if (this.autoOptionFocus()) {
|
|
430
|
+
targetIndex = selectedIdx !== -1 ? selectedIdx : 0;
|
|
431
|
+
}
|
|
432
|
+
if (targetIndex !== -1 && this.dropdownMenuElement) {
|
|
433
|
+
this.focusedIndex.set(targetIndex);
|
|
434
|
+
const elements = this.dropdownMenuElement.nativeElement.querySelectorAll('.dropdown-item[role="option"]');
|
|
435
|
+
const targetElement = elements[targetIndex];
|
|
436
|
+
if (targetElement && typeof targetElement.scrollIntoView === 'function') {
|
|
437
|
+
targetElement.scrollIntoView({ block: 'nearest', inline: 'start' });
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
onOptionClick(option, event) {
|
|
442
|
+
if (this.isOptionDisabled(option))
|
|
443
|
+
return;
|
|
444
|
+
const val = this.resolveOptionValue(option);
|
|
445
|
+
if (this.multiple()) {
|
|
446
|
+
let currentSelection = Array.isArray(this.value()) ? [...this.value()] : [];
|
|
447
|
+
const selectedIndex = currentSelection.findIndex((item) => this.areValuesEqual(item, val));
|
|
448
|
+
if (selectedIndex !== -1) {
|
|
449
|
+
currentSelection.splice(selectedIndex, 1);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
if (this.selectionLimit() !== undefined && currentSelection.length >= this.selectionLimit()) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
currentSelection.push(val);
|
|
456
|
+
}
|
|
457
|
+
this.updateModel(currentSelection, event);
|
|
458
|
+
this.updateSelectAllState();
|
|
459
|
+
if (this.closeOnSelect()) {
|
|
460
|
+
this.closeOverlay(event);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
this.updateModel(val, event);
|
|
465
|
+
if (this.filterInTrigger()) {
|
|
466
|
+
this.filterValue.set('');
|
|
467
|
+
this.updateFilteredOptions();
|
|
468
|
+
if (this.triggerFilterInputElement) {
|
|
469
|
+
this.triggerFilterInputElement.nativeElement.value = '';
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
this.closeOverlay(event);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
removeChip(val, event) {
|
|
476
|
+
event.stopPropagation();
|
|
477
|
+
if (this.disabled() || this.readonly())
|
|
478
|
+
return;
|
|
479
|
+
if (Array.isArray(this.value())) {
|
|
480
|
+
const nextVal = this.value().filter((item) => !this.areValuesEqual(item, val));
|
|
481
|
+
this.updateModel(nextVal, event);
|
|
482
|
+
this.onRemoveChip.emit({ originalEvent: event, value: val });
|
|
483
|
+
this.updateSelectAllState();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
toggleSelectAll(event) {
|
|
487
|
+
const checked = event.target.checked;
|
|
488
|
+
const targetOptions = this.getFlatFilteredOptions().filter((opt) => !this.isOptionDisabled(opt));
|
|
489
|
+
if (checked) {
|
|
490
|
+
let allValues = targetOptions.map((opt) => this.resolveOptionValue(opt));
|
|
491
|
+
if (this.selectionLimit() !== undefined) {
|
|
492
|
+
allValues = allValues.slice(0, this.selectionLimit());
|
|
493
|
+
}
|
|
494
|
+
this.value.set(allValues);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
this.value.set([]);
|
|
498
|
+
}
|
|
499
|
+
this.selectAll.set(checked);
|
|
500
|
+
this.updateModel(this.value(), event);
|
|
501
|
+
this.onSelectAllChange.emit({ originalEvent: event, checked });
|
|
502
|
+
}
|
|
503
|
+
updateSelectAllState() {
|
|
504
|
+
if (!this.multiple() || !this.showSelectAll())
|
|
505
|
+
return;
|
|
506
|
+
const targetOptions = this.getFlatFilteredOptions().filter((opt) => !this.isOptionDisabled(opt));
|
|
507
|
+
if (targetOptions.length === 0) {
|
|
508
|
+
this.selectAll.set(false);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.selectAll.set(targetOptions.every((opt) => this.isSelected(opt)));
|
|
512
|
+
}
|
|
513
|
+
updateModel(val, event) {
|
|
514
|
+
this.value.set(val);
|
|
515
|
+
this.onModelChange(this.value());
|
|
516
|
+
this.onChange.emit({
|
|
517
|
+
originalEvent: event,
|
|
518
|
+
value: this.value(),
|
|
519
|
+
});
|
|
520
|
+
this.cdr.markForCheck();
|
|
521
|
+
}
|
|
522
|
+
onClearClick(event) {
|
|
523
|
+
event.stopPropagation();
|
|
524
|
+
if (this.disabled() || this.readonly())
|
|
525
|
+
return;
|
|
526
|
+
const clearedValue = this.multiple() ? [] : null;
|
|
527
|
+
this.updateModel(clearedValue, event);
|
|
528
|
+
this.updateSelectAllState();
|
|
529
|
+
this.onClear.emit(event);
|
|
530
|
+
}
|
|
531
|
+
onEditableInput(event) {
|
|
532
|
+
const inputVal = event.target.value;
|
|
533
|
+
this.updateModel(inputVal, event);
|
|
534
|
+
}
|
|
535
|
+
onEditableFocus(event) {
|
|
536
|
+
if (this.selectOnFocus() && this.editableInputElement) {
|
|
537
|
+
this.editableInputElement.nativeElement.select();
|
|
538
|
+
}
|
|
539
|
+
this.onFocus.emit(event);
|
|
540
|
+
}
|
|
541
|
+
onFilterChange(event) {
|
|
542
|
+
const raw = event.target.value || '';
|
|
543
|
+
this.filterValue.set(raw);
|
|
544
|
+
this.updateFilteredOptions();
|
|
545
|
+
this.updateSelectAllState();
|
|
546
|
+
this.onFilter.emit({
|
|
547
|
+
originalEvent: event,
|
|
548
|
+
filter: this.filterValue(),
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
updateFilteredOptions() {
|
|
552
|
+
if (!this.filterValue()) {
|
|
553
|
+
this.filteredOptions.set([...this.safeOptions()]);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const query = this.filterValue();
|
|
557
|
+
if (this.group()) {
|
|
558
|
+
this.filteredOptions.set(this.safeOptions()
|
|
559
|
+
.map((group) => {
|
|
560
|
+
const children = this.resolveOptionGroupChildren(group);
|
|
561
|
+
const filteredChildren = children.filter((opt) => this.matchesFilter(opt, query));
|
|
562
|
+
return {
|
|
563
|
+
...group,
|
|
564
|
+
[this.optionGroupChildren()]: filteredChildren,
|
|
565
|
+
};
|
|
566
|
+
})
|
|
567
|
+
.filter((group) => this.resolveOptionGroupChildren(group).length > 0));
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
this.filteredOptions.set(this.safeOptions().filter((opt) => this.matchesFilter(opt, query)));
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
matchesFilter(option, query) {
|
|
574
|
+
if (!option)
|
|
575
|
+
return false;
|
|
576
|
+
const fieldsToSearch = this.getFilterFields();
|
|
577
|
+
return fieldsToSearch.some((field) => {
|
|
578
|
+
const val = this.resolveFieldData(option, field);
|
|
579
|
+
if (val === null || val === undefined)
|
|
580
|
+
return false;
|
|
581
|
+
const stringVal = String(val);
|
|
582
|
+
return this.compareStrings(stringVal, query, this.filterMatchMode(), this.filterLocale());
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
getFilterFields() {
|
|
586
|
+
if (this.filterBy()) {
|
|
587
|
+
return this.filterBy().split(',').map((f) => f.trim());
|
|
588
|
+
}
|
|
589
|
+
return [this.optionLabel() || 'label'];
|
|
590
|
+
}
|
|
591
|
+
resolveFieldData(data, field) {
|
|
592
|
+
if (data && field) {
|
|
593
|
+
if (field.indexOf('.') === -1) {
|
|
594
|
+
return data[field] !== undefined
|
|
595
|
+
? data[field]
|
|
596
|
+
: typeof data === 'string' || typeof data === 'number'
|
|
597
|
+
? data
|
|
598
|
+
: null;
|
|
599
|
+
}
|
|
600
|
+
const fields = field.split('.');
|
|
601
|
+
let value = data;
|
|
602
|
+
for (const f of fields) {
|
|
603
|
+
if (value === null || value === undefined)
|
|
604
|
+
return null;
|
|
605
|
+
value = value[f];
|
|
606
|
+
}
|
|
607
|
+
return value;
|
|
608
|
+
}
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
normalizeArabicText(text) {
|
|
612
|
+
return text
|
|
613
|
+
.replace(/[\u064B-\u065F\u0670\u0640]/g, '') // Remove Arabic Tashkeel diacritics & Tatweel
|
|
614
|
+
.replace(/[إأآا]/g, 'ا') // Normalize Alef forms
|
|
615
|
+
.replace(/[يى]/g, 'ي') // Normalize Yaa & Alef Maksura
|
|
616
|
+
.replace(/[ة]/g, 'ه'); // Normalize Taa Marbuta
|
|
617
|
+
}
|
|
618
|
+
compareStrings(val, query, mode, locale) {
|
|
619
|
+
let v = locale ? val.toLocaleLowerCase(locale) : val.toLowerCase();
|
|
620
|
+
let q = locale ? query.toLocaleLowerCase(locale) : query.toLowerCase();
|
|
621
|
+
if (this.filterNormalizeArabic()) {
|
|
622
|
+
v = this.normalizeArabicText(v);
|
|
623
|
+
q = this.normalizeArabicText(q);
|
|
624
|
+
}
|
|
625
|
+
switch (mode) {
|
|
626
|
+
case 'startsWith':
|
|
627
|
+
return v.startsWith(q);
|
|
628
|
+
case 'endsWith':
|
|
629
|
+
return v.endsWith(q);
|
|
630
|
+
case 'equals':
|
|
631
|
+
return v === q;
|
|
632
|
+
case 'notEquals':
|
|
633
|
+
return v !== q;
|
|
634
|
+
case 'contains':
|
|
635
|
+
default:
|
|
636
|
+
return v.includes(q);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
getFlatFilteredOptions() {
|
|
640
|
+
if (this.group()) {
|
|
641
|
+
const flat = [];
|
|
642
|
+
for (const grp of this.filteredOptions()) {
|
|
643
|
+
flat.push(...this.resolveOptionGroupChildren(grp));
|
|
644
|
+
}
|
|
645
|
+
return flat;
|
|
646
|
+
}
|
|
647
|
+
return this.filteredOptions();
|
|
648
|
+
}
|
|
649
|
+
onKeydown(event) {
|
|
650
|
+
if (this.disabled() || this.readonly())
|
|
651
|
+
return;
|
|
652
|
+
switch (event.key) {
|
|
653
|
+
case 'ArrowDown':
|
|
654
|
+
event.preventDefault();
|
|
655
|
+
if (!this.overlayVisible()) {
|
|
656
|
+
this.openOverlay(event);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
this.navigateOption(1);
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
662
|
+
case 'ArrowUp':
|
|
663
|
+
event.preventDefault();
|
|
664
|
+
if (!this.overlayVisible()) {
|
|
665
|
+
this.openOverlay(event);
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
this.navigateOption(-1);
|
|
669
|
+
}
|
|
670
|
+
break;
|
|
671
|
+
case 'Enter':
|
|
672
|
+
case ' ':
|
|
673
|
+
if (event.key === ' ' &&
|
|
674
|
+
((this.filter() && this.filterInputElement?.nativeElement === document.activeElement) ||
|
|
675
|
+
(this.filterInTrigger() &&
|
|
676
|
+
this.triggerFilterInputElement?.nativeElement === document.activeElement))) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
event.preventDefault();
|
|
680
|
+
if (!this.overlayVisible()) {
|
|
681
|
+
this.openOverlay(event);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
const flatItems = this.getFlatFilteredOptions();
|
|
685
|
+
if (this.focusedIndex() >= 0 && this.focusedIndex() < flatItems.length) {
|
|
686
|
+
this.onOptionClick(flatItems[this.focusedIndex()], event);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
break;
|
|
690
|
+
case 'Escape':
|
|
691
|
+
if (this.overlayVisible()) {
|
|
692
|
+
event.preventDefault();
|
|
693
|
+
this.closeOverlay(event);
|
|
694
|
+
}
|
|
695
|
+
break;
|
|
696
|
+
case 'Tab':
|
|
697
|
+
if (this.overlayVisible()) {
|
|
698
|
+
this.closeOverlay(event);
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
onFilterKeydown(event) {
|
|
704
|
+
if (event.key === 'ArrowDown' ||
|
|
705
|
+
event.key === 'ArrowUp' ||
|
|
706
|
+
event.key === 'Enter' ||
|
|
707
|
+
event.key === 'Escape') {
|
|
708
|
+
this.onKeydown(event);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
navigateOption(step) {
|
|
712
|
+
const flatItems = this.getFlatFilteredOptions();
|
|
713
|
+
if (flatItems.length === 0)
|
|
714
|
+
return;
|
|
715
|
+
let nextIdx = this.focusedIndex() + step;
|
|
716
|
+
if (nextIdx < 0)
|
|
717
|
+
nextIdx = 0;
|
|
718
|
+
if (nextIdx >= flatItems.length)
|
|
719
|
+
nextIdx = flatItems.length - 1;
|
|
720
|
+
while (nextIdx >= 0 &&
|
|
721
|
+
nextIdx < flatItems.length &&
|
|
722
|
+
this.isOptionDisabled(flatItems[nextIdx])) {
|
|
723
|
+
nextIdx += step;
|
|
724
|
+
}
|
|
725
|
+
if (nextIdx >= 0 && nextIdx < flatItems.length) {
|
|
726
|
+
this.focusedIndex.set(nextIdx);
|
|
727
|
+
if (this.dropdownMenuElement) {
|
|
728
|
+
const elements = this.dropdownMenuElement.nativeElement.querySelectorAll('.dropdown-item[role="option"]');
|
|
729
|
+
const targetElement = elements[nextIdx];
|
|
730
|
+
if (targetElement && typeof targetElement.scrollIntoView === 'function') {
|
|
731
|
+
targetElement.scrollIntoView({ block: 'nearest', inline: 'start' });
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
isOptionFocused(option) {
|
|
737
|
+
if (this.focusedIndex() < 0)
|
|
738
|
+
return false;
|
|
739
|
+
const flat = this.getFlatFilteredOptions();
|
|
740
|
+
if (this.focusedIndex() >= flat.length)
|
|
741
|
+
return false;
|
|
742
|
+
return this.areValuesEqual(this.resolveOptionValue(flat[this.focusedIndex()]), this.resolveOptionValue(option));
|
|
743
|
+
}
|
|
744
|
+
onOverlayScroll(event) {
|
|
745
|
+
if (!this.lazy())
|
|
746
|
+
return;
|
|
747
|
+
const target = event.target;
|
|
748
|
+
if (target.scrollTop + target.clientHeight >= target.scrollHeight - 10) {
|
|
749
|
+
const flat = this.getFlatFilteredOptions();
|
|
750
|
+
this.onLazyLoad.emit({
|
|
751
|
+
first: flat.length,
|
|
752
|
+
last: flat.length + 10,
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
handleAppendTo() {
|
|
757
|
+
const appendTo = this.appendTo();
|
|
758
|
+
if (!appendTo || !this.dropdownMenuElement)
|
|
759
|
+
return;
|
|
760
|
+
if (appendTo === 'body') {
|
|
761
|
+
document.body.appendChild(this.dropdownMenuElement.nativeElement);
|
|
762
|
+
this.repositionOverlay();
|
|
763
|
+
}
|
|
764
|
+
else if (appendTo instanceof HTMLElement) {
|
|
765
|
+
appendTo.appendChild(this.dropdownMenuElement.nativeElement);
|
|
766
|
+
this.repositionOverlay();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
repositionOverlay() {
|
|
770
|
+
if (!this.dropdownMenuElement || this.isModalMode())
|
|
771
|
+
return;
|
|
772
|
+
this.calculateDropdownPosition();
|
|
773
|
+
const triggerRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
774
|
+
const dropdown = this.dropdownMenuElement.nativeElement;
|
|
775
|
+
dropdown.style.position = 'fixed';
|
|
776
|
+
dropdown.style.left = `${triggerRect.left}px`;
|
|
777
|
+
dropdown.style.width = `${triggerRect.width}px`;
|
|
778
|
+
dropdown.style.minWidth = `${triggerRect.width}px`;
|
|
779
|
+
dropdown.style.maxWidth = `${triggerRect.width}px`;
|
|
780
|
+
dropdown.style.boxSizing = 'border-box';
|
|
781
|
+
dropdown.style.zIndex = '1060';
|
|
782
|
+
if (this.isDropup()) {
|
|
783
|
+
dropdown.style.top = 'auto';
|
|
784
|
+
dropdown.style.bottom = `${window.innerHeight - triggerRect.top + 2}px`;
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
dropdown.style.top = `${triggerRect.bottom + 2}px`;
|
|
788
|
+
dropdown.style.bottom = 'auto';
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
cleanAppendTo() {
|
|
792
|
+
if (this.appendTo() && this.dropdownMenuElement) {
|
|
793
|
+
const el = this.dropdownMenuElement.nativeElement;
|
|
794
|
+
if (el.parentElement) {
|
|
795
|
+
el.parentElement.removeChild(el);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
onTriggerFocus(event) {
|
|
800
|
+
this.onFocus.emit(event);
|
|
801
|
+
}
|
|
802
|
+
onTriggerBlur(event) {
|
|
803
|
+
this.onBlur.emit(event);
|
|
804
|
+
}
|
|
805
|
+
focus() {
|
|
806
|
+
if (this.filterInTrigger() && this.triggerFilterInputElement) {
|
|
807
|
+
this.triggerFilterInputElement.nativeElement.focus();
|
|
808
|
+
}
|
|
809
|
+
else if (this.editable() && !this.multiple() && this.editableInputElement) {
|
|
810
|
+
this.editableInputElement.nativeElement.focus();
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
const trigger = this.elementRef.nativeElement.querySelector('.form-select');
|
|
814
|
+
if (trigger)
|
|
815
|
+
trigger.focus();
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
onWindowResize() {
|
|
819
|
+
if (this.overlayVisible()) {
|
|
820
|
+
this.calculateDropdownPosition();
|
|
821
|
+
if (this.appendTo()) {
|
|
822
|
+
this.repositionOverlay();
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
onWindowScroll() {
|
|
827
|
+
if (this.overlayVisible()) {
|
|
828
|
+
this.calculateDropdownPosition();
|
|
829
|
+
if (this.appendTo()) {
|
|
830
|
+
this.repositionOverlay();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
onDocumentClick(event) {
|
|
835
|
+
if (this.overlayVisible() && !this.elementRef.nativeElement.contains(event.target)) {
|
|
836
|
+
if (this.dropdownMenuElement &&
|
|
837
|
+
this.dropdownMenuElement.nativeElement.contains(event.target)) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
this.closeOverlay(event);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: NgbSelectComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
844
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.21", type: NgbSelectComponent, isStandalone: true, selector: "ngb-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionDisabled: { classPropertyName: "optionDisabled", publicName: "optionDisabled", isSignal: true, isRequired: false, transformFunction: null }, optionGroupLabel: { classPropertyName: "optionGroupLabel", publicName: "optionGroupLabel", isSignal: true, isRequired: false, transformFunction: null }, optionGroupChildren: { classPropertyName: "optionGroupChildren", publicName: "optionGroupChildren", isSignal: true, isRequired: false, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, display: { classPropertyName: "display", publicName: "display", isSignal: true, isRequired: false, transformFunction: null }, showSelectAll: { classPropertyName: "showSelectAll", publicName: "showSelectAll", isSignal: true, isRequired: false, transformFunction: null }, maxSelectedLabels: { classPropertyName: "maxSelectedLabels", publicName: "maxSelectedLabels", isSignal: true, isRequired: false, transformFunction: null }, selectedItemsLabel: { classPropertyName: "selectedItemsLabel", publicName: "selectedItemsLabel", isSignal: true, isRequired: false, transformFunction: null }, selectionLimit: { classPropertyName: "selectionLimit", publicName: "selectionLimit", isSignal: true, isRequired: false, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, filterMatchMode: { classPropertyName: "filterMatchMode", publicName: "filterMatchMode", isSignal: true, isRequired: false, transformFunction: null }, filterLocale: { classPropertyName: "filterLocale", publicName: "filterLocale", isSignal: true, isRequired: false, transformFunction: null }, filterNormalizeArabic: { classPropertyName: "filterNormalizeArabic", publicName: "filterNormalizeArabic", isSignal: true, isRequired: false, transformFunction: null }, filterPlaceholder: { classPropertyName: "filterPlaceholder", publicName: "filterPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, filterInTrigger: { classPropertyName: "filterInTrigger", publicName: "filterInTrigger", isSignal: true, isRequired: false, transformFunction: null }, resetFilterOnHide: { classPropertyName: "resetFilterOnHide", publicName: "resetFilterOnHide", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyFilterMessage: { classPropertyName: "emptyFilterMessage", publicName: "emptyFilterMessage", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, floatLabel: { classPropertyName: "floatLabel", publicName: "floatLabel", isSignal: true, isRequired: false, transformFunction: null }, floatLabelVariant: { classPropertyName: "floatLabelVariant", publicName: "floatLabelVariant", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, dropdownPosition: { classPropertyName: "dropdownPosition", publicName: "dropdownPosition", isSignal: true, isRequired: false, transformFunction: null }, dropdownDirection: { classPropertyName: "dropdownDirection", publicName: "dropdownDirection", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null }, scrollHeight: { classPropertyName: "scrollHeight", publicName: "scrollHeight", isSignal: true, isRequired: false, transformFunction: null }, style: { classPropertyName: "style", publicName: "style", isSignal: true, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: true, isRequired: false, transformFunction: null }, panelStyle: { classPropertyName: "panelStyle", publicName: "panelStyle", isSignal: true, isRequired: false, transformFunction: null }, panelStyleClass: { classPropertyName: "panelStyleClass", publicName: "panelStyleClass", isSignal: true, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, popup: { classPropertyName: "popup", publicName: "popup", isSignal: true, isRequired: false, transformFunction: null }, touchUI: { classPropertyName: "touchUI", publicName: "touchUI", isSignal: true, isRequired: false, transformFunction: null }, popupTitle: { classPropertyName: "popupTitle", publicName: "popupTitle", isSignal: true, isRequired: false, transformFunction: null }, modalTitle: { classPropertyName: "modalTitle", publicName: "modalTitle", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, maxLength: { classPropertyName: "maxLength", publicName: "maxLength", isSignal: true, isRequired: false, transformFunction: null }, selectOnFocus: { classPropertyName: "selectOnFocus", publicName: "selectOnFocus", isSignal: true, isRequired: false, transformFunction: null }, autoOptionFocus: { classPropertyName: "autoOptionFocus", publicName: "autoOptionFocus", isSignal: true, isRequired: false, transformFunction: null }, focusOnOpen: { classPropertyName: "focusOnOpen", publicName: "focusOnOpen", isSignal: true, isRequired: false, transformFunction: null }, focusOnOpenStrategy: { classPropertyName: "focusOnOpenStrategy", publicName: "focusOnOpenStrategy", isSignal: true, isRequired: false, transformFunction: null }, lazy: { classPropertyName: "lazy", publicName: "lazy", isSignal: true, isRequired: false, transformFunction: null }, overlayVisible: { classPropertyName: "overlayVisible", publicName: "overlayVisible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", overlayVisible: "overlayVisibleChange", onChange: "onChange", onFilter: "onFilter", onFocus: "onFocus", onBlur: "onBlur", onShow: "onShow", onHide: "onHide", onClear: "onClear", onSelectAllChange: "onSelectAllChange", onRemoveChip: "onRemoveChip", onLazyLoad: "onLazyLoad" }, host: { listeners: { "window:resize": "onWindowResize()", "window:scroll": "onWindowScroll()", "document:click": "onDocumentClick($event)" } }, providers: [
|
|
845
|
+
{
|
|
846
|
+
provide: NG_VALUE_ACCESSOR,
|
|
847
|
+
useExisting: forwardRef(() => NgbSelectComponent),
|
|
848
|
+
multi: true,
|
|
849
|
+
},
|
|
850
|
+
], queries: [{ propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true }, { propertyName: "selectedItemTemplate", first: true, predicate: ["selectedItem"], descendants: true }, { propertyName: "labelTemplate", first: true, predicate: ["label"], descendants: true }, { propertyName: "chipTemplate", first: true, predicate: ["chip"], descendants: true }, { propertyName: "headerCheckboxTemplate", first: true, predicate: ["headerCheckbox"], descendants: true }, { propertyName: "headerTemplate", first: true, predicate: ["header"], descendants: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"], descendants: true }, { propertyName: "clearIconTemplate", first: true, predicate: ["clearIcon"], descendants: true }, { propertyName: "dropdownIconTemplate", first: true, predicate: ["dropdownIcon"], descendants: true }, { propertyName: "filterIconTemplate", first: true, predicate: ["filterIcon"], descendants: true }], viewQueries: [{ propertyName: "filterInputElement", first: true, predicate: ["filterInput"], descendants: true }, { propertyName: "triggerFilterInputElement", first: true, predicate: ["triggerFilterInput"], descendants: true }, { propertyName: "editableInputElement", first: true, predicate: ["editableInput"], descendants: true }, { propertyName: "dropdownMenuElement", first: true, predicate: ["dropdownMenu"], descendants: true }], ngImport: i0, template: "<div\n class=\"ngb-select-container position-relative\"\n [class.form-floating]=\"floatLabel()\"\n [class.float-variant-on]=\"floatLabel() && floatLabelVariant() === 'on'\"\n [class.float-variant-in]=\"floatLabel() && floatLabelVariant() === 'in'\"\n [class.float-variant-over]=\"floatLabel() && floatLabelVariant() === 'over'\"\n [class.floating-active]=\"hasSelectedValue() || overlayVisible()\"\n [class.dropup]=\"isDropup()\"\n [class.dropdown-up]=\"isDropup()\"\n [class.w-100]=\"fluid()\"\n [attr.dir]=\"dir() || null\"\n [ngStyle]=\"style()\"\n [ngClass]=\"styleClass()\"\n (keydown)=\"onKeydown($event)\"\n>\n <!-- Select Trigger Box -->\n <div\n class=\"form-select d-flex align-items-center justify-content-between\"\n [class.is-invalid]=\"invalid()\"\n [class.disabled]=\"disabled()\"\n [class.form-select-sm]=\"size() === 'small'\"\n [class.form-select-lg]=\"size() === 'large'\"\n [class.bg-light]=\"variant() === 'filled'\"\n [attr.id]=\"id()\"\n [attr.tabindex]=\"disabled() ? -1 : tabindex()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledBy()\"\n [attr.aria-expanded]=\"overlayVisible()\"\n [attr.aria-haspopup]=\"'listbox'\"\n role=\"combobox\"\n (click)=\"onTriggerClick($event)\"\n (focus)=\"onTriggerFocus($event)\"\n (blur)=\"onTriggerBlur($event)\"\n >\n <!-- Selected Value / Input / Chips Area -->\n <span class=\"text-truncate flex-grow-1 me-2 d-flex flex-wrap align-items-center gap-1\">\n <!-- Filter directly in Trigger Box -->\n @if (filterInTrigger()) {\n <!-- Chips in multiple mode when filterInTrigger is active -->\n @if (multiple() && display() === 'chip' && hasSelectedValue()) {\n @for (val of value(); track val) {\n <span\n class=\"badge bg-light text-dark border d-inline-flex align-items-center gap-1 py-1 px-2\"\n >\n @if (chipTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n chipTemplate;\n context: { $implicit: findOptionByValue(val) ?? val, value: val }\n \"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabelByValue(val) }}</span>\n }\n @if (!disabled() && !readonly()) {\n <i\n class=\"bi bi-x ms-1 cursor-pointer fw-bold\"\n (click)=\"removeChip(val, $event)\"\n ></i>\n }\n </span>\n }\n }\n <!-- Search Filter Input embedded inside the trigger -->\n <input\n #triggerFilterInput\n type=\"text\"\n class=\"form-control border-0 bg-transparent p-0 shadow-none flex-grow-1\"\n style=\"min-width: 80px\"\n [class.form-control-sm]=\"size() === 'small'\"\n [class.form-control-lg]=\"size() === 'large'\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"effectiveFilterValue()\"\n [placeholder]=\"\n multiple() && hasSelectedValue()\n ? ''\n : hasSelectedValue() && !overlayVisible()\n ? getDisplayLabel()\n : effectiveSearchPlaceholder()\n \"\n (input)=\"onFilterChange($event)\"\n (keydown)=\"onFilterKeydown($event)\"\n (focus)=\"openOverlay($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <!-- Editable Input (Single mode only) -->\n @if (editable() && !multiple()) {\n <input\n #editableInput\n type=\"text\"\n class=\"form-control border-0 bg-transparent p-0 shadow-none\"\n [class.form-control-sm]=\"size() === 'small'\"\n [class.form-control-lg]=\"size() === 'large'\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [attr.maxlength]=\"maxLength()\"\n [value]=\"getDisplayLabel()\"\n [placeholder]=\"placeholder() || ''\"\n (input)=\"onEditableInput($event)\"\n (focus)=\"onEditableFocus($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <!-- Multi-Select Chips Display Mode -->\n @if (multiple() && display() === 'chip' && hasSelectedValue()) {\n @for (val of value(); track val) {\n <span\n class=\"badge bg-light text-dark border d-inline-flex align-items-center gap-1 py-1 px-2\"\n >\n @if (chipTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n chipTemplate;\n context: { $implicit: findOptionByValue(val) ?? val, value: val }\n \"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabelByValue(val) }}</span>\n }\n @if (!disabled() && !readonly()) {\n <i\n class=\"bi bi-x ms-1 cursor-pointer fw-bold\"\n (click)=\"removeChip(val, $event)\"\n ></i>\n }\n </span>\n }\n } @else {\n @if (hasSelectedValue()) {\n @if (selectedItemTemplate || labelTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n selectedItemTemplate || labelTemplate;\n context: { $implicit: findOptionByValue(value()) ?? value(), value: value() }\n \"\n ></ng-container>\n } @else {\n <span>{{ getDisplayLabel() }}</span>\n }\n } @else {\n <span class=\"text-muted\">{{ floatLabel() ? '' : placeholder() || '' }}</span>\n }\n }\n <!-- Standard Single or Comma Multi-Select Text -->\n }\n }\n </span>\n\n <!-- Icons & Spinners Area -->\n <div class=\"d-flex align-items-center flex-shrink-0 gap-1 ms-auto\">\n <!-- Clear Icon -->\n @if (showClear() && hasSelectedValue() && !disabled() && !readonly()) {\n <span\n class=\"ngb-select-clear-icon text-muted me-1\"\n (click)=\"onClearClick($event)\"\n title=\"Clear\"\n tabindex=\"0\"\n role=\"button\"\n aria-label=\"Clear value\"\n >\n @if (clearIconTemplate) {\n <ng-container *ngTemplateOutlet=\"clearIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-x-circle-fill\"></i>\n }\n </span>\n }\n\n <!-- Loading Spinner -->\n @if (loading()) {\n <div class=\"spinner-border spinner-border-sm text-secondary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n }\n\n <!-- Dropdown Caret Icon -->\n @if (!loading()) {\n <span class=\"ngb-select-dropdown-icon text-secondary\">\n @if (dropdownIconTemplate) {\n <ng-container *ngTemplateOutlet=\"dropdownIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-chevron-down\" [class.rotate-180]=\"overlayVisible()\"></i>\n }\n </span>\n }\n </div>\n </div>\n\n <!-- Float Label Support -->\n @if (floatLabel() && placeholder()) {\n <label [attr.for]=\"id()\">{{ placeholder() }}</label>\n }\n\n <ng-template #dropdownContent>\n <!-- Header Template -->\n @if (headerTemplate) {\n <div class=\"p-2 border-bottom\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </div>\n }\n\n <!-- Header: Select All Checkbox & Search / Filter Box -->\n @if ((filter() && !filterInTrigger()) || (multiple() && showSelectAll())) {\n <div class=\"p-2 border-bottom bg-light bg-opacity-50\">\n <!-- Select All Checkbox -->\n @if (multiple() && showSelectAll()) {\n <div class=\"d-flex align-items-center mb-2 px-1\">\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0 cursor-pointer\"\n [checked]=\"selectAll()\"\n (change)=\"toggleSelectAll($event)\"\n id=\"selectAllCheckbox\"\n />\n <label\n class=\"form-check-label small fw-semibold cursor-pointer user-select-none\"\n for=\"selectAllCheckbox\"\n >\n @if (headerCheckboxTemplate) {\n <ng-container\n *ngTemplateOutlet=\"headerCheckboxTemplate; context: { $implicit: selectAll() }\"\n ></ng-container>\n } @else {\n Select All\n }\n </label>\n </div>\n }\n <!-- Search Box -->\n @if (filter() && !filterInTrigger()) {\n <div class=\"input-group input-group-sm\">\n <span class=\"input-group-text bg-transparent border-end-0\">\n @if (filterIconTemplate) {\n <ng-container *ngTemplateOutlet=\"filterIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-search text-muted\"></i>\n }\n </span>\n <input\n #filterInput\n type=\"text\"\n class=\"form-control border-start-0\"\n [placeholder]=\"effectiveSearchPlaceholder()\"\n [value]=\"filterValue()\"\n (input)=\"onFilterChange($event)\"\n (keydown)=\"onFilterKeydown($event)\"\n />\n </div>\n }\n </div>\n }\n\n <!-- Grouped Options Mode -->\n @if (group()) {\n @for (groupOption of filteredOptions(); track groupOption) {\n <div>\n <!-- Group Header -->\n <h6\n class=\"dropdown-header text-muted py-2 px-3 m-0 bg-light bg-opacity-75 d-flex align-items-center\"\n >\n @if (groupTemplate) {\n <ng-container\n *ngTemplateOutlet=\"groupTemplate; context: { $implicit: groupOption }\"\n ></ng-container>\n } @else {\n {{ resolveOptionGroupLabel(groupOption) }}\n }\n </h6>\n <!-- Group Items -->\n @for (option of resolveOptionGroupChildren(groupOption); track option) {\n <button\n type=\"button\"\n class=\"dropdown-item d-flex align-items-center py-2 px-3\"\n [class.active]=\"!multiple() && isSelected(option)\"\n [class.bg-light]=\"multiple() && isSelected(option)\"\n [class.fw-semibold]=\"multiple() && isSelected(option)\"\n [class.focus]=\"isOptionFocused(option)\"\n [class.bg-body-secondary]=\"isOptionFocused(option) && !isSelected(option)\"\n [class.disabled]=\"isOptionDisabled(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(option)\"\n [attr.aria-checked]=\"multiple() ? isSelected(option) : null\"\n (click)=\"onOptionClick(option, $event)\"\n >\n <!-- Checkbox in Multiple Mode synced to selection -->\n @if (multiple()) {\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0\"\n style=\"pointer-events: none\"\n [checked]=\"isSelected(option)\"\n tabindex=\"-1\"\n />\n }\n @if (itemTemplate) {\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: option }\"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabel(option) }}</span>\n }\n </button>\n }\n </div>\n }\n } @else {\n @for (option of filteredOptions(); track option; let i = $index) {\n <button\n type=\"button\"\n class=\"dropdown-item d-flex align-items-center py-2 px-3\"\n [class.active]=\"!multiple() && isSelected(option)\"\n [class.bg-light]=\"multiple() && isSelected(option)\"\n [class.fw-semibold]=\"multiple() && isSelected(option)\"\n [class.focus]=\"isOptionFocused(option)\"\n [class.bg-body-secondary]=\"isOptionFocused(option) && !isSelected(option)\"\n [class.disabled]=\"isOptionDisabled(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(option)\"\n [attr.aria-checked]=\"multiple() ? isSelected(option) : null\"\n (click)=\"onOptionClick(option, $event)\"\n >\n <!-- Checkbox in Multiple Mode synced to selection -->\n @if (multiple()) {\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0\"\n style=\"pointer-events: none\"\n [checked]=\"isSelected(option)\"\n tabindex=\"-1\"\n />\n }\n @if (itemTemplate) {\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: option }\"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabel(option) }}</span>\n }\n </button>\n }\n }\n\n <!-- Empty State Message -->\n @if (isOptionsEmpty()) {\n <div class=\"dropdown-item text-muted text-center py-3\">\n @if (emptyTemplate) {\n <ng-container *ngTemplateOutlet=\"emptyTemplate\"></ng-container>\n } @else {\n <small>{{\n filterValue()\n ? emptyFilterMessage() || 'No results found'\n : emptyMessage() || 'No results found'\n }}</small>\n }\n </div>\n }\n </ng-template>\n\n @if (isModalMode()) {\n <!-- Bootstrap Modal Overlay -->\n @if (overlayVisible()) {\n <div\n class=\"modal fade show d-block\"\n tabindex=\"-1\"\n role=\"dialog\"\n aria-modal=\"true\"\n style=\"background-color: rgba(0, 0, 0, 0.45); z-index: 1075\"\n (click)=\"closeOverlay($event)\"\n >\n <div\n class=\"modal-dialog modal-dialog-centered modal-dialog-scrollable\"\n role=\"document\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"modal-content shadow\" [ngClass]=\"panelStyleClass()\" [ngStyle]=\"panelStyle()\">\n <!-- Modal Header -->\n <div class=\"modal-header bg-light bg-opacity-50 py-2 px-3\">\n <h6 class=\"modal-title m-0 fw-semibold text-truncate\">{{ effectivePopupTitle() }}</h6>\n <button\n type=\"button\"\n class=\"btn-close\"\n aria-label=\"Close\"\n (click)=\"closeOverlay($event)\"\n ></button>\n </div>\n\n <!-- Modal Body (Options Content) -->\n <div\n class=\"modal-body p-0\"\n #dropdownMenu\n role=\"listbox\"\n (scroll)=\"onOverlayScroll($event)\"\n >\n <ng-container *ngTemplateOutlet=\"dropdownContent\"></ng-container>\n </div>\n\n <!-- Modal Footer (Custom Template or Done Button) -->\n @if (footerTemplate || multiple()) {\n <div\n class=\"modal-footer p-2 bg-light bg-opacity-50 d-flex align-items-center justify-content-end\"\n >\n @if (footerTemplate) {\n <div class=\"w-100\">\n <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n </div>\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-sm btn-primary px-3\"\n (click)=\"closeOverlay($event)\"\n >\n Done\n </button>\n }\n </div>\n }\n </div>\n </div>\n </div>\n }\n } @else {\n <!-- Standard Dropdown Menu -->\n <div\n #dropdownMenu\n class=\"dropdown-menu shadow-sm p-0\"\n [class.show]=\"overlayVisible()\"\n [ngStyle]=\"panelStyle()\"\n [ngClass]=\"panelStyleClass()\"\n [style.max-height]=\"scrollHeight()\"\n style=\"overflow-y: auto\"\n role=\"listbox\"\n (scroll)=\"onOverlayScroll($event)\"\n (click)=\"$event.stopPropagation()\"\n >\n <ng-container *ngTemplateOutlet=\"dropdownContent\"></ng-container>\n\n <!-- Footer Template -->\n @if (footerTemplate) {\n <div class=\"p-2 border-top\">\n <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block;width:100%}:host.inline{display:inline-block;width:auto}.ngb-select-container{position:relative;-webkit-user-select:none;user-select:none;width:100%}.ngb-select-container .form-select{cursor:pointer;min-height:38px;background-image:none;padding-right:.75rem;padding-left:.75rem}.ngb-select-container .form-select.form-select-sm{min-height:31px;padding-right:.5rem;padding-left:.5rem}.ngb-select-container .form-select.form-select-lg{min-height:48px;padding-right:1rem;padding-left:1rem}.ngb-select-container .form-select.disabled,.ngb-select-container .form-select:disabled{cursor:not-allowed;background-color:var(--bs-secondary-bg);opacity:.65}.ngb-select-container.form-floating{display:block;width:100%;position:relative}.ngb-select-container.form-floating.float-variant-on,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over){margin-top:.35rem}.ngb-select-container.form-floating.float-variant-on .form-select,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select{min-height:38px;height:auto;padding:.375rem .75rem;align-items:center}.ngb-select-container.form-floating.float-variant-on .form-select.form-select-sm,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select.form-select-sm{min-height:31px;padding-top:.25rem;padding-bottom:.25rem}.ngb-select-container.form-floating.float-variant-on .form-select.form-select-lg,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select.form-select-lg{min-height:48px;padding-top:.5rem;padding-bottom:.5rem}.ngb-select-container.form-floating.float-variant-on>label,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over)>label{position:absolute;top:50%;left:.75rem;transform:translateY(-50%);height:auto;padding:0 .35rem;margin:0;line-height:1;font-size:.95rem;color:var(--bs-secondary-color);pointer-events:none;border-radius:var(--bs-border-radius);background-color:transparent;transform-origin:left center;transition:transform .2s cubic-bezier(.25,.8,.25,1),top .2s cubic-bezier(.25,.8,.25,1),color .2s ease-in-out,background-color .2s ease-in-out;z-index:5}.ngb-select-container.form-floating.float-variant-on.floating-active>label,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over).floating-active>label{top:0;transform:translateY(-50%) scale(.85);background-color:var(--bs-body-bg);color:var(--bs-primary);font-weight:600}.ngb-select-container.form-floating.float-variant-in .form-select{height:calc(3.5rem + 2px);min-height:calc(3.5rem + 2px);padding:1.625rem .75rem .5rem;align-items:flex-end}.ngb-select-container.form-floating.float-variant-in>label{position:absolute;top:0;left:0;z-index:2;height:100%;padding:1rem .75rem;overflow:hidden;text-align:start;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;border:var(--bs-border-width) solid transparent;transform-origin:0 0;transition:opacity .15s ease-in-out,transform .15s ease-in-out,color .15s ease-in-out;color:rgba(var(--bs-body-color-rgb),.65);transform:scale(1) translateY(0)}.ngb-select-container.form-floating.float-variant-in.floating-active>label{transform:scale(.85) translateY(-.65rem) translate(.15rem);color:var(--bs-primary);font-weight:500}.ngb-select-container.form-floating.float-variant-over{margin-top:1.25rem}.ngb-select-container.form-floating.float-variant-over .form-select{min-height:38px;height:auto;padding:.375rem .75rem;align-items:center}.ngb-select-container.form-floating.float-variant-over .form-select.form-select-sm{min-height:31px}.ngb-select-container.form-floating.float-variant-over .form-select.form-select-lg{min-height:48px}.ngb-select-container.form-floating.float-variant-over>label{position:absolute;top:50%;left:.75rem;transform:translateY(-50%);height:auto;padding:0;margin:0;line-height:1;font-size:.95rem;color:var(--bs-secondary-color);pointer-events:none;transform-origin:left center;transition:transform .2s cubic-bezier(.25,.8,.25,1),top .2s cubic-bezier(.25,.8,.25,1),color .2s ease-in-out;z-index:5}.ngb-select-container.form-floating.float-variant-over.floating-active>label{top:-.75rem;transform:scale(.85);color:var(--bs-primary);font-weight:600}.ngb-select-container .ngb-select-clear-icon,.ngb-select-container .ngb-select-dropdown-icon{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;font-size:.875rem}.ngb-select-container .ngb-select-clear-icon i,.ngb-select-container .ngb-select-dropdown-icon i{transition:transform .2s ease-in-out}.ngb-select-container .ngb-select-clear-icon i.rotate-180,.ngb-select-container .ngb-select-dropdown-icon i.rotate-180{transform:rotate(180deg)}.ngb-select-container .ngb-select-clear-icon{opacity:.6;transition:opacity .15s ease}.ngb-select-container .ngb-select-clear-icon:hover{opacity:1}.ngb-select-container.dropup .dropdown-menu,.ngb-select-container.dropdown-up .dropdown-menu{top:auto;bottom:100%;margin-top:0;margin-bottom:.125rem}.dropdown-menu{top:100%;left:0;width:100%;min-width:100%;margin-top:.125rem;z-index:1060;box-sizing:border-box;text-align:inherit}.dropdown-menu .dropdown-item{cursor:pointer;white-space:normal;word-break:break-word;text-align:inherit}.dropdown-menu .dropdown-item.disabled,.dropdown-menu .dropdown-item:disabled{cursor:not-allowed;opacity:.5}.dropdown-menu .dropdown-item.focus,.dropdown-menu .dropdown-item.focused,.dropdown-menu .dropdown-item:focus{color:var(--bs-dropdown-link-hover-color, inherit);background-color:var(--bs-dropdown-link-hover-bg, var(--bs-tertiary-bg))!important}.dropdown-menu .dropdown-item.active{color:var(--bs-dropdown-link-active-color)!important;background-color:var(--bs-dropdown-link-active-bg)!important}.dropdown-menu .dropdown-header{font-weight:600;text-transform:uppercase;font-size:.75rem;letter-spacing:.05em;text-align:inherit}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }] });
|
|
851
|
+
}
|
|
852
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: NgbSelectComponent, decorators: [{
|
|
853
|
+
type: Component,
|
|
854
|
+
args: [{ selector: 'ngb-select', standalone: true, imports: [CommonModule, FormsModule], providers: [
|
|
855
|
+
{
|
|
856
|
+
provide: NG_VALUE_ACCESSOR,
|
|
857
|
+
useExisting: forwardRef(() => NgbSelectComponent),
|
|
858
|
+
multi: true,
|
|
859
|
+
},
|
|
860
|
+
], template: "<div\n class=\"ngb-select-container position-relative\"\n [class.form-floating]=\"floatLabel()\"\n [class.float-variant-on]=\"floatLabel() && floatLabelVariant() === 'on'\"\n [class.float-variant-in]=\"floatLabel() && floatLabelVariant() === 'in'\"\n [class.float-variant-over]=\"floatLabel() && floatLabelVariant() === 'over'\"\n [class.floating-active]=\"hasSelectedValue() || overlayVisible()\"\n [class.dropup]=\"isDropup()\"\n [class.dropdown-up]=\"isDropup()\"\n [class.w-100]=\"fluid()\"\n [attr.dir]=\"dir() || null\"\n [ngStyle]=\"style()\"\n [ngClass]=\"styleClass()\"\n (keydown)=\"onKeydown($event)\"\n>\n <!-- Select Trigger Box -->\n <div\n class=\"form-select d-flex align-items-center justify-content-between\"\n [class.is-invalid]=\"invalid()\"\n [class.disabled]=\"disabled()\"\n [class.form-select-sm]=\"size() === 'small'\"\n [class.form-select-lg]=\"size() === 'large'\"\n [class.bg-light]=\"variant() === 'filled'\"\n [attr.id]=\"id()\"\n [attr.tabindex]=\"disabled() ? -1 : tabindex()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledBy()\"\n [attr.aria-expanded]=\"overlayVisible()\"\n [attr.aria-haspopup]=\"'listbox'\"\n role=\"combobox\"\n (click)=\"onTriggerClick($event)\"\n (focus)=\"onTriggerFocus($event)\"\n (blur)=\"onTriggerBlur($event)\"\n >\n <!-- Selected Value / Input / Chips Area -->\n <span class=\"text-truncate flex-grow-1 me-2 d-flex flex-wrap align-items-center gap-1\">\n <!-- Filter directly in Trigger Box -->\n @if (filterInTrigger()) {\n <!-- Chips in multiple mode when filterInTrigger is active -->\n @if (multiple() && display() === 'chip' && hasSelectedValue()) {\n @for (val of value(); track val) {\n <span\n class=\"badge bg-light text-dark border d-inline-flex align-items-center gap-1 py-1 px-2\"\n >\n @if (chipTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n chipTemplate;\n context: { $implicit: findOptionByValue(val) ?? val, value: val }\n \"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabelByValue(val) }}</span>\n }\n @if (!disabled() && !readonly()) {\n <i\n class=\"bi bi-x ms-1 cursor-pointer fw-bold\"\n (click)=\"removeChip(val, $event)\"\n ></i>\n }\n </span>\n }\n }\n <!-- Search Filter Input embedded inside the trigger -->\n <input\n #triggerFilterInput\n type=\"text\"\n class=\"form-control border-0 bg-transparent p-0 shadow-none flex-grow-1\"\n style=\"min-width: 80px\"\n [class.form-control-sm]=\"size() === 'small'\"\n [class.form-control-lg]=\"size() === 'large'\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"effectiveFilterValue()\"\n [placeholder]=\"\n multiple() && hasSelectedValue()\n ? ''\n : hasSelectedValue() && !overlayVisible()\n ? getDisplayLabel()\n : effectiveSearchPlaceholder()\n \"\n (input)=\"onFilterChange($event)\"\n (keydown)=\"onFilterKeydown($event)\"\n (focus)=\"openOverlay($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <!-- Editable Input (Single mode only) -->\n @if (editable() && !multiple()) {\n <input\n #editableInput\n type=\"text\"\n class=\"form-control border-0 bg-transparent p-0 shadow-none\"\n [class.form-control-sm]=\"size() === 'small'\"\n [class.form-control-lg]=\"size() === 'large'\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [attr.maxlength]=\"maxLength()\"\n [value]=\"getDisplayLabel()\"\n [placeholder]=\"placeholder() || ''\"\n (input)=\"onEditableInput($event)\"\n (focus)=\"onEditableFocus($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <!-- Multi-Select Chips Display Mode -->\n @if (multiple() && display() === 'chip' && hasSelectedValue()) {\n @for (val of value(); track val) {\n <span\n class=\"badge bg-light text-dark border d-inline-flex align-items-center gap-1 py-1 px-2\"\n >\n @if (chipTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n chipTemplate;\n context: { $implicit: findOptionByValue(val) ?? val, value: val }\n \"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabelByValue(val) }}</span>\n }\n @if (!disabled() && !readonly()) {\n <i\n class=\"bi bi-x ms-1 cursor-pointer fw-bold\"\n (click)=\"removeChip(val, $event)\"\n ></i>\n }\n </span>\n }\n } @else {\n @if (hasSelectedValue()) {\n @if (selectedItemTemplate || labelTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n selectedItemTemplate || labelTemplate;\n context: { $implicit: findOptionByValue(value()) ?? value(), value: value() }\n \"\n ></ng-container>\n } @else {\n <span>{{ getDisplayLabel() }}</span>\n }\n } @else {\n <span class=\"text-muted\">{{ floatLabel() ? '' : placeholder() || '' }}</span>\n }\n }\n <!-- Standard Single or Comma Multi-Select Text -->\n }\n }\n </span>\n\n <!-- Icons & Spinners Area -->\n <div class=\"d-flex align-items-center flex-shrink-0 gap-1 ms-auto\">\n <!-- Clear Icon -->\n @if (showClear() && hasSelectedValue() && !disabled() && !readonly()) {\n <span\n class=\"ngb-select-clear-icon text-muted me-1\"\n (click)=\"onClearClick($event)\"\n title=\"Clear\"\n tabindex=\"0\"\n role=\"button\"\n aria-label=\"Clear value\"\n >\n @if (clearIconTemplate) {\n <ng-container *ngTemplateOutlet=\"clearIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-x-circle-fill\"></i>\n }\n </span>\n }\n\n <!-- Loading Spinner -->\n @if (loading()) {\n <div class=\"spinner-border spinner-border-sm text-secondary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n }\n\n <!-- Dropdown Caret Icon -->\n @if (!loading()) {\n <span class=\"ngb-select-dropdown-icon text-secondary\">\n @if (dropdownIconTemplate) {\n <ng-container *ngTemplateOutlet=\"dropdownIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-chevron-down\" [class.rotate-180]=\"overlayVisible()\"></i>\n }\n </span>\n }\n </div>\n </div>\n\n <!-- Float Label Support -->\n @if (floatLabel() && placeholder()) {\n <label [attr.for]=\"id()\">{{ placeholder() }}</label>\n }\n\n <ng-template #dropdownContent>\n <!-- Header Template -->\n @if (headerTemplate) {\n <div class=\"p-2 border-bottom\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </div>\n }\n\n <!-- Header: Select All Checkbox & Search / Filter Box -->\n @if ((filter() && !filterInTrigger()) || (multiple() && showSelectAll())) {\n <div class=\"p-2 border-bottom bg-light bg-opacity-50\">\n <!-- Select All Checkbox -->\n @if (multiple() && showSelectAll()) {\n <div class=\"d-flex align-items-center mb-2 px-1\">\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0 cursor-pointer\"\n [checked]=\"selectAll()\"\n (change)=\"toggleSelectAll($event)\"\n id=\"selectAllCheckbox\"\n />\n <label\n class=\"form-check-label small fw-semibold cursor-pointer user-select-none\"\n for=\"selectAllCheckbox\"\n >\n @if (headerCheckboxTemplate) {\n <ng-container\n *ngTemplateOutlet=\"headerCheckboxTemplate; context: { $implicit: selectAll() }\"\n ></ng-container>\n } @else {\n Select All\n }\n </label>\n </div>\n }\n <!-- Search Box -->\n @if (filter() && !filterInTrigger()) {\n <div class=\"input-group input-group-sm\">\n <span class=\"input-group-text bg-transparent border-end-0\">\n @if (filterIconTemplate) {\n <ng-container *ngTemplateOutlet=\"filterIconTemplate\"></ng-container>\n } @else {\n <i class=\"bi bi-search text-muted\"></i>\n }\n </span>\n <input\n #filterInput\n type=\"text\"\n class=\"form-control border-start-0\"\n [placeholder]=\"effectiveSearchPlaceholder()\"\n [value]=\"filterValue()\"\n (input)=\"onFilterChange($event)\"\n (keydown)=\"onFilterKeydown($event)\"\n />\n </div>\n }\n </div>\n }\n\n <!-- Grouped Options Mode -->\n @if (group()) {\n @for (groupOption of filteredOptions(); track groupOption) {\n <div>\n <!-- Group Header -->\n <h6\n class=\"dropdown-header text-muted py-2 px-3 m-0 bg-light bg-opacity-75 d-flex align-items-center\"\n >\n @if (groupTemplate) {\n <ng-container\n *ngTemplateOutlet=\"groupTemplate; context: { $implicit: groupOption }\"\n ></ng-container>\n } @else {\n {{ resolveOptionGroupLabel(groupOption) }}\n }\n </h6>\n <!-- Group Items -->\n @for (option of resolveOptionGroupChildren(groupOption); track option) {\n <button\n type=\"button\"\n class=\"dropdown-item d-flex align-items-center py-2 px-3\"\n [class.active]=\"!multiple() && isSelected(option)\"\n [class.bg-light]=\"multiple() && isSelected(option)\"\n [class.fw-semibold]=\"multiple() && isSelected(option)\"\n [class.focus]=\"isOptionFocused(option)\"\n [class.bg-body-secondary]=\"isOptionFocused(option) && !isSelected(option)\"\n [class.disabled]=\"isOptionDisabled(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(option)\"\n [attr.aria-checked]=\"multiple() ? isSelected(option) : null\"\n (click)=\"onOptionClick(option, $event)\"\n >\n <!-- Checkbox in Multiple Mode synced to selection -->\n @if (multiple()) {\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0\"\n style=\"pointer-events: none\"\n [checked]=\"isSelected(option)\"\n tabindex=\"-1\"\n />\n }\n @if (itemTemplate) {\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: option }\"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabel(option) }}</span>\n }\n </button>\n }\n </div>\n }\n } @else {\n @for (option of filteredOptions(); track option; let i = $index) {\n <button\n type=\"button\"\n class=\"dropdown-item d-flex align-items-center py-2 px-3\"\n [class.active]=\"!multiple() && isSelected(option)\"\n [class.bg-light]=\"multiple() && isSelected(option)\"\n [class.fw-semibold]=\"multiple() && isSelected(option)\"\n [class.focus]=\"isOptionFocused(option)\"\n [class.bg-body-secondary]=\"isOptionFocused(option) && !isSelected(option)\"\n [class.disabled]=\"isOptionDisabled(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(option)\"\n [attr.aria-checked]=\"multiple() ? isSelected(option) : null\"\n (click)=\"onOptionClick(option, $event)\"\n >\n <!-- Checkbox in Multiple Mode synced to selection -->\n @if (multiple()) {\n <input\n type=\"checkbox\"\n class=\"form-check-input me-2 mt-0\"\n style=\"pointer-events: none\"\n [checked]=\"isSelected(option)\"\n tabindex=\"-1\"\n />\n }\n @if (itemTemplate) {\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: option }\"\n ></ng-container>\n } @else {\n <span>{{ resolveOptionLabel(option) }}</span>\n }\n </button>\n }\n }\n\n <!-- Empty State Message -->\n @if (isOptionsEmpty()) {\n <div class=\"dropdown-item text-muted text-center py-3\">\n @if (emptyTemplate) {\n <ng-container *ngTemplateOutlet=\"emptyTemplate\"></ng-container>\n } @else {\n <small>{{\n filterValue()\n ? emptyFilterMessage() || 'No results found'\n : emptyMessage() || 'No results found'\n }}</small>\n }\n </div>\n }\n </ng-template>\n\n @if (isModalMode()) {\n <!-- Bootstrap Modal Overlay -->\n @if (overlayVisible()) {\n <div\n class=\"modal fade show d-block\"\n tabindex=\"-1\"\n role=\"dialog\"\n aria-modal=\"true\"\n style=\"background-color: rgba(0, 0, 0, 0.45); z-index: 1075\"\n (click)=\"closeOverlay($event)\"\n >\n <div\n class=\"modal-dialog modal-dialog-centered modal-dialog-scrollable\"\n role=\"document\"\n (click)=\"$event.stopPropagation()\"\n >\n <div class=\"modal-content shadow\" [ngClass]=\"panelStyleClass()\" [ngStyle]=\"panelStyle()\">\n <!-- Modal Header -->\n <div class=\"modal-header bg-light bg-opacity-50 py-2 px-3\">\n <h6 class=\"modal-title m-0 fw-semibold text-truncate\">{{ effectivePopupTitle() }}</h6>\n <button\n type=\"button\"\n class=\"btn-close\"\n aria-label=\"Close\"\n (click)=\"closeOverlay($event)\"\n ></button>\n </div>\n\n <!-- Modal Body (Options Content) -->\n <div\n class=\"modal-body p-0\"\n #dropdownMenu\n role=\"listbox\"\n (scroll)=\"onOverlayScroll($event)\"\n >\n <ng-container *ngTemplateOutlet=\"dropdownContent\"></ng-container>\n </div>\n\n <!-- Modal Footer (Custom Template or Done Button) -->\n @if (footerTemplate || multiple()) {\n <div\n class=\"modal-footer p-2 bg-light bg-opacity-50 d-flex align-items-center justify-content-end\"\n >\n @if (footerTemplate) {\n <div class=\"w-100\">\n <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n </div>\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-sm btn-primary px-3\"\n (click)=\"closeOverlay($event)\"\n >\n Done\n </button>\n }\n </div>\n }\n </div>\n </div>\n </div>\n }\n } @else {\n <!-- Standard Dropdown Menu -->\n <div\n #dropdownMenu\n class=\"dropdown-menu shadow-sm p-0\"\n [class.show]=\"overlayVisible()\"\n [ngStyle]=\"panelStyle()\"\n [ngClass]=\"panelStyleClass()\"\n [style.max-height]=\"scrollHeight()\"\n style=\"overflow-y: auto\"\n role=\"listbox\"\n (scroll)=\"onOverlayScroll($event)\"\n (click)=\"$event.stopPropagation()\"\n >\n <ng-container *ngTemplateOutlet=\"dropdownContent\"></ng-container>\n\n <!-- Footer Template -->\n @if (footerTemplate) {\n <div class=\"p-2 border-top\">\n <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block;width:100%}:host.inline{display:inline-block;width:auto}.ngb-select-container{position:relative;-webkit-user-select:none;user-select:none;width:100%}.ngb-select-container .form-select{cursor:pointer;min-height:38px;background-image:none;padding-right:.75rem;padding-left:.75rem}.ngb-select-container .form-select.form-select-sm{min-height:31px;padding-right:.5rem;padding-left:.5rem}.ngb-select-container .form-select.form-select-lg{min-height:48px;padding-right:1rem;padding-left:1rem}.ngb-select-container .form-select.disabled,.ngb-select-container .form-select:disabled{cursor:not-allowed;background-color:var(--bs-secondary-bg);opacity:.65}.ngb-select-container.form-floating{display:block;width:100%;position:relative}.ngb-select-container.form-floating.float-variant-on,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over){margin-top:.35rem}.ngb-select-container.form-floating.float-variant-on .form-select,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select{min-height:38px;height:auto;padding:.375rem .75rem;align-items:center}.ngb-select-container.form-floating.float-variant-on .form-select.form-select-sm,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select.form-select-sm{min-height:31px;padding-top:.25rem;padding-bottom:.25rem}.ngb-select-container.form-floating.float-variant-on .form-select.form-select-lg,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over) .form-select.form-select-lg{min-height:48px;padding-top:.5rem;padding-bottom:.5rem}.ngb-select-container.form-floating.float-variant-on>label,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over)>label{position:absolute;top:50%;left:.75rem;transform:translateY(-50%);height:auto;padding:0 .35rem;margin:0;line-height:1;font-size:.95rem;color:var(--bs-secondary-color);pointer-events:none;border-radius:var(--bs-border-radius);background-color:transparent;transform-origin:left center;transition:transform .2s cubic-bezier(.25,.8,.25,1),top .2s cubic-bezier(.25,.8,.25,1),color .2s ease-in-out,background-color .2s ease-in-out;z-index:5}.ngb-select-container.form-floating.float-variant-on.floating-active>label,.ngb-select-container.form-floating:not(.float-variant-in):not(.float-variant-over).floating-active>label{top:0;transform:translateY(-50%) scale(.85);background-color:var(--bs-body-bg);color:var(--bs-primary);font-weight:600}.ngb-select-container.form-floating.float-variant-in .form-select{height:calc(3.5rem + 2px);min-height:calc(3.5rem + 2px);padding:1.625rem .75rem .5rem;align-items:flex-end}.ngb-select-container.form-floating.float-variant-in>label{position:absolute;top:0;left:0;z-index:2;height:100%;padding:1rem .75rem;overflow:hidden;text-align:start;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;border:var(--bs-border-width) solid transparent;transform-origin:0 0;transition:opacity .15s ease-in-out,transform .15s ease-in-out,color .15s ease-in-out;color:rgba(var(--bs-body-color-rgb),.65);transform:scale(1) translateY(0)}.ngb-select-container.form-floating.float-variant-in.floating-active>label{transform:scale(.85) translateY(-.65rem) translate(.15rem);color:var(--bs-primary);font-weight:500}.ngb-select-container.form-floating.float-variant-over{margin-top:1.25rem}.ngb-select-container.form-floating.float-variant-over .form-select{min-height:38px;height:auto;padding:.375rem .75rem;align-items:center}.ngb-select-container.form-floating.float-variant-over .form-select.form-select-sm{min-height:31px}.ngb-select-container.form-floating.float-variant-over .form-select.form-select-lg{min-height:48px}.ngb-select-container.form-floating.float-variant-over>label{position:absolute;top:50%;left:.75rem;transform:translateY(-50%);height:auto;padding:0;margin:0;line-height:1;font-size:.95rem;color:var(--bs-secondary-color);pointer-events:none;transform-origin:left center;transition:transform .2s cubic-bezier(.25,.8,.25,1),top .2s cubic-bezier(.25,.8,.25,1),color .2s ease-in-out;z-index:5}.ngb-select-container.form-floating.float-variant-over.floating-active>label{top:-.75rem;transform:scale(.85);color:var(--bs-primary);font-weight:600}.ngb-select-container .ngb-select-clear-icon,.ngb-select-container .ngb-select-dropdown-icon{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;font-size:.875rem}.ngb-select-container .ngb-select-clear-icon i,.ngb-select-container .ngb-select-dropdown-icon i{transition:transform .2s ease-in-out}.ngb-select-container .ngb-select-clear-icon i.rotate-180,.ngb-select-container .ngb-select-dropdown-icon i.rotate-180{transform:rotate(180deg)}.ngb-select-container .ngb-select-clear-icon{opacity:.6;transition:opacity .15s ease}.ngb-select-container .ngb-select-clear-icon:hover{opacity:1}.ngb-select-container.dropup .dropdown-menu,.ngb-select-container.dropdown-up .dropdown-menu{top:auto;bottom:100%;margin-top:0;margin-bottom:.125rem}.dropdown-menu{top:100%;left:0;width:100%;min-width:100%;margin-top:.125rem;z-index:1060;box-sizing:border-box;text-align:inherit}.dropdown-menu .dropdown-item{cursor:pointer;white-space:normal;word-break:break-word;text-align:inherit}.dropdown-menu .dropdown-item.disabled,.dropdown-menu .dropdown-item:disabled{cursor:not-allowed;opacity:.5}.dropdown-menu .dropdown-item.focus,.dropdown-menu .dropdown-item.focused,.dropdown-menu .dropdown-item:focus{color:var(--bs-dropdown-link-hover-color, inherit);background-color:var(--bs-dropdown-link-hover-bg, var(--bs-tertiary-bg))!important}.dropdown-menu .dropdown-item.active{color:var(--bs-dropdown-link-active-color)!important;background-color:var(--bs-dropdown-link-active-bg)!important}.dropdown-menu .dropdown-header{font-weight:600;text-transform:uppercase;font-size:.75rem;letter-spacing:.05em;text-align:inherit}\n"] }]
|
|
861
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], optionDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionDisabled", required: false }] }], optionGroupLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionGroupLabel", required: false }] }], optionGroupChildren: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionGroupChildren", required: false }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: false }] }], dataKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataKey", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], display: [{ type: i0.Input, args: [{ isSignal: true, alias: "display", required: false }] }], showSelectAll: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSelectAll", required: false }] }], maxSelectedLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelectedLabels", required: false }] }], selectedItemsLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedItemsLabel", required: false }] }], selectionLimit: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionLimit", required: false }] }], closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], filterBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterBy", required: false }] }], filterMatchMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterMatchMode", required: false }] }], filterLocale: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterLocale", required: false }] }], filterNormalizeArabic: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterNormalizeArabic", required: false }] }], filterPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPlaceholder", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], filterInTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterInTrigger", required: false }] }], resetFilterOnHide: [{ type: i0.Input, args: [{ isSignal: true, alias: "resetFilterOnHide", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], emptyFilterMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyFilterMessage", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], floatLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "floatLabel", required: false }] }], floatLabelVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "floatLabelVariant", required: false }] }], autofocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocus", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], dir: [{ type: i0.Input, args: [{ isSignal: true, alias: "dir", required: false }] }], dropdownPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownPosition", required: false }] }], dropdownDirection: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownDirection", required: false }] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], style: [{ type: i0.Input, args: [{ isSignal: true, alias: "style", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], panelStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelStyle", required: false }] }], panelStyleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelStyleClass", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], popup: [{ type: i0.Input, args: [{ isSignal: true, alias: "popup", required: false }] }], touchUI: [{ type: i0.Input, args: [{ isSignal: true, alias: "touchUI", required: false }] }], popupTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupTitle", required: false }] }], modalTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "modalTitle", required: false }] }], editable: [{ type: i0.Input, args: [{ isSignal: true, alias: "editable", required: false }] }], maxLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxLength", required: false }] }], selectOnFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectOnFocus", required: false }] }], autoOptionFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoOptionFocus", required: false }] }], focusOnOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnOpen", required: false }] }], focusOnOpenStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnOpenStrategy", required: false }] }], lazy: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazy", required: false }] }], overlayVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "overlayVisible", required: false }] }, { type: i0.Output, args: ["overlayVisibleChange"] }], onChange: [{ type: i0.Output, args: ["onChange"] }], onFilter: [{ type: i0.Output, args: ["onFilter"] }], onFocus: [{ type: i0.Output, args: ["onFocus"] }], onBlur: [{ type: i0.Output, args: ["onBlur"] }], onShow: [{ type: i0.Output, args: ["onShow"] }], onHide: [{ type: i0.Output, args: ["onHide"] }], onClear: [{ type: i0.Output, args: ["onClear"] }], onSelectAllChange: [{ type: i0.Output, args: ["onSelectAllChange"] }], onRemoveChip: [{ type: i0.Output, args: ["onRemoveChip"] }], onLazyLoad: [{ type: i0.Output, args: ["onLazyLoad"] }], itemTemplate: [{
|
|
862
|
+
type: ContentChild,
|
|
863
|
+
args: ['item']
|
|
864
|
+
}], selectedItemTemplate: [{
|
|
865
|
+
type: ContentChild,
|
|
866
|
+
args: ['selectedItem']
|
|
867
|
+
}], labelTemplate: [{
|
|
868
|
+
type: ContentChild,
|
|
869
|
+
args: ['label']
|
|
870
|
+
}], chipTemplate: [{
|
|
871
|
+
type: ContentChild,
|
|
872
|
+
args: ['chip']
|
|
873
|
+
}], headerCheckboxTemplate: [{
|
|
874
|
+
type: ContentChild,
|
|
875
|
+
args: ['headerCheckbox']
|
|
876
|
+
}], headerTemplate: [{
|
|
877
|
+
type: ContentChild,
|
|
878
|
+
args: ['header']
|
|
879
|
+
}], footerTemplate: [{
|
|
880
|
+
type: ContentChild,
|
|
881
|
+
args: ['footer']
|
|
882
|
+
}], groupTemplate: [{
|
|
883
|
+
type: ContentChild,
|
|
884
|
+
args: ['group']
|
|
885
|
+
}], emptyTemplate: [{
|
|
886
|
+
type: ContentChild,
|
|
887
|
+
args: ['empty']
|
|
888
|
+
}], clearIconTemplate: [{
|
|
889
|
+
type: ContentChild,
|
|
890
|
+
args: ['clearIcon']
|
|
891
|
+
}], dropdownIconTemplate: [{
|
|
892
|
+
type: ContentChild,
|
|
893
|
+
args: ['dropdownIcon']
|
|
894
|
+
}], filterIconTemplate: [{
|
|
895
|
+
type: ContentChild,
|
|
896
|
+
args: ['filterIcon']
|
|
897
|
+
}], filterInputElement: [{
|
|
898
|
+
type: ViewChild,
|
|
899
|
+
args: ['filterInput']
|
|
900
|
+
}], triggerFilterInputElement: [{
|
|
901
|
+
type: ViewChild,
|
|
902
|
+
args: ['triggerFilterInput']
|
|
903
|
+
}], editableInputElement: [{
|
|
904
|
+
type: ViewChild,
|
|
905
|
+
args: ['editableInput']
|
|
906
|
+
}], dropdownMenuElement: [{
|
|
907
|
+
type: ViewChild,
|
|
908
|
+
args: ['dropdownMenu']
|
|
909
|
+
}], onWindowResize: [{
|
|
910
|
+
type: HostListener,
|
|
911
|
+
args: ['window:resize']
|
|
912
|
+
}], onWindowScroll: [{
|
|
913
|
+
type: HostListener,
|
|
914
|
+
args: ['window:scroll']
|
|
915
|
+
}], onDocumentClick: [{
|
|
916
|
+
type: HostListener,
|
|
917
|
+
args: ['document:click', ['$event']]
|
|
918
|
+
}] } });
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Generated bundle index. Do not edit.
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
export { NGB_SELECT_VERSION, NgbSelectComponent };
|
|
925
|
+
//# sourceMappingURL=amro93-ngb-select.mjs.map
|