@mirohq/design-system-tooltip
Advanced tools
Comparing version 3.3.17 to 3.3.18-combobox.0
@@ -7,3 +7,2 @@ 'use strict'; | ||
var React = require('react'); | ||
var designSystemUseId = require('@mirohq/design-system-use-id'); | ||
var reactTooltip = require('@radix-ui/react-tooltip'); | ||
@@ -84,14 +83,11 @@ var designSystemStitches = require('@mirohq/design-system-stitches'); | ||
const Trigger = React__default["default"].forwardRef(({ onPress, onClick, ...restProps }, forwardRef) => { | ||
const { id } = React.useContext(TooltipTriggerContext); | ||
return /* @__PURE__ */ jsxRuntime.jsx( | ||
StyledTrigger, | ||
{ | ||
...restProps, | ||
onClick: onPress != null ? onPress : onClick, | ||
"data-tooltip-trigger": id, | ||
ref: forwardRef | ||
} | ||
); | ||
}); | ||
const Trigger = React__default["default"].forwardRef(({ onPress, onClick, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx( | ||
StyledTrigger, | ||
{ | ||
...restProps, | ||
onClick: onPress != null ? onPress : onClick, | ||
"data-tooltip-trigger": "", | ||
ref: forwardRef | ||
} | ||
)); | ||
Trigger.displayName = "Tooltip.Trigger"; | ||
@@ -120,3 +116,2 @@ | ||
const DEFAULT_DELAY_DURATION = 200; | ||
const TooltipTriggerContext = React.createContext({}); | ||
const Tooltip = ({ | ||
@@ -137,3 +132,2 @@ defaultOpen = false, | ||
const _skipDelayDuration = (_a = skipDelayDuration != null ? skipDelayDuration : context.skipDelayDuration) != null ? _a : DEFAULT_SKIP_DELAY_DURATION; | ||
const triggerId = designSystemUseId.useId(); | ||
const [openState, setOpenState] = React.useState(defaultOpen); | ||
@@ -145,3 +139,2 @@ const setDelayedOpen = React.useCallback( | ||
clearTimeout(skipDelayTimer); | ||
const triggerSelector = '[data-tooltip-trigger="'.concat(triggerId, '"]'); | ||
if (!newOpenState) { | ||
@@ -155,3 +148,3 @@ skipDelayTimer = setTimeout(() => { | ||
} | ||
if (shouldSkipDelay || document.querySelector("".concat(triggerSelector, ":focus")) != null) { | ||
if (shouldSkipDelay || document.querySelector("[data-tooltip-trigger]:focus") != null) { | ||
setOpenState(newOpenState); | ||
@@ -161,3 +154,3 @@ return; | ||
delayTimer = setTimeout(() => { | ||
if (document.querySelector("".concat(triggerSelector, ":hover")) == null && process.env.NODE_ENV !== "test") { | ||
if (document.querySelector("[data-tooltip-trigger]:hover") == null && process.env.NODE_ENV !== "test") { | ||
return; | ||
@@ -172,10 +165,3 @@ } | ||
}, | ||
[ | ||
delayDuration, | ||
context.delayDuration, | ||
_skipDelayDuration, | ||
onClose, | ||
onOpen, | ||
triggerId | ||
] | ||
[delayDuration, context.delayDuration, _skipDelayDuration, onClose, onOpen] | ||
); | ||
@@ -208,3 +194,3 @@ const handleOpenChange = React.useCallback( | ||
}, []); | ||
return /* @__PURE__ */ jsxRuntime.jsx(reactTooltip.Provider, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipTriggerContext.Provider, { value: { id: triggerId }, children: /* @__PURE__ */ jsxRuntime.jsx( | ||
return /* @__PURE__ */ jsxRuntime.jsx(reactTooltip.Provider, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx( | ||
reactTooltip.Root, | ||
@@ -218,3 +204,3 @@ { | ||
} | ||
) }) }); | ||
) }); | ||
}; | ||
@@ -221,0 +207,0 @@ Tooltip.Trigger = Trigger; |
import { jsxs, jsx } from 'react/jsx-runtime'; | ||
import React, { useContext, createContext, useRef, useState, useCallback, useEffect } from 'react'; | ||
import { useId } from '@mirohq/design-system-use-id'; | ||
import React, { createContext, useContext, useRef, useState, useCallback, useEffect } from 'react'; | ||
import { Arrow, Content as Content$1, Trigger as Trigger$1, Portal as Portal$1, Provider as Provider$1, Root } from '@radix-ui/react-tooltip'; | ||
@@ -75,14 +74,11 @@ import { styled } from '@mirohq/design-system-stitches'; | ||
const Trigger = React.forwardRef(({ onPress, onClick, ...restProps }, forwardRef) => { | ||
const { id } = useContext(TooltipTriggerContext); | ||
return /* @__PURE__ */ jsx( | ||
StyledTrigger, | ||
{ | ||
...restProps, | ||
onClick: onPress != null ? onPress : onClick, | ||
"data-tooltip-trigger": id, | ||
ref: forwardRef | ||
} | ||
); | ||
}); | ||
const Trigger = React.forwardRef(({ onPress, onClick, ...restProps }, forwardRef) => /* @__PURE__ */ jsx( | ||
StyledTrigger, | ||
{ | ||
...restProps, | ||
onClick: onPress != null ? onPress : onClick, | ||
"data-tooltip-trigger": "", | ||
ref: forwardRef | ||
} | ||
)); | ||
Trigger.displayName = "Tooltip.Trigger"; | ||
@@ -111,3 +107,2 @@ | ||
const DEFAULT_DELAY_DURATION = 200; | ||
const TooltipTriggerContext = createContext({}); | ||
const Tooltip = ({ | ||
@@ -128,3 +123,2 @@ defaultOpen = false, | ||
const _skipDelayDuration = (_a = skipDelayDuration != null ? skipDelayDuration : context.skipDelayDuration) != null ? _a : DEFAULT_SKIP_DELAY_DURATION; | ||
const triggerId = useId(); | ||
const [openState, setOpenState] = useState(defaultOpen); | ||
@@ -136,3 +130,2 @@ const setDelayedOpen = useCallback( | ||
clearTimeout(skipDelayTimer); | ||
const triggerSelector = '[data-tooltip-trigger="'.concat(triggerId, '"]'); | ||
if (!newOpenState) { | ||
@@ -146,3 +139,3 @@ skipDelayTimer = setTimeout(() => { | ||
} | ||
if (shouldSkipDelay || document.querySelector("".concat(triggerSelector, ":focus")) != null) { | ||
if (shouldSkipDelay || document.querySelector("[data-tooltip-trigger]:focus") != null) { | ||
setOpenState(newOpenState); | ||
@@ -152,3 +145,3 @@ return; | ||
delayTimer = setTimeout(() => { | ||
if (document.querySelector("".concat(triggerSelector, ":hover")) == null && process.env.NODE_ENV !== "test") { | ||
if (document.querySelector("[data-tooltip-trigger]:hover") == null && process.env.NODE_ENV !== "test") { | ||
return; | ||
@@ -163,10 +156,3 @@ } | ||
}, | ||
[ | ||
delayDuration, | ||
context.delayDuration, | ||
_skipDelayDuration, | ||
onClose, | ||
onOpen, | ||
triggerId | ||
] | ||
[delayDuration, context.delayDuration, _skipDelayDuration, onClose, onOpen] | ||
); | ||
@@ -199,3 +185,3 @@ const handleOpenChange = useCallback( | ||
}, []); | ||
return /* @__PURE__ */ jsx(Provider$1, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ jsx(TooltipTriggerContext.Provider, { value: { id: triggerId }, children: /* @__PURE__ */ jsx( | ||
return /* @__PURE__ */ jsx(Provider$1, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ jsx( | ||
Root, | ||
@@ -209,3 +195,3 @@ { | ||
} | ||
) }) }); | ||
) }); | ||
}; | ||
@@ -212,0 +198,0 @@ Tooltip.Trigger = Trigger; |
{ | ||
"name": "@mirohq/design-system-tooltip", | ||
"version": "3.3.17", | ||
"version": "3.3.18-combobox.0", | ||
"description": "", | ||
@@ -31,7 +31,6 @@ "author": "Miro", | ||
"@radix-ui/react-tooltip": "^1.0.3", | ||
"@mirohq/design-system-base-hotkey": "^0.1.11", | ||
"@mirohq/design-system-primitive": "^1.1.2", | ||
"@mirohq/design-system-base-hotkey": "^0.1.11", | ||
"@mirohq/design-system-styles": "^1.2.9", | ||
"@mirohq/design-system-stitches": "^2.6.10", | ||
"@mirohq/design-system-use-id": "^0.1.2", | ||
"@mirohq/design-system-styles": "^1.2.10-combobox.0", | ||
"@mirohq/design-system-utils": "^0.15.4", | ||
@@ -38,0 +37,0 @@ "@mirohq/design-tokens": "^5.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10
61144
594
2
- Removed@mirohq/design-system-use-id@^0.1.2
- Removed@mirohq/design-system-use-id@0.1.2(transitive)
- Removed@mirohq/design-system-use-layout-effect@0.2.1(transitive)