kalendly 0.1.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.
@@ -0,0 +1,181 @@
1
+ interface CalendarEvent {
2
+ id: string | number;
3
+ name: string;
4
+ date: string | Date;
5
+ description?: string;
6
+ color?: string;
7
+ [key: string]: any;
8
+ }
9
+ interface CalendarDate {
10
+ date: Date;
11
+ isCurrentMonth: boolean;
12
+ isToday: boolean;
13
+ hasEvents: boolean;
14
+ events: CalendarEvent[];
15
+ }
16
+ interface CalendarState {
17
+ currentYear: number;
18
+ currentMonth: number;
19
+ currentDate: number;
20
+ selectedDate: Date | null;
21
+ selectedDayIndex: number | null;
22
+ tasks: CalendarEvent[];
23
+ }
24
+ interface CalendarConfig {
25
+ events: CalendarEvent[];
26
+ initialDate?: Date;
27
+ minYear?: number;
28
+ maxYear?: number;
29
+ weekStartsOn?: 0 | 1;
30
+ }
31
+ interface CalendarActions {
32
+ next: () => void;
33
+ previous: () => void;
34
+ jump: (year: number, month: number) => void;
35
+ selectDate: (date: Date) => void;
36
+ updateTasks: () => void;
37
+ }
38
+ interface PopupPosition {
39
+ class: 'popup-left' | 'popup-right' | 'popup-center-top' | 'popup-center-bottom';
40
+ style?: Record<string, string | number>;
41
+ }
42
+ interface CalendarViewModel extends CalendarState {
43
+ months: string[];
44
+ days: string[];
45
+ years: number[];
46
+ monthAndYearText: string;
47
+ scheduleDay: string;
48
+ calendarDates: (CalendarDate | null)[][];
49
+ popupPositionClass: string;
50
+ }
51
+ type CalendarEventHandler = (event: CalendarEvent) => void;
52
+ interface CalendarProps {
53
+ events: CalendarEvent[];
54
+ initialDate?: Date;
55
+ minYear?: number;
56
+ maxYear?: number;
57
+ weekStartsOn?: 0 | 1;
58
+ onDateSelect?: (date: Date) => void;
59
+ onEventClick?: CalendarEventHandler;
60
+ onMonthChange?: (year: number, month: number) => void;
61
+ }
62
+
63
+ declare const MONTHS: string[];
64
+ declare const DAYS: string[];
65
+ /**
66
+ * Normalizes a date to midnight (00:00:00) for comparison purposes
67
+ */
68
+ declare function normalizeDate(date: Date): Date;
69
+ /**
70
+ * Checks if two dates are the same day
71
+ */
72
+ declare function isSameDay(date1: Date, date2: Date): boolean;
73
+ /**
74
+ * Checks if a date is today
75
+ */
76
+ declare function isToday(date: Date): boolean;
77
+ /**
78
+ * Generates an array of years for the year selector
79
+ */
80
+ declare function generateYears(minYear?: number, maxYear?: number): number[];
81
+ /**
82
+ * Gets events for a specific date
83
+ */
84
+ declare function getEventsForDate(events: CalendarEvent[], date: Date): CalendarEvent[];
85
+ /**
86
+ * Checks if a date has any events
87
+ */
88
+ declare function hasEvents(events: CalendarEvent[], date: Date): boolean;
89
+ /**
90
+ * Generates calendar dates for a given month and year
91
+ */
92
+ declare function generateCalendarDates(year: number, month: number, events?: CalendarEvent[], weekStartsOn?: 0 | 1): (CalendarDate | null)[][];
93
+ /**
94
+ * Gets the popup position class based on the selected day index
95
+ */
96
+ declare function getPopupPositionClass(selectedDayIndex: number | null): string;
97
+ /**
98
+ * Gets CSS classes for a calendar cell
99
+ */
100
+ declare function getCellClasses(calendarDate: CalendarDate | null): string[];
101
+ /**
102
+ * Formats a date for display
103
+ */
104
+ declare function formatDateForDisplay(date: Date): string;
105
+ /**
106
+ * Gets month and year text for display
107
+ */
108
+ declare function getMonthYearText(year: number, month: number): string;
109
+
110
+ declare class CalendarEngine {
111
+ private state;
112
+ private config;
113
+ private listeners;
114
+ constructor(config: CalendarConfig);
115
+ /**
116
+ * Subscribe to state changes
117
+ */
118
+ subscribe(listener: () => void): () => void;
119
+ /**
120
+ * Notify all listeners of state changes
121
+ */
122
+ private notify;
123
+ /**
124
+ * Get current state
125
+ */
126
+ getState(): CalendarState;
127
+ /**
128
+ * Get view model with computed properties
129
+ */
130
+ getViewModel(): CalendarViewModel;
131
+ /**
132
+ * Get actions object
133
+ */
134
+ getActions(): CalendarActions;
135
+ /**
136
+ * Navigate to next month
137
+ */
138
+ private next;
139
+ /**
140
+ * Navigate to previous month
141
+ */
142
+ private previous;
143
+ /**
144
+ * Jump to specific month and year
145
+ */
146
+ private jump;
147
+ /**
148
+ * Select a specific date
149
+ */
150
+ private selectDate;
151
+ /**
152
+ * Update tasks for the currently selected date
153
+ */
154
+ private updateTasks;
155
+ /**
156
+ * Update events configuration
157
+ */
158
+ updateEvents(events: CalendarEvent[]): void;
159
+ /**
160
+ * Handle date cell click
161
+ */
162
+ handleDateClick(date: Date, dayIndex?: number): void;
163
+ /**
164
+ * Check if date has events
165
+ */
166
+ hasEventsForDate(date: Date): boolean;
167
+ /**
168
+ * Get events for a specific date
169
+ */
170
+ getEventsForDate(date: Date): CalendarEvent[];
171
+ /**
172
+ * Clear selected date
173
+ */
174
+ clearSelection(): void;
175
+ /**
176
+ * Destroy the engine and cleanup listeners
177
+ */
178
+ destroy(): void;
179
+ }
180
+
181
+ export { type CalendarActions, type CalendarConfig, type CalendarDate, CalendarEngine, type CalendarEvent, type CalendarEventHandler, type CalendarProps, type CalendarState, type CalendarViewModel, DAYS, MONTHS, type PopupPosition, formatDateForDisplay, generateCalendarDates, generateYears, getCellClasses, getEventsForDate, getMonthYearText, getPopupPositionClass, hasEvents, isSameDay, isToday, normalizeDate };
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CalendarEngine: () => CalendarEngine,
24
+ DAYS: () => DAYS,
25
+ MONTHS: () => MONTHS,
26
+ formatDateForDisplay: () => formatDateForDisplay,
27
+ generateCalendarDates: () => generateCalendarDates,
28
+ generateYears: () => generateYears,
29
+ getCellClasses: () => getCellClasses,
30
+ getEventsForDate: () => getEventsForDate,
31
+ getMonthYearText: () => getMonthYearText,
32
+ getPopupPositionClass: () => getPopupPositionClass,
33
+ hasEvents: () => hasEvents,
34
+ isSameDay: () => isSameDay,
35
+ isToday: () => isToday,
36
+ normalizeDate: () => normalizeDate
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/core/utils.ts
41
+ var MONTHS = [
42
+ "Jan",
43
+ "Feb",
44
+ "Mar",
45
+ "Apr",
46
+ "May",
47
+ "Jun",
48
+ "Jul",
49
+ "Aug",
50
+ "Sep",
51
+ "Oct",
52
+ "Nov",
53
+ "Dec"
54
+ ];
55
+ var DAYS = [
56
+ "Sunday",
57
+ "Monday",
58
+ "Tuesday",
59
+ "Wednesday",
60
+ "Thursday",
61
+ "Friday",
62
+ "Saturday"
63
+ ];
64
+ function normalizeDate(date) {
65
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
66
+ }
67
+ function isSameDay(date1, date2) {
68
+ return normalizeDate(date1).getTime() === normalizeDate(date2).getTime();
69
+ }
70
+ function isToday(date) {
71
+ return isSameDay(date, /* @__PURE__ */ new Date());
72
+ }
73
+ function generateYears(minYear, maxYear) {
74
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
75
+ const min = minYear ?? currentYear - 30;
76
+ const max = maxYear ?? currentYear + 10;
77
+ return Array.from({ length: max - min + 1 }, (_, i) => min + i);
78
+ }
79
+ function getEventsForDate(events, date) {
80
+ const normalizedTargetDate = normalizeDate(date);
81
+ return events.filter((event) => {
82
+ const eventDate = normalizeDate(new Date(event.date));
83
+ return eventDate.getTime() === normalizedTargetDate.getTime();
84
+ });
85
+ }
86
+ function hasEvents(events, date) {
87
+ return getEventsForDate(events, date).length > 0;
88
+ }
89
+ function generateCalendarDates(year, month, events = [], weekStartsOn = 0) {
90
+ const firstDay = new Date(year, month, 1);
91
+ const lastDay = new Date(year, month + 1, 0);
92
+ const daysInMonth = lastDay.getDate();
93
+ let firstDayOfWeek = firstDay.getDay();
94
+ if (weekStartsOn === 1) {
95
+ firstDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;
96
+ }
97
+ const dates = [];
98
+ let day = 1;
99
+ for (let week = 0; week < 6; week++) {
100
+ const weekDates = [];
101
+ for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
102
+ if (week === 0 && dayOfWeek < firstDayOfWeek) {
103
+ weekDates.push(null);
104
+ } else if (day > daysInMonth) {
105
+ weekDates.push(null);
106
+ } else {
107
+ const currentDate = new Date(year, month, day);
108
+ const dateEvents = getEventsForDate(events, currentDate);
109
+ weekDates.push({
110
+ date: currentDate,
111
+ isCurrentMonth: true,
112
+ isToday: isToday(currentDate),
113
+ hasEvents: dateEvents.length > 0,
114
+ events: dateEvents
115
+ });
116
+ day++;
117
+ }
118
+ }
119
+ dates.push(weekDates);
120
+ if (day > daysInMonth && weekDates.every((date) => date === null)) {
121
+ break;
122
+ }
123
+ }
124
+ return dates;
125
+ }
126
+ function getPopupPositionClass(selectedDayIndex) {
127
+ if (selectedDayIndex === null) return "popup-center-bottom";
128
+ if (selectedDayIndex < 3) {
129
+ return "popup-right";
130
+ } else if (selectedDayIndex > 4) {
131
+ return "popup-left";
132
+ } else {
133
+ return "popup-center-bottom";
134
+ }
135
+ }
136
+ function getCellClasses(calendarDate) {
137
+ if (!calendarDate) return [];
138
+ const classes = [];
139
+ if (calendarDate.isToday) {
140
+ classes.push("schedule--current--exam");
141
+ }
142
+ if (calendarDate.hasEvents) {
143
+ classes.push("has--event");
144
+ }
145
+ return classes;
146
+ }
147
+ function formatDateForDisplay(date) {
148
+ return `${DAYS[date.getDay()]} ${date.getDate()}`;
149
+ }
150
+ function getMonthYearText(year, month) {
151
+ return `${MONTHS[month]} ${year}`;
152
+ }
153
+
154
+ // src/core/calendar-engine.ts
155
+ var CalendarEngine = class {
156
+ constructor(config) {
157
+ this.listeners = /* @__PURE__ */ new Set();
158
+ this.config = config;
159
+ const initialDate = config.initialDate || /* @__PURE__ */ new Date();
160
+ this.state = {
161
+ currentYear: initialDate.getFullYear(),
162
+ currentMonth: initialDate.getMonth(),
163
+ currentDate: initialDate.getDate(),
164
+ selectedDate: null,
165
+ selectedDayIndex: null,
166
+ tasks: []
167
+ };
168
+ }
169
+ /**
170
+ * Subscribe to state changes
171
+ */
172
+ subscribe(listener) {
173
+ this.listeners.add(listener);
174
+ return () => this.listeners.delete(listener);
175
+ }
176
+ /**
177
+ * Notify all listeners of state changes
178
+ */
179
+ notify() {
180
+ this.listeners.forEach((listener) => listener());
181
+ }
182
+ /**
183
+ * Get current state
184
+ */
185
+ getState() {
186
+ return { ...this.state };
187
+ }
188
+ /**
189
+ * Get view model with computed properties
190
+ */
191
+ getViewModel() {
192
+ const calendarDates = generateCalendarDates(
193
+ this.state.currentYear,
194
+ this.state.currentMonth,
195
+ this.config.events,
196
+ this.config.weekStartsOn
197
+ );
198
+ return {
199
+ ...this.state,
200
+ months: MONTHS,
201
+ days: DAYS,
202
+ years: generateYears(this.config.minYear, this.config.maxYear),
203
+ monthAndYearText: getMonthYearText(
204
+ this.state.currentYear,
205
+ this.state.currentMonth
206
+ ),
207
+ scheduleDay: this.state.selectedDate ? formatDateForDisplay(this.state.selectedDate) : "",
208
+ calendarDates,
209
+ popupPositionClass: getPopupPositionClass(this.state.selectedDayIndex)
210
+ };
211
+ }
212
+ /**
213
+ * Get actions object
214
+ */
215
+ getActions() {
216
+ return {
217
+ next: this.next.bind(this),
218
+ previous: this.previous.bind(this),
219
+ jump: this.jump.bind(this),
220
+ selectDate: this.selectDate.bind(this),
221
+ updateTasks: this.updateTasks.bind(this)
222
+ };
223
+ }
224
+ /**
225
+ * Navigate to next month
226
+ */
227
+ next() {
228
+ if (this.state.currentMonth === 11) {
229
+ this.state.currentMonth = 0;
230
+ this.state.currentYear++;
231
+ } else {
232
+ this.state.currentMonth++;
233
+ }
234
+ this.state.selectedDate = null;
235
+ this.state.selectedDayIndex = null;
236
+ this.updateTasks();
237
+ this.notify();
238
+ }
239
+ /**
240
+ * Navigate to previous month
241
+ */
242
+ previous() {
243
+ if (this.state.currentMonth === 0) {
244
+ this.state.currentMonth = 11;
245
+ this.state.currentYear--;
246
+ } else {
247
+ this.state.currentMonth--;
248
+ }
249
+ this.state.selectedDate = null;
250
+ this.state.selectedDayIndex = null;
251
+ this.updateTasks();
252
+ this.notify();
253
+ }
254
+ /**
255
+ * Jump to specific month and year
256
+ */
257
+ jump(year, month) {
258
+ this.state.currentYear = year;
259
+ this.state.currentMonth = month;
260
+ this.state.selectedDate = null;
261
+ this.state.selectedDayIndex = null;
262
+ this.updateTasks();
263
+ this.notify();
264
+ }
265
+ /**
266
+ * Select a specific date
267
+ */
268
+ selectDate(date, dayIndex) {
269
+ this.state.selectedDate = date;
270
+ this.state.selectedDayIndex = dayIndex ?? null;
271
+ this.state.currentDate = date.getDate();
272
+ this.state.currentMonth = date.getMonth();
273
+ this.state.currentYear = date.getFullYear();
274
+ this.updateTasks();
275
+ this.notify();
276
+ }
277
+ /**
278
+ * Update tasks for the currently selected date
279
+ */
280
+ updateTasks() {
281
+ if (!this.state.selectedDate) {
282
+ this.state.tasks = [];
283
+ return;
284
+ }
285
+ this.state.tasks = getEventsForDate(
286
+ this.config.events,
287
+ this.state.selectedDate
288
+ );
289
+ }
290
+ /**
291
+ * Update events configuration
292
+ */
293
+ updateEvents(events) {
294
+ this.config.events = events;
295
+ this.updateTasks();
296
+ this.notify();
297
+ }
298
+ /**
299
+ * Handle date cell click
300
+ */
301
+ handleDateClick(date, dayIndex) {
302
+ this.selectDate(date, dayIndex);
303
+ }
304
+ /**
305
+ * Check if date has events
306
+ */
307
+ hasEventsForDate(date) {
308
+ return getEventsForDate(this.config.events, date).length > 0;
309
+ }
310
+ /**
311
+ * Get events for a specific date
312
+ */
313
+ getEventsForDate(date) {
314
+ return getEventsForDate(this.config.events, date);
315
+ }
316
+ /**
317
+ * Clear selected date
318
+ */
319
+ clearSelection() {
320
+ this.state.selectedDate = null;
321
+ this.state.selectedDayIndex = null;
322
+ this.state.tasks = [];
323
+ this.notify();
324
+ }
325
+ /**
326
+ * Destroy the engine and cleanup listeners
327
+ */
328
+ destroy() {
329
+ this.listeners.clear();
330
+ }
331
+ };
332
+ // Annotate the CommonJS export names for ESM import in node:
333
+ 0 && (module.exports = {
334
+ CalendarEngine,
335
+ DAYS,
336
+ MONTHS,
337
+ formatDateForDisplay,
338
+ generateCalendarDates,
339
+ generateYears,
340
+ getCellClasses,
341
+ getEventsForDate,
342
+ getMonthYearText,
343
+ getPopupPositionClass,
344
+ hasEvents,
345
+ isSameDay,
346
+ isToday,
347
+ normalizeDate
348
+ });
349
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/index.ts","../../src/core/utils.ts","../../src/core/calendar-engine.ts"],"sourcesContent":["export * from './types';\nexport * from './utils';\nexport { CalendarEngine } from './calendar-engine';\n\n// Re-export commonly used utilities\nexport {\n MONTHS,\n DAYS,\n normalizeDate,\n isSameDay,\n isToday,\n generateYears,\n getEventsForDate,\n hasEvents,\n generateCalendarDates,\n getPopupPositionClass,\n getCellClasses,\n formatDateForDisplay,\n getMonthYearText,\n} from './utils';\n","import { CalendarEvent, CalendarDate } from './types';\n\nexport const MONTHS = [\n 'Jan',\n 'Feb',\n 'Mar',\n 'Apr',\n 'May',\n 'Jun',\n 'Jul',\n 'Aug',\n 'Sep',\n 'Oct',\n 'Nov',\n 'Dec',\n];\n\nexport const DAYS = [\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n];\n\n/**\n * Normalizes a date to midnight (00:00:00) for comparison purposes\n */\nexport function normalizeDate(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);\n}\n\n/**\n * Checks if two dates are the same day\n */\nexport function isSameDay(date1: Date, date2: Date): boolean {\n return normalizeDate(date1).getTime() === normalizeDate(date2).getTime();\n}\n\n/**\n * Checks if a date is today\n */\nexport function isToday(date: Date): boolean {\n return isSameDay(date, new Date());\n}\n\n/**\n * Generates an array of years for the year selector\n */\nexport function generateYears(minYear?: number, maxYear?: number): number[] {\n const currentYear = new Date().getFullYear();\n const min = minYear ?? currentYear - 30;\n const max = maxYear ?? currentYear + 10;\n\n return Array.from({ length: max - min + 1 }, (_, i) => min + i);\n}\n\n/**\n * Gets events for a specific date\n */\nexport function getEventsForDate(\n events: CalendarEvent[],\n date: Date\n): CalendarEvent[] {\n const normalizedTargetDate = normalizeDate(date);\n\n return events.filter(event => {\n const eventDate = normalizeDate(new Date(event.date));\n return eventDate.getTime() === normalizedTargetDate.getTime();\n });\n}\n\n/**\n * Checks if a date has any events\n */\nexport function hasEvents(events: CalendarEvent[], date: Date): boolean {\n return getEventsForDate(events, date).length > 0;\n}\n\n/**\n * Generates calendar dates for a given month and year\n */\nexport function generateCalendarDates(\n year: number,\n month: number,\n events: CalendarEvent[] = [],\n weekStartsOn: 0 | 1 = 0\n): (CalendarDate | null)[][] {\n const firstDay = new Date(year, month, 1);\n const lastDay = new Date(year, month + 1, 0);\n const daysInMonth = lastDay.getDate();\n\n // Adjust first day based on week start preference\n let firstDayOfWeek = firstDay.getDay();\n if (weekStartsOn === 1) {\n firstDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;\n }\n\n const dates: (CalendarDate | null)[][] = [];\n let day = 1;\n\n for (let week = 0; week < 6; week++) {\n const weekDates: (CalendarDate | null)[] = [];\n\n for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {\n if (week === 0 && dayOfWeek < firstDayOfWeek) {\n weekDates.push(null);\n } else if (day > daysInMonth) {\n weekDates.push(null);\n } else {\n const currentDate = new Date(year, month, day);\n const dateEvents = getEventsForDate(events, currentDate);\n\n weekDates.push({\n date: currentDate,\n isCurrentMonth: true,\n isToday: isToday(currentDate),\n hasEvents: dateEvents.length > 0,\n events: dateEvents,\n });\n day++;\n }\n }\n\n dates.push(weekDates);\n\n // Break early if we've filled all days and the rest of the row is empty\n if (day > daysInMonth && weekDates.every(date => date === null)) {\n break;\n }\n }\n\n return dates;\n}\n\n/**\n * Gets the popup position class based on the selected day index\n */\nexport function getPopupPositionClass(selectedDayIndex: number | null): string {\n if (selectedDayIndex === null) return 'popup-center-bottom';\n\n if (selectedDayIndex < 3) {\n return 'popup-right';\n } else if (selectedDayIndex > 4) {\n return 'popup-left';\n } else {\n return 'popup-center-bottom';\n }\n}\n\n/**\n * Gets CSS classes for a calendar cell\n */\nexport function getCellClasses(calendarDate: CalendarDate | null): string[] {\n if (!calendarDate) return [];\n\n const classes: string[] = [];\n\n if (calendarDate.isToday) {\n classes.push('schedule--current--exam');\n }\n\n if (calendarDate.hasEvents) {\n classes.push('has--event');\n }\n\n return classes;\n}\n\n/**\n * Formats a date for display\n */\nexport function formatDateForDisplay(date: Date): string {\n return `${DAYS[date.getDay()]} ${date.getDate()}`;\n}\n\n/**\n * Gets month and year text for display\n */\nexport function getMonthYearText(year: number, month: number): string {\n return `${MONTHS[month]} ${year}`;\n}\n","import {\n CalendarEvent,\n CalendarState,\n CalendarConfig,\n CalendarActions,\n CalendarViewModel,\n} from './types';\nimport {\n generateCalendarDates,\n getEventsForDate,\n generateYears,\n getPopupPositionClass,\n getMonthYearText,\n formatDateForDisplay,\n MONTHS,\n DAYS,\n} from './utils';\n\nexport class CalendarEngine {\n private state: CalendarState;\n private config: CalendarConfig;\n private listeners: Set<() => void> = new Set();\n\n constructor(config: CalendarConfig) {\n this.config = config;\n\n const initialDate = config.initialDate || new Date();\n this.state = {\n currentYear: initialDate.getFullYear(),\n currentMonth: initialDate.getMonth(),\n currentDate: initialDate.getDate(),\n selectedDate: null,\n selectedDayIndex: null,\n tasks: [],\n };\n }\n\n /**\n * Subscribe to state changes\n */\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Notify all listeners of state changes\n */\n private notify(): void {\n this.listeners.forEach(listener => listener());\n }\n\n /**\n * Get current state\n */\n getState(): CalendarState {\n return { ...this.state };\n }\n\n /**\n * Get view model with computed properties\n */\n getViewModel(): CalendarViewModel {\n const calendarDates = generateCalendarDates(\n this.state.currentYear,\n this.state.currentMonth,\n this.config.events,\n this.config.weekStartsOn\n );\n\n return {\n ...this.state,\n months: MONTHS,\n days: DAYS,\n years: generateYears(this.config.minYear, this.config.maxYear),\n monthAndYearText: getMonthYearText(\n this.state.currentYear,\n this.state.currentMonth\n ),\n scheduleDay: this.state.selectedDate\n ? formatDateForDisplay(this.state.selectedDate)\n : '',\n calendarDates,\n popupPositionClass: getPopupPositionClass(this.state.selectedDayIndex),\n };\n }\n\n /**\n * Get actions object\n */\n getActions(): CalendarActions {\n return {\n next: this.next.bind(this),\n previous: this.previous.bind(this),\n jump: this.jump.bind(this),\n selectDate: this.selectDate.bind(this),\n updateTasks: this.updateTasks.bind(this),\n };\n }\n\n /**\n * Navigate to next month\n */\n private next(): void {\n if (this.state.currentMonth === 11) {\n this.state.currentMonth = 0;\n this.state.currentYear++;\n } else {\n this.state.currentMonth++;\n }\n\n this.state.selectedDate = null;\n this.state.selectedDayIndex = null;\n this.updateTasks();\n this.notify();\n }\n\n /**\n * Navigate to previous month\n */\n private previous(): void {\n if (this.state.currentMonth === 0) {\n this.state.currentMonth = 11;\n this.state.currentYear--;\n } else {\n this.state.currentMonth--;\n }\n\n this.state.selectedDate = null;\n this.state.selectedDayIndex = null;\n this.updateTasks();\n this.notify();\n }\n\n /**\n * Jump to specific month and year\n */\n private jump(year: number, month: number): void {\n this.state.currentYear = year;\n this.state.currentMonth = month;\n this.state.selectedDate = null;\n this.state.selectedDayIndex = null;\n this.updateTasks();\n this.notify();\n }\n\n /**\n * Select a specific date\n */\n private selectDate(date: Date, dayIndex?: number): void {\n this.state.selectedDate = date;\n this.state.selectedDayIndex = dayIndex ?? null;\n this.state.currentDate = date.getDate();\n this.state.currentMonth = date.getMonth();\n this.state.currentYear = date.getFullYear();\n this.updateTasks();\n this.notify();\n }\n\n /**\n * Update tasks for the currently selected date\n */\n private updateTasks(): void {\n if (!this.state.selectedDate) {\n this.state.tasks = [];\n return;\n }\n\n this.state.tasks = getEventsForDate(\n this.config.events,\n this.state.selectedDate\n );\n }\n\n /**\n * Update events configuration\n */\n updateEvents(events: CalendarEvent[]): void {\n this.config.events = events;\n this.updateTasks();\n this.notify();\n }\n\n /**\n * Handle date cell click\n */\n handleDateClick(date: Date, dayIndex?: number): void {\n this.selectDate(date, dayIndex);\n }\n\n /**\n * Check if date has events\n */\n hasEventsForDate(date: Date): boolean {\n return getEventsForDate(this.config.events, date).length > 0;\n }\n\n /**\n * Get events for a specific date\n */\n getEventsForDate(date: Date): CalendarEvent[] {\n return getEventsForDate(this.config.events, date);\n }\n\n /**\n * Clear selected date\n */\n clearSelection(): void {\n this.state.selectedDate = null;\n this.state.selectedDayIndex = null;\n this.state.tasks = [];\n this.notify();\n }\n\n /**\n * Destroy the engine and cleanup listeners\n */\n destroy(): void {\n this.listeners.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,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