import { Effect, Option, Schema as S } from 'effect'; import * as Calendar from 'foldkit/calendar'; import type { CalendarDate } from 'foldkit/calendar'; import * as Command from 'foldkit/command'; import { type ChildAttribute, type Html } from 'foldkit/html'; import { type Reflect } from 'foldkit/submodel'; import * as Update from 'foldkit/update'; /** Which grid the calendar is currently displaying. `Days` is the standard * 6×7 day grid; `Months` is a 3×4 month-name grid for fast month jumps; * `Years` is a 3×4 year grid paged in 12-year windows for fast year jumps. */ export declare const ViewMode: S.Literals; export type ViewMode = typeof ViewMode.Type; /** Schema for the calendar component's state. Tracks the visible month/year, * the keyboard-focused and user-selected dates, the active view mode, and * the configuration that governs navigation (locale, min/max, disabled * days). */ export declare const Model: 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>; }>; export type Model = typeof Model.Type; /** Union of all messages the calendar component can produce. */ export declare const 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: {}; }>; export type Message = typeof Message.Type; export type ClickedDay = typeof Message.ClickedDay.Type; export type PressedKeyOnGrid = typeof Message.PressedKeyOnGrid.Type; export type SelectedMonth = typeof Message.SelectedMonth.Type; export type SelectedYear = typeof Message.SelectedYear.Type; /** Union of the calendar's OutMessages. */ 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; }>; }; }>; export type OutMessage = typeof OutMessage.Type; export type ChangedViewMonth = typeof OutMessage.ChangedViewMonth.Type; export type SelectedDate = typeof OutMessage.SelectedDate.Type; /** Configuration for creating a calendar model with `init`. */ export type InitConfig = Readonly<{ id: string; today: CalendarDate; initialViewDate?: CalendarDate; locale?: Calendar.LocaleConfig; minDate?: CalendarDate; maxDate?: CalendarDate; disabledDaysOfWeek?: ReadonlyArray; disabledDates?: ReadonlyArray; }>; /** Creates an initial calendar model. The selected date is owned by the * parent and passed in via `ViewInputs.maybeSelectedDate`. The view month * defaults to `initialViewDate` (pass the parent's selected date to open onto * it), or today when omitted. */ export declare const init: (config: InitConfig) => Model; type UpdateReturn = Update.ReturnWithOutMessage; /** Focuses the calendar grid container. Parent components like DatePicker * dispatch this after opening to hand focus to the grid's keyboard layer. */ export declare const FocusGrid: Command.CommandDefinitionWithArgs<"FocusGrid", { id: S.String; }, Effect.Effect<{ readonly _tag: "CompletedFocusGrid"; }, never, never>>; /** Programmatically selects a date on the calendar, committing it as the * chosen value and moving the cursor onto it. Use this in controlled-mode * handlers (when the view's `onSelectedDate` callback is provided) to write * the selection back to the calendar's internal state. * * Equivalent to dispatching `ClickedDay({ date })` through `update`. */ export declare const selectDate: (model: Model, date: CalendarDate) => UpdateReturn; /** Moves the calendar's view and cursor to a date without changing the * selection (which the parent owns). Use it to navigate to a known date, for * example when opening a date picker onto its current value so the selected * month is visible. Returns the model directly because it produces no * commands and no OutMessage. */ export declare const focusDate: Reflect; /** Reflects the minimum selectable date onto the model. 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 model. 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 model. 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 (e.g. weekends) onto the * model. Pass an empty array to clear. Does NOT reconcile the current * selection. */ export declare const reflectDisabledDaysOfWeek: Reflect>; /** Returns the calendar to Days mode regardless of current depth. Useful for * standalone (non-popovered) consumers that want to wire their own back-out * gesture. Popovered consumers like `DatePicker` don't need this. Escape * closes the popover, and the calendar resets to Days on next open. * * Reconciles `maybeFocusedDate` to a date inside the visible (`viewYear`, * `viewMonth`). Months/Years navigation can leave the cursor on a date * outside the days grid (paged-away year, etc.), which would otherwise * cause `aria-activedescendant` to point at a non-rendered cell and the * next ArrowLeft to jump to the cursor's stale year. */ export declare const dropToDays: (model: Model) => Model; /** Processes a Calendar 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 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; }[]; }; commands?: Update.Commands<{ 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"; }, 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; }; }; }>; /** Information about a single day cell in the rendered calendar grid. */ export type DayCell = Readonly<{ date: CalendarDate; label: string; cellAttributes: ReadonlyArray; buttonAttributes: ReadonlyArray; isSelected: boolean; isFocused: boolean; isToday: boolean; isInViewMonth: boolean; isDisabled: boolean; }>; /** A column header for the day grid's first row (day-of-week labels). */ export type ColumnHeader = Readonly<{ name: string; attributes: ReadonlyArray; }>; /** A single week row in the day grid, carrying its own row attributes (role, * aria-rowindex) alongside its 7 day cells. */ export type Week = Readonly<{ attributes: ReadonlyArray; cells: ReadonlyArray; }>; /** Information about a single month cell in the rendered months grid. * `label` is the locale-aware full month name (e.g. "September"); `shortLabel` * is the locale-aware abbreviation (e.g. "Sep"). Render whichever fits the * cell. Never substring `label` to abbreviate, since that's not safe across * locales. */ export type MonthCell = Readonly<{ month: number; label: string; shortLabel: string; cellAttributes: ReadonlyArray; buttonAttributes: ReadonlyArray; isSelected: boolean; isFocused: boolean; isCurrentMonth: boolean; isDisabled: boolean; }>; /** Information about a single year cell in the rendered years grid. */ export type YearCell = Readonly<{ year: number; label: string; cellAttributes: ReadonlyArray; buttonAttributes: ReadonlyArray; isSelected: boolean; isFocused: boolean; isCurrentYear: boolean; isDisabled: boolean; }>; /** Attributes provided to the consumer when rendering the day grid. */ export type DaysModeAttributes = Readonly<{ _tag: 'Days'; root: ReadonlyArray; previousMonthButton: ReadonlyArray; nextMonthButton: ReadonlyArray; headingButton: ReadonlyArray; heading: Readonly<{ id: string; text: string; }>; grid: ReadonlyArray; headerRow: ReadonlyArray; columnHeaders: ReadonlyArray; weeks: ReadonlyArray; }>; /** Attributes provided to the consumer when rendering the months grid. The * 12 cells are pre-built in calendar (locale-ordered). The consumer arranges * them in whatever grid layout they prefer (3×4 is the typical choice). */ export type MonthsModeAttributes = Readonly<{ _tag: 'Months'; root: ReadonlyArray; headingButton: ReadonlyArray; heading: Readonly<{ id: string; text: string; }>; grid: ReadonlyArray; cells: ReadonlyArray; }>; /** Attributes provided to the consumer when rendering the years grid. The * 12 cells span one paged window; prev/next buttons page by 12 years. */ export type YearsModeAttributes = Readonly<{ _tag: 'Years'; root: ReadonlyArray; previousPageButton: ReadonlyArray; nextPageButton: ReadonlyArray; heading: Readonly<{ id: string; text: string; }>; grid: ReadonlyArray; cells: ReadonlyArray; }>; /** Discriminated union of attribute groups and derived data the calendar * component provides to the consumer's `toView` callback. The variant * matches `model.viewMode`. Pattern-match on `_tag` with `M.tagsExhaustive` * to render each mode. */ export type CalendarAttributes = DaysModeAttributes | MonthsModeAttributes | YearsModeAttributes; /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. * * The Calendar dispatches its own `ClickedDay` message on date commit * and emits a `SelectedDate` OutMessage. Handle the selection in the * `foldOutMessage` of the Calendar's `Update.foldChild` config. */ export type ViewInputs = Readonly<{ /** The selected date, read straight from the parent Model. The selected-day * marker derives from it. */ maybeSelectedDate: Option.Option; toView: (attributes: CalendarAttributes) => Html; previousMonthLabel?: string; nextMonthLabel?: string; previousYearsPageLabel?: string; nextYearsPageLabel?: string; daysHeadingButtonLabel?: string; monthsHeadingButtonLabel?: string; }>; /** Renders an accessible calendar. Publishes mode-specific ARIA attribute * bundles + derived cell data, then delegates layout to the consumer's * `toView` callback. The variant of `CalendarAttributes` passed to * `toView` matches `model.viewMode`. */ export declare const view: import("foldkit/submodel").View<{ 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 _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<{ /** The selected date, read straight from the parent Model. The selected-day * marker derives from it. */ maybeSelectedDate: Option.Option; toView: (attributes: CalendarAttributes) => Html; previousMonthLabel?: string; nextMonthLabel?: string; previousYearsPageLabel?: string; nextYearsPageLabel?: string; daysHeadingButtonLabel?: string; monthsHeadingButtonLabel?: string; }>>; export {}; //# sourceMappingURL=index.d.ts.map