{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "form-01",
  "title": "Create form",
  "description": "A new-project form with a URL derived from the name, visibility as radio cards, and validation that replaces a hint with its error. Renders in any Satori UI design system (cueit, skita, folio or a generated one): install a system first.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "card",
    "checkbox",
    "input",
    "label",
    "radio-group",
    "textarea"
  ],
  "files": [
    {
      "path": "design-systems/blocks/form-01.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Globe, Lock } from \"lucide-react\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\";\nimport { Checkbox } from \"@/components/ui/checkbox\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { RadioGroup, RadioGroupItem } from \"@/components/ui/radio-group\";\nimport { Textarea } from \"@/components/ui/textarea\";\nimport { cn } from \"@/lib/utils\";\n\n/**\n * A \"create project\" form: name with a derived URL, description,\n * visibility as radio cards and an opt-in, with validation that replaces a\n * field's hint with its error.\n *\n * Written against the block contract only, so it takes the look of\n * whichever design system scopes it. `onCreate` receives the values once\n * they validate; without it the form only validates.\n */\n\nexport type ProjectValues = {\n  name: string;\n  slug: string;\n  description: string;\n  visibility: \"private\" | \"public\";\n  invite: boolean;\n};\n\nconst toSlug = (s: string) =>\n  s\n    .toLowerCase()\n    .trim()\n    .replace(/[^a-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\")\n    .slice(0, 40);\n\nexport type Form01Props = Omit<React.ComponentProps<\"form\">, \"onSubmit\"> & {\n  /** Shown before the slug, such as your app's domain. */\n  urlPrefix?: string;\n  onCreate?: (values: ProjectValues) => void | Promise<void>;\n  onCancel?: () => void;\n};\n\nexport function Form01({ urlPrefix = \"duebird.app/\", onCreate, onCancel, className, ...props }: Form01Props) {\n  const [name, setName] = React.useState(\"\");\n  const [slug, setSlug] = React.useState(\"\");\n  const [slugEdited, setSlugEdited] = React.useState(false);\n  const [errors, setErrors] = React.useState<Partial<Record<\"name\" | \"slug\", string>>>({});\n  const [pending, setPending] = React.useState(false);\n  const shownSlug = slugEdited ? slug : toSlug(name);\n\n  async function submit(e: React.FormEvent<HTMLFormElement>) {\n    e.preventDefault();\n    const data = new FormData(e.currentTarget);\n    const next: typeof errors = {};\n    if (name.trim().length < 2) next.name = \"Give the project a name of at least two characters.\";\n    if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(shownSlug)) next.slug = \"Use lowercase letters, numbers and single hyphens.\";\n    setErrors(next);\n    if (Object.keys(next).length) return;\n    setPending(true);\n    try {\n      await onCreate?.({\n        name: name.trim(),\n        slug: shownSlug,\n        description: String(data.get(\"description\") ?? \"\"),\n        visibility: data.get(\"visibility\") === \"public\" ? \"public\" : \"private\",\n        invite: data.get(\"invite\") === \"on\",\n      });\n    } finally {\n      setPending(false);\n    }\n  }\n\n  return (\n    <form noValidate onSubmit={submit} className={cn(\"@container/form w-full max-w-2xl\", className)} {...props}>\n      <Card className=\"gap-6\">\n        <CardHeader>\n          <CardTitle>New project</CardTitle>\n          <CardDescription>You can change all of this later in settings.</CardDescription>\n        </CardHeader>\n\n        <CardContent className=\"flex flex-col gap-5\">\n          <div className=\"grid gap-5 @lg/form:grid-cols-2\">\n            <div className=\"flex flex-col gap-2\">\n              <Label htmlFor=\"project-name\">Project name</Label>\n              <Input\n                id=\"project-name\"\n                name=\"name\"\n                value={name}\n                onChange={(e) => setName(e.target.value)}\n                placeholder=\"Marketing site\"\n                aria-invalid={errors.name ? true : undefined}\n                aria-describedby=\"project-name-msg\"\n              />\n              <p\n                id=\"project-name-msg\"\n                className={cn(\"ds-small\", errors.name ? \"text-destructive\" : \"text-muted-foreground\")}\n              >\n                {errors.name ?? \"What your team will call it.\"}\n              </p>\n            </div>\n            <div className=\"flex flex-col gap-2\">\n              <Label htmlFor=\"project-slug\">URL</Label>\n              <div className=\"flex items-center\">\n                <span className=\"ds-meta shrink-0 pr-2\">{urlPrefix}</span>\n                <Input\n                  id=\"project-slug\"\n                  name=\"slug\"\n                  value={shownSlug}\n                  onChange={(e) => {\n                    setSlugEdited(true);\n                    setSlug(e.target.value);\n                  }}\n                  placeholder=\"marketing-site\"\n                  aria-invalid={errors.slug ? true : undefined}\n                  aria-describedby=\"project-slug-msg\"\n                />\n              </div>\n              <p\n                id=\"project-slug-msg\"\n                className={cn(\"ds-small\", errors.slug ? \"text-destructive\" : \"text-muted-foreground\")}\n              >\n                {errors.slug ?? \"Filled in from the name until you edit it.\"}\n              </p>\n            </div>\n          </div>\n\n          <div className=\"flex flex-col gap-2\">\n            <Label htmlFor=\"project-description\">\n              Description <span className=\"font-normal text-muted-foreground\">(optional)</span>\n            </Label>\n            <Textarea id=\"project-description\" name=\"description\" rows={3} placeholder=\"What is it for?\" />\n          </div>\n\n          <fieldset className=\"flex flex-col gap-2\">\n            <legend className=\"ds-small mb-2 font-medium\">Visibility</legend>\n            <RadioGroup name=\"visibility\" defaultValue=\"private\" className=\"grid gap-3 @lg/form:grid-cols-2\">\n              {[\n                { value: \"private\", label: \"Private\", hint: \"Only people you invite.\", icon: Lock },\n                { value: \"public\", label: \"Public\", hint: \"Anyone with the link can view.\", icon: Globe },\n              ].map(({ value, label, hint, icon: Icon }) => (\n                <Label\n                  key={value}\n                  htmlFor={`visibility-${value}`}\n                  className=\"ds-tile ds-hover flex cursor-pointer items-start gap-3 p-4\"\n                >\n                  <span className=\"ds-well flex size-8 shrink-0 items-center justify-center\">\n                    <Icon className=\"size-4\" aria-hidden=\"true\" />\n                  </span>\n                  <span className=\"min-w-0 flex-1\">\n                    <span className=\"block\">{label}</span>\n                    <span className=\"ds-small mt-0.5 block font-normal text-muted-foreground\">{hint}</span>\n                  </span>\n                  <RadioGroupItem id={`visibility-${value}`} value={value} className=\"mt-0.5\" />\n                </Label>\n              ))}\n            </RadioGroup>\n          </fieldset>\n\n          <div className=\"flex items-start gap-3\">\n            <Checkbox id=\"project-invite\" name=\"invite\" defaultChecked className=\"mt-0.5\" />\n            <div>\n              <Label htmlFor=\"project-invite\">Invite my team</Label>\n              <p className=\"ds-small mt-0.5 text-muted-foreground\">Everyone in Duebird gets an email.</p>\n            </div>\n          </div>\n        </CardContent>\n\n        <CardFooter className=\"justify-end gap-2 border-t pt-6\">\n          <Button type=\"button\" variant=\"ghost\" onClick={onCancel}>\n            Cancel\n          </Button>\n          <Button type=\"submit\" disabled={pending}>\n            {pending ? \"Creating…\" : \"Create project\"}\n          </Button>\n        </CardFooter>\n      </Card>\n    </form>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/satori-ui/blocks/form-01.tsx"
    }
  ],
  "type": "registry:block"
}