Skip to main content

ReFormer

Reactive forms library with signals

МодСль Π½Π° сигналах β€” источник истины. Одна схСма связываСт поля, Π²Π°Π»ΠΈΠ΄Π°Ρ†ΠΈΡŽ ΠΈ Ρ€Π΅Π°ΠΊΡ‚ΠΈΠ²Π½Ρ‹Π΅ behaviors. Π Π΅Π½Π΄Π΅Ρ€ΠΈΡ‚Π΅ Π²Ρ€ΡƒΡ‡Π½ΡƒΡŽ, ΠΈΠ· схСмы ΠΈΠ»ΠΈ ΠΈΠ· JSON.

Π€ΠΎΡ€ΠΌΠ° Π·Π° ΠΌΠΈΠ½ΡƒΡ‚Ρƒ

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.