UNPKG

asciitorium

Version:

an ASCII ui framework for web + cli

30 lines (29 loc) 1.08 kB
import { Component, ComponentProps } from '../core/Component'; import { State } from '../core/State'; export interface TextInputOptions extends Omit<ComponentProps, 'height'> { /** Accepts string OR number state */ value?: State<string> | State<number>; /** Shown when empty (string or number ok) */ placeholder?: string | number; /** Fixed height (defaults 3) */ height?: number; /** If true, restricts typing to numeric characters (0-9, one '.', leading '-') */ numeric?: boolean; } export declare class TextInput extends Component { /** Internal editable string state (always string) */ private readonly valueStr; /** Optional backing number state we mirror into/out of */ private readonly valueNum?; private readonly placeholder; private readonly numericMode; private cursorIndex; private suppressCursorSync; focusable: boolean; hasFocus: boolean; constructor(options: TextInputOptions); private setString; private allowChar; handleEvent(event: string): boolean; draw(): string[][]; }