gantt-task-react-powern 0.6.29 → 0.6.31
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 +69 -43
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +69 -43
- package/dist/index.modern.js.map +1 -1
- package/dist/types/public-types.d.ts +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
|
|
|
@@ -1424,7 +1427,7 @@ var GridBody = function GridBody(_ref) {
|
|
|
1424
1427
|
height: rowHeight,
|
|
1425
1428
|
fill: rowFill
|
|
1426
1429
|
}));
|
|
1427
|
-
var cal = task.
|
|
1430
|
+
var cal = task.calendar;
|
|
1428
1431
|
|
|
1429
1432
|
if (cal) {
|
|
1430
1433
|
for (var _i = 0, _x = 0; _i < dates.length; _i++, _x += columnWidth) {
|
|
@@ -2206,9 +2209,9 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
2206
2209
|
var plannedSegments;
|
|
2207
2210
|
var actualSegments;
|
|
2208
2211
|
|
|
2209
|
-
if (task.
|
|
2212
|
+
if (task.calendar && task.start && task.end && task.start.getTime() > 0) {
|
|
2210
2213
|
var planEnd = addToDate(startOfDate(task.end, "day"), 1, "day");
|
|
2211
|
-
var intervals = getWorkingIntervals(task.start, planEnd, task.
|
|
2214
|
+
var intervals = getWorkingIntervals(task.start, planEnd, task.calendar);
|
|
2212
2215
|
var segs = intervals.map(function (iv) {
|
|
2213
2216
|
return {
|
|
2214
2217
|
x1: taskXCoordinate(iv.start, dates, columnWidth),
|
|
@@ -2220,10 +2223,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
2220
2223
|
if (segs.length > 0) plannedSegments = segs;
|
|
2221
2224
|
}
|
|
2222
2225
|
|
|
2223
|
-
if (task.
|
|
2226
|
+
if (task.calendar && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
|
|
2224
2227
|
var actEnd = addToDate(startOfDate(task.actualEnd, "day"), 1, "day");
|
|
2225
2228
|
|
|
2226
|
-
var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.
|
|
2229
|
+
var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calendar);
|
|
2227
2230
|
|
|
2228
2231
|
var _segs = _intervals.map(function (iv) {
|
|
2229
2232
|
return {
|
|
@@ -3207,8 +3210,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3207
3210
|
|
|
3208
3211
|
var dragType = ganttEvent.type;
|
|
3209
3212
|
|
|
3210
|
-
if (changedTask.
|
|
3211
|
-
var cal = finalTask.
|
|
3213
|
+
if (changedTask.calendar && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
|
|
3214
|
+
var cal = finalTask.calendar;
|
|
3212
3215
|
|
|
3213
3216
|
if (dragType === "actual") {
|
|
3214
3217
|
if (ganttEvent.action === "end") {
|
|
@@ -3329,8 +3332,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3329
3332
|
var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
|
|
3330
3333
|
var dropType = type;
|
|
3331
3334
|
|
|
3332
|
-
if (newChangedTask.
|
|
3333
|
-
var cal = newChangedTask.
|
|
3335
|
+
if (newChangedTask.calendar && (action === "move" || action === "end" || action === "start")) {
|
|
3336
|
+
var cal = newChangedTask.calendar;
|
|
3334
3337
|
|
|
3335
3338
|
if (dropType === "actual") {
|
|
3336
3339
|
if (action === "end") {
|
|
@@ -3627,18 +3630,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3627
3630
|
|
|
3628
3631
|
var lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
|
|
3629
3632
|
var totalHeight = tasks.length * rowHeight;
|
|
3630
|
-
useEffect(function () {
|
|
3631
|
-
if (sliderTime !== undefined) {
|
|
3632
|
-
console.log('Vertical line debug:', {
|
|
3633
|
-
sliderTime: new Date(sliderTime).toLocaleString(),
|
|
3634
|
-
lineX: lineX,
|
|
3635
|
-
totalHeight: totalHeight,
|
|
3636
|
-
tasksCount: tasks.length,
|
|
3637
|
-
columnWidth: columnWidth,
|
|
3638
|
-
datesRange: dates.length > 0 ? dates[0].toLocaleString() + " - " + dates[dates.length - 1].toLocaleString() : 'empty'
|
|
3639
|
-
});
|
|
3640
|
-
}
|
|
3641
|
-
}, [sliderTime, lineX, totalHeight, tasks.length, dates, columnWidth]);
|
|
3642
3633
|
return React.createElement("g", {
|
|
3643
3634
|
className: "content"
|
|
3644
3635
|
}, lineX !== null && lineX > 0 && React.createElement("line", {
|
|
@@ -3646,7 +3637,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3646
3637
|
y1: 0,
|
|
3647
3638
|
x2: lineX,
|
|
3648
3639
|
y2: totalHeight,
|
|
3649
|
-
stroke: "
|
|
3640
|
+
stroke: "blue",
|
|
3650
3641
|
strokeWidth: 2,
|
|
3651
3642
|
pointerEvents: "none",
|
|
3652
3643
|
opacity: 0.8
|
|
@@ -3816,6 +3807,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3816
3807
|
};
|
|
3817
3808
|
|
|
3818
3809
|
var Gantt = function Gantt(_ref) {
|
|
3810
|
+
var _ref3;
|
|
3811
|
+
|
|
3819
3812
|
var tasks = _ref.tasks,
|
|
3820
3813
|
_ref$leafTasks = _ref.leafTasks,
|
|
3821
3814
|
leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
|
|
@@ -3827,8 +3820,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3827
3820
|
endDate = _ref$endDate === void 0 ? new Date() : _ref$endDate,
|
|
3828
3821
|
_ref$headerHeight = _ref.headerHeight,
|
|
3829
3822
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
3830
|
-
|
|
3831
|
-
columnWidth = _ref$columnWidth === void 0 ? 60 : _ref$columnWidth,
|
|
3823
|
+
columnWidthProp = _ref.columnWidth,
|
|
3832
3824
|
_ref$listCellWidth = _ref.listCellWidth,
|
|
3833
3825
|
listCellWidth = _ref$listCellWidth === void 0 ? "155px" : _ref$listCellWidth,
|
|
3834
3826
|
_ref$rowHeight = _ref.rowHeight,
|
|
@@ -3909,6 +3901,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3909
3901
|
var wrapperRef = useRef(null);
|
|
3910
3902
|
var taskListRef = useRef(null);
|
|
3911
3903
|
var isDraggingTable = useRef(false);
|
|
3904
|
+
var userResizedRef = useRef(false);
|
|
3912
3905
|
var dragStartX = useRef(0);
|
|
3913
3906
|
var dragStartWidth = useRef(0);
|
|
3914
3907
|
var dragMaxWidth = useRef(Infinity);
|
|
@@ -3965,6 +3958,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3965
3958
|
var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
|
|
3966
3959
|
|
|
3967
3960
|
isDraggingTable.current = true;
|
|
3961
|
+
userResizedRef.current = true;
|
|
3968
3962
|
dragStartX.current = e.clientX;
|
|
3969
3963
|
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;
|
|
3970
3964
|
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);
|
|
@@ -4031,38 +4025,70 @@ var Gantt = function Gantt(_ref) {
|
|
|
4031
4025
|
failedTask = _useState11[0],
|
|
4032
4026
|
setFailedTask = _useState11[1];
|
|
4033
4027
|
|
|
4028
|
+
var _useState12 = useState(null),
|
|
4029
|
+
computedColumnWidth = _useState12[0],
|
|
4030
|
+
setComputedColumnWidth = _useState12[1];
|
|
4031
|
+
|
|
4032
|
+
var computedForViewModeRef = useRef(null);
|
|
4033
|
+
useEffect(function () {
|
|
4034
|
+
if (columnWidthProp != null) return;
|
|
4035
|
+
if (svgContainerWidth <= 0) return;
|
|
4036
|
+
var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
|
|
4037
|
+
if (userResizedRef.current && alreadySnappedForView) return;
|
|
4038
|
+
var target = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
|
|
4039
|
+
if (!target) return;
|
|
4040
|
+
var next = Math.max(20, Math.floor(svgContainerWidth / target));
|
|
4041
|
+
|
|
4042
|
+
if (next !== computedColumnWidth) {
|
|
4043
|
+
setComputedColumnWidth(next);
|
|
4044
|
+
}
|
|
4045
|
+
|
|
4046
|
+
computedForViewModeRef.current = viewMode;
|
|
4047
|
+
}, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
|
|
4048
|
+
var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
|
|
4034
4049
|
var effectiveColumnWidth = useMemo(function () {
|
|
4035
4050
|
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
4051
|
+
|
|
4052
|
+
if (columnWidthProp == null) {
|
|
4053
|
+
var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
|
|
4054
|
+
|
|
4055
|
+
if (maxVisible) {
|
|
4056
|
+
return Math.max(columnWidth, Math.ceil(svgContainerWidth / maxVisible));
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
return columnWidth;
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4036
4062
|
return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
|
|
4037
|
-
}, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
|
|
4063
|
+
}, [columnWidth, columnWidthProp, viewMode, svgContainerWidth, dateSetup.dates.length]);
|
|
4038
4064
|
var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
|
|
4039
4065
|
var ganttFullHeight = useMemo(function () {
|
|
4040
4066
|
return barTasks.length * rowHeight;
|
|
4041
4067
|
}, [barTasks.length, rowHeight]);
|
|
4042
4068
|
|
|
4043
|
-
var
|
|
4044
|
-
scrollY =
|
|
4045
|
-
setScrollY =
|
|
4069
|
+
var _useState13 = useState(0),
|
|
4070
|
+
scrollY = _useState13[0],
|
|
4071
|
+
setScrollY = _useState13[1];
|
|
4046
4072
|
|
|
4047
|
-
var
|
|
4048
|
-
scrollX =
|
|
4049
|
-
setScrollX =
|
|
4073
|
+
var _useState14 = useState(-1),
|
|
4074
|
+
scrollX = _useState14[0],
|
|
4075
|
+
setScrollX = _useState14[1];
|
|
4050
4076
|
|
|
4051
|
-
var
|
|
4052
|
-
ignoreScrollEvent =
|
|
4053
|
-
setIgnoreScrollEvent =
|
|
4054
|
-
|
|
4055
|
-
var _useState15 = useState(0),
|
|
4056
|
-
lastTouchX = _useState15[0],
|
|
4057
|
-
setLastTouchX = _useState15[1];
|
|
4077
|
+
var _useState15 = useState(false),
|
|
4078
|
+
ignoreScrollEvent = _useState15[0],
|
|
4079
|
+
setIgnoreScrollEvent = _useState15[1];
|
|
4058
4080
|
|
|
4059
4081
|
var _useState16 = useState(0),
|
|
4060
|
-
|
|
4061
|
-
|
|
4082
|
+
lastTouchX = _useState16[0],
|
|
4083
|
+
setLastTouchX = _useState16[1];
|
|
4084
|
+
|
|
4085
|
+
var _useState17 = useState(0),
|
|
4086
|
+
lastTouchY = _useState17[0],
|
|
4087
|
+
setLastTouchY = _useState17[1];
|
|
4062
4088
|
|
|
4063
|
-
var
|
|
4064
|
-
isProcessing =
|
|
4065
|
-
setIsProcessing =
|
|
4089
|
+
var _useState18 = useState(false),
|
|
4090
|
+
isProcessing = _useState18[0],
|
|
4091
|
+
setIsProcessing = _useState18[1];
|
|
4066
4092
|
|
|
4067
4093
|
var buffer = rowHeight * 10;
|
|
4068
4094
|
var visibleStartY = scrollY - buffer;
|