@vaadin/upload 24.2.0-dev.f254716fe → 24.3.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -10
- package/src/vaadin-upload-file-list-mixin.js +74 -0
- package/src/vaadin-upload-file-list.js +9 -68
- package/src/vaadin-upload-file-mixin.d.ts +71 -0
- package/src/vaadin-upload-file-mixin.js +181 -0
- package/src/vaadin-upload-file-styles.d.ts +8 -0
- package/src/vaadin-upload-file-styles.js +32 -0
- package/src/vaadin-upload-file.d.ts +92 -0
- package/src/vaadin-upload-file.js +10 -199
- package/src/vaadin-upload-icon.js +3 -1
- package/src/vaadin-upload-mixin.d.ts +254 -0
- package/src/vaadin-upload-mixin.js +932 -0
- package/src/vaadin-upload.d.ts +3 -244
- package/src/vaadin-upload.js +6 -922
- package/web-types.json +546 -0
- package/web-types.lit.json +307 -0
package/src/vaadin-upload.d.ts
CHANGED
|
@@ -6,65 +6,9 @@
|
|
|
6
6
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import { type UploadFile, UploadMixin } from './vaadin-upload-mixin.js';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
uploadTarget: string;
|
|
12
|
-
elapsed: number;
|
|
13
|
-
elapsedStr: string;
|
|
14
|
-
remaining: number;
|
|
15
|
-
remainingStr: string;
|
|
16
|
-
progress: number;
|
|
17
|
-
speed: number;
|
|
18
|
-
totalStr: string;
|
|
19
|
-
loaded: number;
|
|
20
|
-
loadedStr: string;
|
|
21
|
-
status: string;
|
|
22
|
-
error: string;
|
|
23
|
-
abort?: boolean;
|
|
24
|
-
complete?: boolean;
|
|
25
|
-
uploading?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface UploadI18n {
|
|
29
|
-
dropFiles: {
|
|
30
|
-
one: string;
|
|
31
|
-
many: string;
|
|
32
|
-
};
|
|
33
|
-
addFiles: {
|
|
34
|
-
one: string;
|
|
35
|
-
many: string;
|
|
36
|
-
};
|
|
37
|
-
error: {
|
|
38
|
-
tooManyFiles: string;
|
|
39
|
-
fileIsTooBig: string;
|
|
40
|
-
incorrectFileType: string;
|
|
41
|
-
};
|
|
42
|
-
uploading: {
|
|
43
|
-
status: {
|
|
44
|
-
connecting: string;
|
|
45
|
-
stalled: string;
|
|
46
|
-
processing: string;
|
|
47
|
-
held: string;
|
|
48
|
-
};
|
|
49
|
-
remainingTime: {
|
|
50
|
-
prefix: string;
|
|
51
|
-
unknown: string;
|
|
52
|
-
};
|
|
53
|
-
error: {
|
|
54
|
-
serverUnavailable: string;
|
|
55
|
-
unexpectedServerError: string;
|
|
56
|
-
forbidden: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
units: {
|
|
60
|
-
size: string[];
|
|
61
|
-
sizeBase?: number;
|
|
62
|
-
};
|
|
63
|
-
formatSize?(bytes: number): string;
|
|
64
|
-
formatTime?(seconds: number, units: number[]): string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type UploadMethod = 'POST' | 'PUT';
|
|
11
|
+
export { UploadFile, UploadI18n, UploadMethod } from './vaadin-upload-mixin.js';
|
|
68
12
|
|
|
69
13
|
/**
|
|
70
14
|
* Fired when a file cannot be added to the queue due to a constrain:
|
|
@@ -210,192 +154,7 @@ export interface UploadEventMap extends HTMLElementEventMap, UploadCustomEventMa
|
|
|
210
154
|
* @fires {CustomEvent} upload-retry - Fired when retry upload is requested.
|
|
211
155
|
* @fires {CustomEvent} upload-abort - Fired when upload abort is requested.
|
|
212
156
|
*/
|
|
213
|
-
declare class Upload extends ThemableMixin(ElementMixin(ControllerMixin(HTMLElement))) {
|
|
214
|
-
/**
|
|
215
|
-
* Define whether the element supports dropping files on it for uploading.
|
|
216
|
-
* By default it's enabled in desktop and disabled in touch devices
|
|
217
|
-
* because mobile devices do not support drag events in general. Setting
|
|
218
|
-
* it false means that drop is enabled even in touch-devices, and true
|
|
219
|
-
* disables drop in all devices.
|
|
220
|
-
*/
|
|
221
|
-
nodrop: boolean;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* The server URL. The default value is an empty string, which means that
|
|
225
|
-
* _window.location_ will be used.
|
|
226
|
-
*/
|
|
227
|
-
target: string;
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* HTTP Method used to send the files. Only POST and PUT are allowed.
|
|
231
|
-
*/
|
|
232
|
-
method: UploadMethod;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Key-Value map to send to the server. If you set this property as an
|
|
236
|
-
* attribute, use a valid JSON string, for example:
|
|
237
|
-
* ```
|
|
238
|
-
* <vaadin-upload headers='{"X-Foo": "Bar"}'></vaadin-upload>
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
headers: object | string | null;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Max time in milliseconds for the entire upload process, if exceeded the
|
|
245
|
-
* request will be aborted. Zero means that there is no timeout.
|
|
246
|
-
*/
|
|
247
|
-
timeout: number;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* The array of files being processed, or already uploaded.
|
|
251
|
-
*
|
|
252
|
-
* Each element is a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File)
|
|
253
|
-
* object with a number of extra properties to track the upload process:
|
|
254
|
-
* - `uploadTarget`: The target URL used to upload this file.
|
|
255
|
-
* - `elapsed`: Elapsed time since the upload started.
|
|
256
|
-
* - `elapsedStr`: Human-readable elapsed time.
|
|
257
|
-
* - `remaining`: Number of seconds remaining for the upload to finish.
|
|
258
|
-
* - `remainingStr`: Human-readable remaining time for the upload to finish.
|
|
259
|
-
* - `progress`: Percentage of the file already uploaded.
|
|
260
|
-
* - `speed`: Upload speed in kB/s.
|
|
261
|
-
* - `size`: File size in bytes.
|
|
262
|
-
* - `totalStr`: Human-readable total size of the file.
|
|
263
|
-
* - `loaded`: Bytes transferred so far.
|
|
264
|
-
* - `loadedStr`: Human-readable uploaded size at the moment.
|
|
265
|
-
* - `status`: Status of the upload process.
|
|
266
|
-
* - `error`: Error message in case the upload failed.
|
|
267
|
-
* - `abort`: True if the file was canceled by the user.
|
|
268
|
-
* - `complete`: True when the file was transferred to the server.
|
|
269
|
-
* - `uploading`: True while transferring data to the server.
|
|
270
|
-
*/
|
|
271
|
-
files: UploadFile[];
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Limit of files to upload, by default it is unlimited. If the value is
|
|
275
|
-
* set to one, native file browser will prevent selecting multiple files.
|
|
276
|
-
* @attr {number} max-files
|
|
277
|
-
*/
|
|
278
|
-
maxFiles: number;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Specifies if the maximum number of files have been uploaded
|
|
282
|
-
* @attr {boolean} max-files-reached
|
|
283
|
-
*/
|
|
284
|
-
readonly maxFilesReached: boolean;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Specifies the types of files that the server accepts.
|
|
288
|
-
* Syntax: a comma-separated list of MIME type patterns (wildcards are
|
|
289
|
-
* allowed) or file extensions.
|
|
290
|
-
* Notice that MIME types are widely supported, while file extensions
|
|
291
|
-
* are only implemented in certain browsers, so avoid using it.
|
|
292
|
-
* Example: accept="video/*,image/tiff" or accept=".pdf,audio/mp3"
|
|
293
|
-
*/
|
|
294
|
-
accept: string;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Specifies the maximum file size in bytes allowed to upload.
|
|
298
|
-
* Notice that it is a client-side constraint, which will be checked before
|
|
299
|
-
* sending the request. Obviously you need to do the same validation in
|
|
300
|
-
* the server-side and be sure that they are aligned.
|
|
301
|
-
* @attr {number} max-file-size
|
|
302
|
-
*/
|
|
303
|
-
maxFileSize: number;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Specifies the 'name' property at Content-Disposition
|
|
307
|
-
* @attr {string} form-data-name
|
|
308
|
-
*/
|
|
309
|
-
formDataName: string;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Prevents upload(s) from immediately uploading upon adding file(s).
|
|
313
|
-
* When set, you must manually trigger uploads using the `uploadFiles` method
|
|
314
|
-
* @attr {boolean} no-auto
|
|
315
|
-
*/
|
|
316
|
-
noAuto: boolean;
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Set the withCredentials flag on the request.
|
|
320
|
-
* @attr {boolean} with-credentials
|
|
321
|
-
*/
|
|
322
|
-
withCredentials: boolean;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Pass-through to input's capture attribute. Allows user to trigger device inputs
|
|
326
|
-
* such as camera or microphone immediately.
|
|
327
|
-
*/
|
|
328
|
-
capture: string | null | undefined;
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* The object used to localize this component.
|
|
332
|
-
* For changing the default localization, change the entire
|
|
333
|
-
* _i18n_ object or just the property you want to modify.
|
|
334
|
-
*
|
|
335
|
-
* The object has the following JSON structure and default values:
|
|
336
|
-
*
|
|
337
|
-
* ```
|
|
338
|
-
* {
|
|
339
|
-
* dropFiles: {
|
|
340
|
-
* one: 'Drop file here',
|
|
341
|
-
* many: 'Drop files here'
|
|
342
|
-
* },
|
|
343
|
-
* addFiles: {
|
|
344
|
-
* one: 'Select File...',
|
|
345
|
-
* many: 'Upload Files...'
|
|
346
|
-
* },
|
|
347
|
-
* error: {
|
|
348
|
-
* tooManyFiles: 'Too Many Files.',
|
|
349
|
-
* fileIsTooBig: 'File is Too Big.',
|
|
350
|
-
* incorrectFileType: 'Incorrect File Type.'
|
|
351
|
-
* },
|
|
352
|
-
* uploading: {
|
|
353
|
-
* status: {
|
|
354
|
-
* connecting: 'Connecting...',
|
|
355
|
-
* stalled: 'Stalled',
|
|
356
|
-
* processing: 'Processing File...',
|
|
357
|
-
* held: 'Queued'
|
|
358
|
-
* },
|
|
359
|
-
* remainingTime: {
|
|
360
|
-
* prefix: 'remaining time: ',
|
|
361
|
-
* unknown: 'unknown remaining time'
|
|
362
|
-
* },
|
|
363
|
-
* error: {
|
|
364
|
-
* serverUnavailable: 'Server Unavailable',
|
|
365
|
-
* unexpectedServerError: 'Unexpected Server Error',
|
|
366
|
-
* forbidden: 'Forbidden'
|
|
367
|
-
* }
|
|
368
|
-
* },
|
|
369
|
-
* file: {
|
|
370
|
-
* retry: 'Retry',
|
|
371
|
-
* start: 'Start',
|
|
372
|
-
* remove: 'Remove'
|
|
373
|
-
* },
|
|
374
|
-
* units: {
|
|
375
|
-
* size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
376
|
-
* sizeBase: 1000
|
|
377
|
-
* },
|
|
378
|
-
* formatSize: function(bytes) {
|
|
379
|
-
* // returns the size followed by the best suitable unit
|
|
380
|
-
* },
|
|
381
|
-
* formatTime: function(seconds, [secs, mins, hours]) {
|
|
382
|
-
* // returns a 'HH:MM:SS' string
|
|
383
|
-
* }
|
|
384
|
-
* }
|
|
385
|
-
* ```
|
|
386
|
-
*
|
|
387
|
-
* @type {!UploadI18n}
|
|
388
|
-
* @default {English}
|
|
389
|
-
*/
|
|
390
|
-
i18n: UploadI18n;
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Triggers the upload of any files that are not completed
|
|
394
|
-
*
|
|
395
|
-
* @param files Files being uploaded. Defaults to all outstanding files
|
|
396
|
-
*/
|
|
397
|
-
uploadFiles(files?: UploadFile | UploadFile[]): void;
|
|
398
|
-
|
|
157
|
+
declare class Upload extends UploadMixin(ThemableMixin(ElementMixin(ControllerMixin(HTMLElement)))) {
|
|
399
158
|
addEventListener<K extends keyof UploadEventMap>(
|
|
400
159
|
type: K,
|
|
401
160
|
listener: (this: Upload, ev: UploadEventMap[K]) => void,
|