import * as React from "react"; import { type PropsWithChildren, createContext, useContext } from "react"; import { Popover as PopoverPrimitive, Tooltip as TooltipPrimitive, } from "radix-ui"; import { cn } from "src/lib/utils"; import { Popover, PopoverContent, PopoverTrigger } from "./popover"; function TooltipProvider({ delayDuration = 0, ...props }: React.ComponentProps) { return ( ); } function RadixTooltipRootWithProvider( props: React.ComponentProps ) { return ( ); } function BaseTooltipContent({ className, sideOffset = 0, children, ...props }: React.ComponentProps) { return ( {children} ); } // Hybrid tooltip for touch devices const TouchContext = createContext(undefined); const useTouch = () => useContext(TouchContext); function TouchProvider(props: PropsWithChildren) { const isTouch = React.useMemo( () => window.matchMedia("(pointer: coarse)").matches, [] ); return ; } type HybridTooltipProps = React.ComponentProps & React.ComponentProps; function HybridTooltip(props: HybridTooltipProps) { const isTouch = useTouch(); return isTouch ? ( ) : ( ); } type HybridTooltipTriggerProps = React.ComponentProps< typeof TooltipPrimitive.Trigger > & React.ComponentProps; function HybridTooltipTrigger(props: HybridTooltipTriggerProps) { const isTouch = useTouch(); return isTouch ? ( ) : ( ); } type HybridTooltipContentProps = React.ComponentProps< typeof TooltipPrimitive.Content > & React.ComponentProps; function HybridTooltipContent({ className, ...props }: HybridTooltipContentProps) { const isTouch = useTouch(); return isTouch ? ( ) : ( ); } export { HybridTooltip as Tooltip, HybridTooltipContent as TooltipContent, TooltipProvider, HybridTooltipTrigger as TooltipTrigger, TouchProvider, };