@@ -269,6 +269,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
269
269
( function ( global ) {
270
270
'use strict' ;
271
271
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
+
272
274
var _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 ; } ; } ( ) ;
273
275
274
276
var _class , _class2 , _temp ;
@@ -318,6 +320,8 @@ var _getTipContent = require('./utils/getTipContent');
318
320
319
321
var _getTipContent2 = _interopRequireDefault ( _getTipContent ) ;
320
322
323
+ var _aria = require ( './utils/aria' ) ;
324
+
321
325
var _style = require ( './style' ) ;
322
326
323
327
var _style2 = _interopRequireDefault ( _style ) ;
@@ -353,7 +357,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
353
357
event : props . event || null ,
354
358
eventOff : props . eventOff || null ,
355
359
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
357
362
} ;
358
363
359
364
_this . bind ( [ 'showTooltip' , 'updateTooltip' , 'hideTooltip' , 'globalRebuild' , 'onWindowResize' ] ) ;
@@ -386,6 +391,20 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
386
391
this . bindListener ( ) ; // Bind listener for tooltip
387
392
this . bindWindowEvents ( ) ; // Bind global event for static method
388
393
}
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
+ }
389
408
} , {
390
409
key : 'componentWillUnmount' ,
391
410
value : function componentWillUnmount ( ) {
@@ -573,6 +592,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
573
592
var _state = this . state ;
574
593
var delayShow = _state . delayShow ;
575
594
var show = _state . show ;
595
+ var afterShow = this . props . afterShow ;
576
596
var placeholder = this . state . placeholder ;
577
597
578
598
var delayTime = show ? 0 : parseInt ( delayShow , 10 ) ;
@@ -581,17 +601,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
581
601
var updateState = function updateState ( ) {
582
602
if ( typeof placeholder === 'string' ) placeholder = placeholder . trim ( ) ;
583
603
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
+ } ) ( ) ;
591
615
}
592
616
} ;
593
617
594
- this . clearTimer ( ) ;
618
+ clearTimeout ( this . delayShowLoop ) ;
595
619
if ( delayShow ) {
596
620
this . delayShowLoop = setTimeout ( updateState , delayTime ) ;
597
621
} else {
@@ -609,15 +633,19 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
609
633
var _this7 = this ;
610
634
611
635
var delayHide = this . state . delayHide ;
636
+ var afterHide = this . props . afterHide ;
612
637
613
638
614
639
if ( ! this . mount ) return ;
615
640
616
641
var resetState = function resetState ( ) {
642
+ var isVisible = _this7 . state . show ;
617
643
_this7 . setState ( {
618
644
show : false
645
+ } , function ( ) {
646
+ _this7 . removeScrollListener ( ) ;
647
+ if ( isVisible && afterHide ) afterHide ( ) ;
619
648
} ) ;
620
- _this7 . removeScrollListener ( ) ;
621
649
} ;
622
650
623
651
this . clearTimer ( ) ;
@@ -709,18 +737,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
709
737
var placeholder = _state3 . placeholder ;
710
738
var extraClass = _state3 . extraClass ;
711
739
var html = _state3 . html ;
740
+ var ariaProps = _state3 . ariaProps ;
712
741
713
742
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' } ) ;
714
743
715
744
if ( html ) {
716
- return _react2 . default . createElement ( 'div' , { className : tooltipClass + ' ' + extraClass ,
745
+ return _react2 . default . createElement ( 'div' , _extends ( { className : tooltipClass + ' ' + extraClass
746
+ } , ariaProps , {
717
747
'data-id' : 'tooltip' ,
718
- dangerouslySetInnerHTML : { __html : placeholder } } ) ;
748
+ dangerouslySetInnerHTML : { __html : placeholder } } ) ) ;
719
749
} else {
720
750
return _react2 . default . createElement (
721
751
'div' ,
722
- { className : tooltipClass + ' ' + extraClass ,
723
- 'data-id' : 'tooltip' } ,
752
+ _extends ( { className : tooltipClass + ' ' + extraClass
753
+ } , ariaProps , {
754
+ 'data-id' : 'tooltip' } ) ,
724
755
placeholder
725
756
) ;
726
757
}
@@ -747,7 +778,9 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
747
778
isCapture : _react . PropTypes . bool ,
748
779
globalEventOff : _react . PropTypes . string ,
749
780
getContent : _react . PropTypes . any ,
750
- countTransform : _react . PropTypes . bool
781
+ countTransform : _react . PropTypes . bool ,
782
+ afterShow : _react . PropTypes . func ,
783
+ afterHide : _react . PropTypes . func
751
784
} , _temp ) ) || _class ) || _class ) || _class ) || _class ;
752
785
753
786
/* export default not fit for standalone, it will exports {default:...} */
@@ -756,7 +789,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
756
789
module . exports = ReactTooltip ;
757
790
758
791
} ) . 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 ) {
760
793
'use strict' ;
761
794
762
795
Object . defineProperty ( exports , "__esModule" , {
@@ -765,6 +798,32 @@ Object.defineProperty(exports, "__esModule", {
765
798
exports . 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}' ;
766
799
767
800
} , { } ] , 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 ) {
768
827
'use strict' ;
769
828
770
829
Object . defineProperty ( exports , "__esModule" , {
@@ -1079,7 +1138,7 @@ var getParent = function getParent(currentTarget) {
1079
1138
return { parentTop : parentTop , parentLeft : parentLeft } ;
1080
1139
} ;
1081
1140
1082
- } , { } ] , 10 :[ function ( require , module , exports ) {
1141
+ } , { } ] , 11 :[ function ( require , module , exports ) {
1083
1142
( function ( global ) {
1084
1143
'use strict' ;
1085
1144
0 commit comments