Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Examples

Working integrations of Formhaus with real UI kits. Each example is self-contained: it installs its own dependencies, has its own README, and can be used as a starter.

| Example | Stack | What it shows |
|---------|-------|---------------|
| [`react-mui`](react-mui/) | React 18 + Material UI | `components` prop with MUI Autocomplete, DateTimePicker, Select, etc. |
| [`vue-vuetify`](vue-vuetify/) | Vue 3 + Vuetify 3 | `components` prop with Vuetify `<v-autocomplete>`, `<v-text-field>`, etc. |
| [`vanilla-svelte`](vanilla-svelte/) | Svelte (no adapter) | Using `@formhaus/core` directly without a framework adapter |

## Run any example

```bash
cd examples/<name>
pnpm install --ignore-workspace
pnpm dev
```

The `--ignore-workspace` flag is important — it makes the example resolve `@formhaus/*` from the public npm registry, the way a real consumer would.

## Form definitions

[`definitions/`](definitions/) contains stand-alone JSON form definitions used by the documentation playground. They're regular `FormDefinition` files; copy any of them into a new project to get started.
26 changes: 26 additions & 0 deletions examples/react-mui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# React + MUI example

Wires the Formhaus React adapter to [Material UI](https://mui.com) components. Demonstrates the `components` prop pattern: each MUI input is a thin wrapper that maps `FieldComponentProps` onto the MUI API.

## Run

This example installs its own dependencies (it ignores the workspace root):

```bash
pnpm install --ignore-workspace
pnpm dev
```

Opens at http://localhost:5173.

## What's interesting

- [src/component-map.ts](src/component-map.ts) — maps every Formhaus field type to an MUI-backed renderer. Copy this file as a starting point for your own MUI-based form.
- [src/fields/AutocompleteField.tsx](src/fields/AutocompleteField.tsx) — MUI's `<Autocomplete>` filtering by `label` (the default `<datalist>` filters by `value`).
- [src/fields/SelectField.tsx](src/fields/SelectField.tsx) — handles both `select` and `multiselect` from one component.
- [src/fields/TextField.tsx](src/fields/TextField.tsx) — covers text, email, phone, number, password, date, datetime in one renderer using MUI's `<TextField>`.
- [src/definition.json](src/definition.json) — a small contact form using `text`, `email`, `autocomplete`, and `datetime`.

## Use as a starter

Copy this folder, rename, and tweak `definition.json` and the field map. Nothing in here references workspace-internal paths.
23 changes: 23 additions & 0 deletions examples/vanilla-svelte/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Svelte example (no adapter package)

Demonstrates that `@formhaus/core` works directly with any framework — no `@formhaus/svelte` package needed. The Svelte component subscribes to the `FormEngine` and re-renders on change.

## Run

This example installs its own dependencies (it ignores the workspace root):

```bash
pnpm install --ignore-workspace
pnpm dev
```

Opens at http://localhost:5173.

## What's interesting

- [src/App.svelte](src/App.svelte) — subscribes to `engine.subscribe(...)`, copies state into reactive `let` variables in `sync()`, and renders fields by `field.type`. This is the pattern you'd use to write `@formhaus/svelte` if you wanted one.
- [src/definition.json](src/definition.json) — same form definition format as the React/Vue examples. Define once, render anywhere.

## Use as a starter

Copy this folder, rename, and tweak `definition.json` and the renderer logic. Add support for whichever field types your app needs.
26 changes: 26 additions & 0 deletions examples/vue-vuetify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Vue + Vuetify example

Wires the Formhaus Vue adapter to [Vuetify 3](https://vuetifyjs.com) components. Demonstrates the `components` prop pattern: each Vuetify input is a thin wrapper that maps `FormFieldProps` onto the Vuetify API.

## Run

This example installs its own dependencies (it ignores the workspace root):

```bash
pnpm install --ignore-workspace
pnpm dev
```

Opens at http://localhost:5173.

## What's interesting

- [src/component-map.ts](src/component-map.ts) — maps every Formhaus field type to a Vuetify-backed renderer. Copy this file as a starting point for your own Vuetify-based form.
- [src/fields/AutocompleteField.vue](src/fields/AutocompleteField.vue) — Vuetify's `<v-autocomplete>` filtering by `label` (the default `<datalist>` filters by `value`).
- [src/fields/SelectField.vue](src/fields/SelectField.vue) — handles both `select` and `multiselect` from one component.
- [src/fields/TextField.vue](src/fields/TextField.vue) — covers text, email, phone, number, password, date, datetime in one renderer using Vuetify's `<v-text-field>`.
- [src/definition.json](src/definition.json) — a small contact form using `text`, `email`, `autocomplete`, and `datetime`.

## Use as a starter

Copy this folder, rename, and tweak `definition.json` and the field map. Nothing in here references workspace-internal paths.
Loading