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>;
}
