UNPKG

asciitorium

Version:
42 lines (41 loc) 1.46 kB
import { Component, ComponentProps } from '../core/Component.js'; import { State } from '../core/State.js'; export interface TextInputOptions extends ComponentProps { /** Accepts string OR number state */ value?: State<string> | State<number>; /** Shown when empty (string or number ok) */ placeholder?: string | number; /** If true, restricts typing to numeric characters (0-9, one '.', leading '-') */ numeric?: boolean; /** Callback function called when Enter key is pressed */ onEnter?: () => void; } 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 readonly fixedHeight?; private readonly onEnter?; private initialHeightCalculated; private cursorIndex; private suppressCursorSync; private cursorVisible; private blinkInterval?; focusable: boolean; constructor(options: TextInputOptions); private setString; private updateHeight; private calculateRequiredHeight; private wrapText; private allowChar; private startCursorBlink; private stopCursorBlink; private resetCursorBlink; destroy(): void; handleEvent(event: string): boolean; draw(): string[][]; private getCursorPosition; }