Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-tooltip

Package Overview
Dependencies
Maintainers
6
Versions
264
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-tooltip - npm Package Compare versions

Comparing version 1.0.8-rc.9 to 1.1.0-rc.1

72

dist/index.d.ts

@@ -1,8 +0,20 @@

import * as React from "react";
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
import * as PopperPrimitive from "@radix-ui/react-popper";
import { Portal as _Portal1 } from "@radix-ui/react-portal";
import * as Radix from "@radix-ui/react-primitive";
import { Primitive } from "@radix-ui/react-primitive";
export const createTooltipScope: import("@radix-ui/react-context").CreateScope;
import * as React from 'react';
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
import * as PopperPrimitive from '@radix-ui/react-popper';
import { Portal as Portal$1 } from '@radix-ui/react-portal';
import * as Radix from '@radix-ui/react-primitive';
import { Primitive } from '@radix-ui/react-primitive';
declare type Scope<C = any> = {
[scopeName: string]: React.Context<C>[];
} | undefined;
declare type ScopeHook = (scope: Scope) => {
[__scopeProp: string]: Scope;
};
interface CreateScope {
scopeName: string;
(): ScopeHook;
}
declare const createTooltipScope: CreateScope;
interface TooltipProviderProps {

@@ -26,4 +38,4 @@ children: React.ReactNode;

}
export const TooltipProvider: React.FC<TooltipProviderProps>;
export interface TooltipProps {
declare const TooltipProvider: React.FC<TooltipProviderProps>;
interface TooltipProps {
children?: React.ReactNode;

@@ -45,9 +57,9 @@ open?: boolean;

}
export const Tooltip: React.FC<TooltipProps>;
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
export interface TooltipTriggerProps extends PrimitiveButtonProps {
declare const Tooltip: React.FC<TooltipProps>;
declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
interface TooltipTriggerProps extends PrimitiveButtonProps {
}
export const TooltipTrigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
type PortalProps = React.ComponentPropsWithoutRef<typeof _Portal1>;
export interface TooltipPortalProps {
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
declare type PortalProps = React.ComponentPropsWithoutRef<typeof Portal$1>;
interface TooltipPortalProps {
children?: React.ReactNode;

@@ -64,4 +76,4 @@ /**

}
export const TooltipPortal: React.FC<TooltipPortalProps>;
export interface TooltipContentProps extends TooltipContentImplProps {
declare const TooltipPortal: React.FC<TooltipPortalProps>;
interface TooltipContentProps extends TooltipContentImplProps {
/**

@@ -73,5 +85,5 @@ * Used to force mounting when more control is needed. Useful when

}
export const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;
type PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
declare const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
declare type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;
declare type PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
interface TooltipContentImplProps extends Omit<PopperContentProps, 'onPlaced'> {

@@ -93,13 +105,13 @@ /**

}
type PopperArrowProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;
export interface TooltipArrowProps extends PopperArrowProps {
declare type PopperArrowProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;
interface TooltipArrowProps extends PopperArrowProps {
}
export const TooltipArrow: React.ForwardRefExoticComponent<TooltipArrowProps & React.RefAttributes<SVGSVGElement>>;
export const Provider: React.FC<TooltipProviderProps>;
export const Root: React.FC<TooltipProps>;
export const Trigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
export const Portal: React.FC<TooltipPortalProps>;
export const Content: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
export const Arrow: React.ForwardRefExoticComponent<TooltipArrowProps & React.RefAttributes<SVGSVGElement>>;
declare const TooltipArrow: React.ForwardRefExoticComponent<TooltipArrowProps & React.RefAttributes<SVGSVGElement>>;
declare const Provider: React.FC<TooltipProviderProps>;
declare const Root: React.FC<TooltipProps>;
declare const Trigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
declare const Portal: React.FC<TooltipPortalProps>;
declare const Content: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
declare const Arrow: React.ForwardRefExoticComponent<TooltipArrowProps & React.RefAttributes<SVGSVGElement>>;
//# sourceMappingURL=index.d.ts.map
export { Arrow, Content, Portal, Provider, Root, Tooltip, TooltipArrow, type TooltipArrowProps, TooltipContent, type TooltipContentProps, TooltipPortal, type TooltipPortalProps, type TooltipProps, TooltipProvider, TooltipTrigger, type TooltipTriggerProps, Trigger, createTooltipScope };

@@ -1,451 +0,388 @@

var $iVrL9$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
var $iVrL9$react = require("react");
var $iVrL9$radixuiprimitive = require("@radix-ui/primitive");
var $iVrL9$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
var $iVrL9$radixuireactcontext = require("@radix-ui/react-context");
var $iVrL9$radixuireactdismissablelayer = require("@radix-ui/react-dismissable-layer");
var $iVrL9$radixuireactid = require("@radix-ui/react-id");
var $iVrL9$radixuireactpopper = require("@radix-ui/react-popper");
var $iVrL9$radixuireactportal = require("@radix-ui/react-portal");
var $iVrL9$radixuireactpresence = require("@radix-ui/react-presence");
var $iVrL9$radixuireactprimitive = require("@radix-ui/react-primitive");
var $iVrL9$radixuireactslot = require("@radix-ui/react-slot");
var $iVrL9$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
var $iVrL9$radixuireactvisuallyhidden = require("@radix-ui/react-visually-hidden");
"use strict";
(() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "createTooltipScope", () => $c34afbc43c90cc6f$export$1c540a2224f0d865);
$parcel$export(module.exports, "TooltipProvider", () => $c34afbc43c90cc6f$export$f78649fb9ca566b8);
$parcel$export(module.exports, "Tooltip", () => $c34afbc43c90cc6f$export$28c660c63b792dea);
$parcel$export(module.exports, "TooltipTrigger", () => $c34afbc43c90cc6f$export$8c610744efcf8a1d);
$parcel$export(module.exports, "TooltipPortal", () => $c34afbc43c90cc6f$export$7b36b8f925ab7497);
$parcel$export(module.exports, "TooltipContent", () => $c34afbc43c90cc6f$export$e9003e2be37ec060);
$parcel$export(module.exports, "TooltipArrow", () => $c34afbc43c90cc6f$export$c27ee0ad710f7559);
$parcel$export(module.exports, "Provider", () => $c34afbc43c90cc6f$export$2881499e37b75b9a);
$parcel$export(module.exports, "Root", () => $c34afbc43c90cc6f$export$be92b6f5f03c0fe9);
$parcel$export(module.exports, "Trigger", () => $c34afbc43c90cc6f$export$41fb9f06171c75f4);
$parcel$export(module.exports, "Portal", () => $c34afbc43c90cc6f$export$602eac185826482c);
$parcel$export(module.exports, "Content", () => $c34afbc43c90cc6f$export$7c6e2c02157bb7d2);
$parcel$export(module.exports, "Arrow", () => $c34afbc43c90cc6f$export$21b07c8f274aebd5);
const [$c34afbc43c90cc6f$var$createTooltipContext, $c34afbc43c90cc6f$export$1c540a2224f0d865] = $iVrL9$radixuireactcontext.createContextScope('Tooltip', [
$iVrL9$radixuireactpopper.createPopperScope
]);
const $c34afbc43c90cc6f$var$usePopperScope = $iVrL9$radixuireactpopper.createPopperScope();
/* -------------------------------------------------------------------------------------------------
* TooltipProvider
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$PROVIDER_NAME = 'TooltipProvider';
const $c34afbc43c90cc6f$var$DEFAULT_DELAY_DURATION = 700;
const $c34afbc43c90cc6f$var$TOOLTIP_OPEN = 'tooltip.open';
const [$c34afbc43c90cc6f$var$TooltipProviderContextProvider, $c34afbc43c90cc6f$var$useTooltipProviderContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$PROVIDER_NAME);
const $c34afbc43c90cc6f$export$f78649fb9ca566b8 = (props)=>{
const { __scopeTooltip: __scopeTooltip , delayDuration: delayDuration = $c34afbc43c90cc6f$var$DEFAULT_DELAY_DURATION , skipDelayDuration: skipDelayDuration = 300 , disableHoverableContent: disableHoverableContent = false , children: children } = props;
const [isOpenDelayed, setIsOpenDelayed] = $iVrL9$react.useState(true);
const isPointerInTransitRef = $iVrL9$react.useRef(false);
const skipDelayTimerRef = $iVrL9$react.useRef(0);
$iVrL9$react.useEffect(()=>{
const skipDelayTimer = skipDelayTimerRef.current;
return ()=>window.clearTimeout(skipDelayTimer)
;
// packages/react/tooltip/src/Tooltip.tsx
var React = __toESM(__require("react"));
var import_primitive = __require("@radix-ui/primitive");
var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
var import_react_context = __require("@radix-ui/react-context");
var import_react_dismissable_layer = __require("@radix-ui/react-dismissable-layer");
var import_react_id = __require("@radix-ui/react-id");
var PopperPrimitive = __toESM(__require("@radix-ui/react-popper"));
var import_react_popper = __require("@radix-ui/react-popper");
var import_react_portal = __require("@radix-ui/react-portal");
var import_react_presence = __require("@radix-ui/react-presence");
var import_react_primitive = __require("@radix-ui/react-primitive");
var import_react_slot = __require("@radix-ui/react-slot");
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
var VisuallyHiddenPrimitive = __toESM(__require("@radix-ui/react-visually-hidden"));
var import_jsx_runtime = __require("react/jsx-runtime");
var [createTooltipContext, createTooltipScope] = (0, import_react_context.createContextScope)("Tooltip", [
import_react_popper.createPopperScope
]);
var usePopperScope = (0, import_react_popper.createPopperScope)();
var PROVIDER_NAME = "TooltipProvider";
var DEFAULT_DELAY_DURATION = 700;
var TOOLTIP_OPEN = "tooltip.open";
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
var TooltipProvider = (props) => {
const {
__scopeTooltip,
delayDuration = DEFAULT_DELAY_DURATION,
skipDelayDuration = 300,
disableHoverableContent = false,
children
} = props;
const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
const isPointerInTransitRef = React.useRef(false);
const skipDelayTimerRef = React.useRef(0);
React.useEffect(() => {
const skipDelayTimer = skipDelayTimerRef.current;
return () => window.clearTimeout(skipDelayTimer);
}, []);
return /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipProviderContextProvider, {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
TooltipProviderContextProvider,
{
scope: __scopeTooltip,
isOpenDelayed: isOpenDelayed,
delayDuration: delayDuration,
onOpen: $iVrL9$react.useCallback(()=>{
window.clearTimeout(skipDelayTimerRef.current);
setIsOpenDelayed(false);
isOpenDelayed,
delayDuration,
onOpen: React.useCallback(() => {
window.clearTimeout(skipDelayTimerRef.current);
setIsOpenDelayed(false);
}, []),
onClose: $iVrL9$react.useCallback(()=>{
window.clearTimeout(skipDelayTimerRef.current);
skipDelayTimerRef.current = window.setTimeout(()=>setIsOpenDelayed(true)
, skipDelayDuration);
}, [
onClose: React.useCallback(() => {
window.clearTimeout(skipDelayTimerRef.current);
skipDelayTimerRef.current = window.setTimeout(
() => setIsOpenDelayed(true),
skipDelayDuration
]),
isPointerInTransitRef: isPointerInTransitRef,
onPointerInTransitChange: $iVrL9$react.useCallback((inTransit)=>{
isPointerInTransitRef.current = inTransit;
);
}, [skipDelayDuration]),
isPointerInTransitRef,
onPointerInTransitChange: React.useCallback((inTransit) => {
isPointerInTransitRef.current = inTransit;
}, []),
disableHoverableContent: disableHoverableContent
}, children);
};
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$f78649fb9ca566b8, {
displayName: $c34afbc43c90cc6f$var$PROVIDER_NAME
});
/* -------------------------------------------------------------------------------------------------
* Tooltip
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$TOOLTIP_NAME = 'Tooltip';
const [$c34afbc43c90cc6f$var$TooltipContextProvider, $c34afbc43c90cc6f$var$useTooltipContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$TOOLTIP_NAME);
const $c34afbc43c90cc6f$export$28c660c63b792dea = (props)=>{
const { __scopeTooltip: __scopeTooltip , children: children , open: openProp , defaultOpen: defaultOpen = false , onOpenChange: onOpenChange , disableHoverableContent: disableHoverableContentProp , delayDuration: delayDurationProp } = props;
const providerContext = $c34afbc43c90cc6f$var$useTooltipProviderContext($c34afbc43c90cc6f$var$TOOLTIP_NAME, props.__scopeTooltip);
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
const [trigger, setTrigger] = $iVrL9$react.useState(null);
const contentId = $iVrL9$radixuireactid.useId();
const openTimerRef = $iVrL9$react.useRef(0);
const disableHoverableContent = disableHoverableContentProp !== null && disableHoverableContentProp !== void 0 ? disableHoverableContentProp : providerContext.disableHoverableContent;
const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : providerContext.delayDuration;
const wasOpenDelayedRef = $iVrL9$react.useRef(false);
const [open1 = false, setOpen] = $iVrL9$radixuireactusecontrollablestate.useControllableState({
prop: openProp,
defaultProp: defaultOpen,
onChange: (open)=>{
if (open) {
providerContext.onOpen(); // as `onChange` is called within a lifecycle method we
// avoid dispatching via `dispatchDiscreteCustomEvent`.
document.dispatchEvent(new CustomEvent($c34afbc43c90cc6f$var$TOOLTIP_OPEN));
} else providerContext.onClose();
onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
disableHoverableContent,
children
}
);
};
TooltipProvider.displayName = PROVIDER_NAME;
var TOOLTIP_NAME = "Tooltip";
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
var Tooltip = (props) => {
const {
__scopeTooltip,
children,
open: openProp,
defaultOpen = false,
onOpenChange,
disableHoverableContent: disableHoverableContentProp,
delayDuration: delayDurationProp
} = props;
const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
const popperScope = usePopperScope(__scopeTooltip);
const [trigger, setTrigger] = React.useState(null);
const contentId = (0, import_react_id.useId)();
const openTimerRef = React.useRef(0);
const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
const delayDuration = delayDurationProp ?? providerContext.delayDuration;
const wasOpenDelayedRef = React.useRef(false);
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
prop: openProp,
defaultProp: defaultOpen,
onChange: (open2) => {
if (open2) {
providerContext.onOpen();
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
} else {
providerContext.onClose();
}
onOpenChange?.(open2);
}
});
const stateAttribute = $iVrL9$react.useMemo(()=>{
return open1 ? wasOpenDelayedRef.current ? 'delayed-open' : 'instant-open' : 'closed';
}, [
open1
]);
const handleOpen = $iVrL9$react.useCallback(()=>{
window.clearTimeout(openTimerRef.current);
wasOpenDelayedRef.current = false;
const stateAttribute = React.useMemo(() => {
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
}, [open]);
const handleOpen = React.useCallback(() => {
window.clearTimeout(openTimerRef.current);
wasOpenDelayedRef.current = false;
setOpen(true);
}, [setOpen]);
const handleClose = React.useCallback(() => {
window.clearTimeout(openTimerRef.current);
setOpen(false);
}, [setOpen]);
const handleDelayedOpen = React.useCallback(() => {
window.clearTimeout(openTimerRef.current);
openTimerRef.current = window.setTimeout(() => {
wasOpenDelayedRef.current = true;
setOpen(true);
}, [
setOpen
]);
const handleClose = $iVrL9$react.useCallback(()=>{
window.clearTimeout(openTimerRef.current);
setOpen(false);
}, [
setOpen
]);
const handleDelayedOpen = $iVrL9$react.useCallback(()=>{
window.clearTimeout(openTimerRef.current);
openTimerRef.current = window.setTimeout(()=>{
wasOpenDelayedRef.current = true;
setOpen(true);
}, delayDuration);
}, [
delayDuration,
setOpen
]);
$iVrL9$react.useEffect(()=>{
return ()=>window.clearTimeout(openTimerRef.current)
;
}, delayDuration);
}, [delayDuration, setOpen]);
React.useEffect(() => {
return () => window.clearTimeout(openTimerRef.current);
}, []);
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Root, popperScope, /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContextProvider, {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
TooltipContextProvider,
{
scope: __scopeTooltip,
contentId: contentId,
open: open1,
stateAttribute: stateAttribute,
trigger: trigger,
contentId,
open,
stateAttribute,
trigger,
onTriggerChange: setTrigger,
onTriggerEnter: $iVrL9$react.useCallback(()=>{
if (providerContext.isOpenDelayed) handleDelayedOpen();
else handleOpen();
}, [
providerContext.isOpenDelayed,
handleDelayedOpen,
handleOpen
]),
onTriggerLeave: $iVrL9$react.useCallback(()=>{
if (disableHoverableContent) handleClose();
else // Clear the timer in case the pointer leaves the trigger before the tooltip is opened.
onTriggerEnter: React.useCallback(() => {
if (providerContext.isOpenDelayed) handleDelayedOpen();
else handleOpen();
}, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen]),
onTriggerLeave: React.useCallback(() => {
if (disableHoverableContent) {
handleClose();
} else {
window.clearTimeout(openTimerRef.current);
}, [
handleClose,
disableHoverableContent
]),
}
}, [handleClose, disableHoverableContent]),
onOpen: handleOpen,
onClose: handleClose,
disableHoverableContent: disableHoverableContent
}, children));
};
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$28c660c63b792dea, {
displayName: $c34afbc43c90cc6f$var$TOOLTIP_NAME
});
/* -------------------------------------------------------------------------------------------------
* TooltipTrigger
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$TRIGGER_NAME = 'TooltipTrigger';
const $c34afbc43c90cc6f$export$8c610744efcf8a1d = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
const { __scopeTooltip: __scopeTooltip , ...triggerProps } = props;
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$TRIGGER_NAME, __scopeTooltip);
const providerContext = $c34afbc43c90cc6f$var$useTooltipProviderContext($c34afbc43c90cc6f$var$TRIGGER_NAME, __scopeTooltip);
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
const ref = $iVrL9$react.useRef(null);
const composedRefs = $iVrL9$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref, context.onTriggerChange);
const isPointerDownRef = $iVrL9$react.useRef(false);
const hasPointerMoveOpenedRef = $iVrL9$react.useRef(false);
const handlePointerUp = $iVrL9$react.useCallback(()=>isPointerDownRef.current = false
, []);
$iVrL9$react.useEffect(()=>{
return ()=>document.removeEventListener('pointerup', handlePointerUp)
;
}, [
handlePointerUp
]);
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Anchor, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
asChild: true
}, popperScope), /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
// We purposefully avoid adding `type=button` here because tooltip triggers are also
// commonly anchors and the anchor `type` attribute signifies MIME type.
"aria-describedby": context.open ? context.contentId : undefined,
"data-state": context.stateAttribute
}, triggerProps, {
ref: composedRefs,
onPointerMove: $iVrL9$radixuiprimitive.composeEventHandlers(props.onPointerMove, (event)=>{
if (event.pointerType === 'touch') return;
disableHoverableContent,
children
}
) });
};
Tooltip.displayName = TOOLTIP_NAME;
var TRIGGER_NAME = "TooltipTrigger";
var TooltipTrigger = React.forwardRef(
(props, forwardedRef) => {
const { __scopeTooltip, ...triggerProps } = props;
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
const popperScope = usePopperScope(__scopeTooltip);
const ref = React.useRef(null);
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref, context.onTriggerChange);
const isPointerDownRef = React.useRef(false);
const hasPointerMoveOpenedRef = React.useRef(false);
const handlePointerUp = React.useCallback(() => isPointerDownRef.current = false, []);
React.useEffect(() => {
return () => document.removeEventListener("pointerup", handlePointerUp);
}, [handlePointerUp]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
"aria-describedby": context.open ? context.contentId : void 0,
"data-state": context.stateAttribute,
...triggerProps,
ref: composedRefs,
onPointerMove: (0, import_primitive.composeEventHandlers)(props.onPointerMove, (event) => {
if (event.pointerType === "touch") return;
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
context.onTriggerEnter();
hasPointerMoveOpenedRef.current = true;
context.onTriggerEnter();
hasPointerMoveOpenedRef.current = true;
}
}),
onPointerLeave: $iVrL9$radixuiprimitive.composeEventHandlers(props.onPointerLeave, ()=>{
}),
onPointerLeave: (0, import_primitive.composeEventHandlers)(props.onPointerLeave, () => {
context.onTriggerLeave();
hasPointerMoveOpenedRef.current = false;
}),
onPointerDown: $iVrL9$radixuiprimitive.composeEventHandlers(props.onPointerDown, ()=>{
}),
onPointerDown: (0, import_primitive.composeEventHandlers)(props.onPointerDown, () => {
isPointerDownRef.current = true;
document.addEventListener('pointerup', handlePointerUp, {
once: true
});
}),
onFocus: $iVrL9$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>{
document.addEventListener("pointerup", handlePointerUp, { once: true });
}),
onFocus: (0, import_primitive.composeEventHandlers)(props.onFocus, () => {
if (!isPointerDownRef.current) context.onOpen();
}),
onBlur: $iVrL9$radixuiprimitive.composeEventHandlers(props.onBlur, context.onClose),
onClick: $iVrL9$radixuiprimitive.composeEventHandlers(props.onClick, context.onClose)
})));
});
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$8c610744efcf8a1d, {
displayName: $c34afbc43c90cc6f$var$TRIGGER_NAME
});
/* -------------------------------------------------------------------------------------------------
* TooltipPortal
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$PORTAL_NAME = 'TooltipPortal';
const [$c34afbc43c90cc6f$var$PortalProvider, $c34afbc43c90cc6f$var$usePortalContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$PORTAL_NAME, {
forceMount: undefined
});
const $c34afbc43c90cc6f$export$7b36b8f925ab7497 = (props)=>{
const { __scopeTooltip: __scopeTooltip , forceMount: forceMount , children: children , container: container } = props;
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$PORTAL_NAME, __scopeTooltip);
return /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$PortalProvider, {
scope: __scopeTooltip,
forceMount: forceMount
}, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpresence.Presence, {
present: forceMount || context.open
}, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactportal.Portal, {
asChild: true,
container: container
}, children)));
};
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$7b36b8f925ab7497, {
displayName: $c34afbc43c90cc6f$var$PORTAL_NAME
});
/* -------------------------------------------------------------------------------------------------
* TooltipContent
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$CONTENT_NAME = 'TooltipContent';
const $c34afbc43c90cc6f$export$e9003e2be37ec060 = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
const portalContext = $c34afbc43c90cc6f$var$usePortalContext($c34afbc43c90cc6f$var$CONTENT_NAME, props.__scopeTooltip);
const { forceMount: forceMount = portalContext.forceMount , side: side = 'top' , ...contentProps } = props;
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$CONTENT_NAME, props.__scopeTooltip);
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpresence.Presence, {
present: forceMount || context.open
}, context.disableHoverableContent ? /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContentImpl, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
side: side
}, contentProps, {
ref: forwardedRef
})) : /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContentHoverable, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
side: side
}, contentProps, {
ref: forwardedRef
})));
});
const $c34afbc43c90cc6f$var$TooltipContentHoverable = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$CONTENT_NAME, props.__scopeTooltip);
const providerContext = $c34afbc43c90cc6f$var$useTooltipProviderContext($c34afbc43c90cc6f$var$CONTENT_NAME, props.__scopeTooltip);
const ref = $iVrL9$react.useRef(null);
const composedRefs = $iVrL9$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
const [pointerGraceArea, setPointerGraceArea] = $iVrL9$react.useState(null);
const { trigger: trigger , onClose: onClose } = context;
}),
onBlur: (0, import_primitive.composeEventHandlers)(props.onBlur, context.onClose),
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onClose)
}
) });
}
);
TooltipTrigger.displayName = TRIGGER_NAME;
var PORTAL_NAME = "TooltipPortal";
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
forceMount: void 0
});
var TooltipPortal = (props) => {
const { __scopeTooltip, forceMount, children, container } = props;
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopeTooltip, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
};
TooltipPortal.displayName = PORTAL_NAME;
var CONTENT_NAME = "TooltipContent";
var TooltipContent = React.forwardRef(
(props, forwardedRef) => {
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: context.disableHoverableContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentImpl, { side, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentHoverable, { side, ...contentProps, ref: forwardedRef }) });
}
);
var TooltipContentHoverable = React.forwardRef((props, forwardedRef) => {
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
const ref = React.useRef(null);
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
const { trigger, onClose } = context;
const content = ref.current;
const { onPointerInTransitChange: onPointerInTransitChange } = providerContext;
const handleRemoveGraceArea = $iVrL9$react.useCallback(()=>{
setPointerGraceArea(null);
onPointerInTransitChange(false);
}, [
onPointerInTransitChange
]);
const handleCreateGraceArea = $iVrL9$react.useCallback((event, hoverTarget)=>{
const { onPointerInTransitChange } = providerContext;
const handleRemoveGraceArea = React.useCallback(() => {
setPointerGraceArea(null);
onPointerInTransitChange(false);
}, [onPointerInTransitChange]);
const handleCreateGraceArea = React.useCallback(
(event, hoverTarget) => {
const currentTarget = event.currentTarget;
const exitPoint = {
x: event.clientX,
y: event.clientY
};
const exitSide = $c34afbc43c90cc6f$var$getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
const paddedExitPoints = $c34afbc43c90cc6f$var$getPaddedExitPoints(exitPoint, exitSide);
const hoverTargetPoints = $c34afbc43c90cc6f$var$getPointsFromRect(hoverTarget.getBoundingClientRect());
const graceArea = $c34afbc43c90cc6f$var$getHull([
...paddedExitPoints,
...hoverTargetPoints
]);
const exitPoint = { x: event.clientX, y: event.clientY };
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
setPointerGraceArea(graceArea);
onPointerInTransitChange(true);
}, [
onPointerInTransitChange
]);
$iVrL9$react.useEffect(()=>{
return ()=>handleRemoveGraceArea()
;
}, [
handleRemoveGraceArea
]);
$iVrL9$react.useEffect(()=>{
if (trigger && content) {
const handleTriggerLeave = (event)=>handleCreateGraceArea(event, content)
;
const handleContentLeave = (event)=>handleCreateGraceArea(event, trigger)
;
trigger.addEventListener('pointerleave', handleTriggerLeave);
content.addEventListener('pointerleave', handleContentLeave);
return ()=>{
trigger.removeEventListener('pointerleave', handleTriggerLeave);
content.removeEventListener('pointerleave', handleContentLeave);
};
},
[onPointerInTransitChange]
);
React.useEffect(() => {
return () => handleRemoveGraceArea();
}, [handleRemoveGraceArea]);
React.useEffect(() => {
if (trigger && content) {
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
trigger.addEventListener("pointerleave", handleTriggerLeave);
content.addEventListener("pointerleave", handleContentLeave);
return () => {
trigger.removeEventListener("pointerleave", handleTriggerLeave);
content.removeEventListener("pointerleave", handleContentLeave);
};
}
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
React.useEffect(() => {
if (pointerGraceArea) {
const handleTrackPointerGrace = (event) => {
const target = event.target;
const pointerPosition = { x: event.clientX, y: event.clientY };
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
if (hasEnteredTarget) {
handleRemoveGraceArea();
} else if (isPointerOutsideGraceArea) {
handleRemoveGraceArea();
onClose();
}
};
document.addEventListener("pointermove", handleTrackPointerGrace);
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
}
}, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContentImpl, { ...props, ref: composedRefs });
});
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
var TooltipContentImpl = React.forwardRef(
(props, forwardedRef) => {
const {
__scopeTooltip,
children,
"aria-label": ariaLabel,
onEscapeKeyDown,
onPointerDownOutside,
...contentProps
} = props;
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
const popperScope = usePopperScope(__scopeTooltip);
const { onClose } = context;
React.useEffect(() => {
document.addEventListener(TOOLTIP_OPEN, onClose);
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
}, [onClose]);
React.useEffect(() => {
if (context.trigger) {
const handleScroll = (event) => {
const target = event.target;
if (target?.contains(context.trigger)) onClose();
};
window.addEventListener("scroll", handleScroll, { capture: true });
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
}
}, [
trigger,
content,
handleCreateGraceArea,
handleRemoveGraceArea
]);
$iVrL9$react.useEffect(()=>{
if (pointerGraceArea) {
const handleTrackPointerGrace = (event)=>{
const target = event.target;
const pointerPosition = {
x: event.clientX,
y: event.clientY
};
const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
const isPointerOutsideGraceArea = !$c34afbc43c90cc6f$var$isPointInPolygon(pointerPosition, pointerGraceArea);
if (hasEnteredTarget) handleRemoveGraceArea();
else if (isPointerOutsideGraceArea) {
handleRemoveGraceArea();
onClose();
}, [context.trigger, onClose]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_dismissable_layer.DismissableLayer,
{
asChild: true,
disableOutsidePointerEvents: false,
onEscapeKeyDown,
onPointerDownOutside,
onFocusOutside: (event) => event.preventDefault(),
onDismiss: onClose,
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
PopperPrimitive.Content,
{
"data-state": context.stateAttribute,
...popperScope,
...contentProps,
ref: forwardedRef,
style: {
...contentProps.style,
// re-namespace exposed content custom properties
...{
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
}
};
document.addEventListener('pointermove', handleTrackPointerGrace);
return ()=>document.removeEventListener('pointermove', handleTrackPointerGrace)
;
},
children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slottable, { children }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VisuallyHiddenContentContextProvider, { scope: __scopeTooltip, isInside: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VisuallyHiddenPrimitive.Root, { id: context.contentId, role: "tooltip", children: ariaLabel || children }) })
]
}
)
}
}, [
trigger,
content,
pointerGraceArea,
onClose,
handleRemoveGraceArea
]);
return /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContentImpl, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({}, props, {
ref: composedRefs
}));
});
const [$c34afbc43c90cc6f$var$VisuallyHiddenContentContextProvider, $c34afbc43c90cc6f$var$useVisuallyHiddenContentContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$TOOLTIP_NAME, {
isInside: false
});
const $c34afbc43c90cc6f$var$TooltipContentImpl = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
const { __scopeTooltip: __scopeTooltip , children: children , 'aria-label': ariaLabel , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , ...contentProps } = props;
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$CONTENT_NAME, __scopeTooltip);
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
const { onClose: onClose } = context; // Close this tooltip if another one opens
$iVrL9$react.useEffect(()=>{
document.addEventListener($c34afbc43c90cc6f$var$TOOLTIP_OPEN, onClose);
return ()=>document.removeEventListener($c34afbc43c90cc6f$var$TOOLTIP_OPEN, onClose)
;
}, [
onClose
]); // Close the tooltip if the trigger is scrolled
$iVrL9$react.useEffect(()=>{
if (context.trigger) {
const handleScroll = (event)=>{
const target = event.target;
if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
};
window.addEventListener('scroll', handleScroll, {
capture: true
});
return ()=>window.removeEventListener('scroll', handleScroll, {
capture: true
})
;
}
}, [
context.trigger,
onClose
]);
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactdismissablelayer.DismissableLayer, {
asChild: true,
disableOutsidePointerEvents: false,
onEscapeKeyDown: onEscapeKeyDown,
onPointerDownOutside: onPointerDownOutside,
onFocusOutside: (event)=>event.preventDefault()
,
onDismiss: onClose
}, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Content, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
"data-state": context.stateAttribute
}, popperScope, contentProps, {
ref: forwardedRef,
style: {
...contentProps.style,
'--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',
'--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',
'--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',
'--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',
'--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)'
}
}), /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactslot.Slottable, null, children), /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$VisuallyHiddenContentContextProvider, {
scope: __scopeTooltip,
isInside: true
}, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactvisuallyhidden.Root, {
id: context.contentId,
role: "tooltip"
}, ariaLabel || children))));
});
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$e9003e2be37ec060, {
displayName: $c34afbc43c90cc6f$var$CONTENT_NAME
});
/* -------------------------------------------------------------------------------------------------
* TooltipArrow
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$ARROW_NAME = 'TooltipArrow';
const $c34afbc43c90cc6f$export$c27ee0ad710f7559 = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
const { __scopeTooltip: __scopeTooltip , ...arrowProps } = props;
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
const visuallyHiddenContentContext = $c34afbc43c90cc6f$var$useVisuallyHiddenContentContext($c34afbc43c90cc6f$var$ARROW_NAME, __scopeTooltip); // if the arrow is inside the `VisuallyHidden`, we don't want to render it all to
// prevent issues in positioning the arrow due to the duplicate
return visuallyHiddenContentContext.isInside ? null : /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Arrow, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({}, popperScope, arrowProps, {
ref: forwardedRef
}));
});
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$c27ee0ad710f7559, {
displayName: $c34afbc43c90cc6f$var$ARROW_NAME
});
/* -----------------------------------------------------------------------------------------------*/ function $c34afbc43c90cc6f$var$getExitSideFromRect(point, rect) {
);
}
);
TooltipContent.displayName = CONTENT_NAME;
var ARROW_NAME = "TooltipArrow";
var TooltipArrow = React.forwardRef(
(props, forwardedRef) => {
const { __scopeTooltip, ...arrowProps } = props;
const popperScope = usePopperScope(__scopeTooltip);
const visuallyHiddenContentContext = useVisuallyHiddenContentContext(
ARROW_NAME,
__scopeTooltip
);
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
}
);
TooltipArrow.displayName = ARROW_NAME;
function getExitSideFromRect(point, rect) {
const top = Math.abs(rect.top - point.y);

@@ -455,143 +392,117 @@ const bottom = Math.abs(rect.bottom - point.y);

const left = Math.abs(rect.left - point.x);
switch(Math.min(top, bottom, right, left)){
case left:
return 'left';
case right:
return 'right';
case top:
return 'top';
case bottom:
return 'bottom';
default:
throw new Error('unreachable');
switch (Math.min(top, bottom, right, left)) {
case left:
return "left";
case right:
return "right";
case top:
return "top";
case bottom:
return "bottom";
default:
throw new Error("unreachable");
}
}
function $c34afbc43c90cc6f$var$getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
}
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
const paddedExitPoints = [];
switch(exitSide){
case 'top':
paddedExitPoints.push({
x: exitPoint.x - padding,
y: exitPoint.y + padding
}, {
x: exitPoint.x + padding,
y: exitPoint.y + padding
});
break;
case 'bottom':
paddedExitPoints.push({
x: exitPoint.x - padding,
y: exitPoint.y - padding
}, {
x: exitPoint.x + padding,
y: exitPoint.y - padding
});
break;
case 'left':
paddedExitPoints.push({
x: exitPoint.x + padding,
y: exitPoint.y - padding
}, {
x: exitPoint.x + padding,
y: exitPoint.y + padding
});
break;
case 'right':
paddedExitPoints.push({
x: exitPoint.x - padding,
y: exitPoint.y - padding
}, {
x: exitPoint.x - padding,
y: exitPoint.y + padding
});
break;
switch (exitSide) {
case "top":
paddedExitPoints.push(
{ x: exitPoint.x - padding, y: exitPoint.y + padding },
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
);
break;
case "bottom":
paddedExitPoints.push(
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
{ x: exitPoint.x + padding, y: exitPoint.y - padding }
);
break;
case "left":
paddedExitPoints.push(
{ x: exitPoint.x + padding, y: exitPoint.y - padding },
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
);
break;
case "right":
paddedExitPoints.push(
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
{ x: exitPoint.x - padding, y: exitPoint.y + padding }
);
break;
}
return paddedExitPoints;
}
function $c34afbc43c90cc6f$var$getPointsFromRect(rect) {
const { top: top , right: right , bottom: bottom , left: left } = rect;
}
function getPointsFromRect(rect) {
const { top, right, bottom, left } = rect;
return [
{
x: left,
y: top
},
{
x: right,
y: top
},
{
x: right,
y: bottom
},
{
x: left,
y: bottom
}
{ x: left, y: top },
{ x: right, y: top },
{ x: right, y: bottom },
{ x: left, y: bottom }
];
} // Determine if a point is inside of a polygon.
// Based on https://github.com/substack/point-in-polygon
function $c34afbc43c90cc6f$var$isPointInPolygon(point, polygon) {
const { x: x , y: y } = point;
}
function isPointInPolygon(point, polygon) {
const { x, y } = point;
let inside = false;
for(let i = 0, j = polygon.length - 1; i < polygon.length; j = i++){
const xi = polygon[i].x;
const yi = polygon[i].y;
const xj = polygon[j].x;
const yj = polygon[j].y; // prettier-ignore
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
if (intersect) inside = !inside;
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
const xi = polygon[i].x;
const yi = polygon[i].y;
const xj = polygon[j].x;
const yj = polygon[j].y;
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
if (intersect) inside = !inside;
}
return inside;
} // Returns a new array of points representing the convex hull of the given set of points.
// https://www.nayuki.io/page/convex-hull-algorithm
function $c34afbc43c90cc6f$var$getHull(points) {
}
function getHull(points) {
const newPoints = points.slice();
newPoints.sort((a, b)=>{
if (a.x < b.x) return -1;
else if (a.x > b.x) return 1;
else if (a.y < b.y) return -1;
else if (a.y > b.y) return 1;
else return 0;
newPoints.sort((a, b) => {
if (a.x < b.x) return -1;
else if (a.x > b.x) return 1;
else if (a.y < b.y) return -1;
else if (a.y > b.y) return 1;
else return 0;
});
return $c34afbc43c90cc6f$var$getHullPresorted(newPoints);
} // Returns the convex hull, assuming that each points[i] <= points[i + 1]. Runs in O(n) time.
function $c34afbc43c90cc6f$var$getHullPresorted(points) {
return getHullPresorted(newPoints);
}
function getHullPresorted(points) {
if (points.length <= 1) return points.slice();
const upperHull = [];
for(let i = 0; i < points.length; i++){
const p = points[i];
while(upperHull.length >= 2){
const q = upperHull[upperHull.length - 1];
const r = upperHull[upperHull.length - 2];
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
else break;
}
upperHull.push(p);
for (let i = 0; i < points.length; i++) {
const p = points[i];
while (upperHull.length >= 2) {
const q = upperHull[upperHull.length - 1];
const r = upperHull[upperHull.length - 2];
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
else break;
}
upperHull.push(p);
}
upperHull.pop();
const lowerHull = [];
for(let i1 = points.length - 1; i1 >= 0; i1--){
const p = points[i1];
while(lowerHull.length >= 2){
const q = lowerHull[lowerHull.length - 1];
const r = lowerHull[lowerHull.length - 2];
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
else break;
}
lowerHull.push(p);
for (let i = points.length - 1; i >= 0; i--) {
const p = points[i];
while (lowerHull.length >= 2) {
const q = lowerHull[lowerHull.length - 1];
const r = lowerHull[lowerHull.length - 2];
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
else break;
}
lowerHull.push(p);
}
lowerHull.pop();
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
else return upperHull.concat(lowerHull);
}
const $c34afbc43c90cc6f$export$2881499e37b75b9a = $c34afbc43c90cc6f$export$f78649fb9ca566b8;
const $c34afbc43c90cc6f$export$be92b6f5f03c0fe9 = $c34afbc43c90cc6f$export$28c660c63b792dea;
const $c34afbc43c90cc6f$export$41fb9f06171c75f4 = $c34afbc43c90cc6f$export$8c610744efcf8a1d;
const $c34afbc43c90cc6f$export$602eac185826482c = $c34afbc43c90cc6f$export$7b36b8f925ab7497;
const $c34afbc43c90cc6f$export$7c6e2c02157bb7d2 = $c34afbc43c90cc6f$export$e9003e2be37ec060;
const $c34afbc43c90cc6f$export$21b07c8f274aebd5 = $c34afbc43c90cc6f$export$c27ee0ad710f7559;
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
return upperHull;
} else {
return upperHull.concat(lowerHull);
}
}
var Provider = TooltipProvider;
var Root3 = Tooltip;
var Trigger = TooltipTrigger;
var Portal = TooltipPortal;
var Content2 = TooltipContent;
var Arrow2 = TooltipArrow;
})();
//# sourceMappingURL=index.js.map
{
"name": "@radix-ui/react-tooltip",
"version": "1.0.8-rc.9",
"version": "1.1.0-rc.1",
"license": "MIT",

@@ -31,15 +31,14 @@ "exports": {

"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-dismissable-layer": "1.0.6-rc.6",
"@radix-ui/react-id": "1.0.1",
"@radix-ui/react-popper": "1.1.4-rc.9",
"@radix-ui/react-portal": "1.0.4",
"@radix-ui/react-presence": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-slot": "1.0.2",
"@radix-ui/react-use-controllable-state": "1.0.1",
"@radix-ui/react-visually-hidden": "1.0.3"
"@radix-ui/primitive": "1.1.0-rc.1",
"@radix-ui/react-compose-refs": "1.1.0-rc.1",
"@radix-ui/react-context": "1.1.0-rc.1",
"@radix-ui/react-dismissable-layer": "1.1.0-rc.1",
"@radix-ui/react-id": "1.1.0-rc.1",
"@radix-ui/react-popper": "1.2.0-rc.1",
"@radix-ui/react-portal": "1.1.0-rc.1",
"@radix-ui/react-presence": "1.1.0-rc.1",
"@radix-ui/react-primitive": "1.1.0-rc.1",
"@radix-ui/react-slot": "1.1.0-rc.1",
"@radix-ui/react-use-controllable-state": "1.1.0-rc.1",
"@radix-ui/react-visually-hidden": "1.1.0-rc.1"
},

@@ -46,0 +45,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc