gantt-task-react-powern 0.4.19 → 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 +109 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +109 -2
- 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
|
@@ -575,7 +575,8 @@ var VerticalScroll = function VerticalScroll(_ref) {
|
|
|
575
575
|
style: {
|
|
576
576
|
height: ganttHeight,
|
|
577
577
|
marginTop: headerHeight,
|
|
578
|
-
marginLeft: rtl ? "" : "-1rem"
|
|
578
|
+
marginLeft: rtl ? "" : "-1rem",
|
|
579
|
+
marginRight: "1rem"
|
|
579
580
|
},
|
|
580
581
|
className: styles$3.scroll,
|
|
581
582
|
onScroll: onScroll,
|
|
@@ -2227,6 +2228,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2227
2228
|
className: "arrows"
|
|
2228
2229
|
}, tasks.map(function (task) {
|
|
2229
2230
|
return task.barChildren.map(function (child) {
|
|
2231
|
+
var _task$criticalPathArr, _task$criticalPathArr2;
|
|
2232
|
+
|
|
2230
2233
|
return React__default.createElement(Arrow, {
|
|
2231
2234
|
key: "Arrow from " + task.id + " to " + tasks[child.index].id,
|
|
2232
2235
|
taskFrom: task,
|
|
@@ -2235,7 +2238,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2235
2238
|
taskHeight: taskHeight,
|
|
2236
2239
|
arrowIndent: arrowIndent,
|
|
2237
2240
|
rtl: rtl,
|
|
2238
|
-
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"
|
|
2239
2244
|
});
|
|
2240
2245
|
});
|
|
2241
2246
|
})), React__default.createElement("g", {
|
|
@@ -2344,6 +2349,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
2344
2349
|
|
|
2345
2350
|
var Gantt = function Gantt(_ref) {
|
|
2346
2351
|
var tasks = _ref.tasks,
|
|
2352
|
+
_ref$leafNodes = _ref.leafNodes,
|
|
2353
|
+
leafNodes = _ref$leafNodes === void 0 ? [] : _ref$leafNodes,
|
|
2347
2354
|
_ref$headerHeight = _ref.headerHeight,
|
|
2348
2355
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
2349
2356
|
_ref$columnWidth = _ref.columnWidth,
|
|
@@ -2513,6 +2520,13 @@ var Gantt = function Gantt(_ref) {
|
|
|
2513
2520
|
dates: newDates,
|
|
2514
2521
|
viewMode: viewMode
|
|
2515
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);
|
|
2516
2530
|
setBarTasks(convertToBarTasks(filteredTasks, newDates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
|
|
2517
2531
|
}, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, columnWidth, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, scrollX, onExpanderClick]);
|
|
2518
2532
|
React.useEffect(function () {
|
|
@@ -2727,6 +2741,99 @@ var Gantt = function Gantt(_ref) {
|
|
|
2727
2741
|
}
|
|
2728
2742
|
};
|
|
2729
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
|
+
|
|
2730
2837
|
var gridProps = {
|
|
2731
2838
|
columnWidth: columnWidth,
|
|
2732
2839
|
svgWidth: svgWidth,
|