@vaadin/upload 22.0.1 → 23.0.0-alpha3

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.1",
3
+ "version": "23.0.0-alpha3",
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.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"
36
+ "@vaadin/button": "23.0.0-alpha3",
37
+ "@vaadin/component-base": "23.0.0-alpha3",
38
+ "@vaadin/progress-bar": "23.0.0-alpha3",
39
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha3",
40
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha3",
41
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha3"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@esm-bundle/chai": "^4.3.4",
45
- "@vaadin/form-layout": "^22.0.1",
45
+ "@vaadin/form-layout": "23.0.0-alpha3",
46
46
  "@vaadin/testing-helpers": "^0.3.2",
47
47
  "sinon": "^9.2.0"
48
48
  },
49
- "gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
49
+ "gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44"
50
50
  }
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import '@vaadin/progress-bar/src/vaadin-progress-bar.js';
7
7
  import './vaadin-upload-icons.js';
8
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
+ import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
9
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
11
 
11
12
  /**
@@ -15,36 +16,40 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
15
16
  *
16
17
  * The following shadow DOM parts are available for styling:
17
18
  *
18
- * Part name | Description
19
- * ---|---
20
- * `row` | File container
21
- * `info` | Container for file status icon, file name, status and error messages
22
- * `done-icon` | File done status icon
23
- * `warning-icon` | File warning status icon
24
- * `meta` | Container for file name, status and error messages
25
- * `name` | File name
26
- * `error` | Error message, shown when error happens
27
- * `status` | Status message
28
- * `commands` | Container for file command icons
29
- * `start-button` | Start file upload button
30
- * `retry-button` | Retry file upload button
31
- * `remove-button` | Remove file button
32
- * `progress`| Progress bar
19
+ * Part name | Description
20
+ * -----------------|-------------
21
+ * `row` | File container
22
+ * `info` | Container for file status icon, file name, status and error messages
23
+ * `done-icon` | File done status icon
24
+ * `warning-icon` | File warning status icon
25
+ * `meta` | Container for file name, status and error messages
26
+ * `name` | File name
27
+ * `error` | Error message, shown when error happens
28
+ * `status` | Status message
29
+ * `commands` | Container for file command buttons
30
+ * `start-button` | Start file upload button
31
+ * `retry-button` | Retry file upload button
32
+ * `remove-button` | Remove file button
33
+ * `progress` | Progress bar
33
34
  *
34
35
  * The following state attributes are available for styling:
35
36
  *
36
- * Attribute | Description | Part name
37
- * ---|---|---
38
- * `error` | An error has happened during uploading | `:host`
39
- * `indeterminate` | Uploading is in progress, but the progress value is unknown | `:host`
40
- * `uploading` | Uploading is in progress | `:host`
41
- * `complete` | Uploading has finished successfully | `:host`
37
+ * Attribute | Description
38
+ * -----------------|-------------
39
+ * `focus-ring` | Set when the element is focused using the keyboard.
40
+ * `focused` | Set when the element is focused.
41
+ * `error` | An error has happened during uploading.
42
+ * `indeterminate` | Uploading is in progress, but the progress value is unknown.
43
+ * `uploading` | Uploading is in progress.
44
+ * `complete` | Uploading has finished successfully.
42
45
  *
43
46
  * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
44
47
  *
48
+ * @extends HTMLElement
49
+ * @mixes FocusMixin
45
50
  * @mixes ThemableMixin
46
51
  */
47
- class UploadFile extends ThemableMixin(PolymerElement) {
52
+ class UploadFile extends FocusMixin(ThemableMixin(PolymerElement)) {
48
53
  static get template() {
49
54
  return html`
50
55
  <style>
@@ -129,7 +134,17 @@ class UploadFile extends ThemableMixin(PolymerElement) {
129
134
  return {
130
135
  file: Object,
131
136
 
132
- i18n: Object
137
+ i18n: Object,
138
+
139
+ /**
140
+ * Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
141
+ * @protected
142
+ */
143
+ tabindex: {
144
+ type: Number,
145
+ value: 0,
146
+ reflectToAttribute: true
147
+ }
133
148
  };
134
149
  }
135
150
 
@@ -143,6 +158,38 @@ class UploadFile extends ThemableMixin(PolymerElement) {
143
158
  ];
144
159
  }
145
160
 
161
+ /** @protected */
162
+ ready() {
163
+ super.ready();
164
+
165
+ // Handle moving focus to the button on Tab.
166
+ this.shadowRoot.addEventListener('focusin', (e) => {
167
+ const target = e.composedPath()[0];
168
+
169
+ if (target.getAttribute('part').endsWith('button')) {
170
+ this._setFocused(false);
171
+ }
172
+ });
173
+
174
+ // Handle moving focus from the button on Shift Tab.
175
+ this.shadowRoot.addEventListener('focusout', (e) => {
176
+ if (e.relatedTarget === this) {
177
+ this._setFocused(true);
178
+ }
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Override method inherited from `FocusMixin` to mark the file as focused
184
+ * only when the host is focused.
185
+ * @param {Event} event
186
+ * @return {boolean}
187
+ * @protected
188
+ */
189
+ _shouldSetFocus(event) {
190
+ return event.composedPath()[0] === this;
191
+ }
192
+
146
193
  /** @private */
147
194
  _fileAborted(abort) {
148
195
  if (abort) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  const $_documentContainer = document.createElement('template');
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import '@polymer/polymer/lib/elements/dom-repeat.js';
7
7
  import '@vaadin/button/src/vaadin-button.js';
8
8
  import './vaadin-upload-icons.js';
9
9
  import './vaadin-upload-file.js';
10
- import { resetMouseCanceller } from '@polymer/polymer/lib/utils/gestures.js';
11
10
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
12
11
  import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
13
12
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -95,7 +94,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
95
94
  </vaadin-button>
96
95
  </slot>
97
96
  </div>
98
- <div part="drop-label" hidden$="[[nodrop]]" id="dropLabelContainer">
97
+ <div part="drop-label" hidden$="[[nodrop]]" id="dropLabelContainer" aria-hidden="true">
99
98
  <slot name="drop-label-icon">
100
99
  <div part="drop-label-icon"></div>
101
100
  </slot>
@@ -106,7 +105,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
106
105
  <ul id="fileList" part="file-list">
107
106
  <template is="dom-repeat" items="[[files]]" as="file">
108
107
  <li>
109
- <vaadin-upload-file tabindex="0" file="[[file]]" i18n="[[i18n]]"></vaadin-upload-file>
108
+ <vaadin-upload-file file="[[file]]" i18n="[[i18n]]"></vaadin-upload-file>
110
109
  </li>
111
110
  </template>
112
111
  </ul>
@@ -456,7 +455,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
456
455
  const base = this.i18n.units.sizeBase || 1000;
457
456
  const unit = ~~(Math.log(bytes) / Math.log(base));
458
457
  const dec = Math.max(0, Math.min(3, unit - 1));
459
- const size = parseFloat((bytes / Math.pow(base, unit)).toFixed(dec));
458
+ const size = parseFloat((bytes / base ** unit).toFixed(dec));
460
459
  return size + ' ' + this.i18n.units.size[unit];
461
460
  }
462
461
 
@@ -748,7 +747,7 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
748
747
  /** @private */
749
748
  _notifyFileChanges(file) {
750
749
  var p = 'files.' + this.files.indexOf(file) + '.';
751
- for (let i in file) {
750
+ for (const i in file) {
752
751
  // eslint-disable-next-line no-prototype-builtins
753
752
  if (file.hasOwnProperty(i)) {
754
753
  this.notifyPath(p + i, file[i]);
@@ -819,18 +818,9 @@ class Upload extends ElementMixin(ThemableMixin(PolymerElement)) {
819
818
  _onAddFilesTouchEnd(e) {
820
819
  // Cancel the event to avoid the following click event
821
820
  e.preventDefault();
822
- // FIXME(platosha): workaround for Polymer Gestures mouseCanceller
823
- // cancelling the following synthetic click. See also:
824
- // https://github.com/Polymer/polymer/issues/5289
825
- this.__resetMouseCanceller();
826
821
  this._onAddFilesClick(e);
827
822
  }
828
823
 
829
- /** @private */
830
- __resetMouseCanceller() {
831
- resetMouseCanceller();
832
- }
833
-
834
824
  /** @private */
835
825
  _onAddFilesClick(e) {
836
826
  if (this.maxFilesReached) {
@@ -73,13 +73,10 @@ registerStyles(
73
73
  const uploadFile = css`
74
74
  :host {
75
75
  padding: var(--lumo-space-s) 0;
76
- }
77
-
78
- :host(:focus) {
79
76
  outline: none;
80
77
  }
81
78
 
82
- :host(:focus) [part='row'] {
79
+ :host([focus-ring]) [part='row'] {
83
80
  border-radius: var(--lumo-border-radius-s);
84
81
  box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
85
82
  }
@@ -99,6 +99,10 @@ registerStyles(
99
99
  registerStyles(
100
100
  'vaadin-upload-file',
101
101
  css`
102
+ :host {
103
+ outline: none;
104
+ }
105
+
102
106
  [part='row'] {
103
107
  display: flex;
104
108
  align-items: flex-start;
@@ -106,11 +110,7 @@ registerStyles(
106
110
  padding: 8px;
107
111
  }
108
112
 
109
- :host(:focus) {
110
- outline: none;
111
- }
112
-
113
- :host(:focus) [part='row'] {
113
+ :host([focus-ring]) [part='row'] {
114
114
  background-color: var(--material-divider-color);
115
115
  }
116
116