react-weekly-planning 1.0.0
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/LICENSE +21 -0
- package/README.md +160 -0
- package/__tests__/page.test.js +46 -0
- package/__tests__/page.test.tsx +57 -0
- package/contexts/CalendarContext.js +12 -0
- package/contexts/CalendarContext.tsx +34 -0
- package/definition.txt +318 -0
- package/definitions/index.js +1 -0
- package/definitions/index.ts +446 -0
- package/docs/global.html +4983 -0
- package/docs/index.html +473 -0
- package/docs/index.ts.html +567 -0
- package/docs/scripts/app.min.js +1 -0
- package/docs/scripts/linenumber.js +26 -0
- package/docs/scripts/search.js +39 -0
- package/docs/styles/app.min.css +1 -0
- package/docs/styles/iframe.css +13 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/docs/styles/reset.css +44 -0
- package/index.js +224 -0
- package/index.tsx +591 -0
- package/jest.config.js +9 -0
- package/jest.config.ts +10 -0
- package/jsdoc.json +26 -0
- package/lib/utils.js +437 -0
- package/lib/utils.ts +598 -0
- package/myJsDoc.js +0 -0
- package/out/index.html +129 -0
- package/out/scripts/app.min.js +1 -0
- package/out/scripts/linenumber.js +26 -0
- package/out/scripts/search.js +39 -0
- package/out/styles/app.min.css +1 -0
- package/out/styles/iframe.css +13 -0
- package/out/styles/prettify-jsdoc.css +111 -0
- package/out/styles/prettify-tomorrow.css +132 -0
- package/out/styles/reset.css +44 -0
- package/package.json +45 -0
- package/style.css +51 -0
package/index.tsx
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
import {
|
|
3
|
+
AddTaskPropsType,
|
|
4
|
+
CalendarPropsType,
|
|
5
|
+
DayPropsType,
|
|
6
|
+
GroupPropsType,
|
|
7
|
+
StyleType,
|
|
8
|
+
TaskContainerPropsType,
|
|
9
|
+
GroupsHeadContainerPropsType,
|
|
10
|
+
SumHoursContainerPropsType,
|
|
11
|
+
SumHoursHeadContainerPropsType,
|
|
12
|
+
} from "./definitions";
|
|
13
|
+
import {
|
|
14
|
+
getWeekDays,
|
|
15
|
+
getDayHourly,
|
|
16
|
+
calculerEcartSemaine,
|
|
17
|
+
getSessionStorageRecordForDragAndDrop,
|
|
18
|
+
sumHoursByGroups,
|
|
19
|
+
millisecondsToDate,
|
|
20
|
+
compareWeekOffset,
|
|
21
|
+
} from "./lib/utils";
|
|
22
|
+
|
|
23
|
+
const tableStyle: StyleType = {
|
|
24
|
+
width: "100%",
|
|
25
|
+
height: "150px",
|
|
26
|
+
borderRadius: "0.5rem",
|
|
27
|
+
zIndex: 10,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const trStyle: StyleType = {
|
|
31
|
+
color: "#0f5173",
|
|
32
|
+
fontWeight: "300",
|
|
33
|
+
position: "sticky",
|
|
34
|
+
top: 0,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const thStyle: StyleType = {
|
|
38
|
+
color: "#0f5173",
|
|
39
|
+
paddingLeft: "5px",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const weekDayThStyle: StyleType = {};
|
|
43
|
+
|
|
44
|
+
const totalThStyle: StyleType = {
|
|
45
|
+
width: "40px",
|
|
46
|
+
textAlign: "right",
|
|
47
|
+
paddingRight: "2px",
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const tdStyle: StyleType = {
|
|
51
|
+
height: "auto",
|
|
52
|
+
width: "150px",
|
|
53
|
+
};
|
|
54
|
+
const tableTrStyle: StyleType = {
|
|
55
|
+
borderBottom: "1.5px solid #0f52737e",
|
|
56
|
+
// backgroundColor: "#f2f8fb",
|
|
57
|
+
padding: "2px",
|
|
58
|
+
};
|
|
59
|
+
const tableTdStyle: StyleType = {
|
|
60
|
+
borderLeft: "0.74px solid rgba(198, 219, 225, 0.68)",
|
|
61
|
+
borderRight: "0.74px solid rgba(198, 219, 225, 0.68)",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const groupContainerStyle: StyleType = {
|
|
65
|
+
width: "100%",
|
|
66
|
+
height: "100%",
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
justifyContent: "space-between",
|
|
70
|
+
gap: "0.75rem", // Correspond à gap-3
|
|
71
|
+
padding: "0.75rem", // Correspond à p-3
|
|
72
|
+
color: "#0f5173",
|
|
73
|
+
cursor: "pointer",
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Calendar component to display tasks and groups in a weekly view.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} props - The props for the Calendar component.
|
|
80
|
+
* @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
|
|
81
|
+
* @param {string} [props.className] - Additional class names for the calendar component.
|
|
82
|
+
* @param {Array} props.groups - Array of group data to be displayed in the calendar.
|
|
83
|
+
* @param {number} [props.weekOffset] - Offset for the week (e.g., -1 for last week, 0 for current week, 1 for next week).
|
|
84
|
+
* @param {Date} props.date - The current date to display in the calendar.
|
|
85
|
+
* @param {Function} [props.groupRender] - Custom render function for a group.
|
|
86
|
+
* @param {Function} [props.dayRender] - Custom render function for a day.
|
|
87
|
+
* @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
|
|
88
|
+
* @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
|
|
89
|
+
* @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
|
|
90
|
+
* @param {Function} [props.addTaskRender] - Custom render function for the add task button.
|
|
91
|
+
* @param {Function} [props.handleAddTask] - Handler function for adding a new task.
|
|
92
|
+
* @param {string} [props.dayClassName] - Additional class names for the days.
|
|
93
|
+
* @param {React.CSSProperties} [props.dayStyle] - Additional styles for the days.
|
|
94
|
+
* @param {string} [props.groupClassName] - Additional class names for the groups.
|
|
95
|
+
* @param {React.CSSProperties} [props.groupStyle] - Additional styles for the groups.
|
|
96
|
+
* @param {string} [props.addTaskClassName] - Additional class names for the add task button.
|
|
97
|
+
* @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add task button.
|
|
98
|
+
* @param {Array} props.tasks - Array of tasks to be displayed in the calendar.
|
|
99
|
+
* @param {Function} [props.handleDragTask] - Handler function for dragging a task.
|
|
100
|
+
* @param {Function} [props.handleDropTask] - Handler function for dropping a task.
|
|
101
|
+
* @param {Function} [props.taskRender] - Custom render function for a task.
|
|
102
|
+
* @param {Function} [props.groupsHeadRender] - Custom render function for the groups header.
|
|
103
|
+
* @param {Function} [props.sumHoursRender] - Custom render function for the sum of hours.
|
|
104
|
+
* @param {Function} [props.sumHoursHeadRender] - Custom render function for the sum of hours header.
|
|
105
|
+
* @param {Function} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
|
|
106
|
+
* @param {string} [props.rowsClassName] - Additional class names for the rows.
|
|
107
|
+
* @param {string} [props.daysColsClassName] - Additional class names for the day columns.
|
|
108
|
+
* @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum hours container.
|
|
109
|
+
* @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum hours container.
|
|
110
|
+
* @param {string} [props.groupHeadContainerClassName] - Additional class names for the group head container.
|
|
111
|
+
* @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group head container.
|
|
112
|
+
* @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
|
|
113
|
+
* @param {string} [props.taskContainerClassName] - Additional class names for the task container.
|
|
114
|
+
* @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
|
|
115
|
+
* @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum hours header.
|
|
116
|
+
* @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum hours header.
|
|
117
|
+
* @param {Function} [props.handleClickGroup] - Handler function for clicking a group.
|
|
118
|
+
* @param {Function} [props.handleClickTask] - Handler function for clicking a task.
|
|
119
|
+
* @returns {JSX.Element} The rendered Calendar component.
|
|
120
|
+
*/
|
|
121
|
+
const Calendar = ({
|
|
122
|
+
style,
|
|
123
|
+
className,
|
|
124
|
+
groups,
|
|
125
|
+
weekOffset,
|
|
126
|
+
date,
|
|
127
|
+
groupRender,
|
|
128
|
+
dayRender,
|
|
129
|
+
rowsStyle,
|
|
130
|
+
groupsColsStyle,
|
|
131
|
+
daysColsStyle,
|
|
132
|
+
addTaskRender,
|
|
133
|
+
handleAddTask,
|
|
134
|
+
dayClassName,
|
|
135
|
+
dayStyle,
|
|
136
|
+
groupClassName,
|
|
137
|
+
groupStyle,
|
|
138
|
+
addTaskClassName,
|
|
139
|
+
addTaskStyle,
|
|
140
|
+
tasks,
|
|
141
|
+
handleDragTask,
|
|
142
|
+
handleDropTask,
|
|
143
|
+
taskRender,
|
|
144
|
+
groupsHeadRender,
|
|
145
|
+
sumHoursRender,
|
|
146
|
+
sumHoursHeadRender,
|
|
147
|
+
handleDragTaskEnd,
|
|
148
|
+
rowsClassName,
|
|
149
|
+
daysColsClassName,
|
|
150
|
+
sumHoursContainerClassName,
|
|
151
|
+
sumHoursContainerStyle,
|
|
152
|
+
groupHeadContainerClassName,
|
|
153
|
+
groupHeadContainerStyle,
|
|
154
|
+
groupsColsClassName,
|
|
155
|
+
taskContainerClassName,
|
|
156
|
+
taskContainerStyle,
|
|
157
|
+
sumHoursHeadClassName,
|
|
158
|
+
sumHoursHeadStyle,
|
|
159
|
+
handleClickGroup,
|
|
160
|
+
handleClickTask,
|
|
161
|
+
}: CalendarPropsType) => {
|
|
162
|
+
const weekOffsetByDate = calculerEcartSemaine(date);
|
|
163
|
+
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
164
|
+
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
165
|
+
|
|
166
|
+
const handleDragOver = (event: React.DragEvent<HTMLTableDataCellElement>) => {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
};
|
|
169
|
+
return (
|
|
170
|
+
<table className={`${className}`} style={{ ...tableStyle, ...style }}>
|
|
171
|
+
<thead>
|
|
172
|
+
<tr
|
|
173
|
+
className={`${rowsClassName}`}
|
|
174
|
+
style={{ ...trStyle, ...tableTrStyle, ...rowsStyle }}
|
|
175
|
+
key=""
|
|
176
|
+
>
|
|
177
|
+
<th style={thStyle}>
|
|
178
|
+
<GroupsHeadContainer
|
|
179
|
+
className={`${groupHeadContainerClassName}`}
|
|
180
|
+
style={groupHeadContainerStyle}
|
|
181
|
+
groupsHeadRender={groupsHeadRender}
|
|
182
|
+
/>
|
|
183
|
+
</th>
|
|
184
|
+
{weekDays.map((day, i) => (
|
|
185
|
+
<th
|
|
186
|
+
key={i}
|
|
187
|
+
className={`${daysColsClassName}`}
|
|
188
|
+
style={{ ...weekDayThStyle, ...daysColsStyle }}
|
|
189
|
+
>
|
|
190
|
+
<DayContainer
|
|
191
|
+
style={dayStyle}
|
|
192
|
+
className={dayClassName}
|
|
193
|
+
dayIndex={i}
|
|
194
|
+
dayRender={dayRender}
|
|
195
|
+
day={day.day}
|
|
196
|
+
dayOfTheMonth={day.dayOfTheMonth}
|
|
197
|
+
dayMonth={day.dayMonth}
|
|
198
|
+
dayYear={day.dayYear}
|
|
199
|
+
/>
|
|
200
|
+
</th>
|
|
201
|
+
))}
|
|
202
|
+
<th style={totalThStyle}>
|
|
203
|
+
<SumHoursHead
|
|
204
|
+
className={sumHoursHeadClassName}
|
|
205
|
+
style={sumHoursHeadStyle}
|
|
206
|
+
sumHoursHeadRender={sumHoursHeadRender}
|
|
207
|
+
/>
|
|
208
|
+
</th>
|
|
209
|
+
</tr>
|
|
210
|
+
</thead>
|
|
211
|
+
<tbody>
|
|
212
|
+
{groups?.map((group, i) => (
|
|
213
|
+
<tr
|
|
214
|
+
key={`${i} tr`}
|
|
215
|
+
className={`${rowsClassName}`}
|
|
216
|
+
style={{ ...tableTrStyle, ...rowsStyle }}
|
|
217
|
+
>
|
|
218
|
+
<td
|
|
219
|
+
className={`${groupsColsClassName}`}
|
|
220
|
+
key={i}
|
|
221
|
+
style={{ ...tdStyle, ...tableTdStyle, ...groupsColsStyle }}
|
|
222
|
+
>
|
|
223
|
+
<GroupContainer
|
|
224
|
+
style={groupStyle}
|
|
225
|
+
className={groupClassName}
|
|
226
|
+
groupRender={groupRender}
|
|
227
|
+
currentGroup={group}
|
|
228
|
+
handleClickGroup={handleClickGroup}
|
|
229
|
+
/>
|
|
230
|
+
</td>
|
|
231
|
+
{dailyHours.map((_, positionDay) => (
|
|
232
|
+
<td
|
|
233
|
+
style={{ width: "8vw", ...tableTdStyle }}
|
|
234
|
+
key={`td-${group.id}day-i${positionDay}`}
|
|
235
|
+
onDragOver={handleDragOver}
|
|
236
|
+
onDrop={(event) => {
|
|
237
|
+
if (!handleDropTask || !tasks) return;
|
|
238
|
+
const dropInfo = getSessionStorageRecordForDragAndDrop(
|
|
239
|
+
tasks,
|
|
240
|
+
positionDay,
|
|
241
|
+
group.id
|
|
242
|
+
);
|
|
243
|
+
if (!dropInfo) return;
|
|
244
|
+
handleDropTask(
|
|
245
|
+
event,
|
|
246
|
+
dropInfo.taskDropStart,
|
|
247
|
+
dropInfo.taskDropEnd,
|
|
248
|
+
dropInfo.taskDropDate,
|
|
249
|
+
group.id,
|
|
250
|
+
positionDay,
|
|
251
|
+
dropInfo.newTask,
|
|
252
|
+
dropInfo.newTasks
|
|
253
|
+
);
|
|
254
|
+
}}
|
|
255
|
+
id={`td-${group.id}day-i`}
|
|
256
|
+
>
|
|
257
|
+
<div
|
|
258
|
+
key={positionDay}
|
|
259
|
+
style={{
|
|
260
|
+
display: "flex",
|
|
261
|
+
width: "100%",
|
|
262
|
+
height: "100%",
|
|
263
|
+
flexDirection: "column",
|
|
264
|
+
padding: "5px",
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
<>
|
|
268
|
+
{tasks
|
|
269
|
+
?.filter(
|
|
270
|
+
(task) =>
|
|
271
|
+
task.dayIndex === positionDay &&
|
|
272
|
+
task.groupId === group.id &&
|
|
273
|
+
compareWeekOffset(
|
|
274
|
+
date,
|
|
275
|
+
weekOffset || 0,
|
|
276
|
+
task.taskDate
|
|
277
|
+
)
|
|
278
|
+
)
|
|
279
|
+
.sort((a, b) => a.taskStart - b.taskStart)
|
|
280
|
+
.map((task, taskKey) => {
|
|
281
|
+
return (
|
|
282
|
+
<TaskContainer
|
|
283
|
+
key={`${taskKey} task`}
|
|
284
|
+
handleDragTask={handleDragTask}
|
|
285
|
+
taskRender={taskRender}
|
|
286
|
+
handleDragTaskEnd={handleDragTaskEnd}
|
|
287
|
+
style={taskContainerStyle}
|
|
288
|
+
className={`${taskContainerClassName}`}
|
|
289
|
+
currentTask={task}
|
|
290
|
+
handleClickTask={handleClickTask}
|
|
291
|
+
/>
|
|
292
|
+
);
|
|
293
|
+
})}
|
|
294
|
+
</>
|
|
295
|
+
|
|
296
|
+
<AddTask
|
|
297
|
+
addTaskStyle={addTaskStyle}
|
|
298
|
+
addTaskClassName={addTaskClassName}
|
|
299
|
+
groupId={group.id}
|
|
300
|
+
dayInfo={dailyHours[positionDay]}
|
|
301
|
+
addTaskRender={addTaskRender}
|
|
302
|
+
handleAddTask={handleAddTask}
|
|
303
|
+
/>
|
|
304
|
+
</div>
|
|
305
|
+
</td>
|
|
306
|
+
))}
|
|
307
|
+
<td key={`${i}sumHours`}>
|
|
308
|
+
<SumHoursContainer
|
|
309
|
+
groupId={group.id}
|
|
310
|
+
tasks={tasks}
|
|
311
|
+
weekOffset={weekOffset || 0}
|
|
312
|
+
calendarDate={date}
|
|
313
|
+
sumHoursRender={sumHoursRender}
|
|
314
|
+
sumHoursByGroups={sumHoursByGroups(
|
|
315
|
+
group.id,
|
|
316
|
+
tasks,
|
|
317
|
+
weekOffset || 0,
|
|
318
|
+
date
|
|
319
|
+
)}
|
|
320
|
+
className={sumHoursContainerClassName}
|
|
321
|
+
style={sumHoursContainerStyle}
|
|
322
|
+
/>
|
|
323
|
+
</td>
|
|
324
|
+
</tr>
|
|
325
|
+
))}
|
|
326
|
+
</tbody>
|
|
327
|
+
</table>
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const SumHoursHead = ({
|
|
332
|
+
sumHoursHeadRender,
|
|
333
|
+
className,
|
|
334
|
+
style,
|
|
335
|
+
}: SumHoursHeadContainerPropsType) => {
|
|
336
|
+
if (sumHoursHeadRender) {
|
|
337
|
+
return <>{sumHoursHeadRender()}</>;
|
|
338
|
+
}
|
|
339
|
+
return (
|
|
340
|
+
<div
|
|
341
|
+
className={`${className}`}
|
|
342
|
+
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
343
|
+
>
|
|
344
|
+
Hours
|
|
345
|
+
</div>
|
|
346
|
+
);
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const SumHoursContainer = ({
|
|
350
|
+
groupId,
|
|
351
|
+
tasks,
|
|
352
|
+
weekOffset,
|
|
353
|
+
calendarDate,
|
|
354
|
+
sumHoursByGroups,
|
|
355
|
+
sumHoursRender,
|
|
356
|
+
className,
|
|
357
|
+
style,
|
|
358
|
+
}: SumHoursContainerPropsType) => {
|
|
359
|
+
if (sumHoursRender) {
|
|
360
|
+
return (
|
|
361
|
+
<>
|
|
362
|
+
{sumHoursRender({
|
|
363
|
+
groupId,
|
|
364
|
+
tasks,
|
|
365
|
+
weekOffset,
|
|
366
|
+
calendarDate,
|
|
367
|
+
sumHoursByGroups,
|
|
368
|
+
})}
|
|
369
|
+
</>
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return (
|
|
374
|
+
<div
|
|
375
|
+
style={{ textAlign: "right", marginRight: "5px", ...style }}
|
|
376
|
+
className={`${className}`}
|
|
377
|
+
>
|
|
378
|
+
{sumHoursByGroups}
|
|
379
|
+
</div>
|
|
380
|
+
);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const DayContainer = ({
|
|
384
|
+
dayIndex,
|
|
385
|
+
dayOfTheMonth,
|
|
386
|
+
day,
|
|
387
|
+
dayMonth,
|
|
388
|
+
dayYear,
|
|
389
|
+
dayRender,
|
|
390
|
+
className,
|
|
391
|
+
style,
|
|
392
|
+
}: DayPropsType) => {
|
|
393
|
+
if (dayRender) {
|
|
394
|
+
return (
|
|
395
|
+
<>
|
|
396
|
+
{dayRender({
|
|
397
|
+
dayIndex,
|
|
398
|
+
day,
|
|
399
|
+
dayOfTheMonth,
|
|
400
|
+
dayMonth,
|
|
401
|
+
dayYear,
|
|
402
|
+
})}
|
|
403
|
+
</>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<div className={`${className}`} style={style}>
|
|
409
|
+
{`${day}. ${dayOfTheMonth}`}
|
|
410
|
+
</div>
|
|
411
|
+
);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const GroupContainer = ({
|
|
415
|
+
className,
|
|
416
|
+
style,
|
|
417
|
+
groupRender,
|
|
418
|
+
currentGroup,
|
|
419
|
+
handleClickGroup,
|
|
420
|
+
}: GroupPropsType) => {
|
|
421
|
+
if (groupRender) {
|
|
422
|
+
return <>{groupRender({ currentGroup })}</>;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const handleClick = () => {
|
|
426
|
+
if (!handleClickGroup) return;
|
|
427
|
+
handleClickGroup(currentGroup);
|
|
428
|
+
};
|
|
429
|
+
return (
|
|
430
|
+
<div
|
|
431
|
+
onClick={handleClick}
|
|
432
|
+
className={`${className}`}
|
|
433
|
+
style={{ ...groupContainerStyle, ...style }}
|
|
434
|
+
>
|
|
435
|
+
{currentGroup.imageUrl && (
|
|
436
|
+
<img
|
|
437
|
+
width={30}
|
|
438
|
+
height={30}
|
|
439
|
+
src={currentGroup.imageUrl}
|
|
440
|
+
alt="groupimg"
|
|
441
|
+
/>
|
|
442
|
+
)}
|
|
443
|
+
<label>{currentGroup.label && currentGroup.label}</label>
|
|
444
|
+
</div>
|
|
445
|
+
);
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
const AddTask = ({
|
|
449
|
+
groupId,
|
|
450
|
+
handleAddTask,
|
|
451
|
+
addTaskRender,
|
|
452
|
+
dayInfo,
|
|
453
|
+
addTaskStyle,
|
|
454
|
+
addTaskClassName,
|
|
455
|
+
}: AddTaskPropsType) => {
|
|
456
|
+
if (addTaskRender) {
|
|
457
|
+
return (
|
|
458
|
+
<>
|
|
459
|
+
{addTaskRender({
|
|
460
|
+
groupId,
|
|
461
|
+
dayInfo,
|
|
462
|
+
})}
|
|
463
|
+
</>
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const handleClick = () => {
|
|
468
|
+
if (!handleAddTask) return;
|
|
469
|
+
handleAddTask(groupId, dayInfo);
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
return (
|
|
473
|
+
<div
|
|
474
|
+
onClick={handleClick}
|
|
475
|
+
style={addTaskStyle}
|
|
476
|
+
className={`addPlanStyle ${addTaskClassName}`}
|
|
477
|
+
>
|
|
478
|
+
+
|
|
479
|
+
</div>
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
const TaskContainer = ({
|
|
484
|
+
handleDragTask,
|
|
485
|
+
taskRender,
|
|
486
|
+
handleDragTaskEnd,
|
|
487
|
+
style,
|
|
488
|
+
className,
|
|
489
|
+
currentTask,
|
|
490
|
+
handleClickTask,
|
|
491
|
+
}: TaskContainerPropsType) => {
|
|
492
|
+
const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => {
|
|
493
|
+
if (!handleDragTask) return;
|
|
494
|
+
event.dataTransfer.effectAllowed = "move";
|
|
495
|
+
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
496
|
+
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
497
|
+
window.sessionStorage.setItem(
|
|
498
|
+
"calendardragtaskStart",
|
|
499
|
+
`${currentTask.taskStart}`
|
|
500
|
+
);
|
|
501
|
+
window.sessionStorage.setItem(
|
|
502
|
+
"calendardragtaskEnd",
|
|
503
|
+
`${currentTask.taskEnd}`
|
|
504
|
+
);
|
|
505
|
+
window.sessionStorage.setItem(
|
|
506
|
+
"calendardragdayIndex",
|
|
507
|
+
`${currentTask.dayIndex}`
|
|
508
|
+
);
|
|
509
|
+
handleDragTask(event, currentTask);
|
|
510
|
+
};
|
|
511
|
+
const handleDragEnd = (event: React.DragEvent<HTMLDivElement>) => {
|
|
512
|
+
if (!handleDragTaskEnd) return;
|
|
513
|
+
handleDragTaskEnd(event);
|
|
514
|
+
};
|
|
515
|
+
const handleClick = () => {
|
|
516
|
+
if (!handleClickTask) return;
|
|
517
|
+
handleClickTask(currentTask);
|
|
518
|
+
};
|
|
519
|
+
if (taskRender) {
|
|
520
|
+
return (
|
|
521
|
+
<div
|
|
522
|
+
onClick={handleClick}
|
|
523
|
+
id={currentTask.taskId}
|
|
524
|
+
className={`taskContainer ${className}`}
|
|
525
|
+
style={{ ...style }}
|
|
526
|
+
draggable
|
|
527
|
+
onDragStart={handleDragStart}
|
|
528
|
+
onDragEnd={handleDragEnd}
|
|
529
|
+
>
|
|
530
|
+
{taskRender({
|
|
531
|
+
currentTask,
|
|
532
|
+
})}
|
|
533
|
+
</div>
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return (
|
|
538
|
+
<div
|
|
539
|
+
onClick={handleClick}
|
|
540
|
+
id={currentTask.taskId}
|
|
541
|
+
className={`taskContainer ${className}`}
|
|
542
|
+
style={{ ...style }}
|
|
543
|
+
draggable
|
|
544
|
+
onDragStart={handleDragStart}
|
|
545
|
+
onDragEnd={handleDragEnd}
|
|
546
|
+
>
|
|
547
|
+
<p className="tasklabel">{currentTask.task && currentTask.task}</p>
|
|
548
|
+
<p className="taskhour">
|
|
549
|
+
{currentTask.taskStart &&
|
|
550
|
+
currentTask.taskEnd &&
|
|
551
|
+
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${
|
|
552
|
+
millisecondsToDate(currentTask.taskEnd).formattedDate
|
|
553
|
+
}`}
|
|
554
|
+
</p>
|
|
555
|
+
</div>
|
|
556
|
+
);
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const GroupsHeadContainer = ({
|
|
560
|
+
groupsHeadRender,
|
|
561
|
+
style,
|
|
562
|
+
className,
|
|
563
|
+
}: GroupsHeadContainerPropsType) => {
|
|
564
|
+
if (groupsHeadRender) {
|
|
565
|
+
return <>{groupsHeadRender()}</>;
|
|
566
|
+
}
|
|
567
|
+
return (
|
|
568
|
+
<div className={`${className}`} style={style}>
|
|
569
|
+
WeeklyCalendar
|
|
570
|
+
</div>
|
|
571
|
+
);
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
export const updateCalendarDateWithOffset = (
|
|
575
|
+
offset: number,
|
|
576
|
+
calendarDate: Date
|
|
577
|
+
) => {
|
|
578
|
+
const newDate = new Date(calendarDate);
|
|
579
|
+
newDate.setDate(newDate.getDate() + offset);
|
|
580
|
+
return newDate;
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
export const updateOffsetWithDateCalendar = (calendarDate: Date) => {
|
|
584
|
+
return calculerEcartSemaine(calendarDate);
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
export const millisecondsToHours = (milliseconds: number) => {
|
|
588
|
+
return millisecondsToDate(milliseconds).formattedDate;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
export default Calendar;
|
package/jest.config.js
ADDED
package/jest.config.ts
ADDED
package/jsdoc.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|