@vaadin/notification 22.0.0-alpha7 → 22.0.0-beta2

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-notification>
1
+ # @vaadin/notification
2
2
 
3
- [Live Demo ↗](https://vaadin.com/components/vaadin-notification/html-examples)
4
- |
5
- [API documentation ↗](https://vaadin.com/components/vaadin-notification/html-api)
3
+ A web component for providing feedback to the user.
6
4
 
7
- [<vaadin-notification>](https://vaadin.com/components/vaadin-notification) is a Web Component providing accessible and customizable notifications (toasts), part of the [Vaadin components](https://vaadin.com/components).
5
+ [Documentation + Live Demo ](https://vaadin.com/docs/latest/ds/components/notification)
8
6
 
9
7
  [![npm version](https://badgen.net/npm/v/@vaadin/notification)](https://www.npmjs.com/package/@vaadin/notification)
10
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-notification)
11
8
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
12
9
 
13
10
  ```html
@@ -22,41 +19,44 @@
22
19
  </script>
23
20
  ```
24
21
 
25
- [<img src="https://raw.githubusercontent.com/vaadin/vaadin-notification/master/screenshot.png" width="336" alt="Screenshot of vaadin-notification">](https://vaadin.com/components/vaadin-notification)
22
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/notification/screenshot.png" width="336" alt="Screenshot of vaadin-notification">](https://vaadin.com/docs/latest/ds/components/notification)
26
23
 
27
24
  ## Installation
28
25
 
29
- Install `vaadin-notification`:
26
+ Install the component:
30
27
 
31
28
  ```sh
32
- npm i @vaadin/notification --save
29
+ npm i @vaadin/notification
33
30
  ```
34
31
 
35
- Once installed, import it in your application:
32
+ Once installed, import the component in your application:
36
33
 
37
34
  ```js
38
- import '@vaadin/notification/vaadin-notification.js';
35
+ import '@vaadin/notification';
39
36
  ```
40
37
 
41
- ## Getting started
38
+ ## Themes
42
39
 
43
- Vaadin components use the Lumo theme by default.
40
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
41
+ The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/notification/vaadin-notification.js) of the package uses the Lumo theme.
44
42
 
45
- To use the Material theme, import the correspondent file from the `theme/material` folder.
43
+ To use the Material theme, import the component from the `theme/material` folder:
46
44
 
47
- ## Entry points
48
-
49
- - The component with the Lumo theme:
50
-
51
- `theme/lumo/vaadin-notification.js`
45
+ ```js
46
+ import '@vaadin/notification/theme/material/vaadin-notification.js';
47
+ ```
52
48
 
53
- - The component with the Material theme:
49
+ You can also import the Lumo version of the component explicitly:
54
50
 
55
- `theme/material/vaadin-notification.js`
51
+ ```js
52
+ import '@vaadin/notification/theme/lumo/vaadin-notification.js';
53
+ ```
56
54
 
57
- - Alias for `theme/lumo/vaadin-notification.js`:
55
+ Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
58
56
 
59
- - `vaadin-notification.js`
57
+ ```js
58
+ import '@vaadin/notification/src/vaadin-notification.js';
59
+ ```
60
60
 
61
61
  ## Contributing
62
62
 
@@ -66,4 +66,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
66
66
 
67
67
  Apache License 2.0
68
68
 
69
- Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
69
+ Vaadin collects usage statistics at development time to improve this product.
70
+ 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/notification",
3
- "version": "22.0.0-alpha7",
3
+ "version": "22.0.0-beta2",
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/component-base": "22.0.0-alpha7",
37
- "@vaadin/vaadin-lumo-styles": "22.0.0-alpha7",
38
- "@vaadin/vaadin-material-styles": "22.0.0-alpha7",
39
- "@vaadin/vaadin-themable-mixin": "22.0.0-alpha7",
36
+ "@vaadin/component-base": "22.0.0-beta2",
37
+ "@vaadin/vaadin-lumo-styles": "22.0.0-beta2",
38
+ "@vaadin/vaadin-material-styles": "22.0.0-beta2",
39
+ "@vaadin/vaadin-themable-mixin": "22.0.0-beta2",
40
40
  "lit": "^2.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@esm-bundle/chai": "^4.3.4",
44
- "@vaadin/button": "22.0.0-alpha7",
45
- "@vaadin/polymer-legacy-adapter": "22.0.0-alpha7",
44
+ "@vaadin/button": "22.0.0-beta2",
45
+ "@vaadin/polymer-legacy-adapter": "22.0.0-beta2",
46
46
  "@vaadin/testing-helpers": "^0.3.0",
47
47
  "sinon": "^9.2.1"
48
48
  },
49
- "gitHead": "8e89419c6b44a1d225d5859e180d7b35e47ddb52"
49
+ "gitHead": "f13833683e6667f6ca6678452db14aa6b7eac4a4"
50
50
  }
@@ -1,8 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
1
6
  import { TemplateResult } from 'lit';
2
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
3
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
9
  import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
5
- import { NotificationEventMap, NotificationPosition, NotificationRenderer, ShowOptions } from './interfaces';
10
+
11
+ export type NotificationPosition =
12
+ | 'top-stretch'
13
+ | 'top-start'
14
+ | 'top-center'
15
+ | 'top-end'
16
+ | 'middle'
17
+ | 'bottom-start'
18
+ | 'bottom-center'
19
+ | 'bottom-end'
20
+ | 'bottom-stretch';
21
+
22
+ export type NotificationRenderer = (root: HTMLElement, notification?: Notification) => void;
23
+
24
+ /**
25
+ * Fired when the `opened` property changes.
26
+ */
27
+ export type NotificationOpenedChangedEvent = CustomEvent<{ value: boolean }>;
28
+
29
+ export interface NotificationCustomEventMap {
30
+ 'opened-changed': NotificationOpenedChangedEvent;
31
+ }
32
+
33
+ export interface NotificationEventMap extends HTMLElementEventMap, NotificationCustomEventMap {}
34
+
35
+ export interface ShowOptions {
36
+ duration?: number;
37
+ position?: NotificationPosition;
38
+ theme?: string;
39
+ }
6
40
 
7
41
  /**
8
42
  * An element used internally by `<vaadin-notification>`. Not intended to be used separately.
@@ -101,13 +135,6 @@ declare class Notification extends ThemePropertyMixin(ElementMixin(HTMLElement))
101
135
  */
102
136
  requestContentUpdate(): void;
103
137
 
104
- /**
105
- * Manually invoke existing renderer.
106
- *
107
- * @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
108
- */
109
- render(): void;
110
-
111
138
  /**
112
139
  * Opens the notification.
113
140
  */
@@ -140,6 +167,7 @@ declare class Notification extends ThemePropertyMixin(ElementMixin(HTMLElement))
140
167
  * {
141
168
  * position?: string
142
169
  * duration?: number
170
+ * theme?: string
143
171
  * }
144
172
  * ```
145
173
  *
@@ -3,7 +3,7 @@
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';
6
+ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
7
  import { render } from 'lit';
8
8
  import { isTemplateResult } from 'lit/directive-helpers.js';
9
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
@@ -325,17 +325,6 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
325
325
  this.renderer(this._card, this);
326
326
  }
327
327
 
328
- /**
329
- * Manually invoke existing renderer.
330
- *
331
- * @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
332
- */
333
- render() {
334
- console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');
335
-
336
- this.requestContentUpdate();
337
- }
338
-
339
328
  /** @private */
340
329
  _rendererChanged(renderer, opened, card) {
341
330
  if (!card) {
@@ -484,6 +473,7 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
484
473
  * {
485
474
  * position?: string
486
475
  * duration?: number
476
+ * theme?: string
487
477
  * }
488
478
  * ```
489
479
  *
@@ -515,6 +505,9 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
515
505
  if (options && options.position) {
516
506
  notification.position = options.position;
517
507
  }
508
+ if (options && options.theme) {
509
+ notification.setAttribute('theme', options.theme);
510
+ }
518
511
  notification.renderer = renderer;
519
512
  document.body.appendChild(notification);
520
513
  notification.opened = true;
@@ -1,8 +1,8 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-lumo-styles/color.js';
3
2
  import '@vaadin/vaadin-lumo-styles/spacing.js';
4
3
  import '@vaadin/vaadin-lumo-styles/style.js';
5
4
  import '@vaadin/vaadin-lumo-styles/typography.js';
5
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6
6
 
7
7
  registerStyles(
8
8
  'vaadin-notification-card',
@@ -1,7 +1,7 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
- import { colorDark } from '@vaadin/vaadin-material-styles/color.js';
3
1
  import '@vaadin/vaadin-material-styles/typography.js';
4
2
  import '@vaadin/vaadin-material-styles/shadow.js';
3
+ import { colorDark } from '@vaadin/vaadin-material-styles/color.js';
4
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
5
5
 
6
6
  registerStyles(
7
7
  'vaadin-notification-container',
@@ -1,2 +1 @@
1
1
  export * from './src/vaadin-notification.js';
2
- export * from './src/interfaces';
@@ -1,30 +0,0 @@
1
- import { Notification } from './vaadin-notification';
2
-
3
- export type NotificationPosition =
4
- | 'top-stretch'
5
- | 'top-start'
6
- | 'top-center'
7
- | 'top-end'
8
- | 'middle'
9
- | 'bottom-start'
10
- | 'bottom-center'
11
- | 'bottom-end'
12
- | 'bottom-stretch';
13
-
14
- export type NotificationRenderer = (root: HTMLElement, notification?: Notification) => void;
15
-
16
- /**
17
- * Fired when the `opened` property changes.
18
- */
19
- export type NotificationOpenedChangedEvent = CustomEvent<{ value: boolean }>;
20
-
21
- export interface NotificationCustomEventMap {
22
- 'opened-changed': NotificationOpenedChangedEvent;
23
- }
24
-
25
- export interface NotificationEventMap extends HTMLElementEventMap, NotificationCustomEventMap {}
26
-
27
- export interface ShowOptions {
28
- duration?: number;
29
- position?: NotificationPosition;
30
- }