react-weekly-planning 1.0.28 → 1.0.29
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 +3 -1
- package/components/AddTask/index.js +17 -0
- package/components/AddTask/index.tsx +39 -0
- package/components/CalendarTable.js +48 -0
- package/components/CalendarTable.tsx +219 -0
- package/components/DayContainer/index.js +15 -0
- package/components/DayContainer/index.tsx +35 -0
- package/components/GroupContainer/index.js +15 -0
- package/components/GroupContainer/index.tsx +41 -0
- package/components/GroupsHeadContainer/index.js +9 -0
- package/components/GroupsHeadContainer/index.tsx +19 -0
- package/components/SumHoursContainer/index.js +15 -0
- package/components/SumHoursContainer/index.tsx +38 -0
- package/components/SumHoursHead/index.js +9 -0
- package/components/SumHoursHead/index.tsx +22 -0
- package/components/TaskContainer/index.js +35 -0
- package/components/TaskContainer/index.tsx +86 -0
- package/definitions/index.ts +24 -3
- package/hooks/useCalendarDateState.js +13 -0
- package/hooks/useCalendarDateState.ts +24 -0
- package/index.js +4 -200
- package/index.tsx +6 -568
- package/lib/slyles.js +21 -0
- package/lib/slyles.ts +25 -0
- package/lib/utils.js +98 -271
- package/lib/utils.ts +130 -378
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ It is possible to use either Weekoffset or Date, or even both simultaneously.
|
|
|
85
85
|
|
|
86
86
|
**Example**:
|
|
87
87
|
```jsx
|
|
88
|
-
import {getSavedTasks} from "react-weekly-planning";
|
|
88
|
+
import {getSavedTasks} from "react-weekly-planning/lib/utils";
|
|
89
89
|
const [tasks,setTasks]=useState([])
|
|
90
90
|
|
|
91
91
|
useEffect(()=>{
|
|
@@ -173,6 +173,7 @@ Props for the Calendar component.
|
|
|
173
173
|
|
|
174
174
|
**Example**:
|
|
175
175
|
```javascript
|
|
176
|
+
import {updateOffsetWithDateCalendar} from "react-weekly-planning/lib/utils";
|
|
176
177
|
const offset = updateOffsetWithDateCalendar(new Date());
|
|
177
178
|
console.log(offset); // Logs the week offset for the given date
|
|
178
179
|
```
|
|
@@ -186,6 +187,7 @@ Props for the Calendar component.
|
|
|
186
187
|
|
|
187
188
|
**Example**:
|
|
188
189
|
```javascript
|
|
190
|
+
import {millisecondsToHours} from "react-weekly-planning/lib/utils";
|
|
189
191
|
const formattedTime = millisecondsToHours(1716905215397);
|
|
190
192
|
console.log(formattedTime); // Logs the formatted time for 14h06
|
|
191
193
|
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const AddTask = ({ currentGroup, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }) => {
|
|
4
|
+
if (addTaskRender) {
|
|
5
|
+
return (_jsx(_Fragment, { children: addTaskRender({
|
|
6
|
+
currentGroup,
|
|
7
|
+
dayInfo,
|
|
8
|
+
}) }));
|
|
9
|
+
}
|
|
10
|
+
const handleClick = () => {
|
|
11
|
+
if (!handleAddTask)
|
|
12
|
+
return;
|
|
13
|
+
handleAddTask(currentGroup, dayInfo);
|
|
14
|
+
};
|
|
15
|
+
return (_jsx("div", { onClick: handleClick, style: addTaskStyle, className: `addPlanStyle ${addTaskClassName}`, children: "+" }));
|
|
16
|
+
};
|
|
17
|
+
export default memo(AddTask);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { AddTaskPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const AddTask = ({
|
|
5
|
+
currentGroup,
|
|
6
|
+
handleAddTask,
|
|
7
|
+
addTaskRender,
|
|
8
|
+
dayInfo,
|
|
9
|
+
addTaskStyle,
|
|
10
|
+
addTaskClassName,
|
|
11
|
+
}: AddTaskPropsType) => {
|
|
12
|
+
if (addTaskRender) {
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{addTaskRender({
|
|
16
|
+
currentGroup,
|
|
17
|
+
dayInfo,
|
|
18
|
+
})}
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleClick = () => {
|
|
24
|
+
if (!handleAddTask) return;
|
|
25
|
+
handleAddTask(currentGroup, dayInfo);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
onClick={handleClick}
|
|
31
|
+
style={addTaskStyle}
|
|
32
|
+
className={`addPlanStyle ${addTaskClassName}`}
|
|
33
|
+
>
|
|
34
|
+
+
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default memo(AddTask);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import GroupContainer from "./GroupContainer";
|
|
4
|
+
import GroupsHeadContainer from "./GroupsHeadContainer";
|
|
5
|
+
import { groupTdStyle, theadTrStyle } from "../lib/slyles";
|
|
6
|
+
import DayContainer from "./DayContainer";
|
|
7
|
+
import SumHoursHead from "./SumHoursHead";
|
|
8
|
+
import { compareWeekOffset, getSessionStorageRecordForDragAndDrop, saveTasksToLocalStorage, sumHoursByGroups, } from "../lib/utils";
|
|
9
|
+
import TaskContainer from "./TaskContainer";
|
|
10
|
+
import AddTask from "./AddTask";
|
|
11
|
+
import SumHoursContainer from "./SumHoursContainer";
|
|
12
|
+
import { memo, useCallback, useEffect } from "react";
|
|
13
|
+
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
14
|
+
function CalendarTable(props) {
|
|
15
|
+
var _a;
|
|
16
|
+
const { dailyHours, weekDays } = useCalendarDateState(props.date, props.weekOffset);
|
|
17
|
+
const handleDragOver = useCallback((event) => {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
}, []);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
saveTasksToLocalStorage(props.tasks);
|
|
22
|
+
}, [props.tasks]);
|
|
23
|
+
return (_jsxs("table", { className: `planningCalendar ${props.className}`, style: Object.assign({}, props.style), children: [_jsx("thead", { children: _jsxs("tr", { className: `${props.rowsClassName}`, style: Object.assign(Object.assign({}, theadTrStyle), props.rowsStyle), children: [_jsx("th", { className: "dayTh", children: _jsx(GroupsHeadContainer, { className: `${props.groupHeadContainerClassName}`, style: props.groupHeadContainerStyle, groupsHeadRender: props.groupsHeadRender }) }), weekDays.map((day, i) => (_jsx("th", { className: `${props.daysColsClassName}`, style: Object.assign({}, props.daysColsStyle), children: _jsx(DayContainer, { style: props.dayStyle, className: props.dayClassName, dayIndex: i, dayRender: props.dayRender, day: day.day, dayOfTheMonth: day.dayOfTheMonth, dayMonth: day.dayMonth, dayYear: day.dayYear }) }, i))), _jsx("th", { className: "totalTh", children: _jsx(SumHoursHead, { className: props.sumHoursHeadClassName, style: props.sumHoursHeadStyle, sumHoursHeadRender: props.sumHoursHeadRender }) })] }, "") }), _jsx("tbody", { children: (_a = props.groups) === null || _a === void 0 ? void 0 : _a.map((group, i) => (_jsxs("tr", { className: `${props.rowsClassName}`, style: Object.assign({}, props.rowsStyle), children: [_jsx("td", { className: `${props.groupsColsClassName}`, style: Object.assign(Object.assign({}, groupTdStyle), props.groupsColsStyle), children: _jsx(GroupContainer, { style: props.groupStyle, className: props.groupClassName, groupRender: props.groupRender, currentGroup: group, handleClickGroup: props.handleClickGroup }) }, i), dailyHours.map((_, positionDay) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_jsx("td", { onDragOver: handleDragOver, onDrop: (event) => {
|
|
26
|
+
if (!props.handleDropTask || !props.tasks)
|
|
27
|
+
return;
|
|
28
|
+
const dropInfo = getSessionStorageRecordForDragAndDrop(props.tasks, positionDay, group.id);
|
|
29
|
+
if (!dropInfo)
|
|
30
|
+
return;
|
|
31
|
+
props.handleDropTask(event, dropInfo.taskDropStart, dropInfo.taskDropEnd, dropInfo.taskDropDate, group.id, positionDay, dropInfo.newTask, dropInfo.newTasks);
|
|
32
|
+
}, id: `td-${group.id}day-i`, children: _jsxs("div", { style: {
|
|
33
|
+
display: "flex",
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: "100%",
|
|
36
|
+
flexDirection: "column",
|
|
37
|
+
padding: "5px",
|
|
38
|
+
}, children: [_jsx(_Fragment, { children: (_a = props.tasks) === null || _a === void 0 ? void 0 : _a.filter((task) => task.dayIndex === positionDay &&
|
|
39
|
+
task.groupId === group.id &&
|
|
40
|
+
compareWeekOffset(props.date, props.weekOffset || 0, task.taskDate)).sort((a, b) => a.taskStart - b.taskStart).map((task, taskKey) => {
|
|
41
|
+
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`));
|
|
42
|
+
}) }), _jsx(AddTask, { addTaskStyle: props.addTaskStyle, addTaskClassName: props.addTaskClassName, currentGroup: group, dayInfo: dailyHours[positionDay], addTaskRender: props.addTaskRender, handleAddTask: props.handleAddTask })] }, positionDay) }, `td-${group.id}day-i${positionDay}`));
|
|
43
|
+
}), _jsx("td", { children: _jsx(SumHoursContainer, { groupId: group.id, tasks: props.tasks, weekOffset: props.weekOffset || 0, calendarDate: props.date, sumHoursRender: props.sumHoursRender, sumHoursByGroups: sumHoursByGroups(group.id, props.tasks, props.weekOffset || 0, props.date), className: props.sumHoursContainerClassName, style: props.sumHoursContainerStyle }) }, `${i}sumHours`)] }, `${i} tr`))) })] }));
|
|
44
|
+
}
|
|
45
|
+
export default memo(CalendarTable, (prevProps, nextProps) => prevProps.tasks === nextProps.tasks &&
|
|
46
|
+
prevProps.date === nextProps.date &&
|
|
47
|
+
prevProps.groups === nextProps.groups &&
|
|
48
|
+
prevProps.weekOffset === nextProps.weekOffset);
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { CalendarPropsType, CalendarTablePropsType } from "../definitions";
|
|
4
|
+
import GroupContainer from "./GroupContainer";
|
|
5
|
+
import GroupsHeadContainer from "./GroupsHeadContainer";
|
|
6
|
+
|
|
7
|
+
import { groupTdStyle, theadTrStyle } from "../lib/slyles";
|
|
8
|
+
import DayContainer from "./DayContainer";
|
|
9
|
+
import SumHoursHead from "./SumHoursHead";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
compareWeekOffset,
|
|
13
|
+
getSessionStorageRecordForDragAndDrop,
|
|
14
|
+
saveTasksToLocalStorage,
|
|
15
|
+
sumHoursByGroups,
|
|
16
|
+
} from "../lib/utils";
|
|
17
|
+
|
|
18
|
+
import TaskContainer from "./TaskContainer";
|
|
19
|
+
import AddTask from "./AddTask";
|
|
20
|
+
import SumHoursContainer from "./SumHoursContainer";
|
|
21
|
+
import { memo, useCallback, useEffect } from "react";
|
|
22
|
+
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
23
|
+
|
|
24
|
+
function CalendarTable(props: CalendarTablePropsType) {
|
|
25
|
+
|
|
26
|
+
const { dailyHours, weekDays } = useCalendarDateState(
|
|
27
|
+
props.date,
|
|
28
|
+
props.weekOffset
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const handleDragOver = useCallback(
|
|
32
|
+
(event: React.DragEvent<HTMLTableDataCellElement>) => {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
},
|
|
35
|
+
[]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
saveTasksToLocalStorage(props.tasks);
|
|
40
|
+
}, [props.tasks]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<table
|
|
44
|
+
className={`planningCalendar ${props.className}`}
|
|
45
|
+
style={{ ...props.style }}
|
|
46
|
+
>
|
|
47
|
+
<thead>
|
|
48
|
+
<tr
|
|
49
|
+
className={`${props.rowsClassName}`}
|
|
50
|
+
style={{ ...theadTrStyle, ...props.rowsStyle }}
|
|
51
|
+
key=""
|
|
52
|
+
>
|
|
53
|
+
<th className="dayTh">
|
|
54
|
+
<GroupsHeadContainer
|
|
55
|
+
className={`${props.groupHeadContainerClassName}`}
|
|
56
|
+
style={props.groupHeadContainerStyle}
|
|
57
|
+
groupsHeadRender={props.groupsHeadRender}
|
|
58
|
+
/>
|
|
59
|
+
</th>
|
|
60
|
+
{weekDays.map((day, i) => (
|
|
61
|
+
<th
|
|
62
|
+
key={i}
|
|
63
|
+
className={`${props.daysColsClassName}`}
|
|
64
|
+
style={{ ...props.daysColsStyle }}
|
|
65
|
+
>
|
|
66
|
+
<DayContainer
|
|
67
|
+
style={props.dayStyle}
|
|
68
|
+
className={props.dayClassName}
|
|
69
|
+
dayIndex={i}
|
|
70
|
+
dayRender={props.dayRender}
|
|
71
|
+
day={day.day}
|
|
72
|
+
dayOfTheMonth={day.dayOfTheMonth}
|
|
73
|
+
dayMonth={day.dayMonth}
|
|
74
|
+
dayYear={day.dayYear}
|
|
75
|
+
/>
|
|
76
|
+
</th>
|
|
77
|
+
))}
|
|
78
|
+
<th className="totalTh">
|
|
79
|
+
<SumHoursHead
|
|
80
|
+
className={props.sumHoursHeadClassName}
|
|
81
|
+
style={props.sumHoursHeadStyle}
|
|
82
|
+
sumHoursHeadRender={props.sumHoursHeadRender}
|
|
83
|
+
/>
|
|
84
|
+
</th>
|
|
85
|
+
</tr>
|
|
86
|
+
</thead>
|
|
87
|
+
<tbody>
|
|
88
|
+
{props.groups?.map((group, i) => (
|
|
89
|
+
<tr
|
|
90
|
+
key={`${i} tr`}
|
|
91
|
+
className={`${props.rowsClassName}`}
|
|
92
|
+
style={{ ...props.rowsStyle }}
|
|
93
|
+
>
|
|
94
|
+
<td
|
|
95
|
+
className={`${props.groupsColsClassName}`}
|
|
96
|
+
key={i}
|
|
97
|
+
style={{ ...groupTdStyle, ...props.groupsColsStyle }}
|
|
98
|
+
>
|
|
99
|
+
<GroupContainer
|
|
100
|
+
style={props.groupStyle}
|
|
101
|
+
className={props.groupClassName}
|
|
102
|
+
groupRender={props.groupRender}
|
|
103
|
+
currentGroup={group}
|
|
104
|
+
handleClickGroup={props.handleClickGroup}
|
|
105
|
+
/>
|
|
106
|
+
</td>
|
|
107
|
+
{dailyHours.map((_, positionDay) => (
|
|
108
|
+
<td
|
|
109
|
+
key={`td-${group.id}day-i${positionDay}`}
|
|
110
|
+
onDragOver={handleDragOver}
|
|
111
|
+
onDrop={(event) => {
|
|
112
|
+
if (!props.handleDropTask || !props.tasks) return;
|
|
113
|
+
const dropInfo = getSessionStorageRecordForDragAndDrop(
|
|
114
|
+
props.tasks,
|
|
115
|
+
positionDay,
|
|
116
|
+
group.id
|
|
117
|
+
);
|
|
118
|
+
if (!dropInfo) return;
|
|
119
|
+
props.handleDropTask(
|
|
120
|
+
event,
|
|
121
|
+
dropInfo.taskDropStart,
|
|
122
|
+
dropInfo.taskDropEnd,
|
|
123
|
+
dropInfo.taskDropDate,
|
|
124
|
+
group.id,
|
|
125
|
+
positionDay,
|
|
126
|
+
dropInfo.newTask,
|
|
127
|
+
dropInfo.newTasks
|
|
128
|
+
);
|
|
129
|
+
}}
|
|
130
|
+
id={`td-${group.id}day-i`}
|
|
131
|
+
>
|
|
132
|
+
<div
|
|
133
|
+
key={positionDay}
|
|
134
|
+
style={{
|
|
135
|
+
display: "flex",
|
|
136
|
+
width: "100%",
|
|
137
|
+
height: "100%",
|
|
138
|
+
flexDirection: "column",
|
|
139
|
+
padding: "5px",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<>
|
|
143
|
+
{props.tasks
|
|
144
|
+
?.filter(
|
|
145
|
+
(task) =>
|
|
146
|
+
task.dayIndex === positionDay &&
|
|
147
|
+
task.groupId === group.id &&
|
|
148
|
+
compareWeekOffset(
|
|
149
|
+
props.date,
|
|
150
|
+
props.weekOffset || 0,
|
|
151
|
+
task.taskDate
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
.sort((a, b) => a.taskStart - b.taskStart)
|
|
155
|
+
.map((task, taskKey) => {
|
|
156
|
+
return (
|
|
157
|
+
<TaskContainer
|
|
158
|
+
key={`${taskKey} task`}
|
|
159
|
+
handleDragTask={props.handleDragTask}
|
|
160
|
+
taskRender={props.taskRender}
|
|
161
|
+
handleDragTaskEnd={props.handleDragTaskEnd}
|
|
162
|
+
style={props.taskContainerStyle}
|
|
163
|
+
className={`${props.taskContainerClassName}`}
|
|
164
|
+
currentTask={task}
|
|
165
|
+
handleClickTask={props.handleClickTask}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
})}
|
|
169
|
+
</>
|
|
170
|
+
|
|
171
|
+
<AddTask
|
|
172
|
+
addTaskStyle={props.addTaskStyle}
|
|
173
|
+
addTaskClassName={props.addTaskClassName}
|
|
174
|
+
currentGroup={group}
|
|
175
|
+
dayInfo={dailyHours[positionDay]}
|
|
176
|
+
addTaskRender={props.addTaskRender}
|
|
177
|
+
handleAddTask={props.handleAddTask}
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</td>
|
|
181
|
+
))}
|
|
182
|
+
<td key={`${i}sumHours`}>
|
|
183
|
+
<SumHoursContainer
|
|
184
|
+
groupId={group.id}
|
|
185
|
+
tasks={props.tasks}
|
|
186
|
+
weekOffset={props.weekOffset || 0}
|
|
187
|
+
calendarDate={props.date}
|
|
188
|
+
sumHoursRender={props.sumHoursRender}
|
|
189
|
+
sumHoursByGroups={sumHoursByGroups(
|
|
190
|
+
group.id,
|
|
191
|
+
props.tasks,
|
|
192
|
+
props.weekOffset || 0,
|
|
193
|
+
props.date
|
|
194
|
+
)}
|
|
195
|
+
className={props.sumHoursContainerClassName}
|
|
196
|
+
style={props.sumHoursContainerStyle}
|
|
197
|
+
/>
|
|
198
|
+
</td>
|
|
199
|
+
</tr>
|
|
200
|
+
))}
|
|
201
|
+
</tbody>
|
|
202
|
+
</table>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export default memo(
|
|
207
|
+
|
|
208
|
+
CalendarTable,
|
|
209
|
+
(
|
|
210
|
+
prevProps: Readonly<CalendarPropsType>,
|
|
211
|
+
nextProps: Readonly<CalendarPropsType>
|
|
212
|
+
) =>
|
|
213
|
+
|
|
214
|
+
prevProps.tasks === nextProps.tasks &&
|
|
215
|
+
prevProps.date === nextProps.date &&
|
|
216
|
+
prevProps.groups === nextProps.groups &&
|
|
217
|
+
prevProps.weekOffset === nextProps.weekOffset
|
|
218
|
+
|
|
219
|
+
);
|
|
@@ -0,0 +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);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { DayPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const DayContainer = ({
|
|
5
|
+
dayIndex,
|
|
6
|
+
dayOfTheMonth,
|
|
7
|
+
day,
|
|
8
|
+
dayMonth,
|
|
9
|
+
dayYear,
|
|
10
|
+
dayRender,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
}: DayPropsType) => {
|
|
14
|
+
if (dayRender) {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{dayRender({
|
|
18
|
+
dayIndex,
|
|
19
|
+
day,
|
|
20
|
+
dayOfTheMonth,
|
|
21
|
+
dayMonth,
|
|
22
|
+
dayYear,
|
|
23
|
+
})}
|
|
24
|
+
</>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className={`${className}`} style={style}>
|
|
30
|
+
{`${day}. ${dayOfTheMonth}`}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default memo(DayContainer);
|
|
@@ -0,0 +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);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { GroupPropsType } from "../../definitions";
|
|
3
|
+
import { groupContainerStyle } from "../../lib/slyles";
|
|
4
|
+
|
|
5
|
+
const GroupContainer = ({
|
|
6
|
+
className,
|
|
7
|
+
style,
|
|
8
|
+
groupRender,
|
|
9
|
+
currentGroup,
|
|
10
|
+
handleClickGroup,
|
|
11
|
+
}: GroupPropsType) => {
|
|
12
|
+
if (groupRender) {
|
|
13
|
+
return <>{groupRender({ currentGroup })}</>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
if (!handleClickGroup) return;
|
|
18
|
+
handleClickGroup(currentGroup);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
onClick={handleClick}
|
|
24
|
+
className={`${className}`}
|
|
25
|
+
style={{ ...groupContainerStyle, ...style }}
|
|
26
|
+
>
|
|
27
|
+
{currentGroup.imageUrl && (
|
|
28
|
+
<img
|
|
29
|
+
width={30}
|
|
30
|
+
height={30}
|
|
31
|
+
src={currentGroup.imageUrl}
|
|
32
|
+
alt="groupimg"
|
|
33
|
+
/>
|
|
34
|
+
)}
|
|
35
|
+
|
|
36
|
+
<label>{currentGroup.label && currentGroup.label}</label>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default memo(GroupContainer);
|
|
@@ -0,0 +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);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { GroupsHeadContainerPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const GroupsHeadContainer = ({
|
|
5
|
+
groupsHeadRender,
|
|
6
|
+
style,
|
|
7
|
+
className,
|
|
8
|
+
}: GroupsHeadContainerPropsType) => {
|
|
9
|
+
if (groupsHeadRender) {
|
|
10
|
+
return <>{groupsHeadRender()}</>;
|
|
11
|
+
}
|
|
12
|
+
return (
|
|
13
|
+
<div className={`${className}`} style={style}>
|
|
14
|
+
WeeklyCalendar
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default memo(GroupsHeadContainer);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const SumHoursContainer = ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, sumHoursRender, className, style, }) => {
|
|
4
|
+
if (sumHoursRender) {
|
|
5
|
+
return (_jsx(_Fragment, { children: sumHoursRender({
|
|
6
|
+
groupId,
|
|
7
|
+
tasks,
|
|
8
|
+
weekOffset,
|
|
9
|
+
calendarDate,
|
|
10
|
+
sumHoursByGroups,
|
|
11
|
+
}) }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx("div", { style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), className: `${className}`, children: sumHoursByGroups }));
|
|
14
|
+
};
|
|
15
|
+
export default memo(SumHoursContainer);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { SumHoursContainerPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const SumHoursContainer = ({
|
|
5
|
+
groupId,
|
|
6
|
+
tasks,
|
|
7
|
+
weekOffset,
|
|
8
|
+
calendarDate,
|
|
9
|
+
sumHoursByGroups,
|
|
10
|
+
sumHoursRender,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
}: SumHoursContainerPropsType) => {
|
|
14
|
+
if (sumHoursRender) {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{sumHoursRender({
|
|
18
|
+
groupId,
|
|
19
|
+
tasks,
|
|
20
|
+
weekOffset,
|
|
21
|
+
calendarDate,
|
|
22
|
+
sumHoursByGroups,
|
|
23
|
+
})}
|
|
24
|
+
</>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
31
|
+
className={`${className}`}
|
|
32
|
+
>
|
|
33
|
+
{sumHoursByGroups}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default memo(SumHoursContainer);
|
|
@@ -0,0 +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);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { SumHoursHeadContainerPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const SumHoursHead = ({
|
|
5
|
+
sumHoursHeadRender,
|
|
6
|
+
className,
|
|
7
|
+
style,
|
|
8
|
+
}: SumHoursHeadContainerPropsType) => {
|
|
9
|
+
if (sumHoursHeadRender) {
|
|
10
|
+
return <>{sumHoursHeadRender()}</>;
|
|
11
|
+
}
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={`${className}`}
|
|
15
|
+
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
16
|
+
>
|
|
17
|
+
Hours
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default memo(SumHoursHead);
|
|
@@ -0,0 +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);
|