react-tooltip 5.28.1 → 5.29.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.
@@ -98,7 +98,7 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
98
98
  fallbackAxisSideDirection: 'start',
99
99
  }),
100
100
  shift({ padding: 5 }),
101
- ], border, }) => {
101
+ ], border, arrowSize = 8, }) => {
102
102
  if (!elementReference) {
103
103
  // elementReference can be null or undefined and we will not compute the position
104
104
  // eslint-disable-next-line no-console
@@ -152,7 +152,7 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
152
152
  right: '',
153
153
  bottom: '',
154
154
  ...borderSide,
155
- [staticSide]: `-${4 + borderWidth}px`,
155
+ [staticSide]: `-${arrowSize / 2 + borderWidth}px`,
156
156
  };
157
157
  /* c8 ignore end */
158
158
  return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
@@ -392,7 +392,7 @@ const Tooltip = ({
392
392
  // props
393
393
  forwardRef, 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, imperativeModeOnly, style: externalStyles, position, afterShow, afterHide, disableTooltip,
394
394
  // props handled by controller
395
- content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, role = 'tooltip', }) => {
395
+ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnchor, setActiveAnchor, border, opacity, arrowColor, arrowSize = 8, role = 'tooltip', }) => {
396
396
  var _a;
397
397
  const tooltipRef = useRef(null);
398
398
  const tooltipArrowRef = useRef(null);
@@ -653,6 +653,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
653
653
  strategy: positionStrategy,
654
654
  middlewares,
655
655
  border,
656
+ arrowSize,
656
657
  }).then((computedStylesData) => {
657
658
  handleComputedPosition(computedStylesData);
658
659
  });
@@ -740,6 +741,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
740
741
  strategy: positionStrategy,
741
742
  middlewares,
742
743
  border,
744
+ arrowSize,
743
745
  }).then((computedStylesData) => {
744
746
  if (!mounted.current) {
745
747
  // invalidate computed positions after remount
@@ -759,6 +761,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
759
761
  position,
760
762
  imperativeOptions === null || imperativeOptions === void 0 ? void 0 : imperativeOptions.position,
761
763
  float,
764
+ arrowSize,
762
765
  ]);
763
766
  useEffect(() => {
764
767
  var _a, _b;
@@ -1143,6 +1146,7 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, activeAnch
1143
1146
  background: arrowColor
1144
1147
  ? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
1145
1148
  : undefined,
1149
+ '--rt-arrow-size': `${arrowSize}px`,
1146
1150
  }, ref: tooltipArrowRef }))) : null;
1147
1151
  };
1148
1152
 
@@ -1151,7 +1155,7 @@ const TooltipContent = ({ content }) => {
1151
1155
  return React.createElement("span", { dangerouslySetInnerHTML: { __html: content } });
1152
1156
  };
1153
1157
 
1154
- const TooltipController = React.forwardRef(({ 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, imperativeModeOnly = false, style, position, isOpen, defaultIsOpen = false, disableStyleInjection = false, border, opacity, arrowColor, setIsOpen, afterShow, afterHide, disableTooltip, role = 'tooltip', }, ref) => {
1158
+ const TooltipController = React.forwardRef(({ 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, imperativeModeOnly = false, style, position, isOpen, defaultIsOpen = false, disableStyleInjection = false, border, opacity, arrowColor, arrowSize, setIsOpen, afterShow, afterHide, disableTooltip, role = 'tooltip', }, ref) => {
1155
1159
  const [tooltipContent, setTooltipContent] = useState(content);
1156
1160
  const [tooltipHtml, setTooltipHtml] = useState(html);
1157
1161
  const [tooltipPlace, setTooltipPlace] = useState(place);
@@ -1421,6 +1425,7 @@ const TooltipController = React.forwardRef(({ id, anchorId, anchorSelect, conten
1421
1425
  border,
1422
1426
  opacity,
1423
1427
  arrowColor,
1428
+ arrowSize,
1424
1429
  setIsOpen,
1425
1430
  afterShow,
1426
1431
  afterHide,
@@ -1443,6 +1448,7 @@ const TooltipCoreStyles = `:root {
1443
1448
  --rt-opacity: 0.9;
1444
1449
  --rt-transition-show-delay: 0.15s;
1445
1450
  --rt-transition-closing-delay: 0.15s;
1451
+ --rt-arrow-size: 8px;
1446
1452
  }
1447
1453
 
1448
1454
  .core-styles-module_tooltip__3vRRp {
@@ -1461,6 +1467,7 @@ const TooltipCoreStyles = `:root {
1461
1467
  .core-styles-module_arrow__cvMwQ {
1462
1468
  position: absolute;
1463
1469
  background: inherit;
1470
+ z-index: -1;
1464
1471
  }
1465
1472
 
1466
1473
  .core-styles-module_noArrow__xock6 {
@@ -1492,8 +1499,8 @@ const TooltipStyles = `
1492
1499
  }
1493
1500
 
1494
1501
  .styles-module_arrow__K0L3T {
1495
- width: 8px;
1496
- height: 8px;
1502
+ width: var(--rt-arrow-size);
1503
+ height: var(--rt-arrow-size);
1497
1504
  }
1498
1505
 
1499
1506
  [class*='react-tooltip__place-top'] > .styles-module_arrow__K0L3T {