@vonage/vivid 4.1.0 → 4.2.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.
@@ -9035,9 +9035,28 @@
9035
9035
  "kind": "method",
9036
9036
  "name": "#expandedChange"
9037
9037
  },
9038
+ {
9039
+ "kind": "field",
9040
+ "name": "#handleMenuItemKeyDown",
9041
+ "privacy": "private"
9042
+ },
9043
+ {
9044
+ "kind": "field",
9045
+ "name": "#syntheticClickEvents",
9046
+ "privacy": "private",
9047
+ "default": "new WeakSet<Event>()"
9048
+ },
9049
+ {
9050
+ "kind": "method",
9051
+ "name": "#emitSyntheticClick"
9052
+ },
9038
9053
  {
9039
9054
  "kind": "field",
9040
9055
  "name": "updateSubmenu"
9056
+ },
9057
+ {
9058
+ "kind": "field",
9059
+ "name": "handleMenuItemKeyDown"
9041
9060
  }
9042
9061
  ],
9043
9062
  "events": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/vivid",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "type": "module",
5
5
  "module": "./index.js",
6
6
  "main": "./index.cjs",
@@ -7,8 +7,8 @@ const repeat = require('./repeat.cjs');
7
7
  const slotted = require('./slotted.cjs');
8
8
  const children = require('./children.cjs');
9
9
  const icon = require('./icon.cjs');
10
- const keyCodes$1 = require('./key-codes2.cjs');
11
10
  const when = require('./when.cjs');
11
+ const keyCodes$1 = require('./key-codes2.cjs');
12
12
 
13
13
  /**
14
14
  * This set of exported strings reference https://developer.mozilla.org/en-US/docs/Web/Events
@@ -5,8 +5,8 @@ import { R as RepeatDirective } from './repeat.js';
5
5
  import { s as slotted, e as elements } from './slotted.js';
6
6
  import { c as children } from './children.js';
7
7
  import { I as Icon } from './icon.js';
8
- import { b as keyEnter$1, g as keySpace } from './key-codes2.js';
9
8
  import { w as when } from './when.js';
9
+ import { b as keyEnter$1, g as keySpace } from './key-codes2.js';
10
10
 
11
11
  /**
12
12
  * This set of exported strings reference https://developer.mozilla.org/en-US/docs/Web/Events
@@ -2,6 +2,7 @@
2
2
 
3
3
  const index = require('./index.cjs');
4
4
  const definition = require('./definition27.cjs');
5
+ const keyCodes$1 = require('./key-codes2.cjs');
5
6
  const affix = require('./affix.cjs');
6
7
  const anchored = require('./anchored.cjs');
7
8
  const startEnd = require('./start-end.cjs');
@@ -744,8 +745,38 @@ class MenuItem extends MenuItem$1 {
744
745
  super();
745
746
  this.checkTrailing = false;
746
747
  this.#submenuArray = [];
748
+ this.#handleMenuItemKeyDown = (e) => {
749
+ if (e.defaultPrevented) {
750
+ return false;
751
+ }
752
+ switch (e.key) {
753
+ case keyCodes$1.keyEnter:
754
+ case keyCodes$1.keySpace:
755
+ this.invoke();
756
+ if (!this.disabled) {
757
+ this.#emitSyntheticClick();
758
+ }
759
+ return false;
760
+ case keyCodes$1.keyArrowRight:
761
+ this.expandAndFocus();
762
+ if (this.hasSubmenu) {
763
+ this.#emitSyntheticClick();
764
+ }
765
+ return false;
766
+ case keyCodes$1.keyArrowLeft:
767
+ if (this.expanded) {
768
+ this.expanded = false;
769
+ this.focus();
770
+ this.#emitSyntheticClick();
771
+ return false;
772
+ }
773
+ }
774
+ return true;
775
+ };
776
+ this.#syntheticClickEvents = /* @__PURE__ */ new WeakSet();
747
777
  this.updateSubmenu = () => this.#updateSubmenu();
748
778
  this.addEventListener("expanded-change", this.#expandedChange);
779
+ this.handleMenuItemKeyDown = this.#handleMenuItemKeyDown;
749
780
  }
750
781
  #submenuArray;
751
782
  /**
@@ -773,6 +804,22 @@ class MenuItem extends MenuItem$1 {
773
804
  this.submenu.open = this.expanded;
774
805
  }
775
806
  }
807
+ #handleMenuItemKeyDown;
808
+ #syntheticClickEvents;
809
+ /**
810
+ * @internal
811
+ */
812
+ _isSyntheticClickEvent(event) {
813
+ return this.#syntheticClickEvents.has(event);
814
+ }
815
+ #emitSyntheticClick() {
816
+ const mouseEvent = new MouseEvent("click", {
817
+ bubbles: true,
818
+ composed: true
819
+ });
820
+ this.#syntheticClickEvents.add(mouseEvent);
821
+ this.dispatchEvent(mouseEvent);
822
+ }
776
823
  }
777
824
  __decorateClass([
778
825
  index.attr
@@ -833,6 +880,9 @@ const getClasses = ({
833
880
  ["has-meta", Boolean(metaSlottedContent?.length)]
834
881
  );
835
882
  function handleClick(x, { event }) {
883
+ if (x._isSyntheticClickEvent(event)) {
884
+ return true;
885
+ }
836
886
  x.handleMenuItemClick(event);
837
887
  return x.role === MenuItemRole.presentation;
838
888
  }
@@ -1,5 +1,6 @@
1
1
  import { F as FoundationElement, D as DOM, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
2
  import { a as iconRegistries } from './definition27.js';
3
+ import { k as keyArrowLeft$1, a as keyArrowRight$1, g as keySpace$1, b as keyEnter$1 } from './key-codes2.js';
3
4
  import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
4
5
  import { b as anchored } from './anchored.js';
5
6
  import { S as StartEnd } from './start-end.js';
@@ -742,8 +743,38 @@ class MenuItem extends MenuItem$1 {
742
743
  super();
743
744
  this.checkTrailing = false;
744
745
  this.#submenuArray = [];
746
+ this.#handleMenuItemKeyDown = (e) => {
747
+ if (e.defaultPrevented) {
748
+ return false;
749
+ }
750
+ switch (e.key) {
751
+ case keyEnter$1:
752
+ case keySpace$1:
753
+ this.invoke();
754
+ if (!this.disabled) {
755
+ this.#emitSyntheticClick();
756
+ }
757
+ return false;
758
+ case keyArrowRight$1:
759
+ this.expandAndFocus();
760
+ if (this.hasSubmenu) {
761
+ this.#emitSyntheticClick();
762
+ }
763
+ return false;
764
+ case keyArrowLeft$1:
765
+ if (this.expanded) {
766
+ this.expanded = false;
767
+ this.focus();
768
+ this.#emitSyntheticClick();
769
+ return false;
770
+ }
771
+ }
772
+ return true;
773
+ };
774
+ this.#syntheticClickEvents = /* @__PURE__ */ new WeakSet();
745
775
  this.updateSubmenu = () => this.#updateSubmenu();
746
776
  this.addEventListener("expanded-change", this.#expandedChange);
777
+ this.handleMenuItemKeyDown = this.#handleMenuItemKeyDown;
747
778
  }
748
779
  #submenuArray;
749
780
  /**
@@ -771,6 +802,22 @@ class MenuItem extends MenuItem$1 {
771
802
  this.submenu.open = this.expanded;
772
803
  }
773
804
  }
805
+ #handleMenuItemKeyDown;
806
+ #syntheticClickEvents;
807
+ /**
808
+ * @internal
809
+ */
810
+ _isSyntheticClickEvent(event) {
811
+ return this.#syntheticClickEvents.has(event);
812
+ }
813
+ #emitSyntheticClick() {
814
+ const mouseEvent = new MouseEvent("click", {
815
+ bubbles: true,
816
+ composed: true
817
+ });
818
+ this.#syntheticClickEvents.add(mouseEvent);
819
+ this.dispatchEvent(mouseEvent);
820
+ }
774
821
  }
775
822
  __decorateClass([
776
823
  attr
@@ -831,6 +878,9 @@ const getClasses = ({
831
878
  ["has-meta", Boolean(metaSlottedContent?.length)]
832
879
  );
833
880
  function handleClick(x, { event }) {
881
+ if (x._isSyntheticClickEvent(event)) {
882
+ return true;
883
+ }
834
884
  x.handleMenuItemClick(event);
835
885
  return x.role === MenuItemRole.presentation;
836
886
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  .vvd-root {
6
6
  color-scheme: var(--vvd-color-scheme);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  .vvd-root {
6
6
  color-scheme: var(--vvd-color-scheme);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  .vvd-root:root {
6
6
  --vvd-size-font-scale-base: 1rem;
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
7
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
8
8
  */
9
9
  /**
10
10
  * Do not edit directly
11
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
11
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
12
12
  */
13
13
  /**
14
14
  * Do not edit directly
15
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
15
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
16
16
  */
17
17
  @property --vvd-size-density {
18
18
  syntax: "<integer>";
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
7
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
8
8
  */
9
9
  /**
10
10
  * Do not edit directly
11
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
11
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
12
12
  */
13
13
  /**
14
14
  * Do not edit directly
15
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
15
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
16
16
  */
17
17
  @property --vvd-size-density {
18
18
  syntax: "<integer>";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 08 Jul 2024 12:38:12 GMT
3
+ * Generated on Thu, 11 Jul 2024 10:35:07 GMT
4
4
  */
5
5
  .vvd-root, ::part(vvd-root),
6
6
  .vvd-theme-alternate, ::part(vvd-theme-alternate) {