system-canvas-standalone 0.2.3 → 0.2.5
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 +841 -298
- 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,25 +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
|
-
const { selectedIdsRef, nodesRef, edgesRef, viewport, onNodeAdd, onEdgeAdd, canvasRef, getCursorScreenPos } = options;
|
|
15353
|
-
const getCursorScreenPosRef = (0,
|
|
15593
|
+
const { selectedIdsRef, nodesRef, edgesRef, viewport, onNodeAdd, onEdgeAdd, canvasRef, getCursorScreenPos, onBeginBatch, onEndBatch } = options;
|
|
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
|
-
(0,
|
|
15602
|
+
const onBeginBatchRef = (0, import_react8.useRef)(onBeginBatch);
|
|
15603
|
+
onBeginBatchRef.current = onBeginBatch;
|
|
15604
|
+
const onEndBatchRef = (0, import_react8.useRef)(onEndBatch);
|
|
15605
|
+
onEndBatchRef.current = onEndBatch;
|
|
15606
|
+
(0, import_react8.useEffect)(() => {
|
|
15362
15607
|
const handler = (e) => {
|
|
15363
15608
|
const active = document.activeElement;
|
|
15364
15609
|
if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable) {
|
|
@@ -15430,12 +15675,14 @@ var SystemCanvas = (() => {
|
|
|
15430
15675
|
toNode: oldToNew.get(edge.toNode)
|
|
15431
15676
|
}));
|
|
15432
15677
|
const ref = canvasRefRef.current;
|
|
15678
|
+
onBeginBatchRef.current?.();
|
|
15433
15679
|
for (const node of clonedNodes) {
|
|
15434
15680
|
onNodeAddRef.current(node, ref);
|
|
15435
15681
|
}
|
|
15436
15682
|
for (const edge of clonedEdges) {
|
|
15437
15683
|
onEdgeAddRef.current(edge, ref);
|
|
15438
15684
|
}
|
|
15685
|
+
onEndBatchRef.current?.();
|
|
15439
15686
|
e.preventDefault();
|
|
15440
15687
|
return;
|
|
15441
15688
|
}
|
|
@@ -15447,8 +15694,298 @@ var SystemCanvas = (() => {
|
|
|
15447
15694
|
}, [selectedIdsRef, nodesRef, edgesRef, viewport]);
|
|
15448
15695
|
}
|
|
15449
15696
|
|
|
15697
|
+
// ../react/dist/hooks/useCommandHistory.js
|
|
15698
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
15699
|
+
function getCanvasRef(cmd) {
|
|
15700
|
+
if (cmd.type === "batch") {
|
|
15701
|
+
return cmd.commands.length > 0 ? getCanvasRef(cmd.commands[0]) : void 0;
|
|
15702
|
+
}
|
|
15703
|
+
return cmd.canvasRef;
|
|
15704
|
+
}
|
|
15705
|
+
function useCommandHistory(options) {
|
|
15706
|
+
const { nodesRef, edgesRef, onNodeAdd, onNodeUpdate, onNodesUpdate, onNodeDelete, onNodesDelete, onEdgeAdd, onEdgeUpdate, onEdgeDelete, maxDepth = 50, enabled = true, onUndo, onRedo } = options;
|
|
15707
|
+
const onNodeAddRef = (0, import_react9.useRef)(onNodeAdd);
|
|
15708
|
+
onNodeAddRef.current = onNodeAdd;
|
|
15709
|
+
const onNodeUpdateRef = (0, import_react9.useRef)(onNodeUpdate);
|
|
15710
|
+
onNodeUpdateRef.current = onNodeUpdate;
|
|
15711
|
+
const onNodesUpdateRef = (0, import_react9.useRef)(onNodesUpdate);
|
|
15712
|
+
onNodesUpdateRef.current = onNodesUpdate;
|
|
15713
|
+
const onNodeDeleteRef = (0, import_react9.useRef)(onNodeDelete);
|
|
15714
|
+
onNodeDeleteRef.current = onNodeDelete;
|
|
15715
|
+
const onNodesDeleteRef = (0, import_react9.useRef)(onNodesDelete);
|
|
15716
|
+
onNodesDeleteRef.current = onNodesDelete;
|
|
15717
|
+
const onEdgeAddRef = (0, import_react9.useRef)(onEdgeAdd);
|
|
15718
|
+
onEdgeAddRef.current = onEdgeAdd;
|
|
15719
|
+
const onEdgeUpdateRef = (0, import_react9.useRef)(onEdgeUpdate);
|
|
15720
|
+
onEdgeUpdateRef.current = onEdgeUpdate;
|
|
15721
|
+
const onEdgeDeleteRef = (0, import_react9.useRef)(onEdgeDelete);
|
|
15722
|
+
onEdgeDeleteRef.current = onEdgeDelete;
|
|
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);
|
|
15729
|
+
function syncBooleans() {
|
|
15730
|
+
setCanUndo(undoStack.current.length > 0);
|
|
15731
|
+
setCanRedo(redoStack.current.length > 0);
|
|
15732
|
+
}
|
|
15733
|
+
function pushCommand(cmd) {
|
|
15734
|
+
if (pendingBatchRef.current) {
|
|
15735
|
+
pendingBatchRef.current.push(cmd);
|
|
15736
|
+
return;
|
|
15737
|
+
}
|
|
15738
|
+
undoStack.current.push(cmd);
|
|
15739
|
+
if (undoStack.current.length > maxDepth)
|
|
15740
|
+
undoStack.current.shift();
|
|
15741
|
+
redoStack.current = [];
|
|
15742
|
+
syncBooleans();
|
|
15743
|
+
}
|
|
15744
|
+
function applyInverse(cmd) {
|
|
15745
|
+
switch (cmd.type) {
|
|
15746
|
+
case "node:add":
|
|
15747
|
+
onNodeDeleteRef.current?.(cmd.node.id, cmd.canvasRef);
|
|
15748
|
+
break;
|
|
15749
|
+
case "node:delete":
|
|
15750
|
+
onNodeAddRef.current?.(cmd.node, cmd.canvasRef);
|
|
15751
|
+
break;
|
|
15752
|
+
case "node:update":
|
|
15753
|
+
onNodeUpdateRef.current?.(cmd.id, cmd.prev, cmd.canvasRef);
|
|
15754
|
+
break;
|
|
15755
|
+
case "nodes:update":
|
|
15756
|
+
onNodesUpdateRef.current?.(cmd.updates.map((u) => ({ id: u.id, patch: u.prev })), cmd.canvasRef);
|
|
15757
|
+
break;
|
|
15758
|
+
case "nodes:delete":
|
|
15759
|
+
for (const node of cmd.nodes) {
|
|
15760
|
+
onNodeAddRef.current?.(node, cmd.canvasRef);
|
|
15761
|
+
}
|
|
15762
|
+
break;
|
|
15763
|
+
case "edge:add":
|
|
15764
|
+
onEdgeDeleteRef.current?.(cmd.edge.id, cmd.canvasRef);
|
|
15765
|
+
break;
|
|
15766
|
+
case "edge:delete":
|
|
15767
|
+
onEdgeAddRef.current?.(cmd.edge, cmd.canvasRef);
|
|
15768
|
+
break;
|
|
15769
|
+
case "edge:update":
|
|
15770
|
+
onEdgeUpdateRef.current?.(cmd.id, cmd.prev, cmd.canvasRef);
|
|
15771
|
+
break;
|
|
15772
|
+
case "batch":
|
|
15773
|
+
for (let i = cmd.commands.length - 1; i >= 0; i--) {
|
|
15774
|
+
applyInverse(cmd.commands[i]);
|
|
15775
|
+
}
|
|
15776
|
+
break;
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15779
|
+
function applyForward(cmd) {
|
|
15780
|
+
switch (cmd.type) {
|
|
15781
|
+
case "node:add":
|
|
15782
|
+
onNodeAddRef.current?.(cmd.node, cmd.canvasRef);
|
|
15783
|
+
break;
|
|
15784
|
+
case "node:delete":
|
|
15785
|
+
onNodeDeleteRef.current?.(cmd.node.id, cmd.canvasRef);
|
|
15786
|
+
break;
|
|
15787
|
+
case "node:update":
|
|
15788
|
+
onNodeUpdateRef.current?.(cmd.id, cmd.patch, cmd.canvasRef);
|
|
15789
|
+
break;
|
|
15790
|
+
case "nodes:update":
|
|
15791
|
+
onNodesUpdateRef.current?.(cmd.updates.map((u) => ({ id: u.id, patch: u.patch })), cmd.canvasRef);
|
|
15792
|
+
break;
|
|
15793
|
+
case "nodes:delete":
|
|
15794
|
+
onNodesDeleteRef.current?.(cmd.nodes.map((n) => n.id), cmd.canvasRef);
|
|
15795
|
+
break;
|
|
15796
|
+
case "edge:add":
|
|
15797
|
+
onEdgeAddRef.current?.(cmd.edge, cmd.canvasRef);
|
|
15798
|
+
break;
|
|
15799
|
+
case "edge:delete":
|
|
15800
|
+
onEdgeDeleteRef.current?.(cmd.edge.id, cmd.canvasRef);
|
|
15801
|
+
break;
|
|
15802
|
+
case "edge:update":
|
|
15803
|
+
onEdgeUpdateRef.current?.(cmd.id, cmd.patch, cmd.canvasRef);
|
|
15804
|
+
break;
|
|
15805
|
+
case "batch":
|
|
15806
|
+
for (const c of cmd.commands) {
|
|
15807
|
+
applyForward(c);
|
|
15808
|
+
}
|
|
15809
|
+
break;
|
|
15810
|
+
}
|
|
15811
|
+
}
|
|
15812
|
+
const undo = (0, import_react9.useCallback)(() => {
|
|
15813
|
+
if (!enabled)
|
|
15814
|
+
return;
|
|
15815
|
+
const cmd = undoStack.current.pop();
|
|
15816
|
+
if (!cmd)
|
|
15817
|
+
return;
|
|
15818
|
+
isUndoingRef.current = true;
|
|
15819
|
+
applyInverse(cmd);
|
|
15820
|
+
isUndoingRef.current = false;
|
|
15821
|
+
redoStack.current.push(cmd);
|
|
15822
|
+
syncBooleans();
|
|
15823
|
+
onUndo?.(getCanvasRef(cmd));
|
|
15824
|
+
}, [enabled, onUndo]);
|
|
15825
|
+
const redo = (0, import_react9.useCallback)(() => {
|
|
15826
|
+
if (!enabled)
|
|
15827
|
+
return;
|
|
15828
|
+
const cmd = redoStack.current.pop();
|
|
15829
|
+
if (!cmd)
|
|
15830
|
+
return;
|
|
15831
|
+
isUndoingRef.current = true;
|
|
15832
|
+
applyForward(cmd);
|
|
15833
|
+
isUndoingRef.current = false;
|
|
15834
|
+
undoStack.current.push(cmd);
|
|
15835
|
+
if (undoStack.current.length > maxDepth)
|
|
15836
|
+
undoStack.current.shift();
|
|
15837
|
+
syncBooleans();
|
|
15838
|
+
onRedo?.(getCanvasRef(cmd));
|
|
15839
|
+
}, [enabled, onRedo, maxDepth]);
|
|
15840
|
+
const beginBatch = (0, import_react9.useCallback)(() => {
|
|
15841
|
+
if (!enabled)
|
|
15842
|
+
return;
|
|
15843
|
+
pendingBatchRef.current = [];
|
|
15844
|
+
}, [enabled]);
|
|
15845
|
+
const endBatch = (0, import_react9.useCallback)(() => {
|
|
15846
|
+
if (!enabled)
|
|
15847
|
+
return;
|
|
15848
|
+
const cmds = pendingBatchRef.current;
|
|
15849
|
+
pendingBatchRef.current = null;
|
|
15850
|
+
if (!cmds || cmds.length === 0)
|
|
15851
|
+
return;
|
|
15852
|
+
if (cmds.length === 1) {
|
|
15853
|
+
pushCommand(cmds[0]);
|
|
15854
|
+
return;
|
|
15855
|
+
}
|
|
15856
|
+
undoStack.current.push({ type: "batch", commands: cmds });
|
|
15857
|
+
if (undoStack.current.length > maxDepth)
|
|
15858
|
+
undoStack.current.shift();
|
|
15859
|
+
redoStack.current = [];
|
|
15860
|
+
syncBooleans();
|
|
15861
|
+
}, [enabled, maxDepth]);
|
|
15862
|
+
const wrappedOnNodeAdd = (0, import_react9.useCallback)(
|
|
15863
|
+
(node, canvasRef) => {
|
|
15864
|
+
if (enabled && !isUndoingRef.current) {
|
|
15865
|
+
pushCommand({ type: "node:add", node, canvasRef });
|
|
15866
|
+
}
|
|
15867
|
+
onNodeAddRef.current?.(node, canvasRef);
|
|
15868
|
+
},
|
|
15869
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15870
|
+
[enabled]
|
|
15871
|
+
);
|
|
15872
|
+
const wrappedOnNodeUpdate = (0, import_react9.useCallback)(
|
|
15873
|
+
(id2, patch, canvasRef) => {
|
|
15874
|
+
if (enabled && !isUndoingRef.current) {
|
|
15875
|
+
const node = nodesRef.current?.find((n) => n.id === id2);
|
|
15876
|
+
if (node) {
|
|
15877
|
+
const prev = Object.fromEntries(Object.keys(patch).map((k) => [k, node[k]]));
|
|
15878
|
+
pushCommand({ type: "node:update", id: id2, prev, patch, canvasRef });
|
|
15879
|
+
}
|
|
15880
|
+
}
|
|
15881
|
+
onNodeUpdateRef.current?.(id2, patch, canvasRef);
|
|
15882
|
+
},
|
|
15883
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15884
|
+
[enabled, nodesRef]
|
|
15885
|
+
);
|
|
15886
|
+
const wrappedOnNodesUpdate = (0, import_react9.useCallback)(
|
|
15887
|
+
(updates, canvasRef) => {
|
|
15888
|
+
if (enabled && !isUndoingRef.current) {
|
|
15889
|
+
const enriched = [];
|
|
15890
|
+
for (const u of updates) {
|
|
15891
|
+
const node = nodesRef.current?.find((n) => n.id === u.id);
|
|
15892
|
+
if (node) {
|
|
15893
|
+
const prev = Object.fromEntries(Object.keys(u.patch).map((k) => [k, node[k]]));
|
|
15894
|
+
enriched.push({ id: u.id, prev, patch: u.patch });
|
|
15895
|
+
}
|
|
15896
|
+
}
|
|
15897
|
+
if (enriched.length > 0) {
|
|
15898
|
+
pushCommand({ type: "nodes:update", updates: enriched, canvasRef });
|
|
15899
|
+
}
|
|
15900
|
+
}
|
|
15901
|
+
onNodesUpdateRef.current?.(updates, canvasRef);
|
|
15902
|
+
},
|
|
15903
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15904
|
+
[enabled, nodesRef]
|
|
15905
|
+
);
|
|
15906
|
+
const wrappedOnNodeDelete = (0, import_react9.useCallback)(
|
|
15907
|
+
(nodeId, canvasRef) => {
|
|
15908
|
+
if (enabled && !isUndoingRef.current) {
|
|
15909
|
+
const node = nodesRef.current?.find((n) => n.id === nodeId);
|
|
15910
|
+
if (node) {
|
|
15911
|
+
pushCommand({ type: "node:delete", node, canvasRef });
|
|
15912
|
+
}
|
|
15913
|
+
}
|
|
15914
|
+
onNodeDeleteRef.current?.(nodeId, canvasRef);
|
|
15915
|
+
},
|
|
15916
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15917
|
+
[enabled, nodesRef]
|
|
15918
|
+
);
|
|
15919
|
+
const wrappedOnNodesDelete = (0, import_react9.useCallback)(
|
|
15920
|
+
(nodeIds, canvasRef) => {
|
|
15921
|
+
if (enabled && !isUndoingRef.current) {
|
|
15922
|
+
const nodes = nodesRef.current?.filter((n) => nodeIds.includes(n.id)) ?? [];
|
|
15923
|
+
if (nodes.length > 0) {
|
|
15924
|
+
pushCommand({ type: "nodes:delete", nodes, canvasRef });
|
|
15925
|
+
}
|
|
15926
|
+
}
|
|
15927
|
+
onNodesDeleteRef.current?.(nodeIds, canvasRef);
|
|
15928
|
+
},
|
|
15929
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15930
|
+
[enabled, nodesRef]
|
|
15931
|
+
);
|
|
15932
|
+
const wrappedOnEdgeAdd = (0, import_react9.useCallback)(
|
|
15933
|
+
(edge, canvasRef) => {
|
|
15934
|
+
if (enabled && !isUndoingRef.current) {
|
|
15935
|
+
pushCommand({ type: "edge:add", edge, canvasRef });
|
|
15936
|
+
}
|
|
15937
|
+
onEdgeAddRef.current?.(edge, canvasRef);
|
|
15938
|
+
},
|
|
15939
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15940
|
+
[enabled]
|
|
15941
|
+
);
|
|
15942
|
+
const wrappedOnEdgeUpdate = (0, import_react9.useCallback)(
|
|
15943
|
+
(id2, patch, canvasRef) => {
|
|
15944
|
+
if (enabled && !isUndoingRef.current) {
|
|
15945
|
+
const edge = edgesRef.current?.find((e) => e.id === id2);
|
|
15946
|
+
if (edge) {
|
|
15947
|
+
const prev = Object.fromEntries(Object.keys(patch).map((k) => [k, edge[k]]));
|
|
15948
|
+
pushCommand({ type: "edge:update", id: id2, prev, patch, canvasRef });
|
|
15949
|
+
}
|
|
15950
|
+
}
|
|
15951
|
+
onEdgeUpdateRef.current?.(id2, patch, canvasRef);
|
|
15952
|
+
},
|
|
15953
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15954
|
+
[enabled, edgesRef]
|
|
15955
|
+
);
|
|
15956
|
+
const wrappedOnEdgeDelete = (0, import_react9.useCallback)(
|
|
15957
|
+
(edgeId, canvasRef) => {
|
|
15958
|
+
if (enabled && !isUndoingRef.current) {
|
|
15959
|
+
const edge = edgesRef.current?.find((e) => e.id === edgeId);
|
|
15960
|
+
if (edge) {
|
|
15961
|
+
pushCommand({ type: "edge:delete", edge, canvasRef });
|
|
15962
|
+
}
|
|
15963
|
+
}
|
|
15964
|
+
onEdgeDeleteRef.current?.(edgeId, canvasRef);
|
|
15965
|
+
},
|
|
15966
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15967
|
+
[enabled, edgesRef]
|
|
15968
|
+
);
|
|
15969
|
+
return {
|
|
15970
|
+
wrappedOnNodeAdd,
|
|
15971
|
+
wrappedOnNodeUpdate,
|
|
15972
|
+
wrappedOnNodesUpdate,
|
|
15973
|
+
wrappedOnNodeDelete,
|
|
15974
|
+
wrappedOnNodesDelete,
|
|
15975
|
+
wrappedOnEdgeAdd,
|
|
15976
|
+
wrappedOnEdgeUpdate,
|
|
15977
|
+
wrappedOnEdgeDelete,
|
|
15978
|
+
beginBatch,
|
|
15979
|
+
endBatch,
|
|
15980
|
+
undo,
|
|
15981
|
+
redo,
|
|
15982
|
+
canUndo,
|
|
15983
|
+
canRedo
|
|
15984
|
+
};
|
|
15985
|
+
}
|
|
15986
|
+
|
|
15450
15987
|
// ../react/dist/hooks/useZoomNavigation.js
|
|
15451
|
-
var
|
|
15988
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
15452
15989
|
function expandRect(rect, factor) {
|
|
15453
15990
|
if (factor === 1)
|
|
15454
15991
|
return rect;
|
|
@@ -15486,16 +16023,16 @@ var SystemCanvas = (() => {
|
|
|
15486
16023
|
}
|
|
15487
16024
|
function useZoomNavigation(options) {
|
|
15488
16025
|
const { enabled, config, nodes, currentCanvas, parentFrame, canvases, onResolveCanvas, onSeedCanvas, theme, getViewportSize, getCursorScreenPos, onEnter, onExit } = options;
|
|
15489
|
-
const committingRef = (0,
|
|
15490
|
-
(0,
|
|
16026
|
+
const committingRef = (0, import_react10.useRef)(false);
|
|
16027
|
+
(0, import_react10.useEffect)(() => {
|
|
15491
16028
|
committingRef.current = false;
|
|
15492
16029
|
}, [currentCanvas]);
|
|
15493
|
-
const exitArmedRef = (0,
|
|
15494
|
-
(0,
|
|
16030
|
+
const exitArmedRef = (0, import_react10.useRef)(false);
|
|
16031
|
+
(0, import_react10.useEffect)(() => {
|
|
15495
16032
|
exitArmedRef.current = false;
|
|
15496
16033
|
}, [currentCanvas, parentFrame]);
|
|
15497
|
-
const prefetchRef = (0,
|
|
15498
|
-
const prefetch = (0,
|
|
16034
|
+
const prefetchRef = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
16035
|
+
const prefetch = (0, import_react10.useCallback)((ref) => {
|
|
15499
16036
|
if (!onResolveCanvas)
|
|
15500
16037
|
return;
|
|
15501
16038
|
if (canvases?.[ref])
|
|
@@ -15513,7 +16050,7 @@ var SystemCanvas = (() => {
|
|
|
15513
16050
|
state.loading = false;
|
|
15514
16051
|
});
|
|
15515
16052
|
}, [canvases, onResolveCanvas, onSeedCanvas]);
|
|
15516
|
-
const handleViewportChange = (0,
|
|
16053
|
+
const handleViewportChange = (0, import_react10.useCallback)((vp) => {
|
|
15517
16054
|
if (!enabled)
|
|
15518
16055
|
return;
|
|
15519
16056
|
if (committingRef.current)
|
|
@@ -15652,7 +16189,7 @@ var SystemCanvas = (() => {
|
|
|
15652
16189
|
onEnter,
|
|
15653
16190
|
onExit
|
|
15654
16191
|
]);
|
|
15655
|
-
const clearCommitting = (0,
|
|
16192
|
+
const clearCommitting = (0, import_react10.useCallback)(() => {
|
|
15656
16193
|
committingRef.current = false;
|
|
15657
16194
|
}, []);
|
|
15658
16195
|
return { handleViewportChange, clearCommitting };
|
|
@@ -15660,10 +16197,10 @@ var SystemCanvas = (() => {
|
|
|
15660
16197
|
|
|
15661
16198
|
// ../react/dist/components/Viewport.js
|
|
15662
16199
|
var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
|
|
15663
|
-
var
|
|
16200
|
+
var import_react19 = __toESM(require_react(), 1);
|
|
15664
16201
|
|
|
15665
16202
|
// ../react/dist/hooks/useViewport.js
|
|
15666
|
-
var
|
|
16203
|
+
var import_react11 = __toESM(require_react(), 1);
|
|
15667
16204
|
|
|
15668
16205
|
// ../../node_modules/d3-dispatch/src/dispatch.js
|
|
15669
16206
|
var noop = { value: () => {
|
|
@@ -18406,13 +18943,13 @@ var SystemCanvas = (() => {
|
|
|
18406
18943
|
// ../react/dist/hooks/useViewport.js
|
|
18407
18944
|
function useViewport(options) {
|
|
18408
18945
|
const { minZoom, maxZoom, defaultViewport, onViewportChange, marqueeActiveRef } = options;
|
|
18409
|
-
const svgRef = (0,
|
|
18410
|
-
const groupRef = (0,
|
|
18411
|
-
const viewport = (0,
|
|
18412
|
-
const zoomBehaviorRef = (0,
|
|
18413
|
-
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);
|
|
18414
18951
|
onViewportChangeRef.current = onViewportChange;
|
|
18415
|
-
(0,
|
|
18952
|
+
(0, import_react11.useEffect)(() => {
|
|
18416
18953
|
const svg = svgRef.current;
|
|
18417
18954
|
const group = groupRef.current;
|
|
18418
18955
|
if (!svg || !group)
|
|
@@ -18452,7 +18989,7 @@ var SystemCanvas = (() => {
|
|
|
18452
18989
|
selection2.on(".zoom", null);
|
|
18453
18990
|
};
|
|
18454
18991
|
}, [minZoom, maxZoom]);
|
|
18455
|
-
const fitToContent = (0,
|
|
18992
|
+
const fitToContent = (0, import_react11.useCallback)((nodes, animate = true) => {
|
|
18456
18993
|
const svg = svgRef.current;
|
|
18457
18994
|
if (!svg || !zoomBehaviorRef.current || nodes.length === 0)
|
|
18458
18995
|
return;
|
|
@@ -18465,13 +19002,13 @@ var SystemCanvas = (() => {
|
|
|
18465
19002
|
select_default2(svg).call(zoomBehaviorRef.current.transform, t);
|
|
18466
19003
|
}
|
|
18467
19004
|
}, []);
|
|
18468
|
-
const resetZoom = (0,
|
|
19005
|
+
const resetZoom = (0, import_react11.useCallback)(() => {
|
|
18469
19006
|
const svg = svgRef.current;
|
|
18470
19007
|
if (!svg || !zoomBehaviorRef.current)
|
|
18471
19008
|
return;
|
|
18472
19009
|
select_default2(svg).transition().duration(400).call(zoomBehaviorRef.current.transform, identity2);
|
|
18473
19010
|
}, []);
|
|
18474
|
-
const setTransform = (0,
|
|
19011
|
+
const setTransform = (0, import_react11.useCallback)((transform2, options2) => {
|
|
18475
19012
|
const svg = svgRef.current;
|
|
18476
19013
|
if (!svg || !zoomBehaviorRef.current)
|
|
18477
19014
|
return;
|
|
@@ -18483,7 +19020,7 @@ var SystemCanvas = (() => {
|
|
|
18483
19020
|
sel.call(zoomBehaviorRef.current.transform, t);
|
|
18484
19021
|
}
|
|
18485
19022
|
}, []);
|
|
18486
|
-
const zoomToNode = (0,
|
|
19023
|
+
const zoomToNode = (0, import_react11.useCallback)((node, onComplete, options2) => {
|
|
18487
19024
|
const svg = svgRef.current;
|
|
18488
19025
|
if (!svg || !zoomBehaviorRef.current) {
|
|
18489
19026
|
onComplete?.();
|
|
@@ -18677,9 +19214,9 @@ var SystemCanvas = (() => {
|
|
|
18677
19214
|
|
|
18678
19215
|
// ../react/dist/components/RefIndicator.js
|
|
18679
19216
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
18680
|
-
var
|
|
19217
|
+
var import_react12 = __toESM(require_react(), 1);
|
|
18681
19218
|
function RefIndicator({ node, theme, nodeX, nodeY, nodeWidth, nodeHeight, strokeColor, strokeWidth, corner = "bottom-right", size: sizeProp, onNavigate }) {
|
|
18682
|
-
const [hover, setHover] = (0,
|
|
19219
|
+
const [hover, setHover] = (0, import_react12.useState)(false);
|
|
18683
19220
|
const iconKind = theme.node.refIndicator.icon;
|
|
18684
19221
|
if (iconKind === "none")
|
|
18685
19222
|
return null;
|
|
@@ -18750,7 +19287,7 @@ var SystemCanvas = (() => {
|
|
|
18750
19287
|
|
|
18751
19288
|
// ../react/dist/components/CategorySlotsLayer.js
|
|
18752
19289
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
18753
|
-
var
|
|
19290
|
+
var import_react14 = __toESM(require_react(), 1);
|
|
18754
19291
|
|
|
18755
19292
|
// ../react/dist/primitives/NodeColorFill.js
|
|
18756
19293
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -18870,9 +19407,9 @@ var SystemCanvas = (() => {
|
|
|
18870
19407
|
|
|
18871
19408
|
// ../react/dist/primitives/NodeText.js
|
|
18872
19409
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
18873
|
-
var
|
|
19410
|
+
var import_react13 = __toESM(require_react(), 1);
|
|
18874
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" }) {
|
|
18875
|
-
const reactId = (0,
|
|
19412
|
+
const reactId = (0, import_react13.useId)();
|
|
18876
19413
|
const safeId = reactId.replace(/:/g, "");
|
|
18877
19414
|
if (!value)
|
|
18878
19415
|
return null;
|
|
@@ -18946,8 +19483,8 @@ var SystemCanvas = (() => {
|
|
|
18946
19483
|
// ../react/dist/components/CategorySlotsLayer.js
|
|
18947
19484
|
function CategorySlotsLayer({ node, theme, canvases, slots: slotsProp }) {
|
|
18948
19485
|
const slots = slotsProp ?? getCategorySlots(node, theme);
|
|
18949
|
-
const regions = (0,
|
|
18950
|
-
const reactId = (0,
|
|
19486
|
+
const regions = (0, import_react14.useMemo)(() => computeCategorySlotRegions(node, theme, slots), [node, theme, slots]);
|
|
19487
|
+
const reactId = (0, import_react14.useId)();
|
|
18951
19488
|
const clipId = `sc-edge-clip-${reactId.replace(/:/g, "")}`;
|
|
18952
19489
|
if (!slots)
|
|
18953
19490
|
return null;
|
|
@@ -19180,7 +19717,7 @@ var SystemCanvas = (() => {
|
|
|
19180
19717
|
|
|
19181
19718
|
// ../react/dist/components/ResizeHandles.js
|
|
19182
19719
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
19183
|
-
var
|
|
19720
|
+
var import_react15 = __toESM(require_react(), 1);
|
|
19184
19721
|
var HANDLE_SIZE = 7;
|
|
19185
19722
|
var CORNERS = [
|
|
19186
19723
|
{ corner: "nw", cursor: "nwse-resize", anchor: "nw" },
|
|
@@ -19191,7 +19728,7 @@ var SystemCanvas = (() => {
|
|
|
19191
19728
|
var cornerInset = (cornerRadius) => Math.min(cornerRadius * 0.25, 3);
|
|
19192
19729
|
function ResizeHandles({ node, theme, onHandlePointerDown }) {
|
|
19193
19730
|
const { x, y, width, height } = node;
|
|
19194
|
-
const [hoveredCorner, setHoveredCorner] = (0,
|
|
19731
|
+
const [hoveredCorner, setHoveredCorner] = (0, import_react15.useState)(null);
|
|
19195
19732
|
const handleColor = node.resolvedStroke ?? theme.node.labelColor;
|
|
19196
19733
|
const i = cornerInset(node.resolvedCornerRadius);
|
|
19197
19734
|
const anchorPos = (anchor) => {
|
|
@@ -19302,7 +19839,7 @@ var SystemCanvas = (() => {
|
|
|
19302
19839
|
|
|
19303
19840
|
// ../react/dist/components/NodeEditor.js
|
|
19304
19841
|
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
|
|
19305
|
-
var
|
|
19842
|
+
var import_react16 = __toESM(require_react(), 1);
|
|
19306
19843
|
function NodeEditor({ node, theme, onCommit, onCancel }) {
|
|
19307
19844
|
const editableFields = useCategoryFields(node, theme);
|
|
19308
19845
|
if (editableFields) {
|
|
@@ -19321,11 +19858,11 @@ var SystemCanvas = (() => {
|
|
|
19321
19858
|
}
|
|
19322
19859
|
function SingleFieldEditor({ node, theme, onCommit, onCancel }) {
|
|
19323
19860
|
const initial = getInitialValue(node);
|
|
19324
|
-
const [value, setValue] = (0,
|
|
19325
|
-
const textareaRef = (0,
|
|
19326
|
-
const inputRef = (0,
|
|
19327
|
-
const committedRef = (0,
|
|
19328
|
-
(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)(() => {
|
|
19329
19866
|
const el = textareaRef.current ?? inputRef.current;
|
|
19330
19867
|
if (el) {
|
|
19331
19868
|
el.focus();
|
|
@@ -19421,10 +19958,10 @@ var SystemCanvas = (() => {
|
|
|
19421
19958
|
}
|
|
19422
19959
|
}
|
|
19423
19960
|
function FormEditor({ node, theme, fields, onCommit, onCancel }) {
|
|
19424
|
-
const initial = (0,
|
|
19425
|
-
const [values, setValues] = (0,
|
|
19426
|
-
const committedRef = (0,
|
|
19427
|
-
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);
|
|
19428
19965
|
const width = Math.max(node.width, 240);
|
|
19429
19966
|
const height = Math.max(node.height, 36 + fields.length * 44);
|
|
19430
19967
|
const commit = () => {
|
|
@@ -19453,7 +19990,7 @@ var SystemCanvas = (() => {
|
|
|
19453
19990
|
const stopPointer = (e) => {
|
|
19454
19991
|
e.stopPropagation();
|
|
19455
19992
|
};
|
|
19456
|
-
(0,
|
|
19993
|
+
(0, import_react16.useEffect)(() => {
|
|
19457
19994
|
const el = panelRef.current;
|
|
19458
19995
|
if (!el)
|
|
19459
19996
|
return;
|
|
@@ -19583,13 +20120,13 @@ var SystemCanvas = (() => {
|
|
|
19583
20120
|
|
|
19584
20121
|
// ../react/dist/components/EdgeLabelEditor.js
|
|
19585
20122
|
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
|
|
19586
|
-
var
|
|
20123
|
+
var import_react17 = __toESM(require_react(), 1);
|
|
19587
20124
|
var EDITOR_WIDTH = 110;
|
|
19588
20125
|
function EdgeLabelEditor({ initialLabel, midpoint, theme, onCommit, onCancel }) {
|
|
19589
|
-
const [value, setValue] = (0,
|
|
19590
|
-
const inputRef = (0,
|
|
19591
|
-
const committedRef = (0,
|
|
19592
|
-
(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)(() => {
|
|
19593
20130
|
const el = inputRef.current;
|
|
19594
20131
|
if (el) {
|
|
19595
20132
|
el.focus();
|
|
@@ -19644,7 +20181,7 @@ var SystemCanvas = (() => {
|
|
|
19644
20181
|
|
|
19645
20182
|
// ../react/dist/components/ConnectionHandles.js
|
|
19646
20183
|
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
|
|
19647
|
-
var
|
|
20184
|
+
var import_react18 = __toESM(require_react(), 1);
|
|
19648
20185
|
var SIDES = ["top", "right", "bottom", "left"];
|
|
19649
20186
|
var HANDLE_RADIUS = 4;
|
|
19650
20187
|
var HANDLE_HIT_RADIUS = 10;
|
|
@@ -19653,9 +20190,9 @@ var SystemCanvas = (() => {
|
|
|
19653
20190
|
var HOVER_SCALE = 1.42;
|
|
19654
20191
|
var HOVER_TRANSITION_MS = 120;
|
|
19655
20192
|
function ConnectionHandles({ node, theme, onHandlePointerDown, immediate, activeSide }) {
|
|
19656
|
-
const [visible, setVisible] = (0,
|
|
19657
|
-
const [hoveredSide, setHoveredSide] = (0,
|
|
19658
|
-
(0,
|
|
20193
|
+
const [visible, setVisible] = (0, import_react18.useState)(!!immediate);
|
|
20194
|
+
const [hoveredSide, setHoveredSide] = (0, import_react18.useState)(null);
|
|
20195
|
+
(0, import_react18.useEffect)(() => {
|
|
19659
20196
|
if (immediate) {
|
|
19660
20197
|
setVisible(true);
|
|
19661
20198
|
return;
|
|
@@ -19742,7 +20279,7 @@ var SystemCanvas = (() => {
|
|
|
19742
20279
|
// ../react/dist/components/Viewport.js
|
|
19743
20280
|
var HOVER_PADDING = 10;
|
|
19744
20281
|
var EDGE_PROXIMITY = 16;
|
|
19745
|
-
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) {
|
|
19746
20283
|
const { svgRef, groupRef, viewport, fitToContent, zoomToNode, setTransform } = useViewport({
|
|
19747
20284
|
minZoom,
|
|
19748
20285
|
maxZoom,
|
|
@@ -19750,10 +20287,10 @@ var SystemCanvas = (() => {
|
|
|
19750
20287
|
onViewportChange,
|
|
19751
20288
|
marqueeActiveRef
|
|
19752
20289
|
});
|
|
19753
|
-
const navigatingRef = (0,
|
|
19754
|
-
const fadeRafRef = (0,
|
|
19755
|
-
const fadeTimeoutRef = (0,
|
|
19756
|
-
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) => {
|
|
19757
20294
|
if (durationMs <= 0)
|
|
19758
20295
|
return;
|
|
19759
20296
|
const g = groupRef.current;
|
|
@@ -19776,7 +20313,7 @@ var SystemCanvas = (() => {
|
|
|
19776
20313
|
}, durationMs + 16);
|
|
19777
20314
|
});
|
|
19778
20315
|
}, []);
|
|
19779
|
-
(0,
|
|
20316
|
+
(0, import_react19.useEffect)(() => {
|
|
19780
20317
|
return () => {
|
|
19781
20318
|
if (fadeRafRef.current !== null)
|
|
19782
20319
|
cancelAnimationFrame(fadeRafRef.current);
|
|
@@ -19784,10 +20321,10 @@ var SystemCanvas = (() => {
|
|
|
19784
20321
|
clearTimeout(fadeTimeoutRef.current);
|
|
19785
20322
|
};
|
|
19786
20323
|
}, []);
|
|
19787
|
-
const [hoveredNodeId, setHoveredNodeId] = (0,
|
|
19788
|
-
const [hoveredSide, setHoveredSide] = (0,
|
|
19789
|
-
const cursorPosRef = (0,
|
|
19790
|
-
(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, () => ({
|
|
19791
20328
|
zoomToNode: (node, onComplete, options) => {
|
|
19792
20329
|
navigatingRef.current = true;
|
|
19793
20330
|
zoomToNode(node, onComplete, options);
|
|
@@ -19798,7 +20335,7 @@ var SystemCanvas = (() => {
|
|
|
19798
20335
|
getViewport: () => viewport.current ?? { x: 0, y: 0, zoom: 1 },
|
|
19799
20336
|
getCursorScreenPos: () => cursorPosRef.current
|
|
19800
20337
|
}));
|
|
19801
|
-
const renderNodes = (0,
|
|
20338
|
+
const renderNodes = (0, import_react19.useMemo)(() => {
|
|
19802
20339
|
const hasDrag = dragOverrides && dragOverrides.size > 0;
|
|
19803
20340
|
const hasResize = resizeOverrides && resizeOverrides.size > 0;
|
|
19804
20341
|
if (!hasDrag && !hasResize)
|
|
@@ -19811,7 +20348,7 @@ var SystemCanvas = (() => {
|
|
|
19811
20348
|
return d ? { ...n, x: d.x, y: d.y } : n;
|
|
19812
20349
|
});
|
|
19813
20350
|
}, [nodes, dragOverrides, resizeOverrides]);
|
|
19814
|
-
const renderNodeMap = (0,
|
|
20351
|
+
const renderNodeMap = (0, import_react19.useMemo)(() => {
|
|
19815
20352
|
const hasDrag = dragOverrides && dragOverrides.size > 0;
|
|
19816
20353
|
const hasResize = resizeOverrides && resizeOverrides.size > 0;
|
|
19817
20354
|
if (!hasDrag && !hasResize)
|
|
@@ -19822,11 +20359,11 @@ var SystemCanvas = (() => {
|
|
|
19822
20359
|
}
|
|
19823
20360
|
return m;
|
|
19824
20361
|
}, [renderNodes, nodeMap, dragOverrides, resizeOverrides]);
|
|
19825
|
-
const latestNodesRef = (0,
|
|
19826
|
-
(0,
|
|
20362
|
+
const latestNodesRef = (0, import_react19.useRef)(nodes);
|
|
20363
|
+
(0, import_react19.useEffect)(() => {
|
|
19827
20364
|
latestNodesRef.current = nodes;
|
|
19828
20365
|
}, [nodes]);
|
|
19829
|
-
const fitNow = (0,
|
|
20366
|
+
const fitNow = (0, import_react19.useCallback)(() => {
|
|
19830
20367
|
const current = latestNodesRef.current;
|
|
19831
20368
|
if (current.length === 0)
|
|
19832
20369
|
return;
|
|
@@ -19836,7 +20373,7 @@ var SystemCanvas = (() => {
|
|
|
19836
20373
|
fitToContent(current, animate);
|
|
19837
20374
|
});
|
|
19838
20375
|
}, [fitToContent]);
|
|
19839
|
-
(0,
|
|
20376
|
+
(0, import_react19.useEffect)(() => {
|
|
19840
20377
|
if (defaultViewport)
|
|
19841
20378
|
return;
|
|
19842
20379
|
if (autoFit !== "always")
|
|
@@ -19845,8 +20382,8 @@ var SystemCanvas = (() => {
|
|
|
19845
20382
|
return;
|
|
19846
20383
|
fitNow();
|
|
19847
20384
|
}, [nodes, autoFit, defaultViewport, fitNow]);
|
|
19848
|
-
const fittedForRef = (0,
|
|
19849
|
-
(0,
|
|
20385
|
+
const fittedForRef = (0, import_react19.useRef)(null);
|
|
20386
|
+
(0, import_react19.useEffect)(() => {
|
|
19850
20387
|
if (defaultViewport)
|
|
19851
20388
|
return;
|
|
19852
20389
|
if (autoFit !== "canvas-change" && autoFit !== "initial")
|
|
@@ -19878,7 +20415,7 @@ var SystemCanvas = (() => {
|
|
|
19878
20415
|
triggerFade
|
|
19879
20416
|
]);
|
|
19880
20417
|
const editingNode = editingId ? renderNodes.find((n) => n.id === editingId) ?? null : null;
|
|
19881
|
-
const handleSvgPointerMove = (0,
|
|
20418
|
+
const handleSvgPointerMove = (0, import_react19.useCallback)((event) => {
|
|
19882
20419
|
const svg = svgRef.current;
|
|
19883
20420
|
if (!svg)
|
|
19884
20421
|
return;
|
|
@@ -19930,7 +20467,7 @@ var SystemCanvas = (() => {
|
|
|
19930
20467
|
setHoveredSide((prev) => prev === null ? prev : null);
|
|
19931
20468
|
}
|
|
19932
20469
|
}, [edgeCreateEnabled, renderNodes, svgRef, viewport]);
|
|
19933
|
-
const handleSvgPointerLeave = (0,
|
|
20470
|
+
const handleSvgPointerLeave = (0, import_react19.useCallback)(() => {
|
|
19934
20471
|
setHoveredNodeId(null);
|
|
19935
20472
|
setHoveredSide(null);
|
|
19936
20473
|
cursorPosRef.current = null;
|
|
@@ -19969,7 +20506,7 @@ var SystemCanvas = (() => {
|
|
|
19969
20506
|
|
|
19970
20507
|
// ../react/dist/components/Breadcrumbs.js
|
|
19971
20508
|
var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
|
|
19972
|
-
var
|
|
20509
|
+
var import_react20 = __toESM(require_react(), 1);
|
|
19973
20510
|
function Breadcrumbs({ breadcrumbs, theme, onNavigate }) {
|
|
19974
20511
|
if (breadcrumbs.length <= 1)
|
|
19975
20512
|
return null;
|
|
@@ -19990,7 +20527,7 @@ var SystemCanvas = (() => {
|
|
|
19990
20527
|
backdropFilter: "blur(8px)"
|
|
19991
20528
|
}, children: breadcrumbs.map((crumb, index) => {
|
|
19992
20529
|
const isLast = index === breadcrumbs.length - 1;
|
|
19993
|
-
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: {
|
|
19994
20531
|
color: theme.separatorColor,
|
|
19995
20532
|
margin: "0 2px"
|
|
19996
20533
|
}, children: "/" }), (0, import_jsx_runtime23.jsx)("span", { onClick: isLast ? void 0 : () => onNavigate(index), style: {
|
|
@@ -20014,11 +20551,11 @@ var SystemCanvas = (() => {
|
|
|
20014
20551
|
|
|
20015
20552
|
// ../react/dist/components/AddNodeButton.js
|
|
20016
20553
|
var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
|
|
20017
|
-
var
|
|
20554
|
+
var import_react21 = __toESM(require_react(), 1);
|
|
20018
20555
|
function AddNodeButton({ options, addNode: addNode2, theme }) {
|
|
20019
|
-
const [open, setOpen] = (0,
|
|
20020
|
-
const rootRef = (0,
|
|
20021
|
-
(0,
|
|
20556
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
20557
|
+
const rootRef = (0, import_react21.useRef)(null);
|
|
20558
|
+
(0, import_react21.useEffect)(() => {
|
|
20022
20559
|
if (!open)
|
|
20023
20560
|
return;
|
|
20024
20561
|
function onDocClick(e) {
|
|
@@ -20107,7 +20644,7 @@ var SystemCanvas = (() => {
|
|
|
20107
20644
|
} });
|
|
20108
20645
|
}
|
|
20109
20646
|
function MenuRow({ theme, option, onClick }) {
|
|
20110
|
-
const [hover, setHover] = (0,
|
|
20647
|
+
const [hover, setHover] = (0, import_react21.useState)(false);
|
|
20111
20648
|
const swatchSize = 18;
|
|
20112
20649
|
return (0, import_jsx_runtime24.jsxs)("div", { role: "button", onClick, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), style: {
|
|
20113
20650
|
display: "flex",
|
|
@@ -20143,12 +20680,12 @@ var SystemCanvas = (() => {
|
|
|
20143
20680
|
|
|
20144
20681
|
// ../react/dist/components/LaneHeaders.js
|
|
20145
20682
|
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
|
|
20146
|
-
var
|
|
20683
|
+
var import_react22 = __toESM(require_react(), 1);
|
|
20147
20684
|
function LaneHeaders({ columns, rows, theme, getViewport, width, height, pinned = true }) {
|
|
20148
20685
|
const hasColumns = columns && columns.length > 0;
|
|
20149
20686
|
const hasRows = rows && rows.length > 0;
|
|
20150
|
-
const [viewport, setViewport] = (0,
|
|
20151
|
-
(0,
|
|
20687
|
+
const [viewport, setViewport] = (0, import_react22.useState)(() => getViewport());
|
|
20688
|
+
(0, import_react22.useEffect)(() => {
|
|
20152
20689
|
if (!hasColumns && !hasRows)
|
|
20153
20690
|
return;
|
|
20154
20691
|
let raf = 0;
|
|
@@ -20222,7 +20759,7 @@ var SystemCanvas = (() => {
|
|
|
20222
20759
|
|
|
20223
20760
|
// ../react/dist/components/NodeToolbar.js
|
|
20224
20761
|
var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
|
|
20225
|
-
var
|
|
20762
|
+
var import_react23 = __toESM(require_react(), 1);
|
|
20226
20763
|
var NODE_GAP = 10;
|
|
20227
20764
|
var FLIP_MARGIN = 8;
|
|
20228
20765
|
var PADDING = 6;
|
|
@@ -20231,8 +20768,8 @@ var SystemCanvas = (() => {
|
|
|
20231
20768
|
var BUTTON_SIZE = 28;
|
|
20232
20769
|
var DELETE_SIZE = 14;
|
|
20233
20770
|
function NodeToolbar({ node, theme, onPatch, onDelete, getViewport, containerWidth, containerHeight, render: render2, selectedNodes, onMultiPatch }) {
|
|
20234
|
-
const [viewport, setViewport] = (0,
|
|
20235
|
-
(0,
|
|
20771
|
+
const [viewport, setViewport] = (0, import_react23.useState)(() => getViewport());
|
|
20772
|
+
(0, import_react23.useEffect)(() => {
|
|
20236
20773
|
let raf = 0;
|
|
20237
20774
|
let lastX = -Infinity;
|
|
20238
20775
|
let lastY = -Infinity;
|
|
@@ -20252,7 +20789,7 @@ var SystemCanvas = (() => {
|
|
|
20252
20789
|
}, [getViewport]);
|
|
20253
20790
|
const isMulti = selectedNodes != null && selectedNodes.length > 1;
|
|
20254
20791
|
const align = theme.toolbarAlign ?? "center";
|
|
20255
|
-
const { anchorTopY, anchorBottomY, anchorX } = (0,
|
|
20792
|
+
const { anchorTopY, anchorBottomY, anchorX } = (0, import_react23.useMemo)(() => {
|
|
20256
20793
|
if (isMulti && selectedNodes) {
|
|
20257
20794
|
const minX = Math.min(...selectedNodes.map((n) => n.x));
|
|
20258
20795
|
const maxX = Math.max(...selectedNodes.map((n) => n.x + n.width));
|
|
@@ -20269,9 +20806,9 @@ var SystemCanvas = (() => {
|
|
|
20269
20806
|
}, [isMulti, selectedNodes, align, node]);
|
|
20270
20807
|
const topAnchor = canvasToScreen(anchorX, anchorTopY, viewport);
|
|
20271
20808
|
const bottomAnchor = canvasToScreen(anchorX, anchorBottomY, viewport);
|
|
20272
|
-
const toolbarRef = (0,
|
|
20273
|
-
const [size, setSize] = (0,
|
|
20274
|
-
(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)(() => {
|
|
20275
20812
|
const el = toolbarRef.current;
|
|
20276
20813
|
if (!el)
|
|
20277
20814
|
return;
|
|
@@ -20331,7 +20868,7 @@ var SystemCanvas = (() => {
|
|
|
20331
20868
|
}
|
|
20332
20869
|
function MultiToolbarContent({ selectedNodes, theme, onMultiPatch, onDelete }) {
|
|
20333
20870
|
const representativeNode = selectedNodes[0];
|
|
20334
|
-
const groups = (0,
|
|
20871
|
+
const groups = (0, import_react23.useMemo)(() => getNodeActionsForNode(representativeNode, theme), [representativeNode, theme]);
|
|
20335
20872
|
const showDelete = theme.showToolbarDelete === true;
|
|
20336
20873
|
const swatchGroups = groups.filter((g) => g.kind === "swatches" || g.kind == null);
|
|
20337
20874
|
const otherGroups = groups.filter((g) => g.kind !== "swatches" && g.kind != null && g.kind !== "menu");
|
|
@@ -20345,7 +20882,7 @@ var SystemCanvas = (() => {
|
|
|
20345
20882
|
const actions = filterActionsForNode(group, representativeNode);
|
|
20346
20883
|
if (actions.length === 0)
|
|
20347
20884
|
return null;
|
|
20348
|
-
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) => {
|
|
20349
20886
|
const active = action.isActive?.(representativeNode) ?? false;
|
|
20350
20887
|
const handleClick = () => {
|
|
20351
20888
|
const patch = resolveActionPatch(action, representativeNode);
|
|
@@ -20357,7 +20894,7 @@ var SystemCanvas = (() => {
|
|
|
20357
20894
|
const actions = filterActionsForNode(group, representativeNode);
|
|
20358
20895
|
if (actions.length === 0)
|
|
20359
20896
|
return null;
|
|
20360
|
-
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) => {
|
|
20361
20898
|
const active = action.isActive?.(representativeNode) ?? false;
|
|
20362
20899
|
const handleClick = () => {
|
|
20363
20900
|
const patch = resolveActionPatch(action, representativeNode);
|
|
@@ -20368,9 +20905,9 @@ var SystemCanvas = (() => {
|
|
|
20368
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 })] })] });
|
|
20369
20906
|
}
|
|
20370
20907
|
function DefaultToolbarContent({ node, theme, onPatch, onDelete }) {
|
|
20371
|
-
const groups = (0,
|
|
20908
|
+
const groups = (0, import_react23.useMemo)(() => getNodeActionsForNode(node, theme), [node, theme]);
|
|
20372
20909
|
const showDelete = theme.showToolbarDelete === true;
|
|
20373
|
-
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 })] })] });
|
|
20374
20911
|
}
|
|
20375
20912
|
function Divider2({ theme }) {
|
|
20376
20913
|
return (0, import_jsx_runtime26.jsx)("div", { style: {
|
|
@@ -20437,9 +20974,9 @@ var SystemCanvas = (() => {
|
|
|
20437
20974
|
} }) : (0, import_jsx_runtime26.jsx)("span", { style: { fontSize: 10 }, children: action.label.slice(0, 2) }) });
|
|
20438
20975
|
}
|
|
20439
20976
|
function MenuGroup({ group, actions, node, theme, onPatch }) {
|
|
20440
|
-
const [open, setOpen] = (0,
|
|
20441
|
-
const wrapRef = (0,
|
|
20442
|
-
(0,
|
|
20977
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
20978
|
+
const wrapRef = (0, import_react23.useRef)(null);
|
|
20979
|
+
(0, import_react23.useEffect)(() => {
|
|
20443
20980
|
if (!open)
|
|
20444
20981
|
return;
|
|
20445
20982
|
const onDown = (e) => {
|
|
@@ -20526,18 +21063,18 @@ var SystemCanvas = (() => {
|
|
|
20526
21063
|
|
|
20527
21064
|
// ../react/dist/components/NodeContextMenuOverlay.js
|
|
20528
21065
|
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
|
|
20529
|
-
var
|
|
21066
|
+
var import_react24 = __toESM(require_react(), 1);
|
|
20530
21067
|
var ESTIMATED_MENU_WIDTH = 200;
|
|
20531
21068
|
var MIN_MENU_WIDTH = 160;
|
|
20532
21069
|
var VIEWPORT_MARGIN = 8;
|
|
20533
21070
|
function NodeContextMenuOverlay({ state, config, theme, onClose }) {
|
|
20534
|
-
const rootRef = (0,
|
|
20535
|
-
const [hoveredId, setHoveredId] = (0,
|
|
20536
|
-
(0,
|
|
21071
|
+
const rootRef = (0, import_react24.useRef)(null);
|
|
21072
|
+
const [hoveredId, setHoveredId] = (0, import_react24.useState)(null);
|
|
21073
|
+
(0, import_react24.useEffect)(() => {
|
|
20537
21074
|
if (state)
|
|
20538
21075
|
setHoveredId(null);
|
|
20539
21076
|
}, [state]);
|
|
20540
|
-
(0,
|
|
21077
|
+
(0, import_react24.useEffect)(() => {
|
|
20541
21078
|
if (!state)
|
|
20542
21079
|
return;
|
|
20543
21080
|
function onDown(e) {
|
|
@@ -20645,8 +21182,8 @@ var SystemCanvas = (() => {
|
|
|
20645
21182
|
// ../react/dist/components/SystemCanvas.js
|
|
20646
21183
|
var CASCADE_WINDOW_MS = 1500;
|
|
20647
21184
|
var CASCADE_OFFSET = 20;
|
|
20648
|
-
var SystemCanvas = (0,
|
|
20649
|
-
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)(() => {
|
|
20650
21187
|
const defaults = {
|
|
20651
21188
|
enterThreshold: 0.66,
|
|
20652
21189
|
exitThreshold: 0.33,
|
|
@@ -20671,16 +21208,16 @@ var SystemCanvas = (() => {
|
|
|
20671
21208
|
}, [zoomNavigation]);
|
|
20672
21209
|
const effectiveMaxZoom = maxZoom ?? (zoomNavConfig.enabled ? 16 : 4);
|
|
20673
21210
|
const effectiveMinZoom = minZoomProp ?? (zoomNavConfig.enabled ? 0.01 : 0.1);
|
|
20674
|
-
(0,
|
|
21211
|
+
(0, import_react25.useEffect)(() => {
|
|
20675
21212
|
const env = globalThis.process?.env?.NODE_ENV;
|
|
20676
21213
|
if (editable && !canvases && env !== "production") {
|
|
20677
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.");
|
|
20678
21215
|
}
|
|
20679
21216
|
}, [editable, canvases]);
|
|
20680
|
-
const [parentFrames, setParentFrames] = (0,
|
|
20681
|
-
const [pendingHandoff, setPendingHandoff] = (0,
|
|
20682
|
-
const suppressNextHandoffClearRef = (0,
|
|
20683
|
-
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) => {
|
|
20684
21221
|
setParentFrames((prev) => prev.slice(0, index));
|
|
20685
21222
|
if (suppressNextHandoffClearRef.current) {
|
|
20686
21223
|
suppressNextHandoffClearRef.current = false;
|
|
@@ -20697,10 +21234,10 @@ var SystemCanvas = (() => {
|
|
|
20697
21234
|
onNavigate,
|
|
20698
21235
|
onBreadcrumbClick: handleBreadcrumbClick
|
|
20699
21236
|
});
|
|
20700
|
-
(0,
|
|
21237
|
+
(0, import_react25.useEffect)(() => {
|
|
20701
21238
|
onBreadcrumbsChange?.(breadcrumbs);
|
|
20702
21239
|
}, [breadcrumbs, onBreadcrumbsChange]);
|
|
20703
|
-
const theme = (0,
|
|
21240
|
+
const theme = (0, import_react25.useMemo)(() => {
|
|
20704
21241
|
const registry = { ...themes, ...customThemes };
|
|
20705
21242
|
const resolveByName = (name) => name && registry[name] ? registry[name] : null;
|
|
20706
21243
|
if (themeProp) {
|
|
@@ -20711,22 +21248,22 @@ var SystemCanvas = (() => {
|
|
|
20711
21248
|
}
|
|
20712
21249
|
return resolveByName(currentCanvas.theme?.base) ?? resolveByName(canvas.theme?.base) ?? darkTheme;
|
|
20713
21250
|
}, [themeProp, customThemes, currentCanvas.theme?.base, canvas.theme?.base]);
|
|
20714
|
-
const { nodes, edges, nodeMap } = (0,
|
|
21251
|
+
const { nodes, edges, nodeMap } = (0, import_react25.useMemo)(() => {
|
|
20715
21252
|
const resolved = resolveCanvas(currentCanvas, theme);
|
|
20716
21253
|
const map = buildNodeMap(resolved.nodes);
|
|
20717
21254
|
return { nodes: resolved.nodes, edges: resolved.edges, nodeMap: map };
|
|
20718
21255
|
}, [currentCanvas, theme]);
|
|
20719
|
-
const nodesRef = (0,
|
|
21256
|
+
const nodesRef = (0, import_react25.useRef)(nodes);
|
|
20720
21257
|
nodesRef.current = nodes;
|
|
20721
|
-
const viewportStateRef = (0,
|
|
20722
|
-
const viewportHandleRef = (0,
|
|
20723
|
-
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);
|
|
20724
21261
|
navigateToRefRef.current = navigateToRef;
|
|
20725
|
-
const navigateToBreadcrumbRef = (0,
|
|
21262
|
+
const navigateToBreadcrumbRef = (0, import_react25.useRef)(navigateToBreadcrumb);
|
|
20726
21263
|
navigateToBreadcrumbRef.current = navigateToBreadcrumb;
|
|
20727
|
-
const breadcrumbsRef = (0,
|
|
21264
|
+
const breadcrumbsRef = (0, import_react25.useRef)(breadcrumbs);
|
|
20728
21265
|
breadcrumbsRef.current = breadcrumbs;
|
|
20729
|
-
(0,
|
|
21266
|
+
(0, import_react25.useImperativeHandle)(forwardedRef, () => ({
|
|
20730
21267
|
zoomIntoNode: (nodeId, options) => {
|
|
20731
21268
|
return new Promise((resolve) => {
|
|
20732
21269
|
const node = nodesRef.current.find((n) => n.id === nodeId);
|
|
@@ -20758,49 +21295,67 @@ var SystemCanvas = (() => {
|
|
|
20758
21295
|
navigateToBreadcrumbRef.current(0);
|
|
20759
21296
|
}
|
|
20760
21297
|
}), [forwardedRef]);
|
|
20761
|
-
const [editingId, setEditingId] = (0,
|
|
20762
|
-
const [selectedEdgeId, setSelectedEdgeId] = (0,
|
|
20763
|
-
const [editingEdgeId, setEditingEdgeId] = (0,
|
|
20764
|
-
const svgProxyRef = (0,
|
|
20765
|
-
const containerRef = (0,
|
|
20766
|
-
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({
|
|
20767
21304
|
svgRef: svgProxyRef,
|
|
20768
21305
|
viewport: viewportStateRef,
|
|
20769
21306
|
nodesRef,
|
|
20770
21307
|
containerRef,
|
|
20771
21308
|
enabled: editable
|
|
20772
21309
|
});
|
|
20773
|
-
const selectedIdsRef = (0,
|
|
20774
|
-
(0,
|
|
21310
|
+
const selectedIdsRef = (0, import_react25.useRef)(selectedIds);
|
|
21311
|
+
(0, import_react25.useEffect)(() => {
|
|
20775
21312
|
selectedIdsRef.current = selectedIds;
|
|
20776
21313
|
}, [selectedIds]);
|
|
20777
|
-
const edgesRef = (0,
|
|
20778
|
-
(0,
|
|
21314
|
+
const edgesRef = (0, import_react25.useRef)(edges);
|
|
21315
|
+
(0, import_react25.useEffect)(() => {
|
|
20779
21316
|
edgesRef.current = edges;
|
|
20780
21317
|
}, [edges]);
|
|
21318
|
+
const { wrappedOnNodeAdd, wrappedOnNodeUpdate, wrappedOnNodesUpdate, wrappedOnNodeDelete, wrappedOnNodesDelete, wrappedOnEdgeAdd, wrappedOnEdgeUpdate, wrappedOnEdgeDelete, beginBatch, endBatch, undo, redo } = useCommandHistory({
|
|
21319
|
+
nodesRef,
|
|
21320
|
+
edgesRef,
|
|
21321
|
+
onNodeAdd,
|
|
21322
|
+
onNodeUpdate,
|
|
21323
|
+
onNodesUpdate,
|
|
21324
|
+
onNodeDelete,
|
|
21325
|
+
onNodesDelete,
|
|
21326
|
+
onEdgeAdd,
|
|
21327
|
+
onEdgeUpdate,
|
|
21328
|
+
onEdgeDelete,
|
|
21329
|
+
maxDepth: historyDepth ?? 50,
|
|
21330
|
+
enabled: editable,
|
|
21331
|
+
onUndo,
|
|
21332
|
+
onRedo
|
|
21333
|
+
});
|
|
20781
21334
|
useMultiSelectClipboard({
|
|
20782
21335
|
selectedIdsRef,
|
|
20783
21336
|
nodesRef,
|
|
20784
21337
|
edgesRef,
|
|
20785
21338
|
viewport: viewportStateRef,
|
|
20786
21339
|
canvasContainerRef: containerRef,
|
|
20787
|
-
onNodeAdd: (node) =>
|
|
20788
|
-
onEdgeAdd: (edge) =>
|
|
21340
|
+
onNodeAdd: (node) => wrappedOnNodeAdd(node, currentCanvasRef),
|
|
21341
|
+
onEdgeAdd: (edge) => wrappedOnEdgeAdd(edge, currentCanvasRef),
|
|
20789
21342
|
canvasRef: currentCanvasRef,
|
|
20790
|
-
getCursorScreenPos: () => viewportHandleRef.current?.getCursorScreenPos() ?? null
|
|
21343
|
+
getCursorScreenPos: () => viewportHandleRef.current?.getCursorScreenPos() ?? null,
|
|
21344
|
+
onBeginBatch: beginBatch,
|
|
21345
|
+
onEndBatch: endBatch
|
|
20791
21346
|
});
|
|
20792
|
-
(0,
|
|
21347
|
+
(0, import_react25.useEffect)(() => {
|
|
20793
21348
|
clearSelection();
|
|
20794
21349
|
setEditingId(null);
|
|
20795
21350
|
setSelectedEdgeId(null);
|
|
20796
21351
|
setEditingEdgeId(null);
|
|
20797
21352
|
}, [currentCanvasRef]);
|
|
20798
|
-
const onSelectionChangeRef = (0,
|
|
20799
|
-
(0,
|
|
21353
|
+
const onSelectionChangeRef = (0, import_react25.useRef)(onSelectionChange);
|
|
21354
|
+
(0, import_react25.useEffect)(() => {
|
|
20800
21355
|
onSelectionChangeRef.current = onSelectionChange;
|
|
20801
21356
|
}, [onSelectionChange]);
|
|
20802
|
-
const lastEmittedSelectionRef = (0,
|
|
20803
|
-
(0,
|
|
21357
|
+
const lastEmittedSelectionRef = (0, import_react25.useRef)({ kind: null, id: null, multiIds: null, canvasRef: void 0 });
|
|
21358
|
+
(0, import_react25.useEffect)(() => {
|
|
20804
21359
|
const cb = onSelectionChangeRef.current;
|
|
20805
21360
|
let next = null;
|
|
20806
21361
|
if (selectedIds.size > 1) {
|
|
@@ -20842,8 +21397,8 @@ var SystemCanvas = (() => {
|
|
|
20842
21397
|
}
|
|
20843
21398
|
cb?.(next);
|
|
20844
21399
|
}, [selectedIds, selectedEdgeId, currentCanvasRef, nodeMap, edges]);
|
|
20845
|
-
const [containerSize, setContainerSize] = (0,
|
|
20846
|
-
(0,
|
|
21400
|
+
const [containerSize, setContainerSize] = (0, import_react25.useState)({ width: 0, height: 0 });
|
|
21401
|
+
(0, import_react25.useEffect)(() => {
|
|
20847
21402
|
const el = containerRef.current;
|
|
20848
21403
|
if (!el)
|
|
20849
21404
|
return;
|
|
@@ -20858,8 +21413,8 @@ var SystemCanvas = (() => {
|
|
|
20858
21413
|
}, []);
|
|
20859
21414
|
const hasLanes = currentCanvas.columns && currentCanvas.columns.length > 0 || currentCanvas.rows && currentCanvas.rows.length > 0;
|
|
20860
21415
|
const showLaneHeaders = hasLanes && laneHeaders !== "none";
|
|
20861
|
-
const getViewportState = (0,
|
|
20862
|
-
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) => {
|
|
20863
21418
|
if (!snapToLanes)
|
|
20864
21419
|
return patch;
|
|
20865
21420
|
const cols = currentCanvas.columns;
|
|
@@ -20884,28 +21439,28 @@ var SystemCanvas = (() => {
|
|
|
20884
21439
|
}
|
|
20885
21440
|
return final;
|
|
20886
21441
|
}, [snapToLanes, currentCanvas.columns, currentCanvas.rows]);
|
|
20887
|
-
const commitResize = (0,
|
|
20888
|
-
|
|
20889
|
-
}, [
|
|
20890
|
-
const commitDragBatch = (0,
|
|
21442
|
+
const commitResize = (0, import_react25.useCallback)((id2, patch) => {
|
|
21443
|
+
wrappedOnNodeUpdate(id2, applyLaneSnap(id2, patch), currentCanvasRef);
|
|
21444
|
+
}, [wrappedOnNodeUpdate, currentCanvasRef, applyLaneSnap]);
|
|
21445
|
+
const commitDragBatch = (0, import_react25.useCallback)((updates) => {
|
|
20891
21446
|
const final = updates.map((u) => ({
|
|
20892
21447
|
id: u.id,
|
|
20893
21448
|
patch: applyLaneSnap(u.id, u.patch)
|
|
20894
21449
|
}));
|
|
20895
21450
|
if (onNodesUpdate) {
|
|
20896
|
-
|
|
21451
|
+
wrappedOnNodesUpdate(final, currentCanvasRef);
|
|
20897
21452
|
return;
|
|
20898
21453
|
}
|
|
20899
21454
|
if (!onNodeUpdate)
|
|
20900
21455
|
return;
|
|
20901
21456
|
for (const { id: id2, patch } of final) {
|
|
20902
|
-
|
|
21457
|
+
wrappedOnNodeUpdate(id2, patch, currentCanvasRef);
|
|
20903
21458
|
}
|
|
20904
|
-
}, [onNodeUpdate, onNodesUpdate, currentCanvasRef, applyLaneSnap]);
|
|
20905
|
-
const handleNodeDrop = (0,
|
|
21459
|
+
}, [wrappedOnNodeUpdate, wrappedOnNodesUpdate, onNodeUpdate, onNodesUpdate, currentCanvasRef, applyLaneSnap]);
|
|
21460
|
+
const handleNodeDrop = (0, import_react25.useCallback)((sources, target) => {
|
|
20906
21461
|
onNodeDrop?.(sources, target, { canvasRef: currentCanvasRef });
|
|
20907
21462
|
}, [onNodeDrop, currentCanvasRef]);
|
|
20908
|
-
const { dragOverrides, dropTargetId, onPointerDown: onNodePointerDown } = useNodeDrag({
|
|
21463
|
+
const { dragOverrides, dropTargetId, onPointerDown: onNodePointerDown, cancelDrag } = useNodeDrag({
|
|
20909
21464
|
viewport: viewportStateRef,
|
|
20910
21465
|
nodesRef,
|
|
20911
21466
|
onCommit: commitDragBatch,
|
|
@@ -20919,7 +21474,7 @@ var SystemCanvas = (() => {
|
|
|
20919
21474
|
onCommit: commitResize
|
|
20920
21475
|
});
|
|
20921
21476
|
const singleSelectedId = selectedIds.size === 1 ? Array.from(selectedIds)[0] : null;
|
|
20922
|
-
const selectedResolvedNode = (0,
|
|
21477
|
+
const selectedResolvedNode = (0, import_react25.useMemo)(() => {
|
|
20923
21478
|
if (!singleSelectedId)
|
|
20924
21479
|
return null;
|
|
20925
21480
|
const base = nodeMap.get(singleSelectedId);
|
|
@@ -20936,16 +21491,16 @@ var SystemCanvas = (() => {
|
|
|
20936
21491
|
return base;
|
|
20937
21492
|
}, [singleSelectedId, nodeMap, dragOverrides, resizeOverrides]);
|
|
20938
21493
|
svgProxyRef.current = viewportHandleRef.current?.getSvgElement() ?? null;
|
|
20939
|
-
const handleEdgeCreated = (0,
|
|
20940
|
-
|
|
20941
|
-
}, [
|
|
21494
|
+
const handleEdgeCreated = (0, import_react25.useCallback)((edge) => {
|
|
21495
|
+
wrappedOnEdgeAdd(edge, currentCanvasRef);
|
|
21496
|
+
}, [wrappedOnEdgeAdd, currentCanvasRef]);
|
|
20942
21497
|
const { pending: pendingEdge, onHandlePointerDown: onConnectionHandlePointerDown } = useEdgeCreate({
|
|
20943
21498
|
svgRef: svgProxyRef,
|
|
20944
21499
|
viewport: viewportStateRef,
|
|
20945
21500
|
nodesRef,
|
|
20946
21501
|
onCreate: handleEdgeCreated
|
|
20947
21502
|
});
|
|
20948
|
-
const handleNavigableNodeClick = (0,
|
|
21503
|
+
const handleNavigableNodeClick = (0, import_react25.useCallback)((node) => {
|
|
20949
21504
|
const frame2 = {
|
|
20950
21505
|
parentCanvasRef: currentCanvasRef,
|
|
20951
21506
|
parentNodeRect: {
|
|
@@ -20972,7 +21527,7 @@ var SystemCanvas = (() => {
|
|
|
20972
21527
|
navigateToRef(node);
|
|
20973
21528
|
}
|
|
20974
21529
|
}, [navigateToRef, currentCanvasRef, zoomNavConfig.enabled]);
|
|
20975
|
-
const handleZoomEnter = (0,
|
|
21530
|
+
const handleZoomEnter = (0, import_react25.useCallback)((node, targetTransform) => {
|
|
20976
21531
|
const frame2 = {
|
|
20977
21532
|
parentCanvasRef: currentCanvasRef,
|
|
20978
21533
|
parentNodeRect: {
|
|
@@ -20986,7 +21541,7 @@ var SystemCanvas = (() => {
|
|
|
20986
21541
|
setPendingHandoff(targetTransform);
|
|
20987
21542
|
navigateToRef(node);
|
|
20988
21543
|
}, [currentCanvasRef, navigateToRef]);
|
|
20989
|
-
const handleZoomExit = (0,
|
|
21544
|
+
const handleZoomExit = (0, import_react25.useCallback)((targetTransform) => {
|
|
20990
21545
|
setPendingHandoff(targetTransform);
|
|
20991
21546
|
suppressNextHandoffClearRef.current = true;
|
|
20992
21547
|
navigateToBreadcrumb(breadcrumbs.length - 2);
|
|
@@ -21013,26 +21568,26 @@ var SystemCanvas = (() => {
|
|
|
21013
21568
|
onEnter: handleZoomEnter,
|
|
21014
21569
|
onExit: handleZoomExit
|
|
21015
21570
|
});
|
|
21016
|
-
const handleViewportChange = (0,
|
|
21571
|
+
const handleViewportChange = (0, import_react25.useCallback)((vp) => {
|
|
21017
21572
|
viewportStateRef.current = vp;
|
|
21018
21573
|
handleZoomNavViewportChange(vp);
|
|
21019
21574
|
onViewportChange?.(vp);
|
|
21020
21575
|
}, [handleZoomNavViewportChange, onViewportChange]);
|
|
21021
|
-
const handleHandoffApplied = (0,
|
|
21576
|
+
const handleHandoffApplied = (0, import_react25.useCallback)(() => {
|
|
21022
21577
|
setPendingHandoff(null);
|
|
21023
21578
|
clearZoomNavCommitting();
|
|
21024
21579
|
}, [clearZoomNavCommitting]);
|
|
21025
|
-
const handleBeginEdit = (0,
|
|
21580
|
+
const handleBeginEdit = (0, import_react25.useCallback)((node) => {
|
|
21026
21581
|
setEditingId(node.id);
|
|
21027
21582
|
}, []);
|
|
21028
|
-
const handleBeginEditEdge = (0,
|
|
21583
|
+
const handleBeginEditEdge = (0, import_react25.useCallback)((edge) => {
|
|
21029
21584
|
setEditingEdgeId(edge.id);
|
|
21030
21585
|
}, []);
|
|
21031
|
-
const [contextMenuState, setContextMenuState] = (0,
|
|
21032
|
-
(0,
|
|
21586
|
+
const [contextMenuState, setContextMenuState] = (0, import_react25.useState)(null);
|
|
21587
|
+
(0, import_react25.useEffect)(() => {
|
|
21033
21588
|
setContextMenuState(null);
|
|
21034
21589
|
}, [currentCanvasRef]);
|
|
21035
|
-
const handleContextMenu = (0,
|
|
21590
|
+
const handleContextMenu = (0, import_react25.useCallback)((event) => {
|
|
21036
21591
|
onContextMenu?.(event);
|
|
21037
21592
|
if (!nodeContextMenu)
|
|
21038
21593
|
return;
|
|
@@ -21075,27 +21630,27 @@ var SystemCanvas = (() => {
|
|
|
21075
21630
|
onSelectEdge: setSelectedEdgeId,
|
|
21076
21631
|
onBeginEditEdge: handleBeginEditEdge
|
|
21077
21632
|
});
|
|
21078
|
-
const handleEditorCommit = (0,
|
|
21633
|
+
const handleEditorCommit = (0, import_react25.useCallback)((patch) => {
|
|
21079
21634
|
if (editingId) {
|
|
21080
|
-
|
|
21635
|
+
wrappedOnNodeUpdate(editingId, patch, currentCanvasRef);
|
|
21081
21636
|
}
|
|
21082
21637
|
setEditingId(null);
|
|
21083
|
-
}, [editingId,
|
|
21084
|
-
const handleEditorCancel = (0,
|
|
21638
|
+
}, [editingId, wrappedOnNodeUpdate, currentCanvasRef]);
|
|
21639
|
+
const handleEditorCancel = (0, import_react25.useCallback)(() => {
|
|
21085
21640
|
setEditingId(null);
|
|
21086
21641
|
}, []);
|
|
21087
|
-
const handleEdgeEditorCommit = (0,
|
|
21642
|
+
const handleEdgeEditorCommit = (0, import_react25.useCallback)((patch) => {
|
|
21088
21643
|
if (editingEdgeId) {
|
|
21089
|
-
|
|
21644
|
+
wrappedOnEdgeUpdate(editingEdgeId, patch, currentCanvasRef);
|
|
21090
21645
|
}
|
|
21091
21646
|
setEditingEdgeId(null);
|
|
21092
|
-
}, [editingEdgeId,
|
|
21093
|
-
const handleEdgeEditorCancel = (0,
|
|
21647
|
+
}, [editingEdgeId, wrappedOnEdgeUpdate, currentCanvasRef]);
|
|
21648
|
+
const handleEdgeEditorCancel = (0, import_react25.useCallback)(() => {
|
|
21094
21649
|
setEditingEdgeId(null);
|
|
21095
21650
|
}, []);
|
|
21096
|
-
const lastAddRef = (0,
|
|
21097
|
-
const menuOptions = (0,
|
|
21098
|
-
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) => {
|
|
21099
21654
|
let x, y;
|
|
21100
21655
|
if (position) {
|
|
21101
21656
|
x = position.x;
|
|
@@ -21125,54 +21680,42 @@ var SystemCanvas = (() => {
|
|
|
21125
21680
|
lastAddRef.current = { t: now2, offset: nextOffset };
|
|
21126
21681
|
}
|
|
21127
21682
|
const node = createNodeFromOption(option, Math.round(x), Math.round(y), void 0, theme);
|
|
21128
|
-
|
|
21129
|
-
}, [
|
|
21130
|
-
const handleKeyDown = (
|
|
21131
|
-
if (!editable)
|
|
21132
|
-
return;
|
|
21133
|
-
if (e.key === "Escape") {
|
|
21134
|
-
setEditingId(null);
|
|
21135
|
-
clearSelection();
|
|
21136
|
-
setEditingEdgeId(null);
|
|
21137
|
-
setSelectedEdgeId(null);
|
|
21138
|
-
return;
|
|
21139
|
-
}
|
|
21140
|
-
if (editingId || editingEdgeId)
|
|
21141
|
-
return;
|
|
21142
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "a") {
|
|
21143
|
-
e.preventDefault();
|
|
21144
|
-
selectAll();
|
|
21145
|
-
return;
|
|
21146
|
-
}
|
|
21147
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
|
21148
|
-
if (selectedIds.size > 1) {
|
|
21149
|
-
e.preventDefault();
|
|
21150
|
-
onNodesDelete?.(Array.from(selectedIds), currentCanvasRef);
|
|
21151
|
-
clearSelection();
|
|
21152
|
-
} else if (selectedIds.size === 1) {
|
|
21153
|
-
const id2 = Array.from(selectedIds)[0];
|
|
21154
|
-
e.preventDefault();
|
|
21155
|
-
onNodeDelete?.(id2, currentCanvasRef);
|
|
21156
|
-
clearSelection();
|
|
21157
|
-
} else if (selectedEdgeId) {
|
|
21158
|
-
e.preventDefault();
|
|
21159
|
-
onEdgeDelete?.(selectedEdgeId, currentCanvasRef);
|
|
21160
|
-
setSelectedEdgeId(null);
|
|
21161
|
-
}
|
|
21162
|
-
}
|
|
21163
|
-
}, [
|
|
21683
|
+
wrappedOnNodeAdd(node, currentCanvasRef);
|
|
21684
|
+
}, [wrappedOnNodeAdd, currentCanvasRef, theme]);
|
|
21685
|
+
const handleKeyDown = useKeyboardShortcuts({
|
|
21164
21686
|
editable,
|
|
21165
21687
|
editingId,
|
|
21166
21688
|
editingEdgeId,
|
|
21167
21689
|
selectedIds,
|
|
21168
21690
|
selectedEdgeId,
|
|
21169
|
-
|
|
21170
|
-
|
|
21171
|
-
|
|
21691
|
+
nodesRef,
|
|
21692
|
+
edgesRef,
|
|
21693
|
+
theme,
|
|
21172
21694
|
currentCanvasRef,
|
|
21695
|
+
contextMenuState,
|
|
21696
|
+
setContextMenuState,
|
|
21697
|
+
wrappedOnNodeAdd,
|
|
21698
|
+
wrappedOnEdgeAdd,
|
|
21699
|
+
wrappedOnNodeUpdate,
|
|
21700
|
+
wrappedOnNodesUpdate,
|
|
21701
|
+
wrappedOnNodeDelete,
|
|
21702
|
+
wrappedOnNodesDelete,
|
|
21703
|
+
wrappedOnEdgeDelete,
|
|
21704
|
+
onNodesUpdate,
|
|
21705
|
+
onNodeUpdate,
|
|
21706
|
+
beginBatch,
|
|
21707
|
+
endBatch,
|
|
21708
|
+
undo,
|
|
21709
|
+
redo,
|
|
21710
|
+
selectNode,
|
|
21711
|
+
selectMultiple,
|
|
21712
|
+
selectAll,
|
|
21173
21713
|
clearSelection,
|
|
21174
|
-
|
|
21175
|
-
|
|
21714
|
+
setEditingId,
|
|
21715
|
+
setEditingEdgeId,
|
|
21716
|
+
setSelectedEdgeId,
|
|
21717
|
+
cancelDrag
|
|
21718
|
+
});
|
|
21176
21719
|
const renderProps = { options: menuOptions, addNode: addNode2, theme };
|
|
21177
21720
|
return (0, import_jsx_runtime28.jsxs)("div", { ref: containerRef, className: `system-canvas ${className ?? ""}`, tabIndex: editable ? 0 : -1, onKeyDown: handleKeyDown, style: {
|
|
21178
21721
|
position: "relative",
|
|
@@ -21194,9 +21737,9 @@ var SystemCanvas = (() => {
|
|
|
21194
21737
|
fontSize: 12,
|
|
21195
21738
|
backdropFilter: "blur(8px)"
|
|
21196
21739
|
}, children: "Loading..." }), (0, import_jsx_runtime28.jsx)(Viewport, { ref: viewportHandleRef, nodes, edges, nodeMap, theme, edgeStyle, columns: currentCanvas.columns, rows: currentCanvas.rows, canvases, minZoom: effectiveMinZoom, maxZoom: effectiveMaxZoom, defaultViewport, autoFit, canvasRef: currentCanvasRef, handoffTransform: pendingHandoff, onHandoffApplied: handleHandoffApplied, handoffFadeMs: zoomNavConfig.fadeDuration, onViewportChange: handleViewportChange, onNodeClick: handleNodeClick, onNodeDoubleClick: handleNodeDoubleClick, onNodeNavigate: handleNodeNavigate, onEdgeClick: handleEdgeClick, onEdgeDoubleClick: handleEdgeDoubleClick, onCanvasClick: editable ? handleCanvasClick : void 0, onCanvasContextMenu: handleCanvasContextMenu, onNodeContextMenu: handleNodeContextMenu, onEdgeContextMenu: handleEdgeContextMenu, onNodePointerDown: editable ? onNodePointerDown : void 0, selectedIds: editable ? selectedIds : void 0, marqueeRect: editable ? marqueeRect : null, marqueeActiveRef: editable ? marqueeActiveRef : void 0, editingId: editable ? editingId : null, selectedEdgeId: editable ? selectedEdgeId : null, editingEdgeId: editable ? editingEdgeId : null, dragOverrides, dropTargetId, resizeOverrides, onResizeHandlePointerDown: editable ? onResizeHandlePointerDown : void 0, onEditorCommit: handleEditorCommit, onEditorCancel: handleEditorCancel, onEdgeEditorCommit: handleEdgeEditorCommit, onEdgeEditorCancel: handleEdgeEditorCancel, pendingEdge: editable ? pendingEdge : null, onConnectionHandlePointerDown: editable ? onConnectionHandlePointerDown : void 0, edgeCreateEnabled: editable }), showLaneHeaders && (0, import_jsx_runtime28.jsx)(LaneHeaders, { columns: currentCanvas.columns, rows: currentCanvas.rows, theme, getViewport: getViewportState, width: containerSize.width, height: containerSize.height, pinned: laneHeaders === "pinned" }), editable && showNodeToolbar && selectedIds.size === 1 && selectedResolvedNode && !editingId && (0, import_jsx_runtime28.jsx)(NodeToolbar, { node: selectedResolvedNode, theme, onPatch: (update) => {
|
|
21197
|
-
|
|
21740
|
+
wrappedOnNodeUpdate(selectedResolvedNode.id, update, currentCanvasRef);
|
|
21198
21741
|
}, onDelete: () => {
|
|
21199
|
-
|
|
21742
|
+
wrappedOnNodeDelete(selectedResolvedNode.id, currentCanvasRef);
|
|
21200
21743
|
clearSelection();
|
|
21201
21744
|
}, getViewport: getViewportState, containerWidth: containerSize.width, containerHeight: containerSize.height, render: renderNodeToolbar }), editable && showNodeToolbar && selectedIds.size > 1 && !editingId && (() => {
|
|
21202
21745
|
const selectedResolvedNodes = Array.from(selectedIds).map((id2) => nodeMap.get(id2)).filter((n) => n != null);
|
|
@@ -21206,10 +21749,10 @@ var SystemCanvas = (() => {
|
|
|
21206
21749
|
return (0, import_jsx_runtime28.jsx)(NodeToolbar, { node: anchorNode, selectedNodes: selectedResolvedNodes, theme, onPatch: () => {
|
|
21207
21750
|
}, onMultiPatch: (patch) => {
|
|
21208
21751
|
for (const id2 of selectedIds) {
|
|
21209
|
-
|
|
21752
|
+
wrappedOnNodeUpdate(id2, patch, currentCanvasRef);
|
|
21210
21753
|
}
|
|
21211
21754
|
}, onDelete: () => {
|
|
21212
|
-
|
|
21755
|
+
wrappedOnNodesDelete(Array.from(selectedIds), currentCanvasRef);
|
|
21213
21756
|
clearSelection();
|
|
21214
21757
|
}, getViewport: getViewportState, containerWidth: containerSize.width, containerHeight: containerSize.height });
|
|
21215
21758
|
})(), editable && (renderAddNodeButton ? renderAddNodeButton(renderProps) : (0, import_jsx_runtime28.jsx)(AddNodeButton, { ...renderProps })), nodeContextMenu && (0, import_jsx_runtime28.jsx)(NodeContextMenuOverlay, { state: contextMenuState, config: nodeContextMenu, theme, onClose: () => setContextMenuState(null) })] });
|
|
@@ -21323,7 +21866,7 @@ var SystemCanvas = (() => {
|
|
|
21323
21866
|
onEdgeUpdate: handleEdgeUpdate,
|
|
21324
21867
|
onEdgeDelete: handleEdgeDelete
|
|
21325
21868
|
};
|
|
21326
|
-
root2.render(
|
|
21869
|
+
root2.render(import_react26.default.createElement(SystemCanvas, props));
|
|
21327
21870
|
};
|
|
21328
21871
|
doRender();
|
|
21329
21872
|
return {
|