react-weekly-planning 1.0.37 → 1.0.39

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.
Files changed (37) hide show
  1. package/README.md +219 -98
  2. package/package.json +49 -1
  3. package/dist/components/AddTask/index.js +0 -17
  4. package/dist/components/CalendarForWeek.js +0 -49
  5. package/dist/components/CalendarForday.js +0 -33
  6. package/dist/components/DayContainer/index.js +0 -15
  7. package/dist/components/GroupContainer/index.js +0 -15
  8. package/dist/components/GroupsHeadContainer/index.js +0 -9
  9. package/dist/components/SumHoursContainer/index.js +0 -16
  10. package/dist/components/SumHoursHead/index.js +0 -9
  11. package/dist/components/TaskContainer/index.js +0 -35
  12. package/dist/components/TaskList/index.js +0 -4
  13. package/dist/components/index.js +0 -69
  14. package/dist/components/style.css +0 -123
  15. package/dist/contexts/CalendarContext.js +0 -12
  16. package/dist/definitions/index.js +0 -1
  17. package/dist/hooks/useCalendarDateState.js +0 -19
  18. package/dist/index.js +0 -7
  19. package/dist/lib/slyles.js +0 -21
  20. package/dist/lib/utils.js +0 -650
  21. package/dist/types/components/AddTask/index.d.ts +0 -3
  22. package/dist/types/components/CalendarForWeek.d.ts +0 -4
  23. package/dist/types/components/CalendarForday.d.ts +0 -5
  24. package/dist/types/components/DayContainer/index.d.ts +0 -3
  25. package/dist/types/components/GroupContainer/index.d.ts +0 -3
  26. package/dist/types/components/GroupsHeadContainer/index.d.ts +0 -3
  27. package/dist/types/components/SumHoursContainer/index.d.ts +0 -3
  28. package/dist/types/components/SumHoursHead/index.d.ts +0 -3
  29. package/dist/types/components/TaskContainer/index.d.ts +0 -3
  30. package/dist/types/components/TaskList/index.d.ts +0 -5
  31. package/dist/types/components/index.d.ts +0 -65
  32. package/dist/types/contexts/CalendarContext.d.ts +0 -15
  33. package/dist/types/definitions/index.d.ts +0 -395
  34. package/dist/types/hooks/useCalendarDateState.d.ts +0 -6
  35. package/dist/types/index.d.ts +0 -3
  36. package/dist/types/lib/slyles.d.ts +0 -4
  37. package/dist/types/lib/utils.d.ts +0 -86
@@ -1,35 +0,0 @@
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,4 +0,0 @@
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,69 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import "./style.css";
3
- import CalendarForWeek from "./CalendarForWeek";
4
- import CalendarForDay from "./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;
@@ -1,123 +0,0 @@
1
- .addPlanStyle {
2
- cursor: pointer;
3
- display: flex;
4
- align-items: center;
5
- justify-content: center;
6
- flex: 1;
7
- background-color: #f2f8fb;
8
- opacity: 0;
9
- border-radius: 5px;
10
- color: #0f5173;
11
- transition: background-color 0.3s, opacity 0.3s;
12
- }
13
-
14
- .addPlanStyle:hover {
15
- background-color: #c6dbe159;
16
- opacity: 1;
17
- }
18
- .taskContainer {
19
- box-shadow: 0px 7px 18px 0px rgba(15, 105, 115, 0.03),
20
- 0px 6px 10px 0px rgba(15, 105, 115, 0.04),
21
- 0px 3px 5px 0px rgba(15, 105, 115, 0.05);
22
- display: flex;
23
- justify-content: center;
24
- column-gap: 10px;
25
- flex-direction: column;
26
- height: auto;
27
- border-left: 5px solid #457993;
28
- background-color: #f4ffff;
29
- color: #457993;
30
- cursor: pointer;
31
- border-radius: 5px;
32
- margin-bottom: 5px;
33
- font-size: 13px;
34
- overflow: auto;
35
- padding: 2px;
36
- z-index: 10;
37
- }
38
-
39
- .tasklabel {
40
- color: #55585d;
41
- font-size: 12px;
42
- line-height: 16px;
43
- font-weight: 400;
44
- margin-left: 5px;
45
- }
46
-
47
- .taskhour {
48
- font-size: 12px;
49
- line-height: 16px;
50
- font-weight: 600;
51
- margin-left: 5px;
52
- }
53
-
54
- .planningCalendar {
55
- width: 100%;
56
- height: 150px;
57
- border-radius: 0.5rem;
58
- z-index: 10;
59
- }
60
-
61
- .planningCalendar .dayTh {
62
- color: #0f5173;
63
- padding-left: 5px;
64
- }
65
- .planningCalendar .totalTh {
66
- color: #0f5173;
67
- width: 40px;
68
- text-align: right;
69
- padding-right: 2px;
70
- }
71
-
72
- .planningCalendar td {
73
- -moz-box-sizing: border-box;
74
- border-left: 0.74px solid rgba(198, 219, 225, 0.68);
75
- border-right: 0.74px solid rgba(198, 219, 225, 0.68);
76
- width: 8vw;
77
- }
78
- .planningCalendar tr {
79
- border-bottom: 1.5px solid #0f52737e;
80
- padding: 2px;
81
- }
82
- .planningCalendar tr:nth-child(1){
83
- z-index: 200;
84
- }
85
-
86
- .CalendarTableForDay {
87
- display: flex;
88
- gap: 10px;
89
- width: 100vw;
90
- height: auto;
91
- }
92
-
93
- .CalendarTableForDayTasksContainer {
94
- flex: 1;
95
- display: flex;
96
- flex-direction: column;
97
- height: auto;
98
- padding: 10px;
99
- position: relative;
100
- }
101
-
102
- .CalendarTableForDayRow {
103
- display: flex !important;
104
- flex-direction: row !important;
105
- gap: 15px;
106
- align-items: flex-start;
107
- padding: 15px !important;
108
- }
109
-
110
- .CalendarTableForDayGroupTasks {
111
- flex: 1;
112
- display: grid;
113
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
114
- gap: 10px;
115
- }
116
-
117
- .CalendarTableForDayGroupTasks .taskContainer,
118
- .CalendarTableForDayGroupTasks .addPlanStyle {
119
- margin-bottom: 0px;
120
- height: 100%;
121
- min-height: 80px;
122
- }
123
-
@@ -1,12 +0,0 @@
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 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
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;
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- // src/index.ts
2
- // 1. Tu exportes ton composant principal
3
- export { default as Calendar } from './components/index';
4
- // 2. Tu exportes tout le contenu de ton fichier utils
5
- export * from './lib/utils';
6
- export * from './definitions/index';
7
- // OU exportes des éléments spécifiques : export { formatTime, generateSlots } from './utils';
@@ -1,21 +0,0 @@
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
- };