@loomhq/lens 10.63.1 → 10.63.2

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.
@@ -4,7 +4,7 @@ declare const TooltipBoxWrapper: import("@emotion/styled-base").StyledComponent<
4
4
  declare const ShortcutWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement>>, object>;
5
5
  export declare const ShortcutBox: ({ children, }: React.ComponentProps<typeof ShortcutWrapper>) => JSX.Element;
6
6
  export declare const TooltipBox: ({ children, maxWidth, onMouseEnter, onMouseLeave, layerProps, zIndex, ...rest }: TooltipBoxProps & React.ComponentProps<typeof TooltipBoxWrapper>) => JSX.Element;
7
- declare const Tooltip: ({ children, content, shortcut, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, tabIndex, zIndex, verticalAlign, delay, dynamicPosition, ...rest }: TooltipProps) => JSX.Element;
7
+ declare const Tooltip: ({ children, content, shortcut, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, tabIndex, zIndex, verticalAlign, delay, ...rest }: TooltipProps) => JSX.Element;
8
8
  export declare const availablePlacements: string[];
9
9
  declare type TooltipBoxProps = {
10
10
  children?: React.ReactNode;
@@ -24,7 +24,6 @@ declare type TooltipProps = {
24
24
  keepOpen?: boolean;
25
25
  maxWidth?: number | string | [];
26
26
  placement?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'leftTop' | 'leftCenter' | 'leftBottom' | 'rightTop' | 'rightCenter' | 'rightBottom';
27
- dynamicPosition?: boolean;
28
27
  triggerOffset?: number;
29
28
  verticalAlign?: string;
30
29
  zIndex?: number;
@@ -13,11 +13,10 @@ import React, { useState, useRef, useEffect } from 'react';
13
13
  import Arrange from '../arrange/arrange';
14
14
  import Text from '../text/text';
15
15
  import { getColorValue, getFontWeight, getRadius, getShadow, getSize, getTextSize, u, } from '../../utilities';
16
- import { useHover, useLayer, mergeRefs, useMousePositionAsTrigger, } from 'react-laag';
16
+ import { useHover, useLayer, mergeRefs } from 'react-laag';
17
17
  import ResizeObserver from 'resize-observer-polyfill';
18
18
  import styled from '@emotion/styled';
19
19
  import { textSizes } from '../../variables';
20
- import { usePrefersReducedMotion } from '../../hooks/use-prefer-reduced-motion';
21
20
  const placements = {
22
21
  topLeft: 'top-start',
23
22
  topCenter: 'top-center',
@@ -82,20 +81,15 @@ function getInitialDelaySpeed(delay) {
82
81
  }
83
82
  }
84
83
  const Tooltip = (_a) => {
85
- var { children, content, shortcut, placement = 'topCenter', keepOpen, triggerOffset = 4, maxWidth = 26, isInline = true, isDisabled, container, tabIndex = 0, zIndex = 1100, verticalAlign = 'middle', delay = 'immediate', dynamicPosition = false } = _a, rest = __rest(_a, ["children", "content", "shortcut", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "tabIndex", "zIndex", "verticalAlign", "delay", "dynamicPosition"]);
84
+ var { children, content, shortcut, placement = 'topCenter', keepOpen, triggerOffset = 4, maxWidth = 26, isInline = true, isDisabled, container, tabIndex = 0, zIndex = 1100, verticalAlign = 'middle', delay = 'immediate' } = _a, rest = __rest(_a, ["children", "content", "shortcut", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "tabIndex", "zIndex", "verticalAlign", "delay"]);
86
85
  const [show, hoverProps] = useHover({
87
86
  delayEnter: getInitialDelaySpeed(delay),
88
87
  delayLeave: 200,
89
88
  });
90
- const { handleMouseEvent, trigger, parentRef } = useMousePositionAsTrigger({
91
- enabled: show,
92
- });
93
89
  const [isOverTooltip, setIsOverTooltip] = useState(false);
94
90
  const [isOpen, setIsOpen] = useState(false);
95
91
  const focusRef = useRef();
96
92
  const isTooltipDisabled = !content || isDisabled;
97
- const prefersReducedMotion = usePrefersReducedMotion();
98
- const allowTrackMousePosition = dynamicPosition && !prefersReducedMotion;
99
93
  // show the tooltip if a user has focused or hovered on it AND it is not disabled
100
94
  useEffect(() => {
101
95
  const keepTooltipOpenOnHover = isOverTooltip && keepOpen;
@@ -148,10 +142,9 @@ const Tooltip = (_a) => {
148
142
  triggerOffset,
149
143
  container,
150
144
  auto: true,
151
- trigger: allowTrackMousePosition ? trigger : null,
152
145
  });
153
146
  return (React.createElement(React.Fragment, null,
154
- React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isTooltipDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef, parentRef), onMouseMove: allowTrackMousePosition ? handleMouseEvent : null }), children),
147
+ React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isTooltipDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef) }), children),
155
148
  isOpen &&
156
149
  renderLayer(React.createElement("div", Object.assign({}, layerProps, { style: Object.assign(Object.assign({}, layerProps.style), { zIndex }) }),
157
150
  React.createElement(TooltipBox, Object.assign({ maxWidth: maxWidth, onMouseEnter: () => setIsOverTooltip(true), onMouseLeave: () => setIsOverTooltip(false) }, rest),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.63.1",
3
+ "version": "10.63.2",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",
@@ -1 +0,0 @@
1
- export function usePrefersReducedMotion(): boolean;
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- const QUERY = '(prefers-reduced-motion: no-preference)';
3
- export function usePrefersReducedMotion() {
4
- const [prefersReducedMotion, setPrefersReducedMotion] = useState(true);
5
- useEffect(() => {
6
- const mediaQueryList = window.matchMedia(QUERY);
7
- setPrefersReducedMotion(!window.matchMedia(QUERY).matches);
8
- const listener = event => {
9
- setPrefersReducedMotion(!event.matches);
10
- };
11
- mediaQueryList.addEventListener('toggle motion', listener);
12
- return () => {
13
- mediaQueryList.removeEventListener('toggle motion', listener);
14
- };
15
- }, []);
16
- return prefersReducedMotion;
17
- }