@spectrum-web-components/overlay 0.13.0 → 0.13.3-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.
Files changed (40) hide show
  1. package/custom-elements.json +28 -9
  2. package/package.json +7 -7
  3. package/src/ActiveOverlay.d.ts +2 -8
  4. package/src/ActiveOverlay.js +2 -1
  5. package/src/ActiveOverlay.js.map +1 -1
  6. package/src/OverlayTrigger.js +4 -7
  7. package/src/OverlayTrigger.js.map +1 -1
  8. package/src/active-overlay.css.js +2 -2
  9. package/src/active-overlay.css.js.map +1 -1
  10. package/src/overlay-stack.d.ts +2 -0
  11. package/src/overlay-stack.js +33 -24
  12. package/src/overlay-stack.js.map +1 -1
  13. package/src/overlay-trigger.css.js +1 -1
  14. package/src/overlay-trigger.css.js.map +1 -1
  15. package/src/overlay.js +1 -0
  16. package/src/overlay.js.map +1 -1
  17. package/stories/overlay-story-components.js +1 -1
  18. package/stories/overlay-story-components.js.map +1 -1
  19. package/stories/overlay.stories.js +1 -1
  20. package/stories/overlay.stories.js.map +1 -1
  21. package/test/overlay-lifecycle.test.js +0 -80
  22. package/test/overlay-lifecycle.test.js.map +0 -1
  23. package/test/overlay-timer.test.js +0 -129
  24. package/test/overlay-timer.test.js.map +0 -1
  25. package/test/overlay-trigger-click.test.js +0 -76
  26. package/test/overlay-trigger-click.test.js.map +0 -1
  27. package/test/overlay-trigger-hover-click.test.js +0 -89
  28. package/test/overlay-trigger-hover-click.test.js.map +0 -1
  29. package/test/overlay-trigger-hover.test.js +0 -112
  30. package/test/overlay-trigger-hover.test.js.map +0 -1
  31. package/test/overlay-trigger-longpress.test.js +0 -112
  32. package/test/overlay-trigger-longpress.test.js.map +0 -1
  33. package/test/overlay-trigger-sync.test.js +0 -555
  34. package/test/overlay-trigger-sync.test.js.map +0 -1
  35. package/test/overlay-trigger.test.js +0 -555
  36. package/test/overlay-trigger.test.js.map +0 -1
  37. package/test/overlay.test-vrt.js +0 -15
  38. package/test/overlay.test-vrt.js.map +0 -1
  39. package/test/overlay.test.js +0 -505
  40. package/test/overlay.test.js.map +0 -1
@@ -1,80 +0,0 @@
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 { elementUpdated, expect, fixture, html, oneEvent, waitUntil, } from '@open-wc/testing';
13
- import '@spectrum-web-components/tooltip/sp-tooltip.js';
14
- import '@spectrum-web-components/action-button/sp-action-button.js';
15
- import '@spectrum-web-components/overlay/overlay-trigger.js';
16
- import { a11ySnapshot, findAccessibilityNode } from '@web/test-runner-commands';
17
- describe('Overlay Trigger - Lifecycle Methods', () => {
18
- it('calls the overlay lifecycle (willOpen/Close)', async () => {
19
- const el = await fixture(html `
20
- <overlay-trigger placement="right-start">
21
- <sp-action-button slot="trigger">
22
- Button with Tooltip
23
- </sp-action-button>
24
- <sp-tooltip slot="hover-content">
25
- Described by this content on focus/hover. 1
26
- </sp-tooltip>
27
- </overlay-trigger>
28
- `);
29
- await elementUpdated(el);
30
- expect(el.open).to.be.undefined;
31
- expect(el.childNodes.length).to.equal(5);
32
- const trigger = el.querySelector('[slot="trigger"]');
33
- let snapshot = (await a11ySnapshot({}));
34
- expect(findAccessibilityNode(snapshot, (node) => node.name === 'Button with Tooltip' &&
35
- typeof node.description === 'undefined'), '`name`ed with no `description`');
36
- const opened = oneEvent(el, 'sp-opened');
37
- trigger.dispatchEvent(new FocusEvent('focusin', { bubbles: true, composed: true }));
38
- await opened;
39
- expect(el.open).to.equal('hover');
40
- snapshot = (await a11ySnapshot({}));
41
- expect(el.childNodes.length).to.equal(6);
42
- expect(findAccessibilityNode(snapshot, (node) => node.name === 'Button with Tooltip' &&
43
- node.description ===
44
- 'Described by this content on focus/hover.'), '`name`ed with `description`');
45
- const closed = oneEvent(el, 'sp-closed');
46
- trigger.dispatchEvent(new FocusEvent('focusout', { bubbles: true, composed: true }));
47
- await closed;
48
- await elementUpdated(el);
49
- await waitUntil(() => el.open === null);
50
- expect(el.childNodes.length).to.equal(5);
51
- });
52
- it('calls the overlay lifecycle (willOpen/openCanceled)', async () => {
53
- const el = await fixture(html `
54
- <overlay-trigger placement="right-start">
55
- <sp-action-button slot="trigger">
56
- Button with Tooltip
57
- </sp-action-button>
58
- <sp-tooltip slot="hover-content" delayed>
59
- Described by this content on focus/hover. 2
60
- </sp-tooltip>
61
- </overlay-trigger>
62
- `);
63
- await elementUpdated(el);
64
- expect(el.open).to.be.undefined;
65
- expect(el.childNodes.length, 'always').to.equal(5);
66
- const trigger = el.querySelector('[slot="trigger"]');
67
- trigger.dispatchEvent(new FocusEvent('focusin', { bubbles: true, composed: true }));
68
- await elementUpdated(el);
69
- trigger.dispatchEvent(new FocusEvent('focusout', { bubbles: true, composed: true }));
70
- await elementUpdated(el);
71
- await waitUntil(() => {
72
- return el.open === null;
73
- }, 'open');
74
- await elementUpdated(el);
75
- await waitUntil(() => {
76
- return el.childNodes.length === 5;
77
- }, 'children');
78
- });
79
- });
80
- //# sourceMappingURL=overlay-lifecycle.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-lifecycle.test.js","sourceRoot":"","sources":["overlay-lifecycle.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,SAAS,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AAEpE,OAAO,qDAAqD,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAA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,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,CAAC,aAAa,CACjB,IAAI,UAAU,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAChE,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,SAAS,CAAC,GAAG,EAAE;YACjB,OAAO,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC;QAC5B,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QACzB,MAAM,SAAS,CAAC,GAAG,EAAE;YACjB,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;QACtC,CAAC,EAAE,UAAU,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/tooltip/sp-tooltip.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { OverlayTrigger } from '..';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { a11ySnapshot, findAccessibilityNode } from '@web/test-runner-commands';\n\ndescribe('Overlay Trigger - Lifecycle Methods', () => {\n it('calls the overlay lifecycle (willOpen/Close)', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\">\n Described by this content on focus/hover. 1\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length).to.equal(5);\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n type DescribedNode = {\n name: string;\n description: string;\n };\n let snapshot = (await a11ySnapshot({})) as unknown as DescribedNode & {\n children: DescribedNode[];\n };\n expect(\n findAccessibilityNode<DescribedNode>(\n snapshot,\n (node) =>\n node.name === 'Button with Tooltip' &&\n typeof node.description === 'undefined'\n ),\n '`name`ed with no `description`'\n );\n const opened = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await opened;\n\n expect(el.open).to.equal('hover');\n snapshot = (await a11ySnapshot({})) as unknown as DescribedNode & {\n children: DescribedNode[];\n };\n\n expect(el.childNodes.length).to.equal(6);\n expect(\n findAccessibilityNode<DescribedNode>(\n snapshot,\n (node) =>\n node.name === 'Button with Tooltip' &&\n node.description ===\n 'Described by this content on focus/hover.'\n ),\n '`name`ed with `description`'\n );\n\n const closed = oneEvent(el, 'sp-closed');\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await closed;\n await elementUpdated(el);\n\n await waitUntil(() => el.open === null);\n expect(el.childNodes.length).to.equal(5);\n });\n it('calls the overlay lifecycle (willOpen/openCanceled)', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n Button with Tooltip\n </sp-action-button>\n <sp-tooltip slot=\"hover-content\" delayed>\n Described by this content on focus/hover. 2\n </sp-tooltip>\n </overlay-trigger>\n `);\n\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n expect(el.childNodes.length, 'always').to.equal(5);\n const trigger = el.querySelector('[slot=\"trigger\"]') as HTMLElement;\n trigger.dispatchEvent(\n new FocusEvent('focusin', { bubbles: true, composed: true })\n );\n await elementUpdated(el);\n trigger.dispatchEvent(\n new FocusEvent('focusout', { bubbles: true, composed: true })\n );\n await elementUpdated(el);\n\n await waitUntil(() => {\n return el.open === null;\n }, 'open');\n await elementUpdated(el);\n await waitUntil(() => {\n return el.childNodes.length === 5;\n }, 'children');\n });\n});\n"]}
@@ -1,129 +0,0 @@
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 { useFakeTimers } from 'sinon';
13
- import { OverlayTimer } from '../src/overlay-timer.js';
14
- import { expect } from '@open-wc/testing';
15
- describe('Overlays timer', () => {
16
- let clock;
17
- beforeEach(() => {
18
- clock = useFakeTimers();
19
- });
20
- afterEach(() => {
21
- clock.restore();
22
- });
23
- it('should resolve after warmup', async () => {
24
- const timer = new OverlayTimer({
25
- warmUpDelay: 500,
26
- coolDownDelay: 500,
27
- });
28
- const element = document.createElement('div');
29
- const promise = timer.openTimer(element);
30
- clock.next();
31
- expect(clock.now).to.equal(500);
32
- const cancelled = await promise;
33
- expect(cancelled).to.be.false;
34
- });
35
- it('should resolve true when cancelled', async () => {
36
- const timer = new OverlayTimer({
37
- warmUpDelay: 500,
38
- coolDownDelay: 500,
39
- });
40
- const element = document.createElement('div');
41
- const promise = timer.openTimer(element);
42
- clock.tick(10);
43
- timer.close(element);
44
- clock.next();
45
- const cancelled = await promise;
46
- expect(cancelled).to.be.true;
47
- });
48
- it('should resolve cancelled when opening new overlay', async () => {
49
- const timer = new OverlayTimer({
50
- warmUpDelay: 500,
51
- coolDownDelay: 500,
52
- });
53
- const element1 = document.createElement('div');
54
- const element2 = document.createElement('div');
55
- const promise1 = timer.openTimer(element1);
56
- clock.tick(10);
57
- const promise2 = timer.openTimer(element2);
58
- clock.tick(10);
59
- let cancelled = await promise1;
60
- expect(cancelled).to.be.true;
61
- clock.next();
62
- cancelled = await promise2;
63
- expect(cancelled).to.be.false;
64
- expect(clock.now).to.equal(510);
65
- });
66
- it('should cooldown after closing overlay', async () => {
67
- const timer = new OverlayTimer({
68
- warmUpDelay: 500,
69
- coolDownDelay: 500,
70
- });
71
- const element = document.createElement('div');
72
- let promise = timer.openTimer(element);
73
- clock.next();
74
- timer.close(element);
75
- clock.next();
76
- expect(clock.now).to.equal(1000);
77
- promise = timer.openTimer(element);
78
- clock.next();
79
- const cancelled = await promise;
80
- expect(cancelled).to.be.false;
81
- expect(clock.now).to.equal(1500);
82
- });
83
- it('should open overlay quickly when hot', async () => {
84
- const timer = new OverlayTimer({
85
- warmUpDelay: 500,
86
- coolDownDelay: 500,
87
- });
88
- const element = document.createElement('div');
89
- let promise = timer.openTimer(element);
90
- clock.next();
91
- timer.close(element);
92
- clock.tick(1);
93
- promise = timer.openTimer(element);
94
- clock.next();
95
- const cancelled = await promise;
96
- expect(cancelled).to.be.false;
97
- expect(clock.now).to.equal(501);
98
- });
99
- it('should cooldown after opening and closing overlay multiple times', async () => {
100
- const timer = new OverlayTimer({
101
- warmUpDelay: 500,
102
- coolDownDelay: 500,
103
- });
104
- const element = document.createElement('div');
105
- let promise = timer.openTimer(element);
106
- clock.next();
107
- expect(clock.now).to.equal(500);
108
- timer.close(element);
109
- clock.tick(1);
110
- for (let i = 0; i < 10; i++) {
111
- const element = document.createElement('div');
112
- promise = timer.openTimer(element);
113
- clock.next();
114
- const cancelled = await promise;
115
- expect(cancelled).to.be.false;
116
- timer.close(element);
117
- clock.tick(1);
118
- }
119
- // Wait for cooldown
120
- clock.next();
121
- expect(clock.now).to.equal(1010);
122
- promise = timer.openTimer(element);
123
- clock.next();
124
- const cancelled = await promise;
125
- expect(cancelled).to.be.false;
126
- expect(clock.now).to.equal(1510);
127
- });
128
- });
129
- //# sourceMappingURL=overlay-timer.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-timer.test.js","sourceRoot":"","sources":["overlay-timer.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAmB,aAAa,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,IAAI,KAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,GAAG,aAAa,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC;YAC3B,WAAW,EAAE,GAAG;YAChB,aAAa,EAAE,GAAG;SACrB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;QAChC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QACh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AS,CAAC,OAAO,CAAC,CAAC;YACnC,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC9B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,oBAAoB;QACpB,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;QAChC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,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*/\n\nimport { SinonFakeTimers, useFakeTimers } from 'sinon';\nimport { OverlayTimer } from '../src/overlay-timer.js';\nimport { expect } from '@open-wc/testing';\n\ndescribe('Overlays timer', () => {\n let clock: SinonFakeTimers;\n\n beforeEach(() => {\n clock = useFakeTimers();\n });\n\n afterEach(() => {\n clock.restore();\n });\n\n it('should resolve after warmup', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element = document.createElement('div');\n const promise = timer.openTimer(element);\n clock.next();\n expect(clock.now).to.equal(500);\n const cancelled = await promise;\n expect(cancelled).to.be.false;\n });\n\n it('should resolve true when cancelled', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element = document.createElement('div');\n const promise = timer.openTimer(element);\n clock.tick(10);\n timer.close(element);\n clock.next();\n const cancelled = await promise;\n expect(cancelled).to.be.true;\n });\n\n it('should resolve cancelled when opening new overlay', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element1 = document.createElement('div');\n const element2 = document.createElement('div');\n const promise1 = timer.openTimer(element1);\n clock.tick(10);\n const promise2 = timer.openTimer(element2);\n clock.tick(10);\n let cancelled = await promise1;\n expect(cancelled).to.be.true;\n clock.next();\n cancelled = await promise2;\n expect(cancelled).to.be.false;\n expect(clock.now).to.equal(510);\n });\n\n it('should cooldown after closing overlay', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element = document.createElement('div');\n let promise = timer.openTimer(element);\n clock.next();\n timer.close(element);\n clock.next();\n expect(clock.now).to.equal(1000);\n promise = timer.openTimer(element);\n clock.next();\n const cancelled = await promise;\n expect(cancelled).to.be.false;\n expect(clock.now).to.equal(1500);\n });\n\n it('should open overlay quickly when hot', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element = document.createElement('div');\n let promise = timer.openTimer(element);\n clock.next();\n timer.close(element);\n clock.tick(1);\n promise = timer.openTimer(element);\n clock.next();\n const cancelled = await promise;\n expect(cancelled).to.be.false;\n expect(clock.now).to.equal(501);\n });\n\n it('should cooldown after opening and closing overlay multiple times', async () => {\n const timer = new OverlayTimer({\n warmUpDelay: 500,\n coolDownDelay: 500,\n });\n const element = document.createElement('div');\n let promise = timer.openTimer(element);\n clock.next();\n expect(clock.now).to.equal(500);\n timer.close(element);\n clock.tick(1);\n\n for (let i = 0; i < 10; i++) {\n const element = document.createElement('div');\n promise = timer.openTimer(element);\n clock.next();\n const cancelled = await promise;\n expect(cancelled).to.be.false;\n timer.close(element);\n clock.tick(1);\n }\n\n // Wait for cooldown\n clock.next();\n expect(clock.now).to.equal(1010);\n promise = timer.openTimer(element);\n clock.next();\n const cancelled = await promise;\n expect(cancelled).to.be.false;\n expect(clock.now).to.equal(1510);\n });\n});\n"]}
@@ -1,76 +0,0 @@
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 { elementUpdated, expect, fixture, html, waitUntil, } from '@open-wc/testing';
13
- import '@spectrum-web-components/popover/sp-popover.js';
14
- import '@spectrum-web-components/action-button/sp-action-button.js';
15
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
16
- import '@spectrum-web-components/popover/sp-popover.js';
17
- import '@spectrum-web-components/overlay/overlay-trigger.js';
18
- import { spy } from 'sinon';
19
- describe('Overlay Trigger - Click', () => {
20
- it('displays `click` declaratively', async () => {
21
- const openedSpy = spy();
22
- const closedSpy = spy();
23
- const el = await fixture((() => html `
24
- <overlay-trigger
25
- placement="right-start"
26
- open="click"
27
- @sp-opened=${() => openedSpy()}
28
- @sp-closed=${() => closedSpy()}
29
- >
30
- <sp-action-button slot="trigger">
31
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
32
- </sp-action-button>
33
- <sp-popover slot="click-content" tip></sp-popover>
34
- </overlay-trigger>
35
- `)());
36
- await elementUpdated(el);
37
- await waitUntil(() => openedSpy.calledOnce, 'click content projected to overlay', { timeout: 2000 });
38
- el.removeAttribute('open');
39
- await elementUpdated(el);
40
- await waitUntil(() => closedSpy.calledOnce, 'click content returned', {
41
- timeout: 2000,
42
- });
43
- });
44
- it('opens a second time', async () => {
45
- const openedSpy = spy();
46
- const closedSpy = spy();
47
- const el = await fixture(html `
48
- <overlay-trigger
49
- placement="right-start"
50
- type="modal"
51
- open="click"
52
- @sp-opened=${() => openedSpy()}
53
- @sp-closed=${() => closedSpy()}
54
- >
55
- <sp-action-button slot="trigger">
56
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
57
- </sp-action-button>
58
- <sp-popover slot="click-content" tip></sp-popover>
59
- </overlay-trigger>
60
- `);
61
- await elementUpdated(el);
62
- const trigger = el.querySelector('[slot=trigger]');
63
- await waitUntil(() => openedSpy.calledOnce, 'click content projected to overlay', { timeout: 2000 });
64
- expect(el.open).to.equal('click');
65
- el.removeAttribute('open');
66
- await elementUpdated(el);
67
- await waitUntil(() => closedSpy.calledOnce, 'click content returned', {
68
- timeout: 2000,
69
- });
70
- expect(el.open).to.be.null;
71
- trigger.click();
72
- await waitUntil(() => openedSpy.callCount === 2, 'click content projected to overlay, again', { timeout: 2000 });
73
- expect(el.open).to.equal('click');
74
- });
75
- });
76
- //# sourceMappingURL=overlay-trigger-click.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-trigger-click.test.js","sourceRoot":"","sources":["overlay-trigger-click.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AACpE,OAAO,kEAAkE,CAAC;AAC1E,OAAO,gDAAgD,CAAC;AAExD,OAAO,qDAAqD,CAAC;AAC7D,O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E,MAAM,SAAS,CACX,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAC1B,oCAAoC,EACpC,EAAE,OAAO,EAAE,IAAI,EAAE,CACpB,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAElC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,wBAAwB,EAAE;YAClE,OAAO,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAE3B,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,SAAS,CACX,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,KAAK,CAAC,EAC/B,2CAA2C,EAC3C,EAAE,OAAO,EAAE,IAAI,EAAE,CACpB,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n waitUntil,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport { OverlayTrigger } from '..';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { spy } from 'sinon';\nimport { ActionButton } from '@spectrum-web-components/action-button';\n\ndescribe('Overlay Trigger - Click', () => {\n it('displays `click` declaratively', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger\n placement=\"right-start\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n });\n it('opens a second time', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger\n placement=\"right-start\"\n type=\"modal\"\n open=\"click\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"click-content\" tip></sp-popover>\n </overlay-trigger>\n `);\n await elementUpdated(el);\n const trigger = el.querySelector('[slot=trigger]') as ActionButton;\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'click content projected to overlay',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'click content returned', {\n timeout: 2000,\n });\n\n expect(el.open).to.be.null;\n\n trigger.click();\n await waitUntil(\n () => openedSpy.callCount === 2,\n 'click content projected to overlay, again',\n { timeout: 2000 }\n );\n expect(el.open).to.equal('click');\n });\n});\n"]}
@@ -1,89 +0,0 @@
1
- /*
2
- Copyright 2021 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 { expect, fixture, html, oneEvent } from '@open-wc/testing';
13
- import '@spectrum-web-components/popover/sp-popover.js';
14
- import '@spectrum-web-components/action-button/sp-action-button.js';
15
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
16
- import '@spectrum-web-components/popover/sp-popover.js';
17
- import '@spectrum-web-components/overlay/overlay-trigger.js';
18
- import { executeServerCommand } from '@web/test-runner-commands';
19
- describe('Overlay Trigger - Hover and Click', () => {
20
- it('toggles open and closed on click', async () => {
21
- const el = await fixture(html `
22
- <overlay-trigger>
23
- <sp-button slot="trigger">Click and hover</sp-button>
24
- <sp-popover slot="click-content" dialog tip>
25
- Popover content
26
- </sp-popover>
27
- <sp-tooltip slot="hover-content" delayed>
28
- Tooltip content
29
- </sp-tooltip>
30
- </overlay-trigger>
31
- `);
32
- const trigger = el.querySelector('[slot=trigger]');
33
- let interaction;
34
- // repeatedly click to toggle the popover
35
- for (let i = 0; i < 3; i++) {
36
- const openedEvent = oneEvent(el, 'sp-opened');
37
- trigger.click();
38
- interaction = (await openedEvent).detail.interaction;
39
- expect(interaction).equals('click');
40
- const closedEvent = oneEvent(el, 'sp-closed');
41
- trigger.click();
42
- interaction = (await closedEvent).detail.interaction;
43
- expect(interaction).equals('click');
44
- }
45
- });
46
- it('toggles on click after hover', async () => {
47
- const el = await fixture(html `
48
- <overlay-trigger>
49
- <sp-button slot="trigger">Click and hover</sp-button>
50
- <sp-popover slot="click-content" dialog tip>
51
- Popover content
52
- </sp-popover>
53
- <sp-tooltip slot="hover-content" delayed>
54
- Tooltip content
55
- </sp-tooltip>
56
- </overlay-trigger>
57
- `);
58
- const trigger = el.querySelector('[slot=trigger]');
59
- const bounds = el.getBoundingClientRect();
60
- let interaction;
61
- // hover over the button to trigger the tooltip
62
- const hoveredEvent = oneEvent(el, 'sp-opened');
63
- await executeServerCommand('send-mouse', {
64
- steps: [
65
- {
66
- type: 'move',
67
- position: [
68
- bounds.left + bounds.width / 2,
69
- bounds.top + bounds.height / 2,
70
- ],
71
- },
72
- ],
73
- });
74
- interaction = (await hoveredEvent).detail.interaction;
75
- expect(interaction).equals('hover');
76
- // repeatedly click to toggle the popover
77
- for (let i = 0; i < 3; i++) {
78
- const openedEvent = oneEvent(el, 'sp-opened');
79
- trigger.click();
80
- interaction = (await openedEvent).detail.interaction;
81
- expect(interaction).equals('click');
82
- const closedEvent = oneEvent(el, 'sp-closed');
83
- trigger.click();
84
- interaction = (await closedEvent).detail.interaction;
85
- expect(interaction).equals('click');
86
- }
87
- });
88
- });
89
- //# sourceMappingURL=overlay-trigger-hover-click.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-trigger-hover-click.test.js","sourceRoot":"","sources":["overlay-trigger-hover-click.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AACpE,OAAO,kEAAkE,CAAC;AAC1E,OAAO,gDAAgD,CAAC;AAGxD,OAAO,qDAAqD,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE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M,oBAAoB,CAAC,YAAY,EAAE;YACrC,KAAK,EAAE;gBACH;oBACI,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE;wBACN,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC;wBAC9B,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;qBACjC;iBACJ;aACJ;SACJ,CAAC,CAAC;QACH,WAAW,GAAG,CAAC,MAAM,YAAY,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;QAEtD,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEpC,yCAAyC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAC9C,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;YAErD,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAEpC,MAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAC9C,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;YAErD,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACvC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2021 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 { expect, fixture, html, oneEvent } from '@open-wc/testing';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport { OverlayTrigger } from '../src/OverlayTrigger';\nimport { TriggerInteractions } from '../src/overlay-types';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { ActionButton } from '@spectrum-web-components/action-button';\nimport { executeServerCommand } from '@web/test-runner-commands';\n\ndescribe('Overlay Trigger - Hover and Click', () => {\n it('toggles open and closed on click', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger>\n <sp-button slot=\"trigger\">Click and hover</sp-button>\n <sp-popover slot=\"click-content\" dialog tip>\n Popover content\n </sp-popover>\n <sp-tooltip slot=\"hover-content\" delayed>\n Tooltip content\n </sp-tooltip>\n </overlay-trigger>\n `);\n const trigger = el.querySelector(\n '[slot=trigger]'\n ) as unknown as ActionButton;\n let interaction: TriggerInteractions;\n\n // repeatedly click to toggle the popover\n for (let i = 0; i < 3; i++) {\n const openedEvent = oneEvent(el, 'sp-opened');\n trigger.click();\n interaction = (await openedEvent).detail.interaction;\n\n expect(interaction).equals('click');\n\n const closedEvent = oneEvent(el, 'sp-closed');\n trigger.click();\n interaction = (await closedEvent).detail.interaction;\n\n expect(interaction).equals('click');\n }\n });\n it('toggles on click after hover', async () => {\n const el = await fixture<OverlayTrigger>(html`\n <overlay-trigger>\n <sp-button slot=\"trigger\">Click and hover</sp-button>\n <sp-popover slot=\"click-content\" dialog tip>\n Popover content\n </sp-popover>\n <sp-tooltip slot=\"hover-content\" delayed>\n Tooltip content\n </sp-tooltip>\n </overlay-trigger>\n `);\n const trigger = el.querySelector(\n '[slot=trigger]'\n ) as unknown as ActionButton;\n const bounds = el.getBoundingClientRect();\n let interaction: TriggerInteractions;\n\n // hover over the button to trigger the tooltip\n const hoveredEvent = oneEvent(el, 'sp-opened');\n await executeServerCommand('send-mouse', {\n steps: [\n {\n type: 'move',\n position: [\n bounds.left + bounds.width / 2,\n bounds.top + bounds.height / 2,\n ],\n },\n ],\n });\n interaction = (await hoveredEvent).detail.interaction;\n\n expect(interaction).equals('hover');\n\n // repeatedly click to toggle the popover\n for (let i = 0; i < 3; i++) {\n const openedEvent = oneEvent(el, 'sp-opened');\n trigger.click();\n interaction = (await openedEvent).detail.interaction;\n\n expect(interaction).equals('click');\n\n const closedEvent = oneEvent(el, 'sp-closed');\n trigger.click();\n interaction = (await closedEvent).detail.interaction;\n\n expect(interaction).equals('click');\n }\n });\n});\n"]}
@@ -1,112 +0,0 @@
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 { elementUpdated, expect, fixture, html, waitUntil, } from '@open-wc/testing';
13
- import '@spectrum-web-components/popover/sp-popover.js';
14
- import '@spectrum-web-components/action-button/sp-action-button.js';
15
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
16
- import '@spectrum-web-components/overlay/overlay-trigger.js';
17
- import { spy } from 'sinon';
18
- describe('Overlay Trigger - Hover', () => {
19
- it('displays `hover` declaratively', async () => {
20
- const openedSpy = spy();
21
- const closedSpy = spy();
22
- const el = await fixture((() => html `
23
- <overlay-trigger
24
- placement="right-start"
25
- open="hover"
26
- @sp-opened=${() => openedSpy()}
27
- @sp-closed=${() => closedSpy()}
28
- >
29
- <sp-action-button slot="trigger">
30
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
31
- </sp-action-button>
32
- <sp-popover slot="hover-content" tip></sp-popover>
33
- </overlay-trigger>
34
- `)());
35
- await elementUpdated(el);
36
- await waitUntil(() => openedSpy.calledOnce, 'hover content projected to overlay', { timeout: 2000 });
37
- el.removeAttribute('open');
38
- await elementUpdated(el);
39
- await waitUntil(() => closedSpy.calledOnce, 'hover content returned', {
40
- timeout: 2000,
41
- });
42
- });
43
- it('persists hover content', async () => {
44
- const el = await fixture((() => html `
45
- <overlay-trigger placement="right-start">
46
- <sp-action-button slot="trigger">
47
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
48
- </sp-action-button>
49
- <sp-popover slot="hover-content" tip></sp-popover>
50
- </overlay-trigger>
51
- `)());
52
- await elementUpdated(el);
53
- expect(el.open).to.be.undefined;
54
- const trigger = el.querySelector('[slot="trigger"]');
55
- trigger.dispatchEvent(new Event('mouseenter', {
56
- bubbles: true,
57
- }));
58
- await elementUpdated(el);
59
- expect(el.open).to.equal('hover');
60
- trigger.click();
61
- await elementUpdated(el);
62
- expect(el.open).to.equal('hover');
63
- });
64
- it('closes persistent hover content on `longpress`', async () => {
65
- const el = await fixture((() => html `
66
- <overlay-trigger placement="right-start">
67
- <sp-action-button slot="trigger">
68
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
69
- </sp-action-button>
70
- <sp-popover slot="hover-content" tip></sp-popover>
71
- <sp-popover slot="longpress-content" tip></sp-popover>
72
- </overlay-trigger>
73
- `)());
74
- await elementUpdated(el);
75
- expect(el.open).to.be.undefined;
76
- const trigger = el.querySelector('[slot="trigger"]');
77
- trigger.dispatchEvent(new Event('mouseenter', {
78
- bubbles: true,
79
- }));
80
- await elementUpdated(el);
81
- expect(el.open).to.equal('hover');
82
- trigger.dispatchEvent(new Event('longpress', {
83
- bubbles: true,
84
- }));
85
- await elementUpdated(el);
86
- expect(el.open).to.equal('longpress');
87
- });
88
- it('closes `hover` overlay when [type="modal"]', async () => {
89
- const el = await fixture((() => html `
90
- <overlay-trigger placement="right-start" type="modal">
91
- <sp-action-button slot="trigger">
92
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
93
- </sp-action-button>
94
- <sp-popover slot="hover-content" tip></sp-popover>
95
- </overlay-trigger>
96
- `)());
97
- await elementUpdated(el);
98
- expect(el.open).to.be.undefined;
99
- const trigger = el.querySelector('[slot="trigger"]');
100
- trigger.dispatchEvent(new Event('mouseenter', {
101
- bubbles: true,
102
- }));
103
- await elementUpdated(el);
104
- expect(el.open).to.equal('hover');
105
- trigger.dispatchEvent(new Event('mouseleave', {
106
- bubbles: true,
107
- }));
108
- await elementUpdated(el);
109
- expect(el.open).to.be.null;
110
- });
111
- });
112
- //# sourceMappingURL=overlay-trigger-hover.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-trigger-hover.test.js","sourceRoot":"","sources":["overlay-trigger-hover.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,gDAAgD,CAAC;AACxD,OAAO,4DAA4D,CAAC;AACpE,OAAO,kEAAkE,CAAC;AAE1E,OAAO,qDAAqD,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA;;;;iCAIU,GAAG,EAAE,CAAC,SAAS,EAAE;iCACjB,GAAG,EAAE,CAAC,SAAS,EAAE;;;;;;;aAOrC,CAAC,EAAE,CACP,CAAC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AI,KAAK,CAAC,YAAY,EAAE;YACpB,OAAO,EAAE,IAAI;SAChB,CAAC,CACL,CAAC;QAEF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAElC,OAAO,CAAC,aAAa,CACjB,IAAI,KAAK,CAAC,YAAY,EAAE;YACpB,OAAO,EAAE,IAAI;SAChB,CAAC,CACL,CAAC;QAEF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,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*/\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n waitUntil,\n} from '@open-wc/testing';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport { OverlayTrigger } from '..';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { spy } from 'sinon';\nimport { ActionButton } from '@spectrum-web-components/action-button';\n\ndescribe('Overlay Trigger - Hover', () => {\n it('displays `hover` declaratively', async () => {\n const openedSpy = spy();\n const closedSpy = spy();\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger\n placement=\"right-start\"\n open=\"hover\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"hover-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'hover content projected to overlay',\n { timeout: 2000 }\n );\n\n el.removeAttribute('open');\n await elementUpdated(el);\n\n await waitUntil(() => closedSpy.calledOnce, 'hover content returned', {\n timeout: 2000,\n });\n });\n it('persists hover content', async () => {\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"hover-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as ActionButton;\n trigger.dispatchEvent(\n new Event('mouseenter', {\n bubbles: true,\n })\n );\n\n await elementUpdated(el);\n\n expect(el.open).to.equal('hover');\n\n trigger.click();\n\n await elementUpdated(el);\n\n expect(el.open).to.equal('hover');\n });\n it('closes persistent hover content on `longpress`', async () => {\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"hover-content\" tip></sp-popover>\n <sp-popover slot=\"longpress-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as ActionButton;\n trigger.dispatchEvent(\n new Event('mouseenter', {\n bubbles: true,\n })\n );\n\n await elementUpdated(el);\n\n expect(el.open).to.equal('hover');\n\n trigger.dispatchEvent(\n new Event('longpress', {\n bubbles: true,\n })\n );\n\n await elementUpdated(el);\n\n expect(el.open).to.equal('longpress');\n });\n it('closes `hover` overlay when [type=\"modal\"]', async () => {\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger placement=\"right-start\" type=\"modal\">\n <sp-action-button slot=\"trigger\">\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"hover-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n expect(el.open).to.be.undefined;\n\n const trigger = el.querySelector('[slot=\"trigger\"]') as ActionButton;\n trigger.dispatchEvent(\n new Event('mouseenter', {\n bubbles: true,\n })\n );\n\n await elementUpdated(el);\n\n expect(el.open).to.equal('hover');\n\n trigger.dispatchEvent(\n new Event('mouseleave', {\n bubbles: true,\n })\n );\n\n await elementUpdated(el);\n\n expect(el.open).to.be.null;\n });\n});\n"]}