@vaadin/notification 25.3.0-alpha8 → 25.3.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/notification",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-beta1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,18 +37,19 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/component-base": "25.3.0-
|
|
41
|
-
"@vaadin/lit-renderer": "25.3.0-
|
|
42
|
-
"@vaadin/
|
|
40
|
+
"@vaadin/component-base": "25.3.0-beta1",
|
|
41
|
+
"@vaadin/lit-renderer": "25.3.0-beta1",
|
|
42
|
+
"@vaadin/overlay": "25.3.0-beta1",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-beta1",
|
|
43
44
|
"lit": "^3.0.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@vaadin/aura": "25.3.0-
|
|
47
|
-
"@vaadin/button": "25.3.0-
|
|
48
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
49
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
47
|
+
"@vaadin/aura": "25.3.0-beta1",
|
|
48
|
+
"@vaadin/button": "25.3.0-beta1",
|
|
49
|
+
"@vaadin/chai-plugins": "25.3.0-beta1",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.3.0-beta1",
|
|
50
51
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
51
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-beta1",
|
|
52
53
|
"sinon": "^22.0.0"
|
|
53
54
|
},
|
|
54
55
|
"customElements": "custom-elements.json",
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"web-types.json",
|
|
57
58
|
"web-types.lit.json"
|
|
58
59
|
],
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "295432e44a6967e1aff36462b2e3e1d0e64eb8cc"
|
|
60
61
|
}
|
|
@@ -5,10 +5,57 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/component-base/src/styles/style-props.js';
|
|
7
7
|
import { css } from 'lit';
|
|
8
|
+
import { overlayAnimationStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-animation-base-styles.js';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const notificationCard = css`
|
|
10
11
|
:host {
|
|
11
12
|
display: block;
|
|
13
|
+
position: relative;
|
|
14
|
+
--vaadin-overlay-animation-duration: 0.3s;
|
|
15
|
+
transition-duration: var(--vaadin-overlay-animation-duration);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:host([closing]) [part='overlay'] {
|
|
19
|
+
animation-fill-mode: both;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([slot^='top']) {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: end;
|
|
25
|
+
--vaadin-overlay-translate-closed: 0% -30%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([slot^='bottom']) {
|
|
29
|
+
--vaadin-overlay-translate-closed: 0% 30%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Cards on the sides slide in horizontally, once the vertical collapse is done */
|
|
33
|
+
@media (min-width: 600px) and (min-height: 600px) {
|
|
34
|
+
:host([slot$='start']) {
|
|
35
|
+
--vaadin-overlay-translate-closed: -30% 0%;
|
|
36
|
+
--vaadin-overlay-animation-delay: var(--vaadin-overlay-animation-duration);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([slot$='end']) {
|
|
40
|
+
--vaadin-overlay-translate-closed: 30% 0%;
|
|
41
|
+
--vaadin-overlay-animation-delay: var(--vaadin-overlay-animation-duration);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host([closing]) {
|
|
46
|
+
animation-direction: reverse;
|
|
47
|
+
animation-duration: var(--vaadin-overlay-animation-duration);
|
|
48
|
+
animation-delay: var(--vaadin-overlay-animation-duration);
|
|
49
|
+
transition-delay: var(--vaadin-overlay-animation-duration);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Cards scale down in place instead of sliding back out */
|
|
53
|
+
/* WebKit/Safari needs these to be explicitly set on the part=overlay element as well */
|
|
54
|
+
:host([closing]),
|
|
55
|
+
:host([closing]) [part='overlay'] {
|
|
56
|
+
--vaadin-overlay-translate-closed: 0%;
|
|
57
|
+
--vaadin-overlay-scale-closed: 0.98;
|
|
58
|
+
--vaadin-overlay-animation-delay: 0s;
|
|
12
59
|
}
|
|
13
60
|
|
|
14
61
|
[part='overlay'] {
|
|
@@ -30,4 +77,67 @@ export const notificationCardStyles = css`
|
|
|
30
77
|
border: 3px solid !important;
|
|
31
78
|
}
|
|
32
79
|
}
|
|
80
|
+
|
|
81
|
+
/* The other cards make room for a card that opens, and close the gap when it is removed */
|
|
82
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
83
|
+
@supports (interpolate-size: allow-keywords) {
|
|
84
|
+
:host {
|
|
85
|
+
interpolate-size: allow-keywords;
|
|
86
|
+
transition-property: height, margin-top, margin-bottom;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@starting-style {
|
|
90
|
+
:host([opening]:not(:nth-child(1 of [slot='middle']))),
|
|
91
|
+
:host([closing]) {
|
|
92
|
+
height: 0;
|
|
93
|
+
margin-top: 0 !important;
|
|
94
|
+
margin-bottom: 0 !important;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([closing]) {
|
|
99
|
+
height: 0;
|
|
100
|
+
margin-top: 0 !important;
|
|
101
|
+
margin-bottom: 0 !important;
|
|
102
|
+
transition-delay: var(--vaadin-overlay-animation-duration);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Without interpolate-size, only the margins animate, and max-height stands in for the height */
|
|
107
|
+
@supports not (interpolate-size: allow-keywords) {
|
|
108
|
+
:host([opening]:not(:nth-child(1 of [slot='middle']))),
|
|
109
|
+
:host([closing]) {
|
|
110
|
+
animation-name: --notification-max-height, --notification-margins;
|
|
111
|
+
animation-duration: calc(var(--vaadin-overlay-animation-duration) * 2 + var(--vaadin-overlay-animation-delay));
|
|
112
|
+
animation-delay: 0s;
|
|
113
|
+
animation-timing-function: ease-in-out, cubic-bezier(0.4, 1.1, 0, 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (prefers-reduced-motion) {
|
|
119
|
+
/* The height animation of the fallback above is a keyframe animation, not a transition */
|
|
120
|
+
:host(:is([opening], [closing])) {
|
|
121
|
+
animation-name: --fade !important;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@keyframes --notification-max-height {
|
|
126
|
+
0% {
|
|
127
|
+
max-height: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
50% {
|
|
131
|
+
max-height: 20em;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@keyframes --notification-margins {
|
|
136
|
+
0% {
|
|
137
|
+
margin-top: 0;
|
|
138
|
+
margin-bottom: 0;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
33
141
|
`;
|
|
142
|
+
|
|
143
|
+
export const notificationCardStyles = [overlayAnimationStyles, notificationCard];
|
|
@@ -342,6 +342,42 @@ export const NotificationMixin = (superClass) =>
|
|
|
342
342
|
this._card.removeEventListener('animationend', this.__animationEndListener);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Detect whether an animation runs on the card, so that its end can be awaited before the
|
|
347
|
+
* card is removed. A card that is not rendered, has no animation name, or has a zero
|
|
348
|
+
* duration does not fire `animationend`.
|
|
349
|
+
*
|
|
350
|
+
* `getStateAnimations()` cannot replace this: the card declares the same keyframes for both
|
|
351
|
+
* states, so nothing restarts when it closes right after the opening animation ended, and no
|
|
352
|
+
* animation is found. The computed style still reports the declared animation, which is what
|
|
353
|
+
* the card needs in order to stay in the DOM until its height has collapsed.
|
|
354
|
+
* @private
|
|
355
|
+
*/
|
|
356
|
+
__shouldAnimateCard() {
|
|
357
|
+
const style = getComputedStyle(this._card);
|
|
358
|
+
const name = style.getPropertyValue('animation-name');
|
|
359
|
+
const hasDuration = style
|
|
360
|
+
.getPropertyValue('animation-duration')
|
|
361
|
+
.split(',')
|
|
362
|
+
.some((duration) => parseFloat(duration) > 0);
|
|
363
|
+
return style.getPropertyValue('display') !== 'none' && name && name !== 'none' && hasDuration;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Run the callback when the animation of the card itself ends. Animations of the
|
|
368
|
+
* notification content also end on the card, as the content is in its light DOM.
|
|
369
|
+
* @private
|
|
370
|
+
*/
|
|
371
|
+
__onCardAnimationEnd(callback) {
|
|
372
|
+
this.__animationEndListener = (event) => {
|
|
373
|
+
if (event.target !== this._card) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
callback();
|
|
377
|
+
};
|
|
378
|
+
this._card.addEventListener('animationend', this.__animationEndListener);
|
|
379
|
+
}
|
|
380
|
+
|
|
345
381
|
/** @private */
|
|
346
382
|
_animatedAppendNotificationCard() {
|
|
347
383
|
if (this._card) {
|
|
@@ -349,8 +385,11 @@ export const NotificationMixin = (superClass) =>
|
|
|
349
385
|
|
|
350
386
|
this._card.setAttribute('opening', '');
|
|
351
387
|
this._appendNotificationCard();
|
|
352
|
-
|
|
353
|
-
|
|
388
|
+
if (this.__shouldAnimateCard()) {
|
|
389
|
+
this.__onCardAnimationEnd(() => this.__cleanUpOpeningClosingState());
|
|
390
|
+
} else {
|
|
391
|
+
this.__cleanUpOpeningClosingState();
|
|
392
|
+
}
|
|
354
393
|
this._didAnimateNotificationAppend = true;
|
|
355
394
|
} else {
|
|
356
395
|
this._didAnimateNotificationAppend = false;
|
|
@@ -409,13 +448,11 @@ export const NotificationMixin = (superClass) =>
|
|
|
409
448
|
this.__cleanUpOpeningClosingState();
|
|
410
449
|
|
|
411
450
|
this._card.setAttribute('closing', '');
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this.__animationEndListener = () => {
|
|
451
|
+
if (this.__shouldAnimateCard()) {
|
|
452
|
+
this.__onCardAnimationEnd(() => {
|
|
415
453
|
this._removeNotificationCard();
|
|
416
454
|
this.__cleanUpOpeningClosingState();
|
|
417
|
-
};
|
|
418
|
-
this._card.addEventListener('animationend', this.__animationEndListener);
|
|
455
|
+
});
|
|
419
456
|
} else {
|
|
420
457
|
this._removeNotificationCard();
|
|
421
458
|
}
|
package/web-types.json
CHANGED
package/web-types.lit.json
CHANGED