@vaadin/upload 22.0.0-beta1 → 22.0.1

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 CHANGED
@@ -1,13 +1,10 @@
1
- # <vaadin-upload>
1
+ # @vaadin/upload
2
2
 
3
- [Live Demo ↗](https://vaadin.com/components/vaadin-upload/html-examples/upload-basic-demos)
4
- |
5
- [API documentation ↗](https://vaadin.com/components/vaadin-upload/html-api)
3
+ A web component for uploading files.
6
4
 
7
- [<vaadin-upload>](https://vaadin.com/components/vaadin-upload) is a Web Component for uploading files, part of the [Vaadin components](https://vaadin.com/components).
5
+ [Documentation + Live Demo ](https://vaadin.com/docs/latest/ds/components/upload)
8
6
 
9
7
  [![npm version](https://badgen.net/npm/v/@vaadin/upload)](https://www.npmjs.com/package/@vaadin/upload)
10
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-upload)
11
8
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](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/vaadin-upload/master/screenshot.png" alt="Screenshot of vaadin-upload" width="670" />](https://vaadin.com/components/vaadin-upload)
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 `vaadin-upload`:
20
+ Install the component:
24
21
 
25
22
  ```sh
26
- npm i @vaadin/upload --save
23
+ npm i @vaadin/upload
27
24
  ```
28
25
 
29
- Once installed, import it in your application:
26
+ Once installed, import the component in your application:
30
27
 
31
28
  ```js
32
- import '@vaadin/upload/vaadin-upload.js';
29
+ import '@vaadin/upload';
33
30
  ```
34
31
 
35
- ## Getting started
32
+ ## Themes
36
33
 
37
- Vaadin components use the Lumo theme by default.
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 correspondent file from the `theme/material` folder.
37
+ To use the Material theme, import the component from the `theme/material` folder:
40
38
 
41
- ## Entry points
42
-
43
- - The component with the Lumo theme:
44
-
45
- `theme/lumo/vaadin-upload.js`
39
+ ```js
40
+ import '@vaadin/upload/theme/material/vaadin-upload.js';
41
+ ```
46
42
 
47
- - The component with the Material theme:
43
+ You can also import the Lumo version of the component explicitly:
48
44
 
49
- `theme/material/vaadin-upload.js`
45
+ ```js
46
+ import '@vaadin/upload/theme/lumo/vaadin-upload.js';
47
+ ```
50
48
 
51
- - Alias for `theme/lumo/vaadin-upload.js`:
49
+ Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
52
50
 
53
- `vaadin-upload.js`
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 usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
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-beta1",
3
+ "version": "22.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,18 +33,18 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/button": "22.0.0-beta1",
37
- "@vaadin/component-base": "22.0.0-beta1",
38
- "@vaadin/progress-bar": "22.0.0-beta1",
39
- "@vaadin/vaadin-lumo-styles": "22.0.0-beta1",
40
- "@vaadin/vaadin-material-styles": "22.0.0-beta1",
41
- "@vaadin/vaadin-themable-mixin": "22.0.0-beta1"
36
+ "@vaadin/button": "^22.0.1",
37
+ "@vaadin/component-base": "^22.0.1",
38
+ "@vaadin/progress-bar": "^22.0.1",
39
+ "@vaadin/vaadin-lumo-styles": "^22.0.1",
40
+ "@vaadin/vaadin-material-styles": "^22.0.1",
41
+ "@vaadin/vaadin-themable-mixin": "^22.0.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@esm-bundle/chai": "^4.3.4",
45
- "@vaadin/form-layout": "22.0.0-beta1",
46
- "@vaadin/testing-helpers": "^0.3.0",
45
+ "@vaadin/form-layout": "^22.0.1",
46
+ "@vaadin/testing-helpers": "^0.3.2",
47
47
  "sinon": "^9.2.0"
48
48
  },
49
- "gitHead": "4cf8a9d0504994200c610e44b3676114fef49c1e"
49
+ "gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
50
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
- <li part="row" tabindex="0">
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
- </li>
110
+ </div>
111
111
 
112
112
  <vaadin-progress-bar
113
113
  part="progress"
@@ -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,
@@ -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.
@@ -82,6 +83,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
82
83
  [part='file-list'] {
83
84
  padding: 0;
84
85
  margin: 0;
86
+ list-style-type: none;
85
87
  }
86
88
  </style>
87
89
 
@@ -103,7 +105,9 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
103
105
  <slot name="file-list">
104
106
  <ul id="fileList" part="file-list">
105
107
  <template is="dom-repeat" items="[[files]]" as="file">
106
- <vaadin-upload-file file="[[file]]" i18n="[[i18n]]"></vaadin-upload-file>
108
+ <li>
109
+ <vaadin-upload-file tabindex="0" file="[[file]]" i18n="[[i18n]]"></vaadin-upload-file>
110
+ </li>
107
111
  </template>
108
112
  </ul>
109
113
  </slot>
@@ -139,13 +143,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
139
143
  nodrop: {
140
144
  type: Boolean,
141
145
  reflectToAttribute: true,
142
- value: function () {
143
- try {
144
- return !!document.createEvent('TouchEvent');
145
- } catch (e) {
146
- return false;
147
- }
148
- }
146
+ value: isTouch
149
147
  },
150
148
 
151
149
  /**
@@ -825,7 +823,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
825
823
  // cancelling the following synthetic click. See also:
826
824
  // https://github.com/Polymer/polymer/issues/5289
827
825
  this.__resetMouseCanceller();
828
- this._onAddFilesClick();
826
+ this._onAddFilesClick(e);
829
827
  }
830
828
 
831
829
  /** @private */
@@ -834,11 +832,12 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
834
832
  }
835
833
 
836
834
  /** @private */
837
- _onAddFilesClick() {
835
+ _onAddFilesClick(e) {
838
836
  if (this.maxFilesReached) {
839
837
  return;
840
838
  }
841
839
 
840
+ e.stopPropagation();
842
841
  this.$.fileInput.value = '';
843
842
  this.$.fileInput.click();
844
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 { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
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',
@@ -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(:not(:first-child)) {
75
- border-top: 1px solid var(--lumo-contrast-10pct);
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 { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
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
- [part='row']:focus {
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