gantt-task-react-powern 0.6.28 → 0.6.30

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.
@@ -897,8 +897,26 @@ var TaskList = function TaskList(_ref) {
897
897
  taskLabelRenderer = _ref.taskLabelRenderer,
898
898
  onMultiSelect = _ref.onMultiSelect,
899
899
  containerWidth = _ref.containerWidth,
900
- innerScrollRef = _ref.innerScrollRef;
901
- var horizontalContainerRef = useRef(null);
900
+ innerScrollRef = _ref.innerScrollRef,
901
+ externalHorizontalContainerRef = _ref.horizontalContainerRef;
902
+ var internalHorizontalContainerRef = useRef(null);
903
+ var horizontalContainerRef = externalHorizontalContainerRef != null ? externalHorizontalContainerRef : internalHorizontalContainerRef;
904
+ var headerScrollRef = useRef(null);
905
+ useEffect(function () {
906
+ var rowsEl = horizontalContainerRef.current;
907
+ if (!rowsEl) return;
908
+
909
+ var onScroll = function onScroll() {
910
+ if (headerScrollRef.current) {
911
+ headerScrollRef.current.scrollLeft = rowsEl.scrollLeft;
912
+ }
913
+ };
914
+
915
+ rowsEl.addEventListener("scroll", onScroll);
916
+ return function () {
917
+ return rowsEl.removeEventListener("scroll", onScroll);
918
+ };
919
+ }, [horizontalContainerRef]);
902
920
 
903
921
  var _useState = useState([]),
904
922
  selectedTasks = _useState[0],
@@ -1085,9 +1103,14 @@ var TaskList = function TaskList(_ref) {
1085
1103
  ref: innerScrollRef,
1086
1104
  className: styles$4.hideScrollbar,
1087
1105
  style: {
1088
- overflowX: "auto"
1106
+ overflowX: "hidden"
1089
1107
  }
1090
- }, React.createElement(TaskListHeader, Object.assign({}, headerProps)), React.createElement("div", {
1108
+ }, React.createElement("div", {
1109
+ ref: headerScrollRef,
1110
+ style: {
1111
+ overflow: "hidden"
1112
+ }
1113
+ }, React.createElement(TaskListHeader, Object.assign({}, headerProps))), React.createElement("div", {
1091
1114
  ref: horizontalContainerRef,
1092
1115
  className: horizontalContainerClass,
1093
1116
  style: ganttHeight ? {
@@ -1355,6 +1378,7 @@ var GridBody = function GridBody(_ref) {
1355
1378
  });
1356
1379
  var rowBackgrounds = [];
1357
1380
  var rowLines = [];
1381
+ var rowOverlays = [];
1358
1382
  rowLines.push(React.createElement("line", {
1359
1383
  key: "top-line",
1360
1384
  x1: 0,
@@ -1363,6 +1387,7 @@ var GridBody = function GridBody(_ref) {
1363
1387
  y2: visibleStartY,
1364
1388
  className: styles$5.gridRowLine
1365
1389
  }));
1390
+ var showPerRowOffDays = viewMode !== ViewMode.Month && viewMode !== ViewMode.Quarter;
1366
1391
 
1367
1392
  for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {
1368
1393
  var vi = _step.value;
@@ -1387,6 +1412,63 @@ var GridBody = function GridBody(_ref) {
1387
1412
  y2: y + rowHeight,
1388
1413
  className: styles$5.gridRowLine
1389
1414
  }));
1415
+
1416
+ if (showPerRowOffDays) {
1417
+ var rowEven = vi.index % 2 === 1;
1418
+ var rowFill = isMilestone ? "#e6e4e4" : scheduleType === "lookAhead" ? "#fff" : rowEven ? "#f5f5f5" : "#fff";
1419
+ rowOverlays.push(React.createElement("rect", {
1420
+ key: "row-clean-" + vi.key,
1421
+ x: 0,
1422
+ y: y,
1423
+ width: svgWidth,
1424
+ height: rowHeight,
1425
+ fill: rowFill
1426
+ }));
1427
+ var cal = task.calendar;
1428
+
1429
+ if (cal) {
1430
+ for (var _i = 0, _x = 0; _i < dates.length; _i++, _x += columnWidth) {
1431
+ var _dates2;
1432
+
1433
+ var _pEnd = (_dates2 = dates[_i + 1]) != null ? _dates2 : addToDate(dates[_i], 1, "day");
1434
+
1435
+ var _periodMs = _pEnd.getTime() - dates[_i].getTime();
1436
+
1437
+ if (_periodMs <= 0) continue;
1438
+
1439
+ var _cursor = new Date(dates[_i]);
1440
+
1441
+ _cursor.setHours(0, 0, 0, 0);
1442
+
1443
+ while (_cursor.getTime() < _pEnd.getTime()) {
1444
+ if (isOffDay(_cursor, cal)) {
1445
+ var _ds = _cursor.getTime() - dates[_i].getTime();
1446
+
1447
+ var _de = _ds + 86400000;
1448
+
1449
+ var _startFrac = Math.max(0, _ds) / _periodMs;
1450
+
1451
+ var _endFrac = Math.min(_periodMs, _de) / _periodMs;
1452
+
1453
+ var _rw = (_endFrac - _startFrac) * columnWidth;
1454
+
1455
+ if (_rw > 0.5) {
1456
+ rowOverlays.push(React.createElement("rect", {
1457
+ key: "row-offday-" + vi.key + "-" + _cursor.getTime(),
1458
+ x: rtl ? _x + columnWidth - (_startFrac * columnWidth + _rw) : _x + _startFrac * columnWidth,
1459
+ y: y,
1460
+ width: _rw,
1461
+ height: rowHeight,
1462
+ fill: weekendColor
1463
+ }));
1464
+ }
1465
+ }
1466
+
1467
+ _cursor.setDate(_cursor.getDate() + 1);
1468
+ }
1469
+ }
1470
+ }
1471
+ }
1390
1472
  }
1391
1473
 
1392
1474
  return React.createElement("g", {
@@ -1398,6 +1480,8 @@ var GridBody = function GridBody(_ref) {
1398
1480
  }, rowLines), React.createElement("g", {
1399
1481
  className: "offdays"
1400
1482
  }, offDayRects), React.createElement("g", {
1483
+ className: "rowOverlays"
1484
+ }, rowOverlays), React.createElement("g", {
1401
1485
  className: "ticks"
1402
1486
  }, tickLines), React.createElement("g", {
1403
1487
  className: "today"
@@ -2122,9 +2206,9 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
2122
2206
  var plannedSegments;
2123
2207
  var actualSegments;
2124
2208
 
2125
- if (task.calender && task.start && task.end && task.start.getTime() > 0) {
2209
+ if (task.calendar && task.start && task.end && task.start.getTime() > 0) {
2126
2210
  var planEnd = addToDate(startOfDate(task.end, "day"), 1, "day");
2127
- var intervals = getWorkingIntervals(task.start, planEnd, task.calender);
2211
+ var intervals = getWorkingIntervals(task.start, planEnd, task.calendar);
2128
2212
  var segs = intervals.map(function (iv) {
2129
2213
  return {
2130
2214
  x1: taskXCoordinate(iv.start, dates, columnWidth),
@@ -2136,10 +2220,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
2136
2220
  if (segs.length > 0) plannedSegments = segs;
2137
2221
  }
2138
2222
 
2139
- if (task.calender && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
2223
+ if (task.calendar && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
2140
2224
  var actEnd = addToDate(startOfDate(task.actualEnd, "day"), 1, "day");
2141
2225
 
2142
- var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calender);
2226
+ var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calendar);
2143
2227
 
2144
2228
  var _segs = _intervals.map(function (iv) {
2145
2229
  return {
@@ -3123,8 +3207,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3123
3207
 
3124
3208
  var dragType = ganttEvent.type;
3125
3209
 
3126
- if (changedTask.calender && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
3127
- var cal = finalTask.calender;
3210
+ if (changedTask.calendar && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
3211
+ var cal = finalTask.calendar;
3128
3212
 
3129
3213
  if (dragType === "actual") {
3130
3214
  if (ganttEvent.action === "end") {
@@ -3245,8 +3329,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3245
3329
  var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
3246
3330
  var dropType = type;
3247
3331
 
3248
- if (newChangedTask.calender && (action === "move" || action === "end" || action === "start")) {
3249
- var cal = newChangedTask.calender;
3332
+ if (newChangedTask.calendar && (action === "move" || action === "end" || action === "start")) {
3333
+ var cal = newChangedTask.calendar;
3250
3334
 
3251
3335
  if (dropType === "actual") {
3252
3336
  if (action === "end") {
@@ -3543,18 +3627,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3543
3627
 
3544
3628
  var lineX = sliderTime !== undefined ? taskXCoordinate(new Date(sliderTime), dates, columnWidth) : null;
3545
3629
  var totalHeight = tasks.length * rowHeight;
3546
- useEffect(function () {
3547
- if (sliderTime !== undefined) {
3548
- console.log('Vertical line debug:', {
3549
- sliderTime: new Date(sliderTime).toLocaleString(),
3550
- lineX: lineX,
3551
- totalHeight: totalHeight,
3552
- tasksCount: tasks.length,
3553
- columnWidth: columnWidth,
3554
- datesRange: dates.length > 0 ? dates[0].toLocaleString() + " - " + dates[dates.length - 1].toLocaleString() : 'empty'
3555
- });
3556
- }
3557
- }, [sliderTime, lineX, totalHeight, tasks.length, dates, columnWidth]);
3558
3630
  return React.createElement("g", {
3559
3631
  className: "content"
3560
3632
  }, lineX !== null && lineX > 0 && React.createElement("line", {
@@ -3562,7 +3634,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
3562
3634
  y1: 0,
3563
3635
  x2: lineX,
3564
3636
  y2: totalHeight,
3565
- stroke: "red",
3637
+ stroke: "blue",
3566
3638
  strokeWidth: 2,
3567
3639
  pointerEvents: "none",
3568
3640
  opacity: 0.8
@@ -3732,8 +3804,6 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3732
3804
  };
3733
3805
 
3734
3806
  var Gantt = function Gantt(_ref) {
3735
- var _tasks$find$calender, _tasks$find;
3736
-
3737
3807
  var tasks = _ref.tasks,
3738
3808
  _ref$leafTasks = _ref.leafTasks,
3739
3809
  leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
@@ -3824,9 +3894,6 @@ var Gantt = function Gantt(_ref) {
3824
3894
  projectCalendar = _ref.projectCalendar,
3825
3895
  onCalendarError = _ref.onCalendarError,
3826
3896
  sliderTime = _ref.sliderTime;
3827
- var effectiveCalendar = (_tasks$find$calender = (_tasks$find = tasks.find(function (t) {
3828
- return t.calender;
3829
- })) === null || _tasks$find === void 0 ? void 0 : _tasks$find.calender) != null ? _tasks$find$calender : projectCalendar;
3830
3897
  var wrapperRef = useRef(null);
3831
3898
  var taskListRef = useRef(null);
3832
3899
  var isDraggingTable = useRef(false);
@@ -3839,6 +3906,7 @@ var Gantt = function Gantt(_ref) {
3839
3906
  setTableContainerWidth = _useState[1];
3840
3907
 
3841
3908
  var tableInnerScrollRef = useRef(null);
3909
+ var tableHorizontalContainerRef = useRef(null);
3842
3910
  var tableHScrollRef = useRef(null);
3843
3911
 
3844
3912
  var _useState2 = useState(0),
@@ -3874,18 +3942,20 @@ var Gantt = function Gantt(_ref) {
3874
3942
  setTaskListWidth = _useState5[1];
3875
3943
 
3876
3944
  useEffect(function () {
3877
- if (tableInnerScrollRef.current) {
3945
+ if (tableHorizontalContainerRef.current) {
3946
+ setTableScrollableWidth(tableHorizontalContainerRef.current.scrollWidth);
3947
+ } else if (tableInnerScrollRef.current) {
3878
3948
  setTableScrollableWidth(tableInnerScrollRef.current.scrollWidth);
3879
3949
  }
3880
3950
  }, [taskListWidth, listCellWidth]);
3881
3951
 
3882
3952
  var handleTableResizeMouseDown = function handleTableResizeMouseDown(e) {
3883
- var _taskListRef$current$, _taskListRef$current, _tableInnerScrollRef$, _tableInnerScrollRef$2, _wrapperRef$current$o, _wrapperRef$current;
3953
+ var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
3884
3954
 
3885
3955
  isDraggingTable.current = true;
3886
3956
  dragStartX.current = e.clientX;
3887
3957
  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;
3888
- dragMaxWidth.current = (_tableInnerScrollRef$ = (_tableInnerScrollRef$2 = tableInnerScrollRef.current) === null || _tableInnerScrollRef$2 === void 0 ? void 0 : _tableInnerScrollRef$2.scrollWidth) != null ? _tableInnerScrollRef$ : 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);
3958
+ 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);
3889
3959
  e.preventDefault();
3890
3960
  };
3891
3961
 
@@ -4003,13 +4073,13 @@ var Gantt = function Gantt(_ref) {
4003
4073
  }
4004
4074
 
4005
4075
  debounceRef.current = setTimeout(function () {
4006
- var _effectiveCalendar$qu;
4076
+ var _projectCalendar$quar;
4007
4077
 
4008
4078
  var filteredTasks;
4009
4079
  filteredTasks = removeHiddenTasks(tasks);
4010
4080
  filteredTasks = filteredTasks.sort(sortTasks);
4011
4081
 
4012
- var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_effectiveCalendar$qu = effectiveCalendar === null || effectiveCalendar === void 0 ? void 0 : effectiveCalendar.quarter_start) != null ? _effectiveCalendar$qu : 0),
4082
+ var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0),
4013
4083
  startDateRange = _ganttDateRange2[0],
4014
4084
  endDateRange = _ganttDateRange2[1];
4015
4085
 
@@ -4048,7 +4118,7 @@ var Gantt = function Gantt(_ref) {
4048
4118
  setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
4049
4119
  setIsProcessing(false);
4050
4120
  }, delayToRender);
4051
- }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, effectiveCalendar]);
4121
+ }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, projectCalendar]);
4052
4122
  useEffect(function () {
4053
4123
  return function () {
4054
4124
  clearTimeout(debounceRef.current);
@@ -4320,7 +4390,7 @@ var Gantt = function Gantt(_ref) {
4320
4390
  rtl: rtl,
4321
4391
  visibleStartY: visibleStartY,
4322
4392
  visibleEndY: visibleEndY,
4323
- projectCalendar: effectiveCalendar,
4393
+ projectCalendar: projectCalendar,
4324
4394
  viewMode: viewMode
4325
4395
  };
4326
4396
  var calendarProps = {
@@ -4332,7 +4402,7 @@ var Gantt = function Gantt(_ref) {
4332
4402
  fontFamily: fontFamily,
4333
4403
  fontSize: fontSize,
4334
4404
  rtl: rtl,
4335
- projectCalendar: effectiveCalendar
4405
+ projectCalendar: projectCalendar
4336
4406
  };
4337
4407
  var barProps = {
4338
4408
  tasks: barTasks,
@@ -4359,7 +4429,7 @@ var Gantt = function Gantt(_ref) {
4359
4429
  onClick: onClick,
4360
4430
  onDelete: onDelete,
4361
4431
  onCalendarError: onCalendarError,
4362
- projectCalendar: effectiveCalendar,
4432
+ projectCalendar: projectCalendar,
4363
4433
  visibleStartY: visibleStartY,
4364
4434
  visibleEndY: visibleEndY,
4365
4435
  sliderTime: sliderTime
@@ -4392,7 +4462,8 @@ var Gantt = function Gantt(_ref) {
4392
4462
  taskLabelRenderer: taskLabelRenderer,
4393
4463
  onMultiSelect: onMultiSelect,
4394
4464
  containerWidth: tableContainerWidth != null ? tableContainerWidth : undefined,
4395
- innerScrollRef: tableInnerScrollRef
4465
+ innerScrollRef: tableInnerScrollRef,
4466
+ horizontalContainerRef: tableHorizontalContainerRef
4396
4467
  };
4397
4468
  return React.createElement("div", {
4398
4469
  style: {
@@ -4488,8 +4559,8 @@ var Gantt = function Gantt(_ref) {
4488
4559
  flexShrink: 0
4489
4560
  },
4490
4561
  onScroll: function onScroll(e) {
4491
- if (tableInnerScrollRef.current) {
4492
- tableInnerScrollRef.current.scrollLeft = e.currentTarget.scrollLeft;
4562
+ if (tableHorizontalContainerRef.current) {
4563
+ tableHorizontalContainerRef.current.scrollLeft = e.currentTarget.scrollLeft;
4493
4564
  }
4494
4565
  }
4495
4566
  }, React.createElement("div", {