{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-tooltip",
  "type": "registry:ui",
  "title": "react-tw/tooltip.tsx",
  "description": "Carbon `Tooltip` / icon tooltip as a React + Tailwind component, the look and rules of Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [
    "@purpurabog/ui@^2.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-position",
    "@kanok-ui/tw-floating",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/tooltip.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/tooltip.tsx",
      "content": "import type { CSSProperties, ReactElement, ComponentProps } from 'react';\nimport type { Placement } from '../core/position.ts';\nimport { Tooltip as TooltipPrimitive } from '@purpurabog/ui/headless';\nimport { caretClasses } from './lib/floating.ts';\nimport { cn } from './lib/utils.ts';\n\n/**\n * Carbon `Tooltip` / icon tooltip as a React + Tailwind component, the look and rules of\n * `<ui-tooltip>` on the headless `Tooltip`: short plain-text help for the one trigger it wraps, in\n * the top layer with a caret. Opens on hover after 100ms and on keyboard focus (`:focus-visible`), closes on blur, on\n * activation (click / Enter / Space, Carbon `closeOnActivation`) and on Esc (WCAG 1.4.13; the\n * pointer can move onto the bubble). The text describes the trigger, or names it with `asLabel`\n * (an icon-only button: 8px off, 2px / 16px padding, 8×4 caret); `small` is that look while the\n * text still describes (a trigger named by its own content).\n */\nconst SHOW_DELAY = 100;\nconst HIDE_DELAY = 300; // Carbon leaveDelayMs\n\nexport interface TooltipProps extends Omit<ComponentProps<'span'>, 'text' | 'placement' | 'asLabel' | 'small' | 'open' | 'onOpenChange' | 'children' | 'className'> {\n    text: string;\n    /** top | bottom | left | right, optionally `-start` / `-end` (Carbon `align`). */\n    placement?: Placement;\n    /** The text is the trigger's accessible name (icon-only buttons) instead of its description. */\n    asLabel?: boolean;\n    /** The icon tooltip's look (as `asLabel`) while the text stays the trigger's description. */\n    small?: boolean;\n    /** Controlled visibility (e.g. \"Copied!\" kept up); hover / focus then only report through onOpenChange. */\n    open?: boolean;\n    onOpenChange?: (open: boolean) => void;\n    /** One focusable element. */\n    children: ReactElement<Record<string, unknown>>;\n    className?: string;\n}\n\nexport function Tooltip({ text, placement = 'top', asLabel, small, open, onOpenChange, children, className, ref, ...rest }: Readonly<TooltipProps>) {\n    const compact = asLabel || small;\n    return (\n        <TooltipPrimitive.Root open={open} onOpenChange={onOpenChange} label={asLabel ? text : undefined} disabled={!text} placement={placement} gap={compact ? 8 : 12} caret delay={SHOW_DELAY} closeDelay={HIDE_DELAY}>\n            <TooltipPrimitive.Trigger {...rest} ref={ref} className={cn('inline-block', className)}>\n                {children}\n                <TooltipPrimitive.Popup\n                    style={{ '--_caret-w': compact ? '8px' : '12px', '--_caret-h': compact ? '4px' : '6px' } as CSSProperties}\n                    className={cn(\n                        'group/bubble absolute inset-auto m-0 box-border w-max max-w-[288px] overflow-visible rounded-[var(--ui-tooltip-radius,var(--ui-radius-xs))] border-0 bg-inverse-surface-1 p-4 text-inverse-ink type-body-sm leading-5! [overflow-wrap:break-word]',\n                        compact && 'px-4 py-[2px] leading-[18px]!',\n                        'forced-colors:border forced-colors:border-solid forced-colors:border-[CanvasText]',\n                    )}\n                >\n                    {text}\n                    <span className={caretClasses} aria-hidden=\"true\" />\n                </TooltipPrimitive.Popup>\n            </TooltipPrimitive.Trigger>\n        </TooltipPrimitive.Root>\n    );\n}\n"
    }
  ]
}
