Modules
Form examples
Checkout, onboarding, booking, survey and filters, plus a gallery and a schema-driven playground.
config/forms.config.ts
View in the demo
/forms/overview is a gallery driven by FORM_EXAMPLES: a type filter, featured cards with icon, description and capability chips, compact links to forms that live elsewhere and the schema-driven playground. Each example starts with BasePageHeader + FormsExampleChips. How forms work is in Forms.
Files
File | Role |
|---|---|
pages/forms/overview.vue | The gallery and the playground (useFormPlayground). |
pages/forms/checkout.vue | Express pay, numbered sections, card brand detection, a discount code and a sticky summary. |
pages/forms/onboarding.vue | BaseForm layout="stepper" contained. |
pages/forms/booking.vue | BaseDatePicker and slot buttons with role="radio". |
pages/forms/survey.vue | A follow-up question by score and a progress bar. |
pages/forms/filters.vue | Active filter chips over a BaseDataTable. |
config/forms.config.ts | The gallery entries, types and capability icons. |
mocks/forms.mock.ts | Demo submissions that throw FormSubmitError for server errors. |
components/pages/forms/ | FormsExampleChips, FormsCheckoutSummary, FormsExpressPay. |
Configuration
FORM_EXAMPLES
The entries of the gallery.
const FORM_EXAMPLES: FormExample[]
FORM_EXAMPLE_TYPES
The types of the filter.
const FORM_EXAMPLE_TYPES: FormExampleType[]
FORM_CAPABILITY_ICONS
The icon of each capability chip.
const FORM_CAPABILITY_ICONS: Record<FormCapability, string>
Rules
Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.
cardBrand()
Card brand detection.
cardBrand(number: string): CardBrand | undefined
How it works
- Every example is a plain
v-formwithBase*inputs,:rulesfromuseFormRules()anduseFormSubmit(values, handler). - Add an example by creating the page and adding an entry to
FORM_EXAMPLESand to the menu inuseNavigation().