# Add the "LOI Form" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/loi-form) to this Pantheon Content Publisher (P1) Next.js project. Letter of inquiry form with EIN, contact, program area, request amount, summary guidance and what happens next.

## Steps

1. Create `components/puck/loi-form-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { loiFormBlock } from "./components/puck/loi-form-block";`
3. Register it under `components` as `LoiFormBlock: loiFormBlock`.
4. Add `"LoiFormBlock"` to the best-fitting entry in `categories` (this block's library category is "Foundations"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/loi-form-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * LOI Form — a letter of inquiry form (organization, EIN, contact, program area, request,
 * project summary, budget size) that posts to your form handler, plus what happens next.
 * Register: `LoiFormBlock: loiFormBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

export type LoiFormProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  formAction: string;
  programAreas: { label: string }[];
  budgetSizes: { label: string }[];
  summaryMax: number;
  summaryHint: string;
  submitLabel: string;
  privacyNote: string;
  nextHeading: string;
  nextSteps: { title: string; body: string }[];
  deadlineNote: string;
  contactName: string;
  contactEmail: string;
  contactPhone: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";
const inputClass =
  "block min-h-11 w-full rounded-lg border-0 bg-white px-3.5 py-2.5 text-base text-neutral-950 shadow-xs ring-1 ring-neutral-300 ring-inset placeholder:text-neutral-500 focus:ring-2 focus:ring-indigo-600 focus:outline-none";
const labelClass = "block text-sm leading-6 font-medium text-neutral-900";
const hintClass = "mt-2 text-sm leading-6 text-neutral-600";
const chevron = "M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z";

const Optional = () => <span className="font-normal text-neutral-600"> (optional)</span>;

export const loiFormBlock: ComponentConfig<LoiFormProps> = {
  label: "LOI Form",
  fields: {
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    intro: { type: "textarea", label: "Intro" },
    formAction: { type: "text", label: "Form action URL", metadata: { help: "Where the form posts: your grants portal, form service or API route. Fields are sent as org_name, ein, contact_name, contact_title, email, phone, program_area, request_amount, summary and budget_size." } },
    programAreas: {
      type: "array",
      label: "Program areas",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.label || "Program area",
      defaultItemProps: { label: "New program area" },
      arrayFields: { label: { type: "text", label: "Program area" } },
    },
    budgetSizes: {
      type: "array",
      label: "Budget size options",
      min: 1,
      max: 8,
      getItemSummary: (item) => item?.label || "Budget range",
      defaultItemProps: { label: "$1 million–$5 million" },
      arrayFields: { label: { type: "text", label: "Range" } },
      metadata: { help: "Ranges for the organization's annual operating budget." },
    },
    summaryMax: { type: "number", label: "Summary character limit", min: 200, max: 5000, metadata: { help: "The browser stops typing at this length. About 1,500 characters is a page." } },
    summaryHint: { type: "textarea", label: "Summary guidance", metadata: { help: "What to cover in the project summary. Shown under the field." } },
    submitLabel: { type: "text", label: "Submit button text" },
    privacyNote: { type: "textarea", label: "Privacy note", metadata: { help: "Shown next to the submit button. Leave blank to hide it." } },
    nextHeading: { type: "text", label: "Next steps heading" },
    nextSteps: {
      type: "array",
      label: "What happens next",
      min: 0,
      max: 5,
      getItemSummary: (item) => item?.title || "Step",
      defaultItemProps: { title: "New step", body: "" },
      arrayFields: {
        title: { type: "text", label: "Step" },
        body: { type: "textarea", label: "Description" },
      },
    },
    deadlineNote: { type: "textarea", label: "Deadline note", metadata: { help: "Leave blank to hide it." } },
    contactName: { type: "text", label: "Questions contact", metadata: { help: "Leave blank to hide the contact." } },
    contactEmail: { type: "text", label: "Contact email" },
    contactPhone: { type: "text", label: "Contact phone" },
  },
  defaultProps: {
    heading: "Submit a letter of inquiry",
    headingLevel: "h2",
    intro: "A letter of inquiry is a short first step, not a full proposal. Tell us about your organization and the project, and a program officer will be in touch.",
    formAction: "/api/letter-of-inquiry",
    programAreas: [{ label: "Housing & neighborhoods" }, { label: "Early learning" }, { label: "Health access" }, { label: "Arts & culture" }, { label: "Nonprofit strength" }],
    budgetSizes: [{ label: "Under $250,000" }, { label: "$250,000–$1 million" }, { label: "$1 million–$5 million" }, { label: "Over $5 million" }],
    summaryMax: 1500,
    summaryHint: "In about 250 words: the need, what you'll do, who benefits and how you'll know it worked. Up to 1,500 characters.",
    submitLabel: "Submit letter of inquiry",
    privacyNote: "We use this information only to review your request. It is never sold or shared.",
    nextHeading: "What happens next",
    nextSteps: [
      { title: "We confirm receipt", body: "You'll get an email with a copy of your letter within one business day." },
      { title: "A program officer reviews it", body: "Expect a reply within three weeks. We may call with a few questions." },
      { title: "You hear our decision", body: "Promising requests are invited to submit a full proposal. If we decline, we'll tell you why." },
    ],
    deadlineNote: "Letters for the spring cycle are due November 14 at 5 p.m. Eastern.",
    contactName: "Renée Okafor, Senior Program Officer",
    contactEmail: "grants@harlowfoundation.example.org",
    contactPhone: "(555) 555-0142",
  },
  render: ({ id, heading, headingLevel, intro, formAction, programAreas, budgetSizes, summaryMax, summaryHint, submitLabel, privacyNote, nextHeading, nextSteps, deadlineNote, contactName, contactEmail, contactPhone }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] ?? "h3";
    const uid = `loi-${id || "form"}`;
    const areas = (programAreas ?? []).map((a) => a?.label?.trim()).filter(Boolean) as string[];
    const budgets = (budgetSizes ?? []).map((b) => b?.label?.trim()).filter(Boolean) as string[];
    const steps = (nextSteps ?? []).filter((s) => s?.title);
    const max = Number(summaryMax) > 0 ? Math.round(Number(summaryMax)) : undefined;
    const tel = (contactPhone || "").replace(/[^\d+]/g, "");
    const hasAside = Boolean(nextHeading || steps.length || deadlineNote || contactName);

    const select = (name: string, label: string, options: string[], placeholder: string) => (
      <div>
        <label htmlFor={`${uid}-${name}`} className={labelClass}>{label}</label>
        <div className="relative mt-2">
          <select id={`${uid}-${name}`} name={name} required defaultValue="" className={`appearance-none pr-10 ${inputClass}`}>
            <option value="" disabled>{placeholder}</option>
            {options.map((o, i) => (
              <option key={`${o}-${i}`} value={o}>{o}</option>
            ))}
          </select>
          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="pointer-events-none absolute top-1/2 right-3 size-5 -translate-y-1/2 text-neutral-500">
            <path fillRule="evenodd" d={chevron} clipRule="evenodd" />
          </svg>
        </div>
      </div>
    );

    return (
      <section className="bg-neutral-50 px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className={`mx-auto grid grid-cols-1 gap-12 lg:gap-16 ${hasAside ? "max-w-6xl lg:grid-cols-12" : "max-w-3xl"}`}>
          <div className={`min-w-0 ${hasAside ? "lg:col-span-7" : ""}`}>
            {heading ? <H className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">{heading}</H> : null}
            {intro ? <p className="mt-4 max-w-xl text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}

            <form action={formAction || undefined} method="post" className={`rounded-2xl bg-white p-5 shadow-xs ring-1 ring-neutral-200 sm:p-8 ${heading || intro ? "mt-10" : ""}`}>
              <p className="text-sm leading-6 text-neutral-600">All fields are required unless marked optional.</p>

              <fieldset className="mt-8">
                <legend className="text-base font-semibold text-neutral-950">Organization</legend>
                <div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-2">
                  <div className="sm:col-span-2">
                    <label htmlFor={`${uid}-org`} className={labelClass}>Legal name of organization</label>
                    <input id={`${uid}-org`} name="org_name" type="text" required autoComplete="organization" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-ein`} className={labelClass}>EIN</label>
                    <input
                      id={`${uid}-ein`}
                      name="ein"
                      type="text"
                      required
                      inputMode="numeric"
                      pattern="\d{2}-?\d{7}"
                      maxLength={10}
                      placeholder="12-3456789"
                      aria-describedby={`${uid}-ein-hint`}
                      className={`mt-2 tabular-nums ${inputClass}`}
                    />
                    <p id={`${uid}-ein-hint`} className={hintClass}>Nine digits. Fiscally sponsored projects use the sponsor&rsquo;s EIN.</p>
                  </div>
                  {budgets.length ? select("budget_size", "Annual operating budget", budgets, "Choose a range") : null}
                </div>
              </fieldset>

              <fieldset className="mt-10 border-t border-neutral-200 pt-8">
                <legend className="text-base font-semibold text-neutral-950">Contact</legend>
                <div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-2">
                  <div>
                    <label htmlFor={`${uid}-name`} className={labelClass}>Full name</label>
                    <input id={`${uid}-name`} name="contact_name" type="text" required autoComplete="name" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-title`} className={labelClass}>Title<Optional /></label>
                    <input id={`${uid}-title`} name="contact_title" type="text" autoComplete="organization-title" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-email`} className={labelClass}>Email</label>
                    <input id={`${uid}-email`} name="email" type="email" required autoComplete="email" inputMode="email" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-phone`} className={labelClass}>Phone<Optional /></label>
                    <input id={`${uid}-phone`} name="phone" type="tel" autoComplete="tel" inputMode="tel" className={`mt-2 ${inputClass}`} />
                  </div>
                </div>
              </fieldset>

              <fieldset className="mt-10 border-t border-neutral-200 pt-8">
                <legend className="text-base font-semibold text-neutral-950">Request</legend>
                <div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-2">
                  {areas.length ? select("program_area", "Program area", areas, "Choose a program area") : null}
                  <div>
                    <label htmlFor={`${uid}-amount`} className={labelClass}>Amount requested</label>
                    <div className="relative mt-2">
                      <span aria-hidden="true" className="pointer-events-none absolute top-1/2 left-3.5 -translate-y-1/2 text-base text-neutral-600">$</span>
                      <input
                        id={`${uid}-amount`}
                        name="request_amount"
                        type="text"
                        required
                        inputMode="numeric"
                        pattern="[\d,]+"
                        placeholder="25,000"
                        aria-describedby={`${uid}-amount-hint`}
                        className={`pl-7 tabular-nums ${inputClass}`}
                      />
                    </div>
                    <p id={`${uid}-amount-hint`} className={hintClass}>In U.S. dollars, whole numbers.</p>
                  </div>
                  <div className="sm:col-span-2">
                    <label htmlFor={`${uid}-summary`} className={labelClass}>Project summary</label>
                    <textarea
                      id={`${uid}-summary`}
                      name="summary"
                      rows={8}
                      required
                      minLength={100}
                      maxLength={max}
                      aria-describedby={summaryHint ? `${uid}-summary-hint` : undefined}
                      className={`mt-2 ${inputClass}`}
                    />
                    {summaryHint ? <p id={`${uid}-summary-hint`} className={hintClass}>{summaryHint}</p> : null}
                  </div>
                </div>
              </fieldset>

              <div className="mt-10 flex flex-col gap-4 border-t border-neutral-200 pt-8 sm:flex-row sm:items-center sm:gap-6">
                <button type="submit" className={`inline-flex min-h-11 shrink-0 items-center justify-center rounded-lg bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-xs transition hover:bg-indigo-700 ${focusRing}`}>
                  {submitLabel || "Submit letter of inquiry"}
                </button>
                {privacyNote ? <p className="text-sm leading-6 text-pretty text-neutral-600">{privacyNote}</p> : null}
              </div>
            </form>
          </div>

          {hasAside ? (
            <aside aria-labelledby={nextHeading ? `${uid}-next` : undefined} aria-label={nextHeading ? undefined : "What happens next"} className="lg:col-span-5">
              <div className="lg:sticky lg:top-8">
                {nextHeading ? <Sub id={`${uid}-next`} className="text-lg leading-7 font-semibold text-neutral-950">{nextHeading}</Sub> : null}
                {steps.length ? (
                  <ol role="list" className={`space-y-6 ${nextHeading ? "mt-6" : ""}`}>
                    {steps.map((s, i) => (
                      <li key={`${s.title}-${i}`} className="relative flex gap-4">
                        {i < steps.length - 1 ? <span aria-hidden="true" className="absolute top-9 -bottom-6 left-4 w-px -translate-x-1/2 bg-neutral-300" /> : null}
                        <span aria-hidden="true" className="relative grid size-8 shrink-0 place-items-center rounded-full bg-white text-sm font-semibold text-indigo-700 ring-1 ring-indigo-200 tabular-nums">{i + 1}</span>
                        <div className="min-w-0 pt-1">
                          <p className="text-base font-semibold text-neutral-950">{s.title}</p>
                          {s.body ? <p className="mt-1 text-sm leading-6 text-pretty text-neutral-600">{s.body}</p> : null}
                        </div>
                      </li>
                    ))}
                  </ol>
                ) : null}
                {deadlineNote ? (
                  <p className="mt-8 flex gap-3 rounded-xl bg-indigo-50 p-4 text-sm leading-6 font-medium text-indigo-950 ring-1 ring-indigo-600/15 ring-inset">
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 shrink-0 text-indigo-700">
                      <path fillRule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-13a.75.75 0 0 0-1.5 0v5c0 .414.336.75.75.75h4a.75.75 0 0 0 0-1.5h-3.25V5Z" clipRule="evenodd" />
                    </svg>
                    <span>{deadlineNote}</span>
                  </p>
                ) : null}
                {contactName ? (
                  <div className="mt-8 border-t border-neutral-200 pt-6 text-sm leading-6">
                    <p className="text-neutral-600">Questions before you submit?</p>
                    <p className="font-semibold text-neutral-950">{contactName}</p>
                    {contactEmail ? (
                      <a href={`mailto:${contactEmail}`} className={`-mx-1 flex min-h-11 items-center rounded px-1 font-medium break-all text-indigo-700 hover:text-indigo-900 ${focusRing}`}>{contactEmail}</a>
                    ) : null}
                    {contactPhone ? (
                      <a href={`tel:${tel}`} className={`-mx-1 -mt-2 flex min-h-11 items-center rounded px-1 font-medium text-indigo-700 tabular-nums hover:text-indigo-900 ${focusRing}`}>{contactPhone}</a>
                    ) : null}
                  </div>
                ) : null}
              </div>
            </aside>
          ) : null}
        </div>
      </section>
    );
  },
};
```
