@vaadin/tooltip 25.0.0-alpha20 → 25.0.0-alpha21
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 +11 -10
- package/src/styles/vaadin-tooltip-overlay-base-styles.js +2 -2
- package/src/vaadin-tooltip-mixin.d.ts +9 -0
- package/src/vaadin-tooltip-mixin.js +47 -4
- package/src/vaadin-tooltip.d.ts +14 -0
- package/src/vaadin-tooltip.js +17 -0
- package/web-types.json +24 -2
- package/web-types.lit.json +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/tooltip",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha21",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,23 +34,24 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
38
|
-
"@vaadin/component-base": "25.0.0-
|
|
39
|
-
"@vaadin/
|
|
40
|
-
"@vaadin/
|
|
41
|
-
"@vaadin/
|
|
37
|
+
"@vaadin/a11y-base": "25.0.0-alpha21",
|
|
38
|
+
"@vaadin/component-base": "25.0.0-alpha21",
|
|
39
|
+
"@vaadin/markdown": "25.0.0-alpha21",
|
|
40
|
+
"@vaadin/overlay": "25.0.0-alpha21",
|
|
41
|
+
"@vaadin/popover": "25.0.0-alpha21",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha21",
|
|
42
43
|
"lit": "^3.0.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
46
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
46
|
+
"@vaadin/chai-plugins": "25.0.0-alpha21",
|
|
47
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha21",
|
|
47
48
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
48
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
49
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha21",
|
|
49
50
|
"sinon": "^21.0.0"
|
|
50
51
|
},
|
|
51
52
|
"web-types": [
|
|
52
53
|
"web-types.json",
|
|
53
54
|
"web-types.lit.json"
|
|
54
55
|
],
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "8fb9e9710c01449edf623a1aaac4655cdc11a933"
|
|
56
57
|
}
|
|
@@ -25,10 +25,10 @@ export const tooltipOverlayStyles = css`
|
|
|
25
25
|
box-shadow:
|
|
26
26
|
0 0 0 var(--vaadin-tooltip-border-width, 1px)
|
|
27
27
|
var(--vaadin-tooltip-border-color, var(--vaadin-border-color-secondary)),
|
|
28
|
-
var(--vaadin-tooltip-
|
|
28
|
+
var(--vaadin-tooltip-shadow, 0 3px 8px -1px rgba(0, 0, 0, 0.2));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
[part='content'] {
|
|
31
|
+
:host(:not([markdown])) [part='content'] {
|
|
32
32
|
white-space: pre-wrap;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -87,4 +87,13 @@ export declare class TooltipMixinClass {
|
|
|
87
87
|
* String used as a tooltip content.
|
|
88
88
|
*/
|
|
89
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;
|
|
90
99
|
}
|
|
@@ -328,6 +328,19 @@ export const TooltipMixin = (superClass) =>
|
|
|
328
328
|
type: String,
|
|
329
329
|
},
|
|
330
330
|
|
|
331
|
+
/**
|
|
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.
|
|
337
|
+
*/
|
|
338
|
+
markdown: {
|
|
339
|
+
type: Boolean,
|
|
340
|
+
value: false,
|
|
341
|
+
reflectToAttribute: true,
|
|
342
|
+
},
|
|
343
|
+
|
|
331
344
|
/**
|
|
332
345
|
* Element used to link with the `aria-describedby`
|
|
333
346
|
* attribute. When not set, defaults to `target`.
|
|
@@ -447,9 +460,8 @@ export const TooltipMixin = (superClass) =>
|
|
|
447
460
|
updated(props) {
|
|
448
461
|
super.updated(props);
|
|
449
462
|
|
|
450
|
-
if (props.has('text') || props.has('generator') || props.has('context')) {
|
|
463
|
+
if (props.has('text') || props.has('generator') || props.has('context') || props.has('markdown')) {
|
|
451
464
|
this.__updateContent();
|
|
452
|
-
this.$.overlay.toggleAttribute('hidden', this.__contentNode.textContent.trim() === '');
|
|
453
465
|
}
|
|
454
466
|
}
|
|
455
467
|
|
|
@@ -611,6 +623,20 @@ export const TooltipMixin = (superClass) =>
|
|
|
611
623
|
}
|
|
612
624
|
}
|
|
613
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
|
+
|
|
614
640
|
/** @private */
|
|
615
641
|
__handleMouseLeave() {
|
|
616
642
|
if (this.manual) {
|
|
@@ -667,8 +693,17 @@ export const TooltipMixin = (superClass) =>
|
|
|
667
693
|
}
|
|
668
694
|
|
|
669
695
|
/** @private */
|
|
670
|
-
__updateContent() {
|
|
671
|
-
|
|
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() === '');
|
|
672
707
|
this.dispatchEvent(new CustomEvent('content-changed', { detail: { content: this.__contentNode.textContent } }));
|
|
673
708
|
}
|
|
674
709
|
|
|
@@ -694,6 +729,14 @@ export const TooltipMixin = (superClass) =>
|
|
|
694
729
|
}
|
|
695
730
|
}
|
|
696
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
|
+
|
|
697
740
|
/**
|
|
698
741
|
* Fired when the tooltip text content is changed.
|
|
699
742
|
*
|
package/src/vaadin-tooltip.d.ts
CHANGED
|
@@ -28,6 +28,19 @@ export interface TooltipEventMap extends HTMLElementEventMap, TooltipCustomEvent
|
|
|
28
28
|
* <vaadin-tooltip text="Click to save changes" for="confirm"></vaadin-tooltip>
|
|
29
29
|
* ```
|
|
30
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
|
+
*
|
|
31
44
|
* ### Styling
|
|
32
45
|
*
|
|
33
46
|
* The following shadow DOM parts are available for styling:
|
|
@@ -41,6 +54,7 @@ export interface TooltipEventMap extends HTMLElementEventMap, TooltipCustomEvent
|
|
|
41
54
|
*
|
|
42
55
|
* Attribute | Description
|
|
43
56
|
* -----------------|----------------------------------------
|
|
57
|
+
* `markdown` | Reflects the `markdown` property value.
|
|
44
58
|
* `position` | Reflects the `position` property value.
|
|
45
59
|
*
|
|
46
60
|
* ### Custom CSS Properties
|
package/src/vaadin-tooltip.js
CHANGED
|
@@ -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,6 +46,7 @@ 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
52
|
* ### Custom CSS Properties
|
|
@@ -85,9 +99,12 @@ class Tooltip extends TooltipMixin(ThemePropertyMixin(ElementMixin(PolylitMixin(
|
|
|
85
99
|
?no-vertical-overlap="${this.__computeNoVerticalOverlap(effectivePosition)}"
|
|
86
100
|
.horizontalAlign="${this.__computeHorizontalAlign(effectivePosition)}"
|
|
87
101
|
.verticalAlign="${this.__computeVerticalAlign(effectivePosition)}"
|
|
102
|
+
@click="${this.__onOverlayClick}"
|
|
103
|
+
@mousedown="${this.__onOverlayMouseDown}"
|
|
88
104
|
@mouseenter="${this.__onOverlayMouseEnter}"
|
|
89
105
|
@mouseleave="${this.__onOverlayMouseLeave}"
|
|
90
106
|
modeless
|
|
107
|
+
?markdown="${this.markdown}"
|
|
91
108
|
exportparts="overlay, content"
|
|
92
109
|
><slot name="overlay"></slot
|
|
93
110
|
></vaadin-tooltip-overlay>
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha21",
|
|
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\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
13
|
{
|
|
14
14
|
"name": "position",
|
|
@@ -98,6 +98,17 @@
|
|
|
98
98
|
]
|
|
99
99
|
}
|
|
100
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
|
+
},
|
|
101
112
|
{
|
|
102
113
|
"name": "theme",
|
|
103
114
|
"description": "The theme variants to apply to the component.",
|
|
@@ -254,6 +265,17 @@
|
|
|
254
265
|
"undefined"
|
|
255
266
|
]
|
|
256
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
|
+
}
|
|
257
279
|
}
|
|
258
280
|
],
|
|
259
281
|
"events": [
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha21",
|
|
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\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
|
{
|
|
@@ -33,6 +33,13 @@
|
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
{
|
|
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
|
+
"value": {
|
|
40
|
+
"kind": "expression"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
36
43
|
{
|
|
37
44
|
"name": ".position",
|
|
38
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`.",
|