@tanstack/react-form 0.3.5 → 0.3.6

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { FieldOptions, DeepKeys } from '@tanstack/form-core'\n\nexport type UseFieldOptions<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n> = FieldOptions<TData, TParentData, TName> & {\n mode?: 'value' | 'array'\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { FieldOptions, DeepKeys, DeepValue } from '@tanstack/form-core'\n\nexport type UseFieldOptions<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = FieldOptions<TParentData, TName, TData> & {\n mode?: 'value' | 'array'\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,6 +1,6 @@
1
- import { DeepKeys, FieldOptions } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core';
2
2
 
3
- type UseFieldOptions<TData, TParentData, TName extends DeepKeys<TParentData>> = FieldOptions<TData, TParentData, TName> & {
3
+ type UseFieldOptions<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = FieldOptions<TParentData, TName, TData> & {
4
4
  mode?: 'value' | 'array';
5
5
  };
6
6
 
@@ -1,6 +1,6 @@
1
- import { DeepKeys, FieldOptions } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core';
2
2
 
3
- type UseFieldOptions<TData, TParentData, TName extends DeepKeys<TParentData>> = FieldOptions<TData, TParentData, TName> & {
3
+ type UseFieldOptions<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = FieldOptions<TParentData, TName, TData> & {
4
4
  mode?: 'value' | 'array';
5
5
  };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n Narrow,\n ResolveData,\n} from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n DeepValue<TParentData, TName>,\n TParentData,\n TName\n >,\n) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>\n\nexport function useField<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n>(\n opts: UseFieldOptions<TData, TParentData, TName>,\n): FieldApi<\n TData,\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName>,\n> = {\n children: (\n fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>,\n ) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any\n\nexport function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TParentData, TName>) => any\n} & UseFieldOptions<TData, TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,yBAAyB;AAOzB,uBAA2C;AAC3C,yBAA4C;AAC5C,0CAAsC;AA2B/B,SAAS,SAKd,MAQA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,CAAC,QAAQ,QAAI,uBAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,0CAAAA,SAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,0CAAAA,SAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AAmCO,SAAS,MAA+D;AAAA,EAC7E;AAAA,EACA,GAAG;AACL,GAEgD;AAC9C,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE,6BAAAC,QAAA;AAAA,IAAC,+BAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,cAAU,mCAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":["useIsomorphicLayoutEffect","React"]}
1
+ {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<TParentData, TName>,\n) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>\n\nexport function useField<TParentData, TName extends DeepKeys<TParentData>>(\n opts: UseFieldOptions<TParentData, TName>,\n): FieldApi<\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = {\n children: (fieldApi: FieldApi<TParentData, TName, TData>) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TParentData, TName, TData>) => any\n\nexport function Field<TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TParentData, TName>) => any\n} & UseFieldOptions<TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,yBAAyB;AAEzB,uBAA2C;AAC3C,yBAA4C;AAC5C,0CAAsC;AAkB/B,SAAS,SACd,MAOA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,CAAC,QAAQ,QAAI,uBAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,0CAAAA,SAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,0CAAAA,SAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AA2BO,SAAS,MAAwD;AAAA,EACtE;AAAA,EACA,GAAG;AACL,GAEyC;AACvC,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE,6BAAAC,QAAA;AAAA,IAAC,+BAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,cAAU,mCAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":["useIsomorphicLayoutEffect","React"]}
@@ -1,27 +1,27 @@
1
- import { DeepKeys, ResolveData, Narrow, DeepValue, FieldApi } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, Narrow, FieldApi } from '@tanstack/form-core';
2
2
  import { UseFieldOptions } from './types.cjs';
3
3
 
4
4
  declare module '@tanstack/form-core' {
5
- interface FieldApi<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>> {
5
+ interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> {
6
6
  Field: FieldComponent<TData>;
7
7
  }
8
8
  }
9
9
  type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(opts?: {
10
10
  name: Narrow<TName>;
11
- } & UseFieldOptions<DeepValue<TParentData, TName>, TParentData, TName>) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>;
12
- declare function useField<TData, TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TData, TParentData, TName>): FieldApi<TData, TParentData, TName>;
13
- type FieldComponentProps<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName>> = {
14
- children: (fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>) => any;
11
+ } & UseFieldOptions<TParentData, TName>) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>;
12
+ declare function useField<TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TParentData, TName>): FieldApi<TParentData, TName>;
13
+ type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = {
14
+ children: (fieldApi: FieldApi<TParentData, TName, TData>) => any;
15
15
  } & (TParentData extends any[] ? {
16
16
  name?: TName;
17
17
  index: number;
18
18
  } : {
19
19
  name: TName;
20
20
  index?: never;
21
- }) & Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>;
22
- type FieldComponent<TParentData> = <TData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any;
23
- declare function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
- children: (fieldApi: FieldApi<TData, TParentData, TName>) => any;
25
- } & UseFieldOptions<TData, TParentData, TName>): JSX.Element;
21
+ }) & Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>;
22
+ type FieldComponent<TParentData> = <TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TParentData, TName, TData>) => any;
23
+ declare function Field<TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
+ children: (fieldApi: FieldApi<TParentData, TName>) => any;
25
+ } & UseFieldOptions<TParentData, TName>): JSX.Element;
26
26
 
27
27
  export { Field, FieldComponent, UseField, useField };
@@ -1,27 +1,27 @@
1
- import { DeepKeys, ResolveData, Narrow, DeepValue, FieldApi } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, Narrow, FieldApi } from '@tanstack/form-core';
2
2
  import { UseFieldOptions } from './types.js';
3
3
 
4
4
  declare module '@tanstack/form-core' {
5
- interface FieldApi<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>> {
5
+ interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> {
6
6
  Field: FieldComponent<TData>;
7
7
  }
8
8
  }
9
9
  type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(opts?: {
10
10
  name: Narrow<TName>;
11
- } & UseFieldOptions<DeepValue<TParentData, TName>, TParentData, TName>) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>;
12
- declare function useField<TData, TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TData, TParentData, TName>): FieldApi<TData, TParentData, TName>;
13
- type FieldComponentProps<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName>> = {
14
- children: (fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>) => any;
11
+ } & UseFieldOptions<TParentData, TName>) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>;
12
+ declare function useField<TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TParentData, TName>): FieldApi<TParentData, TName>;
13
+ type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = {
14
+ children: (fieldApi: FieldApi<TParentData, TName, TData>) => any;
15
15
  } & (TParentData extends any[] ? {
16
16
  name?: TName;
17
17
  index: number;
18
18
  } : {
19
19
  name: TName;
20
20
  index?: never;
21
- }) & Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>;
22
- type FieldComponent<TParentData> = <TData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any;
23
- declare function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
- children: (fieldApi: FieldApi<TData, TParentData, TName>) => any;
25
- } & UseFieldOptions<TData, TParentData, TName>): JSX.Element;
21
+ }) & Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>;
22
+ type FieldComponent<TParentData> = <TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TParentData, TName, TData>) => any;
23
+ declare function Field<TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
+ children: (fieldApi: FieldApi<TParentData, TName>) => any;
25
+ } & UseFieldOptions<TParentData, TName>): JSX.Element;
26
26
 
27
27
  export { Field, FieldComponent, UseField, useField };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n Narrow,\n ResolveData,\n} from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n DeepValue<TParentData, TName>,\n TParentData,\n TName\n >,\n) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>\n\nexport function useField<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n>(\n opts: UseFieldOptions<TData, TParentData, TName>,\n): FieldApi<\n TData,\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName>,\n> = {\n children: (\n fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>,\n ) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any\n\nexport function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TParentData, TName>) => any\n} & UseFieldOptions<TData, TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";AAAA,OAAO,SAAS,gBAAgB;AAChC,SAAS,gBAAgB;AAOzB,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,mBAAmB;AAC5C,OAAO,+BAA+B;AA2B/B,SAAS,SAKd,MAQA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,4BAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,4BAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AAmCO,SAAS,MAA+D;AAAA,EAC7E;AAAA,EACA,GAAG;AACL,GAEgD;AAC9C,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,UAAU,iBAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<TParentData, TName>,\n) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>\n\nexport function useField<TParentData, TName extends DeepKeys<TParentData>>(\n opts: UseFieldOptions<TParentData, TName>,\n): FieldApi<\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = {\n children: (fieldApi: FieldApi<TParentData, TName, TData>) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TParentData, TName, TData>) => any\n\nexport function Field<TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TParentData, TName>) => any\n} & UseFieldOptions<TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";AAAA,OAAO,SAAS,gBAAgB;AAChC,SAAS,gBAAgB;AAEzB,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,mBAAmB;AAC5C,OAAO,+BAA+B;AAkB/B,SAAS,SACd,MAOA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,4BAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,4BAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AA2BO,SAAS,MAAwD;AAAA,EACtE;AAAA,EACA,GAAG;AACL,GAEyC;AACvC,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,UAAU,iBAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { FieldOptions, DeepKeys } from '@tanstack/form-core'\n\nexport type UseFieldOptions<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n> = FieldOptions<TData, TParentData, TName> & {\n mode?: 'value' | 'array'\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { FieldOptions, DeepKeys, DeepValue } from '@tanstack/form-core'\n\nexport type UseFieldOptions<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = FieldOptions<TParentData, TName, TData> & {\n mode?: 'value' | 'array'\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,6 +1,6 @@
1
- import { DeepKeys, FieldOptions } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core';
2
2
 
3
- type UseFieldOptions<TData, TParentData, TName extends DeepKeys<TParentData>> = FieldOptions<TData, TParentData, TName> & {
3
+ type UseFieldOptions<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = FieldOptions<TParentData, TName, TData> & {
4
4
  mode?: 'value' | 'array';
5
5
  };
6
6
 
@@ -1,6 +1,6 @@
1
- import { DeepKeys, FieldOptions } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core';
2
2
 
3
- type UseFieldOptions<TData, TParentData, TName extends DeepKeys<TParentData>> = FieldOptions<TData, TParentData, TName> & {
3
+ type UseFieldOptions<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = FieldOptions<TParentData, TName, TData> & {
4
4
  mode?: 'value' | 'array';
5
5
  };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n Narrow,\n ResolveData,\n} from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n DeepValue<TParentData, TName>,\n TParentData,\n TName\n >,\n) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>\n\nexport function useField<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n>(\n opts: UseFieldOptions<TData, TParentData, TName>,\n): FieldApi<\n TData,\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName>,\n> = {\n children: (\n fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>,\n ) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any\n\nexport function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TParentData, TName>) => any\n} & UseFieldOptions<TData, TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,yBAAyB;AAOzB,uBAA2C;AAC3C,yBAA4C;AAC5C,0CAAsC;AA2B/B,SAAS,SAKd,MAQA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,CAAC,QAAQ,QAAI,uBAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,0CAAAA,SAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,0CAAAA,SAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AAmCO,SAAS,MAA+D;AAAA,EAC7E;AAAA,EACA,GAAG;AACL,GAEgD;AAC9C,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE,6BAAAC,QAAA;AAAA,IAAC,+BAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,cAAU,mCAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":["useIsomorphicLayoutEffect","React"]}
1
+ {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<TParentData, TName>,\n) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>\n\nexport function useField<TParentData, TName extends DeepKeys<TParentData>>(\n opts: UseFieldOptions<TParentData, TName>,\n): FieldApi<\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = {\n children: (fieldApi: FieldApi<TParentData, TName, TData>) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TParentData, TName, TData>) => any\n\nexport function Field<TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TParentData, TName>) => any\n} & UseFieldOptions<TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,yBAAyB;AAEzB,uBAA2C;AAC3C,yBAA4C;AAC5C,0CAAsC;AAkB/B,SAAS,SACd,MAOA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,CAAC,QAAQ,QAAI,uBAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,0CAAAA,SAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,0CAAAA,SAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AA2BO,SAAS,MAAwD;AAAA,EACtE;AAAA,EACA,GAAG;AACL,GAEyC;AACvC,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE,6BAAAC,QAAA;AAAA,IAAC,+BAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,cAAU,mCAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":["useIsomorphicLayoutEffect","React"]}
@@ -1,27 +1,27 @@
1
- import { DeepKeys, ResolveData, Narrow, DeepValue, FieldApi } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, Narrow, FieldApi } from '@tanstack/form-core';
2
2
  import { UseFieldOptions } from './types.cjs';
3
3
 
4
4
  declare module '@tanstack/form-core' {
5
- interface FieldApi<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>> {
5
+ interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> {
6
6
  Field: FieldComponent<TData>;
7
7
  }
8
8
  }
9
9
  type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(opts?: {
10
10
  name: Narrow<TName>;
11
- } & UseFieldOptions<DeepValue<TParentData, TName>, TParentData, TName>) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>;
12
- declare function useField<TData, TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TData, TParentData, TName>): FieldApi<TData, TParentData, TName>;
13
- type FieldComponentProps<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName>> = {
14
- children: (fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>) => any;
11
+ } & UseFieldOptions<TParentData, TName>) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>;
12
+ declare function useField<TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TParentData, TName>): FieldApi<TParentData, TName>;
13
+ type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = {
14
+ children: (fieldApi: FieldApi<TParentData, TName, TData>) => any;
15
15
  } & (TParentData extends any[] ? {
16
16
  name?: TName;
17
17
  index: number;
18
18
  } : {
19
19
  name: TName;
20
20
  index?: never;
21
- }) & Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>;
22
- type FieldComponent<TParentData> = <TData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any;
23
- declare function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
- children: (fieldApi: FieldApi<TData, TParentData, TName>) => any;
25
- } & UseFieldOptions<TData, TParentData, TName>): JSX.Element;
21
+ }) & Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>;
22
+ type FieldComponent<TParentData> = <TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TParentData, TName, TData>) => any;
23
+ declare function Field<TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
+ children: (fieldApi: FieldApi<TParentData, TName>) => any;
25
+ } & UseFieldOptions<TParentData, TName>): JSX.Element;
26
26
 
27
27
  export { Field, FieldComponent, UseField, useField };
@@ -1,27 +1,27 @@
1
- import { DeepKeys, ResolveData, Narrow, DeepValue, FieldApi } from '@tanstack/form-core';
1
+ import { DeepKeys, DeepValue, Narrow, FieldApi } from '@tanstack/form-core';
2
2
  import { UseFieldOptions } from './types.js';
3
3
 
4
4
  declare module '@tanstack/form-core' {
5
- interface FieldApi<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>> {
5
+ interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> {
6
6
  Field: FieldComponent<TData>;
7
7
  }
8
8
  }
9
9
  type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(opts?: {
10
10
  name: Narrow<TName>;
11
- } & UseFieldOptions<DeepValue<TParentData, TName>, TParentData, TName>) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>;
12
- declare function useField<TData, TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TData, TParentData, TName>): FieldApi<TData, TParentData, TName>;
13
- type FieldComponentProps<TData, TParentData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName>> = {
14
- children: (fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>) => any;
11
+ } & UseFieldOptions<TParentData, TName>) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>;
12
+ declare function useField<TParentData, TName extends DeepKeys<TParentData>>(opts: UseFieldOptions<TParentData, TName>): FieldApi<TParentData, TName>;
13
+ type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>> = {
14
+ children: (fieldApi: FieldApi<TParentData, TName, TData>) => any;
15
15
  } & (TParentData extends any[] ? {
16
16
  name?: TName;
17
17
  index: number;
18
18
  } : {
19
19
  name: TName;
20
20
  index?: never;
21
- }) & Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>;
22
- type FieldComponent<TParentData> = <TData, TName extends DeepKeys<TParentData>, TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<TData, TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any;
23
- declare function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
- children: (fieldApi: FieldApi<TData, TParentData, TName>) => any;
25
- } & UseFieldOptions<TData, TParentData, TName>): JSX.Element;
21
+ }) & Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>;
22
+ type FieldComponent<TParentData> = <TName extends DeepKeys<TParentData>, TData = DeepValue<TParentData, TName>>({ children, ...fieldOptions }: FieldComponentProps<TParentData, TName, TData>) => any;
23
+ declare function Field<TParentData, TName extends DeepKeys<TParentData>>({ children, ...fieldOptions }: {
24
+ children: (fieldApi: FieldApi<TParentData, TName>) => any;
25
+ } & UseFieldOptions<TParentData, TName>): JSX.Element;
26
26
 
27
27
  export { Field, FieldComponent, UseField, useField };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n Narrow,\n ResolveData,\n} from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n DeepValue<TParentData, TName>,\n TParentData,\n TName\n >,\n) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>\n\nexport function useField<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n>(\n opts: UseFieldOptions<TData, TParentData, TName>,\n): FieldApi<\n TData,\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TData,\n TParentData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName>,\n> = {\n children: (\n fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>,\n ) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TData,\n TName extends DeepKeys<TParentData>,\n TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<\n TData,\n TParentData,\n TName\n >,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any\n\nexport function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TParentData, TName>) => any\n} & UseFieldOptions<TData, TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";AAAA,OAAO,SAAS,gBAAgB;AAChC,SAAS,gBAAgB;AAOzB,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,mBAAmB;AAC5C,OAAO,+BAA+B;AA2B/B,SAAS,SAKd,MAQA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,4BAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,4BAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AAmCO,SAAS,MAA+D;AAAA,EAC7E;AAAA,EACA,GAAG;AACL,GAEgD;AAC9C,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,UAAU,iBAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\nimport useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TData>\n }\n}\n\nexport type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<TParentData, TName>,\n) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>\n\nexport function useField<TParentData, TName extends DeepKeys<TParentData>>(\n opts: UseFieldOptions<TParentData, TName>,\n): FieldApi<\n TParentData,\n TName\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = useState(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })\n\n /**\n * fieldApi.update should not have any side effects. Think of it like a `useRef`\n * that we need to keep updated every render with the most up-to-date information.\n */\n useIsomorphicLayoutEffect(() => {\n fieldApi.update({ ...opts, form: formApi } as never)\n })\n\n useStore(\n fieldApi.store,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n // Instantiates field meta and removes it when unrendered\n useIsomorphicLayoutEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi as never\n}\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n> = {\n children: (fieldApi: FieldApi<TParentData, TName, TData>) => any\n} & (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>\n\nexport type FieldComponent<TParentData> = <\n TName extends DeepKeys<TParentData>,\n TData = DeepValue<TParentData, TName>,\n>({\n children,\n ...fieldOptions\n}: FieldComponentProps<TParentData, TName, TData>) => any\n\nexport function Field<TParentData, TName extends DeepKeys<TParentData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TParentData, TName>) => any\n} & UseFieldOptions<TParentData, TName>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"mappings":";AAAA,OAAO,SAAS,gBAAgB;AAChC,SAAS,gBAAgB;AAEzB,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,mBAAmB;AAC5C,OAAO,+BAA+B;AAkB/B,SAAS,SACd,MAOA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM;AAChC,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN;AAAA,IACF,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,CAAC;AAMD,4BAA0B,MAAM;AAC9B,aAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,EACrD,CAAC;AAED;AAAA,IACE,SAAS;AAAA,IACT,KAAK,SAAS,UACV,CAAC,UAAe;AACd,aAAO,CAAC,MAAM,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,EAAE,MAAM;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,4BAA0B,MAAM,SAAS,MAAM,GAAG,CAAC,QAAQ,CAAC;AAE5D,SAAO;AACT;AA2BO,SAAS,MAAwD;AAAA,EACtE;AAAA,EACA,GAAG;AACL,GAEyC;AACvC,QAAM,WAAW,SAAS,YAAmB;AAE7C,SACE;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAAS,SAAS,MAAM,iBAAiB,SAAS,KAAK;AAAA,MAChE,UAAU,iBAAiB,UAAU,QAAe;AAAA;AAAA,EACtD;AAEJ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-form",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Powerful, type-safe forms for React.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "@tanstack/react-store": "0.1.3",
55
55
  "@tanstack/store": "0.1.3",
56
56
  "use-isomorphic-layout-effect": "^1.1.2",
57
- "@tanstack/form-core": "0.3.5"
57
+ "@tanstack/form-core": "0.3.6"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^17.0.0 || ^18.0.0",
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { FieldOptions, DeepKeys } from '@tanstack/form-core'
1
+ import type { FieldOptions, DeepKeys, DeepValue } from '@tanstack/form-core'
2
2
 
3
3
  export type UseFieldOptions<
4
- TData,
5
4
  TParentData,
6
5
  TName extends DeepKeys<TParentData>,
7
- > = FieldOptions<TData, TParentData, TName> & {
6
+ TData = DeepValue<TParentData, TName>,
7
+ > = FieldOptions<TParentData, TName, TData> & {
8
8
  mode?: 'value' | 'array'
9
9
  }
package/src/useField.tsx CHANGED
@@ -1,11 +1,6 @@
1
1
  import React, { useState } from 'react'
2
2
  import { useStore } from '@tanstack/react-store'
3
- import type {
4
- DeepKeys,
5
- DeepValue,
6
- Narrow,
7
- ResolveData,
8
- } from '@tanstack/form-core'
3
+ import type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'
9
4
  import { FieldApi, functionalUpdate } from '@tanstack/form-core'
10
5
  import { useFormContext, formContext } from './formContext'
11
6
  import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
@@ -14,35 +9,21 @@ import type { UseFieldOptions } from './types'
14
9
  declare module '@tanstack/form-core' {
15
10
  // eslint-disable-next-line no-shadow
16
11
  interface FieldApi<
17
- TData,
18
12
  TParentData,
19
13
  TName extends DeepKeys<TParentData>,
20
- TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<
21
- TData,
22
- TParentData,
23
- TName
24
- >,
14
+ TData = DeepValue<TParentData, TName>,
25
15
  > {
26
16
  Field: FieldComponent<TData>
27
17
  }
28
18
  }
29
19
 
30
20
  export type UseField<TParentData> = <TName extends DeepKeys<TParentData>>(
31
- opts?: { name: Narrow<TName> } & UseFieldOptions<
32
- DeepValue<TParentData, TName>,
33
- TParentData,
34
- TName
35
- >,
36
- ) => FieldApi<DeepValue<TParentData, TName>, TParentData, TName>
21
+ opts?: { name: Narrow<TName> } & UseFieldOptions<TParentData, TName>,
22
+ ) => FieldApi<TParentData, TName, DeepValue<TParentData, TName>>
37
23
 
38
- export function useField<
39
- TData,
40
- TParentData,
41
- TName extends DeepKeys<TParentData>,
42
- >(
43
- opts: UseFieldOptions<TData, TParentData, TName>,
24
+ export function useField<TParentData, TName extends DeepKeys<TParentData>>(
25
+ opts: UseFieldOptions<TParentData, TName>,
44
26
  ): FieldApi<
45
- TData,
46
27
  TParentData,
47
28
  TName
48
29
  // Omit<typeof opts, 'onMount'> & {
@@ -95,14 +76,11 @@ export function useField<
95
76
  }
96
77
 
97
78
  type FieldComponentProps<
98
- TData,
99
79
  TParentData,
100
80
  TName extends DeepKeys<TParentData>,
101
- TResolvedData extends ResolveData<TData, TParentData, TName>,
81
+ TData = DeepValue<TParentData, TName>,
102
82
  > = {
103
- children: (
104
- fieldApi: FieldApi<TData, TParentData, TName, TResolvedData>,
105
- ) => any
83
+ children: (fieldApi: FieldApi<TParentData, TName, TData>) => any
106
84
  } & (TParentData extends any[]
107
85
  ? {
108
86
  name?: TName
@@ -112,27 +90,22 @@ type FieldComponentProps<
112
90
  name: TName
113
91
  index?: never
114
92
  }) &
115
- Omit<UseFieldOptions<TData, TParentData, TName>, 'name' | 'index'>
93
+ Omit<UseFieldOptions<TParentData, TName>, 'name' | 'index'>
116
94
 
117
95
  export type FieldComponent<TParentData> = <
118
- TData,
119
96
  TName extends DeepKeys<TParentData>,
120
- TResolvedData extends ResolveData<TData, TParentData, TName> = ResolveData<
121
- TData,
122
- TParentData,
123
- TName
124
- >,
97
+ TData = DeepValue<TParentData, TName>,
125
98
  >({
126
99
  children,
127
100
  ...fieldOptions
128
- }: FieldComponentProps<TData, TParentData, TName, TResolvedData>) => any
101
+ }: FieldComponentProps<TParentData, TName, TData>) => any
129
102
 
130
- export function Field<TData, TParentData, TName extends DeepKeys<TParentData>>({
103
+ export function Field<TParentData, TName extends DeepKeys<TParentData>>({
131
104
  children,
132
105
  ...fieldOptions
133
106
  }: {
134
- children: (fieldApi: FieldApi<TData, TParentData, TName>) => any
135
- } & UseFieldOptions<TData, TParentData, TName>) {
107
+ children: (fieldApi: FieldApi<TParentData, TName>) => any
108
+ } & UseFieldOptions<TParentData, TName>) {
136
109
  const fieldApi = useField(fieldOptions as any)
137
110
 
138
111
  return (