@vaadin/upload 22.0.0-alpha9 → 22.0.0
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/README.md +25 -24
- package/package.json +10 -9
- package/src/vaadin-upload-file.js +6 -6
- package/src/vaadin-upload.d.ts +0 -14
- package/src/vaadin-upload.js +14 -14
- package/theme/lumo/vaadin-upload-styles.js +14 -6
- package/theme/material/vaadin-upload-styles.js +5 -2
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vaadin/upload
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
|
5
|
-
[API documentation ↗](https://vaadin.com/components/vaadin-upload/html-api)
|
|
3
|
+
A web component for uploading files.
|
|
6
4
|
|
|
7
|
-
[
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/upload)
|
|
8
6
|
|
|
9
7
|
[](https://www.npmjs.com/package/@vaadin/upload)
|
|
10
|
-
[](https://vaadin.com/directory/component/vaadinvaadin-upload)
|
|
11
8
|
[](https://discord.gg/PHmkCKC)
|
|
12
9
|
|
|
13
10
|
```html
|
|
@@ -16,41 +13,44 @@
|
|
|
16
13
|
</vaadin-upload>
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
[<img src="https://raw.githubusercontent.com/vaadin/
|
|
16
|
+
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/upload/screenshot.png" width="656" alt="Screenshot of vaadin-upload">](https://vaadin.com/docs/latest/ds/components/upload)
|
|
20
17
|
|
|
21
18
|
## Installation
|
|
22
19
|
|
|
23
|
-
Install
|
|
20
|
+
Install the component:
|
|
24
21
|
|
|
25
22
|
```sh
|
|
26
|
-
npm i @vaadin/upload
|
|
23
|
+
npm i @vaadin/upload
|
|
27
24
|
```
|
|
28
25
|
|
|
29
|
-
Once installed, import
|
|
26
|
+
Once installed, import the component in your application:
|
|
30
27
|
|
|
31
28
|
```js
|
|
32
|
-
import '@vaadin/upload
|
|
29
|
+
import '@vaadin/upload';
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
##
|
|
32
|
+
## Themes
|
|
36
33
|
|
|
37
|
-
Vaadin components
|
|
34
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
35
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/upload/vaadin-upload.js) of the package uses the Lumo theme.
|
|
38
36
|
|
|
39
|
-
To use the Material theme, import the
|
|
37
|
+
To use the Material theme, import the component from the `theme/material` folder:
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`theme/lumo/vaadin-upload.js`
|
|
39
|
+
```js
|
|
40
|
+
import '@vaadin/upload/theme/material/vaadin-upload.js';
|
|
41
|
+
```
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
You can also import the Lumo version of the component explicitly:
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
```js
|
|
46
|
+
import '@vaadin/upload/theme/lumo/vaadin-upload.js';
|
|
47
|
+
```
|
|
50
48
|
|
|
51
|
-
-
|
|
49
|
+
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
```js
|
|
52
|
+
import '@vaadin/upload/src/vaadin-upload.js';
|
|
53
|
+
```
|
|
54
54
|
|
|
55
55
|
## Contributing
|
|
56
56
|
|
|
@@ -60,4 +60,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
|
|
|
60
60
|
|
|
61
61
|
Apache License 2.0
|
|
62
62
|
|
|
63
|
-
Vaadin collects development time
|
|
63
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
64
|
+
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/upload",
|
|
3
|
-
"version": "22.0.0
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,17 +33,18 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@polymer/polymer": "^3.0.0",
|
|
36
|
-
"@vaadin/button": "22.0.0
|
|
37
|
-
"@vaadin/component-base": "22.0.0
|
|
38
|
-
"@vaadin/progress-bar": "22.0.0
|
|
39
|
-
"@vaadin/vaadin-lumo-styles": "22.0.0
|
|
40
|
-
"@vaadin/vaadin-material-styles": "22.0.0
|
|
41
|
-
"@vaadin/vaadin-themable-mixin": "22.0.0
|
|
36
|
+
"@vaadin/button": "^22.0.0",
|
|
37
|
+
"@vaadin/component-base": "^22.0.0",
|
|
38
|
+
"@vaadin/progress-bar": "^22.0.0",
|
|
39
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.0",
|
|
40
|
+
"@vaadin/vaadin-material-styles": "^22.0.0",
|
|
41
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@esm-bundle/chai": "^4.3.4",
|
|
45
|
-
"@vaadin/
|
|
45
|
+
"@vaadin/form-layout": "^22.0.0",
|
|
46
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
46
47
|
"sinon": "^9.2.0"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b668e9b1a975227fbe34beb70d1cd5b03dce2348"
|
|
49
50
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
6
|
import '@vaadin/progress-bar/src/vaadin-progress-bar.js';
|
|
9
7
|
import './vaadin-upload-icons.js';
|
|
8
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* `<vaadin-upload-file>` element represents a file in the file list of `<vaadin-upload>`.
|
|
@@ -68,10 +68,10 @@ class UploadFile extends ThemableMixin(PolymerElement) {
|
|
|
68
68
|
}
|
|
69
69
|
</style>
|
|
70
70
|
|
|
71
|
-
<
|
|
71
|
+
<div part="row">
|
|
72
72
|
<div part="info">
|
|
73
|
-
<div part="done-icon" hidden$="[[!file.complete]]"></div>
|
|
74
|
-
<div part="warning-icon" hidden$="[[!file.error]]"></div>
|
|
73
|
+
<div part="done-icon" hidden$="[[!file.complete]]" aria-hidden="true"></div>
|
|
74
|
+
<div part="warning-icon" hidden$="[[!file.error]]" aria-hidden="true"></div>
|
|
75
75
|
|
|
76
76
|
<div part="meta">
|
|
77
77
|
<div part="name" id="name">[[file.name]]</div>
|
|
@@ -107,7 +107,7 @@ class UploadFile extends ThemableMixin(PolymerElement) {
|
|
|
107
107
|
aria-describedby="name"
|
|
108
108
|
></button>
|
|
109
109
|
</div>
|
|
110
|
-
</
|
|
110
|
+
</div>
|
|
111
111
|
|
|
112
112
|
<vaadin-progress-bar
|
|
113
113
|
part="progress"
|
package/src/vaadin-upload.d.ts
CHANGED
|
@@ -398,20 +398,6 @@ declare class Upload extends ThemableMixin(ElementMixin(HTMLElement)) {
|
|
|
398
398
|
*/
|
|
399
399
|
uploadFiles(files?: UploadFile | UploadFile[]): void;
|
|
400
400
|
|
|
401
|
-
/**
|
|
402
|
-
* Add the file for uploading. Called internally for each file after picking files from dialog or dropping files.
|
|
403
|
-
*
|
|
404
|
-
* @param file File being added
|
|
405
|
-
*/
|
|
406
|
-
_addFile(file: UploadFile): void;
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Remove file from upload list. Called internally if file upload was canceled.
|
|
410
|
-
*
|
|
411
|
-
* @param file File to remove
|
|
412
|
-
*/
|
|
413
|
-
_removeFile(file: UploadFile): void;
|
|
414
|
-
|
|
415
401
|
addEventListener<K extends keyof UploadEventMap>(
|
|
416
402
|
type: K,
|
|
417
403
|
listener: (this: Upload, ev: UploadEventMap[K]) => void,
|
package/src/vaadin-upload.js
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { resetMouseCanceller } from '@polymer/polymer/lib/utils/gestures.js';
|
|
8
6
|
import '@polymer/polymer/lib/elements/dom-repeat.js';
|
|
9
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
10
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
7
|
import '@vaadin/button/src/vaadin-button.js';
|
|
12
8
|
import './vaadin-upload-icons.js';
|
|
13
9
|
import './vaadin-upload-file.js';
|
|
10
|
+
import { resetMouseCanceller } from '@polymer/polymer/lib/utils/gestures.js';
|
|
11
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
|
+
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
13
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* `<vaadin-upload>` is a Web Component for uploading multiple files with drag and drop support.
|
|
@@ -68,6 +69,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
68
69
|
:host {
|
|
69
70
|
display: block;
|
|
70
71
|
position: relative;
|
|
72
|
+
box-sizing: border-box;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
:host([hidden]) {
|
|
@@ -81,6 +83,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
81
83
|
[part='file-list'] {
|
|
82
84
|
padding: 0;
|
|
83
85
|
margin: 0;
|
|
86
|
+
list-style-type: none;
|
|
84
87
|
}
|
|
85
88
|
</style>
|
|
86
89
|
|
|
@@ -102,7 +105,9 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
102
105
|
<slot name="file-list">
|
|
103
106
|
<ul id="fileList" part="file-list">
|
|
104
107
|
<template is="dom-repeat" items="[[files]]" as="file">
|
|
105
|
-
<
|
|
108
|
+
<li>
|
|
109
|
+
<vaadin-upload-file tabindex="0" file="[[file]]" i18n="[[i18n]]"></vaadin-upload-file>
|
|
110
|
+
</li>
|
|
106
111
|
</template>
|
|
107
112
|
</ul>
|
|
108
113
|
</slot>
|
|
@@ -138,13 +143,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
138
143
|
nodrop: {
|
|
139
144
|
type: Boolean,
|
|
140
145
|
reflectToAttribute: true,
|
|
141
|
-
value:
|
|
142
|
-
try {
|
|
143
|
-
return !!document.createEvent('TouchEvent');
|
|
144
|
-
} catch (e) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
146
|
+
value: isTouch
|
|
148
147
|
},
|
|
149
148
|
|
|
150
149
|
/**
|
|
@@ -824,7 +823,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
824
823
|
// cancelling the following synthetic click. See also:
|
|
825
824
|
// https://github.com/Polymer/polymer/issues/5289
|
|
826
825
|
this.__resetMouseCanceller();
|
|
827
|
-
this._onAddFilesClick();
|
|
826
|
+
this._onAddFilesClick(e);
|
|
828
827
|
}
|
|
829
828
|
|
|
830
829
|
/** @private */
|
|
@@ -833,11 +832,12 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
833
832
|
}
|
|
834
833
|
|
|
835
834
|
/** @private */
|
|
836
|
-
_onAddFilesClick() {
|
|
835
|
+
_onAddFilesClick(e) {
|
|
837
836
|
if (this.maxFilesReached) {
|
|
838
837
|
return;
|
|
839
838
|
}
|
|
840
839
|
|
|
840
|
+
e.stopPropagation();
|
|
841
841
|
this.$.fileInput.value = '';
|
|
842
842
|
this.$.fileInput.click();
|
|
843
843
|
}
|
|
@@ -4,10 +4,10 @@ import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
5
5
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
6
6
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
7
|
-
import { fieldButton } from '@vaadin/vaadin-lumo-styles/mixins/field-button.js';
|
|
8
7
|
import '@vaadin/button/theme/lumo/vaadin-button.js';
|
|
9
8
|
import '@vaadin/progress-bar/theme/lumo/vaadin-progress-bar.js';
|
|
10
|
-
import {
|
|
9
|
+
import { fieldButton } from '@vaadin/vaadin-lumo-styles/mixins/field-button.js';
|
|
10
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
11
|
|
|
12
12
|
registerStyles(
|
|
13
13
|
'vaadin-upload',
|
|
@@ -19,7 +19,7 @@ registerStyles(
|
|
|
19
19
|
:host(:not([nodrop])) {
|
|
20
20
|
overflow: hidden;
|
|
21
21
|
border: 1px dashed var(--lumo-contrast-20pct);
|
|
22
|
-
border-radius: var(--lumo-border-radius-
|
|
22
|
+
border-radius: var(--lumo-border-radius-l);
|
|
23
23
|
padding: var(--lumo-space-m);
|
|
24
24
|
transition: background-color 0.6s, border-color 0.6s;
|
|
25
25
|
}
|
|
@@ -62,6 +62,10 @@ registerStyles(
|
|
|
62
62
|
line-height: 1;
|
|
63
63
|
vertical-align: -0.25em;
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
[part='file-list'] > *:not(:first-child) > * {
|
|
67
|
+
border-top: 1px solid var(--lumo-contrast-10pct);
|
|
68
|
+
}
|
|
65
69
|
`,
|
|
66
70
|
{ moduleId: 'lumo-upload' }
|
|
67
71
|
);
|
|
@@ -71,8 +75,13 @@ const uploadFile = css`
|
|
|
71
75
|
padding: var(--lumo-space-s) 0;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
:host(:
|
|
75
|
-
|
|
78
|
+
:host(:focus) {
|
|
79
|
+
outline: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:host(:focus) [part='row'] {
|
|
83
|
+
border-radius: var(--lumo-border-radius-s);
|
|
84
|
+
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
[part='row'] {
|
|
@@ -129,7 +138,6 @@ const uploadFile = css`
|
|
|
129
138
|
cursor: var(--lumo-clickable-cursor);
|
|
130
139
|
}
|
|
131
140
|
|
|
132
|
-
[part='row']:focus,
|
|
133
141
|
[part$='button']:focus {
|
|
134
142
|
outline: none;
|
|
135
143
|
border-radius: var(--lumo-border-radius-s);
|
|
@@ -3,7 +3,7 @@ import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
|
3
3
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
4
|
import '@vaadin/button/theme/material/vaadin-button.js';
|
|
5
5
|
import '@vaadin/progress-bar/theme/material/vaadin-progress-bar.js';
|
|
6
|
-
import {
|
|
6
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
registerStyles(
|
|
9
9
|
'vaadin-upload',
|
|
@@ -106,8 +106,11 @@ registerStyles(
|
|
|
106
106
|
padding: 8px;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
:host(:focus) {
|
|
110
110
|
outline: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:host(:focus) [part='row'] {
|
|
111
114
|
background-color: var(--material-divider-color);
|
|
112
115
|
}
|
|
113
116
|
|