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
|
@@ -5,6 +5,22 @@ declare type DateHelperScales = "year" | "quarter" | "month" | "day" | "hour" |
|
|
|
5
5
|
export declare const getCachedDateTimeFormat: (locString: string | string[], opts?: DateTimeFormatOptions) => DateTimeFormat;
|
|
6
6
|
export declare const addToDate: (date: Date, quantity: number, scale: DateHelperScales) => Date;
|
|
7
7
|
export declare const startOfDate: (date: Date, scale: DateHelperScales) => Date;
|
|
8
|
+
/**
|
|
9
|
+
* Default number of columns the chart aims to render across the chart pane
|
|
10
|
+
* for each view mode. The Gantt component sizes columns so that this many
|
|
11
|
+
* fit at the current pane width when the view mode is selected.
|
|
12
|
+
*
|
|
13
|
+
* Modes not listed (Hour / QuarterDay / HalfDay / Year) fall through to the
|
|
14
|
+
* legacy `columnWidth` default.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VIEW_MODE_DEFAULT_VISIBLE_COUNT: Partial<Record<ViewMode, number>>;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of columns the chart will show at once, even when the user
|
|
19
|
+
* widens the chart pane with the resize bar. The Gantt component clamps
|
|
20
|
+
* column width upward so visible count never exceeds this — overflow becomes
|
|
21
|
+
* horizontal scroll.
|
|
22
|
+
*/
|
|
23
|
+
export declare const VIEW_MODE_MAX_VISIBLE_COUNT: Partial<Record<ViewMode, number>>;
|
|
8
24
|
export declare const ganttDateRange: (tasks: Task[], viewMode: ViewMode, preStepsCount: number, quarterStart?: number) => Date[];
|
|
9
25
|
export declare const seedDates: (startDate: Date, endDate: Date, viewMode: ViewMode) => Date[];
|
|
10
26
|
export declare const getLocaleMonth: (date: Date, locale: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
75
75
|
ViewMode["Year"] = "Year";
|
|
76
76
|
})(exports.ViewMode || (exports.ViewMode = {}));
|
|
77
77
|
|
|
78
|
+
var _VIEW_MODE_DEFAULT_VI, _VIEW_MODE_MAX_VISIBL;
|
|
78
79
|
var intlDTCache = {};
|
|
79
80
|
var getCachedDateTimeFormat = function getCachedDateTimeFormat(locString, opts) {
|
|
80
81
|
if (opts === void 0) {
|
|
@@ -116,6 +117,8 @@ var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarter
|
|
|
116
117
|
return new Date(year, qStartMonth, 1);
|
|
117
118
|
};
|
|
118
119
|
|
|
120
|
+
var VIEW_MODE_DEFAULT_VISIBLE_COUNT = (_VIEW_MODE_DEFAULT_VI = {}, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Day] = 14, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Week] = 6, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Month] = 6, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Quarter] = 4, _VIEW_MODE_DEFAULT_VI);
|
|
121
|
+
var VIEW_MODE_MAX_VISIBLE_COUNT = (_VIEW_MODE_MAX_VISIBL = {}, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Day] = 30, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Week] = 13, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Month] = 12, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Quarter] = 8, _VIEW_MODE_MAX_VISIBL);
|
|
119
122
|
var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
|
|
120
123
|
var _tasks$, _tasks$2, _tasks$3, _tasks$4;
|
|
121
124
|
|
|
@@ -1425,7 +1428,7 @@ var GridBody = function GridBody(_ref) {
|
|
|
1425
1428
|
height: rowHeight,
|
|
1426
1429
|
fill: rowFill
|
|
1427
1430
|
}));
|
|
1428
|
-
var cal = task.
|
|
1431
|
+
var cal = task.calendar;
|
|
1429
1432
|
|
|
1430
1433
|
if (cal) {
|
|
1431
1434
|
for (var _i = 0, _x = 0; _i < dates.length; _i++, _x += columnWidth) {
|
|
@@ -2207,9 +2210,9 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
2207
2210
|
var plannedSegments;
|
|
2208
2211
|
var actualSegments;
|
|
2209
2212
|
|
|
2210
|
-
if (task.
|
|
2213
|
+
if (task.calendar && task.start && task.end && task.start.getTime() > 0) {
|
|
2211
2214
|
var planEnd = addToDate(startOfDate(task.end, "day"), 1, "day");
|
|
2212
|
-
var intervals = getWorkingIntervals(task.start, planEnd, task.
|
|
2215
|
+
var intervals = getWorkingIntervals(task.start, planEnd, task.calendar);
|
|
2213
2216
|
var segs = intervals.map(function (iv) {
|
|
2214
2217
|
return {
|
|
2215
2218
|
x1: taskXCoordinate(iv.start, dates, columnWidth),
|
|
@@ -2221,10 +2224,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
2221
2224
|
if (segs.length > 0) plannedSegments = segs;
|
|
2222
2225
|
}
|
|
2223
2226
|
|
|
2224
|
-
if (task.
|
|
2227
|
+
if (task.calendar && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
|
|
2225
2228
|
var actEnd = addToDate(startOfDate(task.actualEnd, "day"), 1, "day");
|
|
2226
2229
|
|
|
2227
|
-
var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.
|
|
2230
|
+
var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calendar);
|
|
2228
2231
|
|
|
2229
2232
|
var _segs = _intervals.map(function (iv) {
|
|
2230
2233
|
return {
|
|
@@ -3208,8 +3211,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3208
3211
|
|
|
3209
3212
|
var dragType = ganttEvent.type;
|
|
3210
3213
|
|
|
3211
|
-
if (changedTask.
|
|
3212
|
-
var cal = finalTask.
|
|
3214
|
+
if (changedTask.calendar && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
|
|
3215
|
+
var cal = finalTask.calendar;
|
|
3213
3216
|
|
|
3214
3217
|
if (dragType === "actual") {
|
|
3215
3218
|
if (ganttEvent.action === "end") {
|
|
@@ -3330,8 +3333,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3330
3333
|
var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
|
|
3331
3334
|
var dropType = type;
|
|
3332
3335
|
|
|
3333
|
-
if (newChangedTask.
|
|
3334
|
-
var cal = newChangedTask.
|
|
3336
|
+
if (newChangedTask.calendar && (action === "move" || action === "end" || action === "start")) {
|
|
3337
|
+
var cal = newChangedTask.calendar;
|
|
3335
3338
|
|
|
3336
3339
|
if (dropType === "actual") {
|
|
3337
3340
|
if (action === "end") {
|
|
@@ -3628,18 +3631,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3628
3631
|
|
|
3629
3632
|
var lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
|
|
3630
3633
|
var totalHeight = tasks.length * rowHeight;
|
|
3631
|
-
React.useEffect(function () {
|
|
3632
|
-
if (sliderTime !== undefined) {
|
|
3633
|
-
console.log('Vertical line debug:', {
|
|
3634
|
-
sliderTime: new Date(sliderTime).toLocaleString(),
|
|
3635
|
-
lineX: lineX,
|
|
3636
|
-
totalHeight: totalHeight,
|
|
3637
|
-
tasksCount: tasks.length,
|
|
3638
|
-
columnWidth: columnWidth,
|
|
3639
|
-
datesRange: dates.length > 0 ? dates[0].toLocaleString() + " - " + dates[dates.length - 1].toLocaleString() : 'empty'
|
|
3640
|
-
});
|
|
3641
|
-
}
|
|
3642
|
-
}, [sliderTime, lineX, totalHeight, tasks.length, dates, columnWidth]);
|
|
3643
3634
|
return React__default.createElement("g", {
|
|
3644
3635
|
className: "content"
|
|
3645
3636
|
}, lineX !== null && lineX > 0 && React__default.createElement("line", {
|
|
@@ -3647,7 +3638,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
3647
3638
|
y1: 0,
|
|
3648
3639
|
x2: lineX,
|
|
3649
3640
|
y2: totalHeight,
|
|
3650
|
-
stroke: "
|
|
3641
|
+
stroke: "blue",
|
|
3651
3642
|
strokeWidth: 2,
|
|
3652
3643
|
pointerEvents: "none",
|
|
3653
3644
|
opacity: 0.8
|
|
@@ -3817,6 +3808,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3817
3808
|
};
|
|
3818
3809
|
|
|
3819
3810
|
var Gantt = function Gantt(_ref) {
|
|
3811
|
+
var _ref3;
|
|
3812
|
+
|
|
3820
3813
|
var tasks = _ref.tasks,
|
|
3821
3814
|
_ref$leafTasks = _ref.leafTasks,
|
|
3822
3815
|
leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
|
|
@@ -3828,8 +3821,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3828
3821
|
endDate = _ref$endDate === void 0 ? new Date() : _ref$endDate,
|
|
3829
3822
|
_ref$headerHeight = _ref.headerHeight,
|
|
3830
3823
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
3831
|
-
|
|
3832
|
-
columnWidth = _ref$columnWidth === void 0 ? 60 : _ref$columnWidth,
|
|
3824
|
+
columnWidthProp = _ref.columnWidth,
|
|
3833
3825
|
_ref$listCellWidth = _ref.listCellWidth,
|
|
3834
3826
|
listCellWidth = _ref$listCellWidth === void 0 ? "155px" : _ref$listCellWidth,
|
|
3835
3827
|
_ref$rowHeight = _ref.rowHeight,
|
|
@@ -3910,6 +3902,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3910
3902
|
var wrapperRef = React.useRef(null);
|
|
3911
3903
|
var taskListRef = React.useRef(null);
|
|
3912
3904
|
var isDraggingTable = React.useRef(false);
|
|
3905
|
+
var userResizedRef = React.useRef(false);
|
|
3913
3906
|
var dragStartX = React.useRef(0);
|
|
3914
3907
|
var dragStartWidth = React.useRef(0);
|
|
3915
3908
|
var dragMaxWidth = React.useRef(Infinity);
|
|
@@ -3966,6 +3959,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3966
3959
|
var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
|
|
3967
3960
|
|
|
3968
3961
|
isDraggingTable.current = true;
|
|
3962
|
+
userResizedRef.current = true;
|
|
3969
3963
|
dragStartX.current = e.clientX;
|
|
3970
3964
|
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;
|
|
3971
3965
|
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);
|
|
@@ -4032,38 +4026,70 @@ var Gantt = function Gantt(_ref) {
|
|
|
4032
4026
|
failedTask = _useState11[0],
|
|
4033
4027
|
setFailedTask = _useState11[1];
|
|
4034
4028
|
|
|
4029
|
+
var _useState12 = React.useState(null),
|
|
4030
|
+
computedColumnWidth = _useState12[0],
|
|
4031
|
+
setComputedColumnWidth = _useState12[1];
|
|
4032
|
+
|
|
4033
|
+
var computedForViewModeRef = React.useRef(null);
|
|
4034
|
+
React.useEffect(function () {
|
|
4035
|
+
if (columnWidthProp != null) return;
|
|
4036
|
+
if (svgContainerWidth <= 0) return;
|
|
4037
|
+
var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
|
|
4038
|
+
if (userResizedRef.current && alreadySnappedForView) return;
|
|
4039
|
+
var target = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
|
|
4040
|
+
if (!target) return;
|
|
4041
|
+
var next = Math.max(20, Math.floor(svgContainerWidth / target));
|
|
4042
|
+
|
|
4043
|
+
if (next !== computedColumnWidth) {
|
|
4044
|
+
setComputedColumnWidth(next);
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
computedForViewModeRef.current = viewMode;
|
|
4048
|
+
}, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
|
|
4049
|
+
var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
|
|
4035
4050
|
var effectiveColumnWidth = React.useMemo(function () {
|
|
4036
4051
|
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
4052
|
+
|
|
4053
|
+
if (columnWidthProp == null) {
|
|
4054
|
+
var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
|
|
4055
|
+
|
|
4056
|
+
if (maxVisible) {
|
|
4057
|
+
return Math.max(columnWidth, Math.ceil(svgContainerWidth / maxVisible));
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
return columnWidth;
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4037
4063
|
return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
|
|
4038
|
-
}, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
|
|
4064
|
+
}, [columnWidth, columnWidthProp, viewMode, svgContainerWidth, dateSetup.dates.length]);
|
|
4039
4065
|
var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
|
|
4040
4066
|
var ganttFullHeight = React.useMemo(function () {
|
|
4041
4067
|
return barTasks.length * rowHeight;
|
|
4042
4068
|
}, [barTasks.length, rowHeight]);
|
|
4043
4069
|
|
|
4044
|
-
var
|
|
4045
|
-
scrollY =
|
|
4046
|
-
setScrollY =
|
|
4070
|
+
var _useState13 = React.useState(0),
|
|
4071
|
+
scrollY = _useState13[0],
|
|
4072
|
+
setScrollY = _useState13[1];
|
|
4047
4073
|
|
|
4048
|
-
var
|
|
4049
|
-
scrollX =
|
|
4050
|
-
setScrollX =
|
|
4074
|
+
var _useState14 = React.useState(-1),
|
|
4075
|
+
scrollX = _useState14[0],
|
|
4076
|
+
setScrollX = _useState14[1];
|
|
4051
4077
|
|
|
4052
|
-
var
|
|
4053
|
-
ignoreScrollEvent =
|
|
4054
|
-
setIgnoreScrollEvent =
|
|
4055
|
-
|
|
4056
|
-
var _useState15 = React.useState(0),
|
|
4057
|
-
lastTouchX = _useState15[0],
|
|
4058
|
-
setLastTouchX = _useState15[1];
|
|
4078
|
+
var _useState15 = React.useState(false),
|
|
4079
|
+
ignoreScrollEvent = _useState15[0],
|
|
4080
|
+
setIgnoreScrollEvent = _useState15[1];
|
|
4059
4081
|
|
|
4060
4082
|
var _useState16 = React.useState(0),
|
|
4061
|
-
|
|
4062
|
-
|
|
4083
|
+
lastTouchX = _useState16[0],
|
|
4084
|
+
setLastTouchX = _useState16[1];
|
|
4085
|
+
|
|
4086
|
+
var _useState17 = React.useState(0),
|
|
4087
|
+
lastTouchY = _useState17[0],
|
|
4088
|
+
setLastTouchY = _useState17[1];
|
|
4063
4089
|
|
|
4064
|
-
var
|
|
4065
|
-
isProcessing =
|
|
4066
|
-
setIsProcessing =
|
|
4090
|
+
var _useState18 = React.useState(false),
|
|
4091
|
+
isProcessing = _useState18[0],
|
|
4092
|
+
setIsProcessing = _useState18[1];
|
|
4067
4093
|
|
|
4068
4094
|
var buffer = rowHeight * 10;
|
|
4069
4095
|
var visibleStartY = scrollY - buffer;
|