diff --git a/app/frontend/src/javascript/components/base/rhf-input.tsx b/app/frontend/src/javascript/components/base/rhf-input.tsx index a23c4be53..1c90cbafb 100644 --- a/app/frontend/src/javascript/components/base/rhf-input.tsx +++ b/app/frontend/src/javascript/components/base/rhf-input.tsx @@ -1,20 +1,22 @@ import React, { ReactNode } from 'react'; -import { FieldErrors, UseFormRegister, Validate } from 'react-hook-form'; +import { FieldErrors, FieldPathValue, UseFormRegister, Validate } from 'react-hook-form'; +import { FieldValues } from 'react-hook-form/dist/types/fields'; +import { FieldPath } from 'react-hook-form/dist/types/path'; type inputType = string|number|readonly string []; -type ruleTypes = { +type ruleTypes = { required?: boolean | string, pattern?: RegExp | {value: RegExp, message: string}, minLenght?: number, maxLenght?: number, min?: number, max?: number, - validate?: Validate; + validate?: Validate; }; -interface RHFInputProps { +interface RHFInputProps { id: string, - register: UseFormRegister, + register: UseFormRegister, label?: string, tooltip?: string, defaultValue?: inputType, @@ -22,7 +24,7 @@ interface RHFInputProps { addOn?: ReactNode, addOnClassName?: string, classes?: string, - rules?: ruleTypes, + rules?: ruleTypes, readOnly?: boolean, disabled?: boolean, placeholder?: string, @@ -34,8 +36,7 @@ interface RHFInputProps { /** * This component is a template for an input component to use within React Hook Form */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const RHFInput: React.FC> = ({ id, register, label, tooltip, defaultValue, icon, classes, rules, readOnly, disabled, type, addOn, addOnClassName, placeholder, error, step }) => { +export const RHFInput = ({ id, register, label, tooltip, defaultValue, icon, classes, rules, readOnly, disabled, type, addOn, addOnClassName, placeholder, error, step }: RHFInputProps) => { // Compose classnames from props const classNames = ` rhf-input ${classes || ''} @@ -54,10 +55,10 @@ export const RHFInput: React.FC> = ({ id, register, label, to
{icon && {icon}} , { ...rules, valueAsNumber: type === 'number', - value: defaultValue + value: defaultValue as FieldPathValue> })} type={type} step={step}