@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.
- package/README.md +11 -10
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/docs/accessibility.md +5 -4
- package/docs/agents/changes.md +3 -3
- package/docs/agents/coding-agents.md +19 -20
- package/docs/agents/connect.md +20 -11
- package/docs/agents/deleting.md +2 -2
- package/docs/agents/reference.md +5 -6
- package/docs/agents/server.md +4 -4
- package/docs/agents/webmcp.md +2 -2
- package/docs/agents.md +10 -8
- package/docs/annotations.md +10 -8
- package/docs/api/changes.md +37 -21
- package/docs/api/{react.md → components.md} +65 -56
- package/docs/api/dnd-kit.md +1 -3
- package/docs/api/events.md +14 -13
- package/docs/api/primitives.md +61 -11
- package/docs/api/store.md +3 -3
- package/docs/api.md +23 -23
- package/docs/availability.md +25 -22
- package/docs/comparison.md +23 -24
- package/docs/concepts/anatomy.md +3 -3
- package/docs/concepts/events.md +2 -3
- package/docs/concepts/how-it-works.md +33 -16
- package/docs/concepts/state.md +1 -1
- package/docs/concepts/time.md +5 -7
- package/docs/customization.md +271 -0
- package/docs/frameworks.md +116 -0
- package/docs/guides/dnd-kit.md +2 -2
- package/docs/guides/google-calendar-sync.md +3 -3
- package/docs/guides/google-calendar.md +4 -4
- package/docs/guides/motion.md +2 -2
- package/docs/guides/nextjs-app-router.md +1 -1
- package/docs/guides/nextjs.md +1 -1
- package/docs/guides/performance.md +6 -6
- package/docs/guides/tanstack-query.md +2 -2
- package/docs/{guides/ics.md → ics/feed.md} +7 -9
- package/docs/ics/import.md +183 -0
- package/docs/{api/ics.md → ics/reference.md} +11 -53
- package/docs/ics.md +142 -0
- package/docs/index.md +81 -50
- package/docs/installation.md +48 -33
- package/docs/interactions.md +36 -3
- package/docs/llms.txt +81 -68
- package/docs/migrating-to-2.md +200 -25
- package/docs/quick-start.md +27 -23
- package/docs/{guides/recurring-events.md → recurrence/calendar.md} +23 -8
- package/docs/{concepts/recurrence.md → recurrence/model.md} +13 -12
- package/docs/{api/recurrence.md → recurrence/reference.md} +22 -61
- package/docs/recurrence.md +122 -0
- package/docs/stylex.md +74 -49
- package/docs/temporal/daylight-saving-time.md +172 -0
- package/docs/temporal/month-grid.md +119 -0
- package/docs/{api/temporal.md → temporal/reference.md} +7 -12
- package/docs/temporal.md +105 -0
- package/docs/testing.md +20 -1
- package/docs/theme-builder.md +9 -8
- package/docs/theming.md +108 -2
- package/docs/undo-redo.md +24 -16
- package/docs/views/agenda.md +14 -13
- package/docs/views/custom-views.md +13 -10
- package/docs/views/month.md +10 -9
- package/docs/views/resource-columns.md +21 -17
- package/docs/views/resource-timeline.md +16 -15
- package/docs/views/scrolling.md +7 -6
- package/docs/views/week-and-day.md +15 -14
- package/docs/views/year.md +11 -11
- package/docs/views.md +1 -1
- package/package.json +7 -6
- package/skills/moltenship-time/SKILL.md +7 -5
- package/skills/moltenship-time/references/compose.md +13 -6
- package/skills/moltenship-time/references/mistakes.md +4 -2
- package/skills/moltenship-time/references/solid.md +36 -25
- package/docs/api/solid.md +0 -460
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
# Solid
|
|
2
2
|
|
|
3
|
-
`@moltenship/calendar-solid` is the SolidJS 2 integration
|
|
3
|
+
`@moltenship/calendar-solid` is the SolidJS 2 integration. It renders the same primitive as React, so state, actions, event changes, policies and the agent surface are the same. It has every hook React has. The Solid registry has ready-made views for the week and day, the month, the year and the agenda, each but the year also as a scrolling view, the resource columns and the resource timeline, with a toolbar, a view switcher, a mini month, the recurring-event dialog, the undo toast and a kit of controls. `calendar-full` installs all of them. `https://time.molten.sh/docs/solid/frameworks.md` says what Solid doesn't have. Read the Solid docs before you write Solid code, and check the package's own types. The docs in the package are React's. Solid's are on the site: `https://time.molten.sh/llms.txt` lists them, and `https://time.molten.sh/docs/solid/api/components.md` is the reference.
|
|
4
4
|
|
|
5
5
|
## What it has, and what it doesn't
|
|
6
6
|
|
|
7
|
-
| Has
|
|
8
|
-
|
|
|
9
|
-
| `createCalendar`, `defineCalendarView`
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
|
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
| Has | Doesn't have |
|
|
8
|
+
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
9
|
+
| `createCalendar`, `defineCalendarView`, `Root` with the same props as React's | A testing package: `@moltenship/calendar-testing` is React only |
|
|
10
|
+
| Every part: the structural ones, `Event` and `Announcer` | `@moltenship/calendar-dnd-kit`, which has React as a peer |
|
|
11
|
+
| The read hooks: state, selector, actions, meta, range, projection, pending changes | The registry's views in StyleX: Solid's are Tailwind CSS |
|
|
12
|
+
| `useCalendarKeyboard`, `useRovingFocus`, `useCalendarFocus`, `useCalendarSelection` | |
|
|
13
|
+
| `useCalendarPointer`, `eventIdAttributes`, `resourceIdAttributes` | |
|
|
14
|
+
| `useCalendarInteraction`, `useCalendarDraft`, `useCalendarDraftReporter`, `useDraftBusy` | |
|
|
15
|
+
| `useCalendarAnnouncer`, `useCalendarHistory`, `useCalendarHistoryShortcuts` | |
|
|
16
|
+
| `useNow`, resources, status, availability, closed dates, annotations, `useAnchorDateRequests` | |
|
|
17
|
+
| `createStateSelector`, `createCalendarStore`, `resolveViewOptions`; the agent actions | |
|
|
18
|
+
| The registry's week and day, month, year, agenda, their scrolling versions, resource columns and resource timeline, its dialog and toast | |
|
|
19
|
+
|
|
20
|
+
Every hook React's integration exports has a Solid one with the same name. If the user asks for something in the right column, say Solid doesn't have it.
|
|
20
21
|
|
|
21
22
|
## Install
|
|
22
23
|
|
|
23
24
|
```bash
|
|
24
|
-
pnpm add @moltenship/calendar-solid
|
|
25
|
+
pnpm add @moltenship/calendar-solid solid-js @solidjs/web @ui-sdk/core @ui-sdk/solid
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
-
|
|
28
|
+
- `@moltenship/calendar-solid` is the one package to import. It re-exports the engine and the Temporal helpers, so the adapter and the view functions come from it too.
|
|
29
|
+
- The views install with the shadcn CLI from the Solid registry: `npx shadcn@latest add https://time.molten.sh/r/solid/calendar-full.json` adds every Solid item but `base-tokens`, `list-view.json` the agenda alone, and `time-grid-view`, `month-view` and `year-view` the week and day, the month and the year. `scrolling-time-grid-view`, `scrolling-month-view` and `scrolling-list-view` add the scrolling week and day, month and agenda (`https://time.molten.sh/docs/solid/views/scrolling.md`), `resource-columns-view` the resource columns (`https://time.molten.sh/docs/solid/views/resource-columns.md`), and `resource-timeline-view` the resource timeline (`https://time.molten.sh/docs/solid/views/resource-timeline.md`). `https://time.molten.sh/docs/solid/installation.md` has the setup, and `https://time.molten.sh/docs/solid/views.md` links each view's page.
|
|
30
|
+
- The same registry's `calendar` item has the toolbar, the view switcher and the mini month (`https://time.molten.sh/docs/solid/views/toolbar.md`), and `calendar-ui` the controls they're built from (`https://time.molten.sh/docs/solid/views/controls.md`). `recurrence-scope-dialog` is the recurring-event dialog (`https://time.molten.sh/docs/solid/recurrence/calendar.md`), and `calendar-history-toast` the undo toast (`https://time.molten.sh/docs/solid/undo-redo.md`).
|
|
28
31
|
- Don't install `@moltenship/calendar` in a Solid app. It's the React package.
|
|
29
32
|
- With Vite, use `@solidjs/vite-plugin`, and set `"jsx": "preserve"` and `"jsxImportSource": "@solidjs/web"` in `tsconfig.json`. Exclude `@ui-sdk/core` from `optimizeDeps` so the dev server loads one copy.
|
|
30
33
|
|
|
@@ -34,19 +37,17 @@ A view is a strategy from the engine and a Solid component that draws its projec
|
|
|
34
37
|
|
|
35
38
|
```tsx title="calendar.tsx"
|
|
36
39
|
import {
|
|
40
|
+
createCalendar,
|
|
41
|
+
defineCalendarView,
|
|
37
42
|
defineEventAdapter,
|
|
38
43
|
getListRange,
|
|
39
44
|
getListTitle,
|
|
40
45
|
navigateList,
|
|
41
46
|
projectList,
|
|
42
47
|
type CalendarEventInterval,
|
|
48
|
+
type CalendarViewRendererProps,
|
|
43
49
|
type ListProjection,
|
|
44
50
|
type ListViewOptions,
|
|
45
|
-
} from "@moltenship/calendar-core";
|
|
46
|
-
import {
|
|
47
|
-
createCalendar,
|
|
48
|
-
defineCalendarView,
|
|
49
|
-
type CalendarViewRendererProps,
|
|
50
51
|
} from "@moltenship/calendar-solid";
|
|
51
52
|
import { For } from "solid-js";
|
|
52
53
|
|
|
@@ -99,7 +100,7 @@ export const Calendar = createCalendar<Meeting>()({ eventAdapter, views: [listVi
|
|
|
99
100
|
```
|
|
100
101
|
|
|
101
102
|
```tsx title="app.tsx"
|
|
102
|
-
import type { CalendarWeekRules } from "@moltenship/calendar-
|
|
103
|
+
import type { CalendarWeekRules } from "@moltenship/calendar-solid";
|
|
103
104
|
import { createSignal } from "solid-js";
|
|
104
105
|
|
|
105
106
|
import { Calendar, type Meeting } from "./calendar";
|
|
@@ -176,9 +177,12 @@ export function App() {
|
|
|
176
177
|
- **`class`, not `className`**, on the parts.
|
|
177
178
|
- **A trigger needs children or an `aria-label`.** TypeScript requires one of them.
|
|
178
179
|
- **An accessor has the new value once Solid flushes**, a microtask after the action.
|
|
180
|
+
- **`useCalendarKeyboard()` and `useCalendarPointer(options)` return refs**, not handlers: `<div ref={[keyboard, pointer]}>`. Spread `useRovingFocus(target)` on each day, slot and event.
|
|
181
|
+
- **Pass an accessor where an argument changes:** `useRovingFocus(() => ({ date: props.day.date, kind: "day" }))`. A plain value is read once.
|
|
182
|
+
- **Key a `For` by identity** so an element keeps its focus across projections: `keyed={(segment) => segment.event.id}`. The children then get accessors.
|
|
179
183
|
- **The store's view type has to be the calendar's:** `createCalendarStore<View>(...)`. A calendar without resources takes a store made without the resource ID type.
|
|
180
184
|
|
|
181
|
-
The rest is in the other references and applies as written: `state.md` for controlled and uncontrolled state, `changes.md` for `onEventChange`, policies and pending changes.
|
|
185
|
+
The rest is in the other references and applies as written: `state.md` for controlled and uncontrolled state, `changes.md` for `onEventChange`, policies and pending changes. The history hooks apply too, from `@moltenship/calendar-solid`. What they say about the registry's views is React's: in Solid, check the view's own page.
|
|
182
186
|
|
|
183
187
|
## Agents
|
|
184
188
|
|
|
@@ -193,9 +197,16 @@ export const agent = createAgent({
|
|
|
193
197
|
|
|
194
198
|
Everything in `agent-ready.md` holds: `label` on `Root`, `Calendar.Frame` rendered, `detail.fields` read in `onEventChange`, `allowAgentDelete` for deletes, the same fifteen actions with one object each, the same results and errors. Only the import path differs.
|
|
195
199
|
|
|
196
|
-
##
|
|
200
|
+
## Keyboard, dragging and undo
|
|
201
|
+
|
|
202
|
+
`https://time.molten.sh/docs/solid/accessibility.md` has a month view with the keyboard ref, `https://time.molten.sh/docs/solid/interactions.md` a week view with the pointer ref, and `https://time.molten.sh/docs/solid/undo-redo.md` the undo buttons. In short:
|
|
203
|
+
|
|
204
|
+
- Give the strategy a `getSpatialNavigation`, such as `monthSpatialNavigation`, or the keys move nothing.
|
|
205
|
+
- Pass `useCalendarPointer` the Renderer's `events`, `actions.proposeEventChange` as `onPropose`, `isReadOnly` as `disabled` and the environment's `timeZone`. Three more options are optional: `actions.checkEventChange` as `check` marks a preview a policy would reject, `useCalendarAnnouncer()` as `announcer` says each drag to a screen reader, and `useCalendarDraftReporter()` as `onPreview` lets `useCalendarDraft` and `useDraftBusy` follow the drag. Render `data-date` on each day, `eventIdAttributes(id)` on each event and `data-resize="start"` or `"end"` on its handles.
|
|
206
|
+
- Render `<Calendar.Announcer messages={...} />` inside `Root`. The registry's `calendar/announcements.ts` has English messages; the packages ship none.
|
|
207
|
+
- Record results in `Root`'s `onEventChangeResult` with `history.record`, then bind `useCalendarHistory(history)` and `useCalendarHistoryShortcuts(controls, () => ({ scope: meta().refs.frame }))`. Pass `createdEventId` to `createEventHistory` so creates can be undone.
|
|
197
208
|
|
|
198
|
-
|
|
209
|
+
A person can also change an event through your own controls: call `actions.proposeEventChange(proposal)` from `Calendar.useCalendarActions()`. It runs the policies and `onEventChange` and resolves with the result. `changes.md` has the proposal's shape.
|
|
199
210
|
|
|
200
211
|
## Testing
|
|
201
212
|
|
package/docs/api/solid.md
DELETED
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
# Solid
|
|
2
|
-
|
|
3
|
-
The SolidJS 2 integration, a preview. What it has, how it differs from React, and what isn't in it yet.
|
|
4
|
-
|
|
5
|
-
Source: https://time.molten.sh/docs/api/solid
|
|
6
|
-
|
|
7
|
-
`@moltenship/calendar-solid` is the calendar for [SolidJS](https://www.solidjs.com) 2. It renders
|
|
8
|
-
the same [primitive](./primitives.md) as the React integration, so both share one
|
|
9
|
-
implementation of the calendar's state, actions, event changes and [agent surface](../agents.md).
|
|
10
|
-
|
|
11
|
-
> **A preview**
|
|
12
|
-
>
|
|
13
|
-
> This package is new in 2.0 and its API can change in any release before 2.0.0. It has the root,
|
|
14
|
-
> the structural parts, the read hooks and the agent surface. It has no ready-made views, no
|
|
15
|
-
> keyboard navigation and no dragging yet: see [what isn't in it yet](#what-isnt-in-it-yet). The
|
|
16
|
-
> rest of these docs describe React.
|
|
17
|
-
|
|
18
|
-
## Install
|
|
19
|
-
|
|
20
|
-
**pnpm**
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
pnpm add @moltenship/calendar-solid @moltenship/calendar-core solid-js @solidjs/web @ui-sdk/core @ui-sdk/solid
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**npm**
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install @moltenship/calendar-solid @moltenship/calendar-core solid-js @solidjs/web @ui-sdk/core @ui-sdk/solid
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**yarn**
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
yarn add @moltenship/calendar-solid @moltenship/calendar-core solid-js @solidjs/web @ui-sdk/core @ui-sdk/solid
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**bun**
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
bun add @moltenship/calendar-solid @moltenship/calendar-core solid-js @solidjs/web @ui-sdk/core @ui-sdk/solid
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
- **`@moltenship/calendar-core`** has the event adapter and the functions a view is made of. The
|
|
45
|
-
Solid package doesn't re-export them.
|
|
46
|
-
- **`solid-js` and `@solidjs/web`** 2.0, and **`@ui-sdk/core` and `@ui-sdk/solid`** from
|
|
47
|
-
`0.1.0-beta.16` on within the 0.1 line, are peer dependencies.
|
|
48
|
-
- **Don't install `@moltenship/calendar`.** It's the React package, and it doesn't re-export this
|
|
49
|
-
one.
|
|
50
|
-
- A runtime with `Temporal`, or a polyfill that defines `globalThis.Temporal`, loaded before the
|
|
51
|
-
calendar, and TypeScript 6 or later with `"lib": ["DOM", "DOM.Iterable", "ESNext"]`. Both are the
|
|
52
|
-
same as for React: see [Installation](../installation.md).
|
|
53
|
-
|
|
54
|
-
### Build setup
|
|
55
|
-
|
|
56
|
-
The integration is plain TypeScript, and `@ui-sdk/solid` ships JSX for your app's Solid compiler.
|
|
57
|
-
With Vite, use Solid's plugin:
|
|
58
|
-
|
|
59
|
-
```ts title="vite.config.ts"
|
|
60
|
-
import solid from "@solidjs/vite-plugin";
|
|
61
|
-
import { defineConfig } from "vite";
|
|
62
|
-
|
|
63
|
-
export default defineConfig({
|
|
64
|
-
plugins: [solid()],
|
|
65
|
-
optimizeDeps: {
|
|
66
|
-
// One copy of ui-sdk's core in the dev server. The calendar and the agent bridge find each
|
|
67
|
-
// other through it.
|
|
68
|
-
exclude: ["@ui-sdk/core"],
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
```json title="tsconfig.json"
|
|
74
|
-
{
|
|
75
|
-
"compilerOptions": {
|
|
76
|
-
"jsx": "preserve",
|
|
77
|
-
"jsxImportSource": "@solidjs/web",
|
|
78
|
-
"lib": ["ESNext", "DOM", "DOM.Iterable"]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
If the page fails with `React is not defined` from a file in `@ui-sdk/solid`, the plugin didn't
|
|
84
|
-
compile that package as Solid. Check that `@ui-sdk/solid` is in your app's own `dependencies`,
|
|
85
|
-
where the install command puts it.
|
|
86
|
-
|
|
87
|
-
## A calendar
|
|
88
|
-
|
|
89
|
-
There are no ready-made Solid views. A view is a strategy from `@moltenship/calendar-core` and a
|
|
90
|
-
Solid component that draws its projection. This one is the engine's list projection as an agenda:
|
|
91
|
-
|
|
92
|
-
```tsx title="calendar.tsx"
|
|
93
|
-
import {
|
|
94
|
-
defineEventAdapter,
|
|
95
|
-
getListRange,
|
|
96
|
-
getListTitle,
|
|
97
|
-
navigateList,
|
|
98
|
-
projectList,
|
|
99
|
-
type CalendarEventInterval,
|
|
100
|
-
type ListProjection,
|
|
101
|
-
type ListViewOptions,
|
|
102
|
-
} from "@moltenship/calendar-core";
|
|
103
|
-
import {
|
|
104
|
-
createCalendar,
|
|
105
|
-
defineCalendarView,
|
|
106
|
-
type CalendarViewRendererProps,
|
|
107
|
-
} from "@moltenship/calendar-solid";
|
|
108
|
-
import { For } from "solid-js";
|
|
109
|
-
|
|
110
|
-
export interface Meeting {
|
|
111
|
-
readonly id: string;
|
|
112
|
-
readonly title: string;
|
|
113
|
-
readonly interval: CalendarEventInterval;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const eventAdapter = defineEventAdapter<Meeting>()({
|
|
117
|
-
getId: (meeting) => meeting.id,
|
|
118
|
-
getTitle: (meeting) => meeting.title,
|
|
119
|
-
getInterval: (meeting) => meeting.interval,
|
|
120
|
-
getResourceIds: () => [],
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
type List = ListProjection<Meeting, string, string>;
|
|
124
|
-
|
|
125
|
-
// Props are getters in Solid: read `props.projection` in the JSX, and don't destructure it.
|
|
126
|
-
function Agenda(props: CalendarViewRendererProps<List, ListViewOptions>) {
|
|
127
|
-
const day = (date: Temporal.PlainDate) =>
|
|
128
|
-
date.toLocaleString(props.environment.locale, { dateStyle: "full" });
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<For each={props.projection.days} fallback={<p>Nothing in these weeks.</p>}>
|
|
132
|
-
{(entry) => (
|
|
133
|
-
<section>
|
|
134
|
-
<h3>{day(entry.date)}</h3>
|
|
135
|
-
<ul>
|
|
136
|
-
<For each={entry.items}>
|
|
137
|
-
{(item) => <li data-event-id={item.event.id}>{item.event.title}</li>}
|
|
138
|
-
</For>
|
|
139
|
-
</ul>
|
|
140
|
-
</section>
|
|
141
|
-
)}
|
|
142
|
-
</For>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const listView = defineCalendarView({
|
|
147
|
-
name: "list",
|
|
148
|
-
defaultOptions: { weeks: 2 } as ListViewOptions,
|
|
149
|
-
strategy: {
|
|
150
|
-
getRange: (anchor, environment, options) => getListRange(anchor, environment, options),
|
|
151
|
-
getTitle: (range, environment) => getListTitle(range, environment),
|
|
152
|
-
navigate: (anchor, delta, options) => navigateList(anchor, delta, options),
|
|
153
|
-
project: (input) => projectList(input) as List,
|
|
154
|
-
},
|
|
155
|
-
Renderer: Agenda,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
export const Calendar = createCalendar<Meeting>()({ eventAdapter, views: [listView] });
|
|
159
|
-
|
|
160
|
-
export type View = (typeof Calendar.views)[number]["name"];
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
`Root` takes your events and the handler that saves a change, as in React. Events live in a
|
|
164
|
-
signal of yours, and the calendar never stores them:
|
|
165
|
-
|
|
166
|
-
```tsx title="app.tsx"
|
|
167
|
-
import type { CalendarProposalDetail, CalendarWeekRules } from "@moltenship/calendar-core";
|
|
168
|
-
import { createSignal } from "solid-js";
|
|
169
|
-
|
|
170
|
-
import { Calendar, type Meeting } from "./calendar";
|
|
171
|
-
|
|
172
|
-
const timeZone = "Europe/Berlin";
|
|
173
|
-
const at = (value: string) =>
|
|
174
|
-
Temporal.PlainDateTime.from(value).toZonedDateTime(timeZone).toInstant();
|
|
175
|
-
|
|
176
|
-
const seed: readonly Meeting[] = [
|
|
177
|
-
{
|
|
178
|
-
id: "standup",
|
|
179
|
-
title: "Standup",
|
|
180
|
-
interval: { kind: "timed", start: at("2026-10-08T09:00"), end: at("2026-10-08T09:30") },
|
|
181
|
-
},
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
const weekRules: CalendarWeekRules = { firstDay: 1, minimalDays: 4, weekend: [6, 7] };
|
|
185
|
-
|
|
186
|
-
// A title an agent sent with `createEvent` or `updateEvent`. A person's gesture sends none.
|
|
187
|
-
function titleFrom(detail: CalendarProposalDetail): string | undefined {
|
|
188
|
-
const title = detail.fields?.title;
|
|
189
|
-
return typeof title === "string" && title.trim() !== "" ? title.trim() : undefined;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export function App() {
|
|
193
|
-
const [meetings, setMeetings] = createSignal<readonly Meeting[]>(seed);
|
|
194
|
-
|
|
195
|
-
return (
|
|
196
|
-
<Calendar.Root
|
|
197
|
-
label="Team calendar"
|
|
198
|
-
events={meetings()}
|
|
199
|
-
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
|
|
200
|
-
defaultTimeZone={timeZone}
|
|
201
|
-
locale="en-US"
|
|
202
|
-
weekRules={weekRules}
|
|
203
|
-
onEventChange={(change, detail) => {
|
|
204
|
-
const title = titleFrom(detail);
|
|
205
|
-
if (change.cause === "delete") {
|
|
206
|
-
setMeetings((current) => current.filter((meeting) => meeting.id !== change.eventId));
|
|
207
|
-
} else if (change.cause === "create") {
|
|
208
|
-
setMeetings((current) => [
|
|
209
|
-
...current,
|
|
210
|
-
{ id: crypto.randomUUID(), title: title ?? "New meeting", interval: change.proposed },
|
|
211
|
-
]);
|
|
212
|
-
} else {
|
|
213
|
-
setMeetings((current) =>
|
|
214
|
-
current.map((meeting) =>
|
|
215
|
-
meeting.id === change.eventId
|
|
216
|
-
? { ...meeting, title: title ?? meeting.title, interval: change.proposed }
|
|
217
|
-
: meeting,
|
|
218
|
-
),
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
<Calendar.Frame>
|
|
224
|
-
<Calendar.Toolbar>
|
|
225
|
-
<Calendar.PreviousTrigger>Previous</Calendar.PreviousTrigger>
|
|
226
|
-
<Calendar.TodayTrigger>Today</Calendar.TodayTrigger>
|
|
227
|
-
<Calendar.NextTrigger>Next</Calendar.NextTrigger>
|
|
228
|
-
<Calendar.Title />
|
|
229
|
-
</Calendar.Toolbar>
|
|
230
|
-
<Calendar.Viewport>
|
|
231
|
-
<Calendar.ActiveView />
|
|
232
|
-
</Calendar.Viewport>
|
|
233
|
-
</Calendar.Frame>
|
|
234
|
-
</Calendar.Root>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
A page of this site is a React app, so this example isn't live here. The repository's
|
|
240
|
-
[`apps/demo-solid`](https://github.com/Moltenship/time/tree/main/apps/demo-solid) is a running
|
|
241
|
-
Solid calendar with a month grid, an agenda and an agent panel.
|
|
242
|
-
|
|
243
|
-
## What it exports
|
|
244
|
-
|
|
245
|
-
| Export | What it is |
|
|
246
|
-
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
247
|
-
| `createCalendar<TEvent, TResource, TSelection, TFocus>()(options)` | The factory. Takes `eventAdapter`, `views` and `invalidEventPolicy`, as [React's](./react.md#createcalendar) does |
|
|
248
|
-
| `defineCalendarView({ name, defaultOptions, strategy, Renderer })` | A view. `Renderer` is a Solid component |
|
|
249
|
-
| `createStateSelector(source, selector, options?)` | An accessor of one value of a store |
|
|
250
|
-
| `createCalendarStore(options)` | The [state store](./store.md). The same function `@moltenship/calendar` exports |
|
|
251
|
-
| `resolveViewOptions(view, overrides)` | A view's options: its `defaultOptions` with a root's `viewOptions` over them |
|
|
252
|
-
|
|
253
|
-
It also exports the types of all of these, and the state types: `CalendarPublicState`,
|
|
254
|
-
`CalendarActions`, `CalendarStore`, `CalendarStateChangeDetail`, `CalendarCommandOptions` and the
|
|
255
|
-
others [Primitives](./primitives.md#what-it-exports) lists.
|
|
256
|
-
|
|
257
|
-
## The factory
|
|
258
|
-
|
|
259
|
-
`createCalendar` returns the parts and hooks for your record types.
|
|
260
|
-
|
|
261
|
-
### Parts
|
|
262
|
-
|
|
263
|
-
| Part | Renders | Notes |
|
|
264
|
-
| ----------------- | ----------- | ------------------------------------------------------------------------------------------ |
|
|
265
|
-
| `Root` | nothing | Provides the calendar. Its props are the ones [React's `Root`](./react.md#root) takes |
|
|
266
|
-
| `Frame` | `<section>` | Named by `Root`'s `label`, or by the title without one. An agent finds the calendar here |
|
|
267
|
-
| `Toolbar` | `<header>` | |
|
|
268
|
-
| `Title` | `<span>` | The visible dates, from the view's `getTitle` |
|
|
269
|
-
| `PreviousTrigger` | `<button>` | Needs children or an `aria-label` |
|
|
270
|
-
| `NextTrigger` | `<button>` | Needs children or an `aria-label` |
|
|
271
|
-
| `TodayTrigger` | `<button>` | Needs children or an `aria-label` |
|
|
272
|
-
| `ViewSwitcher` | `<select>` | One option per view. Requires `getViewLabel(name)` |
|
|
273
|
-
| `Viewport` | `<div>` | Wrapper for the view |
|
|
274
|
-
| `ActiveView` | view output | Renders the active view's `Renderer`, or `fallback` if the view isn't registered |
|
|
275
|
-
|
|
276
|
-
Each part has the `data-calendar-part` attribute React's has, so CSS written for one works for the
|
|
277
|
-
other. The parts take the element's own props, in Solid's spelling: `class`, not `className`.
|
|
278
|
-
|
|
279
|
-
`Root`'s props have the same names, types and defaults as in React, the agent's `label`,
|
|
280
|
-
`allowAgentDelete` and `formatAgentEventLabel` included. Pass a signal's value for a prop that
|
|
281
|
-
changes: `events={meetings()}`, `view={view()}`.
|
|
282
|
-
|
|
283
|
-
### Hooks
|
|
284
|
-
|
|
285
|
-
Call them in a component inside `Root`. Where React's hook returns a value, Solid's returns an
|
|
286
|
-
accessor:
|
|
287
|
-
|
|
288
|
-
| Hook | Returns |
|
|
289
|
-
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
290
|
-
| `useCalendarState()` | `Accessor` of the six state values |
|
|
291
|
-
| `useCalendarSelector(selector, options?)` | `Accessor` of one value from the state. Re-runs readers only when it changes by `options.isEqual` |
|
|
292
|
-
| `useCalendarActions()` | The actions, as an object. Stable for the root's lifetime |
|
|
293
|
-
| `useCalendarMeta()` | `Accessor` of the meta: `label`, `environment`, `eventSnapshot`, `views`, `diagnostics`, `ids`, `refs` |
|
|
294
|
-
| `useVisibleRange()` | `Accessor` of the visible dates, or `null` |
|
|
295
|
-
| `useViewProjection()` | `Accessor` of the active view and its projection, or `null` |
|
|
296
|
-
| `useCalendarPendingChanges(selector?)` | `Accessor` of the changes being saved, or of what `selector` picks from them |
|
|
297
|
-
| `useCalendar()` | `{ actions, meta, state }`. `meta` and `state` are getters |
|
|
298
|
-
|
|
299
|
-
```tsx title="status.tsx"
|
|
300
|
-
import { Calendar } from "./calendar";
|
|
301
|
-
|
|
302
|
-
// Render it inside <Calendar.Root>.
|
|
303
|
-
export function Status() {
|
|
304
|
-
const state = Calendar.useCalendarState();
|
|
305
|
-
const range = Calendar.useVisibleRange();
|
|
306
|
-
const view = Calendar.useCalendarSelector((current) => current.view);
|
|
307
|
-
const saving = Calendar.useCalendarPendingChanges((changes) => changes.size > 0);
|
|
308
|
-
const actions = Calendar.useCalendarActions();
|
|
309
|
-
|
|
310
|
-
return (
|
|
311
|
-
<p>
|
|
312
|
-
{view()} from {range()?.start.toString()}, anchored on {state().anchorDate.toString()}
|
|
313
|
-
{saving() ? ", saving" : ""}
|
|
314
|
-
<button type="button" onClick={() => actions.navigateToday()}>
|
|
315
|
-
Today
|
|
316
|
-
</button>
|
|
317
|
-
</p>
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
## Differences from React
|
|
323
|
-
|
|
324
|
-
| In React | In Solid |
|
|
325
|
-
| -------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
326
|
-
| Hooks return values | Hooks return accessors: `state().view`, not `state.view` |
|
|
327
|
-
| `useCalendar()` returns plain objects | `meta` and `state` are getters. Read them in JSX, a memo or an effect, and don't destructure them |
|
|
328
|
-
| A `Renderer` gets props you can destructure | A `Renderer`'s props are getters: `props.projection`, read where it's used |
|
|
329
|
-
| `meta.refs` holds React refs | `meta.refs` holds accessors: `meta().refs.viewport()` |
|
|
330
|
-
| A state change is visible on the next render | An accessor has the new value once Solid flushes: a microtask later, or after `flush()` |
|
|
331
|
-
| `@moltenship/calendar` is the one package | `@moltenship/calendar-solid` and `@moltenship/calendar-core` |
|
|
332
|
-
| The bridge is `@ui-sdk/react/agent` | The bridge is `@ui-sdk/solid/agent` |
|
|
333
|
-
|
|
334
|
-
What doesn't differ: the [state model](../concepts/state.md), controlled and uncontrolled props,
|
|
335
|
-
[change handlers](../concepts/state.md#what-a-handler-hears), `onEventChange` and
|
|
336
|
-
`onEventChangeResult`, [policies](./changes.md), pending changes, and every agent action.
|
|
337
|
-
|
|
338
|
-
## A store outside Root
|
|
339
|
-
|
|
340
|
-
`createStateSelector` reads one value of a store as an accessor, for a component outside `Root`:
|
|
341
|
-
|
|
342
|
-
```tsx title="store.tsx"
|
|
343
|
-
import { createCalendarStore, createStateSelector } from "@moltenship/calendar-solid";
|
|
344
|
-
|
|
345
|
-
import type { View } from "./calendar";
|
|
346
|
-
|
|
347
|
-
export const store = createCalendarStore<View>({
|
|
348
|
-
defaultView: "list",
|
|
349
|
-
defaultAnchorDate: Temporal.PlainDate.from("2026-10-08"),
|
|
350
|
-
defaultTimeZone: "Europe/Berlin",
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// An accessor of one value, for a component outside <Calendar.Root store={store}>.
|
|
354
|
-
export function AnchorDate() {
|
|
355
|
-
const anchorDate = createStateSelector(store, (state) => state.anchorDate, {
|
|
356
|
-
isEqual: (a, b) => a.equals(b),
|
|
357
|
-
});
|
|
358
|
-
return <time>{anchorDate().toString()}</time>;
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
Pass the store to `Root` as `store={store}`, and `store.actions.setAnchorDate(date)` moves the
|
|
363
|
-
calendar from anywhere. The store's view type has to be the calendar's, and so do its selection
|
|
364
|
-
and focus types if you changed them. A calendar without resources takes a store made without the
|
|
365
|
-
resource ID type, as here. [State store](./store.md) has the rest.
|
|
366
|
-
|
|
367
|
-
## Agents
|
|
368
|
-
|
|
369
|
-
The agent surface is the primitive's, so it's the same fifteen actions with the same inputs,
|
|
370
|
-
results and errors as in React: see the [agent reference](../agents/reference.md). The bridge
|
|
371
|
-
comes from ui-sdk's Solid package.
|
|
372
|
-
|
|
373
|
-
```ts title="agent.ts"
|
|
374
|
-
import { createAgent } from "@ui-sdk/solid/agent";
|
|
375
|
-
|
|
376
|
-
// One bridge for the page, created before the app renders.
|
|
377
|
-
export const agent = createAgent({
|
|
378
|
-
// Reading, navigation and changes run. A delete doesn't, until your app asks the person.
|
|
379
|
-
allow: (step) => step.action !== "deleteEvent",
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
export async function moveStandup() {
|
|
383
|
-
const outcome = await agent.act({
|
|
384
|
-
steps: [
|
|
385
|
-
{
|
|
386
|
-
ref: "Team calendar",
|
|
387
|
-
action: "moveEvent",
|
|
388
|
-
// Every action takes one object.
|
|
389
|
-
args: [{ eventId: "standup", start: "2026-10-09T11:00" }],
|
|
390
|
-
},
|
|
391
|
-
],
|
|
392
|
-
});
|
|
393
|
-
if (!outcome.ok) {
|
|
394
|
-
return outcome.error?.message ?? "failed";
|
|
395
|
-
}
|
|
396
|
-
// The change the calendar made of the step: `{ changeId, cause, eventId, proposed, status }`.
|
|
397
|
-
return JSON.stringify(outcome.steps[0]?.result);
|
|
398
|
-
}
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
With the calendar above, `moveStandup()` calls your `onEventChange` with `detail.input` equal to
|
|
402
|
-
`"agent"`, the standup shows on October 9, and the function returns the change:
|
|
403
|
-
|
|
404
|
-
```json
|
|
405
|
-
{
|
|
406
|
-
"cause": "move",
|
|
407
|
-
"changeId": "change-1",
|
|
408
|
-
"eventId": "standup",
|
|
409
|
-
"proposed": {
|
|
410
|
-
"end": "2026-10-09T11:30:00+02:00",
|
|
411
|
-
"kind": "timed",
|
|
412
|
-
"resourceIds": [],
|
|
413
|
-
"start": "2026-10-09T11:00:00+02:00"
|
|
414
|
-
},
|
|
415
|
-
"status": "saved"
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
`status` is `"saved"` because this handler saves synchronously. A handler that returns a promise
|
|
420
|
-
gives `"saving"`, and the agent reads how it ended with `getChange`: see
|
|
421
|
-
[What a step returns](../agents.md#what-a-step-returns).
|
|
422
|
-
|
|
423
|
-
- **Create the bridge before the app renders.** Import its module before the one that calls
|
|
424
|
-
`render`.
|
|
425
|
-
- **Give `Root` a `label` and render `Calendar.Frame`.** An agent finds the calendar by the label,
|
|
426
|
-
and a calendar without a frame isn't listed.
|
|
427
|
-
- **Read `detail.fields` in `onEventChange`.** An agent's `createEvent` and `updateEvent` send the
|
|
428
|
-
title there, and the calendar doesn't store it for you. The `App` above does this with
|
|
429
|
-
`titleFrom`. See [Save what the agent sent](../agents/connect.md#save-what-the-agent-sent).
|
|
430
|
-
- **A calendar has `deleteEvent` only when `Root` has `allowAgentDelete`.** Without it the action
|
|
431
|
-
isn't among the calendar's, a step that asks for it fails whatever `allow` returns, and a delete
|
|
432
|
-
an agent causes by pressing a button of yours is refused.
|
|
433
|
-
|
|
434
|
-
The [Agents](../agents.md) guides show React. The bridge's API (`createAgent`, `snapshot`, `act`,
|
|
435
|
-
`agentTools`, `registerTools`) and everything about the calendar's actions carry over; only the
|
|
436
|
-
import path changes.
|
|
437
|
-
|
|
438
|
-
## What isn't in it yet
|
|
439
|
-
|
|
440
|
-
| Missing | In React it's |
|
|
441
|
-
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
442
|
-
| Ready-made views | The [registry](../installation.md)'s week, day, month, year, agenda and timeline views, which are React source |
|
|
443
|
-
| Keyboard navigation inside a view | `useCalendarKeyboard`, `useRovingFocus`, `useCalendarFocus` |
|
|
444
|
-
| Dragging, resizing and creating with a pointer | `@moltenship/calendar-dnd` and the hooks that bind it |
|
|
445
|
-
| Gesture previews | `useCalendarDraft`, `useCalendarInteraction` |
|
|
446
|
-
| Undo and redo bindings | `useCalendarHistory`, `useCalendarHistoryShortcuts` |
|
|
447
|
-
| Announcements for screen readers | `Calendar.Announcer`, `useCalendarAnnouncer` |
|
|
448
|
-
| `Calendar.Event` | A part that looks up one event |
|
|
449
|
-
| Hooks for selection, annotations, availability, resources and the clock | `useCalendarSelection`, `useCalendarAnnotations`, `useCalendarAvailability`, `useVisibleResources`, `useNow` and others |
|
|
450
|
-
| A testing package | `@moltenship/calendar-testing`, which is React only |
|
|
451
|
-
|
|
452
|
-
`Root` already takes the props behind some of these: `annotations`, `availability`, `resources`,
|
|
453
|
-
`selection` and `focus`. The calendar validates them, policies get `availability`, and `selection`
|
|
454
|
-
and `focus` are state values you can read and set. What's missing is the hooks that hand
|
|
455
|
-
annotations, availability and the resource tree to a view, and the behaviour built on them.
|
|
456
|
-
|
|
457
|
-
Until they land, a Solid calendar is navigated and changed with its toolbar, with your own
|
|
458
|
-
controls calling `actions`, and by an agent. Events change through
|
|
459
|
-
`actions.proposeEventChange(proposal)`, which runs your policies and `onEventChange` as a drag
|
|
460
|
-
does in React.
|