@vaadin/upload 25.2.0-alpha8 → 25.2.0-beta1
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/custom-elements.json +25 -15
- package/package.json +11 -11
- package/src/vaadin-upload-button.js +1 -4
- package/src/vaadin-upload-drop-zone.js +2 -4
- package/src/vaadin-upload-file-list-mixin.js +5 -5
- package/src/vaadin-upload-file-list.js +0 -2
- package/src/vaadin-upload-file-mixin.js +0 -4
- package/src/vaadin-upload-file.d.ts +6 -6
- package/src/vaadin-upload-file.js +3 -32
- package/src/vaadin-upload-helpers.js +1 -1
- package/src/vaadin-upload-manager.js +8 -8
- package/src/vaadin-upload-mixin.js +5 -4
- package/src/vaadin-upload.d.ts +8 -8
- package/src/vaadin-upload.js +8 -117
- package/web-types.json +124 -278
- package/web-types.lit.json +89 -96
package/custom-elements.json
CHANGED
|
@@ -122,8 +122,7 @@
|
|
|
122
122
|
"text": "boolean"
|
|
123
123
|
},
|
|
124
124
|
"description": "True when max files has been reached on the manager.",
|
|
125
|
-
"attribute": "max-files-reached"
|
|
126
|
-
"reflects": true
|
|
125
|
+
"attribute": "max-files-reached"
|
|
127
126
|
},
|
|
128
127
|
{
|
|
129
128
|
"kind": "method",
|
|
@@ -140,6 +139,18 @@
|
|
|
140
139
|
"description": "Capture attribute for mobile file input.",
|
|
141
140
|
"fieldName": "capture"
|
|
142
141
|
},
|
|
142
|
+
{
|
|
143
|
+
"name": "disabled",
|
|
144
|
+
"type": {
|
|
145
|
+
"text": "boolean"
|
|
146
|
+
},
|
|
147
|
+
"description": "If true, the user cannot interact with this element.",
|
|
148
|
+
"fieldName": "disabled",
|
|
149
|
+
"inheritedFrom": {
|
|
150
|
+
"name": "DisabledMixin",
|
|
151
|
+
"package": "@vaadin/a11y-base/src/disabled-mixin.js"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
143
154
|
{
|
|
144
155
|
"name": "manager",
|
|
145
156
|
"type": {
|
|
@@ -237,8 +248,7 @@
|
|
|
237
248
|
},
|
|
238
249
|
"description": "True when max files has been reached on the manager.",
|
|
239
250
|
"readonly": true,
|
|
240
|
-
"attribute": "max-files-reached"
|
|
241
|
-
"reflects": true
|
|
251
|
+
"attribute": "max-files-reached"
|
|
242
252
|
}
|
|
243
253
|
],
|
|
244
254
|
"attributes": [
|
|
@@ -964,21 +974,21 @@
|
|
|
964
974
|
"type": {
|
|
965
975
|
"text": "CustomEvent"
|
|
966
976
|
},
|
|
967
|
-
"description": "Fired when the abort button is pressed.",
|
|
977
|
+
"description": "Fired when the abort button is pressed to request aborting the upload of this file.",
|
|
968
978
|
"name": "file-abort"
|
|
969
979
|
},
|
|
970
980
|
{
|
|
971
981
|
"type": {
|
|
972
982
|
"text": "CustomEvent"
|
|
973
983
|
},
|
|
974
|
-
"description": "Fired when the retry button is pressed.",
|
|
984
|
+
"description": "Fired when the retry button is pressed to request retrying the upload of this file.",
|
|
975
985
|
"name": "file-retry"
|
|
976
986
|
},
|
|
977
987
|
{
|
|
978
988
|
"type": {
|
|
979
989
|
"text": "CustomEvent"
|
|
980
990
|
},
|
|
981
|
-
"description": "Fired when the start button is pressed.",
|
|
991
|
+
"description": "Fired when the start button is pressed to request starting the upload of this file.",
|
|
982
992
|
"name": "file-start"
|
|
983
993
|
}
|
|
984
994
|
],
|
|
@@ -2166,7 +2176,7 @@
|
|
|
2166
2176
|
"type": {
|
|
2167
2177
|
"text": "CustomEvent"
|
|
2168
2178
|
},
|
|
2169
|
-
"description": "Fired when a file cannot be added to the queue due to a
|
|
2179
|
+
"description": "Fired when a file cannot be added to the queue due to a constraint: file size, file type, or maxFiles.",
|
|
2170
2180
|
"inheritedFrom": {
|
|
2171
2181
|
"name": "UploadMixin",
|
|
2172
2182
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2202,7 +2212,7 @@
|
|
|
2202
2212
|
"type": {
|
|
2203
2213
|
"text": "CustomEvent"
|
|
2204
2214
|
},
|
|
2205
|
-
"description": "Fired when upload abort is requested.",
|
|
2215
|
+
"description": "Fired when upload abort is requested. If the default is prevented, the upload is not aborted.",
|
|
2206
2216
|
"inheritedFrom": {
|
|
2207
2217
|
"name": "UploadMixin",
|
|
2208
2218
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2213,7 +2223,7 @@
|
|
|
2213
2223
|
"type": {
|
|
2214
2224
|
"text": "CustomEvent"
|
|
2215
2225
|
},
|
|
2216
|
-
"description": "Fired before the XHR is opened.",
|
|
2226
|
+
"description": "Fired before the XHR is opened. Useful for changing the request URL. If the default is prevented, the XHR is not opened.",
|
|
2217
2227
|
"inheritedFrom": {
|
|
2218
2228
|
"name": "UploadMixin",
|
|
2219
2229
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2223,7 +2233,7 @@
|
|
|
2223
2233
|
"type": {
|
|
2224
2234
|
"text": "CustomEvent"
|
|
2225
2235
|
},
|
|
2226
|
-
"description": "Fired
|
|
2236
|
+
"description": "Fired when the upload process fails.",
|
|
2227
2237
|
"name": "upload-error"
|
|
2228
2238
|
},
|
|
2229
2239
|
{
|
|
@@ -2242,7 +2252,7 @@
|
|
|
2242
2252
|
"type": {
|
|
2243
2253
|
"text": "CustomEvent"
|
|
2244
2254
|
},
|
|
2245
|
-
"description": "Fired when the XHR has been opened but not sent yet.",
|
|
2255
|
+
"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
2256
|
"inheritedFrom": {
|
|
2247
2257
|
"name": "UploadMixin",
|
|
2248
2258
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2253,7 +2263,7 @@
|
|
|
2253
2263
|
"type": {
|
|
2254
2264
|
"text": "CustomEvent"
|
|
2255
2265
|
},
|
|
2256
|
-
"description": "Fired when
|
|
2266
|
+
"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
2267
|
"inheritedFrom": {
|
|
2258
2268
|
"name": "UploadMixin",
|
|
2259
2269
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2264,7 +2274,7 @@
|
|
|
2264
2274
|
"type": {
|
|
2265
2275
|
"text": "CustomEvent"
|
|
2266
2276
|
},
|
|
2267
|
-
"description": "Fired when retry upload is requested.",
|
|
2277
|
+
"description": "Fired when retry upload is requested. If the default is prevented, the retry is not performed.",
|
|
2268
2278
|
"inheritedFrom": {
|
|
2269
2279
|
"name": "UploadMixin",
|
|
2270
2280
|
"module": "src/vaadin-upload-mixin.js"
|
|
@@ -2285,7 +2295,7 @@
|
|
|
2285
2295
|
"type": {
|
|
2286
2296
|
"text": "CustomEvent"
|
|
2287
2297
|
},
|
|
2288
|
-
"description": "Fired
|
|
2298
|
+
"description": "Fired when the upload process succeeds.",
|
|
2289
2299
|
"name": "upload-success"
|
|
2290
2300
|
}
|
|
2291
2301
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/upload",
|
|
3
|
-
"version": "25.2.0-
|
|
3
|
+
"version": "25.2.0-beta1",
|
|
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.2.0-
|
|
39
|
-
"@vaadin/button": "25.2.0-
|
|
40
|
-
"@vaadin/component-base": "25.2.0-
|
|
41
|
-
"@vaadin/progress-bar": "25.2.0-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "25.2.0-
|
|
38
|
+
"@vaadin/a11y-base": "25.2.0-beta1",
|
|
39
|
+
"@vaadin/button": "25.2.0-beta1",
|
|
40
|
+
"@vaadin/component-base": "25.2.0-beta1",
|
|
41
|
+
"@vaadin/progress-bar": "25.2.0-beta1",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.2.0-beta1",
|
|
43
43
|
"lit": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vaadin/aura": "25.2.0-
|
|
47
|
-
"@vaadin/chai-plugins": "25.2.0-
|
|
48
|
-
"@vaadin/test-runner-commands": "25.2.0-
|
|
46
|
+
"@vaadin/aura": "25.2.0-beta1",
|
|
47
|
+
"@vaadin/chai-plugins": "25.2.0-beta1",
|
|
48
|
+
"@vaadin/test-runner-commands": "25.2.0-beta1",
|
|
49
49
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
50
|
-
"@vaadin/vaadin-lumo-styles": "25.2.0-
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "25.2.0-beta1",
|
|
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": "
|
|
58
|
+
"gitHead": "471a23f60d1eb725f98a33f62cb9664d9c0a4163"
|
|
59
59
|
}
|
|
@@ -72,9 +72,6 @@ import { UploadManager } from './vaadin-upload-manager.js';
|
|
|
72
72
|
*
|
|
73
73
|
* @customElement vaadin-upload-button
|
|
74
74
|
* @extends HTMLElement
|
|
75
|
-
* @mixes ButtonMixin
|
|
76
|
-
* @mixes ElementMixin
|
|
77
|
-
* @mixes ThemableMixin
|
|
78
75
|
*/
|
|
79
76
|
class UploadButton extends ButtonMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
80
77
|
static get is() {
|
|
@@ -112,7 +109,7 @@ class UploadButton extends ButtonMixin(ElementMixin(ThemableMixin(PolylitMixin(L
|
|
|
112
109
|
maxFilesReached: {
|
|
113
110
|
type: Boolean,
|
|
114
111
|
value: false,
|
|
115
|
-
|
|
112
|
+
reflectToAttribute: true,
|
|
116
113
|
attribute: 'max-files-reached',
|
|
117
114
|
},
|
|
118
115
|
};
|
|
@@ -49,8 +49,6 @@ import { UploadManager } from './vaadin-upload-manager.js';
|
|
|
49
49
|
*
|
|
50
50
|
* @customElement vaadin-upload-drop-zone
|
|
51
51
|
* @extends HTMLElement
|
|
52
|
-
* @mixes ElementMixin
|
|
53
|
-
* @mixes ThemableMixin
|
|
54
52
|
*/
|
|
55
53
|
class UploadDropZone extends ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
56
54
|
static get is() {
|
|
@@ -94,7 +92,7 @@ class UploadDropZone extends ElementMixin(ThemableMixin(PolylitMixin(LumoInjecti
|
|
|
94
92
|
maxFilesReached: {
|
|
95
93
|
type: Boolean,
|
|
96
94
|
value: false,
|
|
97
|
-
|
|
95
|
+
reflectToAttribute: true,
|
|
98
96
|
attribute: 'max-files-reached',
|
|
99
97
|
},
|
|
100
98
|
|
|
@@ -102,7 +100,7 @@ class UploadDropZone extends ElementMixin(ThemableMixin(PolylitMixin(LumoInjecti
|
|
|
102
100
|
__dragover: {
|
|
103
101
|
type: Boolean,
|
|
104
102
|
value: false,
|
|
105
|
-
|
|
103
|
+
reflectToAttribute: true,
|
|
106
104
|
attribute: 'dragover',
|
|
107
105
|
},
|
|
108
106
|
};
|
|
@@ -42,12 +42,8 @@ const DEFAULT_I18N = {
|
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
/**
|
|
46
|
-
* @polymerMixin
|
|
47
|
-
* @mixes I18nMixin
|
|
48
|
-
*/
|
|
49
45
|
export const UploadFileListMixin = (superClass) =>
|
|
50
|
-
class UploadFileListMixin extends I18nMixin(
|
|
46
|
+
class UploadFileListMixin extends I18nMixin(superClass) {
|
|
51
47
|
static get properties() {
|
|
52
48
|
return {
|
|
53
49
|
/**
|
|
@@ -86,6 +82,10 @@ export const UploadFileListMixin = (superClass) =>
|
|
|
86
82
|
return ['__updateItems(items, __effectiveI18n, disabled, _theme)'];
|
|
87
83
|
}
|
|
88
84
|
|
|
85
|
+
static get defaultI18n() {
|
|
86
|
+
return DEFAULT_I18N;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
89
|
/**
|
|
90
90
|
* The object used to localize this component.
|
|
91
91
|
* To change the default localization, replace this with an object
|
|
@@ -77,8 +77,6 @@ import { UploadFileListMixin } from './vaadin-upload-file-list-mixin.js';
|
|
|
77
77
|
*
|
|
78
78
|
* @customElement vaadin-upload-file-list
|
|
79
79
|
* @extends HTMLElement
|
|
80
|
-
* @mixes ThemableMixin
|
|
81
|
-
* @mixes UploadFileListMixin
|
|
82
80
|
*/
|
|
83
81
|
class UploadFileList extends UploadFileListMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
84
82
|
static get is() {
|
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
7
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @polymerMixin
|
|
11
|
-
* @mixes FocusMixin
|
|
12
|
-
*/
|
|
13
9
|
export const UploadFileMixin = (superClass) =>
|
|
14
10
|
class UploadFileMixin extends FocusMixin(superClass) {
|
|
15
11
|
static get properties() {
|
|
@@ -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,14 +77,12 @@ 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
|
|
86
|
-
* @mixes UploadFileMixin
|
|
87
|
-
* @mixes ThemableMixin
|
|
88
86
|
*/
|
|
89
87
|
class UploadFile extends UploadFileMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
90
88
|
static get is() {
|
|
@@ -157,33 +155,6 @@ class UploadFile extends UploadFileMixin(ThemableMixin(PolylitMixin(LumoInjectio
|
|
|
157
155
|
<slot name="progress"></slot>
|
|
158
156
|
`;
|
|
159
157
|
}
|
|
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
158
|
}
|
|
188
159
|
|
|
189
160
|
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
|
|
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
|
|
8
|
-
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.
|
|
@@ -119,15 +119,15 @@ export class UploadManager extends EventTarget {
|
|
|
119
119
|
this.method = options.method || 'POST';
|
|
120
120
|
this.headers = options.headers || {};
|
|
121
121
|
this.timeout = options.timeout || 0;
|
|
122
|
-
this.maxFiles = options.maxFiles
|
|
123
|
-
this.maxFileSize = options.maxFileSize
|
|
122
|
+
this.maxFiles = options.maxFiles ?? Infinity;
|
|
123
|
+
this.maxFileSize = options.maxFileSize ?? Infinity;
|
|
124
124
|
this.accept = options.accept || '';
|
|
125
|
-
this.noAuto = options.noAuto
|
|
126
|
-
this.withCredentials = options.withCredentials
|
|
125
|
+
this.noAuto = options.noAuto ?? false;
|
|
126
|
+
this.withCredentials = options.withCredentials ?? false;
|
|
127
127
|
this.uploadFormat = options.uploadFormat || 'raw';
|
|
128
|
-
this.maxConcurrentUploads = options.maxConcurrentUploads
|
|
128
|
+
this.maxConcurrentUploads = options.maxConcurrentUploads ?? 3;
|
|
129
129
|
this.formDataName = options.formDataName || 'file';
|
|
130
|
-
this.disabled = options.disabled
|
|
130
|
+
this.disabled = options.disabled ?? false;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -105,11 +105,8 @@ class DropLabelController extends SlotController {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* @polymerMixin
|
|
110
|
-
*/
|
|
111
108
|
export const UploadMixin = (superClass) =>
|
|
112
|
-
class UploadMixin extends I18nMixin(
|
|
109
|
+
class UploadMixin extends I18nMixin(superClass) {
|
|
113
110
|
static get properties() {
|
|
114
111
|
return {
|
|
115
112
|
/**
|
|
@@ -375,6 +372,10 @@ export const UploadMixin = (superClass) =>
|
|
|
375
372
|
];
|
|
376
373
|
}
|
|
377
374
|
|
|
375
|
+
static get defaultI18n() {
|
|
376
|
+
return DEFAULT_I18N;
|
|
377
|
+
}
|
|
378
|
+
|
|
378
379
|
/**
|
|
379
380
|
* The object used to localize this component. To change the default
|
|
380
381
|
* localization, replace this with an object that provides all properties, or
|
package/src/vaadin-upload.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
208
|
-
* @fires {CustomEvent} upload-error - Fired
|
|
209
|
-
* @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet.
|
|
210
|
-
* @fires {CustomEvent} upload-response - Fired when
|
|
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>(
|
package/src/vaadin-upload.js
CHANGED
|
@@ -88,25 +88,22 @@ 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
|
|
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
|
|
99
|
-
* @fires {CustomEvent} upload-error - Fired
|
|
100
|
-
* @fires {CustomEvent} upload-request - Fired when the XHR has been opened but not sent yet.
|
|
101
|
-
* @fires {CustomEvent} upload-response - Fired when
|
|
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
|
|
107
|
-
* @mixes ThemableMixin
|
|
108
|
-
* @mixes ElementMixin
|
|
109
|
-
* @mixes UploadMixin
|
|
110
107
|
*/
|
|
111
108
|
class Upload extends UploadMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
112
109
|
static get is() {
|
|
@@ -144,112 +141,6 @@ class Upload extends UploadMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInj
|
|
|
144
141
|
/>
|
|
145
142
|
`;
|
|
146
143
|
}
|
|
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
144
|
}
|
|
254
145
|
|
|
255
146
|
defineCustomElement(Upload);
|