@xyflow/system 0.0.9 → 0.0.11

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.
Files changed (45) hide show
  1. package/dist/esm/index.mjs +160 -91
  2. package/dist/esm/types/general.d.ts +2 -0
  3. package/dist/esm/types/general.d.ts.map +1 -1
  4. package/dist/esm/types/nodes.d.ts +11 -7
  5. package/dist/esm/types/nodes.d.ts.map +1 -1
  6. package/dist/esm/utils/dom.d.ts.map +1 -1
  7. package/dist/esm/utils/edges/general.d.ts +1 -1
  8. package/dist/esm/utils/edges/general.d.ts.map +1 -1
  9. package/dist/esm/utils/general.d.ts +2 -2
  10. package/dist/esm/utils/general.d.ts.map +1 -1
  11. package/dist/esm/utils/graph.d.ts +1 -1
  12. package/dist/esm/utils/graph.d.ts.map +1 -1
  13. package/dist/esm/utils/index.d.ts +1 -0
  14. package/dist/esm/utils/index.d.ts.map +1 -1
  15. package/dist/esm/utils/node-toolbar.d.ts +3 -0
  16. package/dist/esm/utils/node-toolbar.d.ts.map +1 -0
  17. package/dist/esm/utils/store.d.ts +3 -3
  18. package/dist/esm/utils/store.d.ts.map +1 -1
  19. package/dist/esm/xydrag/XYDrag.d.ts +1 -0
  20. package/dist/esm/xydrag/XYDrag.d.ts.map +1 -1
  21. package/dist/esm/xydrag/utils.d.ts +2 -2
  22. package/dist/esm/xydrag/utils.d.ts.map +1 -1
  23. package/dist/umd/index.js +1 -1
  24. package/dist/umd/types/general.d.ts +2 -0
  25. package/dist/umd/types/general.d.ts.map +1 -1
  26. package/dist/umd/types/nodes.d.ts +11 -7
  27. package/dist/umd/types/nodes.d.ts.map +1 -1
  28. package/dist/umd/utils/dom.d.ts.map +1 -1
  29. package/dist/umd/utils/edges/general.d.ts +1 -1
  30. package/dist/umd/utils/edges/general.d.ts.map +1 -1
  31. package/dist/umd/utils/general.d.ts +2 -2
  32. package/dist/umd/utils/general.d.ts.map +1 -1
  33. package/dist/umd/utils/graph.d.ts +1 -1
  34. package/dist/umd/utils/graph.d.ts.map +1 -1
  35. package/dist/umd/utils/index.d.ts +1 -0
  36. package/dist/umd/utils/index.d.ts.map +1 -1
  37. package/dist/umd/utils/node-toolbar.d.ts +3 -0
  38. package/dist/umd/utils/node-toolbar.d.ts.map +1 -0
  39. package/dist/umd/utils/store.d.ts +3 -3
  40. package/dist/umd/utils/store.d.ts.map +1 -1
  41. package/dist/umd/xydrag/XYDrag.d.ts +1 -0
  42. package/dist/umd/xydrag/XYDrag.d.ts.map +1 -1
  43. package/dist/umd/xydrag/utils.d.ts +2 -2
  44. package/dist/umd/xydrag/utils.d.ts.map +1 -1
  45. package/package.json +3 -3
@@ -102,23 +102,23 @@ const getNodePositionWithOrigin = (node, nodeOrigin = [0, 0]) => {
102
102
  },
103
103
  };
104
104
  }
105
- const offsetX = (node.width ?? 0) * nodeOrigin[0];
106
- const offsetY = (node.height ?? 0) * nodeOrigin[1];
105
+ const offsetX = (node.computed?.width ?? node.width ?? 0) * nodeOrigin[0];
106
+ const offsetY = (node.computed?.height ?? node.height ?? 0) * nodeOrigin[1];
107
107
  const position = {
108
108
  x: node.position.x - offsetX,
109
109
  y: node.position.y - offsetY,
110
110
  };
111
111
  return {
112
112
  ...position,
113
- positionAbsolute: node.positionAbsolute
113
+ positionAbsolute: node.computed?.positionAbsolute
114
114
  ? {
115
- x: node.positionAbsolute.x - offsetX,
116
- y: node.positionAbsolute.y - offsetY,
115
+ x: node.computed.positionAbsolute.x - offsetX,
116
+ y: node.computed.positionAbsolute.y - offsetY,
117
117
  }
118
118
  : position,
119
119
  };
120
120
  };
121
- const getRectOfNodes = (nodes, nodeOrigin = [0, 0]) => {
121
+ const getNodesBounds = (nodes, nodeOrigin = [0, 0]) => {
122
122
  if (nodes.length === 0) {
123
123
  return { x: 0, y: 0, width: 0, height: 0 };
124
124
  }
@@ -127,8 +127,8 @@ const getRectOfNodes = (nodes, nodeOrigin = [0, 0]) => {
127
127
  return getBoundsOfBoxes(currBox, rectToBox({
128
128
  x,
129
129
  y,
130
- width: node.width || 0,
131
- height: node.height || 0,
130
+ width: node.computed?.width ?? node.width ?? 0,
131
+ height: node.computed?.height ?? node.height ?? 0,
132
132
  }));
133
133
  }, { x: Infinity, y: Infinity, x2: -Infinity, y2: -Infinity });
134
134
  return boxToRect(box);
@@ -142,14 +142,16 @@ excludeNonSelectableNodes = false, nodeOrigin = [0, 0]) => {
142
142
  height: rect.height / tScale,
143
143
  };
144
144
  const visibleNodes = nodes.reduce((res, node) => {
145
- const { width, height, selectable = true, hidden = false } = node;
145
+ const { computed, selectable = true, hidden = false } = node;
146
+ const width = computed?.width ?? node.width ?? null;
147
+ const height = computed?.height ?? node.height ?? null;
146
148
  if ((excludeNonSelectableNodes && !selectable) || hidden) {
147
149
  return res;
148
150
  }
149
151
  const overlappingArea = getOverlappingArea(paneRect, nodeToRect(node, nodeOrigin));
150
- const notInitialized = width === undefined || height === undefined || width === null || height === null;
152
+ const notInitialized = width === null || height === null;
151
153
  const partiallyVisible = partially && overlappingArea > 0;
152
- const area = (width || 0) * (height || 0);
154
+ const area = (width ?? 0) * (height ?? 0);
153
155
  const isVisible = notInitialized || partiallyVisible || overlappingArea >= area;
154
156
  if (isVisible || node.dragging) {
155
157
  res.push(node);
@@ -167,16 +169,16 @@ const getConnectedEdgesBase = (nodes, edges) => {
167
169
  };
168
170
  function fitView({ nodes, width, height, panZoom, minZoom, maxZoom, nodeOrigin = [0, 0] }, options) {
169
171
  const filteredNodes = nodes.filter((n) => {
170
- const isVisible = n.width && n.height && (options?.includeHiddenNodes || !n.hidden);
172
+ const isVisible = n.computed?.width && n.computed?.height && (options?.includeHiddenNodes || !n.hidden);
171
173
  if (options?.nodes?.length) {
172
174
  return isVisible && options?.nodes.some((optionNode) => optionNode.id === n.id);
173
175
  }
174
176
  return isVisible;
175
177
  });
176
178
  if (filteredNodes.length > 0) {
177
- const bounds = getRectOfNodes(filteredNodes, nodeOrigin);
178
- const [x, y, zoom] = getTransformForBounds(bounds, width, height, options?.minZoom ?? minZoom, options?.maxZoom ?? maxZoom, options?.padding ?? 0.1);
179
- panZoom.setViewport({ x, y, zoom }, { duration: options?.duration });
179
+ const bounds = getNodesBounds(filteredNodes, nodeOrigin);
180
+ const viewport = getViewportForBounds(bounds, width, height, options?.minZoom ?? minZoom, options?.maxZoom ?? maxZoom, options?.padding ?? 0.1);
181
+ panZoom.setViewport(viewport, { duration: options?.duration });
180
182
  return true;
181
183
  }
182
184
  return false;
@@ -185,7 +187,7 @@ function clampNodeExtent(node, extent) {
185
187
  if (!extent || extent === 'parent') {
186
188
  return extent;
187
189
  }
188
- return [extent[0], [extent[1][0] - (node.width || 0), extent[1][1] - (node.height || 0)]];
190
+ return [extent[0], [extent[1][0] - (node.computed?.width ?? 0), extent[1][1] - (node.computed?.height ?? 0)]];
189
191
  }
190
192
  function calcNextPosition(node, nextPosition, nodes, nodeExtent, nodeOrigin = [0, 0], onError) {
191
193
  const clampedNodeExtent = clampNodeExtent(node, node.extent || nodeExtent);
@@ -199,15 +201,17 @@ function calcNextPosition(node, nextPosition, nodes, nodeExtent, nodeOrigin = [0
199
201
  : parentPos;
200
202
  }
201
203
  if (node.extent === 'parent' && !node.expandParent) {
202
- if (node.parentNode && node.width && node.height) {
204
+ const nodeWidth = node.computed?.width;
205
+ const nodeHeight = node.computed?.height;
206
+ if (node.parentNode && nodeWidth && nodeHeight) {
203
207
  const currNodeOrigin = node.origin || nodeOrigin;
204
208
  currentExtent =
205
- parentNode && isNumeric(parentNode.width) && isNumeric(parentNode.height)
209
+ parentNode && isNumeric(parentNode.computed?.width) && isNumeric(parentNode.computed?.height)
206
210
  ? [
207
- [parentPos.x + node.width * currNodeOrigin[0], parentPos.y + node.height * currNodeOrigin[1]],
211
+ [parentPos.x + nodeWidth * currNodeOrigin[0], parentPos.y + nodeHeight * currNodeOrigin[1]],
208
212
  [
209
- parentPos.x + parentNode.width - node.width + node.width * currNodeOrigin[0],
210
- parentPos.y + parentNode.height - node.height + node.height * currNodeOrigin[1],
213
+ parentPos.x + (parentNode.computed?.width ?? 0) - nodeWidth + nodeWidth * currNodeOrigin[0],
214
+ parentPos.y + (parentNode.computed?.height ?? 0) - nodeHeight + nodeHeight * currNodeOrigin[1],
211
215
  ],
212
216
  ]
213
217
  : currentExtent;
@@ -251,7 +255,12 @@ function getElementsToRemove({ nodesToRemove, edgesToRemove, nodes, edges, }) {
251
255
  const deletableEdges = edges.filter((e) => (typeof e.deletable === 'boolean' ? e.deletable : true));
252
256
  const initialHitEdges = deletableEdges.filter((e) => edgeIds.includes(e.id));
253
257
  const connectedEdges = getConnectedEdgesBase(matchingNodes, deletableEdges);
254
- const matchingEdges = [...initialHitEdges, ...connectedEdges];
258
+ const matchingEdges = connectedEdges.reduce((res, edge) => {
259
+ if (!res.find((e) => e.id === edge.id)) {
260
+ res.push(edge);
261
+ }
262
+ return res;
263
+ }, initialHitEdges);
255
264
  return {
256
265
  matchingEdges,
257
266
  matchingNodes,
@@ -301,16 +310,16 @@ const nodeToRect = (node, nodeOrigin = [0, 0]) => {
301
310
  const { positionAbsolute } = getNodePositionWithOrigin(node, node.origin || nodeOrigin);
302
311
  return {
303
312
  ...positionAbsolute,
304
- width: node.width || 0,
305
- height: node.height || 0,
313
+ width: node.computed?.width ?? node.width ?? 0,
314
+ height: node.computed?.height ?? node.height ?? 0,
306
315
  };
307
316
  };
308
317
  const nodeToBox = (node, nodeOrigin = [0, 0]) => {
309
318
  const { positionAbsolute } = getNodePositionWithOrigin(node, node.origin || nodeOrigin);
310
319
  return {
311
320
  ...positionAbsolute,
312
- x2: positionAbsolute.x + (node.width || 0),
313
- y2: positionAbsolute.y + (node.height || 0),
321
+ x2: positionAbsolute.x + (node.computed?.width ?? node.width ?? 0),
322
+ y2: positionAbsolute.y + (node.computed?.height ?? node.height ?? 0),
314
323
  };
315
324
  };
316
325
  const getBoundsOfRects = (rect1, rect2) => boxToRect(getBoundsOfBoxes(rectToBox(rect1), rectToBox(rect2)));
@@ -357,7 +366,7 @@ const rendererPointToPoint = ({ x, y }, [tx, ty, tScale]) => {
357
366
  y: y * tScale + ty,
358
367
  };
359
368
  };
360
- const getTransformForBounds = (bounds, width, height, minZoom, maxZoom, padding) => {
369
+ const getViewportForBounds = (bounds, width, height, minZoom, maxZoom, padding) => {
361
370
  const xZoom = width / (bounds.width * (1 + padding));
362
371
  const yZoom = height / (bounds.height * (1 + padding));
363
372
  const zoom = Math.min(xZoom, yZoom);
@@ -366,7 +375,7 @@ const getTransformForBounds = (bounds, width, height, minZoom, maxZoom, padding)
366
375
  const boundsCenterY = bounds.y + bounds.height / 2;
367
376
  const x = width / 2 - boundsCenterX * clampedZoom;
368
377
  const y = height / 2 - boundsCenterY * clampedZoom;
369
- return [x, y, clampedZoom];
378
+ return { x, y, zoom: clampedZoom };
370
379
  };
371
380
  const isMacOs = () => typeof navigator !== 'undefined' && navigator?.userAgent?.indexOf('Mac') >= 0;
372
381
 
@@ -406,12 +415,16 @@ const getEventPosition = (event, bounds) => {
406
415
  y: evtY - (bounds?.top ?? 0),
407
416
  };
408
417
  };
418
+ // The handle bounds are calculated relative to the node element.
419
+ // We store them in the internals object of the node in order to avoid
420
+ // unnecessary recalculations.
409
421
  const getHandleBounds = (selector, nodeElement, zoom, nodeOrigin = [0, 0]) => {
410
422
  const handles = nodeElement.querySelectorAll(selector);
411
423
  if (!handles || !handles.length) {
412
424
  return null;
413
425
  }
414
426
  const handlesArray = Array.from(handles);
427
+ // @todo can't we use the node dimensions here?
415
428
  const nodeBounds = nodeElement.getBoundingClientRect();
416
429
  const nodeOffset = {
417
430
  x: nodeBounds.width * nodeOrigin[0],
@@ -501,14 +514,14 @@ function getEdgeCenter({ sourceX, sourceY, targetX, targetY, }) {
501
514
  return [centerX, centerY, xOffset, yOffset];
502
515
  }
503
516
  const defaultEdgeTree = [{ level: 0, isMaxLevel: true, edges: [] }];
504
- function groupEdgesByZLevel(edges, nodes, elevateEdgesOnSelect = false) {
517
+ function groupEdgesByZLevel(edges, nodeLookup, elevateEdgesOnSelect = false) {
505
518
  let maxLevel = -1;
506
519
  const levelLookup = edges.reduce((tree, edge) => {
507
520
  const hasZIndex = isNumeric(edge.zIndex);
508
521
  let z = hasZIndex ? edge.zIndex : 0;
509
522
  if (elevateEdgesOnSelect) {
510
- const targetNode = nodes.find((n) => n.id === edge.target);
511
- const sourceNode = nodes.find((n) => n.id === edge.source);
523
+ const targetNode = nodeLookup.get(edge.target);
524
+ const sourceNode = nodeLookup.get(edge.source);
512
525
  const edgeOrConnectedNodeSelected = edge.selected || targetNode?.selected || sourceNode?.selected;
513
526
  const selectedZIndex = Math.max(sourceNode?.[internalsSymbol]?.z || 0, targetNode?.[internalsSymbol]?.z || 0, 1000);
514
527
  z = (hasZIndex ? edge.zIndex : 0) + (edgeOrConnectedNodeSelected ? selectedZIndex : 0);
@@ -826,17 +839,17 @@ function toHandleBounds(handles) {
826
839
  }
827
840
  function getHandleDataByNode(node) {
828
841
  const handleBounds = node?.[internalsSymbol]?.handleBounds || toHandleBounds(node?.handles) || null;
829
- const nodeWidth = node?.width || node?.size?.width;
830
- const nodeHeight = node?.height || node?.size?.height;
842
+ const nodeWidth = node?.computed?.width || node?.width;
843
+ const nodeHeight = node?.computed?.height || node?.height;
831
844
  const isValid = handleBounds &&
832
845
  nodeWidth &&
833
846
  nodeHeight &&
834
- typeof node?.positionAbsolute?.x !== 'undefined' &&
835
- typeof node?.positionAbsolute?.y !== 'undefined';
847
+ typeof node?.computed?.positionAbsolute?.x !== 'undefined' &&
848
+ typeof node?.computed?.positionAbsolute?.y !== 'undefined';
836
849
  return [
837
850
  {
838
- x: node?.positionAbsolute?.x || 0,
839
- y: node?.positionAbsolute?.y || 0,
851
+ x: node?.computed?.positionAbsolute?.x || 0,
852
+ y: node?.computed?.positionAbsolute?.y || 0,
840
853
  width: nodeWidth || 0,
841
854
  height: nodeHeight || 0,
842
855
  },
@@ -916,18 +929,57 @@ function createMarkerIds(edges, { id, defaultColor }) {
916
929
  .sort((a, b) => a.id.localeCompare(b.id));
917
930
  }
918
931
 
919
- function updateAbsolutePositions(nodes, nodeOrigin = [0, 0], parentNodes) {
932
+ function getNodeToolbarTransform(nodeRect, viewport, position, offset, align) {
933
+ let alignmentOffset = 0.5;
934
+ if (align === 'start') {
935
+ alignmentOffset = 0;
936
+ }
937
+ else if (align === 'end') {
938
+ alignmentOffset = 1;
939
+ }
940
+ // position === Position.Top
941
+ // we set the x any y position of the toolbar based on the nodes position
942
+ let pos = [
943
+ (nodeRect.x + nodeRect.width * alignmentOffset) * viewport.zoom + viewport.x,
944
+ nodeRect.y * viewport.zoom + viewport.y - offset,
945
+ ];
946
+ // and than shift it based on the alignment. The shift values are in %.
947
+ let shift = [-100 * alignmentOffset, -100];
948
+ switch (position) {
949
+ case Position.Right:
950
+ pos = [
951
+ (nodeRect.x + nodeRect.width) * viewport.zoom + viewport.x + offset,
952
+ (nodeRect.y + nodeRect.height * alignmentOffset) * viewport.zoom + viewport.y,
953
+ ];
954
+ shift = [0, -100 * alignmentOffset];
955
+ break;
956
+ case Position.Bottom:
957
+ pos[1] = (nodeRect.y + nodeRect.height) * viewport.zoom + viewport.y + offset;
958
+ shift[1] = 0;
959
+ break;
960
+ case Position.Left:
961
+ pos = [
962
+ nodeRect.x * viewport.zoom + viewport.x - offset,
963
+ (nodeRect.y + nodeRect.height * alignmentOffset) * viewport.zoom + viewport.y,
964
+ ];
965
+ shift = [-100, -100 * alignmentOffset];
966
+ break;
967
+ }
968
+ return `translate(${pos[0]}px, ${pos[1]}px) translate(${shift[0]}%, ${shift[1]}%)`;
969
+ }
970
+
971
+ function updateAbsolutePositions(nodes, nodeLookup, nodeOrigin = [0, 0], parentNodes) {
920
972
  return nodes.map((node) => {
921
- if (node.parentNode && !nodes.find((n) => n.id === node.parentNode)) {
973
+ if (node.parentNode && !nodeLookup.has(node.parentNode)) {
922
974
  throw new Error(`Parent node ${node.parentNode} not found`);
923
975
  }
924
976
  if (node.parentNode || parentNodes?.[node.id]) {
925
- const parentNode = node.parentNode ? nodes.find((n) => n.id === node.parentNode) : null;
926
- const { x, y, z } = calculateXYZPosition(node, nodes, {
977
+ const parentNode = node.parentNode ? nodeLookup.get(node.parentNode) : null;
978
+ const { x, y, z } = calculateXYZPosition(node, nodes, nodeLookup, {
927
979
  ...node.position,
928
980
  z: node[internalsSymbol]?.z ?? 0,
929
981
  }, parentNode?.origin || nodeOrigin);
930
- node.positionAbsolute = {
982
+ node.computed.positionAbsolute = {
931
983
  x,
932
984
  y,
933
985
  };
@@ -939,7 +991,7 @@ function updateAbsolutePositions(nodes, nodeOrigin = [0, 0], parentNodes) {
939
991
  return node;
940
992
  });
941
993
  }
942
- function updateNodes(nodes, storeNodes, options = {
994
+ function updateNodes(nodes, nodeLookup, options = {
943
995
  nodeOrigin: [0, 0],
944
996
  elevateNodesOnSelect: true,
945
997
  defaults: {},
@@ -947,13 +999,15 @@ function updateNodes(nodes, storeNodes, options = {
947
999
  const parentNodes = {};
948
1000
  const selectedNodeZ = options?.elevateNodesOnSelect ? 1000 : 0;
949
1001
  const nextNodes = nodes.map((n) => {
950
- const currentStoreNode = storeNodes.find((storeNode) => n.id === storeNode.id);
1002
+ const currentStoreNode = nodeLookup.get(n.id);
951
1003
  const node = {
952
1004
  ...options.defaults,
953
1005
  ...n,
954
- positionAbsolute: n.position,
955
- width: n.width || currentStoreNode?.width,
956
- height: n.height || currentStoreNode?.height,
1006
+ computed: {
1007
+ positionAbsolute: n.position,
1008
+ width: n.computed?.width || currentStoreNode?.computed?.width,
1009
+ height: n.computed?.height || currentStoreNode?.computed?.height,
1010
+ },
957
1011
  };
958
1012
  const z = (isNumeric(n.zIndex) ? n.zIndex : 0) + (n.selected ? selectedNodeZ : 0);
959
1013
  const currInternals = n?.[internalsSymbol] || currentStoreNode?.[internalsSymbol];
@@ -967,24 +1021,25 @@ function updateNodes(nodes, storeNodes, options = {
967
1021
  z,
968
1022
  },
969
1023
  });
1024
+ nodeLookup.set(node.id, node);
970
1025
  return node;
971
1026
  });
972
- const nodesWithPositions = updateAbsolutePositions(nextNodes, options.nodeOrigin, parentNodes);
1027
+ const nodesWithPositions = updateAbsolutePositions(nextNodes, nodeLookup, options.nodeOrigin, parentNodes);
973
1028
  return nodesWithPositions;
974
1029
  }
975
- function calculateXYZPosition(node, nodes, result, nodeOrigin) {
1030
+ function calculateXYZPosition(node, nodes, nodeLookup, result, nodeOrigin) {
976
1031
  if (!node.parentNode) {
977
1032
  return result;
978
1033
  }
979
- const parentNode = nodes.find((n) => n.id === node.parentNode);
1034
+ const parentNode = nodeLookup.get(node.parentNode);
980
1035
  const parentNodePosition = getNodePositionWithOrigin(parentNode, parentNode?.origin || nodeOrigin);
981
- return calculateXYZPosition(parentNode, nodes, {
1036
+ return calculateXYZPosition(parentNode, nodes, nodeLookup, {
982
1037
  x: (result.x ?? 0) + parentNodePosition.x,
983
1038
  y: (result.y ?? 0) + parentNodePosition.y,
984
1039
  z: (parentNode[internalsSymbol]?.z ?? 0) > (result.z ?? 0) ? parentNode[internalsSymbol]?.z ?? 0 : result.z ?? 0,
985
1040
  }, parentNode.origin || nodeOrigin);
986
1041
  }
987
- function updateNodeDimensions(updates, nodes, domNode, nodeOrigin, onUpdate) {
1042
+ function updateNodeDimensions(updates, nodes, nodeLookup, domNode, nodeOrigin, onUpdate) {
988
1043
  const viewportNode = domNode?.querySelector('.xyflow__viewport');
989
1044
  if (!viewportNode) {
990
1045
  return null;
@@ -992,17 +1047,20 @@ function updateNodeDimensions(updates, nodes, domNode, nodeOrigin, onUpdate) {
992
1047
  const style = window.getComputedStyle(viewportNode);
993
1048
  const { m22: zoom } = new window.DOMMatrixReadOnly(style.transform);
994
1049
  const nextNodes = nodes.map((node) => {
995
- const update = updates.find((u) => u.id === node.id);
1050
+ const update = updates.get(node.id);
996
1051
  if (update) {
997
1052
  const dimensions = getDimensions(update.nodeElement);
998
1053
  const doUpdate = !!(dimensions.width &&
999
1054
  dimensions.height &&
1000
- (node.width !== dimensions.width || node.height !== dimensions.height || update.forceUpdate));
1055
+ (node.computed?.width !== dimensions.width || node.computed?.height !== dimensions.height || update.forceUpdate));
1001
1056
  if (doUpdate) {
1002
1057
  onUpdate?.(node.id, dimensions);
1003
- return {
1058
+ const newNode = {
1004
1059
  ...node,
1005
- ...dimensions,
1060
+ computed: {
1061
+ ...node.computed,
1062
+ ...dimensions,
1063
+ },
1006
1064
  [internalsSymbol]: {
1007
1065
  ...node[internalsSymbol],
1008
1066
  handleBounds: {
@@ -1011,6 +1069,8 @@ function updateNodeDimensions(updates, nodes, domNode, nodeOrigin, onUpdate) {
1011
1069
  },
1012
1070
  },
1013
1071
  };
1072
+ nodeLookup.set(node.id, newNode);
1073
+ return newNode;
1014
1074
  }
1015
1075
  }
1016
1076
  return node;
@@ -1070,10 +1130,9 @@ function getDragItems(nodes, nodesDraggable, mousePos, nodeId) {
1070
1130
  .map((n) => ({
1071
1131
  id: n.id,
1072
1132
  position: n.position || { x: 0, y: 0 },
1073
- positionAbsolute: n.positionAbsolute || { x: 0, y: 0 },
1074
1133
  distance: {
1075
- x: mousePos.x - (n.positionAbsolute?.x ?? 0),
1076
- y: mousePos.y - (n.positionAbsolute?.y ?? 0),
1134
+ x: mousePos.x - (n.computed?.positionAbsolute?.x ?? 0),
1135
+ y: mousePos.y - (n.computed?.positionAbsolute?.y ?? 0),
1077
1136
  },
1078
1137
  delta: {
1079
1138
  x: 0,
@@ -1081,25 +1140,31 @@ function getDragItems(nodes, nodesDraggable, mousePos, nodeId) {
1081
1140
  },
1082
1141
  extent: n.extent,
1083
1142
  parentNode: n.parentNode,
1084
- width: n.width,
1085
- height: n.height,
1086
1143
  origin: n.origin,
1087
1144
  expandParent: n.expandParent,
1145
+ computed: {
1146
+ positionAbsolute: n.computed?.positionAbsolute || { x: 0, y: 0 },
1147
+ width: n.computed?.width || 0,
1148
+ height: n.computed?.height || 0,
1149
+ },
1088
1150
  }));
1089
1151
  }
1090
1152
  // returns two params:
1091
1153
  // 1. the dragged node (or the first of the list, if we are dragging a node selection)
1092
1154
  // 2. array of selected nodes (for multi selections)
1093
- function getEventHandlerParams({ nodeId, dragItems, nodes, }) {
1094
- const extentedDragItems = dragItems.map((n) => {
1095
- const node = nodes.find((node) => node.id === n.id);
1155
+ function getEventHandlerParams({ nodeId, dragItems, nodeLookup, }) {
1156
+ const nodesFromDragItems = dragItems.map((n) => {
1157
+ const node = nodeLookup.get(n.id);
1096
1158
  return {
1097
1159
  ...node,
1098
1160
  position: n.position,
1099
- positionAbsolute: n.positionAbsolute,
1161
+ computed: {
1162
+ ...n.computed,
1163
+ positionAbsolute: n.computed.positionAbsolute,
1164
+ },
1100
1165
  };
1101
1166
  });
1102
- return [nodeId ? extentedDragItems.find((n) => n.id === nodeId) : extentedDragItems[0], extentedDragItems];
1167
+ return [nodeId ? nodesFromDragItems.find((n) => n.id === nodeId) : nodesFromDragItems[0], nodesFromDragItems];
1103
1168
  }
1104
1169
 
1105
1170
  function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragStop, }) {
@@ -1115,12 +1180,12 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1115
1180
  // public functions
1116
1181
  function update({ noDragClassName, handleSelector, domNode, isSelectable, nodeId }) {
1117
1182
  function updateNodes({ x, y }) {
1118
- const { nodes, nodeExtent, snapGrid, snapToGrid, nodeOrigin, onNodeDrag, onSelectionDrag, onError, updateNodePositions, } = getStoreItems();
1183
+ const { nodes, nodeLookup, nodeExtent, snapGrid, snapToGrid, nodeOrigin, onNodeDrag, onSelectionDrag, onError, updateNodePositions, } = getStoreItems();
1119
1184
  lastPos = { x, y };
1120
1185
  let hasChange = false;
1121
1186
  let nodesBox = { x: 0, y: 0, x2: 0, y2: 0 };
1122
1187
  if (dragItems.length > 1 && nodeExtent) {
1123
- const rect = getRectOfNodes(dragItems, nodeOrigin);
1188
+ const rect = getNodesBounds(dragItems, nodeOrigin);
1124
1189
  nodesBox = rectToBox(rect);
1125
1190
  }
1126
1191
  dragItems = dragItems.map((n) => {
@@ -1135,16 +1200,18 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1135
1200
  [nodeExtent[1][0], nodeExtent[1][1]],
1136
1201
  ];
1137
1202
  if (dragItems.length > 1 && nodeExtent && !n.extent) {
1138
- adjustedNodeExtent[0][0] = n.positionAbsolute.x - nodesBox.x + nodeExtent[0][0];
1139
- adjustedNodeExtent[1][0] = n.positionAbsolute.x + (n.width ?? 0) - nodesBox.x2 + nodeExtent[1][0];
1140
- adjustedNodeExtent[0][1] = n.positionAbsolute.y - nodesBox.y + nodeExtent[0][1];
1141
- adjustedNodeExtent[1][1] = n.positionAbsolute.y + (n.height ?? 0) - nodesBox.y2 + nodeExtent[1][1];
1203
+ adjustedNodeExtent[0][0] = n.computed.positionAbsolute.x - nodesBox.x + nodeExtent[0][0];
1204
+ adjustedNodeExtent[1][0] =
1205
+ n.computed.positionAbsolute.x + (n.computed?.width ?? 0) - nodesBox.x2 + nodeExtent[1][0];
1206
+ adjustedNodeExtent[0][1] = n.computed.positionAbsolute.y - nodesBox.y + nodeExtent[0][1];
1207
+ adjustedNodeExtent[1][1] =
1208
+ n.computed.positionAbsolute.y + (n.computed?.height ?? 0) - nodesBox.y2 + nodeExtent[1][1];
1142
1209
  }
1143
1210
  const updatedPos = calcNextPosition(n, nextPosition, nodes, adjustedNodeExtent, nodeOrigin, onError);
1144
1211
  // we want to make sure that we only fire a change event when there is a change
1145
1212
  hasChange = hasChange || n.position.x !== updatedPos.position.x || n.position.y !== updatedPos.position.y;
1146
1213
  n.position = updatedPos.position;
1147
- n.positionAbsolute = updatedPos.positionAbsolute;
1214
+ n.computed.positionAbsolute = updatedPos.positionAbsolute;
1148
1215
  return n;
1149
1216
  });
1150
1217
  if (!hasChange) {
@@ -1152,11 +1219,11 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1152
1219
  }
1153
1220
  updateNodePositions(dragItems, true, true);
1154
1221
  const onNodeOrSelectionDrag = nodeId ? onNodeDrag : wrapSelectionDragFunc(onSelectionDrag);
1155
- if (dragEvent) {
1222
+ if (dragEvent && (onDrag || onNodeOrSelectionDrag)) {
1156
1223
  const [currentNode, currentNodes] = getEventHandlerParams({
1157
1224
  nodeId,
1158
1225
  dragItems,
1159
- nodes,
1226
+ nodeLookup,
1160
1227
  });
1161
1228
  onDrag?.(dragEvent, dragItems, currentNode, currentNodes);
1162
1229
  onNodeOrSelectionDrag?.(dragEvent, currentNode, currentNodes);
@@ -1178,10 +1245,10 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1178
1245
  autoPanId = requestAnimationFrame(autoPan);
1179
1246
  }
1180
1247
  function startDrag(event) {
1181
- const { nodes, multiSelectionActive, nodesDraggable, transform, snapGrid, snapToGrid, selectNodesOnDrag, onNodeDragStart, onSelectionDragStart, unselectNodesAndEdges, } = getStoreItems();
1248
+ const { nodes, nodeLookup, multiSelectionActive, nodesDraggable, transform, snapGrid, snapToGrid, selectNodesOnDrag, onNodeDragStart, onSelectionDragStart, unselectNodesAndEdges, } = getStoreItems();
1182
1249
  dragStarted = true;
1183
1250
  if ((!selectNodesOnDrag || !isSelectable) && !multiSelectionActive && nodeId) {
1184
- if (!nodes.find((n) => n.id === nodeId)?.selected) {
1251
+ if (!nodeLookup.get(nodeId)?.selected) {
1185
1252
  // we need to reset selected nodes when selectNodesOnDrag=false
1186
1253
  unselectNodesAndEdges();
1187
1254
  }
@@ -1193,11 +1260,11 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1193
1260
  lastPos = pointerPos;
1194
1261
  dragItems = getDragItems(nodes, nodesDraggable, pointerPos, nodeId);
1195
1262
  const onNodeOrSelectionDragStart = nodeId ? onNodeDragStart : wrapSelectionDragFunc(onSelectionDragStart);
1196
- if (dragItems) {
1263
+ if (dragItems && (onDragStart || onNodeOrSelectionDragStart)) {
1197
1264
  const [currentNode, currentNodes] = getEventHandlerParams({
1198
1265
  nodeId,
1199
1266
  dragItems,
1200
- nodes,
1267
+ nodeLookup,
1201
1268
  });
1202
1269
  onDragStart?.(event.sourceEvent, dragItems, currentNode, currentNodes);
1203
1270
  onNodeOrSelectionDragStart?.(event.sourceEvent, currentNode, currentNodes);
@@ -1244,16 +1311,18 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
1244
1311
  dragStarted = false;
1245
1312
  cancelAnimationFrame(autoPanId);
1246
1313
  if (dragItems) {
1247
- const { nodes, updateNodePositions, onNodeDragStop, onSelectionDragStop } = getStoreItems();
1314
+ const { nodeLookup, updateNodePositions, onNodeDragStop, onSelectionDragStop } = getStoreItems();
1248
1315
  const onNodeOrSelectionDragStop = nodeId ? onNodeDragStop : wrapSelectionDragFunc(onSelectionDragStop);
1249
1316
  updateNodePositions(dragItems, false, false);
1250
- const [currentNode, currentNodes] = getEventHandlerParams({
1251
- nodeId,
1252
- dragItems,
1253
- nodes,
1254
- });
1255
- onDragStop?.(event.sourceEvent, dragItems, currentNode, currentNodes);
1256
- onNodeOrSelectionDragStop?.(event.sourceEvent, currentNode, currentNodes);
1317
+ if (onDragStop || onNodeOrSelectionDragStop) {
1318
+ const [currentNode, currentNodes] = getEventHandlerParams({
1319
+ nodeId,
1320
+ dragItems,
1321
+ nodeLookup,
1322
+ });
1323
+ onDragStop?.(event.sourceEvent, dragItems, currentNode, currentNodes);
1324
+ onNodeOrSelectionDragStop?.(event.sourceEvent, currentNode, currentNodes);
1325
+ }
1257
1326
  }
1258
1327
  })
1259
1328
  .filter((event) => {
@@ -1283,8 +1352,8 @@ function getHandles(node, handleBounds, type, currentHandle) {
1283
1352
  id: h.id || null,
1284
1353
  type,
1285
1354
  nodeId: node.id,
1286
- x: (node.positionAbsolute?.x ?? 0) + h.x + h.width / 2,
1287
- y: (node.positionAbsolute?.y ?? 0) + h.y + h.height / 2,
1355
+ x: (node.computed?.positionAbsolute?.x ?? 0) + h.x + h.width / 2,
1356
+ y: (node.computed?.positionAbsolute?.y ?? 0) + h.y + h.height / 2,
1288
1357
  });
1289
1358
  }
1290
1359
  return res;
@@ -1735,7 +1804,7 @@ function createFilter({ zoomActivationKeyPressed, zoomOnScroll, zoomOnPinch, pan
1735
1804
  }
1736
1805
  // if the target element is inside an element with the nopan class, we prevent panning
1737
1806
  if (isWrappedWithClass(event, noPanClassName) &&
1738
- ((!panOnScroll && event.type !== 'wheel') || (panOnScroll && event.type === 'wheel'))) {
1807
+ (event.type !== 'wheel' || (panOnScroll && event.type === 'wheel' && !zoomActivationKeyPressed))) {
1739
1808
  return false;
1740
1809
  }
1741
1810
  if (!zoomOnPinch && event.ctrlKey && event.type === 'wheel') {
@@ -1919,4 +1988,4 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
1919
1988
  };
1920
1989
  }
1921
1990
 
1922
- export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, SelectionMode, XYDrag, XYHandle, XYMinimap, XYPanZoom, addEdgeBase, boxToRect, calcAutoPan, calcNextPosition, clamp, clampPosition, createMarkerIds, devWarn, elementSelectionKeys, errorMessages, fitView, getBezierEdgeCenter, getBezierPath, getBoundsOfBoxes, getBoundsOfRects, getConnectedEdgesBase, getDimensions, getEdgeCenter, getEdgePosition, getElementsToRemove, getEventPosition, getHandleBounds, getHostForElement, getIncomersBase, getMarkerId, getNodePositionWithOrigin, getNodesInside, getOutgoersBase, getOverlappingArea, getPointerPosition, getPositionWithOrigin, getRectOfNodes, getSmoothStepPath, getStraightPath, getTransformForBounds, groupEdgesByZLevel, infiniteExtent, internalsSymbol, isEdgeBase, isEdgeVisible, isInputDOMNode, isMacOs, isMouseEvent, isNodeBase, isNumeric, isRectObject, nodeToBox, nodeToRect, panBy, pointToRendererPoint, rectToBox, rendererPointToPoint, snapPosition, updateAbsolutePositions, updateEdgeBase, updateNodeDimensions, updateNodes };
1991
+ export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, SelectionMode, XYDrag, XYHandle, XYMinimap, XYPanZoom, addEdgeBase, boxToRect, calcAutoPan, calcNextPosition, clamp, clampPosition, createMarkerIds, devWarn, elementSelectionKeys, errorMessages, fitView, getBezierEdgeCenter, getBezierPath, getBoundsOfBoxes, getBoundsOfRects, getConnectedEdgesBase, getDimensions, getEdgeCenter, getEdgePosition, getElementsToRemove, getEventPosition, getHandleBounds, getHostForElement, getIncomersBase, getMarkerId, getNodePositionWithOrigin, getNodeToolbarTransform, getNodesBounds, getNodesInside, getOutgoersBase, getOverlappingArea, getPointerPosition, getPositionWithOrigin, getSmoothStepPath, getStraightPath, getViewportForBounds, groupEdgesByZLevel, infiniteExtent, internalsSymbol, isEdgeBase, isEdgeVisible, isInputDOMNode, isMacOs, isMouseEvent, isNodeBase, isNumeric, isRectObject, nodeToBox, nodeToRect, panBy, pointToRendererPoint, rectToBox, rendererPointToPoint, snapPosition, updateAbsolutePositions, updateEdgeBase, updateNodeDimensions, updateNodes };
@@ -103,4 +103,6 @@ export type UpdateConnection = (params: {
103
103
  connectionStartHandle: ConnectingHandle | null;
104
104
  connectionEndHandle: ConnectingHandle | null;
105
105
  }) => void;
106
+ export type ColorModeClass = 'light' | 'dark';
107
+ export type ColorMode = ColorModeClass | 'system';
106
108
  //# sourceMappingURL=general.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/types/general.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,IAAI,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE/F,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,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ined = string | undefined>
22
22
  zIndex?: number;
23
23
  extent?: 'parent' | CoordinateExtent;
24
24
  expandParent?: boolean;
25
- positionAbsolute?: XYPosition;
26
25
  ariaLabel?: string;
27
26
  focusable?: boolean;
28
27
  origin?: NodeOrigin;
29
28
  handles?: NodeHandle[];
30
- size?: {
29
+ computed?: {
31
30
  width?: number;
32
31
  height?: number;
32
+ positionAbsolute?: XYPosition;
33
33
  };
34
34
  [internalsSymbol]?: {
35
35
  z?: number;
@@ -45,8 +45,9 @@ export type NodeProps<T = any> = {
45
45
  selected: NodeBase['selected'];
46
46
  isConnectable: NodeBase['connectable'];
47
47
  zIndex: NodeBase['zIndex'];
48
- xPos: number;
49
- yPos: number;
48
+ positionAbsolute: XYPosition;
49
+ width?: number;
50
+ height?: number;
50
51
  dragging: boolean;
51
52
  targetPosition?: Position;
52
53
  sourcePosition?: Position;
@@ -67,10 +68,12 @@ export type NodeBounds = XYPosition & {
67
68
  export type NodeDragItem = {
68
69
  id: string;
69
70
  position: XYPosition;
70
- positionAbsolute: XYPosition;
71
71
  distance: XYPosition;
72
- width?: number | null;
73
- height?: number | null;
72
+ computed: {
73
+ width: number | null;
74
+ height: number | null;
75
+ positionAbsolute: XYPosition;
76
+ };
74
77
  extent?: 'parent' | CoordinateExtent;
75
78
  parentNode?: string;
76
79
  dragging?: boolean;
@@ -81,4 +84,5 @@ export type NodeOrigin = [number, number];
81
84
  export type OnNodeDrag = (event: MouseEvent, node: NodeBase, nodes: NodeBase[]) => void;
82
85
  export type OnSelectionDrag = (event: MouseEvent, nodes: NodeBase[]) => void;
83
86
  export type NodeHandle = Optional<HandleElement, 'width' | 'height'>;
87
+ export type Align = 'center' | 'start' | 'end';
84
88
  //# sourceMappingURL=nodes.d.ts.map