@spectrum-web-components/overlay 0.13.0 → 0.13.1

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,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,EA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AC;QAC/C,MAAM,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,E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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,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"]}
@@ -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, oneEvent, waitUntil, } from '@open-wc/testing';
13
- import '@spectrum-web-components/action-button/sp-action-button.js';
14
- import '@spectrum-web-components/action-group/sp-action-group.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 { sendKeys } from '@web/test-runner-commands';
19
- import { spy } from 'sinon';
20
- describe('Overlay Trigger - Longpress', () => {
21
- it('displays `longpress` content', async () => {
22
- const el = await fixture((() => html `
23
- <overlay-trigger placement="right-start">
24
- <sp-action-button slot="trigger" hold-affordance>
25
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
26
- </sp-action-button>
27
- <sp-popover slot="longpress-content" tip>
28
- <sp-action-group
29
- selects="single"
30
- vertical
31
- style="margin: calc(var(--spectrum-actiongroup-button-gap-y,var(--spectrum-global-dimension-size-100)) / 2);"
32
- >
33
- <sp-action-button>
34
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
35
- </sp-action-button>
36
- <sp-action-button>
37
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
38
- </sp-action-button>
39
- <sp-action-button>
40
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
41
- </sp-action-button>
42
- </sp-action-group>
43
- </sp-popover>
44
- </overlay-trigger>
45
- `)());
46
- await elementUpdated(el);
47
- const trigger = el.querySelector('sp-action-button');
48
- const content = el.querySelector('[slot="longpress-content"]');
49
- expect(trigger).to.not.be.null;
50
- expect(content).to.not.be.null;
51
- expect(content.open).to.be.false;
52
- trigger.focus();
53
- let open = oneEvent(el, 'sp-opened');
54
- await sendKeys({
55
- press: 'Space',
56
- });
57
- await open;
58
- expect(content.open, 'opens for `Space`').to.be.true;
59
- let closed = oneEvent(el, 'sp-closed');
60
- document.body.click();
61
- await closed;
62
- expect(!content.open, 'closes for `Space`').to.be.true;
63
- trigger.focus();
64
- open = oneEvent(el, 'sp-opened');
65
- sendKeys({
66
- press: 'Alt+ArrowDown',
67
- });
68
- await open;
69
- expect(content.open, 'opens for `Alt+ArrowDown`').to.be.true;
70
- closed = oneEvent(el, 'sp-closed');
71
- await sendKeys({
72
- press: 'Escape',
73
- });
74
- await closed;
75
- expect(!content.open, 'closes for `Alt+ArrowDown`').to.be.true;
76
- await elementUpdated(el);
77
- open = oneEvent(el, 'sp-opened');
78
- trigger.dispatchEvent(new Event('pointerdown'));
79
- await open;
80
- expect(content.open, 'opens for `pointerdown`').to.be.true;
81
- closed = oneEvent(el, 'sp-closed');
82
- await sendKeys({
83
- press: 'Escape',
84
- });
85
- await closed;
86
- expect(!content.open, 'closes for `pointerdown`').to.be.true;
87
- });
88
- it('displays `longpress` declaratively', async () => {
89
- const openedSpy = spy();
90
- const closedSpy = spy();
91
- const el = await fixture((() => html `
92
- <overlay-trigger
93
- placement="right-start"
94
- open="longpress"
95
- @sp-opened=${() => openedSpy()}
96
- @sp-closed=${() => closedSpy()}
97
- >
98
- <sp-action-button slot="trigger" hold-affordance>
99
- <sp-icon-magnify slot="icon"></sp-icon-magnify>
100
- </sp-action-button>
101
- <sp-popover slot="longpress-content" tip></sp-popover>
102
- </overlay-trigger>
103
- `)());
104
- await elementUpdated(el);
105
- await waitUntil(() => openedSpy.calledOnce, 'longpress content projected to overlay', { timeout: 2000 });
106
- const closed = oneEvent(el, 'sp-closed');
107
- el.removeAttribute('open');
108
- await closed;
109
- expect(closedSpy.calledOnce, 'longpress content returned').to.be.true;
110
- });
111
- });
112
- //# sourceMappingURL=overlay-trigger-longpress.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay-trigger-longpress.test.js","sourceRoot":"","sources":["overlay-trigger-longpress.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,SAAS,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,4DAA4D,CAAC;AACpE,OAAO,0DAA0D,CAAC;AAClE,OAAO,kEAAkE,CAAC;AAE1E,OAAO,gDAAgD,CAAC;AAExD,OAAO,qDAAqD,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,CAAC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AE;;;;;;;aAOrC,CAAC,EAAE,CACP,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,SAAS,CACX,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAC1B,wCAAwC,EACxC,EAAE,OAAO,EAAE,IAAI,EAAE,CACpB,CAAC;QAEF,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QACzC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,CAAC;QAEb,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC1E,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 { ActionButton } from '@spectrum-web-components/action-button';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/action-group/sp-action-group.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';\nimport { Popover } from '@spectrum-web-components/popover';\nimport '@spectrum-web-components/popover/sp-popover.js';\nimport { OverlayTrigger } from '..';\nimport '@spectrum-web-components/overlay/overlay-trigger.js';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { spy } from 'sinon';\n\ndescribe('Overlay Trigger - Longpress', () => {\n it('displays `longpress` content', async () => {\n const el = await fixture<OverlayTrigger>(\n (() => html`\n <overlay-trigger placement=\"right-start\">\n <sp-action-button slot=\"trigger\" hold-affordance>\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"longpress-content\" tip>\n <sp-action-group\n selects=\"single\"\n vertical\n style=\"margin: calc(var(--spectrum-actiongroup-button-gap-y,var(--spectrum-global-dimension-size-100)) / 2);\"\n >\n <sp-action-button>\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n </sp-action-group>\n </sp-popover>\n </overlay-trigger>\n `)()\n );\n\n await elementUpdated(el);\n\n const trigger = el.querySelector('sp-action-button') as ActionButton;\n const content = el.querySelector(\n '[slot=\"longpress-content\"]'\n ) as Popover;\n\n expect(trigger).to.not.be.null;\n expect(content).to.not.be.null;\n expect(content.open).to.be.false;\n\n trigger.focus();\n let open = oneEvent(el, 'sp-opened');\n await sendKeys({\n press: 'Space',\n });\n await open;\n expect(content.open, 'opens for `Space`').to.be.true;\n\n let closed = oneEvent(el, 'sp-closed');\n document.body.click();\n await closed;\n\n expect(!content.open, 'closes for `Space`').to.be.true;\n\n trigger.focus();\n open = oneEvent(el, 'sp-opened');\n sendKeys({\n press: 'Alt+ArrowDown',\n });\n await open;\n expect(content.open, 'opens for `Alt+ArrowDown`').to.be.true;\n closed = oneEvent(el, 'sp-closed');\n await sendKeys({\n press: 'Escape',\n });\n await closed;\n expect(!content.open, 'closes for `Alt+ArrowDown`').to.be.true;\n await elementUpdated(el);\n\n open = oneEvent(el, 'sp-opened');\n trigger.dispatchEvent(new Event('pointerdown'));\n await open;\n expect(content.open, 'opens for `pointerdown`').to.be.true;\n closed = oneEvent(el, 'sp-closed');\n await sendKeys({\n press: 'Escape',\n });\n await closed;\n expect(!content.open, 'closes for `pointerdown`').to.be.true;\n });\n it('displays `longpress` 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=\"longpress\"\n @sp-opened=${() => openedSpy()}\n @sp-closed=${() => closedSpy()}\n >\n <sp-action-button slot=\"trigger\" hold-affordance>\n <sp-icon-magnify slot=\"icon\"></sp-icon-magnify>\n </sp-action-button>\n <sp-popover slot=\"longpress-content\" tip></sp-popover>\n </overlay-trigger>\n `)()\n );\n await elementUpdated(el);\n\n await waitUntil(\n () => openedSpy.calledOnce,\n 'longpress content projected to overlay',\n { timeout: 2000 }\n );\n\n const closed = oneEvent(el, 'sp-closed');\n el.removeAttribute('open');\n await closed;\n\n expect(closedSpy.calledOnce, 'longpress content returned').to.be.true;\n });\n});\n"]}