gantt-task-react-v 1.1.14 → 1.1.16

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.
@@ -15621,7 +15621,7 @@ function isOverflowElement(element) {
15621
15621
  overflowX,
15622
15622
  overflowY,
15623
15623
  display
15624
- } = getComputedStyle(element);
15624
+ } = getComputedStyle$1(element);
15625
15625
  return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
15626
15626
  }
15627
15627
  function isTableElement(element) {
@@ -15629,7 +15629,7 @@ function isTableElement(element) {
15629
15629
  }
15630
15630
  function isContainingBlock(element) {
15631
15631
  const webkit = isWebKit();
15632
- const css = getComputedStyle(element);
15632
+ const css = getComputedStyle$1(element);
15633
15633
  return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
15634
15634
  }
15635
15635
  function getContainingBlock(element) {
@@ -15651,7 +15651,7 @@ function isWebKit() {
15651
15651
  function isLastTraversableNode(node) {
15652
15652
  return ["html", "body", "#document"].includes(getNodeName(node));
15653
15653
  }
15654
- function getComputedStyle(element) {
15654
+ function getComputedStyle$1(element) {
15655
15655
  return getWindow(element).getComputedStyle(element);
15656
15656
  }
15657
15657
  function getNodeScroll(element) {
@@ -15706,7 +15706,7 @@ function getOverflowAncestors(node, list, traverseIframes) {
15706
15706
  return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
15707
15707
  }
15708
15708
  function getCssDimensions(element) {
15709
- const css = getComputedStyle(element);
15709
+ const css = getComputedStyle$1(element);
15710
15710
  let width = parseFloat(css.width) || 0;
15711
15711
  let height = parseFloat(css.height) || 0;
15712
15712
  const hasOffset = isHTMLElement(element);
@@ -15802,7 +15802,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
15802
15802
  while (currentIFrame && offsetParent && offsetWin !== currentWin) {
15803
15803
  const iframeScale = getScale(currentIFrame);
15804
15804
  const iframeRect = currentIFrame.getBoundingClientRect();
15805
- const css = getComputedStyle(currentIFrame);
15805
+ const css = getComputedStyle$1(currentIFrame);
15806
15806
  const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
15807
15807
  const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
15808
15808
  x *= iframeScale.x;
@@ -15884,7 +15884,7 @@ function getDocumentRect(element) {
15884
15884
  const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
15885
15885
  let x = -scroll2.scrollLeft + getWindowScrollBarX(element);
15886
15886
  const y = -scroll2.scrollTop;
15887
- if (getComputedStyle(body).direction === "rtl") {
15887
+ if (getComputedStyle$1(body).direction === "rtl") {
15888
15888
  x += max(html.clientWidth, body.clientWidth) - width;
15889
15889
  }
15890
15890
  return {
@@ -15957,7 +15957,7 @@ function hasFixedPositionAncestor(element, stopNode) {
15957
15957
  if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
15958
15958
  return false;
15959
15959
  }
15960
- return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
15960
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
15961
15961
  }
15962
15962
  function getClippingElementAncestors(element, cache) {
15963
15963
  const cachedResult = cache.get(element);
@@ -15966,10 +15966,10 @@ function getClippingElementAncestors(element, cache) {
15966
15966
  }
15967
15967
  let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
15968
15968
  let currentContainingBlockComputedStyle = null;
15969
- const elementIsFixed = getComputedStyle(element).position === "fixed";
15969
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
15970
15970
  let currentNode = elementIsFixed ? getParentNode(element) : element;
15971
15971
  while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
15972
- const computedStyle = getComputedStyle(currentNode);
15972
+ const computedStyle = getComputedStyle$1(currentNode);
15973
15973
  const currentNodeIsContaining = isContainingBlock(currentNode);
15974
15974
  if (!currentNodeIsContaining && computedStyle.position === "fixed") {
15975
15975
  currentContainingBlockComputedStyle = null;
@@ -16052,7 +16052,7 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
16052
16052
  };
16053
16053
  }
16054
16054
  function getTrueOffsetParent(element, polyfill) {
16055
- if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
16055
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
16056
16056
  return null;
16057
16057
  }
16058
16058
  if (polyfill) {
@@ -16066,10 +16066,10 @@ function getOffsetParent(element, polyfill) {
16066
16066
  return window2;
16067
16067
  }
16068
16068
  let offsetParent = getTrueOffsetParent(element, polyfill);
16069
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
16069
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
16070
16070
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
16071
16071
  }
16072
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
16072
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
16073
16073
  return window2;
16074
16074
  }
16075
16075
  return offsetParent || getContainingBlock(element) || window2;
@@ -16087,7 +16087,7 @@ const getElementRects = async function(data) {
16087
16087
  };
16088
16088
  };
16089
16089
  function isRTL(element) {
16090
- return getComputedStyle(element).direction === "rtl";
16090
+ return getComputedStyle$1(element).direction === "rtl";
16091
16091
  }
16092
16092
  const platform = {
16093
16093
  convertOffsetParentRelativeRectToViewportRelativeRect,
@@ -16788,7 +16788,7 @@ function useDismiss(context, props) {
16788
16788
  const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
16789
16789
  let xCond = canScrollY && event.offsetX > target.clientWidth;
16790
16790
  if (canScrollY) {
16791
- const isRTL2 = getComputedStyle(target).direction === "rtl";
16791
+ const isRTL2 = getComputedStyle$1(target).direction === "rtl";
16792
16792
  if (isRTL2) {
16793
16793
  xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
16794
16794
  }
@@ -18113,7 +18113,7 @@ function ContextMenu(props) {
18113
18113
  handleCloseContextMenu();
18114
18114
  }
18115
18115
  },
18116
- strategy: "absolute",
18116
+ strategy: "fixed",
18117
18117
  placement: "bottom-start",
18118
18118
  middleware: [
18119
18119
  flip(),
@@ -18138,73 +18138,116 @@ function ContextMenu(props) {
18138
18138
  dismiss,
18139
18139
  role
18140
18140
  ]);
18141
- const floatingRef = useRef();
18141
+ const floatingRef = useRef(null);
18142
18142
  const setFloatingRef = useCallback(
18143
18143
  (el) => {
18144
- floatingRef.current = el || void 0;
18144
+ floatingRef.current = el;
18145
18145
  setFloating(el);
18146
18146
  },
18147
18147
  [setFloating]
18148
18148
  );
18149
- return /* @__PURE__ */ jsxs(Fragment, { children: [
18150
- /* @__PURE__ */ jsx(
18151
- "div",
18152
- {
18153
- ...getReferenceProps(),
18154
- style: {
18155
- position: "absolute",
18156
- left: x,
18157
- top: y,
18158
- zIndex: 1
18159
- },
18160
- ref: setReference
18149
+ useEffect(() => {
18150
+ var _a2;
18151
+ if (!task)
18152
+ return;
18153
+ const cssVars = [
18154
+ "--gantt-context-menu-bg-color",
18155
+ "--gantt-context-menu-box-shadow",
18156
+ "--gantt-shape-border-radius",
18157
+ "--gantt-font-family",
18158
+ "--gantt-font-size",
18159
+ "--gantt-context-menu-empty-color"
18160
+ ];
18161
+ const refEl = ((_a2 = refs == null ? void 0 : refs.reference) == null ? void 0 : _a2.current) ?? null;
18162
+ const sourceEl = refEl || (typeof document !== "undefined" ? document.body : null);
18163
+ if (!sourceEl || !floatingRef.current)
18164
+ return;
18165
+ const cs = getComputedStyle(sourceEl);
18166
+ cssVars.forEach((v) => {
18167
+ const val = cs.getPropertyValue(v).trim();
18168
+ if (val) {
18169
+ floatingRef.current.style.setProperty(v, val);
18161
18170
  }
18162
- ),
18163
- task && /* @__PURE__ */ jsxs(
18164
- "div",
18165
- {
18166
- ref: setFloatingRef,
18167
- style: {
18168
- position: strategy,
18169
- top: menuY ?? 0,
18170
- left: menuX ?? 0,
18171
- width: "max-content",
18172
- backgroundColor: "var(--gantt-context-menu-bg-color)",
18173
- boxShadow: "var(--gantt-context-menu-box-shadow)",
18174
- borderRadius: "var(--gantt-shape-border-radius)",
18175
- fontFamily: "var(--gantt-font-family)",
18176
- display: "flex",
18177
- flexDirection: "column",
18178
- overflow: "hidden",
18179
- gap: 6,
18180
- zIndex: 10
18181
- },
18182
- ...getFloatingProps(),
18183
- children: [
18184
- optionsForRender.map((option, index2) => /* @__PURE__ */ jsx(
18185
- MenuOption,
18186
- {
18187
- onClose: handleCloseContextMenu,
18188
- distances,
18189
- handleAction: handleOptionAction,
18190
- option
18171
+ });
18172
+ }, [task, refs, menuX, menuY]);
18173
+ let viewportX = x;
18174
+ let viewportY = y;
18175
+ if (typeof document !== "undefined") {
18176
+ const ganttWrapper = document.querySelector(
18177
+ '[data-testid="gantt"]'
18178
+ );
18179
+ if (ganttWrapper) {
18180
+ const rect = ganttWrapper.getBoundingClientRect();
18181
+ viewportX = rect.left + x;
18182
+ viewportY = rect.top + y;
18183
+ }
18184
+ }
18185
+ const referenceNode = /* @__PURE__ */ jsx(
18186
+ "div",
18187
+ {
18188
+ ...getReferenceProps(),
18189
+ style: {
18190
+ position: "fixed",
18191
+ left: viewportX,
18192
+ top: viewportY,
18193
+ zIndex: 1,
18194
+ pointerEvents: "none"
18195
+ },
18196
+ ref: setReference
18197
+ }
18198
+ );
18199
+ const menuNode = /* @__PURE__ */ jsxs(
18200
+ "div",
18201
+ {
18202
+ ref: setFloatingRef,
18203
+ style: {
18204
+ position: strategy,
18205
+ top: menuY ?? 0,
18206
+ left: menuX ?? 0,
18207
+ width: "max-content",
18208
+ backgroundColor: "var(--gantt-context-menu-bg-color)",
18209
+ boxShadow: "var(--gantt-context-menu-box-shadow)",
18210
+ borderRadius: "var(--gantt-shape-border-radius)",
18211
+ fontFamily: "var(--gantt-font-family)",
18212
+ display: "flex",
18213
+ flexDirection: "column",
18214
+ // Allow the menu to scroll if it would otherwise overflow the viewport
18215
+ maxHeight: "calc(100vh - 24px)",
18216
+ overflowY: "auto",
18217
+ overflowX: "hidden",
18218
+ gap: 6,
18219
+ zIndex: 1e4,
18220
+ pointerEvents: "auto"
18221
+ },
18222
+ ...getFloatingProps(),
18223
+ children: [
18224
+ optionsForRender.map((option, index2) => /* @__PURE__ */ jsx(
18225
+ MenuOption,
18226
+ {
18227
+ onClose: handleCloseContextMenu,
18228
+ distances,
18229
+ handleAction: handleOptionAction,
18230
+ option
18231
+ },
18232
+ index2
18233
+ )),
18234
+ optionsForRender.length === 0 && /* @__PURE__ */ jsx(
18235
+ "div",
18236
+ {
18237
+ style: {
18238
+ padding: "6px 12px",
18239
+ color: "var(--gantt-context-menu-empty-color, #666)",
18240
+ fontSize: "var(--gantt-font-size)"
18191
18241
  },
18192
- index2
18193
- )),
18194
- optionsForRender.length === 0 && /* @__PURE__ */ jsx(
18195
- "div",
18196
- {
18197
- style: {
18198
- padding: "6px 12px",
18199
- color: "var(--gantt-context-menu-empty-color, #666)",
18200
- fontSize: "var(--gantt-font-size)"
18201
- },
18202
- children: "—"
18203
- }
18204
- )
18205
- ]
18206
- }
18207
- )
18242
+ children: "—"
18243
+ }
18244
+ )
18245
+ ]
18246
+ }
18247
+ );
18248
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
18249
+ referenceNode,
18250
+ task && typeof document !== "undefined" ? createPortal(menuNode, document.body) : task && menuNode
18208
18251
  ] });
18209
18252
  }
18210
18253
  const getParentTasks = (selectedTasks, tasksMap) => {
@@ -19942,12 +19985,18 @@ const Gantt = (props) => {
19942
19985
  } catch (err) {
19943
19986
  console.error(err);
19944
19987
  }
19945
- if (task && task.type !== "empty" && contextMenuOptions.length > 0) {
19988
+ if (task && task.type !== "empty" && contextMenuOptions.length > 0 && !selectedIdsMirror[task.id]) {
19946
19989
  selectTask(task.id);
19947
19990
  }
19948
19991
  handleOpenContextMenu(task, clientX, clientY, contextMenuOptions);
19949
19992
  },
19950
- [onRowContextMenu, handleOpenContextMenu, selectTask, contextMenuOptions]
19993
+ [
19994
+ onRowContextMenu,
19995
+ handleOpenContextMenu,
19996
+ selectTask,
19997
+ contextMenuOptions,
19998
+ selectedIdsMirror
19999
+ ]
19951
20000
  );
19952
20001
  const ganttContextMenuOptions = useMemo(() => {
19953
20002
  if (taskBar.taskGanttContextMenuOption) {
@@ -15638,7 +15638,7 @@
15638
15638
  overflowX,
15639
15639
  overflowY,
15640
15640
  display
15641
- } = getComputedStyle(element);
15641
+ } = getComputedStyle$1(element);
15642
15642
  return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
15643
15643
  }
15644
15644
  function isTableElement(element) {
@@ -15646,7 +15646,7 @@
15646
15646
  }
15647
15647
  function isContainingBlock(element) {
15648
15648
  const webkit = isWebKit();
15649
- const css = getComputedStyle(element);
15649
+ const css = getComputedStyle$1(element);
15650
15650
  return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
15651
15651
  }
15652
15652
  function getContainingBlock(element) {
@@ -15668,7 +15668,7 @@
15668
15668
  function isLastTraversableNode(node) {
15669
15669
  return ["html", "body", "#document"].includes(getNodeName(node));
15670
15670
  }
15671
- function getComputedStyle(element) {
15671
+ function getComputedStyle$1(element) {
15672
15672
  return getWindow(element).getComputedStyle(element);
15673
15673
  }
15674
15674
  function getNodeScroll(element) {
@@ -15723,7 +15723,7 @@
15723
15723
  return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
15724
15724
  }
15725
15725
  function getCssDimensions(element) {
15726
- const css = getComputedStyle(element);
15726
+ const css = getComputedStyle$1(element);
15727
15727
  let width = parseFloat(css.width) || 0;
15728
15728
  let height = parseFloat(css.height) || 0;
15729
15729
  const hasOffset = isHTMLElement(element);
@@ -15819,7 +15819,7 @@
15819
15819
  while (currentIFrame && offsetParent && offsetWin !== currentWin) {
15820
15820
  const iframeScale = getScale(currentIFrame);
15821
15821
  const iframeRect = currentIFrame.getBoundingClientRect();
15822
- const css = getComputedStyle(currentIFrame);
15822
+ const css = getComputedStyle$1(currentIFrame);
15823
15823
  const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
15824
15824
  const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
15825
15825
  x *= iframeScale.x;
@@ -15901,7 +15901,7 @@
15901
15901
  const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
15902
15902
  let x = -scroll2.scrollLeft + getWindowScrollBarX(element);
15903
15903
  const y = -scroll2.scrollTop;
15904
- if (getComputedStyle(body).direction === "rtl") {
15904
+ if (getComputedStyle$1(body).direction === "rtl") {
15905
15905
  x += max(html.clientWidth, body.clientWidth) - width;
15906
15906
  }
15907
15907
  return {
@@ -15974,7 +15974,7 @@
15974
15974
  if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
15975
15975
  return false;
15976
15976
  }
15977
- return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
15977
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
15978
15978
  }
15979
15979
  function getClippingElementAncestors(element, cache) {
15980
15980
  const cachedResult = cache.get(element);
@@ -15983,10 +15983,10 @@
15983
15983
  }
15984
15984
  let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
15985
15985
  let currentContainingBlockComputedStyle = null;
15986
- const elementIsFixed = getComputedStyle(element).position === "fixed";
15986
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
15987
15987
  let currentNode = elementIsFixed ? getParentNode(element) : element;
15988
15988
  while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
15989
- const computedStyle = getComputedStyle(currentNode);
15989
+ const computedStyle = getComputedStyle$1(currentNode);
15990
15990
  const currentNodeIsContaining = isContainingBlock(currentNode);
15991
15991
  if (!currentNodeIsContaining && computedStyle.position === "fixed") {
15992
15992
  currentContainingBlockComputedStyle = null;
@@ -16069,7 +16069,7 @@
16069
16069
  };
16070
16070
  }
16071
16071
  function getTrueOffsetParent(element, polyfill) {
16072
- if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
16072
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
16073
16073
  return null;
16074
16074
  }
16075
16075
  if (polyfill) {
@@ -16083,10 +16083,10 @@
16083
16083
  return window2;
16084
16084
  }
16085
16085
  let offsetParent = getTrueOffsetParent(element, polyfill);
16086
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
16086
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
16087
16087
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
16088
16088
  }
16089
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
16089
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
16090
16090
  return window2;
16091
16091
  }
16092
16092
  return offsetParent || getContainingBlock(element) || window2;
@@ -16104,7 +16104,7 @@
16104
16104
  };
16105
16105
  };
16106
16106
  function isRTL(element) {
16107
- return getComputedStyle(element).direction === "rtl";
16107
+ return getComputedStyle$1(element).direction === "rtl";
16108
16108
  }
16109
16109
  const platform = {
16110
16110
  convertOffsetParentRelativeRectToViewportRelativeRect,
@@ -16805,7 +16805,7 @@
16805
16805
  const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
16806
16806
  let xCond = canScrollY && event.offsetX > target.clientWidth;
16807
16807
  if (canScrollY) {
16808
- const isRTL2 = getComputedStyle(target).direction === "rtl";
16808
+ const isRTL2 = getComputedStyle$1(target).direction === "rtl";
16809
16809
  if (isRTL2) {
16810
16810
  xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
16811
16811
  }
@@ -18130,7 +18130,7 @@
18130
18130
  handleCloseContextMenu();
18131
18131
  }
18132
18132
  },
18133
- strategy: "absolute",
18133
+ strategy: "fixed",
18134
18134
  placement: "bottom-start",
18135
18135
  middleware: [
18136
18136
  flip(),
@@ -18155,73 +18155,116 @@
18155
18155
  dismiss,
18156
18156
  role
18157
18157
  ]);
18158
- const floatingRef = React.useRef();
18158
+ const floatingRef = React.useRef(null);
18159
18159
  const setFloatingRef = React.useCallback(
18160
18160
  (el) => {
18161
- floatingRef.current = el || void 0;
18161
+ floatingRef.current = el;
18162
18162
  setFloating(el);
18163
18163
  },
18164
18164
  [setFloating]
18165
18165
  );
18166
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18167
- /* @__PURE__ */ jsxRuntime.jsx(
18168
- "div",
18169
- {
18170
- ...getReferenceProps(),
18171
- style: {
18172
- position: "absolute",
18173
- left: x,
18174
- top: y,
18175
- zIndex: 1
18176
- },
18177
- ref: setReference
18166
+ React.useEffect(() => {
18167
+ var _a2;
18168
+ if (!task)
18169
+ return;
18170
+ const cssVars = [
18171
+ "--gantt-context-menu-bg-color",
18172
+ "--gantt-context-menu-box-shadow",
18173
+ "--gantt-shape-border-radius",
18174
+ "--gantt-font-family",
18175
+ "--gantt-font-size",
18176
+ "--gantt-context-menu-empty-color"
18177
+ ];
18178
+ const refEl = ((_a2 = refs == null ? void 0 : refs.reference) == null ? void 0 : _a2.current) ?? null;
18179
+ const sourceEl = refEl || (typeof document !== "undefined" ? document.body : null);
18180
+ if (!sourceEl || !floatingRef.current)
18181
+ return;
18182
+ const cs = getComputedStyle(sourceEl);
18183
+ cssVars.forEach((v) => {
18184
+ const val = cs.getPropertyValue(v).trim();
18185
+ if (val) {
18186
+ floatingRef.current.style.setProperty(v, val);
18178
18187
  }
18179
- ),
18180
- task && /* @__PURE__ */ jsxRuntime.jsxs(
18181
- "div",
18182
- {
18183
- ref: setFloatingRef,
18184
- style: {
18185
- position: strategy,
18186
- top: menuY ?? 0,
18187
- left: menuX ?? 0,
18188
- width: "max-content",
18189
- backgroundColor: "var(--gantt-context-menu-bg-color)",
18190
- boxShadow: "var(--gantt-context-menu-box-shadow)",
18191
- borderRadius: "var(--gantt-shape-border-radius)",
18192
- fontFamily: "var(--gantt-font-family)",
18193
- display: "flex",
18194
- flexDirection: "column",
18195
- overflow: "hidden",
18196
- gap: 6,
18197
- zIndex: 10
18198
- },
18199
- ...getFloatingProps(),
18200
- children: [
18201
- optionsForRender.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
18202
- MenuOption,
18203
- {
18204
- onClose: handleCloseContextMenu,
18205
- distances,
18206
- handleAction: handleOptionAction,
18207
- option
18188
+ });
18189
+ }, [task, refs, menuX, menuY]);
18190
+ let viewportX = x;
18191
+ let viewportY = y;
18192
+ if (typeof document !== "undefined") {
18193
+ const ganttWrapper = document.querySelector(
18194
+ '[data-testid="gantt"]'
18195
+ );
18196
+ if (ganttWrapper) {
18197
+ const rect = ganttWrapper.getBoundingClientRect();
18198
+ viewportX = rect.left + x;
18199
+ viewportY = rect.top + y;
18200
+ }
18201
+ }
18202
+ const referenceNode = /* @__PURE__ */ jsxRuntime.jsx(
18203
+ "div",
18204
+ {
18205
+ ...getReferenceProps(),
18206
+ style: {
18207
+ position: "fixed",
18208
+ left: viewportX,
18209
+ top: viewportY,
18210
+ zIndex: 1,
18211
+ pointerEvents: "none"
18212
+ },
18213
+ ref: setReference
18214
+ }
18215
+ );
18216
+ const menuNode = /* @__PURE__ */ jsxRuntime.jsxs(
18217
+ "div",
18218
+ {
18219
+ ref: setFloatingRef,
18220
+ style: {
18221
+ position: strategy,
18222
+ top: menuY ?? 0,
18223
+ left: menuX ?? 0,
18224
+ width: "max-content",
18225
+ backgroundColor: "var(--gantt-context-menu-bg-color)",
18226
+ boxShadow: "var(--gantt-context-menu-box-shadow)",
18227
+ borderRadius: "var(--gantt-shape-border-radius)",
18228
+ fontFamily: "var(--gantt-font-family)",
18229
+ display: "flex",
18230
+ flexDirection: "column",
18231
+ // Allow the menu to scroll if it would otherwise overflow the viewport
18232
+ maxHeight: "calc(100vh - 24px)",
18233
+ overflowY: "auto",
18234
+ overflowX: "hidden",
18235
+ gap: 6,
18236
+ zIndex: 1e4,
18237
+ pointerEvents: "auto"
18238
+ },
18239
+ ...getFloatingProps(),
18240
+ children: [
18241
+ optionsForRender.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
18242
+ MenuOption,
18243
+ {
18244
+ onClose: handleCloseContextMenu,
18245
+ distances,
18246
+ handleAction: handleOptionAction,
18247
+ option
18248
+ },
18249
+ index2
18250
+ )),
18251
+ optionsForRender.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
18252
+ "div",
18253
+ {
18254
+ style: {
18255
+ padding: "6px 12px",
18256
+ color: "var(--gantt-context-menu-empty-color, #666)",
18257
+ fontSize: "var(--gantt-font-size)"
18208
18258
  },
18209
- index2
18210
- )),
18211
- optionsForRender.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
18212
- "div",
18213
- {
18214
- style: {
18215
- padding: "6px 12px",
18216
- color: "var(--gantt-context-menu-empty-color, #666)",
18217
- fontSize: "var(--gantt-font-size)"
18218
- },
18219
- children: "—"
18220
- }
18221
- )
18222
- ]
18223
- }
18224
- )
18259
+ children: "—"
18260
+ }
18261
+ )
18262
+ ]
18263
+ }
18264
+ );
18265
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18266
+ referenceNode,
18267
+ task && typeof document !== "undefined" ? ReactDOM.createPortal(menuNode, document.body) : task && menuNode
18225
18268
  ] });
18226
18269
  }
18227
18270
  const getParentTasks = (selectedTasks, tasksMap) => {
@@ -19959,12 +20002,18 @@
19959
20002
  } catch (err) {
19960
20003
  console.error(err);
19961
20004
  }
19962
- if (task && task.type !== "empty" && contextMenuOptions.length > 0) {
20005
+ if (task && task.type !== "empty" && contextMenuOptions.length > 0 && !selectedIdsMirror[task.id]) {
19963
20006
  selectTask(task.id);
19964
20007
  }
19965
20008
  handleOpenContextMenu(task, clientX, clientY, contextMenuOptions);
19966
20009
  },
19967
- [onRowContextMenu, handleOpenContextMenu, selectTask, contextMenuOptions]
20010
+ [
20011
+ onRowContextMenu,
20012
+ handleOpenContextMenu,
20013
+ selectTask,
20014
+ contextMenuOptions,
20015
+ selectedIdsMirror
20016
+ ]
19968
20017
  );
19969
20018
  const ganttContextMenuOptions = React.useMemo(() => {
19970
20019
  if (taskBar.taskGanttContextMenuOption) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
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",