gantt-task-react-v 1.6.6 → 1.6.7

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.
@@ -14,5 +14,6 @@ export declare const useSelection: (taskToRowIndexMap: TaskToRowIndexMap, rowInd
14
14
  selectTaskOnMouseDown: (taskId: string, event: MouseEvent) => void;
15
15
  selectTasksFromLastSelected: (taskId: string) => void;
16
16
  selectedIdsMirror: Readonly<Record<string, true>>;
17
+ selectedIdsRef: import("react").MutableRefObject<Readonly<Record<string, true>>>;
17
18
  toggleTask: (taskId?: string | null, singleMode?: boolean) => void;
18
19
  };
@@ -18289,12 +18289,13 @@ const useSelection = (taskToRowIndexMap, rowIndexToTaskMap, checkTaskIdExists, o
18289
18289
  const [cutIdsMirror, setCutIdsMirror] = useState(initialValue);
18290
18290
  const [copyIdsMirror, setCopyIdsMirror] = useState(initialValue);
18291
18291
  const [selectedIdsMirror, setSelectedIdsMirror] = useState(initialValue);
18292
+ const selectedIdsRef = useRef(initialValue);
18292
18293
  const lastSelectedIdRef = useRef(null);
18293
18294
  const selectTask = useCallback((taskId) => {
18294
18295
  setCutIdsMirror(initialValue);
18295
- setSelectedIdsMirror({
18296
- [taskId]: true
18297
- });
18296
+ const next = { [taskId]: true };
18297
+ setSelectedIdsMirror(next);
18298
+ selectedIdsRef.current = next;
18298
18299
  lastSelectedIdRef.current = taskId;
18299
18300
  }, []);
18300
18301
  const toggleTask = useCallback(
@@ -18302,24 +18303,28 @@ const useSelection = (taskToRowIndexMap, rowIndexToTaskMap, checkTaskIdExists, o
18302
18303
  setCutIdsMirror(initialValue);
18303
18304
  setSelectedIdsMirror((prevValue) => {
18304
18305
  if (!taskId) {
18306
+ selectedIdsRef.current = {};
18305
18307
  return {};
18306
18308
  }
18307
18309
  if (singleMode) {
18308
- return {
18309
- [taskId]: true
18310
- };
18310
+ const next2 = { [taskId]: true };
18311
+ selectedIdsRef.current = next2;
18312
+ return next2;
18311
18313
  }
18312
18314
  if (prevValue[taskId]) {
18313
18315
  const nextValue = {
18314
18316
  ...prevValue
18315
18317
  };
18316
18318
  delete nextValue[taskId];
18319
+ selectedIdsRef.current = nextValue;
18317
18320
  return nextValue;
18318
18321
  }
18319
- return {
18322
+ const next = {
18320
18323
  ...prevValue,
18321
18324
  [taskId]: true
18322
18325
  };
18326
+ selectedIdsRef.current = next;
18327
+ return next;
18323
18328
  });
18324
18329
  lastSelectedIdRef.current = taskId;
18325
18330
  },
@@ -18444,6 +18449,7 @@ const useSelection = (taskToRowIndexMap, rowIndexToTaskMap, checkTaskIdExists, o
18444
18449
  selectTaskOnMouseDown,
18445
18450
  selectTasksFromLastSelected,
18446
18451
  selectedIdsMirror,
18452
+ selectedIdsRef,
18447
18453
  toggleTask
18448
18454
  };
18449
18455
  };
@@ -19989,7 +19995,8 @@ const Gantt = (props) => {
19989
19995
  resetSelectedTasks,
19990
19996
  selectTask,
19991
19997
  selectTaskOnMouseDown,
19992
- selectedIdsMirror
19998
+ selectedIdsMirror,
19999
+ selectedIdsRef
19993
20000
  } = useSelection(
19994
20001
  taskToRowIndexMap,
19995
20002
  rowIndexToTaskMap,
@@ -20916,7 +20923,7 @@ const Gantt = (props) => {
20916
20923
  }
20917
20924
  return;
20918
20925
  }
20919
- if (selectedIdsMirror[task.id]) {
20926
+ if (selectedIdsRef.current[task.id]) {
20920
20927
  setActiveArrowKey(null);
20921
20928
  setActiveTaskId(task.id);
20922
20929
  } else {
@@ -20927,7 +20934,7 @@ const Gantt = (props) => {
20927
20934
  taskBar.onClick(task);
20928
20935
  }
20929
20936
  },
20930
- [enableDrawer, drawerData, selectTask, selectedIdsMirror, taskBar]
20937
+ [enableDrawer, drawerData, selectTask, selectedIdsRef, taskBar]
20931
20938
  );
20932
20939
  const handleTaskDoubleClick = useCallback(
20933
20940
  (task) => {
@@ -18306,12 +18306,13 @@
18306
18306
  const [cutIdsMirror, setCutIdsMirror] = React.useState(initialValue);
18307
18307
  const [copyIdsMirror, setCopyIdsMirror] = React.useState(initialValue);
18308
18308
  const [selectedIdsMirror, setSelectedIdsMirror] = React.useState(initialValue);
18309
+ const selectedIdsRef = React.useRef(initialValue);
18309
18310
  const lastSelectedIdRef = React.useRef(null);
18310
18311
  const selectTask = React.useCallback((taskId) => {
18311
18312
  setCutIdsMirror(initialValue);
18312
- setSelectedIdsMirror({
18313
- [taskId]: true
18314
- });
18313
+ const next = { [taskId]: true };
18314
+ setSelectedIdsMirror(next);
18315
+ selectedIdsRef.current = next;
18315
18316
  lastSelectedIdRef.current = taskId;
18316
18317
  }, []);
18317
18318
  const toggleTask = React.useCallback(
@@ -18319,24 +18320,28 @@
18319
18320
  setCutIdsMirror(initialValue);
18320
18321
  setSelectedIdsMirror((prevValue) => {
18321
18322
  if (!taskId) {
18323
+ selectedIdsRef.current = {};
18322
18324
  return {};
18323
18325
  }
18324
18326
  if (singleMode) {
18325
- return {
18326
- [taskId]: true
18327
- };
18327
+ const next2 = { [taskId]: true };
18328
+ selectedIdsRef.current = next2;
18329
+ return next2;
18328
18330
  }
18329
18331
  if (prevValue[taskId]) {
18330
18332
  const nextValue = {
18331
18333
  ...prevValue
18332
18334
  };
18333
18335
  delete nextValue[taskId];
18336
+ selectedIdsRef.current = nextValue;
18334
18337
  return nextValue;
18335
18338
  }
18336
- return {
18339
+ const next = {
18337
18340
  ...prevValue,
18338
18341
  [taskId]: true
18339
18342
  };
18343
+ selectedIdsRef.current = next;
18344
+ return next;
18340
18345
  });
18341
18346
  lastSelectedIdRef.current = taskId;
18342
18347
  },
@@ -18461,6 +18466,7 @@
18461
18466
  selectTaskOnMouseDown,
18462
18467
  selectTasksFromLastSelected,
18463
18468
  selectedIdsMirror,
18469
+ selectedIdsRef,
18464
18470
  toggleTask
18465
18471
  };
18466
18472
  };
@@ -20006,7 +20012,8 @@
20006
20012
  resetSelectedTasks,
20007
20013
  selectTask,
20008
20014
  selectTaskOnMouseDown,
20009
- selectedIdsMirror
20015
+ selectedIdsMirror,
20016
+ selectedIdsRef
20010
20017
  } = useSelection(
20011
20018
  taskToRowIndexMap,
20012
20019
  rowIndexToTaskMap,
@@ -20933,7 +20940,7 @@
20933
20940
  }
20934
20941
  return;
20935
20942
  }
20936
- if (selectedIdsMirror[task.id]) {
20943
+ if (selectedIdsRef.current[task.id]) {
20937
20944
  setActiveArrowKey(null);
20938
20945
  setActiveTaskId(task.id);
20939
20946
  } else {
@@ -20944,7 +20951,7 @@
20944
20951
  taskBar.onClick(task);
20945
20952
  }
20946
20953
  },
20947
- [enableDrawer, drawerData, selectTask, selectedIdsMirror, taskBar]
20954
+ [enableDrawer, drawerData, selectTask, selectedIdsRef, taskBar]
20948
20955
  );
20949
20956
  const handleTaskDoubleClick = React.useCallback(
20950
20957
  (task) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
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",