react-tooltip 5.26.1-beta.1169.0 → 5.26.1
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 +40 -41
- 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 +40 -41
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +40 -41
- 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
|
@@ -351,28 +351,6 @@
|
|
|
351
351
|
return Number(amount) * (unit === 'ms' ? 1 : 1000);
|
|
352
352
|
};
|
|
353
353
|
|
|
354
|
-
const isObject = (object) => {
|
|
355
|
-
return object !== null && typeof object === 'object';
|
|
356
|
-
};
|
|
357
|
-
const deepEqual = (object1, object2) => {
|
|
358
|
-
if (!isObject(object1) || !isObject(object2)) {
|
|
359
|
-
return object1 === object2;
|
|
360
|
-
}
|
|
361
|
-
const keys1 = Object.keys(object1);
|
|
362
|
-
const keys2 = Object.keys(object2);
|
|
363
|
-
if (keys1.length !== keys2.length) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
return keys1.every((key) => {
|
|
367
|
-
const val1 = object1[key];
|
|
368
|
-
const val2 = object2[key];
|
|
369
|
-
if (isObject(val1) && isObject(val2)) {
|
|
370
|
-
return deepEqual(val1, val2);
|
|
371
|
-
}
|
|
372
|
-
return val1 === val2;
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
|
|
376
354
|
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"};
|
|
377
355
|
|
|
378
356
|
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"};
|
|
@@ -383,17 +361,14 @@
|
|
|
383
361
|
// props handled by controller
|
|
384
362
|
content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, role = 'tooltip', }) => {
|
|
385
363
|
var _a;
|
|
386
|
-
console.log('render');
|
|
387
364
|
const tooltipRef = React.useRef(null);
|
|
388
365
|
const tooltipArrowRef = React.useRef(null);
|
|
389
366
|
const tooltipShowDelayTimerRef = React.useRef(null);
|
|
390
367
|
const tooltipHideDelayTimerRef = React.useRef(null);
|
|
391
368
|
const missedTransitionTimerRef = React.useRef(null);
|
|
392
|
-
const [
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
place,
|
|
396
|
-
});
|
|
369
|
+
const [actualPlacement, setActualPlacement] = React.useState(place);
|
|
370
|
+
const [inlineStyles, setInlineStyles] = React.useState({});
|
|
371
|
+
const [inlineArrowStyles, setInlineArrowStyles] = React.useState({});
|
|
397
372
|
const [show, setShow] = React.useState(false);
|
|
398
373
|
const [rendered, setRendered] = React.useState(false);
|
|
399
374
|
const [imperativeOptions, setImperativeOptions] = React.useState(null);
|
|
@@ -551,15 +526,15 @@
|
|
|
551
526
|
}, transitionShowDelay + 25);
|
|
552
527
|
}
|
|
553
528
|
}, [show]);
|
|
554
|
-
const handleComputedPosition = (newComputedPosition) => {
|
|
555
|
-
setComputedPosition((oldComputedPosition) => deepEqual(oldComputedPosition, newComputedPosition)
|
|
556
|
-
? oldComputedPosition
|
|
557
|
-
: newComputedPosition);
|
|
558
|
-
};
|
|
559
529
|
const handleShowTooltipDelayed = (delay = delayShow) => {
|
|
560
530
|
if (tooltipShowDelayTimerRef.current) {
|
|
561
531
|
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
562
532
|
}
|
|
533
|
+
if (rendered) {
|
|
534
|
+
// if the tooltip is already rendered, ignore delay
|
|
535
|
+
handleShow(true);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
563
538
|
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
564
539
|
handleShow(true);
|
|
565
540
|
}, delay);
|
|
@@ -643,7 +618,13 @@
|
|
|
643
618
|
middlewares,
|
|
644
619
|
border,
|
|
645
620
|
}).then((computedStylesData) => {
|
|
646
|
-
|
|
621
|
+
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
622
|
+
setInlineStyles(computedStylesData.tooltipStyles);
|
|
623
|
+
}
|
|
624
|
+
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
625
|
+
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
626
|
+
}
|
|
627
|
+
setActualPlacement(computedStylesData.place);
|
|
647
628
|
});
|
|
648
629
|
};
|
|
649
630
|
const handlePointerMove = (event) => {
|
|
@@ -664,6 +645,9 @@
|
|
|
664
645
|
return;
|
|
665
646
|
}
|
|
666
647
|
const target = event.target;
|
|
648
|
+
if (!target.isConnected) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
667
651
|
if ((_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) {
|
|
668
652
|
return;
|
|
669
653
|
}
|
|
@@ -733,7 +717,13 @@
|
|
|
733
717
|
// invalidate computed positions after remount
|
|
734
718
|
return;
|
|
735
719
|
}
|
|
736
|
-
|
|
720
|
+
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
721
|
+
setInlineStyles(computedStylesData.tooltipStyles);
|
|
722
|
+
}
|
|
723
|
+
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
724
|
+
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
725
|
+
}
|
|
726
|
+
setActualPlacement(computedStylesData.place);
|
|
737
727
|
});
|
|
738
728
|
}, [
|
|
739
729
|
show,
|
|
@@ -909,6 +899,8 @@
|
|
|
909
899
|
closeEvents,
|
|
910
900
|
globalCloseEvents,
|
|
911
901
|
shouldOpenOnClick,
|
|
902
|
+
delayShow,
|
|
903
|
+
delayHide,
|
|
912
904
|
]);
|
|
913
905
|
React.useEffect(() => {
|
|
914
906
|
var _a, _b;
|
|
@@ -1067,8 +1059,14 @@
|
|
|
1067
1059
|
setAnchorsBySelect([]);
|
|
1068
1060
|
}
|
|
1069
1061
|
}, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
|
|
1062
|
+
React.useEffect(() => {
|
|
1063
|
+
if (tooltipShowDelayTimerRef.current) {
|
|
1064
|
+
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
1065
|
+
handleShowTooltipDelayed(delayShow);
|
|
1066
|
+
}
|
|
1067
|
+
}, [delayShow]);
|
|
1070
1068
|
const actualContent = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.content) !== null && _a !== void 0 ? _a : content;
|
|
1071
|
-
const canShow = show && Object.keys(
|
|
1069
|
+
const canShow = show && Object.keys(inlineStyles).length > 0;
|
|
1072
1070
|
React.useImperativeHandle(forwardRef, () => ({
|
|
1073
1071
|
open: (options) => {
|
|
1074
1072
|
if (options === null || options === void 0 ? void 0 : options.anchorSelect) {
|
|
@@ -1100,10 +1098,10 @@
|
|
|
1100
1098
|
}
|
|
1101
1099
|
},
|
|
1102
1100
|
activeAnchor,
|
|
1103
|
-
place:
|
|
1101
|
+
place: actualPlacement,
|
|
1104
1102
|
isOpen: Boolean(rendered && !hidden && actualContent && canShow),
|
|
1105
1103
|
}));
|
|
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-${
|
|
1104
|
+
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-${actualPlacement}`, coreStyles[canShow ? 'show' : 'closing'], canShow ? 'react-tooltip__show' : 'react-tooltip__closing', positionStrategy === 'fixed' && coreStyles['fixed'], clickable && coreStyles['clickable']), onTransitionEnd: (event) => {
|
|
1107
1105
|
if (missedTransitionTimerRef.current) {
|
|
1108
1106
|
clearTimeout(missedTransitionTimerRef.current);
|
|
1109
1107
|
}
|
|
@@ -1115,12 +1113,12 @@
|
|
|
1115
1113
|
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
1116
1114
|
}, style: {
|
|
1117
1115
|
...externalStyles,
|
|
1118
|
-
...
|
|
1116
|
+
...inlineStyles,
|
|
1119
1117
|
opacity: opacity !== undefined && canShow ? opacity : undefined,
|
|
1120
1118
|
}, ref: tooltipRef },
|
|
1121
1119
|
actualContent,
|
|
1122
1120
|
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
|
|
1123
|
-
...
|
|
1121
|
+
...inlineArrowStyles,
|
|
1124
1122
|
background: arrowColor
|
|
1125
1123
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
1126
1124
|
: undefined,
|
|
@@ -1355,7 +1353,8 @@
|
|
|
1355
1353
|
let renderedContent = children;
|
|
1356
1354
|
const contentWrapperRef = React.useRef(null);
|
|
1357
1355
|
if (render) {
|
|
1358
|
-
const
|
|
1356
|
+
const actualContent = (activeAnchor === null || activeAnchor === void 0 ? void 0 : activeAnchor.getAttribute('data-tooltip-content')) || tooltipContent || null;
|
|
1357
|
+
const rendered = render({ content: actualContent, activeAnchor });
|
|
1359
1358
|
renderedContent = rendered ? (React__default["default"].createElement("div", { ref: contentWrapperRef, className: "react-tooltip-content-wrapper" }, rendered)) : null;
|
|
1360
1359
|
}
|
|
1361
1360
|
else if (tooltipContent) {
|