import * as React from 'react' import * as TooltipPrimitive from '@radix-ui/react-tooltip' import { cn } from '@/lib/utils' const TooltipProvider = TooltipPrimitive.Provider const Tooltip = TooltipPrimitive.Root const TooltipTrigger = TooltipPrimitive.Trigger const processTooltipContent = (content: string) => { if (typeof content !== 'string') return content return (
{content}
) } const TooltipContent = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef & { side?: 'top' | 'right' | 'bottom' | 'left' align?: 'start' | 'center' | 'end' } >(({ className, side = 'left', align = 'start', children, ...props }, ref) => { const contentRef = React.useRef(null); React.useEffect(() => { if (contentRef.current) { contentRef.current.scrollTop = 0; } }, [children]); return ( {typeof children === 'string' ? processTooltipContent(children) : children} ); }) TooltipContent.displayName = TooltipPrimitive.Content.displayName export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }