system-canvas-standalone 0.2.42 → 0.2.44

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.
@@ -15447,7 +15447,15 @@ var SystemCanvas = (() => {
15447
15447
  continue;
15448
15448
  if (y < n.y || y > n.y + n.height)
15449
15449
  continue;
15450
- if (cb([st.source], n))
15450
+ const movingNodes = [st.source];
15451
+ for (const [id2] of st.moving) {
15452
+ if (id2 !== st.source.id) {
15453
+ const mn = nodesRef.current?.find((r) => r.id === id2);
15454
+ if (mn)
15455
+ movingNodes.push(mn);
15456
+ }
15457
+ }
15458
+ if (cb(movingNodes, n))
15451
15459
  return n.id;
15452
15460
  return null;
15453
15461
  }
@@ -15499,7 +15507,15 @@ var SystemCanvas = (() => {
15499
15507
  const nodes = nodesRef.current;
15500
15508
  const target = nodes?.find((n) => n.id === dropTarget) ?? null;
15501
15509
  if (target && onNodeDropRef.current) {
15502
- onNodeDropRef.current([st.source], target);
15510
+ const movingNodes = [st.source];
15511
+ for (const [id2] of st.moving) {
15512
+ if (id2 !== st.source.id) {
15513
+ const mn = nodesRef.current?.find((r) => r.id === id2);
15514
+ if (mn)
15515
+ movingNodes.push(mn);
15516
+ }
15517
+ }
15518
+ onNodeDropRef.current(movingNodes, target);
15503
15519
  stateRef.current = null;
15504
15520
  movedRef.current = false;
15505
15521
  dropTargetIdRef.current = null;
@@ -15845,6 +15861,7 @@ var SystemCanvas = (() => {
15845
15861
  const [selectedIds, setSelectedIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
15846
15862
  const [marqueeRect, setMarqueeRect] = (0, import_react7.useState)(null);
15847
15863
  const marqueeActiveRef = (0, import_react7.useRef)(activationKey === "none");
15864
+ const isPendingRef = (0, import_react7.useRef)(false);
15848
15865
  const isDrawingRef = (0, import_react7.useRef)(false);
15849
15866
  const startScreenRef = (0, import_react7.useRef)(null);
15850
15867
  const pointerIdRef = (0, import_react7.useRef)(null);
@@ -15915,7 +15932,8 @@ var SystemCanvas = (() => {
15915
15932
  if (!matchesKey(e))
15916
15933
  return;
15917
15934
  marqueeActiveRef.current = false;
15918
- if (isDrawingRef.current) {
15935
+ if (isDrawingRef.current || isPendingRef.current) {
15936
+ isPendingRef.current = false;
15919
15937
  isDrawingRef.current = false;
15920
15938
  startScreenRef.current = null;
15921
15939
  pointerIdRef.current = null;
@@ -15965,6 +15983,8 @@ var SystemCanvas = (() => {
15965
15983
  if (target && typeof target.closest === "function") {
15966
15984
  if (target.closest(".system-canvas-node"))
15967
15985
  return;
15986
+ if (target.closest(".system-canvas-edge"))
15987
+ return;
15968
15988
  if (target.closest(".system-canvas-resize-handles"))
15969
15989
  return;
15970
15990
  if (target.closest(".system-canvas-connection-handles"))
@@ -15977,21 +15997,16 @@ var SystemCanvas = (() => {
15977
15997
  const x = e.clientX - rect.left;
15978
15998
  const y = e.clientY - rect.top;
15979
15999
  startScreenRef.current = { x, y };
15980
- isDrawingRef.current = true;
16000
+ isPendingRef.current = true;
16001
+ isDrawingRef.current = false;
15981
16002
  pointerIdRef.current = e.pointerId;
15982
- setMarqueeRect({ x1: x, y1: y, x2: x, y2: y });
15983
- try {
15984
- container.setPointerCapture(e.pointerId);
15985
- } catch {
15986
- }
15987
- e.preventDefault();
15988
- e.stopPropagation();
15989
16003
  };
16004
+ const MARQUEE_DRAG_THRESHOLD = 4;
15990
16005
  const onPointerMove = (e) => {
15991
- if (!isDrawingRef.current)
15992
- return;
15993
16006
  if (e.pointerId !== pointerIdRef.current)
15994
16007
  return;
16008
+ if (!isPendingRef.current && !isDrawingRef.current)
16009
+ return;
15995
16010
  const svg = svgRef.current;
15996
16011
  if (!svg)
15997
16012
  return;
@@ -15999,13 +16014,32 @@ var SystemCanvas = (() => {
15999
16014
  const x = e.clientX - rect.left;
16000
16015
  const y = e.clientY - rect.top;
16001
16016
  const start2 = startScreenRef.current;
16017
+ if (isPendingRef.current && !isDrawingRef.current) {
16018
+ const dx = x - start2.x;
16019
+ const dy = y - start2.y;
16020
+ if (Math.hypot(dx, dy) < MARQUEE_DRAG_THRESHOLD)
16021
+ return;
16022
+ isPendingRef.current = false;
16023
+ isDrawingRef.current = true;
16024
+ try {
16025
+ container.setPointerCapture(e.pointerId);
16026
+ } catch {
16027
+ }
16028
+ }
16029
+ e.preventDefault();
16002
16030
  setMarqueeRect({ x1: start2.x, y1: start2.y, x2: x, y2: y });
16003
16031
  };
16004
16032
  const onPointerUp = (e) => {
16005
- if (!isDrawingRef.current)
16006
- return;
16007
16033
  if (e.pointerId !== pointerIdRef.current)
16008
16034
  return;
16035
+ if (isPendingRef.current && !isDrawingRef.current) {
16036
+ isPendingRef.current = false;
16037
+ startScreenRef.current = null;
16038
+ pointerIdRef.current = null;
16039
+ return;
16040
+ }
16041
+ if (!isDrawingRef.current)
16042
+ return;
16009
16043
  const svg = svgRef.current;
16010
16044
  if (!svg)
16011
16045
  return;
@@ -16031,6 +16065,7 @@ var SystemCanvas = (() => {
16031
16065
  }
16032
16066
  setSelectedIds(matched);
16033
16067
  setMarqueeRect(null);
16068
+ isPendingRef.current = false;
16034
16069
  isDrawingRef.current = false;
16035
16070
  startScreenRef.current = null;
16036
16071
  pointerIdRef.current = null;