@moltenship/calendar-primitives 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 CHANGED
@@ -17,7 +17,7 @@ create, update, move, resize and delete events. Each action takes one JSON objec
17
17
  action returns the change with how it ended. An agent's change says it came from an agent
18
18
  (`input: "agent"`) and goes through the same policies and `onEventChange` as any other, so the app
19
19
  can refuse it. The app creates the bridge; this package never does. See
20
- [Agents](https://time.molten.sh/docs/agents).
20
+ [Agents](https://time.molten.sh/docs/react/agents).
21
21
 
22
22
  The dates, time zones, recurrence, layouts and policies stay in the calendar's own engine
23
23
  (`@moltenship/calendar-core` and `@moltenship/calendar-temporal`). This package imports no UI
@@ -39,8 +39,8 @@ pnpm add @moltenship/calendar-primitives @ui-sdk/core
39
39
 
40
40
  ## Documentation
41
41
 
42
- - [Primitives](https://time.molten.sh/docs/api/primitives)
43
- - [Agent reference](https://time.molten.sh/docs/agents/reference)
42
+ - [Primitives](https://time.molten.sh/docs/react/api/primitives)
43
+ - [Agent reference](https://time.molten.sh/docs/react/agents/reference)
44
44
  - [Repository](https://github.com/Moltenship/time)
45
45
 
46
46
  ## License
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { CalendarClock, InstantInterval, PlainDateInterval } from "@moltenship/calendar-temporal";
2
- import { AnnotationSnapshot, AnnotationSnapshotIssue, AvailabilityIssue, AvailabilitySnapshot, CalendarAnnotation, CalendarAnnotationSource, CalendarAnnouncementContext, CalendarAnnouncementMessages, CalendarAnnouncer, CalendarAvailability, CalendarCellFocus, CalendarChangeCause, CalendarDraft, CalendarEnvironment, CalendarEnvironmentBase, CalendarEventChangeHandler, CalendarEventPlacement, CalendarEventProposal, CalendarFocus, CalendarInteractionCheck, CalendarKeyboardSession, CalendarNowSource, CalendarPendingChanges, CalendarPendingPlacements, CalendarPolicy, CalendarPolicyResult, CalendarProposalDetail, CalendarProposalOutcome, CalendarSecondaryTimeZone, CalendarSelection, CalendarTransactionResult, CalendarViewStrategy, CalendarWeekRules, EventAdapter, EventId, EventSnapshot, EventSnapshotIssue, EventTransactions, InvalidCalendarEventPolicy, NormalizedCalendarEvent, ResourceId, ResourceTree, SecondaryTimeZoneIssue } from "@moltenship/calendar-core";
1
+ import { CalendarClock, InstantInterval, PlainDateInterval, WallTimeSnapOptions } from "@moltenship/calendar-temporal";
2
+ import { AnnotationSnapshot, AnnotationSnapshotIssue, AvailabilityIssue, AvailabilitySnapshot, CalendarAnnotation, CalendarAnnotationSource, CalendarAnnouncementContext, CalendarAnnouncementMessages, CalendarAnnouncer, CalendarAvailability, CalendarCellFocus, CalendarChangeCause, CalendarDraft, CalendarEnvironment, CalendarEnvironmentBase, CalendarEventChangeHandler, CalendarEventInterval, CalendarEventPlacement, CalendarEventProposal, CalendarFocus, CalendarInputMethod, CalendarInteractionCheck, CalendarKeyboardSession, CalendarNowSource, CalendarPendingChanges, CalendarPendingPlacements, CalendarPolicy, CalendarPolicyResult, CalendarProposalDetail, CalendarProposalOutcome, CalendarSecondaryTimeZone, CalendarSelection, CalendarTransactionResult, CalendarViewStrategy, CalendarWeekRules, EventAdapter, EventHistory, EventHistoryOutcome, EventHistorySnapshot, EventId, EventSnapshot, EventSnapshotIssue, EventTransactions, InvalidCalendarEventPolicy, NormalizedCalendarEvent, ResourceId, ResourceStatus, ResourceTree, SecondaryTimeZoneIssue } from "@moltenship/calendar-core";
3
3
  import { PrimitiveInstance, PropSpec, SlotDefinition } from "@ui-sdk/core";
4
4
  interface CalendarPublicState<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> {
5
5
  readonly anchorDate: Temporal.PlainDate;
@@ -232,6 +232,17 @@ interface AnnouncerChannel {
232
232
  }
233
233
  /** `getEnvironment` and `getResources` read the root's last commit when an update arrives. */
234
234
  export declare function createAnnouncerChannel(getEnvironment: () => Pick<CalendarEnvironmentBase, "locale" | "timeZone">, getResources: () => ResourceTree): AnnouncerChannel;
235
+ /**
236
+ * The text of a mounted live region, as a store: pass `speak` to `AnnouncerChannel.mount` and
237
+ * render the snapshot as the region's text. A message that repeats the last one gets a trailing
238
+ * no-break space, so the region changes and a screen reader reads it again. Empty until something
239
+ * is said, on the server too.
240
+ */
241
+ interface AnnouncerLiveText extends CalendarStateSource<string> {
242
+ readonly speak: (text: string) => void;
243
+ }
244
+ /** Creates the text of one mounted live region; see `AnnouncerLiveText`. */
245
+ export declare function createAnnouncerLiveText(): AnnouncerLiveText;
235
246
  type CalendarSemanticActions<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId, TEvent = unknown, TEventId extends EventId = EventId> = CalendarActions<TView, TSelection, TFocus, TResourceId> & {
236
247
  navigateNext(options?: CalendarCommandOptions): void;
237
248
  navigatePrevious(options?: CalendarCommandOptions): void;
@@ -295,46 +306,6 @@ interface CalendarVisibleRange<TView extends string = string> {
295
306
  readonly range: PlainDateInterval;
296
307
  readonly view: TView;
297
308
  }
298
- /** The clock a root reads when it has neither `now` nor `clock`. */
299
- export declare const systemClock: CalendarClock;
300
- /** How often a root samples its clock for `today`. */
301
- export declare const TODAY_SAMPLE_INTERVAL_MS = 6e4;
302
- interface CalendarClockTicker {
303
- /** The last sample, taken now if there is none yet. */
304
- readonly getSnapshot: () => Temporal.Instant;
305
- /**
306
- * Samples at once and then every interval, calling `onChange` when the instant moved; returns
307
- * the cleanup that stops the timer.
308
- */
309
- readonly subscribe: (onChange: () => void) => () => void;
310
- }
311
- /** Samples `clock` every `intervalMs` while subscribed. */
312
- export declare function createClockTicker(clock: CalendarClock, intervalMs: number): CalendarClockTicker;
313
- /** The clock a source samples: its own, or the system's. */
314
- export declare function clockOf(source: CalendarNowSource | undefined): CalendarClock;
315
- type AnyDraft = CalendarDraft<EventId, ResourceId>;
316
- /** The pointer's draft, which the pointer layer reports to the root while a drag previews a change. */
317
- interface DraftStore extends CalendarStateSource<AnyDraft | null> {
318
- readonly set: (draft: AnyDraft | null) => void;
319
- }
320
- export declare function createDraftStore(): DraftStore;
321
- export declare function sameElements<T>(left: readonly T[], right: readonly T[]): boolean;
322
- /** Compares own enumerable properties with `Object.is`; non-objects compare with `Object.is`. */
323
- export declare function shallowEqual<T>(left: T, right: T): boolean;
324
- export declare function samePlainDate(left: Temporal.PlainDate | null | undefined, right: Temporal.PlainDate | null | undefined): boolean;
325
- export declare function sameInstant(left: Temporal.Instant | undefined, right: Temporal.Instant | undefined): boolean;
326
- export declare function sameRange(left: PlainDateInterval | undefined, right: PlainDateInterval | undefined): boolean;
327
- export declare function sameWeekRules(left: CalendarWeekRules, right: CalendarWeekRules): boolean;
328
- /**
329
- * Compares working hours by value, so an inline `availability` keeps its shading cached. Invalid
330
- * entries never throw here; the snapshot reports them.
331
- */
332
- export declare function sameAvailability(left: CalendarAvailability | undefined, right: CalendarAvailability | undefined): boolean;
333
- /**
334
- * Compares secondary time zones by value, so an inline list keeps the environment as it is. A
335
- * single zone passed where a list belongs, which the root reports, compares by value too.
336
- */
337
- export declare function sameSecondaryTimeZones(left: readonly (CalendarSecondaryTimeZone | string)[], right: readonly (CalendarSecondaryTimeZone | string)[]): boolean;
338
309
  /** A keyboard session with what it needs to restart, restore focus, and announce itself. */
339
310
  interface KeyboardGrab {
340
311
  /** The cell the grabbed event sits in, or where a create started. */
@@ -358,6 +329,68 @@ interface KeyboardSessionStore {
358
329
  readonly subscribe: (listener: () => void) => () => void;
359
330
  }
360
331
  export declare function createKeyboardSessionStore(): KeyboardSessionStore;
332
+ type AnyDraft = CalendarDraft<EventId, ResourceId>;
333
+ /** The pointer's draft, which the pointer layer reports to the root while a drag previews a change. */
334
+ interface DraftStore extends CalendarStateSource<AnyDraft | null> {
335
+ readonly set: (draft: AnyDraft | null) => void;
336
+ }
337
+ export declare function createDraftStore(): DraftStore;
338
+ /**
339
+ * Where focus enters the active view: its default entry (`"home"`), or its last target (`"end"`),
340
+ * as focus does after paging back. `calendarViewEntry` gives a view's.
341
+ */
342
+ type CalendarRovingEntry = (command: "end" | "home") => CalendarFocus | null;
343
+ /**
344
+ * The elements of the active view that can take focus. Exactly one is the tab stop: the focused
345
+ * one, else the view's entry, else the first in document order, so the view stays reachable when
346
+ * focus is on something it does not render. Before any element registers, as on the server and
347
+ * while hydrating, the entry is the tab stop: whether the view renders the focus is only known
348
+ * once its elements register.
349
+ */
350
+ interface RovingFocusStore {
351
+ /** Enters the next range from its end, after paging back, until something takes focus. */
352
+ readonly enterFromEnd: () => void;
353
+ /** Moves DOM focus to the tab stop, now or after the next `update`. */
354
+ readonly focusTabStop: (when: "now" | "after-update") => void;
355
+ /** The focus a key pressed on `node` moves from. */
356
+ readonly focusAt: (node: Node) => CalendarFocus | null;
357
+ /** Whether the element showing `target` across `days` dates is the tab stop. */
358
+ readonly isTabStop: (target: CalendarFocus, days: number) => boolean;
359
+ /**
360
+ * Adds an element that shows `target` across `days` dates; returns the cleanup that removes it.
361
+ * Elements a commit registers one by one are told about once, after it, in a microtask.
362
+ */
363
+ readonly register: (element: HTMLElement, target: CalendarFocus, days: number) => () => void;
364
+ /** Tells `listener` when the tab stop may have moved. */
365
+ readonly subscribe: (listener: () => void) => () => void;
366
+ /**
367
+ * Follows the root's focus and the active view's entry. Call it once the elements of a render
368
+ * have registered, so DOM focus can move to one of them.
369
+ */
370
+ readonly update: (focus: CalendarFocus | null, getEntry: CalendarRovingEntry) => void;
371
+ }
372
+ /** The active view's entry points, from its spatial navigation with no focus. */
373
+ export declare function calendarViewEntry(view: CalendarActiveView<AnyCalendarViewDefinition> | null): CalendarRovingEntry;
374
+ /**
375
+ * The focus plumbing of one rendered active view: `getView` reads the latest active view, and the
376
+ * roving store starts from the view `getView` returns now, so server markup gets its tab stop.
377
+ * Keep the store on the root's focus with `roving.update(focus, calendarViewEntry(view))` after
378
+ * the view's elements register.
379
+ */
380
+ export declare function createCalendarViewRuntime(getView: () => CalendarActiveView<AnyCalendarViewDefinition> | null): CalendarViewRuntime;
381
+ /**
382
+ * A key for a focus target that changes exactly when the target does, for an integration that
383
+ * registers an element again when its target changes. `1` and `"1"` are distinct IDs, and `null`
384
+ * (unassigned) differs from no resource.
385
+ */
386
+ export declare function calendarFocusKey(target: CalendarFocus): string;
387
+ /**
388
+ * What an element showing `target` across `days` dates does when it takes DOM focus itself (call
389
+ * it only when the focus event's target is that element): it becomes the calendar's focus. Focus
390
+ * already on it stays as it is, keeping an event's date within the element. `event`, the focus
391
+ * event, reaches the state handlers, so they hear the click or key that moved focus.
392
+ */
393
+ export declare function focusRovingTarget({ actions, read }: Pick<CalendarInteractionRuntime, "actions" | "read">, target: CalendarFocus, days: number, event: Event): void;
361
394
  interface CalendarStoreBinding<TView extends string, TSelection, TFocus, TResourceId extends ResourceId> {
362
395
  readonly controlled: CalendarControlledState<TView, TSelection, TFocus, TResourceId>;
363
396
  readonly handlers: CalendarStateChangeHandlers<TView, TSelection, TFocus, TResourceId>;
@@ -404,6 +437,12 @@ interface CalendarInteractionRuntime {
404
437
  readonly announcements: AnnouncerChannel;
405
438
  /** The root's pending changes, which an event history waits out before it undoes. */
406
439
  readonly changes: CalendarStateSource<AnyPendingChanges>;
440
+ /**
441
+ * The change being drafted, by keyboard or pointer: the keyboard's session while one is in
442
+ * progress, else the pointer's draft. A keyboard session's draft keeps its identity for as long
443
+ * as the session does.
444
+ */
445
+ readonly draft: CalendarStateSource<CalendarDraft<EventId, ResourceId> | null>;
407
446
  /** The root has no `onEventChange`, so it rejects every change and views start no gestures. */
408
447
  readonly isReadOnly: boolean;
409
448
  readonly keyboard: KeyboardSessionStore;
@@ -424,6 +463,251 @@ interface CalendarInteractionRuntime {
424
463
  /** For subscribing; its identity changes with controlled values. */
425
464
  readonly source: CalendarStateSource<AnyCalendarState>;
426
465
  }
466
+ /**
467
+ * The active view's focus plumbing, which an integration creates once per rendered active view
468
+ * (`createCalendarViewRuntime`) and hands to the view's keyboard and focusable elements.
469
+ */
470
+ interface CalendarViewRuntime {
471
+ /** The latest active view, read when a key is handled; `null` once none is registered. */
472
+ readonly getView: () => CalendarActiveView<AnyCalendarViewDefinition> | null;
473
+ /** The view's focusable elements and its one tab stop. */
474
+ readonly roving: RovingFocusStore;
475
+ }
476
+ /**
477
+ * Calls `listener` whenever something asks the root for an anchor date, until the returned
478
+ * cleanup runs: Previous, Next, Today, keys paging past the view, or `setAnchorDate`, even a date
479
+ * that is already the anchor. `range` is what the view on screen shows for that date (`null`
480
+ * without one), so a view can tell a request for the range it has, as Today in this week, from
481
+ * one that moves it.
482
+ */
483
+ export declare function subscribeAnchorDateRequests({ rangeOf, requests }: Pick<CalendarInteractionRuntime, "rangeOf" | "requests">, listener: (date: Temporal.PlainDate, range: PlainDateInterval | null) => void): () => void;
484
+ /** The busy resources of a range, with the events that make them busy; see `busyResources`. */
485
+ type CalendarBusyResources = ReadonlyMap<ResourceId, readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[]>;
486
+ /** A resource during the draft's time; see `useDraftBusy`. */
487
+ interface CalendarDraftBusy {
488
+ /** The busy events that overlap the draft, by start; empty when the resource is free. */
489
+ readonly events: readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[];
490
+ /** Whether the draft falls outside the resource's hours. */
491
+ readonly outsideHours: boolean;
492
+ }
493
+ /** What a busy-resources query asks about a range, besides the range. */
494
+ interface CalendarBusyResourcesQuery {
495
+ /** An event left out, such as the one being moved; `null` and `undefined` leave none out. */
496
+ readonly exclude?: EventId | null;
497
+ /** The resources asked about; every resource by default. */
498
+ readonly resourceIds?: readonly ResourceId[];
499
+ /** The display time zone, which all-day and floating events count on. */
500
+ readonly timeZone: string;
501
+ }
502
+ /** The time a busy-resources query asks about: an instant range, or an event's interval. */
503
+ type BusyRange = InstantInterval | CalendarEventInterval;
504
+ /**
505
+ * A memoized query for the resources busy during a range, with their events; free ones are
506
+ * absent. Call it with the root's events, pending changes included, as often as a framework
507
+ * renders: it queries again only when the events, the range or the query change, the range and
508
+ * the resource IDs by value, so ones made inline cost nothing. A `null` range asks nothing.
509
+ */
510
+ export declare function createBusyResourcesQuery(): (events: AnyEvents, range: BusyRange | null, query: CalendarBusyResourcesQuery) => CalendarBusyResources;
511
+ /**
512
+ * One resource's query of the draft (`CalendarInteractionRuntime.draft`): the busy events that
513
+ * overlap the draft's time, the draft's own event aside, and whether the time falls outside the
514
+ * resource's hours; `null` without a draft, or for a `null` resource. The draft's busy resources
515
+ * are worked out once per draft and events for every resource that asks, and the result keeps its
516
+ * identity while the answer is the same, so a framework re-renders only when it changes.
517
+ */
518
+ export declare function createDraftBusyQuery(): (draft: AnyDraft | null, events: AnyEvents, availability: AvailabilitySnapshot, resourceId: ResourceId | null) => CalendarDraftBusy | null;
519
+ /** The clock a root reads when it has neither `now` nor `clock`. */
520
+ export declare const systemClock: CalendarClock;
521
+ /** How often a root samples its clock for `today`. */
522
+ export declare const TODAY_SAMPLE_INTERVAL_MS = 6e4;
523
+ interface CalendarClockTicker {
524
+ /** The last sample, taken now if there is none yet. */
525
+ readonly getSnapshot: () => Temporal.Instant;
526
+ /**
527
+ * Samples at once, and then every interval while anyone is subscribed, calling every
528
+ * subscriber when the instant moved; returns the cleanup that ends this subscription.
529
+ */
530
+ readonly subscribe: (onChange: () => void) => () => void;
531
+ }
532
+ /**
533
+ * Samples `clock` every `intervalMs` while subscribed: one timer for every subscriber, started by
534
+ * the first and stopped by the last.
535
+ */
536
+ export declare function createClockTicker(clock: CalendarClock, intervalMs: number): CalendarClockTicker;
537
+ /** The clock a source samples: its own, or the system's. */
538
+ export declare function clockOf(source: CalendarNowSource | undefined): CalendarClock;
539
+ export declare function sameElements<T>(left: readonly T[], right: readonly T[]): boolean;
540
+ /** Compares own enumerable properties with `Object.is`; non-objects compare with `Object.is`. */
541
+ export declare function shallowEqual<T>(left: T, right: T): boolean;
542
+ export declare function samePlainDate(left: Temporal.PlainDate | null | undefined, right: Temporal.PlainDate | null | undefined): boolean;
543
+ export declare function sameInstant(left: Temporal.Instant | undefined, right: Temporal.Instant | undefined): boolean;
544
+ export declare function sameRange(left: PlainDateInterval | undefined, right: PlainDateInterval | undefined): boolean;
545
+ export declare function sameWeekRules(left: CalendarWeekRules, right: CalendarWeekRules): boolean;
546
+ /**
547
+ * Compares working hours by value, so an inline `availability` keeps its shading cached. Invalid
548
+ * entries never throw here; the snapshot reports them.
549
+ */
550
+ export declare function sameAvailability(left: CalendarAvailability | undefined, right: CalendarAvailability | undefined): boolean;
551
+ /**
552
+ * Compares secondary time zones by value, so an inline list keeps the environment as it is. A
553
+ * single zone passed where a list belongs, which the root reports, compares by value too.
554
+ */
555
+ export declare function sameSecondaryTimeZones(left: readonly (CalendarSecondaryTimeZone | string)[], right: readonly (CalendarSecondaryTimeZone | string)[]): boolean;
556
+ /** What an undo or redo announcement is built from: the root's announcement context and the step's event. */
557
+ interface CalendarHistoryAnnouncementContext<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends CalendarAnnouncementContext {
558
+ /**
559
+ * The step's event as the calendar shows it, for its title: from the latest events the calendar
560
+ * rendered, which may still be those from before the undo or redo, or from the events the step
561
+ * was checked against. `undefined` when neither has it, as a restored event the events don't
562
+ * include yet.
563
+ */
564
+ readonly event: NormalizedCalendarEvent<TEvent, TEventId, TResourceId> | undefined;
565
+ }
566
+ /** Builds what a screen reader hears after an undo or a redo; `null` says nothing. */
567
+ type CalendarHistoryAnnouncementBuilder<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> = (outcome: EventHistoryOutcome<TEvent, TEventId, TResourceId>, context: CalendarHistoryAnnouncementContext<TEvent, TEventId, TResourceId>) => string | null;
568
+ /**
569
+ * Localized announcements for undo and redo. The calendar packages ship no text: the registry's
570
+ * calendar source has an English set to copy and translate.
571
+ */
572
+ interface CalendarHistoryMessages<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
573
+ readonly redo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
574
+ readonly undo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
575
+ }
576
+ /** How a bound history speaks; see `useCalendarHistory`. */
577
+ interface CalendarHistoryOptions<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
578
+ /**
579
+ * Speaks each undo and redo outcome through the root's `Announcer`. Read from the latest
580
+ * render; without it, nothing is said.
581
+ */
582
+ readonly messages?: CalendarHistoryMessages<TEvent, TEventId, TResourceId>;
583
+ }
584
+ /** What an undo or redo button passes on in the proposal's detail. */
585
+ interface CalendarHistoryCommandOptions {
586
+ /** The input the command came from; `"api"` by default. */
587
+ readonly input?: CalendarInputMethod;
588
+ }
589
+ /** A history bound to a root: its stacks, and undo and redo through the root's pipeline. */
590
+ interface CalendarHistory<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends EventHistorySnapshot<TEvent, TEventId, TResourceId> {
591
+ readonly canRedo: boolean;
592
+ readonly canUndo: boolean;
593
+ /** Takes the last undone step forward again; resolves with the outcome. */
594
+ readonly redo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
595
+ /** Takes the last step back by proposing its inverse; resolves with the outcome. */
596
+ readonly undo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
597
+ }
598
+ /** What a history binding reads from the latest render each time it undoes or redoes. */
599
+ interface CalendarHistoryBindingOptions<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends CalendarHistoryOptions<TEvent, TEventId, TResourceId> {
600
+ /** The events the calendar shows, pending changes included: the root's latest. */
601
+ readonly events: EventSnapshot<TEvent, TEventId, TResourceId>;
602
+ }
603
+ /**
604
+ * Binds an event history to a root, as a store of `CalendarHistory` values: undo and redo propose
605
+ * the inverse through the root's `proposeEventChange`, against the events `getOptions` gives, and
606
+ * with its `messages` their outcomes are spoken through the root's announcer channel. The
607
+ * snapshot keeps its identity until the history changes; the server snapshot is an empty history.
608
+ * `getOptions` is read whenever a command runs and when it ends, so the binding is made once per
609
+ * root and history.
610
+ */
611
+ export declare function bindCalendarHistory<TEvent, TEventId extends EventId, TResourceId extends ResourceId>({ actions, announcements, changes }: Pick<CalendarInteractionRuntime, "actions" | "announcements" | "changes">, history: EventHistory<TEvent, TEventId, TResourceId>, getOptions: () => CalendarHistoryBindingOptions<TEvent, TEventId, TResourceId>): CalendarStateSource<CalendarHistory<TEvent, TEventId, TResourceId>>;
612
+ /** What undo and redo the shortcuts call: a bound history, as `bindCalendarHistory` gives. */
613
+ interface CalendarHistoryShortcutsTarget {
614
+ readonly redo: (options?: CalendarHistoryCommandOptions) => unknown;
615
+ readonly undo: (options?: CalendarHistoryCommandOptions) => unknown;
616
+ }
617
+ /** What the history shortcuts read each time a key arrives. */
618
+ interface CalendarHistoryShortcutsConfig {
619
+ readonly history: CalendarHistoryShortcutsTarget;
620
+ /**
621
+ * Keys that redo, such as `"Shift+Mod+Z"`: modifiers joined by `+`, then the key. `Mod` is ⌘
622
+ * on Apple platforms and Ctrl elsewhere. `["Shift+Mod+Z", "Ctrl+Y"]` by default; `[]` turns
623
+ * them off.
624
+ */
625
+ readonly redo?: readonly string[];
626
+ /**
627
+ * The element whose keys undo and redo, usually the root's frame; `null` while it isn't
628
+ * mounted. Keys elsewhere on the page are left alone.
629
+ */
630
+ readonly scope: HTMLElement | null;
631
+ /** Keys that undo; `["Mod+Z"]` by default, and `[]` turns them off. */
632
+ readonly undo?: readonly string[];
633
+ }
634
+ /**
635
+ * Listens for a calendar's undo and redo keys until the returned cleanup runs: Mod+Z undoes, and
636
+ * Shift+Mod+Z or Ctrl+Y redoes, where Mod is ⌘ on Apple platforms and Ctrl elsewhere. One
637
+ * `keydown` listener on the document acts on keys whose target is inside the scope, after the
638
+ * page's own handlers, a framework's delegated ones included. Keys never undo in a text field,
639
+ * where the browser undoes the text, or in a dialog, menu or list inside the scope, nor during a
640
+ * keyboard or pointer gesture of the root's, nor once something else handled them. Commands pass
641
+ * `{ input: "keyboard" }`.
642
+ *
643
+ * `getConfig` is read when a key arrives, so a scope that mounts after the listener, or remounts,
644
+ * keeps its keys, and a portal outside it, such as a dialog, never reaches them.
645
+ */
646
+ export declare function attachCalendarHistoryShortcuts({ keyboard, pointerDraft }: Pick<CalendarInteractionRuntime, "keyboard" | "pointerDraft">, getConfig: () => CalendarHistoryShortcutsConfig): () => void;
647
+ /** How a view's keyboard creates, moves and resizes events; read whenever a key arrives. */
648
+ interface CalendarKeyboardOptions {
649
+ /**
650
+ * Which way time runs through the view's slots: down the block axis, as in a time grid (the
651
+ * default), or along the inline axis, as in a timeline. A slot create grows that way.
652
+ */
653
+ readonly axis?: "block" | "inline";
654
+ /**
655
+ * How long an event created on a slot starts out, in whole slots; arrow keys then change it
656
+ * as a pointer drag would. One hour by default. A create on a day starts as that day.
657
+ */
658
+ readonly createDuration?: Temporal.DurationLike;
659
+ /** Length and alignment of time-grid slots; pass the pointer layer's `snap`. 15 minutes by default. */
660
+ readonly snap?: WallTimeSnapOptions;
661
+ }
662
+ /**
663
+ * What a framework's handler got for a DOM event, when the framework wraps DOM events in its own,
664
+ * as React does: the keyboard prevents its default and stops its propagation, so the framework's
665
+ * own handlers further out see both.
666
+ */
667
+ interface CalendarKeyEventWrapper {
668
+ readonly preventDefault: () => void;
669
+ readonly stopPropagation: () => void;
670
+ }
671
+ /**
672
+ * A view's keyboard, from `createCalendarKeyboard`. An integration calls its methods from the
673
+ * `keydown` and `focusout` handlers of the element around the view's focusable cells and events.
674
+ * Bind `keydown` on that element itself (`addEventListener` from a ref in Solid, not
675
+ * `onKeyDown`): a handler the framework delegates to the document runs once the key has bubbled
676
+ * past every element, too late for Escape's stopped propagation to keep it from the handlers
677
+ * around the view.
678
+ */
679
+ interface CalendarKeyboardController {
680
+ /**
681
+ * Leaves the element: focus moving outside `region`, the element the handler is on, cancels a
682
+ * gesture in progress, a task later, unless focus has come back by then, as it does when a
683
+ * grabbed event re-renders in a new place.
684
+ */
685
+ readonly focusOut: (event: FocusEvent, region: HTMLElement) => void;
686
+ /**
687
+ * Handles a key pressed inside the view. A key the calendar acts on has its default prevented,
688
+ * and Escape also stops propagating, through `wrapper` when given (see
689
+ * `CalendarKeyEventWrapper`), else through `event` itself. Keys with Alt, Ctrl or Meta, keys
690
+ * composing text, and keys whose default is already prevented are left alone.
691
+ */
692
+ readonly keyDown: (event: KeyboardEvent, wrapper?: CalendarKeyEventWrapper) => void;
693
+ }
694
+ /**
695
+ * The keyboard of one rendered active view: navigation, and keyboard move, resize and create.
696
+ * `getOptions` and `getResources` (the root's resource tree) are read whenever a key arrives, so
697
+ * the controller is created once per root and view and never again for new options.
698
+ *
699
+ * - Arrow keys, Home, End, Page Up, and Page Down move focus through the view's
700
+ * `getSpatialNavigation`, navigating the view when focus leaves it. Enter moves into a cell's
701
+ * events and Escape back out.
702
+ * - Space grabs the focused event to move it, or the focused cell to create an event there;
703
+ * Shift+Space grabs an event's end to resize it, and again switches to its start. Navigation
704
+ * keys then step the gesture, Enter or Space commits it through `proposeEventChange`, and
705
+ * Escape, Tab, or leaving the view cancels it. On a read-only root, Space grabs nothing.
706
+ *
707
+ * Every phase is announced through the root's announcer channel. A view that unmounts mid-gesture
708
+ * lets go of it with `interaction.keyboard.set(null)`.
709
+ */
710
+ export declare function createCalendarKeyboard({ actions, announcements, isReadOnly, keyboard, read }: CalendarInteractionRuntime, { getView, roving }: CalendarViewRuntime, getOptions: () => CalendarKeyboardOptions, getResources: () => ResourceTree | null): CalendarKeyboardController;
427
711
  /**
428
712
  * Memo cells: what `useMemo` and a stable-value hook do in a component, as plain closures a
429
713
  * runtime owns, so a framework can derive during render (or in a signal's memo) and get the same
@@ -814,4 +1098,34 @@ export declare const calendarAgentActions: readonly (keyof CalendarAgentApi)[];
814
1098
  export declare function createCalendarPrimitive<TViewDef extends AnyCalendarViewDefinition, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId>(config: CalendarPrimitiveConfig<TViewDef>): CalendarPrimitive<TViewDef["name"], TSelection, TFocus, TResourceId>;
815
1099
  /** Reports an application callback's error without failing what it was told about. */
816
1100
  export declare function reportCallbackError(error: unknown): void;
817
- export type { AnnouncerChannel, AnyCalendarState, AnyCalendarViewDefinition, AnyPendingChanges, CalendarActions, CalendarActiveView, CalendarAgentApi, CalendarAgentChange, CalendarAgentCreateInput, CalendarAgentDescription, CalendarAgentEvent, CalendarAgentEventFields, CalendarAgentEventRef, CalendarAgentItem, CalendarAgentMoveInput, CalendarAgentPlacement, CalendarAgentRange, CalendarAgentResizeInput, CalendarAgentUpdateInput, CalendarAnnotations, CalendarChangeReason, CalendarChangeSource, CalendarClockTicker, CalendarCommandOptions, CalendarControlledState, CalendarDiagnostic, CalendarInteractionRuntime, CalendarPartIds, CalendarPrimitive, CalendarPrimitiveApi, CalendarPrimitiveConfig, CalendarPrimitiveInstance, CalendarPrimitiveOptions, CalendarPublicState, CalendarRequestListener, CalendarRootStore, CalendarRootStoreBinding, CalendarRuntime, CalendarRuntimeConfig, CalendarRuntimeConnectOptions, CalendarRuntimeConnection, CalendarRuntimeInputs, CalendarRuntimeModel, CalendarRuntimeOverlay, CalendarSemanticActions, CalendarSlotName, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStateSource, CalendarStore, CalendarStoreBinding, CalendarStoreInternals, CalendarStoreOptions, CalendarViewActions, CalendarViewDefinition, CalendarViewOptionsMap, CalendarVisibleRange, DraftStore, KeyboardGrab, KeyboardSessionStore };
1101
+ /**
1102
+ * One resource's expansion commands. Each reads what caused it from its argument: a DOM event,
1103
+ * which `onExpandedResourceIdsChange` hears with the reason `"resource-toggle"`, or a command's
1104
+ * options, `"resource-toggle"` unless they give another reason. Any other value is ignored, so a
1105
+ * command fits a callback that passes something else, as a switch's change handler passes a
1106
+ * boolean.
1107
+ */
1108
+ interface CalendarResourceExpansionCommands {
1109
+ readonly collapse: (cause?: unknown) => void;
1110
+ readonly expand: (cause?: unknown) => void;
1111
+ readonly toggle: (cause?: unknown) => void;
1112
+ }
1113
+ /**
1114
+ * Expands and collapses `resourceId` through the root's `expandedResourceIds`. Each command reads
1115
+ * the latest requested state, so consecutive commands in one handler compose, and one that would
1116
+ * change nothing asks nothing.
1117
+ */
1118
+ export declare function createResourceExpansionCommands({ actions, read }: Pick<CalendarInteractionRuntime, "actions" | "read">, resourceId: ResourceId): CalendarResourceExpansionCommands;
1119
+ /** A resource's status, with the events in progress as the root's snapshot has them. */
1120
+ type CalendarResourceStatus = ResourceStatus<NormalizedCalendarEvent<unknown, EventId, ResourceId>>;
1121
+ /**
1122
+ * A resource's status on a root's clock, as a store: `compute` (usually `resourceStatusAt` with
1123
+ * the root's availability and events) runs when the status next changes, and every minute in case
1124
+ * the clock jumps, and subscribers hear only when the status differs. One timer serves every
1125
+ * subscriber: it starts with the first and stops with the last. Each new subscription samples
1126
+ * again, so a view revealed after a while shows no stale status, and every subscriber hears it
1127
+ * when that sample differs. Only `source`'s clock is read: a root that fixes `source.now` computes
1128
+ * at it without this store. The server snapshot is `null`, as the server reads no clock.
1129
+ */
1130
+ export declare function createResourceStatusClock(source: CalendarNowSource | undefined, compute: (at: Temporal.Instant) => CalendarResourceStatus): CalendarStateSource<CalendarResourceStatus | null>;
1131
+ export type { AnnouncerChannel, AnnouncerLiveText, AnyCalendarState, AnyCalendarViewDefinition, AnyPendingChanges, BusyRange, CalendarActions, CalendarActiveView, CalendarAgentApi, CalendarAgentChange, CalendarAgentCreateInput, CalendarAgentDescription, CalendarAgentEvent, CalendarAgentEventFields, CalendarAgentEventRef, CalendarAgentItem, CalendarAgentMoveInput, CalendarAgentPlacement, CalendarAgentRange, CalendarAgentResizeInput, CalendarAgentUpdateInput, CalendarAnnotations, CalendarBusyResources, CalendarBusyResourcesQuery, CalendarChangeReason, CalendarChangeSource, CalendarClockTicker, CalendarCommandOptions, CalendarControlledState, CalendarDiagnostic, CalendarDraftBusy, CalendarHistory, CalendarHistoryAnnouncementBuilder, CalendarHistoryAnnouncementContext, CalendarHistoryBindingOptions, CalendarHistoryCommandOptions, CalendarHistoryMessages, CalendarHistoryOptions, CalendarHistoryShortcutsConfig, CalendarHistoryShortcutsTarget, CalendarInteractionRuntime, CalendarKeyEventWrapper, CalendarKeyboardController, CalendarKeyboardOptions, CalendarPartIds, CalendarPrimitive, CalendarPrimitiveApi, CalendarPrimitiveConfig, CalendarPrimitiveInstance, CalendarPrimitiveOptions, CalendarPublicState, CalendarRequestListener, CalendarResourceExpansionCommands, CalendarResourceStatus, CalendarRootStore, CalendarRootStoreBinding, CalendarRovingEntry, CalendarRuntime, CalendarRuntimeConfig, CalendarRuntimeConnectOptions, CalendarRuntimeConnection, CalendarRuntimeInputs, CalendarRuntimeModel, CalendarRuntimeOverlay, CalendarSemanticActions, CalendarSlotName, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStateSource, CalendarStore, CalendarStoreBinding, CalendarStoreInternals, CalendarStoreOptions, CalendarViewActions, CalendarViewDefinition, CalendarViewOptionsMap, CalendarViewRuntime, CalendarVisibleRange, DraftStore, KeyboardGrab, KeyboardSessionStore, RovingFocusStore };