@nick-skriabin/glyph 0.1.22 → 0.1.23
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/dist/index.cjs +30 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1591,12 +1591,17 @@ function render(element, opts = {}) {
|
|
|
1591
1591
|
const currentFb = new Framebuffer(terminal.columns, terminal.rows);
|
|
1592
1592
|
let fullRedraw = true;
|
|
1593
1593
|
const inputHandlers = /* @__PURE__ */ new Set();
|
|
1594
|
+
const priorityHandlers = /* @__PURE__ */ new Set();
|
|
1594
1595
|
const focusedInputHandlers = /* @__PURE__ */ new Map();
|
|
1595
1596
|
const inputContextValue = {
|
|
1596
1597
|
subscribe(handler) {
|
|
1597
1598
|
inputHandlers.add(handler);
|
|
1598
1599
|
return () => inputHandlers.delete(handler);
|
|
1599
1600
|
},
|
|
1601
|
+
subscribePriority(handler) {
|
|
1602
|
+
priorityHandlers.add(handler);
|
|
1603
|
+
return () => priorityHandlers.delete(handler);
|
|
1604
|
+
},
|
|
1600
1605
|
registerInputHandler(focusId, handler) {
|
|
1601
1606
|
focusedInputHandlers.set(focusId, handler);
|
|
1602
1607
|
return () => focusedInputHandlers.delete(focusId);
|
|
@@ -1842,7 +1847,13 @@ function render(element, opts = {}) {
|
|
|
1842
1847
|
continue;
|
|
1843
1848
|
}
|
|
1844
1849
|
let consumed = false;
|
|
1845
|
-
|
|
1850
|
+
for (const handler of priorityHandlers) {
|
|
1851
|
+
if (handler(key)) {
|
|
1852
|
+
consumed = true;
|
|
1853
|
+
break;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
if (!consumed && focusedId) {
|
|
1846
1857
|
const inputHandler = focusedInputHandlers.get(focusedId);
|
|
1847
1858
|
if (inputHandler) {
|
|
1848
1859
|
consumed = inputHandler(key);
|
|
@@ -2360,6 +2371,7 @@ function Keybind({
|
|
|
2360
2371
|
keypress,
|
|
2361
2372
|
onPress,
|
|
2362
2373
|
whenFocused,
|
|
2374
|
+
priority,
|
|
2363
2375
|
disabled
|
|
2364
2376
|
}) {
|
|
2365
2377
|
const inputCtx = React15.useContext(InputContext);
|
|
@@ -2370,13 +2382,23 @@ function Keybind({
|
|
|
2370
2382
|
matcherRef.current = parseKeyDescriptor(keypress);
|
|
2371
2383
|
React15.useEffect(() => {
|
|
2372
2384
|
if (!inputCtx || disabled) return;
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2385
|
+
if (priority) {
|
|
2386
|
+
const handler = (key) => {
|
|
2387
|
+
if (!matchesKey(matcherRef.current, key)) return false;
|
|
2388
|
+
if (whenFocused && focusCtx?.focusedId !== whenFocused) return false;
|
|
2389
|
+
onPressRef.current();
|
|
2390
|
+
return true;
|
|
2391
|
+
};
|
|
2392
|
+
return inputCtx.subscribePriority(handler);
|
|
2393
|
+
} else {
|
|
2394
|
+
const handler = (key) => {
|
|
2395
|
+
if (!matchesKey(matcherRef.current, key)) return;
|
|
2396
|
+
if (whenFocused && focusCtx?.focusedId !== whenFocused) return;
|
|
2397
|
+
onPressRef.current();
|
|
2398
|
+
};
|
|
2399
|
+
return inputCtx.subscribe(handler);
|
|
2400
|
+
}
|
|
2401
|
+
}, [inputCtx, focusCtx, whenFocused, priority, disabled]);
|
|
2380
2402
|
return null;
|
|
2381
2403
|
}
|
|
2382
2404
|
function Portal({ children, zIndex = 1e3 }) {
|