Reference headless
calendar
# CalendarContext
Reactive context surfaced to consumers.
Members
focusedDatefocusedDate: CalendarDateCurrently focused day cell. Mirrors
tabindex="0"on its grid cell.maxValuemaxValue: CalendarDate | nullInclusive upper bound for selectable dates.
null= no ceiling.minValueminValue: CalendarDate | nullInclusive lower bound for selectable dates.
null= no floor.selectedDateselectedDate: CalendarDate | nullCurrently selected date, or
nullif nothing is selected yet.selectionsselections: numberNumber of user-initiated selections since construction (telemetry hook).
# CalendarController
Members
contextreadonly context: Readonly<CalendarContext>disabledreadonly disabled: booleanfocusedDatereadonly focusedDate: CalendarDateidreadonly id: stringStable controller id, used to derive deterministic day-cell ids.
machinereadonly machine: CalendarMachineUnderlying machine — exposed for advanced use, debugging, and tests.
rootreadonly root: AttachmentAttachment for the grid container — owns keyboard nav.
selectedDatereadonly selectedDate: CalendarDate | nullstatereadonly state: CalendarStatedayCell()dayCell(date): AttachmentFactory: attachment for a specific day cell.
###### Parameters
###### date
CalendarDate###### Returns
dayCellId()dayCellId(date): stringCompute the deterministic id for a day cell.
###### Parameters
###### date
CalendarDate###### Returns
stringfocus()focus(date): void###### Parameters
###### date
CalendarDate###### Returns
voidisSelectable()isSelectable(date): booleanPure helper: is this date currently selectable?
###### Parameters
###### date
CalendarDate###### Returns
booleanselect()select(date): void###### Parameters
###### date
CalendarDate###### Returns
voidsetDisabled()setDisabled(disabled): void###### Parameters
###### disabled
boolean###### Returns
voidsetValue()setValue(date): void###### Parameters
###### date
CalendarDate|null###### Returns
voidsubscribe()subscribe(listener): () => voidSubscribe to state changes. Returns an unsubscribe.
###### Parameters
###### listener
(
snapshot) =>void###### Returns
() =>
void
# CreateCalendarInput
Construction input.
Members
disabled?optional disabled?: booleanConstruct in the disabled state. Defaults to
false.focusedDatefocusedDate: CalendarDateDate to focus initially. Required — the grid must always have a focused cell.
maxValue?optional maxValue?: CalendarDate | nullInclusive upper bound for selectable dates.
minValue?optional minValue?: CalendarDate | nullInclusive lower bound for selectable dates.
selectedDate?optional selectedDate?: CalendarDate | nullInitial selection. Defaults to
null(no selection).
# CreateCalendarOptions
Construction input.
Members
direction?optional direction?: "ltr" | "rtl"Reading direction. RTL inverts the meaning of
ArrowLeft/ArrowRightto follow visual flow. Defaults to'ltr'.disabled?optional disabled?: booleanConstruct in the disabled state. Defaults to
false.###### Inherited from
focusedDatefocusedDate: CalendarDateDate to focus initially. Required — the grid must always have a focused cell.
###### Inherited from
id?optional id?: stringStable id override.
maxValue?optional maxValue?: CalendarDate | nullminValue?optional minValue?: CalendarDate | nullonFocusChange?optional onFocusChange?: (date) => voidCalled whenever focus moves to a new date (keyboard or programmatic).
###### Parameters
###### date
CalendarDate###### Returns
voidonSelect?optional onSelect?: (date) => voidCalled when the user selects a new date. Not called for controlled
setValue.###### Parameters
###### date
CalendarDate###### Returns
voidselectedDate?optional selectedDate?: CalendarDate | nullInitial selection. Defaults to
null(no selection).###### Inherited from
# Attachment
Attachment = (node) => void | (() => void)Parameters
nodeHTMLElement
Returns
void | (() => void)# CalendarEvent
CalendarEvent = { date: CalendarDate; type: "FOCUS_DATE"; } | { days: number; type: "FOCUS_DAY_DELTA"; } | { months: number; type: "FOCUS_MONTH_DELTA"; } | { type: "FOCUS_YEAR_DELTA"; years: number; } | { date: CalendarDate; type: "SELECT"; } | { date: CalendarDate | null; type: "SET_VALUE"; } | { type: "DISABLE"; } | { type: "ENABLE"; }Calendar machine events.
# CalendarMachine
CalendarMachine = Machine<CalendarContext, CalendarEvent, CalendarState>A running Calendar machine instance.
# CalendarState
CalendarState = "idle" | "disabled"State names.
# IsDateUnavailable
IsDateUnavailable = (date) => booleanPredicate for marking individual dates as unavailable (e.g. holidays).
Parameters
dateCalendarDate
Returns
boolean# createCalendar ( )
createCalendar(options): CalendarControllerParameters
optionsCreateCalendarOptions
Returns
CalendarController