react-tooltip 5.22.0-beta.1109.0 → 5.22.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 +2 -0
- package/dist/react-tooltip.cjs +137 -111
- package/dist/react-tooltip.cjs.map +1 -1
- package/dist/react-tooltip.css +9 -4
- package/dist/react-tooltip.d.ts +36 -26
- 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 +138 -112
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +137 -111
- 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
|
@@ -327,16 +327,15 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
|
|
|
327
327
|
});
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
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"};
|
|
330
|
+
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"};
|
|
331
331
|
|
|
332
332
|
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"};
|
|
333
333
|
|
|
334
334
|
const Tooltip = ({
|
|
335
335
|
// props
|
|
336
|
-
|
|
336
|
+
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, style: externalStyles, position, afterShow, afterHide,
|
|
337
337
|
// props handled by controller
|
|
338
338
|
content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, }) => {
|
|
339
|
-
var _a;
|
|
340
339
|
const tooltipRef = React.useRef(null);
|
|
341
340
|
const tooltipArrowRef = React.useRef(null);
|
|
342
341
|
const tooltipShowDelayTimerRef = React.useRef(null);
|
|
@@ -346,7 +345,6 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
346
345
|
const [inlineArrowStyles, setInlineArrowStyles] = React.useState({});
|
|
347
346
|
const [show, setShow] = React.useState(false);
|
|
348
347
|
const [rendered, setRendered] = React.useState(false);
|
|
349
|
-
const [imperativeOptions, setImperativeOptions] = React.useState(null);
|
|
350
348
|
const wasShowing = React.useRef(false);
|
|
351
349
|
const lastFloatPosition = React.useRef(null);
|
|
352
350
|
/**
|
|
@@ -356,7 +354,48 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
356
354
|
const hoveringTooltip = React.useRef(false);
|
|
357
355
|
const [anchorsBySelect, setAnchorsBySelect] = React.useState([]);
|
|
358
356
|
const mounted = React.useRef(false);
|
|
357
|
+
/**
|
|
358
|
+
* @todo Update when deprecated stuff gets removed.
|
|
359
|
+
*/
|
|
359
360
|
const shouldOpenOnClick = openOnClick || events.includes('click');
|
|
361
|
+
const hasClickEvent = shouldOpenOnClick || (openEvents === null || openEvents === void 0 ? void 0 : openEvents.click) || (openEvents === null || openEvents === void 0 ? void 0 : openEvents.dblclick) || (openEvents === null || openEvents === void 0 ? void 0 : openEvents.mousedown);
|
|
362
|
+
const actualOpenEvents = openEvents
|
|
363
|
+
? { ...openEvents }
|
|
364
|
+
: {
|
|
365
|
+
mouseenter: true,
|
|
366
|
+
focus: true,
|
|
367
|
+
click: false,
|
|
368
|
+
dblclick: false,
|
|
369
|
+
mousedown: false,
|
|
370
|
+
};
|
|
371
|
+
if (!openEvents && shouldOpenOnClick) {
|
|
372
|
+
Object.assign(actualOpenEvents, {
|
|
373
|
+
mouseenter: false,
|
|
374
|
+
focus: false,
|
|
375
|
+
click: true,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
const actualCloseEvents = closeEvents
|
|
379
|
+
? { ...closeEvents }
|
|
380
|
+
: {
|
|
381
|
+
mouseleave: true,
|
|
382
|
+
blur: true,
|
|
383
|
+
click: false,
|
|
384
|
+
};
|
|
385
|
+
if (!closeEvents && shouldOpenOnClick) {
|
|
386
|
+
Object.assign(actualCloseEvents, {
|
|
387
|
+
mouseleave: false,
|
|
388
|
+
blur: false,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
const actualGlobalCloseEvents = globalCloseEvents
|
|
392
|
+
? { ...globalCloseEvents }
|
|
393
|
+
: {
|
|
394
|
+
escape: closeOnEsc || false,
|
|
395
|
+
scroll: closeOnScroll || false,
|
|
396
|
+
resize: closeOnResize || false,
|
|
397
|
+
clickOutsideAnchor: hasClickEvent || false,
|
|
398
|
+
};
|
|
360
399
|
/**
|
|
361
400
|
* useLayoutEffect runs before useEffect,
|
|
362
401
|
* but should be used carefully because of caveats
|
|
@@ -368,23 +407,6 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
368
407
|
mounted.current = false;
|
|
369
408
|
};
|
|
370
409
|
}, []);
|
|
371
|
-
React.useEffect(() => {
|
|
372
|
-
if (!show) {
|
|
373
|
-
/**
|
|
374
|
-
* this fixes weird behavior when switching between two anchor elements very quickly
|
|
375
|
-
* remove the timeout and switch quickly between two adjancent anchor elements to see it
|
|
376
|
-
*
|
|
377
|
-
* in practice, this means the tooltip is not immediately removed from the DOM on hide
|
|
378
|
-
*/
|
|
379
|
-
const timeout = setTimeout(() => {
|
|
380
|
-
setRendered(false);
|
|
381
|
-
}, 150);
|
|
382
|
-
return () => {
|
|
383
|
-
clearTimeout(timeout);
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
return () => null;
|
|
387
|
-
}, [show]);
|
|
388
410
|
const handleShow = (value) => {
|
|
389
411
|
if (!mounted.current) {
|
|
390
412
|
return;
|
|
@@ -433,7 +455,6 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
433
455
|
afterShow === null || afterShow === void 0 ? void 0 : afterShow();
|
|
434
456
|
}
|
|
435
457
|
else {
|
|
436
|
-
setImperativeOptions(null);
|
|
437
458
|
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
438
459
|
}
|
|
439
460
|
}, [show]);
|
|
@@ -544,17 +565,8 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
544
565
|
handleTooltipPosition(mousePosition);
|
|
545
566
|
lastFloatPosition.current = mousePosition;
|
|
546
567
|
};
|
|
547
|
-
const handleClickTooltipAnchor = (event) => {
|
|
548
|
-
handleShowTooltip(event);
|
|
549
|
-
if (delayHide) {
|
|
550
|
-
handleHideTooltipDelayed();
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
568
|
const handleClickOutsideAnchors = (event) => {
|
|
554
569
|
var _a;
|
|
555
|
-
if (!show) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
570
|
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
559
571
|
const anchors = [anchorById, ...anchorsBySelect];
|
|
560
572
|
if (anchors.some((anchor) => anchor === null || anchor === void 0 ? void 0 : anchor.contains(event.target))) {
|
|
@@ -573,11 +585,9 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
573
585
|
const debouncedHandleShowTooltip = debounce(handleShowTooltip, 50, true);
|
|
574
586
|
const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50, true);
|
|
575
587
|
const updateTooltipPosition = React.useCallback(() => {
|
|
576
|
-
|
|
577
|
-
const actualPosition = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position) !== null && _a !== void 0 ? _a : position;
|
|
578
|
-
if (actualPosition) {
|
|
588
|
+
if (position) {
|
|
579
589
|
// if `position` is set, override regular and `float` positioning
|
|
580
|
-
handleTooltipPosition(
|
|
590
|
+
handleTooltipPosition(position);
|
|
581
591
|
return;
|
|
582
592
|
}
|
|
583
593
|
if (float) {
|
|
@@ -628,7 +638,6 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
628
638
|
offset,
|
|
629
639
|
positionStrategy,
|
|
630
640
|
position,
|
|
631
|
-
imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position,
|
|
632
641
|
float,
|
|
633
642
|
]);
|
|
634
643
|
React.useEffect(() => {
|
|
@@ -646,13 +655,13 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
646
655
|
};
|
|
647
656
|
const anchorScrollParent = getScrollParent(activeAnchor);
|
|
648
657
|
const tooltipScrollParent = getScrollParent(tooltipRef.current);
|
|
649
|
-
if (
|
|
658
|
+
if (actualGlobalCloseEvents.scroll) {
|
|
650
659
|
window.addEventListener('scroll', handleScrollResize);
|
|
651
660
|
anchorScrollParent === null || anchorScrollParent === void 0 ? void 0 : anchorScrollParent.addEventListener('scroll', handleScrollResize);
|
|
652
661
|
tooltipScrollParent === null || tooltipScrollParent === void 0 ? void 0 : tooltipScrollParent.addEventListener('scroll', handleScrollResize);
|
|
653
662
|
}
|
|
654
663
|
let updateTooltipCleanup = null;
|
|
655
|
-
if (
|
|
664
|
+
if (actualGlobalCloseEvents.resize) {
|
|
656
665
|
window.addEventListener('resize', handleScrollResize);
|
|
657
666
|
}
|
|
658
667
|
else if (activeAnchor && tooltipRef.current) {
|
|
@@ -668,22 +677,56 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
668
677
|
}
|
|
669
678
|
handleShow(false);
|
|
670
679
|
};
|
|
671
|
-
if (
|
|
680
|
+
if (actualGlobalCloseEvents.escape) {
|
|
672
681
|
window.addEventListener('keydown', handleEsc);
|
|
673
682
|
}
|
|
674
|
-
|
|
675
|
-
if (shouldOpenOnClick) {
|
|
683
|
+
if (actualGlobalCloseEvents.clickOutsideAnchor) {
|
|
676
684
|
window.addEventListener('click', handleClickOutsideAnchors);
|
|
677
|
-
enabledEvents.push({ event: 'click', listener: handleClickTooltipAnchor });
|
|
678
685
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
+
const enabledEvents = [];
|
|
687
|
+
const handleClickOpenTooltipAnchor = (event) => {
|
|
688
|
+
if (show) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
handleShowTooltip(event);
|
|
692
|
+
};
|
|
693
|
+
const handleClickCloseTooltipAnchor = () => {
|
|
694
|
+
if (!show) {
|
|
695
|
+
return;
|
|
686
696
|
}
|
|
697
|
+
handleHideTooltip();
|
|
698
|
+
};
|
|
699
|
+
const regularEvents = ['mouseenter', 'mouseleave', 'focus', 'blur'];
|
|
700
|
+
const clickEvents = ['click', 'dblclick', 'mousedown', 'mouseup'];
|
|
701
|
+
Object.entries(actualOpenEvents).forEach(([event, enabled]) => {
|
|
702
|
+
if (!enabled) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (regularEvents.includes(event)) {
|
|
706
|
+
enabledEvents.push({ event, listener: debouncedHandleShowTooltip });
|
|
707
|
+
}
|
|
708
|
+
else if (clickEvents.includes(event)) {
|
|
709
|
+
enabledEvents.push({ event, listener: handleClickOpenTooltipAnchor });
|
|
710
|
+
}
|
|
711
|
+
else ;
|
|
712
|
+
});
|
|
713
|
+
Object.entries(actualCloseEvents).forEach(([event, enabled]) => {
|
|
714
|
+
if (!enabled) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (regularEvents.includes(event)) {
|
|
718
|
+
enabledEvents.push({ event, listener: debouncedHandleHideTooltip });
|
|
719
|
+
}
|
|
720
|
+
else if (clickEvents.includes(event)) {
|
|
721
|
+
enabledEvents.push({ event, listener: handleClickCloseTooltipAnchor });
|
|
722
|
+
}
|
|
723
|
+
else ;
|
|
724
|
+
});
|
|
725
|
+
if (float) {
|
|
726
|
+
enabledEvents.push({
|
|
727
|
+
event: 'mousemove',
|
|
728
|
+
listener: handleMouseMove,
|
|
729
|
+
});
|
|
687
730
|
}
|
|
688
731
|
const handleMouseEnterTooltip = () => {
|
|
689
732
|
hoveringTooltip.current = true;
|
|
@@ -692,7 +735,9 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
692
735
|
hoveringTooltip.current = false;
|
|
693
736
|
handleHideTooltip();
|
|
694
737
|
};
|
|
695
|
-
if (clickable && !
|
|
738
|
+
if (clickable && !hasClickEvent) {
|
|
739
|
+
// used to keep the tooltip open when hovering content.
|
|
740
|
+
// not needed if using click events.
|
|
696
741
|
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', handleMouseEnterTooltip);
|
|
697
742
|
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
698
743
|
}
|
|
@@ -704,24 +749,24 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
704
749
|
});
|
|
705
750
|
return () => {
|
|
706
751
|
var _a, _b;
|
|
707
|
-
if (
|
|
752
|
+
if (actualGlobalCloseEvents.scroll) {
|
|
708
753
|
window.removeEventListener('scroll', handleScrollResize);
|
|
709
754
|
anchorScrollParent === null || anchorScrollParent === void 0 ? void 0 : anchorScrollParent.removeEventListener('scroll', handleScrollResize);
|
|
710
755
|
tooltipScrollParent === null || tooltipScrollParent === void 0 ? void 0 : tooltipScrollParent.removeEventListener('scroll', handleScrollResize);
|
|
711
756
|
}
|
|
712
|
-
if (
|
|
757
|
+
if (actualGlobalCloseEvents.resize) {
|
|
713
758
|
window.removeEventListener('resize', handleScrollResize);
|
|
714
759
|
}
|
|
715
760
|
else {
|
|
716
761
|
updateTooltipCleanup === null || updateTooltipCleanup === void 0 ? void 0 : updateTooltipCleanup();
|
|
717
762
|
}
|
|
718
|
-
if (
|
|
763
|
+
if (actualGlobalCloseEvents.clickOutsideAnchor) {
|
|
719
764
|
window.removeEventListener('click', handleClickOutsideAnchors);
|
|
720
765
|
}
|
|
721
|
-
if (
|
|
766
|
+
if (actualGlobalCloseEvents.escape) {
|
|
722
767
|
window.removeEventListener('keydown', handleEsc);
|
|
723
768
|
}
|
|
724
|
-
if (clickable && !
|
|
769
|
+
if (clickable && !hasClickEvent) {
|
|
725
770
|
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', handleMouseEnterTooltip);
|
|
726
771
|
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
727
772
|
}
|
|
@@ -742,12 +787,14 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
742
787
|
rendered,
|
|
743
788
|
anchorRefs,
|
|
744
789
|
anchorsBySelect,
|
|
745
|
-
|
|
746
|
-
|
|
790
|
+
// the effect uses the `actual*Events` objects, but this should work
|
|
791
|
+
openEvents,
|
|
792
|
+
closeEvents,
|
|
793
|
+
globalCloseEvents,
|
|
794
|
+
shouldOpenOnClick,
|
|
747
795
|
]);
|
|
748
796
|
React.useEffect(() => {
|
|
749
|
-
|
|
750
|
-
let selector = (_b = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect) !== null && _a !== void 0 ? _a : anchorSelect) !== null && _b !== void 0 ? _b : '';
|
|
797
|
+
let selector = anchorSelect !== null && anchorSelect !== void 0 ? anchorSelect : '';
|
|
751
798
|
if (!selector && id) {
|
|
752
799
|
selector = `[data-tooltip-id='${id}']`;
|
|
753
800
|
}
|
|
@@ -820,7 +867,7 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
820
867
|
});
|
|
821
868
|
if (newAnchors.length || removedAnchors.length) {
|
|
822
869
|
setAnchorsBySelect((anchors) => [
|
|
823
|
-
...anchors.filter((anchor) => removedAnchors.includes(anchor)),
|
|
870
|
+
...anchors.filter((anchor) => !removedAnchors.includes(anchor)),
|
|
824
871
|
...newAnchors,
|
|
825
872
|
]);
|
|
826
873
|
}
|
|
@@ -836,7 +883,7 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
836
883
|
return () => {
|
|
837
884
|
documentObserver.disconnect();
|
|
838
885
|
};
|
|
839
|
-
}, [id, anchorSelect,
|
|
886
|
+
}, [id, anchorSelect, activeAnchor]);
|
|
840
887
|
React.useEffect(() => {
|
|
841
888
|
updateTooltipPosition();
|
|
842
889
|
}, [updateTooltipPosition]);
|
|
@@ -876,8 +923,7 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
876
923
|
};
|
|
877
924
|
}, []);
|
|
878
925
|
React.useEffect(() => {
|
|
879
|
-
|
|
880
|
-
let selector = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect) !== null && _a !== void 0 ? _a : anchorSelect;
|
|
926
|
+
let selector = anchorSelect;
|
|
881
927
|
if (!selector && id) {
|
|
882
928
|
selector = `[data-tooltip-id='${id}']`;
|
|
883
929
|
}
|
|
@@ -888,55 +934,28 @@ content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, bo
|
|
|
888
934
|
const anchors = Array.from(document.querySelectorAll(selector));
|
|
889
935
|
setAnchorsBySelect(anchors);
|
|
890
936
|
}
|
|
891
|
-
catch (
|
|
937
|
+
catch (_a) {
|
|
892
938
|
// warning was already issued in the controller
|
|
893
939
|
setAnchorsBySelect([]);
|
|
894
940
|
}
|
|
895
|
-
}, [id, anchorSelect
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
catch (_a) {
|
|
905
|
-
{
|
|
906
|
-
// eslint-disable-next-line no-console
|
|
907
|
-
console.warn(`[react-tooltip] "${options.anchorSelect}" is not a valid CSS selector`);
|
|
908
|
-
}
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
941
|
+
}, [id, anchorSelect]);
|
|
942
|
+
const canShow = !hidden && content && show && Object.keys(inlineStyles).length > 0;
|
|
943
|
+
return rendered ? (React__default["default"].createElement(WrapperElement, { id: id, role: "tooltip", 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) => {
|
|
944
|
+
/**
|
|
945
|
+
* @warning if `--rt-transition-closing-delay` is set to 0,
|
|
946
|
+
* the tooltip will be stuck (but not visible) on the DOM
|
|
947
|
+
*/
|
|
948
|
+
if (show || event.propertyName !== 'opacity') {
|
|
949
|
+
return;
|
|
911
950
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
},
|
|
915
|
-
close: () => {
|
|
916
|
-
handleShow(false);
|
|
917
|
-
},
|
|
918
|
-
activeAnchor,
|
|
919
|
-
place: actualPlacement,
|
|
920
|
-
isOpen: rendered && canShow,
|
|
921
|
-
}));
|
|
922
|
-
return rendered ? (React__default["default"].createElement(WrapperElement, { id: id, role: "tooltip", className: classNames__default["default"]('react-tooltip', coreStyles['tooltip'], styles['tooltip'], styles[variant], className, `react-tooltip__place-${actualPlacement}`, {
|
|
923
|
-
'react-tooltip__show': canShow,
|
|
924
|
-
[coreStyles['show']]: canShow,
|
|
925
|
-
[coreStyles['fixed']]: positionStrategy === 'fixed',
|
|
926
|
-
[coreStyles['clickable']]: clickable,
|
|
927
|
-
}), style: {
|
|
951
|
+
setRendered(false);
|
|
952
|
+
}, style: {
|
|
928
953
|
...externalStyles,
|
|
929
954
|
...inlineStyles,
|
|
930
955
|
opacity: opacity !== undefined && canShow ? opacity : undefined,
|
|
931
956
|
}, ref: tooltipRef },
|
|
932
|
-
|
|
933
|
-
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, {
|
|
934
|
-
/**
|
|
935
|
-
* changed from dash `no-arrow` to camelcase because of:
|
|
936
|
-
* https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
|
|
937
|
-
*/
|
|
938
|
-
[coreStyles['noArrow']]: noArrow,
|
|
939
|
-
}), style: {
|
|
957
|
+
content,
|
|
958
|
+
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
|
|
940
959
|
...inlineArrowStyles,
|
|
941
960
|
background: arrowColor
|
|
942
961
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
@@ -949,7 +968,7 @@ const TooltipContent = ({ content }) => {
|
|
|
949
968
|
return React__default["default"].createElement("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
950
969
|
};
|
|
951
970
|
|
|
952
|
-
const TooltipController =
|
|
971
|
+
const TooltipController = ({ 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, style, position, isOpen, disableStyleInjection = false, border, opacity, arrowColor, setIsOpen, afterShow, afterHide, }) => {
|
|
953
972
|
const [tooltipContent, setTooltipContent] = React.useState(content);
|
|
954
973
|
const [tooltipHtml, setTooltipHtml] = React.useState(html);
|
|
955
974
|
const [tooltipPlace, setTooltipPlace] = React.useState(place);
|
|
@@ -1173,7 +1192,6 @@ const TooltipController = React__default["default"].forwardRef(({ id, anchorId,
|
|
|
1173
1192
|
renderedContent = React__default["default"].createElement(TooltipContent, { content: tooltipHtml });
|
|
1174
1193
|
}
|
|
1175
1194
|
const props = {
|
|
1176
|
-
forwardRef: ref,
|
|
1177
1195
|
id,
|
|
1178
1196
|
anchorId,
|
|
1179
1197
|
anchorSelect,
|
|
@@ -1198,6 +1216,9 @@ const TooltipController = React__default["default"].forwardRef(({ id, anchorId,
|
|
|
1198
1216
|
closeOnEsc,
|
|
1199
1217
|
closeOnScroll,
|
|
1200
1218
|
closeOnResize,
|
|
1219
|
+
openEvents,
|
|
1220
|
+
closeEvents,
|
|
1221
|
+
globalCloseEvents,
|
|
1201
1222
|
style,
|
|
1202
1223
|
position,
|
|
1203
1224
|
isOpen,
|
|
@@ -1211,7 +1232,7 @@ const TooltipController = React__default["default"].forwardRef(({ id, anchorId,
|
|
|
1211
1232
|
setActiveAnchor: (anchor) => setActiveAnchor(anchor),
|
|
1212
1233
|
};
|
|
1213
1234
|
return React__default["default"].createElement(Tooltip, { ...props });
|
|
1214
|
-
}
|
|
1235
|
+
};
|
|
1215
1236
|
|
|
1216
1237
|
// those content will be replaced in build time with the `react-tooltip.css` builded content
|
|
1217
1238
|
const TooltipCoreStyles = `:root {
|
|
@@ -1222,17 +1243,17 @@ const TooltipCoreStyles = `:root {
|
|
|
1222
1243
|
--rt-color-warning: #f0ad4e;
|
|
1223
1244
|
--rt-color-info: #337ab7;
|
|
1224
1245
|
--rt-opacity: 0.9;
|
|
1246
|
+
--rt-transition-show-delay: 0.15s;
|
|
1247
|
+
--rt-transition-closing-delay: 0.15s;
|
|
1225
1248
|
}
|
|
1226
1249
|
|
|
1227
1250
|
.core-styles-module_tooltip__3vRRp {
|
|
1228
|
-
visibility: hidden;
|
|
1229
1251
|
position: absolute;
|
|
1230
1252
|
top: 0;
|
|
1231
1253
|
left: 0;
|
|
1232
1254
|
pointer-events: none;
|
|
1233
1255
|
opacity: 0;
|
|
1234
|
-
|
|
1235
|
-
will-change: opacity, visibility;
|
|
1256
|
+
will-change: opacity;
|
|
1236
1257
|
}
|
|
1237
1258
|
|
|
1238
1259
|
.core-styles-module_fixed__pcSol {
|
|
@@ -1253,8 +1274,13 @@ const TooltipCoreStyles = `:root {
|
|
|
1253
1274
|
}
|
|
1254
1275
|
|
|
1255
1276
|
.core-styles-module_show__Nt9eE {
|
|
1256
|
-
visibility: visible;
|
|
1257
1277
|
opacity: var(--rt-opacity);
|
|
1278
|
+
transition: opacity var(--rt-transition-show-delay) ease-out;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
.core-styles-module_closing__sGnxF {
|
|
1282
|
+
opacity: 0;
|
|
1283
|
+
transition: opacity var(--rt-transition-closing-delay) ease-in;
|
|
1258
1284
|
}
|
|
1259
1285
|
|
|
1260
1286
|
`;
|