import "./components/ui/tidal.css"; import { useRef, useState } from "react"; import { TidalVersionHistory, type TidalVersionEntry } from "./components/ui/version-history"; import { TidalAlertDialog } from "./components/ui/alert-dialog"; import "./components/ui/version-history.css"; import "./components/ui/alert-dialog.css"; import "./components/ui/status-badge.css"; import "./components/ui/collapsible-panel.css"; const tidalExampleStyles = ".tidal-scope .version-history-demo {\n width: 100%;\n max-width: 680px;\n min-width: 0;\n}\n.tidal-scope .version-history-demo > p {\n font-size: 11px;\n color: var(--t-muted);\n line-height: 1.5;\n margin: 12px 0 0;\n}"; const revisions = [ { id: "v3", label: "Version 3", author: "Alex Morgan", time: { label: "Today, 10:30 AM", dateTime: "2026-10-14T10:30:00Z" }, summary: "Shortened the introduction and added release dates.", changes: "Updated the opening paragraph and release schedule.", content: "A simpler release notes page. Find every update in one place.", }, { id: "v2", label: "Version 2", author: "Sam Lee", time: { label: "Yesterday, 3:45 PM", dateTime: "2026-10-13T15:45:00Z" }, summary: "Added the product overview.", changes: "Added a summary of the product and its current features.", content: "Release notes for the product team. Read the latest changes.", }, { id: "v1", label: "Version 1", author: "Alex Morgan", time: { label: "October 12, 9:00 AM", dateTime: "2026-10-12T09:00:00Z" }, summary: "Created the first draft.", content: "Product release notes.", }, ]; export function VersionHistoryDemo({ theme = "light", }: { theme?: "light" | "dark"; }) { const [current, setCurrent] = useState("v3"), [selected, setSelected] = useState("v3"), [request, setRequest] = useState(null), [message, setMessage] = useState("Sample document history."); const opener = useRef(null); const previewRefs = useRef>({}); return (
({ ...v, previewButtonRef: (node: HTMLButtonElement | null) => { previewRefs.current[v.id] = node; }, }))} currentVersionId={current} selectedVersionId={selected} onPreviewRequest={(v) => setSelected(v.id)} onRestoreRequest={(v, e) => { opener.current = e.currentTarget; setRequest(v); }} preview={ <> Document preview ยท{" "} {revisions.find((v) => v.id === selected)?.label}

{revisions.find((v) => v.id === selected)?.content}

} confirmation={ { if (!open) setRequest(null); }} trigger={ } title={`Restore ${request?.label ?? "version"}?`} description="This changes the current version in this local preview." cancelLabel="Cancel" confirmLabel="Restore version" onCancel={() => setRequest(null)} onConfirm={() => { if (request) { setCurrent(request.id); setSelected(request.id); setMessage(`${request.label} is current in this preview.`); } setRequest(null); }} theme={theme} contentProps={{ onCloseAutoFocus: (event) => { event.preventDefault(); const target = opener.current?.isConnected ? opener.current : previewRefs.current[selected]; target?.focus({ preventScroll: true }); }, }} /> } />

{message}

Sample data. No document is saved.

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