gantt-task-react-powern 0.3.12 → 0.4.1

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.
@@ -18,6 +18,10 @@ function _extends() {
18
18
  return _extends.apply(this, arguments);
19
19
  }
20
20
 
21
+ function _objectDestructuringEmpty(obj) {
22
+ if (obj == null) throw new TypeError("Cannot destructure undefined");
23
+ }
24
+
21
25
  function _unsupportedIterableToArray(o, minLen) {
22
26
  if (!o) return;
23
27
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -1150,15 +1154,25 @@ var convertToBarTask = function convertToBarTask(task, index, dates, columnWidth
1150
1154
  var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor) {
1151
1155
  var x1;
1152
1156
  var x2;
1157
+ var actualx1;
1158
+ var actualx2;
1159
+ var progressStartWidth;
1160
+ var progressEndWidth;
1153
1161
 
1154
1162
  if (rtl) {
1155
1163
  x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
1156
1164
  x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
1165
+ actualx1 = taskXCoordinateRTL(task.actualStart, dates, columnWidth);
1166
+ actualx2 = taskXCoordinateRTL(task.actualEnd, dates, columnWidth);
1157
1167
  } else {
1158
1168
  x1 = taskXCoordinate(task.start, dates, columnWidth);
1159
1169
  x2 = taskXCoordinate(task.end, dates, columnWidth);
1170
+ actualx1 = taskXCoordinate(task.actualStart, dates, columnWidth);
1171
+ actualx2 = taskXCoordinate(task.actualEnd, dates, columnWidth);
1160
1172
  }
1161
1173
 
1174
+ progressStartWidth = Math.abs(actualx1 - x1);
1175
+ progressEndWidth = Math.abs(actualx2 - x2);
1162
1176
  var typeInternal = task.type;
1163
1177
 
1164
1178
  if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
@@ -1166,7 +1180,7 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1166
1180
  x2 = x1 + handleWidth * 2;
1167
1181
  }
1168
1182
 
1169
- var _progressWithByParams = progressWithByParams(x1, x2, task.progress, rtl),
1183
+ var _progressWithByParams = progressWithByParams(actualx1, actualx2, task.progress, rtl),
1170
1184
  progressWidth = _progressWithByParams[0],
1171
1185
  progressX = _progressWithByParams[1];
1172
1186
 
@@ -1184,6 +1198,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1184
1198
  typeInternal: typeInternal,
1185
1199
  x1: x1,
1186
1200
  x2: x2,
1201
+ actualx1: actualx1,
1202
+ actualx2: actualx2,
1203
+ progressStartWidth: progressStartWidth,
1204
+ progressEndWidth: progressEndWidth,
1187
1205
  y: y,
1188
1206
  index: index,
1189
1207
  progressX: progressX,
@@ -1215,6 +1233,10 @@ var convertToMilestone = function convertToMilestone(task, index, dates, columnW
1215
1233
  end: task.start,
1216
1234
  x1: x1,
1217
1235
  x2: x2,
1236
+ actualx1: x1,
1237
+ actualx2: x2,
1238
+ progressStartWidth: 0,
1239
+ progressEndWidth: 0,
1218
1240
  y: y,
1219
1241
  index: index,
1220
1242
  progressX: 0,
@@ -1231,9 +1253,11 @@ var convertToMilestone = function convertToMilestone(task, index, dates, columnW
1231
1253
  };
1232
1254
 
1233
1255
  var taskXCoordinate = function taskXCoordinate(xDate, dates, columnWidth) {
1256
+ console.log(dates);
1234
1257
  var index = dates.findIndex(function (d) {
1235
1258
  return d.getTime() >= xDate.getTime();
1236
1259
  }) - 1;
1260
+ console.log(index);
1237
1261
  var remainderMillis = xDate.getTime() - dates[index].getTime();
1238
1262
  var percentOfInterval = remainderMillis / (dates[index + 1].getTime() - dates[index].getTime());
1239
1263
  var x = index * columnWidth + percentOfInterval * columnWidth;
@@ -1538,6 +1562,8 @@ var styles$6 = {"barWrapper":"_KxSXS","barHandle":"_3w_5u","barBackground":"_31E
1538
1562
  var BarDisplay = function BarDisplay(_ref) {
1539
1563
  var x = _ref.x,
1540
1564
  y = _ref.y,
1565
+ actualX1 = _ref.actualX1,
1566
+ actualX2 = _ref.actualX2,
1541
1567
  width = _ref.width,
1542
1568
  height = _ref.height,
1543
1569
  isSelected = _ref.isSelected,
@@ -1561,16 +1587,24 @@ var BarDisplay = function BarDisplay(_ref) {
1561
1587
  x: x,
1562
1588
  width: width,
1563
1589
  y: y,
1564
- height: height,
1590
+ height: height / 2,
1565
1591
  ry: barCornerRadius,
1566
1592
  rx: barCornerRadius,
1567
1593
  fill: getBarColor(),
1568
1594
  className: styles$6.barBackground
1595
+ }), React.createElement("rect", {
1596
+ x: actualX1,
1597
+ width: actualX2 - actualX1,
1598
+ y: y + height / 2,
1599
+ height: height / 2,
1600
+ ry: barCornerRadius,
1601
+ rx: barCornerRadius,
1602
+ fill: styles.taskProgressColor
1569
1603
  }), React.createElement("rect", {
1570
1604
  x: progressX,
1571
1605
  width: progressWidth,
1572
- y: y,
1573
- height: height,
1606
+ y: y + height / 2,
1607
+ height: height / 2,
1574
1608
  ry: barCornerRadius,
1575
1609
  rx: barCornerRadius,
1576
1610
  fill: getProcessColor()
@@ -1597,13 +1631,9 @@ var BarDateHandle = function BarDateHandle(_ref) {
1597
1631
  };
1598
1632
 
1599
1633
  var BarProgressHandle = function BarProgressHandle(_ref) {
1600
- var progressPoint = _ref.progressPoint,
1601
- onMouseDown = _ref.onMouseDown;
1602
- return React.createElement("polygon", {
1603
- className: styles$6.barHandle,
1604
- points: progressPoint,
1605
- onMouseDown: onMouseDown
1606
- });
1634
+ _objectDestructuringEmpty(_ref);
1635
+
1636
+ return React.createElement("div", null);
1607
1637
  };
1608
1638
 
1609
1639
  var Bar = function Bar(_ref) {
@@ -1621,6 +1651,10 @@ var Bar = function Bar(_ref) {
1621
1651
  }, React.createElement(BarDisplay, {
1622
1652
  x: task.x1,
1623
1653
  y: task.y,
1654
+ actualX1: task.actualx1,
1655
+ actualX2: task.actualx2,
1656
+ startProgressWidth: task.progressStartWidth,
1657
+ endProgressWidth: task.progressEndWidth,
1624
1658
  width: task.x2 - task.x1,
1625
1659
  height: task.height,
1626
1660
  progressX: task.progressX,
@@ -1672,6 +1706,10 @@ var BarSmall = function BarSmall(_ref) {
1672
1706
  }, React.createElement(BarDisplay, {
1673
1707
  x: task.x1,
1674
1708
  y: task.y,
1709
+ actualX1: task.actualx1,
1710
+ actualX2: task.actualx2,
1711
+ startProgressWidth: task.progressStartWidth,
1712
+ endProgressWidth: task.progressEndWidth,
1675
1713
  width: task.x2 - task.x1,
1676
1714
  height: task.height,
1677
1715
  progressX: task.progressX,
@@ -1774,28 +1812,17 @@ var Project = function Project(_ref) {
1774
1812
  }));
1775
1813
  };
1776
1814
 
1777
- var style = {"barLabel":"_3zRJQ","barLabelOutside":"_3KcaM"};
1778
-
1779
1815
  var TaskItem = function TaskItem(props) {
1780
1816
  var _props = _extends({}, props),
1781
1817
  task = _props.task,
1782
- arrowIndent = _props.arrowIndent,
1783
1818
  isDelete = _props.isDelete,
1784
- taskHeight = _props.taskHeight,
1785
1819
  isSelected = _props.isSelected,
1786
- rtl = _props.rtl,
1787
1820
  onEventStart = _props.onEventStart;
1788
1821
 
1789
- var textRef = useRef(null);
1790
-
1791
1822
  var _useState = useState(React.createElement("div", null)),
1792
1823
  taskItem = _useState[0],
1793
1824
  setTaskItem = _useState[1];
1794
1825
 
1795
- var _useState2 = useState(true),
1796
- isTextInside = _useState2[0],
1797
- setIsTextInside = _useState2[1];
1798
-
1799
1826
  useEffect(function () {
1800
1827
  switch (task.typeInternal) {
1801
1828
  case "milestone":
@@ -1815,27 +1842,6 @@ var TaskItem = function TaskItem(props) {
1815
1842
  break;
1816
1843
  }
1817
1844
  }, [task, isSelected]);
1818
- useEffect(function () {
1819
- if (textRef.current) {
1820
- setIsTextInside(textRef.current.getBBox().width < task.x2 - task.x1);
1821
- }
1822
- }, [textRef, task]);
1823
-
1824
- var getX = function getX() {
1825
- var width = task.x2 - task.x1;
1826
- var hasChild = task.barChildren.length > 0;
1827
-
1828
- if (isTextInside) {
1829
- return task.x1 + width * 0.5;
1830
- }
1831
-
1832
- if (rtl && textRef.current) {
1833
- return task.x1 - textRef.current.getBBox().width - arrowIndent * +hasChild - arrowIndent * 0.2;
1834
- } else {
1835
- return task.x1 + width + arrowIndent * +hasChild + arrowIndent * 0.2;
1836
- }
1837
- };
1838
-
1839
1845
  return React.createElement("g", {
1840
1846
  onKeyDown: function onKeyDown(e) {
1841
1847
  switch (e.key) {
@@ -1863,12 +1869,7 @@ var TaskItem = function TaskItem(props) {
1863
1869
  onFocus: function onFocus() {
1864
1870
  onEventStart("select", task);
1865
1871
  }
1866
- }, taskItem, React.createElement("text", {
1867
- x: getX(),
1868
- y: task.y + taskHeight * 0.5,
1869
- className: isTextInside ? style.barLabel : style.barLabelOutside,
1870
- ref: textRef
1871
- }, task.name));
1872
+ }, taskItem);
1872
1873
  };
1873
1874
 
1874
1875
  var TaskGanttContent = function TaskGanttContent(_ref) {