@explita/daily-toolset-components
Version:
A lightweight and versatile collection of TypeScript utility functions and form components, inspired by ShadCN UI, designed for seamless everyday development. Enhance your Node.js, React, and Next.js projects with a well-structured suite of helpers for st
28 lines (27 loc) • 1.03 kB
TypeScript
import { z, ZodTypeAny } from "zod";
import { DefaultSchema, UseFormHook } from "../form.hook.type";
type BaseCommonProps<S> = {
errors?: Partial<Record<keyof S, string>>;
mode?: "controlled" | "uncontrolled";
errorParser?: (message: string) => string;
};
type CommonProps<S> = (BaseCommonProps<S> & {
persist: true;
persistKey: string;
}) | (BaseCommonProps<S> & {
persist?: false | undefined;
persistKey?: never;
});
export declare function useForm<Schema extends ZodTypeAny>(props: {
schema: Schema;
defaultValues?: Partial<z.infer<Schema>>;
} & CommonProps<z.infer<Schema>>): UseFormHook<z.infer<Schema>>;
export declare function useForm<DefaultValues extends DefaultSchema = DefaultSchema>(props: {
defaultValues?: DefaultValues;
schema?: ZodTypeAny;
} & CommonProps<DefaultValues>): UseFormHook<DefaultValues>;
export declare function useForm(props?: {
defaultValues?: undefined;
schema?: undefined;
} & CommonProps<DefaultSchema>): UseFormHook<DefaultSchema>;
export {};