@neocomplexx/ngx-neo-completer
Version:
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.5.
16 lines (14 loc) • 38.4 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@angular/common/http"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@neocomplexx/ngx-neo-completer",["exports","@angular/core","@angular/common","@angular/forms","@angular/common/http","rxjs","rxjs/operators"],e):e(((t=t||self).neocomplexx=t.neocomplexx||{},t.neocomplexx["ngx-neo-completer"]={}),t.ng.core,t.ng.common,t.ng.forms,t.ng.common.http,t.rxjs,t.rxjs.operators)}(this,(function(t,e,i,n,r,o,s){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function p(t,e){function i(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function l(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}function h(t,e){return function(i,n){e(i,n,t)}}function a(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],n=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var d=function(){function t(){this.selected=new e.EventEmitter,this.highlighted=new e.EventEmitter,this.opened=new e.EventEmitter,this.dataSourceChange=new e.EventEmitter,this._hasHighlighted=!1,this._hasSelected=!1,this._cancelBlur=!1,this._isOpen=!1}return t.prototype.registerList=function(t){this.list=t},t.prototype.registerDropdown=function(t){this.dropdown=t},t.prototype.onHighlighted=function(t){this.highlighted.emit(t),this._hasHighlighted=!!t},t.prototype.onSelected=function(t,e){void 0===e&&(e=!0),this.selected.emit(t),t&&(this._hasSelected=!0),e&&this.clear()},t.prototype.onDataSourceChange=function(){this.hasSelected&&(this.selected.emit(null),this._hasSelected=!1),this.dataSourceChange.emit()},t.prototype.search=function(t){this._hasSelected&&(this.selected.emit(null),this._hasSelected=!1),this.list&&this.list.search(t)},t.prototype.clear=function(){this._hasHighlighted=!1,this.isOpen=!1,this.dropdown&&this.dropdown.clear(),this.list&&this.list.clear()},t.prototype.selectCurrent=function(){this.dropdown&&this.dropdown.selectCurrent()},t.prototype.nextRow=function(){this.dropdown&&this.dropdown.nextRow()},t.prototype.prevRow=function(){this.dropdown&&this.dropdown.prevRow()},t.prototype.hasHighlighted=function(){return this._hasHighlighted},t.prototype.cancelBlur=function(t){this._cancelBlur=t},t.prototype.isCancelBlur=function(){return this._cancelBlur},t.prototype.open=function(){this._isOpen||(this.isOpen=!0,this.list.open())},Object.defineProperty(t.prototype,"isOpen",{get:function(){return this._isOpen},set:function(t){this._isOpen=t,this.opened.emit(this._isOpen),this.list&&this.list.isOpen(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoHighlightIndex",{get:function(){return this._autoHighlightIndex},set:function(t){this._autoHighlightIndex=t,this.dropdown&&this.dropdown.highlightRow(this._autoHighlightIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasSelected",{get:function(){return this._hasSelected},enumerable:!0,configurable:!0}),l([e.Output(),a("design:type",Object)],t.prototype,"selected",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"highlighted",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"opened",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"dataSourceChange",void 0),t=l([e.Directive({selector:"[ctrCompleter]"})],t)}(),g=function(){function t(){this.parts=[]}return t.prototype.ngOnInit=function(){if(this.searchStr){for(var t=this.text.toLowerCase(),e=t.indexOf(this.searchStr.toLowerCase()),i=0;e>=0;){var n=this.text.slice(e,e+this.searchStr.length);if(0===e)this.parts.push({isMatch:!0,text:n}),i+=this.searchStr.length;else if(e>0){var r=this.text.slice(i,e);this.parts.push({isMatch:!1,text:r}),this.parts.push({isMatch:!0,text:n}),i+=this.searchStr.length+r.length}e=t.indexOf(this.searchStr.toLowerCase(),i)}i<this.text.length&&this.parts.push({isMatch:!1,text:this.text.slice(i,this.text.length)})}else this.parts.push({isMatch:!1,text:this.text})},l([e.Input(),a("design:type",String)],t.prototype,"text",void 0),l([e.Input(),a("design:type",String)],t.prototype,"searchStr",void 0),l([e.Input(),a("design:type",String)],t.prototype,"matchClass",void 0),l([e.Input(),a("design:type",String)],t.prototype,"type",void 0),t=l([e.Component({selector:"completer-list-item",template:'<span class="completer-list-item-holder" [ngClass]="{\'completer-title\': type === \'title\', \'completer-description\': type === \'description\'}" >\n <span class="completer-list-item" *ngFor="let part of parts" [ngClass]="part.isMatch ? matchClass : null">{{part.text}}</span>\n </span>'})],t)}();function m(t){return null==t}var y=function(t,e){this.row=t,this.index=e},f=function(){function t(t,e){this.completer=t,this.el=e,this.rows=[],this._rowMouseDown=!1,this.completer.registerDropdown(this)}return t.prototype.ngOnDestroy=function(){this.completer.registerDropdown(null)},t.prototype.ngAfterViewInit=function(){var t=this,e=getComputedStyle(this.el.nativeElement),i=this.completer.autoHighlightIndex;this.isScrollOn=!!e.maxHeight&&"auto"===e.overflowY,i&&setTimeout((function(){t.highlightRow(i)}),0)},t.prototype.onMouseDown=function(t){var e=this;this._rowMouseDown?this._rowMouseDown=!1:(this.completer.cancelBlur(!0),setTimeout((function(){e.completer.cancelBlur(!1)}),0))},t.prototype.registerRow=function(t){var e=this.rows.findIndex((function(e){return e.index===t.index}));e>=0?this.rows[e]=t:this.rows.push(t)},t.prototype.unregisterRow=function(t){var e=this.rows.findIndex((function(e){return e.index===t}));this.rows.splice(e,1),this.currHighlighted&&t===this.currHighlighted.index&&this.highlightRow(null)},t.prototype.highlightRow=function(t){var e=this.rows.find((function(e){return e.index===t}));if(m(t)||t<0)return this.currHighlighted&&this.currHighlighted.row.setHighlighted(!1),this.currHighlighted=void 0,void this.completer.onHighlighted(null);if(e&&(this.currHighlighted&&this.currHighlighted.row.setHighlighted(!1),this.currHighlighted=e,this.currHighlighted.row.setHighlighted(!0),this.completer.onHighlighted(this.currHighlighted.row.getDataItem()),this.isScrollOn&&this.currHighlighted)){var i=this.dropdownRowTop();if(!i)return;if(i<0)this.dropdownScrollTopTo(i-1);else{var n=this.currHighlighted.row.getNativeElement();this.dropdownHeight()<n.getBoundingClientRect().bottom&&(this.dropdownScrollTopTo(this.dropdownRowOffsetHeight(n)),this.el.nativeElement.getBoundingClientRect().bottom-this.dropdownRowOffsetHeight(n)<n.getBoundingClientRect().top&&this.dropdownScrollTopTo(n.getBoundingClientRect().top-(this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).paddingTop,10))))}}},t.prototype.clear=function(){this.rows=[]},t.prototype.onSelected=function(t){this.completer.onSelected(t)},t.prototype.rowMouseDown=function(){this._rowMouseDown=!0},t.prototype.selectCurrent=function(){this.currHighlighted?this.onSelected(this.currHighlighted.row.getDataItem()):this.rows.length>0&&this.onSelected(this.rows[0].row.getDataItem())},t.prototype.nextRow=function(){var t=0;this.currHighlighted&&(t=this.currHighlighted.index+1),this.highlightRow(t)},t.prototype.prevRow=function(){var t=-1;this.currHighlighted&&(t=this.currHighlighted.index-1),this.highlightRow(t)},t.prototype.dropdownScrollTopTo=function(t){this.el.nativeElement.scrollTop=this.el.nativeElement.scrollTop+t},t.prototype.dropdownRowTop=function(){if(this.currHighlighted)return this.currHighlighted.row.getNativeElement().getBoundingClientRect().top-(this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).paddingTop,10))},t.prototype.dropdownHeight=function(){return this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).maxHeight,10)},t.prototype.dropdownRowOffsetHeight=function(t){var e=getComputedStyle(t.parentElement);return t.parentElement.offsetHeight+parseInt(e.marginTop,10)+parseInt(e.marginBottom,10)},t.ctorParameters=function(){return[{type:d,decorators:[{type:e.Host}]},{type:e.ElementRef}]},l([e.HostListener("mousedown",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onMouseDown",null),t=l([e.Directive({selector:"[ctrDropdown]"}),h(0,e.Host()),a("design:paramtypes",[d,e.ElementRef])],t)}(),v=function(){function t(t,i,n){var r=this;this.completer=t,this.ngModel=i,this.el=n,this.clearSelected=!1,this.clearUnselected=!1,this.overrideSuggested=!1,this.fillHighlighted=!0,this.openOnFocus=!1,this.openOnClick=!1,this.selectOnClick=!1,this.selectOnFocus=!1,this.autoSelectOnEnter=!0,this.ngModelChange=new e.EventEmitter,this._searchStr="",this._displayStr="",this.blurTimer=null,this.completer.selected.subscribe((function(t){t&&(r.clearSelected?r.searchStr="":r.searchStr=t.title,r.ngModelChange.emit(r.searchStr))})),this.completer.highlighted.subscribe((function(t){r.fillHighlighted&&(t?(r._displayStr=t.title,r.ngModelChange.emit(t.title)):(r._displayStr=r.searchStr,r.ngModelChange.emit(r.searchStr)))})),this.completer.dataSourceChange.subscribe((function(){r.completer.search(r.searchStr)})),this.ngModel.valueChanges&&this.ngModel.valueChanges.subscribe((function(t){m(t)||r._displayStr===t||(r.searchStr!==t&&r.completer.search(t),r.searchStr=t)}))}return t.prototype.keyupHandler=function(t){37!==t.keyCode&&39!==t.keyCode&&9!==t.keyCode&&(38===t.keyCode||13===t.keyCode?t.preventDefault():40===t.keyCode?(t.preventDefault(),this.completer.search(this.searchStr)):27===t.keyCode&&this.completer.isOpen&&(this.restoreSearchValue(),this.completer.clear(),t.stopPropagation(),t.preventDefault()))},t.prototype.pasteHandler=function(t){this.completer.open()},t.prototype.keydownHandler=function(t){var e=t.keyCode||t.which;13===e?(this.completer.hasHighlighted()?t.preventDefault():this.autoSelectOnEnter&&(t.preventDefault(),this.completer.open(),this.completer.nextRow()),this.handleSelection()):40===e?(t.preventDefault(),this.completer.open(),this.completer.nextRow()):38===e?(t.preventDefault(),this.completer.prevRow()):9===e?this.handleSelection():8===e?this.completer.open():27===e?(t.preventDefault(),this.completer.isOpen&&t.stopPropagation()):0===e||16===e||20===e||!(e<=112||e>=123)||t.ctrlKey||t.metaKey||t.altKey||this.completer.open()},t.prototype.onBlur=function(t){var e=this;this.completer.isCancelBlur()?setTimeout((function(){e.el.nativeElement.focus()}),0):this.completer.isOpen&&(this.blurTimer=o.timer(200).pipe(s.take(1)).subscribe((function(){return e.doBlur()})))},t.prototype.onfocus=function(){this.blurTimer&&(this.blurTimer.unsubscribe(),this.blurTimer=null),this.selectOnFocus&&this.el.nativeElement.select(),this.openOnFocus&&this.completer.open()},t.prototype.onClick=function(t){this.selectOnClick&&this.el.nativeElement.select(),this.openOnClick&&(this.completer.isOpen?this.completer.clear():this.completer.open())},Object.defineProperty(t.prototype,"searchStr",{get:function(){return this._searchStr},set:function(t){this._searchStr=t,this._displayStr=t},enumerable:!0,configurable:!0}),t.prototype.handleSelection=function(){this.completer.hasHighlighted()?(this._searchStr="",this.completer.selectCurrent()):this.overrideSuggested?this.completer.onSelected({title:this.searchStr,originalObject:null}):(this.clearUnselected&&!this.completer.hasSelected&&(this.searchStr="",this.ngModelChange.emit(this.searchStr)),this.completer.clear())},t.prototype.restoreSearchValue=function(){this.fillHighlighted&&this._displayStr!==this.searchStr&&(this._displayStr=this.searchStr,this.ngModelChange.emit(this.searchStr))},t.prototype.doBlur=function(){this.blurTimer&&(this.blurTimer.unsubscribe(),this.blurTimer=null),this.overrideSuggested?this.completer.onSelected({title:this.searchStr,originalObject:null}):this.clearUnselected&&!this.completer.hasSelected?(this.searchStr="",this.ngModelChange.emit(this.searchStr)):this.restoreSearchValue(),this.completer.clear()},t.ctorParameters=function(){return[{type:d,decorators:[{type:e.Host}]},{type:n.NgModel},{type:e.ElementRef}]},l([e.Input("clearSelected"),a("design:type",Object)],t.prototype,"clearSelected",void 0),l([e.Input("clearUnselected"),a("design:type",Object)],t.prototype,"clearUnselected",void 0),l([e.Input("overrideSuggested"),a("design:type",Object)],t.prototype,"overrideSuggested",void 0),l([e.Input("fillHighlighted"),a("design:type",Object)],t.prototype,"fillHighlighted",void 0),l([e.Input("openOnFocus"),a("design:type",Object)],t.prototype,"openOnFocus",void 0),l([e.Input("openOnClick"),a("design:type",Object)],t.prototype,"openOnClick",void 0),l([e.Input("selectOnClick"),a("design:type",Object)],t.prototype,"selectOnClick",void 0),l([e.Input("selectOnFocus"),a("design:type",Object)],t.prototype,"selectOnFocus",void 0),l([e.Input("autoSelectOnEnter"),a("design:type",Object)],t.prototype,"autoSelectOnEnter",void 0),l([e.Output(),a("design:type",e.EventEmitter)],t.prototype,"ngModelChange",void 0),l([e.HostListener("keyup",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"keyupHandler",null),l([e.HostListener("paste",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"pasteHandler",null),l([e.HostListener("keydown",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"keydownHandler",null),l([e.HostListener("blur",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onBlur",null),l([e.HostListener("focus",[]),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",void 0)],t.prototype,"onfocus",null),l([e.HostListener("click",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onClick",null),t=l([e.Directive({selector:"[ctrInput]"}),h(0,e.Host()),a("design:paramtypes",[d,n.NgModel,e.ElementRef])],t)}(),b=function(t,e,i,n){this.results=t,this.searching=e,this.searchInitialized=i,this.isOpen=n},S=function(){function t(t,e,i,n){this.completer=t,this.templateRef=e,this.viewContainer=i,this.cd=n,this.ctrListMinSearchLength=3,this.ctrListPause=10,this.ctrListAutoMatch=!1,this.ctrListAutoHighlight=!1,this.ctrListDisplaySearching=!0,this.term=null,this.searchTimer=null,this.clearTimer=null,this.ctx=new b([],!1,!1,!1),this._initialValue=null,this.viewRef=null}return t.prototype.ngOnInit=function(){this.completer.registerList(this),this.viewRef=this.viewContainer.createEmbeddedView(this.templateRef,new b([],!1,!1,!1))},Object.defineProperty(t.prototype,"dataService",{set:function(t){this._dataService=t,this.dataServiceSubscribe()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"initialValue",{set:function(t){var e=this;this._dataService&&"function"==typeof this._dataService.convertToItem?setTimeout((function(){var i=e._dataService.convertToItem(t);i&&e.completer.onSelected(i,!1)})):this._dataService||(this._initialValue=t)},enumerable:!0,configurable:!0}),t.prototype.search=function(t){var e=this;!m(t)&&t.length>=this.ctrListMinSearchLength&&this.term!==t?(this.searchTimer&&(this.searchTimer.unsubscribe(),this.searchTimer=null),this.ctx.searching||(this.ctrListDisplaySearching&&(this.ctx.results=[]),this.ctx.searching=!0,this.ctx.searchInitialized=!0,this.refreshTemplate()),this.clearTimer&&this.clearTimer.unsubscribe(),this.searchTimer=o.timer(this.ctrListPause).pipe(s.take(1)).subscribe((function(){e.searchTimerComplete(t)}))):!m(t)&&t.length<this.ctrListMinSearchLength&&(this.clear(),this.term="")},t.prototype.clear=function(){var t=this;this.searchTimer&&this.searchTimer.unsubscribe(),this.clearTimer=o.timer(50).pipe(s.take(1)).subscribe((function(){t._clear()}))},t.prototype.open=function(){this.ctx.searchInitialized||this.search(""),this.refreshTemplate()},t.prototype.isOpen=function(t){this.ctx.isOpen=t},t.prototype._clear=function(){this.searchTimer&&(this.searchTimer.unsubscribe(),this.searchTimer=null),this.dataService&&this.dataService.cancel(),this.viewContainer.clear(),this.viewRef=null},t.prototype.searchTimerComplete=function(t){m(t)||t.length<this.ctrListMinSearchLength?this.ctx.searching=!1:(this.term=t,this._dataService.search(t))},t.prototype.refreshTemplate=function(){this.viewRef?this.viewRef.destroyed||(this.viewRef.context.isOpen=this.ctx.isOpen,this.viewRef.context.results=this.ctx.results,this.viewRef.context.searching=this.ctx.searching,this.viewRef.context.searchInitialized=this.ctx.searchInitialized,this.viewRef.detectChanges()):this.viewRef=this.viewContainer.createEmbeddedView(this.templateRef,this.ctx),this.cd.markForCheck()},t.prototype.getBestMatchIndex=function(){var t=this;if(!this.ctx.results||!this.term)return null;var e=this.ctx.results.findIndex((function(e){return e.title.toLowerCase()===t.term.toLocaleLowerCase()}));return e<0&&(e=this.ctx.results.findIndex((function(e){return e.title.toLowerCase().startsWith(t.term.toLocaleLowerCase())}))),e<0&&(e=this.ctx.results.findIndex((function(e){return e.title.toLowerCase().includes(t.term.toLocaleLowerCase())}))),e<0?null:e},t.prototype.dataServiceSubscribe=function(){var t=this;this._dataService&&(this._dataService.pipe(s.catchError((function(t){return console.error(t),console.error("Unexpected error in dataService: errors should be handled by the dataService Observable"),[]}))).subscribe((function(e){t.ctx.searchInitialized=!0,t.ctx.searching=!1,t.ctx.results=e,t.ctrListAutoMatch&&e&&1===e.length&&e[0].title&&!m(t.term)&&e[0].title.toLocaleLowerCase()===t.term.toLocaleLowerCase()?t.completer.onSelected(e[0]):(t._initialValue&&(t.initialValue=t._initialValue,t._initialValue=null),t.refreshTemplate(),t.ctrListAutoHighlight&&(t.completer.autoHighlightIndex=t.getBestMatchIndex()))})),this._dataService.dataSourceChange&&this._dataService.dataSourceChange.subscribe((function(){t.term=null,t.ctx.searchInitialized=!1,t.ctx.searching=!1,t.ctx.results=[],t.refreshTemplate(),t.completer.onDataSourceChange()})))},t.ctorParameters=function(){return[{type:d,decorators:[{type:e.Host}]},{type:e.TemplateRef},{type:e.ViewContainerRef},{type:e.ChangeDetectorRef}]},l([e.Input(),a("design:type",Object)],t.prototype,"ctrListMinSearchLength",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"ctrListPause",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"ctrListAutoMatch",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"ctrListAutoHighlight",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"ctrListDisplaySearching",void 0),l([e.Input("ctrList"),a("design:type",Object),a("design:paramtypes",[Object])],t.prototype,"dataService",null),l([e.Input("ctrListInitialValue"),a("design:type",Object),a("design:paramtypes",[Object])],t.prototype,"initialValue",null),t=l([e.Directive({selector:"[ctrList]"}),h(0,e.Host()),a("design:paramtypes",[d,e.TemplateRef,e.ViewContainerRef,e.ChangeDetectorRef])],t)}(),w=function(){function t(t,e,i){this.el=t,this.renderer=e,this.dropdown=i,this.selected=!1}return t.prototype.ngOnDestroy=function(){this._rowIndex&&this.dropdown.unregisterRow(this._rowIndex)},Object.defineProperty(t.prototype,"ctrRow",{set:function(t){this._rowIndex=t,this.dropdown.registerRow(new y(this,this._rowIndex))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataItem",{set:function(t){this._item=t},enumerable:!0,configurable:!0}),t.prototype.onClick=function(t){this.dropdown.onSelected(this._item)},t.prototype.onMouseEnter=function(t){this.dropdown.highlightRow(this._rowIndex)},t.prototype.onMouseDown=function(t){this.dropdown.rowMouseDown()},t.prototype.setHighlighted=function(t){this.selected=t;this.selected?this.renderer.addClass(this.el.nativeElement,"completer-selected-row"):this.renderer.removeClass(this.el.nativeElement,"completer-selected-row")},t.prototype.getNativeElement=function(){return this.el.nativeElement},t.prototype.getDataItem=function(){return this._item},t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.Renderer2},{type:f,decorators:[{type:e.Host}]}]},l([e.Input(),a("design:type",Number),a("design:paramtypes",[Number])],t.prototype,"ctrRow",null),l([e.Input(),a("design:type",Object),a("design:paramtypes",[Object])],t.prototype,"dataItem",null),l([e.HostListener("click",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onClick",null),l([e.HostListener("mouseenter",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onMouseEnter",null),l([e.HostListener("mousedown",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"onMouseDown",null),t=l([e.Directive({selector:"[ctrRow]"}),h(2,e.Host()),a("design:paramtypes",[e.ElementRef,e.Renderer2,f])],t)}(),O=function(t){function e(){return t.call(this)||this}return p(e,t),e.prototype.cancel=function(){},e.prototype.searchFields=function(t){return this._searchFields=t,this},e.prototype.titleField=function(t){return this._titleField=t,this},e.prototype.descriptionField=function(t){return this._descriptionField=t,this},e.prototype.imageField=function(t){return this._imageField=t,this},e.prototype.convertToItem=function(t){var e,i=null,n=null;return"string"!=typeof(e=this._titleField?this.extractTitle(t):t)&&(e=JSON.stringify(e)),this._descriptionField&&(n=this.extractValue(t,this._descriptionField)),this._imageField&&(i=this.extractValue(t,this._imageField)),m(e)?null:{description:n,image:i,originalObject:t,title:e}},e.prototype.extractMatches=function(t,e){var i=this,n=this._searchFields?this._searchFields.split(","):null;return null!==this._searchFields&&void 0!==this._searchFields&&""!==e?t.filter((function(t){return(n?i.extractBySearchFields(n,t):[t]).some((function(t){return t.toString().toLowerCase().indexOf(e.toString().toLowerCase())>=0}))})):t},e.prototype.extractTitle=function(t){var e=this;return this._titleField?this._titleField.split(",").map((function(i){return e.extractValue(t,i)})).reduce((function(t,e){return t?t+" "+e:e})):""},e.prototype.extractValue=function(t,e){var i,n,r,o;if(e){r=e.split("."),o=t;try{for(var s=u(r),c=s.next();!c.done;c=s.next())e=c.value,o&&(o=o[e])}catch(t){i={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}}else o=t;return o},e.prototype.processResults=function(t){var e,i=[];if(t&&t.length>0)for(e=0;e<t.length;e++){var n=this.convertToItem(t[e]);n&&i.push(n)}return i},e.prototype.extractBySearchFields=function(t,e){var i=this;return t.map((function(t){return i.extractValue(e,t)})).filter((function(t){return!!t}))},e}(o.Subject),x=function(t){function i(){var i=t.call(this)||this;return i.dataSourceChange=new e.EventEmitter,i}return p(i,t),i.prototype.data=function(t){var e=this;t instanceof o.Observable?t.pipe(s.catchError((function(){return[]}))).subscribe((function(t){e._data=t,e.savedTerm&&e.search(e.savedTerm),e.dataSourceChange.emit()})):this._data=t;return this.dataSourceChange.emit(),this},i.prototype.search=function(t){if(this._data){this.savedTerm=null;var e=this.extractMatches(this._data,t);this.next(this.processResults(e))}else this.savedTerm=t},i.prototype.convertToItem=function(e){return t.prototype.convertToItem.call(this,e)},i}(O),C=function(){function t(){}return t.prototype.create=function(){return new x},t=l([e.Injectable(),a("design:paramtypes",[])],t)}(),I=function(t){function i(i){var n=t.call(this)||this;return n.http=i,n.dataSourceChange=new e.EventEmitter,n._urlFormater=null,n._dataField=null,n}return p(i,t),i.prototype.remoteUrl=function(t){return this._remoteUrl=t,this.dataSourceChange.emit(),this},i.prototype.urlFormater=function(t){this._urlFormater=t},i.prototype.dataField=function(t){this._dataField=t},i.prototype.requestOptions=function(t){this._requestOptions=t},i.prototype.search=function(t){var e=this;this.cancel();var i="";i=this._urlFormater?this._urlFormater(t):this._remoteUrl+encodeURIComponent(t),this.remoteSearch=this.http.get(i,Object.assign({},this._requestOptions)).pipe(s.map((function(i){var n=e.extractValue(i,e._dataField);return e.extractMatches(n,t)})),s.catchError((function(){return[]}))).subscribe((function(t){var i=e.processResults(t);e.next(i)}))},i.prototype.cancel=function(){this.remoteSearch&&this.remoteSearch.unsubscribe()},i.prototype.convertToItem=function(e){return t.prototype.convertToItem.call(this,e)},i}(O),_=function(){function t(t){this.http=t}return t.prototype.create=function(){return new I(this.http)},t.ctorParameters=function(){return[{type:r.HttpClient}]},t=l([e.Injectable(),a("design:paramtypes",[r.HttpClient])],t)}(),j=function(){function t(t,e){this.localDataFactory=t,this.remoteDataFactory=e}return t.prototype.local=function(t,e,i){return void 0===e&&(e=""),void 0===i&&(i=""),this.localDataFactory.create().data(t).searchFields(e).titleField(i)},t.prototype.remote=function(t,e,i){return void 0===e&&(e=""),void 0===i&&(i=""),this.remoteDataFactory.create().remoteUrl(t).searchFields(e).titleField(i)},t.ctorParameters=function(){return[{type:C},{type:_}]},t=l([e.Injectable(),a("design:paramtypes",[C,_])],t)}(),R=function(){},E=R,H={provide:n.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return T})),multi:!0},T=function(){function t(t,i){this.completerService=t,this.cdr=i,this.inputName="",this.inputId="",this.pause=10,this.minSearchLength=3,this.maxChars=524288,this.overrideSuggested=!1,this.clearSelected=!1,this.clearUnselected=!1,this.fillHighlighted=!0,this.placeholder="",this.autoMatch=!1,this.disableInput=!1,this.autofocus=!1,this.openOnFocus=!1,this.openOnClick=!1,this.selectOnClick=!1,this.autoHighlight=!1,this.autoSelectOnEnter=!0,this.selected=new e.EventEmitter,this.highlighted=new e.EventEmitter,this.blurEvent=new e.EventEmitter,this.click=new e.EventEmitter,this.focusEvent=new e.EventEmitter,this.opened=new e.EventEmitter,this.keyup=new e.EventEmitter,this.keydown=new e.EventEmitter,this.searchStr="",this.control=new n.FormControl(""),this.displaySearching=!0,this.displayNoResults=!0,this._textNoResults="No results found",this._textSearching="Searching...",this._onTouchedCallback=R,this._onChangeCallback=R,this._focus=!1,this._open=!1}return Object.defineProperty(t.prototype,"value",{get:function(){return this.searchStr},set:function(t){t!==this.searchStr&&(this.searchStr=t),this._onChangeCallback(t)},enumerable:!0,configurable:!0}),t.prototype.ngAfterViewInit=function(){this.autofocus&&(this._focus=!0)},t.prototype.ngAfterViewChecked=function(){var t=this;this._focus&&setTimeout((function(){t.ctrInput.nativeElement.focus(),t._focus=!1}),0)},t.prototype.onTouched=function(){this._onTouchedCallback()},t.prototype.writeValue=function(t){this.searchStr=t},t.prototype.registerOnChange=function(t){this._onChangeCallback=t},t.prototype.registerOnTouched=function(t){this._onTouchedCallback=t},t.prototype.setDisabledState=function(t){this.disableInput=t},Object.defineProperty(t.prototype,"datasource",{set:function(t){t&&(this.dataService=t instanceof Array?this.completerService.local(t):"string"==typeof t?this.completerService.remote(t):t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textNoResults",{set:function(t){this._textNoResults!==t&&(this._textNoResults=t,this.displayNoResults=!!this._textNoResults&&"false"!==this._textNoResults)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textSearching",{set:function(t){this._textSearching!==t&&(this._textSearching=t,this.displaySearching=!!this._textSearching&&"false"!==this._textSearching)},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){var t=this;this.completer.selected.subscribe((function(e){t.selected.emit(e)})),this.completer.highlighted.subscribe((function(e){t.highlighted.emit(e)})),this.completer.opened.subscribe((function(e){t._open=e,t.opened.emit(e)}))},t.prototype.onBlur=function(){this.blurEvent.emit(),this.onTouched(),this.cdr.detectChanges()},t.prototype.onFocus=function(){this.focusEvent.emit(),this.onTouched()},t.prototype.onClick=function(t){this.click.emit(t),this.onTouched()},t.prototype.onKeyup=function(t){this.keyup.emit(t)},t.prototype.onKeydown=function(t){this.keydown.emit(t)},t.prototype.onChange=function(t){this.value=t},t.prototype.open=function(){this.completer.open()},t.prototype.close=function(){this.completer.clear()},t.prototype.focus=function(){this.ctrInput?this.ctrInput.nativeElement.focus():this._focus=!0},t.prototype.blur=function(){this.ctrInput?this.ctrInput.nativeElement.blur():this._focus=!1},t.prototype.isOpen=function(){return this._open},t.ctorParameters=function(){return[{type:j},{type:e.ChangeDetectorRef}]},l([e.Input(),a("design:type",Object)],t.prototype,"dataService",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"inputName",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"inputId",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"pause",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"minSearchLength",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"maxChars",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"overrideSuggested",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"clearSelected",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"clearUnselected",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"fillHighlighted",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"placeholder",void 0),l([e.Input(),a("design:type",String)],t.prototype,"matchClass",void 0),l([e.Input(),a("design:type",Number)],t.prototype,"fieldTabindex",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"autoMatch",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"disableInput",void 0),l([e.Input(),a("design:type",String)],t.prototype,"inputClass",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"autofocus",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"openOnFocus",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"openOnClick",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"selectOnClick",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"initialValue",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"autoHighlight",void 0),l([e.Input(),a("design:type",Object)],t.prototype,"autoSelectOnEnter",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"selected",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"highlighted",void 0),l([e.Output("blur"),a("design:type",Object)],t.prototype,"blurEvent",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"click",void 0),l([e.Output("focus"),a("design:type",Object)],t.prototype,"focusEvent",void 0),l([e.Output(),a("design:type",Object)],t.prototype,"opened",void 0),l([e.Output(),a("design:type",e.EventEmitter)],t.prototype,"keyup",void 0),l([e.Output(),a("design:type",e.EventEmitter)],t.prototype,"keydown",void 0),l([e.ViewChild(d,{static:!0}),a("design:type",d)],t.prototype,"completer",void 0),l([e.ViewChild("ctrInput",{static:!0}),a("design:type",e.ElementRef)],t.prototype,"ctrInput",void 0),l([e.Input(),a("design:type",Object),a("design:paramtypes",[Object])],t.prototype,"datasource",null),l([e.Input(),a("design:type",String),a("design:paramtypes",[String])],t.prototype,"textNoResults",null),l([e.Input(),a("design:type",String),a("design:paramtypes",[String])],t.prototype,"textSearching",null),t=l([e.Component({selector:"neo-completer",template:'\n <div class="completer-holder" ctrCompleter>\n <input #ctrInput [attr.id]="inputId.length > 0 ? inputId : null" type="search" class="completer-input" ctrInput [ngClass]="inputClass"\n [(ngModel)]="searchStr" (ngModelChange)="onChange($event)" [attr.name]="inputName" [placeholder]="placeholder"\n [attr.maxlength]="maxChars" [tabindex]="fieldTabindex" [disabled]="disableInput"\n [clearSelected]="clearSelected" [clearUnselected]="clearUnselected"\n [overrideSuggested]="overrideSuggested" [openOnFocus]="openOnFocus" [fillHighlighted]="fillHighlighted"\n [openOnClick]="openOnClick" [selectOnClick]="selectOnClick" [autoSelectOnEnter]="autoSelectOnEnter"\n (blur)="onBlur()" (focus)="onFocus()" (keyup)="onKeyup($event)" (keydown)="onKeydown($event)" (click)="onClick($event)"\n autocomplete="off" autocorrect="off" autocapitalize="off" />\n\n <div class="completer-dropdown-holder"\n *ctrList="dataService;\n minSearchLength: minSearchLength;\n pause: pause;\n autoMatch: autoMatch;\n initialValue: initialValue;\n autoHighlight: autoHighlight;\n displaySearching: displaySearching;\n let items = results;\n let searchActive = searching;\n let isInitialized = searchInitialized;\n let isOpen = isOpen;">\n <div class="completer-dropdown" ctrDropdown *ngIf="isInitialized && isOpen && (( items?.length > 0|| (displayNoResults && !searchActive)) || (searchActive && displaySearching))">\n <div *ngIf="searchActive && displaySearching" class="completer-searching">{{_textSearching}}</div>\n <div *ngIf="!searchActive && (!items || items?.length === 0)" class="completer-no-results">{{_textNoResults}}</div>\n <div class="completer-row-wrapper" *ngFor="let item of items; let rowIndex=index">\n <div class="completer-row" [ctrRow]="rowIndex" [dataItem]="item">\n <div *ngIf="item.image || item.image === \'\'" class="completer-image-holder">\n <img *ngIf="item.image != \'\'" src="{{item.image}}" class="completer-image" />\n <div *ngIf="item.image === \'\'" class="completer-image-default"></div>\n </div>\n <div class="completer-item-text" [ngClass]="{\'completer-item-text-image\': item.image || item.image === \'\' }">\n <completer-list-item class="completer-title" [text]="item.title" [matchClass]="matchClass" [searchStr]="searchStr" [type]="\'title\'"></completer-list-item>\n <completer-list-item *ngIf="item.description && item.description != \'\'" class="completer-description" [text]="item.description"\n [matchClass]="matchClass" [searchStr]="searchStr" [type]="\'description\'">\n </completer-list-item>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n ',providers:[H],styles:[".completer-dropdown{border-radius:0;width:calc(100% - 30px);cursor:pointer;z-index:9999;position:absolute;background-color:#fff;max-height:200px;height:200px;overflow-y:auto;overflow-x:hidden;border:1px solid #ececec}.completer-row{color:#000;width:100%;padding:5px 12px}.completer-selected-row{background-color:#add8e6;color:#fff}.completer-description{font-size:14px}.completer-image-default{width:16px;height:16px;background-image:url(demo/res/img/default.png)}.completer-image-holder{float:left;width:10%}.completer-item-text-image{float:right;width:90%}"]}),a("design:paramtypes",[j,e.ChangeDetectorRef])],t)}(),F=function(){function t(){}var o;return o=t,t.forRoot=function(){return{ngModule:o,providers:[j,C,_]}},t=o=l([e.NgModule({imports:[i.CommonModule,n.FormsModule,r.HttpClientModule],declarations:[g,d,f,v,S,w,T],exports:[T,g,d,f,v,S,w]})],t)}(),L=function(){function t(t){this.modelString="",this.fieldValue="",this.completerService=t}return t.prototype.onSelected=function(t){this.selectedObject[this.fieldValue]=null!=t?t.originalObject:this.empty},t.prototype.local=function(t,e,i,n,r,o){return void 0===i&&(i=""),this.selectedObject=e,this.fieldValue=i,this.dataSource=this.completerService.local(t,n,r),this.modelString=""!==i?this.selectedObject[this.fieldValue][n]:this.selectedObject[n],this.empty=o,this.dataSource},t}();t.CompleterBaseData=O,t.CompleterCmp=T,t.CompleterListItemCmp=g,t.CompleterService=j,t.CtrCompleter=d,t.CtrDropdown=f,t.CtrInput=v,t.CtrList=S,t.CtrListContext=b,t.CtrRow=w,t.CtrRowItem=y,t.LocalData=x,t.LocalDataFactory=C,t.NgxNeoCompleterModule=F,t.NgxNeoCompleterService=L,t.RemoteData=I,t.RemoteDataFactory=_,t.ɵ0=E,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=neocomplexx-ngx-neo-completer.umd.min.js.map