import type { Component, DeepReadonly, Ref, RendererElement, RendererNode, VNode, WatchStopHandle } from 'vue' import type * as z3 from 'zod/v3' import type * as z4 from 'zod/v4/core' import type { RefinementCtx as z4RefinementCtx } from 'zod/v4' import type { IgnoredUpdater } from '@vueuse/core' import type { FormFieldType, FormStatus } from './enums' type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] type DecrementDepth = Depth[D] export type EffectType = D extends 0 ? T : T | z3.ZodOptional | z3.ZodNullable | z3.ZodDefault | z3.ZodEffects>> export type $EffectType = D extends 0 ? T : T | z4.$ZodOptional<$EffectType>> | z4.$ZodNullable<$EffectType>> | z4.$ZodDefault<$EffectType>> | z4.$ZodPipe<$EffectType>, z4.$ZodType> // FormSchema garantisce sempre la presenza di safeParse export type FormSchema = z3.ZodTypeAny | z4.$ZodType export type InferSchema = T extends EffectType ? z3.z.infer : z4.infer export type InferFormattedError = T extends EffectType ? z3.z.inferFormattedError : z4.$ZodFormattedError export type RefinementCtx = z3.RefinementCtx | z4RefinementCtx export type VvZodError = T extends EffectType ? z3.ZodError : z4.$ZodError export type ZodIssue = z3.ZodIssue | z4.$ZodIssue export type FormFieldComponentOptions = { lazyLoad?: boolean sideEffects?: (type: `${FormFieldType}`) => Promise | void } export type FormComponentOptions = { updateThrottle?: number continuousValidation?: boolean readonly?: boolean template?: Schema extends FormSchema ? FormTemplate : never class?: Schema extends FormSchema ? new (data?: Partial>) => Type : never onUpdate?: Schema extends FormSchema ? (data?: undefined extends Type ? Partial> : Type) => void : never onSubmit?: Schema extends FormSchema ? (data?: undefined extends Type ? Partial> : Type) => void : never onReset?: Schema extends FormSchema ? (data?: undefined extends Type ? Partial> : Type) => void : never onInvalid?: Schema extends FormSchema ? (error?: InferFormattedError) => void : never onValid?: Schema extends FormSchema ? (data?: undefined extends Type ? Partial> : Type) => void : never } export type FormComposableOptions = FormFieldComponentOptions & FormComponentOptions & { scope?: string } type FormPluginOptionsSchema>> = { schema?: FormSchema factory?: (data?: Partial>) => T } export type FormPluginOptions = FormPluginOptionsSchema & FormComposableOptions export type InjectedFormData = { formData: Ref<(undefined extends Type ? Partial> : Type) | undefined> errors: Readonly< Ref> | undefined> > submit: () => Promise validate: (formData?: undefined extends Type ? Partial> : Type, options?: { fields?: Set>> superRefine?: (arg: InferSchema, ctx: RefinementCtx) => void | Promise }) => Promise clear: () => void reset: () => void ignoreUpdates: IgnoredUpdater stopUpdatesWatch: WatchStopHandle status: Readonly> invalid: Readonly> readonly: Ref wrappers: Map> } export type InjectedFormWrapperData = { name: Readonly> errors: Ref | undefined>> invalid: Readonly> readonly: Readonly> fields: Ref> } export type InjectedFormFieldData = { name: Readonly>>> errors: Readonly | undefined>>> } export type InjectedFormFieldsGroupData = { names: DeepReadonly>[]>> errors: Readonly> | undefined>>> } export type Primitive = | null | undefined | string | number | boolean | symbol | bigint type IsTuple = number extends T['length'] ? false : true type TupleKeys = Exclude export type PathConcat< TKey extends string | number, TValue, > = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path}` export type Path = T extends readonly (infer V)[] ? IsTuple extends true ? { [K in TupleKeys]-?: PathConcat }[TupleKeys] : PathConcat : { [K in keyof T]-?: PathConcat }[keyof T] export type PathValue | Path[]> = T extends any ? TPath extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path ? undefined extends T[K] ? PathValue | undefined : PathValue : never : K extends `${number}` ? T extends readonly (infer V)[] ? PathValue> : never : never : TPath extends keyof T ? T[TPath] : TPath extends `${number}` ? T extends readonly (infer V)[] ? V : never : never : never export type AnyBoolean = | boolean | Ref | ((data?: InjectedFormData) => boolean | Ref) export type SimpleFormTemplateItem = Record< string, any > & { vvIs?: string | Component vvName?: Path> vvSlots?: Record vvChildren?: | Array< | SimpleFormTemplateItem | (( data?: InjectedFormData, scope?: Record, ) => SimpleFormTemplateItem) > | (( data?: InjectedFormData, scope?: Record, ) => Array< | SimpleFormTemplateItem | (( data?: InjectedFormData, scope?: Record, ) => SimpleFormTemplateItem) >) vvIf?: AnyBoolean | Path> vvElseIf?: AnyBoolean | Path> vvType?: `${FormFieldType}` vvShowValid?: boolean vvContent?: string vvDefaultValue?: any } export type FormTemplateItem = | SimpleFormTemplateItem | (( data?: InjectedFormData, scope?: Record, ) => SimpleFormTemplateItem) export type FormTemplate = | FormTemplateItem[] | (( data?: InjectedFormData, scope?: Record, ) => FormTemplateItem[]) export type RenderFunctionOutput = VNode