import { ReactiveController, ReactiveControllerHost } from 'lit'; import { UCalendar } from './UCalendar.js'; import { UPopover } from '../popover/UPopover.js'; /** What a picker with a typed-date text box gives the controller. */ export interface DateTextControllerOptions { /** The value to commit for the typed text — `undefined` for empty text, `null` when it is not readable. */ toValue(text: string): string | undefined | null; /** The ISO day the typed text points at, so an open calendar can follow the typing; `null` when none. */ dayOf(text: string): string | null; /** The value as the text box shows it when nothing is being typed. */ shown(): string; /** Called after a commit that changed the value — the picker validates and fires `change`. */ onChange(): void; /** Called when unreadable text is committed without a value change — the picker re-validates. */ onBadText(): void; popover(): UPopover | undefined; calendar(): UCalendar | undefined; container(): HTMLElement | undefined; input(): HTMLInputElement | null; /** Whether the picker takes input now (not disabled, not read-only). */ interactive(): boolean; } type Host = ReactiveControllerHost & HTMLElement & { value?: string; }; /** * The typed-date text box shared by `u-date-picker` and `u-date-range-picker`: what is being typed * (`draft`), whether the last commit was unreadable (`badText`), committing on Enter and blur, * opening the calendar on a click (caret stays in the box) or ArrowDown (focus moves into the grid), * and following the typing in an open calendar. */ export declare class DateTextController implements ReactiveController { private readonly host; private readonly options; /** What the person is typing, until it is committed; `null` shows the value. */ draft: string | null; /** The committed text was not readable — the value is empty and validity reports `badInput`. */ badText: boolean; private focusGridOnOpen; constructor(host: Host, options: DateTextControllerOptions); hostConnected(): void; /** The text box's current text. */ get text(): string; /** Forget what was typed — after a calendar pick, a clear or a reset. */ clear(): void; /** Called when the calendar has opened: show the typed (or current) month and, if the opening * came from the keyboard, move focus into the grid. */ calendarOpened(fallbackDay: string | Date): void; open(focusGrid: boolean): void; handleInput: (e: Event) => void; /** ArrowDown / Alt+ArrowDown opens the calendar and moves into it (the combobox convention); * Enter commits what was typed. Escape belongs to the popover layer — it closes the calendar. */ handleKeydown: (e: KeyboardEvent) => void; /** A click on the field (not on its clear or calendar button) opens the calendar and keeps the * caret in the text box — the person can pick a day or keep typing. */ handleContainerClick: (e: MouseEvent) => void; /** A press on a part of the calendar that takes no focus — the month title, the weekday row, the * gaps — keeps focus where it is, inside the control. Without this the browser moves focus to the * page: the control loses its place for the keyboard, and a host that ends an edit on `blur` * (a table cell editor) ends it in the middle of choosing. Presses on controls are untouched. */ holdFocus: (e: MouseEvent, boundary?: EventTarget | null) => void; handleCalendarButtonClick: (e: MouseEvent) => void; /** Turns the typed text into the value. Empty text clears it; unreadable text also clears it and * reports `badInput` while the text stays to be fixed (the native date input does the same). */ commit: () => void; } export {};