system-canvas-standalone 0.2.4 → 0.2.6
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/system-canvas.js +533 -316
- package/dist/system-canvas.js.map +1 -1
- package/dist/system-canvas.min.js +8 -8
- package/dist/system-canvas.min.js.map +1 -1
- package/package.json +3 -3
package/dist/system-canvas.js
CHANGED
|
@@ -12759,12 +12759,12 @@ var SystemCanvas = (() => {
|
|
|
12759
12759
|
render: () => render,
|
|
12760
12760
|
themes: () => themes
|
|
12761
12761
|
});
|
|
12762
|
-
var
|
|
12762
|
+
var import_react26 = __toESM(require_react(), 1);
|
|
12763
12763
|
var import_client = __toESM(require_client(), 1);
|
|
12764
12764
|
|
|
12765
12765
|
// ../react/dist/components/SystemCanvas.js
|
|
12766
12766
|
var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
|
|
12767
|
-
var
|
|
12767
|
+
var import_react25 = __toESM(require_react(), 1);
|
|
12768
12768
|
|
|
12769
12769
|
// ../core/dist/themes/dark.js
|
|
12770
12770
|
var darkTheme = {
|
|
@@ -14646,11 +14646,244 @@ var SystemCanvas = (() => {
|
|
|
14646
14646
|
};
|
|
14647
14647
|
}
|
|
14648
14648
|
|
|
14649
|
-
// ../react/dist/hooks/
|
|
14649
|
+
// ../react/dist/hooks/useKeyboardShortcuts.js
|
|
14650
14650
|
var import_react2 = __toESM(require_react(), 1);
|
|
14651
|
+
function useKeyboardShortcuts(options) {
|
|
14652
|
+
const { editable, editingId, editingEdgeId, selectedIds, selectedEdgeId, nodesRef, edgesRef, theme, currentCanvasRef, contextMenuState, wrappedOnNodeAdd, wrappedOnEdgeAdd, wrappedOnNodeUpdate, wrappedOnNodesUpdate, wrappedOnNodeDelete, wrappedOnNodesDelete, wrappedOnEdgeDelete, onNodesUpdate, beginBatch, endBatch, undo, redo, selectNode, selectMultiple, selectAll, clearSelection, setEditingId, setEditingEdgeId, setSelectedEdgeId, setContextMenuState, cancelDrag } = options;
|
|
14653
|
+
const handleKeyDown = (0, import_react2.useCallback)((e) => {
|
|
14654
|
+
if (!editable)
|
|
14655
|
+
return;
|
|
14656
|
+
if (e.key === "Escape") {
|
|
14657
|
+
if (contextMenuState) {
|
|
14658
|
+
setContextMenuState(null);
|
|
14659
|
+
return;
|
|
14660
|
+
}
|
|
14661
|
+
if (editingId || editingEdgeId) {
|
|
14662
|
+
setEditingId(null);
|
|
14663
|
+
setEditingEdgeId(null);
|
|
14664
|
+
return;
|
|
14665
|
+
}
|
|
14666
|
+
if (selectedIds.size > 0 || selectedEdgeId) {
|
|
14667
|
+
clearSelection();
|
|
14668
|
+
setSelectedEdgeId(null);
|
|
14669
|
+
cancelDrag();
|
|
14670
|
+
return;
|
|
14671
|
+
}
|
|
14672
|
+
return;
|
|
14673
|
+
}
|
|
14674
|
+
if (editingId || editingEdgeId)
|
|
14675
|
+
return;
|
|
14676
|
+
const meta = e.metaKey;
|
|
14677
|
+
const ctrl = e.ctrlKey;
|
|
14678
|
+
const shift = e.shiftKey;
|
|
14679
|
+
const key = e.key;
|
|
14680
|
+
if ((meta || ctrl) && !shift && key === "z") {
|
|
14681
|
+
e.preventDefault();
|
|
14682
|
+
undo();
|
|
14683
|
+
return;
|
|
14684
|
+
}
|
|
14685
|
+
if ((meta || ctrl) && shift && key === "z") {
|
|
14686
|
+
e.preventDefault();
|
|
14687
|
+
redo();
|
|
14688
|
+
return;
|
|
14689
|
+
}
|
|
14690
|
+
if ((meta || ctrl) && key === "a") {
|
|
14691
|
+
e.preventDefault();
|
|
14692
|
+
selectAll();
|
|
14693
|
+
return;
|
|
14694
|
+
}
|
|
14695
|
+
if (key === "Delete" || key === "Backspace") {
|
|
14696
|
+
if (selectedIds.size > 1) {
|
|
14697
|
+
e.preventDefault();
|
|
14698
|
+
wrappedOnNodesDelete(Array.from(selectedIds), currentCanvasRef);
|
|
14699
|
+
clearSelection();
|
|
14700
|
+
} else if (selectedIds.size === 1) {
|
|
14701
|
+
const id2 = Array.from(selectedIds)[0];
|
|
14702
|
+
e.preventDefault();
|
|
14703
|
+
wrappedOnNodeDelete(id2, currentCanvasRef);
|
|
14704
|
+
clearSelection();
|
|
14705
|
+
} else if (selectedEdgeId) {
|
|
14706
|
+
e.preventDefault();
|
|
14707
|
+
wrappedOnEdgeDelete(selectedEdgeId, currentCanvasRef);
|
|
14708
|
+
setSelectedEdgeId(null);
|
|
14709
|
+
}
|
|
14710
|
+
return;
|
|
14711
|
+
}
|
|
14712
|
+
if (key === "ArrowUp" || key === "ArrowDown" || key === "ArrowLeft" || key === "ArrowRight") {
|
|
14713
|
+
if (selectedIds.size === 0)
|
|
14714
|
+
return;
|
|
14715
|
+
const gridSize = theme.grid?.size ?? 40;
|
|
14716
|
+
const nudge = shift ? gridSize * 10 : gridSize;
|
|
14717
|
+
const dx = key === "ArrowLeft" ? -nudge : key === "ArrowRight" ? nudge : 0;
|
|
14718
|
+
const dy = key === "ArrowUp" ? -nudge : key === "ArrowDown" ? nudge : 0;
|
|
14719
|
+
const nodes = nodesRef.current ?? [];
|
|
14720
|
+
const updates = [];
|
|
14721
|
+
for (const id2 of selectedIds) {
|
|
14722
|
+
const node = nodes.find((n) => n.id === id2);
|
|
14723
|
+
if (node) {
|
|
14724
|
+
updates.push({ id: id2, patch: { x: node.x + dx, y: node.y + dy } });
|
|
14725
|
+
}
|
|
14726
|
+
}
|
|
14727
|
+
if (updates.length === 0)
|
|
14728
|
+
return;
|
|
14729
|
+
if (onNodesUpdate) {
|
|
14730
|
+
wrappedOnNodesUpdate(updates, currentCanvasRef);
|
|
14731
|
+
} else {
|
|
14732
|
+
for (const { id: id2, patch } of updates) {
|
|
14733
|
+
wrappedOnNodeUpdate(id2, patch, currentCanvasRef);
|
|
14734
|
+
}
|
|
14735
|
+
}
|
|
14736
|
+
e.preventDefault();
|
|
14737
|
+
return;
|
|
14738
|
+
}
|
|
14739
|
+
if (key === "Tab") {
|
|
14740
|
+
const nodes = nodesRef.current ?? [];
|
|
14741
|
+
if (nodes.length === 0)
|
|
14742
|
+
return;
|
|
14743
|
+
const sorted = [...nodes].sort((a, b) => a.y !== b.y ? a.y - b.y : a.x - b.x);
|
|
14744
|
+
if (selectedIds.size === 0) {
|
|
14745
|
+
selectNode(sorted[0].id);
|
|
14746
|
+
} else {
|
|
14747
|
+
const currentId = Array.from(selectedIds)[0];
|
|
14748
|
+
const index = sorted.findIndex((n) => n.id === currentId);
|
|
14749
|
+
const nextIndex = (index + (shift ? -1 : 1) + sorted.length) % sorted.length;
|
|
14750
|
+
selectNode(sorted[nextIndex].id);
|
|
14751
|
+
}
|
|
14752
|
+
e.preventDefault();
|
|
14753
|
+
return;
|
|
14754
|
+
}
|
|
14755
|
+
if ((meta || ctrl) && !shift && key === "d") {
|
|
14756
|
+
if (selectedIds.size === 0)
|
|
14757
|
+
return;
|
|
14758
|
+
e.preventDefault();
|
|
14759
|
+
const nodes = nodesRef.current ?? [];
|
|
14760
|
+
const edges = edgesRef.current ?? [];
|
|
14761
|
+
const gridSize = theme.grid?.size ?? 40;
|
|
14762
|
+
const oldToNew = /* @__PURE__ */ new Map();
|
|
14763
|
+
for (const id2 of selectedIds) {
|
|
14764
|
+
oldToNew.set(id2, generateNodeId());
|
|
14765
|
+
}
|
|
14766
|
+
const clonedNodes = [];
|
|
14767
|
+
for (const id2 of selectedIds) {
|
|
14768
|
+
const node = nodes.find((n) => n.id === id2);
|
|
14769
|
+
if (!node)
|
|
14770
|
+
continue;
|
|
14771
|
+
const newId2 = oldToNew.get(id2);
|
|
14772
|
+
clonedNodes.push({
|
|
14773
|
+
...structuredClone(node),
|
|
14774
|
+
id: newId2,
|
|
14775
|
+
x: node.x + gridSize,
|
|
14776
|
+
y: node.y + gridSize
|
|
14777
|
+
});
|
|
14778
|
+
}
|
|
14779
|
+
const clonedEdges = [];
|
|
14780
|
+
for (const edge of edges) {
|
|
14781
|
+
if (selectedIds.has(edge.fromNode) && selectedIds.has(edge.toNode)) {
|
|
14782
|
+
clonedEdges.push({
|
|
14783
|
+
...structuredClone(edge),
|
|
14784
|
+
id: generateEdgeId(),
|
|
14785
|
+
fromNode: oldToNew.get(edge.fromNode),
|
|
14786
|
+
toNode: oldToNew.get(edge.toNode)
|
|
14787
|
+
});
|
|
14788
|
+
}
|
|
14789
|
+
}
|
|
14790
|
+
beginBatch();
|
|
14791
|
+
for (const node of clonedNodes) {
|
|
14792
|
+
wrappedOnNodeAdd(node, currentCanvasRef);
|
|
14793
|
+
}
|
|
14794
|
+
for (const edge of clonedEdges) {
|
|
14795
|
+
wrappedOnEdgeAdd(edge, currentCanvasRef);
|
|
14796
|
+
}
|
|
14797
|
+
endBatch();
|
|
14798
|
+
selectMultiple([...oldToNew.values()]);
|
|
14799
|
+
return;
|
|
14800
|
+
}
|
|
14801
|
+
if ((meta || ctrl) && shift && key === "g") {
|
|
14802
|
+
if (selectedIds.size !== 1)
|
|
14803
|
+
return;
|
|
14804
|
+
const nodeId = Array.from(selectedIds)[0];
|
|
14805
|
+
const nodes = nodesRef.current ?? [];
|
|
14806
|
+
const node = nodes.find((n) => n.id === nodeId);
|
|
14807
|
+
if (!node || node.type !== "group")
|
|
14808
|
+
return;
|
|
14809
|
+
e.preventDefault();
|
|
14810
|
+
wrappedOnNodeDelete(node.id, currentCanvasRef);
|
|
14811
|
+
clearSelection();
|
|
14812
|
+
return;
|
|
14813
|
+
}
|
|
14814
|
+
if ((meta || ctrl) && !shift && key === "g") {
|
|
14815
|
+
if (selectedIds.size < 2)
|
|
14816
|
+
return;
|
|
14817
|
+
e.preventDefault();
|
|
14818
|
+
const nodes = nodesRef.current ?? [];
|
|
14819
|
+
const selectedNodes = nodes.filter((n) => selectedIds.has(n.id));
|
|
14820
|
+
if (selectedNodes.length < 2)
|
|
14821
|
+
return;
|
|
14822
|
+
const gridSize = theme.grid?.size ?? 40;
|
|
14823
|
+
let minX = Infinity;
|
|
14824
|
+
let minY = Infinity;
|
|
14825
|
+
let maxX = -Infinity;
|
|
14826
|
+
let maxY = -Infinity;
|
|
14827
|
+
for (const node of selectedNodes) {
|
|
14828
|
+
minX = Math.min(minX, node.x);
|
|
14829
|
+
minY = Math.min(minY, node.y);
|
|
14830
|
+
maxX = Math.max(maxX, node.x + node.width);
|
|
14831
|
+
maxY = Math.max(maxY, node.y + node.height);
|
|
14832
|
+
}
|
|
14833
|
+
const groupNode = {
|
|
14834
|
+
id: generateNodeId(),
|
|
14835
|
+
type: "group",
|
|
14836
|
+
x: minX - gridSize,
|
|
14837
|
+
y: minY - gridSize,
|
|
14838
|
+
width: maxX - minX + 2 * gridSize,
|
|
14839
|
+
height: maxY - minY + 2 * gridSize,
|
|
14840
|
+
label: ""
|
|
14841
|
+
};
|
|
14842
|
+
wrappedOnNodeAdd(groupNode, currentCanvasRef);
|
|
14843
|
+
selectNode(groupNode.id);
|
|
14844
|
+
return;
|
|
14845
|
+
}
|
|
14846
|
+
}, [
|
|
14847
|
+
editable,
|
|
14848
|
+
editingId,
|
|
14849
|
+
editingEdgeId,
|
|
14850
|
+
selectedIds,
|
|
14851
|
+
selectedEdgeId,
|
|
14852
|
+
nodesRef,
|
|
14853
|
+
edgesRef,
|
|
14854
|
+
theme,
|
|
14855
|
+
currentCanvasRef,
|
|
14856
|
+
contextMenuState,
|
|
14857
|
+
wrappedOnNodeAdd,
|
|
14858
|
+
wrappedOnEdgeAdd,
|
|
14859
|
+
wrappedOnNodeUpdate,
|
|
14860
|
+
wrappedOnNodesUpdate,
|
|
14861
|
+
wrappedOnNodeDelete,
|
|
14862
|
+
wrappedOnNodesDelete,
|
|
14863
|
+
wrappedOnEdgeDelete,
|
|
14864
|
+
onNodesUpdate,
|
|
14865
|
+
beginBatch,
|
|
14866
|
+
endBatch,
|
|
14867
|
+
undo,
|
|
14868
|
+
redo,
|
|
14869
|
+
selectNode,
|
|
14870
|
+
selectMultiple,
|
|
14871
|
+
selectAll,
|
|
14872
|
+
clearSelection,
|
|
14873
|
+
setEditingId,
|
|
14874
|
+
setEditingEdgeId,
|
|
14875
|
+
setSelectedEdgeId,
|
|
14876
|
+
setContextMenuState,
|
|
14877
|
+
cancelDrag
|
|
14878
|
+
]);
|
|
14879
|
+
return handleKeyDown;
|
|
14880
|
+
}
|
|
14881
|
+
|
|
14882
|
+
// ../react/dist/hooks/useCanvasInteraction.js
|
|
14883
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
14651
14884
|
function useCanvasInteraction(options) {
|
|
14652
14885
|
const { onNodeClick, onNodeDoubleClick, onEdgeClick, onEdgeDoubleClick, onContextMenu, onNavigableNodeClick, viewport, editable, onSelect, onToggleSelect, onBeginEdit, onSelectEdge, onBeginEditEdge } = options;
|
|
14653
|
-
const handleNodeClick = (0,
|
|
14886
|
+
const handleNodeClick = (0, import_react3.useCallback)((node, event) => {
|
|
14654
14887
|
event.stopPropagation();
|
|
14655
14888
|
if (editable) {
|
|
14656
14889
|
if (event.shiftKey && onToggleSelect) {
|
|
@@ -14662,19 +14895,19 @@ var SystemCanvas = (() => {
|
|
|
14662
14895
|
}
|
|
14663
14896
|
onNodeClick?.(node);
|
|
14664
14897
|
}, [editable, onNodeClick, onSelect, onToggleSelect, onSelectEdge]);
|
|
14665
|
-
const handleNodeDoubleClick = (0,
|
|
14898
|
+
const handleNodeDoubleClick = (0, import_react3.useCallback)((node, event) => {
|
|
14666
14899
|
event.stopPropagation();
|
|
14667
14900
|
onNodeDoubleClick?.(node);
|
|
14668
14901
|
if (editable) {
|
|
14669
14902
|
onBeginEdit?.(node);
|
|
14670
14903
|
}
|
|
14671
14904
|
}, [editable, onNodeDoubleClick, onBeginEdit]);
|
|
14672
|
-
const handleNodeNavigate = (0,
|
|
14905
|
+
const handleNodeNavigate = (0, import_react3.useCallback)((node, _event) => {
|
|
14673
14906
|
if (node.isNavigable) {
|
|
14674
14907
|
onNavigableNodeClick?.(node);
|
|
14675
14908
|
}
|
|
14676
14909
|
}, [onNavigableNodeClick]);
|
|
14677
|
-
const handleEdgeClick = (0,
|
|
14910
|
+
const handleEdgeClick = (0, import_react3.useCallback)((edge, event) => {
|
|
14678
14911
|
event.stopPropagation();
|
|
14679
14912
|
if (editable) {
|
|
14680
14913
|
onSelectEdge?.(edge.id);
|
|
@@ -14682,14 +14915,14 @@ var SystemCanvas = (() => {
|
|
|
14682
14915
|
}
|
|
14683
14916
|
onEdgeClick?.(edge);
|
|
14684
14917
|
}, [editable, onEdgeClick, onSelectEdge, onSelect]);
|
|
14685
|
-
const handleEdgeDoubleClick = (0,
|
|
14918
|
+
const handleEdgeDoubleClick = (0, import_react3.useCallback)((edge, event) => {
|
|
14686
14919
|
event.stopPropagation();
|
|
14687
14920
|
onEdgeDoubleClick?.(edge);
|
|
14688
14921
|
if (editable) {
|
|
14689
14922
|
onBeginEditEdge?.(edge);
|
|
14690
14923
|
}
|
|
14691
14924
|
}, [editable, onEdgeDoubleClick, onBeginEditEdge]);
|
|
14692
|
-
const createContextMenuHandler = (0,
|
|
14925
|
+
const createContextMenuHandler = (0, import_react3.useCallback)((type, target) => {
|
|
14693
14926
|
return (event) => {
|
|
14694
14927
|
event.preventDefault();
|
|
14695
14928
|
event.stopPropagation();
|
|
@@ -14708,16 +14941,16 @@ var SystemCanvas = (() => {
|
|
|
14708
14941
|
});
|
|
14709
14942
|
};
|
|
14710
14943
|
}, [onContextMenu, viewport]);
|
|
14711
|
-
const handleCanvasContextMenu = (0,
|
|
14944
|
+
const handleCanvasContextMenu = (0, import_react3.useCallback)((event) => {
|
|
14712
14945
|
createContextMenuHandler("canvas")(event);
|
|
14713
14946
|
}, [createContextMenuHandler]);
|
|
14714
|
-
const handleNodeContextMenu = (0,
|
|
14947
|
+
const handleNodeContextMenu = (0, import_react3.useCallback)((node, event) => {
|
|
14715
14948
|
createContextMenuHandler("node", node)(event);
|
|
14716
14949
|
}, [createContextMenuHandler]);
|
|
14717
|
-
const handleEdgeContextMenu = (0,
|
|
14950
|
+
const handleEdgeContextMenu = (0, import_react3.useCallback)((edge, event) => {
|
|
14718
14951
|
createContextMenuHandler("edge", edge)(event);
|
|
14719
14952
|
}, [createContextMenuHandler]);
|
|
14720
|
-
const handleCanvasClick = (0,
|
|
14953
|
+
const handleCanvasClick = (0, import_react3.useCallback)((_event) => {
|
|
14721
14954
|
if (editable) {
|
|
14722
14955
|
onSelect?.(null);
|
|
14723
14956
|
onSelectEdge?.(null);
|
|
@@ -14737,25 +14970,25 @@ var SystemCanvas = (() => {
|
|
|
14737
14970
|
}
|
|
14738
14971
|
|
|
14739
14972
|
// ../react/dist/hooks/useNodeDrag.js
|
|
14740
|
-
var
|
|
14973
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
14741
14974
|
var DRAG_THRESHOLD = 3;
|
|
14742
14975
|
function useNodeDrag(options) {
|
|
14743
14976
|
const { viewport, nodesRef, onCommit, svgRef, canDropNodeOn, onNodeDrop, selectedIdsRef } = options;
|
|
14744
|
-
const [dragOverrides, setDragOverrides] = (0,
|
|
14745
|
-
const [isDragging, setIsDragging] = (0,
|
|
14746
|
-
const [dropTargetId, setDropTargetId] = (0,
|
|
14747
|
-
const stateRef = (0,
|
|
14748
|
-
const movedRef = (0,
|
|
14749
|
-
const canDropNodeOnRef = (0,
|
|
14977
|
+
const [dragOverrides, setDragOverrides] = (0, import_react4.useState)(() => /* @__PURE__ */ new Map());
|
|
14978
|
+
const [isDragging, setIsDragging] = (0, import_react4.useState)(false);
|
|
14979
|
+
const [dropTargetId, setDropTargetId] = (0, import_react4.useState)(null);
|
|
14980
|
+
const stateRef = (0, import_react4.useRef)(null);
|
|
14981
|
+
const movedRef = (0, import_react4.useRef)(false);
|
|
14982
|
+
const canDropNodeOnRef = (0, import_react4.useRef)(canDropNodeOn);
|
|
14750
14983
|
canDropNodeOnRef.current = canDropNodeOn;
|
|
14751
|
-
const onNodeDropRef = (0,
|
|
14984
|
+
const onNodeDropRef = (0, import_react4.useRef)(onNodeDrop);
|
|
14752
14985
|
onNodeDropRef.current = onNodeDrop;
|
|
14753
|
-
const svgRefRef = (0,
|
|
14986
|
+
const svgRefRef = (0, import_react4.useRef)(svgRef);
|
|
14754
14987
|
svgRefRef.current = svgRef;
|
|
14755
|
-
const emptySetRef = (0,
|
|
14988
|
+
const emptySetRef = (0, import_react4.useRef)(/* @__PURE__ */ new Set());
|
|
14756
14989
|
const effectiveSelectedIdsRef = selectedIdsRef ?? emptySetRef;
|
|
14757
|
-
const dropTargetIdRef = (0,
|
|
14758
|
-
const computeDropTarget = (0,
|
|
14990
|
+
const dropTargetIdRef = (0, import_react4.useRef)(null);
|
|
14991
|
+
const computeDropTarget = (0, import_react4.useCallback)((clientX, clientY) => {
|
|
14759
14992
|
const cb = canDropNodeOnRef.current;
|
|
14760
14993
|
const st = stateRef.current;
|
|
14761
14994
|
const nodes = nodesRef.current;
|
|
@@ -14779,7 +15012,7 @@ var SystemCanvas = (() => {
|
|
|
14779
15012
|
}
|
|
14780
15013
|
return null;
|
|
14781
15014
|
}, [nodesRef, viewport]);
|
|
14782
|
-
const onPointerMove = (0,
|
|
15015
|
+
const onPointerMove = (0, import_react4.useCallback)((event) => {
|
|
14783
15016
|
const st = stateRef.current;
|
|
14784
15017
|
if (!st || event.pointerId !== st.pointerId)
|
|
14785
15018
|
return;
|
|
@@ -14806,7 +15039,7 @@ var SystemCanvas = (() => {
|
|
|
14806
15039
|
setDropTargetId(nextTarget);
|
|
14807
15040
|
}
|
|
14808
15041
|
}, [viewport, computeDropTarget]);
|
|
14809
|
-
const finishDrag = (0,
|
|
15042
|
+
const finishDrag = (0, import_react4.useCallback)((commit) => {
|
|
14810
15043
|
const st = stateRef.current;
|
|
14811
15044
|
if (!st)
|
|
14812
15045
|
return;
|
|
@@ -14850,25 +15083,25 @@ var SystemCanvas = (() => {
|
|
|
14850
15083
|
setDragOverrides(/* @__PURE__ */ new Map());
|
|
14851
15084
|
setDropTargetId(null);
|
|
14852
15085
|
}, [onPointerMove, onCommit, nodesRef]);
|
|
14853
|
-
const dragOverridesRef = (0,
|
|
15086
|
+
const dragOverridesRef = (0, import_react4.useRef)(dragOverrides);
|
|
14854
15087
|
dragOverridesRef.current = dragOverrides;
|
|
14855
|
-
const onPointerUpRef = (0,
|
|
14856
|
-
const onPointerCancelRef = (0,
|
|
14857
|
-
const onPointerUp = (0,
|
|
15088
|
+
const onPointerUpRef = (0, import_react4.useRef)(null);
|
|
15089
|
+
const onPointerCancelRef = (0, import_react4.useRef)(null);
|
|
15090
|
+
const onPointerUp = (0, import_react4.useCallback)((event) => {
|
|
14858
15091
|
const st = stateRef.current;
|
|
14859
15092
|
if (!st || event.pointerId !== st.pointerId)
|
|
14860
15093
|
return;
|
|
14861
15094
|
finishDrag(true);
|
|
14862
15095
|
}, [finishDrag]);
|
|
14863
15096
|
onPointerUpRef.current = onPointerUp;
|
|
14864
|
-
const onPointerCancel = (0,
|
|
15097
|
+
const onPointerCancel = (0, import_react4.useCallback)((event) => {
|
|
14865
15098
|
const st = stateRef.current;
|
|
14866
15099
|
if (!st || event.pointerId !== st.pointerId)
|
|
14867
15100
|
return;
|
|
14868
15101
|
finishDrag(false);
|
|
14869
15102
|
}, [finishDrag]);
|
|
14870
15103
|
onPointerCancelRef.current = onPointerCancel;
|
|
14871
|
-
const onPointerDown = (0,
|
|
15104
|
+
const onPointerDown = (0, import_react4.useCallback)((node, event) => {
|
|
14872
15105
|
if (event.button !== 0)
|
|
14873
15106
|
return;
|
|
14874
15107
|
if (stateRef.current)
|
|
@@ -14913,20 +15146,24 @@ var SystemCanvas = (() => {
|
|
|
14913
15146
|
window.addEventListener("pointerup", onPointerUp);
|
|
14914
15147
|
window.addEventListener("pointercancel", onPointerCancel);
|
|
14915
15148
|
}, [nodesRef, onPointerMove, onPointerUp, onPointerCancel]);
|
|
14916
|
-
|
|
15149
|
+
const cancelDrag = (0, import_react4.useCallback)(() => {
|
|
15150
|
+
if (stateRef.current)
|
|
15151
|
+
finishDrag(false);
|
|
15152
|
+
}, [finishDrag]);
|
|
15153
|
+
return { dragOverrides, dropTargetId, onPointerDown, isDragging, cancelDrag };
|
|
14917
15154
|
}
|
|
14918
15155
|
|
|
14919
15156
|
// ../react/dist/hooks/useNodeResize.js
|
|
14920
|
-
var
|
|
15157
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
14921
15158
|
var DEFAULT_MIN_SIZE = 40;
|
|
14922
15159
|
function useNodeResize(options) {
|
|
14923
15160
|
const { viewport, onCommit, minSize = DEFAULT_MIN_SIZE } = options;
|
|
14924
|
-
const [resizeOverrides, setResizeOverrides] = (0,
|
|
14925
|
-
const [isResizing, setIsResizing] = (0,
|
|
14926
|
-
const stateRef = (0,
|
|
14927
|
-
const overridesRef = (0,
|
|
15161
|
+
const [resizeOverrides, setResizeOverrides] = (0, import_react5.useState)(() => /* @__PURE__ */ new Map());
|
|
15162
|
+
const [isResizing, setIsResizing] = (0, import_react5.useState)(false);
|
|
15163
|
+
const stateRef = (0, import_react5.useRef)(null);
|
|
15164
|
+
const overridesRef = (0, import_react5.useRef)(resizeOverrides);
|
|
14928
15165
|
overridesRef.current = resizeOverrides;
|
|
14929
|
-
const onPointerMove = (0,
|
|
15166
|
+
const onPointerMove = (0, import_react5.useCallback)((event) => {
|
|
14930
15167
|
const st = stateRef.current;
|
|
14931
15168
|
if (!st || event.pointerId !== st.pointerId)
|
|
14932
15169
|
return;
|
|
@@ -14974,9 +15211,9 @@ var SystemCanvas = (() => {
|
|
|
14974
15211
|
if (!isResizing)
|
|
14975
15212
|
setIsResizing(true);
|
|
14976
15213
|
}, [viewport, isResizing]);
|
|
14977
|
-
const onPointerUpRef = (0,
|
|
14978
|
-
const onPointerCancelRef = (0,
|
|
14979
|
-
const finish = (0,
|
|
15214
|
+
const onPointerUpRef = (0, import_react5.useRef)(null);
|
|
15215
|
+
const onPointerCancelRef = (0, import_react5.useRef)(null);
|
|
15216
|
+
const finish = (0, import_react5.useCallback)((commit) => {
|
|
14980
15217
|
const st = stateRef.current;
|
|
14981
15218
|
if (!st)
|
|
14982
15219
|
return;
|
|
@@ -15003,21 +15240,21 @@ var SystemCanvas = (() => {
|
|
|
15003
15240
|
setIsResizing(false);
|
|
15004
15241
|
setResizeOverrides(/* @__PURE__ */ new Map());
|
|
15005
15242
|
}, [onPointerMove, onCommit]);
|
|
15006
|
-
const onPointerUp = (0,
|
|
15243
|
+
const onPointerUp = (0, import_react5.useCallback)((event) => {
|
|
15007
15244
|
const st = stateRef.current;
|
|
15008
15245
|
if (!st || event.pointerId !== st.pointerId)
|
|
15009
15246
|
return;
|
|
15010
15247
|
finish(true);
|
|
15011
15248
|
}, [finish]);
|
|
15012
15249
|
onPointerUpRef.current = onPointerUp;
|
|
15013
|
-
const onPointerCancel = (0,
|
|
15250
|
+
const onPointerCancel = (0, import_react5.useCallback)((event) => {
|
|
15014
15251
|
const st = stateRef.current;
|
|
15015
15252
|
if (!st || event.pointerId !== st.pointerId)
|
|
15016
15253
|
return;
|
|
15017
15254
|
finish(false);
|
|
15018
15255
|
}, [finish]);
|
|
15019
15256
|
onPointerCancelRef.current = onPointerCancel;
|
|
15020
|
-
const onHandlePointerDown = (0,
|
|
15257
|
+
const onHandlePointerDown = (0, import_react5.useCallback)((node, corner, event) => {
|
|
15021
15258
|
if (event.button !== 0)
|
|
15022
15259
|
return;
|
|
15023
15260
|
if (stateRef.current)
|
|
@@ -15049,7 +15286,7 @@ var SystemCanvas = (() => {
|
|
|
15049
15286
|
}
|
|
15050
15287
|
|
|
15051
15288
|
// ../react/dist/hooks/useEdgeCreate.js
|
|
15052
|
-
var
|
|
15289
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
15053
15290
|
var DROP_PADDING = 10;
|
|
15054
15291
|
function hitTestNodes(nodes, x, y) {
|
|
15055
15292
|
const pad = DROP_PADDING;
|
|
@@ -15067,18 +15304,18 @@ var SystemCanvas = (() => {
|
|
|
15067
15304
|
}
|
|
15068
15305
|
function useEdgeCreate(options) {
|
|
15069
15306
|
const { svgRef, viewport, nodesRef, onCreate } = options;
|
|
15070
|
-
const [pending, setPending] = (0,
|
|
15071
|
-
const pendingRef = (0,
|
|
15307
|
+
const [pending, setPending] = (0, import_react6.useState)(null);
|
|
15308
|
+
const pendingRef = (0, import_react6.useRef)(null);
|
|
15072
15309
|
pendingRef.current = pending;
|
|
15073
|
-
const pointerIdRef = (0,
|
|
15074
|
-
const toCanvasPoint = (0,
|
|
15310
|
+
const pointerIdRef = (0, import_react6.useRef)(null);
|
|
15311
|
+
const toCanvasPoint = (0, import_react6.useCallback)((clientX, clientY) => {
|
|
15075
15312
|
const rect = svgRef.current?.getBoundingClientRect();
|
|
15076
15313
|
const sx = clientX - (rect?.left ?? 0);
|
|
15077
15314
|
const sy = clientY - (rect?.top ?? 0);
|
|
15078
15315
|
const vp = viewport.current ?? { x: 0, y: 0, zoom: 1 };
|
|
15079
15316
|
return screenToCanvas(sx, sy, vp);
|
|
15080
15317
|
}, [svgRef, viewport]);
|
|
15081
|
-
const handleMove = (0,
|
|
15318
|
+
const handleMove = (0, import_react6.useCallback)((event) => {
|
|
15082
15319
|
if (pointerIdRef.current !== event.pointerId)
|
|
15083
15320
|
return;
|
|
15084
15321
|
const curr = pendingRef.current;
|
|
@@ -15090,11 +15327,11 @@ var SystemCanvas = (() => {
|
|
|
15090
15327
|
const hoveredTargetId = hit ? hit.id : null;
|
|
15091
15328
|
setPending({ ...curr, cursor, hoveredTargetId });
|
|
15092
15329
|
}, [nodesRef, toCanvasPoint]);
|
|
15093
|
-
const cleanup = (0,
|
|
15330
|
+
const cleanup = (0, import_react6.useCallback)(() => {
|
|
15094
15331
|
pointerIdRef.current = null;
|
|
15095
15332
|
setPending(null);
|
|
15096
15333
|
}, []);
|
|
15097
|
-
const handleUp = (0,
|
|
15334
|
+
const handleUp = (0, import_react6.useCallback)((event) => {
|
|
15098
15335
|
if (pointerIdRef.current !== event.pointerId)
|
|
15099
15336
|
return;
|
|
15100
15337
|
const curr = pendingRef.current;
|
|
@@ -15116,12 +15353,12 @@ var SystemCanvas = (() => {
|
|
|
15116
15353
|
}
|
|
15117
15354
|
cleanup();
|
|
15118
15355
|
}, [cleanup, nodesRef, onCreate, toCanvasPoint]);
|
|
15119
|
-
const handleCancel = (0,
|
|
15356
|
+
const handleCancel = (0, import_react6.useCallback)((event) => {
|
|
15120
15357
|
if (pointerIdRef.current !== event.pointerId)
|
|
15121
15358
|
return;
|
|
15122
15359
|
cleanup();
|
|
15123
15360
|
}, [cleanup]);
|
|
15124
|
-
(0,
|
|
15361
|
+
(0, import_react6.useEffect)(() => {
|
|
15125
15362
|
if (!pending)
|
|
15126
15363
|
return;
|
|
15127
15364
|
window.addEventListener("pointermove", handleMove);
|
|
@@ -15133,7 +15370,7 @@ var SystemCanvas = (() => {
|
|
|
15133
15370
|
window.removeEventListener("pointercancel", handleCancel);
|
|
15134
15371
|
};
|
|
15135
15372
|
}, [pending, handleMove, handleUp, handleCancel]);
|
|
15136
|
-
const onHandlePointerDown = (0,
|
|
15373
|
+
const onHandlePointerDown = (0, import_react6.useCallback)((node, side, event) => {
|
|
15137
15374
|
if (event.button !== 0)
|
|
15138
15375
|
return;
|
|
15139
15376
|
if (pointerIdRef.current !== null)
|
|
@@ -15151,21 +15388,21 @@ var SystemCanvas = (() => {
|
|
|
15151
15388
|
}
|
|
15152
15389
|
|
|
15153
15390
|
// ../react/dist/hooks/useMultiSelect.js
|
|
15154
|
-
var
|
|
15391
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
15155
15392
|
function useMultiSelect(options) {
|
|
15156
15393
|
const { svgRef, viewport, nodesRef, containerRef, enabled } = options;
|
|
15157
|
-
const [selectedIds, setSelectedIds] = (0,
|
|
15158
|
-
const [marqueeRect, setMarqueeRect] = (0,
|
|
15159
|
-
const marqueeActiveRef = (0,
|
|
15160
|
-
const isDrawingRef = (0,
|
|
15161
|
-
const startScreenRef = (0,
|
|
15162
|
-
const pointerIdRef = (0,
|
|
15163
|
-
const selectedIdsRef = (0,
|
|
15394
|
+
const [selectedIds, setSelectedIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
|
|
15395
|
+
const [marqueeRect, setMarqueeRect] = (0, import_react7.useState)(null);
|
|
15396
|
+
const marqueeActiveRef = (0, import_react7.useRef)(false);
|
|
15397
|
+
const isDrawingRef = (0, import_react7.useRef)(false);
|
|
15398
|
+
const startScreenRef = (0, import_react7.useRef)(null);
|
|
15399
|
+
const pointerIdRef = (0, import_react7.useRef)(null);
|
|
15400
|
+
const selectedIdsRef = (0, import_react7.useRef)(selectedIds);
|
|
15164
15401
|
selectedIdsRef.current = selectedIds;
|
|
15165
|
-
const selectNode = (0,
|
|
15402
|
+
const selectNode = (0, import_react7.useCallback)((id2) => {
|
|
15166
15403
|
setSelectedIds(/* @__PURE__ */ new Set([id2]));
|
|
15167
15404
|
}, []);
|
|
15168
|
-
const toggleNode = (0,
|
|
15405
|
+
const toggleNode = (0, import_react7.useCallback)((id2) => {
|
|
15169
15406
|
setSelectedIds((prev) => {
|
|
15170
15407
|
const next = new Set(prev);
|
|
15171
15408
|
if (next.has(id2)) {
|
|
@@ -15176,16 +15413,19 @@ var SystemCanvas = (() => {
|
|
|
15176
15413
|
return next;
|
|
15177
15414
|
});
|
|
15178
15415
|
}, []);
|
|
15179
|
-
const selectAll = (0,
|
|
15416
|
+
const selectAll = (0, import_react7.useCallback)(() => {
|
|
15180
15417
|
const nodes = nodesRef.current;
|
|
15181
15418
|
if (!nodes)
|
|
15182
15419
|
return;
|
|
15183
15420
|
setSelectedIds(new Set(nodes.map((n) => n.id)));
|
|
15184
15421
|
}, [nodesRef]);
|
|
15185
|
-
const clearSelection = (0,
|
|
15422
|
+
const clearSelection = (0, import_react7.useCallback)(() => {
|
|
15186
15423
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
15187
15424
|
}, []);
|
|
15188
|
-
(0,
|
|
15425
|
+
const selectMultiple = (0, import_react7.useCallback)((ids) => {
|
|
15426
|
+
setSelectedIds(new Set(ids));
|
|
15427
|
+
}, []);
|
|
15428
|
+
(0, import_react7.useEffect)(() => {
|
|
15189
15429
|
if (!enabled)
|
|
15190
15430
|
return;
|
|
15191
15431
|
const container = containerRef.current;
|
|
@@ -15219,7 +15459,7 @@ var SystemCanvas = (() => {
|
|
|
15219
15459
|
container.removeEventListener("keyup", onKeyUp);
|
|
15220
15460
|
};
|
|
15221
15461
|
}, [enabled, containerRef]);
|
|
15222
|
-
(0,
|
|
15462
|
+
(0, import_react7.useEffect)(() => {
|
|
15223
15463
|
if (!enabled)
|
|
15224
15464
|
return;
|
|
15225
15465
|
const container = containerRef.current;
|
|
@@ -15240,7 +15480,7 @@ var SystemCanvas = (() => {
|
|
|
15240
15480
|
container.removeEventListener("keydown", onKeyDown);
|
|
15241
15481
|
};
|
|
15242
15482
|
}, [enabled, containerRef, selectAll]);
|
|
15243
|
-
(0,
|
|
15483
|
+
(0, import_react7.useEffect)(() => {
|
|
15244
15484
|
if (!enabled)
|
|
15245
15485
|
return;
|
|
15246
15486
|
const container = containerRef.current;
|
|
@@ -15340,29 +15580,30 @@ var SystemCanvas = (() => {
|
|
|
15340
15580
|
toggleNode,
|
|
15341
15581
|
selectAll,
|
|
15342
15582
|
clearSelection,
|
|
15583
|
+
selectMultiple,
|
|
15343
15584
|
marqueeRect,
|
|
15344
15585
|
marqueeActiveRef
|
|
15345
15586
|
};
|
|
15346
15587
|
}
|
|
15347
15588
|
|
|
15348
15589
|
// ../react/dist/hooks/useMultiSelectClipboard.js
|
|
15349
|
-
var
|
|
15590
|
+
var import_react8 = __toESM(require_react(), 1);
|
|
15350
15591
|
var clipboardSnapshot = null;
|
|
15351
15592
|
function useMultiSelectClipboard(options) {
|
|
15352
15593
|
const { selectedIdsRef, nodesRef, edgesRef, viewport, onNodeAdd, onEdgeAdd, canvasRef, getCursorScreenPos, onBeginBatch, onEndBatch } = options;
|
|
15353
|
-
const getCursorScreenPosRef = (0,
|
|
15594
|
+
const getCursorScreenPosRef = (0, import_react8.useRef)(getCursorScreenPos);
|
|
15354
15595
|
getCursorScreenPosRef.current = getCursorScreenPos;
|
|
15355
|
-
const onNodeAddRef = (0,
|
|
15596
|
+
const onNodeAddRef = (0, import_react8.useRef)(onNodeAdd);
|
|
15356
15597
|
onNodeAddRef.current = onNodeAdd;
|
|
15357
|
-
const onEdgeAddRef = (0,
|
|
15598
|
+
const onEdgeAddRef = (0, import_react8.useRef)(onEdgeAdd);
|
|
15358
15599
|
onEdgeAddRef.current = onEdgeAdd;
|
|
15359
|
-
const canvasRefRef = (0,
|
|
15600
|
+
const canvasRefRef = (0, import_react8.useRef)(canvasRef);
|
|
15360
15601
|
canvasRefRef.current = canvasRef;
|
|
15361
|
-
const onBeginBatchRef = (0,
|
|
15602
|
+
const onBeginBatchRef = (0, import_react8.useRef)(onBeginBatch);
|
|
15362
15603
|
onBeginBatchRef.current = onBeginBatch;
|
|
15363
|
-
const onEndBatchRef = (0,
|
|
15604
|
+
const onEndBatchRef = (0, import_react8.useRef)(onEndBatch);
|
|
15364
15605
|
onEndBatchRef.current = onEndBatch;
|
|
15365
|
-
(0,
|
|
15606
|
+
(0, import_react8.useEffect)(() => {
|
|
15366
15607
|
const handler = (e) => {
|
|
15367
15608
|
const active = document.activeElement;
|
|
15368
15609
|
if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable) {
|
|
@@ -15454,7 +15695,7 @@ var SystemCanvas = (() => {
|
|
|
15454
15695
|
}
|
|
15455
15696
|
|
|
15456
15697
|
// ../react/dist/hooks/useCommandHistory.js
|
|
15457
|
-
var
|
|
15698
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
15458
15699
|
function getCanvasRef(cmd) {
|
|
15459
15700
|
if (cmd.type === "batch") {
|
|
15460
15701
|
return cmd.commands.length > 0 ? getCanvasRef(cmd.commands[0]) : void 0;
|
|
@@ -15463,28 +15704,28 @@ var SystemCanvas = (() => {
|
|
|
15463
15704
|
}
|
|
15464
15705
|
function useCommandHistory(options) {
|
|
15465
15706
|
const { nodesRef, edgesRef, onNodeAdd, onNodeUpdate, onNodesUpdate, onNodeDelete, onNodesDelete, onEdgeAdd, onEdgeUpdate, onEdgeDelete, maxDepth = 50, enabled = true, onUndo, onRedo } = options;
|
|
15466
|
-
const onNodeAddRef = (0,
|
|
15707
|
+
const onNodeAddRef = (0, import_react9.useRef)(onNodeAdd);
|
|
15467
15708
|
onNodeAddRef.current = onNodeAdd;
|
|
15468
|
-
const onNodeUpdateRef = (0,
|
|
15709
|
+
const onNodeUpdateRef = (0, import_react9.useRef)(onNodeUpdate);
|
|
15469
15710
|
onNodeUpdateRef.current = onNodeUpdate;
|
|
15470
|
-
const onNodesUpdateRef = (0,
|
|
15711
|
+
const onNodesUpdateRef = (0, import_react9.useRef)(onNodesUpdate);
|
|
15471
15712
|
onNodesUpdateRef.current = onNodesUpdate;
|
|
15472
|
-
const onNodeDeleteRef = (0,
|
|
15713
|
+
const onNodeDeleteRef = (0, import_react9.useRef)(onNodeDelete);
|
|
15473
15714
|
onNodeDeleteRef.current = onNodeDelete;
|
|
15474
|
-
const onNodesDeleteRef = (0,
|
|
15715
|
+
const onNodesDeleteRef = (0, import_react9.useRef)(onNodesDelete);
|
|
15475
15716
|
onNodesDeleteRef.current = onNodesDelete;
|
|
15476
|
-
const onEdgeAddRef = (0,
|
|
15717
|
+
const onEdgeAddRef = (0, import_react9.useRef)(onEdgeAdd);
|
|
15477
15718
|
onEdgeAddRef.current = onEdgeAdd;
|
|
15478
|
-
const onEdgeUpdateRef = (0,
|
|
15719
|
+
const onEdgeUpdateRef = (0, import_react9.useRef)(onEdgeUpdate);
|
|
15479
15720
|
onEdgeUpdateRef.current = onEdgeUpdate;
|
|
15480
|
-
const onEdgeDeleteRef = (0,
|
|
15721
|
+
const onEdgeDeleteRef = (0, import_react9.useRef)(onEdgeDelete);
|
|
15481
15722
|
onEdgeDeleteRef.current = onEdgeDelete;
|
|
15482
|
-
const undoStack = (0,
|
|
15483
|
-
const redoStack = (0,
|
|
15484
|
-
const isUndoingRef = (0,
|
|
15485
|
-
const pendingBatchRef = (0,
|
|
15486
|
-
const [canUndo, setCanUndo] = (0,
|
|
15487
|
-
const [canRedo, setCanRedo] = (0,
|
|
15723
|
+
const undoStack = (0, import_react9.useRef)([]);
|
|
15724
|
+
const redoStack = (0, import_react9.useRef)([]);
|
|
15725
|
+
const isUndoingRef = (0, import_react9.useRef)(false);
|
|
15726
|
+
const pendingBatchRef = (0, import_react9.useRef)(null);
|
|
15727
|
+
const [canUndo, setCanUndo] = (0, import_react9.useState)(false);
|
|
15728
|
+
const [canRedo, setCanRedo] = (0, import_react9.useState)(false);
|
|
15488
15729
|
function syncBooleans() {
|
|
15489
15730
|
setCanUndo(undoStack.current.length > 0);
|
|
15490
15731
|
setCanRedo(redoStack.current.length > 0);
|
|
@@ -15568,7 +15809,7 @@ var SystemCanvas = (() => {
|
|
|
15568
15809
|
break;
|
|
15569
15810
|
}
|
|
15570
15811
|
}
|
|
15571
|
-
const undo = (0,
|
|
15812
|
+
const undo = (0, import_react9.useCallback)(() => {
|
|
15572
15813
|
if (!enabled)
|
|
15573
15814
|
return;
|
|
15574
15815
|
const cmd = undoStack.current.pop();
|
|
@@ -15581,7 +15822,7 @@ var SystemCanvas = (() => {
|
|
|
15581
15822
|
syncBooleans();
|
|
15582
15823
|
onUndo?.(getCanvasRef(cmd));
|
|
15583
15824
|
}, [enabled, onUndo]);
|
|
15584
|
-
const redo = (0,
|
|
15825
|
+
const redo = (0, import_react9.useCallback)(() => {
|
|
15585
15826
|
if (!enabled)
|
|
15586
15827
|
return;
|
|
15587
15828
|
const cmd = redoStack.current.pop();
|
|
@@ -15596,12 +15837,12 @@ var SystemCanvas = (() => {
|
|
|
15596
15837
|
syncBooleans();
|
|
15597
15838
|
onRedo?.(getCanvasRef(cmd));
|
|
15598
15839
|
}, [enabled, onRedo, maxDepth]);
|
|
15599
|
-
const beginBatch = (0,
|
|
15840
|
+
const beginBatch = (0, import_react9.useCallback)(() => {
|
|
15600
15841
|
if (!enabled)
|
|
15601
15842
|
return;
|
|
15602
15843
|
pendingBatchRef.current = [];
|
|
15603
15844
|
}, [enabled]);
|
|
15604
|
-
const endBatch = (0,
|
|
15845
|
+
const endBatch = (0, import_react9.useCallback)(() => {
|
|
15605
15846
|
if (!enabled)
|
|
15606
15847
|
return;
|
|
15607
15848
|
const cmds = pendingBatchRef.current;
|
|
@@ -15618,7 +15859,7 @@ var SystemCanvas = (() => {
|
|
|
15618
15859
|
redoStack.current = [];
|
|
15619
15860
|
syncBooleans();
|
|
15620
15861
|
}, [enabled, maxDepth]);
|
|
15621
|
-
const wrappedOnNodeAdd = (0,
|
|
15862
|
+
const wrappedOnNodeAdd = (0, import_react9.useCallback)(
|
|
15622
15863
|
(node, canvasRef) => {
|
|
15623
15864
|
if (enabled && !isUndoingRef.current) {
|
|
15624
15865
|
pushCommand({ type: "node:add", node, canvasRef });
|
|
@@ -15628,7 +15869,7 @@ var SystemCanvas = (() => {
|
|
|
15628
15869
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15629
15870
|
[enabled]
|
|
15630
15871
|
);
|
|
15631
|
-
const wrappedOnNodeUpdate = (0,
|
|
15872
|
+
const wrappedOnNodeUpdate = (0, import_react9.useCallback)(
|
|
15632
15873
|
(id2, patch, canvasRef) => {
|
|
15633
15874
|
if (enabled && !isUndoingRef.current) {
|
|
15634
15875
|
const node = nodesRef.current?.find((n) => n.id === id2);
|
|
@@ -15642,7 +15883,7 @@ var SystemCanvas = (() => {
|
|
|
15642
15883
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15643
15884
|
[enabled, nodesRef]
|
|
15644
15885
|
);
|
|
15645
|
-
const wrappedOnNodesUpdate = (0,
|
|
15886
|
+
const wrappedOnNodesUpdate = (0, import_react9.useCallback)(
|
|
15646
15887
|
(updates, canvasRef) => {
|
|
15647
15888
|
if (enabled && !isUndoingRef.current) {
|
|
15648
15889
|
const enriched = [];
|
|
@@ -15662,7 +15903,7 @@ var SystemCanvas = (() => {
|
|
|
15662
15903
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15663
15904
|
[enabled, nodesRef]
|
|
15664
15905
|
);
|
|
15665
|
-
const wrappedOnNodeDelete = (0,
|
|
15906
|
+
const wrappedOnNodeDelete = (0, import_react9.useCallback)(
|
|
15666
15907
|
(nodeId, canvasRef) => {
|
|
15667
15908
|
if (enabled && !isUndoingRef.current) {
|
|
15668
15909
|
const node = nodesRef.current?.find((n) => n.id === nodeId);
|
|
@@ -15675,7 +15916,7 @@ var SystemCanvas = (() => {
|
|
|
15675
15916
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15676
15917
|
[enabled, nodesRef]
|
|
15677
15918
|
);
|
|
15678
|
-
const wrappedOnNodesDelete = (0,
|
|
15919
|
+
const wrappedOnNodesDelete = (0, import_react9.useCallback)(
|
|
15679
15920
|
(nodeIds, canvasRef) => {
|
|
15680
15921
|
if (enabled && !isUndoingRef.current) {
|
|
15681
15922
|
const nodes = nodesRef.current?.filter((n) => nodeIds.includes(n.id)) ?? [];
|
|
@@ -15688,7 +15929,7 @@ var SystemCanvas = (() => {
|
|
|
15688
15929
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15689
15930
|
[enabled, nodesRef]
|
|
15690
15931
|
);
|
|
15691
|
-
const wrappedOnEdgeAdd = (0,
|
|
15932
|
+
const wrappedOnEdgeAdd = (0, import_react9.useCallback)(
|
|
15692
15933
|
(edge, canvasRef) => {
|
|
15693
15934
|
if (enabled && !isUndoingRef.current) {
|
|
15694
15935
|
pushCommand({ type: "edge:add", edge, canvasRef });
|
|
@@ -15698,7 +15939,7 @@ var SystemCanvas = (() => {
|
|
|
15698
15939
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15699
15940
|
[enabled]
|
|
15700
15941
|
);
|
|
15701
|
-
const wrappedOnEdgeUpdate = (0,
|
|
15942
|
+
const wrappedOnEdgeUpdate = (0, import_react9.useCallback)(
|
|
15702
15943
|
(id2, patch, canvasRef) => {
|
|
15703
15944
|
if (enabled && !isUndoingRef.current) {
|
|
15704
15945
|
const edge = edgesRef.current?.find((e) => e.id === id2);
|
|
@@ -15712,7 +15953,7 @@ var SystemCanvas = (() => {
|
|
|
15712
15953
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15713
15954
|
[enabled, edgesRef]
|
|
15714
15955
|
);
|
|
15715
|
-
const wrappedOnEdgeDelete = (0,
|
|
15956
|
+
const wrappedOnEdgeDelete = (0, import_react9.useCallback)(
|
|
15716
15957
|
(edgeId, canvasRef) => {
|
|
15717
15958
|
if (enabled && !isUndoingRef.current) {
|
|
15718
15959
|
const edge = edgesRef.current?.find((e) => e.id === edgeId);
|
|
@@ -15744,7 +15985,7 @@ var SystemCanvas = (() => {
|
|
|
15744
15985
|
}
|
|
15745
15986
|
|
|
15746
15987
|
// ../react/dist/hooks/useZoomNavigation.js
|
|
15747
|
-
var
|
|
15988
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
15748
15989
|
function expandRect(rect, factor) {
|
|
15749
15990
|
if (factor === 1)
|
|
15750
15991
|
return rect;
|
|
@@ -15782,16 +16023,16 @@ var SystemCanvas = (() => {
|
|
|
15782
16023
|
}
|
|
15783
16024
|
function useZoomNavigation(options) {
|
|
15784
16025
|
const { enabled, config, nodes, currentCanvas, parentFrame, canvases, onResolveCanvas, onSeedCanvas, theme, getViewportSize, getCursorScreenPos, onEnter, onExit } = options;
|
|
15785
|
-
const committingRef = (0,
|
|
15786
|
-
(0,
|
|
16026
|
+
const committingRef = (0, import_react10.useRef)(false);
|
|
16027
|
+
(0, import_react10.useEffect)(() => {
|
|
15787
16028
|
committingRef.current = false;
|
|
15788
16029
|
}, [currentCanvas]);
|
|
15789
|
-
const exitArmedRef = (0,
|
|
15790
|
-
(0,
|
|
16030
|
+
const exitArmedRef = (0, import_react10.useRef)(false);
|
|
16031
|
+
(0, import_react10.useEffect)(() => {
|
|
15791
16032
|
exitArmedRef.current = false;
|
|
15792
16033
|
}, [currentCanvas, parentFrame]);
|
|
15793
|
-
const prefetchRef = (0,
|
|
15794
|
-
const prefetch = (0,
|
|
16034
|
+
const prefetchRef = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
16035
|
+
const prefetch = (0, import_react10.useCallback)((ref) => {
|
|
15795
16036
|
if (!onResolveCanvas)
|
|
15796
16037
|
return;
|
|
15797
16038
|
if (canvases?.[ref])
|
|
@@ -15809,7 +16050,7 @@ var SystemCanvas = (() => {
|
|
|
15809
16050
|
state.loading = false;
|
|
15810
16051
|
});
|
|
15811
16052
|
}, [canvases, onResolveCanvas, onSeedCanvas]);
|
|
15812
|
-
const handleViewportChange = (0,
|
|
16053
|
+
const handleViewportChange = (0, import_react10.useCallback)((vp) => {
|
|
15813
16054
|
if (!enabled)
|
|
15814
16055
|
return;
|
|
15815
16056
|
if (committingRef.current)
|
|
@@ -15948,7 +16189,7 @@ var SystemCanvas = (() => {
|
|
|
15948
16189
|
onEnter,
|
|
15949
16190
|
onExit
|
|
15950
16191
|
]);
|
|
15951
|
-
const clearCommitting = (0,
|
|
16192
|
+
const clearCommitting = (0, import_react10.useCallback)(() => {
|
|
15952
16193
|
committingRef.current = false;
|
|
15953
16194
|
}, []);
|
|
15954
16195
|
return { handleViewportChange, clearCommitting };
|
|
@@ -15956,10 +16197,10 @@ var SystemCanvas = (() => {
|
|
|
15956
16197
|
|
|
15957
16198
|
// ../react/dist/components/Viewport.js
|
|
15958
16199
|
var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
|
|
15959
|
-
var
|
|
16200
|
+
var import_react19 = __toESM(require_react(), 1);
|
|
15960
16201
|
|
|
15961
16202
|
// ../react/dist/hooks/useViewport.js
|
|
15962
|
-
var
|
|
16203
|
+
var import_react11 = __toESM(require_react(), 1);
|
|
15963
16204
|
|
|
15964
16205
|
// ../../node_modules/d3-dispatch/src/dispatch.js
|
|
15965
16206
|
var noop = { value: () => {
|
|
@@ -18702,13 +18943,13 @@ var SystemCanvas = (() => {
|
|
|
18702
18943
|
// ../react/dist/hooks/useViewport.js
|
|
18703
18944
|
function useViewport(options) {
|
|
18704
18945
|
const { minZoom, maxZoom, defaultViewport, onViewportChange, marqueeActiveRef } = options;
|
|
18705
|
-
const svgRef = (0,
|
|
18706
|
-
const groupRef = (0,
|
|
18707
|
-
const viewport = (0,
|
|
18708
|
-
const zoomBehaviorRef = (0,
|
|
18709
|
-
const onViewportChangeRef = (0,
|
|
18946
|
+
const svgRef = (0, import_react11.useRef)(null);
|
|
18947
|
+
const groupRef = (0, import_react11.useRef)(null);
|
|
18948
|
+
const viewport = (0, import_react11.useRef)(defaultViewport ?? { x: 0, y: 0, zoom: 1 });
|
|
18949
|
+
const zoomBehaviorRef = (0, import_react11.useRef)(null);
|
|
18950
|
+
const onViewportChangeRef = (0, import_react11.useRef)(onViewportChange);
|
|
18710
18951
|
onViewportChangeRef.current = onViewportChange;
|
|
18711
|
-
(0,
|
|
18952
|
+
(0, import_react11.useEffect)(() => {
|
|
18712
18953
|
const svg = svgRef.current;
|
|
18713
18954
|
const group = groupRef.current;
|
|
18714
18955
|
if (!svg || !group)
|
|
@@ -18748,7 +18989,7 @@ var SystemCanvas = (() => {
|
|
|
18748
18989
|
selection2.on(".zoom", null);
|
|
18749
18990
|
};
|
|
18750
18991
|
}, [minZoom, maxZoom]);
|
|
18751
|
-
const fitToContent = (0,
|
|
18992
|
+
const fitToContent = (0, import_react11.useCallback)((nodes, animate = true) => {
|
|
18752
18993
|
const svg = svgRef.current;
|
|
18753
18994
|
if (!svg || !zoomBehaviorRef.current || nodes.length === 0)
|
|
18754
18995
|
return;
|
|
@@ -18761,13 +19002,13 @@ var SystemCanvas = (() => {
|
|
|
18761
19002
|
select_default2(svg).call(zoomBehaviorRef.current.transform, t);
|
|
18762
19003
|
}
|
|
18763
19004
|
}, []);
|
|
18764
|
-
const resetZoom = (0,
|
|
19005
|
+
const resetZoom = (0, import_react11.useCallback)(() => {
|
|
18765
19006
|
const svg = svgRef.current;
|
|
18766
19007
|
if (!svg || !zoomBehaviorRef.current)
|
|
18767
19008
|
return;
|
|
18768
19009
|
select_default2(svg).transition().duration(400).call(zoomBehaviorRef.current.transform, identity2);
|
|
18769
19010
|
}, []);
|
|
18770
|
-
const setTransform = (0,
|
|
19011
|
+
const setTransform = (0, import_react11.useCallback)((transform2, options2) => {
|
|
18771
19012
|
const svg = svgRef.current;
|
|
18772
19013
|
if (!svg || !zoomBehaviorRef.current)
|
|
18773
19014
|
return;
|
|
@@ -18779,7 +19020,7 @@ var SystemCanvas = (() => {
|
|
|
18779
19020
|
sel.call(zoomBehaviorRef.current.transform, t);
|
|
18780
19021
|
}
|
|
18781
19022
|
}, []);
|
|
18782
|
-
const zoomToNode = (0,
|
|
19023
|
+
const zoomToNode = (0, import_react11.useCallback)((node, onComplete, options2) => {
|
|
18783
19024
|
const svg = svgRef.current;
|
|
18784
19025
|
if (!svg || !zoomBehaviorRef.current) {
|
|
18785
19026
|
onComplete?.();
|
|
@@ -18973,9 +19214,9 @@ var SystemCanvas = (() => {
|
|
|
18973
19214
|
|
|
18974
19215
|
// ../react/dist/components/RefIndicator.js
|
|
18975
19216
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
18976
|
-
var
|
|
19217
|
+
var import_react12 = __toESM(require_react(), 1);
|
|
18977
19218
|
function RefIndicator({ node, theme, nodeX, nodeY, nodeWidth, nodeHeight, strokeColor, strokeWidth, corner = "bottom-right", size: sizeProp, onNavigate }) {
|
|
18978
|
-
const [hover, setHover] = (0,
|
|
19219
|
+
const [hover, setHover] = (0, import_react12.useState)(false);
|
|
18979
19220
|
const iconKind = theme.node.refIndicator.icon;
|
|
18980
19221
|
if (iconKind === "none")
|
|
18981
19222
|
return null;
|
|
@@ -19046,7 +19287,7 @@ var SystemCanvas = (() => {
|
|
|
19046
19287
|
|
|
19047
19288
|
// ../react/dist/components/CategorySlotsLayer.js
|
|
19048
19289
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
19049
|
-
var
|
|
19290
|
+
var import_react14 = __toESM(require_react(), 1);
|
|
19050
19291
|
|
|
19051
19292
|
// ../react/dist/primitives/NodeColorFill.js
|
|
19052
19293
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -19166,9 +19407,9 @@ var SystemCanvas = (() => {
|
|
|
19166
19407
|
|
|
19167
19408
|
// ../react/dist/primitives/NodeText.js
|
|
19168
19409
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
19169
|
-
var
|
|
19410
|
+
var import_react13 = __toESM(require_react(), 1);
|
|
19170
19411
|
function NodeText({ region, value, theme, color: color2, fill, align = "start", fontWeight = 500, uppercase = false, useLabelFont = false, fontFamily, fontSize: fontSizeProp, wrap = false, maxLines, lineHeight: lineHeightProp, verticalAlign = "top" }) {
|
|
19171
|
-
const reactId = (0,
|
|
19412
|
+
const reactId = (0, import_react13.useId)();
|
|
19172
19413
|
const safeId = reactId.replace(/:/g, "");
|
|
19173
19414
|
if (!value)
|
|
19174
19415
|
return null;
|
|
@@ -19242,8 +19483,8 @@ var SystemCanvas = (() => {
|
|
|
19242
19483
|
// ../react/dist/components/CategorySlotsLayer.js
|
|
19243
19484
|
function CategorySlotsLayer({ node, theme, canvases, slots: slotsProp }) {
|
|
19244
19485
|
const slots = slotsProp ?? getCategorySlots(node, theme);
|
|
19245
|
-
const regions = (0,
|
|
19246
|
-
const reactId = (0,
|
|
19486
|
+
const regions = (0, import_react14.useMemo)(() => computeCategorySlotRegions(node, theme, slots), [node, theme, slots]);
|
|
19487
|
+
const reactId = (0, import_react14.useId)();
|
|
19247
19488
|
const clipId = `sc-edge-clip-${reactId.replace(/:/g, "")}`;
|
|
19248
19489
|
if (!slots)
|
|
19249
19490
|
return null;
|
|
@@ -19476,7 +19717,7 @@ var SystemCanvas = (() => {
|
|
|
19476
19717
|
|
|
19477
19718
|
// ../react/dist/components/ResizeHandles.js
|
|
19478
19719
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
19479
|
-
var
|
|
19720
|
+
var import_react15 = __toESM(require_react(), 1);
|
|
19480
19721
|
var HANDLE_SIZE = 7;
|
|
19481
19722
|
var CORNERS = [
|
|
19482
19723
|
{ corner: "nw", cursor: "nwse-resize", anchor: "nw" },
|
|
@@ -19487,7 +19728,7 @@ var SystemCanvas = (() => {
|
|
|
19487
19728
|
var cornerInset = (cornerRadius) => Math.min(cornerRadius * 0.25, 3);
|
|
19488
19729
|
function ResizeHandles({ node, theme, onHandlePointerDown }) {
|
|
19489
19730
|
const { x, y, width, height } = node;
|
|
19490
|
-
const [hoveredCorner, setHoveredCorner] = (0,
|
|
19731
|
+
const [hoveredCorner, setHoveredCorner] = (0, import_react15.useState)(null);
|
|
19491
19732
|
const handleColor = node.resolvedStroke ?? theme.node.labelColor;
|
|
19492
19733
|
const i = cornerInset(node.resolvedCornerRadius);
|
|
19493
19734
|
const anchorPos = (anchor) => {
|
|
@@ -19598,7 +19839,7 @@ var SystemCanvas = (() => {
|
|
|
19598
19839
|
|
|
19599
19840
|
// ../react/dist/components/NodeEditor.js
|
|
19600
19841
|
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
|
|
19601
|
-
var
|
|
19842
|
+
var import_react16 = __toESM(require_react(), 1);
|
|
19602
19843
|
function NodeEditor({ node, theme, onCommit, onCancel }) {
|
|
19603
19844
|
const editableFields = useCategoryFields(node, theme);
|
|
19604
19845
|
if (editableFields) {
|
|
@@ -19617,11 +19858,11 @@ var SystemCanvas = (() => {
|
|
|
19617
19858
|
}
|
|
19618
19859
|
function SingleFieldEditor({ node, theme, onCommit, onCancel }) {
|
|
19619
19860
|
const initial = getInitialValue(node);
|
|
19620
|
-
const [value, setValue] = (0,
|
|
19621
|
-
const textareaRef = (0,
|
|
19622
|
-
const inputRef = (0,
|
|
19623
|
-
const committedRef = (0,
|
|
19624
|
-
(0,
|
|
19861
|
+
const [value, setValue] = (0, import_react16.useState)(initial);
|
|
19862
|
+
const textareaRef = (0, import_react16.useRef)(null);
|
|
19863
|
+
const inputRef = (0, import_react16.useRef)(null);
|
|
19864
|
+
const committedRef = (0, import_react16.useRef)(false);
|
|
19865
|
+
(0, import_react16.useEffect)(() => {
|
|
19625
19866
|
const el = textareaRef.current ?? inputRef.current;
|
|
19626
19867
|
if (el) {
|
|
19627
19868
|
el.focus();
|
|
@@ -19717,10 +19958,10 @@ var SystemCanvas = (() => {
|
|
|
19717
19958
|
}
|
|
19718
19959
|
}
|
|
19719
19960
|
function FormEditor({ node, theme, fields, onCommit, onCancel }) {
|
|
19720
|
-
const initial = (0,
|
|
19721
|
-
const [values, setValues] = (0,
|
|
19722
|
-
const committedRef = (0,
|
|
19723
|
-
const panelRef = (0,
|
|
19961
|
+
const initial = (0, import_react16.useMemo)(() => readInitialValues(node, fields), [node, fields]);
|
|
19962
|
+
const [values, setValues] = (0, import_react16.useState)(initial);
|
|
19963
|
+
const committedRef = (0, import_react16.useRef)(false);
|
|
19964
|
+
const panelRef = (0, import_react16.useRef)(null);
|
|
19724
19965
|
const width = Math.max(node.width, 240);
|
|
19725
19966
|
const height = Math.max(node.height, 36 + fields.length * 44);
|
|
19726
19967
|
const commit = () => {
|
|
@@ -19749,7 +19990,7 @@ var SystemCanvas = (() => {
|
|
|
19749
19990
|
const stopPointer = (e) => {
|
|
19750
19991
|
e.stopPropagation();
|
|
19751
19992
|
};
|
|
19752
|
-
(0,
|
|
19993
|
+
(0, import_react16.useEffect)(() => {
|
|
19753
19994
|
const el = panelRef.current;
|
|
19754
19995
|
if (!el)
|
|
19755
19996
|
return;
|
|
@@ -19879,13 +20120,13 @@ var SystemCanvas = (() => {
|
|
|
19879
20120
|
|
|
19880
20121
|
// ../react/dist/components/EdgeLabelEditor.js
|
|
19881
20122
|
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
|
|
19882
|
-
var
|
|
20123
|
+
var import_react17 = __toESM(require_react(), 1);
|
|
19883
20124
|
var EDITOR_WIDTH = 110;
|
|
19884
20125
|
function EdgeLabelEditor({ initialLabel, midpoint, theme, onCommit, onCancel }) {
|
|
19885
|
-
const [value, setValue] = (0,
|
|
19886
|
-
const inputRef = (0,
|
|
19887
|
-
const committedRef = (0,
|
|
19888
|
-
(0,
|
|
20126
|
+
const [value, setValue] = (0, import_react17.useState)(initialLabel);
|
|
20127
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
20128
|
+
const committedRef = (0, import_react17.useRef)(false);
|
|
20129
|
+
(0, import_react17.useEffect)(() => {
|
|
19889
20130
|
const el = inputRef.current;
|
|
19890
20131
|
if (el) {
|
|
19891
20132
|
el.focus();
|
|
@@ -19940,7 +20181,7 @@ var SystemCanvas = (() => {
|
|
|
19940
20181
|
|
|
19941
20182
|
// ../react/dist/components/ConnectionHandles.js
|
|
19942
20183
|
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
|
|
19943
|
-
var
|
|
20184
|
+
var import_react18 = __toESM(require_react(), 1);
|
|
19944
20185
|
var SIDES = ["top", "right", "bottom", "left"];
|
|
19945
20186
|
var HANDLE_RADIUS = 4;
|
|
19946
20187
|
var HANDLE_HIT_RADIUS = 10;
|
|
@@ -19949,9 +20190,9 @@ var SystemCanvas = (() => {
|
|
|
19949
20190
|
var HOVER_SCALE = 1.42;
|
|
19950
20191
|
var HOVER_TRANSITION_MS = 120;
|
|
19951
20192
|
function ConnectionHandles({ node, theme, onHandlePointerDown, immediate, activeSide }) {
|
|
19952
|
-
const [visible, setVisible] = (0,
|
|
19953
|
-
const [hoveredSide, setHoveredSide] = (0,
|
|
19954
|
-
(0,
|
|
20193
|
+
const [visible, setVisible] = (0, import_react18.useState)(!!immediate);
|
|
20194
|
+
const [hoveredSide, setHoveredSide] = (0, import_react18.useState)(null);
|
|
20195
|
+
(0, import_react18.useEffect)(() => {
|
|
19955
20196
|
if (immediate) {
|
|
19956
20197
|
setVisible(true);
|
|
19957
20198
|
return;
|
|
@@ -20038,7 +20279,7 @@ var SystemCanvas = (() => {
|
|
|
20038
20279
|
// ../react/dist/components/Viewport.js
|
|
20039
20280
|
var HOVER_PADDING = 10;
|
|
20040
20281
|
var EDGE_PROXIMITY = 16;
|
|
20041
|
-
var Viewport = (0,
|
|
20282
|
+
var Viewport = (0, import_react19.forwardRef)(function Viewport2({ nodes, edges, nodeMap, theme, edgeStyle, columns, rows, canvases, minZoom, maxZoom, defaultViewport, onViewportChange, onNodeClick, onNodeDoubleClick, onNodeNavigate, onEdgeClick, onEdgeDoubleClick, onCanvasClick, onCanvasContextMenu, onNodeContextMenu, onEdgeContextMenu, onNodePointerDown, selectedIds, editingId, selectedEdgeId, editingEdgeId, dragOverrides, dropTargetId, marqueeRect, marqueeActiveRef, resizeOverrides, onResizeHandlePointerDown, onEditorCommit, onEditorCancel, onEdgeEditorCommit, onEdgeEditorCancel, pendingEdge, onConnectionHandlePointerDown, edgeCreateEnabled, autoFit = "canvas-change", canvasRef, handoffTransform, onHandoffApplied, handoffFadeMs = 0 }, ref) {
|
|
20042
20283
|
const { svgRef, groupRef, viewport, fitToContent, zoomToNode, setTransform } = useViewport({
|
|
20043
20284
|
minZoom,
|
|
20044
20285
|
maxZoom,
|
|
@@ -20046,10 +20287,10 @@ var SystemCanvas = (() => {
|
|
|
20046
20287
|
onViewportChange,
|
|
20047
20288
|
marqueeActiveRef
|
|
20048
20289
|
});
|
|
20049
|
-
const navigatingRef = (0,
|
|
20050
|
-
const fadeRafRef = (0,
|
|
20051
|
-
const fadeTimeoutRef = (0,
|
|
20052
|
-
const triggerFade = (0,
|
|
20290
|
+
const navigatingRef = (0, import_react19.useRef)(false);
|
|
20291
|
+
const fadeRafRef = (0, import_react19.useRef)(null);
|
|
20292
|
+
const fadeTimeoutRef = (0, import_react19.useRef)(null);
|
|
20293
|
+
const triggerFade = (0, import_react19.useCallback)((durationMs) => {
|
|
20053
20294
|
if (durationMs <= 0)
|
|
20054
20295
|
return;
|
|
20055
20296
|
const g = groupRef.current;
|
|
@@ -20072,7 +20313,7 @@ var SystemCanvas = (() => {
|
|
|
20072
20313
|
}, durationMs + 16);
|
|
20073
20314
|
});
|
|
20074
20315
|
}, []);
|
|
20075
|
-
(0,
|
|
20316
|
+
(0, import_react19.useEffect)(() => {
|
|
20076
20317
|
return () => {
|
|
20077
20318
|
if (fadeRafRef.current !== null)
|
|
20078
20319
|
cancelAnimationFrame(fadeRafRef.current);
|
|
@@ -20080,10 +20321,10 @@ var SystemCanvas = (() => {
|
|
|
20080
20321
|
clearTimeout(fadeTimeoutRef.current);
|
|
20081
20322
|
};
|
|
20082
20323
|
}, []);
|
|
20083
|
-
const [hoveredNodeId, setHoveredNodeId] = (0,
|
|
20084
|
-
const [hoveredSide, setHoveredSide] = (0,
|
|
20085
|
-
const cursorPosRef = (0,
|
|
20086
|
-
(0,
|
|
20324
|
+
const [hoveredNodeId, setHoveredNodeId] = (0, import_react19.useState)(null);
|
|
20325
|
+
const [hoveredSide, setHoveredSide] = (0, import_react19.useState)(null);
|
|
20326
|
+
const cursorPosRef = (0, import_react19.useRef)(null);
|
|
20327
|
+
(0, import_react19.useImperativeHandle)(ref, () => ({
|
|
20087
20328
|
zoomToNode: (node, onComplete, options) => {
|
|
20088
20329
|
navigatingRef.current = true;
|
|
20089
20330
|
zoomToNode(node, onComplete, options);
|
|
@@ -20094,7 +20335,7 @@ var SystemCanvas = (() => {
|
|
|
20094
20335
|
getViewport: () => viewport.current ?? { x: 0, y: 0, zoom: 1 },
|
|
20095
20336
|
getCursorScreenPos: () => cursorPosRef.current
|
|
20096
20337
|
}));
|
|
20097
|
-
const renderNodes = (0,
|
|
20338
|
+
const renderNodes = (0, import_react19.useMemo)(() => {
|
|
20098
20339
|
const hasDrag = dragOverrides && dragOverrides.size > 0;
|
|
20099
20340
|
const hasResize = resizeOverrides && resizeOverrides.size > 0;
|
|
20100
20341
|
if (!hasDrag && !hasResize)
|
|
@@ -20107,7 +20348,7 @@ var SystemCanvas = (() => {
|
|
|
20107
20348
|
return d ? { ...n, x: d.x, y: d.y } : n;
|
|
20108
20349
|
});
|
|
20109
20350
|
}, [nodes, dragOverrides, resizeOverrides]);
|
|
20110
|
-
const renderNodeMap = (0,
|
|
20351
|
+
const renderNodeMap = (0, import_react19.useMemo)(() => {
|
|
20111
20352
|
const hasDrag = dragOverrides && dragOverrides.size > 0;
|
|
20112
20353
|
const hasResize = resizeOverrides && resizeOverrides.size > 0;
|
|
20113
20354
|
if (!hasDrag && !hasResize)
|
|
@@ -20118,11 +20359,11 @@ var SystemCanvas = (() => {
|
|
|
20118
20359
|
}
|
|
20119
20360
|
return m;
|
|
20120
20361
|
}, [renderNodes, nodeMap, dragOverrides, resizeOverrides]);
|
|
20121
|
-
const latestNodesRef = (0,
|
|
20122
|
-
(0,
|
|
20362
|
+
const latestNodesRef = (0, import_react19.useRef)(nodes);
|
|
20363
|
+
(0, import_react19.useEffect)(() => {
|
|
20123
20364
|
latestNodesRef.current = nodes;
|
|
20124
20365
|
}, [nodes]);
|
|
20125
|
-
const fitNow = (0,
|
|
20366
|
+
const fitNow = (0, import_react19.useCallback)(() => {
|
|
20126
20367
|
const current = latestNodesRef.current;
|
|
20127
20368
|
if (current.length === 0)
|
|
20128
20369
|
return;
|
|
@@ -20132,7 +20373,7 @@ var SystemCanvas = (() => {
|
|
|
20132
20373
|
fitToContent(current, animate);
|
|
20133
20374
|
});
|
|
20134
20375
|
}, [fitToContent]);
|
|
20135
|
-
(0,
|
|
20376
|
+
(0, import_react19.useEffect)(() => {
|
|
20136
20377
|
if (defaultViewport)
|
|
20137
20378
|
return;
|
|
20138
20379
|
if (autoFit !== "always")
|
|
@@ -20141,8 +20382,8 @@ var SystemCanvas = (() => {
|
|
|
20141
20382
|
return;
|
|
20142
20383
|
fitNow();
|
|
20143
20384
|
}, [nodes, autoFit, defaultViewport, fitNow]);
|
|
20144
|
-
const fittedForRef = (0,
|
|
20145
|
-
(0,
|
|
20385
|
+
const fittedForRef = (0, import_react19.useRef)(null);
|
|
20386
|
+
(0, import_react19.useEffect)(() => {
|
|
20146
20387
|
if (defaultViewport)
|
|
20147
20388
|
return;
|
|
20148
20389
|
if (autoFit !== "canvas-change" && autoFit !== "initial")
|
|
@@ -20174,7 +20415,7 @@ var SystemCanvas = (() => {
|
|
|
20174
20415
|
triggerFade
|
|
20175
20416
|
]);
|
|
20176
20417
|
const editingNode = editingId ? renderNodes.find((n) => n.id === editingId) ?? null : null;
|
|
20177
|
-
const handleSvgPointerMove = (0,
|
|
20418
|
+
const handleSvgPointerMove = (0, import_react19.useCallback)((event) => {
|
|
20178
20419
|
const svg = svgRef.current;
|
|
20179
20420
|
if (!svg)
|
|
20180
20421
|
return;
|
|
@@ -20226,7 +20467,7 @@ var SystemCanvas = (() => {
|
|
|
20226
20467
|
setHoveredSide((prev) => prev === null ? prev : null);
|
|
20227
20468
|
}
|
|
20228
20469
|
}, [edgeCreateEnabled, renderNodes, svgRef, viewport]);
|
|
20229
|
-
const handleSvgPointerLeave = (0,
|
|
20470
|
+
const handleSvgPointerLeave = (0, import_react19.useCallback)(() => {
|
|
20230
20471
|
setHoveredNodeId(null);
|
|
20231
20472
|
setHoveredSide(null);
|
|
20232
20473
|
cursorPosRef.current = null;
|
|
@@ -20265,7 +20506,7 @@ var SystemCanvas = (() => {
|
|
|
20265
20506
|
|
|
20266
20507
|
// ../react/dist/components/Breadcrumbs.js
|
|
20267
20508
|
var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
|
|
20268
|
-
var
|
|
20509
|
+
var import_react20 = __toESM(require_react(), 1);
|
|
20269
20510
|
function Breadcrumbs({ breadcrumbs, theme, onNavigate }) {
|
|
20270
20511
|
if (breadcrumbs.length <= 1)
|
|
20271
20512
|
return null;
|
|
@@ -20286,7 +20527,7 @@ var SystemCanvas = (() => {
|
|
|
20286
20527
|
backdropFilter: "blur(8px)"
|
|
20287
20528
|
}, children: breadcrumbs.map((crumb, index) => {
|
|
20288
20529
|
const isLast = index === breadcrumbs.length - 1;
|
|
20289
|
-
return (0, import_jsx_runtime23.jsxs)(
|
|
20530
|
+
return (0, import_jsx_runtime23.jsxs)(import_react20.default.Fragment, { children: [index > 0 && (0, import_jsx_runtime23.jsx)("span", { style: {
|
|
20290
20531
|
color: theme.separatorColor,
|
|
20291
20532
|
margin: "0 2px"
|
|
20292
20533
|
}, children: "/" }), (0, import_jsx_runtime23.jsx)("span", { onClick: isLast ? void 0 : () => onNavigate(index), style: {
|
|
@@ -20310,11 +20551,11 @@ var SystemCanvas = (() => {
|
|
|
20310
20551
|
|
|
20311
20552
|
// ../react/dist/components/AddNodeButton.js
|
|
20312
20553
|
var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
|
|
20313
|
-
var
|
|
20554
|
+
var import_react21 = __toESM(require_react(), 1);
|
|
20314
20555
|
function AddNodeButton({ options, addNode: addNode2, theme }) {
|
|
20315
|
-
const [open, setOpen] = (0,
|
|
20316
|
-
const rootRef = (0,
|
|
20317
|
-
(0,
|
|
20556
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
20557
|
+
const rootRef = (0, import_react21.useRef)(null);
|
|
20558
|
+
(0, import_react21.useEffect)(() => {
|
|
20318
20559
|
if (!open)
|
|
20319
20560
|
return;
|
|
20320
20561
|
function onDocClick(e) {
|
|
@@ -20403,7 +20644,7 @@ var SystemCanvas = (() => {
|
|
|
20403
20644
|
} });
|
|
20404
20645
|
}
|
|
20405
20646
|
function MenuRow({ theme, option, onClick }) {
|
|
20406
|
-
const [hover, setHover] = (0,
|
|
20647
|
+
const [hover, setHover] = (0, import_react21.useState)(false);
|
|
20407
20648
|
const swatchSize = 18;
|
|
20408
20649
|
return (0, import_jsx_runtime24.jsxs)("div", { role: "button", onClick, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), style: {
|
|
20409
20650
|
display: "flex",
|
|
@@ -20439,12 +20680,12 @@ var SystemCanvas = (() => {
|
|
|
20439
20680
|
|
|
20440
20681
|
// ../react/dist/components/LaneHeaders.js
|
|
20441
20682
|
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
|
|
20442
|
-
var
|
|
20683
|
+
var import_react22 = __toESM(require_react(), 1);
|
|
20443
20684
|
function LaneHeaders({ columns, rows, theme, getViewport, width, height, pinned = true }) {
|
|
20444
20685
|
const hasColumns = columns && columns.length > 0;
|
|
20445
20686
|
const hasRows = rows && rows.length > 0;
|
|
20446
|
-
const [viewport, setViewport] = (0,
|
|
20447
|
-
(0,
|
|
20687
|
+
const [viewport, setViewport] = (0, import_react22.useState)(() => getViewport());
|
|
20688
|
+
(0, import_react22.useEffect)(() => {
|
|
20448
20689
|
if (!hasColumns && !hasRows)
|
|
20449
20690
|
return;
|
|
20450
20691
|
let raf = 0;
|
|
@@ -20518,7 +20759,7 @@ var SystemCanvas = (() => {
|
|
|
20518
20759
|
|
|
20519
20760
|
// ../react/dist/components/NodeToolbar.js
|
|
20520
20761
|
var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
|
|
20521
|
-
var
|
|
20762
|
+
var import_react23 = __toESM(require_react(), 1);
|
|
20522
20763
|
var NODE_GAP = 10;
|
|
20523
20764
|
var FLIP_MARGIN = 8;
|
|
20524
20765
|
var PADDING = 6;
|
|
@@ -20527,8 +20768,8 @@ var SystemCanvas = (() => {
|
|
|
20527
20768
|
var BUTTON_SIZE = 28;
|
|
20528
20769
|
var DELETE_SIZE = 14;
|
|
20529
20770
|
function NodeToolbar({ node, theme, onPatch, onDelete, getViewport, containerWidth, containerHeight, render: render2, selectedNodes, onMultiPatch }) {
|
|
20530
|
-
const [viewport, setViewport] = (0,
|
|
20531
|
-
(0,
|
|
20771
|
+
const [viewport, setViewport] = (0, import_react23.useState)(() => getViewport());
|
|
20772
|
+
(0, import_react23.useEffect)(() => {
|
|
20532
20773
|
let raf = 0;
|
|
20533
20774
|
let lastX = -Infinity;
|
|
20534
20775
|
let lastY = -Infinity;
|
|
@@ -20548,7 +20789,7 @@ var SystemCanvas = (() => {
|
|
|
20548
20789
|
}, [getViewport]);
|
|
20549
20790
|
const isMulti = selectedNodes != null && selectedNodes.length > 1;
|
|
20550
20791
|
const align = theme.toolbarAlign ?? "center";
|
|
20551
|
-
const { anchorTopY, anchorBottomY, anchorX } = (0,
|
|
20792
|
+
const { anchorTopY, anchorBottomY, anchorX } = (0, import_react23.useMemo)(() => {
|
|
20552
20793
|
if (isMulti && selectedNodes) {
|
|
20553
20794
|
const minX = Math.min(...selectedNodes.map((n) => n.x));
|
|
20554
20795
|
const maxX = Math.max(...selectedNodes.map((n) => n.x + n.width));
|
|
@@ -20565,9 +20806,9 @@ var SystemCanvas = (() => {
|
|
|
20565
20806
|
}, [isMulti, selectedNodes, align, node]);
|
|
20566
20807
|
const topAnchor = canvasToScreen(anchorX, anchorTopY, viewport);
|
|
20567
20808
|
const bottomAnchor = canvasToScreen(anchorX, anchorBottomY, viewport);
|
|
20568
|
-
const toolbarRef = (0,
|
|
20569
|
-
const [size, setSize] = (0,
|
|
20570
|
-
(0,
|
|
20809
|
+
const toolbarRef = (0, import_react23.useRef)(null);
|
|
20810
|
+
const [size, setSize] = (0, import_react23.useState)({ width: 0, height: 0 });
|
|
20811
|
+
(0, import_react23.useEffect)(() => {
|
|
20571
20812
|
const el = toolbarRef.current;
|
|
20572
20813
|
if (!el)
|
|
20573
20814
|
return;
|
|
@@ -20627,7 +20868,7 @@ var SystemCanvas = (() => {
|
|
|
20627
20868
|
}
|
|
20628
20869
|
function MultiToolbarContent({ selectedNodes, theme, onMultiPatch, onDelete }) {
|
|
20629
20870
|
const representativeNode = selectedNodes[0];
|
|
20630
|
-
const groups = (0,
|
|
20871
|
+
const groups = (0, import_react23.useMemo)(() => getNodeActionsForNode(representativeNode, theme), [representativeNode, theme]);
|
|
20631
20872
|
const showDelete = theme.showToolbarDelete === true;
|
|
20632
20873
|
const swatchGroups = groups.filter((g) => g.kind === "swatches" || g.kind == null);
|
|
20633
20874
|
const otherGroups = groups.filter((g) => g.kind !== "swatches" && g.kind != null && g.kind !== "menu");
|
|
@@ -20641,7 +20882,7 @@ var SystemCanvas = (() => {
|
|
|
20641
20882
|
const actions = filterActionsForNode(group, representativeNode);
|
|
20642
20883
|
if (actions.length === 0)
|
|
20643
20884
|
return null;
|
|
20644
|
-
return (0, import_jsx_runtime26.jsxs)(
|
|
20885
|
+
return (0, import_jsx_runtime26.jsxs)(import_react23.default.Fragment, { children: [i > 0 && (0, import_jsx_runtime26.jsx)(Divider2, { theme }), (0, import_jsx_runtime26.jsx)("div", { style: { display: "flex", alignItems: "center", gap: BUTTON_GAP }, children: actions.map((action) => {
|
|
20645
20886
|
const active = action.isActive?.(representativeNode) ?? false;
|
|
20646
20887
|
const handleClick = () => {
|
|
20647
20888
|
const patch = resolveActionPatch(action, representativeNode);
|
|
@@ -20653,7 +20894,7 @@ var SystemCanvas = (() => {
|
|
|
20653
20894
|
const actions = filterActionsForNode(group, representativeNode);
|
|
20654
20895
|
if (actions.length === 0)
|
|
20655
20896
|
return null;
|
|
20656
|
-
return (0, import_jsx_runtime26.jsxs)(
|
|
20897
|
+
return (0, import_jsx_runtime26.jsxs)(import_react23.default.Fragment, { children: [(0, import_jsx_runtime26.jsx)(Divider2, { theme }), (0, import_jsx_runtime26.jsx)("div", { style: { display: "flex", alignItems: "center", gap: BUTTON_GAP }, children: actions.map((action) => {
|
|
20657
20898
|
const active = action.isActive?.(representativeNode) ?? false;
|
|
20658
20899
|
const handleClick = () => {
|
|
20659
20900
|
const patch = resolveActionPatch(action, representativeNode);
|
|
@@ -20664,9 +20905,9 @@ var SystemCanvas = (() => {
|
|
|
20664
20905
|
}), showDelete && (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [(0, import_jsx_runtime26.jsx)(Divider2, { theme }), (0, import_jsx_runtime26.jsx)(DeleteButton, { theme, onDelete })] })] });
|
|
20665
20906
|
}
|
|
20666
20907
|
function DefaultToolbarContent({ node, theme, onPatch, onDelete }) {
|
|
20667
|
-
const groups = (0,
|
|
20908
|
+
const groups = (0, import_react23.useMemo)(() => getNodeActionsForNode(node, theme), [node, theme]);
|
|
20668
20909
|
const showDelete = theme.showToolbarDelete === true;
|
|
20669
|
-
return (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [groups.map((group, i) => (0, import_jsx_runtime26.jsxs)(
|
|
20910
|
+
return (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [groups.map((group, i) => (0, import_jsx_runtime26.jsxs)(import_react23.default.Fragment, { children: [i > 0 && (0, import_jsx_runtime26.jsx)(Divider2, { theme }), (0, import_jsx_runtime26.jsx)(ActionGroupView, { group, node, theme, onPatch })] }, group.id)), showDelete && (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [(0, import_jsx_runtime26.jsx)(Divider2, { theme }), (0, import_jsx_runtime26.jsx)(DeleteButton, { theme, onDelete })] })] });
|
|
20670
20911
|
}
|
|
20671
20912
|
function Divider2({ theme }) {
|
|
20672
20913
|
return (0, import_jsx_runtime26.jsx)("div", { style: {
|
|
@@ -20733,9 +20974,9 @@ var SystemCanvas = (() => {
|
|
|
20733
20974
|
} }) : (0, import_jsx_runtime26.jsx)("span", { style: { fontSize: 10 }, children: action.label.slice(0, 2) }) });
|
|
20734
20975
|
}
|
|
20735
20976
|
function MenuGroup({ group, actions, node, theme, onPatch }) {
|
|
20736
|
-
const [open, setOpen] = (0,
|
|
20737
|
-
const wrapRef = (0,
|
|
20738
|
-
(0,
|
|
20977
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
20978
|
+
const wrapRef = (0, import_react23.useRef)(null);
|
|
20979
|
+
(0, import_react23.useEffect)(() => {
|
|
20739
20980
|
if (!open)
|
|
20740
20981
|
return;
|
|
20741
20982
|
const onDown = (e) => {
|
|
@@ -20822,18 +21063,18 @@ var SystemCanvas = (() => {
|
|
|
20822
21063
|
|
|
20823
21064
|
// ../react/dist/components/NodeContextMenuOverlay.js
|
|
20824
21065
|
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
|
|
20825
|
-
var
|
|
21066
|
+
var import_react24 = __toESM(require_react(), 1);
|
|
20826
21067
|
var ESTIMATED_MENU_WIDTH = 200;
|
|
20827
21068
|
var MIN_MENU_WIDTH = 160;
|
|
20828
21069
|
var VIEWPORT_MARGIN = 8;
|
|
20829
21070
|
function NodeContextMenuOverlay({ state, config, theme, onClose }) {
|
|
20830
|
-
const rootRef = (0,
|
|
20831
|
-
const [hoveredId, setHoveredId] = (0,
|
|
20832
|
-
(0,
|
|
21071
|
+
const rootRef = (0, import_react24.useRef)(null);
|
|
21072
|
+
const [hoveredId, setHoveredId] = (0, import_react24.useState)(null);
|
|
21073
|
+
(0, import_react24.useEffect)(() => {
|
|
20833
21074
|
if (state)
|
|
20834
21075
|
setHoveredId(null);
|
|
20835
21076
|
}, [state]);
|
|
20836
|
-
(0,
|
|
21077
|
+
(0, import_react24.useEffect)(() => {
|
|
20837
21078
|
if (!state)
|
|
20838
21079
|
return;
|
|
20839
21080
|
function onDown(e) {
|
|
@@ -20941,8 +21182,8 @@ var SystemCanvas = (() => {
|
|
|
20941
21182
|
// ../react/dist/components/SystemCanvas.js
|
|
20942
21183
|
var CASCADE_WINDOW_MS = 1500;
|
|
20943
21184
|
var CASCADE_OFFSET = 20;
|
|
20944
|
-
var SystemCanvas = (0,
|
|
20945
|
-
const zoomNavConfig = (0,
|
|
21185
|
+
var SystemCanvas = (0, import_react25.forwardRef)(function SystemCanvas2({ canvas, onResolveCanvas, canvases, rootLabel = "Home", onNavigate, onBreadcrumbClick, onBreadcrumbsChange, onNodeClick, onNodeDoubleClick, onEdgeClick, onEdgeDoubleClick, onContextMenu, onSelectionChange, nodeContextMenu, editable = false, onNodeAdd, onNodeUpdate, onNodesUpdate, onNodeDelete, onNodesDelete, onEdgeUpdate, onEdgeDelete, onEdgeAdd, canDropNodeOn, onNodeDrop, renderAddNodeButton, showNodeToolbar = true, renderNodeToolbar, theme: themeProp, themes: customThemes, edgeStyle = "bezier", defaultViewport, minZoom: minZoomProp, maxZoom, onViewportChange, autoFit = "canvas-change", laneHeaders = "pinned", snapToLanes = false, zoomNavigation = false, historyDepth, onUndo, onRedo, className, style }, forwardedRef) {
|
|
21186
|
+
const zoomNavConfig = (0, import_react25.useMemo)(() => {
|
|
20946
21187
|
const defaults = {
|
|
20947
21188
|
enterThreshold: 0.66,
|
|
20948
21189
|
exitThreshold: 0.33,
|
|
@@ -20967,16 +21208,16 @@ var SystemCanvas = (() => {
|
|
|
20967
21208
|
}, [zoomNavigation]);
|
|
20968
21209
|
const effectiveMaxZoom = maxZoom ?? (zoomNavConfig.enabled ? 16 : 4);
|
|
20969
21210
|
const effectiveMinZoom = minZoomProp ?? (zoomNavConfig.enabled ? 0.01 : 0.1);
|
|
20970
|
-
(0,
|
|
21211
|
+
(0, import_react25.useEffect)(() => {
|
|
20971
21212
|
const env = globalThis.process?.env?.NODE_ENV;
|
|
20972
21213
|
if (editable && !canvases && env !== "production") {
|
|
20973
21214
|
console.warn("[system-canvas] `editable` is enabled but `canvases` prop is missing. Edits to sub-canvases will not be reflected without a synchronous ref \u2192 CanvasData map.");
|
|
20974
21215
|
}
|
|
20975
21216
|
}, [editable, canvases]);
|
|
20976
|
-
const [parentFrames, setParentFrames] = (0,
|
|
20977
|
-
const [pendingHandoff, setPendingHandoff] = (0,
|
|
20978
|
-
const suppressNextHandoffClearRef = (0,
|
|
20979
|
-
const handleBreadcrumbClick = (0,
|
|
21217
|
+
const [parentFrames, setParentFrames] = (0, import_react25.useState)([]);
|
|
21218
|
+
const [pendingHandoff, setPendingHandoff] = (0, import_react25.useState)(null);
|
|
21219
|
+
const suppressNextHandoffClearRef = (0, import_react25.useRef)(false);
|
|
21220
|
+
const handleBreadcrumbClick = (0, import_react25.useCallback)((index) => {
|
|
20980
21221
|
setParentFrames((prev) => prev.slice(0, index));
|
|
20981
21222
|
if (suppressNextHandoffClearRef.current) {
|
|
20982
21223
|
suppressNextHandoffClearRef.current = false;
|
|
@@ -20993,10 +21234,10 @@ var SystemCanvas = (() => {
|
|
|
20993
21234
|
onNavigate,
|
|
20994
21235
|
onBreadcrumbClick: handleBreadcrumbClick
|
|
20995
21236
|
});
|
|
20996
|
-
(0,
|
|
21237
|
+
(0, import_react25.useEffect)(() => {
|
|
20997
21238
|
onBreadcrumbsChange?.(breadcrumbs);
|
|
20998
21239
|
}, [breadcrumbs, onBreadcrumbsChange]);
|
|
20999
|
-
const theme = (0,
|
|
21240
|
+
const theme = (0, import_react25.useMemo)(() => {
|
|
21000
21241
|
const registry = { ...themes, ...customThemes };
|
|
21001
21242
|
const resolveByName = (name) => name && registry[name] ? registry[name] : null;
|
|
21002
21243
|
if (themeProp) {
|
|
@@ -21007,22 +21248,22 @@ var SystemCanvas = (() => {
|
|
|
21007
21248
|
}
|
|
21008
21249
|
return resolveByName(currentCanvas.theme?.base) ?? resolveByName(canvas.theme?.base) ?? darkTheme;
|
|
21009
21250
|
}, [themeProp, customThemes, currentCanvas.theme?.base, canvas.theme?.base]);
|
|
21010
|
-
const { nodes, edges, nodeMap } = (0,
|
|
21251
|
+
const { nodes, edges, nodeMap } = (0, import_react25.useMemo)(() => {
|
|
21011
21252
|
const resolved = resolveCanvas(currentCanvas, theme);
|
|
21012
21253
|
const map = buildNodeMap(resolved.nodes);
|
|
21013
21254
|
return { nodes: resolved.nodes, edges: resolved.edges, nodeMap: map };
|
|
21014
21255
|
}, [currentCanvas, theme]);
|
|
21015
|
-
const nodesRef = (0,
|
|
21256
|
+
const nodesRef = (0, import_react25.useRef)(nodes);
|
|
21016
21257
|
nodesRef.current = nodes;
|
|
21017
|
-
const viewportStateRef = (0,
|
|
21018
|
-
const viewportHandleRef = (0,
|
|
21019
|
-
const navigateToRefRef = (0,
|
|
21258
|
+
const viewportStateRef = (0, import_react25.useRef)(defaultViewport ?? { x: 0, y: 0, zoom: 1 });
|
|
21259
|
+
const viewportHandleRef = (0, import_react25.useRef)(null);
|
|
21260
|
+
const navigateToRefRef = (0, import_react25.useRef)(navigateToRef);
|
|
21020
21261
|
navigateToRefRef.current = navigateToRef;
|
|
21021
|
-
const navigateToBreadcrumbRef = (0,
|
|
21262
|
+
const navigateToBreadcrumbRef = (0, import_react25.useRef)(navigateToBreadcrumb);
|
|
21022
21263
|
navigateToBreadcrumbRef.current = navigateToBreadcrumb;
|
|
21023
|
-
const breadcrumbsRef = (0,
|
|
21264
|
+
const breadcrumbsRef = (0, import_react25.useRef)(breadcrumbs);
|
|
21024
21265
|
breadcrumbsRef.current = breadcrumbs;
|
|
21025
|
-
(0,
|
|
21266
|
+
(0, import_react25.useImperativeHandle)(forwardedRef, () => ({
|
|
21026
21267
|
zoomIntoNode: (nodeId, options) => {
|
|
21027
21268
|
return new Promise((resolve) => {
|
|
21028
21269
|
const node = nodesRef.current.find((n) => n.id === nodeId);
|
|
@@ -21054,24 +21295,24 @@ var SystemCanvas = (() => {
|
|
|
21054
21295
|
navigateToBreadcrumbRef.current(0);
|
|
21055
21296
|
}
|
|
21056
21297
|
}), [forwardedRef]);
|
|
21057
|
-
const [editingId, setEditingId] = (0,
|
|
21058
|
-
const [selectedEdgeId, setSelectedEdgeId] = (0,
|
|
21059
|
-
const [editingEdgeId, setEditingEdgeId] = (0,
|
|
21060
|
-
const svgProxyRef = (0,
|
|
21061
|
-
const containerRef = (0,
|
|
21062
|
-
const { selectedIds, selectNode, toggleNode, selectAll, clearSelection, marqueeRect, marqueeActiveRef } = useMultiSelect({
|
|
21298
|
+
const [editingId, setEditingId] = (0, import_react25.useState)(null);
|
|
21299
|
+
const [selectedEdgeId, setSelectedEdgeId] = (0, import_react25.useState)(null);
|
|
21300
|
+
const [editingEdgeId, setEditingEdgeId] = (0, import_react25.useState)(null);
|
|
21301
|
+
const svgProxyRef = (0, import_react25.useRef)(null);
|
|
21302
|
+
const containerRef = (0, import_react25.useRef)(null);
|
|
21303
|
+
const { selectedIds, selectNode, toggleNode, selectAll, clearSelection, selectMultiple, marqueeRect, marqueeActiveRef } = useMultiSelect({
|
|
21063
21304
|
svgRef: svgProxyRef,
|
|
21064
21305
|
viewport: viewportStateRef,
|
|
21065
21306
|
nodesRef,
|
|
21066
21307
|
containerRef,
|
|
21067
21308
|
enabled: editable
|
|
21068
21309
|
});
|
|
21069
|
-
const selectedIdsRef = (0,
|
|
21070
|
-
(0,
|
|
21310
|
+
const selectedIdsRef = (0, import_react25.useRef)(selectedIds);
|
|
21311
|
+
(0, import_react25.useEffect)(() => {
|
|
21071
21312
|
selectedIdsRef.current = selectedIds;
|
|
21072
21313
|
}, [selectedIds]);
|
|
21073
|
-
const edgesRef = (0,
|
|
21074
|
-
(0,
|
|
21314
|
+
const edgesRef = (0, import_react25.useRef)(edges);
|
|
21315
|
+
(0, import_react25.useEffect)(() => {
|
|
21075
21316
|
edgesRef.current = edges;
|
|
21076
21317
|
}, [edges]);
|
|
21077
21318
|
const { wrappedOnNodeAdd, wrappedOnNodeUpdate, wrappedOnNodesUpdate, wrappedOnNodeDelete, wrappedOnNodesDelete, wrappedOnEdgeAdd, wrappedOnEdgeUpdate, wrappedOnEdgeDelete, beginBatch, endBatch, undo, redo } = useCommandHistory({
|
|
@@ -21103,18 +21344,18 @@ var SystemCanvas = (() => {
|
|
|
21103
21344
|
onBeginBatch: beginBatch,
|
|
21104
21345
|
onEndBatch: endBatch
|
|
21105
21346
|
});
|
|
21106
|
-
(0,
|
|
21347
|
+
(0, import_react25.useEffect)(() => {
|
|
21107
21348
|
clearSelection();
|
|
21108
21349
|
setEditingId(null);
|
|
21109
21350
|
setSelectedEdgeId(null);
|
|
21110
21351
|
setEditingEdgeId(null);
|
|
21111
21352
|
}, [currentCanvasRef]);
|
|
21112
|
-
const onSelectionChangeRef = (0,
|
|
21113
|
-
(0,
|
|
21353
|
+
const onSelectionChangeRef = (0, import_react25.useRef)(onSelectionChange);
|
|
21354
|
+
(0, import_react25.useEffect)(() => {
|
|
21114
21355
|
onSelectionChangeRef.current = onSelectionChange;
|
|
21115
21356
|
}, [onSelectionChange]);
|
|
21116
|
-
const lastEmittedSelectionRef = (0,
|
|
21117
|
-
(0,
|
|
21357
|
+
const lastEmittedSelectionRef = (0, import_react25.useRef)({ kind: null, id: null, multiIds: null, canvasRef: void 0 });
|
|
21358
|
+
(0, import_react25.useEffect)(() => {
|
|
21118
21359
|
const cb = onSelectionChangeRef.current;
|
|
21119
21360
|
let next = null;
|
|
21120
21361
|
if (selectedIds.size > 1) {
|
|
@@ -21156,8 +21397,8 @@ var SystemCanvas = (() => {
|
|
|
21156
21397
|
}
|
|
21157
21398
|
cb?.(next);
|
|
21158
21399
|
}, [selectedIds, selectedEdgeId, currentCanvasRef, nodeMap, edges]);
|
|
21159
|
-
const [containerSize, setContainerSize] = (0,
|
|
21160
|
-
(0,
|
|
21400
|
+
const [containerSize, setContainerSize] = (0, import_react25.useState)({ width: 0, height: 0 });
|
|
21401
|
+
(0, import_react25.useEffect)(() => {
|
|
21161
21402
|
const el = containerRef.current;
|
|
21162
21403
|
if (!el)
|
|
21163
21404
|
return;
|
|
@@ -21172,8 +21413,8 @@ var SystemCanvas = (() => {
|
|
|
21172
21413
|
}, []);
|
|
21173
21414
|
const hasLanes = currentCanvas.columns && currentCanvas.columns.length > 0 || currentCanvas.rows && currentCanvas.rows.length > 0;
|
|
21174
21415
|
const showLaneHeaders = hasLanes && laneHeaders !== "none";
|
|
21175
|
-
const getViewportState = (0,
|
|
21176
|
-
const applyLaneSnap = (0,
|
|
21416
|
+
const getViewportState = (0, import_react25.useCallback)(() => viewportStateRef.current ?? { x: 0, y: 0, zoom: 1 }, []);
|
|
21417
|
+
const applyLaneSnap = (0, import_react25.useCallback)((id2, patch) => {
|
|
21177
21418
|
if (!snapToLanes)
|
|
21178
21419
|
return patch;
|
|
21179
21420
|
const cols = currentCanvas.columns;
|
|
@@ -21198,10 +21439,10 @@ var SystemCanvas = (() => {
|
|
|
21198
21439
|
}
|
|
21199
21440
|
return final;
|
|
21200
21441
|
}, [snapToLanes, currentCanvas.columns, currentCanvas.rows]);
|
|
21201
|
-
const commitResize = (0,
|
|
21442
|
+
const commitResize = (0, import_react25.useCallback)((id2, patch) => {
|
|
21202
21443
|
wrappedOnNodeUpdate(id2, applyLaneSnap(id2, patch), currentCanvasRef);
|
|
21203
21444
|
}, [wrappedOnNodeUpdate, currentCanvasRef, applyLaneSnap]);
|
|
21204
|
-
const commitDragBatch = (0,
|
|
21445
|
+
const commitDragBatch = (0, import_react25.useCallback)((updates) => {
|
|
21205
21446
|
const final = updates.map((u) => ({
|
|
21206
21447
|
id: u.id,
|
|
21207
21448
|
patch: applyLaneSnap(u.id, u.patch)
|
|
@@ -21216,10 +21457,10 @@ var SystemCanvas = (() => {
|
|
|
21216
21457
|
wrappedOnNodeUpdate(id2, patch, currentCanvasRef);
|
|
21217
21458
|
}
|
|
21218
21459
|
}, [wrappedOnNodeUpdate, wrappedOnNodesUpdate, onNodeUpdate, onNodesUpdate, currentCanvasRef, applyLaneSnap]);
|
|
21219
|
-
const handleNodeDrop = (0,
|
|
21460
|
+
const handleNodeDrop = (0, import_react25.useCallback)((sources, target) => {
|
|
21220
21461
|
onNodeDrop?.(sources, target, { canvasRef: currentCanvasRef });
|
|
21221
21462
|
}, [onNodeDrop, currentCanvasRef]);
|
|
21222
|
-
const { dragOverrides, dropTargetId, onPointerDown: onNodePointerDown } = useNodeDrag({
|
|
21463
|
+
const { dragOverrides, dropTargetId, onPointerDown: onNodePointerDown, cancelDrag } = useNodeDrag({
|
|
21223
21464
|
viewport: viewportStateRef,
|
|
21224
21465
|
nodesRef,
|
|
21225
21466
|
onCommit: commitDragBatch,
|
|
@@ -21233,7 +21474,7 @@ var SystemCanvas = (() => {
|
|
|
21233
21474
|
onCommit: commitResize
|
|
21234
21475
|
});
|
|
21235
21476
|
const singleSelectedId = selectedIds.size === 1 ? Array.from(selectedIds)[0] : null;
|
|
21236
|
-
const selectedResolvedNode = (0,
|
|
21477
|
+
const selectedResolvedNode = (0, import_react25.useMemo)(() => {
|
|
21237
21478
|
if (!singleSelectedId)
|
|
21238
21479
|
return null;
|
|
21239
21480
|
const base = nodeMap.get(singleSelectedId);
|
|
@@ -21250,7 +21491,7 @@ var SystemCanvas = (() => {
|
|
|
21250
21491
|
return base;
|
|
21251
21492
|
}, [singleSelectedId, nodeMap, dragOverrides, resizeOverrides]);
|
|
21252
21493
|
svgProxyRef.current = viewportHandleRef.current?.getSvgElement() ?? null;
|
|
21253
|
-
const handleEdgeCreated = (0,
|
|
21494
|
+
const handleEdgeCreated = (0, import_react25.useCallback)((edge) => {
|
|
21254
21495
|
wrappedOnEdgeAdd(edge, currentCanvasRef);
|
|
21255
21496
|
}, [wrappedOnEdgeAdd, currentCanvasRef]);
|
|
21256
21497
|
const { pending: pendingEdge, onHandlePointerDown: onConnectionHandlePointerDown } = useEdgeCreate({
|
|
@@ -21259,7 +21500,7 @@ var SystemCanvas = (() => {
|
|
|
21259
21500
|
nodesRef,
|
|
21260
21501
|
onCreate: handleEdgeCreated
|
|
21261
21502
|
});
|
|
21262
|
-
const handleNavigableNodeClick = (0,
|
|
21503
|
+
const handleNavigableNodeClick = (0, import_react25.useCallback)((node) => {
|
|
21263
21504
|
const frame2 = {
|
|
21264
21505
|
parentCanvasRef: currentCanvasRef,
|
|
21265
21506
|
parentNodeRect: {
|
|
@@ -21286,7 +21527,7 @@ var SystemCanvas = (() => {
|
|
|
21286
21527
|
navigateToRef(node);
|
|
21287
21528
|
}
|
|
21288
21529
|
}, [navigateToRef, currentCanvasRef, zoomNavConfig.enabled]);
|
|
21289
|
-
const handleZoomEnter = (0,
|
|
21530
|
+
const handleZoomEnter = (0, import_react25.useCallback)((node, targetTransform) => {
|
|
21290
21531
|
const frame2 = {
|
|
21291
21532
|
parentCanvasRef: currentCanvasRef,
|
|
21292
21533
|
parentNodeRect: {
|
|
@@ -21300,7 +21541,7 @@ var SystemCanvas = (() => {
|
|
|
21300
21541
|
setPendingHandoff(targetTransform);
|
|
21301
21542
|
navigateToRef(node);
|
|
21302
21543
|
}, [currentCanvasRef, navigateToRef]);
|
|
21303
|
-
const handleZoomExit = (0,
|
|
21544
|
+
const handleZoomExit = (0, import_react25.useCallback)((targetTransform) => {
|
|
21304
21545
|
setPendingHandoff(targetTransform);
|
|
21305
21546
|
suppressNextHandoffClearRef.current = true;
|
|
21306
21547
|
navigateToBreadcrumb(breadcrumbs.length - 2);
|
|
@@ -21327,26 +21568,26 @@ var SystemCanvas = (() => {
|
|
|
21327
21568
|
onEnter: handleZoomEnter,
|
|
21328
21569
|
onExit: handleZoomExit
|
|
21329
21570
|
});
|
|
21330
|
-
const handleViewportChange = (0,
|
|
21571
|
+
const handleViewportChange = (0, import_react25.useCallback)((vp) => {
|
|
21331
21572
|
viewportStateRef.current = vp;
|
|
21332
21573
|
handleZoomNavViewportChange(vp);
|
|
21333
21574
|
onViewportChange?.(vp);
|
|
21334
21575
|
}, [handleZoomNavViewportChange, onViewportChange]);
|
|
21335
|
-
const handleHandoffApplied = (0,
|
|
21576
|
+
const handleHandoffApplied = (0, import_react25.useCallback)(() => {
|
|
21336
21577
|
setPendingHandoff(null);
|
|
21337
21578
|
clearZoomNavCommitting();
|
|
21338
21579
|
}, [clearZoomNavCommitting]);
|
|
21339
|
-
const handleBeginEdit = (0,
|
|
21580
|
+
const handleBeginEdit = (0, import_react25.useCallback)((node) => {
|
|
21340
21581
|
setEditingId(node.id);
|
|
21341
21582
|
}, []);
|
|
21342
|
-
const handleBeginEditEdge = (0,
|
|
21583
|
+
const handleBeginEditEdge = (0, import_react25.useCallback)((edge) => {
|
|
21343
21584
|
setEditingEdgeId(edge.id);
|
|
21344
21585
|
}, []);
|
|
21345
|
-
const [contextMenuState, setContextMenuState] = (0,
|
|
21346
|
-
(0,
|
|
21586
|
+
const [contextMenuState, setContextMenuState] = (0, import_react25.useState)(null);
|
|
21587
|
+
(0, import_react25.useEffect)(() => {
|
|
21347
21588
|
setContextMenuState(null);
|
|
21348
21589
|
}, [currentCanvasRef]);
|
|
21349
|
-
const handleContextMenu = (0,
|
|
21590
|
+
const handleContextMenu = (0, import_react25.useCallback)((event) => {
|
|
21350
21591
|
onContextMenu?.(event);
|
|
21351
21592
|
if (!nodeContextMenu)
|
|
21352
21593
|
return;
|
|
@@ -21389,27 +21630,27 @@ var SystemCanvas = (() => {
|
|
|
21389
21630
|
onSelectEdge: setSelectedEdgeId,
|
|
21390
21631
|
onBeginEditEdge: handleBeginEditEdge
|
|
21391
21632
|
});
|
|
21392
|
-
const handleEditorCommit = (0,
|
|
21633
|
+
const handleEditorCommit = (0, import_react25.useCallback)((patch) => {
|
|
21393
21634
|
if (editingId) {
|
|
21394
21635
|
wrappedOnNodeUpdate(editingId, patch, currentCanvasRef);
|
|
21395
21636
|
}
|
|
21396
21637
|
setEditingId(null);
|
|
21397
21638
|
}, [editingId, wrappedOnNodeUpdate, currentCanvasRef]);
|
|
21398
|
-
const handleEditorCancel = (0,
|
|
21639
|
+
const handleEditorCancel = (0, import_react25.useCallback)(() => {
|
|
21399
21640
|
setEditingId(null);
|
|
21400
21641
|
}, []);
|
|
21401
|
-
const handleEdgeEditorCommit = (0,
|
|
21642
|
+
const handleEdgeEditorCommit = (0, import_react25.useCallback)((patch) => {
|
|
21402
21643
|
if (editingEdgeId) {
|
|
21403
21644
|
wrappedOnEdgeUpdate(editingEdgeId, patch, currentCanvasRef);
|
|
21404
21645
|
}
|
|
21405
21646
|
setEditingEdgeId(null);
|
|
21406
21647
|
}, [editingEdgeId, wrappedOnEdgeUpdate, currentCanvasRef]);
|
|
21407
|
-
const handleEdgeEditorCancel = (0,
|
|
21648
|
+
const handleEdgeEditorCancel = (0, import_react25.useCallback)(() => {
|
|
21408
21649
|
setEditingEdgeId(null);
|
|
21409
21650
|
}, []);
|
|
21410
|
-
const lastAddRef = (0,
|
|
21411
|
-
const menuOptions = (0,
|
|
21412
|
-
const addNode2 = (0,
|
|
21651
|
+
const lastAddRef = (0, import_react25.useRef)(null);
|
|
21652
|
+
const menuOptions = (0, import_react25.useMemo)(() => getNodeMenuOptions(currentCanvas, theme), [currentCanvas, theme]);
|
|
21653
|
+
const addNode2 = (0, import_react25.useCallback)((option, position) => {
|
|
21413
21654
|
let x, y;
|
|
21414
21655
|
if (position) {
|
|
21415
21656
|
x = position.x;
|
|
@@ -21441,64 +21682,40 @@ var SystemCanvas = (() => {
|
|
|
21441
21682
|
const node = createNodeFromOption(option, Math.round(x), Math.round(y), void 0, theme);
|
|
21442
21683
|
wrappedOnNodeAdd(node, currentCanvasRef);
|
|
21443
21684
|
}, [wrappedOnNodeAdd, currentCanvasRef, theme]);
|
|
21444
|
-
const handleKeyDown = (
|
|
21445
|
-
if (!editable)
|
|
21446
|
-
return;
|
|
21447
|
-
if (e.key === "Escape") {
|
|
21448
|
-
setEditingId(null);
|
|
21449
|
-
clearSelection();
|
|
21450
|
-
setEditingEdgeId(null);
|
|
21451
|
-
setSelectedEdgeId(null);
|
|
21452
|
-
return;
|
|
21453
|
-
}
|
|
21454
|
-
if (editingId || editingEdgeId)
|
|
21455
|
-
return;
|
|
21456
|
-
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.key === "z") {
|
|
21457
|
-
e.preventDefault();
|
|
21458
|
-
undo();
|
|
21459
|
-
return;
|
|
21460
|
-
}
|
|
21461
|
-
if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === "z") {
|
|
21462
|
-
e.preventDefault();
|
|
21463
|
-
redo();
|
|
21464
|
-
return;
|
|
21465
|
-
}
|
|
21466
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "a") {
|
|
21467
|
-
e.preventDefault();
|
|
21468
|
-
selectAll();
|
|
21469
|
-
return;
|
|
21470
|
-
}
|
|
21471
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
|
21472
|
-
if (selectedIds.size > 1) {
|
|
21473
|
-
e.preventDefault();
|
|
21474
|
-
wrappedOnNodesDelete(Array.from(selectedIds), currentCanvasRef);
|
|
21475
|
-
clearSelection();
|
|
21476
|
-
} else if (selectedIds.size === 1) {
|
|
21477
|
-
const id2 = Array.from(selectedIds)[0];
|
|
21478
|
-
e.preventDefault();
|
|
21479
|
-
wrappedOnNodeDelete(id2, currentCanvasRef);
|
|
21480
|
-
clearSelection();
|
|
21481
|
-
} else if (selectedEdgeId) {
|
|
21482
|
-
e.preventDefault();
|
|
21483
|
-
wrappedOnEdgeDelete(selectedEdgeId, currentCanvasRef);
|
|
21484
|
-
setSelectedEdgeId(null);
|
|
21485
|
-
}
|
|
21486
|
-
}
|
|
21487
|
-
}, [
|
|
21685
|
+
const handleKeyDown = useKeyboardShortcuts({
|
|
21488
21686
|
editable,
|
|
21489
21687
|
editingId,
|
|
21490
21688
|
editingEdgeId,
|
|
21491
21689
|
selectedIds,
|
|
21492
21690
|
selectedEdgeId,
|
|
21691
|
+
nodesRef,
|
|
21692
|
+
edgesRef,
|
|
21693
|
+
theme,
|
|
21694
|
+
currentCanvasRef,
|
|
21695
|
+
contextMenuState,
|
|
21696
|
+
setContextMenuState,
|
|
21697
|
+
wrappedOnNodeAdd,
|
|
21698
|
+
wrappedOnEdgeAdd,
|
|
21699
|
+
wrappedOnNodeUpdate,
|
|
21700
|
+
wrappedOnNodesUpdate,
|
|
21493
21701
|
wrappedOnNodeDelete,
|
|
21494
21702
|
wrappedOnNodesDelete,
|
|
21495
21703
|
wrappedOnEdgeDelete,
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
|
|
21704
|
+
onNodesUpdate,
|
|
21705
|
+
onNodeUpdate,
|
|
21706
|
+
beginBatch,
|
|
21707
|
+
endBatch,
|
|
21499
21708
|
undo,
|
|
21500
|
-
redo
|
|
21501
|
-
|
|
21709
|
+
redo,
|
|
21710
|
+
selectNode,
|
|
21711
|
+
selectMultiple,
|
|
21712
|
+
selectAll,
|
|
21713
|
+
clearSelection,
|
|
21714
|
+
setEditingId,
|
|
21715
|
+
setEditingEdgeId,
|
|
21716
|
+
setSelectedEdgeId,
|
|
21717
|
+
cancelDrag
|
|
21718
|
+
});
|
|
21502
21719
|
const renderProps = { options: menuOptions, addNode: addNode2, theme };
|
|
21503
21720
|
return (0, import_jsx_runtime28.jsxs)("div", { ref: containerRef, className: `system-canvas ${className ?? ""}`, tabIndex: editable ? 0 : -1, onKeyDown: handleKeyDown, style: {
|
|
21504
21721
|
position: "relative",
|
|
@@ -21649,7 +21866,7 @@ var SystemCanvas = (() => {
|
|
|
21649
21866
|
onEdgeUpdate: handleEdgeUpdate,
|
|
21650
21867
|
onEdgeDelete: handleEdgeDelete
|
|
21651
21868
|
};
|
|
21652
|
-
root2.render(
|
|
21869
|
+
root2.render(import_react26.default.createElement(SystemCanvas, props));
|
|
21653
21870
|
};
|
|
21654
21871
|
doRender();
|
|
21655
21872
|
return {
|