@statelyai/flow 0.9.0 → 0.10.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/README.md +18 -2
- package/dist/esm/index.d.ts +45 -11
- package/dist/esm/index.js +151 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -162,7 +162,9 @@ measurements remain derived session state: they emit no graph commit, create no
|
|
|
162
162
|
undo entry, and do not overwrite authored dimensions. Auto-size label
|
|
163
163
|
measurements drive routing, graph/selection bounds, hit testing, snapping,
|
|
164
164
|
culling, and toolbar anchors; surviving measurements remain stable across
|
|
165
|
-
`replaceGraph()` calls.
|
|
165
|
+
`replaceGraph()` calls. Current graph geometry always supplies entity and label
|
|
166
|
+
positions, so stale DOM measurements cannot move bounds or toolbar anchors back
|
|
167
|
+
to a pre-drag location.
|
|
166
168
|
|
|
167
169
|
## Graph projections
|
|
168
170
|
|
|
@@ -245,6 +247,15 @@ flow.viewport.setFitFrame(null); // reset to the full viewport
|
|
|
245
247
|
unregister();
|
|
246
248
|
```
|
|
247
249
|
|
|
250
|
+
Set a default animation for all viewport commands through Flow settings. An
|
|
251
|
+
animation mode passed to an individual command overrides the default mode:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
const flow = createFlow({
|
|
255
|
+
store: { viewportAnimation: { lerp: 0.15 } },
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
248
259
|
Frames require finite `x`/`y` and positive finite dimensions. A `frame` on
|
|
249
260
|
`fit()`, `fitBounds()`, or `centerOn()` overrides the registered frame for that
|
|
250
261
|
call. `preserveCenter` shifts the viewport by the fit-frame center delta, so
|
|
@@ -754,6 +765,11 @@ const store = createFlowStore(graph, {
|
|
|
754
765
|
});
|
|
755
766
|
```
|
|
756
767
|
|
|
768
|
+
Auto-pan is pointer-driven: while a drag, connection, or resize gesture is
|
|
769
|
+
active, the pointer staying within `autoPanThreshold` of an edge keeps producing
|
|
770
|
+
a per-frame pan delta, including when entity bounds are clamped or lag behind
|
|
771
|
+
the gesture.
|
|
772
|
+
|
|
757
773
|
<!-- box-selection behavior from src/store/index.ts -->
|
|
758
774
|
|
|
759
775
|
Box selection tests node bounds and rendered edge-label bounds only. Crossing
|
|
@@ -857,7 +873,7 @@ store.trigger.dragEnd();
|
|
|
857
873
|
store.trigger.zoomTo({ zoom: 1.5, center: { x: 400, y: 300 } });
|
|
858
874
|
|
|
859
875
|
// Engine is purely derived:
|
|
860
|
-
const bounds = engine.getBounds('a'); //
|
|
876
|
+
const bounds = engine.getBounds('a'); // current model position + measured size
|
|
861
877
|
const paths = engine.getAllEdgePaths(); // computed from graph state
|
|
862
878
|
const canvas = engine.screenToCanvas({ x, y }); // from current viewport
|
|
863
879
|
```
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -742,6 +742,10 @@ type EntityOrderOptions = {
|
|
|
742
742
|
type EdgePathOptions = {
|
|
743
743
|
graph?: FlowStoreContext['graph'];
|
|
744
744
|
};
|
|
745
|
+
type PaintZIndices = {
|
|
746
|
+
nodes: Map<string, number>;
|
|
747
|
+
edges: Map<string, number>;
|
|
748
|
+
};
|
|
745
749
|
/**
|
|
746
750
|
* Create the framework-agnostic derived-geometry and query layer for a store.
|
|
747
751
|
*
|
|
@@ -1513,6 +1517,16 @@ declare function createFlowEngine(store: FlowStore, initialOptions?: FlowEngineO
|
|
|
1513
1517
|
nodes: FlowNode[];
|
|
1514
1518
|
edges: FlowEdge[];
|
|
1515
1519
|
};
|
|
1520
|
+
/**
|
|
1521
|
+
* CSS z-indices for the visible entity set. Base values are spaced by 2.
|
|
1522
|
+
* When `elevateOnSelect` allows an entity kind, a selected entity is
|
|
1523
|
+
* raised just above its own depth/zIndex band while remaining below the
|
|
1524
|
+
* next band, so a selected parent never paints over its descendants.
|
|
1525
|
+
* Multiple selected entities in one band tie; the renderer's DOM order
|
|
1526
|
+
* resolves the tie and matches core's elevated order. The result is
|
|
1527
|
+
* memoized per store snapshot so callers can compare it by identity.
|
|
1528
|
+
*/
|
|
1529
|
+
getPaintZIndices: (options?: EntityOrderOptions) => PaintZIndices;
|
|
1516
1530
|
/**
|
|
1517
1531
|
* Renderable (visible, optionally viewport-culled) entities. Memoized per
|
|
1518
1532
|
* (store snapshot, cull/overscan) so several render layers can share one
|
|
@@ -1874,18 +1888,17 @@ declare function defaultModesForContext(context: FlowStoreContext, keymap?: Part
|
|
|
1874
1888
|
declare function profileModesForContext(profile: FlowProfile): (context: FlowStoreContext) => FlowInputMode[];
|
|
1875
1889
|
declare function profilePoliciesForContext(profile: FlowProfile): (context: FlowStoreContext) => FlowPolicies;
|
|
1876
1890
|
/**
|
|
1877
|
-
* Per-frame auto-pan step while a drag
|
|
1878
|
-
* container edge. Returns the `calcAutoPan` screen-space
|
|
1879
|
-
* `panBy`), or null when auto-pan should not run. Adapters
|
|
1880
|
-
* frame ticker while a gesture session is active and re-send
|
|
1881
|
-
* pointer afterwards so the dragged entity follows the panned
|
|
1891
|
+
* Per-frame, pointer-driven auto-pan step while a drag, connection, or resize
|
|
1892
|
+
* gesture is near the container edge. Returns the `calcAutoPan` screen-space
|
|
1893
|
+
* delta (negate it for `panBy`), or null when auto-pan should not run. Adapters
|
|
1894
|
+
* call this from a frame ticker while a gesture session is active and re-send
|
|
1895
|
+
* the stationary pointer afterwards so the dragged entity follows the panned
|
|
1896
|
+
* canvas.
|
|
1882
1897
|
*/
|
|
1883
1898
|
declare function getAutoPanDelta(context: FlowStoreContext, screenPoint: Point,
|
|
1884
1899
|
/**
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
* actually reaches that viewport edge. Prevents pointless scrolling when a
|
|
1888
|
-
* clamped child is pinned mid-canvas while the pointer overshoots.
|
|
1900
|
+
* Retained for source compatibility. Auto-pan is intentionally driven by the
|
|
1901
|
+
* pointer position, not by resolved entity bounds.
|
|
1889
1902
|
*/
|
|
1890
1903
|
engine?: FlowEngine): Point | null;
|
|
1891
1904
|
//#endregion
|
|
@@ -2061,6 +2074,8 @@ type FlowStoreContext = {
|
|
|
2061
2074
|
} | null;
|
|
2062
2075
|
panOrigin: Point | null;
|
|
2063
2076
|
panViewportOrigin: Viewport | null;
|
|
2077
|
+
/** Default animation applied to viewport commands unless overridden per call. */
|
|
2078
|
+
viewportAnimation: ViewportAnimationOptions | null;
|
|
2064
2079
|
resizingEntityId: string | null;
|
|
2065
2080
|
resizeHandle: ResizeHandle | null;
|
|
2066
2081
|
/** Two opposite corners during resize: [anchor, moving]. Derived bounds = min/max of these. */
|
|
@@ -2122,6 +2137,8 @@ type FlowStoreOptions = {
|
|
|
2122
2137
|
autoPanOnDrag?: boolean;
|
|
2123
2138
|
autoPanThreshold?: number;
|
|
2124
2139
|
autoPanSpeed?: number;
|
|
2140
|
+
/** Default animation applied to viewport commands unless overridden per call. */
|
|
2141
|
+
viewportAnimation?: ViewportAnimationOptions | null;
|
|
2125
2142
|
snapToGrid?: boolean;
|
|
2126
2143
|
snapGrid?: [number, number];
|
|
2127
2144
|
enableSnapLines?: boolean;
|
|
@@ -2149,7 +2166,7 @@ type FlowStoreOptions = {
|
|
|
2149
2166
|
edges: FlowEdge[];
|
|
2150
2167
|
});
|
|
2151
2168
|
};
|
|
2152
|
-
type FlowRuntimeSettings = Pick<FlowStoreOptions, 'dragThreshold' | 'constrainNodeMovement' | 'autoPanOnDrag' | 'autoPanThreshold' | 'autoPanSpeed' | 'enableSnapLines' | 'snapThreshold' | 'enableSpacingGuides' | 'boxSelectionTest' | 'labelAnchor'>;
|
|
2169
|
+
type FlowRuntimeSettings = Pick<FlowStoreOptions, 'dragThreshold' | 'constrainNodeMovement' | 'autoPanOnDrag' | 'autoPanThreshold' | 'autoPanSpeed' | 'viewportAnimation' | 'enableSnapLines' | 'snapThreshold' | 'enableSpacingGuides' | 'boxSelectionTest' | 'labelAnchor'>;
|
|
2153
2170
|
type LayoutRequestedEvent = {
|
|
2154
2171
|
algorithm: string;
|
|
2155
2172
|
graph: FlowGraph;
|
|
@@ -3414,6 +3431,23 @@ type MinimapProjection = {
|
|
|
3414
3431
|
toCanvas(point: Point): Point;
|
|
3415
3432
|
rectToMinimap(rect: Rect): Rect;
|
|
3416
3433
|
};
|
|
3434
|
+
type MinimapViewportCenterOptions = {
|
|
3435
|
+
/** Pointer position in canvas space. */
|
|
3436
|
+
point: Point;
|
|
3437
|
+
/** Pointer offset from the lens center, captured at pointer-down. */
|
|
3438
|
+
grabOffset?: Point;
|
|
3439
|
+
/** Graph bounds that minimap-driven navigation may move around. */
|
|
3440
|
+
contentBounds: Rect;
|
|
3441
|
+
/** Current visible canvas bounds; only its size is used. */
|
|
3442
|
+
viewportBounds: Rect;
|
|
3443
|
+
};
|
|
3444
|
+
/**
|
|
3445
|
+
* Resolve a minimap pointer to a bounded viewport center.
|
|
3446
|
+
*
|
|
3447
|
+
* This constraint applies only to minimap navigation. Each axis lets the lens
|
|
3448
|
+
* move fully past the graph, stopping when its nearest edge reaches the graph.
|
|
3449
|
+
*/
|
|
3450
|
+
declare function getMinimapViewportCenter(options: MinimapViewportCenterOptions): Point;
|
|
3417
3451
|
declare function getMinimapProjection(options: MinimapProjectionOptions): MinimapProjection;
|
|
3418
3452
|
//#endregion
|
|
3419
3453
|
//#region src/graph-index.d.ts
|
|
@@ -3466,4 +3500,4 @@ declare const readonlyConfig: Partial<FlowConfig>;
|
|
|
3466
3500
|
*/
|
|
3467
3501
|
declare function resolveBehavior<TEntity, TState>(predicate: ((entity: TEntity, state: TState) => boolean) | false | undefined, entity: TEntity, state: TState, defaultValue?: boolean): boolean;
|
|
3468
3502
|
//#endregion
|
|
3469
|
-
export { type ActiveGraphProjection, type AnchorSpec, type AnchorTransform, type AnimateViewportOptions, type AutoLayoutState, type AvoidRouterOptions, type BehaviorPredicate, type BezierRouterOptions, type BoxSelectModeOptions, type BoxSelectionTest, CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, type CanvasState, type ComposedGraphProjectionAttrs, type ConnectEndTarget, type ConnectModeOptions, type ConnectionCandidate, type ConnectionCandidateOptions, type ConnectionCandidateSource, type ConnectionEndedEvent, type ConnectionPreviewData, type ConnectionPreviewGraphOptions, type ConnectionState, type ConnectionValidationContext, type ConnectionValidationResult, type CreateEdgeInput, type CreateFlowOptions, type CreateNodeInput, type Direction, type EdgeAdjacencyIndex, type EdgeDirection, type EdgePathData, type EdgePathOptions, type EdgeRouter, type EdgeRouterContext, type EdgeRouterGraph, type EdgeRouting, type EdgeSourceBoundsContext, type EntityRect, type EntityVisualState, type FitViewExclusion, type FitViewExclusionSide, type FitViewOptions, type FlowAbortSignal, type FlowAddressable, type FlowAutoSizeAnchor, type FlowCapabilityCommand, type FlowCapabilityResult, type FlowChangeSet, type FlowColorMode, type FlowCommand, type FlowCommitEvent, type FlowConfig, type FlowConfiguration, type FlowConfigureOptions, type FlowConnectMovedEvent, type FlowConnectStartedEvent, type FlowConnection, type FlowConnectionMode, type FlowConnectionOptions, type FlowConnectionsApi, type FlowContent, type FlowContentApi, type FlowContentInsertResult, type FlowController, type FlowCreateIdContext, type FlowDataSchema, type FlowDataSchemas, type FlowDataVersions, type FlowDragEndedEvent, type FlowDragMovedEvent, type FlowDragStartedEvent, type FlowEdge, type FlowEdgeAttributes, type FlowEdgeLabel, type FlowEdgePatch, type FlowEdgeStyle, type FlowEdgeUpdater, type FlowEdgesApi, type FlowEngine, type FlowEngineOptions, type FlowEntitiesDeletedEvent, type FlowEntityChangeNotifier, type FlowEntityChangeNotifierOptions, type FlowEntityGestureEvent, type FlowEntityRef, type FlowEntityUpdate, type FlowErrorEvent, type FlowEventObject, type FlowGestureModifiers, type FlowGraph, type FlowGraphChangedEvent, type FlowGraphHistoryPolicy, type FlowGraphRetentionPolicy, FlowGraphValidationError, type FlowHighlightEntry, type FlowHighlights, type FlowHighlightsApi, type FlowHistoryApi, type FlowInputEffects, type FlowInputEvent, type FlowInputMode, type FlowInputModeContext, type FlowInputModifiers, type FlowInputProfile, type FlowInputReaction, type FlowInputRuntime, type FlowInputRuntimeOptions, type FlowInputSessionHandlers, type FlowInputTarget, type FlowKeyBinding, type FlowKeyInputEvent, type FlowKeymap, type FlowLayoutApi, type FlowModeDefinition, type FlowNode, type FlowNodeAttributes, type FlowNodePatch, type FlowNodeUpdater, type FlowNodesApi, type FlowOrigin, type FlowPaneGestureEvent, type FlowPatch, type FlowPinchInputEvent, type FlowPointerInputEvent, type FlowPolicies, type FlowPort, type FlowProfile, type FlowProjectionListener, type FlowProjectionsApi, type FlowReplaceGraphOptions, type FlowResizeEndedEvent, type FlowResizeStartedEvent, type FlowResolvers, type FlowResult, type FlowRules, type FlowRuntimeSettings, type FlowSelectionAlignment, type FlowSelectionApi, type FlowSelectionChangedEvent, type FlowSelectionDistribution, type FlowSelectionDuplicateResult, type FlowSerialized, type FlowSessionResult, type FlowSettings, type FlowStore, type FlowStoreContext, type FlowStoreOptions, type FlowTransactionDraft, type FlowTransactionOptions, type FlowTransition, type FlowTransitions, type FlowTriggerCommand, type FlowTriggerName, type FlowUpdateEdgeEvent, type FlowUpdateNodeEvent, type FlowValidationIssue, type FlowViewApi, type FlowViewBoundaryEndpoints, type FlowViewChangedEvent, type FlowViewEndpoint, type FlowViewEntities, type FlowViewScope, type FlowViewSelectionPolicy, type FlowViewportApi, type FlowViewportChangedEvent, type FlowWheelInputEvent, type Graph, type GraphDecoration, type GraphEdge, type GraphEdgeAttrs, type GraphNode, type GraphNodeAttrs, type GraphPort, type GraphProjection, type GraphProjectionMapper, type GroupContentSide, type GroupGeometry, type GroupInsets, type GroupLayout, type InteractionMode, type LabelAnchor, type LayoutAlgorithm, type LayoutAnimationControls, type LayoutAnimationOptions, type LayoutApplyOptions, type LayoutDiagnostic, type LayoutEdgeRoute, type LayoutPositions, type LayoutRequestedEvent, type LayoutResult, type LayoutRunOptions, type LayoutRunResult, type MarkerType, type MinimapProjection, type MinimapProjectionOptions, type PathData, type Point, type PortDirection, type ProposedConnection, type ReconnectModeOptions, type Rect, type RenderableEntitiesOptions, type ReparentDecision, type ReparentDropContext, type ReparentOptions, type ResizeConstraints, type ResizeHandle, type ResolvedFitViewExclusion, type SelectionMode, type ShapeHandler, type Side, type Size, type SnapLine, type SnapOptions, type SnapResult, type SpacingGuide, type StandardSchemaV1Like, type StepRouterOptions, type StyleOverrides, type ToolbarPlacement, type ToolbarPlacementInput, type Viewport, type ViewportAnimationCancelFrame, type ViewportAnimationControls, type ViewportAnimationFrame, type ViewportAnimationOptions, type VisualEdge, type VisualGraph, type VisualNode, type VisualPort, type WheelInteraction, type WheelInteractionOptions, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, markerToSVG, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, portPressMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape, resolveBehavior, resolveGroupPadding, resolveKeymap, resolvedBounds, resolvedEdgeLabelBounds, resolvedEdgeLabelSize, resolvedPosition, resolvedSelectionBounds, screenToCanvas, selectMode, serializeFlowGraph, snapPointToGrid, snapToGrid, snappedBounds, sortActiveGraphProjections, stepRouter, straightRouter, toSVGTransform, toViewBox, trigger, unionRect, validateAndCloneGraph, validateFitFrame, validateViewport, viewportCenteredOn, viewportForBounds, visualBounds, visualPosition, wheelInteraction, wheelMode, wheelZoomDelta, zoomTo };
|
|
3503
|
+
export { type ActiveGraphProjection, type AnchorSpec, type AnchorTransform, type AnimateViewportOptions, type AutoLayoutState, type AvoidRouterOptions, type BehaviorPredicate, type BezierRouterOptions, type BoxSelectModeOptions, type BoxSelectionTest, CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, type CanvasState, type ComposedGraphProjectionAttrs, type ConnectEndTarget, type ConnectModeOptions, type ConnectionCandidate, type ConnectionCandidateOptions, type ConnectionCandidateSource, type ConnectionEndedEvent, type ConnectionPreviewData, type ConnectionPreviewGraphOptions, type ConnectionState, type ConnectionValidationContext, type ConnectionValidationResult, type CreateEdgeInput, type CreateFlowOptions, type CreateNodeInput, type Direction, type EdgeAdjacencyIndex, type EdgeDirection, type EdgePathData, type EdgePathOptions, type EdgeRouter, type EdgeRouterContext, type EdgeRouterGraph, type EdgeRouting, type EdgeSourceBoundsContext, type EntityRect, type EntityVisualState, type FitViewExclusion, type FitViewExclusionSide, type FitViewOptions, type FlowAbortSignal, type FlowAddressable, type FlowAutoSizeAnchor, type FlowCapabilityCommand, type FlowCapabilityResult, type FlowChangeSet, type FlowColorMode, type FlowCommand, type FlowCommitEvent, type FlowConfig, type FlowConfiguration, type FlowConfigureOptions, type FlowConnectMovedEvent, type FlowConnectStartedEvent, type FlowConnection, type FlowConnectionMode, type FlowConnectionOptions, type FlowConnectionsApi, type FlowContent, type FlowContentApi, type FlowContentInsertResult, type FlowController, type FlowCreateIdContext, type FlowDataSchema, type FlowDataSchemas, type FlowDataVersions, type FlowDragEndedEvent, type FlowDragMovedEvent, type FlowDragStartedEvent, type FlowEdge, type FlowEdgeAttributes, type FlowEdgeLabel, type FlowEdgePatch, type FlowEdgeStyle, type FlowEdgeUpdater, type FlowEdgesApi, type FlowEngine, type FlowEngineOptions, type FlowEntitiesDeletedEvent, type FlowEntityChangeNotifier, type FlowEntityChangeNotifierOptions, type FlowEntityGestureEvent, type FlowEntityRef, type FlowEntityUpdate, type FlowErrorEvent, type FlowEventObject, type FlowGestureModifiers, type FlowGraph, type FlowGraphChangedEvent, type FlowGraphHistoryPolicy, type FlowGraphRetentionPolicy, FlowGraphValidationError, type FlowHighlightEntry, type FlowHighlights, type FlowHighlightsApi, type FlowHistoryApi, type FlowInputEffects, type FlowInputEvent, type FlowInputMode, type FlowInputModeContext, type FlowInputModifiers, type FlowInputProfile, type FlowInputReaction, type FlowInputRuntime, type FlowInputRuntimeOptions, type FlowInputSessionHandlers, type FlowInputTarget, type FlowKeyBinding, type FlowKeyInputEvent, type FlowKeymap, type FlowLayoutApi, type FlowModeDefinition, type FlowNode, type FlowNodeAttributes, type FlowNodePatch, type FlowNodeUpdater, type FlowNodesApi, type FlowOrigin, type FlowPaneGestureEvent, type FlowPatch, type FlowPinchInputEvent, type FlowPointerInputEvent, type FlowPolicies, type FlowPort, type FlowProfile, type FlowProjectionListener, type FlowProjectionsApi, type FlowReplaceGraphOptions, type FlowResizeEndedEvent, type FlowResizeStartedEvent, type FlowResolvers, type FlowResult, type FlowRules, type FlowRuntimeSettings, type FlowSelectionAlignment, type FlowSelectionApi, type FlowSelectionChangedEvent, type FlowSelectionDistribution, type FlowSelectionDuplicateResult, type FlowSerialized, type FlowSessionResult, type FlowSettings, type FlowStore, type FlowStoreContext, type FlowStoreOptions, type FlowTransactionDraft, type FlowTransactionOptions, type FlowTransition, type FlowTransitions, type FlowTriggerCommand, type FlowTriggerName, type FlowUpdateEdgeEvent, type FlowUpdateNodeEvent, type FlowValidationIssue, type FlowViewApi, type FlowViewBoundaryEndpoints, type FlowViewChangedEvent, type FlowViewEndpoint, type FlowViewEntities, type FlowViewScope, type FlowViewSelectionPolicy, type FlowViewportApi, type FlowViewportChangedEvent, type FlowWheelInputEvent, type Graph, type GraphDecoration, type GraphEdge, type GraphEdgeAttrs, type GraphNode, type GraphNodeAttrs, type GraphPort, type GraphProjection, type GraphProjectionMapper, type GroupContentSide, type GroupGeometry, type GroupInsets, type GroupLayout, type InteractionMode, type LabelAnchor, type LayoutAlgorithm, type LayoutAnimationControls, type LayoutAnimationOptions, type LayoutApplyOptions, type LayoutDiagnostic, type LayoutEdgeRoute, type LayoutPositions, type LayoutRequestedEvent, type LayoutResult, type LayoutRunOptions, type LayoutRunResult, type MarkerType, type MinimapProjection, type MinimapProjectionOptions, type MinimapViewportCenterOptions, type PathData, type Point, type PortDirection, type ProposedConnection, type ReconnectModeOptions, type Rect, type RenderableEntitiesOptions, type ReparentDecision, type ReparentDropContext, type ReparentOptions, type ResizeConstraints, type ResizeHandle, type ResolvedFitViewExclusion, type SelectionMode, type ShapeHandler, type Side, type Size, type SnapLine, type SnapOptions, type SnapResult, type SpacingGuide, type StandardSchemaV1Like, type StepRouterOptions, type StyleOverrides, type ToolbarPlacement, type ToolbarPlacementInput, type Viewport, type ViewportAnimationCancelFrame, type ViewportAnimationControls, type ViewportAnimationFrame, type ViewportAnimationOptions, type VisualEdge, type VisualGraph, type VisualNode, type VisualPort, type WheelInteraction, type WheelInteractionOptions, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getMinimapViewportCenter, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, markerToSVG, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, portPressMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape, resolveBehavior, resolveGroupPadding, resolveKeymap, resolvedBounds, resolvedEdgeLabelBounds, resolvedEdgeLabelSize, resolvedPosition, resolvedSelectionBounds, screenToCanvas, selectMode, serializeFlowGraph, snapPointToGrid, snapToGrid, snappedBounds, sortActiveGraphProjections, stepRouter, straightRouter, toSVGTransform, toViewBox, trigger, unionRect, validateAndCloneGraph, validateFitFrame, validateViewport, viewportCenteredOn, viewportForBounds, visualBounds, visualPosition, wheelInteraction, wheelMode, wheelZoomDelta, zoomTo };
|
package/dist/esm/index.js
CHANGED
|
@@ -807,14 +807,19 @@ function constrainViewport(viewport, viewportSize, translateExtent) {
|
|
|
807
807
|
* Returns screen-space delta to apply per frame. Returns {0,0} if cursor isn't near an edge.
|
|
808
808
|
*/
|
|
809
809
|
function calcAutoPan(mousePosition, containerBounds, edgeWidth = 25, speed = 10) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
810
|
+
if (edgeWidth <= 0 || speed <= 0) return {
|
|
811
|
+
x: 0,
|
|
812
|
+
y: 0
|
|
813
|
+
};
|
|
814
|
+
const clamp01 = (value) => Math.min(1, Math.max(0, value));
|
|
815
|
+
const getAxisDelta = (position, size) => {
|
|
816
|
+
if (position < edgeWidth) return -speed * clamp01(1 - position / edgeWidth);
|
|
817
|
+
if (position > size - edgeWidth) return speed * clamp01(1 - (size - position) / edgeWidth);
|
|
818
|
+
return 0;
|
|
819
|
+
};
|
|
815
820
|
return {
|
|
816
|
-
x:
|
|
817
|
-
y:
|
|
821
|
+
x: getAxisDelta(mousePosition.x, containerBounds.width),
|
|
822
|
+
y: getAxisDelta(mousePosition.y, containerBounds.height)
|
|
818
823
|
};
|
|
819
824
|
}
|
|
820
825
|
/**
|
|
@@ -3096,6 +3101,21 @@ function createEventObject(type, event) {
|
|
|
3096
3101
|
function isExplicitlyVisibleNode(node) {
|
|
3097
3102
|
return !node.hidden;
|
|
3098
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* A collapsed group hides its descendants: they are not selectable and do not
|
|
3106
|
+
* contribute to any group's derived selection geometry. Mirrors the engine's
|
|
3107
|
+
* `isHiddenByCollapsedAncestor`.
|
|
3108
|
+
*/
|
|
3109
|
+
function isHiddenByCollapsedAncestor(ctx, nodeId) {
|
|
3110
|
+
if (ctx.collapsedNodeIds.size === 0) return false;
|
|
3111
|
+
const nodeIndex = indexNodes(ctx.graph.nodes);
|
|
3112
|
+
let parentId = nodeIndex.get(nodeId)?.parentId;
|
|
3113
|
+
while (parentId) {
|
|
3114
|
+
if (ctx.collapsedNodeIds.has(parentId)) return true;
|
|
3115
|
+
parentId = nodeIndex.get(parentId)?.parentId;
|
|
3116
|
+
}
|
|
3117
|
+
return false;
|
|
3118
|
+
}
|
|
3099
3119
|
function isDescendantOf(nodes, nodeId, ancestorId) {
|
|
3100
3120
|
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
3101
3121
|
let parentId = byId.get(nodeId)?.parentId;
|
|
@@ -3130,6 +3150,7 @@ function entitiesInBox(ctx, rect) {
|
|
|
3130
3150
|
const nodes = ctx.graph.nodes;
|
|
3131
3151
|
for (const node of nodes) {
|
|
3132
3152
|
if (!isExplicitlyVisibleNode(node)) continue;
|
|
3153
|
+
if (isHiddenByCollapsedAncestor(ctx, node.id)) continue;
|
|
3133
3154
|
if (test(rect, nodeSelectionBounds(ctx, node))) ids.add(node.id);
|
|
3134
3155
|
}
|
|
3135
3156
|
for (const edge of ctx.graph.edges) {
|
|
@@ -3169,6 +3190,7 @@ function groupGeometryForSelection(ctx, node, visiting) {
|
|
|
3169
3190
|
};
|
|
3170
3191
|
for (const child of ctx.graph.nodes) {
|
|
3171
3192
|
if (child.parentId !== node.id || !isExplicitlyVisibleNode(child)) continue;
|
|
3193
|
+
if (isHiddenByCollapsedAncestor(ctx, child.id)) continue;
|
|
3172
3194
|
addBounds(child.group && !nextVisiting.has(child.id) ? groupGeometryForSelection(ctx, child, nextVisiting).bounds : resolvedBounds(child));
|
|
3173
3195
|
}
|
|
3174
3196
|
const nodeIndex = indexNodes(ctx.graph.nodes);
|
|
@@ -3244,6 +3266,7 @@ function createFlowStore(initialGraph = {
|
|
|
3244
3266
|
connectionClickStartHandle: null,
|
|
3245
3267
|
panOrigin: null,
|
|
3246
3268
|
panViewportOrigin: null,
|
|
3269
|
+
viewportAnimation: options.viewportAnimation ?? null,
|
|
3247
3270
|
resizingEntityId: null,
|
|
3248
3271
|
resizeHandle: null,
|
|
3249
3272
|
resizeCorners: null,
|
|
@@ -4140,6 +4163,7 @@ function createFlowStore(initialGraph = {
|
|
|
4140
4163
|
if (event.autoPanOnDrag !== void 0) draft.autoPanOnDrag = event.autoPanOnDrag;
|
|
4141
4164
|
if (event.autoPanThreshold !== void 0) draft.autoPanThreshold = Math.max(0, event.autoPanThreshold);
|
|
4142
4165
|
if (event.autoPanSpeed !== void 0) draft.autoPanSpeed = Math.max(0, event.autoPanSpeed);
|
|
4166
|
+
if (event.viewportAnimation !== void 0) draft.viewportAnimation = event.viewportAnimation;
|
|
4143
4167
|
if (event.enableSnapLines !== void 0) draft.enableSnapLines = event.enableSnapLines;
|
|
4144
4168
|
if (event.snapThreshold !== void 0) draft.snapThreshold = Math.max(0, event.snapThreshold);
|
|
4145
4169
|
if (event.enableSpacingGuides !== void 0) draft.enableSpacingGuides = event.enableSpacingGuides;
|
|
@@ -4159,6 +4183,7 @@ function createFlowStore(initialGraph = {
|
|
|
4159
4183
|
if (event.autoPanOnDrag !== void 0) draft.autoPanOnDrag = event.autoPanOnDrag;
|
|
4160
4184
|
if (event.autoPanThreshold !== void 0) draft.autoPanThreshold = Math.max(0, event.autoPanThreshold);
|
|
4161
4185
|
if (event.autoPanSpeed !== void 0) draft.autoPanSpeed = Math.max(0, event.autoPanSpeed);
|
|
4186
|
+
if (event.viewportAnimation !== void 0) draft.viewportAnimation = event.viewportAnimation;
|
|
4162
4187
|
if (event.snapToGrid !== void 0) draft.snapToGrid = event.snapToGrid;
|
|
4163
4188
|
if (event.snapGrid !== void 0) draft.snapGrid = event.snapGrid;
|
|
4164
4189
|
if (event.enableSnapLines !== void 0) draft.enableSnapLines = event.enableSnapLines;
|
|
@@ -5019,6 +5044,7 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
5019
5044
|
let renderableCache = /* @__PURE__ */ new WeakMap();
|
|
5020
5045
|
let entityOrderCache = null;
|
|
5021
5046
|
let baseEntityOrderCache = null;
|
|
5047
|
+
let paintZIndicesCache = /* @__PURE__ */ new WeakMap();
|
|
5022
5048
|
let entityRankCache = null;
|
|
5023
5049
|
let renderableSpatialIndex = null;
|
|
5024
5050
|
let graphBoundsCache = null;
|
|
@@ -5085,6 +5111,7 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
5085
5111
|
renderableCache = /* @__PURE__ */ new WeakMap();
|
|
5086
5112
|
entityOrderCache = null;
|
|
5087
5113
|
baseEntityOrderCache = null;
|
|
5114
|
+
paintZIndicesCache = /* @__PURE__ */ new WeakMap();
|
|
5088
5115
|
entityRankCache = null;
|
|
5089
5116
|
renderableSpatialIndex = null;
|
|
5090
5117
|
graphBoundsCache = null;
|
|
@@ -5640,7 +5667,6 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
5640
5667
|
const edge = getEdge(edgeId);
|
|
5641
5668
|
if (!edge?.label) return null;
|
|
5642
5669
|
const measured = c.measurements.get(edgeId);
|
|
5643
|
-
if (measured && !edge.label.autoSize) return measured;
|
|
5644
5670
|
return resolveEdgeLabelBounds(edge, indexNodes(c.graph.nodes), measured);
|
|
5645
5671
|
}
|
|
5646
5672
|
function getBounds(id) {
|
|
@@ -6385,6 +6411,61 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
6385
6411
|
else baseEntityOrderCache = nextCache;
|
|
6386
6412
|
return value;
|
|
6387
6413
|
}
|
|
6414
|
+
function getPaintZIndicesFor(c, options = {}) {
|
|
6415
|
+
const elevateSelected = options.elevateSelected ?? true;
|
|
6416
|
+
const cacheKey = `${optionsVersion}:${elevateSelected}`;
|
|
6417
|
+
const snapshotCache = paintZIndicesCache.get(c);
|
|
6418
|
+
const cached = snapshotCache?.get(cacheKey);
|
|
6419
|
+
if (cached) return cached;
|
|
6420
|
+
const baseOrder = getEntityOrderFor(c, { elevateSelected: false });
|
|
6421
|
+
const depths = nodeDepths(c.graph.nodes);
|
|
6422
|
+
const visibleNodes = baseOrder.nodes.filter((node) => isNodeVisible(node, c));
|
|
6423
|
+
const visibleEdges = baseOrder.edges.filter((edge) => isEdgeVisible(edge, c.graph, c));
|
|
6424
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
6425
|
+
const edges = /* @__PURE__ */ new Map();
|
|
6426
|
+
for (let start = 0; start < visibleNodes.length;) {
|
|
6427
|
+
const first = visibleNodes[start];
|
|
6428
|
+
const depth = depths.get(first.id) ?? 0;
|
|
6429
|
+
const zIndex = first.zIndex ?? 0;
|
|
6430
|
+
let end = start + 1;
|
|
6431
|
+
while (end < visibleNodes.length) {
|
|
6432
|
+
const node = visibleNodes[end];
|
|
6433
|
+
if ((depths.get(node.id) ?? 0) !== depth || (node.zIndex ?? 0) !== zIndex) break;
|
|
6434
|
+
end++;
|
|
6435
|
+
}
|
|
6436
|
+
const elevatedZIndex = 2 * (end - 1) + 1;
|
|
6437
|
+
for (let index = start; index < end; index++) {
|
|
6438
|
+
const node = visibleNodes[index];
|
|
6439
|
+
nodes.set(node.id, elevateSelected && selectedBoostEnabled("node") && c.selection.has(node.id) ? elevatedZIndex : 2 * index);
|
|
6440
|
+
}
|
|
6441
|
+
start = end;
|
|
6442
|
+
}
|
|
6443
|
+
for (let start = 0; start < visibleEdges.length;) {
|
|
6444
|
+
const first = visibleEdges[start];
|
|
6445
|
+
const depth = Math.max(depths.get(first.sourceId) ?? 0, depths.get(first.targetId) ?? 0);
|
|
6446
|
+
const zIndex = first.zIndex ?? 0;
|
|
6447
|
+
let end = start + 1;
|
|
6448
|
+
while (end < visibleEdges.length) {
|
|
6449
|
+
const edge = visibleEdges[end];
|
|
6450
|
+
if (Math.max(depths.get(edge.sourceId) ?? 0, depths.get(edge.targetId) ?? 0) !== depth || (edge.zIndex ?? 0) !== zIndex) break;
|
|
6451
|
+
end++;
|
|
6452
|
+
}
|
|
6453
|
+
const elevatedZIndex = 2 * (end - 1) + 1;
|
|
6454
|
+
for (let index = start; index < end; index++) {
|
|
6455
|
+
const edge = visibleEdges[index];
|
|
6456
|
+
edges.set(edge.id, elevateSelected && selectedBoostEnabled("edge") && c.selection.has(edge.id) ? elevatedZIndex : 2 * index);
|
|
6457
|
+
}
|
|
6458
|
+
start = end;
|
|
6459
|
+
}
|
|
6460
|
+
const value = {
|
|
6461
|
+
nodes,
|
|
6462
|
+
edges
|
|
6463
|
+
};
|
|
6464
|
+
const nextSnapshotCache = snapshotCache ?? /* @__PURE__ */ new Map();
|
|
6465
|
+
nextSnapshotCache.set(cacheKey, value);
|
|
6466
|
+
if (!snapshotCache) paintZIndicesCache.set(c, nextSnapshotCache);
|
|
6467
|
+
return value;
|
|
6468
|
+
}
|
|
6388
6469
|
function getPublicVisualBounds(nodeOrId) {
|
|
6389
6470
|
const node = typeof nodeOrId === "string" ? getNode(nodeOrId) : nodeOrId;
|
|
6390
6471
|
if (!node) return {
|
|
@@ -6632,6 +6713,16 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
6632
6713
|
/** Deterministic paint order. Later items should paint above earlier ones. */
|
|
6633
6714
|
getEntityOrder: (options = {}) => getEntityOrderFor(ctx(), options),
|
|
6634
6715
|
/**
|
|
6716
|
+
* CSS z-indices for the visible entity set. Base values are spaced by 2.
|
|
6717
|
+
* When `elevateOnSelect` allows an entity kind, a selected entity is
|
|
6718
|
+
* raised just above its own depth/zIndex band while remaining below the
|
|
6719
|
+
* next band, so a selected parent never paints over its descendants.
|
|
6720
|
+
* Multiple selected entities in one band tie; the renderer's DOM order
|
|
6721
|
+
* resolves the tie and matches core's elevated order. The result is
|
|
6722
|
+
* memoized per store snapshot so callers can compare it by identity.
|
|
6723
|
+
*/
|
|
6724
|
+
getPaintZIndices: (options = {}) => getPaintZIndicesFor(ctx(), options),
|
|
6725
|
+
/**
|
|
6635
6726
|
* Renderable (visible, optionally viewport-culled) entities. Memoized per
|
|
6636
6727
|
* (store snapshot, cull/overscan) so several render layers can share one
|
|
6637
6728
|
* computation per frame. Treat the result as read-only.
|
|
@@ -7998,7 +8089,23 @@ function createFlow(options = {}) {
|
|
|
7998
8089
|
return resolvedViewportControls();
|
|
7999
8090
|
}
|
|
8000
8091
|
cancelViewportAnimation();
|
|
8001
|
-
|
|
8092
|
+
const resolvedAnimationOptions = {
|
|
8093
|
+
...store.getSnapshot().context.viewportAnimation ?? {},
|
|
8094
|
+
...animationOptions,
|
|
8095
|
+
...animationOptions?.duration !== void 0 ? {
|
|
8096
|
+
lerp: void 0,
|
|
8097
|
+
spring: void 0
|
|
8098
|
+
} : animationOptions?.lerp !== void 0 ? {
|
|
8099
|
+
duration: void 0,
|
|
8100
|
+
easing: void 0,
|
|
8101
|
+
spring: void 0
|
|
8102
|
+
} : animationOptions?.spring !== void 0 ? {
|
|
8103
|
+
duration: void 0,
|
|
8104
|
+
easing: void 0,
|
|
8105
|
+
lerp: void 0
|
|
8106
|
+
} : {}
|
|
8107
|
+
};
|
|
8108
|
+
if ((resolvedAnimationOptions.duration ?? 0) <= 0 && !resolvedAnimationOptions.spring && resolvedAnimationOptions.lerp === void 0) {
|
|
8002
8109
|
store.trigger.setViewport(target);
|
|
8003
8110
|
return resolvedViewportControls();
|
|
8004
8111
|
}
|
|
@@ -8008,7 +8115,7 @@ function createFlow(options = {}) {
|
|
|
8008
8115
|
...store.trigger,
|
|
8009
8116
|
setViewport: writeViewport
|
|
8010
8117
|
}
|
|
8011
|
-
}, target,
|
|
8118
|
+
}, target, resolvedAnimationOptions);
|
|
8012
8119
|
activeViewportAnimation = animation;
|
|
8013
8120
|
animation.done.then(() => {
|
|
8014
8121
|
if (activeViewportAnimation === animation) activeViewportAnimation = null;
|
|
@@ -9046,7 +9153,7 @@ function fromJSON(data, options = {}) {
|
|
|
9046
9153
|
graph: parsed.graph
|
|
9047
9154
|
});
|
|
9048
9155
|
flow.internals.store.trigger.setCollapsedNodes({ ids: parsed.collapsedNodeIds ?? [] });
|
|
9049
|
-
flow.
|
|
9156
|
+
flow.internals.store.trigger.setViewport(parsed.viewport);
|
|
9050
9157
|
return flow;
|
|
9051
9158
|
}
|
|
9052
9159
|
//#endregion
|
|
@@ -9121,6 +9228,32 @@ function getToolbarPlacement(input) {
|
|
|
9121
9228
|
}
|
|
9122
9229
|
//#endregion
|
|
9123
9230
|
//#region src/minimap.ts
|
|
9231
|
+
/**
|
|
9232
|
+
* Resolve a minimap pointer to a bounded viewport center.
|
|
9233
|
+
*
|
|
9234
|
+
* This constraint applies only to minimap navigation. Each axis lets the lens
|
|
9235
|
+
* move fully past the graph, stopping when its nearest edge reaches the graph.
|
|
9236
|
+
*/
|
|
9237
|
+
function getMinimapViewportCenter(options) {
|
|
9238
|
+
const grabOffset = options.grabOffset ?? {
|
|
9239
|
+
x: 0,
|
|
9240
|
+
y: 0
|
|
9241
|
+
};
|
|
9242
|
+
const target = {
|
|
9243
|
+
x: options.point.x - grabOffset.x,
|
|
9244
|
+
y: options.point.y - grabOffset.y
|
|
9245
|
+
};
|
|
9246
|
+
const halfWidth = Math.max(0, options.viewportBounds.width) / 2;
|
|
9247
|
+
const halfHeight = Math.max(0, options.viewportBounds.height) / 2;
|
|
9248
|
+
const minX = options.contentBounds.x - halfWidth;
|
|
9249
|
+
const maxX = options.contentBounds.x + options.contentBounds.width + halfWidth;
|
|
9250
|
+
const minY = options.contentBounds.y - halfHeight;
|
|
9251
|
+
const maxY = options.contentBounds.y + options.contentBounds.height + halfHeight;
|
|
9252
|
+
return {
|
|
9253
|
+
x: Math.min(Math.max(target.x, minX), maxX),
|
|
9254
|
+
y: Math.min(Math.max(target.y, minY), maxY)
|
|
9255
|
+
};
|
|
9256
|
+
}
|
|
9124
9257
|
function getMinimapProjection(options) {
|
|
9125
9258
|
const padding = options.padding ?? .1;
|
|
9126
9259
|
const content = options.contentBounds;
|
|
@@ -10499,11 +10632,12 @@ function profilePoliciesForContext(profile) {
|
|
|
10499
10632
|
};
|
|
10500
10633
|
}
|
|
10501
10634
|
/**
|
|
10502
|
-
* Per-frame auto-pan step while a drag
|
|
10503
|
-
* container edge. Returns the `calcAutoPan` screen-space
|
|
10504
|
-
* `panBy`), or null when auto-pan should not run. Adapters
|
|
10505
|
-
* frame ticker while a gesture session is active and re-send
|
|
10506
|
-
* pointer afterwards so the dragged entity follows the panned
|
|
10635
|
+
* Per-frame, pointer-driven auto-pan step while a drag, connection, or resize
|
|
10636
|
+
* gesture is near the container edge. Returns the `calcAutoPan` screen-space
|
|
10637
|
+
* delta (negate it for `panBy`), or null when auto-pan should not run. Adapters
|
|
10638
|
+
* call this from a frame ticker while a gesture session is active and re-send
|
|
10639
|
+
* the stationary pointer afterwards so the dragged entity follows the panned
|
|
10640
|
+
* canvas.
|
|
10507
10641
|
*/
|
|
10508
10642
|
function getAutoPanDelta(context, screenPoint, engine) {
|
|
10509
10643
|
if (!context.autoPanOnDrag) return null;
|
|
@@ -10512,44 +10646,6 @@ function getAutoPanDelta(context, screenPoint, engine) {
|
|
|
10512
10646
|
if (size.width === 0 || size.height === 0) return null;
|
|
10513
10647
|
const delta = calcAutoPan(screenPoint, size, context.autoPanThreshold, context.autoPanSpeed);
|
|
10514
10648
|
if (delta.x === 0 && delta.y === 0) return null;
|
|
10515
|
-
const toScreen = (b) => {
|
|
10516
|
-
const x0 = b.x * context.viewport.zoom + context.viewport.x;
|
|
10517
|
-
const y0 = b.y * context.viewport.zoom + context.viewport.y;
|
|
10518
|
-
return {
|
|
10519
|
-
x0,
|
|
10520
|
-
y0,
|
|
10521
|
-
x1: x0 + b.width * context.viewport.zoom,
|
|
10522
|
-
y1: y0 + b.height * context.viewport.zoom
|
|
10523
|
-
};
|
|
10524
|
-
};
|
|
10525
|
-
const gateByBounds = (union) => {
|
|
10526
|
-
const edge = context.autoPanThreshold;
|
|
10527
|
-
if (delta.x < 0 && union.x0 > edge) delta.x = 0;
|
|
10528
|
-
if (delta.x > 0 && union.x1 < size.width - edge) delta.x = 0;
|
|
10529
|
-
if (delta.y < 0 && union.y0 > edge) delta.y = 0;
|
|
10530
|
-
if (delta.y > 0 && union.y1 < size.height - edge) delta.y = 0;
|
|
10531
|
-
if (delta.x === 0 && delta.y === 0) return null;
|
|
10532
|
-
return delta;
|
|
10533
|
-
};
|
|
10534
|
-
if (engine && context.canvasState === "dragging") {
|
|
10535
|
-
let union = null;
|
|
10536
|
-
for (const selectedId of context.selection) {
|
|
10537
|
-
const node = engine.getNode(selectedId);
|
|
10538
|
-
if (!node || node.draggable === false) continue;
|
|
10539
|
-
const s = toScreen(engine.resolvedBounds(selectedId));
|
|
10540
|
-
union = union ? {
|
|
10541
|
-
x0: Math.min(union.x0, s.x0),
|
|
10542
|
-
y0: Math.min(union.y0, s.y0),
|
|
10543
|
-
x1: Math.max(union.x1, s.x1),
|
|
10544
|
-
y1: Math.max(union.y1, s.y1)
|
|
10545
|
-
} : s;
|
|
10546
|
-
}
|
|
10547
|
-
if (union) return gateByBounds(union);
|
|
10548
|
-
}
|
|
10549
|
-
if (engine && context.canvasState === "resizing") {
|
|
10550
|
-
const rect = engine.getResizeBounds();
|
|
10551
|
-
if (rect) return gateByBounds(toScreen(rect));
|
|
10552
|
-
}
|
|
10553
10649
|
return delta;
|
|
10554
10650
|
}
|
|
10555
10651
|
//#endregion
|
|
@@ -10780,4 +10876,4 @@ function createEntityChangeNotifier(store, options = {}) {
|
|
|
10780
10876
|
};
|
|
10781
10877
|
}
|
|
10782
10878
|
//#endregion
|
|
10783
|
-
export { CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, FlowGraphValidationError, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, markerToSVG, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, portPressMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape, resolveBehavior, resolveGroupPadding, resolveKeymap, resolvedBounds, resolvedEdgeLabelBounds, resolvedEdgeLabelSize, resolvedPosition, resolvedSelectionBounds, screenToCanvas, selectMode, serializeFlowGraph, snapPointToGrid, snapToGrid, snappedBounds, sortActiveGraphProjections, stepRouter, straightRouter, toSVGTransform, toViewBox, trigger, unionRect, validateAndCloneGraph, validateFitFrame, validateViewport, viewportCenteredOn, viewportForBounds, visualBounds, visualPosition, wheelInteraction, wheelMode, wheelZoomDelta, zoomTo };
|
|
10879
|
+
export { CONNECTION_PREVIEW_EDGE_ID, CONNECTION_PREVIEW_NODE_ID, FlowGraphValidationError, animateViewport, applyFlowPatches, areNodesMeasured, avoidRouter, bestDirection, bezierRouter, boxSelectMode, boxToRect, calcAutoPan, canvasToScreen, clampZoom, cloneJsonSafe, composeGraphProjectionAttrs, configureAvoidRouter, configureBezierRouter, configureStepRouter, connectMode, constrainViewport, createConnectionPreviewGraph, createEdge, createEntityChangeNotifier, createFlow, createFlowChangeSet, createFlowEngine, createFlowInputRuntime, createFlowStore, createGraph, createNode, createPort, createViewport, defaultConfig, defaultFlowProfile, defaultInputModes, defaultInputModesForKeymap, defaultKeymap, defaultModesForContext, defineFlowProfile, deriveFlowView, deriveGroupGeometry, entityPressMode, extractFlowContent, fitFrameAroundExclusions, fixedGroupGeometry, fromJSON, getAnchorTransform, getAutoPanDelta, getConnectedEdges, getEdgeOwner, getGraphBounds, getIncomers, getMinimapProjection, getMinimapViewportCenter, getNeighbors, getOutgoers, getProjectedEdgeAttrs, getProjectedNodeAttrs, getSelectionBounds, getShape, getShapeOrDefault, getSnapLines, getToolbarPlacement, getVisibleBounds, hoverMode, indexChildren, indexEdgeAdjacency, indexEdges, indexNodes, insertFlowContent, isDerivedGroup, isGroup, isTrackpadPinch, keyboardMode, keyboardNavMode, markerToSVG, matchesKeyBinding, mergeGraphEdgeAttrs, mergeGraphNodeAttrs, nodeDepths, normalizeWheelPan, panBy, panMode, panePressMode, parseFlowSerialized, pathToSVG, pinchMode, portPressMode, preventDefault, profileModesForContext, profilePoliciesForContext, readonlyConfig, readonlyInputModes, readonlyInputModesForKeymap, reconnectMode, rectContains, rectsIntersect, registerShape, resolveBehavior, resolveGroupPadding, resolveKeymap, resolvedBounds, resolvedEdgeLabelBounds, resolvedEdgeLabelSize, resolvedPosition, resolvedSelectionBounds, screenToCanvas, selectMode, serializeFlowGraph, snapPointToGrid, snapToGrid, snappedBounds, sortActiveGraphProjections, stepRouter, straightRouter, toSVGTransform, toViewBox, trigger, unionRect, validateAndCloneGraph, validateFitFrame, validateViewport, viewportCenteredOn, viewportForBounds, visualBounds, visualPosition, wheelInteraction, wheelMode, wheelZoomDelta, zoomTo };
|