calendarkit-pro 1.2.1 → 1.3.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 CHANGED
@@ -84,7 +84,9 @@ function MyCalendar() {
84
84
  | `onEventCreate` | `(event: Partial<CalendarEvent>) => void` | Event creation callback |
85
85
  | `onEventUpdate` | `(event: CalendarEvent) => void` | Event update callback |
86
86
  | `onEventDelete` | `(eventId: string) => void` | Event deletion callback |
87
- | `onEventResize` | `(event, start, end) => void` | Event resize callback |
87
+ | `onEventDrop` | `(event, start, end) => void` | Called when an event is dropped (with the event before the move and its new dates), alongside `onEventUpdate` |
88
+ | `onEventResize` | `(event, start, end) => void` | Called when an event is resized, alongside `onEventUpdate` (both fire, so update your state in only one of them) |
89
+ | `onOccurrenceDelete` | `(occurrence, updatedSeries) => void` | Delete a single occurrence of a recurring event: persist `updatedSeries` (it has the date in `recurrence.exdates`). Without it, deleting an occurrence deletes the series |
88
90
  | `calendars` | `Calendar[]` | Multiple calendar support |
89
91
  | `resources` | `Resource[]` | Resources for resource view |
90
92
  | `eventTypes` | `EventType[]` | Pre-defined event types |
@@ -125,7 +127,8 @@ interface CalendarEvent {
125
127
  interval?: number;
126
128
  count?: number;
127
129
  until?: Date;
128
- byweekday?: number[];
130
+ byweekday?: number[]; // 0 = Monday … 6 = Sunday
131
+ exdates?: Date[]; // occurrence starts excluded from the series
129
132
  };
130
133
  }
131
134
  ```
@@ -192,6 +195,25 @@ const recurringEvent: CalendarEvent = {
192
195
  };
193
196
  ```
194
197
 
198
+ Occurrences keep their wall-clock time across daylight-saving changes, in the `timezone` prop's zone (or the browser's).
199
+
200
+ Moving, resizing or editing one occurrence updates the whole series by the same amount (`onEventUpdate` receives the recurring event). To delete a single occurrence, handle `onOccurrenceDelete`:
201
+
202
+ ```tsx
203
+ <Scheduler
204
+ events={events}
205
+ onOccurrenceDelete={(occurrence, updatedSeries) => {
206
+ setEvents(events.map(e => (e.id === updatedSeries.id ? updatedSeries : e)));
207
+ }}
208
+ />
209
+ ```
210
+
211
+ ### Invalid data
212
+
213
+ Dates may be `Date` objects, ISO strings or timestamps. Events with an invalid date or an end before their start are skipped, with a warning in development. Event ids must be unique (duplicates are rendered but warned about, and break drag & drop).
214
+
215
+ Treat events as immutable: to change an event, pass a new object (`events.map(e => e.id === id ? { ...e, title } : e)`). Computations are cached per event object, so mutating an event in place may not be reflected.
216
+
195
217
  ## Timezone Support
196
218
 
197
219
  ```tsx
package/dist/index.d.mts CHANGED
@@ -111,7 +111,13 @@ interface CalendarEvent {
111
111
  count?: number;
112
112
  until?: Date;
113
113
  byweekday?: number[];
114
+ /** Occurrence start dates excluded from the series. */
115
+ exdates?: Date[];
114
116
  };
117
+ /** Set on expanded occurrences: id of the recurring (master) event. */
118
+ originalEventId?: string;
119
+ /** Set on expanded occurrences: start of this occurrence. */
120
+ occurrenceStart?: Date;
115
121
  [key: string]: any;
116
122
  }
117
123
  interface EventType {
@@ -154,6 +160,12 @@ interface CalendarProps {
154
160
  onEventCreate?: (event: Partial<CalendarEvent>) => void;
155
161
  onEventUpdate?: (event: CalendarEvent) => void;
156
162
  onEventDelete?: (eventId: string) => void;
163
+ /**
164
+ * Called when a single occurrence of a recurring event is deleted. `updatedSeries` is the master
165
+ * event with that occurrence added to `recurrence.exdates`: persist it to delete only this
166
+ * occurrence. Without this prop, deleting an occurrence deletes the whole series (`onEventDelete`).
167
+ */
168
+ onOccurrenceDelete?: (occurrence: CalendarEvent, updatedSeries: CalendarEvent) => void;
157
169
  theme?: CalendarTheme;
158
170
  locale?: Locale;
159
171
  timezone?: string;
package/dist/index.d.ts CHANGED
@@ -111,7 +111,13 @@ interface CalendarEvent {
111
111
  count?: number;
112
112
  until?: Date;
113
113
  byweekday?: number[];
114
+ /** Occurrence start dates excluded from the series. */
115
+ exdates?: Date[];
114
116
  };
117
+ /** Set on expanded occurrences: id of the recurring (master) event. */
118
+ originalEventId?: string;
119
+ /** Set on expanded occurrences: start of this occurrence. */
120
+ occurrenceStart?: Date;
115
121
  [key: string]: any;
116
122
  }
117
123
  interface EventType {
@@ -154,6 +160,12 @@ interface CalendarProps {
154
160
  onEventCreate?: (event: Partial<CalendarEvent>) => void;
155
161
  onEventUpdate?: (event: CalendarEvent) => void;
156
162
  onEventDelete?: (eventId: string) => void;
163
+ /**
164
+ * Called when a single occurrence of a recurring event is deleted. `updatedSeries` is the master
165
+ * event with that occurrence added to `recurrence.exdates`: persist it to delete only this
166
+ * occurrence. Without this prop, deleting an occurrence deletes the whole series (`onEventDelete`).
167
+ */
168
+ onOccurrenceDelete?: (occurrence: CalendarEvent, updatedSeries: CalendarEvent) => void;
157
169
  theme?: CalendarTheme;
158
170
  locale?: Locale;
159
171
  timezone?: string;