@tanstack/vue-form 2.0.0-alpha.0 → 2.0.0-alpha.2

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 (38) hide show
  1. package/dist/AppForm/createFormHook.public.d.ts +6 -3
  2. package/dist/AppForm/createFormHook.public.js +2 -4
  3. package/dist/AppForm/createFormHookTypes.public.d.ts +82 -6
  4. package/dist/AppForm/initializeAppForm.lib.js +6 -1
  5. package/dist/FieldGroup/FieldGroupApi.public.d.ts +1 -1
  6. package/dist/VueForm/Components.public.d.ts +2 -2
  7. package/dist/VueForm/formApiTypes.public.d.ts +26 -0
  8. package/dist/VueForm/formType.public.d.ts +24 -2
  9. package/dist/VueForm/useField.lib.js +2 -2
  10. package/dist/VueForm/useForm.public.d.ts +23 -1
  11. package/dist/VueForm/useForm.public.js +22 -0
  12. package/dist/index.d.ts +2 -3
  13. package/package.json +3 -4
  14. package/dist/AppForm/appFormOptions.public.d.ts +0 -14
  15. package/src/AppForm/Components.lib.ts +0 -31
  16. package/src/AppForm/VueAppFormApi.public.ts +0 -17
  17. package/src/AppForm/appFormOptions.public.ts +0 -55
  18. package/src/AppForm/componentMap.public.ts +0 -19
  19. package/src/AppForm/contexts.lib.ts +0 -31
  20. package/src/AppForm/createFormHook.public.ts +0 -32
  21. package/src/AppForm/createFormHookTypes.public.ts +0 -28
  22. package/src/AppForm/fieldComponentHelpers.lib.ts +0 -21
  23. package/src/AppForm/getFormHookHelpers.public.ts +0 -109
  24. package/src/AppForm/initializeAppForm.lib.ts +0 -18
  25. package/src/FieldGroup/FieldGroupApi.public.ts +0 -148
  26. package/src/FieldGroup/withFields.lib.ts +0 -103
  27. package/src/FieldGroup/withFields.public.ts +0 -191
  28. package/src/Subscribe.public.ts +0 -46
  29. package/src/VueForm/Components.lib.ts +0 -182
  30. package/src/VueForm/Components.public.ts +0 -451
  31. package/src/VueForm/VueFormApi.lib.ts +0 -35
  32. package/src/VueForm/fieldSubscriptions.lib.ts +0 -47
  33. package/src/VueForm/formApiTypes.public.ts +0 -32
  34. package/src/VueForm/formType.public.ts +0 -46
  35. package/src/VueForm/useField.lib.ts +0 -64
  36. package/src/VueForm/useForm.public.ts +0 -30
  37. package/src/index.ts +0 -16
  38. package/src/vueTypes.lib.ts +0 -31
@@ -1,32 +0,0 @@
1
- import type { AnyFormApi, FormApi, FormErrorTypes } from '@tanstack/form-core'
2
- import type { Component } from 'vue'
3
- import type { VueTanStackFormComponents } from './Components.public'
4
- import type {
5
- AnyVueFormComponentMap,
6
- DefaultVueFormComponentMap,
7
- } from '../AppForm/componentMap.public'
8
-
9
- type ExtendedFormApi<
10
- TFormData,
11
- TFormErrorTypes extends FormErrorTypes,
12
- TFieldComponents extends Record<string, Component>,
13
- > = FormApi<TFormData, TFormErrorTypes> &
14
- VueTanStackFormComponents<TFormData, TFormErrorTypes, TFieldComponents>
15
-
16
- export type VueFormApi<
17
- TFormData,
18
- TFormErrorTypes extends FormErrorTypes,
19
- TComponents extends AnyVueFormComponentMap = DefaultVueFormComponentMap,
20
- > = unknown extends TComponents['formComponents']
21
- ? ExtendedFormApi<TFormData, TFormErrorTypes, TComponents['fieldComponents']>
22
- : ExtendedFormApi<
23
- TFormData,
24
- TFormErrorTypes,
25
- TComponents['fieldComponents']
26
- > &
27
- TComponents['formComponents']
28
-
29
- export type AnyVueFormApi = AnyFormApi &
30
- VueTanStackFormComponents<any, any, any>
31
-
32
- export type { VueFormComponentMap } from '../AppForm/componentMap.public'
@@ -1,46 +0,0 @@
1
- import type {
2
- AnyFormOptions,
3
- FormOptions,
4
- FormValidators,
5
- ToFormErrorTypes,
6
- } from '@tanstack/form-core'
7
- import type { AppFormOptions } from '../AppForm/appFormOptions.public'
8
- import type {
9
- AnyVueFormComponentMap,
10
- DefaultVueFormComponentMap,
11
- } from '../AppForm/componentMap.public'
12
- import type { VueFormApi } from './formApiTypes.public'
13
-
14
- type VueFormTypeErrorTypes<
15
- TFormValidators extends FormValidators<any>,
16
- TSubmitReturn,
17
- > = unknown extends TSubmitReturn
18
- ? any
19
- : ToFormErrorTypes<TFormValidators, TSubmitReturn>
20
-
21
- export type VueFormType<
22
- TOptions extends
23
- AnyFormOptions | AppFormOptions<any, any, any, AnyVueFormComponentMap>,
24
- > =
25
- TOptions extends AppFormOptions<
26
- infer TFormData,
27
- infer TFormValidators,
28
- infer TSubmitReturn,
29
- infer TComponents
30
- >
31
- ? VueFormApi<
32
- TFormData,
33
- VueFormTypeErrorTypes<TFormValidators, TSubmitReturn>,
34
- TComponents
35
- >
36
- : TOptions extends FormOptions<
37
- infer TFormData,
38
- infer TFormValidators,
39
- infer TSubmitReturn
40
- >
41
- ? VueFormApi<
42
- TFormData,
43
- VueFormTypeErrorTypes<TFormValidators, TSubmitReturn>,
44
- DefaultVueFormComponentMap
45
- >
46
- : never
@@ -1,64 +0,0 @@
1
- import { useSelector } from '@tanstack/vue-store'
2
- import { onMounted, onUnmounted, shallowRef, watch, watchEffect } from 'vue'
3
- import type { Component, ShallowRef } from 'vue'
4
- import type {
5
- AnyInternalFieldApi,
6
- AnyInternalFormApi,
7
- } from '@tanstack/form-core/internals'
8
-
9
- export interface InternalFieldProps {
10
- form: AnyInternalFormApi
11
- name: string
12
- [key: string]: unknown
13
- }
14
-
15
- export function useField(
16
- options: () => InternalFieldProps,
17
- fieldComponents: Record<string, Component> | null,
18
- ): ShallowRef<AnyInternalFieldApi> {
19
- const initialOptions = options()
20
- const resetVersion = useSelector(initialOptions.form._atoms.resetVersion)
21
-
22
- const createField = () => {
23
- const current = options()
24
- const field = current.form._getOrCreateFieldApi({
25
- ...current,
26
- name: current.name,
27
- } as never)
28
- if (fieldComponents !== null) Object.assign(field, fieldComponents)
29
- return field
30
- }
31
-
32
- const fieldApi = shallowRef(createField())
33
-
34
- watch(
35
- [() => options().form, () => options().name, resetVersion],
36
- () => {
37
- fieldApi.value = createField()
38
- },
39
- { flush: 'sync' },
40
- )
41
-
42
- watchEffect(() => {
43
- fieldApi.value._update(options() as never)
44
- })
45
-
46
- let mounted = false
47
- let unregister: (() => void) | undefined
48
- watch(
49
- fieldApi,
50
- (field) => {
51
- if (!mounted) return
52
- unregister?.()
53
- unregister = field._register()
54
- },
55
- { flush: 'sync' },
56
- )
57
- onMounted(() => {
58
- mounted = true
59
- unregister = fieldApi.value._register()
60
- })
61
- onUnmounted(() => unregister?.())
62
-
63
- return fieldApi
64
- }
@@ -1,30 +0,0 @@
1
- import { initializeForm, useInternalForm } from './VueFormApi.lib'
2
- import type {
3
- FormOptions,
4
- FormValidators,
5
- ToFormErrorTypes,
6
- } from '@tanstack/form-core'
7
- import type {
8
- AnyVueFormComponentMap,
9
- DefaultVueFormComponentMap,
10
- } from '../AppForm/componentMap.public'
11
- import type { VueFormApi } from './formApiTypes.public'
12
-
13
- export type UseFormHook<in out TComponents extends AnyVueFormComponentMap> = <
14
- TFormData,
15
- const TFormValidators extends FormValidators<TFormData>,
16
- TSubmitReturn,
17
- >(
18
- options: FormOptions<TFormData, TFormValidators, TSubmitReturn>,
19
- ) => VueFormApi<
20
- TFormData,
21
- ToFormErrorTypes<TFormValidators, TSubmitReturn>,
22
- TComponents
23
- >
24
-
25
- function useFormHook(options: FormOptions<any, any, any>) {
26
- return useInternalForm(options, initializeForm)
27
- }
28
-
29
- export const useForm =
30
- useFormHook as never as UseFormHook<DefaultVueFormComponentMap>
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
1
- export * from '@tanstack/form-core'
2
- export * from '@tanstack/vue-store'
3
-
4
- export * from './VueForm/useForm.public'
5
- export * from './VueForm/formApiTypes.public'
6
- export * from './VueForm/formType.public'
7
- export * from './VueForm/Components.public'
8
- export * from './Subscribe.public'
9
- export * from './FieldGroup/FieldGroupApi.public'
10
- export * from './FieldGroup/withFields.public'
11
- export * from './AppForm/VueAppFormApi.public'
12
- export * from './AppForm/appFormOptions.public'
13
- export * from './AppForm/componentMap.public'
14
- export * from './AppForm/createFormHook.public'
15
- export * from './AppForm/createFormHookTypes.public'
16
- export * from './AppForm/getFormHookHelpers.public'
@@ -1,31 +0,0 @@
1
- import type {
2
- ComponentOptionsMixin,
3
- CreateComponentPublicInstanceWithMixins,
4
- EmitsOptions,
5
- PublicProps,
6
- SlotsType,
7
- } from 'vue'
8
-
9
- export type VueComponentInstance<
10
- TProps extends Record<string, any>,
11
- TSlots extends Record<string, any>,
12
- > = CreateComponentPublicInstanceWithMixins<
13
- TProps,
14
- {},
15
- {},
16
- {},
17
- {},
18
- ComponentOptionsMixin,
19
- ComponentOptionsMixin,
20
- EmitsOptions,
21
- PublicProps,
22
- {},
23
- false,
24
- {},
25
- SlotsType<TSlots>
26
- >
27
-
28
- export type VueComponentWithSlots<
29
- TProps extends Record<string, any>,
30
- TSlots extends Record<string, any>,
31
- > = new (props: TProps & PublicProps) => VueComponentInstance<TProps, TSlots>