UNPKG

dynamic-modal

Version:

The dynamic-modal is a solution of creation different modals into project using a json configuration file

34 lines (33 loc) 1.02 kB
import { CSSProperties } from 'react'; import { Control, FieldValues, UseFormSetValue, UseFormUnregister, UseFormWatch } from 'react-hook-form'; import { IModalRenderCondition } from './modal'; export interface IValidationBase<T> { value: T; message: string; } export interface IField { name: string; id?: string; label?: string; style?: CSSProperties; placeholder?: string; defaultValue?: any; renderIf?: IModalRenderCondition; enableIf?: IModalRenderCondition; validation: { required: boolean; regex?: RegExp; message?: string; maxLength?: IValidationBase<number>; minLength?: IValidationBase<number>; min?: IValidationBase<number | string>; max?: IValidationBase<number | string>; }; disabled?: boolean; } export interface IFieldProps { control: Control<FieldValues, unknown>; watch: UseFormWatch<FieldValues>; setValue: UseFormSetValue<FieldValues>; unregister: UseFormUnregister<FieldValues>; }