@web-loom/forms-core
v0.8.0
Published
Framework-agnostic form management library with Zod integration
Maintainers
Readme
@web-loom/forms-core
Framework-agnostic form management library for building reactive, validated forms in any frontend environment. Provides core logic for form state, field management, validation, and integration with Zod schemas. Adapters are available for React, Vue, and vanilla JS.
Features
- Pure TypeScript, no framework dependencies
- Type-safe form state and validation
- Zod schema integration
- Field arrays, subscriptions, and error handling
- Composable architecture for adapters (React, Vue, Vanilla)
- Lightweight and tree-shakeable
Installation
npm install @web-loom/forms-core zodUsage Example
import { createForm } from '@web-loom/forms-core';
import { z } from 'zod';
const schema = z.object({
name: z.string().min(1),
email: z.string().email(),
});
const form = createForm({
schema,
initialValues: { name: '', email: '' },
});
form.setField('name', 'Alice');
form.setField('email', '[email protected]');
form.subscribe((state) => {
// state.values, state.errors, state.touched, etc.
});API
Core
createForm(options)— Create a reactive form instanceFormController— Main form logicFieldController— Manage individual field stateFormBinder— Bind form to external systems
Utilities
events— Event subscription helperspath— Path utilities for nested fieldsvalidation— Zod integration and validation helpers
Adapters
- @web-loom/forms-react: React hooks and context
- @web-loom/forms-vue: Vue 3 composables
- @web-loom/forms-vanilla: Vanilla JS controllers
Testing
Vitest is used for unit tests:
npm run testLicense
MIT
