import { MousePointerClick, X } from "lucide-react"; import { COMPOSER_INLINE_CHIP_CLASS_NAME, COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME, COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME, } from "../composerInlineChip"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; import { cn } from "~/lib/utils"; import { type ElementContextDraft, formatElementContextLabel, formatElementContextSourceLabel, } from "~/lib/elementContext"; interface ComposerPendingElementContextsProps { contexts: ReadonlyArray; onRemove: (contextId: string) => void; className?: string; } interface ComposerPendingElementContextChipProps { context: ElementContextDraft; onRemove: (contextId: string) => void; } function buildTooltipContent(context: ElementContextDraft): string { const lines: string[] = []; lines.push(formatElementContextLabel(context)); const source = formatElementContextSourceLabel(context); if (source) lines.push(source); if (context.pageUrl) lines.push(context.pageUrl); if (context.selector) lines.push(context.selector); if (context.htmlPreview.trim().length > 0) { lines.push(""); lines.push(context.htmlPreview.trim().slice(0, 600)); } return lines.join("\n"); } export function ComposerPendingElementContextChip({ context, onRemove, }: ComposerPendingElementContextChipProps) { const label = formatElementContextLabel(context); const sourceLabel = formatElementContextSourceLabel(context); return ( {label} {sourceLabel ? ( {sourceLabel} ) : null} } /> {buildTooltipContent(context)} ); } export function ComposerPendingElementContexts({ contexts, onRemove, className, }: ComposerPendingElementContextsProps) { if (contexts.length === 0) return null; return (
{contexts.map((context) => ( ))}
); }