UNPKG

ng-zorro-antd

Version:

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

749 lines (738 loc) 33.4 kB
import { __decorate, __rest } from 'tslib'; import { ESCAPE } from '@angular/cdk/keycodes'; import * as i2 from '@angular/cdk/overlay'; import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay'; import * as i9 from '@angular/cdk/portal'; import { ComponentPortal, TemplatePortal, CdkPortalOutlet, PortalModule } from '@angular/cdk/portal'; import * as i6 from '@angular/common'; import { DOCUMENT, CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { Directive, EventEmitter, TemplateRef, Type, Injector, Component, ChangeDetectionStrategy, Optional, Inject, Input, Output, ViewChild, ContentChild, NgModule, Injectable } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import * as i1 from 'ng-zorro-antd/core/config'; import { WithConfig } from 'ng-zorro-antd/core/config'; import { toCssPixel, InputBoolean } from 'ng-zorro-antd/core/util'; import * as i3 from '@angular/cdk/a11y'; import * as i4 from '@angular/cdk/bidi'; import { BidiModule } from '@angular/cdk/bidi'; import * as i5 from 'ng-zorro-antd/core/no-animation'; import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation'; import * as i7 from 'ng-zorro-antd/core/outlet'; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'; import * as i8 from 'ng-zorro-antd/icon'; import { NzIconModule } from 'ng-zorro-antd/icon'; /** * 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 */ class NzDrawerContentDirective { constructor(templateRef) { this.templateRef = templateRef; } } NzDrawerContentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerContentDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); NzDrawerContentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.5", type: NzDrawerContentDirective, selector: "[nzDrawerContent]", exportAs: ["nzDrawerContent"], ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerContentDirective, decorators: [{ type: Directive, args: [{ selector: '[nzDrawerContent]', exportAs: 'nzDrawerContent' }] }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } }); /** * 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 */ const DRAWER_DEFAULT_SIZE = 378; const DRAWER_LARGE_SIZE = 736; /** * 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 */ class NzDrawerRef { } const DRAWER_ANIMATE_DURATION = 300; const NZ_CONFIG_MODULE_NAME = 'drawer'; class NzDrawerComponent extends NzDrawerRef { constructor(cdr, // eslint-disable-next-line @typescript-eslint/no-explicit-any document, nzConfigService, renderer, overlay, injector, changeDetectorRef, focusTrapFactory, viewContainerRef, overlayKeyboardDispatcher, directionality) { super(); this.cdr = cdr; this.document = document; this.nzConfigService = nzConfigService; this.renderer = renderer; this.overlay = overlay; this.injector = injector; this.changeDetectorRef = changeDetectorRef; this.focusTrapFactory = focusTrapFactory; this.viewContainerRef = viewContainerRef; this.overlayKeyboardDispatcher = overlayKeyboardDispatcher; this.directionality = directionality; this._nzModuleName = NZ_CONFIG_MODULE_NAME; this.nzCloseIcon = 'close'; this.nzClosable = true; this.nzMaskClosable = true; this.nzMask = true; this.nzCloseOnNavigation = true; this.nzNoAnimation = false; this.nzKeyboard = true; this.nzPlacement = 'right'; this.nzSize = 'default'; this.nzMaskStyle = {}; this.nzBodyStyle = {}; this.nzZIndex = 1000; this.nzOffsetX = 0; this.nzOffsetY = 0; this.componentInstance = null; this.nzOnViewInit = new EventEmitter(); this.nzOnClose = new EventEmitter(); this.nzVisibleChange = new EventEmitter(); this.destroy$ = new Subject(); this.placementChanging = false; this.placementChangeTimeoutId = -1; this.isOpen = false; this.inAnimation = false; this.templateContext = { $implicit: undefined, drawerRef: this }; this.nzAfterOpen = new Subject(); this.nzAfterClose = new Subject(); // from service config this.nzDirection = undefined; this.dir = 'ltr'; } set nzVisible(value) { this.isOpen = value; } get nzVisible() { return this.isOpen; } get offsetTransform() { 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)`; } } get transform() { 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%)`; } } get width() { if (this.isLeftOrRight) { const defaultWidth = this.nzSize === 'large' ? DRAWER_LARGE_SIZE : DRAWER_DEFAULT_SIZE; return this.nzWidth === undefined ? toCssPixel(defaultWidth) : toCssPixel(this.nzWidth); } return null; } get height() { if (!this.isLeftOrRight) { const defaultHeight = this.nzSize === 'large' ? DRAWER_LARGE_SIZE : DRAWER_DEFAULT_SIZE; return this.nzHeight === undefined ? toCssPixel(defaultHeight) : toCssPixel(this.nzHeight); } return null; } get isLeftOrRight() { return this.nzPlacement === 'left' || this.nzPlacement === 'right'; } get afterOpen() { return this.nzAfterOpen.asObservable(); } get afterClose() { return this.nzAfterClose.asObservable(); } isTemplateRef(value) { return value instanceof TemplateRef; } ngOnInit() { var _a; (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => { this.dir = direction; this.cdr.detectChanges(); }); this.dir = this.nzDirection || this.directionality.value; this.attachOverlay(); this.updateOverlayStyle(); this.updateBodyOverflow(); this.templateContext = { $implicit: this.nzContentParams, drawerRef: this }; this.changeDetectorRef.detectChanges(); } ngAfterViewInit() { this.attachBodyContent(); // The `setTimeout` triggers change detection. There's no sense to schedule the DOM timer if anyone is // listening to the `nzOnViewInit` event inside the template, for instance `<nz-drawer (nzOnViewInit)="...">`. if (this.nzOnViewInit.observers.length) { setTimeout(() => { this.nzOnViewInit.emit(); }); } } ngOnChanges(changes) { const { nzPlacement, nzVisible } = changes; if (nzVisible) { const value = changes.nzVisible.currentValue; if (value) { this.open(); } else { this.close(); } } if (nzPlacement && !nzPlacement.isFirstChange()) { this.triggerPlacementChangeCycleOnce(); } } ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); clearTimeout(this.placementChangeTimeoutId); this.disposeOverlay(); } getAnimationDuration() { return this.nzNoAnimation ? 0 : DRAWER_ANIMATE_DURATION; } // Disable the transition animation temporarily when the placement changing triggerPlacementChangeCycleOnce() { if (!this.nzNoAnimation) { this.placementChanging = true; this.changeDetectorRef.markForCheck(); clearTimeout(this.placementChangeTimeoutId); this.placementChangeTimeoutId = setTimeout(() => { this.placementChanging = false; this.changeDetectorRef.markForCheck(); }, this.getAnimationDuration()); } } close(result) { this.isOpen = false; this.inAnimation = true; this.nzVisibleChange.emit(false); this.updateOverlayStyle(); this.overlayKeyboardDispatcher.remove(this.overlayRef); this.changeDetectorRef.detectChanges(); setTimeout(() => { this.updateBodyOverflow(); this.restoreFocus(); this.inAnimation = false; this.nzAfterClose.next(result); this.nzAfterClose.complete(); this.componentInstance = null; }, this.getAnimationDuration()); } open() { this.attachOverlay(); this.isOpen = true; this.inAnimation = true; this.nzVisibleChange.emit(true); this.overlayKeyboardDispatcher.add(this.overlayRef); this.updateOverlayStyle(); this.updateBodyOverflow(); this.savePreviouslyFocusedElement(); this.trapFocus(); this.changeDetectorRef.detectChanges(); setTimeout(() => { this.inAnimation = false; this.changeDetectorRef.detectChanges(); this.nzAfterOpen.next(); }, this.getAnimationDuration()); } getContentComponent() { return this.componentInstance; } closeClick() { this.nzOnClose.emit(); } maskClick() { if (this.nzMaskClosable && this.nzMask) { this.nzOnClose.emit(); } } attachBodyContent() { this.bodyPortalOutlet.dispose(); if (this.nzContent instanceof Type) { const childInjector = Injector.create({ parent: this.injector, providers: [{ provide: NzDrawerRef, useValue: this }] }); const componentPortal = new ComponentPortal(this.nzContent, null, childInjector); const componentRef = this.bodyPortalOutlet.attachComponentPortal(componentPortal); this.componentInstance = componentRef.instance; Object.assign(componentRef.instance, this.nzContentParams); componentRef.changeDetectorRef.detectChanges(); } } attachOverlay() { if (!this.overlayRef) { this.portal = new TemplatePortal(this.drawerTemplate, this.viewContainerRef); this.overlayRef = this.overlay.create(this.getOverlayConfig()); } if (this.overlayRef && !this.overlayRef.hasAttached()) { this.overlayRef.attach(this.portal); this.overlayRef.keydownEvents() .pipe(takeUntil(this.destroy$)) .subscribe((event) => { if (event.keyCode === ESCAPE && this.isOpen && this.nzKeyboard) { this.nzOnClose.emit(); } }); this.overlayRef .detachments() .pipe(takeUntil(this.destroy$)) .subscribe(() => { this.disposeOverlay(); }); } } disposeOverlay() { var _a; (_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.dispose(); this.overlayRef = null; } getOverlayConfig() { return new OverlayConfig({ disposeOnNavigation: this.nzCloseOnNavigation, positionStrategy: this.overlay.position().global(), scrollStrategy: this.overlay.scrollStrategies.block() }); } updateOverlayStyle() { if (this.overlayRef && this.overlayRef.overlayElement) { this.renderer.setStyle(this.overlayRef.overlayElement, 'pointer-events', this.isOpen ? 'auto' : 'none'); } } updateBodyOverflow() { if (this.overlayRef) { if (this.isOpen) { this.overlayRef.getConfig().scrollStrategy.enable(); } else { this.overlayRef.getConfig().scrollStrategy.disable(); } } } savePreviouslyFocusedElement() { if (this.document && !this.previouslyFocusedElement) { this.previouslyFocusedElement = this.document.activeElement; // We need the extra check, because IE's svg element has no blur method. if (this.previouslyFocusedElement && typeof this.previouslyFocusedElement.blur === 'function') { this.previouslyFocusedElement.blur(); } } } trapFocus() { if (!this.focusTrap && this.overlayRef && this.overlayRef.overlayElement) { this.focusTrap = this.focusTrapFactory.create(this.overlayRef.overlayElement); this.focusTrap.focusInitialElement(); } } restoreFocus() { // We need the extra check, because IE can set the `activeElement` to null in some cases. if (this.previouslyFocusedElement && typeof this.previouslyFocusedElement.focus === 'function') { this.previouslyFocusedElement.focus(); } if (this.focusTrap) { this.focusTrap.destroy(); } } } NzDrawerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: DOCUMENT, optional: true }, { token: i1.NzConfigService }, { token: i0.Renderer2 }, { token: i2.Overlay }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }, { token: i3.FocusTrapFactory }, { token: i0.ViewContainerRef }, { token: i2.OverlayKeyboardDispatcher }, { token: i4.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Component }); NzDrawerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.5", type: NzDrawerComponent, selector: "nz-drawer", inputs: { nzContent: "nzContent", nzCloseIcon: "nzCloseIcon", nzClosable: "nzClosable", nzMaskClosable: "nzMaskClosable", nzMask: "nzMask", nzCloseOnNavigation: "nzCloseOnNavigation", nzNoAnimation: "nzNoAnimation", nzKeyboard: "nzKeyboard", nzTitle: "nzTitle", nzExtra: "nzExtra", nzFooter: "nzFooter", nzPlacement: "nzPlacement", nzSize: "nzSize", nzMaskStyle: "nzMaskStyle", nzBodyStyle: "nzBodyStyle", nzWrapClassName: "nzWrapClassName", nzWidth: "nzWidth", nzHeight: "nzHeight", nzZIndex: "nzZIndex", nzOffsetX: "nzOffsetX", nzOffsetY: "nzOffsetY", nzVisible: "nzVisible" }, outputs: { nzOnViewInit: "nzOnViewInit", nzOnClose: "nzOnClose", nzVisibleChange: "nzVisibleChange" }, queries: [{ propertyName: "contentFromContentChild", first: true, predicate: NzDrawerContentDirective, descendants: true, read: TemplateRef, static: true }], viewQueries: [{ propertyName: "drawerTemplate", first: true, predicate: ["drawerTemplate"], descendants: true, static: true }, { propertyName: "bodyPortalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true }], exportAs: ["nzDrawer"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: ` <ng-template #drawerTemplate> <div class="ant-drawer" [nzNoAnimation]="nzNoAnimation" [class.ant-drawer-rtl]="dir === 'rtl'" [class.ant-drawer-open]="isOpen" [class.no-mask]="!nzMask" [class.ant-drawer-top]="nzPlacement === 'top'" [class.ant-drawer-bottom]="nzPlacement === 'bottom'" [class.ant-drawer-right]="nzPlacement === 'right'" [class.ant-drawer-left]="nzPlacement === 'left'" [style.transform]="offsetTransform" [style.transition]="placementChanging ? 'none' : null" [style.zIndex]="nzZIndex" > <div class="ant-drawer-mask" (click)="maskClick()" *ngIf="nzMask" [ngStyle]="nzMaskStyle"></div> <div class="ant-drawer-content-wrapper {{ nzWrapClassName }}" [style.width]="width" [style.height]="height" [style.transform]="transform" [style.transition]="placementChanging ? 'none' : null" > <div class="ant-drawer-content"> <div class="ant-drawer-wrapper-body" [style.height]="isLeftOrRight ? '100%' : null"> <div *ngIf="nzTitle || nzClosable" class="ant-drawer-header" [class.ant-drawer-header-close-only]="!nzTitle" > <div class="ant-drawer-header-title"> <button *ngIf="nzClosable" (click)="closeClick()" aria-label="Close" class="ant-drawer-close" style="--scroll-bar: 0px;" > <ng-container *nzStringTemplateOutlet="nzCloseIcon; let closeIcon"> <i nz-icon [nzType]="closeIcon"></i> </ng-container> </button> <div *ngIf="nzTitle" class="ant-drawer-title"> <ng-container *nzStringTemplateOutlet="nzTitle"> <div [innerHTML]="nzTitle"></div> </ng-container> </div> </div> <div *ngIf="nzExtra" class="ant-drawer-extra"> <ng-container *nzStringTemplateOutlet="nzExtra"> <div [innerHTML]="nzExtra"></div> </ng-container> </div> </div> <div class="ant-drawer-body" [ngStyle]="nzBodyStyle"> <ng-template cdkPortalOutlet></ng-template> <ng-container *ngIf="nzContent; else contentElseTemp"> <ng-container *ngIf="isTemplateRef(nzContent)"> <ng-container *ngTemplateOutlet="$any(nzContent); context: templateContext"></ng-container> </ng-container> </ng-container> <ng-template #contentElseTemp> <ng-container *ngIf="contentFromContentChild && (isOpen || inAnimation)"> <ng-template [ngTemplateOutlet]="contentFromContentChild"></ng-template> </ng-container> </ng-template> </div> <div *ngIf="nzFooter" class="ant-drawer-footer"> <ng-container *nzStringTemplateOutlet="nzFooter"> <div [innerHTML]="nzFooter"></div> </ng-container> </div> </div> </div> </div> </div> </ng-template> `, isInline: true, directives: [{ type: i5.NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i7.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { type: i8.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { type: i9.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); __decorate([ InputBoolean() ], NzDrawerComponent.prototype, "nzClosable", void 0); __decorate([ WithConfig(), InputBoolean() ], NzDrawerComponent.prototype, "nzMaskClosable", void 0); __decorate([ WithConfig(), InputBoolean() ], NzDrawerComponent.prototype, "nzMask", void 0); __decorate([ WithConfig(), InputBoolean() ], NzDrawerComponent.prototype, "nzCloseOnNavigation", void 0); __decorate([ InputBoolean() ], NzDrawerComponent.prototype, "nzNoAnimation", void 0); __decorate([ InputBoolean() ], NzDrawerComponent.prototype, "nzKeyboard", void 0); __decorate([ WithConfig() ], NzDrawerComponent.prototype, "nzDirection", void 0); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerComponent, decorators: [{ type: Component, args: [{ selector: 'nz-drawer', exportAs: 'nzDrawer', template: ` <ng-template #drawerTemplate> <div class="ant-drawer" [nzNoAnimation]="nzNoAnimation" [class.ant-drawer-rtl]="dir === 'rtl'" [class.ant-drawer-open]="isOpen" [class.no-mask]="!nzMask" [class.ant-drawer-top]="nzPlacement === 'top'" [class.ant-drawer-bottom]="nzPlacement === 'bottom'" [class.ant-drawer-right]="nzPlacement === 'right'" [class.ant-drawer-left]="nzPlacement === 'left'" [style.transform]="offsetTransform" [style.transition]="placementChanging ? 'none' : null" [style.zIndex]="nzZIndex" > <div class="ant-drawer-mask" (click)="maskClick()" *ngIf="nzMask" [ngStyle]="nzMaskStyle"></div> <div class="ant-drawer-content-wrapper {{ nzWrapClassName }}" [style.width]="width" [style.height]="height" [style.transform]="transform" [style.transition]="placementChanging ? 'none' : null" > <div class="ant-drawer-content"> <div class="ant-drawer-wrapper-body" [style.height]="isLeftOrRight ? '100%' : null"> <div *ngIf="nzTitle || nzClosable" class="ant-drawer-header" [class.ant-drawer-header-close-only]="!nzTitle" > <div class="ant-drawer-header-title"> <button *ngIf="nzClosable" (click)="closeClick()" aria-label="Close" class="ant-drawer-close" style="--scroll-bar: 0px;" > <ng-container *nzStringTemplateOutlet="nzCloseIcon; let closeIcon"> <i nz-icon [nzType]="closeIcon"></i> </ng-container> </button> <div *ngIf="nzTitle" class="ant-drawer-title"> <ng-container *nzStringTemplateOutlet="nzTitle"> <div [innerHTML]="nzTitle"></div> </ng-container> </div> </div> <div *ngIf="nzExtra" class="ant-drawer-extra"> <ng-container *nzStringTemplateOutlet="nzExtra"> <div [innerHTML]="nzExtra"></div> </ng-container> </div> </div> <div class="ant-drawer-body" [ngStyle]="nzBodyStyle"> <ng-template cdkPortalOutlet></ng-template> <ng-container *ngIf="nzContent; else contentElseTemp"> <ng-container *ngIf="isTemplateRef(nzContent)"> <ng-container *ngTemplateOutlet="$any(nzContent); context: templateContext"></ng-container> </ng-container> </ng-container> <ng-template #contentElseTemp> <ng-container *ngIf="contentFromContentChild && (isOpen || inAnimation)"> <ng-template [ngTemplateOutlet]="contentFromContentChild"></ng-template> </ng-container> </ng-template> </div> <div *ngIf="nzFooter" class="ant-drawer-footer"> <ng-container *nzStringTemplateOutlet="nzFooter"> <div [innerHTML]="nzFooter"></div> </ng-container> </div> </div> </div> </div> </div> </ng-template> `, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush }] }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT] }] }, { type: i1.NzConfigService }, { type: i0.Renderer2 }, { type: i2.Overlay }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }, { type: i3.FocusTrapFactory }, { type: i0.ViewContainerRef }, { type: i2.OverlayKeyboardDispatcher }, { type: i4.Directionality, decorators: [{ type: Optional }] }]; }, propDecorators: { nzContent: [{ type: Input }], nzCloseIcon: [{ type: Input }], nzClosable: [{ type: Input }], nzMaskClosable: [{ type: Input }], nzMask: [{ type: Input }], nzCloseOnNavigation: [{ type: Input }], nzNoAnimation: [{ type: Input }], nzKeyboard: [{ type: Input }], nzTitle: [{ type: Input }], nzExtra: [{ type: Input }], nzFooter: [{ type: Input }], nzPlacement: [{ type: Input }], nzSize: [{ type: Input }], nzMaskStyle: [{ type: Input }], nzBodyStyle: [{ type: Input }], nzWrapClassName: [{ type: Input }], nzWidth: [{ type: Input }], nzHeight: [{ type: Input }], nzZIndex: [{ type: Input }], nzOffsetX: [{ type: Input }], nzOffsetY: [{ type: Input }], nzVisible: [{ type: Input }], nzOnViewInit: [{ type: Output }], nzOnClose: [{ type: Output }], nzVisibleChange: [{ type: Output }], drawerTemplate: [{ type: ViewChild, args: ['drawerTemplate', { static: true }] }], bodyPortalOutlet: [{ type: ViewChild, args: [CdkPortalOutlet, { static: false }] }], contentFromContentChild: [{ type: ContentChild, args: [NzDrawerContentDirective, { static: true, read: TemplateRef }] }], nzDirection: [] } }); /** * 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 */ class NzDrawerServiceModule { } NzDrawerServiceModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); NzDrawerServiceModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerServiceModule }); NzDrawerServiceModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerServiceModule }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerServiceModule, decorators: [{ type: NgModule }] }); /** * 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 */ class NzDrawerModule { } NzDrawerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); NzDrawerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerModule, declarations: [NzDrawerComponent, NzDrawerContentDirective], imports: [BidiModule, CommonModule, OverlayModule, PortalModule, NzIconModule, NzOutletModule, NzNoAnimationModule, NzDrawerServiceModule], exports: [NzDrawerComponent, NzDrawerContentDirective] }); NzDrawerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerModule, imports: [[ BidiModule, CommonModule, OverlayModule, PortalModule, NzIconModule, NzOutletModule, NzNoAnimationModule, NzDrawerServiceModule ]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerModule, decorators: [{ type: NgModule, args: [{ imports: [ BidiModule, CommonModule, OverlayModule, PortalModule, NzIconModule, NzOutletModule, NzNoAnimationModule, NzDrawerServiceModule ], exports: [NzDrawerComponent, NzDrawerContentDirective], declarations: [NzDrawerComponent, NzDrawerContentDirective], entryComponents: [NzDrawerComponent] }] }] }); class DrawerBuilderForService { constructor(overlay, options) { this.overlay = overlay; this.options = options; this.unsubscribe$ = new Subject(); /** pick {@link NzDrawerOptions.nzOnCancel} and omit this option */ const _a = this.options, { nzOnCancel } = _a, componentOption = __rest(_a, ["nzOnCancel"]); this.overlayRef = this.overlay.create(); this.drawerRef = this.overlayRef.attach(new ComponentPortal(NzDrawerComponent)).instance; this.updateOptions(componentOption); // Prevent repeatedly open drawer when tap focus element. this.drawerRef.savePreviouslyFocusedElement(); this.drawerRef.nzOnViewInit.pipe(takeUntil(this.unsubscribe$)).subscribe(() => { this.drawerRef.open(); }); this.drawerRef.nzOnClose.subscribe(() => { if (nzOnCancel) { nzOnCancel().then(canClose => { if (canClose !== false) { this.drawerRef.close(); } }); } else { this.drawerRef.close(); } }); this.drawerRef.afterClose.pipe(takeUntil(this.unsubscribe$)).subscribe(() => { this.overlayRef.dispose(); this.drawerRef = null; this.unsubscribe$.next(); this.unsubscribe$.complete(); }); } getInstance() { return this.drawerRef; } updateOptions(options) { Object.assign(this.drawerRef, options); } } class NzDrawerService { constructor(overlay) { this.overlay = overlay; } create(options) { return new DrawerBuilderForService(this.overlay, options).getInstance(); } } NzDrawerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerService, deps: [{ token: i2.Overlay }], target: i0.ɵɵFactoryTarget.Injectable }); NzDrawerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerService, providedIn: NzDrawerServiceModule }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NzDrawerService, decorators: [{ type: Injectable, args: [{ providedIn: NzDrawerServiceModule }] }], ctorParameters: function () { return [{ type: i2.Overlay }]; } }); /** * 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 */ /** * Generated bundle index. Do not edit. */ export { DRAWER_ANIMATE_DURATION, DRAWER_DEFAULT_SIZE, DRAWER_LARGE_SIZE, DrawerBuilderForService, NzDrawerComponent, NzDrawerContentDirective, NzDrawerModule, NzDrawerRef, NzDrawerService, NzDrawerServiceModule }; //# sourceMappingURL=ng-zorro-antd-drawer.mjs.map