dynamic-modal
Version:
The dynamic-modal is a solution of creation different modals into project using a json configuration file
35 lines (34 loc) • 1.07 kB
TypeScript
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;
customProperties?: Record<string, any>;
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>;
}