UNPKG

38.5 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/animations'), require('primeng/inputtext'), require('primeng/button'), require('primeng/api'), require('primeng/dom'), require('primeng/utils'), require('@angular/forms')) :
3 typeof define === 'function' && define.amd ? define('primeng/autocomplete', ['exports', '@angular/core', '@angular/common', '@angular/animations', 'primeng/inputtext', 'primeng/button', 'primeng/api', 'primeng/dom', 'primeng/utils', '@angular/forms'], factory) :
4 (global = global || self, factory((global.primeng = global.primeng || {}, global.primeng.autocomplete = {}), global.ng.core, global.ng.common, global.ng.animations, global.primeng.inputtext, global.primeng.button, global.primeng.api, global.primeng.dom, global.primeng.utils, global.ng.forms));
5}(this, (function (exports, core, common, animations, inputtext, button, api, dom, utils, forms) { 'use strict';
6
7 var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11 return c > 3 && r && Object.defineProperty(target, key, r), r;
12 };
13 var __read = (this && this.__read) || function (o, n) {
14 var m = typeof Symbol === "function" && o[Symbol.iterator];
15 if (!m) return o;
16 var i = m.call(o), r, ar = [], e;
17 try {
18 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19 }
20 catch (error) { e = { error: error }; }
21 finally {
22 try {
23 if (r && !r.done && (m = i["return"])) m.call(i);
24 }
25 finally { if (e) throw e.error; }
26 }
27 return ar;
28 };
29 var __spread = (this && this.__spread) || function () {
30 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
31 return ar;
32 };
33 var __values = (this && this.__values) || function(o) {
34 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
35 if (m) return m.call(o);
36 if (o && typeof o.length === "number") return {
37 next: function () {
38 if (o && i >= o.length) o = void 0;
39 return { value: o && o[i++], done: !o };
40 }
41 };
42 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
43 };
44 var AUTOCOMPLETE_VALUE_ACCESSOR = {
45 provide: forms.NG_VALUE_ACCESSOR,
46 useExisting: core.forwardRef(function () { return AutoComplete; }),
47 multi: true
48 };
49 var AutoComplete = /** @class */ (function () {
50 function AutoComplete(el, renderer, cd, differs) {
51 this.el = el;
52 this.renderer = renderer;
53 this.cd = cd;
54 this.differs = differs;
55 this.minLength = 1;
56 this.delay = 300;
57 this.type = 'text';
58 this.autoZIndex = true;
59 this.baseZIndex = 0;
60 this.dropdownIcon = "pi pi-caret-down";
61 this.unique = true;
62 this.completeOnFocus = false;
63 this.completeMethod = new core.EventEmitter();
64 this.onSelect = new core.EventEmitter();
65 this.onUnselect = new core.EventEmitter();
66 this.onFocus = new core.EventEmitter();
67 this.onBlur = new core.EventEmitter();
68 this.onDropdownClick = new core.EventEmitter();
69 this.onClear = new core.EventEmitter();
70 this.onKeyUp = new core.EventEmitter();
71 this.onShow = new core.EventEmitter();
72 this.onHide = new core.EventEmitter();
73 this.scrollHeight = '200px';
74 this.dropdownMode = 'blank';
75 this.showTransitionOptions = '225ms ease-out';
76 this.hideTransitionOptions = '195ms ease-in';
77 this.autocomplete = 'off';
78 this.onModelChange = function () { };
79 this.onModelTouched = function () { };
80 this.overlayVisible = false;
81 this.focus = false;
82 this.inputFieldValue = null;
83 this.differ = differs.find([]).create(null);
84 this.listId = utils.UniqueComponentId() + '_list';
85 }
86 Object.defineProperty(AutoComplete.prototype, "suggestions", {
87 get: function () {
88 return this._suggestions;
89 },
90 set: function (val) {
91 this._suggestions = val;
92 this.handleSuggestionsChange();
93 },
94 enumerable: true,
95 configurable: true
96 });
97 AutoComplete.prototype.ngAfterViewChecked = function () {
98 var _this = this;
99 //Use timeouts as since Angular 4.2, AfterViewChecked is broken and not called after panel is updated
100 if (this.suggestionsUpdated && this.overlay && this.overlay.offsetParent) {
101 setTimeout(function () {
102 if (_this.overlay) {
103 _this.alignOverlay();
104 }
105 }, 1);
106 this.suggestionsUpdated = false;
107 }
108 if (this.highlightOptionChanged) {
109 setTimeout(function () {
110 if (_this.overlay) {
111 var listItem = dom.DomHandler.findSingle(_this.overlay, 'li.ui-state-highlight');
112 if (listItem) {
113 dom.DomHandler.scrollInView(_this.overlay, listItem);
114 }
115 }
116 }, 1);
117 this.highlightOptionChanged = false;
118 }
119 };
120 AutoComplete.prototype.handleSuggestionsChange = function () {
121 if (this._suggestions != null && this.loading) {
122 this.highlightOption = null;
123 if (this._suggestions.length) {
124 this.noResults = false;
125 this.show();
126 this.suggestionsUpdated = true;
127 if (this.autoHighlight) {
128 this.highlightOption = this._suggestions[0];
129 }
130 }
131 else {
132 this.noResults = true;
133 if (this.emptyMessage) {
134 this.show();
135 this.suggestionsUpdated = true;
136 }
137 else {
138 this.hide();
139 }
140 }
141 this.loading = false;
142 }
143 };
144 AutoComplete.prototype.ngAfterContentInit = function () {
145 var _this = this;
146 this.templates.forEach(function (item) {
147 switch (item.getType()) {
148 case 'item':
149 _this.itemTemplate = item.template;
150 break;
151 case 'selectedItem':
152 _this.selectedItemTemplate = item.template;
153 break;
154 default:
155 _this.itemTemplate = item.template;
156 break;
157 }
158 });
159 };
160 AutoComplete.prototype.writeValue = function (value) {
161 this.value = value;
162 this.filled = this.value && this.value != '';
163 this.updateInputField();
164 };
165 AutoComplete.prototype.registerOnChange = function (fn) {
166 this.onModelChange = fn;
167 };
168 AutoComplete.prototype.registerOnTouched = function (fn) {
169 this.onModelTouched = fn;
170 };
171 AutoComplete.prototype.setDisabledState = function (val) {
172 this.disabled = val;
173 };
174 AutoComplete.prototype.onInput = function (event) {
175 var _this = this;
176 // When an input element with a placeholder is clicked, the onInput event is invoked in IE.
177 if (!this.inputKeyDown && dom.DomHandler.isIE()) {
178 return;
179 }
180 if (this.timeout) {
181 clearTimeout(this.timeout);
182 }
183 var value = event.target.value;
184 if (!this.multiple && !this.forceSelection) {
185 this.onModelChange(value);
186 }
187 if (value.length === 0 && !this.multiple) {
188 this.hide();
189 this.onClear.emit(event);
190 this.onModelChange(value);
191 }
192 if (value.length >= this.minLength) {
193 this.timeout = setTimeout(function () {
194 _this.search(event, value);
195 }, this.delay);
196 }
197 else {
198 this.suggestions = null;
199 this.hide();
200 }
201 this.updateFilledState();
202 this.inputKeyDown = false;
203 };
204 AutoComplete.prototype.onInputClick = function (event) {
205 if (this.documentClickListener) {
206 this.inputClick = true;
207 }
208 };
209 AutoComplete.prototype.search = function (event, query) {
210 //allow empty string but not undefined or null
211 if (query === undefined || query === null) {
212 return;
213 }
214 this.loading = true;
215 this.completeMethod.emit({
216 originalEvent: event,
217 query: query
218 });
219 };
220 AutoComplete.prototype.selectItem = function (option, focus) {
221 if (focus === void 0) { 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 = __spread(this.value, [option]);
231 this.onModelChange(this.value);
232 }
233 }
234 else {
235 this.inputEL.nativeElement.value = this.field ? utils.ObjectUtils.resolveFieldData(option, this.field) || '' : 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 AutoComplete.prototype.show = function () {
247 if (this.multiInputEL || this.inputEL) {
248 var hasFocus = this.multiple ? document.activeElement == this.multiInputEL.nativeElement : document.activeElement == this.inputEL.nativeElement;
249 if (!this.overlayVisible && hasFocus) {
250 this.overlayVisible = true;
251 }
252 }
253 };
254 AutoComplete.prototype.onOverlayAnimationStart = function (event) {
255 switch (event.toState) {
256 case 'visible':
257 this.overlay = event.element;
258 this.appendOverlay();
259 if (this.autoZIndex) {
260 this.overlay.style.zIndex = String(this.baseZIndex + (++dom.DomHandler.zindex));
261 }
262 this.alignOverlay();
263 this.bindDocumentClickListener();
264 this.bindDocumentResizeListener();
265 this.onShow.emit(event);
266 break;
267 case 'void':
268 this.onOverlayHide();
269 break;
270 }
271 };
272 AutoComplete.prototype.onOverlayAnimationDone = function (event) {
273 if (event.toState === 'void') {
274 this._suggestions = null;
275 }
276 };
277 AutoComplete.prototype.appendOverlay = function () {
278 if (this.appendTo) {
279 if (this.appendTo === 'body')
280 document.body.appendChild(this.overlay);
281 else
282 dom.DomHandler.appendChild(this.overlay, this.appendTo);
283 if (!this.overlay.style.minWidth) {
284 this.overlay.style.minWidth = dom.DomHandler.getWidth(this.el.nativeElement.children[0]) + 'px';
285 }
286 }
287 };
288 AutoComplete.prototype.resolveFieldData = function (value) {
289 return this.field ? utils.ObjectUtils.resolveFieldData(value, this.field) : value;
290 };
291 AutoComplete.prototype.restoreOverlayAppend = function () {
292 if (this.overlay && this.appendTo) {
293 this.el.nativeElement.appendChild(this.overlay);
294 }
295 };
296 AutoComplete.prototype.alignOverlay = function () {
297 if (this.appendTo)
298 dom.DomHandler.absolutePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
299 else
300 dom.DomHandler.relativePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
301 };
302 AutoComplete.prototype.hide = function () {
303 this.overlayVisible = false;
304 };
305 AutoComplete.prototype.handleDropdownClick = function (event) {
306 if (!this.overlayVisible) {
307 this.focusInput();
308 var queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
309 if (this.dropdownMode === 'blank')
310 this.search(event, '');
311 else if (this.dropdownMode === 'current')
312 this.search(event, queryValue);
313 this.onDropdownClick.emit({
314 originalEvent: event,
315 query: queryValue
316 });
317 }
318 else {
319 this.hide();
320 }
321 };
322 AutoComplete.prototype.focusInput = function () {
323 if (this.multiple)
324 this.multiInputEL.nativeElement.focus();
325 else
326 this.inputEL.nativeElement.focus();
327 };
328 AutoComplete.prototype.removeItem = function (item) {
329 var itemIndex = dom.DomHandler.index(item);
330 var removedValue = this.value[itemIndex];
331 this.value = this.value.filter(function (val, i) { return i != itemIndex; });
332 this.onModelChange(this.value);
333 this.updateFilledState();
334 this.onUnselect.emit(removedValue);
335 };
336 AutoComplete.prototype.onKeydown = function (event) {
337 if (this.overlayVisible) {
338 var highlightItemIndex = this.findOptionIndex(this.highlightOption);
339 switch (event.which) {
340 //down
341 case 40:
342 if (highlightItemIndex != -1) {
343 var nextItemIndex = highlightItemIndex + 1;
344 if (nextItemIndex != (this.suggestions.length)) {
345 this.highlightOption = this.suggestions[nextItemIndex];
346 this.highlightOptionChanged = true;
347 }
348 }
349 else {
350 this.highlightOption = this.suggestions[0];
351 }
352 event.preventDefault();
353 break;
354 //up
355 case 38:
356 if (highlightItemIndex > 0) {
357 var prevItemIndex = highlightItemIndex - 1;
358 this.highlightOption = this.suggestions[prevItemIndex];
359 this.highlightOptionChanged = true;
360 }
361 event.preventDefault();
362 break;
363 //enter
364 case 13:
365 if (this.highlightOption) {
366 this.selectItem(this.highlightOption);
367 this.hide();
368 }
369 event.preventDefault();
370 break;
371 //escape
372 case 27:
373 this.hide();
374 event.preventDefault();
375 break;
376 //tab
377 case 9:
378 if (this.highlightOption) {
379 this.selectItem(this.highlightOption);
380 }
381 this.hide();
382 break;
383 }
384 }
385 else {
386 if (event.which === 40 && this.suggestions) {
387 this.search(event, event.target.value);
388 }
389 }
390 if (this.multiple) {
391 switch (event.which) {
392 //backspace
393 case 8:
394 if (this.value && this.value.length && !this.multiInputEL.nativeElement.value) {
395 this.value = __spread(this.value);
396 var removedValue = this.value.pop();
397 this.onModelChange(this.value);
398 this.updateFilledState();
399 this.onUnselect.emit(removedValue);
400 }
401 break;
402 }
403 }
404 this.inputKeyDown = true;
405 };
406 AutoComplete.prototype.onKeyup = function (event) {
407 this.onKeyUp.emit(event);
408 };
409 AutoComplete.prototype.onInputFocus = function (event) {
410 if (!this.itemClicked && this.completeOnFocus) {
411 var queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
412 this.search(event, queryValue);
413 }
414 this.focus = true;
415 this.onFocus.emit(event);
416 this.itemClicked = false;
417 };
418 AutoComplete.prototype.onInputBlur = function (event) {
419 this.focus = false;
420 this.onModelTouched();
421 this.onBlur.emit(event);
422 };
423 AutoComplete.prototype.onInputChange = function (event) {
424 var e_1, _a;
425 var _this = this;
426 if (this.forceSelection) {
427 var valid = false;
428 var inputValue = event.target.value.trim();
429 if (this.suggestions) {
430 var _loop_1 = function (suggestion) {
431 var itemValue = this_1.field ? utils.ObjectUtils.resolveFieldData(suggestion, this_1.field) : suggestion;
432 if (itemValue && inputValue === itemValue.trim()) {
433 valid = true;
434 this_1.forceSelectionUpdateModelTimeout = setTimeout(function () {
435 _this.selectItem(suggestion, false);
436 }, 250);
437 return "break";
438 }
439 };
440 var this_1 = this;
441 try {
442 for (var _b = __values(this.suggestions), _c = _b.next(); !_c.done; _c = _b.next()) {
443 var suggestion = _c.value;
444 var state_1 = _loop_1(suggestion);
445 if (state_1 === "break")
446 break;
447 }
448 }
449 catch (e_1_1) { e_1 = { error: e_1_1 }; }
450 finally {
451 try {
452 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
453 }
454 finally { if (e_1) throw e_1.error; }
455 }
456 }
457 if (!valid) {
458 if (this.multiple) {
459 this.multiInputEL.nativeElement.value = '';
460 }
461 else {
462 this.value = null;
463 this.inputEL.nativeElement.value = '';
464 }
465 this.onClear.emit(event);
466 this.onModelChange(this.value);
467 }
468 }
469 };
470 AutoComplete.prototype.onInputPaste = function (event) {
471 this.onKeydown(event);
472 };
473 AutoComplete.prototype.isSelected = function (val) {
474 var selected = false;
475 if (this.value && this.value.length) {
476 for (var i = 0; i < this.value.length; i++) {
477 if (utils.ObjectUtils.equals(this.value[i], val, this.dataKey)) {
478 selected = true;
479 break;
480 }
481 }
482 }
483 return selected;
484 };
485 AutoComplete.prototype.findOptionIndex = function (option) {
486 var index = -1;
487 if (this.suggestions) {
488 for (var i = 0; i < this.suggestions.length; i++) {
489 if (utils.ObjectUtils.equals(option, this.suggestions[i])) {
490 index = i;
491 break;
492 }
493 }
494 }
495 return index;
496 };
497 AutoComplete.prototype.updateFilledState = function () {
498 if (this.multiple)
499 this.filled = (this.value && this.value.length) || (this.multiInputEL && this.multiInputEL.nativeElement && this.multiInputEL.nativeElement.value != '');
500 else
501 this.filled = (this.inputFieldValue && this.inputFieldValue != '') || (this.inputEL && this.inputEL.nativeElement && this.inputEL.nativeElement.value != '');
502 ;
503 };
504 AutoComplete.prototype.updateInputField = function () {
505 var formattedValue = this.value ? (this.field ? utils.ObjectUtils.resolveFieldData(this.value, this.field) || '' : this.value) : '';
506 this.inputFieldValue = formattedValue;
507 if (this.inputEL && this.inputEL.nativeElement) {
508 this.inputEL.nativeElement.value = formattedValue;
509 }
510 this.updateFilledState();
511 };
512 AutoComplete.prototype.bindDocumentClickListener = function () {
513 var _this = this;
514 if (!this.documentClickListener) {
515 this.documentClickListener = this.renderer.listen('document', 'click', function (event) {
516 if (event.which === 3) {
517 return;
518 }
519 if (!_this.inputClick && !_this.isDropdownClick(event)) {
520 _this.hide();
521 }
522 _this.inputClick = false;
523 _this.cd.markForCheck();
524 });
525 }
526 };
527 AutoComplete.prototype.isDropdownClick = function (event) {
528 if (this.dropdown) {
529 var target = event.target;
530 return (target === this.dropdownButton.nativeElement || target.parentNode === this.dropdownButton.nativeElement);
531 }
532 else {
533 return false;
534 }
535 };
536 AutoComplete.prototype.unbindDocumentClickListener = function () {
537 if (this.documentClickListener) {
538 this.documentClickListener();
539 this.documentClickListener = null;
540 }
541 };
542 AutoComplete.prototype.bindDocumentResizeListener = function () {
543 this.documentResizeListener = this.onWindowResize.bind(this);
544 window.addEventListener('resize', this.documentResizeListener);
545 };
546 AutoComplete.prototype.unbindDocumentResizeListener = function () {
547 if (this.documentResizeListener) {
548 window.removeEventListener('resize', this.documentResizeListener);
549 this.documentResizeListener = null;
550 }
551 };
552 AutoComplete.prototype.onWindowResize = function () {
553 this.hide();
554 };
555 AutoComplete.prototype.onOverlayHide = function () {
556 this.unbindDocumentClickListener();
557 this.unbindDocumentResizeListener();
558 this.overlay = null;
559 this.onHide.emit();
560 };
561 AutoComplete.prototype.ngOnDestroy = function () {
562 if (this.forceSelectionUpdateModelTimeout) {
563 clearTimeout(this.forceSelectionUpdateModelTimeout);
564 this.forceSelectionUpdateModelTimeout = null;
565 }
566 this.restoreOverlayAppend();
567 this.onOverlayHide();
568 };
569 AutoComplete.ctorParameters = function () { return [
570 { type: core.ElementRef },
571 { type: core.Renderer2 },
572 { type: core.ChangeDetectorRef },
573 { type: core.IterableDiffers }
574 ]; };
575 __decorate([
576 core.Input()
577 ], AutoComplete.prototype, "minLength", void 0);
578 __decorate([
579 core.Input()
580 ], AutoComplete.prototype, "delay", void 0);
581 __decorate([
582 core.Input()
583 ], AutoComplete.prototype, "style", void 0);
584 __decorate([
585 core.Input()
586 ], AutoComplete.prototype, "panelStyle", void 0);
587 __decorate([
588 core.Input()
589 ], AutoComplete.prototype, "styleClass", void 0);
590 __decorate([
591 core.Input()
592 ], AutoComplete.prototype, "panelStyleClass", void 0);
593 __decorate([
594 core.Input()
595 ], AutoComplete.prototype, "inputStyle", void 0);
596 __decorate([
597 core.Input()
598 ], AutoComplete.prototype, "inputId", void 0);
599 __decorate([
600 core.Input()
601 ], AutoComplete.prototype, "inputStyleClass", void 0);
602 __decorate([
603 core.Input()
604 ], AutoComplete.prototype, "placeholder", void 0);
605 __decorate([
606 core.Input()
607 ], AutoComplete.prototype, "readonly", void 0);
608 __decorate([
609 core.Input()
610 ], AutoComplete.prototype, "disabled", void 0);
611 __decorate([
612 core.Input()
613 ], AutoComplete.prototype, "maxlength", void 0);
614 __decorate([
615 core.Input()
616 ], AutoComplete.prototype, "name", void 0);
617 __decorate([
618 core.Input()
619 ], AutoComplete.prototype, "required", void 0);
620 __decorate([
621 core.Input()
622 ], AutoComplete.prototype, "size", void 0);
623 __decorate([
624 core.Input()
625 ], AutoComplete.prototype, "appendTo", void 0);
626 __decorate([
627 core.Input()
628 ], AutoComplete.prototype, "autoHighlight", void 0);
629 __decorate([
630 core.Input()
631 ], AutoComplete.prototype, "forceSelection", void 0);
632 __decorate([
633 core.Input()
634 ], AutoComplete.prototype, "type", void 0);
635 __decorate([
636 core.Input()
637 ], AutoComplete.prototype, "autoZIndex", void 0);
638 __decorate([
639 core.Input()
640 ], AutoComplete.prototype, "baseZIndex", void 0);
641 __decorate([
642 core.Input()
643 ], AutoComplete.prototype, "ariaLabel", void 0);
644 __decorate([
645 core.Input()
646 ], AutoComplete.prototype, "ariaLabelledBy", void 0);
647 __decorate([
648 core.Input()
649 ], AutoComplete.prototype, "dropdownIcon", void 0);
650 __decorate([
651 core.Input()
652 ], AutoComplete.prototype, "unique", void 0);
653 __decorate([
654 core.Input()
655 ], AutoComplete.prototype, "completeOnFocus", void 0);
656 __decorate([
657 core.Output()
658 ], AutoComplete.prototype, "completeMethod", void 0);
659 __decorate([
660 core.Output()
661 ], AutoComplete.prototype, "onSelect", void 0);
662 __decorate([
663 core.Output()
664 ], AutoComplete.prototype, "onUnselect", void 0);
665 __decorate([
666 core.Output()
667 ], AutoComplete.prototype, "onFocus", void 0);
668 __decorate([
669 core.Output()
670 ], AutoComplete.prototype, "onBlur", void 0);
671 __decorate([
672 core.Output()
673 ], AutoComplete.prototype, "onDropdownClick", void 0);
674 __decorate([
675 core.Output()
676 ], AutoComplete.prototype, "onClear", void 0);
677 __decorate([
678 core.Output()
679 ], AutoComplete.prototype, "onKeyUp", void 0);
680 __decorate([
681 core.Output()
682 ], AutoComplete.prototype, "onShow", void 0);
683 __decorate([
684 core.Output()
685 ], AutoComplete.prototype, "onHide", void 0);
686 __decorate([
687 core.Input()
688 ], AutoComplete.prototype, "field", void 0);
689 __decorate([
690 core.Input()
691 ], AutoComplete.prototype, "scrollHeight", void 0);
692 __decorate([
693 core.Input()
694 ], AutoComplete.prototype, "dropdown", void 0);
695 __decorate([
696 core.Input()
697 ], AutoComplete.prototype, "dropdownMode", void 0);
698 __decorate([
699 core.Input()
700 ], AutoComplete.prototype, "multiple", void 0);
701 __decorate([
702 core.Input()
703 ], AutoComplete.prototype, "tabindex", void 0);
704 __decorate([
705 core.Input()
706 ], AutoComplete.prototype, "dataKey", void 0);
707 __decorate([
708 core.Input()
709 ], AutoComplete.prototype, "emptyMessage", void 0);
710 __decorate([
711 core.Input()
712 ], AutoComplete.prototype, "showTransitionOptions", void 0);
713 __decorate([
714 core.Input()
715 ], AutoComplete.prototype, "hideTransitionOptions", void 0);
716 __decorate([
717 core.Input()
718 ], AutoComplete.prototype, "autofocus", void 0);
719 __decorate([
720 core.Input()
721 ], AutoComplete.prototype, "autocomplete", void 0);
722 __decorate([
723 core.ViewChild('in')
724 ], AutoComplete.prototype, "inputEL", void 0);
725 __decorate([
726 core.ViewChild('multiIn')
727 ], AutoComplete.prototype, "multiInputEL", void 0);
728 __decorate([
729 core.ViewChild('multiContainer')
730 ], AutoComplete.prototype, "multiContainerEL", void 0);
731 __decorate([
732 core.ViewChild('ddBtn')
733 ], AutoComplete.prototype, "dropdownButton", void 0);
734 __decorate([
735 core.ContentChildren(api.PrimeTemplate)
736 ], AutoComplete.prototype, "templates", void 0);
737 __decorate([
738 core.Input()
739 ], AutoComplete.prototype, "suggestions", null);
740 AutoComplete = __decorate([
741 core.Component({
742 selector: 'p-autoComplete',
743 template: "\n <span [ngClass]=\"{'ui-autocomplete ui-widget':true,'ui-autocomplete-dd':dropdown,'ui-autocomplete-multiple':multiple}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <input *ngIf=\"!multiple\" #in [attr.type]=\"type\" [attr.id]=\"inputId\" [ngStyle]=\"inputStyle\" [class]=\"inputStyleClass\" [autocomplete]=\"autocomplete\" [attr.required]=\"required\" [attr.name]=\"name\"\n [ngClass]=\"'ui-inputtext ui-widget ui-state-default ui-corner-all ui-autocomplete-input'\" [value]=\"inputFieldValue\" aria-autocomplete=\"list\" [attr.aria-controls]=\"listId\" role=\"searchbox\" [attr.aria-expanded]=\"overlayVisible\" aria-haspopup=\"true\" [attr.aria-activedescendant]=\"'p-highlighted-option'\"\n (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)\"\n [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\"\n ><ul *ngIf=\"multiple\" #multiContainer class=\"ui-autocomplete-multiple-container ui-widget ui-inputtext ui-state-default ui-corner-all\" [ngClass]=\"{'ui-state-disabled':disabled,'ui-state-focus':focus}\" (click)=\"multiIn.focus()\">\n <li #token *ngFor=\"let val of value\" class=\"ui-autocomplete-token ui-state-highlight ui-corner-all\">\n <span class=\"ui-autocomplete-token-icon pi pi-fw pi-times\" (click)=\"removeItem(token)\" *ngIf=\"!disabled\"></span>\n <span *ngIf=\"!selectedItemTemplate\" class=\"ui-autocomplete-token-label\">{{resolveFieldData(val)}}</span>\n <ng-container *ngTemplateOutlet=\"selectedItemTemplate; context: {$implicit: val}\"></ng-container>\n </li>\n <li class=\"ui-autocomplete-input-token\">\n <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)\"\n (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\"\n [ngStyle]=\"inputStyle\" [class]=\"inputStyleClass\" [attr.aria-label]=\"ariaLabel\" [attr.aria-labelledby]=\"ariaLabelledBy\" [attr.aria-required]=\"required\"\n aria-autocomplete=\"list\" [attr.aria-controls]=\"listId\" role=\"searchbox\" [attr.aria-expanded]=\"overlayVisible\" aria-haspopup=\"true\" [attr.aria-activedescendant]=\"'p-highlighted-option'\">\n </li>\n </ul>\n <i *ngIf=\"loading\" class=\"ui-autocomplete-loader pi pi-spinner pi-spin\"></i><button #ddBtn type=\"button\" pButton [icon]=\"dropdownIcon\" class=\"ui-autocomplete-dropdown\" [disabled]=\"disabled\"\n (click)=\"handleDropdownClick($event)\" *ngIf=\"dropdown\" [attr.tabindex]=\"tabindex\"></button>\n <div #panel *ngIf=\"overlayVisible\" [ngClass]=\"['ui-autocomplete-panel ui-widget ui-widget-content ui-corner-all ui-shadow']\" [style.max-height]=\"scrollHeight\" [ngStyle]=\"panelStyle\" [class]=\"panelStyleClass\"\n [@overlayAnimation]=\"{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\" (@overlayAnimation.start)=\"onOverlayAnimationStart($event)\" (@overlayAnimation.done)=\"onOverlayAnimationDone($event)\" >\n <ul role=\"listbox\" [attr.id]=\"listId\" class=\"ui-autocomplete-items ui-autocomplete-list ui-widget-content ui-widget ui-corner-all ui-helper-reset\">\n <li role=\"option\" *ngFor=\"let option of suggestions; let idx = index\" [ngClass]=\"{'ui-autocomplete-list-item ui-corner-all':true,'ui-state-highlight':(highlightOption==option)}\"\n (mouseenter)=\"highlightOption=option\" (mouseleave)=\"highlightOption=null\" [id]=\"highlightOption == option ? 'p-highlighted-option':''\" (click)=\"selectItem(option)\">\n <span *ngIf=\"!itemTemplate\">{{resolveFieldData(option)}}</span>\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: {$implicit: option, index: idx}\"></ng-container>\n </li>\n <li *ngIf=\"noResults && emptyMessage\" class=\"ui-autocomplete-emptymessage ui-autocomplete-list-item ui-corner-all\">{{emptyMessage}}</li>\n </ul>\n </div>\n </span>\n ",
744 animations: [
745 animations.trigger('overlayAnimation', [
746 animations.state('void', animations.style({
747 transform: 'translateY(5%)',
748 opacity: 0
749 })),
750 animations.state('visible', animations.style({
751 transform: 'translateY(0)',
752 opacity: 1
753 })),
754 animations.transition('void => visible', animations.animate('{{showTransitionParams}}')),
755 animations.transition('visible => void', animations.animate('{{hideTransitionParams}}'))
756 ])
757 ],
758 host: {
759 '[class.ui-inputwrapper-filled]': 'filled',
760 '[class.ui-inputwrapper-focus]': 'focus && !disabled'
761 },
762 providers: [AUTOCOMPLETE_VALUE_ACCESSOR],
763 changeDetection: core.ChangeDetectionStrategy.Default
764 })
765 ], AutoComplete);
766 return AutoComplete;
767 }());
768 var AutoCompleteModule = /** @class */ (function () {
769 function AutoCompleteModule() {
770 }
771 AutoCompleteModule = __decorate([
772 core.NgModule({
773 imports: [common.CommonModule, inputtext.InputTextModule, button.ButtonModule, api.SharedModule],
774 exports: [AutoComplete, api.SharedModule],
775 declarations: [AutoComplete]
776 })
777 ], AutoCompleteModule);
778 return AutoCompleteModule;
779 }());
780
781 exports.AUTOCOMPLETE_VALUE_ACCESSOR = AUTOCOMPLETE_VALUE_ACCESSOR;
782 exports.AutoComplete = AutoComplete;
783 exports.AutoCompleteModule = AutoCompleteModule;
784
785 Object.defineProperty(exports, '__esModule', { value: true });
786
787})));
788//# sourceMappingURL=primeng-autocomplete.umd.js.map