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.
@@ -8,6 +8,7 @@ type BarDisplayProps = {
8
8
  height: number;
9
9
  progressWidth: number;
10
10
  progressX: number;
11
+ progress: number;
11
12
  startMoveFullTask: (clientX: number) => void;
12
13
  taskId: TaskId;
13
14
  width: number;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { ColumnProps } from "../../../types";
3
+ export declare const AssigneesColumn: React.FC<ColumnProps>;
@@ -42,4 +42,10 @@ export declare function useTaskListColumnsBuilder(): {
42
42
  width: number;
43
43
  canResize: boolean;
44
44
  };
45
+ createAssigneesColumn: (title: React.ReactNode | null, width?: number) => {
46
+ id: string;
47
+ component: React.FC<import("../../..").ColumnProps>;
48
+ width: number;
49
+ title: React.ReactNode;
50
+ };
45
51
  };
@@ -5017,6 +5017,16 @@ const AddColumn = ({
5017
5017
  }
5018
5018
  );
5019
5019
  };
5020
+ const AssigneesColumn = ({ data: { task } }) => {
5021
+ if (task.type === "empty") {
5022
+ return null;
5023
+ }
5024
+ const assignees = task.assignees;
5025
+ if (!assignees || assignees.length === 0) {
5026
+ return null;
5027
+ }
5028
+ return /* @__PURE__ */ jsx(Fragment, { children: assignees.join(", ") });
5029
+ };
5020
5030
  function useTaskListColumnsBuilder() {
5021
5031
  const createNameColumn = useCallback(
5022
5032
  (title2, width) => {
@@ -5086,6 +5096,17 @@ function useTaskListColumnsBuilder() {
5086
5096
  canResize: false
5087
5097
  };
5088
5098
  }, []);
5099
+ const createAssigneesColumn = useCallback(
5100
+ (title2, width) => {
5101
+ return {
5102
+ id: "AssigneesColumn",
5103
+ component: AssigneesColumn,
5104
+ width: width || 120,
5105
+ title: title2
5106
+ };
5107
+ },
5108
+ []
5109
+ );
5089
5110
  return {
5090
5111
  createNameColumn,
5091
5112
  createStartDateColumn,
@@ -5093,7 +5114,8 @@ function useTaskListColumnsBuilder() {
5093
5114
  createDependenciesColumn,
5094
5115
  createDeleteActionColumn,
5095
5116
  createEditActionColumn,
5096
- createAddActionColumn
5117
+ createAddActionColumn,
5118
+ createAssigneesColumn
5097
5119
  };
5098
5120
  }
5099
5121
  const DEFAULT_THEME = {
@@ -12176,6 +12198,17 @@ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
12176
12198
  }
12177
12199
  return [progressWidth, progressX];
12178
12200
  };
12201
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
12202
+ const point = [
12203
+ progressX - 5,
12204
+ taskY + taskHeight,
12205
+ progressX + 5,
12206
+ taskY + taskHeight,
12207
+ progressX,
12208
+ taskY + taskHeight - 8.66
12209
+ ];
12210
+ return point.join(",");
12211
+ };
12179
12212
  const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
12180
12213
  const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
12181
12214
  const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
@@ -12355,6 +12388,7 @@ const BarDisplay = ({
12355
12388
  height,
12356
12389
  progressWidth,
12357
12390
  progressX,
12391
+ progress,
12358
12392
  startMoveFullTask,
12359
12393
  width,
12360
12394
  x,
@@ -12455,6 +12489,24 @@ const BarDisplay = ({
12455
12489
  rx: barCornerRadius,
12456
12490
  fill: processColor
12457
12491
  }
12492
+ ),
12493
+ showProgress && width > 40 && /* @__PURE__ */ jsxs(
12494
+ "text",
12495
+ {
12496
+ x: x + width / 2,
12497
+ y: y + height / 2,
12498
+ dominantBaseline: "central",
12499
+ textAnchor: "middle",
12500
+ fill: "#fff",
12501
+ fontSize: 11,
12502
+ fontWeight: 600,
12503
+ pointerEvents: "none",
12504
+ style: { userSelect: "none" },
12505
+ children: [
12506
+ Math.round(progress),
12507
+ "%"
12508
+ ]
12509
+ }
12458
12510
  )
12459
12511
  ]
12460
12512
  }
@@ -12495,6 +12547,31 @@ const BarDateHandle = ({
12495
12547
  }
12496
12548
  );
12497
12549
  };
12550
+ const BarProgressHandle = ({
12551
+ taskId,
12552
+ progressPoint,
12553
+ startMoveProgress,
12554
+ className
12555
+ }) => {
12556
+ return /* @__PURE__ */ jsx(
12557
+ "polygon",
12558
+ {
12559
+ "data-testid": `bar-progress-handle-${taskId}`,
12560
+ className,
12561
+ points: progressPoint,
12562
+ onMouseDown: (e) => {
12563
+ e.stopPropagation();
12564
+ startMoveProgress(e.clientX);
12565
+ },
12566
+ onTouchStart: (e) => {
12567
+ const firstTouch = e.touches[0];
12568
+ if (firstTouch) {
12569
+ startMoveProgress(firstTouch.clientX);
12570
+ }
12571
+ }
12572
+ }
12573
+ );
12574
+ };
12498
12575
  const projectWrapper = "_projectWrapper_1maxt_1";
12499
12576
  const projectBackground = "_projectBackground_1maxt_11";
12500
12577
  const projectTop = "_projectTop_1maxt_21";
@@ -12706,7 +12783,7 @@ const Bar = (props) => {
12706
12783
  showProgress = true,
12707
12784
  progressColor
12708
12785
  } = props;
12709
- useMemo(() => width < 30, [width]);
12786
+ const isSmallWidth = useMemo(() => width < 30, [width]);
12710
12787
  const handleHeight = useMemo(() => taskHeight - 2, [taskHeight]);
12711
12788
  const rootRef = useRef();
12712
12789
  const [ctrlPressed, setCtrlPressed] = useState(true);
@@ -12740,12 +12817,17 @@ const Bar = (props) => {
12740
12817
  },
12741
12818
  [onTaskEventStart]
12742
12819
  );
12743
- useCallback(
12820
+ const startMoveProgress = useCallback(
12744
12821
  (clientX) => {
12745
12822
  onTaskEventStart("progress", clientX);
12746
12823
  },
12747
12824
  [onTaskEventStart]
12748
12825
  );
12826
+ const progressPoint = getProgressPoint(
12827
+ +!rtl * progressWidth + progressX,
12828
+ taskYOffset,
12829
+ taskHeight
12830
+ );
12749
12831
  const renderBarDisplay = () => {
12750
12832
  if (task.type === "project") {
12751
12833
  return /* @__PURE__ */ jsx(
@@ -12782,6 +12864,7 @@ const Bar = (props) => {
12782
12864
  height: taskHeight,
12783
12865
  progressX,
12784
12866
  progressWidth,
12867
+ progress: task.progress,
12785
12868
  barCornerRadius,
12786
12869
  isSelected,
12787
12870
  isCritical,
@@ -12845,7 +12928,15 @@ const Bar = (props) => {
12845
12928
  }
12846
12929
  ),
12847
12930
  relationHandles,
12848
- false
12931
+ isProgressChangeable(task) && /* @__PURE__ */ jsx(
12932
+ BarProgressHandle,
12933
+ {
12934
+ className: `${styles$9.barHandle} ${isMovingProgress ? styles$9.barHandleImportantVisible : ""} ${isSmallWidth || isMovingDate || isRelationDrawMode ? styles$9.barHandleImportantHidden : ""}`,
12935
+ taskId: task.id,
12936
+ progressPoint,
12937
+ startMoveProgress
12938
+ }
12939
+ )
12849
12940
  ] });
12850
12941
  };
12851
12942
  const milestoneWrapper = "_milestoneWrapper_vcirf_1";
@@ -19565,12 +19656,12 @@ const GanttDrawerInner = ({
19565
19656
  )
19566
19657
  ] }),
19567
19658
  /* @__PURE__ */ jsxs("div", { className: styles.body, children: [
19568
- data && onGoToTask && /* @__PURE__ */ jsx("div", { className: styles.goToTaskBar, children: data.type === "arrow" && /* @__PURE__ */ jsxs(Fragment, { children: [
19569
- /* @__PURE__ */ jsxs(
19659
+ data && onGoToTask && /* @__PURE__ */ jsxs("div", { className: styles.goToTaskBar, children: [
19660
+ data.type === "task" && /* @__PURE__ */ jsxs(
19570
19661
  "button",
19571
19662
  {
19572
19663
  className: styles.goToTaskButton,
19573
- onClick: () => onGoToTask(data.taskFrom.id),
19664
+ onClick: () => onGoToTask(data.task.id),
19574
19665
  type: "button",
19575
19666
  children: [
19576
19667
  /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
@@ -19583,35 +19674,59 @@ const GanttDrawerInner = ({
19583
19674
  strokeLinejoin: "round"
19584
19675
  }
19585
19676
  ) }),
19586
- "Go to ",
19587
- data.taskFrom.name
19677
+ "Go to Task"
19588
19678
  ]
19589
19679
  }
19590
19680
  ),
19591
- /* @__PURE__ */ jsxs(
19592
- "button",
19593
- {
19594
- className: styles.goToTaskButton,
19595
- onClick: () => onGoToTask(data.taskTo.id),
19596
- type: "button",
19597
- children: [
19598
- /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19599
- "path",
19600
- {
19601
- d: "M2 7h10M8 3l4 4-4 4",
19602
- stroke: "currentColor",
19603
- strokeWidth: "1.5",
19604
- strokeLinecap: "round",
19605
- strokeLinejoin: "round"
19606
- }
19607
- ) }),
19608
- "Go to ",
19609
- data.taskTo.name
19610
- ]
19611
- }
19612
- )
19613
- ] }) }),
19614
- data && renderContent ? renderContent(data) : null
19681
+ data.type === "arrow" && /* @__PURE__ */ jsxs(Fragment, { children: [
19682
+ /* @__PURE__ */ jsxs(
19683
+ "button",
19684
+ {
19685
+ className: styles.goToTaskButton,
19686
+ onClick: () => onGoToTask(data.taskFrom.id),
19687
+ type: "button",
19688
+ children: [
19689
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19690
+ "path",
19691
+ {
19692
+ d: "M2 7h10M8 3l4 4-4 4",
19693
+ stroke: "currentColor",
19694
+ strokeWidth: "1.5",
19695
+ strokeLinecap: "round",
19696
+ strokeLinejoin: "round"
19697
+ }
19698
+ ) }),
19699
+ "Go to ",
19700
+ data.taskFrom.name
19701
+ ]
19702
+ }
19703
+ ),
19704
+ /* @__PURE__ */ jsxs(
19705
+ "button",
19706
+ {
19707
+ className: styles.goToTaskButton,
19708
+ onClick: () => onGoToTask(data.taskTo.id),
19709
+ type: "button",
19710
+ children: [
19711
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19712
+ "path",
19713
+ {
19714
+ d: "M2 7h10M8 3l4 4-4 4",
19715
+ stroke: "currentColor",
19716
+ strokeWidth: "1.5",
19717
+ strokeLinecap: "round",
19718
+ strokeLinejoin: "round"
19719
+ }
19720
+ ) }),
19721
+ "Go to ",
19722
+ data.taskTo.name
19723
+ ]
19724
+ }
19725
+ )
19726
+ ] })
19727
+ ] }),
19728
+ data && renderContent ? renderContent(data, onGoToTask ?? (() => {
19729
+ })) : null
19615
19730
  ] })
19616
19731
  ]
19617
19732
  }
@@ -19644,8 +19759,6 @@ const Gantt = (props) => {
19644
19759
  onSelectTaskIds,
19645
19760
  // Invoked when user right-clicks a row in the task list
19646
19761
  onRowContextMenu,
19647
- onClickTaskRow,
19648
- onDoubleClickTaskRow,
19649
19762
  onWheel,
19650
19763
  roundEndDate: clientRoundEndDate = defaultRoundEndDate,
19651
19764
  roundStartDate: clientRoundStartDate = defaultRoundStartDate,
@@ -20796,11 +20909,11 @@ const Gantt = (props) => {
20796
20909
  if (enableDrawer) {
20797
20910
  setActiveArrowKey(null);
20798
20911
  setActiveTaskId(task.id);
20912
+ selectTask(task.id);
20799
20913
  if ((drawerData == null ? void 0 : drawerData.type) === "task") {
20800
20914
  setDrawerData({ type: "task", task });
20801
20915
  }
20802
20916
  }
20803
- selectTask(task.id);
20804
20917
  if (taskBar.onClick) {
20805
20918
  taskBar.onClick(task);
20806
20919
  }
@@ -20833,11 +20946,11 @@ const Gantt = (props) => {
20833
20946
  setDrawerData({ type: "task", task });
20834
20947
  }
20835
20948
  }
20836
- if (onClickTaskRow) {
20837
- onClickTaskRow(task);
20949
+ if (taskList.onClickTaskRow) {
20950
+ taskList.onClickTaskRow(task);
20838
20951
  }
20839
20952
  },
20840
- [enableDrawer, drawerData, onClickTaskRow]
20953
+ [enableDrawer, drawerData, taskList]
20841
20954
  );
20842
20955
  const handleTaskRowDoubleClick = useCallback(
20843
20956
  (task) => {
@@ -20852,11 +20965,11 @@ const Gantt = (props) => {
20852
20965
  setActiveTaskId(task.id);
20853
20966
  setDrawerData({ type: "task", task });
20854
20967
  }
20855
- if (onDoubleClickTaskRow) {
20856
- onDoubleClickTaskRow(task);
20968
+ if (taskList.onDoubleClickTaskRow) {
20969
+ taskList.onDoubleClickTaskRow(task);
20857
20970
  }
20858
20971
  },
20859
- [enableDrawer, drawerData, onDoubleClickTaskRow, selectTask]
20972
+ [enableDrawer, drawerData, taskList, selectTask]
20860
20973
  );
20861
20974
  const handleDrawerClose = useCallback(() => {
20862
20975
  setDrawerData(null);
@@ -21115,6 +21228,16 @@ const Gantt = (props) => {
21115
21228
  language
21116
21229
  ]
21117
21230
  );
21231
+ const drawerAwareSelectOnMouseDown = useCallback(
21232
+ (taskId, event) => {
21233
+ if (enableDrawer && drawerData) {
21234
+ selectTask(taskId);
21235
+ return;
21236
+ }
21237
+ selectTaskOnMouseDown(taskId, event);
21238
+ },
21239
+ [enableDrawer, drawerData, selectTask, selectTaskOnMouseDown]
21240
+ );
21118
21241
  const renderTaskBarProps = useMemo(
21119
21242
  () => ({
21120
21243
  ...taskBar,
@@ -21151,7 +21274,7 @@ const Gantt = (props) => {
21151
21274
  activeTaskId,
21152
21275
  renderedRowIndexes,
21153
21276
  rtl,
21154
- selectTaskOnMouseDown,
21277
+ selectTaskOnMouseDown: drawerAwareSelectOnMouseDown,
21155
21278
  selectedIdsMirror,
21156
21279
  startColumnIndex,
21157
21280
  taskHalfHeight,
@@ -21193,7 +21316,7 @@ const Gantt = (props) => {
21193
21316
  handleTaskClick,
21194
21317
  renderedRowIndexes,
21195
21318
  rtl,
21196
- selectTaskOnMouseDown,
21319
+ drawerAwareSelectOnMouseDown,
21197
21320
  selectedIdsMirror,
21198
21321
  startColumnIndex,
21199
21322
  taskHalfHeight,