{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-booking",
  "type": "registry:block",
  "title": "Contact, booking",
  "description": "Contact options beside a card of static time slots to pick from, the name and email of who is booking, and a confirm button.",
  "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/input.json",
    "https://ui.klarhimmel.com/r/kit-form.json",
    "https://ui.klarhimmel.com/r/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/contact-booking/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-booking/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, formFields, link, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  options: z.array(z.object({ label: t(40), description: t(140), link })).min(1).max(3),\n  /** What is being booked (a room, a service, a lesson): with a label and choices, the visitor picks one before a time; sent as `choice`. */\n  choiceLabel: t(60).optional(),\n  choices: z.array(t(40)).max(8).optional(),\n  slotsTitle: t(60),\n  slots: z.array(req(30)).min(1).max(8),\n  /** Who is booking: with a label the field is drawn and required. Without both, the business cannot reply, so fill them unless the page is behind a sign-in. */\n  nameLabel: t(40).optional(),\n  emailLabel: t(40).optional(),\n  /** With a label, a phone field (optional to fill) for confirming by call or text. */\n  phoneLabel: t(40).optional(),\n  submit: req(30),\n  /** Form wiring: `action` is where the form goes (and a flow edge in Canvas); with `method` it submits natively. See formFields. */\n  ...formFields,\n});\n\nexport const spec = defineSpec({\n  type: 'contact-booking',\n  aliases: ['contact/booking'],\n  name: 'Contact, booking',\n  category: 'contact',\n  role: 'body',\n  description: 'Contact options beside a card of static time slots to pick from, the name and email of who is booking, and a confirm button.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the section',\n    title: 'Say what the call is',\n    description: 'Say in one sentence how long the call takes and what it settles. Say they can pick a time.',\n    options: [\n      { label: 'First way', description: 'Give the address or number and say how fast you reply.', link: { label: 'Main action', href: 'mailto:hello@yourcompany.example' } },\n      { label: 'Second way', description: 'Say what they find there, in one line.', link: { label: 'Second action', href: '#help' } },\n    ],\n    slotsTitle: 'Say to pick a time',\n    slots: ['Day 00:00', 'Day 00:00', 'Day 00:00', 'Day 00:00', 'Day 00:00', 'Day 00:00'],\n    nameLabel: 'Full name',\n    emailLabel: 'Your email',\n    submit: 'Confirm',\n  },\n});\n"
    },
    {
      "path": "src/blocks/contact-booking/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-booking/index.tsx",
      "content": "import { useId, useState } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Button } from '../../ui/button';\nimport { EMAIL_PATTERN, FormExtras, useFormProps } from '../_shared/form-kit';\nimport { Input } from '../../ui/input';\nimport { TextLink } from '../../ui/text-link';\nimport { Container, Section, SectionHeader, Gate, useEditing } from '../_shared/kit';\nimport { cn } from '../../lib/utils';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\n\n/** One look for every pick on the card (what, then when). */\nconst PILL = cn(\n  'flex min-h-11 cursor-pointer items-center justify-center rounded-kh border border-kh-line-strong bg-kh-surface px-3 text-kh-small font-medium text-kh-ink transition-colors hover:bg-kh-surface-2',\n  'peer-checked:border-kh-ink peer-checked:bg-kh-ink peer-checked:text-kh-on-ink peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--kh-focus)',\n);\ntype Props = z.infer<typeof spec.schema>;\n\nfunction ContactBooking({ props }: BlockProps<Props>) {\n  const id = useId();\n  const formProps = useFormProps(props);\n  const [picked, setPicked] = useState<number | null>(null);\n  const [chosen, setChosen] = useState<number | null>(null);\n  const editing = useEditing();\n  // an empty choice stays visible while editing (to be typed into) and is never drawn on a published page\n  const choices = props.choiceLabel || editing ? (props.choices ?? []).filter((c) => editing || c.trim()) : [];\n  const f = (n: string) => `${id}-${n}`;\n  const who = [['name', props.nameLabel], ['email', props.emailLabel], ['phone', props.phoneLabel]].filter((x): x is [string, string] => Boolean(x[1]));\n  return (\n    <Section labelledBy={id}>\n      <Container className=\"grid gap-14 @4xl:grid-cols-[1fr_1.1fr] @4xl:gap-20\">\n        <div>\n          <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n          <ul className=\"mt-10 divide-y divide-kh-line border-y border-kh-line\">\n            {props.options.map((o, i) => (\n              <li key={i} className=\"py-5\">\n                <Text path={['options', i, 'label']} value={o.label} as=\"h3\" className=\"text-kh-body font-semibold\" />\n                <Text path={['options', i, 'description']} value={o.description} as=\"p\" className=\"mt-1 text-kh-small text-kh-muted\" />\n                <Gate label={o.link.label}>\n                  <p className=\"mt-2 text-kh-small\">\n                    <TextLink href={o.link.href} className=\"inline-flex min-h-11 items-center\">\n                      <Text path={['options', i, 'link', 'label']} value={o.link.label} as=\"span\" />\n                    </TextLink>\n                  </p>\n                </Gate>\n              </li>\n            ))}\n          </ul>\n        </div>\n        <form {...formProps} className=\"self-start rounded-kh-xl border border-kh-line bg-kh-surface p-6 shadow-kh-1 @xl:p-8\">\n          {choices.length > 0 && (\n            <fieldset className=\"mb-6\">\n              <legend className=\"text-kh-heading font-semibold\">\n                <Text path={['choiceLabel']} value={props.choiceLabel ?? ''} as=\"span\" />\n              </legend>\n              {/* names vary in length (rooms, services), so one per row, left-aligned, instead of the time grid */}\n              <div className=\"mt-5 grid gap-3\">\n                {choices.map((c, i) => (\n                  <label key={i} className=\"relative block\">\n                    <input type=\"radio\" name=\"choice\" value={c} checked={chosen === i} onChange={() => setChosen(i)} className=\"peer sr-only\" />\n                    <span className={cn(PILL, 'justify-start px-4 py-2 text-left')}>\n                      <Text path={['choices', i]} value={c} as=\"span\" />\n                    </span>\n                  </label>\n                ))}\n              </div>\n            </fieldset>\n          )}\n          <fieldset>\n            <legend className=\"text-kh-heading font-semibold\">\n              <Text path={['slotsTitle']} value={props.slotsTitle} as=\"span\" />\n            </legend>\n            <div className=\"mt-5 grid grid-cols-2 gap-3 @xl:grid-cols-3\">\n              {props.slots.map((s, i) => (\n                <label key={i} className=\"relative block\">\n                  <input type=\"radio\" name=\"slot\" value={s} checked={picked === i} onChange={() => setPicked(i)} className=\"peer sr-only\" />\n                  <span className={PILL}>\n                    <Text path={['slots', i]} value={s} as=\"span\" />\n                  </span>\n                </label>\n              ))}\n            </div>\n          </fieldset>\n          {who.length > 0 && (\n            <div className={cn('mt-6 grid gap-4', who.length >= 2 && '@xl:grid-cols-2')}>\n              {who.map(([n, label]) => (\n                <div key={n} className={cn(who.length === 3 && n === 'phone' && '@xl:col-span-2')}>\n                  <label htmlFor={f(n)} className=\"mb-1.5 block text-kh-small font-medium\">\n                    <Text path={[`${n}Label`]} value={label} as=\"span\" />\n                  </label>\n                  {n === 'name' && <Input id={f(n)} name=\"name\" autoComplete=\"name\" required />}\n                  {n === 'email' && <Input id={f(n)} name=\"email\" type=\"email\" autoComplete=\"email\" required pattern={EMAIL_PATTERN} />}\n                  {n === 'phone' && <Input id={f(n)} name=\"phone\" type=\"tel\" autoComplete=\"tel\" inputMode=\"tel\" />}\n                </div>\n              ))}\n            </div>\n          )}\n          <FormExtras {...props} />\n          <Button type=\"submit\" size=\"lg\" full className=\"mt-6\" disabled={picked === null || (choices.length > 0 && chosen === null)}>\n            <Text path={['submit']} value={props.submit} as=\"span\" />\n          </Button>\n        </form>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(ContactBooking);\n"
    }
  ]
}
