@pixerate/editor-svelte 0.6.1 → 0.7.0
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.
- package/dist/canvas/index.js +116 -13
- package/dist/canvas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/canvas/README.md +15 -3
- package/src/canvas/__tests__/canvas-docking.test.ts +152 -0
- package/src/canvas/createCanvasDocking.svelte.ts +226 -16
- package/src/canvas/index.ts +2 -1
- package/src/canvas/types.ts +9 -0
package/dist/canvas/index.js
CHANGED
|
@@ -400,6 +400,91 @@ function createCanvasClipboard(options = {}) {
|
|
|
400
400
|
|
|
401
401
|
// src/canvas/createCanvasDocking.svelte.ts
|
|
402
402
|
import * as $3 from "svelte/internal/client";
|
|
403
|
+
function getNodeRect(node) {
|
|
404
|
+
const x = node.position?.x ?? 0;
|
|
405
|
+
const y = node.position?.y ?? 0;
|
|
406
|
+
const width = node.measured?.width ?? node.width ?? node.initialWidth ?? 0;
|
|
407
|
+
const height = node.measured?.height ?? node.height ?? node.initialHeight ?? 0;
|
|
408
|
+
return { x, y, width, height };
|
|
409
|
+
}
|
|
410
|
+
function getNodeCenter(node) {
|
|
411
|
+
const rect = getNodeRect(node);
|
|
412
|
+
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
413
|
+
}
|
|
414
|
+
function getDistanceSq(p1, p2) {
|
|
415
|
+
const dx = p1.x - p2.x;
|
|
416
|
+
const dy = p1.y - p2.y;
|
|
417
|
+
return dx * dx + dy * dy;
|
|
418
|
+
}
|
|
419
|
+
function getOverlapArea(rectA, rectB) {
|
|
420
|
+
const xOverlap = Math.max(0, Math.min(rectA.x + rectA.width, rectB.x + rectB.width) - Math.max(rectA.x, rectB.x));
|
|
421
|
+
const yOverlap = Math.max(0, Math.min(rectA.y + rectA.height, rectB.y + rectB.height) - Math.max(rectA.y, rectB.y));
|
|
422
|
+
return xOverlap * yOverlap;
|
|
423
|
+
}
|
|
424
|
+
function resolvePrimaryTarget(targets, draggedNode, strategy, customResolver, event) {
|
|
425
|
+
if (targets.length === 0) return null;
|
|
426
|
+
if (targets.length === 1) return targets[0];
|
|
427
|
+
if (customResolver) {
|
|
428
|
+
const resolved = customResolver(targets, draggedNode, event);
|
|
429
|
+
if (resolved !== void 0) return resolved;
|
|
430
|
+
}
|
|
431
|
+
if (strategy === "first") {
|
|
432
|
+
return targets[0];
|
|
433
|
+
}
|
|
434
|
+
if (strategy === "pointer" && event) {
|
|
435
|
+
const clientX = "clientX" in event ? event.clientX : event.touches?.[0]?.clientX;
|
|
436
|
+
const clientY = "clientY" in event ? event.clientY : event.touches?.[0]?.clientY;
|
|
437
|
+
if (typeof clientX === "number" && typeof clientY === "number") {
|
|
438
|
+
const pointerInside = targets.filter((target) => {
|
|
439
|
+
const r = getNodeRect(target);
|
|
440
|
+
return r.width > 0 && r.height > 0 && clientX >= r.x && clientX <= r.x + r.width && clientY >= r.y && clientY <= r.y + r.height;
|
|
441
|
+
});
|
|
442
|
+
if (pointerInside.length === 1) return pointerInside[0];
|
|
443
|
+
if (pointerInside.length > 1) {
|
|
444
|
+
return pointerInside.reduce((best, cur) => {
|
|
445
|
+
const bestDist = getDistanceSq(getNodeCenter(best), { x: clientX, y: clientY });
|
|
446
|
+
const curDist = getDistanceSq(getNodeCenter(cur), { x: clientX, y: clientY });
|
|
447
|
+
return curDist < bestDist ? cur : best;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (strategy === "max-overlap") {
|
|
453
|
+
const draggedRect = getNodeRect(draggedNode);
|
|
454
|
+
let maxArea = -1;
|
|
455
|
+
let bestTarget = targets[0];
|
|
456
|
+
for (const target of targets) {
|
|
457
|
+
const targetRect = getNodeRect(target);
|
|
458
|
+
const area = getOverlapArea(draggedRect, targetRect);
|
|
459
|
+
if (area > maxArea) {
|
|
460
|
+
maxArea = area;
|
|
461
|
+
bestTarget = target;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return bestTarget;
|
|
465
|
+
}
|
|
466
|
+
const draggedCenter = getNodeCenter(draggedNode);
|
|
467
|
+
const containing = targets.filter((target) => {
|
|
468
|
+
const r = getNodeRect(target);
|
|
469
|
+
if (r.width > 0 && r.height > 0) {
|
|
470
|
+
return draggedCenter.x >= r.x && draggedCenter.x <= r.x + r.width && draggedCenter.y >= r.y && draggedCenter.y <= r.y + r.height;
|
|
471
|
+
}
|
|
472
|
+
return false;
|
|
473
|
+
});
|
|
474
|
+
if (containing.length === 1) return containing[0];
|
|
475
|
+
if (containing.length > 1) {
|
|
476
|
+
return containing.reduce((best, cur) => {
|
|
477
|
+
const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);
|
|
478
|
+
const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);
|
|
479
|
+
return curDist < bestDist ? cur : best;
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
return targets.reduce((best, cur) => {
|
|
483
|
+
const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);
|
|
484
|
+
const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);
|
|
485
|
+
return curDist < bestDist ? cur : best;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
403
488
|
function createCanvasDocking(options = {}) {
|
|
404
489
|
let draggedNode = $3.state(null);
|
|
405
490
|
let draggedInitialPosition = $3.state(null);
|
|
@@ -407,6 +492,8 @@ function createCanvasDocking(options = {}) {
|
|
|
407
492
|
let connectingNode = $3.state(null);
|
|
408
493
|
let currentHoverTargets = $3.state(/* @__PURE__ */ new Set());
|
|
409
494
|
const isDockTarget = options.isDockTarget ?? ((target) => target.type === "boardNode");
|
|
495
|
+
const dockStrategy = options.dockStrategy ?? "center-point";
|
|
496
|
+
const exclusiveHover = options.exclusiveHover ?? true;
|
|
410
497
|
function handleNodeDragStart(params) {
|
|
411
498
|
$3.set(draggedNode, params.targetNode);
|
|
412
499
|
$3.set(draggedInitialPosition, params.targetNode?.position ? { ...params.targetNode.position } : null);
|
|
@@ -417,25 +504,41 @@ function createCanvasDocking(options = {}) {
|
|
|
417
504
|
if (!$3.get(draggedNode)) return;
|
|
418
505
|
const intersecting = getIntersectingNodes($3.get(draggedNode));
|
|
419
506
|
const currentDockTargets = intersecting.filter(isDockTarget);
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
507
|
+
if (exclusiveHover) {
|
|
508
|
+
const primaryTarget = currentDockTargets.length > 0 ? resolvePrimaryTarget(currentDockTargets, $3.get(draggedNode), dockStrategy, options.resolvePrimaryDockTarget, params.event) : null;
|
|
509
|
+
const primaryTargetId = primaryTarget ? primaryTarget.id : null;
|
|
510
|
+
$3.get(currentHoverTargets).forEach((targetId) => {
|
|
511
|
+
if (targetId !== primaryTargetId) {
|
|
512
|
+
const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };
|
|
513
|
+
options.onDockLeave?.(leftNode, $3.get(draggedNode));
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
if (primaryTarget && !$3.get(currentHoverTargets).has(primaryTarget.id)) {
|
|
517
|
+
options.onDockHover?.(primaryTarget, $3.get(draggedNode));
|
|
430
518
|
}
|
|
431
|
-
|
|
432
|
-
|
|
519
|
+
$3.set(currentHoverTargets, primaryTargetId ? /* @__PURE__ */ new Set([primaryTargetId]) : /* @__PURE__ */ new Set());
|
|
520
|
+
} else {
|
|
521
|
+
const newHoverSet = new Set(currentDockTargets.map((t) => t.id));
|
|
522
|
+
$3.get(currentHoverTargets).forEach((targetId) => {
|
|
523
|
+
if (!newHoverSet.has(targetId)) {
|
|
524
|
+
const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };
|
|
525
|
+
options.onDockLeave?.(leftNode, $3.get(draggedNode));
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
currentDockTargets.forEach((target) => {
|
|
529
|
+
if (!$3.get(currentHoverTargets).has(target.id)) {
|
|
530
|
+
options.onDockHover?.(target, $3.get(draggedNode));
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
$3.set(currentHoverTargets, newHoverSet);
|
|
534
|
+
}
|
|
433
535
|
}
|
|
434
536
|
function handleNodeDragStop(params, getIntersectingNodes, updateNodePosition) {
|
|
435
537
|
$3.set(draggedNode, params.targetNode);
|
|
436
538
|
if ($3.get(draggedNode)) {
|
|
437
539
|
const intersecting = getIntersectingNodes($3.get(draggedNode));
|
|
438
|
-
const
|
|
540
|
+
const dockTargets = intersecting.filter(isDockTarget);
|
|
541
|
+
const dockTarget = dockTargets.length > 0 ? resolvePrimaryTarget(dockTargets, $3.get(draggedNode), dockStrategy, options.resolvePrimaryDockTarget, params.event) : null;
|
|
439
542
|
if (dockTarget) {
|
|
440
543
|
options.onDockDrop?.(dockTarget, $3.get(draggedNode));
|
|
441
544
|
if (options.restorePositionOnDock !== false && $3.get(draggedInitialPosition) && updateNodePosition) {
|
package/dist/canvas/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/canvas/createCanvasGraph.svelte.ts","../../src/canvas/createCanvasLayout.ts","../../src/canvas/createCanvasClipboard.svelte.ts","../../src/canvas/createCanvasDocking.svelte.ts","../../src/canvas/createCanvasShortcuts.ts","../../src/canvas/createCanvasInteractions.svelte.ts","../../src/canvas/createCanvasTrajectory.ts","../../src/canvas/createCanvasDisplacement.ts","../../src/canvas/createCanvasExplosion.svelte.ts"],"sourcesContent":["import { cubicOut } from \"svelte/easing\";\nexport function calculateGraphDifferences(currentState, baselineState) {\n const currentNodes = currentState.nodes ?? [];\n const currentEdges = currentState.edges ?? [];\n const baselineNodes = baselineState.nodes ?? [];\n const baselineEdges = baselineState.edges ?? [];\n const baselineNodeMap = new Map(baselineNodes.map((n) => [n.id, n]));\n const baselineEdgeMap = new Map(baselineEdges.map((e) => [e.id, e]));\n const currentNodeMap = new Map(currentNodes.map((n) => [n.id, n]));\n const currentEdgeMap = new Map(currentEdges.map((e) => [e.id, e]));\n const removedNodes = baselineNodes.filter((oldNode) => !currentNodeMap.has(oldNode.id));\n const removedEdges = baselineEdges.filter((oldEdge) => !currentEdgeMap.has(oldEdge.id));\n const changedNodes = currentNodes.filter((newNode) => {\n const oldNode = baselineNodeMap.get(newNode.id);\n if (!oldNode) return true;\n return JSON.stringify(newNode) !== JSON.stringify(oldNode);\n });\n const changedEdges = currentEdges.filter((newEdge) => {\n const oldEdge = baselineEdgeMap.get(newEdge.id);\n if (!oldEdge) return true;\n return JSON.stringify(newEdge) !== JSON.stringify(oldEdge);\n });\n return { changedNodes, changedEdges, removedNodes, removedEdges };\n}\nexport function replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges = false) {\n const updatedNodes = nodes.map((n) => n.id === oldNode.id ? newNode : n);\n if (!keepEdges) {\n return { nodes: updatedNodes, edges };\n }\n const updatedEdges = edges.map((edge) => {\n if (edge.source === oldNode.id || edge.target === oldNode.id) {\n return {\n ...edge,\n id: crypto.randomUUID(),\n source: edge.source === oldNode.id ? newNode.id : edge.source,\n target: edge.target === oldNode.id ? newNode.id : edge.target\n };\n }\n return edge;\n });\n return {\n nodes: updatedNodes,\n edges: updatedEdges\n };\n}\nexport function createCanvasGraph(options = {}) {\n let nodes = $state.raw(options.initialNodes ?? []);\n let edges = $state.raw(options.initialEdges ?? []);\n function setNodes(newNodes, triggerCallback = true) {\n nodes = newNodes;\n if (triggerCallback) {\n options.onNodesChange?.(nodes);\n }\n }\n function setEdges(newEdges, triggerCallback = true) {\n edges = newEdges;\n if (triggerCallback) {\n options.onEdgesChange?.(edges);\n }\n }\n function animateNodePosition(node, targetPosition, duration = 400, easing = cubicOut) {\n const delay = node.data?.animationDelay ?? 0;\n const startPosition = { ...node.position };\n const startTime = Date.now() + delay;\n function step() {\n const currentTime = Date.now();\n if (currentTime < startTime) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n return;\n }\n const progress = Math.min((currentTime - startTime) / duration, 1);\n const eased = easing(progress);\n const currentPos = {\n x: startPosition.x + (targetPosition.x - startPosition.x) * eased,\n y: startPosition.y + (targetPosition.y - startPosition.y) * eased\n };\n const targetNode = nodes.find((n) => n.id === node.id);\n if (targetNode) {\n targetNode.position = currentPos;\n }\n if (progress < 1) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n } else {\n setNodes([...nodes]);\n }\n }\n step();\n }\n function addNodeOrNodes(nodeOrNodesToAdd, animateFromPosition, save = true) {\n const toAdd = Array.isArray(nodeOrNodesToAdd) ? nodeOrNodesToAdd : [nodeOrNodesToAdd];\n const existingMap = new Map(nodes.map((n) => [n.id, n]));\n toAdd.forEach((node) => {\n if (!existingMap.has(node.id)) {\n existingMap.set(node.id, node);\n }\n });\n setNodes(Array.from(existingMap.values()));\n if (animateFromPosition) {\n toAdd.forEach((node) => {\n const target = { ...node.position };\n node.position = { ...animateFromPosition };\n animateNodePosition(node, target);\n });\n }\n if (save) options.onSave?.();\n }\n function addEdge(edgeToAdd, save = true) {\n setEdges([...edges, edgeToAdd]);\n if (save) options.onSave?.();\n }\n function addEdges(edgesToAdd, save = true) {\n setEdges([...edges, ...edgesToAdd]);\n if (save) options.onSave?.();\n }\n function removeNodes(nodesToRemove, save = true) {\n const idsToRemove = new Set(nodesToRemove.map((n) => n.id));\n setNodes(nodes.filter((n) => !idsToRemove.has(n.id)));\n if (save) options.onSave?.();\n }\n function removeEdges(edgesToRemove, save = true) {\n const idsToRemove = new Set(edgesToRemove.map((e) => e.id));\n setEdges(edges.filter((e) => !idsToRemove.has(e.id)));\n if (save) options.onSave?.();\n }\n function replaceNode(oldNode, newNode, save = true, keepEdges = false) {\n const result = replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges);\n setNodes(result.nodes);\n if (result.edges !== edges) {\n setEdges(result.edges);\n }\n if (save) options.onSave?.();\n }\n function addConnectedNodes(params) {\n const {\n nodesToAdd,\n inboundNodes = [],\n outboundNodes = [],\n animatedEdges = false,\n animateFromPosition,\n inboundEdgeData = {},\n outboundEdgeData = {},\n getEdgeLabel\n } = params;\n const defaultCreateEdge = (sourceId, targetId, opt) => {\n if (options.createEdge) {\n return options.createEdge(sourceId, targetId, opt);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId,\n label: opt?.label ?? \"\",\n animated: opt?.animated ?? false,\n data: opt?.data ?? {}\n };\n };\n nodesToAdd.forEach((addedNode) => {\n addNodeOrNodes(addedNode, animateFromPosition, false);\n inboundNodes.forEach((sourceNode) => {\n const label = getEdgeLabel ? getEdgeLabel(sourceNode, addedNode) : \"\";\n addEdge(\n defaultCreateEdge(sourceNode.id, addedNode.id, {\n label,\n animated: animatedEdges,\n data: inboundEdgeData\n }),\n false\n );\n });\n outboundNodes.forEach((targetNode) => {\n const label = getEdgeLabel ? getEdgeLabel(addedNode, targetNode) : \"\";\n addEdge(\n defaultCreateEdge(addedNode.id, targetNode.id, {\n label,\n animated: animatedEdges,\n data: outboundEdgeData\n }),\n false\n );\n });\n });\n options.onSave?.();\n }\n function getDifferences(baseline) {\n return calculateGraphDifferences({ nodes, edges }, baseline);\n }\n return {\n get nodes() {\n return nodes;\n },\n set nodes(val) {\n setNodes(val);\n },\n get edges() {\n return edges;\n },\n set edges(val) {\n setEdges(val);\n },\n setNodes,\n setEdges,\n addNodeOrNodes,\n addEdge,\n addEdges,\n removeNodes,\n removeEdges,\n replaceNode,\n addConnectedNodes,\n animateNodePosition,\n getDifferences\n };\n}\n","import dagre from '@dagrejs/dagre';\nimport { Position, type XYPosition, type Rect } from '@xyflow/svelte';\nimport type { CanvasNode, CanvasEdge, CanvasLayoutOptions } from './types.js';\n\n/**\n * Calculates upper-left flow coordinate for an element to be centered in the viewport.\n */\nexport function getCenteredNodePosition(\n\twidth = 0,\n\theight = 0,\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tscreenDimensions?: { width: number; height: number }\n): XYPosition {\n\tconst rect = screenDimensions ?? (typeof document !== 'undefined'\n\t\t? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }\n\t\t: { width: 1920, height: 1080 });\n\n\tconst flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });\n\treturn {\n\t\tx: flowPos.x - width / 2,\n\t\ty: flowPos.y - height / 2\n\t};\n}\n\n/**\n * Updates positions of nodes so their collective bounding box is centered in the current viewport.\n */\nexport function centerNodes<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\tscreenDimensions?: { width: number; height: number }\n): TNode[] {\n\tif (nodes.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst bounds = getNodesBounds(nodes);\n\tconst boundingBoxOrigin = { x: bounds.x, y: bounds.y };\n\n\tconst centeredPosition = getCenteredNodePosition(\n\t\tbounds.width,\n\t\tbounds.height,\n\t\tscreenToFlowPosition,\n\t\tscreenDimensions\n\t);\n\n\tconst deltaX = centeredPosition.x - boundingBoxOrigin.x;\n\tconst deltaY = centeredPosition.y - boundingBoxOrigin.y;\n\n\treturn nodes.map((node) => ({\n\t\t...node,\n\t\tposition: {\n\t\t\tx: node.position.x + deltaX,\n\t\t\ty: node.position.y + deltaY\n\t\t}\n\t}));\n}\n\n/**\n * Automatically calculates directed hierarchical layout of nodes and edges using Dagre.\n */\nexport function getLayoutedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\toptions: CanvasLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 200\n\t} = options;\n\n\tconst isHorizontal = direction === 'LR' || direction === 'RL';\n\tconst bounds = getNodesBounds(nodes);\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(nodes.map((node) => node.id));\n\n\tnodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tedges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\treturn nodes.map((node) => {\n\t\tconst nodeWithPosition = dagreGraph.node(node.id);\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\treturn {\n\t\t\t...node,\n\t\t\ttargetPosition: isHorizontal ? Position.Left : Position.Top,\n\t\t\tsourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n\t\t\tposition: {\n\t\t\t\tx: bounds.x + (nodeWithPosition?.x ?? 0) - nodeWidth / 2,\n\t\t\t\ty: bounds.y + (nodeWithPosition?.y ?? 0) - nodeHeight / 2\n\t\t\t}\n\t\t};\n\t});\n}\n","import { tick } from \"svelte\";\nexport function isEventFromTextInput(event) {\n const target = event.target;\n if (!target) return false;\n if (target.tagName === \"INPUT\" || target.tagName === \"TEXTAREA\" || target.tagName === \"SELECT\" || target.isContentEditable || target.closest?.('[contenteditable=\"true\"]') || target.closest?.(\".ProseMirror\")) {\n return true;\n }\n return false;\n}\nexport function isValidCanvasNode(obj) {\n return typeof obj === \"object\" && obj !== null && \"id\" in obj && typeof obj.id === \"string\" && \"position\" in obj && typeof obj.position === \"object\" && obj.position !== null && \"x\" in obj.position && \"y\" in obj.position;\n}\nexport function isValidUrl(url) {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\nexport function createCanvasClipboard(options = {}) {\n function copySelectedNodes(selectedNodes, connectedEdges, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n if (selectedNodes.length === 0) return false;\n const payload = {\n version: 1,\n nodes: selectedNodes,\n edges: connectedEdges\n };\n const serialized = JSON.stringify(payload);\n if (event?.clipboardData) {\n event.clipboardData.setData(\"application/json\", serialized);\n event.clipboardData.setData(\"text/plain\", serialized);\n event.preventDefault();\n } else if (typeof navigator !== \"undefined\" && navigator.clipboard) {\n navigator.clipboard.writeText(serialized).catch(() => {\n });\n }\n return true;\n }\n function cutSelectedNodes(selectedNodes, connectedEdges, onRemove, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n const copied = copySelectedNodes(selectedNodes, connectedEdges, event);\n if (copied && onRemove) {\n onRemove(selectedNodes);\n }\n return copied;\n }\n async function handlePasteEvent(event) {\n if (isEventFromTextInput(event)) {\n return false;\n }\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n const files = clipboardData.files;\n if (files && files.length > 0) {\n const imageFile = Array.from(files).find((f) => f.type.startsWith(\"image/\"));\n if (imageFile && options.onPasteImage) {\n event.preventDefault();\n await options.onPasteImage(imageFile);\n return true;\n }\n }\n const rawJson = clipboardData.getData(\"application/json\") || clipboardData.getData(\"text/plain\");\n if (rawJson) {\n try {\n const parsed = JSON.parse(rawJson);\n let rawNodes;\n let rawEdges;\n if (Array.isArray(parsed) && parsed.every(isValidCanvasNode)) {\n rawNodes = parsed;\n } else if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.nodes) && parsed.nodes.every(isValidCanvasNode)) {\n rawNodes = parsed.nodes;\n rawEdges = parsed.edges;\n }\n if (rawNodes && rawNodes.length > 0) {\n event.preventDefault();\n const idMap = /* @__PURE__ */ new Map();\n const newNodes = rawNodes.map((node) => {\n const newId = crypto.randomUUID();\n idMap.set(node.id, newId);\n return {\n ...node,\n id: newId,\n selected: true,\n position: {\n x: node.position.x + 40,\n y: node.position.y + 40\n }\n };\n });\n const newEdges = rawEdges?.map((edge) => ({\n ...edge,\n id: crypto.randomUUID(),\n source: idMap.get(edge.source) ?? edge.source,\n target: idMap.get(edge.target) ?? edge.target\n }));\n if (options.onPasteNodes) {\n await options.onPasteNodes(newNodes, newEdges);\n await tick();\n }\n return true;\n }\n } catch {\n }\n }\n const text = clipboardData.getData(\"text/plain\")?.trim();\n if (text) {\n if (isValidUrl(text) && options.onPasteUrl) {\n event.preventDefault();\n options.onPasteUrl(text);\n return true;\n } else if (options.onPasteText) {\n event.preventDefault();\n options.onPasteText(text);\n return true;\n }\n }\n return false;\n }\n return {\n copySelectedNodes,\n cutSelectedNodes,\n handlePasteEvent\n };\n}\n","export function createCanvasDocking(options = {}) {\n let draggedNode = $state.raw(null);\n let draggedInitialPosition = $state.raw(null);\n let connectingHandle = $state.raw(\"\");\n let connectingNode = $state.raw(null);\n let currentHoverTargets = $state.raw(/* @__PURE__ */ new Set());\n const isDockTarget = options.isDockTarget ?? ((target) => target.type === \"boardNode\");\n function handleNodeDragStart(params) {\n draggedNode = params.targetNode;\n draggedInitialPosition = params.targetNode?.position ? { ...params.targetNode.position } : null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n function handleNodeDrag(params, getIntersectingNodes) {\n draggedNode = params.targetNode;\n if (!draggedNode) return;\n const intersecting = getIntersectingNodes(draggedNode);\n const currentDockTargets = intersecting.filter(isDockTarget);\n const newHoverSet = new Set(currentDockTargets.map((t) => t.id));\n currentHoverTargets.forEach((targetId) => {\n if (!newHoverSet.has(targetId)) {\n const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };\n options.onDockLeave?.(leftNode, draggedNode);\n }\n });\n currentDockTargets.forEach((target) => {\n if (!currentHoverTargets.has(target.id)) {\n options.onDockHover?.(target, draggedNode);\n }\n });\n currentHoverTargets = newHoverSet;\n }\n function handleNodeDragStop(params, getIntersectingNodes, updateNodePosition) {\n draggedNode = params.targetNode;\n if (draggedNode) {\n const intersecting = getIntersectingNodes(draggedNode);\n const dockTarget = intersecting.find(isDockTarget);\n if (dockTarget) {\n options.onDockDrop?.(dockTarget, draggedNode);\n if (options.restorePositionOnDock !== false && draggedInitialPosition && updateNodePosition) {\n updateNodePosition(draggedNode.id, draggedInitialPosition);\n }\n }\n }\n draggedNode = null;\n draggedInitialPosition = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n options.onSave?.();\n }\n function handleConnectStart(params, getNode) {\n connectingHandle = params.handleType ?? \"\";\n connectingNode = params.nodeId ? getNode(params.nodeId) ?? null : null;\n }\n function handleConnectEnd() {\n connectingHandle = \"\";\n connectingNode = null;\n }\n function reset() {\n draggedNode = null;\n draggedInitialPosition = null;\n connectingHandle = \"\";\n connectingNode = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n return {\n get draggedNode() {\n return draggedNode;\n },\n get draggedInitialPosition() {\n return draggedInitialPosition;\n },\n get connectingHandle() {\n return connectingHandle;\n },\n get connectingNode() {\n return connectingNode;\n },\n get isDragging() {\n return draggedNode !== null;\n },\n handleNodeDragStart,\n handleNodeDrag,\n handleNodeDragStop,\n handleConnectStart,\n handleConnectEnd,\n reset\n };\n}\n","import { isEventFromTextInput } from './createCanvasClipboard.svelte.js';\nimport type { CanvasNode, CanvasShortcutsOptions } from './types.js';\n\n/**\n * Attaches keyboard shortcut handlers for canvas interaction.\n * Automatically ignores shortcuts when the user is typing into text inputs, textareas, or rich editors.\n *\n * @returns A cleanup function to remove event listeners.\n */\nexport function createCanvasShortcuts<TNode extends CanvasNode = CanvasNode>(\n\toptions: CanvasShortcutsOptions<TNode>\n): () => void {\n\tconst target = options.targetElement ?? (typeof window !== 'undefined' ? window : null);\n\tif (!target) return () => {};\n\n\tfunction handleKeyDown(event: Event) {\n\t\tconst keyboardEvent = event as KeyboardEvent;\n\t\tif (isEventFromTextInput(keyboardEvent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMod = keyboardEvent.metaKey || keyboardEvent.ctrlKey;\n\t\tconst isShift = keyboardEvent.shiftKey;\n\t\tconst key = keyboardEvent.key;\n\n\t\tconst selectedNodes = options.getSelectedNodes ? options.getSelectedNodes() : [];\n\n\t\tif (key === 'Backspace' || key === 'Delete') {\n\t\t\tif (options.onDelete && selectedNodes.length > 0) {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\toptions.onDelete(selectedNodes);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMod) {\n\t\t\tconst lowerKey = key.toLowerCase();\n\n\t\t\tif (lowerKey === 'c' && !isShift) {\n\t\t\t\tif (options.onCopy) {\n\t\t\t\t\t// We let the native copy event fire or call onCopy\n\t\t\t\t\toptions.onCopy();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'x' && !isShift) {\n\t\t\t\tif (options.onCut) {\n\t\t\t\t\toptions.onCut();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'd' && !isShift) {\n\t\t\t\tif (options.onDuplicate && selectedNodes.length > 0) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onDuplicate(selectedNodes);\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'a' && !isShift) {\n\t\t\t\tif (options.onSelectAll) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSelectAll();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'g') {\n\t\t\t\tif (isShift) {\n\t\t\t\t\tif (options.onUngroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onUngroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (options.onGroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onGroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (key === '=' || key === '+') {\n\t\t\t\tif (options.onZoomIn) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomIn();\n\t\t\t\t}\n\t\t\t} else if (key === '-') {\n\t\t\t\tif (options.onZoomOut) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomOut();\n\t\t\t\t}\n\t\t\t} else if (key === '0') {\n\t\t\t\tif (options.onFitView) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onFitView();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'f') {\n\t\t\t\tif (options.onSearch) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSearch();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttarget.addEventListener('keydown', handleKeyDown as EventListener);\n\n\treturn () => {\n\t\ttarget.removeEventListener('keydown', handleKeyDown as EventListener);\n\t};\n}\n","import { isEventFromTextInput } from \"./createCanvasClipboard.svelte.js\";\nexport function createCanvasInteractions(options = {}) {\n let isSpacebarPanning = $state.raw(false);\n let trackpadDetected = $state.raw(false);\n let toggledPanMode = false;\n function handleKeyDown(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (isSpacebarPanning || isEventFromTextInput(event)) return;\n isSpacebarPanning = true;\n toggledPanMode = true;\n options.onPanModeChange?.(true);\n if (typeof document !== \"undefined\") {\n document.body.classList.add(\"cursor-grab\");\n }\n }\n }\n function handleKeyUp(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (!isSpacebarPanning && !toggledPanMode) return;\n isSpacebarPanning = false;\n toggledPanMode = false;\n options.onPanModeChange?.(false);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n }\n }\n function handleWheel(event) {\n if (event.ctrlKey && !trackpadDetected) {\n trackpadDetected = true;\n options.onTrackpadDetected?.();\n }\n }\n function attachListeners(target) {\n const el = target ?? options.targetElement ?? (typeof window !== \"undefined\" ? window : null);\n if (!el) return () => {\n };\n el.addEventListener(\"keydown\", handleKeyDown);\n el.addEventListener(\"keyup\", handleKeyUp);\n el.addEventListener(\"wheel\", handleWheel, { passive: true });\n return () => {\n el.removeEventListener(\"keydown\", handleKeyDown);\n el.removeEventListener(\"keyup\", handleKeyUp);\n el.removeEventListener(\"wheel\", handleWheel);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n };\n }\n return {\n get isSpacebarPanning() {\n return isSpacebarPanning;\n },\n get trackpadDetected() {\n return trackpadDetected;\n },\n attachListeners,\n destroy: attachListeners()\n };\n}\nexport const defaultSvelteFlowPreset = {\n snapGrid: [25, 25],\n panOnDrag: [0, 1, 2, 3, 4],\n panOnScroll: false,\n selectionOnDrag: false,\n colorMode: \"system\",\n multiSelectionKey: [\"Shift\", \"Meta\"]\n};\nexport const miroCompatiblePreset = {\n ...defaultSvelteFlowPreset,\n panOnDrag: [1, 2],\n selectionOnDrag: true\n};\nexport function restorePanelPointerEvents(panelSelector = \".svelte-flow__panel\") {\n if (typeof document === \"undefined\") return;\n const panels = document.querySelectorAll(panelSelector);\n panels.forEach((panel) => {\n panel.style.pointerEvents = \"auto\";\n });\n}\n","import { cubicOut } from 'svelte/easing';\nimport type { XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasNode,\n\tFanOutTrajectoryOptions,\n\tNodeTransition,\n\tTrajectoryFunction,\n\tTrajectoryPoint\n} from './types.js';\n\n/**\n * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.\n */\nexport const linearTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t},\n\t\tscale: progress,\n\t\topacity: Math.min(1, progress * 1.5)\n\t};\n};\n\n/**\n * Linear position trajectory: pure position interpolation without altering scale or opacity.\n * Used for displaced sibling nodes to ensure their visibility remains unaltered.\n */\nexport const linearPositionTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t}\n\t};\n};\n\n/**\n * Creates a fan-out trajectory where nodes arc outward from origin to target.\n * Matches the curved distribution shown in multi-node branching diagrams.\n */\nexport function createFanOutTrajectory(options: FanOutTrajectoryOptions = {}): TrajectoryFunction {\n\tconst {\n\t\tcurvature = 0.4,\n\t\tstartScale = 0,\n\t\tendScale = 1,\n\t\tstartOpacity = 0,\n\t\tendOpacity = 1\n\t} = options;\n\n\treturn (\n\t\torigin: XYPosition,\n\t\ttarget: XYPosition,\n\t\tprogress: number,\n\t\tindex: number,\n\t\ttotal: number\n\t): TrajectoryPoint => {\n\t\tconst dx = target.x - origin.x;\n\t\tconst dy = target.y - origin.y;\n\n\t\t// Normalized index from -1 (top) to +1 (bottom)\n\t\tconst normIndex = total > 1 ? (index - (total - 1) / 2) / ((total - 1) / 2) : 0;\n\n\t\t// Perpendicular control point offset to create smooth fan arc\n\t\tconst midX = origin.x + dx * 0.4;\n\t\tconst midY = origin.y + dy * 0.1 - normIndex * Math.abs(dx) * 0.15 * curvature;\n\n\t\t// Quadratic Bezier interpolation: B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * midX + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * midY + t * t * target.y;\n\n\t\tconst scale = startScale + (endScale - startScale) * progress;\n\t\tconst opacity = startOpacity + (endOpacity - startOpacity) * progress;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale,\n\t\t\topacity\n\t\t};\n\t};\n}\n\n/**\n * Creates a custom quadratic Bezier trajectory with a specified or dynamically calculated control point.\n */\nexport function createBezierTrajectory(\n\tgetControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition\n): TrajectoryFunction {\n\treturn (origin: XYPosition, target: XYPosition, progress: number): TrajectoryPoint => {\n\t\tconst cp = getControlPoint(origin, target);\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * cp.x + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * cp.y + t * t * target.y;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale: progress,\n\t\t\topacity: progress\n\t\t};\n\t};\n}\n\n/**\n * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.\n * Directly mutates node positions and data (scale, opacity) in-place during the animation loop.\n */\nexport function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(\n\ttransitions: NodeTransition<TNode>[],\n\toptions: {\n\t\tdefaultDuration?: number;\n\t\tdefaultEasing?: (t: number) => number;\n\t\tonUpdate?: () => void;\n\t\tonComplete?: () => void;\n\t} = {}\n): () => void {\n\tif (transitions.length === 0) {\n\t\toptions.onComplete?.();\n\t\treturn () => {};\n\t}\n\n\tconst { defaultDuration = 400, defaultEasing = cubicOut, onUpdate, onComplete } = options;\n\n\tlet isCancelled = false;\n\tconst startTime = Date.now();\n\n\tconst items = transitions.map((tr, i) => ({\n\t\t...tr,\n\t\tindex: tr.index ?? i,\n\t\ttotal: tr.total ?? transitions.length,\n\t\tduration: tr.duration ?? defaultDuration,\n\t\teasing: tr.easing ?? defaultEasing,\n\t\tdelay: tr.delay ?? 0,\n\t\ttrajectory: tr.trajectory ?? linearTrajectory\n\t}));\n\n\tfunction frame() {\n\t\tif (isCancelled) return;\n\n\t\tconst now = Date.now();\n\t\tlet allCompleted = true;\n\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\tconst item = items[i];\n\t\t\tconst elapsed = now - (startTime + item.delay);\n\n\t\t\tif (elapsed < 0) {\n\t\t\t\tallCompleted = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawProgress = item.duration <= 0 ? 1 : Math.min(elapsed / item.duration, 1);\n\t\t\tconst progress = item.duration <= 0 ? 1 : item.easing(rawProgress);\n\n\t\t\tconst point = item.trajectory(item.from, item.to, progress, item.index, item.total);\n\n\t\t\t// Direct in-place mutation avoids array reconstruction during RAF\n\t\t\titem.node.position = { ...point.position };\n\n\t\t\tif (point.scale !== undefined || point.opacity !== undefined) {\n\t\t\t\tif (!item.node.data) {\n\t\t\t\t\titem.node.data = {} as any;\n\t\t\t\t}\n\t\t\t\tif (point.scale !== undefined) {\n\t\t\t\t\t(item.node.data as any).scale = point.scale;\n\t\t\t\t}\n\t\t\t\tif (point.opacity !== undefined) {\n\t\t\t\t\t(item.node.data as any).opacity = point.opacity;\n\t\t\t\t\tconst currentStyle = (item.node.style || '').replace(/opacity:\\s*[^;]+;?/g, '').trim();\n\t\t\t\t\titem.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rawProgress < 1) {\n\t\t\t\tallCompleted = false;\n\t\t\t}\n\t\t}\n\n\t\tonUpdate?.();\n\n\t\tif (!allCompleted) {\n\t\t\tif (typeof requestAnimationFrame !== 'undefined') {\n\t\t\t\trequestAnimationFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tonComplete?.();\n\t\t}\n\t}\n\n\tframe();\n\n\treturn () => {\n\t\tisCancelled = true;\n\t};\n}\n","import dagre from '@dagrejs/dagre';\nimport type { Rect, XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasEdge,\n\tCanvasLayoutOptions,\n\tCanvasNode,\n\tDirectionalDisplacementOptions\n} from './types.js';\n\n/**\n * Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.\n */\nexport function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tdefaultWidth = 200,\n\tdefaultHeight = 60\n): Rect {\n\tif (nodes.length === 0) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\n\tlet minX = Infinity;\n\tlet minY = Infinity;\n\tlet maxX = -Infinity;\n\tlet maxY = -Infinity;\n\n\tfor (const node of nodes) {\n\t\tconst width = node.measured?.width ?? (node as any).width ?? defaultWidth;\n\t\tconst height = node.measured?.height ?? (node as any).height ?? defaultHeight;\n\n\t\tminX = Math.min(minX, node.position.x);\n\t\tminY = Math.min(minY, node.position.y);\n\t\tmaxX = Math.max(maxX, node.position.x + width);\n\t\tmaxY = Math.max(maxY, node.position.y + height);\n\t}\n\n\treturn {\n\t\tx: minX,\n\t\ty: minY,\n\t\twidth: maxX - minX,\n\t\theight: maxY - minY\n\t};\n}\n\n/**\n * Pure directional displacement calculation.\n * Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.\n */\nexport function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {\n\texistingNodes: TNode[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: DirectionalDisplacementOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tgetNodesBounds,\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'right',\n\t\tgap = 40,\n\t\tspreadSiblingLanes = false,\n\t\tsiblingTolerance = 50,\n\t\tminY\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (childNodes.length === 0 || existingNodes.length === 0) {\n\t\treturn displacedMap;\n\t}\n\n\tconst childBounds = getNodesBounds\n\t\t? getNodesBounds(childNodes)\n\t\t: computeNodesBoundingBox(childNodes);\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? 200;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? 60;\n\n\t// The delta space required along primary axis\n\tconst deltaPrimary = (direction === 'right' || direction === 'left')\n\t\t? childBounds.width + gap\n\t\t: childBounds.height + gap;\n\n\t// Vertical displacement parameters: upward and downward row clearance\n\tconst deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);\n\tconst deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\t// Both above and below displace equally so the row expands symmetrically\n\tconst equalDelta = Math.max(deltaUp, deltaDown);\n\n\tfor (const node of existingNodes) {\n\t\tif (node.id === originNode.id) continue;\n\n\t\tlet newX = node.position.x;\n\t\tlet newY = node.position.y;\n\t\tlet moved = false;\n\n\t\tif (direction === 'right') {\n\t\t\t// Downstream nodes strictly to the right of the origin\n\t\t\tif (node.position.x >= originNode.position.x + originWidth * 0.5) {\n\t\t\t\tnewX += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t} else if (spreadSiblingLanes) {\n\t\t\t\t// Sibling nodes occupying the same vertical space as the exploded cluster\n\t\t\t\tconst isVerticallyOverlapping =\n\t\t\t\t\tnode.position.y + ((node as any).height ?? 60) >= childBounds.y - gap &&\n\t\t\t\t\tnode.position.y <= childBounds.y + childBounds.height + gap;\n\n\t\t\t\tif (isVerticallyOverlapping && Math.abs(node.position.x - originNode.position.x) <= siblingTolerance) {\n\t\t\t\t\tconst pushDirection = node.position.y >= originNode.position.y ? 1 : -1;\n\t\t\t\t\tnewY += pushDirection * (childBounds.height * 0.5 + gap);\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (direction === 'left') {\n\t\t\tif (node.position.x <= originNode.position.x) {\n\t\t\t\tnewX -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'down') {\n\t\t\tif (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tnewY += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'up') {\n\t\t\tif (node.position.y <= originNode.position.y) {\n\t\t\t\tnewY -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'vertical') {\n\t\t\t// Row grows vertically:\n\t\t\t// Nodes strictly above the origin node move up by equalDelta\n\t\t\t// Nodes strictly below the origin node move down by equalDelta\n\t\t\t// Both above and below displace equally; horizontal position (x) is strictly preserved\n\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY -= equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY += equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (moved) {\n\t\t\tdisplacedMap.set(node.id, { x: newX, y: newY });\n\t\t}\n\t}\n\n\treturn displacedMap;\n}\n\n/**\n * Pure hierarchical Dagre reflow displacement calculation.\n * Calculates new coordinates for surrounding nodes using Dagre hierarchical layout,\n * anchoring the origin node at its current position to eliminate layout jumping.\n */\nexport function calculateReflowDisplacement<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(params: {\n\texistingNodes: TNode[];\n\texistingEdges: TEdge[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tchildEdges?: TEdge[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: CanvasLayoutOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\texistingEdges,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tchildEdges = [],\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 80,\n\t\tnodesep = 30,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 60\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (existingNodes.length === 0) return displacedMap;\n\n\tconst allNodes = [...existingNodes, ...childNodes];\n\tconst allEdges = [...existingEdges, ...childEdges];\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst allNodeIds = new Set(allNodes.map((n) => n.id));\n\n\tallNodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tallEdges.forEach((edge) => {\n\t\tif (allNodeIds.has(edge.source) && allNodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\tconst dagreOrigin = dagreGraph.node(originNode.id);\n\tif (!dagreOrigin) return displacedMap;\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? defaultNodeWidth;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? defaultNodeHeight;\n\n\t// Calculate offset so origin node remains anchored at its exact initial coordinates\n\tconst anchorOffsetX = originNode.position.x - (dagreOrigin.x - originWidth / 2);\n\tconst anchorOffsetY = originNode.position.y - (dagreOrigin.y - originHeight / 2);\n\n\texistingNodes.forEach((node) => {\n\t\tif (node.id === originNode.id) return;\n\n\t\tconst dagreNode = dagreGraph.node(node.id);\n\t\tif (!dagreNode) return;\n\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\tconst targetX = dagreNode.x - nodeWidth / 2 + anchorOffsetX;\n\t\tconst targetY = dagreNode.y - nodeHeight / 2 + anchorOffsetY;\n\n\t\t// Only include if position actually shifted\n\t\tif (Math.abs(targetX - node.position.x) > 0.5 || Math.abs(targetY - node.position.y) > 0.5) {\n\t\t\tdisplacedMap.set(node.id, { x: targetX, y: targetY });\n\t\t}\n\t});\n\n\treturn displacedMap;\n}\n","import { cubicOut } from \"svelte/easing\";\nimport {\n calculateDirectionalDisplacement,\n calculateReflowDisplacement\n} from \"./createCanvasDisplacement.js\";\nimport {\n createFanOutTrajectory,\n linearPositionTrajectory,\n runMultiNodeTransition\n} from \"./createCanvasTrajectory.js\";\nexport function createCanvasExplosion(graph, options = {}) {\n let explodedNodeIds = $state([]);\n const snapshots = /* @__PURE__ */ new Map();\n let activeAnimationCancel = null;\n function isExploded(nodeId) {\n return explodedNodeIds.includes(nodeId);\n }\n function explodeNode(parentId, explodeOptions) {\n if (isExploded(parentId)) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n childNodes,\n childEdges = [],\n connectParentToChildren = \"all\",\n displacementStrategy = \"directional\",\n directionalOptions = {},\n reflowOptions = {},\n trajectory,\n duration = 500,\n staggerDelay = 20,\n easing = cubicOut,\n onComplete\n } = explodeOptions;\n if (childNodes.length === 0) {\n return false;\n }\n let displacementMap;\n if (displacementStrategy === \"dagre\") {\n displacementMap = calculateReflowDisplacement({\n existingNodes: graph.nodes,\n existingEdges: graph.edges,\n originNode: parentNode,\n childNodes,\n childEdges,\n getNodesBounds: options.getNodesBounds,\n options: {\n ...reflowOptions,\n direction: reflowOptions.direction ?? \"LR\"\n }\n });\n } else if (displacementStrategy === \"none\") {\n displacementMap = /* @__PURE__ */ new Map();\n } else {\n displacementMap = calculateDirectionalDisplacement({\n existingNodes: graph.nodes,\n originNode: parentNode,\n childNodes,\n getNodesBounds: options.getNodesBounds,\n options: directionalOptions\n });\n }\n const displacedNodesSnapshot = Array.from(displacementMap.entries()).map(([id]) => {\n const node = graph.nodes.find((n) => n.id === id);\n return {\n id,\n originalPosition: { ...node?.position ?? { x: 0, y: 0 } }\n };\n });\n const edgesToAdd = [...childEdges];\n const defaultCreateEdge = (sourceId, targetId) => {\n if (graph.createEdge) {\n return graph.createEdge(sourceId, targetId);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId\n };\n };\n if (connectParentToChildren === \"all\" || connectParentToChildren === true) {\n childNodes.forEach((child) => {\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === child.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, child.id));\n }\n });\n } else if (connectParentToChildren === \"first\" && childNodes.length > 0) {\n const firstChild = childNodes[0];\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === firstChild.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, firstChild.id));\n }\n }\n const snapshot = {\n parentId,\n childNodeIds: childNodes.map((n) => n.id),\n childEdgeIds: edgesToAdd.map((e) => e.id),\n displacedNodes: displacedNodesSnapshot,\n timestamp: Date.now()\n };\n snapshots.set(parentId, snapshot);\n const originPos = { ...parentNode.position };\n const targetPositions = childNodes.map((child) => ({ ...child.position }));\n childNodes.forEach((child) => {\n child.position = { ...originPos };\n if (!child.data) child.data = {};\n child.data.scale = 0;\n child.data.opacity = 0;\n const currentStyle = (child.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n child.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n edgesToAdd.forEach((edge) => {\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n graph.addNodeOrNodes(childNodes, void 0, false);\n if (edgesToAdd.length > 0) {\n graph.addEdges(edgesToAdd, false);\n }\n const chosenTrajectory = trajectory ?? createFanOutTrajectory({ curvature: 0.35 });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n childNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: originPos,\n to: targetPositions[i],\n trajectory: chosenTrajectory,\n delay: i * effectiveStagger,\n duration,\n easing,\n index: i,\n total: childNodes.length\n });\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const node = graph.nodes.find((n) => n.id === nodeId);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: targetPos,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n if (edgesToAdd.length > 0) {\n const childIdSet = new Set(childNodes.map((c) => c.id));\n const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = childNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 1;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n childNodes.forEach((child, i) => {\n const node = graph.nodes.find((n) => n.id === child.id);\n if (node) {\n node.position = { ...targetPositions[i] };\n node.style = (node.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n if (node.data) {\n node.data.opacity = 1;\n }\n }\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const graphNode = graph.nodes.find((n) => n.id === nodeId);\n if (graphNode) {\n graphNode.position = { ...targetPos };\n }\n });\n edgesToAdd.forEach((edge) => {\n const graphEdge = graph.edges.find((e) => e.id === edge.id);\n if (graphEdge) {\n graphEdge.style = (graphEdge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n }\n });\n graph.setNodes([...graph.nodes]);\n graph.setEdges([...graph.edges]);\n explodedNodeIds = [...explodedNodeIds, parentId];\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function collapseNode(parentId, collapseOptions = {}) {\n const snapshot = snapshots.get(parentId);\n if (!snapshot) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n duration = 400,\n staggerDelay = 15,\n easing = cubicOut,\n trajectory,\n onComplete\n } = collapseOptions;\n const childIdSet = new Set(snapshot.childNodeIds);\n const activeChildNodes = graph.nodes.filter((n) => childIdSet.has(n.id));\n const originPos = { ...parentNode.position };\n const reverseTrajectory = trajectory ?? createFanOutTrajectory({\n curvature: 0.2,\n startScale: 1,\n endScale: 0,\n startOpacity: 1,\n endOpacity: 0\n });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n activeChildNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: { ...child.position },\n to: originPos,\n trajectory: reverseTrajectory,\n delay: (activeChildNodes.length - 1 - i) * effectiveStagger,\n duration,\n easing,\n index: i,\n total: activeChildNodes.length\n });\n });\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const node = graph.nodes.find((n) => n.id === id);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: originalPosition,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = activeChildNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 0;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n graph.removeNodes(activeChildNodes, false);\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const edgesToRemove = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (edgesToRemove.length > 0) {\n graph.removeEdges(edgesToRemove, false);\n }\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const graphNode = graph.nodes.find((n) => n.id === id);\n if (graphNode) {\n graphNode.position = { ...originalPosition };\n }\n });\n graph.setNodes([...graph.nodes]);\n snapshots.delete(parentId);\n explodedNodeIds = explodedNodeIds.filter((id) => id !== parentId);\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function toggleExplode(parentId, explodeOptions, collapseOptions) {\n if (isExploded(parentId)) {\n return collapseNode(parentId, collapseOptions);\n }\n return explodeNode(parentId, explodeOptions);\n }\n function getSnapshot(parentId) {\n return snapshots.get(parentId);\n }\n return {\n get explodedNodeIds() {\n return explodedNodeIds;\n },\n isExploded,\n explodeNode,\n collapseNode,\n toggleEx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AAM,KAAK,CAAA;MAChC;MACA,YAAU,MAAQ;AAChB,cAAM,YAAY,kBAAkB,KAAK;AACzC,cAAM,YAAY,IAAI,IAAI,SAAS,YAAY;AAC/C,cAAM,gBAAgB,MAAM,MAAM,OAAM,CAAE,MAAM,UAAU,IAAI,EAAE,EAAE,CAAA;AAClE,YAAI,cAAc,SAAS,GAAG;AAC5B,gBAAM,YAAY,eAAe,KAAK;QACxC;AACA,iBAAS,eAAe,QAAO,CAAA,EAAI,IAAI,iBAAgB,MAAO;AAC5D,gBAAM,YAAY,MAAM,MAAM,KAAI,CAAE,MAAM,EAAE,OAAO,EAAE;AACrD,cAAI,WAAW;AACb,sBAAU,WAAQ,EAAA,GAAQ,iBAAgB;UAC5C;QACF,CAAC;AACD,cAAM,SAAQ,CAAA,GAAK,MAAM,KAAK,CAAA;AAC9B,kBAAU,OAAO,QAAQ;eACzB,iBAAe,OAAG,eAAe,EAAC,OAAM,CAAE,OAAO,OAAO,QAAQ,GAAA,IAAA;AAChE,gCAAwB;AACxB,gBAAQ,SAAM;AACd,cAAM,SAAM;AACZ,qBAAU;MACZ;;AAEF,WAAO;EACT;AACA,WAAS,cAAc,UAAU,gBAAgB,iBAAiB;AAChE,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO,aAAa,UAAU,eAAe;IAC/C;AACA,WAAO,YAAY,UAAU,cAAc;EAC7C;AACA,WAAS,YAAY,UAAU;AAC7B,WAAO,UAAU,IAAI,QAAQ;EAC/B;AACA,SAAM;IACJ,IAAI,kBAAkB;AACpB,aAAM,OAAC,eAAe;IACxB;IACA;IACA;IACA;IACA;IACA;;AAEJ;","names":["cubicOut","dagre","cubicOut","cubicOut"]}
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/createCanvasGraph.svelte.ts","../../src/canvas/createCanvasLayout.ts","../../src/canvas/createCanvasClipboard.svelte.ts","../../src/canvas/createCanvasDocking.svelte.ts","../../src/canvas/createCanvasShortcuts.ts","../../src/canvas/createCanvasInteractions.svelte.ts","../../src/canvas/createCanvasTrajectory.ts","../../src/canvas/createCanvasDisplacement.ts","../../src/canvas/createCanvasExplosion.svelte.ts"],"sourcesContent":["import { cubicOut } from \"svelte/easing\";\nexport function calculateGraphDifferences(currentState, baselineState) {\n const currentNodes = currentState.nodes ?? [];\n const currentEdges = currentState.edges ?? [];\n const baselineNodes = baselineState.nodes ?? [];\n const baselineEdges = baselineState.edges ?? [];\n const baselineNodeMap = new Map(baselineNodes.map((n) => [n.id, n]));\n const baselineEdgeMap = new Map(baselineEdges.map((e) => [e.id, e]));\n const currentNodeMap = new Map(currentNodes.map((n) => [n.id, n]));\n const currentEdgeMap = new Map(currentEdges.map((e) => [e.id, e]));\n const removedNodes = baselineNodes.filter((oldNode) => !currentNodeMap.has(oldNode.id));\n const removedEdges = baselineEdges.filter((oldEdge) => !currentEdgeMap.has(oldEdge.id));\n const changedNodes = currentNodes.filter((newNode) => {\n const oldNode = baselineNodeMap.get(newNode.id);\n if (!oldNode) return true;\n return JSON.stringify(newNode) !== JSON.stringify(oldNode);\n });\n const changedEdges = currentEdges.filter((newEdge) => {\n const oldEdge = baselineEdgeMap.get(newEdge.id);\n if (!oldEdge) return true;\n return JSON.stringify(newEdge) !== JSON.stringify(oldEdge);\n });\n return { changedNodes, changedEdges, removedNodes, removedEdges };\n}\nexport function replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges = false) {\n const updatedNodes = nodes.map((n) => n.id === oldNode.id ? newNode : n);\n if (!keepEdges) {\n return { nodes: updatedNodes, edges };\n }\n const updatedEdges = edges.map((edge) => {\n if (edge.source === oldNode.id || edge.target === oldNode.id) {\n return {\n ...edge,\n id: crypto.randomUUID(),\n source: edge.source === oldNode.id ? newNode.id : edge.source,\n target: edge.target === oldNode.id ? newNode.id : edge.target\n };\n }\n return edge;\n });\n return {\n nodes: updatedNodes,\n edges: updatedEdges\n };\n}\nexport function createCanvasGraph(options = {}) {\n let nodes = $state.raw(options.initialNodes ?? []);\n let edges = $state.raw(options.initialEdges ?? []);\n function setNodes(newNodes, triggerCallback = true) {\n nodes = newNodes;\n if (triggerCallback) {\n options.onNodesChange?.(nodes);\n }\n }\n function setEdges(newEdges, triggerCallback = true) {\n edges = newEdges;\n if (triggerCallback) {\n options.onEdgesChange?.(edges);\n }\n }\n function animateNodePosition(node, targetPosition, duration = 400, easing = cubicOut) {\n const delay = node.data?.animationDelay ?? 0;\n const startPosition = { ...node.position };\n const startTime = Date.now() + delay;\n function step() {\n const currentTime = Date.now();\n if (currentTime < startTime) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n return;\n }\n const progress = Math.min((currentTime - startTime) / duration, 1);\n const eased = easing(progress);\n const currentPos = {\n x: startPosition.x + (targetPosition.x - startPosition.x) * eased,\n y: startPosition.y + (targetPosition.y - startPosition.y) * eased\n };\n const targetNode = nodes.find((n) => n.id === node.id);\n if (targetNode) {\n targetNode.position = currentPos;\n }\n if (progress < 1) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n } else {\n setNodes([...nodes]);\n }\n }\n step();\n }\n function addNodeOrNodes(nodeOrNodesToAdd, animateFromPosition, save = true) {\n const toAdd = Array.isArray(nodeOrNodesToAdd) ? nodeOrNodesToAdd : [nodeOrNodesToAdd];\n const existingMap = new Map(nodes.map((n) => [n.id, n]));\n toAdd.forEach((node) => {\n if (!existingMap.has(node.id)) {\n existingMap.set(node.id, node);\n }\n });\n setNodes(Array.from(existingMap.values()));\n if (animateFromPosition) {\n toAdd.forEach((node) => {\n const target = { ...node.position };\n node.position = { ...animateFromPosition };\n animateNodePosition(node, target);\n });\n }\n if (save) options.onSave?.();\n }\n function addEdge(edgeToAdd, save = true) {\n setEdges([...edges, edgeToAdd]);\n if (save) options.onSave?.();\n }\n function addEdges(edgesToAdd, save = true) {\n setEdges([...edges, ...edgesToAdd]);\n if (save) options.onSave?.();\n }\n function removeNodes(nodesToRemove, save = true) {\n const idsToRemove = new Set(nodesToRemove.map((n) => n.id));\n setNodes(nodes.filter((n) => !idsToRemove.has(n.id)));\n if (save) options.onSave?.();\n }\n function removeEdges(edgesToRemove, save = true) {\n const idsToRemove = new Set(edgesToRemove.map((e) => e.id));\n setEdges(edges.filter((e) => !idsToRemove.has(e.id)));\n if (save) options.onSave?.();\n }\n function replaceNode(oldNode, newNode, save = true, keepEdges = false) {\n const result = replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges);\n setNodes(result.nodes);\n if (result.edges !== edges) {\n setEdges(result.edges);\n }\n if (save) options.onSave?.();\n }\n function addConnectedNodes(params) {\n const {\n nodesToAdd,\n inboundNodes = [],\n outboundNodes = [],\n animatedEdges = false,\n animateFromPosition,\n inboundEdgeData = {},\n outboundEdgeData = {},\n getEdgeLabel\n } = params;\n const defaultCreateEdge = (sourceId, targetId, opt) => {\n if (options.createEdge) {\n return options.createEdge(sourceId, targetId, opt);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId,\n label: opt?.label ?? \"\",\n animated: opt?.animated ?? false,\n data: opt?.data ?? {}\n };\n };\n nodesToAdd.forEach((addedNode) => {\n addNodeOrNodes(addedNode, animateFromPosition, false);\n inboundNodes.forEach((sourceNode) => {\n const label = getEdgeLabel ? getEdgeLabel(sourceNode, addedNode) : \"\";\n addEdge(\n defaultCreateEdge(sourceNode.id, addedNode.id, {\n label,\n animated: animatedEdges,\n data: inboundEdgeData\n }),\n false\n );\n });\n outboundNodes.forEach((targetNode) => {\n const label = getEdgeLabel ? getEdgeLabel(addedNode, targetNode) : \"\";\n addEdge(\n defaultCreateEdge(addedNode.id, targetNode.id, {\n label,\n animated: animatedEdges,\n data: outboundEdgeData\n }),\n false\n );\n });\n });\n options.onSave?.();\n }\n function getDifferences(baseline) {\n return calculateGraphDifferences({ nodes, edges }, baseline);\n }\n return {\n get nodes() {\n return nodes;\n },\n set nodes(val) {\n setNodes(val);\n },\n get edges() {\n return edges;\n },\n set edges(val) {\n setEdges(val);\n },\n setNodes,\n setEdges,\n addNodeOrNodes,\n addEdge,\n addEdges,\n removeNodes,\n removeEdges,\n replaceNode,\n addConnectedNodes,\n animateNodePosition,\n getDifferences\n };\n}\n","import dagre from '@dagrejs/dagre';\nimport { Position, type XYPosition, type Rect } from '@xyflow/svelte';\nimport type { CanvasNode, CanvasEdge, CanvasLayoutOptions } from './types.js';\n\n/**\n * Calculates upper-left flow coordinate for an element to be centered in the viewport.\n */\nexport function getCenteredNodePosition(\n\twidth = 0,\n\theight = 0,\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tscreenDimensions?: { width: number; height: number }\n): XYPosition {\n\tconst rect = screenDimensions ?? (typeof document !== 'undefined'\n\t\t? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }\n\t\t: { width: 1920, height: 1080 });\n\n\tconst flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });\n\treturn {\n\t\tx: flowPos.x - width / 2,\n\t\ty: flowPos.y - height / 2\n\t};\n}\n\n/**\n * Updates positions of nodes so their collective bounding box is centered in the current viewport.\n */\nexport function centerNodes<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\tscreenDimensions?: { width: number; height: number }\n): TNode[] {\n\tif (nodes.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst bounds = getNodesBounds(nodes);\n\tconst boundingBoxOrigin = { x: bounds.x, y: bounds.y };\n\n\tconst centeredPosition = getCenteredNodePosition(\n\t\tbounds.width,\n\t\tbounds.height,\n\t\tscreenToFlowPosition,\n\t\tscreenDimensions\n\t);\n\n\tconst deltaX = centeredPosition.x - boundingBoxOrigin.x;\n\tconst deltaY = centeredPosition.y - boundingBoxOrigin.y;\n\n\treturn nodes.map((node) => ({\n\t\t...node,\n\t\tposition: {\n\t\t\tx: node.position.x + deltaX,\n\t\t\ty: node.position.y + deltaY\n\t\t}\n\t}));\n}\n\n/**\n * Automatically calculates directed hierarchical layout of nodes and edges using Dagre.\n */\nexport function getLayoutedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\toptions: CanvasLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 200\n\t} = options;\n\n\tconst isHorizontal = direction === 'LR' || direction === 'RL';\n\tconst bounds = getNodesBounds(nodes);\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(nodes.map((node) => node.id));\n\n\tnodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tedges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\treturn nodes.map((node) => {\n\t\tconst nodeWithPosition = dagreGraph.node(node.id);\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\treturn {\n\t\t\t...node,\n\t\t\ttargetPosition: isHorizontal ? Position.Left : Position.Top,\n\t\t\tsourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n\t\t\tposition: {\n\t\t\t\tx: bounds.x + (nodeWithPosition?.x ?? 0) - nodeWidth / 2,\n\t\t\t\ty: bounds.y + (nodeWithPosition?.y ?? 0) - nodeHeight / 2\n\t\t\t}\n\t\t};\n\t});\n}\n","import { tick } from \"svelte\";\nexport function isEventFromTextInput(event) {\n const target = event.target;\n if (!target) return false;\n if (target.tagName === \"INPUT\" || target.tagName === \"TEXTAREA\" || target.tagName === \"SELECT\" || target.isContentEditable || target.closest?.('[contenteditable=\"true\"]') || target.closest?.(\".ProseMirror\")) {\n return true;\n }\n return false;\n}\nexport function isValidCanvasNode(obj) {\n return typeof obj === \"object\" && obj !== null && \"id\" in obj && typeof obj.id === \"string\" && \"position\" in obj && typeof obj.position === \"object\" && obj.position !== null && \"x\" in obj.position && \"y\" in obj.position;\n}\nexport function isValidUrl(url) {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\nexport function createCanvasClipboard(options = {}) {\n function copySelectedNodes(selectedNodes, connectedEdges, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n if (selectedNodes.length === 0) return false;\n const payload = {\n version: 1,\n nodes: selectedNodes,\n edges: connectedEdges\n };\n const serialized = JSON.stringify(payload);\n if (event?.clipboardData) {\n event.clipboardData.setData(\"application/json\", serialized);\n event.clipboardData.setData(\"text/plain\", serialized);\n event.preventDefault();\n } else if (typeof navigator !== \"undefined\" && navigator.clipboard) {\n navigator.clipboard.writeText(serialized).catch(() => {\n });\n }\n return true;\n }\n function cutSelectedNodes(selectedNodes, connectedEdges, onRemove, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n const copied = copySelectedNodes(selectedNodes, connectedEdges, event);\n if (copied && onRemove) {\n onRemove(selectedNodes);\n }\n return copied;\n }\n async function handlePasteEvent(event) {\n if (isEventFromTextInput(event)) {\n return false;\n }\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n const files = clipboardData.files;\n if (files && files.length > 0) {\n const imageFile = Array.from(files).find((f) => f.type.startsWith(\"image/\"));\n if (imageFile && options.onPasteImage) {\n event.preventDefault();\n await options.onPasteImage(imageFile);\n return true;\n }\n }\n const rawJson = clipboardData.getData(\"application/json\") || clipboardData.getData(\"text/plain\");\n if (rawJson) {\n try {\n const parsed = JSON.parse(rawJson);\n let rawNodes;\n let rawEdges;\n if (Array.isArray(parsed) && parsed.every(isValidCanvasNode)) {\n rawNodes = parsed;\n } else if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.nodes) && parsed.nodes.every(isValidCanvasNode)) {\n rawNodes = parsed.nodes;\n rawEdges = parsed.edges;\n }\n if (rawNodes && rawNodes.length > 0) {\n event.preventDefault();\n const idMap = /* @__PURE__ */ new Map();\n const newNodes = rawNodes.map((node) => {\n const newId = crypto.randomUUID();\n idMap.set(node.id, newId);\n return {\n ...node,\n id: newId,\n selected: true,\n position: {\n x: node.position.x + 40,\n y: node.position.y + 40\n }\n };\n });\n const newEdges = rawEdges?.map((edge) => ({\n ...edge,\n id: crypto.randomUUID(),\n source: idMap.get(edge.source) ?? edge.source,\n target: idMap.get(edge.target) ?? edge.target\n }));\n if (options.onPasteNodes) {\n await options.onPasteNodes(newNodes, newEdges);\n await tick();\n }\n return true;\n }\n } catch {\n }\n }\n const text = clipboardData.getData(\"text/plain\")?.trim();\n if (text) {\n if (isValidUrl(text) && options.onPasteUrl) {\n event.preventDefault();\n options.onPasteUrl(text);\n return true;\n } else if (options.onPasteText) {\n event.preventDefault();\n options.onPasteText(text);\n return true;\n }\n }\n return false;\n }\n return {\n copySelectedNodes,\n cutSelectedNodes,\n handlePasteEvent\n };\n}\n","function getNodeRect(node) {\n const x = node.position?.x ?? 0;\n const y = node.position?.y ?? 0;\n const width = node.measured?.width ?? node.width ?? node.initialWidth ?? 0;\n const height = node.measured?.height ?? node.height ?? node.initialHeight ?? 0;\n return { x, y, width, height };\n}\nfunction getNodeCenter(node) {\n const rect = getNodeRect(node);\n return {\n x: rect.x + rect.width / 2,\n y: rect.y + rect.height / 2\n };\n}\nfunction getDistanceSq(p1, p2) {\n const dx = p1.x - p2.x;\n const dy = p1.y - p2.y;\n return dx * dx + dy * dy;\n}\nfunction getOverlapArea(rectA, rectB) {\n const xOverlap = Math.max(\n 0,\n Math.min(rectA.x + rectA.width, rectB.x + rectB.width) - Math.max(rectA.x, rectB.x)\n );\n const yOverlap = Math.max(\n 0,\n Math.min(rectA.y + rectA.height, rectB.y + rectB.height) - Math.max(rectA.y, rectB.y)\n );\n return xOverlap * yOverlap;\n}\nfunction resolvePrimaryTarget(targets, draggedNode, strategy, customResolver, event) {\n if (targets.length === 0) return null;\n if (targets.length === 1) return targets[0];\n if (customResolver) {\n const resolved = customResolver(targets, draggedNode, event);\n if (resolved !== void 0) return resolved;\n }\n if (strategy === \"first\") {\n return targets[0];\n }\n if (strategy === \"pointer\" && event) {\n const clientX = \"clientX\" in event ? event.clientX : event.touches?.[0]?.clientX;\n const clientY = \"clientY\" in event ? event.clientY : event.touches?.[0]?.clientY;\n if (typeof clientX === \"number\" && typeof clientY === \"number\") {\n const pointerInside = targets.filter((target) => {\n const r = getNodeRect(target);\n return r.width > 0 && r.height > 0 && clientX >= r.x && clientX <= r.x + r.width && clientY >= r.y && clientY <= r.y + r.height;\n });\n if (pointerInside.length === 1) return pointerInside[0];\n if (pointerInside.length > 1) {\n return pointerInside.reduce((best, cur) => {\n const bestDist = getDistanceSq(getNodeCenter(best), { x: clientX, y: clientY });\n const curDist = getDistanceSq(getNodeCenter(cur), { x: clientX, y: clientY });\n return curDist < bestDist ? cur : best;\n });\n }\n }\n }\n if (strategy === \"max-overlap\") {\n const draggedRect = getNodeRect(draggedNode);\n let maxArea = -1;\n let bestTarget = targets[0];\n for (const target of targets) {\n const targetRect = getNodeRect(target);\n const area = getOverlapArea(draggedRect, targetRect);\n if (area > maxArea) {\n maxArea = area;\n bestTarget = target;\n }\n }\n return bestTarget;\n }\n const draggedCenter = getNodeCenter(draggedNode);\n const containing = targets.filter((target) => {\n const r = getNodeRect(target);\n if (r.width > 0 && r.height > 0) {\n return draggedCenter.x >= r.x && draggedCenter.x <= r.x + r.width && draggedCenter.y >= r.y && draggedCenter.y <= r.y + r.height;\n }\n return false;\n });\n if (containing.length === 1) return containing[0];\n if (containing.length > 1) {\n return containing.reduce((best, cur) => {\n const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);\n const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);\n return curDist < bestDist ? cur : best;\n });\n }\n return targets.reduce((best, cur) => {\n const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);\n const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);\n return curDist < bestDist ? cur : best;\n });\n}\nexport function createCanvasDocking(options = {}) {\n let draggedNode = $state.raw(null);\n let draggedInitialPosition = $state.raw(null);\n let connectingHandle = $state.raw(\"\");\n let connectingNode = $state.raw(null);\n let currentHoverTargets = $state.raw(/* @__PURE__ */ new Set());\n const isDockTarget = options.isDockTarget ?? ((target) => target.type === \"boardNode\");\n const dockStrategy = options.dockStrategy ?? \"center-point\";\n const exclusiveHover = options.exclusiveHover ?? true;\n function handleNodeDragStart(params) {\n draggedNode = params.targetNode;\n draggedInitialPosition = params.targetNode?.position ? { ...params.targetNode.position } : null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n function handleNodeDrag(params, getIntersectingNodes) {\n draggedNode = params.targetNode;\n if (!draggedNode) return;\n const intersecting = getIntersectingNodes(draggedNode);\n const currentDockTargets = intersecting.filter(isDockTarget);\n if (exclusiveHover) {\n const primaryTarget = currentDockTargets.length > 0 ? resolvePrimaryTarget(\n currentDockTargets,\n draggedNode,\n dockStrategy,\n options.resolvePrimaryDockTarget,\n params.event\n ) : null;\n const primaryTargetId = primaryTarget ? primaryTarget.id : null;\n currentHoverTargets.forEach((targetId) => {\n if (targetId !== primaryTargetId) {\n const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };\n options.onDockLeave?.(leftNode, draggedNode);\n }\n });\n if (primaryTarget && !currentHoverTargets.has(primaryTarget.id)) {\n options.onDockHover?.(primaryTarget, draggedNode);\n }\n currentHoverTargets = primaryTargetId ? /* @__PURE__ */ new Set([primaryTargetId]) : /* @__PURE__ */ new Set();\n } else {\n const newHoverSet = new Set(currentDockTargets.map((t) => t.id));\n currentHoverTargets.forEach((targetId) => {\n if (!newHoverSet.has(targetId)) {\n const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };\n options.onDockLeave?.(leftNode, draggedNode);\n }\n });\n currentDockTargets.forEach((target) => {\n if (!currentHoverTargets.has(target.id)) {\n options.onDockHover?.(target, draggedNode);\n }\n });\n currentHoverTargets = newHoverSet;\n }\n }\n function handleNodeDragStop(params, getIntersectingNodes, updateNodePosition) {\n draggedNode = params.targetNode;\n if (draggedNode) {\n const intersecting = getIntersectingNodes(draggedNode);\n const dockTargets = intersecting.filter(isDockTarget);\n const dockTarget = dockTargets.length > 0 ? resolvePrimaryTarget(\n dockTargets,\n draggedNode,\n dockStrategy,\n options.resolvePrimaryDockTarget,\n params.event\n ) : null;\n if (dockTarget) {\n options.onDockDrop?.(dockTarget, draggedNode);\n if (options.restorePositionOnDock !== false && draggedInitialPosition && updateNodePosition) {\n updateNodePosition(draggedNode.id, draggedInitialPosition);\n }\n }\n }\n draggedNode = null;\n draggedInitialPosition = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n options.onSave?.();\n }\n function handleConnectStart(params, getNode) {\n connectingHandle = params.handleType ?? \"\";\n connectingNode = params.nodeId ? getNode(params.nodeId) ?? null : null;\n }\n function handleConnectEnd() {\n connectingHandle = \"\";\n connectingNode = null;\n }\n function reset() {\n draggedNode = null;\n draggedInitialPosition = null;\n connectingHandle = \"\";\n connectingNode = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n return {\n get draggedNode() {\n return draggedNode;\n },\n get draggedInitialPosition() {\n return draggedInitialPosition;\n },\n get connectingHandle() {\n return connectingHandle;\n },\n get connectingNode() {\n return connectingNode;\n },\n get isDragging() {\n return draggedNode !== null;\n },\n handleNodeDragStart,\n handleNodeDrag,\n handleNodeDragStop,\n handleConnectStart,\n handleConnectEnd,\n reset\n };\n}\n","import { isEventFromTextInput } from './createCanvasClipboard.svelte.js';\nimport type { CanvasNode, CanvasShortcutsOptions } from './types.js';\n\n/**\n * Attaches keyboard shortcut handlers for canvas interaction.\n * Automatically ignores shortcuts when the user is typing into text inputs, textareas, or rich editors.\n *\n * @returns A cleanup function to remove event listeners.\n */\nexport function createCanvasShortcuts<TNode extends CanvasNode = CanvasNode>(\n\toptions: CanvasShortcutsOptions<TNode>\n): () => void {\n\tconst target = options.targetElement ?? (typeof window !== 'undefined' ? window : null);\n\tif (!target) return () => {};\n\n\tfunction handleKeyDown(event: Event) {\n\t\tconst keyboardEvent = event as KeyboardEvent;\n\t\tif (isEventFromTextInput(keyboardEvent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMod = keyboardEvent.metaKey || keyboardEvent.ctrlKey;\n\t\tconst isShift = keyboardEvent.shiftKey;\n\t\tconst key = keyboardEvent.key;\n\n\t\tconst selectedNodes = options.getSelectedNodes ? options.getSelectedNodes() : [];\n\n\t\tif (key === 'Backspace' || key === 'Delete') {\n\t\t\tif (options.onDelete && selectedNodes.length > 0) {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\toptions.onDelete(selectedNodes);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMod) {\n\t\t\tconst lowerKey = key.toLowerCase();\n\n\t\t\tif (lowerKey === 'c' && !isShift) {\n\t\t\t\tif (options.onCopy) {\n\t\t\t\t\t// We let the native copy event fire or call onCopy\n\t\t\t\t\toptions.onCopy();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'x' && !isShift) {\n\t\t\t\tif (options.onCut) {\n\t\t\t\t\toptions.onCut();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'd' && !isShift) {\n\t\t\t\tif (options.onDuplicate && selectedNodes.length > 0) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onDuplicate(selectedNodes);\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'a' && !isShift) {\n\t\t\t\tif (options.onSelectAll) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSelectAll();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'g') {\n\t\t\t\tif (isShift) {\n\t\t\t\t\tif (options.onUngroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onUngroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (options.onGroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onGroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (key === '=' || key === '+') {\n\t\t\t\tif (options.onZoomIn) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomIn();\n\t\t\t\t}\n\t\t\t} else if (key === '-') {\n\t\t\t\tif (options.onZoomOut) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomOut();\n\t\t\t\t}\n\t\t\t} else if (key === '0') {\n\t\t\t\tif (options.onFitView) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onFitView();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'f') {\n\t\t\t\tif (options.onSearch) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSearch();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttarget.addEventListener('keydown', handleKeyDown as EventListener);\n\n\treturn () => {\n\t\ttarget.removeEventListener('keydown', handleKeyDown as EventListener);\n\t};\n}\n","import { isEventFromTextInput } from \"./createCanvasClipboard.svelte.js\";\nexport function createCanvasInteractions(options = {}) {\n let isSpacebarPanning = $state.raw(false);\n let trackpadDetected = $state.raw(false);\n let toggledPanMode = false;\n function handleKeyDown(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (isSpacebarPanning || isEventFromTextInput(event)) return;\n isSpacebarPanning = true;\n toggledPanMode = true;\n options.onPanModeChange?.(true);\n if (typeof document !== \"undefined\") {\n document.body.classList.add(\"cursor-grab\");\n }\n }\n }\n function handleKeyUp(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (!isSpacebarPanning && !toggledPanMode) return;\n isSpacebarPanning = false;\n toggledPanMode = false;\n options.onPanModeChange?.(false);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n }\n }\n function handleWheel(event) {\n if (event.ctrlKey && !trackpadDetected) {\n trackpadDetected = true;\n options.onTrackpadDetected?.();\n }\n }\n function attachListeners(target) {\n const el = target ?? options.targetElement ?? (typeof window !== \"undefined\" ? window : null);\n if (!el) return () => {\n };\n el.addEventListener(\"keydown\", handleKeyDown);\n el.addEventListener(\"keyup\", handleKeyUp);\n el.addEventListener(\"wheel\", handleWheel, { passive: true });\n return () => {\n el.removeEventListener(\"keydown\", handleKeyDown);\n el.removeEventListener(\"keyup\", handleKeyUp);\n el.removeEventListener(\"wheel\", handleWheel);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n };\n }\n return {\n get isSpacebarPanning() {\n return isSpacebarPanning;\n },\n get trackpadDetected() {\n return trackpadDetected;\n },\n attachListeners,\n destroy: attachListeners()\n };\n}\nexport const defaultSvelteFlowPreset = {\n snapGrid: [25, 25],\n panOnDrag: [0, 1, 2, 3, 4],\n panOnScroll: false,\n selectionOnDrag: false,\n colorMode: \"system\",\n multiSelectionKey: [\"Shift\", \"Meta\"]\n};\nexport const miroCompatiblePreset = {\n ...defaultSvelteFlowPreset,\n panOnDrag: [1, 2],\n selectionOnDrag: true\n};\nexport function restorePanelPointerEvents(panelSelector = \".svelte-flow__panel\") {\n if (typeof document === \"undefined\") return;\n const panels = document.querySelectorAll(panelSelector);\n panels.forEach((panel) => {\n panel.style.pointerEvents = \"auto\";\n });\n}\n","import { cubicOut } from 'svelte/easing';\nimport type { XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasNode,\n\tFanOutTrajectoryOptions,\n\tNodeTransition,\n\tTrajectoryFunction,\n\tTrajectoryPoint\n} from './types.js';\n\n/**\n * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.\n */\nexport const linearTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t},\n\t\tscale: progress,\n\t\topacity: Math.min(1, progress * 1.5)\n\t};\n};\n\n/**\n * Linear position trajectory: pure position interpolation without altering scale or opacity.\n * Used for displaced sibling nodes to ensure their visibility remains unaltered.\n */\nexport const linearPositionTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t}\n\t};\n};\n\n/**\n * Creates a fan-out trajectory where nodes arc outward from origin to target.\n * Matches the curved distribution shown in multi-node branching diagrams.\n */\nexport function createFanOutTrajectory(options: FanOutTrajectoryOptions = {}): TrajectoryFunction {\n\tconst {\n\t\tcurvature = 0.4,\n\t\tstartScale = 0,\n\t\tendScale = 1,\n\t\tstartOpacity = 0,\n\t\tendOpacity = 1\n\t} = options;\n\n\treturn (\n\t\torigin: XYPosition,\n\t\ttarget: XYPosition,\n\t\tprogress: number,\n\t\tindex: number,\n\t\ttotal: number\n\t): TrajectoryPoint => {\n\t\tconst dx = target.x - origin.x;\n\t\tconst dy = target.y - origin.y;\n\n\t\t// Normalized index from -1 (top) to +1 (bottom)\n\t\tconst normIndex = total > 1 ? (index - (total - 1) / 2) / ((total - 1) / 2) : 0;\n\n\t\t// Perpendicular control point offset to create smooth fan arc\n\t\tconst midX = origin.x + dx * 0.4;\n\t\tconst midY = origin.y + dy * 0.1 - normIndex * Math.abs(dx) * 0.15 * curvature;\n\n\t\t// Quadratic Bezier interpolation: B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * midX + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * midY + t * t * target.y;\n\n\t\tconst scale = startScale + (endScale - startScale) * progress;\n\t\tconst opacity = startOpacity + (endOpacity - startOpacity) * progress;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale,\n\t\t\topacity\n\t\t};\n\t};\n}\n\n/**\n * Creates a custom quadratic Bezier trajectory with a specified or dynamically calculated control point.\n */\nexport function createBezierTrajectory(\n\tgetControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition\n): TrajectoryFunction {\n\treturn (origin: XYPosition, target: XYPosition, progress: number): TrajectoryPoint => {\n\t\tconst cp = getControlPoint(origin, target);\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * cp.x + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * cp.y + t * t * target.y;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale: progress,\n\t\t\topacity: progress\n\t\t};\n\t};\n}\n\n/**\n * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.\n * Directly mutates node positions and data (scale, opacity) in-place during the animation loop.\n */\nexport function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(\n\ttransitions: NodeTransition<TNode>[],\n\toptions: {\n\t\tdefaultDuration?: number;\n\t\tdefaultEasing?: (t: number) => number;\n\t\tonUpdate?: () => void;\n\t\tonComplete?: () => void;\n\t} = {}\n): () => void {\n\tif (transitions.length === 0) {\n\t\toptions.onComplete?.();\n\t\treturn () => {};\n\t}\n\n\tconst { defaultDuration = 400, defaultEasing = cubicOut, onUpdate, onComplete } = options;\n\n\tlet isCancelled = false;\n\tconst startTime = Date.now();\n\n\tconst items = transitions.map((tr, i) => ({\n\t\t...tr,\n\t\tindex: tr.index ?? i,\n\t\ttotal: tr.total ?? transitions.length,\n\t\tduration: tr.duration ?? defaultDuration,\n\t\teasing: tr.easing ?? defaultEasing,\n\t\tdelay: tr.delay ?? 0,\n\t\ttrajectory: tr.trajectory ?? linearTrajectory\n\t}));\n\n\tfunction frame() {\n\t\tif (isCancelled) return;\n\n\t\tconst now = Date.now();\n\t\tlet allCompleted = true;\n\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\tconst item = items[i];\n\t\t\tconst elapsed = now - (startTime + item.delay);\n\n\t\t\tif (elapsed < 0) {\n\t\t\t\tallCompleted = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawProgress = item.duration <= 0 ? 1 : Math.min(elapsed / item.duration, 1);\n\t\t\tconst progress = item.duration <= 0 ? 1 : item.easing(rawProgress);\n\n\t\t\tconst point = item.trajectory(item.from, item.to, progress, item.index, item.total);\n\n\t\t\t// Direct in-place mutation avoids array reconstruction during RAF\n\t\t\titem.node.position = { ...point.position };\n\n\t\t\tif (point.scale !== undefined || point.opacity !== undefined) {\n\t\t\t\tif (!item.node.data) {\n\t\t\t\t\titem.node.data = {} as any;\n\t\t\t\t}\n\t\t\t\tif (point.scale !== undefined) {\n\t\t\t\t\t(item.node.data as any).scale = point.scale;\n\t\t\t\t}\n\t\t\t\tif (point.opacity !== undefined) {\n\t\t\t\t\t(item.node.data as any).opacity = point.opacity;\n\t\t\t\t\tconst currentStyle = (item.node.style || '').replace(/opacity:\\s*[^;]+;?/g, '').trim();\n\t\t\t\t\titem.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rawProgress < 1) {\n\t\t\t\tallCompleted = false;\n\t\t\t}\n\t\t}\n\n\t\tonUpdate?.();\n\n\t\tif (!allCompleted) {\n\t\t\tif (typeof requestAnimationFrame !== 'undefined') {\n\t\t\t\trequestAnimationFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tonComplete?.();\n\t\t}\n\t}\n\n\tframe();\n\n\treturn () => {\n\t\tisCancelled = true;\n\t};\n}\n","import dagre from '@dagrejs/dagre';\nimport type { Rect, XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasEdge,\n\tCanvasLayoutOptions,\n\tCanvasNode,\n\tDirectionalDisplacementOptions\n} from './types.js';\n\n/**\n * Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.\n */\nexport function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tdefaultWidth = 200,\n\tdefaultHeight = 60\n): Rect {\n\tif (nodes.length === 0) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\n\tlet minX = Infinity;\n\tlet minY = Infinity;\n\tlet maxX = -Infinity;\n\tlet maxY = -Infinity;\n\n\tfor (const node of nodes) {\n\t\tconst width = node.measured?.width ?? (node as any).width ?? defaultWidth;\n\t\tconst height = node.measured?.height ?? (node as any).height ?? defaultHeight;\n\n\t\tminX = Math.min(minX, node.position.x);\n\t\tminY = Math.min(minY, node.position.y);\n\t\tmaxX = Math.max(maxX, node.position.x + width);\n\t\tmaxY = Math.max(maxY, node.position.y + height);\n\t}\n\n\treturn {\n\t\tx: minX,\n\t\ty: minY,\n\t\twidth: maxX - minX,\n\t\theight: maxY - minY\n\t};\n}\n\n/**\n * Pure directional displacement calculation.\n * Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.\n */\nexport function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {\n\texistingNodes: TNode[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: DirectionalDisplacementOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tgetNodesBounds,\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'right',\n\t\tgap = 40,\n\t\tspreadSiblingLanes = false,\n\t\tsiblingTolerance = 50,\n\t\tminY\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (childNodes.length === 0 || existingNodes.length === 0) {\n\t\treturn displacedMap;\n\t}\n\n\tconst childBounds = getNodesBounds\n\t\t? getNodesBounds(childNodes)\n\t\t: computeNodesBoundingBox(childNodes);\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? 200;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? 60;\n\n\t// The delta space required along primary axis\n\tconst deltaPrimary = (direction === 'right' || direction === 'left')\n\t\t? childBounds.width + gap\n\t\t: childBounds.height + gap;\n\n\t// Vertical displacement parameters: upward and downward row clearance\n\tconst deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);\n\tconst deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\t// Both above and below displace equally so the row expands symmetrically\n\tconst equalDelta = Math.max(deltaUp, deltaDown);\n\n\tfor (const node of existingNodes) {\n\t\tif (node.id === originNode.id) continue;\n\n\t\tlet newX = node.position.x;\n\t\tlet newY = node.position.y;\n\t\tlet moved = false;\n\n\t\tif (direction === 'right') {\n\t\t\t// Downstream nodes strictly to the right of the origin\n\t\t\tif (node.position.x >= originNode.position.x + originWidth * 0.5) {\n\t\t\t\tnewX += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t} else if (spreadSiblingLanes) {\n\t\t\t\t// Sibling nodes occupying the same vertical space as the exploded cluster\n\t\t\t\tconst isVerticallyOverlapping =\n\t\t\t\t\tnode.position.y + ((node as any).height ?? 60) >= childBounds.y - gap &&\n\t\t\t\t\tnode.position.y <= childBounds.y + childBounds.height + gap;\n\n\t\t\t\tif (isVerticallyOverlapping && Math.abs(node.position.x - originNode.position.x) <= siblingTolerance) {\n\t\t\t\t\tconst pushDirection = node.position.y >= originNode.position.y ? 1 : -1;\n\t\t\t\t\tnewY += pushDirection * (childBounds.height * 0.5 + gap);\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (direction === 'left') {\n\t\t\tif (node.position.x <= originNode.position.x) {\n\t\t\t\tnewX -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'down') {\n\t\t\tif (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tnewY += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'up') {\n\t\t\tif (node.position.y <= originNode.position.y) {\n\t\t\t\tnewY -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'vertical') {\n\t\t\t// Row grows vertically:\n\t\t\t// Nodes strictly above the origin node move up by equalDelta\n\t\t\t// Nodes strictly below the origin node move down by equalDelta\n\t\t\t// Both above and below displace equally; horizontal position (x) is strictly preserved\n\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY -= equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY += equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (moved) {\n\t\t\tdisplacedMap.set(node.id, { x: newX, y: newY });\n\t\t}\n\t}\n\n\treturn displacedMap;\n}\n\n/**\n * Pure hierarchical Dagre reflow displacement calculation.\n * Calculates new coordinates for surrounding nodes using Dagre hierarchical layout,\n * anchoring the origin node at its current position to eliminate layout jumping.\n */\nexport function calculateReflowDisplacement<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(params: {\n\texistingNodes: TNode[];\n\texistingEdges: TEdge[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tchildEdges?: TEdge[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: CanvasLayoutOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\texistingEdges,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tchildEdges = [],\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 80,\n\t\tnodesep = 30,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 60\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (existingNodes.length === 0) return displacedMap;\n\n\tconst allNodes = [...existingNodes, ...childNodes];\n\tconst allEdges = [...existingEdges, ...childEdges];\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst allNodeIds = new Set(allNodes.map((n) => n.id));\n\n\tallNodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tallEdges.forEach((edge) => {\n\t\tif (allNodeIds.has(edge.source) && allNodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\tconst dagreOrigin = dagreGraph.node(originNode.id);\n\tif (!dagreOrigin) return displacedMap;\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? defaultNodeWidth;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? defaultNodeHeight;\n\n\t// Calculate offset so origin node remains anchored at its exact initial coordinates\n\tconst anchorOffsetX = originNode.position.x - (dagreOrigin.x - originWidth / 2);\n\tconst anchorOffsetY = originNode.position.y - (dagreOrigin.y - originHeight / 2);\n\n\texistingNodes.forEach((node) => {\n\t\tif (node.id === originNode.id) return;\n\n\t\tconst dagreNode = dagreGraph.node(node.id);\n\t\tif (!dagreNode) return;\n\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\tconst targetX = dagreNode.x - nodeWidth / 2 + anchorOffsetX;\n\t\tconst targetY = dagreNode.y - nodeHeight / 2 + anchorOffsetY;\n\n\t\t// Only include if position actually shifted\n\t\tif (Math.abs(targetX - node.position.x) > 0.5 || Math.abs(targetY - node.position.y) > 0.5) {\n\t\t\tdisplacedMap.set(node.id, { x: targetX, y: targetY });\n\t\t}\n\t});\n\n\treturn displacedMap;\n}\n","import { cubicOut } from \"svelte/easing\";\nimport {\n calculateDirectionalDisplacement,\n calculateReflowDisplacement\n} from \"./createCanvasDisplacement.js\";\nimport {\n createFanOutTrajectory,\n linearPositionTrajectory,\n runMultiNodeTransition\n} from \"./createCanvasTrajectory.js\";\nexport function createCanvasExplosion(graph, options = {}) {\n let explodedNodeIds = $state([]);\n const snapshots = /* @__PURE__ */ new Map();\n let activeAnimationCancel = null;\n function isExploded(nodeId) {\n return explodedNodeIds.includes(nodeId);\n }\n function explodeNode(parentId, explodeOptions) {\n if (isExploded(parentId)) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n childNodes,\n childEdges = [],\n connectParentToChildren = \"all\",\n displacementStrategy = \"directional\",\n directionalOptions = {},\n reflowOptions = {},\n trajectory,\n duration = 500,\n staggerDelay = 20,\n easing = cubicOut,\n onComplete\n } = explodeOptions;\n if (childNodes.length === 0) {\n return false;\n }\n let displacementMap;\n if (displacementStrategy === \"dagre\") {\n displacementMap = calculateReflowDisplacement({\n existingNodes: graph.nodes,\n existingEdges: graph.edges,\n originNode: parentNode,\n childNodes,\n childEdges,\n getNodesBounds: options.getNodesBounds,\n options: {\n ...reflowOptions,\n direction: reflowOptions.direction ?? \"LR\"\n }\n });\n } else if (displacementStrategy === \"none\") {\n displacementMap = /* @__PURE__ */ new Map();\n } else {\n displacementMap = calculateDirectionalDisplacement({\n existingNodes: graph.nodes,\n originNode: parentNode,\n childNodes,\n getNodesBounds: options.getNodesBounds,\n options: directionalOptions\n });\n }\n const displacedNodesSnapshot = Array.from(displacementMap.entries()).map(([id]) => {\n const node = graph.nodes.find((n) => n.id === id);\n return {\n id,\n originalPosition: { ...node?.position ?? { x: 0, y: 0 } }\n };\n });\n const edgesToAdd = [...childEdges];\n const defaultCreateEdge = (sourceId, targetId) => {\n if (graph.createEdge) {\n return graph.createEdge(sourceId, targetId);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId\n };\n };\n if (connectParentToChildren === \"all\" || connectParentToChildren === true) {\n childNodes.forEach((child) => {\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === child.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, child.id));\n }\n });\n } else if (connectParentToChildren === \"first\" && childNodes.length > 0) {\n const firstChild = childNodes[0];\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === firstChild.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, firstChild.id));\n }\n }\n const snapshot = {\n parentId,\n childNodeIds: childNodes.map((n) => n.id),\n childEdgeIds: edgesToAdd.map((e) => e.id),\n displacedNodes: displacedNodesSnapshot,\n timestamp: Date.now()\n };\n snapshots.set(parentId, snapshot);\n const originPos = { ...parentNode.position };\n const targetPositions = childNodes.map((child) => ({ ...child.position }));\n childNodes.forEach((child) => {\n child.position = { ...originPos };\n if (!child.data) child.data = {};\n child.data.scale = 0;\n child.data.opacity = 0;\n const currentStyle = (child.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n child.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n edgesToAdd.forEach((edge) => {\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n graph.addNodeOrNodes(childNodes, void 0, false);\n if (edgesToAdd.length > 0) {\n graph.addEdges(edgesToAdd, false);\n }\n const chosenTrajectory = trajectory ?? createFanOutTrajectory({ curvature: 0.35 });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n childNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: originPos,\n to: targetPositions[i],\n trajectory: chosenTrajectory,\n delay: i * effectiveStagger,\n duration,\n easing,\n index: i,\n total: childNodes.length\n });\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const node = graph.nodes.find((n) => n.id === nodeId);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: targetPos,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n if (edgesToAdd.length > 0) {\n const childIdSet = new Set(childNodes.map((c) => c.id));\n const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = childNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 1;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n childNodes.forEach((child, i) => {\n const node = graph.nodes.find((n) => n.id === child.id);\n if (node) {\n node.position = { ...targetPositions[i] };\n node.style = (node.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n if (node.data) {\n node.data.opacity = 1;\n }\n }\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const graphNode = graph.nodes.find((n) => n.id === nodeId);\n if (graphNode) {\n graphNode.position = { ...targetPos };\n }\n });\n edgesToAdd.forEach((edge) => {\n const graphEdge = graph.edges.find((e) => e.id === edge.id);\n if (graphEdge) {\n graphEdge.style = (graphEdge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n }\n });\n graph.setNodes([...graph.nodes]);\n graph.setEdges([...graph.edges]);\n explodedNodeIds = [...explodedNodeIds, parentId];\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function collapseNode(parentId, collapseOptions = {}) {\n const snapshot = snapshots.get(parentId);\n if (!snapshot) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n duration = 400,\n staggerDelay = 15,\n easing = cubicOut,\n trajectory,\n onComplete\n } = collapseOptions;\n const childIdSet = new Set(snapshot.childNodeIds);\n const activeChildNodes = graph.nodes.filter((n) => childIdSet.has(n.id));\n const originPos = { ...parentNode.position };\n const reverseTrajectory = trajectory ?? createFanOutTrajectory({\n curvature: 0.2,\n startScale: 1,\n endScale: 0,\n startOpacity: 1,\n endOpacity: 0\n });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n activeChildNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: { ...child.position },\n to: originPos,\n trajectory: reverseTrajectory,\n delay: (activeChildNodes.length - 1 - i) * effectiveStagger,\n duration,\n easing,\n index: i,\n total: activeChildNodes.length\n });\n });\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const node = graph.nodes.find((n) => n.id === id);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: originalPosition,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = activeChildNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 0;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n graph.removeNodes(activeChildNodes, false);\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const edgesToRemove = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (edgesToRemove.length > 0) {\n graph.removeEdges(edgesToRemove, false);\n }\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const graphNode = graph.nodes.find((n) => n.id === id);\n if (graphNode) {\n graphNode.position = { ...originalPosition };\n }\n });\n graph.setNodes([...graph.nodes]);\n snapshots.delete(parentId);\n explodedNodeIds = explodedNodeIds.filter((id) => id !== parentId);\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function toggleExplode(parentId, explodeOptions, collapseOptions) {\n if (isExploded(parentId)) {\n return collapseNode(parentId, collapseOptions);\n }\n return explodeNode(parentId, explodeOptions);\n }\n function getSnapshot(parentId) {\n return snapshots.get(parentId);\n }\n return {\n get explodedNodeIds() {\n return explodedNodeIds;\n },\n isExploded,\n explodeNode,\n collapseNode,\n toggleExplode,\n getSnapshot\n };\n}\n"],"mappings":";;AAAA,SAAS,gBAAgB;AAClB,SAAS,0BAA0B,cAAc,eAAe;AACrE,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE,CAAA;AACrF,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE,CAAA;AACrF,QAAM,eAAe,aAAa,OAAM,CAAE,YAAY;AACpD,UAAM,UAAU,gBAAgB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UAAU,gBAAgB,iBAAiB;AAChE,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO,aAAa,UAAU,eAAe;IAC/C;AACA,WAAO,YAAY,UAAU,cAAc;EAC7C;AACA,WAAS,YAAY,UAAU;AAC7B,WAAO,UAAU,IAAI,QAAQ;EAC/B;AACA,SAAM;IACJ,IAAI,kBAAkB;AACpB,aAAM,OAAC,eAAe;IACxB;IACA;IACA;IACA;IACA;IACA;;AAEJ;","names":["cubicOut","dagre","cubicOut","cubicOut"]}
|
package/package.json
CHANGED
package/src/canvas/README.md
CHANGED
|
@@ -139,11 +139,23 @@ Headless clipboard interaction:
|
|
|
139
139
|
|
|
140
140
|
### `createCanvasDocking(options?)`
|
|
141
141
|
|
|
142
|
-
Drag-and-dock interaction tracking:
|
|
142
|
+
Drag-and-dock interaction tracking and multi-target disambiguation:
|
|
143
143
|
|
|
144
|
+
#### Parameters (`options`):
|
|
145
|
+
- `isDockTarget?: (target: TNode) => boolean`: Filter determining whether an intersecting node is a valid dock target.
|
|
146
|
+
- `dockStrategy?: 'center-point' | 'max-overlap' | 'pointer' | 'first'`: Disambiguation strategy when a dragged node intersects multiple candidate dock targets (defaults to `'center-point'`).
|
|
147
|
+
- `resolvePrimaryDockTarget?: (targets, draggedNode, event?) => TNode | null`: Custom target resolution callback that takes precedence over `dockStrategy`.
|
|
148
|
+
- `exclusiveHover?: boolean`: When `true` (default), ensures only the single disambiguated primary dock target is hovered at any time, firing `onDockLeave` on the previous target when moving between adjacent targets. Set to `false` for concurrent multi-target hover.
|
|
149
|
+
- `restorePositionOnDock?: boolean`: Restores dragged node initial position upon successful dock drop (defaults to `true`).
|
|
150
|
+
- `onDockHover?: (target, draggedNode) => void`: Callback fired when entering a dock target.
|
|
151
|
+
- `onDockLeave?: (target, draggedNode) => void`: Callback fired when leaving a dock target.
|
|
152
|
+
- `onDockDrop?: (target, draggedNode) => void`: Callback fired on drop into a dock target.
|
|
153
|
+
- `onSave?: () => void`: Optional persistence trigger.
|
|
154
|
+
|
|
155
|
+
#### Methods:
|
|
144
156
|
- `handleNodeDragStart({ targetNode, event })`: Starts drag tracking.
|
|
145
|
-
- `handleNodeDrag({ targetNode, event }, getIntersectingNodes)`: Computes intersections,
|
|
146
|
-
- `handleNodeDragStop({ targetNode, event }, getIntersectingNodes, updatePosition?)`:
|
|
157
|
+
- `handleNodeDrag({ targetNode, event }, getIntersectingNodes)`: Computes intersections, disambiguates primary target, and fires `onDockHover` / `onDockLeave`.
|
|
158
|
+
- `handleNodeDragStop({ targetNode, event }, getIntersectingNodes, updatePosition?)`: Disambiguates primary target, fires `onDockDrop`, and cleans up state.
|
|
147
159
|
- `handleConnectStart` / `handleConnectEnd`: Tracks connection handle dragging.
|
|
148
160
|
|
|
149
161
|
---
|
|
@@ -133,4 +133,156 @@ describe('createCanvasDocking', () => {
|
|
|
133
133
|
expect(docking.draggedNode).toBeNull();
|
|
134
134
|
expect(docking.draggedInitialPosition).toBeNull();
|
|
135
135
|
});
|
|
136
|
+
|
|
137
|
+
describe('Dock Target Disambiguation & Exclusive Hover', () => {
|
|
138
|
+
it('disambiguates adjacent targets using default center-point strategy and exclusive hover', () => {
|
|
139
|
+
const onDockHover = vi.fn();
|
|
140
|
+
const onDockLeave = vi.fn();
|
|
141
|
+
const onDockDrop = vi.fn();
|
|
142
|
+
|
|
143
|
+
const docking = createCanvasDocking({
|
|
144
|
+
isDockTarget: (n) => n.type === 'dockArea',
|
|
145
|
+
onDockHover,
|
|
146
|
+
onDockLeave,
|
|
147
|
+
onDockDrop
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Adjacent columns: dockA [0, 200] and dockB [200, 400]
|
|
151
|
+
const dockA = {
|
|
152
|
+
...createSampleNode('dock-a', 'dockArea', 0, 0),
|
|
153
|
+
measured: { width: 200, height: 400 }
|
|
154
|
+
};
|
|
155
|
+
const dockB = {
|
|
156
|
+
...createSampleNode('dock-b', 'dockArea', 200, 0),
|
|
157
|
+
measured: { width: 200, height: 400 }
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Dragged card with width 100, positioned at x: 50 -> center is x: 100 (inside dockA)
|
|
161
|
+
const draggedNode = {
|
|
162
|
+
...createSampleNode('dragged', 'item', 50, 50),
|
|
163
|
+
measured: { width: 100, height: 50 }
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
docking.handleNodeDragStart({ targetNode: draggedNode });
|
|
167
|
+
|
|
168
|
+
// Even if xyflow returns both intersecting targets
|
|
169
|
+
docking.handleNodeDrag(
|
|
170
|
+
{ targetNode: draggedNode },
|
|
171
|
+
() => [dockA, dockB]
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// Only dockA receives hover
|
|
175
|
+
expect(onDockHover).toHaveBeenCalledTimes(1);
|
|
176
|
+
expect(onDockHover).toHaveBeenCalledWith(dockA, draggedNode);
|
|
177
|
+
expect(onDockLeave).not.toHaveBeenCalled();
|
|
178
|
+
|
|
179
|
+
// Card dragged across boundary: x: 160 -> center is x: 210 (inside dockB)
|
|
180
|
+
draggedNode.position = { x: 160, y: 50 };
|
|
181
|
+
docking.handleNodeDrag(
|
|
182
|
+
{ targetNode: draggedNode },
|
|
183
|
+
() => [dockA, dockB]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// dockA is left, dockB is entered
|
|
187
|
+
expect(onDockLeave).toHaveBeenCalledTimes(1);
|
|
188
|
+
expect(onDockLeave).toHaveBeenCalledWith(expect.objectContaining({ id: 'dock-a' }), draggedNode);
|
|
189
|
+
expect(onDockHover).toHaveBeenCalledTimes(2);
|
|
190
|
+
expect(onDockHover).toHaveBeenLastCalledWith(dockB, draggedNode);
|
|
191
|
+
|
|
192
|
+
// Dropping selects dockB, not dockA
|
|
193
|
+
docking.handleNodeDragStop(
|
|
194
|
+
{ targetNode: draggedNode },
|
|
195
|
+
() => [dockA, dockB]
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(onDockDrop).toHaveBeenCalledTimes(1);
|
|
199
|
+
expect(onDockDrop).toHaveBeenCalledWith(dockB, draggedNode);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('disambiguates candidate targets using max-overlap strategy', () => {
|
|
203
|
+
const onDockHover = vi.fn();
|
|
204
|
+
const onDockDrop = vi.fn();
|
|
205
|
+
|
|
206
|
+
const docking = createCanvasDocking({
|
|
207
|
+
isDockTarget: (n) => n.type === 'dockArea',
|
|
208
|
+
dockStrategy: 'max-overlap',
|
|
209
|
+
onDockHover,
|
|
210
|
+
onDockDrop
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// dockA: [0, 100] (area overlap will be 20 * 50 = 1000)
|
|
214
|
+
const dockA = {
|
|
215
|
+
...createSampleNode('dock-a', 'dockArea', 0, 0),
|
|
216
|
+
measured: { width: 100, height: 200 }
|
|
217
|
+
};
|
|
218
|
+
// dockB: [100, 300] (area overlap will be 80 * 50 = 4000)
|
|
219
|
+
const dockB = {
|
|
220
|
+
...createSampleNode('dock-b', 'dockArea', 100, 0),
|
|
221
|
+
measured: { width: 200, height: 200 }
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Dragged card spanning x: 80 to 180 (width 100)
|
|
225
|
+
const draggedNode = {
|
|
226
|
+
...createSampleNode('dragged', 'item', 80, 50),
|
|
227
|
+
measured: { width: 100, height: 50 }
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
docking.handleNodeDragStart({ targetNode: draggedNode });
|
|
231
|
+
docking.handleNodeDrag({ targetNode: draggedNode }, () => [dockA, dockB]);
|
|
232
|
+
|
|
233
|
+
// dockB has the larger overlap area (80px vs 20px width)
|
|
234
|
+
expect(onDockHover).toHaveBeenCalledWith(dockB, draggedNode);
|
|
235
|
+
|
|
236
|
+
docking.handleNodeDragStop({ targetNode: draggedNode }, () => [dockA, dockB]);
|
|
237
|
+
expect(onDockDrop).toHaveBeenCalledWith(dockB, draggedNode);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('allows custom resolvePrimaryDockTarget callback to take precedence', () => {
|
|
241
|
+
const onDockHover = vi.fn();
|
|
242
|
+
const onDockDrop = vi.fn();
|
|
243
|
+
|
|
244
|
+
const dockA = createSampleNode('dock-a', 'dockArea', 0, 0);
|
|
245
|
+
const dockB = createSampleNode('dock-b', 'dockArea', 100, 0);
|
|
246
|
+
const draggedNode = createSampleNode('dragged', 'item', 0, 0);
|
|
247
|
+
|
|
248
|
+
const docking = createCanvasDocking({
|
|
249
|
+
isDockTarget: (n) => n.type === 'dockArea',
|
|
250
|
+
resolvePrimaryDockTarget: (targets) => targets.find((t) => t.id === 'dock-b') ?? null,
|
|
251
|
+
onDockHover,
|
|
252
|
+
onDockDrop
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
docking.handleNodeDragStart({ targetNode: draggedNode });
|
|
256
|
+
docking.handleNodeDrag({ targetNode: draggedNode }, () => [dockA, dockB]);
|
|
257
|
+
|
|
258
|
+
expect(onDockHover).toHaveBeenCalledWith(dockB, draggedNode);
|
|
259
|
+
|
|
260
|
+
docking.handleNodeDragStop({ targetNode: draggedNode }, () => [dockA, dockB]);
|
|
261
|
+
expect(onDockDrop).toHaveBeenCalledWith(dockB, draggedNode);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('supports non-exclusive hover mode when exclusiveHover is false', () => {
|
|
265
|
+
const onDockHover = vi.fn();
|
|
266
|
+
const onDockLeave = vi.fn();
|
|
267
|
+
|
|
268
|
+
const docking = createCanvasDocking({
|
|
269
|
+
isDockTarget: (n) => n.type === 'dockArea',
|
|
270
|
+
exclusiveHover: false,
|
|
271
|
+
onDockHover,
|
|
272
|
+
onDockLeave
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const dockA = createSampleNode('dock-a', 'dockArea', 0, 0);
|
|
276
|
+
const dockB = createSampleNode('dock-b', 'dockArea', 100, 0);
|
|
277
|
+
const draggedNode = createSampleNode('dragged', 'item', 50, 0);
|
|
278
|
+
|
|
279
|
+
docking.handleNodeDragStart({ targetNode: draggedNode });
|
|
280
|
+
docking.handleNodeDrag({ targetNode: draggedNode }, () => [dockA, dockB]);
|
|
281
|
+
|
|
282
|
+
// Both targets should receive hover in non-exclusive mode
|
|
283
|
+
expect(onDockHover).toHaveBeenCalledTimes(2);
|
|
284
|
+
expect(onDockHover).toHaveBeenCalledWith(dockA, draggedNode);
|
|
285
|
+
expect(onDockHover).toHaveBeenCalledWith(dockB, draggedNode);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
136
288
|
});
|
|
@@ -1,11 +1,179 @@
|
|
|
1
1
|
import type { XYPosition } from '@xyflow/svelte';
|
|
2
|
-
import type { CanvasNode, CanvasDockingCallbacks } from './types.js';
|
|
2
|
+
import type { CanvasNode, CanvasDockingCallbacks, DockStrategy } from './types.js';
|
|
3
|
+
|
|
4
|
+
export type { DockStrategy };
|
|
3
5
|
|
|
4
6
|
export interface CreateCanvasDockingOptions<TNode extends CanvasNode = CanvasNode>
|
|
5
7
|
extends CanvasDockingCallbacks<TNode> {
|
|
6
8
|
isDockTarget?: (target: TNode) => boolean;
|
|
7
9
|
restorePositionOnDock?: boolean;
|
|
8
10
|
onSave?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Disambiguation strategy when multiple candidate dock targets intersect the dragged node.
|
|
13
|
+
* - 'center-point': (Default) Resolves the target enclosing or closest to the dragged node's center.
|
|
14
|
+
* - 'max-overlap': Resolves the target with the greatest overlapping area.
|
|
15
|
+
* - 'pointer': Resolves the target enclosing or closest to the mouse/touch cursor.
|
|
16
|
+
* - 'first': Resolves the first intersecting target (legacy behavior).
|
|
17
|
+
*/
|
|
18
|
+
dockStrategy?: DockStrategy;
|
|
19
|
+
/**
|
|
20
|
+
* Custom primary dock target resolution callback. If provided and returns a node, takes precedence.
|
|
21
|
+
*/
|
|
22
|
+
resolvePrimaryDockTarget?: (
|
|
23
|
+
targets: TNode[],
|
|
24
|
+
draggedNode: TNode,
|
|
25
|
+
event?: MouseEvent | TouchEvent
|
|
26
|
+
) => TNode | null;
|
|
27
|
+
/**
|
|
28
|
+
* When true (default), ensures only a single primary dock target is considered hovered at any time.
|
|
29
|
+
* Transitioning across adjacent dock targets automatically fires onDockLeave on the previous target
|
|
30
|
+
* and onDockHover on the new target. Set to false to allow concurrent multi-target hover.
|
|
31
|
+
*/
|
|
32
|
+
exclusiveHover?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface NodeRect {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getNodeRect(node: CanvasNode): NodeRect {
|
|
43
|
+
const x = node.position?.x ?? 0;
|
|
44
|
+
const y = node.position?.y ?? 0;
|
|
45
|
+
const width =
|
|
46
|
+
(node as any).measured?.width ??
|
|
47
|
+
(node as any).width ??
|
|
48
|
+
(node as any).initialWidth ??
|
|
49
|
+
0;
|
|
50
|
+
const height =
|
|
51
|
+
(node as any).measured?.height ??
|
|
52
|
+
(node as any).height ??
|
|
53
|
+
(node as any).initialHeight ??
|
|
54
|
+
0;
|
|
55
|
+
return { x, y, width, height };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getNodeCenter(node: CanvasNode): { x: number; y: number } {
|
|
59
|
+
const rect = getNodeRect(node);
|
|
60
|
+
return {
|
|
61
|
+
x: rect.x + rect.width / 2,
|
|
62
|
+
y: rect.y + rect.height / 2
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getDistanceSq(p1: { x: number; y: number }, p2: { x: number; y: number }): number {
|
|
67
|
+
const dx = p1.x - p2.x;
|
|
68
|
+
const dy = p1.y - p2.y;
|
|
69
|
+
return dx * dx + dy * dy;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getOverlapArea(rectA: NodeRect, rectB: NodeRect): number {
|
|
73
|
+
const xOverlap = Math.max(
|
|
74
|
+
0,
|
|
75
|
+
Math.min(rectA.x + rectA.width, rectB.x + rectB.width) - Math.max(rectA.x, rectB.x)
|
|
76
|
+
);
|
|
77
|
+
const yOverlap = Math.max(
|
|
78
|
+
0,
|
|
79
|
+
Math.min(rectA.y + rectA.height, rectB.y + rectB.height) - Math.max(rectA.y, rectB.y)
|
|
80
|
+
);
|
|
81
|
+
return xOverlap * yOverlap;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function resolvePrimaryTarget<TNode extends CanvasNode>(
|
|
85
|
+
targets: TNode[],
|
|
86
|
+
draggedNode: TNode,
|
|
87
|
+
strategy: DockStrategy,
|
|
88
|
+
customResolver?: (
|
|
89
|
+
targets: TNode[],
|
|
90
|
+
draggedNode: TNode,
|
|
91
|
+
event?: MouseEvent | TouchEvent
|
|
92
|
+
) => TNode | null,
|
|
93
|
+
event?: MouseEvent | TouchEvent
|
|
94
|
+
): TNode | null {
|
|
95
|
+
if (targets.length === 0) return null;
|
|
96
|
+
if (targets.length === 1) return targets[0];
|
|
97
|
+
|
|
98
|
+
if (customResolver) {
|
|
99
|
+
const resolved = customResolver(targets, draggedNode, event);
|
|
100
|
+
if (resolved !== undefined) return resolved;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (strategy === 'first') {
|
|
104
|
+
return targets[0];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (strategy === 'pointer' && event) {
|
|
108
|
+
const clientX = 'clientX' in event ? event.clientX : event.touches?.[0]?.clientX;
|
|
109
|
+
const clientY = 'clientY' in event ? event.clientY : event.touches?.[0]?.clientY;
|
|
110
|
+
if (typeof clientX === 'number' && typeof clientY === 'number') {
|
|
111
|
+
const pointerInside = targets.filter((target) => {
|
|
112
|
+
const r = getNodeRect(target);
|
|
113
|
+
return (
|
|
114
|
+
r.width > 0 &&
|
|
115
|
+
r.height > 0 &&
|
|
116
|
+
clientX >= r.x &&
|
|
117
|
+
clientX <= r.x + r.width &&
|
|
118
|
+
clientY >= r.y &&
|
|
119
|
+
clientY <= r.y + r.height
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
if (pointerInside.length === 1) return pointerInside[0];
|
|
123
|
+
if (pointerInside.length > 1) {
|
|
124
|
+
return pointerInside.reduce((best, cur) => {
|
|
125
|
+
const bestDist = getDistanceSq(getNodeCenter(best), { x: clientX, y: clientY });
|
|
126
|
+
const curDist = getDistanceSq(getNodeCenter(cur), { x: clientX, y: clientY });
|
|
127
|
+
return curDist < bestDist ? cur : best;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (strategy === 'max-overlap') {
|
|
134
|
+
const draggedRect = getNodeRect(draggedNode);
|
|
135
|
+
let maxArea = -1;
|
|
136
|
+
let bestTarget = targets[0];
|
|
137
|
+
for (const target of targets) {
|
|
138
|
+
const targetRect = getNodeRect(target);
|
|
139
|
+
const area = getOverlapArea(draggedRect, targetRect);
|
|
140
|
+
if (area > maxArea) {
|
|
141
|
+
maxArea = area;
|
|
142
|
+
bestTarget = target;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return bestTarget;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Strategy: 'center-point' (default)
|
|
149
|
+
const draggedCenter = getNodeCenter(draggedNode);
|
|
150
|
+
const containing = targets.filter((target) => {
|
|
151
|
+
const r = getNodeRect(target);
|
|
152
|
+
if (r.width > 0 && r.height > 0) {
|
|
153
|
+
return (
|
|
154
|
+
draggedCenter.x >= r.x &&
|
|
155
|
+
draggedCenter.x <= r.x + r.width &&
|
|
156
|
+
draggedCenter.y >= r.y &&
|
|
157
|
+
draggedCenter.y <= r.y + r.height
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (containing.length === 1) return containing[0];
|
|
164
|
+
if (containing.length > 1) {
|
|
165
|
+
return containing.reduce((best, cur) => {
|
|
166
|
+
const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);
|
|
167
|
+
const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);
|
|
168
|
+
return curDist < bestDist ? cur : best;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return targets.reduce((best, cur) => {
|
|
173
|
+
const bestDist = getDistanceSq(getNodeCenter(best), draggedCenter);
|
|
174
|
+
const curDist = getDistanceSq(getNodeCenter(cur), draggedCenter);
|
|
175
|
+
return curDist < bestDist ? cur : best;
|
|
176
|
+
});
|
|
9
177
|
}
|
|
10
178
|
|
|
11
179
|
/**
|
|
@@ -21,6 +189,8 @@ export function createCanvasDocking<TNode extends CanvasNode = CanvasNode>(
|
|
|
21
189
|
let currentHoverTargets = $state.raw<Set<string>>(new Set());
|
|
22
190
|
|
|
23
191
|
const isDockTarget = options.isDockTarget ?? ((target: TNode) => (target as any).type === 'boardNode');
|
|
192
|
+
const dockStrategy = options.dockStrategy ?? 'center-point';
|
|
193
|
+
const exclusiveHover = options.exclusiveHover ?? true;
|
|
24
194
|
|
|
25
195
|
function handleNodeDragStart(params: {
|
|
26
196
|
targetNode: TNode | null;
|
|
@@ -43,24 +213,54 @@ export function createCanvasDocking<TNode extends CanvasNode = CanvasNode>(
|
|
|
43
213
|
|
|
44
214
|
const intersecting = getIntersectingNodes(draggedNode);
|
|
45
215
|
const currentDockTargets = intersecting.filter(isDockTarget);
|
|
46
|
-
const newHoverSet = new Set(currentDockTargets.map((t) => t.id));
|
|
47
216
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
217
|
+
if (exclusiveHover) {
|
|
218
|
+
const primaryTarget =
|
|
219
|
+
currentDockTargets.length > 0
|
|
220
|
+
? resolvePrimaryTarget(
|
|
221
|
+
currentDockTargets,
|
|
222
|
+
draggedNode,
|
|
223
|
+
dockStrategy,
|
|
224
|
+
options.resolvePrimaryDockTarget,
|
|
225
|
+
params.event
|
|
226
|
+
)
|
|
227
|
+
: null;
|
|
228
|
+
const primaryTargetId = primaryTarget ? primaryTarget.id : null;
|
|
229
|
+
|
|
230
|
+
// Fire onDockLeave for previous targets no longer considered primary
|
|
231
|
+
currentHoverTargets.forEach((targetId) => {
|
|
232
|
+
if (targetId !== primaryTargetId) {
|
|
233
|
+
const leftNode = intersecting.find((n) => n.id === targetId) ?? ({ id: targetId } as TNode);
|
|
234
|
+
options.onDockLeave?.(leftNode, draggedNode!);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
55
237
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
options.onDockHover?.(target, draggedNode!);
|
|
238
|
+
// Fire onDockHover if entering a new primary target
|
|
239
|
+
if (primaryTarget && !currentHoverTargets.has(primaryTarget.id)) {
|
|
240
|
+
options.onDockHover?.(primaryTarget, draggedNode);
|
|
60
241
|
}
|
|
61
|
-
});
|
|
62
242
|
|
|
63
|
-
|
|
243
|
+
currentHoverTargets = primaryTargetId ? new Set([primaryTargetId]) : new Set();
|
|
244
|
+
} else {
|
|
245
|
+
const newHoverSet = new Set(currentDockTargets.map((t) => t.id));
|
|
246
|
+
|
|
247
|
+
// Check for left targets
|
|
248
|
+
currentHoverTargets.forEach((targetId) => {
|
|
249
|
+
if (!newHoverSet.has(targetId)) {
|
|
250
|
+
const leftNode = intersecting.find((n) => n.id === targetId) ?? ({ id: targetId } as TNode);
|
|
251
|
+
options.onDockLeave?.(leftNode, draggedNode!);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// Check for newly entered targets
|
|
256
|
+
currentDockTargets.forEach((target) => {
|
|
257
|
+
if (!currentHoverTargets.has(target.id)) {
|
|
258
|
+
options.onDockHover?.(target, draggedNode!);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
currentHoverTargets = newHoverSet;
|
|
263
|
+
}
|
|
64
264
|
}
|
|
65
265
|
|
|
66
266
|
function handleNodeDragStop(
|
|
@@ -75,7 +275,17 @@ export function createCanvasDocking<TNode extends CanvasNode = CanvasNode>(
|
|
|
75
275
|
|
|
76
276
|
if (draggedNode) {
|
|
77
277
|
const intersecting = getIntersectingNodes(draggedNode);
|
|
78
|
-
const
|
|
278
|
+
const dockTargets = intersecting.filter(isDockTarget);
|
|
279
|
+
const dockTarget =
|
|
280
|
+
dockTargets.length > 0
|
|
281
|
+
? resolvePrimaryTarget(
|
|
282
|
+
dockTargets,
|
|
283
|
+
draggedNode,
|
|
284
|
+
dockStrategy,
|
|
285
|
+
options.resolvePrimaryDockTarget,
|
|
286
|
+
params.event
|
|
287
|
+
)
|
|
288
|
+
: null;
|
|
79
289
|
|
|
80
290
|
if (dockTarget) {
|
|
81
291
|
options.onDockDrop?.(dockTarget, draggedNode);
|
package/src/canvas/index.ts
CHANGED
package/src/canvas/types.ts
CHANGED
|
@@ -72,6 +72,15 @@ export interface CanvasShortcutsOptions<TNode extends CanvasNode = CanvasNode> {
|
|
|
72
72
|
getSelectedNodes?: () => TNode[];
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Strategy used to resolve the primary dock target when multiple targets intersect a dragged node.
|
|
77
|
+
* - 'center-point': Chooses the target enclosing or closest to the center coordinate of the dragged node.
|
|
78
|
+
* - 'max-overlap': Chooses the target with the largest bounding box intersection area.
|
|
79
|
+
* - 'pointer': Chooses the target enclosing or closest to the mouse/touch cursor coordinates (falls back to 'center-point').
|
|
80
|
+
* - 'first': Chooses the first intersecting target (legacy behavior).
|
|
81
|
+
*/
|
|
82
|
+
export type DockStrategy = 'center-point' | 'max-overlap' | 'pointer' | 'first';
|
|
83
|
+
|
|
75
84
|
/**
|
|
76
85
|
* Docking and intersection callbacks.
|
|
77
86
|
*/
|