@vaadin/tooltip 25.3.0-dev.1fa5a51482 → 25.3.0-rc1
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 +1 -1
- package/package.json +12 -12
- package/src/vaadin-tooltip-aria-mixin.d.ts +4 -0
- package/src/vaadin-tooltip-aria-mixin.js +50 -22
- package/web-types.json +1 -1
- package/web-types.lit.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"declarations": [
|
|
24
24
|
{
|
|
25
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.",
|
|
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
27
|
"name": "TooltipAriaMixin",
|
|
28
28
|
"members": [
|
|
29
29
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/tooltip",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-rc1",
|
|
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": "25.3.0-
|
|
39
|
-
"@vaadin/component-base": "25.3.0-
|
|
40
|
-
"@vaadin/markdown": "25.3.0-
|
|
41
|
-
"@vaadin/overlay": "25.3.0-
|
|
42
|
-
"@vaadin/popover": "25.3.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
38
|
+
"@vaadin/a11y-base": "25.3.0-rc1",
|
|
39
|
+
"@vaadin/component-base": "25.3.0-rc1",
|
|
40
|
+
"@vaadin/markdown": "25.3.0-rc1",
|
|
41
|
+
"@vaadin/overlay": "25.3.0-rc1",
|
|
42
|
+
"@vaadin/popover": "25.3.0-rc1",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-rc1",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/aura": "25.3.0-
|
|
48
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
49
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
47
|
+
"@vaadin/aura": "25.3.0-rc1",
|
|
48
|
+
"@vaadin/chai-plugins": "25.3.0-rc1",
|
|
49
|
+
"@vaadin/test-runner-commands": "25.3.0-rc1",
|
|
50
50
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
51
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
51
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-rc1",
|
|
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": "d4809590b2f61bd607e376ab3dec84f4bfb059a7"
|
|
60
60
|
}
|
|
@@ -8,6 +8,10 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
8
8
|
/**
|
|
9
9
|
* A mixin providing linking of the tooltip content to the tooltip target
|
|
10
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.
|
|
11
15
|
*/
|
|
12
16
|
export declare function TooltipAriaMixin<T extends Constructor<HTMLElement>>(
|
|
13
17
|
base: T,
|
|
@@ -3,14 +3,21 @@
|
|
|
3
3
|
* Copyright (c) 2026 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
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';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* A mixin providing linking of the tooltip content to the tooltip target
|
|
10
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.
|
|
11
16
|
*/
|
|
12
17
|
export const TooltipAriaMixin = (superClass) =>
|
|
13
18
|
class TooltipAriaMixinClass extends superClass {
|
|
19
|
+
#ariaReferences = [];
|
|
20
|
+
|
|
14
21
|
static get properties() {
|
|
15
22
|
return {
|
|
16
23
|
/**
|
|
@@ -52,41 +59,62 @@ export const TooltipAriaMixin = (superClass) =>
|
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
/** @protected */
|
|
55
|
-
|
|
56
|
-
super.
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.#addAriaReferences();
|
|
65
|
+
}
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
/** @protected */
|
|
68
|
+
disconnectedCallback() {
|
|
69
|
+
super.disconnectedCallback();
|
|
70
|
+
this.#removeAriaReferences();
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.#removeAriaReferences(oldTarget, oldMode);
|
|
73
|
+
/** @protected */
|
|
74
|
+
updated(props) {
|
|
75
|
+
super.updated(props);
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.#addAriaReferences(newTarget, newMode);
|
|
77
|
+
if (props.has('_effectiveAriaTarget') || props.has('ariaLinkMode')) {
|
|
78
|
+
this.#updateAriaReferences();
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
72
|
-
#addAriaReferences(
|
|
73
|
-
|
|
82
|
+
#addAriaReferences() {
|
|
83
|
+
const mode = this.ariaLinkMode;
|
|
84
|
+
const targets = this._effectiveAriaTarget;
|
|
85
|
+
const contentNode = this.__contentNode;
|
|
86
|
+
if (!contentNode || !targets || !mode || mode === 'none') {
|
|
74
87
|
return;
|
|
75
88
|
}
|
|
76
89
|
|
|
77
|
-
[
|
|
78
|
-
|
|
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 });
|
|
79
99
|
});
|
|
80
100
|
}
|
|
81
101
|
|
|
82
|
-
#removeAriaReferences(
|
|
83
|
-
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
102
|
+
#removeAriaReferences() {
|
|
103
|
+
const contentNode = this.__contentNode;
|
|
86
104
|
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
this.#ariaReferences.forEach(({ target, mode, byReference }) => {
|
|
106
|
+
if (byReference) {
|
|
107
|
+
removeAriaElementReference(target, mode, contentNode);
|
|
108
|
+
} else {
|
|
109
|
+
removeValuesFromAttribute(target, mode, contentNode.id);
|
|
110
|
+
}
|
|
89
111
|
});
|
|
112
|
+
this.#ariaReferences = [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#updateAriaReferences() {
|
|
116
|
+
this.#removeAriaReferences();
|
|
117
|
+
this.#addAriaReferences();
|
|
90
118
|
}
|
|
91
119
|
|
|
92
120
|
/** @private */
|
package/web-types.json
CHANGED
package/web-types.lit.json
CHANGED