@ilamy/calendar 0.1.6 → 0.1.8

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 CHANGED
@@ -143,58 +143,207 @@ 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
+ interface EventRecurrence {
147
+ /** How often the event repeats */
148
+ frequency: "daily" | "weekly" | "monthly" | "yearly";
149
+ /**
150
+ * Interval between repetitions (e.g., every 2 weeks = interval: 2, frequency: 'weekly')
151
+ * @default 1
152
+ */
153
+ interval: number;
154
+ /**
155
+ * Optional end date for the recurrence pattern
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;
164
+ /**
165
+ * Days of the week for weekly recurrence (0 = Sunday, 6 = Saturday)
166
+ * Only used when frequency is 'weekly'
167
+ * @example [1, 3, 5] for Monday, Wednesday, Friday
168
+ */
169
+ daysOfWeek?: number[];
170
+ /**
171
+ * Specific dates to exclude from the recurrence pattern
172
+ * Useful for holidays or one-off cancellations
173
+ */
174
+ exceptions?: dayjs.Dayjs[];
175
+ }
176
+ /**
177
+ * Core calendar event interface representing a single calendar event.
178
+ * This is the primary data structure for calendar events.
179
+ */
146
180
  interface CalendarEvent {
147
- id: string;
181
+ /** Unique identifier for the event */
182
+ id: string | number;
183
+ /** Display title of the event */
148
184
  title: string;
149
- start: dayjs.Dayjs;
185
+ /**
186
+ * Original start date for recurring events (used for tracking modifications)
187
+ * @internal
188
+ */
150
189
  originalStart?: dayjs.Dayjs;
190
+ /**
191
+ * Original end date for recurring events (used for tracking modifications)
192
+ * @internal
193
+ */
151
194
  originalEnd?: dayjs.Dayjs;
195
+ /** Start date and time of the event */
196
+ start: dayjs.Dayjs;
197
+ /** End date and time of the event */
152
198
  end: dayjs.Dayjs;
199
+ /**
200
+ * Color for the event (supports CSS color values, hex, rgb, hsl, or CSS class names)
201
+ * @example "#3b82f6", "blue-500", "rgb(59, 130, 246)"
202
+ */
153
203
  color?: string;
204
+ /**
205
+ * Background color for the event (supports CSS color values, hex, rgb, hsl, or CSS class names)
206
+ * @example "#dbeafe", "blue-100", "rgba(59, 130, 246, 0.1)"
207
+ */
154
208
  backgroundColor?: string;
209
+ /** Optional description or notes for the event */
155
210
  description?: string;
211
+ /** Optional location where the event takes place */
156
212
  location?: string;
157
- height?: number;
213
+ /**
214
+ * Whether this is an all-day event
215
+ * @default false
216
+ */
158
217
  allDay?: boolean;
159
- recurrence?: {
160
- frequency: "daily" | "weekly" | "monthly" | "yearly"
161
- interval: number
162
- endDate?: dayjs.Dayjs
163
- count?: number
164
- daysOfWeek?: number[]
165
- exceptions?: dayjs.Dayjs[]
166
- };
218
+ /**
219
+ * Recurrence configuration for repeating events
220
+ * If present, this event will repeat according to the specified pattern
221
+ */
222
+ recurrence?: EventRecurrence;
223
+ /**
224
+ * Whether this event is part of a recurring series
225
+ * @internal Set automatically by the calendar system
226
+ */
167
227
  isRecurring?: boolean;
168
- parentEventId?: string;
228
+ /**
229
+ * Reference to the parent event ID for recurring event instances
230
+ * @internal Used to link recurring instances to their parent
231
+ */
232
+ parentEventId?: string | number;
233
+ /**
234
+ * Whether this is a modified instance of a recurring event
235
+ * @internal Used to track exceptions in recurring series
236
+ */
169
237
  isException?: boolean;
170
238
  /**
171
239
  * Custom data associated with the event
240
+ * Use this to store additional metadata specific to your application
241
+ * @example { meetingType: 'standup', attendees: ['john', 'jane'] }
172
242
  */
173
243
  data?: Record<string, any>;
174
244
  }
175
- interface ProcessedCalendarEvent extends CalendarEvent {
176
- left: number;
177
- width: number;
178
- top: number;
179
- height: number;
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;
180
269
  }
270
+ /**
271
+ * Supported days of the week for calendar configuration.
272
+ * Used for setting the first day of the week and other week-related settings.
273
+ */
181
274
  type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
182
275
  interface CalendarProps {
183
- events?: CalendarEvent[];
276
+ /**
277
+ * Array of events to display in the calendar.
278
+ */
279
+ events?: IlamyCalendarEvent[];
280
+ /**
281
+ * The first day of the week to display in the calendar.
282
+ * Can be 'sunday', 'monday', etc. Defaults to 'sunday'.
283
+ */
184
284
  firstDayOfWeek?: WeekDays;
285
+ /**
286
+ * Custom render function for calendar events.
287
+ * If provided, it will override the default event rendering.
288
+ */
185
289
  renderEvent?: (event: CalendarEvent) => React2.ReactNode;
290
+ /**
291
+ * Callback when an event is clicked.
292
+ * Provides the clicked event object.
293
+ */
186
294
  onEventClick?: (event: CalendarEvent) => void;
295
+ /**
296
+ * Callback when a calendar cell is clicked.
297
+ * Provides the start and end date of the clicked cell.
298
+ */
187
299
  onCellClick?: (startDate: dayjs.Dayjs, endDate: dayjs.Dayjs) => void;
300
+ /**
301
+ * Callback when the calendar view changes (month, week, day, year).
302
+ * Useful for syncing with external state or analytics.
303
+ */
188
304
  onViewChange?: (view: "month" | "week" | "day" | "year") => void;
305
+ /**
306
+ * Locale to use for formatting dates and times.
307
+ * If not provided, the default locale will be used.
308
+ */
189
309
  locale?: string;
310
+ /**
311
+ * Timezone to use for displaying dates and times.
312
+ * If not provided, the local timezone will be used.
313
+ */
190
314
  timezone?: string;
315
+ /**
316
+ * Whether to disable click events on calendar cells.
317
+ * Useful for read-only views or when cell clicks are not needed.
318
+ */
191
319
  disableCellClick?: boolean;
320
+ /**
321
+ * Whether to disable click events on calendar events.
322
+ * Useful for read-only views or when event clicks are not needed.
323
+ */
192
324
  disableEventClick?: boolean;
325
+ /**
326
+ * Whether to disable drag-and-drop functionality for calendar events.
327
+ * Useful for read-only views or when drag-and-drop is not needed.
328
+ */
193
329
  disableDragAndDrop?: boolean;
194
330
  dayMaxEvents?: number;
331
+ /**
332
+ * Whether to stick the view header to the top of the calendar.
333
+ * Useful for keeping the header visible while scrolling.
334
+ */
195
335
  stickyViewHeader?: boolean;
336
+ /**
337
+ * Custom class name for the view header.
338
+ * Useful for applying custom styles or themes.
339
+ */
196
340
  viewHeaderClassName?: string;
341
+ /**
342
+ * Custom header component to replace the default calendar header.
343
+ * Useful for adding custom branding or additional controls.
344
+ */
345
+ headerComponent?: React2.ReactNode;
197
346
  }
198
347
  declare const IlamyCalendar: React2.FC<CalendarProps>;
199
348
  declare const usePublicCalendarContext: () => {};
200
- export { usePublicCalendarContext as useIlamyCalendarContext, WeekDays, ProcessedCalendarEvent, IlamyCalendar, CalendarEvent };
349
+ export { usePublicCalendarContext as useIlamyCalendarContext, WeekDays, IlamyCalendar, IlamyCalendarEventRecurrence as EventRecurrence, IlamyCalendarEvent as CalendarEvent };