-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
60 lines (55 loc) · 2.07 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import * as React from 'react';
import {StyledComponent} from "styled-components";
export const UploadArea: StyledComponent;
export interface DragContainerProps {
onDragEnter: React.EventHandler<void>;
onDragLeave: React.EventHandler<void>;
onDragExit: React.EventHandler<void>;
onDragEnd: React.EventHandler<void>;
onDrop: React.EventHandler<void>;
isDragging: boolean;
}
export interface FileInputChildrenProps {
dragContainerProps: DragContainerProps;
fileInput: React.ReactNode;
}
export interface FileInputProps {
/**
* handler called before uploading started
*/
onStartUploading?: () => void;
/**
* handler called with (result, event), where result is onUpload result or FileReader result, if onUpload not provided
*/
onChange?: (src: string | ArrayBuffer | null, event: React.SyntheticEvent) => void;
/**
* handler called if an error occurred
*/
onError?: (error: Error) => void;
/**
* handler called with (multiple ? first file : files, event). It should return promise that resoles future onChange result (For example file src)
*/
onUpload?: (files: File | File[], event: React.SyntheticEvent) => Promise<string>;
/**
* whether you want fileInput to accept multiple files or not
* @default false
*/
multiple?: boolean;
/**
* input name
*/
name?: string;
/**
* acceptable types of files
*/
accepts?: string;
/**
* maximum size of file (MB) for uploading (if actual size of file more then onError fired with Error { message: "Too large file" } )
*/
maxFileSize?: number;
/**
* if children is function then it called with { fileInput, dragContainerProps }, you should render fileInput inside drag container and provide drag container with dragContainerProps. There is "isDragging" prop inside dragContainerProps, so you can use it for styling.
*/
children?: React.ReactNode | ((FileInputChildrenProps) => React.ReactNode);
}
export default class FileInput extends React.Component<FileInputProps> {}