@moltenship/calendar 1.0.0-rc.2 → 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.
- package/README.md +24 -4
- package/dist/index.d.mts +2 -2
- package/docs/accessibility.md +304 -0
- package/docs/agents/changes.md +449 -0
- package/docs/agents/coding-agents.md +117 -0
- package/docs/agents/connect.md +435 -0
- package/docs/agents/deleting.md +296 -0
- package/docs/agents/reference.md +512 -0
- package/docs/agents/server.md +317 -0
- package/docs/agents/webmcp.md +153 -0
- package/docs/agents.md +353 -0
- package/docs/annotations.md +196 -0
- package/docs/api/changes.md +248 -0
- package/docs/api/dnd-kit.md +267 -0
- package/docs/api/events.md +152 -0
- package/docs/api/ics.md +524 -0
- package/docs/api/primitives.md +168 -0
- package/docs/api/react.md +236 -0
- package/docs/api/recurrence.md +586 -0
- package/docs/api/solid.md +460 -0
- package/docs/api/store.md +92 -0
- package/docs/api/temporal.md +172 -0
- package/docs/api.md +57 -0
- package/docs/availability.md +573 -0
- package/docs/comparison.md +279 -0
- package/docs/concepts/anatomy.md +73 -0
- package/docs/concepts/events.md +164 -0
- package/docs/concepts/how-it-works.md +95 -0
- package/docs/concepts/recurrence.md +127 -0
- package/docs/concepts/state.md +244 -0
- package/docs/concepts/time.md +170 -0
- package/docs/guides/dnd-kit.md +333 -0
- package/docs/guides/google-calendar-sync.md +1246 -0
- package/docs/guides/google-calendar.md +367 -0
- package/docs/guides/ics.md +486 -0
- package/docs/guides/motion.md +414 -0
- package/docs/guides/nextjs-app-router.md +630 -0
- package/docs/guides/nextjs.md +149 -0
- package/docs/guides/performance.md +103 -0
- package/docs/guides/recurring-events.md +583 -0
- package/docs/guides/tanstack-query.md +485 -0
- package/docs/index.md +118 -0
- package/docs/installation.md +194 -0
- package/docs/interactions.md +408 -0
- package/docs/llms.txt +86 -0
- package/docs/migrating-to-2.md +322 -0
- package/docs/quick-start.md +159 -0
- package/docs/stylex.md +265 -0
- package/docs/testing.md +581 -0
- package/docs/theme-builder.md +81 -0
- package/docs/theming.md +169 -0
- package/docs/undo-redo.md +339 -0
- package/docs/views/agenda.md +221 -0
- package/docs/views/custom-views.md +192 -0
- package/docs/views/month.md +109 -0
- package/docs/views/resource-columns.md +261 -0
- package/docs/views/resource-timeline.md +225 -0
- package/docs/views/scrolling.md +192 -0
- package/docs/views/week-and-day.md +257 -0
- package/docs/views/year.md +138 -0
- package/docs/views.md +69 -0
- package/package.json +41 -14
- package/skills/moltenship-time/SKILL.md +75 -0
- package/skills/moltenship-time/references/agent-ready.md +272 -0
- package/skills/moltenship-time/references/changes.md +188 -0
- package/skills/moltenship-time/references/compose.md +168 -0
- package/skills/moltenship-time/references/mistakes.md +98 -0
- package/skills/moltenship-time/references/solid.md +202 -0
- package/skills/moltenship-time/references/state.md +129 -0
- package/skills/moltenship-time/references/testing.md +176 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Temporal helpers
|
|
2
|
+
|
|
3
|
+
Ranges, date and time grids, rounding, day boundaries, and DST from @moltenship/calendar-temporal.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/api/temporal
|
|
6
|
+
|
|
7
|
+
`@moltenship/calendar-temporal` has the date math that views need. `@moltenship/calendar` re-exports
|
|
8
|
+
all of it, so you can import these functions from either package:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { plainDateInterval, zonedDayRange } from "@moltenship/calendar";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The package on its own has no dependencies and no React, so it also works where React isn't
|
|
15
|
+
loaded.
|
|
16
|
+
|
|
17
|
+
Dates and times go in and out as native Temporal values. Apart from `createSystemClock`, nothing
|
|
18
|
+
reads the clock, and nothing reads the host time zone.
|
|
19
|
+
|
|
20
|
+
## Ranges
|
|
21
|
+
|
|
22
|
+
A range has a `start` and an `end`. The start is included and the end is excluded, and the start
|
|
23
|
+
must come before the end.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { plainDateInterval, plainDateIntervalContains } from "@moltenship/calendar-temporal";
|
|
27
|
+
|
|
28
|
+
const october = plainDateInterval(
|
|
29
|
+
Temporal.PlainDate.from("2026-10-01"),
|
|
30
|
+
Temporal.PlainDate.from("2026-11-01"),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
plainDateIntervalContains(october, Temporal.PlainDate.from("2026-10-31")); // true
|
|
34
|
+
plainDateIntervalContains(october, Temporal.PlainDate.from("2026-11-01")); // false
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`instantInterval`, `plainDateInterval`, and `plainDateTimeInterval` create frozen ranges and throw
|
|
38
|
+
`InvalidHalfOpenIntervalError` when the start isn't before the end. To get a result object instead
|
|
39
|
+
of an error, use `validateHalfOpenInterval`.
|
|
40
|
+
|
|
41
|
+
There's one function per operation and type:
|
|
42
|
+
|
|
43
|
+
| Operation | `Temporal.Instant` | `Temporal.PlainDate` | `Temporal.PlainDateTime` |
|
|
44
|
+
| ---------------- | --------------------------------- | ----------------------------------- | --------------------------------------- |
|
|
45
|
+
| Contains a point | `instantIntervalContains` | `plainDateIntervalContains` | `plainDateTimeIntervalContains` |
|
|
46
|
+
| Contains a range | `instantIntervalContainsInterval` | `plainDateIntervalContainsInterval` | `plainDateTimeIntervalContainsInterval` |
|
|
47
|
+
| Overlaps | `instantIntervalsIntersect` | `plainDateIntervalsIntersect` | `plainDateTimeIntervalsIntersect` |
|
|
48
|
+
| Overlapping part | `intersectInstantIntervals` | `intersectPlainDateIntervals` | `intersectPlainDateTimeIntervals` |
|
|
49
|
+
| Split at a point | `splitInstantInterval` | `splitPlainDateInterval` | `splitPlainDateTimeInterval` |
|
|
50
|
+
|
|
51
|
+
Ranges that only touch don't overlap. The overlapping part is `null` when there's no overlap.
|
|
52
|
+
Splitting returns two ranges when the point is strictly inside, and the original range otherwise.
|
|
53
|
+
|
|
54
|
+
`compareInstants`, `comparePlainDates`, `comparePlainDateTimes`, and `comparePlainTimes` are the
|
|
55
|
+
matching sort functions.
|
|
56
|
+
|
|
57
|
+
## Days, weeks, and months
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { iteratePlainDates, monthGrid, weekRange } from "@moltenship/calendar-temporal";
|
|
61
|
+
|
|
62
|
+
const date = Temporal.PlainDate.from("2026-10-08");
|
|
63
|
+
|
|
64
|
+
weekRange(date, { weekStartsOn: 1 }); // 2026-10-05 to 2026-10-12, Monday start
|
|
65
|
+
|
|
66
|
+
const grid = monthGrid(date, { weekStartsOn: 1 });
|
|
67
|
+
grid.weeks.length; // 5 weeks shown for October 2026
|
|
68
|
+
|
|
69
|
+
for (const day of iteratePlainDates(grid.range)) {
|
|
70
|
+
// every date in the visible grid, end excluded
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- `weekRange(date, { weekStartsOn })` returns the seven-day range containing `date`. `weekStartsOn`
|
|
75
|
+
is 1 (Monday) to 7 (Sunday).
|
|
76
|
+
- `monthGrid(date, options)` returns the month's first day (`month`), the full visible `range`, and
|
|
77
|
+
one range per week (`weeks`). It has four to six weeks; pass `fixedWeeks: true` for always six.
|
|
78
|
+
- `iteratePlainDates(range, { stepDays })` and `iterateInstants(range, { step })` step through a
|
|
79
|
+
range lazily. They throw a `RangeError` rather than yield more than 10,000 values; raise `limit` for
|
|
80
|
+
longer ranges.
|
|
81
|
+
|
|
82
|
+
## Rounding and snapping
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { snapPlainTime, snapZonedDateTime } from "@moltenship/calendar-temporal";
|
|
86
|
+
|
|
87
|
+
snapPlainTime(Temporal.PlainTime.from("23:50"), {
|
|
88
|
+
increment: 30,
|
|
89
|
+
mode: "ceil",
|
|
90
|
+
smallestUnit: "minute",
|
|
91
|
+
}); // { time: 00:00, days: 1 }
|
|
92
|
+
|
|
93
|
+
snapZonedDateTime(Temporal.ZonedDateTime.from("2026-03-29T01:50+01:00[Europe/Berlin]"), {
|
|
94
|
+
increment: 15,
|
|
95
|
+
mode: "ceil",
|
|
96
|
+
smallestUnit: "minute",
|
|
97
|
+
}); // 2026-03-29T03:00:00+02:00[Europe/Berlin]: 02:00 doesn't exist that night
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The snap functions round to a wall-clock grid that starts at midnight, with `mode` set to
|
|
101
|
+
`"nearest"` (the default), `"floor"`, or `"ceil"`:
|
|
102
|
+
|
|
103
|
+
- `snapPlainTime(time, options)` returns `{ time, days }`. `days` is `1` when rounding up passed
|
|
104
|
+
midnight, so a late end time isn't mistaken for an early one.
|
|
105
|
+
- `snapZonedDateTime(value, options)` rounds in the value's own time zone. In a repeated hour it
|
|
106
|
+
keeps the same occurrence. If the result lands in a skipped hour, it moves to the moment the clocks
|
|
107
|
+
change, so `floor` never moves later and `ceil` never moves earlier.
|
|
108
|
+
- `snapZonedWallTime(wallTime, { timeZone, fold, ...options })` does the same for a wall-clock time
|
|
109
|
+
with no zone yet, such as a pointer position. `fold` picks `"earlier"` (the default) or `"later"`
|
|
110
|
+
for a repeated time.
|
|
111
|
+
|
|
112
|
+
`roundPlainTime` and `roundInstant` take Temporal's full set of rounding modes. Instant rounding
|
|
113
|
+
starts at the Unix epoch.
|
|
114
|
+
|
|
115
|
+
## Days in a time zone
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { zonedDayRange } from "@moltenship/calendar-temporal";
|
|
119
|
+
|
|
120
|
+
const day = zonedDayRange(Temporal.PlainDate.from("2026-03-29"), "Europe/Berlin");
|
|
121
|
+
|
|
122
|
+
day.kind; // "available"
|
|
123
|
+
day.duration.toString(); // "PT23H": the clocks go forward that night
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- `zonedDayRange(date, timeZone)` returns the real start and end of a date in a zone. Its
|
|
127
|
+
`interval` is the instant range to query with. In the rare case where a time zone skips a whole
|
|
128
|
+
date, `kind` is `"skipped"` and `interval` is `null`.
|
|
129
|
+
- `splitInstantRangeByZonedDay(range, timeZone)` cuts an instant range into one piece per day, for
|
|
130
|
+
events that cross midnight. Each piece says whether the event continues before or after that day.
|
|
131
|
+
- `zonedDayTransitions(date, timeZone)` lists the offset changes on a date, with whether each is a
|
|
132
|
+
gap or a fold and which wall-clock times it affects.
|
|
133
|
+
|
|
134
|
+
## Wall-clock times
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { resolveZonedWallTime } from "@moltenship/calendar-temporal";
|
|
138
|
+
|
|
139
|
+
const result = resolveZonedWallTime(Temporal.PlainDateTime.from("2026-03-29T02:15"), {
|
|
140
|
+
timeZone: "Europe/Berlin",
|
|
141
|
+
disambiguation: "compatible",
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
result.status; // "resolved"
|
|
145
|
+
result.kind; // "gap": 02:15 doesn't exist that day
|
|
146
|
+
result.adjustment?.resolvedWallTime.toString(); // "2026-03-29T03:15:00"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`resolveZonedWallTime(wallTime, { timeZone, disambiguation })` turns a wall-clock time into an
|
|
150
|
+
instant and tells you what happened: `kind` is `"unique"`, `"gap"`, or `"fold"`. For a gap,
|
|
151
|
+
`adjustment` says how far the time moved; with `disambiguation: "reject"`, `status` is `"rejected"`
|
|
152
|
+
instead. For a fold, `occurrences` has both instants. `projectInstantToZonedTime(instant, timeZone)`
|
|
153
|
+
goes the other way.
|
|
154
|
+
|
|
155
|
+
## Time slots
|
|
156
|
+
|
|
157
|
+
`slotsInZonedDay(date, { timeZone, disambiguation, slotDuration })` splits a day into wall-clock
|
|
158
|
+
slots, such as 30-minute rows for a day view. Slots in a skipped hour have no instant. Slots in a
|
|
159
|
+
repeated hour have two. A slot that a DST change cuts through is split at the change. It throws a
|
|
160
|
+
`RangeError` when the day would have more than 10,000 slots; raise `limit` for finer grids.
|
|
161
|
+
|
|
162
|
+
## Keys
|
|
163
|
+
|
|
164
|
+
`instantKey`, `plainDateKey`, `plainDateTimeKey`, `zonedDayKey`, and `zonedWallTimeKey` return
|
|
165
|
+
strings for use as React keys or cache keys. Two moments in a repeated hour share a wall-clock key,
|
|
166
|
+
so key those by `instantKey`. Time zone names are compared case-insensitively, but aliases such as
|
|
167
|
+
`Asia/Calcutta` and `Asia/Kolkata` produce different keys.
|
|
168
|
+
|
|
169
|
+
## Clocks
|
|
170
|
+
|
|
171
|
+
`createFixedClock(instant)` and `createSystemClock()` return objects for `Root`'s `clock` prop. A fixed
|
|
172
|
+
clock always returns the same instant, which helps in tests.
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
What each package exports, and where to import it from.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/api
|
|
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:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createCalendar, defineCalendarView, plainDateInterval } from "@moltenship/calendar";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- [React components and hooks](./api/react.md): createCalendar, Root and its props, components, hooks, meta, diagnostics.
|
|
15
|
+
- [Events and snapshots](./api/events.md): Adapters, ranges, validation, snapshots, and queries.
|
|
16
|
+
- [Event changes](./api/changes.md): Proposals, changes, policies, placement helpers, and the pointer layer.
|
|
17
|
+
- [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.
|
|
21
|
+
- [dnd-kit adapter](./api/dnd-kit.md): Drag your dnd-kit items into the calendar and events out. A separate package.
|
|
22
|
+
- [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
|
+
|
|
26
|
+
The iCalendar parser, `@moltenship/ics`, stands alone. `@moltenship/calendar` doesn't re-export it,
|
|
27
|
+
so install it and import it by its own name. It doesn't need the calendar either.
|
|
28
|
+
|
|
29
|
+
Recurring events come from `@moltenship/calendar-recurrence`, which `@moltenship/calendar` doesn't
|
|
30
|
+
re-export either. It turns series into occurrences that the calendar shows as ordinary events.
|
|
31
|
+
|
|
32
|
+
`@moltenship/calendar-dnd-kit` connects the calendar to dnd-kit, for apps that drag their own items
|
|
33
|
+
into it. It's optional and not re-exported, so the calendar's install carries no dnd-kit.
|
|
34
|
+
|
|
35
|
+
Tests use `@moltenship/calendar-testing`, a development dependency: see [Testing](./testing.md).
|
|
36
|
+
|
|
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).
|
|
39
|
+
|
|
40
|
+
## Packages
|
|
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) |
|
|
55
|
+
|
|
56
|
+
Every package is ESM only. Import from the package name: paths inside a package aren't part of the
|
|
57
|
+
API.
|