Instance and API
What useCalendar returns.
useCalendar returns the calendar instance. Keep it in the component that owns view and date, and call its api
from your own controls; pass it to CalendarProvider for the parts.
useCalendar and Calendar call ~mount and ~update for you.
| Member | Description |
|---|---|
store | Read-only TanStack Store of the state. |
api | Navigation actions, plus actions from registered features. |
options | The options most recently passed in. |
~mount | Starts the clock and returns its cleanup. |
~update | Replaces the options; re-derives only when a tracked option changed. |
api
| Action | Effect |
|---|---|
next(), prev() | Calls onNavigate with the next or previous period. |
today() | Calls onNavigate with today in timeZone. |
goTo(date) | Calls onNavigate with the same view on date. |
setView(view, date?) | Calls onNavigate with view, keeping the date unless one is given. |
navigate({ view, date }) | Calls onNavigate with either or both. |
Navigation actions emit a request for the owner to apply. See navigation.
Interaction APIs
Each operation feature installs its API when registered; calendars without it have no such methods in their types.
| API | Methods |
|---|---|
selection | begin(anchor), evaluate(anchor, target) |
move | begin(eventId, sourceResourceId?), evaluate(eventId, target, sourceResourceId?) |
resize | begin(eventId, edge), evaluate(eventId, edge, target) |
externalDrop | begin(event, metadata?), evaluate(event, target, metadata?) |
transfer | prepare(eventId, sourceResourceId?), begin(preparedSource), evaluate(preparedSource, target) |
interactions | refresh(), locate(point), project(proposal) |
pointer | settings() returns the resolved pointer, touch and scroll configuration. |
interactions.store exposes the readonly session, candidate, outcome and derived preview. Sessions start only through
an operation API; the shared controls have no generic begin. evaluate returns a proposal or a reason without
opening a session. An active begin returns a typed session with update(target), commit(), cancel(reason?),
unavailable(reason) and isActive(). Commands return an object with status, and a committed result includes its
typed proposal. Tokens appear only in ownership snapshots. A valid commit calls the operation's callback and, for
selection, updates its state slice. See selection and editing.
Types
To annotate api explicitly, use Calendar_Api<TViews, TFeatures, TData, TResourceData>. TFeatures defaults to
Calendar_Features, and the payload parameters default to unknown.