@mui-toolpad-extended-tuni/calendar 3.0.2 → 3.2.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 +108 -3
- package/dist/CalendarMicroservice.d.ts +4 -1
- package/dist/hooks/useCalendarApiConfig.d.ts +15 -0
- package/dist/index.cjs +291 -73
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +30499 -11420
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ npm install @mui-toolpad-extended-tuni/calendar @mui-toolpad-extended-tuni/main
|
|
|
15
15
|
This package requires the following peer dependencies to be installed:
|
|
16
16
|
|
|
17
17
|
### Required Packages
|
|
18
|
-
- **`@mui-toolpad-extended-tuni/main`**: ^3.
|
|
19
|
-
- **`@mui-toolpad-extended-tuni/core`**: ^3.
|
|
18
|
+
- **`@mui-toolpad-extended-tuni/main`**: ^3.4.0 - **MUST be installed separately**
|
|
19
|
+
- **`@mui-toolpad-extended-tuni/core`**: ^3.2.0 - **MUST be installed separately** (also required by main)
|
|
20
20
|
|
|
21
21
|
### React & UI Framework
|
|
22
22
|
- `react@^19.0.0`
|
|
@@ -47,6 +47,39 @@ npm install @mui-toolpad-extended-tuni/calendar @mui-toolpad-extended-tuni/main
|
|
|
47
47
|
luxon
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## API Configuration
|
|
51
|
+
|
|
52
|
+
**Note**: The calendar package does not make direct API calls. It receives events through the EventBus system from other microservices (primarily the courses package). However, you can configure calendar endpoints via the `apiEndpoints` prop if you plan to add direct API integration in the future.
|
|
53
|
+
|
|
54
|
+
### Default Endpoints
|
|
55
|
+
|
|
56
|
+
If you need to configure calendar endpoints for future API integration:
|
|
57
|
+
|
|
58
|
+
- `get: "api/calendar/"` - GET list of calendar events
|
|
59
|
+
- `getById: "api/calendar/:id"` - GET event by ID
|
|
60
|
+
- `post: "api/calendar/"` - POST create new event
|
|
61
|
+
- `put: "api/calendar/:id/"` - PUT update event
|
|
62
|
+
- `delete: "api/calendar/:id/"` - DELETE event
|
|
63
|
+
|
|
64
|
+
### Customizing Endpoints
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { CalendarMicroservice } from '@mui-toolpad-extended-tuni/calendar';
|
|
68
|
+
import type { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/calendar';
|
|
69
|
+
|
|
70
|
+
const calendarEndpoints: CalendarApiEndpoints = {
|
|
71
|
+
get: "https://api.example.com/v1/calendar",
|
|
72
|
+
getById: "https://api.example.com/v1/calendar/:id",
|
|
73
|
+
post: "https://api.example.com/v1/calendar",
|
|
74
|
+
put: "https://api.example.com/v1/calendar/:id",
|
|
75
|
+
delete: "https://api.example.com/v1/calendar/:id",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
<CalendarMicroservice apiEndpoints={calendarEndpoints} />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Current Implementation**: The calendar currently uses EventBus to receive events from other microservices. Direct API endpoints are reserved for future use.
|
|
82
|
+
|
|
50
83
|
## Usage
|
|
51
84
|
|
|
52
85
|
### Basic Setup
|
|
@@ -213,6 +246,71 @@ Events from courses are automatically color-coded:
|
|
|
213
246
|
- **By Level**: Basic (light), Intermediate (medium), Advanced (dark) shades
|
|
214
247
|
- **By Type**: Different event types (lecture, exercise, exam, etc.) have distinct styling
|
|
215
248
|
|
|
249
|
+
## Data Types
|
|
250
|
+
|
|
251
|
+
### CalendarEvent
|
|
252
|
+
|
|
253
|
+
Calendar event object displayed in the calendar.
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
interface CalendarEvent {
|
|
257
|
+
id: string; // Unique event ID
|
|
258
|
+
title: string; // Event title
|
|
259
|
+
start: Date | string; // Event start date/time (ISO string or Date)
|
|
260
|
+
end?: Date | string; // Event end date/time (optional)
|
|
261
|
+
backgroundColor?: string; // Background color (hex)
|
|
262
|
+
borderColor?: string; // Border color (hex)
|
|
263
|
+
textColor?: string; // Text color (hex)
|
|
264
|
+
extendedProps?: { // Additional event metadata
|
|
265
|
+
courseCode?: string; // Course code (if from courses package)
|
|
266
|
+
courseTitle?: string; // Course title
|
|
267
|
+
type?: string; // Event type
|
|
268
|
+
description?: string; // Event description
|
|
269
|
+
location?: string; // Event location
|
|
270
|
+
[key: string]: any; // Additional custom properties
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### CalendarEventType
|
|
276
|
+
|
|
277
|
+
Type of calendar event.
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
type CalendarEventType =
|
|
281
|
+
| "lecture" // Lecture events
|
|
282
|
+
| "exercise" // Exercise sessions
|
|
283
|
+
| "exam" // Examinations
|
|
284
|
+
| "deadline" // Assignment deadlines
|
|
285
|
+
| "other" // Other events
|
|
286
|
+
| "meeting" // Meetings
|
|
287
|
+
| "maintenance"; // Maintenance windows
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### EventBus Event Format
|
|
291
|
+
|
|
292
|
+
Events received from EventBus (e.g., from courses package) follow this structure:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
interface Event {
|
|
296
|
+
id: string;
|
|
297
|
+
title: string;
|
|
298
|
+
start: string; // ISO date string
|
|
299
|
+
end: string; // ISO date string
|
|
300
|
+
metadata: {
|
|
301
|
+
source: string; // Event source (e.g., "courses")
|
|
302
|
+
type?: CalendarEventType; // Event type
|
|
303
|
+
courseCode?: string; // Course code
|
|
304
|
+
courseTitle?: string; // Course title
|
|
305
|
+
subject?: string; // Course subject
|
|
306
|
+
courseLevel?: "basic" | "intermediate" | "advanced";
|
|
307
|
+
description?: string;
|
|
308
|
+
location?: string;
|
|
309
|
+
[key: string]: any; // Additional metadata
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
216
314
|
## Exports
|
|
217
315
|
|
|
218
316
|
### Components
|
|
@@ -224,9 +322,16 @@ Events from courses are automatically color-coded:
|
|
|
224
322
|
|
|
225
323
|
### Store
|
|
226
324
|
- `useCalendarStore` - Zustand store for calendar management
|
|
325
|
+
- `createCalendarEvent` - Helper function to create calendar events
|
|
326
|
+
- `getContrastColor` - Helper function to get contrasting text color
|
|
327
|
+
|
|
328
|
+
### Hooks
|
|
329
|
+
- `useCalendarApiConfig()` - Hook to access calendar API endpoint configuration (for future use)
|
|
227
330
|
|
|
228
331
|
### Types
|
|
229
|
-
- `
|
|
332
|
+
- `CalendarEvent` - Calendar event interface
|
|
333
|
+
- `CalendarEventType` - Calendar event type enumeration
|
|
334
|
+
- `CalendarApiEndpoints` - API endpoint configuration type (for future use)
|
|
230
335
|
|
|
231
336
|
## Features
|
|
232
337
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
import { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/core';
|
|
3
|
+
export interface CalendarMicroserviceProps {
|
|
3
4
|
children?: ReactNode;
|
|
5
|
+
/** API endpoint configuration for the calendar microservice (for future use) */
|
|
6
|
+
apiEndpoints?: CalendarApiEndpoints;
|
|
4
7
|
}
|
|
5
8
|
/**
|
|
6
9
|
* CalendarMicroservice Component
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CalendarApiEndpoints } from '@mui-toolpad-extended-tuni/core';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access calendar API configuration.
|
|
4
|
+
* Returns the calendar endpoint configuration merged with defaults.
|
|
5
|
+
*
|
|
6
|
+
* @returns Calendar API endpoints configuration, or undefined if not registered
|
|
7
|
+
* @throws Error if used outside of ApiConfigProvider
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const calendarConfig = useCalendarApiConfig();
|
|
12
|
+
* const endpoint = calendarConfig?.get; // "api/calendar/" or custom value
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const useCalendarApiConfig: () => CalendarApiEndpoints | undefined;
|