@ilamy/calendar 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/index.d.ts +502 -112
- package/dist/index.js +3 -3
- package/dist/plugins/agenda.d.ts +42 -2
- package/dist/plugins/agenda.js +1 -1
- package/dist/plugins/drag-to-create.d.ts +42 -2
- package/dist/plugins/drag-to-create.js +1 -1
- package/dist/plugins/recurrence.d.ts +42 -2
- package/dist/plugins/recurrence.js +2 -2
- package/dist/shared/chunk-58t5nwpa.js +2 -0
- package/dist/shared/chunk-8n7287tn.js +2 -0
- package/dist/shared/{chunk-1x8xjsbq.js → chunk-fdfxtah1.js} +2 -2
- package/dist/shared/chunk-hd24e4t0.js +2 -0
- package/dist/shared/chunk-qc1dpk9c.js +2 -0
- package/dist/shared/{chunk-p26ryh5z.js → chunk-ybbzp3rf.js} +2 -2
- package/dist/testing/index.d.ts +836 -34
- package/dist/testing/index.js +1 -1
- package/package.json +3 -2
- package/dist/shared/chunk-cn24081x.js +0 -2
- package/dist/shared/chunk-mn44xvnt.js +0 -2
- package/dist/shared/chunk-tfk3a0d4.js +0 -2
- package/dist/shared/chunk-xf8cy2gp.js +0 -2
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode as
|
|
2
|
-
import { ComponentType, ReactNode } from "react";
|
|
1
|
+
import { ReactNode as ReactNode7 } from "react";
|
|
2
|
+
import { ComponentType, ReactNode as ReactNode2 } from "react";
|
|
3
3
|
import { Dayjs as Dayjs2, ManipulateType as ManipulateType2 } from "dayjs";
|
|
4
4
|
/**
|
|
5
5
|
* Core calendar event interface representing a single calendar event.
|
|
@@ -48,6 +48,27 @@ interface CalendarEvent {
|
|
|
48
48
|
* @example { meetingType: 'standup', attendees: ['john', 'jane'] }
|
|
49
49
|
*/
|
|
50
50
|
data?: Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether this event can be moved. Beats the calendar's
|
|
53
|
+
* `editable`; `startEditable` beats this one (FullCalendar
|
|
54
|
+
* `event.editable`).
|
|
55
|
+
*/
|
|
56
|
+
editable?: boolean;
|
|
57
|
+
/** Whether this event can be moved. Defaults to `editable`. */
|
|
58
|
+
startEditable?: boolean;
|
|
59
|
+
/** Whether this event can be resized by its edges. Defaults to `editable`. */
|
|
60
|
+
durationEditable?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A candidate placement for a dragged event, handed to `eventAllow` (the
|
|
64
|
+
* counterpart of FullCalendar's `DateSpanApi` plus the resource).
|
|
65
|
+
*/
|
|
66
|
+
interface EventDropInfo {
|
|
67
|
+
start: Dayjs2;
|
|
68
|
+
end: Dayjs2;
|
|
69
|
+
allDay: boolean;
|
|
70
|
+
/** The resource the event would land on, in resource views. */
|
|
71
|
+
resourceId?: string | number;
|
|
51
72
|
}
|
|
52
73
|
/**
|
|
53
74
|
* Supported days of the week for calendar configuration.
|
|
@@ -60,8 +81,15 @@ type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "fr
|
|
|
60
81
|
*/
|
|
61
82
|
interface BusinessHours {
|
|
62
83
|
/**
|
|
63
|
-
* Days of the week to apply business hours to.
|
|
64
|
-
*
|
|
84
|
+
* Days of the week to apply business hours to. Omitted, the hours apply to
|
|
85
|
+
* every day, weekends included, in both the object and the array form.
|
|
86
|
+
*
|
|
87
|
+
* This deviates from FullCalendar, which defaults an object to Monday-Friday
|
|
88
|
+
* and ignores an array entry without days
|
|
89
|
+
* (core/src/structs/business-hours.ts, v6.1.21). Kept until the next major
|
|
90
|
+
* (see the TODO in business-hours.ts); list the days explicitly to get
|
|
91
|
+
* weekdays only.
|
|
92
|
+
* @default every day
|
|
65
93
|
*/
|
|
66
94
|
daysOfWeek?: WeekDays[];
|
|
67
95
|
/**
|
|
@@ -128,6 +156,23 @@ interface PluginMutationResult {
|
|
|
128
156
|
added: CalendarEvent[];
|
|
129
157
|
/** Existing rows to persist via `onEventDelete`. */
|
|
130
158
|
deleted: CalendarEvent[];
|
|
159
|
+
/**
|
|
160
|
+
* The update as it was stored, when that is less than what was asked: a
|
|
161
|
+
* scope that keeps its own day applies only the time of day of a drop on
|
|
162
|
+
* another day. `delta` and `endDelta` describe these, not the request.
|
|
163
|
+
* Omit it when the update was stored as asked.
|
|
164
|
+
*/
|
|
165
|
+
appliedUpdates?: Partial<CalendarEvent>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* How far an update moved an event's start: whole calendar days plus the change
|
|
169
|
+
* in wall-clock time of day.
|
|
170
|
+
*/
|
|
171
|
+
interface EventDelta {
|
|
172
|
+
/** Whole calendar days, in the calendar's zone. */
|
|
173
|
+
days: number;
|
|
174
|
+
/** Change in the time of day on the wall clock, in milliseconds. */
|
|
175
|
+
milliseconds: number;
|
|
131
176
|
}
|
|
132
177
|
/**
|
|
133
178
|
* One user action and every stored row it touched, reported once through
|
|
@@ -140,7 +185,10 @@ interface PluginMutationResult {
|
|
|
140
185
|
interface EventsChange {
|
|
141
186
|
/** What the user did. */
|
|
142
187
|
action: "add" | "update" | "delete";
|
|
143
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* The event the user acted on, as it was shown before the change (an
|
|
190
|
+
* occurrence, for a series). The changed rows are in `updated`.
|
|
191
|
+
*/
|
|
144
192
|
event: CalendarEvent;
|
|
145
193
|
/**
|
|
146
194
|
* The scope chosen in the plugin's scope dialog, when a plugin manages the
|
|
@@ -154,6 +202,34 @@ interface EventsChange {
|
|
|
154
202
|
updated: CalendarEvent[];
|
|
155
203
|
/** Removed rows, the same ones passed to `onEventDelete`. */
|
|
156
204
|
deleted: CalendarEvent[];
|
|
205
|
+
/**
|
|
206
|
+
* For `'update'`: how far the event's start moved (zero when it did not).
|
|
207
|
+
* Undefined for `'add'` and `'delete'`. A timed event that became all-day is
|
|
208
|
+
* measured from the start of its own day.
|
|
209
|
+
*/
|
|
210
|
+
delta?: EventDelta;
|
|
211
|
+
/**
|
|
212
|
+
* For `'update'`: how far the event's end moved (zero when it did not),
|
|
213
|
+
* measured the same way as `delta`, from the two ends as they are. A resize
|
|
214
|
+
* from the end edge sets only this one and a resize from the start edge only
|
|
215
|
+
* `delta`. A move sets both to the same amount, except that a timed event
|
|
216
|
+
* moved onto the all-day row has `delta` measured from the start of its day,
|
|
217
|
+
* so the two can differ. Undefined for `'add'` and `'delete'`.
|
|
218
|
+
*
|
|
219
|
+
* FullCalendar reports a resize through its own `eventResize` callback with
|
|
220
|
+
* `startDelta` and `endDelta`; ilamy reports every action once, through
|
|
221
|
+
* `onEventsChange` (#309), so `delta` is the `startDelta`.
|
|
222
|
+
*/
|
|
223
|
+
endDelta?: EventDelta;
|
|
224
|
+
/**
|
|
225
|
+
* Undoes the whole action in the calendar's own store: removes `added`,
|
|
226
|
+
* restores the previous version of every row in `updated`, and puts back
|
|
227
|
+
* `deleted`. A later edit of one of those rows is overwritten; rows other
|
|
228
|
+
* actions added or changed since are kept. It fires no callbacks, and
|
|
229
|
+
* calling it again does nothing. A consumer that controls `events` reverts
|
|
230
|
+
* its own state instead.
|
|
231
|
+
*/
|
|
232
|
+
revert: () => void;
|
|
157
233
|
}
|
|
158
234
|
/**
|
|
159
235
|
* Calendar configuration handed to a view's `columns()`/`renderHeader()`.
|
|
@@ -163,12 +239,23 @@ interface EventsChange {
|
|
|
163
239
|
*/
|
|
164
240
|
interface ViewConfig {
|
|
165
241
|
firstDayOfWeek: number;
|
|
242
|
+
/** Weekdays (0 = Sunday) the view does not draw. Absent when none are hidden. */
|
|
166
243
|
hiddenDays?: Set<number>;
|
|
167
244
|
businessHours?: BusinessHours | BusinessHours[];
|
|
168
245
|
hideNonBusinessHours?: boolean;
|
|
246
|
+
/** First visible time in hour grids, `'HH:mm'`. Unset shows from midnight. */
|
|
247
|
+
slotMinTime?: string;
|
|
248
|
+
/** End of the visible time in hour grids, exclusive, `'HH:mm'` up to `'24:00'`. */
|
|
249
|
+
slotMaxTime?: string;
|
|
169
250
|
/** The resource axis. Set only when the calendar renders resources. */
|
|
170
251
|
resources?: Resource[];
|
|
171
252
|
/**
|
|
253
|
+
* Whether the calendar is a resource calendar: it has resources, or is still
|
|
254
|
+
* loading them (then `resources` is empty or absent). When absent, it is
|
|
255
|
+
* derived from `resources` being non-empty.
|
|
256
|
+
*/
|
|
257
|
+
hasResourceAxis?: boolean;
|
|
258
|
+
/**
|
|
172
259
|
* The calendar-level resource arrangement (the user's choice): where the
|
|
173
260
|
* resource axis goes. Only meaningful when `resources` is set.
|
|
174
261
|
*/
|
|
@@ -194,7 +281,7 @@ interface VerticalColumnSpec {
|
|
|
194
281
|
className?: string;
|
|
195
282
|
/** Label-only column (e.g. the time gutter): renders no events. */
|
|
196
283
|
noEvents?: boolean;
|
|
197
|
-
renderCell?: (date: Dayjs2) =>
|
|
284
|
+
renderCell?: (date: Dayjs2) => ReactNode2;
|
|
198
285
|
/**
|
|
199
286
|
* Resource-axis identity when the column belongs to one resource. The
|
|
200
287
|
* single carrier: consumers derive the id from `resource.id`.
|
|
@@ -220,6 +307,11 @@ interface HorizontalRowSpec {
|
|
|
220
307
|
columns?: HorizontalCellSpec[];
|
|
221
308
|
className?: string;
|
|
222
309
|
showDayNumber?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Marks the row as one calendar week, so it shows its week number at its
|
|
312
|
+
* start when the calendar's `weekNumbers` is `true`.
|
|
313
|
+
*/
|
|
314
|
+
showWeekNumber?: boolean;
|
|
223
315
|
/** Resource-axis identity when the row belongs to one resource. */
|
|
224
316
|
resource?: Resource;
|
|
225
317
|
}
|
|
@@ -295,7 +387,7 @@ interface PluginView {
|
|
|
295
387
|
*/
|
|
296
388
|
layout?: "vertical" | "horizontal";
|
|
297
389
|
/** Header row content rendered above the grid by the shared renderer. */
|
|
298
|
-
renderHeader?: (ctx: ViewHeaderContext) =>
|
|
390
|
+
renderHeader?: (ctx: ViewHeaderContext) => ReactNode2;
|
|
299
391
|
/**
|
|
300
392
|
* Whether `columns()` composes the resource axis when `config.resources`
|
|
301
393
|
* is set. Defaults to false; the view switcher hides resource-incapable
|
|
@@ -331,7 +423,7 @@ interface IlamyPlugin {
|
|
|
331
423
|
managesEvent?: (event: CalendarEvent) => boolean;
|
|
332
424
|
applyEdit?: (args: PluginMutationArgs) => CalendarEvent[] | PluginMutationResult;
|
|
333
425
|
applyDelete?: (args: PluginMutationArgs) => CalendarEvent[] | PluginMutationResult;
|
|
334
|
-
renderSlot?: (slotName: string, context: unknown) =>
|
|
426
|
+
renderSlot?: (slotName: string, context: unknown) => ReactNode2;
|
|
335
427
|
/**
|
|
336
428
|
* Contributes arbitrary data to a named point. Additive: all plugins may
|
|
337
429
|
* contribute to the same point; the runtime aggregates all results via
|
|
@@ -349,12 +441,13 @@ interface IlamyPlugin {
|
|
|
349
441
|
* among all plugin providers.
|
|
350
442
|
*/
|
|
351
443
|
provider?: ComponentType<{
|
|
352
|
-
children:
|
|
444
|
+
children: ReactNode2;
|
|
353
445
|
}>;
|
|
354
446
|
}
|
|
447
|
+
import { ReactNode as ReactNode6 } from "react";
|
|
355
448
|
import { Dayjs as DayjsInstance } from "dayjs";
|
|
356
449
|
type Dayjs3 = DayjsInstance;
|
|
357
|
-
import { ReactNode as
|
|
450
|
+
import { ReactNode as ReactNode5, Ref } from "react";
|
|
358
451
|
declare const defaultTranslations: {
|
|
359
452
|
today: string;
|
|
360
453
|
create: string;
|
|
@@ -376,6 +469,15 @@ declare const defaultTranslations: {
|
|
|
376
469
|
endDate: string;
|
|
377
470
|
startTime: string;
|
|
378
471
|
searchTime: string;
|
|
472
|
+
selectTime: string;
|
|
473
|
+
noTimeFound: string;
|
|
474
|
+
pickDate: string;
|
|
475
|
+
previousMonth: string;
|
|
476
|
+
nextMonth: string;
|
|
477
|
+
previousYear: string;
|
|
478
|
+
nextYear: string;
|
|
479
|
+
previousYears: string;
|
|
480
|
+
nextYears: string;
|
|
379
481
|
endTime: string;
|
|
380
482
|
color: string;
|
|
381
483
|
createEvent: string;
|
|
@@ -454,6 +556,7 @@ interface EventFormProps {
|
|
|
454
556
|
onDelete?: (event: CalendarEvent) => void;
|
|
455
557
|
onClose: () => void;
|
|
456
558
|
}
|
|
559
|
+
import React3 from "react";
|
|
457
560
|
/**
|
|
458
561
|
* Available calendar view types. The built-in views (day, week, month, year)
|
|
459
562
|
* are `PluginView` specs in `features/calendar/components/views`; plugins may
|
|
@@ -465,11 +568,98 @@ type CalendarView = string;
|
|
|
465
568
|
*/
|
|
466
569
|
type TimeFormat = "12-hour" | "24-hour";
|
|
467
570
|
/**
|
|
571
|
+
* The public calendar API surface exposed by useIlamyCalendarContext() — for consumers and plugin
|
|
572
|
+
* components. The full internal context is intentionally not exported.
|
|
573
|
+
*/
|
|
574
|
+
interface IlamyCalendarApi {
|
|
575
|
+
readonly currentDate: Dayjs3;
|
|
576
|
+
/** The active view's current visible date range (what is on screen). */
|
|
577
|
+
readonly currentRange: DateRange;
|
|
578
|
+
readonly view: CalendarView;
|
|
579
|
+
readonly events: CalendarEvent[];
|
|
580
|
+
readonly rawEvents: CalendarEvent[];
|
|
581
|
+
/**
|
|
582
|
+
* Fetches the visible range again through the `events` function, whatever
|
|
583
|
+
* `lazyFetching` says. The events shown stay until the new ones arrive. Does
|
|
584
|
+
* nothing when `events` is an array.
|
|
585
|
+
*/
|
|
586
|
+
readonly refetchEvents: () => void;
|
|
587
|
+
/**
|
|
588
|
+
* Scrolls the hour grids to a time of day, `'HH:mm'` or `'HH:mm:ss'`, the way
|
|
589
|
+
* the `scrollTime` prop does at the start (the minute lands that far into
|
|
590
|
+
* the hour). Does nothing in a view without an hour axis, such as month.
|
|
591
|
+
*/
|
|
592
|
+
readonly scrollToTime: (time: string) => void;
|
|
593
|
+
/**
|
|
594
|
+
* Calls the `resources` function again. The resources shown stay until the
|
|
595
|
+
* new ones arrive. Does nothing when `resources` is an array.
|
|
596
|
+
*/
|
|
597
|
+
readonly refetchResources: () => void;
|
|
598
|
+
readonly isEventFormOpen: boolean;
|
|
599
|
+
readonly selectedEvent: CalendarEvent | null;
|
|
600
|
+
readonly selectedDate: Dayjs3 | null;
|
|
601
|
+
readonly firstDayOfWeek: number;
|
|
602
|
+
readonly resources: Resource[];
|
|
603
|
+
/** Whether the calendar lays out a resource axis: it has resources, or is still loading them. */
|
|
604
|
+
readonly hasResourceAxis: boolean;
|
|
605
|
+
/** Axis the views lay out along: 'horizontal' (columns) or 'vertical' (rows). */
|
|
606
|
+
readonly orientation: "horizontal" | "vertical";
|
|
607
|
+
readonly setCurrentDate: (date: Dayjs3) => void;
|
|
608
|
+
readonly selectDate: (date: Dayjs3) => void;
|
|
609
|
+
/** Switch view; pass `date` to move there atomically in the same update. */
|
|
610
|
+
readonly setView: (view: CalendarView, date?: Dayjs3) => void;
|
|
611
|
+
readonly nextPeriod: () => void;
|
|
612
|
+
readonly prevPeriod: () => void;
|
|
613
|
+
readonly today: () => void;
|
|
614
|
+
readonly addEvent: (event: CalendarEvent) => void;
|
|
615
|
+
readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
|
|
616
|
+
readonly deleteEvent: (eventId: string | number) => void;
|
|
617
|
+
readonly openEventForm: (eventData?: OpenEventFormInput) => void;
|
|
618
|
+
readonly closeEventForm: () => void;
|
|
619
|
+
/**
|
|
620
|
+
* Handle a click on an existing event: runs the consumer's `onEventClick`
|
|
621
|
+
* callback if provided, otherwise opens the event for editing. Lets plugin
|
|
622
|
+
* views (e.g. agenda) handle event clicks identically to the built-in views.
|
|
623
|
+
*/
|
|
624
|
+
readonly onEventClick: (event: CalendarEvent) => void;
|
|
625
|
+
/**
|
|
626
|
+
* The consumer's custom current-time-indicator renderer, if provided. Lets
|
|
627
|
+
* plugin views (e.g. agenda) render the indicator consistently with the
|
|
628
|
+
* built-in views via the shared `@ilamy/ui` CurrentTimeIndicator.
|
|
629
|
+
*/
|
|
630
|
+
readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React3.ReactNode;
|
|
631
|
+
/**
|
|
632
|
+
* Events whose resource membership (`resourceIds`, falling back to
|
|
633
|
+
* `resourceId`) contains the given resource. On a calendar without
|
|
634
|
+
* resources this simply filters by the events' own resource fields.
|
|
635
|
+
*/
|
|
636
|
+
readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
|
|
637
|
+
readonly businessHours?: BusinessHours | BusinessHours[];
|
|
638
|
+
readonly t: TranslatorFunction;
|
|
639
|
+
readonly timeFormat: TimeFormat;
|
|
640
|
+
readonly timezone?: string;
|
|
641
|
+
readonly currentLocale: string;
|
|
642
|
+
readonly getEventsForDateRange: (start: Dayjs3, end: Dayjs3) => CalendarEvent[];
|
|
643
|
+
readonly applyScopedEdit: (event: CalendarEvent, updates: Partial<CalendarEvent>, scope: unknown) => void;
|
|
644
|
+
readonly applyScopedDelete: (event: CalendarEvent, scope: unknown) => void;
|
|
645
|
+
readonly getEventManager: (event: CalendarEvent) => IlamyPlugin | undefined;
|
|
646
|
+
readonly renderSlot: (slotName: string, context: unknown) => React3.ReactNode[];
|
|
647
|
+
readonly collect: (point: string, context: unknown) => unknown[];
|
|
648
|
+
readonly getViews: () => PluginView[];
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
468
651
|
* Granularity of the time grid in minutes for day, week, and resource hour views.
|
|
469
|
-
*
|
|
470
|
-
*
|
|
652
|
+
* `60` shows one row per hour with no sub-hour lines. `30` shows two rows per
|
|
653
|
+
* hour. `15` shows four rows per hour with dashed sub-hour separators.
|
|
471
654
|
*/
|
|
472
655
|
type SlotDuration = 15 | 30 | 60;
|
|
656
|
+
/** The finest sizes a drag, a resize or a drag-to-create selection can snap to. */
|
|
657
|
+
type SnapDuration = 15 | 30;
|
|
658
|
+
/**
|
|
659
|
+
* How a week number is counted: the locale's own count (`'local'`) or ISO 8601
|
|
660
|
+
* (`'ISO'`).
|
|
661
|
+
*/
|
|
662
|
+
type WeekNumberCalculation = "local" | "ISO";
|
|
473
663
|
/**
|
|
474
664
|
* Which slice of an event a `renderEvent` call is drawing.
|
|
475
665
|
*
|
|
@@ -504,6 +694,18 @@ interface CalendarClassesOverride {
|
|
|
504
694
|
disabledCell?: string;
|
|
505
695
|
}
|
|
506
696
|
/**
|
|
697
|
+
* This interface extends the base CalendarEvent but allows more flexible date types
|
|
698
|
+
* for the start and end properties. The component will automatically convert these
|
|
699
|
+
* to dayjs objects internally for consistent date handling.
|
|
700
|
+
*
|
|
701
|
+
* @interface IlamyCalendarPropEvent
|
|
702
|
+
* @extends {Omit<CalendarEvent, 'start' | 'end'>}
|
|
703
|
+
*/
|
|
704
|
+
interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
|
|
705
|
+
start: Dayjs3 | Date | string;
|
|
706
|
+
end: Dayjs3 | Date | string;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
507
709
|
* Information passed to the onCellClick callback.
|
|
508
710
|
* Uses named properties for extensibility.
|
|
509
711
|
*/
|
|
@@ -522,6 +724,14 @@ interface CellInfo {
|
|
|
522
724
|
allDay?: boolean;
|
|
523
725
|
}
|
|
524
726
|
/**
|
|
727
|
+
* Input accepted by `openEventForm`. A partial event, optionally carrying the
|
|
728
|
+
* full resource of the clicked cell (`CellInfo` is assignable as-is). When no
|
|
729
|
+
* explicit `resourceId` is given, the carried resource's id is used.
|
|
730
|
+
*/
|
|
731
|
+
type OpenEventFormInput = Partial<CalendarEvent> & {
|
|
732
|
+
resource?: Resource;
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
525
735
|
* Props passed to the custom render function for the current time indicator.
|
|
526
736
|
* Allows users to customize how the current time indicator is displayed.
|
|
527
737
|
*/
|
|
@@ -555,63 +765,655 @@ interface RenderCurrentTimeIndicatorProps {
|
|
|
555
765
|
/** The current calendar view (e.g. 'day', 'week') */
|
|
556
766
|
view: CalendarView;
|
|
557
767
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
768
|
+
/**
|
|
769
|
+
* What the calendar asks an `events` function for: the visible range, in the
|
|
770
|
+
* calendar's time zone. `end` is exclusive (the next midnight after the last
|
|
771
|
+
* visible day), like an event's own `end`. In month view the range is the whole
|
|
772
|
+
* grid, including the leading and trailing days of the neighbouring months.
|
|
773
|
+
*/
|
|
774
|
+
interface EventsFetchInfo {
|
|
775
|
+
/** Start of the visible range, inclusive. */
|
|
776
|
+
start: Dayjs3;
|
|
777
|
+
/** End of the visible range, exclusive. */
|
|
778
|
+
end: Dayjs3;
|
|
779
|
+
/** `start` as an ISO string. */
|
|
780
|
+
startStr: string;
|
|
781
|
+
/** `end` as an ISO string. */
|
|
782
|
+
endStr: string;
|
|
783
|
+
/** The `timezone` prop, when one is set. */
|
|
784
|
+
timezone?: string;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Loads the events for a visible range. `options.signal` aborts when a newer
|
|
788
|
+
* request supersedes this one, so a `fetch` can be cancelled by passing it on.
|
|
789
|
+
* A result that arrives after being superseded is ignored either way.
|
|
790
|
+
*/
|
|
791
|
+
type EventsFetcher = (info: EventsFetchInfo, options: {
|
|
792
|
+
signal: AbortSignal;
|
|
793
|
+
}) => Promise<IlamyCalendarPropEvent[]>;
|
|
794
|
+
/**
|
|
795
|
+
* Loads the resources. Called with the visible range at mount (and, with
|
|
796
|
+
* `refetchResourcesOnNavigate`, whenever the view leaves the fetched range).
|
|
797
|
+
* `options.signal` aborts when a newer request supersedes this one; a late
|
|
798
|
+
* result is ignored either way.
|
|
799
|
+
*/
|
|
800
|
+
type ResourcesFetcher = (info: EventsFetchInfo, options: {
|
|
801
|
+
signal: AbortSignal;
|
|
802
|
+
}) => Promise<Resource[]>;
|
|
803
|
+
interface IlamyCalendarProps {
|
|
804
|
+
/**
|
|
805
|
+
* Drives the calendar from outside it: `ref.current` is the object
|
|
806
|
+
* `useIlamyCalendarContext()` returns, so a toolbar or sidebar of your own
|
|
807
|
+
* calls `ref.current.nextPeriod()`, `setView('week')`, `scrollToTime('13:30')`
|
|
808
|
+
* and the rest. Read it in event handlers and effects, not while rendering:
|
|
809
|
+
* it is set after the calendar mounts and refreshed after every render.
|
|
810
|
+
*/
|
|
811
|
+
ref?: Ref<IlamyCalendarApi>;
|
|
812
|
+
/**
|
|
813
|
+
* The events to display: an array, or a function the calendar calls with the
|
|
814
|
+
* visible range to load them on demand (see `EventsFetcher`).
|
|
815
|
+
*
|
|
816
|
+
* With a function, the calendar refetches when the visible range leaves the
|
|
817
|
+
* last fetched one (unless `lazyFetching` is off), when `timezone` changes,
|
|
818
|
+
* and when `refetchEvents()` is called. A new function identity does NOT
|
|
819
|
+
* refetch: an inline function would refetch on every render. Call
|
|
820
|
+
* `refetchEvents()` when your query changes. Edits made in the calendar are
|
|
821
|
+
* applied immediately and reported through the `onEvent*` callbacks; the next
|
|
822
|
+
* fetch replaces them with exactly what your function returns.
|
|
823
|
+
*/
|
|
824
|
+
events?: IlamyCalendarPropEvent[] | EventsFetcher;
|
|
825
|
+
/**
|
|
826
|
+
* With an `events` function: fetch only when the visible range is not inside
|
|
827
|
+
* the range last fetched. When `false`, every navigation fetches.
|
|
828
|
+
* @default true
|
|
829
|
+
*/
|
|
830
|
+
lazyFetching?: boolean;
|
|
831
|
+
/**
|
|
832
|
+
* With an `events` or `resources` function: called with `true` when a fetch
|
|
833
|
+
* starts and `false` when none is in flight any more, for both together. Fires on those transitions only.
|
|
834
|
+
*/
|
|
835
|
+
loading?: (isLoading: boolean) => void;
|
|
836
|
+
/**
|
|
837
|
+
* With an `events` function: called when a fetch fails. The events already
|
|
838
|
+
* shown stay, and the next navigation retries. Without it, the error goes to
|
|
839
|
+
* `console.error`.
|
|
840
|
+
*/
|
|
841
|
+
onEventsError?: (error: unknown) => void;
|
|
842
|
+
/**
|
|
843
|
+
* The first day of the week to display in the calendar.
|
|
844
|
+
* Can be 'sunday', 'monday', etc. Defaults to 'sunday'.
|
|
845
|
+
*/
|
|
846
|
+
firstDayOfWeek?: WeekDays;
|
|
847
|
+
/**
|
|
848
|
+
* The initial view to display when the calendar loads.
|
|
849
|
+
* Defaults to 'month'.
|
|
850
|
+
*/
|
|
562
851
|
initialView?: CalendarView;
|
|
852
|
+
/**
|
|
853
|
+
* The initial date to display when the calendar loads.
|
|
854
|
+
* If not provided, the calendar will default to today's date.
|
|
855
|
+
*/
|
|
563
856
|
initialDate?: Dayjs3 | Date | string;
|
|
564
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Custom render function for calendar events.
|
|
859
|
+
* If provided, it will override the default event rendering.
|
|
860
|
+
*
|
|
861
|
+
* The default content keeps its title in view while a long event is
|
|
862
|
+
* scrolled partly out of the grid; custom content does not. To opt a
|
|
863
|
+
* custom title in, make it sticky with `left: var(--ilamy-sticky-left)`
|
|
864
|
+
* and `top: var(--ilamy-sticky-top)`, which each grid publishes to clear
|
|
865
|
+
* its own sticky column and header.
|
|
866
|
+
*/
|
|
867
|
+
renderEvent?: (event: CalendarEvent, segment: EventSegment) => ReactNode5;
|
|
868
|
+
/**
|
|
869
|
+
* Callback when an event is clicked.
|
|
870
|
+
* Provides the clicked event object.
|
|
871
|
+
*/
|
|
565
872
|
onEventClick?: (event: CalendarEvent) => void;
|
|
873
|
+
/**
|
|
874
|
+
* Callback when a calendar cell is clicked.
|
|
875
|
+
* Provides cell information including start/end dates and optional resourceId.
|
|
876
|
+
*/
|
|
566
877
|
onCellClick?: (info: CellInfo) => void;
|
|
878
|
+
/**
|
|
879
|
+
* Predicate to disable individual cells based on custom logic (holidays,
|
|
880
|
+
* days-off, past dates, on-call windows, etc.). Return `true` to disable a
|
|
881
|
+
* cell — disabled cells block event creation clicks, reject drag-drops, and
|
|
882
|
+
* are grayed out. Composes with `businessHours` (a cell is disabled if either
|
|
883
|
+
* business hours or this predicate disables it).
|
|
884
|
+
*/
|
|
567
885
|
isCellDisabled?: (info: CellInfo) => boolean;
|
|
886
|
+
/**
|
|
887
|
+
* Returns extra CSS classes for a cell based on custom logic (unavailability
|
|
888
|
+
* styling, on-call windows, etc.). Unlike `isCellDisabled`, this is purely
|
|
889
|
+
* visual — cells remain clickable and accept drag-drops.
|
|
890
|
+
*/
|
|
568
891
|
getCellClassName?: (info: CellInfo) => string;
|
|
892
|
+
/**
|
|
893
|
+
* Callback when the calendar view changes (month, week, day, year).
|
|
894
|
+
* Useful for syncing with external state or analytics.
|
|
895
|
+
*/
|
|
569
896
|
onViewChange?: (view: CalendarView) => void;
|
|
897
|
+
/**
|
|
898
|
+
* Callback when a new event is added to the calendar.
|
|
899
|
+
* Provides the newly created event object.
|
|
900
|
+
*/
|
|
570
901
|
onEventAdd?: (event: CalendarEvent) => void;
|
|
902
|
+
/**
|
|
903
|
+
* Callback when an existing event is updated.
|
|
904
|
+
* Provides the updated event object.
|
|
905
|
+
*/
|
|
571
906
|
onEventUpdate?: (event: CalendarEvent) => void;
|
|
907
|
+
/**
|
|
908
|
+
* Callback when an event is deleted from the calendar.
|
|
909
|
+
* Provides the deleted event object.
|
|
910
|
+
*/
|
|
572
911
|
onEventDelete?: (event: CalendarEvent) => void;
|
|
912
|
+
/**
|
|
913
|
+
* Callback once per user action, with every stored row it touched: what
|
|
914
|
+
* `onEventAdd`, `onEventUpdate` and `onEventDelete` report one row at a time.
|
|
915
|
+
* Use it to save a recurring edit (series, override, deleted overrides) as
|
|
916
|
+
* one unit. The per-row callbacks still fire; use one or the other.
|
|
917
|
+
*/
|
|
573
918
|
onEventsChange?: (change: EventsChange) => void;
|
|
919
|
+
/**
|
|
920
|
+
* Callback when the current date changes (navigation).
|
|
921
|
+
* Provides the new current date and the current visible range.
|
|
922
|
+
*/
|
|
574
923
|
onDateChange?: (date: Dayjs3, range: DateRange) => void;
|
|
924
|
+
/**
|
|
925
|
+
* Locale to use for formatting dates and times.
|
|
926
|
+
* If not provided, the default locale will be used.
|
|
927
|
+
*/
|
|
575
928
|
locale?: string;
|
|
929
|
+
/**
|
|
930
|
+
* Translations object for internationalization.
|
|
931
|
+
* Provide either this OR translator function, not both.
|
|
932
|
+
*/
|
|
933
|
+
translations?: Translations;
|
|
934
|
+
/**
|
|
935
|
+
* Translator function for internationalization.
|
|
936
|
+
* Provide either this OR translations object, not both.
|
|
937
|
+
*/
|
|
938
|
+
translator?: TranslatorFunction;
|
|
939
|
+
/**
|
|
940
|
+
* Timezone to use for displaying dates and times.
|
|
941
|
+
* If not provided, the local timezone will be used.
|
|
942
|
+
*/
|
|
576
943
|
timezone?: string;
|
|
944
|
+
/**
|
|
945
|
+
* Whether to disable click events on calendar cells.
|
|
946
|
+
* Useful for read-only views or when cell clicks are not needed.
|
|
947
|
+
*/
|
|
577
948
|
disableCellClick?: boolean;
|
|
949
|
+
/**
|
|
950
|
+
* Whether to disable click events on calendar events.
|
|
951
|
+
* Useful for read-only views or when event clicks are not needed.
|
|
952
|
+
*/
|
|
578
953
|
disableEventClick?: boolean;
|
|
954
|
+
/**
|
|
955
|
+
* Whether to disable drag-and-drop functionality for calendar events.
|
|
956
|
+
* Only sets the `editable` default, so an explicit `eventStartEditable`
|
|
957
|
+
* still enables moving.
|
|
958
|
+
* @deprecated Use `editable={false}`. Kept until 4.0.
|
|
959
|
+
*/
|
|
579
960
|
disableDragAndDrop?: boolean;
|
|
580
|
-
/**
|
|
961
|
+
/**
|
|
962
|
+
* Whether events can be moved. A per-event `editable` beats it, and
|
|
963
|
+
* `eventStartEditable` beats it for moving.
|
|
964
|
+
*
|
|
965
|
+
* Deliberate deviation: FullCalendar defaults `editable` to `false`
|
|
966
|
+
* (`options.ts:495`, v7.1.1). Drag is on by default here, so this defaults
|
|
967
|
+
* to `true` until 4.0, when flipping it can be a breaking change.
|
|
968
|
+
* @default true
|
|
969
|
+
*/
|
|
970
|
+
editable?: boolean;
|
|
971
|
+
/**
|
|
972
|
+
* Whether events can be moved.
|
|
973
|
+
* @default editable
|
|
974
|
+
*/
|
|
975
|
+
eventStartEditable?: boolean;
|
|
976
|
+
/**
|
|
977
|
+
* Whether events can be resized by dragging an edge. Resize needs a mouse
|
|
978
|
+
* or a pen: on touch-only devices events can be moved but not resized until
|
|
979
|
+
* event selection lands. A per-event `durationEditable` beats it. The end edge always shows a handle when
|
|
980
|
+
* allowed; the start edge needs `eventResizableFromStart`.
|
|
981
|
+
* @default editable
|
|
982
|
+
*/
|
|
983
|
+
eventDurationEditable?: boolean;
|
|
984
|
+
/**
|
|
985
|
+
* Also show a resize handle on the start edge of an event.
|
|
986
|
+
* @default false
|
|
987
|
+
*/
|
|
988
|
+
eventResizableFromStart?: boolean;
|
|
989
|
+
/**
|
|
990
|
+
* Vetoes a candidate placement while an event is dragged or resized. Called when the
|
|
991
|
+
* hovered placement changes, not on every pointer move; returning `false`
|
|
992
|
+
* shows the not-allowed cursor and a release there changes nothing.
|
|
993
|
+
* `draggedEvent` is the event as it was before the drag. It does not apply
|
|
994
|
+
* to the event form or to drag-to-create (FullCalendar's `selectAllow`).
|
|
995
|
+
*/
|
|
996
|
+
eventAllow?: (dropInfo: EventDropInfo, draggedEvent: CalendarEvent) => boolean;
|
|
997
|
+
/**
|
|
998
|
+
* Maximum number of events to display in one grid cell: a day in month
|
|
999
|
+
* view, an hour in the resource day view.
|
|
1000
|
+
* Additional events will be hidden and can be viewed via a "more" link.
|
|
1001
|
+
* Defaults to 4 if not specified.
|
|
1002
|
+
*/
|
|
581
1003
|
dayMaxEvents?: number;
|
|
1004
|
+
/**
|
|
1005
|
+
* Vertical spacing between stacked events in pixels.
|
|
1006
|
+
* Controls the gap between events when multiple events are displayed in the same view.
|
|
1007
|
+
* Defaults to 1 pixel if not specified.
|
|
1008
|
+
* Recommended range: 1-8 pixels for optimal readability.
|
|
1009
|
+
*/
|
|
582
1010
|
eventSpacing?: number;
|
|
1011
|
+
/**
|
|
1012
|
+
* Height of event bars in horizontal grid views (month view, resource month, resource week horizontal) in pixels.
|
|
1013
|
+
* Increase this to show more content per event (e.g., title + time on separate lines).
|
|
1014
|
+
* Does not affect day/week views, which use percentage-based heights that scale with event duration.
|
|
1015
|
+
* Defaults to 24 pixels if not specified.
|
|
1016
|
+
*/
|
|
583
1017
|
eventHeight?: number;
|
|
1018
|
+
/**
|
|
1019
|
+
* Whether to stick the view header to the top of the calendar.
|
|
1020
|
+
* Useful for keeping the header visible while scrolling.
|
|
1021
|
+
*/
|
|
584
1022
|
stickyViewHeader?: boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Custom class name for the view header.
|
|
1025
|
+
* Useful for applying custom styles or themes.
|
|
1026
|
+
*/
|
|
585
1027
|
viewHeaderClassName?: string;
|
|
586
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* Custom header component to replace the default calendar header.
|
|
1030
|
+
* Useful for adding custom branding or additional controls.
|
|
1031
|
+
*/
|
|
1032
|
+
headerComponent?: ReactNode5;
|
|
1033
|
+
/**
|
|
1034
|
+
* Custom class name for the calendar header.
|
|
1035
|
+
* Useful for applying custom styles to the header.
|
|
1036
|
+
*/
|
|
587
1037
|
headerClassName?: string;
|
|
1038
|
+
/**
|
|
1039
|
+
* Configuration for business hours.
|
|
1040
|
+
* Defines the working hours to be highlighted on the calendar.
|
|
1041
|
+
* Can be a single BusinessHours object (applies to all specified days)
|
|
1042
|
+
* or an array of BusinessHours objects (for different hours on different days).
|
|
1043
|
+
*/
|
|
588
1044
|
businessHours?: BusinessHours | BusinessHours[];
|
|
589
|
-
|
|
1045
|
+
/**
|
|
1046
|
+
* Custom render function for the event form.
|
|
1047
|
+
* If provided, it will override the default event form component.
|
|
1048
|
+
* The function receives EventFormProps and should return a React node.
|
|
1049
|
+
*/
|
|
1050
|
+
renderEventForm?: (props: EventFormProps) => ReactNode5;
|
|
1051
|
+
/**
|
|
1052
|
+
* Called when the "+N more" overflow indicator in a month/grid cell is
|
|
1053
|
+
* clicked, receiving the cell's day and its full list of events.
|
|
1054
|
+
* If provided, it overrides the built-in "all events" dialog, letting you
|
|
1055
|
+
* render your own popover/dialog. When omitted, the default dialog opens.
|
|
1056
|
+
*/
|
|
590
1057
|
onMoreEventsClick?: (day: Dayjs3, events: CalendarEvent[]) => void;
|
|
591
|
-
|
|
592
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* Time format for displaying times in the calendar.
|
|
1060
|
+
* - "12-hour": Times displayed as "1:00 PM" (default)
|
|
1061
|
+
* - "24-hour": Times displayed as "13:00"
|
|
1062
|
+
*/
|
|
593
1063
|
timeFormat?: TimeFormat;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
1064
|
+
/**
|
|
1065
|
+
* How the labels in the time gutter are written, as `Intl.DateTimeFormat`
|
|
1066
|
+
* options, formatted with the calendar's `locale` and `timezone`. When the
|
|
1067
|
+
* options carry neither `hour12` nor `hourCycle`, a `timeFormat` you passed
|
|
1068
|
+
* decides; without one, the locale does.
|
|
1069
|
+
* Unset keeps the built-in label. `renderHour` takes precedence.
|
|
1070
|
+
*
|
|
1071
|
+
* Only the `Intl.DateTimeFormatOptions` form is supported: no format
|
|
1072
|
+
* strings, no functions, and none of FullCalendar's extras (`meridiem`,
|
|
1073
|
+
* `omitZeroMinute`). Use `renderHour` for anything else.
|
|
1074
|
+
* (FullCalendar v7 calls this `slotHeaderFormat` too.)
|
|
1075
|
+
*/
|
|
1076
|
+
slotHeaderFormat?: Intl.DateTimeFormatOptions;
|
|
1077
|
+
/**
|
|
1078
|
+
* How the time on an event bar is written, as `Intl.DateTimeFormat`
|
|
1079
|
+
* options. Same rules as `slotHeaderFormat`. Setting it shows the time
|
|
1080
|
+
* unless `displayEventTime` is `false`. `renderEvent` takes precedence.
|
|
1081
|
+
*/
|
|
1082
|
+
eventTimeFormat?: Intl.DateTimeFormatOptions;
|
|
1083
|
+
/**
|
|
1084
|
+
* Whether the built-in event bar shows the event's time. All-day events
|
|
1085
|
+
* never do. Unset: shown only when `eventTimeFormat` is set, so existing
|
|
1086
|
+
* calendars look as they did. Shown with no `eventTimeFormat`, it reads
|
|
1087
|
+
* like "9:30 AM".
|
|
1088
|
+
*
|
|
1089
|
+
* FullCalendar defaults this to on; flipping it here is a 4.0 candidate.
|
|
1090
|
+
*/
|
|
1091
|
+
displayEventTime?: boolean;
|
|
1092
|
+
/**
|
|
1093
|
+
* Whether the time on an event bar runs to the end ("9:30 – 10:30").
|
|
1094
|
+
* Needs the time to be shown. FullCalendar defaults the end on when the
|
|
1095
|
+
* event has one; flipping it here is a 4.0 candidate.
|
|
1096
|
+
* @default false
|
|
1097
|
+
*/
|
|
1098
|
+
displayEventEnd?: boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* How a day header is written, as `Intl.DateTimeFormat` options. When set,
|
|
1101
|
+
* the formatted text is the whole header: `{ weekday: 'long' }` gives
|
|
1102
|
+
* "Wednesday" with no day number, and `{ weekday: 'short', day: 'numeric' }`
|
|
1103
|
+
* gives "Wed 12". Applies to the week, day, month and resource headers
|
|
1104
|
+
* (not the agenda plugin). Unset keeps the weekday over the day number.
|
|
1105
|
+
*/
|
|
1106
|
+
dayHeaderFormat?: Intl.DateTimeFormatOptions;
|
|
1107
|
+
/**
|
|
1108
|
+
* How the toolbar title is written, as `Intl.DateTimeFormat` options.
|
|
1109
|
+
* A range (week, custom window) is written with `formatRange`. Unset keeps
|
|
1110
|
+
* the built-in title for each view.
|
|
1111
|
+
*/
|
|
1112
|
+
titleFormat?: Intl.DateTimeFormatOptions;
|
|
1113
|
+
/**
|
|
1114
|
+
* Whether to hide non-business hours in Day and Week views.
|
|
1115
|
+
* Requires businessHours to be configured.
|
|
1116
|
+
* @default false
|
|
1117
|
+
*/
|
|
597
1118
|
hideNonBusinessHours?: boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* First visible time in the hour grids (day, week, and the resource hour
|
|
1121
|
+
* views in both orientations), `'HH:mm'` or `'HH:mm:ss'`. A bound that falls
|
|
1122
|
+
* inside an hour shows that whole hour. Month, year, agenda and
|
|
1123
|
+
* `weekViewGranularity: 'daily'` ignore it.
|
|
1124
|
+
*
|
|
1125
|
+
* An event outside the range is not drawn; one that crosses its edge is
|
|
1126
|
+
* clipped to it and keeps its real start and end times. Combined with
|
|
1127
|
+
* `hideNonBusinessHours`, the grid shows the overlap of the two ranges.
|
|
1128
|
+
*
|
|
1129
|
+
* Between `'00:00'` and `'24:00'` only. An invalid value, or a range whose
|
|
1130
|
+
* end is not after its start, shows the whole day and logs one
|
|
1131
|
+
* `console.warn` naming the prop.
|
|
1132
|
+
*
|
|
1133
|
+
* @default '00:00'
|
|
1134
|
+
* @example slotMinTime="08:00"
|
|
1135
|
+
*/
|
|
1136
|
+
slotMinTime?: string;
|
|
1137
|
+
/**
|
|
1138
|
+
* End of the visible time in the hour grids, exclusive: `'18:00'` shows the
|
|
1139
|
+
* 5 PM row and stops there. `'HH:mm'` or `'HH:mm:ss'` up to `'24:00'`. See
|
|
1140
|
+
* `slotMinTime`.
|
|
1141
|
+
*
|
|
1142
|
+
* @default '24:00'
|
|
1143
|
+
* @example slotMaxTime="18:00"
|
|
1144
|
+
*/
|
|
1145
|
+
slotMaxTime?: string;
|
|
1146
|
+
/**
|
|
1147
|
+
* Whether to hide the iCalendar button in the calendar header.
|
|
1148
|
+
* Applies to both desktop and mobile header layouts.
|
|
1149
|
+
* @default false
|
|
1150
|
+
*/
|
|
598
1151
|
hideExportButton?: boolean;
|
|
599
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* Custom class names for overriding default calendar element styles.
|
|
1154
|
+
* Allows fine-grained control over the appearance of different calendar elements.
|
|
1155
|
+
* @example { disabledCell: "bg-gray-100 text-gray-400" }
|
|
1156
|
+
*/
|
|
1157
|
+
classesOverride?: CalendarClassesOverride;
|
|
1158
|
+
/**
|
|
1159
|
+
* Custom render function for the current time indicator.
|
|
1160
|
+
* If provided, replaces the default red line indicator.
|
|
1161
|
+
* Useful for adding custom time labels or styling.
|
|
1162
|
+
*
|
|
1163
|
+
* Branch on `axis` to position correctly across vertical day/week grids
|
|
1164
|
+
* (`axis === 'vertical'` → use `top`) and horizontal resource hour grids
|
|
1165
|
+
* (`axis === 'horizontal'` → use `left`).
|
|
1166
|
+
*
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```tsx
|
|
1169
|
+
* renderCurrentTimeIndicator={({ currentTime, progress, resource, view, axis }) => {
|
|
1170
|
+
* // Only show the time badge for the first resource in Day view (to avoid repetition)
|
|
1171
|
+
* const isPrimary = !resource || resource.id === 'room-a'
|
|
1172
|
+
* const showBadge = view === 'day' ? isPrimary : true
|
|
1173
|
+
*
|
|
1174
|
+
* if (axis === 'horizontal') {
|
|
1175
|
+
* return (
|
|
1176
|
+
* <div style={{ left: `${progress}%` }} className="absolute top-0 bottom-0">
|
|
1177
|
+
* <div className="w-0.5 h-full bg-red-500" />
|
|
1178
|
+
* </div>
|
|
1179
|
+
* )
|
|
1180
|
+
* }
|
|
1181
|
+
*
|
|
1182
|
+
* return (
|
|
1183
|
+
* <div style={{ top: `${progress}%` }} className="absolute left-0 right-0">
|
|
1184
|
+
* <div className="h-0.5 bg-red-500" />
|
|
1185
|
+
* {showBadge && (
|
|
1186
|
+
* <span className="absolute left-0 bg-red-500 text-white text-[10px] px-1 rounded-r-sm">
|
|
1187
|
+
* {currentTime.format('h:mm A')}
|
|
1188
|
+
* </span>
|
|
1189
|
+
* )}
|
|
1190
|
+
* </div>
|
|
1191
|
+
* )
|
|
1192
|
+
* }}
|
|
1193
|
+
* ```
|
|
1194
|
+
*/
|
|
1195
|
+
renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => ReactNode5;
|
|
1196
|
+
/**
|
|
1197
|
+
* Days of the week to hide. A hidden day gets no column or row, so the
|
|
1198
|
+
* remaining days share the space.
|
|
1199
|
+
*
|
|
1200
|
+
* Applies to the month, week and day views, with or without `resources`, in
|
|
1201
|
+
* every orientation and granularity. The day view skips hidden days when you
|
|
1202
|
+
* step to the previous or next day, and opens on the next visible day if it
|
|
1203
|
+
* is given a hidden one.
|
|
1204
|
+
*
|
|
1205
|
+
* An event that runs across a hidden day is drawn as one bar over the visible
|
|
1206
|
+
* days it covers; one that starts or ends on a hidden day is clamped to the
|
|
1207
|
+
* nearest visible day (`EventSegment.isStart` / `isEnd` are false there), and
|
|
1208
|
+
* one that lies wholly on hidden days is not drawn.
|
|
1209
|
+
*
|
|
1210
|
+
* Does NOT apply to the year view, which shows every day of each month, or to
|
|
1211
|
+
* the agenda plugin, which lists events rather than days.
|
|
1212
|
+
*
|
|
1213
|
+
* Hiding all seven days is ignored, with a warning in development.
|
|
1214
|
+
*
|
|
1215
|
+
* @default []
|
|
1216
|
+
* @example ['saturday', 'sunday'] // Hide weekends
|
|
1217
|
+
*/
|
|
1218
|
+
hiddenDays?: WeekDays[];
|
|
1219
|
+
/**
|
|
1220
|
+
* Whether to show Saturday and Sunday. `false` is the same as adding both
|
|
1221
|
+
* to `hiddenDays`, and is added to it when both are set.
|
|
1222
|
+
*
|
|
1223
|
+
* @default true
|
|
1224
|
+
*/
|
|
1225
|
+
weekends?: boolean;
|
|
1226
|
+
/**
|
|
1227
|
+
* Custom render function for the hour labels in the gutter/header.
|
|
1228
|
+
* Receives a Dayjs object for the hour and should return a React node.
|
|
1229
|
+
*/
|
|
1230
|
+
renderHour?: (date: Dayjs3) => ReactNode5;
|
|
1231
|
+
/**
|
|
1232
|
+
* Granularity of the time grid in minutes for day, week, and resource hour views.
|
|
1233
|
+
* - `60` (default): one row per hour, no sub-hour lines.
|
|
1234
|
+
* - `30`: two rows per hour (top of hour, half hour).
|
|
1235
|
+
* - `15`: four rows per hour with dashed sub-hour separators.
|
|
1236
|
+
*
|
|
1237
|
+
* @default 60
|
|
1238
|
+
*/
|
|
600
1239
|
slotDuration?: SlotDuration;
|
|
1240
|
+
/**
|
|
1241
|
+
* The size, in minutes, a dragged or resized event (and a drag-to-create
|
|
1242
|
+
* selection) snaps to: `15` or `30`. Takes effect only where it is finer than
|
|
1243
|
+
* the cell under the pointer (`slotDuration` in the vertical time grid, one
|
|
1244
|
+
* hour in the horizontal resource timeline) and divides it: with
|
|
1245
|
+
* `slotDuration={60}` and `snapDuration={15}` an event dropped halfway down an
|
|
1246
|
+
* hour row lands on `:30`. Otherwise the cell's own size is used.
|
|
1247
|
+
*/
|
|
1248
|
+
snapDuration?: SnapDuration;
|
|
1249
|
+
/**
|
|
1250
|
+
* Initial scroll position for hour-resolution views (day, week, resource
|
|
1251
|
+
* day, resource week, in both orientations). Accepts `"HH:mm"` or
|
|
1252
|
+
* `"HH:mm:ss"`. The grid scrolls to the exact minute: `"08:30"` lands
|
|
1253
|
+
* halfway into the 08:00 row. The scroll target is clamped to the nearest
|
|
1254
|
+
* visible row (landing on its edge) when `hideNonBusinessHours` hides the
|
|
1255
|
+
* requested hour.
|
|
1256
|
+
*
|
|
1257
|
+
* Reapplied whenever the visible date range changes (navigation, view
|
|
1258
|
+
* switch), the rendered hours change, or `scrollTime` itself changes, as
|
|
1259
|
+
* FullCalendar does.
|
|
1260
|
+
* Ordinary re-renders leave the user's own scroll position alone.
|
|
1261
|
+
* `scrollToNow` takes precedence while the current moment is on screen.
|
|
1262
|
+
*
|
|
1263
|
+
* Independent of `businessHours`: you can show all 24 hours and still
|
|
1264
|
+
* focus on 08:00 on load.
|
|
1265
|
+
*
|
|
1266
|
+
* **Requires a fixed calendar height** so the internal time grid has a
|
|
1267
|
+
* scroll container to scroll within. If the calendar host element has
|
|
1268
|
+
* `height: auto`, the time grid grows to fit all hours and there is
|
|
1269
|
+
* nothing to scroll — this prop becomes a silent no-op.
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```tsx
|
|
1273
|
+
* <IlamyCalendar
|
|
1274
|
+
* businessHours={{ daysOfWeek: [1,2,3,4,5], startTime: 0, endTime: 24 }}
|
|
1275
|
+
* scrollTime="08:00:00"
|
|
1276
|
+
* />
|
|
1277
|
+
* ```
|
|
1278
|
+
*/
|
|
601
1279
|
scrollTime?: string;
|
|
1280
|
+
/**
|
|
1281
|
+
* Open every scrolling grid on the current moment rather than its start:
|
|
1282
|
+
* the current moment in time grids (day, week, resource day, hourly
|
|
1283
|
+
* resource week), down to the minute, and today's column or row in day grids (resource month, daily
|
|
1284
|
+
* resource week, #285). Month and year grids do not scroll, so it does
|
|
1285
|
+
* nothing there.
|
|
1286
|
+
*
|
|
1287
|
+
* Applies only while now is on screen. On a range without it (after
|
|
1288
|
+
* navigating away, or when the current hour or day is hidden) the grid
|
|
1289
|
+
* falls back to `scrollTime`, or to its start. Like `scrollTime`, it is
|
|
1290
|
+
* applied when the range, rendered hours, or this prop changes. Clock
|
|
1291
|
+
* movement alone never changes the scroll position. "Now" is the current
|
|
1292
|
+
* instant; the calendar's `timezone` only decides how it is drawn.
|
|
1293
|
+
*
|
|
1294
|
+
* Now is lined up with the leading edge, like `scrollTime`. Late in the day
|
|
1295
|
+
* or month there is not enough grid left to do that, and the browser stops
|
|
1296
|
+
* at its maximum scroll: now stays on screen, short of the edge. FullCalendar
|
|
1297
|
+
* behaves the same.
|
|
1298
|
+
*
|
|
1299
|
+
* Neither FullCalendar nor RFC 5545 defines this. FullCalendar's timeline
|
|
1300
|
+
* opens on the range start plus `scrollTime`, and its users reach today by
|
|
1301
|
+
* setting `scrollTime` themselves; this is that, done for them.
|
|
1302
|
+
*
|
|
1303
|
+
* @default false
|
|
1304
|
+
*/
|
|
602
1305
|
scrollToNow?: boolean;
|
|
1306
|
+
/**
|
|
1307
|
+
* Whether day, week and resource time grids draw the all-day row above the
|
|
1308
|
+
* hours. When `false` the row is removed and all-day events are not shown in
|
|
1309
|
+
* those views. Month, year and agenda views are unaffected.
|
|
1310
|
+
*
|
|
1311
|
+
* @default true
|
|
1312
|
+
*/
|
|
1313
|
+
allDaySlot?: boolean;
|
|
1314
|
+
/**
|
|
1315
|
+
* Whether time grids draw a line at the current time.
|
|
1316
|
+
*
|
|
1317
|
+
* @default true
|
|
1318
|
+
*/
|
|
1319
|
+
nowIndicator?: boolean;
|
|
1320
|
+
/**
|
|
1321
|
+
* Whether week numbers are shown.
|
|
1322
|
+
*
|
|
1323
|
+
* - unset (default): the week number appears in the corner of the week and
|
|
1324
|
+
* resource week headers, and month view shows none.
|
|
1325
|
+
* - `true`: additionally shows a number in each row of the month view,
|
|
1326
|
+
* counted from the row's first day.
|
|
1327
|
+
* - `false`: shows week numbers nowhere.
|
|
1328
|
+
*/
|
|
1329
|
+
weekNumbers?: boolean;
|
|
1330
|
+
/**
|
|
1331
|
+
* How week numbers are counted.
|
|
1332
|
+
*
|
|
1333
|
+
* - `'local'` (default): the locale's own count.
|
|
1334
|
+
* - `'ISO'`: ISO 8601, week 1 being the week holding the year's first
|
|
1335
|
+
* Thursday. It only changes the number: it does not make weeks start on
|
|
1336
|
+
* Monday. Use `firstDayOfWeek` for that.
|
|
1337
|
+
*
|
|
1338
|
+
* @default 'local'
|
|
1339
|
+
*/
|
|
1340
|
+
weekNumberCalculation?: WeekNumberCalculation;
|
|
1341
|
+
/**
|
|
1342
|
+
* Optional plugins that add behavior/UI (e.g. recurrence). The core ships
|
|
1343
|
+
* with no plugins by default — pass `recurrencePlugin()` to enable recurring
|
|
1344
|
+
* events.
|
|
1345
|
+
*/
|
|
603
1346
|
plugins?: IlamyPlugin[];
|
|
604
|
-
/**
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
1347
|
+
/**
|
|
1348
|
+
* Resources (people, rooms, equipment) to display as a resource axis: an
|
|
1349
|
+
* array, or a function that loads them (see `ResourcesFetcher`).
|
|
1350
|
+
*
|
|
1351
|
+
* A function is called once on mount and again on `refetchResources()`, or
|
|
1352
|
+
* on navigation with `refetchResourcesOnNavigate`. A new function identity
|
|
1353
|
+
* does NOT refetch. Until it resolves the calendar is a resource calendar with no lanes yet;
|
|
1354
|
+
* a failure keeps the resources shown and goes to `onResourcesError`.
|
|
1355
|
+
* When set: events are shown per matching resource (`resourceIds`, falling
|
|
1356
|
+
* back to `resourceId`); events with no resource assignment are hidden; the
|
|
1357
|
+
* year view is hidden from the view switcher.
|
|
1358
|
+
*/
|
|
1359
|
+
resources?: Resource[] | ResourcesFetcher;
|
|
1360
|
+
/**
|
|
1361
|
+
* With a `resources` function: also fetch when the visible range leaves the
|
|
1362
|
+
* range last fetched, so the function can return resources for the dates in view.
|
|
1363
|
+
* @default false
|
|
1364
|
+
*/
|
|
1365
|
+
refetchResourcesOnNavigate?: boolean;
|
|
1366
|
+
/**
|
|
1367
|
+
* Called with the resource list once it is set and after every change: an
|
|
1368
|
+
* array prop whose resources changed, or a fetch result. Compared by
|
|
1369
|
+
* content, so an inline array does not re-fire on every render (`data` is
|
|
1370
|
+
* compared one level deep: same keys, each value `===`; keep objects nested
|
|
1371
|
+
* deeper inside `data` stable). Not called
|
|
1372
|
+
* while there is no list yet.
|
|
1373
|
+
*/
|
|
1374
|
+
resourcesSet?: (resources: Resource[]) => void;
|
|
1375
|
+
/**
|
|
1376
|
+
* With a `resources` function: called when a fetch fails. The resources
|
|
1377
|
+
* already shown stay. Without it, the error goes to `console.error`.
|
|
1378
|
+
*/
|
|
1379
|
+
onResourcesError?: (error: unknown) => void;
|
|
1380
|
+
/** Custom render function for resource header cells. */
|
|
1381
|
+
renderResource?: (resource: Resource) => ReactNode5;
|
|
1382
|
+
/**
|
|
1383
|
+
* How resources are arranged. Only applies when `resources` is set.
|
|
1384
|
+
* - "horizontal": resources are rows, time is columns (default)
|
|
1385
|
+
* - "vertical": resources are columns, time is rows
|
|
1386
|
+
*/
|
|
609
1387
|
orientation?: "horizontal" | "vertical";
|
|
610
|
-
/**
|
|
1388
|
+
/**
|
|
1389
|
+
* Granularity of week-view time slots when `resources` is set.
|
|
1390
|
+
* - "hourly": one column per hour (default)
|
|
1391
|
+
* - "daily": one column per day
|
|
1392
|
+
*/
|
|
611
1393
|
weekViewGranularity?: "hourly" | "daily";
|
|
612
1394
|
}
|
|
1395
|
+
type RangeFetcher<Row> = (info: EventsFetchInfo, options: {
|
|
1396
|
+
signal: AbortSignal;
|
|
1397
|
+
}) => Promise<Row[]>;
|
|
1398
|
+
/**
|
|
1399
|
+
* The public props, with four the provider receives already resolved:
|
|
1400
|
+
* `events` as stored events, `firstDayOfWeek` as a day number,
|
|
1401
|
+
* `hiddenDays` as a set of day numbers and `resources` as an array.
|
|
1402
|
+
*/
|
|
1403
|
+
type CalendarProviderProps = Omit<IlamyCalendarProps, "events" | "firstDayOfWeek" | "hiddenDays" | "resources"> & {
|
|
1404
|
+
children: ReactNode6;
|
|
1405
|
+
events?: CalendarEvent[];
|
|
1406
|
+
/** Loads the events for the visible range; used instead of `events` when set. */
|
|
1407
|
+
eventsFetcher?: RangeFetcher<CalendarEvent>;
|
|
1408
|
+
/** The resolved resource array; a `resources` function arrives as `resourcesFetcher`. */
|
|
1409
|
+
resources?: Resource[];
|
|
1410
|
+
/** Loads the resources; used instead of `resources` when set. */
|
|
1411
|
+
resourcesFetcher?: RangeFetcher<Resource>;
|
|
1412
|
+
firstDayOfWeek?: number;
|
|
1413
|
+
hiddenDays?: Set<number>;
|
|
1414
|
+
};
|
|
613
1415
|
type CalendarTestProviderProps = Partial<CalendarProviderProps> & {
|
|
614
|
-
children:
|
|
1416
|
+
children: ReactNode7;
|
|
615
1417
|
};
|
|
616
1418
|
/**
|
|
617
1419
|
* Public test harness for plugin authors. Mounts children inside the calendar
|
|
@@ -626,5 +1428,5 @@ type CalendarTestProviderProps = Partial<CalendarProviderProps> & {
|
|
|
626
1428
|
* </CalendarTestProvider>
|
|
627
1429
|
* )
|
|
628
1430
|
*/
|
|
629
|
-
declare const CalendarTestProvider: ({ children,...overrides }: CalendarTestProviderProps) =>
|
|
1431
|
+
declare const CalendarTestProvider: ({ children,...overrides }: CalendarTestProviderProps) => ReactNode7;
|
|
630
1432
|
export { CalendarTestProvider };
|