@@ -6,12 +6,24 @@ import { ResumableConfiguration } from './types/types';
6
6
*/
7
7
export declare class Resumable extends ResumableEventHandler {
8
8
private opts ;
9
+ /**
10
+ * An object that contains one entry for every file category. The key is the category name, the value is an array of
11
+ * all ResumableFiles of that category that were added to this instance.
12
+ */
9
13
private files ;
14
+ /**
15
+ * Contains all file categories for which the upload was not yet completed.
16
+ */
17
+ private uncompletedFileCategories ;
10
18
private validators ;
11
19
private support ;
12
20
clearInput : boolean ;
13
21
dragOverClass : string ;
14
- fileTypes : string [ ] ;
22
+ fileCategories : string [ ] ;
23
+ defaultFileCategory : string | null ;
24
+ fileTypes : string [ ] | {
25
+ [ fileCategory : string ] : string [ ] ;
26
+ } ;
15
27
fileTypeErrorCallback : Function ;
16
28
_generateUniqueIdentifier : Function ;
17
29
maxFileSize ?: number ;
@@ -38,6 +50,7 @@ export declare class Resumable extends ResumableEventHandler {
38
50
*/
39
51
protected setInstanceProperties ( options : ResumableConfiguration ) : void ;
40
52
private sanitizeFileTypes ;
53
+ private throwIfUnknownFileCategory ;
41
54
/**
42
55
* Transforms a single fileEntry or directoryEntry item into a list of File objects this method is used to convert
43
56
* entries found inside dragged-and-dropped directories.
@@ -61,7 +74,6 @@ export declare class Resumable extends ResumableEventHandler {
61
74
* class to the element when a file is dropped onto it. In this case, we have to remove that class again before
62
75
* calling "onDrop()".
63
76
* If "onDrop()" is called from "handleDropEvent()" this is not needed.
64
- *
65
77
*/
66
78
private removeDragOverClassAndCallOnDrop ;
67
79
/**
@@ -80,47 +92,70 @@ export declare class Resumable extends ResumableEventHandler {
80
92
* Validate and clean a list of files. This includes the removal of duplicates, a check whether the file type is
81
93
* allowed and custom validation functions defined per file type.
82
94
* @param {ExtendedFile[] } files A list of File instances that were previously extended with a uniqueIdentifier
95
+ * @param fileCategory The file category that has been provided for the files. Defaults to `defaultFileCategory`.
83
96
*/
84
97
private validateFiles ;
85
98
/**
86
- * Add an array of files to this instance's file list by creating new ResumableFiles. This includes a validation and
87
- * deduplication of the provided array.
99
+ * Add an array of files to this instance's file list (of the file category, if given) by creating new ResumableFiles.
100
+ * This includes a validation and deduplication of the provided array.
88
101
* @param fileList An array containing File objects
89
102
* @param event The event with which the fileList was provided
103
+ * @param fileCategory The file category that has been provided for the file. Defaults to `defaultFileCategory`.
90
104
*/
91
105
private appendFilesFromFileList ;
92
106
/**
93
107
* Generate a new unique identifier for a given file either with a default helper function or with a custom
94
108
* generator function.
95
109
* @param file The file as an HTML 5 File object
96
110
* @param event The event with which the file was provided originally
111
+ * @param fileCategory The file category that has been provided for the file. Defaults to `defaultFileCategory`.
97
112
*/
98
113
private generateUniqueIdentifier ;
99
114
/**
100
115
* Queue a new chunk to be uploaded that is currently awaiting upload.
101
116
*/
102
117
private uploadNextChunk ;
118
+ /**
119
+ * Returns all ResumableFiles of all file categories.
120
+ * The files are ordered by the order of the file categories in `this.fileCategories`. Files of the first category
121
+ * are added first, files of the second category are added second etc.
122
+ *
123
+ * @returns {ResumableFile[] } Array of all ResumableFiles that are stored for any category.
124
+ */
125
+ private getFilesOfAllCategories ;
103
126
/**
104
127
* PUBLIC METHODS FOR RESUMABLE.JS
105
128
* This section only includes methods that should be callable from external packages.
106
129
*/
107
130
/**
108
131
* Assign a browse action to one or more DOM nodes. Pass in true to allow directories to be selected (Chrome only).
132
+ *
133
+ * @param domNodes The dom nodes to which the browse action should be assigned (can be an array or a single dom node).
134
+ * @param isDirectory If true, directories can be added via the file picker (Chrome only).
135
+ * @param fileCategory The file category that will be assigned to all added files. Defaults to `defaultFileCategory`.
109
136
*/
110
- assignBrowse ( domNodes : HTMLElement | HTMLElement [ ] , isDirectory ?: boolean ) : void ;
137
+ assignBrowse ( domNodes : HTMLElement | HTMLElement [ ] , isDirectory ?: boolean , fileCategory ?: string ) : void ;
111
138
/**
112
139
* Assign one or more DOM nodes as a drop target.
140
+ *
141
+ * @param domNodes The dom nodes to which the drop action should be assigned (can be an array or a single dom node).
142
+ * @param fileCategory The file category that will be assigned to all added files. Defaults to `defaultFileCategory`.
113
143
*/
114
- assignDrop ( domNodes : HTMLElement | HTMLElement [ ] ) : void ;
144
+ assignDrop ( domNodes : HTMLElement | HTMLElement [ ] , fileCategory ?: string ) : void ;
115
145
/**
116
146
* Remove one or more DOM nodes as a drop target.
117
147
*/
118
148
unAssignDrop ( domNodes : HTMLElement | HTMLElement [ ] ) : void ;
119
149
/**
120
- * Set the file types allowed to upload. Optionally pass a dom node on which the accepted file types should be
121
- * updated as well.
150
+ * Set the file types allowed to upload.
151
+ * Per default the file types are updated for the default file category.
152
+ * Optionally pass a dom node on which the accepted file types should be updated as well.
153
+ *
154
+ * @param fileTypes String array of all allowed file types
155
+ * @param domNode An optional HTMLInputElement for which the "accepted" attribute should be updated accordingly.
156
+ * @param fileCategory The file category for which the file types should be updated. Defaults to `defaultFileCategory`.
122
157
*/
123
- setFileTypes ( fileTypes : string [ ] , domNode ?: HTMLInputElement ) : void ;
158
+ setFileTypes ( fileTypes : string [ ] , domNode ?: HTMLInputElement , fileCategory ?: string ) : void ;
124
159
/**
125
160
* Check whether any files are currently uploading
126
161
*/
@@ -144,11 +179,11 @@ export declare class Resumable extends ResumableEventHandler {
144
179
/**
145
180
* Add a HTML5 File object to the list of files.
146
181
*/
147
- addFile ( file : File , event : Event ) : void ;
182
+ addFile ( file : File , event : Event , fileCategory ?: string ) : void ;
148
183
/**
149
184
* Add a list of HTML5 File objects to the list of files.
150
185
*/
151
- addFiles ( files : File [ ] , event : Event ) : void ;
186
+ addFiles ( files : File [ ] , event : Event , fileCategory ?: string ) : void ;
152
187
/**
153
188
* Add a validator function for the given file type. This can e.g. be used to read the file and validate
154
189
* checksums based on certain properties.
@@ -157,7 +192,7 @@ export declare class Resumable extends ResumableEventHandler {
157
192
*/
158
193
addFileValidator ( fileType : string , validator : Function ) : void ;
159
194
/**
160
- * Cancel the upload of a specific ResumableFile object and remove it from the file list .
195
+ * Remove the given resumable file from the file list (of its corresponding file category) .
161
196
*/
162
197
removeFile ( file : ResumableFile ) : void ;
163
198
/**
@@ -171,13 +206,14 @@ export declare class Resumable extends ResumableEventHandler {
171
206
/**
172
207
* Call the event handler for a DragEvent (when a file is dropped on a drop area).
173
208
*/
174
- handleDropEvent ( e : DragEvent ) : void ;
209
+ handleDropEvent ( e : DragEvent , fileCategory ?: string ) : void ;
175
210
/**
176
211
* Call the event handler for an InputEvent (i.e. received one or multiple files).
177
212
*/
178
- handleChangeEvent ( e : InputEvent ) : void ;
213
+ handleChangeEvent ( e : InputEvent , fileCategory ?: string ) : void ;
179
214
/**
180
- * Check whether the upload is completed, i.e. if all files were uploaded successfully.
215
+ * Check whether the upload is completed (if all files of a category are uploaded and if all files in general are
216
+ * uploaded).
181
217
*/
182
218
checkUploadComplete ( ) : void ;
183
219
/**
0 commit comments