react-weekly-planning 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 +21 -0
- package/README.md +160 -0
- package/__tests__/page.test.js +46 -0
- package/__tests__/page.test.tsx +57 -0
- package/contexts/CalendarContext.js +12 -0
- package/contexts/CalendarContext.tsx +34 -0
- package/definition.txt +318 -0
- package/definitions/index.js +1 -0
- package/definitions/index.ts +446 -0
- package/docs/global.html +4983 -0
- package/docs/index.html +473 -0
- package/docs/index.ts.html +567 -0
- package/docs/scripts/app.min.js +1 -0
- package/docs/scripts/linenumber.js +26 -0
- package/docs/scripts/search.js +39 -0
- package/docs/styles/app.min.css +1 -0
- package/docs/styles/iframe.css +13 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/docs/styles/reset.css +44 -0
- package/index.js +224 -0
- package/index.tsx +591 -0
- package/jest.config.js +9 -0
- package/jest.config.ts +10 -0
- package/jsdoc.json +26 -0
- package/lib/utils.js +437 -0
- package/lib/utils.ts +598 -0
- package/myJsDoc.js +0 -0
- package/out/index.html +129 -0
- package/out/scripts/app.min.js +1 -0
- package/out/scripts/linenumber.js +26 -0
- package/out/scripts/search.js +39 -0
- package/out/styles/app.min.css +1 -0
- package/out/styles/iframe.css +13 -0
- package/out/styles/prettify-jsdoc.css +111 -0
- package/out/styles/prettify-tomorrow.css +132 -0
- package/out/styles/reset.css +44 -0
- package/package.json +45 -0
- package/style.css +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kacou Yao Yves Morel
|
|
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,160 @@
|
|
|
1
|
+
## License
|
|
2
|
+
|
|
3
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Detailed Description and Use Cases
|
|
7
|
+
|
|
8
|
+
#### `weekOffset`
|
|
9
|
+
|
|
10
|
+
- **Description**: This prop sets the offset for the week being displayed in the calendar.
|
|
11
|
+
- **Type**: `number`
|
|
12
|
+
- **Use Case**: If you want to show the previous week's calendar, you can set `weekOffset` to `-7`. For the next week, set it to `7`. For the current week, set it to `0`.
|
|
13
|
+
|
|
14
|
+
**Example**:
|
|
15
|
+
```jsx
|
|
16
|
+
<Calendar weekOffset={-7} ... />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### `groups`
|
|
20
|
+
|
|
21
|
+
- **Description**: This prop is an array of group data to be displayed in the calendar.
|
|
22
|
+
- **Type**: `GroupFeildsType[]`
|
|
23
|
+
- **Use Case**: Use this prop to display different groups in the calendar. Each group can have an id, label, image URL, and other custom fields.
|
|
24
|
+
The "id" field for each group is required
|
|
25
|
+
**Example**:
|
|
26
|
+
```jsx
|
|
27
|
+
const groups = [
|
|
28
|
+
{ id: '1', label: 'Group 1', imageUrl: 'url1', ... },
|
|
29
|
+
{ id: '2', label: 'Group 2', imageUrl: 'url2', ... }
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
<Calendar groups={groups} ... />
|
|
33
|
+
```
|
|
34
|
+
It is possible to use either Weekoffset or Date, or even both simultaneously.
|
|
35
|
+
#### `date`
|
|
36
|
+
|
|
37
|
+
- **Description**: This prop sets the current date to display in the calendar.
|
|
38
|
+
- **Type**: `Date`
|
|
39
|
+
- **Use Case**: Use this prop to set the focus date of the calendar. It helps in aligning the calendar view to a specific date.
|
|
40
|
+
|
|
41
|
+
**Example**:
|
|
42
|
+
```jsx
|
|
43
|
+
const currentDate = new Date();
|
|
44
|
+
|
|
45
|
+
<Calendar date={currentDate} ... />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### `tasks`
|
|
49
|
+
|
|
50
|
+
- **Description**: This prop is an array of tasks to be displayed in the calendar.
|
|
51
|
+
- **Type**: `TasksType`
|
|
52
|
+
- **Use Case**: Use this prop to manage and display tasks in the calendar. Each task should contain details such as start time, end time, description, date, group ID, and day index.
|
|
53
|
+
taskId, taskStart taskEnd, task, taskDate, groupId, dayIndex
|
|
54
|
+
**Example**:
|
|
55
|
+
```jsx
|
|
56
|
+
const tasks = [
|
|
57
|
+
{ taskId: '1', taskStart:'Time in milliseconde', taskEnd:'Time in milliseconde', task: 'Task 1', taskDate: new Date(), groupId: '1', dayIndex: 0, ... }
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
<Calendar tasks={tasks} ... />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## `CalendarPropsType`
|
|
67
|
+
|
|
68
|
+
Props for the Calendar component.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
| Prop Name | Type | Description |
|
|
72
|
+
|------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
|
|
73
|
+
| `weekOffset` | number | Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week). |
|
|
74
|
+
| `groups` | GroupFeildsType[] | Array of group data to be displayed in the calendar. |
|
|
75
|
+
| `className` | string | Additional class names for the calendar component. |
|
|
76
|
+
| `style` | React.CSSProperties \| undefined | Additional styles for the calendar component. |
|
|
77
|
+
| `date` | Date | The current date to display in the calendar. |
|
|
78
|
+
| `groupRender` | ({ currentGroup }: { currentGroup: GroupFeildsType }) => React.ReactNode | Custom render function for a group. |
|
|
79
|
+
| `dayRender` | ({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear }: { dayIndex: number; day: string; dayOfTheMonth: number; dayMonth: string; dayYear: number; }) => React.ReactNode | Custom render function for a day. |
|
|
80
|
+
| `taskRender` | ({ currentTask, handleDragTask }: { currentTask: TaskFeildsType; handleDragTask?: (event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void; }) => React.ReactNode | Custom render function for a task. |
|
|
81
|
+
| `rowsStyle` | React.CSSProperties \| undefined | Additional styles for the rows. |
|
|
82
|
+
| `rowsClassName` | string | Additional class names for the rows. |
|
|
83
|
+
| `groupsColsStyle` | React.CSSProperties \| undefined | Additional styles for the group columns. |
|
|
84
|
+
| `groupsColsClassName` | string | Additional class names for the group columns. |
|
|
85
|
+
| `daysColsStyle` | React.CSSProperties \| undefined | Additional styles for the day columns. |
|
|
86
|
+
| `daysColsClassName` | string | Additional class names for the day columns. |
|
|
87
|
+
| `addTaskClassName` | string | Additional class names for the add task button. |
|
|
88
|
+
| `addTaskStyle` | React.CSSProperties \| undefined | Additional styles for the add task button. |
|
|
89
|
+
| `groupClassName` | string | Additional class names for the groups. |
|
|
90
|
+
| `groupStyle` | React.CSSProperties \| undefined | Additional styles for the groups. |
|
|
91
|
+
| `dayClassName` | string | Additional class names for the days. |
|
|
92
|
+
| `dayStyle` | React.CSSProperties \| undefined | Additional styles for the days. |
|
|
93
|
+
| `taskContainerStyle` | React.CSSProperties \| undefined | Additional styles for the task container. |
|
|
94
|
+
| `taskContainerClassName` | string | Additional class names for the task container. |
|
|
95
|
+
| `groupHeadContainerStyle` | React.CSSProperties \| undefined | Additional styles for the group head container. |
|
|
96
|
+
| `groupHeadContainerClassName`| string | Additional class names for the group head container. |
|
|
97
|
+
| `sumHoursContainerStyle` | React.CSSProperties \| undefined | Additional styles for the sum hours container. |
|
|
98
|
+
| `sumHoursContainerClassName` | string | Additional class names for the sum hours container. |
|
|
99
|
+
| `sumHoursHeadStyle` | React.CSSProperties \| undefined | Additional styles for the sum hours header. |
|
|
100
|
+
| `sumHoursHeadClassName` | string | Additional class names for the sum hours header. |
|
|
101
|
+
| `handleAddTask` | (groupId: string, dayInfo: dayInfoType) => void | Handler function for adding a new task. |
|
|
102
|
+
| `addTaskRender` | ({ groupId, dayInfo }: { groupId: string; dayInfo: dayInfoType }) => React.ReactNode | Custom render function for adding a task. |
|
|
103
|
+
| `tasks` | TasksType | Array of tasks to be displayed in the calendar. |
|
|
104
|
+
| `handleDragTask` | (event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void | Handler function for dragging a task. |
|
|
105
|
+
| `handleDropTask` | (event: React.DragEvent<HTMLTableDataCellElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void | Handler function for dropping a task. |
|
|
106
|
+
| `handleDragTaskEnd` | (event: React.DragEvent<HTMLDivElement>) => void | Handler function for ending the drag of a task. |
|
|
107
|
+
| `groupsHeadRender` | () => React.ReactNode | Custom render function for the groups header. |
|
|
108
|
+
| `sumHoursRender` | ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups }: { groupId: string; tasks: TasksType; weekOffset: number; calendarDate: Date; sumHoursByGroups: number; }) => React.ReactNode | Custom render function for the sum of hours. |
|
|
109
|
+
| `sumHoursHeadRender` | () => React.ReactNode | Custom render function for the sum of hours header. |
|
|
110
|
+
| `handleClickTask` | (currentTask: TaskFeildsType) => void | Handler function for clicking a task. |
|
|
111
|
+
| `handleClickGroup` | (currentGroup: GroupFeildsType) => void | Handler function for clicking a group. |
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Additional Functions
|
|
117
|
+
|
|
118
|
+
### `updateCalendarDateWithOffset`
|
|
119
|
+
|
|
120
|
+
- **Description**: Updates the calendar date based on the week offset.
|
|
121
|
+
- **Parameters**:
|
|
122
|
+
- `offset` (number): This represents the difference in days between the current calendar date and the same date from the previous week. A shift of 7 days takes us to the following week, while a shift of -7 days takes us back to last week. `weekOffset` is different and represents the difference in days between the current date and the week we want to reach. **A shift of 14 days brings us back to the next week starting from the current date `new Date()`**.
|
|
123
|
+
**The current date `new Date()` is not necessarily the one selected in the calendar**.
|
|
124
|
+
- `calendarDate` (Date): The current calendar date.
|
|
125
|
+
- **Returns**: A new `Date` object with the updated date.
|
|
126
|
+
|
|
127
|
+
**Example**:
|
|
128
|
+
```javascript
|
|
129
|
+
const updatedDate = updateCalendarDateWithOffset(7, new Date());
|
|
130
|
+
console.log(updatedDate); // Logs the date one week ahead
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `updateOffsetWithDateCalendar`
|
|
134
|
+
|
|
135
|
+
- **Description**: Calculates the week offset from a given calendar date.
|
|
136
|
+
- **Parameters**:
|
|
137
|
+
- `calendarDate` (Date): The calendar date.
|
|
138
|
+
- **Returns**: The calculated week offset.
|
|
139
|
+
|
|
140
|
+
**Example**:
|
|
141
|
+
```javascript
|
|
142
|
+
const offset = updateOffsetWithDateCalendar(new Date());
|
|
143
|
+
console.log(offset); // Logs the week offset for the given date
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### `millisecondsToHours`
|
|
147
|
+
|
|
148
|
+
- **Description**: Converts milliseconds to a formatted hour string.
|
|
149
|
+
- **Parameters**:
|
|
150
|
+
- `milliseconds` (number): The time duration in milliseconds.
|
|
151
|
+
- **Returns**: A formatted date string.
|
|
152
|
+
|
|
153
|
+
**Example**:
|
|
154
|
+
```javascript
|
|
155
|
+
const formattedTime = millisecondsToHours(1716905215397);
|
|
156
|
+
console.log(formattedTime); // Logs the formatted time for 14h06
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
function getWeekNumber(date) {
|
|
3
|
+
date.setHours(0, 0, 0, 0);
|
|
4
|
+
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
|
|
5
|
+
const yearStart = new Date(date.getFullYear(), 0, 1).getTime();
|
|
6
|
+
const weekNumber = Math.ceil(((date.getTime() - yearStart) / 86400000 + 1) / 7);
|
|
7
|
+
return weekNumber;
|
|
8
|
+
}
|
|
9
|
+
function calculerEcartSemaine(dateSelectionnee) {
|
|
10
|
+
// Récupérer la date actuelle
|
|
11
|
+
const dateActuelle = new Date();
|
|
12
|
+
// Extraire l'année et le numéro de la semaine de la date actuelle
|
|
13
|
+
const anneeActuelle = dateActuelle.getFullYear();
|
|
14
|
+
const numeroSemaineActuelle = getWeekNumber(dateActuelle);
|
|
15
|
+
// Extraire l'année et le numéro de la semaine de la date sélectionnée
|
|
16
|
+
const anneeSelectionnee = dateSelectionnee.getFullYear();
|
|
17
|
+
const numeroSemaineSelectionnee = getWeekNumber(dateSelectionnee);
|
|
18
|
+
// Calculer le nombre de semaines depuis une date d'origine arbitraire
|
|
19
|
+
// Calculer l'écart entre les semaines en utilisant la formule
|
|
20
|
+
const ecartSemaine = semainesDepuisOrigine(anneeSelectionnee, numeroSemaineSelectionnee) -
|
|
21
|
+
semainesDepuisOrigine(anneeActuelle, numeroSemaineActuelle);
|
|
22
|
+
return ecartSemaine * 7;
|
|
23
|
+
}
|
|
24
|
+
function semainesDepuisOrigine(annee, numeroSemaine) {
|
|
25
|
+
// Choisir le 1er janvier 2022 comme date d'origine
|
|
26
|
+
const dateOrigine = new Date(2022, 0, 1);
|
|
27
|
+
const anneeOrigine = dateOrigine.getFullYear();
|
|
28
|
+
const numeroSemaineOrigine = getWeekNumber(dateOrigine);
|
|
29
|
+
// Calculer le nombre total de semaines écoulées depuis la date d'origine
|
|
30
|
+
let nombreSemaines = 0;
|
|
31
|
+
for (let i = anneeOrigine; i < annee; i++) {
|
|
32
|
+
nombreSemaines += moment().year(i).weeksInYear();
|
|
33
|
+
}
|
|
34
|
+
nombreSemaines += numeroSemaine - numeroSemaineOrigine;
|
|
35
|
+
return nombreSemaines;
|
|
36
|
+
}
|
|
37
|
+
const makeCalcul = (date) => calculerEcartSemaine(date);
|
|
38
|
+
describe("Ecartweek", () => {
|
|
39
|
+
test("current week to next week to be 7", () => {
|
|
40
|
+
const currentDay = Date.now();
|
|
41
|
+
const nextWeekDay = currentDay - 14 * 86400000;
|
|
42
|
+
// console.log(calculerEcartSemaine(new Date(nextWeekDay)));
|
|
43
|
+
const nextWeek = new Date(nextWeekDay);
|
|
44
|
+
expect(makeCalcul(nextWeek)).toBe(-14);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
|
|
3
|
+
function getWeekNumber(date: Date) {
|
|
4
|
+
date.setHours(0, 0, 0, 0);
|
|
5
|
+
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
|
|
6
|
+
const yearStart= new Date(date.getFullYear(), 0, 1).getTime();
|
|
7
|
+
const weekNumber = Math.ceil(((date.getTime() - yearStart) / 86400000 + 1) / 7);
|
|
8
|
+
return weekNumber;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function calculerEcartSemaine(dateSelectionnee: Date) {
|
|
12
|
+
// Récupérer la date actuelle
|
|
13
|
+
const dateActuelle = new Date();
|
|
14
|
+
|
|
15
|
+
// Extraire l'année et le numéro de la semaine de la date actuelle
|
|
16
|
+
const anneeActuelle = dateActuelle.getFullYear();
|
|
17
|
+
const numeroSemaineActuelle = getWeekNumber(dateActuelle);
|
|
18
|
+
|
|
19
|
+
// Extraire l'année et le numéro de la semaine de la date sélectionnée
|
|
20
|
+
|
|
21
|
+
const anneeSelectionnee = dateSelectionnee.getFullYear();
|
|
22
|
+
const numeroSemaineSelectionnee = getWeekNumber(dateSelectionnee);
|
|
23
|
+
|
|
24
|
+
// Calculer le nombre de semaines depuis une date d'origine arbitraire
|
|
25
|
+
|
|
26
|
+
// Calculer l'écart entre les semaines en utilisant la formule
|
|
27
|
+
const ecartSemaine =
|
|
28
|
+
semainesDepuisOrigine(anneeSelectionnee, numeroSemaineSelectionnee) -
|
|
29
|
+
semainesDepuisOrigine(anneeActuelle, numeroSemaineActuelle);
|
|
30
|
+
|
|
31
|
+
return ecartSemaine * 7;
|
|
32
|
+
}
|
|
33
|
+
function semainesDepuisOrigine(annee: number, numeroSemaine: number) {
|
|
34
|
+
// Choisir le 1er janvier 2022 comme date d'origine
|
|
35
|
+
const dateOrigine = new Date(2022, 0, 1);
|
|
36
|
+
const anneeOrigine = dateOrigine.getFullYear();
|
|
37
|
+
const numeroSemaineOrigine = getWeekNumber(dateOrigine);
|
|
38
|
+
|
|
39
|
+
// Calculer le nombre total de semaines écoulées depuis la date d'origine
|
|
40
|
+
let nombreSemaines = 0;
|
|
41
|
+
for (let i = anneeOrigine; i < annee; i++) {
|
|
42
|
+
nombreSemaines += moment().year(i).weeksInYear();
|
|
43
|
+
}
|
|
44
|
+
nombreSemaines += numeroSemaine - numeroSemaineOrigine;
|
|
45
|
+
|
|
46
|
+
return nombreSemaines;
|
|
47
|
+
}
|
|
48
|
+
const makeCalcul=(date:Date)=>calculerEcartSemaine(date)
|
|
49
|
+
describe("Ecartweek", () => {
|
|
50
|
+
test("current week to next week to be 7", () => {
|
|
51
|
+
const currentDay = Date.now();
|
|
52
|
+
const nextWeekDay = currentDay - 14 * 86400000;
|
|
53
|
+
// console.log(calculerEcartSemaine(new Date(nextWeekDay)));
|
|
54
|
+
const nextWeek = new Date(nextWeekDay);
|
|
55
|
+
expect(makeCalcul(nextWeek)).toBe(-14);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const CalendarContext = createContext({
|
|
4
|
+
groups: [],
|
|
5
|
+
weekOffset: 0,
|
|
6
|
+
date: new Date()
|
|
7
|
+
});
|
|
8
|
+
const CalendarContextProvider = ({ groups, weekOffset, children, date }) => {
|
|
9
|
+
return (_jsx(CalendarContext.Provider, { value: { groups, weekOffset, date }, children: children }));
|
|
10
|
+
};
|
|
11
|
+
export const useCalendarContext = () => useContext(CalendarContext);
|
|
12
|
+
export default CalendarContextProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { GroupPropsType } from "../definitions";
|
|
3
|
+
type CalendarContextProviderPropsType = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
groups: GroupPropsType[];
|
|
6
|
+
weekOffset: number;
|
|
7
|
+
date:Date
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type CalendarContextType = {
|
|
11
|
+
groups: GroupPropsType[];
|
|
12
|
+
weekOffset: number;
|
|
13
|
+
date:Date
|
|
14
|
+
};
|
|
15
|
+
const CalendarContext = createContext<CalendarContextType>({
|
|
16
|
+
groups: [],
|
|
17
|
+
weekOffset: 0,
|
|
18
|
+
date:new Date()
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const CalendarContextProvider = ({
|
|
22
|
+
groups,
|
|
23
|
+
weekOffset,
|
|
24
|
+
children,
|
|
25
|
+
date
|
|
26
|
+
}: CalendarContextProviderPropsType) => {
|
|
27
|
+
return (
|
|
28
|
+
<CalendarContext.Provider value={{ groups, weekOffset ,date}}>
|
|
29
|
+
{children}
|
|
30
|
+
</CalendarContext.Provider>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export const useCalendarContext = () => useContext(CalendarContext);
|
|
34
|
+
export default CalendarContextProvider;
|
package/definition.txt
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
definition
|
|
2
|
+
export type GroupPropsType = {
|
|
3
|
+
label?: string;
|
|
4
|
+
imageUrl?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
groupRender?: GroupRenderType;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties | undefined;
|
|
9
|
+
currentGroup: GroupFeildsType;
|
|
10
|
+
handleClickGroup?: (currentGroup: GroupFeildsType) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type GroupRiquiredFieldsType = {
|
|
14
|
+
label?: string;
|
|
15
|
+
imageUrl?: string;
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type GroupAdditionalFieldsType = Record<any, unknown>;
|
|
20
|
+
export type GroupFeildsType = GroupRiquiredFieldsType &
|
|
21
|
+
GroupAdditionalFieldsType;
|
|
22
|
+
|
|
23
|
+
export type GroupRenderType = ({
|
|
24
|
+
id,
|
|
25
|
+
label,
|
|
26
|
+
imageUrl,
|
|
27
|
+
currentGroup,
|
|
28
|
+
}: {
|
|
29
|
+
id?: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
imageUrl?: string;
|
|
32
|
+
currentGroup?: GroupFeildsType;
|
|
33
|
+
}) => React.ReactNode;
|
|
34
|
+
export type GroupComponentPropsType = {
|
|
35
|
+
groupRender?: GroupRenderType;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: React.CSSProperties | undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type TaskRenderType = ({
|
|
41
|
+
taskId,
|
|
42
|
+
taskStart,
|
|
43
|
+
taskEnd,
|
|
44
|
+
task,
|
|
45
|
+
taskDate,
|
|
46
|
+
groupId,
|
|
47
|
+
dayIndex,
|
|
48
|
+
handleDragTask,
|
|
49
|
+
}: {
|
|
50
|
+
taskStart: number;
|
|
51
|
+
taskEnd: number;
|
|
52
|
+
task: string;
|
|
53
|
+
taskDate: Date;
|
|
54
|
+
groupId: string;
|
|
55
|
+
dayIndex: number;
|
|
56
|
+
taskId: string;
|
|
57
|
+
currentTask?: TaskFeildsType;
|
|
58
|
+
handleDragTask?: (
|
|
59
|
+
event: React.DragEvent<HTMLDivElement>,
|
|
60
|
+
taskId: string,
|
|
61
|
+
taskStart: number,
|
|
62
|
+
taskEnd: number,
|
|
63
|
+
task: string,
|
|
64
|
+
taskDate: Date,
|
|
65
|
+
groupId: string,
|
|
66
|
+
dayIndex: number
|
|
67
|
+
) => void;
|
|
68
|
+
}) => React.ReactNode;
|
|
69
|
+
|
|
70
|
+
export type DayRenderType = ({
|
|
71
|
+
dayIndex,
|
|
72
|
+
day,
|
|
73
|
+
dayOfTheMonth,
|
|
74
|
+
dayMonth,
|
|
75
|
+
dayYear,
|
|
76
|
+
}: {
|
|
77
|
+
dayIndex?: number;
|
|
78
|
+
day?: string;
|
|
79
|
+
dayOfTheMonth?: number;
|
|
80
|
+
dayMonth?: string;
|
|
81
|
+
dayYear?: number;
|
|
82
|
+
}) => React.ReactNode;
|
|
83
|
+
|
|
84
|
+
export type DaysPropsType = {
|
|
85
|
+
dayRender: DayRenderType;
|
|
86
|
+
className?: string;
|
|
87
|
+
style?: React.CSSProperties | undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type DayPropsType = {
|
|
91
|
+
dayIndex?: number;
|
|
92
|
+
day?: string;
|
|
93
|
+
dayOfTheMonth?: number;
|
|
94
|
+
dayRender?: DayRenderType;
|
|
95
|
+
dayMonth?: string;
|
|
96
|
+
dayYear?: number;
|
|
97
|
+
className?: string;
|
|
98
|
+
style?: React.CSSProperties | undefined;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type AddTaskRenderType = ({
|
|
102
|
+
dayIndex,
|
|
103
|
+
groupId,
|
|
104
|
+
dayInfo,
|
|
105
|
+
}: {
|
|
106
|
+
dayIndex?: number;
|
|
107
|
+
groupId?: string;
|
|
108
|
+
dayInfo: dayInfoType;
|
|
109
|
+
}) => React.ReactNode;
|
|
110
|
+
|
|
111
|
+
export type CalendarPropsType = {
|
|
112
|
+
/**
|
|
113
|
+
* Props for the Calendar component.
|
|
114
|
+
*/
|
|
115
|
+
/** Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week). */
|
|
116
|
+
weekOffset: number;
|
|
117
|
+
/** Array of group data to be displayed in the calendar. [{id*:string,label:string,imageUrl:string,...the fields of your choice}] id field is required */
|
|
118
|
+
groups: GroupFeildsType[];
|
|
119
|
+
/** Additional class names for the calendar component. */
|
|
120
|
+
className?: string;
|
|
121
|
+
/** Additional styles for the calendar component. */
|
|
122
|
+
style?: React.CSSProperties | undefined;
|
|
123
|
+
/** The current date to display in the calendar. */
|
|
124
|
+
date: Date;
|
|
125
|
+
/** Custom render function for a group.
|
|
126
|
+
* const GroupRender=({
|
|
127
|
+
id,
|
|
128
|
+
label,
|
|
129
|
+
imageUrl,
|
|
130
|
+
currentGroup,
|
|
131
|
+
})=> {
|
|
132
|
+
your render
|
|
133
|
+
}
|
|
134
|
+
*/
|
|
135
|
+
groupRender?: GroupRenderType;
|
|
136
|
+
/** Custom render function for a day.
|
|
137
|
+
* const DayRender=(dayIndex,
|
|
138
|
+
day,
|
|
139
|
+
dayOfTheMonth,
|
|
140
|
+
dayMonth,
|
|
141
|
+
dayYear)=> {
|
|
142
|
+
your render
|
|
143
|
+
}
|
|
144
|
+
*/
|
|
145
|
+
dayRender?: DayRenderType;
|
|
146
|
+
/** Custom render function for a task.
|
|
147
|
+
* const TasKRender=({
|
|
148
|
+
taskId,
|
|
149
|
+
taskStart,
|
|
150
|
+
taskEnd,
|
|
151
|
+
task,
|
|
152
|
+
taskDate,
|
|
153
|
+
groupId,
|
|
154
|
+
dayIndex,
|
|
155
|
+
handleDragTask,
|
|
156
|
+
})=> {
|
|
157
|
+
your render
|
|
158
|
+
}
|
|
159
|
+
*/
|
|
160
|
+
taskRender?: TaskRenderType;
|
|
161
|
+
/** Additional styles for the rows. */
|
|
162
|
+
rowsStyle?: React.CSSProperties | undefined;
|
|
163
|
+
/** Additional class names for the rows. */
|
|
164
|
+
rowsClassName?: string;
|
|
165
|
+
/** Additional styles for the group columns. */
|
|
166
|
+
groupsColsStyle?: React.CSSProperties | undefined;
|
|
167
|
+
/** Additional class names for the group columns. */
|
|
168
|
+
groupsColsClassName?: string;
|
|
169
|
+
/** Additional styles for the day columns. */
|
|
170
|
+
daysColsStyle?: React.CSSProperties | undefined;
|
|
171
|
+
daysColsClassName?: string;
|
|
172
|
+
addTaskClassName?: string;
|
|
173
|
+
addTaskStyle?: React.CSSProperties | undefined;
|
|
174
|
+
/** Additional class names for the groups. */
|
|
175
|
+
groupClassName?: string;
|
|
176
|
+
groupStyle?: React.CSSProperties | undefined;
|
|
177
|
+
dayClassName?: string;
|
|
178
|
+
dayStyle?: React.CSSProperties | undefined;
|
|
179
|
+
taskContainerStyle?: React.CSSProperties | undefined;
|
|
180
|
+
taskContainerClassName?: string;
|
|
181
|
+
groupHeadContainerStyle?: React.CSSProperties | undefined;
|
|
182
|
+
groupHeadContainerClassName?: string;
|
|
183
|
+
sumHoursContainerStyle?: React.CSSProperties | undefined;
|
|
184
|
+
sumHoursContainerClassName?: string;
|
|
185
|
+
sumHoursHeadStyle?: React.CSSProperties | undefined;
|
|
186
|
+
sumHoursHeadClassName?: string;
|
|
187
|
+
|
|
188
|
+
handleAddTask?: (
|
|
189
|
+
dayIndex: number,
|
|
190
|
+
groupId: string,
|
|
191
|
+
dayInfo: dayInfoType
|
|
192
|
+
) => void;
|
|
193
|
+
addTaskRender?: AddTaskRenderType;
|
|
194
|
+
tasks?: TasksType;
|
|
195
|
+
handleDragTask?: (
|
|
196
|
+
event: React.DragEvent<HTMLDivElement>,
|
|
197
|
+
taskId: string,
|
|
198
|
+
taskStart: number,
|
|
199
|
+
taskEnd: number,
|
|
200
|
+
task: string,
|
|
201
|
+
taskDate: Date,
|
|
202
|
+
groupId: string,
|
|
203
|
+
dayIndex: number
|
|
204
|
+
) => void;
|
|
205
|
+
handleDropTask?: (
|
|
206
|
+
event: React.DragEvent<HTMLTableDataCellElement>,
|
|
207
|
+
taskStart: number,
|
|
208
|
+
taskEnd: number,
|
|
209
|
+
taskDate: Date,
|
|
210
|
+
groupId: string,
|
|
211
|
+
dayIndex: number,
|
|
212
|
+
newTask: TaskFeildsType,
|
|
213
|
+
newTasts: TasksType
|
|
214
|
+
) => void;
|
|
215
|
+
handleDragTaskEnd?: handleDragTaskEndType;
|
|
216
|
+
groupsHeadRender?: GroupsHeadRenderType;
|
|
217
|
+
sumHoursRender?: SumHoursRenderType;
|
|
218
|
+
sumHoursHeadRender?: SumHoursHeadRenderType;
|
|
219
|
+
handleClickTask?: (currentTask: TaskFeildsType) => void;
|
|
220
|
+
handleClickGroup?: (currentGroup: GroupFeildsType) => void;
|
|
221
|
+
};
|
|
222
|
+
export type StyleType = React.CSSProperties | undefined;
|
|
223
|
+
export type AddTaskPropsType = {
|
|
224
|
+
dayIndex: number;
|
|
225
|
+
groupId: string;
|
|
226
|
+
addTaskStyle?: StyleType;
|
|
227
|
+
addTaskClassName?: string;
|
|
228
|
+
addTaskRender?: AddTaskRenderType;
|
|
229
|
+
dayInfo: dayInfoType;
|
|
230
|
+
handleAddTask?: (
|
|
231
|
+
dayIndex: number,
|
|
232
|
+
groupId: string,
|
|
233
|
+
dayInfo: dayInfoType
|
|
234
|
+
) => void;
|
|
235
|
+
};
|
|
236
|
+
export type dayInfoType = {
|
|
237
|
+
positionDay: number;
|
|
238
|
+
day: Date;
|
|
239
|
+
start: number;
|
|
240
|
+
end: number;
|
|
241
|
+
};
|
|
242
|
+
export type TaskType = {
|
|
243
|
+
taskStart: number;
|
|
244
|
+
taskEnd: number;
|
|
245
|
+
task: string;
|
|
246
|
+
taskDate: Date;
|
|
247
|
+
groupId: string;
|
|
248
|
+
dayIndex: number;
|
|
249
|
+
taskId: string;
|
|
250
|
+
};
|
|
251
|
+
export type TaskContainerPropsType = {
|
|
252
|
+
taskStart: number;
|
|
253
|
+
taskEnd: number;
|
|
254
|
+
task: string;
|
|
255
|
+
taskDate: Date;
|
|
256
|
+
groupId: string;
|
|
257
|
+
dayIndex: number;
|
|
258
|
+
taskId: string;
|
|
259
|
+
className?: string;
|
|
260
|
+
style?: React.CSSProperties | undefined;
|
|
261
|
+
handleDragTask?: (
|
|
262
|
+
event: React.DragEvent<HTMLDivElement>,
|
|
263
|
+
taskId: string,
|
|
264
|
+
taskStart: number,
|
|
265
|
+
taskEnd: number,
|
|
266
|
+
task: string,
|
|
267
|
+
taskDate: Date,
|
|
268
|
+
groupId: string,
|
|
269
|
+
dayIndex: number
|
|
270
|
+
) => void;
|
|
271
|
+
taskRender?: TaskRenderType;
|
|
272
|
+
handleDragTaskEnd?: handleDragTaskEndType;
|
|
273
|
+
currentTask: TaskFeildsType;
|
|
274
|
+
handleClickTask?: (currentTask: TaskFeildsType) => void;
|
|
275
|
+
};
|
|
276
|
+
type GroupsHeadRenderType = () => React.ReactNode;
|
|
277
|
+
export type GroupsHeadContainerPropsType = {
|
|
278
|
+
groupsHeadRender?: GroupsHeadRenderType;
|
|
279
|
+
style?: React.CSSProperties | undefined;
|
|
280
|
+
className?: string;
|
|
281
|
+
};
|
|
282
|
+
type SumHoursHeadRenderType = () => React.ReactNode;
|
|
283
|
+
export type SumHoursHeadContainerPropsType = {
|
|
284
|
+
sumHoursHeadRender?: SumHoursHeadRenderType;
|
|
285
|
+
style?: React.CSSProperties | undefined;
|
|
286
|
+
className?: string;
|
|
287
|
+
};
|
|
288
|
+
type TaskAdditionalFieldsType = Record<any, unknown>;
|
|
289
|
+
export type TaskFeildsType = TaskType & TaskAdditionalFieldsType;
|
|
290
|
+
|
|
291
|
+
export type TasksType = TaskFeildsType[];
|
|
292
|
+
export type handleDragTaskEndType = (
|
|
293
|
+
event: React.DragEvent<HTMLDivElement>
|
|
294
|
+
) => void;
|
|
295
|
+
export type SumHoursRenderType = ({
|
|
296
|
+
groupId,
|
|
297
|
+
tasks,
|
|
298
|
+
weekOffset,
|
|
299
|
+
calendarDate,
|
|
300
|
+
sumHoursByGroups,
|
|
301
|
+
}: {
|
|
302
|
+
groupId: string;
|
|
303
|
+
tasks: TasksType | any;
|
|
304
|
+
weekOffset: number;
|
|
305
|
+
calendarDate: Date;
|
|
306
|
+
sumHoursByGroups: number;
|
|
307
|
+
}) => React.ReactNode;
|
|
308
|
+
|
|
309
|
+
export type SumHoursContainerPropsType = {
|
|
310
|
+
groupId: string;
|
|
311
|
+
tasks: TasksType | any;
|
|
312
|
+
weekOffset: number;
|
|
313
|
+
calendarDate: Date;
|
|
314
|
+
sumHoursByGroups: number;
|
|
315
|
+
sumHoursRender?: SumHoursRenderType;
|
|
316
|
+
style?: React.CSSProperties | undefined;
|
|
317
|
+
className?: string;
|
|
318
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|