1 | import * as i0 from '@angular/core';
|
---|
2 | import { forwardRef, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, NgModule } from '@angular/core';
|
---|
3 | import * as i3 from '@angular/common';
|
---|
4 | import { CommonModule } from '@angular/common';
|
---|
5 | import { trigger, transition, style, animate } from '@angular/animations';
|
---|
6 | import { InputTextModule } from 'primeng/inputtext';
|
---|
7 | import * as i4 from 'primeng/button';
|
---|
8 | import { ButtonModule } from 'primeng/button';
|
---|
9 | import * as i5 from 'primeng/ripple';
|
---|
10 | import { RippleModule } from 'primeng/ripple';
|
---|
11 | import * as i1 from 'primeng/api';
|
---|
12 | import { TranslationKeys, PrimeTemplate, SharedModule } from 'primeng/api';
|
---|
13 | import { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom';
|
---|
14 | import { UniqueComponentId, ObjectUtils, ZIndexUtils } from 'primeng/utils';
|
---|
15 | import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
---|
16 | import * as i2 from '@angular/cdk/scrolling';
|
---|
17 | import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
---|
18 |
|
---|
19 | const AUTOCOMPLETE_VALUE_ACCESSOR = {
|
---|
20 | provide: NG_VALUE_ACCESSOR,
|
---|
21 | useExisting: forwardRef(() => AutoComplete),
|
---|
22 | multi: true
|
---|
23 | };
|
---|
24 | class AutoComplete {
|
---|
25 | constructor(el, renderer, cd, differs, config, overlayService) {
|
---|
26 | this.el = el;
|
---|
27 | this.renderer = renderer;
|
---|
28 | this.cd = cd;
|
---|
29 | this.differs = differs;
|
---|
30 | this.config = config;
|
---|
31 | this.overlayService = overlayService;
|
---|
32 | this.minLength = 1;
|
---|
33 | this.delay = 300;
|
---|
34 | this.type = 'text';
|
---|
35 | this.autoZIndex = true;
|
---|
36 | this.baseZIndex = 0;
|
---|
37 | this.dropdownIcon = "pi pi-chevron-down";
|
---|
38 | this.unique = true;
|
---|
39 | this.completeOnFocus = false;
|
---|
40 | this.completeMethod = new EventEmitter();
|
---|
41 | this.onSelect = new EventEmitter();
|
---|
42 | this.onUnselect = new EventEmitter();
|
---|
43 | this.onFocus = new EventEmitter();
|
---|
44 | this.onBlur = new EventEmitter();
|
---|
45 | this.onDropdownClick = new EventEmitter();
|
---|
46 | this.onClear = new EventEmitter();
|
---|
47 | this.onKeyUp = new EventEmitter();
|
---|
48 | this.onShow = new EventEmitter();
|
---|
49 | this.onHide = new EventEmitter();
|
---|
50 | this.scrollHeight = '200px';
|
---|
51 | this.dropdownMode = 'blank';
|
---|
52 | this.showTransitionOptions = '.12s cubic-bezier(0, 0, 0.2, 1)';
|
---|
53 | this.hideTransitionOptions = '.1s linear';
|
---|
54 | this.autocomplete = 'off';
|
---|
55 | this.onModelChange = () => { };
|
---|
56 | this.onModelTouched = () => { };
|
---|
57 | this.overlayVisible = false;
|
---|
58 | this.focus = false;
|
---|
59 | this.inputFieldValue = null;
|
---|
60 | this.differ = differs.find([]).create(null);
|
---|
61 | this.listId = UniqueComponentId() + '_list';
|
---|
62 | }
|
---|
63 | get suggestions() {
|
---|
64 | return this._suggestions;
|
---|
65 | }
|
---|
66 | set suggestions(val) {
|
---|
67 | this._suggestions = val;
|
---|
68 | this.handleSuggestionsChange();
|
---|
69 | }
|
---|
70 | ngAfterViewChecked() {
|
---|
71 | //Use timeouts as since Angular 4.2, AfterViewChecked is broken and not called after panel is updated
|
---|
72 | if (this.suggestionsUpdated && this.overlay && this.overlay.offsetParent) {
|
---|
73 | setTimeout(() => {
|
---|
74 | if (this.overlay) {
|
---|
75 | this.alignOverlay();
|
---|
76 | }
|
---|
77 | }, 1);
|
---|
78 | this.suggestionsUpdated = false;
|
---|
79 | }
|
---|
80 | if (this.highlightOptionChanged) {
|
---|
81 | setTimeout(() => {
|
---|
82 | if (this.overlay && this.itemsWrapper) {
|
---|
83 | let listItem = DomHandler.findSingle(this.overlay, 'li.p-highlight');
|
---|
84 | if (listItem) {
|
---|
85 | DomHandler.scrollInView(this.itemsWrapper, listItem);
|
---|
86 | }
|
---|
87 | if (this.virtualScroll && this.viewPort) {
|
---|
88 | let range = this.viewPort.getRenderedRange();
|
---|
89 | this.updateVirtualScrollSelectedIndex();
|
---|
90 | if (range.start > this.virtualScrollSelectedIndex || range.end < this.virtualScrollSelectedIndex) {
|
---|
91 | this.viewPort.scrollToIndex(this.virtualScrollSelectedIndex);
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }, 1);
|
---|
96 | this.highlightOptionChanged = false;
|
---|
97 | }
|
---|
98 | }
|
---|
99 | handleSuggestionsChange() {
|
---|
100 | if (this._suggestions != null && this.loading) {
|
---|
101 | this.highlightOption = null;
|
---|
102 | if (this._suggestions.length) {
|
---|
103 | this.noResults = false;
|
---|
104 | this.show();
|
---|
105 | this.suggestionsUpdated = true;
|
---|
106 | if (this.autoHighlight) {
|
---|
107 | this.highlightOption = this._suggestions[0];
|
---|
108 | }
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | this.noResults = true;
|
---|
112 | if (this.showEmptyMessage) {
|
---|
113 | this.show();
|
---|
114 | this.suggestionsUpdated = true;
|
---|
115 | }
|
---|
116 | else {
|
---|
117 | this.hide();
|
---|
118 | }
|
---|
119 | }
|
---|
120 | this.loading = false;
|
---|
121 | }
|
---|
122 | }
|
---|
123 | ngAfterContentInit() {
|
---|
124 | this.templates.forEach((item) => {
|
---|
125 | switch (item.getType()) {
|
---|
126 | case 'item':
|
---|
127 | this.itemTemplate = item.template;
|
---|
128 | break;
|
---|
129 | case 'group':
|
---|
130 | this.groupTemplate = item.template;
|
---|
131 | break;
|
---|
132 | case 'selectedItem':
|
---|
133 | this.selectedItemTemplate = item.template;
|
---|
134 | break;
|
---|
135 | case 'header':
|
---|
136 | this.headerTemplate = item.template;
|
---|
137 | break;
|
---|
138 | case 'empty':
|
---|
139 | this.emptyTemplate = item.template;
|
---|
140 | break;
|
---|
141 | case 'footer':
|
---|
142 | this.footerTemplate = item.template;
|
---|
143 | break;
|
---|
144 | default:
|
---|
145 | this.itemTemplate = item.template;
|
---|
146 | break;
|
---|
147 | }
|
---|
148 | });
|
---|
149 | }
|
---|
150 | updateVirtualScrollSelectedIndex() {
|
---|
151 | if (this.highlightOption && this.suggestions && this.suggestions.length) {
|
---|
152 | this.virtualScrollSelectedIndex = this.findOptionIndex(this.highlightOption, this.suggestions);
|
---|
153 | }
|
---|
154 | }
|
---|
155 | writeValue(value) {
|
---|
156 | this.value = value;
|
---|
157 | this.filled = this.value && this.value != '';
|
---|
158 | this.updateInputField();
|
---|
159 | this.cd.markForCheck();
|
---|
160 | }
|
---|
161 | getOptionGroupChildren(optionGroup) {
|
---|
162 | return this.optionGroupChildren ? ObjectUtils.resolveFieldData(optionGroup, this.optionGroupChildren) : optionGroup.items;
|
---|
163 | }
|
---|
164 | getOptionGroupLabel(optionGroup) {
|
---|
165 | return this.optionGroupLabel ? ObjectUtils.resolveFieldData(optionGroup, this.optionGroupLabel) : (optionGroup.label != undefined ? optionGroup.label : optionGroup);
|
---|
166 | }
|
---|
167 | registerOnChange(fn) {
|
---|
168 | this.onModelChange = fn;
|
---|
169 | }
|
---|
170 | registerOnTouched(fn) {
|
---|
171 | this.onModelTouched = fn;
|
---|
172 | }
|
---|
173 | setDisabledState(val) {
|
---|
174 | this.disabled = val;
|
---|
175 | this.cd.markForCheck();
|
---|
176 | }
|
---|
177 | onInput(event) {
|
---|
178 | // When an input element with a placeholder is clicked, the onInput event is invoked in IE.
|
---|
179 | if (!this.inputKeyDown && DomHandler.isIE()) {
|
---|
180 | return;
|
---|
181 | }
|
---|
182 | if (this.timeout) {
|
---|
183 | clearTimeout(this.timeout);
|
---|
184 | }
|
---|
185 | let value = event.target.value;
|
---|
186 | if (!this.multiple && !this.forceSelection) {
|
---|
187 | this.onModelChange(value);
|
---|
188 | }
|
---|
189 | if (value.length === 0 && !this.multiple) {
|
---|
190 | this.hide();
|
---|
191 | this.onClear.emit(event);
|
---|
192 | this.onModelChange(value);
|
---|
193 | }
|
---|
194 | if (value.length >= this.minLength) {
|
---|
195 | this.timeout = setTimeout(() => {
|
---|
196 | this.search(event, value);
|
---|
197 | }, this.delay);
|
---|
198 | }
|
---|
199 | else {
|
---|
200 | this.hide();
|
---|
201 | }
|
---|
202 | this.updateFilledState();
|
---|
203 | this.inputKeyDown = false;
|
---|
204 | }
|
---|
205 | onInputClick(event) {
|
---|
206 | if (this.documentClickListener) {
|
---|
207 | this.inputClick = true;
|
---|
208 | }
|
---|
209 | }
|
---|
210 | search(event, query) {
|
---|
211 | //allow empty string but not undefined or null
|
---|
212 | if (query === undefined || query === null) {
|
---|
213 | return;
|
---|
214 | }
|
---|
215 | this.loading = true;
|
---|
216 | this.completeMethod.emit({
|
---|
217 | originalEvent: event,
|
---|
218 | query: query
|
---|
219 | });
|
---|
220 | }
|
---|
221 | selectItem(option, focus = true) {
|
---|
222 | if (this.forceSelectionUpdateModelTimeout) {
|
---|
223 | clearTimeout(this.forceSelectionUpdateModelTimeout);
|
---|
224 | this.forceSelectionUpdateModelTimeout = null;
|
---|
225 | }
|
---|
226 | if (this.multiple) {
|
---|
227 | this.multiInputEL.nativeElement.value = '';
|
---|
228 | this.value = this.value || [];
|
---|
229 | if (!this.isSelected(option) || !this.unique) {
|
---|
230 | this.value = [...this.value, option];
|
---|
231 | this.onModelChange(this.value);
|
---|
232 | }
|
---|
233 | }
|
---|
234 | else {
|
---|
235 | this.inputEL.nativeElement.value = this.resolveFieldData(option);
|
---|
236 | this.value = option;
|
---|
237 | this.onModelChange(this.value);
|
---|
238 | }
|
---|
239 | this.onSelect.emit(option);
|
---|
240 | this.updateFilledState();
|
---|
241 | if (focus) {
|
---|
242 | this.itemClicked = true;
|
---|
243 | this.focusInput();
|
---|
244 | }
|
---|
245 | }
|
---|
246 | show() {
|
---|
247 | if (this.multiInputEL || this.inputEL) {
|
---|
248 | let hasFocus = this.multiple ?
|
---|
249 | this.multiInputEL.nativeElement.ownerDocument.activeElement == this.multiInputEL.nativeElement :
|
---|
250 | this.inputEL.nativeElement.ownerDocument.activeElement == this.inputEL.nativeElement;
|
---|
251 | if (!this.overlayVisible && hasFocus) {
|
---|
252 | this.overlayVisible = true;
|
---|
253 | }
|
---|
254 | }
|
---|
255 | }
|
---|
256 | onOverlayAnimationStart(event) {
|
---|
257 | switch (event.toState) {
|
---|
258 | case 'visible':
|
---|
259 | this.overlay = event.element;
|
---|
260 | this.itemsWrapper = this.virtualScroll ? DomHandler.findSingle(this.overlay, '.cdk-virtual-scroll-viewport') : this.overlay;
|
---|
261 | this.appendOverlay();
|
---|
262 | if (this.autoZIndex) {
|
---|
263 | ZIndexUtils.set('overlay', this.overlay, this.baseZIndex + this.config.zIndex.overlay);
|
---|
264 | }
|
---|
265 | this.alignOverlay();
|
---|
266 | this.bindDocumentClickListener();
|
---|
267 | this.bindDocumentResizeListener();
|
---|
268 | this.bindScrollListener();
|
---|
269 | this.onShow.emit(event);
|
---|
270 | break;
|
---|
271 | case 'void':
|
---|
272 | this.onOverlayHide();
|
---|
273 | break;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | onOverlayAnimationEnd(event) {
|
---|
277 | switch (event.toState) {
|
---|
278 | case 'void':
|
---|
279 | if (this.autoZIndex) {
|
---|
280 | ZIndexUtils.clear(event.element);
|
---|
281 | }
|
---|
282 | break;
|
---|
283 | }
|
---|
284 | }
|
---|
285 | onOverlayClick(event) {
|
---|
286 | this.overlayService.add({
|
---|
287 | originalEvent: event,
|
---|
288 | target: this.el.nativeElement
|
---|
289 | });
|
---|
290 | }
|
---|
291 | appendOverlay() {
|
---|
292 | if (this.appendTo) {
|
---|
293 | if (this.appendTo === 'body')
|
---|
294 | document.body.appendChild(this.overlay);
|
---|
295 | else
|
---|
296 | DomHandler.appendChild(this.overlay, this.appendTo);
|
---|
297 | if (!this.overlay.style.minWidth) {
|
---|
298 | this.overlay.style.minWidth = DomHandler.getWidth(this.el.nativeElement.children[0]) + 'px';
|
---|
299 | }
|
---|
300 | }
|
---|
301 | }
|
---|
302 | resolveFieldData(value) {
|
---|
303 | let data = this.field ? ObjectUtils.resolveFieldData(value, this.field) : value;
|
---|
304 | return data !== (null || undefined) ? data : '';
|
---|
305 | }
|
---|
306 | restoreOverlayAppend() {
|
---|
307 | if (this.overlay && this.appendTo) {
|
---|
308 | this.el.nativeElement.appendChild(this.overlay);
|
---|
309 | }
|
---|
310 | }
|
---|
311 | alignOverlay() {
|
---|
312 | if (this.appendTo)
|
---|
313 | DomHandler.absolutePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
|
---|
314 | else
|
---|
315 | DomHandler.relativePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
|
---|
316 | }
|
---|
317 | hide() {
|
---|
318 | this.overlayVisible = false;
|
---|
319 | this.cd.markForCheck();
|
---|
320 | }
|
---|
321 | handleDropdownClick(event) {
|
---|
322 | if (!this.overlayVisible) {
|
---|
323 | this.focusInput();
|
---|
324 | let queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
|
---|
325 | if (this.dropdownMode === 'blank')
|
---|
326 | this.search(event, '');
|
---|
327 | else if (this.dropdownMode === 'current')
|
---|
328 | this.search(event, queryValue);
|
---|
329 | this.onDropdownClick.emit({
|
---|
330 | originalEvent: event,
|
---|
331 | query: queryValue
|
---|
332 | });
|
---|
333 | }
|
---|
334 | else {
|
---|
335 | this.hide();
|
---|
336 | }
|
---|
337 | }
|
---|
338 | focusInput() {
|
---|
339 | if (this.multiple)
|
---|
340 | this.multiInputEL.nativeElement.focus();
|
---|
341 | else
|
---|
342 | this.inputEL.nativeElement.focus();
|
---|
343 | }
|
---|
344 | get emptyMessageLabel() {
|
---|
345 | return this.emptyMessage || this.config.getTranslation(TranslationKeys.EMPTY_MESSAGE);
|
---|
346 | }
|
---|
347 | removeItem(item) {
|
---|
348 | let itemIndex = DomHandler.index(item);
|
---|
349 | let removedValue = this.value[itemIndex];
|
---|
350 | this.value = this.value.filter((val, i) => i != itemIndex);
|
---|
351 | this.onModelChange(this.value);
|
---|
352 | this.updateFilledState();
|
---|
353 | this.onUnselect.emit(removedValue);
|
---|
354 | }
|
---|
355 | onKeydown(event) {
|
---|
356 | if (this.overlayVisible) {
|
---|
357 | switch (event.which) {
|
---|
358 | //down
|
---|
359 | case 40:
|
---|
360 | if (this.group) {
|
---|
361 | let highlightItemIndex = this.findOptionGroupIndex(this.highlightOption, this.suggestions);
|
---|
362 | if (highlightItemIndex !== -1) {
|
---|
363 | let nextItemIndex = highlightItemIndex.itemIndex + 1;
|
---|
364 | if (nextItemIndex < (this.getOptionGroupChildren(this.suggestions[highlightItemIndex.groupIndex]).length)) {
|
---|
365 | this.highlightOption = this.getOptionGroupChildren(this.suggestions[highlightItemIndex.groupIndex])[nextItemIndex];
|
---|
366 | this.highlightOptionChanged = true;
|
---|
367 | }
|
---|
368 | else if (this.suggestions[highlightItemIndex.groupIndex + 1]) {
|
---|
369 | this.highlightOption = this.getOptionGroupChildren(this.suggestions[highlightItemIndex.groupIndex + 1])[0];
|
---|
370 | this.highlightOptionChanged = true;
|
---|
371 | }
|
---|
372 | }
|
---|
373 | else {
|
---|
374 | this.highlightOption = this.getOptionGroupChildren(this.suggestions[0])[0];
|
---|
375 | }
|
---|
376 | }
|
---|
377 | else {
|
---|
378 | let highlightItemIndex = this.findOptionIndex(this.highlightOption, this.suggestions);
|
---|
379 | if (highlightItemIndex != -1) {
|
---|
380 | var nextItemIndex = highlightItemIndex + 1;
|
---|
381 | if (nextItemIndex != (this.suggestions.length)) {
|
---|
382 | this.highlightOption = this.suggestions[nextItemIndex];
|
---|
383 | this.highlightOptionChanged = true;
|
---|
384 | }
|
---|
385 | }
|
---|
386 | else {
|
---|
387 | this.highlightOption = this.suggestions[0];
|
---|
388 | }
|
---|
389 | }
|
---|
390 | event.preventDefault();
|
---|
391 | break;
|
---|
392 | //up
|
---|
393 | case 38:
|
---|
394 | if (this.group) {
|
---|
395 | let highlightItemIndex = this.findOptionGroupIndex(this.highlightOption, this.suggestions);
|
---|
396 | if (highlightItemIndex !== -1) {
|
---|
397 | let prevItemIndex = highlightItemIndex.itemIndex - 1;
|
---|
398 | if (prevItemIndex >= 0) {
|
---|
399 | this.highlightOption = this.getOptionGroupChildren(this.suggestions[highlightItemIndex.groupIndex])[prevItemIndex];
|
---|
400 | this.highlightOptionChanged = true;
|
---|
401 | }
|
---|
402 | else if (prevItemIndex < 0) {
|
---|
403 | let prevGroup = this.suggestions[highlightItemIndex.groupIndex - 1];
|
---|
404 | if (prevGroup) {
|
---|
405 | this.highlightOption = this.getOptionGroupChildren(prevGroup)[this.getOptionGroupChildren(prevGroup).length - 1];
|
---|
406 | this.highlightOptionChanged = true;
|
---|
407 | }
|
---|
408 | }
|
---|
409 | }
|
---|
410 | }
|
---|
411 | else {
|
---|
412 | let highlightItemIndex = this.findOptionIndex(this.highlightOption, this.suggestions);
|
---|
413 | if (highlightItemIndex > 0) {
|
---|
414 | let prevItemIndex = highlightItemIndex - 1;
|
---|
415 | this.highlightOption = this.suggestions[prevItemIndex];
|
---|
416 | this.highlightOptionChanged = true;
|
---|
417 | }
|
---|
418 | }
|
---|
419 | event.preventDefault();
|
---|
420 | break;
|
---|
421 | //enter
|
---|
422 | case 13:
|
---|
423 | if (this.highlightOption) {
|
---|
424 | this.selectItem(this.highlightOption);
|
---|
425 | this.hide();
|
---|
426 | }
|
---|
427 | event.preventDefault();
|
---|
428 | break;
|
---|
429 | //escape
|
---|
430 | case 27:
|
---|
431 | this.hide();
|
---|
432 | event.preventDefault();
|
---|
433 | break;
|
---|
434 | //tab
|
---|
435 | case 9:
|
---|
436 | if (this.highlightOption) {
|
---|
437 | this.selectItem(this.highlightOption);
|
---|
438 | }
|
---|
439 | this.hide();
|
---|
440 | break;
|
---|
441 | }
|
---|
442 | }
|
---|
443 | else {
|
---|
444 | if (event.which === 40 && this.suggestions) {
|
---|
445 | this.search(event, event.target.value);
|
---|
446 | }
|
---|
447 | }
|
---|
448 | if (this.multiple) {
|
---|
449 | switch (event.which) {
|
---|
450 | //backspace
|
---|
451 | case 8:
|
---|
452 | if (this.value && this.value.length && !this.multiInputEL.nativeElement.value) {
|
---|
453 | this.value = [...this.value];
|
---|
454 | const removedValue = this.value.pop();
|
---|
455 | this.onModelChange(this.value);
|
---|
456 | this.updateFilledState();
|
---|
457 | this.onUnselect.emit(removedValue);
|
---|
458 | }
|
---|
459 | break;
|
---|
460 | }
|
---|
461 | }
|
---|
462 | this.inputKeyDown = true;
|
---|
463 | }
|
---|
464 | onKeyup(event) {
|
---|
465 | this.onKeyUp.emit(event);
|
---|
466 | }
|
---|
467 | onInputFocus(event) {
|
---|
468 | if (!this.itemClicked && this.completeOnFocus) {
|
---|
469 | let queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
|
---|
470 | this.search(event, queryValue);
|
---|
471 | }
|
---|
472 | this.focus = true;
|
---|
473 | this.onFocus.emit(event);
|
---|
474 | this.itemClicked = false;
|
---|
475 | }
|
---|
476 | onInputBlur(event) {
|
---|
477 | this.focus = false;
|
---|
478 | this.onModelTouched();
|
---|
479 | this.onBlur.emit(event);
|
---|
480 | }
|
---|
481 | onInputChange(event) {
|
---|
482 | if (this.forceSelection) {
|
---|
483 | let valid = false;
|
---|
484 | let inputValue = event.target.value.trim();
|
---|
485 | if (this.suggestions) {
|
---|
486 | for (let suggestion of this.suggestions) {
|
---|
487 | let itemValue = this.field ? ObjectUtils.resolveFieldData(suggestion, this.field) : suggestion;
|
---|
488 | if (itemValue && inputValue === itemValue.trim()) {
|
---|
489 | valid = true;
|
---|
490 | this.forceSelectionUpdateModelTimeout = setTimeout(() => {
|
---|
491 | this.selectItem(suggestion, false);
|
---|
492 | }, 250);
|
---|
493 | break;
|
---|
494 | }
|
---|
495 | }
|
---|
496 | }
|
---|
497 | if (!valid) {
|
---|
498 | if (this.multiple) {
|
---|
499 | this.multiInputEL.nativeElement.value = '';
|
---|
500 | }
|
---|
501 | else {
|
---|
502 | this.value = null;
|
---|
503 | this.inputEL.nativeElement.value = '';
|
---|
504 | }
|
---|
505 | this.onClear.emit(event);
|
---|
506 | this.onModelChange(this.value);
|
---|
507 | this.updateFilledState();
|
---|
508 | }
|
---|
509 | }
|
---|
510 | }
|
---|
511 | onInputPaste(event) {
|
---|
512 | this.onKeydown(event);
|
---|
513 | }
|
---|
514 | isSelected(val) {
|
---|
515 | let selected = false;
|
---|
516 | if (this.value && this.value.length) {
|
---|
517 | for (let i = 0; i < this.value.length; i++) {
|
---|
518 | if (ObjectUtils.equals(this.value[i], val, this.dataKey)) {
|
---|
519 | selected = true;
|
---|
520 | break;
|
---|
521 | }
|
---|
522 | }
|
---|
523 | }
|
---|
524 | return selected;
|
---|
525 | }
|
---|
526 | findOptionIndex(option, suggestions) {
|
---|
527 | let index = -1;
|
---|
528 | if (suggestions) {
|
---|
529 | for (let i = 0; i < suggestions.length; i++) {
|
---|
530 | if (ObjectUtils.equals(option, suggestions[i])) {
|
---|
531 | index = i;
|
---|
532 | break;
|
---|
533 | }
|
---|
534 | }
|
---|
535 | }
|
---|
536 | return index;
|
---|
537 | }
|
---|
538 | findOptionGroupIndex(val, opts) {
|
---|
539 | let groupIndex, itemIndex;
|
---|
540 | if (opts) {
|
---|
541 | for (let i = 0; i < opts.length; i++) {
|
---|
542 | groupIndex = i;
|
---|
543 | itemIndex = this.findOptionIndex(val, this.getOptionGroupChildren(opts[i]));
|
---|
544 | if (itemIndex !== -1) {
|
---|
545 | break;
|
---|
546 | }
|
---|
547 | }
|
---|
548 | }
|
---|
549 | if (itemIndex !== -1) {
|
---|
550 | return { groupIndex: groupIndex, itemIndex: itemIndex };
|
---|
551 | }
|
---|
552 | else {
|
---|
553 | return -1;
|
---|
554 | }
|
---|
555 | }
|
---|
556 | updateFilledState() {
|
---|
557 | if (this.multiple)
|
---|
558 | this.filled = (this.value && this.value.length) || (this.multiInputEL && this.multiInputEL.nativeElement && this.multiInputEL.nativeElement.value != '');
|
---|
559 | else
|
---|
560 | this.filled = (this.inputFieldValue && this.inputFieldValue != '') || (this.inputEL && this.inputEL.nativeElement && this.inputEL.nativeElement.value != '');
|
---|
561 | ;
|
---|
562 | }
|
---|
563 | updateInputField() {
|
---|
564 | let formattedValue = this.resolveFieldData(this.value);
|
---|
565 | this.inputFieldValue = formattedValue;
|
---|
566 | if (this.inputEL && this.inputEL.nativeElement) {
|
---|
567 | this.inputEL.nativeElement.value = formattedValue;
|
---|
568 | }
|
---|
569 | this.updateFilledState();
|
---|
570 | }
|
---|
571 | bindDocumentClickListener() {
|
---|
572 | if (!this.documentClickListener) {
|
---|
573 | const documentTarget = this.el ? this.el.nativeElement.ownerDocument : 'document';
|
---|
574 | this.documentClickListener = this.renderer.listen(documentTarget, 'click', (event) => {
|
---|
575 | if (event.which === 3) {
|
---|
576 | return;
|
---|
577 | }
|
---|
578 | if (!this.inputClick && !this.isDropdownClick(event)) {
|
---|
579 | this.hide();
|
---|
580 | }
|
---|
581 | this.inputClick = false;
|
---|
582 | this.cd.markForCheck();
|
---|
583 | });
|
---|
584 | }
|
---|
585 | }
|
---|
586 | isDropdownClick(event) {
|
---|
587 | if (this.dropdown) {
|
---|
588 | let target = event.target;
|
---|
589 | return (target === this.dropdownButton.nativeElement || target.parentNode === this.dropdownButton.nativeElement);
|
---|
590 | }
|
---|
591 | else {
|
---|
592 | return false;
|
---|
593 | }
|
---|
594 | }
|
---|
595 | unbindDocumentClickListener() {
|
---|
596 | if (this.documentClickListener) {
|
---|
597 | this.documentClickListener();
|
---|
598 | this.documentClickListener = null;
|
---|
599 | }
|
---|
600 | }
|
---|
601 | bindDocumentResizeListener() {
|
---|
602 | this.documentResizeListener = this.onWindowResize.bind(this);
|
---|
603 | window.addEventListener('resize', this.documentResizeListener);
|
---|
604 | }
|
---|
605 | unbindDocumentResizeListener() {
|
---|
606 | if (this.documentResizeListener) {
|
---|
607 | window.removeEventListener('resize', this.documentResizeListener);
|
---|
608 | this.documentResizeListener = null;
|
---|
609 | }
|
---|
610 | }
|
---|
611 | onWindowResize() {
|
---|
612 | this.hide();
|
---|
613 | }
|
---|
614 | bindScrollListener() {
|
---|
615 | if (!this.scrollHandler) {
|
---|
616 | this.scrollHandler = new ConnectedOverlayScrollHandler(this.containerEL.nativeElement, () => {
|
---|
617 | if (this.overlayVisible) {
|
---|
618 | this.hide();
|
---|
619 | }
|
---|
620 | });
|
---|
621 | }
|
---|
622 | this.scrollHandler.bindScrollListener();
|
---|
623 | }
|
---|
624 | unbindScrollListener() {
|
---|
625 | if (this.scrollHandler) {
|
---|
626 | this.scrollHandler.unbindScrollListener();
|
---|
627 | }
|
---|
628 | }
|
---|
629 | onOverlayHide() {
|
---|
630 | this.unbindDocumentClickListener();
|
---|
631 | this.unbindDocumentResizeListener();
|
---|
632 | this.unbindScrollListener();
|
---|
633 | this.overlay = null;
|
---|
634 | this.onHide.emit();
|
---|
635 | }
|
---|
636 | ngOnDestroy() {
|
---|
637 | if (this.forceSelectionUpdateModelTimeout) {
|
---|
638 | clearTimeout(this.forceSelectionUpdateModelTimeout);
|
---|
639 | this.forceSelectionUpdateModelTimeout = null;
|
---|
640 | }
|
---|
641 | if (this.scrollHandler) {
|
---|
642 | this.scrollHandler.destroy();
|
---|
643 | this.scrollHandler = null;
|
---|
644 | }
|
---|
645 | if (this.overlay) {
|
---|
646 | ZIndexUtils.clear(this.overlay);
|
---|
647 | }
|
---|
648 | this.restoreOverlayAppend();
|
---|
649 | this.onOverlayHide();
|
---|
650 | }
|
---|
651 | }
|
---|
652 | AutoComplete.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoComplete, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.IterableDiffers }, { token: i1.PrimeNGConfig }, { token: i1.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
|
---|
653 | AutoComplete.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: AutoComplete, selector: "p-autoComplete", inputs: { minLength: "minLength", delay: "delay", style: "style", panelStyle: "panelStyle", styleClass: "styleClass", panelStyleClass: "panelStyleClass", inputStyle: "inputStyle", inputId: "inputId", inputStyleClass: "inputStyleClass", placeholder: "placeholder", readonly: "readonly", disabled: "disabled", virtualScroll: "virtualScroll", itemSize: "itemSize", maxlength: "maxlength", name: "name", required: "required", size: "size", appendTo: "appendTo", autoHighlight: "autoHighlight", forceSelection: "forceSelection", type: "type", autoZIndex: "autoZIndex", baseZIndex: "baseZIndex", ariaLabel: "ariaLabel", dropdownAriaLabel: "dropdownAriaLabel", ariaLabelledBy: "ariaLabelledBy", dropdownIcon: "dropdownIcon", unique: "unique", group: "group", completeOnFocus: "completeOnFocus", field: "field", scrollHeight: "scrollHeight", dropdown: "dropdown", showEmptyMessage: "showEmptyMessage", dropdownMode: "dropdownMode", multiple: "multiple", tabindex: "tabindex", dataKey: "dataKey", emptyMessage: "emptyMessage", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions", autofocus: "autofocus", autocomplete: "autocomplete", optionGroupChildren: "optionGroupChildren", optionGroupLabel: "optionGroupLabel", suggestions: "suggestions" }, outputs: { completeMethod: "completeMethod", onSelect: "onSelect", onUnselect: "onUnselect", onFocus: "onFocus", onBlur: "onBlur", onDropdownClick: "onDropdownClick", onClear: "onClear", onKeyUp: "onKeyUp", onShow: "onShow", onHide: "onHide" }, host: { properties: { "class.p-inputwrapper-filled": "filled", "class.p-inputwrapper-focus": "(focus && !disabled) ||\u00A0overlayVisible" }, classAttribute: "p-element p-inputwrapper" }, providers: [AUTOCOMPLETE_VALUE_ACCESSOR], queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "containerEL", first: true, predicate: ["container"], descendants: true }, { propertyName: "inputEL", first: true, predicate: ["in"], descendants: true }, { propertyName: "multiInputEL", first: true, predicate: ["multiIn"], descendants: true }, { propertyName: "multiContainerEL", first: true, predicate: ["multiContainer"], descendants: true }, { propertyName: "dropdownButton", first: true, predicate: ["ddBtn"], descendants: true }, { propertyName: "viewPort", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], ngImport: i0, template: `
|
---|
654 | <span #container [ngClass]="{'p-autocomplete p-component':true,'p-autocomplete-dd':dropdown,'p-autocomplete-multiple':multiple}" [ngStyle]="style" [class]="styleClass">
|
---|
655 | <input *ngIf="!multiple" #in [attr.type]="type" [attr.id]="inputId" [ngStyle]="inputStyle" [class]="inputStyleClass" [autocomplete]="autocomplete" [attr.required]="required" [attr.name]="name"
|
---|
656 | class="p-autocomplete-input p-inputtext p-component" [ngClass]="{'p-autocomplete-dd-input':dropdown,'p-disabled': disabled}" [value]="inputFieldValue" aria-autocomplete="list" [attr.aria-controls]="listId" role="searchbox" [attr.aria-expanded]="overlayVisible" aria-haspopup="true" [attr.aria-activedescendant]="'p-highlighted-option'"
|
---|
657 | (click)="onInputClick($event)" (input)="onInput($event)" (keydown)="onKeydown($event)" (keyup)="onKeyup($event)" [attr.autofocus]="autofocus" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (change)="onInputChange($event)" (paste)="onInputPaste($event)"
|
---|
658 | [attr.placeholder]="placeholder" [attr.size]="size" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [readonly]="readonly" [disabled]="disabled" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-required]="required"
|
---|
659 | ><ul *ngIf="multiple" #multiContainer class="p-autocomplete-multiple-container p-component p-inputtext" [ngClass]="{'p-disabled':disabled,'p-focus':focus}" (click)="multiIn.focus()">
|
---|
660 | <li #token *ngFor="let val of value" class="p-autocomplete-token">
|
---|
661 | <ng-container *ngTemplateOutlet="selectedItemTemplate; context: {$implicit: val}"></ng-container>
|
---|
662 | <span *ngIf="!selectedItemTemplate" class="p-autocomplete-token-label">{{resolveFieldData(val)}}</span>
|
---|
663 | <span class="p-autocomplete-token-icon pi pi-times-circle" (click)="removeItem(token)" *ngIf="!disabled && !readonly"></span>
|
---|
664 | </li>
|
---|
665 | <li class="p-autocomplete-input-token">
|
---|
666 | <input #multiIn [attr.type]="type" [attr.id]="inputId" [disabled]="disabled" [attr.placeholder]="(value&&value.length ? null : placeholder)" [attr.tabindex]="tabindex" [attr.maxlength]="maxlength" (input)="onInput($event)" (click)="onInputClick($event)"
|
---|
667 | (keydown)="onKeydown($event)" [readonly]="readonly" (keyup)="onKeyup($event)" [attr.autofocus]="autofocus" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (change)="onInputChange($event)" (paste)="onInputPaste($event)" [autocomplete]="autocomplete"
|
---|
668 | [ngStyle]="inputStyle" [class]="inputStyleClass" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-required]="required"
|
---|
669 | aria-autocomplete="list" [attr.aria-controls]="listId" role="searchbox" [attr.aria-expanded]="overlayVisible" aria-haspopup="true" [attr.aria-activedescendant]="'p-highlighted-option'">
|
---|
670 | </li>
|
---|
671 | </ul>
|
---|
672 | <i *ngIf="loading" class="p-autocomplete-loader pi pi-spinner pi-spin"></i><button #ddBtn type="button" pButton [icon]="dropdownIcon" [attr.aria-label]="dropdownAriaLabel" class="p-autocomplete-dropdown" [disabled]="disabled" pRipple
|
---|
673 | (click)="handleDropdownClick($event)" *ngIf="dropdown" [attr.tabindex]="tabindex"></button>
|
---|
674 | <div #panel *ngIf="overlayVisible" (click)="onOverlayClick($event)" [ngClass]="['p-autocomplete-panel p-component']" [style.max-height]="virtualScroll ? 'auto' : scrollHeight" [ngStyle]="panelStyle" [class]="panelStyleClass"
|
---|
675 | [@overlayAnimation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@overlayAnimation.start)="onOverlayAnimationStart($event)" (@overlayAnimation.done)="onOverlayAnimationEnd($event)">
|
---|
676 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
677 | <ul role="listbox" [attr.id]="listId" class="p-autocomplete-items" [ngClass]="{'p-autocomplete-virtualscroll': virtualScroll}">
|
---|
678 | <ng-container *ngIf="group">
|
---|
679 | <ng-template ngFor let-optgroup [ngForOf]="suggestions">
|
---|
680 | <li class="p-autocomplete-item-group">
|
---|
681 | <span *ngIf="!groupTemplate">{{getOptionGroupLabel(optgroup)||'empty'}}</span>
|
---|
682 | <ng-container *ngTemplateOutlet="groupTemplate; context: {$implicit: optgroup}"></ng-container>
|
---|
683 | </li>
|
---|
684 | <ng-container *ngTemplateOutlet="itemslist; context: {$implicit: getOptionGroupChildren(optgroup)}"></ng-container>
|
---|
685 | </ng-template>
|
---|
686 | </ng-container>
|
---|
687 | <ng-container *ngIf="!group">
|
---|
688 | <ng-container *ngTemplateOutlet="itemslist; context: {$implicit: suggestions}"></ng-container>
|
---|
689 | </ng-container>
|
---|
690 | <ng-template #itemslist let-suggestionsToDisplay>
|
---|
691 | <ng-container *ngIf="!virtualScroll; else virtualScrollList">
|
---|
692 | <li role="option" *ngFor="let option of suggestionsToDisplay; let idx = index" class="p-autocomplete-item" pRipple [ngClass]="{'p-highlight': (option === highlightOption)}" [id]="highlightOption == option ? 'p-highlighted-option':''" (click)="selectItem(option)">
|
---|
693 | <span *ngIf="!itemTemplate">{{resolveFieldData(option)}}</span>
|
---|
694 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: option, index: idx}"></ng-container>
|
---|
695 | </li>
|
---|
696 | </ng-container>
|
---|
697 | <ng-template #virtualScrollList>
|
---|
698 | <cdk-virtual-scroll-viewport [ngStyle]="{'height': scrollHeight}" [itemSize]="itemSize" *ngIf="virtualScroll && !noResults">
|
---|
699 | <ng-container *cdkVirtualFor="let option of suggestionsToDisplay; let i = index; let c = count; let f = first; let l = last; let e = even; let o = odd">
|
---|
700 | <li role="option" class="p-autocomplete-item" pRipple [ngClass]="{'p-highlight': (option === highlightOption)}" [ngStyle]="{'height': itemSize + 'px'}" [id]="highlightOption == option ? 'p-highlighted-option':''" (click)="selectItem(option)">
|
---|
701 | <span *ngIf="!itemTemplate">{{resolveFieldData(option)}}</span>
|
---|
702 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: option, index: i}"></ng-container>
|
---|
703 | </li>
|
---|
704 | </ng-container>
|
---|
705 | </cdk-virtual-scroll-viewport>
|
---|
706 | </ng-template>
|
---|
707 | <li *ngIf="noResults && showEmptyMessage" class="p-autocomplete-empty-message">
|
---|
708 | <ng-container *ngIf="!emptyTemplate; else empty">
|
---|
709 | {{emptyMessageLabel}}
|
---|
710 | </ng-container>
|
---|
711 | <ng-container #empty *ngTemplateOutlet="emptyTemplate"></ng-container>
|
---|
712 | </li>
|
---|
713 | </ng-template>
|
---|
714 | </ul>
|
---|
715 | <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
---|
716 | </div>
|
---|
717 | </span>
|
---|
718 | `, isInline: true, styles: [".p-autocomplete{display:inline-flex;position:relative}.p-autocomplete-loader{position:absolute;top:50%;margin-top:-.5rem}.p-autocomplete-dd .p-autocomplete-input{flex:1 1 auto;width:1%}.p-autocomplete-dd .p-autocomplete-input,.p-autocomplete-dd .p-autocomplete-multiple-container{border-top-right-radius:0;border-bottom-right-radius:0}.p-autocomplete-dd .p-autocomplete-dropdown{border-top-left-radius:0;border-bottom-left-radius:0}.p-autocomplete .p-autocomplete-panel{min-width:100%;top:0;left:0}.p-autocomplete-panel{position:absolute;overflow:auto}.p-autocomplete-items{margin:0;padding:0;list-style-type:none}.p-autocomplete-item{cursor:pointer;white-space:nowrap;position:relative;overflow:hidden}.p-autocomplete-multiple-container{margin:0;padding:0;list-style-type:none;cursor:text;overflow:hidden;display:flex;align-items:center;flex-wrap:wrap}.p-autocomplete-token{cursor:default;display:inline-flex;align-items:center;flex:0 0 auto}.p-autocomplete-token-icon{cursor:pointer}.p-autocomplete-input-token{flex:1 1 auto;display:inline-flex}.p-autocomplete-input-token input{border:0 none;outline:0 none;background-color:transparent;margin:0;padding:0;box-shadow:none;border-radius:0;width:100%}.p-fluid .p-autocomplete{display:flex}.p-fluid .p-autocomplete-dd .p-autocomplete-input{width:1%}\n"], components: [{ type: i2.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i4.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i5.Ripple, selector: "[pRipple]" }, { type: i2.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { type: i2.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }], animations: [
|
---|
719 | trigger('overlayAnimation', [
|
---|
720 | transition(':enter', [
|
---|
721 | style({ opacity: 0, transform: 'scaleY(0.8)' }),
|
---|
722 | animate('{{showTransitionParams}}')
|
---|
723 | ]),
|
---|
724 | transition(':leave', [
|
---|
725 | animate('{{hideTransitionParams}}', style({ opacity: 0 }))
|
---|
726 | ])
|
---|
727 | ])
|
---|
728 | ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
729 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoComplete, decorators: [{
|
---|
730 | type: Component,
|
---|
731 | args: [{ selector: 'p-autoComplete', template: `
|
---|
732 | <span #container [ngClass]="{'p-autocomplete p-component':true,'p-autocomplete-dd':dropdown,'p-autocomplete-multiple':multiple}" [ngStyle]="style" [class]="styleClass">
|
---|
733 | <input *ngIf="!multiple" #in [attr.type]="type" [attr.id]="inputId" [ngStyle]="inputStyle" [class]="inputStyleClass" [autocomplete]="autocomplete" [attr.required]="required" [attr.name]="name"
|
---|
734 | class="p-autocomplete-input p-inputtext p-component" [ngClass]="{'p-autocomplete-dd-input':dropdown,'p-disabled': disabled}" [value]="inputFieldValue" aria-autocomplete="list" [attr.aria-controls]="listId" role="searchbox" [attr.aria-expanded]="overlayVisible" aria-haspopup="true" [attr.aria-activedescendant]="'p-highlighted-option'"
|
---|
735 | (click)="onInputClick($event)" (input)="onInput($event)" (keydown)="onKeydown($event)" (keyup)="onKeyup($event)" [attr.autofocus]="autofocus" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (change)="onInputChange($event)" (paste)="onInputPaste($event)"
|
---|
736 | [attr.placeholder]="placeholder" [attr.size]="size" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [readonly]="readonly" [disabled]="disabled" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-required]="required"
|
---|
737 | ><ul *ngIf="multiple" #multiContainer class="p-autocomplete-multiple-container p-component p-inputtext" [ngClass]="{'p-disabled':disabled,'p-focus':focus}" (click)="multiIn.focus()">
|
---|
738 | <li #token *ngFor="let val of value" class="p-autocomplete-token">
|
---|
739 | <ng-container *ngTemplateOutlet="selectedItemTemplate; context: {$implicit: val}"></ng-container>
|
---|
740 | <span *ngIf="!selectedItemTemplate" class="p-autocomplete-token-label">{{resolveFieldData(val)}}</span>
|
---|
741 | <span class="p-autocomplete-token-icon pi pi-times-circle" (click)="removeItem(token)" *ngIf="!disabled && !readonly"></span>
|
---|
742 | </li>
|
---|
743 | <li class="p-autocomplete-input-token">
|
---|
744 | <input #multiIn [attr.type]="type" [attr.id]="inputId" [disabled]="disabled" [attr.placeholder]="(value&&value.length ? null : placeholder)" [attr.tabindex]="tabindex" [attr.maxlength]="maxlength" (input)="onInput($event)" (click)="onInputClick($event)"
|
---|
745 | (keydown)="onKeydown($event)" [readonly]="readonly" (keyup)="onKeyup($event)" [attr.autofocus]="autofocus" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (change)="onInputChange($event)" (paste)="onInputPaste($event)" [autocomplete]="autocomplete"
|
---|
746 | [ngStyle]="inputStyle" [class]="inputStyleClass" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-required]="required"
|
---|
747 | aria-autocomplete="list" [attr.aria-controls]="listId" role="searchbox" [attr.aria-expanded]="overlayVisible" aria-haspopup="true" [attr.aria-activedescendant]="'p-highlighted-option'">
|
---|
748 | </li>
|
---|
749 | </ul>
|
---|
750 | <i *ngIf="loading" class="p-autocomplete-loader pi pi-spinner pi-spin"></i><button #ddBtn type="button" pButton [icon]="dropdownIcon" [attr.aria-label]="dropdownAriaLabel" class="p-autocomplete-dropdown" [disabled]="disabled" pRipple
|
---|
751 | (click)="handleDropdownClick($event)" *ngIf="dropdown" [attr.tabindex]="tabindex"></button>
|
---|
752 | <div #panel *ngIf="overlayVisible" (click)="onOverlayClick($event)" [ngClass]="['p-autocomplete-panel p-component']" [style.max-height]="virtualScroll ? 'auto' : scrollHeight" [ngStyle]="panelStyle" [class]="panelStyleClass"
|
---|
753 | [@overlayAnimation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@overlayAnimation.start)="onOverlayAnimationStart($event)" (@overlayAnimation.done)="onOverlayAnimationEnd($event)">
|
---|
754 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
755 | <ul role="listbox" [attr.id]="listId" class="p-autocomplete-items" [ngClass]="{'p-autocomplete-virtualscroll': virtualScroll}">
|
---|
756 | <ng-container *ngIf="group">
|
---|
757 | <ng-template ngFor let-optgroup [ngForOf]="suggestions">
|
---|
758 | <li class="p-autocomplete-item-group">
|
---|
759 | <span *ngIf="!groupTemplate">{{getOptionGroupLabel(optgroup)||'empty'}}</span>
|
---|
760 | <ng-container *ngTemplateOutlet="groupTemplate; context: {$implicit: optgroup}"></ng-container>
|
---|
761 | </li>
|
---|
762 | <ng-container *ngTemplateOutlet="itemslist; context: {$implicit: getOptionGroupChildren(optgroup)}"></ng-container>
|
---|
763 | </ng-template>
|
---|
764 | </ng-container>
|
---|
765 | <ng-container *ngIf="!group">
|
---|
766 | <ng-container *ngTemplateOutlet="itemslist; context: {$implicit: suggestions}"></ng-container>
|
---|
767 | </ng-container>
|
---|
768 | <ng-template #itemslist let-suggestionsToDisplay>
|
---|
769 | <ng-container *ngIf="!virtualScroll; else virtualScrollList">
|
---|
770 | <li role="option" *ngFor="let option of suggestionsToDisplay; let idx = index" class="p-autocomplete-item" pRipple [ngClass]="{'p-highlight': (option === highlightOption)}" [id]="highlightOption == option ? 'p-highlighted-option':''" (click)="selectItem(option)">
|
---|
771 | <span *ngIf="!itemTemplate">{{resolveFieldData(option)}}</span>
|
---|
772 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: option, index: idx}"></ng-container>
|
---|
773 | </li>
|
---|
774 | </ng-container>
|
---|
775 | <ng-template #virtualScrollList>
|
---|
776 | <cdk-virtual-scroll-viewport [ngStyle]="{'height': scrollHeight}" [itemSize]="itemSize" *ngIf="virtualScroll && !noResults">
|
---|
777 | <ng-container *cdkVirtualFor="let option of suggestionsToDisplay; let i = index; let c = count; let f = first; let l = last; let e = even; let o = odd">
|
---|
778 | <li role="option" class="p-autocomplete-item" pRipple [ngClass]="{'p-highlight': (option === highlightOption)}" [ngStyle]="{'height': itemSize + 'px'}" [id]="highlightOption == option ? 'p-highlighted-option':''" (click)="selectItem(option)">
|
---|
779 | <span *ngIf="!itemTemplate">{{resolveFieldData(option)}}</span>
|
---|
780 | <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: option, index: i}"></ng-container>
|
---|
781 | </li>
|
---|
782 | </ng-container>
|
---|
783 | </cdk-virtual-scroll-viewport>
|
---|
784 | </ng-template>
|
---|
785 | <li *ngIf="noResults && showEmptyMessage" class="p-autocomplete-empty-message">
|
---|
786 | <ng-container *ngIf="!emptyTemplate; else empty">
|
---|
787 | {{emptyMessageLabel}}
|
---|
788 | </ng-container>
|
---|
789 | <ng-container #empty *ngTemplateOutlet="emptyTemplate"></ng-container>
|
---|
790 | </li>
|
---|
791 | </ng-template>
|
---|
792 | </ul>
|
---|
793 | <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
|
---|
794 | </div>
|
---|
795 | </span>
|
---|
796 | `, animations: [
|
---|
797 | trigger('overlayAnimation', [
|
---|
798 | transition(':enter', [
|
---|
799 | style({ opacity: 0, transform: 'scaleY(0.8)' }),
|
---|
800 | animate('{{showTransitionParams}}')
|
---|
801 | ]),
|
---|
802 | transition(':leave', [
|
---|
803 | animate('{{hideTransitionParams}}', style({ opacity: 0 }))
|
---|
804 | ])
|
---|
805 | ])
|
---|
806 | ], host: {
|
---|
807 | 'class': 'p-element p-inputwrapper',
|
---|
808 | '[class.p-inputwrapper-filled]': 'filled',
|
---|
809 | '[class.p-inputwrapper-focus]': '(focus && !disabled) || overlayVisible'
|
---|
810 | }, providers: [AUTOCOMPLETE_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".p-autocomplete{display:inline-flex;position:relative}.p-autocomplete-loader{position:absolute;top:50%;margin-top:-.5rem}.p-autocomplete-dd .p-autocomplete-input{flex:1 1 auto;width:1%}.p-autocomplete-dd .p-autocomplete-input,.p-autocomplete-dd .p-autocomplete-multiple-container{border-top-right-radius:0;border-bottom-right-radius:0}.p-autocomplete-dd .p-autocomplete-dropdown{border-top-left-radius:0;border-bottom-left-radius:0}.p-autocomplete .p-autocomplete-panel{min-width:100%;top:0;left:0}.p-autocomplete-panel{position:absolute;overflow:auto}.p-autocomplete-items{margin:0;padding:0;list-style-type:none}.p-autocomplete-item{cursor:pointer;white-space:nowrap;position:relative;overflow:hidden}.p-autocomplete-multiple-container{margin:0;padding:0;list-style-type:none;cursor:text;overflow:hidden;display:flex;align-items:center;flex-wrap:wrap}.p-autocomplete-token{cursor:default;display:inline-flex;align-items:center;flex:0 0 auto}.p-autocomplete-token-icon{cursor:pointer}.p-autocomplete-input-token{flex:1 1 auto;display:inline-flex}.p-autocomplete-input-token input{border:0 none;outline:0 none;background-color:transparent;margin:0;padding:0;box-shadow:none;border-radius:0;width:100%}.p-fluid .p-autocomplete{display:flex}.p-fluid .p-autocomplete-dd .p-autocomplete-input{width:1%}\n"] }]
|
---|
811 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.IterableDiffers }, { type: i1.PrimeNGConfig }, { type: i1.OverlayService }]; }, propDecorators: { minLength: [{
|
---|
812 | type: Input
|
---|
813 | }], delay: [{
|
---|
814 | type: Input
|
---|
815 | }], style: [{
|
---|
816 | type: Input
|
---|
817 | }], panelStyle: [{
|
---|
818 | type: Input
|
---|
819 | }], styleClass: [{
|
---|
820 | type: Input
|
---|
821 | }], panelStyleClass: [{
|
---|
822 | type: Input
|
---|
823 | }], inputStyle: [{
|
---|
824 | type: Input
|
---|
825 | }], inputId: [{
|
---|
826 | type: Input
|
---|
827 | }], inputStyleClass: [{
|
---|
828 | type: Input
|
---|
829 | }], placeholder: [{
|
---|
830 | type: Input
|
---|
831 | }], readonly: [{
|
---|
832 | type: Input
|
---|
833 | }], disabled: [{
|
---|
834 | type: Input
|
---|
835 | }], virtualScroll: [{
|
---|
836 | type: Input
|
---|
837 | }], itemSize: [{
|
---|
838 | type: Input
|
---|
839 | }], maxlength: [{
|
---|
840 | type: Input
|
---|
841 | }], name: [{
|
---|
842 | type: Input
|
---|
843 | }], required: [{
|
---|
844 | type: Input
|
---|
845 | }], size: [{
|
---|
846 | type: Input
|
---|
847 | }], appendTo: [{
|
---|
848 | type: Input
|
---|
849 | }], autoHighlight: [{
|
---|
850 | type: Input
|
---|
851 | }], forceSelection: [{
|
---|
852 | type: Input
|
---|
853 | }], type: [{
|
---|
854 | type: Input
|
---|
855 | }], autoZIndex: [{
|
---|
856 | type: Input
|
---|
857 | }], baseZIndex: [{
|
---|
858 | type: Input
|
---|
859 | }], ariaLabel: [{
|
---|
860 | type: Input
|
---|
861 | }], dropdownAriaLabel: [{
|
---|
862 | type: Input
|
---|
863 | }], ariaLabelledBy: [{
|
---|
864 | type: Input
|
---|
865 | }], dropdownIcon: [{
|
---|
866 | type: Input
|
---|
867 | }], unique: [{
|
---|
868 | type: Input
|
---|
869 | }], group: [{
|
---|
870 | type: Input
|
---|
871 | }], completeOnFocus: [{
|
---|
872 | type: Input
|
---|
873 | }], completeMethod: [{
|
---|
874 | type: Output
|
---|
875 | }], onSelect: [{
|
---|
876 | type: Output
|
---|
877 | }], onUnselect: [{
|
---|
878 | type: Output
|
---|
879 | }], onFocus: [{
|
---|
880 | type: Output
|
---|
881 | }], onBlur: [{
|
---|
882 | type: Output
|
---|
883 | }], onDropdownClick: [{
|
---|
884 | type: Output
|
---|
885 | }], onClear: [{
|
---|
886 | type: Output
|
---|
887 | }], onKeyUp: [{
|
---|
888 | type: Output
|
---|
889 | }], onShow: [{
|
---|
890 | type: Output
|
---|
891 | }], onHide: [{
|
---|
892 | type: Output
|
---|
893 | }], field: [{
|
---|
894 | type: Input
|
---|
895 | }], scrollHeight: [{
|
---|
896 | type: Input
|
---|
897 | }], dropdown: [{
|
---|
898 | type: Input
|
---|
899 | }], showEmptyMessage: [{
|
---|
900 | type: Input
|
---|
901 | }], dropdownMode: [{
|
---|
902 | type: Input
|
---|
903 | }], multiple: [{
|
---|
904 | type: Input
|
---|
905 | }], tabindex: [{
|
---|
906 | type: Input
|
---|
907 | }], dataKey: [{
|
---|
908 | type: Input
|
---|
909 | }], emptyMessage: [{
|
---|
910 | type: Input
|
---|
911 | }], showTransitionOptions: [{
|
---|
912 | type: Input
|
---|
913 | }], hideTransitionOptions: [{
|
---|
914 | type: Input
|
---|
915 | }], autofocus: [{
|
---|
916 | type: Input
|
---|
917 | }], autocomplete: [{
|
---|
918 | type: Input
|
---|
919 | }], optionGroupChildren: [{
|
---|
920 | type: Input
|
---|
921 | }], optionGroupLabel: [{
|
---|
922 | type: Input
|
---|
923 | }], containerEL: [{
|
---|
924 | type: ViewChild,
|
---|
925 | args: ['container']
|
---|
926 | }], inputEL: [{
|
---|
927 | type: ViewChild,
|
---|
928 | args: ['in']
|
---|
929 | }], multiInputEL: [{
|
---|
930 | type: ViewChild,
|
---|
931 | args: ['multiIn']
|
---|
932 | }], multiContainerEL: [{
|
---|
933 | type: ViewChild,
|
---|
934 | args: ['multiContainer']
|
---|
935 | }], dropdownButton: [{
|
---|
936 | type: ViewChild,
|
---|
937 | args: ['ddBtn']
|
---|
938 | }], viewPort: [{
|
---|
939 | type: ViewChild,
|
---|
940 | args: [CdkVirtualScrollViewport]
|
---|
941 | }], templates: [{
|
---|
942 | type: ContentChildren,
|
---|
943 | args: [PrimeTemplate]
|
---|
944 | }], suggestions: [{
|
---|
945 | type: Input
|
---|
946 | }] } });
|
---|
947 | class AutoCompleteModule {
|
---|
948 | }
|
---|
949 | AutoCompleteModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoCompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
950 | AutoCompleteModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoCompleteModule, declarations: [AutoComplete], imports: [CommonModule, InputTextModule, ButtonModule, SharedModule, RippleModule, ScrollingModule], exports: [AutoComplete, SharedModule, ScrollingModule] });
|
---|
951 | AutoCompleteModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoCompleteModule, imports: [[CommonModule, InputTextModule, ButtonModule, SharedModule, RippleModule, ScrollingModule], SharedModule, ScrollingModule] });
|
---|
952 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AutoCompleteModule, decorators: [{
|
---|
953 | type: NgModule,
|
---|
954 | args: [{
|
---|
955 | imports: [CommonModule, InputTextModule, ButtonModule, SharedModule, RippleModule, ScrollingModule],
|
---|
956 | exports: [AutoComplete, SharedModule, ScrollingModule],
|
---|
957 | declarations: [AutoComplete]
|
---|
958 | }]
|
---|
959 | }] });
|
---|
960 |
|
---|
961 | /**
|
---|
962 | * Generated bundle index. Do not edit.
|
---|
963 | */
|
---|
964 |
|
---|
965 | export { AUTOCOMPLETE_VALUE_ACCESSOR, AutoComplete, AutoCompleteModule };
|
---|