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,214 @@
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
+ interface VanillaCalendarProps extends CalendarProps {
182
+ container: HTMLElement | string;
183
+ className?: string;
184
+ title?: string;
185
+ renderEvent?: (event: CalendarEvent) => string;
186
+ renderNoEvents?: () => string;
187
+ }
188
+ interface VanillaCalendarInstance {
189
+ destroy: () => void;
190
+ updateEvents: (events: CalendarEvent[]) => void;
191
+ getCurrentDate: () => Date | null;
192
+ goToDate: (date: Date) => void;
193
+ getEngine: () => CalendarEngine;
194
+ }
195
+
196
+ declare class VanillaCalendar implements VanillaCalendarInstance {
197
+ private engine;
198
+ private container;
199
+ private unsubscribe;
200
+ private props;
201
+ private actions;
202
+ constructor(props: VanillaCalendarProps);
203
+ private init;
204
+ private render;
205
+ private attachEventListeners;
206
+ updateEvents(events: CalendarEvent[]): void;
207
+ getCurrentDate(): Date | null;
208
+ goToDate(date: Date): void;
209
+ getEngine(): CalendarEngine;
210
+ destroy(): void;
211
+ }
212
+ declare function createCalendar(props: VanillaCalendarProps): VanillaCalendarInstance;
213
+
214
+ export { type CalendarActions, type CalendarConfig, type CalendarDate, CalendarEngine, type CalendarEvent, type CalendarEventHandler, type CalendarProps, type CalendarState, type CalendarViewModel, DAYS, MONTHS, type PopupPosition, VanillaCalendar, type VanillaCalendarInstance, type VanillaCalendarProps, createCalendar, formatDateForDisplay, generateCalendarDates, generateYears, getCellClasses, getEventsForDate, getMonthYearText, getPopupPositionClass, hasEvents, isSameDay, isToday, normalizeDate };
@@ -0,0 +1,214 @@
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
+ interface VanillaCalendarProps extends CalendarProps {
182
+ container: HTMLElement | string;
183
+ className?: string;
184
+ title?: string;
185
+ renderEvent?: (event: CalendarEvent) => string;
186
+ renderNoEvents?: () => string;
187
+ }
188
+ interface VanillaCalendarInstance {
189
+ destroy: () => void;
190
+ updateEvents: (events: CalendarEvent[]) => void;
191
+ getCurrentDate: () => Date | null;
192
+ goToDate: (date: Date) => void;
193
+ getEngine: () => CalendarEngine;
194
+ }
195
+
196
+ declare class VanillaCalendar implements VanillaCalendarInstance {
197
+ private engine;
198
+ private container;
199
+ private unsubscribe;
200
+ private props;
201
+ private actions;
202
+ constructor(props: VanillaCalendarProps);
203
+ private init;
204
+ private render;
205
+ private attachEventListeners;
206
+ updateEvents(events: CalendarEvent[]): void;
207
+ getCurrentDate(): Date | null;
208
+ goToDate(date: Date): void;
209
+ getEngine(): CalendarEngine;
210
+ destroy(): void;
211
+ }
212
+ declare function createCalendar(props: VanillaCalendarProps): VanillaCalendarInstance;
213
+
214
+ export { type CalendarActions, type CalendarConfig, type CalendarDate, CalendarEngine, type CalendarEvent, type CalendarEventHandler, type CalendarProps, type CalendarState, type CalendarViewModel, DAYS, MONTHS, type PopupPosition, VanillaCalendar, type VanillaCalendarInstance, type VanillaCalendarProps, createCalendar, formatDateForDisplay, generateCalendarDates, generateYears, getCellClasses, getEventsForDate, getMonthYearText, getPopupPositionClass, hasEvents, isSameDay, isToday, normalizeDate };