import { Option, Schema as S } from 'effect'; import * as Calendar from 'foldkit/calendar'; import type { CalendarDate } from 'foldkit/calendar'; import type { ChildAttribute, Html } from 'foldkit/html'; import { type Reflect } from 'foldkit/submodel'; import * as Update from 'foldkit/update'; import type { AnchorConfig } from '../anchor/index.js'; import * as UiCalendar from '../calendar/index.js'; /** Schema for the date picker component's private interaction state. The * selected date is owned by the parent and passed in via * `ViewInputs.maybeSelectedDate`. This holds the embedded Calendar submodel * (the visible grid) and the embedded Popover submodel (the open/close + * transition layer). */ export declare const Model: S.Struct<{ readonly id: S.String; readonly calendar: S.Struct<{ readonly id: S.String; readonly today: S.Struct<{ readonly year: S.Int; readonly month: S.Int; readonly day: S.Int; }>; readonly viewYear: S.Int; readonly viewMonth: S.Int; readonly viewMode: S.Literals; readonly maybeFocusedDate: S.Option>; readonly isGridFocused: S.Boolean; readonly locale: S.Struct<{ readonly firstDayOfWeek: S.Literals; readonly monthNames: S.Tuple; readonly shortMonthNames: S.Tuple; readonly dayNames: S.Tuple; readonly shortDayNames: S.Tuple; }>; readonly maybeMinDate: S.Option>; readonly maybeMaxDate: S.Option>; readonly disabledDaysOfWeek: S.$Array>; readonly disabledDates: S.$Array>; }>; readonly popover: S.Struct<{ readonly id: S.String; readonly isOpen: S.Boolean; readonly isAnimated: S.Boolean; readonly isModal: S.Boolean; readonly contentFocus: S.Boolean; readonly animation: S.Struct<{ readonly id: S.String; readonly isShowing: S.Boolean; readonly transitionState: S.Literals; }>; readonly maybeLastButtonPointerType: S.Option; }>; }>; export type Model = typeof Model.Type; /** Union of all messages the date picker component can produce. */ export declare const Message: import("foldkit/message").MessageUnion<{ readonly GotCalendarMessage: { readonly message: import("foldkit/message").MessageUnion<{ readonly ClickedDay: { readonly date: S.Struct<{ readonly year: S.Int; readonly month: S.Int; readonly day: S.Int; }>; }; readonly PressedKeyOnGrid: { readonly key: S.String; readonly isShift: S.Boolean; }; readonly ClickedPreviousMonthButton: {}; readonly ClickedNextMonthButton: {}; readonly ClickedHeading: {}; readonly SelectedMonth: { readonly month: S.Int; }; readonly SelectedYear: { readonly year: S.Int; }; readonly PagedYears: { readonly direction: S.Literals; }; readonly FocusedGrid: {}; readonly BlurredGrid: {}; readonly RefreshedToday: { readonly today: S.Struct<{ readonly year: S.Int; readonly month: S.Int; readonly day: S.Int; }>; }; readonly CompletedFocusGrid: {}; }>; }; readonly GotPopoverMessage: { readonly message: import("foldkit/message").MessageUnion<{ readonly RequestedOpen: {}; readonly RequestedClose: {}; readonly BlurredPanel: {}; readonly PressedPointerOnButton: { readonly pointerType: S.String; readonly button: S.Number; }; readonly CompletedFocusPanel: {}; readonly CompletedFocusButton: {}; readonly CompletedLockScroll: {}; readonly CompletedUnlockScroll: {}; readonly CompletedInertOthers: {}; readonly CompletedRestoreInert: {}; readonly IgnoredMouseClick: {}; readonly SuppressedSpaceScroll: {}; readonly CompletedAnchorPopover: {}; readonly CompletedPortalPopoverBackdrop: {}; readonly GotAnimationMessage: { readonly message: import("foldkit/message").MessageUnion<{ readonly Showed: {}; readonly Hid: {}; readonly CompletedWaitForPaint: {}; readonly EndedAnimation: {}; }>; }; }>; }; readonly RequestedSelectDate: { readonly date: S.Struct<{ readonly year: S.Int; readonly month: S.Int; readonly day: S.Int; }>; }; readonly Cleared: {}; readonly Opened: {}; readonly Closed: {}; }>; export type Message = typeof Message.Type; /** Union of out-messages the date picker can produce. */ export declare const OutMessage: import("foldkit/message").MessageUnion<{ readonly ChangedViewMonth: { readonly year: S.Int; readonly month: S.Int; }; readonly SelectedDate: { readonly date: S.Struct<{ readonly year: S.Int; readonly month: S.Int; readonly day: S.Int; }>; }; readonly ClearedDate: {}; }>; export type OutMessage = typeof OutMessage.Type; export type ChangedViewMonth = typeof OutMessage.ChangedViewMonth.Type; export type SelectedDate = typeof OutMessage.SelectedDate.Type; export type ClearedDate = typeof OutMessage.ClearedDate.Type; /** Configuration for creating a date picker model with `init`. */ export type InitConfig = Readonly<{ id: string; today: CalendarDate; initialViewDate?: CalendarDate; isAnimated?: boolean; locale?: Calendar.LocaleConfig; minDate?: CalendarDate; maxDate?: CalendarDate; disabledDaysOfWeek?: ReadonlyArray; disabledDates?: ReadonlyArray; }>; /** Creates an initial date picker model from a config. The selected date is * owned by the parent; pass its current value as `initialViewDate` to open the * calendar onto that month. The calendar and popover submodels are created * with derived ids so their DOM elements stay addressable. The popover is * opened in `contentFocus` mode so focus lands on the calendar grid instead of * the panel. */ export declare const init: (config: InitConfig) => Model; type UpdateReturn = Update.ReturnWithOutMessage; /** Processes a DatePicker Message and returns the next Model, optional * Commands, and an optional OutMessage. */ export declare const update: (model: Model, message: Message) => Readonly<{ model: { readonly id: string; readonly calendar: { readonly id: string; readonly today: { readonly year: number; readonly month: number; readonly day: number; }; readonly viewYear: number; readonly viewMonth: number; readonly viewMode: "Days" | "Months" | "Years"; readonly maybeFocusedDate: Option.Option<{ readonly year: number; readonly month: number; readonly day: number; }>; readonly isGridFocused: boolean; readonly locale: { readonly firstDayOfWeek: "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; readonly monthNames: readonly [string, string, string, string, string, string, string, string, string, string, string, string]; readonly shortMonthNames: readonly [string, string, string, string, string, string, string, string, string, string, string, string]; readonly dayNames: readonly [string, string, string, string, string, string, string]; readonly shortDayNames: readonly [string, string, string, string, string, string, string]; }; readonly maybeMinDate: Option.Option<{ readonly year: number; readonly month: number; readonly day: number; }>; readonly maybeMaxDate: Option.Option<{ readonly year: number; readonly month: number; readonly day: number; }>; readonly disabledDaysOfWeek: readonly ("Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday")[]; readonly disabledDates: readonly { readonly year: number; readonly month: number; readonly day: number; }[]; }; readonly popover: { readonly id: string; readonly isOpen: boolean; readonly isAnimated: boolean; readonly isModal: boolean; readonly contentFocus: boolean; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeLastButtonPointerType: Option.Option; }; }; commands?: Update.Commands<{ readonly _tag: "Opened"; } | { readonly _tag: "Closed"; } | { readonly _tag: "GotCalendarMessage"; readonly message: { readonly _tag: "ClickedDay"; readonly date: { readonly year: number; readonly month: number; readonly day: number; }; } | { readonly _tag: "PressedKeyOnGrid"; readonly key: string; readonly isShift: boolean; } | { readonly _tag: "ClickedPreviousMonthButton"; } | { readonly _tag: "ClickedNextMonthButton"; } | { readonly _tag: "ClickedHeading"; } | { readonly _tag: "SelectedMonth"; readonly month: number; } | { readonly _tag: "SelectedYear"; readonly year: number; } | { readonly _tag: "PagedYears"; readonly direction: 1 | -1; } | { readonly _tag: "FocusedGrid"; } | { readonly _tag: "BlurredGrid"; } | { readonly _tag: "RefreshedToday"; readonly today: { readonly year: number; readonly month: number; readonly day: number; }; } | { readonly _tag: "CompletedFocusGrid"; }; } | { readonly _tag: "GotPopoverMessage"; readonly message: { readonly _tag: "RequestedOpen"; } | { readonly _tag: "RequestedClose"; } | { readonly _tag: "BlurredPanel"; } | { readonly _tag: "PressedPointerOnButton"; readonly pointerType: string; readonly button: number; } | { readonly _tag: "IgnoredMouseClick"; } | { readonly _tag: "SuppressedSpaceScroll"; } | { readonly _tag: "CompletedFocusPanel"; } | { readonly _tag: "CompletedFocusButton"; } | { readonly _tag: "CompletedLockScroll"; } | { readonly _tag: "CompletedUnlockScroll"; } | { readonly _tag: "CompletedInertOthers"; } | { readonly _tag: "CompletedRestoreInert"; } | { readonly _tag: "CompletedAnchorPopover"; } | { readonly _tag: "CompletedPortalPopoverBackdrop"; } | { readonly _tag: "GotAnimationMessage"; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; }; } | { readonly _tag: "RequestedSelectDate"; readonly date: { readonly year: number; readonly month: number; readonly day: number; }; } | { readonly _tag: "Cleared"; }, never>; outMessage?: { readonly _tag: "ChangedViewMonth"; readonly year: number; readonly month: number; } | { readonly _tag: "SelectedDate"; readonly date: { readonly year: number; readonly month: number; readonly day: number; }; } | { readonly _tag: "ClearedDate"; }; }>; /** Programmatically opens the DatePicker, updating the Model and returning * focus and Popover Commands. Use this in domain-event handlers. */ export declare const open: (model: Model) => UpdateReturn; /** Programmatically closes the date picker. Use this in domain-event handlers. */ export declare const close: (model: Model) => UpdateReturn; /** Programmatically selects a date, committing it and closing the popover. Emits a `SelectedDate` OutMessage just like a user-initiated selection. */ export declare const selectDate: (model: Model, date: CalendarDate) => UpdateReturn; /** Programmatically clears the selected date. */ export declare const clear: (model: Model) => UpdateReturn; /** Moves the embedded calendar's view and cursor to a date without changing * the selection (which the parent owns). Use it to navigate the picker onto a * known date, for example after the parent sets its value externally (a URL * parameter, a saved draft) so opening the picker shows that month. Returns * the Model directly because it produces no Commands and no OutMessage. */ export declare const focusDate: Reflect; /** Reflects the minimum selectable date onto the embedded calendar. Pass * `Option.none()` to remove the minimum. Use this when the minimum derives * from other Model state (e.g. a start date field whose current selection * constrains an end date picker). * * Does NOT reconcile the current selection. If a previously-selected date * is now below the new minimum, it remains selected. Callers should `clear` * or reassign the selection explicitly if their domain requires it. */ export declare const reflectMinDate: Reflect>; /** Reflects the maximum selectable date onto the embedded calendar. Pass * `Option.none()` to remove the maximum. Does NOT reconcile the current * selection. */ export declare const reflectMaxDate: Reflect>; /** Reflects the list of individually-disabled dates onto the embedded * calendar. Pass an empty array to clear. Does NOT reconcile the current * selection. */ export declare const reflectDisabledDates: Reflect>; /** Reflects the days of the week that are disabled onto the embedded calendar * (e.g. weekends). Pass an empty array to clear. Does NOT reconcile the * current selection. */ export declare const reflectDisabledDaysOfWeek: Reflect>; /** Returns the bare DOM id of the date picker trigger button, derived from * the date picker's base id. The trigger is the embedded Popover's button, * so the id is suffixed `-popover-button`. Use this to associate an external * label with the trigger via a native `