gantt-task-react-powern 0.4.20 → 0.4.21
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.
- package/dist/components/task-item/bar/bar-display.d.ts +4 -0
- package/dist/index.js +107 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +107 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/types/bar-task.d.ts +4 -0
- package/dist/types/public-types.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -2227,6 +2227,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2227
2227
|
className: "arrows"
|
|
2228
2228
|
}, tasks.map(function (task) {
|
|
2229
2229
|
return task.barChildren.map(function (child) {
|
|
2230
|
+
var _task$criticalPathArr, _task$criticalPathArr2;
|
|
2231
|
+
|
|
2230
2232
|
return React.createElement(Arrow, {
|
|
2231
2233
|
key: "Arrow from " + task.id + " to " + tasks[child.index].id,
|
|
2232
2234
|
taskFrom: task,
|
|
@@ -2235,7 +2237,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2235
2237
|
taskHeight: taskHeight,
|
|
2236
2238
|
arrowIndent: arrowIndent,
|
|
2237
2239
|
rtl: rtl,
|
|
2238
|
-
arrowColor: task.
|
|
2240
|
+
arrowColor: ((_task$criticalPathArr = task.criticalPathArrows) === null || _task$criticalPathArr === void 0 ? void 0 : (_task$criticalPathArr2 = _task$criticalPathArr.find(function (arrow) {
|
|
2241
|
+
return arrow.taskId == tasks[child.index].id;
|
|
2242
|
+
})) === null || _task$criticalPathArr2 === void 0 ? void 0 : _task$criticalPathArr2.arrowColor) || "#808080"
|
|
2239
2243
|
});
|
|
2240
2244
|
});
|
|
2241
2245
|
})), React.createElement("g", {
|
|
@@ -2344,6 +2348,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
2344
2348
|
|
|
2345
2349
|
var Gantt = function Gantt(_ref) {
|
|
2346
2350
|
var tasks = _ref.tasks,
|
|
2351
|
+
_ref$leafNodes = _ref.leafNodes,
|
|
2352
|
+
leafNodes = _ref$leafNodes === void 0 ? [] : _ref$leafNodes,
|
|
2347
2353
|
_ref$headerHeight = _ref.headerHeight,
|
|
2348
2354
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
2349
2355
|
_ref$columnWidth = _ref.columnWidth,
|
|
@@ -2513,6 +2519,13 @@ var Gantt = function Gantt(_ref) {
|
|
|
2513
2519
|
dates: newDates,
|
|
2514
2520
|
viewMode: viewMode
|
|
2515
2521
|
});
|
|
2522
|
+
|
|
2523
|
+
var _getCriticalPaths = getCriticalPaths(leafNodes),
|
|
2524
|
+
primaryPath = _getCriticalPaths[0],
|
|
2525
|
+
secondaryPath = _getCriticalPaths[1];
|
|
2526
|
+
|
|
2527
|
+
colorPath(secondaryPath, "#00ff00", tasks);
|
|
2528
|
+
colorPath(primaryPath, "#ff0000", tasks);
|
|
2516
2529
|
setBarTasks(convertToBarTasks(filteredTasks, newDates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
|
|
2517
2530
|
}, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, columnWidth, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, scrollX, onExpanderClick]);
|
|
2518
2531
|
useEffect(function () {
|
|
@@ -2727,6 +2740,99 @@ var Gantt = function Gantt(_ref) {
|
|
|
2727
2740
|
}
|
|
2728
2741
|
};
|
|
2729
2742
|
|
|
2743
|
+
function getCriticalPaths(leafTasks) {
|
|
2744
|
+
var _leafTasks$reduce = leafTasks.reduce(function (_ref2, leafTask) {
|
|
2745
|
+
var primaryPath = _ref2[0],
|
|
2746
|
+
secondaryPath = _ref2[1],
|
|
2747
|
+
primaryDuration = _ref2[2],
|
|
2748
|
+
secondaryDuration = _ref2[3];
|
|
2749
|
+
var newPath = criticalPath(leafTask, leafTasks);
|
|
2750
|
+
var newDuration = computeDuration(newPath);
|
|
2751
|
+
if (newDuration <= secondaryDuration) return [primaryPath, secondaryPath, primaryDuration, secondaryDuration];
|
|
2752
|
+
|
|
2753
|
+
if (newDuration > primaryDuration) {
|
|
2754
|
+
var _primaryPath$;
|
|
2755
|
+
|
|
2756
|
+
if (((_primaryPath$ = primaryPath[0]) === null || _primaryPath$ === void 0 ? void 0 : _primaryPath$.id) !== newPath[0].id) return [newPath, primaryPath, newDuration, primaryDuration];else return [newPath, secondaryPath, newDuration, secondaryDuration];
|
|
2757
|
+
} else {
|
|
2758
|
+
var _primaryPath$2;
|
|
2759
|
+
|
|
2760
|
+
if (((_primaryPath$2 = primaryPath[0]) === null || _primaryPath$2 === void 0 ? void 0 : _primaryPath$2.id) !== newPath[0].id) return [primaryPath, newPath, primaryDuration, newDuration];else return [primaryPath, secondaryPath, primaryDuration, secondaryDuration];
|
|
2761
|
+
}
|
|
2762
|
+
}, [[], [], 0, 0]),
|
|
2763
|
+
primaryPath = _leafTasks$reduce[0],
|
|
2764
|
+
secondaryPath = _leafTasks$reduce[1];
|
|
2765
|
+
|
|
2766
|
+
return [primaryPath, secondaryPath];
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
function computeDuration(path) {
|
|
2770
|
+
return path.length ? path[path.length - 1].end.getTime() - path[0].start.getTime() : 0;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
function criticalPath(task, tasks) {
|
|
2774
|
+
var _task$dependencies;
|
|
2775
|
+
|
|
2776
|
+
if (!task) {
|
|
2777
|
+
return [];
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
if (!task.dependencies) return [task];
|
|
2781
|
+
|
|
2782
|
+
var _task$dependencies$re = (_task$dependencies = task.dependencies) === null || _task$dependencies === void 0 ? void 0 : _task$dependencies.reduce(function (_ref3, dependencyTaskId) {
|
|
2783
|
+
var longestPath = _ref3[0],
|
|
2784
|
+
longestDuration = _ref3[1];
|
|
2785
|
+
var dependencyTask = tasks.find(function (otherTask) {
|
|
2786
|
+
return otherTask.id === dependencyTaskId;
|
|
2787
|
+
});
|
|
2788
|
+
var dependencyPath = criticalPath(dependencyTask, tasks);
|
|
2789
|
+
var dependencyDuration = computeDuration(dependencyPath);
|
|
2790
|
+
if (dependencyDuration > longestDuration) return [dependencyPath, dependencyDuration];else return [longestPath, longestDuration];
|
|
2791
|
+
}, [[], 0]),
|
|
2792
|
+
longestPath = _task$dependencies$re[0];
|
|
2793
|
+
|
|
2794
|
+
return [].concat(longestPath, [task]);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
function colorPath(path, color, tasks) {
|
|
2798
|
+
var _loop = function _loop(i) {
|
|
2799
|
+
var task = tasks.find(function (otherTask) {
|
|
2800
|
+
return path[i].id === otherTask.id;
|
|
2801
|
+
});
|
|
2802
|
+
|
|
2803
|
+
while (task) {
|
|
2804
|
+
if (!task.styles) task.styles = {};
|
|
2805
|
+
task.styles.criticalPathColor = color;
|
|
2806
|
+
task = tasks.find(function (otherTask) {
|
|
2807
|
+
var _task;
|
|
2808
|
+
|
|
2809
|
+
return (_task = task) === null || _task === void 0 ? void 0 : _task.id.startsWith(otherTask.id + ".");
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
for (var i = 0; i < path.length; i++) {
|
|
2815
|
+
_loop(i);
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
var _loop2 = function _loop2(_i) {
|
|
2819
|
+
var arrows = path[_i].criticalPathArrows;
|
|
2820
|
+
if (!arrows) arrows = [];
|
|
2821
|
+
var arrow = arrows.find(function (arrow) {
|
|
2822
|
+
return arrow.taskId === path[_i + 1].id;
|
|
2823
|
+
});
|
|
2824
|
+
if (arrow) arrow.arrowColor = color;else arrows.push({
|
|
2825
|
+
taskId: path[_i + 1].id,
|
|
2826
|
+
arrowColor: color
|
|
2827
|
+
});
|
|
2828
|
+
path[_i].criticalPathArrows = arrows;
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
for (var _i = 0; _i + 1 < path.length; _i++) {
|
|
2832
|
+
_loop2(_i);
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2730
2836
|
var gridProps = {
|
|
2731
2837
|
columnWidth: columnWidth,
|
|
2732
2838
|
svgWidth: svgWidth,
|