calendarkit-pro 1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Zesor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,331 @@
1
+ # CalendarKit Pro
2
+
3
+ A professional, feature-rich React calendar component with drag-and-drop, recurring events, timezone support, resource scheduling, and internationalization.
4
+
5
+ [![npm version](https://badge.fury.io/js/calendarkit-pro.svg)](https://www.npmjs.com/package/calendarkit-pro)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - **5 Views** - Month, Week, Day, Agenda, and Resource views
11
+ - **Drag & Drop** - Move events with smooth animations and grid snapping
12
+ - **Event Resize** - Drag event edges to adjust duration
13
+ - **Recurring Events** - Daily, weekly, monthly, yearly with RRule support
14
+ - **Timezone Support** - Full IANA timezone handling
15
+ - **i18n Ready** - Built-in English/French, fully customizable
16
+ - **Resource Scheduling** - Schedule across rooms, people, or equipment
17
+ - **Dark Mode** - Built-in theme toggle
18
+ - **ICS Import/Export** - RFC 5545 compliant
19
+ - **Mobile Friendly** - Touch gestures and responsive layout
20
+ - **TypeScript** - Full type definitions included
21
+ - **High Performance** - Handles 10,000+ events
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install calendarkit-pro
27
+ ```
28
+
29
+ ## Requirements
30
+
31
+ CalendarKit Pro requires **TailwindCSS**. Add the package to your Tailwind config:
32
+
33
+ ```js
34
+ // tailwind.config.js
35
+ module.exports = {
36
+ content: [
37
+ // ... your paths
38
+ './node_modules/calendarkit-pro/**/*.{js,mjs}',
39
+ ],
40
+ }
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```tsx
46
+ import { Scheduler } from 'calendarkit-pro';
47
+ import type { CalendarEvent, ViewType } from 'calendarkit-pro';
48
+ import { useState } from 'react';
49
+
50
+ function MyCalendar() {
51
+ const [events, setEvents] = useState<CalendarEvent[]>([]);
52
+ const [view, setView] = useState<ViewType>('week');
53
+ const [date, setDate] = useState(new Date());
54
+
55
+ return (
56
+ <Scheduler
57
+ events={events}
58
+ view={view}
59
+ onViewChange={setView}
60
+ date={date}
61
+ onDateChange={setDate}
62
+ onEventCreate={(event) => {
63
+ setEvents([...events, { ...event, id: crypto.randomUUID() } as CalendarEvent]);
64
+ }}
65
+ onEventUpdate={(event) => {
66
+ setEvents(events.map(e => e.id === event.id ? event : e));
67
+ }}
68
+ onEventDelete={(id) => {
69
+ setEvents(events.filter(e => e.id !== id));
70
+ }}
71
+ />
72
+ );
73
+ }
74
+ ```
75
+
76
+ ## Props
77
+
78
+ | Prop | Type | Description |
79
+ |------|------|-------------|
80
+ | `events` | `CalendarEvent[]` | Array of events to display |
81
+ | `view` | `ViewType` | Current view: `'month'` \| `'week'` \| `'day'` \| `'agenda'` \| `'resource'` |
82
+ | `date` | `Date` | Currently focused date |
83
+ | `onViewChange` | `(view: ViewType) => void` | View change callback |
84
+ | `onDateChange` | `(date: Date) => void` | Date change callback |
85
+ | `onEventCreate` | `(event: Partial<CalendarEvent>) => void` | Event creation callback |
86
+ | `onEventUpdate` | `(event: CalendarEvent) => void` | Event update callback |
87
+ | `onEventDelete` | `(eventId: string) => void` | Event deletion callback |
88
+ | `onEventResize` | `(event, start, end) => void` | Event resize callback |
89
+ | `calendars` | `Calendar[]` | Multiple calendar support |
90
+ | `resources` | `Resource[]` | Resources for resource view |
91
+ | `eventTypes` | `EventType[]` | Pre-defined event types |
92
+ | `timezone` | `string` | IANA timezone (e.g., `'America/New_York'`) |
93
+ | `onTimezoneChange` | `(tz: string) => void` | Timezone change callback |
94
+ | `language` | `'en'` \| `'fr'` | UI language |
95
+ | `translations` | `Partial<CalendarTranslations>` | Custom translations |
96
+ | `locale` | `Locale` | date-fns locale for formatting |
97
+ | `isDarkMode` | `boolean` | Enable dark mode |
98
+ | `onThemeToggle` | `() => void` | Dark mode toggle callback |
99
+ | `theme` | `CalendarTheme` | Custom theme colors |
100
+ | `readOnly` | `boolean` | Disable editing |
101
+ | `isLoading` | `boolean` | Show loading skeletons |
102
+ | `hideViewSwitcher` | `boolean` | Hide view switcher |
103
+ | `renderEventForm` | `(props) => ReactNode` | Custom event form |
104
+
105
+ ## Types
106
+
107
+ ### CalendarEvent
108
+
109
+ ```typescript
110
+ interface CalendarEvent {
111
+ id: string;
112
+ title: string;
113
+ start: Date;
114
+ end: Date;
115
+ description?: string;
116
+ color?: string;
117
+ allDay?: boolean;
118
+ calendarId?: string;
119
+ resourceId?: string;
120
+ type?: string;
121
+ guests?: string[];
122
+ attachments?: EventAttachment[];
123
+ reminders?: EventReminder[];
124
+ recurrence?: {
125
+ freq: 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
126
+ interval?: number;
127
+ count?: number;
128
+ until?: Date;
129
+ byweekday?: number[];
130
+ };
131
+ }
132
+ ```
133
+
134
+ ### Resource
135
+
136
+ ```typescript
137
+ interface Resource {
138
+ id: string;
139
+ label: string;
140
+ color?: string;
141
+ avatar?: string;
142
+ }
143
+ ```
144
+
145
+ ### CalendarTheme
146
+
147
+ ```typescript
148
+ interface CalendarTheme {
149
+ colors?: {
150
+ primary?: string;
151
+ secondary?: string;
152
+ background?: string;
153
+ foreground?: string;
154
+ border?: string;
155
+ muted?: string;
156
+ accent?: string;
157
+ };
158
+ fontFamily?: string;
159
+ borderRadius?: string;
160
+ }
161
+ ```
162
+
163
+ ## Views
164
+
165
+ ### Month View
166
+ Full month grid with event indicators. Click a date to switch to day view.
167
+
168
+ ### Week View
169
+ 7-day view with hourly time slots. Drag events to reschedule, resize from bottom edge.
170
+
171
+ ### Day View
172
+ Single day with 15-minute time slots. Ideal for detailed scheduling.
173
+
174
+ ### Agenda View
175
+ Chronological list of upcoming events for 30 days. Shows event details and metadata.
176
+
177
+ ### Resource View
178
+ Horizontal timeline for scheduling across resources (rooms, people, equipment).
179
+
180
+ ## Recurring Events
181
+
182
+ ```tsx
183
+ const recurringEvent: CalendarEvent = {
184
+ id: '1',
185
+ title: 'Weekly Standup',
186
+ start: new Date(),
187
+ end: new Date(Date.now() + 3600000),
188
+ recurrence: {
189
+ freq: 'WEEKLY',
190
+ interval: 1,
191
+ count: 10, // or use 'until' for end date
192
+ },
193
+ };
194
+ ```
195
+
196
+ ## Timezone Support
197
+
198
+ ```tsx
199
+ <Scheduler
200
+ timezone="Europe/Paris"
201
+ onTimezoneChange={(tz) => console.log('Timezone:', tz)}
202
+ />
203
+ ```
204
+
205
+ ## Internationalization
206
+
207
+ ```tsx
208
+ import { fr } from 'date-fns/locale';
209
+
210
+ const frenchTranslations = {
211
+ today: "Aujourd'hui",
212
+ month: 'Mois',
213
+ week: 'Semaine',
214
+ day: 'Jour',
215
+ agenda: 'Agenda',
216
+ createEvent: 'Créer un événement',
217
+ // ... more translations
218
+ };
219
+
220
+ <Scheduler
221
+ language="fr"
222
+ locale={fr}
223
+ translations={frenchTranslations}
224
+ />
225
+ ```
226
+
227
+ ## Theming
228
+
229
+ ```tsx
230
+ <Scheduler
231
+ isDarkMode={darkMode}
232
+ onThemeToggle={() => setDarkMode(!darkMode)}
233
+ theme={{
234
+ colors: {
235
+ primary: '#3b82f6',
236
+ background: '#ffffff',
237
+ foreground: '#1a1a1a',
238
+ },
239
+ fontFamily: 'Inter, sans-serif',
240
+ borderRadius: '12px',
241
+ }}
242
+ />
243
+ ```
244
+
245
+ ## Resource Scheduling
246
+
247
+ ```tsx
248
+ const resources: Resource[] = [
249
+ { id: 'room-a', label: 'Conference Room A', color: '#3b82f6' },
250
+ { id: 'room-b', label: 'Conference Room B', color: '#10b981' },
251
+ ];
252
+
253
+ <Scheduler
254
+ view="resource"
255
+ resources={resources}
256
+ events={events}
257
+ />
258
+ ```
259
+
260
+ ## Multiple Calendars
261
+
262
+ ```tsx
263
+ const calendars = [
264
+ { id: 'work', label: 'Work', color: '#3b82f6', active: true },
265
+ { id: 'personal', label: 'Personal', color: '#10b981', active: true },
266
+ ];
267
+
268
+ <Scheduler
269
+ calendars={calendars}
270
+ onCalendarToggle={(id, active) => {
271
+ // Toggle calendar visibility
272
+ }}
273
+ />
274
+ ```
275
+
276
+ ## Custom Event Form
277
+
278
+ ```tsx
279
+ <Scheduler
280
+ renderEventForm={({ isOpen, onClose, event, onSave, onDelete }) => (
281
+ <MyCustomForm
282
+ open={isOpen}
283
+ onClose={onClose}
284
+ event={event}
285
+ onSave={onSave}
286
+ onDelete={onDelete}
287
+ />
288
+ )}
289
+ />
290
+ ```
291
+
292
+ ## Exports
293
+
294
+ ```typescript
295
+ // Components
296
+ export { Scheduler } from 'calendarkit-pro';
297
+
298
+ // Types
299
+ export type {
300
+ CalendarEvent,
301
+ CalendarProps,
302
+ CalendarTheme,
303
+ CalendarTranslations,
304
+ ViewType,
305
+ EventType,
306
+ Resource,
307
+ EventReminder,
308
+ EventAttachment,
309
+ ThemeColors,
310
+ } from 'calendarkit-pro';
311
+
312
+ // Utilities
313
+ export { cn } from 'calendarkit-pro';
314
+ ```
315
+
316
+ ## Browser Support
317
+
318
+ - Chrome (latest)
319
+ - Firefox (latest)
320
+ - Safari (latest)
321
+ - Edge (latest)
322
+
323
+ ## License
324
+
325
+ MIT License - see [LICENSE](LICENSE) for details.
326
+
327
+ ## Links
328
+
329
+ - [GitHub](https://github.com/Zesor/calendarkit-pro)
330
+ - [Issues](https://github.com/Zesor/calendarkit-pro/issues)
331
+ - [CalendarKit](https://calendarkit.io)
@@ -0,0 +1,161 @@
1
+ import React$1 from 'react';
2
+ import { Locale } from 'date-fns';
3
+ import { ClassValue } from 'clsx';
4
+
5
+ type ViewType = 'month' | 'week' | 'day' | 'agenda' | 'resource';
6
+ interface EventAttachment {
7
+ id: string;
8
+ name: string;
9
+ url?: string;
10
+ type: 'file' | 'link' | 'image';
11
+ size?: string;
12
+ }
13
+ interface EventReminder {
14
+ id: string;
15
+ type: 'notification' | 'email';
16
+ time: number;
17
+ label?: string;
18
+ }
19
+ interface CalendarEvent {
20
+ id: string;
21
+ title: string;
22
+ start: Date;
23
+ end: Date;
24
+ description?: string;
25
+ color?: string;
26
+ allDay?: boolean;
27
+ calendarId?: string;
28
+ resourceId?: string;
29
+ type?: string;
30
+ icon?: string;
31
+ attachments?: EventAttachment[];
32
+ guests?: string[];
33
+ reminders?: EventReminder[];
34
+ recurrence?: {
35
+ freq: 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
36
+ interval?: number;
37
+ count?: number;
38
+ until?: Date;
39
+ byweekday?: number[];
40
+ };
41
+ [key: string]: any;
42
+ }
43
+ interface EventType {
44
+ id: string;
45
+ label: string;
46
+ color?: string;
47
+ icon?: React.ReactNode;
48
+ }
49
+ interface Resource {
50
+ id: string;
51
+ label: string;
52
+ color?: string;
53
+ avatar?: string;
54
+ }
55
+ interface ThemeColors {
56
+ primary?: string;
57
+ secondary?: string;
58
+ background?: string;
59
+ foreground?: string;
60
+ border?: string;
61
+ muted?: string;
62
+ accent?: string;
63
+ }
64
+ interface CalendarTheme {
65
+ colors?: ThemeColors;
66
+ fontFamily?: string;
67
+ borderRadius?: string;
68
+ }
69
+ interface CalendarTranslations {
70
+ today: string;
71
+ month: string;
72
+ week: string;
73
+ day: string;
74
+ agenda: string;
75
+ resource: string;
76
+ createEvent: string;
77
+ editEvent: string;
78
+ delete: string;
79
+ save: string;
80
+ cancel: string;
81
+ title: string;
82
+ start: string;
83
+ end: string;
84
+ allDay: string;
85
+ description: string;
86
+ repeat: string;
87
+ noRepeat: string;
88
+ selectCalendar: string;
89
+ selectType: string;
90
+ daily: string;
91
+ weekly: string;
92
+ monthly: string;
93
+ yearly: string;
94
+ event: string;
95
+ task: string;
96
+ appointmentSchedule: string;
97
+ new: string;
98
+ dateAndTime: string;
99
+ timezone: string;
100
+ whosJoining: string;
101
+ suggestedTimes: string;
102
+ viewSuggestions: string;
103
+ whereWillItBe: string;
104
+ location: string;
105
+ descriptionAndAttachments: string;
106
+ dragAndDrop: string;
107
+ guests: string;
108
+ addAttachment: string;
109
+ moreOptions: string;
110
+ doesNotRepeat: string;
111
+ locationHelpText: string;
112
+ }
113
+ interface CalendarProps {
114
+ events?: CalendarEvent[];
115
+ translations?: Partial<CalendarTranslations>;
116
+ view?: ViewType;
117
+ onViewChange?: (view: ViewType) => void;
118
+ date?: Date;
119
+ onDateChange?: (date: Date) => void;
120
+ onEventClick?: (event: CalendarEvent) => void;
121
+ onEventDrop?: (event: CalendarEvent, start: Date, end: Date) => void;
122
+ onEventResize?: (event: CalendarEvent, start: Date, end: Date) => void;
123
+ onEventCreate?: (event: Partial<CalendarEvent>) => void;
124
+ onEventUpdate?: (event: CalendarEvent) => void;
125
+ onEventDelete?: (eventId: string) => void;
126
+ theme?: CalendarTheme;
127
+ locale?: Locale;
128
+ timezone?: string;
129
+ onTimezoneChange?: (timezone: string) => void;
130
+ className?: string;
131
+ readOnly?: boolean;
132
+ calendars?: {
133
+ id: string;
134
+ label: string;
135
+ color?: string;
136
+ active?: boolean;
137
+ }[];
138
+ resources?: Resource[];
139
+ eventTypes?: EventType[];
140
+ onCalendarToggle?: (calendarId: string, active: boolean) => void;
141
+ isLoading?: boolean;
142
+ isDarkMode?: boolean;
143
+ onThemeToggle?: () => void;
144
+ hideViewSwitcher?: boolean;
145
+ language?: 'en' | 'fr';
146
+ onLanguageChange?: (lang: 'en' | 'fr') => void;
147
+ renderEventForm?: (props: {
148
+ isOpen: boolean;
149
+ onClose: () => void;
150
+ event?: CalendarEvent | null;
151
+ initialDate?: Date;
152
+ onSave: (event: Partial<CalendarEvent>) => void;
153
+ onDelete?: (eventId: string) => void;
154
+ }) => React.ReactNode;
155
+ }
156
+
157
+ declare function cn(...inputs: ClassValue[]): string;
158
+
159
+ declare const Scheduler: React$1.FC<CalendarProps>;
160
+
161
+ export { type CalendarEvent, type CalendarProps, type CalendarTheme, type CalendarTranslations, type EventAttachment, type EventReminder, type EventType, type Resource, Scheduler, type ThemeColors, type ViewType, cn };
@@ -0,0 +1,161 @@
1
+ import React$1 from 'react';
2
+ import { Locale } from 'date-fns';
3
+ import { ClassValue } from 'clsx';
4
+
5
+ type ViewType = 'month' | 'week' | 'day' | 'agenda' | 'resource';
6
+ interface EventAttachment {
7
+ id: string;
8
+ name: string;
9
+ url?: string;
10
+ type: 'file' | 'link' | 'image';
11
+ size?: string;
12
+ }
13
+ interface EventReminder {
14
+ id: string;
15
+ type: 'notification' | 'email';
16
+ time: number;
17
+ label?: string;
18
+ }
19
+ interface CalendarEvent {
20
+ id: string;
21
+ title: string;
22
+ start: Date;
23
+ end: Date;
24
+ description?: string;
25
+ color?: string;
26
+ allDay?: boolean;
27
+ calendarId?: string;
28
+ resourceId?: string;
29
+ type?: string;
30
+ icon?: string;
31
+ attachments?: EventAttachment[];
32
+ guests?: string[];
33
+ reminders?: EventReminder[];
34
+ recurrence?: {
35
+ freq: 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
36
+ interval?: number;
37
+ count?: number;
38
+ until?: Date;
39
+ byweekday?: number[];
40
+ };
41
+ [key: string]: any;
42
+ }
43
+ interface EventType {
44
+ id: string;
45
+ label: string;
46
+ color?: string;
47
+ icon?: React.ReactNode;
48
+ }
49
+ interface Resource {
50
+ id: string;
51
+ label: string;
52
+ color?: string;
53
+ avatar?: string;
54
+ }
55
+ interface ThemeColors {
56
+ primary?: string;
57
+ secondary?: string;
58
+ background?: string;
59
+ foreground?: string;
60
+ border?: string;
61
+ muted?: string;
62
+ accent?: string;
63
+ }
64
+ interface CalendarTheme {
65
+ colors?: ThemeColors;
66
+ fontFamily?: string;
67
+ borderRadius?: string;
68
+ }
69
+ interface CalendarTranslations {
70
+ today: string;
71
+ month: string;
72
+ week: string;
73
+ day: string;
74
+ agenda: string;
75
+ resource: string;
76
+ createEvent: string;
77
+ editEvent: string;
78
+ delete: string;
79
+ save: string;
80
+ cancel: string;
81
+ title: string;
82
+ start: string;
83
+ end: string;
84
+ allDay: string;
85
+ description: string;
86
+ repeat: string;
87
+ noRepeat: string;
88
+ selectCalendar: string;
89
+ selectType: string;
90
+ daily: string;
91
+ weekly: string;
92
+ monthly: string;
93
+ yearly: string;
94
+ event: string;
95
+ task: string;
96
+ appointmentSchedule: string;
97
+ new: string;
98
+ dateAndTime: string;
99
+ timezone: string;
100
+ whosJoining: string;
101
+ suggestedTimes: string;
102
+ viewSuggestions: string;
103
+ whereWillItBe: string;
104
+ location: string;
105
+ descriptionAndAttachments: string;
106
+ dragAndDrop: string;
107
+ guests: string;
108
+ addAttachment: string;
109
+ moreOptions: string;
110
+ doesNotRepeat: string;
111
+ locationHelpText: string;
112
+ }
113
+ interface CalendarProps {
114
+ events?: CalendarEvent[];
115
+ translations?: Partial<CalendarTranslations>;
116
+ view?: ViewType;
117
+ onViewChange?: (view: ViewType) => void;
118
+ date?: Date;
119
+ onDateChange?: (date: Date) => void;
120
+ onEventClick?: (event: CalendarEvent) => void;
121
+ onEventDrop?: (event: CalendarEvent, start: Date, end: Date) => void;
122
+ onEventResize?: (event: CalendarEvent, start: Date, end: Date) => void;
123
+ onEventCreate?: (event: Partial<CalendarEvent>) => void;
124
+ onEventUpdate?: (event: CalendarEvent) => void;
125
+ onEventDelete?: (eventId: string) => void;
126
+ theme?: CalendarTheme;
127
+ locale?: Locale;
128
+ timezone?: string;
129
+ onTimezoneChange?: (timezone: string) => void;
130
+ className?: string;
131
+ readOnly?: boolean;
132
+ calendars?: {
133
+ id: string;
134
+ label: string;
135
+ color?: string;
136
+ active?: boolean;
137
+ }[];
138
+ resources?: Resource[];
139
+ eventTypes?: EventType[];
140
+ onCalendarToggle?: (calendarId: string, active: boolean) => void;
141
+ isLoading?: boolean;
142
+ isDarkMode?: boolean;
143
+ onThemeToggle?: () => void;
144
+ hideViewSwitcher?: boolean;
145
+ language?: 'en' | 'fr';
146
+ onLanguageChange?: (lang: 'en' | 'fr') => void;
147
+ renderEventForm?: (props: {
148
+ isOpen: boolean;
149
+ onClose: () => void;
150
+ event?: CalendarEvent | null;
151
+ initialDate?: Date;
152
+ onSave: (event: Partial<CalendarEvent>) => void;
153
+ onDelete?: (eventId: string) => void;
154
+ }) => React.ReactNode;
155
+ }
156
+
157
+ declare function cn(...inputs: ClassValue[]): string;
158
+
159
+ declare const Scheduler: React$1.FC<CalendarProps>;
160
+
161
+ export { type CalendarEvent, type CalendarProps, type CalendarTheme, type CalendarTranslations, type EventAttachment, type EventReminder, type EventType, type Resource, Scheduler, type ThemeColors, type ViewType, cn };