@vaadin/tooltip 24.2.0-beta3 → 24.2.0-beta4

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.
@@ -1,86 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
7
- import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
8
-
9
- /**
10
- * A mixin providing common tooltip overlay functionality.
11
- *
12
- * @polymerMixin
13
- * @mixes PositionMixin
14
- * @mixes OverlayMixin
15
- */
16
- export const TooltipOverlayMixin = (superClass) =>
17
- class TooltipOverlayMixinClass extends PositionMixin(OverlayMixin(superClass)) {
18
- static get properties() {
19
- return {
20
- position: {
21
- type: String,
22
- reflectToAttribute: true,
23
- },
24
- };
25
- }
26
-
27
- requestContentUpdate() {
28
- super.requestContentUpdate();
29
-
30
- this.toggleAttribute('hidden', this.textContent.trim() === '');
31
-
32
- // Copy custom properties from the tooltip
33
- if (this.positionTarget && this.owner) {
34
- const style = getComputedStyle(this.owner);
35
- ['top', 'bottom', 'start', 'end'].forEach((prop) => {
36
- this.style.setProperty(
37
- `--vaadin-tooltip-offset-${prop}`,
38
- style.getPropertyValue(`--vaadin-tooltip-offset-${prop}`),
39
- );
40
- });
41
- }
42
- }
43
-
44
- /**
45
- * @protected
46
- * @override
47
- */
48
- _updatePosition() {
49
- super._updatePosition();
50
-
51
- if (!this.positionTarget) {
52
- return;
53
- }
54
-
55
- // Center the tooltip overlay horizontally
56
- if (this.position === 'bottom' || this.position === 'top') {
57
- const targetRect = this.positionTarget.getBoundingClientRect();
58
- const overlayRect = this.$.overlay.getBoundingClientRect();
59
-
60
- const offset = targetRect.width / 2 - overlayRect.width / 2;
61
-
62
- if (this.style.left) {
63
- const left = overlayRect.left + offset;
64
- if (left > 0) {
65
- this.style.left = `${left}px`;
66
- }
67
- }
68
-
69
- if (this.style.right) {
70
- const right = parseFloat(this.style.right) + offset;
71
- if (right > 0) {
72
- this.style.right = `${right}px`;
73
- }
74
- }
75
- }
76
-
77
- // Center the tooltip overlay vertically
78
- if (this.position === 'start' || this.position === 'end') {
79
- const targetRect = this.positionTarget.getBoundingClientRect();
80
- const overlayRect = this.$.overlay.getBoundingClientRect();
81
-
82
- const offset = targetRect.height / 2 - overlayRect.height / 2;
83
- this.style.top = `${overlayRect.top + offset}px`;
84
- }
85
- }
86
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 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,42 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
-
8
- export const tooltipOverlayStyles = css`
9
- :host {
10
- z-index: 1100;
11
- }
12
-
13
- [part='overlay'] {
14
- max-width: 40ch;
15
- }
16
-
17
- :host([position^='top'][top-aligned]) [part='overlay'],
18
- :host([position^='bottom'][top-aligned]) [part='overlay'] {
19
- margin-top: var(--vaadin-tooltip-offset-top, 0);
20
- }
21
-
22
- :host([position^='top'][bottom-aligned]) [part='overlay'],
23
- :host([position^='bottom'][bottom-aligned]) [part='overlay'] {
24
- margin-bottom: var(--vaadin-tooltip-offset-bottom, 0);
25
- }
26
-
27
- :host([position^='start'][start-aligned]) [part='overlay'],
28
- :host([position^='end'][start-aligned]) [part='overlay'] {
29
- margin-inline-start: var(--vaadin-tooltip-offset-start, 0);
30
- }
31
-
32
- :host([position^='start'][end-aligned]) [part='overlay'],
33
- :host([position^='end'][end-aligned]) [part='overlay'] {
34
- margin-inline-end: var(--vaadin-tooltip-offset-end, 0);
35
- }
36
-
37
- @media (forced-colors: active) {
38
- [part='overlay'] {
39
- outline: 1px dashed;
40
- }
41
- }
42
- `;