LibreChat/client/src/components/ui/FileUpload.tsx
Danny Avila 2996058fa2
🔘 a11y: Switch Contrast and File Input Key Events to WCAG (#4536)
* 🔘 a11y: Improve Contrast of Switch/Toggles to WCAG Standard

* refactor: Improve file attachment accessibility in Chat Input component

* refactor: clear input ref value before clicks
2024-10-24 09:12:49 -04:00

29 lines
630 B
TypeScript

import React, { forwardRef } from 'react';
type FileUploadProps = {
className?: string;
onClick?: () => void;
children: React.ReactNode;
handleFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
};
const FileUpload = forwardRef<HTMLInputElement, FileUploadProps>(
({ children, handleFileChange }, ref) => {
return (
<>
{children}
<input
ref={ref}
multiple
type="file"
style={{ display: 'none' }}
onChange={handleFileChange}
/>
</>
);
},
);
FileUpload.displayName = 'FileUpload';
export default FileUpload;