@spectrum-web-components/action-button 1.1.0 → 1.1.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.
Files changed (75) hide show
  1. package/package.json +7 -7
  2. package/sp-action-button.d.ts +6 -0
  3. package/sp-action-button.dev.js +5 -0
  4. package/sp-action-button.dev.js.map +7 -0
  5. package/sp-action-button.js +2 -0
  6. package/sp-action-button.js.map +7 -0
  7. package/src/ActionButton.d.ts +67 -0
  8. package/src/ActionButton.dev.js +229 -0
  9. package/src/ActionButton.dev.js.map +7 -0
  10. package/src/ActionButton.js +6 -0
  11. package/src/ActionButton.js.map +7 -0
  12. package/src/action-button-overrides.css.d.ts +2 -0
  13. package/src/action-button-overrides.css.dev.js +7 -0
  14. package/src/action-button-overrides.css.dev.js.map +7 -0
  15. package/src/action-button-overrides.css.js +4 -0
  16. package/src/action-button-overrides.css.js.map +7 -0
  17. package/src/action-button.css.d.ts +2 -0
  18. package/src/action-button.css.dev.js +7 -0
  19. package/src/action-button.css.dev.js.map +7 -0
  20. package/src/action-button.css.js +4 -0
  21. package/src/action-button.css.js.map +7 -0
  22. package/src/index.d.ts +1 -0
  23. package/src/index.dev.js +3 -0
  24. package/src/index.dev.js.map +7 -0
  25. package/src/index.js +2 -0
  26. package/src/index.js.map +7 -0
  27. package/src/spectrum-action-button.css.d.ts +2 -0
  28. package/src/spectrum-action-button.css.dev.js +7 -0
  29. package/src/spectrum-action-button.css.dev.js.map +7 -0
  30. package/src/spectrum-action-button.css.js +4 -0
  31. package/src/spectrum-action-button.css.js.map +7 -0
  32. package/stories/action-button-black-quiet.stories.js +41 -0
  33. package/stories/action-button-black-quiet.stories.js.map +7 -0
  34. package/stories/action-button-black.stories.js +35 -0
  35. package/stories/action-button-black.stories.js.map +7 -0
  36. package/stories/action-button-emphasized-quiet.stories.js +39 -0
  37. package/stories/action-button-emphasized-quiet.stories.js.map +7 -0
  38. package/stories/action-button-emphasized.stories.js +33 -0
  39. package/stories/action-button-emphasized.stories.js.map +7 -0
  40. package/stories/action-button-quiet.stories.js +33 -0
  41. package/stories/action-button-quiet.stories.js.map +7 -0
  42. package/stories/action-button-standard.stories.js +27 -0
  43. package/stories/action-button-standard.stories.js.map +7 -0
  44. package/stories/action-button-white-quiet.stories.js +41 -0
  45. package/stories/action-button-white-quiet.stories.js.map +7 -0
  46. package/stories/action-button-white.stories.js +35 -0
  47. package/stories/action-button-white.stories.js.map +7 -0
  48. package/stories/action-button.stories.js +38 -0
  49. package/stories/action-button.stories.js.map +7 -0
  50. package/stories/index.js +86 -0
  51. package/stories/index.js.map +7 -0
  52. package/test/action-button-black-quiet.test-vrt.js +5 -0
  53. package/test/action-button-black-quiet.test-vrt.js.map +7 -0
  54. package/test/action-button-black.test-vrt.js +5 -0
  55. package/test/action-button-black.test-vrt.js.map +7 -0
  56. package/test/action-button-emphasized-quiet.test-vrt.js +5 -0
  57. package/test/action-button-emphasized-quiet.test-vrt.js.map +7 -0
  58. package/test/action-button-emphasized.test-vrt.js +5 -0
  59. package/test/action-button-emphasized.test-vrt.js.map +7 -0
  60. package/test/action-button-memory.test.js +5 -0
  61. package/test/action-button-memory.test.js.map +7 -0
  62. package/test/action-button-quiet.test-vrt.js +5 -0
  63. package/test/action-button-quiet.test-vrt.js.map +7 -0
  64. package/test/action-button-standard.test-vrt.js +5 -0
  65. package/test/action-button-standard.test-vrt.js.map +7 -0
  66. package/test/action-button-white-quiet.test-vrt.js +5 -0
  67. package/test/action-button-white-quiet.test-vrt.js.map +7 -0
  68. package/test/action-button-white.test-vrt.js +5 -0
  69. package/test/action-button-white.test-vrt.js.map +7 -0
  70. package/test/action-button.test-vrt.js +5 -0
  71. package/test/action-button.test-vrt.js.map +7 -0
  72. package/test/action-button.test.js +273 -0
  73. package/test/action-button.test.js.map +7 -0
  74. package/test/benchmark/basic-test.js +19 -0
  75. package/test/benchmark/basic-test.js.map +7 -0
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import * as stories from "../stories/action-button-white-quiet.stories.js";
3
+ import { regressVisuals } from "../../../test/visual/test.js";
4
+ regressVisuals("ActionButtonWhiteQuietStories", stories);
5
+ //# sourceMappingURL=action-button-white-quiet.test-vrt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["action-button-white-quiet.test-vrt.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 * as stories from '../stories/action-button-white-quiet.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ActionButtonWhiteQuietStories', stories as unknown as TestsType);\n"],
5
+ "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,iCAAiC,OAA+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import * as stories from "../stories/action-button-white.stories.js";
3
+ import { regressVisuals } from "../../../test/visual/test.js";
4
+ regressVisuals("ActionButtonWhiteStories", stories);
5
+ //# sourceMappingURL=action-button-white.test-vrt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["action-button-white.test-vrt.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 * as stories from '../stories/action-button-white.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ActionButtonWhiteStories', stories as unknown as TestsType);\n"],
5
+ "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,4BAA4B,OAA+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import * as stories from "../stories/action-button.stories.js";
3
+ import { regressVisuals } from "../../../test/visual/test.js";
4
+ regressVisuals("ActionButtonStories", stories);
5
+ //# sourceMappingURL=action-button.test-vrt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["action-button.test-vrt.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 * as stories from '../stories/action-button.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ActionButtonStories', stories as unknown as TestsType);\n"],
5
+ "mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,uBAAuB,OAA+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ import "@spectrum-web-components/action-button/sp-action-button.js";
3
+ import {
4
+ LONGPRESS_DURATION
5
+ } from "@spectrum-web-components/action-button";
6
+ import {
7
+ aTimeout,
8
+ elementUpdated,
9
+ expect,
10
+ fixture,
11
+ html,
12
+ waitUntil
13
+ } from "@open-wc/testing";
14
+ import { sendKeys } from "@web/test-runner-commands";
15
+ import { spy } from "sinon";
16
+ import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
17
+ import { m as BlackActionButton } from "../stories/action-button-black.stories.js";
18
+ import { sendMouse } from "../../../test/plugins/browser.js";
19
+ describe("ActionButton", () => {
20
+ testForLitDevWarnings(
21
+ async () => await fixture(
22
+ BlackActionButton(BlackActionButton.args)
23
+ )
24
+ );
25
+ it("loads default", async () => {
26
+ const el = await fixture(html`
27
+ <sp-action-button>Button</sp-action-button>
28
+ `);
29
+ await elementUpdated(el);
30
+ expect(el).to.not.be.undefined;
31
+ expect(el.textContent).to.include("Button");
32
+ await expect(el).to.be.accessible();
33
+ });
34
+ it('gardens "value" as a property', async () => {
35
+ const el = await fixture(html`
36
+ <sp-action-button>Button</sp-action-button>
37
+ `);
38
+ await elementUpdated(el);
39
+ expect(el.hasAttribute("value")).to.be.false;
40
+ el.value = "Value";
41
+ await elementUpdated(el);
42
+ expect(el.hasAttribute("value")).to.be.true;
43
+ el.value = "";
44
+ await elementUpdated(el);
45
+ expect(el.hasAttribute("value")).to.be.false;
46
+ });
47
+ it("loads [hold-affordance]", async () => {
48
+ const el = await fixture(html`
49
+ <sp-action-button hold-affordance>Button</sp-action-button>
50
+ `);
51
+ await elementUpdated(el);
52
+ expect(el).to.not.be.undefined;
53
+ expect(el.textContent).to.include("Button");
54
+ await expect(el).to.be.accessible();
55
+ });
56
+ it("manages a `tabindex`", async () => {
57
+ const el = await fixture(html`
58
+ <sp-action-button>Button</sp-action-button>
59
+ `);
60
+ expect(el.tabIndex).to.equal(0);
61
+ expect(el.disabled).to.be.false;
62
+ el.setAttribute("tabindex", "-1");
63
+ await elementUpdated(el);
64
+ expect(el.tabIndex).to.equal(-1);
65
+ expect(el.disabled).to.be.false;
66
+ el.disabled = true;
67
+ await elementUpdated(el);
68
+ expect(el.tabIndex).to.equal(-1);
69
+ expect(el.disabled).to.be.true;
70
+ el.disabled = false;
71
+ await elementUpdated(el);
72
+ expect(el.tabIndex).to.equal(-1);
73
+ expect(el.disabled).to.be.false;
74
+ });
75
+ it("manages a `size` attribute", async () => {
76
+ const el = await fixture(html`
77
+ <sp-action-button size="xl">Button</sp-action-button>
78
+ `);
79
+ await elementUpdated(el);
80
+ expect(el.size).to.equal("xl");
81
+ expect(el.getAttribute("size")).to.equal("xl");
82
+ el.removeAttribute("size");
83
+ await elementUpdated(el);
84
+ expect(el.size).to.equal("m");
85
+ expect(el.hasAttribute("size")).to.be.false;
86
+ });
87
+ it("does not apply a default `size` attribute", async () => {
88
+ const el = await fixture(html`
89
+ <sp-action-button>Button</sp-action-button>
90
+ `);
91
+ await elementUpdated(el);
92
+ expect(el.size).to.equal("m");
93
+ expect(el.hasAttribute("size")).to.be.false;
94
+ });
95
+ it("dispatches `longpress` events when [hold-affordance]", async () => {
96
+ const longpressSpy = spy();
97
+ const el = await fixture(html`
98
+ <sp-action-button
99
+ hold-affordance
100
+ @longpress=${() => longpressSpy()}
101
+ >
102
+ Button
103
+ </sp-action-button>
104
+ `);
105
+ await elementUpdated(el);
106
+ el.focus();
107
+ await sendKeys({
108
+ press: "Space"
109
+ });
110
+ expect(longpressSpy.callCount).to.equal(1);
111
+ await sendKeys({
112
+ press: "Alt+ArrowDown"
113
+ });
114
+ expect(longpressSpy.callCount).to.equal(2);
115
+ el.dispatchEvent(new PointerEvent("pointerdown", { button: 0 }));
116
+ el.dispatchEvent(new PointerEvent("pointerup"));
117
+ el.dispatchEvent(new PointerEvent("pointerdown", { button: 0 }));
118
+ await waitUntil(() => longpressSpy.callCount === 3);
119
+ });
120
+ it('does not dispatch `longpress` events when "right click"ed', async () => {
121
+ const longpressSpy = spy();
122
+ const el = await fixture(html`
123
+ <sp-action-button
124
+ hold-affordance
125
+ @longpress=${() => longpressSpy()}
126
+ >
127
+ Button
128
+ </sp-action-button>
129
+ `);
130
+ await elementUpdated(el);
131
+ expect(longpressSpy.callCount).to.equal(0);
132
+ el.focus();
133
+ el.dispatchEvent(new PointerEvent("pointerdown", { button: 1 }));
134
+ await aTimeout(2 * LONGPRESS_DURATION);
135
+ expect(longpressSpy.callCount).to.equal(0);
136
+ });
137
+ it(":not([toggles])", async () => {
138
+ const el = await fixture(html`
139
+ <sp-action-button>Button</sp-action-button>
140
+ `);
141
+ await elementUpdated(el);
142
+ const button = el.focusElement;
143
+ expect(el.toggles).to.be.false;
144
+ expect(el.selected).to.be.false;
145
+ expect(button.hasAttribute("aria-pressed")).to.be.false;
146
+ el.click();
147
+ await elementUpdated(el);
148
+ expect(el.toggles).to.be.false;
149
+ expect(el.selected).to.be.false;
150
+ expect(button.hasAttribute("aria-pressed")).to.be.false;
151
+ });
152
+ it("responds to [selected]", async () => {
153
+ const el = await fixture(html`
154
+ <sp-action-button>Button</sp-action-button>
155
+ `);
156
+ await elementUpdated(el);
157
+ const button = el.focusElement;
158
+ expect(el.toggles).to.be.false;
159
+ expect(el.selected).to.be.false;
160
+ expect(button.hasAttribute("aria-pressed")).to.be.false;
161
+ el.selected = true;
162
+ await elementUpdated(el);
163
+ expect(el.toggles).to.be.false;
164
+ expect(el.selected).to.be.true;
165
+ expect(button.getAttribute("aria-pressed")).to.equal("true");
166
+ el.selected = false;
167
+ await elementUpdated(el);
168
+ expect(el.toggles).to.be.false;
169
+ expect(el.selected).to.be.false;
170
+ expect(button.hasAttribute("aria-pressed")).to.be.false;
171
+ });
172
+ it("toggles", async () => {
173
+ const el = await fixture(html`
174
+ <sp-action-button toggles>Button</sp-action-button>
175
+ `);
176
+ await elementUpdated(el);
177
+ const button = el.focusElement;
178
+ expect(el.toggles).to.be.true;
179
+ expect(el.selected).to.be.false;
180
+ expect(button.getAttribute("aria-pressed")).to.equal("false");
181
+ el.focus();
182
+ await sendKeys({
183
+ press: "Space"
184
+ });
185
+ await elementUpdated(el);
186
+ expect(el.toggles).to.be.true;
187
+ expect(el.selected).to.be.true;
188
+ expect(button.getAttribute("aria-pressed")).to.equal("true");
189
+ el.addEventListener("change", (event) => event.preventDefault());
190
+ el.click();
191
+ await elementUpdated(el);
192
+ expect(el.toggles).to.be.true;
193
+ expect(el.selected).to.be.true;
194
+ expect(button.getAttribute("aria-pressed")).to.equal("true");
195
+ });
196
+ it("toggles [aria-haspopup][aria-expanded]", async () => {
197
+ const el = await fixture(html`
198
+ <sp-action-button
199
+ toggles
200
+ aria-haspopup="true"
201
+ aria-expanded="false"
202
+ >
203
+ Button
204
+ </sp-action-button>
205
+ `);
206
+ await elementUpdated(el);
207
+ const button = el.focusElement;
208
+ expect(el.toggles).to.be.true;
209
+ expect(el.selected).to.be.false;
210
+ expect(button).not.to.have.attribute("aria-pressed");
211
+ expect(button).to.have.attribute("aria-haspopup", "true");
212
+ expect(button).to.have.attribute("aria-expanded", "false");
213
+ el.focus();
214
+ await sendKeys({
215
+ press: "Space"
216
+ });
217
+ await elementUpdated(el);
218
+ expect(el.toggles).to.be.true;
219
+ expect(el.selected).to.be.true;
220
+ expect(button).not.to.have.attribute("aria-pressed");
221
+ expect(button).to.have.attribute("aria-haspopup", "true");
222
+ expect(button).to.have.attribute("aria-expanded", "true");
223
+ el.addEventListener("change", (event) => event.preventDefault());
224
+ el.click();
225
+ await elementUpdated(el);
226
+ expect(el.toggles).to.be.true;
227
+ expect(el.selected).to.be.true;
228
+ expect(button).not.to.have.attribute("aria-pressed");
229
+ expect(button).to.have.attribute("aria-haspopup", "true");
230
+ expect(button).to.have.attribute("aria-expanded", "true");
231
+ });
232
+ it("manages a `static-color` attribute", async () => {
233
+ const el = await fixture(html`
234
+ <sp-action-button static-color="black">Button</sp-action-button>
235
+ `);
236
+ await elementUpdated(el);
237
+ expect(el.staticColor).to.equal("black");
238
+ expect(el.getAttribute("static-color")).to.equal("black");
239
+ el.removeAttribute("static-color");
240
+ await elementUpdated(el);
241
+ expect(el.staticColor).to.be.null;
242
+ expect(el.hasAttribute("static-color")).to.be.false;
243
+ });
244
+ it("allows link click", async () => {
245
+ var _a, _b;
246
+ let clicked = false;
247
+ const el = await fixture(html`
248
+ <sp-action-button href="#top" target="_blank">
249
+ With Target
250
+ </sp-action-button>
251
+ `);
252
+ await elementUpdated(el);
253
+ (_b = (_a = el.shadowRoot) == null ? void 0 : _a.querySelector(".anchor")) == null ? void 0 : _b.addEventListener("click", (event) => {
254
+ event.preventDefault();
255
+ clicked = true;
256
+ });
257
+ const rect = el.getBoundingClientRect();
258
+ await sendMouse({
259
+ steps: [
260
+ {
261
+ position: [
262
+ rect.left + rect.width / 2,
263
+ rect.top + rect.height / 2
264
+ ],
265
+ type: "click"
266
+ }
267
+ ]
268
+ });
269
+ await elementUpdated(el);
270
+ expect(clicked).to.be.true;
271
+ });
272
+ });
273
+ //# sourceMappingURL=action-button.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["action-button.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/action-button/sp-action-button.js';\nimport {\n ActionButton,\n LONGPRESS_DURATION,\n} from '@spectrum-web-components/action-button';\nimport {\n aTimeout,\n elementUpdated,\n expect,\n fixture,\n html,\n waitUntil,\n} from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { spy } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { m as BlackActionButton } from '../stories/action-button-black.stories.js';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\ndescribe('ActionButton', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<ActionButton>(\n BlackActionButton(BlackActionButton.args)\n )\n );\n it('loads default', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n expect(el.textContent).to.include('Button');\n await expect(el).to.be.accessible();\n });\n it('gardens \"value\" as a property', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el.hasAttribute('value')).to.be.false;\n el.value = 'Value';\n await elementUpdated(el);\n expect(el.hasAttribute('value')).to.be.true;\n el.value = '';\n await elementUpdated(el);\n expect(el.hasAttribute('value')).to.be.false;\n });\n it('loads [hold-affordance]', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button hold-affordance>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n expect(el.textContent).to.include('Button');\n await expect(el).to.be.accessible();\n });\n it('manages a `tabindex`', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n expect(el.tabIndex).to.equal(0);\n expect(el.disabled).to.be.false;\n\n el.setAttribute('tabindex', '-1');\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(-1);\n expect(el.disabled).to.be.false;\n\n el.disabled = true;\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(-1);\n expect(el.disabled).to.be.true;\n\n el.disabled = false;\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(-1);\n expect(el.disabled).to.be.false;\n });\n it('manages a `size` attribute', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button size=\"xl\">Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el.size).to.equal('xl');\n expect(el.getAttribute('size')).to.equal('xl');\n el.removeAttribute('size');\n await elementUpdated(el);\n expect(el.size).to.equal('m');\n expect(el.hasAttribute('size')).to.be.false;\n });\n it('does not apply a default `size` attribute', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el.size).to.equal('m');\n expect(el.hasAttribute('size')).to.be.false;\n });\n it('dispatches `longpress` events when [hold-affordance]', async () => {\n const longpressSpy = spy();\n const el = await fixture<ActionButton>(html`\n <sp-action-button\n hold-affordance\n @longpress=${() => longpressSpy()}\n >\n Button\n </sp-action-button>\n `);\n\n await elementUpdated(el);\n\n el.focus();\n await sendKeys({\n press: 'Space',\n });\n\n expect(longpressSpy.callCount).to.equal(1);\n await sendKeys({\n press: 'Alt+ArrowDown',\n });\n\n expect(longpressSpy.callCount).to.equal(2);\n el.dispatchEvent(new PointerEvent('pointerdown', { button: 0 }));\n el.dispatchEvent(new PointerEvent('pointerup'));\n el.dispatchEvent(new PointerEvent('pointerdown', { button: 0 }));\n await waitUntil(() => longpressSpy.callCount === 3);\n });\n it('does not dispatch `longpress` events when \"right click\"ed', async () => {\n const longpressSpy = spy();\n const el = await fixture<ActionButton>(html`\n <sp-action-button\n hold-affordance\n @longpress=${() => longpressSpy()}\n >\n Button\n </sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(longpressSpy.callCount).to.equal(0);\n\n el.focus();\n el.dispatchEvent(new PointerEvent('pointerdown', { button: 1 }));\n await aTimeout(2 * LONGPRESS_DURATION);\n expect(longpressSpy.callCount).to.equal(0);\n });\n it(':not([toggles])', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n const button = el.focusElement;\n\n expect(el.toggles).to.be.false;\n expect(el.selected).to.be.false;\n expect(button.hasAttribute('aria-pressed')).to.be.false;\n\n el.click();\n await elementUpdated(el);\n\n expect(el.toggles).to.be.false;\n expect(el.selected).to.be.false;\n expect(button.hasAttribute('aria-pressed')).to.be.false;\n });\n it('responds to [selected]', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n const button = el.focusElement;\n\n expect(el.toggles).to.be.false;\n expect(el.selected).to.be.false;\n expect(button.hasAttribute('aria-pressed')).to.be.false;\n\n el.selected = true;\n await elementUpdated(el);\n\n expect(el.toggles).to.be.false;\n expect(el.selected).to.be.true;\n expect(button.getAttribute('aria-pressed')).to.equal('true');\n\n el.selected = false;\n await elementUpdated(el);\n\n expect(el.toggles).to.be.false;\n expect(el.selected).to.be.false;\n expect(button.hasAttribute('aria-pressed')).to.be.false;\n });\n it('toggles', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button toggles>Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n const button = el.focusElement;\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.false;\n expect(button.getAttribute('aria-pressed')).to.equal('false');\n\n el.focus();\n await sendKeys({\n press: 'Space',\n });\n await elementUpdated(el);\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.true;\n expect(button.getAttribute('aria-pressed')).to.equal('true');\n\n el.addEventListener('change', (event: Event) => event.preventDefault());\n el.click();\n await elementUpdated(el);\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.true;\n expect(button.getAttribute('aria-pressed')).to.equal('true');\n });\n it('toggles [aria-haspopup][aria-expanded]', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button\n toggles\n aria-haspopup=\"true\"\n aria-expanded=\"false\"\n >\n Button\n </sp-action-button>\n `);\n\n await elementUpdated(el);\n const button = el.focusElement;\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.false;\n expect(button).not.to.have.attribute('aria-pressed');\n expect(button).to.have.attribute('aria-haspopup', 'true');\n expect(button).to.have.attribute('aria-expanded', 'false');\n\n el.focus();\n await sendKeys({\n press: 'Space',\n });\n await elementUpdated(el);\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.true;\n expect(button).not.to.have.attribute('aria-pressed');\n expect(button).to.have.attribute('aria-haspopup', 'true');\n expect(button).to.have.attribute('aria-expanded', 'true');\n\n el.addEventListener('change', (event: Event) => event.preventDefault());\n el.click();\n await elementUpdated(el);\n\n expect(el.toggles).to.be.true;\n expect(el.selected).to.be.true;\n expect(button).not.to.have.attribute('aria-pressed');\n expect(button).to.have.attribute('aria-haspopup', 'true');\n expect(button).to.have.attribute('aria-expanded', 'true');\n });\n it('manages a `static-color` attribute', async () => {\n const el = await fixture<ActionButton>(html`\n <sp-action-button static-color=\"black\">Button</sp-action-button>\n `);\n\n await elementUpdated(el);\n expect(el.staticColor).to.equal('black');\n expect(el.getAttribute('static-color')).to.equal('black');\n el.removeAttribute('static-color');\n await elementUpdated(el);\n expect(el.staticColor).to.be.null;\n expect(el.hasAttribute('static-color')).to.be.false;\n });\n it('allows link click', async () => {\n let clicked = false;\n const el = await fixture<ActionButton>(html`\n <sp-action-button href=\"#top\" target=\"_blank\">\n With Target\n </sp-action-button>\n `);\n\n await elementUpdated(el);\n\n // prevents browser from activating link but records the proxy click\n el.shadowRoot\n ?.querySelector('.anchor')\n ?.addEventListener('click', (event: Event) => {\n event.preventDefault();\n clicked = true;\n });\n const rect = el.getBoundingClientRect();\n\n // tests mouse click events, and by extension VoiceOver CRTL+Option+Space click\n await sendMouse({\n steps: [\n {\n position: [\n rect.left + rect.width / 2,\n rect.top + rect.height / 2,\n ],\n type: 'click',\n },\n ],\n });\n await elementUpdated(el);\n expect(clicked).to.be.true;\n });\n});\n"],
5
+ "mappings": ";AAYA,OAAO;AACP;AAAA,EAEI;AAAA,OACG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,SAAS,6BAA6B;AACtC,SAAS,KAAK,yBAAyB;AACvC,SAAS,iBAAiB;AAE1B,SAAS,gBAAgB,MAAM;AAC3B;AAAA,IACI,YACI,MAAM;AAAA,MACF,kBAAkB,kBAAkB,IAAI;AAAA,IAC5C;AAAA,EACR;AACA,KAAG,iBAAiB,YAAY;AAC5B,UAAM,KAAK,MAAM,QAAsB;AAAA;AAAA,SAEt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AAAA;AAAA,SAEtC;AAED,UAAM,eAAe,EAAE;AACvB,WAAO,GAAG,WAAW,EAAE,GAAG,MAAM,OAAO;AACvC,WAAO,GAAG,aAAa,cAAc,CAAC,EAAE,GAAG,MAAM,OAAO;AACxD,OAAG,gBAAgB,cAAc;AACjC,UAAM,eAAe,EAAE;AACvB,WAAO,GAAG,WAAW,EAAE,GAAG,GAAG;AAC7B,WAAO,GAAG,aAAa,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EAClD,CAAC;AACD,KAAG,qBAAqB,YAAY;AA1SxC;AA2SQ,QAAI,UAAU;AACd,UAAM,KAAK,MAAM,QAAsB;AAAA;AAAA;AAAA;AAAA,SAItC;AAED,UAAM,eAAe,EAAE;AAGvB,mBAAG,eAAH,mBACM,cAAc,eADpB,mBAEM,iBAAiB,SAAS,CAAC,UAAiB;AAC1C,YAAM,eAAe;AACrB,gBAAU;AAAA,IACd;AACJ,UAAM,OAAO,GAAG,sBAAsB;AAGtC,UAAM,UAAU;AAAA,MACZ,OAAO;AAAA,QACH;AAAA,UACI,UAAU;AAAA,YACN,KAAK,OAAO,KAAK,QAAQ;AAAA,YACzB,KAAK,MAAM,KAAK,SAAS;AAAA,UAC7B;AAAA,UACA,MAAM;AAAA,QACV;AAAA,MACJ;AAAA,IACJ,CAAC;AACD,UAAM,eAAe,EAAE;AACvB,WAAO,OAAO,EAAE,GAAG,GAAG;AAAA,EAC1B,CAAC;AACL,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ import "@spectrum-web-components/action-button/sp-action-button.js";
3
+ import "@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js";
4
+ import { html } from "lit";
5
+ import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
6
+ measureFixtureCreation(html`
7
+ <sp-action-button>Edit</sp-action-button>
8
+ <sp-action-button>
9
+ <sp-icon-edit slot="icon"></sp-icon-edit>
10
+ Edit
11
+ </sp-action-button>
12
+ <sp-action-button>
13
+ <sp-icon-edit slot="icon"></sp-icon-edit>
14
+ </sp-action-button>
15
+ <sp-action-button hold-affordance>
16
+ <sp-icon-edit slot="icon"></sp-icon-edit>
17
+ </sp-action-button>
18
+ `);
19
+ //# sourceMappingURL=basic-test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["basic-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/action-button/sp-action-button.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-action-button>Edit</sp-action-button>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n Edit\n </sp-action-button>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n </sp-action-button>\n <sp-action-button hold-affordance>\n <sp-icon-edit slot=\"icon\"></sp-icon-edit>\n </sp-action-button>\n`);\n"],
5
+ "mappings": ";AAYA,OAAO;AACP,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAYtB;",
6
+ "names": []
7
+ }