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.
- package/LICENSE +21 -0
- package/README.md +492 -0
- package/dist/core/index.d.mts +181 -0
- package/dist/core/index.d.ts +181 -0
- package/dist/core/index.js +349 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +309 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/index.d.mts +623 -0
- package/dist/index.d.ts +623 -0
- package/dist/index.js +1445 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1403 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +208 -0
- package/dist/react/index.d.ts +208 -0
- package/dist/react/index.js +558 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +516 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/react-native/index.d.mts +465 -0
- package/dist/react-native/index.d.ts +465 -0
- package/dist/react-native/index.js +894 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/index.mjs +851 -0
- package/dist/react-native/index.mjs.map +1 -0
- package/dist/styles/calendar.css +500 -0
- package/dist/vanilla/index.d.mts +214 -0
- package/dist/vanilla/index.d.ts +214 -0
- package/dist/vanilla/index.js +621 -0
- package/dist/vanilla/index.js.map +1 -0
- package/dist/vanilla/index.mjs +579 -0
- package/dist/vanilla/index.mjs.map +1 -0
- package/dist/vanilla/index.umd.js +604 -0
- package/dist/vanilla/index.umd.js.map +1 -0
- package/dist/vue/index.js +1 -0
- package/dist/vue/index.mjs +439 -0
- package/package.json +161 -0
|
@@ -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 };
|