export type SegmentType = "year" | "month" | "day" | "hour" | "minute" | "dayPeriod"; /** Accessible names per segment. Keys match {@link SegmentType} so `labels[type]` resolves. */ export interface SegmentLabels { year: string; month: string; day: string; hour: string; minute: string; dayPeriod: string; } export type LayoutSegment = { kind: "field"; type: SegmentType; } | { kind: "literal"; value: string; }; export interface DateLayout { /** Field + literal segments in locale display order. */ segments: LayoutSegment[]; hour12: boolean; /** Localized AM/PM strings (only meaningful when hour12). */ amText: string; pmText: string; } /** Committed segment values. `hour` is canonical 0–23 regardless of display. */ export interface SegmentBuffer { year: number | null; month: number | null; day: number | null; hour: number | null; minute: number | null; } export declare function emptyBuffer(): SegmentBuffer; /** The Intl options a TIME reads under — 12-vs-24-hour follows from the locale's * own resolution of these. Exported because the segments and the picker list * that fills them (`time_options`) must agree. */ export declare const TIME_FORMAT_OPTIONS: Intl.DateTimeFormatOptions; export declare function getDateLayout(locale: string, hasTime: boolean): DateLayout; /** Time-only layout (hour / minute / dayPeriod), for a standalone time field. */ export declare function getTimeLayout(locale: string): DateLayout; /** Editable field segments in display order (literals dropped). */ export declare function fieldOrder(layout: DateLayout): SegmentType[]; export declare function to12h(hour24: number): { h12: number; pm: boolean; }; export declare function from12h(h12: number, pm: boolean): number; export declare function placeholderFor(type: SegmentType): string; export interface DigitResult { /** In-progress text for the segment. */ text: string; /** Parsed numeric value (display domain — for `hour` in 12h mode this is 1–12). */ value: number; /** When true the segment is full and focus should advance to the next field. */ complete: boolean; } /** Apply a typed digit to a numeric segment's in-progress text. */ export declare function typeDigit(type: SegmentType, currentText: string, digit: string, hour12: boolean): DigitResult; /** A typed separator advances to the next segment — "1" alone cannot * auto-advance (it might be "12"), so the separator is the typist's explicit * "done here". A leading one is a no-op, matching native date inputs. */ export declare function separatorAdvances(key: string, segmentHasContent: boolean): boolean; /** Step a numeric segment up/down, wrapping within its range. */ export declare function incrementSegment(type: SegmentType, current: number | null, delta: number, hour12: boolean): number; /** Convert a typed `hour` segment value (display domain) to a canonical 0–23 hour. */ export declare function setHourField(buffer: SegmentBuffer, typed: number, hour12: boolean): number; /** Set the AM/PM half-day, preserving the displayed 12-hour value. */ export declare function withDayPeriod(buffer: SegmentBuffer, pm: boolean): number; /** Zero-padded display text for a committed segment, or null when unset. */ export declare function displayValue(type: SegmentType, buffer: SegmentBuffer, layout: DateLayout): string | null; export declare function valueToSegments(iso: string, hasTime: boolean): SegmentBuffer; export declare function isBufferEmpty(buffer: SegmentBuffer, hasTime: boolean): boolean; /** Compose a canonical ISO value, or null when the buffer is incomplete/invalid. */ export declare function segmentsToValue(buffer: SegmentBuffer, hasTime: boolean): string | null; /** The layout + value↔buffer mapping the segment engine drives a field with. */ export interface SegmentsConfig { layout: DateLayout; toBuffer: (value: string) => SegmentBuffer; toValue: (buffer: SegmentBuffer) => string | null; isEmpty: (buffer: SegmentBuffer) => boolean; /** Parse loosely-typed/pasted text to a canonical value, or null. */ parse: (text: string) => string | null; } export declare function dateSegmentsConfig(locale: string, hasTime: boolean): SegmentsConfig; /** "HH:mm" → buffer. Anything unparseable or out of range reads as empty. */ export declare function timeToSegments(time: string): SegmentBuffer; /** Buffer → canonical "HH:mm", or null while either half is still missing. */ export declare function segmentsToTime(buffer: SegmentBuffer): string | null; export declare function timeSegmentsConfig(locale: string): SegmentsConfig;