UNPKG

remix-validated-form

Version:

Form component and utils for easy form validation in remix

30 lines (29 loc) 1.17 kB
export type ValidationBehavior = "onBlur" | "onChange" | "onSubmit"; export type ValidationBehaviorOptions = { initial: ValidationBehavior; whenTouched: ValidationBehavior; whenSubmitted: ValidationBehavior; }; export type CreateGetInputPropsOptions = { clearError: () => void; validate: () => void; defaultValue?: any; touched: boolean; setTouched: (touched: boolean) => void; hasBeenSubmitted: boolean; validationBehavior?: Partial<ValidationBehaviorOptions>; name: string; }; type HandledProps = "name" | "defaultValue" | "defaultChecked"; type Callbacks = "onChange" | "onBlur"; type MinimalInputProps = { onChange?: (...args: any[]) => void; onBlur?: (...args: any[]) => void; defaultValue?: any; defaultChecked?: boolean; name?: string; type?: string; }; export type GetInputProps = <T extends MinimalInputProps>(props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>) => T; export declare const createGetInputProps: ({ clearError, validate, defaultValue, touched, setTouched, hasBeenSubmitted, validationBehavior, name, }: CreateGetInputPropsOptions) => GetInputProps; export {};