UNPKG

ng-zorro-antd

Version:

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

245 lines (238 loc) 10.5 kB
import { __decorate, __metadata } from 'tslib'; import { distinctUntilChanged } from 'rxjs/operators'; import { OverlayModule } from '@angular/cdk/overlay'; import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Host, Input, Optional, Output, ViewEncapsulation, ComponentFactoryResolver, Directive, ElementRef, Renderer2, ViewContainerRef, NgModule } from '@angular/core'; import { NzButtonModule } from 'ng-zorro-antd/button'; import { zoomBigMotion, InputBoolean, NzNoAnimationDirective, NzAddOnModule, NzNoAnimationModule, NzOverlayModule } from 'ng-zorro-antd/core'; import { NzI18nModule } from 'ng-zorro-antd/i18n'; import { NzIconModule } from 'ng-zorro-antd/icon'; import { NzToolTipComponent, NzTooltipDirective, NzToolTipModule } from 'ng-zorro-antd/tooltip'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzPopconfirmComponent extends NzToolTipComponent { /** * @param {?} cdr * @param {?=} noAnimation */ constructor(cdr, noAnimation) { super(cdr, noAnimation); this.noAnimation = noAnimation; this._prefix = 'ant-popover-placement'; this._trigger = 'click'; this._hasBackdrop = true; this.nzOkType = 'primary'; this.nzCondition = false; this.nzOnCancel = new EventEmitter(); this.nzOnConfirm = new EventEmitter(); } /** * @return {?} */ show() { if (!this.nzCondition) { this.nzVisible = true; } else { this.onConfirm(); } } /** * @return {?} */ onCancel() { this.nzOnCancel.emit(); this.nzVisible = false; } /** * @return {?} */ onConfirm() { this.nzOnConfirm.emit(); this.nzVisible = false; } } NzPopconfirmComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: 'nz-popconfirm', exportAs: 'nzPopconfirmComponent', preserveWhitespaces: false, animations: [zoomBigMotion], template: "<ng-content></ng-content>\n<ng-template\n #overlay=\"cdkConnectedOverlay\"\n cdkConnectedOverlay\n nzConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n [cdkConnectedOverlayHasBackdrop]=\"_hasBackdrop\"\n (backdropClick)=\"hide()\"\n (detach)=\"hide()\"\n (positionChange)=\"onPositionChange($event)\"\n [cdkConnectedOverlayPositions]=\"_positions\"\n [cdkConnectedOverlayOpen]=\"visible$ | async\">\n <div class=\"ant-popover\"\n [ngClass]=\"_classMap\"\n [ngStyle]=\"nzOverlayStyle\"\n [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n [@zoomBigMotion]=\"'active'\"\n (@zoomBigMotion.done)=\"_afterVisibilityAnimation($event)\">\n <div class=\"ant-popover-content\">\n <div class=\"ant-popover-arrow\"></div>\n <div class=\"ant-popover-inner\">\n <div>\n <div class=\"ant-popover-inner-content\">\n <div class=\"ant-popover-message\">\n <ng-container *nzStringTemplateOutlet=\"nzTitle\">\n <ng-container *nzStringTemplateOutlet=\"nzIcon\">\n <i nz-icon [nzType]=\"nzIcon || 'exclamation-circle'\" nzTheme=\"fill\"></i>\n </ng-container>\n <div class=\"ant-popover-message-title\">{{ nzTitle }}</div>\n </ng-container>\n </div>\n <div class=\"ant-popover-buttons\">\n <button nz-button [nzSize]=\"'small'\" (click)=\"onCancel()\">\n <ng-container *ngIf=\"nzCancelText\">{{ nzCancelText }}</ng-container>\n <ng-container *ngIf=\"!nzCancelText\">{{ 'Modal.cancelText' | nzI18n }}</ng-container>\n </button>\n <button nz-button [nzSize]=\"'small'\" [nzType]=\"nzOkType\" (click)=\"onConfirm()\">\n <ng-container *ngIf=\"nzOkText\">{{ nzOkText }}</ng-container>\n <ng-container *ngIf=\"!nzOkText\">{{ 'Modal.okText' | nzI18n }}</ng-container>\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</ng-template>", styles: [` .ant-popover { position: relative; } `] }] } ]; /** @nocollapse */ NzPopconfirmComponent.ctorParameters = () => [ { type: ChangeDetectorRef }, { type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] } ]; NzPopconfirmComponent.propDecorators = { nzOkText: [{ type: Input }], nzOkType: [{ type: Input }], nzCancelText: [{ type: Input }], nzCondition: [{ type: Input }], nzIcon: [{ type: Input }], nzOnCancel: [{ type: Output }], nzOnConfirm: [{ type: Output }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzPopconfirmComponent.prototype, "nzCondition", void 0); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzPopconfirmDirective extends NzTooltipDirective { /** * @param {?} elementRef * @param {?} hostView * @param {?} resolver * @param {?} renderer * @param {?} tooltip * @param {?=} noAnimation */ constructor(elementRef, hostView, resolver, renderer, tooltip, noAnimation) { super(elementRef, hostView, resolver, renderer, tooltip, noAnimation); this.noAnimation = noAnimation; this.factory = this.resolver.resolveComponentFactory(NzPopconfirmComponent); this.needProxyProperties = [ 'nzTitle', 'nzContent', 'nzOverlayClassName', 'nzOverlayStyle', 'nzMouseEnterDelay', 'nzMouseLeaveDelay', 'nzVisible', 'nzTrigger', 'nzPlacement', 'nzOkText', 'nzOkType', 'nzCancelText', 'nzCondition', 'nzIcon' ]; this.nzOnCancel = new EventEmitter(); this.nzOnConfirm = new EventEmitter(); } /** * @return {?} */ ngOnInit() { if (!this.tooltip) { /** @type {?} */ const tooltipComponent = this.hostView.createComponent(this.factory); this.tooltip = tooltipComponent.instance; this.tooltip.noAnimation = this.noAnimation; // Remove element when use directive https://github.com/NG-ZORRO/ng-zorro-antd/issues/1967 this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), tooltipComponent.location.nativeElement); this.isDynamicTooltip = true; this.needProxyProperties.forEach((/** * @param {?} property * @return {?} */ property => this.updateCompValue(property, this[property]))); /** @type {?} */ const visible_ = this.tooltip.nzVisibleChange.pipe(distinctUntilChanged()).subscribe((/** * @param {?} data * @return {?} */ data => { this.visible = data; this.nzVisibleChange.emit(data); })); /** @type {?} */ const cancel_ = ((/** @type {?} */ (this.tooltip))).nzOnCancel.subscribe((/** * @return {?} */ () => { this.nzOnCancel.emit(); })); /** @type {?} */ const confirm_ = ((/** @type {?} */ (this.tooltip))).nzOnConfirm.subscribe((/** * @return {?} */ () => { this.nzOnConfirm.emit(); })); this.subs_.add(visible_); this.subs_.add(cancel_); this.subs_.add(confirm_); } this.tooltip.setOverlayOrigin(this); } } NzPopconfirmDirective.decorators = [ { type: Directive, args: [{ selector: '[nz-popconfirm]', exportAs: 'nzPopconfirm', host: { '[class.ant-popover-open]': 'isTooltipOpen' } },] } ]; /** @nocollapse */ NzPopconfirmDirective.ctorParameters = () => [ { type: ElementRef }, { type: ViewContainerRef }, { type: ComponentFactoryResolver }, { type: Renderer2 }, { type: NzPopconfirmComponent, decorators: [{ type: Optional }] }, { type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] } ]; NzPopconfirmDirective.propDecorators = { nzOkText: [{ type: Input }], nzOkType: [{ type: Input }], nzCancelText: [{ type: Input }], nzIcon: [{ type: Input }], nzCondition: [{ type: Input }], nzOnCancel: [{ type: Output }], nzOnConfirm: [{ type: Output }] }; __decorate([ InputBoolean(), __metadata("design:type", Boolean) ], NzPopconfirmDirective.prototype, "nzCondition", void 0); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzPopconfirmModule { } NzPopconfirmModule.decorators = [ { type: NgModule, args: [{ declarations: [NzPopconfirmComponent, NzPopconfirmDirective], exports: [NzPopconfirmComponent, NzPopconfirmDirective], imports: [ CommonModule, NzButtonModule, OverlayModule, NzI18nModule, NzIconModule, NzAddOnModule, NzOverlayModule, NzNoAnimationModule, NzToolTipModule ], entryComponents: [NzPopconfirmComponent] },] } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { NzPopconfirmComponent, NzPopconfirmDirective, NzPopconfirmModule }; //# sourceMappingURL=ng-zorro-antd-popconfirm.js.map