"use client"; import "./components/ui/tidal.css"; import { useId, useMemo, useState } from "react"; import { TidalInvoicePreview, type TidalInvoiceLineItem } from "./components/ui/invoice-preview"; import "./components/ui/invoice-preview.css"; const tidalExampleStyles = ".tidal-scope .invoice-preview-demo,\n.tidal-scope .invoice-preview-demo * {\n box-sizing: border-box;\n}\n\n.tidal-scope .invoice-preview-demo {\n width: 100%;\n max-width: 1120px;\n min-width: 0;\n container: invoice-preview-demo / inline-size;\n}\n\n.tidal-scope .invoice-preview-demo-layout {\n display: grid;\n min-width: 0;\n gap: 12px;\n padding: 20px;\n border: 1px solid var(--t-border);\n border-radius: 22px;\n background:\n linear-gradient(var(--t-border) 1px, transparent 1px),\n linear-gradient(90deg, var(--t-border) 1px, transparent 1px),\n var(--t-subtle);\n background-size: 28px 28px;\n}\n\n.tidal-scope .invoice-preview-demo-picker {\n display: grid;\n width: min(100%, 300px);\n gap: 5px;\n padding: 10px;\n border: 1px solid var(--t-border);\n border-radius: 10px;\n background: var(--t-surface);\n color: var(--t-muted);\n font-size: 11px;\n font-weight: 670;\n letter-spacing: 0.05em;\n line-height: 1.35;\n}\n\n.tidal-scope .invoice-preview-demo-picker > span {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .invoice-preview-demo-picker select {\n width: 100%;\n min-width: 0;\n min-height: 44px;\n padding: 8px 10px;\n border: 1px solid var(--t-border);\n border-radius: 8px;\n background: var(--t-surface);\n color: var(--t-ink);\n font: inherit;\n font-size: 16px;\n line-height: 1.4;\n}\n\n.tidal-scope .invoice-preview-demo-picker select:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.tidal-scope .invoice-preview-demo-boundary {\n min-width: 0;\n padding: 20px;\n border: 1px solid var(--t-border);\n border-radius: 18px;\n background: var(--t-ink);\n color: var(--t-surface);\n scroll-margin-block: 18px;\n}\n\n.tidal-scope .invoice-preview-demo-boundary:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.tidal-scope .invoice-preview-demo-boundary > span {\n color: color-mix(in srgb, var(--t-surface) 62%, var(--t-ink));\n font-size: 11px;\n font-weight: 690;\n letter-spacing: 0.09em;\n line-height: 1.35;\n text-transform: uppercase;\n}\n\n.tidal-scope .invoice-preview-demo-boundary h3 {\n margin: 8px 0 0;\n font-size: 18px;\n font-weight: 650;\n letter-spacing: -0.035em;\n line-height: 1.25;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .invoice-preview-demo-boundary p {\n max-width: 72ch;\n margin: 7px 0 0;\n color: color-mix(in srgb, var(--t-surface) 72%, var(--t-ink));\n font-size: 11px;\n line-height: 1.6;\n overflow-wrap: anywhere;\n}\n\n@container invoice-preview-demo (max-width: 520px) {\n .tidal-scope .invoice-preview-demo-layout {\n gap: 9px;\n padding: 8px;\n }\n\n .tidal-scope .invoice-preview-demo-picker {\n width: 100%;\n }\n\n .tidal-scope .invoice-preview-demo-boundary {\n padding: 17px;\n }\n}"; type SampleInvoiceId = "sample-1048" | "sample-1036"; interface SampleInvoice { id: SampleInvoiceId; issue: { dateTime: string; label: string }; due: { dateTime: string; label: string }; reference: string; rows: readonly (TidalInvoiceLineItem & { note: string })[]; subtotal: string; adjustment: string; total: string; } const SAMPLE_INVOICES: readonly SampleInvoice[] = [ { id: "sample-1048", issue: { dateTime: "2026-10-01", label: "October 1, 2026" }, due: { dateTime: "2026-10-15", label: "October 15, 2026" }, reference: "PO-1048", rows: [ { id: "brief-layout", description: "Product design", detail: "Website interface and responsive layouts.", note: "Includes the homepage, component library, and responsive layouts.", quantity: "1", rate: "$16.00", total: "$16.00", }, { id: "checklist-layout", description: "Design review", detail: "Interface review and handoff.", note: "Review notes and developer handoff.", quantity: "1", rate: "$8.00", total: "$8.00", }, ], subtotal: "$24.00", adjustment: "$0.00", total: "$24.00", }, { id: "sample-1036", issue: { dateTime: "2026-09-01", label: "September 1, 2026" }, due: { dateTime: "2026-09-15", label: "September 15, 2026" }, reference: "PO-1036", rows: [ { id: "review-layout", description: "Design review", detail: "Interface review and revisions.", note: "Two rounds of interface review and revisions.", quantity: "2", rate: "$10.00", total: "$20.00", }, ], subtotal: "$20.00", adjustment: "−$2.00", total: "$18.00", }, ]; export function InvoicePreviewDemo() { const generatedId = useId().replace(/:/g, ""); const disclosureId = `invoice-preview-${generatedId}-boundary`; const [invoiceId, setInvoiceId] = useState("sample-1048"); const [showNotes, setShowNotes] = useState(false); const [message, setMessage] = useState("Invoice 1048 selected."); const invoice = SAMPLE_INVOICES.find((entry) => entry.id === invoiceId)!; const rows = useMemo( () => invoice.rows.map((row) => ({ ...row, detail: showNotes ? row.note : row.detail, })), [invoice, showNotes], ); return (
{ setShowNotes((current) => !current); setMessage( showNotes ? "Short descriptions shown." : "Item notes shown.", ); }, }, { kind: "link", id: "review-boundary", label: "About this sample", href: `#${disclosureId}`, onAction: () => setMessage("Sample details opened."), }, ]} footer={ {message} Sample data. Changes stay in this preview. } />
); } export default function AgentExample() { return (
); }