UNPKG

ng-zorro-antd

Version:

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

10 lines 12.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("ng-zorro-antd/core"),require("@angular/cdk/overlay"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-zorro-antd/tooltip",["exports","@angular/core","ng-zorro-antd/core","@angular/cdk/overlay","rxjs","rxjs/operators","@angular/common"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].tooltip={}),t.ng.core,t["ng-zorro-antd"].core,t.ng.cdk.overlay,t.rxjs,t.rxjs.operators,t.ng.common)}(this,function(t,e,n,i,o,r,s){"use strict";var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function p(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t} /** * @license * Copyright Alibaba.com All Rights Reserved. * * 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 */ var h=function(){function t(t,i){this.cdr=t,this.noAnimation=i,this.nzVisibleChange=new e.EventEmitter,this._classMap={},this._hasBackdrop=!1,this._prefix="ant-tooltip-placement",this._visible=!1,this._positions=c(n.DEFAULT_TOOLTIP_POSITIONS),this._placement="top",this._trigger="hover"}return Object.defineProperty(t.prototype,"content",{get:function(){return void 0!==this.nzContent?this.nzContent:this.nzContentTemplate},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"title",{get:function(){return void 0!==this.nzTitle?this.nzTitle:this.nzTitleTemplate},enumerable:!0,configurable:!0}),t.prototype.show=function(){this.nzVisible||this.isTitleEmpty()&&this.isContentEmpty()||(this.nzVisible=!0,this.nzVisibleChange.emit(!0),this.cdr.detectChanges())},t.prototype.hide=function(){this.nzVisible&&(this.nzVisible=!1,this.nzVisibleChange.emit(!1),this.cdr.detectChanges())},t.prototype.updateByDirective=function(){var t=this;this.setClassMap(),this.cdr.detectChanges(),Promise.resolve().then(function(){t.updatePosition()})},t.prototype.updatePosition=function(){this.origin&&this.overlay&&this.overlay.overlayRef&&this.overlay.overlayRef.updatePosition()},t.prototype.onPositionChange=function(t){this._placement=n.getPlacementName(t),this.setClassMap(),this.cdr.detectChanges()},t.prototype.setClassMap=function(){var t;this._classMap=((t={})[this.nzOverlayClassName]=!0,t[this._prefix+"-"+this._placement]=!0,t)},t.prototype.setOverlayOrigin=function(t){this.origin=t,this.cdr.markForCheck()},t.prototype.isTitleEmpty=function(){return!(this.title instanceof e.TemplateRef)&&(""===this.title||!n.isNotNil(this.title))},t.prototype.isContentEmpty=function(){return!(this.content instanceof e.TemplateRef)&&(""===this.content||!n.isNotNil(this.content))},t.propDecorators={nzVisibleChange:[{type:e.Output}]},t}();var u=function(t){function i(n,i){var o=t.call(this,n,i)||this;return o.noAnimation=i,o.nzOverlayClassName="",o.nzOverlayStyle={},o.nzMouseEnterDelay=.15,o.nzMouseLeaveDelay=.1,o.nzVisibleChange=new e.EventEmitter,o}return p(i,t),Object.defineProperty(i.prototype,"nzPlacement",{get:function(){return this._placement},set:function(t){t!==this._placement&&(this._placement=t,this._positions=c([n.POSITION_MAP[this.nzPlacement]],this._positions))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"nzVisible",{get:function(){return this._visible},set:function(t){var e=n.toBoolean(t);this._visible!==e&&(this._visible=e,this.nzVisibleChange.emit(e))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"nzTrigger",{get:function(){return this._trigger},set:function(t){this._trigger=t,this._hasBackdrop="click"===this._trigger},enumerable:!0,configurable:!0}),i.prototype.ngOnChanges=function(){var t=this;Promise.resolve().then(function(){t.updatePosition()})},i.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:n.NzNoAnimationDirective,decorators:[{type:e.Host},{type:e.Optional}]}]},i.propDecorators={overlay:[{type:e.ViewChild,args:["overlay",{static:!1}]}],nzOverlayClassName:[{type:e.Input}],nzOverlayStyle:[{type:e.Input}],nzMouseEnterDelay:[{type:e.Input}],nzMouseLeaveDelay:[{type:e.Input}],nzPlacement:[{type:e.Input}],nzVisible:[{type:e.Input}],nzTrigger:[{type:e.Input}],nzVisibleChange:[{type:e.Output}]},i}(h);var y=function(t){function i(e,n){var i=t.call(this,e)||this;return i.noAnimation=n,i}return p(i,t),i.decorators=[{type:e.Component,args:[{selector:"nz-tooltip",exportAs:"nzTooltipComponent",changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,animations:[n.zoomBigMotion],template:'<ng-content></ng-content>\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 <div\n class="ant-tooltip"\n [ngClass]="_classMap"\n [ngStyle]="nzOverlayStyle"\n [@.disabled]="noAnimation?.nzNoAnimation"\n [nzNoAnimation]="noAnimation?.nzNoAnimation"\n [@zoomBigMotion]="\'active\'">\n <div class="ant-tooltip-content">\n <div class="ant-tooltip-arrow"></div>\n <div class="ant-tooltip-inner">\n <ng-container *nzStringTemplateOutlet="title">{{ title }}</ng-container>\n </div>\n </div>\n </div>\n</ng-template>',preserveWhitespaces:!1,providers:[{provide:u,useExisting:i}],styles:["\n .ant-tooltip {\n position: relative;\n }\n "]}]}],i.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:n.NzNoAnimationDirective,decorators:[{type:e.Host},{type:e.Optional}]}]},i.propDecorators={nzTitle:[{type:e.Input}],nzTitleTemplate:[{type:e.ContentChild,args:["nzTemplate",{static:!0}]}]},i}(u);var d=function(){function t(t,n,i,r,s,a){this.elementRef=t,this.hostView=n,this.resolver=i,this.renderer=r,this._tooltip=s,this.noAnimation=a,this.nzTrigger="hover",this.nzPlacement="top",this.needProxyProperties=["nzOverlayClassName","nzOverlayStyle","nzMouseEnterDelay","nzMouseLeaveDelay","nzVisible","noAnimation"],this.nzVisibleChange=new e.EventEmitter,this.isTooltipComponentVisible=!1,this.isDynamicTooltip=!1,this.triggerUnlisteners=[],this.$destroy=new o.Subject}return Object.defineProperty(t.prototype,"title",{get:function(){return this.specificTitle||this.directiveNameTitle||this.nzTitle},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"content",{get:function(){return this.specificContent||this.directiveNameContent||this.nzContent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"placement",{get:function(){return this.specificPlacement||this.nzPlacement},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trigger",{get:function(){return this.specificTrigger||this.nzTrigger},enumerable:!0,configurable:!0}),t.prototype.ngOnChanges=function(t){this.tooltip&&this.isDynamicTooltip&&this.updateChangedProperties(t)},t.prototype.ngOnInit=function(){var t=this;this._tooltip?(n.warnDeprecation("'<nz-tooltip></nz-tooltip>', '<nz-popover></nz-popover>' and '<nz-popconfirm></nz-popconfirm>' is deprecated and will be removed in 9.0.0. Refer: https://ng.ant.design/components/tooltip/zh ."),this.tooltip=this._tooltip,this.tooltip.setOverlayOrigin(this)):this.createDynamicTooltipComponent(),this.tooltip.nzVisibleChange.pipe(r.distinctUntilChanged(),r.takeUntil(this.$destroy)).subscribe(function(e){t.isTooltipComponentVisible=e,t.nzVisibleChange.emit(e)})},t.prototype.ngAfterViewInit=function(){this.registerTriggers()},t.prototype.ngOnDestroy=function(){this.$destroy.next(),this.$destroy.complete(),this.tooltipRef&&this.tooltipRef.destroy()},t.prototype.show=function(){this.tooltip.show()},t.prototype.hide=function(){this.tooltip.hide()},t.prototype.updatePosition=function(){this.tooltip&&this.isDynamicTooltip&&this.tooltip.updatePosition()},t.prototype.createDynamicTooltipComponent=function(){this.isDynamicTooltip=!0,this.tooltipRef=this.hostView.createComponent(this.componentFactory),this.tooltip=this.tooltipRef.instance,this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement),this.tooltipRef.location.nativeElement),this.tooltip.setOverlayOrigin(this),this.updateChangedProperties(this.needProxyProperties)},t.prototype.registerTriggers=function(){var t,e=this,n=this.elementRef.nativeElement,i=this.isDynamicTooltip?this.trigger:this.tooltip.nzTrigger;"hover"===i?(this.triggerUnlisteners.push(this.renderer.listen(n,"mouseenter",function(){e.delayEnterLeave(!0,!0,e.tooltip.nzMouseEnterDelay)})),this.triggerUnlisteners.push(this.renderer.listen(n,"mouseleave",function(){e.delayEnterLeave(!0,!1,e.tooltip.nzMouseLeaveDelay),e.tooltip.overlay.overlayRef&&!t&&(t=e.tooltip.overlay.overlayRef.overlayElement,e.triggerUnlisteners.push(e.renderer.listen(t,"mouseenter",function(){e.delayEnterLeave(!1,!0)})),e.triggerUnlisteners.push(e.renderer.listen(t,"mouseleave",function(){e.delayEnterLeave(!1,!1)})))}))):"focus"===i?(this.triggerUnlisteners.push(this.renderer.listen(n,"focus",function(){return e.show()})),this.triggerUnlisteners.push(this.renderer.listen(n,"blur",function(){return e.hide()}))):"click"===i&&this.triggerUnlisteners.push(this.renderer.listen(n,"click",function(t){t.preventDefault(),e.show()}))},t.prototype.updateChangedProperties=function(t){var e=this,n=Array.isArray(t);if((n?t:Object.keys(t)).forEach(function(t){-1!==e.needProxyProperties.indexOf(t)&&e.updateComponentValue(t,e[t])}),n)this.updateComponentValue("nzTitle",this.title),this.updateComponentValue("nzContent",this.content),this.updateComponentValue("nzPlacement",this.placement),this.updateComponentValue("nzTrigger",this.trigger);else{var i=t;(i.specificTitle||i.directiveNameTitle||i.nzTitle)&&this.updateComponentValue("nzTitle",this.title),(i.specificContent||i.directiveNameContent||i.nzContent)&&this.updateComponentValue("nzContent",this.content),(i.specificTrigger||i.nzTrigger)&&this.updateComponentValue("nzTrigger",this.trigger),(i.specificPlacement||i.nzPlacement)&&this.updateComponentValue("nzPlacement",this.placement)}this.tooltip.updateByDirective()},t.prototype.updateComponentValue=function(t,e){n.isNotNil(e)&&(this.tooltip[t]=e)},t.prototype.delayEnterLeave=function(t,e,n){var i=this;void 0===n&&(n=-1),this.delayTimer?(clearTimeout(this.delayTimer),this.delayTimer=void 0):n>0?this.delayTimer=setTimeout(function(){i.delayTimer=void 0,e?i.show():i.hide()},1e3*n):e&&t?this.show():this.hide()},t.propDecorators={nzTitle:[{type:e.Input}],nzContent:[{type:e.Input}],nzTrigger:[{type:e.Input}],nzPlacement:[{type:e.Input}],nzMouseEnterDelay:[{type:e.Input}],nzMouseLeaveDelay:[{type:e.Input}],nzOverlayClassName:[{type:e.Input}],nzOverlayStyle:[{type:e.Input}],nzVisible:[{type:e.Input}],nzVisibleChange:[{type:e.Output}]},t}();var g=function(t){function i(e,n,i,o,r,s){var a=t.call(this,e,n,i,o,r,s)||this;return a.componentFactory=a.resolver.resolveComponentFactory(y),a}return p(i,t),i.decorators=[{type:e.Directive,args:[{selector:"[nz-tooltip]",exportAs:"nzTooltip",host:{"[class.ant-tooltip-open]":"isTooltipComponentVisible"}}]}],i.ctorParameters=function(){return[{type:e.ElementRef},{type:e.ViewContainerRef},{type:e.ComponentFactoryResolver},{type:e.Renderer2},{type:u,decorators:[{type:e.Optional}]},{type:n.NzNoAnimationDirective,decorators:[{type:e.Host},{type:e.Optional}]}]},i.propDecorators={specificTitle:[{type:e.Input,args:["nzTooltipTitle"]}],directiveNameTitle:[{type:e.Input,args:["nz-tooltip"]}],specificTrigger:[{type:e.Input,args:["nzTooltipTrigger"]}],specificPlacement:[{type:e.Input,args:["nzTooltipPlacement"]}]},i}(d);var m=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[y,g],exports:[y,g],imports:[s.CommonModule,i.OverlayModule,n.NzAddOnModule,n.NzOverlayModule,n.NzNoAnimationModule],entryComponents:[y]}]}],t}();t.NzToolTipComponent=y,t.NzToolTipModule=m,t.NzTooltipBaseComponent=h,t.NzTooltipBaseComponentLegacy=u,t.NzTooltipBaseDirective=d,t.NzTooltipDirective=g,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-tooltip.umd.min.js.map