react-tooltip 5.28.0 → 5.29.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-tokens.css +1 -0
- package/dist/react-tooltip.cjs +31 -20
- package/dist/react-tooltip.cjs.map +1 -1
- package/dist/react-tooltip.css +4 -2
- 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.css +1 -1
- package/dist/react-tooltip.min.mjs +2 -2
- package/dist/react-tooltip.min.mjs.map +1 -1
- package/dist/react-tooltip.mjs +31 -20
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +31 -20
- 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.mjs
CHANGED
|
@@ -98,7 +98,7 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
|
|
|
98
98
|
fallbackAxisSideDirection: 'start',
|
|
99
99
|
}),
|
|
100
100
|
shift({ padding: 5 }),
|
|
101
|
-
], border, }) => {
|
|
101
|
+
], border, arrowSize = 8, }) => {
|
|
102
102
|
if (!elementReference) {
|
|
103
103
|
// elementReference can be null or undefined and we will not compute the position
|
|
104
104
|
// eslint-disable-next-line no-console
|
|
@@ -152,7 +152,7 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
|
|
|
152
152
|
right: '',
|
|
153
153
|
bottom: '',
|
|
154
154
|
...borderSide,
|
|
155
|
-
[staticSide]: `-${
|
|
155
|
+
[staticSide]: `-${arrowSize / 2 + borderWidth}px`,
|
|
156
156
|
};
|
|
157
157
|
/* c8 ignore end */
|
|
158
158
|
return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
|
|
@@ -392,7 +392,7 @@ const Tooltip = ({
|
|
|
392
392
|
// props
|
|
393
393
|
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,
|
|
394
394
|
// props handled by controller
|
|
395
|
-
content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, role = 'tooltip', }) => {
|
|
395
|
+
content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, arrowSize = 8, role = 'tooltip', }) => {
|
|
396
396
|
var _a;
|
|
397
397
|
const tooltipRef = useRef(null);
|
|
398
398
|
const tooltipArrowRef = useRef(null);
|
|
@@ -466,15 +466,17 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
466
466
|
};
|
|
467
467
|
if (imperativeModeOnly) {
|
|
468
468
|
Object.assign(actualOpenEvents, {
|
|
469
|
-
|
|
469
|
+
mouseover: false,
|
|
470
470
|
focus: false,
|
|
471
|
+
mouseenter: false,
|
|
471
472
|
click: false,
|
|
472
473
|
dblclick: false,
|
|
473
474
|
mousedown: false,
|
|
474
475
|
});
|
|
475
476
|
Object.assign(actualCloseEvents, {
|
|
476
|
-
|
|
477
|
+
mouseout: false,
|
|
477
478
|
blur: false,
|
|
479
|
+
mouseleave: false,
|
|
478
480
|
click: false,
|
|
479
481
|
dblclick: false,
|
|
480
482
|
mouseup: false,
|
|
@@ -651,6 +653,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
651
653
|
strategy: positionStrategy,
|
|
652
654
|
middlewares,
|
|
653
655
|
border,
|
|
656
|
+
arrowSize,
|
|
654
657
|
}).then((computedStylesData) => {
|
|
655
658
|
handleComputedPosition(computedStylesData);
|
|
656
659
|
});
|
|
@@ -738,6 +741,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
738
741
|
strategy: positionStrategy,
|
|
739
742
|
middlewares,
|
|
740
743
|
border,
|
|
744
|
+
arrowSize,
|
|
741
745
|
}).then((computedStylesData) => {
|
|
742
746
|
if (!mounted.current) {
|
|
743
747
|
// invalidate computed positions after remount
|
|
@@ -757,6 +761,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
757
761
|
position,
|
|
758
762
|
imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position,
|
|
759
763
|
float,
|
|
764
|
+
arrowSize,
|
|
760
765
|
]);
|
|
761
766
|
useEffect(() => {
|
|
762
767
|
var _a, _b;
|
|
@@ -805,8 +810,9 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
805
810
|
window.addEventListener('click', handleClickOutsideAnchors);
|
|
806
811
|
}
|
|
807
812
|
const enabledEvents = [];
|
|
813
|
+
const activeAnchorContainsTarget = (event) => Boolean((event === null || event === void 0 ? void 0 : event.target) && (activeAnchor === null || activeAnchor === void 0 ? void 0 : activeAnchor.contains(event.target)));
|
|
808
814
|
const handleClickOpenTooltipAnchor = (event) => {
|
|
809
|
-
if (show && (event
|
|
815
|
+
if (show && activeAnchorContainsTarget(event)) {
|
|
810
816
|
/**
|
|
811
817
|
* ignore clicking the anchor that was used to open the tooltip.
|
|
812
818
|
* this avoids conflict with the click close event.
|
|
@@ -816,7 +822,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
816
822
|
handleShowTooltip(event);
|
|
817
823
|
};
|
|
818
824
|
const handleClickCloseTooltipAnchor = (event) => {
|
|
819
|
-
if (!show || (event
|
|
825
|
+
if (!show || !activeAnchorContainsTarget(event)) {
|
|
820
826
|
/**
|
|
821
827
|
* ignore clicking the anchor that was NOT used to open the tooltip.
|
|
822
828
|
* this avoids closing the tooltip when clicking on a
|
|
@@ -858,18 +864,19 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
858
864
|
listener: handlePointerMove,
|
|
859
865
|
});
|
|
860
866
|
}
|
|
861
|
-
const
|
|
867
|
+
const handleMouseOverTooltip = () => {
|
|
862
868
|
hoveringTooltip.current = true;
|
|
863
869
|
};
|
|
864
|
-
const
|
|
870
|
+
const handleMouseOutTooltip = () => {
|
|
865
871
|
hoveringTooltip.current = false;
|
|
866
872
|
handleHideTooltip();
|
|
867
873
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
//
|
|
871
|
-
|
|
872
|
-
(
|
|
874
|
+
const addHoveringTooltipListeners = clickable && (actualCloseEvents.mouseout || actualCloseEvents.mouseleave);
|
|
875
|
+
if (addHoveringTooltipListeners) {
|
|
876
|
+
// used to keep the tooltip open when hovering from anchor to tooltip.
|
|
877
|
+
// only relevant if either `mouseout`/`mouseleave` is in use
|
|
878
|
+
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover', handleMouseOverTooltip);
|
|
879
|
+
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', handleMouseOutTooltip);
|
|
873
880
|
}
|
|
874
881
|
enabledEvents.forEach(({ event, listener }) => {
|
|
875
882
|
elementRefs.forEach((ref) => {
|
|
@@ -896,9 +903,9 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
896
903
|
if (actualGlobalCloseEvents.escape) {
|
|
897
904
|
window.removeEventListener('keydown', handleEsc);
|
|
898
905
|
}
|
|
899
|
-
if (
|
|
900
|
-
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('
|
|
901
|
-
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('
|
|
906
|
+
if (addHoveringTooltipListeners) {
|
|
907
|
+
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseover', handleMouseOverTooltip);
|
|
908
|
+
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseout', handleMouseOutTooltip);
|
|
902
909
|
}
|
|
903
910
|
enabledEvents.forEach(({ event, listener }) => {
|
|
904
911
|
elementRefs.forEach((ref) => {
|
|
@@ -1139,6 +1146,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1139
1146
|
background: arrowColor
|
|
1140
1147
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
1141
1148
|
: undefined,
|
|
1149
|
+
'--rt-arrow-size': `${arrowSize}px`,
|
|
1142
1150
|
}, ref: tooltipArrowRef }))) : null;
|
|
1143
1151
|
};
|
|
1144
1152
|
|
|
@@ -1147,7 +1155,7 @@ const TooltipContent = ({ content }) => {
|
|
|
1147
1155
|
return React.createElement("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
1148
1156
|
};
|
|
1149
1157
|
|
|
1150
|
-
const TooltipController = React.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) => {
|
|
1158
|
+
const TooltipController = React.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, arrowSize, setIsOpen, afterShow, afterHide, disableTooltip, role = 'tooltip', }, ref) => {
|
|
1151
1159
|
const [tooltipContent, setTooltipContent] = useState(content);
|
|
1152
1160
|
const [tooltipHtml, setTooltipHtml] = useState(html);
|
|
1153
1161
|
const [tooltipPlace, setTooltipPlace] = useState(place);
|
|
@@ -1417,6 +1425,7 @@ const TooltipController = React.forwardRef(({ id, anchorId, anchorSelect, conten
|
|
|
1417
1425
|
border,
|
|
1418
1426
|
opacity,
|
|
1419
1427
|
arrowColor,
|
|
1428
|
+
arrowSize,
|
|
1420
1429
|
setIsOpen,
|
|
1421
1430
|
afterShow,
|
|
1422
1431
|
afterHide,
|
|
@@ -1439,6 +1448,7 @@ const TooltipCoreStyles = `:root {
|
|
|
1439
1448
|
--rt-opacity: 0.9;
|
|
1440
1449
|
--rt-transition-show-delay: 0.15s;
|
|
1441
1450
|
--rt-transition-closing-delay: 0.15s;
|
|
1451
|
+
--rt-arrow-size: 8px;
|
|
1442
1452
|
}
|
|
1443
1453
|
|
|
1444
1454
|
.core-styles-module_tooltip__3vRRp {
|
|
@@ -1457,6 +1467,7 @@ const TooltipCoreStyles = `:root {
|
|
|
1457
1467
|
.core-styles-module_arrow__cvMwQ {
|
|
1458
1468
|
position: absolute;
|
|
1459
1469
|
background: inherit;
|
|
1470
|
+
z-index: -1;
|
|
1460
1471
|
}
|
|
1461
1472
|
|
|
1462
1473
|
.core-styles-module_noArrow__xock6 {
|
|
@@ -1488,8 +1499,8 @@ const TooltipStyles = `
|
|
|
1488
1499
|
}
|
|
1489
1500
|
|
|
1490
1501
|
.styles-module_arrow__K0L3T {
|
|
1491
|
-
width:
|
|
1492
|
-
height:
|
|
1502
|
+
width: var(--rt-arrow-size);
|
|
1503
|
+
height: var(--rt-arrow-size);
|
|
1493
1504
|
}
|
|
1494
1505
|
|
|
1495
1506
|
[class*='react-tooltip__place-top'] > .styles-module_arrow__K0L3T {
|