@@ -269,6 +269,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
269269( function ( global ) {
270270'use strict' ;
271271
272+ var _extends = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
273+
272274var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
273275
274276var _class , _class2 , _temp ;
@@ -318,6 +320,8 @@ var _getTipContent = require('./utils/getTipContent');
318320
319321var _getTipContent2 = _interopRequireDefault ( _getTipContent ) ;
320322
323+ var _aria = require ( './utils/aria' ) ;
324+
321325var _style = require ( './style' ) ;
322326
323327var _style2 = _interopRequireDefault ( _style ) ;
@@ -353,7 +357,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
353357 event : props . event || null ,
354358 eventOff : props . eventOff || null ,
355359 currentEvent : null , // Current mouse event
356- currentTarget : null // Current target of mouse event
360+ currentTarget : null , // Current target of mouse event
361+ ariaProps : ( 0 , _aria . parseAria ) ( props ) // aria- and role attributes
357362 } ;
358363
359364 _this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'globalRebuild' , 'onWindowResize' ] ) ;
@@ -386,6 +391,20 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
386391 this . bindListener ( ) ; // Bind listener for tooltip
387392 this . bindWindowEvents ( ) ; // Bind global event for static method
388393 }
394+ } , {
395+ key : 'componentWillReceiveProps' ,
396+ value : function componentWillReceiveProps ( props ) {
397+ var ariaProps = this . state . ariaProps ;
398+
399+ var newAriaProps = ( 0 , _aria . parseAria ) ( props ) ;
400+
401+ var isChanged = Object . keys ( newAriaProps ) . some ( function ( props ) {
402+ return newAriaProps [ props ] !== ariaProps [ props ] ;
403+ } ) ;
404+ if ( isChanged ) {
405+ this . setState ( { ariaProps : newAriaProps } ) ;
406+ }
407+ }
389408 } , {
390409 key : 'componentWillUnmount' ,
391410 value : function componentWillUnmount ( ) {
@@ -573,6 +592,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
573592 var _state = this . state ;
574593 var delayShow = _state . delayShow ;
575594 var show = _state . show ;
595+ var afterShow = this . props . afterShow ;
576596 var placeholder = this . state . placeholder ;
577597
578598 var delayTime = show ? 0 : parseInt ( delayShow , 10 ) ;
@@ -581,17 +601,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
581601 var updateState = function updateState ( ) {
582602 if ( typeof placeholder === 'string' ) placeholder = placeholder . trim ( ) ;
583603 if ( Array . isArray ( placeholder ) && placeholder . length > 0 || placeholder ) {
584- _this6 . setState ( {
585- currentEvent : e ,
586- currentTarget : eventTarget ,
587- show : true
588- } , function ( ) {
589- _this6 . updatePosition ( ) ;
590- } ) ;
604+ ( function ( ) {
605+ var isInvisible = ! _this6 . state . show ;
606+ _this6 . setState ( {
607+ currentEvent : e ,
608+ currentTarget : eventTarget ,
609+ show : true
610+ } , function ( ) {
611+ _this6 . updatePosition ( ) ;
612+ if ( isInvisible && afterShow ) afterShow ( ) ;
613+ } ) ;
614+ } ) ( ) ;
591615 }
592616 } ;
593617
594- this . clearTimer ( ) ;
618+ clearTimeout ( this . delayShowLoop ) ;
595619 if ( delayShow ) {
596620 this . delayShowLoop = setTimeout ( updateState , delayTime ) ;
597621 } else {
@@ -609,15 +633,19 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
609633 var _this7 = this ;
610634
611635 var delayHide = this . state . delayHide ;
636+ var afterHide = this . props . afterHide ;
612637
613638
614639 if ( ! this . mount ) return ;
615640
616641 var resetState = function resetState ( ) {
642+ var isVisible = _this7 . state . show ;
617643 _this7 . setState ( {
618644 show : false
645+ } , function ( ) {
646+ _this7 . removeScrollListener ( ) ;
647+ if ( isVisible && afterHide ) afterHide ( ) ;
619648 } ) ;
620- _this7 . removeScrollListener ( ) ;
621649 } ;
622650
623651 this . clearTimer ( ) ;
@@ -709,18 +737,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
709737 var placeholder = _state3 . placeholder ;
710738 var extraClass = _state3 . extraClass ;
711739 var html = _state3 . html ;
740+ var ariaProps = _state3 . ariaProps ;
712741
713742 var tooltipClass = ( 0 , _classnames2 . default ) ( '__react_component_tooltip' , { 'show' : this . state . show } , { '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' } ) ;
714743
715744 if ( html ) {
716- return _react2 . default . createElement ( 'div' , { className : tooltipClass + ' ' + extraClass ,
745+ return _react2 . default . createElement ( 'div' , _extends ( { className : tooltipClass + ' ' + extraClass
746+ } , ariaProps , {
717747 'data-id' : 'tooltip' ,
718- dangerouslySetInnerHTML : { __html : placeholder } } ) ;
748+ dangerouslySetInnerHTML : { __html : placeholder } } ) ) ;
719749 } else {
720750 return _react2 . default . createElement (
721751 'div' ,
722- { className : tooltipClass + ' ' + extraClass ,
723- 'data-id' : 'tooltip' } ,
752+ _extends ( { className : tooltipClass + ' ' + extraClass
753+ } , ariaProps , {
754+ 'data-id' : 'tooltip' } ) ,
724755 placeholder
725756 ) ;
726757 }
@@ -747,7 +778,9 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
747778 isCapture : _react . PropTypes . bool ,
748779 globalEventOff : _react . PropTypes . string ,
749780 getContent : _react . PropTypes . any ,
750- countTransform : _react . PropTypes . bool
781+ countTransform : _react . PropTypes . bool ,
782+ afterShow : _react . PropTypes . func ,
783+ afterHide : _react . PropTypes . func
751784} , _temp ) ) || _class ) || _class ) || _class ) || _class ;
752785
753786/* export default not fit for standalone, it will exports {default:...} */
@@ -756,7 +789,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
756789module . exports = ReactTooltip ;
757790
758791} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
759- } , { "./decorators/customEvent" :3 , "./decorators/isCapture" :4 , "./decorators/staticMethods" :5 , "./decorators/windowListener" :6 , "./style" :8 , "./utils/getPosition " :9 , "./utils/getTipContent " :10 , "classnames" :1 } ] , 8 :[ function ( require , module , exports ) {
792+ } , { "./decorators/customEvent" :3 , "./decorators/isCapture" :4 , "./decorators/staticMethods" :5 , "./decorators/windowListener" :6 , "./style" :8 , "./utils/aria " :9 , "./utils/getPosition " :10 , "./utils/getTipContent" : 11 , "classnames" :1 } ] , 8 :[ function ( require , module , exports ) {
760793'use strict' ;
761794
762795Object . defineProperty ( exports , "__esModule" , {
@@ -765,6 +798,32 @@ Object.defineProperty(exports, "__esModule", {
765798exports . default = '.__react_component_tooltip{border-radius:3px;display:inline-block;font-size:13px;left:-999em;opacity:0;padding:8px 21px;position:fixed;pointer-events:none;transition:opacity 0.3s ease-out;top:-999em;visibility:hidden;z-index:999}.__react_component_tooltip:before,.__react_component_tooltip:after{content:"";width:0;height:0;position:absolute}.__react_component_tooltip.show{opacity:0.9;margin-top:0px;margin-left:0px;visibility:visible}.__react_component_tooltip.type-dark{color:#fff;background-color:#222}.__react_component_tooltip.type-dark.place-top:after{border-top-color:#222;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-dark.place-bottom:after{border-bottom-color:#222;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-dark.place-left:after{border-left-color:#222;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-dark.place-right:after{border-right-color:#222;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-dark.border{border:1px solid #fff}.__react_component_tooltip.type-dark.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-dark.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-dark.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-dark.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-success{color:#fff;background-color:#8DC572}.__react_component_tooltip.type-success.place-top:after{border-top-color:#8DC572;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-success.place-bottom:after{border-bottom-color:#8DC572;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-success.place-left:after{border-left-color:#8DC572;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-success.place-right:after{border-right-color:#8DC572;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-success.border{border:1px solid #fff}.__react_component_tooltip.type-success.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-success.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-success.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-success.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-warning{color:#fff;background-color:#F0AD4E}.__react_component_tooltip.type-warning.place-top:after{border-top-color:#F0AD4E;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-warning.place-bottom:after{border-bottom-color:#F0AD4E;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-warning.place-left:after{border-left-color:#F0AD4E;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-warning.place-right:after{border-right-color:#F0AD4E;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-warning.border{border:1px solid #fff}.__react_component_tooltip.type-warning.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-warning.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-warning.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-warning.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-error{color:#fff;background-color:#BE6464}.__react_component_tooltip.type-error.place-top:after{border-top-color:#BE6464;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-error.place-bottom:after{border-bottom-color:#BE6464;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-error.place-left:after{border-left-color:#BE6464;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-error.place-right:after{border-right-color:#BE6464;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-error.border{border:1px solid #fff}.__react_component_tooltip.type-error.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-error.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-error.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-error.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-info{color:#fff;background-color:#337AB7}.__react_component_tooltip.type-info.place-top:after{border-top-color:#337AB7;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-info.place-bottom:after{border-bottom-color:#337AB7;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-info.place-left:after{border-left-color:#337AB7;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-info.place-right:after{border-right-color:#337AB7;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-info.border{border:1px solid #fff}.__react_component_tooltip.type-info.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-info.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-info.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-info.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-light{color:#222;background-color:#fff}.__react_component_tooltip.type-light.place-top:after{border-top-color:#fff;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-light.place-bottom:after{border-bottom-color:#fff;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-light.place-left:after{border-left-color:#fff;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-light.place-right:after{border-right-color:#fff;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-light.border{border:1px solid #222}.__react_component_tooltip.type-light.border.place-top:before{border-top:8px solid #222}.__react_component_tooltip.type-light.border.place-bottom:before{border-bottom:8px solid #222}.__react_component_tooltip.type-light.border.place-left:before{border-left:8px solid #222}.__react_component_tooltip.type-light.border.place-right:before{border-right:8px solid #222}.__react_component_tooltip.place-top{margin-top:-10px}.__react_component_tooltip.place-top:before{border-left:10px solid transparent;border-right:10px solid transparent;bottom:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-top:after{border-left:8px solid transparent;border-right:8px solid transparent;bottom:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-bottom{margin-top:10px}.__react_component_tooltip.place-bottom:before{border-left:10px solid transparent;border-right:10px solid transparent;top:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-bottom:after{border-left:8px solid transparent;border-right:8px solid transparent;top:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-left{margin-left:-10px}.__react_component_tooltip.place-left:before{border-top:6px solid transparent;border-bottom:6px solid transparent;right:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-left:after{border-top:5px solid transparent;border-bottom:5px solid transparent;right:-6px;top:50%;margin-top:-4px}.__react_component_tooltip.place-right{margin-left:10px}.__react_component_tooltip.place-right:before{border-top:6px solid transparent;border-bottom:6px solid transparent;left:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-right:after{border-top:5px solid transparent;border-bottom:5px solid transparent;left:-6px;top:50%;margin-top:-4px}.__react_component_tooltip .multi-line{display:block;padding:2px 0px;text-align:center}' ;
766799
767800} , { } ] , 9 :[ function ( require , module , exports ) {
801+ "use strict" ;
802+
803+ Object . defineProperty ( exports , "__esModule" , {
804+ value : true
805+ } ) ;
806+ exports . parseAria = parseAria ;
807+ /**
808+ * Support aria- and role in ReactTooltip
809+ *
810+ * @params props {Object}
811+ * @return {Object }
812+ */
813+ function parseAria ( props ) {
814+ var ariaObj = { } ;
815+ Object . keys ( props ) . filter ( function ( prop ) {
816+ // aria-xxx and role is acceptable
817+ return ( / ( ^ a r i a - \w + $ | ^ r o l e $ ) / . test ( prop )
818+ ) ;
819+ } ) . forEach ( function ( prop ) {
820+ ariaObj [ prop ] = props [ prop ] ;
821+ } ) ;
822+
823+ return ariaObj ;
824+ }
825+
826+ } , { } ] , 10 :[ function ( require , module , exports ) {
768827'use strict' ;
769828
770829Object . defineProperty ( exports , "__esModule" , {
@@ -1079,7 +1138,7 @@ var getParent = function getParent(currentTarget) {
10791138 return { parentTop : parentTop , parentLeft : parentLeft } ;
10801139} ;
10811140
1082- } , { } ] , 10 :[ function ( require , module , exports ) {
1141+ } , { } ] , 11 :[ function ( require , module , exports ) {
10831142( function ( global ) {
10841143'use strict' ;
10851144
0 commit comments