gantt-task-react-v 1.4.6 → 1.4.8

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.
@@ -4817,7 +4817,7 @@ const TitleColumn = ({
4817
4817
  () => getExpanderSymbol(hasChildren, isClosed, expandIconWidth, icons),
4818
4818
  [hasChildren, isClosed, expandIconWidth, icons]
4819
4819
  );
4820
- const title = isShowTaskNumbers ? `${indexStr} ${name}` : name;
4820
+ const title2 = isShowTaskNumbers ? `${indexStr} ${name}` : name;
4821
4821
  const onClick = useCallback(() => {
4822
4822
  if (task.type !== "empty") {
4823
4823
  onExpanderClick(task);
@@ -4831,7 +4831,7 @@ const TitleColumn = ({
4831
4831
  style: {
4832
4832
  paddingLeft: depth * nestedTaskNameOffset
4833
4833
  },
4834
- title,
4834
+ title: title2,
4835
4835
  children: [
4836
4836
  /* @__PURE__ */ jsx(
4837
4837
  "div",
@@ -5019,45 +5019,45 @@ const AddColumn = ({
5019
5019
  };
5020
5020
  function useTaskListColumnsBuilder() {
5021
5021
  const createNameColumn = useCallback(
5022
- (title, width) => {
5022
+ (title2, width) => {
5023
5023
  return {
5024
5024
  id: "TitleColumn",
5025
5025
  component: TitleColumn,
5026
5026
  width: width || 120,
5027
- title
5027
+ title: title2
5028
5028
  };
5029
5029
  },
5030
5030
  []
5031
5031
  );
5032
5032
  const createStartDateColumn = useCallback(
5033
- (title, width) => {
5033
+ (title2, width) => {
5034
5034
  return {
5035
5035
  id: "DateStartColumn",
5036
5036
  component: DateStartColumn,
5037
5037
  width: width || 60,
5038
- title
5038
+ title: title2
5039
5039
  };
5040
5040
  },
5041
5041
  []
5042
5042
  );
5043
5043
  const createEndDateColumn = useCallback(
5044
- (title, width) => {
5044
+ (title2, width) => {
5045
5045
  return {
5046
5046
  id: "DateEndColumn",
5047
5047
  component: DateEndColumn,
5048
5048
  width: width || 60,
5049
- title
5049
+ title: title2
5050
5050
  };
5051
5051
  },
5052
5052
  []
5053
5053
  );
5054
5054
  const createDependenciesColumn = useCallback(
5055
- (title, width) => {
5055
+ (title2, width) => {
5056
5056
  return {
5057
5057
  id: "DependenciesColumn",
5058
5058
  component: DependenciesColumn,
5059
5059
  width: width || 90,
5060
- title
5060
+ title: title2
5061
5061
  };
5062
5062
  },
5063
5063
  []
@@ -5584,9 +5584,9 @@ const TaskListTableHeadersDefaultInner = ({
5584
5584
  },
5585
5585
  children: [
5586
5586
  canMoveTasks && /* @__PURE__ */ jsx("div", { className: styles$i.ganttTable_HeaderMoveTask }),
5587
- columns.map(({ title, width, canResize }, index2) => {
5587
+ columns.map(({ title: title2, width, canResize }, index2) => {
5588
5588
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
5589
- index2 > 0 && !!title && /* @__PURE__ */ jsx(
5589
+ index2 > 0 && !!title2 && /* @__PURE__ */ jsx(
5590
5590
  "div",
5591
5591
  {
5592
5592
  className: styles$i.ganttTable_HeaderSeparator,
@@ -5599,7 +5599,7 @@ const TaskListTableHeadersDefaultInner = ({
5599
5599
  /* @__PURE__ */ jsxs(
5600
5600
  "div",
5601
5601
  {
5602
- "data-testid": `table-column-header-${title}`,
5602
+ "data-testid": `table-column-header-${title2}`,
5603
5603
  className: styles$i.ganttTable_HeaderItem,
5604
5604
  style: {
5605
5605
  minWidth: width,
@@ -5607,11 +5607,11 @@ const TaskListTableHeadersDefaultInner = ({
5607
5607
  ...pinnedStyles[index2]
5608
5608
  },
5609
5609
  children: [
5610
- title,
5611
- canResizeColumns && canResize !== false && !!title && /* @__PURE__ */ jsx(
5610
+ title2,
5611
+ canResizeColumns && canResize !== false && !!title2 && /* @__PURE__ */ jsx(
5612
5612
  "div",
5613
5613
  {
5614
- "data-testid": `table-column-header-resize-handle-${title}`,
5614
+ "data-testid": `table-column-header-resize-handle-${title2}`,
5615
5615
  className: styles$i.resizer,
5616
5616
  onMouseDown: (event) => {
5617
5617
  onColumnResizeStart(index2, event.clientX);
@@ -11727,12 +11727,14 @@ const generateTrianglePoints = (x, y, width, isLeftDirected) => {
11727
11727
  ${x - width},${y - width}
11728
11728
  ${x - width},${y + width}`;
11729
11729
  };
11730
- const arrow_clickable = "_arrow_clickable_13ifc_1";
11731
- const mainPath = "_mainPath_13ifc_9";
11732
- const clickZone = "_clickZone_13ifc_33";
11730
+ const arrow_clickable = "_arrow_clickable_3u3q2_1";
11731
+ const mainPath = "_mainPath_3u3q2_11";
11732
+ const arrow_active = "_arrow_active_3u3q2_37";
11733
+ const clickZone = "_clickZone_3u3q2_81";
11733
11734
  const styles$b = {
11734
11735
  arrow_clickable,
11735
11736
  mainPath,
11737
+ arrow_active,
11736
11738
  clickZone
11737
11739
  };
11738
11740
  const ArrowInner = (props) => {
@@ -11754,6 +11756,7 @@ const ArrowInner = (props) => {
11754
11756
  rtl,
11755
11757
  onArrowDoubleClick = void 0,
11756
11758
  onArrowClick = void 0,
11759
+ isActive = false,
11757
11760
  fromConnectionIndex = 0,
11758
11761
  fromTotalConnections = 1,
11759
11762
  toConnectionIndex = 0,
@@ -11824,29 +11827,20 @@ const ArrowInner = (props) => {
11824
11827
  }
11825
11828
  return "var(--gantt-arrow-color)";
11826
11829
  }, [isCritical]);
11827
- return /* @__PURE__ */ jsx(
11830
+ return /* @__PURE__ */ jsx("g", { fill: color, stroke: color, children: /* @__PURE__ */ jsxs(
11828
11831
  "g",
11829
11832
  {
11830
- fill: color,
11831
- stroke: color,
11832
- "data-arrow-from": taskFrom.id,
11833
- "data-arrow-to": taskTo.id,
11834
- children: /* @__PURE__ */ jsxs(
11835
- "g",
11836
- {
11837
- "data-testid": `task-arrow-${targetFrom}-${taskFrom.name}-${targetTo}-${taskTo.name}`,
11838
- className: `arrow ${styles$b.arrow_clickable}`,
11839
- onDoubleClick,
11840
- onClick: handleClick,
11841
- children: [
11842
- onArrowDoubleClick && /* @__PURE__ */ jsx("path", { d: path, className: styles$b.clickZone }),
11843
- /* @__PURE__ */ jsx("path", { className: styles$b.mainPath, d: path }),
11844
- /* @__PURE__ */ jsx("polygon", { className: "polygon", points: trianglePoints })
11845
- ]
11846
- }
11847
- )
11833
+ "data-testid": `task-arrow-${targetFrom}-${taskFrom.name}-${targetTo}-${taskTo.name}`,
11834
+ className: `arrow ${styles$b.arrow_clickable}${isActive ? ` ${styles$b.arrow_active}` : ""}`,
11835
+ onDoubleClick,
11836
+ onClick: handleClick,
11837
+ children: [
11838
+ (onArrowDoubleClick || onArrowClick) && /* @__PURE__ */ jsx("path", { d: path, className: styles$b.clickZone }),
11839
+ /* @__PURE__ */ jsx("path", { className: styles$b.mainPath, d: path }),
11840
+ /* @__PURE__ */ jsx("polygon", { className: "polygon", points: trianglePoints })
11841
+ ]
11848
11842
  }
11849
- );
11843
+ ) });
11850
11844
  };
11851
11845
  const Arrow = memo(ArrowInner);
11852
11846
  const roundedPath = (points, radius) => {
@@ -13165,6 +13159,9 @@ const TaskGanttContentInner = (props) => {
13165
13159
  onTaskBarDragStart,
13166
13160
  mapGlobalRowIndexToTask,
13167
13161
  onArrowDoubleClick,
13162
+ onArrowClick,
13163
+ activeArrowKey,
13164
+ activeTaskId,
13168
13165
  onDoubleClick,
13169
13166
  onClick,
13170
13167
  renderedRowIndexes,
@@ -13186,9 +13183,7 @@ const TaskGanttContentInner = (props) => {
13186
13183
  waitCommitTasks,
13187
13184
  viewMode,
13188
13185
  showProgress = true,
13189
- progressColor,
13190
- onArrowClick,
13191
- selectedArrow
13186
+ progressColor
13192
13187
  } = props;
13193
13188
  const renderedHolidays = useMemo(() => {
13194
13189
  const { columnWidth } = distances;
@@ -13471,6 +13466,7 @@ const TaskGanttContentInner = (props) => {
13471
13466
  rtl,
13472
13467
  onArrowDoubleClick,
13473
13468
  onArrowClick,
13469
+ isActive: activeArrowKey === `${source.id}|${taskId}` || activeTaskId === source.id || activeTaskId === taskId,
13474
13470
  fromConnectionIndex: getConnectionIndex(
13475
13471
  `${source.id}|${sourceTarget}|out`
13476
13472
  ),
@@ -13556,6 +13552,7 @@ const TaskGanttContentInner = (props) => {
13556
13552
  rtl,
13557
13553
  onArrowDoubleClick,
13558
13554
  onArrowClick,
13555
+ isActive: activeArrowKey === `${taskId}|${dependent.id}` || activeTaskId === taskId || activeTaskId === dependent.id,
13559
13556
  fromConnectionIndex: getConnectionIndex(
13560
13557
  `${taskId}|${ownTarget}|out`
13561
13558
  ),
@@ -13654,6 +13651,7 @@ const TaskGanttContentInner = (props) => {
13654
13651
  rtl,
13655
13652
  onArrowDoubleClick,
13656
13653
  onArrowClick,
13654
+ isActive: activeArrowKey === `${source.id}|${taskId}` || activeTaskId === source.id || activeTaskId === taskId,
13657
13655
  fromConnectionIndex: getConnectionIndex(
13658
13656
  `${source.id}|${sourceTarget}|out`
13659
13657
  ),
@@ -13712,80 +13710,12 @@ const TaskGanttContentInner = (props) => {
13712
13710
  visibleTasksMirror,
13713
13711
  onArrowDoubleClick,
13714
13712
  onArrowClick,
13713
+ activeArrowKey,
13714
+ activeTaskId,
13715
13715
  showProgress,
13716
13716
  progressColor
13717
13717
  ]);
13718
- const contentRef = useRef(null);
13719
- useEffect(() => {
13720
- const contentEl = contentRef.current;
13721
- if (!contentEl)
13722
- return void 0;
13723
- const svgRoot = contentEl.ownerSVGElement;
13724
- if (!svgRoot)
13725
- return void 0;
13726
- let currentHighlightedTask = null;
13727
- const highlightArrows = (taskId) => {
13728
- if (currentHighlightedTask === taskId)
13729
- return;
13730
- clearHighlights();
13731
- currentHighlightedTask = taskId;
13732
- const arrows = svgRoot.querySelectorAll(
13733
- `[data-arrow-from="${taskId}"], [data-arrow-to="${taskId}"]`
13734
- );
13735
- arrows.forEach((el) => el.classList.add("gantt-arrow-highlighted"));
13736
- };
13737
- const clearHighlights = () => {
13738
- if (!currentHighlightedTask)
13739
- return;
13740
- svgRoot.querySelectorAll(".gantt-arrow-highlighted").forEach((el) => el.classList.remove("gantt-arrow-highlighted"));
13741
- currentHighlightedTask = null;
13742
- };
13743
- const onMouseOver = (e) => {
13744
- const target = e.target;
13745
- const taskWrapper = target.closest(".TaskItemWrapper");
13746
- if (taskWrapper && taskWrapper.id) {
13747
- highlightArrows(taskWrapper.id);
13748
- }
13749
- };
13750
- const onMouseOut = (e) => {
13751
- const target = e.target;
13752
- const taskWrapper = target.closest(".TaskItemWrapper");
13753
- if (taskWrapper) {
13754
- const relatedTarget = e.relatedTarget;
13755
- if (!relatedTarget || !taskWrapper.contains(relatedTarget)) {
13756
- clearHighlights();
13757
- }
13758
- }
13759
- };
13760
- contentEl.addEventListener("mouseover", onMouseOver);
13761
- contentEl.addEventListener("mouseout", onMouseOut);
13762
- return () => {
13763
- contentEl.removeEventListener("mouseover", onMouseOver);
13764
- contentEl.removeEventListener("mouseout", onMouseOut);
13765
- };
13766
- }, []);
13767
- useLayoutEffect(() => {
13768
- const contentEl = contentRef.current;
13769
- if (!contentEl)
13770
- return;
13771
- const svgRoot = contentEl.ownerSVGElement;
13772
- if (!svgRoot)
13773
- return;
13774
- svgRoot.querySelectorAll(".gantt-arrow-selected").forEach((el) => el.classList.remove("gantt-arrow-selected"));
13775
- if (!selectedArrow)
13776
- return;
13777
- if (selectedArrow.taskId) {
13778
- svgRoot.querySelectorAll(
13779
- `[data-arrow-from="${selectedArrow.taskId}"], [data-arrow-to="${selectedArrow.taskId}"]`
13780
- ).forEach((el) => el.classList.add("gantt-arrow-selected"));
13781
- }
13782
- if (selectedArrow.fromId && selectedArrow.toId) {
13783
- svgRoot.querySelectorAll(
13784
- `[data-arrow-from="${selectedArrow.fromId}"][data-arrow-to="${selectedArrow.toId}"]`
13785
- ).forEach((el) => el.classList.add("gantt-arrow-selected"));
13786
- }
13787
- }, [selectedArrow, renderedArrows]);
13788
- return /* @__PURE__ */ jsxs("g", { className: "content", ref: contentRef, children: [
13718
+ return /* @__PURE__ */ jsxs("g", { className: "content", children: [
13789
13719
  renderedSelectedTasks,
13790
13720
  /* @__PURE__ */ jsx("g", { children: renderedHolidays }),
13791
13721
  /* @__PURE__ */ jsx(
@@ -16341,13 +16271,13 @@ function getWindowScrollBarX(element) {
16341
16271
  function getDocumentRect(element) {
16342
16272
  const html = getDocumentElement(element);
16343
16273
  const scroll2 = getNodeScroll(element);
16344
- const body = element.ownerDocument.body;
16345
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
16346
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
16274
+ const body2 = element.ownerDocument.body;
16275
+ const width = max(html.scrollWidth, html.clientWidth, body2.scrollWidth, body2.clientWidth);
16276
+ const height = max(html.scrollHeight, html.clientHeight, body2.scrollHeight, body2.clientHeight);
16347
16277
  let x = -scroll2.scrollLeft + getWindowScrollBarX(element);
16348
16278
  const y = -scroll2.scrollTop;
16349
- if (getComputedStyle$1(body).direction === "rtl") {
16350
- x += max(html.clientWidth, body.clientWidth) - width;
16279
+ if (getComputedStyle$1(body2).direction === "rtl") {
16280
+ x += max(html.clientWidth, body2.clientWidth) - width;
16351
16281
  }
16352
16282
  return {
16353
16283
  width,
@@ -19402,110 +19332,154 @@ const GanttLoaderInner = ({ loading }) => {
19402
19332
  return /* @__PURE__ */ jsx("div", { className: `${styles$1.loader} ${loading ? "" : styles$1.loaderHidden}` });
19403
19333
  };
19404
19334
  const GanttLoader = memo(GanttLoaderInner);
19405
- const drawerOverlay = "_drawerOverlay_3p2w6_1";
19406
- const drawer = "_drawer_3p2w6_1";
19407
- const slideIn = "_slideIn_3p2w6_1";
19408
- const drawerHeader = "_drawerHeader_3p2w6_71";
19409
- const closeButton = "_closeButton_3p2w6_89";
19410
- const drawerContent = "_drawerContent_3p2w6_127";
19411
- const defaultSection = "_defaultSection_3p2w6_139";
19412
- const defaultField = "_defaultField_3p2w6_175";
19413
- const defaultFieldLabel = "_defaultFieldLabel_3p2w6_191";
19335
+ const overlay = "_overlay_hyem8_1";
19336
+ const drawer = "_drawer_hyem8_19";
19337
+ const drawer_open = "_drawer_open_hyem8_51";
19338
+ const header = "_header_hyem8_59";
19339
+ const title = "_title_hyem8_77";
19340
+ const closeButton = "_closeButton_hyem8_97";
19341
+ const body = "_body_hyem8_131";
19342
+ const goToTaskBar = "_goToTaskBar_hyem8_145";
19343
+ const goToTaskButton = "_goToTaskButton_hyem8_159";
19414
19344
  const styles = {
19415
- drawerOverlay,
19345
+ overlay,
19416
19346
  drawer,
19417
- slideIn,
19418
- drawerHeader,
19347
+ drawer_open,
19348
+ header,
19349
+ title,
19419
19350
  closeButton,
19420
- drawerContent,
19421
- defaultSection,
19422
- defaultField,
19423
- defaultFieldLabel
19351
+ body,
19352
+ goToTaskBar,
19353
+ goToTaskButton
19424
19354
  };
19425
- const DefaultDrawerContent = ({
19426
- data
19427
- }) => {
19428
- var _a, _b, _c, _d, _e, _f;
19429
- if (data.type === "task" && data.task) {
19430
- const { task } = data;
19431
- return /* @__PURE__ */ jsxs("div", { className: styles.defaultSection, children: [
19432
- /* @__PURE__ */ jsx("h3", { children: "Task Details" }),
19433
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19434
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Name:" }),
19435
- /* @__PURE__ */ jsx("span", { children: task.name })
19436
- ] }),
19437
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19438
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Start:" }),
19439
- /* @__PURE__ */ jsx("span", { children: (_a = task.start) == null ? void 0 : _a.toLocaleDateString() })
19440
- ] }),
19441
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19442
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "End:" }),
19443
- /* @__PURE__ */ jsx("span", { children: (_b = task.end) == null ? void 0 : _b.toLocaleDateString() })
19444
- ] }),
19445
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19446
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Progress:" }),
19447
- /* @__PURE__ */ jsxs("span", { children: [
19448
- Math.round(task.progress || 0),
19449
- "%"
19450
- ] })
19451
- ] })
19452
- ] });
19453
- }
19454
- if (data.type === "connection" && data.taskFrom && data.taskTo) {
19455
- return /* @__PURE__ */ jsxs("div", { className: styles.defaultSection, children: [
19456
- /* @__PURE__ */ jsx("h3", { children: "Connection Details" }),
19457
- /* @__PURE__ */ jsx("h4", { children: "From" }),
19458
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19459
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Name:" }),
19460
- /* @__PURE__ */ jsx("span", { children: data.taskFrom.name })
19461
- ] }),
19462
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19463
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Start:" }),
19464
- /* @__PURE__ */ jsx("span", { children: (_c = data.taskFrom.start) == null ? void 0 : _c.toLocaleDateString() })
19465
- ] }),
19466
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19467
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "End:" }),
19468
- /* @__PURE__ */ jsx("span", { children: (_d = data.taskFrom.end) == null ? void 0 : _d.toLocaleDateString() })
19469
- ] }),
19470
- /* @__PURE__ */ jsx("h4", { children: "To" }),
19471
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19472
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Name:" }),
19473
- /* @__PURE__ */ jsx("span", { children: data.taskTo.name })
19474
- ] }),
19475
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19476
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "Start:" }),
19477
- /* @__PURE__ */ jsx("span", { children: (_e = data.taskTo.start) == null ? void 0 : _e.toLocaleDateString() })
19478
- ] }),
19479
- /* @__PURE__ */ jsxs("div", { className: styles.defaultField, children: [
19480
- /* @__PURE__ */ jsx("span", { className: styles.defaultFieldLabel, children: "End:" }),
19481
- /* @__PURE__ */ jsx("span", { children: (_f = data.taskTo.end) == null ? void 0 : _f.toLocaleDateString() })
19482
- ] })
19483
- ] });
19484
- }
19485
- return null;
19486
- };
19487
- const GanttDrawer = ({
19488
- open,
19489
- width,
19355
+ const GanttDrawerInner = ({
19490
19356
  data,
19357
+ width,
19491
19358
  onClose,
19359
+ onGoToTask,
19492
19360
  renderContent
19493
19361
  }) => {
19494
- if (!open || !data)
19495
- return null;
19496
- return /* @__PURE__ */ jsx("div", { className: styles.drawerOverlay, children: /* @__PURE__ */ jsxs("div", { className: styles.drawer, style: { width }, children: [
19497
- /* @__PURE__ */ jsx("div", { className: styles.drawerHeader, children: /* @__PURE__ */ jsx(
19498
- "button",
19362
+ const handleOverlayClick = useCallback(
19363
+ (e) => {
19364
+ e.stopPropagation();
19365
+ onClose();
19366
+ },
19367
+ [onClose]
19368
+ );
19369
+ const title2 = (data == null ? void 0 : data.type) === "task" ? data.task.name : (data == null ? void 0 : data.type) === "arrow" ? `${data.taskFrom.name} → ${data.taskTo.name}` : "";
19370
+ const goToTaskIds = [];
19371
+ if ((data == null ? void 0 : data.type) === "task") {
19372
+ goToTaskIds.push(data.task.id);
19373
+ } else if ((data == null ? void 0 : data.type) === "arrow") {
19374
+ goToTaskIds.push(data.taskFrom.id, data.taskTo.id);
19375
+ }
19376
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
19377
+ data && /* @__PURE__ */ jsx("div", { className: styles.overlay, onClick: handleOverlayClick }),
19378
+ /* @__PURE__ */ jsxs(
19379
+ "div",
19499
19380
  {
19500
- className: styles.closeButton,
19501
- onClick: onClose,
19502
- "aria-label": "Close drawer",
19503
- children: "×"
19381
+ className: `${styles.drawer}${data ? ` ${styles.drawer_open}` : ""}`,
19382
+ style: { width },
19383
+ children: [
19384
+ /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
19385
+ /* @__PURE__ */ jsx("span", { className: styles.title, children: title2 }),
19386
+ /* @__PURE__ */ jsx(
19387
+ "button",
19388
+ {
19389
+ className: styles.closeButton,
19390
+ onClick: onClose,
19391
+ "aria-label": "Close drawer",
19392
+ type: "button",
19393
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx(
19394
+ "path",
19395
+ {
19396
+ d: "M12 4L4 12M4 4l8 8",
19397
+ stroke: "currentColor",
19398
+ strokeWidth: "1.5",
19399
+ strokeLinecap: "round"
19400
+ }
19401
+ ) })
19402
+ }
19403
+ )
19404
+ ] }),
19405
+ /* @__PURE__ */ jsxs("div", { className: styles.body, children: [
19406
+ data && onGoToTask && /* @__PURE__ */ jsxs("div", { className: styles.goToTaskBar, children: [
19407
+ data.type === "task" && /* @__PURE__ */ jsxs(
19408
+ "button",
19409
+ {
19410
+ className: styles.goToTaskButton,
19411
+ onClick: () => onGoToTask(data.task.id),
19412
+ type: "button",
19413
+ children: [
19414
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19415
+ "path",
19416
+ {
19417
+ d: "M2 7h10M8 3l4 4-4 4",
19418
+ stroke: "currentColor",
19419
+ strokeWidth: "1.5",
19420
+ strokeLinecap: "round",
19421
+ strokeLinejoin: "round"
19422
+ }
19423
+ ) }),
19424
+ "Go to Task"
19425
+ ]
19426
+ }
19427
+ ),
19428
+ data.type === "arrow" && /* @__PURE__ */ jsxs(Fragment, { children: [
19429
+ /* @__PURE__ */ jsxs(
19430
+ "button",
19431
+ {
19432
+ className: styles.goToTaskButton,
19433
+ onClick: () => onGoToTask(data.taskFrom.id),
19434
+ type: "button",
19435
+ children: [
19436
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19437
+ "path",
19438
+ {
19439
+ d: "M2 7h10M8 3l4 4-4 4",
19440
+ stroke: "currentColor",
19441
+ strokeWidth: "1.5",
19442
+ strokeLinecap: "round",
19443
+ strokeLinejoin: "round"
19444
+ }
19445
+ ) }),
19446
+ "Go to ",
19447
+ data.taskFrom.name
19448
+ ]
19449
+ }
19450
+ ),
19451
+ /* @__PURE__ */ jsxs(
19452
+ "button",
19453
+ {
19454
+ className: styles.goToTaskButton,
19455
+ onClick: () => onGoToTask(data.taskTo.id),
19456
+ type: "button",
19457
+ children: [
19458
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx(
19459
+ "path",
19460
+ {
19461
+ d: "M2 7h10M8 3l4 4-4 4",
19462
+ stroke: "currentColor",
19463
+ strokeWidth: "1.5",
19464
+ strokeLinecap: "round",
19465
+ strokeLinejoin: "round"
19466
+ }
19467
+ ) }),
19468
+ "Go to ",
19469
+ data.taskTo.name
19470
+ ]
19471
+ }
19472
+ )
19473
+ ] })
19474
+ ] }),
19475
+ data && renderContent ? renderContent(data) : null
19476
+ ] })
19477
+ ]
19504
19478
  }
19505
- ) }),
19506
- /* @__PURE__ */ jsx("div", { className: styles.drawerContent, children: renderContent ? renderContent(data) : /* @__PURE__ */ jsx(DefaultDrawerContent, { data }) })
19507
- ] }) });
19479
+ )
19480
+ ] });
19508
19481
  };
19482
+ const GanttDrawer = memo(GanttDrawerInner);
19509
19483
  const Gantt = (props) => {
19510
19484
  var _a, _b;
19511
19485
  const {
@@ -19552,10 +19526,7 @@ const Gantt = (props) => {
19552
19526
  showProgress = true,
19553
19527
  progressColor,
19554
19528
  scrollToTaskId,
19555
- enableDrawer = false,
19556
- drawerWidth = 300,
19557
- renderDrawerContent,
19558
- onArrowClick: onArrowClickProp
19529
+ drawer: drawerProps
19559
19530
  } = props;
19560
19531
  const ganttSVGRef = useRef(null);
19561
19532
  const wrapperRef = useRef(null);
@@ -19572,36 +19543,12 @@ const Gantt = (props) => {
19572
19543
  [theme, rowHeight]
19573
19544
  );
19574
19545
  const [waitCommitTasks, setWaitCommitTasks] = useState(false);
19546
+ const enableDrawer = (drawerProps == null ? void 0 : drawerProps.enableDrawer) ?? false;
19547
+ const drawerWidth = (drawerProps == null ? void 0 : drawerProps.drawerWidth) ?? 360;
19548
+ const renderDrawerContent = drawerProps == null ? void 0 : drawerProps.renderDrawerContent;
19575
19549
  const [drawerData, setDrawerData] = useState(null);
19576
- const [selectedArrow, setSelectedArrow] = useState(null);
19577
- const handleDrawerClose = useCallback(() => {
19578
- setDrawerData(null);
19579
- setSelectedArrow(null);
19580
- }, []);
19581
- const handleBarClickForDrawer = useCallback(
19582
- (task, _event) => {
19583
- if (clientTaskBar == null ? void 0 : clientTaskBar.onClick) {
19584
- clientTaskBar.onClick(task);
19585
- }
19586
- if (enableDrawer) {
19587
- setDrawerData({ type: "task", task });
19588
- setSelectedArrow({ taskId: task.id });
19589
- }
19590
- },
19591
- [clientTaskBar == null ? void 0 : clientTaskBar.onClick, enableDrawer]
19592
- );
19593
- const handleArrowClickForDrawer = useCallback(
19594
- (taskFrom, taskTo) => {
19595
- if (onArrowClickProp) {
19596
- onArrowClickProp(taskFrom, taskTo);
19597
- }
19598
- if (enableDrawer) {
19599
- setDrawerData({ type: "connection", taskFrom, taskTo });
19600
- setSelectedArrow({ fromId: taskFrom.id, toId: taskTo.id });
19601
- }
19602
- },
19603
- [onArrowClickProp, enableDrawer]
19604
- );
19550
+ const [activeArrowKey, setActiveArrowKey] = useState(null);
19551
+ const [activeTaskId, setActiveTaskId] = useState(null);
19605
19552
  const taskBar = useMemo(() => {
19606
19553
  return mergeDeepObj(
19607
19554
  {},
@@ -20691,6 +20638,80 @@ const Gantt = (props) => {
20691
20638
  },
20692
20639
  [mapTaskToGlobalIndex, taskBar, handleCommitInternal, sortedTasks]
20693
20640
  );
20641
+ const onArrowClick = useCallback(
20642
+ (taskFrom, taskTo) => {
20643
+ if (enableDrawer) {
20644
+ setActiveArrowKey(`${taskFrom.id}|${taskTo.id}`);
20645
+ setActiveTaskId(null);
20646
+ setDrawerData({ type: "arrow", taskFrom, taskTo });
20647
+ }
20648
+ if (taskBar.onArrowClick) {
20649
+ taskBar.onArrowClick(taskFrom, taskTo);
20650
+ }
20651
+ },
20652
+ [enableDrawer, taskBar]
20653
+ );
20654
+ const handleTaskClick = useCallback(
20655
+ (task, _event) => {
20656
+ if (enableDrawer) {
20657
+ setActiveArrowKey(null);
20658
+ setActiveTaskId(task.id);
20659
+ setDrawerData({ type: "task", task });
20660
+ }
20661
+ if (taskBar.onClick) {
20662
+ taskBar.onClick(task);
20663
+ }
20664
+ },
20665
+ [enableDrawer, taskBar]
20666
+ );
20667
+ const handleDrawerClose = useCallback(() => {
20668
+ setDrawerData(null);
20669
+ setActiveArrowKey(null);
20670
+ setActiveTaskId(null);
20671
+ }, []);
20672
+ const handleGoToTask = useCallback(
20673
+ (taskId) => {
20674
+ for (const [comparisonLevel, levelMap] of tasksMap) {
20675
+ const task = levelMap.get(taskId);
20676
+ if (!task || task.type === "empty")
20677
+ continue;
20678
+ const { x1 } = getTaskCoordinates(task, mapTaskToCoordinates);
20679
+ setScrollXProgrammatically(Math.max(0, x1 - 100));
20680
+ const rowIndexMap = taskToRowIndexMap.get(comparisonLevel);
20681
+ if (rowIndexMap) {
20682
+ const rowIndex = rowIndexMap.get(taskId);
20683
+ if (typeof rowIndex === "number") {
20684
+ const targetScrollY = rowIndex * fullRowHeight - ganttHeight / 2 + fullRowHeight / 2;
20685
+ setScrollYProgrammatically(
20686
+ Math.max(
20687
+ 0,
20688
+ Math.min(targetScrollY, ganttFullHeight - ganttHeight)
20689
+ )
20690
+ );
20691
+ }
20692
+ }
20693
+ selectTask(taskId);
20694
+ if (onSelectTaskIds) {
20695
+ onSelectTaskIds([taskId]);
20696
+ }
20697
+ break;
20698
+ }
20699
+ handleDrawerClose();
20700
+ },
20701
+ [
20702
+ tasksMap,
20703
+ mapTaskToCoordinates,
20704
+ taskToRowIndexMap,
20705
+ fullRowHeight,
20706
+ ganttHeight,
20707
+ ganttFullHeight,
20708
+ setScrollXProgrammatically,
20709
+ setScrollYProgrammatically,
20710
+ selectTask,
20711
+ onSelectTaskIds,
20712
+ handleDrawerClose
20713
+ ]
20714
+ );
20694
20715
  const handleAction = useHandleAction({
20695
20716
  checkTaskIdExists,
20696
20717
  childTasksMap,
@@ -20877,6 +20898,7 @@ const Gantt = (props) => {
20877
20898
  const renderTaskBarProps = useMemo(
20878
20899
  () => ({
20879
20900
  ...taskBar,
20901
+ onClick: enableDrawer ? handleTaskClick : taskBar.onClick,
20880
20902
  taskBarMovingAction: (task) => {
20881
20903
  var _a2;
20882
20904
  return task.id === ((_a2 = changeInProgress == null ? void 0 : changeInProgress.changedTask) == null ? void 0 : _a2.id) ? changeInProgress.action : null;
@@ -20903,6 +20925,9 @@ const Gantt = (props) => {
20903
20925
  onTooltipTask: onChangeTooltipTask,
20904
20926
  mapGlobalRowIndexToTask,
20905
20927
  onArrowDoubleClick,
20928
+ onArrowClick: enableDrawer ? onArrowClick : taskBar.onArrowClick,
20929
+ activeArrowKey,
20930
+ activeTaskId,
20906
20931
  renderedRowIndexes,
20907
20932
  rtl,
20908
20933
  selectTaskOnMouseDown,
@@ -20914,10 +20939,7 @@ const Gantt = (props) => {
20914
20939
  visibleTasksMirror,
20915
20940
  viewMode,
20916
20941
  showProgress,
20917
- progressColor,
20918
- onArrowClick: enableDrawer ? handleArrowClickForDrawer : void 0,
20919
- onClick: enableDrawer ? handleBarClickForDrawer : taskBar.onClick,
20920
- selectedArrow
20942
+ progressColor
20921
20943
  }),
20922
20944
  [
20923
20945
  viewMode,
@@ -20943,6 +20965,11 @@ const Gantt = (props) => {
20943
20965
  onChangeTooltipTask,
20944
20966
  mapGlobalRowIndexToTask,
20945
20967
  onArrowDoubleClick,
20968
+ onArrowClick,
20969
+ activeArrowKey,
20970
+ activeTaskId,
20971
+ enableDrawer,
20972
+ handleTaskClick,
20946
20973
  renderedRowIndexes,
20947
20974
  rtl,
20948
20975
  selectTaskOnMouseDown,
@@ -20956,11 +20983,7 @@ const Gantt = (props) => {
20956
20983
  changeInProgress == null ? void 0 : changeInProgress.action,
20957
20984
  handleDeleteTasks,
20958
20985
  showProgress,
20959
- progressColor,
20960
- enableDrawer,
20961
- handleArrowClickForDrawer,
20962
- handleBarClickForDrawer,
20963
- selectedArrow
20986
+ progressColor
20964
20987
  ]
20965
20988
  );
20966
20989
  const renderTaskListProps = useMemo(
@@ -21117,10 +21140,10 @@ const Gantt = (props) => {
21117
21140
  enableDrawer && /* @__PURE__ */ jsx(
21118
21141
  GanttDrawer,
21119
21142
  {
21120
- open: drawerData !== null,
21121
- width: drawerWidth,
21122
21143
  data: drawerData,
21144
+ width: drawerWidth,
21123
21145
  onClose: handleDrawerClose,
21146
+ onGoToTask: handleGoToTask,
21124
21147
  renderContent: renderDrawerContent
21125
21148
  }
21126
21149
  )