UNPKG

3.45 kBTypeScriptView Raw
1import * as React from 'react';
2export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
3 /** Unique id for the TextArea, also used to generate ids for accessible labels */
4 id: string;
5 /** What type of file. Determines what is is expected by `value`
6 * (a string for 'text' and 'dataURL', or a File object otherwise). */
7 type?: 'text' | 'dataURL';
8 /** Value of the file's contents
9 * (string if text file, File object otherwise) */
10 value?: string | File;
11 /** Value to be shown in the read-only filename field. */
12 filename?: string;
13 /** A callback for when the TextArea value changes. */
14 onChange?: (value: string, filename: string, event: React.ChangeEvent<HTMLTextAreaElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
15 /** Additional classes added to the FileUploadField container element. */
16 className?: string;
17 /** Flag to show if the field is disabled. */
18 isDisabled?: boolean;
19 /** Flag to show if the field is read only. */
20 isReadOnly?: boolean;
21 /** Flag to show if a file is being loaded. */
22 isLoading?: boolean;
23 /** Aria-valuetext for the loading spinner */
24 spinnerAriaValueText?: string;
25 /** Flag to show if the field is required. */
26 isRequired?: boolean;
27 /** Value to indicate if the field is modified to show that validation state.
28 * If set to success, field will be modified to indicate valid state.
29 * If set to error, field will be modified to indicate error state.
30 */
31 validated?: 'success' | 'error' | 'default';
32 /** Aria-label for the TextArea. */
33 'aria-label'?: string;
34 /** Placeholder string to display in the empty filename field */
35 filenamePlaceholder?: string;
36 /** Aria-label for the read-only filename field */
37 filenameAriaLabel?: string;
38 /** Text for the Browse button */
39 browseButtonText?: string;
40 /** Text for the Clear button */
41 clearButtonText?: string;
42 /** Flag to disable the Clear button */
43 isClearButtonDisabled?: boolean;
44 /** Flag to hide the built-in preview of the file (where available).
45 * If true, you can use children to render an alternate preview. */
46 hideDefaultPreview?: boolean;
47 /** Flag to allow editing of a text file's contents after it is selected from disk */
48 allowEditingUploadedText?: boolean;
49 /** Additional children to render after (or instead of) the file preview. */
50 children?: React.ReactNode;
51 /** A callback for when the Browse button is clicked. */
52 onBrowseButtonClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
53 /** A callback for when the Clear button is clicked. */
54 onClearButtonClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
55 /** A callback from when the text area is clicked. Can also be set via the onClick property of FileUpload. */
56 onTextAreaClick?: (event: React.MouseEvent<HTMLTextAreaElement, MouseEvent>) => void;
57 /** Flag to show if a file is being dragged over the field */
58 isDragActive?: boolean;
59 /** A reference object to attach to the FileUploadField container element. */
60 containerRef?: React.Ref<HTMLDivElement>;
61 /** Text area text changed */
62 onTextChange?: (text: string) => void;
63}
64export declare const FileUploadField: React.FunctionComponent<FileUploadFieldProps>;
65//# sourceMappingURL=FileUploadField.d.ts.map
\No newline at end of file