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