ngx-bootstrap-ci
Version:
Native Angular Bootstrap Components
2 lines • 10.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/utils"),require("rxjs/operators"),require("ngx-bootstrap/component-loader"),require("ngx-bootstrap/positioning")):"function"==typeof define&&define.amd?define("ngx-bootstrap/dropdown",["exports","@angular/core","ngx-bootstrap/utils","rxjs/operators","ngx-bootstrap/component-loader","ngx-bootstrap/positioning"],t):t((e["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].dropdown={}),e.ng.core,e.utils,e.rxjs.operators,e.componentLoader,e.positioning)}(this,function(e,n,s,i,o,r){"use strict";function p(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}}}}var a=function(){function e(){this.autoClose=!0,this.insideClick=!1}return e.decorators=[{type:n.Injectable}],e}(),d=function(){function e(){var t=this;this.direction="down",this.isOpenChange=new n.EventEmitter,this.isDisabledChange=new n.EventEmitter,this.toggleClick=new n.EventEmitter,this.dropdownMenu=new Promise(function(e){t.resolveDropdownMenu=e})}return e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[]},e}(),u=function(){function e(e,t,n,i){var o=this;this._state=e,this.cd=t,this._renderer=n,this._element=i,this.isOpen=!1,this._subscription=e.isOpenChange.subscribe(function(e){o.isOpen=e;var t=o._element.nativeElement.querySelector(".dropdown-menu");t&&!s.isBs3()&&(o._renderer.addClass(t,"show"),t.classList.contains("dropdown-menu-right")&&(o._renderer.setStyle(t,"left","auto"),o._renderer.setStyle(t,"right","0")),"up"===o.direction&&(o._renderer.setStyle(t,"top","auto"),o._renderer.setStyle(t,"transform","translateY(-101%)"))),o.cd.markForCheck(),o.cd.detectChanges()})}return Object.defineProperty(e.prototype,"direction",{get:function(){return this._state.direction},enumerable:!0,configurable:!0}),e.prototype._contains=function(e){return this._element.nativeElement.contains(e)},e.prototype.ngOnDestroy=function(){this._subscription.unsubscribe()},e.decorators=[{type:n.Component,args:[{selector:"bs-dropdown-container",changeDetection:n.ChangeDetectionStrategy.OnPush,host:{style:"display:block;position: absolute;"},template:'\n <div [class.dropup]="direction === \'up\'"\n [class.dropdown]="direction === \'down\'"\n [class.show]="isOpen"\n [class.open]="isOpen"><ng-content></ng-content></div>\n '}]}],e.ctorParameters=function(){return[{type:d},{type:n.ChangeDetectorRef},{type:n.Renderer2},{type:n.ElementRef}]},e}(),c=function(){function e(e,t,n,i,o,s){this._elementRef=e,this._renderer=t,this._viewContainerRef=n,this._cis=i,this._config=o,this._state=s,this._isInlineOpen=!1,this._subscriptions=[],this._isInited=!1,this._state.autoClose=this._config.autoClose,this._state.insideClick=this._config.insideClick,this._dropdown=this._cis.createLoader(this._elementRef,this._viewContainerRef,this._renderer).provide({provide:d,useValue:this._state}),this.onShown=this._dropdown.onShown,this.onHidden=this._dropdown.onHidden,this.isOpenChange=this._state.isOpenChange}return Object.defineProperty(e.prototype,"autoClose",{get:function(){return this._state.autoClose},set:function(e){this._state.autoClose=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"insideClick",{get:function(){return this._state.insideClick},set:function(e){this._state.insideClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this._isDisabled},set:function(e){this._isDisabled=e,this._state.isDisabledChange.emit(e),e&&this.hide()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isOpen",{get:function(){return this._showInline?this._isInlineOpen:this._dropdown.isShown},set:function(e){e?this.show():this.hide()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBs4",{get:function(){return!s.isBs3()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_showInline",{get:function(){return!this.container},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var t=this;this._isInited||(this._isInited=!0,this._dropdown.listen({outsideClick:!1,triggers:this.triggers,show:function(){return t.show()}}),this._subscriptions.push(this._state.toggleClick.subscribe(function(e){return t.toggle(e)})),this._subscriptions.push(this._state.isDisabledChange.pipe(i.filter(function(e){return e})).subscribe(function(e){return t.hide()})))},e.prototype.show=function(){var i=this;if(!this.isOpen&&!this.isDisabled)return this._showInline?(this._inlinedMenu||this._state.dropdownMenu.then(function(e){i._dropdown.attachInline(e.viewContainer,e.templateRef),i._inlinedMenu=i._dropdown._inlineViewRef,i.addBs4Polyfills()})["catch"](),this.addBs4Polyfills(),this._isInlineOpen=!0,this.onShown.emit(!0),void this._state.isOpenChange.emit(!0)):void this._state.dropdownMenu.then(function(e){var t=i.dropup||"undefined"!=typeof i.dropup&&i.dropup;i._state.direction=t?"up":"down";var n=i.placement||(t?"top left":"bottom left");i._dropdown.attach(u).to(i.container).position({attachment:n}).show({content:e.templateRef,placement:n}),i._state.isOpenChange.emit(!0)})["catch"]()},e.prototype.hide=function(){this.isOpen&&(this._showInline?(this.removeShowClass(),this.removeDropupStyles(),this._isInlineOpen=!1,this.onHidden.emit(!0)):this._dropdown.hide(),this._state.isOpenChange.emit(!1))},e.prototype.toggle=function(e){return this.isOpen||!e?this.hide():this.show()},e.prototype._contains=function(e){return this._elementRef.nativeElement.contains(e.target)||this._dropdown.instance&&this._dropdown.instance._contains(e.target)},e.prototype.ngOnDestroy=function(){try{for(var e=p(this._subscriptions),t=e.next();!t.done;t=e.next()){t.value.unsubscribe()}}catch(o){n={error:o}}finally{try{t&&!t.done&&(i=e["return"])&&i.call(e)}finally{if(n)throw n.error}}var n,i;this._dropdown.dispose()},e.prototype.addBs4Polyfills=function(){s.isBs3()||(this.addShowClass(),this.checkRightAlignment(),this.addDropupStyles())},e.prototype.addShowClass=function(){this._inlinedMenu&&this._inlinedMenu.rootNodes[0]&&this._renderer.addClass(this._inlinedMenu.rootNodes[0],"show")},e.prototype.removeShowClass=function(){this._inlinedMenu&&this._inlinedMenu.rootNodes[0]&&this._renderer.removeClass(this._inlinedMenu.rootNodes[0],"show")},e.prototype.checkRightAlignment=function(){if(this._inlinedMenu&&this._inlinedMenu.rootNodes[0]){var e=this._inlinedMenu.rootNodes[0].classList.contains("dropdown-menu-right");this._renderer.setStyle(this._inlinedMenu.rootNodes[0],"left",e?"auto":"0"),this._renderer.setStyle(this._inlinedMenu.rootNodes[0],"right",e?"0":"auto")}},e.prototype.addDropupStyles=function(){this._inlinedMenu&&this._inlinedMenu.rootNodes[0]&&(this._renderer.setStyle(this._inlinedMenu.rootNodes[0],"top",this.dropup?"auto":"100%"),this._renderer.setStyle(this._inlinedMenu.rootNodes[0],"transform",this.dropup?"translateY(-101%)":"translateY(0)"),this._renderer.setStyle(this._inlinedMenu.rootNodes[0],"bottom","auto"))},e.prototype.removeDropupStyles=function(){this._inlinedMenu&&this._inlinedMenu.rootNodes[0]&&(this._renderer.removeStyle(this._inlinedMenu.rootNodes[0],"top"),this._renderer.removeStyle(this._inlinedMenu.rootNodes[0],"transform"),this._renderer.removeStyle(this._inlinedMenu.rootNodes[0],"bottom"))},e.decorators=[{type:n.Directive,args:[{selector:"[bsDropdown],[dropdown]",exportAs:"bs-dropdown",providers:[d],host:{"[class.dropup]":"dropup","[class.open]":"isOpen","[class.show]":"isOpen && isBs4"}}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.Renderer2},{type:n.ViewContainerRef},{type:o.ComponentLoaderFactory},{type:a},{type:d}]},e.propDecorators={placement:[{type:n.Input}],triggers:[{type:n.Input}],container:[{type:n.Input}],dropup:[{type:n.Input}],autoClose:[{type:n.Input}],insideClick:[{type:n.Input}],isDisabled:[{type:n.Input}],isOpen:[{type:n.Input}],isOpenChange:[{type:n.Output}],onShown:[{type:n.Output}],onHidden:[{type:n.Output}]},e}(),l=function(){function e(e,t,n){e.resolveDropdownMenu({templateRef:n,viewContainer:t})}return e.decorators=[{type:n.Directive,args:[{selector:"[bsDropdownMenu],[dropdownMenu]",exportAs:"bs-dropdown-menu"}]}],e.ctorParameters=function(){return[{type:d},{type:n.ViewContainerRef},{type:n.TemplateRef}]},e}(),h=function(){function e(e,t,n){var i=this;this._state=e,this._element=t,this.dropdown=n,this.isDisabled=null,this._subscriptions=[],this._subscriptions.push(this._state.isOpenChange.subscribe(function(e){return i.isOpen=e})),this._subscriptions.push(this._state.isDisabledChange.subscribe(function(e){return i.isDisabled=e||null}))}return e.prototype.onClick=function(){this.isDisabled||this._state.toggleClick.emit(!0)},e.prototype.onDocumentClick=function(e){!this._state.autoClose||2===e.button||this._element.nativeElement.contains(e.target)||this._state.insideClick&&this.dropdown._contains(e)||this._state.toggleClick.emit(!1)},e.prototype.onEsc=function(){this._state.autoClose&&this._state.toggleClick.emit(!1)},e.prototype.ngOnDestroy=function(){try{for(var e=p(this._subscriptions),t=e.next();!t.done;t=e.next()){t.value.unsubscribe()}}catch(o){n={error:o}}finally{try{t&&!t.done&&(i=e["return"])&&i.call(e)}finally{if(n)throw n.error}}var n,i},e.decorators=[{type:n.Directive,args:[{selector:"[bsDropdownToggle],[dropdownToggle]",exportAs:"bs-dropdown-toggle",host:{"[attr.aria-haspopup]":"true"}}]}],e.ctorParameters=function(){return[{type:d},{type:n.ElementRef},{type:c}]},e.propDecorators={isDisabled:[{type:n.HostBinding,args:["attr.disabled"]}],isOpen:[{type:n.HostBinding,args:["attr.aria-expanded"]}],onClick:[{type:n.HostListener,args:["click",[]]}],onDocumentClick:[{type:n.HostListener,args:["document:click",["$event"]]}],onEsc:[{type:n.HostListener,args:["keyup.esc"]}]},e}(),t=function(){function t(){}return t.forRoot=function(e){return{ngModule:t,providers:[o.ComponentLoaderFactory,r.PositioningService,d,{provide:a,useValue:e||{autoClose:!0,insideClick:!1}}]}},t.decorators=[{type:n.NgModule,args:[{declarations:[l,h,u,c],exports:[l,h,c],entryComponents:[u]}]}],t}();e.BsDropdownDirective=c,e.BsDropdownMenuDirective=l,e.BsDropdownToggleDirective=h,e.BsDropdownContainerComponent=u,e.BsDropdownState=d,e.BsDropdownConfig=a,e.BsDropdownModule=t,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-bootstrap-dropdown.umd.min.js.map