mdc-autocomplete-list
Version:
MdcAutocomplete in conjunction with MdcAutocompleteList and MdcAutocompleteListItem are a pack of angular components to provide an autocomplete functionality to Angular MDC web.
2 lines • 4.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("mdc-autocomplete-list-item"),require("rxjs"),require("@angular/common"),require("@angular-mdc/web")):"function"==typeof define&&define.amd?define("mdc-autocomplete-list",["exports","@angular/core","mdc-autocomplete-list-item","rxjs","@angular/common","@angular-mdc/web"],t):t(e["mdc-autocomplete-list"]={},e.ng.core,null,e.rxjs,e.ng.common,null)}(this,function(e,t,o,n,i,r){"use strict";var s=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),c=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"mdc-mdc-autocomplete-list",template:"\n <p>\n mdc-autocomplete-list works!\n </p>\n ",styles:[]}]}],e.ctorParameters=function(){return[]},e}(),u=function(){function e(){this.itemSelected=new n.Subject,this.maxVisibleItems=Number.POSITIVE_INFINITY,this._visible=!1,this._filter=""}return Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){(this._visible=e)?(this.filterItems(),this.focusFirstItem()):this.unfocusAllItems()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(e){this._filter=e,this.filterItems(),this.focusFirstItem()},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngAfterContentChecked=function(){var o=this;this.autocompleteListItems.toArray().forEach(function(t){0===t.itemClicked.observers.length&&t.itemClicked.subscribe(function(e){o.itemSelected.next(e)}),0===t.itemHovered.observers.length&&t.itemHovered.subscribe(function(e){o.unfocusAllItems(),t.focused=!0})})},e.prototype.unfocusAllItems=function(){this.autocompleteListItems.toArray().forEach(function(e){e.focused=!1})},e.prototype.focusNextItem=function(){var e=this.autocompleteListItems.filter(function(e,t,o){return e.focused}),t=0<e.length?e[0]:null,o=this.autocompleteListItems.filter(function(e,t,o){return e.visible});if(t){var n=o.indexOf(t),i=o.length>=n+1?o[n+1]:null;i&&(t.focused=!1,i.focused=!0,i.scrollIntoView())}else 0<o.length&&(o[0].focused=!0)},e.prototype.focusPreviousItem=function(){var e=this.autocompleteListItems.filter(function(e,t,o){return e.focused}),t=0<e.length?e[0]:null,o=this.autocompleteListItems.filter(function(e,t,o){return e.visible});if(t){var n=o.indexOf(t),i=0<n?o[n-1]:null;i&&(t.focused=!1,i.focused=!0,i.scrollIntoView())}else 0<o.length&&(o[0].focused=!0)},e.prototype.focusFirstItem=function(){this.unfocusAllItems();var e=this.autocompleteListItems.filter(function(e,t,o){return e.visible});0<e.length&&(e[0].focused=!0)},e.prototype.selectFocusedItem=function(){var e=this.autocompleteListItems.filter(function(e,t,o){return e.focused}),t=0<e.length?e[0]:null;t&&this.itemSelected.next(t.value)},e.prototype.filterItems=function(){var n=this,i=0;this.autocompleteListItems.forEach(function(e,t,o){i<n.maxVisibleItems&&e.filterString.toUpperCase().includes(n._filter.toUpperCase())?(e.visible=!0,i++):(e.visible=!1,e.focused=!1)})},e.decorators=[{type:t.Component,args:[{selector:"mdc-autocomplete-list",template:'<ul *ngIf="visible" class="mdc-elevation--z2">\n <ng-content></ng-content>\n</ul>\n',styles:["ul{position:absolute;min-width:200px;max-height:400px;padding:0;margin:0;background-color:#fff;overflow-y:scroll;list-style:none}"]}]}],e.ctorParameters=function(){return[]},e.propDecorators={maxVisibleItems:[{type:t.Input}],itemSelected:[{type:t.Output}],autocompleteListItems:[{type:t.ContentChildren,args:[o.MdcAutocompleteListItem]}]},e}(),l=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[i.CommonModule,o.MdcAutocompleteListItemModule,r.MdcElevationModule],declarations:[c,u],exports:[u]}]}],e}();e.MdcAutocompleteListService=s,e.MdcAutocompleteListModule=l,e.MdcAutocompleteList=u,e.ɵa=c,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=mdc-autocomplete-list.umd.min.js.map