@ilamy/calendar 0.1.6 → 0.1.7
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 +161 -14
- package/dist/index.js +35 -11
- package/package.json +1 -5
- package/dist/index.cjs +0 -3570
- package/dist/index.d.cts +0 -200
package/dist/index.d.ts
CHANGED
|
@@ -143,58 +143,205 @@ 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
|
-
|
|
181
|
+
/** Unique identifier for the event */
|
|
182
|
+
id: string | number;
|
|
183
|
+
/** Display title of the event */
|
|
148
184
|
title: string;
|
|
149
|
-
|
|
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
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Whether this is an all-day event
|
|
215
|
+
* @default false
|
|
216
|
+
*/
|
|
158
217
|
allDay?: boolean;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
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
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Extended calendar event interface with calculated positioning properties.
|
|
247
|
+
* Used internally by the calendar rendering engine to position events on the grid.
|
|
248
|
+
*
|
|
249
|
+
* @internal This interface is used by the calendar layout system and should not be used directly
|
|
250
|
+
*/
|
|
175
251
|
interface ProcessedCalendarEvent extends CalendarEvent {
|
|
252
|
+
/** Left position as a percentage of the container width (0-100) */
|
|
176
253
|
left: number;
|
|
254
|
+
/** Width as a percentage of the container width (0-100) */
|
|
177
255
|
width: number;
|
|
256
|
+
/** Top position as a percentage of the container height (0-100) */
|
|
178
257
|
top: number;
|
|
258
|
+
/** Height as a percentage of the container height (0-100) */
|
|
179
259
|
height: number;
|
|
180
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Supported days of the week for calendar configuration.
|
|
263
|
+
* Used for setting the first day of the week and other week-related settings.
|
|
264
|
+
*/
|
|
181
265
|
type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
|
|
266
|
+
interface CalendarEvents extends Omit<CalendarEvent, "start" | "end" | "recurrence" | "originalStart" | "originalEnd"> {
|
|
267
|
+
start: dayjs.Dayjs | Date | string;
|
|
268
|
+
end: dayjs.Dayjs | Date | string;
|
|
269
|
+
originalStart?: dayjs.Dayjs | Date | string;
|
|
270
|
+
originalEnd?: dayjs.Dayjs | Date | string;
|
|
271
|
+
recurrence?: EventRecurrence;
|
|
272
|
+
}
|
|
182
273
|
interface CalendarProps {
|
|
183
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Array of events to display in the calendar.
|
|
276
|
+
*/
|
|
277
|
+
events?: CalendarEvents[];
|
|
278
|
+
/**
|
|
279
|
+
* The first day of the week to display in the calendar.
|
|
280
|
+
* Can be 'sunday', 'monday', etc. Defaults to 'sunday'.
|
|
281
|
+
*/
|
|
184
282
|
firstDayOfWeek?: WeekDays;
|
|
283
|
+
/**
|
|
284
|
+
* Custom render function for calendar events.
|
|
285
|
+
* If provided, it will override the default event rendering.
|
|
286
|
+
*/
|
|
185
287
|
renderEvent?: (event: CalendarEvent) => React2.ReactNode;
|
|
288
|
+
/**
|
|
289
|
+
* Callback when an event is clicked.
|
|
290
|
+
* Provides the clicked event object.
|
|
291
|
+
*/
|
|
186
292
|
onEventClick?: (event: CalendarEvent) => void;
|
|
293
|
+
/**
|
|
294
|
+
* Callback when a calendar cell is clicked.
|
|
295
|
+
* Provides the start and end date of the clicked cell.
|
|
296
|
+
*/
|
|
187
297
|
onCellClick?: (startDate: dayjs.Dayjs, endDate: dayjs.Dayjs) => void;
|
|
298
|
+
/**
|
|
299
|
+
* Callback when the calendar view changes (month, week, day, year).
|
|
300
|
+
* Useful for syncing with external state or analytics.
|
|
301
|
+
*/
|
|
188
302
|
onViewChange?: (view: "month" | "week" | "day" | "year") => void;
|
|
303
|
+
/**
|
|
304
|
+
* Locale to use for formatting dates and times.
|
|
305
|
+
* If not provided, the default locale will be used.
|
|
306
|
+
*/
|
|
189
307
|
locale?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Timezone to use for displaying dates and times.
|
|
310
|
+
* If not provided, the local timezone will be used.
|
|
311
|
+
*/
|
|
190
312
|
timezone?: string;
|
|
313
|
+
/**
|
|
314
|
+
* Whether to disable click events on calendar cells.
|
|
315
|
+
* Useful for read-only views or when cell clicks are not needed.
|
|
316
|
+
*/
|
|
191
317
|
disableCellClick?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Whether to disable click events on calendar events.
|
|
320
|
+
* Useful for read-only views or when event clicks are not needed.
|
|
321
|
+
*/
|
|
192
322
|
disableEventClick?: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Whether to disable drag-and-drop functionality for calendar events.
|
|
325
|
+
* Useful for read-only views or when drag-and-drop is not needed.
|
|
326
|
+
*/
|
|
193
327
|
disableDragAndDrop?: boolean;
|
|
194
328
|
dayMaxEvents?: number;
|
|
329
|
+
/**
|
|
330
|
+
* Whether to stick the view header to the top of the calendar.
|
|
331
|
+
* Useful for keeping the header visible while scrolling.
|
|
332
|
+
*/
|
|
195
333
|
stickyViewHeader?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Custom class name for the view header.
|
|
336
|
+
* Useful for applying custom styles or themes.
|
|
337
|
+
*/
|
|
196
338
|
viewHeaderClassName?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Custom header component to replace the default calendar header.
|
|
341
|
+
* Useful for adding custom branding or additional controls.
|
|
342
|
+
*/
|
|
343
|
+
headerComponent?: React2.ReactNode;
|
|
197
344
|
}
|
|
198
345
|
declare const IlamyCalendar: React2.FC<CalendarProps>;
|
|
199
346
|
declare const usePublicCalendarContext: () => {};
|
|
200
|
-
export { usePublicCalendarContext as useIlamyCalendarContext, WeekDays, ProcessedCalendarEvent, IlamyCalendar, CalendarEvent };
|
|
347
|
+
export { usePublicCalendarContext as useIlamyCalendarContext, WeekDays, ProcessedCalendarEvent, IlamyCalendar, EventRecurrence, CalendarEvent };
|