ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 13.7 kB
JavaScript
!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/logger"),require("ng-zorro-antd/core/overlay"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/bidi"),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/logger","ng-zorro-antd/core/overlay","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/cdk/bidi","@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="undefined"!=typeof globalThis?globalThis: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.logger,e["ng-zorro-antd"].core.overlay,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e.ng.cdk.bidi,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,d,u,y,f,h,v,g,m,z){"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 b(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 w(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;function M(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 R=[s.POSITION_MAP.bottomLeft,s.POSITION_MAP.bottomRight,s.POSITION_MAP.topRight,s.POSITION_MAP.topLeft],C=function(){function e(e,t,n,o,r){this.elementRef=e,this.overlay=t,this.renderer=n,this.viewContainerRef=o,this.platform=r,this.overlayRef=null,this.destroy$=new p.Subject,this.positionStrategy=this.overlay.position().flexibleConnectedTo(this.elementRef.nativeElement).withLockedPosition().withTransformOriginOn(".ant-dropdown"),this.inputVisible$=new p.BehaviorSubject(!1),this.nzTrigger$=new p.BehaviorSubject("hover"),this.overlayClose$=new p.Subject,this.nzDropdownMenu=null,this.nzTrigger="hover",this.nzMatchWidthElement=null,this.nzBackdrop=!1,this.nzHasBackdrop=!1,this.nzClickHide=!0,this.nzDisabled=!1,this.nzVisible=!1,this.nzOverlayClassName="",this.nzOverlayStyle={},this.nzPlacement="bottomLeft",this.nzVisibleChange=new i.EventEmitter,this.elementRef.nativeElement.classList.add("ant-dropdown-trigger")}return e.prototype.setDropdownMenuValue=function(e,t){this.nzDropdownMenu&&this.nzDropdownMenu.setValue(e,t)},e.prototype.ngOnInit=function(){},e.prototype.ngAfterViewInit=function(){var e=this;if(this.nzDropdownMenu){var n=this.elementRef.nativeElement,o=p.merge(p.fromEvent(n,"mouseenter").pipe(c.mapTo(!0)),p.fromEvent(n,"mouseleave").pipe(c.mapTo(!1))),i=this.nzDropdownMenu.mouseState$,a=p.merge(i,o),l=p.fromEvent(n,"click").pipe(c.map((function(){return!e.nzVisible}))),d=this.nzTrigger$.pipe(c.switchMap((function(e){return"hover"===e?a:"click"===e?l:p.EMPTY}))),u=this.nzDropdownMenu.descendantMenuItemClick$.pipe(c.filter((function(){return e.nzClickHide})),c.mapTo(!1)),y=p.merge(d,u,this.overlayClose$).pipe(c.filter((function(){return!e.nzDisabled}))),f=p.merge(this.inputVisible$,y);p.combineLatest([f,this.nzDropdownMenu.isChildSubMenuOpen$]).pipe(c.map((function(e){var t=M(e,2),n=t[0],o=t[1];return n||o})),c.auditTime(150),c.distinctUntilChanged(),c.filter((function(){return e.platform.isBrowser})),c.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)e.overlayRef.getConfig().minWidth=i;else e.overlayRef=e.overlay.create({positionStrategy:e.positionStrategy,minWidth:i,disposeOnNavigation:!0,hasBackdrop:(e.nzHasBackdrop||e.nzBackdrop)&&"click"===e.nzTrigger,scrollStrategy:e.overlay.scrollStrategies.reposition()}),p.merge(e.overlayRef.backdropClick(),e.overlayRef.detachments(),e.overlayRef.outsidePointerEvents().pipe(c.filter((function(t){return!e.elementRef.nativeElement.contains(t.target)}))),e.overlayRef.keydownEvents().pipe(c.filter((function(e){return e.keyCode===t.ESCAPE&&!t.hasModifierKey(e)})))).pipe(c.mapTo(!1),c.takeUntil(e.destroy$)).subscribe(e.overlayClose$);e.positionStrategy.withPositions(function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(M(arguments[t]));return e}([s.POSITION_MAP[e.nzPlacement]],R)),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.nzDisabled,o=e.nzOverlayClassName,r=e.nzOverlayStyle,i=e.nzTrigger,s=e.nzBackdrop;if(i&&this.nzTrigger$.next(this.nzTrigger),t&&this.inputVisible$.next(this.nzVisible),n){var l=this.elementRef.nativeElement;this.nzDisabled?(this.renderer.setAttribute(l,"disabled",""),this.inputVisible$.next(!1)):this.renderer.removeAttribute(l,"disabled")}o&&this.setDropdownMenuValue("nzOverlayClassName",this.nzOverlayClassName),r&&this.setDropdownMenuValue("nzOverlayStyle",this.nzOverlayStyle),s&&a.warnDeprecation("`nzBackdrop` in dropdown component will be removed in 12.0.0, please use `nzHasBackdrop` instead.")},e}();C.decorators=[{type:i.Directive,args:[{selector:"[nz-dropdown]",exportAs:"nzDropdown"}]}],C.ctorParameters=function(){return[{type:i.ElementRef},{type:n.Overlay},{type:i.Renderer2},{type:i.ViewContainerRef},{type:o.Platform}]},C.propDecorators={nzDropdownMenu:[{type:i.Input}],nzTrigger:[{type:i.Input}],nzMatchWidthElement:[{type:i.Input}],nzBackdrop:[{type:i.Input}],nzHasBackdrop:[{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}]},b([l.InputBoolean(),w("design:type",Object)],C.prototype,"nzBackdrop",void 0),b([l.InputBoolean(),w("design:type",Object)],C.prototype,"nzHasBackdrop",void 0),b([l.InputBoolean(),w("design:type",Object)],C.prototype,"nzClickHide",void 0),b([l.InputBoolean(),w("design:type",Object)],C.prototype,"nzDisabled",void 0),b([l.InputBoolean(),w("design:type",Object)],C.prototype,"nzVisible",void 0);var O=function(){};O.decorators=[{type:i.NgModule}];var k=function(e){this.elementRef=e,this.elementRef.nativeElement.classList.add("ant-dropdown-link")};k.decorators=[{type:i.Directive,args:[{selector:"a[nz-dropdown]"}]}],k.ctorParameters=function(){return[{type:i.ElementRef}]};var S=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}();S.decorators=[{type:i.Directive,args:[{selector:"[nz-button][nz-dropdown]"}]}],S.ctorParameters=function(){return[{type:i.Renderer2},{type:f.NzButtonGroupComponent,decorators:[{type:i.Host},{type:i.Optional}]},{type:i.ElementRef}]};var D=function(){function e(e,t,n,o,r,i,a){this.cdr=e,this.elementRef=t,this.renderer=n,this.viewContainerRef=o,this.nzMenuService=r,this.directionality=i,this.noAnimation=a,this.mouseState$=new p.BehaviorSubject(!1),this.isChildSubMenuOpen$=this.nzMenuService.isChildSubMenuOpen$,this.descendantMenuItemClick$=this.nzMenuService.descendantMenuItemClick$,this.nzOverlayClassName="",this.nzOverlayStyle={},this.dir="ltr",this.destroy$=new p.Subject}return e.prototype.setMouseState=function(e){this.mouseState$.next(e)},e.prototype.setValue=function(e,t){this[e]=t,this.cdr.markForCheck()},e.prototype.ngOnInit=function(){var e,t=this;null===(e=this.directionality.change)||void 0===e||e.pipe(c.takeUntil(this.destroy$)).subscribe((function(e){t.dir=e,t.cdr.detectChanges()})),this.dir=this.directionality.value},e.prototype.ngAfterContentInit=function(){this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement),this.elementRef.nativeElement)},e.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},e}();D.decorators=[{type:i.Component,args:[{selector:"nz-dropdown-menu",exportAs:"nzDropdownMenu",animations:[z.slideMotion],providers:[m.MenuService,{provide:m.NzIsMenuInsideDropDownToken,useValue:!0}],template:'\n <ng-template>\n <div\n class="ant-dropdown"\n [class.ant-dropdown-rtl]="dir === \'rtl\'"\n [ngClass]="nzOverlayClassName"\n [ngStyle]="nzOverlayStyle"\n [@slideMotion]="\'enter\'"\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}]}],D.ctorParameters=function(){return[{type:i.ChangeDetectorRef},{type:i.ElementRef},{type:i.Renderer2},{type:i.ViewContainerRef},{type:m.MenuService},{type:d.Directionality,decorators:[{type:i.Optional}]},{type:h.NzNoAnimationDirective,decorators:[{type:i.Host},{type:i.Optional}]}]},D.propDecorators={templateRef:[{type:i.ViewChild,args:[i.TemplateRef,{static:!0}]}]};var I=function(){};I.decorators=[{type:i.NgModule,args:[{imports:[d.BidiModule,u.CommonModule,n.OverlayModule,y.FormsModule,f.NzButtonModule,m.NzMenuModule,g.NzIconModule,h.NzNoAnimationModule,o.PlatformModule,s.NzOverlayModule,O,v.NzOutletModule],entryComponents:[D],declarations:[C,k,D,S],exports:[m.NzMenuModule,C,k,D,S]}]}];var N=[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=p.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(N).withTransformOriginOn(".ant-dropdown");this.overlayRef=this.overlay.create({positionStrategy:a,disposeOnNavigation:!0,scrollStrategy:this.overlay.scrollStrategies.close()}),this.closeSubscription=p.merge(t.descendantMenuItemClick$,p.fromEvent(document,"click").pipe(c.filter((function(e){return!!n.overlayRef&&!n.overlayRef.overlayElement.contains(e.target)})),c.filter((function(e){return 2!==e.button})),c.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}();P.ɵprov=i.ɵɵdefineInjectable({factory:function(){return new P(i.ɵɵinject(n.Overlay))},token:P,providedIn:O}),P.decorators=[{type:i.Injectable,args:[{providedIn:O}]}],P.ctorParameters=function(){return[{type:n.Overlay}]},e.NzContextMenuService=P,e.NzContextMenuServiceModule=O,e.NzDropDownADirective=k,e.NzDropDownDirective=C,e.NzDropDownModule=I,e.NzDropdownButtonDirective=S,e.NzDropdownMenuComponent=D,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-dropdown.umd.min.js.map