"use client"; import { useState } from "react"; import { IconCheck, IconCopy, IconTrash, IconX } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import type { Annotation } from "@/lib/preview-inspect-bridge"; import { formatAnnotations } from "@/lib/preview-inspect-bridge"; interface AnnotationsPanelProps { annotations: Annotation[]; onRemove: (id: string) => void; onClear: () => void; } function describeAnnotation(a: Annotation): string { if (a.kind === "pin") { const el = a.element; if (!el) return "Pin"; let suffix = ""; if (el.id) suffix = `#${el.id}`; else if (el.classes) suffix = `.${el.classes.split(/\s+/)[0]}`; return `${el.tag}${suffix}`; } const r = a.rect; return r ? `Area ${Math.round(r.w)}x${Math.round(r.h)}` : "Area"; } export function AnnotationsPanel({ annotations, onRemove, onClear }: AnnotationsPanelProps) { const [copied, setCopied] = useState(false); if (annotations.length === 0) return null; async function handleCopy() { try { await navigator.clipboard.writeText(formatAnnotations(annotations)); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error(`AnnotationsPanel: clipboard write failed: ${String(err)}`); } } return (
{annotations.length} annotation{annotations.length === 1 ? "" : "s"}
); }