Form Presets
FORM_PRESETS is a catalogue of complete forms (not single fields — for those see the Field Library). Each preset is a serializable FormConfig: English base strings, a Spanish overlay in i18n.translations.es, and validation as plain ValidationRules.
It lives in a lean, data-only subpath, so the root bundle does not grow:
import { FORM_PRESETS, getFormPresetsByFamily } from '@saastro/forms/presets';
import type { FormPreset, FormPresetFamily, FormPresetId } from '@saastro/forms/presets';
What’s in the box
| Key | Family | Steps | Fields |
|---|---|---|---|
contact |
contact |
1 | name, email, message, consent |
quote |
quote |
2 | service, budget, details → name, email, phone, consent |
booking |
booking |
1 | date, time, guests, name, email, phone, notes, consent |
job-application |
legal-hr |
1 | name, email, phone, position, experience, data-protection consent (GDPR) |
Every preset passes validateFormConfig, and each carries a label and description in en and es for pickers.
Using one
The catalogue is shared, so clone before changing anything and give the copy its own formId:
import { Form } from '@saastro/forms';
import { FORM_PRESETS } from '@saastro/forms/presets';
const config = { ...structuredClone(FORM_PRESETS.contact.config), formId: 'contact-home', locale: 'es' };
<Form config={config} components={components} onSubmit={send} />;
getFormPresetsByFamily('booking') returns the presets of one family.
A preset has no submit action: add yours (submitActions, a plugin…) to the clone.