UNPKG

ng-zorro-antd

Version:

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

173 lines (167 loc) 7.12 kB
import { __decorate } 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 { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config'; import { NzNoAnimationDirective, NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation'; import { NzTooltipBaseDirective, NzToolTipComponent, isTooltipEmpty, NzToolTipModule } from 'ng-zorro-antd/tooltip'; import { OverlayModule } from '@angular/cdk/overlay'; import { CommonModule } from '@angular/common'; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'; import { NzOverlayModule } from 'ng-zorro-antd/core/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 */ const NZ_CONFIG_MODULE_NAME = 'popover'; class NzPopoverDirective extends NzTooltipBaseDirective { constructor(elementRef, hostView, resolver, renderer, noAnimation, nzConfigService) { super(elementRef, hostView, resolver, renderer, noAnimation, nzConfigService); this.noAnimation = noAnimation; this._nzModuleName = NZ_CONFIG_MODULE_NAME; this.trigger = 'hover'; this.placement = 'top'; this.nzPopoverBackdrop = false; // eslint-disable-next-line @angular-eslint/no-output-rename this.visibleChange = new EventEmitter(); this.componentFactory = this.resolver.resolveComponentFactory(NzPopoverComponent); } getProxyPropertyMap() { return Object.assign({ nzPopoverBackdrop: ['nzBackdrop', () => this.nzPopoverBackdrop] }, super.getProxyPropertyMap()); } } NzPopoverDirective.decorators = [ { type: Directive, args: [{ selector: '[nz-popover]', exportAs: 'nzPopover', host: { '[class.ant-popover-open]': 'visible' } },] } ]; NzPopoverDirective.ctorParameters = () => [ { type: ElementRef }, { type: ViewContainerRef }, { type: ComponentFactoryResolver }, { type: Renderer2 }, { type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] }, { type: NzConfigService } ]; NzPopoverDirective.propDecorators = { title: [{ type: Input, args: ['nzPopoverTitle',] }], content: [{ type: Input, args: ['nzPopoverContent',] }], directiveTitle: [{ type: Input, args: ['nz-popover',] }], trigger: [{ type: Input, args: ['nzPopoverTrigger',] }], placement: [{ type: Input, args: ['nzPopoverPlacement',] }], origin: [{ type: Input, args: ['nzPopoverOrigin',] }], visible: [{ type: Input, args: ['nzPopoverVisible',] }], mouseEnterDelay: [{ type: Input, args: ['nzPopoverMouseEnterDelay',] }], mouseLeaveDelay: [{ type: Input, args: ['nzPopoverMouseLeaveDelay',] }], overlayClassName: [{ type: Input, args: ['nzPopoverOverlayClassName',] }], overlayStyle: [{ type: Input, args: ['nzPopoverOverlayStyle',] }], nzPopoverBackdrop: [{ type: Input }], visibleChange: [{ type: Output, args: ['nzPopoverVisibleChange',] }] }; __decorate([ WithConfig() ], NzPopoverDirective.prototype, "nzPopoverBackdrop", void 0); class NzPopoverComponent extends NzToolTipComponent { constructor(cdr, directionality, noAnimation) { super(cdr, directionality, noAnimation); this.noAnimation = noAnimation; this._prefix = 'ant-popover'; } get hasBackdrop() { return this.nzTrigger === 'click' ? this.nzBackdrop : false; } isEmpty() { return isTooltipEmpty(this.nzTitle) && isTooltipEmpty(this.nzContent); } } NzPopoverComponent.decorators = [ { type: Component, args: [{ selector: 'nz-popover', exportAs: 'nzPopoverComponent', animations: [zoomBigMotion], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: ` <ng-template #overlay="cdkConnectedOverlay" cdkConnectedOverlay nzConnectedOverlay [cdkConnectedOverlayHasBackdrop]="hasBackdrop" [cdkConnectedOverlayOrigin]="origin" [cdkConnectedOverlayPositions]="_positions" [cdkConnectedOverlayOpen]="_visible" [cdkConnectedOverlayPush]="true" (overlayOutsideClick)="onClickOutside($event)" (detach)="hide()" (positionChange)="onPositionChange($event)" > <div class="ant-popover" [class.ant-popover-rtl]="dir === 'rtl'" [ngClass]="_classMap" [ngStyle]="nzOverlayStyle" [@.disabled]="noAnimation?.nzNoAnimation" [nzNoAnimation]="noAnimation?.nzNoAnimation" [@zoomBigMotion]="'active'" > <div class="ant-popover-content"> <div class="ant-popover-arrow"> <span class="ant-popover-arrow-content"></span> </div> <div class="ant-popover-inner" role="tooltip"> <div> <div class="ant-popover-title" *ngIf="nzTitle"> <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container> </div> <div class="ant-popover-inner-content"> <ng-container *nzStringTemplateOutlet="nzContent">{{ nzContent }}</ng-container> </div> </div> </div> </div> </div> </ng-template> ` },] } ]; NzPopoverComponent.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 NzPopoverModule { } NzPopoverModule.decorators = [ { type: NgModule, args: [{ exports: [NzPopoverDirective, NzPopoverComponent], entryComponents: [NzPopoverComponent], declarations: [NzPopoverDirective, NzPopoverComponent], imports: [ BidiModule, CommonModule, OverlayModule, 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 { NzPopoverComponent, NzPopoverDirective, NzPopoverModule }; //# sourceMappingURL=ng-zorro-antd-popover.js.map