gantt-task-react-powern 0.4.78 → 0.4.80

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.
@@ -1150,7 +1150,7 @@ var Calendar = function Calendar(_ref) {
1150
1150
 
1151
1151
  for (var i = 0; i < dates.length; i++) {
1152
1152
  var date = dates[i];
1153
- var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate().toString() : getLocalDayOfWeek(date, locale, "narrow") + " " + date.getDate().toString() + " " + (i < dates.length - 1 ? "," : "");
1153
+ var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate().toString() : getLocalDayOfWeek(date, locale, "narrow") + "," + date.getDate().toString();
1154
1154
  bottomValues.push(React.createElement("text", {
1155
1155
  key: date.getTime(),
1156
1156
  y: headerHeight * 0.8,
@@ -2518,44 +2518,51 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2518
2518
  }
2519
2519
  };
2520
2520
 
2521
- return React.createElement("g", {
2522
- className: "content"
2523
- }, React.createElement("g", {
2524
- className: "arrows"
2525
- }, tasks.map(function (_task) {
2526
- var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
2521
+ var getArrows = function getArrows(isCritical, criticalPathType) {
2522
+ return tasks.flatMap(function (_task) {
2523
+ var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
2527
2524
 
2528
- if (!task) {
2529
- return React.createElement("g", {
2530
- key: _task.id,
2531
- style: {
2532
- height: taskHeight
2533
- }
2534
- });
2535
- }
2525
+ if (!task) {
2526
+ return [React.createElement("g", {
2527
+ key: _task.id + (isCritical ? "-critical" : "-normal"),
2528
+ style: {
2529
+ height: taskHeight
2530
+ }
2531
+ })];
2532
+ }
2536
2533
 
2537
- return task.barChildren.map(function (child) {
2538
- var _task$criticalPathArr, _task$criticalPathArr2;
2539
-
2540
- if (task.x2 > task.x1 || task.actualx2 > task.actualx1) return React.createElement(Arrow, {
2541
- key: "Arrow from " + task.id + " to " + tasks[child.index].id,
2542
- taskFrom: task,
2543
- taskTo: tasks[child.index],
2544
- rowHeight: rowHeight,
2545
- taskHeight: taskHeight,
2546
- arrowIndent: arrowIndent,
2547
- rtl: rtl,
2548
- arrowColor: ((_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : (_task$criticalPathArr2 = _task$criticalPathArr.find(function (arrow) {
2549
- return arrow.taskId == tasks[child.index].id;
2550
- })) === null || _task$criticalPathArr2 === void 0 ? void 0 : _task$criticalPathArr2.arrowColor) || "#808080"
2551
- });else return React.createElement("g", {
2552
- key: _task.id,
2553
- style: {
2554
- height: taskHeight
2534
+ return task.barChildren.map(function (child) {
2535
+ if (task.x2 > task.x1 || task.actualx2 > task.actualx1) {
2536
+ var _task$criticalPathArr;
2537
+
2538
+ var criticalTask = (_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : _task$criticalPathArr.find(function (arrow) {
2539
+ return arrow.taskId === tasks[child.index].id && (!!arrow.criticalPathType ? arrow.criticalPathType === criticalPathType : !criticalPathType);
2540
+ });
2541
+
2542
+ if (!!criticalTask === isCritical) {
2543
+ return React.createElement(Arrow, {
2544
+ key: "Arrow from " + task.id + " to " + tasks[child.index].id + (isCritical ? "-critical" : ""),
2545
+ taskFrom: task,
2546
+ taskTo: tasks[child.index],
2547
+ rowHeight: rowHeight,
2548
+ taskHeight: taskHeight,
2549
+ arrowIndent: arrowIndent,
2550
+ rtl: rtl,
2551
+ arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
2552
+ });
2553
+ }
2555
2554
  }
2556
- });
2555
+
2556
+ return null;
2557
+ }).filter(Boolean);
2557
2558
  });
2558
- })), React.createElement("g", {
2559
+ };
2560
+
2561
+ return React.createElement("g", {
2562
+ className: "content"
2563
+ }, React.createElement("g", {
2564
+ className: "arrows"
2565
+ }, getArrows(false), getArrows(true, "secondary"), getArrows(true, "primary")), React.createElement("g", {
2559
2566
  className: "bar",
2560
2567
  fontFamily: fontFamily,
2561
2568
  fontSize: fontSize
@@ -2815,7 +2822,7 @@ var Gantt = function Gantt(_ref) {
2815
2822
  failedTask = _useState9[0],
2816
2823
  setFailedTask = _useState9[1];
2817
2824
 
2818
- var svgWidth = dateSetup.dates.length * columnWidth;
2825
+ var svgWidth = columnWidth < 55 ? (dateSetup.dates.length + 0.5) * columnWidth : dateSetup.dates.length * columnWidth;
2819
2826
  var ganttFullHeight = barTasks.length * rowHeight;
2820
2827
 
2821
2828
  var _useState10 = useState(0),
@@ -2881,8 +2888,8 @@ var Gantt = function Gantt(_ref) {
2881
2888
  uncolorAll(tasks);
2882
2889
 
2883
2890
  if (scheduleType !== "lookAhead") {
2884
- colorPath(secondaryPath, "#00ff00", tasks);
2885
- colorPath(primaryPath, "#ff0000", tasks);
2891
+ colorPath(secondaryPath, "#00ff00", tasks, "secondary");
2892
+ colorPath(primaryPath, "#ff0000", tasks, "primary");
2886
2893
  }
2887
2894
 
2888
2895
  setBarTasks(convertToBarTasks(filteredTasks, newDates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
@@ -3325,7 +3332,7 @@ function uncolorAll(tasks) {
3325
3332
  delete task.criticalPathArrows;
3326
3333
  });
3327
3334
  }
3328
- function colorPath(path, color, tasks) {
3335
+ function colorPath(path, color, tasks, criticalPathType) {
3329
3336
  for (var i = 0; i < path.length; i++) {
3330
3337
  var longestIDLength = 0;
3331
3338
  var longestTask = void 0;
@@ -3368,10 +3375,16 @@ function colorPath(path, color, tasks) {
3368
3375
  var arrow = arrows.find(function (arrow) {
3369
3376
  return arrow.taskId === path[_i7 + 1].id;
3370
3377
  });
3371
- if (arrow) arrow.arrowColor = color;else arrows.push({
3378
+
3379
+ if (arrow) {
3380
+ arrow.arrowColor = color;
3381
+ arrow.criticalPathType = criticalPathType;
3382
+ } else arrows.push({
3372
3383
  taskId: path[_i7 + 1].id,
3373
- arrowColor: color
3384
+ arrowColor: color,
3385
+ criticalPathType: criticalPathType
3374
3386
  });
3387
+
3375
3388
  taskFromTasks.criticalPathArrows = arrows;
3376
3389
  }
3377
3390
  };