1- import {
2- type DeepKeys ,
3- type DeepValue ,
4- FieldApi ,
5- type FieldOptions ,
6- type Narrow ,
1+ import { FieldApi } from '@tanstack/form-core'
2+ import type {
3+ FieldState ,
4+ DeepKeys ,
5+ DeepValue ,
6+ FieldOptions ,
7+ Narrow ,
78} from '@tanstack/form-core'
89import { useStore } from '@tanstack/vue-store'
9- import {
10- type SetupContext ,
11- defineComponent ,
12- type Ref ,
13- onMounted ,
14- onUnmounted ,
15- watch ,
16- } from 'vue-demi'
10+ import { defineComponent , onMounted , onUnmounted , watch } from 'vue-demi'
11+ import type { SlotsType , SetupContext , Ref } from 'vue-demi'
1712import { provideFormContext , useFormContext } from './formContext'
1813
1914declare module '@tanstack/form-core' {
@@ -113,11 +108,7 @@ export type FieldValue<TFormData, TField> = TFormData extends any[]
113108// // ^?
114109
115110export type FieldComponent < TParentData , TFormData > = < TField > (
116- fieldOptions : {
117- children ?: (
118- fieldApi : FieldApi < FieldValue < TParentData , TField > , TFormData > ,
119- ) => any
120- } & Omit <
111+ fieldOptions : Omit <
121112 UseFieldOptions < FieldValue < TParentData , TField > , TFormData > ,
122113 'name' | 'index'
123114 > &
@@ -130,7 +121,15 @@ export type FieldComponent<TParentData, TFormData> = <TField>(
130121 name : TField extends undefined ? TField : DeepKeys < TParentData >
131122 index ?: never
132123 } ) ,
133- context : SetupContext ,
124+ context : SetupContext <
125+ { } ,
126+ SlotsType < {
127+ default : {
128+ field : FieldApi < FieldValue < TParentData , TField > , TFormData >
129+ state : FieldState < any >
130+ }
131+ } >
132+ > ,
134133) => any
135134
136135export const Field = defineComponent (
@@ -145,7 +144,11 @@ export const Field = defineComponent(
145144 parentFieldName : fieldApi . api . name ,
146145 } as never )
147146
148- return ( ) => context . slots . default ! ( fieldApi . api , fieldApi . state . value )
147+ return ( ) =>
148+ context . slots . default ! ( {
149+ field : fieldApi . api ,
150+ state : fieldApi . state . value ,
151+ } )
149152 } ,
150153 { name : 'Field' , inheritAttrs : false } ,
151154)
0 commit comments