@cascivo/flow 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts DELETED
@@ -1,706 +0,0 @@
1
- import { ReadonlySignal, Signal } from "@cascivo/core";
2
- import { CSSProperties, HTMLAttributes, ReactNode, RefObject } from "react";
3
-
4
- /** Shared geometry + graph types for the flow engine. */
5
- interface XYPosition {
6
- x: number;
7
- y: number;
8
- }
9
- type HandlePosition = 'top' | 'right' | 'bottom' | 'left';
10
- interface NodeSize {
11
- width: number;
12
- height: number;
13
- }
14
- /** A graph node. Positioned in flow coordinates; renders as themed HTML. */
15
- interface FlowNode$1<Data = Record<string, unknown>> {
16
- id: string;
17
- position: XYPosition;
18
- data?: Data;
19
- /** Custom renderer key resolved via `nodeTypes`. */
20
- type?: string;
21
- selected?: boolean;
22
- /** Explicit/measured size used for handle anchors + bounding boxes. */
23
- width?: number;
24
- height?: number;
25
- }
26
- type EdgePathType = 'bezier' | 'straight' | 'smoothstep';
27
- /** A directed connection between two nodes' handles. */
28
- interface FlowEdge$1 {
29
- id: string;
30
- source: string;
31
- target: string;
32
- sourceHandle?: string;
33
- targetHandle?: string;
34
- /** Custom renderer key resolved via `edgeTypes`. */
35
- type?: EdgePathType | string;
36
- animated?: boolean;
37
- label?: string;
38
- selected?: boolean;
39
- /** Arrowhead at the source end (points back toward the source). Default false. */
40
- markerStart?: boolean;
41
- /** Arrowhead at the target end (points at the target). Default true. */
42
- markerEnd?: boolean;
43
- }
44
- /** The pan/zoom state of the canvas pane. */
45
- interface Viewport {
46
- x: number;
47
- y: number;
48
- zoom: number;
49
- }
50
- /** A new connection produced by interactive connect. */
51
- interface Connection {
52
- source: string;
53
- target: string;
54
- sourceHandle?: string | undefined;
55
- targetHandle?: string | undefined;
56
- }
57
- /** Default node footprint when a node has no explicit/measured size. */
58
- declare const DEFAULT_NODE_SIZE: NodeSize;
59
- interface UseFlowOptions {
60
- /** Controlled nodes. When provided, the parent owns node state. */
61
- nodes?: FlowNode$1[] | undefined;
62
- defaultNodes?: FlowNode$1[] | undefined;
63
- onNodesChange?: ((nodes: FlowNode$1[]) => void) | undefined;
64
- /** Controlled edges. */
65
- edges?: FlowEdge$1[] | undefined;
66
- defaultEdges?: FlowEdge$1[] | undefined;
67
- onEdgesChange?: ((edges: FlowEdge$1[]) => void) | undefined;
68
- /** Controlled viewport. */
69
- viewport?: Viewport | undefined;
70
- defaultViewport?: Viewport | undefined;
71
- onViewportChange?: ((viewport: Viewport) => void) | undefined;
72
- }
73
- interface FlowStore {
74
- nodes: Signal<FlowNode$1[]>;
75
- edges: Signal<FlowEdge$1[]>;
76
- viewport: Signal<Viewport>;
77
- setNodes: (nodes: FlowNode$1[]) => void;
78
- updateNode: (id: string, patch: Partial<FlowNode$1>) => void;
79
- setEdges: (edges: FlowEdge$1[]) => void;
80
- addEdge: (edge: FlowEdge$1) => void;
81
- setViewport: (viewport: Viewport) => void;
82
- }
83
- /**
84
- * The flow state model — plain signals (no Zustand, no MVX). `nodes`, `edges`,
85
- * and `viewport` are controllable signals with action helpers. No banned hooks.
86
- */
87
- declare function useFlow(options?: UseFlowOptions): FlowStore;
88
- /** Clamp a zoom level into the allowed range. */
89
- declare function clampZoom(zoom: number, min?: number, max?: number): number;
90
- /**
91
- * Convert a screen-space point (relative to the pane origin) into flow
92
- * coordinates. Inverse of `flowToScreen`. The pane applies
93
- * `translate(viewport.x, viewport.y) scale(viewport.zoom)` with origin `0 0`,
94
- * so a flow point maps to `p * zoom + translate`.
95
- */
96
- declare function screenToFlow(point: XYPosition, viewport: Viewport): XYPosition;
97
- /** Convert a flow-space point into screen coordinates (relative to the pane origin). */
98
- declare function flowToScreen(point: XYPosition, viewport: Viewport): XYPosition;
99
- interface Rect {
100
- x: number;
101
- y: number;
102
- width: number;
103
- height: number;
104
- }
105
- interface Size {
106
- width: number;
107
- height: number;
108
- }
109
- /** The effective size of a node (explicit/measured, else the default footprint). */
110
- declare function nodeSize(node: FlowNode$1): NodeSize;
111
- /** The node's bounding rectangle in flow coordinates. */
112
- declare function nodeBounds(node: FlowNode$1): Rect;
113
- /** The `{x,y}` (flow coords) where an edge attaches for a given handle position. */
114
- declare function handleAnchor(node: FlowNode$1, position: HandlePosition): XYPosition;
115
- /** Bounding box (flow coords) enclosing all nodes — the input to fit-view. */
116
- declare function graphBounds(nodes: readonly FlowNode$1[]): Rect | null;
117
- interface FitViewportOptions {
118
- /** Fractional padding around the graph (0.1 = 10% on each side). */
119
- padding?: number;
120
- minZoom?: number;
121
- maxZoom?: number;
122
- }
123
- /**
124
- * Compute the `viewport` (x/y/zoom) that frames `bounds` inside a container of
125
- * `container` size, with padding. Pure math — testable with injected sizes.
126
- */
127
- declare function fitViewport(bounds: Rect, container: Size, options?: FitViewportOptions): Viewport;
128
- interface EdgePathParams {
129
- source: XYPosition;
130
- target: XYPosition;
131
- sourcePosition?: HandlePosition;
132
- targetPosition?: HandlePosition;
133
- }
134
- interface EdgePath {
135
- /** The SVG `d` attribute. */
136
- d: string;
137
- /** The path midpoint — where an edge label is placed. */
138
- mid: XYPosition;
139
- }
140
- /** A straight line from source to target. */
141
- declare function straightPath({
142
- source,
143
- target
144
- }: EdgePathParams): EdgePath;
145
- /**
146
- * A cubic-bezier edge with control points offset along each handle's outward
147
- * normal. `curvature` scales the control distance relative to the endpoint gap.
148
- */
149
- declare function bezierPath(params: EdgePathParams & {
150
- curvature?: number;
151
- }): EdgePath;
152
- /**
153
- * An orthogonal "step" edge with rounded corners. Splits perpendicular to the
154
- * source handle's orientation (horizontal handle → vertical split, and vice versa).
155
- */
156
- declare function smoothStepPath(params: EdgePathParams & {
157
- borderRadius?: number;
158
- }): EdgePath;
159
- /** Dispatch to the builder for `type`. */
160
- declare function edgePath(type: EdgePathType, params: EdgePathParams): EdgePath;
161
- interface GridLayoutOptions {
162
- columns?: number;
163
- gap?: number;
164
- nodeWidth?: number;
165
- nodeHeight?: number;
166
- }
167
- /**
168
- * Arrange nodes in a simple grid. Pure — returns new nodes with computed
169
- * `position`s. Bring your own layout for complex graphs.
170
- */
171
- declare function gridLayout(nodes: FlowNode$1[], options?: GridLayoutOptions): FlowNode$1[];
172
- interface LayeredLayoutOptions {
173
- /** 'LR' = left→right (default), 'TB' = top→bottom. */
174
- direction?: 'LR' | 'TB';
175
- gap?: number;
176
- nodeWidth?: number;
177
- nodeHeight?: number;
178
- }
179
- /**
180
- * A minimal longest-path layering for DAGs (no Dagre/ELK). Each node's layer is
181
- * the longest path from a root; nodes share a layer along the cross axis. Pure,
182
- * deterministic. Documented as basic — bring your own layout for complex graphs.
183
- */
184
- declare function layeredLayout(nodes: FlowNode$1[], edges: FlowEdge$1[], options?: LayeredLayoutOptions): FlowNode$1[];
185
- type LayoutStrategy = 'grid' | 'layered' | ((nodes: FlowNode$1[], edges: FlowEdge$1[]) => FlowNode$1[]);
186
- /** Apply a layout strategy to nodes. */
187
- declare function applyLayout(nodes: FlowNode$1[], edges: FlowEdge$1[], layout: LayoutStrategy): FlowNode$1[];
188
- interface StoryStepBase {
189
- label?: string | undefined;
190
- description?: string | undefined;
191
- /** Override the default per-step duration (ms). */
192
- duration?: number | undefined;
193
- }
194
- /** A step expressed as a node pair — the engine finds the connecting edge. */
195
- interface StoryStepFromTo extends StoryStepBase {
196
- from: string;
197
- to: string;
198
- }
199
- /** A power-user step that names the edge directly. */
200
- interface StoryStepEdge extends StoryStepBase {
201
- edge: string;
202
- reverse?: boolean | undefined;
203
- }
204
- type StoryStep = StoryStepFromTo | StoryStepEdge;
205
- interface ResolvedStep {
206
- edgeId: string;
207
- direction: 'forward' | 'reverse';
208
- label?: string | undefined;
209
- description?: string | undefined;
210
- duration?: number | undefined;
211
- }
212
- /**
213
- * Resolve one step to an edge id + travel direction. For `{from,to}`, finds the
214
- * edge connecting the pair in either orientation (so one `A<->B` edge serves
215
- * both `A→B` and `B→A`). Throws on a step that matches no edge (fail-fast).
216
- */
217
- declare function resolveStep(step: StoryStep, edges: readonly FlowEdge$1[]): ResolvedStep;
218
- /** Resolve a whole script. Pure + deterministic. */
219
- declare function resolveScript(script: readonly StoryStep[], edges: readonly FlowEdge$1[]): ResolvedStep[];
220
- interface UseViewportOptions {
221
- minZoom?: number | undefined;
222
- maxZoom?: number | undefined;
223
- /** Drag the empty pane to pan. Default true. */
224
- panOnDrag?: boolean | undefined;
225
- /** Wheel/pinch to zoom. Default true. */
226
- zoomOnScroll?: boolean | undefined;
227
- /** Fractional padding used by `fitView`. Default 0.1. */
228
- fitPadding?: number | undefined;
229
- /** Frame the graph once, when the container is first measured. Default false. */
230
- fitOnInit?: boolean | undefined;
231
- }
232
- interface UseViewportReturn {
233
- /** Outer clipping container — attach for wheel + size measurement. */
234
- containerRef: RefObject<HTMLDivElement | null>;
235
- /** Background drag-surface (behind nodes) — the pan handle. */
236
- panHandleRef: RefObject<HTMLElement | null>;
237
- viewport: Signal<Viewport>;
238
- /** Translate the viewport by a screen-space delta. */
239
- pan: (dx: number, dy: number) => void;
240
- /** Set zoom (clamped), optionally keeping `center` (container coords) fixed. */
241
- zoomTo: (zoom: number, center?: XYPosition) => void;
242
- zoomIn: () => void;
243
- zoomOut: () => void;
244
- /** Frame all nodes. Accepts an explicit container size (else the measured one). */
245
- fitView: (size?: Size) => void;
246
- }
247
- /**
248
- * Pan/zoom/fit-view actions over the store's `viewport` signal. Pan reuses
249
- * `useDraggable` on the background surface; zoom attaches a clamped `wheel`
250
- * listener in `useSignalEffect`; fit-view composes `graphBounds` + the measured
251
- * container size. No `useState`/`useEffect`.
252
- */
253
- declare function useViewport(flow: FlowStore, options?: UseViewportOptions): UseViewportReturn;
254
- interface ConnectionState {
255
- source: string;
256
- sourceHandle?: string | undefined;
257
- /** Source anchor (flow coords) — the live path origin. */
258
- from: XYPosition;
259
- /** Current pointer (flow coords) — the live path end. */
260
- to: XYPosition;
261
- }
262
- interface UseConnectionOptions {
263
- /** The canvas container; pointerdown on a source handle within it starts a connection. */
264
- containerRef: RefObject<HTMLElement | null>;
265
- /** Convert client (screen) coordinates to flow coordinates. */
266
- clientToFlow: (clientX: number, clientY: number) => XYPosition;
267
- onConnect?: ((connection: Connection) => void) | undefined;
268
- isValid?: ((connection: Connection) => boolean) | undefined;
269
- /** When false, interactive connect is disabled (view mode). Default true. */
270
- enabled?: boolean | undefined;
271
- }
272
- interface UseConnectionReturn {
273
- /** The in-progress connection, or null. The canvas draws a live path from it. */
274
- connection: ReadonlySignal<ConnectionState | null>;
275
- }
276
- /**
277
- * Drag from a `source` handle to a `target` handle to create an edge. Tracks a
278
- * live connection in a signal; on a valid drop fires `onConnect`. All pointer
279
- * side effects live in `useSignalEffect`; SSR-guarded; no pointer capture (so
280
- * `pointerup.target` resolves to the handle under the pointer).
281
- */
282
- declare function useConnection(options: UseConnectionOptions): UseConnectionReturn;
283
- interface StoryClock {
284
- setTimeout: (callback: () => void, ms: number) => unknown;
285
- clearTimeout: (handle: unknown) => void;
286
- }
287
- interface UseStoryOptions {
288
- steps: ResolvedStep[];
289
- loop?: boolean | undefined;
290
- /** Controlled play state. */
291
- playing?: boolean | undefined;
292
- defaultPlaying?: boolean | undefined;
293
- onPlayingChange?: ((playing: boolean) => void) | undefined;
294
- /** Controlled step index. */
295
- currentStep?: number | undefined;
296
- defaultCurrentStep?: number | undefined;
297
- onStepChange?: ((step: number) => void) | undefined;
298
- /** Default per-step duration (ms). */
299
- stepDuration?: number | undefined;
300
- /** Extra pause added after each step before advancing (ms). Default 0. */
301
- stepGap?: number | undefined;
302
- /** Injectable clock for deterministic tests (default real timers). */
303
- clock?: StoryClock | undefined;
304
- }
305
- interface UseStoryReturn {
306
- currentStep: Signal<number>;
307
- playing: Signal<boolean>;
308
- activeStep: ReadonlySignal<ResolvedStep | null>;
309
- play: () => void;
310
- pause: () => void;
311
- toggle: () => void;
312
- next: () => void;
313
- prev: () => void;
314
- restart: () => void;
315
- }
316
- /**
317
- * The storyline sequencer: a `currentStep` signal advanced by a timer inside
318
- * `useSignalEffect` (the carousel/relative-time idiom) with an injectable clock
319
- * for deterministic tests. Loops when `loop`. No `useEffect`/wall-clock.
320
- */
321
- declare function useStory(options: UseStoryOptions): UseStoryReturn;
322
- interface FlowCanvasProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
323
- children?: ReactNode;
324
- /** Share an external store (e.g. from `<Flow>`). When omitted, an internal one is created. */
325
- flow?: FlowStore;
326
- /** Controlled viewport (used only when no external `flow` is provided). */
327
- viewport?: Viewport;
328
- defaultViewport?: Viewport;
329
- onViewportChange?: ((viewport: Viewport) => void) | undefined;
330
- minZoom?: number | undefined;
331
- maxZoom?: number | undefined;
332
- /** Drag the empty pane to pan. Default true. */
333
- panOnDrag?: boolean | undefined;
334
- /** Wheel/pinch to zoom. Default true. */
335
- zoomOnScroll?: boolean | undefined;
336
- /** Frame the graph once on mount. Default false. */
337
- fitView?: boolean | undefined;
338
- /** Use a viewport controller owned by a parent (e.g. `<Flow>`). */
339
- controller?: UseViewportReturn;
340
- /** Screen-fixed overlay (controls, minimap, panels) — rendered outside the transformed pane. */
341
- chrome?: ReactNode;
342
- className?: string;
343
- }
344
- /**
345
- * The canvas pane: a single CSS-transformed layer driven by the `viewport`
346
- * signal, with drag-to-pan, wheel zoom, and fit-view. Renders `children`
347
- * (background, nodes, edges) inside the transformed pane. `useSignals()` first.
348
- */
349
- declare function FlowCanvas({
350
- children,
351
- flow,
352
- viewport: viewportProp,
353
- defaultViewport,
354
- onViewportChange,
355
- minZoom,
356
- maxZoom,
357
- panOnDrag,
358
- zoomOnScroll,
359
- fitView,
360
- controller: controllerProp,
361
- chrome,
362
- className,
363
- role,
364
- ...rest
365
- }: FlowCanvasProps): import("react").JSX.Element;
366
- type FlowBackgroundVariant = 'dots' | 'grid' | 'cross';
367
- interface FlowBackgroundProps extends HTMLAttributes<HTMLDivElement> {
368
- /** Pattern style. Default `dots`. */
369
- variant?: FlowBackgroundVariant;
370
- /** Distance between pattern cells, in flow px. Default 20. */
371
- gap?: number;
372
- /** Dot radius / line thickness, in flow px. Default 1. */
373
- size?: number;
374
- /** Pattern color. Defaults to the border token. */
375
- color?: string;
376
- className?: string;
377
- }
378
- /**
379
- * Decorative dots / grid / cross background, drawn purely in CSS gradients
380
- * (no SVG, no per-cell DOM). Lives inside the transformed pane, so it pans and
381
- * scales with the viewport for free. `pointer-events: none` — clicks fall
382
- * through to the pan surface.
383
- */
384
- declare function FlowBackground({
385
- variant,
386
- gap,
387
- size,
388
- color,
389
- className,
390
- style,
391
- ...rest
392
- }: FlowBackgroundProps): import("react").JSX.Element;
393
- interface FlowNodeProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
394
- id: string;
395
- /** Position in flow coordinates (controllable). */
396
- position?: XYPosition;
397
- defaultPosition?: XYPosition;
398
- onPositionChange?: (position: XYPosition) => void;
399
- /** Reports the rendered box size so edges can anchor to the real node bounds. */
400
- onMeasure?: (size: NodeSize) => void;
401
- /** Current zoom — drag deltas are divided by it so the node tracks the pointer. */
402
- zoom?: number;
403
- selected?: boolean;
404
- draggable?: boolean;
405
- /** When false, the node is view-only: not draggable, not selectable, not focusable. Default true. */
406
- interactive?: boolean;
407
- onSelect?: ((id: string) => void) | undefined;
408
- children?: ReactNode;
409
- className?: string;
410
- }
411
- /**
412
- * An HTML node box positioned inside the viewport pane by `--flow-x`/`--flow-y`.
413
- * Draggable via `useDraggable` (zoom-corrected), selectable via CSS
414
- * `data-selected`, and renders arbitrary themed cascivo children.
415
- * `useSignals()` first; no `useState`/`useEffect`.
416
- */
417
- declare function FlowNode({
418
- id,
419
- position,
420
- defaultPosition,
421
- onPositionChange,
422
- onMeasure,
423
- zoom,
424
- selected,
425
- draggable,
426
- interactive,
427
- onSelect,
428
- children,
429
- className,
430
- onClick,
431
- onKeyDown,
432
- ...rest
433
- }: FlowNodeProps): import("react").JSX.Element;
434
- interface FlowHandleProps extends HTMLAttributes<HTMLDivElement> {
435
- type: 'source' | 'target';
436
- /** Edge of the node the port sits on. Defaults by type (source→right, target→left). */
437
- position?: HandlePosition;
438
- /** Handle id, for multi-handle nodes. */
439
- id?: string;
440
- isConnectable?: boolean;
441
- className?: string;
442
- }
443
- /**
444
- * A connection port on a node edge. Marks where edges attach and where
445
- * interactive connect (T5) starts/ends. Renders a small dot inside a ≥44px
446
- * coarse-pointer hit area; keyboard-focusable. No internal state.
447
- */
448
- declare function FlowHandle({
449
- type,
450
- position,
451
- id,
452
- isConnectable,
453
- className,
454
- ...rest
455
- }: FlowHandleProps): import("react").JSX.Element;
456
- interface FlowEdgeProps {
457
- id?: string;
458
- /** Resolved source anchor (flow coords). */
459
- sourceX: number;
460
- sourceY: number;
461
- /** Resolved target anchor (flow coords). */
462
- targetX: number;
463
- targetY: number;
464
- sourcePosition?: HandlePosition | undefined;
465
- targetPosition?: HandlePosition | undefined;
466
- type?: EdgePathType | undefined;
467
- animated?: boolean | undefined;
468
- label?: ReactNode | undefined;
469
- selected?: boolean | undefined;
470
- /** Render an arrowhead at the source (points back toward the source). Default false. */
471
- markerStart?: boolean | undefined;
472
- /** Render an arrowhead at the target. Default true. */
473
- markerEnd?: boolean | undefined;
474
- /** Direction the dash travels when animated. Default 'forward'. */
475
- direction?: 'forward' | 'reverse' | undefined;
476
- /** Highlight the edge (used by FlowStory's active step). */
477
- active?: boolean | undefined;
478
- className?: string | undefined;
479
- }
480
- /**
481
- * An SVG edge: computes its path from source→target anchors using the owned
482
- * bezier/straight/smoothstep builders, draws an arrowhead marker, and (if
483
- * `label`) an HTML label at the midpoint. Animation is CSS-only.
484
- * `useSignals()` first; no `useState`/`useEffect`.
485
- */
486
- declare function FlowEdge({
487
- id,
488
- sourceX,
489
- sourceY,
490
- targetX,
491
- targetY,
492
- sourcePosition,
493
- targetPosition,
494
- type,
495
- animated,
496
- label,
497
- selected,
498
- markerStart,
499
- markerEnd,
500
- direction,
501
- active,
502
- className
503
- }: FlowEdgeProps): import("react").JSX.Element;
504
- type FlowChromePosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
505
- interface FlowControlsLabels {
506
- zoomIn?: string;
507
- zoomOut?: string;
508
- fitView?: string;
509
- }
510
- interface FlowControlsProps extends HTMLAttributes<HTMLDivElement> {
511
- position?: FlowChromePosition;
512
- showZoom?: boolean;
513
- showFitView?: boolean;
514
- onZoomIn?: () => void;
515
- onZoomOut?: () => void;
516
- onFitView?: () => void;
517
- labels?: FlowControlsLabels;
518
- className?: string;
519
- }
520
- /**
521
- * Zoom in / out / fit-view controls for a flow canvas — real buttons with
522
- * i18n-defaulted aria-labels. Calls the viewport actions passed in.
523
- * `useSignals()` first (reads the locale signal via `t`).
524
- */
525
- declare function FlowControls({
526
- position,
527
- showZoom,
528
- showFitView,
529
- onZoomIn,
530
- onZoomOut,
531
- onFitView,
532
- labels,
533
- className,
534
- ...rest
535
- }: FlowControlsProps): import("react").JSX.Element;
536
- interface FlowMiniMapProps {
537
- nodes: FlowNode$1[];
538
- viewport: Viewport;
539
- /** Canvas size — used to draw the visible-region rectangle. */
540
- containerWidth?: number | undefined;
541
- containerHeight?: number | undefined;
542
- width?: number | undefined;
543
- height?: number | undefined;
544
- position?: FlowChromePosition | undefined;
545
- nodeColor?: string | undefined;
546
- onViewportChange?: ((viewport: Viewport) => void) | undefined;
547
- label?: string | undefined;
548
- className?: string | undefined;
549
- }
550
- /**
551
- * A scaled SVG overview of the graph with a draggable viewport rectangle.
552
- * Dragging the rectangle pans the main viewport. `useSignals()` first.
553
- */
554
- declare function FlowMiniMap({
555
- nodes,
556
- viewport,
557
- containerWidth,
558
- containerHeight,
559
- width,
560
- height,
561
- position,
562
- nodeColor,
563
- onViewportChange,
564
- label,
565
- className
566
- }: FlowMiniMapProps): import("react").JSX.Element;
567
- type FlowPanelPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
568
- interface FlowPanelProps extends HTMLAttributes<HTMLDivElement> {
569
- position?: FlowPanelPosition;
570
- children?: ReactNode;
571
- className?: string;
572
- }
573
- /**
574
- * An absolutely-positioned slot for custom UI on a flow canvas (a legend, a
575
- * toolbar). Pure presentational — no state.
576
- */
577
- declare function FlowPanel({
578
- position,
579
- children,
580
- className,
581
- ...rest
582
- }: FlowPanelProps): import("react").JSX.Element;
583
- type NodeRenderer = (args: {
584
- node: FlowNode$1;
585
- }) => ReactNode;
586
- interface FlowProps {
587
- /** Initial nodes (serializable — an agent can emit these as JSON). */
588
- nodes: FlowNode$1[];
589
- /** Initial edges. */
590
- edges: FlowEdge$1[];
591
- onNodesChange?: (nodes: FlowNode$1[]) => void;
592
- onEdgesChange?: (edges: FlowEdge$1[]) => void;
593
- onConnect?: (connection: Connection) => void;
594
- /** Custom node renderers keyed by `node.type`. */
595
- nodeTypes?: Record<string, NodeRenderer>;
596
- /** Frame the graph on mount. Default true. */
597
- fitView?: boolean;
598
- /** Show a background — `true` for dots, or pass props. Default false. */
599
- background?: boolean | FlowBackgroundProps;
600
- /** Show zoom/fit controls. Default false. */
601
- controls?: boolean;
602
- /** Show a minimap. Default false. */
603
- minimap?: boolean;
604
- /** Arrange nodes: 'grid' | 'layered' | a custom function. */
605
- layout?: LayoutStrategy;
606
- minZoom?: number;
607
- maxZoom?: number;
608
- /**
609
- * Interaction mode. When false (view mode), nodes can't be selected, dragged,
610
- * or connected and connection handles are hidden — pan/zoom still work.
611
- * Default true.
612
- */
613
- interactive?: boolean;
614
- /** Highlight + animate a single edge (used by FlowStory's active step). */
615
- activeEdgeId?: string | undefined;
616
- activeDirection?: 'forward' | 'reverse' | undefined;
617
- className?: string;
618
- style?: CSSProperties;
619
- }
620
- /**
621
- * The declarative, AI-first flow surface: `<Flow nodes={…} edges={…} />` over
622
- * plain serializable data. Composes the canvas, background, nodes, edges,
623
- * interactive connect, and optional chrome. `useSignals()` first; no banned hooks.
624
- */
625
- declare function Flow({
626
- nodes,
627
- edges,
628
- onNodesChange,
629
- onEdgesChange,
630
- onConnect,
631
- nodeTypes,
632
- fitView,
633
- background,
634
- controls,
635
- minimap,
636
- layout,
637
- minZoom,
638
- maxZoom,
639
- interactive,
640
- activeEdgeId,
641
- activeDirection,
642
- className,
643
- style
644
- }: FlowProps): import("react").JSX.Element;
645
- interface FlowStoryLabels {
646
- play?: string;
647
- pause?: string;
648
- next?: string;
649
- previous?: string;
650
- restart?: string;
651
- }
652
- interface FlowStoryProps {
653
- nodes: FlowNode$1[];
654
- edges: FlowEdge$1[];
655
- /** The storyboard: an ordered, serializable list of steps. */
656
- script: StoryStep[];
657
- loop?: boolean;
658
- /** Per-step dwell time (ms). Default 1500. */
659
- stepDuration?: number;
660
- /** Extra pause added after each step before advancing (ms), so the story is easier to follow. Default 0. */
661
- stepGap?: number;
662
- playing?: boolean;
663
- currentStep?: number;
664
- onStepChange?: (step: number) => void;
665
- /** Show the play/pause/prev/next controls. Default true. */
666
- controls?: boolean;
667
- /** Start playing on mount. Default true. */
668
- autoPlay?: boolean;
669
- background?: boolean;
670
- /**
671
- * Allow selecting / dragging / connecting nodes. A storyline is a view by
672
- * default — pan/zoom still work. Default false.
673
- */
674
- interactive?: boolean;
675
- labels?: FlowStoryLabels;
676
- /** Injectable clock for deterministic tests. */
677
- clock?: StoryClock;
678
- className?: string;
679
- style?: CSSProperties;
680
- }
681
- /**
682
- * A scripted, sequenced, looping flow animation: walks a graph step by step,
683
- * fading in a caption at each step so the flow is *understood*. Composes
684
- * `<Flow>` and drives the active edge via a `currentStep` signal.
685
- * `useSignals()` first; no banned hooks.
686
- */
687
- declare function FlowStory({
688
- nodes,
689
- edges,
690
- script,
691
- loop,
692
- stepDuration,
693
- stepGap,
694
- playing,
695
- currentStep,
696
- onStepChange,
697
- controls,
698
- autoPlay,
699
- background,
700
- interactive,
701
- labels,
702
- clock,
703
- className,
704
- style
705
- }: FlowStoryProps): import("react").JSX.Element;
706
- export { type Connection, ConnectionState, DEFAULT_NODE_SIZE, EdgePath, EdgePathParams, type EdgePathType, FitViewportOptions, Flow, FlowBackground, FlowBackgroundProps, FlowBackgroundVariant, FlowCanvas, FlowCanvasProps, FlowChromePosition, FlowControls, FlowControlsLabels, FlowControlsProps, FlowEdge, type FlowEdge$1 as FlowEdgeData, FlowEdgeProps, FlowHandle, FlowHandleProps, FlowMiniMap, FlowMiniMapProps, FlowNode, type FlowNode$1 as FlowNodeData, FlowNodeProps, FlowPanel, FlowPanelPosition, FlowPanelProps, FlowProps, FlowStore, FlowStory, FlowStoryLabels, FlowStoryProps, GridLayoutOptions, type HandlePosition, LayeredLayoutOptions, LayoutStrategy, NodeRenderer, type NodeSize, Rect, ResolvedStep, Size, StoryClock, StoryStep, StoryStepBase, StoryStepEdge, StoryStepFromTo, UseConnectionOptions, UseConnectionReturn, UseFlowOptions, UseStoryOptions, UseStoryReturn, UseViewportOptions, UseViewportReturn, type Viewport, type XYPosition, applyLayout, bezierPath, clampZoom, edgePath, fitViewport, flowToScreen, graphBounds, gridLayout, handleAnchor, layeredLayout, nodeBounds, nodeSize, resolveScript, resolveStep, screenToFlow, smoothStepPath, straightPath, useConnection, useFlow, useStory, useViewport };