@apexara/ng-components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1867 -0
- package/fesm2022/apexara-ng-components-button.mjs +66 -0
- package/fesm2022/apexara-ng-components-button.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-carousel.mjs +161 -0
- package/fesm2022/apexara-ng-components-carousel.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-checkbox.mjs +64 -0
- package/fesm2022/apexara-ng-components-checkbox.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-chip.mjs +26 -0
- package/fesm2022/apexara-ng-components-chip.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-datepicker.mjs +2175 -0
- package/fesm2022/apexara-ng-components-datepicker.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-dialog.mjs +65 -0
- package/fesm2022/apexara-ng-components-dialog.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-drawer.mjs +69 -0
- package/fesm2022/apexara-ng-components-drawer.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-expander.mjs +41 -0
- package/fesm2022/apexara-ng-components-expander.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-image.mjs +201 -0
- package/fesm2022/apexara-ng-components-image.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-input.mjs +129 -0
- package/fesm2022/apexara-ng-components-input.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-listbox.mjs +308 -0
- package/fesm2022/apexara-ng-components-listbox.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-radiobutton.mjs +40 -0
- package/fesm2022/apexara-ng-components-radiobutton.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-select.mjs +620 -0
- package/fesm2022/apexara-ng-components-select.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-services.mjs +290 -0
- package/fesm2022/apexara-ng-components-services.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-snackbar.mjs +279 -0
- package/fesm2022/apexara-ng-components-snackbar.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-table.mjs +686 -0
- package/fesm2022/apexara-ng-components-table.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-textarea.mjs +82 -0
- package/fesm2022/apexara-ng-components-textarea.mjs.map +1 -0
- package/fesm2022/apexara-ng-components-tooltip.mjs +319 -0
- package/fesm2022/apexara-ng-components-tooltip.mjs.map +1 -0
- package/fesm2022/apexara-ng-components.mjs +8 -0
- package/fesm2022/apexara-ng-components.mjs.map +1 -0
- package/package.json +146 -0
- package/types/apexara-ng-components-button.d.ts +27 -0
- package/types/apexara-ng-components-carousel.d.ts +31 -0
- package/types/apexara-ng-components-checkbox.d.ts +29 -0
- package/types/apexara-ng-components-chip.d.ts +11 -0
- package/types/apexara-ng-components-datepicker.d.ts +172 -0
- package/types/apexara-ng-components-dialog.d.ts +24 -0
- package/types/apexara-ng-components-drawer.d.ts +22 -0
- package/types/apexara-ng-components-expander.d.ts +10 -0
- package/types/apexara-ng-components-image.d.ts +46 -0
- package/types/apexara-ng-components-input.d.ts +51 -0
- package/types/apexara-ng-components-listbox.d.ts +70 -0
- package/types/apexara-ng-components-radiobutton.d.ts +30 -0
- package/types/apexara-ng-components-select.d.ts +111 -0
- package/types/apexara-ng-components-services.d.ts +96 -0
- package/types/apexara-ng-components-snackbar.d.ts +73 -0
- package/types/apexara-ng-components-table.d.ts +157 -0
- package/types/apexara-ng-components-textarea.d.ts +34 -0
- package/types/apexara-ng-components-tooltip.d.ts +54 -0
- package/types/apexara-ng-components.d.ts +3 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, inject, PLATFORM_ID, HostListener, Output, Input, ViewChild, Component } from '@angular/core';
|
|
3
|
+
import { isPlatformServer, NgClass } from '@angular/common';
|
|
4
|
+
import * as i2 from '@angular/forms';
|
|
5
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
6
|
+
import { RouterLink } from '@angular/router';
|
|
7
|
+
import * as i3 from '@angular/cdk/scrolling';
|
|
8
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
9
|
+
import { fromEvent, tap, debounceTime } from 'rxjs';
|
|
10
|
+
import { IpiChipComponent } from '@apexara/ng-components/chip';
|
|
11
|
+
import { IpiImageComponent } from '@apexara/ng-components/image';
|
|
12
|
+
import { IpiCheckboxComponent } from '@apexara/ng-components/checkbox';
|
|
13
|
+
import * as i1 from '@apexara/ng-components/services';
|
|
14
|
+
import { MobileOS } from '@apexara/ng-components/services';
|
|
15
|
+
import { TooltipPosition, IpiTooltipDirective } from '@apexara/ng-components/tooltip';
|
|
16
|
+
|
|
17
|
+
class IpiSelectComponent {
|
|
18
|
+
constructor(osService, elementRef, iterableDiffers, changeDetectorRef) {
|
|
19
|
+
this.osService = osService;
|
|
20
|
+
this.elementRef = elementRef;
|
|
21
|
+
this.iterableDiffers = iterableDiffers;
|
|
22
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
23
|
+
this.input = null;
|
|
24
|
+
this.label = null;
|
|
25
|
+
this.dropdown = null;
|
|
26
|
+
this.inputWrapper = null;
|
|
27
|
+
this.selectChange = new EventEmitter();
|
|
28
|
+
this.helperTextChange = new EventEmitter();
|
|
29
|
+
this.firstDropdown = 0;
|
|
30
|
+
this.isDropdown = false;
|
|
31
|
+
this.tooltipPosition = TooltipPosition;
|
|
32
|
+
this.platformId = inject(PLATFORM_ID);
|
|
33
|
+
this.isDropdownReversed = false;
|
|
34
|
+
this.shouldPreventEvents = false;
|
|
35
|
+
this.documentKeyupValue = '';
|
|
36
|
+
this.documentKeyupValueResetTime = 1000;
|
|
37
|
+
this.documentKeyUpSubscription = null;
|
|
38
|
+
this.controlSubscription = null;
|
|
39
|
+
this.filteredData = [];
|
|
40
|
+
this.lastSearch = '';
|
|
41
|
+
this.keyListener = (event) => this.blockArrowScroll(event);
|
|
42
|
+
this.wheelListener = (event) => this.blockScroll(event);
|
|
43
|
+
this.scrollBlockersAttached = false;
|
|
44
|
+
// Virtual scroll config for options list
|
|
45
|
+
this.optionItemSizePx = 48; // must match .dropdown .option height in CSS
|
|
46
|
+
this.maxVisibleOptions = 8;
|
|
47
|
+
this.dropdownHeightPx = this.optionItemSizePx;
|
|
48
|
+
this.changeDetectorRef.detach();
|
|
49
|
+
this.dataDiffer = this.iterableDiffers.find([]).create();
|
|
50
|
+
this.handleEvents();
|
|
51
|
+
}
|
|
52
|
+
ngOnInit() {
|
|
53
|
+
this.control = this.getControl();
|
|
54
|
+
this.changeDetectorRef.detectChanges();
|
|
55
|
+
if (isPlatformServer(this.platformId)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.documentKeyUpSubscription = fromEvent(this.elementRef.nativeElement, 'keydown')
|
|
59
|
+
.pipe(tap(event => { this.keyup(event); }), debounceTime(this.documentKeyupValueResetTime))
|
|
60
|
+
.subscribe(() => { this.documentKeyupValue = ''; });
|
|
61
|
+
}
|
|
62
|
+
ngDoCheck() {
|
|
63
|
+
const data = this.options?.data || [];
|
|
64
|
+
const diff = this.dataDiffer.diff(data);
|
|
65
|
+
if (!diff) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.filteredData = [...data];
|
|
69
|
+
this.changeDetectorRef.detectChanges();
|
|
70
|
+
}
|
|
71
|
+
ngAfterViewInit() {
|
|
72
|
+
this.filteredData = [...this.options.data];
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
if (this.options.formGroup && this.options.formControlName) {
|
|
75
|
+
this.setVisibleValue(this.options.formGroup.controls[this.options.formControlName].value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (this.options.searchable) {
|
|
79
|
+
this.controlSubscription = this.control.valueChanges.subscribe((value) => {
|
|
80
|
+
this.setVisibleValue(value);
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
this.changeDetectorRef.detectChanges();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
this.changeDetectorRef.detectChanges();
|
|
87
|
+
}
|
|
88
|
+
ngOnChanges(changes) {
|
|
89
|
+
if (!changes['options'] || changes['options'].firstChange) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.updateDropdownHeight();
|
|
93
|
+
this.changeDetectorRef.detectChanges();
|
|
94
|
+
}
|
|
95
|
+
ngOnDestroy() {
|
|
96
|
+
if (isPlatformServer(this.platformId)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.detachGlobalScrollBlockers();
|
|
100
|
+
window.removeEventListener('keydown', this.keyListener);
|
|
101
|
+
if (this.documentKeyUpSubscription) {
|
|
102
|
+
this.documentKeyUpSubscription.unsubscribe();
|
|
103
|
+
}
|
|
104
|
+
if (this.controlSubscription) {
|
|
105
|
+
this.controlSubscription.unsubscribe();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
onHelperText() {
|
|
109
|
+
this.helperTextChange.emit();
|
|
110
|
+
}
|
|
111
|
+
setValue(value) {
|
|
112
|
+
this.changeDetectorRef.detectChanges();
|
|
113
|
+
if (!this.options.multiple) {
|
|
114
|
+
value = this.removeProperty(value, 'isHover');
|
|
115
|
+
}
|
|
116
|
+
this.control.setValue(value);
|
|
117
|
+
this.input.nativeElement.value = value.label ? value.label : '';
|
|
118
|
+
this.selectChange.emit(value);
|
|
119
|
+
if (value.value == null) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
this.removeDropdown();
|
|
124
|
+
if (!this.options.multiple) {
|
|
125
|
+
this.lastSearch = '';
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
setMultipleValue(data, event) {
|
|
130
|
+
if (event) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
}
|
|
133
|
+
const newValue = this.control.value;
|
|
134
|
+
let indexOfValue = -1;
|
|
135
|
+
for (let i = 0; i < newValue.length; i++) {
|
|
136
|
+
if (newValue[i].value === data.value) {
|
|
137
|
+
indexOfValue = i;
|
|
138
|
+
}
|
|
139
|
+
if (JSON.stringify(newValue[i].value) === JSON.stringify(data.value)) {
|
|
140
|
+
indexOfValue = i;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (indexOfValue === -1) {
|
|
144
|
+
newValue.push({ label: data.label, value: data.value });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
newValue.splice(indexOfValue, 1);
|
|
148
|
+
}
|
|
149
|
+
this.lastSearch = '';
|
|
150
|
+
this.input.nativeElement.value = '';
|
|
151
|
+
this.filteredData = this.options.data;
|
|
152
|
+
this.control.setValue(newValue);
|
|
153
|
+
this.selectChange.emit(newValue);
|
|
154
|
+
}
|
|
155
|
+
setVisibleValue(newValue) {
|
|
156
|
+
if (newValue === null) {
|
|
157
|
+
this.input.nativeElement.value = '';
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (this.options.counterAsValue) {
|
|
161
|
+
if (this.options.searchable) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (this.showMultipleCount() > 0) {
|
|
165
|
+
this.input.nativeElement.value = this.showMultipleCount() + ' selected';
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
let visibleValue = '';
|
|
170
|
+
for (let data of this.filteredData) {
|
|
171
|
+
// when newValue is object and not array
|
|
172
|
+
if (data.value === newValue.value) {
|
|
173
|
+
visibleValue = data.label;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
if (this.options.multiple && !this.options.searchable) {
|
|
177
|
+
// when newValue is array
|
|
178
|
+
for (let item of newValue) {
|
|
179
|
+
if (data.value === item.value) {
|
|
180
|
+
visibleValue += item.label + ', ';
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (newValue.value) {
|
|
186
|
+
// Edge case for when we use { label, value } pattern as value
|
|
187
|
+
if (newValue.value.value && this.getControl()?.value.value.value === newValue.value.value) {
|
|
188
|
+
visibleValue = data.label;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
this.input.nativeElement.value = visibleValue;
|
|
194
|
+
this.changeDetectorRef.detectChanges();
|
|
195
|
+
}
|
|
196
|
+
updateDropdownHeight() {
|
|
197
|
+
if (!this.isDropdown) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
const count = this.filteredData.length;
|
|
202
|
+
const maxRows = this.maxVisibleOptions;
|
|
203
|
+
let next = this.optionItemSizePx;
|
|
204
|
+
if (count > 0 && count <= maxRows && this.dropdown) {
|
|
205
|
+
const options = this.dropdown.elementRef.nativeElement.querySelectorAll('.option');
|
|
206
|
+
let total = 0;
|
|
207
|
+
options.forEach((option) => {
|
|
208
|
+
const height = option.getBoundingClientRect().height;
|
|
209
|
+
total += isFinite(height) ? height : 0;
|
|
210
|
+
});
|
|
211
|
+
next = total;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const rows = Math.min(count, maxRows);
|
|
215
|
+
next = Math.max(rows * this.optionItemSizePx, this.optionItemSizePx);
|
|
216
|
+
}
|
|
217
|
+
const maxHeight = this.options.maxDropdownHeightPx;
|
|
218
|
+
if (maxHeight) {
|
|
219
|
+
next = Math.min(next, Math.max(this.optionItemSizePx, maxHeight));
|
|
220
|
+
}
|
|
221
|
+
this.dropdownHeightPx = next;
|
|
222
|
+
this.changeDetectorRef.detectChanges();
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
this.dropdown?.checkViewportSize();
|
|
225
|
+
}, 100);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
showMultipleCount() {
|
|
229
|
+
if (!this.control.value.length) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
return this.control.value.length;
|
|
233
|
+
}
|
|
234
|
+
isValueSelected(value) {
|
|
235
|
+
if (value.value == null || this.control.value == null) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
return value.value === this.control.value.value;
|
|
239
|
+
}
|
|
240
|
+
isMultipleSelected(value) {
|
|
241
|
+
for (let i = 0; i < this.control.value.length; i++) {
|
|
242
|
+
if (value.value === this.control.value[i]) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
if (this.control.value[i].value === value.value) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if (JSON.stringify(this.control.value[i].value) === JSON.stringify(value.value)) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
activateDropdown() {
|
|
255
|
+
if (this.checkIfControlDisabled()) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.isDropdown = true;
|
|
259
|
+
this.input.nativeElement.focus();
|
|
260
|
+
if (this.firstDropdown === 0) {
|
|
261
|
+
this.firstDropdown += 1;
|
|
262
|
+
setTimeout(() => this.generateDropdownPosition(true));
|
|
263
|
+
// Reattaching is needed to properly update the hovered options by KeyboardEvents
|
|
264
|
+
this.changeDetectorRef.reattach();
|
|
265
|
+
}
|
|
266
|
+
this.attachGlobalScrollBlockers();
|
|
267
|
+
this.onSearch(this.lastSearch, false);
|
|
268
|
+
}
|
|
269
|
+
deactivateControl(event) {
|
|
270
|
+
if (event instanceof KeyboardEvent) {
|
|
271
|
+
this.removeDropdown();
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!this.dropdown || !this.inputWrapper) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const dropdownRect = this.dropdown.elementRef.nativeElement.getBoundingClientRect();
|
|
278
|
+
const inputWrapperRect = this.inputWrapper.nativeElement.getBoundingClientRect();
|
|
279
|
+
const isClickInsideDropdown = this.isWithinBounds(event, dropdownRect);
|
|
280
|
+
const isClickInsideInputWrapper = this.isWithinBounds(event, inputWrapperRect);
|
|
281
|
+
if (isClickInsideDropdown || isClickInsideInputWrapper) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
this.removeDropdown();
|
|
285
|
+
}
|
|
286
|
+
onFocusIn() {
|
|
287
|
+
this.shouldPreventEvents = true;
|
|
288
|
+
this.activateDropdown();
|
|
289
|
+
setTimeout(() => {
|
|
290
|
+
this.shouldPreventEvents = false;
|
|
291
|
+
}, 200);
|
|
292
|
+
}
|
|
293
|
+
onFocusOut() {
|
|
294
|
+
this.shouldPreventEvents = true;
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
this.shouldPreventEvents = false;
|
|
297
|
+
}, 200);
|
|
298
|
+
this.removeDropdown();
|
|
299
|
+
}
|
|
300
|
+
toggleDropdown() {
|
|
301
|
+
if (this.shouldPreventEvents) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (this.isDropdown) {
|
|
305
|
+
this.removeDropdown();
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this.activateDropdown();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
generateDropdownPosition(checkRevserse = false) {
|
|
312
|
+
if (!this.dropdown) {
|
|
313
|
+
// method will keep executing until dropdown is rendered
|
|
314
|
+
setTimeout(() => this.generateDropdownPosition(true));
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const dropdownEl = this.dropdown.elementRef.nativeElement;
|
|
318
|
+
const elementRefRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
319
|
+
if (this.osService.mobileOS === MobileOS.iOS) {
|
|
320
|
+
elementRefRect.y += window.visualViewport.offsetTop;
|
|
321
|
+
elementRefRect.x += window.visualViewport.offsetLeft;
|
|
322
|
+
}
|
|
323
|
+
dropdownEl.style.left = elementRefRect.x + 'px';
|
|
324
|
+
dropdownEl.style.width = elementRefRect.width + 'px';
|
|
325
|
+
dropdownEl.style.top = elementRefRect.y + elementRefRect.height + 'px';
|
|
326
|
+
if (checkRevserse) {
|
|
327
|
+
if (window.innerHeight < dropdownEl.getBoundingClientRect().bottom) {
|
|
328
|
+
dropdownEl.style.top = 'unset';
|
|
329
|
+
dropdownEl.style.bottom = window.innerHeight - elementRefRect.y + 10 + 'px';
|
|
330
|
+
this.isDropdownReversed = true;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (this.isDropdownReversed) {
|
|
334
|
+
dropdownEl.style.top = 'unset';
|
|
335
|
+
dropdownEl.style.bottom = window.innerHeight - elementRefRect.y + 10 + 'px';
|
|
336
|
+
}
|
|
337
|
+
setTimeout(() => {
|
|
338
|
+
this.updateDropdownHeight();
|
|
339
|
+
}, 100);
|
|
340
|
+
this.changeDetectorRef.detectChanges();
|
|
341
|
+
}
|
|
342
|
+
removeDropdown() {
|
|
343
|
+
this.isDropdown = false;
|
|
344
|
+
this.isDropdownReversed = false;
|
|
345
|
+
this.firstDropdown = 0;
|
|
346
|
+
this.changeDetectorRef.detectChanges();
|
|
347
|
+
this.input.nativeElement.blur();
|
|
348
|
+
this.detachGlobalScrollBlockers();
|
|
349
|
+
this.changeDetectorRef.detach();
|
|
350
|
+
}
|
|
351
|
+
handleKeydown(event) {
|
|
352
|
+
if (event.code === 'Backspace') {
|
|
353
|
+
this.onSearch('', true);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
preventFocusChange(event) {
|
|
357
|
+
if (this.input?.nativeElement === document.activeElement) {
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
onSearch(value, shouldResetHover) {
|
|
363
|
+
this.lastSearch = value;
|
|
364
|
+
if (!value) {
|
|
365
|
+
// Reset to original data if input is empty
|
|
366
|
+
this.filteredData = [...this.options.data];
|
|
367
|
+
this.updateDropdownHeight();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const searchTerm = value.toLowerCase();
|
|
371
|
+
this.filteredData = this.options.data.filter(item => item.label.toLowerCase().includes(searchTerm));
|
|
372
|
+
if (this.filteredData.length && shouldResetHover) {
|
|
373
|
+
for (let i = 0; i < this.filteredData.length; i++) {
|
|
374
|
+
this.filteredData[i].isHover = false;
|
|
375
|
+
}
|
|
376
|
+
this.filteredData[0].isHover = true;
|
|
377
|
+
}
|
|
378
|
+
this.updateDropdownHeight();
|
|
379
|
+
}
|
|
380
|
+
getPlaceholder() {
|
|
381
|
+
const options = this.options;
|
|
382
|
+
const formGroup = options.formGroup;
|
|
383
|
+
const formControlName = options.formControlName;
|
|
384
|
+
let placeholder = '';
|
|
385
|
+
if (options.placeholder) {
|
|
386
|
+
placeholder = options.placeholder;
|
|
387
|
+
}
|
|
388
|
+
if (formGroup && formControlName && options.errors && this.checkIfControlInvalid()) {
|
|
389
|
+
for (const error in options.errors) {
|
|
390
|
+
if (formGroup.controls[formControlName].hasError(error)) {
|
|
391
|
+
placeholder = options.errors[error];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if ((this.control.value instanceof Array && this.control.value.length) || (this.control.value && !(this.control.value instanceof Array))) {
|
|
396
|
+
return '';
|
|
397
|
+
}
|
|
398
|
+
return placeholder;
|
|
399
|
+
}
|
|
400
|
+
checkIfControlInvalid() {
|
|
401
|
+
return this.control.touched && this.control.invalid;
|
|
402
|
+
}
|
|
403
|
+
checkIfControlDisabled() {
|
|
404
|
+
return this.control.disabled;
|
|
405
|
+
}
|
|
406
|
+
getControl() {
|
|
407
|
+
if (this.options && this.options.formGroup && this.options.formControlName) {
|
|
408
|
+
return this.options.formGroup.controls[this.options.formControlName];
|
|
409
|
+
}
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
isWithinBounds(event, rect) {
|
|
413
|
+
return (event.clientX >= rect.left &&
|
|
414
|
+
event.clientX <= rect.right &&
|
|
415
|
+
event.clientY >= rect.top &&
|
|
416
|
+
event.clientY <= rect.bottom);
|
|
417
|
+
}
|
|
418
|
+
handleEvents() {
|
|
419
|
+
if (isPlatformServer(this.platformId)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
window.addEventListener('keydown', this.keyListener);
|
|
423
|
+
}
|
|
424
|
+
keyup(event) {
|
|
425
|
+
if (document.activeElement !== this.input?.nativeElement) {
|
|
426
|
+
this.deactivateControl(event);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (document.activeElement === this.input?.nativeElement) {
|
|
430
|
+
if (document.activeElement !== this.input?.nativeElement) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
switch (event.code) {
|
|
434
|
+
case 'Enter':
|
|
435
|
+
this.documentEnterKeyup(event);
|
|
436
|
+
return;
|
|
437
|
+
case 'Space':
|
|
438
|
+
if (!this.options.searchable) {
|
|
439
|
+
this.documentEnterKeyup(event);
|
|
440
|
+
}
|
|
441
|
+
return;
|
|
442
|
+
case 'Backspace':
|
|
443
|
+
if (!this.options.multiple && this.options.searchable && this.control.value.value != null) {
|
|
444
|
+
this.onSearch('', false);
|
|
445
|
+
this.setValue('');
|
|
446
|
+
}
|
|
447
|
+
return;
|
|
448
|
+
case 'Escape':
|
|
449
|
+
this.deactivateControl(event);
|
|
450
|
+
return;
|
|
451
|
+
case 'ArrowDown':
|
|
452
|
+
this.documentArrowsKeyup(true);
|
|
453
|
+
return;
|
|
454
|
+
case 'ArrowUp':
|
|
455
|
+
this.documentArrowsKeyup(false);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
this.documentKeyup(event);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
documentEnterKeyup(event) {
|
|
462
|
+
for (let i = 0; i < this.filteredData.length; i++) {
|
|
463
|
+
if (this.filteredData[i].isHover) {
|
|
464
|
+
switch (this.options.multiple) {
|
|
465
|
+
case true:
|
|
466
|
+
this.setMultipleValue(this.filteredData[i], event);
|
|
467
|
+
this.updateDropdownHeight();
|
|
468
|
+
this.changeDetectorRef.detectChanges();
|
|
469
|
+
return;
|
|
470
|
+
default:
|
|
471
|
+
this.setValue(this.filteredData[i]);
|
|
472
|
+
this.removeDropdown();
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
documentArrowsKeyup(isDownArrow) {
|
|
478
|
+
if (!this.dropdown || !this.filteredData.length) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const dataLength = this.filteredData.length;
|
|
482
|
+
const controlValue = this.control.getRawValue();
|
|
483
|
+
const isControlValue = controlValue && controlValue !== '';
|
|
484
|
+
let hoverIndex = null;
|
|
485
|
+
let valueIndex = null;
|
|
486
|
+
for (let i = 0; i < dataLength; i++) {
|
|
487
|
+
if (this.filteredData[i].isHover) {
|
|
488
|
+
hoverIndex = i;
|
|
489
|
+
}
|
|
490
|
+
if (isControlValue && this.filteredData[i].value === controlValue) {
|
|
491
|
+
valueIndex = i;
|
|
492
|
+
}
|
|
493
|
+
this.filteredData[i].isHover = false;
|
|
494
|
+
}
|
|
495
|
+
const currentIndex = hoverIndex ? hoverIndex : valueIndex ? valueIndex : 0;
|
|
496
|
+
let newIndex = isDownArrow ? currentIndex + 1 : currentIndex - 1;
|
|
497
|
+
newIndex = newIndex < 0 ? 0 : newIndex;
|
|
498
|
+
newIndex = newIndex >= dataLength ? dataLength - 1 : newIndex;
|
|
499
|
+
this.filteredData[newIndex].isHover = true;
|
|
500
|
+
this.dropdown?.scrollToIndex(newIndex, 'auto');
|
|
501
|
+
}
|
|
502
|
+
documentKeyup(event) {
|
|
503
|
+
if (!this.isDropdown || this.options.searchable) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
for (let i = 0; i < this.filteredData.length; i++) {
|
|
507
|
+
this.filteredData[i].isHover = false;
|
|
508
|
+
}
|
|
509
|
+
this.documentKeyupValue = this.documentKeyupValue + event.key.toLowerCase();
|
|
510
|
+
let newIndex = null;
|
|
511
|
+
for (let i = 0; i < this.filteredData.length; i++) {
|
|
512
|
+
const subLabel = this.filteredData[i].label.substring(0, this.documentKeyupValue.length).toLowerCase();
|
|
513
|
+
if (subLabel === this.documentKeyupValue) {
|
|
514
|
+
newIndex = i;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
this.filteredData[i].isHover = false;
|
|
518
|
+
}
|
|
519
|
+
if (newIndex !== null) {
|
|
520
|
+
this.filteredData[newIndex].isHover = true;
|
|
521
|
+
this.dropdown?.scrollToIndex(newIndex, 'auto');
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
removeProperty(obj, propertyName) {
|
|
525
|
+
let { [propertyName]: removedProperty, ...data } = obj;
|
|
526
|
+
return data;
|
|
527
|
+
}
|
|
528
|
+
blockArrowScroll(event) {
|
|
529
|
+
if (!this.dropdown) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
533
|
+
event.preventDefault();
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
blockScroll(event) {
|
|
537
|
+
if (!this.dropdown) {
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
const dropdownEl = this.dropdown.elementRef.nativeElement;
|
|
541
|
+
const isInsideDropdown = this.isDescendant(dropdownEl, event.target);
|
|
542
|
+
if (isInsideDropdown) {
|
|
543
|
+
const canScroll = dropdownEl.scrollHeight > dropdownEl.clientHeight;
|
|
544
|
+
if (!canScroll) {
|
|
545
|
+
event.preventDefault();
|
|
546
|
+
}
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
event.preventDefault();
|
|
550
|
+
}
|
|
551
|
+
isDescendant(parent, child) {
|
|
552
|
+
while (child !== null) {
|
|
553
|
+
if (child === parent) {
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
child = child.parentElement;
|
|
557
|
+
}
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
attachGlobalScrollBlockers() {
|
|
561
|
+
if (this.scrollBlockersAttached) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
window.addEventListener('wheel', this.wheelListener, { passive: false });
|
|
565
|
+
window.addEventListener('touchmove', this.wheelListener, { passive: false });
|
|
566
|
+
this.scrollBlockersAttached = true;
|
|
567
|
+
}
|
|
568
|
+
detachGlobalScrollBlockers() {
|
|
569
|
+
if (!this.scrollBlockersAttached) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
window.removeEventListener('wheel', this.wheelListener);
|
|
573
|
+
window.removeEventListener('touchmove', this.wheelListener);
|
|
574
|
+
this.scrollBlockersAttached = false;
|
|
575
|
+
}
|
|
576
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: IpiSelectComponent, deps: [{ token: i1.OSService }, { token: i0.ElementRef }, { token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
577
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.2", type: IpiSelectComponent, isStandalone: true, selector: "ipi-select", inputs: { options: "options" }, outputs: { selectChange: "selectChange", helperTextChange: "helperTextChange" }, host: { listeners: { "document:click": "deactivateControl($event)" } }, viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }, { propertyName: "label", first: true, predicate: ["label"], descendants: true }, { propertyName: "dropdown", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "inputWrapper", first: true, predicate: ["inputWrapper"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "@if (options) {\n @if (options.formGroup && options.formControlName) {\n <div class=\"container\" (mousedown)=\"preventFocusChange($event)\">\n @if (options.label !== '') {\n <div class=\"header\">\n <div class=\"label-wrapper\">\n <label>{{ options.label }}</label>\n \n @if (options.tooltip) {\n <svg class=\"tooltip-icon\" [ipiTooltip]=\"options.tooltip\" [tooltipPosition]=\"tooltipPosition.Above\" width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g>\n <path d=\"M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M7.5 7.5H8V11h.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M8.25 5.25a.25.25 0 1 1-.5 0 .25.25 0 0 1 .5 0z\" fill=\"#fff\"/>\n </g>\n </svg>\n }\n </div>\n \n @if (options.helperText) {\n <div class=\"header-helper\" (click)=\"onHelperText()\" [routerLink]=\"options.helperRoute\">{{ options.helperText }}</div>\n }\n </div>\n }\n\n <div #inputWrapper class=\"input-field-wrapper\" (click)=\"toggleDropdown()\" [formGroup]=\"options.formGroup\" [ngClass]=\"{ 'invalid': checkIfControlInvalid(), 'disabled': checkIfControlDisabled() }\">\n @if (options.prefixImg) {\n <ipi-img class=\"prefix\" [src]=\"'assets/img/' + this.options.prefixImg\" [ariaLabel]=\"'Select prefix icon'\"></ipi-img>\n }\n\n @if (options.searchable && options.multiple && this.showMultipleCount() > 0) {\n @if (options.counterAsValue) {\n <span class=\"multiple-count\">\n {{ this.showMultipleCount() }} selected\n </span>\n } @else {\n <div class=\"chips\">\n @for (data of options.data; track $index) {\n @if (isMultipleSelected(data)) {\n <ipi-chip [closeIcon]=\"true\" (closeChange)=\"setMultipleValue(data)\">{{ data.label }}</ipi-chip>\n }\n }\n </div>\n }\n }\n\n @if (options.searchable) {\n <!-- used for formControl data binding and reactivness -->\n <input #hiddenInput\n class=\"hidden\"\n [formControlName]=\"options.formControlName\">\n\n <!-- used for searching and data displaying -->\n <input #input\n [placeholder]=\"getPlaceholder()\"\n [readOnly]=\"!options.searchable\"\n [ngClass]=\"{ 'no-icon': !options.prefixImg }\"\n [disabled]=\"checkIfControlDisabled()\"\n (keydown)=\"handleKeydown($event)\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut()\"\n (input)=\"onSearch(input.value, true)\"\n autocorrect=\"off\"\n spellcheck=\"false\">\n } @else {\n <input #input\n readonly\n [disabled]=\"checkIfControlDisabled()\"\n [placeholder]=\"getPlaceholder()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut()\"\n [formControlName]=\"options.formControlName\"\n [ngClass]=\"{ 'no-icon': !options.prefixImg }\"\n (ngModelChange)=\"setVisibleValue($event)\"/>\n }\n \n <div class=\"arrow-wrapper\">\n <div class=\"arrow\" [class]=\"{ checked: this.isDropdown }\"></div>\n </div>\n </div>\n\n @if (isDropdown) {\n <cdk-virtual-scroll-viewport [itemSize]=\"optionItemSizePx\" [style.height.px]=\"dropdownHeightPx\" class=\"dropdown\" #dropdown>\n <div class=\"option\"\n *cdkVirtualFor=\"let data of filteredData;\"\n [ngClass]=\"{ selected: !options.multiple ? isValueSelected(data) : false, preselected: data.isHover, checkbox: options.multiple }\"\n (click)=\"options.multiple ? setMultipleValue(data, $event) : setValue(data)\">\n @if (options.multiple) {\n <ipi-checkbox [checked]=\"isMultipleSelected(data)\">\n <div class=\"multiple-checkbox-container\">\n <span>{{ data.label }}</span>\n @if (data.description) { <span>{{ data.description }}</span> }\n </div>\n </ipi-checkbox>\n } @else {\n {{ data.label }}\n }\n </div>\n @if (filteredData.length === 0) {\n <div class=\"option disabled\">No options to select from.</div>\n }\n </cdk-virtual-scroll-viewport>\n }\n </div>\n }\n}\n", styles: [":host{display:block;touch-action:manipulation}:host-context(.table) .input-field-wrapper{width:80px;justify-content:center}:host-context(.table) .input-field-wrapper input{width:40px;color:var(--ipi-select-input-table-color, #5D6068);font-weight:600;margin:0}.header{display:flex;align-items:center;justify-content:space-between;column-gap:4px;color:var(--ipi-select-header-color, #0B1222);text-wrap:nowrap;margin-bottom:2px}.header label{font-size:14px;font-weight:600}.header-helper{font-size:12px;text-align:right;color:var(--ipi-select-helper-text-color, #5D6068);cursor:pointer}.header-helper:after{width:0;height:1px;display:block;content:\"\";background:var(--ipi-select-helper-text-color, #5D6068);transition:width .3s}.header-helper:hover:after{width:100%}.header .label-wrapper{display:flex;justify-content:center;align-items:center;text-wrap:wrap}.tooltip-icon{overflow:visible}.tooltip-icon path{fill:var(--ipi-select-tooltip-icon-fill, transparent);stroke:var(--ipi-input-tooltip-icon-stroke, #C6C6C6)}.input-field-wrapper{width:100%;height:44px;display:flex;justify-content:space-around;align-items:center;cursor:pointer;box-sizing:border-box;overflow:scroll;background-color:var(--ipi-select-input-background-color, #ffffff00);border:solid var(--ipi-select-input-border-color, #E9E9E9);border-width:var(--ipi-select-input-border-width, 1px);transition:border 1s;border-radius:4px;padding:0 16px}.input-field-wrapper .multiple-count{font-size:14px;padding:0 8px;font-weight:600}.input-field-wrapper::-webkit-scrollbar{display:none}.input-field-wrapper:not(.input-field-wrapper.disabled):hover{border-color:var(--ipi-select-input-border-hover-color, #4B5368)}.input-field-wrapper.disabled{opacity:.8;cursor:not-allowed;border:1px dashed var(--ipi-select-input-border-disabled-color, #F2F2F2)}.input-field-wrapper .input-field{height:100%;display:flex;justify-content:space-between;align-items:center;padding:0 16px}ipi-img{width:16px;height:16px}ipi-img.prefix path{fill:var(--ipi-select-icon-prefix-fill, #C6C6C6);stroke:var(--ipi-select-icon-prefix-stroke, transparent)}.input-field-wrapper.disabled label{cursor:not-allowed}.chips{--ipi-chip-font-size: var(--ipi-select-chip-font-size, 10px);--ipi-chip-color: var(--ipi-select-chip-color, #FFFFFF);--ipi-chip-background-color: var(--ipi-select-chip-background-color, #0B1222);--ipi-chip-icon-color: var(--ipi-select-chip-icon-color, #FFFFFF);display:flex;padding-left:8px}.input-field-wrapper input{width:inherit;flex:1;text-overflow:ellipsis;border:none;outline:none;cursor:pointer;background:transparent;color:var(--ipi-select-input-text-color, #0B1222);font-size:16px;transform:scale(.875);transform-origin:left center;padding:0;margin:0 12px}.input-field-wrapper input.hidden{display:none}input::placeholder{color:var(--ipi-select-input-placeholder-color, #0B1222)}.input-field-wrapper input.no-icon{left:0}.input-field-wrapper.disabled input{cursor:not-allowed}.arrow-wrapper{width:8px;height:8px}.arrow{width:8px;height:8px;position:relative;bottom:3px;border-top:2px solid var(--ipi-select-arrow-color, #5D6068);border-left:2px solid var(--ipi-select-arrow-color, #5D6068);border-top-left-radius:3px;border-top-right-radius:1px;border-bottom-left-radius:1px;transition:all .25s ease-in-out;transform-origin:center;transform:rotate(-135deg)}.arrow.checked{bottom:-2px;transform:rotate(45deg);border-top:2px solid var(--ipi-select-arrow-checked-color, #F96138);border-left:2px solid var(--ipi-select-arrow-checked-color, #F96138)}.arrow svg{width:16px;height:16px;transform:rotate(0);transition:transform .25s ease-in-out}.arrow.checked svg{transform:rotate(180deg)}.input-field-wrapper.invalid{border:solid var(--ipi-select-invalid-color, #F96138);border-width:var(--ipi-select-invalid-border-width, 1px)}.input-field-wrapper.invalid label{color:var(--ipi-select-invalid-color, #F96138)}.input-field-wrapper ipi-chip{margin-right:4px}.dropdown{width:264px;position:fixed;overscroll-behavior:contain;border-radius:8px;border:1px solid var(--ipi-select-dropdown-border-color, #E9E9E9);background-color:var(--ipi-select-dropdown-background-color, #FFFFFF);box-shadow:var(--ipi-select-dropdown-box-shadow);z-index:900;margin-top:15px;opacity:0;animation:fadeIn .3s forwards}.dropdown:focus{outline:none}.dropdown::-webkit-scrollbar{width:16px;padding:8px}.dropdown::-webkit-scrollbar-thumb{background-color:#e0dfde;border-radius:25px}.dropdown::-webkit-scrollbar-track{background-color:#f8f8f8;border-top-right-radius:8px;border-bottom-right-radius:8px}.dropdown::-webkit-scrollbar-button{display:none}.dropdown.no-scroll{overflow:hidden}.values::-webkit-scrollbar{width:8px;padding:4px}.values::-webkit-scrollbar-thumb{background-color:#e0dfde;border-radius:25px}.values::-webkit-scrollbar-track{background-color:#f8f8f8;border-top-right-radius:8px;border-bottom-right-radius:8px}.values::-webkit-scrollbar-button{display:none}.dropdown .option{min-height:48px;display:flex;align-items:center;cursor:pointer;font-weight:600;color:#0009;padding:0 16px}.dropdown .option.disabled{pointer-events:none}.dropdown .option:hover,.dropdown .option.preselected{background:#00000005}.dropdown .option.checkbox.selected{--ipi-checkbox-text-color: var(--ipi-select-input-text-selected-color, #F96138);background:#0000000a}.dropdown .option.selected{color:var(--ipi-select-input-text-selected-color, #F96138);background:#0000000a}.values{width:fit-content;display:flex;flex-wrap:wrap;align-items:center;padding:6px;overflow-x:auto}.values ipi-chip{margin:6px 0 0}.single-value{padding:6px}.options-divider{width:calc(100% - 36px);height:var(--ipi-select-options-divider-height, 1px);background-color:var(--ipi-select-options-divider-color, #E9E9E9);margin:0 auto}.multiple-checkbox-container{display:flex;flex-direction:column;row-gap:3px;padding:12px 0 12px 6px}.multiple-checkbox-container span{word-break:normal;overflow-wrap:break-word;white-space:normal}.multiple-checkbox-container span:nth-of-type(2){font-size:13px;font-weight:500;line-height:1.3;color:#5d6068}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ScrollingModule }, { kind: "directive", type: i3.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i3.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i3.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: IpiChipComponent, selector: "ipi-chip", inputs: ["closeIcon"], outputs: ["closeChange"] }, { kind: "component", type: IpiImageComponent, selector: "ipi-img", inputs: ["src", "ariaLabel"] }, { kind: "directive", type: IpiTooltipDirective, selector: "[ipiTooltip]", inputs: ["ipiTooltip", "tooltipPosition"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: IpiCheckboxComponent, selector: "ipi-checkbox", inputs: ["checked", "disabled", "tooltip", "options"], outputs: ["clickChange"] }] }); }
|
|
578
|
+
}
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: IpiSelectComponent, decorators: [{
|
|
580
|
+
type: Component,
|
|
581
|
+
args: [{ selector: 'ipi-select', imports: [
|
|
582
|
+
NgClass,
|
|
583
|
+
RouterLink,
|
|
584
|
+
FormsModule,
|
|
585
|
+
ScrollingModule,
|
|
586
|
+
IpiChipComponent,
|
|
587
|
+
IpiImageComponent,
|
|
588
|
+
IpiTooltipDirective,
|
|
589
|
+
ReactiveFormsModule,
|
|
590
|
+
IpiCheckboxComponent,
|
|
591
|
+
], template: "@if (options) {\n @if (options.formGroup && options.formControlName) {\n <div class=\"container\" (mousedown)=\"preventFocusChange($event)\">\n @if (options.label !== '') {\n <div class=\"header\">\n <div class=\"label-wrapper\">\n <label>{{ options.label }}</label>\n \n @if (options.tooltip) {\n <svg class=\"tooltip-icon\" [ipiTooltip]=\"options.tooltip\" [tooltipPosition]=\"tooltipPosition.Above\" width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g>\n <path d=\"M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M7.5 7.5H8V11h.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M8.25 5.25a.25.25 0 1 1-.5 0 .25.25 0 0 1 .5 0z\" fill=\"#fff\"/>\n </g>\n </svg>\n }\n </div>\n \n @if (options.helperText) {\n <div class=\"header-helper\" (click)=\"onHelperText()\" [routerLink]=\"options.helperRoute\">{{ options.helperText }}</div>\n }\n </div>\n }\n\n <div #inputWrapper class=\"input-field-wrapper\" (click)=\"toggleDropdown()\" [formGroup]=\"options.formGroup\" [ngClass]=\"{ 'invalid': checkIfControlInvalid(), 'disabled': checkIfControlDisabled() }\">\n @if (options.prefixImg) {\n <ipi-img class=\"prefix\" [src]=\"'assets/img/' + this.options.prefixImg\" [ariaLabel]=\"'Select prefix icon'\"></ipi-img>\n }\n\n @if (options.searchable && options.multiple && this.showMultipleCount() > 0) {\n @if (options.counterAsValue) {\n <span class=\"multiple-count\">\n {{ this.showMultipleCount() }} selected\n </span>\n } @else {\n <div class=\"chips\">\n @for (data of options.data; track $index) {\n @if (isMultipleSelected(data)) {\n <ipi-chip [closeIcon]=\"true\" (closeChange)=\"setMultipleValue(data)\">{{ data.label }}</ipi-chip>\n }\n }\n </div>\n }\n }\n\n @if (options.searchable) {\n <!-- used for formControl data binding and reactivness -->\n <input #hiddenInput\n class=\"hidden\"\n [formControlName]=\"options.formControlName\">\n\n <!-- used for searching and data displaying -->\n <input #input\n [placeholder]=\"getPlaceholder()\"\n [readOnly]=\"!options.searchable\"\n [ngClass]=\"{ 'no-icon': !options.prefixImg }\"\n [disabled]=\"checkIfControlDisabled()\"\n (keydown)=\"handleKeydown($event)\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut()\"\n (input)=\"onSearch(input.value, true)\"\n autocorrect=\"off\"\n spellcheck=\"false\">\n } @else {\n <input #input\n readonly\n [disabled]=\"checkIfControlDisabled()\"\n [placeholder]=\"getPlaceholder()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut()\"\n [formControlName]=\"options.formControlName\"\n [ngClass]=\"{ 'no-icon': !options.prefixImg }\"\n (ngModelChange)=\"setVisibleValue($event)\"/>\n }\n \n <div class=\"arrow-wrapper\">\n <div class=\"arrow\" [class]=\"{ checked: this.isDropdown }\"></div>\n </div>\n </div>\n\n @if (isDropdown) {\n <cdk-virtual-scroll-viewport [itemSize]=\"optionItemSizePx\" [style.height.px]=\"dropdownHeightPx\" class=\"dropdown\" #dropdown>\n <div class=\"option\"\n *cdkVirtualFor=\"let data of filteredData;\"\n [ngClass]=\"{ selected: !options.multiple ? isValueSelected(data) : false, preselected: data.isHover, checkbox: options.multiple }\"\n (click)=\"options.multiple ? setMultipleValue(data, $event) : setValue(data)\">\n @if (options.multiple) {\n <ipi-checkbox [checked]=\"isMultipleSelected(data)\">\n <div class=\"multiple-checkbox-container\">\n <span>{{ data.label }}</span>\n @if (data.description) { <span>{{ data.description }}</span> }\n </div>\n </ipi-checkbox>\n } @else {\n {{ data.label }}\n }\n </div>\n @if (filteredData.length === 0) {\n <div class=\"option disabled\">No options to select from.</div>\n }\n </cdk-virtual-scroll-viewport>\n }\n </div>\n }\n}\n", styles: [":host{display:block;touch-action:manipulation}:host-context(.table) .input-field-wrapper{width:80px;justify-content:center}:host-context(.table) .input-field-wrapper input{width:40px;color:var(--ipi-select-input-table-color, #5D6068);font-weight:600;margin:0}.header{display:flex;align-items:center;justify-content:space-between;column-gap:4px;color:var(--ipi-select-header-color, #0B1222);text-wrap:nowrap;margin-bottom:2px}.header label{font-size:14px;font-weight:600}.header-helper{font-size:12px;text-align:right;color:var(--ipi-select-helper-text-color, #5D6068);cursor:pointer}.header-helper:after{width:0;height:1px;display:block;content:\"\";background:var(--ipi-select-helper-text-color, #5D6068);transition:width .3s}.header-helper:hover:after{width:100%}.header .label-wrapper{display:flex;justify-content:center;align-items:center;text-wrap:wrap}.tooltip-icon{overflow:visible}.tooltip-icon path{fill:var(--ipi-select-tooltip-icon-fill, transparent);stroke:var(--ipi-input-tooltip-icon-stroke, #C6C6C6)}.input-field-wrapper{width:100%;height:44px;display:flex;justify-content:space-around;align-items:center;cursor:pointer;box-sizing:border-box;overflow:scroll;background-color:var(--ipi-select-input-background-color, #ffffff00);border:solid var(--ipi-select-input-border-color, #E9E9E9);border-width:var(--ipi-select-input-border-width, 1px);transition:border 1s;border-radius:4px;padding:0 16px}.input-field-wrapper .multiple-count{font-size:14px;padding:0 8px;font-weight:600}.input-field-wrapper::-webkit-scrollbar{display:none}.input-field-wrapper:not(.input-field-wrapper.disabled):hover{border-color:var(--ipi-select-input-border-hover-color, #4B5368)}.input-field-wrapper.disabled{opacity:.8;cursor:not-allowed;border:1px dashed var(--ipi-select-input-border-disabled-color, #F2F2F2)}.input-field-wrapper .input-field{height:100%;display:flex;justify-content:space-between;align-items:center;padding:0 16px}ipi-img{width:16px;height:16px}ipi-img.prefix path{fill:var(--ipi-select-icon-prefix-fill, #C6C6C6);stroke:var(--ipi-select-icon-prefix-stroke, transparent)}.input-field-wrapper.disabled label{cursor:not-allowed}.chips{--ipi-chip-font-size: var(--ipi-select-chip-font-size, 10px);--ipi-chip-color: var(--ipi-select-chip-color, #FFFFFF);--ipi-chip-background-color: var(--ipi-select-chip-background-color, #0B1222);--ipi-chip-icon-color: var(--ipi-select-chip-icon-color, #FFFFFF);display:flex;padding-left:8px}.input-field-wrapper input{width:inherit;flex:1;text-overflow:ellipsis;border:none;outline:none;cursor:pointer;background:transparent;color:var(--ipi-select-input-text-color, #0B1222);font-size:16px;transform:scale(.875);transform-origin:left center;padding:0;margin:0 12px}.input-field-wrapper input.hidden{display:none}input::placeholder{color:var(--ipi-select-input-placeholder-color, #0B1222)}.input-field-wrapper input.no-icon{left:0}.input-field-wrapper.disabled input{cursor:not-allowed}.arrow-wrapper{width:8px;height:8px}.arrow{width:8px;height:8px;position:relative;bottom:3px;border-top:2px solid var(--ipi-select-arrow-color, #5D6068);border-left:2px solid var(--ipi-select-arrow-color, #5D6068);border-top-left-radius:3px;border-top-right-radius:1px;border-bottom-left-radius:1px;transition:all .25s ease-in-out;transform-origin:center;transform:rotate(-135deg)}.arrow.checked{bottom:-2px;transform:rotate(45deg);border-top:2px solid var(--ipi-select-arrow-checked-color, #F96138);border-left:2px solid var(--ipi-select-arrow-checked-color, #F96138)}.arrow svg{width:16px;height:16px;transform:rotate(0);transition:transform .25s ease-in-out}.arrow.checked svg{transform:rotate(180deg)}.input-field-wrapper.invalid{border:solid var(--ipi-select-invalid-color, #F96138);border-width:var(--ipi-select-invalid-border-width, 1px)}.input-field-wrapper.invalid label{color:var(--ipi-select-invalid-color, #F96138)}.input-field-wrapper ipi-chip{margin-right:4px}.dropdown{width:264px;position:fixed;overscroll-behavior:contain;border-radius:8px;border:1px solid var(--ipi-select-dropdown-border-color, #E9E9E9);background-color:var(--ipi-select-dropdown-background-color, #FFFFFF);box-shadow:var(--ipi-select-dropdown-box-shadow);z-index:900;margin-top:15px;opacity:0;animation:fadeIn .3s forwards}.dropdown:focus{outline:none}.dropdown::-webkit-scrollbar{width:16px;padding:8px}.dropdown::-webkit-scrollbar-thumb{background-color:#e0dfde;border-radius:25px}.dropdown::-webkit-scrollbar-track{background-color:#f8f8f8;border-top-right-radius:8px;border-bottom-right-radius:8px}.dropdown::-webkit-scrollbar-button{display:none}.dropdown.no-scroll{overflow:hidden}.values::-webkit-scrollbar{width:8px;padding:4px}.values::-webkit-scrollbar-thumb{background-color:#e0dfde;border-radius:25px}.values::-webkit-scrollbar-track{background-color:#f8f8f8;border-top-right-radius:8px;border-bottom-right-radius:8px}.values::-webkit-scrollbar-button{display:none}.dropdown .option{min-height:48px;display:flex;align-items:center;cursor:pointer;font-weight:600;color:#0009;padding:0 16px}.dropdown .option.disabled{pointer-events:none}.dropdown .option:hover,.dropdown .option.preselected{background:#00000005}.dropdown .option.checkbox.selected{--ipi-checkbox-text-color: var(--ipi-select-input-text-selected-color, #F96138);background:#0000000a}.dropdown .option.selected{color:var(--ipi-select-input-text-selected-color, #F96138);background:#0000000a}.values{width:fit-content;display:flex;flex-wrap:wrap;align-items:center;padding:6px;overflow-x:auto}.values ipi-chip{margin:6px 0 0}.single-value{padding:6px}.options-divider{width:calc(100% - 36px);height:var(--ipi-select-options-divider-height, 1px);background-color:var(--ipi-select-options-divider-color, #E9E9E9);margin:0 auto}.multiple-checkbox-container{display:flex;flex-direction:column;row-gap:3px;padding:12px 0 12px 6px}.multiple-checkbox-container span{word-break:normal;overflow-wrap:break-word;white-space:normal}.multiple-checkbox-container span:nth-of-type(2){font-size:13px;font-weight:500;line-height:1.3;color:#5d6068}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}\n"] }]
|
|
592
|
+
}], ctorParameters: () => [{ type: i1.OSService }, { type: i0.ElementRef }, { type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }], propDecorators: { input: [{
|
|
593
|
+
type: ViewChild,
|
|
594
|
+
args: ['input']
|
|
595
|
+
}], label: [{
|
|
596
|
+
type: ViewChild,
|
|
597
|
+
args: ['label']
|
|
598
|
+
}], dropdown: [{
|
|
599
|
+
type: ViewChild,
|
|
600
|
+
args: ['dropdown']
|
|
601
|
+
}], inputWrapper: [{
|
|
602
|
+
type: ViewChild,
|
|
603
|
+
args: ['inputWrapper']
|
|
604
|
+
}], options: [{
|
|
605
|
+
type: Input
|
|
606
|
+
}], selectChange: [{
|
|
607
|
+
type: Output
|
|
608
|
+
}], helperTextChange: [{
|
|
609
|
+
type: Output
|
|
610
|
+
}], deactivateControl: [{
|
|
611
|
+
type: HostListener,
|
|
612
|
+
args: ['document:click', ['$event']]
|
|
613
|
+
}] } });
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Generated bundle index. Do not edit.
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
export { IpiSelectComponent };
|
|
620
|
+
//# sourceMappingURL=apexara-ng-components-select.mjs.map
|