@cypress-design/react-tooltip 0.6.3 → 0.7.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/index.umd.js CHANGED
@@ -60,6 +60,16 @@ function __rest(s, e) {
60
60
  t[p[i]] = s[p[i]];
61
61
  }
62
62
  return t;
63
+ }
64
+
65
+ function __spreadArray(to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
63
73
  }
64
74
 
65
75
  function getSide(placement) {
@@ -33537,21 +33547,15 @@ var ROTATE_MAP = {
33537
33547
  };
33538
33548
  var Tooltip = function (_a) {
33539
33549
  var _b;
33540
- var placement = _a.placement, _c = _a.color, color = _c === void 0 ? 'light' : _c, className = _a.className, children = _a.children, popper = _a.popper, disabled = _a.disabled, interactive = _a.interactive, forcePlacement = _a.forcePlacement, rest = __rest(_a, ["placement", "color", "className", "children", "popper", "disabled", "interactive", "forcePlacement"]);
33550
+ var placement = _a.placement, _c = _a.color, color = _c === void 0 ? 'light' : _c, className = _a.className, children = _a.children, popper = _a.popper, disabled = _a.disabled, interactive = _a.interactive, forcePlacement = _a.forcePlacement, _d = _a.forceOpen, forceOpen = _d === void 0 ? false : _d, rest = __rest(_a, ["placement", "color", "className", "children", "popper", "disabled", "interactive", "forcePlacement", "forceOpen"]);
33541
33551
  var arrowRef = React__namespace.useRef(null);
33542
- var _d = React__namespace.useState(false), open = _d[0], setOpen = _d[1];
33543
- var container = React__namespace.useState(function () {
33544
- // This will be executed only on the initial render
33545
- // https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
33546
- return document.createElement('div');
33547
- })[0];
33552
+ var _e = React__namespace.useState(false), open = _e[0], setOpen = _e[1];
33548
33553
  React__namespace.useEffect(function () {
33549
- document.body.appendChild(container);
33550
- return function () {
33551
- document.body.removeChild(container);
33552
- };
33553
- }, []);
33554
- var _e = useFloating({
33554
+ if (forceOpen) {
33555
+ setOpen(true);
33556
+ }
33557
+ }, [forceOpen]);
33558
+ var _f = useFloating({
33555
33559
  placement: placement,
33556
33560
  open: open,
33557
33561
  onOpenChange: setOpen,
@@ -33567,18 +33571,17 @@ var Tooltip = function (_a) {
33567
33571
  shift({ padding: 16 }),
33568
33572
  ],
33569
33573
  whileElementsMounted: autoUpdate,
33570
- }), x = _e.x, y = _e.y, reference = _e.reference, floating = _e.floating, strategy = _e.strategy, calculatedPlacement = _e.placement, context = _e.context, _f = _e.middlewareData.arrow, _g = _f === void 0 ? {} : _f, arrowX = _g.x, arrowY = _g.y;
33571
- var _h = useInteractions([
33574
+ }), x = _f.x, y = _f.y, reference = _f.reference, floating = _f.floating, strategy = _f.strategy, calculatedPlacement = _f.placement, context = _f.context, _g = _f.middlewareData.arrow, _h = _g === void 0 ? {} : _g, arrowX = _h.x, arrowY = _h.y;
33575
+ var _j = useInteractions(__spreadArray([
33572
33576
  useHover(context, {
33573
33577
  handleClose: interactive ? safePolygon() : undefined,
33574
- enabled: !disabled,
33578
+ enabled: !disabled && !forceOpen,
33575
33579
  }),
33576
33580
  useFocus(context, {
33577
- enabled: !disabled,
33581
+ enabled: !disabled && !forceOpen,
33578
33582
  }),
33579
- useRole(context, { role: 'tooltip' }),
33580
- useDismiss(context),
33581
- ]), getReferenceProps = _h.getReferenceProps, getFloatingProps = _h.getFloatingProps;
33583
+ useRole(context, { role: 'tooltip' })
33584
+ ], (!forceOpen ? [useDismiss(context)] : []), true)), getReferenceProps = _j.getReferenceProps, getFloatingProps = _j.getFloatingProps;
33582
33585
  var placementSide = calculatedPlacement.split('-')[0];
33583
33586
  var arrowRotate = ROTATE_MAP[placementSide];
33584
33587
  var arrowXRule = 'left', arrowYRule = 'top';
@@ -33641,4 +33644,4 @@ var Tooltip = function (_a) {
33641
33644
  module.exports = Tooltip;
33642
33645
  //# sourceMappingURL=index.umd.js.map
33643
33646
 
33644
- /* <wind-keep class="container stroke-none fill-white block text-gray-900 shadow-gray-100 border-transparent bg-white fill-gray-900 text-white shadow-gray-800 bg-gray-900 rounded shadow border invisible absolute z-10 transform filter text-[16px] leading-[24px] min-w-[160px] text-center p-[8px] relative z-20 drop-shadow"> */
33647
+ /* <wind-keep class="stroke-none fill-white block text-gray-900 shadow-gray-100 border-transparent bg-white fill-gray-900 text-white shadow-gray-800 bg-gray-900 rounded shadow border invisible absolute z-10 transform filter text-[16px] leading-[24px] min-w-[160px] text-center p-[8px] relative z-20 drop-shadow"> */