gantt-task-react-powern 0.4.85 → 0.4.87
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/other/arrow.d.ts +2 -1
- package/dist/index.js +96 -62
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +96 -62
- package/dist/index.modern.js.map +1 -1
- package/dist/types/bar-task.d.ts +2 -1
- package/dist/types/public-types.d.ts +6 -1
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BarTask } from "../../types/bar-task";
|
|
3
|
+
import { Dependency } from "../../types/public-types";
|
|
3
4
|
declare type ArrowProps = {
|
|
4
5
|
taskFrom: BarTask;
|
|
5
6
|
taskTo: BarTask;
|
|
6
7
|
rowHeight: number;
|
|
7
8
|
taskHeight: number;
|
|
8
9
|
arrowIndent: number;
|
|
9
|
-
rtl: boolean;
|
|
10
10
|
arrowColor: string;
|
|
11
|
+
dependencyType: Dependency;
|
|
11
12
|
};
|
|
12
13
|
export declare const Arrow: React.FC<ArrowProps>;
|
|
13
14
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1358,22 +1358,12 @@ var Arrow = function Arrow(_ref) {
|
|
|
1358
1358
|
rowHeight = _ref.rowHeight,
|
|
1359
1359
|
taskHeight = _ref.taskHeight,
|
|
1360
1360
|
arrowIndent = _ref.arrowIndent,
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
var path;
|
|
1364
|
-
var trianglePoints;
|
|
1361
|
+
arrowColor = _ref.arrowColor,
|
|
1362
|
+
dependencyType = _ref.dependencyType;
|
|
1365
1363
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
path = _drownPathAndTriangle[0];
|
|
1370
|
-
trianglePoints = _drownPathAndTriangle[1];
|
|
1371
|
-
} else {
|
|
1372
|
-
var _drownPathAndTriangle2 = drownPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent);
|
|
1373
|
-
|
|
1374
|
-
path = _drownPathAndTriangle2[0];
|
|
1375
|
-
trianglePoints = _drownPathAndTriangle2[1];
|
|
1376
|
-
}
|
|
1364
|
+
var _drawPathAndTriangle = drawPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType),
|
|
1365
|
+
path = _drawPathAndTriangle[0],
|
|
1366
|
+
trianglePoints = _drawPathAndTriangle[1];
|
|
1377
1367
|
|
|
1378
1368
|
return React__default.createElement("g", {
|
|
1379
1369
|
className: "arrow"
|
|
@@ -1388,35 +1378,84 @@ var Arrow = function Arrow(_ref) {
|
|
|
1388
1378
|
}));
|
|
1389
1379
|
};
|
|
1390
1380
|
|
|
1391
|
-
var
|
|
1392
|
-
var
|
|
1381
|
+
var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent, dependencyType) {
|
|
1382
|
+
var indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
|
|
1383
|
+
var taskToEndY = taskTo.y + taskHeight / 2;
|
|
1384
|
+
var verticalOffset = indexCompare * (rowHeight / 2);
|
|
1385
|
+
|
|
1386
|
+
var minX = function minX(t) {
|
|
1387
|
+
if (t.x1 && t.actualx1) {
|
|
1388
|
+
return Math.min(t.x1, t.actualx1);
|
|
1389
|
+
} else if (t.x1) {
|
|
1390
|
+
return t.x1;
|
|
1391
|
+
} else if (t.actualx1) {
|
|
1392
|
+
return t.actualx1;
|
|
1393
|
+
} else {
|
|
1394
|
+
return 0;
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1393
1397
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1398
|
+
var maxX = function maxX(t) {
|
|
1399
|
+
return Math.max(t.x2 || 0, t.actualx2 || 0);
|
|
1400
|
+
};
|
|
1397
1401
|
|
|
1398
|
-
|
|
1399
|
-
taskFromEnd = Math.max(taskFrom.x2, taskFrom.actualx2);
|
|
1400
|
-
} else if (taskFrom.x2 > 0) taskFromEnd = taskFrom.x2;else if (taskFrom.actualx2 > 0) taskFromEnd = taskFrom.actualx2;else taskFromEnd = 0;
|
|
1402
|
+
var fromPoint, toPoint;
|
|
1401
1403
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1404
|
+
switch (dependencyType) {
|
|
1405
|
+
case "SS":
|
|
1406
|
+
fromPoint = minX(taskFrom);
|
|
1407
|
+
toPoint = minX(taskTo);
|
|
1408
|
+
break;
|
|
1409
|
+
|
|
1410
|
+
case "SF":
|
|
1411
|
+
fromPoint = minX(taskFrom);
|
|
1412
|
+
toPoint = maxX(taskTo);
|
|
1413
|
+
break;
|
|
1414
|
+
|
|
1415
|
+
case "FS":
|
|
1416
|
+
fromPoint = maxX(taskFrom);
|
|
1417
|
+
toPoint = minX(taskTo);
|
|
1418
|
+
break;
|
|
1419
|
+
|
|
1420
|
+
case "FF":
|
|
1421
|
+
fromPoint = maxX(taskFrom);
|
|
1422
|
+
toPoint = maxX(taskTo);
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
var arrowPoints = function arrowPoints(x, y, right) {
|
|
1427
|
+
if (right === void 0) {
|
|
1428
|
+
right = true;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
return right ? x + "," + y + " " + (x - 5) + "," + (y - 5) + " " + (x - 5) + "," + (y + 5) : x + "," + y + " " + (x + 5) + "," + (y - 5) + " " + (x + 5) + "," + (y + 5);
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
var path;
|
|
1435
|
+
var trianglePoints;
|
|
1436
|
+
|
|
1437
|
+
switch (dependencyType) {
|
|
1438
|
+
case "SS":
|
|
1439
|
+
path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + Math.min(toPoint - fromPoint, 0) - 2 * arrowIndent) + "\n V " + taskToEndY + "\n H " + (toPoint - 5);
|
|
1440
|
+
trianglePoints = arrowPoints(toPoint, taskToEndY, true);
|
|
1441
|
+
break;
|
|
1442
|
+
|
|
1443
|
+
case "SF":
|
|
1444
|
+
path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint - 2 * arrowIndent) + "\n V " + (taskFrom.y + taskHeight / 2 + verticalOffset) + "\n " + (fromPoint - toPoint > 4 * arrowIndent ? "" : "H " + (toPoint + 2 * arrowIndent)) + "\n V " + taskToEndY + "\n H " + (toPoint + 5);
|
|
1445
|
+
trianglePoints = arrowPoints(toPoint, taskToEndY, false);
|
|
1446
|
+
break;
|
|
1447
|
+
|
|
1448
|
+
case "FS":
|
|
1449
|
+
path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + 2 * arrowIndent) + "\n V " + (taskFrom.y + taskHeight / 2 + verticalOffset) + "\n " + (toPoint - fromPoint > 4 * arrowIndent ? "" : "H " + (toPoint - 2 * arrowIndent)) + "\n V " + taskToEndY + "\n H " + (toPoint - 5);
|
|
1450
|
+
trianglePoints = arrowPoints(toPoint, taskToEndY, true);
|
|
1451
|
+
break;
|
|
1452
|
+
|
|
1453
|
+
case "FF":
|
|
1454
|
+
path = "M " + fromPoint + " " + (taskFrom.y + taskHeight / 2) + "\n H " + (fromPoint + Math.max(toPoint - fromPoint, 0) + 2 * arrowIndent) + "\n V " + taskToEndY + "\n H " + (toPoint + 5);
|
|
1455
|
+
trianglePoints = arrowPoints(toPoint, taskToEndY, false);
|
|
1456
|
+
break;
|
|
1457
|
+
}
|
|
1411
1458
|
|
|
1412
|
-
var drownPathAndTriangleRTL = function drownPathAndTriangleRTL(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent) {
|
|
1413
|
-
var indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
|
|
1414
|
-
var taskToEndPosition = taskTo.y + taskHeight / 2;
|
|
1415
|
-
var taskFromEndPosition = taskFrom.x1 - arrowIndent * 2;
|
|
1416
|
-
var taskFromHorizontalOffsetValue = taskFromEndPosition > taskTo.x2 ? "" : "H " + (taskTo.x2 + arrowIndent);
|
|
1417
|
-
var taskToHorizontalOffsetValue = taskFromEndPosition < taskTo.x2 ? -arrowIndent : taskTo.x2 - taskFrom.x1 + arrowIndent;
|
|
1418
|
-
var path = "M " + taskFrom.x1 + " " + (taskFrom.y + taskHeight / 2) + " \n h " + -arrowIndent + " \n v " + indexCompare * rowHeight / 2 + " \n " + taskFromHorizontalOffsetValue + "\n V " + taskToEndPosition + " \n h " + taskToHorizontalOffsetValue;
|
|
1419
|
-
var trianglePoints = taskTo.x2 + "," + taskToEndPosition + " \n " + (taskTo.x2 + 5) + "," + (taskToEndPosition + 5) + " \n " + (taskTo.x2 + 5) + "," + (taskToEndPosition - 5);
|
|
1420
1459
|
return [path, trianglePoints];
|
|
1421
1460
|
};
|
|
1422
1461
|
|
|
@@ -1429,9 +1468,16 @@ var convertToBarTasks = function convertToBarTasks(tasks, dates, columnWidth, ro
|
|
|
1429
1468
|
|
|
1430
1469
|
var _loop = function _loop(j) {
|
|
1431
1470
|
var dependence = barTasks.findIndex(function (value) {
|
|
1432
|
-
return value.id === dependencies[j];
|
|
1471
|
+
return value.id === dependencies[j].id;
|
|
1433
1472
|
});
|
|
1434
|
-
|
|
1473
|
+
|
|
1474
|
+
if (dependence !== -1 && task.start.getTime() > 0 && task.end.getTime() > 0) {
|
|
1475
|
+
var barchild = _extends({}, task, {
|
|
1476
|
+
dependencyType: dependencies[j].type
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
barTasks[dependence].barChildren.push(barchild);
|
|
1480
|
+
}
|
|
1435
1481
|
};
|
|
1436
1482
|
|
|
1437
1483
|
for (var j = 0; j < dependencies.length; j++) {
|
|
@@ -1523,7 +1569,7 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
1523
1569
|
};
|
|
1524
1570
|
|
|
1525
1571
|
var convertToMilestone = function convertToMilestone(task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, milestoneBackgroundColor, milestoneBackgroundSelectedColor) {
|
|
1526
|
-
var x = task.start && task.end ? taskXCoordinate(task.
|
|
1572
|
+
var x = task.start && task.end ? taskXCoordinate(task.start, dates, columnWidth) : 0;
|
|
1527
1573
|
var y = taskYCoordinate(index, rowHeight, taskHeight);
|
|
1528
1574
|
var x1 = task.start && task.end ? x - taskHeight * 0.5 : 0;
|
|
1529
1575
|
var x2 = task.start && task.end ? x + taskHeight * 0.5 : 0;
|
|
@@ -1841,7 +1887,10 @@ function getChildren(taskList, task) {
|
|
|
1841
1887
|
|
|
1842
1888
|
if (task.type !== "project") {
|
|
1843
1889
|
tasks = taskList.filter(function (t) {
|
|
1844
|
-
return t.dependencies && t.dependencies.
|
|
1890
|
+
return t.dependencies && t.dependencies.map(function (_ref) {
|
|
1891
|
+
var id = _ref.id;
|
|
1892
|
+
return id;
|
|
1893
|
+
}).indexOf(task.id) !== -1;
|
|
1845
1894
|
});
|
|
1846
1895
|
} else {
|
|
1847
1896
|
tasks = taskList.filter(function (t) {
|
|
@@ -2546,9 +2595,9 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2546
2595
|
taskFrom: task,
|
|
2547
2596
|
taskTo: tasks[child.index],
|
|
2548
2597
|
rowHeight: rowHeight,
|
|
2598
|
+
dependencyType: child.dependencyType,
|
|
2549
2599
|
taskHeight: taskHeight,
|
|
2550
2600
|
arrowIndent: arrowIndent,
|
|
2551
|
-
rtl: rtl,
|
|
2552
2601
|
arrowColor: (criticalTask === null || criticalTask === void 0 ? void 0 : criticalTask.arrowColor) || "#808080"
|
|
2553
2602
|
});
|
|
2554
2603
|
}
|
|
@@ -2570,21 +2619,6 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2570
2619
|
}, tasks.map(function (_task) {
|
|
2571
2620
|
var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 || _task.actualStart.getTime() > 0 && _task.actualEnd.getTime() > 0 ? _task : undefined;
|
|
2572
2621
|
|
|
2573
|
-
if (!task && _task.typeInternal === "milestone") {
|
|
2574
|
-
return React__default.createElement(Milestone, {
|
|
2575
|
-
task: _task,
|
|
2576
|
-
arrowIndent: arrowIndent,
|
|
2577
|
-
taskHeight: taskHeight,
|
|
2578
|
-
isProgressChangeable: false,
|
|
2579
|
-
isDateChangeable: false,
|
|
2580
|
-
isDelete: !_task.isDisabled,
|
|
2581
|
-
onEventStart: function onEventStart() {},
|
|
2582
|
-
key: _task.id,
|
|
2583
|
-
isSelected: !!selectedTask && _task.id === selectedTask.id,
|
|
2584
|
-
rtl: rtl
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
|
|
2588
2622
|
if (!task) {
|
|
2589
2623
|
return React__default.createElement("g", {
|
|
2590
2624
|
key: _task.id,
|
|
@@ -3282,7 +3316,7 @@ function topologicalOrderingHelper(taskID, taskMap, sortedTaskList) {
|
|
|
3282
3316
|
taskMap[taskID].started = true;
|
|
3283
3317
|
var task = taskMap[taskID].task;
|
|
3284
3318
|
if (task.dependencies) for (var i = 0; i < task.dependencies.length; i++) {
|
|
3285
|
-
var successVal = topologicalOrderingHelper(task.dependencies[i], taskMap, sortedTaskList);
|
|
3319
|
+
var successVal = topologicalOrderingHelper(task.dependencies[i].id, taskMap, sortedTaskList);
|
|
3286
3320
|
if (!successVal) return false;
|
|
3287
3321
|
}
|
|
3288
3322
|
taskMap[taskID].finished = true;
|
|
@@ -3314,7 +3348,7 @@ function getCriticalPaths(leafTasks) {
|
|
|
3314
3348
|
if (task.dependencies) for (var j = 0; j < task.dependencies.length; j++) {
|
|
3315
3349
|
var _taskMap$task$depende;
|
|
3316
3350
|
|
|
3317
|
-
(_taskMap$task$depende = taskMap[task.dependencies[j]]) === null || _taskMap$task$depende === void 0 ? void 0 : _taskMap$task$depende.dependents.push(task.id);
|
|
3351
|
+
(_taskMap$task$depende = taskMap[task.dependencies[j].id]) === null || _taskMap$task$depende === void 0 ? void 0 : _taskMap$task$depende.dependents.push(task.id);
|
|
3318
3352
|
}
|
|
3319
3353
|
}
|
|
3320
3354
|
|