UNPKG

4.05 kBTypeScriptView Raw
1import * as React from 'react';
2import { DropzoneProps } from 'react-dropzone';
3import { FileUploadFieldProps } from './FileUploadField';
4export interface FileUploadProps extends Omit<FileUploadFieldProps, 'children' | 'onBrowseButtonClick' | 'onClearButtonClick' | 'isDragActive' | 'containerRef'> {
5 /** Unique id for the TextArea, also used to generate ids for accessible labels. */
6 id: string;
7 /** What type of file. Determines what is is passed to `onChange` and expected by `value`
8 * (a string for 'text' and 'dataURL', or a File object otherwise. */
9 type?: 'text' | 'dataURL';
10 /** Value of the file's contents
11 * (string if text file, File object otherwise) */
12 value?: string | File;
13 /** Value to be shown in the read-only filename field. */
14 filename?: string;
15 /** @deprecated A callback for when the file contents change. Please instead use onFileInputChange, onTextChange, onDataChange, onClearClick individually. */
16 onChange?: (value: string | File, filename: string, event: React.MouseEvent<HTMLButtonElement, MouseEvent> | React.DragEvent<HTMLElement> | React.ChangeEvent<HTMLElement>) => void;
17 /** Change event emitted from the hidden \<input type="file" \> field associated with the component */
18 onFileInputChange?: (event: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLElement>, file: File) => void;
19 /** Callback for clicking on the FileUploadField text area. By default, prevents a click in the text area from opening file dialog. */
20 onClick?: (event: React.MouseEvent) => void;
21 /** Additional classes added to the FileUpload container element. */
22 className?: string;
23 /** Flag to show if the field is disabled. */
24 isDisabled?: boolean;
25 /** Flag to show if the field is read only. */
26 isReadOnly?: boolean;
27 /** Flag to show if a file is being loaded. */
28 isLoading?: boolean;
29 /** Aria-valuetext for the loading spinner */
30 spinnerAriaValueText?: string;
31 /** Flag to show if the field is required. */
32 isRequired?: boolean;
33 /** Value to indicate if the field is modified to show that validation state.
34 * If set to success, field will be modified to indicate valid state.
35 * If set to error, field will be modified to indicate error state.
36 */
37 validated?: 'success' | 'error' | 'default';
38 /** Aria-label for the TextArea. */
39 'aria-label'?: string;
40 /** Placeholder string to display in the empty filename field */
41 filenamePlaceholder?: string;
42 /** Aria-label for the read-only filename field */
43 filenameAriaLabel?: string;
44 /** Text for the Browse button */
45 browseButtonText?: string;
46 /** Text for the Clear button */
47 clearButtonText?: string;
48 /** Flag to hide the built-in preview of the file (where available).
49 * If true, you can use children to render an alternate preview. */
50 hideDefaultPreview?: boolean;
51 /** Flag to allow editing of a text file's contents after it is selected from disk */
52 allowEditingUploadedText?: boolean;
53 /** Additional children to render after (or instead of) the file preview. */
54 children?: React.ReactNode;
55 /** A callback for when a selected file starts loading */
56 onReadStarted?: (fileHandle: File) => void;
57 /** A callback for when a selected file finishes loading */
58 onReadFinished?: (fileHandle: File) => void;
59 /** A callback for when the FileReader API fails */
60 onReadFailed?: (error: DOMException, fileHandle: File) => void;
61 /** Optional extra props to customize react-dropzone. */
62 dropzoneProps?: DropzoneProps;
63 /** Clear button was clicked */
64 onClearClick?: React.MouseEventHandler<HTMLButtonElement>;
65 /** Text area text changed */
66 onTextChange?: (text: string) => void;
67 /** On data changed - if type='text' or type='dataURL' and file was loaded it will call this method */
68 onDataChange?: (data: string) => void;
69}
70export declare const FileUpload: React.FunctionComponent<FileUploadProps>;
71//# sourceMappingURL=FileUpload.d.ts.map
\No newline at end of file