forked from react-native-documents/document-picker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
92 lines (90 loc) · 3.13 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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/*';
csv: 'text/csv';
doc: 'application/msword';
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
images: 'image/*';
pdf: 'application/pdf';
plainText: 'text/plain';
ppt: 'application/vnd.ms-powerpoint';
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
video: 'video/*';
xls: 'application/vnd.ms-excel';
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
zip: 'application/zip';
};
utis: {
allFiles: 'public.item';
audio: 'public.audio';
csv: 'public.comma-separated-values-text';
doc: 'com.microsoft.word.doc';
docx: 'org.openxmlformats.wordprocessingml.document';
images: 'public.image';
pdf: 'com.adobe.pdf';
plainText: 'public.plain-text';
ppt: 'com.microsoft.powerpoint.ppt';
pptx: 'org.openxmlformats.presentationml.presentation';
video: 'public.movie';
xls: 'com.microsoft.excel.xls';
xlsx: 'org.openxmlformats.spreadsheetml.sheet';
zip: 'public.zip-archive';
};
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';
csv: '.csv';
doc: '.doc';
docx: '.docx';
images: '.jpeg .jpg .png';
pdf: '.pdf';
plainText: '.txt';
ppt: '.ppt';
pptx: '.pptx';
video: '.mp4';
xls: '.xls';
xlsx: '.xlsx';
zip: '.zip .gz';
};
};
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];
mode?: 'import' | 'open';
copyTo?: 'cachesDirectory' | 'documentDirectory';
}
interface DocumentPickerResponse {
uri: string;
fileCopyUri: string;
copyError?: string;
type: string;
name: string;
size: number;
}
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;
static releaseSecureAccess(uris: Array<string>): void;
}
}