gantt-task-react-powern 0.3.11 → 0.4.0

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.
@@ -2,6 +2,10 @@ import React from "react";
2
2
  declare type BarDisplayProps = {
3
3
  x: number;
4
4
  y: number;
5
+ actualX1: number;
6
+ actualX2: number;
7
+ startProgressWidth: number;
8
+ endProgressWidth: number;
5
9
  width: number;
6
10
  height: number;
7
11
  isSelected: boolean;
@@ -9,6 +13,7 @@ declare type BarDisplayProps = {
9
13
  progressWidth: number;
10
14
  barCornerRadius: number;
11
15
  styles: {
16
+ taskProgressColor?: string;
12
17
  backgroundColor: string;
13
18
  backgroundSelectedColor: string;
14
19
  progressColor: string;
@@ -10,4 +10,5 @@ export declare const TaskListTableDefault: React.FC<{
10
10
  selectedTaskId: string;
11
11
  setSelectedTask: (taskId: string) => void;
12
12
  onExpanderClick: (task: Task) => void;
13
+ taskLabelRenderer?: (Task: Task) => React.ReactNode;
13
14
  }>;
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { EventOption } from "../../types/public-types";
2
3
  import { BarTask } from "../../types/bar-task";
3
4
  import { Task } from "../../types/public-types";
4
5
  export declare type TaskListProps = {
@@ -16,6 +17,7 @@ export declare type TaskListProps = {
16
17
  selectedTask: BarTask | undefined;
17
18
  setSelectedTask: (task: string) => void;
18
19
  onExpanderClick: (task: Task) => void;
20
+ taskLabelRenderer?: (Task: Task) => React.ReactNode;
19
21
  TaskListHeader: React.FC<{
20
22
  headerHeight: number;
21
23
  rowWidth: string;
@@ -32,6 +34,7 @@ export declare type TaskListProps = {
32
34
  selectedTaskId: string;
33
35
  setSelectedTask: (taskId: string) => void;
34
36
  onExpanderClick: (task: Task) => void;
37
+ taskLabelRenderer?: (Task: Task) => React.ReactNode;
35
38
  }>;
36
- };
39
+ } & EventOption;
37
40
  export declare const TaskList: React.FC<TaskListProps>;
package/dist/index.css CHANGED
@@ -231,30 +231,6 @@
231
231
  user-select: none;
232
232
  }
233
233
 
234
- ._3zRJQ {
235
- fill: #fff;
236
- text-anchor: middle;
237
- font-weight: lighter;
238
- dominant-baseline: central;
239
- -webkit-touch-callout: none;
240
- -webkit-user-select: none;
241
- -moz-user-select: none;
242
- -ms-user-select: none;
243
- user-select: none;
244
- pointer-events: none;
245
- }
246
-
247
- ._3KcaM {
248
- fill: #555;
249
- text-anchor: start;
250
- -webkit-touch-callout: none;
251
- -webkit-user-select: none;
252
- -moz-user-select: none;
253
- -ms-user-select: none;
254
- user-select: none;
255
- pointer-events: none;
256
- }
257
-
258
234
  ._CZjuD {
259
235
  overflow: hidden;
260
236
  font-size: 0;
package/dist/index.js CHANGED
@@ -21,6 +21,10 @@ function _extends() {
21
21
  return _extends.apply(this, arguments);
22
22
  }
23
23
 
24
+ function _objectDestructuringEmpty(obj) {
25
+ if (obj == null) throw new TypeError("Cannot destructure undefined");
26
+ }
27
+
24
28
  function _unsupportedIterableToArray(o, minLen) {
25
29
  if (!o) return;
26
30
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -343,7 +347,11 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
343
347
  fontFamily = _ref.fontFamily,
344
348
  fontSize = _ref.fontSize,
345
349
  locale = _ref.locale,
346
- onExpanderClick = _ref.onExpanderClick;
350
+ onExpanderClick = _ref.onExpanderClick,
351
+ _ref$taskLabelRendere = _ref.taskLabelRenderer,
352
+ taskLabelRenderer = _ref$taskLabelRendere === void 0 ? function (t) {
353
+ return " " + t.name;
354
+ } : _ref$taskLabelRendere;
347
355
  var toLocaleDateString = React.useMemo(function () {
348
356
  return toLocaleDateStringFactory(locale);
349
357
  }, [locale]);
@@ -388,7 +396,7 @@ var TaskListTableDefault = function TaskListTableDefault(_ref) {
388
396
  minWidth: rowWidth,
389
397
  maxWidth: rowWidth
390
398
  }
391
- }, "\xA0", t.name), React__default.createElement("div", {
399
+ }, taskLabelRenderer(t)), React__default.createElement("div", {
392
400
  className: styles$1.taskListCell,
393
401
  style: {
394
402
  minWidth: rowWidth,
@@ -560,7 +568,8 @@ var TaskList = function TaskList(_ref) {
560
568
  taskListRef = _ref.taskListRef,
561
569
  horizontalContainerClass = _ref.horizontalContainerClass,
562
570
  TaskListHeader = _ref.TaskListHeader,
563
- TaskListTable = _ref.TaskListTable;
571
+ TaskListTable = _ref.TaskListTable,
572
+ taskLabelRenderer = _ref.taskLabelRenderer;
564
573
  var horizontalContainerRef = React.useRef(null);
565
574
  React.useEffect(function () {
566
575
  if (horizontalContainerRef.current) {
@@ -583,7 +592,8 @@ var TaskList = function TaskList(_ref) {
583
592
  locale: locale,
584
593
  selectedTaskId: selectedTaskId,
585
594
  setSelectedTask: setSelectedTask,
586
- onExpanderClick: onExpanderClick
595
+ onExpanderClick: onExpanderClick,
596
+ taskLabelRenderer: taskLabelRenderer
587
597
  };
588
598
  return React__default.createElement("div", {
589
599
  ref: taskListRef
@@ -1145,15 +1155,25 @@ var convertToBarTask = function convertToBarTask(task, index, dates, columnWidth
1145
1155
  var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor) {
1146
1156
  var x1;
1147
1157
  var x2;
1158
+ var actualx1;
1159
+ var actualx2;
1160
+ var progressStartWidth;
1161
+ var progressEndWidth;
1148
1162
 
1149
1163
  if (rtl) {
1150
1164
  x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
1151
1165
  x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
1166
+ actualx1 = taskXCoordinateRTL(task.actualStart, dates, columnWidth);
1167
+ actualx2 = taskXCoordinateRTL(task.actualEnd, dates, columnWidth);
1152
1168
  } else {
1153
1169
  x1 = taskXCoordinate(task.start, dates, columnWidth);
1154
1170
  x2 = taskXCoordinate(task.end, dates, columnWidth);
1171
+ actualx1 = taskXCoordinate(task.actualStart, dates, columnWidth);
1172
+ actualx2 = taskXCoordinate(task.actualEnd, dates, columnWidth);
1155
1173
  }
1156
1174
 
1175
+ progressStartWidth = Math.abs(actualx1 - x1);
1176
+ progressEndWidth = Math.abs(actualx2 - x2);
1157
1177
  var typeInternal = task.type;
1158
1178
 
1159
1179
  if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
@@ -1161,7 +1181,7 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1161
1181
  x2 = x1 + handleWidth * 2;
1162
1182
  }
1163
1183
 
1164
- var _progressWithByParams = progressWithByParams(x1, x2, task.progress, rtl),
1184
+ var _progressWithByParams = progressWithByParams(actualx1, actualx2, task.progress, rtl),
1165
1185
  progressWidth = _progressWithByParams[0],
1166
1186
  progressX = _progressWithByParams[1];
1167
1187
 
@@ -1179,6 +1199,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
1179
1199
  typeInternal: typeInternal,
1180
1200
  x1: x1,
1181
1201
  x2: x2,
1202
+ actualx1: actualx1,
1203
+ actualx2: actualx2,
1204
+ progressStartWidth: progressStartWidth,
1205
+ progressEndWidth: progressEndWidth,
1182
1206
  y: y,
1183
1207
  index: index,
1184
1208
  progressX: progressX,
@@ -1210,6 +1234,10 @@ var convertToMilestone = function convertToMilestone(task, index, dates, columnW
1210
1234
  end: task.start,
1211
1235
  x1: x1,
1212
1236
  x2: x2,
1237
+ actualx1: x1,
1238
+ actualx2: x2,
1239
+ progressStartWidth: 0,
1240
+ progressEndWidth: 0,
1213
1241
  y: y,
1214
1242
  index: index,
1215
1243
  progressX: 0,
@@ -1533,6 +1561,8 @@ var styles$6 = {"barWrapper":"_KxSXS","barHandle":"_3w_5u","barBackground":"_31E
1533
1561
  var BarDisplay = function BarDisplay(_ref) {
1534
1562
  var x = _ref.x,
1535
1563
  y = _ref.y,
1564
+ actualX1 = _ref.actualX1,
1565
+ actualX2 = _ref.actualX2,
1536
1566
  width = _ref.width,
1537
1567
  height = _ref.height,
1538
1568
  isSelected = _ref.isSelected,
@@ -1556,16 +1586,24 @@ var BarDisplay = function BarDisplay(_ref) {
1556
1586
  x: x,
1557
1587
  width: width,
1558
1588
  y: y,
1559
- height: height,
1589
+ height: height / 2,
1560
1590
  ry: barCornerRadius,
1561
1591
  rx: barCornerRadius,
1562
1592
  fill: getBarColor(),
1563
1593
  className: styles$6.barBackground
1594
+ }), React__default.createElement("rect", {
1595
+ x: actualX1,
1596
+ width: actualX2 - actualX1,
1597
+ y: y + height / 2,
1598
+ height: height / 2,
1599
+ ry: barCornerRadius,
1600
+ rx: barCornerRadius,
1601
+ fill: styles.taskProgressColor
1564
1602
  }), React__default.createElement("rect", {
1565
1603
  x: progressX,
1566
1604
  width: progressWidth,
1567
- y: y,
1568
- height: height,
1605
+ y: y + height / 2,
1606
+ height: height / 2,
1569
1607
  ry: barCornerRadius,
1570
1608
  rx: barCornerRadius,
1571
1609
  fill: getProcessColor()
@@ -1592,13 +1630,9 @@ var BarDateHandle = function BarDateHandle(_ref) {
1592
1630
  };
1593
1631
 
1594
1632
  var BarProgressHandle = function BarProgressHandle(_ref) {
1595
- var progressPoint = _ref.progressPoint,
1596
- onMouseDown = _ref.onMouseDown;
1597
- return React__default.createElement("polygon", {
1598
- className: styles$6.barHandle,
1599
- points: progressPoint,
1600
- onMouseDown: onMouseDown
1601
- });
1633
+ _objectDestructuringEmpty(_ref);
1634
+
1635
+ return React__default.createElement("div", null);
1602
1636
  };
1603
1637
 
1604
1638
  var Bar = function Bar(_ref) {
@@ -1616,6 +1650,10 @@ var Bar = function Bar(_ref) {
1616
1650
  }, React__default.createElement(BarDisplay, {
1617
1651
  x: task.x1,
1618
1652
  y: task.y,
1653
+ actualX1: task.actualx1,
1654
+ actualX2: task.actualx2,
1655
+ startProgressWidth: task.progressStartWidth,
1656
+ endProgressWidth: task.progressEndWidth,
1619
1657
  width: task.x2 - task.x1,
1620
1658
  height: task.height,
1621
1659
  progressX: task.progressX,
@@ -1667,6 +1705,10 @@ var BarSmall = function BarSmall(_ref) {
1667
1705
  }, React__default.createElement(BarDisplay, {
1668
1706
  x: task.x1,
1669
1707
  y: task.y,
1708
+ actualX1: task.actualx1,
1709
+ actualX2: task.actualx2,
1710
+ startProgressWidth: task.progressStartWidth,
1711
+ endProgressWidth: task.progressEndWidth,
1670
1712
  width: task.x2 - task.x1,
1671
1713
  height: task.height,
1672
1714
  progressX: task.progressX,
@@ -1769,28 +1811,17 @@ var Project = function Project(_ref) {
1769
1811
  }));
1770
1812
  };
1771
1813
 
1772
- var style = {"barLabel":"_3zRJQ","barLabelOutside":"_3KcaM"};
1773
-
1774
1814
  var TaskItem = function TaskItem(props) {
1775
1815
  var _props = _extends({}, props),
1776
1816
  task = _props.task,
1777
- arrowIndent = _props.arrowIndent,
1778
1817
  isDelete = _props.isDelete,
1779
- taskHeight = _props.taskHeight,
1780
1818
  isSelected = _props.isSelected,
1781
- rtl = _props.rtl,
1782
1819
  onEventStart = _props.onEventStart;
1783
1820
 
1784
- var textRef = React.useRef(null);
1785
-
1786
1821
  var _useState = React.useState(React__default.createElement("div", null)),
1787
1822
  taskItem = _useState[0],
1788
1823
  setTaskItem = _useState[1];
1789
1824
 
1790
- var _useState2 = React.useState(true),
1791
- isTextInside = _useState2[0],
1792
- setIsTextInside = _useState2[1];
1793
-
1794
1825
  React.useEffect(function () {
1795
1826
  switch (task.typeInternal) {
1796
1827
  case "milestone":
@@ -1810,27 +1841,6 @@ var TaskItem = function TaskItem(props) {
1810
1841
  break;
1811
1842
  }
1812
1843
  }, [task, isSelected]);
1813
- React.useEffect(function () {
1814
- if (textRef.current) {
1815
- setIsTextInside(textRef.current.getBBox().width < task.x2 - task.x1);
1816
- }
1817
- }, [textRef, task]);
1818
-
1819
- var getX = function getX() {
1820
- var width = task.x2 - task.x1;
1821
- var hasChild = task.barChildren.length > 0;
1822
-
1823
- if (isTextInside) {
1824
- return task.x1 + width * 0.5;
1825
- }
1826
-
1827
- if (rtl && textRef.current) {
1828
- return task.x1 - textRef.current.getBBox().width - arrowIndent * +hasChild - arrowIndent * 0.2;
1829
- } else {
1830
- return task.x1 + width + arrowIndent * +hasChild + arrowIndent * 0.2;
1831
- }
1832
- };
1833
-
1834
1844
  return React__default.createElement("g", {
1835
1845
  onKeyDown: function onKeyDown(e) {
1836
1846
  switch (e.key) {
@@ -1858,12 +1868,7 @@ var TaskItem = function TaskItem(props) {
1858
1868
  onFocus: function onFocus() {
1859
1869
  onEventStart("select", task);
1860
1870
  }
1861
- }, taskItem, React__default.createElement("text", {
1862
- x: getX(),
1863
- y: task.y + taskHeight * 0.5,
1864
- className: isTextInside ? style.barLabel : style.barLabelOutside,
1865
- ref: textRef
1866
- }, task.name));
1871
+ }, taskItem);
1867
1872
  };
1868
1873
 
1869
1874
  var TaskGanttContent = function TaskGanttContent(_ref) {
@@ -2286,7 +2291,8 @@ var Gantt = function Gantt(_ref) {
2286
2291
  onClick = _ref.onClick,
2287
2292
  onDelete = _ref.onDelete,
2288
2293
  onSelect = _ref.onSelect,
2289
- onExpanderClick = _ref.onExpanderClick;
2294
+ onExpanderClick = _ref.onExpanderClick,
2295
+ taskLabelRenderer = _ref.taskLabelRenderer;
2290
2296
  var wrapperRef = React.useRef(null);
2291
2297
  var taskListRef = React.useRef(null);
2292
2298
 
@@ -2658,8 +2664,10 @@ var Gantt = function Gantt(_ref) {
2658
2664
  taskListRef: taskListRef,
2659
2665
  setSelectedTask: handleSelectedTask,
2660
2666
  onExpanderClick: handleExpanderClick,
2667
+ onDoubleClick: onDoubleClick,
2661
2668
  TaskListHeader: TaskListHeader,
2662
- TaskListTable: TaskListTable
2669
+ TaskListTable: TaskListTable,
2670
+ taskLabelRenderer: taskLabelRenderer
2663
2671
  };
2664
2672
  return React__default.createElement("div", null, React__default.createElement("div", {
2665
2673
  className: styles$9.wrapper,