fix: render TUI pickers as overlays

This commit is contained in:
Peter Steinberger
2026-01-15 01:59:05 +00:00
parent 1b79730db8
commit 7904a14af1
4 changed files with 83 additions and 20 deletions

19
src/tui/tui-overlays.ts Normal file
View File

@@ -0,0 +1,19 @@
import type { Component, TUI } from "@mariozechner/pi-tui";
type OverlayHost = Pick<TUI, "showOverlay" | "hideOverlay" | "hasOverlay" | "setFocus">;
export function createOverlayHandlers(host: OverlayHost, fallbackFocus: Component) {
const openOverlay = (component: Component) => {
host.showOverlay(component);
};
const closeOverlay = () => {
if (host.hasOverlay()) {
host.hideOverlay();
return;
}
host.setFocus(fallbackFocus);
};
return { openOverlay, closeOverlay };
}