react-tooltip 4.2.6 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +2 -4
- package/dist/index.es.js +144 -137
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +144 -137
- package/dist/index.js.map +1 -1
- package/dist/react-tooltip.d.ts +2 -2
- package/package.json +32 -25
package/dist/index.js
CHANGED
|
@@ -162,9 +162,9 @@ function _possibleConstructorReturn(self, call) {
|
|
|
162
162
|
|
|
163
163
|
var CONSTANT = {
|
|
164
164
|
GLOBAL: {
|
|
165
|
-
HIDE:
|
|
166
|
-
REBUILD:
|
|
167
|
-
SHOW:
|
|
165
|
+
HIDE: '__react_tooltip_hide_event',
|
|
166
|
+
REBUILD: '__react_tooltip_rebuild_event',
|
|
167
|
+
SHOW: '__react_tooltip_show_event'
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
|
|
@@ -178,12 +178,12 @@ var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
|
|
|
178
178
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
|
|
179
179
|
var event;
|
|
180
180
|
|
|
181
|
-
if (typeof window.CustomEvent ===
|
|
181
|
+
if (typeof window.CustomEvent === 'function') {
|
|
182
182
|
event = new window.CustomEvent(eventName, {
|
|
183
183
|
detail: opts
|
|
184
184
|
});
|
|
185
185
|
} else {
|
|
186
|
-
event = document.createEvent(
|
|
186
|
+
event = document.createEvent('Event');
|
|
187
187
|
event.initEvent(eventName, false, true, opts);
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -265,8 +265,8 @@ function windowListener (target) {
|
|
|
265
265
|
window.addEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow, false); // Resize
|
|
266
266
|
|
|
267
267
|
if (resizeHide) {
|
|
268
|
-
window.removeEventListener(
|
|
269
|
-
window.addEventListener(
|
|
268
|
+
window.removeEventListener('resize', this.onWindowResize);
|
|
269
|
+
window.addEventListener('resize', this.onWindowResize, false);
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
|
|
@@ -274,7 +274,7 @@ function windowListener (target) {
|
|
|
274
274
|
window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
|
|
275
275
|
window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
|
|
276
276
|
window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
|
|
277
|
-
window.removeEventListener(
|
|
277
|
+
window.removeEventListener('resize', this.onWindowResize);
|
|
278
278
|
};
|
|
279
279
|
/**
|
|
280
280
|
* invoked by resize event of window
|
|
@@ -298,13 +298,13 @@ var checkStatus = function checkStatus(dataEventOff, e) {
|
|
|
298
298
|
var show = this.state.show;
|
|
299
299
|
var id = this.props.id;
|
|
300
300
|
var isCapture = this.isCapture(e.currentTarget);
|
|
301
|
-
var currentItem = e.currentTarget.getAttribute(
|
|
301
|
+
var currentItem = e.currentTarget.getAttribute('currentItem');
|
|
302
302
|
if (!isCapture) e.stopPropagation();
|
|
303
303
|
|
|
304
|
-
if (show && currentItem ===
|
|
304
|
+
if (show && currentItem === 'true') {
|
|
305
305
|
if (!dataEventOff) this.hideTooltip(e);
|
|
306
306
|
} else {
|
|
307
|
-
e.currentTarget.setAttribute(
|
|
307
|
+
e.currentTarget.setAttribute('currentItem', 'true');
|
|
308
308
|
setUntargetItems(e.currentTarget, this.getTargetArray(id));
|
|
309
309
|
this.showTooltip(e);
|
|
310
310
|
}
|
|
@@ -313,15 +313,15 @@ var checkStatus = function checkStatus(dataEventOff, e) {
|
|
|
313
313
|
var setUntargetItems = function setUntargetItems(currentTarget, targetArray) {
|
|
314
314
|
for (var i = 0; i < targetArray.length; i++) {
|
|
315
315
|
if (currentTarget !== targetArray[i]) {
|
|
316
|
-
targetArray[i].setAttribute(
|
|
316
|
+
targetArray[i].setAttribute('currentItem', 'false');
|
|
317
317
|
} else {
|
|
318
|
-
targetArray[i].setAttribute(
|
|
318
|
+
targetArray[i].setAttribute('currentItem', 'true');
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
var customListeners = {
|
|
324
|
-
id:
|
|
324
|
+
id: '9b69f92e-d3fe-498b-b1b4-c5e63a51b0cf',
|
|
325
325
|
set: function set(target, event, listener) {
|
|
326
326
|
if (this.id in target) {
|
|
327
327
|
var map = target[this.id];
|
|
@@ -345,7 +345,7 @@ var customListeners = {
|
|
|
345
345
|
function customEvent (target) {
|
|
346
346
|
target.prototype.isCustomEvent = function (ele) {
|
|
347
347
|
var event = this.state.event;
|
|
348
|
-
return event || !!ele.getAttribute(
|
|
348
|
+
return event || !!ele.getAttribute('data-event');
|
|
349
349
|
};
|
|
350
350
|
/* Bind listener for custom event */
|
|
351
351
|
|
|
@@ -356,9 +356,9 @@ function customEvent (target) {
|
|
|
356
356
|
var _this$state = this.state,
|
|
357
357
|
event = _this$state.event,
|
|
358
358
|
eventOff = _this$state.eventOff;
|
|
359
|
-
var dataEvent = ele.getAttribute(
|
|
360
|
-
var dataEventOff = ele.getAttribute(
|
|
361
|
-
dataEvent.split(
|
|
359
|
+
var dataEvent = ele.getAttribute('data-event') || event;
|
|
360
|
+
var dataEventOff = ele.getAttribute('data-event-off') || eventOff;
|
|
361
|
+
dataEvent.split(' ').forEach(function (event) {
|
|
362
362
|
ele.removeEventListener(event, customListeners.get(ele, event));
|
|
363
363
|
var customListener = checkStatus.bind(_this, dataEventOff);
|
|
364
364
|
customListeners.set(ele, event, customListener);
|
|
@@ -366,7 +366,7 @@ function customEvent (target) {
|
|
|
366
366
|
});
|
|
367
367
|
|
|
368
368
|
if (dataEventOff) {
|
|
369
|
-
dataEventOff.split(
|
|
369
|
+
dataEventOff.split(' ').forEach(function (event) {
|
|
370
370
|
ele.removeEventListener(event, _this.hideTooltip);
|
|
371
371
|
ele.addEventListener(event, _this.hideTooltip, false);
|
|
372
372
|
});
|
|
@@ -379,8 +379,8 @@ function customEvent (target) {
|
|
|
379
379
|
var _this$state2 = this.state,
|
|
380
380
|
event = _this$state2.event,
|
|
381
381
|
eventOff = _this$state2.eventOff;
|
|
382
|
-
var dataEvent = event || ele.getAttribute(
|
|
383
|
-
var dataEventOff = eventOff || ele.getAttribute(
|
|
382
|
+
var dataEvent = event || ele.getAttribute('data-event');
|
|
383
|
+
var dataEventOff = eventOff || ele.getAttribute('data-event-off');
|
|
384
384
|
ele.removeEventListener(dataEvent, customListeners.get(ele, event));
|
|
385
385
|
if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip);
|
|
386
386
|
};
|
|
@@ -391,7 +391,7 @@ function customEvent (target) {
|
|
|
391
391
|
*/
|
|
392
392
|
function isCapture (target) {
|
|
393
393
|
target.prototype.isCapture = function (currentTarget) {
|
|
394
|
-
return currentTarget && currentTarget.getAttribute(
|
|
394
|
+
return currentTarget && currentTarget.getAttribute('data-iscapture') === 'true' || this.props.isCapture || false;
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -400,8 +400,8 @@ function isCapture (target) {
|
|
|
400
400
|
*/
|
|
401
401
|
function getEffect (target) {
|
|
402
402
|
target.prototype.getEffect = function (currentTarget) {
|
|
403
|
-
var dataEffect = currentTarget.getAttribute(
|
|
404
|
-
return dataEffect || this.props.effect ||
|
|
403
|
+
var dataEffect = currentTarget.getAttribute('data-effect');
|
|
404
|
+
return dataEffect || this.props.effect || 'float';
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
|
|
@@ -413,7 +413,7 @@ var makeProxy = function makeProxy(e) {
|
|
|
413
413
|
var proxy = {};
|
|
414
414
|
|
|
415
415
|
for (var key in e) {
|
|
416
|
-
if (typeof e[key] ===
|
|
416
|
+
if (typeof e[key] === 'function') {
|
|
417
417
|
proxy[key] = e[key].bind(e);
|
|
418
418
|
} else {
|
|
419
419
|
proxy[key] = e[key];
|
|
@@ -429,8 +429,8 @@ var bodyListener = function bodyListener(callback, options, e) {
|
|
|
429
429
|
_options$customEvent = options.customEvent,
|
|
430
430
|
customEvent = _options$customEvent === void 0 ? false : _options$customEvent;
|
|
431
431
|
var id = this.props.id;
|
|
432
|
-
var tip = e.target.getAttribute(
|
|
433
|
-
var forId = e.target.getAttribute(
|
|
432
|
+
var tip = e.target.getAttribute('data-tip') || null;
|
|
433
|
+
var forId = e.target.getAttribute('data-for') || null;
|
|
434
434
|
var target = e.target;
|
|
435
435
|
|
|
436
436
|
if (this.isCustomEvent(target) && !customEvent) {
|
|
@@ -439,7 +439,7 @@ var bodyListener = function bodyListener(callback, options, e) {
|
|
|
439
439
|
|
|
440
440
|
var isTargetBelongsToTooltip = id == null && forId == null || forId === id;
|
|
441
441
|
|
|
442
|
-
if (tip != null && (!respectEffect || this.getEffect(target) ===
|
|
442
|
+
if (tip != null && (!respectEffect || this.getEffect(target) === 'float') && isTargetBelongsToTooltip) {
|
|
443
443
|
var proxy = makeProxy(e);
|
|
444
444
|
proxy.currentTarget = target;
|
|
445
445
|
callback(proxy);
|
|
@@ -450,7 +450,7 @@ var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
|
|
|
450
450
|
var events = {};
|
|
451
451
|
targetArray.forEach(function (target) {
|
|
452
452
|
var event = target.getAttribute(dataAttribute);
|
|
453
|
-
if (event) event.split(
|
|
453
|
+
if (event) event.split(' ').forEach(function (event) {
|
|
454
454
|
return events[event] = true;
|
|
455
455
|
});
|
|
456
456
|
});
|
|
@@ -458,7 +458,7 @@ var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
|
|
|
458
458
|
};
|
|
459
459
|
|
|
460
460
|
var getBody = function getBody() {
|
|
461
|
-
return document.getElementsByTagName(
|
|
461
|
+
return document.getElementsByTagName('body')[0];
|
|
462
462
|
};
|
|
463
463
|
|
|
464
464
|
function bodyMode (target) {
|
|
@@ -475,14 +475,14 @@ function bodyMode (target) {
|
|
|
475
475
|
possibleCustomEvents = _this$state.possibleCustomEvents,
|
|
476
476
|
possibleCustomEventsOff = _this$state.possibleCustomEventsOff;
|
|
477
477
|
var body = getBody();
|
|
478
|
-
var customEvents = findCustomEvents(targetArray,
|
|
479
|
-
var customEventsOff = findCustomEvents(targetArray,
|
|
478
|
+
var customEvents = findCustomEvents(targetArray, 'data-event');
|
|
479
|
+
var customEventsOff = findCustomEvents(targetArray, 'data-event-off');
|
|
480
480
|
if (event != null) customEvents[event] = true;
|
|
481
481
|
if (eventOff != null) customEventsOff[eventOff] = true;
|
|
482
|
-
possibleCustomEvents.split(
|
|
482
|
+
possibleCustomEvents.split(' ').forEach(function (event) {
|
|
483
483
|
return customEvents[event] = true;
|
|
484
484
|
});
|
|
485
|
-
possibleCustomEventsOff.split(
|
|
485
|
+
possibleCustomEventsOff.split(' ').forEach(function (event) {
|
|
486
486
|
return customEventsOff[event] = true;
|
|
487
487
|
});
|
|
488
488
|
this.unbindBodyListener(body);
|
|
@@ -498,7 +498,7 @@ function bodyMode (target) {
|
|
|
498
498
|
|
|
499
499
|
for (var _event in customEvents) {
|
|
500
500
|
listeners[_event] = bodyListener.bind(this, function (e) {
|
|
501
|
-
var targetEventOff = e.currentTarget.getAttribute(
|
|
501
|
+
var targetEventOff = e.currentTarget.getAttribute('data-event-off') || eventOff;
|
|
502
502
|
checkStatus.call(_this, targetEventOff, e);
|
|
503
503
|
}, {
|
|
504
504
|
customEvent: true
|
|
@@ -677,7 +677,7 @@ function getPosition (e, target, node, place, desiredPlace, effect, offset) {
|
|
|
677
677
|
return !outside(p);
|
|
678
678
|
};
|
|
679
679
|
|
|
680
|
-
var placesList = [
|
|
680
|
+
var placesList = ['top', 'bottom', 'left', 'right'];
|
|
681
681
|
var insideList = [];
|
|
682
682
|
|
|
683
683
|
for (var i = 0; i < 4; i++) {
|
|
@@ -739,7 +739,7 @@ var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
|
|
|
739
739
|
targetWidth = _getDimensions3.width,
|
|
740
740
|
targetHeight = _getDimensions3.height;
|
|
741
741
|
|
|
742
|
-
if (effect ===
|
|
742
|
+
if (effect === 'float') {
|
|
743
743
|
return {
|
|
744
744
|
mouseX: e.clientX,
|
|
745
745
|
mouseY: e.clientY
|
|
@@ -763,7 +763,7 @@ var getDefaultPosition = function getDefaultPosition(effect, targetWidth, target
|
|
|
763
763
|
var triangleHeight = 2;
|
|
764
764
|
var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
|
|
765
765
|
|
|
766
|
-
if (effect ===
|
|
766
|
+
if (effect === 'float') {
|
|
767
767
|
top = {
|
|
768
768
|
l: -(tipWidth / 2),
|
|
769
769
|
r: tipWidth / 2,
|
|
@@ -788,7 +788,7 @@ var getDefaultPosition = function getDefaultPosition(effect, targetWidth, target
|
|
|
788
788
|
t: -(tipHeight / 2),
|
|
789
789
|
b: tipHeight / 2
|
|
790
790
|
};
|
|
791
|
-
} else if (effect ===
|
|
791
|
+
} else if (effect === 'solid') {
|
|
792
792
|
top = {
|
|
793
793
|
l: -(tipWidth / 2),
|
|
794
794
|
r: tipWidth / 2,
|
|
@@ -828,18 +828,18 @@ var calculateOffset = function calculateOffset(offset) {
|
|
|
828
828
|
var extraOffsetX = 0;
|
|
829
829
|
var extraOffsetY = 0;
|
|
830
830
|
|
|
831
|
-
if (Object.prototype.toString.apply(offset) ===
|
|
831
|
+
if (Object.prototype.toString.apply(offset) === '[object String]') {
|
|
832
832
|
offset = JSON.parse(offset.toString().replace(/'/g, '"'));
|
|
833
833
|
}
|
|
834
834
|
|
|
835
835
|
for (var key in offset) {
|
|
836
|
-
if (key ===
|
|
836
|
+
if (key === 'top') {
|
|
837
837
|
extraOffsetY -= parseInt(offset[key], 10);
|
|
838
|
-
} else if (key ===
|
|
838
|
+
} else if (key === 'bottom') {
|
|
839
839
|
extraOffsetY += parseInt(offset[key], 10);
|
|
840
|
-
} else if (key ===
|
|
840
|
+
} else if (key === 'left') {
|
|
841
841
|
extraOffsetX -= parseInt(offset[key], 10);
|
|
842
|
-
} else if (key ===
|
|
842
|
+
} else if (key === 'right') {
|
|
843
843
|
extraOffsetX += parseInt(offset[key], 10);
|
|
844
844
|
}
|
|
845
845
|
}
|
|
@@ -855,7 +855,10 @@ var getParent = function getParent(currentTarget) {
|
|
|
855
855
|
var currentParent = currentTarget;
|
|
856
856
|
|
|
857
857
|
while (currentParent) {
|
|
858
|
-
|
|
858
|
+
var computedStyle = window.getComputedStyle(currentParent); // transform and will-change: transform change the containing block
|
|
859
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_Block
|
|
860
|
+
|
|
861
|
+
if (computedStyle.getPropertyValue('transform') !== 'none' || computedStyle.getPropertyValue('will-change') === 'transform') break;
|
|
859
862
|
currentParent = currentParent.parentElement;
|
|
860
863
|
}
|
|
861
864
|
|
|
@@ -888,7 +891,7 @@ function getTipContent (tip, children, getContent, multiline) {
|
|
|
888
891
|
|
|
889
892
|
var regexp = /<br\s*\/?>/;
|
|
890
893
|
|
|
891
|
-
if (!multiline || multiline ===
|
|
894
|
+
if (!multiline || multiline === 'false' || !regexp.test(tip)) {
|
|
892
895
|
// No trim(), so that user can keep their input
|
|
893
896
|
return tip;
|
|
894
897
|
} // Multiline tooltip content
|
|
@@ -937,7 +940,7 @@ function nodeListToArray (nodeList) {
|
|
|
937
940
|
}
|
|
938
941
|
|
|
939
942
|
function generateUUID() {
|
|
940
|
-
return
|
|
943
|
+
return 't' + uuid.v4();
|
|
941
944
|
}
|
|
942
945
|
|
|
943
946
|
___$insertStyle(".__react_component_tooltip {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n left: -999em;\n opacity: 0;\n padding: 8px 21px;\n position: fixed;\n pointer-events: none;\n transition: opacity 0.3s ease-out;\n top: -999em;\n visibility: hidden;\n z-index: 999;\n}\n.__react_component_tooltip.allow_hover, .__react_component_tooltip.allow_click {\n pointer-events: auto;\n}\n.__react_component_tooltip::before, .__react_component_tooltip::after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n}\n.__react_component_tooltip.show {\n opacity: 0.9;\n margin-top: 0;\n margin-left: 0;\n visibility: visible;\n}\n.__react_component_tooltip.place-top::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n bottom: -8px;\n left: 50%;\n margin-left: -10px;\n}\n.__react_component_tooltip.place-bottom::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n top: -8px;\n left: 50%;\n margin-left: -10px;\n}\n.__react_component_tooltip.place-left::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n right: -8px;\n top: 50%;\n margin-top: -5px;\n}\n.__react_component_tooltip.place-right::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n left: -8px;\n top: 50%;\n margin-top: -5px;\n}\n.__react_component_tooltip .multi-line {\n display: block;\n padding: 2px 0;\n text-align: center;\n}");
|
|
@@ -946,41 +949,41 @@ ___$insertStyle(".__react_component_tooltip {\n border-radius: 3px;\n display:
|
|
|
946
949
|
* Default pop-up style values (text color, background color).
|
|
947
950
|
*/
|
|
948
951
|
var defaultColors = {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
952
|
+
dark: {
|
|
953
|
+
text: '#fff',
|
|
954
|
+
background: '#222',
|
|
955
|
+
border: 'transparent',
|
|
956
|
+
arrow: '#222'
|
|
954
957
|
},
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
958
|
+
success: {
|
|
959
|
+
text: '#fff',
|
|
960
|
+
background: '#8DC572',
|
|
961
|
+
border: 'transparent',
|
|
962
|
+
arrow: '#8DC572'
|
|
960
963
|
},
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
964
|
+
warning: {
|
|
965
|
+
text: '#fff',
|
|
966
|
+
background: '#F0AD4E',
|
|
967
|
+
border: 'transparent',
|
|
968
|
+
arrow: '#F0AD4E'
|
|
966
969
|
},
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
970
|
+
error: {
|
|
971
|
+
text: '#fff',
|
|
972
|
+
background: '#BE6464',
|
|
973
|
+
border: 'transparent',
|
|
974
|
+
arrow: '#BE6464'
|
|
972
975
|
},
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
976
|
+
info: {
|
|
977
|
+
text: '#fff',
|
|
978
|
+
background: '#337AB7',
|
|
979
|
+
border: 'transparent',
|
|
980
|
+
arrow: '#337AB7'
|
|
978
981
|
},
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
982
|
+
light: {
|
|
983
|
+
text: '#222',
|
|
984
|
+
background: '#fff',
|
|
985
|
+
border: 'transparent',
|
|
986
|
+
arrow: '#fff'
|
|
984
987
|
}
|
|
985
988
|
};
|
|
986
989
|
function getDefaultPopupColors(type) {
|
|
@@ -988,8 +991,8 @@ function getDefaultPopupColors(type) {
|
|
|
988
991
|
}
|
|
989
992
|
|
|
990
993
|
/**
|
|
991
|
-
* Generates the specific tooltip style for use on render.
|
|
992
|
-
*/
|
|
994
|
+
* Generates the specific tooltip style for use on render.
|
|
995
|
+
*/
|
|
993
996
|
|
|
994
997
|
function generateTooltipStyle(uuid, customColors, type, hasBorder) {
|
|
995
998
|
return generateStyle(uuid, getPopupColors(customColors, type, hasBorder));
|
|
@@ -1025,7 +1028,7 @@ function getPopupColors(customColors, type, hasBorder) {
|
|
|
1025
1028
|
if (borderColor) {
|
|
1026
1029
|
colors.border = borderColor;
|
|
1027
1030
|
} else {
|
|
1028
|
-
colors.border = type ===
|
|
1031
|
+
colors.border = type === 'light' ? 'black' : 'white';
|
|
1029
1032
|
}
|
|
1030
1033
|
}
|
|
1031
1034
|
|
|
@@ -1095,18 +1098,18 @@ function (_React$Component) {
|
|
|
1095
1098
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactTooltip).call(this, props));
|
|
1096
1099
|
_this.state = {
|
|
1097
1100
|
uuid: props.uuid || generateUUID(),
|
|
1098
|
-
place: props.place ||
|
|
1101
|
+
place: props.place || 'top',
|
|
1099
1102
|
// Direction of tooltip
|
|
1100
|
-
desiredPlace: props.place ||
|
|
1101
|
-
type:
|
|
1103
|
+
desiredPlace: props.place || 'top',
|
|
1104
|
+
type: 'dark',
|
|
1102
1105
|
// Color theme of tooltip
|
|
1103
|
-
effect:
|
|
1106
|
+
effect: 'float',
|
|
1104
1107
|
// float or fixed
|
|
1105
1108
|
show: false,
|
|
1106
1109
|
border: false,
|
|
1107
1110
|
customColors: {},
|
|
1108
1111
|
offset: {},
|
|
1109
|
-
extraClass:
|
|
1112
|
+
extraClass: '',
|
|
1110
1113
|
html: false,
|
|
1111
1114
|
delayHide: 0,
|
|
1112
1115
|
delayShow: 0,
|
|
@@ -1120,13 +1123,13 @@ function (_React$Component) {
|
|
|
1120
1123
|
// aria- and role attributes
|
|
1121
1124
|
isEmptyTip: false,
|
|
1122
1125
|
disable: false,
|
|
1123
|
-
possibleCustomEvents: props.possibleCustomEvents ||
|
|
1124
|
-
possibleCustomEventsOff: props.possibleCustomEventsOff ||
|
|
1126
|
+
possibleCustomEvents: props.possibleCustomEvents || '',
|
|
1127
|
+
possibleCustomEventsOff: props.possibleCustomEventsOff || '',
|
|
1125
1128
|
originTooltip: null,
|
|
1126
1129
|
isMultiline: false
|
|
1127
1130
|
};
|
|
1128
1131
|
|
|
1129
|
-
_this.bind([
|
|
1132
|
+
_this.bind(['showTooltip', 'updateTooltip', 'hideTooltip', 'hideTooltipOnScroll', 'getTooltipContent', 'globalRebuild', 'globalShow', 'globalHide', 'onWindowResize', 'mouseOnToolTip']);
|
|
1130
1133
|
|
|
1131
1134
|
_this.mount = true;
|
|
1132
1135
|
_this.delayShowLoop = null;
|
|
@@ -1190,7 +1193,7 @@ function (_React$Component) {
|
|
|
1190
1193
|
}
|
|
1191
1194
|
}
|
|
1192
1195
|
|
|
1193
|
-
return this.tooltipRef.matches(
|
|
1196
|
+
return this.tooltipRef.matches(':hover');
|
|
1194
1197
|
}
|
|
1195
1198
|
|
|
1196
1199
|
return false;
|
|
@@ -1206,14 +1209,14 @@ function (_React$Component) {
|
|
|
1206
1209
|
var selector;
|
|
1207
1210
|
|
|
1208
1211
|
if (!id) {
|
|
1209
|
-
selector =
|
|
1212
|
+
selector = '[data-tip]:not([data-for])';
|
|
1210
1213
|
} else {
|
|
1211
|
-
var escaped = id.replace(/\\/g,
|
|
1214
|
+
var escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
1212
1215
|
selector = "[data-tip][data-for=\"".concat(escaped, "\"]");
|
|
1213
1216
|
} // Scan document for shadow DOM elements
|
|
1214
1217
|
|
|
1215
1218
|
|
|
1216
|
-
nodeListToArray(document.getElementsByTagName(
|
|
1219
|
+
nodeListToArray(document.getElementsByTagName('*')).filter(function (element) {
|
|
1217
1220
|
return element.shadowRoot;
|
|
1218
1221
|
}).forEach(function (element) {
|
|
1219
1222
|
targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector)));
|
|
@@ -1236,8 +1239,8 @@ function (_React$Component) {
|
|
|
1236
1239
|
isCapture = _this$props2.isCapture;
|
|
1237
1240
|
var targetArray = this.getTargetArray(id);
|
|
1238
1241
|
targetArray.forEach(function (target) {
|
|
1239
|
-
if (target.getAttribute(
|
|
1240
|
-
target.setAttribute(
|
|
1242
|
+
if (target.getAttribute('currentItem') === null) {
|
|
1243
|
+
target.setAttribute('currentItem', 'false');
|
|
1241
1244
|
}
|
|
1242
1245
|
|
|
1243
1246
|
_this3.unbindBasicListener(target);
|
|
@@ -1261,13 +1264,13 @@ function (_React$Component) {
|
|
|
1261
1264
|
return;
|
|
1262
1265
|
}
|
|
1263
1266
|
|
|
1264
|
-
target.addEventListener(
|
|
1267
|
+
target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode);
|
|
1265
1268
|
|
|
1266
|
-
if (effect ===
|
|
1267
|
-
target.addEventListener(
|
|
1269
|
+
if (effect === 'float') {
|
|
1270
|
+
target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode);
|
|
1268
1271
|
}
|
|
1269
1272
|
|
|
1270
|
-
target.addEventListener(
|
|
1273
|
+
target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode);
|
|
1271
1274
|
});
|
|
1272
1275
|
} // Global event to hide tooltip
|
|
1273
1276
|
|
|
@@ -1317,9 +1320,9 @@ function (_React$Component) {
|
|
|
1317
1320
|
key: "unbindBasicListener",
|
|
1318
1321
|
value: function unbindBasicListener(target) {
|
|
1319
1322
|
var isCaptureMode = this.isCapture(target);
|
|
1320
|
-
target.removeEventListener(
|
|
1321
|
-
target.removeEventListener(
|
|
1322
|
-
target.removeEventListener(
|
|
1323
|
+
target.removeEventListener('mouseenter', this.showTooltip, isCaptureMode);
|
|
1324
|
+
target.removeEventListener('mousemove', this.updateTooltip, isCaptureMode);
|
|
1325
|
+
target.removeEventListener('mouseleave', this.hideTooltip, isCaptureMode);
|
|
1323
1326
|
}
|
|
1324
1327
|
}, {
|
|
1325
1328
|
key: "getTooltipContent",
|
|
@@ -1343,7 +1346,7 @@ function (_React$Component) {
|
|
|
1343
1346
|
}, {
|
|
1344
1347
|
key: "isEmptyTip",
|
|
1345
1348
|
value: function isEmptyTip(placeholder) {
|
|
1346
|
-
return typeof placeholder ===
|
|
1349
|
+
return typeof placeholder === 'string' && placeholder === '' || placeholder === null;
|
|
1347
1350
|
}
|
|
1348
1351
|
/**
|
|
1349
1352
|
* When mouse enter, show the tooltip
|
|
@@ -1352,6 +1355,10 @@ function (_React$Component) {
|
|
|
1352
1355
|
}, {
|
|
1353
1356
|
key: "showTooltip",
|
|
1354
1357
|
value: function showTooltip(e, isGlobalCall) {
|
|
1358
|
+
if (!this.tooltipRef) {
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1355
1362
|
if (isGlobalCall) {
|
|
1356
1363
|
// Don't trigger other elements belongs to other ReactTooltip
|
|
1357
1364
|
var targetArray = this.getTargetArray(this.props.id);
|
|
@@ -1366,23 +1373,23 @@ function (_React$Component) {
|
|
|
1366
1373
|
var _this$props5 = this.props,
|
|
1367
1374
|
multiline = _this$props5.multiline,
|
|
1368
1375
|
getContent = _this$props5.getContent;
|
|
1369
|
-
var originTooltip = e.currentTarget.getAttribute(
|
|
1370
|
-
var isMultiline = e.currentTarget.getAttribute(
|
|
1376
|
+
var originTooltip = e.currentTarget.getAttribute('data-tip');
|
|
1377
|
+
var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false; // If it is focus event or called by ReactTooltip.show, switch to `solid` effect
|
|
1371
1378
|
|
|
1372
1379
|
var switchToSolid = e instanceof window.FocusEvent || isGlobalCall; // if it needs to skip adding hide listener to scroll
|
|
1373
1380
|
|
|
1374
1381
|
var scrollHide = true;
|
|
1375
1382
|
|
|
1376
|
-
if (e.currentTarget.getAttribute(
|
|
1377
|
-
scrollHide = e.currentTarget.getAttribute(
|
|
1383
|
+
if (e.currentTarget.getAttribute('data-scroll-hide')) {
|
|
1384
|
+
scrollHide = e.currentTarget.getAttribute('data-scroll-hide') === 'true';
|
|
1378
1385
|
} else if (this.props.scrollHide != null) {
|
|
1379
1386
|
scrollHide = this.props.scrollHide;
|
|
1380
1387
|
} // Make sure the correct place is set
|
|
1381
1388
|
|
|
1382
1389
|
|
|
1383
|
-
var desiredPlace = e.currentTarget.getAttribute(
|
|
1384
|
-
var effect = switchToSolid &&
|
|
1385
|
-
var offset = e.currentTarget.getAttribute(
|
|
1390
|
+
var desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top';
|
|
1391
|
+
var effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget);
|
|
1392
|
+
var offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {};
|
|
1386
1393
|
var result = getPosition(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
1387
1394
|
|
|
1388
1395
|
if (result.position && this.props.overridePosition) {
|
|
@@ -1393,7 +1400,7 @@ function (_React$Component) {
|
|
|
1393
1400
|
|
|
1394
1401
|
this.clearTimer();
|
|
1395
1402
|
var target = e.currentTarget;
|
|
1396
|
-
var reshowDelay = this.state.show ? target.getAttribute(
|
|
1403
|
+
var reshowDelay = this.state.show ? target.getAttribute('data-delay-update') || this.props.delayUpdate : 0;
|
|
1397
1404
|
var self = this;
|
|
1398
1405
|
|
|
1399
1406
|
var updateState = function updateState() {
|
|
@@ -1402,22 +1409,22 @@ function (_React$Component) {
|
|
|
1402
1409
|
isMultiline: isMultiline,
|
|
1403
1410
|
desiredPlace: desiredPlace,
|
|
1404
1411
|
place: place,
|
|
1405
|
-
type: target.getAttribute(
|
|
1412
|
+
type: target.getAttribute('data-type') || self.props.type || 'dark',
|
|
1406
1413
|
customColors: {
|
|
1407
|
-
text: target.getAttribute(
|
|
1408
|
-
background: target.getAttribute(
|
|
1409
|
-
border: target.getAttribute(
|
|
1410
|
-
arrow: target.getAttribute(
|
|
1414
|
+
text: target.getAttribute('data-text-color') || self.props.textColor || null,
|
|
1415
|
+
background: target.getAttribute('data-background-color') || self.props.backgroundColor || null,
|
|
1416
|
+
border: target.getAttribute('data-border-color') || self.props.borderColor || null,
|
|
1417
|
+
arrow: target.getAttribute('data-arrow-color') || self.props.arrowColor || null
|
|
1411
1418
|
},
|
|
1412
1419
|
effect: effect,
|
|
1413
1420
|
offset: offset,
|
|
1414
|
-
html: (target.getAttribute(
|
|
1415
|
-
delayShow: target.getAttribute(
|
|
1416
|
-
delayHide: target.getAttribute(
|
|
1417
|
-
delayUpdate: target.getAttribute(
|
|
1418
|
-
border: (target.getAttribute(
|
|
1419
|
-
extraClass: target.getAttribute(
|
|
1420
|
-
disable: (target.getAttribute(
|
|
1421
|
+
html: (target.getAttribute('data-html') ? target.getAttribute('data-html') === 'true' : self.props.html) || false,
|
|
1422
|
+
delayShow: target.getAttribute('data-delay-show') || self.props.delayShow || 0,
|
|
1423
|
+
delayHide: target.getAttribute('data-delay-hide') || self.props.delayHide || 0,
|
|
1424
|
+
delayUpdate: target.getAttribute('data-delay-update') || self.props.delayUpdate || 0,
|
|
1425
|
+
border: (target.getAttribute('data-border') ? target.getAttribute('data-border') === 'true' : self.props.border) || false,
|
|
1426
|
+
extraClass: target.getAttribute('data-class') || self.props["class"] || self.props.className || '',
|
|
1427
|
+
disable: (target.getAttribute('data-tip-disable') ? target.getAttribute('data-tip-disable') === 'true' : self.props.disable) || false,
|
|
1421
1428
|
currentTarget: target
|
|
1422
1429
|
}, function () {
|
|
1423
1430
|
if (scrollHide) {
|
|
@@ -1430,7 +1437,7 @@ function (_React$Component) {
|
|
|
1430
1437
|
self.intervalUpdateContent = setInterval(function () {
|
|
1431
1438
|
if (self.mount) {
|
|
1432
1439
|
var _getContent = self.props.getContent;
|
|
1433
|
-
var placeholder = getTipContent(originTooltip,
|
|
1440
|
+
var placeholder = getTipContent(originTooltip, '', _getContent[0](), isMultiline);
|
|
1434
1441
|
var isEmptyTip = self.isEmptyTip(placeholder);
|
|
1435
1442
|
self.setState({
|
|
1436
1443
|
isEmptyTip: isEmptyTip
|
|
@@ -1511,7 +1518,7 @@ function (_React$Component) {
|
|
|
1511
1518
|
var show = this.state.show;
|
|
1512
1519
|
|
|
1513
1520
|
if (show && this.tooltipRef) {
|
|
1514
|
-
this.tooltipRef.addEventListener(
|
|
1521
|
+
this.tooltipRef.addEventListener('mouseleave', this.hideTooltip);
|
|
1515
1522
|
}
|
|
1516
1523
|
}
|
|
1517
1524
|
}, {
|
|
@@ -1520,7 +1527,7 @@ function (_React$Component) {
|
|
|
1520
1527
|
var show = this.state.show;
|
|
1521
1528
|
|
|
1522
1529
|
if (show && this.tooltipRef) {
|
|
1523
|
-
this.tooltipRef.removeEventListener(
|
|
1530
|
+
this.tooltipRef.removeEventListener('mouseleave', this.hideTooltip);
|
|
1524
1531
|
}
|
|
1525
1532
|
}
|
|
1526
1533
|
/**
|
|
@@ -1602,13 +1609,13 @@ function (_React$Component) {
|
|
|
1602
1609
|
key: "addScrollListener",
|
|
1603
1610
|
value: function addScrollListener(currentTarget) {
|
|
1604
1611
|
var isCaptureMode = this.isCapture(currentTarget);
|
|
1605
|
-
window.addEventListener(
|
|
1612
|
+
window.addEventListener('scroll', this.hideTooltipOnScroll, isCaptureMode);
|
|
1606
1613
|
}
|
|
1607
1614
|
}, {
|
|
1608
1615
|
key: "removeScrollListener",
|
|
1609
1616
|
value: function removeScrollListener(currentTarget) {
|
|
1610
1617
|
var isCaptureMode = this.isCapture(currentTarget);
|
|
1611
|
-
window.removeEventListener(
|
|
1618
|
+
window.removeEventListener('scroll', this.hideTooltipOnScroll, isCaptureMode);
|
|
1612
1619
|
} // Calculation the position
|
|
1613
1620
|
|
|
1614
1621
|
}, {
|
|
@@ -1638,8 +1645,8 @@ function (_React$Component) {
|
|
|
1638
1645
|
} // Set tooltip position
|
|
1639
1646
|
|
|
1640
1647
|
|
|
1641
|
-
node.style.left = result.position.left +
|
|
1642
|
-
node.style.top = result.position.top +
|
|
1648
|
+
node.style.left = result.position.left + 'px';
|
|
1649
|
+
node.style.top = result.position.top + 'px';
|
|
1643
1650
|
}
|
|
1644
1651
|
/**
|
|
1645
1652
|
* CLear all kinds of timeout of interval
|
|
@@ -1659,8 +1666,8 @@ function (_React$Component) {
|
|
|
1659
1666
|
var _this8 = this;
|
|
1660
1667
|
|
|
1661
1668
|
return Boolean(Object.keys(this.state.customColors).find(function (color) {
|
|
1662
|
-
return color !==
|
|
1663
|
-
}) || this.state.border && this.state.customColors[
|
|
1669
|
+
return color !== 'border' && _this8.state.customColors[color];
|
|
1670
|
+
}) || this.state.border && this.state.customColors['border']);
|
|
1664
1671
|
}
|
|
1665
1672
|
}, {
|
|
1666
1673
|
key: "render",
|
|
@@ -1675,16 +1682,16 @@ function (_React$Component) {
|
|
|
1675
1682
|
var content = this.getTooltipContent();
|
|
1676
1683
|
var isEmptyTip = this.isEmptyTip(content);
|
|
1677
1684
|
var style = generateTooltipStyle(this.state.uuid, this.state.customColors, this.state.type, this.state.border);
|
|
1678
|
-
var tooltipClass =
|
|
1679
|
-
" type-".concat(this.hasCustomColors() ?
|
|
1680
|
-
this.props.delayUpdate ?
|
|
1685
|
+
var tooltipClass = '__react_component_tooltip' + " ".concat(this.state.uuid) + (this.state.show && !disable && !isEmptyTip ? ' show' : '') + (this.state.border ? ' border' : '') + " place-".concat(this.state.place) + // top, bottom, left, right
|
|
1686
|
+
" type-".concat(this.hasCustomColors() ? 'custom' : this.state.type) + ( // dark, success, warning, error, info, light, custom
|
|
1687
|
+
this.props.delayUpdate ? ' allow_hover' : '') + (this.props.clickable ? ' allow_click' : '');
|
|
1681
1688
|
var Wrapper = this.props.wrapper;
|
|
1682
1689
|
|
|
1683
1690
|
if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) {
|
|
1684
1691
|
Wrapper = ReactTooltip.defaultProps.wrapper;
|
|
1685
1692
|
}
|
|
1686
1693
|
|
|
1687
|
-
var wrapperClassName = [tooltipClass, extraClass].filter(Boolean).join(
|
|
1694
|
+
var wrapperClassName = [tooltipClass, extraClass].filter(Boolean).join(' ');
|
|
1688
1695
|
|
|
1689
1696
|
if (html) {
|
|
1690
1697
|
var htmlContent = "".concat(content, "\n<style>").concat(style, "</style>");
|
|
@@ -1739,9 +1746,9 @@ function (_React$Component) {
|
|
|
1739
1746
|
}(React.Component), _defineProperty(_class2, "defaultProps", {
|
|
1740
1747
|
insecure: true,
|
|
1741
1748
|
resizeHide: true,
|
|
1742
|
-
wrapper:
|
|
1749
|
+
wrapper: 'div',
|
|
1743
1750
|
clickable: false
|
|
1744
|
-
}), _defineProperty(_class2, "supportedWrappers", [
|
|
1751
|
+
}), _defineProperty(_class2, "supportedWrappers", ['div', 'span']), _defineProperty(_class2, "displayName", 'ReactTooltip'), _temp)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
|
|
1745
1752
|
|
|
1746
1753
|
module.exports = ReactTooltip;
|
|
1747
1754
|
//# sourceMappingURL=index.js.map
|