@vaadin/upload 22.0.0-alpha7 → 22.0.0-alpha8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/upload",
3
- "version": "22.0.0-alpha7",
3
+ "version": "22.0.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,17 +33,17 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/button": "22.0.0-alpha7",
37
- "@vaadin/component-base": "22.0.0-alpha7",
38
- "@vaadin/progress-bar": "22.0.0-alpha7",
39
- "@vaadin/vaadin-lumo-styles": "22.0.0-alpha7",
40
- "@vaadin/vaadin-material-styles": "22.0.0-alpha7",
41
- "@vaadin/vaadin-themable-mixin": "22.0.0-alpha7"
36
+ "@vaadin/button": "22.0.0-alpha8",
37
+ "@vaadin/component-base": "22.0.0-alpha8",
38
+ "@vaadin/progress-bar": "22.0.0-alpha8",
39
+ "@vaadin/vaadin-lumo-styles": "22.0.0-alpha8",
40
+ "@vaadin/vaadin-material-styles": "22.0.0-alpha8",
41
+ "@vaadin/vaadin-themable-mixin": "22.0.0-alpha8"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@esm-bundle/chai": "^4.3.4",
45
45
  "@vaadin/testing-helpers": "^0.3.0",
46
46
  "sinon": "^9.2.0"
47
47
  },
48
- "gitHead": "8e89419c6b44a1d225d5859e180d7b35e47ddb52"
48
+ "gitHead": "c24468526298ee26ad7f7280b59f6c8789e1f75f"
49
49
  }
@@ -28,7 +28,7 @@ import './vaadin-upload-icons.js';
28
28
  * `commands` | Container for file command icons
29
29
  * `start-button` | Start file upload button
30
30
  * `retry-button` | Retry file upload button
31
- * `clear-button` | Clear file button
31
+ * `remove-button` | Remove file button
32
32
  * `progress`| Progress bar
33
33
  *
34
34
  * The following state attributes are available for styling:
@@ -100,10 +100,10 @@ class UploadFile extends ThemableMixin(PolymerElement) {
100
100
  ></button>
101
101
  <button
102
102
  type="button"
103
- part="clear-button"
103
+ part="remove-button"
104
104
  file-event="file-abort"
105
105
  on-click="_fireFileEvent"
106
- aria-label$="[[i18n.file.clear]]"
106
+ aria-label$="[[i18n.file.remove]]"
107
107
  aria-describedby="name"
108
108
  ></button>
109
109
  </div>
@@ -1,8 +1,171 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
1
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
2
-
3
7
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
8
 
5
- import { UploadEventMap, UploadFile, UploadI18n, UploadMethod } from './interfaces';
9
+ export interface UploadFile extends File {
10
+ uploadTarget: string;
11
+ elapsed: number;
12
+ elapsedStr: string;
13
+ remaining: number;
14
+ remainingStr: string;
15
+ progress: number;
16
+ speed: number;
17
+ totalStr: string;
18
+ loaded: number;
19
+ loadedStr: string;
20
+ status: string;
21
+ error: string;
22
+ abort?: boolean;
23
+ complete?: boolean;
24
+ uploading?: boolean;
25
+ }
26
+
27
+ export interface UploadI18n {
28
+ dropFiles: {
29
+ one: string;
30
+ many: string;
31
+ };
32
+ addFiles: {
33
+ one: string;
34
+ many: string;
35
+ };
36
+ error: {
37
+ tooManyFiles: string;
38
+ fileIsTooBig: string;
39
+ incorrectFileType: string;
40
+ };
41
+ uploading: {
42
+ status: {
43
+ connecting: string;
44
+ stalled: string;
45
+ processing: string;
46
+ held: string;
47
+ };
48
+ remainingTime: {
49
+ prefix: string;
50
+ unknown: string;
51
+ };
52
+ error: {
53
+ serverUnavailable: string;
54
+ unexpectedServerError: string;
55
+ forbidden: string;
56
+ };
57
+ };
58
+ units: {
59
+ size: string[];
60
+ sizeBase?: number;
61
+ };
62
+ formatSize?: (bytes: number) => string;
63
+ formatTime?: (seconds: number, units: number[]) => string;
64
+ }
65
+
66
+ export type UploadMethod = 'POST' | 'PUT';
67
+
68
+ /**
69
+ * Fired when a file cannot be added to the queue due to a constrain:
70
+ * file-size, file-type or maxFiles
71
+ */
72
+ export type UploadFileRejectEvent = CustomEvent<{ file: UploadFile; error: string }>;
73
+
74
+ /**
75
+ * Fired when the `files` property changes.
76
+ */
77
+ export type UploadFilesChangedEvent = CustomEvent<{ value: UploadFile[] }>;
78
+
79
+ /**
80
+ * Fired when the `max-files-reached` property changes.
81
+ */
82
+ export type UploadMaxFilesReachedChangedEvent = CustomEvent<{ value: boolean }>;
83
+
84
+ /**
85
+ * Fired before the XHR is opened. Could be used for changing the request
86
+ * URL. If the default is prevented, then XHR would not be opened.
87
+ */
88
+ export type UploadBeforeEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
89
+
90
+ /**
91
+ * Fired when the XHR is sent.
92
+ */
93
+ export type UploadStartEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
94
+
95
+ /**
96
+ * Fired as many times as the progress is updated.
97
+ */
98
+ export type UploadProgressEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
99
+
100
+ /**
101
+ * Fired in case the upload process succeeded.
102
+ */
103
+ export type UploadSuccessEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
104
+
105
+ /**
106
+ * Fired in case the upload process failed.
107
+ */
108
+ export type UploadErrorEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
109
+
110
+ /**
111
+ * Fired when we have the actual server response, and before the component
112
+ * analyses it. It's useful for developers to make the upload fail depending
113
+ * on the server response. If the event is defaultPrevented the vaadin-upload
114
+ * will return allowing the user to do something on his own like retry the
115
+ * upload, etc. since he has full access to the `xhr` and `file` objects.
116
+ * Otherwise, if the event is not prevented default `vaadin-upload` continues
117
+ * with the normal workflow checking the `xhr.status` and `file.error`
118
+ * which also might be modified by the user to force a customized response,
119
+ */
120
+ export type UploadResponseEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
121
+
122
+ /**
123
+ * Fired when retry upload is requested. If the default is prevented, then
124
+ * retry would not be performed.
125
+ */
126
+ export type UploadRetryEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
127
+
128
+ /**
129
+ * Fired when upload abort is requested. If the default is prevented, then the
130
+ * file upload would not be aborted.
131
+ */
132
+ export type UploadAbortEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
133
+
134
+ /**
135
+ * Fired when the XHR has been opened but not sent yet. Useful for appending
136
+ * data keys to the FormData object, for changing some parameters like
137
+ * headers, etc. If the event is defaultPrevented, `vaadin-upload` will not
138
+ * send the request allowing the user to do something on his own.
139
+ */
140
+ export type UploadRequestEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile; formData: FormData }>;
141
+
142
+ export interface UploadCustomEventMap {
143
+ 'file-reject': UploadFileRejectEvent;
144
+
145
+ 'files-changed': UploadFilesChangedEvent;
146
+
147
+ 'max-files-reached-changed': UploadMaxFilesReachedChangedEvent;
148
+
149
+ 'upload-before': UploadBeforeEvent;
150
+
151
+ 'upload-start': UploadStartEvent;
152
+
153
+ 'upload-progress': UploadProgressEvent;
154
+
155
+ 'upload-response': UploadResponseEvent;
156
+
157
+ 'upload-success': UploadSuccessEvent;
158
+
159
+ 'upload-error': UploadErrorEvent;
160
+
161
+ 'upload-retry': UploadRetryEvent;
162
+
163
+ 'upload-abort': UploadAbortEvent;
164
+
165
+ 'upload-request': UploadRequestEvent;
166
+ }
167
+
168
+ export interface UploadEventMap extends HTMLElementEventMap, UploadCustomEventMap {}
6
169
 
7
170
  /**
8
171
  * `<vaadin-upload>` is a Web Component for uploading multiple files with drag and drop support.
@@ -208,7 +371,7 @@ declare class Upload extends ThemableMixin(ElementMixin(HTMLElement)) {
208
371
  * file: {
209
372
  * retry: 'Retry',
210
373
  * start: 'Start',
211
- * clear: 'Clear'
374
+ * remove: 'Remove'
212
375
  * },
213
376
  * units: {
214
377
  * size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
@@ -369,7 +369,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
369
369
  * file: {
370
370
  * retry: 'Retry',
371
371
  * start: 'Start',
372
- * clear: 'Clear'
372
+ * remove: 'Remove'
373
373
  * },
374
374
  * units: {
375
375
  * size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
@@ -424,7 +424,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
424
424
  file: {
425
425
  retry: 'Retry',
426
426
  start: 'Start',
427
- clear: 'Clear'
427
+ remove: 'Remove'
428
428
  },
429
429
  units: {
430
430
  size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
@@ -159,7 +159,7 @@ const uploadFile = css`
159
159
  content: var(--lumo-icons-reload);
160
160
  }
161
161
 
162
- [part='clear-button']::before {
162
+ [part='remove-button']::before {
163
163
  content: var(--lumo-icons-cross);
164
164
  }
165
165
 
@@ -168,7 +168,7 @@ registerStyles(
168
168
  outline: none;
169
169
  }
170
170
 
171
- [part='clear-button'] {
171
+ [part='remove-button'] {
172
172
  margin-right: -8px;
173
173
  }
174
174
 
@@ -194,7 +194,7 @@ registerStyles(
194
194
  content: var(--material-icons-reload);
195
195
  }
196
196
 
197
- [part='clear-button']::before {
197
+ [part='remove-button']::before {
198
198
  content: var(--material-icons-clear);
199
199
  }
200
200
 
@@ -1,2 +1 @@
1
1
  export * from './src/vaadin-upload.js';
2
- export * from './src/interfaces';
@@ -1,160 +0,0 @@
1
- export interface UploadFile extends File {
2
- uploadTarget: string;
3
- elapsed: number;
4
- elapsedStr: string;
5
- remaining: number;
6
- remainingStr: string;
7
- progress: number;
8
- speed: number;
9
- totalStr: string;
10
- loaded: number;
11
- loadedStr: string;
12
- status: string;
13
- error: string;
14
- abort?: boolean;
15
- complete?: boolean;
16
- uploading?: boolean;
17
- }
18
-
19
- export interface UploadI18n {
20
- dropFiles: {
21
- one: string;
22
- many: string;
23
- };
24
- addFiles: {
25
- one: string;
26
- many: string;
27
- };
28
- error: {
29
- tooManyFiles: string;
30
- fileIsTooBig: string;
31
- incorrectFileType: string;
32
- };
33
- uploading: {
34
- status: {
35
- connecting: string;
36
- stalled: string;
37
- processing: string;
38
- held: string;
39
- };
40
- remainingTime: {
41
- prefix: string;
42
- unknown: string;
43
- };
44
- error: {
45
- serverUnavailable: string;
46
- unexpectedServerError: string;
47
- forbidden: string;
48
- };
49
- };
50
- units: {
51
- size: string[];
52
- sizeBase?: number;
53
- };
54
- formatSize?: (bytes: number) => string;
55
- formatTime?: (seconds: number, units: number[]) => string;
56
- }
57
-
58
- export type UploadMethod = 'POST' | 'PUT';
59
-
60
- /**
61
- * Fired when a file cannot be added to the queue due to a constrain:
62
- * file-size, file-type or maxFiles
63
- */
64
- export type UploadFileRejectEvent = CustomEvent<{ file: UploadFile; error: string }>;
65
-
66
- /**
67
- * Fired when the `files` property changes.
68
- */
69
- export type UploadFilesChangedEvent = CustomEvent<{ value: UploadFile[] }>;
70
-
71
- /**
72
- * Fired when the `max-files-reached` property changes.
73
- */
74
- export type UploadMaxFilesReachedChangedEvent = CustomEvent<{ value: boolean }>;
75
-
76
- /**
77
- * Fired before the XHR is opened. Could be used for changing the request
78
- * URL. If the default is prevented, then XHR would not be opened.
79
- */
80
- export type UploadBeforeEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
81
-
82
- /**
83
- * Fired when the XHR is sent.
84
- */
85
- export type UploadStartEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
86
-
87
- /**
88
- * Fired as many times as the progress is updated.
89
- */
90
- export type UploadProgressEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
91
-
92
- /**
93
- * Fired in case the upload process succeeded.
94
- */
95
- export type UploadSuccessEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
96
-
97
- /**
98
- * Fired in case the upload process failed.
99
- */
100
- export type UploadErrorEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
101
-
102
- /**
103
- * Fired when we have the actual server response, and before the component
104
- * analyses it. It's useful for developers to make the upload fail depending
105
- * on the server response. If the event is defaultPrevented the vaadin-upload
106
- * will return allowing the user to do something on his own like retry the
107
- * upload, etc. since he has full access to the `xhr` and `file` objects.
108
- * Otherwise, if the event is not prevented default `vaadin-upload` continues
109
- * with the normal workflow checking the `xhr.status` and `file.error`
110
- * which also might be modified by the user to force a customized response,
111
- */
112
- export type UploadResponseEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
113
-
114
- /**
115
- * Fired when retry upload is requested. If the default is prevented, then
116
- * retry would not be performed.
117
- */
118
- export type UploadRetryEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
119
-
120
- /**
121
- * Fired when upload abort is requested. If the default is prevented, then the
122
- * file upload would not be aborted.
123
- */
124
- export type UploadAbortEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile }>;
125
-
126
- /**
127
- * Fired when the XHR has been opened but not sent yet. Useful for appending
128
- * data keys to the FormData object, for changing some parameters like
129
- * headers, etc. If the event is defaultPrevented, `vaadin-upload` will not
130
- * send the request allowing the user to do something on his own.
131
- */
132
- export type UploadRequestEvent = CustomEvent<{ xhr: XMLHttpRequest; file: UploadFile; formData: FormData }>;
133
-
134
- export interface UploadCustomEventMap {
135
- 'file-reject': UploadFileRejectEvent;
136
-
137
- 'files-changed': UploadFilesChangedEvent;
138
-
139
- 'max-files-reached-changed': UploadMaxFilesReachedChangedEvent;
140
-
141
- 'upload-before': UploadBeforeEvent;
142
-
143
- 'upload-start': UploadStartEvent;
144
-
145
- 'upload-progress': UploadProgressEvent;
146
-
147
- 'upload-response': UploadResponseEvent;
148
-
149
- 'upload-success': UploadSuccessEvent;
150
-
151
- 'upload-error': UploadErrorEvent;
152
-
153
- 'upload-retry': UploadRetryEvent;
154
-
155
- 'upload-abort': UploadAbortEvent;
156
-
157
- 'upload-request': UploadRequestEvent;
158
- }
159
-
160
- export interface UploadEventMap extends HTMLElementEventMap, UploadCustomEventMap {}