@moltenship/calendar-react 0.0.0-stage → 1.0.0-rc.2
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/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/index.d.mts +686 -0
- package/dist/index.mjs +2353 -0
- package/package.json +52 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
import { AnnotationSnapshot, AnnotationSnapshotIssue, AvailabilityBand, AvailabilityExtent, AvailabilityIssue, AvailabilitySnapshot, CalendarAnnotation, CalendarAnnotationSource, CalendarAnnouncementContext, CalendarAnnouncementMessages, CalendarAnnouncer, CalendarAvailability, CalendarDraft, CalendarEnvironment, CalendarEnvironmentBase, CalendarEventChangeHandler, CalendarEventInput, CalendarEventInterval, CalendarEventProposal, CalendarFocus, CalendarInputMethod, CalendarInteractionCheck, CalendarKeyboardSession, CalendarNowSource, CalendarPendingChanges, CalendarPolicy, CalendarPolicyResult, CalendarProposalDetail, CalendarSecondaryTimeZone, CalendarSelection, CalendarTransactionResult, CalendarViewStrategy, CalendarWeekRules, ClosedDate, EventAdapter, EventHistory, EventHistoryOutcome, EventHistorySnapshot, EventId, EventSnapshot, EventSnapshotIssue, InvalidCalendarEventPolicy, NormalizedCalendarEvent, ResourceId, ResourceStatus, ResourceVisibilityOptions, SecondaryTimeZoneIssue, TimeGridAnnotationGeometry, TimeGridAnnotationMark, TimeGridColumn, VisibleResource } from "@moltenship/calendar-core";
|
|
2
|
+
import { ComponentPropsWithRef, ComponentType, FocusEvent, KeyboardEvent, ReactNode, RefCallback, RefObject } from "react";
|
|
3
|
+
import { InstantInterval, PlainDateInterval, WallTimeSnapOptions } from "@moltenship/calendar-temporal";
|
|
4
|
+
//#region src/annotations.d.ts
|
|
5
|
+
/** The root's annotations and the sources it shows. */
|
|
6
|
+
interface CalendarAnnotations {
|
|
7
|
+
readonly snapshot: AnnotationSnapshot;
|
|
8
|
+
readonly sources: readonly CalendarAnnotationSource[];
|
|
9
|
+
}
|
|
10
|
+
export declare function useCalendarAnnotations(): CalendarAnnotations;
|
|
11
|
+
/**
|
|
12
|
+
* The root's annotations laid out beside a time grid's columns, one list of marks per column; see
|
|
13
|
+
* `projectTimeGridAnnotations`. Marks carry the root's source objects unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useTimeGridAnnotations(columns: readonly TimeGridColumn[], { layout, maxLanes, minGap, minHeight }?: TimeGridAnnotationGeometry): readonly (readonly TimeGridAnnotationMark[])[];
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/types.d.ts
|
|
18
|
+
interface CalendarPublicState<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> {
|
|
19
|
+
readonly anchorDate: Temporal.PlainDate;
|
|
20
|
+
readonly expandedResourceIds: readonly TResourceId[];
|
|
21
|
+
readonly focus: TFocus | null;
|
|
22
|
+
readonly selection: TSelection | null;
|
|
23
|
+
readonly timeZone: string;
|
|
24
|
+
readonly view: TView;
|
|
25
|
+
}
|
|
26
|
+
type CalendarStateSlice = keyof CalendarPublicState;
|
|
27
|
+
interface CalendarStoreOptions<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> {
|
|
28
|
+
readonly defaultAnchorDate: Temporal.PlainDate;
|
|
29
|
+
readonly defaultExpandedResourceIds?: readonly TResourceId[];
|
|
30
|
+
readonly defaultFocus?: TFocus | null;
|
|
31
|
+
readonly defaultSelection?: TSelection | null;
|
|
32
|
+
readonly defaultTimeZone: string;
|
|
33
|
+
readonly defaultView: TView;
|
|
34
|
+
}
|
|
35
|
+
/** Slices whose value is owned by props. `undefined` leaves a slice uncontrolled. */
|
|
36
|
+
type CalendarControlledState<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> = Partial<CalendarPublicState<TView, TSelection, TFocus, TResourceId>>;
|
|
37
|
+
interface CalendarStateChangeDetail<TValue, TSlice extends CalendarStateSlice = CalendarStateSlice> {
|
|
38
|
+
readonly controlled: boolean;
|
|
39
|
+
readonly previous: TValue;
|
|
40
|
+
readonly slice: TSlice;
|
|
41
|
+
}
|
|
42
|
+
type CalendarStateChangeHandler<TValue, TSlice extends CalendarStateSlice> = (next: TValue, detail: CalendarStateChangeDetail<TValue, TSlice>) => void;
|
|
43
|
+
type CalendarStateChangeHandlers<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> = { readonly [TSlice in CalendarStateSlice as `on${Capitalize<TSlice>}Change`]?: CalendarStateChangeHandler<CalendarPublicState<TView, TSelection, TFocus, TResourceId>[TSlice], TSlice>; };
|
|
44
|
+
type CalendarActions<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> = { readonly [TSlice in CalendarStateSlice as `set${Capitalize<TSlice>}`]: (next: CalendarPublicState<TView, TSelection, TFocus, TResourceId>[TSlice]) => void; };
|
|
45
|
+
/**
|
|
46
|
+
* Uncontrolled calendar state. While a `Root` is mounted with this store, `actions` honor that
|
|
47
|
+
* root's controlled slices and change handlers.
|
|
48
|
+
*/
|
|
49
|
+
interface CalendarStore<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId> {
|
|
50
|
+
readonly actions: CalendarActions<TView, TSelection, TFocus, TResourceId>;
|
|
51
|
+
readonly getSnapshot: () => CalendarPublicState<TView, TSelection, TFocus, TResourceId>;
|
|
52
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
53
|
+
}
|
|
54
|
+
type CalendarStateSelector<TState, TSelected> = (state: TState) => TSelected;
|
|
55
|
+
interface CalendarStateSelectorOptions<TSelected> {
|
|
56
|
+
readonly isEqual?: (previous: TSelected, next: TSelected) => boolean;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/views.d.ts
|
|
60
|
+
/** The semantic commands a view renderer may issue without knowing its calendar's types. */
|
|
61
|
+
interface CalendarViewActions {
|
|
62
|
+
/**
|
|
63
|
+
* Asks the policies about a proposal without saving it, as a gesture's preview does; pass it to
|
|
64
|
+
* the pointer layer's `check`. A plain function, so it can be passed on as a callback.
|
|
65
|
+
*/
|
|
66
|
+
readonly checkEventChange: (proposal: CalendarEventProposal<EventId, ResourceId, unknown>) => CalendarPolicyResult<unknown, EventId, ResourceId> | null;
|
|
67
|
+
navigateNext(): void;
|
|
68
|
+
navigatePrevious(): void;
|
|
69
|
+
navigateToday(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Proposes a move, resize, create, or delete, such as the result of a pointer drag; the pointer
|
|
72
|
+
* layer passes `{ input: "pointer" }` as `detail`. A create may carry the application's record
|
|
73
|
+
* as `event`, as an item dropped in from outside the calendar does. A plain function, so it can
|
|
74
|
+
* be passed on as a callback.
|
|
75
|
+
*/
|
|
76
|
+
readonly proposeEventChange: (proposal: CalendarEventProposal<EventId, ResourceId, unknown>, detail?: CalendarProposalDetail) => Promise<CalendarTransactionResult<unknown, EventId, ResourceId>>;
|
|
77
|
+
setAnchorDate(anchorDate: Temporal.PlainDate): void;
|
|
78
|
+
/** Moves the calendar's focus; `useRovingFocus` and `useCalendarKeyboard` call it for you. */
|
|
79
|
+
setFocus(focus: CalendarFocus | null): void;
|
|
80
|
+
setSelection(selection: CalendarSelection | null): void;
|
|
81
|
+
setView(view: string): void;
|
|
82
|
+
}
|
|
83
|
+
interface CalendarViewRendererProps<TProjection, TOptions> {
|
|
84
|
+
/** Stable for the lifetime of the calendar root. */
|
|
85
|
+
readonly actions: CalendarViewActions;
|
|
86
|
+
readonly environment: CalendarEnvironmentBase;
|
|
87
|
+
/** The events the projection was built from, pending changes included. */
|
|
88
|
+
readonly events: EventSnapshot<unknown, EventId, ResourceId>;
|
|
89
|
+
/**
|
|
90
|
+
* The root has no `onEventChange`, so it rejects every change: start no pointer gestures (pass
|
|
91
|
+
* it as `useCalendarPointer`'s `disabled`) and draw no resize handles. Keyboard grabs stay off
|
|
92
|
+
* on their own. `ActiveView` always passes it; a renderer used on its own is editable.
|
|
93
|
+
*/
|
|
94
|
+
readonly isReadOnly?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The dates the projection covers: `range`, plus the neighbouring dates a scrolling view keeps
|
|
97
|
+
* ready (its strategy's `getLoadRange`). `ActiveView` always passes it; a renderer used on its
|
|
98
|
+
* own falls back to `range`.
|
|
99
|
+
*/
|
|
100
|
+
readonly loadRange?: PlainDateInterval;
|
|
101
|
+
readonly options: TOptions;
|
|
102
|
+
readonly projection: TProjection;
|
|
103
|
+
/** The visible dates. */
|
|
104
|
+
readonly range: PlainDateInterval;
|
|
105
|
+
}
|
|
106
|
+
interface CalendarView<TName extends string = string, TProjection = unknown, TOptions = unknown, TEvent = unknown> {
|
|
107
|
+
readonly defaultOptions: TOptions;
|
|
108
|
+
readonly name: TName;
|
|
109
|
+
readonly Renderer: ComponentType<CalendarViewRendererProps<TProjection, TOptions>>;
|
|
110
|
+
readonly strategy: CalendarViewStrategy<TProjection, TOptions, TEvent>;
|
|
111
|
+
}
|
|
112
|
+
type AnyCalendarView<TEvent = any> = CalendarView<string, any, any, TEvent>;
|
|
113
|
+
interface CalendarViewInputBase<TName extends string, TProjection, TOptions, TEvent> {
|
|
114
|
+
readonly name: TName;
|
|
115
|
+
readonly Renderer: ComponentType<CalendarViewRendererProps<TProjection, TOptions>>;
|
|
116
|
+
readonly strategy: CalendarViewStrategy<TProjection, TOptions, TEvent>;
|
|
117
|
+
}
|
|
118
|
+
type CalendarViewInput<TName extends string, TProjection, TOptions, TEvent> = CalendarViewInputBase<TName, TProjection, TOptions, TEvent> & (undefined extends TOptions ? {
|
|
119
|
+
readonly defaultOptions?: TOptions;
|
|
120
|
+
} : {
|
|
121
|
+
readonly defaultOptions: TOptions;
|
|
122
|
+
});
|
|
123
|
+
/** Options a root passes to its registered views, keyed by view name. */
|
|
124
|
+
type CalendarViewOptionsMap<TViewDef extends AnyCalendarView> = { readonly [TName in TViewDef["name"]]?: Partial<Extract<TViewDef, {
|
|
125
|
+
readonly name: TName;
|
|
126
|
+
}>["defaultOptions"]>; };
|
|
127
|
+
/** The active view of a calendar with its visible range and memoized projection. */
|
|
128
|
+
type CalendarActiveView<TViewDef extends AnyCalendarView> = TViewDef extends unknown ? {
|
|
129
|
+
readonly definition: TViewDef;
|
|
130
|
+
readonly environment: CalendarEnvironmentBase;
|
|
131
|
+
/** The events the projection was built from, pending changes included. */
|
|
132
|
+
readonly events: EventSnapshot<unknown, EventId, ResourceId>;
|
|
133
|
+
readonly instantRange: InstantInterval;
|
|
134
|
+
/** `loadRange` resolved to instants in the display time zone. */
|
|
135
|
+
readonly loadInstantRange: InstantInterval;
|
|
136
|
+
/** The dates the projection covers: `range`, or more for a scrolling view. */
|
|
137
|
+
readonly loadRange: PlainDateInterval;
|
|
138
|
+
readonly options: TViewDef["defaultOptions"];
|
|
139
|
+
readonly projection: ReturnType<TViewDef["strategy"]["project"]>;
|
|
140
|
+
readonly range: PlainDateInterval;
|
|
141
|
+
readonly view: TViewDef["name"];
|
|
142
|
+
} : never;
|
|
143
|
+
export declare function defineCalendarView<const TName extends string, TProjection, TOptions = undefined, TEvent = unknown>(view: CalendarViewInput<TName, TProjection, TOptions, TEvent>): CalendarView<TName, TProjection, TOptions, TEvent>;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/calendar-types.d.ts
|
|
146
|
+
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> & {
|
|
147
|
+
navigateNext(): void;
|
|
148
|
+
navigatePrevious(): void;
|
|
149
|
+
navigateToday(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Runs a change through the root's policies without showing or saving it, as a gesture's
|
|
152
|
+
* preview does: `rejected` with the reason `proposeEventChange` would give, or `accepted`, with
|
|
153
|
+
* any `change.warnings`. `null` for an unknown event, or when a policy answers asynchronously.
|
|
154
|
+
*/
|
|
155
|
+
readonly checkEventChange: (proposal: CalendarEventProposal<TEventId, TResourceId, TEvent>) => CalendarPolicyResult<TEvent, TEventId, TResourceId> | null;
|
|
156
|
+
/**
|
|
157
|
+
* Validates a change against the root's policies, shows it while `onEventChange` persists it,
|
|
158
|
+
* and resolves with the outcome, which `onEventChangeResult` hears first, with `detail` as
|
|
159
|
+
* given. Read-only events and roots without `onEventChange` reject. `detail.input` names the
|
|
160
|
+
* input that made the proposal, `"api"` by default. A plain function, so it can be passed on as
|
|
161
|
+
* a callback.
|
|
162
|
+
*/
|
|
163
|
+
readonly proposeEventChange: (proposal: CalendarEventProposal<TEventId, TResourceId, TEvent>, detail?: CalendarProposalDetail) => Promise<CalendarTransactionResult<TEvent, TEventId, TResourceId>>;
|
|
164
|
+
};
|
|
165
|
+
type CalendarDiagnostic<TEvent, TEventId extends EventId> = {
|
|
166
|
+
readonly code: "unregistered-active-view";
|
|
167
|
+
readonly severity: "error";
|
|
168
|
+
readonly viewName: string;
|
|
169
|
+
} | {
|
|
170
|
+
readonly code: "invalid-event";
|
|
171
|
+
readonly issue: EventSnapshotIssue<TEvent, TEventId>;
|
|
172
|
+
readonly severity: "error";
|
|
173
|
+
} | {
|
|
174
|
+
readonly code: "invalid-annotation";
|
|
175
|
+
readonly issue: AnnotationSnapshotIssue;
|
|
176
|
+
readonly severity: "error";
|
|
177
|
+
} | {
|
|
178
|
+
readonly code: "invalid-availability";
|
|
179
|
+
readonly issue: AvailabilityIssue;
|
|
180
|
+
readonly severity: "error";
|
|
181
|
+
} | {
|
|
182
|
+
readonly code: "invalid-secondary-time-zone";
|
|
183
|
+
readonly issue: SecondaryTimeZoneIssue;
|
|
184
|
+
readonly severity: "error";
|
|
185
|
+
};
|
|
186
|
+
interface CalendarPartIds {
|
|
187
|
+
readonly frame: string;
|
|
188
|
+
readonly title: string;
|
|
189
|
+
readonly viewport: string;
|
|
190
|
+
}
|
|
191
|
+
interface CalendarPartRefs {
|
|
192
|
+
readonly frame: RefObject<HTMLElement | null>;
|
|
193
|
+
readonly title: RefObject<HTMLSpanElement | null>;
|
|
194
|
+
readonly toolbar: RefObject<HTMLElement | null>;
|
|
195
|
+
readonly viewport: RefObject<HTMLDivElement | null>;
|
|
196
|
+
}
|
|
197
|
+
interface CalendarMeta<TEvent, TResource, TViewDef extends AnyCalendarView = AnyCalendarView, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
198
|
+
readonly activeView: TViewDef | undefined;
|
|
199
|
+
readonly diagnostics: readonly CalendarDiagnostic<TEvent, TEventId>[];
|
|
200
|
+
readonly environment: CalendarEnvironment;
|
|
201
|
+
readonly eventSnapshot: EventSnapshot<TEvent, TEventId, TResourceId>;
|
|
202
|
+
readonly ids: CalendarPartIds;
|
|
203
|
+
readonly instanceId: string;
|
|
204
|
+
readonly refs: CalendarPartRefs;
|
|
205
|
+
readonly resources: readonly TResource[];
|
|
206
|
+
readonly views: readonly TViewDef[];
|
|
207
|
+
}
|
|
208
|
+
interface CalendarContextValue<TEvent, TResource, TViewDef extends AnyCalendarView = AnyCalendarView, TSelection = CalendarSelection, TFocus = CalendarFocus, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
209
|
+
readonly actions: CalendarSemanticActions<TViewDef["name"], TSelection, TFocus, TResourceId, TEvent, TEventId>;
|
|
210
|
+
readonly meta: CalendarMeta<TEvent, TResource, TViewDef, TEventId, TResourceId>;
|
|
211
|
+
readonly state: CalendarPublicState<TViewDef["name"], TSelection, TFocus, TResourceId>;
|
|
212
|
+
}
|
|
213
|
+
/** What the active view shows and which events it needs, as `onVisibleRangeChange` reports it. */
|
|
214
|
+
interface CalendarVisibleRange<TView extends string = string> {
|
|
215
|
+
/** `range` resolved to instants in the display time zone. */
|
|
216
|
+
readonly instantRange: InstantInterval;
|
|
217
|
+
/** `loadRange` resolved to instants in the display time zone. */
|
|
218
|
+
readonly loadInstantRange: InstantInterval;
|
|
219
|
+
/**
|
|
220
|
+
* The dates to have events for: `range`, plus the pages a scrolling view keeps ready on each
|
|
221
|
+
* side, so a swipe shows their events at once.
|
|
222
|
+
*/
|
|
223
|
+
readonly loadRange: PlainDateInterval;
|
|
224
|
+
/** The visible dates. */
|
|
225
|
+
readonly range: PlainDateInterval;
|
|
226
|
+
readonly view: TView;
|
|
227
|
+
}
|
|
228
|
+
interface CalendarRootBaseProps<TEvent, TResource, TViewDef extends AnyCalendarView, TSelection, TFocus, TEventId extends EventId, TResourceId extends ResourceId> {
|
|
229
|
+
/** The sources views show annotations of, in order. Leave one out to hide its annotations. */
|
|
230
|
+
readonly annotationSources?: readonly CalendarAnnotationSource[];
|
|
231
|
+
/**
|
|
232
|
+
* Time-based information shown beside events, such as listening sessions or sleep. Annotations
|
|
233
|
+
* are read-only and never change event layout. Invalid ones are skipped and reported through
|
|
234
|
+
* `onDiagnosticsChange`.
|
|
235
|
+
*/
|
|
236
|
+
readonly annotations?: readonly CalendarAnnotation<unknown, TResourceId>[];
|
|
237
|
+
/**
|
|
238
|
+
* The calendar's working hours. Resources follow them on their own `timeZone`, unless they have
|
|
239
|
+
* their own `availability`. Views shade the time outside them, and `availabilityPolicy` keeps
|
|
240
|
+
* changes inside. Invalid rules and time zones are left out and reported through
|
|
241
|
+
* `onDiagnosticsChange`.
|
|
242
|
+
*/
|
|
243
|
+
readonly availability?: CalendarAvailability;
|
|
244
|
+
readonly children?: ReactNode;
|
|
245
|
+
readonly defaultExpandedResourceIds?: readonly TResourceId[];
|
|
246
|
+
readonly defaultFocus?: TFocus | null;
|
|
247
|
+
readonly defaultSelection?: TSelection | null;
|
|
248
|
+
readonly defaultView?: TViewDef["name"];
|
|
249
|
+
readonly direction?: CalendarEnvironment["direction"];
|
|
250
|
+
readonly disambiguation?: CalendarEnvironment["disambiguation"];
|
|
251
|
+
/**
|
|
252
|
+
* Your events: an array, or a `CalendarEventSource` an external store updates. A new array
|
|
253
|
+
* holding the same records counts as unchanged. A source's updates render the calendar without
|
|
254
|
+
* the component that renders `Root`; keep the source stable, since a new one subscribes again.
|
|
255
|
+
*/
|
|
256
|
+
readonly events: CalendarEventInput<TEvent>;
|
|
257
|
+
readonly expandedResourceIds?: readonly TResourceId[];
|
|
258
|
+
readonly focus?: TFocus | null;
|
|
259
|
+
readonly id?: string;
|
|
260
|
+
readonly locale: Intl.Locale | string;
|
|
261
|
+
readonly onAnchorDateChange?: CalendarStateChangeHandler<Temporal.PlainDate, "anchorDate">;
|
|
262
|
+
readonly onDiagnosticsChange?: (diagnostics: readonly CalendarDiagnostic<TEvent, TEventId>[]) => void;
|
|
263
|
+
/**
|
|
264
|
+
* Persists an accepted event change. Apply it to `events` synchronously, or return a promise:
|
|
265
|
+
* the change stays visible as pending until it settles and `events` reflect it, and a rejection
|
|
266
|
+
* rolls it back. Without a handler the calendar is read-only.
|
|
267
|
+
*/
|
|
268
|
+
readonly onEventChange?: CalendarEventChangeHandler<TEvent, TEventId, TResourceId>;
|
|
269
|
+
/**
|
|
270
|
+
* Hears how each proposal ended, from a pointer, the keyboard or `proposeEventChange`: once per
|
|
271
|
+
* proposal, after it settles, with the result its promise resolves with and the input that made
|
|
272
|
+
* it. Read from the latest render. A committed change may still wait for `events`; see
|
|
273
|
+
* `useCalendarPendingChanges`.
|
|
274
|
+
*/
|
|
275
|
+
readonly onEventChangeResult?: (result: CalendarTransactionResult<TEvent, TEventId, TResourceId>, detail: CalendarProposalDetail) => void;
|
|
276
|
+
readonly onExpandedResourceIdsChange?: CalendarStateChangeHandler<readonly TResourceId[], "expandedResourceIds">;
|
|
277
|
+
readonly onFocusChange?: CalendarStateChangeHandler<TFocus | null, "focus">;
|
|
278
|
+
readonly onSelectionChange?: CalendarStateChangeHandler<TSelection | null, "selection">;
|
|
279
|
+
readonly onTimeZoneChange?: CalendarStateChangeHandler<string, "timeZone">;
|
|
280
|
+
readonly onViewChange?: CalendarStateChangeHandler<TViewDef["name"], "view">;
|
|
281
|
+
/**
|
|
282
|
+
* Called after the active view first shows its dates and whenever they, the view, or the time
|
|
283
|
+
* zone change, but not when only events do. Load events for `loadRange`, and a scrolling view's
|
|
284
|
+
* next pages are ready before they scroll into view. Each change is reported once, also when
|
|
285
|
+
* Strict Mode runs effects twice or a hidden `Activity` is revealed, and never on the server, so
|
|
286
|
+
* the first render needs a guess of its own.
|
|
287
|
+
*/
|
|
288
|
+
readonly onVisibleRangeChange?: (range: CalendarVisibleRange<TViewDef["name"]>) => void;
|
|
289
|
+
/** Run in order on every proposed change, after the built-in read-only check. */
|
|
290
|
+
readonly policies?: readonly CalendarPolicy<TEvent, TEventId, TResourceId>[];
|
|
291
|
+
readonly resources?: readonly TResource[];
|
|
292
|
+
/**
|
|
293
|
+
* Other time zones time grids label their hours in, beside the display time zone: IANA names,
|
|
294
|
+
* or `{ timeZone, label }` to name one in the header. Views get them as
|
|
295
|
+
* `environment.secondaryTimeZones`. Invalid entries are left out and reported through
|
|
296
|
+
* `onDiagnosticsChange`.
|
|
297
|
+
*/
|
|
298
|
+
readonly secondaryTimeZones?: readonly (CalendarSecondaryTimeZone | string)[];
|
|
299
|
+
readonly selection?: TSelection | null;
|
|
300
|
+
readonly store?: CalendarStore<TViewDef["name"], TSelection, TFocus, TResourceId>;
|
|
301
|
+
readonly view?: TViewDef["name"];
|
|
302
|
+
/** Per-view overrides of each registered view's `defaultOptions`. */
|
|
303
|
+
readonly viewOptions?: CalendarViewOptionsMap<TViewDef>;
|
|
304
|
+
readonly weekRules: CalendarWeekRules;
|
|
305
|
+
}
|
|
306
|
+
type CalendarRootAnchorProps = {
|
|
307
|
+
readonly anchorDate: Temporal.PlainDate;
|
|
308
|
+
readonly defaultAnchorDate?: Temporal.PlainDate;
|
|
309
|
+
} | {
|
|
310
|
+
readonly anchorDate?: undefined;
|
|
311
|
+
readonly defaultAnchorDate: Temporal.PlainDate;
|
|
312
|
+
};
|
|
313
|
+
type CalendarRootTimeZoneProps = {
|
|
314
|
+
readonly defaultTimeZone?: string;
|
|
315
|
+
readonly timeZone: string;
|
|
316
|
+
} | {
|
|
317
|
+
readonly defaultTimeZone: string;
|
|
318
|
+
readonly timeZone?: undefined;
|
|
319
|
+
};
|
|
320
|
+
type CalendarRootProps<TEvent, TResource, TViewDef extends AnyCalendarView = AnyCalendarView, TSelection = CalendarSelection, TFocus = CalendarFocus, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> = CalendarRootBaseProps<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId> & CalendarRootAnchorProps & CalendarRootTimeZoneProps & CalendarNowSource;
|
|
321
|
+
type CalendarFrameProps = Omit<ComponentPropsWithRef<"section">, "id">;
|
|
322
|
+
type CalendarToolbarProps = ComponentPropsWithRef<"header">;
|
|
323
|
+
type CalendarViewportProps = Omit<ComponentPropsWithRef<"div">, "id">;
|
|
324
|
+
type CalendarTitleProps = Omit<ComponentPropsWithRef<"span">, "id">;
|
|
325
|
+
type CalendarAccessibleName = {
|
|
326
|
+
readonly "aria-label": string;
|
|
327
|
+
readonly children?: ReactNode;
|
|
328
|
+
} | {
|
|
329
|
+
readonly "aria-label"?: string;
|
|
330
|
+
readonly children: ReactNode;
|
|
331
|
+
};
|
|
332
|
+
type CalendarTriggerProps = Omit<ComponentPropsWithRef<"button">, "children"> & CalendarAccessibleName;
|
|
333
|
+
type CalendarViewSwitcherProps<TView extends string = string> = Omit<ComponentPropsWithRef<"select">, "children" | "defaultValue" | "value"> & {
|
|
334
|
+
readonly getViewLabel: (view: TView) => string;
|
|
335
|
+
};
|
|
336
|
+
type CalendarAnnouncerProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
337
|
+
/** What each phase says, in the calendar's language; the registry has an English set. */
|
|
338
|
+
readonly messages: CalendarAnnouncementMessages;
|
|
339
|
+
};
|
|
340
|
+
interface CalendarActiveViewProps {
|
|
341
|
+
readonly fallback?: ReactNode;
|
|
342
|
+
}
|
|
343
|
+
interface CalendarEventRenderValue<TEvent, TEventId extends EventId, TResourceId extends ResourceId> {
|
|
344
|
+
readonly event: TEvent;
|
|
345
|
+
readonly normalized: NormalizedCalendarEvent<TEvent, TEventId, TResourceId>;
|
|
346
|
+
}
|
|
347
|
+
interface CalendarEventProps<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
348
|
+
readonly children: (value: CalendarEventRenderValue<TEvent, TEventId, TResourceId>) => ReactNode;
|
|
349
|
+
readonly eventId: TEventId;
|
|
350
|
+
readonly fallback?: ReactNode;
|
|
351
|
+
}
|
|
352
|
+
interface CreateCalendarOptions<TEvent, TViewDef extends AnyCalendarView, TEventId extends EventId, TResourceId extends ResourceId> {
|
|
353
|
+
readonly eventAdapter: EventAdapter<TEvent, TEventId, TResourceId>;
|
|
354
|
+
readonly invalidEventPolicy?: InvalidCalendarEventPolicy;
|
|
355
|
+
readonly views?: readonly TViewDef[];
|
|
356
|
+
}
|
|
357
|
+
interface CalendarFactory<TEvent, TResource, TViewDef extends AnyCalendarView = AnyCalendarView, TSelection = CalendarSelection, TFocus = CalendarFocus, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
358
|
+
readonly ActiveView: ComponentType<CalendarActiveViewProps>;
|
|
359
|
+
readonly Announcer: ComponentType<CalendarAnnouncerProps>;
|
|
360
|
+
readonly Event: ComponentType<CalendarEventProps<TEvent, TEventId, TResourceId>>;
|
|
361
|
+
readonly Frame: ComponentType<CalendarFrameProps>;
|
|
362
|
+
readonly NextTrigger: ComponentType<CalendarTriggerProps>;
|
|
363
|
+
readonly PreviousTrigger: ComponentType<CalendarTriggerProps>;
|
|
364
|
+
readonly Root: ComponentType<CalendarRootProps<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>>;
|
|
365
|
+
readonly Title: ComponentType<CalendarTitleProps>;
|
|
366
|
+
readonly TodayTrigger: ComponentType<CalendarTriggerProps>;
|
|
367
|
+
readonly Toolbar: ComponentType<CalendarToolbarProps>;
|
|
368
|
+
readonly Viewport: ComponentType<CalendarViewportProps>;
|
|
369
|
+
readonly ViewSwitcher: ComponentType<CalendarViewSwitcherProps<TViewDef["name"]>>;
|
|
370
|
+
readonly views: readonly TViewDef[];
|
|
371
|
+
useCalendar(): CalendarContextValue<TEvent, TResource, TViewDef, TSelection, TFocus, TEventId, TResourceId>;
|
|
372
|
+
useCalendarActions(): CalendarSemanticActions<TViewDef["name"], TSelection, TFocus, TResourceId, TEvent, TEventId>;
|
|
373
|
+
useCalendarMeta(): CalendarMeta<TEvent, TResource, TViewDef, TEventId, TResourceId>;
|
|
374
|
+
/**
|
|
375
|
+
* Proposals still validating or saving, and saved changes `events` don't show yet, by change ID
|
|
376
|
+
* in the order they were proposed. Re-renders when they change; with a selector, only when its
|
|
377
|
+
* result does, by `isEqual` (`Object.is` by default).
|
|
378
|
+
*/
|
|
379
|
+
useCalendarPendingChanges(): CalendarPendingChanges<TEvent, TEventId, TResourceId>;
|
|
380
|
+
useCalendarPendingChanges<TSelected>(selector: CalendarStateSelector<CalendarPendingChanges<TEvent, TEventId, TResourceId>, TSelected>, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
|
|
381
|
+
useCalendarSelector<TSelected>(selector: CalendarStateSelector<CalendarPublicState<TViewDef["name"], TSelection, TFocus, TResourceId>, TSelected>, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
|
|
382
|
+
useCalendarState(): CalendarPublicState<TViewDef["name"], TSelection, TFocus, TResourceId>;
|
|
383
|
+
/** The active view's projection, discriminated by `view`; `null` when it is unregistered. */
|
|
384
|
+
useViewProjection(): CalendarActiveView<TViewDef> | null;
|
|
385
|
+
/** The active view's visible dates; `null` when it is unregistered. */
|
|
386
|
+
useVisibleRange(): PlainDateInterval | null;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/announcer.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* The announcer views pass to the pointer layer (`useCalendarPointer({ announcer })`), so pointer
|
|
392
|
+
* gestures are spoken by the same messages and its preview labels ranges the same way.
|
|
393
|
+
*/
|
|
394
|
+
export declare function useCalendarAnnouncer(): CalendarAnnouncer;
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/availability.d.ts
|
|
397
|
+
/** The root's working hours: the calendar's, and each resource's on its time zone. */
|
|
398
|
+
export declare function useCalendarAvailability(): AvailabilitySnapshot;
|
|
399
|
+
/**
|
|
400
|
+
* The closed time of each time-grid column, as bands on its 24-hour axis with their reasons: the
|
|
401
|
+
* calendar's, or with `resourceId` that resource's, on its own time zone. See
|
|
402
|
+
* `projectTimeGridAvailability`.
|
|
403
|
+
*/
|
|
404
|
+
export declare function useTimeGridAvailability(columns: readonly TimeGridColumn[], resourceId?: ResourceId | null): readonly (readonly AvailabilityBand[])[];
|
|
405
|
+
/**
|
|
406
|
+
* The closed time along a timeline of `columns`: the calendar's, or with `resourceId` that
|
|
407
|
+
* resource's. See `projectTimelineAvailability`.
|
|
408
|
+
*/
|
|
409
|
+
export declare function useTimelineAvailability(columns: readonly TimeGridColumn[], resourceId?: ResourceId | null): readonly AvailabilityExtent[];
|
|
410
|
+
/**
|
|
411
|
+
* The dates of `range` with no open time on their day in the display time zone: the calendar's,
|
|
412
|
+
* or with `resourceId` that resource's. See `closedDates`.
|
|
413
|
+
*/
|
|
414
|
+
export declare function useClosedDates(range: PlainDateInterval, resourceId?: ResourceId | null): ReadonlyMap<string, ClosedDate>;
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/calendar.d.ts
|
|
417
|
+
/**
|
|
418
|
+
* Creates a typed calendar. The first call fixes the application's record types; the second infers
|
|
419
|
+
* the view-name union and identifier types from `views` and `eventAdapter`.
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* const Calendar = createCalendar<Meeting, Room>()({ eventAdapter, views: [monthView] });
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
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>;
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/draft.d.ts
|
|
428
|
+
type AnyDraft = CalendarDraft<EventId, ResourceId>;
|
|
429
|
+
/** The busy resources of a range, with the events that make them busy; see `busyResources`. */
|
|
430
|
+
type CalendarBusyResources = ReadonlyMap<ResourceId, readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[]>;
|
|
431
|
+
/** A resource during the draft's time; see `useDraftBusy`. */
|
|
432
|
+
interface CalendarDraftBusy {
|
|
433
|
+
/** The busy events that overlap the draft, by start; empty when the resource is free. */
|
|
434
|
+
readonly events: readonly NormalizedCalendarEvent<unknown, EventId, ResourceId>[];
|
|
435
|
+
/** Whether the draft falls outside the resource's hours. */
|
|
436
|
+
readonly outsideHours: boolean;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The resources busy during `range`, such as a meeting being placed, with their events; free
|
|
440
|
+
* ones are absent. It queries the root's events, pending changes included, once per change of
|
|
441
|
+
* events or range, however many components ask. `exclude` leaves out an event, such as the one
|
|
442
|
+
* being moved; `null` asks nothing.
|
|
443
|
+
*/
|
|
444
|
+
export declare function useBusyResources(range: InstantInterval | CalendarEventInterval | null, { exclude, resourceIds }?: {
|
|
445
|
+
readonly exclude?: EventId | null;
|
|
446
|
+
readonly resourceIds?: readonly ResourceId[];
|
|
447
|
+
}): CalendarBusyResources;
|
|
448
|
+
/** Reports the pointer's draft to the root, for `onPreview` of `useCalendarPointer`. */
|
|
449
|
+
export declare function useCalendarDraftReporter(): (draft: AnyDraft | null) => void;
|
|
450
|
+
/**
|
|
451
|
+
* The change being drafted, by pointer or keyboard: the event it changes (`null` when creating)
|
|
452
|
+
* and where it would land; `null` without one. It changes once a slot step, so pass its
|
|
453
|
+
* `proposed` to `useBusyResources` for any "who's busy" UI of your own.
|
|
454
|
+
*/
|
|
455
|
+
export declare function useCalendarDraft(): AnyDraft | null;
|
|
456
|
+
/**
|
|
457
|
+
* A resource during the draft's time while one is being made, by pointer or keyboard: the busy
|
|
458
|
+
* events that overlap it (the draft's own event aside; see `isBusy` on the event adapter), and
|
|
459
|
+
* whether the time falls outside its hours. `null` without a draft, or for a `null` resource.
|
|
460
|
+
* The draft's busy resources are worked out once a step for every component that asks, and a
|
|
461
|
+
* component re-renders only when its own resource's answer changes.
|
|
462
|
+
*/
|
|
463
|
+
export declare function useDraftBusy(resourceId: ResourceId | null): CalendarDraftBusy | null;
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/history.d.ts
|
|
466
|
+
interface CalendarHistoryAnnouncementContext<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends CalendarAnnouncementContext {
|
|
467
|
+
/**
|
|
468
|
+
* The step's event as the calendar shows it, for its title: from the latest events the calendar
|
|
469
|
+
* rendered, which may still be those from before the undo or redo, or from the events the step
|
|
470
|
+
* was checked against. `undefined` when neither has it, as a restored event the events don't
|
|
471
|
+
* include yet.
|
|
472
|
+
*/
|
|
473
|
+
readonly event: NormalizedCalendarEvent<TEvent, TEventId, TResourceId> | undefined;
|
|
474
|
+
}
|
|
475
|
+
/** Builds what a screen reader hears after an undo or a redo; `null` says nothing. */
|
|
476
|
+
type CalendarHistoryAnnouncementBuilder<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> = (outcome: EventHistoryOutcome<TEvent, TEventId, TResourceId>, context: CalendarHistoryAnnouncementContext<TEvent, TEventId, TResourceId>) => string | null;
|
|
477
|
+
/**
|
|
478
|
+
* Localized announcements for undo and redo. The calendar packages ship no text: the registry's
|
|
479
|
+
* calendar source has an English set to copy and translate.
|
|
480
|
+
*/
|
|
481
|
+
interface CalendarHistoryMessages<TEvent = unknown, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
482
|
+
readonly redo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
|
|
483
|
+
readonly undo: CalendarHistoryAnnouncementBuilder<TEvent, TEventId, TResourceId>;
|
|
484
|
+
}
|
|
485
|
+
interface CalendarHistoryOptions<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> {
|
|
486
|
+
/**
|
|
487
|
+
* Speaks each undo and redo outcome through the root's `Announcer`. Read from the latest
|
|
488
|
+
* render; without it, nothing is said.
|
|
489
|
+
*/
|
|
490
|
+
readonly messages?: CalendarHistoryMessages<TEvent, TEventId, TResourceId>;
|
|
491
|
+
}
|
|
492
|
+
/** What an undo or redo button passes on in the proposal's detail. */
|
|
493
|
+
interface CalendarHistoryCommandOptions {
|
|
494
|
+
/** The input the command came from; `"api"` by default. */
|
|
495
|
+
readonly input?: CalendarInputMethod;
|
|
496
|
+
}
|
|
497
|
+
/** A history bound to a root: its stacks, and undo and redo through the root's pipeline. */
|
|
498
|
+
interface CalendarHistory<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> extends EventHistorySnapshot<TEvent, TEventId, TResourceId> {
|
|
499
|
+
readonly canRedo: boolean;
|
|
500
|
+
readonly canUndo: boolean;
|
|
501
|
+
/** Takes the last undone step forward again; resolves with the outcome. */
|
|
502
|
+
readonly redo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
|
|
503
|
+
/** Takes the last step back by proposing its inverse; resolves with the outcome. */
|
|
504
|
+
readonly undo: (options?: CalendarHistoryCommandOptions) => Promise<EventHistoryOutcome<TEvent, TEventId, TResourceId>>;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Binds an event history to the nearest `Root`: undo and redo propose the inverse through the
|
|
508
|
+
* root's `proposeEventChange`, against the events the user sees, and with `messages` their
|
|
509
|
+
* outcomes are spoken through the root's `Announcer`. The history records through `Root`'s
|
|
510
|
+
* `onEventChangeResult`:
|
|
511
|
+
*
|
|
512
|
+
* ```tsx
|
|
513
|
+
* const [history] = useState(() => createEventHistory<Meeting, string, string>());
|
|
514
|
+
* <Calendar.Root onEventChangeResult={history.record} …>
|
|
515
|
+
* <UndoButtons history={history} />
|
|
516
|
+
* </Calendar.Root>
|
|
517
|
+
* // Inside: const { canUndo, undo } = useCalendarHistory(history, { messages });
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* The server and hydration read an empty history.
|
|
521
|
+
*/
|
|
522
|
+
export declare function useCalendarHistory<TEvent, TEventId extends EventId, TResourceId extends ResourceId>(history: EventHistory<TEvent, TEventId, TResourceId>, options?: CalendarHistoryOptions<NoInfer<TEvent>, NoInfer<TEventId>, NoInfer<TResourceId>>): CalendarHistory<TEvent, TEventId, TResourceId>;
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/history-shortcuts.d.ts
|
|
525
|
+
interface CalendarHistoryShortcutsOptions {
|
|
526
|
+
/** Listens for nothing while `true`. */
|
|
527
|
+
readonly disabled?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Keys that redo, such as `"Shift+Mod+Z"`: modifiers joined by `+`, then the key. `Mod` is ⌘
|
|
530
|
+
* on Apple platforms and Ctrl elsewhere. `["Shift+Mod+Z", "Ctrl+Y"]` by default; `[]` turns
|
|
531
|
+
* them off.
|
|
532
|
+
*/
|
|
533
|
+
readonly redo?: readonly string[];
|
|
534
|
+
/**
|
|
535
|
+
* The element whose keys undo and redo, usually the root's frame,
|
|
536
|
+
* `Calendar.useCalendarMeta().refs.frame`. Keys elsewhere on the page are left alone.
|
|
537
|
+
*/
|
|
538
|
+
readonly scope: RefObject<HTMLElement | null>;
|
|
539
|
+
/** Keys that undo; `["Mod+Z"]` by default, and `[]` turns them off. */
|
|
540
|
+
readonly undo?: readonly string[];
|
|
541
|
+
}
|
|
542
|
+
/** What undo and redo the shortcuts call: a bound history, from `useCalendarHistory`. */
|
|
543
|
+
interface CalendarHistoryShortcutsTarget {
|
|
544
|
+
readonly redo: (options?: CalendarHistoryCommandOptions) => unknown;
|
|
545
|
+
readonly undo: (options?: CalendarHistoryCommandOptions) => unknown;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Undo and redo keys for a calendar: Mod+Z undoes, and Shift+Mod+Z or Ctrl+Y redoes, where Mod is
|
|
549
|
+
* ⌘ on Apple platforms and Ctrl elsewhere. While the hook is mounted and enabled, one `keydown`
|
|
550
|
+
* listener on the document acts on keys whose target is inside `scope`, after the page's own
|
|
551
|
+
* handlers, React's included. Keys never undo in a text field, where the browser undoes the
|
|
552
|
+
* text, or in a dialog, menu or list inside the scope, nor during a keyboard or pointer gesture,
|
|
553
|
+
* nor once something else handled them. Commands pass `{ input: "keyboard" }`.
|
|
554
|
+
*
|
|
555
|
+
* ```tsx
|
|
556
|
+
* const history = useCalendarHistory(eventHistory);
|
|
557
|
+
* useCalendarHistoryShortcuts(history, { scope: Calendar.useCalendarMeta().refs.frame });
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
export declare function useCalendarHistoryShortcuts(history: CalendarHistoryShortcutsTarget, options: CalendarHistoryShortcutsOptions): void;
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/status.d.ts
|
|
563
|
+
/** A resource's status, with the events in progress as the root's snapshot has them. */
|
|
564
|
+
type CalendarResourceStatus = ResourceStatus<NormalizedCalendarEvent<unknown, EventId, ResourceId>>;
|
|
565
|
+
export declare function useResourceStatus(resourceId?: ResourceId | null, at?: Temporal.Instant): CalendarResourceStatus | null;
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/store.d.ts
|
|
568
|
+
export declare function createCalendarStore<TView extends string = string, TSelection = CalendarSelection, TFocus = CalendarFocus, TResourceId extends ResourceId = ResourceId>(options: CalendarStoreOptions<TView, TSelection, TFocus, TResourceId>): CalendarStore<TView, TSelection, TFocus, TResourceId>;
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region src/keyboard.d.ts
|
|
571
|
+
interface CalendarKeyboardOptions {
|
|
572
|
+
/**
|
|
573
|
+
* Which way time runs through the view's slots: down the block axis, as in a time grid (the
|
|
574
|
+
* default), or along the inline axis, as in a timeline. A slot create grows that way.
|
|
575
|
+
*/
|
|
576
|
+
readonly axis?: "block" | "inline";
|
|
577
|
+
/**
|
|
578
|
+
* How long an event created on a slot starts out, in whole slots; arrow keys then change it
|
|
579
|
+
* as a pointer drag would. One hour by default. A create on a day starts as that day.
|
|
580
|
+
*/
|
|
581
|
+
readonly createDuration?: Temporal.DurationLike;
|
|
582
|
+
/** Length and alignment of time-grid slots; pass the pointer layer's `snap`. 15 minutes by default. */
|
|
583
|
+
readonly snap?: WallTimeSnapOptions;
|
|
584
|
+
}
|
|
585
|
+
/** Handlers for the element that holds a view's focusable cells and events. */
|
|
586
|
+
interface CalendarKeyboardHandlers {
|
|
587
|
+
readonly onBlur: (event: FocusEvent<HTMLElement>) => void;
|
|
588
|
+
readonly onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Keyboard navigation and keyboard move, resize, and create for a view; spread the handlers on
|
|
592
|
+
* the element around its focusable cells and events (see `useRovingFocus`).
|
|
593
|
+
*
|
|
594
|
+
* - Arrow keys, Home, End, Page Up, and Page Down move focus through the view's
|
|
595
|
+
* `getSpatialNavigation`, navigating the view when focus leaves it. Enter moves into a cell's
|
|
596
|
+
* events and Escape back out.
|
|
597
|
+
* - Space grabs the focused event to move it, or the focused cell to create an event there;
|
|
598
|
+
* Shift+Space grabs an event's end to resize it, and again switches to its start. Navigation
|
|
599
|
+
* keys then step the gesture, Enter or Space commits it through `proposeEventChange`, and
|
|
600
|
+
* Escape, Tab, or leaving the view cancels it. On a root without `onEventChange`, Space grabs
|
|
601
|
+
* nothing.
|
|
602
|
+
*
|
|
603
|
+
* Every phase is announced through the root's `Announcer`.
|
|
604
|
+
*/
|
|
605
|
+
export declare function useCalendarKeyboard(options?: CalendarKeyboardOptions): CalendarKeyboardHandlers;
|
|
606
|
+
/**
|
|
607
|
+
* The keyboard gesture in progress, or `null` while idle. Pass a selector to re-render only when
|
|
608
|
+
* its result changes, such as whether a cell is inside a create's range. The selector also gets
|
|
609
|
+
* what the root's policies say about committing the gesture now, to show an invalid preview.
|
|
610
|
+
*/
|
|
611
|
+
export declare function useCalendarInteraction(): CalendarKeyboardSession | null;
|
|
612
|
+
export declare function useCalendarInteraction<TSelected>(selector: (session: CalendarKeyboardSession | null, check: CalendarInteractionCheck) => TSelected, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/roving-focus.d.ts
|
|
615
|
+
interface CalendarRovingFocusOptions {
|
|
616
|
+
/** Dates an event element shows from `target.date`, such as a month segment's span. */
|
|
617
|
+
readonly days?: number;
|
|
618
|
+
}
|
|
619
|
+
interface CalendarRovingFocusProps {
|
|
620
|
+
readonly onFocus: (event: FocusEvent<HTMLElement>) => void;
|
|
621
|
+
readonly ref: RefCallback<HTMLElement>;
|
|
622
|
+
readonly tabIndex: 0 | -1;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Props for one focusable element of a view: a day cell, a slot, or an event. The view's one tab
|
|
626
|
+
* stop gets `tabIndex={0}`; focusing an element makes it the calendar's focus, and keyboard
|
|
627
|
+
* navigation moves DOM focus to the new target, even when it renders in a new place. Only the
|
|
628
|
+
* elements whose tab stop changes re-render.
|
|
629
|
+
*/
|
|
630
|
+
export declare function useRovingFocus(target: CalendarFocus, { days }?: CalendarRovingFocusOptions): CalendarRovingFocusProps;
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/resources.d.ts
|
|
633
|
+
interface CalendarResourceExpansion {
|
|
634
|
+
/** Whether the resource's children show. */
|
|
635
|
+
readonly expanded: boolean;
|
|
636
|
+
readonly collapse: () => void;
|
|
637
|
+
readonly expand: () => void;
|
|
638
|
+
readonly toggle: () => void;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* The root's resources as a view shows them: depth first, with collapsed resources' descendants
|
|
642
|
+
* left out (see `visibleResources`). Re-renders when the resources or their expansion change.
|
|
643
|
+
*/
|
|
644
|
+
export declare function useVisibleResources(options?: ResourceVisibilityOptions): readonly VisibleResource[];
|
|
645
|
+
/**
|
|
646
|
+
* One resource's expansion and the commands that change it, through `expandedResourceIds`. A
|
|
647
|
+
* component re-renders only when this resource expands or collapses, so a resource header can
|
|
648
|
+
* own its toggle.
|
|
649
|
+
*/
|
|
650
|
+
export declare function useResourceExpansion(resourceId: ResourceId): CalendarResourceExpansion;
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/selectors.d.ts
|
|
653
|
+
/**
|
|
654
|
+
* Selects from the calendar's focus for a view's item, such as whether a slot cursor sits on this
|
|
655
|
+
* column. A component re-renders only when its result changes.
|
|
656
|
+
*/
|
|
657
|
+
export declare function useCalendarFocus<TSelected>(selector: (focus: CalendarFocus | null) => TSelected, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
|
|
658
|
+
/**
|
|
659
|
+
* Selects from the calendar's selection, as `useCalendarFocus` does from its focus:
|
|
660
|
+
* `useCalendarSelection((selection) => selection?.kind === "event" && selection.eventId === id)`.
|
|
661
|
+
*/
|
|
662
|
+
export declare function useCalendarSelection<TSelected>(selector: (selection: CalendarSelection | null) => TSelected, options?: CalendarStateSelectorOptions<TSelected>): TSelected;
|
|
663
|
+
//#endregion
|
|
664
|
+
//#region src/use-now.d.ts
|
|
665
|
+
interface UseNowOptions {
|
|
666
|
+
/** How often the clock is sampled. Defaults to one minute. */
|
|
667
|
+
readonly intervalMs?: number;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* The current instant from the nearest calendar's `now` or `clock`, falling back to the system
|
|
671
|
+
* clock. It is `null` during server rendering and hydration unless the calendar fixes `now`.
|
|
672
|
+
*/
|
|
673
|
+
export declare function useNow({ intervalMs }?: UseNowOptions): Temporal.Instant | null;
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/requests.d.ts
|
|
676
|
+
/**
|
|
677
|
+
* Calls `listener` whenever something asks the calendar for an anchor date: Previous, Next,
|
|
678
|
+
* Today, keys paging past the view, or `setAnchorDate`, even a date that is already the anchor.
|
|
679
|
+
* `range` is what the view on screen shows for that date, so a view can tell a request for the
|
|
680
|
+
* range it has, as Today in this week, from one that moves it. A view whose scroll position can
|
|
681
|
+
* run ahead of the anchor, as a scrolling view's does while a controlled anchor catches up, uses
|
|
682
|
+
* it to show its range again when asked.
|
|
683
|
+
*/
|
|
684
|
+
export declare function useAnchorDateRequests(listener: (date: Temporal.PlainDate, range: PlainDateInterval | null) => void): void;
|
|
685
|
+
//#endregion
|
|
686
|
+
export type { 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 };
|