@mui-toolpad-extended-tuni/calendar 3.0.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/README.md +237 -0
- package/dist/Calendar.d.ts +3 -0
- package/dist/CalendarBody.d.ts +16 -0
- package/dist/CalendarEventAggregator.d.ts +9 -0
- package/dist/CalendarEventItem.d.ts +9 -0
- package/dist/CalendarHeader.d.ts +12 -0
- package/dist/CalendarManager.d.ts +3 -0
- package/dist/CalendarMicroservice.d.ts +32 -0
- package/dist/DatePickerPopover.d.ts +8 -0
- package/dist/components/EventDetails.d.ts +3 -0
- package/dist/components/EventMenu.d.ts +3 -0
- package/dist/components/EventViews.d.ts +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/index.cjs +249 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +15361 -0
- package/dist/store/useCalendarStore.d.ts +44 -0
- package/dist/types.d.ts +49 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# @mui-toolpad-extended-tuni/calendar
|
|
2
|
+
|
|
3
|
+
Calendar microservice extension for MUI Toolpad Extended TUNI. This package provides calendar functionality, event management, and calendar-related components using FullCalendar.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mui-toolpad-extended-tuni/calendar
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Note**: This package requires `mui-toolpad-extended-tuni@^3.0.0` as a peer dependency.
|
|
12
|
+
|
|
13
|
+
## Peer Dependencies
|
|
14
|
+
|
|
15
|
+
- `mui-toolpad-extended-tuni@^3.0.0`
|
|
16
|
+
- `react@^19.0.0`
|
|
17
|
+
- `react-dom@^19.0.0`
|
|
18
|
+
- `react-router-dom@^7.0.0`
|
|
19
|
+
- `@mui/material@^7.0.0`
|
|
20
|
+
- `@mui/icons-material@^7.0.0`
|
|
21
|
+
- `@mui/x-date-pickers@^7.0.0`
|
|
22
|
+
- `@fullcalendar/core@^6.0.0`
|
|
23
|
+
- `@fullcalendar/daygrid@^6.0.0`
|
|
24
|
+
- `@fullcalendar/interaction@^6.0.0`
|
|
25
|
+
- `@fullcalendar/react@^6.0.0`
|
|
26
|
+
- `@fullcalendar/timegrid@^6.0.0`
|
|
27
|
+
- `@emotion/react@^11.0.0`
|
|
28
|
+
- `@emotion/styled@^11.0.0`
|
|
29
|
+
- `luxon@^3.0.0`
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Setup
|
|
34
|
+
|
|
35
|
+
The calendar microservice automatically registers itself when imported:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
39
|
+
import { LMSProvider, Microservices } from 'mui-toolpad-extended-tuni';
|
|
40
|
+
import { CalendarMicroservice } from '@mui-toolpad-extended-tuni/calendar';
|
|
41
|
+
|
|
42
|
+
function App() {
|
|
43
|
+
return (
|
|
44
|
+
<BrowserRouter>
|
|
45
|
+
<LMSProvider>
|
|
46
|
+
<Microservices>
|
|
47
|
+
<CalendarMicroservice />
|
|
48
|
+
{/* Other microservices */}
|
|
49
|
+
</Microservices>
|
|
50
|
+
</LMSProvider>
|
|
51
|
+
</BrowserRouter>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using Calendar Store
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { useCalendarStore } from '@mui-toolpad-extended-tuni/calendar';
|
|
60
|
+
|
|
61
|
+
function MyComponent() {
|
|
62
|
+
const { events, getEvents, addEvent } = useCalendarStore();
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
getEvents();
|
|
66
|
+
}, [getEvents]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div>
|
|
70
|
+
{events.map(event => (
|
|
71
|
+
<div key={event.id}>{event.title}</div>
|
|
72
|
+
))}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Calendar Components
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { Calendar, CalendarManager } from '@mui-toolpad-extended-tuni/calendar';
|
|
82
|
+
|
|
83
|
+
function CalendarPage() {
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<CalendarManager />
|
|
87
|
+
<Calendar />
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Calendar Event Aggregator
|
|
94
|
+
|
|
95
|
+
The `CalendarEventAggregator` component (included in `CalendarMicroservice`) automatically subscribes to events from the EventBus and displays them in the calendar.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { CalendarEventAggregator } from '@mui-toolpad-extended-tuni/calendar';
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<CalendarEventAggregator />
|
|
104
|
+
{/* Rest of your app */}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## EventBus Integration with Courses Package
|
|
111
|
+
|
|
112
|
+
The calendar package automatically integrates with the courses package through the EventBus system. **This integration is automatic** - when both packages are installed, course events are automatically displayed in the calendar!
|
|
113
|
+
|
|
114
|
+
### How It Works
|
|
115
|
+
|
|
116
|
+
1. **Courses Package** (`CourseMicroservice` includes `CourseEventPublisher`):
|
|
117
|
+
- Automatically monitors course data from the course store
|
|
118
|
+
- Converts course events (lectures, exercises, exams, deadlines) to generic EventBus events
|
|
119
|
+
- Publishes them via `eventBus.publish('courses', events)`
|
|
120
|
+
|
|
121
|
+
2. **Calendar Package** (`CalendarMicroservice` includes `CalendarEventAggregator`):
|
|
122
|
+
- Automatically subscribes to EventBus events
|
|
123
|
+
- Converts generic events to calendar events with proper colors based on course subject and level
|
|
124
|
+
- Updates the calendar display in real-time
|
|
125
|
+
|
|
126
|
+
3. **Event Color Coding**:
|
|
127
|
+
- Events are automatically color-coded by course subject (COMP.CS = blue, MATH = green, etc.)
|
|
128
|
+
- Different shades for course levels (basic = light, intermediate = medium, advanced = dark)
|
|
129
|
+
- Distinct styling for different event types
|
|
130
|
+
|
|
131
|
+
### Setup for EventBus Integration
|
|
132
|
+
|
|
133
|
+
Simply include both microservices - the integration happens automatically:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
137
|
+
import { LMSProvider, Microservices } from 'mui-toolpad-extended-tuni';
|
|
138
|
+
import { CourseMicroservice } from '@mui-toolpad-extended-tuni/courses';
|
|
139
|
+
import { CalendarMicroservice } from '@mui-toolpad-extended-tuni/calendar';
|
|
140
|
+
|
|
141
|
+
function App() {
|
|
142
|
+
return (
|
|
143
|
+
<BrowserRouter>
|
|
144
|
+
<LMSProvider>
|
|
145
|
+
<Microservices>
|
|
146
|
+
{/* CourseEventPublisher automatically publishes course events */}
|
|
147
|
+
<CourseMicroservice />
|
|
148
|
+
|
|
149
|
+
{/* CalendarEventAggregator automatically subscribes and displays events */}
|
|
150
|
+
<CalendarMicroservice />
|
|
151
|
+
</Microservices>
|
|
152
|
+
</LMSProvider>
|
|
153
|
+
</BrowserRouter>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**That's it!** No additional configuration needed. Course events will automatically appear in the calendar with proper colors and styling.
|
|
159
|
+
|
|
160
|
+
### Event Sources
|
|
161
|
+
|
|
162
|
+
The calendar aggregates events from multiple sources:
|
|
163
|
+
- **Courses** (`'courses'` source) - Automatically from `@mui-toolpad-extended-tuni/courses`
|
|
164
|
+
- **Custom events** - You can publish your own events to the EventBus
|
|
165
|
+
|
|
166
|
+
### Publishing Custom Events
|
|
167
|
+
|
|
168
|
+
You can also publish custom events that will appear in the calendar:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import { eventBus, Event } from 'mui-toolpad-extended-tuni';
|
|
172
|
+
|
|
173
|
+
function publishCustomEvent() {
|
|
174
|
+
const customEvent: Event = {
|
|
175
|
+
id: 'custom-1',
|
|
176
|
+
title: 'Custom Event',
|
|
177
|
+
start: '2024-01-15T10:00:00Z',
|
|
178
|
+
end: '2024-01-15T11:00:00Z',
|
|
179
|
+
metadata: {
|
|
180
|
+
source: 'custom',
|
|
181
|
+
type: 'meeting',
|
|
182
|
+
description: 'Custom meeting event',
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
eventBus.publish('custom', [customEvent]);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Event Color Coding
|
|
191
|
+
|
|
192
|
+
Events from courses are automatically color-coded:
|
|
193
|
+
- **By Subject**: Each subject (COMP.CS, MATH, PHYS, etc.) has a base color
|
|
194
|
+
- **By Level**: Basic (light), Intermediate (medium), Advanced (dark) shades
|
|
195
|
+
- **By Type**: Different event types (lecture, exercise, exam, etc.) have distinct styling
|
|
196
|
+
|
|
197
|
+
## Exports
|
|
198
|
+
|
|
199
|
+
### Components
|
|
200
|
+
- `CalendarMicroservice` - Main microservice component
|
|
201
|
+
- `Calendar` - Main calendar component (FullCalendar wrapper)
|
|
202
|
+
- `CalendarManager` - Manages calendar registration and grid layout
|
|
203
|
+
- `CalendarEventAggregator` - Aggregates and publishes calendar events
|
|
204
|
+
- `CalendarHeader` - Calendar header with view controls
|
|
205
|
+
|
|
206
|
+
### Store
|
|
207
|
+
- `useCalendarStore` - Zustand store for calendar management
|
|
208
|
+
|
|
209
|
+
### Types
|
|
210
|
+
- `CalendarEventType` - Calendar event type (lecture, exercise, exam, deadline, other, meeting, maintenance)
|
|
211
|
+
|
|
212
|
+
## Features
|
|
213
|
+
|
|
214
|
+
- FullCalendar integration
|
|
215
|
+
- Multiple calendar views (month, week, day)
|
|
216
|
+
- Event management and CRUD operations
|
|
217
|
+
- Event aggregation from course events
|
|
218
|
+
- EventBus integration for event publishing
|
|
219
|
+
- Grid layout integration
|
|
220
|
+
- Responsive calendar design
|
|
221
|
+
- Event type customization
|
|
222
|
+
- Course color integration
|
|
223
|
+
|
|
224
|
+
## Event Types
|
|
225
|
+
|
|
226
|
+
The calendar supports the following event types:
|
|
227
|
+
- `lecture` - Lecture events
|
|
228
|
+
- `exercise` - Exercise sessions
|
|
229
|
+
- `exam` - Examinations
|
|
230
|
+
- `deadline` - Assignment deadlines
|
|
231
|
+
- `other` - Other events
|
|
232
|
+
- `meeting` - Meetings
|
|
233
|
+
- `maintenance` - Maintenance windows
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface CalendarBodyProps {
|
|
3
|
+
calendarRef: React.RefObject<any>;
|
|
4
|
+
calendarView: string;
|
|
5
|
+
events: any[];
|
|
6
|
+
onDatesSet: (arg: any) => void;
|
|
7
|
+
eventDidMount: (info: any) => void;
|
|
8
|
+
showAllDaySlot: boolean;
|
|
9
|
+
onMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
10
|
+
onMouseMove: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
11
|
+
onMouseUp: () => void;
|
|
12
|
+
onMouseLeave: () => void;
|
|
13
|
+
density?: "compact" | "comfortable" | "spacious";
|
|
14
|
+
}
|
|
15
|
+
declare const CalendarBody: React.FC<CalendarBodyProps>;
|
|
16
|
+
export default CalendarBody;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
/**
|
|
3
|
+
* CalendarEventAggregator coordinates between the EventBus and the Calendar store.
|
|
4
|
+
* This component subscribes to generic events from the EventBus and converts them
|
|
5
|
+
* to CalendarEvent format for the calendar display.
|
|
6
|
+
* It's placed at the application level to maintain proper separation of concerns.
|
|
7
|
+
*/
|
|
8
|
+
declare const CalendarEventAggregator: React.FC;
|
|
9
|
+
export default CalendarEventAggregator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EventContentArg } from '@fullcalendar/core';
|
|
2
|
+
type ExtendedEventContentArg = EventContentArg & {
|
|
3
|
+
el?: HTMLElement;
|
|
4
|
+
};
|
|
5
|
+
interface CalendarEventItemProps {
|
|
6
|
+
eventInfo: ExtendedEventContentArg;
|
|
7
|
+
}
|
|
8
|
+
declare const CalendarEventItem: ({ eventInfo }: CalendarEventItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default CalendarEventItem;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface CalendarHeaderProps {
|
|
3
|
+
onPrev: () => void;
|
|
4
|
+
onToday: () => void;
|
|
5
|
+
onNext: () => void;
|
|
6
|
+
onDatePickerOpen: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
7
|
+
calendarView: string;
|
|
8
|
+
onViewChange: (view: string) => void;
|
|
9
|
+
currentTitle: string;
|
|
10
|
+
}
|
|
11
|
+
declare const CalendarHeader: React.FC<CalendarHeaderProps>;
|
|
12
|
+
export default CalendarHeader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
interface CalendarMicroserviceProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* CalendarMicroservice Component
|
|
7
|
+
*
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*
|
|
10
|
+
* Self-contained microservice that handles all calendar-related functionality:
|
|
11
|
+
* - Calendar grid item registration (via CalendarManager)
|
|
12
|
+
* - Calendar microservice registration with NavigationRegistry
|
|
13
|
+
* - Event aggregation from EventBus (via CalendarEventAggregator)
|
|
14
|
+
*
|
|
15
|
+
* Calendar receives events from EventBus, not directly from Courses.
|
|
16
|
+
* Courses publishes events via CourseEventPublisher, Calendar subscribes via CalendarEventAggregator.
|
|
17
|
+
*
|
|
18
|
+
* This component should be used in App.tsx, not LMSProvider.tsx, to maintain
|
|
19
|
+
* proper separation of concerns and avoid tight coupling.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Microservices>
|
|
24
|
+
* <CalendarMicroservice />
|
|
25
|
+
* <CourseMicroservice>
|
|
26
|
+
* <EduTest />
|
|
27
|
+
* </CourseMicroservice>
|
|
28
|
+
* </Microservices>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const CalendarMicroservice: React.FC<CalendarMicroserviceProps>;
|
|
32
|
+
export default CalendarMicroservice;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface DatePickerPopoverProps {
|
|
3
|
+
anchorEl: HTMLElement | null;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onDateSelect: (date: any) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const DatePickerPopover: React.FC<DatePickerPopoverProps>;
|
|
8
|
+
export default DatePickerPopover;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EventDetailsProps } from '../types';
|
|
2
|
+
declare const EventDetails: ({ description, location, courseColor, maxParticipants, requiresRegistration, teachers, type, recurring, onAddToCalendar, onRegister, theme, }: EventDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default EventDetails;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EventMenuProps } from '../types';
|
|
2
|
+
declare const EventMenu: ({ open, anchorEl, onClose, eventInfo, courseColor, type, eventTypeIcons, courseTitle, courseCode, description, location, maxParticipants, requiresRegistration, teachers, recurring, theme, }: EventMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default EventMenu;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EventViewProps } from '../types';
|
|
2
|
+
export declare const CompactEventView: ({ eventInfo, courseCode, type, courseColor, requiresRegistration, recurring, eventTypeIcons, theme, }: EventViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const RegularView: ({ eventInfo, courseCode, type, courseColor, location, requiresRegistration, recurring, eventTypeIcons, theme, }: EventViewProps) => import("react/jsx-runtime").JSX.Element;
|