react-weekly-planning 1.0.29 → 1.0.31
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/__tests__/page.test.js +106 -46
- package/__tests__/page.test.tsx +117 -45
- package/babel.config.js +1 -0
- package/components/AddTask/index.js +17 -17
- package/components/AddTask/index.tsx +4 -0
- package/components/CalendarForWeek.js +50 -0
- package/components/{CalendarTable.tsx → CalendarForWeek.tsx} +49 -39
- package/components/CalendarForday.js +34 -0
- package/components/CalendarForday.tsx +130 -0
- package/components/DayContainer/index.js +15 -15
- package/components/DayContainer/index.tsx +1 -0
- package/components/GroupContainer/index.js +15 -15
- package/components/GroupContainer/index.tsx +1 -0
- package/components/GroupsHeadContainer/index.js +9 -9
- package/components/SumHoursContainer/index.js +16 -15
- package/components/SumHoursContainer/index.tsx +2 -1
- package/components/SumHoursHead/index.js +9 -9
- package/components/TaskContainer/index.js +35 -35
- package/components/TaskContainer/index.tsx +1 -1
- package/components/TaskList/index.js +5 -0
- package/components/TaskList/index.tsx +20 -0
- package/contexts/CalendarContext.js +12 -12
- package/contexts/CalendarContext.tsx +4 -0
- package/definitions/index.js +1 -1
- package/definitions/index.ts +644 -4
- package/docs/global.html +4982 -4982
- package/docs/index.html +474 -474
- package/docs/index.ts.html +121 -121
- package/docs/scripts/linenumber.js +26 -26
- package/docs/scripts/search.js +38 -38
- package/docs/styles/iframe.css +12 -12
- package/docs/styles/prettify-jsdoc.css +111 -111
- package/docs/styles/prettify-tomorrow.css +132 -132
- package/docs/styles/reset.css +44 -44
- package/hooks/useCalendarDateState.js +19 -13
- package/hooks/useCalendarDateState.ts +28 -8
- package/index.js +70 -52
- package/index.tsx +57 -41
- package/jest.config.js +9 -9
- package/lib/slyles.js +21 -21
- package/lib/slyles.ts +1 -1
- package/lib/utils.js +640 -317
- package/lib/utils.ts +588 -14
- package/out/index.html +128 -128
- package/out/scripts/linenumber.js +26 -26
- package/out/scripts/search.js +38 -38
- package/out/styles/iframe.css +12 -12
- package/out/styles/prettify-jsdoc.css +111 -111
- package/out/styles/prettify-tomorrow.css +132 -132
- package/out/styles/reset.css +44 -44
- package/package.json +81 -71
- package/style.css +26 -4
- package/components/CalendarTable.js +0 -48
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import "../style.css";
|
|
4
|
+
import { memo, useEffect } from "react";
|
|
5
|
+
import { compareWeekOffset, saveTasksToLocalStorage } from "../lib/utils";
|
|
6
|
+
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
7
|
+
import AddTask from "./AddTask";
|
|
8
|
+
import TaskContainer from "./TaskContainer";
|
|
9
|
+
import GroupContainer from "./GroupContainer";
|
|
10
|
+
import DayContainer from "./DayContainer";
|
|
11
|
+
function CalendarForDay(props) {
|
|
12
|
+
const { dailyHours, weekDays } = useCalendarDateState(props.date, props.weekOffset, props.timeZone);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
saveTasksToLocalStorage(props.tasks);
|
|
15
|
+
}, [props.tasks]);
|
|
16
|
+
const currentDay = weekDays[props.dayOffset || 0];
|
|
17
|
+
const currentDailyHours = dailyHours[props.dayOffset || 0];
|
|
18
|
+
return (_jsxs("div", { className: ` CalendarTableForDay ${props.className}`, style: Object.assign({}, props.style), children: [currentDay && (_jsx(DayContainer, { style: props.dayStyle, className: props.dayClassName, dayIndex: props.dayOffset || 0, dayRender: props.dayRender, day: currentDay.day, dayOfTheMonth: currentDay.dayOfTheMonth, dayMonth: currentDay.dayMonth, dayYear: currentDay.dayYear })), _jsx("div", { className: `CalendarTableForDayTasksContainer`, children: currentDailyHours &&
|
|
19
|
+
props.groups.map((group, i) => {
|
|
20
|
+
return (_jsxs("div", { style: Object.assign({ width: "100%", height: "auto", background: "#f2f8f8", padding: "5px", borderBottom: "1.5px solid #0f52737e", borderRight: "0.74px solid rgba(198, 219, 225, 0.68)", borderLeft: "0.74px solid rgba(198, 219, 225, 0.68)" }, props.rowsStyle), className: `${props.rowsClassName}`, children: [_jsx("div", { style: Object.assign({ width: "auto", height: "auto" }, props.groupsColsStyle), className: props.groupsColsClassName, children: _jsx(GroupContainer, { style: props.groupContainerStyle, className: props.groupContainerClassName, groupRender: props.groupRender, currentGroup: group, handleClickGroup: props.handleClickGroup }) }), props.tasks.map((task, taskKey) => {
|
|
21
|
+
if (task.dayIndex === (props.dayOffset || 0) &&
|
|
22
|
+
task.groupId === group.id &&
|
|
23
|
+
compareWeekOffset(props.date, props.weekOffset || 0, task.taskDate)) {
|
|
24
|
+
return (_jsx(TaskContainer, { handleDragTask: props.handleDragTask, taskRender: props.taskRender, handleDragTaskEnd: props.handleDragTaskEnd, style: props.taskContainerStyle, className: `${props.taskContainerClassName}`, currentTask: task, handleClickTask: props.handleClickTask }, `${taskKey} task`));
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
return "";
|
|
28
|
+
}), _jsx(AddTask, { addTaskStyle: props.addTaskStyle, addTaskClassName: props.addTaskClassName, currentGroup: group, dayInfo: currentDailyHours, addTaskRender: props.addTaskRender, handleAddTask: props.handleAddTask })] }, i));
|
|
29
|
+
}) })] }));
|
|
30
|
+
}
|
|
31
|
+
export default memo(CalendarForDay, (prevProps, nextProps) => prevProps.tasks === nextProps.tasks &&
|
|
32
|
+
prevProps.date === nextProps.date &&
|
|
33
|
+
prevProps.groups === nextProps.groups &&
|
|
34
|
+
prevProps.weekOffset === nextProps.weekOffset);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../style.css";
|
|
3
|
+
import { memo, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
import { CalendarPropsType, CalendarTablePropsType } from "../definitions";
|
|
6
|
+
import { compareWeekOffset, saveTasksToLocalStorage } from "../lib/utils";
|
|
7
|
+
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
8
|
+
|
|
9
|
+
import AddTask from "./AddTask";
|
|
10
|
+
import TaskContainer from "./TaskContainer";
|
|
11
|
+
import GroupContainer from "./GroupContainer";
|
|
12
|
+
import DayContainer from "./DayContainer";
|
|
13
|
+
|
|
14
|
+
function CalendarForDay(props: CalendarTablePropsType) {
|
|
15
|
+
const { dailyHours, weekDays } = useCalendarDateState(
|
|
16
|
+
props.date,
|
|
17
|
+
props.weekOffset,
|
|
18
|
+
props.timeZone
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
saveTasksToLocalStorage(props.tasks);
|
|
23
|
+
}, [props.tasks]);
|
|
24
|
+
|
|
25
|
+
const currentDay = weekDays[props.dayOffset || 0];
|
|
26
|
+
const currentDailyHours = dailyHours[props.dayOffset || 0];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className={` CalendarTableForDay ${props.className}`}
|
|
31
|
+
style={{ ...props.style }}
|
|
32
|
+
>
|
|
33
|
+
{currentDay && (
|
|
34
|
+
<DayContainer
|
|
35
|
+
style={props.dayStyle}
|
|
36
|
+
className={props.dayClassName}
|
|
37
|
+
dayIndex={props.dayOffset || 0}
|
|
38
|
+
dayRender={props.dayRender}
|
|
39
|
+
day={currentDay.day}
|
|
40
|
+
dayOfTheMonth={currentDay.dayOfTheMonth}
|
|
41
|
+
dayMonth={currentDay.dayMonth}
|
|
42
|
+
dayYear={currentDay.dayYear}
|
|
43
|
+
/>
|
|
44
|
+
)}
|
|
45
|
+
<div className={`CalendarTableForDayTasksContainer`}>
|
|
46
|
+
{currentDailyHours &&
|
|
47
|
+
props.groups.map((group, i) => {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
key={i}
|
|
51
|
+
style={{
|
|
52
|
+
width: "100%",
|
|
53
|
+
height: "auto",
|
|
54
|
+
background: "#f2f8f8",
|
|
55
|
+
padding: "5px",
|
|
56
|
+
borderBottom: "1.5px solid #0f52737e",
|
|
57
|
+
borderRight: "0.74px solid rgba(198, 219, 225, 0.68)",
|
|
58
|
+
borderLeft: "0.74px solid rgba(198, 219, 225, 0.68)",
|
|
59
|
+
...props.rowsStyle,
|
|
60
|
+
}}
|
|
61
|
+
className={`${props.rowsClassName}`}
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
style={{
|
|
65
|
+
width: "auto",
|
|
66
|
+
height: "auto",
|
|
67
|
+
...props.groupsColsStyle,
|
|
68
|
+
}}
|
|
69
|
+
className={props.groupsColsClassName}
|
|
70
|
+
>
|
|
71
|
+
<GroupContainer
|
|
72
|
+
style={props.groupContainerStyle}
|
|
73
|
+
className={props.groupContainerClassName}
|
|
74
|
+
groupRender={props.groupRender}
|
|
75
|
+
currentGroup={group}
|
|
76
|
+
handleClickGroup={props.handleClickGroup}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
{props.tasks.map((task, taskKey) => {
|
|
81
|
+
if (
|
|
82
|
+
task.dayIndex === (props.dayOffset || 0) &&
|
|
83
|
+
task.groupId === group.id &&
|
|
84
|
+
compareWeekOffset(
|
|
85
|
+
props.date,
|
|
86
|
+
props.weekOffset || 0,
|
|
87
|
+
task.taskDate
|
|
88
|
+
)
|
|
89
|
+
) {
|
|
90
|
+
return (
|
|
91
|
+
<TaskContainer
|
|
92
|
+
key={`${taskKey} task`}
|
|
93
|
+
handleDragTask={props.handleDragTask}
|
|
94
|
+
taskRender={props.taskRender}
|
|
95
|
+
handleDragTaskEnd={props.handleDragTaskEnd}
|
|
96
|
+
style={props.taskContainerStyle}
|
|
97
|
+
className={`${props.taskContainerClassName}`}
|
|
98
|
+
currentTask={task}
|
|
99
|
+
handleClickTask={props.handleClickTask}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
} else return "";
|
|
103
|
+
})}
|
|
104
|
+
<AddTask
|
|
105
|
+
addTaskStyle={props.addTaskStyle}
|
|
106
|
+
addTaskClassName={props.addTaskClassName}
|
|
107
|
+
currentGroup={group}
|
|
108
|
+
dayInfo={currentDailyHours}
|
|
109
|
+
addTaskRender={props.addTaskRender}
|
|
110
|
+
handleAddTask={props.handleAddTask}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default memo(
|
|
121
|
+
CalendarForDay,
|
|
122
|
+
(
|
|
123
|
+
prevProps: Readonly<CalendarPropsType>,
|
|
124
|
+
nextProps: Readonly<CalendarPropsType>
|
|
125
|
+
) =>
|
|
126
|
+
prevProps.tasks === nextProps.tasks &&
|
|
127
|
+
prevProps.date === nextProps.date &&
|
|
128
|
+
prevProps.groups === nextProps.groups &&
|
|
129
|
+
prevProps.weekOffset === nextProps.weekOffset
|
|
130
|
+
);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
const DayContainer = ({ dayIndex, dayOfTheMonth, day, dayMonth, dayYear, dayRender, className, style, }) => {
|
|
4
|
-
if (dayRender) {
|
|
5
|
-
return (_jsx(_Fragment, { children: dayRender({
|
|
6
|
-
dayIndex,
|
|
7
|
-
day,
|
|
8
|
-
dayOfTheMonth,
|
|
9
|
-
dayMonth,
|
|
10
|
-
dayYear,
|
|
11
|
-
}) }));
|
|
12
|
-
}
|
|
13
|
-
return (_jsx("div", { className: `${className}`, style: style, children: `${day}. ${dayOfTheMonth}` }));
|
|
14
|
-
};
|
|
15
|
-
export default memo(DayContainer);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const DayContainer = ({ dayIndex, dayOfTheMonth, day, dayMonth, dayYear, dayRender, className, style, }) => {
|
|
4
|
+
if (dayRender) {
|
|
5
|
+
return (_jsx(_Fragment, { children: dayRender({
|
|
6
|
+
dayIndex,
|
|
7
|
+
day,
|
|
8
|
+
dayOfTheMonth,
|
|
9
|
+
dayMonth,
|
|
10
|
+
dayYear,
|
|
11
|
+
}) }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx("div", { className: `${className}`, style: style, children: `${day}. ${dayOfTheMonth}` }));
|
|
14
|
+
};
|
|
15
|
+
export default memo(DayContainer);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
import { groupContainerStyle } from "../../lib/slyles";
|
|
4
|
-
const GroupContainer = ({ className, style, groupRender, currentGroup, handleClickGroup, }) => {
|
|
5
|
-
if (groupRender) {
|
|
6
|
-
return _jsx(_Fragment, { children: groupRender({ currentGroup }) });
|
|
7
|
-
}
|
|
8
|
-
const handleClick = () => {
|
|
9
|
-
if (!handleClickGroup)
|
|
10
|
-
return;
|
|
11
|
-
handleClickGroup(currentGroup);
|
|
12
|
-
};
|
|
13
|
-
return (_jsxs("div", { onClick: handleClick, className: `${className}`, style: Object.assign(Object.assign({}, groupContainerStyle), style), children: [currentGroup.imageUrl && (_jsx("img", { width: 30, height: 30, src: currentGroup.imageUrl, alt: "groupimg" })), _jsx("label", { children: currentGroup.label && currentGroup.label })] }));
|
|
14
|
-
};
|
|
15
|
-
export default memo(GroupContainer);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { groupContainerStyle } from "../../lib/slyles";
|
|
4
|
+
const GroupContainer = ({ className, style, groupRender, currentGroup, handleClickGroup, }) => {
|
|
5
|
+
if (groupRender) {
|
|
6
|
+
return _jsx(_Fragment, { children: groupRender({ currentGroup }) });
|
|
7
|
+
}
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
if (!handleClickGroup)
|
|
10
|
+
return;
|
|
11
|
+
handleClickGroup(currentGroup);
|
|
12
|
+
};
|
|
13
|
+
return (_jsxs("div", { onClick: handleClick, className: `${className}`, style: Object.assign(Object.assign({}, groupContainerStyle), style), children: [currentGroup.imageUrl && (_jsx("img", { width: 30, height: 30, src: currentGroup.imageUrl, alt: "groupimg" })), _jsx("label", { children: currentGroup.label && currentGroup.label })] }));
|
|
14
|
+
};
|
|
15
|
+
export default memo(GroupContainer);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
const GroupsHeadContainer = ({ groupsHeadRender, style, className, }) => {
|
|
4
|
-
if (groupsHeadRender) {
|
|
5
|
-
return _jsx(_Fragment, { children: groupsHeadRender() });
|
|
6
|
-
}
|
|
7
|
-
return (_jsx("div", { className: `${className}`, style: style, children: "WeeklyCalendar" }));
|
|
8
|
-
};
|
|
9
|
-
export default memo(GroupsHeadContainer);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const GroupsHeadContainer = ({ groupsHeadRender, style, className, }) => {
|
|
4
|
+
if (groupsHeadRender) {
|
|
5
|
+
return _jsx(_Fragment, { children: groupsHeadRender() });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { className: `${className}`, style: style, children: "WeeklyCalendar" }));
|
|
8
|
+
};
|
|
9
|
+
export default memo(GroupsHeadContainer);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { totalLabel } from "../../lib/utils";
|
|
4
|
+
const SumHoursContainer = ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, sumHoursRender, className, style, }) => {
|
|
5
|
+
if (sumHoursRender) {
|
|
6
|
+
return (_jsx(_Fragment, { children: sumHoursRender({
|
|
7
|
+
groupId,
|
|
8
|
+
tasks,
|
|
9
|
+
weekOffset,
|
|
10
|
+
calendarDate,
|
|
11
|
+
sumHoursByGroups,
|
|
12
|
+
}) }));
|
|
13
|
+
}
|
|
14
|
+
return (_jsx("div", { style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), className: `${className}`, children: totalLabel(sumHoursByGroups) }));
|
|
15
|
+
};
|
|
16
|
+
export default memo(SumHoursContainer);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memo } from "react";
|
|
2
2
|
import { SumHoursContainerPropsType } from "../../definitions";
|
|
3
|
+
import { millisecondsToHours, totalLabel } from "../../lib/utils";
|
|
3
4
|
|
|
4
5
|
const SumHoursContainer = ({
|
|
5
6
|
groupId,
|
|
@@ -30,7 +31,7 @@ const SumHoursContainer = ({
|
|
|
30
31
|
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
31
32
|
className={`${className}`}
|
|
32
33
|
>
|
|
33
|
-
{sumHoursByGroups}
|
|
34
|
+
{totalLabel(sumHoursByGroups)}
|
|
34
35
|
</div>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
|
|
4
|
-
if (sumHoursHeadRender) {
|
|
5
|
-
return _jsx(_Fragment, { children: sumHoursHeadRender() });
|
|
6
|
-
}
|
|
7
|
-
return (_jsx("div", { className: `${className}`, style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), children: "Hours" }));
|
|
8
|
-
};
|
|
9
|
-
export default memo(SumHoursHead);
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
|
|
4
|
+
if (sumHoursHeadRender) {
|
|
5
|
+
return _jsx(_Fragment, { children: sumHoursHeadRender() });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { className: `${className}`, style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), children: "Hours" }));
|
|
8
|
+
};
|
|
9
|
+
export default memo(SumHoursHead);
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
|
-
import { millisecondsToDate } from "../../lib/utils";
|
|
4
|
-
const TaskContainer = ({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }) => {
|
|
5
|
-
const handleDragStart = (event) => {
|
|
6
|
-
if (!handleDragTask)
|
|
7
|
-
return;
|
|
8
|
-
event.dataTransfer.effectAllowed = "move";
|
|
9
|
-
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
10
|
-
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
11
|
-
window.sessionStorage.setItem("calendardragtaskStart", `${currentTask.taskStart}`);
|
|
12
|
-
window.sessionStorage.setItem("calendardragtaskEnd", `${currentTask.taskEnd}`);
|
|
13
|
-
window.sessionStorage.setItem("calendardragdayIndex", `${currentTask.dayIndex}`);
|
|
14
|
-
handleDragTask(event, currentTask);
|
|
15
|
-
};
|
|
16
|
-
const handleDragEnd = (event) => {
|
|
17
|
-
if (!handleDragTaskEnd)
|
|
18
|
-
return;
|
|
19
|
-
handleDragTaskEnd(event);
|
|
20
|
-
};
|
|
21
|
-
const handleClick = () => {
|
|
22
|
-
if (!handleClickTask)
|
|
23
|
-
return;
|
|
24
|
-
handleClickTask(currentTask);
|
|
25
|
-
};
|
|
26
|
-
if (taskRender) {
|
|
27
|
-
return (_jsx("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: taskRender({
|
|
28
|
-
currentTask,
|
|
29
|
-
}) }));
|
|
30
|
-
}
|
|
31
|
-
return (_jsxs("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: [_jsx("p", { className: "tasklabel", children: currentTask.task && currentTask.task }), _jsx("p", { className: "taskhour", children: currentTask.taskStart &&
|
|
32
|
-
currentTask.taskEnd &&
|
|
33
|
-
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${millisecondsToDate(currentTask.taskEnd).formattedDate}` })] }));
|
|
34
|
-
};
|
|
35
|
-
export default memo(TaskContainer);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { millisecondsToDate } from "../../lib/utils";
|
|
4
|
+
const TaskContainer = ({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }) => {
|
|
5
|
+
const handleDragStart = (event) => {
|
|
6
|
+
if (!handleDragTask)
|
|
7
|
+
return;
|
|
8
|
+
event.dataTransfer.effectAllowed = "move";
|
|
9
|
+
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
10
|
+
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
11
|
+
window.sessionStorage.setItem("calendardragtaskStart", `${currentTask.taskStart}`);
|
|
12
|
+
window.sessionStorage.setItem("calendardragtaskEnd", `${currentTask.taskEnd}`);
|
|
13
|
+
window.sessionStorage.setItem("calendardragdayIndex", `${currentTask.dayIndex}`);
|
|
14
|
+
handleDragTask(event, currentTask);
|
|
15
|
+
};
|
|
16
|
+
const handleDragEnd = (event) => {
|
|
17
|
+
if (!handleDragTaskEnd)
|
|
18
|
+
return;
|
|
19
|
+
handleDragTaskEnd(event);
|
|
20
|
+
};
|
|
21
|
+
const handleClick = () => {
|
|
22
|
+
if (!handleClickTask)
|
|
23
|
+
return;
|
|
24
|
+
handleClickTask(currentTask);
|
|
25
|
+
};
|
|
26
|
+
if (taskRender) {
|
|
27
|
+
return (_jsx("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: taskRender({
|
|
28
|
+
currentTask,
|
|
29
|
+
}) }));
|
|
30
|
+
}
|
|
31
|
+
return (_jsxs("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: [_jsx("p", { className: "tasklabel", children: currentTask.task && currentTask.task }), _jsx("p", { className: "taskhour", children: currentTask.taskStart &&
|
|
32
|
+
currentTask.taskEnd &&
|
|
33
|
+
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${millisecondsToDate(currentTask.taskEnd).formattedDate}` })] }));
|
|
34
|
+
};
|
|
35
|
+
export default memo(TaskContainer);
|
|
@@ -10,7 +10,6 @@ const TaskContainer = ({
|
|
|
10
10
|
className,
|
|
11
11
|
currentTask,
|
|
12
12
|
handleClickTask,
|
|
13
|
-
|
|
14
13
|
}: TaskContainerPropsType) => {
|
|
15
14
|
|
|
16
15
|
const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => {
|
|
@@ -72,6 +71,7 @@ const TaskContainer = ({
|
|
|
72
71
|
onDragEnd={handleDragEnd}
|
|
73
72
|
>
|
|
74
73
|
<p className="tasklabel">{currentTask.task && currentTask.task}</p>
|
|
74
|
+
|
|
75
75
|
<p className="taskhour">
|
|
76
76
|
{currentTask.taskStart &&
|
|
77
77
|
currentTask.taskEnd &&
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FixedSizeList as List } from "react-window";
|
|
3
|
+
import TaskContainer from "../TaskContainer";
|
|
4
|
+
const TaskList = ({ tasks }) => (_jsx(List, { height: 300, itemCount: tasks.length, itemSize: 50, width: "100%", children: ({ index, style }) => (_jsx("div", { style: style, children: _jsx(TaskContainer, { currentTask: tasks[index] }, tasks[index].id) })) }));
|
|
5
|
+
export default TaskList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FixedSizeList as List } from "react-window";
|
|
2
|
+
import TaskContainer from "../TaskContainer";
|
|
3
|
+
import { TaskFeildsType } from "../../definitions";
|
|
4
|
+
|
|
5
|
+
const TaskList = ({ tasks }: { tasks: TaskFeildsType[] }) => (
|
|
6
|
+
<List
|
|
7
|
+
height={300}
|
|
8
|
+
itemCount={tasks.length}
|
|
9
|
+
itemSize={50}
|
|
10
|
+
width="100%"
|
|
11
|
+
>
|
|
12
|
+
{({ index, style }) => (
|
|
13
|
+
<div style={style}>
|
|
14
|
+
<TaskContainer key={tasks[index].id} currentTask={tasks[index]} />
|
|
15
|
+
</div>
|
|
16
|
+
)}
|
|
17
|
+
</List>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default TaskList;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const CalendarContext = createContext({
|
|
4
|
-
groups: [],
|
|
5
|
-
weekOffset: 0,
|
|
6
|
-
date: new Date()
|
|
7
|
-
});
|
|
8
|
-
const CalendarContextProvider = ({ groups, weekOffset, children, date }) => {
|
|
9
|
-
return (_jsx(CalendarContext.Provider, { value: { groups, weekOffset, date }, children: children }));
|
|
10
|
-
};
|
|
11
|
-
export const useCalendarContext = () => useContext(CalendarContext);
|
|
12
|
-
export default CalendarContextProvider;
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const CalendarContext = createContext({
|
|
4
|
+
groups: [],
|
|
5
|
+
weekOffset: 0,
|
|
6
|
+
date: new Date()
|
|
7
|
+
});
|
|
8
|
+
const CalendarContextProvider = ({ groups, weekOffset, children, date }) => {
|
|
9
|
+
return (_jsx(CalendarContext.Provider, { value: { groups, weekOffset, date }, children: children }));
|
|
10
|
+
};
|
|
11
|
+
export const useCalendarContext = () => useContext(CalendarContext);
|
|
12
|
+
export default CalendarContextProvider;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { GroupPropsType } from "../definitions";
|
|
3
|
+
|
|
4
|
+
|
|
3
5
|
type CalendarContextProviderPropsType = {
|
|
4
6
|
children: React.ReactNode;
|
|
5
7
|
groups: GroupPropsType[];
|
|
@@ -30,5 +32,7 @@ const CalendarContextProvider = ({
|
|
|
30
32
|
</CalendarContext.Provider>
|
|
31
33
|
);
|
|
32
34
|
};
|
|
35
|
+
|
|
36
|
+
|
|
33
37
|
export const useCalendarContext = () => useContext(CalendarContext);
|
|
34
38
|
export default CalendarContextProvider;
|
package/definitions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|