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