react-weekly-planning 1.0.35 → 1.0.37

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 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());
@@ -239,6 +239,20 @@ Props for the Calendar component.
239
239
 
240
240
  ## Additional Functions
241
241
 
242
+ ### `getCalendarDate`
243
+
244
+ - **Description**: Returns the current date according to the selected timezone or the local time.
245
+ - **Parameters**:
246
+ - `timeZone` (TimeZone, optional): The timezone to use for the date calculation.
247
+ - **Returns**: A `Date` object representing the current time in the specified timezone (or local time if omitted).
248
+
249
+ **Example**:
250
+ ```javascript
251
+ import { getCalendarDate } from "react-weekly-planning";
252
+ const now = getCalendarDate("Europe/Paris");
253
+ console.log(now); // Logs the current date in Paris
254
+ ```
255
+
242
256
  ### `updateCalendarDateWithOffset`
243
257
 
244
258
  - **Description**: Updates the calendar date based on the week offset.
@@ -263,7 +277,7 @@ Props for the Calendar component.
263
277
 
264
278
  **Example**:
265
279
  ```javascript
266
- import {updateOffsetWithDateCalendar} from "react-weekly-planning/lib/utils";
280
+ import {updateOffsetWithDateCalendar} from "react-weekly-planning";
267
281
  const offset = updateOffsetWithDateCalendar(new Date());
268
282
  console.log(offset); // Logs the week offset for the given date
269
283
  ```
@@ -277,7 +291,7 @@ Props for the Calendar component.
277
291
 
278
292
  **Example**:
279
293
  ```javascript
280
- import {millisecondsToHours} from "react-weekly-planning/lib/utils";
294
+ import {millisecondsToHours} from "react-weekly-planning";
281
295
  const formattedTime = millisecondsToHours(1716905215397);
282
296
  console.log(formattedTime); // Logs the formatted time for 14h06
283
297
  ```
@@ -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,70 +1,69 @@
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 };
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;
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';
package/dist/lib/utils.js CHANGED
@@ -30,7 +30,7 @@ export const endDateMilliseconds = endDate.getTime();
30
30
  export function getDayHourly(weekOffset, timeZone) {
31
31
  const dailyHours = [];
32
32
  let dayOffset = weekOffset;
33
- const resolvedCurrentDate = timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
33
+ const resolvedCurrentDate = getCalendarDate(timeZone);
34
34
  const currentDayOfWeek = resolvedCurrentDate.getDay();
35
35
  const resolvedStartDate = new Date(resolvedCurrentDate);
36
36
  resolvedStartDate.setDate(resolvedStartDate.getDate() - currentDayOfWeek);
@@ -116,11 +116,11 @@ export function getWeekDays(jump, timeZone) {
116
116
  "Nov",
117
117
  "Dec",
118
118
  ];
119
- const currentDate = timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
119
+ const currentDate = getCalendarDate(timeZone);
120
120
  const currentDayOfWeek = currentDate.getDay();
121
121
  let weekDays = [];
122
122
  for (let i = 0; i < 7; i++) {
123
- const day = timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
123
+ const day = getCalendarDate(timeZone);
124
124
  const diff = i - currentDayOfWeek;
125
125
  if (currentDayOfWeek === 0) {
126
126
  day.setDate(currentDate.getDate() + diff + jump - 7);
@@ -171,11 +171,19 @@ function updateSelectedDateForEcartSemaine(dateSelectionnee) {
171
171
  * @returns The week difference in days.
172
172
  */
173
173
  export function calculerEcartSemaine(dateSelectionnee, timeZone) {
174
- const dateActuelle = timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
175
- const recupDate = new Date(dateSelectionnee);
176
- recupDate.setUTCDate(recupDate.getUTCDate() + 4 - (recupDate.getUTCDay() || 7));
177
- dateActuelle.setUTCDate(dateActuelle.getUTCDate() + 4 - (dateActuelle.getUTCDay() || 7));
178
- return Math.ceil((recupDate.getTime() - dateActuelle.getTime()) / 86400000);
174
+ const dateActuelle = getCalendarDate(timeZone);
175
+ // 1. Retrieve only the year, month, and day, and force it to midnight UTC.
176
+ // This eliminates any risk related to time zones and daylight saving time.
177
+ const utcSelected = Date.UTC(dateSelectionnee.getFullYear(), dateSelectionnee.getMonth(), dateSelectionnee.getDate());
178
+ const utcActuelle = Date.UTC(dateActuelle.getFullYear(), dateActuelle.getMonth(), dateActuelle.getDate());
179
+ const MS_PAR_JOUR = 86400000;
180
+ // 2. Resize each date to the Sunday of its corresponding week.
181
+ // getDay() returns a number from 0 (Sunday) to 6 (Saturday).
182
+ // By subtracting (day * ms_per_day), we arrive at Sunday at midnight.
183
+ const dimancheSelected = utcSelected - (dateSelectionnee.getDay() * MS_PAR_JOUR);
184
+ const dimancheActuelle = utcActuelle - (dateActuelle.getDay() * MS_PAR_JOUR);
185
+ const ecartJours = Math.round((dimancheSelected - dimancheActuelle) / MS_PAR_JOUR);
186
+ return ecartJours; // Retournera 0, 7, -7, 14, -14...
179
187
  }
180
188
  /**
181
189
  * Calculate the number of weeks since an arbitrary origin date (January 1, 2022).
@@ -216,10 +224,12 @@ export function compareWeekOffset(calendarDate, weekOffset, taskDate, timeZone)
216
224
  // if (taskDate.getDay() === 0 && calculerEcartSemaine(taskDate) === -7) {
217
225
  // return true;
218
226
  // }
227
+ const currentDate = getCalendarDate(timeZone);
228
+ const currentWeekOffset = calculerEcartSemaine(currentDate, timeZone);
219
229
  const localTaskDate = getArbitraryDateInTimeZone(taskDate, timeZone);
220
230
  // if (calendarDate)
221
231
  // return (calculerEcartSemaine(calendarDate) === calculerEcartSemaine(taskDate));
222
- const ecartTask = calculerEcartSemaine(taskDate, timeZone) + (localTaskDate.getDay() === 0 ? 7 : 0);
232
+ const ecartTask = calculerEcartSemaine(taskDate, timeZone);
223
233
  return weekOffset === ecartTask;
224
234
  }
225
235
  export const sumHoursByGroups = (groupId, tasks, weekOffset, calendarDate, timeZone) => {
@@ -353,6 +363,14 @@ export function getDateObjectInTimeZone(timeZone) {
353
363
  return new Date();
354
364
  }
355
365
  }
366
+ /**
367
+ * Returns the current date according to the selected timezone or the local time.
368
+ * @param timeZone - The optional timezone.
369
+ * @returns The current date.
370
+ */
371
+ export function getCalendarDate(timeZone) {
372
+ return timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
373
+ }
356
374
  export function getArbitraryDateInTimeZone(date, timeZone) {
357
375
  if (!timeZone)
358
376
  return date;
@@ -437,7 +455,7 @@ export function getHoursByGroup(tasks, groupId, weekOffset, timeZone) {
437
455
  return sum;
438
456
  }
439
457
  export function getTaskProgression(task, timeZone) {
440
- const now = timeZone ? getDateObjectInTimeZone(timeZone) : new Date();
458
+ const now = getCalendarDate(timeZone);
441
459
  if (task.taskStart >= now.getTime())
442
460
  return 0;
443
461
  if (now.getTime() >= task.taskEnd)
@@ -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;
@@ -0,0 +1,65 @@
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;
@@ -0,0 +1,395 @@
1
+ /**
2
+ * Props for the Group component.
3
+ */
4
+ export type GroupPropsType = {
5
+ /** Custom render function for the group. */
6
+ groupRender?: ({ currentGroup, }: {
7
+ currentGroup: GroupFeildsType;
8
+ }) => React.ReactNode;
9
+ /** Additional class names for the group component. */
10
+ className?: string;
11
+ /** Additional styles for the group component. */
12
+ style?: React.CSSProperties | undefined;
13
+ /** The current group data. */
14
+ currentGroup: GroupFeildsType;
15
+ /** Handler function for clicking the group. */
16
+ handleClickGroup?: (currentGroup: GroupFeildsType) => void;
17
+ };
18
+ /**
19
+ * Required fields for a group.
20
+ */
21
+ type GroupRiquiredFieldsType = {
22
+ /** Label for the group. */
23
+ label?: string;
24
+ /** URL of the image representing the group. */
25
+ imageUrl?: string;
26
+ /** Unique identifier for the group. */
27
+ id: string;
28
+ };
29
+ /**
30
+ * Additional fields for a group.
31
+ */
32
+ type GroupAdditionalFieldsType = Record<any, any>;
33
+ /**
34
+ * Fields for a group, including both required and additional fields.
35
+ */
36
+ export type GroupFeildsType = GroupRiquiredFieldsType & GroupAdditionalFieldsType;
37
+ /**
38
+ * Props for the GroupComponent.
39
+ */
40
+ export type GroupComponentPropsType = {
41
+ /** Custom render function for the group. */
42
+ groupRender?: ({ currentGroup, }: {
43
+ currentGroup: GroupFeildsType;
44
+ }) => React.ReactNode;
45
+ /** Additional class names for the group component. */
46
+ className?: string;
47
+ /** Additional styles for the group component. */
48
+ style?: React.CSSProperties | undefined;
49
+ };
50
+ /**
51
+ * Props for the Days component.
52
+ */
53
+ export type DaysPropsType = {
54
+ /** Custom render function for a day. */
55
+ dayRender?: ({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear, }: {
56
+ dayIndex?: number;
57
+ day?: string;
58
+ dayOfTheMonth?: number;
59
+ dayMonth?: string;
60
+ dayYear?: number;
61
+ }) => React.ReactNode;
62
+ /** Additional class names for the days component. */
63
+ className?: string;
64
+ /** Additional styles for the days component. */
65
+ style?: React.CSSProperties | undefined;
66
+ };
67
+ /**
68
+ * Props for a single day.
69
+ */
70
+ export type DayPropsType = {
71
+ /** Index of the day. */
72
+ dayIndex: number;
73
+ /** Name of the day. */
74
+ day: string;
75
+ /** Day of the month. */
76
+ dayOfTheMonth: number;
77
+ /** Custom render function for a day. */
78
+ dayRender?: ({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear, }: {
79
+ dayIndex: number;
80
+ day: string;
81
+ dayOfTheMonth: number;
82
+ dayMonth: string;
83
+ dayYear: number;
84
+ }) => React.ReactNode;
85
+ /** Month of the day. */
86
+ dayMonth: string;
87
+ /** Year of the day. */
88
+ dayYear: number;
89
+ /** Additional class names for the day component. */
90
+ className?: string;
91
+ /** Additional styles for the day component. */
92
+ style?: React.CSSProperties | undefined;
93
+ };
94
+ /**
95
+ * Props for the Calendar component.
96
+ */
97
+ export type CalendarPropsType = {
98
+ scope?: "day" | "week";
99
+ /** Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week). */
100
+ weekOffset?: number;
101
+ /** Array of group data to be displayed in the calendar. */
102
+ groups: GroupFeildsType[];
103
+ /** Additional class names for the calendar component. */
104
+ className?: string;
105
+ /** Additional styles for the calendar component. */
106
+ style?: React.CSSProperties | undefined;
107
+ /** The current date to display in the calendar. */
108
+ date: Date;
109
+ /** Custom render function for a group. */
110
+ groupRender?: ({ currentGroup, }: {
111
+ currentGroup: GroupFeildsType;
112
+ }) => React.ReactNode;
113
+ /** Custom render function for a day. */
114
+ dayRender?: ({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear, }: {
115
+ dayIndex: number;
116
+ day: string;
117
+ dayOfTheMonth: number;
118
+ dayMonth: string;
119
+ dayYear: number;
120
+ }) => React.ReactNode;
121
+ /** Custom render function for a task. */
122
+ taskRender?: ({ currentTask, }: {
123
+ currentTask: TaskFeildsType;
124
+ }) => React.ReactNode;
125
+ /** Additional styles for the rows. */
126
+ rowsStyle?: React.CSSProperties | undefined;
127
+ /** Additional class names for the rows. */
128
+ rowsClassName?: string;
129
+ /** Additional styles for the group columns. */
130
+ groupsColsStyle?: React.CSSProperties | undefined;
131
+ /** Additional class names for the group columns. */
132
+ groupsColsClassName?: string;
133
+ /** Additional styles for the day columns. */
134
+ daysColsStyle?: React.CSSProperties | undefined;
135
+ /** Additional class names for the day columns. */
136
+ daysColsClassName?: string;
137
+ /** Additional class names for the add task button. */
138
+ addTaskClassName?: string;
139
+ /** Additional styles for the add task button. */
140
+ addTaskStyle?: React.CSSProperties | undefined;
141
+ /** Additional class names for the groups. */
142
+ groupContainerClassName?: string;
143
+ /** Additional styles for the groups. */
144
+ groupContainerStyle?: React.CSSProperties | undefined;
145
+ /** Additional class names for the days. */
146
+ dayClassName?: string;
147
+ /** Additional styles for the days. */
148
+ dayStyle?: React.CSSProperties | undefined;
149
+ /** Additional styles for the task container. */
150
+ taskContainerStyle?: React.CSSProperties | undefined;
151
+ /** Additional class names for the task container. */
152
+ taskContainerClassName?: string;
153
+ /** Additional styles for the group head container. */
154
+ groupHeadContainerStyle?: React.CSSProperties | undefined;
155
+ /** Additional class names for the group head container. */
156
+ groupHeadContainerClassName?: string;
157
+ /** Additional styles for the sum hours container. */
158
+ sumHoursContainerStyle?: React.CSSProperties | undefined;
159
+ /** Additional class names for the sum hours container. */
160
+ sumHoursContainerClassName?: string;
161
+ /** Additional styles for the sum hours header. */
162
+ sumHoursHeadStyle?: React.CSSProperties | undefined;
163
+ /** Additional class names for the sum hours header. */
164
+ sumHoursHeadClassName?: string;
165
+ /** Handler function for adding a new task. */
166
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
167
+ /** Custom render function for adding a task. */
168
+ addTaskRender?: ({ currentGroup, dayInfo, }: {
169
+ currentGroup: GroupFeildsType;
170
+ dayInfo: dayInfoType;
171
+ }) => React.ReactNode;
172
+ /** Array of tasks to be displayed in the calendar. */
173
+ tasks: TasksType;
174
+ /** Handler function for dragging a task. */
175
+ handleDragTask?: (event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void;
176
+ /** Handler function for dropping a task. */
177
+ handleDropTask?: (event: React.DragEvent<HTMLDivElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void;
178
+ /** Handler function for ending the drag of a task. */
179
+ handleDragTaskEnd?: (event: React.DragEvent<HTMLDivElement>) => void;
180
+ /** Custom render function for the groups header. */
181
+ groupsHeadRender?: () => React.ReactNode;
182
+ /** Custom render function for the sum of hours. */
183
+ sumHoursRender?: ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, }: {
184
+ groupId: string;
185
+ tasks: TasksType;
186
+ weekOffset: number;
187
+ calendarDate: Date;
188
+ sumHoursByGroups: number;
189
+ }) => React.ReactNode;
190
+ /** Custom render function for the sum of hours header. */
191
+ sumHoursHeadRender?: () => React.ReactNode;
192
+ /** Handler function for clicking a task. */
193
+ handleClickTask?: (currentTask: TaskFeildsType) => void;
194
+ /** Handler function for clicking a group. */
195
+ handleClickGroup?: (currentGroup: GroupFeildsType) => void;
196
+ /** your timezones */
197
+ timeZone?: TimeZone;
198
+ /** day id */
199
+ dayOffset?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
200
+ /**day columns styles */
201
+ dayColsStyle?: React.CSSProperties | undefined;
202
+ /**day columns className*/
203
+ dayColsClassName?: string;
204
+ /**hours columns className*/
205
+ hoursColsStyle?: React.CSSProperties | undefined;
206
+ /**hours columns className*/
207
+ hoursColsClassName?: string;
208
+ };
209
+ /**
210
+ * Type for style props.
211
+ */
212
+ export type StyleType = React.CSSProperties | undefined;
213
+ /**
214
+ * Props for the AddTask component.
215
+ */
216
+ export type AddTaskPropsType = {
217
+ /** The current group data. */
218
+ currentGroup: GroupFeildsType;
219
+ /** Additional styles for the add task button. */
220
+ addTaskStyle?: StyleType;
221
+ /** Additional class names for the add task button. */
222
+ addTaskClassName?: string;
223
+ /** Custom render function for adding a task. */
224
+ addTaskRender?: ({ currentGroup, dayInfo, }: {
225
+ currentGroup: GroupFeildsType;
226
+ dayInfo: dayInfoType;
227
+ }) => React.ReactNode;
228
+ /** Information about the day. */
229
+ dayInfo: dayInfoType;
230
+ /** Handler function for adding a new task. */
231
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
232
+ };
233
+ /**
234
+ * Information about a day.
235
+ */
236
+ export type dayInfoType = {
237
+ /** Position of the day. */
238
+ positionDay: number;
239
+ /** Date of the day. */
240
+ day: Date;
241
+ /** Start time of the day. */
242
+ start: number;
243
+ /** End time of the day. */
244
+ end: number;
245
+ };
246
+ /**
247
+ * Type for a task.
248
+ */
249
+ export type TaskType = {
250
+ /** Start time of the task. */
251
+ taskStart: number;
252
+ /** End time of the task. */
253
+ taskEnd: number;
254
+ /** Description of the task. */
255
+ taskDescription?: string;
256
+ /** Description of the task. */
257
+ taskSummary?: string;
258
+ /** Date of the task. */
259
+ taskDate: Date;
260
+ /** ID of the group the task belongs to. */
261
+ groupId: string;
262
+ /** Index of the day the task belongs to. */
263
+ dayIndex: number;
264
+ /** Unique identifier for the task. */
265
+ taskId: string;
266
+ /** This is a prop to save the date in local storage until a date of your choice */
267
+ taskExpiryDate?: Date;
268
+ /**task created date */
269
+ taskCreatedAt?: Date;
270
+ /**task location */
271
+ taskLocation?: string;
272
+ /**task timezone */
273
+ taskTimzone?: string;
274
+ };
275
+ export type filterTaskType = {
276
+ /** Start time of the task. */
277
+ taskStart?: number;
278
+ /** End time of the task. */
279
+ taskEnd?: number;
280
+ /** Description of the task. */
281
+ taskDescription: string;
282
+ /** Description of the task. */
283
+ taskSummary: string;
284
+ /** Date of the task. */
285
+ taskDate?: Date;
286
+ /** ID of the group the task belongs to. */
287
+ groupId?: string;
288
+ /** Index of the day the task belongs to. */
289
+ dayIndex?: number;
290
+ /** Unique identifier for the task. */
291
+ taskId?: string;
292
+ /** This is a prop to save the date in local storage until a date of your choice */
293
+ taskExpiryDate?: Date;
294
+ } & TaskAdditionalFieldsType;
295
+ /**
296
+ * Props for the TaskContainer component.
297
+ */
298
+ export type TaskContainerPropsType = {
299
+ /** Additional class names for the task container. */
300
+ className?: string;
301
+ /** Additional styles for the task container. */
302
+ style?: React.CSSProperties | undefined;
303
+ /** Handler function for dragging a task. */
304
+ handleDragTask?: (event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void;
305
+ /** Custom render function for a task. */
306
+ taskRender?: ({ currentTask, }: {
307
+ currentTask: TaskFeildsType;
308
+ }) => React.ReactNode;
309
+ /** Handler function for ending the drag of a task. */
310
+ handleDragTaskEnd?: (event: React.DragEvent<HTMLDivElement>) => void;
311
+ /** The current task data. */
312
+ currentTask: TaskFeildsType;
313
+ /** Handler function for clicking a task. */
314
+ handleClickTask?: (currentTask: TaskFeildsType) => void;
315
+ };
316
+ /**
317
+ * Props for the GroupsHeadContainer component.
318
+ */
319
+ export type GroupsHeadContainerPropsType = {
320
+ /** Custom render function for the groups header. */
321
+ groupsHeadRender?: () => React.ReactNode;
322
+ /** Additional styles for the groups header container. */
323
+ style?: React.CSSProperties | undefined;
324
+ /** Additional class names for the groups header container. */
325
+ className?: string;
326
+ };
327
+ /**
328
+ * Props for the SumHoursHeadContainer component.
329
+ */
330
+ export type SumHoursHeadContainerPropsType = {
331
+ /** Custom render function for the sum hours header. */
332
+ sumHoursHeadRender?: () => React.ReactNode;
333
+ /** Additional styles for the sum hours header container. */
334
+ style?: React.CSSProperties | undefined;
335
+ /** Additional class names for the sum hours header container. */
336
+ className?: string;
337
+ };
338
+ /**
339
+ * Additional fields for a task.
340
+ */
341
+ type TaskAdditionalFieldsType = Record<any, any>;
342
+ /**
343
+ * Fields for a task, including both required and additional fields.
344
+ */
345
+ export type TaskFeildsType = TaskType & TaskAdditionalFieldsType;
346
+ /**
347
+ * Type for an array of tasks.
348
+ */
349
+ export type TasksType = TaskFeildsType[];
350
+ /**
351
+ * Handler function type for ending the drag of a task.
352
+ */
353
+ export type handleDragTaskEndType = (event: React.DragEvent<HTMLDivElement>) => void;
354
+ /**
355
+ * Props for the SumHoursContainer component.
356
+ */
357
+ export type SumHoursContainerPropsType = {
358
+ /** ID of the group. */
359
+ groupId: string;
360
+ /** Array of tasks to be displayed in the calendar. */
361
+ tasks: TasksType;
362
+ /** Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week). */
363
+ weekOffset: number;
364
+ /** The current date to display in the calendar. */
365
+ calendarDate: Date;
366
+ /** Sum of hours for the group. */
367
+ sumHoursByGroups: number;
368
+ /** Custom render function for the sum of hours. */
369
+ sumHoursRender?: ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, }: {
370
+ groupId: string;
371
+ tasks: TasksType;
372
+ weekOffset: number;
373
+ calendarDate: Date;
374
+ sumHoursByGroups: number;
375
+ }) => React.ReactNode;
376
+ /** Additional styles for the sum hours container. */
377
+ style?: React.CSSProperties | undefined;
378
+ /** Additional class names for the sum hours container. */
379
+ className?: string;
380
+ };
381
+ export type weekDaysType = {
382
+ day: string;
383
+ dayMonth: string;
384
+ dayYear: number;
385
+ dayOfTheMonth: number;
386
+ }[];
387
+ export type dailyHoursType = {
388
+ positionDay: number;
389
+ day: Date;
390
+ start: number;
391
+ end: number;
392
+ }[];
393
+ export type CalendarTablePropsType = CalendarPropsType;
394
+ export type TimeZone = "Africa/Abidjan" | "Africa/Accra" | "Africa/Addis_Ababa" | "Africa/Algiers" | "Africa/Asmara" | "Africa/Asmera" | "Africa/Bamako" | "Africa/Bangui" | "Africa/Banjul" | "Africa/Bissau" | "Africa/Blantyre" | "Africa/Brazzaville" | "Africa/Bujumbura" | "Africa/Cairo" | "Africa/Casablanca" | "Africa/Ceuta" | "Africa/Conakry" | "Africa/Dakar" | "Africa/Dar_es_Salaam" | "Africa/Djibouti" | "Africa/Douala" | "Africa/El_Aaiun" | "Africa/Freetown" | "Africa/Gaborone" | "Africa/Harare" | "Africa/Johannesburg" | "Africa/Juba" | "Africa/Kampala" | "Africa/Khartoum" | "Africa/Kigali" | "Africa/Kinshasa" | "Africa/Lagos" | "Africa/Libreville" | "Africa/Lome" | "Africa/Luanda" | "Africa/Lubumbashi" | "Africa/Lusaka" | "Africa/Malabo" | "Africa/Maputo" | "Africa/Maseru" | "Africa/Mbabane" | "Africa/Mogadishu" | "Africa/Monrovia" | "Africa/Nairobi" | "Africa/Ndjamena" | "Africa/Niamey" | "Africa/Nouakchott" | "Africa/Ouagadougou" | "Africa/Porto-Novo" | "Africa/Sao_Tome" | "Africa/Timbuktu" | "Africa/Tripoli" | "Africa/Tunis" | "Africa/Windhoek" | "America/Adak" | "America/Anchorage" | "America/Anguilla" | "America/Antigua" | "America/Araguaina" | "America/Argentina/Buenos_Aires" | "America/Argentina/Catamarca" | "America/Argentina/ComodRivadavia" | "America/Argentina/Cordoba" | "America/Argentina/Jujuy" | "America/Argentina/La_Rioja" | "America/Argentina/Mendoza" | "America/Argentina/Rio_Gallegos" | "America/Argentina/Salta" | "America/Argentina/San_Juan" | "America/Argentina/San_Luis" | "America/Argentina/Tucuman" | "America/Argentina/Ushuaia" | "America/Aruba" | "America/Asuncion" | "America/Atikokan" | "America/Atka" | "America/Bahia" | "America/Bahia_Banderas" | "America/Barbados" | "America/Belem" | "America/Belize" | "America/Blanc-Sablon" | "America/Boa_Vista" | "America/Bogota" | "America/Boise" | "America/Buenos_Aires" | "America/Cambridge_Bay" | "America/Campo_Grande" | "America/Cancun" | "America/Caracas" | "America/Catamarca" | "America/Cayenne" | "America/Cayman" | "America/Chicago" | "America/Chihuahua" | "America/Ciudad_Juarez" | "America/Coral_Harbour" | "America/Cordoba" | "America/Costa_Rica" | "America/Creston" | "America/Cuiaba" | "America/Curacao" | "America/Danmarkshavn" | "America/Dawson" | "America/Dawson_Creek" | "America/Denver" | "America/Detroit" | "America/Dominica" | "America/Edmonton" | "America/Eirunepe" | "America/El_Salvador" | "America/Ensenada" | "America/Fort_Nelson" | "America/Fort_Wayne" | "America/Fortaleza" | "America/Glace_Bay" | "America/Godthab" | "America/Goose_Bay" | "America/Grand_Turk" | "America/Grenada" | "America/Guadeloupe" | "America/Guatemala" | "America/Guayaquil" | "America/Guyana" | "America/Halifax" | "America/Havana" | "America/Hermosillo" | "America/Indiana/Indianapolis" | "America/Indiana/Knox" | "America/Indiana/Marengo" | "America/Indiana/Petersburg" | "America/Indiana/Tell_City" | "America/Indiana/Vevay" | "America/Indiana/Vincennes" | "America/Indiana/Winamac" | "America/Indianapolis" | "America/Inuvik" | "America/Iqaluit" | "America/Jamaica" | "America/Jujuy" | "America/Juneau" | "America/Kentucky/Louisville" | "America/Kentucky/Monticello" | "America/Knox_IN" | "America/Kralendijk" | "America/La_Paz" | "America/Lima" | "America/Los_Angeles" | "America/Louisville" | "America/Lower_Princes" | "America/Maceio" | "America/Managua" | "America/Manaus" | "America/Marigot" | "America/Martinique" | "America/Matamoros" | "America/Mazatlan" | "America/Mendoza" | "America/Menominee" | "America/Merida" | "America/Metlakatla" | "America/Mexico_City" | "America/Miquelon" | "America/Moncton" | "America/Monterrey" | "America/Montevideo" | "America/Montreal" | "America/Montserrat" | "America/Nassau" | "America/New_York" | "America/Nipigon" | "America/Nome" | "America/Noronha" | "America/North_Dakota/Beulah" | "America/North_Dakota/Center" | "America/North_Dakota/New_Salem" | "America/Nuuk" | "America/Ojinaga" | "America/Panama" | "America/Pangnirtung" | "America/Paramaribo" | "America/Phoenix" | "America/Port-au-Prince" | "America/Port_of_Spain" | "America/Porto_Acre" | "America/Porto_Velho" | "America/Puerto_Rico" | "America/Punta_Arenas" | "America/Rainy_River" | "America/Rankin_Inlet" | "America/Recife" | "America/Regina" | "America/Resolute" | "America/Rio_Branco" | "America/Rosario" | "America/Santa_Isabel" | "America/Santarem" | "America/Santiago" | "America/Santo_Domingo" | "America/Sao_Paulo" | "America/Scoresbysund" | "America/Shiprock" | "America/Sitka" | "America/St_Barthelemy" | "America/St_Johns" | "America/St_Kitts" | "America/St_Lucia" | "America/St_Thomas" | "America/St_Vincent" | "America/Swift_Current" | "America/Tegucigalpa" | "America/Thule" | "America/Thunder_Bay" | "America/Tijuana" | "America/Toronto" | "America/Tortola" | "America/Vancouver" | "America/Virgin" | "America/Whitehorse" | "America/Winnipeg" | "America/Yakutat" | "America/Yellowknife" | "Antarctica/Casey" | "Antarctica/Davis" | "Antarctica/DumontDUrville" | "Antarctica/Macquarie" | "Antarctica/Mawson" | "Antarctica/McMurdo" | "Antarctica/Palmer" | "Antarctica/Rothera" | "Antarctica/South_Pole" | "Antarctica/Syowa" | "Antarctica/Troll" | "Antarctica/Vostok" | "Arctic/Longyearbyen" | "Asia/Aden" | "Asia/Almaty" | "Asia/Amman" | "Asia/Anadyr" | "Asia/Aqtau" | "Asia/Aqtobe" | "Asia/Ashgabat" | "Asia/Ashkhabad" | "Asia/Atyrau" | "Asia/Baghdad" | "Asia/Bahrain" | "Asia/Baku" | "Asia/Bangkok" | "Asia/Barnaul" | "Asia/Beirut" | "Asia/Bishkek" | "Asia/Brunei" | "Asia/Calcutta" | "Asia/Chita" | "Asia/Choibalsan" | "Asia/Chongqing" | "Asia/Chungking" | "Asia/Colombo" | "Asia/Dacca" | "Asia/Damascus" | "Asia/Dhaka" | "Asia/Dili" | "Asia/Dubai" | "Asia/Dushanbe" | "Asia/Famagusta" | "Asia/Gaza" | "Asia/Harbin" | "Asia/Hebron" | "Asia/Ho_Chi_Minh" | "Asia/Hong_Kong" | "Asia/Hovd" | "Asia/Irkutsk" | "Asia/Istanbul" | "Asia/Jakarta" | "Asia/Jayapura" | "Asia/Jerusalem" | "Asia/Kabul" | "Asia/Kamchatka" | "Asia/Karachi" | "Asia/Kashgar" | "Asia/Kathmandu" | "Asia/Katmandu" | "Asia/Khandyga" | "Asia/Kolkata" | "Asia/Krasnoyarsk" | "Asia/Kuala_Lumpur" | "Asia/Kuching" | "Asia/Kuwait" | "Asia/Macao" | "Asia/Macau" | "Asia/Magadan" | "Asia/Makassar" | "Asia/Manila" | "Asia/Muscat" | "Asia/Nicosia" | "Asia/Novokuznetsk" | "Asia/Novosibirsk" | "Asia/Omsk" | "Asia/Oral" | "Asia/Phnom_Penh" | "Asia/Pontianak" | "Asia/Pyongyang" | "Asia/Qatar" | "Asia/Qostanay" | "Asia/Qyzylorda" | "Asia/Rangoon" | "Asia/Riyadh" | "Asia/Saigon" | "Asia/Sakhalin" | "Asia/Samarkand" | "Asia/Seoul" | "Asia/Shanghai" | "Asia/Singapore" | "Asia/Srednekolymsk" | "Asia/Taipei" | "Asia/Tashkent" | "Asia/Tbilisi" | "Asia/Tehran" | "Asia/Tel_Aviv" | "Asia/Thimbu" | "Asia/Thimphu" | "Asia/Tokyo" | "Asia/Tomsk" | "Asia/Ujung_Pandang" | "Asia/Ulaanbaatar" | "Asia/Ulan_Bator" | "Asia/Urumqi" | "Asia/Ust-Nera" | "Asia/Vientiane" | "Asia/Vladivostok" | "Asia/Yakutsk" | "Asia/Yangon" | "Asia/Yekaterinburg" | "Asia/Yerevan" | "Atlantic/Azores" | "Atlantic/Bermuda" | "Atlantic/Canary" | "Atlantic/Cape_Verde" | "Atlantic/Faeroe" | "Atlantic/Faroe" | "Atlantic/Jan_Mayen" | "Atlantic/Madeira" | "Atlantic/Reykjavik" | "Atlantic/South_Georgia" | "Atlantic/St_Helena" | "Atlantic/Stanley" | "Australia/ACT" | "Australia/Adelaide" | "Australia/Brisbane" | "Australia/Broken_Hill" | "Australia/Canberra" | "Australia/Currie" | "Australia/Darwin" | "Australia/Eucla" | "Australia/Hobart" | "Australia/LHI" | "Australia/Lindeman" | "Australia/Lord_Howe" | "Australia/Melbourne" | "Australia/North" | "Australia/NSW" | "Australia/Perth" | "Australia/Queensland" | "Australia/South" | "Australia/Sydney" | "Australia/Tasmania" | "Australia/Victoria" | "Australia/West" | "Australia/Yancowinna" | "Brazil/Acre" | "Brazil/DeNoronha" | "Brazil/East" | "Brazil/West" | "Canada/Atlantic" | "Canada/Central" | "Canada/Eastern" | "Canada/Mountain" | "Canada/Newfoundland" | "Canada/Pacific" | "Canada/Saskatchewan" | "Canada/Yukon" | "CET" | "Chile/Continental" | "Chile/EasterIsland" | "CST6CDT" | "Cuba" | "EET" | "Egypt" | "Eire" | "EST" | "EST5EDT" | "Etc/GMT" | "Etc/GMT+0" | "Etc/GMT+1" | "Etc/GMT+10" | "Etc/GMT+11" | "Etc/GMT+12" | "Etc/GMT+2" | "Etc/GMT+3" | "Etc/GMT+4" | "Etc/GMT+5" | "Etc/GMT+6" | "Etc/GMT+7" | "Etc/GMT+8" | "Etc/GMT+9" | "Etc/GMT-0" | "Etc/GMT-1" | "Etc/GMT-10" | "Etc/GMT-11" | "Etc/GMT-12" | "Etc/GMT-13" | "Etc/GMT-14" | "Etc/GMT-2" | "Etc/GMT-3" | "Etc/GMT-4" | "Etc/GMT-5" | "Etc/GMT-6" | "Etc/GMT-7" | "Etc/GMT-8" | "Etc/GMT-9" | "Etc/GMT0" | "Etc/Greenwich" | "Etc/UCT" | "Etc/Universal" | "Etc/UTC" | "Etc/Zulu" | "Europe/Amsterdam" | "Europe/Andorra" | "Europe/Astrakhan" | "Europe/Athens" | "Europe/Belfast" | "Europe/Belgrade" | "Europe/Berlin" | "Europe/Bratislava" | "Europe/Brussels" | "Europe/Bucharest" | "Europe/Budapest" | "Europe/Busingen" | "Europe/Chisinau" | "Europe/Copenhagen" | "Europe/Dublin" | "Europe/Gibraltar" | "Europe/Guernsey" | "Europe/Helsinki" | "Europe/Isle_of_Man" | "Europe/Istanbul" | "Europe/Jersey" | "Europe/Kaliningrad" | "Europe/Kiev" | "Europe/Kirov" | "Europe/Kyiv" | "Europe/Lisbon" | "Europe/Ljubljana" | "Europe/London" | "Europe/Luxembourg" | "Europe/Madrid" | "Europe/Malta" | "Europe/Mariehamn" | "Europe/Minsk" | "Europe/Monaco" | "Europe/Moscow" | "Europe/Nicosia" | "Europe/Oslo" | "Europe/Paris" | "Europe/Podgorica" | "Europe/Prague" | "Europe/Riga" | "Europe/Rome" | "Europe/Samara" | "Europe/San_Marino" | "Europe/Sarajevo" | "Europe/Saratov" | "Europe/Simferopol" | "Europe/Skopje" | "Europe/Sofia" | "Europe/Stockholm" | "Europe/Tallinn" | "Europe/Tirane" | "Europe/Tiraspol" | "Europe/Ulyanovsk" | "Europe/Uzhgorod" | "Europe/Vaduz" | "Europe/Vatican" | "Europe/Vienna" | "Europe/Vilnius" | "Europe/Volgograd" | "Europe/Warsaw" | "Europe/Zagreb" | "Europe/Zaporozhye" | "Europe/Zurich" | "Factory" | "GB" | "GB-Eire" | "GMT" | "GMT+0" | "GMT-0" | "GMT0" | "Greenwich" | "Hongkong" | "HST" | "Iceland" | "Indian/Antananarivo" | "Indian/Chagos" | "Indian/Christmas" | "Indian/Cocos" | "Indian/Comoro" | "Indian/Kerguelen" | "Indian/Mahe" | "Indian/Maldives" | "Indian/Mauritius" | "Indian/Mayotte" | "Indian/Reunion" | "Iran" | "Israel" | "Jamaica" | "Japan" | "Kwajalein" | "Libya" | "MET" | "Mexico/BajaNorte" | "Mexico/BajaSur" | "Mexico/General" | "MST" | "MST7MDT" | "Navajo" | "NZ" | "NZ-CHAT" | "Pacific/Apia" | "Pacific/Auckland" | "Pacific/Bougainville" | "Pacific/Chatham" | "Pacific/Chuuk" | "Pacific/Easter" | "Pacific/Efate" | "Pacific/Enderbury" | "Pacific/Fakaofo" | "Pacific/Fiji" | "Pacific/Funafuti" | "Pacific/Galapagos" | "Pacific/Gambier" | "Pacific/Guadalcanal" | "Pacific/Guam" | "Pacific/Honolulu" | "Pacific/Johnston" | "Pacific/Kanton" | "Pacific/Kiritimati" | "Pacific/Kosrae" | "Pacific/Kwajalein" | "Pacific/Majuro" | "Pacific/Marquesas" | "Pacific/Midway" | "Pacific/Nauru" | "Pacific/Niue" | "Pacific/Norfolk" | "Pacific/Noumea" | "Pacific/Pago_Pago" | "Pacific/Palau" | "Pacific/Pitcairn" | "Pacific/Pohnpei" | "Pacific/Ponape" | "Pacific/Port_Moresby" | "Pacific/Rarotonga" | "Pacific/Saipan" | "Pacific/Samoa" | "Pacific/Tahiti" | "Pacific/Tarawa" | "Pacific/Tongatapu" | "Pacific/Truk" | "Pacific/Wake" | "Pacific/Wallis" | "Pacific/Yap" | "Poland" | "Portugal" | "PRC" | "PST8PDT" | "ROC" | "ROK" | "Singapore" | "Turkey" | "UCT" | "Universal" | "US/Alaska" | "US/Aleutian" | "US/Arizona" | "US/Central" | "US/East-Indiana" | "US/Eastern" | "US/Hawaii" | "US/Indiana-Starke" | "US/Michigan" | "US/Mountain" | "US/Pacific" | "US/Samoa" | "UTC" | "W-SU" | "WET" | "Zulu";
395
+ export {};
@@ -0,0 +1,6 @@
1
+ import { dailyHoursType, TimeZone, weekDaysType } from "../definitions";
2
+ declare function useCalendarDateState(date: Date, weekOffset: number | undefined, timeZone: TimeZone | undefined): {
3
+ weekDays: weekDaysType;
4
+ dailyHours: dailyHoursType;
5
+ };
6
+ export default useCalendarDateState;
@@ -0,0 +1,3 @@
1
+ export { default as Calendar } from './components/index';
2
+ export * from './lib/utils';
3
+ export * from './definitions/index';
@@ -0,0 +1,4 @@
1
+ import { StyleType } from "../definitions";
2
+ export declare const theadTrStyle: StyleType;
3
+ export declare const groupTdStyle: StyleType;
4
+ export declare const groupContainerStyle: StyleType;
@@ -0,0 +1,86 @@
1
+ import { TasksType, TaskFeildsType, TimeZone, GroupFeildsType, dayInfoType } from "../definitions";
2
+ export declare const DAY_IN_MILLISECONDS = 86400000;
3
+ export declare const WEEK_IN_MILLISECONDS: number;
4
+ export declare const startDateMilliseconds: number;
5
+ export declare const endDateMilliseconds: number;
6
+ export declare function getDayHourly(weekOffset: number, timeZone?: TimeZone): {
7
+ positionDay: number;
8
+ day: Date;
9
+ start: number;
10
+ end: number;
11
+ }[];
12
+ export declare function millisecondsToDate(milliseconds: number): {
13
+ formattedDate: string;
14
+ dayOfWeek: string;
15
+ };
16
+ export declare function millisecondsToInt(milliseconds: number): {
17
+ formattedDate: string;
18
+ dayOfWeek: string;
19
+ };
20
+ export declare function getWeekDays(jump: number, timeZone?: TimeZone): {
21
+ day: string;
22
+ dayMonth: string;
23
+ dayYear: number;
24
+ dayOfTheMonth: number;
25
+ }[];
26
+ /**
27
+ * Calculate the week difference between the selected date and the current date.
28
+ * @param dateSelectionnee - The selected date.
29
+ * @returns The week difference in days.
30
+ */
31
+ export declare function calculerEcartSemaine(dateSelectionnee: Date, timeZone?: TimeZone): number;
32
+ /**
33
+ * Calculate the number of weeks since an arbitrary origin date (January 1, 2022).
34
+ * @param annee - The year.
35
+ * @param numeroSemaine - The week number.
36
+ * @returns The number of weeks since the origin date.
37
+ */
38
+ export declare function getSessionStorageRecordForDragAndDrop(tasks: TasksType, positionDay: number, dropGroupId: string): {
39
+ taskDropStart: number;
40
+ taskDropEnd: number;
41
+ taskDropDate: Date;
42
+ newTask: any;
43
+ newTasks: TasksType;
44
+ } | undefined;
45
+ export declare function compareWeekOffset(calendarDate: Date, weekOffset: number, taskDate: Date, timeZone?: TimeZone): boolean;
46
+ export declare const sumHoursByGroups: (groupId: string, tasks: TasksType | any, weekOffset: number, calendarDate: Date, timeZone?: TimeZone) => number;
47
+ export declare function saveTasksToLocalStorage(tasks: TasksType): void;
48
+ export declare const updateCalendarDateWithOffset: (offset: number, calendarDate: Date) => Date;
49
+ export declare const updateOffsetWithDateCalendar: (calendarDate: Date, timeZone?: TimeZone) => number;
50
+ export declare const millisecondsToHours: (milliseconds: number) => string;
51
+ export declare const checkDuplicates: (tasks: TasksType, taskStart: number, taskEnd: number, groupId: string) => boolean;
52
+ export declare const getSavedTasks: () => any;
53
+ export declare const deleteTaskSaved: (taskId: string) => void;
54
+ export declare const deleteTasksSaved: () => void;
55
+ export declare function getWeeksInMonth(year: number, month: number): number;
56
+ export declare function getMonthNumber(monthName: string): number;
57
+ export declare function getDateObjectInTimeZone(timeZone: string): Date;
58
+ /**
59
+ * Returns the current date according to the selected timezone or the local time.
60
+ * @param timeZone - The optional timezone.
61
+ * @returns The current date.
62
+ */
63
+ export declare function getCalendarDate(timeZone?: TimeZone): Date;
64
+ export declare function getArbitraryDateInTimeZone(date: Date, timeZone?: string): Date;
65
+ export declare function recurringTasks(allTasks: TasksType, task: TaskFeildsType, recurrenceType: "daily" | "weekly" | "monthly", occurrences: number, timeZone?: TimeZone): TaskFeildsType[];
66
+ export declare function getHoursByday(tasks: TaskFeildsType[], dayIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6, weekOffset?: number, timeZone?: TimeZone): number;
67
+ export declare function getHoursByGroup(tasks: TaskFeildsType[], groupId: string, weekOffset?: number, timeZone?: TimeZone): number;
68
+ export declare function getTaskProgression(task: TaskFeildsType, timeZone?: TimeZone): string | 0 | 100;
69
+ export declare function convertTasksToIcsFormat(tasks: TaskFeildsType[]): string;
70
+ export declare function addTask(tasks: TaskFeildsType[], task: TaskFeildsType): TaskFeildsType[];
71
+ export declare function deleteTask(tasks: TaskFeildsType[], taskId: string): TaskFeildsType[];
72
+ export declare function getTaskInfoById(tasks: TaskFeildsType[], groups: GroupFeildsType[], taskId: string): {
73
+ group: GroupFeildsType | undefined;
74
+ task: TaskFeildsType;
75
+ };
76
+ export declare function selectTask(task: TaskFeildsType): void;
77
+ export declare function deSelectTask(task: TaskFeildsType): void;
78
+ export declare function copyTasks(task: TaskFeildsType): void;
79
+ export declare function cutTasks(task: TaskFeildsType, tasks: TaskFeildsType[]): TaskFeildsType[];
80
+ export declare function getUnqueId(): string;
81
+ export declare function pastTasks(dayInfo: dayInfoType, groupId: string, tasks: TaskFeildsType[], taskExpiryDate?: Date, timeZone?: TimeZone): TaskFeildsType[] | undefined;
82
+ export declare function updateTask(tasks: TaskFeildsType[], taskId: string, newtask: TaskFeildsType): TaskFeildsType[];
83
+ export declare function duplicateTasksForPeriod(periodStart: Date, periodEnd: Date, calendarOffset: number, allTasks: TasksType): TasksType;
84
+ export declare function duplicateTaskForPeriod(periodStart: Date, periodEnd: Date, task: TaskFeildsType, ecartDay?: number, groupId?: string, taskExpiryDate?: Date): TasksType;
85
+ export declare const GetTimeRangeByDay: (start: number, end: number) => number[];
86
+ export declare function totalLabel(milliseconds: number): string;
package/package.json CHANGED
@@ -1,7 +1,25 @@
1
1
  {
2
2
  "name": "react-weekly-planning",
3
- "version": "1.0.35",
4
- "main": "index.js",
3
+ "version": "1.0.37",
4
+ "main": "dist/index.js",
5
+ "types": "dist/types/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/types/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./utils": {
12
+ "types": "./dist/types/lib/utils.d.ts",
13
+ "default": "./dist/lib/utils.js"
14
+ },
15
+ "./definitions": {
16
+ "types": "./dist/types/definitions/index.d.ts",
17
+ "default": "./dist/definitions/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
5
23
  "scripts": {
6
24
  "test": "jest --env=jsdom",
7
25
  "test:watch": "jest --watch",
Binary file
Binary file
package/jsdoc.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "tags": {
3
- "allowUnknownTags": true,
4
- "dictionaries": ["jsdoc", "closure"]
5
- },
6
- "source": {
7
- "include": ["definitions"],
8
- "includePattern": "\\.(jsx|js|ts|tsx)$",
9
- "excludePattern": "(^|\\/|\\\\)_"
10
- },
11
- "plugins": ["node_modules/better-docs/typescript"],
12
- "typescript": {
13
- "moduleRoot": "test"
14
- },
15
- "templates": {
16
- "better-docs": {
17
- "name": "Calendar"
18
- }
19
- },
20
- "opts": {
21
- "template": "node_modules/better-docs",
22
- "destination": "docs",
23
- "recurse": true,
24
- "readme": "README.md"
25
- }
26
- }
File without changes