import type { AnyFieldApi, AnyFormApi, BaseFormOptions, DeepKeysOfType, FieldApi, FieldsMap, FormAsyncValidateOrFn, FormOptions, FormValidateOrFn } from '@tanstack/form-core'; import type { Accessor, Component, Context, JSXElement, ParentProps } from 'solid-js'; import type { FieldComponent } from './createField'; import type { AppFieldExtendedSolidFieldGroupApi } from './createFieldGroup'; import type { SolidFormExtendedApi } from './createForm'; /** * TypeScript inferencing is weird. * * If you have: * * @example * * interface Args { * arg?: T * } * * function test(arg?: Partial>): T { * return 0 as any; * } * * const a = test({}); * * Then `T` will default to `unknown`. * * However, if we change `test` to be: * * @example * * function test(arg?: Partial>): T; * * Then `T` becomes `undefined`. * * Here, we are checking if the passed type `T` extends `DefaultT` and **only** * `DefaultT`, as if that's the case we assume that inferencing has not occurred. */ type UnwrapOrAny = [unknown] extends [T] ? any : T; type UnwrapDefaultOrAny = [DefaultT] extends [T] ? [T] extends [DefaultT] ? any : T : T; export declare function createFormHookContexts(): { fieldContext: Context>; useFieldContext: () => Accessor>; useFormContext: () => SolidFormExtendedApi, any, any, any, any, any, any, any, any, any, any, any>; formContext: Context; }; interface CreateFormHookProps>, TFormComponents extends Record>> { fieldComponents: TFieldComponents; fieldContext: Context>; formComponents: TFormComponents; formContext: Context; } /** * @private */ export type AppFieldExtendedSolidFormApi, TOnChange extends undefined | FormValidateOrFn, TOnChangeAsync extends undefined | FormAsyncValidateOrFn, TOnBlur extends undefined | FormValidateOrFn, TOnBlurAsync extends undefined | FormAsyncValidateOrFn, TOnSubmit extends undefined | FormValidateOrFn, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn, TOnDynamic extends undefined | FormValidateOrFn, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn, TOnServer extends undefined | FormAsyncValidateOrFn, TSubmitMeta, TFieldComponents extends Record>, TFormComponents extends Record>> = SolidFormExtendedApi & NoInfer & { AppField: FieldComponent>; AppForm: Component; }; export interface WithFormProps, TOnChange extends undefined | FormValidateOrFn, TOnChangeAsync extends undefined | FormAsyncValidateOrFn, TOnBlur extends undefined | FormValidateOrFn, TOnBlurAsync extends undefined | FormAsyncValidateOrFn, TOnSubmit extends undefined | FormValidateOrFn, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn, TOnDynamic extends undefined | FormValidateOrFn, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn, TOnServer extends undefined | FormAsyncValidateOrFn, TSubmitMeta, TFieldComponents extends Record>, TFormComponents extends Record>, TRenderProps extends Record = Record> extends FormOptions { props?: TRenderProps; render: (props: ParentProps & { form: AppFieldExtendedSolidFormApi; }>) => JSXElement; } export interface WithFieldGroupProps>, TFormComponents extends Record>, TSubmitMeta, TRenderProps extends Record = Record> extends BaseFormOptions { props?: TRenderProps; render: (props: ParentProps & { group: AppFieldExtendedSolidFieldGroupApi, undefined | FormValidateOrFn, undefined | FormValidateOrFn, undefined | FormAsyncValidateOrFn, undefined | FormValidateOrFn, undefined | FormAsyncValidateOrFn, undefined | FormValidateOrFn, undefined | FormAsyncValidateOrFn, undefined | FormValidateOrFn, undefined | FormAsyncValidateOrFn, undefined | FormAsyncValidateOrFn, unknown extends TSubmitMeta ? never : TSubmitMeta, TFieldComponents, TFormComponents>; }>) => JSXElement; } export declare function createFormHook>, const TFormComponents extends Record>>(opts: CreateFormHookProps): { useAppForm: , TOnChange extends undefined | FormValidateOrFn, TOnChangeAsync extends undefined | FormAsyncValidateOrFn, TOnBlur extends undefined | FormValidateOrFn, TOnBlurAsync extends undefined | FormAsyncValidateOrFn, TOnSubmit extends undefined | FormValidateOrFn, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn, TOnDynamic extends undefined | FormValidateOrFn, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn, TOnServer extends undefined | FormAsyncValidateOrFn, TSubmitMeta>(props: Accessor>) => AppFieldExtendedSolidFormApi; withForm: , TOnChange extends undefined | FormValidateOrFn, TOnChangeAsync extends undefined | FormAsyncValidateOrFn, TOnBlur extends undefined | FormValidateOrFn, TOnBlurAsync extends undefined | FormAsyncValidateOrFn, TOnSubmit extends undefined | FormValidateOrFn, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn, TOnDynamic extends undefined | FormValidateOrFn, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn, TOnServer extends undefined | FormAsyncValidateOrFn, TSubmitMeta, TRenderProps extends Record = {}>({ render, props, }: WithFormProps) => WithFormProps, UnwrapDefaultOrAny, TOnMount>, UnwrapDefaultOrAny, TOnChange>, UnwrapDefaultOrAny, TOnChangeAsync>, UnwrapDefaultOrAny, TOnBlur>, UnwrapDefaultOrAny, TOnBlurAsync>, UnwrapDefaultOrAny, TOnSubmit>, UnwrapDefaultOrAny, TOnSubmitAsync>, UnwrapDefaultOrAny, TOnDynamic>, UnwrapDefaultOrAny, TOnDynamicAsync>, UnwrapDefaultOrAny, TOnServer>, UnwrapOrAny, UnwrapOrAny, UnwrapOrAny, UnwrapOrAny>["render"]; withFieldGroup: = {}>({ render, props, defaultValues, }: WithFieldGroupProps) => | FieldsMap, TOnMount extends undefined | FormValidateOrFn, TOnChange extends undefined | FormValidateOrFn, TOnChangeAsync extends undefined | FormAsyncValidateOrFn, TOnBlur extends undefined | FormValidateOrFn, TOnBlurAsync extends undefined | FormAsyncValidateOrFn, TOnSubmit extends undefined | FormValidateOrFn, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn, TOnDynamic extends undefined | FormValidateOrFn, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn, TOnServer extends undefined | FormAsyncValidateOrFn, TFormSubmitMeta>(params: ParentProps & { form: AppFieldExtendedSolidFormApi | AppFieldExtendedSolidFieldGroupApi, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, TComponents, TFormComponents>; fields: TFields; }>) => JSXElement; }; export {};