react-tooltip 5.27.0 → 5.27.1
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/dist/react-tooltip.cjs +25 -39
- package/dist/react-tooltip.cjs.map +1 -1
- package/dist/react-tooltip.min.cjs +2 -2
- package/dist/react-tooltip.min.cjs.map +1 -1
- package/dist/react-tooltip.min.mjs +2 -2
- package/dist/react-tooltip.min.mjs.map +1 -1
- package/dist/react-tooltip.mjs +25 -39
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +25 -39
- package/dist/react-tooltip.umd.js.map +1 -1
- package/dist/react-tooltip.umd.min.js +2 -2
- package/dist/react-tooltip.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -49,11 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
const { insertAt } = ref;
|
|
51
51
|
if (document.getElementById(id)) {
|
|
52
|
-
// this
|
|
53
|
-
{
|
|
54
|
-
// eslint-disable-next-line no-console
|
|
55
|
-
console.warn(`[react-tooltip] Element with id '${id}' already exists. Call \`removeStyle()\` first`);
|
|
56
|
-
}
|
|
52
|
+
// this could happen in cases the tooltip is imported by multiple js modules
|
|
57
53
|
return;
|
|
58
54
|
}
|
|
59
55
|
const head = document.head || document.getElementsByTagName('head')[0];
|
|
@@ -289,6 +285,14 @@
|
|
|
289
285
|
|
|
290
286
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
291
287
|
|
|
288
|
+
const clearTimeoutRef = (ref) => {
|
|
289
|
+
if (ref.current) {
|
|
290
|
+
clearTimeout(ref.current);
|
|
291
|
+
// eslint-disable-next-line no-param-reassign
|
|
292
|
+
ref.current = null;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
292
296
|
const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
|
|
293
297
|
const DEFAULT_CONTEXT_DATA = {
|
|
294
298
|
anchorRefs: new Set(),
|
|
@@ -543,9 +547,7 @@
|
|
|
543
547
|
if (show === wasShowing.current) {
|
|
544
548
|
return;
|
|
545
549
|
}
|
|
546
|
-
|
|
547
|
-
clearTimeout(missedTransitionTimerRef.current);
|
|
548
|
-
}
|
|
550
|
+
clearTimeoutRef(missedTransitionTimerRef);
|
|
549
551
|
wasShowing.current = show;
|
|
550
552
|
if (show) {
|
|
551
553
|
afterShow === null || afterShow === void 0 ? void 0 : afterShow();
|
|
@@ -574,9 +576,7 @@
|
|
|
574
576
|
: newComputedPosition);
|
|
575
577
|
};
|
|
576
578
|
const handleShowTooltipDelayed = (delay = delayShow) => {
|
|
577
|
-
|
|
578
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
579
|
-
}
|
|
579
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
580
580
|
if (rendered) {
|
|
581
581
|
// if the tooltip is already rendered, ignore delay
|
|
582
582
|
handleShow(true);
|
|
@@ -587,9 +587,7 @@
|
|
|
587
587
|
}, delay);
|
|
588
588
|
};
|
|
589
589
|
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
590
|
-
|
|
591
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
592
|
-
}
|
|
590
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
593
591
|
tooltipHideDelayTimerRef.current = setTimeout(() => {
|
|
594
592
|
if (hoveringTooltip.current) {
|
|
595
593
|
return;
|
|
@@ -620,9 +618,7 @@
|
|
|
620
618
|
}
|
|
621
619
|
setActiveAnchor(target);
|
|
622
620
|
setProviderActiveAnchor({ current: target });
|
|
623
|
-
|
|
624
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
625
|
-
}
|
|
621
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
626
622
|
};
|
|
627
623
|
const handleHideTooltip = () => {
|
|
628
624
|
if (clickable) {
|
|
@@ -635,9 +631,7 @@
|
|
|
635
631
|
else {
|
|
636
632
|
handleShow(false);
|
|
637
633
|
}
|
|
638
|
-
|
|
639
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
640
|
-
}
|
|
634
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
641
635
|
};
|
|
642
636
|
const handleTooltipPosition = ({ x, y }) => {
|
|
643
637
|
var _a;
|
|
@@ -698,9 +692,7 @@
|
|
|
698
692
|
return;
|
|
699
693
|
}
|
|
700
694
|
handleShow(false);
|
|
701
|
-
|
|
702
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
703
|
-
}
|
|
695
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
704
696
|
};
|
|
705
697
|
// debounce handler to prevent call twice when
|
|
706
698
|
// mouse enter and focus events being triggered toggether
|
|
@@ -984,12 +976,8 @@
|
|
|
984
976
|
setRendered(false);
|
|
985
977
|
handleShow(false);
|
|
986
978
|
setActiveAnchor(null);
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
991
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
992
|
-
}
|
|
979
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
980
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
993
981
|
return true;
|
|
994
982
|
}
|
|
995
983
|
return false;
|
|
@@ -1068,12 +1056,8 @@
|
|
|
1068
1056
|
handleShow(true);
|
|
1069
1057
|
}
|
|
1070
1058
|
return () => {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
1075
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
1076
|
-
}
|
|
1059
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1060
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
1077
1061
|
};
|
|
1078
1062
|
}, []);
|
|
1079
1063
|
React.useEffect(() => {
|
|
@@ -1096,7 +1080,11 @@
|
|
|
1096
1080
|
}, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
|
|
1097
1081
|
React.useEffect(() => {
|
|
1098
1082
|
if (tooltipShowDelayTimerRef.current) {
|
|
1099
|
-
|
|
1083
|
+
/**
|
|
1084
|
+
* if the delay changes while the tooltip is waiting to show,
|
|
1085
|
+
* reset the timer with the new delay
|
|
1086
|
+
*/
|
|
1087
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1100
1088
|
handleShowTooltipDelayed(delayShow);
|
|
1101
1089
|
}
|
|
1102
1090
|
}, [delayShow]);
|
|
@@ -1137,9 +1125,7 @@
|
|
|
1137
1125
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1138
1126
|
}));
|
|
1139
1127
|
return rendered && !hidden && actualContent ? (React__default["default"].createElement(WrapperElement, { id: id, role: role, className: classNames__default["default"]('react-tooltip', coreStyles['tooltip'], styles['tooltip'], styles[variant], className, `react-tooltip__place-${computedPosition.place}`, coreStyles[canShow ? 'show' : 'closing'], canShow ? 'react-tooltip__show' : 'react-tooltip__closing', positionStrategy === 'fixed' && coreStyles['fixed'], clickable && coreStyles['clickable']), onTransitionEnd: (event) => {
|
|
1140
|
-
|
|
1141
|
-
clearTimeout(missedTransitionTimerRef.current);
|
|
1142
|
-
}
|
|
1128
|
+
clearTimeoutRef(missedTransitionTimerRef);
|
|
1143
1129
|
if (show || event.propertyName !== 'opacity') {
|
|
1144
1130
|
return;
|
|
1145
1131
|
}
|