@spectrum-web-components/tooltip 0.10.14 → 0.10.17-devmode.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 +22 -9
- package/sp-tooltip.dev.js +3 -0
- package/sp-tooltip.dev.js.map +7 -0
- package/sp-tooltip.js +3 -14
- package/sp-tooltip.js.map +7 -1
- package/src/Tooltip.dev.js +206 -0
- package/src/Tooltip.dev.js.map +7 -0
- package/src/Tooltip.js +190 -201
- package/src/Tooltip.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/spectrum-tooltip.css.dev.js +92 -0
- package/src/spectrum-tooltip.css.dev.js.map +7 -0
- package/src/spectrum-tooltip.css.js +3 -14
- package/src/spectrum-tooltip.css.js.map +7 -1
- package/src/tooltip.css.dev.js +102 -0
- package/src/tooltip.css.dev.js.map +7 -0
- package/src/tooltip.css.js +3 -14
- package/src/tooltip.css.js.map +7 -1
- package/stories/tooltip.stories.js +221 -218
- package/stories/tooltip.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +5 -16
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/tooltip.test-vrt.js +4 -15
- package/test/tooltip.test-vrt.js.map +7 -1
- package/test/tooltip.test.js +97 -102
- package/test/tooltip.test.js.map +7 -1
package/src/Tooltip.js
CHANGED
|
@@ -1,217 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SpectrumElement
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import {
|
|
17
|
+
property,
|
|
18
|
+
query
|
|
19
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
|
+
import { openOverlay } from "@spectrum-web-components/overlay/src/loader.js";
|
|
21
|
+
import tooltipStyles from "./tooltip.css.js";
|
|
17
22
|
export class TooltipProxy extends HTMLElement {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
this.dispatchEvent(new Event("disconnected"));
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
|
-
customElements.define(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.addEventListener('sp-overlay-query', this.onOverlayQuery);
|
|
67
|
-
}
|
|
68
|
-
static get styles() {
|
|
69
|
-
return [tooltipStyles];
|
|
70
|
-
}
|
|
71
|
-
get variant() {
|
|
72
|
-
return this._variant;
|
|
73
|
-
}
|
|
74
|
-
set variant(variant) {
|
|
75
|
-
if (variant === this.variant) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (['info', 'positive', 'negative'].includes(variant)) {
|
|
79
|
-
this.setAttribute('variant', variant);
|
|
80
|
-
this._variant = variant;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
this.removeAttribute('variant');
|
|
84
|
-
this._variant = '';
|
|
27
|
+
customElements.define("tooltip-proxy", TooltipProxy);
|
|
28
|
+
const _Tooltip = class extends SpectrumElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this._tooltipId = `sp-tooltip-describedby-helper-${_Tooltip.instanceCount++}`;
|
|
32
|
+
this.selfManaged = false;
|
|
33
|
+
this.offset = 6;
|
|
34
|
+
this.hadTooltipId = false;
|
|
35
|
+
this.open = false;
|
|
36
|
+
this.placement = "top";
|
|
37
|
+
this._variant = "";
|
|
38
|
+
this.abortOverlay = () => {
|
|
39
|
+
return;
|
|
40
|
+
};
|
|
41
|
+
this.openOverlay = () => {
|
|
42
|
+
const parentElement = this.parentElement;
|
|
43
|
+
const abortPromise = new Promise((res) => {
|
|
44
|
+
this.abortOverlay = res;
|
|
45
|
+
});
|
|
46
|
+
this.closeOverlayCallback = openOverlay(parentElement, "hover", this, {
|
|
47
|
+
abortPromise,
|
|
48
|
+
offset: this.offset,
|
|
49
|
+
placement: this.placement
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
this.closeOverlay = async () => {
|
|
53
|
+
if (this.abortOverlay)
|
|
54
|
+
this.abortOverlay(true);
|
|
55
|
+
if (!this.closeOverlayCallback)
|
|
56
|
+
return;
|
|
57
|
+
(await this.closeOverlayCallback)();
|
|
58
|
+
delete this.closeOverlayCallback;
|
|
59
|
+
};
|
|
60
|
+
this.addEventListener("sp-overlay-query", this.onOverlayQuery);
|
|
61
|
+
}
|
|
62
|
+
static get styles() {
|
|
63
|
+
return [tooltipStyles];
|
|
64
|
+
}
|
|
65
|
+
get variant() {
|
|
66
|
+
return this._variant;
|
|
67
|
+
}
|
|
68
|
+
set variant(variant) {
|
|
69
|
+
if (variant === this.variant) {
|
|
70
|
+
return;
|
|
85
71
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const target = event.target;
|
|
91
|
-
/* c8 ignore next */
|
|
92
|
-
if (target !== this)
|
|
93
|
-
return;
|
|
94
|
-
event.detail.overlayContentTipElement = this.tipElement;
|
|
72
|
+
if (["info", "positive", "negative"].includes(variant)) {
|
|
73
|
+
this.setAttribute("variant", variant);
|
|
74
|
+
this._variant = variant;
|
|
75
|
+
return;
|
|
95
76
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
77
|
+
this.removeAttribute("variant");
|
|
78
|
+
this._variant = "";
|
|
79
|
+
}
|
|
80
|
+
onOverlayQuery(event) {
|
|
81
|
+
if (!event.target)
|
|
82
|
+
return;
|
|
83
|
+
const target = event.target;
|
|
84
|
+
if (target !== this)
|
|
85
|
+
return;
|
|
86
|
+
event.detail.overlayContentTipElement = this.tipElement;
|
|
87
|
+
}
|
|
88
|
+
generateProxy() {
|
|
89
|
+
if (this._proxy) {
|
|
90
|
+
return;
|
|
106
91
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
92
|
+
this._proxy = document.createElement("tooltip-proxy");
|
|
93
|
+
this._proxy.id = this._tooltipId;
|
|
94
|
+
this._proxy.hidden = true;
|
|
95
|
+
this._proxy.slot = "hidden-tooltip-content";
|
|
96
|
+
this._proxy.setAttribute("role", "tooltip");
|
|
97
|
+
this._proxy.addEventListener("disconnected", this.closeOverlay);
|
|
98
|
+
}
|
|
99
|
+
overlayWillOpenCallback({
|
|
100
|
+
trigger
|
|
101
|
+
}) {
|
|
102
|
+
this.setAttribute("aria-hidden", "true");
|
|
103
|
+
this.generateProxy();
|
|
104
|
+
this._proxy.textContent = this.textContent;
|
|
105
|
+
const ariaDescribedby = trigger.getAttribute("aria-describedby") || "";
|
|
106
|
+
this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;
|
|
107
|
+
this.insertAdjacentElement("beforebegin", this._proxy);
|
|
108
|
+
if (this.hadTooltipId)
|
|
109
|
+
return;
|
|
110
|
+
if (ariaDescribedby) {
|
|
111
|
+
trigger.setAttribute("aria-describedby", `${ariaDescribedby} ${this._tooltipId}`);
|
|
112
|
+
} else {
|
|
113
|
+
trigger.setAttribute("aria-describedby", `${this._tooltipId}`);
|
|
122
114
|
}
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
}
|
|
116
|
+
overlayOpenCancelledCallback({
|
|
117
|
+
trigger
|
|
118
|
+
}) {
|
|
119
|
+
this.overlayCloseCallback({ trigger });
|
|
120
|
+
}
|
|
121
|
+
overlayCloseCallback({ trigger }) {
|
|
122
|
+
const ariaDescribedby = trigger.getAttribute("aria-describedby") || "";
|
|
123
|
+
let descriptors = ariaDescribedby.split(/\s+/);
|
|
124
|
+
if (!this.hadTooltipId) {
|
|
125
|
+
descriptors = descriptors.filter((descriptor) => descriptor !== this._tooltipId);
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
descriptors = descriptors.filter((descriptor) => descriptor !== this._tooltipId);
|
|
131
|
-
}
|
|
132
|
-
if (descriptors.length) {
|
|
133
|
-
trigger.setAttribute('aria-describedby', descriptors.join(' '));
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
trigger.removeAttribute('aria-describedby');
|
|
137
|
-
}
|
|
138
|
-
this.removeAttribute('aria-hidden');
|
|
139
|
-
this.removeProxy();
|
|
127
|
+
if (descriptors.length) {
|
|
128
|
+
trigger.setAttribute("aria-describedby", descriptors.join(" "));
|
|
129
|
+
} else {
|
|
130
|
+
trigger.removeAttribute("aria-describedby");
|
|
140
131
|
}
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
this.removeAttribute("aria-hidden");
|
|
133
|
+
this.removeProxy();
|
|
134
|
+
}
|
|
135
|
+
removeProxy() {
|
|
136
|
+
this._proxy.remove();
|
|
137
|
+
}
|
|
138
|
+
manageTooltip() {
|
|
139
|
+
const parentElement = this.parentElement;
|
|
140
|
+
if (this.selfManaged) {
|
|
141
|
+
if (this.slot) {
|
|
142
|
+
this.previousSlot = this.slot;
|
|
143
|
+
}
|
|
144
|
+
this.slot = "self-managed-tooltip";
|
|
145
|
+
parentElement.addEventListener("pointerenter", this.openOverlay);
|
|
146
|
+
parentElement.addEventListener("focusin", this.openOverlay);
|
|
147
|
+
parentElement.addEventListener("pointerleave", this.closeOverlay);
|
|
148
|
+
parentElement.addEventListener("focusout", this.closeOverlay);
|
|
149
|
+
} else {
|
|
150
|
+
if (this.previousSlot) {
|
|
151
|
+
this.slot = this.previousSlot;
|
|
152
|
+
} else if (this.slot === "self-managed-tooltip") {
|
|
153
|
+
this.removeAttribute("slot");
|
|
154
|
+
}
|
|
155
|
+
parentElement.removeEventListener("pointerenter", this.openOverlay);
|
|
156
|
+
parentElement.removeEventListener("focusin", this.openOverlay);
|
|
157
|
+
parentElement.removeEventListener("pointerleave", this.closeOverlay);
|
|
158
|
+
parentElement.removeEventListener("focusout", this.closeOverlay);
|
|
143
159
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (this.slot) {
|
|
148
|
-
this.previousSlot = this.slot;
|
|
149
|
-
}
|
|
150
|
-
this.slot = 'self-managed-tooltip';
|
|
151
|
-
parentElement.addEventListener('pointerenter', this.openOverlay);
|
|
152
|
-
parentElement.addEventListener('focusin', this.openOverlay);
|
|
153
|
-
parentElement.addEventListener('pointerleave', this.closeOverlay);
|
|
154
|
-
parentElement.addEventListener('focusout', this.closeOverlay);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
if (this.previousSlot) {
|
|
158
|
-
this.slot = this.previousSlot;
|
|
159
|
-
}
|
|
160
|
-
else if (this.slot === 'self-managed-tooltip') {
|
|
161
|
-
this.removeAttribute('slot');
|
|
162
|
-
}
|
|
163
|
-
parentElement.removeEventListener('pointerenter', this.openOverlay);
|
|
164
|
-
parentElement.removeEventListener('focusin', this.openOverlay);
|
|
165
|
-
parentElement.removeEventListener('pointerleave', this.closeOverlay);
|
|
166
|
-
parentElement.removeEventListener('focusout', this.closeOverlay);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
render() {
|
|
170
|
-
return html `
|
|
160
|
+
}
|
|
161
|
+
render() {
|
|
162
|
+
return html`
|
|
171
163
|
<slot name="icon"></slot>
|
|
172
164
|
<span id="label"><slot></slot></span>
|
|
173
165
|
<span id="tip"></span>
|
|
174
166
|
`;
|
|
167
|
+
}
|
|
168
|
+
async update(changed) {
|
|
169
|
+
if (changed.has("open") && this.selfManaged) {
|
|
170
|
+
if (this.open) {
|
|
171
|
+
this.openOverlay();
|
|
172
|
+
} else {
|
|
173
|
+
this.closeOverlay();
|
|
174
|
+
}
|
|
175
175
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
this.generateProxy();
|
|
186
|
-
super.update(changed);
|
|
187
|
-
}
|
|
188
|
-
updated(changed) {
|
|
189
|
-
super.updated(changed);
|
|
190
|
-
if (changed.has('selfManaged')) {
|
|
191
|
-
this.manageTooltip();
|
|
192
|
-
}
|
|
176
|
+
this.generateProxy();
|
|
177
|
+
super.update(changed);
|
|
178
|
+
}
|
|
179
|
+
updated(changed) {
|
|
180
|
+
super.updated(changed);
|
|
181
|
+
if (changed.has("selfManaged")) {
|
|
182
|
+
this.manageTooltip();
|
|
193
183
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
*/
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
export let Tooltip = _Tooltip;
|
|
198
187
|
Tooltip.instanceCount = 0;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
], Tooltip.prototype, "selfManaged",
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
], Tooltip.prototype, "offset",
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
], Tooltip.prototype, "open",
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
], Tooltip.prototype, "placement",
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
], Tooltip.prototype, "tipElement",
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
], Tooltip.prototype, "variant",
|
|
217
|
-
//# sourceMappingURL=Tooltip.js.map
|
|
188
|
+
__decorateClass([
|
|
189
|
+
property({ type: Boolean, attribute: "self-managed" })
|
|
190
|
+
], Tooltip.prototype, "selfManaged", 2);
|
|
191
|
+
__decorateClass([
|
|
192
|
+
property({ type: Number, reflect: true })
|
|
193
|
+
], Tooltip.prototype, "offset", 2);
|
|
194
|
+
__decorateClass([
|
|
195
|
+
property({ type: Boolean, reflect: true })
|
|
196
|
+
], Tooltip.prototype, "open", 2);
|
|
197
|
+
__decorateClass([
|
|
198
|
+
property({ reflect: true })
|
|
199
|
+
], Tooltip.prototype, "placement", 2);
|
|
200
|
+
__decorateClass([
|
|
201
|
+
query("#tip")
|
|
202
|
+
], Tooltip.prototype, "tipElement", 2);
|
|
203
|
+
__decorateClass([
|
|
204
|
+
property({ type: String })
|
|
205
|
+
], Tooltip.prototype, "vari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,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAEkB,OAAO,CAAC,OAA6B;QACpD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;IACL,CAAC;;AArND;;GAEG;AACI,qBAAa,GAAG,CAAC,CAAC;AAKzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;4CAC5B;AAG3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCACxB;AAIlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACvB;AAOpB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACQ;AAGpC;IADC,KAAK,CAAC,MAAM,CAAC;2CACuB;AAMrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAG1B","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport type {\n OverlayDisplayQueryDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\nimport { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';\n\nimport tooltipStyles from './tooltip.css.js';\n\nexport class TooltipProxy extends HTMLElement {\n disconnectedCallback(): void {\n this.dispatchEvent(new Event('disconnected'));\n }\n}\n\ncustomElements.define('tooltip-proxy', TooltipProxy);\n\n/**\n * @element sp-tooltip\n *\n * @slot icon - the icon element appearing at the start of the label\n * @slot - the text label of the Tooltip\n */\n\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n private _tooltipId = `sp-tooltip-describedby-helper-${Tooltip.instanceCount++}`;\n\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number, reflect: true })\n public offset = 6;\n private hadTooltipId = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * @type {\"auto\" | \"auto-start\" | \"auto-end\" | \"top\" | \"bottom\" | \"right\" | \"left\" | \"top-start\" | \"top-end\" | \"bottom-start\" | \"bottom-end\" | \"right-start\" | \"right-end\" | \"left-start\" | \"left-end\" | \"none\"}\n * @attr\n */\n @property({ reflect: true })\n public placement: Placement = 'top';\n\n @query('#tip')\n private tipElement!: HTMLSpanElement;\n\n /* Ensure that a '' value for `variant` removes the attribute instead of a blank value */\n private _variant = '';\n\n @property({ type: String })\n public get variant(): string {\n return this._variant;\n }\n public set variant(variant: string) {\n if (variant === this.variant) {\n return;\n }\n if (['info', 'positive', 'negative'].includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n return;\n }\n this.removeAttribute('variant');\n this._variant = '';\n }\n\n public constructor() {\n super();\n this.addEventListener('sp-overlay-query', this.onOverlayQuery);\n }\n\n public onOverlayQuery(event: CustomEvent<OverlayDisplayQueryDetail>): void {\n /* c8 ignore next */\n if (!event.target) return;\n\n const target = event.target as Node;\n /* c8 ignore next */\n if (target !== this) return;\n\n event.detail.overlayContentTipElement = this.tipElement;\n }\n\n private _proxy!: HTMLElement;\n\n private generateProxy(): void {\n if (this._proxy) {\n return;\n }\n this._proxy = document.createElement('tooltip-proxy');\n this._proxy.id = this._tooltipId;\n this._proxy.hidden = true;\n this._proxy.slot = 'hidden-tooltip-content';\n this._proxy.setAttribute('role', 'tooltip');\n this._proxy.addEventListener('disconnected', this.closeOverlay);\n }\n\n public overlayWillOpenCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.setAttribute('aria-hidden', 'true');\n this.generateProxy();\n this._proxy.textContent = this.textContent;\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;\n\n this.insertAdjacentElement('beforebegin', this._proxy);\n\n if (this.hadTooltipId) return;\n\n if (ariaDescribedby) {\n trigger.setAttribute(\n 'aria-describedby',\n `${ariaDescribedby} ${this._tooltipId}`\n );\n } else {\n trigger.setAttribute('aria-describedby', `${this._tooltipId}`);\n }\n }\n\n public overlayOpenCancelledCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.overlayCloseCallback({ trigger });\n }\n\n public overlayCloseCallback({ trigger }: { trigger: HTMLElement }): void {\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n let descriptors = ariaDescribedby.split(/\\s+/);\n\n if (!this.hadTooltipId) {\n descriptors = descriptors.filter(\n (descriptor) => descriptor !== this._tooltipId\n );\n }\n if (descriptors.length) {\n trigger.setAttribute('aria-describedby', descriptors.join(' '));\n } else {\n trigger.removeAttribute('aria-describedby');\n }\n\n this.removeAttribute('aria-hidden');\n this.removeProxy();\n }\n\n private removeProxy(): void {\n this._proxy.remove();\n }\n\n private closeOverlayCallback?: Promise<() => void>;\n private abortOverlay: (cancelled: boolean) => void = () => {\n return;\n };\n\n private openOverlay = (): void => {\n const parentElement = this.parentElement as HTMLElement;\n const abortPromise: Promise<boolean> = new Promise((res) => {\n this.abortOverlay = res;\n });\n this.closeOverlayCallback = openOverlay(parentElement, 'hover', this, {\n abortPromise,\n offset: this.offset,\n placement: this.placement,\n });\n };\n\n private closeOverlay = async (): Promise<void> => {\n if (this.abortOverlay) this.abortOverlay(true);\n if (!this.closeOverlayCallback) return;\n (await this.closeOverlayCallback)();\n delete this.closeOverlayCallback;\n };\n\n private previousSlot?: string;\n\n private manageTooltip(): void {\n const parentElement = this.parentElement as HTMLElement;\n if (this.selfManaged) {\n if (this.slot) {\n this.previousSlot = this.slot;\n }\n this.slot = 'self-managed-tooltip';\n parentElement.addEventListener('pointerenter', this.openOverlay);\n parentElement.addEventListener('focusin', this.openOverlay);\n parentElement.addEventListener('pointerleave', this.closeOverlay);\n parentElement.addEventListener('focusout', this.closeOverlay);\n } else {\n if (this.previousSlot) {\n this.slot = this.previousSlot;\n } else if (this.slot === 'self-managed-tooltip') {\n this.removeAttribute('slot');\n }\n parentElement.removeEventListener('pointerenter', this.openOverlay);\n parentElement.removeEventListener('focusin', this.openOverlay);\n parentElement.removeEventListener(\n 'pointerleave',\n this.closeOverlay\n );\n parentElement.removeEventListener('focusout', this.closeOverlay);\n }\n }\n\n override render(): TemplateResult {\n return html`\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n `;\n }\n\n protected override async update(\n changed: PropertyValues<this>\n ): Promise<void> {\n if (changed.has('open') && this.selfManaged) {\n if (this.open) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n this.generateProxy();\n super.update(changed);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n super.updated(changed);\n if (changed.has('selfManaged')) {\n this.manageTooltip();\n }\n }\n}\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Tooltip.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport type {\n OverlayDisplayQueryDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\nimport { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';\n\nimport tooltipStyles from './tooltip.css.js';\n\nexport class TooltipProxy extends HTMLElement {\n disconnectedCallback(): void {\n this.dispatchEvent(new Event('disconnected'));\n }\n}\n\ncustomElements.define('tooltip-proxy', TooltipProxy);\n\n/**\n * @element sp-tooltip\n *\n * @slot icon - the icon element appearing at the start of the label\n * @slot - the text label of the Tooltip\n */\n\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n private _tooltipId = `sp-tooltip-describedby-helper-${Tooltip.instanceCount++}`;\n\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number, reflect: true })\n public offset = 6;\n private hadTooltipId = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * @type {\"auto\" | \"auto-start\" | \"auto-end\" | \"top\" | \"bottom\" | \"right\" | \"left\" | \"top-start\" | \"top-end\" | \"bottom-start\" | \"bottom-end\" | \"right-start\" | \"right-end\" | \"left-start\" | \"left-end\" | \"none\"}\n * @attr\n */\n @property({ reflect: true })\n public placement: Placement = 'top';\n\n @query('#tip')\n private tipElement!: HTMLSpanElement;\n\n /* Ensure that a '' value for `variant` removes the attribute instead of a blank value */\n private _variant = '';\n\n @property({ type: String })\n public get variant(): string {\n return this._variant;\n }\n public set variant(variant: string) {\n if (variant === this.variant) {\n return;\n }\n if (['info', 'positive', 'negative'].includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n return;\n }\n this.removeAttribute('variant');\n this._variant = '';\n }\n\n public constructor() {\n super();\n this.addEventListener('sp-overlay-query', this.onOverlayQuery);\n }\n\n public onOverlayQuery(event: CustomEvent<OverlayDisplayQueryDetail>): void {\n /* c8 ignore next */\n if (!event.target) return;\n\n const target = event.target as Node;\n /* c8 ignore next */\n if (target !== this) return;\n\n event.detail.overlayContentTipElement = this.tipElement;\n }\n\n private _proxy!: HTMLElement;\n\n private generateProxy(): void {\n if (this._proxy) {\n return;\n }\n this._proxy = document.createElement('tooltip-proxy');\n this._proxy.id = this._tooltipId;\n this._proxy.hidden = true;\n this._proxy.slot = 'hidden-tooltip-content';\n this._proxy.setAttribute('role', 'tooltip');\n this._proxy.addEventListener('disconnected', this.closeOverlay);\n }\n\n public overlayWillOpenCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.setAttribute('aria-hidden', 'true');\n this.generateProxy();\n this._proxy.textContent = this.textContent;\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;\n\n this.insertAdjacentElement('beforebegin', this._proxy);\n\n if (this.hadTooltipId) return;\n\n if (ariaDescribedby) {\n trigger.setAttribute(\n 'aria-describedby',\n `${ariaDescribedby} ${this._tooltipId}`\n );\n } else {\n trigger.setAttribute('aria-describedby', `${this._tooltipId}`);\n }\n }\n\n public overlayOpenCancelledCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.overlayCloseCallback({ trigger });\n }\n\n public overlayCloseCallback({ trigger }: { trigger: HTMLElement }): void {\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n let descriptors = ariaDescribedby.split(/\\s+/);\n\n if (!this.hadTooltipId) {\n descriptors = descriptors.filter(\n (descriptor) => descriptor !== this._tooltipId\n );\n }\n if (descriptors.length) {\n trigger.setAttribute('aria-describedby', descriptors.join(' '));\n } else {\n trigger.removeAttribute('aria-describedby');\n }\n\n this.removeAttribute('aria-hidden');\n this.removeProxy();\n }\n\n private removeProxy(): void {\n this._proxy.remove();\n }\n\n private closeOverlayCallback?: Promise<() => void>;\n private abortOverlay: (cancelled: boolean) => void = () => {\n return;\n };\n\n private openOverlay = (): void => {\n const parentElement = this.parentElement as HTMLElement;\n const abortPromise: Promise<boolean> = new Promise((res) => {\n this.abortOverlay = res;\n });\n this.closeOverlayCallback = openOverlay(parentElement, 'hover', this, {\n abortPromise,\n offset: this.offset,\n placement: this.placement,\n });\n };\n\n private closeOverlay = async (): Promise<void> => {\n if (this.abortOverlay) this.abortOverlay(true);\n if (!this.closeOverlayCallback) return;\n (await this.closeOverlayCallback)();\n delete this.closeOverlayCallback;\n };\n\n private previousSlot?: string;\n\n private manageTooltip(): void {\n const parentElement = this.parentElement as HTMLElement;\n if (this.selfManaged) {\n if (this.slot) {\n this.previousSlot = this.slot;\n }\n this.slot = 'self-managed-tooltip';\n parentElement.addEventListener('pointerenter', this.openOverlay);\n parentElement.addEventListener('focusin', this.openOverlay);\n parentElement.addEventListener('pointerleave', this.closeOverlay);\n parentElement.addEventListener('focusout', this.closeOverlay);\n } else {\n if (this.previousSlot) {\n this.slot = this.previousSlot;\n } else if (this.slot === 'self-managed-tooltip') {\n this.removeAttribute('slot');\n }\n parentElement.removeEventListener('pointerenter', this.openOverlay);\n parentElement.removeEventListener('focusin', this.openOverlay);\n parentElement.removeEventListener(\n 'pointerleave',\n this.closeOverlay\n );\n parentElement.removeEventListener('focusout', this.closeOverlay);\n }\n }\n\n override render(): TemplateResult {\n return html`\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n `;\n }\n\n protected override async update(\n changed: PropertyValues<this>\n ): Promise<void> {\n if (changed.has('open') && this.selfManaged) {\n if (this.open) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n this.generateProxy();\n super.update(changed);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n super.updated(changed);\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AAAA,EACxB;AAAA,EAEmB,QAAQ,SAAqC;AAC5D,UAAM,QAAQ,OAAO;AACrB,QAAI,QAAQ,IAAI,aAAa,GAAG;AAC5B,WAAK,cAAc;AAAA,IACvB;AAAA,EACJ;AACJ;AA3NO;AAQI,AARJ,QAQI,gBAAgB;AAKhB;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,WAAW,eAAe,CAAC;AAAA,GAC/C,AAbJ,QAaI;AAGA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAClC,AAhBJ,QAgBI;AAIA;AAAA,EADP,AAAC,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GACnC,AApBJ,QAoBI;AAOA;AAAA,EADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GACpB,AA3BJ,QA2BI;AAGC;AAAA,EADR,AAAC,MAAM,MAAM;AAAA,GACL,AA9BL,QA8BK;AAMG;AAAA,EADX,AAAC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GACf,AApCR,QAoCQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Tooltip.dev.js'\n"],
|
|
5
|
+
"mappings": "AAWA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
export * from './Tooltip.js';
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./Tooltip.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Tooltip.js';\n"],
|
|
5
|
+
"mappings": "AAWA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { css } from "@spectrum-web-components/base";
|
|
2
|
+
const styles = css`
|
|
3
|
+
:host{--spectrum-overlay-animation-distance:var(
|
|
4
|
+
--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)
|
|
5
|
+
);opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host([placement*=bottom][open]){transform:translateY(var(--spectrum-overlay-animation-distance))}:host([placement*=top][open]){transform:translateY(calc(var(--spectrum-overlay-animation-distance)*-1))}:host([placement*=right][open]){transform:translateX(var(--spectrum-overlay-animation-distance))}:host([placement*=left][open]){transform:translateX(calc(var(--spectrum-overlay-animation-distance)*-1))}:host{--spectrum-tooltip-neutral-target-offset:3px;--spectrum-tooltip-neutral-tip-width:var(
|
|
6
|
+
--spectrum-tooltip-neutral-tip-height,var(--spectrum-global-dimension-size-50)
|
|
7
|
+
)}:host{-webkit-font-smoothing:antialiased;align-items:center;border-radius:var(
|
|
8
|
+
--spectrum-tooltip-neutral-border-radius,var(--spectrum-alias-component-border-radius)
|
|
9
|
+
);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(
|
|
10
|
+
--spectrum-tooltip-neutral-text-size,var(--spectrum-global-dimension-font-size-75)
|
|
11
|
+
);font-weight:var(
|
|
12
|
+
--spectrum-tooltip-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)
|
|
13
|
+
);left:0;line-height:var(
|
|
14
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
15
|
+
);max-width:var(
|
|
16
|
+
--spectrum-tooltip-neutral-max-width,var(--spectrum-global-dimension-size-2000)
|
|
17
|
+
);min-height:var(
|
|
18
|
+
--spectrum-tooltip-neutral-min-height,var(--spectrum-global-dimension-size-300)
|
|
19
|
+
);padding:0 var(
|
|
20
|
+
--spectrum-tooltip-neutral-padding-x,var(--spectrum-global-dimension-size-85)
|
|
21
|
+
);position:relative;top:0;vertical-align:top;width:auto;word-break:break-word}:host{cursor:default;-webkit-user-select:none;user-select:none}p{margin:0}#tip{border-bottom:var(
|
|
22
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
23
|
+
) solid transparent;border-left:var(
|
|
24
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
25
|
+
) solid transparent;border-right:var(
|
|
26
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
27
|
+
) solid transparent;border-top-style:solid;border-top-width:var(
|
|
28
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
29
|
+
);height:0;position:absolute;width:0}:host([placement*=left]) #tip,:host([placement*=right]) #tip{margin-top:calc(var(
|
|
30
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
31
|
+
var(--spectrum-global-dimension-size-100)
|
|
32
|
+
)*-1);top:50%}:host([placement*=right]){margin-left:var(
|
|
33
|
+
--spectrum-tooltip-neutral-target-offset
|
|
34
|
+
)}:host([placement*=right]) #tip{right:100%;transform:rotate(90deg)}:host([placement*=left]){margin-right:var(
|
|
35
|
+
--spectrum-tooltip-neutral-target-offset
|
|
36
|
+
)}:host([placement*=left]) #tip{left:100%;transform:rotate(-90deg)}:host([placement*=top]){margin-bottom:var(
|
|
37
|
+
--spectrum-tooltip-neutral-target-offset
|
|
38
|
+
)}:host([placement*=top]) #tip{top:100%}:host([placement*=bottom]){margin-top:var(
|
|
39
|
+
--spectrum-tooltip-neutral-target-offset
|
|
40
|
+
)}:host([placement*=bottom]) #tip{bottom:100%;transform:rotate(-180deg)}:host([placement*=bottom]) #tip,:host([placement*=top]) #tip{left:50%;margin-left:calc(var(
|
|
41
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
42
|
+
var(--spectrum-global-dimension-size-100)
|
|
43
|
+
)*-1)}:host([dir=ltr]) ::slotted([slot=icon]){margin-left:calc(var(
|
|
44
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
45
|
+
var(--spectrum-global-dimension-size-85)
|
|
46
|
+
) - var(
|
|
47
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
48
|
+
var(--spectrum-global-dimension-size-85)
|
|
49
|
+
))}:host([dir=rtl]) ::slotted([slot=icon]){margin-right:calc(var(
|
|
50
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
51
|
+
var(--spectrum-global-dimension-size-85)
|
|
52
|
+
) - var(
|
|
53
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
54
|
+
var(--spectrum-global-dimension-size-85)
|
|
55
|
+
))}:host([dir=ltr]) ::slotted([slot=icon]){margin-right:var(
|
|
56
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
57
|
+
)}:host([dir=rtl]) ::slotted([slot=icon]){margin-left:var(
|
|
58
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
59
|
+
)}::slotted([slot=icon]){align-self:flex-start;flex-shrink:0;height:var(
|
|
60
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
61
|
+
);margin-bottom:var(
|
|
62
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
63
|
+
);margin-top:var(
|
|
64
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
65
|
+
);width:var(
|
|
66
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
67
|
+
)}#label{line-height:var(
|
|
68
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
69
|
+
);margin-bottom:var(--spectrum-tooltip-neutral-text-margin-bottom);margin-top:var(
|
|
70
|
+
--spectrum-tooltip-neutral-text-margin-top,var(--spectrum-global-dimension-static-size-50)
|
|
71
|
+
)}:host{background-color:var(
|
|
72
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
73
|
+
);color:var(
|
|
74
|
+
--spectrum-tooltip-neutral-text-color,var(--spectrum-global-color-static-white)
|
|
75
|
+
)}#tip{border-top-color:var(
|
|
76
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
77
|
+
)}.spectrum-Tooltip--error,:host([variant=negative]){background-color:var(
|
|
78
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
79
|
+
)}.spectrum-Tooltip--error #tip,:host([variant=negative]) #tip{border-top-color:var(
|
|
80
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
81
|
+
)}.spectrum-Tooltip--help,:host([variant=info]){background-color:var(
|
|
82
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
83
|
+
)}.spectrum-Tooltip--help #tip,:host([variant=info]) #tip{border-top-color:var(
|
|
84
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
85
|
+
)}.spectrum-Tooltip--success,:host([variant=positive]){background-color:var(
|
|
86
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
87
|
+
)}.spectrum-Tooltip--success #tip,:host([variant=positive]) #tip{border-top-color:var(
|
|
88
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
89
|
+
)}@media (forced-colors:active){:host{border:1px solid transparent}#tip{--spectrum-tooltip-neutral-background-color:CanvasText;--spectrum-tooltip-negative-background-color:CanvasText;--spectrum-tooltip-info-background-color:CanvasText;--spectrum-tooltip-positive-background-color:CanvasText;forced-color-adjust:none}}
|
|
90
|
+
`;
|
|
91
|
+
export default styles;
|
|
92
|
+
//# sourceMappingURL=spectrum-tooltip.css.dev.js.map
|