/** * Fixed-width segment masks for typed fields — a date (`DD/MM/YYYY`), a date * range (`DD/MM/YYYY - DD/MM/YYYY`), a time (`HH:MM`). The field accepts digits * only; the mask places them into segments and writes the separators in. * * Pure functions: the components own the segment-level rules (a day is 01–31, * an hour 00–23) and pass them in through `acceptsSegment`. */ export interface MaskSegment { /** Segment name; also its placeholder text in `pattern` (`DD`, `HH`, …). */ readonly kind: K; readonly length: number; } export interface SegmentMask { readonly segments: readonly MaskSegment[]; /** Separator after each segment but the last: `separators.length === segments.length - 1`. */ readonly separators: readonly string[]; /** The whole placeholder, e.g. `DD/MM/YYYY`. */ readonly pattern: string; /** Index in a display value where each segment starts. */ readonly starts: readonly number[]; } export declare function createSegmentMask(segments: readonly MaskSegment[], separators: readonly string[]): SegmentMask; export interface ApplyMaskOptions { /** * Also write the separator after a segment that the typed digits just * completed, so the caret moves on to the next segment. Off while deleting, * so a separator can be removed. */ trailingSeparator?: boolean; /** * Whether a complete segment is valid. A trailing separator is only written * after a valid one, so the caret stays on a segment the user must correct. */ acceptsSegment?: (index: number, digits: string) => boolean; } /** Re-format raw input: keep the digits the mask has room for and write the separators in. */ export declare function applyMask(mask: SegmentMask, raw: string, options?: ApplyMaskOptions): string; /** Index of the segment a caret position falls in, or `null` past the end. */ export declare function segmentIndexAt(mask: SegmentMask, position: number): number | null; /** The text of each segment in a display value; partial or empty where not typed yet. */ export declare function readSegments(mask: SegmentMask, display: string): string[]; /** * Split a typed prefix into the part typed and the rest of the pattern, for a * ghost hint that keeps the unfilled segments visible after the caret. */ export declare function ghostParts(mask: SegmentMask, value: string): { typed: string; remaining: string; }; /** The key that types a separator: its visible character (`/`, `:`, `-` for ` - `). */ export declare function separatorKey(separator: string): string; /** * Pressing a segment's separator key while that segment is part-typed * completes it with leading zeros and moves on (`3` + `/` → `03/`). * Returns the segment index and the new value, or `null` when the key does not * apply (the value ends on a boundary, or the key is not that separator). */ export declare function padSegmentOnSeparator(mask: SegmentMask, value: string, key: string): { index: number; value: string; } | null;