The withFieldGroup props comment said the props are "not used at
runtime", but they are. In createFormHook the render call spreads them
(render({ ...props, ...innerProps, group })), so they act as default
values that innerProps can override, the same as withForm does with
render({ ...props, ...innerProps }). The withForm docs already describe
this correctly as default values, so this updates the react, solid and
preact copies to match.
Closes#2099
Co-authored-by: Patrick Wehbe <patrick.wehbe.applications@gmail.com>
* feat: initial work on FormGroupApi in core
* chore: initial (and wrong) per-form-group-validation
This is wrong because instead of keeping the state inside of `FormGroupApi` itself, we need to follow the same pattern of `FieldApi` and keep the state in `FormApi` and reference that state in a derived way.
* chore: create a common FieldLikeAPI to adopt in form groups shortly
* chore: implement FieldLike API on FormGroup
* chore: revert changes to FormApi validation logic
* chore: fix type issues with validation kind
* chore: minor fixes
* Revert "chore: revert changes to FormApi validation logic"
This reverts commit 756ddf8402.
* chore: filter fields to validate in formgroup
* chore: improve store
* chore: fix tests
* chore: fix another test
* chore: add submitmeta test
* ci: apply automated fixes and generate docs
* chore: add FormLike methods to FormGroup
* chore: add type tests
* chore: fix build
* chore: fix type tests
* ci: apply automated fixes and generate docs
* chore: export two missing items
* chore: add new interop FormGroupOptions type
* chore: initial implement of useFormGroup in React
* ci: apply automated fixes and generate docs
* chore: add formGroup to useForm
* chore: add initial React implementation tests
* ci: apply automated fixes and generate docs
* chore: add type tests for React adapter
* ci: apply automated fixes and generate docs
* chore: fix eslint
* ci: apply automated fixes and generate docs
* chore: add multi-step wizard
* ci: apply automated fixes and generate docs
* fix: handle resubmissions
* fix: validate on resubmit
* feat: add better onDynamic handling to FormGroupApi
* chore: first attempt to fix onDynamic change handling on groups
* chore: attempt 2
* chore: attempt 3
* chore: attempt 4
* Revert "chore: attempt 4"
This reverts commit 7546f08b94.
* chore: finalize fixing form errors
* chore: fix eslint
* chore: regenerate lockfile
* ci: apply automated fixes and generate docs
* docs: update the wizard example
* ci: apply automated fixes and generate docs
* chore: initial work on Vue FormGroup API
* ci: apply automated fixes and generate docs
* chore: revert useContext changes
* feat: add preact form group
* chore: fix tests and export names
* chore: add Preact wizard demo
* feat: add FormGroup support for Solid adapter
* chore: add formgroup tests for Solid
* chore: add type tests for Solid
* ci: apply automated fixes and generate docs
* chore: add Solid group example
* ci: apply automated fixes and generate docs
* chore: fix test
* feat: add FormGroup impl to Svelte
* ci: apply automated fixes and generate docs
* chore: add formGroup tests for Svelte
* ci: apply automated fixes and generate docs
* chore: add Svelte example
* chore: fix sherif
* feat: add Lit FormGroup API
* chore: add Lit FormGroup tests
* chore: refactor Lit tests
* ci: apply automated fixes and generate docs
* feat: implement FormGroup in Angular
* chore: add FormGroup Angular spec
* ci: apply automated fixes and generate docs
* feat: add withForm feature to Angular
* chore: update Angular large-form example to use new `withForm` API
* docs: add docs to Angular withForm example
* chore: add changeset
* chore: fix knip
* chore: initial multi-step-wizard Angular example
* chore: update the multi-step-wizard to use new API
* chore: add multi-step-wizard example to Lit
* ci: apply automated fixes and generate docs
* chore: add Vue example
* chore: fix CI
* chore: update to use Testing Library
* chore: make tests more Testing Library-y
* fix: isSubmitting now works with FormGroup
Thank you @gaganref!
* chore: fix Lit warning
* ci: apply automated fixes and generate docs
* chore: add currently failing tests
* fix: handle validation better in form groups
* chore: add test for duped group schema
* chore: update `form` error field to `group`
* chore: fix CI
* ci: apply automated fixes and generate docs
* chore: add test for isGroupValid and isFieldsValid
* ci: apply automated fixes and generate docs
* chore: refactor FormGroup to core
* chore: refactor Lit Form to use Lit Store properly
* chore: fix eslint
* ci: apply automated fixes and generate docs
* chore: remove temp changeset
* docs: initial docs for React adapter
* docs: add multi-step-wizard examples to docs site
* docs: add form group state docs for React
* docs: mirror React docs to Preact
* docs: add Solid docs
* docs: add Vue docs
* ci: apply automated fixes and generate docs
* docs: add groups docs for Svelte
* docs: add groups docs for Lit
* docs: add groups docs for Angular
* fix: handle issue with field group names
* ci: apply automated fixes and generate docs
* chore: fix CI
* chore: remove onXListenTo APIs
* chore: add onMount errors to groups
* chore: add onChange listeners to form
* chore: handle group validation async cleanup, onmount listener, et al
* chore: fix Group change listeners
* chore: add changeset
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* docs(react-form): show how to render formErrorMap.onChange when using Standard Schema
The form-level error rendering example uses a function validator
returning a string, which renders directly. Readers applying the same
pattern to a Standard Schema validator (Zod, Valibot, ArkType,
Effect/Schema) hit a TypeScript error because errorMap.onChange is then
Record<string, StandardSchemaV1Issue[]>, not a string.
Add a note after the example with the iteration pattern needed for the
Standard Schema case.
Closes#1564
* ci: apply automated fixes and generate docs
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix: make field unmount
* more tests
* ref: prefer object.entries
* jsdoc
* Fix field unmount issue in core
Fixes the issue with field unmount in core.
* ci: apply automated fixes and generate docs
* fix: update fieldInfo type to be partial and handle unmounted fields
* fix: cleanupFieldsOnUnmount flag
* fix: eslint
* fix: coderabbit findings
* fix: ensure async validation cancellation on field unmount
* more tests
* chore: remove default
* feat: listeners
* ci: apply automated fixes and generate docs
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Harry Whorlow <79278353+harry-whorlow@users.noreply.github.com>
Co-authored-by: Harry Whorlow <whorlowharry@gmail.com>
* docs(react-form): add Chakra UI integration guide to ui-libraries documentation
Add comprehensive Chakra UI integration examples to the UI libraries guide,
covering both composable (Checkbox.Root) and pre-composed Checkbox components.
Includes code examples demonstrating how to integrate Chakra UI's Input and
Checkbox components with TanStack Form's Field component, maintaining
consistency with existing Mantine, Material UI, and shadcn/ui examples.
* docs: Update Chakra UI Checkbox example in UI libraries guide
* Refine language and formatting in basic concepts guide
Hey team,
These are some suggestions I have for how we could improve this page. It's mostly grammar and consistency fixes, but includes slight re-wording to improve clarity. I'm open to feedback.
* docs(form): Removed links to references and moved `isDefaultValue`
* ci: apply automated fixes and generate docs
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Making docs more robus
I ran into some errors caused by ESLint and I have found that a few other people did too, I think it would be good to include this in the docs.
* Wording change for linting issues
* Enhance validation guide with preventing submission tip
Added guidance on preventing form submission before interaction.
* move the tip after the code block to no break logic
* enhance guide for all frameworks
* docs(nextjs-ssr): clarify need for HTML name attribute in native form submissions
add inline comments to client components in next.js server action examples
highlighting the need to explicitly set the name attribute on input fields
for native POST submissions (e.g. with Next.js Server Actions). This avoids
confusion where inputs may otherwise be omitted from formData.
closes https://github.com/TanStack/form/issues/1565
* docs: change hardcoded name to field name
---------
Co-authored-by: LeCarbonator <18158911+LeCarbonator@users.noreply.github.com>
* feat: add createFormGroup
* refactor: move createFormGroup to AppForm
While the previous separate implementation was compatible with AppForm, users
wouldn't have been able to use any field/form components
in the render itself. This commit allows them to do that,
at the expense of not being compatible with useForm.
* chore: add unit tests for createFormGroup types
* chore: add unit test for createFormGroup
* chore: export CreateFormGroupProps
* add DeepKeysOfType util type
This type will help with a lens API for forms
so that only names leading to the subset data
are allowed.
* feat: add initial FormLensApi draft
* chore: add FormLensApi tests batch
* fix(form-core): fix form.resetField() ignoring nested fields
* chore: complete form-core unit test for FormLensApi
* feat: add react adapter to form lens api
* fix: fix names for lens.Field and add test
* chore: export WithFormLensProps
* feat: add Subscribe and store to form lens
* feat: add mount method to FormLensApi
* fix: memoize innerProps to avoid focus loss in withFormLens
* refactor: use single useState instead of multiple useMemos
this is because useMemo is not intended for stable objects
see https://react.dev/reference/react/useMemo for more info
* feat: allow nesting withFormLenses
* remove createFormGroup for redundancy
* fix: widen typing of lens.Field/AppField to correct level
* docs: add withFormLens section
* fix: fix TName for lens component
* docs: fix typo in withFormLens
* feat: add lensErrors to FormLensApi store
* chore: adjust memo dependency in useFormLens
* chore: call userEvent.setup() in createFormHook tests
* refactor: move path concatenation to utils
* chore: move useLens to own file and rename
* feat: add FieldsMap and createFieldMap utils
* chore: migrate (most) lens references to field group
* chore: finalize migration from lens to field group
* ci: apply automated fixes and generate docs
* chore: remove accidental test file
* chore: add some unit tests for field mapping
* chore: add unit tests
* docs: update docs to use group
* docs: add caveat with field mapping
* docs: fix weird line break in alert text
* revert: remove FieldGroupApi#resetFieldMeta
the method appears to be a helper function for form.reset,
which is accessible from the field group API.
There does not seem to be a good reason to port this method
from FormApi.
* refactor: allow null or undefined for field group keys
users are able to do conditional rendering, but
TS generally doesn't pick up on it. Therefore,
while it is less type safe, it allows users to
use field groups in more locations than previously
possible.
* chore: add FieldGroupApi.test-d.ts
* docs(react-form): amend large form example with withFieldGroup
* chore(form-core): remove FieldGroupApi.reset
the reset is already accessible through group.form.reset.
* chore: fix broken unit test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat(solid-form): add `createFormHook` for solid-js.
* fix(solid-form): make the field in useFieldContext an accessor.
* fix(solid-form): directly assign values to form object.
This fixes and issue where some parts of the form, like submitting didn't work.
* feat(solid-form): add docs for form composition for solid.
* ci: apply automated fixes and generate docs
* fix: move to PoeplePage to align with the large form example.
* feat(solid-form): add large form example.
* ci: apply automated fixes and generate docs
* chore: use tanstack store adapter
* chore: fix CI
* ci: apply automated fixes and generate docs
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Corbin Crutchley <git@crutchcorn.dev>
* feat(form-core): add <FieldMeta>.isValid
this is a shortened counterpart to checking
field.state.meta.errors.length > 0
* docs: use isValid checks instaed of error length checks
* fix: read field derived data from the right store
* style: revert extracting errorMap variable in setMeta
* style: revert extracting errorMap variable in setFieldMeta
* docs: rephrase isValid description and related props
---------
Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
Co-authored-by: Luca <luca@luca-laptop.int.dr-jakob.ch>
* feat(FormApi): add standard schema validator wrapper
* feat(form-core): add parseValueWithSchema methods
* docs: add parseValueWithSchema documentation
* refactor(form-core): rename FormApi#parseValuesWithSchema
This is to be consistent with other methods
that include the word Values.
* refactor(form-core): adjust unit tests for parseValuesWithSchema
* refactor(FormApi): rename parseFieldValuesWithSchema
Since we don't pass a field to the method, the term
shouldn't be included in the method name.
* docs: generate