@robert-stackflow/oneui 0.6.36 → 0.6.37
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/CHANGELOG.md +4 -0
- package/components/ContextMenu.js +11 -0
- package/components/ContextMenu.module.css +43 -42
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 0.6.37
|
|
2
|
+
|
|
3
|
+
- Keep wheel input inside open ContextMenu layers. Short menus and scroll boundaries no longer scroll the document or nested workspace behind them; long menus retain native scrolling.
|
|
4
|
+
|
|
1
5
|
## 0.6.35
|
|
2
6
|
|
|
3
7
|
- Add an optional `IconButton text` slot for unified icon/text or count actions, sharing one hover, focus, pressed and click region without application styling. Preserve icon-only and disclosure variants.
|
|
@@ -92,15 +92,26 @@ function ContextMenu({
|
|
|
92
92
|
{ x: event.clientX, y: event.clientY, time: now }
|
|
93
93
|
];
|
|
94
94
|
};
|
|
95
|
+
const wheel = (event) => {
|
|
96
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
97
|
+
const panel = target?.closest('[data-menu-state="open"]');
|
|
98
|
+
const inside = !!panel && !!root.current?.contains(panel);
|
|
99
|
+
const down = event.deltaY > 0;
|
|
100
|
+
const canScroll = inside && event.deltaY !== 0 && (down ? panel.scrollTop + panel.clientHeight < panel.scrollHeight - 1 : panel.scrollTop > 0);
|
|
101
|
+
if (!canScroll) event.preventDefault();
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
};
|
|
95
104
|
const blur = () => close(false);
|
|
96
105
|
document.addEventListener("pointerdown", pointer, true);
|
|
97
106
|
document.addEventListener("pointermove", track, true);
|
|
98
107
|
document.addEventListener("keydown", key2, true);
|
|
108
|
+
document.addEventListener("wheel", wheel, { capture: true, passive: false });
|
|
99
109
|
window.addEventListener("blur", blur);
|
|
100
110
|
return () => {
|
|
101
111
|
document.removeEventListener("pointerdown", pointer, true);
|
|
102
112
|
document.removeEventListener("pointermove", track, true);
|
|
103
113
|
document.removeEventListener("keydown", key2, true);
|
|
114
|
+
document.removeEventListener("wheel", wheel, true);
|
|
104
115
|
window.removeEventListener("blur", blur);
|
|
105
116
|
};
|
|
106
117
|
}, [open, close]);
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
.host {
|
|
2
|
-
min-width: 0;
|
|
3
|
-
}
|
|
4
|
-
.root {
|
|
5
|
-
position: fixed;
|
|
6
|
-
inset: 0;
|
|
7
|
-
margin: 0;
|
|
8
|
-
width: 100%;
|
|
9
|
-
height: 100%;
|
|
10
|
-
padding: 0;
|
|
11
|
-
border: 0;
|
|
12
|
-
background: transparent;
|
|
13
|
-
color: var(--fg);
|
|
14
|
-
overflow: visible;
|
|
15
|
-
pointer-events: none;
|
|
16
|
-
}
|
|
17
|
-
.root::backdrop {
|
|
18
|
-
background: transparent;
|
|
19
|
-
pointer-events: none;
|
|
20
|
-
}
|
|
21
|
-
.panel {
|
|
22
|
-
position: fixed;
|
|
23
|
-
pointer-events: auto;
|
|
24
|
-
width: 236px;
|
|
25
|
-
max-width: calc(100vw - 16px);
|
|
26
|
-
max-height: calc(100vh - 16px);
|
|
27
|
-
overflow: auto;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
border
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
.host {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
}
|
|
4
|
+
.root {
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
padding: 0;
|
|
11
|
+
border: 0;
|
|
12
|
+
background: transparent;
|
|
13
|
+
color: var(--fg);
|
|
14
|
+
overflow: visible;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
.root::backdrop {
|
|
18
|
+
background: transparent;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
}
|
|
21
|
+
.panel {
|
|
22
|
+
position: fixed;
|
|
23
|
+
pointer-events: auto;
|
|
24
|
+
width: 236px;
|
|
25
|
+
max-width: calc(100vw - 16px);
|
|
26
|
+
max-height: calc(100vh - 16px);
|
|
27
|
+
overflow: auto;
|
|
28
|
+
overscroll-behavior: contain;
|
|
29
|
+
padding: 5px;
|
|
30
|
+
background: var(--surface);
|
|
31
|
+
border: 1px solid var(--line);
|
|
32
|
+
border-radius: var(--radius);
|
|
33
|
+
box-shadow: var(--shadow);
|
|
34
|
+
}
|
|
35
|
+
.error {
|
|
36
|
+
padding: 8px;
|
|
37
|
+
color: var(--danger);
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.panel[inert] {
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
}
|