@uipath/apollo-react 6.25.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/BaseCanvas/BaseCanvas.cjs +15 -2
- package/dist/canvas/components/BaseCanvas/BaseCanvas.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.cjs +33 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.d.ts +2 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.js +31 -2
- package/dist/canvas/components/BaseCanvas/BaseCanvas.js +16 -3
- package/dist/canvas/components/BaseCanvas/BaseCanvas.types.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/index.cjs +54 -17
- package/dist/canvas/components/BaseCanvas/index.d.ts +1 -1
- package/dist/canvas/components/BaseCanvas/index.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/index.js +2 -2
- package/dist/canvas/components/BaseNode/BaseNode.cjs +32 -10
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +32 -10
- package/dist/canvas/components/BaseNode/NodeLabel.cjs +17 -11
- package/dist/canvas/components/BaseNode/NodeLabel.d.ts +2 -1
- package/dist/canvas/components/BaseNode/NodeLabel.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/NodeLabel.js +17 -11
- package/dist/canvas/components/Toolbar/shared/ToolbarButton.cjs +28 -23
- package/dist/canvas/components/Toolbar/shared/ToolbarButton.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/shared/ToolbarButton.js +28 -23
- package/package.json +1 -1
|
@@ -39,10 +39,22 @@ const external_ReadOnlyNodesContext_cjs_namespaceObject = require("./ReadOnlyNod
|
|
|
39
39
|
const BaseCanvasInnerComponent = (props)=>{
|
|
40
40
|
const { innerRef, fitViewOptions: fitViewOptionsProps, ...canvasProps } = props;
|
|
41
41
|
const fitViewOptions = fitViewOptionsProps ?? external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.fitViewOptions;
|
|
42
|
-
const { nodes = [], edges = [], nodeTypes, edgeTypes, children, mode = 'view', readOnlyNodeIds, showBackground = true, backgroundColor = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.color, backgroundSecondaryColor = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.bgColor, backgroundVariant = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.variant, backgroundGap = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.gap, backgroundSize = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.size, isDarkMode, locale, minZoom = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.zoom.min, maxZoom = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.zoom.max, defaultViewport = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.defaultViewport, defaultEdgeOptions = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.edge, stickyNoteOptions, onNodesChange, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onNodeClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onPaneClick, onInit, onSelectionChange, proOptions = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.pro, connectionMode = react_cjs_namespaceObject.ConnectionMode.Loose, connectionLineComponent, connectionLineStyle, deleteKeyCode = null, selectNodesOnDrag = true, nodesDraggable = true, nodesConnectable = true, elementsSelectable = true, onlyRenderVisibleElements = true, zoomOnDoubleClick = true, snapToGrid = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.snapToGrid, snapGrid = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.snapGrid, initialAutoLayout, maintainNodesInView, onToolbarAction, breakpoints, panShortcutTeachingUIMessage = 'Hold Space and drag to pan around the canvas!', ...reactFlowProps } = canvasProps;
|
|
42
|
+
const { nodes = [], edges = [], nodeTypes, edgeTypes, children, mode = 'view', readOnlyNodeIds, showBackground = true, backgroundColor = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.color, backgroundSecondaryColor = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.bgColor, backgroundVariant = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.variant, backgroundGap = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.gap, backgroundSize = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.background.size, isDarkMode, locale, minZoom = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.zoom.min, maxZoom = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.zoom.max, defaultViewport = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.defaultViewport, defaultEdgeOptions = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.edge, stickyNoteOptions, onNodesChange, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onNodeClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onPaneClick, onInit, onSelectionChange, onBeforeDelete, proOptions = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.pro, connectionMode = react_cjs_namespaceObject.ConnectionMode.Loose, connectionLineComponent, connectionLineStyle, deleteKeyCode = null, selectNodesOnDrag = true, nodesDraggable = true, nodesConnectable = true, elementsSelectable = true, onlyRenderVisibleElements = true, zoomOnDoubleClick = true, snapToGrid = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.snapToGrid, snapGrid = external_BaseCanvas_constants_cjs_namespaceObject.BASE_CANVAS_DEFAULTS.snapGrid, initialAutoLayout, maintainNodesInView, onToolbarAction, breakpoints, panShortcutTeachingUIMessage = 'Hold Space and drag to pan around the canvas!', ...reactFlowProps } = canvasProps;
|
|
43
43
|
const isInteractive = 'readonly' !== mode;
|
|
44
44
|
const isDesignMode = 'design' === mode;
|
|
45
45
|
const stableReadOnlyNodeIds = (0, external_ReadOnlyNodesContext_cjs_namespaceObject.useStableNodeIdSet)(readOnlyNodeIds);
|
|
46
|
+
const guardedBeforeDelete = (0, external_BaseCanvas_hooks_cjs_namespaceObject.useReadOnlyBeforeDelete)(stableReadOnlyNodeIds, onBeforeDelete);
|
|
47
|
+
const handleNodesChange = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
48
|
+
if (!onNodesChange || 0 === stableReadOnlyNodeIds.size) return onNodesChange;
|
|
49
|
+
const guarded = (changes)=>{
|
|
50
|
+
const allowed = changes.filter((change)=>!('remove' === change.type && stableReadOnlyNodeIds.has(change.id)));
|
|
51
|
+
if (allowed.length > 0) onNodesChange(allowed);
|
|
52
|
+
};
|
|
53
|
+
return guarded;
|
|
54
|
+
}, [
|
|
55
|
+
onNodesChange,
|
|
56
|
+
stableReadOnlyNodeIds
|
|
57
|
+
]);
|
|
46
58
|
const [reactFlowInstance, setReactFlowInstance] = (0, external_react_namespaceObject.useState)();
|
|
47
59
|
const { isReady } = (0, external_BaseCanvas_hooks_cjs_namespaceObject.useAutoLayout)(nodes, initialAutoLayout, fitViewOptions);
|
|
48
60
|
const { ensureNodesInView, ensureAllNodesInView, centerNode } = (0, external_BaseCanvas_hooks_cjs_namespaceObject.useEnsureNodesInView)();
|
|
@@ -108,8 +120,9 @@ const BaseCanvasInnerComponent = (props)=>{
|
|
|
108
120
|
zoomOnDoubleClick: isInteractive && zoomOnDoubleClick,
|
|
109
121
|
panOnDrag: isInteractive ? external_BaseCanvas_constants_cjs_namespaceObject.PAN_ON_DRAG : false,
|
|
110
122
|
onInit: handleInit,
|
|
111
|
-
onNodesChange: isInteractive ?
|
|
123
|
+
onNodesChange: isInteractive ? handleNodesChange : void 0,
|
|
112
124
|
onEdgesChange: isInteractive ? onEdgesChange : void 0,
|
|
125
|
+
onBeforeDelete: guardedBeforeDelete,
|
|
113
126
|
onConnect: isDesignMode ? onConnect : void 0,
|
|
114
127
|
onConnectStart: isDesignMode ? onConnectStart : void 0,
|
|
115
128
|
onConnectEnd: isDesignMode ? onConnectEnd : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,IAAI,EACJ,IAAI,EAEL,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAIL,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,IAAI,EACJ,IAAI,EAEL,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAIL,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAqOzE,eAAO,MAAM,UAAU,EAKjB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,EAC/D,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG;IAC3C,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;CACpD,KACE,YAAY,CAAC"}
|
|
@@ -27,6 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
useAutoLayout: ()=>useAutoLayout,
|
|
28
28
|
useMaintainNodesInView: ()=>useMaintainNodesInView,
|
|
29
29
|
useEnsureNodesInView: ()=>useEnsureNodesInView,
|
|
30
|
+
useReadOnlyBeforeDelete: ()=>useReadOnlyBeforeDelete,
|
|
30
31
|
useFitView: ()=>useFitView
|
|
31
32
|
});
|
|
32
33
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
@@ -237,15 +238,46 @@ const useMaintainNodesInView = (nodeIds, fitViewOptions)=>{
|
|
|
237
238
|
fitViewOptions
|
|
238
239
|
]);
|
|
239
240
|
};
|
|
241
|
+
function useReadOnlyBeforeDelete(readOnlyNodeIds, onBeforeDelete) {
|
|
242
|
+
return (0, external_react_namespaceObject.useMemo)(()=>{
|
|
243
|
+
if (0 === readOnlyNodeIds.size) return onBeforeDelete;
|
|
244
|
+
return async ({ nodes, edges })=>{
|
|
245
|
+
const upstream = onBeforeDelete ? await onBeforeDelete({
|
|
246
|
+
nodes,
|
|
247
|
+
edges
|
|
248
|
+
}) : true;
|
|
249
|
+
if (false === upstream) return false;
|
|
250
|
+
const candidate = true === upstream ? {
|
|
251
|
+
nodes,
|
|
252
|
+
edges
|
|
253
|
+
} : upstream;
|
|
254
|
+
const vetoedNodeIds = new Set();
|
|
255
|
+
const deletedNodeIds = new Set();
|
|
256
|
+
for (const node of candidate.nodes)(readOnlyNodeIds.has(node.id) ? vetoedNodeIds : deletedNodeIds).add(node.id);
|
|
257
|
+
if (0 === vetoedNodeIds.size) return candidate;
|
|
258
|
+
const touchesVetoedNode = (edge)=>vetoedNodeIds.has(edge.source) || vetoedNodeIds.has(edge.target);
|
|
259
|
+
const touchesDeletedNode = (edge)=>deletedNodeIds.has(edge.source) || deletedNodeIds.has(edge.target);
|
|
260
|
+
return {
|
|
261
|
+
nodes: candidate.nodes.filter((node)=>!vetoedNodeIds.has(node.id)),
|
|
262
|
+
edges: candidate.edges.filter((edge)=>!touchesVetoedNode(edge) || touchesDeletedNode(edge))
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
}, [
|
|
266
|
+
readOnlyNodeIds,
|
|
267
|
+
onBeforeDelete
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
240
270
|
exports.useAutoLayout = __webpack_exports__.useAutoLayout;
|
|
241
271
|
exports.useEnsureNodesInView = __webpack_exports__.useEnsureNodesInView;
|
|
242
272
|
exports.useFitView = __webpack_exports__.useFitView;
|
|
243
273
|
exports.useMaintainNodesInView = __webpack_exports__.useMaintainNodesInView;
|
|
274
|
+
exports.useReadOnlyBeforeDelete = __webpack_exports__.useReadOnlyBeforeDelete;
|
|
244
275
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
245
276
|
"useAutoLayout",
|
|
246
277
|
"useEnsureNodesInView",
|
|
247
278
|
"useFitView",
|
|
248
|
-
"useMaintainNodesInView"
|
|
279
|
+
"useMaintainNodesInView",
|
|
280
|
+
"useReadOnlyBeforeDelete"
|
|
249
281
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
250
282
|
Object.defineProperty(exports, '__esModule', {
|
|
251
283
|
value: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '../../xyflow/react.ts';
|
|
1
|
+
import type { Edge, Node, OnBeforeDelete } from '../../xyflow/react.ts';
|
|
2
2
|
import type { BaseCanvasFitViewOptions, EnsureNodesInViewOptions } from './BaseCanvas.types';
|
|
3
3
|
export declare const useAutoLayout: (nodes: Node[] | undefined, initialAutoLayout?: () => Promise<void> | void, fitViewOptions?: BaseCanvasFitViewOptions) => {
|
|
4
4
|
isReady: boolean;
|
|
@@ -12,4 +12,5 @@ export declare const useEnsureNodesInView: () => {
|
|
|
12
12
|
centerNode: (nodeId: string, options?: EnsureNodesInViewOptions) => void;
|
|
13
13
|
};
|
|
14
14
|
export declare const useMaintainNodesInView: (nodeIds?: string[], fitViewOptions?: BaseCanvasFitViewOptions) => void;
|
|
15
|
+
export declare function useReadOnlyBeforeDelete<NodeType extends Node, EdgeType extends Edge>(readOnlyNodeIds: ReadonlySet<string>, onBeforeDelete: OnBeforeDelete<NodeType, EdgeType> | undefined): OnBeforeDelete<NodeType, EdgeType> | undefined;
|
|
15
16
|
//# sourceMappingURL=BaseCanvas.hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCanvas.hooks.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseCanvas.hooks.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAI3F,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAqB7F,eAAO,MAAM,aAAa,GACxB,OAAO,IAAI,EAAE,GAAG,SAAS,EACzB,oBAAoB,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC9C,iBAAiB,wBAAwB;;CA+E1C,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,QAAQ,IAAI,EAAE,EACd,QAAQ,MAAM,EACd,iBAAiB,wBAAwB;;CAgC1C,CAAC;AAEF,eAAO,MAAM,oBAAoB;iCAInB,MAAM,EAAE,YAAY,wBAAwB;qCA4B3C,wBAAwB;yBAqB1B,MAAM,YAAY,wBAAwB;CAgCtD,CAAC;AAqCF,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,EAAE,EAClB,iBAAiB,wBAAwB,SAuE1C,CAAC;AAiBF,wBAAgB,uBAAuB,CAAC,QAAQ,SAAS,IAAI,EAAE,QAAQ,SAAS,IAAI,EAClF,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,EACpC,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,SAAS,GAC7D,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,SAAS,CA+BhD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useReactFlow, useStoreApi } from "../../xyflow/react.js";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { BASE_CANVAS_DEFAULTS, FIT_VIEW_DELAY_MS } from "./BaseCanvas.constants.js";
|
|
4
4
|
const waitForNodeMeasurements = (getNodes)=>new Promise((resolve)=>{
|
|
5
5
|
const startTime = Date.now();
|
|
@@ -206,4 +206,33 @@ const useMaintainNodesInView = (nodeIds, fitViewOptions)=>{
|
|
|
206
206
|
fitViewOptions
|
|
207
207
|
]);
|
|
208
208
|
};
|
|
209
|
-
|
|
209
|
+
function useReadOnlyBeforeDelete(readOnlyNodeIds, onBeforeDelete) {
|
|
210
|
+
return useMemo(()=>{
|
|
211
|
+
if (0 === readOnlyNodeIds.size) return onBeforeDelete;
|
|
212
|
+
return async ({ nodes, edges })=>{
|
|
213
|
+
const upstream = onBeforeDelete ? await onBeforeDelete({
|
|
214
|
+
nodes,
|
|
215
|
+
edges
|
|
216
|
+
}) : true;
|
|
217
|
+
if (false === upstream) return false;
|
|
218
|
+
const candidate = true === upstream ? {
|
|
219
|
+
nodes,
|
|
220
|
+
edges
|
|
221
|
+
} : upstream;
|
|
222
|
+
const vetoedNodeIds = new Set();
|
|
223
|
+
const deletedNodeIds = new Set();
|
|
224
|
+
for (const node of candidate.nodes)(readOnlyNodeIds.has(node.id) ? vetoedNodeIds : deletedNodeIds).add(node.id);
|
|
225
|
+
if (0 === vetoedNodeIds.size) return candidate;
|
|
226
|
+
const touchesVetoedNode = (edge)=>vetoedNodeIds.has(edge.source) || vetoedNodeIds.has(edge.target);
|
|
227
|
+
const touchesDeletedNode = (edge)=>deletedNodeIds.has(edge.source) || deletedNodeIds.has(edge.target);
|
|
228
|
+
return {
|
|
229
|
+
nodes: candidate.nodes.filter((node)=>!vetoedNodeIds.has(node.id)),
|
|
230
|
+
edges: candidate.edges.filter((edge)=>!touchesVetoedNode(edge) || touchesDeletedNode(edge))
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
}, [
|
|
234
|
+
readOnlyNodeIds,
|
|
235
|
+
onBeforeDelete
|
|
236
|
+
]);
|
|
237
|
+
}
|
|
238
|
+
export { useAutoLayout, useEnsureNodesInView, useFitView, useMaintainNodesInView, useReadOnlyBeforeDelete };
|
|
@@ -3,7 +3,7 @@ import { ConnectionMode, ReactFlow } from "../../xyflow/react.js";
|
|
|
3
3
|
import { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useState } from "react";
|
|
4
4
|
import { useToolbarActionStore } from "../../hooks/ToolbarActionContext.js";
|
|
5
5
|
import { BASE_CANVAS_DEFAULTS, PAN_ON_DRAG } from "./BaseCanvas.constants.js";
|
|
6
|
-
import { useAutoLayout, useEnsureNodesInView, useMaintainNodesInView } from "./BaseCanvas.hooks.js";
|
|
6
|
+
import { useAutoLayout, useEnsureNodesInView, useMaintainNodesInView, useReadOnlyBeforeDelete } from "./BaseCanvas.hooks.js";
|
|
7
7
|
import { CanvasBackground } from "./CanvasBackground.js";
|
|
8
8
|
import { CanvasProviders } from "./CanvasProviders.js";
|
|
9
9
|
import { PanShortcutTeachingUI } from "./PanShortcutTeachingUI.js";
|
|
@@ -11,10 +11,22 @@ import { useStableNodeIdSet } from "./ReadOnlyNodesContext.js";
|
|
|
11
11
|
const BaseCanvasInnerComponent = (props)=>{
|
|
12
12
|
const { innerRef, fitViewOptions: fitViewOptionsProps, ...canvasProps } = props;
|
|
13
13
|
const fitViewOptions = fitViewOptionsProps ?? BASE_CANVAS_DEFAULTS.fitViewOptions;
|
|
14
|
-
const { nodes = [], edges = [], nodeTypes, edgeTypes, children, mode = 'view', readOnlyNodeIds, showBackground = true, backgroundColor = BASE_CANVAS_DEFAULTS.background.color, backgroundSecondaryColor = BASE_CANVAS_DEFAULTS.background.bgColor, backgroundVariant = BASE_CANVAS_DEFAULTS.background.variant, backgroundGap = BASE_CANVAS_DEFAULTS.background.gap, backgroundSize = BASE_CANVAS_DEFAULTS.background.size, isDarkMode, locale, minZoom = BASE_CANVAS_DEFAULTS.zoom.min, maxZoom = BASE_CANVAS_DEFAULTS.zoom.max, defaultViewport = BASE_CANVAS_DEFAULTS.defaultViewport, defaultEdgeOptions = BASE_CANVAS_DEFAULTS.edge, stickyNoteOptions, onNodesChange, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onNodeClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onPaneClick, onInit, onSelectionChange, proOptions = BASE_CANVAS_DEFAULTS.pro, connectionMode = ConnectionMode.Loose, connectionLineComponent, connectionLineStyle, deleteKeyCode = null, selectNodesOnDrag = true, nodesDraggable = true, nodesConnectable = true, elementsSelectable = true, onlyRenderVisibleElements = true, zoomOnDoubleClick = true, snapToGrid = BASE_CANVAS_DEFAULTS.snapToGrid, snapGrid = BASE_CANVAS_DEFAULTS.snapGrid, initialAutoLayout, maintainNodesInView, onToolbarAction, breakpoints, panShortcutTeachingUIMessage = 'Hold Space and drag to pan around the canvas!', ...reactFlowProps } = canvasProps;
|
|
14
|
+
const { nodes = [], edges = [], nodeTypes, edgeTypes, children, mode = 'view', readOnlyNodeIds, showBackground = true, backgroundColor = BASE_CANVAS_DEFAULTS.background.color, backgroundSecondaryColor = BASE_CANVAS_DEFAULTS.background.bgColor, backgroundVariant = BASE_CANVAS_DEFAULTS.background.variant, backgroundGap = BASE_CANVAS_DEFAULTS.background.gap, backgroundSize = BASE_CANVAS_DEFAULTS.background.size, isDarkMode, locale, minZoom = BASE_CANVAS_DEFAULTS.zoom.min, maxZoom = BASE_CANVAS_DEFAULTS.zoom.max, defaultViewport = BASE_CANVAS_DEFAULTS.defaultViewport, defaultEdgeOptions = BASE_CANVAS_DEFAULTS.edge, stickyNoteOptions, onNodesChange, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onNodeClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onPaneClick, onInit, onSelectionChange, onBeforeDelete, proOptions = BASE_CANVAS_DEFAULTS.pro, connectionMode = ConnectionMode.Loose, connectionLineComponent, connectionLineStyle, deleteKeyCode = null, selectNodesOnDrag = true, nodesDraggable = true, nodesConnectable = true, elementsSelectable = true, onlyRenderVisibleElements = true, zoomOnDoubleClick = true, snapToGrid = BASE_CANVAS_DEFAULTS.snapToGrid, snapGrid = BASE_CANVAS_DEFAULTS.snapGrid, initialAutoLayout, maintainNodesInView, onToolbarAction, breakpoints, panShortcutTeachingUIMessage = 'Hold Space and drag to pan around the canvas!', ...reactFlowProps } = canvasProps;
|
|
15
15
|
const isInteractive = 'readonly' !== mode;
|
|
16
16
|
const isDesignMode = 'design' === mode;
|
|
17
17
|
const stableReadOnlyNodeIds = useStableNodeIdSet(readOnlyNodeIds);
|
|
18
|
+
const guardedBeforeDelete = useReadOnlyBeforeDelete(stableReadOnlyNodeIds, onBeforeDelete);
|
|
19
|
+
const handleNodesChange = useMemo(()=>{
|
|
20
|
+
if (!onNodesChange || 0 === stableReadOnlyNodeIds.size) return onNodesChange;
|
|
21
|
+
const guarded = (changes)=>{
|
|
22
|
+
const allowed = changes.filter((change)=>!('remove' === change.type && stableReadOnlyNodeIds.has(change.id)));
|
|
23
|
+
if (allowed.length > 0) onNodesChange(allowed);
|
|
24
|
+
};
|
|
25
|
+
return guarded;
|
|
26
|
+
}, [
|
|
27
|
+
onNodesChange,
|
|
28
|
+
stableReadOnlyNodeIds
|
|
29
|
+
]);
|
|
18
30
|
const [reactFlowInstance, setReactFlowInstance] = useState();
|
|
19
31
|
const { isReady } = useAutoLayout(nodes, initialAutoLayout, fitViewOptions);
|
|
20
32
|
const { ensureNodesInView, ensureAllNodesInView, centerNode } = useEnsureNodesInView();
|
|
@@ -80,8 +92,9 @@ const BaseCanvasInnerComponent = (props)=>{
|
|
|
80
92
|
zoomOnDoubleClick: isInteractive && zoomOnDoubleClick,
|
|
81
93
|
panOnDrag: isInteractive ? PAN_ON_DRAG : false,
|
|
82
94
|
onInit: handleInit,
|
|
83
|
-
onNodesChange: isInteractive ?
|
|
95
|
+
onNodesChange: isInteractive ? handleNodesChange : void 0,
|
|
84
96
|
onEdgesChange: isInteractive ? onEdgesChange : void 0,
|
|
97
|
+
onBeforeDelete: guardedBeforeDelete,
|
|
85
98
|
onConnect: isDesignMode ? onConnect : void 0,
|
|
86
99
|
onConnectStart: isDesignMode ? onConnectStart : void 0,
|
|
87
100
|
onConnectEnd: isDesignMode ? onConnectEnd : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCanvas.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,iBAAiB,EACjB,cAAc,EACf,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAMtF,MAAM,WAAW,wBAAwB;IAOvC,OAAO,CAAC,EACJ,MAAM,GACN;QACE,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAON,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AASD,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,CACzF,SAAQ,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAe1C,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseCanvas.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/BaseCanvas.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,iBAAiB,EACjB,cAAc,EACf,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAMtF,MAAM,WAAW,wBAAwB;IAOvC,OAAO,CAAC,EACJ,MAAM,GACN;QACE,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAON,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AASD,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,CACzF,SAAQ,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAe1C,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAmBtC,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAAC;IAM1D,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IAO5C,QAAQ,CAAC,EAAE,SAAS,CAAC;IAOrB,cAAc,CAAC,EAAE,OAAO,CAAC;IAKzB,eAAe,CAAC,EAAE,MAAM,CAAC;IAKzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAOlC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAOtC,aAAa,CAAC,EAAE,MAAM,CAAC;IAOvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAcxB,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAkB/C,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAM/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IAUtC,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAK1C,eAAe,CAAC,EAAE,oBAAoB,CAAC;IAMvC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAW1B,UAAU,CAAC,EAAE,OAAO,CAAC;IAOrB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAMD,MAAM,WAAW,wBAAwB;IAKvC,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAOjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AASD,MAAM,WAAW,aAAa,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI;IAgBvF,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAa/E,oBAAoB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAiB/D,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAyBrE,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC;CAC9D"}
|
|
@@ -79,88 +79,125 @@ var __webpack_exports__ = {};
|
|
|
79
79
|
__webpack_require__.r(__webpack_exports__);
|
|
80
80
|
__webpack_require__.d(__webpack_exports__, {
|
|
81
81
|
BaseCanvas: ()=>_BaseCanvas__rspack_import_0.BaseCanvas,
|
|
82
|
-
|
|
82
|
+
useAutoLayout: ()=>_BaseCanvas_hooks__rspack_import_2.useAutoLayout,
|
|
83
|
+
useEnsureNodesInView: ()=>_BaseCanvas_hooks__rspack_import_2.useEnsureNodesInView,
|
|
84
|
+
useFitView: ()=>_BaseCanvas_hooks__rspack_import_2.useFitView,
|
|
85
|
+
useIsNodeReadOnly: ()=>_ReadOnlyNodesContext__rspack_import_9.useIsNodeReadOnly,
|
|
86
|
+
useMaintainNodesInView: ()=>_BaseCanvas_hooks__rspack_import_2.useMaintainNodesInView
|
|
83
87
|
});
|
|
84
88
|
var _BaseCanvas__rspack_import_0 = __webpack_require__("./BaseCanvas?388c");
|
|
85
89
|
var _BaseCanvas_constants__rspack_import_1 = __webpack_require__("./BaseCanvas.constants");
|
|
86
90
|
var __rspack_reexport = {};
|
|
87
91
|
for(const __rspack_import_key in _BaseCanvas_constants__rspack_import_1)if ([
|
|
92
|
+
"useAutoLayout",
|
|
93
|
+
"useMaintainNodesInView",
|
|
94
|
+
"useEnsureNodesInView",
|
|
95
|
+
"default",
|
|
88
96
|
"useIsNodeReadOnly",
|
|
89
97
|
"BaseCanvas",
|
|
90
|
-
"
|
|
98
|
+
"useFitView"
|
|
91
99
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_BaseCanvas_constants__rspack_import_1[__rspack_import_key];
|
|
92
100
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
93
101
|
var _BaseCanvas_hooks__rspack_import_2 = __webpack_require__("./BaseCanvas.hooks");
|
|
94
|
-
var __rspack_reexport = {};
|
|
95
|
-
for(const __rspack_import_key in _BaseCanvas_hooks__rspack_import_2)if ([
|
|
96
|
-
"useIsNodeReadOnly",
|
|
97
|
-
"BaseCanvas",
|
|
98
|
-
"default"
|
|
99
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_BaseCanvas_hooks__rspack_import_2[__rspack_import_key];
|
|
100
|
-
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
101
102
|
var _BaseCanvas_types__rspack_import_3 = __webpack_require__("./BaseCanvas.types");
|
|
102
103
|
var __rspack_reexport = {};
|
|
103
104
|
for(const __rspack_import_key in _BaseCanvas_types__rspack_import_3)if ([
|
|
105
|
+
"useAutoLayout",
|
|
106
|
+
"useMaintainNodesInView",
|
|
107
|
+
"useEnsureNodesInView",
|
|
108
|
+
"default",
|
|
104
109
|
"useIsNodeReadOnly",
|
|
105
110
|
"BaseCanvas",
|
|
106
|
-
"
|
|
111
|
+
"useFitView"
|
|
107
112
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_BaseCanvas_types__rspack_import_3[__rspack_import_key];
|
|
108
113
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
109
114
|
var _BaseCanvasModeProvider__rspack_import_4 = __webpack_require__("./BaseCanvasModeProvider");
|
|
110
115
|
var __rspack_reexport = {};
|
|
111
116
|
for(const __rspack_import_key in _BaseCanvasModeProvider__rspack_import_4)if ([
|
|
117
|
+
"useAutoLayout",
|
|
118
|
+
"useMaintainNodesInView",
|
|
119
|
+
"useEnsureNodesInView",
|
|
120
|
+
"default",
|
|
112
121
|
"useIsNodeReadOnly",
|
|
113
122
|
"BaseCanvas",
|
|
114
|
-
"
|
|
123
|
+
"useFitView"
|
|
115
124
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_BaseCanvasModeProvider__rspack_import_4[__rspack_import_key];
|
|
116
125
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
117
126
|
var _CanvasBackground__rspack_import_5 = __webpack_require__("./CanvasBackground");
|
|
118
127
|
var __rspack_reexport = {};
|
|
119
128
|
for(const __rspack_import_key in _CanvasBackground__rspack_import_5)if ([
|
|
129
|
+
"useAutoLayout",
|
|
130
|
+
"useMaintainNodesInView",
|
|
131
|
+
"useEnsureNodesInView",
|
|
132
|
+
"default",
|
|
120
133
|
"useIsNodeReadOnly",
|
|
121
134
|
"BaseCanvas",
|
|
122
|
-
"
|
|
135
|
+
"useFitView"
|
|
123
136
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_CanvasBackground__rspack_import_5[__rspack_import_key];
|
|
124
137
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
125
138
|
var _CanvasProviders__rspack_import_6 = __webpack_require__("./CanvasProviders");
|
|
126
139
|
var __rspack_reexport = {};
|
|
127
140
|
for(const __rspack_import_key in _CanvasProviders__rspack_import_6)if ([
|
|
141
|
+
"useAutoLayout",
|
|
142
|
+
"useMaintainNodesInView",
|
|
143
|
+
"useEnsureNodesInView",
|
|
144
|
+
"default",
|
|
128
145
|
"useIsNodeReadOnly",
|
|
129
146
|
"BaseCanvas",
|
|
130
|
-
"
|
|
147
|
+
"useFitView"
|
|
131
148
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_CanvasProviders__rspack_import_6[__rspack_import_key];
|
|
132
149
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
133
150
|
var _CanvasThemeContext__rspack_import_7 = __webpack_require__("./CanvasThemeContext");
|
|
134
151
|
var __rspack_reexport = {};
|
|
135
152
|
for(const __rspack_import_key in _CanvasThemeContext__rspack_import_7)if ([
|
|
153
|
+
"useAutoLayout",
|
|
154
|
+
"useMaintainNodesInView",
|
|
155
|
+
"useEnsureNodesInView",
|
|
156
|
+
"default",
|
|
136
157
|
"useIsNodeReadOnly",
|
|
137
158
|
"BaseCanvas",
|
|
138
|
-
"
|
|
159
|
+
"useFitView"
|
|
139
160
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_CanvasThemeContext__rspack_import_7[__rspack_import_key];
|
|
140
161
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
141
162
|
var _ConnectedHandlesContext__rspack_import_8 = __webpack_require__("./ConnectedHandlesContext");
|
|
142
163
|
var __rspack_reexport = {};
|
|
143
164
|
for(const __rspack_import_key in _ConnectedHandlesContext__rspack_import_8)if ([
|
|
165
|
+
"useAutoLayout",
|
|
166
|
+
"useMaintainNodesInView",
|
|
167
|
+
"useEnsureNodesInView",
|
|
168
|
+
"default",
|
|
144
169
|
"useIsNodeReadOnly",
|
|
145
170
|
"BaseCanvas",
|
|
146
|
-
"
|
|
171
|
+
"useFitView"
|
|
147
172
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_ConnectedHandlesContext__rspack_import_8[__rspack_import_key];
|
|
148
173
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
149
174
|
var _ReadOnlyNodesContext__rspack_import_9 = __webpack_require__("./ReadOnlyNodesContext");
|
|
150
175
|
var _SelectionStateContext__rspack_import_10 = __webpack_require__("./SelectionStateContext");
|
|
151
176
|
var __rspack_reexport = {};
|
|
152
177
|
for(const __rspack_import_key in _SelectionStateContext__rspack_import_10)if ([
|
|
178
|
+
"useAutoLayout",
|
|
179
|
+
"useMaintainNodesInView",
|
|
180
|
+
"useEnsureNodesInView",
|
|
181
|
+
"default",
|
|
153
182
|
"useIsNodeReadOnly",
|
|
154
183
|
"BaseCanvas",
|
|
155
|
-
"
|
|
184
|
+
"useFitView"
|
|
156
185
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_SelectionStateContext__rspack_import_10[__rspack_import_key];
|
|
157
186
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
158
187
|
})();
|
|
159
188
|
exports.BaseCanvas = __webpack_exports__.BaseCanvas;
|
|
189
|
+
exports.useAutoLayout = __webpack_exports__.useAutoLayout;
|
|
190
|
+
exports.useEnsureNodesInView = __webpack_exports__.useEnsureNodesInView;
|
|
191
|
+
exports.useFitView = __webpack_exports__.useFitView;
|
|
160
192
|
exports.useIsNodeReadOnly = __webpack_exports__.useIsNodeReadOnly;
|
|
193
|
+
exports.useMaintainNodesInView = __webpack_exports__.useMaintainNodesInView;
|
|
161
194
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
162
195
|
"BaseCanvas",
|
|
163
|
-
"
|
|
196
|
+
"useAutoLayout",
|
|
197
|
+
"useEnsureNodesInView",
|
|
198
|
+
"useFitView",
|
|
199
|
+
"useIsNodeReadOnly",
|
|
200
|
+
"useMaintainNodesInView"
|
|
164
201
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
165
202
|
Object.defineProperty(exports, '__esModule', {
|
|
166
203
|
value: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BaseCanvas } from './BaseCanvas';
|
|
2
2
|
export * from './BaseCanvas.constants';
|
|
3
|
-
export
|
|
3
|
+
export { useAutoLayout, useEnsureNodesInView, useFitView, useMaintainNodesInView, } from './BaseCanvas.hooks';
|
|
4
4
|
export * from './BaseCanvas.types';
|
|
5
5
|
export * from './BaseCanvasModeProvider';
|
|
6
6
|
export * from './CanvasBackground';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseCanvas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAG1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseCanvas } from "./BaseCanvas.js";
|
|
2
|
+
import { useAutoLayout, useEnsureNodesInView, useFitView, useMaintainNodesInView } from "./BaseCanvas.hooks.js";
|
|
2
3
|
import { useIsNodeReadOnly } from "./ReadOnlyNodesContext.js";
|
|
3
4
|
export * from "./BaseCanvas.constants.js";
|
|
4
|
-
export * from "./BaseCanvas.hooks.js";
|
|
5
5
|
export * from "./BaseCanvas.types.js";
|
|
6
6
|
export * from "./BaseCanvasModeProvider.js";
|
|
7
7
|
export * from "./CanvasBackground.js";
|
|
@@ -9,4 +9,4 @@ export * from "./CanvasProviders.js";
|
|
|
9
9
|
export * from "./CanvasThemeContext.js";
|
|
10
10
|
export * from "./ConnectedHandlesContext.js";
|
|
11
11
|
export * from "./SelectionStateContext.js";
|
|
12
|
-
export { BaseCanvas, useIsNodeReadOnly };
|
|
12
|
+
export { BaseCanvas, useAutoLayout, useEnsureNodesInView, useFitView, useIsNodeReadOnly, useMaintainNodesInView };
|
|
@@ -41,6 +41,7 @@ const toolbar_resolver_cjs_namespaceObject = require("../../utils/toolbar-resolv
|
|
|
41
41
|
const BaseCanvasModeProvider_cjs_namespaceObject = require("../BaseCanvas/BaseCanvasModeProvider.cjs");
|
|
42
42
|
const CanvasThemeContext_cjs_namespaceObject = require("../BaseCanvas/CanvasThemeContext.cjs");
|
|
43
43
|
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
|
|
44
|
+
const ReadOnlyNodesContext_cjs_namespaceObject = require("../BaseCanvas/ReadOnlyNodesContext.cjs");
|
|
44
45
|
const SelectionStateContext_cjs_namespaceObject = require("../BaseCanvas/SelectionStateContext.cjs");
|
|
45
46
|
const SmartHandle_cjs_namespaceObject = require("../ButtonHandle/SmartHandle.cjs");
|
|
46
47
|
const useButtonHandles_cjs_namespaceObject = require("../ButtonHandle/useButtonHandles.cjs");
|
|
@@ -52,6 +53,11 @@ const external_BaseNodeContainer_cjs_namespaceObject = require("./BaseNodeContai
|
|
|
52
53
|
const external_BaseNodeInnerShape_cjs_namespaceObject = require("./BaseNodeInnerShape.cjs");
|
|
53
54
|
const external_BaseNodeMissingManifest_cjs_namespaceObject = require("./BaseNodeMissingManifest.cjs");
|
|
54
55
|
const external_NodeLabel_cjs_namespaceObject = require("./NodeLabel.cjs");
|
|
56
|
+
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
57
|
+
const disableToolbarActions = (actions)=>actions.map((action)=>'separator' === action.id ? action : {
|
|
58
|
+
...action,
|
|
59
|
+
disabled: true
|
|
60
|
+
});
|
|
55
61
|
const getContainerWidth = (shape, width)=>{
|
|
56
62
|
const defaultWidth = 'rectangle' === shape ? external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH : external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE;
|
|
57
63
|
if (width && width !== external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE && width !== external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -80,6 +86,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
80
86
|
const validationState = (0, external_hooks_index_cjs_namespaceObject.useElementValidationStatus)(id);
|
|
81
87
|
const nodeTypeRegistry = (0, index_cjs_namespaceObject.useNodeTypeRegistry)();
|
|
82
88
|
const { mode } = (0, BaseCanvasModeProvider_cjs_namespaceObject.useBaseCanvasMode)();
|
|
89
|
+
const isNodeReadOnly = (0, ReadOnlyNodesContext_cjs_namespaceObject.useIsNodeReadOnly)(id);
|
|
90
|
+
const canEdit = 'design' === mode && !isNodeReadOnly;
|
|
83
91
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
84
92
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)(NodeUtils_cjs_namespaceObject.selectIsConnecting);
|
|
85
93
|
const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
|
|
@@ -107,7 +115,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
107
115
|
mode
|
|
108
116
|
]);
|
|
109
117
|
const onHandleActionCallback = onHandleActionProp;
|
|
110
|
-
const shouldShowAddButtonFn = shouldShowAddButtonFnProp;
|
|
118
|
+
const shouldShowAddButtonFn = isNodeReadOnly ? NEVER_SHOW_ADD_BUTTON : shouldShowAddButtonFnProp;
|
|
111
119
|
const shouldShowButtonHandleNotchesFn = shouldShowButtonHandleNotchesFnProp;
|
|
112
120
|
const executionStatus = executionStatusOverride ?? ('string' == typeof executionState ? executionState : executionState?.status);
|
|
113
121
|
const display = (0, external_react_namespaceObject.useMemo)(()=>(0, manifest_resolver_cjs_namespaceObject.resolveDisplay)(manifest?.display, {
|
|
@@ -171,6 +179,19 @@ const BaseNodeComponent = (props)=>{
|
|
|
171
179
|
manifest,
|
|
172
180
|
statusContext
|
|
173
181
|
]);
|
|
182
|
+
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
183
|
+
if (!toolbarConfig || !isNodeReadOnly) return toolbarConfig;
|
|
184
|
+
return {
|
|
185
|
+
...toolbarConfig,
|
|
186
|
+
actions: disableToolbarActions(toolbarConfig.actions),
|
|
187
|
+
...toolbarConfig.overflowActions && {
|
|
188
|
+
overflowActions: disableToolbarActions(toolbarConfig.overflowActions)
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}, [
|
|
192
|
+
toolbarConfig,
|
|
193
|
+
isNodeReadOnly
|
|
194
|
+
]);
|
|
174
195
|
const adornments = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
175
196
|
const adornmentsFromProps = adornmentsProp ?? {};
|
|
176
197
|
const adornmentsFromResolver = (0, adornment_resolver_cjs_namespaceObject.resolveAdornments)(statusContext);
|
|
@@ -339,8 +360,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
339
360
|
if (multipleNodesSelected) return false;
|
|
340
361
|
const { hasButton, hasLabel } = toolbarSideHandleAffordances;
|
|
341
362
|
const isAddButtonShown = ()=>{
|
|
342
|
-
if (useSmartHandles) return
|
|
343
|
-
const showAddButton =
|
|
363
|
+
if (useSmartHandles) return canEdit && !!selected;
|
|
364
|
+
const showAddButton = canEdit && !isConnecting && !dragging;
|
|
344
365
|
if (shouldShowAddButtonFn) return shouldShowAddButtonFn({
|
|
345
366
|
showAddButton,
|
|
346
367
|
selected: !!selected
|
|
@@ -352,7 +373,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
352
373
|
return false;
|
|
353
374
|
}, [
|
|
354
375
|
toolbarSideHandleAffordances,
|
|
355
|
-
|
|
376
|
+
canEdit,
|
|
356
377
|
multipleNodesSelected,
|
|
357
378
|
useSmartHandles,
|
|
358
379
|
selected,
|
|
@@ -370,7 +391,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
370
391
|
nodeId: id,
|
|
371
392
|
selected: selected ?? false,
|
|
372
393
|
hovered: isHovered,
|
|
373
|
-
showAddButton:
|
|
394
|
+
showAddButton: canEdit && !multipleNodesSelected && !isConnecting && !dragging,
|
|
374
395
|
showNotches,
|
|
375
396
|
nodeWidth: containerWidth,
|
|
376
397
|
nodeHeight: computedHeight,
|
|
@@ -388,7 +409,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
388
409
|
const handleVisualType = handle.handleType ?? ('source' === handle.type ? 'output' : 'input');
|
|
389
410
|
const hasConnection = connectedHandleIds.has(handle.id);
|
|
390
411
|
const isVisible = hasConnection || shouldShowHandles && configVisible;
|
|
391
|
-
const shouldShowButton =
|
|
412
|
+
const shouldShowButton = canEdit && selected && handle.showButton && !multipleNodesSelected;
|
|
392
413
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SmartHandle_cjs_namespaceObject.SmartHandle, {
|
|
393
414
|
type: handle.type,
|
|
394
415
|
id: handle.id,
|
|
@@ -412,7 +433,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
412
433
|
shouldShowHandles,
|
|
413
434
|
containerWidth,
|
|
414
435
|
computedHeight,
|
|
415
|
-
|
|
436
|
+
canEdit,
|
|
416
437
|
selected,
|
|
417
438
|
showNotches,
|
|
418
439
|
handleAction,
|
|
@@ -493,7 +514,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
493
514
|
hasBottomHandles: hasVisibleBottomHandles,
|
|
494
515
|
selected: selected,
|
|
495
516
|
dragging: dragging,
|
|
496
|
-
readonly:
|
|
517
|
+
readonly: !canEdit,
|
|
518
|
+
discardDraftOnReadonly: isNodeReadOnly,
|
|
497
519
|
onChange: handleLabelChange
|
|
498
520
|
}),
|
|
499
521
|
displayFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
@@ -502,9 +524,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
502
524
|
})
|
|
503
525
|
]
|
|
504
526
|
}),
|
|
505
|
-
|
|
527
|
+
effectiveToolbarConfig && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbar_index_cjs_namespaceObject.NodeToolbar, {
|
|
506
528
|
nodeId: id,
|
|
507
|
-
config:
|
|
529
|
+
config: effectiveToolbarConfig,
|
|
508
530
|
expanded: selected || isHovered,
|
|
509
531
|
hidden: dragging || multipleNodesSelected,
|
|
510
532
|
offsetToolbar: offsetToolbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AA8ChF,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AAqtB1B,eAAO,MAAM,QAAQ,8CAzqBa,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,6CAyqBmB,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { resolveToolbar } from "../../utils/toolbar-resolver.js";
|
|
|
13
13
|
import { useBaseCanvasMode } from "../BaseCanvas/BaseCanvasModeProvider.js";
|
|
14
14
|
import { useCanvasTheme } from "../BaseCanvas/CanvasThemeContext.js";
|
|
15
15
|
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
16
|
+
import { useIsNodeReadOnly } from "../BaseCanvas/ReadOnlyNodesContext.js";
|
|
16
17
|
import { useSelectionState } from "../BaseCanvas/SelectionStateContext.js";
|
|
17
18
|
import { SmartHandle, SmartHandleProvider } from "../ButtonHandle/SmartHandle.js";
|
|
18
19
|
import { useButtonHandles } from "../ButtonHandle/useButtonHandles.js";
|
|
@@ -24,6 +25,11 @@ import { BaseContainer } from "./BaseNodeContainer.js";
|
|
|
24
25
|
import { BaseInnerShape } from "./BaseNodeInnerShape.js";
|
|
25
26
|
import { MissingManifestNode } from "./BaseNodeMissingManifest.js";
|
|
26
27
|
import { NodeLabel } from "./NodeLabel.js";
|
|
28
|
+
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
29
|
+
const disableToolbarActions = (actions)=>actions.map((action)=>'separator' === action.id ? action : {
|
|
30
|
+
...action,
|
|
31
|
+
disabled: true
|
|
32
|
+
});
|
|
27
33
|
const getContainerWidth = (shape, width)=>{
|
|
28
34
|
const defaultWidth = 'rectangle' === shape ? DEFAULT_RECTANGLE_NODE_WIDTH : DEFAULT_NODE_SIZE;
|
|
29
35
|
if (width && width !== DEFAULT_NODE_SIZE && width !== DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -52,6 +58,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
52
58
|
const validationState = useElementValidationStatus(id);
|
|
53
59
|
const nodeTypeRegistry = useNodeTypeRegistry();
|
|
54
60
|
const { mode } = useBaseCanvasMode();
|
|
61
|
+
const isNodeReadOnly = useIsNodeReadOnly(id);
|
|
62
|
+
const canEdit = 'design' === mode && !isNodeReadOnly;
|
|
55
63
|
const connectedHandleIds = useConnectedHandles(id);
|
|
56
64
|
const isConnecting = useStore(selectIsConnecting);
|
|
57
65
|
const { multipleNodesSelected } = useSelectionState();
|
|
@@ -79,7 +87,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
79
87
|
mode
|
|
80
88
|
]);
|
|
81
89
|
const onHandleActionCallback = onHandleActionProp;
|
|
82
|
-
const shouldShowAddButtonFn = shouldShowAddButtonFnProp;
|
|
90
|
+
const shouldShowAddButtonFn = isNodeReadOnly ? NEVER_SHOW_ADD_BUTTON : shouldShowAddButtonFnProp;
|
|
83
91
|
const shouldShowButtonHandleNotchesFn = shouldShowButtonHandleNotchesFnProp;
|
|
84
92
|
const executionStatus = executionStatusOverride ?? ('string' == typeof executionState ? executionState : executionState?.status);
|
|
85
93
|
const display = useMemo(()=>resolveDisplay(manifest?.display, {
|
|
@@ -143,6 +151,19 @@ const BaseNodeComponent = (props)=>{
|
|
|
143
151
|
manifest,
|
|
144
152
|
statusContext
|
|
145
153
|
]);
|
|
154
|
+
const effectiveToolbarConfig = useMemo(()=>{
|
|
155
|
+
if (!toolbarConfig || !isNodeReadOnly) return toolbarConfig;
|
|
156
|
+
return {
|
|
157
|
+
...toolbarConfig,
|
|
158
|
+
actions: disableToolbarActions(toolbarConfig.actions),
|
|
159
|
+
...toolbarConfig.overflowActions && {
|
|
160
|
+
overflowActions: disableToolbarActions(toolbarConfig.overflowActions)
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}, [
|
|
164
|
+
toolbarConfig,
|
|
165
|
+
isNodeReadOnly
|
|
166
|
+
]);
|
|
146
167
|
const adornments = useMemo(()=>{
|
|
147
168
|
const adornmentsFromProps = adornmentsProp ?? {};
|
|
148
169
|
const adornmentsFromResolver = resolveAdornments(statusContext);
|
|
@@ -311,8 +332,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
311
332
|
if (multipleNodesSelected) return false;
|
|
312
333
|
const { hasButton, hasLabel } = toolbarSideHandleAffordances;
|
|
313
334
|
const isAddButtonShown = ()=>{
|
|
314
|
-
if (useSmartHandles) return
|
|
315
|
-
const showAddButton =
|
|
335
|
+
if (useSmartHandles) return canEdit && !!selected;
|
|
336
|
+
const showAddButton = canEdit && !isConnecting && !dragging;
|
|
316
337
|
if (shouldShowAddButtonFn) return shouldShowAddButtonFn({
|
|
317
338
|
showAddButton,
|
|
318
339
|
selected: !!selected
|
|
@@ -324,7 +345,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
324
345
|
return false;
|
|
325
346
|
}, [
|
|
326
347
|
toolbarSideHandleAffordances,
|
|
327
|
-
|
|
348
|
+
canEdit,
|
|
328
349
|
multipleNodesSelected,
|
|
329
350
|
useSmartHandles,
|
|
330
351
|
selected,
|
|
@@ -342,7 +363,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
342
363
|
nodeId: id,
|
|
343
364
|
selected: selected ?? false,
|
|
344
365
|
hovered: isHovered,
|
|
345
|
-
showAddButton:
|
|
366
|
+
showAddButton: canEdit && !multipleNodesSelected && !isConnecting && !dragging,
|
|
346
367
|
showNotches,
|
|
347
368
|
nodeWidth: containerWidth,
|
|
348
369
|
nodeHeight: computedHeight,
|
|
@@ -360,7 +381,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
360
381
|
const handleVisualType = handle.handleType ?? ('source' === handle.type ? 'output' : 'input');
|
|
361
382
|
const hasConnection = connectedHandleIds.has(handle.id);
|
|
362
383
|
const isVisible = hasConnection || shouldShowHandles && configVisible;
|
|
363
|
-
const shouldShowButton =
|
|
384
|
+
const shouldShowButton = canEdit && selected && handle.showButton && !multipleNodesSelected;
|
|
364
385
|
return /*#__PURE__*/ jsx(SmartHandle, {
|
|
365
386
|
type: handle.type,
|
|
366
387
|
id: handle.id,
|
|
@@ -384,7 +405,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
384
405
|
shouldShowHandles,
|
|
385
406
|
containerWidth,
|
|
386
407
|
computedHeight,
|
|
387
|
-
|
|
408
|
+
canEdit,
|
|
388
409
|
selected,
|
|
389
410
|
showNotches,
|
|
390
411
|
handleAction,
|
|
@@ -465,7 +486,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
465
486
|
hasBottomHandles: hasVisibleBottomHandles,
|
|
466
487
|
selected: selected,
|
|
467
488
|
dragging: dragging,
|
|
468
|
-
readonly:
|
|
489
|
+
readonly: !canEdit,
|
|
490
|
+
discardDraftOnReadonly: isNodeReadOnly,
|
|
469
491
|
onChange: handleLabelChange
|
|
470
492
|
}),
|
|
471
493
|
displayFooter && /*#__PURE__*/ jsx("div", {
|
|
@@ -474,9 +496,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
474
496
|
})
|
|
475
497
|
]
|
|
476
498
|
}),
|
|
477
|
-
|
|
499
|
+
effectiveToolbarConfig && /*#__PURE__*/ jsx(NodeToolbar, {
|
|
478
500
|
nodeId: id,
|
|
479
|
-
config:
|
|
501
|
+
config: effectiveToolbarConfig,
|
|
480
502
|
expanded: selected || isHovered,
|
|
481
503
|
hidden: dragging || multipleNodesSelected,
|
|
482
504
|
offsetToolbar: offsetToolbar
|
|
@@ -95,14 +95,15 @@ const EditableLabel = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRe
|
|
|
95
95
|
} : void 0
|
|
96
96
|
}));
|
|
97
97
|
EditableLabel.displayName = 'EditableLabel';
|
|
98
|
-
const EmptyLabelPlaceholder = ({ onDoubleClick })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
98
|
+
const EmptyLabelPlaceholder = ({ disabled, onDoubleClick })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
99
99
|
type: "button",
|
|
100
|
+
disabled: disabled,
|
|
100
101
|
onDoubleClick: onDoubleClick,
|
|
101
102
|
className: "nodrag nowheel text-sm leading-[18px] font-semibold text-foreground-muted bg-transparent border border-dashed border-border-de-emp rounded-sm cursor-pointer opacity-0 transition-opacity duration-200 min-w-5 min-h-5 hover:opacity-100",
|
|
102
103
|
"aria-label": "Add node label",
|
|
103
104
|
"data-testid": "empty-label-placeholder"
|
|
104
105
|
});
|
|
105
|
-
const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, onChange })=>{
|
|
106
|
+
const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, discardDraftOnReadonly, onChange })=>{
|
|
106
107
|
const [isEditing, setIsEditing] = (0, external_react_namespaceObject.useState)(false);
|
|
107
108
|
const [localLabel, setLocalLabel] = (0, external_react_namespaceObject.useState)('');
|
|
108
109
|
const [localSubLabel, setLocalSubLabel] = (0, external_react_namespaceObject.useState)('');
|
|
@@ -147,15 +148,6 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
147
148
|
isEditing,
|
|
148
149
|
focusTarget
|
|
149
150
|
]);
|
|
150
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
151
|
-
if (isEditing && (!selected || dragging || readonly)) handleSave();
|
|
152
|
-
}, [
|
|
153
|
-
selected,
|
|
154
|
-
dragging,
|
|
155
|
-
isEditing,
|
|
156
|
-
readonly,
|
|
157
|
-
handleSave
|
|
158
|
-
]);
|
|
159
151
|
const handleCancel = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
160
152
|
setIsEditing(false);
|
|
161
153
|
setFocusTarget(null);
|
|
@@ -165,6 +157,19 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
165
157
|
label,
|
|
166
158
|
subLabel
|
|
167
159
|
]);
|
|
160
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
161
|
+
if (!isEditing) return;
|
|
162
|
+
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
163
|
+
else if (!selected || dragging || readonly) handleSave();
|
|
164
|
+
}, [
|
|
165
|
+
selected,
|
|
166
|
+
dragging,
|
|
167
|
+
isEditing,
|
|
168
|
+
readonly,
|
|
169
|
+
discardDraftOnReadonly,
|
|
170
|
+
handleSave,
|
|
171
|
+
handleCancel
|
|
172
|
+
]);
|
|
168
173
|
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
169
174
|
if ('Enter' === e.key) {
|
|
170
175
|
e.preventDefault();
|
|
@@ -191,6 +196,7 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
191
196
|
shape: shape,
|
|
192
197
|
children: [
|
|
193
198
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyLabelPlaceholder, {
|
|
199
|
+
disabled: readonly,
|
|
194
200
|
onDoubleClick: readonly ? void 0 : handleDoubleClick(labelInputRef)
|
|
195
201
|
}),
|
|
196
202
|
centerAdornment
|
|
@@ -16,11 +16,12 @@ export interface NodeLabelProps {
|
|
|
16
16
|
dragging?: boolean;
|
|
17
17
|
centerAdornment?: React.ReactNode;
|
|
18
18
|
readonly?: boolean;
|
|
19
|
+
discardDraftOnReadonly?: boolean;
|
|
19
20
|
onChange?: (values: {
|
|
20
21
|
label: string;
|
|
21
22
|
subLabel: string;
|
|
22
23
|
}) => void;
|
|
23
24
|
}
|
|
24
|
-
export declare const NodeLabel: import("react").MemoExoticComponent<({ label, subLabel, labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, onChange, }: NodeLabelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
25
|
+
export declare const NodeLabel: import("react").MemoExoticComponent<({ label, subLabel, labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, discardDraftOnReadonly, onChange, }: NodeLabelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=NodeLabel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeLabel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/NodeLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,UAAU,sBAAsB;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,GAAI,wCAI/B,sBAAsB,4CAmBxB,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeLabel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/NodeLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,UAAU,sBAAsB;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,GAAI,wCAI/B,sBAAsB,4CAmBxB,CAAC;AAyKF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAClE;AAkMD,eAAO,MAAM,SAAS,2MAnLnB,cAAc,6CAmL+B,CAAC"}
|
|
@@ -66,14 +66,15 @@ const EditableLabel = /*#__PURE__*/ forwardRef(({ shape, backgroundColor, varian
|
|
|
66
66
|
} : void 0
|
|
67
67
|
}));
|
|
68
68
|
EditableLabel.displayName = 'EditableLabel';
|
|
69
|
-
const EmptyLabelPlaceholder = ({ onDoubleClick })=>/*#__PURE__*/ jsx("button", {
|
|
69
|
+
const EmptyLabelPlaceholder = ({ disabled, onDoubleClick })=>/*#__PURE__*/ jsx("button", {
|
|
70
70
|
type: "button",
|
|
71
|
+
disabled: disabled,
|
|
71
72
|
onDoubleClick: onDoubleClick,
|
|
72
73
|
className: "nodrag nowheel text-sm leading-[18px] font-semibold text-foreground-muted bg-transparent border border-dashed border-border-de-emp rounded-sm cursor-pointer opacity-0 transition-opacity duration-200 min-w-5 min-h-5 hover:opacity-100",
|
|
73
74
|
"aria-label": "Add node label",
|
|
74
75
|
"data-testid": "empty-label-placeholder"
|
|
75
76
|
});
|
|
76
|
-
const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, onChange })=>{
|
|
77
|
+
const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, discardDraftOnReadonly, onChange })=>{
|
|
77
78
|
const [isEditing, setIsEditing] = useState(false);
|
|
78
79
|
const [localLabel, setLocalLabel] = useState('');
|
|
79
80
|
const [localSubLabel, setLocalSubLabel] = useState('');
|
|
@@ -118,15 +119,6 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
118
119
|
isEditing,
|
|
119
120
|
focusTarget
|
|
120
121
|
]);
|
|
121
|
-
useEffect(()=>{
|
|
122
|
-
if (isEditing && (!selected || dragging || readonly)) handleSave();
|
|
123
|
-
}, [
|
|
124
|
-
selected,
|
|
125
|
-
dragging,
|
|
126
|
-
isEditing,
|
|
127
|
-
readonly,
|
|
128
|
-
handleSave
|
|
129
|
-
]);
|
|
130
122
|
const handleCancel = useCallback(()=>{
|
|
131
123
|
setIsEditing(false);
|
|
132
124
|
setFocusTarget(null);
|
|
@@ -136,6 +128,19 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
136
128
|
label,
|
|
137
129
|
subLabel
|
|
138
130
|
]);
|
|
131
|
+
useEffect(()=>{
|
|
132
|
+
if (!isEditing) return;
|
|
133
|
+
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
134
|
+
else if (!selected || dragging || readonly) handleSave();
|
|
135
|
+
}, [
|
|
136
|
+
selected,
|
|
137
|
+
dragging,
|
|
138
|
+
isEditing,
|
|
139
|
+
readonly,
|
|
140
|
+
discardDraftOnReadonly,
|
|
141
|
+
handleSave,
|
|
142
|
+
handleCancel
|
|
143
|
+
]);
|
|
139
144
|
const handleKeyDown = useCallback((e)=>{
|
|
140
145
|
if ('Enter' === e.key) {
|
|
141
146
|
e.preventDefault();
|
|
@@ -162,6 +167,7 @@ const NodeLabelInternal = ({ label = '', subLabel = '', labelTooltip, labelBackg
|
|
|
162
167
|
shape: shape,
|
|
163
168
|
children: [
|
|
164
169
|
/*#__PURE__*/ jsx(EmptyLabelPlaceholder, {
|
|
170
|
+
disabled: readonly,
|
|
165
171
|
onDoubleClick: readonly ? void 0 : handleDoubleClick(labelInputRef)
|
|
166
172
|
}),
|
|
167
173
|
centerAdornment
|
|
@@ -40,32 +40,37 @@ const ToolbarButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({
|
|
|
40
40
|
e.preventDefault();
|
|
41
41
|
if (isEnabled) action.onClick();
|
|
42
42
|
};
|
|
43
|
+
const button = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ToolbarIconButton_cjs_namespaceObject.ToolbarIconButton, {
|
|
44
|
+
layout: layoutId ? true : void 0,
|
|
45
|
+
layoutId: layoutId,
|
|
46
|
+
transition: {
|
|
47
|
+
type: 'tween',
|
|
48
|
+
duration: 0.2,
|
|
49
|
+
ease: 'easeOut'
|
|
50
|
+
},
|
|
51
|
+
type: "button",
|
|
52
|
+
className: "nodrag nopan",
|
|
53
|
+
onClick: handleClick,
|
|
54
|
+
"aria-label": action.label,
|
|
55
|
+
"aria-disabled": !isEnabled,
|
|
56
|
+
"aria-pressed": action.isToggled,
|
|
57
|
+
disabled: !isEnabled,
|
|
58
|
+
isToggled: action.isToggled,
|
|
59
|
+
color: action.color,
|
|
60
|
+
hoverBg: hoverBg,
|
|
61
|
+
children: action.icon && 'string' == typeof action.icon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
|
|
62
|
+
icon: action.icon,
|
|
63
|
+
size: 16,
|
|
64
|
+
color: action.color
|
|
65
|
+
}) : action.icon
|
|
66
|
+
});
|
|
43
67
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
44
68
|
content: action.label,
|
|
45
69
|
placement: "top",
|
|
46
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
type: 'tween',
|
|
51
|
-
duration: 0.2,
|
|
52
|
-
ease: 'easeOut'
|
|
53
|
-
},
|
|
54
|
-
type: "button",
|
|
55
|
-
className: "nodrag nopan",
|
|
56
|
-
onClick: handleClick,
|
|
57
|
-
"aria-label": action.label,
|
|
58
|
-
"aria-disabled": !isEnabled,
|
|
59
|
-
"aria-pressed": action.isToggled,
|
|
60
|
-
disabled: !isEnabled,
|
|
61
|
-
isToggled: action.isToggled,
|
|
62
|
-
color: action.color,
|
|
63
|
-
hoverBg: hoverBg,
|
|
64
|
-
children: action.icon && 'string' == typeof action.icon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
|
|
65
|
-
icon: action.icon,
|
|
66
|
-
size: 16,
|
|
67
|
-
color: action.color
|
|
68
|
-
}) : action.icon
|
|
70
|
+
children: isEnabled ? button : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
71
|
+
className: "inline-flex",
|
|
72
|
+
"data-testid": "toolbar-action-hover-target",
|
|
73
|
+
children: button
|
|
69
74
|
})
|
|
70
75
|
});
|
|
71
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/shared/ToolbarButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,qBAAqB,CAAC;IAK9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,6DAA+B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/shared/ToolbarButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,qBAAqB,CAAC;IAK9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,6DAA+B,kBAAkB,6CAkDzE,CAAC"}
|
|
@@ -12,32 +12,37 @@ const ToolbarButton = /*#__PURE__*/ memo(({ action, layoutId })=>{
|
|
|
12
12
|
e.preventDefault();
|
|
13
13
|
if (isEnabled) action.onClick();
|
|
14
14
|
};
|
|
15
|
+
const button = /*#__PURE__*/ jsx(ToolbarIconButton, {
|
|
16
|
+
layout: layoutId ? true : void 0,
|
|
17
|
+
layoutId: layoutId,
|
|
18
|
+
transition: {
|
|
19
|
+
type: 'tween',
|
|
20
|
+
duration: 0.2,
|
|
21
|
+
ease: 'easeOut'
|
|
22
|
+
},
|
|
23
|
+
type: "button",
|
|
24
|
+
className: "nodrag nopan",
|
|
25
|
+
onClick: handleClick,
|
|
26
|
+
"aria-label": action.label,
|
|
27
|
+
"aria-disabled": !isEnabled,
|
|
28
|
+
"aria-pressed": action.isToggled,
|
|
29
|
+
disabled: !isEnabled,
|
|
30
|
+
isToggled: action.isToggled,
|
|
31
|
+
color: action.color,
|
|
32
|
+
hoverBg: hoverBg,
|
|
33
|
+
children: action.icon && 'string' == typeof action.icon ? /*#__PURE__*/ jsx(CanvasIcon, {
|
|
34
|
+
icon: action.icon,
|
|
35
|
+
size: 16,
|
|
36
|
+
color: action.color
|
|
37
|
+
}) : action.icon
|
|
38
|
+
});
|
|
15
39
|
return /*#__PURE__*/ jsx(CanvasTooltip, {
|
|
16
40
|
content: action.label,
|
|
17
41
|
placement: "top",
|
|
18
|
-
children: /*#__PURE__*/ jsx(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: 'tween',
|
|
23
|
-
duration: 0.2,
|
|
24
|
-
ease: 'easeOut'
|
|
25
|
-
},
|
|
26
|
-
type: "button",
|
|
27
|
-
className: "nodrag nopan",
|
|
28
|
-
onClick: handleClick,
|
|
29
|
-
"aria-label": action.label,
|
|
30
|
-
"aria-disabled": !isEnabled,
|
|
31
|
-
"aria-pressed": action.isToggled,
|
|
32
|
-
disabled: !isEnabled,
|
|
33
|
-
isToggled: action.isToggled,
|
|
34
|
-
color: action.color,
|
|
35
|
-
hoverBg: hoverBg,
|
|
36
|
-
children: action.icon && 'string' == typeof action.icon ? /*#__PURE__*/ jsx(CanvasIcon, {
|
|
37
|
-
icon: action.icon,
|
|
38
|
-
size: 16,
|
|
39
|
-
color: action.color
|
|
40
|
-
}) : action.icon
|
|
42
|
+
children: isEnabled ? button : /*#__PURE__*/ jsx("span", {
|
|
43
|
+
className: "inline-flex",
|
|
44
|
+
"data-testid": "toolbar-action-hover-target",
|
|
45
|
+
children: button
|
|
41
46
|
})
|
|
42
47
|
});
|
|
43
48
|
});
|