gantt-task-react-v 1.4.6 → 1.4.7

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,8 @@ const TaskGanttContentInner = (props) => {
13165
13159
  onTaskBarDragStart,
13166
13160
  mapGlobalRowIndexToTask,
13167
13161
  onArrowDoubleClick,
13162
+ onArrowClick,
13163
+ activeArrowKey,
13168
13164
  onDoubleClick,
13169
13165
  onClick,
13170
13166
  renderedRowIndexes,
@@ -13186,9 +13182,7 @@ const TaskGanttContentInner = (props) => {
13186
13182
  waitCommitTasks,
13187
13183
  viewMode,
13188
13184
  showProgress = true,
13189
- progressColor,
13190
- onArrowClick,
13191
- selectedArrow
13185
+ progressColor
13192
13186
  } = props;
13193
13187
  const renderedHolidays = useMemo(() => {
13194
13188
  const { columnWidth } = distances;
@@ -13471,6 +13465,7 @@ const TaskGanttContentInner = (props) => {
13471
13465
  rtl,
13472
13466
  onArrowDoubleClick,
13473
13467
  onArrowClick,
13468
+ isActive: activeArrowKey === `${source.id}|${taskId}`,
13474
13469
  fromConnectionIndex: getConnectionIndex(
13475
13470
  `${source.id}|${sourceTarget}|out`
13476
13471
  ),
@@ -13556,6 +13551,7 @@ const TaskGanttContentInner = (props) => {
13556
13551
  rtl,
13557
13552
  onArrowDoubleClick,
13558
13553
  onArrowClick,
13554
+ isActive: activeArrowKey === `${taskId}|${dependent.id}`,
13559
13555
  fromConnectionIndex: getConnectionIndex(
13560
13556
  `${taskId}|${ownTarget}|out`
13561
13557
  ),
@@ -13654,6 +13650,7 @@ const TaskGanttContentInner = (props) => {
13654
13650
  rtl,
13655
13651
  onArrowDoubleClick,
13656
13652
  onArrowClick,
13653
+ isActive: activeArrowKey === `${source.id}|${taskId}`,
13657
13654
  fromConnectionIndex: getConnectionIndex(
13658
13655
  `${source.id}|${sourceTarget}|out`
13659
13656
  ),
@@ -13712,80 +13709,11 @@ const TaskGanttContentInner = (props) => {
13712
13709
  visibleTasksMirror,
13713
13710
  onArrowDoubleClick,
13714
13711
  onArrowClick,
13712
+ activeArrowKey,
13715
13713
  showProgress,
13716
13714
  progressColor
13717
13715
  ]);
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: [
13716
+ return /* @__PURE__ */ jsxs("g", { className: "content", children: [
13789
13717
  renderedSelectedTasks,
13790
13718
  /* @__PURE__ */ jsx("g", { children: renderedHolidays }),
13791
13719
  /* @__PURE__ */ jsx(
@@ -16341,13 +16269,13 @@ function getWindowScrollBarX(element) {
16341
16269
  function getDocumentRect(element) {
16342
16270
  const html = getDocumentElement(element);
16343
16271
  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);
16272
+ const body2 = element.ownerDocument.body;
16273
+ const width = max(html.scrollWidth, html.clientWidth, body2.scrollWidth, body2.clientWidth);
16274
+ const height = max(html.scrollHeight, html.clientHeight, body2.scrollHeight, body2.clientHeight);
16347
16275
  let x = -scroll2.scrollLeft + getWindowScrollBarX(element);
16348
16276
  const y = -scroll2.scrollTop;
16349
- if (getComputedStyle$1(body).direction === "rtl") {
16350
- x += max(html.clientWidth, body.clientWidth) - width;
16277
+ if (getComputedStyle$1(body2).direction === "rtl") {
16278
+ x += max(html.clientWidth, body2.clientWidth) - width;
16351
16279
  }
16352
16280
  return {
16353
16281
  width,
@@ -19402,110 +19330,72 @@ const GanttLoaderInner = ({ loading }) => {
19402
19330
  return /* @__PURE__ */ jsx("div", { className: `${styles$1.loader} ${loading ? "" : styles$1.loaderHidden}` });
19403
19331
  };
19404
19332
  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";
19333
+ const overlay = "_overlay_1rnqn_1";
19334
+ const drawer = "_drawer_1rnqn_19";
19335
+ const drawer_open = "_drawer_open_1rnqn_51";
19336
+ const header = "_header_1rnqn_59";
19337
+ const title = "_title_1rnqn_77";
19338
+ const closeButton = "_closeButton_1rnqn_97";
19339
+ const body = "_body_1rnqn_131";
19414
19340
  const styles = {
19415
- drawerOverlay,
19341
+ overlay,
19416
19342
  drawer,
19417
- slideIn,
19418
- drawerHeader,
19343
+ drawer_open,
19344
+ header,
19345
+ title,
19419
19346
  closeButton,
19420
- drawerContent,
19421
- defaultSection,
19422
- defaultField,
19423
- defaultFieldLabel
19424
- };
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;
19347
+ body
19486
19348
  };
19487
- const GanttDrawer = ({
19488
- open,
19489
- width,
19349
+ const GanttDrawerInner = ({
19490
19350
  data,
19351
+ width,
19491
19352
  onClose,
19492
19353
  renderContent
19493
19354
  }) => {
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",
19355
+ const handleOverlayClick = useCallback(
19356
+ (e) => {
19357
+ e.stopPropagation();
19358
+ onClose();
19359
+ },
19360
+ [onClose]
19361
+ );
19362
+ 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}` : "";
19363
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
19364
+ data && /* @__PURE__ */ jsx("div", { className: styles.overlay, onClick: handleOverlayClick }),
19365
+ /* @__PURE__ */ jsxs(
19366
+ "div",
19499
19367
  {
19500
- className: styles.closeButton,
19501
- onClick: onClose,
19502
- "aria-label": "Close drawer",
19503
- children: "×"
19368
+ className: `${styles.drawer}${data ? ` ${styles.drawer_open}` : ""}`,
19369
+ style: { width },
19370
+ children: [
19371
+ /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
19372
+ /* @__PURE__ */ jsx("span", { className: styles.title, children: title2 }),
19373
+ /* @__PURE__ */ jsx(
19374
+ "button",
19375
+ {
19376
+ className: styles.closeButton,
19377
+ onClick: onClose,
19378
+ "aria-label": "Close drawer",
19379
+ type: "button",
19380
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx(
19381
+ "path",
19382
+ {
19383
+ d: "M12 4L4 12M4 4l8 8",
19384
+ stroke: "currentColor",
19385
+ strokeWidth: "1.5",
19386
+ strokeLinecap: "round"
19387
+ }
19388
+ ) })
19389
+ }
19390
+ )
19391
+ ] }),
19392
+ /* @__PURE__ */ jsx("div", { className: styles.body, children: data && renderContent ? renderContent(data) : null })
19393
+ ]
19504
19394
  }
19505
- ) }),
19506
- /* @__PURE__ */ jsx("div", { className: styles.drawerContent, children: renderContent ? renderContent(data) : /* @__PURE__ */ jsx(DefaultDrawerContent, { data }) })
19507
- ] }) });
19395
+ )
19396
+ ] });
19508
19397
  };
19398
+ const GanttDrawer = memo(GanttDrawerInner);
19509
19399
  const Gantt = (props) => {
19510
19400
  var _a, _b;
19511
19401
  const {
@@ -19552,10 +19442,7 @@ const Gantt = (props) => {
19552
19442
  showProgress = true,
19553
19443
  progressColor,
19554
19444
  scrollToTaskId,
19555
- enableDrawer = false,
19556
- drawerWidth = 300,
19557
- renderDrawerContent,
19558
- onArrowClick: onArrowClickProp
19445
+ drawer: drawerProps
19559
19446
  } = props;
19560
19447
  const ganttSVGRef = useRef(null);
19561
19448
  const wrapperRef = useRef(null);
@@ -19572,36 +19459,11 @@ const Gantt = (props) => {
19572
19459
  [theme, rowHeight]
19573
19460
  );
19574
19461
  const [waitCommitTasks, setWaitCommitTasks] = useState(false);
19462
+ const enableDrawer = (drawerProps == null ? void 0 : drawerProps.enableDrawer) ?? false;
19463
+ const drawerWidth = (drawerProps == null ? void 0 : drawerProps.drawerWidth) ?? 360;
19464
+ const renderDrawerContent = drawerProps == null ? void 0 : drawerProps.renderDrawerContent;
19575
19465
  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
- );
19466
+ const [activeArrowKey, setActiveArrowKey] = useState(null);
19605
19467
  const taskBar = useMemo(() => {
19606
19468
  return mergeDeepObj(
19607
19469
  {},
@@ -20691,6 +20553,34 @@ const Gantt = (props) => {
20691
20553
  },
20692
20554
  [mapTaskToGlobalIndex, taskBar, handleCommitInternal, sortedTasks]
20693
20555
  );
20556
+ const onArrowClick = useCallback(
20557
+ (taskFrom, taskTo) => {
20558
+ if (enableDrawer) {
20559
+ setActiveArrowKey(`${taskFrom.id}|${taskTo.id}`);
20560
+ setDrawerData({ type: "arrow", taskFrom, taskTo });
20561
+ }
20562
+ if (taskBar.onArrowClick) {
20563
+ taskBar.onArrowClick(taskFrom, taskTo);
20564
+ }
20565
+ },
20566
+ [enableDrawer, taskBar]
20567
+ );
20568
+ const handleTaskClick = useCallback(
20569
+ (task, _event) => {
20570
+ if (enableDrawer) {
20571
+ setActiveArrowKey(null);
20572
+ setDrawerData({ type: "task", task });
20573
+ }
20574
+ if (taskBar.onClick) {
20575
+ taskBar.onClick(task);
20576
+ }
20577
+ },
20578
+ [enableDrawer, taskBar]
20579
+ );
20580
+ const handleDrawerClose = useCallback(() => {
20581
+ setDrawerData(null);
20582
+ setActiveArrowKey(null);
20583
+ }, []);
20694
20584
  const handleAction = useHandleAction({
20695
20585
  checkTaskIdExists,
20696
20586
  childTasksMap,
@@ -20877,6 +20767,7 @@ const Gantt = (props) => {
20877
20767
  const renderTaskBarProps = useMemo(
20878
20768
  () => ({
20879
20769
  ...taskBar,
20770
+ onClick: enableDrawer ? handleTaskClick : taskBar.onClick,
20880
20771
  taskBarMovingAction: (task) => {
20881
20772
  var _a2;
20882
20773
  return task.id === ((_a2 = changeInProgress == null ? void 0 : changeInProgress.changedTask) == null ? void 0 : _a2.id) ? changeInProgress.action : null;
@@ -20903,6 +20794,8 @@ const Gantt = (props) => {
20903
20794
  onTooltipTask: onChangeTooltipTask,
20904
20795
  mapGlobalRowIndexToTask,
20905
20796
  onArrowDoubleClick,
20797
+ onArrowClick: enableDrawer ? onArrowClick : taskBar.onArrowClick,
20798
+ activeArrowKey,
20906
20799
  renderedRowIndexes,
20907
20800
  rtl,
20908
20801
  selectTaskOnMouseDown,
@@ -20914,10 +20807,7 @@ const Gantt = (props) => {
20914
20807
  visibleTasksMirror,
20915
20808
  viewMode,
20916
20809
  showProgress,
20917
- progressColor,
20918
- onArrowClick: enableDrawer ? handleArrowClickForDrawer : void 0,
20919
- onClick: enableDrawer ? handleBarClickForDrawer : taskBar.onClick,
20920
- selectedArrow
20810
+ progressColor
20921
20811
  }),
20922
20812
  [
20923
20813
  viewMode,
@@ -20943,6 +20833,10 @@ const Gantt = (props) => {
20943
20833
  onChangeTooltipTask,
20944
20834
  mapGlobalRowIndexToTask,
20945
20835
  onArrowDoubleClick,
20836
+ onArrowClick,
20837
+ activeArrowKey,
20838
+ enableDrawer,
20839
+ handleTaskClick,
20946
20840
  renderedRowIndexes,
20947
20841
  rtl,
20948
20842
  selectTaskOnMouseDown,
@@ -20956,11 +20850,7 @@ const Gantt = (props) => {
20956
20850
  changeInProgress == null ? void 0 : changeInProgress.action,
20957
20851
  handleDeleteTasks,
20958
20852
  showProgress,
20959
- progressColor,
20960
- enableDrawer,
20961
- handleArrowClickForDrawer,
20962
- handleBarClickForDrawer,
20963
- selectedArrow
20853
+ progressColor
20964
20854
  ]
20965
20855
  );
20966
20856
  const renderTaskListProps = useMemo(
@@ -21117,9 +21007,8 @@ const Gantt = (props) => {
21117
21007
  enableDrawer && /* @__PURE__ */ jsx(
21118
21008
  GanttDrawer,
21119
21009
  {
21120
- open: drawerData !== null,
21121
- width: drawerWidth,
21122
21010
  data: drawerData,
21011
+ width: drawerWidth,
21123
21012
  onClose: handleDrawerClose,
21124
21013
  renderContent: renderDrawerContent
21125
21014
  }