/** * TyDatePicker Web Component — read-only input stub + calendar dropdown * (modal ), optional time input, form participation via * ElementInternals. Value is UTC; 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'; /** * Date components (internal representation in local timezone) */ interface DateComponents { year?: number; month?: number; day?: number; hour?: number; minute?: number; } /** * Internal date picker state */ interface DatePickerState extends DateComponents { 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; }; clearable: { type: "boolean"; visual: boolean; default: boolean; aliases: { 'not-clearable': boolean; }; }; 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; }; }; private _state; private _clickListener?; private _keydownListener?; private _dialogClickListener?; private _closeTimestamp; 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 - returns UTC string from current state * TyComponent calls this automatically when value property changes */ protected getFormValue(): FormDataEntryValue | null; 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; /** * Reflect constraint validation to the owning
via ElementInternals. * Without this `required` is only cosmetic — unlike ty-input/ty-select/ * ty-calendar, which all call setValidity, an empty required date-picker * never blocks form submission. */ private updateValidity; /** * Handle time input changes from TimeInput class */ handleTimeInputChange(hour: number, minute: number): void; 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 clearable(): boolean; set clearable(v: boolean); get min(): string; set min(v: string); get max(): string; set max(v: string); get withTime(): boolean; set withTime(v: boolean); /** * Get current value (UTC ISO string) */ get value(): string | null; /** * Set value (UTC ISO string, Date object, or null) * * When set to null/undefined/empty string, the attribute is removed. * When set to a valid date, the attribute is set to ISO UTC string. */ set value(val: string | Date | null); /** * Clear the date value programmatically WITH a change event (source: * 'clear'). Works regardless of the `clearable` attribute — 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 createTimeInputElement; private renderTimeSection; private renderCalendarDropdown; /** * 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; private calculateCalendarPosition; private renderContainer; protected render(): void; /** * 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 {};