@loomhq/lens 10.53.1 → 10.54.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.
@@ -0,0 +1,2 @@
1
+ export default SvgBellOff;
2
+ declare function SvgBellOff(props: any): JSX.Element;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ function SvgBellOff(props) {
3
+ return (React.createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: "none" }, props),
4
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M7.575 3.875A6.401 6.401 0 0118.502 8.4c0 3.003.643 4.86 1.229 5.935.294.54.58.892.776 1.099a2.618 2.618 0 00.263.243v.001a1 1 0 01-.567 1.823H4a1 1 0 01-.568-1.823h.001l.043-.034c.045-.038.122-.106.22-.21.196-.207.482-.56.776-1.1.586-1.074 1.228-2.93 1.228-5.934 0-1.698.675-3.326 1.875-4.526zM6.11 15.502h11.983a8.219 8.219 0 01-.118-.209c-.765-1.4-1.473-3.594-1.473-6.892a4.401 4.401 0 00-8.801 0c0 3.298-.709 5.491-1.473 6.892a8.57 8.57 0 01-.118.21zM10.042 19.238a1 1 0 011.367.363.8.8 0 001.385 0 1 1 0 011.73 1.004 2.8 2.8 0 01-4.845 0 1 1 0 01.363-1.367z", fill: "currentColor" }),
5
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.29289 2.29289C2.68342 1.90237 3.31658 1.90237 3.70711 2.29289L22.0404 20.6262C22.431 21.0167 22.431 21.6499 22.0404 22.0404C21.6499 22.431 21.0167 22.431 20.6262 22.0404L2.29289 3.70711C1.90237 3.31658 1.90237 2.68342 2.29289 2.29289Z", fill: "currentColor" })));
6
+ }
7
+ export default SvgBellOff;
@@ -21,6 +21,8 @@ export { default as SvgReplay5 } from "./replay-5.js";
21
21
  export { default as SvgBack5 } from "./back5.js";
22
22
  export { default as SvgForward5 } from "./forward-5.js";
23
23
  export { default as SvgBarChart } from "./bar-chart.js";
24
+ export { default as SvgBell } from "./bell.js";
25
+ export { default as SvgBellOff } from "./bell-off.js";
24
26
  export { default as SvgBlur } from "./blur.js";
25
27
  export { default as SvgBorderColor } from "./border-color.js";
26
28
  export { default as SvgBulb } from "./bulb.js";
@@ -226,4 +228,3 @@ export { default as SvgPictureInPicture } from "./picture-in-picture.js";
226
228
  export { default as SvgFolderPlus } from "./folder-plus.js";
227
229
  export { default as SvgPower } from "./power.js";
228
230
  export { default as SvgReplay } from "./replay.js";
229
- export { default as SvgBell } from "./bell.js";
@@ -21,6 +21,8 @@ export { default as SvgReplay5 } from './replay-5.js';
21
21
  export { default as SvgBack5 } from './back5.js';
22
22
  export { default as SvgForward5 } from './forward-5.js';
23
23
  export { default as SvgBarChart } from './bar-chart.js';
24
+ export { default as SvgBell } from './bell.js';
25
+ export { default as SvgBellOff } from './bell-off.js';
24
26
  export { default as SvgBlur } from './blur.js';
25
27
  export { default as SvgBorderColor } from './border-color.js';
26
28
  export { default as SvgBulb } from './bulb.js';
@@ -226,4 +228,3 @@ export { default as SvgPictureInPicture } from './picture-in-picture.js';
226
228
  export { default as SvgFolderPlus } from './folder-plus.js';
227
229
  export { default as SvgPower } from './power.js';
228
230
  export { default as SvgReplay } from './replay.js';
229
- export { default as SvgBell } from './bell.js';
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  declare type DelaySpeed = 'immediate' | 'long';
3
3
  declare const TooltipBoxWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TooltipBoxProps, object>;
4
4
  export declare const TooltipBox: ({ children, maxWidth, onMouseEnter, onMouseLeave, layerProps, zIndex, ...rest }: TooltipBoxProps & React.ComponentProps<typeof TooltipBoxWrapper>) => JSX.Element;
5
- declare const Tooltip: ({ children, content, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, zIndex, verticalAlign, delay, ...rest }: TooltipProps) => JSX.Element;
5
+ declare const Tooltip: ({ children, content, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, tabIndex, zIndex, verticalAlign, delay, ...rest }: TooltipProps) => JSX.Element;
6
6
  export declare const availablePlacements: string[];
7
7
  declare type TooltipBoxProps = {
8
8
  children?: React.ReactNode;
@@ -9,13 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { useState, useRef } from 'react';
12
+ import React, { useState, useRef, useEffect } from 'react';
13
13
  import { getColorValue, getFontWeight, getRadius, getShadow, getSize, getTextSize, u, } from '../../utilities';
14
14
  import { useHover, useLayer, mergeRefs } from 'react-laag';
15
15
  import ResizeObserver from 'resize-observer-polyfill';
16
16
  import styled from '@emotion/styled';
17
17
  import { textSizes } from '../../variables';
18
- import useFocusedElement from '../../hooks/use-focused-element';
19
18
  const placements = {
20
19
  topLeft: 'top-start',
21
20
  topCenter: 'top-center',
@@ -64,17 +63,49 @@ function getInitialDelaySpeed(delay) {
64
63
  }
65
64
  }
66
65
  const Tooltip = (_a) => {
67
- var { children, content, placement = 'topCenter', keepOpen, triggerOffset = 4, maxWidth = 26, isInline = true, isDisabled, container, zIndex = 1100, verticalAlign = 'middle', delay = 'immediate' } = _a, rest = __rest(_a, ["children", "content", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "zIndex", "verticalAlign", "delay"]);
66
+ var { children, content, 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", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "tabIndex", "zIndex", "verticalAlign", "delay"]);
68
67
  const [show, hoverProps] = useHover({
69
68
  delayEnter: getInitialDelaySpeed(delay),
70
69
  delayLeave: 100,
71
70
  });
72
71
  const [isOverTooltip, setIsOverTooltip] = useState(false);
72
+ const [isOpen, setIsOpen] = useState(false);
73
73
  const focusRef = useRef();
74
- const isFocused = useFocusedElement(focusRef);
75
74
  // show the tooltip if a user has focused or hovered on it AND it is not disabled
76
- const isOpen = (content && (show || (isOverTooltip && keepOpen)) && !isDisabled) ||
77
- (content && isFocused && !isDisabled);
75
+ useEffect(() => {
76
+ const isTooltipDisabled = !content || isDisabled;
77
+ if (isTooltipDisabled) {
78
+ return;
79
+ }
80
+ if (show || (isOverTooltip && keepOpen)) {
81
+ setIsOpen(true);
82
+ }
83
+ // We have to watch this separately since hover and focus are managed separately. So, an element can be keyboard focused while another element is mouse hovered.
84
+ if (!show) {
85
+ setIsOpen(false);
86
+ }
87
+ }, [content, isDisabled, isOverTooltip, keepOpen, setIsOpen, show]);
88
+ const handleFocus = () => {
89
+ setIsOpen(true);
90
+ };
91
+ const handleBlur = () => {
92
+ setIsOpen(false);
93
+ };
94
+ useEffect(() => {
95
+ if (!isOpen) {
96
+ return;
97
+ }
98
+ const keyListener = e => {
99
+ if (e.key === 'Escape') {
100
+ e.preventDefault();
101
+ handleBlur();
102
+ }
103
+ };
104
+ window.addEventListener('keydown', keyListener);
105
+ return () => {
106
+ window.removeEventListener('keydown', keyListener);
107
+ };
108
+ }, [isOpen, setIsOpen]);
78
109
  const { layerProps, triggerProps, renderLayer } = useLayer({
79
110
  isOpen,
80
111
  placement: placements[placement],
@@ -84,7 +115,7 @@ const Tooltip = (_a) => {
84
115
  auto: true,
85
116
  });
86
117
  return (React.createElement(React.Fragment, null,
87
- React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { isInline: isInline, verticalAlign: verticalAlign, tabIndex: isDisabled ? -1 : 0, ref: mergeRefs(triggerProps.ref, focusRef) }), children),
118
+ React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef) }), children),
88
119
  isOpen &&
89
120
  renderLayer(React.createElement("div", Object.assign({}, layerProps, { style: Object.assign(Object.assign({}, layerProps.style), { zIndex }) }),
90
121
  React.createElement(TooltipBox, Object.assign({ maxWidth: maxWidth, onMouseEnter: () => setIsOverTooltip(true), onMouseLeave: () => setIsOverTooltip(false) }, rest), content)))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.53.1",
3
+ "version": "10.54.1",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",