gantt-task-react-powern 0.6.27 → 0.6.29

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"
1107
+ }
1108
+ }, React.createElement("div", {
1109
+ ref: headerScrollRef,
1110
+ style: {
1111
+ overflow: "hidden"
1089
1112
  }
1090
- }, React.createElement(TaskListHeader, Object.assign({}, headerProps)), React.createElement("div", {
1113
+ }, React.createElement(TaskListHeader, Object.assign({}, headerProps))), React.createElement("div", {
1091
1114
  ref: horizontalContainerRef,
1092
1115
  className: horizontalContainerClass,
1093
1116
  style: ganttHeight ? {
@@ -1115,13 +1138,21 @@ function toDateString(date) {
1115
1138
  }
1116
1139
 
1117
1140
  function isHoliday(date, cal) {
1118
- return cal.holidays.includes(toDateString(date));
1141
+ if (cal.holidays && cal.holidays.length > 0) {
1142
+ return cal.holidays.includes(toDateString(date));
1143
+ } else {
1144
+ return false;
1145
+ }
1119
1146
  }
1120
1147
  function isOffDay(date, cal) {
1121
- return cal.off_days.includes(date.getDay()) || isHoliday(date, cal);
1148
+ if (cal.off_days && cal.off_days.length > 0) {
1149
+ return cal.off_days.includes(date.getDay()) || isHoliday(date, cal);
1150
+ } else {
1151
+ return false;
1152
+ }
1122
1153
  }
1123
1154
  function getShiftsForDay(date, cal) {
1124
- if (isOffDay(date, cal)) return [];
1155
+ if (isOffDay(date, cal) || !cal.shifts) return [];
1125
1156
  return cal.shifts.map(function (_ref) {
1126
1157
  var s = _ref[0],
1127
1158
  e = _ref[1];
@@ -1347,6 +1378,7 @@ var GridBody = function GridBody(_ref) {
1347
1378
  });
1348
1379
  var rowBackgrounds = [];
1349
1380
  var rowLines = [];
1381
+ var rowOverlays = [];
1350
1382
  rowLines.push(React.createElement("line", {
1351
1383
  key: "top-line",
1352
1384
  x1: 0,
@@ -1355,6 +1387,7 @@ var GridBody = function GridBody(_ref) {
1355
1387
  y2: visibleStartY,
1356
1388
  className: styles$5.gridRowLine
1357
1389
  }));
1390
+ var showPerRowOffDays = viewMode !== ViewMode.Month && viewMode !== ViewMode.Quarter;
1358
1391
 
1359
1392
  for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {
1360
1393
  var vi = _step.value;
@@ -1379,6 +1412,63 @@ var GridBody = function GridBody(_ref) {
1379
1412
  y2: y + rowHeight,
1380
1413
  className: styles$5.gridRowLine
1381
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.calender;
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
+ }
1382
1472
  }
1383
1473
 
1384
1474
  return React.createElement("g", {
@@ -1390,6 +1480,8 @@ var GridBody = function GridBody(_ref) {
1390
1480
  }, rowLines), React.createElement("g", {
1391
1481
  className: "offdays"
1392
1482
  }, offDayRects), React.createElement("g", {
1483
+ className: "rowOverlays"
1484
+ }, rowOverlays), React.createElement("g", {
1393
1485
  className: "ticks"
1394
1486
  }, tickLines), React.createElement("g", {
1395
1487
  className: "today"
@@ -3724,8 +3816,6 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3724
3816
  };
3725
3817
 
3726
3818
  var Gantt = function Gantt(_ref) {
3727
- var _tasks$find$calender, _tasks$find;
3728
-
3729
3819
  var tasks = _ref.tasks,
3730
3820
  _ref$leafTasks = _ref.leafTasks,
3731
3821
  leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
@@ -3816,9 +3906,6 @@ var Gantt = function Gantt(_ref) {
3816
3906
  projectCalendar = _ref.projectCalendar,
3817
3907
  onCalendarError = _ref.onCalendarError,
3818
3908
  sliderTime = _ref.sliderTime;
3819
- var effectiveCalendar = (_tasks$find$calender = (_tasks$find = tasks.find(function (t) {
3820
- return t.calender;
3821
- })) === null || _tasks$find === void 0 ? void 0 : _tasks$find.calender) != null ? _tasks$find$calender : projectCalendar;
3822
3909
  var wrapperRef = useRef(null);
3823
3910
  var taskListRef = useRef(null);
3824
3911
  var isDraggingTable = useRef(false);
@@ -3831,6 +3918,7 @@ var Gantt = function Gantt(_ref) {
3831
3918
  setTableContainerWidth = _useState[1];
3832
3919
 
3833
3920
  var tableInnerScrollRef = useRef(null);
3921
+ var tableHorizontalContainerRef = useRef(null);
3834
3922
  var tableHScrollRef = useRef(null);
3835
3923
 
3836
3924
  var _useState2 = useState(0),
@@ -3866,18 +3954,20 @@ var Gantt = function Gantt(_ref) {
3866
3954
  setTaskListWidth = _useState5[1];
3867
3955
 
3868
3956
  useEffect(function () {
3869
- if (tableInnerScrollRef.current) {
3957
+ if (tableHorizontalContainerRef.current) {
3958
+ setTableScrollableWidth(tableHorizontalContainerRef.current.scrollWidth);
3959
+ } else if (tableInnerScrollRef.current) {
3870
3960
  setTableScrollableWidth(tableInnerScrollRef.current.scrollWidth);
3871
3961
  }
3872
3962
  }, [taskListWidth, listCellWidth]);
3873
3963
 
3874
3964
  var handleTableResizeMouseDown = function handleTableResizeMouseDown(e) {
3875
- var _taskListRef$current$, _taskListRef$current, _tableInnerScrollRef$, _tableInnerScrollRef$2, _wrapperRef$current$o, _wrapperRef$current;
3965
+ var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
3876
3966
 
3877
3967
  isDraggingTable.current = true;
3878
3968
  dragStartX.current = e.clientX;
3879
3969
  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;
3880
- 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);
3970
+ 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);
3881
3971
  e.preventDefault();
3882
3972
  };
3883
3973
 
@@ -3995,13 +4085,13 @@ var Gantt = function Gantt(_ref) {
3995
4085
  }
3996
4086
 
3997
4087
  debounceRef.current = setTimeout(function () {
3998
- var _effectiveCalendar$qu;
4088
+ var _projectCalendar$quar;
3999
4089
 
4000
4090
  var filteredTasks;
4001
4091
  filteredTasks = removeHiddenTasks(tasks);
4002
4092
  filteredTasks = filteredTasks.sort(sortTasks);
4003
4093
 
4004
- var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_effectiveCalendar$qu = effectiveCalendar === null || effectiveCalendar === void 0 ? void 0 : effectiveCalendar.quarter_start) != null ? _effectiveCalendar$qu : 0),
4094
+ var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0),
4005
4095
  startDateRange = _ganttDateRange2[0],
4006
4096
  endDateRange = _ganttDateRange2[1];
4007
4097
 
@@ -4040,7 +4130,7 @@ var Gantt = function Gantt(_ref) {
4040
4130
  setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
4041
4131
  setIsProcessing(false);
4042
4132
  }, delayToRender);
4043
- }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, effectiveCalendar]);
4133
+ }, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, projectCalendar]);
4044
4134
  useEffect(function () {
4045
4135
  return function () {
4046
4136
  clearTimeout(debounceRef.current);
@@ -4312,7 +4402,7 @@ var Gantt = function Gantt(_ref) {
4312
4402
  rtl: rtl,
4313
4403
  visibleStartY: visibleStartY,
4314
4404
  visibleEndY: visibleEndY,
4315
- projectCalendar: effectiveCalendar,
4405
+ projectCalendar: projectCalendar,
4316
4406
  viewMode: viewMode
4317
4407
  };
4318
4408
  var calendarProps = {
@@ -4324,7 +4414,7 @@ var Gantt = function Gantt(_ref) {
4324
4414
  fontFamily: fontFamily,
4325
4415
  fontSize: fontSize,
4326
4416
  rtl: rtl,
4327
- projectCalendar: effectiveCalendar
4417
+ projectCalendar: projectCalendar
4328
4418
  };
4329
4419
  var barProps = {
4330
4420
  tasks: barTasks,
@@ -4351,7 +4441,7 @@ var Gantt = function Gantt(_ref) {
4351
4441
  onClick: onClick,
4352
4442
  onDelete: onDelete,
4353
4443
  onCalendarError: onCalendarError,
4354
- projectCalendar: effectiveCalendar,
4444
+ projectCalendar: projectCalendar,
4355
4445
  visibleStartY: visibleStartY,
4356
4446
  visibleEndY: visibleEndY,
4357
4447
  sliderTime: sliderTime
@@ -4384,7 +4474,8 @@ var Gantt = function Gantt(_ref) {
4384
4474
  taskLabelRenderer: taskLabelRenderer,
4385
4475
  onMultiSelect: onMultiSelect,
4386
4476
  containerWidth: tableContainerWidth != null ? tableContainerWidth : undefined,
4387
- innerScrollRef: tableInnerScrollRef
4477
+ innerScrollRef: tableInnerScrollRef,
4478
+ horizontalContainerRef: tableHorizontalContainerRef
4388
4479
  };
4389
4480
  return React.createElement("div", {
4390
4481
  style: {
@@ -4480,8 +4571,8 @@ var Gantt = function Gantt(_ref) {
4480
4571
  flexShrink: 0
4481
4572
  },
4482
4573
  onScroll: function onScroll(e) {
4483
- if (tableInnerScrollRef.current) {
4484
- tableInnerScrollRef.current.scrollLeft = e.currentTarget.scrollLeft;
4574
+ if (tableHorizontalContainerRef.current) {
4575
+ tableHorizontalContainerRef.current.scrollLeft = e.currentTarget.scrollLeft;
4485
4576
  }
4486
4577
  }
4487
4578
  }, React.createElement("div", {