import { KeyboardInput, KeyboardOptions, CursorPosition, CursorWorkerParams } from '../types'; import type Keyboard from '../Keyboard'; /** * CursorWorker. * Controls input value insertion */ declare class CursorWorker { getOptions: () => KeyboardOptions; getCursorPositionStart: () => CursorPosition; getCursorPositionEnd: () => CursorPosition; keyboardInstance: Keyboard; maxLengthReached: boolean; /** * Last cursor position at start for POS keyup event fix */ lastCursorPositionStart: CursorPosition; /** * Last cursor position end for POS keyup event fix */ lastCursorPositionEnd: CursorPosition; /** * Cursor position at start */ cursorPositionStart: CursorPosition; /** * Cursor position end */ cursorPositionEnd: CursorPosition; /** * Captured cursor input target */ cursorInputTarget?: HTMLInputElement | null; /** * Control flag for events setup */ setuped: boolean; /** * Creates an instance of the CursorWorker */ constructor({ getOptions, keyboardInstance }: CursorWorkerParams); /** * Moves the cursor position by a given amount * * @param length Represents by how many characters the input should be moved * @param minus Whether the cursor should be moved to the left or not. * @param moveCursor Move cursor of target input or not * @param customTarget Pass early input event from focus */ updateCursorPos(length: number, minus?: boolean, moveCursor?: boolean, customTarget?: any): void; /** * Action method of updateCursorPos * * @param length Represents by how many characters the input should be moved * @param minus Whether the cursor should be moved to the left or not. */ private updateCursorPosAction; /** * Adds a string to the input at a given position * * @param source The source input * @param str The string to add * @param positionStart The (cursor) position where the string should be added * @param positionEnd The end (cursor) position, normally same as positionStart * @param moveCursor Whether to update mamba-keyboard's cursor */ private addStringAt; /** * Removes an amount of characters before a given position * * @param source The source input * @param position The (cursor) position from where the characters should be removed * @param moveCursor Whether to update mamba-keyboard's cursor */ private removeAt; /** * Removes an amount of characters after a given position * * @param source The source input * @param position The (cursor) position from where the characters should be removed */ private removeForwardsAt; /** * Gets the current value of maxLengthReached * * @returns If max length reached */ isMaxLengthReached(): boolean; /** * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered */ private cursorEventHandler; /** * Handles mamba-keyboard event listeners */ setupCursorEventsControl(): void; /** * Remove cursor worker controls events */ ceaseCursorEventsControl(): void; /** * Changes the internal cursor position * * @param position The cursor's start position * @param positionEnd The cursor's end position * @param moveCursor Move cursor of target input or not * @param customTarget Pass early input event from focusin */ setCursorPosition(position: CursorPosition, endPosition?: CursorPosition, moveCursor?: boolean, customTarget?: any): void; /** * Determines whether the max length has been reached when maxLength option are set. * * @param keyboardInput * @param updatedInput */ handleMaxLength(keyboardInput: KeyboardInput, updatedInput: string): boolean; /** * Filters numeric output to handle formatted inputs * @experimental * * @param value * @returns */ shouldFilterNumericValue(value: string): string; /** * Returns the updated input resulting from clicking a given button * * @param button The button's layout name * @param input The input string * @param cursorPos The cursor's current position * @param cursorPosEnd The cursor's current end position * @param moveCursor Whether to update mamba-keyboard's cursor * @return Updated input value */ getUpdatedInput(button: string, input: string, moveCursor?: boolean): string; } /** * Export only type */ export type { CursorWorker }; export default CursorWorker;