@spectrum-web-components/tooltip 0.35.1-rc.26 → 0.35.1-rc.41
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 +5 -5
- package/src/Tooltip.d.ts +3 -1
- package/src/Tooltip.dev.js +68 -10
- package/src/Tooltip.dev.js.map +2 -2
- package/src/Tooltip.js +3 -4
- package/src/Tooltip.js.map +3 -3
- package/stories/tooltip.stories.js +11 -0
- package/stories/tooltip.stories.js.map +2 -2
- package/test/tooltip.test.js +38 -0
- package/test/tooltip.test.js.map +2 -2
- package/custom-elements.json +0 -328
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tooltip",
|
|
3
|
-
"version": "0.35.1-rc.
|
|
3
|
+
"version": "0.35.1-rc.41+6ac4e82f0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"lit-html"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@spectrum-web-components/base": "^0.35.1-rc.
|
|
61
|
-
"@spectrum-web-components/overlay": "^0.35.1-rc.
|
|
62
|
-
"@spectrum-web-components/shared": "^0.35.1-rc.
|
|
60
|
+
"@spectrum-web-components/base": "^0.35.1-rc.41+6ac4e82f0",
|
|
61
|
+
"@spectrum-web-components/overlay": "^0.35.1-rc.41+6ac4e82f0",
|
|
62
|
+
"@spectrum-web-components/shared": "^0.35.1-rc.41+6ac4e82f0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@spectrum-css/tooltip": "^5.0.42"
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"./sp-*.js",
|
|
71
71
|
"./**/*.dev.js"
|
|
72
72
|
],
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "6ac4e82f0a4a68eb50b5dd4b96a562060162ac6f"
|
|
74
74
|
}
|
package/src/Tooltip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
-
import type { Placement } from '@spectrum-web-components/overlay';
|
|
2
|
+
import type { Overlay, Placement } from '@spectrum-web-components/overlay';
|
|
3
3
|
import '@spectrum-web-components/overlay/sp-overlay.js';
|
|
4
4
|
/**
|
|
5
5
|
* @element sp-tooltip
|
|
@@ -16,6 +16,7 @@ export declare class Tooltip extends SpectrumElement {
|
|
|
16
16
|
selfManaged: boolean;
|
|
17
17
|
offset: number;
|
|
18
18
|
open: boolean;
|
|
19
|
+
overlayElement?: Overlay;
|
|
19
20
|
/**
|
|
20
21
|
* @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"}
|
|
21
22
|
* @attr
|
|
@@ -32,4 +33,5 @@ export declare class Tooltip extends SpectrumElement {
|
|
|
32
33
|
protected handleTransitionend(event: TransitionEvent): void;
|
|
33
34
|
private get triggerElement();
|
|
34
35
|
render(): TemplateResult;
|
|
36
|
+
connectedCallback(): void;
|
|
35
37
|
}
|
package/src/Tooltip.dev.js
CHANGED
|
@@ -24,9 +24,24 @@ import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
24
24
|
import { focusableSelector } from "@spectrum-web-components/shared/src/focusable-selectors.js";
|
|
25
25
|
class TooltipOpenable extends HTMLElement {
|
|
26
26
|
constructor() {
|
|
27
|
-
super(
|
|
27
|
+
super();
|
|
28
28
|
this._open = false;
|
|
29
29
|
this._placement = "top";
|
|
30
|
+
this.addEventListener("sp-opened", this.redispatchEvent);
|
|
31
|
+
this.addEventListener("sp-closed", this.redispatchEvent);
|
|
32
|
+
}
|
|
33
|
+
redispatchEvent(event) {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
this.tooltip.dispatchEvent(
|
|
36
|
+
new CustomEvent(event.type, {
|
|
37
|
+
bubbles: event.bubbles,
|
|
38
|
+
composed: event.composed,
|
|
39
|
+
detail: event.detail
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
get tooltip() {
|
|
44
|
+
return this.getRootNode().host;
|
|
30
45
|
}
|
|
31
46
|
static get observedAttributes() {
|
|
32
47
|
return ["open", "placement"];
|
|
@@ -43,10 +58,11 @@ class TooltipOpenable extends HTMLElement {
|
|
|
43
58
|
}
|
|
44
59
|
set open(open) {
|
|
45
60
|
this._open = open;
|
|
46
|
-
const tooltip = this
|
|
47
|
-
if (tooltip) {
|
|
48
|
-
|
|
61
|
+
const { tooltip } = this;
|
|
62
|
+
if (!tooltip) {
|
|
63
|
+
return;
|
|
49
64
|
}
|
|
65
|
+
tooltip.open = open;
|
|
50
66
|
}
|
|
51
67
|
get open() {
|
|
52
68
|
return this._open;
|
|
@@ -57,17 +73,18 @@ class TooltipOpenable extends HTMLElement {
|
|
|
57
73
|
*/
|
|
58
74
|
set placement(placement) {
|
|
59
75
|
this._placement = placement;
|
|
60
|
-
const tooltip = this
|
|
61
|
-
if (tooltip) {
|
|
62
|
-
|
|
76
|
+
const { tooltip } = this;
|
|
77
|
+
if (!tooltip) {
|
|
78
|
+
return;
|
|
63
79
|
}
|
|
80
|
+
tooltip.placement = placement;
|
|
64
81
|
}
|
|
82
|
+
/* c8 ignore next 3 */
|
|
65
83
|
get placement() {
|
|
66
84
|
return this._placement;
|
|
67
85
|
}
|
|
68
86
|
get tipElement() {
|
|
69
|
-
|
|
70
|
-
return tooltip.tipElement;
|
|
87
|
+
return this.tooltip.tipElement;
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
90
|
if (!customElements.get("sp-tooltip-openable")) {
|
|
@@ -128,10 +145,36 @@ export class Tooltip extends SpectrumElement {
|
|
|
128
145
|
var _a;
|
|
129
146
|
let start = this.assignedSlot || this;
|
|
130
147
|
let root = start.getRootNode();
|
|
148
|
+
if (true) {
|
|
149
|
+
if (root === document) {
|
|
150
|
+
window.__swc.warn(
|
|
151
|
+
this,
|
|
152
|
+
`Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,
|
|
153
|
+
"https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays",
|
|
154
|
+
{
|
|
155
|
+
level: "high"
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
return root;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
131
161
|
let triggerElement = start.parentElement || root.host || root;
|
|
132
162
|
while (!((_a = triggerElement == null ? void 0 : triggerElement.matches) == null ? void 0 : _a.call(triggerElement, focusableSelector))) {
|
|
133
163
|
start = triggerElement.assignedSlot || triggerElement;
|
|
134
164
|
root = start.getRootNode();
|
|
165
|
+
if (true) {
|
|
166
|
+
if (root === document) {
|
|
167
|
+
window.__swc.warn(
|
|
168
|
+
this,
|
|
169
|
+
`Self managed <${this.localName}> elements walk up the composed tree to acquire a trigger element. No trigger element was found before the document.`,
|
|
170
|
+
"https://opensource.adobe.com/spectrum-web-components/components/tooltip#self-managed-overlays",
|
|
171
|
+
{
|
|
172
|
+
level: "high"
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
return root;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
135
178
|
triggerElement = start.parentElement || root.host || root;
|
|
136
179
|
}
|
|
137
180
|
return triggerElement;
|
|
@@ -157,7 +200,6 @@ export class Tooltip extends SpectrumElement {
|
|
|
157
200
|
.placement=${this.placement}
|
|
158
201
|
type="hint"
|
|
159
202
|
.tipPadding=${this.tipPadding}
|
|
160
|
-
.triggerElement=${this.triggerElement}
|
|
161
203
|
.triggerInteraction=${"hover"}
|
|
162
204
|
@sp-opened=${this.handleOpenOverlay}
|
|
163
205
|
@sp-closed=${this.handleCloseOverlay}
|
|
@@ -169,6 +211,19 @@ export class Tooltip extends SpectrumElement {
|
|
|
169
211
|
return tooltip;
|
|
170
212
|
}
|
|
171
213
|
}
|
|
214
|
+
connectedCallback() {
|
|
215
|
+
super.connectedCallback();
|
|
216
|
+
this.updateComplete.then(() => {
|
|
217
|
+
if (!this.selfManaged) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const overlayElement = this.overlayElement;
|
|
221
|
+
if (overlayElement) {
|
|
222
|
+
const triggerElement = this.triggerElement;
|
|
223
|
+
overlayElement.triggerElement = triggerElement;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
172
227
|
}
|
|
173
228
|
__decorateClass([
|
|
174
229
|
property({ type: Boolean, attribute: "self-managed" })
|
|
@@ -179,6 +234,9 @@ __decorateClass([
|
|
|
179
234
|
__decorateClass([
|
|
180
235
|
property({ type: Boolean, reflect: true })
|
|
181
236
|
], Tooltip.prototype, "open", 2);
|
|
237
|
+
__decorateClass([
|
|
238
|
+
query("sp-overlay")
|
|
239
|
+
], Tooltip.prototype, "overlayElement", 2);
|
|
182
240
|
__decorateClass([
|
|
183
241
|
property({ reflect: true })
|
|
184
242
|
], Tooltip.prototype, "placement", 2);
|
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 type { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\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.getRootNode() as ShadowRoot).host as Tooltip;\n if (tooltip) {\n tooltip.open = open;\n }\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\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\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const tooltip = (this.getRootNode() as ShadowRoot).host as Tooltip;\n if (tooltip) {\n tooltip.placement = placement;\n }\n }\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n const tooltip = (this.getRootNode() as ShadowRoot).host as Tooltip;\n return 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 /**\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\"}\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 handleTransitionrun(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionrun', {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n protected handleTransitionend(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionend', {\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 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 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.handleTransitionrun}\n @transitionend=${this.handleTransitionend}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\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 .triggerElement=${this.triggerElement}\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;
|
|
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 {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { ifDefined } from 'lit/directives/if-defined.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 {\"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\"}\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 {\"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\"}\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 handleTransitionrun(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionrun', {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n protected handleTransitionend(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionend', {\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.handleTransitionrun}\n @transitionend=${this.handleTransitionend}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\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,E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;AACnB;AAAA,MACJ;AACA,YAAM,iBAAiB,KAAK;AAC5B,UAAI,gBAAgB;AAChB,cAAM,iBAAiB,KAAK;AAC5B,uBAAe,iBAAiB;AAAA,MACpC;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AApKW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,WAAW,eAAe,CAAC;AAAA,GAT7C,QAUF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAZjB,QAaF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAfjC,QAgBF;AAGA;AAAA,EADN,MAAM,YAAY;AAAA,GAlBV,QAmBF;AAOA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAzBlB,QA0BF;AAGA;AAAA,EADN,MAAM,MAAM;AAAA,GA5BJ,QA6BF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA/BjB,QAgCF;AAMI;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GArCjB,QAsCE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Tooltip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var o=(r,s,e,n)=>{for(var t=n>1?void 0:n?d(s,e):s,i=r.length-1,l;i>=0;i--)(l=r[i])&&(t=(n?l(s,e,t):l(t))||t);return n&&t&&c(s,e,t),t};import{html as p,SpectrumElement as h}from"@spectrum-web-components/base";import{property as a,query as m}from"@spectrum-web-components/base/src/decorators.js";import"@spectrum-web-components/overlay/sp-overlay.js";import u from"./tooltip.css.js";import{ifDefined as v}from"lit/directives/if-defined.js";import{focusableSelector as b}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.selfManaged=!1;this.offset=0;this.open=!1;this._variant="";this.handleOpenOverlay=()=>{this.open=!0};this.handleCloseOverlay=()=>{this.open=!1}}static get styles(){return[u]}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=""}}handleTransitionrun(e){this.dispatchEvent(new TransitionEvent("transitionrun",{bubbles:!0,composed:!0,propertyName:e.propertyName}))}handleTransitionend(e){this.dispatchEvent(new TransitionEvent("transitionend",{bubbles:!0,composed:!0,propertyName:e.propertyName}))}get triggerElement(){var i;let e=this.assignedSlot||this,n=e.getRootNode(),t=e.parentElement||n.host||n;for(;!((i=t==null?void 0:t.matches)!=null&&i.call(t,b));)e=t.assignedSlot||t,n=e.getRootNode(),t=e.parentElement||n.host||n;return t}render(){const e=p`
|
|
2
2
|
<sp-tooltip-openable
|
|
3
3
|
id="tooltip"
|
|
4
|
-
placement=${
|
|
4
|
+
placement=${v(this.placement)}
|
|
5
5
|
@transitionrun=${this.handleTransitionrun}
|
|
6
6
|
@transitionend=${this.handleTransitionend}
|
|
7
7
|
>
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
.placement=${this.placement}
|
|
17
17
|
type="hint"
|
|
18
18
|
.tipPadding=${this.tipPadding}
|
|
19
|
-
.triggerElement=${this.triggerElement}
|
|
20
19
|
.triggerInteraction=${"hover"}
|
|
21
20
|
@sp-opened=${this.handleOpenOverlay}
|
|
22
21
|
@sp-closed=${this.handleCloseOverlay}
|
|
23
22
|
>
|
|
24
23
|
${e}
|
|
25
24
|
</sp-overlay>
|
|
26
|
-
`:e}}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([a({reflect:!0})],Tooltip.prototype,"placement",2),o([
|
|
25
|
+
`: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([m("sp-overlay")],Tooltip.prototype,"overlayElement",2),o([a({reflect:!0})],Tooltip.prototype,"placement",2),o([m("#tip")],Tooltip.prototype,"tipElement",2),o([a({type:Number})],Tooltip.prototype,"tipPadding",2),o([a({type:String})],Tooltip.prototype,"variant",1);
|
|
27
26
|
//# 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 type { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { focusableSelector } from '@spectrum-web-components/shared/src/focusable-selectors.js';\n\nclass TooltipOpenable extends HTMLElement {\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.getRootNode() as ShadowRoot).host as Tooltip;\n if (tooltip) {\n tooltip.open = open;\n }\n }\n get open(): boolean {\n return this._open;\n }\n private _open = false;\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\"}\n * @attr\n */\n set placement(placement: Placement) {\n this._placement = placement;\n const tooltip = (this.getRootNode() as ShadowRoot).host as Tooltip;\n if (tooltip) {\n tooltip.placement = placement;\n }\n }\n get placement(): Placement {\n return this._placement;\n }\n private _placement: Placement = 'top';\n get tipElement(): HTMLElement {\n const tooltip = (this.getRootNode() as ShadowRoot).host as Tooltip;\n return 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 /**\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\"}\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 handleTransitionrun(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionrun', {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n protected handleTransitionend(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionend', {\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 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 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.handleTransitionrun}\n @transitionend=${this.handleTransitionend}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\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 .triggerElement=${this.triggerElement}\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,
|
|
6
|
-
"names": ["html", "SpectrumElement", "property", "query", "tooltipStyles", "ifDefined", "focusableSelector", "TooltipOpenable", "name", "_oldValue", "newValue", "open", "tooltip", "placement", "variant", "
|
|
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 {\n Overlay,\n OverlayOpenCloseDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nimport tooltipStyles from './tooltip.css.js';\nimport { ifDefined } from 'lit/directives/if-defined.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 {\"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\"}\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 {\"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\"}\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 handleTransitionrun(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionrun', {\n bubbles: true,\n composed: true,\n propertyName: event.propertyName,\n })\n );\n }\n\n protected handleTransitionend(event: TransitionEvent): void {\n this.dispatchEvent(\n new TransitionEvent('transitionend', {\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.handleTransitionrun}\n @transitionend=${this.handleTransitionend}\n >\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n </sp-tooltip-openable>\n `;\n if (this.selfManaged) {\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,kDAMP,MAAO,iDAEP,OAAOC,MAAmB,mBAC1B,OAAS,aAAAC,MAAiB,+BAC1B,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,UAA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,MAAO,CAAC,GArCjB,QAsCE",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "query", "tooltipStyles", "ifDefined", "focusableSelector", "TooltipOpenable", "event", "name", "_oldValue", "newValue", "open", "tooltip", "placement", "variant", "_a", "start", "root", "triggerElement", "overlayElement", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -7,6 +7,8 @@ import "@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js";
|
|
|
7
7
|
import "@spectrum-web-components/icons-workflow/icons/sp-icon-info.js";
|
|
8
8
|
import "@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js";
|
|
9
9
|
import "@spectrum-web-components/button/sp-button.js";
|
|
10
|
+
import "@spectrum-web-components/field-label/sp-field-label.js";
|
|
11
|
+
import "@spectrum-web-components/textfield/sp-textfield.js";
|
|
10
12
|
import "@spectrum-web-components/action-button/sp-action-button.js";
|
|
11
13
|
import "@spectrum-web-components/overlay/sp-overlay.js";
|
|
12
14
|
const iconOptions = {
|
|
@@ -350,4 +352,13 @@ export const selfManagedIconOnly = () => html`
|
|
|
350
352
|
<sp-icon-edit slot="icon"></sp-icon-edit>
|
|
351
353
|
</sp-action-button>
|
|
352
354
|
`;
|
|
355
|
+
export const selfManagedFieldLabel = () => html`
|
|
356
|
+
<div style="display: inline-flex; flex-direction: column;">
|
|
357
|
+
<sp-field-label for="input">
|
|
358
|
+
<sp-icon-edit></sp-icon-edit>
|
|
359
|
+
<sp-tooltip self-managed>Edit</sp-tooltip>
|
|
360
|
+
</sp-field-label>
|
|
361
|
+
<sp-textfield id="input"></sp-textfield>
|
|
362
|
+
</div>
|
|
363
|
+
`;
|
|
353
364
|
//# sourceMappingURL=tooltip.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.stories.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*/\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-info.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nconst iconOptions: {\n [key: string]: ({\n width,\n height,\n hidden,\n title,\n }?: {\n width?: number;\n height?: number;\n hidden?: boolean;\n title?: string;\n }) => TemplateResult | string;\n} = {\n '': () => html``,\n negative: () =>\n html`\n <sp-icon-alert slot=\"icon\"></sp-icon-alert>\n `,\n positive: () =>\n html`\n <sp-icon-checkmark slot=\"icon\"></sp-icon-checkmark>\n `,\n info: () =>\n html`\n <sp-icon-info slot=\"icon\"></sp-icon-info>\n `,\n};\n\nexport default {\n component: 'sp-tooltip',\n title: 'Tooltip',\n};\n\ninterface Properties {\n open?: boolean;\n placement?: Placement;\n variant?: string;\n text?: string;\n offset?: number;\n delayed?: boolean;\n}\n\nexport const Default = ({\n open,\n placement,\n variant,\n text,\n}: Properties): TemplateResult => {\n return html`\n <sp-tooltip ?open=${open} placement=${placement} variant=${variant}>\n ${text}\n </sp-tooltip>\n `;\n};\nDefault.args = {\n open: true,\n placement: 'top',\n variant: '',\n text: 'Tooltip',\n};\nDefault.argTypes = {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n text: {\n name: 'text',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n variant: {\n name: 'variant',\n type: { name: 'string', required: false },\n description: 'The style of the tooltip.',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['info', 'positive', 'negative', ''],\n },\n },\n};\n\nexport const wIcon = ({\n open,\n placement,\n variant,\n text,\n}: Properties): TemplateResult => {\n return html`\n <sp-tooltip ?open=${open} placement=${placement} variant=${variant}>\n ${!!variant ? iconOptions[variant]() : html``} ${text}\n </sp-tooltip>\n `;\n};\nwIcon.args = {\n open: true,\n placement: 'top',\n text: 'Tooltip',\n variant: 'negative',\n};\nwIcon.argTypes = {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n text: {\n name: 'text',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n variant: {\n name: 'variant',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['info', 'positive', 'negative', ''],\n },\n },\n};\n\nconst overlayStyles = html`\n <style>\n html,\n body,\n #root,\n #root-inner,\n sp-story-decorator {\n height: 100%;\n margin: 0;\n }\n\n sp-story-decorator > div {\n display: contents;\n }\n\n sp-story-decorator::part(container) {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n gap: 24px;\n }\n\n sp-button:nth-of-type(1) {\n margin-top: 24px;\n }\n </style>\n`;\n\nconst overlaid = (openPlacement: Placement): TemplateResult => {\n return html`\n ${overlayStyles}\n ${(\n [\n ['bottom', ''],\n ['left', 'negative'],\n ['right', 'positive'],\n ['top', 'info'],\n ['top-start', ''],\n ] as [Placement, string][]\n ).map(([placement, variant]) => {\n return html`\n <sp-button id=\"trigger-${placement}\" label=\"${placement} test\">\n Hover for ${variant ? variant : 'tooltip'} on the\n ${placement}\n </sp-button>\n <sp-overlay\n trigger=\"trigger-${placement}@hover\"\n placement=${placement}\n open=${ifDefined(\n openPlacement === placement ? 'hover' : undefined\n )}\n >\n <sp-tooltip variant=${variant} placement=${placement}>\n ${placement}\n </sp-tooltip>\n </sp-overlay>\n `;\n })}\n `;\n};\n\nexport const overlaidTop = (): TemplateResult => overlaid('top');\nexport const overlaidRight = (): TemplateResult => overlaid('right');\nexport const overlaidBottom = (): TemplateResult => overlaid('bottom');\nexport const overlaidLeft = (): TemplateResult => overlaid('left');\nexport const overlaidTopStart = (): TemplateResult => overlaid('top-start');\n\nexport const selfManaged = ({\n placement,\n open,\n offset,\n delayed,\n}: Properties): TemplateResult => html`\n ${overlayStyles}\n <sp-action-button class=\"self-managed\">\n This is a button.\n <sp-tooltip\n self-managed\n placement=${placement}\n offset=${offset}\n ?delayed=${delayed}\n open=${open}\n >\n Add paragraph text by dragging the Text tool on the canvas to use\n this feature\n </sp-tooltip>\n </sp-action-button>\n`;\nselfManaged.args = {\n placement: 'top',\n open: true,\n offset: 6,\n delayed: false,\n};\nselfManaged.argTypes = {\n delayed: {\n name: 'delayed',\n type: { name: 'boolean', required: false },\n description: 'Whether to manage the tooltip with the warmup timer',\n },\n offset: {\n name: 'offset',\n type: { name: 'number', required: false },\n description:\n 'The pixel distance from the parent element to place the tooltip',\n },\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n};\n\nexport const selfManagedIconOnly = (): TemplateResult => html`\n ${overlayStyles}\n <sp-action-button class=\"self-managed\">\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n <sp-tooltip self-managed>This is a tooltip.</sp-tooltip>\n </sp-action-button>\n <hr />\n\n <sp-action-button class=\"self-managed\">\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n </sp-action-button>\n`;\n"],
|
|
5
|
-
"mappings": ";AAWA,OAAO;AACP,SAAS,YAA4B;AACrC,SAAS,iBAAiB;AAC1B,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,OAAO;AAEP,MAAM,cAYF;AAAA,EACA,IAAI,MAAM;AAAA,EACV,UAAU,MACN;AAAA;AAAA;AAAA,EAGJ,UAAU,MACN;AAAA;AAAA;AAAA,EAGJ,MAAM,MACF;AAAA;AAAA;AAGR;AAEA,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AACX;AAWO,aAAM,UAAU,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAkC;AAC9B,SAAO;AAAA,4BACiB,
|
|
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*/\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-info.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/textfield/sp-textfield.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { Placement } from '@spectrum-web-components/overlay';\nimport '@spectrum-web-components/overlay/sp-overlay.js';\n\nconst iconOptions: {\n [key: string]: ({\n width,\n height,\n hidden,\n title,\n }?: {\n width?: number;\n height?: number;\n hidden?: boolean;\n title?: string;\n }) => TemplateResult | string;\n} = {\n '': () => html``,\n negative: () =>\n html`\n <sp-icon-alert slot=\"icon\"></sp-icon-alert>\n `,\n positive: () =>\n html`\n <sp-icon-checkmark slot=\"icon\"></sp-icon-checkmark>\n `,\n info: () =>\n html`\n <sp-icon-info slot=\"icon\"></sp-icon-info>\n `,\n};\n\nexport default {\n component: 'sp-tooltip',\n title: 'Tooltip',\n};\n\ninterface Properties {\n open?: boolean;\n placement?: Placement;\n variant?: string;\n text?: string;\n offset?: number;\n delayed?: boolean;\n}\n\nexport const Default = ({\n open,\n placement,\n variant,\n text,\n}: Properties): TemplateResult => {\n return html`\n <sp-tooltip ?open=${open} placement=${placement} variant=${variant}>\n ${text}\n </sp-tooltip>\n `;\n};\nDefault.args = {\n open: true,\n placement: 'top',\n variant: '',\n text: 'Tooltip',\n};\nDefault.argTypes = {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n text: {\n name: 'text',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n variant: {\n name: 'variant',\n type: { name: 'string', required: false },\n description: 'The style of the tooltip.',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['info', 'positive', 'negative', ''],\n },\n },\n};\n\nexport const wIcon = ({\n open,\n placement,\n variant,\n text,\n}: Properties): TemplateResult => {\n return html`\n <sp-tooltip ?open=${open} placement=${placement} variant=${variant}>\n ${!!variant ? iconOptions[variant]() : html``} ${text}\n </sp-tooltip>\n `;\n};\nwIcon.args = {\n open: true,\n placement: 'top',\n text: 'Tooltip',\n variant: 'negative',\n};\nwIcon.argTypes = {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n text: {\n name: 'text',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: 'text',\n },\n variant: {\n name: 'variant',\n type: { name: 'string', required: false },\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['info', 'positive', 'negative', ''],\n },\n },\n};\n\nconst overlayStyles = html`\n <style>\n html,\n body,\n #root,\n #root-inner,\n sp-story-decorator {\n height: 100%;\n margin: 0;\n }\n\n sp-story-decorator > div {\n display: contents;\n }\n\n sp-story-decorator::part(container) {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n gap: 24px;\n }\n\n sp-button:nth-of-type(1) {\n margin-top: 24px;\n }\n </style>\n`;\n\nconst overlaid = (openPlacement: Placement): TemplateResult => {\n return html`\n ${overlayStyles}\n ${(\n [\n ['bottom', ''],\n ['left', 'negative'],\n ['right', 'positive'],\n ['top', 'info'],\n ['top-start', ''],\n ] as [Placement, string][]\n ).map(([placement, variant]) => {\n return html`\n <sp-button id=\"trigger-${placement}\" label=\"${placement} test\">\n Hover for ${variant ? variant : 'tooltip'} on the\n ${placement}\n </sp-button>\n <sp-overlay\n trigger=\"trigger-${placement}@hover\"\n placement=${placement}\n open=${ifDefined(\n openPlacement === placement ? 'hover' : undefined\n )}\n >\n <sp-tooltip variant=${variant} placement=${placement}>\n ${placement}\n </sp-tooltip>\n </sp-overlay>\n `;\n })}\n `;\n};\n\nexport const overlaidTop = (): TemplateResult => overlaid('top');\nexport const overlaidRight = (): TemplateResult => overlaid('right');\nexport const overlaidBottom = (): TemplateResult => overlaid('bottom');\nexport const overlaidLeft = (): TemplateResult => overlaid('left');\nexport const overlaidTopStart = (): TemplateResult => overlaid('top-start');\n\nexport const selfManaged = ({\n placement,\n open,\n offset,\n delayed,\n}: Properties): TemplateResult => html`\n ${overlayStyles}\n <sp-action-button class=\"self-managed\">\n This is a button.\n <sp-tooltip\n self-managed\n placement=${placement}\n offset=${offset}\n ?delayed=${delayed}\n open=${open}\n >\n Add paragraph text by dragging the Text tool on the canvas to use\n this feature\n </sp-tooltip>\n </sp-action-button>\n`;\nselfManaged.args = {\n placement: 'top',\n open: true,\n offset: 6,\n delayed: false,\n};\nselfManaged.argTypes = {\n delayed: {\n name: 'delayed',\n type: { name: 'boolean', required: false },\n description: 'Whether to manage the tooltip with the warmup timer',\n },\n offset: {\n name: 'offset',\n type: { name: 'number', required: false },\n description:\n 'The pixel distance from the parent element to place the tooltip',\n },\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tooltip is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n placement: {\n name: 'placement',\n type: { name: 'string', required: false },\n description: 'The placement of the tooltip in relation to its parent',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'top' },\n },\n control: {\n type: 'inline-radio',\n options: [\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'right-start',\n 'right-end',\n 'left-start',\n 'left-end',\n 'none',\n ],\n },\n },\n};\n\nexport const selfManagedIconOnly = (): TemplateResult => html`\n ${overlayStyles}\n <sp-action-button class=\"self-managed\">\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n <sp-tooltip self-managed>This is a tooltip.</sp-tooltip>\n </sp-action-button>\n <hr />\n\n <sp-action-button class=\"self-managed\">\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n </sp-action-button>\n`;\n\nexport const selfManagedFieldLabel = (): TemplateResult => html`\n <div style=\"display: inline-flex; flex-direction: column;\">\n <sp-field-label for=\"input\">\n <sp-icon-edit></sp-icon-edit>\n <sp-tooltip self-managed>Edit</sp-tooltip>\n </sp-field-label>\n <sp-textfield id=\"input\"></sp-textfield>\n </div>\n`;\n"],
|
|
5
|
+
"mappings": ";AAWA,OAAO;AACP,SAAS,YAA4B;AACrC,SAAS,iBAAiB;AAC1B,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,OAAO;AAEP,MAAM,cAYF;AAAA,EACA,IAAI,MAAM;AAAA,EACV,UAAU,MACN;AAAA;AAAA;AAAA,EAGJ,UAAU,MACN;AAAA;AAAA;AAAA,EAGJ,MAAM,MACF;AAAA;AAAA;AAGR;AAEA,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AACX;AAWO,aAAM,UAAU,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAkC;AAC9B,SAAO;AAAA,4BACiB,IAAI,cAAc,SAAS,YAAY,OAAO;AAAA,cAC5D,IAAI;AAAA;AAAA;AAGlB;AACA,QAAQ,OAAO;AAAA,EACX,MAAM;AAAA,EACN,WAAW;AAAA,EACX,SAAS;A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;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;AAEO,aAAM,sBAAsB,MAAsB;AAAA,MACnD,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYZ,aAAM,wBAAwB,MAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/tooltip.test.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
oneEvent
|
|
9
9
|
} from "@open-wc/testing";
|
|
10
10
|
import "@spectrum-web-components/button/sp-button.js";
|
|
11
|
+
import { stub } from "sinon";
|
|
11
12
|
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
12
13
|
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
13
14
|
describe("Tooltip", () => {
|
|
@@ -151,5 +152,42 @@ describe("Tooltip", () => {
|
|
|
151
152
|
await elementUpdated(el);
|
|
152
153
|
expect(typeof el.tipElement).to.not.equal("undefined");
|
|
153
154
|
});
|
|
155
|
+
describe("dev mode", () => {
|
|
156
|
+
let consoleWarnStub;
|
|
157
|
+
before(() => {
|
|
158
|
+
window.__swc.verbose = true;
|
|
159
|
+
consoleWarnStub = stub(console, "warn");
|
|
160
|
+
});
|
|
161
|
+
afterEach(() => {
|
|
162
|
+
consoleWarnStub.resetHistory();
|
|
163
|
+
});
|
|
164
|
+
after(() => {
|
|
165
|
+
window.__swc.verbose = false;
|
|
166
|
+
consoleWarnStub.restore();
|
|
167
|
+
});
|
|
168
|
+
it("loads default badge accessibly", async () => {
|
|
169
|
+
const el = await fixture(
|
|
170
|
+
html`
|
|
171
|
+
<sp-tooltip variant="negative" self-managed>
|
|
172
|
+
Help text.
|
|
173
|
+
</sp-tooltip>
|
|
174
|
+
`
|
|
175
|
+
);
|
|
176
|
+
await elementUpdated(el);
|
|
177
|
+
expect(consoleWarnStub.called).to.be.true;
|
|
178
|
+
const spyCall = consoleWarnStub.getCall(0);
|
|
179
|
+
expect(
|
|
180
|
+
spyCall.args.at(0).includes("Self managed"),
|
|
181
|
+
"confirm self managed-centric message"
|
|
182
|
+
).to.be.true;
|
|
183
|
+
expect(spyCall.args.at(-1), "confirm `data` shape").to.deep.equal({
|
|
184
|
+
data: {
|
|
185
|
+
localName: "sp-tooltip",
|
|
186
|
+
type: "api",
|
|
187
|
+
level: "high"
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
154
192
|
});
|
|
155
193
|
//# sourceMappingURL=tooltip.test.js.map
|
package/test/tooltip.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.test.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 '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n} from '@open-wc/testing';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/button/sp-button.js';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\ndescribe('Tooltip', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n )\n );\n it('loads', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('self manages', async () => {\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [1, 1],\n },\n ],\n });\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed placement=\"top\">\n Help text.\n </sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n await expect(button).to.be.accessible();\n\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self manages', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self managed and removed', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.remove();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('accepts variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"negative\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('negative');\n expect(el.getAttribute('variant')).to.equal('negative');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.setAttribute('variant', 'positive');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('positive');\n expect(el.getAttribute('variant')).to.equal('positive');\n\n el.removeAttribute('variant');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n });\n it('validates variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"other\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n });\n\n it('surfaces tip element', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip placement=\"top\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(typeof el.tipElement).to.not.equal('undefined');\n });\n});\n"],
|
|
5
|
-
"mappings": ";AAYA,OAAO;AAEP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AACP,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;AAE1B,SAAS,WAAW,MAAM;AACtB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,SAAS,YAAY;AACpB,UAAM,KAAK,MAAM;AAAA,MACb;AAA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ACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE;AAC9B,WAAO,GAAG,aAAa,SAAS,CAAC,EAAE,GAAG,GAAG;AAEzC,OAAG,UAAU;AAEb,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,OAAO,EAAE,GAAG,MAAM,MAAM;AAClC,WAAO,GAAG,aAAa,SAAS,CAAC,EAAE,GAAG,MAAM,MAAM;AAElD,OAAG,UAAU;AAEb,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,OAAO,EAAE,GAAG,MAAM,MAAM;AAClC,WAAO,GAAG,aAAa,SAAS,CAAC,EAAE,GAAG,MAAM,MAAM;AAAA,EACtD,CAAC;AAED,KAAG,wBAAwB,YAAY;AACnC,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,OAAO,GAAG,UAAU,EAAE,GAAG,IAAI,MAAM,WAAW;AAAA,EACzD,CAAC;AACL,CAAC;",
|
|
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 '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n} from '@open-wc/testing';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/button/sp-button.js';\nimport { stub } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\ndescribe('Tooltip', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n )\n );\n it('loads', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('self manages', async () => {\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [1, 1],\n },\n ],\n });\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed placement=\"top\">\n Help text.\n </sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n await expect(button).to.be.accessible();\n\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self manages', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self managed and removed', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.remove();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('accepts variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"negative\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('negative');\n expect(el.getAttribute('variant')).to.equal('negative');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.setAttribute('variant', 'positive');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('positive');\n expect(el.getAttribute('variant')).to.equal('positive');\n\n el.removeAttribute('variant');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n });\n it('validates variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"other\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n });\n\n it('surfaces tip element', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip placement=\"top\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(typeof el.tipElement).to.not.equal('undefined');\n });\n describe('dev mode', () => {\n let consoleWarnStub!: ReturnType<typeof stub>;\n before(() => {\n window.__swc.verbose = true;\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n window.__swc.verbose = false;\n consoleWarnStub.restore();\n });\n\n it('loads default badge accessibly', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"negative\" self-managed>\n Help text.\n </sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n (spyCall.args.at(0) as string).includes('Self managed'),\n 'confirm self managed-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-tooltip',\n type: 'api',\n level: 'high',\n },\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO;AAEP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;AAE1B,SAAS,WAAW,MAAM;AACtB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,SAAS,YAAY;AACpB,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,gBAAgB,YAAY;AAC3B,UAAM,UAAU;AAAA,MACZ,OAAO;AAAA,QACH;AAAA,UACI,MAAM;AAAA,UACN,UAAU,CAAC,GAAG,CAAC;AAAA,QACnB;AAAA,MACJ;AAAA,IACJ,CAAC;AACD,UAAM,SAAS,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQJ;AAEA,UAAM,KAAK,OAAO,cAAc,YAAY;AAE5C,UAAM,eAAe,EAAE;AACvB,UAAM,OAAO,MAAM,EAAE,GAAG,GAAG,WAAW;AAEtC,UAAM,SAAS,SAAS,QAAQ,WAAW;AAC3C,WAAO,MAAM;AACb,UAAM;AAEN,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AACtB,UAAM,OAAO,MAAM,EAAE,GAAG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,GAAG,IAAI,MAAM,WAAW;AAAA,EACzD,CAAC;AACD,WAAS,YAAY,MAAM;AACvB,QAAI;AACJ,WAAO,MAAM;AACT,aAAO,MAAM,UAAU;AACvB,wBAAkB,KAAK,SAAS,MAAM;AAAA,IAC1C,CAAC;AACD,cAAU,MAAM;AACZ,sBAAgB,aAAa;AAAA,IACjC,CAAC;AACD,UAAM,MAAM;AACR,aAAO,MAAM,UAAU;AACvB,sBAAgB,QAAQ;AAAA,IAC5B,CAAC;AAED,OAAG,kCAAkC,YAAY;AAC7C,YAAM,KAAK,MAAM;AAAA,QACb;AAAA;AAAA;AAAA;AAAA;AAAA,MAKJ;AAEA,YAAM,eAAe,EAAE;AAEvB,aAAO,gBAAgB,MAAM,EAAE,GAAG,GAAG;AACrC,YAAM,UAAU,gBAAgB,QAAQ,CAAC;AACzC;AAAA,QACK,QAAQ,KAAK,GAAG,CAAC,EAAa,SAAS,cAAc;AAAA,QACtD;AAAA,MACJ,EAAE,GAAG,GAAG;AACR,aAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,sBAAsB,EAAE,GAAG,KAAK,MAAM;AAAA,QAC9D,MAAM;AAAA,UACF,WAAW;AAAA,UACX,MAAM;AAAA,UACN,OAAO;AAAA,QACX;AAAA,MACJ,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AACL,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/custom-elements.json
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": "1.0.0",
|
|
3
|
-
"readme": "",
|
|
4
|
-
"modules": [
|
|
5
|
-
{
|
|
6
|
-
"kind": "javascript-module",
|
|
7
|
-
"path": "sp-tooltip.ts",
|
|
8
|
-
"declarations": [],
|
|
9
|
-
"exports": [
|
|
10
|
-
{
|
|
11
|
-
"kind": "custom-element-definition",
|
|
12
|
-
"name": "sp-tooltip",
|
|
13
|
-
"declaration": {
|
|
14
|
-
"name": "Tooltip",
|
|
15
|
-
"module": "/src/Tooltip.js"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"kind": "javascript-module",
|
|
22
|
-
"path": "src/Tooltip.ts",
|
|
23
|
-
"declarations": [
|
|
24
|
-
{
|
|
25
|
-
"kind": "class",
|
|
26
|
-
"description": "",
|
|
27
|
-
"name": "TooltipOpenable",
|
|
28
|
-
"members": [
|
|
29
|
-
{
|
|
30
|
-
"kind": "field",
|
|
31
|
-
"name": "open",
|
|
32
|
-
"type": {
|
|
33
|
-
"text": "boolean"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"kind": "field",
|
|
38
|
-
"name": "_open",
|
|
39
|
-
"type": {
|
|
40
|
-
"text": "boolean"
|
|
41
|
-
},
|
|
42
|
-
"privacy": "private",
|
|
43
|
-
"default": "false"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"kind": "field",
|
|
47
|
-
"name": "placement",
|
|
48
|
-
"type": {
|
|
49
|
-
"text": "Placement"
|
|
50
|
-
},
|
|
51
|
-
"attribute": "placement"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"kind": "field",
|
|
55
|
-
"name": "_placement",
|
|
56
|
-
"type": {
|
|
57
|
-
"text": "Placement"
|
|
58
|
-
},
|
|
59
|
-
"privacy": "private",
|
|
60
|
-
"default": "'top'"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"kind": "field",
|
|
64
|
-
"name": "tipElement",
|
|
65
|
-
"type": {
|
|
66
|
-
"text": "HTMLElement"
|
|
67
|
-
},
|
|
68
|
-
"readonly": true
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
"attributes": [
|
|
72
|
-
{
|
|
73
|
-
"name": "open"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "placement",
|
|
77
|
-
"type": {
|
|
78
|
-
"text": "\"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\""
|
|
79
|
-
},
|
|
80
|
-
"fieldName": "placement"
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
"superclass": {
|
|
84
|
-
"name": "HTMLElement"
|
|
85
|
-
},
|
|
86
|
-
"tagName": "sp-tooltip-openable",
|
|
87
|
-
"customElement": true
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"kind": "class",
|
|
91
|
-
"description": "",
|
|
92
|
-
"name": "Tooltip",
|
|
93
|
-
"slots": [
|
|
94
|
-
{
|
|
95
|
-
"description": "the icon element appearing at the start of the label",
|
|
96
|
-
"name": "icon"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"description": "the text label of the Tooltip",
|
|
100
|
-
"name": ""
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
"members": [
|
|
104
|
-
{
|
|
105
|
-
"kind": "field",
|
|
106
|
-
"name": "selfManaged",
|
|
107
|
-
"type": {
|
|
108
|
-
"text": "boolean"
|
|
109
|
-
},
|
|
110
|
-
"privacy": "public",
|
|
111
|
-
"default": "false",
|
|
112
|
-
"description": "Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\nWithout this, you must provide your own `overlay-trigger`.",
|
|
113
|
-
"attribute": "self-managed"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"kind": "field",
|
|
117
|
-
"name": "offset",
|
|
118
|
-
"type": {
|
|
119
|
-
"text": "number"
|
|
120
|
-
},
|
|
121
|
-
"privacy": "public",
|
|
122
|
-
"default": "0",
|
|
123
|
-
"attribute": "offset"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"kind": "field",
|
|
127
|
-
"name": "open",
|
|
128
|
-
"type": {
|
|
129
|
-
"text": "boolean"
|
|
130
|
-
},
|
|
131
|
-
"privacy": "public",
|
|
132
|
-
"default": "false",
|
|
133
|
-
"attribute": "open",
|
|
134
|
-
"reflects": true
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"kind": "field",
|
|
138
|
-
"name": "placement",
|
|
139
|
-
"type": {
|
|
140
|
-
"text": "\"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\""
|
|
141
|
-
},
|
|
142
|
-
"privacy": "public",
|
|
143
|
-
"attribute": "placement",
|
|
144
|
-
"reflects": true
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"kind": "field",
|
|
148
|
-
"name": "tipElement",
|
|
149
|
-
"type": {
|
|
150
|
-
"text": "HTMLSpanElement"
|
|
151
|
-
},
|
|
152
|
-
"privacy": "public"
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"kind": "field",
|
|
156
|
-
"name": "tipPadding",
|
|
157
|
-
"type": {
|
|
158
|
-
"text": "number | undefined"
|
|
159
|
-
},
|
|
160
|
-
"privacy": "public",
|
|
161
|
-
"attribute": "tipPadding"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"kind": "field",
|
|
165
|
-
"name": "_variant",
|
|
166
|
-
"type": {
|
|
167
|
-
"text": "string"
|
|
168
|
-
},
|
|
169
|
-
"privacy": "private",
|
|
170
|
-
"default": "''"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"kind": "field",
|
|
174
|
-
"name": "variant",
|
|
175
|
-
"type": {
|
|
176
|
-
"text": "string"
|
|
177
|
-
},
|
|
178
|
-
"privacy": "public",
|
|
179
|
-
"attribute": "variant"
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"kind": "field",
|
|
183
|
-
"name": "handleOpenOverlay",
|
|
184
|
-
"privacy": "private"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
"kind": "field",
|
|
188
|
-
"name": "handleCloseOverlay",
|
|
189
|
-
"privacy": "protected"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"kind": "method",
|
|
193
|
-
"name": "handleTransitionrun",
|
|
194
|
-
"privacy": "protected",
|
|
195
|
-
"return": {
|
|
196
|
-
"type": {
|
|
197
|
-
"text": "void"
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
"parameters": [
|
|
201
|
-
{
|
|
202
|
-
"name": "event",
|
|
203
|
-
"type": {
|
|
204
|
-
"text": "TransitionEvent"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
"kind": "method",
|
|
211
|
-
"name": "handleTransitionend",
|
|
212
|
-
"privacy": "protected",
|
|
213
|
-
"return": {
|
|
214
|
-
"type": {
|
|
215
|
-
"text": "void"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"parameters": [
|
|
219
|
-
{
|
|
220
|
-
"name": "event",
|
|
221
|
-
"type": {
|
|
222
|
-
"text": "TransitionEvent"
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
"kind": "field",
|
|
229
|
-
"name": "triggerElement",
|
|
230
|
-
"type": {
|
|
231
|
-
"text": "HTMLElement"
|
|
232
|
-
},
|
|
233
|
-
"privacy": "private",
|
|
234
|
-
"readonly": true
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
"events": [
|
|
238
|
-
{
|
|
239
|
-
"name": "transitionrun",
|
|
240
|
-
"type": {
|
|
241
|
-
"text": "TransitionEvent"
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
"name": "transitionend",
|
|
246
|
-
"type": {
|
|
247
|
-
"text": "TransitionEvent"
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
],
|
|
251
|
-
"attributes": [
|
|
252
|
-
{
|
|
253
|
-
"name": "placement",
|
|
254
|
-
"type": {
|
|
255
|
-
"text": "\"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\""
|
|
256
|
-
},
|
|
257
|
-
"fieldName": "placement",
|
|
258
|
-
"attribute": "placement"
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
"name": "self-managed",
|
|
262
|
-
"type": {
|
|
263
|
-
"text": "boolean"
|
|
264
|
-
},
|
|
265
|
-
"default": "false",
|
|
266
|
-
"description": "Automatically bind to the parent element of the assigned `slot` or the parent element of the `sp-tooltip`.\nWithout this, you must provide your own `overlay-trigger`.",
|
|
267
|
-
"fieldName": "selfManaged"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
"name": "offset",
|
|
271
|
-
"type": {
|
|
272
|
-
"text": "number"
|
|
273
|
-
},
|
|
274
|
-
"default": "0",
|
|
275
|
-
"fieldName": "offset"
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
"name": "open",
|
|
279
|
-
"type": {
|
|
280
|
-
"text": "boolean"
|
|
281
|
-
},
|
|
282
|
-
"default": "false",
|
|
283
|
-
"fieldName": "open"
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
"name": "tipPadding",
|
|
287
|
-
"type": {
|
|
288
|
-
"text": "number | undefined"
|
|
289
|
-
},
|
|
290
|
-
"fieldName": "tipPadding"
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"name": "variant",
|
|
294
|
-
"type": {
|
|
295
|
-
"text": "string"
|
|
296
|
-
},
|
|
297
|
-
"fieldName": "variant"
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
"superclass": {
|
|
301
|
-
"name": "SpectrumElement",
|
|
302
|
-
"package": "@spectrum-web-components/base"
|
|
303
|
-
},
|
|
304
|
-
"tagName": "sp-tooltip",
|
|
305
|
-
"customElement": true
|
|
306
|
-
}
|
|
307
|
-
],
|
|
308
|
-
"exports": [
|
|
309
|
-
{
|
|
310
|
-
"kind": "custom-element-definition",
|
|
311
|
-
"name": "sp-tooltip-openable",
|
|
312
|
-
"declaration": {
|
|
313
|
-
"name": "TooltipOpenable",
|
|
314
|
-
"module": "src/Tooltip.ts"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
"kind": "js",
|
|
319
|
-
"name": "Tooltip",
|
|
320
|
-
"declaration": {
|
|
321
|
-
"name": "Tooltip",
|
|
322
|
-
"module": "src/Tooltip.ts"
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
]
|
|
326
|
-
}
|
|
327
|
-
]
|
|
328
|
-
}
|