@vaadin/tooltip 24.4.6 → 24.5.0-alpha10

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
@@ -50,7 +50,7 @@ import '@vaadin/tooltip/src/vaadin-tooltip.js';
50
50
 
51
51
  ## Contributing
52
52
 
53
- Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
53
+ Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
54
54
 
55
55
  ## License
56
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/tooltip",
3
- "version": "24.4.6",
3
+ "version": "24.5.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,21 +36,23 @@
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/a11y-base": "~24.4.6",
40
- "@vaadin/component-base": "~24.4.6",
41
- "@vaadin/overlay": "~24.4.6",
42
- "@vaadin/vaadin-lumo-styles": "~24.4.6",
43
- "@vaadin/vaadin-material-styles": "~24.4.6",
44
- "@vaadin/vaadin-themable-mixin": "~24.4.6"
39
+ "@vaadin/a11y-base": "24.5.0-alpha10",
40
+ "@vaadin/component-base": "24.5.0-alpha10",
41
+ "@vaadin/overlay": "24.5.0-alpha10",
42
+ "@vaadin/popover": "24.5.0-alpha10",
43
+ "@vaadin/vaadin-lumo-styles": "24.5.0-alpha10",
44
+ "@vaadin/vaadin-material-styles": "24.5.0-alpha10",
45
+ "@vaadin/vaadin-themable-mixin": "24.5.0-alpha10",
46
+ "lit": "^3.0.0"
45
47
  },
46
48
  "devDependencies": {
47
- "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/testing-helpers": "^0.6.0",
49
- "sinon": "^13.0.2"
49
+ "@vaadin/chai-plugins": "24.5.0-alpha10",
50
+ "@vaadin/testing-helpers": "^1.0.0",
51
+ "sinon": "^18.0.0"
50
52
  },
51
53
  "web-types": [
52
54
  "web-types.json",
53
55
  "web-types.lit.json"
54
56
  ],
55
- "gitHead": "46d3cdb72eb99d544c7bb86c3de95043b9e5857f"
57
+ "gitHead": "6f9c37308031af872a98017bfab4de89aeacda51"
56
58
  }
@@ -8,8 +8,8 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
10
  import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
11
+ import { PopoverOverlayMixin } from '@vaadin/popover/src/vaadin-popover-overlay-mixin.js';
11
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
- import { TooltipOverlayMixin } from './vaadin-tooltip-overlay-mixin.js';
13
13
  import { tooltipOverlayStyles } from './vaadin-tooltip-overlay-styles.js';
14
14
 
15
15
  /**
@@ -19,10 +19,10 @@ import { tooltipOverlayStyles } from './vaadin-tooltip-overlay-styles.js';
19
19
  * @extends HTMLElement
20
20
  * @mixes DirMixin
21
21
  * @mixes ThemableMixin
22
- * @mixes TooltipOverlayMixin
22
+ * @mixes PopoverOverlayMixin
23
23
  * @private
24
24
  */
25
- class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))) {
25
+ class TooltipOverlay extends PopoverOverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))) {
26
26
  static get is() {
27
27
  return 'vaadin-tooltip-overlay';
28
28
  }
@@ -31,6 +31,15 @@ class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolylitM
31
31
  return [overlayStyles, tooltipOverlayStyles];
32
32
  }
33
33
 
34
+ /**
35
+ * Tag name prefix used by custom properties.
36
+ * @protected
37
+ * @return {string}
38
+ */
39
+ get _tagNamePrefix() {
40
+ return 'vaadin-tooltip';
41
+ }
42
+
34
43
  /** @protected */
35
44
  render() {
36
45
  return html`
@@ -40,6 +49,12 @@ class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolylitM
40
49
  </div>
41
50
  `;
42
51
  }
52
+
53
+ requestContentUpdate() {
54
+ super.requestContentUpdate();
55
+
56
+ this.toggleAttribute('hidden', this.textContent.trim() === '');
57
+ }
43
58
  }
44
59
 
45
60
  defineCustomElement(TooltipOverlay);
@@ -5,27 +5,21 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
8
+ import type { PopoverPositionMixinClass } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
9
+ import type { PopoverTargetMixinClass } from '@vaadin/popover/src/vaadin-popover-target-mixin.js';
8
10
 
9
- export type TooltipPosition =
10
- | 'bottom-end'
11
- | 'bottom-start'
12
- | 'bottom'
13
- | 'end-bottom'
14
- | 'end-top'
15
- | 'end'
16
- | 'start-bottom'
17
- | 'start-top'
18
- | 'start'
19
- | 'top-end'
20
- | 'top-start'
21
- | 'top';
11
+ export type { PopoverPosition as TooltipPosition } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
22
12
 
23
13
  /**
24
14
  * A mixin providing common tooltip functionality.
25
15
  */
26
16
  export declare function TooltipMixin<T extends Constructor<HTMLElement>>(
27
17
  base: T,
28
- ): Constructor<OverlayClassMixinClass> & Constructor<TooltipMixinClass> & T;
18
+ ): Constructor<OverlayClassMixinClass> &
19
+ Constructor<PopoverPositionMixinClass> &
20
+ Constructor<PopoverTargetMixinClass> &
21
+ Constructor<TooltipMixinClass> &
22
+ T;
29
23
 
30
24
  export declare class TooltipMixinClass {
31
25
  /**
@@ -49,13 +43,6 @@ export declare class TooltipMixinClass {
49
43
  */
50
44
  focusDelay: number;
51
45
 
52
- /**
53
- * The id of the element used as a tooltip trigger.
54
- * The element should be in the DOM by the time when
55
- * the attribute is set, otherwise a warning is shown.
56
- */
57
- for: string | undefined;
58
-
59
46
  /**
60
47
  * Function used to generate the tooltip content.
61
48
  * When provided, it overrides the `text` property.
@@ -91,14 +78,6 @@ export declare class TooltipMixinClass {
91
78
  */
92
79
  opened: boolean;
93
80
 
94
- /**
95
- * Position of the tooltip with respect to its target.
96
- * Supported values: `top-start`, `top`, `top-end`,
97
- * `bottom-start`, `bottom`, `bottom-end`, `start-top`,
98
- * `start`, `start-bottom`, `end-top`, `end`, `end-bottom`.
99
- */
100
- position: TooltipPosition;
101
-
102
81
  /**
103
82
  * Function used to detect whether to show the tooltip based on a condition,
104
83
  * called every time the tooltip is about to be shown on hover and focus.
@@ -108,13 +87,6 @@ export declare class TooltipMixinClass {
108
87
  */
109
88
  shouldShow: (target: HTMLElement, context?: Record<string, unknown>) => boolean;
110
89
 
111
- /**
112
- * Reference to the element used as a tooltip trigger.
113
- * The target must be placed in the same shadow scope.
114
- * Defaults to an element referenced with `for`.
115
- */
116
- target: HTMLElement | undefined;
117
-
118
90
  /**
119
91
  * String used as a tooltip content.
120
92
  */
@@ -4,12 +4,12 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
7
- import { microTask } from '@vaadin/component-base/src/async.js';
8
- import { Debouncer } from '@vaadin/component-base/src/debounce.js';
9
7
  import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
10
8
  import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
9
  import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
12
10
  import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
11
+ import { PopoverPositionMixin } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
12
+ import { PopoverTargetMixin } from '@vaadin/popover/src/vaadin-popover-target-mixin.js';
13
13
 
14
14
  const DEFAULT_DELAY = 500;
15
15
 
@@ -216,9 +216,11 @@ class TooltipStateController {
216
216
  *
217
217
  * @polymerMixin
218
218
  * @mixes OverlayClassMixin
219
+ * @mixes PopoverPositionMixin
220
+ * @mixes PopoverTargetMixin
219
221
  */
220
222
  export const TooltipMixin = (superClass) =>
221
- class TooltipMixinClass extends OverlayClassMixin(superClass) {
223
+ class TooltipMixinClass extends PopoverPositionMixin(PopoverTargetMixin(OverlayClassMixin(superClass))) {
222
224
  static get properties() {
223
225
  return {
224
226
  /**
@@ -251,16 +253,6 @@ export const TooltipMixin = (superClass) =>
251
253
  type: Number,
252
254
  },
253
255
 
254
- /**
255
- * The id of the element used as a tooltip trigger.
256
- * The element should be in the DOM by the time when
257
- * the attribute is set, otherwise a warning is shown.
258
- */
259
- for: {
260
- type: String,
261
- observer: '__forChanged',
262
- },
263
-
264
256
  /**
265
257
  * Function used to generate the tooltip content.
266
258
  * When provided, it overrides the `text` property.
@@ -310,16 +302,6 @@ export const TooltipMixin = (superClass) =>
310
302
  sync: true,
311
303
  },
312
304
 
313
- /**
314
- * Position of the tooltip with respect to its target.
315
- * Supported values: `top-start`, `top`, `top-end`,
316
- * `bottom-start`, `bottom`, `bottom-end`, `start-top`,
317
- * `start`, `start-bottom`, `end-top`, `end`, `end-bottom`.
318
- */
319
- position: {
320
- type: String,
321
- },
322
-
323
305
  /**
324
306
  * Function used to detect whether to show the tooltip based on a condition,
325
307
  * called every time the tooltip is about to be shown on hover and focus.
@@ -334,16 +316,6 @@ export const TooltipMixin = (superClass) =>
334
316
  },
335
317
  },
336
318
 
337
- /**
338
- * Reference to the element used as a tooltip trigger.
339
- * The target must be placed in the same shadow scope.
340
- * Defaults to an element referenced with `for`.
341
- */
342
- target: {
343
- type: Object,
344
- observer: '__targetChanged',
345
- },
346
-
347
319
  /**
348
320
  * String used as a tooltip content.
349
321
  */
@@ -374,12 +346,6 @@ export const TooltipMixin = (superClass) =>
374
346
  observer: '__effectiveAriaTargetChanged',
375
347
  },
376
348
 
377
- /** @private */
378
- __effectivePosition: {
379
- type: String,
380
- computed: '__computePosition(position, _position)',
381
- },
382
-
383
349
  /** @private */
384
350
  __isTargetHidden: {
385
351
  type: Boolean,
@@ -392,15 +358,6 @@ export const TooltipMixin = (superClass) =>
392
358
  sync: true,
393
359
  },
394
360
 
395
- /**
396
- * Default value used when `position` property is not set.
397
- * @protected
398
- */
399
- _position: {
400
- type: String,
401
- value: 'bottom',
402
- },
403
-
404
361
  /** @private */
405
362
  _srLabel: {
406
363
  type: Object,
@@ -509,36 +466,11 @@ export const TooltipMixin = (superClass) =>
509
466
  this.addController(this._srLabelController);
510
467
  }
511
468
 
512
- /** @private */
513
- __computeHorizontalAlign(position) {
514
- return ['top-end', 'bottom-end', 'start-top', 'start', 'start-bottom'].includes(position) ? 'end' : 'start';
515
- }
516
-
517
- /** @private */
518
- __computeNoHorizontalOverlap(position) {
519
- return ['start-top', 'start', 'start-bottom', 'end-top', 'end', 'end-bottom'].includes(position);
520
- }
521
-
522
- /** @private */
523
- __computeNoVerticalOverlap(position) {
524
- return ['top-start', 'top-end', 'top', 'bottom-start', 'bottom', 'bottom-end'].includes(position);
525
- }
526
-
527
- /** @private */
528
- __computeVerticalAlign(position) {
529
- return ['top-start', 'top-end', 'top', 'start-bottom', 'end-bottom'].includes(position) ? 'bottom' : 'top';
530
- }
531
-
532
469
  /** @private */
533
470
  __computeOpened(manual, opened, autoOpened, connected) {
534
471
  return connected && (manual ? opened : autoOpened);
535
472
  }
536
473
 
537
- /** @private */
538
- __computePosition(position, defaultPosition) {
539
- return position || defaultPosition;
540
- }
541
-
542
474
  /** @private */
543
475
  __autoOpenedChanged(opened, oldOpened) {
544
476
  if (opened) {
@@ -548,54 +480,37 @@ export const TooltipMixin = (superClass) =>
548
480
  }
549
481
  }
550
482
 
551
- /** @private */
552
- __forChanged(forId) {
553
- if (forId) {
554
- this.__setTargetByIdDebouncer = Debouncer.debounce(this.__setTargetByIdDebouncer, microTask, () =>
555
- this.__setTargetById(forId),
556
- );
557
- }
558
- }
559
-
560
- /** @private */
561
- __setTargetById(targetId) {
562
- if (!this.isConnected) {
563
- return;
564
- }
565
-
566
- const target = this.getRootNode().getElementById(targetId);
567
-
568
- if (target) {
569
- this.target = target;
570
- } else {
571
- console.warn(`No element with id="${targetId}" found to show tooltip.`);
572
- }
483
+ /**
484
+ * @param {HTMLElement} target
485
+ * @protected
486
+ * @override
487
+ */
488
+ _addTargetListeners(target) {
489
+ target.addEventListener('mouseenter', this.__onMouseEnter);
490
+ target.addEventListener('mouseleave', this.__onMouseLeave);
491
+ target.addEventListener('focusin', this.__onFocusin);
492
+ target.addEventListener('focusout', this.__onFocusout);
493
+ target.addEventListener('mousedown', this.__onMouseDown);
494
+
495
+ // Wait before observing to avoid Chrome issue.
496
+ requestAnimationFrame(() => {
497
+ this.__targetVisibilityObserver.observe(target);
498
+ });
573
499
  }
574
500
 
575
- /** @private */
576
- __targetChanged(target, oldTarget) {
577
- if (oldTarget) {
578
- oldTarget.removeEventListener('mouseenter', this.__onMouseEnter);
579
- oldTarget.removeEventListener('mouseleave', this.__onMouseLeave);
580
- oldTarget.removeEventListener('focusin', this.__onFocusin);
581
- oldTarget.removeEventListener('focusout', this.__onFocusout);
582
- oldTarget.removeEventListener('mousedown', this.__onMouseDown);
583
-
584
- this.__targetVisibilityObserver.unobserve(oldTarget);
585
- }
586
-
587
- if (target) {
588
- target.addEventListener('mouseenter', this.__onMouseEnter);
589
- target.addEventListener('mouseleave', this.__onMouseLeave);
590
- target.addEventListener('focusin', this.__onFocusin);
591
- target.addEventListener('focusout', this.__onFocusout);
592
- target.addEventListener('mousedown', this.__onMouseDown);
593
-
594
- // Wait before observing to avoid Chrome issue.
595
- requestAnimationFrame(() => {
596
- this.__targetVisibilityObserver.observe(target);
597
- });
598
- }
501
+ /**
502
+ * @param {HTMLElement} target
503
+ * @protected
504
+ * @override
505
+ */
506
+ _removeTargetListeners(target) {
507
+ target.removeEventListener('mouseenter', this.__onMouseEnter);
508
+ target.removeEventListener('mouseleave', this.__onMouseLeave);
509
+ target.removeEventListener('focusin', this.__onFocusin);
510
+ target.removeEventListener('focusout', this.__onFocusout);
511
+ target.removeEventListener('mousedown', this.__onMouseDown);
512
+
513
+ this.__targetVisibilityObserver.unobserve(target);
599
514
  }
600
515
 
601
516
  /** @private */
@@ -7,8 +7,8 @@ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
9
  import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
10
+ import { PopoverOverlayMixin } from '@vaadin/popover/src/vaadin-popover-overlay-mixin.js';
10
11
  import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
- import { TooltipOverlayMixin } from './vaadin-tooltip-overlay-mixin.js';
12
12
  import { tooltipOverlayStyles } from './vaadin-tooltip-overlay-styles.js';
13
13
 
14
14
  registerStyles('vaadin-tooltip-overlay', [overlayStyles, tooltipOverlayStyles], {
@@ -22,10 +22,10 @@ registerStyles('vaadin-tooltip-overlay', [overlayStyles, tooltipOverlayStyles],
22
22
  * @extends HTMLElement
23
23
  * @mixes DirMixin
24
24
  * @mixes ThemableMixin
25
- * @mixes TooltipOverlayMixin
25
+ * @mixes PopoverOverlayMixin
26
26
  * @private
27
27
  */
28
- class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolymerElement))) {
28
+ class TooltipOverlay extends PopoverOverlayMixin(DirMixin(ThemableMixin(PolymerElement))) {
29
29
  static get is() {
30
30
  return 'vaadin-tooltip-overlay';
31
31
  }
@@ -39,6 +39,15 @@ class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolymerE
39
39
  `;
40
40
  }
41
41
 
42
+ /**
43
+ * Tag name prefix used by custom properties.
44
+ * @protected
45
+ * @return {string}
46
+ */
47
+ get _tagNamePrefix() {
48
+ return 'vaadin-tooltip';
49
+ }
50
+
42
51
  /** @protected */
43
52
  ready() {
44
53
  super.ready();
@@ -49,6 +58,12 @@ class TooltipOverlay extends TooltipOverlayMixin(DirMixin(ThemableMixin(PolymerE
49
58
  this.owner = this.__dataHost;
50
59
  this.owner._overlayElement = this;
51
60
  }
61
+
62
+ requestContentUpdate() {
63
+ super.requestContentUpdate();
64
+
65
+ this.toggleAttribute('hidden', this.textContent.trim() === '');
66
+ }
52
67
  }
53
68
 
54
69
  defineCustomElement(TooltipOverlay);
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "24.4.6",
4
+ "version": "24.5.0-alpha10",
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/24.4.6/#/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/styling-components) documentation.",
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/24.5.0-alpha10/#/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/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "overlay-class",
@@ -22,11 +22,11 @@
22
22
  }
23
23
  },
24
24
  {
25
- "name": "focus-delay",
26
- "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
25
+ "name": "position",
26
+ "description": "Position of the overlay with respect to the target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
27
27
  "value": {
28
28
  "type": [
29
- "number",
29
+ "string",
30
30
  "null",
31
31
  "undefined"
32
32
  ]
@@ -34,7 +34,7 @@
34
34
  },
35
35
  {
36
36
  "name": "for",
37
- "description": "The id of the element used as a tooltip trigger.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
37
+ "description": "The id of the element to be used as `target` value.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
38
38
  "value": {
39
39
  "type": [
40
40
  "string",
@@ -43,6 +43,17 @@
43
43
  ]
44
44
  }
45
45
  },
46
+ {
47
+ "name": "focus-delay",
48
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
49
+ "value": {
50
+ "type": [
51
+ "number",
52
+ "null",
53
+ "undefined"
54
+ ]
55
+ }
56
+ },
46
57
  {
47
58
  "name": "hide-delay",
48
59
  "description": "The delay in milliseconds before the tooltip\nis closed on losing hover, when not in manual mode.\nOn blur, the tooltip is closed immediately.",
@@ -87,17 +98,6 @@
87
98
  ]
88
99
  }
89
100
  },
90
- {
91
- "name": "position",
92
- "description": "Position of the tooltip with respect to its target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
93
- "value": {
94
- "type": [
95
- "string",
96
- "null",
97
- "undefined"
98
- ]
99
- }
100
- },
101
101
  {
102
102
  "name": "text",
103
103
  "description": "String used as a tooltip content.",
@@ -135,8 +135,30 @@
135
135
  }
136
136
  },
137
137
  {
138
- "name": "ariaTarget",
139
- "description": "Element used to link with the `aria-describedby`\nattribute. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
138
+ "name": "position",
139
+ "description": "Position of the overlay with respect to the target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
140
+ "value": {
141
+ "type": [
142
+ "string",
143
+ "null",
144
+ "undefined"
145
+ ]
146
+ }
147
+ },
148
+ {
149
+ "name": "for",
150
+ "description": "The id of the element to be used as `target` value.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
151
+ "value": {
152
+ "type": [
153
+ "string",
154
+ "null",
155
+ "undefined"
156
+ ]
157
+ }
158
+ },
159
+ {
160
+ "name": "target",
161
+ "description": "Reference to the DOM element used both to trigger the overlay\nby user interaction and to visually position it on the screen.\n\nDefaults to an element referenced with `for` attribute, in\nwhich case it must be located in the same shadow scope.",
140
162
  "value": {
141
163
  "type": [
142
164
  "Object",
@@ -146,8 +168,8 @@
146
168
  }
147
169
  },
148
170
  {
149
- "name": "context",
150
- "description": "Object with properties passed to `generator` and\n`shouldShow` functions for generating tooltip text\nor detecting whether to show the tooltip or not.",
171
+ "name": "ariaTarget",
172
+ "description": "Element used to link with the `aria-describedby`\nattribute. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
151
173
  "value": {
152
174
  "type": [
153
175
  "Object",
@@ -157,22 +179,22 @@
157
179
  }
158
180
  },
159
181
  {
160
- "name": "focusDelay",
161
- "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
182
+ "name": "context",
183
+ "description": "Object with properties passed to `generator` and\n`shouldShow` functions for generating tooltip text\nor detecting whether to show the tooltip or not.",
162
184
  "value": {
163
185
  "type": [
164
- "number",
186
+ "Object",
165
187
  "null",
166
188
  "undefined"
167
189
  ]
168
190
  }
169
191
  },
170
192
  {
171
- "name": "for",
172
- "description": "The id of the element used as a tooltip trigger.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
193
+ "name": "focusDelay",
194
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
173
195
  "value": {
174
196
  "type": [
175
- "string",
197
+ "number",
176
198
  "null",
177
199
  "undefined"
178
200
  ]
@@ -233,17 +255,6 @@
233
255
  ]
234
256
  }
235
257
  },
236
- {
237
- "name": "position",
238
- "description": "Position of the tooltip with respect to its target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
239
- "value": {
240
- "type": [
241
- "string",
242
- "null",
243
- "undefined"
244
- ]
245
- }
246
- },
247
258
  {
248
259
  "name": "shouldShow",
249
260
  "description": "Function used to detect whether to show the tooltip based on a condition,\ncalled every time the tooltip is about to be shown on hover and focus.\nThe function takes two parameters: `target` and `context`, which contain\nvalues of the corresponding tooltip properties at the time of calling.\nThe tooltip is only shown when the function invocation returns `true`.",
@@ -255,17 +266,6 @@
255
266
  ]
256
267
  }
257
268
  },
258
- {
259
- "name": "target",
260
- "description": "Reference to the element used as a tooltip trigger.\nThe target must be placed in the same shadow scope.\nDefaults to an element referenced with `for`.",
261
- "value": {
262
- "type": [
263
- "Object",
264
- "null",
265
- "undefined"
266
- ]
267
- }
268
- },
269
269
  {
270
270
  "name": "text",
271
271
  "description": "String used as a tooltip content.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "24.4.6",
4
+ "version": "24.5.0-alpha10",
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/24.4.6/#/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/styling-components) documentation.",
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/24.5.0-alpha10/#/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/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -41,71 +41,71 @@
41
41
  }
42
42
  },
43
43
  {
44
- "name": ".ariaTarget",
45
- "description": "Element used to link with the `aria-describedby`\nattribute. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
44
+ "name": ".position",
45
+ "description": "Position of the overlay with respect to the target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
46
46
  "value": {
47
47
  "kind": "expression"
48
48
  }
49
49
  },
50
50
  {
51
- "name": ".context",
52
- "description": "Object with properties passed to `generator` and\n`shouldShow` functions for generating tooltip text\nor detecting whether to show the tooltip or not.",
51
+ "name": ".for",
52
+ "description": "The id of the element to be used as `target` value.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
53
53
  "value": {
54
54
  "kind": "expression"
55
55
  }
56
56
  },
57
57
  {
58
- "name": ".focusDelay",
59
- "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
58
+ "name": ".target",
59
+ "description": "Reference to the DOM element used both to trigger the overlay\nby user interaction and to visually position it on the screen.\n\nDefaults to an element referenced with `for` attribute, in\nwhich case it must be located in the same shadow scope.",
60
60
  "value": {
61
61
  "kind": "expression"
62
62
  }
63
63
  },
64
64
  {
65
- "name": ".for",
66
- "description": "The id of the element used as a tooltip trigger.\nThe element should be in the DOM by the time when\nthe attribute is set, otherwise a warning is shown.",
65
+ "name": ".ariaTarget",
66
+ "description": "Element used to link with the `aria-describedby`\nattribute. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
67
67
  "value": {
68
68
  "kind": "expression"
69
69
  }
70
70
  },
71
71
  {
72
- "name": ".generator",
73
- "description": "Function used to generate the tooltip content.\nWhen provided, it overrides the `text` property.\nUse the `context` property to provide argument\nthat can be passed to the generator function.",
72
+ "name": ".context",
73
+ "description": "Object with properties passed to `generator` and\n`shouldShow` functions for generating tooltip text\nor detecting whether to show the tooltip or not.",
74
74
  "value": {
75
75
  "kind": "expression"
76
76
  }
77
77
  },
78
78
  {
79
- "name": ".hideDelay",
80
- "description": "The delay in milliseconds before the tooltip\nis closed on losing hover, when not in manual mode.\nOn blur, the tooltip is closed immediately.",
79
+ "name": ".focusDelay",
80
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
81
81
  "value": {
82
82
  "kind": "expression"
83
83
  }
84
84
  },
85
85
  {
86
- "name": ".hoverDelay",
87
- "description": "The delay in milliseconds before the tooltip\nis opened on hover, when not in manual mode.",
86
+ "name": ".generator",
87
+ "description": "Function used to generate the tooltip content.\nWhen provided, it overrides the `text` property.\nUse the `context` property to provide argument\nthat can be passed to the generator function.",
88
88
  "value": {
89
89
  "kind": "expression"
90
90
  }
91
91
  },
92
92
  {
93
- "name": ".position",
94
- "description": "Position of the tooltip with respect to its target.\nSupported values: `top-start`, `top`, `top-end`,\n`bottom-start`, `bottom`, `bottom-end`, `start-top`,\n`start`, `start-bottom`, `end-top`, `end`, `end-bottom`.",
93
+ "name": ".hideDelay",
94
+ "description": "The delay in milliseconds before the tooltip\nis closed on losing hover, when not in manual mode.\nOn blur, the tooltip is closed immediately.",
95
95
  "value": {
96
96
  "kind": "expression"
97
97
  }
98
98
  },
99
99
  {
100
- "name": ".shouldShow",
101
- "description": "Function used to detect whether to show the tooltip based on a condition,\ncalled every time the tooltip is about to be shown on hover and focus.\nThe function takes two parameters: `target` and `context`, which contain\nvalues of the corresponding tooltip properties at the time of calling.\nThe tooltip is only shown when the function invocation returns `true`.",
100
+ "name": ".hoverDelay",
101
+ "description": "The delay in milliseconds before the tooltip\nis opened on hover, when not in manual mode.",
102
102
  "value": {
103
103
  "kind": "expression"
104
104
  }
105
105
  },
106
106
  {
107
- "name": ".target",
108
- "description": "Reference to the element used as a tooltip trigger.\nThe target must be placed in the same shadow scope.\nDefaults to an element referenced with `for`.",
107
+ "name": ".shouldShow",
108
+ "description": "Function used to detect whether to show the tooltip based on a condition,\ncalled every time the tooltip is about to be shown on hover and focus.\nThe function takes two parameters: `target` and `context`, which contain\nvalues of the corresponding tooltip properties at the time of calling.\nThe tooltip is only shown when the function invocation returns `true`.",
109
109
  "value": {
110
110
  "kind": "expression"
111
111
  }
@@ -1,86 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2024 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
7
- import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
8
-
9
- /**
10
- * A mixin providing common tooltip overlay functionality.
11
- *
12
- * @polymerMixin
13
- * @mixes PositionMixin
14
- * @mixes OverlayMixin
15
- */
16
- export const TooltipOverlayMixin = (superClass) =>
17
- class TooltipOverlayMixinClass extends PositionMixin(OverlayMixin(superClass)) {
18
- static get properties() {
19
- return {
20
- position: {
21
- type: String,
22
- reflectToAttribute: true,
23
- },
24
- };
25
- }
26
-
27
- requestContentUpdate() {
28
- super.requestContentUpdate();
29
-
30
- this.toggleAttribute('hidden', this.textContent.trim() === '');
31
-
32
- // Copy custom properties from the tooltip
33
- if (this.positionTarget && this.owner) {
34
- const style = getComputedStyle(this.owner);
35
- ['top', 'bottom', 'start', 'end'].forEach((prop) => {
36
- this.style.setProperty(
37
- `--vaadin-tooltip-offset-${prop}`,
38
- style.getPropertyValue(`--vaadin-tooltip-offset-${prop}`),
39
- );
40
- });
41
- }
42
- }
43
-
44
- /**
45
- * @protected
46
- * @override
47
- */
48
- _updatePosition() {
49
- super._updatePosition();
50
-
51
- if (!this.positionTarget) {
52
- return;
53
- }
54
-
55
- // Center the tooltip overlay horizontally
56
- if (this.position === 'bottom' || this.position === 'top') {
57
- const targetRect = this.positionTarget.getBoundingClientRect();
58
- const overlayRect = this.$.overlay.getBoundingClientRect();
59
-
60
- const offset = targetRect.width / 2 - overlayRect.width / 2;
61
-
62
- if (this.style.left) {
63
- const left = overlayRect.left + offset;
64
- if (left > 0) {
65
- this.style.left = `${left}px`;
66
- }
67
- }
68
-
69
- if (this.style.right) {
70
- const right = parseFloat(this.style.right) + offset;
71
- if (right > 0) {
72
- this.style.right = `${right}px`;
73
- }
74
- }
75
- }
76
-
77
- // Center the tooltip overlay vertically
78
- if (this.position === 'start' || this.position === 'end') {
79
- const targetRect = this.positionTarget.getBoundingClientRect();
80
- const overlayRect = this.$.overlay.getBoundingClientRect();
81
-
82
- const offset = targetRect.height / 2 - overlayRect.height / 2;
83
- this.style.top = `${overlayRect.top + offset}px`;
84
- }
85
- }
86
- };