@vaadin/tooltip 24.2.0-dev.f254716fe → 24.2.0

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": "24.2.0-dev.f254716fe",
3
+ "version": "24.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,21 +35,21 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/a11y-base": "24.2.0-dev.f254716fe",
39
- "@vaadin/component-base": "24.2.0-dev.f254716fe",
40
- "@vaadin/overlay": "24.2.0-dev.f254716fe",
41
- "@vaadin/vaadin-lumo-styles": "24.2.0-dev.f254716fe",
42
- "@vaadin/vaadin-material-styles": "24.2.0-dev.f254716fe",
43
- "@vaadin/vaadin-themable-mixin": "24.2.0-dev.f254716fe"
38
+ "@vaadin/a11y-base": "~24.2.0",
39
+ "@vaadin/component-base": "~24.2.0",
40
+ "@vaadin/overlay": "~24.2.0",
41
+ "@vaadin/vaadin-lumo-styles": "~24.2.0",
42
+ "@vaadin/vaadin-material-styles": "~24.2.0",
43
+ "@vaadin/vaadin-themable-mixin": "~24.2.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
47
- "@vaadin/testing-helpers": "^0.4.3",
47
+ "@vaadin/testing-helpers": "^0.5.0",
48
48
  "sinon": "^13.0.2"
49
49
  },
50
50
  "web-types": [
51
51
  "web-types.json",
52
52
  "web-types.lit.json"
53
53
  ],
54
- "gitHead": "da54950b9f8c14c6451ede0d426e16a489c7fb9b"
54
+ "gitHead": "8b9e860d53fc0132d05d3e8701eeded2dca74eba"
55
55
  }
@@ -4,6 +4,7 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
7
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
9
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
9
10
  import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
@@ -53,6 +54,7 @@ registerStyles('vaadin-tooltip-overlay', [overlayStyles, tooltipOverlayStyles],
53
54
  /**
54
55
  * An element used internally by `<vaadin-tooltip>`. Not intended to be used separately.
55
56
  *
57
+ * @customElement
56
58
  * @extends HTMLElement
57
59
  * @mixes DirMixin
58
60
  * @mixes OverlayMixin
@@ -155,4 +157,4 @@ class TooltipOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(P
155
157
  }
156
158
  }
157
159
 
158
- customElements.define(TooltipOverlay.is, TooltipOverlay);
160
+ defineCustomElement(TooltipOverlay);
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
6
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
8
  import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
8
9
  import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
@@ -59,7 +60,7 @@ export type TooltipPosition =
59
60
  *
60
61
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
61
62
  */
62
- declare class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(HTMLElement))) {
63
+ declare class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ControllerMixin(ElementMixin(HTMLElement)))) {
63
64
  /**
64
65
  * Sets the default focus delay to be used by all tooltip instances,
65
66
  * except for those that have focus delay configured using property.
@@ -78,6 +79,13 @@ declare class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(
78
79
  */
79
80
  static setDefaultHoverDelay(delay: number): void;
80
81
 
82
+ /**
83
+ * Element used to link with the `aria-describedby`
84
+ * attribute. Supports array of multiple elements.
85
+ * When not set, defaults to `target`.
86
+ */
87
+ ariaTarget: HTMLElement | HTMLElement[] | undefined;
88
+
81
89
  /**
82
90
  * Object with properties passed to `generator` and
83
91
  * `shouldShow` functions for generating tooltip text
@@ -7,10 +7,13 @@ import './vaadin-tooltip-overlay.js';
7
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
8
  import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
9
9
  import { microTask } from '@vaadin/component-base/src/async.js';
10
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
10
11
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
12
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
11
13
  import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
12
14
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
13
15
  import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
16
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
14
17
  import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
15
18
  import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
16
19
 
@@ -69,6 +72,14 @@ class TooltipStateController {
69
72
  return tooltip.hideDelay != null && tooltip.hideDelay > 0 ? tooltip.hideDelay : defaultHideDelay;
70
73
  }
71
74
 
75
+ /**
76
+ * Whether closing is currently in progress.
77
+ * @return {boolean}
78
+ */
79
+ get isClosing() {
80
+ return closing.has(this.host);
81
+ }
82
+
72
83
  /**
73
84
  * Schedule opening the tooltip.
74
85
  * @param {Object} options
@@ -244,12 +255,14 @@ class TooltipStateController {
244
255
  *
245
256
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
246
257
  *
258
+ * @customElement
247
259
  * @extends HTMLElement
260
+ * @mixes ControllerMixin
248
261
  * @mixes ElementMixin
249
262
  * @mixes OverlayClassMixin
250
263
  * @mixes ThemePropertyMixin
251
264
  */
252
- class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerElement))) {
265
+ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(ControllerMixin(PolymerElement)))) {
253
266
  static get is() {
254
267
  return 'vaadin-tooltip';
255
268
  }
@@ -262,8 +275,6 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
262
275
  }
263
276
  </style>
264
277
  <vaadin-tooltip-overlay
265
- id="[[_uniqueId]]"
266
- role="tooltip"
267
278
  renderer="[[_renderer]]"
268
279
  theme$="[[_theme]]"
269
280
  opened="[[__computeOpened(manual, opened, _autoOpened, _isConnected)]]"
@@ -273,14 +284,26 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
273
284
  no-vertical-overlap$="[[__computeNoVerticalOverlap(__effectivePosition)]]"
274
285
  horizontal-align="[[__computeHorizontalAlign(__effectivePosition)]]"
275
286
  vertical-align="[[__computeVerticalAlign(__effectivePosition)]]"
287
+ on-mouseenter="__onOverlayMouseEnter"
276
288
  on-mouseleave="__onOverlayMouseLeave"
277
289
  modeless
278
290
  ></vaadin-tooltip-overlay>
291
+
292
+ <slot name="sr-label"></slot>
279
293
  `;
280
294
  }
281
295
 
282
296
  static get properties() {
283
297
  return {
298
+ /**
299
+ * Element used to link with the `aria-describedby`
300
+ * attribute. Supports array of multiple elements.
301
+ * When not set, defaults to `target`.
302
+ */
303
+ ariaTarget: {
304
+ type: Object,
305
+ },
306
+
284
307
  /**
285
308
  * Object with properties passed to `generator` and
286
309
  * `shouldShow` functions for generating tooltip text
@@ -420,6 +443,17 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
420
443
  value: 'bottom',
421
444
  },
422
445
 
446
+ /**
447
+ * Element used to link with the `aria-describedby`
448
+ * attribute. When not set, defaults to `target`.
449
+ * @protected
450
+ */
451
+ _effectiveAriaTarget: {
452
+ type: Object,
453
+ computed: '__computeAriaTarget(ariaTarget, target)',
454
+ observer: '__effectiveAriaTargetChanged',
455
+ },
456
+
423
457
  /** @private */
424
458
  __effectivePosition: {
425
459
  type: String,
@@ -436,11 +470,24 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
436
470
  _isConnected: {
437
471
  type: Boolean,
438
472
  },
473
+
474
+ /** @private */
475
+ _srLabel: {
476
+ type: Object,
477
+ },
478
+
479
+ /** @private */
480
+ _overlayContent: {
481
+ type: String,
482
+ },
439
483
  };
440
484
  }
441
485
 
442
486
  static get observers() {
443
- return ['__generatorChanged(_overlayElement, generator, context)'];
487
+ return [
488
+ '__generatorChanged(_overlayElement, generator, context)',
489
+ '__updateSrLabelText(_srLabel, _overlayContent)',
490
+ ];
444
491
  }
445
492
 
446
493
  /**
@@ -518,6 +565,27 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
518
565
  document.body.removeEventListener('vaadin-overlay-open', this.__onOverlayOpen);
519
566
  }
520
567
 
568
+ /** @protected */
569
+ ready() {
570
+ super.ready();
571
+
572
+ this._srLabelController = new SlotController(this, 'sr-label', 'div', {
573
+ initializer: (element) => {
574
+ element.id = this._uniqueId;
575
+ element.setAttribute('role', 'tooltip');
576
+ this._srLabel = element;
577
+ },
578
+ });
579
+ this.addController(this._srLabelController);
580
+ }
581
+
582
+ /** @private */
583
+ __computeAriaTarget(ariaTarget, target) {
584
+ const isElementNode = (el) => el && el.nodeType === Node.ELEMENT_NODE;
585
+ const isAriaTargetSet = Array.isArray(ariaTarget) ? ariaTarget.some(isElementNode) : ariaTarget;
586
+ return isAriaTargetSet ? ariaTarget : target;
587
+ }
588
+
521
589
  /** @private */
522
590
  __computeHorizontalAlign(position) {
523
591
  return ['top-end', 'bottom-end', 'start-top', 'start', 'start-bottom'].includes(position) ? 'end' : 'start';
@@ -551,6 +619,24 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
551
619
  /** @private */
552
620
  __tooltipRenderer(root) {
553
621
  root.textContent = typeof this.generator === 'function' ? this.generator(this.context) : this.text;
622
+
623
+ // Update the sr-only label text content
624
+ this._overlayContent = root.textContent;
625
+ }
626
+
627
+ /** @private */
628
+ __effectiveAriaTargetChanged(ariaTarget, oldAriaTarget) {
629
+ if (oldAriaTarget) {
630
+ [oldAriaTarget].flat().forEach((target) => {
631
+ removeValueFromAttribute(target, 'aria-describedby', this._uniqueId);
632
+ });
633
+ }
634
+
635
+ if (ariaTarget) {
636
+ [ariaTarget].flat().forEach((target) => {
637
+ addValueToAttribute(target, 'aria-describedby', this._uniqueId);
638
+ });
639
+ }
554
640
  }
555
641
 
556
642
  /** @private */
@@ -596,8 +682,6 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
596
682
  oldTarget.removeEventListener('mousedown', this.__onMouseDown);
597
683
 
598
684
  this.__targetVisibilityObserver.unobserve(oldTarget);
599
-
600
- removeValueFromAttribute(oldTarget, 'aria-describedby', this._uniqueId);
601
685
  }
602
686
 
603
687
  if (target) {
@@ -611,8 +695,6 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
611
695
  requestAnimationFrame(() => {
612
696
  this.__targetVisibilityObserver.observe(target);
613
697
  });
614
-
615
- addValueToAttribute(target, 'aria-describedby', this._uniqueId);
616
698
  }
617
699
  }
618
700
 
@@ -703,6 +785,17 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
703
785
  }
704
786
  }
705
787
 
788
+ /** @private */
789
+ __onOverlayMouseEnter() {
790
+ // Retain opened state when moving pointer over the overlay.
791
+ // Closing can start due to an offset between the target and
792
+ // the overlay itself. If that's the case, re-open overlay.
793
+ // See https://github.com/vaadin/web-components/issues/6316
794
+ if (this._stateController.isClosing) {
795
+ this._stateController.open({ immediate: true });
796
+ }
797
+ }
798
+
706
799
  /** @private */
707
800
  __onOverlayMouseLeave(event) {
708
801
  if (event.relatedTarget !== this.target) {
@@ -779,8 +872,15 @@ class Tooltip extends OverlayClassMixin(ThemePropertyMixin(ElementMixin(PolymerE
779
872
  this.__oldContext = context;
780
873
  }
781
874
  }
875
+
876
+ /** @private */
877
+ __updateSrLabelText(srLabel, textContent) {
878
+ if (srLabel) {
879
+ srLabel.textContent = textContent;
880
+ }
881
+ }
782
882
  }
783
883
 
784
- customElements.define(Tooltip.is, Tooltip);
884
+ defineCustomElement(Tooltip);
785
885
 
786
886
  export { Tooltip };
package/web-types.json ADDED
@@ -0,0 +1,287 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/tooltip",
4
+ "version": "24.2.0",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
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.2.0/#/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
+ "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
+ {
25
+ "name": "focus-delay",
26
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
27
+ "value": {
28
+ "type": [
29
+ "number",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
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.",
38
+ "value": {
39
+ "type": [
40
+ "string",
41
+ "null",
42
+ "undefined"
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "name": "hide-delay",
48
+ "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.",
49
+ "value": {
50
+ "type": [
51
+ "number",
52
+ "null",
53
+ "undefined"
54
+ ]
55
+ }
56
+ },
57
+ {
58
+ "name": "hover-delay",
59
+ "description": "The delay in milliseconds before the tooltip\nis opened on hover, when not in manual mode.",
60
+ "value": {
61
+ "type": [
62
+ "number",
63
+ "null",
64
+ "undefined"
65
+ ]
66
+ }
67
+ },
68
+ {
69
+ "name": "manual",
70
+ "description": "When true, the tooltip is controlled programmatically\ninstead of reacting to focus and mouse events.",
71
+ "value": {
72
+ "type": [
73
+ "boolean",
74
+ "null",
75
+ "undefined"
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "name": "opened",
81
+ "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
82
+ "value": {
83
+ "type": [
84
+ "boolean",
85
+ "null",
86
+ "undefined"
87
+ ]
88
+ }
89
+ },
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
+ {
102
+ "name": "text",
103
+ "description": "String used as a tooltip content.",
104
+ "value": {
105
+ "type": [
106
+ "string",
107
+ "null",
108
+ "undefined"
109
+ ]
110
+ }
111
+ },
112
+ {
113
+ "name": "theme",
114
+ "description": "The theme variants to apply to the component.",
115
+ "value": {
116
+ "type": [
117
+ "string",
118
+ "null",
119
+ "undefined"
120
+ ]
121
+ }
122
+ }
123
+ ],
124
+ "js": {
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
+ {
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`.",
140
+ "value": {
141
+ "type": [
142
+ "Object",
143
+ "null",
144
+ "undefined"
145
+ ]
146
+ }
147
+ },
148
+ {
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.",
151
+ "value": {
152
+ "type": [
153
+ "Object",
154
+ "null",
155
+ "undefined"
156
+ ]
157
+ }
158
+ },
159
+ {
160
+ "name": "focusDelay",
161
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
162
+ "value": {
163
+ "type": [
164
+ "number",
165
+ "null",
166
+ "undefined"
167
+ ]
168
+ }
169
+ },
170
+ {
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.",
173
+ "value": {
174
+ "type": [
175
+ "string",
176
+ "null",
177
+ "undefined"
178
+ ]
179
+ }
180
+ },
181
+ {
182
+ "name": "hideDelay",
183
+ "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.",
184
+ "value": {
185
+ "type": [
186
+ "number",
187
+ "null",
188
+ "undefined"
189
+ ]
190
+ }
191
+ },
192
+ {
193
+ "name": "hoverDelay",
194
+ "description": "The delay in milliseconds before the tooltip\nis opened on hover, when not in manual mode.",
195
+ "value": {
196
+ "type": [
197
+ "number",
198
+ "null",
199
+ "undefined"
200
+ ]
201
+ }
202
+ },
203
+ {
204
+ "name": "manual",
205
+ "description": "When true, the tooltip is controlled programmatically\ninstead of reacting to focus and mouse events.",
206
+ "value": {
207
+ "type": [
208
+ "boolean",
209
+ "null",
210
+ "undefined"
211
+ ]
212
+ }
213
+ },
214
+ {
215
+ "name": "opened",
216
+ "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
217
+ "value": {
218
+ "type": [
219
+ "boolean",
220
+ "null",
221
+ "undefined"
222
+ ]
223
+ }
224
+ },
225
+ {
226
+ "name": "position",
227
+ "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`.",
228
+ "value": {
229
+ "type": [
230
+ "string",
231
+ "null",
232
+ "undefined"
233
+ ]
234
+ }
235
+ },
236
+ {
237
+ "name": "shouldShow",
238
+ "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`.",
239
+ "value": {
240
+ "type": [
241
+ "Object",
242
+ "null",
243
+ "undefined"
244
+ ]
245
+ }
246
+ },
247
+ {
248
+ "name": "target",
249
+ "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`.",
250
+ "value": {
251
+ "type": [
252
+ "Object",
253
+ "null",
254
+ "undefined"
255
+ ]
256
+ }
257
+ },
258
+ {
259
+ "name": "text",
260
+ "description": "String used as a tooltip content.",
261
+ "value": {
262
+ "type": [
263
+ "string",
264
+ "null",
265
+ "undefined"
266
+ ]
267
+ }
268
+ },
269
+ {
270
+ "name": "generator",
271
+ "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.",
272
+ "value": {
273
+ "type": [
274
+ "Object",
275
+ "null",
276
+ "undefined"
277
+ ]
278
+ }
279
+ }
280
+ ],
281
+ "events": []
282
+ }
283
+ }
284
+ ]
285
+ }
286
+ }
287
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/tooltip",
4
+ "version": "24.2.0",
5
+ "description-markup": "markdown",
6
+ "framework": "lit",
7
+ "framework-config": {
8
+ "enable-when": {
9
+ "node-packages": [
10
+ "lit"
11
+ ]
12
+ }
13
+ },
14
+ "contributions": {
15
+ "html": {
16
+ "elements": [
17
+ {
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.2.0/#/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
+ "extension": true,
21
+ "attributes": [
22
+ {
23
+ "name": "?manual",
24
+ "description": "When true, the tooltip is controlled programmatically\ninstead of reacting to focus and mouse events.",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
29
+ {
30
+ "name": "?opened",
31
+ "description": "When true, the tooltip is opened programmatically.\nOnly works if `manual` is set to `true`.",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
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.",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
42
+ },
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`.",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
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.",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
57
+ {
58
+ "name": ".focusDelay",
59
+ "description": "The delay in milliseconds before the tooltip\nis opened on keyboard focus, when not in manual mode.",
60
+ "value": {
61
+ "kind": "expression"
62
+ }
63
+ },
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.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ },
71
+ {
72
+ "name": ".hideDelay",
73
+ "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.",
74
+ "value": {
75
+ "kind": "expression"
76
+ }
77
+ },
78
+ {
79
+ "name": ".hoverDelay",
80
+ "description": "The delay in milliseconds before the tooltip\nis opened on hover, when not in manual mode.",
81
+ "value": {
82
+ "kind": "expression"
83
+ }
84
+ },
85
+ {
86
+ "name": ".position",
87
+ "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`.",
88
+ "value": {
89
+ "kind": "expression"
90
+ }
91
+ },
92
+ {
93
+ "name": ".shouldShow",
94
+ "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`.",
95
+ "value": {
96
+ "kind": "expression"
97
+ }
98
+ },
99
+ {
100
+ "name": ".target",
101
+ "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`.",
102
+ "value": {
103
+ "kind": "expression"
104
+ }
105
+ },
106
+ {
107
+ "name": ".text",
108
+ "description": "String used as a tooltip content.",
109
+ "value": {
110
+ "kind": "expression"
111
+ }
112
+ },
113
+ {
114
+ "name": ".generator",
115
+ "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.",
116
+ "value": {
117
+ "kind": "expression"
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ ]
123
+ }
124
+ }
125
+ }