@statelyai/flow 0.9.1 → 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 +31 -11
- package/dist/esm/index.js +67 -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
|
@@ -1888,18 +1888,17 @@ declare function defaultModesForContext(context: FlowStoreContext, keymap?: Part
|
|
|
1888
1888
|
declare function profileModesForContext(profile: FlowProfile): (context: FlowStoreContext) => FlowInputMode[];
|
|
1889
1889
|
declare function profilePoliciesForContext(profile: FlowProfile): (context: FlowStoreContext) => FlowPolicies;
|
|
1890
1890
|
/**
|
|
1891
|
-
* Per-frame auto-pan step while a drag
|
|
1892
|
-
* container edge. Returns the `calcAutoPan` screen-space
|
|
1893
|
-
* `panBy`), or null when auto-pan should not run. Adapters
|
|
1894
|
-
* frame ticker while a gesture session is active and re-send
|
|
1895
|
-
* 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.
|
|
1896
1897
|
*/
|
|
1897
1898
|
declare function getAutoPanDelta(context: FlowStoreContext, screenPoint: Point,
|
|
1898
1899
|
/**
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
* actually reaches that viewport edge. Prevents pointless scrolling when a
|
|
1902
|
-
* 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.
|
|
1903
1902
|
*/
|
|
1904
1903
|
engine?: FlowEngine): Point | null;
|
|
1905
1904
|
//#endregion
|
|
@@ -2075,6 +2074,8 @@ type FlowStoreContext = {
|
|
|
2075
2074
|
} | null;
|
|
2076
2075
|
panOrigin: Point | null;
|
|
2077
2076
|
panViewportOrigin: Viewport | null;
|
|
2077
|
+
/** Default animation applied to viewport commands unless overridden per call. */
|
|
2078
|
+
viewportAnimation: ViewportAnimationOptions | null;
|
|
2078
2079
|
resizingEntityId: string | null;
|
|
2079
2080
|
resizeHandle: ResizeHandle | null;
|
|
2080
2081
|
/** Two opposite corners during resize: [anchor, moving]. Derived bounds = min/max of these. */
|
|
@@ -2136,6 +2137,8 @@ type FlowStoreOptions = {
|
|
|
2136
2137
|
autoPanOnDrag?: boolean;
|
|
2137
2138
|
autoPanThreshold?: number;
|
|
2138
2139
|
autoPanSpeed?: number;
|
|
2140
|
+
/** Default animation applied to viewport commands unless overridden per call. */
|
|
2141
|
+
viewportAnimation?: ViewportAnimationOptions | null;
|
|
2139
2142
|
snapToGrid?: boolean;
|
|
2140
2143
|
snapGrid?: [number, number];
|
|
2141
2144
|
enableSnapLines?: boolean;
|
|
@@ -2163,7 +2166,7 @@ type FlowStoreOptions = {
|
|
|
2163
2166
|
edges: FlowEdge[];
|
|
2164
2167
|
});
|
|
2165
2168
|
};
|
|
2166
|
-
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'>;
|
|
2167
2170
|
type LayoutRequestedEvent = {
|
|
2168
2171
|
algorithm: string;
|
|
2169
2172
|
graph: FlowGraph;
|
|
@@ -3428,6 +3431,23 @@ type MinimapProjection = {
|
|
|
3428
3431
|
toCanvas(point: Point): Point;
|
|
3429
3432
|
rectToMinimap(rect: Rect): Rect;
|
|
3430
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;
|
|
3431
3451
|
declare function getMinimapProjection(options: MinimapProjectionOptions): MinimapProjection;
|
|
3432
3452
|
//#endregion
|
|
3433
3453
|
//#region src/graph-index.d.ts
|
|
@@ -3480,4 +3500,4 @@ declare const readonlyConfig: Partial<FlowConfig>;
|
|
|
3480
3500
|
*/
|
|
3481
3501
|
declare function resolveBehavior<TEntity, TState>(predicate: ((entity: TEntity, state: TState) => boolean) | false | undefined, entity: TEntity, state: TState, defaultValue?: boolean): boolean;
|
|
3482
3502
|
//#endregion
|
|
3483
|
-
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
|
/**
|
|
@@ -3261,6 +3266,7 @@ function createFlowStore(initialGraph = {
|
|
|
3261
3266
|
connectionClickStartHandle: null,
|
|
3262
3267
|
panOrigin: null,
|
|
3263
3268
|
panViewportOrigin: null,
|
|
3269
|
+
viewportAnimation: options.viewportAnimation ?? null,
|
|
3264
3270
|
resizingEntityId: null,
|
|
3265
3271
|
resizeHandle: null,
|
|
3266
3272
|
resizeCorners: null,
|
|
@@ -4157,6 +4163,7 @@ function createFlowStore(initialGraph = {
|
|
|
4157
4163
|
if (event.autoPanOnDrag !== void 0) draft.autoPanOnDrag = event.autoPanOnDrag;
|
|
4158
4164
|
if (event.autoPanThreshold !== void 0) draft.autoPanThreshold = Math.max(0, event.autoPanThreshold);
|
|
4159
4165
|
if (event.autoPanSpeed !== void 0) draft.autoPanSpeed = Math.max(0, event.autoPanSpeed);
|
|
4166
|
+
if (event.viewportAnimation !== void 0) draft.viewportAnimation = event.viewportAnimation;
|
|
4160
4167
|
if (event.enableSnapLines !== void 0) draft.enableSnapLines = event.enableSnapLines;
|
|
4161
4168
|
if (event.snapThreshold !== void 0) draft.snapThreshold = Math.max(0, event.snapThreshold);
|
|
4162
4169
|
if (event.enableSpacingGuides !== void 0) draft.enableSpacingGuides = event.enableSpacingGuides;
|
|
@@ -4176,6 +4183,7 @@ function createFlowStore(initialGraph = {
|
|
|
4176
4183
|
if (event.autoPanOnDrag !== void 0) draft.autoPanOnDrag = event.autoPanOnDrag;
|
|
4177
4184
|
if (event.autoPanThreshold !== void 0) draft.autoPanThreshold = Math.max(0, event.autoPanThreshold);
|
|
4178
4185
|
if (event.autoPanSpeed !== void 0) draft.autoPanSpeed = Math.max(0, event.autoPanSpeed);
|
|
4186
|
+
if (event.viewportAnimation !== void 0) draft.viewportAnimation = event.viewportAnimation;
|
|
4179
4187
|
if (event.snapToGrid !== void 0) draft.snapToGrid = event.snapToGrid;
|
|
4180
4188
|
if (event.snapGrid !== void 0) draft.snapGrid = event.snapGrid;
|
|
4181
4189
|
if (event.enableSnapLines !== void 0) draft.enableSnapLines = event.enableSnapLines;
|
|
@@ -5659,7 +5667,6 @@ function createFlowEngine(store, initialOptions = {}) {
|
|
|
5659
5667
|
const edge = getEdge(edgeId);
|
|
5660
5668
|
if (!edge?.label) return null;
|
|
5661
5669
|
const measured = c.measurements.get(edgeId);
|
|
5662
|
-
if (measured && !edge.label.autoSize) return measured;
|
|
5663
5670
|
return resolveEdgeLabelBounds(edge, indexNodes(c.graph.nodes), measured);
|
|
5664
5671
|
}
|
|
5665
5672
|
function getBounds(id) {
|
|
@@ -8082,7 +8089,23 @@ function createFlow(options = {}) {
|
|
|
8082
8089
|
return resolvedViewportControls();
|
|
8083
8090
|
}
|
|
8084
8091
|
cancelViewportAnimation();
|
|
8085
|
-
|
|
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) {
|
|
8086
8109
|
store.trigger.setViewport(target);
|
|
8087
8110
|
return resolvedViewportControls();
|
|
8088
8111
|
}
|
|
@@ -8092,7 +8115,7 @@ function createFlow(options = {}) {
|
|
|
8092
8115
|
...store.trigger,
|
|
8093
8116
|
setViewport: writeViewport
|
|
8094
8117
|
}
|
|
8095
|
-
}, target,
|
|
8118
|
+
}, target, resolvedAnimationOptions);
|
|
8096
8119
|
activeViewportAnimation = animation;
|
|
8097
8120
|
animation.done.then(() => {
|
|
8098
8121
|
if (activeViewportAnimation === animation) activeViewportAnimation = null;
|
|
@@ -9130,7 +9153,7 @@ function fromJSON(data, options = {}) {
|
|
|
9130
9153
|
graph: parsed.graph
|
|
9131
9154
|
});
|
|
9132
9155
|
flow.internals.store.trigger.setCollapsedNodes({ ids: parsed.collapsedNodeIds ?? [] });
|
|
9133
|
-
flow.
|
|
9156
|
+
flow.internals.store.trigger.setViewport(parsed.viewport);
|
|
9134
9157
|
return flow;
|
|
9135
9158
|
}
|
|
9136
9159
|
//#endregion
|
|
@@ -9205,6 +9228,32 @@ function getToolbarPlacement(input) {
|
|
|
9205
9228
|
}
|
|
9206
9229
|
//#endregion
|
|
9207
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
|
+
}
|
|
9208
9257
|
function getMinimapProjection(options) {
|
|
9209
9258
|
const padding = options.padding ?? .1;
|
|
9210
9259
|
const content = options.contentBounds;
|
|
@@ -10583,11 +10632,12 @@ function profilePoliciesForContext(profile) {
|
|
|
10583
10632
|
};
|
|
10584
10633
|
}
|
|
10585
10634
|
/**
|
|
10586
|
-
* Per-frame auto-pan step while a drag
|
|
10587
|
-
* container edge. Returns the `calcAutoPan` screen-space
|
|
10588
|
-
* `panBy`), or null when auto-pan should not run. Adapters
|
|
10589
|
-
* frame ticker while a gesture session is active and re-send
|
|
10590
|
-
* 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.
|
|
10591
10641
|
*/
|
|
10592
10642
|
function getAutoPanDelta(context, screenPoint, engine) {
|
|
10593
10643
|
if (!context.autoPanOnDrag) return null;
|
|
@@ -10596,44 +10646,6 @@ function getAutoPanDelta(context, screenPoint, engine) {
|
|
|
10596
10646
|
if (size.width === 0 || size.height === 0) return null;
|
|
10597
10647
|
const delta = calcAutoPan(screenPoint, size, context.autoPanThreshold, context.autoPanSpeed);
|
|
10598
10648
|
if (delta.x === 0 && delta.y === 0) return null;
|
|
10599
|
-
const toScreen = (b) => {
|
|
10600
|
-
const x0 = b.x * context.viewport.zoom + context.viewport.x;
|
|
10601
|
-
const y0 = b.y * context.viewport.zoom + context.viewport.y;
|
|
10602
|
-
return {
|
|
10603
|
-
x0,
|
|
10604
|
-
y0,
|
|
10605
|
-
x1: x0 + b.width * context.viewport.zoom,
|
|
10606
|
-
y1: y0 + b.height * context.viewport.zoom
|
|
10607
|
-
};
|
|
10608
|
-
};
|
|
10609
|
-
const gateByBounds = (union) => {
|
|
10610
|
-
const edge = context.autoPanThreshold;
|
|
10611
|
-
if (delta.x < 0 && union.x0 > edge) delta.x = 0;
|
|
10612
|
-
if (delta.x > 0 && union.x1 < size.width - edge) delta.x = 0;
|
|
10613
|
-
if (delta.y < 0 && union.y0 > edge) delta.y = 0;
|
|
10614
|
-
if (delta.y > 0 && union.y1 < size.height - edge) delta.y = 0;
|
|
10615
|
-
if (delta.x === 0 && delta.y === 0) return null;
|
|
10616
|
-
return delta;
|
|
10617
|
-
};
|
|
10618
|
-
if (engine && context.canvasState === "dragging") {
|
|
10619
|
-
let union = null;
|
|
10620
|
-
for (const selectedId of context.selection) {
|
|
10621
|
-
const node = engine.getNode(selectedId);
|
|
10622
|
-
if (!node || node.draggable === false) continue;
|
|
10623
|
-
const s = toScreen(engine.resolvedBounds(selectedId));
|
|
10624
|
-
union = union ? {
|
|
10625
|
-
x0: Math.min(union.x0, s.x0),
|
|
10626
|
-
y0: Math.min(union.y0, s.y0),
|
|
10627
|
-
x1: Math.max(union.x1, s.x1),
|
|
10628
|
-
y1: Math.max(union.y1, s.y1)
|
|
10629
|
-
} : s;
|
|
10630
|
-
}
|
|
10631
|
-
if (union) return gateByBounds(union);
|
|
10632
|
-
}
|
|
10633
|
-
if (engine && context.canvasState === "resizing") {
|
|
10634
|
-
const rect = engine.getResizeBounds();
|
|
10635
|
-
if (rect) return gateByBounds(toScreen(rect));
|
|
10636
|
-
}
|
|
10637
10649
|
return delta;
|
|
10638
10650
|
}
|
|
10639
10651
|
//#endregion
|
|
@@ -10864,4 +10876,4 @@ function createEntityChangeNotifier(store, options = {}) {
|
|
|
10864
10876
|
};
|
|
10865
10877
|
}
|
|
10866
10878
|
//#endregion
|
|
10867
|
-
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 };
|