UNPKG

ng-zorro-antd

Version:

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

10 lines 13.6 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/keycodes"),require("@angular/common"),require("@angular/core"),require("@angular/cdk/a11y"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("rxjs"),require("ng-zorro-antd/core"),require("rxjs/operators"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("ng-zorro-antd/drawer",["exports","@angular/cdk/keycodes","@angular/common","@angular/core","@angular/cdk/a11y","@angular/cdk/overlay","@angular/cdk/portal","rxjs","ng-zorro-antd/core","rxjs/operators","ng-zorro-antd/icon"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].drawer={}),e.ng.cdk.keycodes,e.ng.common,e.ng.core,e.ng.cdk.a11y,e.ng.cdk.overlay,e.ng.cdk.portal,e.rxjs,e["ng-zorro-antd"].core,e.rxjs.operators,e["ng-zorro-antd"].icon)}(this,function(e,t,n,r,o,a,i,s,l,c,p){"use strict";var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function f(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function y(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ var d=function(){};var h=function(e){function p(t,n,o,a,i,l,c,p,u){var f=e.call(this)||this;return f.document=t,f.nzConfigService=n,f.renderer=o,f.overlay=a,f.injector=i,f.changeDetectorRef=l,f.focusTrapFactory=c,f.viewContainerRef=p,f.overlayKeyboardDispatcher=u,f.nzClosable=!0,f.nzNoAnimation=!1,f.nzKeyboard=!0,f.nzPlacement="right",f.nzMaskStyle={},f.nzBodyStyle={},f.nzWidth=256,f.nzHeight=256,f.nzZIndex=1e3,f.nzOffsetX=0,f.nzOffsetY=0,f.nzOnViewInit=new r.EventEmitter,f.nzOnClose=new r.EventEmitter,f.destroy$=new s.Subject,f.isOpen=!1,f.templateContext={$implicit:void 0,drawerRef:f},f.nzAfterOpen=new s.Subject,f.nzAfterClose=new s.Subject,f}return function(e,t){function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(p,e),Object.defineProperty(p.prototype,"nzVisible",{get:function(){return this.isOpen},set:function(e){this.isOpen=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"offsetTransform",{get:function(){if(!this.isOpen||this.nzOffsetX+this.nzOffsetY===0)return null;switch(this.nzPlacement){case"left":return"translateX("+this.nzOffsetX+"px)";case"right":return"translateX(-"+this.nzOffsetX+"px)";case"top":return"translateY("+this.nzOffsetY+"px)";case"bottom":return"translateY(-"+this.nzOffsetY+"px)"}},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"transform",{get:function(){if(this.isOpen)return null;switch(this.nzPlacement){case"left":return"translateX(-100%)";case"right":return"translateX(100%)";case"top":return"translateY(-100%)";case"bottom":return"translateY(100%)"}},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"width",{get:function(){return this.isLeftOrRight?l.toCssPixel(this.nzWidth):null},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"height",{get:function(){return this.isLeftOrRight?null:l.toCssPixel(this.nzHeight)},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"isLeftOrRight",{get:function(){return"left"===this.nzPlacement||"right"===this.nzPlacement},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"afterOpen",{get:function(){return this.nzAfterOpen.asObservable()},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"afterClose",{get:function(){return this.nzAfterClose.asObservable()},enumerable:!0,configurable:!0}),p.prototype.isTemplateRef=function(e){return e instanceof r.TemplateRef},p.prototype.ngOnInit=function(){this.attachOverlay(),this.updateOverlayStyle(),this.updateBodyOverflow(),this.templateContext={$implicit:this.nzContentParams,drawerRef:this},this.changeDetectorRef.detectChanges()},p.prototype.ngAfterViewInit=function(){var e=this;this.attachBodyContent(),setTimeout(function(){e.nzOnViewInit.emit()})},p.prototype.ngOnChanges=function(e){e.hasOwnProperty("nzVisible")&&(e.nzVisible.currentValue?this.open():this.close())},p.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.disposeOverlay()},p.prototype.getAnimationDuration=function(){return this.nzNoAnimation?0:300},p.prototype.close=function(e){var t=this;this.isOpen=!1,this.updateOverlayStyle(),this.overlayKeyboardDispatcher.remove(this.overlayRef),this.changeDetectorRef.detectChanges(),setTimeout(function(){t.updateBodyOverflow(),t.restoreFocus(),t.nzAfterClose.next(e),t.nzAfterClose.complete()},this.getAnimationDuration())},p.prototype.open=function(){var e=this;this.isOpen=!0,this.overlayKeyboardDispatcher.add(this.overlayRef),this.updateOverlayStyle(),this.updateBodyOverflow(),this.savePreviouslyFocusedElement(),this.trapFocus(),this.changeDetectorRef.detectChanges(),setTimeout(function(){e.nzAfterOpen.next()},this.getAnimationDuration())},p.prototype.closeClick=function(){this.nzOnClose.emit()},p.prototype.maskClick=function(){this.nzMaskClosable&&this.nzMask&&this.nzOnClose.emit()},p.prototype.attachBodyContent=function(){if(this.bodyPortalOutlet.dispose(),this.nzContent instanceof r.Type){var e=new i.PortalInjector(this.injector,new WeakMap([[d,this]])),t=new i.ComponentPortal(this.nzContent,null,e),n=this.bodyPortalOutlet.attachComponentPortal(t);Object.assign(n.instance,this.nzContentParams),n.changeDetectorRef.detectChanges()}},p.prototype.attachOverlay=function(){var e=this;this.overlayRef||(this.portal=new i.TemplatePortal(this.drawerTemplate,this.viewContainerRef),this.overlayRef=this.overlay.create(this.getOverlayConfig())),this.overlayRef&&!this.overlayRef.hasAttached()&&(this.overlayRef.attach(this.portal),this.overlayRef.keydownEvents().pipe(c.takeUntil(this.destroy$)).subscribe(function(n){n.keyCode===t.ESCAPE&&e.isOpen&&e.nzKeyboard&&e.nzOnClose.emit()}))},p.prototype.disposeOverlay=function(){this.overlayRef&&this.overlayRef.dispose(),this.overlayRef=null},p.prototype.getOverlayConfig=function(){return new a.OverlayConfig({positionStrategy:this.overlay.position().global(),scrollStrategy:this.overlay.scrollStrategies.block()})},p.prototype.updateOverlayStyle=function(){this.overlayRef&&this.overlayRef.overlayElement&&this.renderer.setStyle(this.overlayRef.overlayElement,"pointer-events",this.isOpen?"auto":"none")},p.prototype.updateBodyOverflow=function(){this.overlayRef&&(this.isOpen?this.overlayRef.getConfig().scrollStrategy.enable():this.overlayRef.getConfig().scrollStrategy.disable())},p.prototype.savePreviouslyFocusedElement=function(){this.document&&!this.previouslyFocusedElement&&(this.previouslyFocusedElement=this.document.activeElement,this.previouslyFocusedElement&&"function"==typeof this.previouslyFocusedElement.blur&&this.previouslyFocusedElement.blur())},p.prototype.trapFocus=function(){!this.focusTrap&&this.overlayRef&&this.overlayRef.overlayElement&&(this.focusTrap=this.focusTrapFactory.create(this.overlayRef.overlayElement),this.focusTrap.focusInitialElement())},p.prototype.restoreFocus=function(){this.previouslyFocusedElement&&"function"==typeof this.previouslyFocusedElement.focus&&this.previouslyFocusedElement.focus(),this.focusTrap&&this.focusTrap.destroy()},p.decorators=[{type:r.Component,args:[{selector:"nz-drawer",exportAs:"nzDrawer",template:'<ng-template #drawerTemplate>\n <div\n class="ant-drawer"\n [nzNoAnimation]="nzNoAnimation"\n [class.ant-drawer-open]="isOpen"\n [class.ant-drawer-top]="nzPlacement === \'top\'"\n [class.ant-drawer-bottom]="nzPlacement === \'bottom\'"\n [class.ant-drawer-right]="nzPlacement === \'right\'"\n [class.ant-drawer-left]="nzPlacement === \'left\'"\n [style.transform]="offsetTransform"\n [style.zIndex]="nzZIndex">\n <div class="ant-drawer-mask" (click)="maskClick()" *ngIf="nzMask" [ngStyle]="nzMaskStyle"></div>\n <div class="ant-drawer-content-wrapper {{ nzWrapClassName }}"\n [style.width]="width"\n [style.height]="height"\n [style.transform]="transform">\n <div class="ant-drawer-content">\n <div class="ant-drawer-wrapper-body"\n [style.overflow]="isLeftOrRight ? \'auto\' : null"\n [style.height]="isLeftOrRight ? \'100%\' : null">\n <div *ngIf="nzTitle" class="ant-drawer-header">\n <div class="ant-drawer-title">\n <ng-container *nzStringTemplateOutlet="nzTitle"><div [innerHTML]="nzTitle"></div></ng-container>\n </div>\n </div>\n <button *ngIf="nzClosable" (click)="closeClick()" aria-label="Close" class="ant-drawer-close">\n <span class="ant-drawer-close-x"><i nz-icon nzType="close"></i></span>\n </button>\n <div class="ant-drawer-body" [ngStyle]="nzBodyStyle">\n <ng-template cdkPortalOutlet></ng-template>\n <ng-container *ngIf="isTemplateRef(nzContent)">\n <ng-container *ngTemplateOutlet="nzContent; context: templateContext"></ng-container>\n </ng-container>\n <ng-content *ngIf="!nzContent"></ng-content>\n </div>\n </div>\n </div>\n </div>\n </div>\n</ng-template>\n',preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush}]}],p.ctorParameters=function(){return[{type:void 0,decorators:[{type:r.Optional},{type:r.Inject,args:[n.DOCUMENT]}]},{type:l.NzConfigService},{type:r.Renderer2},{type:a.Overlay},{type:r.Injector},{type:r.ChangeDetectorRef},{type:o.FocusTrapFactory},{type:r.ViewContainerRef},{type:a.OverlayKeyboardDispatcher}]},p.propDecorators={nzContent:[{type:r.Input}],nzClosable:[{type:r.Input}],nzMaskClosable:[{type:r.Input}],nzMask:[{type:r.Input}],nzNoAnimation:[{type:r.Input}],nzKeyboard:[{type:r.Input}],nzTitle:[{type:r.Input}],nzPlacement:[{type:r.Input}],nzMaskStyle:[{type:r.Input}],nzBodyStyle:[{type:r.Input}],nzWrapClassName:[{type:r.Input}],nzWidth:[{type:r.Input}],nzHeight:[{type:r.Input}],nzZIndex:[{type:r.Input}],nzOffsetX:[{type:r.Input}],nzOffsetY:[{type:r.Input}],nzVisible:[{type:r.Input}],nzOnViewInit:[{type:r.Output}],nzOnClose:[{type:r.Output}],drawerTemplate:[{type:r.ViewChild,args:["drawerTemplate",{static:!0}]}],bodyPortalOutlet:[{type:r.ViewChild,args:[i.CdkPortalOutlet,{static:!1}]}]},f([l.InputBoolean(),y("design:type",Boolean)],p.prototype,"nzClosable",void 0),f([l.WithConfig(!0),l.InputBoolean(),y("design:type",Boolean)],p.prototype,"nzMaskClosable",void 0),f([l.WithConfig(!0),l.InputBoolean(),y("design:type",Boolean)],p.prototype,"nzMask",void 0),f([l.InputBoolean(),y("design:type",Object)],p.prototype,"nzNoAnimation",void 0),f([l.InputBoolean(),y("design:type",Boolean)],p.prototype,"nzKeyboard",void 0),p}(d);var g=function(){function e(){}return e.decorators=[{type:r.NgModule}],e}(),v=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[n.CommonModule,a.OverlayModule,i.PortalModule,p.NzIconModule,l.NzAddOnModule,l.NzNoAnimationModule,g],exports:[h],declarations:[h],entryComponents:[h]}]}],e}(),m=function(){function e(e,t){var n=this;this.overlay=e,this.options=t,this.unsubscribe$=new s.Subject;var r=this.options,o=r.nzOnCancel,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(r,["nzOnCancel"]);this.createDrawer(),this.updateOptions(a),this.drawerRef.instance.savePreviouslyFocusedElement(),this.drawerRef.instance.nzOnViewInit.pipe(c.takeUntil(this.unsubscribe$)).subscribe(function(){n.drawerRef.instance.open()}),this.drawerRef.instance.nzOnClose.subscribe(function(){o?o().then(function(e){!1!==e&&n.drawerRef.instance.close()}):n.drawerRef.instance.close()}),this.drawerRef.instance.afterClose.pipe(c.takeUntil(this.unsubscribe$)).subscribe(function(){n.overlayRef.dispose(),n.drawerRef=null,n.unsubscribe$.next(),n.unsubscribe$.complete()})}return e.prototype.getInstance=function(){return this.drawerRef&&this.drawerRef.instance},e.prototype.createDrawer=function(){this.overlayRef=this.overlay.create(),this.drawerRef=this.overlayRef.attach(new i.ComponentPortal(h))},e.prototype.updateOptions=function(e){Object.assign(this.drawerRef.instance,e)},e}();var z=function(){function e(e){this.overlay=e}return e.prototype.create=function(e){return new m(this.overlay,e).getInstance()},e.decorators=[{type:r.Injectable,args:[{providedIn:g}]}],e.ctorParameters=function(){return[{type:a.Overlay}]},e.ngInjectableDef=r.ɵɵdefineInjectable({factory:function(){return new e(r.ɵɵinject(a.Overlay))},token:e,providedIn:g}),e}();e.DRAWER_ANIMATE_DURATION=300,e.DrawerBuilderForService=m,e.NzDrawerComponent=h,e.NzDrawerModule=v,e.NzDrawerRef=d,e.NzDrawerService=z,e.NzDrawerServiceModule=g,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-drawer.umd.min.js.map