react-weekly-planning 1.0.30 → 1.0.32
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 +90 -0
- package/__tests__/page.test.js +92 -92
- package/components/AddTask/index.js +17 -17
- package/components/CalendarForWeek.js +49 -50
- package/components/CalendarForWeek.tsx +7 -3
- package/components/CalendarForday.js +33 -34
- package/components/CalendarForday.tsx +3 -2
- package/components/DayContainer/index.js +15 -15
- package/components/GroupContainer/index.js +15 -15
- package/components/GroupsHeadContainer/index.js +9 -9
- package/components/SumHoursContainer/index.js +16 -15
- package/components/SumHoursContainer/index.tsx +2 -1
- package/components/SumHoursHead/index.js +9 -9
- package/components/TaskContainer/index.js +35 -35
- package/components/TaskList/index.js +4 -5
- package/components/TaskList/index.tsx +6 -13
- package/contexts/CalendarContext.js +12 -12
- package/definitions/index.js +1 -1
- package/definitions/index.ts +1 -0
- package/hooks/useCalendarDateState.js +19 -19
- package/hooks/useCalendarDateState.ts +5 -4
- package/index.js +70 -70
- package/index.tsx +1 -1
- package/jest.config.js +9 -9
- package/lib/slyles.js +21 -21
- package/lib/utils.js +636 -605
- package/lib/utils.ts +107 -64
- package/package.json +28 -31
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
import { groupContainerStyle } from "../../lib/slyles";
|
|
4
|
-
const GroupContainer = ({ className, style, groupRender, currentGroup, handleClickGroup, }) => {
|
|
5
|
-
if (groupRender) {
|
|
6
|
-
return _jsx(_Fragment, { children: groupRender({ currentGroup }) });
|
|
7
|
-
}
|
|
8
|
-
const handleClick = () => {
|
|
9
|
-
if (!handleClickGroup)
|
|
10
|
-
return;
|
|
11
|
-
handleClickGroup(currentGroup);
|
|
12
|
-
};
|
|
13
|
-
return (_jsxs("div", { onClick: handleClick, className: `${className}`, style: Object.assign(Object.assign({}, groupContainerStyle), style), children: [currentGroup.imageUrl && (_jsx("img", { width: 30, height: 30, src: currentGroup.imageUrl, alt: "groupimg" })), _jsx("label", { children: currentGroup.label && currentGroup.label })] }));
|
|
14
|
-
};
|
|
15
|
-
export default memo(GroupContainer);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { groupContainerStyle } from "../../lib/slyles";
|
|
4
|
+
const GroupContainer = ({ className, style, groupRender, currentGroup, handleClickGroup, }) => {
|
|
5
|
+
if (groupRender) {
|
|
6
|
+
return _jsx(_Fragment, { children: groupRender({ currentGroup }) });
|
|
7
|
+
}
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
if (!handleClickGroup)
|
|
10
|
+
return;
|
|
11
|
+
handleClickGroup(currentGroup);
|
|
12
|
+
};
|
|
13
|
+
return (_jsxs("div", { onClick: handleClick, className: `${className}`, style: Object.assign(Object.assign({}, groupContainerStyle), style), children: [currentGroup.imageUrl && (_jsx("img", { width: 30, height: 30, src: currentGroup.imageUrl, alt: "groupimg" })), _jsx("label", { children: currentGroup.label && currentGroup.label })] }));
|
|
14
|
+
};
|
|
15
|
+
export default memo(GroupContainer);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
const GroupsHeadContainer = ({ groupsHeadRender, style, className, }) => {
|
|
4
|
-
if (groupsHeadRender) {
|
|
5
|
-
return _jsx(_Fragment, { children: groupsHeadRender() });
|
|
6
|
-
}
|
|
7
|
-
return (_jsx("div", { className: `${className}`, style: style, children: "WeeklyCalendar" }));
|
|
8
|
-
};
|
|
9
|
-
export default memo(GroupsHeadContainer);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const GroupsHeadContainer = ({ groupsHeadRender, style, className, }) => {
|
|
4
|
+
if (groupsHeadRender) {
|
|
5
|
+
return _jsx(_Fragment, { children: groupsHeadRender() });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { className: `${className}`, style: style, children: "WeeklyCalendar" }));
|
|
8
|
+
};
|
|
9
|
+
export default memo(GroupsHeadContainer);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { totalLabel } from "../../lib/utils";
|
|
4
|
+
const SumHoursContainer = ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, sumHoursRender, className, style, }) => {
|
|
5
|
+
if (sumHoursRender) {
|
|
6
|
+
return (_jsx(_Fragment, { children: sumHoursRender({
|
|
7
|
+
groupId,
|
|
8
|
+
tasks,
|
|
9
|
+
weekOffset,
|
|
10
|
+
calendarDate,
|
|
11
|
+
sumHoursByGroups,
|
|
12
|
+
}) }));
|
|
13
|
+
}
|
|
14
|
+
return (_jsx("div", { style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), className: `${className}`, children: totalLabel(sumHoursByGroups) }));
|
|
15
|
+
};
|
|
16
|
+
export default memo(SumHoursContainer);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memo } from "react";
|
|
2
2
|
import { SumHoursContainerPropsType } from "../../definitions";
|
|
3
|
+
import { millisecondsToHours, totalLabel } from "../../lib/utils";
|
|
3
4
|
|
|
4
5
|
const SumHoursContainer = ({
|
|
5
6
|
groupId,
|
|
@@ -30,7 +31,7 @@ const SumHoursContainer = ({
|
|
|
30
31
|
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
31
32
|
className={`${className}`}
|
|
32
33
|
>
|
|
33
|
-
{sumHoursByGroups}
|
|
34
|
+
{totalLabel(sumHoursByGroups)}
|
|
34
35
|
</div>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
|
|
4
|
-
if (sumHoursHeadRender) {
|
|
5
|
-
return _jsx(_Fragment, { children: sumHoursHeadRender() });
|
|
6
|
-
}
|
|
7
|
-
return (_jsx("div", { className: `${className}`, style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), children: "Hours" }));
|
|
8
|
-
};
|
|
9
|
-
export default memo(SumHoursHead);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
|
|
4
|
+
if (sumHoursHeadRender) {
|
|
5
|
+
return _jsx(_Fragment, { children: sumHoursHeadRender() });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { className: `${className}`, style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), children: "Hours" }));
|
|
8
|
+
};
|
|
9
|
+
export default memo(SumHoursHead);
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
import { millisecondsToDate } from "../../lib/utils";
|
|
4
|
-
const TaskContainer = ({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }) => {
|
|
5
|
-
const handleDragStart = (event) => {
|
|
6
|
-
if (!handleDragTask)
|
|
7
|
-
return;
|
|
8
|
-
event.dataTransfer.effectAllowed = "move";
|
|
9
|
-
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
10
|
-
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
11
|
-
window.sessionStorage.setItem("calendardragtaskStart", `${currentTask.taskStart}`);
|
|
12
|
-
window.sessionStorage.setItem("calendardragtaskEnd", `${currentTask.taskEnd}`);
|
|
13
|
-
window.sessionStorage.setItem("calendardragdayIndex", `${currentTask.dayIndex}`);
|
|
14
|
-
handleDragTask(event, currentTask);
|
|
15
|
-
};
|
|
16
|
-
const handleDragEnd = (event) => {
|
|
17
|
-
if (!handleDragTaskEnd)
|
|
18
|
-
return;
|
|
19
|
-
handleDragTaskEnd(event);
|
|
20
|
-
};
|
|
21
|
-
const handleClick = () => {
|
|
22
|
-
if (!handleClickTask)
|
|
23
|
-
return;
|
|
24
|
-
handleClickTask(currentTask);
|
|
25
|
-
};
|
|
26
|
-
if (taskRender) {
|
|
27
|
-
return (_jsx("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: taskRender({
|
|
28
|
-
currentTask,
|
|
29
|
-
}) }));
|
|
30
|
-
}
|
|
31
|
-
return (_jsxs("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: [_jsx("p", { className: "tasklabel", children: currentTask.task && currentTask.task }), _jsx("p", { className: "taskhour", children: currentTask.taskStart &&
|
|
32
|
-
currentTask.taskEnd &&
|
|
33
|
-
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${millisecondsToDate(currentTask.taskEnd).formattedDate}` })] }));
|
|
34
|
-
};
|
|
35
|
-
export default memo(TaskContainer);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { millisecondsToDate } from "../../lib/utils";
|
|
4
|
+
const TaskContainer = ({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }) => {
|
|
5
|
+
const handleDragStart = (event) => {
|
|
6
|
+
if (!handleDragTask)
|
|
7
|
+
return;
|
|
8
|
+
event.dataTransfer.effectAllowed = "move";
|
|
9
|
+
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
10
|
+
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
11
|
+
window.sessionStorage.setItem("calendardragtaskStart", `${currentTask.taskStart}`);
|
|
12
|
+
window.sessionStorage.setItem("calendardragtaskEnd", `${currentTask.taskEnd}`);
|
|
13
|
+
window.sessionStorage.setItem("calendardragdayIndex", `${currentTask.dayIndex}`);
|
|
14
|
+
handleDragTask(event, currentTask);
|
|
15
|
+
};
|
|
16
|
+
const handleDragEnd = (event) => {
|
|
17
|
+
if (!handleDragTaskEnd)
|
|
18
|
+
return;
|
|
19
|
+
handleDragTaskEnd(event);
|
|
20
|
+
};
|
|
21
|
+
const handleClick = () => {
|
|
22
|
+
if (!handleClickTask)
|
|
23
|
+
return;
|
|
24
|
+
handleClickTask(currentTask);
|
|
25
|
+
};
|
|
26
|
+
if (taskRender) {
|
|
27
|
+
return (_jsx("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: taskRender({
|
|
28
|
+
currentTask,
|
|
29
|
+
}) }));
|
|
30
|
+
}
|
|
31
|
+
return (_jsxs("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: [_jsx("p", { className: "tasklabel", children: currentTask.task && currentTask.task }), _jsx("p", { className: "taskhour", children: currentTask.taskStart &&
|
|
32
|
+
currentTask.taskEnd &&
|
|
33
|
+
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${millisecondsToDate(currentTask.taskEnd).formattedDate}` })] }));
|
|
34
|
+
};
|
|
35
|
+
export default memo(TaskContainer);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default TaskList;
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import TaskContainer from "../TaskContainer";
|
|
3
|
+
const TaskList = ({ tasks }) => (_jsx("div", { style: { height: 300, width: "100%" }, children: _jsx("div", { style: { display: "flex", flexDirection: "column" }, children: tasks.map(task => _jsx(TaskContainer, { currentTask: task }, task.id)) }) }));
|
|
4
|
+
export default TaskList;
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import TaskContainer from "../TaskContainer";
|
|
3
3
|
import { TaskFeildsType } from "../../definitions";
|
|
4
4
|
|
|
5
5
|
const TaskList = ({ tasks }: { tasks: TaskFeildsType[] }) => (
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
>
|
|
12
|
-
{({ index, style }) => (
|
|
13
|
-
<div style={style}>
|
|
14
|
-
<TaskContainer key={tasks[index].id} currentTask={tasks[index]} />
|
|
15
|
-
</div>
|
|
16
|
-
)}
|
|
17
|
-
</List>
|
|
6
|
+
<div style={{ height: 300, width: "100%" }}>
|
|
7
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
|
8
|
+
{tasks.map(task => <TaskContainer key={task.id} currentTask={task} />)}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
18
11
|
);
|
|
19
12
|
|
|
20
13
|
export default TaskList;
|
|
@@ -1,12 +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;
|
|
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;
|
package/definitions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/definitions/index.ts
CHANGED
|
@@ -119,6 +119,7 @@ export type DayPropsType = {
|
|
|
119
119
|
* Props for the Calendar component.
|
|
120
120
|
*/
|
|
121
121
|
export type CalendarPropsType = {
|
|
122
|
+
scope?: "day" | "week";
|
|
122
123
|
/** Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week). */
|
|
123
124
|
weekOffset?: number;
|
|
124
125
|
/** Array of group data to be displayed in the calendar. */
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { calculerEcartSemaine, getDateObjectInTimeZone, getDayHourly, getWeekDays, } from "../lib/utils";
|
|
3
|
-
function useCalendarDateState(date, weekOffset, timeZone) {
|
|
4
|
-
const [calendarDateState, setCalendarDateState] = useState({ dailyHours: [], weekDays: [] });
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const weekOffsetByDate = timeZone
|
|
7
|
-
? calculerEcartSemaine(getDateObjectInTimeZone(timeZone))
|
|
8
|
-
: calculerEcartSemaine(date);
|
|
9
|
-
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
10
|
-
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
11
|
-
const calData = {
|
|
12
|
-
dailyHours: dailyHours,
|
|
13
|
-
weekDays,
|
|
14
|
-
};
|
|
15
|
-
setCalendarDateState(calData);
|
|
16
|
-
}, [date, weekOffset]);
|
|
17
|
-
return Object.assign({}, calendarDateState);
|
|
18
|
-
}
|
|
19
|
-
export default useCalendarDateState;
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { calculerEcartSemaine, getDateObjectInTimeZone, getDayHourly, getWeekDays, } from "../lib/utils";
|
|
3
|
+
function useCalendarDateState(date, weekOffset, timeZone) {
|
|
4
|
+
const [calendarDateState, setCalendarDateState] = useState({ dailyHours: [], weekDays: [] });
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const weekOffsetByDate = timeZone
|
|
7
|
+
? calculerEcartSemaine(getDateObjectInTimeZone(timeZone), timeZone)
|
|
8
|
+
: calculerEcartSemaine(date, timeZone);
|
|
9
|
+
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0, timeZone);
|
|
10
|
+
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0, timeZone);
|
|
11
|
+
const calData = {
|
|
12
|
+
dailyHours: dailyHours,
|
|
13
|
+
weekDays,
|
|
14
|
+
};
|
|
15
|
+
setCalendarDateState(calData);
|
|
16
|
+
}, [date, weekOffset]);
|
|
17
|
+
return Object.assign({}, calendarDateState);
|
|
18
|
+
}
|
|
19
|
+
export default useCalendarDateState;
|
|
@@ -25,17 +25,18 @@ function useCalendarDateState(
|
|
|
25
25
|
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
const weekOffsetByDate = timeZone
|
|
28
|
-
? calculerEcartSemaine(getDateObjectInTimeZone(timeZone))
|
|
29
|
-
: calculerEcartSemaine(date);
|
|
28
|
+
? calculerEcartSemaine(getDateObjectInTimeZone(timeZone), timeZone)
|
|
29
|
+
: calculerEcartSemaine(date, timeZone);
|
|
30
30
|
|
|
31
|
-
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
32
|
-
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
31
|
+
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0, timeZone);
|
|
32
|
+
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0, timeZone);
|
|
33
33
|
const calData = {
|
|
34
34
|
dailyHours: dailyHours,
|
|
35
35
|
weekDays,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
setCalendarDateState(calData);
|
|
39
|
+
|
|
39
40
|
}, [date, weekOffset]);
|
|
40
41
|
|
|
41
42
|
return { ...calendarDateState };
|
package/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import "./style.css";
|
|
3
|
-
import CalendarForWeek from "./components/CalendarForWeek";
|
|
4
|
-
import CalendarForDay from "./components/CalendarForday";
|
|
5
|
-
/**
|
|
6
|
-
* Calendar component to display tasks and groups in a weekly view.
|
|
7
|
-
*
|
|
8
|
-
* @param {CalendarPropsType} props - The props for the Calendar component.
|
|
9
|
-
* @param {number} [props.weekOffset] - Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week).
|
|
10
|
-
* @param {GroupFeildsType[]} props.groups - Array of group data to be displayed in the calendar.
|
|
11
|
-
* @param {string} [props.className] - Additional class names for the calendar component.
|
|
12
|
-
* @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
|
|
13
|
-
* @param {Date} props.date - The current date to display in the calendar.
|
|
14
|
-
* @param {(currentGroup: { currentGroup: GroupFeildsType }) => React.ReactNode} [props.groupRender] - Custom render function for a group.
|
|
15
|
-
* @param {({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear }: { dayIndex: number; day: string; dayOfTheMonth: number; dayMonth: string; dayYear: number }) => React.ReactNode} [props.dayRender] - Custom render function for a day.
|
|
16
|
-
* @param {(currentTask: { currentTask: TaskFeildsType }) => React.ReactNode} [props.taskRender] - Custom render function for a task.
|
|
17
|
-
* @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
|
|
18
|
-
* @param {string} [props.rowsClassName] - Additional class names for the rows.
|
|
19
|
-
* @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
|
|
20
|
-
* @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
|
|
21
|
-
* @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
|
|
22
|
-
* @param {string} [props.daysColsClassName] - Additional class names for the day columns.
|
|
23
|
-
* @param {string} [props.addTaskClassName] - Additional class names for the add-task button.
|
|
24
|
-
* @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add-task button.
|
|
25
|
-
* @param {string} [props.groupContainerClassName] - Additional class names for the group containers.
|
|
26
|
-
* @param {React.CSSProperties} [props.groupContainerStyle] - Additional styles for the group containers.
|
|
27
|
-
* @param {string} [props.dayClassName] - Additional class names for the day elements.
|
|
28
|
-
* @param {React.CSSProperties} [props.dayStyle] - Additional styles for the day elements.
|
|
29
|
-
* @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
|
|
30
|
-
* @param {string} [props.taskContainerClassName] - Additional class names for the task container.
|
|
31
|
-
* @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group header container.
|
|
32
|
-
* @param {string} [props.groupHeadContainerClassName] - Additional class names for the group header container.
|
|
33
|
-
* @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum-of-hours container.
|
|
34
|
-
* @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum-of-hours container.
|
|
35
|
-
* @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum-of-hours header.
|
|
36
|
-
* @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum-of-hours header.
|
|
37
|
-
* @param {(currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void} [props.handleAddTask] - Handler function for adding a new task.
|
|
38
|
-
* @param {({ currentGroup, dayInfo }: { currentGroup: GroupFeildsType; dayInfo: dayInfoType }) => React.ReactNode} [props.addTaskRender] - Custom render function for adding a task.
|
|
39
|
-
* @param {TasksType} props.tasks - Array of tasks to be displayed in the calendar.
|
|
40
|
-
* @param {(event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void} [props.handleDragTask] - Handler function for dragging a task.
|
|
41
|
-
* @param {(event: React.DragEvent<HTMLDivElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void} [props.handleDropTask] - Handler function for dropping a task.
|
|
42
|
-
* @param {(event: React.DragEvent<HTMLDivElement>) => void} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
|
|
43
|
-
* @param {() => React.ReactNode} [props.groupsHeadRender] - Custom render function for the groups header.
|
|
44
|
-
* @param {({
|
|
45
|
-
* groupId,
|
|
46
|
-
* tasks,
|
|
47
|
-
* weekOffset,
|
|
48
|
-
* calendarDate,
|
|
49
|
-
* sumHoursByGroups
|
|
50
|
-
* }: {
|
|
51
|
-
* groupId: string;
|
|
52
|
-
* tasks: TasksType;
|
|
53
|
-
* weekOffset: number;
|
|
54
|
-
* calendarDate: Date;
|
|
55
|
-
* sumHoursByGroups: number;
|
|
56
|
-
* }) => React.ReactNode} [props.sumHoursRender] - Custom render function for the sum of hours.
|
|
57
|
-
* @param {() => React.ReactNode} [props.sumHoursHeadRender] - Custom render function for the sum-of-hours header.
|
|
58
|
-
* @param {(currentTask: TaskFeildsType) => void} [props.handleClickTask] - Handler function for clicking a task.
|
|
59
|
-
* @param {(currentGroup: GroupFeildsType) => void} [props.handleClickGroup] - Handler function for clicking a group.
|
|
60
|
-
* @param {0|1|2|3|4|5|6} [props.dayOffset] - Offset index for the day column (0 = first day of week, …, 6 = last day).
|
|
61
|
-
* @param {React.CSSProperties} [props.dayColsStyle] - Additional styles for the day columns.
|
|
62
|
-
* @param {string} [props.dayColsClassName] - Additional class names for the day columns.
|
|
63
|
-
* @param {React.CSSProperties} [props.hoursColsStyle] - Additional styles for the hours columns.
|
|
64
|
-
* @param {string} [props.hoursColsClassName] - Additional class names for the hours columns.
|
|
65
|
-
*/
|
|
66
|
-
const Calendar = (props) => {
|
|
67
|
-
return (_jsx(_Fragment, { children: _jsx(CalendarForWeek, Object.assign({}, props)) }));
|
|
68
|
-
};
|
|
69
|
-
export default Calendar;
|
|
70
|
-
export { CalendarForDay };
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import "./style.css";
|
|
3
|
+
import CalendarForWeek from "./components/CalendarForWeek";
|
|
4
|
+
import CalendarForDay from "./components/CalendarForday";
|
|
5
|
+
/**
|
|
6
|
+
* Calendar component to display tasks and groups in a weekly view.
|
|
7
|
+
*
|
|
8
|
+
* @param {CalendarPropsType} props - The props for the Calendar component.
|
|
9
|
+
* @param {number} [props.weekOffset] - Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week).
|
|
10
|
+
* @param {GroupFeildsType[]} props.groups - Array of group data to be displayed in the calendar.
|
|
11
|
+
* @param {string} [props.className] - Additional class names for the calendar component.
|
|
12
|
+
* @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
|
|
13
|
+
* @param {Date} props.date - The current date to display in the calendar.
|
|
14
|
+
* @param {(currentGroup: { currentGroup: GroupFeildsType }) => React.ReactNode} [props.groupRender] - Custom render function for a group.
|
|
15
|
+
* @param {({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear }: { dayIndex: number; day: string; dayOfTheMonth: number; dayMonth: string; dayYear: number }) => React.ReactNode} [props.dayRender] - Custom render function for a day.
|
|
16
|
+
* @param {(currentTask: { currentTask: TaskFeildsType }) => React.ReactNode} [props.taskRender] - Custom render function for a task.
|
|
17
|
+
* @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
|
|
18
|
+
* @param {string} [props.rowsClassName] - Additional class names for the rows.
|
|
19
|
+
* @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
|
|
20
|
+
* @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
|
|
21
|
+
* @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
|
|
22
|
+
* @param {string} [props.daysColsClassName] - Additional class names for the day columns.
|
|
23
|
+
* @param {string} [props.addTaskClassName] - Additional class names for the add-task button.
|
|
24
|
+
* @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add-task button.
|
|
25
|
+
* @param {string} [props.groupContainerClassName] - Additional class names for the group containers.
|
|
26
|
+
* @param {React.CSSProperties} [props.groupContainerStyle] - Additional styles for the group containers.
|
|
27
|
+
* @param {string} [props.dayClassName] - Additional class names for the day elements.
|
|
28
|
+
* @param {React.CSSProperties} [props.dayStyle] - Additional styles for the day elements.
|
|
29
|
+
* @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
|
|
30
|
+
* @param {string} [props.taskContainerClassName] - Additional class names for the task container.
|
|
31
|
+
* @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group header container.
|
|
32
|
+
* @param {string} [props.groupHeadContainerClassName] - Additional class names for the group header container.
|
|
33
|
+
* @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum-of-hours container.
|
|
34
|
+
* @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum-of-hours container.
|
|
35
|
+
* @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum-of-hours header.
|
|
36
|
+
* @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum-of-hours header.
|
|
37
|
+
* @param {(currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void} [props.handleAddTask] - Handler function for adding a new task.
|
|
38
|
+
* @param {({ currentGroup, dayInfo }: { currentGroup: GroupFeildsType; dayInfo: dayInfoType }) => React.ReactNode} [props.addTaskRender] - Custom render function for adding a task.
|
|
39
|
+
* @param {TasksType} props.tasks - Array of tasks to be displayed in the calendar.
|
|
40
|
+
* @param {(event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void} [props.handleDragTask] - Handler function for dragging a task.
|
|
41
|
+
* @param {(event: React.DragEvent<HTMLDivElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void} [props.handleDropTask] - Handler function for dropping a task.
|
|
42
|
+
* @param {(event: React.DragEvent<HTMLDivElement>) => void} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
|
|
43
|
+
* @param {() => React.ReactNode} [props.groupsHeadRender] - Custom render function for the groups header.
|
|
44
|
+
* @param {({
|
|
45
|
+
* groupId,
|
|
46
|
+
* tasks,
|
|
47
|
+
* weekOffset,
|
|
48
|
+
* calendarDate,
|
|
49
|
+
* sumHoursByGroups
|
|
50
|
+
* }: {
|
|
51
|
+
* groupId: string;
|
|
52
|
+
* tasks: TasksType;
|
|
53
|
+
* weekOffset: number;
|
|
54
|
+
* calendarDate: Date;
|
|
55
|
+
* sumHoursByGroups: number;
|
|
56
|
+
* }) => React.ReactNode} [props.sumHoursRender] - Custom render function for the sum of hours.
|
|
57
|
+
* @param {() => React.ReactNode} [props.sumHoursHeadRender] - Custom render function for the sum-of-hours header.
|
|
58
|
+
* @param {(currentTask: TaskFeildsType) => void} [props.handleClickTask] - Handler function for clicking a task.
|
|
59
|
+
* @param {(currentGroup: GroupFeildsType) => void} [props.handleClickGroup] - Handler function for clicking a group.
|
|
60
|
+
* @param {0|1|2|3|4|5|6} [props.dayOffset] - Offset index for the day column (0 = first day of week, …, 6 = last day).
|
|
61
|
+
* @param {React.CSSProperties} [props.dayColsStyle] - Additional styles for the day columns.
|
|
62
|
+
* @param {string} [props.dayColsClassName] - Additional class names for the day columns.
|
|
63
|
+
* @param {React.CSSProperties} [props.hoursColsStyle] - Additional styles for the hours columns.
|
|
64
|
+
* @param {string} [props.hoursColsClassName] - Additional class names for the hours columns.
|
|
65
|
+
*/
|
|
66
|
+
const Calendar = (props) => {
|
|
67
|
+
return (_jsx(_Fragment, { children: props.scope === "day" ? _jsx(CalendarForDay, Object.assign({}, props)) : _jsx(CalendarForWeek, Object.assign({}, props)) }));
|
|
68
|
+
};
|
|
69
|
+
export default Calendar;
|
|
70
|
+
export { CalendarForDay };
|
package/index.tsx
CHANGED
|
@@ -67,7 +67,7 @@ import CalendarForDay from "./components/CalendarForday";
|
|
|
67
67
|
const Calendar = (props: CalendarPropsType) => {
|
|
68
68
|
return (
|
|
69
69
|
<>
|
|
70
|
-
<CalendarForWeek {...props} />
|
|
70
|
+
{props.scope === "day" ? <CalendarForDay {...props} /> : <CalendarForWeek {...props} />}
|
|
71
71
|
</>
|
|
72
72
|
);
|
|
73
73
|
};
|
package/jest.config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Sync object
|
|
2
|
-
const config = {
|
|
3
|
-
verbose: true,
|
|
4
|
-
transform: {
|
|
5
|
-
'.+\\.tsx?$': 'ts-jest',
|
|
6
|
-
'^.+\\.(js|jsx)$': 'babel-jest',
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
export default config;
|
|
1
|
+
// Sync object
|
|
2
|
+
const config = {
|
|
3
|
+
verbose: true,
|
|
4
|
+
transform: {
|
|
5
|
+
'.+\\.tsx?$': 'ts-jest',
|
|
6
|
+
'^.+\\.(js|jsx)$': 'babel-jest',
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export default config;
|
package/lib/slyles.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export const theadTrStyle = {
|
|
2
|
-
color: "#0f5173",
|
|
3
|
-
fontWeight: "300",
|
|
4
|
-
position: "sticky",
|
|
5
|
-
top: -1,
|
|
6
|
-
};
|
|
7
|
-
export const groupTdStyle = {
|
|
8
|
-
height: "auto",
|
|
9
|
-
width: "150px",
|
|
10
|
-
};
|
|
11
|
-
export const groupContainerStyle = {
|
|
12
|
-
width: "100%",
|
|
13
|
-
height: "100%",
|
|
14
|
-
display: "flex",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
justifyContent: "space-between",
|
|
17
|
-
gap: "0.75rem", // Correspond à gap-3
|
|
18
|
-
padding: "0.75rem", // Correspond à p-3
|
|
19
|
-
color: "#0f5173",
|
|
20
|
-
cursor: "pointer",
|
|
21
|
-
};
|
|
1
|
+
export const theadTrStyle = {
|
|
2
|
+
color: "#0f5173",
|
|
3
|
+
fontWeight: "300",
|
|
4
|
+
position: "sticky",
|
|
5
|
+
top: -1,
|
|
6
|
+
};
|
|
7
|
+
export const groupTdStyle = {
|
|
8
|
+
height: "auto",
|
|
9
|
+
width: "150px",
|
|
10
|
+
};
|
|
11
|
+
export const groupContainerStyle = {
|
|
12
|
+
width: "100%",
|
|
13
|
+
height: "100%",
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "space-between",
|
|
17
|
+
gap: "0.75rem", // Correspond à gap-3
|
|
18
|
+
padding: "0.75rem", // Correspond à p-3
|
|
19
|
+
color: "#0f5173",
|
|
20
|
+
cursor: "pointer",
|
|
21
|
+
};
|