@vaadin/tooltip 23.3.0-alpha2 → 23.3.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 +7 -7
- package/src/vaadin-tooltip-overlay.js +8 -4
- package/src/vaadin-tooltip.d.ts +1 -1
- package/src/vaadin-tooltip.js +238 -162
- package/theme/lumo/vaadin-tooltip-styles.js +4 -2
- package/theme/lumo/vaadin-tooltip.js +1 -1
- package/theme/material/vaadin-tooltip.js +1 -1
- package/web-types.json +4 -4
- package/web-types.lit.json +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/tooltip",
|
|
3
|
-
"version": "23.3.0-
|
|
3
|
+
"version": "23.3.0-alpha4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/component-base": "23.3.0-
|
|
39
|
-
"@vaadin/
|
|
40
|
-
"@vaadin/vaadin-
|
|
41
|
-
"@vaadin/vaadin-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "23.3.0-
|
|
38
|
+
"@vaadin/component-base": "23.3.0-alpha4",
|
|
39
|
+
"@vaadin/overlay": "23.3.0-alpha4",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha4",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha4",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"web-types.json",
|
|
51
51
|
"web-types.lit.json"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "da037c0aa36e4b2874f253967300f6ca1af27315"
|
|
54
54
|
}
|
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
* Copyright (c) 2022 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 { PositionMixin } from '@vaadin/
|
|
6
|
+
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
7
|
+
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
8
8
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
|
|
10
10
|
registerStyles(
|
|
11
11
|
'vaadin-tooltip-overlay',
|
|
12
12
|
css`
|
|
13
|
+
[part='overlay'] {
|
|
14
|
+
max-width: 40ch;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
:host([position^='top'][top-aligned]) [part='overlay'],
|
|
14
18
|
:host([position^='bottom'][top-aligned]) [part='overlay'] {
|
|
15
19
|
margin-top: var(--vaadin-tooltip-offset-top, 0);
|
|
@@ -38,10 +42,10 @@ let memoizedTemplate;
|
|
|
38
42
|
/**
|
|
39
43
|
* An element used internally by `<vaadin-tooltip>`. Not intended to be used separately.
|
|
40
44
|
*
|
|
41
|
-
* @extends
|
|
45
|
+
* @extends Overlay
|
|
42
46
|
* @private
|
|
43
47
|
*/
|
|
44
|
-
class TooltipOverlay extends PositionMixin(
|
|
48
|
+
class TooltipOverlay extends PositionMixin(Overlay) {
|
|
45
49
|
static get is() {
|
|
46
50
|
return 'vaadin-tooltip-overlay';
|
|
47
51
|
}
|
package/src/vaadin-tooltip.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ declare class Tooltip extends ThemePropertyMixin(ElementMixin(HTMLElement)) {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* The delay in milliseconds before the tooltip
|
|
89
|
-
* is opened on focus, when not in manual mode.
|
|
89
|
+
* is opened on keyboard focus, when not in manual mode.
|
|
90
90
|
* @attr {number} focus-delay
|
|
91
91
|
*/
|
|
92
92
|
focusDelay: number;
|
package/src/vaadin-tooltip.js
CHANGED
|
@@ -23,6 +23,174 @@ let warmedUp = false;
|
|
|
23
23
|
let warmUpTimeout = null;
|
|
24
24
|
let cooldownTimeout = null;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Controller for handling tooltip opened state.
|
|
28
|
+
*/
|
|
29
|
+
class TooltipStateController {
|
|
30
|
+
constructor(host) {
|
|
31
|
+
this.host = host;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Schedule opening the tooltip.
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
*/
|
|
38
|
+
open(options = { immediate: false }) {
|
|
39
|
+
const { immediate, hover, focus } = options;
|
|
40
|
+
const isHover = hover && this.hoverDelay > 0;
|
|
41
|
+
const isFocus = focus && this.focusDelay > 0;
|
|
42
|
+
|
|
43
|
+
if (!immediate && (isHover || isFocus) && !this.__closeTimeout) {
|
|
44
|
+
this.__warmupTooltip(isFocus);
|
|
45
|
+
} else {
|
|
46
|
+
this.__showTooltip();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Schedule closing the tooltip.
|
|
52
|
+
* @param {boolean} immediate
|
|
53
|
+
*/
|
|
54
|
+
close(immediate) {
|
|
55
|
+
if (!immediate && this.hideDelay > 0) {
|
|
56
|
+
this.__scheduleClose();
|
|
57
|
+
} else {
|
|
58
|
+
this.__abortClose();
|
|
59
|
+
this._setOpened(false);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.__abortWarmUp();
|
|
63
|
+
|
|
64
|
+
if (warmedUp) {
|
|
65
|
+
// Re-start cooldown timer on each tooltip closing.
|
|
66
|
+
this.__abortCooldown();
|
|
67
|
+
this.__scheduleCooldown();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @private */
|
|
72
|
+
get openedProp() {
|
|
73
|
+
return this.host.manual ? 'opened' : '_autoOpened';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @private */
|
|
77
|
+
get focusDelay() {
|
|
78
|
+
const tooltip = this.host;
|
|
79
|
+
return tooltip.focusDelay != null && tooltip.focusDelay > 0 ? tooltip.focusDelay : defaultFocusDelay;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @private */
|
|
83
|
+
get hoverDelay() {
|
|
84
|
+
const tooltip = this.host;
|
|
85
|
+
return tooltip.hoverDelay != null && tooltip.hoverDelay > 0 ? tooltip.hoverDelay : defaultHoverDelay;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @private */
|
|
89
|
+
get hideDelay() {
|
|
90
|
+
const tooltip = this.host;
|
|
91
|
+
return tooltip.hideDelay != null && tooltip.hideDelay > 0 ? tooltip.hideDelay : defaultHideDelay;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @private */
|
|
95
|
+
_isOpened() {
|
|
96
|
+
return this.host[this.openedProp];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @private */
|
|
100
|
+
_setOpened(opened) {
|
|
101
|
+
this.host[this.openedProp] = opened;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @private */
|
|
105
|
+
__flushClosingTooltips() {
|
|
106
|
+
closing.forEach((tooltip) => {
|
|
107
|
+
tooltip._stateController.close(true);
|
|
108
|
+
closing.delete(tooltip);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @private */
|
|
113
|
+
__showTooltip() {
|
|
114
|
+
this.__abortClose();
|
|
115
|
+
this.__flushClosingTooltips();
|
|
116
|
+
|
|
117
|
+
this._setOpened(true);
|
|
118
|
+
warmedUp = true;
|
|
119
|
+
|
|
120
|
+
// Abort previously scheduled timers.
|
|
121
|
+
this.__abortWarmUp();
|
|
122
|
+
this.__abortCooldown();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @private */
|
|
126
|
+
__warmupTooltip(isFocus) {
|
|
127
|
+
if (!this._isOpened()) {
|
|
128
|
+
// First tooltip is opened, warm up.
|
|
129
|
+
if (!warmedUp) {
|
|
130
|
+
this.__scheduleWarmUp(isFocus);
|
|
131
|
+
} else {
|
|
132
|
+
// Warmed up, show another tooltip.
|
|
133
|
+
this.__showTooltip();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** @private */
|
|
139
|
+
__abortClose() {
|
|
140
|
+
if (this.__closeTimeout) {
|
|
141
|
+
clearTimeout(this.__closeTimeout);
|
|
142
|
+
this.__closeTimeout = null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @private */
|
|
147
|
+
__abortCooldown() {
|
|
148
|
+
if (cooldownTimeout) {
|
|
149
|
+
clearTimeout(cooldownTimeout);
|
|
150
|
+
cooldownTimeout = null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** @private */
|
|
155
|
+
__abortWarmUp() {
|
|
156
|
+
if (warmUpTimeout) {
|
|
157
|
+
clearTimeout(warmUpTimeout);
|
|
158
|
+
warmUpTimeout = null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @private */
|
|
163
|
+
__scheduleClose() {
|
|
164
|
+
if (this._isOpened()) {
|
|
165
|
+
closing.add(this.host);
|
|
166
|
+
|
|
167
|
+
this.__closeTimeout = setTimeout(() => {
|
|
168
|
+
closing.delete(this.host);
|
|
169
|
+
this.__closeTimeout = null;
|
|
170
|
+
this._setOpened(false);
|
|
171
|
+
}, this.hideDelay);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** @private */
|
|
176
|
+
__scheduleCooldown() {
|
|
177
|
+
cooldownTimeout = setTimeout(() => {
|
|
178
|
+
cooldownTimeout = null;
|
|
179
|
+
warmedUp = false;
|
|
180
|
+
}, this.hideDelay);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** @private */
|
|
184
|
+
__scheduleWarmUp(isFocus) {
|
|
185
|
+
const delay = isFocus ? this.focusDelay : this.hoverDelay;
|
|
186
|
+
warmUpTimeout = setTimeout(() => {
|
|
187
|
+
warmUpTimeout = null;
|
|
188
|
+
warmedUp = true;
|
|
189
|
+
this.__showTooltip();
|
|
190
|
+
}, delay);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
26
194
|
/**
|
|
27
195
|
* `<vaadin-tooltip>` is a Web Component for creating tooltips.
|
|
28
196
|
*
|
|
@@ -82,13 +250,13 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
82
250
|
role="tooltip"
|
|
83
251
|
renderer="[[_renderer]]"
|
|
84
252
|
theme$="[[_theme]]"
|
|
85
|
-
opened="[[__computeOpened(manual, opened, _autoOpened)]]"
|
|
253
|
+
opened="[[__computeOpened(manual, opened, _autoOpened, _isConnected)]]"
|
|
86
254
|
position-target="[[target]]"
|
|
87
|
-
position="[[
|
|
88
|
-
no-horizontal-overlap$="[[__computeNoHorizontalOverlap(
|
|
89
|
-
no-vertical-overlap$="[[__computeNoVerticalOverlap(
|
|
90
|
-
horizontal-align="[[__computeHorizontalAlign(
|
|
91
|
-
vertical-align="[[__computeVerticalAlign(
|
|
255
|
+
position="[[__effectivePosition]]"
|
|
256
|
+
no-horizontal-overlap$="[[__computeNoHorizontalOverlap(__effectivePosition)]]"
|
|
257
|
+
no-vertical-overlap$="[[__computeNoVerticalOverlap(__effectivePosition)]]"
|
|
258
|
+
horizontal-align="[[__computeHorizontalAlign(__effectivePosition)]]"
|
|
259
|
+
vertical-align="[[__computeVerticalAlign(__effectivePosition)]]"
|
|
92
260
|
on-mouseleave="__onOverlayMouseLeave"
|
|
93
261
|
modeless
|
|
94
262
|
></vaadin-tooltip-overlay>
|
|
@@ -111,7 +279,7 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
111
279
|
|
|
112
280
|
/**
|
|
113
281
|
* The delay in milliseconds before the tooltip
|
|
114
|
-
* is opened on focus, when not in manual mode.
|
|
282
|
+
* is opened on keyboard focus, when not in manual mode.
|
|
115
283
|
* @attr {number} focus-delay
|
|
116
284
|
*/
|
|
117
285
|
focusDelay: {
|
|
@@ -173,7 +341,6 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
173
341
|
*/
|
|
174
342
|
position: {
|
|
175
343
|
type: String,
|
|
176
|
-
value: 'bottom',
|
|
177
344
|
},
|
|
178
345
|
|
|
179
346
|
/**
|
|
@@ -228,6 +395,21 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
228
395
|
observer: '__autoOpenedChanged',
|
|
229
396
|
},
|
|
230
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Default value used when `position` property is not set.
|
|
400
|
+
* @protected
|
|
401
|
+
*/
|
|
402
|
+
_position: {
|
|
403
|
+
type: String,
|
|
404
|
+
value: 'bottom',
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
/** @private */
|
|
408
|
+
__effectivePosition: {
|
|
409
|
+
type: String,
|
|
410
|
+
computed: '__computePosition(position, _position)',
|
|
411
|
+
},
|
|
412
|
+
|
|
231
413
|
/** @protected */
|
|
232
414
|
_overlayElement: Object,
|
|
233
415
|
|
|
@@ -236,6 +418,11 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
236
418
|
type: Boolean,
|
|
237
419
|
value: false,
|
|
238
420
|
},
|
|
421
|
+
|
|
422
|
+
/** @private */
|
|
423
|
+
_isConnected: {
|
|
424
|
+
type: Boolean,
|
|
425
|
+
},
|
|
239
426
|
};
|
|
240
427
|
}
|
|
241
428
|
|
|
@@ -285,6 +472,7 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
285
472
|
this.__onMouseEnter = this.__onMouseEnter.bind(this);
|
|
286
473
|
this.__onMouseLeave = this.__onMouseLeave.bind(this);
|
|
287
474
|
this.__onKeyDown = this.__onKeyDown.bind(this);
|
|
475
|
+
this.__onOverlayOpen = this.__onOverlayOpen.bind(this);
|
|
288
476
|
|
|
289
477
|
this.__targetVisibilityObserver = new IntersectionObserver(
|
|
290
478
|
([entry]) => {
|
|
@@ -292,6 +480,17 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
292
480
|
},
|
|
293
481
|
{ threshold: 1 },
|
|
294
482
|
);
|
|
483
|
+
|
|
484
|
+
this._stateController = new TooltipStateController(this);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** @protected */
|
|
488
|
+
connectedCallback() {
|
|
489
|
+
super.connectedCallback();
|
|
490
|
+
|
|
491
|
+
this._isConnected = true;
|
|
492
|
+
|
|
493
|
+
document.body.addEventListener('vaadin-overlay-open', this.__onOverlayOpen);
|
|
295
494
|
}
|
|
296
495
|
|
|
297
496
|
/** @protected */
|
|
@@ -299,8 +498,11 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
299
498
|
super.disconnectedCallback();
|
|
300
499
|
|
|
301
500
|
if (this._autoOpened) {
|
|
302
|
-
this.
|
|
501
|
+
this._stateController.close(true);
|
|
303
502
|
}
|
|
503
|
+
this._isConnected = false;
|
|
504
|
+
|
|
505
|
+
document.body.removeEventListener('vaadin-overlay-open', this.__onOverlayOpen);
|
|
304
506
|
}
|
|
305
507
|
|
|
306
508
|
/** @private */
|
|
@@ -324,8 +526,13 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
324
526
|
}
|
|
325
527
|
|
|
326
528
|
/** @private */
|
|
327
|
-
__computeOpened(manual, opened, autoOpened) {
|
|
328
|
-
return manual ? opened : autoOpened;
|
|
529
|
+
__computeOpened(manual, opened, autoOpened, connected) {
|
|
530
|
+
return connected && (manual ? opened : autoOpened);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** @private */
|
|
534
|
+
__computePosition(position, defaultPosition) {
|
|
535
|
+
return position || defaultPosition;
|
|
329
536
|
}
|
|
330
537
|
|
|
331
538
|
/** @private */
|
|
@@ -408,7 +615,7 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
408
615
|
this.__focusInside = true;
|
|
409
616
|
|
|
410
617
|
if (!this.__isTargetHidden && (!this.__hoverInside || !this._autoOpened)) {
|
|
411
|
-
this.
|
|
618
|
+
this._stateController.open({ focus: true });
|
|
412
619
|
}
|
|
413
620
|
}
|
|
414
621
|
|
|
@@ -426,7 +633,7 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
426
633
|
this.__focusInside = false;
|
|
427
634
|
|
|
428
635
|
if (!this.__hoverInside) {
|
|
429
|
-
this.
|
|
636
|
+
this._stateController.close(true);
|
|
430
637
|
}
|
|
431
638
|
}
|
|
432
639
|
|
|
@@ -434,13 +641,13 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
434
641
|
__onKeyDown(event) {
|
|
435
642
|
if (event.key === 'Escape') {
|
|
436
643
|
event.stopPropagation();
|
|
437
|
-
this.
|
|
644
|
+
this._stateController.close(true);
|
|
438
645
|
}
|
|
439
646
|
}
|
|
440
647
|
|
|
441
648
|
/** @private */
|
|
442
649
|
__onMouseDown() {
|
|
443
|
-
this.
|
|
650
|
+
this._stateController.close(true);
|
|
444
651
|
}
|
|
445
652
|
|
|
446
653
|
/** @private */
|
|
@@ -461,7 +668,7 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
461
668
|
this.__hoverInside = true;
|
|
462
669
|
|
|
463
670
|
if (!this.__isTargetHidden && (!this.__focusInside || !this._autoOpened)) {
|
|
464
|
-
this.
|
|
671
|
+
this._stateController.open({ hover: true });
|
|
465
672
|
}
|
|
466
673
|
}
|
|
467
674
|
|
|
@@ -488,7 +695,19 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
488
695
|
this.__hoverInside = false;
|
|
489
696
|
|
|
490
697
|
if (!this.__focusInside) {
|
|
491
|
-
this.
|
|
698
|
+
this._stateController.close();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** @private */
|
|
703
|
+
__onOverlayOpen() {
|
|
704
|
+
if (this.manual) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// Close tooltip if another overlay is opened on top of the tooltip's overlay
|
|
709
|
+
if (this._overlayElement.opened && !this._overlayElement._last) {
|
|
710
|
+
this._stateController.close(true);
|
|
492
711
|
}
|
|
493
712
|
}
|
|
494
713
|
|
|
@@ -499,13 +718,13 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
499
718
|
|
|
500
719
|
// Open the overlay when the target becomes visible and has focus or hover.
|
|
501
720
|
if (oldHidden && isVisible && (this.__focusInside || this.__hoverInside)) {
|
|
502
|
-
this.
|
|
721
|
+
this._stateController.open({ immediate: true });
|
|
503
722
|
return;
|
|
504
723
|
}
|
|
505
724
|
|
|
506
725
|
// Close the overlay when the target is no longer fully visible.
|
|
507
726
|
if (!isVisible && this._autoOpened) {
|
|
508
|
-
this.
|
|
727
|
+
this._stateController.close(true);
|
|
509
728
|
}
|
|
510
729
|
}
|
|
511
730
|
|
|
@@ -518,149 +737,6 @@ class Tooltip extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
|
|
|
518
737
|
return true;
|
|
519
738
|
}
|
|
520
739
|
|
|
521
|
-
/**
|
|
522
|
-
* Schedule opening the tooltip.
|
|
523
|
-
* @param {boolean} immediate
|
|
524
|
-
* @protected
|
|
525
|
-
*/
|
|
526
|
-
_open(options = { immediate: false }) {
|
|
527
|
-
const { immediate, hover, focus } = options;
|
|
528
|
-
const isHover = hover && this.__getHoverDelay() > 0;
|
|
529
|
-
const isFocus = focus && this.__getFocusDelay() > 0;
|
|
530
|
-
|
|
531
|
-
if (!immediate && (isHover || isFocus) && !this.__closeTimeout) {
|
|
532
|
-
this.__warmupTooltip(isFocus);
|
|
533
|
-
} else {
|
|
534
|
-
this.__showTooltip();
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Schedule closing the tooltip.
|
|
540
|
-
* @param {boolean} immediate
|
|
541
|
-
* @protected
|
|
542
|
-
*/
|
|
543
|
-
_close(immediate) {
|
|
544
|
-
if (!immediate && this.__getHideDelay() > 0) {
|
|
545
|
-
this.__scheduleClose();
|
|
546
|
-
} else {
|
|
547
|
-
this.__abortClose();
|
|
548
|
-
this._autoOpened = false;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
this.__abortWarmUp();
|
|
552
|
-
|
|
553
|
-
if (warmedUp) {
|
|
554
|
-
// Re-start cooldown timer on each tooltip closing.
|
|
555
|
-
this.__abortCooldown();
|
|
556
|
-
this.__scheduleCooldown();
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/** @private */
|
|
561
|
-
__getFocusDelay() {
|
|
562
|
-
return this.focusDelay != null && this.focusDelay > 0 ? this.focusDelay : defaultFocusDelay;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/** @private */
|
|
566
|
-
__getHoverDelay() {
|
|
567
|
-
return this.hoverDelay != null && this.hoverDelay > 0 ? this.hoverDelay : defaultHoverDelay;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/** @private */
|
|
571
|
-
__getHideDelay() {
|
|
572
|
-
return this.hideDelay != null && this.hideDelay > 0 ? this.hideDelay : defaultHideDelay;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/** @private */
|
|
576
|
-
__flushClosingTooltips() {
|
|
577
|
-
closing.forEach((tooltip) => {
|
|
578
|
-
tooltip._close(true);
|
|
579
|
-
closing.delete(tooltip);
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/** @private */
|
|
584
|
-
__showTooltip() {
|
|
585
|
-
this.__abortClose();
|
|
586
|
-
this.__flushClosingTooltips();
|
|
587
|
-
|
|
588
|
-
this._autoOpened = true;
|
|
589
|
-
warmedUp = true;
|
|
590
|
-
|
|
591
|
-
// Abort previously scheduled timers.
|
|
592
|
-
this.__abortWarmUp();
|
|
593
|
-
this.__abortCooldown();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/** @private */
|
|
597
|
-
__warmupTooltip(isFocus) {
|
|
598
|
-
if (!this._autoOpened) {
|
|
599
|
-
// First tooltip is opened, warm up.
|
|
600
|
-
if (!warmedUp) {
|
|
601
|
-
this.__scheduleWarmUp(isFocus);
|
|
602
|
-
} else {
|
|
603
|
-
// Warmed up, show another tooltip.
|
|
604
|
-
this.__showTooltip();
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/** @private */
|
|
610
|
-
__abortClose() {
|
|
611
|
-
if (this.__closeTimeout) {
|
|
612
|
-
clearTimeout(this.__closeTimeout);
|
|
613
|
-
this.__closeTimeout = null;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/** @private */
|
|
618
|
-
__abortCooldown() {
|
|
619
|
-
if (cooldownTimeout) {
|
|
620
|
-
clearTimeout(cooldownTimeout);
|
|
621
|
-
cooldownTimeout = null;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/** @private */
|
|
626
|
-
__abortWarmUp() {
|
|
627
|
-
if (warmUpTimeout) {
|
|
628
|
-
clearTimeout(warmUpTimeout);
|
|
629
|
-
warmUpTimeout = null;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
/** @private */
|
|
634
|
-
__scheduleClose() {
|
|
635
|
-
if (this._autoOpened) {
|
|
636
|
-
closing.add(this);
|
|
637
|
-
|
|
638
|
-
this.__closeTimeout = setTimeout(() => {
|
|
639
|
-
closing.delete(this);
|
|
640
|
-
this.__closeTimeout = null;
|
|
641
|
-
this._autoOpened = false;
|
|
642
|
-
}, this.__getHideDelay());
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/** @private */
|
|
647
|
-
__scheduleCooldown() {
|
|
648
|
-
cooldownTimeout = setTimeout(() => {
|
|
649
|
-
cooldownTimeout = null;
|
|
650
|
-
warmedUp = false;
|
|
651
|
-
}, this.__getHideDelay());
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/** @private */
|
|
655
|
-
__scheduleWarmUp(isFocus) {
|
|
656
|
-
const delay = isFocus ? this.__getFocusDelay() : this.__getHoverDelay();
|
|
657
|
-
warmUpTimeout = setTimeout(() => {
|
|
658
|
-
warmUpTimeout = null;
|
|
659
|
-
warmedUp = true;
|
|
660
|
-
this.__showTooltip();
|
|
661
|
-
}, delay);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
740
|
/** @private */
|
|
665
741
|
__textChanged(text, oldText) {
|
|
666
742
|
if (this._overlayElement && (text || oldText)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
2
2
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
3
|
+
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
3
4
|
import { overlay } from '@vaadin/vaadin-lumo-styles/mixins/overlay.js';
|
|
4
5
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
6
|
|
|
@@ -12,9 +13,10 @@ const tooltipOverlay = css`
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
[part='overlay'] {
|
|
15
|
-
background-color
|
|
16
|
-
color: var(--lumo-
|
|
16
|
+
background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
|
|
17
|
+
color: var(--lumo-body-text-color);
|
|
17
18
|
font-size: var(--lumo-font-size-xs);
|
|
19
|
+
line-height: var(--lumo-line-height-s);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
[part='content'] {
|
package/web-types.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/tooltip",
|
|
4
|
-
"version": "23.3.0-
|
|
4
|
+
"version": "23.3.0-alpha4",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-tooltip",
|
|
11
|
-
"description": "`<vaadin-tooltip>` is a Web Component for creating tooltips.\n\n```html\n<button id=\"confirm\">Confirm</button>\n<vaadin-tooltip text=\"Click to save changes\" for=\"confirm\"></vaadin-tooltip>\n```\n\n### Styling\n\n`<vaadin-tooltip>` uses `<vaadin-tooltip-overlay>` internal\nthemable component as the actual visible overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-
|
|
11
|
+
"description": "`<vaadin-tooltip>` is a Web Component for creating tooltips.\n\n```html\n<button id=\"confirm\">Confirm</button>\n<vaadin-tooltip text=\"Click to save changes\" for=\"confirm\"></vaadin-tooltip>\n```\n\n### Styling\n\n`<vaadin-tooltip>` uses `<vaadin-tooltip-overlay>` internal\nthemable component as the actual visible overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha4/#/elements/vaadin-overlay) documentation\nfor `<vaadin-tooltip-overlay>` parts.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|----------------------------------------\n`position` | Reflects the `position` property value.\n\nNote: the `theme` attribute value set on `<vaadin-tooltip>` is\npropagated to the internal `<vaadin-tooltip-overlay>` component.\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available on the `<vaadin-tooltip>` element:\n\nCustom CSS property | Description\n---------------------------------|-------------\n`--vaadin-tooltip-offset-top` | Used as an offset when the tooltip is aligned vertically below the target\n`--vaadin-tooltip-offset-bottom` | Used as an offset when the tooltip is aligned vertically above the target\n`--vaadin-tooltip-offset-start` | Used as an offset when the tooltip is aligned horizontally after the target\n`--vaadin-tooltip-offset-end` | Used as an offset when the tooltip is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "focus-delay",
|
|
15
|
-
"description": "The delay in milliseconds before the tooltip\nis opened on focus, when not in manual mode.",
|
|
15
|
+
"description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
|
|
16
16
|
"value": {
|
|
17
17
|
"type": [
|
|
18
18
|
"number",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
"name": "focusDelay",
|
|
128
|
-
"description": "The delay in milliseconds before the tooltip\nis opened on focus, when not in manual mode.",
|
|
128
|
+
"description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
|
|
129
129
|
"value": {
|
|
130
130
|
"type": [
|
|
131
131
|
"number",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/tooltip",
|
|
4
|
-
"version": "23.3.0-
|
|
4
|
+
"version": "23.3.0-alpha4",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-tooltip",
|
|
19
|
-
"description": "`<vaadin-tooltip>` is a Web Component for creating tooltips.\n\n```html\n<button id=\"confirm\">Confirm</button>\n<vaadin-tooltip text=\"Click to save changes\" for=\"confirm\"></vaadin-tooltip>\n```\n\n### Styling\n\n`<vaadin-tooltip>` uses `<vaadin-tooltip-overlay>` internal\nthemable component as the actual visible overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-
|
|
19
|
+
"description": "`<vaadin-tooltip>` is a Web Component for creating tooltips.\n\n```html\n<button id=\"confirm\">Confirm</button>\n<vaadin-tooltip text=\"Click to save changes\" for=\"confirm\"></vaadin-tooltip>\n```\n\n### Styling\n\n`<vaadin-tooltip>` uses `<vaadin-tooltip-overlay>` internal\nthemable component as the actual visible overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha4/#/elements/vaadin-overlay) documentation\nfor `<vaadin-tooltip-overlay>` parts.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|----------------------------------------\n`position` | Reflects the `position` property value.\n\nNote: the `theme` attribute value set on `<vaadin-tooltip>` is\npropagated to the internal `<vaadin-tooltip-overlay>` component.\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available on the `<vaadin-tooltip>` element:\n\nCustom CSS property | Description\n---------------------------------|-------------\n`--vaadin-tooltip-offset-top` | Used as an offset when the tooltip is aligned vertically below the target\n`--vaadin-tooltip-offset-bottom` | Used as an offset when the tooltip is aligned vertically above the target\n`--vaadin-tooltip-offset-start` | Used as an offset when the tooltip is aligned horizontally after the target\n`--vaadin-tooltip-offset-end` | Used as an offset when the tooltip is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"name": ".focusDelay",
|
|
45
|
-
"description": "The delay in milliseconds before the tooltip\nis opened on focus, when not in manual mode.",
|
|
45
|
+
"description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
48
48
|
}
|