ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
238 lines (232 loc) • 9.68 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Directionality, BidiModule } from '@angular/cdk/bidi';
import { EventEmitter, Directive, ElementRef, ViewContainerRef, ComponentFactoryResolver, Renderer2, Host, Optional, Input, Output, Component, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, NgModule } from '@angular/core';
import { zoomBigMotion } from 'ng-zorro-antd/core/animation';
import { NzNoAnimationDirective, NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { NzTooltipBaseDirective, NzToolTipComponent, NzToolTipModule } from 'ng-zorro-antd/tooltip';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { OverlayModule } from '@angular/cdk/overlay';
import { CommonModule } from '@angular/common';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzOverlayModule } from 'ng-zorro-antd/core/overlay';
import { NzI18nModule } from 'ng-zorro-antd/i18n';
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 NzPopconfirmDirective extends NzTooltipBaseDirective {
constructor(elementRef, hostView, resolver, renderer, noAnimation) {
super(elementRef, hostView, resolver, renderer, noAnimation);
this.trigger = 'click';
this.placement = 'top';
this.nzCondition = false;
this.nzPopconfirmShowArrow = true;
// tslint:disable-next-line:no-output-rename
this.visibleChange = new EventEmitter();
this.nzOnCancel = new EventEmitter();
this.nzOnConfirm = new EventEmitter();
this.componentFactory = this.resolver.resolveComponentFactory(NzPopconfirmComponent);
}
getProxyPropertyMap() {
return Object.assign({ nzOkText: ['nzOkText', () => this.nzOkText], nzOkType: ['nzOkType', () => this.nzOkType], nzCancelText: ['nzCancelText', () => this.nzCancelText], nzCondition: ['nzCondition', () => this.nzCondition], nzIcon: ['nzIcon', () => this.nzIcon], nzPopconfirmShowArrow: ['nzPopconfirmShowArrow', () => this.nzPopconfirmShowArrow] }, super.getProxyPropertyMap());
}
/**
* @override
*/
createComponent() {
super.createComponent();
this.component.nzOnCancel.pipe(takeUntil(this.destroy$)).subscribe(() => {
this.nzOnCancel.emit();
});
this.component.nzOnConfirm.pipe(takeUntil(this.destroy$)).subscribe(() => {
this.nzOnConfirm.emit();
});
}
}
NzPopconfirmDirective.decorators = [
{ type: Directive, args: [{
selector: '[nz-popconfirm]',
exportAs: 'nzPopconfirm',
host: {
'[class.ant-popover-open]': 'visible'
}
},] }
];
NzPopconfirmDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: ViewContainerRef },
{ type: ComponentFactoryResolver },
{ type: Renderer2 },
{ type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] }
];
NzPopconfirmDirective.propDecorators = {
title: [{ type: Input, args: ['nzPopconfirmTitle',] }],
directiveTitle: [{ type: Input, args: ['nz-popconfirm',] }],
trigger: [{ type: Input, args: ['nzPopconfirmTrigger',] }],
placement: [{ type: Input, args: ['nzPopconfirmPlacement',] }],
origin: [{ type: Input, args: ['nzPopconfirmOrigin',] }],
mouseEnterDelay: [{ type: Input, args: ['nzPopconfirmMouseEnterDelay',] }],
mouseLeaveDelay: [{ type: Input, args: ['nzPopconfirmMouseLeaveDelay',] }],
overlayClassName: [{ type: Input, args: ['nzPopconfirmOverlayClassName',] }],
overlayStyle: [{ type: Input, args: ['nzPopconfirmOverlayStyle',] }],
visible: [{ type: Input, args: ['nzPopconfirmVisible',] }],
nzOkText: [{ type: Input }],
nzOkType: [{ type: Input }],
nzCancelText: [{ type: Input }],
nzIcon: [{ type: Input }],
nzCondition: [{ type: Input }],
nzPopconfirmShowArrow: [{ type: Input }],
visibleChange: [{ type: Output, args: ['nzPopconfirmVisibleChange',] }],
nzOnCancel: [{ type: Output }],
nzOnConfirm: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Boolean)
], NzPopconfirmDirective.prototype, "nzCondition", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Boolean)
], NzPopconfirmDirective.prototype, "nzPopconfirmShowArrow", void 0);
class NzPopconfirmComponent extends NzToolTipComponent {
constructor(cdr, directionality, noAnimation) {
super(cdr, directionality, noAnimation);
this.noAnimation = noAnimation;
this.nzCondition = false;
this.nzPopconfirmShowArrow = true;
this.nzOkType = 'primary';
this.nzOnCancel = new Subject();
this.nzOnConfirm = new Subject();
this._trigger = 'click';
this._prefix = 'ant-popover';
}
ngOnDestroy() {
super.ngOnDestroy();
this.nzOnCancel.complete();
this.nzOnConfirm.complete();
}
/**
* @override
*/
show() {
if (!this.nzCondition) {
super.show();
}
else {
this.onConfirm();
}
}
onCancel() {
this.nzOnCancel.next();
super.hide();
}
onConfirm() {
this.nzOnConfirm.next();
super.hide();
}
}
NzPopconfirmComponent.decorators = [
{ type: Component, args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-popconfirm',
exportAs: 'nzPopconfirmComponent',
preserveWhitespaces: false,
animations: [zoomBigMotion],
template: `
<ng-template
#overlay="cdkConnectedOverlay"
cdkConnectedOverlay
nzConnectedOverlay
[cdkConnectedOverlayOrigin]="origin"
(overlayOutsideClick)="onClickOutside($event)"
(detach)="hide()"
(positionChange)="onPositionChange($event)"
[cdkConnectedOverlayPositions]="_positions"
[cdkConnectedOverlayOpen]="_visible"
[cdkConnectedOverlayPush]="true"
>
<div
class="ant-popover"
[ngClass]="_classMap"
[class.ant-popover-rtl]="dir === 'rtl'"
[ngStyle]="nzOverlayStyle"
[@.disabled]="noAnimation?.nzNoAnimation"
[nzNoAnimation]="noAnimation?.nzNoAnimation"
[ ]="'active'"
>
<div class="ant-popover-content">
<div class="ant-popover-arrow" *ngIf="nzPopconfirmShowArrow"></div>
<div class="ant-popover-inner">
<div>
<div class="ant-popover-inner-content">
<div class="ant-popover-message">
<ng-container *nzStringTemplateOutlet="nzTitle">
<ng-container *nzStringTemplateOutlet="nzIcon; let icon">
<i nz-icon [nzType]="icon || 'exclamation-circle'" nzTheme="fill"></i>
</ng-container>
<div class="ant-popover-message-title">{{ nzTitle }}</div>
</ng-container>
</div>
<div class="ant-popover-buttons">
<button nz-button [nzSize]="'small'" (click)="onCancel()">
<ng-container *ngIf="nzCancelText">{{ nzCancelText }}</ng-container>
<ng-container *ngIf="!nzCancelText">{{ 'Modal.cancelText' | nzI18n }}</ng-container>
</button>
<button nz-button [nzSize]="'small'" [nzType]="nzOkType" (click)="onConfirm()">
<ng-container *ngIf="nzOkText">{{ nzOkText }}</ng-container>
<ng-container *ngIf="!nzOkText">{{ 'Modal.okText' | nzI18n }}</ng-container>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</ng-template>
`
},] }
];
NzPopconfirmComponent.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: Directionality, decorators: [{ type: Optional }] },
{ type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] }
];
/**
* 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 NzPopconfirmModule {
}
NzPopconfirmModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzPopconfirmComponent, NzPopconfirmDirective],
exports: [NzPopconfirmComponent, NzPopconfirmDirective],
entryComponents: [NzPopconfirmComponent],
imports: [
BidiModule,
CommonModule,
NzButtonModule,
OverlayModule,
NzI18nModule,
NzIconModule,
NzOutletModule,
NzOverlayModule,
NzNoAnimationModule,
NzToolTipModule
]
},] }
];
/**
* 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 { NzPopconfirmComponent, NzPopconfirmDirective, NzPopconfirmModule };
//# sourceMappingURL=ng-zorro-antd-popconfirm.js.map