react-weekly-planning 1.0.34 → 1.0.36

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 (58) hide show
  1. package/README.md +4 -4
  2. package/{components → dist/components}/CalendarForday.js +1 -1
  3. package/{index.js → dist/components/index.js} +2 -3
  4. package/dist/index.js +7 -0
  5. package/dist/types/components/AddTask/index.d.ts +3 -0
  6. package/dist/types/components/CalendarForWeek.d.ts +4 -0
  7. package/dist/types/components/CalendarForday.d.ts +5 -0
  8. package/dist/types/components/DayContainer/index.d.ts +3 -0
  9. package/dist/types/components/GroupContainer/index.d.ts +3 -0
  10. package/dist/types/components/GroupsHeadContainer/index.d.ts +3 -0
  11. package/dist/types/components/SumHoursContainer/index.d.ts +3 -0
  12. package/dist/types/components/SumHoursHead/index.d.ts +3 -0
  13. package/dist/types/components/TaskContainer/index.d.ts +3 -0
  14. package/dist/types/components/TaskList/index.d.ts +5 -0
  15. package/{index.tsx → dist/types/components/index.d.ts} +65 -77
  16. package/dist/types/contexts/CalendarContext.d.ts +15 -0
  17. package/dist/types/definitions/index.d.ts +395 -0
  18. package/dist/types/hooks/useCalendarDateState.d.ts +6 -0
  19. package/dist/types/index.d.ts +3 -0
  20. package/dist/types/lib/slyles.d.ts +4 -0
  21. package/dist/types/lib/utils.d.ts +80 -0
  22. package/package.json +20 -2
  23. package/assets/planning-screenshot.png +0 -0
  24. package/assets/planning-screenshot.webp +0 -0
  25. package/babel.config.js +0 -1
  26. package/components/AddTask/index.tsx +0 -43
  27. package/components/CalendarForWeek.tsx +0 -233
  28. package/components/CalendarForday.tsx +0 -131
  29. package/components/DayContainer/index.tsx +0 -36
  30. package/components/GroupContainer/index.tsx +0 -42
  31. package/components/GroupsHeadContainer/index.tsx +0 -19
  32. package/components/SumHoursContainer/index.tsx +0 -39
  33. package/components/SumHoursHead/index.tsx +0 -22
  34. package/components/TaskContainer/index.tsx +0 -86
  35. package/components/TaskList/index.tsx +0 -13
  36. package/contexts/CalendarContext.tsx +0 -38
  37. package/definitions/index.ts +0 -1084
  38. package/hooks/useCalendarDateState.ts +0 -45
  39. package/jest.config.js +0 -9
  40. package/jest.config.ts +0 -10
  41. package/jsdoc.json +0 -26
  42. package/lib/slyles.ts +0 -25
  43. package/lib/utils.ts +0 -976
  44. /package/{components → dist/components}/AddTask/index.js +0 -0
  45. /package/{components → dist/components}/CalendarForWeek.js +0 -0
  46. /package/{components → dist/components}/DayContainer/index.js +0 -0
  47. /package/{components → dist/components}/GroupContainer/index.js +0 -0
  48. /package/{components → dist/components}/GroupsHeadContainer/index.js +0 -0
  49. /package/{components → dist/components}/SumHoursContainer/index.js +0 -0
  50. /package/{components → dist/components}/SumHoursHead/index.js +0 -0
  51. /package/{components → dist/components}/TaskContainer/index.js +0 -0
  52. /package/{components → dist/components}/TaskList/index.js +0 -0
  53. /package/{style.css → dist/components/style.css} +0 -0
  54. /package/{contexts → dist/contexts}/CalendarContext.js +0 -0
  55. /package/{definitions → dist/definitions}/index.js +0 -0
  56. /package/{hooks → dist/hooks}/useCalendarDateState.js +0 -0
  57. /package/{lib → dist/lib}/slyles.js +0 -0
  58. /package/{lib → dist/lib}/utils.js +0 -0
package/README.md CHANGED
@@ -118,7 +118,7 @@ It is possible to use either Weekoffset or Date, or even both simultaneously.
118
118
 
119
119
  **Example**:
120
120
  ```jsx
121
- import {getSavedTasks} from "react-weekly-planning/lib/utils";
121
+ import {getSavedTasks} from "react-weekly-planning";
122
122
  const [tasks,setTasks]=useState([])
123
123
 
124
124
  useEffect(()=>{
@@ -137,7 +137,7 @@ Here is a complete, minimal example showing how to set up the `Calendar` with si
137
137
  ```tsx
138
138
  import React, { useState } from "react";
139
139
  import Calendar from "react-pweekly-planning"; // Verify your exact import path based on package.json
140
- import "react-pweekly-planning/dist/style.css"; // Ensure CSS is imported depending on your setup
140
+
141
141
 
142
142
  const App = () => {
143
143
  const [date] = useState(new Date());
@@ -263,7 +263,7 @@ Props for the Calendar component.
263
263
 
264
264
  **Example**:
265
265
  ```javascript
266
- import {updateOffsetWithDateCalendar} from "react-weekly-planning/lib/utils";
266
+ import {updateOffsetWithDateCalendar} from "react-weekly-planning";
267
267
  const offset = updateOffsetWithDateCalendar(new Date());
268
268
  console.log(offset); // Logs the week offset for the given date
269
269
  ```
@@ -277,7 +277,7 @@ Props for the Calendar component.
277
277
 
278
278
  **Example**:
279
279
  ```javascript
280
- import {millisecondsToHours} from "react-weekly-planning/lib/utils";
280
+ import {millisecondsToHours} from "react-weekly-planning";
281
281
  const formattedTime = millisecondsToHours(1716905215397);
282
282
  console.log(formattedTime); // Logs the formatted time for 14h06
283
283
  ```
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import "../style.css";
2
+ import "./style.css";
3
3
  import { memo, useEffect } from "react";
4
4
  import { compareWeekOffset, saveTasksToLocalStorage } from "../lib/utils";
5
5
  import useCalendarDateState from "../hooks/useCalendarDateState";
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import "./style.css";
3
- import CalendarForWeek from "./components/CalendarForWeek";
4
- import CalendarForDay from "./components/CalendarForday";
3
+ import CalendarForWeek from "./CalendarForWeek";
4
+ import CalendarForDay from "./CalendarForday";
5
5
  /**
6
6
  * Calendar component to display tasks and groups in a weekly view.
7
7
  *
@@ -67,4 +67,3 @@ const Calendar = (props) => {
67
67
  return (_jsx(_Fragment, { children: props.scope === "day" ? _jsx(CalendarForDay, Object.assign({}, props)) : _jsx(CalendarForWeek, Object.assign({}, props)) }));
68
68
  };
69
69
  export default Calendar;
70
- export { CalendarForDay };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,3 @@
1
+ import { AddTaskPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ currentGroup, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }: AddTaskPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { CalendarTablePropsType } from "../definitions";
2
+ declare function CalendarForWeek(props: CalendarTablePropsType): import("react/jsx-runtime").JSX.Element;
3
+ declare const _default: import("react").MemoExoticComponent<typeof CalendarForWeek>;
4
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import "./style.css";
2
+ import { CalendarTablePropsType } from "../definitions";
3
+ declare function CalendarForDay(props: CalendarTablePropsType): import("react/jsx-runtime").JSX.Element;
4
+ declare const _default: import("react").MemoExoticComponent<typeof CalendarForDay>;
5
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { DayPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ dayIndex, dayOfTheMonth, day, dayMonth, dayYear, dayRender, className, style, }: DayPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { GroupPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ className, style, groupRender, currentGroup, handleClickGroup, }: GroupPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { GroupsHeadContainerPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ groupsHeadRender, style, className, }: GroupsHeadContainerPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { SumHoursContainerPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, sumHoursRender, className, style, }: SumHoursContainerPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { SumHoursHeadContainerPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ sumHoursHeadRender, className, style, }: SumHoursHeadContainerPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { TaskContainerPropsType } from "../../definitions";
2
+ declare const _default: import("react").MemoExoticComponent<({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }: TaskContainerPropsType) => import("react/jsx-runtime").JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { TaskFeildsType } from "../../definitions";
2
+ declare const TaskList: ({ tasks }: {
3
+ tasks: TaskFeildsType[];
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default TaskList;
@@ -1,77 +1,65 @@
1
- import "./style.css";
2
- import { CalendarPropsType } from "./definitions";
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
-
67
- const Calendar = (props: CalendarPropsType) => {
68
- return (
69
- <>
70
- {props.scope === "day" ? <CalendarForDay {...props} /> : <CalendarForWeek {...props} />}
71
- </>
72
- );
73
- };
74
-
75
- export default Calendar;
76
-
77
- export { CalendarForDay };
1
+ import "./style.css";
2
+ import { CalendarPropsType } from "../definitions";
3
+ /**
4
+ * Calendar component to display tasks and groups in a weekly view.
5
+ *
6
+ * @param {CalendarPropsType} props - The props for the Calendar component.
7
+ * @param {number} [props.weekOffset] - Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week).
8
+ * @param {GroupFeildsType[]} props.groups - Array of group data to be displayed in the calendar.
9
+ * @param {string} [props.className] - Additional class names for the calendar component.
10
+ * @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
11
+ * @param {Date} props.date - The current date to display in the calendar.
12
+ * @param {(currentGroup: { currentGroup: GroupFeildsType }) => React.ReactNode} [props.groupRender] - Custom render function for a group.
13
+ * @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.
14
+ * @param {(currentTask: { currentTask: TaskFeildsType }) => React.ReactNode} [props.taskRender] - Custom render function for a task.
15
+ * @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
16
+ * @param {string} [props.rowsClassName] - Additional class names for the rows.
17
+ * @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
18
+ * @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
19
+ * @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
20
+ * @param {string} [props.daysColsClassName] - Additional class names for the day columns.
21
+ * @param {string} [props.addTaskClassName] - Additional class names for the add-task button.
22
+ * @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add-task button.
23
+ * @param {string} [props.groupContainerClassName] - Additional class names for the group containers.
24
+ * @param {React.CSSProperties} [props.groupContainerStyle] - Additional styles for the group containers.
25
+ * @param {string} [props.dayClassName] - Additional class names for the day elements.
26
+ * @param {React.CSSProperties} [props.dayStyle] - Additional styles for the day elements.
27
+ * @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
28
+ * @param {string} [props.taskContainerClassName] - Additional class names for the task container.
29
+ * @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group header container.
30
+ * @param {string} [props.groupHeadContainerClassName] - Additional class names for the group header container.
31
+ * @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum-of-hours container.
32
+ * @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum-of-hours container.
33
+ * @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum-of-hours header.
34
+ * @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum-of-hours header.
35
+ * @param {(currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void} [props.handleAddTask] - Handler function for adding a new task.
36
+ * @param {({ currentGroup, dayInfo }: { currentGroup: GroupFeildsType; dayInfo: dayInfoType }) => React.ReactNode} [props.addTaskRender] - Custom render function for adding a task.
37
+ * @param {TasksType} props.tasks - Array of tasks to be displayed in the calendar.
38
+ * @param {(event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void} [props.handleDragTask] - Handler function for dragging a task.
39
+ * @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.
40
+ * @param {(event: React.DragEvent<HTMLDivElement>) => void} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
41
+ * @param {() => React.ReactNode} [props.groupsHeadRender] - Custom render function for the groups header.
42
+ * @param {({
43
+ * groupId,
44
+ * tasks,
45
+ * weekOffset,
46
+ * calendarDate,
47
+ * sumHoursByGroups
48
+ * }: {
49
+ * groupId: string;
50
+ * tasks: TasksType;
51
+ * weekOffset: number;
52
+ * calendarDate: Date;
53
+ * sumHoursByGroups: number;
54
+ * }) => React.ReactNode} [props.sumHoursRender] - Custom render function for the sum of hours.
55
+ * @param {() => React.ReactNode} [props.sumHoursHeadRender] - Custom render function for the sum-of-hours header.
56
+ * @param {(currentTask: TaskFeildsType) => void} [props.handleClickTask] - Handler function for clicking a task.
57
+ * @param {(currentGroup: GroupFeildsType) => void} [props.handleClickGroup] - Handler function for clicking a group.
58
+ * @param {0|1|2|3|4|5|6} [props.dayOffset] - Offset index for the day column (0 = first day of week, …, 6 = last day).
59
+ * @param {React.CSSProperties} [props.dayColsStyle] - Additional styles for the day columns.
60
+ * @param {string} [props.dayColsClassName] - Additional class names for the day columns.
61
+ * @param {React.CSSProperties} [props.hoursColsStyle] - Additional styles for the hours columns.
62
+ * @param {string} [props.hoursColsClassName] - Additional class names for the hours columns.
63
+ */
64
+ declare const Calendar: (props: CalendarPropsType) => import("react/jsx-runtime").JSX.Element;
65
+ export default Calendar;
@@ -0,0 +1,15 @@
1
+ import { GroupPropsType } from "../definitions";
2
+ type CalendarContextProviderPropsType = {
3
+ children: React.ReactNode;
4
+ groups: GroupPropsType[];
5
+ weekOffset: number;
6
+ date: Date;
7
+ };
8
+ type CalendarContextType = {
9
+ groups: GroupPropsType[];
10
+ weekOffset: number;
11
+ date: Date;
12
+ };
13
+ declare const CalendarContextProvider: ({ groups, weekOffset, children, date }: CalendarContextProviderPropsType) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const useCalendarContext: () => CalendarContextType;
15
+ export default CalendarContextProvider;