react-weekly-planning 1.0.1 → 1.0.3

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
@@ -3,7 +3,9 @@
3
3
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
4
4
 
5
5
 
6
- ### Detailed Description and Use Cases
6
+ ### Description and Use Cases
7
+
8
+ `react-weekly-planning` provides a React component for weekly planning. Easily set up and manage a weekly schedule with customizable tasks, groups and views.
7
9
 
8
10
  #### `weekOffset`
9
11
 
@@ -98,8 +100,10 @@ Props for the Calendar component.
98
100
  | `sumHoursContainerClassName` | string | Additional class names for the sum hours container. |
99
101
  | `sumHoursHeadStyle` | React.CSSProperties \| undefined | Additional styles for the sum hours header. |
100
102
  | `sumHoursHeadClassName` | string | Additional class names for the sum hours header. |
101
- | `handleAddTask` | (groupId: string, dayInfo: dayInfoType) => void | Handler function for adding a new task. |
102
- | `addTaskRender` | ({ groupId, dayInfo }: { groupId: string; dayInfo: dayInfoType }) => React.ReactNode | Custom render function for adding a task. |
103
+ | `handleAddTask` | handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void; | Handler function for adding a new task. |
104
+ | `addTaskRender` | addTaskRender?: ({currentGroup,dayInfo}:{
105
+ currentGroup: GroupFeildsType;dayInfo: dayInfoType;
106
+ }) => React.ReactNode; | Custom render function for adding a task. |
103
107
  | `tasks` | TasksType | Array of tasks to be displayed in the calendar. |
104
108
  | `handleDragTask` | (event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void | Handler function for dragging a task. |
105
109
  | `handleDropTask` | (event: React.DragEvent<HTMLTableDataCellElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void | Handler function for dropping a task. |
@@ -4,7 +4,7 @@
4
4
  export type GroupPropsType = {
5
5
  /** Custom render function for the group. */
6
6
  groupRender?: ({
7
- currentGroup
7
+ currentGroup,
8
8
  }: {
9
9
  currentGroup: GroupFeildsType;
10
10
  }) => React.ReactNode;
@@ -41,15 +41,13 @@ type GroupAdditionalFieldsType = Record<any, unknown>;
41
41
  export type GroupFeildsType = GroupRiquiredFieldsType &
42
42
  GroupAdditionalFieldsType;
43
43
 
44
-
45
-
46
44
  /**
47
45
  * Props for the GroupComponent.
48
46
  */
49
47
  export type GroupComponentPropsType = {
50
48
  /** Custom render function for the group. */
51
49
  groupRender?: ({
52
- currentGroup
50
+ currentGroup,
53
51
  }: {
54
52
  currentGroup: GroupFeildsType;
55
53
  }) => React.ReactNode;
@@ -133,7 +131,7 @@ export type CalendarPropsType = {
133
131
  date: Date;
134
132
  /** Custom render function for a group. */
135
133
  groupRender?: ({
136
- currentGroup
134
+ currentGroup,
137
135
  }: {
138
136
  currentGroup: GroupFeildsType;
139
137
  }) => React.ReactNode;
@@ -154,7 +152,7 @@ export type CalendarPropsType = {
154
152
  /** Custom render function for a task. */
155
153
  taskRender?: ({
156
154
  currentTask,
157
- handleDragTask
155
+ handleDragTask,
158
156
  }: {
159
157
  currentTask: TaskFeildsType;
160
158
  handleDragTask?: (
@@ -203,16 +201,13 @@ export type CalendarPropsType = {
203
201
  /** Additional class names for the sum hours header. */
204
202
  sumHoursHeadClassName?: string;
205
203
  /** Handler function for adding a new task. */
206
- handleAddTask?: (
207
- groupId: string,
208
- dayInfo: dayInfoType
209
- ) => void;
204
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
210
205
  /** Custom render function for adding a task. */
211
- addTaskRender?:({
212
- groupId,
206
+ addTaskRender?: ({
207
+ currentGroup,
213
208
  dayInfo,
214
209
  }: {
215
- groupId: string;
210
+ currentGroup: GroupFeildsType;
216
211
  dayInfo: dayInfoType;
217
212
  }) => React.ReactNode;
218
213
  /** Array of tasks to be displayed in the calendar. */
@@ -234,9 +229,7 @@ export type CalendarPropsType = {
234
229
  newTasks: TasksType
235
230
  ) => void;
236
231
  /** Handler function for ending the drag of a task. */
237
- handleDragTaskEnd?: (
238
- event: React.DragEvent<HTMLDivElement>
239
- ) => void;
232
+ handleDragTaskEnd?: (event: React.DragEvent<HTMLDivElement>) => void;
240
233
  /** Custom render function for the groups header. */
241
234
  groupsHeadRender?: () => React.ReactNode;
242
235
  /** Custom render function for the sum of hours. */
@@ -254,7 +247,7 @@ export type CalendarPropsType = {
254
247
  sumHoursByGroups: number;
255
248
  }) => React.ReactNode;
256
249
  /** Custom render function for the sum of hours header. */
257
- sumHoursHeadRender?:() => React.ReactNode;
250
+ sumHoursHeadRender?: () => React.ReactNode;
258
251
  /** Handler function for clicking a task. */
259
252
  handleClickTask?: (currentTask: TaskFeildsType) => void;
260
253
  /** Handler function for clicking a group. */
@@ -270,27 +263,24 @@ export type StyleType = React.CSSProperties | undefined;
270
263
  * Props for the AddTask component.
271
264
  */
272
265
  export type AddTaskPropsType = {
273
- /** ID of the group. */
274
- groupId: string;
266
+ /** The current group data. */
267
+ currentGroup: GroupFeildsType;
275
268
  /** Additional styles for the add task button. */
276
269
  addTaskStyle?: StyleType;
277
270
  /** Additional class names for the add task button. */
278
271
  addTaskClassName?: string;
279
272
  /** Custom render function for adding a task. */
280
273
  addTaskRender?: ({
281
- groupId,
274
+ currentGroup,
282
275
  dayInfo,
283
276
  }: {
284
- groupId: string;
277
+ currentGroup: GroupFeildsType;
285
278
  dayInfo: dayInfoType;
286
279
  }) => React.ReactNode;
287
280
  /** Information about the day. */
288
281
  dayInfo: dayInfoType;
289
282
  /** Handler function for adding a new task. */
290
- handleAddTask?: (
291
- groupId: string,
292
- dayInfo: dayInfoType
293
- ) => void;
283
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
294
284
  };
295
285
 
296
286
  /**
@@ -343,7 +333,7 @@ export type TaskContainerPropsType = {
343
333
  /** Custom render function for a task. */
344
334
  taskRender?: ({
345
335
  currentTask,
346
- handleDragTask
336
+ handleDragTask,
347
337
  }: {
348
338
  currentTask: TaskFeildsType;
349
339
  handleDragTask?: (
@@ -352,17 +342,13 @@ export type TaskContainerPropsType = {
352
342
  ) => void;
353
343
  }) => React.ReactNode;
354
344
  /** Handler function for ending the drag of a task. */
355
- handleDragTaskEnd?:(
356
- event: React.DragEvent<HTMLDivElement>
357
- ) => void;
345
+ handleDragTaskEnd?: (event: React.DragEvent<HTMLDivElement>) => void;
358
346
  /** The current task data. */
359
347
  currentTask: TaskFeildsType;
360
348
  /** Handler function for clicking a task. */
361
349
  handleClickTask?: (currentTask: TaskFeildsType) => void;
362
350
  };
363
351
 
364
-
365
-
366
352
  /**
367
353
  * Props for the GroupsHeadContainer component.
368
354
  */
@@ -375,8 +361,6 @@ export type GroupsHeadContainerPropsType = {
375
361
  className?: string;
376
362
  };
377
363
 
378
-
379
-
380
364
  /**
381
365
  * Props for the SumHoursHeadContainer component.
382
366
  */
package/docs/global.html CHANGED
@@ -220,13 +220,13 @@
220
220
 
221
221
  <tr class="deep-level-0">
222
222
 
223
- <td class="name"><code>groupId</code></td>
223
+ <td class="name"><code>currentGroup</code></td>
224
224
 
225
225
 
226
226
  <td class="type">
227
227
 
228
228
 
229
- <code class="param-type">string</code>
229
+ <code class="param-type"><a href="global.html#GroupFeildsType">GroupFeildsType</a></code>
230
230
 
231
231
 
232
232
 
@@ -242,7 +242,7 @@
242
242
 
243
243
 
244
244
 
245
- <td class="description last">ID of the group.</td>
245
+ <td class="description last">The current group data.</td>
246
246
  </tr>
247
247
 
248
248
 
package/docs/index.html CHANGED
@@ -106,7 +106,8 @@
106
106
  <section>
107
107
  <article><h2>License</h2>
108
108
  <p>This project is licensed under the MIT License - see the <a href="LICENSE">LICENSE</a> file for details.</p>
109
- <h3>Detailed Description and Use Cases</h3>
109
+ <h3>Description and Use Cases</h3>
110
+ <p><code>react-weekly-planning</code> provides a React component for weekly planning. Easily set up and manage a weekly schedule with customizable tasks, groups and views.</p>
110
111
  <h4><code>weekOffset</code></h4>
111
112
  <ul>
112
113
  <li>
@@ -324,13 +325,23 @@ taskId, taskStart taskEnd, task, taskDate, groupId, dayIndex
324
325
  </tr>
325
326
  <tr>
326
327
  <td><code>handleAddTask</code></td>
327
- <td>(groupId: string, dayInfo: dayInfoType) =&gt; void</td>
328
+ <td>handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) =&gt; void;</td>
328
329
  <td>Handler function for adding a new task.</td>
329
330
  </tr>
330
331
  <tr>
331
332
  <td><code>addTaskRender</code></td>
332
- <td>({ groupId, dayInfo }: { groupId: string; dayInfo: dayInfoType }) =&gt; React.ReactNode</td>
333
+ <td>addTaskRender?: ({currentGroup,dayInfo}:{</td>
334
+ <td></td>
335
+ </tr>
336
+ <tr>
337
+ <td>currentGroup: GroupFeildsType;dayInfo: dayInfoType;</td>
338
+ <td></td>
339
+ <td></td>
340
+ </tr>
341
+ <tr>
342
+ <td>}) =&gt; React.ReactNode;</td>
333
343
  <td>Custom render function for adding a task.</td>
344
+ <td></td>
334
345
  </tr>
335
346
  <tr>
336
347
  <td><code>tasks</code></td>
@@ -95,7 +95,7 @@
95
95
  export type GroupPropsType = {
96
96
  /** Custom render function for the group. */
97
97
  groupRender?: ({
98
- currentGroup
98
+ currentGroup,
99
99
  }: {
100
100
  currentGroup: GroupFeildsType;
101
101
  }) => React.ReactNode;
@@ -132,15 +132,13 @@ type GroupAdditionalFieldsType = Record&lt;any, unknown>;
132
132
  export type GroupFeildsType = GroupRiquiredFieldsType &amp;
133
133
  GroupAdditionalFieldsType;
134
134
 
135
-
136
-
137
135
  /**
138
136
  * Props for the GroupComponent.
139
137
  */
140
138
  export type GroupComponentPropsType = {
141
139
  /** Custom render function for the group. */
142
140
  groupRender?: ({
143
- currentGroup
141
+ currentGroup,
144
142
  }: {
145
143
  currentGroup: GroupFeildsType;
146
144
  }) => React.ReactNode;
@@ -224,7 +222,7 @@ export type CalendarPropsType = {
224
222
  date: Date;
225
223
  /** Custom render function for a group. */
226
224
  groupRender?: ({
227
- currentGroup
225
+ currentGroup,
228
226
  }: {
229
227
  currentGroup: GroupFeildsType;
230
228
  }) => React.ReactNode;
@@ -245,7 +243,7 @@ export type CalendarPropsType = {
245
243
  /** Custom render function for a task. */
246
244
  taskRender?: ({
247
245
  currentTask,
248
- handleDragTask
246
+ handleDragTask,
249
247
  }: {
250
248
  currentTask: TaskFeildsType;
251
249
  handleDragTask?: (
@@ -294,16 +292,13 @@ export type CalendarPropsType = {
294
292
  /** Additional class names for the sum hours header. */
295
293
  sumHoursHeadClassName?: string;
296
294
  /** Handler function for adding a new task. */
297
- handleAddTask?: (
298
- groupId: string,
299
- dayInfo: dayInfoType
300
- ) => void;
295
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
301
296
  /** Custom render function for adding a task. */
302
- addTaskRender?:({
303
- groupId,
297
+ addTaskRender?: ({
298
+ currentGroup,
304
299
  dayInfo,
305
300
  }: {
306
- groupId: string;
301
+ currentGroup: GroupFeildsType;
307
302
  dayInfo: dayInfoType;
308
303
  }) => React.ReactNode;
309
304
  /** Array of tasks to be displayed in the calendar. */
@@ -325,9 +320,7 @@ export type CalendarPropsType = {
325
320
  newTasks: TasksType
326
321
  ) => void;
327
322
  /** Handler function for ending the drag of a task. */
328
- handleDragTaskEnd?: (
329
- event: React.DragEvent&lt;HTMLDivElement>
330
- ) => void;
323
+ handleDragTaskEnd?: (event: React.DragEvent&lt;HTMLDivElement>) => void;
331
324
  /** Custom render function for the groups header. */
332
325
  groupsHeadRender?: () => React.ReactNode;
333
326
  /** Custom render function for the sum of hours. */
@@ -345,7 +338,7 @@ export type CalendarPropsType = {
345
338
  sumHoursByGroups: number;
346
339
  }) => React.ReactNode;
347
340
  /** Custom render function for the sum of hours header. */
348
- sumHoursHeadRender?:() => React.ReactNode;
341
+ sumHoursHeadRender?: () => React.ReactNode;
349
342
  /** Handler function for clicking a task. */
350
343
  handleClickTask?: (currentTask: TaskFeildsType) => void;
351
344
  /** Handler function for clicking a group. */
@@ -361,27 +354,24 @@ export type StyleType = React.CSSProperties | undefined;
361
354
  * Props for the AddTask component.
362
355
  */
363
356
  export type AddTaskPropsType = {
364
- /** ID of the group. */
365
- groupId: string;
357
+ /** The current group data. */
358
+ currentGroup: GroupFeildsType;
366
359
  /** Additional styles for the add task button. */
367
360
  addTaskStyle?: StyleType;
368
361
  /** Additional class names for the add task button. */
369
362
  addTaskClassName?: string;
370
363
  /** Custom render function for adding a task. */
371
364
  addTaskRender?: ({
372
- groupId,
365
+ currentGroup,
373
366
  dayInfo,
374
367
  }: {
375
- groupId: string;
368
+ currentGroup: GroupFeildsType;
376
369
  dayInfo: dayInfoType;
377
370
  }) => React.ReactNode;
378
371
  /** Information about the day. */
379
372
  dayInfo: dayInfoType;
380
373
  /** Handler function for adding a new task. */
381
- handleAddTask?: (
382
- groupId: string,
383
- dayInfo: dayInfoType
384
- ) => void;
374
+ handleAddTask?: (currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void;
385
375
  };
386
376
 
387
377
  /**
@@ -434,7 +424,7 @@ export type TaskContainerPropsType = {
434
424
  /** Custom render function for a task. */
435
425
  taskRender?: ({
436
426
  currentTask,
437
- handleDragTask
427
+ handleDragTask,
438
428
  }: {
439
429
  currentTask: TaskFeildsType;
440
430
  handleDragTask?: (
@@ -443,17 +433,13 @@ export type TaskContainerPropsType = {
443
433
  ) => void;
444
434
  }) => React.ReactNode;
445
435
  /** Handler function for ending the drag of a task. */
446
- handleDragTaskEnd?:(
447
- event: React.DragEvent&lt;HTMLDivElement>
448
- ) => void;
436
+ handleDragTaskEnd?: (event: React.DragEvent&lt;HTMLDivElement>) => void;
449
437
  /** The current task data. */
450
438
  currentTask: TaskFeildsType;
451
439
  /** Handler function for clicking a task. */
452
440
  handleClickTask?: (currentTask: TaskFeildsType) => void;
453
441
  };
454
442
 
455
-
456
-
457
443
  /**
458
444
  * Props for the GroupsHeadContainer component.
459
445
  */
@@ -466,8 +452,6 @@ export type GroupsHeadContainerPropsType = {
466
452
  className?: string;
467
453
  };
468
454
 
469
-
470
-
471
455
  /**
472
456
  * Props for the SumHoursHeadContainer component.
473
457
  */
package/index.js CHANGED
@@ -116,7 +116,7 @@ const Calendar = ({ style, className, groups, weekOffset, date, groupRender, day
116
116
  task.groupId === group.id &&
117
117
  compareWeekOffset(date, weekOffset || 0, task.taskDate)).sort((a, b) => a.taskStart - b.taskStart).map((task, taskKey) => {
118
118
  return (_jsx(TaskContainer, { handleDragTask: handleDragTask, taskRender: taskRender, handleDragTaskEnd: handleDragTaskEnd, style: taskContainerStyle, className: `${taskContainerClassName}`, currentTask: task, handleClickTask: handleClickTask }, `${taskKey} task`));
119
- }) }), _jsx(AddTask, { addTaskStyle: addTaskStyle, addTaskClassName: addTaskClassName, groupId: group.id, dayInfo: dailyHours[positionDay], addTaskRender: addTaskRender, handleAddTask: handleAddTask })] }, positionDay) }, `td-${group.id}day-i${positionDay}`))), _jsx("td", { children: _jsx(SumHoursContainer, { groupId: group.id, tasks: tasks, weekOffset: weekOffset || 0, calendarDate: date, sumHoursRender: sumHoursRender, sumHoursByGroups: sumHoursByGroups(group.id, tasks, weekOffset || 0, date), className: sumHoursContainerClassName, style: sumHoursContainerStyle }) }, `${i}sumHours`)] }, `${i} tr`))) })] }));
119
+ }) }), _jsx(AddTask, { addTaskStyle: addTaskStyle, addTaskClassName: addTaskClassName, currentGroup: group, dayInfo: dailyHours[positionDay], addTaskRender: addTaskRender, handleAddTask: handleAddTask })] }, positionDay) }, `td-${group.id}day-i${positionDay}`))), _jsx("td", { children: _jsx(SumHoursContainer, { groupId: group.id, tasks: tasks, weekOffset: weekOffset || 0, calendarDate: date, sumHoursRender: sumHoursRender, sumHoursByGroups: sumHoursByGroups(group.id, tasks, weekOffset || 0, date), className: sumHoursContainerClassName, style: sumHoursContainerStyle }) }, `${i}sumHours`)] }, `${i} tr`))) })] }));
120
120
  };
121
121
  const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
122
122
  if (sumHoursHeadRender) {
@@ -159,17 +159,17 @@ const GroupContainer = ({ className, style, groupRender, currentGroup, handleCli
159
159
  };
160
160
  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 })] }));
161
161
  };
162
- const AddTask = ({ groupId, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }) => {
162
+ const AddTask = ({ currentGroup, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }) => {
163
163
  if (addTaskRender) {
164
164
  return (_jsx(_Fragment, { children: addTaskRender({
165
- groupId,
165
+ currentGroup,
166
166
  dayInfo,
167
167
  }) }));
168
168
  }
169
169
  const handleClick = () => {
170
170
  if (!handleAddTask)
171
171
  return;
172
- handleAddTask(groupId, dayInfo);
172
+ handleAddTask(currentGroup, dayInfo);
173
173
  };
174
174
  return (_jsx("div", { onClick: handleClick, style: addTaskStyle, className: `addPlanStyle ${addTaskClassName}`, children: "+" }));
175
175
  };
package/index.tsx CHANGED
@@ -296,7 +296,7 @@ const Calendar = ({
296
296
  <AddTask
297
297
  addTaskStyle={addTaskStyle}
298
298
  addTaskClassName={addTaskClassName}
299
- groupId={group.id}
299
+ currentGroup={group}
300
300
  dayInfo={dailyHours[positionDay]}
301
301
  addTaskRender={addTaskRender}
302
302
  handleAddTask={handleAddTask}
@@ -446,7 +446,7 @@ const GroupContainer = ({
446
446
  };
447
447
 
448
448
  const AddTask = ({
449
- groupId,
449
+ currentGroup,
450
450
  handleAddTask,
451
451
  addTaskRender,
452
452
  dayInfo,
@@ -457,7 +457,7 @@ const AddTask = ({
457
457
  return (
458
458
  <>
459
459
  {addTaskRender({
460
- groupId,
460
+ currentGroup,
461
461
  dayInfo,
462
462
  })}
463
463
  </>
@@ -466,7 +466,7 @@ const AddTask = ({
466
466
 
467
467
  const handleClick = () => {
468
468
  if (!handleAddTask) return;
469
- handleAddTask(groupId, dayInfo);
469
+ handleAddTask(currentGroup, dayInfo);
470
470
  };
471
471
 
472
472
  return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-weekly-planning",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "author": "Kacou Yao Yves Morel",
31
31
  "license": "MIT",
32
- "description": "A React component for weekly planning. Easily set up and manage a weekly schedule with customizable tasks, groups and views.",
32
+ "description": "react-weekly-planning provides a React component for weekly planning. Easily set up and manage a weekly schedule with customizable tasks, groups and views.",
33
33
  "dependencies": {
34
34
  "@babel/types": "^7.24.5",
35
35
  "@types/babel__generator": "^7.6.8",