@ilamy/calendar 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Frequency, Weekday } from "rrule";
2
2
  import { RRule } from "rrule";
3
3
  import { Options } from "rrule";
4
+ import { Dayjs } from "dayjs";
4
5
  /**
5
6
  * Re-rrule.js Options with practical TypeScript interface.
6
7
  * Makes all properties optional except freq and dtstart (which are required by RFC 5545).
@@ -21,9 +22,6 @@ type RRuleOptions = {
21
22
  */
22
23
  dtstart: Date;
23
24
  } & Partial<Omit<Options, "freq" | "dtstart">>;
24
- import React4 from "react";
25
- import React3 from "react";
26
- import dayjs2 from "dayjs";
27
25
  /**
28
26
  * Core calendar event interface representing a single calendar event.
29
27
  * This is the primary data structure for calendar events.
@@ -34,9 +32,9 @@ interface CalendarEvent {
34
32
  /** Display title of the event */
35
33
  title: string;
36
34
  /** Start date and time of the event */
37
- start: dayjs2.Dayjs;
35
+ start: Dayjs;
38
36
  /** End date and time of the event */
39
- end: dayjs2.Dayjs;
37
+ end: Dayjs;
40
38
  /**
41
39
  * Color for the event (supports CSS color values, hex, rgb, hsl, or CSS class names)
42
40
  * @example "#3b82f6", "blue-500", "rgb(59, 130, 246)"
@@ -129,10 +127,12 @@ interface EventFormProps {
129
127
  onDelete?: (event: CalendarEvent) => void;
130
128
  onClose: () => void;
131
129
  }
130
+ import React4 from "react";
131
+ import React3 from "react";
132
132
  /**
133
133
  * Public-facing resource calendar event interface with flexible date types.
134
134
  * Similar to IlamyCalendarPropEvent but with resource assignment fields.
135
- * Dates can be provided as dayjs.Dayjs, Date, or string and will be normalized internally.
135
+ * Dates can be provided as Dayjs, Date, or string and will be normalized internally.
136
136
  *
137
137
  * @interface IlamyResourceCalendarPropEvent
138
138
  * @extends {IlamyCalendarPropEvent}
@@ -182,6 +182,12 @@ interface Resource {
182
182
  * If provided, these will be used instead of the global business hours for this resource.
183
183
  */
184
184
  businessHours?: BusinessHours | BusinessHours[];
185
+ /**
186
+ * Custom data associated with the resource
187
+ * Use this to store additional metadata specific to your application
188
+ * @example { avatar: 'https://example.com/avatar.png', role: 'admin' }
189
+ */
190
+ data?: Record<string, any>;
185
191
  }
186
192
  interface Translations {
187
193
  today: string;
@@ -312,18 +318,22 @@ interface CalendarClassesOverride {
312
318
  * @extends {Omit<CalendarEvent, 'start' | 'end'>}
313
319
  */
314
320
  interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
315
- start: dayjs2.Dayjs | Date | string;
316
- end: dayjs2.Dayjs | Date | string;
321
+ start: Dayjs | Date | string;
322
+ end: Dayjs | Date | string;
317
323
  }
318
324
  /**
319
325
  * Information passed to the onCellClick callback.
320
326
  * Uses named properties for extensibility.
321
327
  */
328
+ interface DateRange {
329
+ start: Dayjs;
330
+ end: Dayjs;
331
+ }
322
332
  interface CellClickInfo {
323
333
  /** Start date/time of the clicked cell */
324
- start: dayjs2.Dayjs;
334
+ start: Dayjs;
325
335
  /** End date/time of the clicked cell */
326
- end: dayjs2.Dayjs;
336
+ end: Dayjs;
327
337
  /** Resource ID if clicking on a resource calendar cell (optional) */
328
338
  resourceId?: string | number;
329
339
  /** Whether the clicked cell is an all-day cell (optional) */
@@ -335,11 +345,11 @@ interface CellClickInfo {
335
345
  */
336
346
  interface RenderCurrentTimeIndicatorProps {
337
347
  /** The current time as a dayjs object */
338
- currentTime: dayjs2.Dayjs;
348
+ currentTime: Dayjs;
339
349
  /** The start of the visible time range */
340
- rangeStart: dayjs2.Dayjs;
350
+ rangeStart: Dayjs;
341
351
  /** The end of the visible time range */
342
- rangeEnd: dayjs2.Dayjs;
352
+ rangeEnd: Dayjs;
343
353
  /** Progress percentage (0-100) representing position in the range */
344
354
  progress: number;
345
355
  /**
@@ -369,7 +379,7 @@ interface IlamyCalendarProps {
369
379
  * The initial date to display when the calendar loads.
370
380
  * If not provided, the calendar will default to today's date.
371
381
  */
372
- initialDate?: dayjs2.Dayjs | Date | string;
382
+ initialDate?: Dayjs | Date | string;
373
383
  /**
374
384
  * Custom render function for calendar events.
375
385
  * If provided, it will override the default event rendering.
@@ -407,9 +417,9 @@ interface IlamyCalendarProps {
407
417
  onEventDelete?: (event: CalendarEvent) => void;
408
418
  /**
409
419
  * Callback when the current date changes (navigation).
410
- * Provides the new current date.
420
+ * Provides the new current date and the current visible range.
411
421
  */
412
- onDateChange?: (date: dayjs2.Dayjs) => void;
422
+ onDateChange?: (date: Dayjs, range: DateRange) => void;
413
423
  /**
414
424
  * Locale to use for formatting dates and times.
415
425
  * If not provided, the default locale will be used.
@@ -544,14 +554,19 @@ interface IlamyCalendarProps {
544
554
  * @example ['saturday', 'sunday'] // Hide weekends
545
555
  */
546
556
  hiddenDays?: WeekDays[];
557
+ /**
558
+ * Custom render function for the hour labels in the gutter/header.
559
+ * Receives a Dayjs object for the hour and should return a React node.
560
+ */
561
+ renderHour?: (date: Dayjs) => React3.ReactNode;
547
562
  }
548
563
  declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
549
564
  declare const isRecurringEvent: (event: CalendarEvent) => boolean;
550
565
  interface GenerateRecurringEventsProps {
551
566
  event: CalendarEvent;
552
567
  currentEvents: CalendarEvent[];
553
- startDate: dayjs2.Dayjs;
554
- endDate: dayjs2.Dayjs;
568
+ startDate: Dayjs;
569
+ endDate: Dayjs;
555
570
  }
556
571
  declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
557
572
  import React5 from "react";
@@ -560,16 +575,16 @@ declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
560
575
  * Publicly exposed calendar context properties.
561
576
  */
562
577
  interface UseIlamyCalendarContextReturn {
563
- readonly currentDate: dayjs2.Dayjs;
578
+ readonly currentDate: Dayjs;
564
579
  readonly view: CalendarView;
565
580
  readonly events: CalendarEvent[];
566
581
  readonly isEventFormOpen: boolean;
567
582
  readonly selectedEvent: CalendarEvent | null;
568
- readonly selectedDate: dayjs2.Dayjs | null;
583
+ readonly selectedDate: Dayjs | null;
569
584
  readonly firstDayOfWeek: number;
570
585
  readonly resources: Resource[];
571
- readonly setCurrentDate: (date: dayjs2.Dayjs) => void;
572
- readonly selectDate: (date: dayjs2.Dayjs) => void;
586
+ readonly setCurrentDate: (date: Dayjs) => void;
587
+ readonly selectDate: (date: Dayjs) => void;
573
588
  readonly setView: (view: CalendarView) => void;
574
589
  readonly nextPeriod: () => void;
575
590
  readonly prevPeriod: () => void;