react-tooltip 5.26.4 → 5.27.0-beta.1205.rc.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.
@@ -289,6 +289,14 @@
289
289
 
290
290
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
291
291
 
292
+ const clearTimeoutRef = (ref) => {
293
+ if (ref.current) {
294
+ clearTimeout(ref.current);
295
+ // eslint-disable-next-line no-param-reassign
296
+ ref.current = null;
297
+ }
298
+ };
299
+
292
300
  const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
293
301
  const DEFAULT_CONTEXT_DATA = {
294
302
  anchorRefs: new Set(),
@@ -427,8 +435,9 @@
427
435
  const actualOpenEvents = openEvents
428
436
  ? { ...openEvents }
429
437
  : {
430
- mouseenter: true,
438
+ mouseover: true,
431
439
  focus: true,
440
+ mouseenter: false,
432
441
  click: false,
433
442
  dblclick: false,
434
443
  mousedown: false,
@@ -437,14 +446,16 @@
437
446
  Object.assign(actualOpenEvents, {
438
447
  mouseenter: false,
439
448
  focus: false,
449
+ mouseover: false,
440
450
  click: true,
441
451
  });
442
452
  }
443
453
  const actualCloseEvents = closeEvents
444
454
  ? { ...closeEvents }
445
455
  : {
446
- mouseleave: true,
456
+ mouseout: true,
447
457
  blur: true,
458
+ mouseleave: false,
448
459
  click: false,
449
460
  dblclick: false,
450
461
  mouseup: false,
@@ -453,6 +464,7 @@
453
464
  Object.assign(actualCloseEvents, {
454
465
  mouseleave: false,
455
466
  blur: false,
467
+ mouseout: false,
456
468
  });
457
469
  }
458
470
  const actualGlobalCloseEvents = globalCloseEvents
@@ -539,9 +551,7 @@
539
551
  if (show === wasShowing.current) {
540
552
  return;
541
553
  }
542
- if (missedTransitionTimerRef.current) {
543
- clearTimeout(missedTransitionTimerRef.current);
544
- }
554
+ clearTimeoutRef(missedTransitionTimerRef);
545
555
  wasShowing.current = show;
546
556
  if (show) {
547
557
  afterShow === null || afterShow === void 0 ? void 0 : afterShow();
@@ -570,9 +580,7 @@
570
580
  : newComputedPosition);
571
581
  };
572
582
  const handleShowTooltipDelayed = (delay = delayShow) => {
573
- if (tooltipShowDelayTimerRef.current) {
574
- clearTimeout(tooltipShowDelayTimerRef.current);
575
- }
583
+ clearTimeoutRef(tooltipShowDelayTimerRef);
576
584
  if (rendered) {
577
585
  // if the tooltip is already rendered, ignore delay
578
586
  handleShow(true);
@@ -583,9 +591,7 @@
583
591
  }, delay);
584
592
  };
585
593
  const handleHideTooltipDelayed = (delay = delayHide) => {
586
- if (tooltipHideDelayTimerRef.current) {
587
- clearTimeout(tooltipHideDelayTimerRef.current);
588
- }
594
+ clearTimeoutRef(tooltipHideDelayTimerRef);
589
595
  tooltipHideDelayTimerRef.current = setTimeout(() => {
590
596
  if (hoveringTooltip.current) {
591
597
  return;
@@ -616,9 +622,7 @@
616
622
  }
617
623
  setActiveAnchor(target);
618
624
  setProviderActiveAnchor({ current: target });
619
- if (tooltipHideDelayTimerRef.current) {
620
- clearTimeout(tooltipHideDelayTimerRef.current);
621
- }
625
+ clearTimeoutRef(tooltipHideDelayTimerRef);
622
626
  };
623
627
  const handleHideTooltip = () => {
624
628
  if (clickable) {
@@ -631,9 +635,7 @@
631
635
  else {
632
636
  handleShow(false);
633
637
  }
634
- if (tooltipShowDelayTimerRef.current) {
635
- clearTimeout(tooltipShowDelayTimerRef.current);
636
- }
638
+ clearTimeoutRef(tooltipShowDelayTimerRef);
637
639
  };
638
640
  const handleTooltipPosition = ({ x, y }) => {
639
641
  var _a;
@@ -694,9 +696,7 @@
694
696
  return;
695
697
  }
696
698
  handleShow(false);
697
- if (tooltipShowDelayTimerRef.current) {
698
- clearTimeout(tooltipShowDelayTimerRef.current);
699
- }
699
+ clearTimeoutRef(tooltipShowDelayTimerRef);
700
700
  };
701
701
  // debounce handler to prevent call twice when
702
702
  // mouse enter and focus events being triggered toggether
@@ -834,7 +834,7 @@
834
834
  }
835
835
  handleHideTooltip();
836
836
  };
837
- const regularEvents = ['mouseenter', 'mouseleave', 'focus', 'blur'];
837
+ const regularEvents = ['mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'focus', 'blur'];
838
838
  const clickEvents = ['click', 'dblclick', 'mousedown', 'mouseup'];
839
839
  Object.entries(actualOpenEvents).forEach(([event, enabled]) => {
840
840
  if (!enabled) {
@@ -980,12 +980,8 @@
980
980
  setRendered(false);
981
981
  handleShow(false);
982
982
  setActiveAnchor(null);
983
- if (tooltipShowDelayTimerRef.current) {
984
- clearTimeout(tooltipShowDelayTimerRef.current);
985
- }
986
- if (tooltipHideDelayTimerRef.current) {
987
- clearTimeout(tooltipHideDelayTimerRef.current);
988
- }
983
+ clearTimeoutRef(tooltipShowDelayTimerRef);
984
+ clearTimeoutRef(tooltipHideDelayTimerRef);
989
985
  return true;
990
986
  }
991
987
  return false;
@@ -1064,12 +1060,8 @@
1064
1060
  handleShow(true);
1065
1061
  }
1066
1062
  return () => {
1067
- if (tooltipShowDelayTimerRef.current) {
1068
- clearTimeout(tooltipShowDelayTimerRef.current);
1069
- }
1070
- if (tooltipHideDelayTimerRef.current) {
1071
- clearTimeout(tooltipHideDelayTimerRef.current);
1072
- }
1063
+ clearTimeoutRef(tooltipShowDelayTimerRef);
1064
+ clearTimeoutRef(tooltipHideDelayTimerRef);
1073
1065
  };
1074
1066
  }, []);
1075
1067
  React.useEffect(() => {
@@ -1092,7 +1084,11 @@
1092
1084
  }, [id, anchorSelect, imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.anchorSelect]);
1093
1085
  React.useEffect(() => {
1094
1086
  if (tooltipShowDelayTimerRef.current) {
1095
- clearTimeout(tooltipShowDelayTimerRef.current);
1087
+ /**
1088
+ * if the delay changes while the tooltip is waiting to show,
1089
+ * reset the timer with the new delay
1090
+ */
1091
+ clearTimeoutRef(tooltipShowDelayTimerRef);
1096
1092
  handleShowTooltipDelayed(delayShow);
1097
1093
  }
1098
1094
  }, [delayShow]);
@@ -1133,9 +1129,7 @@
1133
1129
  isOpen: Boolean(rendered && !hidden && actualContent && canShow),
1134
1130
  }));
1135
1131
  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) => {
1136
- if (missedTransitionTimerRef.current) {
1137
- clearTimeout(missedTransitionTimerRef.current);
1138
- }
1132
+ clearTimeoutRef(missedTransitionTimerRef);
1139
1133
  if (show || event.propertyName !== 'opacity') {
1140
1134
  return;
1141
1135
  }