{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "forms-17",
  "type": "registry:block",
  "description": "One-question-at-a-time conversational form with progress bar and lettered choices.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input"
  ],
  "files": [
    {
      "path": "registry/designali/blocks/forms/forms-17.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  ArrowLeft,\n  ArrowRight,\n  CornerDownLeft,\n} from \"@designali/icons\"\n\nimport { Button } from \"@workspace/ui/components/button\"\nimport { Input } from \"@workspace/ui/components/input\"\nimport { cn } from \"@workspace/ui/lib/utils\"\n\ntype Question =\n  | { id: string; kind: \"text\"; prompt: string; placeholder: string }\n  | { id: string; kind: \"choice\"; prompt: string; options: string[] }\n\nconst questions: Question[] = [\n  { id: \"name\", kind: \"text\", prompt: \"First up, what should we call you?\", placeholder: \"Type your name\" },\n  {\n    id: \"team\",\n    kind: \"choice\",\n    prompt: \"How big is the team working with Designali?\",\n    options: [\"Just me\", \"2 - 10\", \"11 - 50\", \"51 - 250\", \"250+\"],\n  },\n  {\n    id: \"goal\",\n    kind: \"choice\",\n    prompt: \"What do you need help with first?\",\n    options: [\"Brand identity\", \"UI/UX design\", \"Next.js website\", \"Design system\"],\n  },\n  { id: \"email\", kind: \"text\", prompt: \"Where can Ali Imam send your project plan?\", placeholder: \"you@example.com\" },\n]\n\nexport default function Forms17() {\n  const [index, setIndex] = useState(0)\n  const [answers, setAnswers] = useState<Record<string, string>>({})\n  const done = index >= questions.length\n  const question = questions[Math.min(index, questions.length - 1)]!\n  const value = answers[question.id] ?? \"\"\n  const progress = Math.round((Math.min(index, questions.length) / questions.length) * 100)\n\n  const next = () => setIndex((i) => Math.min(questions.length, i + 1))\n  const setValue = (v: string) => setAnswers((a) => ({ ...a, [question.id]: v }))\n\n  return (\n    <section className=\"w-full bg-background\">\n      <div className=\"h-1 w-full bg-muted\">\n        <div className=\"h-full bg-primary transition-all duration-500\" style={{ width: `${progress}%` }} />\n      </div>\n      <div className=\"mx-auto flex min-h-[520px] max-w-2xl flex-col justify-center px-6 py-20\">\n        {done ? (\n          <div aria-live=\"polite\">\n            <p className=\"font-sans text-xs text-muted-foreground\">All done</p>\n            <h2 className=\"mt-4 text-3xl font-semibold tracking-tight md:text-4xl\">\n              Thanks, {answers.name || \"friend\"}. Your plan is on its way.\n            </h2>\n            <p className=\"mt-4 text-sm leading-6 text-muted-foreground\">\n              Designali will email {answers.email || \"you\"} a project plan tailored\n              to a {answers.team || \"small\"} person team.\n            </p>\n            <Button variant=\"outline\" className=\"mt-8\" onClick={() => setIndex(0)}>\n              Start over\n            </Button>\n          </div>\n        ) : (\n          <form\n            onSubmit={(event) => {\n              event.preventDefault()\n              if (value) next()\n            }}\n          >\n            <p className=\"flex items-center gap-2 font-sans text-xs text-muted-foreground\">\n              {index + 1} <ArrowRight className=\"size-3\" /> {questions.length}\n            </p>\n            <h2 className=\"mt-4 text-3xl leading-tight font-semibold tracking-tight md:text-4xl\">\n              <label htmlFor={`f17-${question.id}`}>{question.prompt}</label>\n            </h2>\n\n            {question.kind === \"text\" ? (\n              <Input\n                key={question.id}\n                id={`f17-${question.id}`}\n                value={value}\n                onChange={(event) => setValue(event.target.value)}\n                placeholder={question.placeholder}\n                className=\"mt-8 h-14 border-0 border-b border-border bg-transparent px-0 text-xl focus-visible:border-foreground focus-visible:ring-0 md:text-2xl dark:bg-transparent\"\n              />\n            ) : (\n              <div className=\"mt-8 grid gap-2\" id={`f17-${question.id}`} role=\"radiogroup\">\n                {question.options.map((option, optionIndex) => (\n                  <button\n                    key={option}\n                    type=\"button\"\n                    role=\"radio\"\n                    aria-checked={value === option}\n                    onClick={() => setValue(option)}\n                    className={cn(\n                      \"flex items-center gap-3 border px-4 py-3 text-left text-sm transition-colors\",\n                      value === option ? \"border-foreground bg-muted\" : \"border-border hover:bg-muted/60\"\n                    )}\n                  >\n                    <span\n                      className={cn(\n                        \"flex size-6 items-center justify-center border font-sans text-[10px]\",\n                        value === option ? \"border-foreground bg-foreground text-background\" : \"border-border\"\n                      )}\n                    >\n                      {String.fromCharCode(65 + optionIndex)}\n                    </span>\n                    {option}\n                  </button>\n                ))}\n              </div>\n            )}\n\n            <div className=\"mt-10 flex items-center gap-3\">\n              <Button type=\"submit\" size=\"lg\" disabled={!value}>\n                {index === questions.length - 1 ? \"Submit\" : \"OK\"}\n                <ArrowRight />\n              </Button>\n              <span className=\"hidden items-center gap-1 text-xs text-muted-foreground sm:flex\">\n                press Enter <CornerDownLeft className=\"size-3\" />\n              </span>\n              {index > 0 && (\n                <Button\n                  type=\"button\"\n                  variant=\"ghost\"\n                  className=\"ml-auto\"\n                  onClick={() => setIndex((i) => Math.max(0, i - 1))}\n                >\n                  <ArrowLeft />\n                  Back\n                </Button>\n              )}\n            </div>\n          </form>\n        )}\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "600px"
  },
  "categories": [
    "forms"
  ]
}