{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-form",
  "title": "Contact Form",
  "description": "A contact section with a header, contact details and a validated message form that reports pending, success and error states.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/button",
    "@corsair-ui/card",
    "@corsair-ui/field",
    "@corsair-ui/input",
    "@corsair-ui/textarea"
  ],
  "files": [
    {
      "path": "registry/default/components/blocks/contact-form.tsx",
      "content": "\"use client\";\n\nimport { ClockIcon, MailIcon } from \"lucide-react\";\nimport { useId, useState, type ComponentProps, type ReactNode, type SubmitEvent } from \"react\";\n\nimport { cn } from \"@/registry/default/lib/utils\";\nimport { Button } from \"@/registry/default/ui/button\";\nimport { Card, CardContent } from \"@/registry/default/ui/card\";\nimport { Field, FieldLabel } from \"@/registry/default/ui/field\";\nimport { Input } from \"@/registry/default/ui/input\";\nimport { Textarea } from \"@/registry/default/ui/textarea\";\n\n/** What the form hands to `onSubmit`, read from its fields with FormData. */\ninterface ContactFormValues {\n  name: string;\n  email: string;\n  message: string;\n}\n\n/** Every string the form shows, including the button and status messages. */\ninterface ContactFormLabels {\n  name: ReactNode;\n  email: ReactNode;\n  message: ReactNode;\n  submit: ReactNode;\n  /** Button text while `onSubmit` is running. */\n  pending: ReactNode;\n  /** Announced in the status region once `onSubmit` resolves. */\n  success: ReactNode;\n  /** Announced in the alert region when `onSubmit` throws. */\n  error: ReactNode;\n}\n\ntype ContactFormStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nconst defaultLabels: ContactFormLabels = {\n  name: \"Name\",\n  email: \"Email\",\n  message: \"Message\",\n  submit: \"Send message\",\n  pending: \"Sending…\",\n  success: \"Thanks for your message. We'll get back to you soon.\",\n  error: \"Something went wrong. Please try again.\",\n};\n\nconst defaultDetails = (\n  <ul className=\"text-muted-foreground flex flex-col gap-3 text-sm\">\n    <li className=\"flex items-center gap-3\">\n      <MailIcon aria-hidden=\"true\" className=\"size-4 shrink-0\" />\n      <a\n        href=\"mailto:hello@example.com\"\n        className=\"text-foreground focus-visible:ring-ring/50 rounded-md underline-offset-4 outline-none hover:underline focus-visible:ring-[3px]\"\n      >\n        hello@example.com\n      </a>\n    </li>\n    <li className=\"flex items-center gap-3\">\n      <ClockIcon aria-hidden=\"true\" className=\"size-4 shrink-0\" />\n      <span>We reply within one business day</span>\n    </li>\n  </ul>\n);\n\ninterface ContactFormProps extends Omit<ComponentProps<\"section\">, \"title\" | \"onSubmit\"> {\n  /** Small line above the title. Pass `null` to hide it. */\n  eyebrow?: ReactNode;\n  /** Section title, rendered as an `<h2>`. */\n  title?: ReactNode;\n  description?: ReactNode;\n  /** Shown under the description: contact channels, office hours. Pass `null` to hide it. */\n  details?: ReactNode;\n  /** Overrides for any of the form's strings; the rest keep their English defaults. */\n  labels?: Partial<ContactFormLabels>;\n  /**\n   * Called with the field values instead of a native submit. While it runs the\n   * button is disabled; resolving resets the form and shows `labels.success`,\n   * throwing keeps the values and shows `labels.error`.\n   */\n  onSubmit?: (values: ContactFormValues) => void | Promise<void>;\n  /** Props for the `<form>`, such as `action` and `method` for a native submit. */\n  formProps?: ComponentProps<\"form\">;\n}\n\n/**\n * A contact section: a header with contact details on the left and a\n * message form in a Card on the right (stacked below `lg`). The name, email\n * and message fields are all `required` and use native validation and\n * `autoComplete`, so the browser blocks an incomplete submit before\n * `onSubmit` is called.\n *\n * With `onSubmit`, the form does not navigate: the section and form get\n * `data-status=\"pending\"`, then `\"success\"` or `\"error\"`, which you can\n * style with `data-[status=…]:`. The success message goes to a `role=\"status\"`\n * region and the error to a `role=\"alert\"` region; both stay mounted (empty\n * when idle) so screen readers announce them. Without `onSubmit` the form\n * submits natively: pass `action` and `method` through `formProps`.\n *\n * @example\n * <ContactForm\n *   title=\"Talk to us\"\n *   labels={{ submit: \"Send\" }}\n *   onSubmit={async (values) => {\n *     await fetch(\"/api/contact\", { method: \"POST\", body: JSON.stringify(values) });\n *   }}\n * />\n */\nfunction ContactForm({\n  eyebrow = \"Contact\",\n  title = \"Get in touch\",\n  description = \"Questions about plans, features or anything else? Send us a message and the team will reply.\",\n  details = defaultDetails,\n  labels: labelsProp,\n  onSubmit,\n  formProps,\n  className,\n  ...props\n}: ContactFormProps) {\n  const id = useId();\n  const [status, setStatus] = useState<ContactFormStatus>(\"idle\");\n  const labels = { ...defaultLabels, ...labelsProp };\n  const pending = status === \"pending\";\n\n  async function handleSubmit(event: SubmitEvent<HTMLFormElement>) {\n    formProps?.onSubmit?.(event);\n    // No handler, or the consumer cancelled it: leave the native submit alone.\n    if (!onSubmit || event.defaultPrevented) return;\n    event.preventDefault();\n    if (pending) return;\n\n    // React clears currentTarget once the event is handled, so keep the form.\n    const form = event.currentTarget;\n    const data = new FormData(form);\n    const values: ContactFormValues = {\n      name: String(data.get(\"name\") ?? \"\"),\n      email: String(data.get(\"email\") ?? \"\"),\n      message: String(data.get(\"message\") ?? \"\"),\n    };\n\n    setStatus(\"pending\");\n    try {\n      await onSubmit(values);\n      form.reset();\n      setStatus(\"success\");\n    } catch {\n      setStatus(\"error\");\n    }\n  }\n\n  return (\n    <section\n      data-slot=\"contact-form\"\n      data-status={status}\n      className={cn(\"py-16 sm:py-24\", className)}\n      {...props}\n    >\n      <div\n        data-slot=\"contact-form-container\"\n        className=\"mx-auto grid w-full max-w-6xl gap-12 px-4 sm:px-6 lg:grid-cols-2\"\n      >\n        <div data-slot=\"contact-form-header\" className=\"max-w-2xl\">\n          {eyebrow ? (\n            <p\n              data-slot=\"contact-form-eyebrow\"\n              className=\"text-muted-foreground text-sm font-medium\"\n            >\n              {eyebrow}\n            </p>\n          ) : null}\n          <h2\n            data-slot=\"contact-form-title\"\n            className={cn(\n              \"text-3xl font-semibold tracking-tight text-balance sm:text-4xl\",\n              eyebrow ? \"mt-2\" : null\n            )}\n          >\n            {title}\n          </h2>\n          {description ? (\n            <p\n              data-slot=\"contact-form-description\"\n              className=\"text-muted-foreground mt-4 text-lg text-pretty\"\n            >\n              {description}\n            </p>\n          ) : null}\n          {details ? (\n            <div data-slot=\"contact-form-details\" className=\"mt-8\">\n              {details}\n            </div>\n          ) : null}\n        </div>\n        <Card data-slot=\"contact-form-card\" className=\"min-w-0\">\n          <CardContent>\n            <form\n              data-slot=\"contact-form-form\"\n              data-status={status}\n              {...formProps}\n              className={cn(\"flex flex-col gap-6\", formProps?.className)}\n              onSubmit={handleSubmit}\n            >\n              <div className=\"grid gap-6 sm:grid-cols-2\">\n                <Field>\n                  <FieldLabel htmlFor={`${id}-name`}>{labels.name}</FieldLabel>\n                  <Input id={`${id}-name`} name=\"name\" autoComplete=\"name\" required />\n                </Field>\n                <Field>\n                  <FieldLabel htmlFor={`${id}-email`}>{labels.email}</FieldLabel>\n                  <Input\n                    id={`${id}-email`}\n                    name=\"email\"\n                    type=\"email\"\n                    autoComplete=\"email\"\n                    required\n                  />\n                </Field>\n              </div>\n              <Field>\n                <FieldLabel htmlFor={`${id}-message`}>{labels.message}</FieldLabel>\n                <Textarea id={`${id}-message`} name=\"message\" rows={5} required />\n              </Field>\n              <div data-slot=\"contact-form-footer\">\n                <Button\n                  type=\"submit\"\n                  data-slot=\"contact-form-submit\"\n                  loading={pending}\n                  className=\"w-full sm:w-auto\"\n                >\n                  {pending ? labels.pending : labels.submit}\n                </Button>\n                <p\n                  role=\"status\"\n                  data-slot=\"contact-form-success\"\n                  className=\"mt-4 text-sm empty:mt-0\"\n                >\n                  {status === \"success\" ? labels.success : null}\n                </p>\n                <p\n                  role=\"alert\"\n                  data-slot=\"contact-form-error\"\n                  className=\"text-destructive mt-4 text-sm empty:mt-0\"\n                >\n                  {status === \"error\" ? labels.error : null}\n                </p>\n              </div>\n            </form>\n          </CardContent>\n        </Card>\n      </div>\n    </section>\n  );\n}\n\nexport {\n  ContactForm,\n  type ContactFormLabels,\n  type ContactFormProps,\n  type ContactFormStatus,\n  type ContactFormValues,\n};\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:block"
}