Reference machines
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).
# 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).
# 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# createCalendarMachine ( )
createCalendarMachine(input): CalendarMachineConstruct a fresh Calendar machine.
Parameters
inputCreateCalendarInput
Returns
CalendarMachine# isCalendarDateSelectable ( )
isCalendarDateSelectable(date, ctx): booleanPure helper: is a given date selectable given the constraints in ctx? Exported so the headless / component layers can render aria-disabled without round-tripping through the machine.
Parameters
dateCalendarDatectxPick<CalendarContext, "minValue" | "maxValue" | "isDateUnavailable">
Returns
boolean