@xsolla/xui-context-menu 0.202.2 → 0.202.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.
package/web/index.mjs CHANGED
@@ -596,7 +596,7 @@ var OptionCell = ({
596
596
  if (hasSubmenu) scheduleClose();
597
597
  };
598
598
  const labelColor = disabled ? theme.colors.control.input.textDisable : destructive ? theme.colors.content.alert.primary : theme.colors.content.primary;
599
- const bg = inHoverState ? theme.colors.control.input.bgHover : "transparent";
599
+ const bg = checked ? theme.colors.overlay.brand : inHoverState ? theme.colors.overlay.mono : "transparent";
600
600
  const role = !hasSubmenu && checked !== void 0 ? leadingControl === "radio" ? "menuitemradio" : "menuitemcheckbox" : "menuitem";
601
601
  const ariaChecked = !hasSubmenu && checked !== void 0 ? checked ? "true" : "false" : void 0;
602
602
  const handleClick = () => {
@@ -729,11 +729,7 @@ var OptionCell = ({
729
729
  display: "inline-flex",
730
730
  alignItems: "center",
731
731
  flexShrink: 0,
732
- // Top alignment pins the slot to the top of the row and gives it
733
- // the height of one label line, so the dot centres on the FIRST
734
- // line and stays there when the label wraps or a `description`
735
- // pushes the row taller. Without it the row's `alignItems:center`
736
- // floats the dot to the middle of a multi-line cell.
732
+ // One label line tall, so the dot centres on that line when text wraps.
737
733
  ...statusTopAlignment ? { alignSelf: "flex-start", minHeight: labelLineHeight } : {}
738
734
  },
739
735
  children: status
@@ -835,8 +831,7 @@ var OptionCell = ({
835
831
  position: "fixed",
836
832
  top: submenuPos.top,
837
833
  left: submenuPos.left,
838
- // Same band as the parent menu; the submenu portal mounts later in
839
- // the DOM so it paints above it (holds for arbitrary nesting depth).
834
+ // Same band as the parent; later DOM order paints it above.
840
835
  zIndex: overlayLayer + LAYER_OFFSET.menu
841
836
  },
842
837
  children: submenu
@@ -1210,9 +1205,7 @@ var ContextMenuSubmenu = ({
1210
1205
  top: pos ? pos.top : 0,
1211
1206
  // Hidden until measured to avoid a flash at (0,0).
1212
1207
  visibility: pos ? "visible" : "hidden",
1213
- // One step above the parent panel. The overlay-layer context flows
1214
- // through the portal, so a submenu inside a modal stays above panel and
1215
- // modal; nested submenus tie and DOM order resolves the stack.
1208
+ // One step above the parent panel; nested ties resolve by DOM order.
1216
1209
  zIndex: overlayLayer + LAYER_OFFSET2.menu + 1,
1217
1210
  opacity: visible ? 1 : 0,
1218
1211
  transform: visible ? "translateX(0)" : openLeft ? "translateX(4px)" : "translateX(-4px)",
@@ -1228,6 +1221,7 @@ var ContextMenuSubmenu = ({
1228
1221
  borderWidth: 1,
1229
1222
  borderRadius,
1230
1223
  paddingVertical: sizeStyles.paddingVertical,
1224
+ paddingHorizontal: sizeStyles.paddingHorizontal,
1231
1225
  style: {
1232
1226
  boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
1233
1227
  minWidth: sizeStyles.minWidth
@@ -1478,6 +1472,15 @@ var ARROW_TIP_PROTRUSION = ARROW_HALF * Math.SQRT2;
1478
1472
  var PANEL_SHADOW = "0 4px 12px rgba(0,0,0,0.15)";
1479
1473
  var DROPDOWN_LAYER_SELECTOR = '[data-modal-id],[role="listbox"]';
1480
1474
  var ownLayerSelector = (menuId) => `${DROPDOWN_LAYER_SELECTOR},[data-xui-context-menu-portal="${menuId}"],[data-xui-context-menu-owner="${menuId}"]`;
1475
+ var isInOwnLayer = (event, selector) => {
1476
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
1477
+ if (path.length)
1478
+ return path.some(
1479
+ (node) => node instanceof Element && node.matches(selector)
1480
+ );
1481
+ const target = event.target;
1482
+ return target instanceof Element && !!target.closest(selector);
1483
+ };
1481
1484
  var textFromNode = (node) => {
1482
1485
  if (node === null || node === void 0 || typeof node === "boolean")
1483
1486
  return "";
@@ -1681,12 +1684,7 @@ var ContextMenuRoot = forwardRef(
1681
1684
  const target = event.target;
1682
1685
  if (!target) return;
1683
1686
  if (containerRef.current?.contains(target)) return;
1684
- const selector = ownLayerSelector(menuId);
1685
- const path = typeof event.composedPath === "function" ? event.composedPath() : [];
1686
- const isInsidePortaledLayer = path.length ? path.some(
1687
- (node) => node instanceof Element && node.matches(selector)
1688
- ) : target instanceof Element && !!target.closest(selector);
1689
- if (isInsidePortaledLayer) return;
1687
+ if (isInOwnLayer(event, ownLayerSelector(menuId))) return;
1690
1688
  closeMenu();
1691
1689
  };
1692
1690
  const onScroll = (event) => {
@@ -1694,6 +1692,7 @@ var ContextMenuRoot = forwardRef(
1694
1692
  if (target instanceof Node && (containerRef.current?.contains(target) || panelRef.current?.contains(target))) {
1695
1693
  return;
1696
1694
  }
1695
+ if (isInOwnLayer(event, ownLayerSelector(menuId))) return;
1697
1696
  closeMenu();
1698
1697
  };
1699
1698
  document.addEventListener("mousedown", onMouseDown);
@@ -1868,22 +1867,26 @@ var ContextMenuRoot = forwardRef(
1868
1867
  firstChild instanceof HTMLElement ? firstChild : node
1869
1868
  );
1870
1869
  };
1871
- const triggerNode = trigger && isValidElement(trigger) ? /* @__PURE__ */ jsx4(
1872
- "span",
1873
- {
1874
- ref: assignTriggerWrapperRef,
1875
- onClick: (event) => {
1876
- if (!event.defaultPrevented) toggleMenu();
1877
- },
1878
- style: {
1879
- display: "inline-flex",
1880
- width: triggerFullWidth ? "100%" : "auto"
1881
- },
1882
- children: cloneElement(trigger, {
1883
- "aria-haspopup": "menu",
1884
- "aria-expanded": isOpen ? "true" : "false"
1885
- })
1886
- }
1870
+ const triggerNode = trigger && isValidElement(trigger) ? (
1871
+ // Presentational click shim; the wrapped trigger owns keyboard activation.
1872
+ /* @__PURE__ */ jsx4(
1873
+ "span",
1874
+ {
1875
+ ref: assignTriggerWrapperRef,
1876
+ role: "presentation",
1877
+ onClick: (event) => {
1878
+ if (!event.defaultPrevented) toggleMenu();
1879
+ },
1880
+ style: {
1881
+ display: "inline-flex",
1882
+ width: triggerFullWidth ? "100%" : "auto"
1883
+ },
1884
+ children: cloneElement(trigger, {
1885
+ "aria-haspopup": "menu",
1886
+ "aria-expanded": isOpen ? "true" : "false"
1887
+ })
1888
+ }
1889
+ )
1887
1890
  ) : trigger ? /* @__PURE__ */ jsx4(
1888
1891
  "span",
1889
1892
  {
@@ -1893,6 +1896,11 @@ var ContextMenuRoot = forwardRef(
1893
1896
  "aria-haspopup": "menu",
1894
1897
  "aria-expanded": isOpen ? "true" : "false",
1895
1898
  onClick: toggleMenu,
1899
+ onKeyDown: (event) => {
1900
+ if (event.key !== "Enter" && event.key !== " ") return;
1901
+ event.preventDefault();
1902
+ toggleMenu();
1903
+ },
1896
1904
  children: trigger
1897
1905
  }
1898
1906
  ) : null;
@@ -1933,6 +1941,7 @@ var ContextMenuRoot = forwardRef(
1933
1941
  borderWidth: 1,
1934
1942
  borderRadius,
1935
1943
  paddingVertical: sizeStyles.paddingVertical,
1944
+ paddingHorizontal: sizeStyles.paddingHorizontal,
1936
1945
  width,
1937
1946
  minWidth: sizeStyles.minWidth,
1938
1947
  tabIndex: -1,
@@ -1947,7 +1956,9 @@ var ContextMenuRoot = forwardRef(
1947
1956
  overflow: "visible"
1948
1957
  } : {
1949
1958
  maxHeight,
1950
- overflowY: "auto"
1959
+ overflowY: "auto",
1960
+ // Panel still scrolls; the bar itself is hidden.
1961
+ scrollbarWidth: "none"
1951
1962
  },
1952
1963
  outline: "none"
1953
1964
  },
@@ -1963,7 +1974,12 @@ var ContextMenuRoot = forwardRef(
1963
1974
  /* @__PURE__ */ jsx4(
1964
1975
  "div",
1965
1976
  {
1966
- style: { maxHeight, overflowY: "auto", borderRadius },
1977
+ style: {
1978
+ maxHeight,
1979
+ overflowY: "auto",
1980
+ scrollbarWidth: "none",
1981
+ borderRadius
1982
+ },
1967
1983
  children: renderContent()
1968
1984
  }
1969
1985
  )