import { InputGroup, VisuallyHiddenInput } from '@chakra-ui/react'; import type { ChangeEvent } from 'react'; import React from 'react'; import type { ControllerRenderProps, FieldValues, Path } from 'react-hook-form'; interface Props> { children: React.ReactNode; field: ControllerRenderProps; accept?: string; multiple?: boolean; } const FileInput = >({ children, accept, multiple, field }: Props) => { const ref = React.useRef(null); const handleInputChange = React.useCallback((event: ChangeEvent) => { const fileList = event.target.files; if (!fileList) { return; } const files = Array.from(fileList); field.onChange(files); field.onBlur(); }, [ field ]); const handleClick = React.useCallback(() => { ref.current?.click(); }, []); const handleInputBlur = React.useCallback(() => { field.onBlur(); }, [ field ]); return ( { children } ); }; export default FileInput;