UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

16 lines (14 loc) 12.9 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/keycodes"),require("@angular/cdk/overlay"),require("@angular/cdk/platform"),require("@angular/cdk/portal"),require("@angular/core"),require("ng-zorro-antd/core/overlay"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/forms"),require("ng-zorro-antd/button"),require("ng-zorro-antd/core/no-animation"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/menu"),require("ng-zorro-antd/core/animation")):"function"==typeof define&&define.amd?define("ng-zorro-antd/dropdown",["exports","@angular/cdk/keycodes","@angular/cdk/overlay","@angular/cdk/platform","@angular/cdk/portal","@angular/core","ng-zorro-antd/core/overlay","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/common","@angular/forms","ng-zorro-antd/button","ng-zorro-antd/core/no-animation","ng-zorro-antd/core/outlet","ng-zorro-antd/icon","ng-zorro-antd/menu","ng-zorro-antd/core/animation"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].dropdown={}),e.ng.cdk.keycodes,e.ng.cdk.overlay,e.ng.cdk.platform,e.ng.cdk.portal,e.ng.core,e["ng-zorro-antd"].core.overlay,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e.ng.common,e.ng.forms,e["ng-zorro-antd"].button,e["ng-zorro-antd"].core["no-animation"],e["ng-zorro-antd"].core.outlet,e["ng-zorro-antd"].icon,e["ng-zorro-antd"].menu,e["ng-zorro-antd"].core.animation)}(this,(function(e,t,n,o,r,i,a,s,l,p,c,u,d,y,f,h,v,m){"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. ***************************************************************************** */function g(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function z(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}Object.create;var w=[a.POSITION_MAP.bottomLeft,a.POSITION_MAP.bottomRight,a.POSITION_MAP.topRight,a.POSITION_MAP.topLeft],M=function(){function e(e,t,n,o){this.elementRef=e,this.overlay=t,this.viewContainerRef=n,this.platform=o,this.overlayRef=null,this.destroy$=new l.Subject,this.positionStrategy=this.overlay.position().flexibleConnectedTo(this.elementRef.nativeElement).withLockedPosition(),this.inputVisible$=new l.BehaviorSubject(!1),this.nzTrigger$=new l.BehaviorSubject("hover"),this.overlayClose$=new l.Subject,this.nzDropdownMenu=null,this.nzTrigger="hover",this.nzMatchWidthElement=null,this.nzBackdrop=!0,this.nzClickHide=!0,this.nzDisabled=!1,this.nzVisible=!1,this.nzOverlayClassName="",this.nzOverlayStyle={},this.nzPlacement="bottomLeft",this.nzVisibleChange=new i.EventEmitter}return e.prototype.setDropdownMenuValue=function(e,t){this.nzDropdownMenu&&this.nzDropdownMenu.setValue(e,t)},e.prototype.ngOnInit=function(){var e=this;this.positionStrategy.positionChanges.pipe(p.takeUntil(this.destroy$)).subscribe((function(t){e.setDropdownMenuValue("dropDownPosition",t.connectionPair.originY)}))},e.prototype.ngAfterViewInit=function(){var e=this;if(this.nzDropdownMenu){var n=this.elementRef.nativeElement,o=l.merge(l.fromEvent(n,"mouseenter").pipe(p.mapTo(!0)),l.fromEvent(n,"mouseleave").pipe(p.mapTo(!1))),i=this.nzDropdownMenu.mouseState$,s=l.merge(i,o),c=l.fromEvent(n,"click").pipe(p.mapTo(!0)),u=this.nzTrigger$.pipe(p.switchMap((function(e){return"hover"===e?s:"click"===e?c:l.EMPTY}))),d=this.nzDropdownMenu.descendantMenuItemClick$.pipe(p.filter((function(){return e.nzClickHide})),p.mapTo(!1)),y=l.merge(u,d,this.overlayClose$).pipe(p.filter((function(){return!e.nzDisabled}))),f=l.merge(this.inputVisible$,y);l.combineLatest([f,this.nzDropdownMenu.isChildSubMenuOpen$]).pipe(p.map((function(e){var t=b(e,2),n=t[0],o=t[1];return n||o})),p.auditTime(150),p.distinctUntilChanged(),p.filter((function(){return e.platform.isBrowser})),p.takeUntil(this.destroy$)).subscribe((function(o){var i=(e.nzMatchWidthElement?e.nzMatchWidthElement.nativeElement:n).getBoundingClientRect().width;if(e.nzVisible!==o&&e.nzVisibleChange.emit(o),e.nzVisible=o,o){if(e.overlayRef){var s=e.overlayRef.getConfig();s.minWidth=i,s.hasBackdrop="click"===e.nzTrigger}else e.overlayRef=e.overlay.create({positionStrategy:e.positionStrategy,minWidth:i,disposeOnNavigation:!0,hasBackdrop:"click"===e.nzTrigger,backdropClass:e.nzBackdrop?void 0:"nz-overlay-transparent-backdrop",scrollStrategy:e.overlay.scrollStrategies.reposition()}),l.merge(e.overlayRef.backdropClick(),e.overlayRef.detachments(),e.overlayRef.keydownEvents().pipe(p.filter((function(e){return e.keyCode===t.ESCAPE&&!t.hasModifierKey(e)})))).pipe(p.mapTo(!1),p.takeUntil(e.destroy$)).subscribe(e.overlayClose$);e.positionStrategy.withPositions(function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}([a.POSITION_MAP[e.nzPlacement]],w)),e.portal&&e.portal.templateRef===e.nzDropdownMenu.templateRef||(e.portal=new r.TemplatePortal(e.nzDropdownMenu.templateRef,e.viewContainerRef)),e.overlayRef.attach(e.portal)}else e.overlayRef&&e.overlayRef.detach()}))}},e.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.overlayRef&&(this.overlayRef.dispose(),this.overlayRef=null)},e.prototype.ngOnChanges=function(e){var t=e.nzVisible,n=e.nzPlacement,o=e.nzDisabled,r=e.nzOverlayClassName,i=e.nzOverlayStyle;e.nzTrigger&&this.nzTrigger$.next(this.nzTrigger),t&&this.inputVisible$.next(this.nzVisible),o&&this.nzDisabled&&this.inputVisible$.next(!1),r&&this.setDropdownMenuValue("nzOverlayClassName",this.nzOverlayClassName),i&&this.setDropdownMenuValue("nzOverlayStyle",this.nzOverlayStyle),n&&this.setDropdownMenuValue("dropDownPosition",-1!==this.nzPlacement.indexOf("top")?"top":"bottom")},e.decorators=[{type:i.Directive,args:[{selector:"[nz-dropdown]",exportAs:"nzDropdown",host:{"[attr.disabled]":"nzDisabled ? '' : null","[class.ant-dropdown-trigger]":"true"}}]}],e.ctorParameters=function(){return[{type:i.ElementRef},{type:n.Overlay},{type:i.ViewContainerRef},{type:o.Platform}]},e.propDecorators={nzDropdownMenu:[{type:i.Input}],nzTrigger:[{type:i.Input}],nzMatchWidthElement:[{type:i.Input}],nzBackdrop:[{type:i.Input}],nzClickHide:[{type:i.Input}],nzDisabled:[{type:i.Input}],nzVisible:[{type:i.Input}],nzOverlayClassName:[{type:i.Input}],nzOverlayStyle:[{type:i.Input}],nzPlacement:[{type:i.Input}],nzVisibleChange:[{type:i.Output}]},g([s.InputBoolean(),z("design:type",Object)],e.prototype,"nzBackdrop",void 0),g([s.InputBoolean(),z("design:type",Object)],e.prototype,"nzClickHide",void 0),g([s.InputBoolean(),z("design:type",Object)],e.prototype,"nzDisabled",void 0),g([s.InputBoolean(),z("design:type",Object)],e.prototype,"nzVisible",void 0),e}();var C=function(){function e(){}return e.decorators=[{type:i.NgModule}],e}(),R=function(){function e(){}return e.decorators=[{type:i.Directive,args:[{selector:"a[nz-dropdown]",host:{"[class.ant-dropdown-link]":"true"}}]}],e}(),D=function(){function e(e,t,n){this.renderer=e,this.nzButtonGroupComponent=t,this.elementRef=n}return e.prototype.ngAfterViewInit=function(){var e=this.renderer.parentNode(this.elementRef.nativeElement);this.nzButtonGroupComponent&&e&&this.renderer.addClass(e,"ant-dropdown-button")},e.decorators=[{type:i.Directive,args:[{selector:"[nz-button][nz-dropdown]"}]}],e.ctorParameters=function(){return[{type:i.Renderer2},{type:d.NzButtonGroupComponent,decorators:[{type:i.Host},{type:i.Optional}]},{type:i.ElementRef}]},e}();var O=function(){function e(e,t,n,o,r,i){this.cdr=e,this.elementRef=t,this.renderer=n,this.viewContainerRef=o,this.nzMenuService=r,this.noAnimation=i,this.dropDownPosition="bottom",this.mouseState$=new l.BehaviorSubject(!1),this.isChildSubMenuOpen$=this.nzMenuService.isChildSubMenuOpen$,this.descendantMenuItemClick$=this.nzMenuService.descendantMenuItemClick$,this.nzOverlayClassName="",this.nzOverlayStyle={}}return e.prototype.setMouseState=function(e){this.mouseState$.next(e)},e.prototype.setValue=function(e,t){this[e]=t,this.cdr.markForCheck()},e.prototype.ngAfterContentInit=function(){this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement),this.elementRef.nativeElement)},e.decorators=[{type:i.Component,args:[{selector:"nz-dropdown-menu",exportAs:"nzDropdownMenu",animations:[m.slideMotion],providers:[v.MenuService,{provide:v.NzIsMenuInsideDropDownToken,useValue:!0}],template:'\n <ng-template>\n <div\n class="ant-dropdown"\n [ngClass]="nzOverlayClassName"\n [ngStyle]="nzOverlayStyle"\n [@slideMotion]="dropDownPosition"\n [@.disabled]="noAnimation?.nzNoAnimation"\n [nzNoAnimation]="noAnimation?.nzNoAnimation"\n (mouseenter)="setMouseState(true)"\n (mouseleave)="setMouseState(false)"\n >\n <ng-content></ng-content>\n </div>\n </ng-template>\n ',preserveWhitespaces:!1,encapsulation:i.ViewEncapsulation.None,changeDetection:i.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:i.ChangeDetectorRef},{type:i.ElementRef},{type:i.Renderer2},{type:i.ViewContainerRef},{type:v.MenuService},{type:y.NzNoAnimationDirective,decorators:[{type:i.Host},{type:i.Optional}]}]},e.propDecorators={templateRef:[{type:i.ViewChild,args:[i.TemplateRef,{static:!0}]}]},e}();var S=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{imports:[c.CommonModule,n.OverlayModule,u.FormsModule,d.NzButtonModule,v.NzMenuModule,h.NzIconModule,y.NzNoAnimationModule,o.PlatformModule,a.NzOverlayModule,C,f.NzOutletModule],entryComponents:[O],declarations:[M,R,O,D],exports:[v.NzMenuModule,M,R,O,D]}]}],e}(),k=[new n.ConnectionPositionPair({originX:"start",originY:"top"},{overlayX:"start",overlayY:"top"}),new n.ConnectionPositionPair({originX:"start",originY:"top"},{overlayX:"start",overlayY:"bottom"}),new n.ConnectionPositionPair({originX:"start",originY:"top"},{overlayX:"end",overlayY:"bottom"}),new n.ConnectionPositionPair({originX:"start",originY:"top"},{overlayX:"end",overlayY:"top"})],P=function(){function e(e){this.overlay=e,this.overlayRef=null,this.closeSubscription=l.Subscription.EMPTY}return e.prototype.create=function(e,t){var n=this;this.close(!0);var o=e.x,i=e.y;e instanceof MouseEvent&&e.preventDefault();var a=this.overlay.position().flexibleConnectedTo({x:o,y:i}).withPositions(k);this.overlayRef=this.overlay.create({positionStrategy:a,disposeOnNavigation:!0,scrollStrategy:this.overlay.scrollStrategies.close()}),a.positionChanges.subscribe((function(e){t.setValue("dropDownPosition","bottom"===e.connectionPair.overlayY?"top":"bottom")})),this.closeSubscription=l.merge(t.descendantMenuItemClick$,l.fromEvent(document,"click").pipe(p.filter((function(e){return!!n.overlayRef&&!n.overlayRef.overlayElement.contains(e.target)})),p.filter((function(e){return 2!==e.button})),p.take(1))).subscribe((function(){n.close()})),this.overlayRef.attach(new r.TemplatePortal(t.templateRef,t.viewContainerRef))},e.prototype.close=function(e){void 0===e&&(e=!1),this.overlayRef&&(this.overlayRef.detach(),e&&this.overlayRef.dispose(),this.overlayRef=null,this.closeSubscription.unsubscribe())},e.decorators=[{type:i.Injectable,args:[{providedIn:C}]}],e.ctorParameters=function(){return[{type:n.Overlay}]},e.ɵprov=i.ɵɵdefineInjectable({factory:function(){return new e(i.ɵɵinject(n.Overlay))},token:e,providedIn:C}),e}();e.NzContextMenuService=P,e.NzContextMenuServiceModule=C,e.NzDropDownADirective=R,e.NzDropDownDirective=M,e.NzDropDownModule=S,e.NzDropdownButtonDirective=D,e.NzDropdownMenuComponent=O,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-dropdown.umd.min.js.map