gantt-task-react-v 1.5.26 → 1.6.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.
@@ -5034,6 +5034,16 @@
5034
5034
  }
5035
5035
  );
5036
5036
  };
5037
+ const AssigneesColumn = ({ data: { task } }) => {
5038
+ if (task.type === "empty") {
5039
+ return null;
5040
+ }
5041
+ const assignees = task.assignees;
5042
+ if (!assignees || assignees.length === 0) {
5043
+ return null;
5044
+ }
5045
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: assignees.join(", ") });
5046
+ };
5037
5047
  function useTaskListColumnsBuilder() {
5038
5048
  const createNameColumn = React.useCallback(
5039
5049
  (title2, width) => {
@@ -5103,6 +5113,17 @@
5103
5113
  canResize: false
5104
5114
  };
5105
5115
  }, []);
5116
+ const createAssigneesColumn = React.useCallback(
5117
+ (title2, width) => {
5118
+ return {
5119
+ id: "AssigneesColumn",
5120
+ component: AssigneesColumn,
5121
+ width: width || 120,
5122
+ title: title2
5123
+ };
5124
+ },
5125
+ []
5126
+ );
5106
5127
  return {
5107
5128
  createNameColumn,
5108
5129
  createStartDateColumn,
@@ -5110,7 +5131,8 @@
5110
5131
  createDependenciesColumn,
5111
5132
  createDeleteActionColumn,
5112
5133
  createEditActionColumn,
5113
- createAddActionColumn
5134
+ createAddActionColumn,
5135
+ createAssigneesColumn
5114
5136
  };
5115
5137
  }
5116
5138
  const DEFAULT_THEME = {
@@ -12193,6 +12215,17 @@
12193
12215
  }
12194
12216
  return [progressWidth, progressX];
12195
12217
  };
12218
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
12219
+ const point = [
12220
+ progressX - 5,
12221
+ taskY + taskHeight,
12222
+ progressX + 5,
12223
+ taskY + taskHeight,
12224
+ progressX,
12225
+ taskY + taskHeight - 8.66
12226
+ ];
12227
+ return point.join(",");
12228
+ };
12196
12229
  const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
12197
12230
  const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
12198
12231
  const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
@@ -12372,6 +12405,7 @@
12372
12405
  height,
12373
12406
  progressWidth,
12374
12407
  progressX,
12408
+ progress,
12375
12409
  startMoveFullTask,
12376
12410
  width,
12377
12411
  x,
@@ -12472,6 +12506,24 @@
12472
12506
  rx: barCornerRadius,
12473
12507
  fill: processColor
12474
12508
  }
12509
+ ),
12510
+ showProgress && width > 40 && /* @__PURE__ */ jsxRuntime.jsxs(
12511
+ "text",
12512
+ {
12513
+ x: x + width / 2,
12514
+ y: y + height / 2,
12515
+ dominantBaseline: "central",
12516
+ textAnchor: "middle",
12517
+ fill: "#fff",
12518
+ fontSize: 11,
12519
+ fontWeight: 600,
12520
+ pointerEvents: "none",
12521
+ style: { userSelect: "none" },
12522
+ children: [
12523
+ Math.round(progress),
12524
+ "%"
12525
+ ]
12526
+ }
12475
12527
  )
12476
12528
  ]
12477
12529
  }
@@ -12512,6 +12564,31 @@
12512
12564
  }
12513
12565
  );
12514
12566
  };
12567
+ const BarProgressHandle = ({
12568
+ taskId,
12569
+ progressPoint,
12570
+ startMoveProgress,
12571
+ className
12572
+ }) => {
12573
+ return /* @__PURE__ */ jsxRuntime.jsx(
12574
+ "polygon",
12575
+ {
12576
+ "data-testid": `bar-progress-handle-${taskId}`,
12577
+ className,
12578
+ points: progressPoint,
12579
+ onMouseDown: (e) => {
12580
+ e.stopPropagation();
12581
+ startMoveProgress(e.clientX);
12582
+ },
12583
+ onTouchStart: (e) => {
12584
+ const firstTouch = e.touches[0];
12585
+ if (firstTouch) {
12586
+ startMoveProgress(firstTouch.clientX);
12587
+ }
12588
+ }
12589
+ }
12590
+ );
12591
+ };
12515
12592
  const projectWrapper = "_projectWrapper_1maxt_1";
12516
12593
  const projectBackground = "_projectBackground_1maxt_11";
12517
12594
  const projectTop = "_projectTop_1maxt_21";
@@ -12723,7 +12800,7 @@
12723
12800
  showProgress = true,
12724
12801
  progressColor
12725
12802
  } = props;
12726
- React.useMemo(() => width < 30, [width]);
12803
+ const isSmallWidth = React.useMemo(() => width < 30, [width]);
12727
12804
  const handleHeight = React.useMemo(() => taskHeight - 2, [taskHeight]);
12728
12805
  const rootRef = React.useRef();
12729
12806
  const [ctrlPressed, setCtrlPressed] = React.useState(true);
@@ -12757,12 +12834,17 @@
12757
12834
  },
12758
12835
  [onTaskEventStart]
12759
12836
  );
12760
- React.useCallback(
12837
+ const startMoveProgress = React.useCallback(
12761
12838
  (clientX) => {
12762
12839
  onTaskEventStart("progress", clientX);
12763
12840
  },
12764
12841
  [onTaskEventStart]
12765
12842
  );
12843
+ const progressPoint = getProgressPoint(
12844
+ +!rtl * progressWidth + progressX,
12845
+ taskYOffset,
12846
+ taskHeight
12847
+ );
12766
12848
  const renderBarDisplay = () => {
12767
12849
  if (task.type === "project") {
12768
12850
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -12799,6 +12881,7 @@
12799
12881
  height: taskHeight,
12800
12882
  progressX,
12801
12883
  progressWidth,
12884
+ progress: task.progress,
12802
12885
  barCornerRadius,
12803
12886
  isSelected,
12804
12887
  isCritical,
@@ -12862,7 +12945,15 @@
12862
12945
  }
12863
12946
  ),
12864
12947
  relationHandles,
12865
- false
12948
+ isProgressChangeable(task) && /* @__PURE__ */ jsxRuntime.jsx(
12949
+ BarProgressHandle,
12950
+ {
12951
+ className: `${styles$9.barHandle} ${isMovingProgress ? styles$9.barHandleImportantVisible : ""} ${isSmallWidth || isMovingDate || isRelationDrawMode ? styles$9.barHandleImportantHidden : ""}`,
12952
+ taskId: task.id,
12953
+ progressPoint,
12954
+ startMoveProgress
12955
+ }
12956
+ )
12866
12957
  ] });
12867
12958
  };
12868
12959
  const milestoneWrapper = "_milestoneWrapper_vcirf_1";
@@ -19582,12 +19673,12 @@
19582
19673
  )
19583
19674
  ] }),
19584
19675
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.body, children: [
19585
- data && onGoToTask && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.goToTaskBar, children: data.type === "arrow" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
19586
- /* @__PURE__ */ jsxRuntime.jsxs(
19676
+ data && onGoToTask && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.goToTaskBar, children: [
19677
+ data.type === "task" && /* @__PURE__ */ jsxRuntime.jsxs(
19587
19678
  "button",
19588
19679
  {
19589
19680
  className: styles.goToTaskButton,
19590
- onClick: () => onGoToTask(data.taskFrom.id),
19681
+ onClick: () => onGoToTask(data.task.id),
19591
19682
  type: "button",
19592
19683
  children: [
19593
19684
  /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -19600,35 +19691,59 @@
19600
19691
  strokeLinejoin: "round"
19601
19692
  }
19602
19693
  ) }),
19603
- "Go to ",
19604
- data.taskFrom.name
19694
+ "Go to Task"
19605
19695
  ]
19606
19696
  }
19607
19697
  ),
19608
- /* @__PURE__ */ jsxRuntime.jsxs(
19609
- "button",
19610
- {
19611
- className: styles.goToTaskButton,
19612
- onClick: () => onGoToTask(data.taskTo.id),
19613
- type: "button",
19614
- children: [
19615
- /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
19616
- "path",
19617
- {
19618
- d: "M2 7h10M8 3l4 4-4 4",
19619
- stroke: "currentColor",
19620
- strokeWidth: "1.5",
19621
- strokeLinecap: "round",
19622
- strokeLinejoin: "round"
19623
- }
19624
- ) }),
19625
- "Go to ",
19626
- data.taskTo.name
19627
- ]
19628
- }
19629
- )
19630
- ] }) }),
19631
- data && renderContent ? renderContent(data) : null
19698
+ data.type === "arrow" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
19699
+ /* @__PURE__ */ jsxRuntime.jsxs(
19700
+ "button",
19701
+ {
19702
+ className: styles.goToTaskButton,
19703
+ onClick: () => onGoToTask(data.taskFrom.id),
19704
+ type: "button",
19705
+ children: [
19706
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
19707
+ "path",
19708
+ {
19709
+ d: "M2 7h10M8 3l4 4-4 4",
19710
+ stroke: "currentColor",
19711
+ strokeWidth: "1.5",
19712
+ strokeLinecap: "round",
19713
+ strokeLinejoin: "round"
19714
+ }
19715
+ ) }),
19716
+ "Go to ",
19717
+ data.taskFrom.name
19718
+ ]
19719
+ }
19720
+ ),
19721
+ /* @__PURE__ */ jsxRuntime.jsxs(
19722
+ "button",
19723
+ {
19724
+ className: styles.goToTaskButton,
19725
+ onClick: () => onGoToTask(data.taskTo.id),
19726
+ type: "button",
19727
+ children: [
19728
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
19729
+ "path",
19730
+ {
19731
+ d: "M2 7h10M8 3l4 4-4 4",
19732
+ stroke: "currentColor",
19733
+ strokeWidth: "1.5",
19734
+ strokeLinecap: "round",
19735
+ strokeLinejoin: "round"
19736
+ }
19737
+ ) }),
19738
+ "Go to ",
19739
+ data.taskTo.name
19740
+ ]
19741
+ }
19742
+ )
19743
+ ] })
19744
+ ] }),
19745
+ data && renderContent ? renderContent(data, onGoToTask ?? (() => {
19746
+ })) : null
19632
19747
  ] })
19633
19748
  ]
19634
19749
  }
@@ -19661,8 +19776,6 @@
19661
19776
  onSelectTaskIds,
19662
19777
  // Invoked when user right-clicks a row in the task list
19663
19778
  onRowContextMenu,
19664
- onClickTaskRow,
19665
- onDoubleClickTaskRow,
19666
19779
  onWheel,
19667
19780
  roundEndDate: clientRoundEndDate = defaultRoundEndDate,
19668
19781
  roundStartDate: clientRoundStartDate = defaultRoundStartDate,
@@ -20813,11 +20926,11 @@
20813
20926
  if (enableDrawer) {
20814
20927
  setActiveArrowKey(null);
20815
20928
  setActiveTaskId(task.id);
20929
+ selectTask(task.id);
20816
20930
  if ((drawerData == null ? void 0 : drawerData.type) === "task") {
20817
20931
  setDrawerData({ type: "task", task });
20818
20932
  }
20819
20933
  }
20820
- selectTask(task.id);
20821
20934
  if (taskBar.onClick) {
20822
20935
  taskBar.onClick(task);
20823
20936
  }
@@ -20850,11 +20963,11 @@
20850
20963
  setDrawerData({ type: "task", task });
20851
20964
  }
20852
20965
  }
20853
- if (onClickTaskRow) {
20854
- onClickTaskRow(task);
20966
+ if (taskList.onClickTaskRow) {
20967
+ taskList.onClickTaskRow(task);
20855
20968
  }
20856
20969
  },
20857
- [enableDrawer, drawerData, onClickTaskRow]
20970
+ [enableDrawer, drawerData, taskList]
20858
20971
  );
20859
20972
  const handleTaskRowDoubleClick = React.useCallback(
20860
20973
  (task) => {
@@ -20869,11 +20982,11 @@
20869
20982
  setActiveTaskId(task.id);
20870
20983
  setDrawerData({ type: "task", task });
20871
20984
  }
20872
- if (onDoubleClickTaskRow) {
20873
- onDoubleClickTaskRow(task);
20985
+ if (taskList.onDoubleClickTaskRow) {
20986
+ taskList.onDoubleClickTaskRow(task);
20874
20987
  }
20875
20988
  },
20876
- [enableDrawer, drawerData, onDoubleClickTaskRow, selectTask]
20989
+ [enableDrawer, drawerData, taskList, selectTask]
20877
20990
  );
20878
20991
  const handleDrawerClose = React.useCallback(() => {
20879
20992
  setDrawerData(null);
@@ -21132,6 +21245,16 @@
21132
21245
  language
21133
21246
  ]
21134
21247
  );
21248
+ const drawerAwareSelectOnMouseDown = React.useCallback(
21249
+ (taskId, event) => {
21250
+ if (enableDrawer && drawerData) {
21251
+ selectTask(taskId);
21252
+ return;
21253
+ }
21254
+ selectTaskOnMouseDown(taskId, event);
21255
+ },
21256
+ [enableDrawer, drawerData, selectTask, selectTaskOnMouseDown]
21257
+ );
21135
21258
  const renderTaskBarProps = React.useMemo(
21136
21259
  () => ({
21137
21260
  ...taskBar,
@@ -21168,7 +21291,7 @@
21168
21291
  activeTaskId,
21169
21292
  renderedRowIndexes,
21170
21293
  rtl,
21171
- selectTaskOnMouseDown,
21294
+ selectTaskOnMouseDown: drawerAwareSelectOnMouseDown,
21172
21295
  selectedIdsMirror,
21173
21296
  startColumnIndex,
21174
21297
  taskHalfHeight,
@@ -21210,7 +21333,7 @@
21210
21333
  handleTaskClick,
21211
21334
  renderedRowIndexes,
21212
21335
  rtl,
21213
- selectTaskOnMouseDown,
21336
+ drawerAwareSelectOnMouseDown,
21214
21337
  selectedIdsMirror,
21215
21338
  startColumnIndex,
21216
21339
  taskHalfHeight,
@@ -10,7 +10,7 @@ export type GanttDrawerData = {
10
10
  taskFrom: Task;
11
11
  taskTo: Task;
12
12
  };
13
- export type RenderDrawerContent = (data: GanttDrawerData) => ReactNode;
13
+ export type RenderDrawerContent = (data: GanttDrawerData, goToTask: (taskId: string) => void) => ReactNode;
14
14
  export interface GanttDrawerProps {
15
15
  /**
16
16
  * Enable the drawer panel on task/arrow click
@@ -184,6 +184,14 @@ export interface GanttTaskListProps {
184
184
  * Render bottom table content
185
185
  */
186
186
  tableBottom?: TableRenderBottomProps;
187
+ /**
188
+ * Invokes on single click on a task list row. Receives the task data.
189
+ */
190
+ onClickTaskRow?: (task: RenderTask) => void;
191
+ /**
192
+ * Invokes on double click on a task list row. Receives the task data.
193
+ */
194
+ onDoubleClickTaskRow?: (task: RenderTask) => void;
187
195
  }
188
196
  export interface TableRenderBottomProps {
189
197
  height?: number;
@@ -408,14 +416,6 @@ export interface GanttProps {
408
416
  * Set to a task id to scroll both horizontally and vertically to that task.
409
417
  */
410
418
  scrollToTaskId?: TaskId;
411
- /**
412
- * Invokes on single click on a task list row. Receives the task data.
413
- */
414
- onClickTaskRow?: (task: RenderTask) => void;
415
- /**
416
- * Invokes on double click on a task list row. Receives the task data.
417
- */
418
- onDoubleClickTaskRow?: (task: RenderTask) => void;
419
419
  /**
420
420
  * Drawer panel options for task/arrow click
421
421
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.5.26",
3
+ "version": "1.6.0",
4
4
  "description": "Interactive Gantt Chart for React with TypeScript.",
5
5
  "author": "aguilanbon",
6
6
  "homepage": "https://github.com/aguilanbon/gantt-task-react-v",