forked from react-native-documents/document-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
64 lines (62 loc) · 2 KB
/
index.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
61
62
63
64
declare module 'react-native-document-picker' {
type UTI = 'public.png' | 'public.jpeg' | 'com.adobe.pdf';
type MimeType = 'image/jpg' | 'image/jpeg' | 'image/png' | 'application/pdf';
type Extension = '.jpeg' | '.jpg' | '.png' | '.txt' | '.pdf';
type DocumentType = {
android: MimeType | MimeType[]
ios: UTI | UTI[]
windows: Extension | Extension[]
};
type Types = {
mimeTypes: {
allFiles: '*/*',
audio: 'audio/*',
images: 'image/*',
plainText: 'text/plain',
pdf: 'application/pdf',
video: 'video/*',
},
utis: {
allFiles: 'public.content',
audio: 'public.audio',
images: 'public.image',
plainText: 'public.plain-text',
pdf: 'com.adobe.pdf',
video: 'public.movie',
},
extensions: {
allFiles: '*',
audio:
'.3g2 .3gp .aac .adt .adts .aif .aifc .aiff .asf .au .m3u .m4a .m4b .mid .midi .mp2 .mp3 .mp4 .rmi .snd .wav .wax .wma',
images: '.jpeg .jpg .png',
plainText: '.txt',
pdf: '.pdf',
video: '.mp4',
},
};
type PlatformTypes = {
android: Types['mimeTypes']
ios: Types['utis']
windows: Types['extensions']
};
interface DocumentPickerOptions<OS extends keyof PlatformTypes> {
type: Array<PlatformTypes[OS][keyof PlatformTypes[OS]]> | DocumentType[OS]
}
interface DocumentPickerResponse {
uri: string;
type: string;
name: string;
size: string;
}
type Platform = 'ios' | 'android' | 'windows'
export default class DocumentPicker<OS extends keyof PlatformTypes = Platform> {
static types: PlatformTypes['ios'] | PlatformTypes['android'] | PlatformTypes['windows']
static pick<OS extends keyof PlatformTypes = Platform>(
options: DocumentPickerOptions<OS>
): Promise<DocumentPickerResponse>;
static pickMultiple<OS extends keyof PlatformTypes = Platform>(
options: DocumentPickerOptions<OS>
): Promise<DocumentPickerResponse[]>;
static isCancel<IError extends {code?: string}>(err?: IError): boolean;
}
}