@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.
@@ -1,18 +1,197 @@
1
- import"@spectrum-web-components/tooltip/sp-tooltip.js";import{html as o}from"@spectrum-web-components/base";import{ifDefined as l}from"@spectrum-web-components/base/src/directives.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-info.js";import"@spectrum-web-components/button/sp-button.js";import"@spectrum-web-components/action-button/sp-action-button.js";import"@spectrum-web-components/overlay/overlay-trigger.js";const p={"":()=>o``,negative:()=>o`
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
- `,positive:()=>o`
15
+ `,
16
+ positive: () => html`
4
17
  <sp-icon-checkmark slot="icon"></sp-icon-checkmark>
5
- `,info:()=>o`
18
+ `,
19
+ info: () => html`
6
20
  <sp-icon-info slot="icon"></sp-icon-info>
7
- `};export default{component:"sp-tooltip",title:"Tooltip"};export const Default=({open:n,placement:t,variant:e,text:r})=>o`
8
- <sp-tooltip ?open=${n} placement=${t} variant=${e}>
9
- ${r}
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
- `;Default.args={open:!0,placement:"top",variant:"",text:"Tooltip"},Default.argTypes={open:{name:"open",type:{name:"boolean",required:!1},description:"Whether the tooltip is open.",table:{type:{summary:"boolean"},defaultValue:{summary:!1}},control:{type:"boolean"}},placement:{name:"placement",type:{name:"string",required:!1},description:"The placement of the tooltip in relation to its parent",table:{type:{summary:"string"},defaultValue:{summary:"top"}},control:{type:"inline-radio",options:["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"]}},text:{name:"text",type:{name:"string",required:!1},table:{type:{summary:"string"},defaultValue:{summary:""}},control:"text"},variant:{name:"variant",type:{name:"string",required:!1},description:"The style of the tooltip.",table:{type:{summary:"string"},defaultValue:{summary:""}},control:{type:"inline-radio",options:["info","positive","negative",""]}}};export const wIcon=({open:n,placement:t,variant:e,text:r})=>o`
12
- <sp-tooltip ?open=${n} placement=${t} variant=${e}>
13
- ${e?p[e]():o``} ${r}
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
- `;wIcon.args={open:!0,placement:"top",text:"Tooltip",variant:"negative"},wIcon.argTypes={open:{name:"open",type:{name:"boolean",required:!1},description:"Whether the tooltip is open.",table:{type:{summary:"boolean"},defaultValue:{summary:!1}},control:{type:"boolean"}},placement:{name:"placement",type:{name:"string",required:!1},description:"The placement of the tooltip in relation to its parent",table:{type:{summary:"string"},defaultValue:{summary:"top"}},control:{type:"inline-radio",options:["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"]}},text:{name:"text",type:{name:"string",required:!1},table:{type:{summary:"string"},defaultValue:{summary:""}},control:"text"},variant:{name:"variant",type:{name:"string",required:!1},table:{type:{summary:"string"},defaultValue:{summary:""}},control:{type:"inline-radio",options:["info","positive","negative",""]}}};const i=o`
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
- `,a=n=>o`
49
- ${i}
50
- ${[["bottom",""],["left","negative"],["right","positive"],["top","info"]].map(([t,e])=>o`
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=${t}
53
- open=${l(n===t?"hover":void 0)}
239
+ placement=${placement}
240
+ open=${ifDefined(
241
+ openPlacement === placement ? "hover" : void 0
242
+ )}
54
243
  >
55
- <sp-button label="${t} test" slot="trigger">
56
- Hover for ${e||"tooltip"} on the
57
- ${t}
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=${e}>
60
- ${t}
248
+ <sp-tooltip slot="hover-content" variant=${variant}>
249
+ ${placement}
61
250
  </sp-tooltip>
62
251
  </overlay-trigger>
63
- `)}
64
- `;export const overlaidTop=()=>a("top"),overlaidRight=()=>a("right"),overlaidBottom=()=>a("bottom"),overlaidLeft=()=>a("left"),selfManaged=({placement:n,offset:t,delayed:e})=>o`
65
- ${i}
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=${n}
71
- offset=${t}
72
- ?delayed=${e}
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
- `;selfManaged.args={placement:"top",offset:6,delayed:!1},selfManaged.argTypes={delayed:{name:"delayed",type:{name:"boolean",required:!1},description:"Whether to manage the tooltip with the warmup timer"},offset:{name:"offset",type:{name:"number",required:!1},description:"The pixel distance from the parent element to place the tooltip"},placement:{name:"placement",type:{name:"string",required:!1},description:"The placement of the tooltip in relation to its parent",table:{type:{summary:"string"},defaultValue:{summary:"top"}},control:{type:"inline-radio",options:["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"]}}};
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,uDACA,qDACA,4EACA,uEACA,2EACA,sEACA,qDACA,mEAEA,4DAEA,KAAM,GAYF,CACA,GAAI,IAAM,IACV,SAAU,IACN;AAAA;AAAA,UAGJ,SAAU,IACN;AAAA;AAAA,UAGJ,KAAM,IACF;AAAA;AAAA,SAGR,EAEA,cAAe,CACX,UAAW,aACX,MAAO,SACX,EAWO,YAAM,SAAU,CAAC,CACpB,OACA,YACA,UACA,UAEO;AAAA,4BACiB,eAAkB,aAAqB;AAAA,cACrD;AAAA;AAAA,MAId,QAAQ,KAAO,CACX,KAAM,GACN,UAAW,MACX,QAAS,GACT,KAAM,SACV,EACA,QAAQ,SAAW,CACf,KAAM,CACF,KAAM,OACN,KAAM,CAAE,KAAM,UAAW,SAAU,EAAM,EACzC,YAAa,+BACb,MAAO,CACH,KAAM,CAAE,QAAS,SAAU,EAC3B,aAAc,CAAE,QAAS,EAAM,CACnC,EACA,QAAS,CACL,KAAM,SACV,CACJ,EACA,UAAW,CACP,KAAM,YACN,KAAM,CAAE,KAAM,SAAU,SAAU,EAAM,EACxC,YAAa,yDACb,MAAO,CACH,KAAM,CAAE,QAAS,QAAS,EAC1B,aAAc,CAAE,QAAS,KAAM,CACnC,EACA,QAAS,CACL,KAAM,eACN,QAAS,CACL,OACA,aACA,WACA,MACA,SACA,QACA,OACA,YACA,UACA,eACA,aACA,cAC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nB,SAAS;AAAA,IACL,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,EACjB;AAAA,EACA,QAAQ;AAAA,IACJ,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aACI;AAAA,EACR;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,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
- import"@spectrum-web-components/tooltip/sp-tooltip.js";import{html as o}from"lit";import{measureFixtureCreation as t}from"../../../../test/benchmark/helpers.js";t(o`
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,uDACA,2BACA,+EAEA,EAAuB;AAAA;AAAA,CAEtB",
5
+ "mappings": ";AAYA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,5 @@
1
- import*as o from"../stories/tooltip.stories.js";import{regressVisuals as r}from"../../../test/visual/test.js";r("TooltipStories",o);
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,gDACA,8DAEA,EAAe,iBAAkB,CAAO",
5
+ "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,kBAAkB,OAAO;",
6
6
  "names": []
7
7
  }
@@ -1,22 +1,140 @@
1
- import"@spectrum-web-components/tooltip/sp-tooltip.js";import{elementUpdated as o,expect as e,fixture as i,html as l,oneEvent as p}from"@open-wc/testing";import"@spectrum-web-components/button/sp-button.js";import{testForLitDevWarnings as u}from"../../../test/testing-helpers.js";describe("Tooltip",()=>{u(async()=>await i(l`
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
- `)),it("loads",async()=>{const t=await i(l`
17
+ `
18
+ )
19
+ );
20
+ it("loads", async () => {
21
+ const el = await fixture(
22
+ html`
4
23
  <sp-tooltip>Help text.</sp-tooltip>
5
- `);await o(t),await e(t).to.be.accessible()}),it("self manages",async()=>{const t=await i(l`
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
- `),a=t.querySelector("sp-tooltip");await o(a),await e(t).to.be.accessible();const n=p(t,"sp-opened");t.focus(),await n,await o(a),e(a.open).to.be.true,await e(t).to.be.accessible();const s=p(t,"sp-closed");t.blur(),await s,await o(a),e(a.open).to.be.false}),it("cleans up when self manages",async()=>{const t=await i(l`
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
- `),a=t.querySelector("sp-tooltip");await o(a);const n=p(t,"sp-opened");t.focus(),await n,await o(a),e(a.open).to.be.true;let s=document.querySelector("active-overlay");e(s).to.not.be.null;const r=p(t,"sp-closed");t.remove(),await r,s=document.querySelector("active-overlay"),e(s).to.be.null}),it("accepts variants",async()=>{const t=await i(l`
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
- `);await o(t),e(t.variant).to.equal("negative"),e(t.getAttribute("variant")).to.equal("negative"),t.variant="info",await o(t),e(t.variant).to.equal("info"),e(t.getAttribute("variant")).to.equal("info"),t.setAttribute("variant","positive"),await o(t),e(t.variant).to.equal("positive"),e(t.getAttribute("variant")).to.equal("positive"),t.removeAttribute("variant"),await o(t),e(t.variant).to.equal(""),e(t.hasAttribute("variant")).to.be.false}),it("validates variants",async()=>{const t=await i(l`
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
- `);await o(t),e(t.variant).to.equal(""),e(t.hasAttribute("variant")).to.be.false,t.variant="info",await o(t),e(t.variant).to.equal("info"),e(t.getAttribute("variant")).to.equal("info"),t.variant="info",await o(t),e(t.variant).to.equal("info"),e(t.getAttribute("variant")).to.equal("info")}),it("answers tip query",async()=>{const t=await i(l`
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
- `);await o(t);const a={},n=new CustomEvent("sp-overlay-query",{bubbles:!0,composed:!0,detail:a,cancelable:!0});t.dispatchEvent(n),e(a.overlayContentTipElement).to.exist,a.overlayContentTipElement&&e(a.overlayContentTipElement.id).to.equal("tip")})});
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
@@ -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,uDAGA,mGAQA,qDACA,yEAEA,SAAS,UAAW,IAAM,CACtB,EACI,SACI,KAAM,GACF;AAAA;AAAA,iBAGJ,CACR,EACA,GAAG,QAAS,SAAY,CACpB,KAAM,GAAK,KAAM,GACb;AAAA;AAAA,aAGJ,EAEA,KAAM,GAAe,CAAE,EAEvB,KAAM,GAAO,CAAE,EAAE,GAAG,GAAG,WAAW,CACtC,CAAC,EACD,GAAG,eAAgB,SAAY,CAC3B,KAAM,GAAS,KAAM,GACjB;AAAA;AAAA;AAAA;AAAA;AAAA,aAMJ,EAEM,EAAK,EAAO,cAAc,YAAY,EAE5C,KAAM,GAAe,CAAE,EACvB,KAAM,GAAO,CAAM,EAAE,GAAG,GAAG,WAAW,EAEtC,KAAM,GAAS,EAAS,EAAQ,WAAW,EAC3C,EAAO,MAAM,EACb,KAAM,GACN,KAAM,GAAe,CAAE,EAE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