UNPKG

text-interface

Version:

A simple text interface library for interactive text-based UIs.

71 lines (67 loc) 2.73 kB
/** * Apply a theme by injecting CSS into the document head at the beginning * This ensures user styles can override theme styles * @param themeCSS - The CSS string containing :root variables * @param id - Optional ID for the style element (defaults to 'text-interface-theme') */ export declare function applyTheme(themeCSS: string, id?: string): void; export declare class TextInterface { private listener; outputAnimationLength: number; outputDelay: number; shouldStealFocus: boolean; private outputQueue; private div; private inputEl; private outputEl; private placeholderEl; private promptEl; private inputWrap; private outputting; private scrollOptions; private promptString; constructor(element?: HTMLElement, title?: string, placeholder?: string, prompt?: string); setPlaceholder(text: string): void; setPrompt(text: string): void; setTitle(text: string): void; hideTitle(): void; showTitle(): void; clear(): void; setScrollOptions(options: ScrollIntoViewOptions): void; readChoice(choices: string[], prompt?: string, error?: string): Promise<string>; readYesOrNo(errorMessage?: string): Promise<boolean>; readNumber(errorMessage?: string): Promise<number>; readInteger(errorMessage?: string): Promise<number>; readIntegerInRange(min: number, max: number, errorMessage?: string): Promise<number>; readNumberInRange(min: number, max: number, errorMessage?: string): Promise<number>; readText(): Promise<string>; prompt(prompt: string): Promise<string>; promptYesOrNo(prompt: string): Promise<boolean>; promptNumber(prompt: string, errorMessage: string): Promise<number>; promptInteger(prompt: string, errorMessage: string): Promise<number>; promptNumberInRange(prompt: string, min: number, max: number, errorMessage: string): Promise<number>; promptIntegerInRange(prompt: string, min: number, max: number, errorMessage: string): Promise<number>; showElement(element: HTMLElement): Promise<void>; showHTML(arbitraryHTML: string): Promise<void>; showImage(src: string, alt?: string): Promise<void>; output(text: string, echo?: boolean): Promise<void>; private doNextOutput; private setupInputListener; } export declare const themes: { lightMode: string; darkMode: string; greenTerminal: string; orangeTerminal: string; futuristic: string; typewriter: string; vsCodeDark: string; dracula: string; solarizedDark: string; monokai: string; nord: string; solarizedLight: string; githubLight: string; paperLight: string; }; export { }