@spectrum-web-components/tooltip 0.11.15 → 0.11.16-overlay.8
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 +4 -4
- package/src/Tooltip.d.ts +7 -30
- package/src/Tooltip.dev.js +38 -163
- package/src/Tooltip.dev.js.map +3 -3
- package/src/Tooltip.js +20 -5
- package/src/Tooltip.js.map +3 -3
- package/src/spectrum-config.js +120 -17
- package/src/spectrum-tooltip.css.dev.js +19 -19
- package/src/spectrum-tooltip.css.dev.js.map +1 -1
- package/src/spectrum-tooltip.css.js +19 -19
- package/src/spectrum-tooltip.css.js.map +1 -1
- package/src/tooltip.css.dev.js +20 -20
- package/src/tooltip.css.dev.js.map +1 -1
- package/src/tooltip.css.js +20 -20
- package/src/tooltip.css.js.map +1 -1
- package/stories/tooltip.stories.js +12 -15
- package/stories/tooltip.stories.js.map +2 -2
- package/test/tooltip.test.js +12 -54
- package/test/tooltip.test.js.map +2 -2
- package/custom-elements.json +0 -374
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tooltip",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.16-overlay.8+eef228d8d",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"lit-html"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@spectrum-web-components/base": "^0.7.
|
|
61
|
-
"@spectrum-web-components/overlay": "^0.19.
|
|
60
|
+
"@spectrum-web-components/base": "^0.7.5-overlay.236+eef228d8d",
|
|
61
|
+
"@spectrum-web-components/overlay": "^0.19.4-overlay.8+eef228d8d"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@spectrum-css/tooltip": "^4.0.10"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"./sp-*.js",
|
|
70
70
|
"./**/*.dev.js"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "eef228d8defcf04fe32713c7232fd0873828752b"
|
|
73
73
|
}
|
package/src/Tooltip.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { CSSResultArray,
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
disconnectedCallback(): void;
|
|
5
|
-
}
|
|
1
|
+
import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import type { Placement } from '@spectrum-web-components/overlay';
|
|
3
|
+
import '@spectrum-web-components/overlay/sp-overlay.js';
|
|
6
4
|
/**
|
|
7
5
|
* @element sp-tooltip
|
|
8
6
|
*
|
|
@@ -15,41 +13,20 @@ export declare class Tooltip extends SpectrumElement {
|
|
|
15
13
|
* @private
|
|
16
14
|
*/
|
|
17
15
|
static instanceCount: number;
|
|
18
|
-
private _tooltipId;
|
|
19
16
|
selfManaged: boolean;
|
|
20
17
|
offset: number;
|
|
21
|
-
private hadTooltipId;
|
|
22
18
|
open: boolean;
|
|
23
19
|
/**
|
|
24
20
|
* @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"}
|
|
25
21
|
* @attr
|
|
26
22
|
*/
|
|
27
23
|
placement: Placement;
|
|
28
|
-
|
|
24
|
+
tipElement: HTMLSpanElement;
|
|
29
25
|
private _variant;
|
|
30
26
|
get variant(): string;
|
|
31
27
|
set variant(variant: string);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private generateProxy;
|
|
36
|
-
overlayWillOpenCallback({ trigger, }: {
|
|
37
|
-
trigger: HTMLElement;
|
|
38
|
-
}): void;
|
|
39
|
-
overlayOpenCancelledCallback({ trigger, }: {
|
|
40
|
-
trigger: HTMLElement;
|
|
41
|
-
}): void;
|
|
42
|
-
overlayCloseCallback({ trigger }: {
|
|
43
|
-
trigger: HTMLElement;
|
|
44
|
-
}): void;
|
|
45
|
-
private removeProxy;
|
|
46
|
-
private closeOverlayCallback?;
|
|
47
|
-
private abortOverlay;
|
|
48
|
-
private openOverlay;
|
|
49
|
-
private closeOverlay;
|
|
50
|
-
private previousSlot?;
|
|
51
|
-
private manageTooltip;
|
|
28
|
+
private handleOpenOverlay;
|
|
29
|
+
protected handleCloseOverlay: () => void;
|
|
30
|
+
protected handleTransitionend(): void;
|
|
52
31
|
render(): TemplateResult;
|
|
53
|
-
protected update(changed: PropertyValues<this>): Promise<void>;
|
|
54
|
-
protected updated(changed: PropertyValues<this>): void;
|
|
55
32
|
}
|
package/src/Tooltip.dev.js
CHANGED
|
@@ -18,69 +18,23 @@ import {
|
|
|
18
18
|
property,
|
|
19
19
|
query
|
|
20
20
|
} from "@spectrum-web-components/base/src/decorators.js";
|
|
21
|
-
import
|
|
21
|
+
import "@spectrum-web-components/overlay/sp-overlay.js";
|
|
22
22
|
import tooltipStyles from "./tooltip.css.js";
|
|
23
|
-
export class
|
|
24
|
-
disconnectedCallback() {
|
|
25
|
-
this.dispatchEvent(new Event("disconnected"));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
customElements.define("tooltip-proxy", TooltipProxy);
|
|
29
|
-
const _Tooltip = class extends SpectrumElement {
|
|
23
|
+
export class Tooltip extends SpectrumElement {
|
|
30
24
|
constructor() {
|
|
31
|
-
super();
|
|
32
|
-
this._tooltipId = `sp-tooltip-describedby-helper-${_Tooltip.instanceCount++}`;
|
|
25
|
+
super(...arguments);
|
|
33
26
|
this.selfManaged = false;
|
|
34
27
|
this.offset = 6;
|
|
35
|
-
this.hadTooltipId = false;
|
|
36
28
|
this.open = false;
|
|
37
29
|
this.placement = "top";
|
|
38
30
|
/* Ensure that a '' value for `variant` removes the attribute instead of a blank value */
|
|
39
31
|
this._variant = "";
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
this.openOverlay = () => {
|
|
44
|
-
const parentElement = this.parentElement;
|
|
45
|
-
const abortPromise = new Promise((res) => {
|
|
46
|
-
this.abortOverlay = res;
|
|
47
|
-
});
|
|
48
|
-
if (true) {
|
|
49
|
-
window.__swc.ignoreWarningLevels.deprecation = true;
|
|
50
|
-
}
|
|
51
|
-
this.closeOverlayCallback = openOverlay(parentElement, "hover", this, {
|
|
52
|
-
abortPromise,
|
|
53
|
-
offset: this.offset,
|
|
54
|
-
placement: this.placement
|
|
55
|
-
});
|
|
56
|
-
if (true) {
|
|
57
|
-
window.__swc.ignoreWarningLevels.deprecation = false;
|
|
58
|
-
}
|
|
32
|
+
this.handleOpenOverlay = () => {
|
|
33
|
+
this.open = true;
|
|
59
34
|
};
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
if (pointerIsEnteringTooltip) {
|
|
63
|
-
this.addEventListener(
|
|
64
|
-
"pointerleave",
|
|
65
|
-
(event2) => {
|
|
66
|
-
const pointerIsEnteringParnet = event2.relatedTarget === this.parentElement;
|
|
67
|
-
if (pointerIsEnteringParnet) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.closeOverlay(event2);
|
|
71
|
-
},
|
|
72
|
-
{ once: true }
|
|
73
|
-
);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (this.abortOverlay)
|
|
77
|
-
this.abortOverlay(true);
|
|
78
|
-
if (!this.closeOverlayCallback)
|
|
79
|
-
return;
|
|
80
|
-
(await this.closeOverlayCallback)();
|
|
81
|
-
delete this.closeOverlayCallback;
|
|
35
|
+
this.handleCloseOverlay = () => {
|
|
36
|
+
this.open = false;
|
|
82
37
|
};
|
|
83
|
-
this.addEventListener("sp-overlay-query", this.onOverlayQuery);
|
|
84
38
|
}
|
|
85
39
|
static get styles() {
|
|
86
40
|
return [tooltipStyles];
|
|
@@ -100,121 +54,42 @@ const _Tooltip = class extends SpectrumElement {
|
|
|
100
54
|
this.removeAttribute("variant");
|
|
101
55
|
this._variant = "";
|
|
102
56
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
generateProxy() {
|
|
112
|
-
if (this._proxy) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
this._proxy = document.createElement("tooltip-proxy");
|
|
116
|
-
this._proxy.id = this._tooltipId;
|
|
117
|
-
this._proxy.hidden = true;
|
|
118
|
-
this._proxy.slot = "hidden-tooltip-content";
|
|
119
|
-
this._proxy.setAttribute("role", "tooltip");
|
|
120
|
-
this._proxy.addEventListener("disconnected", this.closeOverlay);
|
|
121
|
-
}
|
|
122
|
-
overlayWillOpenCallback({
|
|
123
|
-
trigger
|
|
124
|
-
}) {
|
|
125
|
-
this.setAttribute("aria-hidden", "true");
|
|
126
|
-
this.generateProxy();
|
|
127
|
-
this._proxy.textContent = this.textContent;
|
|
128
|
-
const ariaDescribedby = trigger.getAttribute("aria-describedby") || "";
|
|
129
|
-
this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;
|
|
130
|
-
this.insertAdjacentElement("beforebegin", this._proxy);
|
|
131
|
-
if (this.hadTooltipId)
|
|
132
|
-
return;
|
|
133
|
-
if (ariaDescribedby) {
|
|
134
|
-
trigger.setAttribute(
|
|
135
|
-
"aria-describedby",
|
|
136
|
-
`${ariaDescribedby} ${this._tooltipId}`
|
|
137
|
-
);
|
|
138
|
-
} else {
|
|
139
|
-
trigger.setAttribute("aria-describedby", `${this._tooltipId}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
overlayOpenCancelledCallback({
|
|
143
|
-
trigger
|
|
144
|
-
}) {
|
|
145
|
-
this.overlayCloseCallback({ trigger });
|
|
146
|
-
}
|
|
147
|
-
overlayCloseCallback({ trigger }) {
|
|
148
|
-
const ariaDescribedby = trigger.getAttribute("aria-describedby") || "";
|
|
149
|
-
let descriptors = ariaDescribedby.split(/\s+/);
|
|
150
|
-
if (!this.hadTooltipId) {
|
|
151
|
-
descriptors = descriptors.filter(
|
|
152
|
-
(descriptor) => descriptor !== this._tooltipId
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (descriptors.length) {
|
|
156
|
-
trigger.setAttribute("aria-describedby", descriptors.join(" "));
|
|
157
|
-
} else {
|
|
158
|
-
trigger.removeAttribute("aria-describedby");
|
|
159
|
-
}
|
|
160
|
-
this.removeAttribute("aria-hidden");
|
|
161
|
-
this.removeProxy();
|
|
162
|
-
}
|
|
163
|
-
removeProxy() {
|
|
164
|
-
this._proxy.remove();
|
|
165
|
-
}
|
|
166
|
-
manageTooltip() {
|
|
167
|
-
const parentElement = this.parentElement;
|
|
168
|
-
if (this.selfManaged) {
|
|
169
|
-
if (this.slot) {
|
|
170
|
-
this.previousSlot = this.slot;
|
|
171
|
-
}
|
|
172
|
-
this.slot = "self-managed-tooltip";
|
|
173
|
-
parentElement.addEventListener("pointerenter", this.openOverlay);
|
|
174
|
-
parentElement.addEventListener("focusin", this.openOverlay);
|
|
175
|
-
parentElement.addEventListener("pointerleave", this.closeOverlay);
|
|
176
|
-
parentElement.addEventListener("focusout", this.closeOverlay);
|
|
177
|
-
} else {
|
|
178
|
-
if (this.previousSlot) {
|
|
179
|
-
this.slot = this.previousSlot;
|
|
180
|
-
} else if (this.slot === "self-managed-tooltip") {
|
|
181
|
-
this.removeAttribute("slot");
|
|
182
|
-
}
|
|
183
|
-
parentElement.removeEventListener("pointerenter", this.openOverlay);
|
|
184
|
-
parentElement.removeEventListener("focusin", this.openOverlay);
|
|
185
|
-
parentElement.removeEventListener(
|
|
186
|
-
"pointerleave",
|
|
187
|
-
this.closeOverlay
|
|
188
|
-
);
|
|
189
|
-
parentElement.removeEventListener("focusout", this.closeOverlay);
|
|
190
|
-
}
|
|
57
|
+
handleTransitionend() {
|
|
58
|
+
this.dispatchEvent(
|
|
59
|
+
new Event("transitionend", {
|
|
60
|
+
bubbles: true,
|
|
61
|
+
composed: true
|
|
62
|
+
})
|
|
63
|
+
);
|
|
191
64
|
}
|
|
192
65
|
render() {
|
|
193
|
-
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
66
|
+
const tooltip = html`
|
|
67
|
+
<span id="tooltip" @transitionend=${this.handleTransitionend}>
|
|
68
|
+
<slot name="icon"></slot>
|
|
69
|
+
<span id="label"><slot></slot></span>
|
|
70
|
+
<span id="tip"></span>
|
|
71
|
+
</span>
|
|
197
72
|
`;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
73
|
+
if (this.selfManaged) {
|
|
74
|
+
return html`
|
|
75
|
+
<sp-overlay
|
|
76
|
+
?open=${this.open}
|
|
77
|
+
offset=${this.offset}
|
|
78
|
+
type="hint"
|
|
79
|
+
.placement=${this.placement}
|
|
80
|
+
.triggerElement=${this.parentElement}
|
|
81
|
+
.triggerInteraction=${"hover"}
|
|
82
|
+
@sp-opened=${this.handleOpenOverlay}
|
|
83
|
+
@sp-closed=${this.handleCloseOverlay}
|
|
84
|
+
>
|
|
85
|
+
${tooltip}
|
|
86
|
+
</sp-overlay>
|
|
87
|
+
`;
|
|
88
|
+
} else {
|
|
89
|
+
return tooltip;
|
|
214
90
|
}
|
|
215
91
|
}
|
|
216
|
-
}
|
|
217
|
-
export let Tooltip = _Tooltip;
|
|
92
|
+
}
|
|
218
93
|
/**
|
|
219
94
|
* @private
|
|
220
95
|
*/
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;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} from '@spectrum-web-components/base/src/decorators.js';\nimport type { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\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 @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number, reflect: true })\n public offset = 6;\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 public 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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected handleTransitionend(): void {\n this.dispatchEvent(\n new Event('transitionend', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <span id=\"tooltip\" @transitionend=${this.handleTransitionend}>\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </span>\n `;\n if (this.selfManaged) {\n return html`\n <sp-overlay\n ?open=${this.open}\n offset=${this.offset}\n type=\"hint\"\n .placement=${this.placement}\n .triggerElement=${this.parentElement}\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AAEP,OAAO,mBAAmB;AASnB,aAAM,gBAAgB,gBAAgB;AAAA,EAAtC;AAAA;AAWH,SAAO,cAAc;AAGrB,SAAO,SAAS;AAGhB,SAAO,OAAO;AAOd,SAAO,YAAuB;AAM9B;AAAA,SAAQ,WAAW;AAmBnB,SAAQ,oBAAoB,MAAY;AACpC,WAAK,OAAO;AAAA,IAChB;AAEA,SAAU,qBAAqB,MAAY;AACvC,WAAK,OAAO;AAAA,IAChB;AAAA;AAAA,EAtDA,WAA2B,SAAyB;AAChD,WAAO,CAAC,aAAa;AAAA,EACzB;AAAA,EA8BA,IAAW,UAAkB;AACzB,WAAO,KAAK;AAAA,EAChB;AAAA,EACA,IAAW,QAAQ,SAAiB;AAChC,QAAI,YAAY,KAAK,SAAS;AAC1B;AAAA,IACJ;AACA,QAAI,CAAC,QAAQ,YAAY,UAAU,EAAE,SAAS,OAAO,GAAG;AACpD,WAAK,aAAa,WAAW,OAAO;AACpC,WAAK,WAAW;AAChB;AAAA,IACJ;AACA,SAAK,gBAAgB,SAAS;AAC9B,SAAK,WAAW;AAAA,EACpB;AAAA,EAUU,sBAA4B;AAClC,SAAK;AAAA,MACD,IAAI,MAAM,iBAAiB;AAAA,QACvB,SAAS;AAAA,QACT,UAAU;AAAA,MACd,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAES,SAAyB;AAC9B,UAAM,UAAU;AAAA,gDACwB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAM7C,QAAI,KAAK,aAAa;AAClB,aAAO;AAAA;AAAA,4BAES,KAAK;AAAA,6BACJ,KAAK;AAAA;AAAA,iCAED,KAAK;AAAA,sCACA,KAAK;AAAA,0CACD;AAAA,iCACT,KAAK;AAAA,iCACL,KAAK;AAAA;AAAA,sBAEhB;AAAA;AAAA;AAAA,IAGd,OAAO;AACH,aAAO;AAAA,IACX;AAAA,EACJ;AACJ;AAAA;AAAA;AAAA;AA7Fa,QAQF,gBAAgB;AAGhB;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,WAAW,eAAe,CAAC;AAAA,GAV7C,QAWF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAbhC,QAcF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAhBjC,QAiBF;AAOA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAvBlB,QAwBF;AAGA;AAAA,EADN,MAAM,MAAM;AAAA,GA1BJ,QA2BF;AAMI;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAhCjB,QAiCE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/src/Tooltip.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";var u=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=(a,r,e,s)=>{for(var t=s>1?void 0:s?c(r,e):r,l=a.length-1,p;l>=0;l--)(p=a[l])&&(t=(s?p(r,e,t):p(t))||t);return s&&t&&u(r,e,t),t};import{html as o,SpectrumElement as d}from"@spectrum-web-components/base";import{property as i,query as m}from"@spectrum-web-components/base/src/decorators.js";import"@spectrum-web-components/overlay/sp-overlay.js";import h from"./tooltip.css.js";export class Tooltip extends d{constructor(){super(...arguments);this.selfManaged=!1;this.offset=6;this.open=!1;this.placement="top";this._variant="";this.handleOpenOverlay=()=>{this.open=!0};this.handleCloseOverlay=()=>{this.open=!1}}static get styles(){return[h]}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=""}}handleTransitionend(){this.dispatchEvent(new Event("transitionend",{bubbles:!0,composed:!0}))}render(){const e=o`
|
|
2
|
+
<span id="tooltip" @transitionend=${this.handleTransitionend}>
|
|
3
|
+
<slot name="icon"></slot>
|
|
4
|
+
<span id="label"><slot></slot></span>
|
|
5
|
+
<span id="tip"></span>
|
|
6
|
+
</span>
|
|
7
|
+
`;return this.selfManaged?o`
|
|
8
|
+
<sp-overlay
|
|
9
|
+
?open=${this.open}
|
|
10
|
+
offset=${this.offset}
|
|
11
|
+
type="hint"
|
|
12
|
+
.placement=${this.placement}
|
|
13
|
+
.triggerElement=${this.parentElement}
|
|
14
|
+
.triggerInteraction=${"hover"}
|
|
15
|
+
@sp-opened=${this.handleOpenOverlay}
|
|
16
|
+
@sp-closed=${this.handleCloseOverlay}
|
|
17
|
+
>
|
|
18
|
+
${e}
|
|
19
|
+
</sp-overlay>
|
|
20
|
+
`:e}}Tooltip.instanceCount=0,n([i({type:Boolean,attribute:"self-managed"})],Tooltip.prototype,"selfManaged",2),n([i({type:Number,reflect:!0})],Tooltip.prototype,"offset",2),n([i({type:Boolean,reflect:!0})],Tooltip.prototype,"open",2),n([i({reflect:!0})],Tooltip.prototype,"placement",2),n([m("#tip")],Tooltip.prototype,"tipElement",2),n([i({type:String})],Tooltip.prototype,"variant",1);
|
|
6
21
|
//# 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
|
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,
|
|
6
|
-
"names": ["html", "SpectrumElement", "property", "query", "
|
|
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 type { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\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 @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number, reflect: true })\n public offset = 6;\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 public 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 private handleOpenOverlay = (): void => {\n this.open = true;\n };\n\n protected handleCloseOverlay = (): void => {\n this.open = false;\n };\n\n protected handleTransitionend(): void {\n this.dispatchEvent(\n new Event('transitionend', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n override render(): TemplateResult {\n const tooltip = html`\n <span id=\"tooltip\" @transitionend=${this.handleTransitionend}>\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </span>\n `;\n if (this.selfManaged) {\n return html`\n <sp-overlay\n ?open=${this.open}\n offset=${this.offset}\n type=\"hint\"\n .placement=${this.placement}\n .triggerElement=${this.parentElement}\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"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EACA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,MACG,kDAEP,MAAO,iDAEP,OAAOC,MAAmB,mBASnB,aAAM,gBAAgBH,CAAgB,CAAtC,kCAWH,KAAO,YAAc,GAGrB,KAAO,OAAS,EAGhB,KAAO,KAAO,GAOd,KAAO,UAAuB,MAM9B,KAAQ,SAAW,GAmBnB,KAAQ,kBAAoB,IAAY,CACpC,KAAK,KAAO,EAChB,EAEA,KAAU,mBAAqB,IAAY,CACvC,KAAK,KAAO,EAChB,EAtDA,WAA2B,QAAyB,CAChD,MAAO,CAACG,CAAa,CACzB,CA8BA,IAAW,SAAkB,CACzB,OAAO,KAAK,QAChB,CACA,IAAW,QAAQC,EAAiB,CAChC,GAAIA,IAAY,KAAK,QAGrB,IAAI,CAAC,OAAQ,WAAY,UAAU,EAAE,SAASA,CAAO,EAAG,CACpD,KAAK,aAAa,UAAWA,CAAO,EACpC,KAAK,SAAWA,EAChB,MACJ,CACA,KAAK,gBAAgB,SAAS,EAC9B,KAAK,SAAW,GACpB,CAUU,qBAA4B,CAClC,KAAK,cACD,IAAI,MAAM,gBAAiB,CACvB,QAAS,GACT,SAAU,EACd,CAAC,CACL,CACJ,CAES,QAAyB,CAC9B,MAAMC,EAAUN;AAAA,gDACwB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,UAM7C,OAAI,KAAK,YACEA;AAAA;AAAA,4BAES,KAAK;AAAA,6BACJ,KAAK;AAAA;AAAA,iCAED,KAAK;AAAA,sCACA,KAAK;AAAA,0CACD;AAAA,iCACT,KAAK;AAAA,iCACL,KAAK;AAAA;AAAA,sBAEhBM;AAAA;AAAA,cAIHA,CAEf,CACJ,CA7Fa,QAQF,cAAgB,EAGhBC,EAAA,CADNL,EAAS,CAAE,KAAM,QAAS,UAAW,cAAe,CAAC,GAV7C,QAWF,2BAGAK,EAAA,CADNL,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAbhC,QAcF,sBAGAK,EAAA,CADNL,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAhBjC,QAiBF,oBAOAK,EAAA,CADNL,EAAS,CAAE,QAAS,EAAK,CAAC,GAvBlB,QAwBF,yBAGAK,EAAA,CADNJ,EAAM,MAAM,GA1BJ,QA2BF,0BAMII,EAAA,CADVL,EAAS,CAAE,KAAM,MAAO,CAAC,GAhCjB,QAiCE",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "query", "tooltipStyles", "variant", "tooltip", "__decorateClass"]
|
|
7
7
|
}
|
package/src/spectrum-config.js
CHANGED
|
@@ -29,26 +29,129 @@ export default {
|
|
|
29
29
|
fileName: 'tooltip',
|
|
30
30
|
excludeByComponents: [builder.class('u-tooltip-showOnHover')],
|
|
31
31
|
components: [
|
|
32
|
-
converter.
|
|
32
|
+
converter.classToId('spectrum-Tooltip', 'tooltip'),
|
|
33
33
|
converter.classToAttribute('is-open', 'open'),
|
|
34
|
-
|
|
35
|
-
[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
{
|
|
35
|
+
find: [builder.class('spectrum-Tooltip--top')],
|
|
36
|
+
replace: [
|
|
37
|
+
{
|
|
38
|
+
replace: builder.attribute(
|
|
39
|
+
'placement',
|
|
40
|
+
'top',
|
|
41
|
+
'substring'
|
|
42
|
+
),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
replace: builder.combinator(' '),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
replace: builder.id('tooltip'),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
expandSelector: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
find: [builder.class('spectrum-Tooltip--bottom')],
|
|
55
|
+
replace: [
|
|
56
|
+
{
|
|
57
|
+
replace: builder.attribute(
|
|
58
|
+
'placement',
|
|
59
|
+
'bottom',
|
|
60
|
+
'substring'
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
replace: builder.combinator(' '),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
replace: builder.id('tooltip'),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
expandSelector: true,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
find: [builder.class('spectrum-Tooltip--left')],
|
|
74
|
+
replace: [
|
|
75
|
+
{
|
|
76
|
+
replace: builder.attribute(
|
|
77
|
+
'placement',
|
|
78
|
+
'left',
|
|
79
|
+
'substring'
|
|
80
|
+
),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
replace: builder.combinator(' '),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
replace: builder.id('tooltip'),
|
|
87
|
+
},
|
|
40
88
|
],
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
89
|
+
expandSelector: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
find: [builder.class('spectrum-Tooltip--right')],
|
|
93
|
+
replace: [
|
|
94
|
+
{
|
|
95
|
+
replace: builder.attribute(
|
|
96
|
+
'placement',
|
|
97
|
+
'right',
|
|
98
|
+
'substring'
|
|
99
|
+
),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
replace: builder.combinator(' '),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
replace: builder.id('tooltip'),
|
|
106
|
+
},
|
|
49
107
|
],
|
|
50
|
-
|
|
51
|
-
|
|
108
|
+
expandSelector: true,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
find: [builder.class('spectrum-Tooltip--info')],
|
|
112
|
+
replace: [
|
|
113
|
+
{
|
|
114
|
+
replace: builder.attribute('variant', 'info'),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
replace: builder.combinator(' '),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
replace: builder.id('tooltip'),
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
expandSelector: true,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
find: [builder.class('spectrum-Tooltip--positive')],
|
|
127
|
+
replace: [
|
|
128
|
+
{
|
|
129
|
+
replace: builder.attribute('variant', 'positive'),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
replace: builder.combinator(' '),
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
replace: builder.id('tooltip'),
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
expandSelector: true,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
find: [builder.class('spectrum-Tooltip--negative')],
|
|
142
|
+
replace: [
|
|
143
|
+
{
|
|
144
|
+
replace: builder.attribute('variant', 'negative'),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
replace: builder.combinator(' '),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
replace: builder.id('tooltip'),
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
expandSelector: true,
|
|
154
|
+
},
|
|
52
155
|
converter.classToId('spectrum-Tooltip-label'),
|
|
53
156
|
converter.classToId('spectrum-Tooltip-tip'),
|
|
54
157
|
converter.classToSlotted('spectrum-Tooltip-typeIcon', 'icon'),
|