- Name
reason- Kind
- property
- Type
CalendarReason- Requirement
- required
DocsAPI referenceUI machinescalendar
calendar machine
The public state machine contract for @grassroot/ui-machines/calendar. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/calendar
Package
Service example
calendar.tsts
import { createService } from "@grassroot/statechart";import { calendarMachine } from "@grassroot/ui-machines/calendar"; const service = createService(calendarMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();14 of 14
Exports
CalendarCommand
typeCalendarCommandts
type CalendarCommand = CommandObject & { readonly type: "VALUE_CHANGE_REQUEST"; readonly value: string; readonly reason: CalendarReason;};Name
Kind
Type
Requirement
reasonproperty
CalendarReasonrequired
typeproperty
stringrequired
valueproperty
stringrequired
- Name
type- Kind
- property
- Type
string- Requirement
- required
- Name
value- Kind
- property
- Type
string- Requirement
- required
CalendarContext
typeCalendarContextts
type CalendarContext = { readonly value: string | null; readonly year: number; readonly month: number; readonly mode: BindingMode;};Name
Kind
Type
Requirement
modeproperty
BindingModerequired
monthproperty
numberrequired
valueproperty
string | nullrequired
yearproperty
numberrequired
- Name
mode- Kind
- property
- Type
BindingMode- Requirement
- required
- Name
month- Kind
- property
- Type
number- Requirement
- required
- Name
value- Kind
- property
- Type
string | null- Requirement
- required
- Name
year- Kind
- property
- Type
number- Requirement
- required
CalendarDay
interfaceCalendarDayts
interface CalendarDay { readonly date: string; readonly day: number; readonly inMonth: boolean;}Name
Kind
Type
Requirement
dateproperty
stringrequired
dayproperty
numberrequired
inMonthproperty
booleanrequired
- Name
date- Kind
- property
- Type
string- Requirement
- required
- Name
day- Kind
- property
- Type
number- Requirement
- required
- Name
inMonth- Kind
- property
- Type
boolean- Requirement
- required
CalendarDiagnosticCodes
valueCalendarDiagnosticCodests
export declare const CalendarDiagnosticCodes: readonly DiagnosticCatalogueEntry[];CalendarEvent
typeCalendarEventts
type CalendarEvent = { readonly type: "SELECT"; readonly value: string; readonly reason: CalendarReason;} | { readonly type: "SHIFT"; readonly delta: number;} | { readonly type: "RESET";};calendarGrid
functioncalendarGridts
declare function calendarGrid(year: number, month: number, weekStartsOn?: number): CalendarDay[];Name
Kind
Type
Requirement
yearparameter
numberrequired
monthparameter
numberrequired
weekStartsOnparameter
numberoptional
returnreturn value
CalendarDay[]n/a
- Name
year- Kind
- parameter
- Type
number- Requirement
- required
- Name
month- Kind
- parameter
- Type
number- Requirement
- required
- Name
weekStartsOn- Kind
- parameter
- Type
number- Requirement
- optional
- Name
return- Kind
- return value
- Type
CalendarDay[]- Requirement
- n/a
CalendarInput
typeCalendarInputts
type CalendarInput = { readonly value?: string | null; readonly defaultValue?: string | null; readonly today?: string; readonly weekStartsOn?: number;};Name
Kind
Type
Requirement
defaultValueproperty
string | nulloptional
todayproperty
stringoptional
valueproperty
string | nulloptional
weekStartsOnproperty
numberoptional
- Name
defaultValue- Kind
- property
- Type
string | null- Requirement
- optional
- Name
today- Kind
- property
- Type
string- Requirement
- optional
- Name
value- Kind
- property
- Type
string | null- Requirement
- optional
- Name
weekStartsOn- Kind
- property
- Type
number- Requirement
- optional
calendarMachine
valuecalendarMachinets
export declare const calendarMachine: Machine<CalendarInput, "ready", CalendarContext, CalendarEvent, CalendarCommand>;CalendarReason
typeCalendarReasonts
type CalendarReason = "pointer" | "keyboard" | "programmatic";calendarReplaySequence
valuecalendarReplaySequencets
export declare const calendarReplaySequence: readonly CalendarEvent[];calendarSelectors
valuecalendarSelectorsts
export declare const calendarSelectors: { value: (snapshot: CalendarSnapshot) => string | null; year: (snapshot: CalendarSnapshot) => number; month: (snapshot: CalendarSnapshot) => number;};Name
Kind
Type
Requirement
monthproperty
(snapshot: CalendarSnapshot) => numberrequired
valueproperty
(snapshot: CalendarSnapshot) => string | nullrequired
yearproperty
(snapshot: CalendarSnapshot) => numberrequired
- Name
month- Kind
- property
- Type
(snapshot: CalendarSnapshot) => number- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: CalendarSnapshot) => string | null- Requirement
- required
- Name
year- Kind
- property
- Type
(snapshot: CalendarSnapshot) => number- Requirement
- required
CalendarSnapshot
typeCalendarSnapshotts
type CalendarSnapshot = Snapshot<"ready", CalendarContext>;daysInCalendarMonth
functiondaysInCalendarMonthts
declare function daysInMonth(year: number, month: number): number;Name
Kind
Type
Requirement
yearparameter
numberrequired
monthparameter
numberrequired
returnreturn value
numbern/a
- Name
year- Kind
- parameter
- Type
number- Requirement
- required
- Name
month- Kind
- parameter
- Type
number- Requirement
- required
- Name
return- Kind
- return value
- Type
number- Requirement
- n/a
shiftCalendarMonth
functionPure month shift (any delta, negative years handled).
shiftCalendarMonthts
declare function shiftMonth(year: number, month: number, delta: number): { year: number; month: number;};Name
Kind
Type
Requirement
yearparameter
numberrequired
monthparameter
numberrequired
deltaparameter
numberrequired
returnreturn value
{
year: number;
month: number;
}n/a
- Name
year- Kind
- parameter
- Type
number- Requirement
- required
- Name
month- Kind
- parameter
- Type
number- Requirement
- required
- Name
delta- Kind
- parameter
- Type
number- Requirement
- required
- Name
return- Kind
- return value
- Type
{ year: number; month: number; }- Requirement
- n/a