ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 17.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ng-zorro-antd/core/animation"),require("ng-zorro-antd/core/no-animation"),require("@angular/cdk/overlay"),require("ng-zorro-antd/core/logger"),require("ng-zorro-antd/core/overlay"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("ng-zorro-antd/core/outlet")):"function"==typeof define&&define.amd?define("ng-zorro-antd/tooltip",["exports","@angular/core","ng-zorro-antd/core/animation","ng-zorro-antd/core/no-animation","@angular/cdk/overlay","ng-zorro-antd/core/logger","ng-zorro-antd/core/overlay","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/common","ng-zorro-antd/core/outlet"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].tooltip={}),e.ng.core,e["ng-zorro-antd"].core.animation,e["ng-zorro-antd"].core["no-animation"],e.ng.cdk.overlay,e["ng-zorro-antd"].core.logger,e["ng-zorro-antd"].core.overlay,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e.ng.common,e["ng-zorro-antd"].core.outlet)}(this,(function(e,t,n,i,o,r,s,a,l,p,c,u){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var h=function(e,t){return(h=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 y(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function g(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function d(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}var f=function(){function e(e,n,i,o,r){this.elementRef=e,this.hostView=n,this.resolver=i,this.renderer=o,this.noAnimation=r,this.specificVisibleChange=new t.EventEmitter,this.nzTrigger="hover",this.nzPlacement="top",this.visible=!1,this.needProxyProperties=["noAnimation"],this.nzVisibleChange=new t.EventEmitter,this.destroy$=new l.Subject,this.triggerDisposables=[]}return Object.defineProperty(e.prototype,"title",{get:function(){return this.specificTitle||this.directiveNameTitle||this.nzTitle||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"content",{get:function(){return this.specificContent||this.directiveNameContent||this.nzContent||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"placement",{get:function(){return this.specificPlacement||this.nzPlacement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trigger",{get:function(){return void 0!==this.specificTrigger?this.specificTrigger:this.nzTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return this.specificVisible||this.nzVisible||!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mouseEnterDelay",{get:function(){return this.specificMouseEnterDelay||this.nzMouseEnterDelay||.15},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mouseLeaveDelay",{get:function(){return this.specificMouseLeaveDelay||this.nzMouseLeaveDelay||.1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"overlayClassName",{get:function(){return this.specificOverlayClassName||this.nzOverlayClassName||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"overlayStyle",{get:function(){return this.specificOverlayStyle||this.nzOverlayStyle||null},enumerable:!0,configurable:!0}),e.prototype.warnDeprecationIfNeeded=function(e,t,n,i,o){if(void 0===i&&(i="nz-tooltip"),void 0===o&&(o=!0),e){var s="'"+t+"' of '"+i+"' is deprecated and will be removed in 10.0.0.\n Please use '"+n+"' instead.";o&&(s+=" The same with 'nz-popover' and 'nz-popconfirm'."),r.warnDeprecation(s)}},e.prototype.warnDeprecationByChanges=function(e){this.warnDeprecationIfNeeded(e.nzTitle&&!this.specificTitle&&!this.directiveNameTitle,"nzTitle","nzTooltipTitle"),this.warnDeprecationIfNeeded(e.nzContent&&!this.specificContent,"nzContent","nzPopoverContent","nz-popover",!1),this.warnDeprecationIfNeeded(e.nzPlacement&&!this.specificPlacement,"nzPlacement","nzTooltipPlacement"),this.warnDeprecationIfNeeded(e.nzTrigger&&!this.specificTrigger,"nzTrigger","nzTooltipTrigger"),this.warnDeprecationIfNeeded(e.nzVisible&&!this.specificVisible,"nzVisible","nzTooltipVisible"),this.warnDeprecationIfNeeded(e.nzMouseEnterDelay&&!this.specificMouseEnterDelay,"nzMouseEnterDelay","nzTooltipMouseEnterDelay"),this.warnDeprecationIfNeeded(e.nzMouseLeaveDelay&&!this.specificMouseLeaveDelay,"nzMouseLeaveDelay","nzTooltipMouseLeaveDelay"),this.warnDeprecationIfNeeded(e.nzOverlayClassName&&!this.specificOverlayClassName,"nzOverlayClassName","nzTooltipClassName"),this.warnDeprecationIfNeeded(e.nzOverlayStyle&&!this.specificOverlayStyle,"nzOverlayStyle","nzTooltipOverlayStyle")},e.prototype.ngOnChanges=function(e){var t=e.nzTrigger,n=e.specificTrigger||t;n&&!n.isFirstChange()&&this.registerTriggers(),this.component&&this.updateChangedProperties(e),this.warnDeprecationByChanges(e)},e.prototype.ngAfterViewInit=function(){this.createComponent(),this.registerTriggers()},e.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.clearTogglingTimer(),this.removeTriggerListeners()},e.prototype.show=function(){var e;null===(e=this.component)||void 0===e||e.show()},e.prototype.hide=function(){var e;null===(e=this.component)||void 0===e||e.hide()},e.prototype.updatePosition=function(){this.component&&this.component.updatePosition()},e.prototype.createComponent=function(){var e=this,t=this.hostView.createComponent(this.componentFactory);this.component=t.instance,this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement),t.location.nativeElement),this.component.setOverlayOrigin({elementRef:this.specificOrigin||this.elementRef}),this.updateChangedProperties(this.needProxyProperties),this.component.nzVisibleChange.pipe(p.distinctUntilChanged(),p.takeUntil(this.destroy$)).subscribe((function(t){e.visible=t,e.specificVisibleChange.emit(t),e.nzVisibleChange.emit(t)}))},e.prototype.registerTriggers=function(){var e,t=this,n=this.elementRef.nativeElement,i=this.trigger;(this.removeTriggerListeners(),"hover"===i)?(this.triggerDisposables.push(this.renderer.listen(n,"mouseenter",(function(){t.delayEnterLeave(!0,!0,t.mouseEnterDelay)}))),this.triggerDisposables.push(this.renderer.listen(n,"mouseleave",(function(){var n;t.delayEnterLeave(!0,!1,t.mouseLeaveDelay),(null===(n=t.component)||void 0===n?void 0:n.overlay.overlayRef)&&!e&&(e=t.component.overlay.overlayRef.overlayElement,t.triggerDisposables.push(t.renderer.listen(e,"mouseenter",(function(){t.delayEnterLeave(!1,!0)}))),t.triggerDisposables.push(t.renderer.listen(e,"mouseleave",(function(){t.delayEnterLeave(!1,!1)}))))})))):"focus"===i?(this.triggerDisposables.push(this.renderer.listen(n,"focus",(function(){return t.show()}))),this.triggerDisposables.push(this.renderer.listen(n,"blur",(function(){return t.hide()})))):"click"===i&&this.triggerDisposables.push(this.renderer.listen(n,"click",(function(e){e.preventDefault(),t.show()})))},e.prototype.updatePropertiesByChanges=function(e){var t=this,n={specificTitle:["nzTitle",this.title],directiveNameTitle:["nzTitle",this.title],nzTitle:["nzTitle",this.title],specificContent:["nzContent",this.content],directiveNameContent:["nzContent",this.content],nzContent:["nzContent",this.content],specificTrigger:["nzTrigger",this.trigger],nzTrigger:["nzTrigger",this.trigger],specificPlacement:["nzPlacement",this.placement],nzPlacement:["nzPlacement",this.placement],specificVisible:["nzVisible",this.isVisible],nzVisible:["nzVisible",this.isVisible],specificMouseEnterDelay:["nzMouseEnterDelay",this.mouseEnterDelay],nzMouseEnterDelay:["nzMouseEnterDelay",this.mouseEnterDelay],specificMouseLeaveDelay:["nzMouseLeaveDelay",this.mouseLeaveDelay],nzMouseLeaveDelay:["nzMouseLeaveDelay",this.mouseLeaveDelay],specificOverlayClassName:["nzOverlayClassName",this.overlayClassName],nzOverlayClassName:["nzOverlayClassName",this.overlayClassName],specificOverlayStyle:["nzOverlayStyle",this.overlayStyle],nzOverlayStyle:["nzOverlayStyle",this.overlayStyle]};Object.keys(e).forEach((function(e){if(n[e]){var i=g(n[e],2),o=i[0],r=i[1];t.updateComponentValue(o,r)}}))},e.prototype.updatePropertiesByArray=function(){this.updateComponentValue("nzTitle",this.title),this.updateComponentValue("nzContent",this.content),this.updateComponentValue("nzPlacement",this.placement),this.updateComponentValue("nzTrigger",this.trigger),this.updateComponentValue("nzVisible",this.isVisible),this.updateComponentValue("nzMouseEnterDelay",this.mouseEnterDelay),this.updateComponentValue("nzMouseLeaveDelay",this.mouseLeaveDelay),this.updateComponentValue("nzOverlayClassName",this.overlayClassName),this.updateComponentValue("nzOverlayStyle",this.overlayStyle)},e.prototype.updateChangedProperties=function(e){var t,n=this,i=Array.isArray(e);(i?e:Object.keys(e)).forEach((function(e){-1!==n.needProxyProperties.indexOf(e)&&n.updateComponentValue(e,n[e])})),i?this.updatePropertiesByArray():this.updatePropertiesByChanges(e),null===(t=this.component)||void 0===t||t.updateByDirective()},e.prototype.updateComponentValue=function(e,t){void 0!==t&&(this.component[e]=t)},e.prototype.delayEnterLeave=function(e,t,n){var i=this;void 0===n&&(n=-1),this.delayTimer?this.clearTogglingTimer():n>0?this.delayTimer=setTimeout((function(){i.delayTimer=void 0,t?i.show():i.hide()}),1e3*n):t&&e?this.show():this.hide()},e.prototype.removeTriggerListeners=function(){this.triggerDisposables.forEach((function(e){return e()})),this.triggerDisposables.length=0},e.prototype.clearTogglingTimer=function(){this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=void 0)},e.decorators=[{type:t.Directive}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef},{type:t.ComponentFactoryResolver},{type:t.Renderer2},{type:i.NzNoAnimationDirective}]},e.propDecorators={nzTitle:[{type:t.Input}],nzContent:[{type:t.Input}],nzTrigger:[{type:t.Input}],nzPlacement:[{type:t.Input}],nzMouseEnterDelay:[{type:t.Input}],nzMouseLeaveDelay:[{type:t.Input}],nzOverlayClassName:[{type:t.Input}],nzOverlayStyle:[{type:t.Input}],nzVisible:[{type:t.Input}],nzVisibleChange:[{type:t.Output}]},e}();var m=function(){function e(e,t){this.cdr=e,this.noAnimation=t,this.nzVisibleChange=new l.Subject,this.nzTitle=null,this.nzContent=null,this.nzOverlayStyle={},this._visible=!1,this._trigger="hover",this.preferredPlacement="top",this._classMap={},this._hasBackdrop=!1,this._prefix="ant-tooltip-placement",this._positions=d(s.DEFAULT_TOOLTIP_POSITIONS)}return Object.defineProperty(e.prototype,"nzVisible",{get:function(){return this._visible},set:function(e){var t=a.toBoolean(e);this._visible!==t&&(this._visible=t,this.nzVisibleChange.next(t))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzTrigger",{get:function(){return this._trigger},set:function(e){this._trigger=e,this._hasBackdrop="click"===this._trigger},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzPlacement",{get:function(){return this.preferredPlacement},set:function(e){e!==this.preferredPlacement&&(this.preferredPlacement=e,this._positions=d([s.POSITION_MAP[this.nzPlacement]],this._positions))},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.nzVisibleChange.complete()},e.prototype.show=function(){this.nzVisible||this.isEmpty()||(this.nzVisible=!0,this.nzVisibleChange.next(!0),this.cdr.detectChanges())},e.prototype.hide=function(){this.nzVisible&&(this.nzVisible=!1,this.nzVisibleChange.next(!1),this.cdr.detectChanges())},e.prototype.updateByDirective=function(){var e=this;this.setClassMap(),this.cdr.detectChanges(),Promise.resolve().then((function(){e.updatePosition(),e.updateVisibilityByTitle()}))},e.prototype.updatePosition=function(){this.origin&&this.overlay&&this.overlay.overlayRef&&this.overlay.overlayRef.updatePosition()},e.prototype.onPositionChange=function(e){this.preferredPlacement=s.getPlacementName(e),this.setClassMap(),this.cdr.detectChanges()},e.prototype.setClassMap=function(){var e;this._classMap=((e={})[this.nzOverlayClassName]=!0,e[this._prefix+"-"+this.preferredPlacement]=!0,e)},e.prototype.setOverlayOrigin=function(e){this.origin=e,this.cdr.markForCheck()},e.prototype.updateVisibilityByTitle=function(){this.isEmpty()&&this.hide()},e.decorators=[{type:t.Directive}],e.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:i.NzNoAnimationDirective}]},e.propDecorators={overlay:[{type:t.ViewChild,args:["overlay",{static:!1}]}]},e}();function v(e){return!(e instanceof t.TemplateRef)&&(""===e||!a.isNotNil(e))}var z=function(e){function n(n,i,o,r,s){var a=e.call(this,n,i,o,r,s)||this;return a.specificVisibleChange=new t.EventEmitter,a.componentFactory=a.resolver.resolveComponentFactory(C),a}return y(n,e),n.decorators=[{type:t.Directive,args:[{selector:"[nz-tooltip]",exportAs:"nzTooltip",host:{"[class.ant-tooltip-open]":"visible"}}]}],n.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef},{type:t.ComponentFactoryResolver},{type:t.Renderer2},{type:i.NzNoAnimationDirective,decorators:[{type:t.Host},{type:t.Optional}]}]},n.propDecorators={specificTitle:[{type:t.Input,args:["nzTooltipTitle"]}],directiveNameTitle:[{type:t.Input,args:["nz-tooltip"]}],specificTrigger:[{type:t.Input,args:["nzTooltipTrigger"]}],specificPlacement:[{type:t.Input,args:["nzTooltipPlacement"]}],specificOrigin:[{type:t.Input,args:["nzTooltipOrigin"]}],specificVisible:[{type:t.Input,args:["nzTooltipVisible"]}],specificMouseEnterDelay:[{type:t.Input,args:["nzTooltipMouseEnterDelay"]}],specificMouseLeaveDelay:[{type:t.Input,args:["nzTooltipMouseLeaveDelay"]}],specificOverlayClassName:[{type:t.Input,args:["nzTooltipOverlayClassName"]}],specificOverlayStyle:[{type:t.Input,args:["nzTooltipOverlayStyle"]}],specificVisibleChange:[{type:t.Output,args:["nzTooltipVisibleChange"]}]},n}(f);var C=function(e){function o(t,n){var i=e.call(this,t,n)||this;return i.noAnimation=n,i.nzTitle=null,i}return y(o,e),o.prototype.isEmpty=function(){return v(this.nzTitle)},o.decorators=[{type:t.Component,args:[{selector:"nz-tooltip",exportAs:"nzTooltipComponent",changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,animations:[n.zoomBigMotion],template:'\n <ng-template\n #overlay="cdkConnectedOverlay"\n cdkConnectedOverlay\n nzConnectedOverlay\n [cdkConnectedOverlayOrigin]="origin"\n [cdkConnectedOverlayOpen]="_visible"\n [cdkConnectedOverlayHasBackdrop]="_hasBackdrop"\n [cdkConnectedOverlayPositions]="_positions"\n (backdropClick)="hide()"\n (detach)="hide()"\n (positionChange)="onPositionChange($event)"\n >\n <div\n class="ant-tooltip"\n [ngClass]="_classMap"\n [ngStyle]="nzOverlayStyle"\n [@.disabled]="noAnimation?.nzNoAnimation"\n [nzNoAnimation]="noAnimation?.nzNoAnimation"\n [@zoomBigMotion]="\'active\'"\n >\n <div class="ant-tooltip-content">\n <div class="ant-tooltip-arrow"></div>\n <div class="ant-tooltip-inner">\n <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>\n </div>\n </div>\n </div>\n </ng-template>\n ',preserveWhitespaces:!1}]}],o.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:i.NzNoAnimationDirective,decorators:[{type:t.Host},{type:t.Optional}]}]},o.propDecorators={nzTitle:[{type:t.Input}]},o}(m);var b=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[C,z],exports:[C,z],entryComponents:[C],imports:[c.CommonModule,o.OverlayModule,u.NzOutletModule,s.NzOverlayModule,i.NzNoAnimationModule]}]}],e}();e.NzToolTipComponent=C,e.NzToolTipModule=b,e.NzTooltipBaseComponent=m,e.NzTooltipBaseDirective=f,e.NzTooltipDirective=z,e.isTooltipEmpty=v,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-tooltip.umd.min.js.map