@@ -1615,7 +1615,6 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
16151615 effect : 'float' , // float or fixed
16161616 show : false ,
16171617 border : false ,
1618- placeholder : '' ,
16191618 offset : { } ,
16201619 extraClass : '' ,
16211620 html : false ,
@@ -1627,10 +1626,12 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
16271626 currentTarget : null , // Current target of mouse event
16281627 ariaProps : ( 0 , _aria . parseAria ) ( props ) , // aria- and role attributes
16291628 isEmptyTip : false ,
1630- disable : false
1629+ disable : false ,
1630+ originTooltip : null ,
1631+ isMultiline : false
16311632 } ;
16321633
1633- _this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'globalRebuild' , 'globalShow' , 'globalHide' , 'onWindowResize' ] ) ;
1634+ _this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'getTooltipContent' , ' globalRebuild', 'globalShow' , 'globalHide' , 'onWindowResize' ] ) ;
16341635
16351636 _this . mount = true ;
16361637 _this . delayShowLoop = null ;
@@ -1793,6 +1794,31 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
17931794 target . removeEventListener ( 'mousemove' , this . updateTooltip , isCaptureMode ) ;
17941795 target . removeEventListener ( 'mouseleave' , this . hideTooltip , isCaptureMode ) ;
17951796 }
1797+ } , {
1798+ key : 'getTooltipContent' ,
1799+ value : function getTooltipContent ( ) {
1800+ var _props4 = this . props ,
1801+ getContent = _props4 . getContent ,
1802+ children = _props4 . children ;
1803+
1804+ // Generate tooltip content
1805+
1806+ var content = void 0 ;
1807+ if ( getContent ) {
1808+ if ( Array . isArray ( getContent ) ) {
1809+ content = getContent [ 0 ] && getContent [ 0 ] ( ) ;
1810+ } else {
1811+ content = getContent ( ) ;
1812+ }
1813+ }
1814+
1815+ return ( 0 , _getTipContent2 . default ) ( this . state . originTooltip , children , content , this . state . isMultiline ) ;
1816+ }
1817+ } , {
1818+ key : 'isEmptyTip' ,
1819+ value : function isEmptyTip ( placeholder ) {
1820+ return typeof placeholder === 'string' && placeholder === '' || placeholder === null ;
1821+ }
17961822
17971823 /**
17981824 * When mouse enter, show the tooltip
@@ -1813,26 +1839,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18131839 }
18141840 // Get the tooltip content
18151841 // calculate in this phrase so that tip width height can be detected
1816- var _props4 = this . props ,
1817- children = _props4 . children ,
1818- multiline = _props4 . multiline ,
1819- getContent = _props4 . getContent ;
1842+ var _props5 = this . props ,
1843+ multiline = _props5 . multiline ,
1844+ getContent = _props5 . getContent ;
18201845
18211846 var originTooltip = e . currentTarget . getAttribute ( 'data-tip' ) ;
18221847 var isMultiline = e . currentTarget . getAttribute ( 'data-multiline' ) || multiline || false ;
18231848
1824- // Generate tootlip content
1825- var content = void 0 ;
1826- if ( getContent ) {
1827- if ( Array . isArray ( getContent ) ) {
1828- content = getContent [ 0 ] && getContent [ 0 ] ( ) ;
1829- } else {
1830- content = getContent ( ) ;
1831- }
1832- }
1833- var placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , children , content , isMultiline ) ;
1834- var isEmptyTip = typeof placeholder === 'string' && placeholder === '' || placeholder === null ;
1835-
18361849 // If it is focus event or called by ReactTooltip.show, switch to `solid` effect
18371850 var switchToSolid = e instanceof window . FocusEvent || isGlobalCall ;
18381851
@@ -1848,8 +1861,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18481861 this . clearTimer ( ) ;
18491862
18501863 this . setState ( {
1851- placeholder : placeholder ,
1852- isEmptyTip : isEmptyTip ,
1864+ originTooltip : originTooltip ,
1865+ isMultiline : isMultiline ,
18531866 desiredPlace : e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ,
18541867 place : e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ,
18551868 type : e . currentTarget . getAttribute ( 'data-type' ) || this . props . type || 'dark' ,
@@ -1870,11 +1883,10 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18701883 if ( _this5 . mount ) {
18711884 var _getContent = _this5 . props . getContent ;
18721885
1873- var _placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , '' , _getContent [ 0 ] ( ) , isMultiline ) ;
1874- var _isEmptyTip = typeof _placeholder === 'string' && _placeholder === '' ;
1886+ var placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , '' , _getContent [ 0 ] ( ) , isMultiline ) ;
1887+ var isEmptyTip = _this5 . isEmptyTip ( placeholder ) ;
18751888 _this5 . setState ( {
1876- placeholder : _placeholder ,
1877- isEmptyTip : _isEmptyTip
1889+ isEmptyTip : isEmptyTip
18781890 } ) ;
18791891 }
18801892 } , getContent [ 1 ] ) ;
@@ -1894,15 +1906,14 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18941906 var _state = this . state ,
18951907 delayShow = _state . delayShow ,
18961908 show = _state . show ,
1897- isEmptyTip = _state . isEmptyTip ,
18981909 disable = _state . disable ;
18991910 var afterShow = this . props . afterShow ;
1900- var placeholder = this . state . placeholder ;
19011911
1912+ var placeholder = this . getTooltipContent ( ) ;
19021913 var delayTime = show ? 0 : parseInt ( delayShow , 10 ) ;
19031914 var eventTarget = e . currentTarget ;
19041915
1905- if ( isEmptyTip || disable ) return ; // if the tooltip is empty, disable the tooltip
1916+ if ( this . isEmptyTip ( placeholder ) || disable ) return ; // if the tooltip is empty, disable the tooltip
19061917 var updateState = function updateState ( ) {
19071918 if ( Array . isArray ( placeholder ) && placeholder . length > 0 || placeholder ) {
19081919 var isInvisible = ! _this6 . state . show ;
@@ -1936,12 +1947,12 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
19361947
19371948 var _state2 = this . state ,
19381949 delayHide = _state2 . delayHide ,
1939- isEmptyTip = _state2 . isEmptyTip ,
19401950 disable = _state2 . disable ;
19411951 var afterHide = this . props . afterHide ;
19421952
1953+ var placeholder = this . getTooltipContent ( ) ;
19431954 if ( ! this . mount ) return ;
1944- if ( isEmptyTip || disable ) return ; // if the tooltip is empty, disable the tooltip
1955+ if ( this . isEmptyTip ( placeholder ) || disable ) return ; // if the tooltip is empty, disable the tooltip
19451956 if ( hasTarget ) {
19461957 // Don't trigger other elements belongs to other ReactTooltip
19471958 var targetArray = this . getTargetArray ( this . props . id ) ;
@@ -2046,13 +2057,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
20462057 key : 'render' ,
20472058 value : function render ( ) {
20482059 var _state4 = this . state ,
2049- placeholder = _state4 . placeholder ,
20502060 extraClass = _state4 . extraClass ,
20512061 html = _state4 . html ,
20522062 ariaProps = _state4 . ariaProps ,
2053- disable = _state4 . disable ,
2054- isEmptyTip = _state4 . isEmptyTip ;
2063+ disable = _state4 . disable ;
20552064
2065+ var placeholder = this . getTooltipContent ( ) ;
2066+ var isEmptyTip = this . isEmptyTip ( placeholder ) ;
20562067 var tooltipClass = ( 0 , _classnames2 . default ) ( '__react_component_tooltip' , { 'show' : this . state . show && ! disable && ! isEmptyTip } , { 'border' : this . state . border } , { 'place-top' : this . state . place === 'top' } , { 'place-bottom' : this . state . place === 'bottom' } , { 'place-left' : this . state . place === 'left' } , { 'place-right' : this . state . place === 'right' } , { 'type-dark' : this . state . type === 'dark' } , { 'type-success' : this . state . type === 'success' } , { 'type-warning' : this . state . type === 'warning' } , { 'type-error' : this . state . type === 'error' } , { 'type-info' : this . state . type === 'info' } , { 'type-light' : this . state . type === 'light' } ) ;
20572068
20582069 var Wrapper = this . props . wrapper ;
0 commit comments