Repository navigation
v2.1.0
[2.1.0] - 2026-08-14
Added
- Conditional fields -
visibleWhenon any field shows/hides it based on another field's value (equals,notEquals,truthy,falsy). Hidden fields keep their value and are excluded from the generated schema so they never block submission onValuesChangeprop - live subscription to form values on bothAutoFormandAutoFormWizard(fires on every change)- Async validators - field validators can now use async Zod refinements (e.g. username uniqueness checks); the submit button disables while validation is in flight
- New field types -
radio,switch(boolean toggle) andmultiselect(array value), all with built-in renderers and CSS - Per-field
defaultValue- set a default directly on a field; precedence isdefaultValue<initialValues< cached values - Nested field keys - dot-paths (
"address.street") produce nested objects with full type inference, validation and submit output - Unit tests - First test suite (
vitest) covering generated schema logic (required/optional, checkbox/email/date validation, coercion) extended with coverage for the new field types, nested keys, async validators, and visibility evaluation, anddefineFormtype inference (44 tests total) typecheckandtestscripts -npm run typecheck(was missing despite being referenced by CI) andnpm run testsideEffectsfield - Marked CSS as the only side-effectful entry so bundlers don't tree-shakeimport "@pavan-silva/react-autoform/styles.css"- Explicit
typesexport condition -exports["."].typesso TypeScript resolves types reliably undermoduleResolution: "node16"/"bundler"
Changed
- Dependencies updated to latest -
zod^4.4.3,react-hook-form^7.85.0,@hookform/resolvers^5.7.1, React 19,@types/react19, TypeScript 5.9.3, tsup 8.5.1, Vite 8 (examples) - Runtime libs moved to
peerDependencies-react,react-dom,react-hook-form,zod,@hookform/resolversare no longer duplicated independencies, avoiding version conflicts for consumers datefield inference - Form values now inferDate(matching the runtime value) instead ofnumber- Wizard submit values -
AutoFormWizardnow runs the generated schema over the raw values and submits parsed/transformed output, consistent withAutoForm; values added by custom step components are preserved - Optional field values - Empty optional
number/date/email/selectvalues resolve toundefinedinstead of"" - Zod 4 API - Replaced deprecated
.email()withz.email(),ZodTypeAnywithz.ZodType, anderrorMapwith theerrorparam - Performance - Fields subscribe to their own
useFormState(per-key) instead of the full form state; custom renderers are shallow-compared and merged once (useMergedRenderers); the cache is read/saved against a stable key instead of object identity - Custom wizard steps -
valuesprop is now live viauseWatch(reactive to edits on the current step) - Dynamic schema - the generated schema now only includes currently visible fields (via a stable resolver reading the latest schema), keeping the form type-safe while hidden required fields can't fail validation
- Cache -
allowlistentries support nested dot-paths ("address.street") - Examples - basic and wizard examples now demonstrate conditional fields,
onValuesChange, async validation,defaultValue, radio/switch/multiselect - CI - Publish workflow uses
npm ci(was pnpm with a missingpnpm-lock.yaml) on Node 22, and runstypecheck,test, andbuild - tsconfig -
moduleResolutionset to"bundler" defineFormsignature - the definition parameter is now typed per-element (object →FieldDef, array →FieldDef[]) instead of aFieldDef | FieldDef[]union, so editors can autocomplete field props (key,label,type,defaultValue, …) insidedefineForm([...])- New
row()helper - wrap a group of fields to place them on one row; unlike a plain nested array,row(...)keeps editor autocompletion working for the fields inside the row (works both standalone and insidedefineForm) - Renderers moved into the definition - the
renderersprop is removed fromAutoForm/AutoFormWizard. Custom renderers are now declared in the definition: a per-fieldrendereron anyFieldDef, and/or a per-typerenderersmap passed todefineForm(definition, { renderers })/defineWizard(steps, { renderers }). Precedence isfield.renderer→renderersmap → built-in defaults (breaking change) - Default UI redesigned to a modern, shadcn-style theme - neutral zinc palette (softer primary than pure black), flush focus rings on inputs/buttons/switch, larger refined stepper badges, shadcn-sized switch, auto-height textarea, custom tag-based multiselect with removable chips, styled file input with a
::file-selector-button, and a custom select chevron with right-edge spacing. A subtle accent (default Facebook-blue,--af-accent) colors active/interactive states (active step, switch, radio/checkbox, selected options). Everything stays themeable via CSS variables on.autoform-container
Fixed
-
Editor autocomplete inside
defineForm- object literals no longer lose their contextual type (the union element type made editors fall back to unrelated global suggestions); completions and excess-property checks now work insidedefineForm([...])(regression tests added) -
Optional fields with custom validators - a custom validator no longer bypasses the optional/required wrapping, so untouched optional fields pass validation (regression test added)
-
Required
number/date/checkboxfields always failed validation - the required check was piped throughz.string(), which rejected non-string values; now applied viaz.any().refine(...) -
Required checkboxes could be left unchecked -
required: trueon a checkbox now means it must be checked -
Cache cleared before
onSubmitsucceeded - a failed submit no longer discards the user's saved progress; cache is cleared only after a successful submit -
package-lock.jsonout of sync - regenerated to matchpackage.json(was pinned to 1.2.0 / zod 3) -
Examples referenced a stale tarball - updated to the
2.0.0package archive