@tanstack/react-form 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/build/legacy/createFormFactory.cjs.map +1 -1
  2. package/build/legacy/createFormFactory.d.cts +5 -4
  3. package/build/legacy/createFormFactory.d.ts +5 -4
  4. package/build/legacy/createFormFactory.js.map +1 -1
  5. package/build/legacy/formContext.cjs.map +1 -1
  6. package/build/legacy/formContext.d.cts +2 -2
  7. package/build/legacy/formContext.d.ts +2 -2
  8. package/build/legacy/formContext.js.map +1 -1
  9. package/build/legacy/types.cjs.map +1 -1
  10. package/build/legacy/types.d.cts +1 -1
  11. package/build/legacy/types.d.ts +1 -1
  12. package/build/legacy/useField.cjs +6 -2
  13. package/build/legacy/useField.cjs.map +1 -1
  14. package/build/legacy/useField.d.cts +13 -12
  15. package/build/legacy/useField.d.ts +13 -12
  16. package/build/legacy/useField.js +6 -2
  17. package/build/legacy/useField.js.map +1 -1
  18. package/build/legacy/useForm.cjs.map +1 -1
  19. package/build/legacy/useForm.d.cts +3 -3
  20. package/build/legacy/useForm.d.ts +3 -3
  21. package/build/legacy/useForm.js.map +1 -1
  22. package/build/modern/createFormFactory.cjs.map +1 -1
  23. package/build/modern/createFormFactory.d.cts +5 -4
  24. package/build/modern/createFormFactory.d.ts +5 -4
  25. package/build/modern/createFormFactory.js.map +1 -1
  26. package/build/modern/formContext.cjs.map +1 -1
  27. package/build/modern/formContext.d.cts +2 -2
  28. package/build/modern/formContext.d.ts +2 -2
  29. package/build/modern/formContext.js.map +1 -1
  30. package/build/modern/types.cjs.map +1 -1
  31. package/build/modern/types.d.cts +1 -1
  32. package/build/modern/types.d.ts +1 -1
  33. package/build/modern/useField.cjs +6 -2
  34. package/build/modern/useField.cjs.map +1 -1
  35. package/build/modern/useField.d.cts +13 -12
  36. package/build/modern/useField.d.ts +13 -12
  37. package/build/modern/useField.js +6 -2
  38. package/build/modern/useField.js.map +1 -1
  39. package/build/modern/useForm.cjs.map +1 -1
  40. package/build/modern/useForm.d.cts +3 -3
  41. package/build/modern/useForm.d.ts +3 -3
  42. package/build/modern/useForm.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/createFormFactory.ts +9 -7
  45. package/src/formContext.ts +1 -1
  46. package/src/tests/createFormFactory.test.tsx +1 -1
  47. package/src/tests/useField.test.tsx +54 -9
  48. package/src/tests/useForm.test.tsx +2 -2
  49. package/src/types.ts +4 -2
  50. package/src/useField.tsx +72 -23
  51. package/src/useForm.tsx +5 -3
package/src/useForm.tsx CHANGED
@@ -9,9 +9,9 @@ import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
9
9
 
10
10
  declare module '@tanstack/form-core' {
11
11
  // eslint-disable-next-line no-shadow
12
- interface FormApi<TFormData> {
12
+ interface FormApi<TFormData, ValidatorType> {
13
13
  Provider: (props: { children: any }) => any
14
- Field: FieldComponent<TFormData>
14
+ Field: FieldComponent<TFormData, ValidatorType>
15
15
  useField: UseField<TFormData>
16
16
  useStore: <TSelected = NoInfer<FormState<TFormData>>>(
17
17
  selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,
@@ -23,7 +23,9 @@ declare module '@tanstack/form-core' {
23
23
  }
24
24
  }
25
25
 
26
- export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
26
+ export function useForm<TData, FormValidator>(
27
+ opts?: FormOptions<TData, FormValidator>,
28
+ ): FormApi<TData, FormValidator> {
27
29
  const [formApi] = useState(() => {
28
30
  // @ts-ignore
29
31
  const api = new FormApi<TData>(opts)