@vaadin/upload 24.0.0-alpha6 → 24.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": "24.0.0-alpha6",
3
+ "version": "24.0.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,16 +36,16 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/button": "24.0.0-alpha6",
40
- "@vaadin/component-base": "24.0.0-alpha6",
41
- "@vaadin/progress-bar": "24.0.0-alpha6",
42
- "@vaadin/vaadin-lumo-styles": "24.0.0-alpha6",
43
- "@vaadin/vaadin-material-styles": "24.0.0-alpha6",
44
- "@vaadin/vaadin-themable-mixin": "24.0.0-alpha6"
39
+ "@vaadin/button": "24.0.0-alpha8",
40
+ "@vaadin/component-base": "24.0.0-alpha8",
41
+ "@vaadin/progress-bar": "24.0.0-alpha8",
42
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha8",
43
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha8",
44
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha8"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/form-layout": "24.0.0-alpha6",
48
+ "@vaadin/form-layout": "24.0.0-alpha8",
49
49
  "@vaadin/testing-helpers": "^0.3.2",
50
50
  "sinon": "^13.0.2"
51
51
  },
@@ -53,5 +53,5 @@
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "0004ac92b6e5f415b5fa949e0582d1d11e527b1f"
56
+ "gitHead": "476752249bb12295c500980d98a3256ad3b22b73"
57
57
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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-upload-file.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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 template = document.createElement('template');
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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 { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2016 - 2023 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';
@@ -16,6 +16,59 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
16
16
  import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
17
17
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
18
18
 
19
+ class AddButtonController extends SlotController {
20
+ constructor(host) {
21
+ super(host, 'add-button', 'vaadin-button');
22
+ }
23
+
24
+ /**
25
+ * Override method inherited from `SlotController`
26
+ * to add listeners to default and custom node.
27
+ *
28
+ * @param {Node} node
29
+ * @protected
30
+ * @override
31
+ */
32
+ initNode(node) {
33
+ // Needed by Flow counterpart to apply i18n to custom button
34
+ if (node._isDefault) {
35
+ this.defaultNode = node;
36
+ }
37
+
38
+ node.addEventListener('touchend', (e) => {
39
+ this.host._onAddFilesTouchEnd(e);
40
+ });
41
+
42
+ node.addEventListener('click', (e) => {
43
+ this.host._onAddFilesClick(e);
44
+ });
45
+
46
+ this.host._addButton = node;
47
+ }
48
+ }
49
+
50
+ class DropLabelController extends SlotController {
51
+ constructor(host) {
52
+ super(host, 'drop-label', 'span');
53
+ }
54
+
55
+ /**
56
+ * Override method inherited from `SlotController`
57
+ * to add listeners to default and custom node.
58
+ *
59
+ * @param {Node} node
60
+ * @protected
61
+ * @override
62
+ */
63
+ initNode(node) {
64
+ // Needed by Flow counterpart to apply i18n to custom label
65
+ if (node._isDefault) {
66
+ this.defaultNode = node;
67
+ }
68
+ this.host._dropLabel = node;
69
+ }
70
+ }
71
+
19
72
  /**
20
73
  * `<vaadin-upload>` is a Web Component for uploading multiple files with drag and drop support.
21
74
  *
@@ -453,27 +506,11 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
453
506
  this.addEventListener('upload-success', this._onUploadSuccess.bind(this));
454
507
  this.addEventListener('upload-error', this._onUploadError.bind(this));
455
508
 
456
- this.addController(
457
- new SlotController(this, 'add-button', 'vaadin-button', {
458
- initializer: (button) => {
459
- button.addEventListener('touchend', (e) => {
460
- this._onAddFilesTouchEnd(e);
461
- });
462
- button.addEventListener('click', (e) => {
463
- this._onAddFilesClick(e);
464
- });
465
- this._addButton = button;
466
- },
467
- }),
468
- );
509
+ this._addButtonController = new AddButtonController(this);
510
+ this.addController(this._addButtonController);
469
511
 
470
- this.addController(
471
- new SlotController(this, 'drop-label', 'span', {
472
- initializer: (label) => {
473
- this._dropLabel = label;
474
- },
475
- }),
476
- );
512
+ this._dropLabelController = new DropLabelController(this);
513
+ this.addController(this._dropLabelController);
477
514
 
478
515
  this.addController(
479
516
  new SlotController(this, 'file-list', 'vaadin-upload-file-list', {
@@ -551,13 +588,18 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
551
588
  __updateAddButton(addButton, maxFiles, i18n, maxFilesReached) {
552
589
  if (addButton) {
553
590
  addButton.disabled = maxFilesReached;
554
- addButton.textContent = this._i18nPlural(maxFiles, i18n.addFiles);
591
+
592
+ // Only update text content for the default button element
593
+ if (addButton === this._addButtonController.defaultNode) {
594
+ addButton.textContent = this._i18nPlural(maxFiles, i18n.addFiles);
595
+ }
555
596
  }
556
597
  }
557
598
 
558
599
  /** @private */
559
600
  __updateDropLabel(dropLabel, maxFiles, i18n) {
560
- if (dropLabel) {
601
+ // Only update text content for the default label element
602
+ if (dropLabel && dropLabel === this._dropLabelController.defaultNode) {
561
603
  dropLabel.textContent = this._i18nPlural(maxFiles, i18n.dropFiles);
562
604
  }
563
605
  }
@@ -637,11 +679,10 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
637
679
  *
638
680
  * @param {!UploadFile | !Array<!UploadFile>=} files - Files being uploaded. Defaults to all outstanding files
639
681
  */
640
- uploadFiles(files) {
682
+ uploadFiles(files = this.files) {
641
683
  if (files && !Array.isArray(files)) {
642
684
  files = [files];
643
685
  }
644
- files = files || this.files;
645
686
  files = files.filter((file) => !file.complete);
646
687
  Array.prototype.forEach.call(files, this._uploadFile.bind(this));
647
688
  }
@@ -838,11 +879,11 @@ class Upload extends ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))
838
879
  );
839
880
  return;
840
881
  }
841
- const fileExt = file.name.match(/\.[^.]*$|$/)[0];
882
+ const fileExt = file.name.match(/\.[^.]*$|$/u)[0];
842
883
  // Escape regex operators common to mime types
843
- const escapedAccept = this.accept.replace(/[+.]/g, '\\$&');
884
+ const escapedAccept = this.accept.replace(/[+.]/gu, '\\$&');
844
885
  // Create accept regex that can match comma separated patterns, star (*) wildcards
845
- const re = new RegExp(`^(${escapedAccept.replace(/[, ]+/g, '|').replace(/\/\*/g, '/.*')})$`, 'i');
886
+ const re = new RegExp(`^(${escapedAccept.replace(/[, ]+/gu, '|').replace(/\/\*/gu, '/.*')})$`, 'iu');
846
887
  if (this.accept && !(re.test(file.type) || re.test(fileExt))) {
847
888
  this.dispatchEvent(
848
889
  new CustomEvent('file-reject', {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/upload",
4
- "version": "24.0.0-alpha6",
4
+ "version": "24.0.0-alpha8",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/upload",
4
- "version": "24.0.0-alpha6",
4
+ "version": "24.0.0-alpha8",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {