gantt-task-react-powern 0.4.49 → 0.4.51

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.
@@ -105,25 +105,27 @@ var startOfDate = function startOfDate(date, scale) {
105
105
  return newDate;
106
106
  };
107
107
  var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount) {
108
- var newStartDate = tasks[0].start;
109
- var newEndDate = tasks[0].start;
108
+ var _tasks$, _tasks$2;
109
+
110
+ var newStartDate = tasks[0].start.getTime() !== 0 ? ((_tasks$ = tasks[0]) === null || _tasks$ === void 0 ? void 0 : _tasks$.start) || new Date() : new Date();
111
+ var newEndDate = tasks[0].end.getTime() !== 0 ? ((_tasks$2 = tasks[0]) === null || _tasks$2 === void 0 ? void 0 : _tasks$2.end) || new Date() : new Date();
110
112
 
111
113
  for (var _iterator = _createForOfIteratorHelperLoose(tasks), _step; !(_step = _iterator()).done;) {
112
114
  var task = _step.value;
113
115
 
114
- if (task.start < newStartDate) {
116
+ if (task.start && task.start.getTime() !== 0 && task.start < newStartDate) {
115
117
  newStartDate = task.start;
116
118
  }
117
119
 
118
- if (task.end > newEndDate) {
120
+ if (task.end && task.end.getTime() !== 0 && task.end > newEndDate) {
119
121
  newEndDate = task.end;
120
122
  }
121
123
 
122
- if (task.actualStart < newStartDate) {
124
+ if (task.actualStart && task.actualStart.getTime() !== 0 && task.actualStart < newStartDate) {
123
125
  newStartDate = task.actualStart;
124
126
  }
125
127
 
126
- if (task.actualEnd > newEndDate) {
128
+ if (task.actualEnd && task.actualEnd.getTime() !== 0 && task.actualEnd > newEndDate) {
127
129
  newEndDate = task.actualEnd;
128
130
  }
129
131
  }
@@ -345,6 +347,7 @@ var localeDateStringCache = {};
345
347
 
346
348
  var toLocaleDateStringFactory = function toLocaleDateStringFactory(locale) {
347
349
  return function (date, dateTimeOptions) {
350
+ if (!date || date.getTime() === 0) return "";
348
351
  var key = date.toString();
349
352
  var lds = localeDateStringCache[key];
350
353
 
@@ -1209,8 +1212,16 @@ var Arrow = function Arrow(_ref) {
1209
1212
  };
1210
1213
 
1211
1214
  var drownPathAndTriangle = function drownPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent) {
1212
- var taskToStart = Math.min(taskTo.x1, taskTo.actualx1);
1213
- var taskFromEnd = Math.max(taskFrom.x2, taskFrom.actualx2);
1215
+ var taskToStart, taskFromEnd;
1216
+
1217
+ if (taskTo.x1 >= 0 && taskTo.actualx1 >= 0) {
1218
+ taskToStart = Math.min(taskTo.x1, taskTo.actualx1);
1219
+ } else if (taskTo.x1 >= 0) taskToStart = taskTo.x1;else if (taskTo.actualx1 >= 0) taskToStart = taskTo.actualx1;else taskToStart = 0;
1220
+
1221
+ if (taskFrom.x2 >= 0 && taskFrom.actualx2 >= 0) {
1222
+ taskFromEnd = Math.min(taskFrom.x2, taskFrom.actualx2);
1223
+ } else if (taskFrom.x2 >= 0) taskFromEnd = taskFrom.x2;else if (taskFrom.actualx2 >= 0) taskFromEnd = taskFrom.actualx2;else taskFromEnd = 0;
1224
+
1214
1225
  var indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
1215
1226
  var taskToEndPosition = taskTo.y + taskHeight / 2;
1216
1227
  var taskFromEndPosition = taskFromEnd + arrowIndent * 2;
@@ -1284,26 +1295,21 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1284
1295
  var progressEndWidth;
1285
1296
 
1286
1297
  if (rtl) {
1287
- x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
1288
- x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
1289
- actualx1 = taskXCoordinateRTL(task.actualStart, dates, columnWidth);
1290
- actualx2 = taskXCoordinateRTL(task.actualEnd, dates, columnWidth);
1298
+ x2 = task.start ? taskXCoordinateRTL(task.start, dates, columnWidth) : -1;
1299
+ x1 = task.end ? taskXCoordinateRTL(task.end, dates, columnWidth) : -1;
1300
+ actualx1 = task.actualStart ? taskXCoordinateRTL(task.actualStart, dates, columnWidth) : -1;
1301
+ actualx2 = task.actualEnd ? taskXCoordinateRTL(task.actualEnd, dates, columnWidth) : -1;
1291
1302
  } else {
1292
- x1 = taskXCoordinate(task.start, dates, columnWidth);
1293
- x2 = taskXCoordinate(task.end, dates, columnWidth);
1294
- actualx1 = taskXCoordinate(task.actualStart, dates, columnWidth);
1295
- actualx2 = taskXCoordinate(task.actualEnd, dates, columnWidth);
1303
+ x1 = task.start ? taskXCoordinate(task.start, dates, columnWidth) : -1;
1304
+ x2 = task.end ? taskXCoordinate(task.end, dates, columnWidth) : -1;
1305
+ actualx1 = task.actualStart ? taskXCoordinate(task.actualStart, dates, columnWidth) : -1;
1306
+ actualx2 = task.actualEnd ? taskXCoordinate(task.actualEnd, dates, columnWidth) : -1;
1296
1307
  }
1297
1308
 
1298
- progressStartWidth = Math.abs(actualx1 - x1);
1299
- progressEndWidth = Math.abs(actualx2 - x2);
1309
+ progressStartWidth = actualx1 && x1 ? Math.abs(actualx1 - x1) : -1;
1310
+ progressEndWidth = actualx2 && x2 ? Math.abs(actualx2 - x2) : -1;
1300
1311
  var typeInternal = task.type;
1301
1312
 
1302
- if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
1303
- typeInternal = "smalltask";
1304
- x2 = x1 + handleWidth * 2;
1305
- }
1306
-
1307
1313
  var _progressWithByParams = progressWithByParams(actualx1, actualx2, task.progress, rtl),
1308
1314
  progressWidth = _progressWithByParams[0],
1309
1315
  progressX = _progressWithByParams[1];
@@ -1340,10 +1346,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1340
1346
  };
1341
1347
 
1342
1348
  var convertToMilestone = function convertToMilestone(task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, milestoneBackgroundColor, milestoneBackgroundSelectedColor) {
1343
- var x = taskXCoordinate(task.start, dates, columnWidth);
1349
+ var x = task.start && task.end ? taskXCoordinate(task.start, dates, columnWidth) : 0;
1344
1350
  var y = taskYCoordinate(index, rowHeight, taskHeight);
1345
- var x1 = x - taskHeight * 0.5;
1346
- var x2 = x + taskHeight * 0.5;
1351
+ var x1 = task.start && task.end ? x - taskHeight * 0.5 : 0;
1352
+ var x2 = task.start && task.end ? x + taskHeight * 0.5 : 0;
1347
1353
  var rotatedHeight = taskHeight / 1.414;
1348
1354
 
1349
1355
  var styles = _extends({
@@ -1380,6 +1386,11 @@ var taskXCoordinate = function taskXCoordinate(xDate, dates, columnWidth) {
1380
1386
  var index = dates.findIndex(function (d) {
1381
1387
  return d.getTime() >= xDate.getTime();
1382
1388
  }) - 1;
1389
+
1390
+ if (index < 0) {
1391
+ return 0;
1392
+ }
1393
+
1383
1394
  var remainderMillis = xDate.getTime() - dates[index].getTime();
1384
1395
  var percentOfInterval = remainderMillis / (dates[index + 1].getTime() - dates[index].getTime());
1385
1396
  var x = index * columnWidth + percentOfInterval * columnWidth;
@@ -1398,13 +1409,13 @@ var taskYCoordinate = function taskYCoordinate(index, rowHeight, taskHeight) {
1398
1409
  };
1399
1410
 
1400
1411
  var progressWithByParams = function progressWithByParams(taskX1, taskX2, progress, rtl) {
1401
- var progressWidth = (taskX2 - taskX1) * progress * 0.01;
1412
+ var progressWidth = taskX2 > 0 && taskX1 > 0 ? (taskX2 - taskX1) * progress * 0.01 : 0;
1402
1413
  var progressX;
1403
1414
 
1404
1415
  if (rtl) {
1405
- progressX = taskX2 - progressWidth;
1416
+ progressX = taskX2 > 0 ? taskX2 - progressWidth : 0;
1406
1417
  } else {
1407
- progressX = taskX1;
1418
+ progressX = taskX1 > 0 ? taskX1 : 0;
1408
1419
  }
1409
1420
 
1410
1421
  return [progressWidth, progressX];
@@ -1778,95 +1789,108 @@ var Bar = function Bar(_ref) {
1778
1789
  isSelected = _ref.isSelected;
1779
1790
  var progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
1780
1791
  var handleHeight = task.height / 2 - 1;
1781
- if (type == "planned") return React.createElement("g", {
1782
- className: styles$6.barWrapper,
1783
- tabIndex: 0
1784
- }, React.createElement(BarDisplay, {
1785
- x: task.x1,
1786
- y: task.y,
1787
- type: type,
1788
- startProgressWidth: task.progressStartWidth,
1789
- endProgressWidth: task.progressEndWidth,
1790
- width: task.x2 - task.x1,
1791
- height: task.height / 2,
1792
- progressX: task.progressX,
1793
- progressWidth: task.progressWidth,
1794
- barCornerRadius: task.barCornerRadius,
1795
- styles: task.styles,
1796
- isSelected: isSelected,
1797
- onMouseDown: function onMouseDown(e) {
1798
- isDateChangeable && onEventStart("move", task, e, "planned");
1799
- }
1800
- }), React.createElement("g", {
1801
- className: "handleGroup"
1802
- }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1803
- x: task.x1 + 1,
1804
- y: task.y + 1,
1805
- width: task.handleWidth,
1806
- height: handleHeight,
1807
- barCornerRadius: task.barCornerRadius,
1808
- onMouseDown: function onMouseDown(e) {
1809
- onEventStart("start", task, e, "planned");
1810
- }
1811
- }), React.createElement(BarDateHandle, {
1812
- x: task.x2 - task.handleWidth - 1,
1813
- y: task.y + 1,
1814
- width: task.handleWidth,
1815
- height: handleHeight,
1816
- barCornerRadius: task.barCornerRadius,
1817
- onMouseDown: function onMouseDown(e) {
1818
- onEventStart("end", task, e, "planned");
1819
- }
1820
- })), isProgressChangeable && React.createElement(BarProgressHandle, {
1821
- progressPoint: progressPoint,
1822
- onMouseDown: function onMouseDown(e) {
1823
- onEventStart("progress", task, e, "planned");
1824
- }
1825
- })));else return React.createElement("g", {
1826
- className: styles$6.barWrapper,
1827
- tabIndex: 0
1828
- }, React.createElement(BarDisplay, {
1829
- x: task.actualx1,
1830
- y: task.y + task.height / 2,
1831
- type: type,
1832
- startProgressWidth: task.progressStartWidth,
1833
- endProgressWidth: task.progressEndWidth,
1834
- width: task.actualx2 - task.actualx1,
1835
- height: task.height / 2,
1836
- progressX: task.progressX,
1837
- progressWidth: task.progressWidth,
1838
- barCornerRadius: task.barCornerRadius,
1839
- styles: task.styles,
1840
- isSelected: isSelected,
1841
- onMouseDown: function onMouseDown(e) {
1842
- isDateChangeable && onEventStart("move", task, e, "actual");
1843
- }
1844
- }), React.createElement("g", {
1845
- className: "handleGroup"
1846
- }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1847
- x: task.actualx1 + 1,
1848
- y: task.y + task.height / 2 + 1,
1849
- width: task.handleWidth,
1850
- height: handleHeight,
1851
- barCornerRadius: task.barCornerRadius,
1852
- onMouseDown: function onMouseDown(e) {
1853
- onEventStart("start", task, e, "actual");
1854
- }
1855
- }), React.createElement(BarDateHandle, {
1856
- x: task.actualx2 - task.handleWidth - 1,
1857
- y: task.y + task.height / 2 + 1,
1858
- width: task.handleWidth,
1859
- height: handleHeight,
1860
- barCornerRadius: task.barCornerRadius,
1861
- onMouseDown: function onMouseDown(e) {
1862
- onEventStart("end", task, e, "actual");
1863
- }
1864
- })), isProgressChangeable && React.createElement(BarProgressHandle, {
1865
- progressPoint: progressPoint,
1866
- onMouseDown: function onMouseDown(e) {
1867
- onEventStart("progress", task, e, "actual");
1868
- }
1869
- })));
1792
+
1793
+ if (type == "planned") {
1794
+ if (task.x1 && task.x2) return React.createElement("g", {
1795
+ className: styles$6.barWrapper,
1796
+ tabIndex: 0
1797
+ }, React.createElement(BarDisplay, {
1798
+ x: task.x1,
1799
+ y: task.y,
1800
+ type: type,
1801
+ startProgressWidth: task.progressStartWidth,
1802
+ endProgressWidth: task.progressEndWidth,
1803
+ width: task.x2 - task.x1,
1804
+ height: task.height / 2,
1805
+ progressX: task.progressX,
1806
+ progressWidth: task.progressWidth,
1807
+ barCornerRadius: task.barCornerRadius,
1808
+ styles: task.styles,
1809
+ isSelected: isSelected,
1810
+ onMouseDown: function onMouseDown(e) {
1811
+ isDateChangeable && onEventStart("move", task, e, "planned");
1812
+ }
1813
+ }), React.createElement("g", {
1814
+ className: "handleGroup"
1815
+ }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1816
+ x: task.x1 + 1,
1817
+ y: task.y + 1,
1818
+ width: task.handleWidth,
1819
+ height: handleHeight,
1820
+ barCornerRadius: task.barCornerRadius,
1821
+ onMouseDown: function onMouseDown(e) {
1822
+ onEventStart("start", task, e, "planned");
1823
+ }
1824
+ }), React.createElement(BarDateHandle, {
1825
+ x: task.x2 - task.handleWidth - 1,
1826
+ y: task.y + 1,
1827
+ width: task.handleWidth,
1828
+ height: handleHeight,
1829
+ barCornerRadius: task.barCornerRadius,
1830
+ onMouseDown: function onMouseDown(e) {
1831
+ onEventStart("end", task, e, "planned");
1832
+ }
1833
+ })), isProgressChangeable && React.createElement(BarProgressHandle, {
1834
+ progressPoint: progressPoint,
1835
+ onMouseDown: function onMouseDown(e) {
1836
+ onEventStart("progress", task, e, "planned");
1837
+ }
1838
+ })));else return React.createElement("g", {
1839
+ className: styles$6.barWrapper,
1840
+ tabIndex: 0
1841
+ });
1842
+ } else if (task.actualx1 && task.actualx2) {
1843
+ return React.createElement("g", {
1844
+ className: styles$6.barWrapper,
1845
+ tabIndex: 0
1846
+ }, React.createElement(BarDisplay, {
1847
+ x: task.actualx1,
1848
+ y: task.y + task.height / 2,
1849
+ type: type,
1850
+ startProgressWidth: task.progressStartWidth,
1851
+ endProgressWidth: task.progressEndWidth,
1852
+ width: task.actualx2 - task.actualx1,
1853
+ height: task.height / 2,
1854
+ progressX: task.progressX,
1855
+ progressWidth: task.progressWidth,
1856
+ barCornerRadius: task.barCornerRadius,
1857
+ styles: task.styles,
1858
+ isSelected: isSelected,
1859
+ onMouseDown: function onMouseDown(e) {
1860
+ isDateChangeable && onEventStart("move", task, e, "actual");
1861
+ }
1862
+ }), React.createElement("g", {
1863
+ className: "handleGroup"
1864
+ }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1865
+ x: task.actualx1 + 1,
1866
+ y: task.y + task.height / 2 + 1,
1867
+ width: task.handleWidth,
1868
+ height: handleHeight,
1869
+ barCornerRadius: task.barCornerRadius,
1870
+ onMouseDown: function onMouseDown(e) {
1871
+ onEventStart("start", task, e, "actual");
1872
+ }
1873
+ }), React.createElement(BarDateHandle, {
1874
+ x: task.actualx2 - task.handleWidth - 1,
1875
+ y: task.y + task.height / 2 + 1,
1876
+ width: task.handleWidth,
1877
+ height: handleHeight,
1878
+ barCornerRadius: task.barCornerRadius,
1879
+ onMouseDown: function onMouseDown(e) {
1880
+ onEventStart("end", task, e, "actual");
1881
+ }
1882
+ })), isProgressChangeable && React.createElement(BarProgressHandle, {
1883
+ progressPoint: progressPoint,
1884
+ onMouseDown: function onMouseDown(e) {
1885
+ onEventStart("progress", task, e, "actual");
1886
+ }
1887
+ })));
1888
+ } else {
1889
+ return React.createElement("g", {
1890
+ className: styles$6.barWrapper,
1891
+ tabIndex: 0
1892
+ });
1893
+ }
1870
1894
  };
1871
1895
 
1872
1896
  var BarSmall = function BarSmall(_ref) {
@@ -2014,11 +2038,23 @@ var TaskItem = function TaskItem(props) {
2014
2038
  break;
2015
2039
 
2016
2040
  default:
2017
- setTaskItem([React.createElement(Bar, Object.assign({}, props, {
2018
- type: "planned"
2019
- })), React.createElement(Bar, Object.assign({}, props, {
2020
- type: "actual"
2021
- }))]);
2041
+ {
2042
+ var _taskItem = [];
2043
+
2044
+ if (task.x1 && task.x2) {
2045
+ _taskItem.push(React.createElement(Bar, Object.assign({}, props, {
2046
+ type: "planned"
2047
+ })));
2048
+ }
2049
+
2050
+ if (task.actualx1 && task.actualx2) {
2051
+ _taskItem.push(React.createElement(Bar, Object.assign({}, props, {
2052
+ type: "actual"
2053
+ })));
2054
+ }
2055
+
2056
+ setTaskItem(_taskItem);
2057
+ }
2022
2058
  break;
2023
2059
  }
2024
2060
  }, [task, isSelected]);
@@ -2307,7 +2343,18 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2307
2343
  className: "content"
2308
2344
  }, React.createElement("g", {
2309
2345
  className: "arrows"
2310
- }, tasks.map(function (task) {
2346
+ }, tasks.map(function (_task) {
2347
+ var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
2348
+
2349
+ if (!task) {
2350
+ return React.createElement("g", {
2351
+ key: _task.id,
2352
+ style: {
2353
+ height: taskHeight
2354
+ }
2355
+ });
2356
+ }
2357
+
2311
2358
  return task.barChildren.map(function (child) {
2312
2359
  var _task$criticalPathArr, _task$criticalPathArr2;
2313
2360
 
@@ -2328,7 +2375,18 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2328
2375
  className: "bar",
2329
2376
  fontFamily: fontFamily,
2330
2377
  fontSize: fontSize
2331
- }, tasks.map(function (task) {
2378
+ }, tasks.map(function (_task) {
2379
+ var task = _task.start.getTime() > 0 && _task.end.getTime() > 0 ? _task : undefined;
2380
+
2381
+ if (!task) {
2382
+ return React.createElement("g", {
2383
+ key: _task.id,
2384
+ style: {
2385
+ height: taskHeight
2386
+ }
2387
+ });
2388
+ }
2389
+
2332
2390
  return React.createElement(TaskItem, {
2333
2391
  task: task,
2334
2392
  arrowIndent: arrowIndent,
@@ -2643,7 +2701,7 @@ var Gantt = function Gantt(_ref) {
2643
2701
  return t.id === changedTask.id;
2644
2702
  });
2645
2703
 
2646
- if (prevStateTask && (prevStateTask.start.getTime() !== changedTask.start.getTime() || prevStateTask.end.getTime() !== changedTask.end.getTime() || prevStateTask.actualStart.getTime() !== changedTask.actualStart.getTime() || prevStateTask.actualEnd.getTime() !== changedTask.actualEnd.getTime() || prevStateTask.progress !== changedTask.progress)) {
2704
+ if (prevStateTask && (prevStateTask.start.getTime() >= 0 && prevStateTask.start.getTime() !== changedTask.start.getTime() || prevStateTask.end.getTime() >= 0 && prevStateTask.end.getTime() !== changedTask.end.getTime() || (prevStateTask.actualStart.getTime() >= 0 && prevStateTask.actualStart.getTime()) !== changedTask.actualStart.getTime() || prevStateTask.actualEnd.getTime() >= 0 && prevStateTask.actualEnd.getTime() !== changedTask.actualEnd.getTime() || prevStateTask.progress !== changedTask.progress)) {
2647
2705
  var newTaskList = barTasks.map(function (t) {
2648
2706
  return t.id === changedTask.id ? changedTask : t;
2649
2707
  });