{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-form-grid",
  "type": "registry:block",
  "title": "Contact, form grid",
  "description": "A centred contact section: a two-part heading and a short line, then fields in two columns, a full-width message, and a row with a terms tick box and a send button. One column on a phone.",
  "categories": [
    "contact"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json",
    "https://ui.klarhimmel.com/r/kit-form.json"
  ],
  "files": [
    {
      "path": "src/blocks/contact-form-grid/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-form-grid/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, formFields, link, t } from '../_shared/schema';\n\nconst field = z.object({\n  /** The word shown in the empty field; it is the field's name for assistive tech too. */\n  label: t(30),\n  type: z.enum(['text', 'email', 'tel']).default('text'),\n  required: z.boolean().default(false),\n});\n\nconst schema = z.object({\n  title: t(30),\n  /** The second, bold half of the heading, after a thin bar. */\n  titleStrong: t(30),\n  description: t(240),\n  /** Short fields, laid out two to a row. */\n  fields: z.array(field).min(1).max(8),\n  messageLabel: t(40),\n  consent: t(80),\n  consentLink: link.optional(),\n  submit: t(24),\n  ...formFields,\n});\n\nexport const spec = defineSpec({\n  type: 'contact-form-grid',\n  aliases: ['contact/form-grid'],\n  name: 'Contact, form grid',\n  category: 'contact',\n  role: 'body',\n  description: 'A centred contact section: a two-part heading and a short line, then fields in two columns, a full-width message, and a row with a terms tick box and a send button. One column on a phone.',\n  schema,\n  defaults: {\n    title: 'Name the section',\n    titleStrong: 'Name the business',\n    description: 'Say in one or two sentences who this form is for, what they can ask and how soon the team answers.',\n    fields: [\n      { label: 'The visitor’s first name', type: 'text', required: true },\n      { label: 'The visitor’s last name', type: 'text', required: false },\n      { label: 'Their company', type: 'text', required: false },\n      { label: 'Their role', type: 'text', required: false },\n      { label: 'Their email address', type: 'email', required: true },\n      { label: 'Their phone number', type: 'tel', required: false },\n    ],\n    messageLabel: 'What the visitor wants to ask',\n    consent: 'Say what the visitor agrees to by sending.',\n    consentLink: { label: 'Terms', href: '#terms' },\n    submit: 'Send the message',\n  },\n});\n"
    },
    {
      "path": "src/blocks/contact-form-grid/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-form-grid/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { safeHref } from '../../ui/button';\nimport { Container, Gate, Section } from '../_shared/kit';\nimport { useHeadingId } from '../_shared/c-proof-kit';\nimport { FormExtras, useFormProps } from '../_shared/form-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nconst line = 'peer block w-full border-0 border-b border-kh-line-strong bg-transparent px-0 pb-2 pt-5 text-kh-small text-kh-ink outline-none focus-visible:border-kh-ink';\nconst word = 'pointer-events-none absolute left-0 top-5 text-kh-small text-kh-muted peer-focus:hidden peer-[:not(:placeholder-shown)]:hidden';\n\nfunction ContactFormGrid({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const formProps = useFormProps(props);\n  const base = `${id}-f`;\n  return (\n    <Section labelledBy={id}>\n      <Container width=\"narrow\" className=\"text-center\">\n        <div id={id} className=\"flex flex-wrap items-center justify-center gap-x-4 text-kh-display leading-[1.1] tracking-wide\">\n          <Text path={['title']} value={props.title} as=\"h2\" className=\"font-light uppercase\" />\n          <span aria-hidden className=\"h-[1em] w-0.5 bg-kh-ink\" />\n          <Text path={['titleStrong']} value={props.titleStrong} as=\"span\" className=\"font-bold uppercase\" />\n        </div>\n        <Text path={['description']} value={props.description} as=\"p\" multiline className=\"mx-auto mt-6 max-w-xl text-kh-lead text-kh-muted\" />\n        <form {...formProps} className=\"mt-12 text-left\">\n          <div className=\"grid gap-x-6 gap-y-3 @xl:grid-cols-2\">\n            {/* A field is drawn only with its label (an emptied one would leave an unnamed input). */}\n            {props.fields.map((f, i) => f.label.trim() && (\n              <div key={i} className=\"relative\">\n                <input id={`${base}${i}`} name={`field-${i}`} type={f.type} required={f.required} placeholder=\" \" className={line} />\n                <label htmlFor={`${base}${i}`} className={word}><Text path={['fields', i, 'label']} value={f.label} as=\"span\" /></label>\n              </div>\n            ))}\n          </div>\n          {props.messageLabel.trim() && <div className=\"relative mt-6\">\n            <textarea id={`${base}m`} name=\"message\" rows={4} placeholder=\" \" className={`${line} resize-y`} />\n            <label htmlFor={`${base}m`} className={word}><Text path={['messageLabel']} value={props.messageLabel} as=\"span\" /></label>\n          </div>}\n          <FormExtras {...props} />\n          <div className=\"mt-6 flex flex-col gap-5 @xl:flex-row @xl:items-center @xl:justify-between\">\n            <label className=\"flex cursor-pointer items-center gap-3 text-kh-small text-kh-muted\">\n              <input type=\"checkbox\" name=\"consent\" required className=\"size-4 shrink-0 accent-[var(--kh-primary)]\" />\n              <span>\n                <Text path={['consent']} value={props.consent} as=\"span\" />\n                {props.consentLink?.label && <> <a href={safeHref(props.consentLink.href)} className=\"underline underline-offset-2 hover:text-kh-ink\"><Text path={['consentLink', 'label']} value={props.consentLink.label} as=\"span\" /></a></>}\n              </span>\n            </label>\n            <Gate label={props.submit}>\n              <button type=\"submit\" className=\"inline-flex min-h-11 items-center justify-center rounded-kh bg-kh-primary px-8 text-kh-small font-medium uppercase tracking-widest text-kh-on-primary hover:opacity-90\">\n                <Text path={['submit']} value={props.submit} as=\"span\" />\n              </button>\n            </Gate>\n          </div>\n        </form>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(ContactFormGrid);\n"
    }
  ]
}
