ngx-bootstrap-fix-datepicker
Version:
Native Angular Bootstrap Components
16 lines (14 loc) • 12.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs/operators"),require("ngx-bootstrap/component-loader"),require("ngx-bootstrap/utils"),require("@angular/animations"),require("ngx-bootstrap/positioning")):"function"==typeof define&&define.amd?define("ngx-bootstrap/dropdown",["exports","@angular/core","rxjs/operators","ngx-bootstrap/component-loader","ngx-bootstrap/utils","@angular/animations","ngx-bootstrap/positioning"],t):t(((e=e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].dropdown={}),e.ng.core,e.rxjs.operators,e.componentLoader,e.utils,e.ng.animations,e.positioning)}(this,(function(e,t,n,i,o,s,r){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function a(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 d=function(){function e(){this.autoClose=!0,this.insideClick=!1,this.isAnimated=!1}return e.decorators=[{type:t.Injectable}],e}();var p=function(){function e(){var e=this;this.direction="down",this.isOpenChange=new t.EventEmitter,this.isDisabledChange=new t.EventEmitter,this.toggleClick=new t.EventEmitter,this.dropdownMenu=new Promise((function(t){e.resolveDropdownMenu=t}))}return e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[]},e}();var u=[s.style({height:0,overflow:"hidden"}),s.animate("220ms cubic-bezier(0, 0, 0.2, 1)",s.style({height:"*",overflow:"hidden"}))],c=function(){function e(e,t,n,i,s){var r=this;this._state=e,this.cd=t,this._renderer=n,this._element=i,this.isOpen=!1,this._factoryDropDownAnimation=s.build(u),this._subscription=e.isOpenChange.subscribe((function(e){r.isOpen=e;var t=r._element.nativeElement.querySelector(".dropdown-menu");r._renderer.addClass(r._element.nativeElement.querySelector("div"),"open"),t&&!o.isBs3()&&(r._renderer.addClass(t,"show"),t.classList.contains("dropdown-menu-right")&&(r._renderer.setStyle(t,"left","auto"),r._renderer.setStyle(t,"right","0")),"up"===r.direction&&(r._renderer.setStyle(t,"top","auto"),r._renderer.setStyle(t,"transform","translateY(-101%)"))),t&&r._state.isAnimated&&r._factoryDropDownAnimation.create(t).play(),r.cd.markForCheck(),r.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:t.Component,args:[{selector:"bs-dropdown-container",changeDetection:t.ChangeDetectionStrategy.OnPush,host:{style:"display:block;position: absolute;z-index: 1040"},template:'\n <div [class.dropup]="direction === \'up\'"\n [class.dropdown]="direction === \'down\'"\n [class.show]="isOpen"\n [class.open]="isOpen"><ng-content></ng-content>\n </div>\n '}]}],e.ctorParameters=function(){return[{type:p},{type:t.ChangeDetectorRef},{type:t.Renderer2},{type:t.ElementRef},{type:s.AnimationBuilder}]},e}();var l=function(){function e(e,t,n,i,o,s,r){this._elementRef=e,this._renderer=t,this._viewContainerRef=n,this._cis=i,this._state=o,this._config=s,this._isInlineOpen=!1,this._subscriptions=[],this._isInited=!1,this._state.autoClose=this._config.autoClose,this._state.insideClick=this._config.insideClick,this._state.isAnimated=this._config.isAnimated,this._factoryDropDownAnimation=r.build(u),this._dropdown=this._cis.createLoader(this._elementRef,this._viewContainerRef,this._renderer).provide({provide:p,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,"isAnimated",{get:function(){return this._state.isAnimated},set:function(e){this._state.isAnimated=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!o.isBs3()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_showInline",{get:function(){return!this.container},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this._isInited||(this._isInited=!0,this._dropdown.listen({outsideClick:!1,triggers:this.triggers,show:function(){return e.show()}}),this._subscriptions.push(this._state.toggleClick.subscribe((function(t){return e.toggle(t)}))),this._subscriptions.push(this._state.isDisabledChange.pipe(n.filter((function(e){return e}))).subscribe((function(t){return e.hide()}))))},e.prototype.show=function(){var e=this;if(!this.isOpen&&!this.isDisabled)return this._showInline?(this._inlinedMenu||this._state.dropdownMenu.then((function(t){e._dropdown.attachInline(t.viewContainer,t.templateRef),e._inlinedMenu=e._dropdown._inlineViewRef,e.addBs4Polyfills(),e._renderer.addClass(e._inlinedMenu.rootNodes[0].parentNode,"open"),e.playAnimation()})).catch(),this.addBs4Polyfills(),this._isInlineOpen=!0,this.onShown.emit(!0),this._state.isOpenChange.emit(!0),void this.playAnimation()):void this._state.dropdownMenu.then((function(t){var n=e.dropup||void 0!==e.dropup&&e.dropup;e._state.direction=n?"up":"down";var i=e.placement||(n?"top start":"bottom start");e._dropdown.attach(c).to(e.container).position({attachment:i}).show({content:t.templateRef,placement:i}),e._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(){var e,t;try{for(var n=a(this._subscriptions),i=n.next();!i.done;i=n.next()){i.value.unsubscribe()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._dropdown.dispose()},e.prototype.addBs4Polyfills=function(){o.isBs3()||(this.addShowClass(),this.checkRightAlignment(),this.addDropupStyles())},e.prototype.playAnimation=function(){var e=this;this._state.isAnimated&&this._inlinedMenu&&setTimeout((function(){e._factoryDropDownAnimation.create(e._inlinedMenu.rootNodes[0]).play()}))},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:t.Directive,args:[{selector:"[bsDropdown],[dropdown]",exportAs:"bs-dropdown",providers:[p],host:{"[class.dropup]":"dropup","[class.open]":"isOpen","[class.show]":"isOpen && isBs4"}}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:t.ViewContainerRef},{type:i.ComponentLoaderFactory},{type:p},{type:d},{type:s.AnimationBuilder}]},e.propDecorators={placement:[{type:t.Input}],triggers:[{type:t.Input}],container:[{type:t.Input}],dropup:[{type:t.Input}],autoClose:[{type:t.Input}],isAnimated:[{type:t.Input}],insideClick:[{type:t.Input}],isDisabled:[{type:t.Input}],isOpen:[{type:t.Input}],isOpenChange:[{type:t.Output}],onShown:[{type:t.Output}],onHidden:[{type:t.Output}]},e}();var h=function(){function e(e,t,n){e.resolveDropdownMenu({templateRef:n,viewContainer:t})}return e.decorators=[{type:t.Directive,args:[{selector:"[bsDropdownMenu],[dropdownMenu]",exportAs:"bs-dropdown-menu"}]}],e.ctorParameters=function(){return[{type:p},{type:t.ViewContainerRef},{type:t.TemplateRef}]},e}(),_=function(){function e(e,t,n,i,o){var s=this;this._changeDetectorRef=e,this._dropdown=t,this._element=n,this._renderer=i,this._state=o,this.isDisabled=null,this._subscriptions=[],this._subscriptions.push(this._state.isOpenChange.subscribe((function(e){s.isOpen=e,e?(s._documentClickListener=s._renderer.listen("document","click",(function(e){!s._state.autoClose||2===e.button||s._element.nativeElement.contains(e.target)||s._state.insideClick&&s._dropdown._contains(e)||(s._state.toggleClick.emit(!1),s._changeDetectorRef.detectChanges())})),s._escKeyUpListener=s._renderer.listen(s._element.nativeElement,"keyup.esc",(function(){s._state.autoClose&&(s._state.toggleClick.emit(!1),s._changeDetectorRef.detectChanges())}))):(s._documentClickListener(),s._escKeyUpListener())}))),this._subscriptions.push(this._state.isDisabledChange.subscribe((function(e){return s.isDisabled=e||null})))}return e.prototype.onClick=function(){this.isDisabled||this._state.toggleClick.emit(!0)},e.prototype.ngOnDestroy=function(){var e,t;this._documentClickListener&&this._documentClickListener(),this._escKeyUpListener&&this._escKeyUpListener();try{for(var n=a(this._subscriptions),i=n.next();!i.done;i=n.next()){i.value.unsubscribe()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.decorators=[{type:t.Directive,args:[{selector:"[bsDropdownToggle],[dropdownToggle]",exportAs:"bs-dropdown-toggle",host:{"[attr.aria-haspopup]":"true"}}]}],e.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:l},{type:t.ElementRef},{type:t.Renderer2},{type:p}]},e.propDecorators={isDisabled:[{type:t.HostBinding,args:["attr.disabled"]}],isOpen:[{type:t.HostBinding,args:["attr.aria-expanded"]}],onClick:[{type:t.HostListener,args:["click",[]]}]},e}();var f=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[i.ComponentLoaderFactory,r.PositioningService,p,{provide:d,useValue:t||{autoClose:!0,insideClick:!1}}]}},e.decorators=[{type:t.NgModule,args:[{declarations:[h,_,c,l],exports:[h,_,l],entryComponents:[c]}]}],e}();e.BsDropdownConfig=d,e.BsDropdownContainerComponent=c,e.BsDropdownDirective=l,e.BsDropdownMenuDirective=h,e.BsDropdownModule=f,e.BsDropdownState=p,e.BsDropdownToggleDirective=_,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-bootstrap-dropdown.umd.min.js.map