@vulcantech/forms 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,118 @@
2
2
 
3
3
  Dynamic form renderer for VulcanTech apps. Renders a form from a JSON `FormDefinition` (authored in the CMS form builder) using Formik + Yup, with sensitive-field encryption and Tailwind styling.
4
4
 
5
- **Exports**: `DynamicForm`, `DynamicFormSection`, `FormDefinition` (type), `buildYupSchema`, `buildInitialValues`, plus transform / crypto / email-template helpers.
5
+ **Exports**: `DynamicForm`, `DynamicFormSection`, `DynamicFormField`, `buildYupSchema`, `buildInitialValues`, `parseFormDefinition`, `getSafeRedirectUrl`, `renderEmailTemplate`, `encryptSensitiveValue`, the `useFormDefinition` / `useUndoRedo` / `useDragReorder` builder hooks, and the `FormDefinition` / `FormDefinitionJSON` / `FormFieldDefinition` / `FormStyle` / `FormSubmissionType` types.
6
6
 
7
- **Field types**: `text`, `email`, `phone`, `textarea`, `select`, `checkbox`, `radio`, `number`, `date`, `datetime`, `url`, `address`, `hidden`.
7
+ **Field types**: `text`, `email`, `phone`, `url`, `address`, `textarea`, `select`, `checkbox`, `radio`, `number`, `date`, `datetime`, `hidden`, `sensitive`, `file`.
8
+
9
+ ## Form shape (`FormDefinition`)
10
+
11
+ A `FormDefinition` is the CMS-authored schema for one form. Consumer sites never build it by hand — they fetch it from the CMS `GET /api/forms` and hand it to `<DynamicForm>`.
12
+
13
+ ```ts
14
+ interface FormDefinition {
15
+ id: string;
16
+ projectId?: string; // SERVER-ONLY — stripped from every client response (see below)
17
+ name: string;
18
+ slug: string; // unique per project; the CMS 409s on a collision
19
+ description?: string;
20
+ version: number; // bumped on each CMS edit; emitted as data-form-version
21
+ status: string; // "draft" | "published" | "archived" — typed as string, NOT the union
22
+ submissionType?: FormSubmissionType; // absent = "contact"; decides the target collection
23
+ bookingConfig?: FormBookingConfig; // only read when submissionType === "booking"
24
+ sections: FormSection[]; // render order is `order`, NOT array order
25
+ submitConfig: FormSubmitConfig; // button text, success/error copy, redirect, spam settings
26
+ style?: FormStyle; // absent = DEFAULT_FORM_STYLE (structure only, no colors)
27
+ defaultTextColor?: string; // hex; per-section `textColor` overrides it
28
+ metadata?: { trackAdReferral?: boolean; customFields?: Record<string, unknown> };
29
+ integrations?: FormIntegrations; // SERVER-ONLY — stripped
30
+ notificationEmailTemplate?: NotificationEmailTemplate; // SERVER-ONLY — stripped
31
+ applicationStatusEmails?: ApplicationStatusEmailTemplates; // SERVER-ONLY — stripped
32
+ createdAt: string; // ISO 8601
33
+ updatedAt: string; // ISO 8601
34
+ createdBy: string; // CMS user uid
35
+ }
36
+ ```
37
+
38
+ Field notes:
39
+
40
+ - **Four fields are server-only and will always be `undefined` on a consumer site.** The CMS strips `projectId`, `integrations`, `notificationEmailTemplate`, and `applicationStatusEmails` from every public response (`stripSensitiveFields`). Do not branch on them client-side, and never read `definition.projectId` — resolve the project from `VULCANTECH_PROJECT_ID` in your server-side proxy instead.
41
+ - **`status` is typed `string`, not `FormStatus`.** Same for the `*JSON` mirror types. Compare against the literals (`status === "published"`) rather than assuming a narrowed union. The CMS `GET /api/forms` already filters to published forms unless you pass `includeDrafts=1`, so you rarely need to check it.
42
+ - **`sections[].order` and `fields[].layout.order` drive render order**, not array position — `DynamicForm` sorts by `order` before rendering. Field width comes from `layout.width` (`"full"` / `"half"` / `"third"`) on a 6-column grid.
43
+ - **`style` is colors-optional by design.** `DEFAULT_FORM_STYLE` supplies only the structural choices (`preset`, `borderRadius`, `spacing`, `buttonVariant`, `buttonPlacement`, `sectionDividers`, `inputVariant`). Every color is optional and resolves through CSS `var()` fallbacks, so an unstyled form inherits the host page rather than forcing its own palette.
44
+ - **`FormDefinitionJSON` vs `FormDefinition`.** The strict type keeps string-literal unions; JSON parsed off a `fetch` widens them to `string` and won't assign. Type the raw value as `FormDefinitionJSON`, then call `parseFormDefinition(json)` — an unchecked structural cast that trusts the CMS, not a validator.
45
+
46
+ ### Where a submission lands (`submissionType`)
47
+
48
+ `submissionType` is read **from the form definition on the server**, never from the request body. A submission whose `formId` doesn't resolve always routes to `contact`.
49
+
50
+ | `submissionType` | Firestore collection | Notes |
51
+ | --- | --- | --- |
52
+ | `contact` (default) | `projects/{id}/contact-forms` | Values stored flat at the doc top level. |
53
+ | `application` | `projects/{id}/applications` | Values nested under `data`; adds `referenceNumber`, `status: "received"`, `statusHistory`. The route echoes `referenceNumber` back in the response. |
54
+ | `newsletter` | `projects/{id}/newsletter_subscribers` | Restricted to `email` + `checkbox` fields (`NEWSLETTER_ALLOWED_FIELD_TYPES`); checkbox ids become `preferences` booleans. A repeat email updates the existing record instead of creating one. |
55
+ | `booking` | `projects/{id}/bookings` | Values nested under `data`, plus a denormalized `date`. |
56
+
57
+ For `booking`, the CMS resolves the booking date in three steps: `bookingConfig.dateFieldId` → the first `date`/`datetime` field in render order → a top-level `date` key. **Date-only convention:** a `date` field submits `"yyyy-MM-dd"`, which parses to UTC midnight, so a stored epoch that is an exact multiple of 86,400,000 is treated as date-only and formatted in UTC; a `datetime` field submits a full ISO string and is treated as a real instant.
58
+
59
+ ## Submitting (`DynamicForm`)
60
+
61
+ `<DynamicForm definition={…} apiRoute="/api/contact" />` POSTs a **flat JSON object** to `apiRoute` — the form's own field ids as top-level keys, plus anything in `extraData`, plus `formId: definition.id`. There is no `data` or `values` wrapper. Before sending it strips the honeypot, fields hidden by an unmet `showWhen`, and the synthetic `_sameAs_*` toggles.
62
+
63
+ Your `apiRoute` is expected to be a **server-side proxy in your own app** that adds the credentials and forwards to the CMS `POST /api/contact`. The renderer never sends `projectId`, `apiKey`, or `url` — the proxy adds those. Forward the browser's body through **whole**; hand-picking fields into a new object is what silently destroys leads once the CMS re-validates the definition's required fields.
64
+
65
+ Other `DynamicForm` props: `onSuccess(data?)` (receives the parsed response body — this is how you read `referenceNumber`), `onError(error)`, `extraData`, `className`, `onFileUpload` / `fileUploadRoute` (required for `file` fields — see [Field types needing extra wiring](#field-types-needing-extra-wiring)), `onFormView` / `onFormSubmit` (analytics; they fall back to `window.__vtTrack` so a site running `@vulcantech/analytics` tracks conversions with no wiring), `transportKeyEndpoint`, and the `preview*` props used only by the CMS builder.
66
+
67
+ ### Two CMS rejections that will bite you
68
+
69
+ - **`url` binding → `400 {"error":"Invalid url"}`.** The CMS compares the submitted `url` against the project's stored `url` by exact string equality. Proxies therefore hardcode the production origin, which means **submissions from a localhost dev server are rejected**. Test against the CMS directly (or temporarily point the project's `url` at your dev origin) rather than assuming the form is broken.
70
+ - **A top-level `email` is required on every submission type.** After the credential, URL, rate-limit and honeypot gates, the CMS runs a Yup schema requiring a valid `email` and returns `400 {"error":"Validation failed","details":[…]}`. Because builder-generated field ids look like `field-1712…`, a form satisfies this only if its email field's id is literally `email`, or the proxy adds a canonical `email` key alongside the raw field ids. A second pass then re-enforces the definition's own `required` rules (skipping `showWhen`-hidden fields), reporting `"<Field label> is required"` in the same `details` array.
71
+
72
+ ### Failure mode
73
+
74
+ **`DynamicForm` never throws at the call site** — it catches everything internally, sets its own error banner, and calls `onError(error)`. There is no promise to await and no exception to catch around the component.
75
+
76
+ Three outcomes look like success but aren't a stored lead, and each is deliberate:
77
+
78
+ - **Spam (honeypot filled, or submitted faster than `minSubmitTime`, default 3s).** The renderer shows the success banner, calls `onSuccess()` **with no argument**, and makes **no network request at all**. Treat a missing argument in `onSuccess` as "no server response", not as an error.
79
+ - **Server-side honeypot.** If a filled honeypot does reach the CMS it writes the row with `status: "spam"` and still answers `200 {"success":true}` — indistinguishable from success by design.
80
+ - **Duplicate.** The CMS fingerprints each submission (all values except `apiKey`, `projectId`, `url`, `formId`, `formType`, `submittedAt`, `_hp_website`) and suppresses an identical resubmit within **10 minutes**, answering `200 {"success":true,"duplicate":true}` with the original `referenceNumber`. No second document, no second notification email. Dedupe fails open — a Firestore outage lets the write through rather than dropping a lead. Forms with sensitive fields are never fingerprinted (fresh ciphertext each submit).
81
+
82
+ Other CMS statuses reach `onError` with the server's `error` string as the message: `413` (payload over 256KB, any string over 20,000 chars, or over 100 top-level keys), `429` (60 submissions/min per IP, 200/hour per project), `401`/`403` (bad or out-of-scope API key), `400` for the two rejections above.
83
+
84
+ ### Field types needing extra wiring
85
+
86
+ - **`sensitive`** — encrypted in the browser (RSA-OAEP + AES-GCM) before submission. The renderer fetches the wrapping key from `transportKeyEndpoint`, defaulting to **`/api/forms/transport-key` on the same origin**. That route exists in the CMS, not in consumer apps, so a site with a sensitive field must either proxy it or pass an absolute CMS URL. Values arrive at the CMS as envelopes, get re-encrypted with KMS into an isolated `sensitive_data` collection, and the submission keeps only `{ sensitiveDataId, last4 }`. An envelope on a field the definition doesn't declare sensitive is rejected with `400 {"error":"Failed to process sensitive fields"}` — the usual cause is a wrong or missing `formId`.
87
+ - **`file`** — the value submitted is a URL string (or an array of them when `multiple`), never file bytes; the CMS stores it as an ordinary string. **Uploads are not automatic**: this package ships no default uploader, because a public form submitter holds no CMS credentials. Give `DynamicForm` an upload path, exactly as you give it an `apiRoute`:
88
+
89
+ ```tsx
90
+ <DynamicForm definition={def} apiRoute="/api/contact" fileUploadRoute="/api/form-upload" />
91
+ ```
92
+
93
+ `fileUploadRoute` is a route **in your own app**. It receives `POST` `multipart/form-data` with `file` (the File) and `formId`, and must answer `200 {"url": "https://…"}` (optionally `name`, `size`); on failure, answer non-2xx with `{"error": "…"}` and that message renders under the field. The returned `url` must be durable — a `blob:`/`data:` URL is rejected. For full control (a client-side SDK upload, a signed URL, progress of your own), pass `onFileUpload(file, config)` instead; it wins over `fileUploadRoute`.
94
+
95
+ **The standard implementation of that route is a thin proxy to the CMS** — copy it rather than inventing storage of your own. The CMS exposes `POST /api/forms/upload`, the credentialed counterpart to `/api/contact`: same apiKey + `url`-binding trust model, per-IP and per-project rate limits, a 10 MB hard cap, and a content-type allowlist verified against the file's magic bytes (no SVG, no HTML — both execute script when opened from the storage origin). Files land under `forms/{projectId}/uploads/…`, never the media library, so lead attachments stay out of the staff media picker, and deleting a submission deletes its attachments with it. The response is `{ url, name, size }` where `url` is a non-expiring Firebase download-token URL — chosen over a signed URL because the value is persisted verbatim on the lead and staff may open it months later.
96
+
97
+ Your route's only job is to add the credentials the browser must never hold:
98
+
99
+ ```ts
100
+ // app/api/form-upload/route.ts
101
+ const outgoing = new FormData();
102
+ outgoing.append("file", file, file.name);
103
+ outgoing.append("formId", formId);
104
+ outgoing.append("projectId", process.env.VULCANTECH_PROJECT_ID!);
105
+ outgoing.append("apiKey", process.env.VULCANTECH_API_KEY!);
106
+ outgoing.append("url", SITE_URL); // must equal the project's stored `url`
107
+ const res = await fetch(`${CMS_URL}/api/forms/upload`, { method: "POST", body: outgoing });
108
+ ```
109
+
110
+ Relay the CMS's `error` string verbatim on a non-2xx — it renders under the field, and a message like "That file's contents don't match its type" is worth the user seeing. `apps/castlerents/src/app/api/form-upload/route.ts` is the reference copy. The API key needs the `contact:write` scope (an attachment is part of a submission, so there is no new scope to provision), and — exactly as with `/api/contact` — the `url` must match the project's stored `url`, which is why localhost dev uploads always 400.
111
+
112
+ With **neither** prop set, the picker renders disabled and says so, and nothing is submitted. That is deliberate: the field previously fell back to `URL.createObjectURL` and submitted a `blob:` URL, which looked like a successful upload and arrived as an unopenable attachment on the lead. `DynamicForm` also aborts any submission still carrying a `blob:`/`data:` value rather than storing a dead link. The CMS form builder's live preview is the one exception — it keeps the local stand-in, since its submissions never leave the browser.
113
+
114
+ `FileField` is also exported for use outside `DynamicForm`, taking the same handler as an `onUpload` prop.
115
+
116
+ `fileConfig.resizeImages` (default **true**) downscales images in the browser before they reach your handler, to `fileConfig.maxImageWidth` (default **1600**). It only touches JPEG/PNG/WebP wider than the limit, keeps the original format, and hands the file over untouched if anything about the round-trip fails — GIF is skipped so an animation isn't flattened to its first frame, and HEIC/HEIF because only Safari decodes it. `maxSizeBytes` is checked against the **resized** file, so a photo that only fits once downscaled is accepted. Set `resizeImages: false` if your handler wants the original bytes.
8
117
 
9
118
  ## Integration
10
119
 
@@ -26,6 +135,8 @@ npm install @vulcantech/forms
26
135
 
27
136
  **4. Server fetcher** `src/lib/cms/forms.ts` — ISR-cached wrapper over the CMS `/api/forms`. Exposes `getFormById(id)` / `getFormBySlug(slug)`; tags each fetch `form:{projectId}:{formId}` + `forms:{projectId}`; returns `null` on failure so the page still renders.
28
137
 
138
+ `GET /api/forms` takes its credentials as **query params, not headers**: `projectId` and `apiKey` (required, scope `forms:read`), then `formId` **or** `slug` to fetch one form (`formId` wins if both are sent), and optional `includeDrafts=1` to bypass the published-only filter. With neither `formId` nor `slug` it returns `{ forms: [{ id, name, slug, status, updatedAt }] }`. A single form comes back as the definition object itself with `id` set from the Firestore doc id. It answers `404 {"error":"Form not found"}` for a missing, deleted, or unpublished form, and sends `Cache-Control: private, no-store` deliberately — caching is the consumer's job via Next fetch tags plus `/api/revalidate`.
139
+
29
140
  **5. Per-form loader** `src/lib/cms/load<Name>Form.ts` — pin the form's Firestore id and wrap the fetcher with a fallback:
30
141
  ```ts
31
142
  import { getFormById } from "./forms";
@@ -49,16 +160,19 @@ export function ContactForm({ definition }: { definition?: FormDefinition }) {
49
160
  }
50
161
  ```
51
162
 
52
- **7. ISR invalidation** — ensure `src/app/api/revalidate/route.ts` exists; the CMS purges `form:{projectId}:{formId}` (single) and `forms:{projectId}` (list) on edit.
163
+ **7. ISR invalidation** — ensure `src/app/api/revalidate/route.ts` exists, set `VULCANTECH_REVALIDATE_SECRET`, and register the site under **Settings → Form Consumers (ISR Revalidation)** in the CMS. The CMS purges `form:{projectId}:{formId}` (single) and `forms:{projectId}` (list) on edit. This is the same route and consumer entry the blog, banners, and SEO-files dispatchers use — one per site. Route contract and reference copy: the `@vulcantech/cms` README, [ISR revalidation](../cms/README.md#isr-revalidation).
164
+
165
+ **8. File-upload proxy (only if any form has a `file` field)** — add `src/app/api/form-upload/route.ts` and pass `fileUploadRoute="/api/form-upload"` alongside `apiRoute`. The route re-posts the multipart body to the CMS `/api/forms/upload` with `projectId` / `apiKey` / `url` attached server-side, and relays the CMS's `error` string on failure. See [Field types needing extra wiring](#field-types-needing-extra-wiring) for the full contract and `apps/castlerents/src/app/api/form-upload/route.ts` for the reference copy. Without it a `file` field renders a disabled picker saying uploads aren't configured.
53
166
 
54
167
  ### Required env
55
- `VULCANTECH_PROJECT_ID`, `VULCANTECH_API_KEY` (required) · `VULCANTECH_CMS_URL` (optional) · `VULCANTECH_FORMS_NO_CACHE` (optional, `1`/`true` to bypass ISR).
168
+ `VULCANTECH_PROJECT_ID`, `VULCANTECH_API_KEY` (required) · `VULCANTECH_REVALIDATE_SECRET` (required for instant ISR purges; see step 7) · `VULCANTECH_CMS_URL` (optional) · `VULCANTECH_FORMS_NO_CACHE` (optional, `1`/`true` to bypass ISR).
56
169
 
57
170
  ### Per-app values
58
171
  - **Form definition ID(s)** — Firestore doc id from the CMS admin (one per form), pinned in `load<Name>Form.ts` (e.g. `CONTACT_FORM_ID`, `SERVICE_REQUEST_FORM_ID`).
59
172
 
60
173
  ### Notes
61
- - `FormDefinition` is the CMS-authored schema (sections, fields, submit config, style).
174
+ - `FormDefinition` is the CMS-authored schema (sections, fields, submit config, style) — see [Form shape](#form-shape-formdefinition) above.
62
175
  - `style.buttonPlacement: "inline"` renders the submit button beside the fields instead of full-width below them — suited to single-field forms (newsletter email + Join). Editable in the CMS form builder under Style → Submit Button → Button Placement.
63
176
  - Newsletter forms (`submissionType: "newsletter"`) should submit to an app route that proxies to the CMS `/api/contact` — the CMS routes them into `newsletter_subscribers`.
177
+ - `submitConfig.redirectUrl` takes precedence over `successBehavior` on genuine submissions (typically a thank-you page for ad conversion tracking). It fires only on a real success — the spam path deliberately stays on-page so a detected bot never triggers the conversion tag. Values are passed through `getSafeRedirectUrl`, which accepts absolute http(s) URLs and site-relative paths only.
64
178
  - The package also ships `buildYupSchema` / `buildInitialValues` for custom render paths, but consumer sites use the server-fetcher pattern above for ISR caching.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Yup from 'yup';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
3
  import { CSSProperties, DragEvent } from 'react';
4
4
 
5
5
  type FieldType = "text" | "email" | "phone" | "url" | "address" | "textarea" | "select" | "checkbox" | "radio" | "number" | "date" | "datetime" | "hidden" | "sensitive" | "file";
@@ -74,9 +74,17 @@ interface SensitiveFieldConfig {
74
74
  }
75
75
  declare const DEFAULT_SENSITIVE_FIELD_CONFIG: SensitiveFieldConfig;
76
76
  /**
77
- * Configuration for the `file` field type. Files are uploaded to
78
- * Firebase Storage client-side; the form submission receives the
79
- * download URL(s) rather than raw file data.
77
+ * Configuration for the `file` field type. Files are uploaded by the
78
+ * consuming app before submit; the form submission receives the resulting
79
+ * URL(s) rather than raw file data — a string, or an array of strings when
80
+ * `multiple`. The CMS stores whatever string arrives and does nothing
81
+ * file-specific with it.
82
+ *
83
+ * Uploads are NOT automatic: a form containing a `file` field must be given
84
+ * an upload path via `DynamicForm`'s `onFileUpload` or `fileUploadRoute`
85
+ * prop (see {@link FormFileUploadHandler}). Without one the picker renders
86
+ * disabled with an explanatory message rather than silently submitting a
87
+ * throwaway `blob:` URL.
80
88
  */
81
89
  interface FileFieldConfig {
82
90
  /** Accepted MIME types. Default: "image/*" */
@@ -88,14 +96,48 @@ interface FileFieldConfig {
88
96
  /** Max number of files when multiple=true. Default: 5. */
89
97
  maxFiles?: number;
90
98
  /**
91
- * Resize images before upload. Default: true.
92
- * When true, images are scaled to maxImageWidth and compressed.
99
+ * Downscale images in the browser before handing them to the upload
100
+ * handler. Default: true.
101
+ *
102
+ * Applies only to JPEG, PNG and WebP, and only when the image is wider
103
+ * than {@link FileFieldConfig.maxImageWidth}; the format is preserved and
104
+ * anything that can't be re-encoded (GIF — a canvas round-trip would drop
105
+ * the animation, HEIC/HEIF, SVG, a file this browser can't decode) is
106
+ * uploaded untouched. `maxSizeBytes` is checked against the resized file,
107
+ * so a large photo that fits once downscaled is accepted.
93
108
  */
94
109
  resizeImages?: boolean;
95
- /** Max image width for resize. Default: 1600. */
110
+ /** Max image width in pixels when `resizeImages`. Default: 1600. */
96
111
  maxImageWidth?: number;
97
112
  }
98
113
  declare const DEFAULT_FILE_FIELD_CONFIG: FileFieldConfig;
114
+ /**
115
+ * A file that has finished uploading. `url` is the value the form submits
116
+ * for the field (or one entry of the array, when `multiple`), so it must be
117
+ * durable and reachable outside the submitting browser tab — never a
118
+ * `blob:` or `data:` URL.
119
+ */
120
+ interface UploadedFormFile {
121
+ /** Stored, publicly reachable URL. */
122
+ url: string;
123
+ /** Display name, shown in the field's file list. */
124
+ name: string;
125
+ /** Size in bytes, shown in the field's file list. */
126
+ size: number;
127
+ }
128
+ /**
129
+ * Uploads one picked file and resolves with its stored location.
130
+ *
131
+ * Supplied by the consuming app — this package deliberately ships no
132
+ * default implementation, because a public form submitter holds no CMS
133
+ * credentials. The usual shape mirrors `DynamicForm`'s `apiRoute`: POST the
134
+ * file to a server-side route in your own app, which holds the credentials
135
+ * and writes to storage, then return the stored URL.
136
+ *
137
+ * Called once per file, sequentially. Throw to fail the file — the message
138
+ * is shown inline under the picker and no value is recorded.
139
+ */
140
+ type FormFileUploadHandler = (file: File, config: FileFieldConfig) => Promise<UploadedFormFile>;
99
141
  interface FormFieldDefinition {
100
142
  id: string;
101
143
  type: FieldType;
@@ -260,11 +302,47 @@ type FormStatus = "draft" | "published" | "archived";
260
302
  * (optional, for preferences/consent) fields. Duplicate emails within a
261
303
  * project update the existing record's preferences rather than creating
262
304
  * a new entry.
305
+ * - `booking`: writes to the project's `bookings` subcollection and surfaces
306
+ * in the Bookings dashboard. The submitted values are stored like an
307
+ * application (nested `data` map), plus a denormalized booking `date`
308
+ * (epoch ms) parsed from the form's designated date field — see
309
+ * {@link FormBookingConfig}.
263
310
  *
264
311
  * Only the routing changes — spam protection, sensitive field handling,
265
312
  * notification emails, and integrations behave identically.
266
313
  */
267
- type FormSubmissionType = "contact" | "application" | "newsletter";
314
+ type FormSubmissionType = "contact" | "application" | "newsletter" | "booking";
315
+ /**
316
+ * Booking settings for a form with `submissionType: "booking"`. The renderer
317
+ * is unaffected — booking forms submit exactly like any other form; the CMS
318
+ * submission route uses this config to pull the booking date(s) out of the
319
+ * submitted values.
320
+ *
321
+ * Date-only convention: a `date` field submits `"yyyy-MM-dd"`, which parses
322
+ * to UTC midnight, so a stored epoch that is an exact multiple of a day is
323
+ * treated as date-only and displayed in UTC. A `datetime` field submits a
324
+ * full ISO string and is stored as a real instant. An unparseable value is
325
+ * stored as an explicit `null` rather than a fabricated date.
326
+ */
327
+ interface FormBookingConfig {
328
+ /**
329
+ * Field id of the `date`/`datetime` field holding the booking date (the
330
+ * start date, when `endDateFieldId` is also set). When omitted, the
331
+ * submission route falls back to the form's first date/datetime field in
332
+ * render order, and then to a top-level `date` key on the submission.
333
+ */
334
+ dateFieldId?: string;
335
+ /**
336
+ * Optional second `date`/`datetime` field id for begin/end bookings.
337
+ * Bookings without an end date use `defaultDurationMinutes` instead.
338
+ */
339
+ endDateFieldId?: string;
340
+ /**
341
+ * Default duration (minutes) stamped onto each new booking. Individual
342
+ * bookings can be overridden afterwards in the Bookings dashboard.
343
+ */
344
+ defaultDurationMinutes?: number;
345
+ }
268
346
  /**
269
347
  * Field types allowed on a newsletter form. Enforced by the form builder UI
270
348
  * and (defensively) by the submission route. Keep in sync with
@@ -311,6 +389,16 @@ declare const APPLICATION_STATUS_KEYS: ApplicationStatusKey[];
311
389
  */
312
390
  type ApplicationStatusEmailTemplates = Partial<Record<ApplicationStatusKey, NotificationEmailTemplate>>;
313
391
  declare const DEFAULT_APPLICATION_STATUS_EMAIL_TEMPLATES: Record<ApplicationStatusKey, NotificationEmailTemplate>;
392
+ /**
393
+ * The CMS-authored schema for one form — the value `DynamicForm` renders and
394
+ * the CMS submission route consults to route and validate a submission.
395
+ *
396
+ * Consumer sites fetch this from `GET /api/forms` rather than building it.
397
+ * Four fields are stripped from every client-facing response by the CMS
398
+ * (`stripSensitiveFields`) and are therefore always `undefined` outside the
399
+ * CMS server: `projectId`, `integrations`, `notificationEmailTemplate`, and
400
+ * `applicationStatusEmails`.
401
+ */
314
402
  interface FormDefinition {
315
403
  id: string;
316
404
  /**
@@ -323,17 +411,37 @@ interface FormDefinition {
323
411
  */
324
412
  projectId?: string;
325
413
  name: string;
414
+ /** Unique within a project — the CMS rejects a colliding slug with a 409. */
326
415
  slug: string;
327
416
  description?: string;
417
+ /** Bumped on every CMS edit. Emitted by the renderer as `data-form-version`. */
328
418
  version: number;
419
+ /**
420
+ * FormStatus values: "draft" | "published" | "archived".
421
+ *
422
+ * Deliberately typed `string`, not the {@link FormStatus} union, because
423
+ * definitions cross a JSON boundary. Compare against the literals. The
424
+ * public GET route already filters to published forms unless the caller
425
+ * passes `includeDrafts=1`.
426
+ */
329
427
  status: string;
330
428
  /**
331
429
  * Routes submissions to the matching dashboard collection.
332
430
  * Defaults to `"contact"` when omitted. See {@link FormSubmissionType}.
431
+ *
432
+ * Read server-side from this definition, never from the request body — a
433
+ * submission whose `formId` does not resolve always routes to `contact`.
333
434
  */
334
435
  submissionType?: FormSubmissionType;
436
+ /**
437
+ * Booking settings. Only consulted when `submissionType === "booking"`.
438
+ * See {@link FormBookingConfig}.
439
+ */
440
+ bookingConfig?: FormBookingConfig;
441
+ /** Rendered in `order`, not array order — the renderer sorts before rendering. */
335
442
  sections: FormSection[];
336
443
  submitConfig: FormSubmitConfig;
444
+ /** Absent = {@link DEFAULT_FORM_STYLE} (structure only; colors stay unset). */
337
445
  style?: FormStyle;
338
446
  /**
339
447
  * Optional hex color applied as the default text color for every section
@@ -346,15 +454,19 @@ interface FormDefinition {
346
454
  trackAdReferral?: boolean;
347
455
  customFields?: Record<string, unknown>;
348
456
  };
457
+ /** Server-only — stripped from client-facing responses like `projectId`. */
349
458
  integrations?: FormIntegrations;
350
459
  /**
351
460
  * Customizable email sent to project members when a submission arrives.
352
461
  * Falls back to `DEFAULT_NOTIFICATION_EMAIL_TEMPLATE` when undefined.
462
+ *
463
+ * Server-only — stripped from client-facing responses like `projectId`.
353
464
  */
354
465
  notificationEmailTemplate?: NotificationEmailTemplate;
355
466
  /**
356
467
  * Per-status applicant-facing email templates. Only consulted when
357
- * `submissionType === "application"`. Missing entries fall back to
468
+ * `submissionType === "application"`. Server-only — stripped from
469
+ * client-facing responses like `projectId`. Missing entries fall back to
358
470
  * `DEFAULT_APPLICATION_STATUS_EMAIL_TEMPLATES[status]`. Set to an empty
359
471
  * object to opt every status into the defaults explicitly.
360
472
  */
@@ -419,6 +531,8 @@ interface FormFieldDefinitionJSON {
419
531
  datetimeConfig?: DatetimeConfig;
420
532
  showWhen?: FieldVisibilityCondition;
421
533
  sensitiveConfig?: SensitiveFieldConfigJSON;
534
+ /** No narrowed unions, so the strict type is reused. */
535
+ fileConfig?: FileFieldConfig;
422
536
  }
423
537
  interface FormSectionJSON {
424
538
  id: string;
@@ -476,6 +590,8 @@ interface FormDefinitionJSON {
476
590
  version: number;
477
591
  status: string;
478
592
  submissionType?: string;
593
+ /** See {@link FormDefinition.bookingConfig} — no narrowed unions, so the strict type is reused. */
594
+ bookingConfig?: FormBookingConfig;
479
595
  sections: FormSectionJSON[];
480
596
  submitConfig: FormSubmitConfigJSON;
481
597
  style?: FormStyleJSON;
@@ -643,6 +759,42 @@ declare function renderNotificationEmail(template: NotificationEmailTemplate, va
643
759
  html: string;
644
760
  };
645
761
 
762
+ /**
763
+ * Client-side image downscaling for `file` fields.
764
+ *
765
+ * A phone camera hands the picker a 4000px, several-megabyte photo for what
766
+ * is almost always displayed as a thumbnail on a lead. Downscaling in the
767
+ * browser — before the bytes leave it — is the only place that saves the
768
+ * submitter's upload time as well as our storage.
769
+ *
770
+ * The rule this module follows everywhere: **never lose a file to an
771
+ * optimisation.** Every failure path (an undecodable file, a browser without
772
+ * the APIs, an encoder that returns nothing, a re-encode that came out
773
+ * bigger) returns the original `File` unchanged, so the worst case is the
774
+ * behaviour we had before resizing existed.
775
+ */
776
+ /**
777
+ * Scale an image file down so it is at most `maxWidth` pixels wide,
778
+ * re-encoding it in its original format.
779
+ *
780
+ * Only images narrower-or-equal to the limit, unsupported formats, and files
781
+ * this environment cannot decode are left alone — everything else comes back
782
+ * as a new `File` carrying the same name, type and `lastModified`, so the
783
+ * upload handler and the CMS's magic-byte check see an ordinary picked file.
784
+ *
785
+ * EXIF orientation is baked into the pixels (`imageOrientation: "from-image"`),
786
+ * which is what a browser would have rendered anyway; the resized copy carries
787
+ * no EXIF of its own, so a rotated photo stays upright without the metadata
788
+ * that made it so.
789
+ *
790
+ * @param file - The picked file.
791
+ * @param maxWidth - Maximum width in pixels. Non-positive or non-finite
792
+ * values disable resizing.
793
+ * @returns The downscaled file, or the original when resizing was skipped or
794
+ * failed. Never rejects.
795
+ */
796
+ declare function resizeImageFile(file: File, maxWidth: number): Promise<File>;
797
+
646
798
  /**
647
799
  * Client-side encryption utilities for sensitive form fields.
648
800
  *
@@ -698,17 +850,81 @@ declare function encryptSensitiveValue(plaintext: string, publicKey: TransportPu
698
850
  declare function deriveLast4(plaintext: string): string;
699
851
 
700
852
  interface DynamicFormProps {
853
+ /**
854
+ * The CMS-authored schema, normally fetched from `GET /api/forms`. Note
855
+ * that `projectId`, `integrations`, `notificationEmailTemplate` and
856
+ * `applicationStatusEmails` are stripped from client-facing responses, so
857
+ * they are always undefined here — never read `definition.projectId`.
858
+ */
701
859
  definition: FormDefinition;
860
+ /**
861
+ * Endpoint this form POSTs to — expected to be a server-side proxy in the
862
+ * consuming app that adds credentials and forwards to the CMS
863
+ * `POST /api/contact`.
864
+ *
865
+ * The body is a FLAT JSON object: the definition's field ids as top-level
866
+ * keys, plus `extraData`, plus `formId`. There is no `data`/`values`
867
+ * wrapper. The honeypot, fields hidden by an unmet `showWhen`, and the
868
+ * synthetic `_sameAs_*` toggles are stripped before sending. The renderer
869
+ * never sends `projectId` / `apiKey` / `url` — the proxy must add those,
870
+ * and must forward the browser's body WHOLE (hand-picking fields into a
871
+ * new object drops values the CMS then rejects as required).
872
+ *
873
+ * Two CMS rejections to expect: `url` must exactly equal the project's
874
+ * stored URL (so localhost dev submissions get `400 "Invalid url"`), and
875
+ * a top-level `email` key is required on every submission type.
876
+ */
702
877
  apiRoute: string;
703
878
  /**
704
879
  * Called after a successful submission. The argument is the parsed JSON
705
880
  * response body, when one was returned — application submissions echo
706
881
  * `{ success: true, referenceNumber: "APP-…" }` here so the consumer
707
882
  * can display it on its confirmation page.
883
+ *
884
+ * Also fired on the spam path (honeypot filled or submitted faster than
885
+ * `minSubmitTime`) with NO argument and no network request at all — treat
886
+ * a missing argument as "no server response", not as an error.
708
887
  */
709
888
  onSuccess?: (data?: unknown) => void;
889
+ /**
890
+ * Called when the submission fails. `DynamicForm` catches everything
891
+ * internally and never throws at the call site, so this callback is the
892
+ * only error channel. The message is the CMS `error` string when one was
893
+ * returned (e.g. "Invalid url", "Validation failed"), otherwise
894
+ * `Submission failed (<status>)`.
895
+ */
710
896
  onError?: (error: Error) => void;
897
+ /** Extra top-level keys merged into the payload alongside the field values. */
711
898
  extraData?: Record<string, unknown>;
899
+ /**
900
+ * Upload path for `file` fields. Called once per picked file; resolve with
901
+ * the stored URL, which becomes the field's submitted value.
902
+ *
903
+ * There is no default — a public form submitter holds no CMS credentials,
904
+ * so the upload has to go through a route in the consuming app, exactly
905
+ * like {@link DynamicFormProps.apiRoute}. Use {@link DynamicFormProps.fileUploadRoute}
906
+ * for the standard multipart wiring, or this prop for full control.
907
+ *
908
+ * A definition containing a `file` field with neither prop set renders the
909
+ * picker disabled with an explanatory message — it will NOT fall back to a
910
+ * throwaway `blob:` URL, which used to look like a successful upload and
911
+ * arrive as an unopenable attachment on the lead.
912
+ */
913
+ onFileUpload?: FormFileUploadHandler;
914
+ /**
915
+ * Convenience alternative to {@link DynamicFormProps.onFileUpload}: an
916
+ * endpoint in the consuming app that accepts one file and returns its
917
+ * stored location.
918
+ *
919
+ * Request: `POST <fileUploadRoute>` with `multipart/form-data` carrying
920
+ * `file` (the File) and `formId` (the definition id).
921
+ * Response: `200` with JSON `{ url: string, name?: string, size?: number }`.
922
+ * `url` must be durable — a `blob:`/`data:` URL is rejected. On failure,
923
+ * answer non-2xx with `{ error }` and the message is shown under the field.
924
+ *
925
+ * Ignored when `onFileUpload` is set.
926
+ */
927
+ fileUploadRoute?: string;
712
928
  className?: string;
713
929
  /**
714
930
  * Endpoint that returns the RSA-OAEP transport public key used to wrap the
@@ -716,6 +932,10 @@ interface DynamicFormProps {
716
932
  * `/api/forms/transport-key` (resolved against the same origin).
717
933
  *
718
934
  * The endpoint must respond with `{ kid: string, jwk: JsonWebKey }`.
935
+ *
936
+ * That route lives in the CMS, not in consumer apps — a consumer site with
937
+ * a sensitive field must either proxy it or pass an absolute CMS URL here.
938
+ * Only fetched when the definition actually contains a sensitive field.
719
939
  */
720
940
  transportKeyEndpoint?: string;
721
941
  /**
@@ -754,7 +974,21 @@ interface DynamicFormProps {
754
974
  */
755
975
  previewTextColor?: string;
756
976
  }
757
- declare const DynamicForm: ({ definition, apiRoute, onSuccess, onError, extraData, className, onFormView, onFormSubmit: onFormSubmitCallback, transportKeyEndpoint, previewState, previewTouchAllSignal, previewUntouchAllSignal, previewBg, previewTextColor, }: DynamicFormProps) => react_jsx_runtime.JSX.Element;
977
+ /**
978
+ * Render a CMS-authored {@link FormDefinition} as a working form.
979
+ *
980
+ * Sections and fields render in `order` (not array order); validation comes
981
+ * from `buildYupSchema(definition)`; sensitive fields are encrypted in the
982
+ * browser before submission. Submission goes to {@link DynamicFormProps.apiRoute}
983
+ * as a flat JSON payload — see that prop for the wire contract.
984
+ *
985
+ * Failure mode: this component never throws. Network and CMS errors are
986
+ * caught, shown in the built-in error banner, and reported via `onError`.
987
+ * Note that a suppressed duplicate (an identical resubmit within 10 minutes)
988
+ * and a server-side spam catch both answer `200` and are indistinguishable
989
+ * from a stored lead by design.
990
+ */
991
+ declare const DynamicForm: ({ definition, apiRoute, onSuccess, onError, extraData, onFileUpload, fileUploadRoute, className, onFormView, onFormSubmit: onFormSubmitCallback, transportKeyEndpoint, previewState, previewTouchAllSignal, previewUntouchAllSignal, previewBg, previewTextColor, }: DynamicFormProps) => react.JSX.Element;
758
992
 
759
993
  /**
760
994
  * Single source of truth for the CSS custom properties the renderer publishes
@@ -826,6 +1060,47 @@ declare const FORM_VAR: {
826
1060
  */
827
1061
  declare function buildFormCssVars(style: FormStyle, previewBg?: string): CSSProperties;
828
1062
 
1063
+ /**
1064
+ * The upload path `DynamicForm` publishes to the `file` fields beneath it.
1065
+ *
1066
+ * Threaded by context rather than by prop because `FileField` sits two
1067
+ * levels down (section → field) and no intermediate component has any other
1068
+ * reason to know about uploads.
1069
+ */
1070
+ interface FormFileUploadContextValue {
1071
+ /**
1072
+ * Uploads a picked file and returns its stored URL. Undefined means the
1073
+ * consuming app wired no upload path — file fields then render disabled
1074
+ * instead of submitting an unusable value.
1075
+ */
1076
+ upload?: FormFileUploadHandler;
1077
+ /**
1078
+ * Builder-preview escape hatch: allows `FileField` to stand in a local
1079
+ * `URL.createObjectURL` value when no `upload` is set. Only ever true in
1080
+ * the CMS form builder, where submissions are short-circuited and the
1081
+ * throwaway URL can't reach a lead.
1082
+ */
1083
+ allowObjectUrlFallback?: boolean;
1084
+ }
1085
+ declare const useFormFileUpload: () => FormFileUploadContextValue;
1086
+ declare const FormFileUploadProvider: react.Provider<FormFileUploadContextValue>;
1087
+
1088
+ interface Props$2 {
1089
+ field: FormFieldDefinition;
1090
+ /** Project ID for storage path. Passed from the form renderer. */
1091
+ projectId?: string;
1092
+ /**
1093
+ * Upload handler. Normally supplied through `DynamicForm`'s
1094
+ * `onFileUpload` / `fileUploadRoute` prop (delivered by context); pass it
1095
+ * here when rendering `FileField` outside a `DynamicForm`. This prop wins
1096
+ * over the context value.
1097
+ */
1098
+ onUpload?: FormFileUploadHandler;
1099
+ /** When true (mirrored/locked), the picker is read-only. */
1100
+ disabled?: boolean;
1101
+ }
1102
+ declare const FileField: ({ field: fieldDef, onUpload, disabled }: Props$2) => react.JSX.Element;
1103
+
829
1104
  interface Props$1 {
830
1105
  section: FormSection;
831
1106
  isLast?: boolean;
@@ -842,7 +1117,7 @@ interface Props$1 {
842
1117
  */
843
1118
  inlineSubmit?: React.ReactNode;
844
1119
  }
845
- declare const DynamicFormSection: ({ section, isLast, formDefaultTextColor, inlineSubmit, }: Props$1) => react_jsx_runtime.JSX.Element;
1120
+ declare const DynamicFormSection: ({ section, isLast, formDefaultTextColor, inlineSubmit, }: Props$1) => react.JSX.Element;
846
1121
 
847
1122
  interface Props {
848
1123
  field: FormFieldDefinition;
@@ -851,7 +1126,7 @@ interface Props {
851
1126
  /** How a mirrored target renders while the toggle is on. */
852
1127
  mirrorBehavior?: "hide" | "lock";
853
1128
  }
854
- declare const DynamicFormField: ({ field, mirrored, mirrorBehavior }: Props) => react_jsx_runtime.JSX.Element | null;
1129
+ declare const DynamicFormField: ({ field, mirrored, mirrorBehavior }: Props) => react.JSX.Element | null;
855
1130
 
856
1131
  interface BaseFetchOptions {
857
1132
  cmsUrl: string;
@@ -974,4 +1249,4 @@ interface UseDragReorderResult extends DragReorderState {
974
1249
  */
975
1250
  declare function useDragReorder<T>({ items, getId, onReorder, dragType, }: UseDragReorderOptions<T>): UseDragReorderResult;
976
1251
 
977
- export { APPLICATION_STATUS_KEYS, type ApplicationStatusEmailTemplates, type ApplicationStatusKey, CORE_EMAIL_TEMPLATE_VARIABLES, DEFAULT_APPLICATION_STATUS_EMAIL_TEMPLATES, DEFAULT_FILE_FIELD_CONFIG, DEFAULT_FORM_STYLE, DEFAULT_NOTIFICATION_EMAIL_HTML, DEFAULT_NOTIFICATION_EMAIL_SUBJECT, DEFAULT_NOTIFICATION_EMAIL_TEMPLATE, DEFAULT_SENSITIVE_FIELD_CONFIG, DEFAULT_SPAM_PROTECTION, type DatetimeConfig, type DragReorderItemHandlers, type DragReorderState, type DropPosition, DynamicForm, DynamicFormField, DynamicFormSection, type EmailTemplateVariableDescriptor, type EmailTemplateVariables, type EncryptedSensitiveValue, FORM_CSS_VAR, FORM_DEFAULT_COLOR, FORM_VAR, type FieldOption, type FieldTransform, type FieldType, type FieldVisibilityCondition, type FieldWidth, type FileFieldConfig, type FormDefinition, type FormDefinitionJSON, type FormFieldDefinition, type FormFieldDefinitionJSON, type FormIdentifier, type FormIntegrationConfig, type FormIntegrationConfigJSON, type FormIntegrations, type FormIntegrationsJSON, type FormSection, type FormSectionJSON, type FormSpamProtectionConfig, type FormStatus, type FormStyle, type FormStyleJSON, type FormStylePreset, type FormSubmissionType, type FormSubmitConfig, type FormSubmitConfigJSON, type FormSuccessBehavior, HONEYPOT_FIELD_NAME, type InputVariant, type IntegrationFieldMappingEntry, type IntegrationFieldMappingEntryJSON, NEWSLETTER_ALLOWED_FIELD_TYPES, type NotificationEmailTemplate, SAME_AS_TOGGLE_PREFIX, SAMPLE_EMAIL_TEMPLATE_VARIABLES, type SectionSameAsConfig, type SensitiveFieldConfig, type SensitiveFieldConfigJSON, type SetStateUpdater, type TextTransform, type TransportPublicKey, type UseDragReorderOptions, type UseDragReorderResult, type UseFormDefinitionOptions, type UseUndoRedoControls, type UseUndoRedoOptions, type UseUndoRedoReturn, type ValidationRule, type ValidationRuleJSON, type VisibilityOperator, applyTextTransform, applyTransform, base64ToBuffer, bufferToBase64, buildEmailTemplateVariables, buildFormCssVars, buildInitialValues, buildYupSchema, deriveLast4, encryptSensitiveValue, formatSsn, formatUsPhone, getFormDefinition, getSafeRedirectUrl, isVisibilityConditionMet, parseFormDefinition, renderEmailTemplate, renderNotificationEmail, sameAsToggleKey, useDragReorder, useFormDefinition, useUndoRedo, useUndoRedoShortcuts };
1252
+ export { APPLICATION_STATUS_KEYS, type ApplicationStatusEmailTemplates, type ApplicationStatusKey, CORE_EMAIL_TEMPLATE_VARIABLES, DEFAULT_APPLICATION_STATUS_EMAIL_TEMPLATES, DEFAULT_FILE_FIELD_CONFIG, DEFAULT_FORM_STYLE, DEFAULT_NOTIFICATION_EMAIL_HTML, DEFAULT_NOTIFICATION_EMAIL_SUBJECT, DEFAULT_NOTIFICATION_EMAIL_TEMPLATE, DEFAULT_SENSITIVE_FIELD_CONFIG, DEFAULT_SPAM_PROTECTION, type DatetimeConfig, type DragReorderItemHandlers, type DragReorderState, type DropPosition, DynamicForm, DynamicFormField, DynamicFormSection, type EmailTemplateVariableDescriptor, type EmailTemplateVariables, type EncryptedSensitiveValue, FORM_CSS_VAR, FORM_DEFAULT_COLOR, FORM_VAR, type FieldOption, type FieldTransform, type FieldType, type FieldVisibilityCondition, type FieldWidth, FileField, type FileFieldConfig, type FormBookingConfig, type FormDefinition, type FormDefinitionJSON, type FormFieldDefinition, type FormFieldDefinitionJSON, type FormFileUploadContextValue, type FormFileUploadHandler, FormFileUploadProvider, type FormIdentifier, type FormIntegrationConfig, type FormIntegrationConfigJSON, type FormIntegrations, type FormIntegrationsJSON, type FormSection, type FormSectionJSON, type FormSpamProtectionConfig, type FormStatus, type FormStyle, type FormStyleJSON, type FormStylePreset, type FormSubmissionType, type FormSubmitConfig, type FormSubmitConfigJSON, type FormSuccessBehavior, HONEYPOT_FIELD_NAME, type InputVariant, type IntegrationFieldMappingEntry, type IntegrationFieldMappingEntryJSON, NEWSLETTER_ALLOWED_FIELD_TYPES, type NotificationEmailTemplate, SAME_AS_TOGGLE_PREFIX, SAMPLE_EMAIL_TEMPLATE_VARIABLES, type SectionSameAsConfig, type SensitiveFieldConfig, type SensitiveFieldConfigJSON, type SetStateUpdater, type TextTransform, type TransportPublicKey, type UploadedFormFile, type UseDragReorderOptions, type UseDragReorderResult, type UseFormDefinitionOptions, type UseUndoRedoControls, type UseUndoRedoOptions, type UseUndoRedoReturn, type ValidationRule, type ValidationRuleJSON, type VisibilityOperator, applyTextTransform, applyTransform, base64ToBuffer, bufferToBase64, buildEmailTemplateVariables, buildFormCssVars, buildInitialValues, buildYupSchema, deriveLast4, encryptSensitiveValue, formatSsn, formatUsPhone, getFormDefinition, getSafeRedirectUrl, isVisibilityConditionMet, parseFormDefinition, renderEmailTemplate, renderNotificationEmail, resizeImageFile, sameAsToggleKey, useDragReorder, useFormDefinition, useFormFileUpload, useUndoRedo, useUndoRedoShortcuts };