/** * TyDatePicker Web Component — read-only input stub + calendar dropdown * (modal ), optional time input, form participation via * ElementInternals. Value is a UTC instant (wall-clock with `native`); * display is local. */ import { type Placement } from '../utils/positioning.js'; import { TyComponent } from '../base/ty-component.js'; import type { Flavor } from '../types/common.js'; import type { PropertyChange } from '../utils/property-manager.js'; import { type DateTimeParts } from '../utils/calendar-utils.js'; /** * Internal date picker state */ interface DatePickerState extends DateTimeParts { withTime: boolean; open: boolean; } type DatePickerSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; /** * Date picker flavors (visual styles) */ type DatePickerFlavor = 'default' | Flavor; type DateFormatType = 'short' | 'medium' | 'long' | 'full'; /** * Change event detail */ export interface DatePickerChangeDetail { value: string | null; localValue: string | null; milliseconds: number | null; formatted: string | null; source: 'selection' | 'time-change' | 'clear' | 'external'; } export declare class TyDatePicker extends TyComponent { protected static properties: { placement: { type: "string"; visual: boolean; default: string; }; size: { type: "string"; visual: boolean; default: import("../types/common.js").Size; validate: (v: any) => boolean; coerce: (v: any) => any; }; flavor: { type: "string"; visual: boolean; default: string; }; label: { type: "string"; visual: boolean; default: string; }; placeholder: { type: "string"; visual: boolean; default: string; }; name: { type: "string"; visual: boolean; default: string; }; min: { type: "string"; visual: boolean; default: string; }; max: { type: "string"; visual: boolean; default: string; }; required: { type: "boolean"; visual: boolean; default: boolean; }; disabled: { type: "boolean"; visual: boolean; default: boolean; }; noClear: { type: "boolean"; visual: boolean; default: boolean; }; error: { type: "string"; visual: boolean; default: string; }; format: { type: "string"; visual: boolean; default: string; validate: (v: any) => boolean; coerce: (v: any) => any; }; locale: { type: "string"; visual: boolean; default: string; }; value: { type: "string"; visual: boolean; formValue: boolean; emitChange: boolean; default: null; }; 'with-time': { type: "boolean"; visual: boolean; default: boolean; }; native: { type: "boolean"; visual: boolean; default: boolean; }; }; private _state; private _clickListener?; private _keydownListener?; private _dialogClickListener?; private _closeTimestamp; private _initialized; private _syncing; private _timeInput?; private _localeObserver?; private _customFlavorSheet; static formAssociated: boolean; constructor(); /** TyComponent handles property capture automatically. */ protected onConnect(): void; /** Custom (non-built-in) flavors — see utils/flavor-sheet.ts. */ private _syncCustomFlavor; protected onDisconnect(): void; /** Handle state updates BEFORE render. */ protected onPropertiesChanged(changes: PropertyChange[]): void; /** * Get form value - the submitted string from current state (see * componentsToOutputValue). TyComponent calls this automatically when the * value property changes. */ protected getFormValue(): FormDataEntryValue | null; private outputValue; protected updateFormValue(): void; /** The field's focusable element: the stub, or the native input on touch devices. */ private focusTarget; /** Focus the field: the host itself isn't focusable. Disabled: nothing, like a native input. */ focus(options?: FocusOptions): void; /** * `required` used to be cosmetic: nothing reported valueMissing, so an empty * required picker never blocked its form. Disabled pickers don't validate. * The message is a native date (datetime-local with time) input's. */ private updateValidity; private getComponents; /** * Whether internal state has a complete date */ private hasDate; /** * Format current components for display using Intl API */ private getFormattedValue; /** * Initialize component state from attributes */ private initializeState; private updateState; /** * Sync form value with current state * Compares before setting to prevent circular triggers */ private syncFormValue; /** * Handle time changes from the footer's hour/minute fields */ handleTimeInputChange(hour: number, minute: number): void; /** Footer summary under the time fields: "Wed, Sep 23 · 14:30" + local ISO. */ private updateTimeSummary; private emitChangeEvent; get size(): DatePickerSize; set size(v: DatePickerSize); get placement(): Placement | ''; set placement(v: Placement | ''); get flavor(): DatePickerFlavor; set flavor(v: DatePickerFlavor); get label(): string; set label(v: string); get placeholder(): string; set placeholder(v: string); get name(): string; set name(v: string); get format(): DateFormatType; set format(v: DateFormatType); get locale(): string; set locale(v: string); get required(): boolean; set required(v: boolean); get disabled(): boolean; set disabled(v: boolean); get noClear(): boolean; set noClear(v: boolean); get min(): string; set min(v: string); get max(): string; set max(v: string); get withTime(): boolean; set withTime(v: boolean); get native(): boolean; set native(v: boolean); get error(): string; set error(v: string); /** * Get current value — the string the form submits: a UTC ISO instant, or * wall-clock ('YYYY-MM-DD' / 'YYYY-MM-DDTHH:mm') with `native`. null when * empty (the form then submits name=, like a native date input). */ get value(): string | null; /** * Set value: any format parseDateTime() reads, a Date, epoch milliseconds, * or null. It's normalized to the submitted form. * * When set to null/undefined/empty string, the attribute is removed. */ set value(val: string | number | Date | null); /** * Clear the date value programmatically WITH a change event (source: * 'clear'). Works regardless of `no-clear` — lets any * external trigger (e.g. a button elsewhere in the page) clear the value * without needing the built-in clear button. Mirrors ty-select's clear(). */ clear(): void; private buildStubClasses; private renderStub; private createTimeField; /** Footer: clock + "Time" on the left, HH : MM on the right, summary below. */ private renderTimeSection; private renderCalendarDropdown; /** * Match the popup calendar to the stub's look: danger while an error * shows, as on the stub (styles: errorLook), else the user's flavor. * 'default' is the stub's own unstyled state, not a real flavor: the * calendar stays on its own default. */ private calendarFlavor; /** * Render native date input for mobile touch devices. * Uses or when with-time. * Reuses .date-picker-stub styling and existing event/state infrastructure. */ private renderNativeInput; /** * The touch devices' native input follows the picker: type (date, or * datetime-local with time), disabled, required, min/max (datetime-local * wants a time suffix) and value — also when they change at runtime. */ private syncNativeInput; private calculateCalendarPosition; private renderContainer; protected render(): void; /** * The `error` line under the field — same markup as ty-input's; the field * (stub, or the native input on touch devices) is described by it. */ private syncErrorLine; /** * Update display without destroying DOM (for open dialog) */ private updateDisplay; private setupEventListeners; private handleStubClick; /** * Clear the date value, sync state, emit event, and re-render. */ private clearValue; private handleClearClick; private handleCalendarChange; private handleDialogClick; private handleOutsideClick; private handleEscapeKey; private openDropdown; private closeDropdown; private cleanup; } export {};