react-tooltip 5.26.1-beta.1170.0 → 5.26.2
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 +54 -23
- 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 +54 -23
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +54 -23
- 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
|
@@ -353,6 +353,28 @@ const cssTimeToMs = (time) => {
|
|
|
353
353
|
return Number(amount) * (unit === 'ms' ? 1 : 1000);
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
+
const isObject = (object) => {
|
|
357
|
+
return object !== null && typeof object === 'object';
|
|
358
|
+
};
|
|
359
|
+
const deepEqual = (object1, object2) => {
|
|
360
|
+
if (!isObject(object1) || !isObject(object2)) {
|
|
361
|
+
return object1 === object2;
|
|
362
|
+
}
|
|
363
|
+
const keys1 = Object.keys(object1);
|
|
364
|
+
const keys2 = Object.keys(object2);
|
|
365
|
+
if (keys1.length !== keys2.length) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
return keys1.every((key) => {
|
|
369
|
+
const val1 = object1[key];
|
|
370
|
+
const val2 = object2[key];
|
|
371
|
+
if (isObject(val1) && isObject(val2)) {
|
|
372
|
+
return deepEqual(val1, val2);
|
|
373
|
+
}
|
|
374
|
+
return val1 === val2;
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
|
|
356
378
|
var coreStyles = {"tooltip":"core-styles-module_tooltip__3vRRp","fixed":"core-styles-module_fixed__pcSol","arrow":"core-styles-module_arrow__cvMwQ","noArrow":"core-styles-module_noArrow__xock6","clickable":"core-styles-module_clickable__ZuTTB","show":"core-styles-module_show__Nt9eE","closing":"core-styles-module_closing__sGnxF"};
|
|
357
379
|
|
|
358
380
|
var styles = {"tooltip":"styles-module_tooltip__mnnfp","arrow":"styles-module_arrow__K0L3T","dark":"styles-module_dark__xNqje","light":"styles-module_light__Z6W-X","success":"styles-module_success__A2AKt","warning":"styles-module_warning__SCK0X","error":"styles-module_error__JvumD","info":"styles-module_info__BWdHW"};
|
|
@@ -368,9 +390,11 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
368
390
|
const tooltipShowDelayTimerRef = React.useRef(null);
|
|
369
391
|
const tooltipHideDelayTimerRef = React.useRef(null);
|
|
370
392
|
const missedTransitionTimerRef = React.useRef(null);
|
|
371
|
-
const [
|
|
372
|
-
|
|
373
|
-
|
|
393
|
+
const [computedPosition, setComputedPosition] = React.useState({
|
|
394
|
+
tooltipStyles: {},
|
|
395
|
+
tooltipArrowStyles: {},
|
|
396
|
+
place,
|
|
397
|
+
});
|
|
374
398
|
const [show, setShow] = React.useState(false);
|
|
375
399
|
const [rendered, setRendered] = React.useState(false);
|
|
376
400
|
const [imperativeOptions, setImperativeOptions] = React.useState(null);
|
|
@@ -528,10 +552,20 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
528
552
|
}, transitionShowDelay + 25);
|
|
529
553
|
}
|
|
530
554
|
}, [show]);
|
|
555
|
+
const handleComputedPosition = (newComputedPosition) => {
|
|
556
|
+
setComputedPosition((oldComputedPosition) => deepEqual(oldComputedPosition, newComputedPosition)
|
|
557
|
+
? oldComputedPosition
|
|
558
|
+
: newComputedPosition);
|
|
559
|
+
};
|
|
531
560
|
const handleShowTooltipDelayed = (delay = delayShow) => {
|
|
532
561
|
if (tooltipShowDelayTimerRef.current) {
|
|
533
562
|
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
534
563
|
}
|
|
564
|
+
if (rendered) {
|
|
565
|
+
// if the tooltip is already rendered, ignore delay
|
|
566
|
+
handleShow(true);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
535
569
|
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
536
570
|
handleShow(true);
|
|
537
571
|
}, delay);
|
|
@@ -615,13 +649,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
615
649
|
middlewares,
|
|
616
650
|
border,
|
|
617
651
|
}).then((computedStylesData) => {
|
|
618
|
-
|
|
619
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
620
|
-
}
|
|
621
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
622
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
623
|
-
}
|
|
624
|
-
setActualPlacement(computedStylesData.place);
|
|
652
|
+
handleComputedPosition(computedStylesData);
|
|
625
653
|
});
|
|
626
654
|
};
|
|
627
655
|
const handlePointerMove = (event) => {
|
|
@@ -714,13 +742,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
714
742
|
// invalidate computed positions after remount
|
|
715
743
|
return;
|
|
716
744
|
}
|
|
717
|
-
|
|
718
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
719
|
-
}
|
|
720
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
721
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
722
|
-
}
|
|
723
|
-
setActualPlacement(computedStylesData.place);
|
|
745
|
+
handleComputedPosition(computedStylesData);
|
|
724
746
|
});
|
|
725
747
|
}, [
|
|
726
748
|
show,
|
|
@@ -896,6 +918,8 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
896
918
|
closeEvents,
|
|
897
919
|
globalCloseEvents,
|
|
898
920
|
shouldOpenOnClick,
|
|
921
|
+
delayShow,
|
|
922
|
+
delayHide,
|
|
899
923
|
]);
|
|
900
924
|
React.useEffect(() => {
|
|
901
925
|
var _a, _b;
|
|
@@ -1054,8 +1078,14 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1054
1078
|
setAnchorsBySelect([]);
|
|
1055
1079
|
}
|
|
1056
1080
|
}, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
|
|
1081
|
+
React.useEffect(() => {
|
|
1082
|
+
if (tooltipShowDelayTimerRef.current) {
|
|
1083
|
+
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
1084
|
+
handleShowTooltipDelayed(delayShow);
|
|
1085
|
+
}
|
|
1086
|
+
}, [delayShow]);
|
|
1057
1087
|
const actualContent = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.content) !== null && _a !== void 0 ? _a : content;
|
|
1058
|
-
const canShow = show && Object.keys(
|
|
1088
|
+
const canShow = show && Object.keys(computedPosition.tooltipStyles).length > 0;
|
|
1059
1089
|
React.useImperativeHandle(forwardRef, () => ({
|
|
1060
1090
|
open: (options) => {
|
|
1061
1091
|
if (options === null || options === void 0 ? void 0 : options.anchorSelect) {
|
|
@@ -1087,10 +1117,10 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1087
1117
|
}
|
|
1088
1118
|
},
|
|
1089
1119
|
activeAnchor,
|
|
1090
|
-
place:
|
|
1120
|
+
place: computedPosition.place,
|
|
1091
1121
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1092
1122
|
}));
|
|
1093
|
-
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-${
|
|
1123
|
+
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) => {
|
|
1094
1124
|
if (missedTransitionTimerRef.current) {
|
|
1095
1125
|
clearTimeout(missedTransitionTimerRef.current);
|
|
1096
1126
|
}
|
|
@@ -1102,12 +1132,12 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1102
1132
|
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
1103
1133
|
}, style: {
|
|
1104
1134
|
...externalStyles,
|
|
1105
|
-
...
|
|
1135
|
+
...computedPosition.tooltipStyles,
|
|
1106
1136
|
opacity: opacity !== undefined && canShow ? opacity : undefined,
|
|
1107
1137
|
}, ref: tooltipRef },
|
|
1108
1138
|
actualContent,
|
|
1109
1139
|
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
|
|
1110
|
-
...
|
|
1140
|
+
...computedPosition.tooltipArrowStyles,
|
|
1111
1141
|
background: arrowColor
|
|
1112
1142
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
1113
1143
|
: undefined,
|
|
@@ -1342,7 +1372,8 @@ const TooltipController = React__default["default"].forwardRef(({ id, anchorId,
|
|
|
1342
1372
|
let renderedContent = children;
|
|
1343
1373
|
const contentWrapperRef = React.useRef(null);
|
|
1344
1374
|
if (render) {
|
|
1345
|
-
const
|
|
1375
|
+
const actualContent = (activeAnchor === null || activeAnchor === void 0 ? void 0 : activeAnchor.getAttribute('data-tooltip-content')) || tooltipContent || null;
|
|
1376
|
+
const rendered = render({ content: actualContent, activeAnchor });
|
|
1346
1377
|
renderedContent = rendered ? (React__default["default"].createElement("div", { ref: contentWrapperRef, className: "react-tooltip-content-wrapper" }, rendered)) : null;
|
|
1347
1378
|
}
|
|
1348
1379
|
else if (tooltipContent) {
|