@ilamy/calendar 1.0.2 → 1.1.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 +81 -22
- package/dist/index.js +6 -7
- package/package.json +2 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React4 from "react";
|
|
2
|
+
import dayjs from "dayjs";
|
|
2
3
|
import { Options } from "rrule";
|
|
3
4
|
/**
|
|
4
5
|
* Re-rrule.js Options with practical TypeScript interface.
|
|
@@ -80,6 +81,10 @@ interface CalendarEvent {
|
|
|
80
81
|
* Unique identifier across calendar systems
|
|
81
82
|
*/
|
|
82
83
|
uid?: string;
|
|
84
|
+
/** Single resource assignment */
|
|
85
|
+
resourceId?: string | number;
|
|
86
|
+
/** Multiple resource assignment (cross-resource events) */
|
|
87
|
+
resourceIds?: (string | number)[];
|
|
83
88
|
/**
|
|
84
89
|
* Custom data associated with the event
|
|
85
90
|
* Use this to store additional metadata specific to your application
|
|
@@ -92,7 +97,36 @@ interface CalendarEvent {
|
|
|
92
97
|
* Used for setting the first day of the week and other week-related settings.
|
|
93
98
|
*/
|
|
94
99
|
type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
|
|
95
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Configuration for business hours.
|
|
102
|
+
* Defines the working hours to be highlighted on the calendar.
|
|
103
|
+
*/
|
|
104
|
+
interface BusinessHours {
|
|
105
|
+
/**
|
|
106
|
+
* Days of the week to apply business hours to.
|
|
107
|
+
* @default ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
|
|
108
|
+
*/
|
|
109
|
+
daysOfWeek?: WeekDays[];
|
|
110
|
+
/**
|
|
111
|
+
* Start time for business hours in 24-hour format (0-24).
|
|
112
|
+
* @default 9
|
|
113
|
+
*/
|
|
114
|
+
startTime?: number;
|
|
115
|
+
/**
|
|
116
|
+
* End time for business hours in 24-hour format (0-24).
|
|
117
|
+
* @default 17
|
|
118
|
+
*/
|
|
119
|
+
endTime?: number;
|
|
120
|
+
}
|
|
121
|
+
interface EventFormProps {
|
|
122
|
+
open?: boolean;
|
|
123
|
+
selectedEvent?: CalendarEvent | null;
|
|
124
|
+
onAdd?: (event: CalendarEvent) => void;
|
|
125
|
+
onUpdate?: (event: CalendarEvent) => void;
|
|
126
|
+
onDelete?: (event: CalendarEvent) => void;
|
|
127
|
+
onClose: () => void;
|
|
128
|
+
}
|
|
129
|
+
import React3 from "react";
|
|
96
130
|
interface Translations {
|
|
97
131
|
today: string;
|
|
98
132
|
create: string;
|
|
@@ -197,6 +231,10 @@ type TranslatorFunction = (key: TranslationKey | string) => string;
|
|
|
197
231
|
*/
|
|
198
232
|
type CalendarView = "month" | "week" | "day" | "year";
|
|
199
233
|
/**
|
|
234
|
+
* Time format options for displaying times in the calendar.
|
|
235
|
+
*/
|
|
236
|
+
type TimeFormat = "12-hour" | "24-hour";
|
|
237
|
+
/**
|
|
200
238
|
* This interface extends the base CalendarEvent but allows more flexible date types
|
|
201
239
|
* for the start and end properties. The component will automatically convert these
|
|
202
240
|
* to dayjs objects internally for consistent date handling.
|
|
@@ -208,6 +246,18 @@ interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
|
|
|
208
246
|
start: dayjs.Dayjs | Date | string;
|
|
209
247
|
end: dayjs.Dayjs | Date | string;
|
|
210
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Information passed to the onCellClick callback.
|
|
251
|
+
* Uses named properties for extensibility.
|
|
252
|
+
*/
|
|
253
|
+
interface CellClickInfo {
|
|
254
|
+
/** Start date/time of the clicked cell */
|
|
255
|
+
start: dayjs.Dayjs;
|
|
256
|
+
/** End date/time of the clicked cell */
|
|
257
|
+
end: dayjs.Dayjs;
|
|
258
|
+
/** Resource ID if clicking on a resource calendar cell (optional) */
|
|
259
|
+
resourceId?: string | number;
|
|
260
|
+
}
|
|
211
261
|
interface IlamyCalendarProps {
|
|
212
262
|
/**
|
|
213
263
|
* Array of events to display in the calendar.
|
|
@@ -232,7 +282,7 @@ interface IlamyCalendarProps {
|
|
|
232
282
|
* Custom render function for calendar events.
|
|
233
283
|
* If provided, it will override the default event rendering.
|
|
234
284
|
*/
|
|
235
|
-
renderEvent?: (event: CalendarEvent) =>
|
|
285
|
+
renderEvent?: (event: CalendarEvent) => React3.ReactNode;
|
|
236
286
|
/**
|
|
237
287
|
* Callback when an event is clicked.
|
|
238
288
|
* Provides the clicked event object.
|
|
@@ -240,9 +290,9 @@ interface IlamyCalendarProps {
|
|
|
240
290
|
onEventClick?: (event: CalendarEvent) => void;
|
|
241
291
|
/**
|
|
242
292
|
* Callback when a calendar cell is clicked.
|
|
243
|
-
* Provides
|
|
293
|
+
* Provides cell information including start/end dates and optional resourceId.
|
|
244
294
|
*/
|
|
245
|
-
onCellClick?: (
|
|
295
|
+
onCellClick?: (info: CellClickInfo) => void;
|
|
246
296
|
/**
|
|
247
297
|
* Callback when the calendar view changes (month, week, day, year).
|
|
248
298
|
* Useful for syncing with external state or analytics.
|
|
@@ -323,15 +373,32 @@ interface IlamyCalendarProps {
|
|
|
323
373
|
* Custom header component to replace the default calendar header.
|
|
324
374
|
* Useful for adding custom branding or additional controls.
|
|
325
375
|
*/
|
|
326
|
-
headerComponent?:
|
|
376
|
+
headerComponent?: React3.ReactNode;
|
|
327
377
|
/**
|
|
328
378
|
* Custom class name for the calendar header.
|
|
329
379
|
* Useful for applying custom styles to the header.
|
|
330
380
|
*/
|
|
331
381
|
headerClassName?: string;
|
|
382
|
+
/**
|
|
383
|
+
* Configuration for business hours.
|
|
384
|
+
* Defines the working hours to be highlighted on the calendar.
|
|
385
|
+
*/
|
|
386
|
+
businessHours?: BusinessHours;
|
|
387
|
+
/**
|
|
388
|
+
* Custom render function for the event form.
|
|
389
|
+
* If provided, it will override the default event form component.
|
|
390
|
+
* The function receives EventFormProps and should return a React node.
|
|
391
|
+
*/
|
|
392
|
+
renderEventForm?: (props: EventFormProps) => React3.ReactNode;
|
|
393
|
+
/**
|
|
394
|
+
* Time format for displaying times in the calendar.
|
|
395
|
+
* - "12-hour": Times displayed as "1:00 PM" (default)
|
|
396
|
+
* - "24-hour": Times displayed as "13:00"
|
|
397
|
+
*/
|
|
398
|
+
timeFormat?: TimeFormat;
|
|
332
399
|
}
|
|
333
|
-
declare const IlamyCalendar:
|
|
334
|
-
import
|
|
400
|
+
declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
|
|
401
|
+
import React5 from "react";
|
|
335
402
|
/**
|
|
336
403
|
* Public-facing resource calendar event interface with flexible date types.
|
|
337
404
|
* Similar to IlamyCalendarPropEvent but with resource assignment fields.
|
|
@@ -375,16 +442,7 @@ interface Resource {
|
|
|
375
442
|
/** Optional position for resource display */
|
|
376
443
|
position?: number;
|
|
377
444
|
}
|
|
378
|
-
|
|
379
|
-
* Resource calendar event interface extending CalendarEvent with resource assignment
|
|
380
|
-
*/
|
|
381
|
-
interface ResourceCalendarEvent extends CalendarEvent {
|
|
382
|
-
/** Single resource assignment */
|
|
383
|
-
resourceId?: string | number;
|
|
384
|
-
/** Multiple resource assignment (cross-resource events) */
|
|
385
|
-
resourceIds?: (string | number)[];
|
|
386
|
-
}
|
|
387
|
-
declare const IlamyResourceCalendar: React4.FC<IlamyResourceCalendarProps>;
|
|
445
|
+
declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
|
|
388
446
|
/**
|
|
389
447
|
* Simplified calendar context type for external use
|
|
390
448
|
* Contains only the most commonly used calendar operations
|
|
@@ -406,17 +464,18 @@ interface UseIlamyCalendarContextReturn {
|
|
|
406
464
|
readonly addEvent: (event: CalendarEvent) => void;
|
|
407
465
|
readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
|
|
408
466
|
readonly deleteEvent: (eventId: string | number) => void;
|
|
409
|
-
readonly openEventForm: (
|
|
467
|
+
readonly openEventForm: (eventData?: Partial<CalendarEvent>) => void;
|
|
410
468
|
readonly closeEventForm: () => void;
|
|
469
|
+
readonly businessHours?: BusinessHours;
|
|
411
470
|
}
|
|
412
471
|
declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
|
|
413
472
|
/**
|
|
414
473
|
* Simplified resource calendar context type for external use
|
|
415
474
|
*/
|
|
416
475
|
interface UseIlamyResourceCalendarContextReturn extends UseIlamyCalendarContextReturn {
|
|
417
|
-
readonly events:
|
|
476
|
+
readonly events: CalendarEvent[];
|
|
418
477
|
readonly resources: Resource[];
|
|
419
|
-
readonly getEventsForResource: (resourceId: string | number) =>
|
|
478
|
+
readonly getEventsForResource: (resourceId: string | number) => CalendarEvent[];
|
|
420
479
|
}
|
|
421
480
|
declare const useIlamyResourceCalendarContext: () => UseIlamyResourceCalendarContextReturn;
|
|
422
481
|
declare const isRecurringEvent: (event: CalendarEvent) => boolean;
|
|
@@ -430,4 +489,4 @@ declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDa
|
|
|
430
489
|
import { Frequency, Weekday } from "rrule";
|
|
431
490
|
import { RRule } from "rrule";
|
|
432
491
|
declare const defaultTranslations: Translations;
|
|
433
|
-
export { useIlamyResourceCalendarContext, useIlamyCalendarContext, isRecurringEvent, generateRecurringEvents, defaultTranslations, Weekday, WeekDays, UseIlamyResourceCalendarContextReturn, UseIlamyCalendarContextReturn, TranslatorFunction, Translations, TranslationKey,
|
|
492
|
+
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 };
|