ngx-select2-ex
Version:
Angular(2+) version of the popular alternative to select inputs, Select2. Select2 classes are used in the template, so you can use any pre-existing styles for Select2 and it will look the same as the original.
3 lines (2 loc) • 25.6 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs/ReplaySubject"),require("rxjs/BehaviorSubject"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-select2-ex",["exports","@angular/core","rxjs/ReplaySubject","rxjs/BehaviorSubject","@angular/forms","@angular/common"],t):t(e["ngx-select2-ex"]={},e.ng.core,e.Rx,e.Rx,e.ng.forms,e.ng.common)}(this,function(e,t,n,i,s,o){"use strict";var l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,s,o=n.call(e),r=[];try{for(;(void 0===t||0<t--)&&!(i=o.next()).done;)r.push(i.value)}catch(l){s={error:l}}finally{try{i&&!i.done&&(n=o["return"])&&n.call(o)}finally{if(s)throw s.error}}return r}var r=function(r){function t(e,t,n,i,s){var o=r.call(this,e,t,!!n,!!i)||this;return o.highlighted=!!s,o}return function(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,r),t.copy=function(e){return new t(e.id,e.value,e.disabled,e.selected,e.highlighted)},t.copyArray=function(e){return function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(c(arguments[t]));return e}(e.map(function(e){return t.copy(e)}))},t}(function(e,t,n,i){this.id=e,this.value=t,this.disabled=!!n,this.selected=!!i}),u=function(e){this.errorLoading=e&&e.errorLoading?e.errorLoading:function(){return"The results could not be loaded."},this.inputTooLong=e&&e.inputTooLong?e.inputTooLong:function(e){return"Please delete "+e+" character"},this.inputTooShort=e&&e.inputTooShort?e.inputTooShort:function(e){return"Please enter "+e+" or more characters"},this.loadingMore=e&&e.loadingMore?e.loadingMore:function(){return"Loading more results…"},this.maximumSelected=e&&e.maximumSelected?e.maximumSelected:function(e){return"You can only select "+e+" item"},this.noResults=e&&e.noResults?e.noResults:function(){return"No results found"},this.searching=e&&e.searching?e.searching:function(){return"Searching…"}},a=function(){function e(){this.multi=null,this.disabled=!1,this.theme="default",this.minimumResultsForSearch=0,this.minimumInputLength=null,this.maximumInputLength=null,this.language=new u,this.selectOnClose=!1,this.closeOnSelect=!0,this._options=new i.BehaviorSubject([]),this._dropdownPosition=new n.ReplaySubject(1),this._isOpen=new i.BehaviorSubject(!1),this._isInFocus=new i.BehaviorSubject(!1),this._selection=new i.BehaviorSubject([]),this._search=new i.BehaviorSubject(null)}return Object.defineProperty(e.prototype,"options",{get:function(){return this._options.getValue()},set:function(e){this._options.next(r.copyArray(e)),this.selection=this.options},enumerable:!0,configurable:!0}),e.prototype.getOptionsAsObservable=function(){return this._options.asObservable()},Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection.getValue()},set:function(e){var t,n=(e=r.copyArray(e)).filter(function(e){return e.selected});this.multi?this._selection.next(n):(0===n.length&&e.length?t=r.copyArray(e).reverse().pop():0<n.length&&(t=n.pop()),e.forEach(function(e){return e.selected=!1}),e[e.findIndex(function(e){return e.id===t.id})].selected=!0,this._options.next(e),n=[t],this._selection.next(n))},enumerable:!0,configurable:!0}),e.prototype.getSelectionAsObservable=function(){return this._selection.asObservable()},Object.defineProperty(e.prototype,"dropdownPosition",{set:function(e){this._dropdownPosition.next(e)},enumerable:!0,configurable:!0}),e.prototype.getDropdownPositionAsObservable=function(){return this._dropdownPosition.asObservable()},Object.defineProperty(e.prototype,"isOpen",{get:function(){return this._isOpen.getValue()},set:function(e){this._isOpen.next(e)},enumerable:!0,configurable:!0}),e.prototype.getIsOpenAsObservable=function(){return this._isOpen.asObservable()},Object.defineProperty(e.prototype,"isInFocus",{get:function(){return this._isInFocus.getValue()},set:function(e){this._isInFocus.next(e)},enumerable:!0,configurable:!0}),e.prototype.getIsInFocusAsObservable=function(){return this._isInFocus.asObservable()},Object.defineProperty(e.prototype,"search",{get:function(){return this._search.getValue()},set:function(e){this._search.next(e)},enumerable:!0,configurable:!0}),e.prototype.getSearchAsObservable=function(){return this._search.asObservable()},e.prototype.open=function(){this.isOpen=!0},e.prototype.close=function(){this.isOpen=!1},e.prototype.select=function(t){this.multi||this.options.forEach(function(e){return e.selected=!1});var e=this.options.findIndex(function(e){return e.id===t.id});if(-1<e){var n=r.copyArray(this.options);n[e].selected=!0,this.options=n}},e.prototype.deselect=function(t){if(this.multi){var e=this.options.findIndex(function(e){return e.id===t.id});if(-1<e){var n=r.copyArray(this.options);n[e].selected=!1,this.options=n}}},e.prototype.clear=function(){var e=r.copyArray(this.options);e.forEach(function(e){return e.selected=!1}),this._options.next(e),this._selection.next([])},e}();a.decorators=[{type:t.Injectable}],a.ctorParameters=function(){return[]};var p=function(){function e(e){this.ngxSelect2ExService=e,this.options=null,this.disabled=null,this.multi=null,this.theme=null,this.minimumResultsForSearch=null,this.minimumInputLength=null,this.maximumInputLength=null,this.language=null,this.selectOnClose=!1,this.closeOnSelect=!0,this.allowClear=!1,this.placeholder=null,this.selection=[],this.subscriptions=[],this.propagateChange=function(e){}}return Object.defineProperty(e.prototype,"search",{get:function(){return this.ngxSelect2ExService.search},set:function(e){this.ngxSelect2ExService.search=e},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.initStaticInputValues(),this.subscribeToSelection(),this.subscribeToIsOpen(),this.subscribeToIsInFocus()},e.prototype.ngOnChanges=function(e){e.options&&e.options.currentValue.length&&e.options.previousValue!==e.options.currentValue&&this.initOptions(e.options.currentValue),e.disabled!==undefined&&e.disabled.previousValue!==e.disabled.currentValue&&(this.ngxSelect2ExService.disabled=e.disabled.currentValue)},e.prototype.ngOnDestroy=function(){this.unsubscribe()},e.prototype.writeValue=function(e){this.initOptions(e)},e.prototype.registerOnChange=function(e){this.propagateChange=e},e.prototype.registerOnTouched=function(e){},e.prototype.setDisabledState=function(e){this.disabled=e,this.ngxSelect2ExService.disabled=e},e.prototype.getContainerThemeClass=function(){return"select2-container--"+this.ngxSelect2ExService.theme},e.prototype.getStyleOfSearchListItem=function(){return{width:this.selection&&this.selection.length||!this.placeholder?null:"100%"}},e.prototype.getStyleOfInlineInput=function(e){return e||this.selection&&this.selection.length||!this.placeholder?{width:e?.75*(e.length+1)+"em":"0.75em"}:{width:"100%"}},e.prototype.getInlineInputPlaceholder=function(){return this.selection&&this.selection.length||!this.placeholder?"":this.placeholder},e.prototype.clearSelection=function(){this.shouldShowClearSelectionButton()&&(!this.multi&&this.placeholder||this.multi)&&!this.disabled&&this.ngxSelect2ExService.clear()},e.prototype.shouldShowClearSelectionButton=function(){return this.allowClear&&this.selection&&!!this.selection.length},e.prototype.shouldShowPlaceholder=function(){return!(this.selection&&this.selection.length||!this.placeholder)},e.prototype.getTitleTooltipText=function(){return this.selection&&this.selection.length&&this.selection[0].value?this.selection[0].value:this.placeholder?this.placeholder:""},e.prototype.deselect=function(e){this.ngxSelect2ExService.deselect(e)},e.prototype.subscribeToSelection=function(){var t=this;this.subscriptions.push(this.ngxSelect2ExService.getSelectionAsObservable().subscribe(function(e){t.selection=e,t.propagateChange(t.selection)}))},e.prototype.subscribeToIsOpen=function(){var t=this;this.subscriptions.push(this.ngxSelect2ExService.getIsOpenAsObservable().subscribe(function(e){return t.isOpen=e}))},e.prototype.subscribeToIsInFocus=function(){var t=this;this.subscriptions.push(this.ngxSelect2ExService.getIsInFocusAsObservable().subscribe(function(e){return t.isInFocus=e}))},e.prototype.initOptions=function(e){if(this.isStringList(e))this.ngxSelect2ExService.options=e.map(function(e,t){return new r(t,e)});else{if(!this.isOptionInterfaceList(e))throw new Error("Input for options array should be of type Array<string> or Array<INgxSelect2ExOption>.");this.ngxSelect2ExService.options=e.map(function(e){return new r(e.id,e.value,e.disabled,e.selected)})}},e.prototype.isStringList=function(e){return e&&e.every(function(e){return"string"==typeof e})},e.prototype.isOptionInterfaceList=function(e){return e&&e.every(function(e){return"id"in e&&"value"in e})},e.prototype.defaultChangeListener=function(e,t){e[t]&&e[t].previousValue!==e[t].currentValue&&(this.ngxSelect2ExService[t]=e[t].currentValue)},e.prototype.initStaticInputValues=function(){this.defaultInputSetter("multi"),this.defaultInputSetter("theme"),this.defaultInputSetter("minimumResultsForSearch"),this.defaultInputSetter("minimumInputLength"),this.defaultInputSetter("maximumInputLength",this.minimumInputLength&&this.maximumInputLength&&this.maximumInputLength<this.minimumInputLength?this.minimumInputLength:this.maximumInputLength),this.defaultInputSetter("language",new u(this.language)),this.defaultInputSetter("selectOnClose"),this.defaultInputSetter("closeOnSelect")},e.prototype.defaultInputSetter=function(e,t){null!==this[e]&&(this.ngxSelect2ExService[e]=t||this[e])},e.prototype.unsubscribe=function(){this.subscriptions.forEach(function(e){return e.unsubscribe()})},e}();p.decorators=[{type:t.Component,args:[{selector:"app-ngx-select2-ex",template:'<span appNgxSelect2Ex\n [service]="ngxSelect2ExService"\n class="select2 select2-container"\n [class.select2-container--below]="!disabled"\n [class.select2-container--open]="isOpen"\n [ngClass]="getContainerThemeClass()"\n [class.select2-container--focus]="isInFocus"\n [class.select2-container--disabled]="disabled"\n dir="ltr">\n <span class="selection">\n <span class="select2-selection"\n [class.select2-selection--single]="!multi"\n [class.select2-selection--multiple]="multi"\n role="combobox"\n aria-haspopup="true"\n [attr.aria-expanded]="isOpen"\n [tabindex]="multi ? -1 : 0"\n aria-labelledby="select2-container"\n aria-owns="select2-results">\n <span *ngIf="!multi" class="select2-selection__rendered" id="select2-selection-container" [title]="getTitleTooltipText()">\n <span *ngIf="shouldShowPlaceholder()" class="select2-selection__placeholder">{{placeholder}}</span>\n <span *ngIf="shouldShowClearSelectionButton()" class="select2-selection__clear" (click)="clearSelection()">×</span>\n {{selection[0]?.value}}\n </span>\n <span *ngIf="!multi" class="select2-selection__arrow" role="presentation">\n <b role="presentation"></b>\n </span>\n <ul *ngIf="multi" class="select2-selection__rendered">\n <span *ngIf="shouldShowClearSelectionButton()" class="select2-selection__clear" (click)="clearSelection()">×</span>\n <li *ngFor="let selectionItem of selection" class="select2-selection__choice" [title]="selectionItem.value">\n <span class="select2-selection__choice__remove" role="presentation" (click)="deselect(selectionItem)">×</span>\n {{selectionItem.value}}\n </li>\n <li class="select2-search select2-search--inline" [ngStyle]="getStyleOfSearchListItem()">\n <input class="select2-search__field"\n type="search"\n tabindex="0"\n autocomplete="off"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n role="textbox"\n aria-autocomplete="list"\n [placeholder]="getInlineInputPlaceholder()"\n [ngStyle]="getStyleOfInlineInput(search)"\n [(ngModel)]="search"></li>\n </ul>\n </span>\n </span>\n <span class="dropdown-wrapper" aria-hidden="true"></span>\n</span>\n',styles:[".select2-container{display:block}"],providers:[{provide:s.NG_VALUE_ACCESSOR,useExisting:t.forwardRef(function(){return p}),multi:!0},a]}]}],p.ctorParameters=function(){return[{type:a}]},p.propDecorators={options:[{type:t.Input}],disabled:[{type:t.Input}],multi:[{type:t.Input}],theme:[{type:t.Input}],minimumResultsForSearch:[{type:t.Input}],minimumInputLength:[{type:t.Input}],maximumInputLength:[{type:t.Input}],language:[{type:t.Input}],selectOnClose:[{type:t.Input}],closeOnSelect:[{type:t.Input}],allowClear:[{type:t.Input}],placeholder:[{type:t.Input}]};var h=function(){function e(){}return e.prototype.transform=function(e,t,n,i,s){return void 0===i&&(i=null),void 0===s&&(s=null),this.filterOptions(e,t,n,i,s)},e.prototype.filterOptions=function(e,t,n,i,s){return void 0===i&&(i=null),void 0===s&&(s=null),e.length<n?e:null!==i&&null!==s?this.rangeInputFilteringHandler(e,t,i,s):null!==i?this.minimumInputFilteringHandler(e,t,i):null!==s?this.maximumInputFilteringHandler(e,t,s):this.doFiltering(e,t)},e.prototype.rangeInputFilteringHandler=function(e,t,n,i){return this.isfilterTextBiggerThanMinimumInputLength(t,n)&&this.isfilterTextSmallerThanMaximumInputLength(t,i)?this.doFiltering(e,t):[]},e.prototype.minimumInputFilteringHandler=function(e,t,n){return this.isfilterTextBiggerThanMinimumInputLength(t,n)?this.doFiltering(e,t):[]},e.prototype.maximumInputFilteringHandler=function(e,t,n){return!t||this.isfilterTextSmallerThanMaximumInputLength(t,n)?this.doFiltering(e,t):[]},e.prototype.isfilterTextBiggerThanMinimumInputLength=function(e,t){return e&&t<=e.length},e.prototype.isfilterTextSmallerThanMaximumInputLength=function(e,t){return e&&e.length<=t},e.prototype.doFiltering=function(e,t){return t?e.filter(function(e){return e.value.toLowerCase().includes(t.toLowerCase())}):e},e}();h.decorators=[{type:t.Pipe,args:[{name:"ngxSelect2OptionFilter"}]}];var d=function(){function e(e){this.filterPipe=e,this.multi=null,this.minimumInputLength=null,this.maximumInputLength=null,this.display="block",this.position="absolute",this.options=[],this.subscriptions=[]}return e.prototype.ngOnInit=function(){this.subscribeToOptions(),this.subscribeToDropdownPositionChanges(),this.subscribeToSearchChanges()},e.prototype.ngOnDestroy=function(){this.unsubscribe(),this.selectOnClose()},e.prototype.onOptionHover=function(t){t.disabled||this.options.forEach(function(e){e.highlighted=e.id===t.id})},e.prototype.onOptionClick=function(e){e.disabled||(e.selected?this.service.deselect(e):this.service.select(e),this.service.search=null)},e.prototype.getContainerThemeClass=function(){return"select2-container--"+this.theme},e.prototype.shouldHideSearchBox=function(){return this.options.length<this.minimumResultsForSearch||this.multi},e.prototype.getNoResultsMessage=function(){return this.language.noResults()},e.prototype.getInputTooShortMessage=function(){return this.language.inputTooShort(this.minimumInputLength)},e.prototype.getInputTooLongMessage=function(){return this.language.inputTooLong((this.search?this.search.length:0)-this.maximumInputLength)},e.prototype.shouldShowNoResultsMessage=function(){return this.search&&!this.filterPipe.filterOptions(this.options,this.search,this.minimumResultsForSearch).length&&!this.shouldShowInputTooShortMessage()&&!this.shouldShowInputTooLongMessage()&&(this.multi||!this.shouldHideSearchBox())},e.prototype.shouldShowInputTooShortMessage=function(){return null!==this.minimumInputLength&&(!this.search||this.search&&this.search.length<this.minimumInputLength)&&!this.filterPipe.filterOptions(this.options,this.search,this.minimumResultsForSearch,this.minimumInputLength).length&&!this.shouldHideSearchBox()},e.prototype.shouldShowInputTooLongMessage=function(){return null!==this.maximumInputLength&&this.search&&this.maximumInputLength<this.search.length&&!this.filterPipe.filterOptions(this.options,this.search,this.minimumResultsForSearch,null,this.maximumInputLength).length&&!this.shouldHideSearchBox()},e.prototype.subscribeToOptions=function(){var t=this;this.subscriptions.push(this.service.getOptionsAsObservable().subscribe(function(e){return t.options=e},function(e){return console.error(e)}))},e.prototype.subscribeToDropdownPositionChanges=function(){var t=this;this.subscriptions.push(this.service.getDropdownPositionAsObservable().subscribe(function(e){return t.initDropdownPosition(e)}))},e.prototype.subscribeToSearchChanges=function(){var t=this;this.subscriptions.push(this.service.getSearchAsObservable().subscribe(function(e){return t.search=e}))},e.prototype.initDropdownPosition=function(e){this.top=e.top+"px",this.left=e.left+"px",this.width=e.width+"px"},e.prototype.selectOnClose=function(){var e=this.options.find(function(e){return e.highlighted});e&&this.service.selectOnClose&&this.service.select(e)},e.prototype.unsubscribe=function(){this.subscriptions.forEach(function(e){return e.unsubscribe()})},e}();d.decorators=[{type:t.Component,args:[{selector:"app-ngx-select2-ex-dropdown",template:'<span class="select2-container" [ngClass]="getContainerThemeClass()" [class.select2-container--open]="true">\n <span id="select2-dropdown" class="select2-dropdown select2-dropdown--below" dir="ltr">\n <span *ngIf="!multi" class="select2-search select2-search--dropdown" [class.select2-search--hide]="shouldHideSearchBox()">\n <input appNgxSelect2ExDropdownSearchField\n class="select2-search__field"\n type="search" tabindex="0"\n autocomplete="off"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false"\n role="textbox"\n [(ngModel)]="search">\n </span>\n <span class="select2-results">\n <ul class="select2-results__options" role="tree" id="select2-results" aria-expanded="true" aria-hidden="false">\n <li *ngFor="let option of options | ngxSelect2OptionFilter: search:minimumResultsForSearch:minimumInputLength:maximumInputLength"\n class="select2-results__option"\n [class.select2-results__option--highlighted]="option.highlighted"\n role="treeitem"\n [attr.aria-selected]="option.selected"\n [attr.aria-disabled]="option.disabled ? option.disabled : null"\n (mouseover)="onOptionHover(option)"\n (mousedown)="onOptionClick(option)">\n {{option.value}}\n </li>\n <li *ngIf="shouldShowNoResultsMessage()"\n role="treeitem"\n aria-live="assertive"\n class="select2-results__option select2-results__message">\n {{getNoResultsMessage()}}\n </li>\n <li *ngIf="shouldShowInputTooShortMessage()"\n role="treeitem"\n aria-live="assertive"\n class="select2-results__option select2-results__message">\n {{getInputTooShortMessage()}}\n </li>\n <li *ngIf="shouldShowInputTooLongMessage()"\n role="treeitem"\n aria-live="assertive"\n class="select2-results__option select2-results__message">\n {{getInputTooLongMessage()}}\n </li>\n </ul>\n </span>\n </span>\n</span>\n',styles:[".select2-container{display:block}"]}]}],d.ctorParameters=function(){return[{type:h}]},d.propDecorators={service:[{type:t.Input}],multi:[{type:t.Input}],theme:[{type:t.Input}],minimumResultsForSearch:[{type:t.Input}],minimumInputLength:[{type:t.Input}],maximumInputLength:[{type:t.Input}],language:[{type:t.Input}],display:[{type:t.HostBinding,args:["style.display"]}],position:[{type:t.HostBinding,args:["style.position"]}],top:[{type:t.HostBinding,args:["style.top"]}],left:[{type:t.HostBinding,args:["style.left"]}],right:[{type:t.HostBinding,args:["style.right"]}],width:[{type:t.HostBinding,args:["style.width"]}]};var f=function(){function e(e,t,n){this.applicationRef=e,this.componentFactoryResolver=t,this.injector=n}return e.prototype.getRootViewContainer=function(){if(this._container)return this._container;var e=this.applicationRef.components;if(e.length)return e[0];throw new Error("View Container not found! ngUpgrade needs to manually set this via setRootViewContainer.")},e.prototype.setRootViewContainer=function(e){this._container=e},e.prototype.getComponentRootNode=function(e){return e.hostView.rootNodes[0]},e.prototype.getRootViewContainerNode=function(){return this.getComponentRootNode(this.getRootViewContainer())},e.prototype.projectComponentInputs=function(e,t){if(t){var n=Object.getOwnPropertyNames(t);try{for(var i=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(n),s=i.next();!s.done;s=i.next()){var o=s.value;e.instance[o]=t[o]}}catch(c){r={error:c}}finally{try{s&&!s.done&&(l=i["return"])&&l.call(i)}finally{if(r)throw r.error}}}return e;var r,l},e.prototype.appendComponent=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=this.getRootViewContainerNode());var i=this.componentFactoryResolver.resolveComponentFactory(e).create(this.injector),s=this.applicationRef,o=this.getComponentRootNode(i);return this.projectComponentInputs(i,t),s.attachView(i.hostView),i.onDestroy(function(){s.detachView(i.hostView)}),n.appendChild(o),i},e}();f.decorators=[{type:t.Injectable}],f.ctorParameters=function(){return[{type:t.ApplicationRef},{type:t.ComponentFactoryResolver},{type:t.Injector}]};var g=function(){function e(){}return Object.defineProperty(e.prototype,"nativeWindow",{get:function(){return window},enumerable:!0,configurable:!0}),e}();g.decorators=[{type:t.Injectable}],g.ctorParameters=function(){return[]};var m=function(){function e(e,t,n,i){this.el=e,this.renderer=t,this.ngxSelect2ExDropdownInjectionService=n,this.winRef=i,this.subscriptions=[]}return e.prototype.ngOnInit=function(){this.updateDropdownPosition(),this.subscribeToSearchChanges()},e.prototype.ngOnDestroy=function(){this.unsubscribe()},e.prototype.onClick=function(e){var t=this.compRef?this.compRef.location.nativeElement:null,n="select2-selection__clear"===e.className,i=e.hasAttribute("aria-disabled"),s=e.className.includes("select2-results__message"),o=e.className.includes("select2-search__field"),r=e.className.includes("select2-selection__choice__remove"),l=t&&t.contains(e),c=this.el.nativeElement.contains(e)||l;c&&!this.service.isOpen?(this.service.isInFocus=!1,this.service.disabled||this.openDropdown()):c&&this.service.isOpen?i||s||o||n?this.service.isInFocus=!1:!this.service.closeOnSelect&&l||(this.service.isInFocus=!0,r||this.closeDropdown()):!c&&this.service.isOpen?(this.service.isInFocus=!1,this.closeDropdown()):c||this.service.isOpen||(this.service.isInFocus=!1),c&&(this.service.disabled||this.setFocusForSearchField(this.compRef?this.compRef.location.nativeElement:null),this.service.multi&&!s&&(this.service.search=null))},e.prototype.resize=function(){this.updateDropdownPosition()},e.prototype.openDropdown=function(){this.compRef=this.ngxSelect2ExDropdownInjectionService.appendComponent(d,{service:this.service,multi:this.service.multi,theme:this.service.theme,minimumResultsForSearch:this.service.minimumResultsForSearch,minimumInputLength:this.service.minimumInputLength,maximumInputLength:this.service.maximumInputLength,language:this.service.language}),this.service.isOpen=!0,this.updateDropdownPosition()},e.prototype.closeDropdown=function(){this.compRef&&(this.compRef.destroy(),this.compRef=null),this.service.isOpen=!1},e.prototype.setFocusForSearchField=function(e){var t=this.el.nativeElement?this.el.nativeElement.getElementsByClassName("select2-search__field"):null;t&&t.length&&t[0].focus()},e.prototype.subscribeToSearchChanges=function(){var t=this;this.subscriptions.push(this.service.getSearchAsObservable().subscribe(function(e){t.service.multi&&(e&&!t.service.isOpen&&(t.service.disabled||t.openDropdown()),t.updateDropdownPosition())}))},e.prototype.updateDropdownPosition=function(){this.renderer.setStyle(this.el.nativeElement,"width","100%");var e=this.el.nativeElement.getBoundingClientRect(),t={top:e.bottom+this.winRef.nativeWindow.scrollY,left:e.left,width:e.width};this.service.dropdownPosition=t,this.renderer.setStyle(this.el.nativeElement,"width",e.width+"px")},e.prototype.unsubscribe=function(){this.subscriptions.forEach(function(e){return e.unsubscribe()})},e}();m.decorators=[{type:t.Directive,args:[{selector:"[appNgxSelect2Ex]",providers:[g]}]}],m.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:f},{type:g}]},m.propDecorators={service:[{type:t.Input}],onClick:[{type:t.HostListener,args:["document:mouseup",["$event.target"]]}],resize:[{type:t.HostListener,args:["window:resize"]}]};var y=function(){function e(e){this.el=e}return e.prototype.ngOnInit=function(){this.setFocusForDropdownSearchField()},e.prototype.setFocusForDropdownSearchField=function(){this.el.nativeElement.focus()},e}();y.decorators=[{type:t.Directive,args:[{selector:"[appNgxSelect2ExDropdownSearchField]"}]}],y.ctorParameters=function(){return[{type:t.ElementRef}]};var b=function(){};b.decorators=[{type:t.NgModule,args:[{imports:[o.CommonModule,s.FormsModule],declarations:[p,d,m,y,h],exports:[p],entryComponents:[d],providers:[f,h]}]}],e.NgxSelect2ExModule=b,e.ɵc=d,e.ɵa=p,e.ɵh=y,e.ɵe=m,e.ɵd=h,e.ɵg=f,e.ɵb=a,e.ɵf=g,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-select2-ex.umd.min.js.map