Migrating to 2.0
What changes between Time 1.x and 2.0, and what to do about each change.
2.0 rebuilds the calendar's parts on ui-sdk. With it, an agent can call the calendar's actions, and the calendar has a second framework, Solid, with docs of its own. The engine didn't move: dates, time zones, recurrence, layouts, transactions and policies work as they did.
For most apps the upgrade is two more packages to install. The rest of this page is for code that names the types 2.0 widened.
In short
| Change | Do this | Who it affects |
|---|---|---|
@ui-sdk/core and @ui-sdk/react are peer dependencies | Install them | Everyone |
CalendarInputMethod has a fourth value, "agent" | Handle it | Code that switches on detail.input |
onEventChange and policies get the proposal's detail, with fields | Check handlers with a second parameter | Handlers with an optional second parameter, and code that calls a typed handler |
The toolbar parts and the frame render a data-slot attribute | Check selectors on data-slot="calendar" | Apps with shadcn's date picker, or such CSS |
State handlers hear reason, source, event and can cancel() | Nothing. Use it | Code that builds a detail by hand, in tests |
| Actions take options last | Wrap an action used as an event handler | Code such as onClick={actions.navigateNext} |
Root has label, allowAgentDelete and formatAgentEventLabel | Name your calendar | Apps that want agents, or a fixed name |
The store and state types moved to @moltenship/calendar-primitives | Nothing: the old imports still work | Nobody |
useCalendarPointer moved to @moltenship/calendar-react | Import it from there | Code that imports it from @moltenship/calendar-dnd |
The registry's controls and popups come from a new item, calendar-ui, without Base UI | Add the registry's items again | Apps with the Tailwind items from the registry |
The StyleX items' controls come from stylex-calendar-ui, without Astryx or Base UI | Add the StyleX items again | Apps with the StyleX items from the registry |
What didn't change: the engine, what the registry's views do, the data-calendar-part attributes
and the other attributes your CSS and tests target, the keyboard model, and every hook's name and return
value. The parts gained one attribute, data-slot.
Install the new peer dependencies
pnpm add @moltenship/calendar @ui-sdk/core @ui-sdk/reactreact-domis needed too.@ui-sdk/reacthas it as a peer dependency. A React app on the web already has it.- Install the 2.0 version of every
@moltenship/*package you use. They share one version, and a 1.x package beside a 2.0 one brings a second copy of the engine. @moltenship/calendar-testinghas the same two peers. A project that tests with it needs nothing more once the app has them.shadcn addinstalls them only if they're missing. The registry'scalendar-uiitem lists the ui-sdk packages without a version, so an app that already has them keeps its own. Install the version the calendar asks for yourself.- Keep one copy of
@ui-sdk/core. The calendar and an agent bridge find each other through it. Your package manager keeps one as long as every@ui-sdk/*package is on the same version;pnpm why @ui-sdk/coreshows whether it did.
The calendar takes @ui-sdk/core and @ui-sdk/react from 0.1.0-beta.16 on, within the 0.1
line.
Handle the agent input
CalendarInputMethod was "pointer" | "keyboard" | "api". It's now
"pointer" | "keyboard" | "api" | "agent". The value is the input of the detail that
onEventChangeResult gets, and of a history step.
Code that only compares, such as detail.input === "keyboard", keeps working. A switch that
TypeScript checks for every case stops compiling until it has the fourth:
import type { CalendarInputMethod } from "@moltenship/calendar";
export function inputLabel(input: CalendarInputMethod): string {
switch (input) {
case "pointer":
return "Dragged";
case "keyboard":
return "Moved with the keyboard";
case "api":
return "Changed from a form";
// New in 2.0: an AI agent proposed the change.
case "agent":
return "Changed by the assistant";
}
}No agent proposes anything until your app creates a bridge, so "agent" never arrives in an app
that doesn't opt in. In one that does, "agent" is the input of everything an agent's step
causes. That includes a proposeEventChange your own button's handler makes when an agent
presses the button, which a person's click still reports as "api".
An event history records every input by default, and now that includes an agent's. To leave an agent's changes out of undo, list the inputs you want:
import { createEventHistory } from "@moltenship/calendar";
import type { Meeting } from "./calendar";
// Undo and redo take back what people did, and leave an agent's changes alone.
export const history = createEventHistory<Meeting, string, never>({
inputs: ["pointer", "keyboard", "api"],
});Handlers and policies hear who proposed
In 1.x only onEventChangeResult got the proposal's detail. In 2.0 onEventChange gets it as a
second argument, and a policy as detail in its second argument. Handlers that take one argument
are unchanged.
"use client";
import type { CalendarPolicy } from "@moltenship/calendar";
import { useState } from "react";
import { applyChange } from "./agent-save";
import { Calendar, meetings as initialMeetings, weekRules, type Meeting } from "./calendar";
// `detail` is absent when your own code calls a policy outside a proposal.
const noAgentDeletes: CalendarPolicy<Meeting, string, never> = (change, { detail }) =>
change.cause === "delete" && detail?.input === "agent"
? { type: "reject", reason: "a-person-deletes-meetings" }
: { type: "accept" };
export function SavingCalendar() {
const [meetings, setMeetings] = useState(initialMeetings);
return (
<Calendar.Root
events={meetings}
onEventChange={(change, detail) => {
if (detail.input === "agent") console.info(`The assistant proposed a ${change.cause}.`);
setMeetings((current) => applyChange(current, change, detail));
}}
policies={[noAgentDeletes]}
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
defaultTimeZone="Europe/Berlin"
locale="en-US"
weekRules={weekRules}
>
<Calendar.ActiveView />
</Calendar.Root>
);
}Two kinds of code do change:
- A handler with a second parameter of its own. 1.x called
onEventChangewith the change alone. A function passed directly, asonEventChange={save}wheresaveis(change, options?) => …, now receives the detail asoptions. TypeScript reports it when the two types differ, and stays silent whenoptionsis loose enough to take a detail. Wrap the call:onEventChange={(change) => save(change)}. - Code that calls a typed handler.
CalendarEventChangeHandlernow has two parameters, anddetailis required. A test or a wrapper that calls such a handler with one argument stops compiling. Pass a detail:handler(change, { input: "api" }).
applyChange and calendar.tsx are the ones from Connect an agent
and the Quick start.
The detail has a new optional member, fields: what a change says beside where the event goes.
An agent's createEvent and updateEvent put the title there, and whatever else the agent sent.
A person's gestures send none, so a handler that ignores detail saves a person's changes as it
did. It saves an agent's too, but without the title, which is why applyChange above takes the
detail. See Save what the agent sent.
actions.checkEventChange(proposal, detail?) takes the detail as well, so a preview can ask the
policies the question the real proposal will.
A policy you call yourself, in a unit test for example, has a context type with one more optional
field. Code that builds the context as { events, timeZone } still compiles.
State handlers hear why and who
The second argument of onViewChange, onAnchorDateChange and the other four state handlers had
previous, controlled and slice. It now also has:
| Field | Contents |
|---|---|
reason | "next-press", "previous-press", "today-press", "input-change", "keyboard-navigation", "focus-change", "resource-toggle" or "imperative" |
source | "mouse", "touch", "pen", "keyboard", "virtual", "programmatic" or "agent" |
event | The DOM event, when one of the calendar's own controls caused the change |
cancel() | Keeps the value as it was |
canceled | Whether a handler cancelled |
"keyboard" is a person's keys, on a toolbar button and in a view: arrow-key navigation, moving
focus and expanding a resource report it. "programmatic" is a call from your own code, and
"agent" anything an agent's step causes.
Handlers still run when they did: before a controlled value changes, since your handler is what
changes it, and after an uncontrolled one. cancel() puts an uncontrolled value back.
State has an example.
This breaks one thing: a test or a wrapper that builds a CalendarStateChangeDetail object by
hand. Add the new fields, or let the calendar make the detail by calling an action.
Actions take options
setView, setAnchorDate, setTimeZone, setSelection, setFocus, setExpandedResourceIds,
navigateNext, navigatePrevious and navigateToday take an options object last:
{ event?, reason?, source? }. It says why the app made the call, and a state handler reads it
back.
Calls without it are unchanged. One pattern stops compiling: a navigation action passed directly
as an event handler. TypeScript reports that the click event "has no properties in common with
type CalendarCommandOptions". Wrap the call, and pass the event if a handler should hear it:
"use client";
import { Calendar } from "./calendar";
export function NextButton() {
const actions = Calendar.useCalendarActions();
return (
// Before: onClick={actions.navigateNext}. The click isn't the options object.
<button type="button" onClick={(event) => actions.navigateNext({ event: event.nativeEvent })}>
Next
</button>
);
}Calendar.NextTrigger, Calendar.PreviousTrigger and Calendar.TodayTrigger already do this.
The parts have data-slot
Calendar.Frame and the toolbar parts are ui-sdk slots now, and each renders a data-slot
attribute beside its data-calendar-part:
| Part | data-slot |
|---|---|
Frame | calendar |
Toolbar | calendar-toolbar |
Title | calendar-title |
Viewport | calendar-viewport |
PreviousTrigger | calendar-previous-trigger |
TodayTrigger | calendar-today-trigger |
NextTrigger | calendar-next-trigger |
ViewSwitcher | calendar-view-switcher |
They matter when your app already targets one of those names, and calendar is the likely one:
shadcn's date picker renders data-slot="calendar" on its root. A rule such as [data-slot="calendar"] { … }, or a test's
querySelector('[data-slot="calendar"]'), written for the date picker now matches the scheduler's
frame too. Scope such a selector to the date picker, or select the scheduler by
data-calendar-part="frame".
Add the registry's items again
In 1.x the registry's Tailwind items used shadcn's button, badge, tooltip, select,
popover and dialog from your app's components/ui, and Base UI's toast, so a change you made
there changed the calendar too, and your app needed a Base UI style. In 2.0 they use
calendar-ui, the calendar's own controls, built on ui-sdk, and no longer need Base UI. The controls no longer follow your
app's components/ui: they look the same in every app, and you restyle them in their own files.
They are a default and the files are yours, so you can still put your own components in their
place. Customization lists every way to change the calendar's UI.
-
Add the items you use again, or all of them:
npx shadcn@latest add https://time.molten.sh/r/calendar-full.jsonThis now installs
calendar-uitoo:button.tsx,badge.tsx,tooltip.tsx,select.tsx,popover.tsx,dialog.tsxandtoast.tsxincomponents/calendar/ui/, with the classes each one uses in a*.styles.tsfile beside it. It adds@ui-sdk/coreand@ui-sdk/reactif your app doesn't have them yet.shadcn addasks before it replaces a file you changed; redo your changes on the new files. -
ui-sdk adds a little CSS to the page in a layer named
ui-sdk. Name that layer before Tailwind in your global CSS, so Tailwind's utilities win over it:globals.css @layer ui-sdk; @import "tailwindcss";The calendar's popups, from the view select's list and the tooltips to the popovers, the recurrence dialog and the undo toast, open in the browser's top layer, through the Popover API, so the registry's items now need Chrome and Edge 114, Safari 17 or Firefox 125. In an older browser they render at the end of the page, and a server-rendered page doesn't hydrate them cleanly.
-
If you restyled the calendar's buttons, badges, tooltips, popovers, dialogs or the view switcher through
components/ui, make those changes incomponents/calendar/ui/instead. To keep using your own components there, make those files render them, as Use your own controls shows. -
The items no longer install shadcn's components or
@base-ui/react, and any shadcn style works. Keep the ones your app uses itself; the calendar doesn't need them. An app without shadcn's tokens can addbase-tokens, as UI source shows.
An agent bridge now lists the toolbar's buttons and the view select
beside the calendar, as button and select entries, and your allow hears the steps an agent
takes on them. The calendar's tooltips no longer need a TooltipProvider, and they don't follow
its delay: the toolbar's open after 400 ms, which tooltipDefaults in
components/calendar/ui/tooltip.styles.ts sets.
If you edited the views, in either flavour, a few of their own props changed with the move:
renderUnavailableis a function of the band's props and its state,(props, state) => element. An element alone no longer works: wrap it in a function that spreadspropson it.AnnotationMark'srendertakes an element, and the mark's props merge into it. A function no longer works.- The history toast's
recordedAnnouncement(step, title)message is nowrecordedHint(step), instylex-calendar-history-toasttoo. It returns only the part after the toast's title, such as "To undo it, press F6 and choose Undo.", since the title is read first. A screen reader now reads every toast as it shows, after the announcement of the gesture that caused it. - A popover trigger has
aria-expandedwhile its popover is open, in place of Base UI'sdata-popup-open. Style it witharia-expanded:, or"[aria-expanded=true]"in StyleX. - The time grid's event tooltips share one tooltip per view. A composition that renders
TimeGridEventoutside the registry's views wraps them inTimeGridEventTooltipto do the same; without it, each event brings its own.
Add the StyleX items again
In 1.x the stylex- items took their buttons, badges, tooltips and the view select from Astryx,
and their popovers, dialog and toast from Base UI. Their base colors, such as --background and
--primary, read the Astryx theme around them. In 2.0 they use stylex-calendar-ui, the StyleX
twin of calendar-ui, on ui-sdk, with the same look as the Tailwind items, and their tokens hold
their own values.
-
Add the items you use again, or all of them:
npx shadcn@latest add https://time.molten.sh/r/stylex-calendar-full.jsonThis installs
stylex-calendar-uiincomponents/calendar-stylex/ui/, with each control's styles in a*.styles.tsfile beside it, and adds@ui-sdk/coreand@ui-sdk/react. -
Name ui-sdk's layer at the top of your global CSS, as Add the global CSS shows. If Astryx's
Themeset your root'scolor-scheme, and you drop it, set it yourself. -
To keep the calendar in your Astryx theme's colors, map them onto the base colors, as Use your design system's colors shows. Without that, the calendar takes the Tailwind theme's neutral colors. Astryx's root
Themeputs its variables on<html>, so the theme goes there too:const astryxCalendarTheme = stylex.createTheme(calendarVars, { "--radius": "var(--radius-element)", "--background": "var(--color-background-surface)", "--foreground": "var(--color-text-primary)", "--popover": "var(--color-background-popover)", "--primary": "var(--color-accent)", "--muted-foreground": "var(--color-text-secondary)", "--border": "var(--color-border)", "--ring": "var(--focus-outline-color)", // …and the rest of the base colors, in the same way. }); document.documentElement.classList.add( ...(stylex.props(astryxCalendarTheme).className ?? "").split(" "), ); -
The items no longer list
@astryxdesign/coreor@base-ui/react. Keep them if your app uses them itself. The views hide text visually withvisuallyHiddenStyles, incomponents/calendar-stylex/visually-hidden.styles.ts, in place of Astryx'sVisuallyHidden.
The props that changed for the Tailwind views, listed above, changed in the StyleX views too.
Name the calendar
Root takes three new props:
| Prop | Effect |
|---|---|
label | Names the calendar. Calendar.Frame takes it as its aria-label, and an agent finds the calendar by it |
allowAgentDelete | Gives an agent the deleteEvent action. Off by default: the calendar has no such action then, and refuses any delete an agent causes |
formatAgentEventLabel | Names each visible event in the list an agent reads. By default the title and ISO times |
Without label, the frame is labelled by the title, as in 1.x, so nothing changes for a screen
reader until you set it. With label, the frame's name is the label and the title is no longer
part of it. useCalendarMeta() has the label as meta.label.
Make it agent-ready
Upgrading exposes nothing. An agent reaches a calendar only after your app creates a bridge. When you want that:
- Give
Rootalabel. - Render
Calendar.FrameinsideRoot. A calendar without a frame works for people and isn't listed for agents. - Read
detail.fieldsinonEventChange, so a title an agent sends is saved. See Save what the agent sent. - Create the bridge with an
allow, as Connect an agent shows.
A calendar without onEventChange gives an agent the reading and navigation actions and no
event action, as it gives a person no editing.
New packages
| Package | What it is | Install it when |
|---|---|---|
@moltenship/calendar-primitives | The framework-free runtime, store and ui-sdk primitive | You write a framework integration |
@moltenship/calendar-solid | The Solid integration | Your app is on SolidJS 2 |
createCalendarStore, resolveViewOptions and the state types moved from
@moltenship/calendar-react into the primitives. Both @moltenship/calendar and
@moltenship/calendar-react re-export them, so imports from either still work and a store you
created keeps its contract. See Primitives.
The pointer hook moved
@moltenship/calendar-dnd imports no framework in 2.0, and @moltenship/calendar-solid binds it too. Its
one React hook, useCalendarPointer, is in @moltenship/calendar-react now, with the same
options and return value. @moltenship/calendar exports it as before, so an import from the
facade doesn't change. An import from the pointer package does:
// 1.x
import { useCalendarPointer } from "@moltenship/calendar-dnd";
// 2.0
import { useCalendarPointer } from "@moltenship/calendar-react";Everything else in @moltenship/calendar-dnd stays where it was: attachCalendarPointer,
startCalendarDrop, monitorCalendarDrags and the attribute helpers. It no longer has React as a
peer dependency.
With React but without calendar-react
An app that used @moltenship/calendar-dnd in React without @moltenship/calendar-react has two
ways on:
- Add
@moltenship/calendar-reactand its peers,@ui-sdk/coreand@ui-sdk/react, then import the hook from it as above. - Keep the hook in the app. It's a few lines around
attachCalendarPointer:
import type { EventId, ResourceId } from "@moltenship/calendar-core";
import { attachCalendarPointer, type CalendarPointerOptions } from "@moltenship/calendar-dnd";
import { useCallback, useInsertionEffect, useRef, type RefCallback } from "react";
export function useCalendarPointer<
TEvent,
TEventId extends EventId,
TResourceId extends ResourceId,
>(options: CalendarPointerOptions<TEvent, TEventId, TResourceId>): RefCallback<HTMLElement> {
const latest = useRef(options);
useInsertionEffect(() => {
latest.current = options;
});
const disabled = options.disabled === true;
// Options are read as a gesture goes; only `disabled` attaches the listeners again.
return useCallback(
(element: HTMLElement | null) =>
element === null ? undefined : attachCalendarPointer(element, () => latest.current),
[disabled],
);
}Either way, keep every @moltenship/calendar* package on one version. @moltenship/calendar-react
depends on @moltenship/calendar-dnd at its own exact version, and the pointer package keeps its
drag registry in the module: two copies of it don't hear each other's drags, so a drop from one
never reaches a view bound through the other.
Tests
- Scripted clicks. A click a test dispatches reads
source: "programmatic"in a state handler. Only a real pointer reads"mouse". - The frame's name. A test that finds the frame by its accessible name finds the
labelonce you set one. - The registry's controls in jsdom. They're ui-sdk's, which read paint timing, measure toasts and wait for transitions, none of which jsdom has, and jsdom hides every popup. Add the stubs Testing lists to your test setup file.
- Agent changes. Testing shows how to run an agent's step in a test.
For coding agents
If a coding agent does the upgrade, give it the docs for the version you install. They ship in the
package, at node_modules/@moltenship/calendar/docs, with a skill beside them. See
Build with a coding agent.