import "./components/ui/tidal.css"; import { useLayoutEffect, useRef, useState } from "react"; import { TidalAttachmentTray, type TidalAttachment } from "./components/ui/attachment-tray"; import "./components/ui/attachment-tray.css"; import "./components/ui/status-badge.css"; import "./components/ui/progress.css"; const tidalExampleStyles = ".tidal-scope .attachment-tray-demo {\n width: min(100%, 640px);\n min-width: 0;\n}\n.tidal-scope .attachment-demo-advance,\n.tidal-scope .attachment-demo-footer > button {\n min-height: 44px;\n padding: 8px 12px;\n border: 1px solid var(--t-border);\n background: var(--t-surface);\n border-radius: 9px;\n color: var(--t-ink);\n font: inherit;\n font-size: 12px;\n cursor: pointer;\n}\n.tidal-scope .attachment-demo-advance:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.tidal-scope .attachment-demo-footer {\n display: flex;\n flex-wrap: wrap;\n gap: 12px;\n align-items: center;\n justify-content: space-between;\n margin-top: 16px;\n}\n.tidal-scope .attachment-demo-footer > p {\n flex: 1 1 200px;\n min-width: 0;\n margin: 0;\n font-size: 11px;\n line-height: 1.6;\n color: var(--t-muted);\n}"; const sample: TidalAttachment[] = [ { id: "brief", name: "Project brief.pdf", typeText: "PDF document", sizeText: "2.4 MB", status: "ready", }, { id: "notes", name: "Release notes.md", typeText: "Markdown", sizeText: "42 KB", status: "uploading", progress: 64, }, { id: "assets", name: "Brand assets.zip", typeText: "ZIP archive", sizeText: "8.1 MB", status: "error", error: "Preparation was interrupted. Retry this sample file.", }, ]; export function AttachmentTrayDemo() { const [items, setItems] = useState(sample); const [status, setStatus] = useState( "Local sample files. Nothing is uploaded.", ); const root = useRef(null); const reset = useRef(null); const recovery = useRef<{ id: string; index: number; source?: HTMLButtonElement; } | null>(null); useLayoutEffect(() => { const intent = recovery.current; recovery.current = null; if ( !intent || (document.activeElement !== document.body && !(intent.source?.disabled && document.activeElement === intent.source)) ) return; const rows = Array.from( root.current?.querySelectorAll("[data-attachment-id]") ?? [], ); const row = rows.find((x) => x.dataset.attachmentId === intent.id) ?? rows[Math.min(intent.index, rows.length - 1)]; ( row?.querySelector( '[data-attachment-action="remove"]:not(:disabled)', ) ?? reset.current )?.focus({ preventScroll: true }); }, [items]); return (
{ recovery.current = { id: item.id, index: items.findIndex((x) => x.id === item.id), }; setItems(items.filter((x) => x.id !== item.id)); setStatus(`${item.name} removed from the local sample.`); }} onRetry={(item) => { recovery.current = { id: item.id, index: items.findIndex((x) => x.id === item.id), }; setItems( items.map((x) => x.id === item.id ? { ...x, status: "ready", error: undefined } : x, ), ); setStatus(`${item.name} is ready in the local sample.`); }} actions={ } />

{status}

); } export default function AgentExample() { return (
); }