@@ -1615,7 +1615,6 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1615
1615
effect : 'float' , // float or fixed
1616
1616
show : false ,
1617
1617
border : false ,
1618
- placeholder : '' ,
1619
1618
offset : { } ,
1620
1619
extraClass : '' ,
1621
1620
html : false ,
@@ -1627,10 +1626,12 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1627
1626
currentTarget : null , // Current target of mouse event
1628
1627
ariaProps : ( 0 , _aria . parseAria ) ( props ) , // aria- and role attributes
1629
1628
isEmptyTip : false ,
1630
- disable : false
1629
+ disable : false ,
1630
+ originTooltip : null ,
1631
+ isMultiline : false
1631
1632
} ;
1632
1633
1633
- _this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'globalRebuild' , 'globalShow' , 'globalHide' , 'onWindowResize' ] ) ;
1634
+ _this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'getTooltipContent' , ' globalRebuild', 'globalShow' , 'globalHide' , 'onWindowResize' ] ) ;
1634
1635
1635
1636
_this . mount = true ;
1636
1637
_this . delayShowLoop = null ;
@@ -1793,6 +1794,31 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1793
1794
target . removeEventListener ( 'mousemove' , this . updateTooltip , isCaptureMode ) ;
1794
1795
target . removeEventListener ( 'mouseleave' , this . hideTooltip , isCaptureMode ) ;
1795
1796
}
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
+ }
1796
1822
1797
1823
/**
1798
1824
* When mouse enter, show the tooltip
@@ -1813,26 +1839,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1813
1839
}
1814
1840
// Get the tooltip content
1815
1841
// 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 ;
1820
1845
1821
1846
var originTooltip = e . currentTarget . getAttribute ( 'data-tip' ) ;
1822
1847
var isMultiline = e . currentTarget . getAttribute ( 'data-multiline' ) || multiline || false ;
1823
1848
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
-
1836
1849
// If it is focus event or called by ReactTooltip.show, switch to `solid` effect
1837
1850
var switchToSolid = e instanceof window . FocusEvent || isGlobalCall ;
1838
1851
@@ -1848,8 +1861,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1848
1861
this . clearTimer ( ) ;
1849
1862
1850
1863
this . setState ( {
1851
- placeholder : placeholder ,
1852
- isEmptyTip : isEmptyTip ,
1864
+ originTooltip : originTooltip ,
1865
+ isMultiline : isMultiline ,
1853
1866
desiredPlace : e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ,
1854
1867
place : e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ,
1855
1868
type : e . currentTarget . getAttribute ( 'data-type' ) || this . props . type || 'dark' ,
@@ -1870,11 +1883,10 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1870
1883
if ( _this5 . mount ) {
1871
1884
var _getContent = _this5 . props . getContent ;
1872
1885
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 ) ;
1875
1888
_this5 . setState ( {
1876
- placeholder : _placeholder ,
1877
- isEmptyTip : _isEmptyTip
1889
+ isEmptyTip : isEmptyTip
1878
1890
} ) ;
1879
1891
}
1880
1892
} , getContent [ 1 ] ) ;
@@ -1894,15 +1906,14 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1894
1906
var _state = this . state ,
1895
1907
delayShow = _state . delayShow ,
1896
1908
show = _state . show ,
1897
- isEmptyTip = _state . isEmptyTip ,
1898
1909
disable = _state . disable ;
1899
1910
var afterShow = this . props . afterShow ;
1900
- var placeholder = this . state . placeholder ;
1901
1911
1912
+ var placeholder = this . getTooltipContent ( ) ;
1902
1913
var delayTime = show ? 0 : parseInt ( delayShow , 10 ) ;
1903
1914
var eventTarget = e . currentTarget ;
1904
1915
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
1906
1917
var updateState = function updateState ( ) {
1907
1918
if ( Array . isArray ( placeholder ) && placeholder . length > 0 || placeholder ) {
1908
1919
var isInvisible = ! _this6 . state . show ;
@@ -1936,12 +1947,12 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
1936
1947
1937
1948
var _state2 = this . state ,
1938
1949
delayHide = _state2 . delayHide ,
1939
- isEmptyTip = _state2 . isEmptyTip ,
1940
1950
disable = _state2 . disable ;
1941
1951
var afterHide = this . props . afterHide ;
1942
1952
1953
+ var placeholder = this . getTooltipContent ( ) ;
1943
1954
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
1945
1956
if ( hasTarget ) {
1946
1957
// Don't trigger other elements belongs to other ReactTooltip
1947
1958
var targetArray = this . getTargetArray ( this . props . id ) ;
@@ -2046,13 +2057,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
2046
2057
key : 'render' ,
2047
2058
value : function render ( ) {
2048
2059
var _state4 = this . state ,
2049
- placeholder = _state4 . placeholder ,
2050
2060
extraClass = _state4 . extraClass ,
2051
2061
html = _state4 . html ,
2052
2062
ariaProps = _state4 . ariaProps ,
2053
- disable = _state4 . disable ,
2054
- isEmptyTip = _state4 . isEmptyTip ;
2063
+ disable = _state4 . disable ;
2055
2064
2065
+ var placeholder = this . getTooltipContent ( ) ;
2066
+ var isEmptyTip = this . isEmptyTip ( placeholder ) ;
2056
2067
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' } ) ;
2057
2068
2058
2069
var Wrapper = this . props . wrapper ;
0 commit comments