customized-calendar 1.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/LICENSE +23 -0
- package/README.md +238 -0
- package/dist/components/classroom-calendar/AddEventModal.d.ts +14 -0
- package/dist/components/classroom-calendar/AddEventModal.d.ts.map +1 -0
- package/dist/components/classroom-calendar/AddEventModal.js +131 -0
- package/dist/components/classroom-calendar/CustomizedCalendar.d.ts +11 -0
- package/dist/components/classroom-calendar/CustomizedCalendar.d.ts.map +1 -0
- package/dist/components/classroom-calendar/CustomizedCalendar.js +442 -0
- package/dist/components/classroom-calendar/DateEventsList.d.ts +14 -0
- package/dist/components/classroom-calendar/DateEventsList.d.ts.map +1 -0
- package/dist/components/classroom-calendar/DateEventsList.js +56 -0
- package/dist/components/classroom-calendar/EventDetailsModal.d.ts +11 -0
- package/dist/components/classroom-calendar/EventDetailsModal.d.ts.map +1 -0
- package/dist/components/classroom-calendar/EventDetailsModal.js +37 -0
- package/dist/components/classroom-calendar/calendar.types.d.ts +57 -0
- package/dist/components/classroom-calendar/calendar.types.d.ts.map +1 -0
- package/dist/components/classroom-calendar/calendar.types.js +10 -0
- package/dist/components/classroom-calendar/calendar.utils.d.ts +64 -0
- package/dist/components/classroom-calendar/calendar.utils.d.ts.map +1 -0
- package/dist/components/classroom-calendar/calendar.utils.js +119 -0
- package/dist/components/classroom-calendar/index.d.ts +7 -0
- package/dist/components/classroom-calendar/index.d.ts.map +1 -0
- package/dist/components/classroom-calendar/index.js +6 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/package.json +74 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar Utility Functions
|
|
3
|
+
*/
|
|
4
|
+
import { CalendarEvent, EventType } from './calendar.types';
|
|
5
|
+
/**
|
|
6
|
+
* Get default color for event type
|
|
7
|
+
* Using vibrant, modern colors with better contrast
|
|
8
|
+
*/
|
|
9
|
+
export declare const getEventTypeColor: (type: EventType) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Format event for FullCalendar
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatEventForFullCalendar: (event: CalendarEvent) => {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
start: string | Date;
|
|
17
|
+
end: string | Date;
|
|
18
|
+
backgroundColor: string;
|
|
19
|
+
borderColor: string;
|
|
20
|
+
textColor: string;
|
|
21
|
+
extendedProps: {
|
|
22
|
+
batchId: string;
|
|
23
|
+
batchName: string;
|
|
24
|
+
type: EventType;
|
|
25
|
+
color: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Convert FullCalendar event back to CalendarEvent
|
|
30
|
+
*/
|
|
31
|
+
export declare const convertFullCalendarEventToCalendarEvent: (fcEvent: any) => CalendarEvent;
|
|
32
|
+
/**
|
|
33
|
+
* Format date to ISO string
|
|
34
|
+
*/
|
|
35
|
+
export declare const formatDateToString: (date: Date) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if date is today
|
|
38
|
+
*/
|
|
39
|
+
export declare const isToday: (date: Date) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get event type label
|
|
42
|
+
*/
|
|
43
|
+
export declare const getEventTypeLabel: (type: EventType) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Convert hex color to RGB
|
|
46
|
+
*/
|
|
47
|
+
export declare const hexToRgb: (hex: string) => {
|
|
48
|
+
r: number;
|
|
49
|
+
g: number;
|
|
50
|
+
b: number;
|
|
51
|
+
} | null;
|
|
52
|
+
/**
|
|
53
|
+
* Convert hex color to RGB string (for CSS rgba)
|
|
54
|
+
*/
|
|
55
|
+
export declare const hexToRgbString: (hex: string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Lighten a hex color by a percentage
|
|
58
|
+
*/
|
|
59
|
+
export declare const lightenColor: (hex: string, percent: number) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Darken a hex color by a percentage
|
|
62
|
+
*/
|
|
63
|
+
export declare const darkenColor: (hex: string, percent: number) => string;
|
|
64
|
+
//# sourceMappingURL=calendar.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.utils.d.ts","sourceRoot":"","sources":["../../../components/classroom-calendar/calendar.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,KAAG,MAQnD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,aAAa;;;;;;;;;;;;;;CAiB9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC,GAClD,SAAS,GAAG,KACX,aAYF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,KAAG,MAE/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,KAAG,OAOpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,KAAG,MAEnD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAS5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAG5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,KAAG,MAS3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,KAAG,MAS1D,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar Utility Functions
|
|
3
|
+
*/
|
|
4
|
+
import { EventType } from './calendar.types';
|
|
5
|
+
/**
|
|
6
|
+
* Get default color for event type
|
|
7
|
+
* Using vibrant, modern colors with better contrast
|
|
8
|
+
*/
|
|
9
|
+
export const getEventTypeColor = (type) => {
|
|
10
|
+
const colorMap = {
|
|
11
|
+
[EventType.SESSION]: '#4f46e5', // Indigo - vibrant blue-purple
|
|
12
|
+
[EventType.EVENT]: '#059669', // Emerald - rich green
|
|
13
|
+
[EventType.EXAM]: '#dc2626', // Red - bold red
|
|
14
|
+
[EventType.HOLIDAY]: '#d97706', // Amber - warm orange
|
|
15
|
+
};
|
|
16
|
+
return colorMap[type] || '#6366f1'; // Default indigo
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Format event for FullCalendar
|
|
20
|
+
*/
|
|
21
|
+
export const formatEventForFullCalendar = (event) => {
|
|
22
|
+
return {
|
|
23
|
+
id: event.id,
|
|
24
|
+
title: event.title,
|
|
25
|
+
start: event.start,
|
|
26
|
+
end: event.end,
|
|
27
|
+
backgroundColor: event.color || getEventTypeColor(event.type),
|
|
28
|
+
borderColor: event.color || getEventTypeColor(event.type),
|
|
29
|
+
textColor: '#ffffff',
|
|
30
|
+
extendedProps: {
|
|
31
|
+
batchId: event.batchId,
|
|
32
|
+
batchName: event.batchName,
|
|
33
|
+
type: event.type,
|
|
34
|
+
color: event.color || getEventTypeColor(event.type),
|
|
35
|
+
...event.extendedProps,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Convert FullCalendar event back to CalendarEvent
|
|
41
|
+
*/
|
|
42
|
+
export const convertFullCalendarEventToCalendarEvent = (fcEvent) => {
|
|
43
|
+
return {
|
|
44
|
+
id: fcEvent.id,
|
|
45
|
+
title: fcEvent.title,
|
|
46
|
+
start: fcEvent.start,
|
|
47
|
+
end: fcEvent.end,
|
|
48
|
+
batchId: fcEvent.extendedProps?.batchId || '',
|
|
49
|
+
batchName: fcEvent.extendedProps?.batchName || '',
|
|
50
|
+
type: fcEvent.extendedProps?.type || EventType.EVENT,
|
|
51
|
+
color: fcEvent.extendedProps?.color || fcEvent.backgroundColor,
|
|
52
|
+
extendedProps: fcEvent.extendedProps,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Format date to ISO string
|
|
57
|
+
*/
|
|
58
|
+
export const formatDateToString = (date) => {
|
|
59
|
+
return date.toISOString().split('T')[0];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Check if date is today
|
|
63
|
+
*/
|
|
64
|
+
export const isToday = (date) => {
|
|
65
|
+
const today = new Date();
|
|
66
|
+
return (date.getDate() === today.getDate() &&
|
|
67
|
+
date.getMonth() === today.getMonth() &&
|
|
68
|
+
date.getFullYear() === today.getFullYear());
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Get event type label
|
|
72
|
+
*/
|
|
73
|
+
export const getEventTypeLabel = (type) => {
|
|
74
|
+
return type.charAt(0) + type.slice(1).toLowerCase();
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Convert hex color to RGB
|
|
78
|
+
*/
|
|
79
|
+
export const hexToRgb = (hex) => {
|
|
80
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
81
|
+
return result
|
|
82
|
+
? {
|
|
83
|
+
r: parseInt(result[1], 16),
|
|
84
|
+
g: parseInt(result[2], 16),
|
|
85
|
+
b: parseInt(result[3], 16),
|
|
86
|
+
}
|
|
87
|
+
: null;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Convert hex color to RGB string (for CSS rgba)
|
|
91
|
+
*/
|
|
92
|
+
export const hexToRgbString = (hex) => {
|
|
93
|
+
const rgb = hexToRgb(hex);
|
|
94
|
+
return rgb ? `${rgb.r}, ${rgb.g}, ${rgb.b}` : '59, 130, 246'; // Default blue
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Lighten a hex color by a percentage
|
|
98
|
+
*/
|
|
99
|
+
export const lightenColor = (hex, percent) => {
|
|
100
|
+
const rgb = hexToRgb(hex);
|
|
101
|
+
if (!rgb)
|
|
102
|
+
return hex;
|
|
103
|
+
const r = Math.min(255, Math.round(rgb.r + (255 - rgb.r) * percent));
|
|
104
|
+
const g = Math.min(255, Math.round(rgb.g + (255 - rgb.g) * percent));
|
|
105
|
+
const b = Math.min(255, Math.round(rgb.b + (255 - rgb.b) * percent));
|
|
106
|
+
return `#${[r, g, b].map((x) => x.toString(16).padStart(2, '0')).join('')}`;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Darken a hex color by a percentage
|
|
110
|
+
*/
|
|
111
|
+
export const darkenColor = (hex, percent) => {
|
|
112
|
+
const rgb = hexToRgb(hex);
|
|
113
|
+
if (!rgb)
|
|
114
|
+
return hex;
|
|
115
|
+
const r = Math.max(0, Math.round(rgb.r * (1 - percent)));
|
|
116
|
+
const g = Math.max(0, Math.round(rgb.g * (1 - percent)));
|
|
117
|
+
const b = Math.max(0, Math.round(rgb.b * (1 - percent)));
|
|
118
|
+
return `#${[r, g, b].map((x) => x.toString(16).padStart(2, '0')).join('')}`;
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/classroom-calendar/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Customized Calendar Component - NPM Package Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the NPM package.
|
|
5
|
+
* It exports all public APIs of the calendar component.
|
|
6
|
+
*/
|
|
7
|
+
export { default as CustomizedCalendar } from '../components/classroom-calendar/CustomizedCalendar';
|
|
8
|
+
export * from '../components/classroom-calendar/calendar.types';
|
|
9
|
+
export * from '../components/classroom-calendar/calendar.utils';
|
|
10
|
+
export type { CalendarEvent, CustomizedCalendarProps, EventType } from '../components/classroom-calendar/calendar.types';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACpG,cAAc,iDAAiD,CAAC;AAChE,cAAc,iDAAiD,CAAC;AAGhE,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Customized Calendar Component - NPM Package Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the NPM package.
|
|
5
|
+
* It exports all public APIs of the calendar component.
|
|
6
|
+
*/
|
|
7
|
+
export { default as CustomizedCalendar } from '../components/classroom-calendar/CustomizedCalendar';
|
|
8
|
+
export * from '../components/classroom-calendar/calendar.types';
|
|
9
|
+
export * from '../components/classroom-calendar/calendar.utils';
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "customized-calendar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A modern, customizable calendar component built with React, TypeScript, and FullCalendar",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"module": "dist/src/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/src/index.js",
|
|
11
|
+
"require": "./dist/src/index.js",
|
|
12
|
+
"types": "./dist/src/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "next dev",
|
|
22
|
+
"build": "next build",
|
|
23
|
+
"build:package": "tsc --project tsconfig.build.json",
|
|
24
|
+
"prepublishOnly": "npm run build:package",
|
|
25
|
+
"start": "next start",
|
|
26
|
+
"lint": "next lint"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"calendar",
|
|
30
|
+
"react",
|
|
31
|
+
"typescript",
|
|
32
|
+
"fullcalendar",
|
|
33
|
+
"event-calendar",
|
|
34
|
+
"customizable",
|
|
35
|
+
"react-component",
|
|
36
|
+
"calendar-component"
|
|
37
|
+
],
|
|
38
|
+
"author": "",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": ""
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^18.0.0",
|
|
46
|
+
"react-dom": "^18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@fullcalendar/core": "^6.1.15",
|
|
50
|
+
"@fullcalendar/daygrid": "^6.1.15",
|
|
51
|
+
"@fullcalendar/interaction": "^6.1.15",
|
|
52
|
+
"@fullcalendar/react": "^6.1.15",
|
|
53
|
+
"@fullcalendar/timegrid": "^6.1.15"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^20.11.0",
|
|
57
|
+
"@types/react": "^18.2.48",
|
|
58
|
+
"@types/react-dom": "^18.2.18",
|
|
59
|
+
"autoprefixer": "^10.4.17",
|
|
60
|
+
"eslint": "^8.56.0",
|
|
61
|
+
"eslint-config-next": "^14.1.0",
|
|
62
|
+
"next": "^14.1.0",
|
|
63
|
+
"postcss": "^8.4.33",
|
|
64
|
+
"tailwindcss": "^3.4.1",
|
|
65
|
+
"typescript": "^5.3.3"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=18.0.0"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|