@vaadin/upload 25.1.2 → 25.2.0-alpha10

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.
@@ -140,6 +140,18 @@
140
140
  "description": "Capture attribute for mobile file input.",
141
141
  "fieldName": "capture"
142
142
  },
143
+ {
144
+ "name": "disabled",
145
+ "type": {
146
+ "text": "boolean"
147
+ },
148
+ "description": "If true, the user cannot interact with this element.",
149
+ "fieldName": "disabled",
150
+ "inheritedFrom": {
151
+ "name": "DisabledMixin",
152
+ "package": "@vaadin/a11y-base/src/disabled-mixin.js"
153
+ }
154
+ },
143
155
  {
144
156
  "name": "manager",
145
157
  "type": {
@@ -332,7 +344,7 @@
332
344
  "type": {
333
345
  "text": "Object"
334
346
  },
335
- "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\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
347
+ "description": "The object used to localize this component.\nTo change the default localization, replace this with an object\nthat provides all properties, or just the individual properties\nyou want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\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 fileTooLarge: 'File is too large'\n }\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n }\n}\n```",
336
348
  "attribute": "i18n",
337
349
  "inheritedFrom": {
338
350
  "name": "I18nMixin",
@@ -454,7 +466,7 @@
454
466
  "type": {
455
467
  "text": "Object"
456
468
  },
457
- "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\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
469
+ "description": "The object used to localize this component.\nTo change the default localization, replace this with an object\nthat provides all properties, or just the individual properties\nyou want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n file: {\n retry: 'Retry',\n start: 'Start',\n remove: 'Remove'\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 fileTooLarge: 'File is too large'\n }\n },\n units: {\n size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n }\n}\n```",
458
470
  "attribute": "i18n",
459
471
  "inheritedFrom": {
460
472
  "name": "I18nMixin",
@@ -964,21 +976,21 @@
964
976
  "type": {
965
977
  "text": "CustomEvent"
966
978
  },
967
- "description": "Fired when the abort button is pressed.",
979
+ "description": "Fired when the abort button is pressed to request aborting the upload of this file.",
968
980
  "name": "file-abort"
969
981
  },
970
982
  {
971
983
  "type": {
972
984
  "text": "CustomEvent"
973
985
  },
974
- "description": "Fired when the retry button is pressed.",
986
+ "description": "Fired when the retry button is pressed to request retrying the upload of this file.",
975
987
  "name": "file-retry"
976
988
  },
977
989
  {
978
990
  "type": {
979
991
  "text": "CustomEvent"
980
992
  },
981
- "description": "Fired when the start button is pressed.",
993
+ "description": "Fired when the start button is pressed to request starting the upload of this file.",
982
994
  "name": "file-start"
983
995
  }
984
996
  ],
@@ -1510,7 +1522,7 @@
1510
1522
  "type": {
1511
1523
  "text": "Object"
1512
1524
  },
1513
- "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```js\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```",
1525
+ "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```js\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 fileTooLarge: 'File is too large'\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```",
1514
1526
  "attribute": "i18n",
1515
1527
  "inheritedFrom": {
1516
1528
  "name": "I18nMixin",
@@ -1977,7 +1989,7 @@
1977
1989
  "type": {
1978
1990
  "text": "Object"
1979
1991
  },
1980
- "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```js\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```",
1992
+ "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```js\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 fileTooLarge: 'File is too large'\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```",
1981
1993
  "attribute": "i18n",
1982
1994
  "inheritedFrom": {
1983
1995
  "name": "I18nMixin",
@@ -2166,7 +2178,7 @@
2166
2178
  "type": {
2167
2179
  "text": "CustomEvent"
2168
2180
  },
2169
- "description": "Fired when a file cannot be added to the queue due to a constrain.",
2181
+ "description": "Fired when a file cannot be added to the queue due to a constraint: file size, file type, or maxFiles.",
2170
2182
  "inheritedFrom": {
2171
2183
  "name": "UploadMixin",
2172
2184
  "module": "src/vaadin-upload-mixin.js"
@@ -2202,7 +2214,7 @@
2202
2214
  "type": {
2203
2215
  "text": "CustomEvent"
2204
2216
  },
2205
- "description": "Fired when upload abort is requested.",
2217
+ "description": "Fired when upload abort is requested. If the default is prevented, the upload is not aborted.",
2206
2218
  "inheritedFrom": {
2207
2219
  "name": "UploadMixin",
2208
2220
  "module": "src/vaadin-upload-mixin.js"
@@ -2213,7 +2225,7 @@
2213
2225
  "type": {
2214
2226
  "text": "CustomEvent"
2215
2227
  },
2216
- "description": "Fired before the XHR is opened.",
2228
+ "description": "Fired before the XHR is opened. Useful for changing the request URL. If the default is prevented, the XHR is not opened.",
2217
2229
  "inheritedFrom": {
2218
2230
  "name": "UploadMixin",
2219
2231
  "module": "src/vaadin-upload-mixin.js"
@@ -2223,7 +2235,7 @@
2223
2235
  "type": {
2224
2236
  "text": "CustomEvent"
2225
2237
  },
2226
- "description": "Fired in case the upload process failed.",
2238
+ "description": "Fired when the upload process fails.",
2227
2239
  "name": "upload-error"
2228
2240
  },
2229
2241
  {
@@ -2242,7 +2254,7 @@
2242
2254
  "type": {
2243
2255
  "text": "CustomEvent"
2244
2256
  },
2245
- "description": "Fired when the XHR has been opened but not sent yet.",
2257
+ "description": "Fired when the XHR has been opened but not sent yet. Useful for appending data to the FormData or modifying request parameters. If the default is prevented, the request is not sent.",
2246
2258
  "inheritedFrom": {
2247
2259
  "name": "UploadMixin",
2248
2260
  "module": "src/vaadin-upload-mixin.js"
@@ -2253,7 +2265,7 @@
2253
2265
  "type": {
2254
2266
  "text": "CustomEvent"
2255
2267
  },
2256
- "description": "Fired when on the server response before analyzing it.",
2268
+ "description": "Fired when the server response is received, before the component analyzes it. If the default is prevented, the component returns and the listener can handle `xhr` and `file` directly; otherwise the normal flow checks `xhr.status` and `file.error`, which can be modified to force a custom outcome.",
2257
2269
  "inheritedFrom": {
2258
2270
  "name": "UploadMixin",
2259
2271
  "module": "src/vaadin-upload-mixin.js"
@@ -2264,7 +2276,7 @@
2264
2276
  "type": {
2265
2277
  "text": "CustomEvent"
2266
2278
  },
2267
- "description": "Fired when retry upload is requested.",
2279
+ "description": "Fired when retry upload is requested. If the default is prevented, the retry is not performed.",
2268
2280
  "inheritedFrom": {
2269
2281
  "name": "UploadMixin",
2270
2282
  "module": "src/vaadin-upload-mixin.js"
@@ -2285,7 +2297,7 @@
2285
2297
  "type": {
2286
2298
  "text": "CustomEvent"
2287
2299
  },
2288
- "description": "Fired in case the upload process succeeded.",
2300
+ "description": "Fired when the upload process succeeds.",
2289
2301
  "name": "upload-success"
2290
2302
  }
2291
2303
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/upload",
3
- "version": "25.1.2",
3
+ "version": "25.2.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,19 +35,19 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/a11y-base": "~25.1.2",
39
- "@vaadin/button": "~25.1.2",
40
- "@vaadin/component-base": "~25.1.2",
41
- "@vaadin/progress-bar": "~25.1.2",
42
- "@vaadin/vaadin-themable-mixin": "~25.1.2",
38
+ "@vaadin/a11y-base": "25.2.0-alpha10",
39
+ "@vaadin/button": "25.2.0-alpha10",
40
+ "@vaadin/component-base": "25.2.0-alpha10",
41
+ "@vaadin/progress-bar": "25.2.0-alpha10",
42
+ "@vaadin/vaadin-themable-mixin": "25.2.0-alpha10",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/aura": "~25.1.2",
47
- "@vaadin/chai-plugins": "~25.1.2",
48
- "@vaadin/test-runner-commands": "~25.1.2",
46
+ "@vaadin/aura": "25.2.0-alpha10",
47
+ "@vaadin/chai-plugins": "25.2.0-alpha10",
48
+ "@vaadin/test-runner-commands": "25.2.0-alpha10",
49
49
  "@vaadin/testing-helpers": "^2.0.0",
50
- "@vaadin/vaadin-lumo-styles": "~25.1.2",
50
+ "@vaadin/vaadin-lumo-styles": "25.2.0-alpha10",
51
51
  "sinon": "^21.0.2"
52
52
  },
53
53
  "customElements": "custom-elements.json",
@@ -55,5 +55,5 @@
55
55
  "web-types.json",
56
56
  "web-types.lit.json"
57
57
  ],
58
- "gitHead": "48e5dc507ac5eb8d34839be06cac652f1635fe1c"
58
+ "gitHead": "1303b6a3eeecb44a9d26f2b53cb56d9e906febdf"
59
59
  }
@@ -34,7 +34,6 @@ export const uploadFileStyles = [
34
34
  grid-column: 1;
35
35
  }
36
36
 
37
- :host([uploading]) [part='loader'],
38
37
  [part='done-icon']:not([hidden]),
39
38
  [part='warning-icon']:not([hidden]) {
40
39
  display: flex;
@@ -69,6 +69,43 @@ export declare class UploadFileListMixinClass {
69
69
  * To change the default localization, replace this with an object
70
70
  * that provides all properties, or just the individual properties
71
71
  * you want to change.
72
+ *
73
+ * The object has the following JSON structure and default values:
74
+ * ```js
75
+ * {
76
+ * file: {
77
+ * retry: 'Retry',
78
+ * start: 'Start',
79
+ * remove: 'Remove'
80
+ * },
81
+ * error: {
82
+ * tooManyFiles: 'Too Many Files.',
83
+ * fileIsTooBig: 'File is Too Big.',
84
+ * incorrectFileType: 'Incorrect File Type.'
85
+ * },
86
+ * uploading: {
87
+ * status: {
88
+ * connecting: 'Connecting...',
89
+ * stalled: 'Stalled',
90
+ * processing: 'Processing File...',
91
+ * held: 'Queued'
92
+ * },
93
+ * remainingTime: {
94
+ * prefix: 'remaining time: ',
95
+ * unknown: 'unknown remaining time'
96
+ * },
97
+ * error: {
98
+ * serverUnavailable: 'Upload failed, please try again later',
99
+ * unexpectedServerError: 'Upload failed due to server error',
100
+ * forbidden: 'Upload forbidden',
101
+ * fileTooLarge: 'File is too large'
102
+ * }
103
+ * },
104
+ * units: {
105
+ * size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
106
+ * }
107
+ * }
108
+ * ```
72
109
  */
73
110
  i18n: UploadFileListI18n;
74
111
  }
@@ -86,6 +86,58 @@ export const UploadFileListMixin = (superClass) =>
86
86
  return ['__updateItems(items, __effectiveI18n, disabled, _theme)'];
87
87
  }
88
88
 
89
+ /**
90
+ * The object used to localize this component.
91
+ * To change the default localization, replace this with an object
92
+ * that provides all properties, or just the individual properties
93
+ * you want to change.
94
+ *
95
+ * The object has the following JSON structure and default values:
96
+ * ```js
97
+ * {
98
+ * file: {
99
+ * retry: 'Retry',
100
+ * start: 'Start',
101
+ * remove: 'Remove'
102
+ * },
103
+ * error: {
104
+ * tooManyFiles: 'Too Many Files.',
105
+ * fileIsTooBig: 'File is Too Big.',
106
+ * incorrectFileType: 'Incorrect File Type.'
107
+ * },
108
+ * uploading: {
109
+ * status: {
110
+ * connecting: 'Connecting...',
111
+ * stalled: 'Stalled',
112
+ * processing: 'Processing File...',
113
+ * held: 'Queued'
114
+ * },
115
+ * remainingTime: {
116
+ * prefix: 'remaining time: ',
117
+ * unknown: 'unknown remaining time'
118
+ * },
119
+ * error: {
120
+ * serverUnavailable: 'Upload failed, please try again later',
121
+ * unexpectedServerError: 'Upload failed due to server error',
122
+ * forbidden: 'Upload forbidden',
123
+ * fileTooLarge: 'File is too large'
124
+ * }
125
+ * },
126
+ * units: {
127
+ * size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
128
+ * }
129
+ * }
130
+ * ```
131
+ * @type {!UploadFileListI18n}
132
+ */
133
+ get i18n() {
134
+ return super.i18n;
135
+ }
136
+
137
+ set i18n(value) {
138
+ super.i18n = value;
139
+ }
140
+
89
141
  constructor() {
90
142
  super();
91
143
  this.__onManagerFilesChanged = this.__onManagerFilesChanged.bind(this);
@@ -9,17 +9,17 @@ import { UploadFileMixin } from './vaadin-upload-file-mixin.js';
9
9
  export type { UploadFileI18n } from './vaadin-upload-file-mixin.js';
10
10
 
11
11
  /**
12
- * Fired when the retry button is pressed.
12
+ * Fired when the retry button is pressed to request retrying the upload of this file.
13
13
  */
14
14
  export type UploadFileRetryEvent = CustomEvent<{ file: File }>;
15
15
 
16
16
  /**
17
- * Fired when the start button is pressed.
17
+ * Fired when the start button is pressed to request starting the upload of this file.
18
18
  */
19
19
  export type UploadFileStartEvent = CustomEvent<{ file: File }>;
20
20
 
21
21
  /**
22
- * Fired when the abort button is pressed.
22
+ * Fired when the abort button is pressed to request aborting the upload of this file.
23
23
  */
24
24
  export type UploadFileAbortEvent = CustomEvent<{ file: File }>;
25
25
 
@@ -97,9 +97,9 @@ export interface UploadFileEventMap extends HTMLElementEventMap, UploadFileCusto
97
97
  *
98
98
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
99
99
  *
100
- * @fires {CustomEvent} file-abort - Fired when the abort button is pressed.
101
- * @fires {CustomEvent} file-retry - Fired when the retry button is pressed.
102
- * @fires {CustomEvent} file-start - Fired when the start button is pressed.
100
+ * @fires {CustomEvent} file-abort - Fired when the abort button is pressed to request aborting the upload of this file.
101
+ * @fires {CustomEvent} file-retry - Fired when the retry button is pressed to request retrying the upload of this file.
102
+ * @fires {CustomEvent} file-start - Fired when the start button is pressed to request starting the upload of this file.
103
103
  */
104
104
  declare class UploadFile extends UploadFileMixin(ThemableMixin(HTMLElement)) {
105
105
  addEventListener<K extends keyof UploadFileEventMap>(
@@ -77,9 +77,9 @@ import { UploadFileMixin } from './vaadin-upload-file-mixin.js';
77
77
  *
78
78
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
79
79
  *
80
- * @fires {CustomEvent} file-abort - Fired when the abort button is pressed.
81
- * @fires {CustomEvent} file-retry - Fired when the retry button is pressed.
82
- * @fires {CustomEvent} file-start - Fired when the start button is pressed.
80
+ * @fires {CustomEvent} file-abort - Fired when the abort button is pressed to request aborting the upload of this file.
81
+ * @fires {CustomEvent} file-retry - Fired when the retry button is pressed to request retrying the upload of this file.
82
+ * @fires {CustomEvent} file-start - Fired when the start button is pressed to request starting the upload of this file.
83
83
  *
84
84
  * @customElement vaadin-upload-file
85
85
  * @extends HTMLElement
@@ -157,33 +157,6 @@ class UploadFile extends UploadFileMixin(ThemableMixin(PolylitMixin(LumoInjectio
157
157
  <slot name="progress"></slot>
158
158
  `;
159
159
  }
160
-
161
- /**
162
- * Fired when the retry button is pressed. It is listened by `vaadin-upload`
163
- * which will start a new upload process of this file.
164
- *
165
- * @event file-retry
166
- * @param {Object} detail
167
- * @param {Object} detail.file file to retry upload of
168
- */
169
-
170
- /**
171
- * Fired when the start button is pressed. It is listened by `vaadin-upload`
172
- * which will start a new upload process of this file.
173
- *
174
- * @event file-start
175
- * @param {Object} detail
176
- * @param {Object} detail.file file to start upload of
177
- */
178
-
179
- /**
180
- * Fired when abort button is pressed. It is listened by `vaadin-upload` which
181
- * will abort the upload in progress, and then remove the file from the list.
182
- *
183
- * @event file-abort
184
- * @param {Object} detail
185
- * @param {Object} detail.file file to abort upload of
186
- */
187
160
  }
188
161
 
189
162
  defineCustomElement(UploadFile);
@@ -33,7 +33,7 @@ export function getFilesFromDropEvent(dropEvent) {
33
33
  .filter((item) => !!item)
34
34
  .filter((item) => typeof item.webkitGetAsEntry === 'function')
35
35
  .map((item) => item.webkitGetAsEntry())
36
- .some((entry) => !!entry && entry.isDirectory);
36
+ .some((entry) => !!entry?.isDirectory);
37
37
 
38
38
  if (!containsFolders) {
39
39
  return Promise.resolve(dropEvent.dataTransfer.files ? Array.from(dropEvent.dataTransfer.files) : []);
@@ -4,8 +4,8 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
7
- window.Vaadin = window.Vaadin || {};
8
- window.Vaadin.featureFlags = window.Vaadin.featureFlags || {};
7
+ window.Vaadin ||= {};
8
+ window.Vaadin.featureFlags ||= {};
9
9
 
10
10
  /**
11
11
  * A pure JavaScript class that manages file upload state and XHR requests.
@@ -252,7 +252,8 @@ export declare class UploadMixinClass {
252
252
  * error: {
253
253
  * serverUnavailable: 'Upload failed, please try again later',
254
254
  * unexpectedServerError: 'Upload failed due to server error',
255
- * forbidden: 'Upload forbidden'
255
+ * forbidden: 'Upload forbidden',
256
+ * fileTooLarge: 'File is too large'
256
257
  * }
257
258
  * },
258
259
  * file: {
@@ -411,7 +411,8 @@ export const UploadMixin = (superClass) =>
411
411
  * error: {
412
412
  * serverUnavailable: 'Upload failed, please try again later',
413
413
  * unexpectedServerError: 'Upload failed due to server error',
414
- * forbidden: 'Upload forbidden'
414
+ * forbidden: 'Upload forbidden',
415
+ * fileTooLarge: 'File is too large'
415
416
  * }
416
417
  * },
417
418
  * file: {
@@ -197,19 +197,19 @@ export interface UploadEventMap extends HTMLElementEventMap, UploadCustomEventMa
197
197
  *
198
198
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
199
199
  *
200
- * @fires {CustomEvent} file-reject - Fired when a file cannot be added to the queue due to a constrain.
200
+ * @fires {CustomEvent} file-reject - Fired when a file cannot be added to the queue due to a constraint: file size, file type, or maxFiles.
201
201
  * @fires {CustomEvent} file-remove - Fired when a file is removed from the list.
202
202
  * @fires {CustomEvent} files-changed - Fired when the `files` property changes.
203
203
  * @fires {CustomEvent} max-files-reached-changed - Fired when the `maxFilesReached` property changes.
204
- * @fires {CustomEvent} upload-before - Fired before the XHR is opened.
204
+ * @fires {CustomEvent} upload-before - Fired before the XHR is opened. Useful for changing the request URL. If the default is prevented, the XHR is not opened.
205
205
  * @fires {CustomEvent} upload-start - Fired when the XHR is sent.
206
206
  * @fires {CustomEvent} upload-progress - Fired as many times as the progress is updated.
207
- * @fires {CustomEvent} upload-success - Fired in case the upload process succeeded.
208
- * @fires {CustomEvent} upload-error - Fired in case the upload process failed.
209
- * @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet.
210
- * @fires {CustomEvent} upload-response - Fired when on the server response before analyzing it.
211
- * @fires {CustomEvent} upload-retry - Fired when retry upload is requested.
212
- * @fires {CustomEvent} upload-abort - Fired when upload abort is requested.
207
+ * @fires {CustomEvent} upload-success - Fired when the upload process succeeds.
208
+ * @fires {CustomEvent} upload-error - Fired when the upload process fails.
209
+ * @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet. Useful for appending data to the FormData or modifying request parameters. If the default is prevented, the request is not sent.
210
+ * @fires {CustomEvent} upload-response - Fired when the server response is received, before the component analyzes it. If the default is prevented, the component returns and the listener can handle `xhr` and `file` directly; otherwise the normal flow checks `xhr.status` and `file.error`, which can be modified to force a custom outcome.
211
+ * @fires {CustomEvent} upload-retry - Fired when retry upload is requested. If the default is prevented, the retry is not performed.
212
+ * @fires {CustomEvent} upload-abort - Fired when upload abort is requested. If the default is prevented, the upload is not aborted.
213
213
  */
214
214
  declare class Upload extends UploadMixin(ThemableMixin(ElementMixin(HTMLElement))) {
215
215
  addEventListener<K extends keyof UploadEventMap>(
@@ -88,19 +88,19 @@ import { UploadMixin } from './vaadin-upload-mixin.js';
88
88
  *
89
89
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
90
90
  *
91
- * @fires {CustomEvent} file-reject - Fired when a file cannot be added to the queue due to a constrain.
91
+ * @fires {CustomEvent} file-reject - Fired when a file cannot be added to the queue due to a constraint: file size, file type, or maxFiles.
92
92
  * @fires {CustomEvent} file-remove - Fired when a file is removed from the list.
93
93
  * @fires {CustomEvent} files-changed - Fired when the `files` property changes.
94
94
  * @fires {CustomEvent} max-files-reached-changed - Fired when the `maxFilesReached` property changes.
95
- * @fires {CustomEvent} upload-before - Fired before the XHR is opened.
95
+ * @fires {CustomEvent} upload-before - Fired before the XHR is opened. Useful for changing the request URL. If the default is prevented, the XHR is not opened.
96
96
  * @fires {CustomEvent} upload-start - Fired when the XHR is sent.
97
97
  * @fires {CustomEvent} upload-progress - Fired as many times as the progress is updated.
98
- * @fires {CustomEvent} upload-success - Fired in case the upload process succeeded.
99
- * @fires {CustomEvent} upload-error - Fired in case the upload process failed.
100
- * @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet.
101
- * @fires {CustomEvent} upload-response - Fired when on the server response before analyzing it.
102
- * @fires {CustomEvent} upload-retry - Fired when retry upload is requested.
103
- * @fires {CustomEvent} upload-abort - Fired when upload abort is requested.
98
+ * @fires {CustomEvent} upload-success - Fired when the upload process succeeds.
99
+ * @fires {CustomEvent} upload-error - Fired when the upload process fails.
100
+ * @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet. Useful for appending data to the FormData or modifying request parameters. If the default is prevented, the request is not sent.
101
+ * @fires {CustomEvent} upload-response - Fired when the server response is received, before the component analyzes it. If the default is prevented, the component returns and the listener can handle `xhr` and `file` directly; otherwise the normal flow checks `xhr.status` and `file.error`, which can be modified to force a custom outcome.
102
+ * @fires {CustomEvent} upload-retry - Fired when retry upload is requested. If the default is prevented, the retry is not performed.
103
+ * @fires {CustomEvent} upload-abort - Fired when upload abort is requested. If the default is prevented, the upload is not aborted.
104
104
  *
105
105
  * @customElement vaadin-upload
106
106
  * @extends HTMLElement
@@ -144,112 +144,6 @@ class Upload extends UploadMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInj
144
144
  />
145
145
  `;
146
146
  }
147
-
148
- /**
149
- * Fired when a file cannot be added to the queue due to a constrain:
150
- * file-size, file-type or maxFiles
151
- *
152
- * @event file-reject
153
- * @param {Object} detail
154
- * @param {Object} detail.file the file added
155
- * @param {string} detail.error the cause
156
- */
157
-
158
- /**
159
- * Fired before the XHR is opened. Could be used for changing the request
160
- * URL. If the default is prevented, then XHR would not be opened.
161
- *
162
- * @event upload-before
163
- * @param {Object} detail
164
- * @param {Object} detail.xhr the xhr
165
- * @param {Object} detail.file the file being uploaded
166
- * @param {Object} detail.file.uploadTarget the upload request URL, initialized with the value of vaadin-upload `target` property
167
- */
168
-
169
- /**
170
- * Fired when the XHR has been opened but not sent yet. Useful for appending
171
- * data keys to the FormData object, for changing some parameters like
172
- * headers, etc. If the event is defaultPrevented, `vaadin-upload` will not
173
- * send the request allowing the user to do something on his own.
174
- *
175
- * @event upload-request
176
- * @param {Object} detail
177
- * @param {Object} detail.xhr the xhr
178
- * @param {Object} detail.file the file being uploaded
179
- * @param {Object} detail.formData the FormData object
180
- */
181
-
182
- /**
183
- * Fired when the XHR is sent.
184
- *
185
- * @event upload-start
186
- * @param {Object} detail
187
- * @param {Object} detail.xhr the xhr
188
- * @param {Object} detail.file the file being uploaded
189
- */
190
-
191
- /**
192
- * Fired as many times as the progress is updated.
193
- *
194
- * @event upload-progress
195
- * @param {Object} detail
196
- * @param {Object} detail.xhr the xhr
197
- * @param {Object} detail.file the file being uploaded with loaded info
198
- */
199
-
200
- /**
201
- * Fired when we have the actual server response, and before the component
202
- * analyses it. It's useful for developers to make the upload fail depending
203
- * on the server response. If the event is defaultPrevented the vaadin-upload
204
- * will return allowing the user to do something on his own like retry the
205
- * upload, etc. since he has full access to the `xhr` and `file` objects.
206
- * Otherwise, if the event is not prevented default `vaadin-upload` continues
207
- * with the normal workflow checking the `xhr.status` and `file.error`
208
- * which also might be modified by the user to force a customized response.
209
- *
210
- * @event upload-response
211
- * @param {Object} detail
212
- * @param {Object} detail.xhr the xhr
213
- * @param {Object} detail.file the file being uploaded
214
- */
215
-
216
- /**
217
- * Fired in case the upload process succeed.
218
- *
219
- * @event upload-success
220
- * @param {Object} detail
221
- * @param {Object} detail.xhr the xhr
222
- * @param {Object} detail.file the file being uploaded with loaded info
223
- */
224
-
225
- /**
226
- * Fired in case the upload process failed.
227
- *
228
- * @event upload-error
229
- * @param {Object} detail
230
- * @param {Object} detail.xhr the xhr
231
- * @param {Object} detail.file the file being uploaded
232
- */
233
-
234
- /**
235
- * Fired when retry upload is requested. If the default is prevented, then
236
- * retry would not be performed.
237
- *
238
- * @event upload-retry
239
- * @param {Object} detail
240
- * @param {Object} detail.xhr the previous upload xhr
241
- * @param {Object} detail.file the file being uploaded
242
- */
243
-
244
- /**
245
- * Fired when retry abort is requested. If the default is prevented, then the
246
- * file upload would not be aborted.
247
- *
248
- * @event upload-abort
249
- * @param {Object} detail
250
- * @param {Object} detail.xhr the xhr
251
- * @param {Object} detail.file the file being uploaded
252
- */
253
147
  }
254
148
 
255
149
  defineCustomElement(Upload);