mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
226 lines
9.4 KiB
Diff
226 lines
9.4 KiB
Diff
diff --git a/dist/chunk/3ARTUDH2.jsx b/dist/chunk/3ARTUDH2.jsx
|
|
index 4a2cfa59cfd0adec119e46de043c590af12ceb60..eeb910652f9f6b150a5bf348f574d477ef70545d 100644
|
|
--- a/dist/chunk/3ARTUDH2.jsx
|
|
+++ b/dist/chunk/3ARTUDH2.jsx
|
|
@@ -197,6 +197,8 @@ function Menu(props) {
|
|
]);
|
|
let pointerGraceTimeoutId = 0;
|
|
let pointerGraceIntent = null;
|
|
+ let pointerGraceOrigin = [0, 0];
|
|
+ let pointerGraceHeld;
|
|
let pointerDir = "right";
|
|
const [triggerId, setTriggerId] = createSignal();
|
|
const [contentId, setContentId] = createSignal();
|
|
@@ -263,12 +265,55 @@ function Menu(props) {
|
|
};
|
|
const isPointerMovingToSubmenu = (e) => {
|
|
const isMovingTowards = pointerDir === pointerGraceIntent?.side;
|
|
- return isMovingTowards && isPointerInGraceArea(e, pointerGraceIntent?.area);
|
|
+ if (!isMovingTowards || !isPointerInGraceArea(e, pointerGraceIntent?.area)) {
|
|
+ return false;
|
|
+ }
|
|
+ // Patched: judge each move of a few pixels by where it points. Heading into the submenu restarts the 300ms grace,
|
|
+ // so a slow move still reaches it. Heading past it, like drifting down the menu, ends the grace, so the items the
|
|
+ // pointer crosses respond at once instead of staying dead for 300ms.
|
|
+ const [originX, originY] = pointerGraceOrigin;
|
|
+ const dx = e.clientX - originX;
|
|
+ const dy = e.clientY - originY;
|
|
+ if (Math.hypot(dx, dy) < 4) {
|
|
+ return true;
|
|
+ }
|
|
+ const [edgeX, edgeStart] = pointerGraceIntent.area[1];
|
|
+ const edgeEnd = pointerGraceIntent.area[4][1];
|
|
+ const edgeY = originY + dy * Math.max(0, (edgeX - originX) / dx);
|
|
+ const advancing = pointerGraceIntent.side === "right" ? dx > 0 : dx < 0;
|
|
+ if (!advancing || edgeY < Math.min(edgeStart, edgeEnd) || edgeY > Math.max(edgeStart, edgeEnd)) {
|
|
+ pointerGraceIntent = null;
|
|
+ return false;
|
|
+ }
|
|
+ pointerGraceOrigin = [e.clientX, e.clientY];
|
|
+ window.clearTimeout(pointerGraceTimeoutId);
|
|
+ pointerGraceTimeoutId = window.setTimeout(endPointerGrace, 300);
|
|
+ return true;
|
|
+ };
|
|
+ // Patched: an item the pointer came to rest on while the grace held it back gets the pointer once the grace ends, as
|
|
+ // if the pointer had moved on it again. Otherwise it stays dead until the pointer moves, while the submenu the pointer
|
|
+ // never reached stays open.
|
|
+ const endPointerGrace = () => {
|
|
+ pointerGraceIntent = null;
|
|
+ const held = pointerGraceHeld;
|
|
+ pointerGraceHeld = void 0;
|
|
+ if (!held?.element.isConnected || !held.element.matches(":hover")) {
|
|
+ return;
|
|
+ }
|
|
+ held.element.dispatchEvent(new PointerEvent("pointermove", {
|
|
+ bubbles: true,
|
|
+ pointerType: "mouse",
|
|
+ clientX: held.clientX,
|
|
+ clientY: held.clientY
|
|
+ }));
|
|
};
|
|
const onItemEnter = (e) => {
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
e.preventDefault();
|
|
+ pointerGraceHeld = { element: e.currentTarget, clientX: e.clientX, clientY: e.clientY };
|
|
+ return;
|
|
}
|
|
+ pointerGraceHeld = void 0;
|
|
};
|
|
const onItemLeave = (e) => {
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
@@ -277,9 +322,12 @@ function Menu(props) {
|
|
focusContent();
|
|
};
|
|
const onTriggerLeave = (e) => {
|
|
+ // Patched: pointerleave can't be cancelled, so preventDefault never sets defaultPrevented for the caller to read.
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
e.preventDefault();
|
|
+ return true;
|
|
}
|
|
+ return false;
|
|
};
|
|
createHideOutside({
|
|
isDisabled: () => {
|
|
@@ -355,7 +403,13 @@ function Menu(props) {
|
|
onTriggerLeave,
|
|
setPointerDir: (dir) => pointerDir = dir,
|
|
setPointerGraceTimeoutId: (id) => pointerGraceTimeoutId = id,
|
|
- setPointerGraceIntent: (intent) => pointerGraceIntent = intent,
|
|
+ endPointerGrace,
|
|
+ setPointerGraceIntent: (intent) => {
|
|
+ pointerGraceIntent = intent;
|
|
+ pointerGraceHeld = void 0;
|
|
+ // The grace area starts 5px behind the pointer.
|
|
+ pointerGraceOrigin = intent ? [intent.area[0][0] + (intent.side === "right" ? 5 : -5), intent.area[0][1]] : [0, 0];
|
|
+ },
|
|
registerNestedMenu,
|
|
registerItemToParentDomCollection: parentDomCollectionContext?.registerItem,
|
|
registerTriggerId: createRegisterId(setTriggerId),
|
|
@@ -1499,12 +1553,11 @@ function MenuSubTrigger(props) {
|
|
});
|
|
window.clearTimeout(parentMenuContext?.pointerGraceTimeoutId());
|
|
const pointerGraceTimeoutId = window.setTimeout(() => {
|
|
- parentMenuContext?.setPointerGraceIntent(null);
|
|
+ parentMenuContext?.endPointerGrace();
|
|
}, 300);
|
|
parentMenuContext?.setPointerGraceTimeoutId(pointerGraceTimeoutId);
|
|
} else {
|
|
- parentMenuContext?.onTriggerLeave(e);
|
|
- if (e.defaultPrevented) {
|
|
+ if (parentMenuContext?.onTriggerLeave(e)) {
|
|
return;
|
|
}
|
|
parentMenuContext?.setPointerGraceIntent(null);
|
|
diff --git a/dist/chunk/HGKTPMYY.js b/dist/chunk/HGKTPMYY.js
|
|
index a8fa9b06a97cb3d4d5029fc0c929d78dfdc6edd4..6c005c52ccf0a84dbd38415c21dfd2c5ad43af5b 100644
|
|
--- a/dist/chunk/HGKTPMYY.js
|
|
+++ b/dist/chunk/HGKTPMYY.js
|
|
@@ -119,6 +119,8 @@ function Menu(props) {
|
|
const [local, others] = splitProps(mergedProps, ["open", "defaultOpen", "onOpenChange"]);
|
|
let pointerGraceTimeoutId = 0;
|
|
let pointerGraceIntent = null;
|
|
+ let pointerGraceOrigin = [0, 0];
|
|
+ let pointerGraceHeld;
|
|
let pointerDir = "right";
|
|
const [triggerId, setTriggerId] = createSignal();
|
|
const [contentId, setContentId] = createSignal();
|
|
@@ -187,12 +189,55 @@ function Menu(props) {
|
|
};
|
|
const isPointerMovingToSubmenu = (e) => {
|
|
const isMovingTowards = pointerDir === pointerGraceIntent?.side;
|
|
- return isMovingTowards && isPointerInGraceArea(e, pointerGraceIntent?.area);
|
|
+ if (!isMovingTowards || !isPointerInGraceArea(e, pointerGraceIntent?.area)) {
|
|
+ return false;
|
|
+ }
|
|
+ // Patched: judge each move of a few pixels by where it points. Heading into the submenu restarts the 300ms grace,
|
|
+ // so a slow move still reaches it. Heading past it, like drifting down the menu, ends the grace, so the items the
|
|
+ // pointer crosses respond at once instead of staying dead for 300ms.
|
|
+ const [originX, originY] = pointerGraceOrigin;
|
|
+ const dx = e.clientX - originX;
|
|
+ const dy = e.clientY - originY;
|
|
+ if (Math.hypot(dx, dy) < 4) {
|
|
+ return true;
|
|
+ }
|
|
+ const [edgeX, edgeStart] = pointerGraceIntent.area[1];
|
|
+ const edgeEnd = pointerGraceIntent.area[4][1];
|
|
+ const edgeY = originY + dy * Math.max(0, (edgeX - originX) / dx);
|
|
+ const advancing = pointerGraceIntent.side === "right" ? dx > 0 : dx < 0;
|
|
+ if (!advancing || edgeY < Math.min(edgeStart, edgeEnd) || edgeY > Math.max(edgeStart, edgeEnd)) {
|
|
+ pointerGraceIntent = null;
|
|
+ return false;
|
|
+ }
|
|
+ pointerGraceOrigin = [e.clientX, e.clientY];
|
|
+ window.clearTimeout(pointerGraceTimeoutId);
|
|
+ pointerGraceTimeoutId = window.setTimeout(endPointerGrace, 300);
|
|
+ return true;
|
|
+ };
|
|
+ // Patched: an item the pointer came to rest on while the grace held it back gets the pointer once the grace ends, as
|
|
+ // if the pointer had moved on it again. Otherwise it stays dead until the pointer moves, while the submenu the pointer
|
|
+ // never reached stays open.
|
|
+ const endPointerGrace = () => {
|
|
+ pointerGraceIntent = null;
|
|
+ const held = pointerGraceHeld;
|
|
+ pointerGraceHeld = void 0;
|
|
+ if (!held?.element.isConnected || !held.element.matches(":hover")) {
|
|
+ return;
|
|
+ }
|
|
+ held.element.dispatchEvent(new PointerEvent("pointermove", {
|
|
+ bubbles: true,
|
|
+ pointerType: "mouse",
|
|
+ clientX: held.clientX,
|
|
+ clientY: held.clientY
|
|
+ }));
|
|
};
|
|
const onItemEnter = (e) => {
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
e.preventDefault();
|
|
+ pointerGraceHeld = { element: e.currentTarget, clientX: e.clientX, clientY: e.clientY };
|
|
+ return;
|
|
}
|
|
+ pointerGraceHeld = void 0;
|
|
};
|
|
const onItemLeave = (e) => {
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
@@ -201,9 +246,12 @@ function Menu(props) {
|
|
focusContent();
|
|
};
|
|
const onTriggerLeave = (e) => {
|
|
+ // Patched: pointerleave can't be cancelled, so preventDefault never sets defaultPrevented for the caller to read.
|
|
if (isPointerMovingToSubmenu(e)) {
|
|
e.preventDefault();
|
|
+ return true;
|
|
}
|
|
+ return false;
|
|
};
|
|
createHideOutside({
|
|
isDisabled: () => {
|
|
@@ -276,7 +324,13 @@ function Menu(props) {
|
|
onTriggerLeave,
|
|
setPointerDir: (dir) => pointerDir = dir,
|
|
setPointerGraceTimeoutId: (id) => pointerGraceTimeoutId = id,
|
|
- setPointerGraceIntent: (intent) => pointerGraceIntent = intent,
|
|
+ endPointerGrace,
|
|
+ setPointerGraceIntent: (intent) => {
|
|
+ pointerGraceIntent = intent;
|
|
+ pointerGraceHeld = void 0;
|
|
+ // The grace area starts 5px behind the pointer.
|
|
+ pointerGraceOrigin = intent ? [intent.area[0][0] + (intent.side === "right" ? 5 : -5), intent.area[0][1]] : [0, 0];
|
|
+ },
|
|
registerNestedMenu,
|
|
registerItemToParentDomCollection: parentDomCollectionContext?.registerItem,
|
|
registerTriggerId: createRegisterId(setTriggerId),
|
|
@@ -1213,12 +1267,11 @@ function MenuSubTrigger(props) {
|
|
});
|
|
window.clearTimeout(parentMenuContext?.pointerGraceTimeoutId());
|
|
const pointerGraceTimeoutId = window.setTimeout(() => {
|
|
- parentMenuContext?.setPointerGraceIntent(null);
|
|
+ parentMenuContext?.endPointerGrace();
|
|
}, 300);
|
|
parentMenuContext?.setPointerGraceTimeoutId(pointerGraceTimeoutId);
|
|
} else {
|
|
- parentMenuContext?.onTriggerLeave(e);
|
|
- if (e.defaultPrevented) {
|
|
+ if (parentMenuContext?.onTriggerLeave(e)) {
|
|
return;
|
|
}
|
|
parentMenuContext?.setPointerGraceIntent(null);
|