gantt-task-react-powern 0.6.28 → 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"
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.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
+ }
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"
@@ -3732,8 +3816,6 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
3732
3816
  };
3733
3817
 
3734
3818
  var Gantt = function Gantt(_ref) {
3735
- var _tasks$find$calender, _tasks$find;
3736
-
3737
3819
  var tasks = _ref.tasks,
3738
3820
  _ref$leafTasks = _ref.leafTasks,
3739
3821
  leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
@@ -3824,9 +3906,6 @@ var Gantt = function Gantt(_ref) {
3824
3906
  projectCalendar = _ref.projectCalendar,
3825
3907
  onCalendarError = _ref.onCalendarError,
3826
3908
  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
3909
  var wrapperRef = useRef(null);
3831
3910
  var taskListRef = useRef(null);
3832
3911
  var isDraggingTable = useRef(false);
@@ -3839,6 +3918,7 @@ var Gantt = function Gantt(_ref) {
3839
3918
  setTableContainerWidth = _useState[1];
3840
3919
 
3841
3920
  var tableInnerScrollRef = useRef(null);
3921
+ var tableHorizontalContainerRef = useRef(null);
3842
3922
  var tableHScrollRef = useRef(null);
3843
3923
 
3844
3924
  var _useState2 = useState(0),
@@ -3874,18 +3954,20 @@ var Gantt = function Gantt(_ref) {
3874
3954
  setTaskListWidth = _useState5[1];
3875
3955
 
3876
3956
  useEffect(function () {
3877
- if (tableInnerScrollRef.current) {
3957
+ if (tableHorizontalContainerRef.current) {
3958
+ setTableScrollableWidth(tableHorizontalContainerRef.current.scrollWidth);
3959
+ } else if (tableInnerScrollRef.current) {
3878
3960
  setTableScrollableWidth(tableInnerScrollRef.current.scrollWidth);
3879
3961
  }
3880
3962
  }, [taskListWidth, listCellWidth]);
3881
3963
 
3882
3964
  var handleTableResizeMouseDown = function handleTableResizeMouseDown(e) {
3883
- 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;
3884
3966
 
3885
3967
  isDraggingTable.current = true;
3886
3968
  dragStartX.current = e.clientX;
3887
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;
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);
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);
3889
3971
  e.preventDefault();
3890
3972
  };
3891
3973
 
@@ -4003,13 +4085,13 @@ var Gantt = function Gantt(_ref) {
4003
4085
  }
4004
4086
 
4005
4087
  debounceRef.current = setTimeout(function () {
4006
- var _effectiveCalendar$qu;
4088
+ var _projectCalendar$quar;
4007
4089
 
4008
4090
  var filteredTasks;
4009
4091
  filteredTasks = removeHiddenTasks(tasks);
4010
4092
  filteredTasks = filteredTasks.sort(sortTasks);
4011
4093
 
4012
- 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),
4013
4095
  startDateRange = _ganttDateRange2[0],
4014
4096
  endDateRange = _ganttDateRange2[1];
4015
4097
 
@@ -4048,7 +4130,7 @@ var Gantt = function Gantt(_ref) {
4048
4130
  setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
4049
4131
  setIsProcessing(false);
4050
4132
  }, delayToRender);
4051
- }, [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]);
4052
4134
  useEffect(function () {
4053
4135
  return function () {
4054
4136
  clearTimeout(debounceRef.current);
@@ -4320,7 +4402,7 @@ var Gantt = function Gantt(_ref) {
4320
4402
  rtl: rtl,
4321
4403
  visibleStartY: visibleStartY,
4322
4404
  visibleEndY: visibleEndY,
4323
- projectCalendar: effectiveCalendar,
4405
+ projectCalendar: projectCalendar,
4324
4406
  viewMode: viewMode
4325
4407
  };
4326
4408
  var calendarProps = {
@@ -4332,7 +4414,7 @@ var Gantt = function Gantt(_ref) {
4332
4414
  fontFamily: fontFamily,
4333
4415
  fontSize: fontSize,
4334
4416
  rtl: rtl,
4335
- projectCalendar: effectiveCalendar
4417
+ projectCalendar: projectCalendar
4336
4418
  };
4337
4419
  var barProps = {
4338
4420
  tasks: barTasks,
@@ -4359,7 +4441,7 @@ var Gantt = function Gantt(_ref) {
4359
4441
  onClick: onClick,
4360
4442
  onDelete: onDelete,
4361
4443
  onCalendarError: onCalendarError,
4362
- projectCalendar: effectiveCalendar,
4444
+ projectCalendar: projectCalendar,
4363
4445
  visibleStartY: visibleStartY,
4364
4446
  visibleEndY: visibleEndY,
4365
4447
  sliderTime: sliderTime
@@ -4392,7 +4474,8 @@ var Gantt = function Gantt(_ref) {
4392
4474
  taskLabelRenderer: taskLabelRenderer,
4393
4475
  onMultiSelect: onMultiSelect,
4394
4476
  containerWidth: tableContainerWidth != null ? tableContainerWidth : undefined,
4395
- innerScrollRef: tableInnerScrollRef
4477
+ innerScrollRef: tableInnerScrollRef,
4478
+ horizontalContainerRef: tableHorizontalContainerRef
4396
4479
  };
4397
4480
  return React.createElement("div", {
4398
4481
  style: {
@@ -4488,8 +4571,8 @@ var Gantt = function Gantt(_ref) {
4488
4571
  flexShrink: 0
4489
4572
  },
4490
4573
  onScroll: function onScroll(e) {
4491
- if (tableInnerScrollRef.current) {
4492
- tableInnerScrollRef.current.scrollLeft = e.currentTarget.scrollLeft;
4574
+ if (tableHorizontalContainerRef.current) {
4575
+ tableHorizontalContainerRef.current.scrollLeft = e.currentTarget.scrollLeft;
4493
4576
  }
4494
4577
  }
4495
4578
  }, React.createElement("div", {