UNPKG

ng-zorro-antd

Version:

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

24 lines (22 loc) 15.6 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("@angular/cdk/keycodes"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core/no-animation"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("ng-zorro-antd/drawer",["exports","@angular/cdk/a11y","@angular/cdk/keycodes","@angular/cdk/overlay","@angular/cdk/portal","@angular/common","@angular/core","ng-zorro-antd/core/config","ng-zorro-antd/core/util","rxjs","rxjs/operators","ng-zorro-antd/core/no-animation","ng-zorro-antd/core/outlet","ng-zorro-antd/icon"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].drawer={}),e.ng.cdk.a11y,e.ng.cdk.keycodes,e.ng.cdk.overlay,e.ng.cdk.portal,e.ng.common,e.ng.core,e["ng-zorro-antd"].core.config,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e["ng-zorro-antd"].core["no-animation"],e["ng-zorro-antd"].core.outlet,e["ng-zorro-antd"].icon)}(this,(function(e,t,n,r,o,i,a,s,l,c,p,u,f,y){"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. ***************************************************************************** */var d=function(e,t){return(d=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 h(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function g(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 m=function(){};var v=function(e){function u(t,n,r,o,i,s,l,p,u){var f=e.call(this)||this;return f.document=t,f.nzConfigService=n,f.renderer=r,f.overlay=o,f.injector=i,f.changeDetectorRef=s,f.focusTrapFactory=l,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 a.EventEmitter,f.nzOnClose=new a.EventEmitter,f.destroy$=new c.Subject,f.placementChanging=!1,f.placementChangeTimeoutId=-1,f.isOpen=!1,f.templateContext={$implicit:void 0,drawerRef:f},f.nzAfterOpen=new c.Subject,f.nzAfterClose=new c.Subject,f}return function(e,t){function n(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(u,e),Object.defineProperty(u.prototype,"nzVisible",{get:function(){return this.isOpen},set:function(e){this.isOpen=e},enumerable:!0,configurable:!0}),Object.defineProperty(u.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(u.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(u.prototype,"width",{get:function(){return this.isLeftOrRight?l.toCssPixel(this.nzWidth):null},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"height",{get:function(){return this.isLeftOrRight?null:l.toCssPixel(this.nzHeight)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"isLeftOrRight",{get:function(){return"left"===this.nzPlacement||"right"===this.nzPlacement},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"afterOpen",{get:function(){return this.nzAfterOpen.asObservable()},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"afterClose",{get:function(){return this.nzAfterClose.asObservable()},enumerable:!0,configurable:!0}),u.prototype.isTemplateRef=function(e){return e instanceof a.TemplateRef},u.prototype.ngOnInit=function(){this.attachOverlay(),this.updateOverlayStyle(),this.updateBodyOverflow(),this.templateContext={$implicit:this.nzContentParams,drawerRef:this},this.changeDetectorRef.detectChanges()},u.prototype.ngAfterViewInit=function(){var e=this;this.attachBodyContent(),setTimeout((function(){e.nzOnViewInit.emit()}))},u.prototype.ngOnChanges=function(e){var t=e.nzPlacement;e.nzVisible&&(e.nzVisible.currentValue?this.open():this.close());t&&!t.isFirstChange()&&this.triggerPlacementChangeCycleOnce()},u.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),clearTimeout(this.placementChangeTimeoutId),this.disposeOverlay()},u.prototype.getAnimationDuration=function(){return this.nzNoAnimation?0:300},u.prototype.triggerPlacementChangeCycleOnce=function(){var e=this;this.nzNoAnimation||(this.placementChanging=!0,this.changeDetectorRef.markForCheck(),clearTimeout(this.placementChangeTimeoutId),this.placementChangeTimeoutId=setTimeout((function(){e.placementChanging=!1,e.changeDetectorRef.markForCheck()}),this.getAnimationDuration()))},u.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())},u.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())},u.prototype.closeClick=function(){this.nzOnClose.emit()},u.prototype.maskClick=function(){this.nzMaskClosable&&this.nzMask&&this.nzOnClose.emit()},u.prototype.attachBodyContent=function(){if(this.bodyPortalOutlet.dispose(),this.nzContent instanceof a.Type){var e=new o.PortalInjector(this.injector,new WeakMap([[m,this]])),t=new o.ComponentPortal(this.nzContent,null,e),n=this.bodyPortalOutlet.attachComponentPortal(t);Object.assign(n.instance,this.nzContentParams),n.changeDetectorRef.detectChanges()}},u.prototype.attachOverlay=function(){var e=this;this.overlayRef||(this.portal=new o.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(p.takeUntil(this.destroy$)).subscribe((function(t){t.keyCode===n.ESCAPE&&e.isOpen&&e.nzKeyboard&&e.nzOnClose.emit()})))},u.prototype.disposeOverlay=function(){this.overlayRef&&this.overlayRef.dispose(),this.overlayRef=null},u.prototype.getOverlayConfig=function(){return new r.OverlayConfig({disposeOnNavigation:!0,positionStrategy:this.overlay.position().global(),scrollStrategy:this.overlay.scrollStrategies.block()})},u.prototype.updateOverlayStyle=function(){this.overlayRef&&this.overlayRef.overlayElement&&this.renderer.setStyle(this.overlayRef.overlayElement,"pointer-events",this.isOpen?"auto":"none")},u.prototype.updateBodyOverflow=function(){this.overlayRef&&(this.isOpen?this.overlayRef.getConfig().scrollStrategy.enable():this.overlayRef.getConfig().scrollStrategy.disable())},u.prototype.savePreviouslyFocusedElement=function(){this.document&&!this.previouslyFocusedElement&&(this.previouslyFocusedElement=this.document.activeElement,this.previouslyFocusedElement&&"function"==typeof this.previouslyFocusedElement.blur&&this.previouslyFocusedElement.blur())},u.prototype.trapFocus=function(){!this.focusTrap&&this.overlayRef&&this.overlayRef.overlayElement&&(this.focusTrap=this.focusTrapFactory.create(this.overlayRef.overlayElement),this.focusTrap.focusInitialElement())},u.prototype.restoreFocus=function(){this.previouslyFocusedElement&&"function"==typeof this.previouslyFocusedElement.focus&&this.previouslyFocusedElement.focus(),this.focusTrap&&this.focusTrap.destroy()},u.decorators=[{type:a.Component,args:[{selector:"nz-drawer",exportAs:"nzDrawer",template:'\n <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.transition]="placementChanging ? \'none\' : null"\n [style.zIndex]="nzZIndex"\n >\n <div class="ant-drawer-mask" (click)="maskClick()" *ngIf="nzMask" [ngStyle]="nzMaskStyle"></div>\n <div\n class="ant-drawer-content-wrapper {{ nzWrapClassName }}"\n [style.width]="width"\n [style.height]="height"\n [style.transform]="transform"\n [style.transition]="placementChanging ? \'none\' : null"\n >\n <div class="ant-drawer-content">\n <div class="ant-drawer-wrapper-body" [style.height]="isLeftOrRight ? \'100%\' : null">\n <div *ngIf="nzTitle || nzClosable" [class.ant-drawer-header]="!!nzTitle" [class.ant-drawer-header-no-title]="!nzTitle">\n <div *ngIf="nzTitle" class="ant-drawer-title">\n <ng-container *nzStringTemplateOutlet="nzTitle"><div [innerHTML]="nzTitle"></div></ng-container>\n </div>\n <button *ngIf="nzClosable" (click)="closeClick()" aria-label="Close" class="ant-drawer-close" style="--scroll-bar: 0px;">\n <i nz-icon nzType="close"></i>\n </button>\n </div>\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:a.ChangeDetectionStrategy.OnPush}]}],u.ctorParameters=function(){return[{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[i.DOCUMENT]}]},{type:s.NzConfigService},{type:a.Renderer2},{type:r.Overlay},{type:a.Injector},{type:a.ChangeDetectorRef},{type:t.FocusTrapFactory},{type:a.ViewContainerRef},{type:r.OverlayKeyboardDispatcher}]},u.propDecorators={nzContent:[{type:a.Input}],nzClosable:[{type:a.Input}],nzMaskClosable:[{type:a.Input}],nzMask:[{type:a.Input}],nzNoAnimation:[{type:a.Input}],nzKeyboard:[{type:a.Input}],nzTitle:[{type:a.Input}],nzPlacement:[{type:a.Input}],nzMaskStyle:[{type:a.Input}],nzBodyStyle:[{type:a.Input}],nzWrapClassName:[{type:a.Input}],nzWidth:[{type:a.Input}],nzHeight:[{type:a.Input}],nzZIndex:[{type:a.Input}],nzOffsetX:[{type:a.Input}],nzOffsetY:[{type:a.Input}],nzVisible:[{type:a.Input}],nzOnViewInit:[{type:a.Output}],nzOnClose:[{type:a.Output}],drawerTemplate:[{type:a.ViewChild,args:["drawerTemplate",{static:!0}]}],bodyPortalOutlet:[{type:a.ViewChild,args:[o.CdkPortalOutlet,{static:!1}]}]},h([l.InputBoolean(),g("design:type",Boolean)],u.prototype,"nzClosable",void 0),h([s.WithConfig("drawer",!0),l.InputBoolean(),g("design:type",Boolean)],u.prototype,"nzMaskClosable",void 0),h([s.WithConfig("drawer",!0),l.InputBoolean(),g("design:type",Boolean)],u.prototype,"nzMask",void 0),h([l.InputBoolean(),g("design:type",Object)],u.prototype,"nzNoAnimation",void 0),h([l.InputBoolean(),g("design:type",Boolean)],u.prototype,"nzKeyboard",void 0),u}(m);var z=function(){function e(){}return e.decorators=[{type:a.NgModule}],e}(),O=function(){function e(){}return e.decorators=[{type:a.NgModule,args:[{imports:[i.CommonModule,r.OverlayModule,o.PortalModule,y.NzIconModule,f.NzOutletModule,u.NzNoAnimationModule,z],exports:[v],declarations:[v],entryComponents:[v]}]}],e}(),b=function(){function e(e,t){var n=this;this.overlay=e,this.options=t,this.unsubscribe$=new c.Subject;var r=this.options,o=r.nzOnCancel,i=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(i),this.drawerRef.instance.savePreviouslyFocusedElement(),this.drawerRef.instance.nzOnViewInit.pipe(p.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(p.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 o.ComponentPortal(v))},e.prototype.updateOptions=function(e){Object.assign(this.drawerRef.instance,e)},e}();var C=function(){function e(e){this.overlay=e}return e.prototype.create=function(e){return new b(this.overlay,e).getInstance()},e.decorators=[{type:a.Injectable,args:[{providedIn:z}]}],e.ctorParameters=function(){return[{type:r.Overlay}]},e.ɵprov=a.ɵɵdefineInjectable({factory:function(){return new e(a.ɵɵinject(r.Overlay))},token:e,providedIn:z}),e}();e.DRAWER_ANIMATE_DURATION=300,e.DrawerBuilderForService=b,e.NzDrawerComponent=v,e.NzDrawerModule=O,e.NzDrawerRef=m,e.NzDrawerService=C,e.NzDrawerServiceModule=z,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-drawer.umd.min.js.map