@vaadin/notification 22.0.2 → 23.0.0-alpha4

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/notification",
3
- "version": "22.0.2",
3
+ "version": "23.0.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-notification.js",
20
20
  "module": "vaadin-notification.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -33,18 +34,18 @@
33
34
  ],
34
35
  "dependencies": {
35
36
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/component-base": "^22.0.2",
37
- "@vaadin/vaadin-lumo-styles": "^22.0.2",
38
- "@vaadin/vaadin-material-styles": "^22.0.2",
39
- "@vaadin/vaadin-themable-mixin": "^22.0.2",
37
+ "@vaadin/component-base": "23.0.0-alpha4",
38
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha4",
39
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha4",
40
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha4",
40
41
  "lit": "^2.0.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@esm-bundle/chai": "^4.3.4",
44
- "@vaadin/button": "^22.0.2",
45
- "@vaadin/polymer-legacy-adapter": "^22.0.2",
45
+ "@vaadin/button": "23.0.0-alpha4",
46
+ "@vaadin/polymer-legacy-adapter": "23.0.0-alpha4",
46
47
  "@vaadin/testing-helpers": "^0.3.2",
47
48
  "sinon": "^9.2.1"
48
49
  },
49
- "gitHead": "df21370c4a655a38eac11f79686021ab3b0887ad"
50
+ "gitHead": "81e2deee5147bb7c1f4884760f4598613306f1fb"
50
51
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { TemplateResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
@@ -114,12 +114,14 @@ class NotificationContainer extends ThemableMixin(ElementMixin(PolymerElement))
114
114
  _openedChanged(opened) {
115
115
  if (opened) {
116
116
  document.body.appendChild(this);
117
+ document.addEventListener('vaadin-overlay-close', this._boundVaadinOverlayClose);
117
118
  if (this._boundIosResizeListener) {
118
119
  this._detectIosNavbar();
119
120
  window.addEventListener('resize', this._boundIosResizeListener);
120
121
  }
121
122
  } else {
122
123
  document.body.removeChild(this);
124
+ document.removeEventListener('vaadin-overlay-close', this._boundVaadinOverlayClose);
123
125
  if (this._boundIosResizeListener) {
124
126
  window.removeEventListener('resize', this._boundIosResizeListener);
125
127
  }
@@ -129,6 +131,7 @@ class NotificationContainer extends ThemableMixin(ElementMixin(PolymerElement))
129
131
  constructor() {
130
132
  super();
131
133
 
134
+ this._boundVaadinOverlayClose = this._onVaadinOverlayClose.bind(this);
132
135
  if (isIOS) {
133
136
  this._boundIosResizeListener = () => this._detectIosNavbar();
134
137
  }
@@ -146,6 +149,17 @@ class NotificationContainer extends ThemableMixin(ElementMixin(PolymerElement))
146
149
  this.style.bottom = '0';
147
150
  }
148
151
  }
152
+
153
+ /** @private */
154
+ _onVaadinOverlayClose(event) {
155
+ // Notifications are a separate overlay mechanism from vaadin-overlay, and
156
+ // interacting with them should not close modal overlays
157
+ const sourceEvent = event.detail.sourceEvent;
158
+ const isFromNotification = sourceEvent && sourceEvent.composedPath().indexOf(this) >= 0;
159
+ if (isFromNotification) {
160
+ event.preventDefault();
161
+ }
162
+ }
149
163
  }
150
164
 
151
165
  /**
@@ -321,7 +335,9 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
321
335
  * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
322
336
  */
323
337
  requestContentUpdate() {
324
- if (!this.renderer) return;
338
+ if (!this.renderer) {
339
+ return;
340
+ }
325
341
 
326
342
  this.renderer(this._card, this);
327
343
  }
@@ -490,11 +506,10 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
490
506
  return Notification._createAndShowNotification((root) => {
491
507
  render(contents, root);
492
508
  }, options);
493
- } else {
494
- return Notification._createAndShowNotification((root) => {
495
- root.innerText = contents;
496
- }, options);
497
509
  }
510
+ return Notification._createAndShowNotification((root) => {
511
+ root.innerText = contents;
512
+ }, options);
498
513
  }
499
514
 
500
515
  /** @private */