@forcecalendar/interface 1.5.0 → 1.6.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.
@@ -4,13 +4,95 @@
4
4
  * Wraps the @forcecalendar/core Calendar instance
5
5
  * Provides reactive state updates and component synchronization
6
6
  */
7
+ import { Calendar } from '@forcecalendar/core';
7
8
  import { EventBus } from './EventBus.js';
9
+ export type CalendarEvent = import('@forcecalendar/core').Event;
10
+ export type EventsSetOptions = {
11
+ /**
12
+ * - Remove stored events that are absent from the snapshot
13
+ */
14
+ removeMissing?: boolean;
15
+ };
16
+ export type EventsSetUpdate = {
17
+ /**
18
+ * - Event now held by the calendar
19
+ */
20
+ event: CalendarEvent;
21
+ /**
22
+ * - Event instance it replaced
23
+ */
24
+ oldEvent: CalendarEvent;
25
+ };
26
+ export type EventsSetResult = {
27
+ /**
28
+ * - All events after the snapshot was applied
29
+ */
30
+ events: CalendarEvent[];
31
+ /**
32
+ * - Events that were not present before
33
+ */
34
+ added: CalendarEvent[];
35
+ /**
36
+ * - Events whose data changed
37
+ */
38
+ updated: EventsSetUpdate[];
39
+ /**
40
+ * - Events dropped because they were missing from the snapshot
41
+ */
42
+ removed: CalendarEvent[];
43
+ /**
44
+ * - Events left untouched (same instances as before)
45
+ */
46
+ unchanged: CalendarEvent[];
47
+ };
48
+ export type VisibleRange = {
49
+ /**
50
+ * - First instant shown by the current view
51
+ */
52
+ start: Date;
53
+ /**
54
+ * - Last instant shown by the current view (inclusive)
55
+ */
56
+ end: Date;
57
+ };
58
+ export type VisibleRangeChange = VisibleRange & {
59
+ view: string;
60
+ date: Date;
61
+ };
62
+ /**
63
+ * @typedef {import('@forcecalendar/core').Event} CalendarEvent
64
+ */
65
+ /**
66
+ * @typedef {Object} EventsSetOptions
67
+ * @property {boolean} [removeMissing=true] - Remove stored events that are absent from the snapshot
68
+ */
69
+ /**
70
+ * @typedef {Object} EventsSetUpdate
71
+ * @property {CalendarEvent} event - Event now held by the calendar
72
+ * @property {CalendarEvent} oldEvent - Event instance it replaced
73
+ */
74
+ /**
75
+ * @typedef {Object} EventsSetResult
76
+ * @property {CalendarEvent[]} events - All events after the snapshot was applied
77
+ * @property {CalendarEvent[]} added - Events that were not present before
78
+ * @property {EventsSetUpdate[]} updated - Events whose data changed
79
+ * @property {CalendarEvent[]} removed - Events dropped because they were missing from the snapshot
80
+ * @property {CalendarEvent[]} unchanged - Events left untouched (same instances as before)
81
+ */
82
+ /**
83
+ * @typedef {Object} VisibleRange
84
+ * @property {Date} start - First instant shown by the current view
85
+ * @property {Date} end - Last instant shown by the current view (inclusive)
86
+ */
87
+ /**
88
+ * @typedef {VisibleRange & { view: string, date: Date }} VisibleRangeChange
89
+ */
8
90
  declare class StateManager {
9
91
  eventBus: EventBus;
10
- calendar: any;
92
+ calendar: Calendar;
11
93
  state: {
12
- view: any;
13
- currentDate: any;
94
+ view: import("@forcecalendar/core/types").ViewType;
95
+ currentDate: Date;
14
96
  events: never[];
15
97
  selectedEvent: null;
16
98
  selectedDate: null;
@@ -19,6 +101,7 @@ declare class StateManager {
19
101
  config: {};
20
102
  };
21
103
  subscribers: Set<any>;
104
+ _visibleRangeKey: string;
22
105
  _subscriberIds: Map<any, any> | null | undefined;
23
106
  constructor(config?: {});
24
107
  /**
@@ -34,7 +117,7 @@ declare class StateManager {
34
117
  _syncEventsFromCore(options?: {
35
118
  silent: boolean;
36
119
  force: boolean;
37
- }): any;
120
+ }): import("@forcecalendar/core").Event[];
38
121
  /**
39
122
  * Check if two event arrays have the same events by id.
40
123
  * Only used for add/delete guards — updateEvent must pass force:true
@@ -42,8 +125,8 @@ declare class StateManager {
42
125
  */
43
126
  _eventsMatch(arr1: any, arr2: any): any;
44
127
  getState(): {
45
- view: any;
46
- currentDate: any;
128
+ view: import("@forcecalendar/core/types").ViewType;
129
+ currentDate: Date;
47
130
  selectedEvent: null;
48
131
  selectedDate: null;
49
132
  loading: boolean;
@@ -52,8 +135,8 @@ declare class StateManager {
52
135
  events: never[];
53
136
  };
54
137
  setState(updates: any, options?: {}): {
55
- view: any;
56
- currentDate: any;
138
+ view: import("@forcecalendar/core/types").ViewType;
139
+ currentDate: Date;
57
140
  events: never[];
58
141
  selectedEvent: null;
59
142
  selectedDate: null;
@@ -75,26 +158,91 @@ declare class StateManager {
75
158
  notifySubscribers(oldState: any, newState: any): void;
76
159
  emitStateChange(oldState: any, newState: any): void;
77
160
  setView(view: any): void;
78
- getView(): any;
161
+ getView(): import("@forcecalendar/core/types").ViewType;
79
162
  setDate(date: any): void;
80
- getCurrentDate(): any;
163
+ getCurrentDate(): Date;
81
164
  next(): void;
82
165
  previous(): void;
83
166
  today(): void;
84
167
  goToDate(date: any): void;
85
- addEvent(event: any): any;
86
- updateEvent(eventId: any, updates: any): any;
168
+ addEvent(event: any): import("@forcecalendar/core").Event | null;
169
+ updateEvent(eventId: any, updates: any): import("@forcecalendar/core").Event | null;
87
170
  deleteEvent(eventId: any): boolean;
88
- getEvents(): any;
171
+ getEvents(): import("@forcecalendar/core").Event[];
172
+ /**
173
+ * Replace the calendar's events with a complete snapshot, applying only the
174
+ * differences.
175
+ *
176
+ * Unchanged events keep their existing instance, changed ones are replaced,
177
+ * new ones are added and events missing from the snapshot are removed
178
+ * (unless `removeMissing` is false). The state is updated at most once and a
179
+ * single `events:set` bus event carries the change set. The per-event
180
+ * `event:add`/`event:added`/`event:remove`/`event:deleted` events are NOT
181
+ * emitted, so listeners that persist user edits are not triggered by a
182
+ * snapshot load.
183
+ *
184
+ * Uses `Calendar#reconcileEvents` when the installed core provides it
185
+ * (2.4.0+) and falls back to an id-based diff on older cores.
186
+ *
187
+ * @param {Iterable<object|CalendarEvent>} events - Complete snapshot of events
188
+ * @param {EventsSetOptions} [options={}]
189
+ * @returns {EventsSetResult} The applied change set
190
+ * @throws {Error} If an entry fails validation or two entries share an id (an `event:error` bus event is emitted first)
191
+ */
192
+ setEvents(events: Iterable<object | CalendarEvent>, options?: EventsSetOptions): EventsSetResult;
193
+ /**
194
+ * Id-based diff for cores that predate `Calendar#reconcileEvents`.
195
+ * Works on the core calendar directly so no per-event bus events fire.
196
+ * Equivalence is approximated by comparing the fields present in the
197
+ * snapshot entry, so an entry that only omits fields is treated as unchanged.
198
+ *
199
+ * @param {Array<object|CalendarEvent>} snapshot
200
+ * @param {boolean} removeMissing
201
+ * @returns {{ added: CalendarEvent[], updated: EventsSetUpdate[], removed: CalendarEvent[], unchanged: CalendarEvent[] }}
202
+ * @private
203
+ */
204
+ private _reconcileFallback;
205
+ /**
206
+ * Field-wise comparison of a stored event against snapshot data.
207
+ * @param {CalendarEvent} existing
208
+ * @param {object} data
209
+ * @returns {boolean}
210
+ * @private
211
+ */
212
+ private _isEquivalentFallback;
89
213
  /**
90
214
  * Force sync state.events from Core calendar
91
215
  * Use this if you've modified events directly on the Core calendar
92
216
  */
93
- syncEvents(): any;
94
- getEventsForDate(date: any): any;
95
- getEventsInRange(start: any, end: any): any;
217
+ syncEvents(): import("@forcecalendar/core").Event[];
218
+ getEventsForDate(date: any): import("@forcecalendar/core").Event[];
219
+ getEventsInRange(start: any, end: any): import("@forcecalendar/core").Event[];
96
220
  getViewData(): any;
97
221
  enrichViewData(viewData: any): any;
222
+ /**
223
+ * Get the window of dates the current view covers, including leading and
224
+ * trailing days from adjacent months in the month view.
225
+ *
226
+ * `end` is the last millisecond of the window (inclusive), so the pair can
227
+ * be passed straight to {@link StateManager#getEventsInRange}.
228
+ *
229
+ * @returns {VisibleRange}
230
+ */
231
+ getVisibleRange(): VisibleRange;
232
+ /**
233
+ * @param {VisibleRange} range
234
+ * @returns {string}
235
+ * @private
236
+ */
237
+ private _rangeKey;
238
+ /**
239
+ * Single choke point for `range:changed`: recompute the visible window and
240
+ * emit only when it differs from the last one that was announced.
241
+ * Called after view, date and week-start changes, once their own bus events
242
+ * have been emitted, so listeners see navigation before the range update.
243
+ * @private
244
+ */
245
+ private _syncVisibleRange;
98
246
  selectEvent(event: any): void;
99
247
  selectEventById(eventId: any): void;
100
248
  deselectEvent(): void;
package/types/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export { MonthViewRenderer } from './renderers/MonthViewRenderer.js';
15
15
  export { WeekViewRenderer } from './renderers/WeekViewRenderer.js';
16
16
  export { DayViewRenderer } from './renderers/DayViewRenderer.js';
17
17
  export { ForceCalendar } from './components/ForceCalendar.js';
18
+ export { EventForm } from './components/EventForm.js';
@@ -28,7 +28,7 @@ export declare class DateUtils extends CoreDateUtils {
28
28
  /**
29
29
  * Check if date is today
30
30
  */
31
- static isToday(date: any): any;
31
+ static isToday(date: any): boolean;
32
32
  /**
33
33
  * Check if date is in the past
34
34
  */