@cypress-design/react-tooltip 0.6.3 → 0.7.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.
package/dist/index.umd.js CHANGED
@@ -36,7 +36,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
36
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
37
  PERFORMANCE OF THIS SOFTWARE.
38
38
  ***************************************************************************** */
39
- /* global Reflect, Promise */
39
+ /* global Reflect, Promise, SuppressedError, Symbol */
40
40
 
41
41
 
42
42
  var __assign = function() {
@@ -60,7 +60,22 @@ function __rest(s, e) {
60
60
  t[p[i]] = s[p[i]];
61
61
  }
62
62
  return t;
63
- }
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));
73
+ }
74
+
75
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
76
+ var e = new Error(message);
77
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
78
+ };
64
79
 
65
80
  function getSide(placement) {
66
81
  return placement.split('-')[0];
@@ -33537,21 +33552,15 @@ var ROTATE_MAP = {
33537
33552
  };
33538
33553
  var Tooltip = function (_a) {
33539
33554
  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"]);
33555
+ 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
33556
  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];
33557
+ var _e = React__namespace.useState(false), open = _e[0], setOpen = _e[1];
33548
33558
  React__namespace.useEffect(function () {
33549
- document.body.appendChild(container);
33550
- return function () {
33551
- document.body.removeChild(container);
33552
- };
33553
- }, []);
33554
- var _e = useFloating({
33559
+ if (forceOpen) {
33560
+ setOpen(true);
33561
+ }
33562
+ }, [forceOpen]);
33563
+ var _f = useFloating({
33555
33564
  placement: placement,
33556
33565
  open: open,
33557
33566
  onOpenChange: setOpen,
@@ -33567,18 +33576,18 @@ var Tooltip = function (_a) {
33567
33576
  shift({ padding: 16 }),
33568
33577
  ],
33569
33578
  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([
33579
+ }), 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;
33580
+ var contextHook = useDismiss(context);
33581
+ var _j = useInteractions(__spreadArray([
33572
33582
  useHover(context, {
33573
33583
  handleClose: interactive ? safePolygon() : undefined,
33574
- enabled: !disabled,
33584
+ enabled: !disabled && !forceOpen,
33575
33585
  }),
33576
33586
  useFocus(context, {
33577
- enabled: !disabled,
33587
+ enabled: !disabled && !forceOpen,
33578
33588
  }),
33579
- useRole(context, { role: 'tooltip' }),
33580
- useDismiss(context),
33581
- ]), getReferenceProps = _h.getReferenceProps, getFloatingProps = _h.getFloatingProps;
33589
+ useRole(context, { role: 'tooltip' })
33590
+ ], (!forceOpen ? [contextHook] : []), true)), getReferenceProps = _j.getReferenceProps, getFloatingProps = _j.getFloatingProps;
33582
33591
  var placementSide = calculatedPlacement.split('-')[0];
33583
33592
  var arrowRotate = ROTATE_MAP[placementSide];
33584
33593
  var arrowXRule = 'left', arrowYRule = 'top';
@@ -33641,4 +33650,4 @@ var Tooltip = function (_a) {
33641
33650
  module.exports = Tooltip;
33642
33651
  //# sourceMappingURL=index.umd.js.map
33643
33652
 
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"> */
33653
+ /* <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"> */