@spectrum-web-components/tooltip 0.31.1-react.3 → 0.32.1-overlay.33
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/custom-elements.json +88 -132
- package/package.json +4 -4
- package/src/Tooltip.d.ts +10 -32
- package/src/Tooltip.dev.js +102 -162
- package/src/Tooltip.dev.js.map +3 -3
- package/src/Tooltip.js +25 -5
- package/src/Tooltip.js.map +3 -3
- package/src/spectrum-config.js +120 -17
- package/src/spectrum-tooltip.css.dev.js +19 -19
- package/src/spectrum-tooltip.css.dev.js.map +1 -1
- package/src/spectrum-tooltip.css.js +19 -19
- package/src/spectrum-tooltip.css.js.map +1 -1
- package/src/tooltip.css.dev.js +23 -20
- package/src/tooltip.css.dev.js.map +2 -2
- package/src/tooltip.css.js +23 -20
- package/src/tooltip.css.js.map +2 -2
- package/stories/tooltip.stories.js +12 -15
- package/stories/tooltip.stories.js.map +2 -2
- package/test/tooltip.test.js +21 -57
- package/test/tooltip.test.js.map +2 -2
package/test/tooltip.test.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "@open-wc/testing";
|
|
10
10
|
import "@spectrum-web-components/button/sp-button.js";
|
|
11
11
|
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
12
|
+
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
12
13
|
describe("Tooltip", () => {
|
|
13
14
|
testForLitDevWarnings(
|
|
14
15
|
async () => await fixture(
|
|
@@ -27,6 +28,14 @@ describe("Tooltip", () => {
|
|
|
27
28
|
await expect(el).to.be.accessible();
|
|
28
29
|
});
|
|
29
30
|
it("self manages", async () => {
|
|
31
|
+
await sendMouse({
|
|
32
|
+
steps: [
|
|
33
|
+
{
|
|
34
|
+
type: "move",
|
|
35
|
+
position: [1, 1]
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
});
|
|
30
39
|
const button = await fixture(
|
|
31
40
|
html`
|
|
32
41
|
<sp-button>
|
|
@@ -41,65 +50,36 @@ describe("Tooltip", () => {
|
|
|
41
50
|
const opened = oneEvent(button, "sp-opened");
|
|
42
51
|
button.focus();
|
|
43
52
|
await opened;
|
|
44
|
-
await elementUpdated(el);
|
|
45
53
|
expect(el.open).to.be.true;
|
|
46
54
|
await expect(button).to.be.accessible();
|
|
47
55
|
const closed = oneEvent(button, "sp-closed");
|
|
48
56
|
button.blur();
|
|
49
57
|
await closed;
|
|
50
|
-
await elementUpdated(el);
|
|
51
58
|
expect(el.open).to.be.false;
|
|
52
59
|
});
|
|
53
|
-
it(
|
|
60
|
+
it("cleans up when self manages", async () => {
|
|
54
61
|
const button = await fixture(
|
|
55
62
|
html`
|
|
56
63
|
<sp-button>
|
|
57
64
|
This is a button.
|
|
58
|
-
<sp-tooltip self-managed
|
|
59
|
-
Help text.
|
|
60
|
-
</sp-tooltip>
|
|
65
|
+
<sp-tooltip self-managed>Help text.</sp-tooltip>
|
|
61
66
|
</sp-button>
|
|
62
67
|
`
|
|
63
68
|
);
|
|
64
69
|
const el = button.querySelector("sp-tooltip");
|
|
65
70
|
await elementUpdated(el);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
button.
|
|
69
|
-
button.dispatchEvent(
|
|
70
|
-
new PointerEvent("pointerleave", {
|
|
71
|
-
relatedTarget: el
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
el.dispatchEvent(
|
|
75
|
-
new PointerEvent("pointerleave", {
|
|
76
|
-
relatedTarget: button
|
|
77
|
-
})
|
|
78
|
-
);
|
|
71
|
+
expect(el.open).to.be.false;
|
|
72
|
+
const opened = oneEvent(button, "sp-opened");
|
|
73
|
+
button.focus();
|
|
79
74
|
await opened;
|
|
80
75
|
await elementUpdated(el);
|
|
81
76
|
expect(el.open).to.be.true;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
button.dispatchEvent(new PointerEvent("pointerleave"));
|
|
77
|
+
const closed = oneEvent(button, "sp-closed");
|
|
78
|
+
button.blur();
|
|
85
79
|
await closed;
|
|
86
|
-
await elementUpdated(el);
|
|
87
80
|
expect(el.open).to.be.false;
|
|
88
|
-
opened = oneEvent(button, "sp-opened");
|
|
89
|
-
button.dispatchEvent(new PointerEvent("pointerenter"));
|
|
90
|
-
button.dispatchEvent(
|
|
91
|
-
new PointerEvent("pointerleave", {
|
|
92
|
-
relatedTarget: el
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
await opened;
|
|
96
|
-
await elementUpdated(el);
|
|
97
|
-
closed = oneEvent(button, "sp-closed");
|
|
98
|
-
el.dispatchEvent(new PointerEvent("pointerleave"));
|
|
99
|
-
await closed;
|
|
100
|
-
await elementUpdated(el);
|
|
101
81
|
});
|
|
102
|
-
it("cleans up when self
|
|
82
|
+
it("cleans up when self managed and removed", async () => {
|
|
103
83
|
const button = await fixture(
|
|
104
84
|
html`
|
|
105
85
|
<sp-button>
|
|
@@ -110,18 +90,15 @@ describe("Tooltip", () => {
|
|
|
110
90
|
);
|
|
111
91
|
const el = button.querySelector("sp-tooltip");
|
|
112
92
|
await elementUpdated(el);
|
|
93
|
+
expect(el.open).to.be.false;
|
|
113
94
|
const opened = oneEvent(button, "sp-opened");
|
|
114
95
|
button.focus();
|
|
115
96
|
await opened;
|
|
116
|
-
await elementUpdated(el);
|
|
117
97
|
expect(el.open).to.be.true;
|
|
118
|
-
let activeOverlay = document.querySelector("active-overlay");
|
|
119
|
-
expect(activeOverlay).to.not.be.null;
|
|
120
98
|
const closed = oneEvent(button, "sp-closed");
|
|
121
99
|
button.remove();
|
|
122
100
|
await closed;
|
|
123
|
-
|
|
124
|
-
expect(activeOverlay).to.be.null;
|
|
101
|
+
expect(el.open).to.be.false;
|
|
125
102
|
});
|
|
126
103
|
it("accepts variants", async () => {
|
|
127
104
|
const el = await fixture(
|
|
@@ -163,27 +140,14 @@ describe("Tooltip", () => {
|
|
|
163
140
|
expect(el.variant).to.equal("info");
|
|
164
141
|
expect(el.getAttribute("variant")).to.equal("info");
|
|
165
142
|
});
|
|
166
|
-
it("
|
|
143
|
+
it("surfaces tip element", async () => {
|
|
167
144
|
const el = await fixture(
|
|
168
145
|
html`
|
|
169
146
|
<sp-tooltip placement="top">Help text.</sp-tooltip>
|
|
170
147
|
`
|
|
171
148
|
);
|
|
172
149
|
await elementUpdated(el);
|
|
173
|
-
|
|
174
|
-
const queryOverlayDetailEvent = new CustomEvent("sp-overlay-query", {
|
|
175
|
-
bubbles: true,
|
|
176
|
-
composed: true,
|
|
177
|
-
detail: overlayDetailQuery,
|
|
178
|
-
cancelable: true
|
|
179
|
-
});
|
|
180
|
-
el.dispatchEvent(queryOverlayDetailEvent);
|
|
181
|
-
expect(overlayDetailQuery.overlayContentTipElement).to.exist;
|
|
182
|
-
if (overlayDetailQuery.overlayContentTipElement) {
|
|
183
|
-
expect(overlayDetailQuery.overlayContentTipElement.id).to.equal(
|
|
184
|
-
"tip"
|
|
185
|
-
);
|
|
186
|
-
}
|
|
150
|
+
expect(typeof el.tipElement).to.not.equal("undefined");
|
|
187
151
|
});
|
|
188
152
|
});
|
|
189
153
|
//# sourceMappingURL=tooltip.test.js.map
|
package/test/tooltip.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tooltip.test.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\nimport {
|
|
5
|
-
"mappings": ";AAYA,OAAO;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport { Tooltip } from '@spectrum-web-components/tooltip';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n} from '@open-wc/testing';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/button/sp-button.js';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\ndescribe('Tooltip', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n )\n );\n it('loads', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('self manages', async () => {\n await sendMouse({\n steps: [\n {\n type: 'move',\n position: [1, 1],\n },\n ],\n });\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>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\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self manages', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self managed and removed', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n\n expect(el.open).to.be.true;\n\n const closed = oneEvent(button, 'sp-closed');\n button.remove();\n await closed;\n\n expect(el.open).to.be.false;\n });\n it('accepts variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"negative\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('negative');\n expect(el.getAttribute('variant')).to.equal('negative');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.setAttribute('variant', 'positive');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('positive');\n expect(el.getAttribute('variant')).to.equal('positive');\n\n el.removeAttribute('variant');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n });\n it('validates variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"other\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n });\n\n it('surfaces tip element', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip placement=\"top\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(typeof el.tipElement).to.not.equal('undefined');\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO;AAEP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,OAAO;AACP,SAAS,6BAA6B;AACtC,SAAS,iBAAiB;AAE1B,SAAS,WAAW,MAAM;AACtB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,SAAS,YAAY;AACpB,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACD,KAAG,gBAAgB,YAAY;AAC3B,UAAM,UAAU;AAAA,MACZ,OAAO;AAAA,QACH;AAAA,UACI,MAAM;AAAA,UACN,UAAU,CAAC,GAAG,CAAC;AAAA,QACnB;AAAA,MACJ;AAAA,IACJ,CAAC;AACD,UAAM,SAAS,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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;AAEN,WAAO,GAAG,IAAI,EAAE,GAAG,GAAG;AACtB,UAAM,OAAO,MAAM,EAAE,GAAG,GAAG,WAAW;AAEtC,UAAM,SAAS,SAAS,QAAQ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