import type { Ref } from '@stacksjs/stx'; /** * Reactive form primitive with schema validation + submit orchestration. * * @example * ```ts * const form = useForm({ * initialValues: { email: '', password: '' }, * schema: { * email: schema.string().email().required(), * password: schema.string().min(6).required(), * }, * onSubmit: async (values) => { * const r = await authStore.login(values) * if (!r.ok) form.setError('form', r.error) * }, * }) * ``` */ export declare function useForm>(opts: UseFormOptions): UseFormResult; /** * useForm (stacksjs/stacks#1940 — Phase 1). * * Per-field state + schema validation + submit orchestration. * Builds on `@stacksjs/validation`'s ts-validation surface — pass any * field-keyed bag of `schema.string()...` etc. and the composable * runs `.validate(value)` to surface the first message. * * Phase 1 deliberately ships the primitive only; the `` / * `` / `` companion components, field * arrays, server-error auto-surfacing on 422, and progressive HTML * fallback are scoped to Phases 2-5 of the issue. * * --- * * THERE IS A SECOND `useForm`, in stx * (packages/stx/src/composables/use-form.ts, called `defineForm` before * stacksjs/stx#1843). It is not this one, and the two are not interchangeable — * they were written independently because neither side could find the other's, * which is stx#1843's adoption problem happening to the framework itself. * * this one stx * useForm({ initialValues, useForm(schema, initialValues) * onSubmit }) * form.values.value.email form.values.email * form.field('email') form.getFieldState('email') * schema.string().email() v.required().email() (stx's own builder) * validate() -> { valid, errors } validate() -> Promise * has: isSubmitting, isValid, has: validating, validateField * isDirty, setErrors (422), * clearErrors, * submitButtonProps, * firstErrorField, * aria inputProps * * stx's is the one that reaches a `