{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diff-view-demo",
  "title": "Diff View Demo",
  "description": "A worked example of Diff View: A proposed change shown as a unified or side-by-side diff, with optional accept and reject controls.",
  "dependencies": [
    "lucide-react@^1.31.0"
  ],
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/diff-view.json"
  ],
  "files": [
    {
      "path": "components/demos/diff-view-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { DemoVariants } from \"@/components/demos/demo-variants\"\nimport { RestartButton } from \"@/components/demos/restart-button\"\nimport { DiffView } from \"@/registry/default/diff-view/diff-view\"\n\nconst before = `export function total(items) {\n  let sum = 0\n\n  for (const item of items) {\n    sum += item.price\n  }\n\n  return sum\n}`\n\nconst after = `export function total(items, { taxRate = 0 } = {}) {\n  let sum = 0\n\n  for (const item of items) {\n    sum += item.price * item.quantity\n  }\n\n  return sum * (1 + taxRate)\n}`\n\nfunction Decision() {\n  const [status, setStatus] = React.useState<\n    \"pending\" | \"accepted\" | \"rejected\"\n  >(\"pending\")\n\n  return (\n    <div className=\"grid gap-4\">\n      <DiffView\n        filename=\"lib/total.ts\"\n        before={before}\n        after={after}\n        status={status}\n        onAccept={() => setStatus(\"accepted\")}\n        onReject={() => setStatus(\"rejected\")}\n      />\n\n      {status === \"pending\" ? null : (\n        <RestartButton onClick={() => setStatus(\"pending\")} />\n      )}\n    </div>\n  )\n}\n\nexport function DiffViewDemo() {\n  return (\n    <DemoVariants\n      label=\"Diff layout\"\n      variants={[\n        { id: \"decide\", label: \"To review\", render: () => <Decision /> },\n        {\n          id: \"unified\",\n          label: \"Unified\",\n          render: () => (\n            <DiffView filename=\"lib/total.ts\" before={before} after={after} />\n          ),\n        },\n        {\n          id: \"split\",\n          label: \"Split\",\n          render: () => (\n            <DiffView\n              filename=\"lib/total.ts\"\n              before={before}\n              after={after}\n              view=\"split\"\n            />\n          ),\n        },\n      ]}\n    />\n  )\n}\n",
      "type": "registry:example"
    },
    {
      "path": "components/demos/demo-variants.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nexport type DemoVariant = {\n  id: string\n  label: string\n  render: () => React.ReactNode\n}\n\nexport function DemoVariants({\n  variants,\n  label = \"Demo variant\",\n}: {\n  variants: [DemoVariant, ...DemoVariant[]]\n  label?: string\n}) {\n  const [activeId, setActiveId] = React.useState(variants[0].id)\n  const active =\n    variants.find((variant) => variant.id === activeId) ?? variants[0]\n\n  return (\n    <div className=\"grid w-full justify-items-center gap-6\">\n      {/* Centres whatever the variant renders. Without this a demo that caps\n          its own width sits against the left edge while the switch below it\n          is centred, which reads as a mistake. */}\n      <div className=\"flex w-full justify-center\">{active.render()}</div>\n\n      <div\n        role=\"group\"\n        aria-label={label}\n        className=\"border-border bg-background/70 inline-flex flex-wrap justify-center gap-1 rounded-full border p-1\"\n      >\n        {variants.map((variant) => {\n          const isActive = variant.id === active.id\n\n          return (\n            <button\n              key={variant.id}\n              type=\"button\"\n              aria-pressed={isActive}\n              className={\n                isActive\n                  ? \"bg-foreground text-background rounded-full px-3 py-1.5 text-xs font-semibold\"\n                  : \"text-muted-foreground hover:text-foreground rounded-full px-3 py-1.5 text-xs font-semibold\"\n              }\n              onClick={() => setActiveId(variant.id)}\n            >\n              {variant.label}\n            </button>\n          )\n        })}\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    },
    {
      "path": "components/demos/restart-button.tsx",
      "content": "\"use client\"\n\nimport { RotateCcw } from \"lucide-react\"\n\nexport function RestartButton({ onClick }: { onClick: () => void }) {\n  return (\n    <button className=\"restore-button\" type=\"button\" onClick={onClick}>\n      <RotateCcw aria-hidden=\"true\" size={15} /> Replay\n    </button>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}