react-tooltip 5.22.0-beta.1109.1 → 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 +141 -127
- package/dist/react-tooltip.cjs.map +1 -1
- package/dist/react-tooltip.css +9 -4
- package/dist/react-tooltip.d.ts +35 -37
- 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 +142 -128
- package/dist/react-tooltip.mjs.map +1 -1
- package/dist/react-tooltip.umd.js +141 -127
- 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
|
@@ -325,16 +325,15 @@
|
|
|
325
325
|
});
|
|
326
326
|
};
|
|
327
327
|
|
|
328
|
-
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"};
|
|
328
|
+
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"};
|
|
329
329
|
|
|
330
330
|
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"};
|
|
331
331
|
|
|
332
332
|
const Tooltip = ({
|
|
333
333
|
// props
|
|
334
|
-
|
|
334
|
+
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,
|
|
335
335
|
// props handled by controller
|
|
336
336
|
content, contentWrapperRef, isOpen, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, }) => {
|
|
337
|
-
var _a;
|
|
338
337
|
const tooltipRef = React.useRef(null);
|
|
339
338
|
const tooltipArrowRef = React.useRef(null);
|
|
340
339
|
const tooltipShowDelayTimerRef = React.useRef(null);
|
|
@@ -344,7 +343,6 @@
|
|
|
344
343
|
const [inlineArrowStyles, setInlineArrowStyles] = React.useState({});
|
|
345
344
|
const [show, setShow] = React.useState(false);
|
|
346
345
|
const [rendered, setRendered] = React.useState(false);
|
|
347
|
-
const [imperativeOptions, setImperativeOptions] = React.useState(null);
|
|
348
346
|
const wasShowing = React.useRef(false);
|
|
349
347
|
const lastFloatPosition = React.useRef(null);
|
|
350
348
|
/**
|
|
@@ -354,7 +352,48 @@
|
|
|
354
352
|
const hoveringTooltip = React.useRef(false);
|
|
355
353
|
const [anchorsBySelect, setAnchorsBySelect] = React.useState([]);
|
|
356
354
|
const mounted = React.useRef(false);
|
|
355
|
+
/**
|
|
356
|
+
* @todo Update when deprecated stuff gets removed.
|
|
357
|
+
*/
|
|
357
358
|
const shouldOpenOnClick = openOnClick || events.includes('click');
|
|
359
|
+
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);
|
|
360
|
+
const actualOpenEvents = openEvents
|
|
361
|
+
? { ...openEvents }
|
|
362
|
+
: {
|
|
363
|
+
mouseenter: true,
|
|
364
|
+
focus: true,
|
|
365
|
+
click: false,
|
|
366
|
+
dblclick: false,
|
|
367
|
+
mousedown: false,
|
|
368
|
+
};
|
|
369
|
+
if (!openEvents && shouldOpenOnClick) {
|
|
370
|
+
Object.assign(actualOpenEvents, {
|
|
371
|
+
mouseenter: false,
|
|
372
|
+
focus: false,
|
|
373
|
+
click: true,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const actualCloseEvents = closeEvents
|
|
377
|
+
? { ...closeEvents }
|
|
378
|
+
: {
|
|
379
|
+
mouseleave: true,
|
|
380
|
+
blur: true,
|
|
381
|
+
click: false,
|
|
382
|
+
};
|
|
383
|
+
if (!closeEvents && shouldOpenOnClick) {
|
|
384
|
+
Object.assign(actualCloseEvents, {
|
|
385
|
+
mouseleave: false,
|
|
386
|
+
blur: false,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
const actualGlobalCloseEvents = globalCloseEvents
|
|
390
|
+
? { ...globalCloseEvents }
|
|
391
|
+
: {
|
|
392
|
+
escape: closeOnEsc || false,
|
|
393
|
+
scroll: closeOnScroll || false,
|
|
394
|
+
resize: closeOnResize || false,
|
|
395
|
+
clickOutsideAnchor: hasClickEvent || false,
|
|
396
|
+
};
|
|
358
397
|
/**
|
|
359
398
|
* useLayoutEffect runs before useEffect,
|
|
360
399
|
* but should be used carefully because of caveats
|
|
@@ -366,23 +405,6 @@
|
|
|
366
405
|
mounted.current = false;
|
|
367
406
|
};
|
|
368
407
|
}, []);
|
|
369
|
-
React.useEffect(() => {
|
|
370
|
-
if (!show) {
|
|
371
|
-
/**
|
|
372
|
-
* this fixes weird behavior when switching between two anchor elements very quickly
|
|
373
|
-
* remove the timeout and switch quickly between two adjancent anchor elements to see it
|
|
374
|
-
*
|
|
375
|
-
* in practice, this means the tooltip is not immediately removed from the DOM on hide
|
|
376
|
-
*/
|
|
377
|
-
const timeout = setTimeout(() => {
|
|
378
|
-
setRendered(false);
|
|
379
|
-
}, 150);
|
|
380
|
-
return () => {
|
|
381
|
-
clearTimeout(timeout);
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
return () => null;
|
|
385
|
-
}, [show]);
|
|
386
408
|
const handleShow = (value) => {
|
|
387
409
|
if (!mounted.current) {
|
|
388
410
|
return;
|
|
@@ -431,17 +453,16 @@
|
|
|
431
453
|
afterShow === null || afterShow === void 0 ? void 0 : afterShow();
|
|
432
454
|
}
|
|
433
455
|
else {
|
|
434
|
-
setImperativeOptions(null);
|
|
435
456
|
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
436
457
|
}
|
|
437
458
|
}, [show]);
|
|
438
|
-
const handleShowTooltipDelayed = (
|
|
459
|
+
const handleShowTooltipDelayed = () => {
|
|
439
460
|
if (tooltipShowDelayTimerRef.current) {
|
|
440
461
|
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
441
462
|
}
|
|
442
463
|
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
443
464
|
handleShow(true);
|
|
444
|
-
},
|
|
465
|
+
}, delayShow);
|
|
445
466
|
};
|
|
446
467
|
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
447
468
|
if (tooltipHideDelayTimerRef.current) {
|
|
@@ -497,7 +518,6 @@
|
|
|
497
518
|
}
|
|
498
519
|
};
|
|
499
520
|
const handleTooltipPosition = ({ x, y }) => {
|
|
500
|
-
var _a;
|
|
501
521
|
const virtualElement = {
|
|
502
522
|
getBoundingClientRect() {
|
|
503
523
|
return {
|
|
@@ -513,7 +533,7 @@
|
|
|
513
533
|
},
|
|
514
534
|
};
|
|
515
535
|
computeTooltipPosition({
|
|
516
|
-
place
|
|
536
|
+
place,
|
|
517
537
|
offset,
|
|
518
538
|
elementReference: virtualElement,
|
|
519
539
|
tooltipReference: tooltipRef.current,
|
|
@@ -543,17 +563,8 @@
|
|
|
543
563
|
handleTooltipPosition(mousePosition);
|
|
544
564
|
lastFloatPosition.current = mousePosition;
|
|
545
565
|
};
|
|
546
|
-
const handleClickTooltipAnchor = (event) => {
|
|
547
|
-
handleShowTooltip(event);
|
|
548
|
-
if (delayHide) {
|
|
549
|
-
handleHideTooltipDelayed();
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
566
|
const handleClickOutsideAnchors = (event) => {
|
|
553
567
|
var _a;
|
|
554
|
-
if (!show) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
568
|
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
558
569
|
const anchors = [anchorById, ...anchorsBySelect];
|
|
559
570
|
if (anchors.some((anchor) => anchor === null || anchor === void 0 ? void 0 : anchor.contains(event.target))) {
|
|
@@ -572,11 +583,9 @@
|
|
|
572
583
|
const debouncedHandleShowTooltip = debounce(handleShowTooltip, 50, true);
|
|
573
584
|
const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50, true);
|
|
574
585
|
const updateTooltipPosition = React.useCallback(() => {
|
|
575
|
-
|
|
576
|
-
const actualPosition = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position) !== null && _a !== void 0 ? _a : position;
|
|
577
|
-
if (actualPosition) {
|
|
586
|
+
if (position) {
|
|
578
587
|
// if `position` is set, override regular and `float` positioning
|
|
579
|
-
handleTooltipPosition(
|
|
588
|
+
handleTooltipPosition(position);
|
|
580
589
|
return;
|
|
581
590
|
}
|
|
582
591
|
if (float) {
|
|
@@ -597,7 +606,7 @@
|
|
|
597
606
|
return;
|
|
598
607
|
}
|
|
599
608
|
computeTooltipPosition({
|
|
600
|
-
place
|
|
609
|
+
place,
|
|
601
610
|
offset,
|
|
602
611
|
elementReference: activeAnchor,
|
|
603
612
|
tooltipReference: tooltipRef.current,
|
|
@@ -624,11 +633,9 @@
|
|
|
624
633
|
content,
|
|
625
634
|
externalStyles,
|
|
626
635
|
place,
|
|
627
|
-
imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.place,
|
|
628
636
|
offset,
|
|
629
637
|
positionStrategy,
|
|
630
638
|
position,
|
|
631
|
-
imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position,
|
|
632
639
|
float,
|
|
633
640
|
]);
|
|
634
641
|
React.useEffect(() => {
|
|
@@ -646,13 +653,13 @@
|
|
|
646
653
|
};
|
|
647
654
|
const anchorScrollParent = getScrollParent(activeAnchor);
|
|
648
655
|
const tooltipScrollParent = getScrollParent(tooltipRef.current);
|
|
649
|
-
if (
|
|
656
|
+
if (actualGlobalCloseEvents.scroll) {
|
|
650
657
|
window.addEventListener('scroll', handleScrollResize);
|
|
651
658
|
anchorScrollParent === null || anchorScrollParent === void 0 ? void 0 : anchorScrollParent.addEventListener('scroll', handleScrollResize);
|
|
652
659
|
tooltipScrollParent === null || tooltipScrollParent === void 0 ? void 0 : tooltipScrollParent.addEventListener('scroll', handleScrollResize);
|
|
653
660
|
}
|
|
654
661
|
let updateTooltipCleanup = null;
|
|
655
|
-
if (
|
|
662
|
+
if (actualGlobalCloseEvents.resize) {
|
|
656
663
|
window.addEventListener('resize', handleScrollResize);
|
|
657
664
|
}
|
|
658
665
|
else if (activeAnchor && tooltipRef.current) {
|
|
@@ -668,22 +675,56 @@
|
|
|
668
675
|
}
|
|
669
676
|
handleShow(false);
|
|
670
677
|
};
|
|
671
|
-
if (
|
|
678
|
+
if (actualGlobalCloseEvents.escape) {
|
|
672
679
|
window.addEventListener('keydown', handleEsc);
|
|
673
680
|
}
|
|
674
|
-
|
|
675
|
-
if (shouldOpenOnClick) {
|
|
681
|
+
if (actualGlobalCloseEvents.clickOutsideAnchor) {
|
|
676
682
|
window.addEventListener('click', handleClickOutsideAnchors);
|
|
677
|
-
enabledEvents.push({ event: 'click', listener: handleClickTooltipAnchor });
|
|
678
683
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
684
|
+
const enabledEvents = [];
|
|
685
|
+
const handleClickOpenTooltipAnchor = (event) => {
|
|
686
|
+
if (show) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
handleShowTooltip(event);
|
|
690
|
+
};
|
|
691
|
+
const handleClickCloseTooltipAnchor = () => {
|
|
692
|
+
if (!show) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
handleHideTooltip();
|
|
696
|
+
};
|
|
697
|
+
const regularEvents = ['mouseenter', 'mouseleave', 'focus', 'blur'];
|
|
698
|
+
const clickEvents = ['click', 'dblclick', 'mousedown', 'mouseup'];
|
|
699
|
+
Object.entries(actualOpenEvents).forEach(([event, enabled]) => {
|
|
700
|
+
if (!enabled) {
|
|
701
|
+
return;
|
|
686
702
|
}
|
|
703
|
+
if (regularEvents.includes(event)) {
|
|
704
|
+
enabledEvents.push({ event, listener: debouncedHandleShowTooltip });
|
|
705
|
+
}
|
|
706
|
+
else if (clickEvents.includes(event)) {
|
|
707
|
+
enabledEvents.push({ event, listener: handleClickOpenTooltipAnchor });
|
|
708
|
+
}
|
|
709
|
+
else ;
|
|
710
|
+
});
|
|
711
|
+
Object.entries(actualCloseEvents).forEach(([event, enabled]) => {
|
|
712
|
+
if (!enabled) {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
if (regularEvents.includes(event)) {
|
|
716
|
+
enabledEvents.push({ event, listener: debouncedHandleHideTooltip });
|
|
717
|
+
}
|
|
718
|
+
else if (clickEvents.includes(event)) {
|
|
719
|
+
enabledEvents.push({ event, listener: handleClickCloseTooltipAnchor });
|
|
720
|
+
}
|
|
721
|
+
else ;
|
|
722
|
+
});
|
|
723
|
+
if (float) {
|
|
724
|
+
enabledEvents.push({
|
|
725
|
+
event: 'mousemove',
|
|
726
|
+
listener: handleMouseMove,
|
|
727
|
+
});
|
|
687
728
|
}
|
|
688
729
|
const handleMouseEnterTooltip = () => {
|
|
689
730
|
hoveringTooltip.current = true;
|
|
@@ -692,7 +733,9 @@
|
|
|
692
733
|
hoveringTooltip.current = false;
|
|
693
734
|
handleHideTooltip();
|
|
694
735
|
};
|
|
695
|
-
if (clickable && !
|
|
736
|
+
if (clickable && !hasClickEvent) {
|
|
737
|
+
// used to keep the tooltip open when hovering content.
|
|
738
|
+
// not needed if using click events.
|
|
696
739
|
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', handleMouseEnterTooltip);
|
|
697
740
|
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
698
741
|
}
|
|
@@ -704,24 +747,24 @@
|
|
|
704
747
|
});
|
|
705
748
|
return () => {
|
|
706
749
|
var _a, _b;
|
|
707
|
-
if (
|
|
750
|
+
if (actualGlobalCloseEvents.scroll) {
|
|
708
751
|
window.removeEventListener('scroll', handleScrollResize);
|
|
709
752
|
anchorScrollParent === null || anchorScrollParent === void 0 ? void 0 : anchorScrollParent.removeEventListener('scroll', handleScrollResize);
|
|
710
753
|
tooltipScrollParent === null || tooltipScrollParent === void 0 ? void 0 : tooltipScrollParent.removeEventListener('scroll', handleScrollResize);
|
|
711
754
|
}
|
|
712
|
-
if (
|
|
755
|
+
if (actualGlobalCloseEvents.resize) {
|
|
713
756
|
window.removeEventListener('resize', handleScrollResize);
|
|
714
757
|
}
|
|
715
758
|
else {
|
|
716
759
|
updateTooltipCleanup === null || updateTooltipCleanup === void 0 ? void 0 : updateTooltipCleanup();
|
|
717
760
|
}
|
|
718
|
-
if (
|
|
761
|
+
if (actualGlobalCloseEvents.clickOutsideAnchor) {
|
|
719
762
|
window.removeEventListener('click', handleClickOutsideAnchors);
|
|
720
763
|
}
|
|
721
|
-
if (
|
|
764
|
+
if (actualGlobalCloseEvents.escape) {
|
|
722
765
|
window.removeEventListener('keydown', handleEsc);
|
|
723
766
|
}
|
|
724
|
-
if (clickable && !
|
|
767
|
+
if (clickable && !hasClickEvent) {
|
|
725
768
|
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', handleMouseEnterTooltip);
|
|
726
769
|
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
727
770
|
}
|
|
@@ -742,12 +785,14 @@
|
|
|
742
785
|
rendered,
|
|
743
786
|
anchorRefs,
|
|
744
787
|
anchorsBySelect,
|
|
745
|
-
|
|
746
|
-
|
|
788
|
+
// the effect uses the `actual*Events` objects, but this should work
|
|
789
|
+
openEvents,
|
|
790
|
+
closeEvents,
|
|
791
|
+
globalCloseEvents,
|
|
792
|
+
shouldOpenOnClick,
|
|
747
793
|
]);
|
|
748
794
|
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 : '';
|
|
795
|
+
let selector = anchorSelect !== null && anchorSelect !== void 0 ? anchorSelect : '';
|
|
751
796
|
if (!selector && id) {
|
|
752
797
|
selector = `[data-tooltip-id='${id}']`;
|
|
753
798
|
}
|
|
@@ -820,7 +865,7 @@
|
|
|
820
865
|
});
|
|
821
866
|
if (newAnchors.length || removedAnchors.length) {
|
|
822
867
|
setAnchorsBySelect((anchors) => [
|
|
823
|
-
...anchors.filter((anchor) => removedAnchors.includes(anchor)),
|
|
868
|
+
...anchors.filter((anchor) => !removedAnchors.includes(anchor)),
|
|
824
869
|
...newAnchors,
|
|
825
870
|
]);
|
|
826
871
|
}
|
|
@@ -836,7 +881,7 @@
|
|
|
836
881
|
return () => {
|
|
837
882
|
documentObserver.disconnect();
|
|
838
883
|
};
|
|
839
|
-
}, [id, anchorSelect,
|
|
884
|
+
}, [id, anchorSelect, activeAnchor]);
|
|
840
885
|
React.useEffect(() => {
|
|
841
886
|
updateTooltipPosition();
|
|
842
887
|
}, [updateTooltipPosition]);
|
|
@@ -876,8 +921,7 @@
|
|
|
876
921
|
};
|
|
877
922
|
}, []);
|
|
878
923
|
React.useEffect(() => {
|
|
879
|
-
|
|
880
|
-
let selector = (_a = imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect) !== null && _a !== void 0 ? _a : anchorSelect;
|
|
924
|
+
let selector = anchorSelect;
|
|
881
925
|
if (!selector && id) {
|
|
882
926
|
selector = `[data-tooltip-id='${id}']`;
|
|
883
927
|
}
|
|
@@ -888,65 +932,28 @@
|
|
|
888
932
|
const anchors = Array.from(document.querySelectorAll(selector));
|
|
889
933
|
setAnchorsBySelect(anchors);
|
|
890
934
|
}
|
|
891
|
-
catch (
|
|
935
|
+
catch (_a) {
|
|
892
936
|
// warning was already issued in the controller
|
|
893
937
|
setAnchorsBySelect([]);
|
|
894
938
|
}
|
|
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
|
-
}
|
|
911
|
-
}
|
|
912
|
-
setImperativeOptions(options !== null && options !== void 0 ? options : null);
|
|
913
|
-
if (options === null || options === void 0 ? void 0 : options.delay) {
|
|
914
|
-
handleShowTooltipDelayed(options.delay);
|
|
915
|
-
}
|
|
916
|
-
else {
|
|
917
|
-
handleShow(true);
|
|
918
|
-
}
|
|
919
|
-
},
|
|
920
|
-
close: (options) => {
|
|
921
|
-
if (options === null || options === void 0 ? void 0 : options.delay) {
|
|
922
|
-
handleHideTooltipDelayed(options.delay);
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
handleShow(false);
|
|
939
|
+
}, [id, anchorSelect]);
|
|
940
|
+
const canShow = !hidden && content && show && Object.keys(inlineStyles).length > 0;
|
|
941
|
+
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) => {
|
|
942
|
+
/**
|
|
943
|
+
* @warning if `--rt-transition-closing-delay` is set to 0,
|
|
944
|
+
* the tooltip will be stuck (but not visible) on the DOM
|
|
945
|
+
*/
|
|
946
|
+
if (show || event.propertyName !== 'opacity') {
|
|
947
|
+
return;
|
|
926
948
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
place: actualPlacement,
|
|
930
|
-
isOpen: rendered && canShow,
|
|
931
|
-
}));
|
|
932
|
-
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}`, {
|
|
933
|
-
'react-tooltip__show': canShow,
|
|
934
|
-
[coreStyles['show']]: canShow,
|
|
935
|
-
[coreStyles['fixed']]: positionStrategy === 'fixed',
|
|
936
|
-
[coreStyles['clickable']]: clickable,
|
|
937
|
-
}), style: {
|
|
949
|
+
setRendered(false);
|
|
950
|
+
}, style: {
|
|
938
951
|
...externalStyles,
|
|
939
952
|
...inlineStyles,
|
|
940
953
|
opacity: opacity !== undefined && canShow ? opacity : undefined,
|
|
941
954
|
}, ref: tooltipRef },
|
|
942
|
-
|
|
943
|
-
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, {
|
|
944
|
-
/**
|
|
945
|
-
* changed from dash `no-arrow` to camelcase because of:
|
|
946
|
-
* https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
|
|
947
|
-
*/
|
|
948
|
-
[coreStyles['noArrow']]: noArrow,
|
|
949
|
-
}), style: {
|
|
955
|
+
content,
|
|
956
|
+
React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
|
|
950
957
|
...inlineArrowStyles,
|
|
951
958
|
background: arrowColor
|
|
952
959
|
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
|
|
@@ -959,7 +966,7 @@
|
|
|
959
966
|
return React__default["default"].createElement("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
960
967
|
};
|
|
961
968
|
|
|
962
|
-
const TooltipController =
|
|
969
|
+
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, }) => {
|
|
963
970
|
const [tooltipContent, setTooltipContent] = React.useState(content);
|
|
964
971
|
const [tooltipHtml, setTooltipHtml] = React.useState(html);
|
|
965
972
|
const [tooltipPlace, setTooltipPlace] = React.useState(place);
|
|
@@ -1183,7 +1190,6 @@
|
|
|
1183
1190
|
renderedContent = React__default["default"].createElement(TooltipContent, { content: tooltipHtml });
|
|
1184
1191
|
}
|
|
1185
1192
|
const props = {
|
|
1186
|
-
forwardRef: ref,
|
|
1187
1193
|
id,
|
|
1188
1194
|
anchorId,
|
|
1189
1195
|
anchorSelect,
|
|
@@ -1208,6 +1214,9 @@
|
|
|
1208
1214
|
closeOnEsc,
|
|
1209
1215
|
closeOnScroll,
|
|
1210
1216
|
closeOnResize,
|
|
1217
|
+
openEvents,
|
|
1218
|
+
closeEvents,
|
|
1219
|
+
globalCloseEvents,
|
|
1211
1220
|
style,
|
|
1212
1221
|
position,
|
|
1213
1222
|
isOpen,
|
|
@@ -1221,7 +1230,7 @@
|
|
|
1221
1230
|
setActiveAnchor: (anchor) => setActiveAnchor(anchor),
|
|
1222
1231
|
};
|
|
1223
1232
|
return React__default["default"].createElement(Tooltip, { ...props });
|
|
1224
|
-
}
|
|
1233
|
+
};
|
|
1225
1234
|
|
|
1226
1235
|
// those content will be replaced in build time with the `react-tooltip.css` builded content
|
|
1227
1236
|
const TooltipCoreStyles = `:root {
|
|
@@ -1232,17 +1241,17 @@
|
|
|
1232
1241
|
--rt-color-warning: #f0ad4e;
|
|
1233
1242
|
--rt-color-info: #337ab7;
|
|
1234
1243
|
--rt-opacity: 0.9;
|
|
1244
|
+
--rt-transition-show-delay: 0.15s;
|
|
1245
|
+
--rt-transition-closing-delay: 0.15s;
|
|
1235
1246
|
}
|
|
1236
1247
|
|
|
1237
1248
|
.core-styles-module_tooltip__3vRRp {
|
|
1238
|
-
visibility: hidden;
|
|
1239
1249
|
position: absolute;
|
|
1240
1250
|
top: 0;
|
|
1241
1251
|
left: 0;
|
|
1242
1252
|
pointer-events: none;
|
|
1243
1253
|
opacity: 0;
|
|
1244
|
-
|
|
1245
|
-
will-change: opacity, visibility;
|
|
1254
|
+
will-change: opacity;
|
|
1246
1255
|
}
|
|
1247
1256
|
|
|
1248
1257
|
.core-styles-module_fixed__pcSol {
|
|
@@ -1263,8 +1272,13 @@
|
|
|
1263
1272
|
}
|
|
1264
1273
|
|
|
1265
1274
|
.core-styles-module_show__Nt9eE {
|
|
1266
|
-
visibility: visible;
|
|
1267
1275
|
opacity: var(--rt-opacity);
|
|
1276
|
+
transition: opacity var(--rt-transition-show-delay) ease-out;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
.core-styles-module_closing__sGnxF {
|
|
1280
|
+
opacity: 0;
|
|
1281
|
+
transition: opacity var(--rt-transition-closing-delay) ease-in;
|
|
1268
1282
|
}
|
|
1269
1283
|
|
|
1270
1284
|
`;
|