react-tooltip 5.26.1 → 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 +39 -22
- 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 +39 -22
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +39 -22
- 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,6 +552,11 @@ 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);
|
|
@@ -620,13 +649,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
620
649
|
middlewares,
|
|
621
650
|
border,
|
|
622
651
|
}).then((computedStylesData) => {
|
|
623
|
-
|
|
624
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
625
|
-
}
|
|
626
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
627
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
628
|
-
}
|
|
629
|
-
setActualPlacement(computedStylesData.place);
|
|
652
|
+
handleComputedPosition(computedStylesData);
|
|
630
653
|
});
|
|
631
654
|
};
|
|
632
655
|
const handlePointerMove = (event) => {
|
|
@@ -719,13 +742,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
719
742
|
// invalidate computed positions after remount
|
|
720
743
|
return;
|
|
721
744
|
}
|
|
722
|
-
|
|
723
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
724
|
-
}
|
|
725
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
726
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
727
|
-
}
|
|
728
|
-
setActualPlacement(computedStylesData.place);
|
|
745
|
+
handleComputedPosition(computedStylesData);
|
|
729
746
|
});
|
|
730
747
|
}, [
|
|
731
748
|
show,
|
|
@@ -1068,7 +1085,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1068
1085
|
}
|
|
1069
1086
|
}, [delayShow]);
|
|
1070
1087
|
const actualContent = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.content) !== null && _a !== void 0 ? _a : content;
|
|
1071
|
-
const canShow = show && Object.keys(
|
|
1088
|
+
const canShow = show && Object.keys(computedPosition.tooltipStyles).length > 0;
|
|
1072
1089
|
React.useImperativeHandle(forwardRef, () => ({
|
|
1073
1090
|
open: (options) => {
|
|
1074
1091
|
if (options === null || options === void 0 ? void 0 : options.anchorSelect) {
|
|
@@ -1100,10 +1117,10 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1100
1117
|
}
|
|
1101
1118
|
},
|
|
1102
1119
|
activeAnchor,
|
|
1103
|
-
place:
|
|
1120
|
+
place: computedPosition.place,
|
|
1104
1121
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1105
1122
|
}));
|
|
1106
|
-
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) => {
|
|
1107
1124
|
if (missedTransitionTimerRef.current) {
|
|
1108
1125
|
clearTimeout(missedTransitionTimerRef.current);
|
|
1109
1126
|
}
|
|
@@ -1115,12 +1132,12 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
|
|
|
1115
1132
|
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
1116
1133
|
}, style: {
|
|
1117
1134
|
...externalStyles,
|
|
1118
|
-
...
|
|
1135
|
+
...computedPosition.tooltipStyles,
|
|
1119
1136
|
opacity: opacity !== undefined && canShow ? opacity : undefined,
|
|
1120
1137
|
}, ref: tooltipRef },
|
|
1121
1138
|
actualContent,
|
|
1122
1139
|
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
|
|
1123
|
-
...
|
|
1140
|
+
...computedPosition.tooltipArrowStyles,
|
|
1124
1141
|
background: arrowColor
|
|
1125
1142
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
1126
1143
|
: undefined,
|