gantt-lib 0.129.0 → 0.131.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/core/scheduling/index.d.mts +1 -1
- package/dist/core/scheduling/index.d.ts +1 -1
- package/dist/core/scheduling/index.js +1 -1
- package/dist/core/scheduling/index.js.map +1 -1
- package/dist/core/scheduling/index.mjs +1 -1
- package/dist/core/scheduling/index.mjs.map +1 -1
- package/dist/{index-CIFbOgGc.d.mts → index-CZ_2i1CO.d.mts} +2 -0
- package/dist/{index-CIFbOgGc.d.ts → index-CZ_2i1CO.d.ts} +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1043,7 +1043,7 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
|
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
1045
|
const parentId = currentOriginal.parentId;
|
|
1046
|
-
if (parentId) {
|
|
1046
|
+
if (parentId && parentId !== movedTask.id) {
|
|
1047
1047
|
const parent = taskById.get(parentId);
|
|
1048
1048
|
if (parent && !parent.locked) {
|
|
1049
1049
|
const siblings = childrenByParentId.get(parentId) ?? [];
|
|
@@ -3583,6 +3583,30 @@ function cancelDrag() {
|
|
|
3583
3583
|
function snapToGrid(pixels, dayWidth) {
|
|
3584
3584
|
return Math.round(pixels / dayWidth) * dayWidth;
|
|
3585
3585
|
}
|
|
3586
|
+
function resolveDragRangeForInteraction(activeDrag, task, mode, left, width) {
|
|
3587
|
+
const proposedRange = resolveDateRangeFromPixels(
|
|
3588
|
+
mode,
|
|
3589
|
+
left,
|
|
3590
|
+
width,
|
|
3591
|
+
activeDrag.monthStart,
|
|
3592
|
+
activeDrag.dayWidth,
|
|
3593
|
+
task,
|
|
3594
|
+
activeDrag.businessDays,
|
|
3595
|
+
activeDrag.weekendPredicate
|
|
3596
|
+
);
|
|
3597
|
+
if (activeDrag.scheduleIntentMode) {
|
|
3598
|
+
return proposedRange;
|
|
3599
|
+
}
|
|
3600
|
+
return clampDateRangeForIncomingFS(
|
|
3601
|
+
task,
|
|
3602
|
+
proposedRange,
|
|
3603
|
+
activeDrag.allTasks,
|
|
3604
|
+
mode,
|
|
3605
|
+
activeDrag.businessDays,
|
|
3606
|
+
activeDrag.weekendPredicate,
|
|
3607
|
+
activeDrag.cascadeContext?.taskById
|
|
3608
|
+
);
|
|
3609
|
+
}
|
|
3586
3610
|
function handleGlobalMouseMove(e) {
|
|
3587
3611
|
if (!globalActiveDrag || globalRafId !== null) {
|
|
3588
3612
|
return;
|
|
@@ -3615,45 +3639,13 @@ function handleGlobalMouseMove(e) {
|
|
|
3615
3639
|
break;
|
|
3616
3640
|
}
|
|
3617
3641
|
if (activeDrag.businessDays && activeDrag.weekendPredicate && draggedTask) {
|
|
3618
|
-
const previewRange =
|
|
3619
|
-
draggedTask,
|
|
3620
|
-
resolveDateRangeFromPixels(
|
|
3621
|
-
mode,
|
|
3622
|
-
newLeft,
|
|
3623
|
-
newWidth,
|
|
3624
|
-
activeDrag.monthStart,
|
|
3625
|
-
dayWidth,
|
|
3626
|
-
draggedTask,
|
|
3627
|
-
true,
|
|
3628
|
-
activeDrag.weekendPredicate
|
|
3629
|
-
),
|
|
3630
|
-
allTasks,
|
|
3631
|
-
mode,
|
|
3632
|
-
true,
|
|
3633
|
-
activeDrag.weekendPredicate,
|
|
3634
|
-
activeDrag.cascadeContext?.taskById
|
|
3635
|
-
);
|
|
3642
|
+
const previewRange = resolveDragRangeForInteraction(activeDrag, draggedTask, mode, newLeft, newWidth);
|
|
3636
3643
|
const alignedStartDay = getDayOffsetFromMonthStart(previewRange.start, activeDrag.monthStart);
|
|
3637
3644
|
const alignedEndDay = getDayOffsetFromMonthStart(previewRange.end, activeDrag.monthStart);
|
|
3638
3645
|
newLeft = Math.round(alignedStartDay * dayWidth);
|
|
3639
3646
|
newWidth = Math.round((alignedEndDay - alignedStartDay + 1) * dayWidth);
|
|
3640
3647
|
} else if (draggedTask) {
|
|
3641
|
-
const previewRange =
|
|
3642
|
-
draggedTask,
|
|
3643
|
-
resolveDateRangeFromPixels(
|
|
3644
|
-
mode,
|
|
3645
|
-
newLeft,
|
|
3646
|
-
newWidth,
|
|
3647
|
-
activeDrag.monthStart,
|
|
3648
|
-
dayWidth,
|
|
3649
|
-
draggedTask
|
|
3650
|
-
),
|
|
3651
|
-
allTasks,
|
|
3652
|
-
mode,
|
|
3653
|
-
activeDrag.businessDays,
|
|
3654
|
-
activeDrag.weekendPredicate,
|
|
3655
|
-
activeDrag.cascadeContext?.taskById
|
|
3656
|
-
);
|
|
3648
|
+
const previewRange = resolveDragRangeForInteraction(activeDrag, draggedTask, mode, newLeft, newWidth);
|
|
3657
3649
|
const alignedStartDay = getDayOffsetFromMonthStart(previewRange.start, activeDrag.monthStart);
|
|
3658
3650
|
const alignedEndDay = getDayOffsetFromMonthStart(previewRange.end, activeDrag.monthStart);
|
|
3659
3651
|
newLeft = Math.round(alignedStartDay * dayWidth);
|
|
@@ -3665,24 +3657,7 @@ function handleGlobalMouseMove(e) {
|
|
|
3665
3657
|
const isParentResizePreview = draggedTask && (mode === "resize-left" || mode === "resize-right") && isTaskParent(activeDrag.taskId, allTasks);
|
|
3666
3658
|
if (isParentResizePreview && activeDrag.onCascadeProgress) {
|
|
3667
3659
|
const { dayWidth: dw, monthStart: mStart } = activeDrag;
|
|
3668
|
-
const previewRange =
|
|
3669
|
-
draggedTask,
|
|
3670
|
-
resolveDateRangeFromPixels(
|
|
3671
|
-
mode,
|
|
3672
|
-
newLeft,
|
|
3673
|
-
newWidth,
|
|
3674
|
-
mStart,
|
|
3675
|
-
dw,
|
|
3676
|
-
draggedTask,
|
|
3677
|
-
activeDrag.businessDays,
|
|
3678
|
-
activeDrag.weekendPredicate
|
|
3679
|
-
),
|
|
3680
|
-
allTasks,
|
|
3681
|
-
mode,
|
|
3682
|
-
activeDrag.businessDays,
|
|
3683
|
-
activeDrag.weekendPredicate,
|
|
3684
|
-
activeDrag.cascadeContext?.taskById
|
|
3685
|
-
);
|
|
3660
|
+
const previewRange = resolveDragRangeForInteraction(activeDrag, draggedTask, mode, newLeft, newWidth);
|
|
3686
3661
|
const anchor = mode === "resize-left" ? "end" : "start";
|
|
3687
3662
|
const parentRange = computeParentDates(activeDrag.taskId, allTasks);
|
|
3688
3663
|
const targetDuration = Math.max(1, getTaskDuration(
|
|
@@ -3929,23 +3904,15 @@ var useTaskDrag = (options) => {
|
|
|
3929
3904
|
isOwnerRef.current = false;
|
|
3930
3905
|
const currentTaskRaw = allTasks.find((t) => t.id === taskId);
|
|
3931
3906
|
const currentTask = currentTaskRaw ? normalizeTaskDatesForType(currentTaskRaw) : void 0;
|
|
3932
|
-
const
|
|
3933
|
-
currentTask,
|
|
3934
|
-
resolveDateRangeFromPixels(
|
|
3935
|
-
finalMode,
|
|
3936
|
-
finalLeft,
|
|
3937
|
-
finalWidth,
|
|
3938
|
-
monthStart,
|
|
3939
|
-
dayWidth,
|
|
3940
|
-
currentTask,
|
|
3941
|
-
businessDays,
|
|
3942
|
-
weekendPredicate
|
|
3943
|
-
),
|
|
3944
|
-
allTasks,
|
|
3907
|
+
const proposedFinalRange = currentTask ? resolveDateRangeFromPixels(
|
|
3945
3908
|
finalMode,
|
|
3909
|
+
finalLeft,
|
|
3910
|
+
finalWidth,
|
|
3911
|
+
monthStart,
|
|
3912
|
+
dayWidth,
|
|
3913
|
+
currentTask,
|
|
3946
3914
|
businessDays,
|
|
3947
|
-
weekendPredicate
|
|
3948
|
-
cascadeContext?.taskById
|
|
3915
|
+
weekendPredicate
|
|
3949
3916
|
) : (() => {
|
|
3950
3917
|
const dayOffset = Math.round(finalLeft / dayWidth);
|
|
3951
3918
|
const durationDays = Math.round(finalWidth / dayWidth) - 1;
|
|
@@ -3962,6 +3929,15 @@ var useTaskDrag = (options) => {
|
|
|
3962
3929
|
))
|
|
3963
3930
|
};
|
|
3964
3931
|
})();
|
|
3932
|
+
const finalRange = currentTask && !onScheduleIntent ? clampDateRangeForIncomingFS(
|
|
3933
|
+
currentTask,
|
|
3934
|
+
proposedFinalRange,
|
|
3935
|
+
allTasks,
|
|
3936
|
+
finalMode,
|
|
3937
|
+
businessDays,
|
|
3938
|
+
weekendPredicate,
|
|
3939
|
+
cascadeContext?.taskById
|
|
3940
|
+
) : proposedFinalRange;
|
|
3965
3941
|
const newStartDate = finalRange.start;
|
|
3966
3942
|
const newEndDate = currentTask && isMilestoneTask(currentTask) ? finalRange.start : finalRange.end;
|
|
3967
3943
|
setIsDragging(false);
|
|
@@ -4026,7 +4002,7 @@ var useTaskDrag = (options) => {
|
|
|
4026
4002
|
}
|
|
4027
4003
|
}
|
|
4028
4004
|
const isParentResize = currentTask && (finalMode === "resize-left" || finalMode === "resize-right") ? isTaskParent(taskId, allTasks) : false;
|
|
4029
|
-
if (!disableConstraints && onCascade && allTasks.length > 0 && !isParentResize) {
|
|
4005
|
+
if (!disableConstraints && onCascade && !onScheduleIntent && allTasks.length > 0 && !isParentResize) {
|
|
4030
4006
|
const draggedTaskData = currentTask;
|
|
4031
4007
|
const movedTask = {
|
|
4032
4008
|
...draggedTaskData ?? { id: taskId, name: "", startDate: "", endDate: "" },
|
|
@@ -4177,7 +4153,8 @@ var useTaskDrag = (options) => {
|
|
|
4177
4153
|
onCascadeProgress,
|
|
4178
4154
|
businessDays,
|
|
4179
4155
|
weekendPredicate,
|
|
4180
|
-
cascadeContext: shouldBuildCascadeContext ? createCascadeContext(allTasks) : void 0
|
|
4156
|
+
cascadeContext: shouldBuildCascadeContext ? createCascadeContext(allTasks) : void 0,
|
|
4157
|
+
scheduleIntentMode: Boolean(onScheduleIntent)
|
|
4181
4158
|
};
|
|
4182
4159
|
}, [edgeZoneWidth, currentLeft, currentWidth, dayWidth, monthStart, taskId, onDragStateChange, handleProgress, handleComplete, handleCancel, allTasks, disableConstraints, onCascadeProgress, onCascade, effectiveLocked, viewMode]);
|
|
4183
4160
|
const handleMouseDown = useCallback((e) => {
|
|
@@ -14397,7 +14374,8 @@ function TaskGanttChartInner(props, ref) {
|
|
|
14397
14374
|
type: "change_duration",
|
|
14398
14375
|
taskId: updatedTask.id,
|
|
14399
14376
|
duration: targetDuration,
|
|
14400
|
-
anchor: durationEdit?.anchor ?? anchor
|
|
14377
|
+
anchor: durationEdit?.anchor ?? anchor,
|
|
14378
|
+
...durationEdit ? { taskType: updatedTask.type ?? "task" } : {}
|
|
14401
14379
|
});
|
|
14402
14380
|
const scaleResult = scaleTaskSubtreeDuration(updatedTask.id, targetDuration, tasks, {
|
|
14403
14381
|
anchor,
|
|
@@ -14437,7 +14415,8 @@ function TaskGanttChartInner(props, ref) {
|
|
|
14437
14415
|
type: "change_duration",
|
|
14438
14416
|
taskId: updatedTask.id,
|
|
14439
14417
|
duration: durationEdit.duration,
|
|
14440
|
-
anchor: durationEdit.anchor
|
|
14418
|
+
anchor: durationEdit.anchor,
|
|
14419
|
+
taskType: updatedTask.type ?? "task"
|
|
14441
14420
|
});
|
|
14442
14421
|
} else {
|
|
14443
14422
|
onTasksChange?.(cascadedTasks);
|