@vaadin/tooltip 25.0.0-alpha9 → 25.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/tooltip",
3
- "version": "25.0.0-alpha9",
3
+ "version": "25.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,9 +21,6 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
- "!src/styles/*-base-styles.d.ts",
25
- "!src/styles/*-base-styles.js",
26
- "theme",
27
24
  "vaadin-*.d.ts",
28
25
  "vaadin-*.js",
29
26
  "web-types.json",
@@ -37,23 +34,24 @@
37
34
  ],
38
35
  "dependencies": {
39
36
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/a11y-base": "25.0.0-alpha9",
41
- "@vaadin/component-base": "25.0.0-alpha9",
42
- "@vaadin/overlay": "25.0.0-alpha9",
43
- "@vaadin/popover": "25.0.0-alpha9",
44
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
45
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
37
+ "@vaadin/a11y-base": "25.0.0-beta1",
38
+ "@vaadin/component-base": "25.0.0-beta1",
39
+ "@vaadin/markdown": "25.0.0-beta1",
40
+ "@vaadin/overlay": "25.0.0-beta1",
41
+ "@vaadin/popover": "25.0.0-beta1",
42
+ "@vaadin/vaadin-themable-mixin": "25.0.0-beta1",
46
43
  "lit": "^3.0.0"
47
44
  },
48
45
  "devDependencies": {
49
- "@vaadin/chai-plugins": "25.0.0-alpha9",
50
- "@vaadin/test-runner-commands": "25.0.0-alpha9",
46
+ "@vaadin/chai-plugins": "25.0.0-beta1",
47
+ "@vaadin/test-runner-commands": "25.0.0-beta1",
51
48
  "@vaadin/testing-helpers": "^2.0.0",
52
- "sinon": "^18.0.0"
49
+ "@vaadin/vaadin-lumo-styles": "25.0.0-beta1",
50
+ "sinon": "^21.0.0"
53
51
  },
54
52
  "web-types": [
55
53
  "web-types.json",
56
54
  "web-types.lit.json"
57
55
  ],
58
- "gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
56
+ "gitHead": "1d20cf54e582d1f2e209126d4586f8b4c01c50e0"
59
57
  }
@@ -3,12 +3,13 @@
3
3
  * Copyright (c) 2022 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import '@vaadin/component-base/src/style-props.js';
6
+ import '@vaadin/component-base/src/styles/style-props.js';
7
7
  import { css } from 'lit';
8
8
 
9
9
  export const tooltipOverlayStyles = css`
10
10
  :host {
11
11
  --_vaadin-tooltip-default-offset: 4px;
12
+ line-height: normal;
12
13
  }
13
14
 
14
15
  [part='overlay'] {
@@ -16,17 +17,18 @@ export const tooltipOverlayStyles = css`
16
17
  padding: var(--vaadin-tooltip-padding, var(--vaadin-padding-container));
17
18
  border-radius: var(--vaadin-tooltip-border-radius, var(--vaadin-radius-m));
18
19
  background: var(--vaadin-tooltip-background, var(--vaadin-background-color));
19
- color: var(--vaadin-tooltip-color, inherit);
20
+ color: var(--vaadin-tooltip-text-color, inherit);
20
21
  font-size: var(--vaadin-tooltip-font-size, 0.9em);
21
22
  font-weight: var(--vaadin-tooltip-font-weight, inherit);
22
23
  line-height: var(--vaadin-tooltip-line-height, inherit);
23
24
  border: 0;
24
25
  box-shadow:
25
- 0 0 0 var(--vaadin-tooltip-border-width, 1px) var(--vaadin-tooltip-border-color, var(--vaadin-border-color)),
26
- var(--vaadin-tooltip-box-shadow, 0 3px 8px -1px rgba(0, 0, 0, 0.2));
26
+ 0 0 0 var(--vaadin-tooltip-border-width, 1px)
27
+ var(--vaadin-tooltip-border-color, var(--vaadin-border-color-secondary)),
28
+ var(--vaadin-tooltip-shadow, 0 3px 8px -1px rgba(0, 0, 0, 0.2));
27
29
  }
28
30
 
29
- [part='content'] {
31
+ :host(:not([markdown])) [part='content'] {
30
32
  white-space: pre-wrap;
31
33
  }
32
34
 
@@ -52,7 +54,7 @@ export const tooltipOverlayStyles = css`
52
54
 
53
55
  @media (forced-colors: active) {
54
56
  [part='overlay'] {
55
- border: 1px dashed;
57
+ border: 1px dashed !important;
56
58
  }
57
59
  }
58
60
  `;
@@ -4,7 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
- import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
8
7
  import type { PopoverPositionMixinClass } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
9
8
  import type { PopoverTargetMixinClass } from '@vaadin/popover/src/vaadin-popover-target-mixin.js';
10
9
 
@@ -15,11 +14,7 @@ export type { PopoverPosition as TooltipPosition } from '@vaadin/popover/src/vaa
15
14
  */
16
15
  export declare function TooltipMixin<T extends Constructor<HTMLElement>>(
17
16
  base: T,
18
- ): Constructor<OverlayClassMixinClass> &
19
- Constructor<PopoverPositionMixinClass> &
20
- Constructor<PopoverTargetMixinClass> &
21
- Constructor<TooltipMixinClass> &
22
- T;
17
+ ): Constructor<PopoverPositionMixinClass> & Constructor<PopoverTargetMixinClass> & Constructor<TooltipMixinClass> & T;
23
18
 
24
19
  export declare class TooltipMixinClass {
25
20
  /**
@@ -27,7 +22,7 @@ export declare class TooltipMixinClass {
27
22
  * attribute. Supports array of multiple elements.
28
23
  * When not set, defaults to `target`.
29
24
  */
30
- ariaTarget: HTMLElement | HTMLElement[] | undefined;
25
+ ariaTarget: HTMLElement | HTMLElement[] | null | undefined;
31
26
 
32
27
  /**
33
28
  * Object with properties passed to `generator` and
@@ -73,8 +68,9 @@ export declare class TooltipMixinClass {
73
68
  manual: boolean;
74
69
 
75
70
  /**
76
- * When true, the tooltip is opened programmatically.
77
- * Only works if `manual` is set to `true`.
71
+ * When true, the tooltip is opened.
72
+ * In manual mode, this can be set programmatically.
73
+ * In automatic mode, this is set automatically by internal logic.
78
74
  */
79
75
  opened: boolean;
80
76
 
@@ -91,4 +87,13 @@ export declare class TooltipMixinClass {
91
87
  * String used as a tooltip content.
92
88
  */
93
89
  text: string | null | undefined;
90
+
91
+ /**
92
+ * When enabled, the tooltip text is rendered as Markdown.
93
+ *
94
+ * **Note:** Using Markdown is discouraged if accessibility of the tooltip
95
+ * content is essential, as semantics of the rendered HTML content
96
+ * (headers, lists, ...) will not be conveyed to assistive technologies.
97
+ */
98
+ markdown: boolean;
94
99
  }
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
7
7
  import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
8
- import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
9
8
  import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
9
  import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
11
10
  import { PopoverPositionMixin } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
@@ -45,11 +44,6 @@ class TooltipStateController {
45
44
  this.host = host;
46
45
  }
47
46
 
48
- /** @private */
49
- get openedProp() {
50
- return this.host.manual ? 'opened' : '_autoOpened';
51
- }
52
-
53
47
  /** @private */
54
48
  get focusDelay() {
55
49
  const tooltip = this.host;
@@ -115,12 +109,12 @@ class TooltipStateController {
115
109
 
116
110
  /** @private */
117
111
  _isOpened() {
118
- return this.host[this.openedProp];
112
+ return this.host.opened;
119
113
  }
120
114
 
121
115
  /** @private */
122
116
  _setOpened(opened) {
123
- this.host[this.openedProp] = opened;
117
+ this.host.opened = opened;
124
118
  }
125
119
 
126
120
  /** @private */
@@ -224,12 +218,11 @@ class TooltipStateController {
224
218
  * A mixin providing common tooltip functionality.
225
219
  *
226
220
  * @polymerMixin
227
- * @mixes OverlayClassMixin
228
221
  * @mixes PopoverPositionMixin
229
222
  * @mixes PopoverTargetMixin
230
223
  */
231
224
  export const TooltipMixin = (superClass) =>
232
- class TooltipMixinClass extends PopoverPositionMixin(PopoverTargetMixin(OverlayClassMixin(superClass))) {
225
+ class TooltipMixinClass extends PopoverPositionMixin(PopoverTargetMixin(superClass)) {
233
226
  static get properties() {
234
227
  return {
235
228
  /**
@@ -302,12 +295,15 @@ export const TooltipMixin = (superClass) =>
302
295
  },
303
296
 
304
297
  /**
305
- * When true, the tooltip is opened programmatically.
306
- * Only works if `manual` is set to `true`.
298
+ * When true, the tooltip is opened.
299
+ * In manual mode, this can be set programmatically.
300
+ * In automatic mode, this is set automatically by internal logic.
307
301
  */
308
302
  opened: {
309
303
  type: Boolean,
310
304
  value: false,
305
+ reflectToAttribute: true,
306
+ observer: '__openedChanged',
311
307
  sync: true,
312
308
  },
313
309
 
@@ -333,14 +329,16 @@ export const TooltipMixin = (superClass) =>
333
329
  },
334
330
 
335
331
  /**
336
- * Set to true when the overlay is opened using auto-added
337
- * event listeners: mouseenter and focusin (keyboard only).
338
- * @protected
332
+ * When enabled, the tooltip text is rendered as Markdown.
333
+ *
334
+ * **Note:** Using Markdown is discouraged if accessibility of the tooltip
335
+ * content is essential, as semantics of the rendered HTML content
336
+ * (headers, lists, ...) will not be conveyed to assistive technologies.
339
337
  */
340
- _autoOpened: {
338
+ markdown: {
341
339
  type: Boolean,
342
- observer: '__autoOpenedChanged',
343
- sync: true,
340
+ value: false,
341
+ reflectToAttribute: true,
344
342
  },
345
343
 
346
344
  /**
@@ -434,7 +432,7 @@ export const TooltipMixin = (superClass) =>
434
432
  disconnectedCallback() {
435
433
  super.disconnectedCallback();
436
434
 
437
- if (this._autoOpened) {
435
+ if (this.opened && !this.manual) {
438
436
  this._stateController.close(true);
439
437
  }
440
438
  this._isConnected = false;
@@ -462,14 +460,13 @@ export const TooltipMixin = (superClass) =>
462
460
  updated(props) {
463
461
  super.updated(props);
464
462
 
465
- if (props.has('text') || props.has('generator') || props.has('context')) {
463
+ if (props.has('text') || props.has('generator') || props.has('context') || props.has('markdown')) {
466
464
  this.__updateContent();
467
- this.$.overlay.toggleAttribute('hidden', this.__contentNode.textContent.trim() === '');
468
465
  }
469
466
  }
470
467
 
471
468
  /** @private */
472
- __autoOpenedChanged(opened, oldOpened) {
469
+ __openedChanged(opened, oldOpened) {
473
470
  if (opened) {
474
471
  document.addEventListener('keydown', this.__onKeyDown, true);
475
472
  } else if (oldOpened) {
@@ -532,7 +529,7 @@ export const TooltipMixin = (superClass) =>
532
529
 
533
530
  this.__focusInside = true;
534
531
 
535
- if (!this.__isTargetHidden && (!this.__hoverInside || !this._autoOpened)) {
532
+ if (!this.__isTargetHidden && (!this.__hoverInside || !this.opened)) {
536
533
  this._stateController.open({ focus: true });
537
534
  }
538
535
  }
@@ -557,6 +554,10 @@ export const TooltipMixin = (superClass) =>
557
554
 
558
555
  /** @private */
559
556
  __onKeyDown(event) {
557
+ if (this.manual) {
558
+ return;
559
+ }
560
+
560
561
  if (event.key === 'Escape') {
561
562
  event.stopPropagation();
562
563
  this._stateController.close(true);
@@ -589,7 +590,7 @@ export const TooltipMixin = (superClass) =>
589
590
 
590
591
  this.__hoverInside = true;
591
592
 
592
- if (!this.__isTargetHidden && (!this.__focusInside || !this._autoOpened)) {
593
+ if (!this.__isTargetHidden && (!this.__focusInside || !this.opened)) {
593
594
  this._stateController.open({ hover: true });
594
595
  }
595
596
  }
@@ -622,6 +623,20 @@ export const TooltipMixin = (superClass) =>
622
623
  }
623
624
  }
624
625
 
626
+ /** @protected */
627
+ __onOverlayMouseDown(event) {
628
+ // Prevent mousedown listeners from being called when
629
+ // the tooltip is slotted into the target element
630
+ event.stopPropagation();
631
+ }
632
+
633
+ /** @protected */
634
+ __onOverlayClick(event) {
635
+ // Prevent click listeners from being called when
636
+ // the tooltip is slotted into the target element
637
+ event.stopPropagation();
638
+ }
639
+
625
640
  /** @private */
626
641
  __handleMouseLeave() {
627
642
  if (this.manual) {
@@ -649,6 +664,10 @@ export const TooltipMixin = (superClass) =>
649
664
 
650
665
  /** @private */
651
666
  __onTargetVisibilityChange(isVisible) {
667
+ if (this.manual) {
668
+ return;
669
+ }
670
+
652
671
  const oldHidden = this.__isTargetHidden;
653
672
  this.__isTargetHidden = !isVisible;
654
673
 
@@ -659,7 +678,7 @@ export const TooltipMixin = (superClass) =>
659
678
  }
660
679
 
661
680
  // Close the overlay when the target is no longer fully visible.
662
- if (!isVisible && this._autoOpened) {
681
+ if (!isVisible && this.opened) {
663
682
  this._stateController.close(true);
664
683
  }
665
684
  }
@@ -674,15 +693,25 @@ export const TooltipMixin = (superClass) =>
674
693
  }
675
694
 
676
695
  /** @private */
677
- __updateContent() {
678
- this.__contentNode.textContent = typeof this.generator === 'function' ? this.generator(this.context) : this.text;
696
+ async __updateContent() {
697
+ const content = typeof this.generator === 'function' ? this.generator(this.context) : this.text;
698
+
699
+ if (this.markdown && content) {
700
+ const helpers = await this.constructor.__importMarkdownHelpers();
701
+ helpers.renderMarkdownToElement(this.__contentNode, content);
702
+ } else {
703
+ this.__contentNode.textContent = content || '';
704
+ }
705
+
706
+ this.$.overlay.toggleAttribute('hidden', this.__contentNode.textContent.trim() === '');
707
+ this.dispatchEvent(new CustomEvent('content-changed', { detail: { content: this.__contentNode.textContent } }));
679
708
  }
680
709
 
681
710
  /** @private */
682
711
  __computeAriaTarget(ariaTarget, target) {
683
712
  const isElementNode = (el) => el && el.nodeType === Node.ELEMENT_NODE;
684
713
  const isAriaTargetSet = Array.isArray(ariaTarget) ? ariaTarget.some(isElementNode) : ariaTarget;
685
- return isAriaTargetSet ? ariaTarget : target;
714
+ return ariaTarget === null || isAriaTargetSet ? ariaTarget : target;
686
715
  }
687
716
 
688
717
  /** @private */
@@ -699,4 +728,18 @@ export const TooltipMixin = (superClass) =>
699
728
  });
700
729
  }
701
730
  }
731
+
732
+ /** @private **/
733
+ static __importMarkdownHelpers() {
734
+ if (!this.__markdownHelpers) {
735
+ this.__markdownHelpers = import('@vaadin/markdown/src/markdown-helpers.js');
736
+ }
737
+ return this.__markdownHelpers;
738
+ }
739
+
740
+ /**
741
+ * Fired when the tooltip text content is changed.
742
+ *
743
+ * @event content-changed
744
+ */
702
745
  };
@@ -7,11 +7,11 @@ import { html, LitElement } from 'lit';
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 { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
- import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
10
+ import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
11
11
  import { PopoverOverlayMixin } from '@vaadin/popover/src/vaadin-popover-overlay-mixin.js';
12
12
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
13
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
- import { tooltipOverlayStyles } from './styles/vaadin-tooltip-overlay-core-styles.js';
14
+ import { tooltipOverlayStyles } from './styles/vaadin-tooltip-overlay-base-styles.js';
15
15
 
16
16
  /**
17
17
  * An element used internally by `<vaadin-tooltip>`. Not intended to be used separately.
@@ -9,6 +9,17 @@ import { TooltipMixin } from './vaadin-tooltip-mixin.js';
9
9
 
10
10
  export { TooltipPosition } from './vaadin-tooltip-mixin.js';
11
11
 
12
+ /**
13
+ * Fired when the tooltip text content is changed.
14
+ */
15
+ export type TooltipContentChangedEvent = CustomEvent<{ content: string }>;
16
+
17
+ export interface TooltipCustomEventMap {
18
+ 'content-changed': TooltipContentChangedEvent;
19
+ }
20
+
21
+ export interface TooltipEventMap extends HTMLElementEventMap, TooltipCustomEventMap {}
22
+
12
23
  /**
13
24
  * `<vaadin-tooltip>` is a Web Component for creating tooltips.
14
25
  *
@@ -17,6 +28,19 @@ export { TooltipPosition } from './vaadin-tooltip-mixin.js';
17
28
  * <vaadin-tooltip text="Click to save changes" for="confirm"></vaadin-tooltip>
18
29
  * ```
19
30
  *
31
+ * ### Markdown Support
32
+ *
33
+ * The tooltip supports rendering Markdown content by setting the `markdown` property:
34
+ *
35
+ * ```html
36
+ * <button id="info">Info</button>
37
+ * <vaadin-tooltip
38
+ * text="**Important:** Click to view *detailed* information"
39
+ * markdown
40
+ * for="info">
41
+ * </vaadin-tooltip>
42
+ * ```
43
+ *
20
44
  * ### Styling
21
45
  *
22
46
  * The following shadow DOM parts are available for styling:
@@ -30,11 +54,9 @@ export { TooltipPosition } from './vaadin-tooltip-mixin.js';
30
54
  *
31
55
  * Attribute | Description
32
56
  * -----------------|----------------------------------------
57
+ * `markdown` | Reflects the `markdown` property value.
33
58
  * `position` | Reflects the `position` property value.
34
59
  *
35
- * Note: the `theme` attribute value set on `<vaadin-tooltip>` is
36
- * propagated to the internal `<vaadin-tooltip-overlay>` component.
37
- *
38
60
  * ### Custom CSS Properties
39
61
  *
40
62
  * The following custom CSS properties are available on the `<vaadin-tooltip>` element:
@@ -47,6 +69,8 @@ export { TooltipPosition } from './vaadin-tooltip-mixin.js';
47
69
  * `--vaadin-tooltip-offset-end` | Used as an offset when the tooltip is aligned horizontally before the target
48
70
  *
49
71
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
72
+ *
73
+ * @fires {CustomEvent} content-changed - Fired when the tooltip text content is changed.
50
74
  */
51
75
  declare class Tooltip extends TooltipMixin(ThemePropertyMixin(ElementMixin(HTMLElement))) {
52
76
  /**
@@ -66,6 +90,18 @@ declare class Tooltip extends TooltipMixin(ThemePropertyMixin(ElementMixin(HTMLE
66
90
  * except for those that have hover delay configured using property.
67
91
  */
68
92
  static setDefaultHoverDelay(hoverDelay: number): void;
93
+
94
+ addEventListener<K extends keyof TooltipEventMap>(
95
+ type: K,
96
+ listener: (this: Tooltip, ev: TooltipEventMap[K]) => void,
97
+ options?: AddEventListenerOptions | boolean,
98
+ ): void;
99
+
100
+ removeEventListener<K extends keyof TooltipEventMap>(
101
+ type: K,
102
+ listener: (this: Tooltip, ev: TooltipEventMap[K]) => void,
103
+ options?: EventListenerOptions | boolean,
104
+ ): void;
69
105
  }
70
106
 
71
107
  declare global {
@@ -20,6 +20,19 @@ import { TooltipMixin } from './vaadin-tooltip-mixin.js';
20
20
  * <vaadin-tooltip text="Click to save changes" for="confirm"></vaadin-tooltip>
21
21
  * ```
22
22
  *
23
+ * ### Markdown Support
24
+ *
25
+ * The tooltip supports rendering Markdown content by setting the `markdown` property:
26
+ *
27
+ * ```html
28
+ * <button id="info">Info</button>
29
+ * <vaadin-tooltip
30
+ * text="**Important:** Click to view *detailed* information"
31
+ * markdown
32
+ * for="info">
33
+ * </vaadin-tooltip>
34
+ * ```
35
+ *
23
36
  * ### Styling
24
37
  *
25
38
  * The following shadow DOM parts are available for styling:
@@ -33,11 +46,9 @@ import { TooltipMixin } from './vaadin-tooltip-mixin.js';
33
46
  *
34
47
  * Attribute | Description
35
48
  * -----------------|----------------------------------------
49
+ * `markdown` | Reflects the `markdown` property value.
36
50
  * `position` | Reflects the `position` property value.
37
51
  *
38
- * Note: the `theme` attribute value set on `<vaadin-tooltip>` is
39
- * propagated to the internal `<vaadin-tooltip-overlay>` component.
40
- *
41
52
  * ### Custom CSS Properties
42
53
  *
43
54
  * The following custom CSS properties are available on the `<vaadin-tooltip>` element:
@@ -51,6 +62,8 @@ import { TooltipMixin } from './vaadin-tooltip-mixin.js';
51
62
  *
52
63
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
53
64
  *
65
+ * @fires {CustomEvent} content-changed - Fired when the tooltip text content is changed.
66
+ *
54
67
  * @customElement
55
68
  * @extends HTMLElement
56
69
  * @mixes ElementMixin
@@ -79,16 +92,19 @@ class Tooltip extends TooltipMixin(ThemePropertyMixin(ElementMixin(PolylitMixin(
79
92
  id="overlay"
80
93
  .owner="${this}"
81
94
  theme="${ifDefined(this._theme)}"
82
- .opened="${this._isConnected && (this.manual ? this.opened : this._autoOpened)}"
95
+ .opened="${this._isConnected && this.opened}"
83
96
  .positionTarget="${this.target}"
84
97
  .position="${effectivePosition}"
85
98
  ?no-horizontal-overlap="${this.__computeNoHorizontalOverlap(effectivePosition)}"
86
99
  ?no-vertical-overlap="${this.__computeNoVerticalOverlap(effectivePosition)}"
87
100
  .horizontalAlign="${this.__computeHorizontalAlign(effectivePosition)}"
88
101
  .verticalAlign="${this.__computeVerticalAlign(effectivePosition)}"
102
+ @click="${this.__onOverlayClick}"
103
+ @mousedown="${this.__onOverlayMouseDown}"
89
104
  @mouseenter="${this.__onOverlayMouseEnter}"
90
105
  @mouseleave="${this.__onOverlayMouseLeave}"
91
106
  modeless
107
+ ?markdown="${this.markdown}"
92
108
  exportparts="overlay, content"
93
109
  ><slot name="overlay"></slot
94
110
  ></vaadin-tooltip-overlay>
package/vaadin-tooltip.js CHANGED
@@ -1,3 +1,3 @@
1
- import './theme/lumo/vaadin-tooltip.js';
1
+ import './src/vaadin-tooltip.js';
2
2
 
3
3
  export * from './src/vaadin-tooltip.js';
package/web-types.json CHANGED
@@ -1,26 +1,15 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "25.0.0-alpha9",
4
+ "version": "25.0.0-beta1",
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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------- | ---------------\n`overlay` | The overlay element\n`content` | The overlay content element\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### Markdown Support\n\nThe tooltip supports rendering Markdown content by setting the `markdown` property:\n\n```html\n<button id=\"info\">Info</button>\n<vaadin-tooltip\n text=\"**Important:** Click to view *detailed* information\"\n markdown\n for=\"info\">\n</vaadin-tooltip>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------- | ---------------\n`overlay` | The overlay element\n`content` | The overlay content element\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|----------------------------------------\n`markdown` | Reflects the `markdown` property value.\n`position` | Reflects the `position` property value.\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
- {
14
- "name": "overlay-class",
15
- "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
16
- "value": {
17
- "type": [
18
- "string",
19
- "null",
20
- "undefined"
21
- ]
22
- }
23
- },
24
13
  {
25
14
  "name": "position",
26
15
  "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`.",
@@ -89,7 +78,7 @@
89
78
  },
90
79
  {
91
80
  "name": "opened",
92
- "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
81
+ "description": "When true, the tooltip is opened.\nIn manual mode, this can be set programmatically.\nIn automatic mode, this is set automatically by internal logic.",
93
82
  "value": {
94
83
  "type": [
95
84
  "boolean",
@@ -109,6 +98,17 @@
109
98
  ]
110
99
  }
111
100
  },
101
+ {
102
+ "name": "markdown",
103
+ "description": "When enabled, the tooltip text is rendered as Markdown.\n\n**Note:** Using Markdown is discouraged if accessibility of the tooltip\ncontent is essential, as semantics of the rendered HTML content\n(headers, lists, ...) will not be conveyed to assistive technologies.",
104
+ "value": {
105
+ "type": [
106
+ "boolean",
107
+ "null",
108
+ "undefined"
109
+ ]
110
+ }
111
+ },
112
112
  {
113
113
  "name": "theme",
114
114
  "description": "The theme variants to apply to the component.",
@@ -123,17 +123,6 @@
123
123
  ],
124
124
  "js": {
125
125
  "properties": [
126
- {
127
- "name": "overlayClass",
128
- "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
129
- "value": {
130
- "type": [
131
- "string",
132
- "null",
133
- "undefined"
134
- ]
135
- }
136
- },
137
126
  {
138
127
  "name": "position",
139
128
  "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`.",
@@ -246,7 +235,7 @@
246
235
  },
247
236
  {
248
237
  "name": "opened",
249
- "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
238
+ "description": "When true, the tooltip is opened.\nIn manual mode, this can be set programmatically.\nIn automatic mode, this is set automatically by internal logic.",
250
239
  "value": {
251
240
  "type": [
252
241
  "boolean",
@@ -276,9 +265,25 @@
276
265
  "undefined"
277
266
  ]
278
267
  }
268
+ },
269
+ {
270
+ "name": "markdown",
271
+ "description": "When enabled, the tooltip text is rendered as Markdown.\n\n**Note:** Using Markdown is discouraged if accessibility of the tooltip\ncontent is essential, as semantics of the rendered HTML content\n(headers, lists, ...) will not be conveyed to assistive technologies.",
272
+ "value": {
273
+ "type": [
274
+ "boolean",
275
+ "null",
276
+ "undefined"
277
+ ]
278
+ }
279
279
  }
280
280
  ],
281
- "events": []
281
+ "events": [
282
+ {
283
+ "name": "content-changed",
284
+ "description": "Fired when the tooltip text content is changed."
285
+ }
286
+ ]
282
287
  }
283
288
  }
284
289
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "25.0.0-alpha9",
4
+ "version": "25.0.0-beta1",
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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------- | ---------------\n`overlay` | The overlay element\n`content` | The overlay content element\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### Markdown Support\n\nThe tooltip supports rendering Markdown content by setting the `markdown` property:\n\n```html\n<button id=\"info\">Info</button>\n<vaadin-tooltip\n text=\"**Important:** Click to view *detailed* information\"\n markdown\n for=\"info\">\n</vaadin-tooltip>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------- | ---------------\n`overlay` | The overlay element\n`content` | The overlay content element\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|----------------------------------------\n`markdown` | Reflects the `markdown` property value.\n`position` | Reflects the `position` property value.\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
  {
@@ -28,14 +28,14 @@
28
28
  },
29
29
  {
30
30
  "name": "?opened",
31
- "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
31
+ "description": "When true, the tooltip is opened.\nIn manual mode, this can be set programmatically.\nIn automatic mode, this is set automatically by internal logic.",
32
32
  "value": {
33
33
  "kind": "expression"
34
34
  }
35
35
  },
36
36
  {
37
- "name": ".overlayClass",
38
- "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
37
+ "name": "?markdown",
38
+ "description": "When enabled, the tooltip text is rendered as Markdown.\n\n**Note:** Using Markdown is discouraged if accessibility of the tooltip\ncontent is essential, as semantics of the rendered HTML content\n(headers, lists, ...) will not be conveyed to assistive technologies.",
39
39
  "value": {
40
40
  "kind": "expression"
41
41
  }
@@ -116,6 +116,13 @@
116
116
  "value": {
117
117
  "kind": "expression"
118
118
  }
119
+ },
120
+ {
121
+ "name": "@content-changed",
122
+ "description": "Fired when the tooltip text content is changed.",
123
+ "value": {
124
+ "kind": "expression"
125
+ }
119
126
  }
120
127
  ]
121
128
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import type { CSSResult } from 'lit';
7
-
8
- export const tooltipOverlayStyles: CSSResult;
@@ -1,46 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { css } from 'lit';
7
-
8
- export const tooltipOverlayStyles = css`
9
- :host {
10
- --_vaadin-tooltip-default-offset: 0;
11
- }
12
-
13
- [part='overlay'] {
14
- max-width: 40ch;
15
- }
16
-
17
- [part='content'] {
18
- white-space: pre-wrap;
19
- }
20
-
21
- :host([position^='top'][top-aligned]) [part='overlay'],
22
- :host([position^='bottom'][top-aligned]) [part='overlay'] {
23
- margin-top: var(--vaadin-tooltip-offset-top, var(--_vaadin-tooltip-default-offset));
24
- }
25
-
26
- :host([position^='top'][bottom-aligned]) [part='overlay'],
27
- :host([position^='bottom'][bottom-aligned]) [part='overlay'] {
28
- margin-bottom: var(--vaadin-tooltip-offset-bottom, var(--_vaadin-tooltip-default-offset));
29
- }
30
-
31
- :host([position^='start'][start-aligned]) [part='overlay'],
32
- :host([position^='end'][start-aligned]) [part='overlay'] {
33
- margin-inline-start: var(--vaadin-tooltip-offset-start, var(--_vaadin-tooltip-default-offset));
34
- }
35
-
36
- :host([position^='start'][end-aligned]) [part='overlay'],
37
- :host([position^='end'][end-aligned]) [part='overlay'] {
38
- margin-inline-end: var(--vaadin-tooltip-offset-end, var(--_vaadin-tooltip-default-offset));
39
- }
40
-
41
- @media (forced-colors: active) {
42
- [part='overlay'] {
43
- outline: 1px dashed;
44
- }
45
- }
46
- `;
@@ -1,3 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/style.js';
3
- import '@vaadin/vaadin-lumo-styles/typography.js';
@@ -1,24 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/style.js';
3
- import '@vaadin/vaadin-lumo-styles/typography.js';
4
- import { overlay } from '@vaadin/vaadin-lumo-styles/mixins/overlay.js';
5
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6
-
7
- const tooltipOverlay = css`
8
- :host {
9
- --_vaadin-tooltip-default-offset: var(--lumo-space-xs);
10
- }
11
-
12
- [part='overlay'] {
13
- background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
14
- color: var(--lumo-body-text-color);
15
- font-size: var(--lumo-font-size-xs);
16
- line-height: var(--lumo-line-height-s);
17
- }
18
-
19
- [part='content'] {
20
- padding: var(--lumo-space-xs) var(--lumo-space-s);
21
- }
22
- `;
23
-
24
- registerStyles('vaadin-tooltip-overlay', [overlay, tooltipOverlay], { moduleId: 'lumo-tooltip-overlay' });
@@ -1,2 +0,0 @@
1
- import './vaadin-tooltip-styles.js';
2
- import '../../src/vaadin-tooltip.js';
@@ -1,2 +0,0 @@
1
- import './vaadin-tooltip-styles.js';
2
- import '../../src/vaadin-tooltip.js';