@vaadin/upload 24.8.0-alpha7 → 24.8.0-alpha9
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 +11 -11
- package/src/vaadin-upload-mixin.d.ts +34 -29
- package/src/vaadin-upload-mixin.js +136 -134
- package/web-types.json +10 -10
- package/web-types.lit.json +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/upload",
|
|
3
|
-
"version": "24.8.0-
|
|
3
|
+
"version": "24.8.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/a11y-base": "24.8.0-
|
|
41
|
-
"@vaadin/button": "24.8.0-
|
|
42
|
-
"@vaadin/component-base": "24.8.0-
|
|
43
|
-
"@vaadin/progress-bar": "24.8.0-
|
|
44
|
-
"@vaadin/vaadin-lumo-styles": "24.8.0-
|
|
45
|
-
"@vaadin/vaadin-material-styles": "24.8.0-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "24.8.0-
|
|
40
|
+
"@vaadin/a11y-base": "24.8.0-alpha9",
|
|
41
|
+
"@vaadin/button": "24.8.0-alpha9",
|
|
42
|
+
"@vaadin/component-base": "24.8.0-alpha9",
|
|
43
|
+
"@vaadin/progress-bar": "24.8.0-alpha9",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "24.8.0-alpha9",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "24.8.0-alpha9",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha9",
|
|
47
47
|
"lit": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@vaadin/chai-plugins": "24.8.0-
|
|
51
|
-
"@vaadin/test-runner-commands": "24.8.0-
|
|
50
|
+
"@vaadin/chai-plugins": "24.8.0-alpha9",
|
|
51
|
+
"@vaadin/test-runner-commands": "24.8.0-alpha9",
|
|
52
52
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
53
53
|
"sinon": "^18.0.0"
|
|
54
54
|
},
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"web-types.json",
|
|
57
57
|
"web-types.lit.json"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "4de3809275ddfd733b0d13fd02af8faf73eb6770"
|
|
60
60
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
7
8
|
|
|
8
9
|
export interface UploadFile extends File {
|
|
9
10
|
uploadTarget: string;
|
|
@@ -25,47 +26,51 @@ export interface UploadFile extends File {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export interface UploadI18n {
|
|
28
|
-
dropFiles
|
|
29
|
-
one
|
|
30
|
-
many
|
|
29
|
+
dropFiles?: {
|
|
30
|
+
one?: string;
|
|
31
|
+
many?: string;
|
|
31
32
|
};
|
|
32
|
-
addFiles
|
|
33
|
-
one
|
|
34
|
-
many
|
|
33
|
+
addFiles?: {
|
|
34
|
+
one?: string;
|
|
35
|
+
many?: string;
|
|
35
36
|
};
|
|
36
|
-
error
|
|
37
|
-
tooManyFiles
|
|
38
|
-
fileIsTooBig
|
|
39
|
-
incorrectFileType
|
|
37
|
+
error?: {
|
|
38
|
+
tooManyFiles?: string;
|
|
39
|
+
fileIsTooBig?: string;
|
|
40
|
+
incorrectFileType?: string;
|
|
40
41
|
};
|
|
41
|
-
uploading
|
|
42
|
-
status
|
|
43
|
-
connecting
|
|
44
|
-
stalled
|
|
45
|
-
processing
|
|
46
|
-
held
|
|
42
|
+
uploading?: {
|
|
43
|
+
status?: {
|
|
44
|
+
connecting?: string;
|
|
45
|
+
stalled?: string;
|
|
46
|
+
processing?: string;
|
|
47
|
+
held?: string;
|
|
47
48
|
};
|
|
48
|
-
remainingTime
|
|
49
|
-
prefix
|
|
50
|
-
unknown
|
|
49
|
+
remainingTime?: {
|
|
50
|
+
prefix?: string;
|
|
51
|
+
unknown?: string;
|
|
51
52
|
};
|
|
52
|
-
error
|
|
53
|
-
serverUnavailable
|
|
54
|
-
unexpectedServerError
|
|
55
|
-
forbidden
|
|
53
|
+
error?: {
|
|
54
|
+
serverUnavailable?: string;
|
|
55
|
+
unexpectedServerError?: string;
|
|
56
|
+
forbidden?: string;
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
|
-
units
|
|
59
|
-
size
|
|
59
|
+
units?: {
|
|
60
|
+
size?: string[];
|
|
60
61
|
sizeBase?: number;
|
|
61
62
|
};
|
|
63
|
+
|
|
62
64
|
formatSize?(bytes: number): string;
|
|
65
|
+
|
|
63
66
|
formatTime?(seconds: number, units: number[]): string;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
export type UploadMethod = 'POST' | 'PUT';
|
|
67
70
|
|
|
68
|
-
export declare function UploadMixin<T extends Constructor<HTMLElement>>(
|
|
71
|
+
export declare function UploadMixin<T extends Constructor<HTMLElement>>(
|
|
72
|
+
base: T,
|
|
73
|
+
): Constructor<UploadMixinClass> & Constructor<I18nMixinClass<UploadI18n>> & T;
|
|
69
74
|
|
|
70
75
|
export declare class UploadMixinClass {
|
|
71
76
|
/**
|
|
@@ -190,9 +195,9 @@ export declare class UploadMixinClass {
|
|
|
190
195
|
capture: string | null | undefined;
|
|
191
196
|
|
|
192
197
|
/**
|
|
193
|
-
* The object used to localize this component.
|
|
194
|
-
*
|
|
195
|
-
*
|
|
198
|
+
* The object used to localize this component. To change the default
|
|
199
|
+
* localization, replace this with an object that provides all properties, or
|
|
200
|
+
* just the individual properties you want to change.
|
|
196
201
|
*
|
|
197
202
|
* The object has the following JSON structure and default values:
|
|
198
203
|
*
|
|
@@ -5,8 +5,50 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { announce } from '@vaadin/a11y-base/src/announce.js';
|
|
7
7
|
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
8
|
+
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
8
9
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
9
10
|
|
|
11
|
+
const DEFAULT_I18N = {
|
|
12
|
+
dropFiles: {
|
|
13
|
+
one: 'Drop file here',
|
|
14
|
+
many: 'Drop files here',
|
|
15
|
+
},
|
|
16
|
+
addFiles: {
|
|
17
|
+
one: 'Upload File...',
|
|
18
|
+
many: 'Upload Files...',
|
|
19
|
+
},
|
|
20
|
+
error: {
|
|
21
|
+
tooManyFiles: 'Too Many Files.',
|
|
22
|
+
fileIsTooBig: 'File is Too Big.',
|
|
23
|
+
incorrectFileType: 'Incorrect File Type.',
|
|
24
|
+
},
|
|
25
|
+
uploading: {
|
|
26
|
+
status: {
|
|
27
|
+
connecting: 'Connecting...',
|
|
28
|
+
stalled: 'Stalled',
|
|
29
|
+
processing: 'Processing File...',
|
|
30
|
+
held: 'Queued',
|
|
31
|
+
},
|
|
32
|
+
remainingTime: {
|
|
33
|
+
prefix: 'remaining time: ',
|
|
34
|
+
unknown: 'unknown remaining time',
|
|
35
|
+
},
|
|
36
|
+
error: {
|
|
37
|
+
serverUnavailable: 'Upload failed, please try again later',
|
|
38
|
+
unexpectedServerError: 'Upload failed due to server error',
|
|
39
|
+
forbidden: 'Upload forbidden',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
file: {
|
|
43
|
+
retry: 'Retry',
|
|
44
|
+
start: 'Start',
|
|
45
|
+
remove: 'Remove',
|
|
46
|
+
},
|
|
47
|
+
units: {
|
|
48
|
+
size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
10
52
|
class AddButtonController extends SlotController {
|
|
11
53
|
constructor(host) {
|
|
12
54
|
super(host, 'add-button', 'vaadin-button');
|
|
@@ -64,7 +106,7 @@ class DropLabelController extends SlotController {
|
|
|
64
106
|
* @polymerMixin
|
|
65
107
|
*/
|
|
66
108
|
export const UploadMixin = (superClass) =>
|
|
67
|
-
class UploadMixin extends superClass {
|
|
109
|
+
class UploadMixin extends I18nMixin(DEFAULT_I18N, superClass) {
|
|
68
110
|
static get properties() {
|
|
69
111
|
return {
|
|
70
112
|
/**
|
|
@@ -272,112 +314,6 @@ export const UploadMixin = (superClass) =>
|
|
|
272
314
|
*/
|
|
273
315
|
capture: String,
|
|
274
316
|
|
|
275
|
-
/**
|
|
276
|
-
* The object used to localize this component.
|
|
277
|
-
* For changing the default localization, change the entire
|
|
278
|
-
* _i18n_ object or just the property you want to modify.
|
|
279
|
-
*
|
|
280
|
-
* The object has the following JSON structure and default values:
|
|
281
|
-
*
|
|
282
|
-
* ```
|
|
283
|
-
* {
|
|
284
|
-
* dropFiles: {
|
|
285
|
-
* one: 'Drop file here',
|
|
286
|
-
* many: 'Drop files here'
|
|
287
|
-
* },
|
|
288
|
-
* addFiles: {
|
|
289
|
-
* one: 'Upload File...',
|
|
290
|
-
* many: 'Upload Files...'
|
|
291
|
-
* },
|
|
292
|
-
* error: {
|
|
293
|
-
* tooManyFiles: 'Too Many Files.',
|
|
294
|
-
* fileIsTooBig: 'File is Too Big.',
|
|
295
|
-
* incorrectFileType: 'Incorrect File Type.'
|
|
296
|
-
* },
|
|
297
|
-
* uploading: {
|
|
298
|
-
* status: {
|
|
299
|
-
* connecting: 'Connecting...',
|
|
300
|
-
* stalled: 'Stalled',
|
|
301
|
-
* processing: 'Processing File...',
|
|
302
|
-
* held: 'Queued'
|
|
303
|
-
* },
|
|
304
|
-
* remainingTime: {
|
|
305
|
-
* prefix: 'remaining time: ',
|
|
306
|
-
* unknown: 'unknown remaining time'
|
|
307
|
-
* },
|
|
308
|
-
* error: {
|
|
309
|
-
* serverUnavailable: 'Upload failed, please try again later',
|
|
310
|
-
* unexpectedServerError: 'Upload failed due to server error',
|
|
311
|
-
* forbidden: 'Upload forbidden'
|
|
312
|
-
* }
|
|
313
|
-
* },
|
|
314
|
-
* file: {
|
|
315
|
-
* retry: 'Retry',
|
|
316
|
-
* start: 'Start',
|
|
317
|
-
* remove: 'Remove'
|
|
318
|
-
* },
|
|
319
|
-
* units: {
|
|
320
|
-
* size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
321
|
-
* sizeBase: 1000
|
|
322
|
-
* },
|
|
323
|
-
* formatSize: function(bytes) {
|
|
324
|
-
* // returns the size followed by the best suitable unit
|
|
325
|
-
* },
|
|
326
|
-
* formatTime: function(seconds, [secs, mins, hours]) {
|
|
327
|
-
* // returns a 'HH:MM:SS' string
|
|
328
|
-
* }
|
|
329
|
-
* }
|
|
330
|
-
* ```
|
|
331
|
-
*
|
|
332
|
-
* @type {!UploadI18n}
|
|
333
|
-
* @default {English}
|
|
334
|
-
*/
|
|
335
|
-
i18n: {
|
|
336
|
-
type: Object,
|
|
337
|
-
value() {
|
|
338
|
-
return {
|
|
339
|
-
dropFiles: {
|
|
340
|
-
one: 'Drop file here',
|
|
341
|
-
many: 'Drop files here',
|
|
342
|
-
},
|
|
343
|
-
addFiles: {
|
|
344
|
-
one: 'Upload 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: 'Upload failed, please try again later',
|
|
365
|
-
unexpectedServerError: 'Upload failed due to server error',
|
|
366
|
-
forbidden: 'Upload 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
|
-
},
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
|
|
381
317
|
/** @private */
|
|
382
318
|
_addButton: {
|
|
383
319
|
type: Object,
|
|
@@ -402,13 +338,79 @@ export const UploadMixin = (superClass) =>
|
|
|
402
338
|
|
|
403
339
|
static get observers() {
|
|
404
340
|
return [
|
|
405
|
-
'__updateAddButton(_addButton, maxFiles,
|
|
406
|
-
'__updateDropLabel(_dropLabel, maxFiles,
|
|
407
|
-
'__updateFileList(_fileList, files,
|
|
341
|
+
'__updateAddButton(_addButton, maxFiles, __effectiveI18n, maxFilesReached, disabled)',
|
|
342
|
+
'__updateDropLabel(_dropLabel, maxFiles, __effectiveI18n)',
|
|
343
|
+
'__updateFileList(_fileList, files, __effectiveI18n, disabled)',
|
|
408
344
|
'__updateMaxFilesReached(maxFiles, files)',
|
|
409
345
|
];
|
|
410
346
|
}
|
|
411
347
|
|
|
348
|
+
/**
|
|
349
|
+
* The object used to localize this component. To change the default
|
|
350
|
+
* localization, replace this with an object that provides all properties, or
|
|
351
|
+
* just the individual properties you want to change.
|
|
352
|
+
*
|
|
353
|
+
* The object has the following JSON structure and default values:
|
|
354
|
+
*
|
|
355
|
+
* ```
|
|
356
|
+
* {
|
|
357
|
+
* dropFiles: {
|
|
358
|
+
* one: 'Drop file here',
|
|
359
|
+
* many: 'Drop files here'
|
|
360
|
+
* },
|
|
361
|
+
* addFiles: {
|
|
362
|
+
* one: 'Upload File...',
|
|
363
|
+
* many: 'Upload Files...'
|
|
364
|
+
* },
|
|
365
|
+
* error: {
|
|
366
|
+
* tooManyFiles: 'Too Many Files.',
|
|
367
|
+
* fileIsTooBig: 'File is Too Big.',
|
|
368
|
+
* incorrectFileType: 'Incorrect File Type.'
|
|
369
|
+
* },
|
|
370
|
+
* uploading: {
|
|
371
|
+
* status: {
|
|
372
|
+
* connecting: 'Connecting...',
|
|
373
|
+
* stalled: 'Stalled',
|
|
374
|
+
* processing: 'Processing File...',
|
|
375
|
+
* held: 'Queued'
|
|
376
|
+
* },
|
|
377
|
+
* remainingTime: {
|
|
378
|
+
* prefix: 'remaining time: ',
|
|
379
|
+
* unknown: 'unknown remaining time'
|
|
380
|
+
* },
|
|
381
|
+
* error: {
|
|
382
|
+
* serverUnavailable: 'Upload failed, please try again later',
|
|
383
|
+
* unexpectedServerError: 'Upload failed due to server error',
|
|
384
|
+
* forbidden: 'Upload forbidden'
|
|
385
|
+
* }
|
|
386
|
+
* },
|
|
387
|
+
* file: {
|
|
388
|
+
* retry: 'Retry',
|
|
389
|
+
* start: 'Start',
|
|
390
|
+
* remove: 'Remove'
|
|
391
|
+
* },
|
|
392
|
+
* units: {
|
|
393
|
+
* size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
394
|
+
* sizeBase: 1000
|
|
395
|
+
* },
|
|
396
|
+
* formatSize: function(bytes) {
|
|
397
|
+
* // returns the size followed by the best suitable unit
|
|
398
|
+
* },
|
|
399
|
+
* formatTime: function(seconds, [secs, mins, hours]) {
|
|
400
|
+
* // returns a 'HH:MM:SS' string
|
|
401
|
+
* }
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
* @return {!UploadI18n}
|
|
405
|
+
*/
|
|
406
|
+
get i18n() {
|
|
407
|
+
return super.i18n;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
set i18n(value) {
|
|
411
|
+
super.i18n = value;
|
|
412
|
+
}
|
|
413
|
+
|
|
412
414
|
/** @private */
|
|
413
415
|
get __acceptRegexp() {
|
|
414
416
|
if (!this.accept) {
|
|
@@ -462,16 +464,16 @@ export const UploadMixin = (superClass) =>
|
|
|
462
464
|
|
|
463
465
|
/** @private */
|
|
464
466
|
_formatSize(bytes) {
|
|
465
|
-
if (typeof this.
|
|
466
|
-
return this.
|
|
467
|
+
if (typeof this.__effectiveI18n.formatSize === 'function') {
|
|
468
|
+
return this.__effectiveI18n.formatSize(bytes);
|
|
467
469
|
}
|
|
468
470
|
|
|
469
471
|
// https://wiki.ubuntu.com/UnitsPolicy
|
|
470
|
-
const base = this.
|
|
472
|
+
const base = this.__effectiveI18n.units.sizeBase || 1000;
|
|
471
473
|
const unit = ~~(Math.log(bytes) / Math.log(base));
|
|
472
474
|
const dec = Math.max(0, Math.min(3, unit - 1));
|
|
473
475
|
const size = parseFloat((bytes / base ** unit).toFixed(dec));
|
|
474
|
-
return `${size} ${this.
|
|
476
|
+
return `${size} ${this.__effectiveI18n.units.size[unit]}`;
|
|
475
477
|
}
|
|
476
478
|
|
|
477
479
|
/** @private */
|
|
@@ -489,8 +491,8 @@ export const UploadMixin = (superClass) =>
|
|
|
489
491
|
|
|
490
492
|
/** @private */
|
|
491
493
|
_formatTime(seconds, split) {
|
|
492
|
-
if (typeof this.
|
|
493
|
-
return this.
|
|
494
|
+
if (typeof this.__effectiveI18n.formatTime === 'function') {
|
|
495
|
+
return this.__effectiveI18n.formatTime(seconds, split);
|
|
494
496
|
}
|
|
495
497
|
|
|
496
498
|
// Fill HH:MM:SS with leading zeros
|
|
@@ -510,8 +512,8 @@ export const UploadMixin = (superClass) =>
|
|
|
510
512
|
_formatFileProgress(file) {
|
|
511
513
|
const remainingTime =
|
|
512
514
|
file.loaded > 0
|
|
513
|
-
? this.
|
|
514
|
-
: this.
|
|
515
|
+
? this.__effectiveI18n.uploading.remainingTime.prefix + file.remainingStr
|
|
516
|
+
: this.__effectiveI18n.uploading.remainingTime.unknown;
|
|
515
517
|
|
|
516
518
|
return `${file.totalStr}: ${file.progress}% (${remainingTime})`;
|
|
517
519
|
}
|
|
@@ -522,30 +524,30 @@ export const UploadMixin = (superClass) =>
|
|
|
522
524
|
}
|
|
523
525
|
|
|
524
526
|
/** @private */
|
|
525
|
-
__updateAddButton(addButton, maxFiles,
|
|
527
|
+
__updateAddButton(addButton, maxFiles, effectiveI18n, maxFilesReached, disabled) {
|
|
526
528
|
if (addButton) {
|
|
527
529
|
addButton.disabled = disabled || maxFilesReached;
|
|
528
530
|
|
|
529
531
|
// Only update text content for the default button element
|
|
530
532
|
if (addButton === this._addButtonController.defaultNode) {
|
|
531
|
-
addButton.textContent = this._i18nPlural(maxFiles,
|
|
533
|
+
addButton.textContent = this._i18nPlural(maxFiles, effectiveI18n.addFiles);
|
|
532
534
|
}
|
|
533
535
|
}
|
|
534
536
|
}
|
|
535
537
|
|
|
536
538
|
/** @private */
|
|
537
|
-
__updateDropLabel(dropLabel, maxFiles,
|
|
539
|
+
__updateDropLabel(dropLabel, maxFiles, effectiveI18n) {
|
|
538
540
|
// Only update text content for the default label element
|
|
539
541
|
if (dropLabel && dropLabel === this._dropLabelController.defaultNode) {
|
|
540
|
-
dropLabel.textContent = this._i18nPlural(maxFiles,
|
|
542
|
+
dropLabel.textContent = this._i18nPlural(maxFiles, effectiveI18n.dropFiles);
|
|
541
543
|
}
|
|
542
544
|
}
|
|
543
545
|
|
|
544
546
|
/** @private */
|
|
545
|
-
__updateFileList(list, files,
|
|
547
|
+
__updateFileList(list, files, effectiveI18n, disabled) {
|
|
546
548
|
if (list) {
|
|
547
549
|
list.items = [...files];
|
|
548
|
-
list.i18n =
|
|
550
|
+
list.i18n = effectiveI18n;
|
|
549
551
|
list.disabled = disabled;
|
|
550
552
|
}
|
|
551
553
|
}
|
|
@@ -691,12 +693,12 @@ export const UploadMixin = (superClass) =>
|
|
|
691
693
|
if (progress < 100) {
|
|
692
694
|
this._setStatus(file, total, loaded, elapsed);
|
|
693
695
|
stalledId = setTimeout(() => {
|
|
694
|
-
file.status = this.
|
|
696
|
+
file.status = this.__effectiveI18n.uploading.status.stalled;
|
|
695
697
|
this._renderFileList();
|
|
696
698
|
}, 2000);
|
|
697
699
|
} else {
|
|
698
700
|
file.loadedStr = file.totalStr;
|
|
699
|
-
file.status = this.
|
|
701
|
+
file.status = this.__effectiveI18n.uploading.status.processing;
|
|
700
702
|
}
|
|
701
703
|
}
|
|
702
704
|
|
|
@@ -726,11 +728,11 @@ export const UploadMixin = (superClass) =>
|
|
|
726
728
|
return;
|
|
727
729
|
}
|
|
728
730
|
if (xhr.status === 0) {
|
|
729
|
-
file.error = this.
|
|
731
|
+
file.error = this.__effectiveI18n.uploading.error.serverUnavailable;
|
|
730
732
|
} else if (xhr.status >= 500) {
|
|
731
|
-
file.error = this.
|
|
733
|
+
file.error = this.__effectiveI18n.uploading.error.unexpectedServerError;
|
|
732
734
|
} else if (xhr.status >= 400) {
|
|
733
|
-
file.error = this.
|
|
735
|
+
file.error = this.__effectiveI18n.uploading.error.forbidden;
|
|
734
736
|
}
|
|
735
737
|
|
|
736
738
|
file.complete = !file.error;
|
|
@@ -765,7 +767,7 @@ export const UploadMixin = (superClass) =>
|
|
|
765
767
|
xhr.open(this.method, file.uploadTarget, true);
|
|
766
768
|
this._configureXhr(xhr);
|
|
767
769
|
|
|
768
|
-
file.status = this.
|
|
770
|
+
file.status = this.__effectiveI18n.uploading.status.connecting;
|
|
769
771
|
file.uploading = file.indeterminate = true;
|
|
770
772
|
file.complete = file.abort = file.error = file.held = false;
|
|
771
773
|
|
|
@@ -844,7 +846,7 @@ export const UploadMixin = (superClass) =>
|
|
|
844
846
|
if (this.maxFilesReached) {
|
|
845
847
|
this.dispatchEvent(
|
|
846
848
|
new CustomEvent('file-reject', {
|
|
847
|
-
detail: { file, error: this.
|
|
849
|
+
detail: { file, error: this.__effectiveI18n.error.tooManyFiles },
|
|
848
850
|
}),
|
|
849
851
|
);
|
|
850
852
|
return;
|
|
@@ -852,7 +854,7 @@ export const UploadMixin = (superClass) =>
|
|
|
852
854
|
if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
|
|
853
855
|
this.dispatchEvent(
|
|
854
856
|
new CustomEvent('file-reject', {
|
|
855
|
-
detail: { file, error: this.
|
|
857
|
+
detail: { file, error: this.__effectiveI18n.error.fileIsTooBig },
|
|
856
858
|
}),
|
|
857
859
|
);
|
|
858
860
|
return;
|
|
@@ -861,14 +863,14 @@ export const UploadMixin = (superClass) =>
|
|
|
861
863
|
if (re && !(re.test(file.type) || re.test(file.name))) {
|
|
862
864
|
this.dispatchEvent(
|
|
863
865
|
new CustomEvent('file-reject', {
|
|
864
|
-
detail: { file, error: this.
|
|
866
|
+
detail: { file, error: this.__effectiveI18n.error.incorrectFileType },
|
|
865
867
|
}),
|
|
866
868
|
);
|
|
867
869
|
return;
|
|
868
870
|
}
|
|
869
871
|
file.loaded = 0;
|
|
870
872
|
file.held = true;
|
|
871
|
-
file.status = this.
|
|
873
|
+
file.status = this.__effectiveI18n.uploading.status.held;
|
|
872
874
|
this.files = [file, ...this.files];
|
|
873
875
|
|
|
874
876
|
if (!this.noAuto) {
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/upload",
|
|
4
|
-
"version": "24.8.0-
|
|
4
|
+
"version": "24.8.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -389,6 +389,15 @@
|
|
|
389
389
|
],
|
|
390
390
|
"js": {
|
|
391
391
|
"properties": [
|
|
392
|
+
{
|
|
393
|
+
"name": "i18n",
|
|
394
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n dropFiles: {\n one: 'Drop file here',\n many: 'Drop files here'\n },\n addFiles: {\n one: 'Upload File...',\n many: 'Upload Files...'\n },\n error: {\n tooManyFiles: 'Too Many Files.',\n fileIsTooBig: 'File is Too Big.',\n incorrectFileType: 'Incorrect File Type.'\n },\n uploading: {\n status: {\n connecting: 'Connecting...',\n stalled: 'Stalled',\n processing: 'Processing File...',\n held: 'Queued'\n },\n remainingTime: {\n prefix: 'remaining time: ',\n unknown: 'unknown remaining time'\n },\n error: {\n serverUnavailable: 'Upload failed, please try again later',\n unexpectedServerError: 'Upload failed due to server error',\n forbidden: 'Upload forbidden'\n }\n },\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n sizeBase: 1000\n },\n formatSize: function(bytes) {\n // returns the size followed by the best suitable unit\n },\n formatTime: function(seconds, [secs, mins, hours]) {\n // returns a 'HH:MM:SS' string\n }\n}\n```",
|
|
395
|
+
"value": {
|
|
396
|
+
"type": [
|
|
397
|
+
"UploadI18n"
|
|
398
|
+
]
|
|
399
|
+
}
|
|
400
|
+
},
|
|
392
401
|
{
|
|
393
402
|
"name": "disabled",
|
|
394
403
|
"description": "If true, the user cannot interact with this element.",
|
|
@@ -517,15 +526,6 @@
|
|
|
517
526
|
"undefined"
|
|
518
527
|
]
|
|
519
528
|
}
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
"name": "i18n",
|
|
523
|
-
"description": "The object used to localize this component.\nFor changing the default localization, change the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n dropFiles: {\n one: 'Drop file here',\n many: 'Drop files here'\n },\n addFiles: {\n one: 'Upload File...',\n many: 'Upload Files...'\n },\n error: {\n tooManyFiles: 'Too Many Files.',\n fileIsTooBig: 'File is Too Big.',\n incorrectFileType: 'Incorrect File Type.'\n },\n uploading: {\n status: {\n connecting: 'Connecting...',\n stalled: 'Stalled',\n processing: 'Processing File...',\n held: 'Queued'\n },\n remainingTime: {\n prefix: 'remaining time: ',\n unknown: 'unknown remaining time'\n },\n error: {\n serverUnavailable: 'Upload failed, please try again later',\n unexpectedServerError: 'Upload failed due to server error',\n forbidden: 'Upload forbidden'\n }\n },\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n sizeBase: 1000\n },\n formatSize: function(bytes) {\n // returns the size followed by the best suitable unit\n },\n formatTime: function(seconds, [secs, mins, hours]) {\n // returns a 'HH:MM:SS' string\n }\n}\n```",
|
|
524
|
-
"value": {
|
|
525
|
-
"type": [
|
|
526
|
-
"UploadI18n"
|
|
527
|
-
]
|
|
528
|
-
}
|
|
529
529
|
}
|
|
530
530
|
],
|
|
531
531
|
"events": [
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/upload",
|
|
4
|
-
"version": "24.8.0-
|
|
4
|
+
"version": "24.8.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -152,6 +152,13 @@
|
|
|
152
152
|
"kind": "expression"
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
|
+
{
|
|
156
|
+
"name": ".i18n",
|
|
157
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n dropFiles: {\n one: 'Drop file here',\n many: 'Drop files here'\n },\n addFiles: {\n one: 'Upload File...',\n many: 'Upload Files...'\n },\n error: {\n tooManyFiles: 'Too Many Files.',\n fileIsTooBig: 'File is Too Big.',\n incorrectFileType: 'Incorrect File Type.'\n },\n uploading: {\n status: {\n connecting: 'Connecting...',\n stalled: 'Stalled',\n processing: 'Processing File...',\n held: 'Queued'\n },\n remainingTime: {\n prefix: 'remaining time: ',\n unknown: 'unknown remaining time'\n },\n error: {\n serverUnavailable: 'Upload failed, please try again later',\n unexpectedServerError: 'Upload failed due to server error',\n forbidden: 'Upload forbidden'\n }\n },\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n sizeBase: 1000\n },\n formatSize: function(bytes) {\n // returns the size followed by the best suitable unit\n },\n formatTime: function(seconds, [secs, mins, hours]) {\n // returns a 'HH:MM:SS' string\n }\n}\n```",
|
|
158
|
+
"value": {
|
|
159
|
+
"kind": "expression"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
155
162
|
{
|
|
156
163
|
"name": ".target",
|
|
157
164
|
"description": "The server URL. The default value is an empty string, which means that\n_window.location_ will be used.",
|
|
@@ -222,13 +229,6 @@
|
|
|
222
229
|
"kind": "expression"
|
|
223
230
|
}
|
|
224
231
|
},
|
|
225
|
-
{
|
|
226
|
-
"name": ".i18n",
|
|
227
|
-
"description": "The object used to localize this component.\nFor changing the default localization, change the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n dropFiles: {\n one: 'Drop file here',\n many: 'Drop files here'\n },\n addFiles: {\n one: 'Upload File...',\n many: 'Upload Files...'\n },\n error: {\n tooManyFiles: 'Too Many Files.',\n fileIsTooBig: 'File is Too Big.',\n incorrectFileType: 'Incorrect File Type.'\n },\n uploading: {\n status: {\n connecting: 'Connecting...',\n stalled: 'Stalled',\n processing: 'Processing File...',\n held: 'Queued'\n },\n remainingTime: {\n prefix: 'remaining time: ',\n unknown: 'unknown remaining time'\n },\n error: {\n serverUnavailable: 'Upload failed, please try again later',\n unexpectedServerError: 'Upload failed due to server error',\n forbidden: 'Upload forbidden'\n }\n },\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n sizeBase: 1000\n },\n formatSize: function(bytes) {\n // returns the size followed by the best suitable unit\n },\n formatTime: function(seconds, [secs, mins, hours]) {\n // returns a 'HH:MM:SS' string\n }\n}\n```",
|
|
228
|
-
"value": {
|
|
229
|
-
"kind": "expression"
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
232
|
{
|
|
233
233
|
"name": "@file-reject",
|
|
234
234
|
"description": "Fired when a file cannot be added to the queue due to a constrain:\n file-size, file-type or maxFiles",
|