@dschz/solid-flow 0.1.4 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Daniel Sanchez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://assets.solidjs.com/banner?project=solid-flow&type=Ecosystem&background=tiles" alt="@dschz/solid-flow banner" />
3
3
  </p>
4
4
 
5
- # @dschz/solid-flow
5
+ # Solid Flow
6
6
 
7
7
  [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
8
8
  [![npm](https://img.shields.io/npm/v/@dschz/solid-flow?color=blue)](https://www.npmjs.com/package/@dschz/solid-flow)
@@ -15,10 +15,9 @@
15
15
 
16
16
  ## Current Unsupported Features:
17
17
 
18
- - `onlyRenderVisibleElements` prop: the ability to only render visible elements on screen.
19
- - Note: The prop is defined as part of `SolidFlow` but it is a no-op. During development and benchmarking, it was revealed that use of it degraded rendering performance due to the amount of work done to actually achieve the outcome of the feature. We need to innovate on the implementation to make the performance comparable (ideally better) to the normal performance of rendering all the nodes/edges on screen. As such it is a no-op prop for now.
20
- - Custom MiniMap nodes: the ability to render custom node visuals in the minimap
21
- - Edge Reconnect Anchors: the ability to re-connect already connected edges
18
+ - [onlyRenderVisibleElements](https://github.com/dsnchz/solid-flow/issues/15): render only visible elements.
19
+ - [Custom MiniMap Nodes](https://github.com/dsnchz/solid-flow/issues/12): define custom minimap jsx node elements.
20
+ - [Edge Reconnect Anchors](https://github.com/dsnchz/solid-flow/issues/13): the ability to re-connect already connected edges.
22
21
 
23
22
  ## Key Features
24
23
 
@@ -38,6 +37,9 @@ The easiest way to get the latest version of Solid Flow is to install it via npm
38
37
 
39
38
  ```sh
40
39
  npm install @dschz/solid-flow
40
+ pnpm install @dschz/solid-flow
41
+ yarn install @dschz/solid-flow
42
+ bun install @dschz/solid-flow
41
43
  ```
42
44
 
43
45
  ## Quick Start
@@ -47,6 +49,7 @@ This is a basic example to get you started. For more advanced examples and full
47
49
  ```tsx
48
50
  import {
49
51
  SolidFlow,
52
+ SolidFlowProvider,
50
53
  Controls,
51
54
  Background,
52
55
  MiniMap,
@@ -54,10 +57,24 @@ import {
54
57
  type EdgeConnection,
55
58
  createEdgeStore,
56
59
  createNodeStore,
60
+ type Viewport,
57
61
  } from "@dschz/solid-flow";
58
62
  import "@dschz/solid-flow/styles"; // Required styles
59
63
 
60
- export default function Flow() {
64
+ import { createStore, produce } from "solid-js/store";
65
+
66
+ export default function Page() {
67
+ return (
68
+ <SolidFlowProvider>
69
+ <Flow />
70
+ </SolidFlowProvider>
71
+ )
72
+ }
73
+
74
+ function Flow() {
75
+ // Can invoke useSolidFlow due to parent Page + SolidFlowProvider wrapper. Contains all helper APIs
76
+ const { .. } = useSolidFlow();
77
+
61
78
  // Use createNodeStore and createEdgeStore for reactive state management
62
79
  const [nodes, setNodes] = createNodeStore([
63
80
  {
@@ -85,6 +102,16 @@ export default function Flow() {
85
102
  { id: "e2-3", source: "2", target: "3" },
86
103
  ]);
87
104
 
105
+ const [viewport, setViewport] = createStore<Viewport>({
106
+ x: 100,
107
+ y: 100,
108
+ zoom: 5,
109
+ });
110
+
111
+ const updateViewport = () => {
112
+ setViewport("x", (prev) => prev + 10);
113
+ };
114
+
88
115
  const onConnect = (connection: EdgeConnection) => {
89
116
  /**
90
117
  * Solid Flow updates the node/edge stores internally. The user-land edge store will have the connection inserted by the time onConnect fires so we can just go ahead and update the state of it
@@ -101,6 +128,9 @@ export default function Flow() {
101
128
  <SolidFlow nodes={nodes} edges={edges} onConnect={onConnect} fitView>
102
129
  <Controls />
103
130
  <MiniMap />
131
+ <Panel position="top-left">
132
+ <button onClick={updateViewport}>Update viewport</button>
133
+ </Panel>
104
134
  <Background variant="dots" />
105
135
  </SolidFlow>
106
136
  );
@@ -196,10 +226,10 @@ import { Handle, type NodeProps } from "@dschz/solid-flow";
196
226
  function CustomNode(props: NodeProps<{ label: string }, "custom">) {
197
227
  return (
198
228
  <div class="custom-node" style={{ padding: "10px", background: "white" }}>
199
- <Handle type="target" position="top />
229
+ <Handle type="target" position="top" />
200
230
  <div>{props.data.label}</div>
201
231
  <Handle type="source" position="bottom" id="output-a" />
202
- <Handle type="source" position="bottom id="output-b" style={{ left: "80%" }} />
232
+ <Handle type="source" position="bottom" id="output-b" style={{ left: "80%" }} />
203
233
  </div>
204
234
  );
205
235
  }
@@ -1,7 +1,5 @@
1
- import * as solid_js from 'solid-js';
2
1
  import { JSX, ParentProps, ParentComponent, Accessor } from 'solid-js';
3
- import * as _xyflow_system from '@xyflow/system';
4
- import { NodeProps as NodeProps$1, NodeBase, InternalNodeBase, EdgeBase, EdgePosition, BezierPathOptions, StepPathOptions, SmoothStepPathOptions, DefaultEdgeOptionsBase, OnReconnect, HandleType, FinalConnectionState, PanOnScrollMode as PanOnScrollMode$1, Position as Position$1, FitViewOptionsBase, ResizeControlVariant as ResizeControlVariant$1, ConnectionMode as ConnectionMode$1, SelectionMode as SelectionMode$1, ConnectionLineType as ConnectionLineType$2, OnBeforeDeleteBase, Connection, XYPosition, Handle as Handle$1, PanelPosition, Viewport, OnMove, OnMoveStart, OnMoveEnd, HandleProps as HandleProps$1, MarkerProps as MarkerProps$1, ShouldResize, OnResizeStart, OnResize, OnResizeEnd, ControlPosition, Align, NodeOrigin, SnapGrid, CoordinateExtent, ColorMode, ProOptions, IsValidConnection, OnError, OnConnectStart, OnConnectEnd, OnReconnectStart, OnReconnectEnd, AriaLabelConfig, ConnectionState, NodeConnection, ZoomInOut, ViewportHelperFunctionOptions, SetCenterOptions, Rect, FitBoundsOptions, HandleConnection, UpdateNodeInternals } from '@xyflow/system';
2
+ import { NodeProps as NodeProps$1, NodeBase, InternalNodeBase, EdgeBase, EdgePosition, BezierPathOptions, StepPathOptions, SmoothStepPathOptions, DefaultEdgeOptionsBase, OnReconnect, HandleType, FinalConnectionState, PanOnScrollMode as PanOnScrollMode$1, Position as Position$1, FitViewOptionsBase, ResizeControlVariant as ResizeControlVariant$1, ConnectionMode as ConnectionMode$1, SelectionMode as SelectionMode$1, ConnectionLineType as ConnectionLineType$2, Connection, OnBeforeDeleteBase, XYPosition, Handle as Handle$1, PanelPosition, Viewport, OnMove, OnMoveStart, OnMoveEnd, HandleProps as HandleProps$1, MarkerProps as MarkerProps$1, EdgeToolbarBaseProps, ShouldResize, OnResizeStart, OnResize, OnResizeEnd, ControlPosition, Align, NodeOrigin, SnapGrid, CoordinateExtent, ColorMode, ZIndexMode, ProOptions, OnError, OnConnectStart, OnConnectEnd, OnReconnectStart, OnReconnectEnd, AriaLabelConfig, ColorModeClass, ConnectionState, NodeConnection, ZoomInOut, ViewportHelperFunctionOptions, SetCenterOptions, Rect, FitBoundsOptions, HandleConnection, UpdateNodeInternals } from '@xyflow/system';
5
3
  export { Align, AriaLabelConfig, BezierPathOptions, Box, ColorMode, ColorModeClass, Connection, ConnectionLineType, ConnectionMode, ControlLinePosition, ControlPosition, CoordinateExtent, Dimensions, EdgeMarker, EdgeMarkerType, FitBounds, FitBoundsOptions, GetBezierPathParams, GetSmoothStepPathParams, GetStraightPathParams, HandleConnection, IsValidConnection, MarkerType, NodeConnection, NodeOrigin, OnConnect, OnConnectEnd, OnConnectStart, OnConnectStartParams, OnError, OnMove, OnMoveEnd, OnMoveStart, OnReconnect, OnReconnectEnd, OnReconnectStart, OnResize, OnResizeEnd, OnResizeStart, OnSelectionDrag, PanOnScrollMode, PanelPosition, Position, ProOptions, Rect, ResizeControlVariant, ResizeDragEvent, ResizeParams, ResizeParamsWithDirection, SelectionMode, SelectionRect, SetCenter, SetCenterOptions, SetViewport, ShouldResize, SmoothStepPathOptions, SnapGrid, Transform, Viewport, ViewportHelperFunctionOptions, XYPosition, XYZPosition, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds } from '@xyflow/system';
6
4
  import { Store, SetStoreFunction } from 'solid-js/store';
7
5
 
@@ -274,6 +272,7 @@ type OnBeforeEdgeConnect<EdgeType extends Edge = Edge> = (connection: EdgeConnec
274
272
  type OnEdgeConnect = (connection: EdgeConnection) => void;
275
273
  type OnBeforeReconnect<EdgeType extends Edge = Edge> = (newEdge: EdgeType, oldEdge: EdgeType) => EdgeType | undefined;
276
274
  type OnBeforeDelete<NodeType extends Node = Node, EdgeType extends Edge = Edge> = OnBeforeDeleteBase<NodeType, EdgeType>;
275
+ type IsValidConnection<EdgeType extends Edge = Edge> = (edge: EdgeType | Connection) => boolean;
277
276
  type OnSelectionChange<NodeType extends Node = Node, EdgeType extends Edge = Edge> = (params: {
278
277
  nodes: NodeType[];
279
278
  edges: EdgeType[];
@@ -288,16 +287,18 @@ type EdgeRendererProps<EdgeType extends Edge = Edge> = EdgeEvents<EdgeType> & {
288
287
  readonly defaultEdgeOptions?: DefaultEdgeOptions;
289
288
  readonly reconnectRadius: number;
290
289
  };
291
- declare const EdgeRenderer: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: EdgeRendererProps<EdgeType>) => solid_js.JSX.Element;
290
+ declare const EdgeRenderer: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: EdgeRendererProps<EdgeType>) => JSX.Element;
292
291
 
293
292
  type NodeRendererProps<NodeType extends Node = Node> = NodeEvents<NodeType> & {
294
293
  readonly nodeClickDistance: number;
295
294
  };
296
- declare const NodeRenderer: <NodeType extends Node = Node>(props: NodeRendererProps<NodeType>) => solid_js.JSX.Element;
295
+ declare const NodeRenderer: <NodeType extends Node = Node>(props: NodeRendererProps<NodeType>) => JSX.Element;
297
296
 
298
297
  type PaneProps = PaneEvents & {
299
298
  readonly panOnDrag?: boolean | number[];
300
299
  readonly selectionOnDrag?: boolean;
300
+ readonly paneClickDistance?: number;
301
+ readonly autoPanOnSelection?: boolean;
301
302
  readonly onSelectionStart?: (event: PointerEvent) => void;
302
303
  readonly onSelectionEnd?: (event: PointerEvent) => void;
303
304
  };
@@ -314,7 +315,7 @@ type PanelProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, "style"> & {
314
315
  };
315
316
  declare const Panel: (props: ParentProps<PanelProps>) => JSX.Element;
316
317
 
317
- declare const ViewportPortal: (props: ParentProps) => solid_js.JSX.Element;
318
+ declare const ViewportPortal: (props: ParentProps) => JSX.Element;
318
319
 
319
320
  type ZoomProps = {
320
321
  readonly initialViewport?: Viewport;
@@ -328,10 +329,12 @@ type ZoomProps = {
328
329
  readonly zoomOnDoubleClick: boolean;
329
330
  readonly zoomOnPinch: boolean;
330
331
  readonly panOnScroll: boolean;
332
+ readonly panOnScrollSpeed: number;
331
333
  readonly panOnDrag: boolean | number[];
332
334
  readonly paneClickDistance: number;
335
+ readonly selectionOnDrag?: boolean;
333
336
  };
334
- declare const Zoom: (props: ParentProps<ZoomProps>) => solid_js.JSX.Element;
337
+ declare const Zoom: (props: ParentProps<ZoomProps>) => JSX.Element;
335
338
 
336
339
  type ConnectionLineType = `${ConnectionLineType$2}`;
337
340
  /**
@@ -365,11 +368,11 @@ type ConnectionLineProps<NodeType extends Node = Node> = {
365
368
  };
366
369
  declare const ConnectionLine: <NodeType extends Node = Node>(props: ParentProps<Partial<ConnectionLineProps<NodeType>>>) => JSX.Element;
367
370
 
368
- declare const BaseEdge: (props: ParentProps<BaseEdgeProps>) => solid_js.JSX.Element;
371
+ declare const BaseEdge: (props: ParentProps<BaseEdgeProps>) => JSX.Element;
369
372
 
370
- declare const BezierEdge: (props: BezierEdgeProps) => solid_js.JSX.Element;
373
+ declare const BezierEdge: (props: BezierEdgeProps) => JSX.Element;
371
374
 
372
- declare const BezierEdgeInternal: (props: BezierEdgeProps) => solid_js.JSX.Element;
375
+ declare const BezierEdgeInternal: (props: BezierEdgeProps) => JSX.Element;
373
376
 
374
377
  type EdgeLabelProps = {
375
378
  readonly x?: number;
@@ -382,7 +385,7 @@ type EdgeLabelProps = {
382
385
  } & Omit<JSX.HTMLAttributes<HTMLDivElement>, "style">;
383
386
  declare const EdgeLabel: (props: ParentProps<EdgeLabelProps>) => JSX.Element;
384
387
 
385
- declare const EdgeLabelRenderer: (props: ParentProps) => solid_js.JSX.Element;
388
+ declare const EdgeLabelRenderer: (props: ParentProps) => JSX.Element;
386
389
 
387
390
  type EdgeReconnectAnchorProps = {
388
391
  readonly type: HandleType;
@@ -397,19 +400,19 @@ declare const EdgeReconnectAnchor: (props: ParentProps<EdgeReconnectAnchorProps>
397
400
  type EdgeWrapperProps<EdgeType extends Edge = Edge> = EdgeEvents<EdgeType> & {
398
401
  readonly edgeId: string;
399
402
  };
400
- declare const EdgeWrapper: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: EdgeWrapperProps<EdgeType>) => solid_js.JSX.Element;
403
+ declare const EdgeWrapper: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: EdgeWrapperProps<EdgeType>) => JSX.Element;
401
404
 
402
- declare const SmoothStepEdge: (props: SmoothStepEdgeProps) => solid_js.JSX.Element;
405
+ declare const SmoothStepEdge: (props: SmoothStepEdgeProps) => JSX.Element;
403
406
 
404
- declare const SmoothStepEdgeInternal: (props: SmoothStepEdgeProps) => solid_js.JSX.Element;
407
+ declare const SmoothStepEdgeInternal: (props: SmoothStepEdgeProps) => JSX.Element;
405
408
 
406
- declare const StepEdge: (props: StepEdgeProps) => solid_js.JSX.Element;
409
+ declare const StepEdge: (props: StepEdgeProps) => JSX.Element;
407
410
 
408
- declare const StepEdgeInternal: (props: StepEdgeProps) => solid_js.JSX.Element;
411
+ declare const StepEdgeInternal: (props: StepEdgeProps) => JSX.Element;
409
412
 
410
- declare const StraightEdge: (props: StraightEdgeProps) => solid_js.JSX.Element;
413
+ declare const StraightEdge: (props: StraightEdgeProps) => JSX.Element;
411
414
 
412
- declare const StraightEdgeInternal: (props: Omit<StraightEdgeProps, "sourcePosition" | "targetPosition">) => solid_js.JSX.Element;
415
+ declare const StraightEdgeInternal: (props: Omit<StraightEdgeProps, "sourcePosition" | "targetPosition">) => JSX.Element;
413
416
 
414
417
  type HandleProps = Omit<HandleProps$1, "position"> & {
415
418
  readonly position: Position;
@@ -426,28 +429,28 @@ type MarkerProps = MarkerProps$1 & {
426
429
  };
427
430
  declare const Marker: (props: MarkerProps) => JSX.Element;
428
431
 
429
- declare const MarkerDefinition: () => solid_js.JSX.Element;
432
+ declare const MarkerDefinition: () => JSX.Element;
430
433
 
431
434
  declare const DefaultNode: (props: NodeProps<{
432
435
  label: string;
433
- }, "default">) => solid_js.JSX.Element;
436
+ }, "default">) => JSX.Element;
434
437
 
435
- declare const GroupNode: (props: NodeProps<Record<string, never>>) => solid_js.JSX.Element;
438
+ declare const GroupNode: (props: NodeProps<Record<string, never>>) => JSX.Element;
436
439
 
437
440
  declare const InputNode: (props: NodeProps<{
438
441
  label: string;
439
- }>) => solid_js.JSX.Element;
442
+ }>) => JSX.Element;
440
443
 
441
444
  type NodeWrapperProps<NodeType extends Node = Node> = NodeEvents<NodeType> & {
442
445
  readonly nodeId: string;
443
446
  readonly resizeObserver: ResizeObserver;
444
447
  readonly nodeClickDistance: number;
445
448
  };
446
- declare const NodeWrapper: <NodeType extends Node = Node>(props: NodeWrapperProps<NodeType>) => solid_js.JSX.Element;
449
+ declare const NodeWrapper: <NodeType extends Node = Node>(props: NodeWrapperProps<NodeType>) => JSX.Element;
447
450
 
448
451
  declare const OutputNode: (props: NodeProps<{
449
452
  label: string;
450
- }>) => solid_js.JSX.Element;
453
+ }>) => JSX.Element;
451
454
 
452
455
  type BackgroundVariant = "lines" | "dots" | "cross";
453
456
 
@@ -513,6 +516,19 @@ type ControlsProps = {
513
516
  } & Omit<JSX.HTMLAttributes<HTMLDivElement>, "style">;
514
517
  declare const Controls: (props: ParentProps<ControlsProps>) => JSX.Element;
515
518
 
519
+ type EdgeToolbarProps = EdgeToolbarBaseProps & {
520
+ /** If `true`, clicking the toolbar selects the edge it belongs to. */
521
+ readonly selectEdgeOnClick?: boolean;
522
+ } & Omit<JSX.HTMLAttributes<HTMLDivElement>, "style">;
523
+ /**
524
+ * The `<EdgeToolbar />` component renders a toolbar or tooltip for an edge.
525
+ * It must be used inside a custom edge component. By default it is only
526
+ * visible when the edge is selected; pass `isVisible` to control it manually.
527
+ *
528
+ * The toolbar does not scale with the viewport so that its content is always legible.
529
+ */
530
+ declare const EdgeToolbar: (props: ParentProps<EdgeToolbarProps>) => JSX.Element;
531
+
516
532
  type GetMiniMapNodeAttribute<NodeType extends Node> = (node: NodeType) => string;
517
533
  type MiniMapProps<NodeType extends Node> = Omit<JSX.HTMLAttributes<HTMLDivElement>, "style"> & {
518
534
  /** Background color of minimap */
@@ -630,7 +646,7 @@ type NodeToolbarProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, "style"> & {
630
646
  declare const NodeToolbar: ParentComponent<Partial<NodeToolbarProps>>;
631
647
 
632
648
  type NodeSelectionProps<NodeType extends Node = Node> = NodeSelectionEvents<NodeType> & Pick<NodeEvents<NodeType>, "onNodeDrag" | "onNodeDragStart" | "onNodeDragStop">;
633
- declare const NodeSelection: <NodeType extends Node = Node>(props: NodeSelectionProps<NodeType>) => solid_js.JSX.Element;
649
+ declare const NodeSelection: <NodeType extends Node = Node>(props: NodeSelectionProps<NodeType>) => JSX.Element;
634
650
 
635
651
  type SelectionProps = {
636
652
  readonly x?: number;
@@ -639,7 +655,7 @@ type SelectionProps = {
639
655
  readonly height?: number | string;
640
656
  readonly isVisible?: boolean;
641
657
  };
642
- declare const Selection: (props: SelectionProps) => solid_js.JSX.Element;
658
+ declare const Selection: (props: SelectionProps) => JSX.Element;
643
659
 
644
660
  type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge> = NodeEvents<NodeType> & NodeSelectionEvents<NodeType> & EdgeEvents<EdgeType> & DeleteEvents<NodeType, EdgeType> & PaneEvents & {
645
661
  /**
@@ -819,7 +835,7 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
819
835
  * You can pass `null` to use the CSS variable `--xy-edge-stroke` for the marker color.
820
836
  * @example "#b1b1b7"
821
837
  */
822
- readonly defaultMarkerColor?: string;
838
+ readonly defaultMarkerColor?: string | null;
823
839
  /**
824
840
  * Controls if all nodes should be draggable
825
841
  * @default true
@@ -830,6 +846,11 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
830
846
  * @default true
831
847
  */
832
848
  readonly autoPanOnNodeFocus?: boolean;
849
+ /**
850
+ * When `true`, the viewport will pan when a drag selection approaches the edges of the flow container.
851
+ * @default true
852
+ */
853
+ readonly autoPanOnSelection?: boolean;
833
854
  /**
834
855
  * Controls if all nodes should be connectable to each other
835
856
  * @default true
@@ -959,6 +980,14 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
959
980
  * @default true
960
981
  */
961
982
  readonly elevateNodesOnSelect?: boolean;
983
+ /**
984
+ * Controls how z-indexes are calculated for nodes and edges.
985
+ * 'auto' automatically manages z-indexing for selections and sub flows,
986
+ * 'basic' manages z-indexing for selections only, and
987
+ * 'manual' does not apply any automatic z-indexing.
988
+ * @default "basic"
989
+ */
990
+ readonly zIndexMode?: ZIndexMode;
962
991
  /**
963
992
  * Enabling this option will raise the z-index of edges when they are selected,
964
993
  * or when the connected nodes are selected.
@@ -1013,7 +1042,7 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
1013
1042
  * before doing so.
1014
1043
  */
1015
1044
  readonly proOptions?: ProOptions;
1016
- readonly isValidConnection?: IsValidConnection;
1045
+ readonly isValidConnection?: IsValidConnection<EdgeType>;
1017
1046
  /** This event handler is called when the user begins to pan or zoom the viewport */
1018
1047
  readonly onMoveStart?: OnMoveStart;
1019
1048
  /** This event handler is called when the user pans or zooms the viewport */
@@ -1049,7 +1078,7 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
1049
1078
  /** This event gets fired when a user starts to reconnect an edge */
1050
1079
  readonly onReconnectStart?: OnReconnectStart<EdgeType>;
1051
1080
  /** This event gets fired when a user stops reconnecting an edge */
1052
- readonly onReconnectEnd?: OnReconnectEnd<EdgeType>;
1081
+ readonly onReconnectEnd?: OnReconnectEnd<NodeType, EdgeType>;
1053
1082
  /** This handler gets called when an edge is reconnected. You can use it to modify the edge before the update is applied. */
1054
1083
  readonly onBeforeReconnect?: OnBeforeReconnect<EdgeType>;
1055
1084
  /** A connection is started by clicking on a handle */
@@ -1080,7 +1109,7 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
1080
1109
  type SolidFlowComponentProps<NodeType extends Node = Node, EdgeType extends Edge = Edge> = ParentProps<SolidFlowProps<NodeType, EdgeType>> & Omit<JSX.HTMLAttributes<HTMLDivElement>, "style" | "onselectionchange" | "onSelectionChange">;
1081
1110
  declare const SolidFlow: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: SolidFlowComponentProps<NodeType, EdgeType>) => JSX.Element;
1082
1111
 
1083
- declare const SolidFlowProvider: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: ParentProps<SolidFlowProps<NodeType, EdgeType>>) => solid_js.JSX.Element;
1112
+ declare const SolidFlowProvider: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: ParentProps<SolidFlowProps<NodeType, EdgeType>>) => JSX.Element;
1084
1113
 
1085
1114
  type ExtractEdgeInfo<T> = T extends (props: EdgeProps<infer TData, infer TType>) => unknown ? {
1086
1115
  data: TData;
@@ -1249,6 +1278,17 @@ type NodesInput<TUserNodeTypes extends NodeTypes> = {
1249
1278
  */
1250
1279
  declare const createNodeStore: <TUserNodeTypes extends NodeTypes = Record<string, never>>(nodes: NodesInput<TUserNodeTypes>[]) => readonly [Store<NodesInput<TUserNodeTypes>[]>, SetStoreFunction<NodesInput<TUserNodeTypes>[]>];
1251
1280
 
1281
+ /**
1282
+ * Hook for receiving the current color mode class ('dark' or 'light').
1283
+ *
1284
+ * When the flow's `colorMode` prop is set to `"system"`, this resolves to the
1285
+ * user's current system preference.
1286
+ *
1287
+ * @public
1288
+ * @returns an accessor for the current color mode class
1289
+ */
1290
+ declare function useColorMode(): () => ColorModeClass;
1291
+
1252
1292
  /**
1253
1293
  * Hook for receiving the current connection.
1254
1294
  *
@@ -1263,24 +1303,44 @@ declare function useConnection(): Accessor<ConnectionState>;
1263
1303
  * @public
1264
1304
  * @returns store with an array of nodes
1265
1305
  */
1266
- declare function useNodes<NodeType extends Node = Node>(): () => NodeType[];
1306
+ declare function useNodes<NodeType extends Node = Node>(): Accessor<NodeType[]>;
1267
1307
  /**
1268
1308
  * Hook for getting the current edges from the store.
1269
1309
  *
1270
1310
  * @public
1271
1311
  * @returns store with an array of edges
1272
1312
  */
1273
- declare function useEdges<EdgeType extends Edge = Edge>(): () => EdgeType[];
1313
+ declare function useEdges<EdgeType extends Edge = Edge>(): Accessor<EdgeType[]>;
1274
1314
  /**
1275
1315
  * Hook for getting the current viewport from the store.
1276
1316
  *
1277
1317
  * @public
1278
1318
  * @returns store with the viewport object
1279
1319
  */
1280
- declare function useViewport(): () => _xyflow_system.Viewport;
1320
+ declare function useViewport(): Accessor<Viewport>;
1281
1321
 
1282
1322
  declare function useHandleEdgeSelect(): (id: string) => void;
1283
1323
 
1324
+ /**
1325
+ * Hook for seeing if all nodes have been measured.
1326
+ *
1327
+ * Returns `false` until every non-hidden node has been rendered and measured.
1328
+ * Useful for running layouting or fitView logic that depends on node dimensions.
1329
+ *
1330
+ * @public
1331
+ * @returns an accessor that indicates whether the nodes are initialized
1332
+ */
1333
+ declare function useNodesInitialized(): Accessor<boolean>;
1334
+ /**
1335
+ * Hook for seeing if the viewport is initialized.
1336
+ *
1337
+ * Returns `true` once the pan/zoom instance has been created for the flow.
1338
+ *
1339
+ * @public
1340
+ * @returns an accessor that indicates whether the viewport is initialized
1341
+ */
1342
+ declare function useViewportInitialized(): Accessor<boolean>;
1343
+
1284
1344
  /**
1285
1345
  * Hook to get an internal node by id.
1286
1346
  *
@@ -1579,4 +1639,4 @@ declare function useSolidFlow<NodeType extends Node = Node, EdgeType extends Edg
1579
1639
  */
1580
1640
  declare function useUpdateNodeInternals(): UpdateNodeInternals;
1581
1641
 
1582
- export { Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, type ConnectionData, ConnectionLine, type ConnectionLineComponentProps, ControlButton, Controls, type DefaultEdgeOptions, DefaultNode, type DeleteEvents, type Edge, type EdgeConnection, type EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeProps, EdgeReconnectAnchor, type EdgeReconnectEvents, EdgeRenderer, type EdgeTypes, EdgeWrapper, type FitViewOptions, GroupNode, Handle, InputNode, type InternalNode, type KeyDefinition, type KeyDefinitionObject, type KeyModifier, Marker, MarkerDefinition, MiniMap, type Node, type NodeEvents, type NodeGraph, type NodeProps, NodeRenderer, NodeResizer, NodeSelection, type NodeSelectionEvents, NodeToolbar, type NodeToolbarProps, type NodeTypes, NodeWrapper, type OnBeforeDelete, type OnBeforeEdgeConnect, type OnBeforeReconnect, type OnDelete, type OnEdgeConnect, type OnEdgeCreate, type OnSelectionChange, OutputNode, Pane, type PaneEvents, Panel, ResizeControl, Selection, type ShortcutModifier, type ShortcutModifierDefinition, SmoothStepEdge, SmoothStepEdgeInternal, type SmoothStepEdgeProps, SolidFlow, SolidFlowProvider, StepEdge, StepEdgeInternal, type StepEdgeProps, StraightEdge, StraightEdgeInternal, type StraightEdgeProps, ViewportPortal, Zoom, createEdgeStore, createNodeStore, useConnection, useEdges, useHandleEdgeSelect, useInternalNode, useNodeConnections, useNodes, useNodesData, useSolidFlow, useUpdateNodeInternals, useViewport };
1642
+ export { Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, type ConnectionData, ConnectionLine, type ConnectionLineComponentProps, ControlButton, Controls, type DefaultEdgeOptions, DefaultNode, type DeleteEvents, type Edge, type EdgeConnection, type EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeProps, EdgeReconnectAnchor, type EdgeReconnectEvents, EdgeRenderer, EdgeToolbar, type EdgeToolbarProps, type EdgeTypes, EdgeWrapper, type FitViewOptions, GroupNode, Handle, InputNode, type InternalNode, type KeyDefinition, type KeyDefinitionObject, type KeyModifier, Marker, MarkerDefinition, MiniMap, type Node, type NodeEvents, type NodeGraph, type NodeProps, NodeRenderer, NodeResizer, NodeSelection, type NodeSelectionEvents, NodeToolbar, type NodeToolbarProps, type NodeTypes, NodeWrapper, type OnBeforeDelete, type OnBeforeEdgeConnect, type OnBeforeReconnect, type OnDelete, type OnEdgeConnect, type OnEdgeCreate, type OnSelectionChange, OutputNode, Pane, type PaneEvents, Panel, ResizeControl, Selection, type ShortcutModifier, type ShortcutModifierDefinition, SmoothStepEdge, SmoothStepEdgeInternal, type SmoothStepEdgeProps, SolidFlow, SolidFlowProvider, StepEdge, StepEdgeInternal, type StepEdgeProps, StraightEdge, StraightEdgeInternal, type StraightEdgeProps, ViewportPortal, Zoom, createEdgeStore, createNodeStore, useColorMode, useConnection, useEdges, useHandleEdgeSelect, useInternalNode, useNodeConnections, useNodes, useNodesData, useNodesInitialized, useSolidFlow, useUpdateNodeInternals, useViewport, useViewportInitialized };