{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tooltip",
  "title": "Tooltip",
  "author": "AniBT <https://anibt.net>",
  "description": "AniBT hint bubble: the dark tip (light in 夜樱) with a tail in its own colour, Radix behaviour, a self-providing root, and Base UI's render / delay props for shadcn's base-* sidebar.",
  "dependencies": [
    "radix-ui"
  ],
  "registryDependencies": [
    "@anibt/theme"
  ],
  "files": [
    {
      "path": "registry/anibt/ui/tooltip.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * Tooltip — the AniBT 「贴纸手账」 hint bubble.\n *\n * A's tip is the one dark thing on a light page (and the one light thing in\n * 夜樱): `--anibt-tip` under `--anibt-tip-ink`, 12/16, radius 6, the sticker\n * shadow, and a tail in its own colour pointing at the control. It names an\n * icon-only control or says one short fact; anything longer belongs in a\n * popover.\n *\n * Radix underneath, so hover, keyboard focus, Escape and the grace area all\n * behave. Compatibility with shadcn:\n * - `Tooltip` works without a `TooltipProvider` (it brings its own); put one\n *   provider around a list so its tooltips share one delay.\n * - `TooltipTrigger` takes Base UI's `render={<button …/>}` as well as\n *   `asChild`, and `TooltipProvider` / `Tooltip` take Base UI's `delay` as well\n *   as Radix's `delayDuration`, so the `base-*` sidebar keeps working.\n */\n\nconst TooltipScope = React.createContext(false)\n\ntype DelayProps = {\n  /** Radix: ms before the tip opens. Default 0. */\n  delayDuration?: number\n  /** Base UI's name for `delayDuration`. */\n  delay?: number\n}\n\nfunction TooltipProvider({\n  delayDuration,\n  delay,\n  children,\n  ...props\n}: Omit<React.ComponentProps<typeof TooltipPrimitive.Provider>, \"delayDuration\"> & DelayProps) {\n  return (\n    <TooltipScope.Provider value={true}>\n      <TooltipPrimitive.Provider\n        data-slot=\"tooltip-provider\"\n        delayDuration={delayDuration ?? delay ?? 0}\n        {...props}\n      >\n        {children}\n      </TooltipPrimitive.Provider>\n    </TooltipScope.Provider>\n  )\n}\n\nfunction Tooltip({\n  delayDuration,\n  delay,\n  ...props\n}: Omit<React.ComponentProps<typeof TooltipPrimitive.Root>, \"delayDuration\"> & DelayProps) {\n  const shared = React.useContext(TooltipScope)\n  const root = (\n    <TooltipPrimitive.Root data-slot=\"tooltip\" delayDuration={delayDuration ?? delay} {...props} />\n  )\n  // A tooltip inside a provider shares its delay; a lone one brings its own.\n  return shared ? root : <TooltipProvider>{root}</TooltipProvider>\n}\n\ntype TooltipTriggerProps = React.ComponentProps<typeof TooltipPrimitive.Trigger> & {\n  /**\n   * Base UI's form of `asChild`: the element to render as the trigger. It\n   * takes the trigger's props; `children` go inside it.\n   */\n  render?: React.ReactElement\n}\n\nfunction TooltipTrigger({ render, asChild, children, ...props }: TooltipTriggerProps) {\n  if (render) {\n    const child = children !== undefined ? React.cloneElement(render, undefined, children) : render\n    return (\n      <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...{ asChild: true }} {...props}>\n        {child}\n      </TooltipPrimitive.Trigger>\n    )\n  }\n  return (\n    <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...{ asChild: asChild }} {...props}>\n      {children}\n    </TooltipPrimitive.Trigger>\n  )\n}\n\nfunction TooltipContent({\n  className,\n  sideOffset = 6,\n  children,\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n  return (\n    <TooltipPrimitive.Portal>\n      <TooltipPrimitive.Content\n        data-slot=\"tooltip-content\"\n        sideOffset={sideOffset}\n        className={cn(\n          \"anibt-tip z-50 inline-flex w-fit max-w-[min(20rem,calc(100vw-2rem))] origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 text-balance\",\n          \"animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n          // A key cap inside the tip (`⌘K`) takes the tip's ink, not a field's.\n          \"**:data-[slot=kbd]:h-4 **:data-[slot=kbd]:min-w-4 **:data-[slot=kbd]:bg-current/15 **:data-[slot=kbd]:text-current **:data-[slot=kbd]:shadow-none\",\n          className\n        )}\n        {...props}\n      >\n        {children}\n        {/* A's tail: the tip's own colour, pointing at the control. */}\n        <TooltipPrimitive.Arrow className=\"fill-anibt-tip\" width={10} height={5} />\n      </TooltipPrimitive.Content>\n    </TooltipPrimitive.Portal>\n  )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\nexport type { TooltipTriggerProps }\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "overlay"
  ],
  "type": "registry:ui"
}