/** Shared types used by both the server route and the client form. */ export type FieldType = 'text' | 'email' | 'tel' | 'url' | 'textarea' | 'select' export interface ContactField { /** Field key — used in the request body, validation and email. */ name: string /** Human label shown in the form and the notification email. */ label: string /** Input kind. Defaults to `'text'`. */ type?: FieldType /** Whether the field is required. Defaults to `false`. */ required?: boolean /** Max accepted length. Defaults per type (text 200, email 254, textarea 5000…). */ maxLength?: number /** Placeholder shown in the input. */ placeholder?: string /** Native `autocomplete` attribute hint. */ autoComplete?: string /** Options for `type: 'select'`. */ options?: ReadonlyArray<{ value: string; label: string }> /** * Render this field as a highlighted block (full-width box, preserves * line breaks) in the email rather than a one-line table row. * `textarea` fields are treated as blocks automatically. */ block?: boolean } /** A validated, trimmed submission: every configured field name → string value. */ export type ContactData = Record /** * Locale-agnostic error codes the route returns in `{ success: false, error }`. * The client maps each code to localized copy via the `messages` prop. */ export type ContactErrorCode = | 'invalid_request' | 'missing_fields' | 'invalid_email' | 'too_long' | 'rate_limited' | 'captcha_failed' | 'server_error' /** Successful response body. */ export interface ContactSuccessResponse { success: true } /** Failure response body. */ export interface ContactErrorResponse { success: false error: ContactErrorCode } export type ContactResponse = ContactSuccessResponse | ContactErrorResponse