@getartisanflow/alpineflow 0.2.2-alpha → 0.2.3-alpha

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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The events the container listens to for pan and zoom.
3
+ *
4
+ * `wheel` and `mousedown`/`pointerdown` reach the pan/zoom behaviour; `dblclick`
5
+ * reaches the double-click zoom, which is bound separately (d3's stepped handler
6
+ * in the default mode, AlpineFlow's own in `'toggle'`) and is the one that used
7
+ * to be left out.
8
+ *
9
+ * `touchstart` is here because d3-zoom binds `touchstart.zoom` DIRECTLY rather
10
+ * than going through pointer events, so stopping `pointerdown` does not reach
11
+ * it: without this, a tap or a drag on any overlay still pans or pinches the
12
+ * canvas underneath it on a phone. The eraser already blocks touch by hand for
13
+ * the same reason.
14
+ */
15
+ export declare const CANVAS_GESTURES: readonly ["mousedown", "pointerdown", "touchstart", "wheel", "dblclick"];
16
+ export type CanvasGesture = (typeof CANVAS_GESTURES)[number];
17
+ /**
18
+ * Keep canvas gestures inside the element they landed on.
19
+ *
20
+ * Stopped on the way OUT of the overlay rather than on the way in, so the
21
+ * buttons inside it keep working: `stopPropagation` ends the bubble, and every
22
+ * listener already reached — including others on this same element — still runs.
23
+ *
24
+ * Pass a subset for an overlay that deliberately lets some gestures through; the
25
+ * minimap does, since a drag on it is its own to interpret and only the
26
+ * double-click zoom is unwanted.
27
+ *
28
+ * Returns a cleanup function that removes the listeners again.
29
+ */
30
+ export declare function isolateCanvasGestures(el: HTMLElement, gestures?: readonly CanvasGesture[]): () => void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Minimal edge shape for flag checking — allows partial edge objects
3
+ * from contexts where the full FlowEdge type isn't available.
4
+ */
5
+ interface EdgeLike {
6
+ selectable?: boolean;
7
+ }
8
+ /**
9
+ * Can this edge be selected by a pointer?
10
+ *
11
+ * `defaultValue` carries the canvas-wide `edgesSelectable` config, so an edge that
12
+ * says nothing follows the canvas and one that states a preference keeps it:
13
+ * { selectable: true }, canvas off → selectable (explicit override wins)
14
+ * { }, canvas off → not selectable
15
+ * { selectable: false }, canvas on → not selectable
16
+ * { }, canvas on → selectable
17
+ *
18
+ * Edges have no `locked`, so unlike `isSelectable` for nodes there is nothing else
19
+ * to weigh — this is the whole rule.
20
+ */
21
+ export declare function isEdgeSelectable(edge: EdgeLike, defaultValue?: boolean): boolean;
22
+ export {};
@@ -13,6 +13,18 @@ export declare function getGradientId(flowId: string, edgeId: string): string;
13
13
  * For gradients, returns the `from` color (used as fallback for selection highlight, etc.).
14
14
  */
15
15
  export declare function resolveStrokeColor(color: string | EdgeGradient | undefined): string | null;
16
+ /**
17
+ * Repaint an existing gradient def, without touching where it is.
18
+ *
19
+ * For the case where an edge's colour changed and NOTHING MOVED: the def's x1/y1/x2/y2 were worked
20
+ * out from the endpoints the last time they moved and are still right, so re-deriving them would
21
+ * mean re-pathing the edge — and, through the path refresh, every sibling edge on both of its
22
+ * nodes.
23
+ *
24
+ * Answers false where there is no def yet, which is the one case that genuinely needs the
25
+ * coordinates: an edge given a gradient for the first time has nothing to keep.
26
+ */
27
+ export declare function restyleGradientDef(defsEl: Element, id: string, gradient: EdgeGradient): boolean;
16
28
  /**
17
29
  * Create or update an SVG <linearGradient> element in a <defs> container.
18
30
  * Uses gradientUnits="userSpaceOnUse" so coordinates are in SVG canvas space.
@@ -1,4 +1,6 @@
1
1
  import type { FlowNode, Viewport, FlowCanvasConfig } from './types';
2
+ export declare const MINIMAP_DEFAULT_WIDTH = 200;
3
+ export declare const MINIMAP_DEFAULT_HEIGHT = 150;
2
4
  export interface MiniMapState {
3
5
  nodes: FlowNode[];
4
6
  viewport: Viewport;
@@ -25,6 +27,12 @@ export interface MiniMapOptions {
25
27
  export interface MiniMapInstance {
26
28
  render(): void;
27
29
  updateViewport(): void;
30
+ /**
31
+ * Give it another box. Redraws at the new size; ignores a width or height that is not positive.
32
+ * Returns whether the box actually changed, so a caller can keep config and events in step with
33
+ * what was drawn rather than with what was asked for.
34
+ */
35
+ resize(width: number, height: number): boolean;
28
36
  destroy(): void;
29
37
  }
30
38
  export declare function createMiniMap(container: HTMLElement, options: MiniMapOptions): MiniMapInstance;
@@ -14,6 +14,10 @@ interface NodeLike {
14
14
  export declare function isDraggable(node: NodeLike): boolean;
15
15
  export declare function isDeletable(node: NodeLike): boolean;
16
16
  export declare function isConnectable(node: NodeLike): boolean;
17
- export declare function isSelectable(node: NodeLike): boolean;
17
+ /**
18
+ * `defaultValue` carries the canvas-wide `nodesSelectable` config: a node with no
19
+ * `selectable` of its own follows the canvas, and one that states a preference keeps it.
20
+ */
21
+ export declare function isSelectable(node: NodeLike, defaultValue?: boolean): boolean;
18
22
  export declare function isResizable(node: NodeLike): boolean;
19
23
  export {};
@@ -49,6 +49,24 @@ export interface PanZoomOptions {
49
49
  * zoom-in. Clamped to [minZoom, maxZoom]. Only consulted when
50
50
  * `zoomOnDoubleClick: 'toggle'`. Default: 1.5 */
51
51
  dblClickZoomLevel?: number;
52
+ /** Where a toggle double-click zooms out to when there is no remembered viewport
53
+ * to restore — the user reached this zoom by wheel or `setViewport`, or panned
54
+ * after zooming in and so dropped the memory.
55
+ *
56
+ * - `'min'` (default) — `minZoom`, about the cursor.
57
+ * - `'fit'` — the viewport that frames the whole graph, as `fitView()` computes
58
+ * it. Needs {@link PanZoomOptions.getFitViewport}; falls back to `'min'` when
59
+ * there is nothing to fit.
60
+ * - `number` — a fixed level, about the cursor. Clamped to [minZoom, maxZoom].
61
+ *
62
+ * Only consulted when `zoomOnDoubleClick: 'toggle'`; a remembered viewport always
63
+ * wins over it. Default: `'min'` */
64
+ dblClickZoomOutLevel?: number | 'fit' | 'min';
65
+ /** Viewport that frames the whole graph, or `null` when there is nothing to frame.
66
+ * Called only when a toggle double-click zooms out under
67
+ * `dblClickZoomOutLevel: 'fit'` — pan/zoom does not know about nodes, so the
68
+ * consumer supplies this. */
69
+ getFitViewport?: () => Viewport | null;
52
70
  /** Key code that temporarily enables panning when held. Default: 'Space' */
53
71
  panActivationKeyCode?: string | null;
54
72
  /** Key code that forces zoom (overrides panOnScroll) when held with wheel. Default: 'Control'.
@@ -119,18 +137,27 @@ interface ViewportTransform {
119
137
  * so the next double-click can put it back exactly;
120
138
  * - at or above `level` with a remembered viewport → restore it;
121
139
  * - at or above `level` with nothing remembered (the user got here by wheel or
122
- * `setViewport`) → zoom out to `minZoom` about the cursor, so the gesture always
123
- * does something rather than stalling.
140
+ * `setViewport`, or panned after zooming in and so dropped the memory) → zoom out
141
+ * to `zoomOut`, so the gesture always does something rather than stalling.
142
+ *
143
+ * `zoomOut` is `'min'` by default — `minZoom` about the cursor. `'fit'` puts the
144
+ * whole graph back on screen instead, which is what the second double-click means
145
+ * on a canvas people read rather than survey; a number is a fixed level, again about
146
+ * the cursor. Only this fallback is configurable: with a remembered viewport, going
147
+ * back exactly where you came from beats any level anybody could name.
148
+ *
149
+ * `fit` is a thunk rather than a viewport because measuring every node's bounds is
150
+ * only worth doing on the branch that uses it, and most double-clicks zoom in.
124
151
  *
125
152
  * Pure so the decision can be tested without driving d3-zoom through a real DOM.
126
153
  *
127
- * Precondition: `level` must sit strictly above `minZoom`. A toggle needs somewhere
128
- * to go — when the two coincide, "at or above the level" is also "already at the
129
- * floor", so the zoom-out branch has no room and the gesture cannot move the
130
- * viewport. That configuration is rejected at wiring time (createPanZoom keeps
131
- * d3's native stepped handler instead of installing a toggle that would stall);
132
- * should it reach here anyway, the current viewport is returned unchanged rather
133
- * than a transform that merely looks new.
154
+ * Precondition: `level` must sit strictly above the level zooming out lands on. A
155
+ * toggle needs somewhere to go — when the two coincide, "at or above the level" is
156
+ * also "already at the floor", so the zoom-out branch has no room and the gesture
157
+ * cannot move the viewport. That configuration is rejected at wiring time
158
+ * (createPanZoom keeps d3's native stepped handler instead of installing a toggle
159
+ * that would stall); should it reach here anyway, the current viewport is returned
160
+ * unchanged rather than a transform that merely looks new.
134
161
  */
135
162
  export declare function resolveDblClickZoom(current: ViewportTransform, pointer: {
136
163
  x: number;
@@ -139,6 +166,8 @@ export declare function resolveDblClickZoom(current: ViewportTransform, pointer:
139
166
  level: number;
140
167
  minZoom: number;
141
168
  remembered: ViewportTransform | null;
169
+ zoomOut?: number | 'fit' | 'min';
170
+ fit?: (() => ViewportTransform | null) | null;
142
171
  }): {
143
172
  next: ViewportTransform;
144
173
  remember: ViewportTransform | null;
@@ -242,6 +242,8 @@ export interface FlowEdge<T = Record<string, any>> {
242
242
  deletable?: boolean;
243
243
  /** Can this edge receive keyboard focus? Default: follows `edgesFocusable` config (true). */
244
244
  focusable?: boolean;
245
+ /** Can this edge be selected? Default: follows `edgesSelectable` config (true). */
246
+ selectable?: boolean;
245
247
  /** Override the ARIA role for this edge. Default: 'group' */
246
248
  ariaRole?: string;
247
249
  /** Override the auto-generated aria-label for this edge. */
@@ -255,6 +257,17 @@ export interface FlowEdge<T = Record<string, any>> {
255
257
  labelVisibility?: 'always' | 'hover' | 'selected';
256
258
  /** Optional label displayed on the edge */
257
259
  label?: string;
260
+ /**
261
+ * Render the labels as HTML instead of text.
262
+ *
263
+ * Labels are written with `textContent` by default, so markup in them shows as the tags
264
+ * themselves. Set this to render `label`, `labelStart` and `labelEnd` as HTML — for a label that
265
+ * needs a line break, an icon or a piece of emphasis.
266
+ *
267
+ * The value goes to `innerHTML` unchanged. Like any HTML you hand a framework, it is trusted:
268
+ * pass user input through your own escaping or sanitiser first.
269
+ */
270
+ labelHtml?: boolean;
258
271
  /** Position of the center label along the path (0 = source, 1 = target). Default: 0.5 */
259
272
  labelPosition?: number;
260
273
  /** Optional label displayed near the source end of the edge */
@@ -487,6 +500,7 @@ export interface FlowEvents {
487
500
  };
488
501
  'selection-context-menu': {
489
502
  nodes: FlowNode[];
503
+ edges: FlowEdge[];
490
504
  event: MouseEvent;
491
505
  };
492
506
  'selection-change': {
@@ -539,6 +553,10 @@ export interface FlowEvents {
539
553
  horizontal: number[];
540
554
  vertical: number[];
541
555
  };
556
+ 'minimap-resize': {
557
+ width: number;
558
+ height: number;
559
+ };
542
560
  'nodes-patch': {
543
561
  patches: Record<string, DeepPartial<FlowNode>>;
544
562
  };
@@ -551,9 +569,44 @@ export interface FlowEvents {
551
569
  viewport?: Partial<Viewport>;
552
570
  origin: 'undo' | 'redo' | 'load';
553
571
  };
572
+ 'layout': LayoutEventPayload;
573
+ 'layout-end': LayoutEventPayload;
554
574
  'init': undefined;
555
575
  'destroy': undefined;
556
576
  }
577
+ /**
578
+ * Where a layout decided each node goes, keyed by node id.
579
+ *
580
+ * A plain object rather than the `Map` the layout functions return: this travels in a DOM event,
581
+ * and a `Map` survives neither `JSON.stringify` nor structured clone — which is exactly the road
582
+ * this payload exists for, since persisting a layout means sending it somewhere.
583
+ */
584
+ export type LayoutPositions = Record<string, XYPosition>;
585
+ /**
586
+ * What a layout announces — carried by both `layout` (when the positions are computed) and
587
+ * `layout-end` (when the nodes have settled there). Discriminated on `type`, so the settings each
588
+ * engine reports are the ones it actually has.
589
+ */
590
+ export type LayoutEventPayload = {
591
+ type: 'dagre';
592
+ direction: string;
593
+ positions: LayoutPositions;
594
+ } | {
595
+ type: 'force';
596
+ charge: number;
597
+ distance: number;
598
+ positions: LayoutPositions;
599
+ } | {
600
+ type: 'tree';
601
+ layoutType: string;
602
+ direction: string;
603
+ positions: LayoutPositions;
604
+ } | {
605
+ type: 'elk';
606
+ algorithm: string;
607
+ direction: string;
608
+ positions: LayoutPositions;
609
+ };
557
610
  /** Per-overlay visibility options for toImage(). All default to false (excluded). */
558
611
  export interface ToImageOverlays {
559
612
  /** Include toolbar and other .canvas-overlay elements. Default: false */
@@ -653,6 +706,8 @@ export interface PatchableConfig {
653
706
  minimapMaskColor?: string;
654
707
  minimapPannable?: boolean;
655
708
  minimapZoomable?: boolean;
709
+ minimapWidth?: number;
710
+ minimapHeight?: number;
656
711
  defaultInteractionWidth?: number;
657
712
  preventOverlap?: boolean | number;
658
713
  reconnectOnDelete?: boolean;
@@ -1182,6 +1237,24 @@ export interface FlowCanvasConfig {
1182
1237
  controlsShowResetPanels?: boolean;
1183
1238
  /** CSS selector for external container. When set, panel renders there instead of inside the canvas. */
1184
1239
  controlsContainer?: string;
1240
+ /**
1241
+ * How long the viewport takes to answer a control, in ms. Default: 0 (instant).
1242
+ *
1243
+ * Zoom in, zoom out and fit view all take a `duration` and animate when given one — the panel
1244
+ * simply never passed one, so its buttons jumped while a double-click zoom (300ms) and a layout
1245
+ * glided. Set this and the three buttons move the same way everything else on the canvas does.
1246
+ */
1247
+ controlsDuration?: number;
1248
+ /**
1249
+ * How big the minimap is drawn, in pixels. Defaults: 200 by 150.
1250
+ *
1251
+ * Not only how big the picture is — the scale that fits the graph into it and the rectangle that
1252
+ * marks the viewport are both computed against these, so a minimap whose ratio does not match the
1253
+ * canvas draws a viewport marker that is not the shape of the viewport. A consumer that wants it
1254
+ * to follow the container watches for a resize and calls `resize()` on the instance.
1255
+ */
1256
+ minimapWidth?: number;
1257
+ minimapHeight?: number;
1185
1258
  /**
1186
1259
  * Element to enter fullscreen mode, instead of the canvas container.
1187
1260
  * Useful when the page wraps the canvas + ancillary UI (inspectors,
@@ -1200,6 +1273,13 @@ export interface FlowCanvasConfig {
1200
1273
  nodesFocusable?: boolean;
1201
1274
  /** Allow edges to receive keyboard focus via Tab. Default: true */
1202
1275
  edgesFocusable?: boolean;
1276
+ /** Allow nodes to be selected by clicking, dragging or a selection box. Default: true.
1277
+ * A node's own `selectable` overrides this. Programmatic selection is unaffected —
1278
+ * this governs what a POINTER may do, not what the host may ask for. */
1279
+ nodesSelectable?: boolean;
1280
+ /** Allow edges to be selected by clicking or a selection box. Default: true.
1281
+ * An edge's own `selectable` overrides this. Programmatic selection is unaffected. */
1282
+ edgesSelectable?: boolean;
1203
1283
  /** Disable arrow-key movement for selected nodes (Tab/Enter still work). Default: false */
1204
1284
  disableKeyboardA11y?: boolean;
1205
1285
  /** Screen reader announcements. true (default) = on, false = off,
@@ -1449,6 +1529,8 @@ export interface FlowCanvasConfig {
1449
1529
  onViewportMove?: (detail: FlowEvents['viewport-move'], ctx?: CanvasContext) => void;
1450
1530
  /** Called when a user gesture (pan/zoom) ends */
1451
1531
  onViewportMoveEnd?: (detail: FlowEvents['viewport-move-end'], ctx?: CanvasContext) => void;
1532
+ /** Called when the minimap is drawn at a new size — a host that persists the size listens here */
1533
+ onMinimapResize?: (detail: FlowEvents['minimap-resize'], ctx?: CanvasContext) => void;
1452
1534
  /** Called when the canvas background is clicked */
1453
1535
  onPaneClick?: (detail: FlowEvents['pane-click'], ctx?: CanvasContext) => void;
1454
1536
  /** Called when a node is right-clicked */
@@ -1571,6 +1653,17 @@ export interface FlowCanvasConfig {
1571
1653
  * have room to return to. Only consulted when `zoomOnDoubleClick: 'toggle'`.
1572
1654
  * Default: 1.5 */
1573
1655
  dblClickZoomLevel?: number;
1656
+ /** Where a toggle double-click zooms out to when it has no remembered viewport to
1657
+ * restore — the user reached this zoom by wheel or `setViewport`, or panned after
1658
+ * zooming in, which drops the memory.
1659
+ *
1660
+ * - `'min'` (default) — `minZoom`, about the cursor.
1661
+ * - `'fit'` — the whole graph back on screen, the viewport `fitView()` computes.
1662
+ * - `number` — a fixed level, about the cursor. Clamped to [minZoom, maxZoom].
1663
+ *
1664
+ * A remembered viewport always wins over this. Only consulted when
1665
+ * `zoomOnDoubleClick: 'toggle'`. Default: `'min'` */
1666
+ dblClickZoomOutLevel?: number | 'fit' | 'min';
1574
1667
  /** Automatically select nodes when they start being dragged. Default: true */
1575
1668
  selectNodesOnDrag?: boolean;
1576
1669
  }
@@ -1608,6 +1701,16 @@ export type AnimateEdgeTarget = {
1608
1701
  strokeWidth?: number;
1609
1702
  animated?: boolean;
1610
1703
  class?: string;
1704
+ /**
1705
+ * Which path generator draws this edge — the same set `FlowEdge.type` accepts:
1706
+ * `'bezier'`, `'smoothstep'`, `'straight'`, `'floating'`, `'orthogonal'`,
1707
+ * `'avoidant'`, `'editable'`, or a type registered in `edgeTypes`.
1708
+ *
1709
+ * Applied instantly whatever the duration: a path type is a choice of generator,
1710
+ * not a value with a midpoint, so there is nothing to interpolate between a curve
1711
+ * and a set of right angles.
1712
+ */
1713
+ type?: EdgeType | (string & {});
1611
1714
  } & ElementTimingOverrides;
1612
1715
  /** Viewport animation target. */
1613
1716
  export type AnimateViewportTarget = {
@@ -1773,6 +1876,8 @@ export interface FlowInstance {
1773
1876
  }): void;
1774
1877
  /** Toggle interactivity (pannable + zoomable + node dragging) */
1775
1878
  toggleInteractive(): void;
1879
+ /** Draw the minimap at another size. Ignores a width or height that is not positive. */
1880
+ resizeMinimap(width: number, height: number): void;
1776
1881
  /** Whether interactivity is currently enabled */
1777
1882
  isInteractive: boolean;
1778
1883
  /** Get the absolute position of a node (resolves parentId chain) */
@@ -1,4 +1,4 @@
1
- import type { FlowNode, FlowEdge, Viewport, XYPosition, Dimensions, FlowCanvasConfig, PendingReconnection, PendingKeyboardConnect, AnimateTargets, AnimateOptions, FlowAnimationHandle, FollowOptions, BurstOptions, ParticleBurstHandle, ConvergingOptions, ConvergingHandle, ParticleHandle, ParticleOptions, ParticleRenderer, PatchableConfig, ChildValidation, RowFilter, FlowNodeRunState, ShapeDefinition, ToImageOptions, StopOptions, SchemaMetrics, EndpointSpreadGrouping, ChangeOrigin } from '../../core/types';
1
+ import type { FlowNode, FlowEdge, EdgeGradient, Viewport, XYPosition, Dimensions, FlowCanvasConfig, PendingReconnection, PendingKeyboardConnect, AnimateTargets, AnimateOptions, FlowAnimationHandle, FollowOptions, BurstOptions, ParticleBurstHandle, ConvergingOptions, ConvergingHandle, ParticleHandle, ParticleOptions, ParticleRenderer, PatchableConfig, ChildValidation, RowFilter, FlowNodeRunState, ShapeDefinition, ToImageOptions, StopOptions, SchemaMetrics, EndpointSpreadGrouping, ChangeOrigin } from '../../core/types';
2
2
  import type { FlowGroup } from '../../animate/flow-group';
3
3
  import type { Transaction } from '../../animate/transaction';
4
4
  import type { Recording, RecordOptions, ReplayOptions, ReplayHandle } from '../../animate/recording';
@@ -351,6 +351,11 @@ export interface CanvasContext {
351
351
  /** Push current viewport state to the DOM (transform, background, culling) */
352
352
  _flushViewport(): void;
353
353
  /** Recompute SVG paths, label positions, and gradients for affected edges */
354
+ /**
355
+ * Repaint one edge's gradient where nothing moved. False where it has no def yet, and the caller
356
+ * falls back to the path refresh — see the implementation for why that is worth avoiding.
357
+ */
358
+ _restyleEdgeGradient(edgeId: string, gradient: EdgeGradient): boolean;
354
359
  _refreshEdgePaths(movedNodeIds: Set<string>): void;
355
360
  /** Hydrate from a pre-rendered static diagram */
356
361
  _hydrateFromStatic(): void;
@@ -590,6 +595,8 @@ export interface CanvasContext {
590
595
  }): void;
591
596
  /** Toggle interactivity */
592
597
  toggleInteractive(): void;
598
+ /** Draw the minimap at another size */
599
+ resizeMinimap(width: number, height: number): void;
593
600
  /** Toggle fullscreen on the canvas container */
594
601
  toggleFullscreen(): void;
595
602
  /** Close the context menu */
@@ -1,4 +1,5 @@
1
1
  import type { CanvasContext } from './canvas-context';
2
+ import type { EdgeGradient } from '../../core/types';
2
3
  export declare function createDomMixin(ctx: CanvasContext, Alpine: any): {
3
4
  /** Write node positions directly to DOM elements (bypassing Alpine effects). */
4
5
  _flushNodePositions(nodeIds: Set<string>): void;
@@ -8,6 +9,19 @@ export declare function createDomMixin(ctx: CanvasContext, Alpine: any): {
8
9
  _flushEdgeStyles(edgeIds: Set<string>): void;
9
10
  /** Push current viewport state to the DOM (transform, background, culling). */
10
11
  _flushViewport(): void;
12
+ /**
13
+ * Repaint one edge's gradient, for a colour change that moved nothing.
14
+ *
15
+ * Answers false where the edge has no def yet — an edge given a gradient for the first time —
16
+ * and the caller falls back to the path refresh, which is what works the coordinates out.
17
+ *
18
+ * Its own entry point because the refresh is driven by which NODES moved: routing a colour
19
+ * change through it re-paths every sibling edge on both endpoints, and re-paths them the way a
20
+ * drag does, without obstacle avoidance, until the layout settles. On a plain graph that is
21
+ * invisible; on an obstacle-routed one it straightens neighbours through the nodes they were
22
+ * drawn around.
23
+ */
24
+ _restyleEdgeGradient(edgeId: string, gradient: EdgeGradient): boolean;
11
25
  /** Recompute SVG paths, label positions, and gradients for edges connected to the given node IDs. */
12
26
  _refreshEdgePaths(movedNodeIds: Set<string>): void;
13
27
  /** Return the registered DOM element for a node by ID, or undefined if not mounted. */
@@ -33,6 +33,15 @@ export declare function createLayoutMixin(ctx: CanvasContext): {
33
33
  handleDirection?: string;
34
34
  fitView?: boolean;
35
35
  duration?: number;
36
+ /**
37
+ * Called once the positions are ON the model, which is a different moment in each
38
+ * branch: after the animation in the animated one, straight after the write in the
39
+ * instant one. The point of it is that a caller does not have to know which branch it
40
+ * took — "the nodes are where the layout put them" means the same thing either way.
41
+ *
42
+ * Not called when the animation never completes: an interrupted layout did not settle.
43
+ */
44
+ onApplied?: () => void;
36
45
  }): void;
37
46
  /**
38
47
  * Update handle positions on nodes and DOM elements to match a layout
@@ -63,6 +63,21 @@ export declare function createViewportMixin(ctx: CanvasContext): {
63
63
  width: number;
64
64
  height: number;
65
65
  };
66
+ /**
67
+ * The viewport that frames the whole graph right now, or null when there is no
68
+ * honest answer.
69
+ *
70
+ * For callers that cannot wait: `fitView()` defers through `_whenMeasured()` until
71
+ * every node has been laid out, and a double-click has to answer within the
72
+ * gesture. So this asks the same question and, where `fitView()` would wait, says
73
+ * null instead and leaves the fallback to the caller.
74
+ *
75
+ * Null on two counts. Nothing visible to frame — and nothing MEASURED to frame it
76
+ * by: an unmeasured node still has bounds, because `getNodesBounds` fills in the
77
+ * 150×50 default, so framing it would frame a row of placeholder boxes at the
78
+ * positions they were declared with rather than the graph anybody can see.
79
+ */
80
+ _fitViewport(): Viewport | null;
66
81
  /**
67
82
  * Compute the viewport (pan + zoom) that frames the given bounds
68
83
  * within the container, respecting min/max zoom and padding.
@@ -22,6 +22,18 @@ export declare function checkHandleLimits(containerEl: HTMLElement, connection:
22
22
  * in the container based on the validation chain for a hypothetical connection
23
23
  * from the given source.
24
24
  *
25
+ * Also raises `.flow-connecting` on the container, because that is the selector
26
+ * the stylesheet reveals those classes through:
27
+ *
28
+ * .flow-connecting .flow-handle-target { outline: 2px solid … }
29
+ * .flow-connecting .flow-handle-target.flow-handle-invalid { outline-color: … }
30
+ *
31
+ * The flag used to be set by the click-to-connect branch alone, so the three
32
+ * DRAG gestures computed a full valid/invalid verdict for every target handle
33
+ * and then painted none of it. Setting it here — and clearing it in
34
+ * `clearValidationClasses` — is what keeps the two halves of one statement from
35
+ * being raised in different places.
36
+ *
25
37
  * When `index` is provided (connect-drag / reconnect gestures build one on
26
38
  * pointerdown), validation runs O(1) per handle off a precomputed context with
27
39
  * ZERO further DOM queries or measurements. Without an index (one-shot callers:
@@ -39,7 +51,10 @@ export declare function applyValidationClasses(containerEl: HTMLElement, sourceN
39
51
  */
40
52
  export declare function legacyApplyValidationClasses(containerEl: HTMLElement, sourceNodeId: string, sourceHandleId: string, canvas: any, excludeEdgeId?: string): void;
41
53
  /**
42
- * Remove .flow-handle-valid / .flow-handle-invalid from all target handles.
54
+ * Remove .flow-handle-valid / .flow-handle-invalid from all target handles, and
55
+ * `.flow-connecting` from the container that revealed them. Every path that ends
56
+ * a connect gesture already calls this, which is what makes it the one place the
57
+ * flag can be dropped from.
43
58
  */
44
59
  export declare function clearValidationClasses(containerEl: HTMLElement): void;
45
60
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package.json",
3
3
  "name": "@getartisanflow/alpineflow",
4
- "version": "0.2.2-alpha",
4
+ "version": "0.2.3-alpha",
5
5
  "description": "Interactive flowchart and node-graph engine for Alpine.js — drag-and-drop nodes, edges, animations, collaboration, and layout algorithms.",
6
6
  "keywords": [
7
7
  "alpinejs",