| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779 |
- "use strict";
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- 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;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- var __metadata = (this && this.__metadata) || function (k, v) {
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var core_1 = require("@angular/core");
- var common_1 = require("@angular/common");
- var animations_1 = require("@angular/animations");
- var inputtext_1 = require("../inputtext/inputtext");
- var button_1 = require("../button/button");
- var shared_1 = require("../common/shared");
- var domhandler_1 = require("../dom/domhandler");
- var objectutils_1 = require("../utils/objectutils");
- var forms_1 = require("@angular/forms");
- exports.AUTOCOMPLETE_VALUE_ACCESSOR = {
- provide: forms_1.NG_VALUE_ACCESSOR,
- useExisting: core_1.forwardRef(function () { return AutoComplete; }),
- multi: true
- };
- var AutoComplete = /** @class */ (function () {
- function AutoComplete(el, renderer, cd, differs) {
- this.el = el;
- this.renderer = renderer;
- this.cd = cd;
- this.differs = differs;
- this.minLength = 1;
- this.delay = 300;
- this.type = 'text';
- this.autoZIndex = true;
- this.baseZIndex = 0;
- this.dropdownIcon = "pi pi-caret-down";
- this.unique = true;
- this.completeMethod = new core_1.EventEmitter();
- this.onSelect = new core_1.EventEmitter();
- this.onUnselect = new core_1.EventEmitter();
- this.onFocus = new core_1.EventEmitter();
- this.onBlur = new core_1.EventEmitter();
- this.onDropdownClick = new core_1.EventEmitter();
- this.onClear = new core_1.EventEmitter();
- this.onKeyUp = new core_1.EventEmitter();
- this.scrollHeight = '200px';
- this.dropdownMode = 'blank';
- this.immutable = true;
- this.showTransitionOptions = '225ms ease-out';
- this.hideTransitionOptions = '195ms ease-in';
- this.autocomplete = 'off';
- this.onModelChange = function () { };
- this.onModelTouched = function () { };
- this.overlayVisible = false;
- this.focus = false;
- this.inputFieldValue = null;
- this.differ = differs.find([]).create(null);
- }
- Object.defineProperty(AutoComplete.prototype, "suggestions", {
- get: function () {
- return this._suggestions;
- },
- set: function (val) {
- this._suggestions = val;
- if (this.immutable) {
- this.handleSuggestionsChange();
- }
- },
- enumerable: true,
- configurable: true
- });
- AutoComplete.prototype.ngDoCheck = function () {
- if (!this.immutable) {
- var changes = this.differ.diff(this.suggestions);
- if (changes) {
- this.handleSuggestionsChange();
- }
- }
- };
- AutoComplete.prototype.ngAfterViewChecked = function () {
- var _this = this;
- //Use timeouts as since Angular 4.2, AfterViewChecked is broken and not called after panel is updated
- if (this.suggestionsUpdated && this.overlay && this.overlay.offsetParent) {
- setTimeout(function () {
- if (_this.overlay) {
- _this.alignOverlay();
- }
- }, 1);
- this.suggestionsUpdated = false;
- }
- if (this.highlightOptionChanged) {
- setTimeout(function () {
- if (_this.overlay) {
- var listItem = domhandler_1.DomHandler.findSingle(_this.overlay, 'li.ui-state-highlight');
- if (listItem) {
- domhandler_1.DomHandler.scrollInView(_this.overlay, listItem);
- }
- }
- }, 1);
- this.highlightOptionChanged = false;
- }
- };
- AutoComplete.prototype.handleSuggestionsChange = function () {
- if (this._suggestions != null && this.loading) {
- this.highlightOption = null;
- if (this._suggestions.length) {
- this.noResults = false;
- this.show();
- this.suggestionsUpdated = true;
- if (this.autoHighlight) {
- this.highlightOption = this._suggestions[0];
- }
- }
- else {
- this.noResults = true;
- if (this.emptyMessage) {
- this.show();
- this.suggestionsUpdated = true;
- }
- else {
- this.hide();
- }
- }
- this.loading = false;
- }
- };
- AutoComplete.prototype.ngAfterContentInit = function () {
- var _this = this;
- this.templates.forEach(function (item) {
- switch (item.getType()) {
- case 'item':
- _this.itemTemplate = item.template;
- break;
- case 'selectedItem':
- _this.selectedItemTemplate = item.template;
- break;
- default:
- _this.itemTemplate = item.template;
- break;
- }
- });
- };
- AutoComplete.prototype.writeValue = function (value) {
- this.value = value;
- this.filled = this.value && this.value != '';
- this.updateInputField();
- };
- AutoComplete.prototype.registerOnChange = function (fn) {
- this.onModelChange = fn;
- };
- AutoComplete.prototype.registerOnTouched = function (fn) {
- this.onModelTouched = fn;
- };
- AutoComplete.prototype.setDisabledState = function (val) {
- this.disabled = val;
- };
- AutoComplete.prototype.onInput = function (event) {
- var _this = this;
- // When an input element with a placeholder is clicked, the onInput event is invoked in IE.
- if (!this.inputKeyDown && domhandler_1.DomHandler.isIE()) {
- return;
- }
- if (this.timeout) {
- clearTimeout(this.timeout);
- }
- var value = event.target.value;
- if (!this.multiple && !this.forceSelection) {
- this.onModelChange(value);
- }
- if (value.length === 0 && !this.multiple) {
- this.hide();
- this.onClear.emit(event);
- this.onModelChange(value);
- }
- if (value.length >= this.minLength) {
- this.timeout = setTimeout(function () {
- _this.search(event, value);
- }, this.delay);
- }
- else {
- this.suggestions = null;
- this.hide();
- }
- this.updateFilledState();
- this.inputKeyDown = false;
- };
- AutoComplete.prototype.onInputClick = function (event) {
- if (this.documentClickListener) {
- this.inputClick = true;
- }
- };
- AutoComplete.prototype.search = function (event, query) {
- //allow empty string but not undefined or null
- if (query === undefined || query === null) {
- return;
- }
- this.loading = true;
- this.completeMethod.emit({
- originalEvent: event,
- query: query
- });
- };
- AutoComplete.prototype.selectItem = function (option, focus) {
- if (focus === void 0) { focus = true; }
- if (this.forceSelectionUpdateModelTimeout) {
- clearTimeout(this.forceSelectionUpdateModelTimeout);
- this.forceSelectionUpdateModelTimeout = null;
- }
- if (this.multiple) {
- this.multiInputEL.nativeElement.value = '';
- this.value = this.value || [];
- if (!this.isSelected(option) || !this.unique) {
- this.value = this.value.concat([option]);
- this.onModelChange(this.value);
- }
- }
- else {
- this.inputEL.nativeElement.value = this.field ? objectutils_1.ObjectUtils.resolveFieldData(option, this.field) || '' : option;
- this.value = option;
- this.onModelChange(this.value);
- }
- this.onSelect.emit(option);
- this.updateFilledState();
- if (focus) {
- this.focusInput();
- }
- };
- AutoComplete.prototype.show = function () {
- if (this.multiInputEL || this.inputEL) {
- var hasFocus = this.multiple ? document.activeElement == this.multiInputEL.nativeElement : document.activeElement == this.inputEL.nativeElement;
- if (!this.overlayVisible && hasFocus) {
- this.overlayVisible = true;
- }
- }
- };
- AutoComplete.prototype.onOverlayAnimationStart = function (event) {
- switch (event.toState) {
- case 'visible':
- this.overlay = event.element;
- this.appendOverlay();
- if (this.autoZIndex) {
- this.overlay.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
- }
- this.alignOverlay();
- this.bindDocumentClickListener();
- this.bindDocumentResizeListener();
- break;
- case 'void':
- this.onOverlayHide();
- break;
- }
- };
- AutoComplete.prototype.onOverlayAnimationDone = function (event) {
- if (event.toState === 'void') {
- this._suggestions = null;
- }
- };
- AutoComplete.prototype.appendOverlay = function () {
- if (this.appendTo) {
- if (this.appendTo === 'body')
- document.body.appendChild(this.overlay);
- else
- domhandler_1.DomHandler.appendChild(this.overlay, this.appendTo);
- this.overlay.style.minWidth = domhandler_1.DomHandler.getWidth(this.el.nativeElement.children[0]) + 'px';
- }
- };
- AutoComplete.prototype.resolveFieldData = function (value) {
- return this.field ? objectutils_1.ObjectUtils.resolveFieldData(value, this.field) : value;
- };
- AutoComplete.prototype.restoreOverlayAppend = function () {
- if (this.overlay && this.appendTo) {
- this.el.nativeElement.appendChild(this.overlay);
- }
- };
- AutoComplete.prototype.alignOverlay = function () {
- if (this.appendTo)
- domhandler_1.DomHandler.absolutePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
- else
- domhandler_1.DomHandler.relativePosition(this.overlay, (this.multiple ? this.multiContainerEL.nativeElement : this.inputEL.nativeElement));
- };
- AutoComplete.prototype.hide = function () {
- this.overlayVisible = false;
- };
- AutoComplete.prototype.handleDropdownClick = function (event) {
- this.focusInput();
- var queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
- if (this.dropdownMode === 'blank')
- this.search(event, '');
- else if (this.dropdownMode === 'current')
- this.search(event, queryValue);
- this.onDropdownClick.emit({
- originalEvent: event,
- query: queryValue
- });
- };
- AutoComplete.prototype.focusInput = function () {
- if (this.multiple)
- this.multiInputEL.nativeElement.focus();
- else
- this.inputEL.nativeElement.focus();
- };
- AutoComplete.prototype.removeItem = function (item) {
- var itemIndex = domhandler_1.DomHandler.index(item);
- var removedValue = this.value[itemIndex];
- this.value = this.value.filter(function (val, i) { return i != itemIndex; });
- this.onModelChange(this.value);
- this.updateFilledState();
- this.onUnselect.emit(removedValue);
- };
- AutoComplete.prototype.onKeydown = function (event) {
- if (this.overlayVisible) {
- var highlightItemIndex = this.findOptionIndex(this.highlightOption);
- switch (event.which) {
- //down
- case 40:
- if (highlightItemIndex != -1) {
- var nextItemIndex = highlightItemIndex + 1;
- if (nextItemIndex != (this.suggestions.length)) {
- this.highlightOption = this.suggestions[nextItemIndex];
- this.highlightOptionChanged = true;
- }
- }
- else {
- this.highlightOption = this.suggestions[0];
- }
- event.preventDefault();
- break;
- //up
- case 38:
- if (highlightItemIndex > 0) {
- var prevItemIndex = highlightItemIndex - 1;
- this.highlightOption = this.suggestions[prevItemIndex];
- this.highlightOptionChanged = true;
- }
- event.preventDefault();
- break;
- //enter
- case 13:
- if (this.highlightOption) {
- this.selectItem(this.highlightOption);
- this.hide();
- }
- event.preventDefault();
- break;
- //escape
- case 27:
- this.hide();
- event.preventDefault();
- break;
- //tab
- case 9:
- if (this.highlightOption) {
- this.selectItem(this.highlightOption);
- }
- this.hide();
- break;
- }
- }
- else {
- if (event.which === 40 && this.suggestions) {
- this.search(event, event.target.value);
- }
- }
- if (this.multiple) {
- switch (event.which) {
- //backspace
- case 8:
- if (this.value && this.value.length && !this.multiInputEL.nativeElement.value) {
- this.value = this.value.slice();
- var removedValue = this.value.pop();
- this.onModelChange(this.value);
- this.updateFilledState();
- this.onUnselect.emit(removedValue);
- }
- break;
- }
- }
- this.inputKeyDown = true;
- };
- AutoComplete.prototype.onKeyup = function (event) {
- this.onKeyUp.emit(event);
- };
- AutoComplete.prototype.onInputFocus = function (event) {
- this.focus = true;
- this.onFocus.emit(event);
- };
- AutoComplete.prototype.onInputBlur = function (event) {
- this.focus = false;
- this.onModelTouched();
- this.onBlur.emit(event);
- };
- AutoComplete.prototype.onInputChange = function (event) {
- var _this = this;
- if (this.forceSelection && this.suggestions) {
- var valid = false;
- var inputValue = event.target.value.trim();
- if (this.suggestions) {
- var _loop_1 = function (suggestion) {
- var itemValue = this_1.field ? objectutils_1.ObjectUtils.resolveFieldData(suggestion, this_1.field) : suggestion;
- if (itemValue && inputValue === itemValue.trim()) {
- valid = true;
- this_1.forceSelectionUpdateModelTimeout = setTimeout(function () {
- _this.selectItem(suggestion, false);
- }, 250);
- return "break";
- }
- };
- var this_1 = this;
- for (var _i = 0, _a = this.suggestions; _i < _a.length; _i++) {
- var suggestion = _a[_i];
- var state_1 = _loop_1(suggestion);
- if (state_1 === "break")
- break;
- }
- }
- if (!valid) {
- if (this.multiple) {
- this.multiInputEL.nativeElement.value = '';
- }
- else {
- this.value = null;
- this.inputEL.nativeElement.value = '';
- }
- this.onClear.emit(event);
- this.onModelChange(this.value);
- }
- }
- };
- AutoComplete.prototype.onInputPaste = function (event) {
- this.onKeydown(event);
- };
- AutoComplete.prototype.isSelected = function (val) {
- var selected = false;
- if (this.value && this.value.length) {
- for (var i = 0; i < this.value.length; i++) {
- if (objectutils_1.ObjectUtils.equals(this.value[i], val, this.dataKey)) {
- selected = true;
- break;
- }
- }
- }
- return selected;
- };
- AutoComplete.prototype.findOptionIndex = function (option) {
- var index = -1;
- if (this.suggestions) {
- for (var i = 0; i < this.suggestions.length; i++) {
- if (objectutils_1.ObjectUtils.equals(option, this.suggestions[i])) {
- index = i;
- break;
- }
- }
- }
- return index;
- };
- AutoComplete.prototype.updateFilledState = function () {
- if (this.multiple)
- this.filled = (this.value && this.value.length) || (this.multiInputEL && this.multiInputEL.nativeElement && this.multiInputEL.nativeElement.value != '');
- else
- this.filled = (this.inputFieldValue && this.inputFieldValue != '') || (this.inputEL && this.inputEL.nativeElement && this.inputEL.nativeElement.value != '');
- ;
- };
- AutoComplete.prototype.updateInputField = function () {
- var formattedValue = this.value ? (this.field ? objectutils_1.ObjectUtils.resolveFieldData(this.value, this.field) || '' : this.value) : '';
- this.inputFieldValue = formattedValue;
- if (this.inputEL && this.inputEL.nativeElement) {
- this.inputEL.nativeElement.value = formattedValue;
- }
- this.updateFilledState();
- };
- AutoComplete.prototype.bindDocumentClickListener = function () {
- var _this = this;
- if (!this.documentClickListener) {
- this.documentClickListener = this.renderer.listen('document', 'click', function (event) {
- if (event.which === 3) {
- return;
- }
- if (!_this.inputClick && !_this.isDropdownClick(event)) {
- _this.hide();
- }
- _this.inputClick = false;
- _this.cd.markForCheck();
- });
- }
- };
- AutoComplete.prototype.isDropdownClick = function (event) {
- if (this.dropdown) {
- var target = event.target;
- return (target === this.dropdownButton.nativeElement || target.parentNode === this.dropdownButton.nativeElement);
- }
- else {
- return false;
- }
- };
- AutoComplete.prototype.unbindDocumentClickListener = function () {
- if (this.documentClickListener) {
- this.documentClickListener();
- this.documentClickListener = null;
- }
- };
- AutoComplete.prototype.bindDocumentResizeListener = function () {
- this.documentResizeListener = this.onWindowResize.bind(this);
- window.addEventListener('resize', this.documentResizeListener);
- };
- AutoComplete.prototype.unbindDocumentResizeListener = function () {
- if (this.documentResizeListener) {
- window.removeEventListener('resize', this.documentResizeListener);
- this.documentResizeListener = null;
- }
- };
- AutoComplete.prototype.onWindowResize = function () {
- this.hide();
- };
- AutoComplete.prototype.onOverlayHide = function () {
- this.unbindDocumentClickListener();
- this.unbindDocumentResizeListener();
- this.overlay = null;
- };
- AutoComplete.prototype.ngOnDestroy = function () {
- this.restoreOverlayAppend();
- this.onOverlayHide();
- };
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "minLength", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "delay", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], AutoComplete.prototype, "style", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], AutoComplete.prototype, "panelStyle", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "styleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "panelStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], AutoComplete.prototype, "inputStyle", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "inputId", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "inputStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "placeholder", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "readonly", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "disabled", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "maxlength", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "name", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "required", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "size", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], AutoComplete.prototype, "appendTo", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "autoHighlight", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "forceSelection", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "type", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "autoZIndex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "baseZIndex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "ariaLabel", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "ariaLabelledBy", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "dropdownIcon", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "unique", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "completeMethod", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onSelect", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onUnselect", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onFocus", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onBlur", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onDropdownClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onClear", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], AutoComplete.prototype, "onKeyUp", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "field", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "scrollHeight", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "dropdown", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "dropdownMode", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "multiple", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], AutoComplete.prototype, "tabindex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "dataKey", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "emptyMessage", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "immutable", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "showTransitionOptions", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "hideTransitionOptions", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], AutoComplete.prototype, "autofocus", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], AutoComplete.prototype, "autocomplete", void 0);
- __decorate([
- core_1.ViewChild('in', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], AutoComplete.prototype, "inputEL", void 0);
- __decorate([
- core_1.ViewChild('multiIn', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], AutoComplete.prototype, "multiInputEL", void 0);
- __decorate([
- core_1.ViewChild('multiContainer', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], AutoComplete.prototype, "multiContainerEL", void 0);
- __decorate([
- core_1.ViewChild('ddBtn', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], AutoComplete.prototype, "dropdownButton", void 0);
- __decorate([
- core_1.ContentChildren(shared_1.PrimeTemplate),
- __metadata("design:type", core_1.QueryList)
- ], AutoComplete.prototype, "templates", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Array),
- __metadata("design:paramtypes", [Array])
- ], AutoComplete.prototype, "suggestions", null);
- AutoComplete = __decorate([
- core_1.Component({
- selector: 'p-autoComplete',
- 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\" role=\"combobox\" [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\" role=\"combobox\" [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\" 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 ",
- animations: [
- animations_1.trigger('overlayAnimation', [
- animations_1.state('void', animations_1.style({
- transform: 'translateY(5%)',
- opacity: 0
- })),
- animations_1.state('visible', animations_1.style({
- transform: 'translateY(0)',
- opacity: 1
- })),
- animations_1.transition('void => visible', animations_1.animate('{{showTransitionParams}}')),
- animations_1.transition('visible => void', animations_1.animate('{{hideTransitionParams}}'))
- ])
- ],
- host: {
- '[class.ui-inputwrapper-filled]': 'filled',
- '[class.ui-inputwrapper-focus]': 'focus && !disabled'
- },
- providers: [exports.AUTOCOMPLETE_VALUE_ACCESSOR]
- }),
- __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, core_1.ChangeDetectorRef, core_1.IterableDiffers])
- ], AutoComplete);
- return AutoComplete;
- }());
- exports.AutoComplete = AutoComplete;
- var AutoCompleteModule = /** @class */ (function () {
- function AutoCompleteModule() {
- }
- AutoCompleteModule = __decorate([
- core_1.NgModule({
- imports: [common_1.CommonModule, inputtext_1.InputTextModule, button_1.ButtonModule, shared_1.SharedModule],
- exports: [AutoComplete, shared_1.SharedModule],
- declarations: [AutoComplete]
- })
- ], AutoCompleteModule);
- return AutoCompleteModule;
- }());
- exports.AutoCompleteModule = AutoCompleteModule;
- //# sourceMappingURL=autocomplete.js.map
|