11import * as React from 'react' ;
2- import Dropzone , { DropzoneProps } from 'react-dropzone' ;
2+ import Dropzone , { DropzoneProps , DropFileEventHandler } from 'react-dropzone' ;
33import { Omit } from '../../helpers' ;
44import { FileUploadField , FileUploadFieldProps } from './FileUploadField' ;
55import { readFile , fileReaderType } from '../../helpers/fileUtils' ;
@@ -75,22 +75,20 @@ export interface FileUploadProps
7575 dropzoneProps ?: DropzoneProps ;
7676}
7777
78- // TODO handle an optional message for errors without using FieldGroup
79-
8078export const FileUpload : React . FunctionComponent < FileUploadProps > = ( {
8179 id,
8280 type,
8381 value = type === fileReaderType . text || type === fileReaderType . dataURL ? '' : null ,
8482 filename = '' ,
8583 children = null ,
86- onChange = ( ) : any => undefined ,
87- onReadStarted = ( ) : any => undefined ,
88- onReadFinished = ( ) : any => undefined ,
89- onReadFailed = ( ) : any => undefined ,
84+ onChange = ( ) => { } ,
85+ onReadStarted = ( ) => { } ,
86+ onReadFinished = ( ) => { } ,
87+ onReadFailed = ( ) => { } ,
9088 dropzoneProps = { } ,
9189 ...props
9290} : FileUploadProps ) => {
93- const onDropAccepted = async ( acceptedFiles : File [ ] , event : React . DragEvent < HTMLElement > ) => {
91+ const onDropAccepted : DropFileEventHandler = async ( acceptedFiles : File [ ] , event : React . DragEvent < HTMLElement > ) => {
9492 if ( acceptedFiles . length > 0 ) {
9593 const fileHandle = acceptedFiles [ 0 ] ;
9694 if ( type === fileReaderType . text || type === fileReaderType . dataURL ) {
@@ -110,7 +108,7 @@ export const FileUpload: React.FunctionComponent<FileUploadProps> = ({
110108 dropzoneProps . onDropAccepted && dropzoneProps . onDropAccepted ( acceptedFiles , event ) ;
111109 } ;
112110
113- const onDropRejected = ( rejectedFiles : File [ ] , event : React . DragEvent < HTMLElement > ) => {
111+ const onDropRejected : DropFileEventHandler = ( rejectedFiles : File [ ] , event : React . DragEvent < HTMLElement > ) => {
114112 if ( rejectedFiles . length > 0 ) {
115113 onChange ( '' , rejectedFiles [ 0 ] . name , event ) ;
116114 }
0 commit comments