@spectrum-web-components/tooltip 0.11.0 → 0.11.2
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.dev.js +1 -0
- package/sp-tooltip.dev.js.map +1 -1
- package/sp-tooltip.js +1 -1
- package/sp-tooltip.js.map +2 -2
- package/src/Tooltip.dev.js +12 -3
- package/src/Tooltip.dev.js.map +1 -1
- package/src/Tooltip.js +2 -2
- package/src/Tooltip.js.map +2 -2
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-tooltip.css.dev.js +2 -7
- package/src/spectrum-tooltip.css.dev.js.map +2 -2
- package/src/spectrum-tooltip.css.js +2 -8
- package/src/spectrum-tooltip.css.js.map +3 -3
- package/src/tooltip.css.dev.js +4 -9
- package/src/tooltip.css.dev.js.map +2 -2
- package/src/tooltip.css.js +4 -10
- package/src/tooltip.css.js.map +3 -3
- package/stories/tooltip.stories.js +274 -27
- package/stories/tooltip.stories.js.map +1 -1
- package/test/benchmark/test-basic.js +5 -1
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/tooltip.test-vrt.js +4 -1
- package/test/tooltip.test-vrt.js.map +1 -1
- package/test/tooltip.test.js +126 -8
- package/test/tooltip.test.js.map +1 -1
|
@@ -1,18 +1,197 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/tooltip/sp-tooltip.js";
|
|
3
|
+
import { html } from "@spectrum-web-components/base";
|
|
4
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
5
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";
|
|
6
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js";
|
|
7
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-info.js";
|
|
8
|
+
import "@spectrum-web-components/button/sp-button.js";
|
|
9
|
+
import "@spectrum-web-components/action-button/sp-action-button.js";
|
|
10
|
+
import "@spectrum-web-components/overlay/overlay-trigger.js";
|
|
11
|
+
const iconOptions = {
|
|
12
|
+
"": () => html``,
|
|
13
|
+
negative: () => html`
|
|
2
14
|
<sp-icon-alert slot="icon"></sp-icon-alert>
|
|
3
|
-
`,
|
|
15
|
+
`,
|
|
16
|
+
positive: () => html`
|
|
4
17
|
<sp-icon-checkmark slot="icon"></sp-icon-checkmark>
|
|
5
|
-
`,
|
|
18
|
+
`,
|
|
19
|
+
info: () => html`
|
|
6
20
|
<sp-icon-info slot="icon"></sp-icon-info>
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
`
|
|
22
|
+
};
|
|
23
|
+
export default {
|
|
24
|
+
component: "sp-tooltip",
|
|
25
|
+
title: "Tooltip"
|
|
26
|
+
};
|
|
27
|
+
export const Default = ({
|
|
28
|
+
open,
|
|
29
|
+
placement,
|
|
30
|
+
variant,
|
|
31
|
+
text
|
|
32
|
+
}) => {
|
|
33
|
+
return html`
|
|
34
|
+
<sp-tooltip ?open=${open} placement=${placement} variant=${variant}>
|
|
35
|
+
${text}
|
|
10
36
|
</sp-tooltip>
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
`;
|
|
38
|
+
};
|
|
39
|
+
Default.args = {
|
|
40
|
+
open: true,
|
|
41
|
+
placement: "top",
|
|
42
|
+
variant: "",
|
|
43
|
+
text: "Tooltip"
|
|
44
|
+
};
|
|
45
|
+
Default.argTypes = {
|
|
46
|
+
open: {
|
|
47
|
+
name: "open",
|
|
48
|
+
type: { name: "boolean", required: false },
|
|
49
|
+
description: "Whether the tooltip is open.",
|
|
50
|
+
table: {
|
|
51
|
+
type: { summary: "boolean" },
|
|
52
|
+
defaultValue: { summary: false }
|
|
53
|
+
},
|
|
54
|
+
control: {
|
|
55
|
+
type: "boolean"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
placement: {
|
|
59
|
+
name: "placement",
|
|
60
|
+
type: { name: "string", required: false },
|
|
61
|
+
description: "The placement of the tooltip in relation to its parent",
|
|
62
|
+
table: {
|
|
63
|
+
type: { summary: "string" },
|
|
64
|
+
defaultValue: { summary: "top" }
|
|
65
|
+
},
|
|
66
|
+
control: {
|
|
67
|
+
type: "inline-radio",
|
|
68
|
+
options: [
|
|
69
|
+
"auto",
|
|
70
|
+
"auto-start",
|
|
71
|
+
"auto-end",
|
|
72
|
+
"top",
|
|
73
|
+
"bottom",
|
|
74
|
+
"right",
|
|
75
|
+
"left",
|
|
76
|
+
"top-start",
|
|
77
|
+
"top-end",
|
|
78
|
+
"bottom-start",
|
|
79
|
+
"bottom-end",
|
|
80
|
+
"right-start",
|
|
81
|
+
"right-end",
|
|
82
|
+
"left-start",
|
|
83
|
+
"left-end",
|
|
84
|
+
"none"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
text: {
|
|
89
|
+
name: "text",
|
|
90
|
+
type: { name: "string", required: false },
|
|
91
|
+
table: {
|
|
92
|
+
type: { summary: "string" },
|
|
93
|
+
defaultValue: { summary: "" }
|
|
94
|
+
},
|
|
95
|
+
control: "text"
|
|
96
|
+
},
|
|
97
|
+
variant: {
|
|
98
|
+
name: "variant",
|
|
99
|
+
type: { name: "string", required: false },
|
|
100
|
+
description: "The style of the tooltip.",
|
|
101
|
+
table: {
|
|
102
|
+
type: { summary: "string" },
|
|
103
|
+
defaultValue: { summary: "" }
|
|
104
|
+
},
|
|
105
|
+
control: {
|
|
106
|
+
type: "inline-radio",
|
|
107
|
+
options: ["info", "positive", "negative", ""]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export const wIcon = ({
|
|
112
|
+
open,
|
|
113
|
+
placement,
|
|
114
|
+
variant,
|
|
115
|
+
text
|
|
116
|
+
}) => {
|
|
117
|
+
return html`
|
|
118
|
+
<sp-tooltip ?open=${open} placement=${placement} variant=${variant}>
|
|
119
|
+
${!!variant ? iconOptions[variant]() : html``} ${text}
|
|
14
120
|
</sp-tooltip>
|
|
15
|
-
`;
|
|
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`
|
|
16
195
|
<style>
|
|
17
196
|
html,
|
|
18
197
|
body,
|
|
@@ -45,35 +224,103 @@ import"@spectrum-web-components/tooltip/sp-tooltip.js";import{html as o}from"@sp
|
|
|
45
224
|
margin-left: 50px;
|
|
46
225
|
}
|
|
47
226
|
</style>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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`
|
|
51
238
|
<overlay-trigger
|
|
52
|
-
placement=${
|
|
53
|
-
open=${
|
|
239
|
+
placement=${placement}
|
|
240
|
+
open=${ifDefined(
|
|
241
|
+
openPlacement === placement ? "hover" : void 0
|
|
242
|
+
)}
|
|
54
243
|
>
|
|
55
|
-
<sp-button label="${
|
|
56
|
-
Hover for ${
|
|
57
|
-
${
|
|
244
|
+
<sp-button label="${placement} test" slot="trigger">
|
|
245
|
+
Hover for ${variant ? variant : "tooltip"} on the
|
|
246
|
+
${placement}
|
|
58
247
|
</sp-button>
|
|
59
|
-
<sp-tooltip slot="hover-content" variant=${
|
|
60
|
-
${
|
|
248
|
+
<sp-tooltip slot="hover-content" variant=${variant}>
|
|
249
|
+
${placement}
|
|
61
250
|
</sp-tooltip>
|
|
62
251
|
</overlay-trigger>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
252
|
+
`;
|
|
253
|
+
})}
|
|
254
|
+
`;
|
|
255
|
+
};
|
|
256
|
+
export const overlaidTop = () => overlaid("top");
|
|
257
|
+
export const overlaidRight = () => overlaid("right");
|
|
258
|
+
export const overlaidBottom = () => overlaid("bottom");
|
|
259
|
+
export const overlaidLeft = () => overlaid("left");
|
|
260
|
+
export const selfManaged = ({
|
|
261
|
+
placement,
|
|
262
|
+
offset,
|
|
263
|
+
delayed
|
|
264
|
+
}) => html`
|
|
265
|
+
${overlayStyles}
|
|
66
266
|
<sp-action-button class="self-managed">
|
|
67
267
|
This is a button.
|
|
68
268
|
<sp-tooltip
|
|
69
269
|
self-managed
|
|
70
|
-
placement=${
|
|
71
|
-
offset=${
|
|
72
|
-
?delayed=${
|
|
270
|
+
placement=${placement}
|
|
271
|
+
offset=${offset}
|
|
272
|
+
?delayed=${delayed}
|
|
73
273
|
open
|
|
74
274
|
>
|
|
75
275
|
This is a tooltip.
|
|
76
276
|
</sp-tooltip>
|
|
77
277
|
</sp-action-button>
|
|
78
|
-
`;
|
|
278
|
+
`;
|
|
279
|
+
selfManaged.args = {
|
|
280
|
+
placement: "top",
|
|
281
|
+
offset: 6,
|
|
282
|
+
delayed: false
|
|
283
|
+
};
|
|
284
|
+
selfManaged.argTypes = {
|
|
285
|
+
delayed: {
|
|
286
|
+
name: "delayed",
|
|
287
|
+
type: { name: "boolean", required: false },
|
|
288
|
+
description: "Whether to manage the tooltip with the warmup timer"
|
|
289
|
+
},
|
|
290
|
+
offset: {
|
|
291
|
+
name: "offset",
|
|
292
|
+
type: { name: "number", required: false },
|
|
293
|
+
description: "The pixel distance from the parent element to place the tooltip"
|
|
294
|
+
},
|
|
295
|
+
placement: {
|
|
296
|
+
name: "placement",
|
|
297
|
+
type: { name: "string", required: false },
|
|
298
|
+
description: "The placement of the tooltip in relation to its parent",
|
|
299
|
+
table: {
|
|
300
|
+
type: { summary: "string" },
|
|
301
|
+
defaultValue: { summary: "top" }
|
|
302
|
+
},
|
|
303
|
+
control: {
|
|
304
|
+
type: "inline-radio",
|
|
305
|
+
options: [
|
|
306
|
+
"auto",
|
|
307
|
+
"auto-start",
|
|
308
|
+
"auto-end",
|
|
309
|
+
"top",
|
|
310
|
+
"bottom",
|
|
311
|
+
"right",
|
|
312
|
+
"left",
|
|
313
|
+
"top-start",
|
|
314
|
+
"top-end",
|
|
315
|
+
"bottom-start",
|
|
316
|
+
"bottom-end",
|
|
317
|
+
"right-start",
|
|
318
|
+
"right-end",
|
|
319
|
+
"left-start",
|
|
320
|
+
"left-end",
|
|
321
|
+
"none"
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
79
326
|
//# sourceMappingURL=tooltip.stories.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.stories.ts"],
|
|
4
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/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"],
|
|
5
|
-
"mappings": "AAWA,
|
|
5
|
+
"mappings": ";AAWA,OAAO;AACP,SAAS,YAA4B;AACrC,SAAS,iBAAiB;AAC1B,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,kBAAkB,qBAAqB;AAAA,cACrD;AAAA;AAAA;AAGd;AACA,QAAQ,OAAO;AAAA,EACX,MAAM;AAAA,EACN,WAAW;AAAA,EACX,SAAS;AAAA,EACT,MAAM;AACV;AACA,QAAQ,WAAW;AAAA,EACf,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,WAAW;AAAA,IACP,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,SAAS;AAAA,MAC1B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IAC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AAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,SAAS;AAAA,MAC1B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,QACL;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,QACA;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/tooltip/sp-tooltip.js";
|
|
3
|
+
import { html } from "lit";
|
|
4
|
+
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
5
|
+
measureFixtureCreation(html`
|
|
2
6
|
<sp-tooltip open>Tip me!</sp-tooltip>
|
|
3
7
|
`);
|
|
4
8
|
//# sourceMappingURL=test-basic.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["test-basic.ts"],
|
|
4
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 { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-tooltip open>Tip me!</sp-tooltip>\n`);\n"],
|
|
5
|
-
"mappings": "AAYA,
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/tooltip.test-vrt.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import * as stories from "../stories/tooltip.stories.js";
|
|
3
|
+
import { regressVisuals } from "../../../test/visual/test.js";
|
|
4
|
+
regressVisuals("TooltipStories", stories);
|
|
2
5
|
//# sourceMappingURL=tooltip.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.test-vrt.ts"],
|
|
4
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 * as stories from '../stories/tooltip.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('TooltipStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA,
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,kBAAkB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/tooltip.test.js
CHANGED
|
@@ -1,22 +1,140 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/tooltip/sp-tooltip.js";
|
|
3
|
+
import {
|
|
4
|
+
elementUpdated,
|
|
5
|
+
expect,
|
|
6
|
+
fixture,
|
|
7
|
+
html,
|
|
8
|
+
oneEvent
|
|
9
|
+
} from "@open-wc/testing";
|
|
10
|
+
import "@spectrum-web-components/button/sp-button.js";
|
|
11
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
12
|
+
describe("Tooltip", () => {
|
|
13
|
+
testForLitDevWarnings(
|
|
14
|
+
async () => await fixture(
|
|
15
|
+
html`
|
|
2
16
|
<sp-tooltip>Help text.</sp-tooltip>
|
|
3
|
-
`
|
|
17
|
+
`
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
it("loads", async () => {
|
|
21
|
+
const el = await fixture(
|
|
22
|
+
html`
|
|
4
23
|
<sp-tooltip>Help text.</sp-tooltip>
|
|
5
|
-
`
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
await elementUpdated(el);
|
|
27
|
+
await expect(el).to.be.accessible();
|
|
28
|
+
});
|
|
29
|
+
it("self manages", async () => {
|
|
30
|
+
const button = await fixture(
|
|
31
|
+
html`
|
|
6
32
|
<sp-button>
|
|
7
33
|
This is a button.
|
|
8
34
|
<sp-tooltip self-managed>Help text.</sp-tooltip>
|
|
9
35
|
</sp-button>
|
|
10
|
-
`
|
|
36
|
+
`
|
|
37
|
+
);
|
|
38
|
+
const el = button.querySelector("sp-tooltip");
|
|
39
|
+
await elementUpdated(el);
|
|
40
|
+
await expect(button).to.be.accessible();
|
|
41
|
+
const opened = oneEvent(button, "sp-opened");
|
|
42
|
+
button.focus();
|
|
43
|
+
await opened;
|
|
44
|
+
await elementUpdated(el);
|
|
45
|
+
expect(el.open).to.be.true;
|
|
46
|
+
await expect(button).to.be.accessible();
|
|
47
|
+
const closed = oneEvent(button, "sp-closed");
|
|
48
|
+
button.blur();
|
|
49
|
+
await closed;
|
|
50
|
+
await elementUpdated(el);
|
|
51
|
+
expect(el.open).to.be.false;
|
|
52
|
+
});
|
|
53
|
+
it("cleans up when self manages", async () => {
|
|
54
|
+
const button = await fixture(
|
|
55
|
+
html`
|
|
11
56
|
<sp-button>
|
|
12
57
|
This is a button.
|
|
13
58
|
<sp-tooltip self-managed>Help text.</sp-tooltip>
|
|
14
59
|
</sp-button>
|
|
15
|
-
`
|
|
60
|
+
`
|
|
61
|
+
);
|
|
62
|
+
const el = button.querySelector("sp-tooltip");
|
|
63
|
+
await elementUpdated(el);
|
|
64
|
+
const opened = oneEvent(button, "sp-opened");
|
|
65
|
+
button.focus();
|
|
66
|
+
await opened;
|
|
67
|
+
await elementUpdated(el);
|
|
68
|
+
expect(el.open).to.be.true;
|
|
69
|
+
let activeOverlay = document.querySelector("active-overlay");
|
|
70
|
+
expect(activeOverlay).to.not.be.null;
|
|
71
|
+
const closed = oneEvent(button, "sp-closed");
|
|
72
|
+
button.remove();
|
|
73
|
+
await closed;
|
|
74
|
+
activeOverlay = document.querySelector("active-overlay");
|
|
75
|
+
expect(activeOverlay).to.be.null;
|
|
76
|
+
});
|
|
77
|
+
it("accepts variants", async () => {
|
|
78
|
+
const el = await fixture(
|
|
79
|
+
html`
|
|
16
80
|
<sp-tooltip variant="negative">Help text.</sp-tooltip>
|
|
17
|
-
`
|
|
81
|
+
`
|
|
82
|
+
);
|
|
83
|
+
await elementUpdated(el);
|
|
84
|
+
expect(el.variant).to.equal("negative");
|
|
85
|
+
expect(el.getAttribute("variant")).to.equal("negative");
|
|
86
|
+
el.variant = "info";
|
|
87
|
+
await elementUpdated(el);
|
|
88
|
+
expect(el.variant).to.equal("info");
|
|
89
|
+
expect(el.getAttribute("variant")).to.equal("info");
|
|
90
|
+
el.setAttribute("variant", "positive");
|
|
91
|
+
await elementUpdated(el);
|
|
92
|
+
expect(el.variant).to.equal("positive");
|
|
93
|
+
expect(el.getAttribute("variant")).to.equal("positive");
|
|
94
|
+
el.removeAttribute("variant");
|
|
95
|
+
await elementUpdated(el);
|
|
96
|
+
expect(el.variant).to.equal("");
|
|
97
|
+
expect(el.hasAttribute("variant")).to.be.false;
|
|
98
|
+
});
|
|
99
|
+
it("validates variants", async () => {
|
|
100
|
+
const el = await fixture(
|
|
101
|
+
html`
|
|
18
102
|
<sp-tooltip variant="other">Help text.</sp-tooltip>
|
|
19
|
-
`
|
|
103
|
+
`
|
|
104
|
+
);
|
|
105
|
+
await elementUpdated(el);
|
|
106
|
+
expect(el.variant).to.equal("");
|
|
107
|
+
expect(el.hasAttribute("variant")).to.be.false;
|
|
108
|
+
el.variant = "info";
|
|
109
|
+
await elementUpdated(el);
|
|
110
|
+
expect(el.variant).to.equal("info");
|
|
111
|
+
expect(el.getAttribute("variant")).to.equal("info");
|
|
112
|
+
el.variant = "info";
|
|
113
|
+
await elementUpdated(el);
|
|
114
|
+
expect(el.variant).to.equal("info");
|
|
115
|
+
expect(el.getAttribute("variant")).to.equal("info");
|
|
116
|
+
});
|
|
117
|
+
it("answers tip query", async () => {
|
|
118
|
+
const el = await fixture(
|
|
119
|
+
html`
|
|
20
120
|
<sp-tooltip placement="top">Help text.</sp-tooltip>
|
|
21
|
-
`
|
|
121
|
+
`
|
|
122
|
+
);
|
|
123
|
+
await elementUpdated(el);
|
|
124
|
+
const overlayDetailQuery = {};
|
|
125
|
+
const queryOverlayDetailEvent = new CustomEvent("sp-overlay-query", {
|
|
126
|
+
bubbles: true,
|
|
127
|
+
composed: true,
|
|
128
|
+
detail: overlayDetailQuery,
|
|
129
|
+
cancelable: true
|
|
130
|
+
});
|
|
131
|
+
el.dispatchEvent(queryOverlayDetailEvent);
|
|
132
|
+
expect(overlayDetailQuery.overlayContentTipElement).to.exist;
|
|
133
|
+
if (overlayDetailQuery.overlayContentTipElement) {
|
|
134
|
+
expect(overlayDetailQuery.overlayContentTipElement.id).to.equal(
|
|
135
|
+
"tip"
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
22
140
|
//# sourceMappingURL=tooltip.test.js.map
|
package/test/tooltip.test.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.test.ts"],
|
|
4
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 { OverlayDisplayQueryDetail } from '@spectrum-web-components/overlay';\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';\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 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 await expect(button).to.be.accessible();\n\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 await expect(button).to.be.accessible();\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n await elementUpdated(el);\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 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 let activeOverlay = document.querySelector('active-overlay');\n expect(activeOverlay).to.not.be.null;\n\n const closed = oneEvent(button, 'sp-closed');\n button.remove();\n await closed;\n\n activeOverlay = document.querySelector('active-overlay');\n expect(activeOverlay).to.be.null;\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('answers tip query', 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 const overlayDetailQuery: OverlayDisplayQueryDetail = {};\n const queryOverlayDetailEvent =\n new CustomEvent<OverlayDisplayQueryDetail>('sp-overlay-query', {\n bubbles: true,\n composed: true,\n detail: overlayDetailQuery,\n cancelable: true,\n });\n el.dispatchEvent(queryOverlayDetailEvent);\n\n expect(overlayDetailQuery.overlayContentTipElement).to.exist;\n if (overlayDetailQuery.overlayContentTipElement) {\n expect(overlayDetailQuery.overlayContentTipElement.id).to.equal(\n 'tip'\n );\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA,
|
|
5
|
+
"mappings": ";AAYA,OAAO;AAGP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AACP,SAAS,6BAA6B;AAEtC,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,SAAS,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMJ;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;AACN,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AACtB,UAAM,OAAO,MAAM,EAAE,GAAG,GAAG,WAAW;AAEtC,UAAM,SAAS,SAAS,QAAQ,WAAW;AAC3C,WAAO,KAAK;AACZ,UAAM;A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