Π€ΠΎΡΠΌΠ° Π·Π° ΠΌΠΈΠ½ΡΡΡ
import { createModel, createForm, validateFormModel } from '@reformer/core';
import { required, email } from '@reformer/core/validators';
import { FormField, Input, Button } from '@reformer/ui-kit';
// 1. ΠΠΎΠ΄Π΅Π»Ρ β ΠΈΡΡΠΎΡΠ½ΠΈΠΊ ΠΈΡΡΠΈΠ½Ρ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ
const model = createModel<{ email: string }>({ email: '' });
// 2. Π‘Ρ
Π΅ΠΌΠ° β ΠΏΡΠΈΠ²ΡΠ·ΠΊΠ° ΠΏΠΎΠ»Ρ ΠΊ ΡΠΈΠ³Π½Π°Π»Ρ + ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ + Π²Π°Π»ΠΈΠ΄Π°ΡΠΎΡΡ
const schema = {
email: {
value: model.$.email,
component: Input,
componentProps: { label: 'Email', type: 'email' },
validators: [required(), email()],
},
};
// 3. Π€ΠΎΡΠΌΠ° β ΡΠ·Π»Ρ ΠΏΠΎΠ²Π΅ΡΡ
ΡΠΈΠ³Π½Π°Π»ΠΎΠ² ΠΌΠΎΠ΄Π΅Π»ΠΈ
const form = createForm({ model, schema });
// 4. Π’ΠΎΠ½ΠΊΠΈΠΉ JSX β FormField Π΄Π΅Π»Π°Π΅Ρ Π²ΡΡ ΡΠ°Π±ΠΎΡΡ
function ContactForm() {
const onSubmit = async (e) => {
e.preventDefault();
const { valid } = await validateFormModel(model, schema);
if (valid) console.log(model.get());
};
return (
<form onSubmit={onSubmit}>
<FormField control={form.email} />
<Button type="submit">ΠΡΠΏΡΠ°Π²ΠΈΡΡ</Button>
</form>
);
}
Reactive by Design
Built on Preact Signals for fine-grained reactivity. Only components using changed values re-render.
Type-Safe Forms
Full TypeScript support with automatic type inference. Catch errors at compile time, not runtime.
Declarative Validation
14 built-in validators, async validation, and easy custom validators. Define validation rules once, apply everywhere.
Smart Behaviors
Computed fields, conditional visibility, field synchronization. Complex form logic made simple.
Nested Structures
Support for deeply nested objects and dynamic arrays. Build any form structure you need.
Framework Agnostic
Core library works anywhere. React bindings included, with more frameworks coming soon.
AI-Friendly
Well-documented API with clear patterns. AI assistants can easily understand and generate code using ReFormer.