/** * Shared TUI form and toggle utilities built on `@earendil-works/pi-tui`. * * These helpers render interactive forms (title, labelled toggle and text * fields, explanatory notes and action buttons) that plug directly into * Pi's `ctx.ui.custom()` overlay API. The Exa configuration modal * and any future provider modal are built on top of * {@link createForm}. * * A form is a single focusable `Component`: Pi gives it keyboard focus and * forwards every keystroke to {@link FormComponent.handleInput}. The form * navigates between fields with the arrow keys (and Tab / Shift+Tab), * toggles boolean fields with the left/right arrows or space, edits text * fields (a simple single-line editor with an exact cursor), submits on * Enter and cancels on Escape. */ import { Key, Spacer, Text, VStack, matchesKey, type Component, type Focusable, } from "@earendil-works/pi-tui"; import type { Theme } from "@earendil-works/pi-coding-agent"; /** The kind of a form field. */ export type FormFieldKind = "toggle" | "text"; /** * Declarative description of a single form field. * * - `toggle` fields are boolean and rendered as `[