system-canvas-standalone 0.2.41 → 0.2.43
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 +76 -32
- package/dist/system-canvas.js.map +1 -1
- package/dist/system-canvas.min.js +11 -11
- package/dist/system-canvas.min.js.map +1 -1
- package/package.json +3 -3
package/dist/system-canvas.js
CHANGED
|
@@ -15841,10 +15841,11 @@ var SystemCanvas = (() => {
|
|
|
15841
15841
|
// ../react/dist/hooks/useMultiSelect.js
|
|
15842
15842
|
var import_react7 = __toESM(require_react(), 1);
|
|
15843
15843
|
function useMultiSelect(options) {
|
|
15844
|
-
const { svgRef, viewport, nodesRef, containerRef, enabled } = options;
|
|
15844
|
+
const { svgRef, viewport, nodesRef, containerRef, enabled, activationKey = "space" } = options;
|
|
15845
15845
|
const [selectedIds, setSelectedIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
|
|
15846
15846
|
const [marqueeRect, setMarqueeRect] = (0, import_react7.useState)(null);
|
|
15847
|
-
const marqueeActiveRef = (0, import_react7.useRef)(
|
|
15847
|
+
const marqueeActiveRef = (0, import_react7.useRef)(activationKey === "none");
|
|
15848
|
+
const isPendingRef = (0, import_react7.useRef)(false);
|
|
15848
15849
|
const isDrawingRef = (0, import_react7.useRef)(false);
|
|
15849
15850
|
const startScreenRef = (0, import_react7.useRef)(null);
|
|
15850
15851
|
const pointerIdRef = (0, import_react7.useRef)(null);
|
|
@@ -15879,28 +15880,48 @@ var SystemCanvas = (() => {
|
|
|
15879
15880
|
(0, import_react7.useEffect)(() => {
|
|
15880
15881
|
if (!enabled)
|
|
15881
15882
|
return;
|
|
15883
|
+
if (activationKey === "none") {
|
|
15884
|
+
marqueeActiveRef.current = true;
|
|
15885
|
+
return;
|
|
15886
|
+
}
|
|
15882
15887
|
const container = containerRef.current;
|
|
15883
15888
|
if (!container)
|
|
15884
15889
|
return;
|
|
15890
|
+
const matchesKey = (e) => {
|
|
15891
|
+
switch (activationKey) {
|
|
15892
|
+
case "space":
|
|
15893
|
+
return e.code === "Space";
|
|
15894
|
+
case "shift":
|
|
15895
|
+
return e.key === "Shift";
|
|
15896
|
+
case "alt":
|
|
15897
|
+
return e.key === "Alt";
|
|
15898
|
+
case "meta":
|
|
15899
|
+
return e.key === "Meta";
|
|
15900
|
+
default:
|
|
15901
|
+
return false;
|
|
15902
|
+
}
|
|
15903
|
+
};
|
|
15885
15904
|
const onKeyDown = (e) => {
|
|
15886
|
-
if (e
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
e.preventDefault();
|
|
15892
|
-
marqueeActiveRef.current = true;
|
|
15905
|
+
if (!matchesKey(e) || e.repeat)
|
|
15906
|
+
return;
|
|
15907
|
+
const active = document.activeElement;
|
|
15908
|
+
if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable) {
|
|
15909
|
+
return;
|
|
15893
15910
|
}
|
|
15911
|
+
if (activationKey === "space")
|
|
15912
|
+
e.preventDefault();
|
|
15913
|
+
marqueeActiveRef.current = true;
|
|
15894
15914
|
};
|
|
15895
15915
|
const onKeyUp = (e) => {
|
|
15896
|
-
if (e
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
|
|
15903
|
-
|
|
15916
|
+
if (!matchesKey(e))
|
|
15917
|
+
return;
|
|
15918
|
+
marqueeActiveRef.current = false;
|
|
15919
|
+
if (isDrawingRef.current || isPendingRef.current) {
|
|
15920
|
+
isPendingRef.current = false;
|
|
15921
|
+
isDrawingRef.current = false;
|
|
15922
|
+
startScreenRef.current = null;
|
|
15923
|
+
pointerIdRef.current = null;
|
|
15924
|
+
setMarqueeRect(null);
|
|
15904
15925
|
}
|
|
15905
15926
|
};
|
|
15906
15927
|
container.addEventListener("keydown", onKeyDown);
|
|
@@ -15909,7 +15930,7 @@ var SystemCanvas = (() => {
|
|
|
15909
15930
|
container.removeEventListener("keydown", onKeyDown);
|
|
15910
15931
|
container.removeEventListener("keyup", onKeyUp);
|
|
15911
15932
|
};
|
|
15912
|
-
}, [enabled, containerRef]);
|
|
15933
|
+
}, [enabled, containerRef, activationKey]);
|
|
15913
15934
|
(0, import_react7.useEffect)(() => {
|
|
15914
15935
|
if (!enabled)
|
|
15915
15936
|
return;
|
|
@@ -15946,6 +15967,12 @@ var SystemCanvas = (() => {
|
|
|
15946
15967
|
if (target && typeof target.closest === "function") {
|
|
15947
15968
|
if (target.closest(".system-canvas-node"))
|
|
15948
15969
|
return;
|
|
15970
|
+
if (target.closest(".system-canvas-edge"))
|
|
15971
|
+
return;
|
|
15972
|
+
if (target.closest(".system-canvas-resize-handles"))
|
|
15973
|
+
return;
|
|
15974
|
+
if (target.closest(".system-canvas-connection-handles"))
|
|
15975
|
+
return;
|
|
15949
15976
|
}
|
|
15950
15977
|
const svg = svgRef.current;
|
|
15951
15978
|
if (!svg)
|
|
@@ -15954,21 +15981,16 @@ var SystemCanvas = (() => {
|
|
|
15954
15981
|
const x = e.clientX - rect.left;
|
|
15955
15982
|
const y = e.clientY - rect.top;
|
|
15956
15983
|
startScreenRef.current = { x, y };
|
|
15957
|
-
|
|
15984
|
+
isPendingRef.current = true;
|
|
15985
|
+
isDrawingRef.current = false;
|
|
15958
15986
|
pointerIdRef.current = e.pointerId;
|
|
15959
|
-
setMarqueeRect({ x1: x, y1: y, x2: x, y2: y });
|
|
15960
|
-
try {
|
|
15961
|
-
container.setPointerCapture(e.pointerId);
|
|
15962
|
-
} catch {
|
|
15963
|
-
}
|
|
15964
|
-
e.preventDefault();
|
|
15965
|
-
e.stopPropagation();
|
|
15966
15987
|
};
|
|
15988
|
+
const MARQUEE_DRAG_THRESHOLD = 4;
|
|
15967
15989
|
const onPointerMove = (e) => {
|
|
15968
|
-
if (!isDrawingRef.current)
|
|
15969
|
-
return;
|
|
15970
15990
|
if (e.pointerId !== pointerIdRef.current)
|
|
15971
15991
|
return;
|
|
15992
|
+
if (!isPendingRef.current && !isDrawingRef.current)
|
|
15993
|
+
return;
|
|
15972
15994
|
const svg = svgRef.current;
|
|
15973
15995
|
if (!svg)
|
|
15974
15996
|
return;
|
|
@@ -15976,13 +15998,32 @@ var SystemCanvas = (() => {
|
|
|
15976
15998
|
const x = e.clientX - rect.left;
|
|
15977
15999
|
const y = e.clientY - rect.top;
|
|
15978
16000
|
const start2 = startScreenRef.current;
|
|
16001
|
+
if (isPendingRef.current && !isDrawingRef.current) {
|
|
16002
|
+
const dx = x - start2.x;
|
|
16003
|
+
const dy = y - start2.y;
|
|
16004
|
+
if (Math.hypot(dx, dy) < MARQUEE_DRAG_THRESHOLD)
|
|
16005
|
+
return;
|
|
16006
|
+
isPendingRef.current = false;
|
|
16007
|
+
isDrawingRef.current = true;
|
|
16008
|
+
try {
|
|
16009
|
+
container.setPointerCapture(e.pointerId);
|
|
16010
|
+
} catch {
|
|
16011
|
+
}
|
|
16012
|
+
}
|
|
16013
|
+
e.preventDefault();
|
|
15979
16014
|
setMarqueeRect({ x1: start2.x, y1: start2.y, x2: x, y2: y });
|
|
15980
16015
|
};
|
|
15981
16016
|
const onPointerUp = (e) => {
|
|
15982
|
-
if (!isDrawingRef.current)
|
|
15983
|
-
return;
|
|
15984
16017
|
if (e.pointerId !== pointerIdRef.current)
|
|
15985
16018
|
return;
|
|
16019
|
+
if (isPendingRef.current && !isDrawingRef.current) {
|
|
16020
|
+
isPendingRef.current = false;
|
|
16021
|
+
startScreenRef.current = null;
|
|
16022
|
+
pointerIdRef.current = null;
|
|
16023
|
+
return;
|
|
16024
|
+
}
|
|
16025
|
+
if (!isDrawingRef.current)
|
|
16026
|
+
return;
|
|
15986
16027
|
const svg = svgRef.current;
|
|
15987
16028
|
if (!svg)
|
|
15988
16029
|
return;
|
|
@@ -16008,6 +16049,7 @@ var SystemCanvas = (() => {
|
|
|
16008
16049
|
}
|
|
16009
16050
|
setSelectedIds(matched);
|
|
16010
16051
|
setMarqueeRect(null);
|
|
16052
|
+
isPendingRef.current = false;
|
|
16011
16053
|
isDrawingRef.current = false;
|
|
16012
16054
|
startScreenRef.current = null;
|
|
16013
16055
|
pointerIdRef.current = null;
|
|
@@ -22915,7 +22957,7 @@ var SystemCanvas = (() => {
|
|
|
22915
22957
|
// ../react/dist/components/SystemCanvas.js
|
|
22916
22958
|
var CASCADE_WINDOW_MS = 1500;
|
|
22917
22959
|
var CASCADE_OFFSET = 20;
|
|
22918
|
-
var SystemCanvas = (0, import_react34.forwardRef)(function SystemCanvas2({ canvas, onResolveCanvas, canvases, rootLabel = "Home", onNavigate, externalNavigation = false, onBreadcrumbClick, onBreadcrumbsChange, onNodeClick, onNodeDoubleClick, onEdgeClick, onEdgeDoubleClick, onContextMenu, onSelectionChange, nodeContextMenu, edgeContextMenu, canvasContextMenu, editable = false, onNodeAdd, onNodeUpdate, onNodesUpdate, onNodeDelete, onNodesDelete, onEdgeUpdate, onEdgeDelete, onEdgeAdd, canDropNodeOn, onNodeDrop, renderAddNodeButton, showExportButton = false, renderExportButton, onImport, showNodeToolbar = true, renderNodeToolbar, theme: themeProp, themes: customThemes, edgeStyle = "bezier", defaultViewport, minZoom: minZoomProp, maxZoom, onViewportChange, panMode = "drag", autoFit = "canvas-change", laneHeaders = "pinned", snapToLanes = false, zoomNavigation = false, snapGrid, guideThreshold, alignDistributeMenu, historyDepth, onUndo, onRedo, collaborators = [], className, style }, forwardedRef) {
|
|
22960
|
+
var SystemCanvas = (0, import_react34.forwardRef)(function SystemCanvas2({ canvas, onResolveCanvas, canvases, rootLabel = "Home", onNavigate, externalNavigation = false, onBreadcrumbClick, onBreadcrumbsChange, onNodeClick, onNodeDoubleClick, onEdgeClick, onEdgeDoubleClick, onContextMenu, onSelectionChange, nodeContextMenu, edgeContextMenu, canvasContextMenu, editable = false, onNodeAdd, onNodeUpdate, onNodesUpdate, onNodeDelete, onNodesDelete, onEdgeUpdate, onEdgeDelete, onEdgeAdd, canDropNodeOn, onNodeDrop, renderAddNodeButton, showExportButton = false, renderExportButton, onImport, showNodeToolbar = true, renderNodeToolbar, theme: themeProp, themes: customThemes, edgeStyle = "bezier", defaultViewport, minZoom: minZoomProp, maxZoom, onViewportChange, panMode = "drag", multiSelectKey = "auto", autoFit = "canvas-change", laneHeaders = "pinned", snapToLanes = false, zoomNavigation = false, snapGrid, guideThreshold, alignDistributeMenu, historyDepth, onUndo, onRedo, collaborators = [], className, style }, forwardedRef) {
|
|
22919
22961
|
const zoomNavConfig = (0, import_react34.useMemo)(() => {
|
|
22920
22962
|
const defaults = {
|
|
22921
22963
|
enterThreshold: 0.66,
|
|
@@ -23043,12 +23085,14 @@ var SystemCanvas = (() => {
|
|
|
23043
23085
|
const [importError, setImportError] = (0, import_react34.useState)(null);
|
|
23044
23086
|
const svgProxyRef = (0, import_react34.useRef)(null);
|
|
23045
23087
|
const containerRef = (0, import_react34.useRef)(null);
|
|
23088
|
+
const resolvedMultiSelectKey = multiSelectKey === "auto" ? panMode === "trackpad" ? "none" : "space" : multiSelectKey;
|
|
23046
23089
|
const { selectedIds, selectNode, toggleNode, selectAll, clearSelection, selectMultiple, marqueeRect, marqueeActiveRef } = useMultiSelect({
|
|
23047
23090
|
svgRef: svgProxyRef,
|
|
23048
23091
|
viewport: viewportStateRef,
|
|
23049
23092
|
nodesRef,
|
|
23050
23093
|
containerRef,
|
|
23051
|
-
enabled: editable
|
|
23094
|
+
enabled: editable,
|
|
23095
|
+
activationKey: resolvedMultiSelectKey
|
|
23052
23096
|
});
|
|
23053
23097
|
const selectedIdsRef = (0, import_react34.useRef)(selectedIds);
|
|
23054
23098
|
(0, import_react34.useEffect)(() => {
|