import { ComputedRef } from 'vue'; import { DefineSetupFnComponent } from 'vue'; import { InputHTMLAttributes } from 'vue'; import { PublicProps } from 'vue'; import { Ref } from 'vue'; import { SlotsType } from 'vue'; import { WritableComputedRef } from 'vue'; declare const ErrorComp: = Record>() => DefineSetupFnComponent< { errorFor: GetKeys; }, {}, SlotsType<{ default: { error: any; }; }>, { errorFor: GetKeys; } & {}, PublicProps>; declare type ExtractValue = K extends `${infer Root}.${infer Rest}` ? Root extends keyof T ? ExtractValue : Root extends `${infer ArrayRoot}[${number}]` ? ArrayRoot extends keyof T ? T[ArrayRoot] extends (infer U)[] ? ExtractValue : never : never : never : K extends `${infer Root}[${number}]` ? Root extends keyof T ? T[Root] extends (infer U) ? UnwrapArray : never : never : K extends keyof T ? UnwrapArray : never; declare const FieldArrayComp: = Record>() => DefineSetupFnComponent extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never, any, SlotsType<{ default: { fields: { id: number; }[]; add: () => void; remove: (idx: number) => void; error: any; }; }>, (FieldArrayType extends infer T_2 ? { [K in keyof T_2]: T_2[K]; } : never) & ({} | { [x: `on${Capitalize}`]: ((...args: any[]) => any) | undefined; } | { [x: `on${Capitalize}`]: ((...args: any[] | unknown[]) => any) | undefined; }), PublicProps>; declare type FieldArrayType> = { [K in GetKeys]: { name: K; default?: ExtractValue; error?: any; ignore?: boolean; modelValue?: any; preserve?: boolean; rule?: StandardSchemaV1; } & InputHTMLAttributes; }[GetKeys]; declare const FieldComp: = Record>() => DefineSetupFnComponent extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never, any, SlotsType<{ default: { field: { value: any; modelValue: any; isValid: boolean; error: any; }; }; }>, (FieldType extends infer T_2 ? { [K in keyof T_2]: T_2[K]; } : never) & ({} | { [x: `on${Capitalize}`]: ((...args: any[]) => any) | undefined; } | { [x: `on${Capitalize}`]: ((...args: any[] | unknown[]) => any) | undefined; }), PublicProps>; declare type FieldType> = { [K in GetKeys]: { name: K; default?: ExtractValue; error?: any; ignore?: boolean; trueValue?: any; modelValue?: any; falseValue?: any; preserve?: boolean; custom?: boolean; as?: 'input' | 'select'; rule?: StandardSchemaV1; } & InputHTMLAttributes; }[GetKeys]; declare const FormComponent: = Record>(opt?: FormOptions) => { cmp: DefineSetupFnComponent< { enctype?: "application/x-www-form-urlencoded" | "multipart/form-data" | undefined; action?: string | undefined; initialValues?: RecursivePartial | undefined; name?: string | undefined; onValueChange?: ((value?: any) => void) | undefined; onSubmit?: ((value?: any, $event?: SubmitEvent) => void | Promise) | undefined; }, ("submit" | "value-change")[], SlotsType<{ default: { values: T; getError: (name: GetKeys) => string; isDirty: boolean; isValid: boolean; }; }>, { enctype?: "application/x-www-form-urlencoded" | "multipart/form-data" | undefined; action?: string | undefined; initialValues?: RecursivePartial | undefined; name?: string | undefined; onValueChange?: ((value?: any) => void) | undefined; onSubmit?: ((value?: any, $event?: SubmitEvent) => void | Promise) | undefined; } & { onSubmit?: ((...args: any[]) => any) | undefined; "onValue-change"?: ((...args: any[]) => any) | undefined; }, PublicProps>; values: WritableComputedRef; isSubmitting: Ref; reset: (force?: boolean) => void; setInitialValues: (initials: Partial) => void; setValue: (name: GetKeys, value: any) => void; setValues: (values: Partial) => void; setError: (name: GetKeys, error: any) => void; handleSubmit: (cb?: (data?: T) => void | Promise) => () => Promise; }; declare type FormOptions> = { initialValues?: T extends Record ? RecursivePartial : Record; schema?: StandardSchemaV1; name?: string; preserve?: boolean; mode?: 'onChange' | 'onSubmit'; }; export declare type FormType = Record> = { values: T; errors: T; isSubmitting: boolean; setError: (name: GetKeys, error: any) => void; updateField: (name: GetKeys, value: any) => void; reset: () => void; flush: () => void; }; declare type GetKeys> = keyof { [K in keyof T as (T[K] extends (infer U)[] ? U extends object ? IsPlainObject extends true ? `${K & string}` | `${K & string}[]` | `${K & string}[${number}]` | `${K & string}[].${GetNestedArray}` | `${K & string}[${number}].${GetNestedArray}` : `${K & string}` | `${K & string}[]` | `${K & string}[${number}]` : `${K & string}` | `${K & string}[]` | `${K & string}[${number}]` : T[K] extends object ? IsPlainObject extends true ? `${K & string}` | `${K & string}.${GetNestedArray}` : `${K & string}` : `${K & string}`)]: any; }; declare type GetNestedArray = T extends object ? IsPlainObject extends true ? { [K in keyof T]: T[K] extends (infer U)[] ? U extends object ? IsPlainObject extends true ? `${K & string}[]` | `${K & string}[${number}]` | `${K & string}[].${GetNestedArray}` | `${K & string}[${number}].${GetNestedArray}` : `${K & string}[]` | `${K & string}[${number}]` : `${K & string}[]` | `${K & string}[${number}]` : T[K] extends object ? IsPlainObject extends true ? `${K & string}` | `${K & string}.${GetNestedArray}` : `${K & string}` : `${K & string}`; }[keyof T] : '' : ''; export declare type InputProps = Record> = { name?: GetKeys; default?: any; error?: any; ignore?: boolean; trueValue?: any; modelValue?: any; falseValue?: any; preserve?: boolean; as?: 'input' | 'select'; rule?: StandardSchemaV1; onInput?: (evt: any) => void; onChange?: (evt: any) => void; onFocus?: () => void; onBlur?: () => void; }; declare type IsPlainObject = T extends object ? T extends Date | RegExp | Map | Set | WeakMap | WeakSet | any[] ? false : true : false; declare type RecursivePartial = { [P in keyof T]?: T[P] extends Record ? RecursivePartial : T[P]; }; /** The Standard Schema interface. */ declare interface StandardSchemaV1 { /** The Standard Schema properties. */ readonly '~standard': StandardSchemaV1.Props; } declare namespace StandardSchemaV1 { /** The Standard Schema properties interface. */ interface Props { /** The version number of the standard. */ readonly version: 1; /** The vendor name of the schema library. */ readonly vendor: string; /** Default input values. */ default?: unknown; /** Validates unknown input values. */ readonly validate: (value: unknown) => Result | Promise>; /** Inferred types associated with the schema. */ readonly types?: Types | undefined; } /** The result interface of the validate function. */ type Result = SuccessResult | FailureResult; /** The result interface if validation succeeds. */ interface SuccessResult { /** The typed output value. */ readonly value: Output; /** The non-existent issues. */ readonly issues?: undefined; } /** The result interface if validation fails. */ interface FailureResult { /** The issues of failed validation. */ readonly issues: readonly Issue[]; } /** The issue interface of the failure output. */ interface Issue { /** The error message of the issue. */ readonly message: string; /** The path of the issue, if any. */ readonly path?: readonly (PropertyKey | PathSegment)[] | undefined; } /** The path segment interface of the issue. */ interface PathSegment { /** The key representing a path segment. */ readonly key: PropertyKey; } /** The Standard Schema types interface. */ interface Types { /** The input type of the schema. */ readonly input: Input; /** The output type of the schema. */ readonly output: Output; } /** Infers the input type of a Standard Schema. */ type InferInput = NonNullable['input']; /** Infers the output type of a Standard Schema. */ type InferOutput = NonNullable['output']; } declare type UnwrapArray = T extends (infer U)[] ? U[] | U : T; export declare const useForm: >(opt?: FormOptions) => UseFormReturn; declare type UseFormReturn> = { Form: ReturnType>['cmp']; Field: ReturnType>; FieldArray: ReturnType>; Error: ReturnType>; reset: ReturnType>['reset']; setInitialValues: ReturnType>['setInitialValues']; setValue: ReturnType>['setValue']; setValues: ReturnType>['setValues']; setError: ReturnType>['setError']; handleSubmit: ReturnType>['handleSubmit']; values: ReturnType>['values']; isSubmitting: ReturnType>['isSubmitting']; }; export declare const useInput: = InputProps>(props: FieldType | (FieldArrayType & { trueValue: any; falseValue: any; }) | InputProps, opt?: UseInputOption) => { value: WritableComputedRef; isValid: ComputedRef; isTouched: ComputedRef; isDirty: ComputedRef; inputProps: any; getError: () => any; setError: (fieldName: string, error: any) => void; setArrayValue: (value: any, key?: any) => void; setValue: (newValue: any) => any; }; declare type UseInputOption = { isArray?: boolean; isComponent?: boolean; isCheckbox?: boolean; }; export { }