@vaadin/tooltip 25.2.7 → 25.3.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/custom-elements.json +115 -34
- package/package.json +12 -12
- package/src/vaadin-tooltip-aria-mixin.d.ts +41 -0
- package/src/vaadin-tooltip-aria-mixin.js +126 -0
- package/src/vaadin-tooltip-mixin.d.ts +6 -22
- package/src/vaadin-tooltip-mixin.js +2 -74
- package/src/vaadin-tooltip-overlay.js +1 -0
- package/src/vaadin-tooltip.js +1 -0
- package/web-types.json +2 -4
- package/web-types.lit.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -17,6 +17,64 @@
|
|
|
17
17
|
}
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"kind": "javascript-module",
|
|
22
|
+
"path": "src/vaadin-tooltip-aria-mixin.js",
|
|
23
|
+
"declarations": [
|
|
24
|
+
{
|
|
25
|
+
"kind": "mixin",
|
|
26
|
+
"description": "A mixin providing linking of the tooltip content to the tooltip target\nelements using the `aria-describedby` or `aria-labelledby` attribute.\n\nTargets in the same root as the tooltip are linked by the content element\nID. ID references only resolve within a single tree scope, so targets in\nother roots are linked with ARIA element references instead.",
|
|
27
|
+
"name": "TooltipAriaMixin",
|
|
28
|
+
"members": [
|
|
29
|
+
{
|
|
30
|
+
"kind": "field",
|
|
31
|
+
"name": "ariaLinkMode",
|
|
32
|
+
"privacy": "public",
|
|
33
|
+
"type": {
|
|
34
|
+
"text": "string"
|
|
35
|
+
},
|
|
36
|
+
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
37
|
+
"attribute": "aria-link-mode"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"kind": "field",
|
|
41
|
+
"name": "ariaTarget",
|
|
42
|
+
"privacy": "public",
|
|
43
|
+
"type": {
|
|
44
|
+
"text": "object"
|
|
45
|
+
},
|
|
46
|
+
"description": "Element used to link with the ARIA attribute controlled by the\n`ariaLinkMode` property. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
|
|
47
|
+
"attribute": "aria-target"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"attributes": [
|
|
51
|
+
{
|
|
52
|
+
"name": "aria-link-mode",
|
|
53
|
+
"type": {
|
|
54
|
+
"text": "string"
|
|
55
|
+
},
|
|
56
|
+
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
57
|
+
"fieldName": "ariaLinkMode"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"parameters": [
|
|
61
|
+
{
|
|
62
|
+
"name": "superClass"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"exports": [
|
|
68
|
+
{
|
|
69
|
+
"kind": "js",
|
|
70
|
+
"name": "TooltipAriaMixin",
|
|
71
|
+
"declaration": {
|
|
72
|
+
"name": "TooltipAriaMixin",
|
|
73
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
20
78
|
{
|
|
21
79
|
"kind": "javascript-module",
|
|
22
80
|
"path": "src/vaadin-tooltip-mixin.js",
|
|
@@ -34,7 +92,11 @@
|
|
|
34
92
|
"text": "string"
|
|
35
93
|
},
|
|
36
94
|
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
37
|
-
"attribute": "aria-link-mode"
|
|
95
|
+
"attribute": "aria-link-mode",
|
|
96
|
+
"inheritedFrom": {
|
|
97
|
+
"name": "TooltipAriaMixin",
|
|
98
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
99
|
+
}
|
|
38
100
|
},
|
|
39
101
|
{
|
|
40
102
|
"kind": "field",
|
|
@@ -44,7 +106,11 @@
|
|
|
44
106
|
"text": "object"
|
|
45
107
|
},
|
|
46
108
|
"description": "Element used to link with the ARIA attribute controlled by the\n`ariaLinkMode` property. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
|
|
47
|
-
"attribute": "aria-target"
|
|
109
|
+
"attribute": "aria-target",
|
|
110
|
+
"inheritedFrom": {
|
|
111
|
+
"name": "TooltipAriaMixin",
|
|
112
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
113
|
+
}
|
|
48
114
|
},
|
|
49
115
|
{
|
|
50
116
|
"kind": "field",
|
|
@@ -246,7 +312,11 @@
|
|
|
246
312
|
"text": "string"
|
|
247
313
|
},
|
|
248
314
|
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
249
|
-
"fieldName": "ariaLinkMode"
|
|
315
|
+
"fieldName": "ariaLinkMode",
|
|
316
|
+
"inheritedFrom": {
|
|
317
|
+
"name": "TooltipAriaMixin",
|
|
318
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
319
|
+
}
|
|
250
320
|
},
|
|
251
321
|
{
|
|
252
322
|
"name": "focus-delay",
|
|
@@ -330,6 +400,10 @@
|
|
|
330
400
|
}
|
|
331
401
|
],
|
|
332
402
|
"mixins": [
|
|
403
|
+
{
|
|
404
|
+
"name": "TooltipAriaMixin",
|
|
405
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
406
|
+
},
|
|
333
407
|
{
|
|
334
408
|
"name": "PopoverPositionMixin",
|
|
335
409
|
"package": "@vaadin/popover/src/vaadin-popover-position-mixin.js"
|
|
@@ -376,8 +450,8 @@
|
|
|
376
450
|
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
377
451
|
"attribute": "aria-link-mode",
|
|
378
452
|
"inheritedFrom": {
|
|
379
|
-
"name": "
|
|
380
|
-
"module": "src/vaadin-tooltip-mixin.js"
|
|
453
|
+
"name": "TooltipAriaMixin",
|
|
454
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
381
455
|
}
|
|
382
456
|
},
|
|
383
457
|
{
|
|
@@ -390,8 +464,8 @@
|
|
|
390
464
|
"description": "Element used to link with the ARIA attribute controlled by the\n`ariaLinkMode` property. Supports array of multiple elements.\nWhen not set, defaults to `target`.",
|
|
391
465
|
"attribute": "aria-target",
|
|
392
466
|
"inheritedFrom": {
|
|
393
|
-
"name": "
|
|
394
|
-
"module": "src/vaadin-tooltip-mixin.js"
|
|
467
|
+
"name": "TooltipAriaMixin",
|
|
468
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
395
469
|
}
|
|
396
470
|
},
|
|
397
471
|
{
|
|
@@ -644,30 +718,6 @@
|
|
|
644
718
|
}
|
|
645
719
|
}
|
|
646
720
|
],
|
|
647
|
-
"mixins": [
|
|
648
|
-
{
|
|
649
|
-
"name": "TooltipMixin",
|
|
650
|
-
"module": "src/vaadin-tooltip-mixin.js"
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
"name": "ThemePropertyMixin",
|
|
654
|
-
"package": "@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js"
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
"name": "ElementMixin",
|
|
658
|
-
"package": "@vaadin/component-base/src/element-mixin.js"
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
"name": "PolylitMixin",
|
|
662
|
-
"package": "@vaadin/component-base/src/polylit-mixin.js"
|
|
663
|
-
}
|
|
664
|
-
],
|
|
665
|
-
"superclass": {
|
|
666
|
-
"name": "LitElement",
|
|
667
|
-
"package": "lit"
|
|
668
|
-
},
|
|
669
|
-
"tagName": "vaadin-tooltip",
|
|
670
|
-
"customElement": true,
|
|
671
721
|
"attributes": [
|
|
672
722
|
{
|
|
673
723
|
"name": "aria-link-mode",
|
|
@@ -677,8 +727,8 @@
|
|
|
677
727
|
"description": "Controls which ARIA attribute is used to link the target element(s)\nwith the tooltip content. Supported values:\n\n- `aria-describedby` - links the tooltip as a description.\n- `aria-labelledby` - links the tooltip as an accessible name.\n- `none` - does not add any ARIA linking attribute.\n\nDefaults to `aria-describedby`.",
|
|
678
728
|
"fieldName": "ariaLinkMode",
|
|
679
729
|
"inheritedFrom": {
|
|
680
|
-
"name": "
|
|
681
|
-
"module": "src/vaadin-tooltip-mixin.js"
|
|
730
|
+
"name": "TooltipAriaMixin",
|
|
731
|
+
"module": "src/vaadin-tooltip-aria-mixin.js"
|
|
682
732
|
}
|
|
683
733
|
},
|
|
684
734
|
{
|
|
@@ -788,8 +838,39 @@
|
|
|
788
838
|
"name": "TooltipMixin",
|
|
789
839
|
"module": "src/vaadin-tooltip-mixin.js"
|
|
790
840
|
}
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
"type": {
|
|
844
|
+
"text": "string"
|
|
845
|
+
},
|
|
846
|
+
"description": "The theme variants to apply to the component.",
|
|
847
|
+
"name": "theme"
|
|
791
848
|
}
|
|
792
|
-
]
|
|
849
|
+
],
|
|
850
|
+
"mixins": [
|
|
851
|
+
{
|
|
852
|
+
"name": "TooltipMixin",
|
|
853
|
+
"module": "src/vaadin-tooltip-mixin.js"
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
"name": "ThemePropertyMixin",
|
|
857
|
+
"package": "@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"name": "ElementMixin",
|
|
861
|
+
"package": "@vaadin/component-base/src/element-mixin.js"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
"name": "PolylitMixin",
|
|
865
|
+
"package": "@vaadin/component-base/src/polylit-mixin.js"
|
|
866
|
+
}
|
|
867
|
+
],
|
|
868
|
+
"superclass": {
|
|
869
|
+
"name": "LitElement",
|
|
870
|
+
"package": "lit"
|
|
871
|
+
},
|
|
872
|
+
"tagName": "vaadin-tooltip",
|
|
873
|
+
"customElement": true
|
|
793
874
|
}
|
|
794
875
|
],
|
|
795
876
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/tooltip",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.3.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,20 +35,20 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "
|
|
39
|
-
"@vaadin/component-base": "
|
|
40
|
-
"@vaadin/markdown": "
|
|
41
|
-
"@vaadin/overlay": "
|
|
42
|
-
"@vaadin/popover": "
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
38
|
+
"@vaadin/a11y-base": "25.3.0-alpha10",
|
|
39
|
+
"@vaadin/component-base": "25.3.0-alpha10",
|
|
40
|
+
"@vaadin/markdown": "25.3.0-alpha10",
|
|
41
|
+
"@vaadin/overlay": "25.3.0-alpha10",
|
|
42
|
+
"@vaadin/popover": "25.3.0-alpha10",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-alpha10",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/aura": "
|
|
48
|
-
"@vaadin/chai-plugins": "
|
|
49
|
-
"@vaadin/test-runner-commands": "
|
|
47
|
+
"@vaadin/aura": "25.3.0-alpha10",
|
|
48
|
+
"@vaadin/chai-plugins": "25.3.0-alpha10",
|
|
49
|
+
"@vaadin/test-runner-commands": "25.3.0-alpha10",
|
|
50
50
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
51
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
51
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-alpha10",
|
|
52
52
|
"sinon": "^22.0.0"
|
|
53
53
|
},
|
|
54
54
|
"customElements": "custom-elements.json",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"web-types.json",
|
|
57
57
|
"web-types.lit.json"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "f2833abdf9b613fa0d0ed216830e3f4de87b7dac"
|
|
60
60
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A mixin providing linking of the tooltip content to the tooltip target
|
|
10
|
+
* elements using the `aria-describedby` or `aria-labelledby` attribute.
|
|
11
|
+
*
|
|
12
|
+
* Targets in the same root as the tooltip are linked by the content element
|
|
13
|
+
* ID. ID references only resolve within a single tree scope, so targets in
|
|
14
|
+
* other roots are linked with ARIA element references instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function TooltipAriaMixin<T extends Constructor<HTMLElement>>(
|
|
17
|
+
base: T,
|
|
18
|
+
): Constructor<TooltipAriaMixinClass> & T;
|
|
19
|
+
|
|
20
|
+
export declare class TooltipAriaMixinClass {
|
|
21
|
+
/**
|
|
22
|
+
* Element used to link with the ARIA attribute controlled by the
|
|
23
|
+
* `ariaLinkMode` property. Supports array of multiple elements.
|
|
24
|
+
* When not set, defaults to `target`.
|
|
25
|
+
*/
|
|
26
|
+
ariaTarget: HTMLElement | HTMLElement[] | null | undefined;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Controls which ARIA attribute is used to link the target element(s)
|
|
30
|
+
* with the tooltip content. Supported values:
|
|
31
|
+
*
|
|
32
|
+
* - `aria-describedby` - links the tooltip as a description.
|
|
33
|
+
* - `aria-labelledby` - links the tooltip as an accessible name.
|
|
34
|
+
* - `none` - does not add any ARIA linking attribute.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to `aria-describedby`.
|
|
37
|
+
*
|
|
38
|
+
* @attr {string} aria-link-mode
|
|
39
|
+
*/
|
|
40
|
+
ariaLinkMode: 'aria-describedby' | 'aria-labelledby' | 'none';
|
|
41
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2026 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { addAriaElementReference, removeAriaElementReference } from '@vaadin/a11y-base/src/aria-element-reference.js';
|
|
7
|
+
import { addValuesToAttribute, removeValuesFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A mixin providing linking of the tooltip content to the tooltip target
|
|
11
|
+
* elements using the `aria-describedby` or `aria-labelledby` attribute.
|
|
12
|
+
*
|
|
13
|
+
* Targets in the same root as the tooltip are linked by the content element
|
|
14
|
+
* ID. ID references only resolve within a single tree scope, so targets in
|
|
15
|
+
* other roots are linked with ARIA element references instead.
|
|
16
|
+
*/
|
|
17
|
+
export const TooltipAriaMixin = (superClass) =>
|
|
18
|
+
class TooltipAriaMixinClass extends superClass {
|
|
19
|
+
#ariaReferences = [];
|
|
20
|
+
|
|
21
|
+
static get properties() {
|
|
22
|
+
return {
|
|
23
|
+
/**
|
|
24
|
+
* Element used to link with the ARIA attribute controlled by the
|
|
25
|
+
* `ariaLinkMode` property. Supports array of multiple elements.
|
|
26
|
+
* When not set, defaults to `target`.
|
|
27
|
+
*/
|
|
28
|
+
ariaTarget: {
|
|
29
|
+
type: Object,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Controls which ARIA attribute is used to link the target element(s)
|
|
34
|
+
* with the tooltip content. Supported values:
|
|
35
|
+
*
|
|
36
|
+
* - `aria-describedby` - links the tooltip as a description.
|
|
37
|
+
* - `aria-labelledby` - links the tooltip as an accessible name.
|
|
38
|
+
* - `none` - does not add any ARIA linking attribute.
|
|
39
|
+
*
|
|
40
|
+
* Defaults to `aria-describedby`.
|
|
41
|
+
*
|
|
42
|
+
* @attr {string} aria-link-mode
|
|
43
|
+
*/
|
|
44
|
+
ariaLinkMode: {
|
|
45
|
+
type: String,
|
|
46
|
+
value: 'aria-describedby',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Element used to link with the `aria-describedby`
|
|
51
|
+
* attribute. When not set, defaults to `target`.
|
|
52
|
+
* @protected
|
|
53
|
+
*/
|
|
54
|
+
_effectiveAriaTarget: {
|
|
55
|
+
type: Object,
|
|
56
|
+
computed: '__computeAriaTarget(ariaTarget, target)',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @protected */
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.#addAriaReferences();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @protected */
|
|
68
|
+
disconnectedCallback() {
|
|
69
|
+
super.disconnectedCallback();
|
|
70
|
+
this.#removeAriaReferences();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @protected */
|
|
74
|
+
updated(props) {
|
|
75
|
+
super.updated(props);
|
|
76
|
+
|
|
77
|
+
if (props.has('_effectiveAriaTarget') || props.has('ariaLinkMode')) {
|
|
78
|
+
this.#updateAriaReferences();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#addAriaReferences() {
|
|
83
|
+
const mode = this.ariaLinkMode;
|
|
84
|
+
const targets = this._effectiveAriaTarget;
|
|
85
|
+
const contentNode = this.__contentNode;
|
|
86
|
+
if (!contentNode || !targets || !mode || mode === 'none') {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[targets].flat().forEach((target) => {
|
|
91
|
+
const byReference = target.getRootNode() !== this.getRootNode();
|
|
92
|
+
if (byReference) {
|
|
93
|
+
addAriaElementReference(target, mode, contentNode);
|
|
94
|
+
} else {
|
|
95
|
+
addValuesToAttribute(target, mode, contentNode.id);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.#ariaReferences.push({ target, mode, byReference });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#removeAriaReferences() {
|
|
103
|
+
const contentNode = this.__contentNode;
|
|
104
|
+
|
|
105
|
+
this.#ariaReferences.forEach(({ target, mode, byReference }) => {
|
|
106
|
+
if (byReference) {
|
|
107
|
+
removeAriaElementReference(target, mode, contentNode);
|
|
108
|
+
} else {
|
|
109
|
+
removeValuesFromAttribute(target, mode, contentNode.id);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
this.#ariaReferences = [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#updateAriaReferences() {
|
|
116
|
+
this.#removeAriaReferences();
|
|
117
|
+
this.#addAriaReferences();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** @private */
|
|
121
|
+
__computeAriaTarget(ariaTarget, target) {
|
|
122
|
+
const isElementNode = (el) => el?.nodeType === Node.ELEMENT_NODE;
|
|
123
|
+
const isAriaTargetSet = Array.isArray(ariaTarget) ? ariaTarget.some(isElementNode) : ariaTarget;
|
|
124
|
+
return ariaTarget === null || isAriaTargetSet ? ariaTarget : target;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { PopoverPositionMixinClass } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
|
|
8
8
|
import type { PopoverTargetMixinClass } from '@vaadin/popover/src/vaadin-popover-target-mixin.js';
|
|
9
|
+
import type { TooltipAriaMixinClass } from './vaadin-tooltip-aria-mixin.js';
|
|
9
10
|
|
|
10
11
|
export type { PopoverPosition as TooltipPosition } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
|
|
11
12
|
|
|
@@ -14,30 +15,13 @@ export type { PopoverPosition as TooltipPosition } from '@vaadin/popover/src/vaa
|
|
|
14
15
|
*/
|
|
15
16
|
export declare function TooltipMixin<T extends Constructor<HTMLElement>>(
|
|
16
17
|
base: T,
|
|
17
|
-
): Constructor<PopoverPositionMixinClass> &
|
|
18
|
+
): Constructor<PopoverPositionMixinClass> &
|
|
19
|
+
Constructor<PopoverTargetMixinClass> &
|
|
20
|
+
Constructor<TooltipAriaMixinClass> &
|
|
21
|
+
Constructor<TooltipMixinClass> &
|
|
22
|
+
T;
|
|
18
23
|
|
|
19
24
|
export declare class TooltipMixinClass {
|
|
20
|
-
/**
|
|
21
|
-
* Element used to link with the ARIA attribute controlled by the
|
|
22
|
-
* `ariaLinkMode` property. Supports array of multiple elements.
|
|
23
|
-
* When not set, defaults to `target`.
|
|
24
|
-
*/
|
|
25
|
-
ariaTarget: HTMLElement | HTMLElement[] | null | undefined;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Controls which ARIA attribute is used to link the target element(s)
|
|
29
|
-
* with the tooltip content. Supported values:
|
|
30
|
-
*
|
|
31
|
-
* - `aria-describedby` - links the tooltip as a description.
|
|
32
|
-
* - `aria-labelledby` - links the tooltip as an accessible name.
|
|
33
|
-
* - `none` - does not add any ARIA linking attribute.
|
|
34
|
-
*
|
|
35
|
-
* Defaults to `aria-describedby`.
|
|
36
|
-
*
|
|
37
|
-
* @attr {string} aria-link-mode
|
|
38
|
-
*/
|
|
39
|
-
ariaLinkMode: 'aria-describedby' | 'aria-labelledby' | 'none';
|
|
40
|
-
|
|
41
25
|
/**
|
|
42
26
|
* Object with properties passed to `generator` and
|
|
43
27
|
* `shouldShow` functions for generating tooltip text
|
|
@@ -4,11 +4,11 @@
|
|
|
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 { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
8
7
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
9
8
|
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
10
9
|
import { PopoverPositionMixin } from '@vaadin/popover/src/vaadin-popover-position-mixin.js';
|
|
11
10
|
import { PopoverTargetMixin } from '@vaadin/popover/src/vaadin-popover-target-mixin.js';
|
|
11
|
+
import { TooltipAriaMixin } from './vaadin-tooltip-aria-mixin.js';
|
|
12
12
|
|
|
13
13
|
const DEFAULT_DELAY = 500;
|
|
14
14
|
|
|
@@ -218,35 +218,9 @@ class TooltipStateController {
|
|
|
218
218
|
* A mixin providing common tooltip functionality.
|
|
219
219
|
*/
|
|
220
220
|
export const TooltipMixin = (superClass) =>
|
|
221
|
-
class TooltipMixinClass extends PopoverPositionMixin(PopoverTargetMixin(superClass)) {
|
|
221
|
+
class TooltipMixinClass extends TooltipAriaMixin(PopoverPositionMixin(PopoverTargetMixin(superClass))) {
|
|
222
222
|
static get properties() {
|
|
223
223
|
return {
|
|
224
|
-
/**
|
|
225
|
-
* Element used to link with the ARIA attribute controlled by the
|
|
226
|
-
* `ariaLinkMode` property. Supports array of multiple elements.
|
|
227
|
-
* When not set, defaults to `target`.
|
|
228
|
-
*/
|
|
229
|
-
ariaTarget: {
|
|
230
|
-
type: Object,
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Controls which ARIA attribute is used to link the target element(s)
|
|
235
|
-
* with the tooltip content. Supported values:
|
|
236
|
-
*
|
|
237
|
-
* - `aria-describedby` - links the tooltip as a description.
|
|
238
|
-
* - `aria-labelledby` - links the tooltip as an accessible name.
|
|
239
|
-
* - `none` - does not add any ARIA linking attribute.
|
|
240
|
-
*
|
|
241
|
-
* Defaults to `aria-describedby`.
|
|
242
|
-
*
|
|
243
|
-
* @attr {string} aria-link-mode
|
|
244
|
-
*/
|
|
245
|
-
ariaLinkMode: {
|
|
246
|
-
type: String,
|
|
247
|
-
value: 'aria-describedby',
|
|
248
|
-
},
|
|
249
|
-
|
|
250
224
|
/**
|
|
251
225
|
* Object with properties passed to `generator` and
|
|
252
226
|
* `shouldShow` functions for generating tooltip text
|
|
@@ -355,16 +329,6 @@ export const TooltipMixin = (superClass) =>
|
|
|
355
329
|
reflectToAttribute: true,
|
|
356
330
|
},
|
|
357
331
|
|
|
358
|
-
/**
|
|
359
|
-
* Element used to link with the `aria-describedby`
|
|
360
|
-
* attribute. When not set, defaults to `target`.
|
|
361
|
-
* @protected
|
|
362
|
-
*/
|
|
363
|
-
_effectiveAriaTarget: {
|
|
364
|
-
type: Object,
|
|
365
|
-
computed: '__computeAriaTarget(ariaTarget, target)',
|
|
366
|
-
},
|
|
367
|
-
|
|
368
332
|
/** @private */
|
|
369
333
|
__isTargetHidden: {
|
|
370
334
|
type: Boolean,
|
|
@@ -476,16 +440,6 @@ export const TooltipMixin = (superClass) =>
|
|
|
476
440
|
if (props.has('text') || props.has('generator') || props.has('context') || props.has('markdown')) {
|
|
477
441
|
this.__updateContent();
|
|
478
442
|
}
|
|
479
|
-
|
|
480
|
-
const ariaTargetChanged = props.has('_effectiveAriaTarget');
|
|
481
|
-
const ariaLinkChanged = props.has('ariaLinkMode');
|
|
482
|
-
|
|
483
|
-
if (ariaTargetChanged || ariaLinkChanged) {
|
|
484
|
-
const oldTarget = ariaTargetChanged ? props.get('_effectiveAriaTarget') : this._effectiveAriaTarget;
|
|
485
|
-
const oldMode = ariaLinkChanged ? props.get('ariaLinkMode') : this.ariaLinkMode;
|
|
486
|
-
|
|
487
|
-
this.__updateAriaAttributes(oldTarget, oldMode);
|
|
488
|
-
}
|
|
489
443
|
}
|
|
490
444
|
|
|
491
445
|
/** @private */
|
|
@@ -746,32 +700,6 @@ export const TooltipMixin = (superClass) =>
|
|
|
746
700
|
}
|
|
747
701
|
}
|
|
748
702
|
|
|
749
|
-
/** @private */
|
|
750
|
-
__computeAriaTarget(ariaTarget, target) {
|
|
751
|
-
const isElementNode = (el) => el?.nodeType === Node.ELEMENT_NODE;
|
|
752
|
-
const isAriaTargetSet = Array.isArray(ariaTarget) ? ariaTarget.some(isElementNode) : ariaTarget;
|
|
753
|
-
return ariaTarget === null || isAriaTargetSet ? ariaTarget : target;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/** @private */
|
|
757
|
-
__updateAriaAttributes(oldTarget, oldMode) {
|
|
758
|
-
// Remove the previously applied attribute from the previous target(s).
|
|
759
|
-
if (oldTarget && oldMode && oldMode !== 'none') {
|
|
760
|
-
[oldTarget].flat().forEach((target) => {
|
|
761
|
-
removeValueFromAttribute(target, oldMode, this._uniqueId);
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// Apply the current attribute to the current target(s).
|
|
766
|
-
const target = this._effectiveAriaTarget;
|
|
767
|
-
const mode = this.ariaLinkMode;
|
|
768
|
-
if (target && mode && mode !== 'none') {
|
|
769
|
-
[target].flat().forEach((el) => {
|
|
770
|
-
addValueToAttribute(el, mode, this._uniqueId);
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
703
|
/** @private **/
|
|
776
704
|
static __importMarkdownHelpers() {
|
|
777
705
|
if (!this.__markdownHelpers) {
|
|
@@ -16,6 +16,7 @@ import { tooltipOverlayStyles } from './styles/vaadin-tooltip-overlay-base-style
|
|
|
16
16
|
/**
|
|
17
17
|
* An element used internally by `<vaadin-tooltip>`. Not intended to be used separately.
|
|
18
18
|
*
|
|
19
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
19
20
|
* @customElement vaadin-tooltip-overlay
|
|
20
21
|
* @extends HTMLElement
|
|
21
22
|
* @private
|
package/src/vaadin-tooltip.js
CHANGED
|
@@ -73,6 +73,7 @@ import { TooltipMixin } from './vaadin-tooltip-mixin.js';
|
|
|
73
73
|
*
|
|
74
74
|
* @fires {CustomEvent} content-changed - Fired when the tooltip text content is changed.
|
|
75
75
|
*
|
|
76
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
76
77
|
* @customElement vaadin-tooltip
|
|
77
78
|
* @extends HTMLElement
|
|
78
79
|
*/
|
package/web-types.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.
|
|
4
|
+
"version": "25.3.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -105,9 +105,7 @@
|
|
|
105
105
|
"description": "The theme variants to apply to the component.",
|
|
106
106
|
"value": {
|
|
107
107
|
"type": [
|
|
108
|
-
"string"
|
|
109
|
-
"null",
|
|
110
|
-
"undefined"
|
|
108
|
+
"string"
|
|
111
109
|
]
|
|
112
110
|
}
|
|
113
111
|
}
|