import { TooltipContentProps } from '@ui/components/shadcn/ui/tooltip' import { Fragment, type ReactNode } from 'react' import { KeyboardShortcut, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { hotkeyToKeys } from '@/state/shortcuts/formatShortcut' import { SHORTCUT_DEFINITIONS, type ShortcutId } from '@/state/shortcuts/registry' interface ShortcutTooltipProps { shortcutId: ShortcutId children: ReactNode side?: TooltipContentProps['side'] align?: TooltipContentProps['align'] sideOffset?: number delayDuration?: number /** * Override the label from the registry. Use when the wrapped element's * action is a narrower/contextual variant of the registered shortcut. */ label?: string /** * Controlled open state for the tooltip. Pass `false` to force the tooltip * closed (e.g. while a popover or dialog opened by the wrapped element is * visible). Leave `undefined` for default uncontrolled behavior. */ open?: boolean } /** * Wraps any element to show its bound keyboard shortcut on hover/focus, in the * style of Linear's shortcut tooltips: `"