@ilamy/calendar 1.3.3 → 1.5.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/dist/index.d.ts +50 -35
- package/dist/index.js +6 -6
- package/package.json +20 -15
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:
|
|
35
|
+
start: Dayjs;
|
|
38
36
|
/** End date and time of the event */
|
|
39
|
-
end:
|
|
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
|
|
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:
|
|
316
|
-
end:
|
|
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:
|
|
334
|
+
start: Dayjs;
|
|
325
335
|
/** End date/time of the clicked cell */
|
|
326
|
-
end:
|
|
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:
|
|
348
|
+
currentTime: Dayjs;
|
|
339
349
|
/** The start of the visible time range */
|
|
340
|
-
rangeStart:
|
|
350
|
+
rangeStart: Dayjs;
|
|
341
351
|
/** The end of the visible time range */
|
|
342
|
-
rangeEnd:
|
|
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?:
|
|
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:
|
|
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.
|
|
@@ -535,30 +545,41 @@ interface IlamyCalendarProps {
|
|
|
535
545
|
* ```
|
|
536
546
|
*/
|
|
537
547
|
renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React3.ReactNode;
|
|
548
|
+
/**
|
|
549
|
+
* Days of the week to hide from the week view.
|
|
550
|
+
* Hidden days won't render as columns, giving remaining days more space.
|
|
551
|
+
* Only applies to vertical week views (regular and resource vertical).
|
|
552
|
+
* Does not affect month, day, year, or resource horizontal week views.
|
|
553
|
+
* @default []
|
|
554
|
+
* @example ['saturday', 'sunday'] // Hide weekends
|
|
555
|
+
*/
|
|
556
|
+
hiddenDays?: WeekDays[];
|
|
538
557
|
}
|
|
539
558
|
declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
|
|
540
559
|
declare const isRecurringEvent: (event: CalendarEvent) => boolean;
|
|
541
560
|
interface GenerateRecurringEventsProps {
|
|
542
561
|
event: CalendarEvent;
|
|
543
562
|
currentEvents: CalendarEvent[];
|
|
544
|
-
startDate:
|
|
545
|
-
endDate:
|
|
563
|
+
startDate: Dayjs;
|
|
564
|
+
endDate: Dayjs;
|
|
546
565
|
}
|
|
547
566
|
declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
|
|
567
|
+
import React5 from "react";
|
|
568
|
+
declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
|
|
548
569
|
/**
|
|
549
|
-
*
|
|
550
|
-
* Contains only the most commonly used calendar operations
|
|
570
|
+
* Publicly exposed calendar context properties.
|
|
551
571
|
*/
|
|
552
572
|
interface UseIlamyCalendarContextReturn {
|
|
553
|
-
readonly currentDate:
|
|
573
|
+
readonly currentDate: Dayjs;
|
|
554
574
|
readonly view: CalendarView;
|
|
555
575
|
readonly events: CalendarEvent[];
|
|
556
576
|
readonly isEventFormOpen: boolean;
|
|
557
577
|
readonly selectedEvent: CalendarEvent | null;
|
|
558
|
-
readonly selectedDate:
|
|
578
|
+
readonly selectedDate: Dayjs | null;
|
|
559
579
|
readonly firstDayOfWeek: number;
|
|
560
|
-
readonly
|
|
561
|
-
readonly
|
|
580
|
+
readonly resources: Resource[];
|
|
581
|
+
readonly setCurrentDate: (date: Dayjs) => void;
|
|
582
|
+
readonly selectDate: (date: Dayjs) => void;
|
|
562
583
|
readonly setView: (view: CalendarView) => void;
|
|
563
584
|
readonly nextPeriod: () => void;
|
|
564
585
|
readonly prevPeriod: () => void;
|
|
@@ -568,19 +589,13 @@ interface UseIlamyCalendarContextReturn {
|
|
|
568
589
|
readonly deleteEvent: (eventId: string | number) => void;
|
|
569
590
|
readonly openEventForm: (eventData?: Partial<CalendarEvent>) => void;
|
|
570
591
|
readonly closeEventForm: () => void;
|
|
592
|
+
readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
|
|
571
593
|
readonly businessHours?: BusinessHours | BusinessHours[];
|
|
572
594
|
}
|
|
573
|
-
declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
|
|
574
|
-
import React5 from "react";
|
|
575
|
-
declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
|
|
576
595
|
/**
|
|
577
|
-
*
|
|
596
|
+
* Public hook exported for library users.
|
|
597
|
+
* Returns a limited set of commonly used properties and methods.
|
|
578
598
|
*/
|
|
579
|
-
|
|
580
|
-
readonly events: CalendarEvent[];
|
|
581
|
-
readonly resources: Resource[];
|
|
582
|
-
readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
|
|
583
|
-
}
|
|
584
|
-
declare const useIlamyResourceCalendarContext: () => UseIlamyResourceCalendarContextReturn;
|
|
599
|
+
declare function useIlamyCalendarContext(): UseIlamyCalendarContextReturn;
|
|
585
600
|
declare const defaultTranslations: Translations;
|
|
586
|
-
export {
|
|
601
|
+
export { useIlamyCalendarContext, isRecurringEvent, generateRecurringEvents, defaultTranslations, Weekday, WeekDays, UseIlamyCalendarContextReturn, TranslatorFunction, Translations, TranslationKey, TimeFormat, Resource, RenderCurrentTimeIndicatorProps, RRuleOptions, RRule, IlamyResourceCalendarProps, IlamyResourceCalendar, IlamyCalendarProps, IlamyCalendar, Frequency, EventFormProps, CellClickInfo, CalendarView, CalendarEvent, BusinessHours };
|