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