gantt-task-react-powern 0.4.50 → 0.4.52

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,27 +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 _tasks$, _tasks$2;
108
+ var _tasks$, _tasks$2, _tasks$3, _tasks$4;
109
109
 
110
- var newStartDate = ((_tasks$ = tasks[0]) === null || _tasks$ === void 0 ? void 0 : _tasks$.start) || new Date();
111
- var newEndDate = ((_tasks$2 = tasks[0]) === null || _tasks$2 === void 0 ? void 0 : _tasks$2.start) || new Date();
110
+ var newStartDate = ((_tasks$ = tasks[0]) === null || _tasks$ === void 0 ? void 0 : _tasks$.start.getTime()) !== 0 ? ((_tasks$2 = tasks[0]) === null || _tasks$2 === void 0 ? void 0 : _tasks$2.start) || new Date() : new Date();
111
+ var newEndDate = ((_tasks$3 = tasks[0]) === null || _tasks$3 === void 0 ? void 0 : _tasks$3.end.getTime()) !== 0 ? ((_tasks$4 = tasks[0]) === null || _tasks$4 === void 0 ? void 0 : _tasks$4.end) || new Date() : new Date();
112
112
 
113
113
  for (var _iterator = _createForOfIteratorHelperLoose(tasks), _step; !(_step = _iterator()).done;) {
114
114
  var task = _step.value;
115
115
 
116
- if (task.start < newStartDate) {
116
+ if (task.start && task.start.getTime() !== 0 && task.start < newStartDate) {
117
117
  newStartDate = task.start;
118
118
  }
119
119
 
120
- if (task.end > newEndDate) {
120
+ if (task.end && task.end.getTime() !== 0 && task.end > newEndDate) {
121
121
  newEndDate = task.end;
122
122
  }
123
123
 
124
- if (task.actualStart < newStartDate) {
124
+ if (task.actualStart && task.actualStart.getTime() !== 0 && task.actualStart < newStartDate) {
125
125
  newStartDate = task.actualStart;
126
126
  }
127
127
 
128
- if (task.actualEnd > newEndDate) {
128
+ if (task.actualEnd && task.actualEnd.getTime() !== 0 && task.actualEnd > newEndDate) {
129
129
  newEndDate = task.actualEnd;
130
130
  }
131
131
  }
@@ -347,6 +347,7 @@ var localeDateStringCache = {};
347
347
 
348
348
  var toLocaleDateStringFactory = function toLocaleDateStringFactory(locale) {
349
349
  return function (date, dateTimeOptions) {
350
+ if (!date || date.getTime() === 0) return "";
350
351
  var key = date.toString();
351
352
  var lds = localeDateStringCache[key];
352
353
 
@@ -1211,8 +1212,16 @@ var Arrow = function Arrow(_ref) {
1211
1212
  };
1212
1213
 
1213
1214
  var drownPathAndTriangle = function drownPathAndTriangle(taskFrom, taskTo, rowHeight, taskHeight, arrowIndent) {
1214
- var taskToStart = Math.min(taskTo.x1, taskTo.actualx1);
1215
- 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
+
1216
1225
  var indexCompare = taskFrom.index > taskTo.index ? -1 : 1;
1217
1226
  var taskToEndPosition = taskTo.y + taskHeight / 2;
1218
1227
  var taskFromEndPosition = taskFromEnd + arrowIndent * 2;
@@ -1286,26 +1295,21 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1286
1295
  var progressEndWidth;
1287
1296
 
1288
1297
  if (rtl) {
1289
- x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
1290
- x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
1291
- actualx1 = taskXCoordinateRTL(task.actualStart, dates, columnWidth);
1292
- 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;
1293
1302
  } else {
1294
- x1 = taskXCoordinate(task.start, dates, columnWidth);
1295
- x2 = taskXCoordinate(task.end, dates, columnWidth);
1296
- actualx1 = taskXCoordinate(task.actualStart, dates, columnWidth);
1297
- 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;
1298
1307
  }
1299
1308
 
1300
- progressStartWidth = Math.abs(actualx1 - x1);
1301
- progressEndWidth = Math.abs(actualx2 - x2);
1309
+ progressStartWidth = actualx1 && x1 ? Math.abs(actualx1 - x1) : -1;
1310
+ progressEndWidth = actualx2 && x2 ? Math.abs(actualx2 - x2) : -1;
1302
1311
  var typeInternal = task.type;
1303
1312
 
1304
- if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
1305
- typeInternal = "smalltask";
1306
- x2 = x1 + handleWidth * 2;
1307
- }
1308
-
1309
1313
  var _progressWithByParams = progressWithByParams(actualx1, actualx2, task.progress, rtl),
1310
1314
  progressWidth = _progressWithByParams[0],
1311
1315
  progressX = _progressWithByParams[1];
@@ -1342,10 +1346,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1342
1346
  };
1343
1347
 
1344
1348
  var convertToMilestone = function convertToMilestone(task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, milestoneBackgroundColor, milestoneBackgroundSelectedColor) {
1345
- var x = taskXCoordinate(task.start, dates, columnWidth);
1349
+ var x = task.start && task.end ? taskXCoordinate(task.start, dates, columnWidth) : 0;
1346
1350
  var y = taskYCoordinate(index, rowHeight, taskHeight);
1347
- var x1 = x - taskHeight * 0.5;
1348
- 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;
1349
1353
  var rotatedHeight = taskHeight / 1.414;
1350
1354
 
1351
1355
  var styles = _extends({
@@ -1382,6 +1386,11 @@ var taskXCoordinate = function taskXCoordinate(xDate, dates, columnWidth) {
1382
1386
  var index = dates.findIndex(function (d) {
1383
1387
  return d.getTime() >= xDate.getTime();
1384
1388
  }) - 1;
1389
+
1390
+ if (index < 0) {
1391
+ return 0;
1392
+ }
1393
+
1385
1394
  var remainderMillis = xDate.getTime() - dates[index].getTime();
1386
1395
  var percentOfInterval = remainderMillis / (dates[index + 1].getTime() - dates[index].getTime());
1387
1396
  var x = index * columnWidth + percentOfInterval * columnWidth;
@@ -1400,13 +1409,13 @@ var taskYCoordinate = function taskYCoordinate(index, rowHeight, taskHeight) {
1400
1409
  };
1401
1410
 
1402
1411
  var progressWithByParams = function progressWithByParams(taskX1, taskX2, progress, rtl) {
1403
- var progressWidth = (taskX2 - taskX1) * progress * 0.01;
1412
+ var progressWidth = taskX2 > 0 && taskX1 > 0 ? (taskX2 - taskX1) * progress * 0.01 : 0;
1404
1413
  var progressX;
1405
1414
 
1406
1415
  if (rtl) {
1407
- progressX = taskX2 - progressWidth;
1416
+ progressX = taskX2 > 0 ? taskX2 - progressWidth : 0;
1408
1417
  } else {
1409
- progressX = taskX1;
1418
+ progressX = taskX1 > 0 ? taskX1 : 0;
1410
1419
  }
1411
1420
 
1412
1421
  return [progressWidth, progressX];
@@ -1780,95 +1789,108 @@ var Bar = function Bar(_ref) {
1780
1789
  isSelected = _ref.isSelected;
1781
1790
  var progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
1782
1791
  var handleHeight = task.height / 2 - 1;
1783
- if (type == "planned") return React.createElement("g", {
1784
- className: styles$6.barWrapper,
1785
- tabIndex: 0
1786
- }, React.createElement(BarDisplay, {
1787
- x: task.x1,
1788
- y: task.y,
1789
- type: type,
1790
- startProgressWidth: task.progressStartWidth,
1791
- endProgressWidth: task.progressEndWidth,
1792
- width: task.x2 - task.x1,
1793
- height: task.height / 2,
1794
- progressX: task.progressX,
1795
- progressWidth: task.progressWidth,
1796
- barCornerRadius: task.barCornerRadius,
1797
- styles: task.styles,
1798
- isSelected: isSelected,
1799
- onMouseDown: function onMouseDown(e) {
1800
- isDateChangeable && onEventStart("move", task, e, "planned");
1801
- }
1802
- }), React.createElement("g", {
1803
- className: "handleGroup"
1804
- }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1805
- x: task.x1 + 1,
1806
- y: task.y + 1,
1807
- width: task.handleWidth,
1808
- height: handleHeight,
1809
- barCornerRadius: task.barCornerRadius,
1810
- onMouseDown: function onMouseDown(e) {
1811
- onEventStart("start", task, e, "planned");
1812
- }
1813
- }), React.createElement(BarDateHandle, {
1814
- x: task.x2 - task.handleWidth - 1,
1815
- y: task.y + 1,
1816
- width: task.handleWidth,
1817
- height: handleHeight,
1818
- barCornerRadius: task.barCornerRadius,
1819
- onMouseDown: function onMouseDown(e) {
1820
- onEventStart("end", task, e, "planned");
1821
- }
1822
- })), isProgressChangeable && React.createElement(BarProgressHandle, {
1823
- progressPoint: progressPoint,
1824
- onMouseDown: function onMouseDown(e) {
1825
- onEventStart("progress", task, e, "planned");
1826
- }
1827
- })));else return React.createElement("g", {
1828
- className: styles$6.barWrapper,
1829
- tabIndex: 0
1830
- }, React.createElement(BarDisplay, {
1831
- x: task.actualx1,
1832
- y: task.y + task.height / 2,
1833
- type: type,
1834
- startProgressWidth: task.progressStartWidth,
1835
- endProgressWidth: task.progressEndWidth,
1836
- width: task.actualx2 - task.actualx1,
1837
- height: task.height / 2,
1838
- progressX: task.progressX,
1839
- progressWidth: task.progressWidth,
1840
- barCornerRadius: task.barCornerRadius,
1841
- styles: task.styles,
1842
- isSelected: isSelected,
1843
- onMouseDown: function onMouseDown(e) {
1844
- isDateChangeable && onEventStart("move", task, e, "actual");
1845
- }
1846
- }), React.createElement("g", {
1847
- className: "handleGroup"
1848
- }, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
1849
- x: task.actualx1 + 1,
1850
- y: task.y + task.height / 2 + 1,
1851
- width: task.handleWidth,
1852
- height: handleHeight,
1853
- barCornerRadius: task.barCornerRadius,
1854
- onMouseDown: function onMouseDown(e) {
1855
- onEventStart("start", task, e, "actual");
1856
- }
1857
- }), React.createElement(BarDateHandle, {
1858
- x: task.actualx2 - task.handleWidth - 1,
1859
- y: task.y + task.height / 2 + 1,
1860
- width: task.handleWidth,
1861
- height: handleHeight,
1862
- barCornerRadius: task.barCornerRadius,
1863
- onMouseDown: function onMouseDown(e) {
1864
- onEventStart("end", task, e, "actual");
1865
- }
1866
- })), isProgressChangeable && React.createElement(BarProgressHandle, {
1867
- progressPoint: progressPoint,
1868
- onMouseDown: function onMouseDown(e) {
1869
- onEventStart("progress", task, e, "actual");
1870
- }
1871
- })));
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
+ }
1872
1894
  };
1873
1895
 
1874
1896
  var BarSmall = function BarSmall(_ref) {
@@ -2016,11 +2038,23 @@ var TaskItem = function TaskItem(props) {
2016
2038
  break;
2017
2039
 
2018
2040
  default:
2019
- setTaskItem([React.createElement(Bar, Object.assign({}, props, {
2020
- type: "planned"
2021
- })), React.createElement(Bar, Object.assign({}, props, {
2022
- type: "actual"
2023
- }))]);
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
+ }
2024
2058
  break;
2025
2059
  }
2026
2060
  }, [task, isSelected]);
@@ -2309,7 +2343,18 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2309
2343
  className: "content"
2310
2344
  }, React.createElement("g", {
2311
2345
  className: "arrows"
2312
- }, 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
+
2313
2358
  return task.barChildren.map(function (child) {
2314
2359
  var _task$criticalPathArr, _task$criticalPathArr2;
2315
2360
 
@@ -2330,7 +2375,18 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
2330
2375
  className: "bar",
2331
2376
  fontFamily: fontFamily,
2332
2377
  fontSize: fontSize
2333
- }, 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
+
2334
2390
  return React.createElement(TaskItem, {
2335
2391
  task: task,
2336
2392
  arrowIndent: arrowIndent,
@@ -2645,7 +2701,7 @@ var Gantt = function Gantt(_ref) {
2645
2701
  return t.id === changedTask.id;
2646
2702
  });
2647
2703
 
2648
- 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)) {
2649
2705
  var newTaskList = barTasks.map(function (t) {
2650
2706
  return t.id === changedTask.id ? changedTask : t;
2651
2707
  });