gantt-task-react-powern 0.6.2 → 0.6.3

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.
@@ -792,7 +792,7 @@ var TaskList = function TaskList(_ref) {
792
792
  estimateSize: function estimateSize() {
793
793
  return rowHeight;
794
794
  },
795
- overscan: 5
795
+ overscan: 10
796
796
  });
797
797
  useEffect(function () {
798
798
  if (horizontalContainerRef.current) {
@@ -983,6 +983,7 @@ var GridBody = function GridBody(_ref) {
983
983
  visibleStartY = _ref.visibleStartY,
984
984
  visibleEndY = _ref.visibleEndY;
985
985
  var visibleHeight = visibleEndY - visibleStartY;
986
+ var now = new Date();
986
987
  var items = virtualItems.length > 0 ? virtualItems : tasks.map(function (_, i) {
987
988
  return {
988
989
  index: i,
@@ -992,30 +993,34 @@ var GridBody = function GridBody(_ref) {
992
993
  key: i
993
994
  };
994
995
  });
995
- var now = new Date();
996
- var x = 0;
997
- var todayRects = [];
998
- var weekendRects = [];
999
996
 
1000
- for (var i = 0; i < dates.length; i++) {
997
+ var isWeekend = function isWeekend(date) {
998
+ var d = date.getDay();
999
+ return d === 0 || d === 6;
1000
+ };
1001
+
1002
+ var isTodayColumn = function isTodayColumn(i) {
1001
1003
  var date = dates[i];
1002
- var isTodayColumn = i + 1 < dates.length && date.getTime() < now.getTime() && dates[i + 1].getTime() >= now.getTime() || i + 1 === dates.length && date.getTime() <= now.getTime() && addToDate(date, date.getTime() - dates[i - 1].getTime(), "millisecond").getTime() > now.getTime();
1004
+ var next = dates[i + 1];
1005
+ if (next && date <= now && next > now) return true;
1003
1006
 
1004
- if (isTodayColumn) {
1005
- todayRects.push(React.createElement("rect", {
1006
- key: "today-" + i,
1007
- x: rtl ? x + columnWidth : x,
1008
- y: visibleStartY,
1009
- width: columnWidth,
1010
- height: visibleHeight,
1011
- fill: todayColor
1012
- }));
1007
+ if (!next && date <= now) {
1008
+ var step = date.getTime() - dates[i - 1].getTime();
1009
+ var end = addToDate(date, step, "millisecond");
1010
+ return end > now;
1013
1011
  }
1014
1012
 
1015
- if (rtl && i + 1 < dates.length && date.getTime() >= now.getTime() && dates[i + 1].getTime() < now.getTime()) {
1013
+ return false;
1014
+ };
1015
+
1016
+ var todayRects = [];
1017
+ var weekendRects = [];
1018
+
1019
+ for (var i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
1020
+ if (isTodayColumn(i)) {
1016
1021
  todayRects.push(React.createElement("rect", {
1017
- key: "today-rtl-" + i,
1018
- x: x,
1022
+ key: "today-" + i,
1023
+ x: rtl ? x + columnWidth : x,
1019
1024
  y: visibleStartY,
1020
1025
  width: columnWidth,
1021
1026
  height: visibleHeight,
@@ -1023,7 +1028,7 @@ var GridBody = function GridBody(_ref) {
1023
1028
  }));
1024
1029
  }
1025
1030
 
1026
- if (date.getDay() === 0 || date.getDay() === 6) {
1031
+ if (isWeekend(dates[i])) {
1027
1032
  weekendRects.push(React.createElement("rect", {
1028
1033
  key: "weekend-" + i,
1029
1034
  x: x,
@@ -1033,44 +1038,43 @@ var GridBody = function GridBody(_ref) {
1033
1038
  fill: weekendColor
1034
1039
  }));
1035
1040
  }
1036
-
1037
- x += columnWidth;
1038
1041
  }
1039
1042
 
1040
- x = 0;
1041
1043
  var tickLines = dates.map(function (_, i) {
1042
- var line = React.createElement("line", {
1044
+ return React.createElement("line", {
1043
1045
  key: "tick-" + i,
1044
- x1: x,
1046
+ x1: i * columnWidth,
1045
1047
  y1: visibleStartY,
1046
- x2: x,
1048
+ x2: i * columnWidth,
1047
1049
  y2: visibleEndY,
1048
1050
  className: styles$4.gridTick
1049
1051
  });
1050
- x += columnWidth;
1051
- return line;
1052
1052
  });
1053
1053
  var rowBackgrounds = [];
1054
1054
  var rowLines = [];
1055
1055
  rowLines.push(React.createElement("line", {
1056
- key: "top",
1056
+ key: "top-line",
1057
1057
  x1: 0,
1058
1058
  y1: visibleStartY,
1059
1059
  x2: svgWidth,
1060
1060
  y2: visibleStartY,
1061
1061
  className: styles$4.gridRowLine
1062
1062
  }));
1063
- items.forEach(function (vi) {
1063
+
1064
+ for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {
1065
+ var vi = _step.value;
1064
1066
  var task = tasks[vi.index];
1067
+ if (!task) break;
1065
1068
  var y = vi.start;
1066
1069
  var isMilestone = task.type === "milestone";
1070
+ var rowClass = isMilestone ? styles$4.darkerGridRow : scheduleType === "lookAhead" ? styles$4.gridRowLookAhead : styles$4.gridRow;
1067
1071
  rowBackgrounds.push(React.createElement("rect", {
1068
1072
  key: "bg-" + vi.key,
1069
1073
  x: 0,
1070
1074
  y: y,
1071
1075
  width: svgWidth,
1072
1076
  height: rowHeight,
1073
- className: isMilestone ? styles$4.darkerGridRow : scheduleType === "lookAhead" ? styles$4.gridRowLookAhead : styles$4.gridRow
1077
+ className: rowClass
1074
1078
  }));
1075
1079
  rowLines.push(React.createElement("line", {
1076
1080
  key: "line-" + vi.key,
@@ -1080,7 +1084,8 @@ var GridBody = function GridBody(_ref) {
1080
1084
  y2: y + rowHeight,
1081
1085
  className: styles$4.gridRowLine
1082
1086
  }));
1083
- });
1087
+ }
1088
+
1084
1089
  return React.createElement("g", {
1085
1090
  className: "gridBody"
1086
1091
  }, React.createElement("g", {
@@ -2528,8 +2533,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2528
2533
  rtl = _ref.rtl,
2529
2534
  _ref$virtualItems = _ref.virtualItems,
2530
2535
  virtualItems = _ref$virtualItems === void 0 ? [] : _ref$virtualItems,
2531
- ganttHeight = _ref.ganttHeight,
2532
- scrollY = _ref.scrollY,
2533
2536
  setGanttEvent = _ref.setGanttEvent,
2534
2537
  setFailedTask = _ref.setFailedTask,
2535
2538
  setSelectedTask = _ref.setSelectedTask,
@@ -2537,7 +2540,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2537
2540
  onProgressChange = _ref.onProgressChange,
2538
2541
  onDoubleClick = _ref.onDoubleClick,
2539
2542
  onClick = _ref.onClick,
2540
- onDelete = _ref.onDelete;
2543
+ onDelete = _ref.onDelete,
2544
+ visibleStartY = _ref.visibleStartY,
2545
+ visibleEndY = _ref.visibleEndY;
2541
2546
  var point = svg === null || svg === void 0 ? void 0 : (_svg$current = svg.current) === null || _svg$current === void 0 ? void 0 : _svg$current.createSVGPoint();
2542
2547
 
2543
2548
  var _useState = useState(0),
@@ -2745,8 +2750,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2745
2750
  };
2746
2751
 
2747
2752
  var getArrows = function getArrows(isCritical, criticalPathType) {
2748
- var visibleMinY = scrollY - rowHeight * 5;
2749
- var visibleMaxY = scrollY + ganttHeight + rowHeight * 5;
2750
2753
  return tasks.flatMap(function (_task) {
2751
2754
  var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
2752
2755
 
@@ -2767,7 +2770,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2767
2770
  var minY = Math.min(yFrom, yTo);
2768
2771
  var maxY = Math.max(yFrom, yTo);
2769
2772
 
2770
- if (maxY < visibleMinY || minY > visibleMaxY) {
2773
+ if (maxY < visibleStartY || minY > visibleEndY) {
2771
2774
  return null;
2772
2775
  }
2773
2776
 
@@ -2879,7 +2882,7 @@ var TaskGantt = function TaskGantt(_ref) {
2879
2882
  estimateSize: function estimateSize() {
2880
2883
  return barProps.rowHeight;
2881
2884
  },
2882
- overscan: 20
2885
+ overscan: 10
2883
2886
  });
2884
2887
  useEffect(function () {
2885
2888
  if (horizontalContainerRef.current) {
@@ -2920,6 +2923,8 @@ var TaskGantt = function TaskGantt(_ref) {
2920
2923
  visibleStartY: visibleStartY,
2921
2924
  visibleEndY: visibleEndY
2922
2925
  })), React.createElement(TaskGanttContent, Object.assign({}, newBarProps, {
2926
+ visibleStartY: visibleStartY,
2927
+ visibleEndY: visibleEndY,
2923
2928
  virtualItems: virtualizer.getVirtualItems()
2924
2929
  })))));
2925
2930
  };
@@ -3493,8 +3498,8 @@ var Gantt = function Gantt(_ref) {
3493
3498
  onDoubleClick: onDoubleClick,
3494
3499
  onClick: onClick,
3495
3500
  onDelete: onDelete,
3496
- ganttHeight: ganttHeight,
3497
- scrollY: scrollY
3501
+ visibleStartY: visibleStartY,
3502
+ visibleEndY: visibleEndY
3498
3503
  };
3499
3504
  var tableProps = {
3500
3505
  rowHeight: rowHeight,