@uipath/apollo-react 6.25.0 → 6.27.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/AgentCanvas/AgentFlow.cjs +4 -3
- package/dist/canvas/components/AgentCanvas/AgentFlow.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/AgentFlow.js +4 -3
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.cjs +13 -9
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +13 -9
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.d.ts +2 -0
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.js +1 -1
- 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 +20 -10
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +20 -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/HierarchicalCanvas/HierarchicalCanvas.cjs +2 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +1 -0
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +2 -1
- package/dist/canvas/components/LoopNode/LoopNode.cjs +13 -5
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.js +13 -5
- package/dist/canvas/components/StageNode/StageNode.cjs +15 -11
- package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.js +15 -11
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +29 -6
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +29 -6
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.cjs +18 -2
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.d.ts +2 -0
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.js +14 -1
- 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/dist/canvas/storybook-utils/components/StoryPage.d.ts +15 -1
- package/dist/canvas/storybook-utils/components/StoryPage.d.ts.map +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/types.d.ts +1 -0
- package/dist/canvas/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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,17 +41,20 @@ 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");
|
|
47
48
|
const InitialsBadge_cjs_namespaceObject = require("../shared/InitialsBadge.cjs");
|
|
48
49
|
const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
50
|
+
const NodeToolbar_utils_cjs_namespaceObject = require("../Toolbar/NodeToolbar/NodeToolbar.utils.cjs");
|
|
49
51
|
const external_BaseNodeBadgeSlot_cjs_namespaceObject = require("./BaseNodeBadgeSlot.cjs");
|
|
50
52
|
const external_BaseNodeConfigContext_cjs_namespaceObject = require("./BaseNodeConfigContext.cjs");
|
|
51
53
|
const external_BaseNodeContainer_cjs_namespaceObject = require("./BaseNodeContainer.cjs");
|
|
52
54
|
const external_BaseNodeInnerShape_cjs_namespaceObject = require("./BaseNodeInnerShape.cjs");
|
|
53
55
|
const external_BaseNodeMissingManifest_cjs_namespaceObject = require("./BaseNodeMissingManifest.cjs");
|
|
54
56
|
const external_NodeLabel_cjs_namespaceObject = require("./NodeLabel.cjs");
|
|
57
|
+
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
55
58
|
const getContainerWidth = (shape, width)=>{
|
|
56
59
|
const defaultWidth = 'rectangle' === shape ? external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH : external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE;
|
|
57
60
|
if (width && width !== external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE && width !== external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -80,6 +83,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
80
83
|
const validationState = (0, external_hooks_index_cjs_namespaceObject.useElementValidationStatus)(id);
|
|
81
84
|
const nodeTypeRegistry = (0, index_cjs_namespaceObject.useNodeTypeRegistry)();
|
|
82
85
|
const { mode } = (0, BaseCanvasModeProvider_cjs_namespaceObject.useBaseCanvasMode)();
|
|
86
|
+
const isNodeReadOnly = (0, ReadOnlyNodesContext_cjs_namespaceObject.useIsNodeReadOnly)(id);
|
|
87
|
+
const canEdit = 'design' === mode && !isNodeReadOnly;
|
|
83
88
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
84
89
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)(NodeUtils_cjs_namespaceObject.selectIsConnecting);
|
|
85
90
|
const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
|
|
@@ -107,7 +112,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
107
112
|
mode
|
|
108
113
|
]);
|
|
109
114
|
const onHandleActionCallback = onHandleActionProp;
|
|
110
|
-
const shouldShowAddButtonFn = shouldShowAddButtonFnProp;
|
|
115
|
+
const shouldShowAddButtonFn = isNodeReadOnly ? NEVER_SHOW_ADD_BUTTON : shouldShowAddButtonFnProp;
|
|
111
116
|
const shouldShowButtonHandleNotchesFn = shouldShowButtonHandleNotchesFnProp;
|
|
112
117
|
const executionStatus = executionStatusOverride ?? ('string' == typeof executionState ? executionState : executionState?.status);
|
|
113
118
|
const display = (0, external_react_namespaceObject.useMemo)(()=>(0, manifest_resolver_cjs_namespaceObject.resolveDisplay)(manifest?.display, {
|
|
@@ -171,6 +176,10 @@ const BaseNodeComponent = (props)=>{
|
|
|
171
176
|
manifest,
|
|
172
177
|
statusContext
|
|
173
178
|
]);
|
|
179
|
+
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>toolbarConfig && isNodeReadOnly ? (0, NodeToolbar_utils_cjs_namespaceObject.lockToolbarConfig)(toolbarConfig) : toolbarConfig, [
|
|
180
|
+
toolbarConfig,
|
|
181
|
+
isNodeReadOnly
|
|
182
|
+
]);
|
|
174
183
|
const adornments = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
175
184
|
const adornmentsFromProps = adornmentsProp ?? {};
|
|
176
185
|
const adornmentsFromResolver = (0, adornment_resolver_cjs_namespaceObject.resolveAdornments)(statusContext);
|
|
@@ -339,8 +348,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
339
348
|
if (multipleNodesSelected) return false;
|
|
340
349
|
const { hasButton, hasLabel } = toolbarSideHandleAffordances;
|
|
341
350
|
const isAddButtonShown = ()=>{
|
|
342
|
-
if (useSmartHandles) return
|
|
343
|
-
const showAddButton =
|
|
351
|
+
if (useSmartHandles) return canEdit && !!selected;
|
|
352
|
+
const showAddButton = canEdit && !isConnecting && !dragging;
|
|
344
353
|
if (shouldShowAddButtonFn) return shouldShowAddButtonFn({
|
|
345
354
|
showAddButton,
|
|
346
355
|
selected: !!selected
|
|
@@ -352,7 +361,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
352
361
|
return false;
|
|
353
362
|
}, [
|
|
354
363
|
toolbarSideHandleAffordances,
|
|
355
|
-
|
|
364
|
+
canEdit,
|
|
356
365
|
multipleNodesSelected,
|
|
357
366
|
useSmartHandles,
|
|
358
367
|
selected,
|
|
@@ -370,7 +379,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
370
379
|
nodeId: id,
|
|
371
380
|
selected: selected ?? false,
|
|
372
381
|
hovered: isHovered,
|
|
373
|
-
showAddButton:
|
|
382
|
+
showAddButton: canEdit && !multipleNodesSelected && !isConnecting && !dragging,
|
|
374
383
|
showNotches,
|
|
375
384
|
nodeWidth: containerWidth,
|
|
376
385
|
nodeHeight: computedHeight,
|
|
@@ -388,7 +397,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
388
397
|
const handleVisualType = handle.handleType ?? ('source' === handle.type ? 'output' : 'input');
|
|
389
398
|
const hasConnection = connectedHandleIds.has(handle.id);
|
|
390
399
|
const isVisible = hasConnection || shouldShowHandles && configVisible;
|
|
391
|
-
const shouldShowButton =
|
|
400
|
+
const shouldShowButton = canEdit && selected && handle.showButton && !multipleNodesSelected;
|
|
392
401
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SmartHandle_cjs_namespaceObject.SmartHandle, {
|
|
393
402
|
type: handle.type,
|
|
394
403
|
id: handle.id,
|
|
@@ -412,7 +421,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
412
421
|
shouldShowHandles,
|
|
413
422
|
containerWidth,
|
|
414
423
|
computedHeight,
|
|
415
|
-
|
|
424
|
+
canEdit,
|
|
416
425
|
selected,
|
|
417
426
|
showNotches,
|
|
418
427
|
handleAction,
|
|
@@ -493,7 +502,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
493
502
|
hasBottomHandles: hasVisibleBottomHandles,
|
|
494
503
|
selected: selected,
|
|
495
504
|
dragging: dragging,
|
|
496
|
-
readonly:
|
|
505
|
+
readonly: !canEdit,
|
|
506
|
+
discardDraftOnReadonly: isNodeReadOnly,
|
|
497
507
|
onChange: handleLabelChange
|
|
498
508
|
}),
|
|
499
509
|
displayFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
@@ -502,9 +512,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
502
512
|
})
|
|
503
513
|
]
|
|
504
514
|
}),
|
|
505
|
-
|
|
515
|
+
effectiveToolbarConfig && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbar_index_cjs_namespaceObject.NodeToolbar, {
|
|
506
516
|
nodeId: id,
|
|
507
|
-
config:
|
|
517
|
+
config: effectiveToolbarConfig,
|
|
508
518
|
expanded: selected || isHovered,
|
|
509
519
|
hidden: dragging || multipleNodesSelected,
|
|
510
520
|
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;AA+ChF,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AAosB1B,eAAO,MAAM,QAAQ,8CA/pBa,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,6CA+pBmB,CAAC"}
|
|
@@ -13,17 +13,20 @@ 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";
|
|
19
20
|
import { InitialsBadge } from "../shared/InitialsBadge.js";
|
|
20
21
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
22
|
+
import { lockToolbarConfig } from "../Toolbar/NodeToolbar/NodeToolbar.utils.js";
|
|
21
23
|
import { BaseBadgeSlot } from "./BaseNodeBadgeSlot.js";
|
|
22
24
|
import { useBaseNodeOverrideConfig } from "./BaseNodeConfigContext.js";
|
|
23
25
|
import { BaseContainer } from "./BaseNodeContainer.js";
|
|
24
26
|
import { BaseInnerShape } from "./BaseNodeInnerShape.js";
|
|
25
27
|
import { MissingManifestNode } from "./BaseNodeMissingManifest.js";
|
|
26
28
|
import { NodeLabel } from "./NodeLabel.js";
|
|
29
|
+
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
27
30
|
const getContainerWidth = (shape, width)=>{
|
|
28
31
|
const defaultWidth = 'rectangle' === shape ? DEFAULT_RECTANGLE_NODE_WIDTH : DEFAULT_NODE_SIZE;
|
|
29
32
|
if (width && width !== DEFAULT_NODE_SIZE && width !== DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -52,6 +55,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
52
55
|
const validationState = useElementValidationStatus(id);
|
|
53
56
|
const nodeTypeRegistry = useNodeTypeRegistry();
|
|
54
57
|
const { mode } = useBaseCanvasMode();
|
|
58
|
+
const isNodeReadOnly = useIsNodeReadOnly(id);
|
|
59
|
+
const canEdit = 'design' === mode && !isNodeReadOnly;
|
|
55
60
|
const connectedHandleIds = useConnectedHandles(id);
|
|
56
61
|
const isConnecting = useStore(selectIsConnecting);
|
|
57
62
|
const { multipleNodesSelected } = useSelectionState();
|
|
@@ -79,7 +84,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
79
84
|
mode
|
|
80
85
|
]);
|
|
81
86
|
const onHandleActionCallback = onHandleActionProp;
|
|
82
|
-
const shouldShowAddButtonFn = shouldShowAddButtonFnProp;
|
|
87
|
+
const shouldShowAddButtonFn = isNodeReadOnly ? NEVER_SHOW_ADD_BUTTON : shouldShowAddButtonFnProp;
|
|
83
88
|
const shouldShowButtonHandleNotchesFn = shouldShowButtonHandleNotchesFnProp;
|
|
84
89
|
const executionStatus = executionStatusOverride ?? ('string' == typeof executionState ? executionState : executionState?.status);
|
|
85
90
|
const display = useMemo(()=>resolveDisplay(manifest?.display, {
|
|
@@ -143,6 +148,10 @@ const BaseNodeComponent = (props)=>{
|
|
|
143
148
|
manifest,
|
|
144
149
|
statusContext
|
|
145
150
|
]);
|
|
151
|
+
const effectiveToolbarConfig = useMemo(()=>toolbarConfig && isNodeReadOnly ? lockToolbarConfig(toolbarConfig) : toolbarConfig, [
|
|
152
|
+
toolbarConfig,
|
|
153
|
+
isNodeReadOnly
|
|
154
|
+
]);
|
|
146
155
|
const adornments = useMemo(()=>{
|
|
147
156
|
const adornmentsFromProps = adornmentsProp ?? {};
|
|
148
157
|
const adornmentsFromResolver = resolveAdornments(statusContext);
|
|
@@ -311,8 +320,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
311
320
|
if (multipleNodesSelected) return false;
|
|
312
321
|
const { hasButton, hasLabel } = toolbarSideHandleAffordances;
|
|
313
322
|
const isAddButtonShown = ()=>{
|
|
314
|
-
if (useSmartHandles) return
|
|
315
|
-
const showAddButton =
|
|
323
|
+
if (useSmartHandles) return canEdit && !!selected;
|
|
324
|
+
const showAddButton = canEdit && !isConnecting && !dragging;
|
|
316
325
|
if (shouldShowAddButtonFn) return shouldShowAddButtonFn({
|
|
317
326
|
showAddButton,
|
|
318
327
|
selected: !!selected
|
|
@@ -324,7 +333,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
324
333
|
return false;
|
|
325
334
|
}, [
|
|
326
335
|
toolbarSideHandleAffordances,
|
|
327
|
-
|
|
336
|
+
canEdit,
|
|
328
337
|
multipleNodesSelected,
|
|
329
338
|
useSmartHandles,
|
|
330
339
|
selected,
|
|
@@ -342,7 +351,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
342
351
|
nodeId: id,
|
|
343
352
|
selected: selected ?? false,
|
|
344
353
|
hovered: isHovered,
|
|
345
|
-
showAddButton:
|
|
354
|
+
showAddButton: canEdit && !multipleNodesSelected && !isConnecting && !dragging,
|
|
346
355
|
showNotches,
|
|
347
356
|
nodeWidth: containerWidth,
|
|
348
357
|
nodeHeight: computedHeight,
|
|
@@ -360,7 +369,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
360
369
|
const handleVisualType = handle.handleType ?? ('source' === handle.type ? 'output' : 'input');
|
|
361
370
|
const hasConnection = connectedHandleIds.has(handle.id);
|
|
362
371
|
const isVisible = hasConnection || shouldShowHandles && configVisible;
|
|
363
|
-
const shouldShowButton =
|
|
372
|
+
const shouldShowButton = canEdit && selected && handle.showButton && !multipleNodesSelected;
|
|
364
373
|
return /*#__PURE__*/ jsx(SmartHandle, {
|
|
365
374
|
type: handle.type,
|
|
366
375
|
id: handle.id,
|
|
@@ -384,7 +393,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
384
393
|
shouldShowHandles,
|
|
385
394
|
containerWidth,
|
|
386
395
|
computedHeight,
|
|
387
|
-
|
|
396
|
+
canEdit,
|
|
388
397
|
selected,
|
|
389
398
|
showNotches,
|
|
390
399
|
handleAction,
|
|
@@ -465,7 +474,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
465
474
|
hasBottomHandles: hasVisibleBottomHandles,
|
|
466
475
|
selected: selected,
|
|
467
476
|
dragging: dragging,
|
|
468
|
-
readonly:
|
|
477
|
+
readonly: !canEdit,
|
|
478
|
+
discardDraftOnReadonly: isNodeReadOnly,
|
|
469
479
|
onChange: handleLabelChange
|
|
470
480
|
}),
|
|
471
481
|
displayFooter && /*#__PURE__*/ jsx("div", {
|
|
@@ -474,9 +484,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
474
484
|
})
|
|
475
485
|
]
|
|
476
486
|
}),
|
|
477
|
-
|
|
487
|
+
effectiveToolbarConfig && /*#__PURE__*/ jsx(NodeToolbar, {
|
|
478
488
|
nodeId: id,
|
|
479
|
-
config:
|
|
489
|
+
config: effectiveToolbarConfig,
|
|
480
490
|
expanded: selected || isHovered,
|
|
481
491
|
hidden: dragging || multipleNodesSelected,
|
|
482
492
|
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
|
|
@@ -66,7 +66,7 @@ function shouldPersistNodeChange(change) {
|
|
|
66
66
|
function isDefaultViewport(viewport) {
|
|
67
67
|
return 0 === viewport.x && 0 === viewport.y && 1 === viewport.zoom;
|
|
68
68
|
}
|
|
69
|
-
const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
69
|
+
const HierarchicalCanvas = ({ mode = 'design', readOnlyNodeIds, initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
70
70
|
const canvasRef = (0, external_react_namespaceObject.useRef)(null);
|
|
71
71
|
const containerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
72
72
|
const [reactFlowInstance, setReactFlowInstance] = (0, external_react_namespaceObject.useState)(null);
|
|
@@ -349,6 +349,7 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
349
349
|
onInit: handleInit,
|
|
350
350
|
onToolbarAction: handleToolbarAction,
|
|
351
351
|
mode: mode,
|
|
352
|
+
readOnlyNodeIds: readOnlyNodeIds,
|
|
352
353
|
defaultViewport: currentCanvas.viewport,
|
|
353
354
|
fitView: shouldFitView,
|
|
354
355
|
fitViewOptions: {
|
|
@@ -2,6 +2,7 @@ import type React from 'react';
|
|
|
2
2
|
import type { CanvasLevel } from '../../types/canvas.types';
|
|
3
3
|
interface HierarchicalCanvasProps {
|
|
4
4
|
mode?: 'view' | 'design' | 'readonly';
|
|
5
|
+
readOnlyNodeIds?: ReadonlySet<string>;
|
|
5
6
|
initialCanvases?: Record<string, CanvasLevel>;
|
|
6
7
|
initialPath?: string[];
|
|
7
8
|
onCanvasesChange?: (canvases: Record<string, CanvasLevel>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA8B/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAe5D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAKtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAK9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;IAInE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAyBD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA8B/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAe5D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAEtC,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAKtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAK9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;IAInE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAyBD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqZhE,CAAC"}
|
|
@@ -38,7 +38,7 @@ function shouldPersistNodeChange(change) {
|
|
|
38
38
|
function isDefaultViewport(viewport) {
|
|
39
39
|
return 0 === viewport.x && 0 === viewport.y && 1 === viewport.zoom;
|
|
40
40
|
}
|
|
41
|
-
const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
41
|
+
const HierarchicalCanvas = ({ mode = 'design', readOnlyNodeIds, initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
42
42
|
const canvasRef = useRef(null);
|
|
43
43
|
const containerRef = useRef(null);
|
|
44
44
|
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
|
@@ -321,6 +321,7 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
321
321
|
onInit: handleInit,
|
|
322
322
|
onToolbarAction: handleToolbarAction,
|
|
323
323
|
mode: mode,
|
|
324
|
+
readOnlyNodeIds: readOnlyNodeIds,
|
|
324
325
|
defaultViewport: currentCanvas.viewport,
|
|
325
326
|
fitView: shouldFitView,
|
|
326
327
|
fitViewOptions: {
|