Skip to content

Commit 6da857e

Browse files
committed
3.2.4
1 parent 0e43567 commit 6da857e

File tree

5 files changed

+57
-23
lines changed

5 files changed

+57
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## Change Log
22

3-
### 3.2.3 (2017/01/30 02:59 +00:00)
3+
### 3.2.4 (2017/02/07 03:53 +00:00)
4+
- [#251](https://github.com/wwayne/react-tooltip/pull/251) Dropfen dynamic wrapper (@dropfen)
5+
6+
### 3.2.3 (2017/01/30 03:00 +00:00)
47
- [#247](https://github.com/wwayne/react-tooltip/pull/247) Fix delayHide issue #246 (@huumanoid)
58
- [#238](https://github.com/wwayne/react-tooltip/pull/238) Update README.md (@nikbelikov)
69
- [#233](https://github.com/wwayne/react-tooltip/pull/233) Added more syntax highlighting (@oyeanuj)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class | data-class | String | | extra custom class, can use !important to
6969
disable | data-tip-disable | Bool | true, false | Disable the tooltip behaviour, default is false
7070
scrollHide | data-scroll-hide | Bool | true, false | Hide the tooltip when scrolling, default is true
7171
resizeHide | null | Bool | true, false | Hide the tooltip when resizing the window, default is true
72+
wrapper | null | String | div, span | Selecting the wrapper element of the react tooltip, default is div
7273

7374
## Using react component as tooltip
7475
Check the example [React-tooltip Test](http://wwayne.com/react-tooltip)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tooltip",
3-
"version": "3.2.3",
3+
"version": "3.2.4",
44
"description": "react tooltip component",
55
"main": "dist/index.js",
66
"scripts": {

standalone/react-tooltip.js

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,28 @@ Object.defineProperty(exports, "__esModule", {
160160
value: true
161161
});
162162

163+
exports.default = function (target) {
164+
target.prototype.getEffect = function (currentTarget) {
165+
var dataEffect = currentTarget.getAttribute('data-effect');
166+
return dataEffect || this.props.effect || 'float';
167+
};
168+
};
169+
170+
},{}],5:[function(require,module,exports){
171+
'use strict';
172+
173+
Object.defineProperty(exports, "__esModule", {
174+
value: true
175+
});
176+
163177
exports.default = function (target) {
164178
target.prototype.isCapture = function (currentTarget) {
165179
var dataIsCapture = currentTarget.getAttribute('data-iscapture');
166180
return dataIsCapture && dataIsCapture === 'true' || this.props.isCapture || false;
167181
};
168182
};
169183

170-
},{}],5:[function(require,module,exports){
184+
},{}],6:[function(require,module,exports){
171185
'use strict';
172186

173187
Object.defineProperty(exports, "__esModule", {
@@ -247,7 +261,7 @@ var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
247261
* Static methods for react-tooltip
248262
*/
249263

250-
},{"../constant":2}],6:[function(require,module,exports){
264+
},{"../constant":2}],7:[function(require,module,exports){
251265
'use strict';
252266

253267
Object.defineProperty(exports, "__esModule", {
@@ -297,7 +311,7 @@ var _constant2 = _interopRequireDefault(_constant);
297311

298312
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
299313

300-
},{"../constant":2}],7:[function(require,module,exports){
314+
},{"../constant":2}],8:[function(require,module,exports){
301315
(function (global){
302316
'use strict';
303317

@@ -344,6 +358,10 @@ var _isCapture = require('./decorators/isCapture');
344358

345359
var _isCapture2 = _interopRequireDefault(_isCapture);
346360

361+
var _getEffect = require('./decorators/getEffect');
362+
363+
var _getEffect2 = _interopRequireDefault(_getEffect);
364+
347365
var _getPosition = require('./utils/getPosition');
348366

349367
var _getPosition2 = _interopRequireDefault(_getPosition);
@@ -366,7 +384,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
366384

367385
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
368386

369-
var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.default)(_class = (0, _customEvent2.default)(_class = (0, _isCapture2.default)(_class = (_temp = _class2 = function (_Component) {
387+
var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.default)(_class = (0, _customEvent2.default)(_class = (0, _isCapture2.default)(_class = (0, _getEffect2.default)(_class = (_temp = _class2 = function (_Component) {
370388
_inherits(ReactTooltip, _Component);
371389

372390
function ReactTooltip(props) {
@@ -474,9 +492,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
474492

475493
// targetArray is a NodeList, convert it to a real array
476494
// I hope I can use Object.values...
477-
return Object.keys(targetArray).filter(function (key) {
478-
return key !== 'length';
479-
}).map(function (key) {
495+
return Object.getOwnPropertyNames(targetArray).map(function (key) {
480496
return targetArray[key];
481497
});
482498
}
@@ -499,6 +515,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
499515

500516
targetArray.forEach(function (target) {
501517
var isCaptureMode = _this3.isCapture(target);
518+
var effect = _this3.getEffect(target);
502519
if (target.getAttribute('currentItem') === null) {
503520
target.setAttribute('currentItem', 'false');
504521
}
@@ -510,7 +527,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
510527
}
511528

512529
target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode);
513-
if (_this3.state.effect === 'float') {
530+
if (effect === 'float') {
514531
target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode);
515532
}
516533
target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode);
@@ -610,12 +627,15 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
610627
scrollHide = this.props.scrollHide;
611628
}
612629

630+
// To prevent previously created timers from triggering
631+
this.clearTimer();
632+
613633
this.setState({
614634
placeholder: placeholder,
615635
isEmptyTip: isEmptyTip,
616636
place: e.currentTarget.getAttribute('data-place') || this.props.place || 'top',
617637
type: e.currentTarget.getAttribute('data-type') || this.props.type || 'dark',
618-
effect: switchToSolid && 'solid' || e.currentTarget.getAttribute('data-effect') || this.props.effect || 'float',
638+
effect: switchToSolid && 'solid' || this.getEffect(e.currentTarget),
619639
offset: e.currentTarget.getAttribute('data-offset') || this.props.offset || {},
620640
html: e.currentTarget.getAttribute('data-html') ? e.currentTarget.getAttribute('data-html') === 'true' : this.props.html || false,
621641
delayShow: e.currentTarget.getAttribute('data-delay-show') || this.props.delayShow || 0,
@@ -816,14 +836,18 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
816836
var isEmptyTip = _state4.isEmptyTip;
817837

818838
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' });
839+
840+
var wrapper = ReactTooltip.supportedWrappers[this.props.wrapper];
841+
if (!wrapper) wrapper = ReactTooltip.supportedWrappers['div'];
842+
819843
if (html) {
820-
return _react2.default.createElement('div', _extends({ className: tooltipClass + ' ' + extraClass
844+
return _react2.default.createElement('wrapper', _extends({ className: tooltipClass + ' ' + extraClass
821845
}, ariaProps, {
822846
'data-id': 'tooltip',
823847
dangerouslySetInnerHTML: { __html: placeholder } }));
824848
} else {
825849
return _react2.default.createElement(
826-
'div',
850+
'wrapper',
827851
_extends({ className: tooltipClass + ' ' + extraClass
828852
}, ariaProps, {
829853
'data-id': 'tooltip' }),
@@ -858,27 +882,32 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
858882
afterHide: _react.PropTypes.func,
859883
disable: _react.PropTypes.bool,
860884
scrollHide: _react.PropTypes.bool,
861-
resizeHide: _react.PropTypes.bool
885+
resizeHide: _react.PropTypes.bool,
886+
wrapper: _react.PropTypes.string
862887
}, _class2.defaultProps = {
863888
insecure: true,
864-
resizeHide: true
865-
}, _temp)) || _class) || _class) || _class) || _class;
889+
resizeHide: true,
890+
wrapper: 'div'
891+
}, _class2.supportedWrappers = {
892+
'div': _react2.default.DOM.div,
893+
'span': _react2.default.DOM.span
894+
}, _temp)) || _class) || _class) || _class) || _class) || _class;
866895

867896
/* export default not fit for standalone, it will exports {default:...} */
868897

869898

870899
module.exports = ReactTooltip;
871900

872901
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
873-
},{"./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){
902+
},{"./decorators/customEvent":3,"./decorators/getEffect":4,"./decorators/isCapture":5,"./decorators/staticMethods":6,"./decorators/windowListener":7,"./style":9,"./utils/aria":10,"./utils/getPosition":11,"./utils/getTipContent":12,"classnames":1}],9:[function(require,module,exports){
874903
'use strict';
875904

876905
Object.defineProperty(exports, "__esModule", {
877906
value: true
878907
});
879908
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}';
880909

881-
},{}],9:[function(require,module,exports){
910+
},{}],10:[function(require,module,exports){
882911
"use strict";
883912

884913
Object.defineProperty(exports, "__esModule", {
@@ -904,7 +933,7 @@ function parseAria(props) {
904933
return ariaObj;
905934
}
906935

907-
},{}],10:[function(require,module,exports){
936+
},{}],11:[function(require,module,exports){
908937
'use strict';
909938

910939
Object.defineProperty(exports, "__esModule", {
@@ -1219,7 +1248,7 @@ var getParent = function getParent(currentTarget) {
12191248
return { parentTop: parentTop, parentLeft: parentLeft };
12201249
};
12211250

1222-
},{}],11:[function(require,module,exports){
1251+
},{}],12:[function(require,module,exports){
12231252
(function (global){
12241253
'use strict';
12251254

@@ -1255,5 +1284,5 @@ var _react2 = _interopRequireDefault(_react);
12551284
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12561285

12571286
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1258-
},{}]},{},[7])(7)
1287+
},{}]},{},[8])(8)
12591288
});

standalone/react-tooltip.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)