@super-calendar/core 2.10.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +176 -105
- package/dist/index.d.ts +176 -105
- package/dist/index.js +59 -5
- package/dist/index.mjs +57 -6
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/utils/eventDisplay.ts +7 -3
- package/src/utils/labels.ts +109 -0
- package/src/utils/monthGrid.ts +13 -15
package/dist/index.d.mts
CHANGED
|
@@ -2,16 +2,16 @@ import { Locale } from "date-fns";
|
|
|
2
2
|
import { Dispatch, SetStateAction } from "react";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/** The view the calendar renders: a day-column grid (`day`, `3days`, `week`, `custom`), the `month` grid, or the `schedule` list. */
|
|
5
|
-
type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule" | "year";
|
|
5
|
+
export type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule" | "year";
|
|
6
6
|
/** The time-grid modes (day-column views, excluding month and schedule). */
|
|
7
|
-
type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
|
|
7
|
+
export type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
|
|
8
8
|
/**
|
|
9
9
|
* The minimal shape every calendar event must have. Layout (positioning,
|
|
10
10
|
* overlap resolution, paging) only ever reads `start`/`end`; `title` is used by
|
|
11
11
|
* the built-in default renderer. Anything else lives in your own type and is
|
|
12
12
|
* threaded through untouched via the `T` generic.
|
|
13
13
|
*/
|
|
14
|
-
interface ICalendarEvent {
|
|
14
|
+
export interface ICalendarEvent {
|
|
15
15
|
/** When the event begins. */
|
|
16
16
|
start: Date;
|
|
17
17
|
/** When the event ends. */
|
|
@@ -63,9 +63,9 @@ interface ICalendarEvent {
|
|
|
63
63
|
recurrence?: RecurrenceRule;
|
|
64
64
|
}
|
|
65
65
|
/** How often a recurring event repeats. */
|
|
66
|
-
type RecurrenceFrequency = "daily" | "weekly" | "monthly" | "yearly";
|
|
66
|
+
export type RecurrenceFrequency = "daily" | "weekly" | "monthly" | "yearly";
|
|
67
67
|
/** A simple, RRULE-inspired repeat rule expanded by `expandRecurringEvents`. */
|
|
68
|
-
interface RecurrenceRule {
|
|
68
|
+
export interface RecurrenceRule {
|
|
69
69
|
/** How often the event repeats. */
|
|
70
70
|
freq: RecurrenceFrequency;
|
|
71
71
|
/** Repeat every N periods. Default 1. */
|
|
@@ -123,18 +123,18 @@ interface RecurrenceRule {
|
|
|
123
123
|
* `ICalendarEvent` is authoritative: keys it reserves (`start`/`end`/`title`)
|
|
124
124
|
* cannot be re-typed by `T`.
|
|
125
125
|
*/
|
|
126
|
-
type CalendarEvent<T = unknown> = ICalendarEvent & Omit<T, keyof ICalendarEvent>;
|
|
126
|
+
export type CalendarEvent<T = unknown> = ICalendarEvent & Omit<T, keyof ICalendarEvent>;
|
|
127
127
|
/** Build a stable key for an event. Defaults to start-time + index. */
|
|
128
|
-
type EventKeyExtractor<T = unknown> = (event: CalendarEvent<T>, index: number) => string;
|
|
128
|
+
export type EventKeyExtractor<T = unknown> = (event: CalendarEvent<T>, index: number) => string;
|
|
129
129
|
/** Sunday = 0 … Saturday = 6, matching `Date.prototype.getDay()`. */
|
|
130
|
-
type WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
130
|
+
export type WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
131
131
|
/**
|
|
132
132
|
* A day's open hours for `businessHours` shading, as hours (fractions allowed,
|
|
133
133
|
* e.g. `9.5`): a single window `{ start, end }`, or an array of windows to leave
|
|
134
134
|
* a closed gap between them (a lunch break: `[{ start: 9, end: 12 }, { start: 13,
|
|
135
135
|
* end: 17 }]`). Everything outside the window(s) is shaded closed.
|
|
136
136
|
*/
|
|
137
|
-
type BusinessHoursValue = {
|
|
137
|
+
export type BusinessHoursValue = {
|
|
138
138
|
start: number;
|
|
139
139
|
end: number;
|
|
140
140
|
} | {
|
|
@@ -147,13 +147,13 @@ type BusinessHoursValue = {
|
|
|
147
147
|
* or `undefined` for no business-hours shading. Shared by both renderers; pair
|
|
148
148
|
* with `closedHourBands` to get the spans to shade.
|
|
149
149
|
*/
|
|
150
|
-
type BusinessHours = (date: Date) => BusinessHoursValue;
|
|
150
|
+
export type BusinessHours = (date: Date) => BusinessHoursValue;
|
|
151
151
|
/**
|
|
152
152
|
* One closed-hours band handed to a `renderBusinessHours` override: the day it
|
|
153
153
|
* belongs to and its span as fractional hours, already clamped to the visible
|
|
154
154
|
* window. `ResourceTimeline` extends it with the lane's resource.
|
|
155
155
|
*/
|
|
156
|
-
interface BusinessHoursBand {
|
|
156
|
+
export interface BusinessHoursBand {
|
|
157
157
|
date: Date;
|
|
158
158
|
start: number;
|
|
159
159
|
end: number;
|
|
@@ -161,7 +161,7 @@ interface BusinessHoursBand {
|
|
|
161
161
|
//#endregion
|
|
162
162
|
//#region src/tokens.d.ts
|
|
163
163
|
/** The shared colour palette both renderers derive their themes from. */
|
|
164
|
-
interface CalendarColors {
|
|
164
|
+
export interface CalendarColors {
|
|
165
165
|
/** Opaque surface behind floating chrome (e.g. the date-picker field and popover). */
|
|
166
166
|
surface: string;
|
|
167
167
|
/** Hour lines, day separators and month-cell borders. */
|
|
@@ -198,44 +198,44 @@ interface CalendarColors {
|
|
|
198
198
|
backgroundEvent: string;
|
|
199
199
|
}
|
|
200
200
|
/** The default light-theme colour palette. */
|
|
201
|
-
declare const lightColors: CalendarColors;
|
|
201
|
+
export declare const lightColors: CalendarColors;
|
|
202
202
|
/** The default dark-theme colour palette. */
|
|
203
|
-
declare const darkColors: CalendarColors;
|
|
203
|
+
export declare const darkColors: CalendarColors;
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region src/presentation.d.ts
|
|
206
206
|
/** Which range-band shape a day shows. */
|
|
207
|
-
type RangeBandKind = "none" | "fill" | "pill-start" | "pill-mid" | "pill-end";
|
|
207
|
+
export type RangeBandKind = "none" | "fill" | "pill-start" | "pill-mid" | "pill-end";
|
|
208
208
|
/** The band shape for a day, given the fill-cell option. */
|
|
209
|
-
declare function rangeBandKind(day: {
|
|
209
|
+
export declare function rangeBandKind(day: {
|
|
210
210
|
isInRange: boolean;
|
|
211
211
|
isRangeStart: boolean;
|
|
212
212
|
isRangeEnd: boolean;
|
|
213
213
|
}, fillCell: boolean): RangeBandKind;
|
|
214
214
|
/** Whether a band shape rounds its leading / trailing edge (pill ends). */
|
|
215
|
-
declare function bandRounding(kind: RangeBandKind): {
|
|
215
|
+
export declare function bandRounding(kind: RangeBandKind): {
|
|
216
216
|
start: boolean;
|
|
217
217
|
end: boolean;
|
|
218
218
|
};
|
|
219
219
|
/** Which filled badge a day shows (today wins over a selection). */
|
|
220
|
-
type DayBadgeKind = "none" | "today" | "selected";
|
|
220
|
+
export type DayBadgeKind = "none" | "today" | "selected";
|
|
221
221
|
/**
|
|
222
222
|
* The filled-badge kind for a day. `isSelected` is true for both range endpoints
|
|
223
223
|
* and discrete selected days; today always wins when it coincides.
|
|
224
224
|
*/
|
|
225
|
-
declare function dayBadgeKind(day: {
|
|
225
|
+
export declare function dayBadgeKind(day: {
|
|
226
226
|
isSelected: boolean;
|
|
227
227
|
}, isToday: boolean): DayBadgeKind;
|
|
228
228
|
//#endregion
|
|
229
229
|
//#region src/utils/dateRange.d.ts
|
|
230
230
|
/** A selected span. `end` is `null` while only the first endpoint has been picked. */
|
|
231
|
-
interface DateRange {
|
|
231
|
+
export interface DateRange {
|
|
232
232
|
/** The first endpoint. */
|
|
233
233
|
start: Date;
|
|
234
234
|
/** The second endpoint, or `null` while only the first has been picked. */
|
|
235
235
|
end: Date | null;
|
|
236
236
|
}
|
|
237
237
|
/** Limits applied before a date can be selected. */
|
|
238
|
-
interface DateSelectionConstraints {
|
|
238
|
+
export interface DateSelectionConstraints {
|
|
239
239
|
/** Earliest selectable day (inclusive). */
|
|
240
240
|
minDate?: Date;
|
|
241
241
|
/** Latest selectable day (inclusive). */
|
|
@@ -244,7 +244,7 @@ interface DateSelectionConstraints {
|
|
|
244
244
|
isDateDisabled?: (date: Date) => boolean;
|
|
245
245
|
}
|
|
246
246
|
/** Whether `date` passes the min/max/disabled constraints (compared by calendar day). */
|
|
247
|
-
declare function isDateSelectable(date: Date, constraints?: DateSelectionConstraints): boolean;
|
|
247
|
+
export declare function isDateSelectable(date: Date, constraints?: DateSelectionConstraints): boolean;
|
|
248
248
|
/**
|
|
249
249
|
* The range after pressing `pressed`, mirroring the familiar date-picker model:
|
|
250
250
|
* - no range yet, or a complete range exists → start fresh (`{ start: pressed, end: null }`),
|
|
@@ -254,13 +254,13 @@ declare function isDateSelectable(date: Date, constraints?: DateSelectionConstra
|
|
|
254
254
|
*
|
|
255
255
|
* Returns `current` unchanged when `pressed` isn't selectable.
|
|
256
256
|
*/
|
|
257
|
-
declare function nextDateRange(current: DateRange | null, pressed: Date, constraints?: DateSelectionConstraints): DateRange | null;
|
|
257
|
+
export declare function nextDateRange(current: DateRange | null, pressed: Date, constraints?: DateSelectionConstraints): DateRange | null;
|
|
258
258
|
/** True when `date` is one of the range's two endpoints. */
|
|
259
|
-
declare function isRangeEndpoint(date: Date, range: DateRange | null): boolean;
|
|
259
|
+
export declare function isRangeEndpoint(date: Date, range: DateRange | null): boolean;
|
|
260
260
|
/** True when `date` falls within a complete range (endpoints included). */
|
|
261
|
-
declare function isWithinDateRange(date: Date, range: DateRange | null): boolean;
|
|
261
|
+
export declare function isWithinDateRange(date: Date, range: DateRange | null): boolean;
|
|
262
262
|
/** The selection/disabled flags for one day. */
|
|
263
|
-
interface DaySelectionState {
|
|
263
|
+
export interface DaySelectionState {
|
|
264
264
|
/** Fails the min/max/disabled constraints. */
|
|
265
265
|
isDisabled: boolean;
|
|
266
266
|
/** A `selectedDates` day or a range endpoint (and not disabled). */
|
|
@@ -277,7 +277,7 @@ interface DaySelectionState {
|
|
|
277
277
|
* `buildMonthGrid` (the headless grid) so the built-in views and a custom
|
|
278
278
|
* calendar can never disagree on what a day's state is.
|
|
279
279
|
*/
|
|
280
|
-
declare function daySelectionState(date: Date, selection: {
|
|
280
|
+
export declare function daySelectionState(date: Date, selection: {
|
|
281
281
|
selectedDates?: Date[];
|
|
282
282
|
selectedRange?: DateRange | null;
|
|
283
283
|
}, constraints?: DateSelectionConstraints): DaySelectionState;
|
|
@@ -286,7 +286,7 @@ declare function daySelectionState(date: Date, selection: {
|
|
|
286
286
|
* plus the selectability constraints. Threaded through context (not props) so
|
|
287
287
|
* cached/virtualized day cells still repaint when any of it changes.
|
|
288
288
|
*/
|
|
289
|
-
interface CalendarSelection extends DateSelectionConstraints {
|
|
289
|
+
export interface CalendarSelection extends DateSelectionConstraints {
|
|
290
290
|
/** Selected discrete days (single or multiple). */
|
|
291
291
|
selectedDates?: Date[];
|
|
292
292
|
/** Selected span. */
|
|
@@ -297,16 +297,16 @@ interface CalendarSelection extends DateSelectionConstraints {
|
|
|
297
297
|
* {@link useCalendarSelection} so they repaint on selection changes even when
|
|
298
298
|
* the virtualized list has cached (and so won't re-render) their page.
|
|
299
299
|
*/
|
|
300
|
-
declare const CalendarSelectionProvider: import("react").Provider<CalendarSelection>;
|
|
300
|
+
export declare const CalendarSelectionProvider: import("react").Provider<CalendarSelection>;
|
|
301
301
|
/** Reads the active selection provided by {@link CalendarSelectionProvider}. */
|
|
302
|
-
declare const useCalendarSelection: () => CalendarSelection;
|
|
302
|
+
export declare const useCalendarSelection: () => CalendarSelection;
|
|
303
303
|
/** Options for {@link useDateRange}. */
|
|
304
|
-
interface UseDateRangeOptions extends DateSelectionConstraints {
|
|
304
|
+
export interface UseDateRangeOptions extends DateSelectionConstraints {
|
|
305
305
|
/** Pre-select a range on mount. */
|
|
306
306
|
initialRange?: DateRange | null;
|
|
307
307
|
}
|
|
308
308
|
/** The state and handlers returned by {@link useDateRange}. */
|
|
309
|
-
interface UseDateRangeResult {
|
|
309
|
+
export interface UseDateRangeResult {
|
|
310
310
|
/** The current selection; `null` until the first endpoint is picked. */
|
|
311
311
|
range: DateRange | null;
|
|
312
312
|
/** Wire to `onPressDay`: advances the range (start, then end, then restarts). */
|
|
@@ -328,32 +328,32 @@ interface UseDateRangeResult {
|
|
|
328
328
|
* <Calendar mode="month" selectedRange={range ?? undefined} onPressDay={onPressDate} … />
|
|
329
329
|
* ```
|
|
330
330
|
*/
|
|
331
|
-
declare function useDateRange(options?: UseDateRangeOptions): UseDateRangeResult;
|
|
331
|
+
export declare function useDateRange(options?: UseDateRangeOptions): UseDateRangeResult;
|
|
332
332
|
//#endregion
|
|
333
333
|
//#region src/utils/dates.d.ts
|
|
334
334
|
/** The seven dates of the week containing `date`, starting on `weekStartsOn`. */
|
|
335
|
-
declare const getWeekDays: (date: Date, weekStartsOn: WeekStartsOn) => Date[];
|
|
335
|
+
export declare const getWeekDays: (date: Date, weekStartsOn: WeekStartsOn) => Date[];
|
|
336
336
|
/** How many day columns a time-grid mode shows. `custom` uses `numberOfDays`. */
|
|
337
|
-
declare const viewDayCount: (mode: CalendarMode, numberOfDays?: number) => number;
|
|
337
|
+
export declare const viewDayCount: (mode: CalendarMode, numberOfDays?: number) => number;
|
|
338
338
|
/**
|
|
339
339
|
* Days in the inclusive span from `weekStartsOn` to `weekEndsOn` (1–7),
|
|
340
340
|
* wrapping when the end precedes the start (e.g. Sat→Wed). Mirrors
|
|
341
341
|
* react-native-big-calendar's `weekDaysCount`.
|
|
342
342
|
*/
|
|
343
|
-
declare const weekDaysCount: (weekStartsOn: WeekStartsOn, weekEndsOn: WeekStartsOn) => number;
|
|
343
|
+
export declare const weekDaysCount: (weekStartsOn: WeekStartsOn, weekEndsOn: WeekStartsOn) => number;
|
|
344
344
|
/**
|
|
345
345
|
* The day columns to render for a time-grid page. `week` spans the calendar week
|
|
346
346
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
347
347
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
348
348
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
349
349
|
*/
|
|
350
|
-
declare const getViewDays: (mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number, isRTL?: boolean, weekEndsOn?: WeekStartsOn, hiddenDays?: number[]) => Date[];
|
|
350
|
+
export declare const getViewDays: (mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number, isRTL?: boolean, weekEndsOn?: WeekStartsOn, hiddenDays?: number[]) => Date[];
|
|
351
351
|
/**
|
|
352
352
|
* The calendar weeks covering `month`, padded to whole weeks starting on
|
|
353
353
|
* `weekStartsOn`. `showSixWeeks` always returns six rows (42 days) for a
|
|
354
354
|
* fixed-height grid; `isRTL` reverses each week's day order.
|
|
355
355
|
*/
|
|
356
|
-
declare const buildMonthWeeks: (month: Date, weekStartsOn: WeekStartsOn, { showSixWeeks, isRTL, hiddenDays }?: {
|
|
356
|
+
export declare const buildMonthWeeks: (month: Date, weekStartsOn: WeekStartsOn, { showSixWeeks, isRTL, hiddenDays }?: {
|
|
357
357
|
showSixWeeks?: boolean;
|
|
358
358
|
isRTL?: boolean;
|
|
359
359
|
hiddenDays?: number[];
|
|
@@ -363,17 +363,17 @@ declare const buildMonthWeeks: (month: Date, weekStartsOn: WeekStartsOn, { showS
|
|
|
363
363
|
* Hiding all seven weekdays is treated as hiding nothing (matching
|
|
364
364
|
* `getViewDays`), so a misconfiguration degrades to the full grid, not a blank.
|
|
365
365
|
*/
|
|
366
|
-
declare const filterHiddenDays: (days: Date[], hiddenDays?: number[]) => Date[];
|
|
366
|
+
export declare const filterHiddenDays: (days: Date[], hiddenDays?: number[]) => Date[];
|
|
367
367
|
/** True when `date` is a Saturday or Sunday. */
|
|
368
|
-
declare const isWeekend: (date: Date) => boolean;
|
|
368
|
+
export declare const isWeekend: (date: Date) => boolean;
|
|
369
369
|
/** True when `date` falls on the current calendar day. */
|
|
370
|
-
declare const getIsToday: (date: Date) => boolean;
|
|
370
|
+
export declare const getIsToday: (date: Date) => boolean;
|
|
371
371
|
/** True when `a` and `b` are the same calendar day (ignoring the time of day). */
|
|
372
|
-
declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
|
|
372
|
+
export declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
|
|
373
373
|
/** Minutes elapsed since midnight (0–1439). */
|
|
374
|
-
declare const minutesIntoDay: (date: Date) => number;
|
|
374
|
+
export declare const minutesIntoDay: (date: Date) => number;
|
|
375
375
|
/** The twelve month anchors (first-of-month) of `date`'s year, January first. */
|
|
376
|
-
declare const getYearMonths: (date: Date) => Date[];
|
|
376
|
+
export declare const getYearMonths: (date: Date) => Date[];
|
|
377
377
|
//#endregion
|
|
378
378
|
//#region src/utils/drag.d.ts
|
|
379
379
|
/**
|
|
@@ -381,26 +381,26 @@ declare const getYearMonths: (date: Date) => Date[];
|
|
|
381
381
|
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
382
382
|
* at the same wall-clock time on different days do not overlap.
|
|
383
383
|
*/
|
|
384
|
-
declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
384
|
+
export declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
385
385
|
/**
|
|
386
386
|
* True when the range `[start, end)` would overlap any event in `events` other
|
|
387
387
|
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
388
388
|
* a drag/resize that would land an event on top of another.
|
|
389
389
|
*/
|
|
390
|
-
declare function overlapsOtherEvents<T>(events: readonly CalendarEvent<T>[], moved: CalendarEvent<T>, start: Date, end: Date): boolean;
|
|
390
|
+
export declare function overlapsOtherEvents<T>(events: readonly CalendarEvent<T>[], moved: CalendarEvent<T>, start: Date, end: Date): boolean;
|
|
391
391
|
/**
|
|
392
392
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
393
393
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
|
394
394
|
* Deliberately ignores `hiddenDays` so a week always steps 7, matching the
|
|
395
395
|
* keyboard PageUp/PageDown paging and `Calendar`'s own page step.
|
|
396
396
|
*/
|
|
397
|
-
declare function pageStepDays(mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number): number;
|
|
397
|
+
export declare function pageStepDays(mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number): number;
|
|
398
398
|
/**
|
|
399
399
|
* Minutes to shift an event, snapping a vertical pixel drag to the nearest
|
|
400
400
|
* `stepMinutes`. Runs on the UI thread inside the drag gesture. Returns 0 for a
|
|
401
401
|
* degenerate grid (non-positive height/step).
|
|
402
402
|
*/
|
|
403
|
-
declare function snapDeltaMinutes(translationPx: number, cellHeightPx: number, stepMinutes: number): number;
|
|
403
|
+
export declare function snapDeltaMinutes(translationPx: number, cellHeightPx: number, stepMinutes: number): number;
|
|
404
404
|
/**
|
|
405
405
|
* Where a moved event may start, in minutes from midnight, given the grid's
|
|
406
406
|
* visible hour window. A move keeps its duration, so only the start is held
|
|
@@ -410,9 +410,9 @@ declare function snapDeltaMinutes(translationPx: number, cellHeightPx: number, s
|
|
|
410
410
|
* cross-day *move* is the horizontal drag) while still allowing a range that
|
|
411
411
|
* spans midnight. Runs on the UI thread inside the drag gesture.
|
|
412
412
|
*/
|
|
413
|
-
declare function clampMoveStartMinutes(startMinutes: number, minHour: number, maxHour: number, snapMinutes: number): number;
|
|
413
|
+
export declare function clampMoveStartMinutes(startMinutes: number, minHour: number, maxHour: number, snapMinutes: number): number;
|
|
414
414
|
/** A copy of `date` shifted by `minutes` (may be negative). */
|
|
415
|
-
declare function shiftMinutes(date: Date, minutes: number): Date;
|
|
415
|
+
export declare function shiftMinutes(date: Date, minutes: number): Date;
|
|
416
416
|
/**
|
|
417
417
|
* Resolve a committed drag into the event's new bounds: `start` shifts by
|
|
418
418
|
* `deltaStartMinutes`, `end` by `deltaEndMinutes` (a move passes the same delta
|
|
@@ -423,7 +423,7 @@ declare function shiftMinutes(date: Date, minutes: number): Date;
|
|
|
423
423
|
* never rejected, even for an already sub-step event. Pure, so the commit path is
|
|
424
424
|
* unit-testable without a running gesture.
|
|
425
425
|
*/
|
|
426
|
-
declare function resolveDraggedBounds(start: Date, end: Date, deltaStartMinutes: number, deltaEndMinutes: number, snapMinutes: number): {
|
|
426
|
+
export declare function resolveDraggedBounds(start: Date, end: Date, deltaStartMinutes: number, deltaEndMinutes: number, snapMinutes: number): {
|
|
427
427
|
start: Date;
|
|
428
428
|
end: Date;
|
|
429
429
|
} | null;
|
|
@@ -433,7 +433,7 @@ declare function resolveDraggedBounds(start: Date, end: Date, deltaStartMinutes:
|
|
|
433
433
|
* midnight after the last, so a one-day sweep still yields a usable event. Shared
|
|
434
434
|
* by both renderers so a month drag-to-create means the same thing on each.
|
|
435
435
|
*/
|
|
436
|
-
declare function monthCreateRange(anchor: Date, hover: Date): {
|
|
436
|
+
export declare function monthCreateRange(anchor: Date, hover: Date): {
|
|
437
437
|
start: Date;
|
|
438
438
|
end: Date;
|
|
439
439
|
};
|
|
@@ -443,7 +443,7 @@ declare function monthCreateRange(anchor: Date, hover: Date): {
|
|
|
443
443
|
* event keeps its time of day and duration (DST included). Returns `null` when
|
|
444
444
|
* the drop lands on the day it started, so a stray drag commits nothing.
|
|
445
445
|
*/
|
|
446
|
-
declare function monthDropBounds<T>(event: CalendarEvent<T>, fromDay: Date, toDay: Date): {
|
|
446
|
+
export declare function monthDropBounds<T>(event: CalendarEvent<T>, fromDay: Date, toDay: Date): {
|
|
447
447
|
start: Date;
|
|
448
448
|
end: Date;
|
|
449
449
|
} | null;
|
|
@@ -455,38 +455,110 @@ declare function monthDropBounds<T>(event: CalendarEvent<T>, fromDay: Date, toDa
|
|
|
455
455
|
* Returns `null` for a degenerate grid (non-positive height/step). Pure, so the
|
|
456
456
|
* commit path is unit-testable without a running gesture.
|
|
457
457
|
*/
|
|
458
|
-
declare function cellRangeFromDrag(day: Date, startPx: number, endPx: number, cellHeightPx: number, minHour: number, snapMinutes: number): {
|
|
458
|
+
export declare function cellRangeFromDrag(day: Date, startPx: number, endPx: number, cellHeightPx: number, minHour: number, snapMinutes: number): {
|
|
459
459
|
start: Date;
|
|
460
460
|
end: Date;
|
|
461
461
|
} | null;
|
|
462
462
|
//#endregion
|
|
463
|
+
//#region src/utils/labels.d.ts
|
|
464
|
+
/**
|
|
465
|
+
* Words the built-in views add to their screen-reader labels and gutter text.
|
|
466
|
+
* The date parts are formatted through `locale`; these words are not, so pass
|
|
467
|
+
* translations through the `labels` prop to localize them. Shared by both
|
|
468
|
+
* renderers, so a translation reads the same on web and native.
|
|
469
|
+
*/
|
|
470
|
+
export interface CalendarLabels {
|
|
471
|
+
/** Appended to a day's label when it is today. Default "today". */
|
|
472
|
+
today: string;
|
|
473
|
+
/** Appended to a day's label when it is selected. Default "selected". */
|
|
474
|
+
selected: string;
|
|
475
|
+
/** Appended to a day's label when it is disabled. Default "unavailable". */
|
|
476
|
+
unavailable: string;
|
|
477
|
+
/** Appended to a year-view day's label when it has events. Default "has events". */
|
|
478
|
+
hasEvents: string;
|
|
479
|
+
/** How many events a month-view day holds. Default "1 event" / "N events". */
|
|
480
|
+
eventCount: (count: number) => string;
|
|
481
|
+
/** The "+N more" overflow control's label. Default "N more events". */
|
|
482
|
+
moreEvents: (count: number) => string;
|
|
483
|
+
/** The all-day gutter text in the time grid. Default "all-day". */
|
|
484
|
+
allDay: string;
|
|
485
|
+
/**
|
|
486
|
+
* Spoken in an all-day event's label (e.g. "Trip, all day"). Default "all day".
|
|
487
|
+
* On native, a `Calendar` `allDayLabel` takes precedence.
|
|
488
|
+
*/
|
|
489
|
+
allDayEvent: string;
|
|
490
|
+
/** A timed event's spoken range from its formatted times. Default "09:00 to 10:00". */
|
|
491
|
+
timeRange: (start: string, end: string) => string;
|
|
492
|
+
/** The close control of the "+N more" popover. Default "Close". */
|
|
493
|
+
close: string;
|
|
494
|
+
/** Screen-reader action that moves an event later by `minutes`. Default "Move 15 minutes later". */
|
|
495
|
+
moveLater: (minutes: number) => string;
|
|
496
|
+
/** Screen-reader action that moves an event earlier by `minutes`. Default "Move 15 minutes earlier". */
|
|
497
|
+
moveEarlier: (minutes: number) => string;
|
|
498
|
+
/** Screen-reader action that lengthens an event by `minutes`. Default "Extend by 15 minutes". */
|
|
499
|
+
extend: (minutes: number) => string;
|
|
500
|
+
/** Screen-reader action that shortens an event by `minutes`. Default "Shorten by 15 minutes". */
|
|
501
|
+
shorten: (minutes: number) => string;
|
|
502
|
+
/**
|
|
503
|
+
* Screen-reader action that moves an event one page forward, given the page's
|
|
504
|
+
* day count and the view mode. Default "Move to next week" in week mode, else
|
|
505
|
+
* "Move to next day" / "Move to next 3 days".
|
|
506
|
+
*/
|
|
507
|
+
moveToNextPage: (days: number, mode: CalendarMode) => string;
|
|
508
|
+
/** The backward counterpart of `moveToNextPage`. Default "Move to previous week". */
|
|
509
|
+
moveToPreviousPage: (days: number, mode: CalendarMode) => string;
|
|
510
|
+
/** Resource timeline action that moves an event to another lane. Default "Move to Room A". */
|
|
511
|
+
moveToResource: (title: string) => string;
|
|
512
|
+
}
|
|
513
|
+
/** The built-in English {@link CalendarLabels}. */
|
|
514
|
+
export declare const defaultCalendarLabels: CalendarLabels;
|
|
515
|
+
/** Fill the labels a consumer left out with {@link defaultCalendarLabels}. */
|
|
516
|
+
export declare function resolveCalendarLabels(labels?: Partial<CalendarLabels>): CalendarLabels;
|
|
517
|
+
/**
|
|
518
|
+
* Screen-reader label for a day: the formatted date followed by its state
|
|
519
|
+
* words, joined with ", " (e.g. "Friday, 17 July 2026, today, 3 events").
|
|
520
|
+
*/
|
|
521
|
+
export declare function dayAccessibilityLabel(args: {
|
|
522
|
+
/** The date, already formatted with the consumer's locale. */
|
|
523
|
+
dateLabel: string;
|
|
524
|
+
isToday?: boolean;
|
|
525
|
+
isSelected?: boolean;
|
|
526
|
+
isDisabled?: boolean;
|
|
527
|
+
hasEvents?: boolean;
|
|
528
|
+
/** Event count to announce; omit to leave the count out. */
|
|
529
|
+
eventCount?: number;
|
|
530
|
+
labels: CalendarLabels;
|
|
531
|
+
}): string;
|
|
532
|
+
//#endregion
|
|
463
533
|
//#region src/utils/eventDisplay.d.ts
|
|
464
534
|
/**
|
|
465
535
|
* Minimum event-box height (px) before the built-in renderer shows the time line
|
|
466
536
|
* on a narrow multi-column timed grid. Tied to the default theme's font sizes.
|
|
467
537
|
*/
|
|
468
|
-
declare const MIN_BOX_HEIGHT_FOR_TIME = 56;
|
|
538
|
+
export declare const MIN_BOX_HEIGHT_FOR_TIME = 56;
|
|
469
539
|
/** Hard-clip an overflowing title by default; opt into a trailing ellipsis. */
|
|
470
|
-
declare function titleEllipsizeMode(ellipsizeTitle: boolean): "clip" | "tail";
|
|
540
|
+
export declare function titleEllipsizeMode(ellipsizeTitle: boolean): "clip" | "tail";
|
|
471
541
|
/**
|
|
472
542
|
* Screen-reader label for an event: its title followed by "all day" or its time
|
|
473
543
|
* range (which the grid otherwise only conveys visually). Empty title is dropped.
|
|
474
544
|
*/
|
|
475
|
-
declare function eventAccessibilityLabel(args: {
|
|
545
|
+
export declare function eventAccessibilityLabel(args: {
|
|
476
546
|
title?: string;
|
|
477
547
|
isAllDay: boolean;
|
|
478
548
|
start: Date;
|
|
479
549
|
end: Date;
|
|
480
550
|
ampm: boolean;
|
|
481
|
-
/** Spoken text for an all-day event. Default
|
|
551
|
+
/** Spoken text for an all-day event. Default `labels.allDayEvent`. */
|
|
482
552
|
allDayLabel?: string;
|
|
553
|
+
/** Words for the all-day text and the time range. Default English. */
|
|
554
|
+
labels?: CalendarLabels;
|
|
483
555
|
}): string;
|
|
484
556
|
/**
|
|
485
557
|
* Context describing how an event is being rendered, passed to a consumer's
|
|
486
558
|
* {@link EventAccessibilityLabeler} so the label can adapt to the view (e.g. omit
|
|
487
559
|
* the time in month mode, or read the 12-hour clock when `ampm` is set).
|
|
488
560
|
*/
|
|
489
|
-
interface EventAccessibilityLabelContext {
|
|
561
|
+
export interface EventAccessibilityLabelContext {
|
|
490
562
|
/** The view the event is rendered in. */
|
|
491
563
|
mode: CalendarMode;
|
|
492
564
|
/** Whether the event sits in the all-day lane (or is an all-day event in month view). */
|
|
@@ -500,12 +572,12 @@ interface EventAccessibilityLabelContext {
|
|
|
500
572
|
* {@link eventAccessibilityLabel}. Shared by both renderers, so a custom label
|
|
501
573
|
* reads the same on web and native.
|
|
502
574
|
*/
|
|
503
|
-
type EventAccessibilityLabeler<T = unknown> = (event: CalendarEvent<T>, context: EventAccessibilityLabelContext) => string;
|
|
575
|
+
export type EventAccessibilityLabeler<T = unknown> = (event: CalendarEvent<T>, context: EventAccessibilityLabelContext) => string;
|
|
504
576
|
/**
|
|
505
577
|
* Month cells and the all-day lane show a single clipped line; timed-grid titles
|
|
506
578
|
* (`undefined`) wrap to fill the box.
|
|
507
579
|
*/
|
|
508
|
-
declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): number | undefined;
|
|
580
|
+
export declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): number | undefined;
|
|
509
581
|
/**
|
|
510
582
|
* The secondary line under the title in the built-in renderer, or `null` when
|
|
511
583
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
@@ -513,7 +585,7 @@ declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): numb
|
|
|
513
585
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
514
586
|
* does). Month cells and `showTime={false}` always return `null`.
|
|
515
587
|
*/
|
|
516
|
-
declare function eventTimeLabel(args: {
|
|
588
|
+
export declare function eventTimeLabel(args: {
|
|
517
589
|
mode: CalendarMode;
|
|
518
590
|
isAllDay: boolean;
|
|
519
591
|
start: Date;
|
|
@@ -529,7 +601,7 @@ declare function eventTimeLabel(args: {
|
|
|
529
601
|
* "h AM/PM" (e.g. "8 AM") when `ampm` is set. Exported so a custom hour renderer
|
|
530
602
|
* can reuse the same formatting.
|
|
531
603
|
*/
|
|
532
|
-
declare function formatHour(hour: number, opts?: {
|
|
604
|
+
export declare function formatHour(hour: number, opts?: {
|
|
533
605
|
ampm?: boolean;
|
|
534
606
|
}): string;
|
|
535
607
|
/**
|
|
@@ -539,9 +611,9 @@ declare function formatHour(hour: number, opts?: {
|
|
|
539
611
|
* {@link MIN_BOX_HEIGHT_FOR_TIME} tall. Runs on the UI thread inside the event
|
|
540
612
|
* renderer's animated style.
|
|
541
613
|
*/
|
|
542
|
-
declare function isTimeVisibleAtHeight(boxHeightPx: number | undefined, mode: CalendarMode): boolean;
|
|
614
|
+
export declare function isTimeVisibleAtHeight(boxHeightPx: number | undefined, mode: CalendarMode): boolean;
|
|
543
615
|
/** Layout for the built-in timed-grid event chip at a given box height. */
|
|
544
|
-
type EventChipLayout = {
|
|
616
|
+
export type EventChipLayout = {
|
|
545
617
|
/**
|
|
546
618
|
* Max whole title lines that fit in the box. `0` means "no clamp" (the box
|
|
547
619
|
* height is unknown, e.g. the schedule), so the title may wrap freely.
|
|
@@ -563,7 +635,7 @@ type EventChipLayout = {
|
|
|
563
635
|
* A `boxHeightPx` of `undefined` (the schedule has no live box height) returns
|
|
564
636
|
* `titleMaxLines: 0` (no clamp) with the unconditional time visibility.
|
|
565
637
|
*/
|
|
566
|
-
declare function eventChipLayout(args: {
|
|
638
|
+
export declare function eventChipLayout(args: {
|
|
567
639
|
boxHeightPx: number | undefined;
|
|
568
640
|
mode: CalendarMode;
|
|
569
641
|
hasTime: boolean;
|
|
@@ -572,7 +644,7 @@ declare function eventChipLayout(args: {
|
|
|
572
644
|
paddingYPx: number;
|
|
573
645
|
}): EventChipLayout;
|
|
574
646
|
/** How many month-cell chips fit in the available height. */
|
|
575
|
-
type MonthEventCapacity = {
|
|
647
|
+
export type MonthEventCapacity = {
|
|
576
648
|
/** Count when every event fits, with no overflow label. */
|
|
577
649
|
full: number;
|
|
578
650
|
/** Count that leaves room for the "+N more" label. */
|
|
@@ -583,16 +655,16 @@ type MonthEventCapacity = {
|
|
|
583
655
|
* `chipRowHeightPx` is one chip plus its gap; `moreRowHeightPx` is the overflow
|
|
584
656
|
* label plus its gap. Both counts are clamped to >= 0.
|
|
585
657
|
*/
|
|
586
|
-
declare function monthEventCapacity(availableHeightPx: number, chipRowHeightPx: number, moreRowHeightPx: number): MonthEventCapacity;
|
|
658
|
+
export declare function monthEventCapacity(availableHeightPx: number, chipRowHeightPx: number, moreRowHeightPx: number): MonthEventCapacity;
|
|
587
659
|
/**
|
|
588
660
|
* Chips to show for a day: all of them when they fit, otherwise `withMore` (at
|
|
589
661
|
* least one) so the rest collapse into a "+N more" label.
|
|
590
662
|
*/
|
|
591
|
-
declare function monthVisibleCount(total: number, capacity: MonthEventCapacity): number;
|
|
663
|
+
export declare function monthVisibleCount(total: number, capacity: MonthEventCapacity): number;
|
|
592
664
|
//#endregion
|
|
593
665
|
//#region src/utils/ical.d.ts
|
|
594
666
|
/** An event parsed from iCal, carrying the standard fields it also round-trips. */
|
|
595
|
-
interface ICalEvent extends ICalendarEvent {
|
|
667
|
+
export interface ICalEvent extends ICalendarEvent {
|
|
596
668
|
/** The VEVENT `UID`, if present. */
|
|
597
669
|
uid?: string;
|
|
598
670
|
/** The VEVENT `DESCRIPTION`, if present. */
|
|
@@ -601,7 +673,7 @@ interface ICalEvent extends ICalendarEvent {
|
|
|
601
673
|
location?: string;
|
|
602
674
|
}
|
|
603
675
|
/** Options for {@link toICalendar}. */
|
|
604
|
-
interface ToICalendarOptions {
|
|
676
|
+
export interface ToICalendarOptions {
|
|
605
677
|
/** `PRODID` written to the calendar header. Default `-//super-calendar//EN`. */
|
|
606
678
|
prodId?: string;
|
|
607
679
|
/** The `DTSTAMP` stamped on every event (when it was written). Default: now. */
|
|
@@ -618,7 +690,7 @@ interface ToICalendarOptions {
|
|
|
618
690
|
* const events = parseICalendar(await file.text());
|
|
619
691
|
* ```
|
|
620
692
|
*/
|
|
621
|
-
declare function parseICalendar(ics: string): ICalEvent[];
|
|
693
|
+
export declare function parseICalendar(ics: string): ICalEvent[];
|
|
622
694
|
/**
|
|
623
695
|
* Serialize events to an iCalendar (`.ics`) string. Timed events are written in
|
|
624
696
|
* UTC (`...Z`); all-day events (`allDay: true`) use `VALUE=DATE`. A `recurrence`
|
|
@@ -629,11 +701,11 @@ declare function parseICalendar(ics: string): ICalEvent[];
|
|
|
629
701
|
* const ics = toICalendar(events);
|
|
630
702
|
* ```
|
|
631
703
|
*/
|
|
632
|
-
declare function toICalendar(events: ICalEvent[], options?: ToICalendarOptions): string;
|
|
704
|
+
export declare function toICalendar(events: ICalEvent[], options?: ToICalendarOptions): string;
|
|
633
705
|
//#endregion
|
|
634
706
|
//#region src/utils/useNow.d.ts
|
|
635
707
|
/** Options for {@link useNow}. */
|
|
636
|
-
interface UseNowOptions {
|
|
708
|
+
export interface UseNowOptions {
|
|
637
709
|
/**
|
|
638
710
|
* A fixed instant to use instead of the device clock (a server-synced clock,
|
|
639
711
|
* or a stable value for tests). A fixed instant doesn't tick.
|
|
@@ -653,11 +725,11 @@ interface UseNowOptions {
|
|
|
653
725
|
* into `timeZone` when given, or pinned to a fixed `now` override. Drives the
|
|
654
726
|
* now indicator on both renderers so it can't disagree with zone-shifted events.
|
|
655
727
|
*/
|
|
656
|
-
declare function useNow(enabled: boolean, { now, timeZone, tickMs }?: UseNowOptions): Date;
|
|
728
|
+
export declare function useNow(enabled: boolean, { now, timeZone, tickMs }?: UseNowOptions): Date;
|
|
657
729
|
//#endregion
|
|
658
730
|
//#region src/utils/useEventSource.d.ts
|
|
659
731
|
/** Options for {@link useEventSource}. */
|
|
660
|
-
interface EventSourceOptions<T> {
|
|
732
|
+
export interface EventSourceOptions<T> {
|
|
661
733
|
/**
|
|
662
734
|
* Feed format for URL sources: `"json"` (default) expects an array of event
|
|
663
735
|
* objects with ISO `start`/`end` strings; `"ics"` parses an iCalendar feed.
|
|
@@ -674,7 +746,7 @@ interface EventSourceOptions<T> {
|
|
|
674
746
|
refetchIntervalMs?: number;
|
|
675
747
|
}
|
|
676
748
|
/** What {@link useEventSource} returns. */
|
|
677
|
-
interface EventSourceState<T> {
|
|
749
|
+
export interface EventSourceState<T> {
|
|
678
750
|
/** The fetched events; the previous batch is kept while a refetch runs or fails. */
|
|
679
751
|
events: CalendarEvent<T>[];
|
|
680
752
|
/** True while the first fetch (or a manual refetch) is in flight. */
|
|
@@ -698,11 +770,11 @@ interface EventSourceState<T> {
|
|
|
698
770
|
* <Calendar mode="week" date={date} events={events} onChangeDate={setDate} />;
|
|
699
771
|
* ```
|
|
700
772
|
*/
|
|
701
|
-
declare function useEventSource<T = unknown>(source: string | (() => Promise<CalendarEvent<T>[]>), { format, map, refetchIntervalMs }?: EventSourceOptions<T>): EventSourceState<T>;
|
|
773
|
+
export declare function useEventSource<T = unknown>(source: string | (() => Promise<CalendarEvent<T>[]>), { format, map, refetchIntervalMs }?: EventSourceOptions<T>): EventSourceState<T>;
|
|
702
774
|
//#endregion
|
|
703
775
|
//#region src/utils/layout.d.ts
|
|
704
776
|
/** An event placed on a single day's time grid by {@link layoutDayEvents}, with its vertical span and overlap column. */
|
|
705
|
-
type PositionedEvent<T> = {
|
|
777
|
+
export type PositionedEvent<T> = {
|
|
706
778
|
/** The source event for this segment. */
|
|
707
779
|
event: CalendarEvent<T>;
|
|
708
780
|
/** Hours from midnight to the event's segment start on this day (fractional). */
|
|
@@ -723,32 +795,32 @@ type PositionedEvent<T> = {
|
|
|
723
795
|
* on `day` (e.g. a 23:00→01:00 event renders 23:00–24:00 on the start day and
|
|
724
796
|
* 00:00–01:00 on the next). Pure — safe to call per render, never per frame.
|
|
725
797
|
*/
|
|
726
|
-
declare function layoutDayEvents<T>(events: CalendarEvent<T>[], day: Date): PositionedEvent<T>[];
|
|
798
|
+
export declare function layoutDayEvents<T>(events: CalendarEvent<T>[], day: Date): PositionedEvent<T>[];
|
|
727
799
|
/**
|
|
728
800
|
* Whether an event belongs in the all-day lane. An explicit `allDay` flag wins;
|
|
729
801
|
* otherwise it's inferred when the event spans whole days (both `start` and
|
|
730
802
|
* `end` land on midnight, e.g. an iCal-style all-day event). Pure.
|
|
731
803
|
*/
|
|
732
|
-
declare function isAllDayEvent<T>(event: CalendarEvent<T>): boolean;
|
|
804
|
+
export declare function isAllDayEvent<T>(event: CalendarEvent<T>): boolean;
|
|
733
805
|
/**
|
|
734
806
|
* The `startOfDay` ISO keys of every calendar day an event touches (inclusive).
|
|
735
807
|
* An event ending exactly at midnight does not count the following day. Used to
|
|
736
808
|
* index events by day for the month grid. Pure.
|
|
737
809
|
*/
|
|
738
|
-
declare function eventDayKeys<T>(event: CalendarEvent<T>): string[];
|
|
810
|
+
export declare function eventDayKeys<T>(event: CalendarEvent<T>): string[];
|
|
739
811
|
/**
|
|
740
812
|
* Index events by the `startOfDay` ISO key of every day they touch (via
|
|
741
813
|
* {@link eventDayKeys}), so a month grid can look up a day's events with
|
|
742
814
|
* `startOfDay(date).toISOString()`. Built once and shared across month cells.
|
|
743
815
|
*/
|
|
744
|
-
declare function groupEventsByDay<T>(events: readonly CalendarEvent<T>[]): Map<string, CalendarEvent<T>[]>;
|
|
816
|
+
export declare function groupEventsByDay<T>(events: readonly CalendarEvent<T>[]): Map<string, CalendarEvent<T>[]>;
|
|
745
817
|
/**
|
|
746
818
|
* Order a day's events for the month and list views: all-day events come first
|
|
747
819
|
* (they head the day regardless of their start time), then timed events by start.
|
|
748
820
|
* Shared by both renderers so the order is identical. Use as an `Array.sort`
|
|
749
821
|
* comparator.
|
|
750
822
|
*/
|
|
751
|
-
declare function compareDayEvents<T>(a: CalendarEvent<T>, b: CalendarEvent<T>): number;
|
|
823
|
+
export declare function compareDayEvents<T>(a: CalendarEvent<T>, b: CalendarEvent<T>): number;
|
|
752
824
|
/**
|
|
753
825
|
* The closed hour-spans of a day to shade on the time grid, given a
|
|
754
826
|
* `businessHours` callback and the visible `[minHour, maxHour]` window: the spans
|
|
@@ -757,18 +829,18 @@ declare function compareDayEvents<T>(a: CalendarEvent<T>, b: CalendarEvent<T>):
|
|
|
757
829
|
* callback returns `undefined`. Shared by both renderers so shading stays
|
|
758
830
|
* identical. Co-located with `groupEventsByDay`; both feed the grid layout.
|
|
759
831
|
*/
|
|
760
|
-
declare function closedHourBands(day: Date, businessHours: BusinessHours | undefined, minHour?: number, maxHour?: number): {
|
|
832
|
+
export declare function closedHourBands(day: Date, businessHours: BusinessHours | undefined, minHour?: number, maxHour?: number): {
|
|
761
833
|
start: number;
|
|
762
834
|
end: number;
|
|
763
835
|
}[];
|
|
764
836
|
/** True when the event paints as a shaded background band, not an event box. */
|
|
765
|
-
declare function isBackgroundEvent<T>(event: CalendarEvent<T>): boolean;
|
|
837
|
+
export declare function isBackgroundEvent<T>(event: CalendarEvent<T>): boolean;
|
|
766
838
|
/**
|
|
767
839
|
* The background events of `events` sliced to `day`, as fractional-hour bands
|
|
768
840
|
* (an all-day or multi-day background covers the day's full window). Shared by
|
|
769
841
|
* both renderers so the shading can't disagree.
|
|
770
842
|
*/
|
|
771
|
-
declare function backgroundBandsForDay<T>(events: CalendarEvent<T>[], day: Date): {
|
|
843
|
+
export declare function backgroundBandsForDay<T>(events: CalendarEvent<T>[], day: Date): {
|
|
772
844
|
event: CalendarEvent<T>;
|
|
773
845
|
startHours: number;
|
|
774
846
|
endHours: number;
|
|
@@ -782,7 +854,7 @@ declare function backgroundBandsForDay<T>(events: CalendarEvent<T>[], day: Date)
|
|
|
782
854
|
* square off the clipped end). Columns index into the row's `days` array, so with
|
|
783
855
|
* `hiddenDays` a bar spans the visible columns it touches.
|
|
784
856
|
*/
|
|
785
|
-
interface MonthEventSegment<T = unknown> {
|
|
857
|
+
export interface MonthEventSegment<T = unknown> {
|
|
786
858
|
event: CalendarEvent<T>;
|
|
787
859
|
/** First covered column in the row (0-based, inclusive). */
|
|
788
860
|
startCol: number;
|
|
@@ -796,7 +868,7 @@ interface MonthEventSegment<T = unknown> {
|
|
|
796
868
|
continuesAfter: boolean;
|
|
797
869
|
}
|
|
798
870
|
/** The laid-out event segments for one week row, with the number of lanes used. */
|
|
799
|
-
interface MonthWeekEvents<T = unknown> {
|
|
871
|
+
export interface MonthWeekEvents<T = unknown> {
|
|
800
872
|
segments: MonthEventSegment<T>[];
|
|
801
873
|
/** Highest lane index used + 1 (0 when the row has no events). */
|
|
802
874
|
laneCount: number;
|
|
@@ -816,9 +888,9 @@ interface MonthWeekEvents<T = unknown> {
|
|
|
816
888
|
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
817
889
|
* matching how calendars keep long events on the upper lanes.
|
|
818
890
|
*/
|
|
819
|
-
declare function layoutMonthWeek<T>(days: Date[], events: readonly CalendarEvent<T>[]): MonthWeekEvents<T>;
|
|
891
|
+
export declare function layoutMonthWeek<T>(days: Date[], events: readonly CalendarEvent<T>[]): MonthWeekEvents<T>;
|
|
820
892
|
/** A single day in the grid, with all the state a custom cell needs to render. */
|
|
821
|
-
interface MonthGridDay {
|
|
893
|
+
export interface MonthGridDay {
|
|
822
894
|
/** The day this cell represents. */
|
|
823
895
|
date: Date;
|
|
824
896
|
/** Stable `yyyy-MM-dd` id, handy as a React key. */
|
|
@@ -843,21 +915,21 @@ interface MonthGridDay {
|
|
|
843
915
|
isInRange: boolean;
|
|
844
916
|
}
|
|
845
917
|
/** One week row. */
|
|
846
|
-
interface MonthGridWeek {
|
|
918
|
+
export interface MonthGridWeek {
|
|
847
919
|
/** Stable id for the week row, handy as a React key. */
|
|
848
920
|
id: string;
|
|
849
921
|
/** The seven days of the row, in display order. */
|
|
850
922
|
days: MonthGridDay[];
|
|
851
923
|
}
|
|
852
924
|
/** A weekday header cell (e.g. "Mon"). */
|
|
853
|
-
interface MonthGridWeekday {
|
|
925
|
+
export interface MonthGridWeekday {
|
|
854
926
|
/** A representative date for the column, used to derive the label. */
|
|
855
927
|
date: Date;
|
|
856
928
|
/** The short weekday name (e.g. "Mon"), localised via `locale`. */
|
|
857
929
|
label: string;
|
|
858
930
|
}
|
|
859
931
|
/** The full grid for one month: the week rows and the weekday header cells. */
|
|
860
|
-
interface MonthGrid {
|
|
932
|
+
export interface MonthGrid {
|
|
861
933
|
/** The week rows, padded to whole weeks. */
|
|
862
934
|
weeks: MonthGridWeek[];
|
|
863
935
|
/** The weekday header cells, in display order. */
|
|
@@ -867,15 +939,15 @@ interface MonthGrid {
|
|
|
867
939
|
* Weekday header label width: `narrow` ("M"), `short` ("Mon", the default), or
|
|
868
940
|
* `long` ("Monday").
|
|
869
941
|
*/
|
|
870
|
-
type WeekdayFormat = "narrow" | "short" | "long";
|
|
942
|
+
export type WeekdayFormat = "narrow" | "short" | "long";
|
|
871
943
|
/**
|
|
872
944
|
* The date-fns format token for a {@link WeekdayFormat}. Exposed so a renderer
|
|
873
945
|
* that formats its own weekday header (rather than reading {@link buildMonthGrid})
|
|
874
946
|
* keeps the same mapping.
|
|
875
947
|
*/
|
|
876
|
-
declare function weekdayFormatToken(format: WeekdayFormat): string;
|
|
948
|
+
export declare function weekdayFormatToken(format: WeekdayFormat): string;
|
|
877
949
|
/** Options for {@link buildMonthGrid} and {@link useMonthGrid}. */
|
|
878
|
-
interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
950
|
+
export interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
879
951
|
/** First day of the week. Sunday = 0 (default) … Saturday = 6. */
|
|
880
952
|
weekStartsOn?: WeekStartsOn;
|
|
881
953
|
/** Weekdays (0=Sunday…6=Saturday) to drop from the grid and header. */
|
|
@@ -898,7 +970,7 @@ interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
|
898
970
|
* annotated with selection/disabled/today state. Use this when you need the
|
|
899
971
|
* data outside React; inside a component prefer {@link useMonthGrid}.
|
|
900
972
|
*/
|
|
901
|
-
declare function buildMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
973
|
+
export declare function buildMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
902
974
|
/**
|
|
903
975
|
* Headless month-grid hook. Returns the weeks and weekday headers for `month`,
|
|
904
976
|
* each day annotated with selection/disabled/today state, so you can render a
|
|
@@ -909,7 +981,7 @@ declare function buildMonthGrid(month: Date, options?: UseMonthGridOptions): Mon
|
|
|
909
981
|
* // map weekdays -> header cells, weeks -> rows, days -> your own <DayCell />
|
|
910
982
|
* ```
|
|
911
983
|
*/
|
|
912
|
-
declare function useMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
984
|
+
export declare function useMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
913
985
|
//#endregion
|
|
914
986
|
//#region src/utils/recurrence.d.ts
|
|
915
987
|
/**
|
|
@@ -918,7 +990,7 @@ declare function useMonthGrid(month: Date, options?: UseMonthGridOptions): Month
|
|
|
918
990
|
* result is ready to hand to `<Calendar events={...} />`. Each occurrence keeps
|
|
919
991
|
* the original event's duration and fields (minus `recurrence`).
|
|
920
992
|
*/
|
|
921
|
-
declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date): CalendarEvent<T>[];
|
|
993
|
+
export declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date): CalendarEvent<T>[];
|
|
922
994
|
//#endregion
|
|
923
995
|
//#region src/utils/timezone.d.ts
|
|
924
996
|
/**
|
|
@@ -931,7 +1003,7 @@ declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart
|
|
|
931
1003
|
* web). The result is for display/layout only; it no longer points at the
|
|
932
1004
|
* original UTC instant, so don't round-trip it back to a real time.
|
|
933
1005
|
*/
|
|
934
|
-
declare function toZonedTime(date: Date, timeZone: string): Date;
|
|
1006
|
+
export declare function toZonedTime(date: Date, timeZone: string): Date;
|
|
935
1007
|
/**
|
|
936
1008
|
* The inverse of {@link toZonedTime}: given a wall-clock time in `timeZone`,
|
|
937
1009
|
* return the absolute UTC instant. Pass the wall clock as a `Date` whose **UTC**
|
|
@@ -939,12 +1011,11 @@ declare function toZonedTime(date: Date, timeZone: string): Date;
|
|
|
939
1011
|
* resolve iCal `TZID` times; DST-correct via a two-pass offset (ambiguous
|
|
940
1012
|
* fall-back times resolve to the post-transition offset).
|
|
941
1013
|
*/
|
|
942
|
-
declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
1014
|
+
export declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
943
1015
|
/**
|
|
944
1016
|
* Map every event's `start`/`end` through {@link toZonedTime} so the calendar
|
|
945
1017
|
* displays them in `timeZone`. Other fields are preserved. Memoize the result
|
|
946
1018
|
* (e.g. with `useMemo`) since it allocates new dates.
|
|
947
1019
|
*/
|
|
948
|
-
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
949
|
-
//#endregion
|
|
950
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSourceOptions, EventSourceState, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, UseNowOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
1020
|
+
export declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
1021
|
+
//#endregion
|