import type { ColorInput } from "bun"; import type { Element as JSXElement } from "solid-js"; import { createSignal, For } from "solid-js"; import { useInput } from "../input/hooks.ts"; export type SelectProps = { /** The rows to choose between. */ items: readonly T[]; /** * Render a row's label. Receives the item, whether it's highlighted, and its * index. Default renders `String(item)` (bold + `highlightColor` when * highlighted). Supply this to render richer rows; you then own their styling. */ children?: (item: T, highlighted: boolean, index: number) => JSXElement; /** * Highlighted index. Pass it to drive the highlight yourself (controlled); * omit it to let `Select` track the highlight internally (uncontrolled). */ index?: number; /** Fires when the highlight moves (↑/↓, `k`/`j`, or hover). */ onHighlight?: (item: T, index: number) => void; /** Fires when a row is committed (Enter or click). */ onSelect?: (item: T, index: number) => void; /** Only handle keys while true. Default true. */ focused?: boolean; /** Glyph in the gutter of the highlighted row. Default `❯`. */ indicator?: string; /** Color of the highlighted row + its indicator. Default `#d77757`. */ highlightColor?: ColorInput; /** Color of the non-highlighted rows. */ color?: ColorInput; }; /** * A keyboard- and mouse-navigable list. `↑`/`↓` (or `k`/`j`) move the * highlight, Enter commits it, and — when the screen has `mouse: true` — hover * highlights a row and a click commits it. Each row is `indicator + label`, the * indicator marking the current row in the gutter so labels stay aligned. * * Uncontrolled by default (it tracks the highlight itself); pass `index` to * drive the highlight from the parent. `onHighlight` fires as the highlight * moves, `onSelect` when a row is committed. * * ```tsx *