@spectrum-web-components/menu 0.40.2 → 0.40.4

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 (54) hide show
  1. package/custom-elements.json +102 -0
  2. package/package.json +11 -11
  3. package/src/Menu.d.ts +3 -0
  4. package/src/Menu.dev.js +17 -0
  5. package/src/Menu.dev.js.map +2 -2
  6. package/src/Menu.js +1 -1
  7. package/src/Menu.js.map +2 -2
  8. package/src/menu-divider.css.dev.js +35 -1
  9. package/src/menu-divider.css.dev.js.map +2 -2
  10. package/src/menu-divider.css.js +35 -1
  11. package/src/menu-divider.css.js.map +2 -2
  12. package/src/menu-group.css.dev.js +35 -1
  13. package/src/menu-group.css.dev.js.map +2 -2
  14. package/src/menu-group.css.js +35 -1
  15. package/src/menu-group.css.js.map +2 -2
  16. package/src/menu-item.css.dev.js +74 -32
  17. package/src/menu-item.css.dev.js.map +2 -2
  18. package/src/menu-item.css.js +76 -34
  19. package/src/menu-item.css.js.map +2 -2
  20. package/src/menu.css.dev.js +45 -3
  21. package/src/menu.css.dev.js.map +2 -2
  22. package/src/menu.css.js +45 -3
  23. package/src/menu.css.js.map +2 -2
  24. package/src/spectrum-checkmark.css.dev.js +38 -4
  25. package/src/spectrum-checkmark.css.dev.js.map +2 -2
  26. package/src/spectrum-checkmark.css.js +38 -4
  27. package/src/spectrum-checkmark.css.js.map +2 -2
  28. package/src/spectrum-chevron.css.dev.js +36 -2
  29. package/src/spectrum-chevron.css.dev.js.map +2 -2
  30. package/src/spectrum-chevron.css.js +38 -4
  31. package/src/spectrum-chevron.css.js.map +2 -2
  32. package/src/spectrum-config.js +23 -0
  33. package/src/spectrum-itemLabel.css.dev.js.map +1 -1
  34. package/src/spectrum-itemLabel.css.js.map +1 -1
  35. package/src/spectrum-menu-divider.css.dev.js +35 -1
  36. package/src/spectrum-menu-divider.css.dev.js.map +2 -2
  37. package/src/spectrum-menu-divider.css.js +35 -1
  38. package/src/spectrum-menu-divider.css.js.map +2 -2
  39. package/src/spectrum-menu-item.css.dev.js +58 -30
  40. package/src/spectrum-menu-item.css.dev.js.map +2 -2
  41. package/src/spectrum-menu-item.css.js +60 -32
  42. package/src/spectrum-menu-item.css.js.map +2 -2
  43. package/src/spectrum-menu-sectionHeading.css.dev.js +35 -1
  44. package/src/spectrum-menu-sectionHeading.css.dev.js.map +2 -2
  45. package/src/spectrum-menu-sectionHeading.css.js +35 -1
  46. package/src/spectrum-menu-sectionHeading.css.js.map +2 -2
  47. package/src/spectrum-menu.css.dev.js +45 -3
  48. package/src/spectrum-menu.css.dev.js.map +2 -2
  49. package/src/spectrum-menu.css.js +45 -3
  50. package/src/spectrum-menu.css.js.map +2 -2
  51. package/test/menu-selects.test.js +24 -41
  52. package/test/menu-selects.test.js.map +2 -2
  53. package/test/submenu.test.js +52 -79
  54. package/test/submenu.test.js.map +2 -2
@@ -5,65 +5,23 @@ import {
5
5
  aTimeout,
6
6
  elementUpdated,
7
7
  expect,
8
- fixture,
9
8
  html,
10
9
  nextFrame,
11
10
  oneEvent
12
11
  } from "@open-wc/testing";
13
- import "@spectrum-web-components/theme/sp-theme.js";
14
- import "@spectrum-web-components/theme/src/themes.js";
12
+ import { fixture } from "../../../test/testing-helpers.js";
15
13
  import { sendMouse } from "../../../test/plugins/browser.js";
16
14
  import { spy } from "sinon";
17
15
  import { sendKeys } from "@web/test-runner-commands";
18
16
  import "@spectrum-web-components/action-menu/sp-action-menu.js";
19
17
  import "@spectrum-web-components/menu/sp-menu-group.js";
18
+ import "@spectrum-web-components/overlay/sp-overlay.js";
20
19
  import "@spectrum-web-components/icons-workflow/icons/sp-icon-show-menu.js";
21
- import { isWebKit } from "@spectrum-web-components/shared";
22
- async function styledFixture(story, dir = "ltr") {
23
- const test = await fixture(html`
24
- <sp-theme dir=${dir} scale="medium" color="dark">
25
- ${story}
26
- <style>
27
- sp-theme {
28
- --spectrum-global-animation-duration-100: 50ms;
29
- --spectrum-global-animation-duration-200: 50ms;
30
- --spectrum-global-animation-duration-300: 50ms;
31
- --spectrum-global-animation-duration-400: 50ms;
32
- --spectrum-global-animation-duration-500: 50ms;
33
- --spectrum-global-animation-duration-600: 50ms;
34
- --spectrum-global-animation-duration-700: 50ms;
35
- --spectrum-global-animation-duration-800: 50ms;
36
- --spectrum-global-animation-duration-900: 50ms;
37
- --spectrum-global-animation-duration-1000: 50ms;
38
- --spectrum-global-animation-duration-2000: 50ms;
39
- --spectrum-global-animation-duration-4000: 50ms;
40
- --spectrum-animation-duration-0: 50ms;
41
- --spectrum-animation-duration-100: 50ms;
42
- --spectrum-animation-duration-200: 50ms;
43
- --spectrum-animation-duration-300: 50ms;
44
- --spectrum-animation-duration-400: 50ms;
45
- --spectrum-animation-duration-500: 50ms;
46
- --spectrum-animation-duration-600: 50ms;
47
- --spectrum-animation-duration-700: 50ms;
48
- --spectrum-animation-duration-800: 50ms;
49
- --spectrum-animation-duration-900: 50ms;
50
- --spectrum-animation-duration-1000: 50ms;
51
- --spectrum-animation-duration-2000: 50ms;
52
- --spectrum-animation-duration-4000: 50ms;
53
- --spectrum-coachmark-animation-indicator-ring-duration: 50ms;
54
- --swc-test-duration: 1ms;
55
- }
56
- </style>
57
- </sp-theme>
58
- `);
59
- document.documentElement.dir = dir;
60
- return test.children[0];
61
- }
62
20
  describe("Submenu", () => {
63
21
  it("selects - pointer", async () => {
64
22
  const rootChanged = spy();
65
23
  const submenuChanged = spy();
66
- const el = await styledFixture(
24
+ const el = await fixture(
67
25
  html`
68
26
  <sp-menu
69
27
  @change=${(event) => {
@@ -99,7 +57,7 @@ describe("Submenu", () => {
99
57
  const rootItemBoundingRect = rootItem.getBoundingClientRect();
100
58
  expect(rootItem.open).to.be.false;
101
59
  const opened = oneEvent(rootItem, "sp-opened");
102
- sendMouse({
60
+ await sendMouse({
103
61
  steps: [
104
62
  {
105
63
  type: "move",
@@ -115,7 +73,7 @@ describe("Submenu", () => {
115
73
  const item2 = document.querySelector(".submenu-item-2");
116
74
  const item2BoundingRect = item2.getBoundingClientRect();
117
75
  const closed = oneEvent(rootItem, "sp-closed");
118
- sendMouse({
76
+ await sendMouse({
119
77
  steps: [
120
78
  {
121
79
  type: "click",
@@ -127,14 +85,17 @@ describe("Submenu", () => {
127
85
  ]
128
86
  });
129
87
  await closed;
130
- expect(submenuChanged.withArgs("Two").calledOnce, "submenu changed").to.be.true;
88
+ expect(
89
+ submenuChanged.withArgs("Two").calledOnce,
90
+ `submenu changed ${submenuChanged.callCount} times`
91
+ ).to.be.true;
131
92
  expect(rootChanged.withArgs("Has submenu").calledOnce, "root changed").to.be.true;
132
93
  });
133
- it("closes deep tree on selection", async () => {
94
+ it("closes deep tree on selection", async function() {
134
95
  const rootChanged = spy();
135
96
  const submenuChanged = spy();
136
97
  const subSubmenuChanged = spy();
137
- const el = await styledFixture(
98
+ const el = await fixture(
138
99
  html`
139
100
  <sp-menu
140
101
  @change=${(event) => {
@@ -185,7 +146,7 @@ describe("Submenu", () => {
185
146
  const itemC = document.querySelector(".sub-submenu-item-3");
186
147
  expect(rootItem.open).to.be.false;
187
148
  let opened = oneEvent(rootItem, "sp-opened");
188
- sendMouse({
149
+ await sendMouse({
189
150
  steps: [
190
151
  {
191
152
  type: "move",
@@ -200,10 +161,10 @@ describe("Submenu", () => {
200
161
  expect(rootItem.open).to.be.true;
201
162
  const item2BoundingRect = item2.getBoundingClientRect();
202
163
  opened = oneEvent(item2, "sp-opened");
203
- sendMouse({
164
+ await sendMouse({
204
165
  steps: [
205
166
  {
206
- type: "click",
167
+ type: "move",
207
168
  position: [
208
169
  item2BoundingRect.left + item2BoundingRect.width / 2,
209
170
  item2BoundingRect.top + item2BoundingRect.height / 2
@@ -214,7 +175,18 @@ describe("Submenu", () => {
214
175
  await opened;
215
176
  expect(item2.open).to.be.true;
216
177
  const closed = oneEvent(rootItem, "sp-closed");
217
- itemC.click();
178
+ const itemCBoundingRect = itemC.getBoundingClientRect();
179
+ await sendMouse({
180
+ steps: [
181
+ {
182
+ type: "click",
183
+ position: [
184
+ itemCBoundingRect.left + itemCBoundingRect.width / 2,
185
+ itemCBoundingRect.top + itemCBoundingRect.height / 2
186
+ ]
187
+ }
188
+ ]
189
+ });
218
190
  await closed;
219
191
  expect(rootChanged.calledWith("Has submenu"), "root changed").to.be.true;
220
192
  expect(submenuChanged.calledWith("Two"), "submenu changed").to.be.true;
@@ -236,7 +208,7 @@ describe("Submenu", () => {
236
208
  var _a, _b;
237
209
  const rootChanged = spy();
238
210
  const submenuChanged = spy();
239
- const el = await styledFixture(
211
+ const el = await fixture(
240
212
  html`
241
213
  <sp-menu
242
214
  id="base"
@@ -323,7 +295,7 @@ describe("Submenu", () => {
323
295
  });
324
296
  });
325
297
  it("closes on `pointerleave`", async () => {
326
- const el = await styledFixture(
298
+ const el = await fixture(
327
299
  html`
328
300
  <sp-menu>
329
301
  <sp-menu-item class="root">
@@ -348,7 +320,7 @@ describe("Submenu", () => {
348
320
  const rootItemBoundingRect = rootItem.getBoundingClientRect();
349
321
  expect(rootItem.open).to.be.false;
350
322
  const opened = oneEvent(rootItem, "sp-opened");
351
- sendMouse({
323
+ await sendMouse({
352
324
  steps: [
353
325
  {
354
326
  type: "move",
@@ -362,7 +334,7 @@ describe("Submenu", () => {
362
334
  await opened;
363
335
  expect(rootItem.open).to.be.true;
364
336
  const closed = oneEvent(rootItem, "sp-closed");
365
- sendMouse({
337
+ await sendMouse({
366
338
  steps: [
367
339
  {
368
340
  type: "move",
@@ -377,7 +349,7 @@ describe("Submenu", () => {
377
349
  expect(rootItem.open).to.be.false;
378
350
  });
379
351
  it("stays open when mousing off menu item and back again", async () => {
380
- const el = await styledFixture(
352
+ const el = await fixture(
381
353
  html`
382
354
  <sp-menu>
383
355
  <sp-menu-item class="root">
@@ -438,7 +410,7 @@ describe("Submenu", () => {
438
410
  await opened;
439
411
  expect(rootItem.open).to.be.true;
440
412
  const closed = oneEvent(rootItem, "sp-closed");
441
- sendMouse({
413
+ await sendMouse({
442
414
  steps: [
443
415
  {
444
416
  type: "move",
@@ -451,9 +423,9 @@ describe("Submenu", () => {
451
423
  });
452
424
  await closed;
453
425
  });
454
- it("continues to open when mousing between menu item and submenu", async () => {
426
+ it("continues to open when mousing between menu item and submenu", async function() {
455
427
  const clickSpy = spy();
456
- const el = await styledFixture(
428
+ const el = await fixture(
457
429
  html`
458
430
  <sp-menu>
459
431
  <sp-menu-item class="root">
@@ -495,6 +467,12 @@ describe("Submenu", () => {
495
467
  });
496
468
  await nextFrame();
497
469
  await nextFrame();
470
+ await nextFrame();
471
+ await nextFrame();
472
+ await nextFrame();
473
+ await nextFrame();
474
+ await nextFrame();
475
+ await nextFrame();
498
476
  const subItemBoundingRect = subItem.getBoundingClientRect();
499
477
  await sendMouse({
500
478
  steps: [
@@ -512,7 +490,7 @@ describe("Submenu", () => {
512
490
  await aTimeout(150);
513
491
  expect(rootItem.open).to.be.true;
514
492
  const closed = oneEvent(rootItem, "sp-closed");
515
- sendMouse({
493
+ await sendMouse({
516
494
  steps: [
517
495
  {
518
496
  type: "click",
@@ -528,7 +506,7 @@ describe("Submenu", () => {
528
506
  });
529
507
  it("stays open when mousing between menu item and submenu", async () => {
530
508
  const clickSpy = spy();
531
- const el = await styledFixture(
509
+ const el = await fixture(
532
510
  html`
533
511
  <sp-menu>
534
512
  <sp-menu-item class="root">
@@ -588,7 +566,7 @@ describe("Submenu", () => {
588
566
  await aTimeout(150);
589
567
  expect(rootItem.open).to.be.true;
590
568
  const closed = oneEvent(rootItem, "sp-closed");
591
- sendMouse({
569
+ await sendMouse({
592
570
  steps: [
593
571
  {
594
572
  type: "click",
@@ -603,7 +581,7 @@ describe("Submenu", () => {
603
581
  expect(clickSpy.callCount).to.equal(1);
604
582
  });
605
583
  it("not opens if disabled", async () => {
606
- const el = await styledFixture(
584
+ const el = await fixture(
607
585
  html`
608
586
  <sp-menu>
609
587
  <sp-menu-item disabled class="root">
@@ -627,7 +605,7 @@ describe("Submenu", () => {
627
605
  const rootItem = el.querySelector(".root");
628
606
  const rootItemBoundingRect = rootItem.getBoundingClientRect();
629
607
  expect(rootItem.open).to.be.false;
630
- sendMouse({
608
+ await sendMouse({
631
609
  steps: [
632
610
  {
633
611
  type: "move",
@@ -642,7 +620,7 @@ describe("Submenu", () => {
642
620
  expect(rootItem.open).to.be.false;
643
621
  });
644
622
  it("closes all decendent submenus when closing a ancestor menu", async () => {
645
- const el = await styledFixture(html`
623
+ const el = await fixture(html`
646
624
  <sp-action-menu>
647
625
  <sp-icon-show-menu slot="icon"></sp-icon-show-menu>
648
626
  <sp-menu-group role="none" id="group">
@@ -712,10 +690,7 @@ describe("Submenu", () => {
712
690
  await rootMenu2Opened;
713
691
  });
714
692
  it("closes back to the first overlay without a `root` when clicking away", async function() {
715
- if (isWebKit()) {
716
- this.skip();
717
- }
718
- const el = await styledFixture(html`
693
+ const el = await fixture(html`
719
694
  <sp-action-menu>
720
695
  <sp-icon-show-menu slot="icon"></sp-icon-show-menu>
721
696
  <sp-menu-group role="none">
@@ -776,7 +751,7 @@ describe("Submenu", () => {
776
751
  oneEvent(rootMenu1, "sp-closed"),
777
752
  oneEvent(el, "sp-closed")
778
753
  ]);
779
- sendMouse({
754
+ await sendMouse({
780
755
  steps: [
781
756
  {
782
757
  type: "click",
@@ -787,7 +762,7 @@ describe("Submenu", () => {
787
762
  await closed;
788
763
  });
789
764
  it("closes decendent menus when Menu Item in ancestor without a submenu is pointerentered", async () => {
790
- const el = await styledFixture(html`
765
+ const el = await fixture(html`
791
766
  <sp-action-menu>
792
767
  <sp-icon-show-menu slot="icon"></sp-icon-show-menu>
793
768
  <sp-menu-group role="none">
@@ -835,10 +810,7 @@ describe("Submenu", () => {
835
810
  await closed;
836
811
  });
837
812
  it("closes decendent menus when Menu Item in ancestor is clicked", async function() {
838
- if (isWebKit()) {
839
- this.skip();
840
- }
841
- const el = await styledFixture(html`
813
+ const el = await fixture(html`
842
814
  <sp-action-menu>
843
815
  <sp-icon-show-menu slot="icon"></sp-icon-show-menu>
844
816
  <sp-menu-group role="none">
@@ -880,6 +852,7 @@ describe("Submenu", () => {
880
852
  </sp-action-menu>
881
853
  `);
882
854
  await nextFrame();
855
+ await nextFrame();
883
856
  const rootMenu1 = el.querySelector("#submenu-item-1");
884
857
  const childMenu2 = el.querySelector("#submenu-item-2");
885
858
  const ancestorItem = el.querySelector("#ancestor-item");
@@ -929,7 +902,7 @@ describe("Submenu", () => {
929
902
  }
930
903
  ]
931
904
  });
932
- const el = await styledFixture(
905
+ const el = await fixture(
933
906
  html`
934
907
  <sp-menu>
935
908
  <sp-menu-item class="root-1">