gantt-task-react-powern 0.6.30 → 0.6.32
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/helpers/date-helper.d.ts +16 -0
- package/dist/index.js +130 -54
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +130 -54
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -74,6 +74,7 @@ var ViewMode;
|
|
|
74
74
|
ViewMode["Year"] = "Year";
|
|
75
75
|
})(ViewMode || (ViewMode = {}));
|
|
76
76
|
|
|
77
|
+
var _VIEW_MODE_DEFAULT_VI, _VIEW_MODE_MAX_VISIBL;
|
|
77
78
|
var intlDTCache = {};
|
|
78
79
|
var getCachedDateTimeFormat = function getCachedDateTimeFormat(locString, opts) {
|
|
79
80
|
if (opts === void 0) {
|
|
@@ -115,6 +116,8 @@ var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarter
|
|
|
115
116
|
return new Date(year, qStartMonth, 1);
|
|
116
117
|
};
|
|
117
118
|
|
|
119
|
+
var VIEW_MODE_DEFAULT_VISIBLE_COUNT = (_VIEW_MODE_DEFAULT_VI = {}, _VIEW_MODE_DEFAULT_VI[ViewMode.Day] = 14, _VIEW_MODE_DEFAULT_VI[ViewMode.Week] = 6, _VIEW_MODE_DEFAULT_VI[ViewMode.Month] = 6, _VIEW_MODE_DEFAULT_VI[ViewMode.Quarter] = 4, _VIEW_MODE_DEFAULT_VI);
|
|
120
|
+
var VIEW_MODE_MAX_VISIBLE_COUNT = (_VIEW_MODE_MAX_VISIBL = {}, _VIEW_MODE_MAX_VISIBL[ViewMode.Day] = 30, _VIEW_MODE_MAX_VISIBL[ViewMode.Week] = 13, _VIEW_MODE_MAX_VISIBL[ViewMode.Month] = 12, _VIEW_MODE_MAX_VISIBL[ViewMode.Quarter] = 8, _VIEW_MODE_MAX_VISIBL);
|
|
118
121
|
var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
|
|
119
122
|
var _tasks$, _tasks$2, _tasks$3, _tasks$4;
|
|
120
123
|
|
|
@@ -2044,8 +2047,8 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
|
|
|
2044
2047
|
|
|
2045
2048
|
if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[0].x1;
|
|
2046
2049
|
var candidates = [];
|
|
2047
|
-
if (t.
|
|
2048
|
-
if (t.
|
|
2050
|
+
if (t.x2 > t.x1) candidates.push(t.x1);
|
|
2051
|
+
if (t.actualx2 > t.actualx1) candidates.push(t.actualx1);
|
|
2049
2052
|
return candidates.length > 0 ? Math.min.apply(Math, candidates) : 0;
|
|
2050
2053
|
};
|
|
2051
2054
|
|
|
@@ -2058,8 +2061,8 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
|
|
|
2058
2061
|
|
|
2059
2062
|
if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[t.actualSegments.length - 1].x2;
|
|
2060
2063
|
var candidates = [];
|
|
2061
|
-
if (t.x2
|
|
2062
|
-
if (t.actualx2
|
|
2064
|
+
if (t.x2 > t.x1) candidates.push(t.x2);
|
|
2065
|
+
if (t.actualx2 > t.actualx1) candidates.push(t.actualx2);
|
|
2063
2066
|
return candidates.length > 0 ? Math.max.apply(Math, candidates) : 0;
|
|
2064
2067
|
};
|
|
2065
2068
|
|
|
@@ -3581,7 +3584,12 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3581
3584
|
|
|
3582
3585
|
var getArrows = function getArrows(isCritical, criticalPathType) {
|
|
3583
3586
|
return tasks.flatMap(function (_task) {
|
|
3584
|
-
var
|
|
3587
|
+
var a = ganttEvent.action;
|
|
3588
|
+
var isDraggingThis = (a === "move" || a === "start" || a === "end" || a === "progress") && !!ganttEvent.changedTask && ganttEvent.changedTask.id === _task.id;
|
|
3589
|
+
|
|
3590
|
+
var _live = isDraggingThis ? _extends({}, ganttEvent.changedTask, {
|
|
3591
|
+
y: _task.y
|
|
3592
|
+
}) : _task;
|
|
3585
3593
|
|
|
3586
3594
|
var task = _live.start.getTime() > 0 && _live.end.getTime() > 0 ? _live : undefined;
|
|
3587
3595
|
|
|
@@ -3590,13 +3598,16 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3590
3598
|
}
|
|
3591
3599
|
|
|
3592
3600
|
return task.barChildren.map(function (child) {
|
|
3593
|
-
|
|
3601
|
+
var taskTo = tasks[child.index];
|
|
3602
|
+
var fromDrawable = task.x2 > task.x1 || task.actualx2 > task.actualx1;
|
|
3603
|
+
var toDrawable = !!taskTo && (taskTo.x2 > taskTo.x1 || taskTo.actualx2 > taskTo.actualx1);
|
|
3604
|
+
|
|
3605
|
+
if (fromDrawable && toDrawable) {
|
|
3594
3606
|
var _task$criticalPathArr;
|
|
3595
3607
|
|
|
3596
3608
|
var criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(function (arrow) {
|
|
3597
|
-
return arrow.taskId ===
|
|
3609
|
+
return arrow.taskId === taskTo.id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
|
|
3598
3610
|
});
|
|
3599
|
-
var taskTo = tasks[child.index];
|
|
3600
3611
|
var yFrom = task.y + taskHeight / 2;
|
|
3601
3612
|
var yTo = taskTo.y + taskHeight / 2;
|
|
3602
3613
|
var minY = Math.min(yFrom, yTo);
|
|
@@ -3608,9 +3619,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3608
3619
|
|
|
3609
3620
|
if (!!criticalTask === isCritical) {
|
|
3610
3621
|
return React.createElement(Arrow, {
|
|
3611
|
-
key: "Arrow from " + task.id + " to " +
|
|
3622
|
+
key: "Arrow from " + task.id + " to " + taskTo.id + (isCritical ? "-critical" : ""),
|
|
3612
3623
|
taskFrom: task,
|
|
3613
|
-
taskTo:
|
|
3624
|
+
taskTo: taskTo,
|
|
3614
3625
|
rowHeight: rowHeight,
|
|
3615
3626
|
dependencyType: child.dependencyType,
|
|
3616
3627
|
taskHeight: taskHeight,
|
|
@@ -3804,6 +3815,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3804
3815
|
};
|
|
3805
3816
|
|
|
3806
3817
|
var Gantt = function Gantt(_ref) {
|
|
3818
|
+
var _ref3;
|
|
3819
|
+
|
|
3807
3820
|
var tasks = _ref.tasks,
|
|
3808
3821
|
_ref$leafTasks = _ref.leafTasks,
|
|
3809
3822
|
leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
|
|
@@ -3815,8 +3828,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3815
3828
|
endDate = _ref$endDate === void 0 ? new Date() : _ref$endDate,
|
|
3816
3829
|
_ref$headerHeight = _ref.headerHeight,
|
|
3817
3830
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
3818
|
-
|
|
3819
|
-
columnWidth = _ref$columnWidth === void 0 ? 60 : _ref$columnWidth,
|
|
3831
|
+
columnWidthProp = _ref.columnWidth,
|
|
3820
3832
|
_ref$listCellWidth = _ref.listCellWidth,
|
|
3821
3833
|
listCellWidth = _ref$listCellWidth === void 0 ? "155px" : _ref$listCellWidth,
|
|
3822
3834
|
_ref$rowHeight = _ref.rowHeight,
|
|
@@ -3897,6 +3909,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3897
3909
|
var wrapperRef = useRef(null);
|
|
3898
3910
|
var taskListRef = useRef(null);
|
|
3899
3911
|
var isDraggingTable = useRef(false);
|
|
3912
|
+
var userResizedRef = useRef(false);
|
|
3900
3913
|
var dragStartX = useRef(0);
|
|
3901
3914
|
var dragStartWidth = useRef(0);
|
|
3902
3915
|
var dragMaxWidth = useRef(Infinity);
|
|
@@ -3953,6 +3966,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3953
3966
|
var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
|
|
3954
3967
|
|
|
3955
3968
|
isDraggingTable.current = true;
|
|
3969
|
+
userResizedRef.current = true;
|
|
3956
3970
|
dragStartX.current = e.clientX;
|
|
3957
3971
|
dragStartWidth.current = tableContainerWidth != null ? tableContainerWidth : (_taskListRef$current$ = (_taskListRef$current = taskListRef.current) === null || _taskListRef$current === void 0 ? void 0 : _taskListRef$current.offsetWidth) != null ? _taskListRef$current$ : 0;
|
|
3958
3972
|
dragMaxWidth.current = (_ref2 = (_tableHorizontalConta = (_tableHorizontalConta2 = tableHorizontalContainerRef.current) === null || _tableHorizontalConta2 === void 0 ? void 0 : _tableHorizontalConta2.scrollWidth) != null ? _tableHorizontalConta : (_tableInnerScrollRef$ = tableInnerScrollRef.current) === null || _tableInnerScrollRef$ === void 0 ? void 0 : _tableInnerScrollRef$.scrollWidth) != null ? _ref2 : Math.max(100, ((_wrapperRef$current$o = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.offsetWidth) != null ? _wrapperRef$current$o : Infinity) - 200);
|
|
@@ -4019,38 +4033,99 @@ var Gantt = function Gantt(_ref) {
|
|
|
4019
4033
|
failedTask = _useState11[0],
|
|
4020
4034
|
setFailedTask = _useState11[1];
|
|
4021
4035
|
|
|
4036
|
+
var _useState12 = useState(null),
|
|
4037
|
+
computedColumnWidth = _useState12[0],
|
|
4038
|
+
setComputedColumnWidth = _useState12[1];
|
|
4039
|
+
|
|
4040
|
+
var computedForViewModeRef = useRef(null);
|
|
4041
|
+
useEffect(function () {
|
|
4042
|
+
if (columnWidthProp != null) return;
|
|
4043
|
+
if (svgContainerWidth <= 0) return;
|
|
4044
|
+
var minVisible = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
|
|
4045
|
+
if (!minVisible) return;
|
|
4046
|
+
var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
|
|
4047
|
+
var prevViewMode = computedForViewModeRef.current;
|
|
4048
|
+
|
|
4049
|
+
if (prevViewMode != null && prevViewMode !== viewMode && computedColumnWidth != null) {
|
|
4050
|
+
var visible = svgContainerWidth / computedColumnWidth;
|
|
4051
|
+
var oldMin = VIEW_MODE_DEFAULT_VISIBLE_COUNT[prevViewMode];
|
|
4052
|
+
var oldMax = VIEW_MODE_MAX_VISIBLE_COUNT[prevViewMode];
|
|
4053
|
+
var _next = computedColumnWidth;
|
|
4054
|
+
|
|
4055
|
+
if (maxVisible && oldMin != null && oldMax != null && oldMax > oldMin) {
|
|
4056
|
+
var t = Math.min(1, Math.max(0, (visible - oldMin) / (oldMax - oldMin)));
|
|
4057
|
+
var targetVisible = minVisible + t * (maxVisible - minVisible);
|
|
4058
|
+
_next = Math.floor(svgContainerWidth / targetVisible);
|
|
4059
|
+
} else if (visible < minVisible) {
|
|
4060
|
+
_next = Math.floor(svgContainerWidth / minVisible);
|
|
4061
|
+
} else if (maxVisible && visible > maxVisible) {
|
|
4062
|
+
_next = Math.ceil(svgContainerWidth / maxVisible);
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
_next = Math.max(20, _next);
|
|
4066
|
+
computedForViewModeRef.current = viewMode;
|
|
4067
|
+
userResizedRef.current = true;
|
|
4068
|
+
|
|
4069
|
+
if (_next !== computedColumnWidth) {
|
|
4070
|
+
setComputedColumnWidth(_next);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
return;
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
|
|
4077
|
+
if (userResizedRef.current && alreadySnappedForView) return;
|
|
4078
|
+
var next = Math.max(20, Math.floor(svgContainerWidth / minVisible));
|
|
4079
|
+
computedForViewModeRef.current = viewMode;
|
|
4080
|
+
|
|
4081
|
+
if (next !== computedColumnWidth) {
|
|
4082
|
+
setComputedColumnWidth(next);
|
|
4083
|
+
}
|
|
4084
|
+
}, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
|
|
4085
|
+
var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
|
|
4022
4086
|
var effectiveColumnWidth = useMemo(function () {
|
|
4023
4087
|
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
4088
|
+
|
|
4089
|
+
if (columnWidthProp == null) {
|
|
4090
|
+
var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
|
|
4091
|
+
|
|
4092
|
+
if (maxVisible) {
|
|
4093
|
+
return Math.max(columnWidth, Math.ceil(svgContainerWidth / maxVisible));
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
return columnWidth;
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4024
4099
|
return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
|
|
4025
|
-
}, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
|
|
4100
|
+
}, [columnWidth, columnWidthProp, viewMode, svgContainerWidth, dateSetup.dates.length]);
|
|
4026
4101
|
var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
|
|
4027
4102
|
var ganttFullHeight = useMemo(function () {
|
|
4028
4103
|
return barTasks.length * rowHeight;
|
|
4029
4104
|
}, [barTasks.length, rowHeight]);
|
|
4030
4105
|
|
|
4031
|
-
var
|
|
4032
|
-
scrollY =
|
|
4033
|
-
setScrollY =
|
|
4106
|
+
var _useState13 = useState(0),
|
|
4107
|
+
scrollY = _useState13[0],
|
|
4108
|
+
setScrollY = _useState13[1];
|
|
4034
4109
|
|
|
4035
|
-
var
|
|
4036
|
-
scrollX =
|
|
4037
|
-
setScrollX =
|
|
4110
|
+
var _useState14 = useState(-1),
|
|
4111
|
+
scrollX = _useState14[0],
|
|
4112
|
+
setScrollX = _useState14[1];
|
|
4038
4113
|
|
|
4039
|
-
var
|
|
4040
|
-
ignoreScrollEvent =
|
|
4041
|
-
setIgnoreScrollEvent =
|
|
4042
|
-
|
|
4043
|
-
var _useState15 = useState(0),
|
|
4044
|
-
lastTouchX = _useState15[0],
|
|
4045
|
-
setLastTouchX = _useState15[1];
|
|
4114
|
+
var _useState15 = useState(false),
|
|
4115
|
+
ignoreScrollEvent = _useState15[0],
|
|
4116
|
+
setIgnoreScrollEvent = _useState15[1];
|
|
4046
4117
|
|
|
4047
4118
|
var _useState16 = useState(0),
|
|
4048
|
-
|
|
4049
|
-
|
|
4119
|
+
lastTouchX = _useState16[0],
|
|
4120
|
+
setLastTouchX = _useState16[1];
|
|
4121
|
+
|
|
4122
|
+
var _useState17 = useState(0),
|
|
4123
|
+
lastTouchY = _useState17[0],
|
|
4124
|
+
setLastTouchY = _useState17[1];
|
|
4050
4125
|
|
|
4051
|
-
var
|
|
4052
|
-
isProcessing =
|
|
4053
|
-
setIsProcessing =
|
|
4126
|
+
var _useState18 = useState(false),
|
|
4127
|
+
isProcessing = _useState18[0],
|
|
4128
|
+
setIsProcessing = _useState18[1];
|
|
4054
4129
|
|
|
4055
4130
|
var buffer = rowHeight * 10;
|
|
4056
4131
|
var visibleStartY = scrollY - buffer;
|
|
@@ -4290,7 +4365,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
4290
4365
|
};
|
|
4291
4366
|
|
|
4292
4367
|
var handleScrollX = function handleScrollX(event) {
|
|
4293
|
-
if (scrollX !== event.currentTarget.scrollLeft) {
|
|
4368
|
+
if (scrollX !== event.currentTarget.scrollLeft && !ignoreScrollEvent) {
|
|
4294
4369
|
setScrollX(event.currentTarget.scrollLeft);
|
|
4295
4370
|
setIgnoreScrollEvent(true);
|
|
4296
4371
|
} else {
|
|
@@ -4600,6 +4675,9 @@ function topologicalOrderingHelper(taskID, taskMap, sortedTaskList) {
|
|
|
4600
4675
|
return true;
|
|
4601
4676
|
}
|
|
4602
4677
|
function getCriticalPaths(leafTasks) {
|
|
4678
|
+
leafTasks = leafTasks.filter(function (t) {
|
|
4679
|
+
return t.type !== "milestone" && (t.start.getTime() !== 0 || t.end.getTime() !== 0);
|
|
4680
|
+
});
|
|
4603
4681
|
var taskMap = {};
|
|
4604
4682
|
|
|
4605
4683
|
for (var i = 0; i < leafTasks.length; i++) {
|
|
@@ -4782,28 +4860,26 @@ function computeCriticalPath(taskID, taskMap) {
|
|
|
4782
4860
|
taskMap[taskID].paths[1].visited = false;
|
|
4783
4861
|
}
|
|
4784
4862
|
}
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
taskMap[taskID].paths[1].visited = false;
|
|
4806
|
-
}
|
|
4863
|
+
} else {
|
|
4864
|
+
var immediateChildDuration = taskMap[taskID].end - taskMap[taskID].start + depDuration - overlap - offTime;
|
|
4865
|
+
|
|
4866
|
+
if (taskMap[taskID].paths.length < 2) {
|
|
4867
|
+
taskMap[taskID].paths.push({
|
|
4868
|
+
duration: immediateChildDuration,
|
|
4869
|
+
task: dependents[j],
|
|
4870
|
+
parent: taskID,
|
|
4871
|
+
visited: false
|
|
4872
|
+
});
|
|
4873
|
+
} else if (immediateChildDuration > taskMap[taskID].paths[0].duration) {
|
|
4874
|
+
taskMap[taskID].paths[0].duration = immediateChildDuration;
|
|
4875
|
+
taskMap[taskID].paths[0].task = dependents[j];
|
|
4876
|
+
taskMap[taskID].paths[0].parent = taskID;
|
|
4877
|
+
taskMap[taskID].paths[0].visited = false;
|
|
4878
|
+
} else if (immediateChildDuration > taskMap[taskID].paths[1].duration) {
|
|
4879
|
+
taskMap[taskID].paths[1].duration = immediateChildDuration;
|
|
4880
|
+
taskMap[taskID].paths[1].task = dependents[j];
|
|
4881
|
+
taskMap[taskID].paths[1].parent = taskID;
|
|
4882
|
+
taskMap[taskID].paths[1].visited = false;
|
|
4807
4883
|
}
|
|
4808
4884
|
}
|
|
4809
4885
|
}
|