gantt-task-react-v 1.5.14 → 1.5.16

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.
@@ -18296,13 +18296,9 @@ const useSelection = (taskToRowIndexMap, rowIndexToTaskMap, checkTaskIdExists, o
18296
18296
  toggleTask(taskId);
18297
18297
  return;
18298
18298
  }
18299
- if (selectedIdsMirror[taskId]) {
18300
- toggleTask(taskId);
18301
- } else {
18302
- selectTask(taskId);
18303
- }
18299
+ selectTask(taskId);
18304
18300
  },
18305
- [selectTask, selectTasksFromLastSelected, toggleTask, selectedIdsMirror]
18301
+ [selectTask, selectTasksFromLastSelected, toggleTask]
18306
18302
  );
18307
18303
  const cutTask = useCallback((task) => {
18308
18304
  setCutIdsMirror({
@@ -19696,6 +19692,7 @@ const Gantt = (props) => {
19696
19692
  showProgress = true,
19697
19693
  progressColor,
19698
19694
  scrollToTaskId,
19695
+ initialSelectedTaskId,
19699
19696
  drawer: drawerProps
19700
19697
  } = props;
19701
19698
  const ganttSVGRef = useRef(null);
@@ -20011,6 +20008,14 @@ const Gantt = (props) => {
20011
20008
  [mapTaskToCoordinates, setScrollXProgrammatically]
20012
20009
  );
20013
20010
  const prevScrollToTaskIdRef = useRef(void 0);
20011
+ const prevInitialSelectedTaskIdRef = useRef(void 0);
20012
+ useEffect(() => {
20013
+ if (!initialSelectedTaskId || initialSelectedTaskId === prevInitialSelectedTaskIdRef.current) {
20014
+ return;
20015
+ }
20016
+ prevInitialSelectedTaskIdRef.current = initialSelectedTaskId;
20017
+ selectTask(initialSelectedTaskId);
20018
+ }, [initialSelectedTaskId, selectTask]);
20014
20019
  useEffect(() => {
20015
20020
  if (!scrollToTaskId || scrollToTaskId === prevScrollToTaskIdRef.current) {
20016
20021
  return;
@@ -20847,6 +20852,14 @@ const Gantt = (props) => {
20847
20852
  },
20848
20853
  [enableDrawer, taskBar]
20849
20854
  );
20855
+ const handleTaskListRowClick = useCallback(
20856
+ (task) => {
20857
+ if (taskList.onClickRow) {
20858
+ taskList.onClickRow(task);
20859
+ }
20860
+ },
20861
+ [taskList]
20862
+ );
20850
20863
  const handleTaskListRowDoubleClick = useCallback(
20851
20864
  (task) => {
20852
20865
  if (task.type !== "empty") {
@@ -21206,6 +21219,7 @@ const Gantt = (props) => {
21206
21219
  handleMoveTasksInside,
21207
21220
  handleOpenContextMenu: handleOpenContextMenuForRow,
21208
21221
  mapTaskToNestedIndex,
21222
+ onClick: handleTaskListRowClick,
21209
21223
  onDoubleClick: handleTaskListRowDoubleClick,
21210
21224
  onExpanderClick,
21211
21225
  scrollToBottomStep,
@@ -21237,6 +21251,7 @@ const Gantt = (props) => {
21237
21251
  handleMoveTaskBefore,
21238
21252
  handleMoveTasksInside,
21239
21253
  handleOpenContextMenuForRow,
21254
+ handleTaskListRowClick,
21240
21255
  handleTaskListRowDoubleClick,
21241
21256
  mapTaskToNestedIndex,
21242
21257
  onExpanderClick,
@@ -18313,13 +18313,9 @@
18313
18313
  toggleTask(taskId);
18314
18314
  return;
18315
18315
  }
18316
- if (selectedIdsMirror[taskId]) {
18317
- toggleTask(taskId);
18318
- } else {
18319
- selectTask(taskId);
18320
- }
18316
+ selectTask(taskId);
18321
18317
  },
18322
- [selectTask, selectTasksFromLastSelected, toggleTask, selectedIdsMirror]
18318
+ [selectTask, selectTasksFromLastSelected, toggleTask]
18323
18319
  );
18324
18320
  const cutTask = React.useCallback((task) => {
18325
18321
  setCutIdsMirror({
@@ -19713,6 +19709,7 @@
19713
19709
  showProgress = true,
19714
19710
  progressColor,
19715
19711
  scrollToTaskId,
19712
+ initialSelectedTaskId,
19716
19713
  drawer: drawerProps
19717
19714
  } = props;
19718
19715
  const ganttSVGRef = React.useRef(null);
@@ -20028,6 +20025,14 @@
20028
20025
  [mapTaskToCoordinates, setScrollXProgrammatically]
20029
20026
  );
20030
20027
  const prevScrollToTaskIdRef = React.useRef(void 0);
20028
+ const prevInitialSelectedTaskIdRef = React.useRef(void 0);
20029
+ React.useEffect(() => {
20030
+ if (!initialSelectedTaskId || initialSelectedTaskId === prevInitialSelectedTaskIdRef.current) {
20031
+ return;
20032
+ }
20033
+ prevInitialSelectedTaskIdRef.current = initialSelectedTaskId;
20034
+ selectTask(initialSelectedTaskId);
20035
+ }, [initialSelectedTaskId, selectTask]);
20031
20036
  React.useEffect(() => {
20032
20037
  if (!scrollToTaskId || scrollToTaskId === prevScrollToTaskIdRef.current) {
20033
20038
  return;
@@ -20864,6 +20869,14 @@
20864
20869
  },
20865
20870
  [enableDrawer, taskBar]
20866
20871
  );
20872
+ const handleTaskListRowClick = React.useCallback(
20873
+ (task) => {
20874
+ if (taskList.onClickRow) {
20875
+ taskList.onClickRow(task);
20876
+ }
20877
+ },
20878
+ [taskList]
20879
+ );
20867
20880
  const handleTaskListRowDoubleClick = React.useCallback(
20868
20881
  (task) => {
20869
20882
  if (task.type !== "empty") {
@@ -21223,6 +21236,7 @@
21223
21236
  handleMoveTasksInside,
21224
21237
  handleOpenContextMenu: handleOpenContextMenuForRow,
21225
21238
  mapTaskToNestedIndex,
21239
+ onClick: handleTaskListRowClick,
21226
21240
  onDoubleClick: handleTaskListRowDoubleClick,
21227
21241
  onExpanderClick,
21228
21242
  scrollToBottomStep,
@@ -21254,6 +21268,7 @@
21254
21268
  handleMoveTaskBefore,
21255
21269
  handleMoveTasksInside,
21256
21270
  handleOpenContextMenuForRow,
21271
+ handleTaskListRowClick,
21257
21272
  handleTaskListRowDoubleClick,
21258
21273
  mapTaskToNestedIndex,
21259
21274
  onExpanderClick,
@@ -184,6 +184,11 @@ export interface GanttTaskListProps {
184
184
  * Render bottom table content
185
185
  */
186
186
  tableBottom?: TableRenderBottomProps;
187
+ /**
188
+ * Invokes on single click on a task list row.
189
+ * Receives the full task data of the clicked row.
190
+ */
191
+ onClickRow?: (task: RenderTask) => void;
187
192
  /**
188
193
  * Invokes on double-click on a task list row.
189
194
  * Receives the full task data of the double-clicked row.
@@ -413,6 +418,11 @@ export interface GanttProps {
413
418
  * Set to a task id to scroll both horizontally and vertically to that task.
414
419
  */
415
420
  scrollToTaskId?: TaskId;
421
+ /**
422
+ * When set (or changed), the gantt will select this task's row without scrolling.
423
+ * Useful for restoring selection from external state (e.g. localStorage) on load.
424
+ */
425
+ initialSelectedTaskId?: TaskId;
416
426
  /**
417
427
  * Drawer panel options for task/arrow click
418
428
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "Interactive Gantt Chart for React with TypeScript.",
5
5
  "author": "aguilanbon",
6
6
  "homepage": "https://github.com/aguilanbon/gantt-task-react-v",