/** * Pure caret-position math: where the caret should land after a value change, and * helpers for the focus-strip path. DOM writes live in `./dom-writes.ts`. */ import type { FormattingOptions, CaretPositionInfo, Separators } from '@/types'; /** * Result of computing a focus-strip: the raw value with separators removed and the * caret positions mapped from the formatted display indices to the raw indices. */ export interface StripSeparatorsResult { raw: string; rawStart: number; rawEnd: number; } /** * Pure compute for the focus-strip path: takes the current formatted value plus the * user's display caret/selection, returns the stripped value and the equivalent caret * positions in the raw value. Returns `null` when no strip is needed (the value already * contains no separators). * * The mapping rule: the new caret index equals the count of non-separator characters * in the formatted prefix up to the display caret. The transformation is bijective on * digits, so this exactly preserves which digit the user clicked on. * * Does NOT mutate the DOM. Callers own the write and any internal-write/broadcast wrapping. * * @param currentValue - The current (formatted) input value * @param displayStart - selectionStart in the formatted value * @param displayEnd - selectionEnd in the formatted value * @param separator - The thousand separator character to strip * @returns Strip result, or null if no separators present */ export declare function computeStripSeparatorsResult(currentValue: string, displayStart: number, displayEnd: number, separator: string): StripSeparatorsResult | null; /** * Skips cursor over thousand separator when deleting/backspacing in 'change' mode. * This prevents the cursor from stopping on the separator, making deletion smoother. * * @param e - The keyboard event * @param inputElement - The input element * @param formattingOptions - Optional formatting options */ export declare function skipOverThousandSeparatorOnDelete(e: KeyboardEvent, inputElement: HTMLInputElement, formattingOptions?: FormattingOptions): void; /** * Pure compute version of cursor-position resolution. Returns the cursor position the * caret should land at after a value change, or null when the inputs don't provide enough * signal to compute one. Does NOT mutate the DOM. Callers own the setSelectionRange call. */ export declare function computeCursorPosition(oldValue: string, newValue: string, oldCursorPosition: number, caretPositionBeforeChange: CaretPositionInfo | undefined, separators: Separators, formattingOptions?: FormattingOptions): number | null;