@vaadin/notification 23.1.0-beta3 → 23.1.0-rc2

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": "23.1.0-beta3",
3
+ "version": "23.1.0-rc2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,19 +36,19 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/component-base": "23.1.0-beta3",
40
- "@vaadin/lit-renderer": "23.1.0-beta3",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-beta3",
42
- "@vaadin/vaadin-material-styles": "23.1.0-beta3",
43
- "@vaadin/vaadin-themable-mixin": "23.1.0-beta3",
39
+ "@vaadin/component-base": "23.1.0-rc2",
40
+ "@vaadin/lit-renderer": "23.1.0-rc2",
41
+ "@vaadin/vaadin-lumo-styles": "23.1.0-rc2",
42
+ "@vaadin/vaadin-material-styles": "23.1.0-rc2",
43
+ "@vaadin/vaadin-themable-mixin": "23.1.0-rc2",
44
44
  "lit": "^2.0.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/button": "23.1.0-beta3",
49
- "@vaadin/polymer-legacy-adapter": "23.1.0-beta3",
48
+ "@vaadin/button": "23.1.0-rc2",
49
+ "@vaadin/polymer-legacy-adapter": "23.1.0-rc2",
50
50
  "@vaadin/testing-helpers": "^0.3.2",
51
51
  "sinon": "^13.0.2"
52
52
  },
53
- "gitHead": "c787ceb8a312f88631c6d429ff320d5f89b1b838"
53
+ "gitHead": "154c6782c42145fed21e443559fbe2d781ad3ec7"
54
54
  }
@@ -100,6 +100,29 @@ declare class NotificationCard extends ThemableMixin(HTMLElement) {}
100
100
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
101
101
  */
102
102
  declare class Notification extends ThemePropertyMixin(ElementMixin(HTMLElement)) {
103
+ /**
104
+ * Shows a notification with the given content.
105
+ * By default, positions the notification at `bottom-start` and uses a 5 second duration.
106
+ * An options object can be passed to configure the notification.
107
+ * The options object has the following structure:
108
+ *
109
+ * ```
110
+ * {
111
+ * position?: string
112
+ * duration?: number
113
+ * theme?: string
114
+ * }
115
+ * ```
116
+ *
117
+ * See the individual documentation for:
118
+ * - [`position`](#/elements/vaadin-notification#property-position)
119
+ * - [`duration`](#/elements/vaadin-notification#property-duration)
120
+ *
121
+ * @param contents the contents to show, either as a string or a Lit template.
122
+ * @param options optional options for customizing the notification.
123
+ */
124
+ static show(contents: string | TemplateResult, options?: ShowOptions): Notification;
125
+
103
126
  /**
104
127
  * The duration in milliseconds to show the notification.
105
128
  * Set to `0` or a negative number to disable the notification auto-closing.
@@ -156,29 +179,6 @@ declare class Notification extends ThemePropertyMixin(ElementMixin(HTMLElement))
156
179
  listener: (this: Notification, ev: NotificationEventMap[K]) => void,
157
180
  options?: boolean | EventListenerOptions,
158
181
  ): void;
159
-
160
- /**
161
- * Shows a notification with the given content.
162
- * By default, positions the notification at `bottom-start` and uses a 5 second duration.
163
- * An options object can be passed to configure the notification.
164
- * The options object has the following structure:
165
- *
166
- * ```
167
- * {
168
- * position?: string
169
- * duration?: number
170
- * theme?: string
171
- * }
172
- * ```
173
- *
174
- * See the individual documentation for:
175
- * - [`position`](#/elements/vaadin-notification#property-position)
176
- * - [`duration`](#/elements/vaadin-notification#property-duration)
177
- *
178
- * @param contents the contents to show, either as a string or a Lit template.
179
- * @param options optional options for customizing the notification.
180
- */
181
- static show(contents: string | TemplateResult, options?: ShowOptions): Notification;
182
182
  }
183
183
 
184
184
  declare global {
@@ -110,6 +110,15 @@ class NotificationContainer extends ThemableMixin(ElementMixin(PolymerElement))
110
110
  };
111
111
  }
112
112
 
113
+ constructor() {
114
+ super();
115
+
116
+ this._boundVaadinOverlayClose = this._onVaadinOverlayClose.bind(this);
117
+ if (isIOS) {
118
+ this._boundIosResizeListener = () => this._detectIosNavbar();
119
+ }
120
+ }
121
+
113
122
  /** @private */
114
123
  _openedChanged(opened) {
115
124
  if (opened) {
@@ -128,15 +137,6 @@ class NotificationContainer extends ThemableMixin(ElementMixin(PolymerElement))
128
137
  }
129
138
  }
130
139
 
131
- constructor() {
132
- super();
133
-
134
- this._boundVaadinOverlayClose = this._onVaadinOverlayClose.bind(this);
135
- if (isIOS) {
136
- this._boundIosResizeListener = () => this._detectIosNavbar();
137
- }
138
- }
139
-
140
140
  /** @private */
141
141
  _detectIosNavbar() {
142
142
  const innerHeight = window.innerHeight;
@@ -319,6 +319,63 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
319
319
  return ['_durationChanged(duration, opened)', '_rendererChanged(renderer, opened, _card)'];
320
320
  }
321
321
 
322
+ /**
323
+ * Shows a notification with the given content.
324
+ * By default, positions the notification at `bottom-start` and uses a 5 second duration.
325
+ * An options object can be passed to configure the notification.
326
+ * The options object has the following structure:
327
+ *
328
+ * ```
329
+ * {
330
+ * position?: string
331
+ * duration?: number
332
+ * theme?: string
333
+ * }
334
+ * ```
335
+ *
336
+ * See the individual documentation for:
337
+ * - [`position`](#/elements/vaadin-notification#property-position)
338
+ * - [`duration`](#/elements/vaadin-notification#property-duration)
339
+ *
340
+ * @param contents the contents to show, either as a string or a Lit template.
341
+ * @param options optional options for customizing the notification.
342
+ */
343
+ static show(contents, options) {
344
+ if (isTemplateResult(contents)) {
345
+ return Notification._createAndShowNotification((root) => {
346
+ render(contents, root);
347
+ }, options);
348
+ }
349
+ return Notification._createAndShowNotification((root) => {
350
+ root.innerText = contents;
351
+ }, options);
352
+ }
353
+
354
+ /** @private */
355
+ static _createAndShowNotification(renderer, options) {
356
+ const notification = document.createElement(Notification.is);
357
+ if (options && Number.isFinite(options.duration)) {
358
+ notification.duration = options.duration;
359
+ }
360
+ if (options && options.position) {
361
+ notification.position = options.position;
362
+ }
363
+ if (options && options.theme) {
364
+ notification.setAttribute('theme', options.theme);
365
+ }
366
+ notification.renderer = renderer;
367
+ document.body.appendChild(notification);
368
+ notification.opened = true;
369
+
370
+ notification.addEventListener('opened-changed', (e) => {
371
+ if (!e.detail.value) {
372
+ notification.remove();
373
+ }
374
+ });
375
+
376
+ return notification;
377
+ }
378
+
322
379
  /** @protected */
323
380
  ready() {
324
381
  super.ready();
@@ -489,63 +546,6 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
489
546
  }
490
547
  }
491
548
  }
492
-
493
- /**
494
- * Shows a notification with the given content.
495
- * By default, positions the notification at `bottom-start` and uses a 5 second duration.
496
- * An options object can be passed to configure the notification.
497
- * The options object has the following structure:
498
- *
499
- * ```
500
- * {
501
- * position?: string
502
- * duration?: number
503
- * theme?: string
504
- * }
505
- * ```
506
- *
507
- * See the individual documentation for:
508
- * - [`position`](#/elements/vaadin-notification#property-position)
509
- * - [`duration`](#/elements/vaadin-notification#property-duration)
510
- *
511
- * @param contents the contents to show, either as a string or a Lit template.
512
- * @param options optional options for customizing the notification.
513
- */
514
- static show(contents, options) {
515
- if (isTemplateResult(contents)) {
516
- return Notification._createAndShowNotification((root) => {
517
- render(contents, root);
518
- }, options);
519
- }
520
- return Notification._createAndShowNotification((root) => {
521
- root.innerText = contents;
522
- }, options);
523
- }
524
-
525
- /** @private */
526
- static _createAndShowNotification(renderer, options) {
527
- const notification = document.createElement(Notification.is);
528
- if (options && Number.isFinite(options.duration)) {
529
- notification.duration = options.duration;
530
- }
531
- if (options && options.position) {
532
- notification.position = options.position;
533
- }
534
- if (options && options.theme) {
535
- notification.setAttribute('theme', options.theme);
536
- }
537
- notification.renderer = renderer;
538
- document.body.appendChild(notification);
539
- notification.opened = true;
540
-
541
- notification.addEventListener('opened-changed', (e) => {
542
- if (!e.detail.value) {
543
- notification.remove();
544
- }
545
- });
546
-
547
- return notification;
548
- }
549
549
  }
550
550
 
551
551
  customElements.define(NotificationContainer.is, NotificationContainer);