@moltenship/calendar 2.0.0-beta.1 → 2.0.0

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 (75) hide show
  1. package/README.md +11 -10
  2. package/dist/index.d.mts +2 -2
  3. package/dist/index.mjs +2 -2
  4. package/docs/accessibility.md +5 -4
  5. package/docs/agents/changes.md +3 -3
  6. package/docs/agents/coding-agents.md +19 -20
  7. package/docs/agents/connect.md +20 -11
  8. package/docs/agents/deleting.md +2 -2
  9. package/docs/agents/reference.md +5 -6
  10. package/docs/agents/server.md +4 -4
  11. package/docs/agents/webmcp.md +2 -2
  12. package/docs/agents.md +10 -8
  13. package/docs/annotations.md +10 -8
  14. package/docs/api/changes.md +37 -21
  15. package/docs/api/{react.md → components.md} +65 -56
  16. package/docs/api/dnd-kit.md +1 -3
  17. package/docs/api/events.md +14 -13
  18. package/docs/api/primitives.md +61 -11
  19. package/docs/api/store.md +3 -3
  20. package/docs/api.md +23 -23
  21. package/docs/availability.md +25 -22
  22. package/docs/comparison.md +23 -24
  23. package/docs/concepts/anatomy.md +3 -3
  24. package/docs/concepts/events.md +2 -3
  25. package/docs/concepts/how-it-works.md +33 -16
  26. package/docs/concepts/state.md +1 -1
  27. package/docs/concepts/time.md +5 -7
  28. package/docs/customization.md +271 -0
  29. package/docs/frameworks.md +116 -0
  30. package/docs/guides/dnd-kit.md +2 -2
  31. package/docs/guides/google-calendar-sync.md +3 -3
  32. package/docs/guides/google-calendar.md +4 -4
  33. package/docs/guides/motion.md +2 -2
  34. package/docs/guides/nextjs-app-router.md +1 -1
  35. package/docs/guides/nextjs.md +1 -1
  36. package/docs/guides/performance.md +6 -6
  37. package/docs/guides/tanstack-query.md +2 -2
  38. package/docs/{guides/ics.md → ics/feed.md} +7 -9
  39. package/docs/ics/import.md +183 -0
  40. package/docs/{api/ics.md → ics/reference.md} +11 -53
  41. package/docs/ics.md +142 -0
  42. package/docs/index.md +81 -50
  43. package/docs/installation.md +48 -33
  44. package/docs/interactions.md +36 -3
  45. package/docs/llms.txt +81 -68
  46. package/docs/migrating-to-2.md +200 -25
  47. package/docs/quick-start.md +27 -23
  48. package/docs/{guides/recurring-events.md → recurrence/calendar.md} +23 -8
  49. package/docs/{concepts/recurrence.md → recurrence/model.md} +13 -12
  50. package/docs/{api/recurrence.md → recurrence/reference.md} +22 -61
  51. package/docs/recurrence.md +122 -0
  52. package/docs/stylex.md +74 -49
  53. package/docs/temporal/daylight-saving-time.md +172 -0
  54. package/docs/temporal/month-grid.md +119 -0
  55. package/docs/{api/temporal.md → temporal/reference.md} +7 -12
  56. package/docs/temporal.md +105 -0
  57. package/docs/testing.md +20 -1
  58. package/docs/theme-builder.md +9 -8
  59. package/docs/theming.md +108 -2
  60. package/docs/undo-redo.md +24 -16
  61. package/docs/views/agenda.md +14 -13
  62. package/docs/views/custom-views.md +13 -10
  63. package/docs/views/month.md +10 -9
  64. package/docs/views/resource-columns.md +21 -17
  65. package/docs/views/resource-timeline.md +16 -15
  66. package/docs/views/scrolling.md +7 -6
  67. package/docs/views/week-and-day.md +15 -14
  68. package/docs/views/year.md +11 -11
  69. package/docs/views.md +1 -1
  70. package/package.json +7 -6
  71. package/skills/moltenship-time/SKILL.md +7 -5
  72. package/skills/moltenship-time/references/compose.md +13 -6
  73. package/skills/moltenship-time/references/mistakes.md +4 -2
  74. package/skills/moltenship-time/references/solid.md +36 -25
  75. package/docs/api/solid.md +0 -460
@@ -1,8 +1,8 @@
1
- # React components and hooks
1
+ # Components and hooks
2
2
 
3
- createCalendar, Root and its props, the components, hooks, meta, and diagnostics.
3
+ createCalendar, Root and its props, the components, hooks, actions, meta, and diagnostics.
4
4
 
5
- Source: https://time.molten.sh/docs/api/react
5
+ Source: https://time.molten.sh/docs/react/api/components
6
6
 
7
7
  Everything on this page is exported from `@moltenship/calendar`.
8
8
 
@@ -24,7 +24,7 @@ from `views` and the ID types from the adapter.
24
24
 
25
25
  | Name | Type | Default | Description |
26
26
  | -------------------- | ------------------------------ | ------------------- | ------------------------------------------------------------------------------------------ |
27
- | `eventAdapter` | `EventAdapter<TEvent>` | | Required. How to read your records. See [adapter](./events.md#adapter). |
27
+ | `eventAdapter` | `EventAdapter<TEvent>` | | Required. How to read your records. See [adapter](./events.md#adapter). |
28
28
  | `views` | `readonly CalendarView[]` | | Views made with `defineCalendarView`. The first is the default view. Names must be unique. |
29
29
  | `invalidEventPolicy` | `"report-and-skip" \| "throw"` | `"report-and-skip"` | What to do with invalid records. |
30
30
 
@@ -44,7 +44,7 @@ Renderer props. The related types are `CalendarViewStrategy`, `CalendarViewProje
44
44
 
45
45
  `resolveViewInstantRange(range, timeZone)` turns visible dates into the instant range that `Root`
46
46
  passes to `project` as `instantRange`, and `resolveViewLoadRange(strategy, anchor, environment,
47
- options, range)` gives the `loadRange` it passes. Use them to run a strategy outside React, for
47
+ options, range)` gives the `loadRange` it passes. Use them to run a strategy outside `Root`, for
48
48
  example in a test.
49
49
 
50
50
  `withAsciiSpaces(text)` writes the thin and narrow no-break spaces in `Intl` output as plain spaces.
@@ -56,41 +56,41 @@ the server, as the built-in titles and views do, and hydration matches.
56
56
  `<Calendar.Root>` holds the state and provides it to everything inside. It renders no element of its
57
57
  own.
58
58
 
59
- | Name | Type | Default | Description |
60
- | -------------------------------------------------- | ------------------------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
- | `events` | `readonly TEvent[] \| CalendarEventSource<TEvent>` | | Required. Your events. A new array holding the same records is treated as unchanged. A source is an external store `Root` subscribes to; see [events from an external store](../concepts/events.md#events-from-an-external-store). |
62
- | `locale` | `Intl.Locale \| string` | | Required. Used by views to format dates and times. |
63
- | `weekRules` | `CalendarWeekRules` | | Required. `{ firstDay, minimalDays, weekend }`, with days numbered 1 (Monday) to 7 (Sunday). `minimalDays` is the minimum number of days in the first week of a year. |
64
- | `defaultAnchorDate` | `Temporal.PlainDate` | | Initial date, uncontrolled. Pass this or `anchorDate`. |
65
- | `anchorDate` | `Temporal.PlainDate` | | Controlled date. |
66
- | `defaultTimeZone` | `string` | | Initial IANA time zone, uncontrolled. Pass this or `timeZone`. |
67
- | `timeZone` | `string` | | Controlled time zone. |
68
- | `secondaryTimeZones` | `readonly (string \| { timeZone: string; label?: string })[]` | `[]` | Other IANA time zones that time grids label their hours in, beside the calendar's. A `label` names a zone in the header. Invalid entries are left out and reported as diagnostics. See [secondary time zones](../concepts/time.md#secondary-time-zones). |
69
- | `defaultView` | `view name` | `the first registered view` | Initial view, uncontrolled. |
70
- | `view` | `view name` | | Controlled view. |
71
- | `viewOptions` | `{ [view]: Partial<options> }` | | Overrides for each view's `defaultOptions`, keyed by view name. |
72
- | `defaultSelection / selection` | `TSelection \| null` | | Uncontrolled or controlled selection. |
73
- | `defaultFocus / focus` | `TFocus \| null` | | Uncontrolled or controlled focus. |
74
- | `defaultExpandedResourceIds / expandedResourceIds` | `readonly TResourceId[]` | | Uncontrolled or controlled expanded resources. |
75
- | `onViewChange, onAnchorDateChange, …` | `(next, detail) => void` | | One handler per value. `detail` has `previous`, `controlled`, `slice`, why it changed (`reason`), who caused it (`source`, `"agent"` for an AI agent), the DOM `event` and `cancel()`. See [what a handler hears](../concepts/state.md#what-a-handler-hears). |
76
- | `onEventChange` | `(change, detail) => void \| Promise<void>` | | Saves a proposed change. Return a promise to keep it pending until it settles. Without it the calendar is read-only. `detail.input` says what proposed it, as for `onEventChangeResult`, and `detail.fields` has what an agent sent beside the times, such as a title. See [Interactions](../interactions.md) and [saving what an agent sent](../agents/connect.md#save-what-the-agent-sent). |
77
- | `onEventChangeResult` | `(result, detail) => void` | | Hears how each proposal ended, once it settles: the result `proposeEventChange` resolves with, and the detail it was proposed with, whose `input` is `"pointer"`, `"keyboard"`, `"api"` or `"agent"`. Pass an event history's `record` here to [undo and redo](../undo-redo.md). See [how changes end](../interactions.md#how-changes-end). |
78
- | `policies` | `readonly CalendarPolicy[]` | | Run in order on every proposed change, after the built-in read-only check. See [policies](./changes.md#policies). |
79
- | `resources` | `readonly TResource[]` | `[]` | Rooms, people, or anything else events are assigned to. |
80
- | `availability` | `CalendarAvailability` | | Working hours: `weekly` rules, dated `exceptions`, and an optional `timeZone`. Views shade the closed time. See [Availability](../availability.md). |
81
- | `annotations` | `readonly CalendarAnnotation[]` | `[]` | Read-only marks beside the events, such as sleep or music. See [Annotations](../annotations.md). |
82
- | `annotationSources` | `readonly CalendarAnnotationSource[]` | `[]` | The annotation sources, in display order. A source left out is hidden. |
83
- | `now` | `Temporal.Instant` | | Fixes the current time, so server and browser agree. Pass `now` or `clock`, not both. |
84
- | `clock` | `{ instant(): Temporal.Instant }` | | A source of the current time. Without now or clock, Time uses the system clock. |
85
- | `direction` | `"ltr" \| "rtl"` | `"ltr"` | Which way the arrow keys move, and which way the resource and scrolling views scroll sideways; the resource timeline and scrolling week and day also set `dir` on their grid from it. `Root` doesn't set `dir` itself: set it on an ancestor to match; see [right-to-left](../accessibility.md#right-to-left). |
86
- | `disambiguation` | `"compatible" \| "earlier" \| "later" \| "reject"` | `"compatible"` | Given to views as `environment.disambiguation`, for your own views to resolve skipped or repeated wall-clock times, and used for the wall-clock times an [agent](../agents/reference.md#events) sends. The built-in views and interactions don't read it. See [daylight saving time](../concepts/time.md#daylight-saving-time). |
87
- | `onVisibleRangeChange` | `(range: CalendarVisibleRange) => void` | | Called after mount and whenever the active view, its dates, or the time zone change, with the visible `range` and the `loadRange` to have events for. Each change is reported once, also under Strict Mode or when a hidden `Activity` is revealed, and never on the server. See [loading events](../views/scrolling.md#loading-events-as-you-scroll) and [TanStack Query](../guides/tanstack-query.md). |
88
- | `onDiagnosticsChange` | `(diagnostics) => void` | | Called after mount and whenever the [diagnostics](#diagnostics) change. |
89
- | `id` | `string` | `derived from useId()` | Base for element IDs, such as `{id}-frame`. |
90
- | `label` | `string` | | The calendar's name, such as `"Team calendar"`. `Frame` takes it as its `aria-label`, so screen readers and [AI agents](../agents/connect.md#name-the-calendar) find the calendar by a name that stays the same while it navigates. Without it, the frame is labelled by the title. |
91
- | `allowAgentDelete` | `boolean` | `false` | Gives an AI agent the `deleteEvent` action. Without it the calendar has no such action, a step that asks for it fails, and a delete an agent causes another way, such as by pressing a button of yours, is refused. Turn it on only with an agent bridge that asks a person first. See [Deleting](../agents/deleting.md). |
92
- | `formatAgentEventLabel` | `(event: CalendarAgentEvent) => string` | | Names each visible event in the list an AI agent reads. By default the title and the times in ISO 8601 in the calendar's time zone. See the [agent reference](../agents/reference.md#snapshot-entry). |
93
- | `store` | `CalendarStore` | | Use a store you created. See [State store](./store.md). |
59
+ | Name | Type | Default | Description |
60
+ | -------------------------------------------------- | ------------------------------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
+ | `events` | `readonly TEvent[] \| CalendarEventSource<TEvent>` | | Required. Your events. A new array holding the same records is treated as unchanged. A source is an external store `Root` subscribes to; see [events from an external store](../concepts/events.md#events-from-an-external-store). |
62
+ | `locale` | `Intl.Locale \| string` | | Required. Used by views to format dates and times. |
63
+ | `weekRules` | `CalendarWeekRules` | | Required. `{ firstDay, minimalDays, weekend }`, with days numbered 1 (Monday) to 7 (Sunday). `minimalDays` is the minimum number of days in the first week of a year. |
64
+ | `defaultAnchorDate` | `Temporal.PlainDate` | | Initial date, uncontrolled. Pass this or `anchorDate`. |
65
+ | `anchorDate` | `Temporal.PlainDate` | | Controlled date. |
66
+ | `defaultTimeZone` | `string` | | Initial IANA time zone, uncontrolled. Pass this or `timeZone`. |
67
+ | `timeZone` | `string` | | Controlled time zone. |
68
+ | `secondaryTimeZones` | `readonly (string \| { timeZone: string; label?: string })[]` | `[]` | Other IANA time zones that time grids label their hours in, beside the calendar's. A `label` names a zone in the header. Invalid entries are left out and reported as diagnostics. See [secondary time zones](../concepts/time.md#secondary-time-zones). |
69
+ | `defaultView` | `view name` | `the first registered view` | Initial view, uncontrolled. |
70
+ | `view` | `view name` | | Controlled view. |
71
+ | `viewOptions` | `{ [view]: Partial<options> }` | | Overrides for each view's `defaultOptions`, keyed by view name. |
72
+ | `defaultSelection / selection` | `TSelection \| null` | | Uncontrolled or controlled selection. |
73
+ | `defaultFocus / focus` | `TFocus \| null` | | Uncontrolled or controlled focus. |
74
+ | `defaultExpandedResourceIds / expandedResourceIds` | `readonly TResourceId[]` | | Uncontrolled or controlled expanded resources. |
75
+ | `onViewChange, onAnchorDateChange, …` | `(next, detail) => void` | | One handler per value. `detail` has `previous`, `controlled`, `slice`, why it changed (`reason`), who caused it (`source`, `"agent"` for an AI agent), the DOM `event` and `cancel()`. See [what a handler hears](../concepts/state.md#what-a-handler-hears). |
76
+ | `onEventChange` | `(change, detail) => void \| Promise<void>` | | Saves a proposed change. Return a promise to keep it pending until it settles. Without it the calendar is read-only. `detail.input` says what proposed it, as for `onEventChangeResult`, and `detail.fields` has what an agent sent beside the times, such as a title. See [Interactions](../interactions.md) and [saving what an agent sent](../agents/connect.md#save-what-the-agent-sent). |
77
+ | `onEventChangeResult` | `(result, detail) => void` | | Hears how each proposal ended, once it settles: the result `proposeEventChange` resolves with, and the detail it was proposed with, whose `input` is `"pointer"`, `"keyboard"`, `"api"` or `"agent"`. Pass an event history's `record` here to [undo and redo](../undo-redo.md). See [how changes end](../interactions.md#how-changes-end). |
78
+ | `policies` | `readonly CalendarPolicy[]` | | Run in order on every proposed change, after the built-in read-only check. See [policies](./changes.md#policies). |
79
+ | `resources` | `readonly TResource[]` | `[]` | Rooms, people, or anything else events are assigned to. |
80
+ | `availability` | `CalendarAvailability` | | Working hours: `weekly` rules, dated `exceptions`, and an optional `timeZone`. Views shade the closed time. See [Availability](../availability.md). |
81
+ | `annotations` | `readonly CalendarAnnotation[]` | `[]` | Read-only marks beside the events, such as sleep or music. See [Annotations](../annotations.md). |
82
+ | `annotationSources` | `readonly CalendarAnnotationSource[]` | `[]` | The annotation sources, in display order. A source left out is hidden. |
83
+ | `now` | `Temporal.Instant` | | Fixes the current time, so server and browser agree. Pass `now` or `clock`, not both. |
84
+ | `clock` | `{ instant(): Temporal.Instant }` | | A source of the current time. Without now or clock, Time uses the system clock. |
85
+ | `direction` | `"ltr" \| "rtl"` | `"ltr"` | Which way the arrow keys move. A view gets it as `environment.direction`, to scroll sideways and to set `dir` on its grid by it. `Root` doesn't set `dir` itself: set it on an ancestor to match; see [right-to-left](../accessibility.md#right-to-left). |
86
+ | `disambiguation` | `"compatible" \| "earlier" \| "later" \| "reject"` | `"compatible"` | Given to views as `environment.disambiguation`, for your own views to resolve skipped or repeated wall-clock times, and used for the wall-clock times an [agent](../agents/reference.md#events) sends. The registry's views, the pointer and the keyboard don't read it. See [daylight saving time](../concepts/time.md#daylight-saving-time). |
87
+ | `onVisibleRangeChange` | `(range: CalendarVisibleRange) => void` | | Called after mount and whenever the active view, its dates, or the time zone change, with the visible `range` and the `loadRange` to have events for. Each change is reported once, and never on the server. |
88
+ | `onDiagnosticsChange` | `(diagnostics) => void` | | Called after mount and whenever the [diagnostics](#diagnostics) change. |
89
+ | `id` | `string` | `a generated ID` | Base for element IDs, such as `{id}-frame`. |
90
+ | `label` | `string` | | The calendar's name, such as `"Team calendar"`. `Frame` takes it as its `aria-label`, so screen readers and [AI agents](../agents/connect.md#name-the-calendar) find the calendar by a name that stays the same while it navigates. Without it, the frame is labelled by the title. |
91
+ | `allowAgentDelete` | `boolean` | `false` | Gives an AI agent the `deleteEvent` action. Without it the calendar has no such action, a step that asks for it fails, and a delete an agent causes another way, such as by pressing a button of yours, is refused. Turn it on only with an agent bridge that asks a person first. See [Deleting](../agents/deleting.md). |
92
+ | `formatAgentEventLabel` | `(event: CalendarAgentEvent) => string` | | Names each visible event in the list an AI agent reads. By default the title and the times in ISO 8601 in the calendar's time zone. See the [agent reference](../agents/reference.md#snapshot-entry). |
93
+ | `store` | `CalendarStore` | | Use a store you created. See [State store](./store.md). |
94
94
 
95
95
  You can write most props inline. `locale`, `weekRules`, `secondaryTimeZones`, `availability`, `now`,
96
96
  and a controlled `anchorDate`, `timeZone` or `view` are compared by value; `events`, `resources`,
@@ -101,6 +101,10 @@ functions and objects in them stable. A
101
101
  `clock` object and a controlled `selection` or `focus` are compared by identity: keep them stable,
102
102
  for example in state or at module scope.
103
103
 
104
+ `onVisibleRangeChange` reports each change once under Strict Mode too, and when a hidden `Activity`
105
+ is revealed. See [loading events](../views/scrolling.md#loading-events-as-you-scroll) and
106
+ [TanStack Query](../guides/tanstack-query.md).
107
+
104
108
  `Root` throws on its first render if it has no date (`calendar-root-requires-anchor-date`), no
105
109
  time zone (`calendar-root-requires-time-zone`), or no view (`calendar-root-requires-view`).
106
110
 
@@ -109,19 +113,19 @@ time zone (`calendar-root-requires-time-zone`), or no view (`calendar-root-requi
109
113
  Use these inside `Root`. Each renders one plain element with a `data-calendar-part` attribute and
110
114
  accepts that element's usual props, including `className`, `style`, `ref`, and event handlers.
111
115
 
112
- | Component | Renders | Notes |
113
- | ----------------- | ----------- | ----------------------------------------------------------------------------------------- |
114
- | `Frame` | `<section>` | Outer wrapper. Gets the `{id}-frame` ID, and its name from `Root`'s `label` or the title. |
115
- | `Toolbar` | `<header>` | Wrapper for controls. |
116
- | `Title` | `<span>` | The active view's title, or its children. Gets the `{id}-title` ID. |
117
- | `PreviousTrigger` | `<button>` | Moves back one step of the active view. Disabled when no view is active. |
118
- | `NextTrigger` | `<button>` | Moves forward one step of the active view. Disabled when no view is active. |
119
- | `TodayTrigger` | `<button>` | Moves to today in the calendar's time zone, from `now`, `clock`, or the system clock. |
120
- | `ViewSwitcher` | `<select>` | One option per view. Requires `getViewLabel(name)`. |
121
- | `Viewport` | `<div>` | Wrapper for the view. Gets the `{id}-viewport` ID. |
122
- | `ActiveView` | view output | Renders the active view, or `fallback` if it isn't registered. |
123
- | `Event` | your output | Looks up one event by `eventId` and calls `children` with it. |
124
- | `Announcer` | `<div>` | A hidden live region that speaks moves, resizes, and creates. Requires `messages`. |
116
+ | Component | Renders | Notes |
117
+ | ----------------- | ----------- | -------------------------------------------------------------------------------------------- |
118
+ | `Frame` | `<section>` | Outer wrapper. Gets the `{id}-frame` ID, and its name from `Root`'s `label` or the title. |
119
+ | `Toolbar` | `<header>` | Wrapper for controls. |
120
+ | `Title` | `<span>` | The active view's title, or its children. Gets the `{id}-title` ID. |
121
+ | `PreviousTrigger` | `<button>` | Moves back one step of the active view. Disabled when no view is active. |
122
+ | `NextTrigger` | `<button>` | Moves forward one step of the active view. Disabled when no view is active. |
123
+ | `TodayTrigger` | `<button>` | Moves to today in the calendar's time zone, from `now`, `clock`, or the system clock. |
124
+ | `ViewSwitcher` | `<select>` | One option per view. Requires `getViewLabel(name)`. |
125
+ | `Viewport` | `<div>` | Wrapper for the view. Gets the `{id}-viewport` ID. |
126
+ | `ActiveView` | view output | Renders the active view, or `fallback` if it isn't registered. |
127
+ | `Event` | your output | Looks up one event by `eventId` and calls `children` with it. |
128
+ | `Announcer` | `<div>` | A hidden live region that speaks moves, resizes, and creates. Requires `messages`. |
125
129
 
126
130
  - The buttons default to `type="button"` and set `aria-controls` to the viewport. Give each one
127
131
  text or an `aria-label`.
@@ -156,7 +160,7 @@ outside `Root` throws `calendar-hook-outside-root`.
156
160
  | `useCalendarState()` | The six [state](../concepts/state.md) values |
157
161
  | `useCalendarActions()` | The actions below. The object never changes. |
158
162
  | `useCalendarMeta()` | The [meta](#meta) object |
159
- | `useCalendarSelector(selector, opts?)` | `selector(state)`. Re-renders only when it changes. |
163
+ | `useCalendarSelector(selector, opts?)` | `selector(state)`. Re-renders only when it changes. |
160
164
  | `useCalendarPendingChanges(selector?, opts?)` | The changes still on their way, or `selector(changes)`. See [pending changes](../interactions.md#across-the-calendar). |
161
165
  | `useVisibleRange()` | The active view's visible dates, or `null` |
162
166
  | `useViewProjection()` | The active view and its projection, or `null` |
@@ -166,9 +170,14 @@ outside `Root` throws `calendar-hook-outside-root`.
166
170
 
167
171
  `useCalendarHistory(history, { messages? })` is exported on its own too. It binds an event history
168
172
  to the nearest `Root`, with `undo`, `redo`, `canUndo` and `canRedo`, and
169
- `useCalendarHistoryShortcuts(history, { scope, undo?, redo?, disabled? })` adds its keys; see
173
+ `useCalendarHistoryShortcuts(history, options)` adds its keys, with the options `scope`, `undo`,
174
+ `redo` and `disabled`; see
170
175
  [Undo and redo](../undo-redo.md).
171
176
 
177
+ `useCalendarPointer(options)` is exported on its own too. It returns the ref that turns drags in
178
+ a custom view into proposals; see the [pointer layer](./changes.md#pointer-layer). It's in
179
+ `@moltenship/calendar-react` from 2.0 on, and was in `@moltenship/calendar-dnd` in 1.x.
180
+
172
181
  `Announcer`'s messages, and the keyboard hooks for your own views (`useCalendarKeyboard`,
173
182
  `useRovingFocus`, `useCalendarInteraction`, `useCalendarAnnouncer`), are covered in
174
183
  [Accessibility](../accessibility.md#announcements).
@@ -211,7 +220,7 @@ first, so `navigateNext(); navigateNext()` moves two steps, even for controlled
211
220
 
212
221
  | Name | Type | Description |
213
222
  | --------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
214
- | `eventSnapshot` | `EventSnapshot` | Validated, indexed events. See [snapshots](./events.md#snapshots). |
223
+ | `eventSnapshot` | `EventSnapshot` | Validated, indexed events. See [snapshots](./events.md#snapshots). |
215
224
  | `resources` | `readonly TResource[]` | The resources prop. |
216
225
  | `environment` | `CalendarEnvironment` | `locale`, `timeZone`, `secondaryTimeZones`, `weekRules`, `direction`, `disambiguation`, and `now` or `clock` when set. |
217
226
  | `activeView` | `CalendarView \| undefined` | The active view's definition, if it's registered. |
@@ -2,7 +2,7 @@
2
2
 
3
3
  Drag your own dnd-kit items into the calendar, and calendar events out to your droppables, with @moltenship/calendar-dnd-kit.
4
4
 
5
- Source: https://time.molten.sh/docs/api/dnd-kit
5
+ Source: https://time.molten.sh/docs/react/api/dnd-kit
6
6
 
7
7
  `@moltenship/calendar-dnd-kit` connects the calendar to [dnd-kit](https://dndkit.com), for apps
8
8
  that already use it:
@@ -23,8 +23,6 @@ the pointer layer: see [drags from and to the rest of the page](./changes.md#dra
23
23
 
24
24
  ## Install
25
25
 
26
- Like the calendar, `@moltenship/calendar-dnd-kit` is on npm as a release candidate for 1.0.0.
27
-
28
26
  **pnpm**
29
27
 
30
28
  ```bash
@@ -2,9 +2,10 @@
2
2
 
3
3
  Adapters, event ranges, validation, snapshots, and queries.
4
4
 
5
- Source: https://time.molten.sh/docs/api/events
5
+ Source: https://time.molten.sh/docs/react/api/events
6
6
 
7
- Exported from `@moltenship/calendar` and from `@moltenship/calendar-core`.
7
+ Exported from `@moltenship/calendar` and from
8
+ `@moltenship/calendar-core`.
8
9
 
9
10
  ## Adapter
10
11
 
@@ -15,14 +16,14 @@ const eventAdapter = defineEventAdapter<TEvent>()({ getId, getTitle, getInterval
15
16
  `defineEventAdapter` returns your adapter unchanged. The two calls let TypeScript fix `TEvent` first
16
17
  and then infer the ID types from `getId` and `getResourceIds`.
17
18
 
18
- | Name | Type | Default | Description |
19
- | ---------------- | ------------------------------------------ | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
- | `getId` | `(event) => string \| number` | | Required. A unique ID: a non-empty string or a finite number. |
21
- | `getTitle` | `(event) => string` | | Required. The display title. |
22
- | `getInterval` | `(event) => CalendarEventInterval` | | Required. When the event happens. See [ranges](#ranges). |
23
- | `getResourceIds` | `(event) => readonly (string \| number)[]` | | Required. The resources the event belongs to. Return `[]` for none. |
24
- | `getRevision` | `(event) => string \| number` | | Changes whenever the record changes. Lets Time reuse work for unchanged records after a refetch. |
25
- | `isReadOnly` | `(event) => boolean` | `false` | Marks events users can't change. Exposed as `isReadOnly` on normalized events. |
19
+ | Name | Type | Default | Description |
20
+ | ---------------- | ------------------------------------------ | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
21
+ | `getId` | `(event) => string \| number` | | Required. A unique ID: a non-empty string or a finite number. |
22
+ | `getTitle` | `(event) => string` | | Required. The display title. |
23
+ | `getInterval` | `(event) => CalendarEventInterval` | | Required. When the event happens. See [ranges](#ranges). |
24
+ | `getResourceIds` | `(event) => readonly (string \| number)[]` | | Required. The resources the event belongs to. Return `[]` for none. |
25
+ | `getRevision` | `(event) => string \| number` | | Changes whenever the record changes. Lets Time reuse work for unchanged records after a refetch. |
26
+ | `isReadOnly` | `(event) => boolean` | `false` | Marks events users can't change. Exposed as `isReadOnly` on normalized events. |
26
27
  | `isBusy` | `(event) => boolean` | `timed and floating events are busy; all-day events are free` | Whether the event makes its resources busy, as "show as busy" or "free" does. Exposed as `isBusy` on normalized events. See [busy or available](../availability.md#busy-or-available). |
27
28
 
28
29
  `createCanonicalEventAdapter()` returns an adapter for records already in Time's `CalendarEvent`
@@ -125,7 +126,7 @@ snapshot.get("meeting-1");
125
126
  - Each query returns the events of one kind that overlap the range. Ranges are end-exclusive on both
126
127
  sides, so an event ending exactly at the range start isn't included.
127
128
  - Build ranges with `instantInterval`, `plainDateInterval`, and `plainDateTimeInterval` from
128
- the [Temporal helpers](./temporal.md#ranges).
129
+ the [Temporal helpers](../temporal/reference.md#ranges).
129
130
  - `resourceIds` keeps events assigned to any of the listed resources. An empty list matches nothing.
130
131
  - Results are frozen and in input order. Repeating a query returns the same array while it's in the
131
132
  cache.
@@ -133,8 +134,8 @@ snapshot.get("meeting-1");
133
134
  ## Invalid records
134
135
 
135
136
  With the default policy, invalid records are left out of the snapshot and listed in
136
- `snapshot.issues`. In React they also appear as `invalid-event` [diagnostics](./react.md#diagnostics).
137
- Each issue has the `event`, its `index` in your array, a `code`, and when known the `eventId`, the
137
+ `snapshot.issues`. In a calendar they also appear as `invalid-event`
138
+ [diagnostics](./components.md#diagnostics). Each issue has the `event`, its `index` in your array, a `code`, and when known the `eventId`, the
138
139
  adapter function that failed (`accessor`), the position of a bad resource ID (`resourceIndex`), and a
139
140
  `message`.
140
141
 
@@ -2,18 +2,15 @@
2
2
 
3
3
  The framework-free layer under the React and Solid integrations, the calendar as a ui-sdk primitive, and the types of its agent actions.
4
4
 
5
- Source: https://time.molten.sh/docs/api/primitives
5
+ Source: https://time.molten.sh/docs/react/api/primitives
6
6
 
7
7
  `@moltenship/calendar-primitives` is the layer between the engine and a framework. It holds what
8
8
  `Root` does, with no React or Solid in it: the state store, the runtime that turns events and state
9
9
  into what a view draws, and the calendar as a [ui-sdk](https://ui-sdk.dev) primitive, which is what
10
10
  an [agent](../agents.md) operates.
11
11
 
12
- > **Unsettled API**
13
- >
14
- > This package is new in 2.0 and its API can change in any release before 2.0.0. Apps don't need it:
15
- > `@moltenship/calendar` re-exports the parts an app uses. Install it to write an integration for
16
- > another framework, or to name the agent types below.
12
+ Apps don't need it: your framework's package exports the parts an app uses. Install it to write an
13
+ integration for another framework, or to name the agent types below.
17
14
 
18
15
  ## Install
19
16
 
@@ -41,7 +38,7 @@ recurrence, layouts, transactions and policies are the calendar's own.
41
38
 
42
39
  | Export | What it is |
43
40
  | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
44
- | `createCalendarStore(options)` | The store of the six state values. The same one [`@moltenship/calendar` exports](./store.md) |
41
+ | `createCalendarStore(options)` | The store of the six state values. The same one [your framework's package exports](./store.md) |
45
42
  | `createCalendarRuntime(config)` | What `Root` runs: event snapshots, pending changes, the active view's projection, the visible range, diagnostics |
46
43
  | `createCalendarPrimitive({ views })` | The calendar as a ui-sdk primitive: the six values as controlled keys, slots for the parts, and the agent actions |
47
44
  | `calendarAgentActions` | The fifteen action names an agent can call |
@@ -68,7 +65,7 @@ integration renders it with its framework's ui-sdk package, `@ui-sdk/react` or `
68
65
 
69
66
  Its slots are the calendar's structural parts:
70
67
 
71
- | Slot | The part in React |
68
+ | Slot | The part |
72
69
  | ------------------ | -------------------------- |
73
70
  | `root` | `Calendar.Frame` |
74
71
  | `toolbar` | `Calendar.Toolbar` |
@@ -149,9 +146,61 @@ The [agent reference](../agents/reference.md) has every input, result and error.
149
146
  An app doesn't call these methods. An agent calls them by name through the bridge, where your
150
147
  `allow` decides first.
151
148
 
149
+ ## Interaction
150
+
151
+ The keyboard, roving focus, drafts, the history binding and the announcer are written once, here.
152
+ An integration binds each in a few lines, with three shapes:
153
+
154
+ - **Stores** have `subscribe` and `getSnapshot`, and `getServerSnapshot` when the server reads
155
+ something else. React reads them with `useSyncExternalStore`, Solid with a store selector.
156
+ - **Element listeners** take the element and a getter for the latest options, and return a
157
+ cleanup, as `attachCalendarPointer(element, () => options)` does. The getter is read whenever an
158
+ event arrives, so new options never re-attach anything.
159
+ - **Queries** are memoized functions an integration calls while it renders, as often as it renders.
160
+
161
+ Most take the root's interaction runtime, `model.interaction` from `runtime.derive`, or the few
162
+ fields of it they use.
163
+
164
+ | Export | What it is |
165
+ | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
166
+ | `createCalendarViewRuntime(getView)` | One rendered active view: `getView` reads the latest view, and `roving` is its roving focus store. Keep it on the root's focus with `roving.update(focus, calendarViewEntry(view))` after each render |
167
+ | `calendarViewEntry(view)` | Where focus enters a view, from its spatial navigation |
168
+ | `focusRovingTarget(interaction, target, days, event)` | What a cell or event does when it takes DOM focus itself: it becomes the calendar's focus |
169
+ | `calendarFocusKey(target)` | A key for a focus target, which changes exactly when the target does |
170
+ | `createCalendarKeyboard(interaction, viewRuntime, getOptions, getResources)` | A view's keyboard: `keyDown(event, wrapper?)` and `focusOut(event, region)` for the element around its cells. `wrapper` is the framework's own event, when it wraps DOM events as React does. Bind `keydown` on that element itself (`addEventListener` from a ref in Solid): a handler delegated to the document stops Escape too late |
171
+ | `interaction.draft` | A store of the change being drafted: the keyboard's session while there is one, else the pointer's draft |
172
+ | `createBusyResourcesQuery()`, `createDraftBusyQuery()` | Queries for the resources busy in a range, and for one resource during the draft |
173
+ | `bindCalendarHistory(interaction, history, getOptions)` | An event history bound to a root, as a store of `{ undo, redo, canUndo, canRedo, … }` |
174
+ | `attachCalendarHistoryShortcuts(interaction, getConfig)` | The undo and redo keys, a `keydown` listener on the document for keys inside `scope`; returns a cleanup |
175
+ | `createAnnouncerLiveText()` | A live region's text as a store. Pass its `speak` to `interaction.announcements.mount` and render the snapshot |
176
+ | `subscribeAnchorDateRequests(interaction, listener)` | Hears every date the root is asked to show, with the range the active view shows for it |
177
+ | `createResourceExpansionCommands(interaction, resourceId)` | `expand`, `collapse` and `toggle` for one resource of a tree |
178
+ | `createResourceStatusClock(source, compute)` | A store of a status that depends on the time, such as whether a resource is open now, sampled on `source`'s clock once a minute while subscribed, and `null` on the server. Only the clock is read: when `source.now` is fixed, compute at it yourself |
179
+
180
+ A view that unmounts mid-gesture leaves nothing grabbed when its integration calls
181
+ `interaction.keyboard.set(null)` on unmount. Its React binding, `useCalendarKeyboard`, is this:
182
+
183
+ ```ts title="keyboard.ts"
184
+ const keyboard = useMemo(
185
+ () =>
186
+ createCalendarKeyboard(
187
+ interaction,
188
+ view,
189
+ () => latest.current.options,
190
+ () => latest.current.resources,
191
+ ),
192
+ [interaction, view],
193
+ );
194
+ useEffect(() => () => interaction.keyboard.set(null), [interaction.keyboard]);
195
+ return {
196
+ onBlur: (event) => keyboard.focusOut(event.nativeEvent, event.currentTarget),
197
+ onKeyDown: (event) => keyboard.keyDown(event.nativeEvent, event),
198
+ };
199
+ ```
200
+
152
201
  ## Writing an integration
153
202
 
154
- `@moltenship/calendar-solid` is the model to read: it's the smaller of the two. An integration
203
+ `@moltenship/calendar-solid` is the model to read: it binds everything React's does, in less code. An integration
155
204
  does four things:
156
205
 
157
206
  1. Creates the runtime and the primitive in its factory, as `createCalendar` does.
@@ -161,8 +210,9 @@ does four things:
161
210
  3. Renders the primitive's slots as parts through the framework's ui-sdk package.
162
211
  4. Passes the model to custom views and hooks through a context of its own.
163
212
 
164
- The keyboard session, the gesture drafts and the announcer channel are shared from here as stores
165
- and plain functions. The pointer layer is `@moltenship/calendar-dnd`.
213
+ The interaction below is shared from here as stores and plain functions. The pointer layer is
214
+ `@moltenship/calendar-dnd`, which imports no framework either: bind `attachCalendarPointer` as
215
+ `useCalendarPointer` does in both integrations.
166
216
 
167
217
  There's no guide beyond this page yet, and the runtime's types change as the Solid integration
168
218
  grows. If you plan an integration, open an issue first.
package/docs/api/store.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Create calendar state outside Root, and change it from anywhere in your app.
4
4
 
5
- Source: https://time.molten.sh/docs/api/store
5
+ Source: https://time.molten.sh/docs/react/api/store
6
6
 
7
7
  `Root` creates a store for its [state](../concepts/state.md) automatically. Create one yourself when
8
8
  code outside `Root` needs to change the calendar, or when the state should survive `Root`
9
- unmounting. Everything here is exported from `@moltenship/calendar`. The store has no framework in
10
- it: `@moltenship/calendar-solid` exports the same `createCalendarStore`.
9
+ unmounting. Everything here is exported from `@moltenship/calendar`. The store has no
10
+ framework in it: `@moltenship/calendar-solid` exports the same `createCalendarStore`.
11
11
 
12
12
  ## createCalendarStore
13
13
 
package/docs/api.md CHANGED
@@ -2,26 +2,26 @@
2
2
 
3
3
  What each package exports, and where to import it from.
4
4
 
5
- Source: https://time.molten.sh/docs/api
5
+ Source: https://time.molten.sh/docs/react/api
6
6
 
7
- Import from `@moltenship/calendar`. It includes the React components and hooks, the event engine,
8
- the Temporal helpers, and the pointer interactions, so one import line covers the calendar:
7
+ In a React app, import from `@moltenship/calendar`. It includes the React components and hooks,
8
+ the event engine, the Temporal helpers, and the pointer interactions, so one import line covers the
9
+ calendar:
9
10
 
10
11
  ```ts
11
12
  import { createCalendar, defineCalendarView, plainDateInterval } from "@moltenship/calendar";
12
13
  ```
13
14
 
14
- - [React components and hooks](./api/react.md): createCalendar, Root and its props, components, hooks, meta, diagnostics.
15
+ - [Components and hooks](./api/components.md): createCalendar, Root and its props, components, hooks, meta, diagnostics.
15
16
  - [Events and snapshots](./api/events.md): Adapters, ranges, validation, snapshots, and queries.
16
17
  - [Event changes](./api/changes.md): Proposals, changes, policies, placement helpers, and the pointer layer.
17
18
  - [State store](./api/store.md): Calendar state without Root, and sharing a store with Root.
18
- - [Temporal helpers](./api/temporal.md): Ranges, grids, rounding, day boundaries, and DST from calendar-temporal.
19
- - [iCalendar (ICS)](./api/ics.md): Parse ICS feeds and files into typed Temporal values. A separate package.
20
- - [Recurrence](./api/recurrence.md): Expand recurring series for the dates on screen, and edit them. A separate package.
19
+ - [Temporal helpers](./temporal/reference.md): Ranges, grids, rounding, day boundaries, and DST from calendar-temporal.
20
+ - [Primitives](./api/primitives.md): The calendar without a framework, for integrations. A separate package.
21
+ - [iCalendar (ICS)](./ics/reference.md): Parse ICS feeds and files into typed Temporal values. A separate package.
22
+ - [Recurrence](./recurrence/reference.md): Expand recurring series for the dates on screen, and edit them. A separate package.
21
23
  - [dnd-kit adapter](./api/dnd-kit.md): Drag your dnd-kit items into the calendar and events out. A separate package.
22
24
  - [Agent reference](./agents/reference.md): What a calendar tells an AI agent: snapshot fields, actions, arguments and errors.
23
- - [Primitives](./api/primitives.md): The calendar without a framework, for integrations. A separate package.
24
- - [Solid](./api/solid.md): The headless calendar for SolidJS 2, as a preview. A separate package.
25
25
 
26
26
  The iCalendar parser, `@moltenship/ics`, stands alone. `@moltenship/calendar` doesn't re-export it,
27
27
  so install it and import it by its own name. It doesn't need the calendar either.
@@ -35,23 +35,23 @@ into it. It's optional and not re-exported, so the calendar's install carries no
35
35
  Tests use `@moltenship/calendar-testing`, a development dependency: see [Testing](./testing.md).
36
36
 
37
37
  The agent bridge isn't the calendar's: `createAgent`, `agentTools` and `registerTools` come from
38
- `@ui-sdk/react/agent`, which your app imports itself. See [Agents](./agents.md).
38
+ `@ui-sdk/react/agent`, which your app imports itself. See [Agents in your app](./agents.md).
39
39
 
40
40
  ## Packages
41
41
 
42
- | Package | Contents | Dependencies |
43
- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
44
- | `@moltenship/calendar` | Re-exports `calendar-react`, `-core`, `-temporal` and `-dnd`. Ships these docs as Markdown and a skill for coding agents | Those four; React 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
45
- | `@moltenship/calendar-react` | `createCalendar`, `defineCalendarView`, components, hooks, store | `calendar-primitives`, `calendar-core`, `calendar-temporal`; React 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
46
- | `@moltenship/calendar-primitives` | The calendar's state, actions, runtime and agent surface, with no framework. Not re-exported. | `calendar-core`, `calendar-temporal`; `@ui-sdk/core` (peer) |
47
- | `@moltenship/calendar-solid` | `createCalendar`, `defineCalendarView`, parts and read hooks for SolidJS 2. A preview. Not re-exported. | `calendar-primitives`, `calendar-core`, `calendar-temporal`; `solid-js`, `@solidjs/web`, `@ui-sdk/core`, `@ui-sdk/solid` (peers) |
48
- | `@moltenship/calendar-core` | Adapters, validation, snapshots, queries, changes and policies, view strategies, availability. No React. | `calendar-temporal`, `@flatten-js/interval-tree` |
49
- | `@moltenship/calendar-temporal` | Ranges, grids, rounding, zoned days, DST | None |
50
- | `@moltenship/calendar-dnd` | Pointer drag, resize, and create for views | `calendar-core`, `calendar-temporal`; React 19 (peer) |
51
- | `@moltenship/ics` | iCalendar parsing into Temporal values. Not re-exported. | None |
52
- | `@moltenship/calendar-recurrence` | Series expansion, occurrence IDs, series edits. Not re-exported. | `calendar-core`, `calendar-temporal`, `ics` |
53
- | `@moltenship/calendar-dnd-kit` | dnd-kit items dragged in, events dragged out. Not re-exported. | `calendar-dnd`, `calendar-core`; React 19, dnd-kit 0.5 (peers) |
54
- | `@moltenship/calendar-testing` | A test harness for your calendar: fixed clock, builders, render and hydration. See [Testing](./testing.md). | `calendar`, `calendar-recurrence`; React and React DOM 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
42
+ | Package | Contents | Dependencies |
43
+ | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
44
+ | `@moltenship/calendar` | Re-exports `calendar-react`, `-core`, `-temporal` and `-dnd`. Since 2.0 it ships these docs as Markdown and a skill for coding agents | Those four; React 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
45
+ | `@moltenship/calendar-react` | `createCalendar`, `defineCalendarView`, components, hooks, store | `calendar-primitives`, `calendar-dnd`, `calendar-core`, `calendar-temporal`; React 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
46
+ | `@moltenship/calendar-primitives` | The calendar's state, actions and runtime, agent actions included, with no framework. Not re-exported. | `calendar-core`, `calendar-temporal`; `@ui-sdk/core` (peer) |
47
+ | `@moltenship/calendar-solid` | `createCalendar`, `defineCalendarView`, parts and hooks for SolidJS 2, and re-exports `-core`, `-temporal` and the pointer helpers of `-dnd`. Not re-exported. | `calendar-primitives`, `calendar-dnd`, `calendar-core`, `calendar-temporal`; `solid-js`, `@solidjs/web`, `@ui-sdk/core`, `@ui-sdk/solid` (peers) |
48
+ | `@moltenship/calendar-core` | Adapters, validation, snapshots, queries, changes and policies, view strategies, availability. No React. | `calendar-temporal`, `@flatten-js/interval-tree` |
49
+ | `@moltenship/calendar-temporal` | Ranges, grids, rounding, zoned days, DST | None |
50
+ | `@moltenship/calendar-dnd` | Pointer drag, resize, and create for views, with no framework | `calendar-core`, `calendar-temporal` |
51
+ | `@moltenship/ics` | iCalendar parsing into Temporal values. Not re-exported. | None |
52
+ | `@moltenship/calendar-recurrence` | Series expansion, occurrence IDs, series edits. Not re-exported. | `calendar-core`, `calendar-temporal`, `ics` |
53
+ | `@moltenship/calendar-dnd-kit` | dnd-kit items dragged in, events dragged out. Not re-exported. | `calendar-dnd`, `calendar-core`; React 19, dnd-kit 0.5 (peers) |
54
+ | `@moltenship/calendar-testing` | A test harness for a React calendar: fixed clock, builders, render and hydration | `calendar`, `calendar-recurrence`; React and React DOM 19, `@ui-sdk/core`, `@ui-sdk/react` (peers) |
55
55
 
56
56
  Every package is ESM only. Import from the package name: paths inside a package aren't part of the
57
57
  API.