caique
API reference

caique/inquirer/prompts

Every export of caique/inquirer/prompts, with its signature and doc comment: Separator, checkbox, editor, confirm, input, number and 5 more, plus 25 types.

caique/inquirer/prompts — @inquirer/prompts' prompts, over caique/inquirer's loop.

import { Separator, checkbox, editor, … } from 'caique/inquirer/prompts';

Constants

checkbox

Ask for any of choices.

const checkbox: <Value>(config: CheckboxConfig<Value>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Value[]>;

confirm

const confirm: import("./inquirer.js").Prompt<boolean, ConfirmConfig>;

editor

const editor: import("./inquirer.js").Prompt<string, EditorConfig>;

expand

const expand: <Value>(config: ExpandConfig<Value>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Value>;

input

const input: import("./inquirer.js").Prompt<string, InputConfig>;

number

const number: <Required extends boolean>(config: NumberConfig<Required>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Required extends true ? number : number | undefined>;

password

const password: import("./inquirer.js").Prompt<string, PasswordConfig>;

rawlist

const rawlist: <Value>(config: RawlistConfig<Value>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Value>;
const search: <Value>(config: SearchConfig<Value>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Value>;

select

Ask for one of choices.

const select: <Value>(config: SelectConfig<Value>, context?: import("./inquirer.js").Context) => import("./inquirer.js").CancelablePromise<Value>;

Interfaces

CheckboxConfig

checkbox's configuration, as @inquirer/checkbox declares it.

interface CheckboxConfig<Value> {
    message: string;
    prefix?: string;
    pageSize?: number;
    choices: readonly (Value | Choice<Value> | Separator)[];
    loop?: boolean;
    required?: boolean;
    validate?: (choices: readonly NormalizedChoice<Value>[]) => boolean | string | Promise<string | boolean>;
    theme?: PartialTheme<CheckboxTheme>;
    shortcuts?: {
        all?: string | null;
        invert?: string | null;
    };
}

CheckboxTheme

What checkbox adds to the core theme.

interface CheckboxTheme {
    icon: {
        checked: string;
        unchecked: string;
        cursor: string;
        disabledChecked: string;
        disabledUnchecked: string;
    };
    style: {
        disabled: (text: string) => string;
        renderSelectedChoices: <T>(selectedChoices: readonly NormalizedChoice<T>[], allChoices: readonly Item<T>[]) => string;
        description: (text: string) => string;
        keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
    };
    i18n: {
        disabledError: string;
    };
}

Choice

A choice as a caller may write it.

interface Choice<Value> {
    value: Value;
    name?: string;
    checkedName?: string;
    description?: string;
    short?: string;
    disabled?: boolean | string;
    checked?: boolean;
    type?: never;
}

ConfirmConfig

confirm's config, as the incumbent declares it.

interface ConfirmConfig {
    message: string;
    default?: boolean | undefined;
    transformer?: (value: boolean) => string;
    theme?: PartialDeep<Theme & ConfirmTheme>;
}

ConfirmTheme

What confirm adds to the shared theme.

interface ConfirmTheme {
    /** The words that answer yes and no, matched by prefix; `y`, `n`, `yes` and `no` always work too. */
    keywords: {
        yes: string;
        no: string;
        error: (keywords: {
            yes: string;
            no: string;
        }) => string;
    };
    /** How the default's letter is drawn in the `Y/n` hint. */
    style: {
        confirmDefault: (text: string) => string;
    };
}

EditorConfig

editor's config, as the incumbent declares it.

interface EditorConfig {
    message: string;
    default?: string | undefined;
    postfix?: string;
    waitForUserInput?: boolean;
    validate?: (value: string) => boolean | string | Promise<string | boolean>;
    file?: EditorFileOptions;
    theme?: PartialDeep<Theme & EditorTheme>;
}

EditorFileOptions

Where the temporary file goes and what it is called, as @inquirer/external-editor takes it.

interface EditorFileOptions {
    prefix?: string;
    postfix?: string;
    mode?: number;
    dir?: string;
}

EditorTheme

What editor adds to the shared theme.

interface EditorTheme {
    validationFailureMode: 'keep' | 'clear';
    style: {
        loadingMessage: () => string;
        waitingMessage: (enterKey: string) => string;
    };
}

ExpandConfig

expand's config, as the incumbent declares it.

interface ExpandConfig<Value> {
    message: string;
    choices: readonly (Separator | {
        key: ExpandKey;
        name: Value & string;
        value?: never;
    } | ExpandChoice<Value>)[];
    default?: ExpandKey | 'h';
    expanded?: boolean;
    theme?: PartialDeep<Theme>;
}

InputConfig

input's config, as the incumbent declares it.

interface InputConfig {
    message: string;
    default?: string | undefined;
    prefill?: 'tab' | 'editable';
    required?: boolean;
    transformer?: (value: string, flags: {
        isFinal: boolean;
    }) => string;
    validate?: (value: string) => Verdict;
    theme?: PartialDeep<Theme & InputTheme>;
    pattern?: RegExp;
    patternError?: string;
}

InputTheme

What input adds to the shared theme.

interface InputTheme {
    validationFailureMode: 'keep' | 'clear';
}

NormalizedChoice

A choice once the prompt has filled in every field.

interface NormalizedChoice<Value> {
    value: Value;
    name: string;
    checkedName: string;
    description?: string;
    short: string;
    disabled: boolean | string;
    checked: boolean;
}

NumberConfig

number's config, as the incumbent declares it.

interface NumberConfig<Required extends boolean = boolean> {
    message: string;
    default?: number | undefined;
    min?: number;
    max?: number;
    step?: number | 'any';
    required?: Required;
    validate?: (value: Required extends true ? number : number | undefined) => Verdict;
    theme?: PartialDeep<Theme>;
}

PasswordConfig

password's config, as the incumbent declares it.

interface PasswordConfig {
    message: string;
    mask?: boolean | string;
    toggleMask?: boolean;
    validate?: (value: string) => Verdict;
    theme?: PartialDeep<Theme & PasswordTheme>;
}

PasswordTheme

What password adds to the shared theme.

interface PasswordTheme {
    style: {
        maskedText: string;
        keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
    };
}

RawlistChoice

A rawlist choice as a caller writes it.

interface RawlistChoice<Value> {
    value: Value;
    name?: string;
    short?: string;
    key?: string;
    description?: string;
}

RawlistConfig

rawlist's config, as the incumbent declares it.

interface RawlistConfig<Value> {
    message: string;
    choices: readonly (Value | RawlistChoice<Value> | Separator)[];
    loop?: boolean;
    theme?: PartialDeep<Theme & RawlistTheme>;
    default?: NoInfer<Value>;
}

RawlistTheme

What rawlist adds to the shared theme.

interface RawlistTheme {
    style: {
        description: (text: string) => string;
    };
}

SearchConfig

search's config, as the incumbent declares it.

interface SearchConfig<Value> {
    message: string;
    source: (term: string | undefined, opt: {
        signal: AbortSignal;
    }) => readonly (Value | SearchChoice<Value> | Separator)[] | Promise<readonly (Value | SearchChoice<Value> | Separator)[]>;
    validate?: (value: Value) => boolean | string | Promise<string | boolean>;
    pageSize?: number;
    default?: NoInfer<Value>;
    initialValue?: string;
    theme?: PartialDeep<Theme & SearchTheme>;
}

SearchTheme

What search adds to the shared theme.

interface SearchTheme {
    icon: {
        cursor: string;
    };
    style: {
        disabled: (text: string) => string;
        searchTerm: (text: string) => string;
        description: (text: string) => string;
        keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
    };
}

SelectConfig

select's configuration, as @inquirer/select declares it.

interface SelectConfig<Value> {
    message: string;
    choices: readonly (Value | Omit<Choice<Value>, 'checked' | 'checkedName'> | Separator)[];
    pageSize?: number;
    loop?: boolean;
    default?: NoInfer<Value>;
    theme?: PartialTheme<SelectTheme>;
}

SelectTheme

What select adds to the core theme.

interface SelectTheme {
    icon: {
        cursor: string;
    };
    style: {
        disabled: (text: string) => string;
        description: (text: string) => string;
        keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
    };
    i18n: {
        disabledError: string;
    };
    indexMode: 'hidden' | 'number';
}

Types

ExpandChoice

An expand choice: a key, and a value, a name, or both.

type ExpandChoice<Value> = {
    key: ExpandKey;
    value: Value;
} | {
    key: ExpandKey;
    name: string;
    value: Value;
};

ExpandKey

The keys expand accepts: a letter or a digit, h aside, because h is help.

type ExpandKey = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';

SearchChoice

A search choice as a caller writes it: select's, without checkbox's fields.

type SearchChoice<Value> = Omit<Choice<Value>, 'checked' | 'checkedName'>;

Re-exported

Documented on the page of the entry point that declares them.

ExportKindDocumented in
Separatorclasscaique/inquirer

On this page