react-tooltip 5.27.0 → 5.28.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 +32 -42
- package/dist/react-tooltip.cjs.map +1 -1
- package/dist/react-tooltip.d.ts +1 -0
- 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 +32 -42
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +32 -42
- 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(),
|
|
@@ -393,7 +397,7 @@
|
|
|
393
397
|
|
|
394
398
|
const Tooltip = ({
|
|
395
399
|
// props
|
|
396
|
-
forwardRef, id, className, classNameArrow, variant = 'dark', anchorId, anchorSelect, place = 'top', offset = 10, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, wrapper: WrapperElement, delayShow = 0, delayHide = 0, float = false, hidden = false, noArrow = false, clickable = false, closeOnEsc = false, closeOnScroll = false, closeOnResize = false, openEvents, closeEvents, globalCloseEvents, imperativeModeOnly, style: externalStyles, position, afterShow, afterHide,
|
|
400
|
+
forwardRef, id, className, classNameArrow, variant = 'dark', anchorId, anchorSelect, place = 'top', offset = 10, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, wrapper: WrapperElement, delayShow = 0, delayHide = 0, float = false, hidden = false, noArrow = false, clickable = false, closeOnEsc = false, closeOnScroll = false, closeOnResize = false, openEvents, closeEvents, globalCloseEvents, imperativeModeOnly, style: externalStyles, position, afterShow, afterHide, disableTooltip,
|
|
397
401
|
// props handled by controller
|
|
398
402
|
content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, role = 'tooltip', }) => {
|
|
399
403
|
var _a;
|
|
@@ -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
|
|
@@ -777,10 +769,13 @@
|
|
|
777
769
|
var _a, _b;
|
|
778
770
|
const elementRefs = new Set(anchorRefs);
|
|
779
771
|
anchorsBySelect.forEach((anchor) => {
|
|
772
|
+
if (disableTooltip === null || disableTooltip === void 0 ? void 0 : disableTooltip(anchor)) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
780
775
|
elementRefs.add({ current: anchor });
|
|
781
776
|
});
|
|
782
777
|
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
783
|
-
if (anchorById) {
|
|
778
|
+
if (anchorById && !(disableTooltip === null || disableTooltip === void 0 ? void 0 : disableTooltip(anchorById))) {
|
|
784
779
|
elementRefs.add({ current: anchorById });
|
|
785
780
|
}
|
|
786
781
|
const handleScrollResize = () => {
|
|
@@ -984,12 +979,8 @@
|
|
|
984
979
|
setRendered(false);
|
|
985
980
|
handleShow(false);
|
|
986
981
|
setActiveAnchor(null);
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
991
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
992
|
-
}
|
|
982
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
983
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
993
984
|
return true;
|
|
994
985
|
}
|
|
995
986
|
return false;
|
|
@@ -1068,12 +1059,8 @@
|
|
|
1068
1059
|
handleShow(true);
|
|
1069
1060
|
}
|
|
1070
1061
|
return () => {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
1075
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
1076
|
-
}
|
|
1062
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1063
|
+
clearTimeoutRef(tooltipHideDelayTimerRef);
|
|
1077
1064
|
};
|
|
1078
1065
|
}, []);
|
|
1079
1066
|
React.useEffect(() => {
|
|
@@ -1096,7 +1083,11 @@
|
|
|
1096
1083
|
}, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
|
|
1097
1084
|
React.useEffect(() => {
|
|
1098
1085
|
if (tooltipShowDelayTimerRef.current) {
|
|
1099
|
-
|
|
1086
|
+
/**
|
|
1087
|
+
* if the delay changes while the tooltip is waiting to show,
|
|
1088
|
+
* reset the timer with the new delay
|
|
1089
|
+
*/
|
|
1090
|
+
clearTimeoutRef(tooltipShowDelayTimerRef);
|
|
1100
1091
|
handleShowTooltipDelayed(delayShow);
|
|
1101
1092
|
}
|
|
1102
1093
|
}, [delayShow]);
|
|
@@ -1137,9 +1128,7 @@
|
|
|
1137
1128
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1138
1129
|
}));
|
|
1139
1130
|
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
|
-
}
|
|
1131
|
+
clearTimeoutRef(missedTransitionTimerRef);
|
|
1143
1132
|
if (show || event.propertyName !== 'opacity') {
|
|
1144
1133
|
return;
|
|
1145
1134
|
}
|
|
@@ -1165,7 +1154,7 @@
|
|
|
1165
1154
|
return React__default["default"].createElement("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
1166
1155
|
};
|
|
1167
1156
|
|
|
1168
|
-
const TooltipController = React__default["default"].forwardRef(({ id, anchorId, anchorSelect, content, html, render, className, classNameArrow, variant = 'dark', place = 'top', offset = 10, wrapper = 'div', children = null, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, delayShow = 0, delayHide = 0, float = false, hidden = false, noArrow = false, clickable = false, closeOnEsc = false, closeOnScroll = false, closeOnResize = false, openEvents, closeEvents, globalCloseEvents, imperativeModeOnly = false, style, position, isOpen, defaultIsOpen = false, disableStyleInjection = false, border, opacity, arrowColor, setIsOpen, afterShow, afterHide, role = 'tooltip', }, ref) => {
|
|
1157
|
+
const TooltipController = React__default["default"].forwardRef(({ id, anchorId, anchorSelect, content, html, render, className, classNameArrow, variant = 'dark', place = 'top', offset = 10, wrapper = 'div', children = null, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, delayShow = 0, delayHide = 0, float = false, hidden = false, noArrow = false, clickable = false, closeOnEsc = false, closeOnScroll = false, closeOnResize = false, openEvents, closeEvents, globalCloseEvents, imperativeModeOnly = false, style, position, isOpen, defaultIsOpen = false, disableStyleInjection = false, border, opacity, arrowColor, setIsOpen, afterShow, afterHide, disableTooltip, role = 'tooltip', }, ref) => {
|
|
1169
1158
|
const [tooltipContent, setTooltipContent] = React.useState(content);
|
|
1170
1159
|
const [tooltipHtml, setTooltipHtml] = React.useState(html);
|
|
1171
1160
|
const [tooltipPlace, setTooltipPlace] = React.useState(place);
|
|
@@ -1438,6 +1427,7 @@
|
|
|
1438
1427
|
setIsOpen,
|
|
1439
1428
|
afterShow,
|
|
1440
1429
|
afterHide,
|
|
1430
|
+
disableTooltip,
|
|
1441
1431
|
activeAnchor,
|
|
1442
1432
|
setActiveAnchor: (anchor) => setActiveAnchor(anchor),
|
|
1443
1433
|
role,
|