@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/native/index.d.mts +9 -47
- package/native/index.d.ts +9 -47
- package/native/index.js +51 -35
- package/native/index.js.map +1 -1
- package/native/index.mjs +51 -35
- package/native/index.mjs.map +1 -1
- package/package.json +10 -10
- package/web/index.d.mts +9 -47
- package/web/index.d.ts +9 -47
- package/web/index.js +51 -35
- package/web/index.js.map +1 -1
- package/web/index.mjs +51 -35
- package/web/index.mjs.map +1 -1
package/native/index.mjs
CHANGED
|
@@ -577,7 +577,7 @@ var OptionCell = ({
|
|
|
577
577
|
if (hasSubmenu) scheduleClose();
|
|
578
578
|
};
|
|
579
579
|
const labelColor = disabled ? theme.colors.control.input.textDisable : destructive ? theme.colors.content.alert.primary : theme.colors.content.primary;
|
|
580
|
-
const bg = inHoverState ? theme.colors.
|
|
580
|
+
const bg = checked ? theme.colors.overlay.brand : inHoverState ? theme.colors.overlay.mono : "transparent";
|
|
581
581
|
const role = !hasSubmenu && checked !== void 0 ? leadingControl === "radio" ? "menuitemradio" : "menuitemcheckbox" : "menuitem";
|
|
582
582
|
const ariaChecked = !hasSubmenu && checked !== void 0 ? checked ? "true" : "false" : void 0;
|
|
583
583
|
const handleClick = () => {
|
|
@@ -710,11 +710,7 @@ var OptionCell = ({
|
|
|
710
710
|
display: "inline-flex",
|
|
711
711
|
alignItems: "center",
|
|
712
712
|
flexShrink: 0,
|
|
713
|
-
//
|
|
714
|
-
// the height of one label line, so the dot centres on the FIRST
|
|
715
|
-
// line and stays there when the label wraps or a `description`
|
|
716
|
-
// pushes the row taller. Without it the row's `alignItems:center`
|
|
717
|
-
// floats the dot to the middle of a multi-line cell.
|
|
713
|
+
// One label line tall, so the dot centres on that line when text wraps.
|
|
718
714
|
...statusTopAlignment ? { alignSelf: "flex-start", minHeight: labelLineHeight } : {}
|
|
719
715
|
},
|
|
720
716
|
children: status
|
|
@@ -816,8 +812,7 @@ var OptionCell = ({
|
|
|
816
812
|
position: "fixed",
|
|
817
813
|
top: submenuPos.top,
|
|
818
814
|
left: submenuPos.left,
|
|
819
|
-
// Same band as the parent
|
|
820
|
-
// the DOM so it paints above it (holds for arbitrary nesting depth).
|
|
815
|
+
// Same band as the parent; later DOM order paints it above.
|
|
821
816
|
zIndex: overlayLayer + LAYER_OFFSET.menu
|
|
822
817
|
},
|
|
823
818
|
children: submenu
|
|
@@ -1191,9 +1186,7 @@ var ContextMenuSubmenu = ({
|
|
|
1191
1186
|
top: pos ? pos.top : 0,
|
|
1192
1187
|
// Hidden until measured to avoid a flash at (0,0).
|
|
1193
1188
|
visibility: pos ? "visible" : "hidden",
|
|
1194
|
-
// One step above the parent panel
|
|
1195
|
-
// through the portal, so a submenu inside a modal stays above panel and
|
|
1196
|
-
// modal; nested submenus tie and DOM order resolves the stack.
|
|
1189
|
+
// One step above the parent panel; nested ties resolve by DOM order.
|
|
1197
1190
|
zIndex: overlayLayer + LAYER_OFFSET2.menu + 1,
|
|
1198
1191
|
opacity: visible ? 1 : 0,
|
|
1199
1192
|
transform: visible ? "translateX(0)" : openLeft ? "translateX(4px)" : "translateX(-4px)",
|
|
@@ -1209,6 +1202,7 @@ var ContextMenuSubmenu = ({
|
|
|
1209
1202
|
borderWidth: 1,
|
|
1210
1203
|
borderRadius,
|
|
1211
1204
|
paddingVertical: sizeStyles.paddingVertical,
|
|
1205
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
1212
1206
|
style: {
|
|
1213
1207
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
|
|
1214
1208
|
minWidth: sizeStyles.minWidth
|
|
@@ -1459,6 +1453,15 @@ var ARROW_TIP_PROTRUSION = ARROW_HALF * Math.SQRT2;
|
|
|
1459
1453
|
var PANEL_SHADOW = "0 4px 12px rgba(0,0,0,0.15)";
|
|
1460
1454
|
var DROPDOWN_LAYER_SELECTOR = '[data-modal-id],[role="listbox"]';
|
|
1461
1455
|
var ownLayerSelector = (menuId) => `${DROPDOWN_LAYER_SELECTOR},[data-xui-context-menu-portal="${menuId}"],[data-xui-context-menu-owner="${menuId}"]`;
|
|
1456
|
+
var isInOwnLayer = (event, selector) => {
|
|
1457
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
1458
|
+
if (path.length)
|
|
1459
|
+
return path.some(
|
|
1460
|
+
(node) => node instanceof Element && node.matches(selector)
|
|
1461
|
+
);
|
|
1462
|
+
const target = event.target;
|
|
1463
|
+
return target instanceof Element && !!target.closest(selector);
|
|
1464
|
+
};
|
|
1462
1465
|
var textFromNode = (node) => {
|
|
1463
1466
|
if (node === null || node === void 0 || typeof node === "boolean")
|
|
1464
1467
|
return "";
|
|
@@ -1662,12 +1665,7 @@ var ContextMenuRoot = forwardRef(
|
|
|
1662
1665
|
const target = event.target;
|
|
1663
1666
|
if (!target) return;
|
|
1664
1667
|
if (containerRef.current?.contains(target)) return;
|
|
1665
|
-
|
|
1666
|
-
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
1667
|
-
const isInsidePortaledLayer = path.length ? path.some(
|
|
1668
|
-
(node) => node instanceof Element && node.matches(selector)
|
|
1669
|
-
) : target instanceof Element && !!target.closest(selector);
|
|
1670
|
-
if (isInsidePortaledLayer) return;
|
|
1668
|
+
if (isInOwnLayer(event, ownLayerSelector(menuId))) return;
|
|
1671
1669
|
closeMenu();
|
|
1672
1670
|
};
|
|
1673
1671
|
const onScroll = (event) => {
|
|
@@ -1675,6 +1673,7 @@ var ContextMenuRoot = forwardRef(
|
|
|
1675
1673
|
if (target instanceof Node && (containerRef.current?.contains(target) || panelRef.current?.contains(target))) {
|
|
1676
1674
|
return;
|
|
1677
1675
|
}
|
|
1676
|
+
if (isInOwnLayer(event, ownLayerSelector(menuId))) return;
|
|
1678
1677
|
closeMenu();
|
|
1679
1678
|
};
|
|
1680
1679
|
document.addEventListener("mousedown", onMouseDown);
|
|
@@ -1849,22 +1848,26 @@ var ContextMenuRoot = forwardRef(
|
|
|
1849
1848
|
firstChild instanceof HTMLElement ? firstChild : node
|
|
1850
1849
|
);
|
|
1851
1850
|
};
|
|
1852
|
-
const triggerNode = trigger && isValidElement(trigger) ?
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1851
|
+
const triggerNode = trigger && isValidElement(trigger) ? (
|
|
1852
|
+
// Presentational click shim; the wrapped trigger owns keyboard activation.
|
|
1853
|
+
/* @__PURE__ */ jsx4(
|
|
1854
|
+
"span",
|
|
1855
|
+
{
|
|
1856
|
+
ref: assignTriggerWrapperRef,
|
|
1857
|
+
role: "presentation",
|
|
1858
|
+
onClick: (event) => {
|
|
1859
|
+
if (!event.defaultPrevented) toggleMenu();
|
|
1860
|
+
},
|
|
1861
|
+
style: {
|
|
1862
|
+
display: "inline-flex",
|
|
1863
|
+
width: triggerFullWidth ? "100%" : "auto"
|
|
1864
|
+
},
|
|
1865
|
+
children: cloneElement(trigger, {
|
|
1866
|
+
"aria-haspopup": "menu",
|
|
1867
|
+
"aria-expanded": isOpen ? "true" : "false"
|
|
1868
|
+
})
|
|
1869
|
+
}
|
|
1870
|
+
)
|
|
1868
1871
|
) : trigger ? /* @__PURE__ */ jsx4(
|
|
1869
1872
|
"span",
|
|
1870
1873
|
{
|
|
@@ -1874,6 +1877,11 @@ var ContextMenuRoot = forwardRef(
|
|
|
1874
1877
|
"aria-haspopup": "menu",
|
|
1875
1878
|
"aria-expanded": isOpen ? "true" : "false",
|
|
1876
1879
|
onClick: toggleMenu,
|
|
1880
|
+
onKeyDown: (event) => {
|
|
1881
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1882
|
+
event.preventDefault();
|
|
1883
|
+
toggleMenu();
|
|
1884
|
+
},
|
|
1877
1885
|
children: trigger
|
|
1878
1886
|
}
|
|
1879
1887
|
) : null;
|
|
@@ -1914,6 +1922,7 @@ var ContextMenuRoot = forwardRef(
|
|
|
1914
1922
|
borderWidth: 1,
|
|
1915
1923
|
borderRadius,
|
|
1916
1924
|
paddingVertical: sizeStyles.paddingVertical,
|
|
1925
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
1917
1926
|
width,
|
|
1918
1927
|
minWidth: sizeStyles.minWidth,
|
|
1919
1928
|
tabIndex: -1,
|
|
@@ -1928,7 +1937,9 @@ var ContextMenuRoot = forwardRef(
|
|
|
1928
1937
|
overflow: "visible"
|
|
1929
1938
|
} : {
|
|
1930
1939
|
maxHeight,
|
|
1931
|
-
overflowY: "auto"
|
|
1940
|
+
overflowY: "auto",
|
|
1941
|
+
// Panel still scrolls; the bar itself is hidden.
|
|
1942
|
+
scrollbarWidth: "none"
|
|
1932
1943
|
},
|
|
1933
1944
|
outline: "none"
|
|
1934
1945
|
},
|
|
@@ -1944,7 +1955,12 @@ var ContextMenuRoot = forwardRef(
|
|
|
1944
1955
|
/* @__PURE__ */ jsx4(
|
|
1945
1956
|
"div",
|
|
1946
1957
|
{
|
|
1947
|
-
style: {
|
|
1958
|
+
style: {
|
|
1959
|
+
maxHeight,
|
|
1960
|
+
overflowY: "auto",
|
|
1961
|
+
scrollbarWidth: "none",
|
|
1962
|
+
borderRadius
|
|
1963
|
+
},
|
|
1948
1964
|
children: renderContent()
|
|
1949
1965
|
}
|
|
1950
1966
|
)
|