@spectrum-web-components/tooltip 0.40.1 → 0.40.3
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 +81 -0
- package/package.json +6 -6
- package/src/Tooltip.d.ts +15 -0
- package/src/Tooltip.dev.js +34 -2
- package/src/Tooltip.dev.js.map +3 -3
- package/src/Tooltip.js +7 -5
- package/src/Tooltip.js.map +3 -3
- package/src/spectrum-tooltip.css.dev.js +32 -8
- package/src/spectrum-tooltip.css.dev.js.map +2 -2
- package/src/spectrum-tooltip.css.js +32 -8
- package/src/spectrum-tooltip.css.js.map +2 -2
- package/src/tooltip.css.dev.js +34 -10
- package/src/tooltip.css.dev.js.map +2 -2
- package/src/tooltip.css.js +34 -10
- package/src/tooltip.css.js.map +2 -2
- package/stories/tooltip.stories.js +43 -3
- package/stories/tooltip.stories.js.map +2 -2
- package/test/tooltip.test.js +1 -1
- package/test/tooltip.test.js.map +2 -2
package/custom-elements.json
CHANGED
|
@@ -126,6 +126,26 @@
|
|
|
126
126
|
}
|
|
127
127
|
],
|
|
128
128
|
"members": [
|
|
129
|
+
{
|
|
130
|
+
"kind": "field",
|
|
131
|
+
"name": "delayed",
|
|
132
|
+
"type": {
|
|
133
|
+
"text": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"default": "false",
|
|
136
|
+
"description": "A Tooltip that is `delayed` will its Overlay wait until a warm-up period of\n1000ms has completed before opening. Once the warmup period has completed, all\nsubsequent Overlays will open immediately. When no Overlays are opened, a\ncooldown period of 1000ms will begin. Once the cooldown has completed, the next\nOverlay to be opened will be subject to the warm-up period if provided that option.",
|
|
137
|
+
"attribute": "delayed"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"kind": "field",
|
|
141
|
+
"name": "disabled",
|
|
142
|
+
"type": {
|
|
143
|
+
"text": "boolean"
|
|
144
|
+
},
|
|
145
|
+
"default": "false",
|
|
146
|
+
"description": "Whether to prevent a self-managed Tooltip from responding to user input.",
|
|
147
|
+
"attribute": "disabled"
|
|
148
|
+
},
|
|
129
149
|
{
|
|
130
150
|
"kind": "field",
|
|
131
151
|
"name": "selfManaged",
|
|
@@ -247,6 +267,49 @@
|
|
|
247
267
|
},
|
|
248
268
|
"privacy": "private",
|
|
249
269
|
"readonly": true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"kind": "field",
|
|
273
|
+
"name": "dependenciesLoaded",
|
|
274
|
+
"type": {
|
|
275
|
+
"text": "boolean"
|
|
276
|
+
},
|
|
277
|
+
"privacy": "private",
|
|
278
|
+
"default": "false"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"kind": "field",
|
|
282
|
+
"name": "dependenciesToLoad",
|
|
283
|
+
"type": {
|
|
284
|
+
"text": "Record<string, boolean>"
|
|
285
|
+
},
|
|
286
|
+
"privacy": "private",
|
|
287
|
+
"default": "{}"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"kind": "method",
|
|
291
|
+
"name": "trackDependency",
|
|
292
|
+
"privacy": "private",
|
|
293
|
+
"return": {
|
|
294
|
+
"type": {
|
|
295
|
+
"text": "void"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"parameters": [
|
|
299
|
+
{
|
|
300
|
+
"name": "dependency",
|
|
301
|
+
"type": {
|
|
302
|
+
"text": "string"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"name": "flag",
|
|
307
|
+
"optional": true,
|
|
308
|
+
"type": {
|
|
309
|
+
"text": "boolean"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
]
|
|
250
313
|
}
|
|
251
314
|
],
|
|
252
315
|
"events": [
|
|
@@ -265,6 +328,24 @@
|
|
|
265
328
|
"fieldName": "placement",
|
|
266
329
|
"attribute": "placement"
|
|
267
330
|
},
|
|
331
|
+
{
|
|
332
|
+
"name": "delayed",
|
|
333
|
+
"type": {
|
|
334
|
+
"text": "boolean"
|
|
335
|
+
},
|
|
336
|
+
"default": "false",
|
|
337
|
+
"description": "A Tooltip that is `delayed` will its Overlay wait until a warm-up period of\n1000ms has completed before opening. Once the warmup period has completed, all\nsubsequent Overlays will open immediately. When no Overlays are opened, a\ncooldown period of 1000ms will begin. Once the cooldown has completed, the next\nOverlay to be opened will be subject to the warm-up period if provided that option.",
|
|
338
|
+
"fieldName": "delayed"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "disabled",
|
|
342
|
+
"type": {
|
|
343
|
+
"text": "boolean"
|
|
344
|
+
},
|
|
345
|
+
"default": "false",
|
|
346
|
+
"description": "Whether to prevent a self-managed Tooltip from responding to user input.",
|
|
347
|
+
"fieldName": "disabled"
|
|
348
|
+
},
|
|
268
349
|
{
|
|
269
350
|
"name": "self-managed",
|
|
270
351
|
"type": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tooltip",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"lit-html"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@spectrum-web-components/base": "^0.40.
|
|
61
|
-
"@spectrum-web-components/overlay": "^0.40.
|
|
62
|
-
"@spectrum-web-components/shared": "^0.40.
|
|
60
|
+
"@spectrum-web-components/base": "^0.40.3",
|
|
61
|
+
"@spectrum-web-components/overlay": "^0.40.3",
|
|
62
|
+
"@spectrum-web-components/shared": "^0.40.3"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@spectrum-css/tooltip": "^5.1.
|
|
65
|
+
"@spectrum-css/tooltip": "^5.1.21"
|
|
66
66
|
},
|
|
67
67
|
"types": "./src/index.d.ts",
|
|
68
68
|
"customElements": "custom-elements.json",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"./sp-*.js",
|
|
71
71
|
"./**/*.dev.js"
|
|
72
72
|
],
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "76467a3470aeafa4beefce1e4fc76341f1d6733f"
|
|
74
74
|
}
|
package/src/Tooltip.d.ts
CHANGED
|
@@ -8,6 +8,18 @@ import type { Overlay, Placement } from '@spectrum-web-components/overlay';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class Tooltip extends SpectrumElement {
|
|
10
10
|
static get styles(): CSSResultArray;
|
|
11
|
+
/**
|
|
12
|
+
* A Tooltip that is `delayed` will its Overlay wait until a warm-up period of
|
|
13
|
+
* 1000ms has completed before opening. Once the warmup period has completed, all
|
|
14
|
+
* subsequent Overlays will open immediately. When no Overlays are opened, a
|
|
15
|
+
* cooldown period of 1000ms will begin. Once the cooldown has completed, the next
|
|
16
|
+
* Overlay to be opened will be subject to the warm-up period if provided that option.
|
|
17
|
+
*/
|
|
18
|
+
delayed: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to prevent a self-managed Tooltip from responding to user input.
|
|
21
|
+
*/
|
|
22
|
+
disabled: boolean;
|
|
11
23
|
/**
|
|
12
24
|
* Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.
|
|
13
25
|
* Without this, you must provide your own `overlay-trigger`.
|
|
@@ -30,6 +42,9 @@ export declare class Tooltip extends SpectrumElement {
|
|
|
30
42
|
protected handleCloseOverlay: () => void;
|
|
31
43
|
protected forwardTransitionEvent(event: TransitionEvent): void;
|
|
32
44
|
private get triggerElement();
|
|
45
|
+
private dependenciesLoaded;
|
|
46
|
+
private dependenciesToLoad;
|
|
47
|
+
private trackDependency;
|
|
33
48
|
render(): TemplateResult;
|
|
34
49
|
connectedCallback(): void;
|
|
35
50
|
}
|
package/src/Tooltip.dev.js
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
} from "@spectrum-web-components/base";
|
|
17
17
|
import {
|
|
18
18
|
property,
|
|
19
|
-
query
|
|
19
|
+
query,
|
|
20
|
+
state
|
|
20
21
|
} from "@spectrum-web-components/base/src/decorators.js";
|
|
21
22
|
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
22
23
|
import tooltipStyles from "./tooltip.css.js";
|
|
@@ -92,6 +93,8 @@ if (!customElements.get("sp-tooltip-openable")) {
|
|
|
92
93
|
export class Tooltip extends SpectrumElement {
|
|
93
94
|
constructor() {
|
|
94
95
|
super(...arguments);
|
|
96
|
+
this.delayed = false;
|
|
97
|
+
this.disabled = false;
|
|
95
98
|
this.selfManaged = false;
|
|
96
99
|
this.offset = 0;
|
|
97
100
|
this.open = false;
|
|
@@ -103,6 +106,8 @@ export class Tooltip extends SpectrumElement {
|
|
|
103
106
|
this.handleCloseOverlay = () => {
|
|
104
107
|
this.open = false;
|
|
105
108
|
};
|
|
109
|
+
this.dependenciesLoaded = false;
|
|
110
|
+
this.dependenciesToLoad = {};
|
|
106
111
|
}
|
|
107
112
|
static get styles() {
|
|
108
113
|
return [tooltipStyles];
|
|
@@ -169,6 +174,21 @@ export class Tooltip extends SpectrumElement {
|
|
|
169
174
|
}
|
|
170
175
|
return triggerElement;
|
|
171
176
|
}
|
|
177
|
+
trackDependency(dependency, flag) {
|
|
178
|
+
const loaded = !!customElements.get(dependency) || this.dependenciesToLoad[dependency] || !!flag;
|
|
179
|
+
if (!loaded) {
|
|
180
|
+
customElements.whenDefined(dependency).then(() => {
|
|
181
|
+
this.trackDependency(dependency, true);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
this.dependenciesToLoad = {
|
|
185
|
+
...this.dependenciesToLoad,
|
|
186
|
+
[dependency]: loaded
|
|
187
|
+
};
|
|
188
|
+
this.dependenciesLoaded = Object.values(this.dependenciesToLoad).every(
|
|
189
|
+
(loaded2) => loaded2
|
|
190
|
+
);
|
|
191
|
+
}
|
|
172
192
|
render() {
|
|
173
193
|
const tooltip = html`
|
|
174
194
|
<sp-tooltip-openable
|
|
@@ -184,10 +204,13 @@ export class Tooltip extends SpectrumElement {
|
|
|
184
204
|
</sp-tooltip-openable>
|
|
185
205
|
`;
|
|
186
206
|
if (this.selfManaged) {
|
|
207
|
+
this.trackDependency("sp-overlay");
|
|
187
208
|
import("@spectrum-web-components/overlay/sp-overlay.js");
|
|
188
209
|
return html`
|
|
189
210
|
<sp-overlay
|
|
190
|
-
?open=${this.open}
|
|
211
|
+
?open=${this.open && !this.disabled && this.dependenciesLoaded}
|
|
212
|
+
?delayed=${this.delayed}
|
|
213
|
+
?disabled=${this.disabled}
|
|
191
214
|
offset=${this.offset}
|
|
192
215
|
.placement=${this.placement}
|
|
193
216
|
type="hint"
|
|
@@ -217,6 +240,12 @@ export class Tooltip extends SpectrumElement {
|
|
|
217
240
|
});
|
|
218
241
|
}
|
|
219
242
|
}
|
|
243
|
+
__decorateClass([
|
|
244
|
+
property({ type: Boolean })
|
|
245
|
+
], Tooltip.prototype, "delayed", 2);
|
|
246
|
+
__decorateClass([
|
|
247
|
+
property({ type: Boolean })
|
|
248
|
+
], Tooltip.prototype, "disabled", 2);
|
|
220
249
|
__decorateClass([
|
|
221
250
|
property({ type: Boolean, attribute: "self-managed" })
|
|
222
251
|
], Tooltip.prototype, "selfManaged", 2);
|
|
@@ -241,4 +270,7 @@ __decorateClass([
|
|
|
241
270
|
__decorateClass([
|
|
242
271
|
property({ type: String })
|
|
243
272
|
], Tooltip.prototype, "variant", 1);
|
|
273
|
+
__decorateClass([
|
|
274
|
+
state()
|
|
275
|
+
], Tooltip.prototype, "dependenciesLoaded", 2);
|
|
244
276
|
//# sourceMappingURL=Tooltip.dev.js.map
|
package/src/Tooltip.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport type {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('sp-opened', this.redispatchEvent);\n this.addEventListener('sp-closed', this.redispatchEvent);\n }\n redispatchEvent(event: Event): void {\n event.stopPropagation();\n this.tooltip.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(event.type, {\n bubbles: event.bubbles,\n composed: event.composed,\n detail: (event as CustomEvent<OverlayOpenCloseDetail>).detail,\n })\n );\n }\n get tooltip(): Tooltip {\n return (this.getRootNode() as ShadowRoot).host as Tooltip;\n }\n static get observedAttributes(): string[] {\n return ['open', 'placement'];\n }\n attributeChangedCallback(\n name: 'open' | 'placement',\n _oldValue: string,\n newValue: 'string'\n ): void {\n switch (name) {\n // API generally sets `open` as a property\n /* c8 ignore next 3 */\n case 'open':\n this.open = newValue !== null;\n break;\n case 'placement':\n this.placement = newValue as Placement;\n break;\n }\n }\n set open(open: boolean) {\n this._open = open;\n const { tooltip } = this;\n /* c8 ignore next 3 */\n if (!tooltip) {\n return;\n }\n tooltip.open = open;\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const { tooltip } = this;\n if (!tooltip) {\n return;\n }\n tooltip.placement = placement;\n }\n /* c8 ignore next 3 */\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n return this.tooltip.tipElement;\n }\n}\n\nif (!customElements.get('sp-tooltip-openable')) {\n customElements.define('sp-tooltip-openable', TooltipOpenable);\n}\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 */\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\n * Without this, you must provide your own `overlay-trigger`.\n */\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number })\n public offset = 0;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @query('sp-overlay')\n public overlayElement?: Overlay;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @query('#tip')\n public tipElement!: HTMLSpanElement;\n\n @property({ type: Number })\n public tipPadding?: number;\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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected forwardTransitionEvent(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent(event.type, {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n private get triggerElement(): HTMLElement {\n // Resolve the parent element of the assigned slot (if one exists) or of the Tooltip.\n let start: HTMLElement = this.assignedSlot || this;\n let root = start.getRootNode();\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n let triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n while (!triggerElement?.matches?.(focusableSelector)) {\n start =\n triggerElement.assignedSlot || (triggerElement as HTMLElement);\n root = start.getRootNode();\n /* c8 ignore next 13 */\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n }\n return triggerElement;\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <sp-tooltip-openable\n id=\"tooltip\"\n placement=${ifDefined(this.placement)}\n @transitionrun=${this.forwardTransitionEvent}\n @transitionend=${this.forwardTransitionEvent}\n @transitioncancel=${this.forwardTransitionEvent}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\" aria-hidden=\"true\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\n import('@spectrum-web-components/overlay/sp-overlay.js');\n return html`\n <sp-overlay\n ?open=${this.open}\n offset=${this.offset}\n .placement=${this.placement}\n type=\"hint\"\n .tipPadding=${this.tipPadding}\n .triggerInteraction=${'hover'}\n @sp-opened=${this.handleOpenOverlay}\n @sp-closed=${this.handleCloseOverlay}\n >\n ${tooltip}\n </sp-overlay>\n `;\n } else {\n return tooltip;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.updateComplete.then(() => {\n if (!this.selfManaged) {\n return;\n }\n const overlayElement = this.overlayElement;\n if (overlayElement) {\n const triggerElement = this.triggerElement;\n overlayElement.triggerElement = triggerElement;\n }\n });\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAO1B,OAAO,mBAAmB;AAC1B,SAAS,yBAAyB;AAElC,MAAM,wBAAwB,YAAY;AAAA,EACtC,cAAc;AACV,UAAM;AAgDV,SAAQ,QAAQ;AAiBhB,SAAQ,aAAwB;AAhE5B,SAAK,iBAAiB,aAAa,KAAK,eAAe;AACvD,SAAK,iBAAiB,aAAa,KAAK,eAAe;AAAA,EAC3D;AAAA,EACA,gBAAgB,OAAoB;AAChC,UAAM,gBAAgB;AACtB,SAAK,QAAQ;AAAA,MACT,IAAI,YAAoC,MAAM,MAAM;AAAA,QAChD,SAAS,MAAM;AAAA,QACf,UAAU,MAAM;AAAA,QAChB,QAAS,MAA8C;AAAA,MAC3D,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EACA,IAAI,UAAmB;AACnB,WAAQ,KAAK,YAAY,EAAiB;AAAA,EAC9C;AAAA,EACA,WAAW,qBAA+B;AACtC,WAAO,CAAC,QAAQ,WAAW;AAAA,EAC/B;AAAA,EACA,yBACI,MACA,WACA,UACI;AACJ,YAAQ,MAAM;AAAA,MAGV,KAAK;AACD,aAAK,OAAO,aAAa;AACzB;AAAA,MACJ,KAAK;AACD,aAAK,YAAY;AACjB;AAAA,IACR;AAAA,EACJ;AAAA,EACA,IAAI,KAAK,MAAe;AACpB,SAAK,QAAQ;AACb,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAI,CAAC,SAAS;AACV;AAAA,IACJ;AACA,YAAQ,OAAO;AAAA,EACnB;AAAA,EACA,IAAI,OAAgB;AAChB,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAU,WAAsB;AAChC,SAAK,aAAa;AAClB,UAAM,EAAE,QAAQ,IAAI;AACpB,QAAI,CAAC,SAAS;AACV;AAAA,IACJ;AACA,YAAQ,YAAY;AAAA,EACxB;AAAA;AAAA,EAEA,IAAI,YAAuB;AACvB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,aAA0B;AAC1B,WAAO,KAAK,QAAQ;AAAA,EACxB;AACJ;AAEA,IAAI,CAAC,eAAe,IAAI,qBAAqB,GAAG;AAC5C,iBAAe,OAAO,uBAAuB,eAAe;AAChE;AAQO,aAAM,gBAAgB,gBAAgB;AAAA,EAAtC;AAAA;
|
|
6
|
-
"names": []
|
|
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 SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport type {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('sp-opened', this.redispatchEvent);\n this.addEventListener('sp-closed', this.redispatchEvent);\n }\n redispatchEvent(event: Event): void {\n event.stopPropagation();\n this.tooltip.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(event.type, {\n bubbles: event.bubbles,\n composed: event.composed,\n detail: (event as CustomEvent<OverlayOpenCloseDetail>).detail,\n })\n );\n }\n get tooltip(): Tooltip {\n return (this.getRootNode() as ShadowRoot).host as Tooltip;\n }\n static get observedAttributes(): string[] {\n return ['open', 'placement'];\n }\n attributeChangedCallback(\n name: 'open' | 'placement',\n _oldValue: string,\n newValue: 'string'\n ): void {\n switch (name) {\n // API generally sets `open` as a property\n /* c8 ignore next 3 */\n case 'open':\n this.open = newValue !== null;\n break;\n case 'placement':\n this.placement = newValue as Placement;\n break;\n }\n }\n set open(open: boolean) {\n this._open = open;\n const { tooltip } = this;\n /* c8 ignore next 3 */\n if (!tooltip) {\n return;\n }\n tooltip.open = open;\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const { tooltip } = this;\n if (!tooltip) {\n return;\n }\n tooltip.placement = placement;\n }\n /* c8 ignore next 3 */\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n return this.tooltip.tipElement;\n }\n}\n\nif (!customElements.get('sp-tooltip-openable')) {\n customElements.define('sp-tooltip-openable', TooltipOpenable);\n}\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 */\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * A Tooltip that is `delayed` will its Overlay wait until a warm-up period of\n * 1000ms has completed before opening. Once the warmup period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened, a\n * cooldown period of 1000ms will begin. Once the cooldown has completed, the next\n * Overlay to be opened will be subject to the warm-up period if provided that option.\n */\n @property({ type: Boolean })\n delayed = false;\n\n /**\n * Whether to prevent a self-managed Tooltip from responding to user input.\n */\n @property({ type: Boolean })\n disabled = false;\n\n /**\n * Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\n * Without this, you must provide your own `overlay-trigger`.\n */\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number })\n public offset = 0;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @query('sp-overlay')\n public overlayElement?: Overlay;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @query('#tip')\n public tipElement!: HTMLSpanElement;\n\n @property({ type: Number })\n public tipPadding?: number;\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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected forwardTransitionEvent(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent(event.type, {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n private get triggerElement(): HTMLElement {\n // Resolve the parent element of the assigned slot (if one exists) or of the Tooltip.\n let start: HTMLElement = this.assignedSlot || this;\n let root = start.getRootNode();\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n let triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n while (!triggerElement?.matches?.(focusableSelector)) {\n start =\n triggerElement.assignedSlot || (triggerElement as HTMLElement);\n root = start.getRootNode();\n /* c8 ignore next 13 */\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n }\n return triggerElement;\n }\n\n @state()\n private dependenciesLoaded = false;\n private dependenciesToLoad: Record<string, boolean> = {};\n\n private trackDependency(dependency: string, flag?: boolean): void {\n const loaded =\n !!customElements.get(dependency) ||\n this.dependenciesToLoad[dependency] ||\n !!flag;\n if (!loaded) {\n customElements.whenDefined(dependency).then(() => {\n this.trackDependency(dependency, true);\n });\n }\n this.dependenciesToLoad = {\n ...this.dependenciesToLoad,\n [dependency]: loaded,\n };\n this.dependenciesLoaded = Object.values(this.dependenciesToLoad).every(\n (loaded) => loaded\n );\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <sp-tooltip-openable\n id=\"tooltip\"\n placement=${ifDefined(this.placement)}\n @transitionrun=${this.forwardTransitionEvent}\n @transitionend=${this.forwardTransitionEvent}\n @transitioncancel=${this.forwardTransitionEvent}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\" aria-hidden=\"true\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\n this.trackDependency('sp-overlay');\n import('@spectrum-web-components/overlay/sp-overlay.js');\n return html`\n <sp-overlay\n ?open=${this.open &&\n !this.disabled &&\n this.dependenciesLoaded}\n ?delayed=${this.delayed}\n ?disabled=${this.disabled}\n offset=${this.offset}\n .placement=${this.placement}\n type=\"hint\"\n .tipPadding=${this.tipPadding}\n .triggerInteraction=${'hover'}\n @sp-opened=${this.handleOpenOverlay}\n @sp-closed=${this.handleCloseOverlay}\n >\n ${tooltip}\n </sp-overlay>\n `;\n } else {\n return tooltip;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.updateComplete.then(() => {\n if (!this.selfManaged) {\n return;\n }\n const overlayElement = this.overlayElement;\n if (overlayElement) {\n const triggerElement = this.triggerElement;\n overlayElement.triggerElement = triggerElement;\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAO1B,OAAO,mBAAmB;AAC1B,SAAS,yBAAyB;AAElC,MAAM,wBAAwB,YAAY;AAAA,EACtC,cAAc;AACV,UAAM;AAgDV,SAAQ,QAAQ;AAiBhB,SAAQ,aAAwB;AAhE5B,SAAK,iBAAiB,aAAa,KAAK,eAAe;AACvD,SAAK,iBAAiB,aAAa,KAAK,eAAe;AAAA,EAC3D;AAAA,EACA,gBAAgB,OAAoB;AAChC,UAAM,gBAAgB;AACtB,SAAK,QAAQ;AAAA,MACT,IAAI,YAAoC,MAAM,MAAM;AAAA,QAChD,SAAS,MAAM;AAAA,QACf,UAAU,MAAM;AAAA,QAChB,QAAS,MAA8C;AAAA,MAC3D,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EACA,IAAI,UAAmB;AACnB,WAAQ,KAAK,YAAY,EAAiB;AAAA,EAC9C;A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AI,gBAAgB;AAChB,cAAM,iBAAiB,KAAK;AAC5B,uBAAe,iBAAiB;AAAA,MACpC;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AArMI;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAZlB,QAaT;AAMA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAlBlB,QAmBT;AAOO;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,WAAW,eAAe,CAAC;AAAA,GAzB7C,QA0BF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA5BjB,QA6BF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GA/BjC,QAgCF;AAGA;AAAA,EADN,MAAM,YAAY;AAAA,GAlCV,QAmCF;AAOA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAzClB,QA0CF;AAGA;AAAA,EADN,MAAM,MAAM;AAAA,GA5CJ,QA6CF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA/CjB,QAgDF;AAMI;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GArDjB,QAsDE;AAgFH;AAAA,EADP,MAAM;AAAA,GArIE,QAsID;",
|
|
6
|
+
"names": ["loaded"]
|
|
7
7
|
}
|
package/src/Tooltip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=(r,i,e,n)=>{for(var t=n>1?void 0:n?m(i,e):i,s=r.length-1,l;s>=0;s--)(l=r[s])&&(t=(n?l(i,e,t):l(t))||t);return n&&t&&c(i,e,t),t};import{html as p,SpectrumElement as h}from"@spectrum-web-components/base";import{property as a,query as d,state as u}from"@spectrum-web-components/base/src/decorators.js";import{ifDefined as v}from"@spectrum-web-components/base/src/directives.js";import b from"./tooltip.css.js";import{focusableSelector as f}from"@spectrum-web-components/shared/src/focusable-selectors.js";class g extends HTMLElement{constructor(){super();this._open=!1;this._placement="top";this.addEventListener("sp-opened",this.redispatchEvent),this.addEventListener("sp-closed",this.redispatchEvent)}redispatchEvent(e){e.stopPropagation(),this.tooltip.dispatchEvent(new CustomEvent(e.type,{bubbles:e.bubbles,composed:e.composed,detail:e.detail}))}get tooltip(){return this.getRootNode().host}static get observedAttributes(){return["open","placement"]}attributeChangedCallback(e,n,t){switch(e){case"open":this.open=t!==null;break;case"placement":this.placement=t;break}}set open(e){this._open=e;const{tooltip:n}=this;n&&(n.open=e)}get open(){return this._open}set placement(e){this._placement=e;const{tooltip:n}=this;n&&(n.placement=e)}get placement(){return this._placement}get tipElement(){return this.tooltip.tipElement}}customElements.get("sp-tooltip-openable")||customElements.define("sp-tooltip-openable",g);export class Tooltip extends h{constructor(){super(...arguments);this.delayed=!1;this.disabled=!1;this.selfManaged=!1;this.offset=0;this.open=!1;this._variant="";this.handleOpenOverlay=()=>{this.open=!0};this.handleCloseOverlay=()=>{this.open=!1};this.dependenciesLoaded=!1;this.dependenciesToLoad={}}static get styles(){return[b]}get variant(){return this._variant}set variant(e){if(e!==this.variant){if(["info","positive","negative"].includes(e)){this.setAttribute("variant",e),this._variant=e;return}this.removeAttribute("variant"),this._variant=""}}forwardTransitionEvent(e){this.dispatchEvent(new TransitionEvent(e.type,{bubbles:!0,composed:!0,propertyName:e.propertyName}))}get triggerElement(){var s;let e=this.assignedSlot||this,n=e.getRootNode(),t=e.parentElement||n.host||n;for(;!((s=t==null?void 0:t.matches)!=null&&s.call(t,f));)e=t.assignedSlot||t,n=e.getRootNode(),t=e.parentElement||n.host||n;return t}trackDependency(e,n){const t=!!customElements.get(e)||this.dependenciesToLoad[e]||!!n;t||customElements.whenDefined(e).then(()=>{this.trackDependency(e,!0)}),this.dependenciesToLoad={...this.dependenciesToLoad,[e]:t},this.dependenciesLoaded=Object.values(this.dependenciesToLoad).every(s=>s)}render(){const e=p`
|
|
2
2
|
<sp-tooltip-openable
|
|
3
3
|
id="tooltip"
|
|
4
|
-
placement=${
|
|
4
|
+
placement=${v(this.placement)}
|
|
5
5
|
@transitionrun=${this.forwardTransitionEvent}
|
|
6
6
|
@transitionend=${this.forwardTransitionEvent}
|
|
7
7
|
@transitioncancel=${this.forwardTransitionEvent}
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
<span id="label"><slot></slot></span>
|
|
11
11
|
<span id="tip" aria-hidden="true"></span>
|
|
12
12
|
</sp-tooltip-openable>
|
|
13
|
-
`;return this.selfManaged?(import("@spectrum-web-components/overlay/sp-overlay.js"),p`
|
|
13
|
+
`;return this.selfManaged?(this.trackDependency("sp-overlay"),import("@spectrum-web-components/overlay/sp-overlay.js"),p`
|
|
14
14
|
<sp-overlay
|
|
15
|
-
?open=${this.open}
|
|
15
|
+
?open=${this.open&&!this.disabled&&this.dependenciesLoaded}
|
|
16
|
+
?delayed=${this.delayed}
|
|
17
|
+
?disabled=${this.disabled}
|
|
16
18
|
offset=${this.offset}
|
|
17
19
|
.placement=${this.placement}
|
|
18
20
|
type="hint"
|
|
@@ -23,5 +25,5 @@
|
|
|
23
25
|
>
|
|
24
26
|
${e}
|
|
25
27
|
</sp-overlay>
|
|
26
|
-
`):e}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{if(!this.selfManaged)return;const e=this.overlayElement;if(e){const n=this.triggerElement;e.triggerElement=n}})}}o([a({type:Boolean,attribute:"self-managed"})],Tooltip.prototype,"selfManaged",2),o([a({type:Number})],Tooltip.prototype,"offset",2),o([a({type:Boolean,reflect:!0})],Tooltip.prototype,"open",2),o([
|
|
28
|
+
`):e}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{if(!this.selfManaged)return;const e=this.overlayElement;if(e){const n=this.triggerElement;e.triggerElement=n}})}}o([a({type:Boolean})],Tooltip.prototype,"delayed",2),o([a({type:Boolean})],Tooltip.prototype,"disabled",2),o([a({type:Boolean,attribute:"self-managed"})],Tooltip.prototype,"selfManaged",2),o([a({type:Number})],Tooltip.prototype,"offset",2),o([a({type:Boolean,reflect:!0})],Tooltip.prototype,"open",2),o([d("sp-overlay")],Tooltip.prototype,"overlayElement",2),o([a({reflect:!0})],Tooltip.prototype,"placement",2),o([d("#tip")],Tooltip.prototype,"tipElement",2),o([a({type:Number})],Tooltip.prototype,"tipPadding",2),o([a({type:String})],Tooltip.prototype,"variant",1),o([u()],Tooltip.prototype,"dependenciesLoaded",2);
|
|
27
29
|
//# sourceMappingURL=Tooltip.js.map
|
package/src/Tooltip.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport type {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('sp-opened', this.redispatchEvent);\n this.addEventListener('sp-closed', this.redispatchEvent);\n }\n redispatchEvent(event: Event): void {\n event.stopPropagation();\n this.tooltip.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(event.type, {\n bubbles: event.bubbles,\n composed: event.composed,\n detail: (event as CustomEvent<OverlayOpenCloseDetail>).detail,\n })\n );\n }\n get tooltip(): Tooltip {\n return (this.getRootNode() as ShadowRoot).host as Tooltip;\n }\n static get observedAttributes(): string[] {\n return ['open', 'placement'];\n }\n attributeChangedCallback(\n name: 'open' | 'placement',\n _oldValue: string,\n newValue: 'string'\n ): void {\n switch (name) {\n // API generally sets `open` as a property\n /* c8 ignore next 3 */\n case 'open':\n this.open = newValue !== null;\n break;\n case 'placement':\n this.placement = newValue as Placement;\n break;\n }\n }\n set open(open: boolean) {\n this._open = open;\n const { tooltip } = this;\n /* c8 ignore next 3 */\n if (!tooltip) {\n return;\n }\n tooltip.open = open;\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const { tooltip } = this;\n if (!tooltip) {\n return;\n }\n tooltip.placement = placement;\n }\n /* c8 ignore next 3 */\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n return this.tooltip.tipElement;\n }\n}\n\nif (!customElements.get('sp-tooltip-openable')) {\n customElements.define('sp-tooltip-openable', TooltipOpenable);\n}\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 */\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\n * Without this, you must provide your own `overlay-trigger`.\n */\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number })\n public offset = 0;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @query('sp-overlay')\n public overlayElement?: Overlay;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @query('#tip')\n public tipElement!: HTMLSpanElement;\n\n @property({ type: Number })\n public tipPadding?: number;\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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected forwardTransitionEvent(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent(event.type, {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n private get triggerElement(): HTMLElement {\n // Resolve the parent element of the assigned slot (if one exists) or of the Tooltip.\n let start: HTMLElement = this.assignedSlot || this;\n let root = start.getRootNode();\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n let triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n while (!triggerElement?.matches?.(focusableSelector)) {\n start =\n triggerElement.assignedSlot || (triggerElement as HTMLElement);\n root = start.getRootNode();\n /* c8 ignore next 13 */\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n }\n return triggerElement;\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <sp-tooltip-openable\n id=\"tooltip\"\n placement=${ifDefined(this.placement)}\n @transitionrun=${this.forwardTransitionEvent}\n @transitionend=${this.forwardTransitionEvent}\n @transitioncancel=${this.forwardTransitionEvent}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\" aria-hidden=\"true\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\n import('@spectrum-web-components/overlay/sp-overlay.js');\n return html`\n <sp-overlay\n ?open=${this.open}\n offset=${this.offset}\n .placement=${this.placement}\n type=\"hint\"\n .tipPadding=${this.tipPadding}\n .triggerInteraction=${'hover'}\n @sp-opened=${this.handleOpenOverlay}\n @sp-closed=${this.handleCloseOverlay}\n >\n ${tooltip}\n </sp-overlay>\n `;\n } else {\n return tooltip;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.updateComplete.then(() => {\n if (!this.selfManaged) {\n return;\n }\n const overlayElement = this.overlayElement;\n if (overlayElement) {\n const triggerElement = this.triggerElement;\n overlayElement.triggerElement = triggerElement;\n }\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,EACA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,MACG,kDACP,OAAS,aAAAC,MAAiB,kDAO1B,OAAOC,MAAmB,mBAC1B,OAAS,qBAAAC,MAAyB,6DAElC,MAAMC,UAAwB,WAAY,CACtC,aAAc,CACV,MAAM,EAgDV,KAAQ,MAAQ,GAiBhB,KAAQ,WAAwB,MAhE5B,KAAK,iBAAiB,YAAa,KAAK,eAAe,EACvD,KAAK,iBAAiB,YAAa,KAAK,eAAe,CAC3D,CACA,gBAAgBC,EAAoB,CAChCA,EAAM,gBAAgB,EACtB,KAAK,QAAQ,cACT,IAAI,YAAoCA,EAAM,KAAM,CAChD,QAASA,EAAM,QACf,SAAUA,EAAM,SAChB,OAASA,EAA8C,MAC3D,CAAC,CACL,CACJ,CACA,IAAI,SAAmB,CACnB,OAAQ,KAAK,YAAY,EAAiB,IAC9C,CACA,WAAW,oBAA+B,CACtC,MAAO,CAAC,OAAQ,WAAW,CAC/B,CACA,yBACIC,EACAC,EACAC,EACI,CACJ,OAAQF,EAAM,CAGV,IAAK,OACD,KAAK,KAAOE,IAAa,KACzB,MACJ,IAAK,YACD,KAAK,UAAYA,EACjB,KACR,CACJ,CACA,IAAI,KAAKC,EAAe,CACpB,KAAK,MAAQA,EACb,KAAM,CAAE,QAAAC,CAAQ,EAAI,KAEfA,IAGLA,EAAQ,KAAOD,EACnB,CACA,IAAI,MAAgB,CAChB,OAAO,KAAK,KAChB,CAMA,IAAI,UAAUE,EAAsB,CAChC,KAAK,WAAaA,EAClB,KAAM,CAAE,QAAAD,CAAQ,EAAI,KACfA,IAGLA,EAAQ,UAAYC,EACxB,CAEA,IAAI,WAAuB,CACvB,OAAO,KAAK,UAChB,CAEA,IAAI,YAA0B,CAC1B,OAAO,KAAK,QAAQ,UACxB,CACJ,CAEK,eAAe,IAAI,qBAAqB,GACzC,eAAe,OAAO,sBAAuBP,CAAe,EASzD,aAAM,
|
|
6
|
-
"names": ["html", "SpectrumElement", "property", "query", "ifDefined", "tooltipStyles", "focusableSelector", "TooltipOpenable", "event", "name", "_oldValue", "newValue", "open", "tooltip", "placement", "variant", "_a", "start", "root", "triggerElement", "overlayElement", "__decorateClass"]
|
|
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 SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport type {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\n constructor() {\n super();\n this.addEventListener('sp-opened', this.redispatchEvent);\n this.addEventListener('sp-closed', this.redispatchEvent);\n }\n redispatchEvent(event: Event): void {\n event.stopPropagation();\n this.tooltip.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(event.type, {\n bubbles: event.bubbles,\n composed: event.composed,\n detail: (event as CustomEvent<OverlayOpenCloseDetail>).detail,\n })\n );\n }\n get tooltip(): Tooltip {\n return (this.getRootNode() as ShadowRoot).host as Tooltip;\n }\n static get observedAttributes(): string[] {\n return ['open', 'placement'];\n }\n attributeChangedCallback(\n name: 'open' | 'placement',\n _oldValue: string,\n newValue: 'string'\n ): void {\n switch (name) {\n // API generally sets `open` as a property\n /* c8 ignore next 3 */\n case 'open':\n this.open = newValue !== null;\n break;\n case 'placement':\n this.placement = newValue as Placement;\n break;\n }\n }\n set open(open: boolean) {\n this._open = open;\n const { tooltip } = this;\n /* c8 ignore next 3 */\n if (!tooltip) {\n return;\n }\n tooltip.open = open;\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const { tooltip } = this;\n if (!tooltip) {\n return;\n }\n tooltip.placement = placement;\n }\n /* c8 ignore next 3 */\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n return this.tooltip.tipElement;\n }\n}\n\nif (!customElements.get('sp-tooltip-openable')) {\n customElements.define('sp-tooltip-openable', TooltipOpenable);\n}\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 */\nexport class Tooltip extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * A Tooltip that is `delayed` will its Overlay wait until a warm-up period of\n * 1000ms has completed before opening. Once the warmup period has completed, all\n * subsequent Overlays will open immediately. When no Overlays are opened, a\n * cooldown period of 1000ms will begin. Once the cooldown has completed, the next\n * Overlay to be opened will be subject to the warm-up period if provided that option.\n */\n @property({ type: Boolean })\n delayed = false;\n\n /**\n * Whether to prevent a self-managed Tooltip from responding to user input.\n */\n @property({ type: Boolean })\n disabled = false;\n\n /**\n * Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\n * Without this, you must provide your own `overlay-trigger`.\n */\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number })\n public offset = 0;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @query('sp-overlay')\n public overlayElement?: Overlay;\n\n /**\n * @type {\"top\" | \"top-start\" | \"top-end\" | \"right\" | \"right-start\" | \"right-end\" | \"bottom\" | \"bottom-start\" | \"bottom-end\" | \"left\" | \"left-start\" | \"left-end\"}\n * @attr\n */\n @property({ reflect: true })\n public placement?: Placement;\n\n @query('#tip')\n public tipElement!: HTMLSpanElement;\n\n @property({ type: Number })\n public tipPadding?: number;\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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected forwardTransitionEvent(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent(event.type, {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n private get triggerElement(): HTMLElement {\n // Resolve the parent element of the assigned slot (if one exists) or of the Tooltip.\n let start: HTMLElement = this.assignedSlot || this;\n let root = start.getRootNode();\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n let triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n while (!triggerElement?.matches?.(focusableSelector)) {\n start =\n triggerElement.assignedSlot || (triggerElement as HTMLElement);\n root = start.getRootNode();\n /* c8 ignore next 13 */\n if (window.__swc.DEBUG) {\n if (root === document) {\n window.__swc.warn(\n this,\n `Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays',\n {\n level: 'high',\n }\n );\n return root as HTMLElement;\n }\n }\n triggerElement = (start.parentElement ||\n (root as ShadowRoot).host ||\n root) as HTMLElement;\n }\n return triggerElement;\n }\n\n @state()\n private dependenciesLoaded = false;\n private dependenciesToLoad: Record<string, boolean> = {};\n\n private trackDependency(dependency: string, flag?: boolean): void {\n const loaded =\n !!customElements.get(dependency) ||\n this.dependenciesToLoad[dependency] ||\n !!flag;\n if (!loaded) {\n customElements.whenDefined(dependency).then(() => {\n this.trackDependency(dependency, true);\n });\n }\n this.dependenciesToLoad = {\n ...this.dependenciesToLoad,\n [dependency]: loaded,\n };\n this.dependenciesLoaded = Object.values(this.dependenciesToLoad).every(\n (loaded) => loaded\n );\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <sp-tooltip-openable\n id=\"tooltip\"\n placement=${ifDefined(this.placement)}\n @transitionrun=${this.forwardTransitionEvent}\n @transitionend=${this.forwardTransitionEvent}\n @transitioncancel=${this.forwardTransitionEvent}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\" aria-hidden=\"true\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\n this.trackDependency('sp-overlay');\n import('@spectrum-web-components/overlay/sp-overlay.js');\n return html`\n <sp-overlay\n ?open=${this.open &&\n !this.disabled &&\n this.dependenciesLoaded}\n ?delayed=${this.delayed}\n ?disabled=${this.disabled}\n offset=${this.offset}\n .placement=${this.placement}\n type=\"hint\"\n .tipPadding=${this.tipPadding}\n .triggerInteraction=${'hover'}\n @sp-opened=${this.handleOpenOverlay}\n @sp-closed=${this.handleCloseOverlay}\n >\n ${tooltip}\n </sp-overlay>\n `;\n } else {\n return tooltip;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.updateComplete.then(() => {\n if (!this.selfManaged) {\n return;\n }\n const overlayElement = this.overlayElement;\n if (overlayElement) {\n const triggerElement = this.triggerElement;\n overlayElement.triggerElement = triggerElement;\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EACA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,EACA,SAAAC,MACG,kDACP,OAAS,aAAAC,MAAiB,kDAO1B,OAAOC,MAAmB,mBAC1B,OAAS,qBAAAC,MAAyB,6DAElC,MAAMC,UAAwB,WAAY,CACtC,aAAc,CACV,MAAM,EAg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OAsB,EAAA,CADNvB,EAAS,CAAE,QAAS,EAAK,CAAC,GAzClB,QA0CF,yBAGAuB,EAAA,CADNtB,EAAM,MAAM,GA5CJ,QA6CF,0BAGAsB,EAAA,CADNvB,EAAS,CAAE,KAAM,MAAO,CAAC,GA/CjB,QAgDF,0BAMIuB,EAAA,CADVvB,EAAS,CAAE,KAAM,MAAO,CAAC,GArDjB,QAsDE,uBAgFHuB,EAAA,CADPrB,EAAM,GArIE,QAsID",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "query", "state", "ifDefined", "tooltipStyles", "focusableSelector", "TooltipOpenable", "event", "name", "_oldValue", "newValue", "open", "tooltip", "placement", "variant", "_a", "start", "root", "triggerElement", "dependency", "flag", "loaded", "overlayElement", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -3,9 +3,13 @@ import { css } from "@spectrum-web-components/base";
|
|
|
3
3
|
const styles = css`
|
|
4
4
|
#tooltip{--spectrum-overlay-animation-distance:6px;--spectrum-overlay-animation-duration:var(
|
|
5
5
|
--spectrum-animation-duration-100
|
|
6
|
-
)
|
|
6
|
+
);--spectrum-overlay-animation-duration-opened:var(
|
|
7
|
+
--spectrum-animation-duration-0
|
|
8
|
+
);opacity:0;pointer-events:none;transition:transform var(--spectrum-overlay-animation-duration) ease-in-out,opacity var(--spectrum-overlay-animation-duration) ease-in-out,visibility 0s linear var(--spectrum-overlay-animation-duration);visibility:hidden}:host([open]) #tooltip{opacity:1;pointer-events:auto;transition-delay:var(
|
|
9
|
+
--mod-overlay-animation-duration-opened,var(--spectrum-overlay-animation-duration-opened)
|
|
10
|
+
);visibility:visible}#tooltip{--spectrum-tooltip-animation-duration:var(
|
|
7
11
|
--spectrum-animation-duration-100
|
|
8
|
-
);--spectrum-tooltip-
|
|
12
|
+
);--spectrum-tooltip-margin:0px;--spectrum-tooltip-height:var(--spectrum-component-height-75);--spectrum-tooltip-max-inline-size:var(--spectrum-tooltip-maximum-width);--spectrum-tooltip-border-radius:var(--spectrum-corner-radius-100);--spectrum-tooltip-icon-width:var(--spectrum-workflow-icon-size-50);--spectrum-tooltip-icon-height:var(--spectrum-workflow-icon-size-50);--spectrum-tooltip-font-size:var(--spectrum-font-size-75);--spectrum-tooltip-line-height:var(--spectrum-line-height-100);--spectrum-tooltip-cjk-line-height:var(--spectrum-cjk-line-height-100);--spectrum-tooltip-font-weight:var(--spectrum-regular-font-weight);--spectrum-tooltip-spacing-inline:var(
|
|
9
13
|
--spectrum-component-edge-to-text-75
|
|
10
14
|
);--spectrum-tooltip-spacing-block-start:var(
|
|
11
15
|
--spectrum-component-top-to-text-75
|
|
@@ -166,22 +170,42 @@ var(--spectrum-tooltip-spacing-inline)
|
|
|
166
170
|
)}#tooltip,.spectrum-Tooltip--top-end,.spectrum-Tooltip--top-left,.spectrum-Tooltip--top-right,.spectrum-Tooltip--top-start,:host([placement*=top]) #tooltip{margin-bottom:calc(var(
|
|
167
171
|
--mod-tooltip-tip-block-size,
|
|
168
172
|
var(--spectrum-tooltip-tip-block-size)
|
|
169
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}.spectrum-Tooltip--
|
|
173
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) #tooltip,:host([open]) .spectrum-Tooltip--top-end,:host([open]) .spectrum-Tooltip--top-left,:host([open]) .spectrum-Tooltip--top-right,:host([open]) .spectrum-Tooltip--top-start,:host([placement*=top][open]) #tooltip{transform:translateY(calc(var(
|
|
174
|
+
--mod-tooltip-animation-distance,
|
|
175
|
+
var(--spectrum-tooltip-animation-distance)
|
|
176
|
+
)*-1))}.spectrum-Tooltip--bottom-end,.spectrum-Tooltip--bottom-left,.spectrum-Tooltip--bottom-right,.spectrum-Tooltip--bottom-start,:host([placement*=bottom]) #tooltip{margin-top:calc(var(
|
|
170
177
|
--mod-tooltip-tip-block-size,
|
|
171
178
|
var(--spectrum-tooltip-tip-block-size)
|
|
172
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}.spectrum-Tooltip--
|
|
179
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) .spectrum-Tooltip--bottom-end,:host([open]) .spectrum-Tooltip--bottom-left,:host([open]) .spectrum-Tooltip--bottom-right,:host([open]) .spectrum-Tooltip--bottom-start,:host([placement*=bottom][open]) #tooltip{transform:translateY(var(
|
|
180
|
+
--mod-tooltip-animation-distance,var(--spectrum-tooltip-animation-distance)
|
|
181
|
+
))}.spectrum-Tooltip--right-bottom,.spectrum-Tooltip--right-top,:host([placement*=right]) #tooltip{margin-left:calc(var(
|
|
173
182
|
--mod-tooltip-tip-block-size,
|
|
174
183
|
var(--spectrum-tooltip-tip-block-size)
|
|
175
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}.spectrum-Tooltip--
|
|
184
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) .spectrum-Tooltip--right-bottom,:host([open]) .spectrum-Tooltip--right-top,:host([placement*=right][open]) #tooltip{transform:translateX(var(
|
|
185
|
+
--mod-tooltip-animation-distance,var(--spectrum-tooltip-animation-distance)
|
|
186
|
+
))}.spectrum-Tooltip--left-bottom,.spectrum-Tooltip--left-top,:host([placement*=left]) #tooltip{margin-right:calc(var(
|
|
176
187
|
--mod-tooltip-tip-block-size,
|
|
177
188
|
var(--spectrum-tooltip-tip-block-size)
|
|
178
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}.spectrum-Tooltip--
|
|
189
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) .spectrum-Tooltip--left-bottom,:host([open]) .spectrum-Tooltip--left-top,:host([placement*=left][open]) #tooltip{transform:translateX(calc(var(
|
|
190
|
+
--mod-tooltip-animation-distance,
|
|
191
|
+
var(--spectrum-tooltip-animation-distance)
|
|
192
|
+
)*-1))}.spectrum-Tooltip--start,.spectrum-Tooltip--start-bottom,.spectrum-Tooltip--start-top{margin-inline-end:calc(var(
|
|
179
193
|
--mod-tooltip-tip-block-size,
|
|
180
194
|
var(--spectrum-tooltip-tip-block-size)
|
|
181
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}.spectrum-Tooltip--
|
|
195
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) .spectrum-Tooltip--start,:host([open]) .spectrum-Tooltip--start-bottom,:host([open]) .spectrum-Tooltip--start-top{transform:translateX(calc(var(
|
|
196
|
+
--mod-tooltip-animation-distance,
|
|
197
|
+
var(--spectrum-tooltip-animation-distance)
|
|
198
|
+
)*-1))}:host([dir=rtl][open]) .spectrum-Tooltip--start,:host([dir=rtl][open]) .spectrum-Tooltip--start-bottom,:host([dir=rtl][open]) .spectrum-Tooltip--start-top{transform:translateX(var(
|
|
199
|
+
--mod-tooltip-animation-distance,var(--spectrum-tooltip-animation-distance)
|
|
200
|
+
))}.spectrum-Tooltip--end,.spectrum-Tooltip--end-bottom,.spectrum-Tooltip--end-top{margin-inline-start:calc(var(
|
|
182
201
|
--mod-tooltip-tip-block-size,
|
|
183
202
|
var(--spectrum-tooltip-tip-block-size)
|
|
184
|
-
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}
|
|
203
|
+
) + var(--mod-tooltip-margin, var(--spectrum-tooltip-margin)))}:host([open]) .spectrum-Tooltip--end,:host([open]) .spectrum-Tooltip--end-bottom,:host([open]) .spectrum-Tooltip--end-top{transform:translateX(var(
|
|
204
|
+
--mod-tooltip-animation-distance,var(--spectrum-tooltip-animation-distance)
|
|
205
|
+
))}:host([dir=rtl][open]) .spectrum-Tooltip--end,:host([dir=rtl][open]) .spectrum-Tooltip--end-bottom,:host([dir=rtl][open]) .spectrum-Tooltip--end-top{transform:translateX(calc(var(
|
|
206
|
+
--mod-tooltip-animation-distance,
|
|
207
|
+
var(--spectrum-tooltip-animation-distance)
|
|
208
|
+
)*-1))}#tooltip{--spectrum-tooltip-backgound-color-default-neutral:var(
|
|
185
209
|
--system-spectrum-tooltip-backgound-color-default-neutral
|
|
186
210
|
)}
|
|
187
211
|
`;
|