@ilamy/calendar 0.1.10 → 0.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 +1 -1
- package/dist/index.d.ts +86 -99
- package/dist/index.js +2133 -1129
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ilamy Calendar
|
|
2
2
|
|
|
3
3
|
A powerful, full-featured React calendar component library built with TypeScript, Tailwind CSS, and modern React patterns. Features multiple calendar views, drag-and-drop support, recurring events, and comprehensive internationalization.
|
|
4
4
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React3 from "react";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import "dayjs/locale/af";
|
|
4
4
|
import "dayjs/locale/am";
|
|
@@ -143,36 +143,27 @@ import "dayjs/locale/zh-cn";
|
|
|
143
143
|
import "dayjs/locale/zh-hk";
|
|
144
144
|
import "dayjs/locale/zh-tw";
|
|
145
145
|
import "dayjs/locale/zh";
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
* If not provided, the event repeats indefinitely
|
|
157
|
-
*/
|
|
158
|
-
endDate?: dayjs.Dayjs;
|
|
159
|
-
/**
|
|
160
|
-
* Optional maximum number of occurrences
|
|
161
|
-
* If provided, takes precedence over endDate
|
|
162
|
-
*/
|
|
163
|
-
count?: number;
|
|
146
|
+
import { Options } from "rrule";
|
|
147
|
+
/**
|
|
148
|
+
* Re-rrule.js Options with practical TypeScript interface.
|
|
149
|
+
* Makes all properties optional except freq and dtstart (which are required by RFC 5545).
|
|
150
|
+
* This allows clean object creation without needing explicit null values.
|
|
151
|
+
*
|
|
152
|
+
* @see https://tools.ietf.org/html/rfc5545 - RFC 5545 iCalendar specification
|
|
153
|
+
* @see https://github.com/jakubroztocil/rrule - rrule.js library documentation
|
|
154
|
+
*/
|
|
155
|
+
type RRuleOptions = {
|
|
164
156
|
/**
|
|
165
|
-
*
|
|
166
|
-
* Only used when frequency is 'weekly'
|
|
167
|
-
* @example [1, 3, 5] for Monday, Wednesday, Friday
|
|
157
|
+
* The frequency of the event. Must be one of the following: DAILY, WEEKLY, MONTHLY, etc.
|
|
168
158
|
*/
|
|
169
|
-
|
|
159
|
+
freq: Options["freq"]
|
|
170
160
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
161
|
+
* The start date of the recurrence rule. This defines when the recurrence pattern begins.
|
|
162
|
+
* Required for proper RRULE functionality according to RFC 5545.
|
|
163
|
+
* @important Same as the event start date.
|
|
173
164
|
*/
|
|
174
|
-
|
|
175
|
-
}
|
|
165
|
+
dtstart: Date
|
|
166
|
+
} & Partial<Omit<Options, "freq" | "dtstart">>;
|
|
176
167
|
/**
|
|
177
168
|
* Core calendar event interface representing a single calendar event.
|
|
178
169
|
* This is the primary data structure for calendar events.
|
|
@@ -182,16 +173,6 @@ interface CalendarEvent {
|
|
|
182
173
|
id: string | number;
|
|
183
174
|
/** Display title of the event */
|
|
184
175
|
title: string;
|
|
185
|
-
/**
|
|
186
|
-
* Original start date for recurring events (used for tracking modifications)
|
|
187
|
-
* @internal
|
|
188
|
-
*/
|
|
189
|
-
originalStart?: dayjs.Dayjs;
|
|
190
|
-
/**
|
|
191
|
-
* Original end date for recurring events (used for tracking modifications)
|
|
192
|
-
* @internal
|
|
193
|
-
*/
|
|
194
|
-
originalEnd?: dayjs.Dayjs;
|
|
195
176
|
/** Start date and time of the event */
|
|
196
177
|
start: dayjs.Dayjs;
|
|
197
178
|
/** End date and time of the event */
|
|
@@ -216,25 +197,33 @@ interface CalendarEvent {
|
|
|
216
197
|
*/
|
|
217
198
|
allDay?: boolean;
|
|
218
199
|
/**
|
|
219
|
-
* Recurrence
|
|
220
|
-
*
|
|
200
|
+
* Recurrence rule for recurring events (RFC 5545 standard)
|
|
201
|
+
*
|
|
202
|
+
* Uses TypeScript interface for better readability, type safety, and IDE support
|
|
203
|
+
* compared to RRULE string format. Converted to rrule.js format internally.
|
|
204
|
+
*
|
|
205
|
+
* @example { freq: 'WEEKLY', interval: 1, byweekday: ['MO', 'WE', 'FR'] }
|
|
206
|
+
* @example { freq: 'DAILY', interval: 1, count: 10 }
|
|
207
|
+
* @example { freq: 'MONTHLY', interval: 1, until: new Date('2025-12-31') }
|
|
221
208
|
*/
|
|
222
|
-
|
|
209
|
+
rrule?: RRuleOptions;
|
|
223
210
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
211
|
+
* Exception dates (EXDATE) - dates to exclude from recurrence
|
|
212
|
+
* Uses ISO string format for storage and transmission
|
|
213
|
+
* @example ['2025-01-15T09:00:00.000Z', '2025-01-22T09:00:00.000Z']
|
|
226
214
|
*/
|
|
227
|
-
|
|
215
|
+
exdates?: string[];
|
|
228
216
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
217
|
+
* Recurrence ID (RECURRENCE-ID) - identifies modified instances
|
|
218
|
+
* Points to the original occurrence date this event modifies
|
|
219
|
+
* Used for events that are modifications of recurring instances
|
|
231
220
|
*/
|
|
232
|
-
|
|
221
|
+
recurrenceId?: string;
|
|
233
222
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
223
|
+
* UID for iCalendar compatibility
|
|
224
|
+
* Unique identifier across calendar systems
|
|
236
225
|
*/
|
|
237
|
-
|
|
226
|
+
uid?: string;
|
|
238
227
|
/**
|
|
239
228
|
* Custom data associated with the event
|
|
240
229
|
* Use this to store additional metadata specific to your application
|
|
@@ -242,41 +231,29 @@ interface CalendarEvent {
|
|
|
242
231
|
*/
|
|
243
232
|
data?: Record<string, any>;
|
|
244
233
|
}
|
|
245
|
-
interface IlamyCalendarEventRecurrence extends Omit<EventRecurrence, "endDate"> {
|
|
246
|
-
/** How often the event repeats */
|
|
247
|
-
endDate?: dayjs.Dayjs | Date | string;
|
|
248
|
-
}
|
|
249
|
-
interface IlamyCalendarEvent extends Omit<CalendarEvent, "start" | "end" | "recurrence" | "originalStart" | "originalEnd"> {
|
|
250
|
-
/** Start date and time of the event */
|
|
251
|
-
start: dayjs.Dayjs | Date | string;
|
|
252
|
-
/** End date and time of the event */
|
|
253
|
-
end: dayjs.Dayjs | Date | string;
|
|
254
|
-
/**
|
|
255
|
-
* Original start date for recurring events (used for tracking modifications)
|
|
256
|
-
* @internal
|
|
257
|
-
*/
|
|
258
|
-
originalStart?: dayjs.Dayjs | Date | string;
|
|
259
|
-
/**
|
|
260
|
-
* Original end date for recurring events (used for tracking modifications)
|
|
261
|
-
* @internal
|
|
262
|
-
*/
|
|
263
|
-
originalEnd?: dayjs.Dayjs | Date | string;
|
|
264
|
-
/**
|
|
265
|
-
* Recurrence configuration for repeating events
|
|
266
|
-
* If present, this event will repeat according to the specified pattern
|
|
267
|
-
*/
|
|
268
|
-
recurrence?: IlamyCalendarEventRecurrence;
|
|
269
|
-
}
|
|
270
234
|
/**
|
|
271
235
|
* Supported days of the week for calendar configuration.
|
|
272
236
|
* Used for setting the first day of the week and other week-related settings.
|
|
273
237
|
*/
|
|
274
238
|
type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
|
|
275
|
-
|
|
239
|
+
import React2 from "react";
|
|
240
|
+
/**
|
|
241
|
+
* This interface extends the base CalendarEvent but allows more flexible date types
|
|
242
|
+
* for the start and end properties. The component will automatically convert these
|
|
243
|
+
* to dayjs objects internally for consistent date handling.
|
|
244
|
+
*
|
|
245
|
+
* @interface IlamyCalendarPropEvent
|
|
246
|
+
* @extends {Omit<CalendarEvent, 'start' | 'end'>}
|
|
247
|
+
*/
|
|
248
|
+
interface IlamyCalendarPropEvent extends Omit<CalendarEvent, "start" | "end"> {
|
|
249
|
+
start: dayjs.Dayjs | Date | string;
|
|
250
|
+
end: dayjs.Dayjs | Date | string;
|
|
251
|
+
}
|
|
252
|
+
interface IlamyCalendarProps {
|
|
276
253
|
/**
|
|
277
254
|
* Array of events to display in the calendar.
|
|
278
255
|
*/
|
|
279
|
-
events?:
|
|
256
|
+
events?: IlamyCalendarPropEvent[];
|
|
280
257
|
/**
|
|
281
258
|
* The first day of the week to display in the calendar.
|
|
282
259
|
* Can be 'sunday', 'monday', etc. Defaults to 'sunday'.
|
|
@@ -296,7 +273,7 @@ interface CalendarProps {
|
|
|
296
273
|
* Callback when a calendar cell is clicked.
|
|
297
274
|
* Provides the start and end date of the clicked cell.
|
|
298
275
|
*/
|
|
299
|
-
onCellClick?: (
|
|
276
|
+
onCellClick?: (start: dayjs.Dayjs, end: dayjs.Dayjs) => void;
|
|
300
277
|
/**
|
|
301
278
|
* Callback when the calendar view changes (month, week, day, year).
|
|
302
279
|
* Useful for syncing with external state or analytics.
|
|
@@ -344,30 +321,40 @@ interface CalendarProps {
|
|
|
344
321
|
*/
|
|
345
322
|
headerComponent?: React2.ReactNode;
|
|
346
323
|
}
|
|
347
|
-
declare const IlamyCalendar:
|
|
324
|
+
declare const IlamyCalendar: React3.FC<IlamyCalendarProps>;
|
|
348
325
|
/**
|
|
349
326
|
* Simplified calendar context type for external use
|
|
350
327
|
* Contains only the most commonly used calendar operations
|
|
351
328
|
*/
|
|
352
|
-
|
|
353
|
-
readonly currentDate: dayjs.Dayjs
|
|
354
|
-
readonly view: "month" | "week" | "day" | "year"
|
|
355
|
-
readonly events: CalendarEvent[]
|
|
356
|
-
readonly isEventFormOpen: boolean
|
|
357
|
-
readonly selectedEvent: CalendarEvent | null
|
|
358
|
-
readonly selectedDate: dayjs.Dayjs | null
|
|
359
|
-
readonly firstDayOfWeek: number
|
|
360
|
-
readonly setCurrentDate: (date: dayjs.Dayjs) => void
|
|
361
|
-
readonly selectDate: (date: dayjs.Dayjs) => void
|
|
362
|
-
readonly setView: (view: "month" | "week" | "day" | "year") => void
|
|
363
|
-
readonly nextPeriod: () => void
|
|
364
|
-
readonly prevPeriod: () => void
|
|
365
|
-
readonly today: () => void
|
|
366
|
-
readonly addEvent: (event: CalendarEvent) => void
|
|
367
|
-
readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void
|
|
368
|
-
readonly deleteEvent: (eventId: string | number) => void
|
|
369
|
-
readonly openEventForm: (date?: dayjs.Dayjs) => void
|
|
370
|
-
readonly closeEventForm: () => void
|
|
371
|
-
}
|
|
329
|
+
interface UseIlamyCalendarContextReturn {
|
|
330
|
+
readonly currentDate: dayjs.Dayjs;
|
|
331
|
+
readonly view: "month" | "week" | "day" | "year";
|
|
332
|
+
readonly events: CalendarEvent[];
|
|
333
|
+
readonly isEventFormOpen: boolean;
|
|
334
|
+
readonly selectedEvent: CalendarEvent | null;
|
|
335
|
+
readonly selectedDate: dayjs.Dayjs | null;
|
|
336
|
+
readonly firstDayOfWeek: number;
|
|
337
|
+
readonly setCurrentDate: (date: dayjs.Dayjs) => void;
|
|
338
|
+
readonly selectDate: (date: dayjs.Dayjs) => void;
|
|
339
|
+
readonly setView: (view: "month" | "week" | "day" | "year") => void;
|
|
340
|
+
readonly nextPeriod: () => void;
|
|
341
|
+
readonly prevPeriod: () => void;
|
|
342
|
+
readonly today: () => void;
|
|
343
|
+
readonly addEvent: (event: CalendarEvent) => void;
|
|
344
|
+
readonly updateEvent: (eventId: string | number, event: Partial<CalendarEvent>) => void;
|
|
345
|
+
readonly deleteEvent: (eventId: string | number) => void;
|
|
346
|
+
readonly openEventForm: (date?: dayjs.Dayjs) => void;
|
|
347
|
+
readonly closeEventForm: () => void;
|
|
348
|
+
}
|
|
372
349
|
declare const useIlamyCalendarContext: () => UseIlamyCalendarContextReturn;
|
|
373
|
-
|
|
350
|
+
declare const isRecurringEvent: (event: CalendarEvent) => boolean;
|
|
351
|
+
interface GenerateRecurringEventsProps {
|
|
352
|
+
event: CalendarEvent;
|
|
353
|
+
currentEvents: CalendarEvent[];
|
|
354
|
+
startDate: dayjs.Dayjs;
|
|
355
|
+
endDate: dayjs.Dayjs;
|
|
356
|
+
}
|
|
357
|
+
declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent[];
|
|
358
|
+
import { Frequency, Weekday } from "rrule";
|
|
359
|
+
import { RRule } from "rrule";
|
|
360
|
+
export { useIlamyCalendarContext, isRecurringEvent, generateRecurringEvents, Weekday, WeekDays, UseIlamyCalendarContextReturn, RRuleOptions, RRule, IlamyCalendarProps, IlamyCalendar, Frequency, CalendarEvent };
|