2026-08-22 02:18:27 +03:00
|
|
|
"use client"
|
|
|
|
|
|
|
|
|
|
import * as React from "react"
|
|
|
|
|
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
|
|
|
|
|
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
|
|
2026-09-25 02:26:37 +03:00
|
|
|
/**
|
|
|
|
|
* The styled tooltip (tooltip wave → subtlety round, owner 2026-09-25):
|
|
|
|
|
* a quiet dark chip, not a white slab — accent tone (the hover-chip color),
|
|
|
|
|
* 11px, minimal padding, no arrow (nothing purely decorative). Opens after
|
|
|
|
|
* a 500ms rest, so tooltips appear when you pause on a control, never in
|
|
|
|
|
* passing; disableHoverableContent means the chip is un-hoverable — the
|
|
|
|
|
* instant the cursor leaves the trigger it's gone, even mid-move onto the
|
|
|
|
|
* chip's own pixels.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** The rest delay (ms): shared by hover and focus opens. */
|
|
|
|
|
export const TOOLTIP_DELAY_MS = 500
|
|
|
|
|
|
2026-08-22 02:18:27 +03:00
|
|
|
function TooltipProvider({
|
2026-09-25 02:26:37 +03:00
|
|
|
delayDuration = TOOLTIP_DELAY_MS,
|
2026-08-22 02:18:27 +03:00
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
|
|
|
return (
|
|
|
|
|
<TooltipPrimitive.Provider
|
|
|
|
|
data-slot="tooltip-provider"
|
|
|
|
|
delayDuration={delayDuration}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Tooltip({
|
2026-09-25 02:26:37 +03:00
|
|
|
disableHoverableContent = true,
|
2026-08-22 02:18:27 +03:00
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
2026-09-25 02:26:37 +03:00
|
|
|
return (
|
|
|
|
|
<TooltipPrimitive.Root
|
|
|
|
|
data-slot="tooltip"
|
|
|
|
|
disableHoverableContent={disableHoverableContent}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
2026-08-22 02:18:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function TooltipTrigger({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
|
|
|
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function TooltipContent({
|
|
|
|
|
className,
|
2026-09-25 02:26:37 +03:00
|
|
|
sideOffset = 6,
|
2026-08-22 02:18:27 +03:00
|
|
|
children,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
|
|
|
return (
|
|
|
|
|
<TooltipPrimitive.Portal>
|
|
|
|
|
<TooltipPrimitive.Content
|
|
|
|
|
data-slot="tooltip-content"
|
|
|
|
|
sideOffset={sideOffset}
|
|
|
|
|
className={cn(
|
2026-09-25 02:26:37 +03:00
|
|
|
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-accent px-2 py-1 text-[11px] text-foreground/85 text-balance fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
2026-08-22 02:18:27 +03:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</TooltipPrimitive.Content>
|
|
|
|
|
</TooltipPrimitive.Portal>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-25 02:26:37 +03:00
|
|
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|