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

14 exports
View source packages/ui-machines/src/calendar/index.ts

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();

Exports

DeclarationView source
CalendarCommandts
type CalendarCommand = CommandObject & {
readonly type: "VALUE_CHANGE_REQUEST";
readonly value: string;
readonly reason: CalendarReason;
};
Name
Kind
Type
Requirement
reason
property
CalendarReason
required
type
property
string
required
value
property
string
required
Name
reason
Kind
property
Type
CalendarReason
Requirement
required
Name
type
Kind
property
Type
string
Requirement
required
Name
value
Kind
property
Type
string
Requirement
required
DeclarationView source
CalendarContextts
type CalendarContext = {
readonly value: string | null;
readonly year: number;
readonly month: number;
readonly mode: BindingMode;
};
Name
Kind
Type
Requirement
mode
property
BindingMode
required
month
property
number
required
value
property
string | null
required
year
property
number
required
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

interface
DeclarationView source
CalendarDayts
interface CalendarDay {
readonly date: string;
readonly day: number;
readonly inMonth: boolean;
}
Name
Kind
Type
Requirement
date
property
string
required
day
property
number
required
inMonth
property
boolean
required
Name
date
Kind
property
Type
string
Requirement
required
Name
day
Kind
property
Type
number
Requirement
required
Name
inMonth
Kind
property
Type
boolean
Requirement
required
DeclarationView source
CalendarDiagnosticCodests
export declare const CalendarDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
CalendarEventts
type CalendarEvent = {
readonly type: "SELECT";
readonly value: string;
readonly reason: CalendarReason;
} | {
readonly type: "SHIFT";
readonly delta: number;
} | {
readonly type: "RESET";
};

calendarGrid

function
DeclarationView source
calendarGridts
declare function calendarGrid(year: number, month: number, weekStartsOn?: number): CalendarDay[];
Name
Kind
Type
Requirement
year
parameter
number
required
month
parameter
number
required
weekStartsOn
parameter
number
optional
return
return 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
DeclarationView source
CalendarInputts
type CalendarInput = {
readonly value?: string | null;
readonly defaultValue?: string | null;
readonly today?: string;
readonly weekStartsOn?: number;
};
Name
Kind
Type
Requirement
defaultValue
property
string | null
optional
today
property
string
optional
value
property
string | null
optional
weekStartsOn
property
number
optional
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
DeclarationView source
calendarMachinets
export declare const calendarMachine: Machine<CalendarInput, "ready", CalendarContext, CalendarEvent, CalendarCommand>;
DeclarationView source
CalendarReasonts
type CalendarReason = "pointer" | "keyboard" | "programmatic";
DeclarationView source
calendarReplaySequencets
export declare const calendarReplaySequence: readonly CalendarEvent[];
DeclarationView source
calendarSelectorsts
export declare const calendarSelectors: {
value: (snapshot: CalendarSnapshot) => string | null;
year: (snapshot: CalendarSnapshot) => number;
month: (snapshot: CalendarSnapshot) => number;
};
Name
Kind
Type
Requirement
month
property
(snapshot: CalendarSnapshot) => number
required
value
property
(snapshot: CalendarSnapshot) => string | null
required
year
property
(snapshot: CalendarSnapshot) => number
required
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
DeclarationView source
CalendarSnapshotts
type CalendarSnapshot = Snapshot<"ready", CalendarContext>;
DeclarationView source
daysInCalendarMonthts
declare function daysInMonth(year: number, month: number): number;
Name
Kind
Type
Requirement
year
parameter
number
required
month
parameter
number
required
return
return value
number
n/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

Pure month shift (any delta, negative years handled).

DeclarationView source
shiftCalendarMonthts
declare function shiftMonth(year: number, month: number, delta: number): {
year: number;
month: number;
};
Name
Kind
Type
Requirement
year
parameter
number
required
month
parameter
number
required
delta
parameter
number
required
return
return 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