@vaadin/vaadin-notification 22.0.0-alpha6 → 22.0.0-beta1
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 +23 -31
- package/src/vaadin-notification.d.ts +9 -155
- package/src/vaadin-notification.js +4 -527
- package/theme/lumo/vaadin-notification.js +1 -2
- package/theme/material/vaadin-notification.js +1 -2
- package/vaadin-notification.d.ts +0 -1
- package/src/interfaces.d.ts +0 -30
- package/theme/lumo/vaadin-notification-styles.js +0 -188
- package/theme/material/vaadin-notification-styles.js +0 -156
package/package.json
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/vaadin-notification",
|
|
3
|
-
"version": "22.0.0-
|
|
3
|
+
"version": "22.0.0-beta1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
4
7
|
"description": "vaadin-notification",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/vaadin/web-components.git",
|
|
12
|
+
"directory": "packages/vaadin-notification"
|
|
13
|
+
},
|
|
14
|
+
"author": "Vaadin Ltd",
|
|
15
|
+
"homepage": "https://vaadin.com/components",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/vaadin/vaadin-notification/issues"
|
|
18
|
+
},
|
|
5
19
|
"main": "vaadin-notification.js",
|
|
6
20
|
"module": "vaadin-notification.js",
|
|
7
|
-
"
|
|
21
|
+
"files": [
|
|
22
|
+
"src",
|
|
23
|
+
"theme",
|
|
24
|
+
"vaadin-*.d.ts",
|
|
25
|
+
"vaadin-*.js"
|
|
26
|
+
],
|
|
8
27
|
"keywords": [
|
|
9
28
|
"Vaadin",
|
|
10
29
|
"vaadin-notification",
|
|
@@ -12,35 +31,8 @@
|
|
|
12
31
|
"web-component",
|
|
13
32
|
"polymer"
|
|
14
33
|
],
|
|
15
|
-
"author": "Vaadin Ltd",
|
|
16
|
-
"license": "Apache-2.0",
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/vaadin/vaadin-notification/issues"
|
|
19
|
-
},
|
|
20
|
-
"homepage": "https://vaadin.com/components",
|
|
21
|
-
"files": [
|
|
22
|
-
"vaadin-*.d.ts",
|
|
23
|
-
"vaadin-*.js",
|
|
24
|
-
"src",
|
|
25
|
-
"theme"
|
|
26
|
-
],
|
|
27
34
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@vaadin/vaadin-element-mixin": "^22.0.0-alpha6",
|
|
30
|
-
"@vaadin/vaadin-lumo-styles": "^22.0.0-alpha6",
|
|
31
|
-
"@vaadin/vaadin-material-styles": "^22.0.0-alpha6",
|
|
32
|
-
"@vaadin/vaadin-themable-mixin": "^22.0.0-alpha6"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@esm-bundle/chai": "^4.3.4",
|
|
36
|
-
"@vaadin/button": "^22.0.0-alpha6",
|
|
37
|
-
"@vaadin/testing-helpers": "^0.3.0",
|
|
38
|
-
"@vaadin/vaadin-template-renderer": "^22.0.0-alpha6",
|
|
39
|
-
"lit": "^2.0.0-rc.1",
|
|
40
|
-
"sinon": "^9.2.1"
|
|
41
|
-
},
|
|
42
|
-
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
35
|
+
"@vaadin/notification": "22.0.0-beta1"
|
|
44
36
|
},
|
|
45
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "4cf8a9d0504994200c610e44b3676114fef49c1e"
|
|
46
38
|
}
|
|
@@ -1,164 +1,18 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
2
|
-
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
|
|
3
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
|
-
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
5
|
-
import { NotificationEventMap, NotificationPosition, NotificationRenderer, ShowOptions } from './interfaces';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
|
-
*
|
|
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/
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* True when the container is opened
|
|
13
|
-
*/
|
|
14
|
-
opened: boolean;
|
|
15
|
-
}
|
|
6
|
+
import { Notification } from '@vaadin/notification/src/vaadin-notification.js';
|
|
16
7
|
|
|
17
8
|
/**
|
|
18
|
-
*
|
|
9
|
+
* @deprecated Import `Notification` from `@vaadin/notification` instead.
|
|
19
10
|
*/
|
|
20
|
-
|
|
11
|
+
export type NotificationElement = Notification;
|
|
21
12
|
|
|
22
13
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* ### Rendering
|
|
26
|
-
*
|
|
27
|
-
* The content of the notification can be populated by using the renderer callback function.
|
|
28
|
-
*
|
|
29
|
-
* The renderer function provides `root`, `notification` arguments.
|
|
30
|
-
* Generate DOM content, append it to the `root` element and control the state
|
|
31
|
-
* of the host element by accessing `notification`. Before generating new content,
|
|
32
|
-
* users are able to check if there is already content in `root` for reusing it.
|
|
33
|
-
*
|
|
34
|
-
* ```html
|
|
35
|
-
* <vaadin-notification id="notification"></vaadin-notification>
|
|
36
|
-
* ```
|
|
37
|
-
* ```js
|
|
38
|
-
* const notification = document.querySelector('#notification');
|
|
39
|
-
* notification.renderer = function(root, notification) {
|
|
40
|
-
* root.textContent = "Your work has been saved";
|
|
41
|
-
* };
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* Renderer is called on the opening of the notification.
|
|
45
|
-
* DOM generated during the renderer call can be reused
|
|
46
|
-
* in the next renderer call and will be provided with the `root` argument.
|
|
47
|
-
* On first call it will be empty.
|
|
48
|
-
*
|
|
49
|
-
* ### Styling
|
|
50
|
-
*
|
|
51
|
-
* `<vaadin-notification>` uses `<vaadin-notification-card>` internal
|
|
52
|
-
* themable component as the actual visible notification cards.
|
|
53
|
-
*
|
|
54
|
-
* The following shadow DOM parts of the `<vaadin-notification-card>` are available for styling:
|
|
55
|
-
*
|
|
56
|
-
* Part name | Description
|
|
57
|
-
* ----------------|----------------
|
|
58
|
-
* `overlay` | The notification container
|
|
59
|
-
* `content` | The content of the notification
|
|
60
|
-
*
|
|
61
|
-
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
62
|
-
*
|
|
63
|
-
* Note: the `theme` attribute value set on `<vaadin-notification>` is
|
|
64
|
-
* propagated to the internal `<vaadin-notification-card>`.
|
|
65
|
-
*
|
|
66
|
-
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
14
|
+
* @deprecated Import `Notification` from `@vaadin/notification` instead.
|
|
67
15
|
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The duration in milliseconds to show the notification.
|
|
71
|
-
* Set to `0` or a negative number to disable the notification auto-closing.
|
|
72
|
-
*/
|
|
73
|
-
duration: number;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* True if the notification is currently displayed.
|
|
77
|
-
*/
|
|
78
|
-
opened: boolean;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Alignment of the notification in the viewport
|
|
82
|
-
* Valid values are `top-stretch|top-start|top-center|top-end|middle|bottom-start|bottom-center|bottom-end|bottom-stretch`
|
|
83
|
-
*/
|
|
84
|
-
position: NotificationPosition;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Custom function for rendering the content of the notification.
|
|
88
|
-
* Receives two arguments:
|
|
89
|
-
*
|
|
90
|
-
* - `root` The `<vaadin-notification-card>` DOM element. Append
|
|
91
|
-
* your content to it.
|
|
92
|
-
* - `notification` The reference to the `<vaadin-notification>` element.
|
|
93
|
-
*/
|
|
94
|
-
renderer: NotificationRenderer | undefined;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Requests an update for the content of the notification.
|
|
98
|
-
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
99
|
-
*
|
|
100
|
-
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
101
|
-
*/
|
|
102
|
-
requestContentUpdate(): void;
|
|
103
|
-
|
|
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
|
-
/**
|
|
112
|
-
* Opens the notification.
|
|
113
|
-
*/
|
|
114
|
-
open(): void;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Closes the notification.
|
|
118
|
-
*/
|
|
119
|
-
close(): void;
|
|
120
|
-
|
|
121
|
-
addEventListener<K extends keyof NotificationEventMap>(
|
|
122
|
-
type: K,
|
|
123
|
-
listener: (this: NotificationElement, ev: NotificationEventMap[K]) => void,
|
|
124
|
-
options?: boolean | AddEventListenerOptions
|
|
125
|
-
): void;
|
|
126
|
-
|
|
127
|
-
removeEventListener<K extends keyof NotificationEventMap>(
|
|
128
|
-
type: K,
|
|
129
|
-
listener: (this: NotificationElement, ev: NotificationEventMap[K]) => void,
|
|
130
|
-
options?: boolean | EventListenerOptions
|
|
131
|
-
): void;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Shows a notification with the given content.
|
|
135
|
-
* By default, positions the notification at `bottom-start` and uses a 5 second duration.
|
|
136
|
-
* An options object can be passed to configure the notification.
|
|
137
|
-
* The options object has the following structure:
|
|
138
|
-
*
|
|
139
|
-
* ```
|
|
140
|
-
* {
|
|
141
|
-
* position?: string
|
|
142
|
-
* duration?: number
|
|
143
|
-
* }
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* See the individual documentation for:
|
|
147
|
-
* - [`position`](#/elements/vaadin-notification#property-position)
|
|
148
|
-
* - [`duration`](#/elements/vaadin-notification#property-duration)
|
|
149
|
-
*
|
|
150
|
-
* @param contents the contents to show, either as a string or a Lit template.
|
|
151
|
-
* @param options optional options for customizing the notification.
|
|
152
|
-
*/
|
|
153
|
-
static show(contents: string | TemplateResult, options?: ShowOptions): NotificationElement;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
declare global {
|
|
157
|
-
interface HTMLElementTagNameMap {
|
|
158
|
-
'vaadin-notification-container': NotificationContainer;
|
|
159
|
-
'vaadin-notification-card': NotificationCard;
|
|
160
|
-
'vaadin-notification': NotificationElement;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
16
|
+
export const NotificationElement: typeof Notification;
|
|
163
17
|
|
|
164
|
-
export
|
|
18
|
+
export * from '@vaadin/notification/src/vaadin-notification.js';
|
|
@@ -3,534 +3,11 @@
|
|
|
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 {
|
|
7
|
-
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
|
|
8
|
-
import { processTemplates } from '@vaadin/vaadin-element-mixin/templates.js';
|
|
9
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
-
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
11
|
-
import { isTemplateResult } from 'lit/directive-helpers.js';
|
|
12
|
-
import { render } from 'lit';
|
|
6
|
+
import { Notification } from '@vaadin/notification/src/vaadin-notification.js';
|
|
13
7
|
|
|
14
8
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes ElementMixin
|
|
19
|
-
* @mixes ThemableMixin
|
|
20
|
-
* @private
|
|
9
|
+
* @deprecated Import `Notification` from `@vaadin/notification` instead.
|
|
21
10
|
*/
|
|
22
|
-
|
|
23
|
-
static get template() {
|
|
24
|
-
return html`
|
|
25
|
-
<style>
|
|
26
|
-
:host {
|
|
27
|
-
position: fixed;
|
|
28
|
-
z-index: 1000;
|
|
29
|
-
top: 0;
|
|
30
|
-
left: 0;
|
|
31
|
-
bottom: 0;
|
|
32
|
-
right: 0;
|
|
33
|
-
box-sizing: border-box;
|
|
11
|
+
export const NotificationElement = Notification;
|
|
34
12
|
|
|
35
|
-
|
|
36
|
-
flex-direction: column;
|
|
37
|
-
align-items: stretch;
|
|
38
|
-
pointer-events: none;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
[region-group] {
|
|
42
|
-
flex: 1 1 0%;
|
|
43
|
-
display: flex;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
[region-group='top'] {
|
|
47
|
-
align-items: flex-start;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[region-group='bottom'] {
|
|
51
|
-
align-items: flex-end;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
[region-group] > [region] {
|
|
55
|
-
flex: 1 1 0%;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@media (max-width: 420px) {
|
|
59
|
-
[region-group] {
|
|
60
|
-
flex-direction: column;
|
|
61
|
-
align-items: stretch;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
[region-group='top'] {
|
|
65
|
-
justify-content: flex-start;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
[region-group='bottom'] {
|
|
69
|
-
justify-content: flex-end;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[region-group] > [region] {
|
|
73
|
-
flex: initial;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
77
|
-
|
|
78
|
-
<div region="top-stretch"><slot name="top-stretch"></slot></div>
|
|
79
|
-
<div region-group="top">
|
|
80
|
-
<div region="top-start"><slot name="top-start"></slot></div>
|
|
81
|
-
<div region="top-center"><slot name="top-center"></slot></div>
|
|
82
|
-
<div region="top-end"><slot name="top-end"></slot></div>
|
|
83
|
-
</div>
|
|
84
|
-
<div region="middle"><slot name="middle"></slot></div>
|
|
85
|
-
<div region-group="bottom">
|
|
86
|
-
<div region="bottom-start"><slot name="bottom-start"></slot></div>
|
|
87
|
-
<div region="bottom-center"><slot name="bottom-center"></slot></div>
|
|
88
|
-
<div region="bottom-end"><slot name="bottom-end"></slot></div>
|
|
89
|
-
</div>
|
|
90
|
-
<div region="bottom-stretch"><slot name="bottom-stretch"></slot></div>
|
|
91
|
-
`;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static get is() {
|
|
95
|
-
return 'vaadin-notification-container';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static get properties() {
|
|
99
|
-
return {
|
|
100
|
-
/**
|
|
101
|
-
* True when the container is opened
|
|
102
|
-
* @type {boolean}
|
|
103
|
-
*/
|
|
104
|
-
opened: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
value: false,
|
|
107
|
-
observer: '_openedChanged'
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** @private */
|
|
113
|
-
_openedChanged(opened) {
|
|
114
|
-
if (opened) {
|
|
115
|
-
document.body.appendChild(this);
|
|
116
|
-
if (this._boundIosResizeListener) {
|
|
117
|
-
this._detectIosNavbar();
|
|
118
|
-
window.addEventListener('resize', this._boundIosResizeListener);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
document.body.removeChild(this);
|
|
122
|
-
if (this._boundIosResizeListener) {
|
|
123
|
-
window.removeEventListener('resize', this._boundIosResizeListener);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
constructor() {
|
|
129
|
-
super();
|
|
130
|
-
|
|
131
|
-
if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
|
|
132
|
-
this._boundIosResizeListener = () => this._detectIosNavbar();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** @private */
|
|
137
|
-
_detectIosNavbar() {
|
|
138
|
-
const innerHeight = window.innerHeight;
|
|
139
|
-
const innerWidth = window.innerWidth;
|
|
140
|
-
const landscape = innerWidth > innerHeight;
|
|
141
|
-
const clientHeight = document.documentElement.clientHeight;
|
|
142
|
-
if (landscape && clientHeight > innerHeight) {
|
|
143
|
-
this.style.bottom = clientHeight - innerHeight + 'px';
|
|
144
|
-
} else {
|
|
145
|
-
this.style.bottom = '0';
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* An element used internally by `<vaadin-notification>`. Not intended to be used separately.
|
|
152
|
-
*
|
|
153
|
-
* @extends HTMLElement
|
|
154
|
-
* @mixes ThemableMixin
|
|
155
|
-
* @private
|
|
156
|
-
*/
|
|
157
|
-
class NotificationCard extends ThemableMixin(PolymerElement) {
|
|
158
|
-
static get template() {
|
|
159
|
-
return html`
|
|
160
|
-
<style>
|
|
161
|
-
:host {
|
|
162
|
-
display: block;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
[part='overlay'] {
|
|
166
|
-
pointer-events: auto;
|
|
167
|
-
}
|
|
168
|
-
</style>
|
|
169
|
-
|
|
170
|
-
<div part="overlay">
|
|
171
|
-
<div part="content">
|
|
172
|
-
<slot></slot>
|
|
173
|
-
</div>
|
|
174
|
-
</div>
|
|
175
|
-
`;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
static get is() {
|
|
179
|
-
return 'vaadin-notification-card';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** @protected */
|
|
183
|
-
ready() {
|
|
184
|
-
super.ready();
|
|
185
|
-
this.setAttribute('role', 'alert');
|
|
186
|
-
this.setAttribute('aria-live', 'polite');
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* `<vaadin-notification>` is a Web Component providing accessible and customizable notifications (toasts).
|
|
192
|
-
*
|
|
193
|
-
* ### Rendering
|
|
194
|
-
*
|
|
195
|
-
* The content of the notification can be populated by using the renderer callback function.
|
|
196
|
-
*
|
|
197
|
-
* The renderer function provides `root`, `notification` arguments.
|
|
198
|
-
* Generate DOM content, append it to the `root` element and control the state
|
|
199
|
-
* of the host element by accessing `notification`. Before generating new content,
|
|
200
|
-
* users are able to check if there is already content in `root` for reusing it.
|
|
201
|
-
*
|
|
202
|
-
* ```html
|
|
203
|
-
* <vaadin-notification id="notification"></vaadin-notification>
|
|
204
|
-
* ```
|
|
205
|
-
* ```js
|
|
206
|
-
* const notification = document.querySelector('#notification');
|
|
207
|
-
* notification.renderer = function(root, notification) {
|
|
208
|
-
* root.textContent = "Your work has been saved";
|
|
209
|
-
* };
|
|
210
|
-
* ```
|
|
211
|
-
*
|
|
212
|
-
* Renderer is called on the opening of the notification.
|
|
213
|
-
* DOM generated during the renderer call can be reused
|
|
214
|
-
* in the next renderer call and will be provided with the `root` argument.
|
|
215
|
-
* On first call it will be empty.
|
|
216
|
-
*
|
|
217
|
-
* ### Styling
|
|
218
|
-
*
|
|
219
|
-
* `<vaadin-notification>` uses `<vaadin-notification-card>` internal
|
|
220
|
-
* themable component as the actual visible notification cards.
|
|
221
|
-
*
|
|
222
|
-
* The following shadow DOM parts of the `<vaadin-notification-card>` are available for styling:
|
|
223
|
-
*
|
|
224
|
-
* Part name | Description
|
|
225
|
-
* ----------------|----------------
|
|
226
|
-
* `overlay` | The notification container
|
|
227
|
-
* `content` | The content of the notification
|
|
228
|
-
*
|
|
229
|
-
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
230
|
-
*
|
|
231
|
-
* Note: the `theme` attribute value set on `<vaadin-notification>` is
|
|
232
|
-
* propagated to the internal `<vaadin-notification-card>`.
|
|
233
|
-
*
|
|
234
|
-
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
235
|
-
*
|
|
236
|
-
* @extends HTMLElement
|
|
237
|
-
* @mixes ThemePropertyMixin
|
|
238
|
-
* @mixes ElementMixin
|
|
239
|
-
*/
|
|
240
|
-
class NotificationElement extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
241
|
-
static get template() {
|
|
242
|
-
return html`
|
|
243
|
-
<style>
|
|
244
|
-
:host {
|
|
245
|
-
display: none;
|
|
246
|
-
}
|
|
247
|
-
</style>
|
|
248
|
-
<vaadin-notification-card theme$="[[theme]]"> </vaadin-notification-card>
|
|
249
|
-
`;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
static get is() {
|
|
253
|
-
return 'vaadin-notification';
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
static get properties() {
|
|
257
|
-
return {
|
|
258
|
-
/**
|
|
259
|
-
* The duration in milliseconds to show the notification.
|
|
260
|
-
* Set to `0` or a negative number to disable the notification auto-closing.
|
|
261
|
-
* @type {number}
|
|
262
|
-
*/
|
|
263
|
-
duration: {
|
|
264
|
-
type: Number,
|
|
265
|
-
value: 5000
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* True if the notification is currently displayed.
|
|
270
|
-
* @type {boolean}
|
|
271
|
-
*/
|
|
272
|
-
opened: {
|
|
273
|
-
type: Boolean,
|
|
274
|
-
value: false,
|
|
275
|
-
notify: true,
|
|
276
|
-
observer: '_openedChanged'
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Alignment of the notification in the viewport
|
|
281
|
-
* Valid values are `top-stretch|top-start|top-center|top-end|middle|bottom-start|bottom-center|bottom-end|bottom-stretch`
|
|
282
|
-
* @type {!NotificationPosition}
|
|
283
|
-
*/
|
|
284
|
-
position: {
|
|
285
|
-
type: String,
|
|
286
|
-
value: 'bottom-start',
|
|
287
|
-
observer: '_positionChanged'
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Custom function for rendering the content of the notification.
|
|
292
|
-
* Receives two arguments:
|
|
293
|
-
*
|
|
294
|
-
* - `root` The `<vaadin-notification-card>` DOM element. Append
|
|
295
|
-
* your content to it.
|
|
296
|
-
* - `notification` The reference to the `<vaadin-notification>` element.
|
|
297
|
-
* @type {!NotificationRenderer | undefined}
|
|
298
|
-
*/
|
|
299
|
-
renderer: Function
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
static get observers() {
|
|
304
|
-
return ['_durationChanged(duration, opened)', '_rendererChanged(renderer, opened, _card)'];
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/** @protected */
|
|
308
|
-
ready() {
|
|
309
|
-
super.ready();
|
|
310
|
-
|
|
311
|
-
this._card = this.shadowRoot.querySelector('vaadin-notification-card');
|
|
312
|
-
|
|
313
|
-
processTemplates(this);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Requests an update for the content of the notification.
|
|
318
|
-
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
319
|
-
*
|
|
320
|
-
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
321
|
-
*/
|
|
322
|
-
requestContentUpdate() {
|
|
323
|
-
if (!this.renderer) return;
|
|
324
|
-
|
|
325
|
-
this.renderer(this._card, this);
|
|
326
|
-
}
|
|
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
|
-
/** @private */
|
|
340
|
-
_rendererChanged(renderer, opened, card) {
|
|
341
|
-
if (!card) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const rendererChanged = this._oldRenderer !== renderer;
|
|
346
|
-
this._oldRenderer = renderer;
|
|
347
|
-
|
|
348
|
-
if (rendererChanged) {
|
|
349
|
-
card.innerHTML = '';
|
|
350
|
-
// Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
|
|
351
|
-
// When clearing the rendered content, this part needs to be manually disposed of.
|
|
352
|
-
// Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
|
|
353
|
-
delete card._$litPart$;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (opened) {
|
|
357
|
-
if (!this._didAnimateNotificationAppend) {
|
|
358
|
-
this._animatedAppendNotificationCard();
|
|
359
|
-
}
|
|
360
|
-
this.requestContentUpdate();
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Opens the notification.
|
|
366
|
-
*/
|
|
367
|
-
open() {
|
|
368
|
-
this.opened = true;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Closes the notification.
|
|
373
|
-
*/
|
|
374
|
-
close() {
|
|
375
|
-
this.opened = false;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/** @private */
|
|
379
|
-
get _container() {
|
|
380
|
-
if (!NotificationElement._container) {
|
|
381
|
-
NotificationElement._container = document.createElement('vaadin-notification-container');
|
|
382
|
-
document.body.appendChild(NotificationElement._container);
|
|
383
|
-
}
|
|
384
|
-
return NotificationElement._container;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/** @private */
|
|
388
|
-
_openedChanged(opened) {
|
|
389
|
-
if (opened) {
|
|
390
|
-
this._container.opened = true;
|
|
391
|
-
this._animatedAppendNotificationCard();
|
|
392
|
-
} else if (this._card) {
|
|
393
|
-
this._closeNotificationCard();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/** @private */
|
|
398
|
-
_animatedAppendNotificationCard() {
|
|
399
|
-
if (this._card) {
|
|
400
|
-
this._card.setAttribute('opening', '');
|
|
401
|
-
this._appendNotificationCard();
|
|
402
|
-
const listener = () => {
|
|
403
|
-
this._card.removeEventListener('animationend', listener);
|
|
404
|
-
this._card.removeAttribute('opening');
|
|
405
|
-
};
|
|
406
|
-
this._card.addEventListener('animationend', listener);
|
|
407
|
-
this._didAnimateNotificationAppend = true;
|
|
408
|
-
} else {
|
|
409
|
-
this._didAnimateNotificationAppend = false;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/** @private */
|
|
414
|
-
_appendNotificationCard() {
|
|
415
|
-
if (!this._card) {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if (!this._container.shadowRoot.querySelector(`slot[name="${this.position}"]`)) {
|
|
420
|
-
console.warn(`Invalid alignment parameter provided: position=${this.position}`);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
this._card.slot = this.position;
|
|
425
|
-
if (this._container.firstElementChild && /top/.test(this.position)) {
|
|
426
|
-
this._container.insertBefore(this._card, this._container.firstElementChild);
|
|
427
|
-
} else {
|
|
428
|
-
this._container.appendChild(this._card);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/** @private */
|
|
433
|
-
_removeNotificationCard() {
|
|
434
|
-
this._card.parentNode && this._card.parentNode.removeChild(this._card);
|
|
435
|
-
this._card.removeAttribute('closing');
|
|
436
|
-
this._container.opened = Boolean(this._container.firstElementChild);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/** @private */
|
|
440
|
-
_closeNotificationCard() {
|
|
441
|
-
this._durationTimeoutId && clearTimeout(this._durationTimeoutId);
|
|
442
|
-
this._animatedRemoveNotificationCard();
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/** @private */
|
|
446
|
-
_animatedRemoveNotificationCard() {
|
|
447
|
-
this._card.setAttribute('closing', '');
|
|
448
|
-
const name = getComputedStyle(this._card).getPropertyValue('animation-name');
|
|
449
|
-
if (name && name != 'none') {
|
|
450
|
-
const listener = () => {
|
|
451
|
-
this._removeNotificationCard();
|
|
452
|
-
this._card.removeEventListener('animationend', listener);
|
|
453
|
-
};
|
|
454
|
-
this._card.addEventListener('animationend', listener);
|
|
455
|
-
} else {
|
|
456
|
-
this._removeNotificationCard();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/** @private */
|
|
461
|
-
_positionChanged() {
|
|
462
|
-
if (this.opened) {
|
|
463
|
-
this._animatedAppendNotificationCard();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/** @private */
|
|
468
|
-
_durationChanged(duration, opened) {
|
|
469
|
-
if (opened) {
|
|
470
|
-
clearTimeout(this._durationTimeoutId);
|
|
471
|
-
if (duration > 0) {
|
|
472
|
-
this._durationTimeoutId = setTimeout(() => this.close(), duration);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Shows a notification with the given content.
|
|
479
|
-
* By default, positions the notification at `bottom-start` and uses a 5 second duration.
|
|
480
|
-
* An options object can be passed to configure the notification.
|
|
481
|
-
* The options object has the following structure:
|
|
482
|
-
*
|
|
483
|
-
* ```
|
|
484
|
-
* {
|
|
485
|
-
* position?: string
|
|
486
|
-
* duration?: number
|
|
487
|
-
* }
|
|
488
|
-
* ```
|
|
489
|
-
*
|
|
490
|
-
* See the individual documentation for:
|
|
491
|
-
* - [`position`](#/elements/vaadin-notification#property-position)
|
|
492
|
-
* - [`duration`](#/elements/vaadin-notification#property-duration)
|
|
493
|
-
*
|
|
494
|
-
* @param contents the contents to show, either as a string or a Lit template.
|
|
495
|
-
* @param options optional options for customizing the notification.
|
|
496
|
-
*/
|
|
497
|
-
static show(contents, options) {
|
|
498
|
-
if (isTemplateResult(contents)) {
|
|
499
|
-
return NotificationElement._createAndShowNotification((root) => {
|
|
500
|
-
render(contents, root);
|
|
501
|
-
}, options);
|
|
502
|
-
} else {
|
|
503
|
-
return NotificationElement._createAndShowNotification((root) => {
|
|
504
|
-
root.innerText = contents;
|
|
505
|
-
}, options);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/** @private */
|
|
510
|
-
static _createAndShowNotification(renderer, options) {
|
|
511
|
-
const notification = document.createElement(NotificationElement.is);
|
|
512
|
-
if (options && options.duration) {
|
|
513
|
-
notification.duration = options.duration;
|
|
514
|
-
}
|
|
515
|
-
if (options && options.position) {
|
|
516
|
-
notification.position = options.position;
|
|
517
|
-
}
|
|
518
|
-
notification.renderer = renderer;
|
|
519
|
-
document.body.appendChild(notification);
|
|
520
|
-
notification.opened = true;
|
|
521
|
-
|
|
522
|
-
notification.addEventListener('opened-changed', (e) => {
|
|
523
|
-
if (!e.detail.value) {
|
|
524
|
-
notification.remove();
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
return notification;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
customElements.define(NotificationContainer.is, NotificationContainer);
|
|
533
|
-
customElements.define(NotificationCard.is, NotificationCard);
|
|
534
|
-
customElements.define(NotificationElement.is, NotificationElement);
|
|
535
|
-
|
|
536
|
-
export { NotificationElement };
|
|
13
|
+
export * from '@vaadin/notification/src/vaadin-notification.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../src/vaadin-notification.js';
|
|
1
|
+
import '@vaadin/notification/theme/lumo/vaadin-notification.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../src/vaadin-notification.js';
|
|
1
|
+
import '@vaadin/notification/theme/material/vaadin-notification.js';
|
package/vaadin-notification.d.ts
CHANGED
package/src/interfaces.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NotificationElement } 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?: NotificationElement) => void;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Fired when the `opened` property changes.
|
|
18
|
-
*/
|
|
19
|
-
export type NotificationOpenedChangedEvent = CustomEvent<{ value: boolean }>;
|
|
20
|
-
|
|
21
|
-
export interface NotificationElementEventMap {
|
|
22
|
-
'opened-changed': NotificationOpenedChangedEvent;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface NotificationEventMap extends HTMLElementEventMap, NotificationElementEventMap {}
|
|
26
|
-
|
|
27
|
-
export interface ShowOptions {
|
|
28
|
-
duration?: number;
|
|
29
|
-
position?: NotificationPosition;
|
|
30
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
|
-
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
3
|
-
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
|
-
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
|
-
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
-
|
|
7
|
-
registerStyles(
|
|
8
|
-
'vaadin-notification-card',
|
|
9
|
-
css`
|
|
10
|
-
:host {
|
|
11
|
-
position: relative;
|
|
12
|
-
margin: var(--lumo-space-s);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
[part='overlay'] {
|
|
16
|
-
background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
|
|
17
|
-
border-radius: var(--lumo-border-radius-l);
|
|
18
|
-
box-shadow: 0 0 0 1px var(--lumo-contrast-10pct), var(--lumo-box-shadow-l);
|
|
19
|
-
font-family: var(--lumo-font-family);
|
|
20
|
-
font-size: var(--lumo-font-size-m);
|
|
21
|
-
font-weight: 400;
|
|
22
|
-
line-height: var(--lumo-line-height-s);
|
|
23
|
-
letter-spacing: 0;
|
|
24
|
-
text-transform: none;
|
|
25
|
-
-webkit-text-size-adjust: 100%;
|
|
26
|
-
-webkit-font-smoothing: antialiased;
|
|
27
|
-
-moz-osx-font-smoothing: grayscale;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[part='content'] {
|
|
31
|
-
padding: var(--lumo-space-wide-l);
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
justify-content: space-between;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[part='content'] ::slotted(vaadin-button) {
|
|
38
|
-
flex: none;
|
|
39
|
-
margin: 0 calc(var(--lumo-space-s) * -1) 0 var(--lumo-space-m);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:host([slot^='middle']) {
|
|
43
|
-
max-width: 80vw;
|
|
44
|
-
margin: var(--lumo-space-s) auto;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
:host([slot\$='stretch']) {
|
|
48
|
-
margin: 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
:host([slot\$='stretch']) [part='overlay'] {
|
|
52
|
-
border-radius: 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@media (min-width: 421px) {
|
|
56
|
-
:host(:not([slot\$='stretch'])) {
|
|
57
|
-
display: flex;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
:host([slot\$='end']) {
|
|
61
|
-
justify-content: flex-end;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
:host([slot^='middle']),
|
|
65
|
-
:host([slot\$='center']) {
|
|
66
|
-
display: flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@keyframes lumo-notification-exit-fade-out {
|
|
72
|
-
100% {
|
|
73
|
-
opacity: 0;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@keyframes lumo-notification-enter-fade-in {
|
|
78
|
-
0% {
|
|
79
|
-
opacity: 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@keyframes lumo-notification-enter-slide-down {
|
|
84
|
-
0% {
|
|
85
|
-
transform: translateY(-200%);
|
|
86
|
-
opacity: 0;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@keyframes lumo-notification-exit-slide-up {
|
|
91
|
-
100% {
|
|
92
|
-
transform: translateY(-200%);
|
|
93
|
-
opacity: 0;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@keyframes lumo-notification-enter-slide-up {
|
|
98
|
-
0% {
|
|
99
|
-
transform: translateY(200%);
|
|
100
|
-
opacity: 0;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@keyframes lumo-notification-exit-slide-down {
|
|
105
|
-
100% {
|
|
106
|
-
transform: translateY(200%);
|
|
107
|
-
opacity: 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:host([slot='middle'][opening]) {
|
|
112
|
-
animation: lumo-notification-enter-fade-in 300ms;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:host([slot='middle'][closing]) {
|
|
116
|
-
animation: lumo-notification-exit-fade-out 300ms;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
:host([slot^='top'][opening]) {
|
|
120
|
-
animation: lumo-notification-enter-slide-down 300ms;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
:host([slot^='top'][closing]) {
|
|
124
|
-
animation: lumo-notification-exit-slide-up 300ms;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
:host([slot^='bottom'][opening]) {
|
|
128
|
-
animation: lumo-notification-enter-slide-up 300ms;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
:host([slot^='bottom'][closing]) {
|
|
132
|
-
animation: lumo-notification-exit-slide-down 300ms;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
:host([theme~='primary']) [part='overlay'] {
|
|
136
|
-
background: var(--lumo-primary-color);
|
|
137
|
-
color: var(--lumo-primary-contrast-color);
|
|
138
|
-
box-shadow: var(--lumo-box-shadow-l);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
:host([theme~='primary']) {
|
|
142
|
-
--_lumo-button-background-color: var(--lumo-shade-20pct);
|
|
143
|
-
--_lumo-button-color: var(--lumo-primary-contrast-color);
|
|
144
|
-
--_lumo-button-primary-background-color: var(--lumo-primary-contrast-color);
|
|
145
|
-
--_lumo-button-primary-color: var(--lumo-primary-text-color);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
:host([theme~='contrast']) [part='overlay'] {
|
|
149
|
-
background: var(--lumo-contrast);
|
|
150
|
-
color: var(--lumo-base-color);
|
|
151
|
-
box-shadow: var(--lumo-box-shadow-l);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
:host([theme~='contrast']) {
|
|
155
|
-
--_lumo-button-background-color: var(--lumo-contrast-20pct);
|
|
156
|
-
--_lumo-button-color: var(--lumo-base-color);
|
|
157
|
-
--_lumo-button-primary-background-color: var(--lumo-base-color);
|
|
158
|
-
--_lumo-button-primary-color: var(--lumo-contrast);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
:host([theme~='success']) [part='overlay'] {
|
|
162
|
-
background: var(--lumo-success-color);
|
|
163
|
-
color: var(--lumo-success-contrast-color);
|
|
164
|
-
box-shadow: var(--lumo-box-shadow-l);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
:host([theme~='success']) {
|
|
168
|
-
--_lumo-button-background-color: var(--lumo-shade-20pct);
|
|
169
|
-
--_lumo-button-color: var(--lumo-success-contrast-color);
|
|
170
|
-
--_lumo-button-primary-background-color: var(--lumo-success-contrast-color);
|
|
171
|
-
--_lumo-button-primary-color: var(--lumo-success-text-color);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
:host([theme~='error']) [part='overlay'] {
|
|
175
|
-
background: var(--lumo-error-color);
|
|
176
|
-
color: var(--lumo-error-contrast-color);
|
|
177
|
-
box-shadow: var(--lumo-box-shadow-l);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
:host([theme~='error']) {
|
|
181
|
-
--_lumo-button-background-color: var(--lumo-shade-20pct);
|
|
182
|
-
--_lumo-button-color: var(--lumo-error-contrast-color);
|
|
183
|
-
--_lumo-button-primary-background-color: var(--lumo-error-contrast-color);
|
|
184
|
-
--_lumo-button-primary-color: var(--lumo-error-text-color);
|
|
185
|
-
}
|
|
186
|
-
`,
|
|
187
|
-
{ moduleId: 'lumo-notification-card' }
|
|
188
|
-
);
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
|
-
import { colorDark } from '@vaadin/vaadin-material-styles/color.js';
|
|
3
|
-
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
|
-
import '@vaadin/vaadin-material-styles/shadow.js';
|
|
5
|
-
|
|
6
|
-
registerStyles(
|
|
7
|
-
'vaadin-notification-container',
|
|
8
|
-
css`
|
|
9
|
-
:host {
|
|
10
|
-
top: 0;
|
|
11
|
-
bottom: 0;
|
|
12
|
-
left: 4px;
|
|
13
|
-
right: 4px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@media (min-width: 420px) {
|
|
17
|
-
:host {
|
|
18
|
-
top: 0;
|
|
19
|
-
bottom: 0;
|
|
20
|
-
left: 12px;
|
|
21
|
-
right: 12px;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`,
|
|
25
|
-
{ moduleId: 'material-notification-container' }
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const notificationCard = css`
|
|
29
|
-
:host {
|
|
30
|
-
min-height: 48px;
|
|
31
|
-
margin: 8px 4px;
|
|
32
|
-
background-color: transparent;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
[part='overlay'] {
|
|
36
|
-
background-color: var(--material-background-color);
|
|
37
|
-
border-radius: 4px;
|
|
38
|
-
box-shadow: var(--material-shadow-elevation-6dp);
|
|
39
|
-
|
|
40
|
-
padding: 14px 16px;
|
|
41
|
-
justify-content: stretch;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[part='content'] {
|
|
45
|
-
font-family: var(--material-font-family);
|
|
46
|
-
font-size: var(--material-small-font-size);
|
|
47
|
-
font-weight: 400;
|
|
48
|
-
line-height: 20px;
|
|
49
|
-
letter-spacing: 0;
|
|
50
|
-
text-transform: none;
|
|
51
|
-
box-sizing: border-box;
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: space-between;
|
|
54
|
-
align-items: center;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* NOTE(platosha): Makes the button take exactly 1 line of vertical space */
|
|
58
|
-
[part='content'] ::slotted(vaadin-button) {
|
|
59
|
-
margin: -8px 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
:host([slot\$='stretch']) {
|
|
63
|
-
margin: 0 -4px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
:host([slot\$='stretch']) [part='overlay'] {
|
|
67
|
-
border-radius: 0;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@media (min-width: 420px) {
|
|
71
|
-
:host {
|
|
72
|
-
margin: 24px 12px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:host([slot^='middle']) {
|
|
76
|
-
width: 372px;
|
|
77
|
-
margin: auto;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
:host([slot\$='stretch']) {
|
|
81
|
-
margin: 0 -12px;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@keyframes material-notification-exit-fade-out {
|
|
86
|
-
100% {
|
|
87
|
-
opacity: 0;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@keyframes material-notification-enter-fade-in {
|
|
92
|
-
0% {
|
|
93
|
-
opacity: 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
100% {
|
|
97
|
-
opacity: 1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@keyframes material-notification-enter-slide-down {
|
|
102
|
-
0% {
|
|
103
|
-
transform: translateY(-200%);
|
|
104
|
-
opacity: 0;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@keyframes material-notification-exit-slide-up {
|
|
109
|
-
100% {
|
|
110
|
-
transform: translateY(-200%);
|
|
111
|
-
opacity: 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@keyframes material-notification-enter-slide-up {
|
|
116
|
-
0% {
|
|
117
|
-
transform: translateY(200%);
|
|
118
|
-
opacity: 0;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@keyframes material-notification-exit-slide-down {
|
|
123
|
-
100% {
|
|
124
|
-
transform: translateY(200%);
|
|
125
|
-
opacity: 0;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
:host([slot='middle'][opening]) {
|
|
130
|
-
animation: material-notification-enter-fade-in 300ms;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
:host([slot='middle'][closing]) {
|
|
134
|
-
animation: material-notification-exit-fade-out 300ms;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
:host([slot^='top'][opening]) {
|
|
138
|
-
animation: material-notification-enter-slide-down 300ms;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
:host([slot^='top'][closing]) {
|
|
142
|
-
animation: material-notification-exit-slide-up 300ms;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
:host([slot^='bottom'][opening]) {
|
|
146
|
-
animation: material-notification-enter-slide-up 300ms;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
:host([slot^='bottom'][closing]) {
|
|
150
|
-
animation: material-notification-exit-slide-down 300ms;
|
|
151
|
-
}
|
|
152
|
-
`;
|
|
153
|
-
|
|
154
|
-
registerStyles('vaadin-notification-card', [colorDark, notificationCard], {
|
|
155
|
-
moduleId: 'material-notification-card'
|
|
156
|
-
});
|