@moltenship/calendar-react 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
@@ -26,8 +26,8 @@ pnpm add @moltenship/calendar-react @ui-sdk/core @ui-sdk/react react react-dom
26
26
 
27
27
  ## Documentation
28
28
 
29
- - [React components and hooks](https://time.molten.sh/docs/api/react)
30
- - [Agents](https://time.molten.sh/docs/agents)
29
+ - [React components and hooks](https://time.molten.sh/docs/react/api/components)
30
+ - [Agents](https://time.molten.sh/docs/react/agents)
31
31
  - [Repository](https://github.com/Moltenship/time)
32
32
 
33
33
  ## License
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { AvailabilityBand, AvailabilityExtent, AvailabilitySnapshot, CalendarAnnotation, CalendarAnnotationSource, CalendarAnnouncementContext, CalendarAnnouncementMessages, CalendarAnnouncer, CalendarAvailability, CalendarDraft, CalendarEnvironment, CalendarEnvironmentBase, CalendarEventChangeHandler, CalendarEventInput, CalendarEventInterval, CalendarFocus, CalendarInputMethod, CalendarInteractionCheck, CalendarKeyboardSession, CalendarNowSource, CalendarPendingChanges, CalendarPolicy, CalendarProposalDetail, CalendarSecondaryTimeZone, CalendarSelection, CalendarTransactionResult, CalendarViewStrategy, CalendarWeekRules, ClosedDate, EventAdapter, EventHistory, EventHistoryOutcome, EventHistorySnapshot, EventId, EventSnapshot, InvalidCalendarEventPolicy, NormalizedCalendarEvent, ResourceId, ResourceStatus, ResourceVisibilityOptions, TimeGridAnnotationGeometry, TimeGridAnnotationMark, TimeGridColumn, VisibleResource } from "@moltenship/calendar-core";
1
+ import { AvailabilityBand, AvailabilityExtent, AvailabilitySnapshot, CalendarAnnotation, CalendarAnnotationSource, CalendarAnnouncementMessages, CalendarAnnouncer, CalendarAvailability, CalendarDraft, CalendarEnvironment, CalendarEnvironmentBase, CalendarEventChangeHandler, CalendarEventInput, CalendarEventInterval, CalendarFocus, CalendarInteractionCheck, CalendarKeyboardSession, CalendarNowSource, CalendarPendingChanges, CalendarPolicy, CalendarProposalDetail, CalendarSecondaryTimeZone, CalendarSelection, CalendarTransactionResult, CalendarViewStrategy, CalendarWeekRules, ClosedDate, EventAdapter, EventHistory, EventId, EventSnapshot, InvalidCalendarEventPolicy, NormalizedCalendarEvent, ResourceId, ResourceVisibilityOptions, TimeGridAnnotationGeometry, TimeGridAnnotationMark, TimeGridColumn, VisibleResource } from "@moltenship/calendar-core";
2
2
  import { ComponentPropsWithRef, ComponentType, FocusEvent, KeyboardEvent, ReactNode, RefCallback, RefObject, SyntheticEvent } from "react";
3
- import { CalendarActions, CalendarActiveView as CalendarActiveView$1, CalendarAgentEvent, CalendarAnnotations, CalendarChangeReason, CalendarChangeSource, CalendarCommandOptions, CalendarControlledState, CalendarDiagnostic, CalendarPartIds, CalendarPublicState, CalendarRootStore, CalendarSemanticActions, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStore, CalendarStoreOptions, CalendarViewActions, CalendarViewDefinition, CalendarViewOptionsMap as CalendarViewOptionsMap$1, CalendarVisibleRange, createCalendarStore } from "@moltenship/calendar-primitives";
3
+ import { CalendarActions, CalendarActiveView as CalendarActiveView$1, CalendarAgentEvent, CalendarAnnotations, CalendarBusyResources, CalendarChangeReason, CalendarChangeSource, CalendarCommandOptions, CalendarControlledState, CalendarDiagnostic, CalendarDraftBusy, CalendarHistory, CalendarHistoryAnnouncementBuilder, CalendarHistoryAnnouncementContext, CalendarHistoryCommandOptions, CalendarHistoryMessages, CalendarHistoryOptions, CalendarHistoryShortcutsTarget, CalendarKeyboardOptions, CalendarPartIds, CalendarPublicState, CalendarResourceStatus, CalendarRootStore, CalendarSemanticActions, CalendarStateChangeDetail, CalendarStateChangeHandler, CalendarStateChangeHandlers, CalendarStateSelector, CalendarStateSelectorOptions, CalendarStateSlice, CalendarStore, CalendarStoreOptions, CalendarViewActions, CalendarViewDefinition, CalendarViewOptionsMap as CalendarViewOptionsMap$1, CalendarVisibleRange, createCalendarStore } from "@moltenship/calendar-primitives";
4
4
  import "@ui-sdk/react/primitive";
5
- import { InstantInterval, PlainDateInterval, WallTimeSnapOptions } from "@moltenship/calendar-temporal";
5
+ import { CalendarPointerOptions } from "@moltenship/calendar-dnd";
6
+ import { InstantInterval, PlainDateInterval } from "@moltenship/calendar-temporal";
6
7
  export declare function useCalendarAnnotations(): CalendarAnnotations;
7
8
  /**
8
9
  * The root's annotations laid out beside a time grid's columns, one list of marks per column; see
@@ -289,15 +290,6 @@ export declare function useClosedDates(range: PlainDateInterval, resourceId?: Re
289
290
  */
290
291
  export declare function createCalendar<TEvent, TResource = unknown, TSelection = CalendarSelection, TFocus = CalendarFocus>(): <TViewDef extends AnyCalendarView<TEvent> = never, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId>(options: CreateCalendarOptions<TEvent, TViewDef, TEventId, TResourceId>) => CalendarFactory<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>;
291
292
  type AnyDraft = CalendarDraft<EventId, ResourceId>;
292
- /** The busy resources of a range, with the events that make them busy; see `busyResources`. */
293
- type CalendarBusyResources = ReadonlyMap<ResourceId, readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[]>;
294
- /** A resource during the draft's time; see `useDraftBusy`. */
295
- interface CalendarDraftBusy {
296
- /** The busy events that overlap the draft, by start; empty when the resource is free. */
297
- readonly events: readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[];
298
- /** Whether the draft falls outside the resource's hours. */
299
- readonly outsideHours: boolean;
300
- }
301
293
  /**
302
294
  * The resources busy during `range`, such as a meeting being placed, with their events; free
303
295
  * ones are absent. It queries the root's events, pending changes included, once per change of
@@ -324,46 +316,6 @@ export declare function useCalendarDraft(): AnyDraft | null;
324
316
  * component re-renders only when its own resource's answer changes.
325
317
  */
326
318
  export declare function useDraftBusy(resourceId: ResourceId | null): CalendarDraftBusy | null;
327
- interface CalendarHistoryAnnouncementContext<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends CalendarAnnouncementContext {
328
- /**
329
- * The step's event as the calendar shows it, for its title: from the latest events the calendar
330
- * rendered, which may still be those from before the undo or redo, or from the events the step
331
- * was checked against. `undefined` when neither has it, as a restored event the events don't
332
- * include yet.
333
- */
334
- readonly event: NormalizedCalendarEvent<TEvent, TEventId, TResourceId> | undefined;
335
- }
336
- /** Builds what a screen reader hears after an undo or a redo; `null` says nothing. */
337
- type CalendarHistoryAnnouncementBuilder<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> = (outcome: EventHistoryOutcome<TEvent, TEventId, TResourceId>, context: CalendarHistoryAnnouncementContext<TEvent, TEventId, TResourceId>) => string | null;
338
- /**
339
- * Localized announcements for undo and redo. The calendar packages ship no text: the registry's
340
- * calendar source has an English set to copy and translate.
341
- */
342
- interface CalendarHistoryMessages<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
343
- readonly redo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
344
- readonly undo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
345
- }
346
- interface CalendarHistoryOptions<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
347
- /**
348
- * Speaks each undo and redo outcome through the root's `Announcer`. Read from the latest
349
- * render; without it, nothing is said.
350
- */
351
- readonly messages?: CalendarHistoryMessages<TEvent, TEventId, TResourceId>;
352
- }
353
- /** What an undo or redo button passes on in the proposal's detail. */
354
- interface CalendarHistoryCommandOptions {
355
- /** The input the command came from; `"api"` by default. */
356
- readonly input?: CalendarInputMethod;
357
- }
358
- /** A history bound to a root: its stacks, and undo and redo through the root's pipeline. */
359
- interface CalendarHistory<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends EventHistorySnapshot<TEvent, TEventId, TResourceId> {
360
- readonly canRedo: boolean;
361
- readonly canUndo: boolean;
362
- /** Takes the last undone step forward again; resolves with the outcome. */
363
- readonly redo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
364
- /** Takes the last step back by proposing its inverse; resolves with the outcome. */
365
- readonly undo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
366
- }
367
319
  /**
368
320
  * Binds an event history to the nearest `Root`: undo and redo propose the inverse through the
369
321
  * root's `proposeEventChange`, against the events the user sees, and with `messages` their
@@ -398,11 +350,6 @@ interface CalendarHistoryShortcutsOptions {
398
350
  /** Keys that undo; `["Mod+Z"]` by default, and `[]` turns them off. */
399
351
  readonly undo?: readonly string[];
400
352
  }
401
- /** What undo and redo the shortcuts call: a bound history, from `useCalendarHistory`. */
402
- interface CalendarHistoryShortcutsTarget {
403
- readonly redo: (options?: CalendarHistoryCommandOptions) => unknown;
404
- readonly undo: (options?: CalendarHistoryCommandOptions) => unknown;
405
- }
406
353
  /**
407
354
  * Undo and redo keys for a calendar: Mod+Z undoes, and Shift+Mod+Z or Ctrl+Y redoes, where Mod is
408
355
  * ⌘ on Apple platforms and Ctrl elsewhere. While the hook is mounted and enabled, one `keydown`
@@ -417,23 +364,15 @@ interface CalendarHistoryShortcutsTarget {
417
364
  * ```
418
365
  */
419
366
  export declare function useCalendarHistoryShortcuts(history: CalendarHistoryShortcutsTarget, options: CalendarHistoryShortcutsOptions): void;
420
- /** A resource's status, with the events in progress as the root's snapshot has them. */
421
- type CalendarResourceStatus = ResourceStatus<NormalizedCalendarEvent<unknown, EventId, ResourceId>>;
367
+ /**
368
+ * Whether a resource is within its working hours and whether its events occupy it, `at` an
369
+ * instant or now on the calendar's clock; see `resourceStatusAt`. Without `resourceId` it is the
370
+ * calendar's hours and every event. All-day and floating events count on the display time zone,
371
+ * as the views show them. On the clock it re-renders only when the status changes, and is `null`
372
+ * while server rendering unless the calendar fixes `now`. A `null` resource turns it off, such as
373
+ * for the Unassigned column, with nothing computed or scheduled.
374
+ */
422
375
  export declare function useResourceStatus(resourceId?: ResourceId | null, at?: Temporal.Instant): CalendarResourceStatus | null;
423
- interface CalendarKeyboardOptions {
424
- /**
425
- * Which way time runs through the view's slots: down the block axis, as in a time grid (the
426
- * default), or along the inline axis, as in a timeline. A slot create grows that way.
427
- */
428
- readonly axis?: "block" | "inline";
429
- /**
430
- * How long an event created on a slot starts out, in whole slots; arrow keys then change it
431
- * as a pointer drag would. One hour by default. A create on a day starts as that day.
432
- */
433
- readonly createDuration?: Temporal.DurationLike;
434
- /** Length and alignment of time-grid slots; pass the pointer layer's `snap`. 15 minutes by default. */
435
- readonly snap?: WallTimeSnapOptions;
436
- }
437
376
  /** Handlers for the element that holds a view's focusable cells and events. */
438
377
  interface CalendarKeyboardHandlers {
439
378
  readonly onBlur: (event: FocusEvent<HTMLElement>) => void;
@@ -462,6 +401,15 @@ export declare function useCalendarKeyboard(options?: CalendarKeyboardOptions):
462
401
  */
463
402
  export declare function useCalendarInteraction(): CalendarKeyboardSession | null;
464
403
  export declare function useCalendarInteraction<TSelected>(selector: (session: CalendarKeyboardSession | null, check: CalendarInteractionCheck) => TSelected, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
404
+ /**
405
+ * Pointer move, resize, and create for a view region; see `attachCalendarPointer` for the data
406
+ * attributes the view renders. Returns a ref for the region element. Options are read when a
407
+ * gesture starts, and `columns` again as it moves, so changing them never re-attaches listeners,
408
+ * and dragging never re-renders. `disabled` is the exception: a disabled region doesn't listen for
409
+ * touch moves, so a read-only calendar's swipes never wait for its listener, and changing it
410
+ * attaches the listeners again.
411
+ */
412
+ export declare function useCalendarPointer<TEvent, TEventId extends EventId, TResourceId extends ResourceId>(options: CalendarPointerOptions<TEvent, TEventId, TResourceId>): RefCallback<HTMLElement>;
465
413
  interface CalendarRovingFocusOptions {
466
414
  /** Dates an event element shows from `target.date`, such as a month segment's span. */
467
415
  readonly days?: number;