@spectrum-web-components/tooltip 0.10.7 → 0.10.8-express.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/sp-tooltip.d.ts +6 -0
- package/sp-tooltip.js +14 -0
- package/sp-tooltip.js.map +1 -0
- package/src/Tooltip.d.ts +55 -0
- package/src/Tooltip.js +217 -0
- package/src/Tooltip.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +13 -0
- package/src/index.js.map +1 -0
- package/src/spectrum-tooltip.css.d.ts +2 -0
- package/src/spectrum-tooltip.css.js +103 -0
- package/src/spectrum-tooltip.css.js.map +1 -0
- package/src/tooltip.css.d.ts +2 -0
- package/src/tooltip.css.js +113 -0
- package/src/tooltip.css.js.map +1 -0
- package/stories/tooltip.stories.js +320 -0
- package/stories/tooltip.stories.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tooltip",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8-express.0+7a2be85d7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@spectrum-web-components/base": "^0.5.3",
|
|
48
|
-
"@spectrum-web-components/overlay": "^0.15.0",
|
|
48
|
+
"@spectrum-web-components/overlay": "^0.15.1-express.0+7a2be85d7",
|
|
49
49
|
"tslib": "^2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"sideEffects": [
|
|
57
57
|
"./sp-*.js"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "7a2be85d7e231dcf4141a86b7056f6c139a43851"
|
|
60
60
|
}
|
package/sp-tooltip.d.ts
ADDED
package/sp-tooltip.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { Tooltip } from './src/Tooltip.js';
|
|
13
|
+
customElements.define('sp-tooltip', Tooltip);
|
|
14
|
+
//# sourceMappingURL=sp-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sp-tooltip.js","sourceRoot":"","sources":["sp-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC","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 { Tooltip } from './src/Tooltip.js';\n\ncustomElements.define('sp-tooltip', Tooltip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tooltip': Tooltip;\n }\n}\n"]}
|
package/src/Tooltip.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import type { OverlayDisplayQueryDetail, Placement } from '@spectrum-web-components/overlay';
|
|
3
|
+
export declare class TooltipProxy extends HTMLElement {
|
|
4
|
+
disconnectedCallback(): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @element sp-tooltip
|
|
8
|
+
*
|
|
9
|
+
* @slot icon - the icon element appearing at the start of the label
|
|
10
|
+
* @slot - the text label of the Tooltip
|
|
11
|
+
*/
|
|
12
|
+
export declare class Tooltip extends SpectrumElement {
|
|
13
|
+
static get styles(): CSSResultArray;
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
static instanceCount: number;
|
|
18
|
+
private _tooltipId;
|
|
19
|
+
selfManaged: boolean;
|
|
20
|
+
offset: number;
|
|
21
|
+
private hadTooltipId;
|
|
22
|
+
open: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @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
|
+
* @attr
|
|
26
|
+
*/
|
|
27
|
+
placement: Placement;
|
|
28
|
+
private tipElement;
|
|
29
|
+
private _variant;
|
|
30
|
+
get variant(): string;
|
|
31
|
+
set variant(variant: string);
|
|
32
|
+
constructor();
|
|
33
|
+
onOverlayQuery(event: CustomEvent<OverlayDisplayQueryDetail>): void;
|
|
34
|
+
private _proxy;
|
|
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;
|
|
52
|
+
render(): TemplateResult;
|
|
53
|
+
protected update(changed: PropertyValues<this>): Promise<void>;
|
|
54
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
55
|
+
}
|
package/src/Tooltip.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { __decorate } from "tslib";
|
|
13
|
+
import { html, SpectrumElement, } from '@spectrum-web-components/base';
|
|
14
|
+
import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
|
|
15
|
+
import { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';
|
|
16
|
+
import tooltipStyles from './tooltip.css.js';
|
|
17
|
+
export class TooltipProxy extends HTMLElement {
|
|
18
|
+
disconnectedCallback() {
|
|
19
|
+
this.dispatchEvent(new Event('disconnected'));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
customElements.define('tooltip-proxy', TooltipProxy);
|
|
23
|
+
/**
|
|
24
|
+
* @element sp-tooltip
|
|
25
|
+
*
|
|
26
|
+
* @slot icon - the icon element appearing at the start of the label
|
|
27
|
+
* @slot - the text label of the Tooltip
|
|
28
|
+
*/
|
|
29
|
+
export class Tooltip extends SpectrumElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this._tooltipId = `sp-tooltip-describedby-helper-${Tooltip.instanceCount++}`;
|
|
33
|
+
this.selfManaged = false;
|
|
34
|
+
this.offset = 6;
|
|
35
|
+
this.hadTooltipId = false;
|
|
36
|
+
this.open = false;
|
|
37
|
+
/**
|
|
38
|
+
* @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"}
|
|
39
|
+
* @attr
|
|
40
|
+
*/
|
|
41
|
+
this.placement = 'top';
|
|
42
|
+
/* Ensure that a '' value for `variant` removes the attribute instead of a blank value */
|
|
43
|
+
this._variant = '';
|
|
44
|
+
this.abortOverlay = () => {
|
|
45
|
+
return;
|
|
46
|
+
};
|
|
47
|
+
this.openOverlay = () => {
|
|
48
|
+
const parentElement = this.parentElement;
|
|
49
|
+
const abortPromise = new Promise((res) => {
|
|
50
|
+
this.abortOverlay = res;
|
|
51
|
+
});
|
|
52
|
+
this.closeOverlayCallback = openOverlay(parentElement, 'hover', this, {
|
|
53
|
+
abortPromise,
|
|
54
|
+
offset: this.offset,
|
|
55
|
+
placement: this.placement,
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
this.closeOverlay = async () => {
|
|
59
|
+
if (this.abortOverlay)
|
|
60
|
+
this.abortOverlay(true);
|
|
61
|
+
if (!this.closeOverlayCallback)
|
|
62
|
+
return;
|
|
63
|
+
(await this.closeOverlayCallback)();
|
|
64
|
+
delete this.closeOverlayCallback;
|
|
65
|
+
};
|
|
66
|
+
this.addEventListener('sp-overlay-query', this.onOverlayQuery);
|
|
67
|
+
}
|
|
68
|
+
static get styles() {
|
|
69
|
+
return [tooltipStyles];
|
|
70
|
+
}
|
|
71
|
+
get variant() {
|
|
72
|
+
return this._variant;
|
|
73
|
+
}
|
|
74
|
+
set variant(variant) {
|
|
75
|
+
if (variant === this.variant) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (['info', 'positive', 'negative'].includes(variant)) {
|
|
79
|
+
this.setAttribute('variant', variant);
|
|
80
|
+
this._variant = variant;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.removeAttribute('variant');
|
|
84
|
+
this._variant = '';
|
|
85
|
+
}
|
|
86
|
+
onOverlayQuery(event) {
|
|
87
|
+
/* c8 ignore next */
|
|
88
|
+
if (!event.target)
|
|
89
|
+
return;
|
|
90
|
+
const target = event.target;
|
|
91
|
+
/* c8 ignore next */
|
|
92
|
+
if (target !== this)
|
|
93
|
+
return;
|
|
94
|
+
event.detail.overlayContentTipElement = this.tipElement;
|
|
95
|
+
}
|
|
96
|
+
generateProxy() {
|
|
97
|
+
if (this._proxy) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this._proxy = document.createElement('tooltip-proxy');
|
|
101
|
+
this._proxy.id = this._tooltipId;
|
|
102
|
+
this._proxy.hidden = true;
|
|
103
|
+
this._proxy.slot = 'hidden-tooltip-content';
|
|
104
|
+
this._proxy.setAttribute('role', 'tooltip');
|
|
105
|
+
this._proxy.addEventListener('disconnected', this.closeOverlay);
|
|
106
|
+
}
|
|
107
|
+
overlayWillOpenCallback({ trigger, }) {
|
|
108
|
+
this.setAttribute('aria-hidden', 'true');
|
|
109
|
+
this.generateProxy();
|
|
110
|
+
this._proxy.textContent = this.textContent;
|
|
111
|
+
const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';
|
|
112
|
+
this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;
|
|
113
|
+
this.insertAdjacentElement('beforebegin', this._proxy);
|
|
114
|
+
if (this.hadTooltipId)
|
|
115
|
+
return;
|
|
116
|
+
if (ariaDescribedby) {
|
|
117
|
+
trigger.setAttribute('aria-describedby', `${ariaDescribedby} ${this._tooltipId}`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
trigger.setAttribute('aria-describedby', `${this._tooltipId}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
overlayOpenCancelledCallback({ trigger, }) {
|
|
124
|
+
this.overlayCloseCallback({ trigger });
|
|
125
|
+
}
|
|
126
|
+
overlayCloseCallback({ trigger }) {
|
|
127
|
+
const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';
|
|
128
|
+
let descriptors = ariaDescribedby.split(/\s+/);
|
|
129
|
+
if (!this.hadTooltipId) {
|
|
130
|
+
descriptors = descriptors.filter((descriptor) => descriptor !== this._tooltipId);
|
|
131
|
+
}
|
|
132
|
+
if (descriptors.length) {
|
|
133
|
+
trigger.setAttribute('aria-describedby', descriptors.join(' '));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
trigger.removeAttribute('aria-describedby');
|
|
137
|
+
}
|
|
138
|
+
this.removeAttribute('aria-hidden');
|
|
139
|
+
this.removeProxy();
|
|
140
|
+
}
|
|
141
|
+
removeProxy() {
|
|
142
|
+
this._proxy.remove();
|
|
143
|
+
}
|
|
144
|
+
manageTooltip() {
|
|
145
|
+
const parentElement = this.parentElement;
|
|
146
|
+
if (this.selfManaged) {
|
|
147
|
+
if (this.slot) {
|
|
148
|
+
this.previousSlot = this.slot;
|
|
149
|
+
}
|
|
150
|
+
this.slot = 'self-managed-tooltip';
|
|
151
|
+
parentElement.addEventListener('pointerenter', this.openOverlay);
|
|
152
|
+
parentElement.addEventListener('focusin', this.openOverlay);
|
|
153
|
+
parentElement.addEventListener('pointerleave', this.closeOverlay);
|
|
154
|
+
parentElement.addEventListener('focusout', this.closeOverlay);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
if (this.previousSlot) {
|
|
158
|
+
this.slot = this.previousSlot;
|
|
159
|
+
}
|
|
160
|
+
else if (this.slot === 'self-managed-tooltip') {
|
|
161
|
+
this.removeAttribute('slot');
|
|
162
|
+
}
|
|
163
|
+
parentElement.removeEventListener('pointerenter', this.openOverlay);
|
|
164
|
+
parentElement.removeEventListener('focusin', this.openOverlay);
|
|
165
|
+
parentElement.removeEventListener('pointerleave', this.closeOverlay);
|
|
166
|
+
parentElement.removeEventListener('focusout', this.closeOverlay);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
render() {
|
|
170
|
+
return html `
|
|
171
|
+
<slot name="icon"></slot>
|
|
172
|
+
<span id="label"><slot></slot></span>
|
|
173
|
+
<span id="tip"></span>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
async update(changed) {
|
|
177
|
+
if (changed.has('open') && this.selfManaged) {
|
|
178
|
+
if (this.open) {
|
|
179
|
+
this.openOverlay();
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.closeOverlay();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.generateProxy();
|
|
186
|
+
super.update(changed);
|
|
187
|
+
}
|
|
188
|
+
updated(changed) {
|
|
189
|
+
super.updated(changed);
|
|
190
|
+
if (changed.has('selfManaged')) {
|
|
191
|
+
this.manageTooltip();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
Tooltip.instanceCount = 0;
|
|
199
|
+
__decorate([
|
|
200
|
+
property({ type: Boolean, attribute: 'self-managed' })
|
|
201
|
+
], Tooltip.prototype, "selfManaged", void 0);
|
|
202
|
+
__decorate([
|
|
203
|
+
property({ type: Number, reflect: true })
|
|
204
|
+
], Tooltip.prototype, "offset", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
property({ type: Boolean, reflect: true })
|
|
207
|
+
], Tooltip.prototype, "open", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ reflect: true })
|
|
210
|
+
], Tooltip.prototype, "placement", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
query('#tip')
|
|
213
|
+
], Tooltip.prototype, "tipElement", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
property({ type: String })
|
|
216
|
+
], Tooltip.prototype, "variant", null);
|
|
217
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["Tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EAEJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AAKzD,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAE7E,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,OAAO,YAAa,SAAQ,WAAW;IACzC,oBAAoB;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;AAErD;;;;;GAKG;AAEH,MAAM,OAAO,OAAQ,SAAQ,eAAe;IAoDxC;QACI,KAAK,EAAE,CAAC;QA3CJ,eAAU,GAAG,iCAAiC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;QAGzE,gBAAW,GAAG,KAAK,CAAC;QAGpB,WAAM,GAAG,CAAC,CAAC;QACV,iBAAY,GAAG,KAAK,CAAC;QAGtB,SAAI,GAAG,KAAK,CAAC;QAEpB;;;WAGG;QAEI,cAAS,GAAc,KAAK,CAAC;QAKpC,yFAAyF;QACjF,aAAQ,GAAG,EAAE,CAAC;QA0Gd,iBAAY,GAAiC,GAAG,EAAE;YACtD,OAAO;QACX,CAAC,CAAC;QAEM,gBAAW,GAAG,GAAS,EAAE;YAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,aAA4B,CAAC;YACxD,MAAM,YAAY,GAAqB,IAAI,OAAO,CAAC,CAAC,GAAG,EAA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CAAC,aAAa,EAAE,CAAC;QACrB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAES,OAAO,CAAC,OAA6B;QAC3C,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;IACL,CAAC;;AAnND;;GAEG;AACI,qBAAa,GAAG,CAAC,CAAC;AAKzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;4CAC5B;AAG3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCACxB;AAIlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCACvB;AAOpB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACQ;AAGpC;IADC,KAAK,CAAC,MAAM,CAAC;2CACuB;AAMrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAG1B","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport type {\n OverlayDisplayQueryDetail,\n Placement,\n} from '@spectrum-web-components/overlay';\nimport { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';\n\nimport tooltipStyles from './tooltip.css.js';\n\nexport class TooltipProxy extends HTMLElement {\n disconnectedCallback(): void {\n this.dispatchEvent(new Event('disconnected'));\n }\n}\n\ncustomElements.define('tooltip-proxy', TooltipProxy);\n\n/**\n * @element sp-tooltip\n *\n * @slot icon - the icon element appearing at the start of the label\n * @slot - the text label of the Tooltip\n */\n\nexport class Tooltip extends SpectrumElement {\n public static get styles(): CSSResultArray {\n return [tooltipStyles];\n }\n\n /**\n * @private\n */\n static instanceCount = 0;\n\n private _tooltipId = `sp-tooltip-describedby-helper-${Tooltip.instanceCount++}`;\n\n @property({ type: Boolean, attribute: 'self-managed' })\n public selfManaged = false;\n\n @property({ type: Number, reflect: true })\n public offset = 6;\n private hadTooltipId = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * @type {\"auto\" | \"auto-start\" | \"auto-end\" | \"top\" | \"bottom\" | \"right\" | \"left\" | \"top-start\" | \"top-end\" | \"bottom-start\" | \"bottom-end\" | \"right-start\" | \"right-end\" | \"left-start\" | \"left-end\" | \"none\"}\n * @attr\n */\n @property({ reflect: true })\n public placement: Placement = 'top';\n\n @query('#tip')\n private tipElement!: HTMLSpanElement;\n\n /* Ensure that a '' value for `variant` removes the attribute instead of a blank value */\n private _variant = '';\n\n @property({ type: String })\n public get variant(): string {\n return this._variant;\n }\n public set variant(variant: string) {\n if (variant === this.variant) {\n return;\n }\n if (['info', 'positive', 'negative'].includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n return;\n }\n this.removeAttribute('variant');\n this._variant = '';\n }\n\n public constructor() {\n super();\n this.addEventListener('sp-overlay-query', this.onOverlayQuery);\n }\n\n public onOverlayQuery(event: CustomEvent<OverlayDisplayQueryDetail>): void {\n /* c8 ignore next */\n if (!event.target) return;\n\n const target = event.target as Node;\n /* c8 ignore next */\n if (target !== this) return;\n\n event.detail.overlayContentTipElement = this.tipElement;\n }\n\n private _proxy!: HTMLElement;\n\n private generateProxy(): void {\n if (this._proxy) {\n return;\n }\n this._proxy = document.createElement('tooltip-proxy');\n this._proxy.id = this._tooltipId;\n this._proxy.hidden = true;\n this._proxy.slot = 'hidden-tooltip-content';\n this._proxy.setAttribute('role', 'tooltip');\n this._proxy.addEventListener('disconnected', this.closeOverlay);\n }\n\n public overlayWillOpenCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.setAttribute('aria-hidden', 'true');\n this.generateProxy();\n this._proxy.textContent = this.textContent;\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n this.hadTooltipId = ariaDescribedby.search(this._tooltipId) > -1;\n\n this.insertAdjacentElement('beforebegin', this._proxy);\n\n if (this.hadTooltipId) return;\n\n if (ariaDescribedby) {\n trigger.setAttribute(\n 'aria-describedby',\n `${ariaDescribedby} ${this._tooltipId}`\n );\n } else {\n trigger.setAttribute('aria-describedby', `${this._tooltipId}`);\n }\n }\n\n public overlayOpenCancelledCallback({\n trigger,\n }: {\n trigger: HTMLElement;\n }): void {\n this.overlayCloseCallback({ trigger });\n }\n\n public overlayCloseCallback({ trigger }: { trigger: HTMLElement }): void {\n const ariaDescribedby = trigger.getAttribute('aria-describedby') || '';\n let descriptors = ariaDescribedby.split(/\\s+/);\n\n if (!this.hadTooltipId) {\n descriptors = descriptors.filter(\n (descriptor) => descriptor !== this._tooltipId\n );\n }\n if (descriptors.length) {\n trigger.setAttribute('aria-describedby', descriptors.join(' '));\n } else {\n trigger.removeAttribute('aria-describedby');\n }\n\n this.removeAttribute('aria-hidden');\n this.removeProxy();\n }\n\n private removeProxy(): void {\n this._proxy.remove();\n }\n\n private closeOverlayCallback?: Promise<() => void>;\n private abortOverlay: (cancelled: boolean) => void = () => {\n return;\n };\n\n private openOverlay = (): void => {\n const parentElement = this.parentElement as HTMLElement;\n const abortPromise: Promise<boolean> = new Promise((res) => {\n this.abortOverlay = res;\n });\n this.closeOverlayCallback = openOverlay(parentElement, 'hover', this, {\n abortPromise,\n offset: this.offset,\n placement: this.placement,\n });\n };\n\n private closeOverlay = async (): Promise<void> => {\n if (this.abortOverlay) this.abortOverlay(true);\n if (!this.closeOverlayCallback) return;\n (await this.closeOverlayCallback)();\n delete this.closeOverlayCallback;\n };\n\n private previousSlot?: string;\n\n private manageTooltip(): void {\n const parentElement = this.parentElement as HTMLElement;\n if (this.selfManaged) {\n if (this.slot) {\n this.previousSlot = this.slot;\n }\n this.slot = 'self-managed-tooltip';\n parentElement.addEventListener('pointerenter', this.openOverlay);\n parentElement.addEventListener('focusin', this.openOverlay);\n parentElement.addEventListener('pointerleave', this.closeOverlay);\n parentElement.addEventListener('focusout', this.closeOverlay);\n } else {\n if (this.previousSlot) {\n this.slot = this.previousSlot;\n } else if (this.slot === 'self-managed-tooltip') {\n this.removeAttribute('slot');\n }\n parentElement.removeEventListener('pointerenter', this.openOverlay);\n parentElement.removeEventListener('focusin', this.openOverlay);\n parentElement.removeEventListener(\n 'pointerleave',\n this.closeOverlay\n );\n parentElement.removeEventListener('focusout', this.closeOverlay);\n }\n }\n\n render(): TemplateResult {\n return html`\n <slot name=\"icon\"></slot>\n <span id=\"label\"><slot></slot></span>\n <span id=\"tip\"></span>\n `;\n }\n\n protected async update(changed: PropertyValues<this>): Promise<void> {\n if (changed.has('open') && this.selfManaged) {\n if (this.open) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n this.generateProxy();\n super.update(changed);\n }\n\n protected updated(changed: PropertyValues<this>): void {\n super.updated(changed);\n if (changed.has('selfManaged')) {\n this.manageTooltip();\n }\n }\n}\n"]}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from './Tooltip.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,cAAc,cAAc,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Tooltip.js';\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{--spectrum-overlay-animation-distance:var(
|
|
15
|
+
--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)
|
|
16
|
+
);opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host([placement*=bottom][open]){transform:translateY(var(--spectrum-overlay-animation-distance))}:host([placement*=top][open]){transform:translateY(calc(var(--spectrum-overlay-animation-distance)*-1))}:host([placement*=right][open]){transform:translateX(var(--spectrum-overlay-animation-distance))}:host([placement*=left][open]){transform:translateX(calc(var(--spectrum-overlay-animation-distance)*-1))}:host{--spectrum-tooltip-neutral-target-offset:3px;--spectrum-tooltip-neutral-tip-width:var(
|
|
17
|
+
--spectrum-tooltip-neutral-tip-height,var(--spectrum-global-dimension-size-50)
|
|
18
|
+
)}:host{-webkit-font-smoothing:antialiased;align-items:center;border-radius:var(
|
|
19
|
+
--spectrum-tooltip-neutral-border-radius,var(--spectrum-alias-component-border-radius)
|
|
20
|
+
);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(
|
|
21
|
+
--spectrum-tooltip-neutral-text-size,var(--spectrum-global-dimension-font-size-75)
|
|
22
|
+
);font-weight:var(
|
|
23
|
+
--spectrum-tooltip-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)
|
|
24
|
+
);left:0;line-height:var(
|
|
25
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
26
|
+
);max-width:var(
|
|
27
|
+
--spectrum-tooltip-neutral-max-width,var(--spectrum-global-dimension-size-2000)
|
|
28
|
+
);min-height:var(
|
|
29
|
+
--spectrum-tooltip-neutral-min-height,var(--spectrum-global-dimension-size-300)
|
|
30
|
+
);padding:0 var(
|
|
31
|
+
--spectrum-tooltip-neutral-padding-x,var(--spectrum-global-dimension-size-85)
|
|
32
|
+
);position:relative;top:0;vertical-align:top;width:auto;word-break:break-word}:host{cursor:default;-webkit-user-select:none;user-select:none}p{margin:0}#tip{border-bottom:var(
|
|
33
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
34
|
+
) solid transparent;border-left:var(
|
|
35
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
36
|
+
) solid transparent;border-right:var(
|
|
37
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
38
|
+
) solid transparent;border-top-style:solid;border-top-width:var(
|
|
39
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
40
|
+
);height:0;position:absolute;width:0}:host([placement*=left]) #tip,:host([placement*=right]) #tip{margin-top:calc(var(
|
|
41
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
42
|
+
var(--spectrum-global-dimension-size-100)
|
|
43
|
+
)*-1);top:50%}:host([placement*=right]){margin-left:var(
|
|
44
|
+
--spectrum-tooltip-neutral-target-offset
|
|
45
|
+
)}:host([placement*=right]) #tip{right:100%;transform:rotate(90deg)}:host([placement*=left]){margin-right:var(
|
|
46
|
+
--spectrum-tooltip-neutral-target-offset
|
|
47
|
+
)}:host([placement*=left]) #tip{left:100%;transform:rotate(-90deg)}:host([placement*=top]){margin-bottom:var(
|
|
48
|
+
--spectrum-tooltip-neutral-target-offset
|
|
49
|
+
)}:host([placement*=top]) #tip{top:100%}:host([placement*=bottom]){margin-top:var(
|
|
50
|
+
--spectrum-tooltip-neutral-target-offset
|
|
51
|
+
)}:host([placement*=bottom]) #tip{bottom:100%;transform:rotate(-180deg)}:host([placement*=bottom]) #tip,:host([placement*=top]) #tip{left:50%;margin-left:calc(var(
|
|
52
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
53
|
+
var(--spectrum-global-dimension-size-100)
|
|
54
|
+
)*-1)}:host([dir=ltr]) ::slotted([slot=icon]){margin-left:calc(var(
|
|
55
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
56
|
+
var(--spectrum-global-dimension-size-85)
|
|
57
|
+
) - var(
|
|
58
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
59
|
+
var(--spectrum-global-dimension-size-85)
|
|
60
|
+
))}:host([dir=rtl]) ::slotted([slot=icon]){margin-right:calc(var(
|
|
61
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
62
|
+
var(--spectrum-global-dimension-size-85)
|
|
63
|
+
) - var(
|
|
64
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
65
|
+
var(--spectrum-global-dimension-size-85)
|
|
66
|
+
))}:host([dir=ltr]) ::slotted([slot=icon]){margin-right:var(
|
|
67
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
68
|
+
)}:host([dir=rtl]) ::slotted([slot=icon]){margin-left:var(
|
|
69
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
70
|
+
)}::slotted([slot=icon]){align-self:flex-start;flex-shrink:0;height:var(
|
|
71
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
72
|
+
);margin-bottom:var(
|
|
73
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
74
|
+
);margin-top:var(
|
|
75
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
76
|
+
);width:var(
|
|
77
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
78
|
+
)}#label{line-height:var(
|
|
79
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
80
|
+
);margin-bottom:var(--spectrum-tooltip-neutral-text-margin-bottom);margin-top:var(
|
|
81
|
+
--spectrum-tooltip-neutral-text-margin-top,var(--spectrum-global-dimension-static-size-50)
|
|
82
|
+
)}:host{background-color:var(
|
|
83
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
84
|
+
);color:var(
|
|
85
|
+
--spectrum-tooltip-neutral-text-color,var(--spectrum-global-color-static-white)
|
|
86
|
+
)}#tip{border-top-color:var(
|
|
87
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
88
|
+
)}.spectrum-Tooltip--error,:host([variant=negative]){background-color:var(
|
|
89
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
90
|
+
)}.spectrum-Tooltip--error #tip,:host([variant=negative]) #tip{border-top-color:var(
|
|
91
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
92
|
+
)}.spectrum-Tooltip--help,:host([variant=info]){background-color:var(
|
|
93
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
94
|
+
)}.spectrum-Tooltip--help #tip,:host([variant=info]) #tip{border-top-color:var(
|
|
95
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
96
|
+
)}.spectrum-Tooltip--success,:host([variant=positive]){background-color:var(
|
|
97
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
98
|
+
)}.spectrum-Tooltip--success #tip,:host([variant=positive]) #tip{border-top-color:var(
|
|
99
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
100
|
+
)}
|
|
101
|
+
`;
|
|
102
|
+
export default styles;
|
|
103
|
+
//# sourceMappingURL=spectrum-tooltip.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectrum-tooltip.css.js","sourceRoot":"","sources":["spectrum-tooltip.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFjB,CAAC;AACF,eAAe,MAAM,CAAC","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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-overlay-animation-distance:var(\n--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)\n);opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host([placement*=bottom][open]){transform:translateY(var(--spectrum-overlay-animation-distance))}:host([placement*=top][open]){transform:translateY(calc(var(--spectrum-overlay-animation-distance)*-1))}:host([placement*=right][open]){transform:translateX(var(--spectrum-overlay-animation-distance))}:host([placement*=left][open]){transform:translateX(calc(var(--spectrum-overlay-animation-distance)*-1))}:host{--spectrum-tooltip-neutral-target-offset:3px;--spectrum-tooltip-neutral-tip-width:var(\n--spectrum-tooltip-neutral-tip-height,var(--spectrum-global-dimension-size-50)\n)}:host{-webkit-font-smoothing:antialiased;align-items:center;border-radius:var(\n--spectrum-tooltip-neutral-border-radius,var(--spectrum-alias-component-border-radius)\n);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(\n--spectrum-tooltip-neutral-text-size,var(--spectrum-global-dimension-font-size-75)\n);font-weight:var(\n--spectrum-tooltip-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);left:0;line-height:var(\n--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)\n);max-width:var(\n--spectrum-tooltip-neutral-max-width,var(--spectrum-global-dimension-size-2000)\n);min-height:var(\n--spectrum-tooltip-neutral-min-height,var(--spectrum-global-dimension-size-300)\n);padding:0 var(\n--spectrum-tooltip-neutral-padding-x,var(--spectrum-global-dimension-size-85)\n);position:relative;top:0;vertical-align:top;width:auto;word-break:break-word}:host{cursor:default;-webkit-user-select:none;user-select:none}p{margin:0}#tip{border-bottom:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-left:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-right:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-top-style:solid;border-top-width:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n);height:0;position:absolute;width:0}:host([placement*=left]) #tip,:host([placement*=right]) #tip{margin-top:calc(var(\n--spectrum-tooltip-neutral-tip-width,\nvar(--spectrum-global-dimension-size-100)\n)*-1);top:50%}:host([placement*=right]){margin-left:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=right]) #tip{right:100%;transform:rotate(90deg)}:host([placement*=left]){margin-right:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=left]) #tip{left:100%;transform:rotate(-90deg)}:host([placement*=top]){margin-bottom:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=top]) #tip{top:100%}:host([placement*=bottom]){margin-top:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=bottom]) #tip{bottom:100%;transform:rotate(-180deg)}:host([placement*=bottom]) #tip,:host([placement*=top]) #tip{left:50%;margin-left:calc(var(\n--spectrum-tooltip-neutral-tip-width,\nvar(--spectrum-global-dimension-size-100)\n)*-1)}:host([dir=ltr]) ::slotted([slot=icon]){margin-left:calc(var(\n--spectrum-tooltip-neutral-icon-margin-x,\nvar(--spectrum-global-dimension-size-85)\n) - var(\n--spectrum-tooltip-neutral-padding-x,\nvar(--spectrum-global-dimension-size-85)\n))}:host([dir=rtl]) ::slotted([slot=icon]){margin-right:calc(var(\n--spectrum-tooltip-neutral-icon-margin-x,\nvar(--spectrum-global-dimension-size-85)\n) - var(\n--spectrum-tooltip-neutral-padding-x,\nvar(--spectrum-global-dimension-size-85)\n))}:host([dir=ltr]) ::slotted([slot=icon]){margin-right:var(\n--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)\n)}:host([dir=rtl]) ::slotted([slot=icon]){margin-left:var(\n--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)\n)}::slotted([slot=icon]){align-self:flex-start;flex-shrink:0;height:var(\n--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)\n);margin-bottom:var(\n--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)\n);margin-top:var(\n--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)\n);width:var(\n--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)\n)}#label{line-height:var(\n--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)\n);margin-bottom:var(--spectrum-tooltip-neutral-text-margin-bottom);margin-top:var(\n--spectrum-tooltip-neutral-text-margin-top,var(--spectrum-global-dimension-static-size-50)\n)}:host{background-color:var(\n--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n);color:var(\n--spectrum-tooltip-neutral-text-color,var(--spectrum-global-color-static-white)\n)}#tip{border-top-color:var(\n--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n)}.spectrum-Tooltip--error,:host([variant=negative]){background-color:var(\n--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}.spectrum-Tooltip--error #tip,:host([variant=negative]) #tip{border-top-color:var(\n--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}.spectrum-Tooltip--help,:host([variant=info]){background-color:var(\n--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}.spectrum-Tooltip--help #tip,:host([variant=info]) #tip{border-top-color:var(\n--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}.spectrum-Tooltip--success,:host([variant=positive]){background-color:var(\n--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}.spectrum-Tooltip--success #tip,:host([variant=positive]) #tip{border-top-color:var(\n--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{--spectrum-overlay-animation-distance:var(
|
|
15
|
+
--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)
|
|
16
|
+
);opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host([placement*=bottom][open]){transform:translateY(var(--spectrum-overlay-animation-distance))}:host([placement*=top][open]){transform:translateY(calc(var(--spectrum-overlay-animation-distance)*-1))}:host([placement*=right][open]){transform:translateX(var(--spectrum-overlay-animation-distance))}:host([placement*=left][open]){transform:translateX(calc(var(--spectrum-overlay-animation-distance)*-1))}:host{--spectrum-tooltip-neutral-target-offset:3px;--spectrum-tooltip-neutral-tip-width:var(
|
|
17
|
+
--spectrum-tooltip-neutral-tip-height,var(--spectrum-global-dimension-size-50)
|
|
18
|
+
)}:host{-webkit-font-smoothing:antialiased;align-items:center;border-radius:var(
|
|
19
|
+
--spectrum-tooltip-neutral-border-radius,var(--spectrum-alias-component-border-radius)
|
|
20
|
+
);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(
|
|
21
|
+
--spectrum-tooltip-neutral-text-size,var(--spectrum-global-dimension-font-size-75)
|
|
22
|
+
);font-weight:var(
|
|
23
|
+
--spectrum-tooltip-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)
|
|
24
|
+
);left:0;line-height:var(
|
|
25
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
26
|
+
);max-width:var(
|
|
27
|
+
--spectrum-tooltip-neutral-max-width,var(--spectrum-global-dimension-size-2000)
|
|
28
|
+
);min-height:var(
|
|
29
|
+
--spectrum-tooltip-neutral-min-height,var(--spectrum-global-dimension-size-300)
|
|
30
|
+
);padding:0 var(
|
|
31
|
+
--spectrum-tooltip-neutral-padding-x,var(--spectrum-global-dimension-size-85)
|
|
32
|
+
);position:relative;top:0;vertical-align:top;width:auto;word-break:break-word}:host{cursor:default;-webkit-user-select:none;user-select:none}p{margin:0}#tip{border-bottom:var(
|
|
33
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
34
|
+
) solid transparent;border-left:var(
|
|
35
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
36
|
+
) solid transparent;border-right:var(
|
|
37
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
38
|
+
) solid transparent;border-top-style:solid;border-top-width:var(
|
|
39
|
+
--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)
|
|
40
|
+
);height:0;position:absolute;width:0}:host([placement*=left]) #tip,:host([placement*=right]) #tip{margin-top:calc(var(
|
|
41
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
42
|
+
var(--spectrum-global-dimension-size-100)
|
|
43
|
+
)*-1);top:50%}:host([placement*=right]){margin-left:var(
|
|
44
|
+
--spectrum-tooltip-neutral-target-offset
|
|
45
|
+
)}:host([placement*=right]) #tip{right:100%;transform:rotate(90deg)}:host([placement*=left]){margin-right:var(
|
|
46
|
+
--spectrum-tooltip-neutral-target-offset
|
|
47
|
+
)}:host([placement*=left]) #tip{left:100%;transform:rotate(-90deg)}:host([placement*=top]){margin-bottom:var(
|
|
48
|
+
--spectrum-tooltip-neutral-target-offset
|
|
49
|
+
)}:host([placement*=top]) #tip{top:100%}:host([placement*=bottom]){margin-top:var(
|
|
50
|
+
--spectrum-tooltip-neutral-target-offset
|
|
51
|
+
)}:host([placement*=bottom]) #tip{bottom:100%;transform:rotate(-180deg)}:host([placement*=bottom]) #tip,:host([placement*=top]) #tip{left:50%;margin-left:calc(var(
|
|
52
|
+
--spectrum-tooltip-neutral-tip-width,
|
|
53
|
+
var(--spectrum-global-dimension-size-100)
|
|
54
|
+
)*-1)}:host([dir=ltr]) ::slotted([slot=icon]){margin-left:calc(var(
|
|
55
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
56
|
+
var(--spectrum-global-dimension-size-85)
|
|
57
|
+
) - var(
|
|
58
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
59
|
+
var(--spectrum-global-dimension-size-85)
|
|
60
|
+
))}:host([dir=rtl]) ::slotted([slot=icon]){margin-right:calc(var(
|
|
61
|
+
--spectrum-tooltip-neutral-icon-margin-x,
|
|
62
|
+
var(--spectrum-global-dimension-size-85)
|
|
63
|
+
) - var(
|
|
64
|
+
--spectrum-tooltip-neutral-padding-x,
|
|
65
|
+
var(--spectrum-global-dimension-size-85)
|
|
66
|
+
))}:host([dir=ltr]) ::slotted([slot=icon]){margin-right:var(
|
|
67
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
68
|
+
)}:host([dir=rtl]) ::slotted([slot=icon]){margin-left:var(
|
|
69
|
+
--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)
|
|
70
|
+
)}::slotted([slot=icon]){align-self:flex-start;flex-shrink:0;height:var(
|
|
71
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
72
|
+
);margin-bottom:var(
|
|
73
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
74
|
+
);margin-top:var(
|
|
75
|
+
--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)
|
|
76
|
+
);width:var(
|
|
77
|
+
--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)
|
|
78
|
+
)}#label{line-height:var(
|
|
79
|
+
--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)
|
|
80
|
+
);margin-bottom:var(--spectrum-tooltip-neutral-text-margin-bottom);margin-top:var(
|
|
81
|
+
--spectrum-tooltip-neutral-text-margin-top,var(--spectrum-global-dimension-static-size-50)
|
|
82
|
+
)}:host{background-color:var(
|
|
83
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
84
|
+
);color:var(
|
|
85
|
+
--spectrum-tooltip-neutral-text-color,var(--spectrum-global-color-static-white)
|
|
86
|
+
)}#tip{border-top-color:var(
|
|
87
|
+
--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)
|
|
88
|
+
)}.spectrum-Tooltip--error,:host([variant=negative]){background-color:var(
|
|
89
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
90
|
+
)}.spectrum-Tooltip--error #tip,:host([variant=negative]) #tip{border-top-color:var(
|
|
91
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)
|
|
92
|
+
)}.spectrum-Tooltip--help,:host([variant=info]){background-color:var(
|
|
93
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
94
|
+
)}.spectrum-Tooltip--help #tip,:host([variant=info]) #tip{border-top-color:var(
|
|
95
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)
|
|
96
|
+
)}.spectrum-Tooltip--success,:host([variant=positive]){background-color:var(
|
|
97
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
98
|
+
)}.spectrum-Tooltip--success #tip,:host([variant=positive]) #tip{border-top-color:var(
|
|
99
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)
|
|
100
|
+
)}#tip{border:none}:host([placement*=bottom]) #tip,:host([placement*=left]) #tip,:host([placement*=right]) #tip{transform:none}#tip:after{border:var(
|
|
101
|
+
--spectrum-tooltip-tip-height,var(--spectrum-global-dimension-size-50)
|
|
102
|
+
) solid transparent;content:"";height:0;left:0;position:absolute;width:0}:host([placement*=bottom]) #tip:after{bottom:100%;transform:scaleY(-1)}:host([placement*=left]) #tip:after{left:100%;transform:rotate(-90deg)}:host([placement*=right]) #tip:after{left:auto;right:100%;transform:rotate(90deg)}:host([placement]) #tip:after{border-top-color:var(
|
|
103
|
+
--spectrum-tooltip-background-color,var(--spectrum-global-color-static-gray-700)
|
|
104
|
+
)}:host([variant=negative]) #tip:after{border-top-color:var(
|
|
105
|
+
--spectrum-tooltip-negative-background-color,var(--spectrum-global-color-static-red-700)
|
|
106
|
+
)}:host([variant=info]) #tip:after{border-top-color:var(
|
|
107
|
+
--spectrum-tooltip-info-background-color,var(--spectrum-global-color-static-blue-700)
|
|
108
|
+
)}:host([variant=positive]) #tip:after{border-top-color:var(
|
|
109
|
+
--spectrum-tooltip-positive-background-color,var(--spectrum-global-color-static-green-700)
|
|
110
|
+
)}
|
|
111
|
+
`;
|
|
112
|
+
export default styles;
|
|
113
|
+
//# sourceMappingURL=tooltip.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.css.js","sourceRoot":"","sources":["tooltip.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGjB,CAAC;AACF,eAAe,MAAM,CAAC","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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-overlay-animation-distance:var(\n--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)\n);opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]){opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host([placement*=bottom][open]){transform:translateY(var(--spectrum-overlay-animation-distance))}:host([placement*=top][open]){transform:translateY(calc(var(--spectrum-overlay-animation-distance)*-1))}:host([placement*=right][open]){transform:translateX(var(--spectrum-overlay-animation-distance))}:host([placement*=left][open]){transform:translateX(calc(var(--spectrum-overlay-animation-distance)*-1))}:host{--spectrum-tooltip-neutral-target-offset:3px;--spectrum-tooltip-neutral-tip-width:var(\n--spectrum-tooltip-neutral-tip-height,var(--spectrum-global-dimension-size-50)\n)}:host{-webkit-font-smoothing:antialiased;align-items:center;border-radius:var(\n--spectrum-tooltip-neutral-border-radius,var(--spectrum-alias-component-border-radius)\n);box-sizing:border-box;display:inline-flex;flex-direction:row;font-size:var(\n--spectrum-tooltip-neutral-text-size,var(--spectrum-global-dimension-font-size-75)\n);font-weight:var(\n--spectrum-tooltip-neutral-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);left:0;line-height:var(\n--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)\n);max-width:var(\n--spectrum-tooltip-neutral-max-width,var(--spectrum-global-dimension-size-2000)\n);min-height:var(\n--spectrum-tooltip-neutral-min-height,var(--spectrum-global-dimension-size-300)\n);padding:0 var(\n--spectrum-tooltip-neutral-padding-x,var(--spectrum-global-dimension-size-85)\n);position:relative;top:0;vertical-align:top;width:auto;word-break:break-word}:host{cursor:default;-webkit-user-select:none;user-select:none}p{margin:0}#tip{border-bottom:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-left:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-right:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n) solid transparent;border-top-style:solid;border-top-width:var(\n--spectrum-tooltip-neutral-tip-width,var(--spectrum-global-dimension-size-100)\n);height:0;position:absolute;width:0}:host([placement*=left]) #tip,:host([placement*=right]) #tip{margin-top:calc(var(\n--spectrum-tooltip-neutral-tip-width,\nvar(--spectrum-global-dimension-size-100)\n)*-1);top:50%}:host([placement*=right]){margin-left:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=right]) #tip{right:100%;transform:rotate(90deg)}:host([placement*=left]){margin-right:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=left]) #tip{left:100%;transform:rotate(-90deg)}:host([placement*=top]){margin-bottom:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=top]) #tip{top:100%}:host([placement*=bottom]){margin-top:var(\n--spectrum-tooltip-neutral-target-offset\n)}:host([placement*=bottom]) #tip{bottom:100%;transform:rotate(-180deg)}:host([placement*=bottom]) #tip,:host([placement*=top]) #tip{left:50%;margin-left:calc(var(\n--spectrum-tooltip-neutral-tip-width,\nvar(--spectrum-global-dimension-size-100)\n)*-1)}:host([dir=ltr]) ::slotted([slot=icon]){margin-left:calc(var(\n--spectrum-tooltip-neutral-icon-margin-x,\nvar(--spectrum-global-dimension-size-85)\n) - var(\n--spectrum-tooltip-neutral-padding-x,\nvar(--spectrum-global-dimension-size-85)\n))}:host([dir=rtl]) ::slotted([slot=icon]){margin-right:calc(var(\n--spectrum-tooltip-neutral-icon-margin-x,\nvar(--spectrum-global-dimension-size-85)\n) - var(\n--spectrum-tooltip-neutral-padding-x,\nvar(--spectrum-global-dimension-size-85)\n))}:host([dir=ltr]) ::slotted([slot=icon]){margin-right:var(\n--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)\n)}:host([dir=rtl]) ::slotted([slot=icon]){margin-left:var(\n--spectrum-tooltip-neutral-icon-margin-x,var(--spectrum-global-dimension-size-85)\n)}::slotted([slot=icon]){align-self:flex-start;flex-shrink:0;height:var(\n--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)\n);margin-bottom:var(\n--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)\n);margin-top:var(\n--spectrum-tooltip-neutral-icon-margin-y,var(--spectrum-global-dimension-size-50)\n);width:var(\n--spectrum-tooltip-neutral-icon-size,var(--spectrum-global-dimension-size-200)\n)}#label{line-height:var(\n--spectrum-tooltip-neutral-text-line-height,var(--spectrum-alias-component-text-line-height)\n);margin-bottom:var(--spectrum-tooltip-neutral-text-margin-bottom);margin-top:var(\n--spectrum-tooltip-neutral-text-margin-top,var(--spectrum-global-dimension-static-size-50)\n)}:host{background-color:var(\n--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n);color:var(\n--spectrum-tooltip-neutral-text-color,var(--spectrum-global-color-static-white)\n)}#tip{border-top-color:var(\n--spectrum-tooltip-neutral-background-color,var(--spectrum-semantic-neutral-background-color-default)\n)}.spectrum-Tooltip--error,:host([variant=negative]){background-color:var(\n--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}.spectrum-Tooltip--error #tip,:host([variant=negative]) #tip{border-top-color:var(\n--spectrum-tooltip-negative-background-color,var(--spectrum-semantic-negative-background-color)\n)}.spectrum-Tooltip--help,:host([variant=info]){background-color:var(\n--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}.spectrum-Tooltip--help #tip,:host([variant=info]) #tip{border-top-color:var(\n--spectrum-tooltip-info-background-color,var(--spectrum-semantic-informative-background-color)\n)}.spectrum-Tooltip--success,:host([variant=positive]){background-color:var(\n--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}.spectrum-Tooltip--success #tip,:host([variant=positive]) #tip{border-top-color:var(\n--spectrum-tooltip-positive-background-color,var(--spectrum-semantic-positive-background-color)\n)}#tip{border:none}:host([placement*=bottom]) #tip,:host([placement*=left]) #tip,:host([placement*=right]) #tip{transform:none}#tip:after{border:var(\n--spectrum-tooltip-tip-height,var(--spectrum-global-dimension-size-50)\n) solid transparent;content:\"\";height:0;left:0;position:absolute;width:0}:host([placement*=bottom]) #tip:after{bottom:100%;transform:scaleY(-1)}:host([placement*=left]) #tip:after{left:100%;transform:rotate(-90deg)}:host([placement*=right]) #tip:after{left:auto;right:100%;transform:rotate(90deg)}:host([placement]) #tip:after{border-top-color:var(\n--spectrum-tooltip-background-color,var(--spectrum-global-color-static-gray-700)\n)}:host([variant=negative]) #tip:after{border-top-color:var(\n--spectrum-tooltip-negative-background-color,var(--spectrum-global-color-static-red-700)\n)}:host([variant=info]) #tip:after{border-top-color:var(\n--spectrum-tooltip-info-background-color,var(--spectrum-global-color-static-blue-700)\n)}:host([variant=positive]) #tip:after{border-top-color:var(\n--spectrum-tooltip-positive-background-color,var(--spectrum-global-color-static-green-700)\n)}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import '../sp-tooltip.js';
|
|
13
|
+
import { html } from '@spectrum-web-components/base';
|
|
14
|
+
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
|
|
15
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';
|
|
16
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js';
|
|
17
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-info.js';
|
|
18
|
+
import '@spectrum-web-components/button/sp-button.js';
|
|
19
|
+
import '@spectrum-web-components/action-button/sp-action-button.js';
|
|
20
|
+
import '@spectrum-web-components/overlay/overlay-trigger.js';
|
|
21
|
+
const iconOptions = {
|
|
22
|
+
'': () => html ``,
|
|
23
|
+
negative: () => html `
|
|
24
|
+
<sp-icon-alert slot="icon"></sp-icon-alert>
|
|
25
|
+
`,
|
|
26
|
+
positive: () => html `
|
|
27
|
+
<sp-icon-checkmark slot="icon"></sp-icon-checkmark>
|
|
28
|
+
`,
|
|
29
|
+
info: () => html `
|
|
30
|
+
<sp-icon-info slot="icon"></sp-icon-info>
|
|
31
|
+
`,
|
|
32
|
+
};
|
|
33
|
+
export default {
|
|
34
|
+
component: 'sp-tooltip',
|
|
35
|
+
title: 'Tooltip',
|
|
36
|
+
};
|
|
37
|
+
export const Default = ({ open, placement, variant, text, }) => {
|
|
38
|
+
return html `
|
|
39
|
+
<sp-tooltip ?open=${open} placement=${placement} variant=${variant}>
|
|
40
|
+
${text}
|
|
41
|
+
</sp-tooltip>
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
44
|
+
Default.args = {
|
|
45
|
+
open: true,
|
|
46
|
+
placement: 'top',
|
|
47
|
+
variant: '',
|
|
48
|
+
text: 'Tooltip',
|
|
49
|
+
};
|
|
50
|
+
Default.argTypes = {
|
|
51
|
+
open: {
|
|
52
|
+
name: 'open',
|
|
53
|
+
type: { name: 'boolean', required: false },
|
|
54
|
+
description: 'Whether the tooltip is open.',
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: 'boolean' },
|
|
57
|
+
defaultValue: { summary: false },
|
|
58
|
+
},
|
|
59
|
+
control: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
placement: {
|
|
64
|
+
name: 'placement',
|
|
65
|
+
type: { name: 'string', required: false },
|
|
66
|
+
description: 'The placement of the tooltip in relation to its parent',
|
|
67
|
+
table: {
|
|
68
|
+
type: { summary: 'string' },
|
|
69
|
+
defaultValue: { summary: 'top' },
|
|
70
|
+
},
|
|
71
|
+
control: {
|
|
72
|
+
type: 'inline-radio',
|
|
73
|
+
options: [
|
|
74
|
+
'auto',
|
|
75
|
+
'auto-start',
|
|
76
|
+
'auto-end',
|
|
77
|
+
'top',
|
|
78
|
+
'bottom',
|
|
79
|
+
'right',
|
|
80
|
+
'left',
|
|
81
|
+
'top-start',
|
|
82
|
+
'top-end',
|
|
83
|
+
'bottom-start',
|
|
84
|
+
'bottom-end',
|
|
85
|
+
'right-start',
|
|
86
|
+
'right-end',
|
|
87
|
+
'left-start',
|
|
88
|
+
'left-end',
|
|
89
|
+
'none',
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
text: {
|
|
94
|
+
name: 'text',
|
|
95
|
+
type: { name: 'string', required: false },
|
|
96
|
+
table: {
|
|
97
|
+
type: { summary: 'string' },
|
|
98
|
+
defaultValue: { summary: '' },
|
|
99
|
+
},
|
|
100
|
+
control: 'text',
|
|
101
|
+
},
|
|
102
|
+
variant: {
|
|
103
|
+
name: 'variant',
|
|
104
|
+
type: { name: 'string', required: false },
|
|
105
|
+
description: 'The style of the tooltip.',
|
|
106
|
+
table: {
|
|
107
|
+
type: { summary: 'string' },
|
|
108
|
+
defaultValue: { summary: '' },
|
|
109
|
+
},
|
|
110
|
+
control: {
|
|
111
|
+
type: 'inline-radio',
|
|
112
|
+
options: ['info', 'positive', 'negative', ''],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
export const wIcon = ({ open, placement, variant, text, }) => {
|
|
117
|
+
return html `
|
|
118
|
+
<sp-tooltip ?open=${open} placement=${placement} variant=${variant}>
|
|
119
|
+
${!!variant ? iconOptions[variant]() : html ``} ${text}
|
|
120
|
+
</sp-tooltip>
|
|
121
|
+
`;
|
|
122
|
+
};
|
|
123
|
+
wIcon.args = {
|
|
124
|
+
open: true,
|
|
125
|
+
placement: 'top',
|
|
126
|
+
text: 'Tooltip',
|
|
127
|
+
variant: 'negative',
|
|
128
|
+
};
|
|
129
|
+
wIcon.argTypes = {
|
|
130
|
+
open: {
|
|
131
|
+
name: 'open',
|
|
132
|
+
type: { name: 'boolean', required: false },
|
|
133
|
+
description: 'Whether the tooltip is open.',
|
|
134
|
+
table: {
|
|
135
|
+
type: { summary: 'boolean' },
|
|
136
|
+
defaultValue: { summary: false },
|
|
137
|
+
},
|
|
138
|
+
control: {
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
placement: {
|
|
143
|
+
name: 'placement',
|
|
144
|
+
type: { name: 'string', required: false },
|
|
145
|
+
description: 'The placement of the tooltip in relation to its parent',
|
|
146
|
+
table: {
|
|
147
|
+
type: { summary: 'string' },
|
|
148
|
+
defaultValue: { summary: 'top' },
|
|
149
|
+
},
|
|
150
|
+
control: {
|
|
151
|
+
type: 'inline-radio',
|
|
152
|
+
options: [
|
|
153
|
+
'auto',
|
|
154
|
+
'auto-start',
|
|
155
|
+
'auto-end',
|
|
156
|
+
'top',
|
|
157
|
+
'bottom',
|
|
158
|
+
'right',
|
|
159
|
+
'left',
|
|
160
|
+
'top-start',
|
|
161
|
+
'top-end',
|
|
162
|
+
'bottom-start',
|
|
163
|
+
'bottom-end',
|
|
164
|
+
'right-start',
|
|
165
|
+
'right-end',
|
|
166
|
+
'left-start',
|
|
167
|
+
'left-end',
|
|
168
|
+
'none',
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
text: {
|
|
173
|
+
name: 'text',
|
|
174
|
+
type: { name: 'string', required: false },
|
|
175
|
+
table: {
|
|
176
|
+
type: { summary: 'string' },
|
|
177
|
+
defaultValue: { summary: '' },
|
|
178
|
+
},
|
|
179
|
+
control: 'text',
|
|
180
|
+
},
|
|
181
|
+
variant: {
|
|
182
|
+
name: 'variant',
|
|
183
|
+
type: { name: 'string', required: false },
|
|
184
|
+
table: {
|
|
185
|
+
type: { summary: 'string' },
|
|
186
|
+
defaultValue: { summary: '' },
|
|
187
|
+
},
|
|
188
|
+
control: {
|
|
189
|
+
type: 'inline-radio',
|
|
190
|
+
options: ['info', 'positive', 'negative', ''],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
const overlayStyles = html `
|
|
195
|
+
<style>
|
|
196
|
+
html,
|
|
197
|
+
body,
|
|
198
|
+
#root,
|
|
199
|
+
#root-inner,
|
|
200
|
+
sp-story-decorator {
|
|
201
|
+
height: 100%;
|
|
202
|
+
margin: 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
sp-story-decorator > div {
|
|
206
|
+
display: contents;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
sp-story-decorator::part(container) {
|
|
210
|
+
display: flex;
|
|
211
|
+
flex-direction: column;
|
|
212
|
+
width: 100%;
|
|
213
|
+
height: 100%;
|
|
214
|
+
align-items: center;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
overlay-trigger {
|
|
219
|
+
flex: none;
|
|
220
|
+
margin: 24px 0;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.self-managed:nth-child(3) {
|
|
224
|
+
margin-left: 50px;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
227
|
+
`;
|
|
228
|
+
const overlaid = (openPlacement) => {
|
|
229
|
+
return html `
|
|
230
|
+
${overlayStyles}
|
|
231
|
+
${[
|
|
232
|
+
['bottom', ''],
|
|
233
|
+
['left', 'negative'],
|
|
234
|
+
['right', 'positive'],
|
|
235
|
+
['top', 'info'],
|
|
236
|
+
].map(([placement, variant]) => {
|
|
237
|
+
return html `
|
|
238
|
+
<overlay-trigger
|
|
239
|
+
placement=${placement}
|
|
240
|
+
open=${ifDefined(openPlacement === placement ? 'hover' : undefined)}
|
|
241
|
+
>
|
|
242
|
+
<sp-button label="${placement} test" slot="trigger">
|
|
243
|
+
Hover for ${variant ? variant : 'tooltip'} on the
|
|
244
|
+
${placement}
|
|
245
|
+
</sp-button>
|
|
246
|
+
<sp-tooltip slot="hover-content" variant=${variant}>
|
|
247
|
+
${placement}
|
|
248
|
+
</sp-tooltip>
|
|
249
|
+
</overlay-trigger>
|
|
250
|
+
`;
|
|
251
|
+
})}
|
|
252
|
+
`;
|
|
253
|
+
};
|
|
254
|
+
export const overlaidTop = () => overlaid('top');
|
|
255
|
+
export const overlaidRight = () => overlaid('right');
|
|
256
|
+
export const overlaidBottom = () => overlaid('bottom');
|
|
257
|
+
export const overlaidLeft = () => overlaid('left');
|
|
258
|
+
export const selfManaged = ({ placement, offset, delayed, }) => html `
|
|
259
|
+
${overlayStyles}
|
|
260
|
+
<sp-action-button class="self-managed">
|
|
261
|
+
This is a button.
|
|
262
|
+
<sp-tooltip
|
|
263
|
+
self-managed
|
|
264
|
+
placement=${placement}
|
|
265
|
+
offset=${offset}
|
|
266
|
+
?delayed=${delayed}
|
|
267
|
+
open
|
|
268
|
+
>
|
|
269
|
+
This is a tooltip.
|
|
270
|
+
</sp-tooltip>
|
|
271
|
+
</sp-action-button>
|
|
272
|
+
`;
|
|
273
|
+
selfManaged.args = {
|
|
274
|
+
placement: 'top',
|
|
275
|
+
offset: 6,
|
|
276
|
+
delayed: false,
|
|
277
|
+
};
|
|
278
|
+
selfManaged.argTypes = {
|
|
279
|
+
delayed: {
|
|
280
|
+
name: 'delayed',
|
|
281
|
+
type: { name: 'boolean', required: false },
|
|
282
|
+
description: 'Whether to manage the tooltip with the warmup timer',
|
|
283
|
+
},
|
|
284
|
+
offset: {
|
|
285
|
+
name: 'offset',
|
|
286
|
+
type: { name: 'number', required: false },
|
|
287
|
+
description: 'The pixel distance from the parent element to place the tooltip',
|
|
288
|
+
},
|
|
289
|
+
placement: {
|
|
290
|
+
name: 'placement',
|
|
291
|
+
type: { name: 'string', required: false },
|
|
292
|
+
description: 'The placement of the tooltip in relation to its parent',
|
|
293
|
+
table: {
|
|
294
|
+
type: { summary: 'string' },
|
|
295
|
+
defaultValue: { summary: 'top' },
|
|
296
|
+
},
|
|
297
|
+
control: {
|
|
298
|
+
type: 'inline-radio',
|
|
299
|
+
options: [
|
|
300
|
+
'auto',
|
|
301
|
+
'auto-start',
|
|
302
|
+
'auto-end',
|
|
303
|
+
'top',
|
|
304
|
+
'bottom',
|
|
305
|
+
'right',
|
|
306
|
+
'left',
|
|
307
|
+
'top-start',
|
|
308
|
+
'top-end',
|
|
309
|
+
'bottom-start',
|
|
310
|
+
'bottom-end',
|
|
311
|
+
'right-start',
|
|
312
|
+
'right-end',
|
|
313
|
+
'left-start',
|
|
314
|
+
'left-end',
|
|
315
|
+
'none',
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
//# sourceMappingURL=tooltip.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.stories.js","sourceRoot":"","sources":["tooltip.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,gEAAgE,CAAC;AACxE,OAAO,oEAAoE,CAAC;AAC5E,OAAO,+DAA+D,CAAC;AACvE,OAAO,8CAA8C,CAAC;AACtD,OAAO,4DAA4D,CAAC;AAEpE,OAAO,qDAAqD,CAAC;AAE7D,MAAM,WAAW,GAYb;IACA,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,EAAE;IAChB,QAAQ,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;SAEH;IACL,QAAQ,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;SAEH;IACL,IAAI,EAAE,GAAG,EAAE,CACP,IAAI,CAAA;;SAEH;CACR,CAAC;AAEF,eAAe;IACX,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,SAAS;CACnB,CAAC;AAWF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EACpB,IAAI,EACJ,SAAS,EACT,OAAO,EAC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IAAI,CAAA;MAChC,aAAa;;;;;wBAKK,SAAS;qBACZ,MAAM;uBACJ,OAAO;;;;;;CAM7B,CAAC;AACF,WAAW,CAAC,IAAI,GAAG;IACf,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,KAAK;CACjB,CAAC;AACF,WAAW,CAAC,QAAQ,GAAG;IACnB,OAAO,EAAE;QACL,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC1C,WAAW,EAAE,qDAAqD;KACrE;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QACzC,WAAW,EACP,iEAAiE;KACxE;IACD,SAAS,EAAE;QACP,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;QACzC,WAAW,EAAE,wDAAwD;QACrE,KAAK,EAAE;YACH,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;YAC3B,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SACnC;QACD,OAAO,EAAE;YACL,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE;gBACL,MAAM;gBACN,YAAY;gBACZ,UAAU;gBACV,KAAK;gBACL,QAAQ;gBACR,OAAO;gBACP,MAAM;gBACN,WAAW;gBACX,SAAS;gBACT,cAAc;gBACd,YAAY;gBACZ,aAAa;gBACb,WAAW;gBACX,YAAY;gBACZ,UAAU;gBACV,MAAM;aACT;SACJ;KACJ;CACJ,CAAC","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 '../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/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/overlay-trigger.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 }\n\n overlay-trigger {\n flex: none;\n margin: 24px 0;\n }\n\n .self-managed:nth-child(3) {\n margin-left: 50px;\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 ] as [Placement, string][]\n ).map(([placement, variant]) => {\n return html`\n <overlay-trigger\n placement=${placement}\n open=${ifDefined(\n openPlacement === placement ? 'hover' : undefined\n )}\n >\n <sp-button label=\"${placement} test\" slot=\"trigger\">\n Hover for ${variant ? variant : 'tooltip'} on the\n ${placement}\n </sp-button>\n <sp-tooltip slot=\"hover-content\" variant=${variant}>\n ${placement}\n </sp-tooltip>\n </overlay-trigger>\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');\n\nexport const selfManaged = ({\n placement,\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\n >\n This is a tooltip.\n </sp-tooltip>\n </sp-action-button>\n`;\nselfManaged.args = {\n placement: 'top',\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 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"]}
|