gantt-lib 0.25.1 → 0.26.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/dist/index.d.mts CHANGED
@@ -575,6 +575,8 @@ interface GanttChartProps {
575
575
  onToggleCollapse?: (parentId: string) => void;
576
576
  /** Task IDs to highlight in the task list (for search results) */
577
577
  highlightedTaskIds?: Set<string>;
578
+ /** Disable task drag and resize on the calendar grid (default: false) */
579
+ disableTaskDrag?: boolean;
578
580
  }
579
581
  /**
580
582
  * Ref handle type for GanttChart — exposes imperative scroll methods.
@@ -665,6 +667,8 @@ interface TaskRowProps {
665
667
  }>;
666
668
  /** Custom weekend predicate (overrides default Saturday/Sunday) */
667
669
  isWeekend?: (date: Date) => boolean;
670
+ /** Disable task drag and resize (overrides task.locked) */
671
+ disableTaskDrag?: boolean;
668
672
  }
669
673
  /**
670
674
  * TaskRow component - renders a single task row with a task bar
@@ -963,6 +967,8 @@ interface UseTaskDragOptions {
963
967
  onCascade?: (tasks: Task$1[]) => void;
964
968
  /** When true, all drag and resize interactions are disabled for this task */
965
969
  locked?: boolean;
970
+ /** When true, drag is disabled globally for all tasks (shows grab cursor instead of not-allowed) */
971
+ disableTaskDrag?: boolean;
966
972
  /** If true, dependency cascade calculations skip weekends */
967
973
  businessDays?: boolean;
968
974
  /** Function that returns true for weekends (for businessDays mode) */
package/dist/index.d.ts CHANGED
@@ -575,6 +575,8 @@ interface GanttChartProps {
575
575
  onToggleCollapse?: (parentId: string) => void;
576
576
  /** Task IDs to highlight in the task list (for search results) */
577
577
  highlightedTaskIds?: Set<string>;
578
+ /** Disable task drag and resize on the calendar grid (default: false) */
579
+ disableTaskDrag?: boolean;
578
580
  }
579
581
  /**
580
582
  * Ref handle type for GanttChart — exposes imperative scroll methods.
@@ -665,6 +667,8 @@ interface TaskRowProps {
665
667
  }>;
666
668
  /** Custom weekend predicate (overrides default Saturday/Sunday) */
667
669
  isWeekend?: (date: Date) => boolean;
670
+ /** Disable task drag and resize (overrides task.locked) */
671
+ disableTaskDrag?: boolean;
668
672
  }
669
673
  /**
670
674
  * TaskRow component - renders a single task row with a task bar
@@ -963,6 +967,8 @@ interface UseTaskDragOptions {
963
967
  onCascade?: (tasks: Task$1[]) => void;
964
968
  /** When true, all drag and resize interactions are disabled for this task */
965
969
  locked?: boolean;
970
+ /** When true, drag is disabled globally for all tasks (shows grab cursor instead of not-allowed) */
971
+ disableTaskDrag?: boolean;
966
972
  /** If true, dependency cascade calculations skip weekends */
967
973
  businessDays?: boolean;
968
974
  /** Function that returns true for weekends (for businessDays mode) */
package/dist/index.js CHANGED
@@ -1992,11 +1992,13 @@ var useTaskDrag = (options) => {
1992
1992
  disableConstraints = false,
1993
1993
  onCascadeProgress,
1994
1994
  onCascade,
1995
+ locked = false,
1996
+ disableTaskDrag = false,
1995
1997
  businessDays = true,
1996
1998
  weekendPredicate
1997
1999
  } = options;
1998
2000
  const isOwnerRef = (0, import_react2.useRef)(false);
1999
- const locked = options.locked ?? false;
2001
+ const effectiveLocked = locked || disableTaskDrag;
2000
2002
  const [isDragging, setIsDragging] = (0, import_react2.useState)(false);
2001
2003
  const [dragMode, setDragMode] = (0, import_react2.useState)(null);
2002
2004
  const [currentLeft, setCurrentLeft] = (0, import_react2.useState)(0);
@@ -2161,7 +2163,7 @@ var useTaskDrag = (options) => {
2161
2163
  };
2162
2164
  }, []);
2163
2165
  const handleMouseDown = (0, import_react2.useCallback)((e) => {
2164
- if (locked) return;
2166
+ if (effectiveLocked) return;
2165
2167
  const target = e.currentTarget;
2166
2168
  const edgeZone = detectEdgeZone(e.clientX, target, edgeZoneWidth);
2167
2169
  let mode = null;
@@ -2239,14 +2241,15 @@ var useTaskDrag = (options) => {
2239
2241
  businessDays,
2240
2242
  weekendPredicate
2241
2243
  };
2242
- }, [edgeZoneWidth, currentLeft, currentWidth, dayWidth, monthStart, taskId, onDragStateChange, handleProgress, handleComplete, handleCancel, allTasks, disableConstraints, onCascadeProgress, onCascade, locked]);
2244
+ }, [edgeZoneWidth, currentLeft, currentWidth, dayWidth, monthStart, taskId, onDragStateChange, handleProgress, handleComplete, handleCancel, allTasks, disableConstraints, onCascadeProgress, onCascade, effectiveLocked]);
2243
2245
  const getCursorStyle = (0, import_react2.useCallback)(() => {
2246
+ if (disableTaskDrag) return "grab";
2244
2247
  if (locked) return "not-allowed";
2245
2248
  if (isDragging) {
2246
2249
  return "grabbing";
2247
2250
  }
2248
2251
  return "grab";
2249
- }, [locked, isDragging]);
2252
+ }, [disableTaskDrag, locked, isDragging]);
2250
2253
  return {
2251
2254
  isDragging,
2252
2255
  dragMode,
@@ -2265,10 +2268,10 @@ var useTaskDrag = (options) => {
2265
2268
  // src/components/TaskRow/TaskRow.tsx
2266
2269
  var import_jsx_runtime2 = require("react/jsx-runtime");
2267
2270
  var arePropsEqual = (prevProps, nextProps) => {
2268
- return prevProps.task.id === nextProps.task.id && prevProps.task.name === nextProps.task.name && prevProps.task.startDate === nextProps.task.startDate && prevProps.task.endDate === nextProps.task.endDate && prevProps.task.color === nextProps.task.color && prevProps.task.progress === nextProps.task.progress && prevProps.task.accepted === nextProps.task.accepted && prevProps.monthStart.getTime() === nextProps.monthStart.getTime() && prevProps.dayWidth === nextProps.dayWidth && prevProps.rowHeight === nextProps.rowHeight && prevProps.overridePosition?.left === nextProps.overridePosition?.left && prevProps.overridePosition?.width === nextProps.overridePosition?.width && prevProps.allTasks === nextProps.allTasks && prevProps.disableConstraints === nextProps.disableConstraints && prevProps.task.locked === nextProps.task.locked && prevProps.task.divider === nextProps.task.divider && prevProps.highlightExpiredTasks === nextProps.highlightExpiredTasks && prevProps.isFilterMatch === nextProps.isFilterMatch && prevProps.businessDays === nextProps.businessDays && prevProps.customDays === nextProps.customDays && prevProps.isWeekend === nextProps.isWeekend;
2271
+ return prevProps.task.id === nextProps.task.id && prevProps.task.name === nextProps.task.name && prevProps.task.startDate === nextProps.task.startDate && prevProps.task.endDate === nextProps.task.endDate && prevProps.task.color === nextProps.task.color && prevProps.task.progress === nextProps.task.progress && prevProps.task.accepted === nextProps.task.accepted && prevProps.monthStart.getTime() === nextProps.monthStart.getTime() && prevProps.dayWidth === nextProps.dayWidth && prevProps.rowHeight === nextProps.rowHeight && prevProps.overridePosition?.left === nextProps.overridePosition?.left && prevProps.overridePosition?.width === nextProps.overridePosition?.width && prevProps.allTasks === nextProps.allTasks && prevProps.disableConstraints === nextProps.disableConstraints && prevProps.task.locked === nextProps.task.locked && prevProps.task.divider === nextProps.task.divider && prevProps.highlightExpiredTasks === nextProps.highlightExpiredTasks && prevProps.isFilterMatch === nextProps.isFilterMatch && prevProps.businessDays === nextProps.businessDays && prevProps.customDays === nextProps.customDays && prevProps.isWeekend === nextProps.isWeekend && prevProps.disableTaskDrag === nextProps.disableTaskDrag;
2269
2272
  };
2270
2273
  var TaskRow = import_react3.default.memo(
2271
- ({ task, monthStart, dayWidth, rowHeight, onTasksChange, onDragStateChange, rowIndex, allTasks, enableAutoSchedule, disableConstraints, overridePosition, onCascadeProgress, onCascade, divider, highlightExpiredTasks, isFilterMatch = false, businessDays, customDays, isWeekend: isWeekend3 }) => {
2274
+ ({ task, monthStart, dayWidth, rowHeight, onTasksChange, onDragStateChange, rowIndex, allTasks, enableAutoSchedule, disableConstraints, overridePosition, onCascadeProgress, onCascade, divider, highlightExpiredTasks, isFilterMatch = false, businessDays, customDays, isWeekend: isWeekend3, disableTaskDrag = false }) => {
2272
2275
  const { divider: taskDivider } = task;
2273
2276
  const taskStartDate = (0, import_react3.useMemo)(() => parseUTCDate(task.startDate), [task.startDate]);
2274
2277
  const taskEndDate = (0, import_react3.useMemo)(() => parseUTCDate(task.endDate), [task.endDate]);
@@ -2348,6 +2351,7 @@ var TaskRow = import_react3.default.memo(
2348
2351
  enableAutoSchedule,
2349
2352
  disableConstraints,
2350
2353
  locked: task.locked,
2354
+ disableTaskDrag,
2351
2355
  onCascadeProgress,
2352
2356
  onCascade,
2353
2357
  businessDays,
@@ -5964,7 +5968,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
5964
5968
  taskFilter,
5965
5969
  collapsedParentIds: externalCollapsedParentIds,
5966
5970
  onToggleCollapse: externalOnToggleCollapse,
5967
- highlightedTaskIds
5971
+ highlightedTaskIds,
5972
+ disableTaskDrag = false
5968
5973
  }, ref) => {
5969
5974
  const scrollContainerRef = (0, import_react13.useRef)(null);
5970
5975
  const [selectedTaskId, setSelectedTaskId] = (0, import_react13.useState)(null);
@@ -6512,7 +6517,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
6512
6517
  isFilterMatch: matchedTaskIds.has(task.id),
6513
6518
  businessDays,
6514
6519
  customDays,
6515
- isWeekend: isWeekend3
6520
+ isWeekend: isWeekend3,
6521
+ disableTaskDrag
6516
6522
  },
6517
6523
  task.id
6518
6524
  ))