react-tooltip 5.30.0-beta.1263.rc.3 → 5.30.0-beta.1263.rc.4

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.
@@ -136,6 +136,10 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
136
136
  left: 'right',
137
137
  }[placement.split('-')[0]]) !== null && _b !== void 0 ? _b : 'bottom';
138
138
  /* c8 ignore end */
139
+ const borderSide = border && {
140
+ borderBottom: border,
141
+ borderRight: border,
142
+ };
139
143
  let borderWidth = 0;
140
144
  if (border) {
141
145
  const match = `${border}`.match(/(\d+)px/);
@@ -156,10 +160,8 @@ const computeTooltipPosition = async ({ elementReference = null, tooltipReferenc
156
160
  top: arrowY != null ? `${arrowY}px` : '',
157
161
  right: '',
158
162
  bottom: '',
159
- // Keep the arrow tucked under the tooltip body. When the tooltip has a
160
- // border, offset by that width, but do not draw a separate arrow border:
161
- // the rotated/clipped element cannot render that seam cleanly.
162
- [staticSide]: `-${arrowSize * 0.5 + borderWidth}px`,
163
+ ...borderSide,
164
+ [staticSide]: `-${arrowSize / 2 + borderWidth - 1}px`,
163
165
  };
164
166
  /* c8 ignore end */
165
167
  return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
@@ -293,36 +295,6 @@ const clearTimeoutRef = (ref) => {
293
295
  }
294
296
  };
295
297
 
296
- /**
297
- * Extract the width token from a CSS border shorthand so arrow styles can
298
- * reuse the same thickness as the tooltip border.
299
- */
300
- const getBorderWidth = (border) => {
301
- var _a;
302
- if (!border) {
303
- return '0px';
304
- }
305
- const match = `${border}`.match(/(\d+px)/);
306
- return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : '1px';
307
- };
308
- /**
309
- * Extract the color token from a CSS border shorthand so the arrow border/fill
310
- * can stay visually aligned with the tooltip border.
311
- */
312
- const getBorderColor = (border) => {
313
- if (!border) {
314
- return undefined;
315
- }
316
- const parts = `${border}`.trim().split(/\s+/);
317
- if (parts.length >= 3) {
318
- return parts.slice(2).join(' ');
319
- }
320
- if (parts.length === 2) {
321
- return parts[1];
322
- }
323
- return parts[0];
324
- };
325
-
326
298
  const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
327
299
  const DEFAULT_CONTEXT_DATA = {
328
300
  anchorRefs: new Set(),
@@ -421,9 +393,9 @@ const TooltipWrapper = ({ tooltipId, children, className, place, content, html,
421
393
  return (React__default["default"].createElement("span", { ref: anchorRef, className: classNames__default["default"]('react-tooltip-wrapper', className), "data-tooltip-place": place, "data-tooltip-content": content, "data-tooltip-html": html, "data-tooltip-variant": variant, "data-tooltip-offset": offset, "data-tooltip-wrapper": wrapper, "data-tooltip-events": events, "data-tooltip-position-strategy": positionStrategy, "data-tooltip-delay-show": delayShow, "data-tooltip-delay-hide": delayHide }, children));
422
394
  };
423
395
 
424
- var coreStyles = {"tooltip":"core-styles-module_tooltip__3vRRp","fixed":"core-styles-module_fixed__pcSol","arrow":"core-styles-module_arrow__cvMwQ","arrowInner":"core-styles-module_arrowInner__HNPYi","noArrow":"core-styles-module_noArrow__xock6","clickable":"core-styles-module_clickable__ZuTTB","show":"core-styles-module_show__Nt9eE","closing":"core-styles-module_closing__sGnxF"};
396
+ var coreStyles = {"tooltip":"core-styles-module_tooltip__3vRRp","fixed":"core-styles-module_fixed__pcSol","arrow":"core-styles-module_arrow__cvMwQ","content":"core-styles-module_content__BRKdB","noArrow":"core-styles-module_noArrow__xock6","clickable":"core-styles-module_clickable__ZuTTB","show":"core-styles-module_show__Nt9eE","closing":"core-styles-module_closing__sGnxF"};
425
397
 
426
- 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"};
398
+ var styles = {"tooltip":"styles-module_tooltip__mnnfp","content":"styles-module_content__ydYdI","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"};
427
399
 
428
400
  const Tooltip = ({
429
401
  // props
@@ -453,9 +425,6 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, previousAc
453
425
  const hoveringTooltip = React.useRef(false);
454
426
  const [anchorsBySelect, setAnchorsBySelect] = React.useState([]);
455
427
  const mounted = React.useRef(false);
456
- const arrowBorderWidth = getBorderWidth(border);
457
- const arrowBorderColor = getBorderColor(border);
458
- const arrowBackground = border && arrowBorderColor ? arrowBorderColor : (arrowColor !== null && arrowColor !== void 0 ? arrowColor : 'var(--rt-tooltip-background)');
459
428
  /**
460
429
  * @todo Update when deprecated stuff gets removed.
461
430
  */
@@ -1215,15 +1184,14 @@ content, contentWrapperRef, isOpen, defaultIsOpen = false, setIsOpen, previousAc
1215
1184
  ...computedPosition.tooltipStyles,
1216
1185
  opacity: opacity !== undefined && canShow ? opacity : undefined,
1217
1186
  }, ref: tooltipRef },
1218
- actualContent,
1187
+ React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-content-wrapper', coreStyles['content'], styles['content']) }, actualContent),
1219
1188
  React__default["default"].createElement(WrapperElement, { className: classNames__default["default"]('react-tooltip-arrow', coreStyles['arrow'], styles['arrow'], classNameArrow, noArrow && coreStyles['noArrow']), style: {
1220
1189
  ...computedPosition.tooltipArrowStyles,
1190
+ background: arrowColor
1191
+ ? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
1192
+ : undefined,
1221
1193
  '--rt-arrow-size': `${arrowSize}px`,
1222
- '--rt-arrow-background': arrowBackground,
1223
- '--rt-arrow-border-width': arrowBorderColor ? arrowBorderWidth : '0px',
1224
- '--rt-arrow-border-color': arrowBorderColor,
1225
- }, ref: tooltipArrowRef },
1226
- React__default["default"].createElement(WrapperElement, { className: coreStyles['arrowInner'] })))) : null;
1194
+ }, ref: tooltipArrowRef }))) : null;
1227
1195
  };
1228
1196
 
1229
1197
  /* eslint-disable react/no-danger */
@@ -1551,16 +1519,15 @@ const TooltipCoreStyles = `:root {
1551
1519
 
1552
1520
  .core-styles-module_arrow__cvMwQ {
1553
1521
  position: absolute;
1522
+ background: inherit;
1554
1523
  z-index: -1;
1555
- clip-path: polygon(0% 100%, 100% 0%, 100% 100%);
1556
- background: var(--rt-arrow-border-color, var(--rt-arrow-background));
1557
- overflow: hidden;
1524
+ -webkit-backface-visibility: hidden;
1525
+ backface-visibility: hidden;
1558
1526
  }
1559
1527
 
1560
- .core-styles-module_arrowInner__HNPYi {
1561
- position: absolute;
1562
- inset: var(--rt-arrow-border-width, 0px);
1563
- background: var(--rt-arrow-background);
1528
+ .core-styles-module_content__BRKdB {
1529
+ position: relative;
1530
+ z-index: 1;
1564
1531
  }
1565
1532
 
1566
1533
  .core-styles-module_noArrow__xock6 {
@@ -1585,12 +1552,17 @@ const TooltipCoreStyles = `:root {
1585
1552
  const TooltipStyles = `
1586
1553
 
1587
1554
  .styles-module_tooltip__mnnfp {
1588
- padding: 8px 16px;
1589
1555
  border-radius: 3px;
1590
1556
  font-size: 90%;
1591
1557
  width: max-content;
1592
1558
  }
1593
1559
 
1560
+ .styles-module_content__ydYdI {
1561
+ background: inherit;
1562
+ border-radius: inherit;
1563
+ padding: 8px 16px;
1564
+ }
1565
+
1594
1566
  .styles-module_arrow__K0L3T {
1595
1567
  width: var(--rt-arrow-size);
1596
1568
  height: var(--rt-arrow-size);
@@ -1614,38 +1586,32 @@ const TooltipStyles = `
1614
1586
 
1615
1587
  /** Types variant **/
1616
1588
  .styles-module_dark__xNqje {
1617
- --rt-tooltip-background: var(--rt-color-dark);
1618
- background: var(--rt-tooltip-background);
1589
+ background: var(--rt-color-dark);
1619
1590
  color: var(--rt-color-white);
1620
1591
  }
1621
1592
 
1622
1593
  .styles-module_light__Z6W-X {
1623
- --rt-tooltip-background: var(--rt-color-white);
1624
- background-color: var(--rt-tooltip-background);
1594
+ background-color: var(--rt-color-white);
1625
1595
  color: var(--rt-color-dark);
1626
1596
  }
1627
1597
 
1628
1598
  .styles-module_success__A2AKt {
1629
- --rt-tooltip-background: var(--rt-color-success);
1630
- background-color: var(--rt-tooltip-background);
1599
+ background-color: var(--rt-color-success);
1631
1600
  color: var(--rt-color-white);
1632
1601
  }
1633
1602
 
1634
1603
  .styles-module_warning__SCK0X {
1635
- --rt-tooltip-background: var(--rt-color-warning);
1636
- background-color: var(--rt-tooltip-background);
1604
+ background-color: var(--rt-color-warning);
1637
1605
  color: var(--rt-color-white);
1638
1606
  }
1639
1607
 
1640
1608
  .styles-module_error__JvumD {
1641
- --rt-tooltip-background: var(--rt-color-error);
1642
- background-color: var(--rt-tooltip-background);
1609
+ background-color: var(--rt-color-error);
1643
1610
  color: var(--rt-color-white);
1644
1611
  }
1645
1612
 
1646
1613
  .styles-module_info__BWdHW {
1647
- --rt-tooltip-background: var(--rt-color-info);
1648
- background-color: var(--rt-tooltip-background);
1614
+ background-color: var(--rt-color-info);
1649
1615
  color: var(--rt-color-white);
1650
1616
  }
1651
1617
  `;