{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "response-demo",
  "title": "Response Demo",
  "description": "A worked example of Response: An assistant's answer as markdown, including while it is still half-written and briefly invalid.",
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/response.json"
  ],
  "files": [
    {
      "path": "components/demos/response-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { Response } from \"@/registry/default/response/response\"\n\nconst answer = `The renewal is **automatic** unless notice is given.\n\n- Notice window: 60 days\n- Governing law: \\`England and Wales\\`\n\n\\`\\`\\`ts\nconst renews = !noticeGiven(contract, { days: 60 })\n\\`\\`\\`\n\nAsk again if you want the clause quoted in full.`\n\nexport function ResponseDemo() {\n  const [shown, setShown] = React.useState(answer.length)\n  const [streaming, setStreaming] = React.useState(false)\n\n  React.useEffect(() => {\n    if (!streaming) return\n\n    const timer = setInterval(() => {\n      setShown((n) => {\n        if (n >= answer.length) {\n          setStreaming(false)\n          return n\n        }\n        return n + 3\n      })\n    }, 24)\n\n    return () => clearInterval(timer)\n  }, [streaming])\n\n  return (\n    <div className=\"w-full max-w-md space-y-3\">\n      <Response streaming={streaming}>{answer.slice(0, shown)}</Response>\n      <button\n        type=\"button\"\n        className=\"border-border hover:bg-muted focus-visible:ring-ring inline-flex min-h-9 items-center rounded-full border px-3 text-xs font-semibold focus-visible:ring-2 focus-visible:outline-none\"\n        onClick={() => {\n          setShown(0)\n          setStreaming(true)\n        }}\n      >\n        Stream it again\n      </button>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}