ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 15.7 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/color"),require("ng-zorro-antd/core/no-animation"),require("@angular/cdk/bidi"),require("ng-zorro-antd/core/overlay"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/overlay"),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/color","ng-zorro-antd/core/no-animation","@angular/cdk/bidi","ng-zorro-antd/core/overlay","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/cdk/overlay","@angular/common","ng-zorro-antd/core/outlet"],t):t(((e="undefined"!=typeof globalThis?globalThis: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.color,e["ng-zorro-antd"].core["no-animation"],e.ng.cdk.bidi,e["ng-zorro-antd"].core.overlay,e["ng-zorro-antd"].core.util,e.rxjs,e.rxjs.operators,e.ng.cdk.overlay,e.ng.common,e["ng-zorro-antd"].core.outlet)}(this,(function(e,t,n,o,i,r,s,a,l,p,c,u,y){"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)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}Object.create;var f=function(){function e(e,n,o,i,r){this.elementRef=e,this.hostView=n,this.resolver=o,this.renderer=i,this.noAnimation=r,this.visibleChange=new t.EventEmitter,this.internalVisible=!1,this.destroy$=new l.Subject,this.triggerDisposables=[]}return Object.defineProperty(e.prototype,"_title",{get:function(){return this.title||this.directiveTitle||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_content",{get:function(){return this.content||this.directiveContent||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_trigger",{get:function(){return void 0!==this.trigger?this.trigger:"hover"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_placement",{get:function(){var e=this.placement;return Array.isArray(e)&&e.length>0?e:"string"==typeof e&&e?[e]:["top"]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_visible",{get:function(){return(void 0!==this.visible?this.visible:this.internalVisible)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_mouseEnterDelay",{get:function(){return this.mouseEnterDelay||.15},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_mouseLeaveDelay",{get:function(){return this.mouseLeaveDelay||.1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_overlayClassName",{get:function(){return this.overlayClassName||null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_overlayStyle",{get:function(){return this.overlayStyle||null},enumerable:!1,configurable:!0}),e.prototype.getProxyPropertyMap=function(){var e=this;return{noAnimation:["noAnimation",function(){return e.noAnimation}]}},e.prototype.ngOnChanges=function(e){var t=e.specificTrigger;t&&!t.isFirstChange()&&this.registerTriggers(),this.component&&this.updatePropertiesByChanges(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.origin||this.elementRef}),this.initProperties(),this.component.nzVisibleChange.pipe(p.distinctUntilChanged(),p.takeUntil(this.destroy$)).subscribe((function(t){e.internalVisible=t,e.visibleChange.emit(t)}))},e.prototype.registerTriggers=function(){var e,t=this,n=this.elementRef.nativeElement,o=this.trigger;(this.removeTriggerListeners(),"hover"===o)?(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._mouseEnterDelay)}))),t.triggerDisposables.push(t.renderer.listen(e,"mouseleave",(function(){t.delayEnterLeave(!1,!1,t._mouseLeaveDelay)}))))})))):"focus"===o?(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"===o&&this.triggerDisposables.push(this.renderer.listen(n,"click",(function(e){e.preventDefault(),t.show()})))},e.prototype.updatePropertiesByChanges=function(e){this.updatePropertiesByKeys(Object.keys(e))},e.prototype.updatePropertiesByKeys=function(e){var t,n=this,o=Object.assign({title:["nzTitle",function(){return n._title}],directiveTitle:["nzTitle",function(){return n._title}],content:["nzContent",function(){return n._content}],directiveContent:["nzContent",function(){return n._content}],trigger:["nzTrigger",function(){return n._trigger}],placement:["nzPlacement",function(){return n._placement}],visible:["nzVisible",function(){return n._visible}],mouseEnterDelay:["nzMouseEnterDelay",function(){return n._mouseEnterDelay}],mouseLeaveDelay:["nzMouseLeaveDelay",function(){return n._mouseLeaveDelay}],overlayClassName:["nzOverlayClassName",function(){return n._overlayClassName}],overlayStyle:["nzOverlayStyle",function(){return n._overlayStyle}]},this.getProxyPropertyMap());(e||Object.keys(o).filter((function(e){return!e.startsWith("directive")}))).forEach((function(e){if(o[e]){var t=d(o[e],2),i=t[0],r=t[1];n.updateComponentValue(i,r())}})),null===(t=this.component)||void 0===t||t.updateByDirective()},e.prototype.initProperties=function(){this.updatePropertiesByKeys()},e.prototype.updateComponentValue=function(e,t){void 0!==t&&(this.component[e]=t)},e.prototype.delayEnterLeave=function(e,t,n){var o=this;void 0===n&&(n=-1),this.delayTimer?this.clearTogglingTimer():n>0?this.delayTimer=setTimeout((function(){o.delayTimer=void 0,t?o.show():o.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}();f.decorators=[{type:t.Directive}],f.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef},{type:t.ComponentFactoryResolver},{type:t.Renderer2},{type:i.NzNoAnimationDirective}]};var m=function(){function e(e,t,n){this.cdr=e,this.directionality=t,this.noAnimation=n,this.nzTitle=null,this.nzContent=null,this.nzOverlayStyle={},this.nzVisibleChange=new l.Subject,this._visible=!1,this._trigger="hover",this.preferredPlacement="top",this.dir="ltr",this._classMap={},this._hasBackdrop=!1,this._prefix="ant-tooltip",this._positions=v(s.DEFAULT_TOOLTIP_POSITIONS),this.destroy$=new l.Subject}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:!1,configurable:!0}),Object.defineProperty(e.prototype,"nzTrigger",{get:function(){return this._trigger},set:function(e){this._trigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nzPlacement",{set:function(e){var t=e.map((function(e){return s.POSITION_MAP[e]}));this._positions=v(t,s.DEFAULT_TOOLTIP_POSITIONS)},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){var e,t=this;null===(e=this.directionality.change)||void 0===e||e.pipe(p.takeUntil(this.destroy$)).subscribe((function(e){t.dir=e,t.cdr.detectChanges()})),this.dir=this.directionality.value},e.prototype.ngOnDestroy=function(){this.nzVisibleChange.complete(),this.destroy$.next(),this.destroy$.complete()},e.prototype.show=function(){this.nzVisible||(this.isEmpty()||(this.nzVisible=!0,this.nzVisibleChange.next(!0),this.cdr.detectChanges()),this.origin&&this.overlay&&this.overlay.overlayRef&&"rtl"===this.overlay.overlayRef.getDirection()&&this.overlay.overlayRef.setDirection("ltr"))},e.prototype.hide=function(){this.nzVisible&&(this.nzVisible=!1,this.nzVisibleChange.next(!1),this.cdr.detectChanges())},e.prototype.updateByDirective=function(){var e=this;this.updateStyles(),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.updateStyles(),this.cdr.detectChanges()},e.prototype.updateStyles=function(){var e;this._classMap=((e={})[this.nzOverlayClassName]=!0,e[this._prefix+"-placement-"+this.preferredPlacement]=!0,e)},e.prototype.setOverlayOrigin=function(e){this.origin=e,this.cdr.markForCheck()},e.prototype.onClickOutside=function(e){this.origin.elementRef.nativeElement.contains(e.target)||this.hide()},e.prototype.updateVisibilityByTitle=function(){this.isEmpty()&&this.hide()},e}();function b(e){return!(e instanceof t.TemplateRef)&&(""===e||!a.isNotNil(e))}m.decorators=[{type:t.Directive}],m.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:r.Directionality,decorators:[{type:t.Optional}]},{type:i.NzNoAnimationDirective}]},m.propDecorators={overlay:[{type:t.ViewChild,args:["overlay",{static:!1}]}]};var z=function(e){function n(n,o,i,r,s){var a=e.call(this,n,o,i,r,s)||this;return a.trigger="hover",a.placement="top",a.visibleChange=new t.EventEmitter,a.componentFactory=a.resolver.resolveComponentFactory(C),a}return g(n,e),n.prototype.getProxyPropertyMap=function(){var e=this;return{nzTooltipColor:["nzColor",function(){return e.nzTooltipColor}]}},n}(f);z.decorators=[{type:t.Directive,args:[{selector:"[nz-tooltip]",exportAs:"nzTooltip",host:{"[class.ant-tooltip-open]":"visible"}}]}],z.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}]}]},z.propDecorators={title:[{type:t.Input,args:["nzTooltipTitle"]}],directiveTitle:[{type:t.Input,args:["nz-tooltip"]}],trigger:[{type:t.Input,args:["nzTooltipTrigger"]}],placement:[{type:t.Input,args:["nzTooltipPlacement"]}],origin:[{type:t.Input,args:["nzTooltipOrigin"]}],visible:[{type:t.Input,args:["nzTooltipVisible"]}],mouseEnterDelay:[{type:t.Input,args:["nzTooltipMouseEnterDelay"]}],mouseLeaveDelay:[{type:t.Input,args:["nzTooltipMouseLeaveDelay"]}],overlayClassName:[{type:t.Input,args:["nzTooltipOverlayClassName"]}],overlayStyle:[{type:t.Input,args:["nzTooltipOverlayStyle"]}],nzTooltipColor:[{type:t.Input}],visibleChange:[{type:t.Output,args:["nzTooltipVisibleChange"]}]};var C=function(e){function t(t,n,o){var i=e.call(this,t,n,o)||this;return i.noAnimation=o,i.nzTitle=null,i._contentStyleMap={},i}return g(t,e),t.prototype.isEmpty=function(){return b(this.nzTitle)},t.prototype.updateStyles=function(){var e,t=this.nzColor&&o.isPresetColor(this.nzColor);this._classMap=((e={})[this.nzOverlayClassName]=!0,e[this._prefix+"-placement-"+this.preferredPlacement]=!0,e[this._prefix+"-"+this.nzColor]=t,e),this._contentStyleMap={backgroundColor:this.nzColor&&!t?this.nzColor:null}},t}(m);C.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 [cdkConnectedOverlayPositions]="_positions"\n [cdkConnectedOverlayPush]="true"\n (overlayOutsideClick)="onClickOutside($event)"\n (detach)="hide()"\n (positionChange)="onPositionChange($event)"\n >\n <div\n class="ant-tooltip"\n [class.ant-tooltip-rtl]="dir === \'rtl\'"\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">\n <span class="ant-tooltip-arrow-content" [ngStyle]="_contentStyleMap"></span>\n </div>\n <div class="ant-tooltip-inner" [ngStyle]="_contentStyleMap">\n <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>\n </div>\n </div>\n </div>\n </ng-template>\n ',preserveWhitespaces:!1}]}],C.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:r.Directionality,decorators:[{type:t.Optional}]},{type:i.NzNoAnimationDirective,decorators:[{type:t.Host},{type:t.Optional}]}]};var T=function(){};T.decorators=[{type:t.NgModule,args:[{declarations:[C,z],exports:[C,z],entryComponents:[C],imports:[r.BidiModule,u.CommonModule,c.OverlayModule,y.NzOutletModule,s.NzOverlayModule,i.NzNoAnimationModule]}]}],e.NzToolTipComponent=C,e.NzToolTipModule=T,e.NzTooltipBaseComponent=m,e.NzTooltipBaseDirective=f,e.NzTooltipDirective=z,e.isTooltipEmpty=b,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-tooltip.umd.min.js.map