react-tooltip 5.27.0-beta.1203.rc.0 → 5.27.0-beta.1205.rc.0
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 +29 -35
- 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 +29 -35
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +29 -35
- 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
package/dist/react-tooltip.cjs
CHANGED
|
@@ -51,7 +51,11 @@ function injectStyle({ css, id = REACT_TOOLTIP_BASE_STYLES_ID, type = 'base', re
|
|
|
51
51
|
}
|
|
52
52
|
const { insertAt } = ref;
|
|
53
53
|
if (document.getElementById(id)) {
|
|
54
|
-
// this
|
|
54
|
+
// this should never happen because of `injected[type]`
|
|
55
|
+
{
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.warn(`[react-tooltip] Element with id '${id}' already exists. Call \`removeStyle()\` first`);
|
|
58
|
+
}
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
61
|
const head = document.head || document.getElementsByTagName('head')[0];
|
|
@@ -287,6 +291,14 @@ const getScrollParent = (node) => {
|
|
|
287
291
|
|
|
288
292
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
289
293
|
|
|
294
|
+
const clearTimeoutRef = (ref) => {
|
|
295
|
+
if (ref.current) {
|
|
296
|
+
clearTimeout(ref.current);
|
|
297
|
+
// eslint-disable-next-line no-param-reassign
|
|
298
|
+
ref.current = null;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
290
302
|
const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
|
|
291
303
|
const DEFAULT_CONTEXT_DATA = {
|
|
292
304
|
anchorRefs: new Set(),
|
|
@@ -541,9 +553,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
541
553
|
if (show === wasShowing.current) {
|
|
542
554
|
return;
|
|
543
555
|
}
|
|
544
|
-
|
|
545
|
-
clearTimeout(missedTransitionTimerRef.current);
|
|
546
|
-
}
|
|
556
|
+
clearTimeoutRef(missedTransitionTimerRef);
|
|
547
557
|
wasShowing.current = show;
|
|
548
558
|
if (show) {
|
|
549
559
|
afterShow === null || afterShow === void 0 ? void 0 : afterShow();
|
|
@@ -572,9 +582,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
572
582
|
: newComputedPosition);
|
|
573
583
|
};
|
|
574
584
|
const handleShowTooltipDelayed = (delay = delayShow) => {
|
|
575
|
-
|
|
576
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
577
|
-
}
|
|
585
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
578
586
|
if (rendered) {
|
|
579
587
|
// if the tooltip is already rendered, ignore delay
|
|
580
588
|
handleShow(true);
|
|
@@ -585,9 +593,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
585
593
|
}, delay);
|
|
586
594
|
};
|
|
587
595
|
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
588
|
-
|
|
589
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
590
|
-
}
|
|
596
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
591
597
|
tooltipHideDelayTimerRef.current = setTimeout(() => {
|
|
592
598
|
if (hoveringTooltip.current) {
|
|
593
599
|
return;
|
|
@@ -618,9 +624,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
618
624
|
}
|
|
619
625
|
setActiveAnchor(target);
|
|
620
626
|
setProviderActiveAnchor({ current: target });
|
|
621
|
-
|
|
622
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
623
|
-
}
|
|
627
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
624
628
|
};
|
|
625
629
|
const handleHideTooltip = () => {
|
|
626
630
|
if (clickable) {
|
|
@@ -633,9 +637,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
633
637
|
else {
|
|
634
638
|
handleShow(false);
|
|
635
639
|
}
|
|
636
|
-
|
|
637
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
638
|
-
}
|
|
640
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
639
641
|
};
|
|
640
642
|
const handleTooltipPosition = ({ x, y }) => {
|
|
641
643
|
var _a;
|
|
@@ -696,9 +698,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
696
698
|
return;
|
|
697
699
|
}
|
|
698
700
|
handleShow(false);
|
|
699
|
-
|
|
700
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
701
|
-
}
|
|
701
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
702
702
|
};
|
|
703
703
|
// debounce handler to prevent call twice when
|
|
704
704
|
// mouse enter and focus events being triggered toggether
|
|
@@ -982,12 +982,8 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
982
982
|
setRendered(false);
|
|
983
983
|
handleShow(false);
|
|
984
984
|
setActiveAnchor(null);
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
989
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
990
|
-
}
|
|
985
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
986
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
991
987
|
return true;
|
|
992
988
|
}
|
|
993
989
|
return false;
|
|
@@ -1066,12 +1062,8 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1066
1062
|
handleShow(true);
|
|
1067
1063
|
}
|
|
1068
1064
|
return () => {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
1073
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
1074
|
-
}
|
|
1065
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1066
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
1075
1067
|
};
|
|
1076
1068
|
}, []);
|
|
1077
1069
|
React.useEffect(() => {
|
|
@@ -1094,7 +1086,11 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1094
1086
|
}, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
|
|
1095
1087
|
React.useEffect(() => {
|
|
1096
1088
|
if (tooltipShowDelayTimerRef.current) {
|
|
1097
|
-
|
|
1089
|
+
/**
|
|
1090
|
+
* if the delay changes while the tooltip is waiting to show,
|
|
1091
|
+
* reset the timer with the new delay
|
|
1092
|
+
*/
|
|
1093
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1098
1094
|
handleShowTooltipDelayed(delayShow);
|
|
1099
1095
|
}
|
|
1100
1096
|
}, [delayShow]);
|
|
@@ -1135,9 +1131,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1135
1131
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1136
1132
|
}));
|
|
1137
1133
|
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) => {
|
|
1138
|
-
|
|
1139
|
-
clearTimeout(missedTransitionTimerRef.current);
|
|
1140
|
-
}
|
|
1134
|
+
clearTimeoutRef(missedTransitionTimerRef);
|
|
1141
1135
|
if (show || event.propertyName !== 'opacity') {
|
|
1142
1136
|
return;
|
|
1143
1137
|
}
|