@moltenship/calendar 1.0.0-rc.1 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +24 -4
  2. package/dist/index.d.mts +2 -2
  3. package/docs/accessibility.md +304 -0
  4. package/docs/agents/changes.md +449 -0
  5. package/docs/agents/coding-agents.md +117 -0
  6. package/docs/agents/connect.md +435 -0
  7. package/docs/agents/deleting.md +296 -0
  8. package/docs/agents/reference.md +512 -0
  9. package/docs/agents/server.md +317 -0
  10. package/docs/agents/webmcp.md +153 -0
  11. package/docs/agents.md +353 -0
  12. package/docs/annotations.md +196 -0
  13. package/docs/api/changes.md +248 -0
  14. package/docs/api/dnd-kit.md +267 -0
  15. package/docs/api/events.md +152 -0
  16. package/docs/api/ics.md +524 -0
  17. package/docs/api/primitives.md +168 -0
  18. package/docs/api/react.md +236 -0
  19. package/docs/api/recurrence.md +586 -0
  20. package/docs/api/solid.md +460 -0
  21. package/docs/api/store.md +92 -0
  22. package/docs/api/temporal.md +172 -0
  23. package/docs/api.md +57 -0
  24. package/docs/availability.md +573 -0
  25. package/docs/comparison.md +279 -0
  26. package/docs/concepts/anatomy.md +73 -0
  27. package/docs/concepts/events.md +164 -0
  28. package/docs/concepts/how-it-works.md +95 -0
  29. package/docs/concepts/recurrence.md +127 -0
  30. package/docs/concepts/state.md +244 -0
  31. package/docs/concepts/time.md +170 -0
  32. package/docs/guides/dnd-kit.md +333 -0
  33. package/docs/guides/google-calendar-sync.md +1246 -0
  34. package/docs/guides/google-calendar.md +367 -0
  35. package/docs/guides/ics.md +486 -0
  36. package/docs/guides/motion.md +414 -0
  37. package/docs/guides/nextjs-app-router.md +630 -0
  38. package/docs/guides/nextjs.md +149 -0
  39. package/docs/guides/performance.md +103 -0
  40. package/docs/guides/recurring-events.md +583 -0
  41. package/docs/guides/tanstack-query.md +485 -0
  42. package/docs/index.md +118 -0
  43. package/docs/installation.md +194 -0
  44. package/docs/interactions.md +408 -0
  45. package/docs/llms.txt +86 -0
  46. package/docs/migrating-to-2.md +322 -0
  47. package/docs/quick-start.md +159 -0
  48. package/docs/stylex.md +265 -0
  49. package/docs/testing.md +581 -0
  50. package/docs/theme-builder.md +81 -0
  51. package/docs/theming.md +169 -0
  52. package/docs/undo-redo.md +339 -0
  53. package/docs/views/agenda.md +221 -0
  54. package/docs/views/custom-views.md +192 -0
  55. package/docs/views/month.md +109 -0
  56. package/docs/views/resource-columns.md +261 -0
  57. package/docs/views/resource-timeline.md +225 -0
  58. package/docs/views/scrolling.md +192 -0
  59. package/docs/views/week-and-day.md +257 -0
  60. package/docs/views/year.md +138 -0
  61. package/docs/views.md +69 -0
  62. package/package.json +41 -14
  63. package/skills/moltenship-time/SKILL.md +75 -0
  64. package/skills/moltenship-time/references/agent-ready.md +272 -0
  65. package/skills/moltenship-time/references/changes.md +188 -0
  66. package/skills/moltenship-time/references/compose.md +168 -0
  67. package/skills/moltenship-time/references/mistakes.md +98 -0
  68. package/skills/moltenship-time/references/solid.md +202 -0
  69. package/skills/moltenship-time/references/state.md +129 -0
  70. package/skills/moltenship-time/references/testing.md +176 -0
package/docs/agents.md ADDED
@@ -0,0 +1,353 @@
1
+ # Agents
2
+
3
+ What an AI agent sees of your calendar, what it can do to it, and where your app stays in charge.
4
+
5
+ Source: https://time.molten.sh/docs/agents
6
+
7
+ > Live example: see it at https://time.molten.sh/docs/agents
8
+
9
+ An agent is an AI model with tools: the one built into a browser, or one you run and connect to
10
+ your page. Since 2.0 a calendar describes itself to agents. An agent reads the calendar's state and
11
+ the events in view, and changes them by calling named actions. It doesn't read your markup or
12
+ simulate a pointer.
13
+
14
+ The calendar is a [ui-sdk](https://ui-sdk.dev) component, and agents reach it through ui-sdk's
15
+ agent bridge. Three things stay yours:
16
+
17
+ - **The bridge.** Nothing is exposed until your app creates one. A calendar on a page without a
18
+ bridge can't be read or changed by an agent.
19
+ - **What an agent may do.** The bridge asks your `allow` before every step.
20
+ - **Saving.** An agent's change is a proposal, like a drag. Your policies check it, and your
21
+ `onEventChange` saves it or refuses it.
22
+
23
+ The example above is a real calendar next to what a real bridge lists for it. The buttons send the
24
+ calls a model would send. No model runs on these pages.
25
+
26
+ ## What an agent sees
27
+
28
+ The bridge's `snapshot()` lists every ui-sdk component on the page. A calendar is one entry:
29
+
30
+ ```json
31
+ {
32
+ "ref": "c1",
33
+ "component": "calendar",
34
+ "actions": [
35
+ "createEvent",
36
+ "describeCalendar",
37
+ "getChange",
38
+ "goToDate",
39
+ "listEvents",
40
+ "moveEvent",
41
+ "navigateNext",
42
+ "navigatePrevious",
43
+ "navigateToday",
44
+ "resizeEvent",
45
+ "selectEvent",
46
+ "setTimeZone",
47
+ "setView",
48
+ "updateEvent"
49
+ ],
50
+ "label": "Team calendar",
51
+ "anchorDate": "2026-10-08",
52
+ "view": "week",
53
+ "timeZone": "Europe/Berlin",
54
+ "selection": null,
55
+ "focus": null,
56
+ "expandedResourceIds": [],
57
+ "items": [
58
+ {
59
+ "value": "planning",
60
+ "label": "Sprint planning · 2026-10-05T10:00 to 2026-10-05T11:30 (Europe/Berlin)"
61
+ },
62
+ {
63
+ "value": "lunch",
64
+ "label": "Team lunch · 2026-10-07T12:30 to 2026-10-07T13:30 (Europe/Berlin)"
65
+ },
66
+ {
67
+ "value": "standup",
68
+ "label": "Standup · 2026-10-08T09:00 to 2026-10-08T09:15 (Europe/Berlin)"
69
+ },
70
+ {
71
+ "value": "review",
72
+ "label": "Design review · 2026-10-08T15:00 to 2026-10-08T16:00 (Europe/Berlin)"
73
+ },
74
+ {
75
+ "value": "one-on-one",
76
+ "label": "1:1 with Sam · 2026-10-09T14:00 to 2026-10-09T14:30 (Europe/Berlin)"
77
+ }
78
+ ],
79
+ "text": ["Oct 5 – 11, 2026"]
80
+ }
81
+ ```
82
+
83
+ | Field | Contents |
84
+ | -------------------------------- | --------------------------------------------------------------------------------------------------- |
85
+ | `ref` | The bridge's handle for the calendar. A step can name the calendar by it |
86
+ | `component` | Always `"calendar"` |
87
+ | `label` | `Root`'s `label`, or the calendar's title when there's none. A step can name the calendar by it too |
88
+ | `actions` | What the agent can call on this calendar now. See [what an agent can do](#what-an-agent-can-do) |
89
+ | `view`, `anchorDate`, `timeZone` | The calendar's [state](./concepts/state.md): the active view, the date it shows, and its time zone |
90
+ | `selection`, `focus` | Your selection and focus values, or `null` |
91
+ | `expandedResourceIds` | The resource groups that are expanded |
92
+ | `items` | The events in the visible range: `value` is the event's ID as a string, `label` its title and time |
93
+ | `text` | The calendar's text an agent can read: its title |
94
+
95
+ `items` holds the events the active view shows, all-day events first and then by start. It's left
96
+ out when the range has none. A label is the event's title, then its start and end as ISO date-times
97
+ in the calendar's time zone, which it names. It doesn't follow `Root`'s `locale`, so a model reads
98
+ the same label in every language. An all-day event reads `Offsite · 2026-10-06 (all day)`.
99
+
100
+ The entry is enough to find the calendar. For anything it's going to act on, an agent asks the
101
+ calendar itself, with the two reading actions below.
102
+
103
+ The toolbar's buttons and the view switcher are parts of the calendar, not entries of their own.
104
+ The agent navigates with actions and never presses "Next".
105
+
106
+ ## What an agent can do
107
+
108
+ An agent calls `act` with steps. Each step names a component, one of its actions, and the action's
109
+ input. An action takes nothing, or exactly one object:
110
+
111
+ ```json
112
+ {
113
+ "steps": [
114
+ { "ref": "Team calendar", "action": "listEvents", "args": [] },
115
+ {
116
+ "ref": "Team calendar",
117
+ "action": "moveEvent",
118
+ "args": [{ "eventId": "review", "start": "2026-10-09T10:00" }]
119
+ }
120
+ ]
121
+ }
122
+ ```
123
+
124
+ | Action | What it does |
125
+ | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
126
+ | `describeCalendar()` | Returns the calendar's facts: today, the time zone, the views, what's allowed |
127
+ | `listEvents({ start?, end? })` | Returns the events of a range of dates. Without one, the range in view |
128
+ | `getChange({ changeId })` | Returns a change by its ID, with where it is now: one an agent proposed, or anyone's that's still pending |
129
+ | `navigateNext()` | Shows the next range: the next week in a week view |
130
+ | `navigatePrevious()` | Shows the previous range |
131
+ | `navigateToday()` | Shows the range that holds today |
132
+ | `goToDate({ date })` | Shows the range that holds `date` |
133
+ | `setView({ view })` | Switches to one of your views by name |
134
+ | `setTimeZone({ timeZone })` | Shows times in another IANA time zone |
135
+ | `selectEvent({ eventId })` | Selects an event, or clears the selection with `null` |
136
+ | `createEvent({ start, end, title?, resourceIds?, fields? })` | Proposes a new event. Dates make an all-day event, date-times a timed one |
137
+ | `updateEvent({ eventId, title?, start?, end?, resourceIds?, fields? })` | Proposes new details for an event: a title, times, resources, or your own fields |
138
+ | `moveEvent({ eventId, start, end?, resourceIds? })` | Proposes a new time for an event. It keeps its length unless `end` is given |
139
+ | `resizeEvent({ eventId, start?, end? })` | Proposes a new start or a new end for an event |
140
+ | `deleteEvent({ eventId })` | Proposes deleting an event. Absent unless `Root` has `allowAgentDelete` |
141
+
142
+ Dates are ISO strings, such as `"2026-10-09"`. A time without an offset, such as
143
+ `"2026-10-09T10:00"`, is wall-clock time in the calendar's time zone; with `Z` or an offset it's
144
+ that exact moment. A date in another calendar, such as one that ends in `[u-ca=hebrew]`, fails
145
+ with `calendar-agent-unsupported-calendar`. The [reference](./agents/reference.md) has every
146
+ argument and every error.
147
+
148
+ The bridge's three tools are the same for every component, so their definitions don't say what a
149
+ calendar's actions take. The calendar says it itself: `describeCalendar` returns each action it
150
+ offers with its input, and an action called wrongly fails with the same text.
151
+
152
+ ## Reading the calendar
153
+
154
+ A model starts with `describeCalendar`. Its result is what the model can't know or guess:
155
+
156
+ ```json
157
+ {
158
+ "actions": {
159
+ "describeCalendar": "nothing",
160
+ "listEvents": "nothing, or { start?: ISO date, end?: ISO date }",
161
+ "getChange": "{ changeId: string }",
162
+ "navigateNext": "nothing",
163
+ "navigatePrevious": "nothing",
164
+ "navigateToday": "nothing",
165
+ "goToDate": "{ date: ISO date }",
166
+ "setView": "{ view: one of views }",
167
+ "setTimeZone": "{ timeZone: IANA name }",
168
+ "selectEvent": "{ eventId: ID or null }",
169
+ "createEvent": "{ start: ISO date or date-time, end: ISO date or date-time, title?: string, resourceIds?: ID[], fields?: object }",
170
+ "updateEvent": "{ eventId: ID, title?: string, start?: ISO date or date-time, end?: same, resourceIds?: ID[], fields?: object }",
171
+ "moveEvent": "{ eventId: ID, start: ISO date or date-time, end?: same, resourceIds?: ID[] }",
172
+ "resizeEvent": "{ eventId: ID, start?: ISO date or date-time, end?: same }, one of start and end"
173
+ },
174
+ "anchorDate": "2026-10-08",
175
+ "canDelete": false,
176
+ "conventions": "Dates are ISO 8601. A time without an offset is wall-clock time in timeZone; with an offset or Z it is that instant. Ranges include start and exclude end. Event IDs are listEvents' id values.",
177
+ "locale": "en-US",
178
+ "now": "2026-10-06T11:42:07.512+02:00",
179
+ "pendingChanges": [],
180
+ "readOnly": false,
181
+ "resources": [],
182
+ "selectedEventId": null,
183
+ "timeZone": "Europe/Berlin",
184
+ "today": "2026-10-06",
185
+ "view": "week",
186
+ "views": ["week", "day", "month", "agenda"],
187
+ "visibleRange": { "start": "2026-10-05", "end": "2026-10-12" }
188
+ }
189
+ ```
190
+
191
+ `today` and `now` are in the calendar's time zone, so "tomorrow at ten" needs nothing from your
192
+ prompt. `views` is what `setView` takes, `resources` what `resourceIds` takes, and `actions` what
193
+ the calendar offers now, each with its input. On a calendar that has resources, a `resourceIds`
194
+ entry that isn't one of them fails with `calendar-agent-unknown-resource`, which lists the ones
195
+ there are.
196
+
197
+ `listEvents` returns the events themselves, which is where event IDs come from:
198
+
199
+ ```json
200
+ [
201
+ {
202
+ "id": "standup",
203
+ "title": "Standup",
204
+ "kind": "timed",
205
+ "start": "2026-10-08T09:00:00+02:00",
206
+ "end": "2026-10-08T09:15:00+02:00",
207
+ "resourceIds": []
208
+ },
209
+ {
210
+ "id": "review",
211
+ "title": "Design review",
212
+ "kind": "timed",
213
+ "start": "2026-10-08T15:00:00+02:00",
214
+ "end": "2026-10-08T16:00:00+02:00",
215
+ "resourceIds": []
216
+ }
217
+ ]
218
+ ```
219
+
220
+ Without input it lists the range in view. With `{ "start": "2026-10-01", "end": "2026-11-01" }` it
221
+ lists any dates, in view or not, so an agent doesn't navigate to read. `end` is exclusive, here and
222
+ on every event. An all-day event has dates for `start` and `end`. An event being saved has
223
+ `"pending": true` and shows where it's going; one that can't be changed has `"readOnly": true`.
224
+
225
+ ## What a step returns
226
+
227
+ A step that changes the calendar's state reports the change:
228
+
229
+ ```json
230
+ {
231
+ "ok": true,
232
+ "steps": [
233
+ {
234
+ "step": 0,
235
+ "ref": "c1",
236
+ "changes": [
237
+ {
238
+ "component": "calendar",
239
+ "label": "Team calendar",
240
+ "key": "anchorDate",
241
+ "value": "2026-10-15"
242
+ }
243
+ ]
244
+ }
245
+ ],
246
+ "appeared": [],
247
+ "values": {}
248
+ }
249
+ ```
250
+
251
+ A reading action's step has what it returned as `result`. So does a step that changes an event: its
252
+ `result` is the change, with a `status`:
253
+
254
+ ```json
255
+ {
256
+ "ok": true,
257
+ "steps": [
258
+ {
259
+ "step": 0,
260
+ "ref": "c1",
261
+ "result": {
262
+ "cause": "move",
263
+ "changeId": "change-1",
264
+ "eventId": "review",
265
+ "proposed": {
266
+ "start": "2026-10-09T10:00:00+02:00",
267
+ "end": "2026-10-09T11:00:00+02:00",
268
+ "kind": "timed",
269
+ "resourceIds": []
270
+ },
271
+ "status": "saved"
272
+ }
273
+ }
274
+ ],
275
+ "appeared": [],
276
+ "values": {}
277
+ }
278
+ ```
279
+
280
+ | `status` | Meaning |
281
+ | ------------ | -------------------------------------------------------------------------------- |
282
+ | `saved` | Your `onEventChange` took the change, at once or once its promise resolved |
283
+ | `saving` | Your `onEventChange` returned a promise that hasn't settled |
284
+ | `validating` | A policy that returns a promise hasn't answered |
285
+ | `rejected` | A policy or your handler refused it after the step returned. `reason` says which |
286
+
287
+ `proposed` is where the event lands, after your policies adjusted it. A change that's `saving` or
288
+ `validating` isn't done: the agent calls `getChange` with its `changeId` to read how it ended, as
289
+ [Saves that take a while](./agents/changes.md#saves-that-take-a-while) shows. A `createEvent` has
290
+ `"eventId": null`, since your app makes the event; the agent finds it with `listEvents`.
291
+
292
+ A step that fails stops the call and says why, in words the model can act on:
293
+
294
+ ```json
295
+ {
296
+ "ok": false,
297
+ "error": {
298
+ "step": 0,
299
+ "message": "calendar-agent-unknown-event: no event has the ID \"nope\". Events: \"standup\", \"review\", \"planning\", \"lunch\", \"one-on-one\""
300
+ },
301
+ "steps": [],
302
+ "appeared": [],
303
+ "values": {}
304
+ }
305
+ ```
306
+
307
+ A change your policies or your handler refuse at once fails its step the same way, with
308
+ `calendar-event-change-rejected:` and the reason. Earlier steps of the same call stay applied.
309
+
310
+ ## What your app writes
311
+
312
+ The calendar holds no events, so three parts of an agent's change are your code:
313
+
314
+ - **Saving.** `onEventChange` gets an agent's change as it gets a drag, with `detail.input` of
315
+ `"agent"`. That holds for anything a step causes, a press on a button of yours included, as
316
+ long as the button's handler makes the change before it returns.
317
+ - **Titles and your own fields.** `createEvent` and `updateEvent` take a `title` and a `fields`
318
+ object. The calendar doesn't know your event's shape, so it hands them to your handler as
319
+ `detail.fields` without checking what's in them, and your handler stores what it accepts.
320
+ - **Rules.** Your policies see every change before it's saved, and `detail.fields` with it.
321
+
322
+ [Connect an agent](./agents/connect.md#name-the-calendar) has the handler.
323
+
324
+ ## What an agent can't do
325
+
326
+ - **Learn an action's input from the bridge's tools.** `act`'s definition says a step has `args`,
327
+ not what `moveEvent` takes. The calendar's own `describeCalendar` says it, so tell your model to
328
+ call it first.
329
+ - **Ask whether a change would be accepted.** There's no dry run. An agent proposes the change, and
330
+ a refusal fails the step with the reason.
331
+ - **Delete, unless you say so.** A calendar has no `deleteEvent` action until `Root` has
332
+ `allowAgentDelete`, and until then it refuses a delete an agent causes any other way, such as
333
+ by pressing a delete button of yours whose handler deletes at once. See
334
+ [Deleting](./agents/deleting.md) for a button that waits first.
335
+ - **Skip your rules.** Policies and `onEventChange` run for an agent as they do for a person, and
336
+ they hear `input: "agent"` for every change a step causes, so a policy that refuses agents
337
+ can't be stepped around through a button whose handler changes the calendar at once. A button
338
+ that waits first is [yours to keep from agents](./agents/changes.md#two-kinds-of-change). A calendar without `onEventChange` is read-only for
339
+ agents too, and offers no action that changes an event.
340
+ - **Write a field your handler doesn't store.** `fields` reaches your `onEventChange` and goes no
341
+ further unless your code puts it somewhere.
342
+ - **See what isn't a ui-sdk component.** A dialog or a form you build with another library isn't in
343
+ the snapshot. ui-sdk's own components are.
344
+
345
+ ## In this section
346
+
347
+ - [Connect an agent](./agents/connect.md): Create the bridge, name the calendar, and decide what an agent may do.
348
+ - [Who made a change](./agents/changes.md): Tell an agent's change from a person's, refuse it with a policy, and undo it.
349
+ - [Deleting](./agents/deleting.md): Let an agent delete only after the person says yes.
350
+ - [WebMCP](./agents/webmcp.md): Hand the calendar's tools to the agent built into a browser.
351
+ - [A model on your server](./agents/server.md): Give a model the bridge's tools and run its calls on the page.
352
+ - [Reference](./agents/reference.md): Every action, argument, error and snapshot field.
353
+ - [Build with a coding agent](./agents/coding-agents.md): The docs as Markdown, llms.txt, and a skill for coding agents.
@@ -0,0 +1,196 @@
1
+ # Annotations
2
+
3
+ Time-based information beside events, such as listening history, sleep, workouts and focus sessions.
4
+
5
+ Source: https://time.molten.sh/docs/annotations
6
+
7
+ > Live example of the `week` view: see it at https://time.molten.sh/docs/annotations
8
+
9
+ Annotations show what happened alongside the events: what you listened to, when you slept, a
10
+ workout, a focus session. Unlike events they are read-only, and they never take part in overlap
11
+ layout, so they never reorder an event or change its lane. An event beside one only moves aside
12
+ for the rail. Try them in the
13
+ [live demo](https://moltenship-time-demo.vercel.app); the sidebar's Activity list shows and hides
14
+ each source.
15
+
16
+ The calendar doesn't fetch anything. Your app loads the data from its integrations and passes it to
17
+ `Root`, the same way it passes events.
18
+
19
+ ## Add them
20
+
21
+ Describe each source once, then pass the sources and the annotations to `Root`:
22
+
23
+ ```tsx
24
+ import { MoonIcon, MusicIcon } from "lucide-react";
25
+ import type { TimeGridAnnotationSource } from "@/components/calendar/time-grid-view/time-grid-annotations";
26
+
27
+ const sources: TimeGridAnnotationSource[] = [
28
+ { id: "sleep", label: "Sleep", color: "purple", Icon: MoonIcon },
29
+ {
30
+ id: "music",
31
+ label: "Music",
32
+ color: "green",
33
+ Icon: MusicIcon,
34
+ // Tracks less than five minutes apart draw as one listening session.
35
+ mergeGap: Temporal.Duration.from({ minutes: 5 }),
36
+ },
37
+ ];
38
+
39
+ const annotations = recentlyPlayed.map((play) => ({
40
+ id: play.id,
41
+ sourceId: "music",
42
+ start: Temporal.Instant.from(play.startedAt),
43
+ end: Temporal.Instant.from(play.endedAt),
44
+ title: `${play.track} · ${play.artist}`,
45
+ }));
46
+
47
+ <Calendar.Root annotationSources={sources} annotations={annotations} {...props} />;
48
+ ```
49
+
50
+ The library knows no kinds of source: "sleep" and "music" are your names. Sources show in the order
51
+ you list them, and leaving one out of `annotationSources` hides its annotations. Like events,
52
+ annotations are half-open, `[start, end)`. Invalid ones are skipped and reported through
53
+ `onDiagnosticsChange`.
54
+
55
+ The week and day views draw annotations as soon as `Root` has sources. Without any, they draw no
56
+ rail.
57
+
58
+ ## How they draw
59
+
60
+ - **A rail beside the events.** The marks draw in a narrow strip at the start of each day column,
61
+ 18px in the week and 30px in the day. An event moves aside for the rail only where a mark is
62
+ beside it, counting a short mark as tall as the rail's `markWidth`. The events it shares lanes
63
+ with move with it, so they keep their places beside each other. Every other event, and every
64
+ event on a day without marks, keeps the column's whole width. With `placement: "overlay"` the
65
+ parts draw behind events instead and move nothing.
66
+ - **Capsules with the source's icon.** Each annotation draws as a capsule in its source's color,
67
+ with the icon inside its top. A mark is never shorter than it is wide, so a short session is a
68
+ circle with the icon.
69
+ - **Merging.** A source's annotations closer than its `mergeGap` draw as one mark, such as tracks
70
+ into a listening session. Marks whose circles would touch merge too, so song-level history stays
71
+ readable when zoomed out.
72
+ - **Lanes.** When different sources overlap, such as music during a focus session, they share the
73
+ rail in up to three narrower lanes. Too narrow for an icon, a mark drops it.
74
+ - **Days.** An annotation across midnight shows on both days. A part that starts the day before
75
+ fades in at the top and has no icon.
76
+ - **Details.** Hovering a mark shows a tooltip, and clicking it opens a popover listing what it
77
+ merges. Both are Base UI components, one of each for the whole grid. The popover keeps focus
78
+ until Escape, outside click or its close button, then returns it to where it was. Pressing or
79
+ dragging a mark never starts a new event.
80
+
81
+ ## Customize
82
+
83
+ The rail is registry source like the rest of the view, built from small parts you can restyle,
84
+ recompose or edit. From the lightest change to the heaviest:
85
+
86
+ **CSS.** Each mark has `data-slot="annotation-mark"`, `data-source`, `data-color`, `data-kind`
87
+ (`bar` or `dot`), and `data-starts-before` or `data-ends-after` when it's cut at midnight. The demo
88
+ gives sleep a night sky this way:
89
+
90
+ ```css
91
+ [data-slot="annotation-mark"][data-source="sleep"] {
92
+ background: linear-gradient(to bottom, oklch(0.5 0.19 282), oklch(0.7 0.14 275));
93
+ }
94
+ ```
95
+
96
+ **Your own composition.** Pass a component as the view's `annotations.Annotations`. It gets one
97
+ column's marks, already merged and placed in lanes, and composes the parts:
98
+
99
+ ```tsx
100
+ import {
101
+ AnnotationMark,
102
+ AnnotationMarkIcon,
103
+ AnnotationRail,
104
+ type TimeGridAnnotationsProps,
105
+ } from "@/components/calendar/time-grid-view/time-grid-annotations";
106
+
107
+ function MyAnnotations({ marks }: TimeGridAnnotationsProps) {
108
+ return (
109
+ <AnnotationRail>
110
+ {marks.map((mark) => (
111
+ <AnnotationMark key={mark.key} mark={mark} className="data-[source=music]:bg-[#1DB954]">
112
+ <AnnotationMarkIcon>
113
+ {mark.source.id === "music" ? <SpotifyLogo /> : null}
114
+ </AnnotationMarkIcon>
115
+ </AnnotationMark>
116
+ ))}
117
+ </AnnotationRail>
118
+ );
119
+ }
120
+
121
+ createWeekView<Meeting>({ annotations: { Annotations: MyAnnotations } });
122
+ ```
123
+
124
+ - `AnnotationMark` has the variants `capsule` (default), `bar` (a thin bar that keeps its true
125
+ length) and `band` (a tint across the column behind events, with `placement: "overlay"`). Base
126
+ UI's `render` prop swaps its element, for example for a link to the track.
127
+ - `AnnotationMarkIcon` draws the source's `Icon`. Children replace it.
128
+ - `useAnnotationMark()` gives any part inside a mark its mark and width.
129
+
130
+ **Rail size and lanes.** These are numbers rather than CSS, because merging and lane packing use
131
+ them:
132
+
133
+ ```tsx
134
+ createWeekView<Meeting>({
135
+ annotations: { rail: { width: 10, markWidth: 4 } }, // thin bars, as in Amie's desktop app
136
+ });
137
+ ```
138
+
139
+ **The parts themselves.** `time-grid-annotations.tsx` is yours: change the capsule, the tooltip or
140
+ the popover there.
141
+
142
+ **Your own view.** `useTimeGridAnnotations(columns, geometry)` returns the marks for any time-grid
143
+ columns, and `summarizeAnnotationMarks` returns a day's totals per source.
144
+
145
+ ## Anatomy
146
+
147
+ > Diagram: see it at https://time.molten.sh/docs/annotations
148
+
149
+ ```txt title="Rendered by TimeGridColumn"
150
+ TimeGridColumn time-grid-column.tsx
151
+ └── TimeGridAnnotations time-grid-annotations.tsx, or yours
152
+ └── AnnotationRail data-slot="annotation-rail", aria-hidden
153
+ └── AnnotationMark data-slot="annotation-mark", one per mark
154
+ └── AnnotationMarkIcon data-slot="annotation-mark-icon"
155
+ ```
156
+
157
+ ## Options
158
+
159
+ | Name | Type | Default | Description |
160
+ | ---------------- | ----------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
161
+ | `rail.width` | `number` | `18 in a week, 30 in a day` | The rail's width in px. |
162
+ | `rail.markWidth` | `number` | `12 in a week, 20 in a day` | A mark's width in px. Marks are never shorter than this, so short ones are circles. |
163
+ | `rail.side` | `"start" \| "end"` | `"start"` | The column edge the rail sits on. |
164
+ | `rail.layout` | `"pack" \| "per-source"` | `"pack"` | pack shares the rail between overlapping marks; per-source gives each source its own lane. |
165
+ | `placement` | `"rail" \| "overlay"` | `"rail"` | rail draws marks in a strip, and the events beside them move aside for it; overlay gives the parts the whole column, behind events. |
166
+ | `Annotations` | `ComponentType<TimeGridAnnotationsProps>` | | Your composition of the parts, in place of TimeGridAnnotations. |
167
+
168
+ Set them as the week or day view's `annotations` option.
169
+
170
+ ## Keyboard and screen readers
171
+
172
+ Annotations add no keys and no tab stops: the grid keeps its single tab stop and its
173
+ [key map](./views/week-and-day.md#keyboard). The rail is `aria-hidden`, and screen readers get the
174
+ same information in words instead:
175
+
176
+ | Where | What a screen reader hears |
177
+ | ---------------- | -------------------------------------------------------------------------------------------------------------- |
178
+ | A day's header | A summary of its annotations: "Annotations: Sleep until 7:05 AM. Music, 3 times, 2 hours, 10 minutes." |
179
+ | A slot, with ↑ ↓ | The items drawn across it, after its time: "Music: Nightcall, 9:00 AM to 9:04 AM; Genesis, 9:05 AM to 9:09 AM" |
180
+
181
+ Hover effects respect `prefers-reduced-motion`.
182
+
183
+ ## Data model
184
+
185
+ | Name | Type | Description |
186
+ | ------------- | ------------------------ | -------------------------------------------------------------------------------- |
187
+ | `id` | `string \| number` | Required. Unique among annotations. |
188
+ | `sourceId` | `string` | Required. The source it belongs to. Annotations of sources not given are hidden. |
189
+ | `start` | `Temporal.Instant` | Required. Inclusive start. |
190
+ | `end` | `Temporal.Instant` | Required. Exclusive end, after start. |
191
+ | `title` | `string` | Required. Shown in tooltips, popovers and slot names. |
192
+ | `resourceIds` | `readonly TResourceId[]` | Resources it belongs to. Resource views will use them. |
193
+ | `data` | `TData` | Anything your own parts need. |
194
+
195
+ A source has an `id`, a `label` that names it in summaries and tooltips, and an optional
196
+ `mergeGap`. The registry's `TimeGridAnnotationSource` adds `color` and `Icon`.