@ilamy/calendar 1.1.0 → 1.1.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 CHANGED
@@ -41,3 +41,10 @@ A powerful, full-featured React calendar component library built with TypeScript
41
41
  ## Documentation
42
42
 
43
43
  For comprehensive documentation, examples, and interactive demos, visit [ilamy.dev](https://ilamy.dev)
44
+
45
+ ## Code Example
46
+
47
+ Check out the [examples directory](./examples) for complete project setups:
48
+
49
+ - [Next.js Example](./examples/nextjs) - Full-featured Next.js integration
50
+ - [Astro Example](./examples/astro) - Static site integration with Astro
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React4 from "react";
2
- import dayjs from "dayjs";
1
+ import { Frequency, Weekday } from "rrule";
2
+ import { RRule } from "rrule";
3
3
  import { Options } from "rrule";
4
4
  /**
5
5
  * Re-rrule.js Options with practical TypeScript interface.
@@ -21,6 +21,9 @@ type RRuleOptions = {
21
21
  */
22
22
  dtstart: Date;
23
23
  } & Partial<Omit<Options, "freq" | "dtstart">>;
24
+ import React4 from "react";
25
+ import React3 from "react";
26
+ import dayjs2 from "dayjs";
24
27
  /**
25
28
  * Core calendar event interface representing a single calendar event.
26
29
  * This is the primary data structure for calendar events.
@@ -31,9 +34,9 @@ interface CalendarEvent {
31
34
  /** Display title of the event */
32
35
  title: string;
33
36
  /** Start date and time of the event */
34
- start: dayjs.Dayjs;
37
+ start: dayjs2.Dayjs;
35
38
  /** End date and time of the event */
36
- end: dayjs.Dayjs;
39
+ end: dayjs2.Dayjs;
37
40
  /**
38
41
  * Color for the event (supports CSS color values, hex, rgb, hsl, or CSS class names)
39
42
  * @example "#3b82f6", "blue-500", "rgb(59, 130, 246)"
@@ -126,7 +129,6 @@ interface EventFormProps {
126
129
  onDelete?: (event: CalendarEvent) => void;
127
130
  onClose: () => void;
128
131
  }
129
- import React3 from "react";
130
132
  interface Translations {
131
133
  today: string;
132
134
  create: string;
@@ -235,6 +237,19 @@ type CalendarView = "month" | "week" | "day" | "year";
235
237
  */
236
238
  type TimeFormat = "12-hour" | "24-hour";
237
239
  /**
240
+ * Custom class names for calendar styling.
241
+ * Allows users to override default styles for various calendar elements.
242
+ */
243
+ interface CalendarClassesOverride {
244
+ /**
245
+ * Class name for disabled cells (non-business hours).
246
+ * Replaces the DISABLED_CELL_CLASSNAME constant.
247
+ * @default "bg-secondary text-muted-foreground pointer-events-none"
248
+ * @example "bg-gray-100 text-gray-400 cursor-not-allowed"
249
+ */
250
+ disabledCell?: string;
251
+ }
252
+ /**
238
253
  * This interface extends the base CalendarEvent but allows more flexible date types
239
254
  * for the start and end properties. The component will automatically convert these
240
255
  * to dayjs objects internally for consistent date handling.
@@ -243,8 +258,8 @@ type TimeFormat = "12-hour" | "24-hour";
243
258
  * @extends {Omit<CalendarEvent, 'start' | 'end'>}
244
259
  */
245
260
  interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
246
- start: dayjs.Dayjs | Date | string;
247
- end: dayjs.Dayjs | Date | string;
261
+ start: dayjs2.Dayjs | Date | string;
262
+ end: dayjs2.Dayjs | Date | string;
248
263
  }
249
264
  /**
250
265
  * Information passed to the onCellClick callback.
@@ -252,9 +267,9 @@ interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
252
267
  */
253
268
  interface CellClickInfo {
254
269
  /** Start date/time of the clicked cell */
255
- start: dayjs.Dayjs;
270
+ start: dayjs2.Dayjs;
256
271
  /** End date/time of the clicked cell */
257
- end: dayjs.Dayjs;
272
+ end: dayjs2.Dayjs;
258
273
  /** Resource ID if clicking on a resource calendar cell (optional) */
259
274
  resourceId?: string | number;
260
275
  }
@@ -277,7 +292,7 @@ interface IlamyCalendarProps {
277
292
  * The initial date to display when the calendar loads.
278
293
  * If not provided, the calendar will default to today's date.
279
294
  */
280
- initialDate?: dayjs.Dayjs | Date | string;
295
+ initialDate?: dayjs2.Dayjs | Date | string;
281
296
  /**
282
297
  * Custom render function for calendar events.
283
298
  * If provided, it will override the default event rendering.
@@ -317,7 +332,7 @@ interface IlamyCalendarProps {
317
332
  * Callback when the current date changes (navigation).
318
333
  * Provides the new current date.
319
334
  */
320
- onDateChange?: (date: dayjs.Dayjs) => void;
335
+ onDateChange?: (date: dayjs2.Dayjs) => void;
321
336
  /**
322
337
  * Locale to use for formatting dates and times.
323
338
  * If not provided, the default locale will be used.
@@ -360,6 +375,13 @@ interface IlamyCalendarProps {
360
375
  */
361
376
  dayMaxEvents?: number;
362
377
  /**
378
+ * Vertical spacing between stacked events in pixels.
379
+ * Controls the gap between events when multiple events are displayed in the same view.
380
+ * Defaults to 1 pixel if not specified.
381
+ * Recommended range: 1-8 pixels for optimal readability.
382
+ */
383
+ eventSpacing?: number;
384
+ /**
363
385
  * Whether to stick the view header to the top of the calendar.
364
386
  * Useful for keeping the header visible while scrolling.
365
387
  */
@@ -382,8 +404,10 @@ interface IlamyCalendarProps {
382
404
  /**
383
405
  * Configuration for business hours.
384
406
  * Defines the working hours to be highlighted on the calendar.
407
+ * Can be a single BusinessHours object (applies to all specified days)
408
+ * or an array of BusinessHours objects (for different hours on different days).
385
409
  */
386
- businessHours?: BusinessHours;
410
+ businessHours?: BusinessHours | BusinessHours[];
387
411
  /**
388
412
  * Custom render function for the event form.
389
413
  * If provided, it will override the default event form component.
@@ -396,9 +420,48 @@ interface IlamyCalendarProps {
396
420
  * - "24-hour": Times displayed as "13:00"
397
421
  */
398
422
  timeFormat?: TimeFormat;
423
+ /**
424
+ * Custom class names for overriding default calendar element styles.
425
+ * Allows fine-grained control over the appearance of different calendar elements.
426
+ * @example { disabledCell: "bg-gray-100 text-gray-400" }
427
+ */
428
+ classesOverride?: CalendarClassesOverride;
399
429
  }
400
430
  declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
401
- import React5 from "react";
431
+ declare const isRecurringEvent: (event: CalendarEvent) => boolean;
432
+ interface GenerateRecurringEventsProps {
433
+ event: CalendarEvent;
434
+ currentEvents: CalendarEvent[];
435
+ startDate: dayjs2.Dayjs;
436
+ endDate: dayjs2.Dayjs;
437
+ }
438
+ declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
439
+ /**
440
+ * Simplified calendar context type for external use
441
+ * Contains only the most commonly used calendar operations
442
+ */
443
+ interface UseIlamyCalendarContextReturn {
444
+ readonly currentDate: dayjs2.Dayjs;
445
+ readonly view: CalendarView;
446
+ readonly events: CalendarEvent[];
447
+ readonly isEventFormOpen: boolean;
448
+ readonly selectedEvent: CalendarEvent | null;
449
+ readonly selectedDate: dayjs2.Dayjs | null;
450
+ readonly firstDayOfWeek: number;
451
+ readonly setCurrentDate: (date: dayjs2.Dayjs) => void;
452
+ readonly selectDate: (date: dayjs2.Dayjs) => void;
453
+ readonly setView: (view: CalendarView) => void;
454
+ readonly nextPeriod: () => void;
455
+ readonly prevPeriod: () => void;
456
+ readonly today: () => void;
457
+ readonly addEvent: (event: CalendarEvent) => void;
458
+ readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
459
+ readonly deleteEvent: (eventId: string | number) => void;
460
+ readonly openEventForm: (eventData?: Partial<CalendarEvent>) => void;
461
+ readonly closeEventForm: () => void;
462
+ readonly businessHours?: BusinessHours | BusinessHours[];
463
+ }
464
+ declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
402
465
  /**
403
466
  * Public-facing resource calendar event interface with flexible date types.
404
467
  * Similar to IlamyCalendarPropEvent but with resource assignment fields.
@@ -442,34 +505,9 @@ interface Resource {
442
505
  /** Optional position for resource display */
443
506
  position?: number;
444
507
  }
508
+ import React5 from "react";
445
509
  declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
446
510
  /**
447
- * Simplified calendar context type for external use
448
- * Contains only the most commonly used calendar operations
449
- */
450
- interface UseIlamyCalendarContextReturn {
451
- readonly currentDate: dayjs.Dayjs;
452
- readonly view: CalendarView;
453
- readonly events: CalendarEvent[];
454
- readonly isEventFormOpen: boolean;
455
- readonly selectedEvent: CalendarEvent | null;
456
- readonly selectedDate: dayjs.Dayjs | null;
457
- readonly firstDayOfWeek: number;
458
- readonly setCurrentDate: (date: dayjs.Dayjs) => void;
459
- readonly selectDate: (date: dayjs.Dayjs) => void;
460
- readonly setView: (view: CalendarView) => void;
461
- readonly nextPeriod: () => void;
462
- readonly prevPeriod: () => void;
463
- readonly today: () => void;
464
- readonly addEvent: (event: CalendarEvent) => void;
465
- readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
466
- readonly deleteEvent: (eventId: string | number) => void;
467
- readonly openEventForm: (eventData?: Partial<CalendarEvent>) => void;
468
- readonly closeEventForm: () => void;
469
- readonly businessHours?: BusinessHours;
470
- }
471
- declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
472
- /**
473
511
  * Simplified resource calendar context type for external use
474
512
  */
475
513
  interface UseIlamyResourceCalendarContextReturn extends UseIlamyCalendarContextReturn {
@@ -478,15 +516,5 @@ interface UseIlamyResourceCalendarContextReturn extends UseIlamyCalendarContextR
478
516
  readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
479
517
  }
480
518
  declare const useIlamyResourceCalendarContext: () => UseIlamyResourceCalendarContextReturn;
481
- declare const isRecurringEvent: (event: CalendarEvent) => boolean;
482
- interface GenerateRecurringEventsProps {
483
- event: CalendarEvent;
484
- currentEvents: CalendarEvent[];
485
- startDate: dayjs.Dayjs;
486
- endDate: dayjs.Dayjs;
487
- }
488
- declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
489
- import { Frequency, Weekday } from "rrule";
490
- import { RRule } from "rrule";
491
519
  declare const defaultTranslations: Translations;
492
520
  export { useIlamyResourceCalendarContext, useIlamyCalendarContext, isRecurringEvent, generateRecurringEvents, defaultTranslations, Weekday, WeekDays, UseIlamyResourceCalendarContextReturn, UseIlamyCalendarContextReturn, TranslatorFunction, Translations, TranslationKey, TimeFormat, Resource, RRuleOptions, RRule, IlamyResourceCalendarProps, IlamyResourceCalendar, IlamyCalendarProps, IlamyCalendar, Frequency, EventFormProps, CellClickInfo, CalendarView, CalendarEvent };