@octanejs/xyflow 0.1.18 → 0.1.20
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/package.json +6 -6
- package/src/additional-components/Background/Background.tsrx +32 -26
- package/src/additional-components/Background/Patterns.tsrx +15 -11
- package/src/additional-components/Controls/ControlButton.tsrx +5 -5
- package/src/additional-components/Controls/Controls.tsrx +48 -44
- package/src/additional-components/Controls/Icons/FitView.tsrx +5 -5
- package/src/additional-components/Controls/Icons/Lock.tsrx +5 -5
- package/src/additional-components/Controls/Icons/Minus.tsrx +5 -3
- package/src/additional-components/Controls/Icons/Plus.tsrx +5 -3
- package/src/additional-components/Controls/Icons/Unlock.tsrx +5 -5
- package/src/additional-components/EdgeToolbar/EdgeToolbar.tsrx +20 -17
- package/src/additional-components/MiniMap/MiniMap.tsrx +85 -86
- package/src/additional-components/MiniMap/MiniMapNode.tsrx +18 -16
- package/src/additional-components/MiniMap/MiniMapNodes.tsrx +47 -45
- package/src/additional-components/NodeResizer/NodeResizeControl.tsrx +31 -30
- package/src/additional-components/NodeResizer/NodeResizer.tsrx +10 -10
- package/src/additional-components/NodeToolbar/NodeToolbar.tsrx +32 -25
- package/src/components/A11yDescriptions/index.tsrx +23 -18
- package/src/components/Attribution/index.tsrx +11 -9
- package/src/components/BatchProvider/index.tsrx +8 -11
- package/src/components/ConnectionLine/index.tsrx +31 -27
- package/src/components/EdgeWrapper/EdgeUpdateAnchors.tsrx +38 -35
- package/src/components/EdgeWrapper/index.tsrx +155 -146
- package/src/components/Edges/BaseEdge.tsrx +16 -14
- package/src/components/Edges/BezierEdge.tsrx +47 -43
- package/src/components/Edges/EdgeAnchor.tsrx +13 -11
- package/src/components/Edges/EdgeText.tsrx +31 -26
- package/src/components/Edges/SimpleBezierEdge.tsrx +55 -44
- package/src/components/Edges/SmoothStepEdge.tsrx +49 -45
- package/src/components/Edges/StepEdge.tsrx +10 -7
- package/src/components/Edges/StraightEdge.tsrx +40 -36
- package/src/components/Handle/index.tsrx +73 -63
- package/src/components/NodeWrapper/index.tsrx +86 -72
- package/src/components/Nodes/DefaultNode.tsrx +7 -5
- package/src/components/Nodes/InputNode.tsrx +11 -7
- package/src/components/Nodes/OutputNode.tsrx +11 -7
- package/src/components/NodesSelection/index.tsrx +23 -22
- package/src/components/Panel/index.tsrx +17 -14
- package/src/components/ReactFlowProvider/index.tsrx +25 -23
- package/src/components/SelectionListener/index.tsrx +4 -2
- package/src/components/StoreUpdater/index.tsrx +43 -34
- package/src/components/UserSelection/index.tsrx +10 -8
- package/src/container/EdgeRenderer/MarkerDefinitions.tsrx +34 -29
- package/src/container/EdgeRenderer/MarkerSymbols.tsrx +21 -17
- package/src/container/EdgeRenderer/index.tsrx +52 -49
- package/src/container/FlowRenderer/index.tsrx +67 -66
- package/src/container/GraphView/index.tsrx +98 -96
- package/src/container/NodeRenderer/index.tsrx +74 -71
- package/src/container/Pane/index.tsrx +69 -60
- package/src/container/ReactFlow/Wrapper.tsrx +23 -21
- package/src/container/ReactFlow/index.tsrx +158 -153
- package/src/container/Viewport/index.tsrx +13 -7
- package/src/container/ZoomPane/index.tsrx +28 -25
|
@@ -165,168 +165,173 @@ function ReactFlow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(
|
|
|
165
165
|
const colorModeClassName = useColorModeClass(colorMode);
|
|
166
166
|
|
|
167
167
|
// Undo scroll events, preventing viewport from shifting when nodes outside of it are focused
|
|
168
|
-
const wrapperOnScroll = useCallback(
|
|
169
|
-
e
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
const wrapperOnScroll = useCallback(
|
|
169
|
+
(e: ReactUIEvent<HTMLDivElement>) => {
|
|
170
|
+
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
171
|
+
onScroll?.(e);
|
|
172
|
+
},
|
|
173
|
+
[onScroll],
|
|
174
|
+
);
|
|
172
175
|
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<Wrapper
|
|
184
|
-
nodes={nodes}
|
|
185
|
-
edges={edges}
|
|
186
|
-
width={width}
|
|
187
|
-
height={height}
|
|
188
|
-
fitView={fitView}
|
|
189
|
-
fitViewOptions={fitViewOptions}
|
|
190
|
-
minZoom={minZoom}
|
|
191
|
-
maxZoom={maxZoom}
|
|
192
|
-
nodeOrigin={nodeOrigin}
|
|
193
|
-
nodeExtent={nodeExtent}
|
|
194
|
-
zIndexMode={zIndexMode}
|
|
176
|
+
return (
|
|
177
|
+
<div
|
|
178
|
+
data-testid="rf__wrapper"
|
|
179
|
+
{...rest}
|
|
180
|
+
onScroll={wrapperOnScroll}
|
|
181
|
+
style={{ ...style, ...wrapperStyle }}
|
|
182
|
+
ref={ref}
|
|
183
|
+
className={cc(['react-flow', className, colorModeClassName])}
|
|
184
|
+
id={id}
|
|
185
|
+
role="application"
|
|
195
186
|
>
|
|
196
|
-
<
|
|
187
|
+
<Wrapper
|
|
197
188
|
nodes={nodes}
|
|
198
189
|
edges={edges}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
onConnect={onConnect}
|
|
202
|
-
onConnectStart={onConnectStart}
|
|
203
|
-
onConnectEnd={onConnectEnd}
|
|
204
|
-
onClickConnectStart={onClickConnectStart}
|
|
205
|
-
onClickConnectEnd={onClickConnectEnd}
|
|
206
|
-
nodesDraggable={nodesDraggable}
|
|
207
|
-
autoPanOnNodeFocus={autoPanOnNodeFocus}
|
|
208
|
-
nodesConnectable={nodesConnectable}
|
|
209
|
-
nodesFocusable={nodesFocusable}
|
|
210
|
-
edgesFocusable={edgesFocusable}
|
|
211
|
-
edgesReconnectable={edgesReconnectable}
|
|
212
|
-
elementsSelectable={elementsSelectable}
|
|
213
|
-
elevateNodesOnSelect={elevateNodesOnSelect}
|
|
214
|
-
elevateEdgesOnSelect={elevateEdgesOnSelect}
|
|
215
|
-
minZoom={minZoom}
|
|
216
|
-
maxZoom={maxZoom}
|
|
217
|
-
nodeExtent={nodeExtent}
|
|
218
|
-
onNodesChange={onNodesChange}
|
|
219
|
-
onEdgesChange={onEdgesChange}
|
|
220
|
-
snapToGrid={snapToGrid}
|
|
221
|
-
snapGrid={snapGrid}
|
|
222
|
-
connectionMode={connectionMode}
|
|
223
|
-
translateExtent={translateExtent}
|
|
224
|
-
connectOnClick={connectOnClick}
|
|
225
|
-
defaultEdgeOptions={defaultEdgeOptions}
|
|
190
|
+
width={width}
|
|
191
|
+
height={height}
|
|
226
192
|
fitView={fitView}
|
|
227
193
|
fitViewOptions={fitViewOptions}
|
|
228
|
-
onNodesDelete={onNodesDelete}
|
|
229
|
-
onEdgesDelete={onEdgesDelete}
|
|
230
|
-
onDelete={onDelete}
|
|
231
|
-
onNodeDragStart={onNodeDragStart}
|
|
232
|
-
onNodeDrag={onNodeDrag}
|
|
233
|
-
onNodeDragStop={onNodeDragStop}
|
|
234
|
-
onSelectionDrag={onSelectionDrag}
|
|
235
|
-
onSelectionDragStart={onSelectionDragStart}
|
|
236
|
-
onSelectionDragStop={onSelectionDragStop}
|
|
237
|
-
onMove={onMove}
|
|
238
|
-
onMoveStart={onMoveStart}
|
|
239
|
-
onMoveEnd={onMoveEnd}
|
|
240
|
-
noPanClassName={noPanClassName}
|
|
241
|
-
nodeOrigin={nodeOrigin}
|
|
242
|
-
rfId={rfId}
|
|
243
|
-
autoPanOnConnect={autoPanOnConnect}
|
|
244
|
-
autoPanOnNodeDrag={autoPanOnNodeDrag}
|
|
245
|
-
autoPanSpeed={autoPanSpeed}
|
|
246
|
-
onError={onError}
|
|
247
|
-
connectionRadius={connectionRadius}
|
|
248
|
-
isValidConnection={isValidConnection}
|
|
249
|
-
selectNodesOnDrag={selectNodesOnDrag}
|
|
250
|
-
nodeDragThreshold={nodeDragThreshold}
|
|
251
|
-
connectionDragThreshold={connectionDragThreshold}
|
|
252
|
-
onBeforeDelete={onBeforeDelete}
|
|
253
|
-
debug={debug}
|
|
254
|
-
ariaLabelConfig={ariaLabelConfig}
|
|
255
|
-
zIndexMode={zIndexMode}
|
|
256
|
-
/>
|
|
257
|
-
<GraphView
|
|
258
|
-
onInit={onInit}
|
|
259
|
-
onNodeClick={onNodeClick}
|
|
260
|
-
onEdgeClick={onEdgeClick}
|
|
261
|
-
onNodeMouseEnter={onNodeMouseEnter}
|
|
262
|
-
onNodeMouseMove={onNodeMouseMove}
|
|
263
|
-
onNodeMouseLeave={onNodeMouseLeave}
|
|
264
|
-
onNodeContextMenu={onNodeContextMenu}
|
|
265
|
-
onNodeDoubleClick={onNodeDoubleClick}
|
|
266
|
-
nodeTypes={nodeTypes}
|
|
267
|
-
edgeTypes={edgeTypes}
|
|
268
|
-
connectionLineType={connectionLineType}
|
|
269
|
-
connectionLineStyle={connectionLineStyle}
|
|
270
|
-
connectionLineComponent={connectionLineComponent}
|
|
271
|
-
connectionLineContainerStyle={connectionLineContainerStyle}
|
|
272
|
-
selectionKeyCode={selectionKeyCode}
|
|
273
|
-
selectionOnDrag={selectionOnDrag}
|
|
274
|
-
selectionMode={selectionMode}
|
|
275
|
-
deleteKeyCode={deleteKeyCode}
|
|
276
|
-
multiSelectionKeyCode={multiSelectionKeyCode}
|
|
277
|
-
panActivationKeyCode={panActivationKeyCode}
|
|
278
|
-
zoomActivationKeyCode={zoomActivationKeyCode}
|
|
279
|
-
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
|
280
|
-
defaultViewport={defaultViewport}
|
|
281
|
-
translateExtent={translateExtent}
|
|
282
194
|
minZoom={minZoom}
|
|
283
195
|
maxZoom={maxZoom}
|
|
284
|
-
|
|
285
|
-
zoomOnScroll={zoomOnScroll}
|
|
286
|
-
zoomOnPinch={zoomOnPinch}
|
|
287
|
-
zoomOnDoubleClick={zoomOnDoubleClick}
|
|
288
|
-
panOnScroll={panOnScroll}
|
|
289
|
-
panOnScrollSpeed={panOnScrollSpeed}
|
|
290
|
-
panOnScrollMode={panOnScrollMode}
|
|
291
|
-
panOnDrag={panOnDrag}
|
|
292
|
-
autoPanOnSelection={autoPanOnSelection}
|
|
293
|
-
onPaneClick={onPaneClick}
|
|
294
|
-
onPaneMouseEnter={onPaneMouseEnter}
|
|
295
|
-
onPaneMouseMove={onPaneMouseMove}
|
|
296
|
-
onPaneMouseLeave={onPaneMouseLeave}
|
|
297
|
-
onPaneScroll={onPaneScroll}
|
|
298
|
-
onPaneContextMenu={onPaneContextMenu}
|
|
299
|
-
paneClickDistance={paneClickDistance}
|
|
300
|
-
nodeClickDistance={nodeClickDistance}
|
|
301
|
-
onSelectionContextMenu={onSelectionContextMenu}
|
|
302
|
-
onSelectionStart={onSelectionStart}
|
|
303
|
-
onSelectionEnd={onSelectionEnd}
|
|
304
|
-
onReconnect={onReconnect}
|
|
305
|
-
onReconnectStart={onReconnectStart}
|
|
306
|
-
onReconnectEnd={onReconnectEnd}
|
|
307
|
-
onEdgeContextMenu={onEdgeContextMenu}
|
|
308
|
-
onEdgeDoubleClick={onEdgeDoubleClick}
|
|
309
|
-
onEdgeMouseEnter={onEdgeMouseEnter}
|
|
310
|
-
onEdgeMouseMove={onEdgeMouseMove}
|
|
311
|
-
onEdgeMouseLeave={onEdgeMouseLeave}
|
|
312
|
-
reconnectRadius={reconnectRadius}
|
|
313
|
-
defaultMarkerColor={defaultMarkerColor}
|
|
314
|
-
noDragClassName={noDragClassName}
|
|
315
|
-
noWheelClassName={noWheelClassName}
|
|
316
|
-
noPanClassName={noPanClassName}
|
|
317
|
-
rfId={rfId}
|
|
318
|
-
disableKeyboardA11y={disableKeyboardA11y}
|
|
196
|
+
nodeOrigin={nodeOrigin}
|
|
319
197
|
nodeExtent={nodeExtent}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
198
|
+
zIndexMode={zIndexMode}
|
|
199
|
+
>
|
|
200
|
+
<StoreUpdater
|
|
201
|
+
nodes={nodes}
|
|
202
|
+
edges={edges}
|
|
203
|
+
defaultNodes={defaultNodes}
|
|
204
|
+
defaultEdges={defaultEdges}
|
|
205
|
+
onConnect={onConnect}
|
|
206
|
+
onConnectStart={onConnectStart}
|
|
207
|
+
onConnectEnd={onConnectEnd}
|
|
208
|
+
onClickConnectStart={onClickConnectStart}
|
|
209
|
+
onClickConnectEnd={onClickConnectEnd}
|
|
210
|
+
nodesDraggable={nodesDraggable}
|
|
211
|
+
autoPanOnNodeFocus={autoPanOnNodeFocus}
|
|
212
|
+
nodesConnectable={nodesConnectable}
|
|
213
|
+
nodesFocusable={nodesFocusable}
|
|
214
|
+
edgesFocusable={edgesFocusable}
|
|
215
|
+
edgesReconnectable={edgesReconnectable}
|
|
216
|
+
elementsSelectable={elementsSelectable}
|
|
217
|
+
elevateNodesOnSelect={elevateNodesOnSelect}
|
|
218
|
+
elevateEdgesOnSelect={elevateEdgesOnSelect}
|
|
219
|
+
minZoom={minZoom}
|
|
220
|
+
maxZoom={maxZoom}
|
|
221
|
+
nodeExtent={nodeExtent}
|
|
222
|
+
onNodesChange={onNodesChange}
|
|
223
|
+
onEdgesChange={onEdgesChange}
|
|
224
|
+
snapToGrid={snapToGrid}
|
|
225
|
+
snapGrid={snapGrid}
|
|
226
|
+
connectionMode={connectionMode}
|
|
227
|
+
translateExtent={translateExtent}
|
|
228
|
+
connectOnClick={connectOnClick}
|
|
229
|
+
defaultEdgeOptions={defaultEdgeOptions}
|
|
230
|
+
fitView={fitView}
|
|
231
|
+
fitViewOptions={fitViewOptions}
|
|
232
|
+
onNodesDelete={onNodesDelete}
|
|
233
|
+
onEdgesDelete={onEdgesDelete}
|
|
234
|
+
onDelete={onDelete}
|
|
235
|
+
onNodeDragStart={onNodeDragStart}
|
|
236
|
+
onNodeDrag={onNodeDrag}
|
|
237
|
+
onNodeDragStop={onNodeDragStop}
|
|
238
|
+
onSelectionDrag={onSelectionDrag}
|
|
239
|
+
onSelectionDragStart={onSelectionDragStart}
|
|
240
|
+
onSelectionDragStop={onSelectionDragStop}
|
|
241
|
+
onMove={onMove}
|
|
242
|
+
onMoveStart={onMoveStart}
|
|
243
|
+
onMoveEnd={onMoveEnd}
|
|
244
|
+
noPanClassName={noPanClassName}
|
|
245
|
+
nodeOrigin={nodeOrigin}
|
|
246
|
+
rfId={rfId}
|
|
247
|
+
autoPanOnConnect={autoPanOnConnect}
|
|
248
|
+
autoPanOnNodeDrag={autoPanOnNodeDrag}
|
|
249
|
+
autoPanSpeed={autoPanSpeed}
|
|
250
|
+
onError={onError}
|
|
251
|
+
connectionRadius={connectionRadius}
|
|
252
|
+
isValidConnection={isValidConnection}
|
|
253
|
+
selectNodesOnDrag={selectNodesOnDrag}
|
|
254
|
+
nodeDragThreshold={nodeDragThreshold}
|
|
255
|
+
connectionDragThreshold={connectionDragThreshold}
|
|
256
|
+
onBeforeDelete={onBeforeDelete}
|
|
257
|
+
debug={debug}
|
|
258
|
+
ariaLabelConfig={ariaLabelConfig}
|
|
259
|
+
zIndexMode={zIndexMode}
|
|
260
|
+
/>
|
|
261
|
+
<GraphView
|
|
262
|
+
onInit={onInit}
|
|
263
|
+
onNodeClick={onNodeClick}
|
|
264
|
+
onEdgeClick={onEdgeClick}
|
|
265
|
+
onNodeMouseEnter={onNodeMouseEnter}
|
|
266
|
+
onNodeMouseMove={onNodeMouseMove}
|
|
267
|
+
onNodeMouseLeave={onNodeMouseLeave}
|
|
268
|
+
onNodeContextMenu={onNodeContextMenu}
|
|
269
|
+
onNodeDoubleClick={onNodeDoubleClick}
|
|
270
|
+
nodeTypes={nodeTypes}
|
|
271
|
+
edgeTypes={edgeTypes}
|
|
272
|
+
connectionLineType={connectionLineType}
|
|
273
|
+
connectionLineStyle={connectionLineStyle}
|
|
274
|
+
connectionLineComponent={connectionLineComponent}
|
|
275
|
+
connectionLineContainerStyle={connectionLineContainerStyle}
|
|
276
|
+
selectionKeyCode={selectionKeyCode}
|
|
277
|
+
selectionOnDrag={selectionOnDrag}
|
|
278
|
+
selectionMode={selectionMode}
|
|
279
|
+
deleteKeyCode={deleteKeyCode}
|
|
280
|
+
multiSelectionKeyCode={multiSelectionKeyCode}
|
|
281
|
+
panActivationKeyCode={panActivationKeyCode}
|
|
282
|
+
zoomActivationKeyCode={zoomActivationKeyCode}
|
|
283
|
+
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
|
284
|
+
defaultViewport={defaultViewport}
|
|
285
|
+
translateExtent={translateExtent}
|
|
286
|
+
minZoom={minZoom}
|
|
287
|
+
maxZoom={maxZoom}
|
|
288
|
+
preventScrolling={preventScrolling}
|
|
289
|
+
zoomOnScroll={zoomOnScroll}
|
|
290
|
+
zoomOnPinch={zoomOnPinch}
|
|
291
|
+
zoomOnDoubleClick={zoomOnDoubleClick}
|
|
292
|
+
panOnScroll={panOnScroll}
|
|
293
|
+
panOnScrollSpeed={panOnScrollSpeed}
|
|
294
|
+
panOnScrollMode={panOnScrollMode}
|
|
295
|
+
panOnDrag={panOnDrag}
|
|
296
|
+
autoPanOnSelection={autoPanOnSelection}
|
|
297
|
+
onPaneClick={onPaneClick}
|
|
298
|
+
onPaneMouseEnter={onPaneMouseEnter}
|
|
299
|
+
onPaneMouseMove={onPaneMouseMove}
|
|
300
|
+
onPaneMouseLeave={onPaneMouseLeave}
|
|
301
|
+
onPaneScroll={onPaneScroll}
|
|
302
|
+
onPaneContextMenu={onPaneContextMenu}
|
|
303
|
+
paneClickDistance={paneClickDistance}
|
|
304
|
+
nodeClickDistance={nodeClickDistance}
|
|
305
|
+
onSelectionContextMenu={onSelectionContextMenu}
|
|
306
|
+
onSelectionStart={onSelectionStart}
|
|
307
|
+
onSelectionEnd={onSelectionEnd}
|
|
308
|
+
onReconnect={onReconnect}
|
|
309
|
+
onReconnectStart={onReconnectStart}
|
|
310
|
+
onReconnectEnd={onReconnectEnd}
|
|
311
|
+
onEdgeContextMenu={onEdgeContextMenu}
|
|
312
|
+
onEdgeDoubleClick={onEdgeDoubleClick}
|
|
313
|
+
onEdgeMouseEnter={onEdgeMouseEnter}
|
|
314
|
+
onEdgeMouseMove={onEdgeMouseMove}
|
|
315
|
+
onEdgeMouseLeave={onEdgeMouseLeave}
|
|
316
|
+
reconnectRadius={reconnectRadius}
|
|
317
|
+
defaultMarkerColor={defaultMarkerColor}
|
|
318
|
+
noDragClassName={noDragClassName}
|
|
319
|
+
noWheelClassName={noWheelClassName}
|
|
320
|
+
noPanClassName={noPanClassName}
|
|
321
|
+
rfId={rfId}
|
|
322
|
+
disableKeyboardA11y={disableKeyboardA11y}
|
|
323
|
+
nodeExtent={nodeExtent}
|
|
324
|
+
viewport={viewport}
|
|
325
|
+
onViewportChange={onViewportChange}
|
|
326
|
+
nodesDraggable={nodesDraggable}
|
|
327
|
+
/>
|
|
328
|
+
<SelectionListener onSelectionChange={onSelectionChange} />
|
|
329
|
+
{children}
|
|
330
|
+
<Attribution proOptions={proOptions} position={attributionPosition} />
|
|
331
|
+
<A11yDescriptions rfId={rfId} disableKeyboardA11y={disableKeyboardA11y} />
|
|
332
|
+
</Wrapper>
|
|
333
|
+
</div>
|
|
334
|
+
);
|
|
330
335
|
}
|
|
331
336
|
|
|
332
337
|
/**
|
|
@@ -26,8 +26,10 @@ export function Viewport({ children }: ViewportProps) {
|
|
|
26
26
|
|
|
27
27
|
// store.subscribe fires on every update, so only touch the DOM when x, y or zoom actually changed
|
|
28
28
|
if (
|
|
29
|
-
prevTransform &&
|
|
30
|
-
|
|
29
|
+
prevTransform &&
|
|
30
|
+
transform[0] === prevTransform[0] &&
|
|
31
|
+
transform[1] === prevTransform[1] &&
|
|
32
|
+
transform[2] === prevTransform[2]
|
|
31
33
|
) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
@@ -44,9 +46,13 @@ export function Viewport({ children }: ViewportProps) {
|
|
|
44
46
|
return store.subscribe(applyTransform);
|
|
45
47
|
}, [store]);
|
|
46
48
|
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
ref={viewportRef}
|
|
52
|
+
className="react-flow__viewport xyflow__viewport react-flow__container"
|
|
53
|
+
style={{ transform: toTransformString(initialTransform) }}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
52
58
|
}
|
|
@@ -10,17 +10,16 @@ import { containerStyle } from '../../styles/utils';
|
|
|
10
10
|
import type { FlowRendererProps } from '../FlowRenderer/index.tsrx';
|
|
11
11
|
import type { ReactFlowState } from '../../types';
|
|
12
12
|
|
|
13
|
-
type ZoomPaneProps =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
13
|
+
type ZoomPaneProps = Omit<
|
|
14
|
+
FlowRendererProps,
|
|
15
|
+
| 'deleteKeyCode'
|
|
16
|
+
| 'selectionKeyCode'
|
|
17
|
+
| 'multiSelectionKeyCode'
|
|
18
|
+
| 'noDragClassName'
|
|
19
|
+
| 'disableKeyboardA11y'
|
|
20
|
+
> & {
|
|
21
|
+
isControlledViewport: boolean;
|
|
22
|
+
};
|
|
24
23
|
|
|
25
24
|
const selector = (s: ReactFlowState) => ({
|
|
26
25
|
userSelectionActive: s.userSelectionActive,
|
|
@@ -59,13 +58,16 @@ export function ZoomPane({
|
|
|
59
58
|
|
|
60
59
|
useResizeHandler(zoomPane);
|
|
61
60
|
|
|
62
|
-
const onTransformChange = useCallback(
|
|
63
|
-
|
|
61
|
+
const onTransformChange = useCallback(
|
|
62
|
+
(transform: Transform) => {
|
|
63
|
+
onViewportChange?.({ x: transform[0], y: transform[1], zoom: transform[2] });
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
if (!isControlledViewport) {
|
|
66
|
+
store.setState({ transform });
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[onViewportChange, isControlledViewport],
|
|
70
|
+
);
|
|
69
71
|
|
|
70
72
|
useEffect(() => {
|
|
71
73
|
if (zoomPane.current) {
|
|
@@ -75,9 +77,10 @@ export function ZoomPane({
|
|
|
75
77
|
maxZoom,
|
|
76
78
|
translateExtent,
|
|
77
79
|
viewport: defaultViewport,
|
|
78
|
-
onDraggingChange: (paneDragging) =>
|
|
79
|
-
(prevState) =>
|
|
80
|
-
|
|
80
|
+
onDraggingChange: (paneDragging) =>
|
|
81
|
+
store.setState((prevState) =>
|
|
82
|
+
prevState.paneDragging === paneDragging ? prevState : { paneDragging },
|
|
83
|
+
),
|
|
81
84
|
onPanZoomStart: (event, vp) => {
|
|
82
85
|
const { onViewportChangeStart, onMoveStart } = store.getState();
|
|
83
86
|
onMoveStart?.(event, vp);
|
|
@@ -151,9 +154,9 @@ export function ZoomPane({
|
|
|
151
154
|
paneClickDistance,
|
|
152
155
|
]);
|
|
153
156
|
|
|
154
|
-
return
|
|
155
|
-
className="react-flow__renderer"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
return (
|
|
158
|
+
<div className="react-flow__renderer" ref={zoomPane} style={containerStyle}>
|
|
159
|
+
{children}
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
159
162
|
}
|