/** * Pure, SSR-safe helpers + wire types for the public form renderer. * * These mirror the `GET /api/cms/public/forms/:slug` response shape produced by * cms-core's `buildPublicForm`. They are intentionally permissive (the data * arrives off the network as JSON) and contain NO browser APIs so they can be * unit-tested in a Node environment and imported by server components. */ import type { FormAnalyticsConfig } from '@prenta/core/forms/analytics'; /** A single renderable field, as delivered by the public form schema. */ export interface PublicFormField { id: string; key: string; label: string; type: string; required: boolean; placeholder?: string; helpText?: string; defaultValue?: unknown; options?: Array<{ label: string; value: string; }>; width?: string; sortOrder: number; } /** The public form schema (honeypot field is stripped from `fields`). */ export interface PublicForm { id: string; name: string; slug: string; description?: string; fields: PublicFormField[]; /** Relative path to POST the submission to (e.g. `/api/cms/public/forms/contact/submit`). */ submitPath: string; successMessage?: string; redirectUrl?: string; spam: { honeypotFieldKey?: string; minSubmitSeconds?: number; }; captcha?: { provider: string; siteKey: string; }; schemaVersionId?: string | null; /** GA4 tracking config — present only when tracking is enabled for the form. */ analytics?: FormAnalyticsConfig; webmcp?: { enabled: boolean; toolName: string; toolDescription: string; autoSubmit: boolean; fieldParams: Record; }; } /** * Coerce a raw JSON value into a {@link PublicForm}, or `null` when it is not a * usable form schema. Accepts either the bare form object or the API's * `{ data: form }` envelope. */ export declare function coercePublicForm(raw: unknown): PublicForm | null; /** What the renderer should do after a successful submission. */ export interface SubmitOutcome { /** When set, navigate here instead of showing a message. */ redirectUrl?: string; message: string; } /** * Resolve the post-submit behaviour from the API response. * * The submit endpoint returns `data.confirmation` as an *object* * (`{ type, message?, redirectUrl? }` — cms-core's `SubmissionConfirmation`). * A legacy string form is tolerated. Falls back to the schema's * `redirectUrl` / `successMessage`, then a generic message. */ export declare function resolveSubmitOutcome(raw: unknown, form: Pick): SubmitOutcome; /** How a public field type renders. */ export type FieldControl = 'input' | 'textarea' | 'select' | 'checkbox' | 'radio'; /** Decide which control a field type maps to. */ export declare function fieldControl(type: string): FieldControl; /** Map a field type to an `` value (control === 'input' only). */ export declare function htmlInputType(type: string): string; /** The initial value map for a form (honeypot excluded — it is a hidden field). */ export declare function initialValues(form: Pick): Record; /** Label of the first required field left empty, or `null` when all are filled. */ export declare function firstMissingRequired(form: Pick, values: Record): string | null; export interface SubmitBodyArgs { values: Record; honeypotKey?: string; honeypotValue?: string; elapsedMs?: number | null; pageUrl?: string | null; captchaToken?: string | null; attribution?: Record | null; } /** * Build the JSON body for `POST {submitPath}`. The honeypot value is merged * into `fields` under its key (it must NOT be a top-level property), matching * `parseSubmissionRequest` in cms-core. */ export declare function buildSubmitBody(args: SubmitBodyArgs): Record; //# sourceMappingURL=forms.d.ts.map