@ilamy/calendar 1.1.0 → 1.2.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 +7 -0
- package/dist/index.d.ts +85 -49
- package/dist/index.js +6 -6
- package/package.json +116 -112
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
|
|
2
|
-
import
|
|
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:
|
|
37
|
+
start: dayjs2.Dayjs;
|
|
35
38
|
/** End date and time of the event */
|
|
36
|
-
end:
|
|
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:
|
|
247
|
-
end:
|
|
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,11 +267,13 @@ interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
|
|
|
252
267
|
*/
|
|
253
268
|
interface CellClickInfo {
|
|
254
269
|
/** Start date/time of the clicked cell */
|
|
255
|
-
start:
|
|
270
|
+
start: dayjs2.Dayjs;
|
|
256
271
|
/** End date/time of the clicked cell */
|
|
257
|
-
end:
|
|
272
|
+
end: dayjs2.Dayjs;
|
|
258
273
|
/** Resource ID if clicking on a resource calendar cell (optional) */
|
|
259
274
|
resourceId?: string | number;
|
|
275
|
+
/** Whether the clicked cell is an all-day cell (optional) */
|
|
276
|
+
allDay?: boolean;
|
|
260
277
|
}
|
|
261
278
|
interface IlamyCalendarProps {
|
|
262
279
|
/**
|
|
@@ -277,7 +294,7 @@ interface IlamyCalendarProps {
|
|
|
277
294
|
* The initial date to display when the calendar loads.
|
|
278
295
|
* If not provided, the calendar will default to today's date.
|
|
279
296
|
*/
|
|
280
|
-
initialDate?:
|
|
297
|
+
initialDate?: dayjs2.Dayjs | Date | string;
|
|
281
298
|
/**
|
|
282
299
|
* Custom render function for calendar events.
|
|
283
300
|
* If provided, it will override the default event rendering.
|
|
@@ -317,7 +334,7 @@ interface IlamyCalendarProps {
|
|
|
317
334
|
* Callback when the current date changes (navigation).
|
|
318
335
|
* Provides the new current date.
|
|
319
336
|
*/
|
|
320
|
-
onDateChange?: (date:
|
|
337
|
+
onDateChange?: (date: dayjs2.Dayjs) => void;
|
|
321
338
|
/**
|
|
322
339
|
* Locale to use for formatting dates and times.
|
|
323
340
|
* If not provided, the default locale will be used.
|
|
@@ -360,6 +377,13 @@ interface IlamyCalendarProps {
|
|
|
360
377
|
*/
|
|
361
378
|
dayMaxEvents?: number;
|
|
362
379
|
/**
|
|
380
|
+
* Vertical spacing between stacked events in pixels.
|
|
381
|
+
* Controls the gap between events when multiple events are displayed in the same view.
|
|
382
|
+
* Defaults to 1 pixel if not specified.
|
|
383
|
+
* Recommended range: 1-8 pixels for optimal readability.
|
|
384
|
+
*/
|
|
385
|
+
eventSpacing?: number;
|
|
386
|
+
/**
|
|
363
387
|
* Whether to stick the view header to the top of the calendar.
|
|
364
388
|
* Useful for keeping the header visible while scrolling.
|
|
365
389
|
*/
|
|
@@ -382,8 +406,10 @@ interface IlamyCalendarProps {
|
|
|
382
406
|
/**
|
|
383
407
|
* Configuration for business hours.
|
|
384
408
|
* Defines the working hours to be highlighted on the calendar.
|
|
409
|
+
* Can be a single BusinessHours object (applies to all specified days)
|
|
410
|
+
* or an array of BusinessHours objects (for different hours on different days).
|
|
385
411
|
*/
|
|
386
|
-
businessHours?: BusinessHours;
|
|
412
|
+
businessHours?: BusinessHours | BusinessHours[];
|
|
387
413
|
/**
|
|
388
414
|
* Custom render function for the event form.
|
|
389
415
|
* If provided, it will override the default event form component.
|
|
@@ -396,9 +422,48 @@ interface IlamyCalendarProps {
|
|
|
396
422
|
* - "24-hour": Times displayed as "13:00"
|
|
397
423
|
*/
|
|
398
424
|
timeFormat?: TimeFormat;
|
|
425
|
+
/**
|
|
426
|
+
* Custom class names for overriding default calendar element styles.
|
|
427
|
+
* Allows fine-grained control over the appearance of different calendar elements.
|
|
428
|
+
* @example { disabledCell: "bg-gray-100 text-gray-400" }
|
|
429
|
+
*/
|
|
430
|
+
classesOverride?: CalendarClassesOverride;
|
|
399
431
|
}
|
|
400
432
|
declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
|
|
401
|
-
|
|
433
|
+
declare const isRecurringEvent: (event: CalendarEvent) => boolean;
|
|
434
|
+
interface GenerateRecurringEventsProps {
|
|
435
|
+
event: CalendarEvent;
|
|
436
|
+
currentEvents: CalendarEvent[];
|
|
437
|
+
startDate: dayjs2.Dayjs;
|
|
438
|
+
endDate: dayjs2.Dayjs;
|
|
439
|
+
}
|
|
440
|
+
declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
|
|
441
|
+
/**
|
|
442
|
+
* Simplified calendar context type for external use
|
|
443
|
+
* Contains only the most commonly used calendar operations
|
|
444
|
+
*/
|
|
445
|
+
interface UseIlamyCalendarContextReturn {
|
|
446
|
+
readonly currentDate: dayjs2.Dayjs;
|
|
447
|
+
readonly view: CalendarView;
|
|
448
|
+
readonly events: CalendarEvent[];
|
|
449
|
+
readonly isEventFormOpen: boolean;
|
|
450
|
+
readonly selectedEvent: CalendarEvent | null;
|
|
451
|
+
readonly selectedDate: dayjs2.Dayjs | null;
|
|
452
|
+
readonly firstDayOfWeek: number;
|
|
453
|
+
readonly setCurrentDate: (date: dayjs2.Dayjs) => void;
|
|
454
|
+
readonly selectDate: (date: dayjs2.Dayjs) => void;
|
|
455
|
+
readonly setView: (view: CalendarView) => void;
|
|
456
|
+
readonly nextPeriod: () => void;
|
|
457
|
+
readonly prevPeriod: () => void;
|
|
458
|
+
readonly today: () => void;
|
|
459
|
+
readonly addEvent: (event: CalendarEvent) => void;
|
|
460
|
+
readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
|
|
461
|
+
readonly deleteEvent: (eventId: string | number) => void;
|
|
462
|
+
readonly openEventForm: (eventData?: Partial<CalendarEvent>) => void;
|
|
463
|
+
readonly closeEventForm: () => void;
|
|
464
|
+
readonly businessHours?: BusinessHours | BusinessHours[];
|
|
465
|
+
}
|
|
466
|
+
declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
|
|
402
467
|
/**
|
|
403
468
|
* Public-facing resource calendar event interface with flexible date types.
|
|
404
469
|
* Similar to IlamyCalendarPropEvent but with resource assignment fields.
|
|
@@ -420,6 +485,12 @@ interface IlamyResourceCalendarProps extends Omit<IlamyCalendarProps, "events">
|
|
|
420
485
|
resources?: Resource[];
|
|
421
486
|
/** Custom render function for resources */
|
|
422
487
|
renderResource?: (resource: Resource) => React.ReactNode;
|
|
488
|
+
/**
|
|
489
|
+
* Orientation of the resource view.
|
|
490
|
+
* - "horizontal": Resources are rows, time is columns (default)
|
|
491
|
+
* - "vertical": Resources are columns, time is rows
|
|
492
|
+
*/
|
|
493
|
+
orientation?: "horizontal" | "vertical";
|
|
423
494
|
}
|
|
424
495
|
/**
|
|
425
496
|
* Resource interface representing a calendar resource (person, room, equipment, etc.)
|
|
@@ -442,34 +513,9 @@ interface Resource {
|
|
|
442
513
|
/** Optional position for resource display */
|
|
443
514
|
position?: number;
|
|
444
515
|
}
|
|
516
|
+
import React5 from "react";
|
|
445
517
|
declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
|
|
446
518
|
/**
|
|
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
519
|
* Simplified resource calendar context type for external use
|
|
474
520
|
*/
|
|
475
521
|
interface UseIlamyResourceCalendarContextReturn extends UseIlamyCalendarContextReturn {
|
|
@@ -478,15 +524,5 @@ interface UseIlamyResourceCalendarContextReturn extends UseIlamyCalendarContextR
|
|
|
478
524
|
readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
|
|
479
525
|
}
|
|
480
526
|
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
527
|
declare const defaultTranslations: Translations;
|
|
492
528
|
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 };
|