/** * The `Pick` kind: several options from a list that narrows as a person types. * * Every option carries a mark saying whether it is picked, and `space` toggles * the one under the caret. Options that name a group sit one step in beneath * the group's header, whose mark says whether all, some, or none of them are * picked and which toggles them together. Typing narrows the list to the * options whose titles contain what was typed, and a group with none of them * goes. The list shows as much as the height it is given allows, names what it * left out above and below, and keeps the header of the caret's group pinned * above it once the header has scrolled away. Neither the reducer nor the view * touches the terminal. */ import type { Doc } from "../doc.js"; import { type AskKey, type AskKind, type AskReducerAction, type PickAsk } from "./ask.js"; /** Where the caret stands, what is picked, what narrows the list, and what was refused. */ export interface PickState { /** The caret's row among the rows the filter leaves. */ readonly cursor: number; /** The positions in the question's options of those picked. */ readonly picked: ReadonlySet; readonly filter: string; /** Why the last key was refused, until the next key that changes something. */ readonly problem?: string; } export type PickAction = AskReducerAction>; /** * One line of the list: a group's header with every option in the group and * those the filter leaves, or one option by its position in the question. */ export type PickRow = { readonly _tag: "Group"; readonly label: string; readonly members: ReadonlyArray; readonly shown: ReadonlyArray; } | { readonly _tag: "Option"; readonly index: number; readonly grouped: boolean; }; /** The question opens on its first row, with the options it marks as selected picked. */ export declare const initialPickState: (ask: PickAsk) => PickState; /** * The rows the filter leaves, in order: options without a group first, then * each group in the order it first appears, its header before its options. A * group none of whose options match is left out, header and all. */ export declare const pickRows: (ask: PickAsk, filter: string) => ReadonlyArray; /** * One key against one list. The arrows move the caret and stop at either end; * `space` toggles the row under it, a group's header toggling the options of * the group that show; `ctrl`+`a` toggles every option that shows; `enter` * submits what is picked once it is within the question's bounds. Typed text * narrows the list, `backspace` takes back a character, and `ctrl`+`u` or * escape clears the filter. Escape with nothing typed, and an interrupt, * cancel. */ export declare const reducePick: (ask: PickAsk, state: PickState, key: AskKey) => PickAction; /** The question as the live scene shows it in `rows` lines while it stands open. */ export declare const pickDoc: (ask: PickAsk, state: PickState, rows: number) => Doc; /** * The one transcript line an answered list leaves behind: the titles picked, * the first few by name and the rest as a count. */ export declare const pickAnswer: (ask: PickAsk, picked: ReadonlyArray) => Doc; /** A `Pick` as the `Screen` runs it. */ export declare const pickKind: (ask: PickAsk) => AskKind; //# sourceMappingURL=pick.d.ts.map