UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 13.9 kB
!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 d(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;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 y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}Object.create;var m=function(){function e(e,n,i,o,r){this.elementRef=e,this.hostView=n,this.resolver=i,this.renderer=o,this.noAnimation=r,this.nzTrigger="hover",this.nzPlacement="top",this.nzMouseEnterDelay=.15,this.nzMouseLeaveDelay=.1,this.needProxyProperties=["nzOverlayClassName","nzOverlayStyle","nzMouseEnterDelay","nzMouseLeaveDelay","nzVisible","noAnimation"],this.nzVisibleChange=new t.EventEmitter,this.visible=!1,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}),e.prototype.ngOnChanges=function(e){var t=e.nzTrigger,n=e.specificTrigger||t;n&&!n.isFirstChange()&&this.registerTriggers(),this.component&&this.updateChangedProperties(e),!e.nzTitle||this.specificTitle||this.directiveNameTitle||r.warnDeprecation("'nzTitle' of 'nz-tooltip' is deprecated and will be removed in 10.0.0.\nPlease use 'nzTooltipTitle' instead. The same with 'nz-popover' and 'nz-popconfirm'."),e.nzContent&&!this.specificContent&&r.warnDeprecation("'nzContent' of 'nz-popover' is deprecated and will be removed in 10.0.0.\nPlease use 'nzPopoverContent' instead."),e.nzPlacement&&!this.specificPlacement&&r.warnDeprecation("'nzPlacement' of 'nz-tooltip' is deprecated and will be removed in 10.0.0.\nPlease use 'nzTooltipContent' instead. The same with 'nz-popover' and 'nz-popconfirm'."),e.nzTrigger&&!this.specificTrigger&&r.warnDeprecation("'nzTrigger' of 'nz-tooltip' is deprecated and will be removed in 10.0.0.\nPlease use 'nzTooltipTrigger' instead. The same with 'nz-popover' and 'nz-popconfirm'.")},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.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.nzMouseEnterDelay)}))),this.triggerDisposables.push(this.renderer.listen(n,"mouseleave",(function(){var n;t.delayEnterLeave(!0,!1,t.nzMouseLeaveDelay),(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.updateChangedProperties=function(e){var t,n=this,i=Array.isArray(e);if((i?e:Object.keys(e)).forEach((function(e){-1!==n.needProxyProperties.indexOf(e)&&n.updateComponentValue(e,n[e])})),i)this.updateComponentValue("nzTitle",this.title),this.updateComponentValue("nzContent",this.content),this.updateComponentValue("nzPlacement",this.placement),this.updateComponentValue("nzTrigger",this.trigger);else{var o=e;(o.specificTitle||o.directiveNameTitle||o.nzTitle)&&this.updateComponentValue("nzTitle",this.title),(o.specificContent||o.directiveNameContent||o.nzContent)&&this.updateComponentValue("nzContent",this.content),(o.specificTrigger||o.nzTrigger)&&this.updateComponentValue("nzTrigger",this.trigger),(o.specificPlacement||o.nzPlacement)&&this.updateComponentValue("nzPlacement",this.placement)}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.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 f=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=y(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=y([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.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(t,n,i,o,r){var s=e.call(this,t,n,i,o,r)||this;return s.componentFactory=s.resolver.resolveComponentFactory(T),s}return d(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"]}]},n}(m);var T=function(e){function o(t,n){var i=e.call(this,t,n)||this;return i.noAnimation=n,i.nzTitle=null,i}return d(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}(f);var C=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[T,z],exports:[T,z],entryComponents:[T],imports:[c.CommonModule,o.OverlayModule,u.NzOutletModule,s.NzOverlayModule,i.NzNoAnimationModule]}]}],e}();e.NzToolTipComponent=T,e.NzToolTipModule=C,e.NzTooltipBaseComponent=f,e.NzTooltipBaseDirective=m,e.NzTooltipDirective=z,e.isTooltipEmpty=v,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-tooltip.umd.min.js.map