gantt-task-react-v 1.6.6 → 1.6.8

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
  };
@@ -20916,18 +20922,14 @@ const Gantt = (props) => {
20916
20922
  }
20917
20923
  return;
20918
20924
  }
20919
- if (selectedIdsMirror[task.id]) {
20920
- setActiveArrowKey(null);
20921
- setActiveTaskId(task.id);
20922
- } else {
20923
- setActiveArrowKey(null);
20924
- setActiveTaskId(null);
20925
- }
20925
+ selectTask(task.id);
20926
+ setActiveArrowKey(null);
20927
+ setActiveTaskId(task.id);
20926
20928
  if (taskBar.onClick) {
20927
20929
  taskBar.onClick(task);
20928
20930
  }
20929
20931
  },
20930
- [enableDrawer, drawerData, selectTask, selectedIdsMirror, taskBar]
20932
+ [enableDrawer, drawerData, selectTask, taskBar]
20931
20933
  );
20932
20934
  const handleTaskDoubleClick = useCallback(
20933
20935
  (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
  };
@@ -20933,18 +20939,14 @@
20933
20939
  }
20934
20940
  return;
20935
20941
  }
20936
- if (selectedIdsMirror[task.id]) {
20937
- setActiveArrowKey(null);
20938
- setActiveTaskId(task.id);
20939
- } else {
20940
- setActiveArrowKey(null);
20941
- setActiveTaskId(null);
20942
- }
20942
+ selectTask(task.id);
20943
+ setActiveArrowKey(null);
20944
+ setActiveTaskId(task.id);
20943
20945
  if (taskBar.onClick) {
20944
20946
  taskBar.onClick(task);
20945
20947
  }
20946
20948
  },
20947
- [enableDrawer, drawerData, selectTask, selectedIdsMirror, taskBar]
20949
+ [enableDrawer, drawerData, selectTask, taskBar]
20948
20950
  );
20949
20951
  const handleTaskDoubleClick = React.useCallback(
20950
20952
  (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.8",
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",