@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.
- 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
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# @moltenship/calendar
|
|
2
2
|
|
|
3
|
-
A React 19 calendar built on the Temporal API. This is the package you install and import.
|
|
4
|
-
has the React components and hooks, the event engine, the Temporal helpers and the pointer
|
|
5
|
-
interactions.
|
|
3
|
+
A headless React 19 calendar built on the Temporal API. This is the package you install and import.
|
|
4
|
+
It has the React components and hooks, the event engine, the Temporal helpers and the pointer
|
|
5
|
+
interactions. Its parts are [ui-sdk](https://ui-sdk.dev) components, so an AI agent can read a
|
|
6
|
+
calendar and act on it through ui-sdk's agent bridge.
|
|
7
|
+
|
|
8
|
+
> **2.0 pre-release.** The API can still change before 2.0.0. Coming from 1.x? See
|
|
9
|
+
> [Migrating to 2.0](https://time.molten.sh/docs/migrating-to-2).
|
|
6
10
|
|
|
7
11
|
```ts
|
|
8
12
|
import { createCalendar, defineCalendarView, plainDateInterval } from "@moltenship/calendar";
|
|
@@ -16,10 +20,13 @@ parsing (`@moltenship/ics`) are separate packages that you add when you need the
|
|
|
16
20
|
## Install
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
|
-
pnpm add @moltenship/calendar react react-dom
|
|
23
|
+
pnpm add @moltenship/calendar @ui-sdk/core @ui-sdk/react react react-dom
|
|
20
24
|
```
|
|
21
25
|
|
|
22
26
|
- React 19. React is a peer dependency.
|
|
27
|
+
- `@ui-sdk/core` and `@ui-sdk/react` 0.1 beta, peer dependencies since 2.0. `@ui-sdk/react` needs
|
|
28
|
+
React DOM. Keep one copy of `@ui-sdk/core` in your app: the calendar and an agent bridge find
|
|
29
|
+
each other through it.
|
|
23
30
|
- A runtime with `Temporal` (Node.js 26 and later include it), or a polyfill that defines
|
|
24
31
|
`globalThis.Temporal`, loaded before the calendar. The package never bundles one.
|
|
25
32
|
- TypeScript 6 or later with `"lib": ["DOM", "DOM.Iterable", "ESNext"]`. `ESNext` has the
|
|
@@ -29,10 +36,23 @@ The styled views, toolbar and theme aren't in this package. They're source files
|
|
|
29
36
|
that you add to your app with the shadcn CLI and then own; see
|
|
30
37
|
[Installation](https://time.molten.sh/docs/installation).
|
|
31
38
|
|
|
39
|
+
## For coding agents
|
|
40
|
+
|
|
41
|
+
The package ships its docs and a skill, so a coding agent reads the API of the version you
|
|
42
|
+
installed:
|
|
43
|
+
|
|
44
|
+
- `docs/llms.txt` is the index of the docs, and `docs/` has each page as Markdown.
|
|
45
|
+
- `skills/moltenship-time` is an [Agent Skill](https://agentskills.io): `SKILL.md` and its
|
|
46
|
+
`references/`. Install it with `npx skills add Moltenship/time --skill moltenship-time`, or copy
|
|
47
|
+
the folder into your agent's skills folder.
|
|
48
|
+
|
|
49
|
+
See [Build with a coding agent](https://time.molten.sh/docs/agents/coding-agents).
|
|
50
|
+
|
|
32
51
|
## Documentation
|
|
33
52
|
|
|
34
53
|
- [Docs](https://time.molten.sh/docs), starting with the
|
|
35
54
|
[Quick start](https://time.molten.sh/docs/quick-start)
|
|
55
|
+
- [Agents](https://time.molten.sh/docs/agents)
|
|
36
56
|
- [Repository](https://github.com/Moltenship/time)
|
|
37
57
|
|
|
38
58
|
## License
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalendarDragFollower, CalendarDragMonitor, CalendarDragPreview, CalendarDropOptions, CalendarDropSession, CalendarDropSource, CalendarEventDrag, CalendarPoint, CalendarPointerOptions, CalendarRect, CalendarRegion, attachCalendarPointer, eventIdAttributes, eventIdOf, monitorCalendarDrags, observeCalendarRegions, resourceIdAttributes, resourceIdOf, startCalendarDrop, useCalendarPointer } from "@moltenship/calendar-dnd";
|
|
2
|
-
import { AnyCalendarView, CalendarActions, CalendarActiveView, CalendarActiveViewProps, CalendarAnnotations, CalendarAnnouncerProps, CalendarBusyResources, CalendarContextValue, CalendarControlledState, CalendarDiagnostic, CalendarDraftBusy, CalendarEventProps, CalendarEventRenderValue, CalendarFactory, CalendarFrameProps, CalendarHistory, CalendarHistoryAnnouncementBuilder, CalendarHistoryAnnouncementContext, CalendarHistoryCommandOptions, CalendarHistoryMessages, CalendarHistoryOptions, CalendarHistoryShortcutsOptions, CalendarHistoryShortcutsTarget, CalendarKeyboardHandlers, CalendarKeyboardOptions, CalendarMeta, CalendarPartIds, CalendarPartRefs, CalendarPublicState, CalendarResourceExpansion, CalendarResourceStatus, CalendarRootProps, CalendarRovingFocusOptions, CalendarRovingFocusProps, CalendarSemanticActions, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStore, CalendarStoreOptions, CalendarTitleProps, CalendarToolbarProps, CalendarTriggerProps, CalendarView, CalendarViewActions, CalendarViewInput, CalendarViewOptionsMap, CalendarViewRendererProps, CalendarViewSwitcherProps, CalendarViewportProps, CalendarVisibleRange, CreateCalendarOptions, UseNowOptions, createCalendar, createCalendarStore, defineCalendarView, useAnchorDateRequests, useBusyResources, useCalendarAnnotations, useCalendarAnnouncer, useCalendarAvailability, useCalendarDraft, useCalendarDraftReporter, useCalendarFocus, useCalendarHistory, useCalendarHistoryShortcuts, useCalendarInteraction, useCalendarKeyboard, useCalendarSelection, useClosedDates, useDraftBusy, useNow, useResourceExpansion, useResourceStatus, useRovingFocus, useTimeGridAnnotations, useTimeGridAvailability, useTimelineAvailability, useVisibleResources } from "@moltenship/calendar-react";
|
|
2
|
+
import { AnyCalendarView, CalendarActions, CalendarActiveView, CalendarActiveViewProps, CalendarAnnotations, CalendarAnnouncerProps, CalendarBusyResources, CalendarChangeReason, CalendarChangeSource, CalendarCommandOptions, CalendarContextValue, CalendarControlledState, CalendarDiagnostic, CalendarDraftBusy, CalendarEventProps, CalendarEventRenderValue, CalendarFactory, CalendarFrameProps, CalendarHistory, CalendarHistoryAnnouncementBuilder, CalendarHistoryAnnouncementContext, CalendarHistoryCommandOptions, CalendarHistoryMessages, CalendarHistoryOptions, CalendarHistoryShortcutsOptions, CalendarHistoryShortcutsTarget, CalendarKeyboardHandlers, CalendarKeyboardOptions, CalendarMeta, CalendarPartIds, CalendarPartRefs, CalendarPublicState, CalendarResourceExpansion, CalendarResourceExpansionCause, CalendarResourceExpansionCommand, CalendarResourceStatus, CalendarRootProps, CalendarRovingFocusOptions, CalendarRovingFocusProps, CalendarSemanticActions, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStore, CalendarStoreOptions, CalendarTitleProps, CalendarToolbarProps, CalendarTriggerProps, CalendarView, CalendarViewActions, CalendarViewInput, CalendarViewOptionsMap, CalendarViewRendererProps, CalendarViewSwitcherProps, CalendarViewportProps, CalendarVisibleRange, CreateCalendarOptions, UseNowOptions, createCalendar, createCalendarStore, defineCalendarView, useAnchorDateRequests, useBusyResources, useCalendarAnnotations, useCalendarAnnouncer, useCalendarAvailability, useCalendarDraft, useCalendarDraftReporter, useCalendarFocus, useCalendarHistory, useCalendarHistoryShortcuts, useCalendarInteraction, useCalendarKeyboard, useCalendarSelection, useClosedDates, useDraftBusy, useNow, useResourceExpansion, useResourceStatus, useRovingFocus, useTimeGridAnnotations, useTimeGridAvailability, useTimelineAvailability, useVisibleResources } from "@moltenship/calendar-react";
|
|
3
3
|
export * from "@moltenship/calendar-core";
|
|
4
4
|
export * from "@moltenship/calendar-temporal";
|
|
5
|
-
export { type AnyCalendarView, type CalendarActions, type CalendarActiveView, type CalendarActiveViewProps, type CalendarAnnotations, type CalendarAnnouncerProps, type CalendarBusyResources, type CalendarContextValue, type CalendarControlledState, type CalendarDiagnostic, type CalendarDraftBusy, type CalendarDragFollower, type CalendarDragMonitor, type CalendarDragPreview, type CalendarDropOptions, type CalendarDropSession, type CalendarDropSource, type CalendarEventDrag, type CalendarEventProps, type CalendarEventRenderValue, type CalendarFactory, type CalendarFrameProps, type CalendarHistory, type CalendarHistoryAnnouncementBuilder, type CalendarHistoryAnnouncementContext, type CalendarHistoryCommandOptions, type CalendarHistoryMessages, type CalendarHistoryOptions, type CalendarHistoryShortcutsOptions, type CalendarHistoryShortcutsTarget, type CalendarKeyboardHandlers, type CalendarKeyboardOptions, type CalendarMeta, type CalendarPartIds, type CalendarPartRefs, type CalendarPoint, type CalendarPointerOptions, type CalendarPublicState, type CalendarRect, type CalendarRegion, type CalendarResourceExpansion, type CalendarResourceStatus, type CalendarRootProps, type CalendarRovingFocusOptions, type CalendarRovingFocusProps, type CalendarSemanticActions, type CalendarStateChangeDetail, type CalendarStateChangeHandler, type CalendarStateChangeHandlers, type CalendarStateSelector, type CalendarStateSelectorOptions, type CalendarStateSlice, type CalendarStore, type CalendarStoreOptions, type CalendarTitleProps, type CalendarToolbarProps, type CalendarTriggerProps, type CalendarView, type CalendarViewActions, type CalendarViewInput, type CalendarViewOptionsMap, type CalendarViewRendererProps, type CalendarViewSwitcherProps, type CalendarViewportProps, type CalendarVisibleRange, type CreateCalendarOptions, type UseNowOptions, attachCalendarPointer, createCalendar, createCalendarStore, defineCalendarView, eventIdAttributes, eventIdOf, monitorCalendarDrags, observeCalendarRegions, resourceIdAttributes, resourceIdOf, startCalendarDrop, useAnchorDateRequests, useBusyResources, useCalendarAnnotations, useCalendarAnnouncer, useCalendarAvailability, useCalendarDraft, useCalendarDraftReporter, useCalendarFocus, useCalendarHistory, useCalendarHistoryShortcuts, useCalendarInteraction, useCalendarKeyboard, useCalendarPointer, useCalendarSelection, useClosedDates, useDraftBusy, useNow, useResourceExpansion, useResourceStatus, useRovingFocus, useTimeGridAnnotations, useTimeGridAvailability, useTimelineAvailability, useVisibleResources };
|
|
5
|
+
export { type AnyCalendarView, type CalendarActions, type CalendarActiveView, type CalendarActiveViewProps, type CalendarAnnotations, type CalendarAnnouncerProps, type CalendarBusyResources, type CalendarChangeReason, type CalendarChangeSource, type CalendarCommandOptions, type CalendarContextValue, type CalendarControlledState, type CalendarDiagnostic, type CalendarDraftBusy, type CalendarDragFollower, type CalendarDragMonitor, type CalendarDragPreview, type CalendarDropOptions, type CalendarDropSession, type CalendarDropSource, type CalendarEventDrag, type CalendarEventProps, type CalendarEventRenderValue, type CalendarFactory, type CalendarFrameProps, type CalendarHistory, type CalendarHistoryAnnouncementBuilder, type CalendarHistoryAnnouncementContext, type CalendarHistoryCommandOptions, type CalendarHistoryMessages, type CalendarHistoryOptions, type CalendarHistoryShortcutsOptions, type CalendarHistoryShortcutsTarget, type CalendarKeyboardHandlers, type CalendarKeyboardOptions, type CalendarMeta, type CalendarPartIds, type CalendarPartRefs, type CalendarPoint, type CalendarPointerOptions, type CalendarPublicState, type CalendarRect, type CalendarRegion, type CalendarResourceExpansion, type CalendarResourceExpansionCause, type CalendarResourceExpansionCommand, type CalendarResourceStatus, type CalendarRootProps, type CalendarRovingFocusOptions, type CalendarRovingFocusProps, type CalendarSemanticActions, type CalendarStateChangeDetail, type CalendarStateChangeHandler, type CalendarStateChangeHandlers, type CalendarStateSelector, type CalendarStateSelectorOptions, type CalendarStateSlice, type CalendarStore, type CalendarStoreOptions, type CalendarTitleProps, type CalendarToolbarProps, type CalendarTriggerProps, type CalendarView, type CalendarViewActions, type CalendarViewInput, type CalendarViewOptionsMap, type CalendarViewRendererProps, type CalendarViewSwitcherProps, type CalendarViewportProps, type CalendarVisibleRange, type CreateCalendarOptions, type UseNowOptions, attachCalendarPointer, createCalendar, createCalendarStore, defineCalendarView, eventIdAttributes, eventIdOf, monitorCalendarDrags, observeCalendarRegions, resourceIdAttributes, resourceIdOf, startCalendarDrop, useAnchorDateRequests, useBusyResources, useCalendarAnnotations, useCalendarAnnouncer, useCalendarAvailability, useCalendarDraft, useCalendarDraftReporter, useCalendarFocus, useCalendarHistory, useCalendarHistoryShortcuts, useCalendarInteraction, useCalendarKeyboard, useCalendarPointer, useCalendarSelection, useClosedDates, useDraftBusy, useNow, useResourceExpansion, useResourceStatus, useRovingFocus, useTimeGridAnnotations, useTimeGridAvailability, useTimelineAvailability, useVisibleResources };
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Accessibility
|
|
2
|
+
|
|
3
|
+
The keyboard map, screen reader announcements, the ARIA patterns each view uses, reduced motion, and right-to-left layout.
|
|
4
|
+
|
|
5
|
+
Source: https://time.molten.sh/docs/accessibility
|
|
6
|
+
|
|
7
|
+
Everything you can do with a pointer in the built-in views, you can also do from the keyboard:
|
|
8
|
+
move around, open an event, and move, resize, or create one. A screen reader hears each step. Try it
|
|
9
|
+
here: Tab into the calendar or click a day, then use the keys below. The strip under the calendar
|
|
10
|
+
shows what a screen reader announces.
|
|
11
|
+
|
|
12
|
+
> Live example of the `week` view: see it at https://time.molten.sh/docs/accessibility
|
|
13
|
+
|
|
14
|
+
## Keyboard
|
|
15
|
+
|
|
16
|
+
Each view is **one tab stop**. Tab enters it on the day, slot, or event you last focused, or on
|
|
17
|
+
today, and the keys below move focus inside it. Moving past the visible range navigates the view.
|
|
18
|
+
Inside a view, arrow, Home, End, and Page keys always belong to the view, so they never trigger your
|
|
19
|
+
app's own shortcuts, even where there's nowhere to move.
|
|
20
|
+
|
|
21
|
+
### Moving around
|
|
22
|
+
|
|
23
|
+
| View | Focus | Key | Effect |
|
|
24
|
+
| --------- | ---------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| All | Outside the view | Tab | Enter the view |
|
|
26
|
+
| All | An event | Enter | Open it: the element's own click, such as the [demo](https://moltenship-time-demo.vercel.app)'s popover |
|
|
27
|
+
| All | An event | Escape | Back to its day (month, all-day row) or the slot it starts in (week, day) |
|
|
28
|
+
| All | A day, slot, or agenda event | Shift+Enter | Open that date in the day view |
|
|
29
|
+
| Month | A day | ← → | Previous or next day |
|
|
30
|
+
| Month | A day | ↑ ↓ | Same weekday a week earlier or later |
|
|
31
|
+
| Month | A day | Home, End | First or last day of the week |
|
|
32
|
+
| Month | A day | Page Up, Page Down | Same day in the previous or next month |
|
|
33
|
+
| Month | A day | Enter | Go into the day's events |
|
|
34
|
+
| Month | An event | ↑ ↓ | Previous or next event of the day; past the ends, to the day itself or the next week |
|
|
35
|
+
| Year | A day | ← → ↑ ↓ | Previous or next day, or the same weekday a week away, across months |
|
|
36
|
+
| Year | A day | Home, End | First or last day of the week's row in its month |
|
|
37
|
+
| Year | A day | Page Up, Page Down | Same day in the previous or next month |
|
|
38
|
+
| Year | A day | Enter, Space | Open the day's events in a popover; Escape returns to the day |
|
|
39
|
+
| Week, day | An all-day cell | ↓ | First slot of the day |
|
|
40
|
+
| Week, day | A slot | ↑ ↓ | Previous or next 15-minute slot; up from the first slot, the all-day cell |
|
|
41
|
+
| Week, day | A day or slot | ← → | Same slot on the previous or next day |
|
|
42
|
+
| Week, day | A day or slot | Home, End | First or last day shown |
|
|
43
|
+
| Week, day | A day or slot | Page Up, Page Down | Back or forward a whole week (or day) |
|
|
44
|
+
| Week, day | A slot | Enter | The event covering it |
|
|
45
|
+
| Week, day | An all-day cell | Enter | Go into the day's all-day events |
|
|
46
|
+
| Week, day | A timed event | ↑ ↓ | Previous or next event in the column |
|
|
47
|
+
| Week, day | A timed event | ← → | The event beside it that overlaps it |
|
|
48
|
+
| Resources | A day or slot | ← → | Same slot in the previous or next column, crossing into the next resource |
|
|
49
|
+
| Resources | A day or slot | Home, End | First or last column |
|
|
50
|
+
| Resources | A day or slot | Page Up, Page Down | Same resource, a whole day (or range) earlier or later |
|
|
51
|
+
| Timeline | A day or slot | ← → | Previous or next day, or half hour in the day timeline |
|
|
52
|
+
| Timeline | A day or slot | ↑ ↓ | The same time in the previous or next resource's row |
|
|
53
|
+
| Timeline | A day or slot | Home, End | First or last day or half hour shown |
|
|
54
|
+
| Timeline | A day or slot | Page Up, Page Down | Back or forward a whole day, week, or month |
|
|
55
|
+
| Timeline | A day or slot | Enter | The events covering it in that row |
|
|
56
|
+
| Timeline | A group's day or slot | Shift+Enter | Expand or collapse the group |
|
|
57
|
+
| Timeline | An event | ← → | Previous or next event in the row |
|
|
58
|
+
| Timeline | An event | ↑ ↓ | The cell at its start in the previous or next row |
|
|
59
|
+
| Agenda | An event | ↑ ↓ | Previous or next event |
|
|
60
|
+
| Agenda | An event | Page Up, Page Down | First event of the previous or next day |
|
|
61
|
+
| Agenda | An event | Home, End | First or last event |
|
|
62
|
+
| Agenda | A range without events | ↑ or Page Up, ↓ or Page Down | The previous or next range |
|
|
63
|
+
|
|
64
|
+
In the [resource columns](./views/resource-columns.md#keyboard) view, each resource's days come
|
|
65
|
+
before the next resource's, and inside a column the week and day keys apply.
|
|
66
|
+
|
|
67
|
+
Shift+Enter opens the view named `day`; in the resource timeline it expands or collapses a group
|
|
68
|
+
instead. In the week view it needs the
|
|
69
|
+
[`dayView`](./views/week-and-day.md#options) option, and the day view has nothing to open. The
|
|
70
|
+
table shows left-to-right calendars; with `direction="rtl"` on `Root`, ← and → swap so they follow
|
|
71
|
+
the layout (see [Right-to-left](#right-to-left)).
|
|
72
|
+
|
|
73
|
+
### Changing events
|
|
74
|
+
|
|
75
|
+
With `onEventChange` on `Root`, the month, week, day, resource columns, and resource timeline views
|
|
76
|
+
can change events from the keyboard, just as a drag does; without it, Space picks nothing up and
|
|
77
|
+
is left to the focused element. The year view shows events without
|
|
78
|
+
changing them, so Space there opens a day's events. Moving a picked-up event into another
|
|
79
|
+
resource's column or row swaps that resource, as dropping it there would.
|
|
80
|
+
|
|
81
|
+
| Focus | Key | Effect |
|
|
82
|
+
| ---------------------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
83
|
+
| An event | Space | Pick it up to move it |
|
|
84
|
+
| An event | Shift+Space | Pick it up to resize its end. Shift+Space again switches to its start, and back |
|
|
85
|
+
| A day (month cell or all-day cell) | Space | Start an all-day event there |
|
|
86
|
+
| A slot | Space | Start an hour-long event there |
|
|
87
|
+
| Picked up | Arrow keys | Move, resize, or extend it: by days in the month and the all-day row, by slots in the time grid. Moving a timed event above the first slot makes it all-day, and below the all-day row makes it timed |
|
|
88
|
+
| Picked up | Enter or Space | Save it through `onEventChange` |
|
|
89
|
+
| Picked up | Escape, Tab, or leaving the view | Cancel. Focus returns to where you started |
|
|
90
|
+
|
|
91
|
+
A saved change goes through your [policies](./interactions.md#policies) and shows as
|
|
92
|
+
[pending](./interactions.md#pending-changes) like any other. Read-only events say so when you pick
|
|
93
|
+
them up, and stay where they are. The agenda has no cells to move events to, so it only navigates
|
|
94
|
+
and opens them.
|
|
95
|
+
|
|
96
|
+
`useCalendarKeyboard({ snap, createDuration })` sets the slot length (the pointer's `snap`, 15
|
|
97
|
+
minutes by default) and how long a slot create starts out (one hour).
|
|
98
|
+
|
|
99
|
+
## Announcements
|
|
100
|
+
|
|
101
|
+
Keyboard and pointer moves, resizes, and creates are announced through a polite live region. Render
|
|
102
|
+
`Announcer` once inside `Root`, with the messages from the registry:
|
|
103
|
+
|
|
104
|
+
```tsx title="calendar.tsx"
|
|
105
|
+
import { calendarAnnouncements } from "@/components/calendar/announcements";
|
|
106
|
+
|
|
107
|
+
<Calendar.Root
|
|
108
|
+
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
|
|
109
|
+
defaultTimeZone="Europe/Berlin"
|
|
110
|
+
events={meetings}
|
|
111
|
+
locale="en-US"
|
|
112
|
+
onEventChange={saveMeeting}
|
|
113
|
+
weekRules={{ firstDay: 1, minimalDays: 4, weekend: [6, 7] }}
|
|
114
|
+
>
|
|
115
|
+
<Calendar.Announcer messages={calendarAnnouncements} />
|
|
116
|
+
<Calendar.ActiveView />
|
|
117
|
+
</Calendar.Root>;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`Announcer` renders a visually hidden `<div role="status" aria-live="polite">`. Without it nothing
|
|
121
|
+
is announced. Picking up Standup and moving it down a slot, for example, reads:
|
|
122
|
+
|
|
123
|
+
1. "Picked up Standup, Thursday, October 8, 9:30 – 9:45 AM. Use the arrow keys to move it, then
|
|
124
|
+
Enter to drop it or Escape to cancel."
|
|
125
|
+
2. "Thursday, October 8, 9:45 – 10:00 AM"
|
|
126
|
+
3. "Moved Standup to Thursday, October 8, 9:45 – 10:00 AM." once `onEventChange` has saved it.
|
|
127
|
+
|
|
128
|
+
In a calendar with resources, picking up, moving and creating an event also name the resources it
|
|
129
|
+
books, from `Root`'s `resources`: "Moved Standup to Thursday, October 8, 9:45 – 10:00 AM, Orchid."
|
|
130
|
+
While moving, a step names them only when they change.
|
|
131
|
+
|
|
132
|
+
### Customize and localize them
|
|
133
|
+
|
|
134
|
+
The packages ship no text. `calendarAnnouncements` lives in `components/calendar/announcements.ts`
|
|
135
|
+
in your app once you add the UI source, so you can edit it in place. To translate it, write a
|
|
136
|
+
`CalendarAnnouncementMessages` object of your own, with one builder per phase:
|
|
137
|
+
|
|
138
|
+
| Phase | When | The update also has |
|
|
139
|
+
| -------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
140
|
+
| `start` | An event is picked up, or a create starts | `check`: what the policies say about `proposed`, or `null` with no answer yet (a keyboard move or resize that hasn't stepped, or an async policy) |
|
|
141
|
+
| `step` | Each arrow key, or each new slot under the pointer | `check`, as for `start` |
|
|
142
|
+
| `commit` | Your handler saved the change | `proposed`: the change as saved, and `warnings` |
|
|
143
|
+
| `reject` | A policy or your handler refused it, or the event is read-only | `reason`, such as `"read-only"`, and `error`: what your handler or a policy threw, if one did (an `AbortError` from your handler means the app cancelled) |
|
|
144
|
+
| `cancel` | Escape, Tab, leaving the view, or a drag dropped outside it | |
|
|
145
|
+
|
|
146
|
+
Each builder receives the update and a context, and returns the text to speak or `null` to stay
|
|
147
|
+
silent. The update has `cause` (`"move"`, `"resize-start"`, `"resize-end"`, or `"create"`),
|
|
148
|
+
`input` (`"keyboard"` or `"pointer"`), `event` (`null` while creating), and the `original` and
|
|
149
|
+
`proposed` placements. The context has `locale`, `timeZone`, `resourceTitle(resourceId)`, and
|
|
150
|
+
`formatRange(placement)`, which formats a placement as the drag preview labels it ("9:30 – 10:00 AM").
|
|
151
|
+
|
|
152
|
+
```tsx title="announcements-de.ts"
|
|
153
|
+
import type { CalendarAnnouncementMessages } from "@moltenship/calendar";
|
|
154
|
+
|
|
155
|
+
const titleOf = ({ event }: { readonly event: { readonly title: string } | null }) =>
|
|
156
|
+
event === null ? "Der neue Termin" : event.title;
|
|
157
|
+
|
|
158
|
+
export const announcementsDe: CalendarAnnouncementMessages = {
|
|
159
|
+
start: (update) =>
|
|
160
|
+
update.cause === "create"
|
|
161
|
+
? "Neuer Termin. Mit den Pfeiltasten verlängern, Eingabe zum Speichern."
|
|
162
|
+
: `${titleOf(update)} aufgenommen. Pfeiltasten zum Verschieben, Eingabe zum Ablegen.`,
|
|
163
|
+
step: ({ proposed }, { formatRange }) => (proposed === null ? null : formatRange(proposed)),
|
|
164
|
+
commit: (update, { formatRange }) => `${titleOf(update)}: ${formatRange(update.proposed)}.`,
|
|
165
|
+
reject: (update) =>
|
|
166
|
+
update.reason === "superseded" ? null : `${titleOf(update)} bleibt, wo er war.`,
|
|
167
|
+
cancel: () => "Abgebrochen.",
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`formatRange` follows the calendar's `locale`. To change how ranges read, add an optional
|
|
172
|
+
`formatRange(placement, { locale, timeZone })` to your messages; the default is
|
|
173
|
+
`formatPlacementRange`. It labels the drag preview and becomes the context's `formatRange`, so it
|
|
174
|
+
changes spoken ranges only in builders that call that helper, as the German example does.
|
|
175
|
+
`calendarAnnouncements` spells dates out with `describeWhen` from `event-label.ts` instead; edit
|
|
176
|
+
that to change how its announcements read.
|
|
177
|
+
|
|
178
|
+
### Pointer gestures
|
|
179
|
+
|
|
180
|
+
The built-in views pass the same announcer to the pointer layer, so drags are announced by the same
|
|
181
|
+
messages and the drag preview labels ranges with the same `formatRange`. In your own views, do the
|
|
182
|
+
same:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
const announcer = useCalendarAnnouncer();
|
|
186
|
+
const pointerRef = useCalendarPointer({ announcer, events, onPropose, timeZone });
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Event names
|
|
190
|
+
|
|
191
|
+
Every event is a `<button>` named in full: "Standup, Thursday, October 8, 9:30 – 9:45 AM, Work
|
|
192
|
+
calendar, saving". The name leads with the title, then says when, where (the resource, in the
|
|
193
|
+
resource columns view), an optional detail, and whether a change is still saving. `useEventLabel` builds it in `registry/calendar/event-label.ts`, where the
|
|
194
|
+
English words live, so edit or translate them there. Pass `describeEvent: (event) => string` to a
|
|
195
|
+
view to add the detail, such as the calendar's name.
|
|
196
|
+
|
|
197
|
+
## ARIA patterns
|
|
198
|
+
|
|
199
|
+
| View | Pattern |
|
|
200
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
201
|
+
| Month | A `grid` labelled with the month ("October 2026"). A header `row` holds a `columnheader` per weekday, named in full. Each week is a `row` of seven `gridcell`s named by date and event count ("Thursday, October 8, 2026, 2 events"). A cell holds its date button and the events that start that day. "+N more" opens a dialog named "Events on Thursday, October 8, 2026". |
|
|
202
|
+
| Year | A `group` labelled with the year ("2026") holding a `grid` per month, labelled "October 2026". A header `row` holds a `columnheader` per weekday, named in full. Each week is a `row` of seven `gridcell`s: a day is named by date and event count ("Thursday, October 8, 2026, 2 events") with `aria-haspopup="dialog"`, and cells outside the month are empty. The twelve grids share one tab stop. A day's events open in a dialog named "Events on Thursday, October 8, 2026". |
|
|
203
|
+
| Week and day | A `grid` labelled with the range ("Oct 4 – 10, 2026") with three rows: a header row of `columnheader`s (the time zone, then each day); the all-day row, led by an "All day" `rowheader` that also holds the expand toggle (`aria-expanded`), with a `gridcell` per day; and the timed row, led by a "Timed events" `rowheader`, with a `gridcell` per day. Hour labels, including those of [secondary time zones](./views/week-and-day.md#secondary-time-zones), are hidden from assistive tech. The focused slot renders as a `button` named "Thursday, October 8 at 9:30 AM", followed by its time in each secondary time zone; the other slots aren't elements at all. |
|
|
204
|
+
| Resource columns | A `grid` labelled with the range, with `aria-colcount` and an `aria-colindex` on every cell, since only the columns in view render. A header `row` has a `columnheader` per resource, named with its groups ("Maya, Design"), and a group's header holds its collapse toggle (`aria-expanded`). Then the all-day and timed rows, as in the week view, with each cell, slot and event named with its resource ("Maya, Thursday, October 8 at 9:30 AM"). |
|
|
205
|
+
| Resource timeline | A `grid` labelled with the range ("Oct 5 – 11, 2026" or "October 2026"). A header `row` holds a "Resources" `columnheader` and one per hour or day, named in full. Each resource is a `row` named by the resource, led by a `rowheader` with its name (and a group's expand toggle, `aria-expanded`, out of the tab order), then a `gridcell` per slot named by resource, time, and event count ("Orchid, Monday, October 5, 2026, 2 events"). `aria-rowcount` and `aria-colcount` count every resource and slot, though only those in view render. The focused cell renders a `button` with the same name. |
|
|
206
|
+
| Agenda | An `<ol>` labelled with the range, with one `<li>` per day and a `<ul>` of its events. Only the days in view render, so each day has `aria-posinset` and `aria-setsize`. A range without events is a focusable group named "No events". The scrolling agenda is the same list. |
|
|
207
|
+
|
|
208
|
+
All views share these:
|
|
209
|
+
|
|
210
|
+
- **One tab stop** with a roving `tabIndex`: only the focused day, slot, or event has
|
|
211
|
+
`tabIndex={0}`. The header's "Open date" buttons and the all-day row's expand toggle are out of
|
|
212
|
+
the tab order; Shift+Enter and focusing a hidden event do their job.
|
|
213
|
+
- **Today** is marked `aria-current="date"`.
|
|
214
|
+
- **Events** are `<button>`s with the full names above. Events with a pending change have
|
|
215
|
+
`aria-busy`.
|
|
216
|
+
- **Focus** shows as a solid 2px `outline-ring` outline, which stays visible in forced-colors mode.
|
|
217
|
+
A focused event rises above its neighbours.
|
|
218
|
+
|
|
219
|
+
The mini month in `registry/calendar` is a separate `grid` of date buttons: arrow keys move by a
|
|
220
|
+
day or a week, and Page Up and Page Down by a month.
|
|
221
|
+
|
|
222
|
+
### Checked in CI
|
|
223
|
+
|
|
224
|
+
`vp run a11y` runs [axe-core](https://github.com/dequelabs/axe-core) in Chromium over every built-in
|
|
225
|
+
view, the toolbar and mini month, and the demo's main screens, in light and dark, and fails on any
|
|
226
|
+
serious or critical WCAG 2.2 A/AA or best-practice violation. It exempts four rules, each only on
|
|
227
|
+
specific elements:
|
|
228
|
+
|
|
229
|
+
- **Label in name**, for events and day cells: a chip shows an abbreviated subset of its name
|
|
230
|
+
("9:30 AM Standup"), and a day cell is named by its date and event count because its events are
|
|
231
|
+
focused separately. Event names lead with the title, so speech input still matches it.
|
|
232
|
+
- **Target size**, inside the month and time grids, where an event's box is its time span (WCAG
|
|
233
|
+
2.5.8's "essential" exception).
|
|
234
|
+
- **Hidden focusable elements**, for Base UI's focus guards, which pass focus straight on.
|
|
235
|
+
- **Command name**, for the same focus guards in WebKit, where Base UI makes them unnamed buttons
|
|
236
|
+
on purpose, so its focus trap catches VoiceOver's cursor instead of letting it leave a popup.
|
|
237
|
+
|
|
238
|
+
`vp run browsers` runs the same checks in Firefox and WebKit (WebKit alone on macOS 27, where
|
|
239
|
+
Playwright's Firefox doesn't start), except the reduced-motion tests, which run in Chromium.
|
|
240
|
+
|
|
241
|
+
On touch screens, month events and "+N more" are 24 px tall; with a mouse they stay 20 px. A test
|
|
242
|
+
emulates a 375 px touch screen in Chromium and checks that every target in the day, 3-day, month,
|
|
243
|
+
year, agenda and resource views is at least 24 px, or spaced as WCAG 2.5.8 allows. It leaves out:
|
|
244
|
+
|
|
245
|
+
- timed events in the time grids, whose height is their time span, the exception above: a
|
|
246
|
+
15-minute event is 12 px tall;
|
|
247
|
+
- annotation marks, which are still 12–20 px wide (#219);
|
|
248
|
+
- the week view, whose seven columns are too narrow for its events on a phone. Offer the 3-day view
|
|
249
|
+
there.
|
|
250
|
+
|
|
251
|
+
A separate test checks the [theme](./theming.md) against WCAG AA in both color schemes: event text
|
|
252
|
+
on every event color, the today marker, the now line, and the focus ring. If you override `--ring`,
|
|
253
|
+
keep it at 3:1 or more against your background, even at 50% opacity. shadcn's default light ring is
|
|
254
|
+
about 1.5:1 at 50%.
|
|
255
|
+
|
|
256
|
+
## Reduced motion
|
|
257
|
+
|
|
258
|
+
When the system asks for reduced motion (`prefers-reduced-motion: reduce`), the calendar theme:
|
|
259
|
+
|
|
260
|
+
- fades popovers, dialogs, and tooltips in and out without zooming or sliding;
|
|
261
|
+
- fades sheets without sliding them in;
|
|
262
|
+
- keeps transitions off the drag preview;
|
|
263
|
+
- crossfades view transitions in place instead of moving them.
|
|
264
|
+
|
|
265
|
+
The rules come with the `calendar-theme` item, which adds them to your global CSS, because the
|
|
266
|
+
registry views use shadcn's own popover, select, and tooltip, which you install from shadcn.
|
|
267
|
+
|
|
268
|
+
## Right-to-left
|
|
269
|
+
|
|
270
|
+
Right-to-left takes two settings: `dir="rtl"` on an ancestor of the calendar, such as `<html>`,
|
|
271
|
+
for the layout, and `direction="rtl"` on `Root` for the keys. `Root` doesn't read the page's
|
|
272
|
+
`dir`, so set both:
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
<html dir="rtl" lang="ar">
|
|
276
|
+
<body>
|
|
277
|
+
<Calendar.Root {...rootProps} direction="rtl" locale="ar">
|
|
278
|
+
<Calendar.ActiveView />
|
|
279
|
+
</Calendar.Root>
|
|
280
|
+
</body>
|
|
281
|
+
</html>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The month, week, day, and agenda views then mirror: days run from right to left, the hour gutter
|
|
285
|
+
moves to the right, events put their accent edge on the right, continuation chevrons point the way
|
|
286
|
+
the event continues, and the toolbar's arrows turn around. ← and → follow the layout, so ← moves to
|
|
287
|
+
the next day, which an RTL grid shows on the left, and a picked-up event moves the same way. The
|
|
288
|
+
views use logical CSS properties throughout (`ms-*`, `border-s`, `start-*`), so your own edits
|
|
289
|
+
should too.
|
|
290
|
+
|
|
291
|
+
## In your own views
|
|
292
|
+
|
|
293
|
+
[Custom views](./views/custom-views.md) get the same keyboard support from three pieces:
|
|
294
|
+
|
|
295
|
+
- **`getSpatialNavigation`** on the view's strategy says where each key moves focus. Reuse
|
|
296
|
+
`monthSpatialNavigation`, `yearSpatialNavigation`, `timeGridSpatialNavigation`, or
|
|
297
|
+
`listSpatialNavigation`, or write your own.
|
|
298
|
+
- **`useCalendarKeyboard(options)`** returns `onKeyDown` and `onBlur` handlers. Spread them on the
|
|
299
|
+
element around the view.
|
|
300
|
+
- **`useRovingFocus(focus)`** returns the props for one focusable day (`{ kind: "day", date }`),
|
|
301
|
+
slot, or event (`{ kind: "event", date, eventId }`), including its `tabIndex`.
|
|
302
|
+
|
|
303
|
+
`useCalendarInteraction()` returns the keyboard gesture in progress, for drawing a create's draft
|
|
304
|
+
or tinting the cells it covers.
|