@dschz/solid-flow 0.2.4 → 0.3.0-next.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/index.d.ts +207 -250
- package/dist/index/index.js +2490 -2288
- package/dist/index/index.jsx +1682 -1448
- package/package.json +14 -20
package/dist/index/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSX } from "@solidjs/web";
|
|
2
|
+
import { Accessor, ParentComponent, ParentProps, Store, StoreSetter } from "solid-js";
|
|
2
3
|
import { Align, Align as Align$1, AriaLabelConfig, AriaLabelConfig as AriaLabelConfig$1, BezierPathOptions, BezierPathOptions as BezierPathOptions$1, Box, ColorMode, ColorMode as ColorMode$1, ColorModeClass, ColorModeClass as ColorModeClass$1, Connection, Connection as Connection$1, ConnectionLineType, ConnectionLineType as ConnectionLineType$1, ConnectionMode, ConnectionMode as ConnectionMode$1, ConnectionState, ControlLinePosition, ControlPosition, ControlPosition as ControlPosition$1, CoordinateExtent, CoordinateExtent as CoordinateExtent$1, DefaultEdgeOptionsBase, Dimensions, EdgeBase, EdgeMarker, EdgeMarkerType, EdgePosition, EdgeToolbarBaseProps, FinalConnectionState, FitBounds, FitBoundsOptions, FitBoundsOptions as FitBoundsOptions$1, FitViewOptionsBase, GetBezierPathParams, GetSmoothStepPathParams, GetStraightPathParams, Handle as Handle$1, HandleConnection, HandleConnection as HandleConnection$1, HandleProps, HandleType, InternalNodeBase, IsValidConnection, MarkerProps, MarkerType, NodeBase, NodeConnection, NodeConnection as NodeConnection$1, NodeOrigin, NodeOrigin as NodeOrigin$1, NodeProps as NodeProps$1, OnBeforeDeleteBase, OnConnect, OnConnectEnd, OnConnectEnd as OnConnectEnd$1, OnConnectStart, OnConnectStart as OnConnectStart$1, OnConnectStartParams, OnError, OnError as OnError$1, OnMove, OnMove as OnMove$1, OnMoveEnd, OnMoveEnd as OnMoveEnd$1, OnMoveStart, OnMoveStart as OnMoveStart$1, OnReconnect, OnReconnect as OnReconnect$1, OnReconnectEnd, OnReconnectEnd as OnReconnectEnd$1, OnReconnectStart, OnReconnectStart as OnReconnectStart$1, OnResize, OnResize as OnResize$1, OnResizeEnd, OnResizeEnd as OnResizeEnd$1, OnResizeStart, OnResizeStart as OnResizeStart$1, OnSelectionDrag, PanOnScrollMode, PanOnScrollMode as PanOnScrollMode$1, PanelPosition, PanelPosition as PanelPosition$1, Position as Position$1, Position as Position$2, ProOptions, ProOptions as ProOptions$1, Rect, Rect as Rect$1, ResizeControlVariant, ResizeControlVariant as ResizeControlVariant$1, ResizeDragEvent, ResizeParams, ResizeParamsWithDirection, SelectionMode, SelectionMode as SelectionMode$1, SelectionRect, SetCenter, SetCenterOptions, SetCenterOptions as SetCenterOptions$1, SetViewport, ShouldResize, ShouldResize as ShouldResize$1, SmoothStepPathOptions, SmoothStepPathOptions as SmoothStepPathOptions$1, SnapGrid, SnapGrid as SnapGrid$1, StepPathOptions, Transform, UpdateNodeInternals, Viewport, Viewport as Viewport$1, ViewportHelperFunctionOptions, ViewportHelperFunctionOptions as ViewportHelperFunctionOptions$1, XYPosition, XYPosition as XYPosition$1, XYZPosition, ZIndexMode, ZoomInOut, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds } from "@xyflow/system";
|
|
3
|
-
import { SetStoreFunction, Store } from "solid-js/store";
|
|
4
4
|
//#region src/types/node.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The node data structure that gets used for internal nodes.
|
|
@@ -142,6 +142,13 @@ type EdgeTypes = { [K in string]: {
|
|
|
142
142
|
bivarianceHack(props: EdgeProps<Record<string, unknown>, string | undefined>): JSX.Element;
|
|
143
143
|
}["bivarianceHack"]; };
|
|
144
144
|
type DefaultEdgeOptions = DefaultEdgeOptionsBase<Edge>;
|
|
145
|
+
type EdgeLayouted<EdgeType extends Edge = Edge> = EdgeType & EdgePosition & {
|
|
146
|
+
sourceNode?: Node;
|
|
147
|
+
targetNode?: Node;
|
|
148
|
+
sourceHandleId?: string | null;
|
|
149
|
+
targetHandleId?: string | null;
|
|
150
|
+
edge: EdgeType;
|
|
151
|
+
};
|
|
145
152
|
//#endregion
|
|
146
153
|
//#region src/types/events.d.ts
|
|
147
154
|
type NodeEventWithPointer<T = PointerEvent, NodeType extends Node = Node> = ({ node, event }: {
|
|
@@ -656,6 +663,7 @@ type ResizeControlProps = NodeResizerSubProps & {
|
|
|
656
663
|
* @example ResizeControlVariant.Handle, ResizeControlVariant.Line
|
|
657
664
|
*/
|
|
658
665
|
readonly variant?: ResizeControlVariant$2;
|
|
666
|
+
readonly color?: string;
|
|
659
667
|
readonly style?: JSX.CSSProperties;
|
|
660
668
|
} & Omit<JSX.HTMLAttributes<HTMLDivElement>, "onResize" | "style">;
|
|
661
669
|
declare const ResizeControl: <NodeType extends Node = Node>(props: ParentProps<ResizeControlProps>) => JSX.Element;
|
|
@@ -1153,6 +1161,158 @@ declare const SolidFlow: <NodeType extends Node = Node, EdgeType extends Edge =
|
|
|
1153
1161
|
//#region src/components/SolidFlow/provider.d.ts
|
|
1154
1162
|
declare const SolidFlowProvider: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: ParentProps<SolidFlowProps<NodeType, EdgeType>>) => JSX.Element;
|
|
1155
1163
|
//#endregion
|
|
1164
|
+
//#region src/core/projections/connections.d.ts
|
|
1165
|
+
/**
|
|
1166
|
+
* Lookup keys for the connection index. Each edge is registered under six
|
|
1167
|
+
* keys — for both of its endpoints: the node, the node+handle-type, and (when
|
|
1168
|
+
* a handle id is present) the node+type+handle:
|
|
1169
|
+
* `${nodeId}` · `${nodeId}-${type}` · `${nodeId}-${type}-${handleId}`
|
|
1170
|
+
*/
|
|
1171
|
+
declare const connectionKey: (nodeId: string, type?: HandleType, handleId?: string | null) => string;
|
|
1172
|
+
type ConnectionsRecord = Record<string, Record<string, HandleConnection$1>>;
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/core/flowState.d.ts
|
|
1175
|
+
/**
|
|
1176
|
+
* The current selection, as one object: the pair travels together everywhere
|
|
1177
|
+
* it is consumed (selection change callbacks, deletion, toolbars).
|
|
1178
|
+
*/
|
|
1179
|
+
type FlowSelection<NodeType extends Node = Node, EdgeType extends Edge = Edge> = {
|
|
1180
|
+
readonly nodes: readonly NodeType[];
|
|
1181
|
+
readonly edges: readonly EdgeType[];
|
|
1182
|
+
};
|
|
1183
|
+
/**
|
|
1184
|
+
* The flow's data graph as one reactive struct — the canonical read surface.
|
|
1185
|
+
*
|
|
1186
|
+
* Every property read in a tracked scope is a live subscription; the struct
|
|
1187
|
+
* itself is a stable identity for the provider's lifetime, so destructuring
|
|
1188
|
+
* `const { flow } = useSolidFlow()` is safe (reactivity lives inside the
|
|
1189
|
+
* property reads, not in the container). Reads in event handlers are
|
|
1190
|
+
* untracked, so `flow.viewport.zoom` inside a handler is already the
|
|
1191
|
+
* "imperative getter" — no extra API needed.
|
|
1192
|
+
*
|
|
1193
|
+
* Keyed lookups are id-keyed records (`flow.internalNodes[id]`) rather than
|
|
1194
|
+
* Maps: reactive property reads, per-key granularity, and the shape the
|
|
1195
|
+
* underlying projections produce natively.
|
|
1196
|
+
*/
|
|
1197
|
+
type FlowState<NodeType extends Node = Node, EdgeType extends Edge = Edge> = {
|
|
1198
|
+
/** The user node graph. */
|
|
1199
|
+
readonly nodes: readonly NodeType[];
|
|
1200
|
+
/** The user edge graph. */
|
|
1201
|
+
readonly edges: readonly EdgeType[];
|
|
1202
|
+
/** Adopted nodes keyed by id: absolute positions, z order, measured dimensions, handle bounds. */
|
|
1203
|
+
readonly internalNodes: Record<string, InternalNode<NodeType>>;
|
|
1204
|
+
/** Screen-space edge geometry keyed by edge id; edges with missing/unmeasured endpoints have no entry. */
|
|
1205
|
+
readonly layoutedEdges: Record<string, EdgeLayouted<EdgeType>>;
|
|
1206
|
+
/**
|
|
1207
|
+
* The connection index. Keys are built with {@link connectionKey}:
|
|
1208
|
+
* `nodeId`, `nodeId-type`, and `nodeId-type-handleId`; each value maps a
|
|
1209
|
+
* connection pair key to its {@link HandleConnection}.
|
|
1210
|
+
*/
|
|
1211
|
+
readonly connections: ConnectionsRecord;
|
|
1212
|
+
/** The currently selected nodes and edges. */
|
|
1213
|
+
readonly selection: FlowSelection<NodeType, EdgeType>;
|
|
1214
|
+
/** True once every non-hidden node has been measured. */
|
|
1215
|
+
readonly nodesInitialized: boolean;
|
|
1216
|
+
/** True once the pan/zoom instance exists. */
|
|
1217
|
+
readonly viewportInitialized: boolean;
|
|
1218
|
+
readonly viewport: Viewport$1;
|
|
1219
|
+
/** The flow container's measured width in px. */
|
|
1220
|
+
readonly width: number;
|
|
1221
|
+
/** The flow container's measured height in px. */
|
|
1222
|
+
readonly height: number;
|
|
1223
|
+
/** The resolved color mode ("system" resolves to the user's preference). */
|
|
1224
|
+
readonly colorMode: ColorModeClass$1;
|
|
1225
|
+
/** The in-progress connection gesture state. */
|
|
1226
|
+
readonly connection: ConnectionState<InternalNode<NodeType>>;
|
|
1227
|
+
/** True while a node drag is in progress. */
|
|
1228
|
+
readonly dragging: boolean;
|
|
1229
|
+
readonly minZoom: number;
|
|
1230
|
+
readonly maxZoom: number;
|
|
1231
|
+
readonly nodesDraggable: boolean;
|
|
1232
|
+
readonly nodesConnectable: boolean;
|
|
1233
|
+
readonly elementsSelectable: boolean;
|
|
1234
|
+
readonly snapGrid: SnapGrid$1 | undefined;
|
|
1235
|
+
};
|
|
1236
|
+
/**
|
|
1237
|
+
* The flow's write surface: every public mutation, viewport motion, and
|
|
1238
|
+
* geometry helper. Commands are stable identities — destructuring
|
|
1239
|
+
* `const { commands } = useSolidFlow()` is safe.
|
|
1240
|
+
*/
|
|
1241
|
+
type FlowCommands<NodeType extends Node = Node, EdgeType extends Edge = Edge> = {
|
|
1242
|
+
/** Fits the view to the graph (or to `options.nodes`). */
|
|
1243
|
+
readonly fitView: (options?: FitViewOptions<NodeType>) => Promise<boolean>;
|
|
1244
|
+
/** Fits the view to the given bounds. */
|
|
1245
|
+
readonly fitBounds: (bounds: Rect$1, options?: FitBoundsOptions$1) => Promise<boolean>;
|
|
1246
|
+
/** Zooms in by 1.2. */
|
|
1247
|
+
readonly zoomIn: ZoomInOut;
|
|
1248
|
+
/** Zooms out by 1 / 1.2. */
|
|
1249
|
+
readonly zoomOut: ZoomInOut;
|
|
1250
|
+
/** Sets the zoom level. */
|
|
1251
|
+
readonly setZoom: (zoomLevel: number, options?: ViewportHelperFunctionOptions$1) => Promise<boolean>;
|
|
1252
|
+
/** Centers the view on the given flow position. */
|
|
1253
|
+
readonly setCenter: (x: number, y: number, options?: SetCenterOptions$1) => Promise<boolean>;
|
|
1254
|
+
/** Sets the viewport. */
|
|
1255
|
+
readonly setViewport: (viewport: Viewport$1, options?: ViewportHelperFunctionOptions$1) => Promise<boolean>;
|
|
1256
|
+
/** Pans the viewport by the given delta. */
|
|
1257
|
+
readonly panBy: (delta: XYPosition$1) => Promise<boolean>;
|
|
1258
|
+
/** Converts a screen/client position to a flow position. */
|
|
1259
|
+
readonly screenToFlowPosition: (clientPosition: XYPosition$1, options?: {
|
|
1260
|
+
snapToGrid: boolean;
|
|
1261
|
+
}) => XYPosition$1;
|
|
1262
|
+
/** Converts a flow position to a screen/client position. */
|
|
1263
|
+
readonly flowToScreenPosition: (flowPosition: XYPosition$1) => XYPosition$1;
|
|
1264
|
+
/** Appends one or many nodes. */
|
|
1265
|
+
readonly addNodes: (payload: NodeType[] | NodeType) => void;
|
|
1266
|
+
/** Appends one or many edges. */
|
|
1267
|
+
readonly addEdges: (payload: EdgeType[] | EdgeType) => void;
|
|
1268
|
+
/** Writes the nodes root (canonical Solid store setter — mutate the draft or return a new array). */
|
|
1269
|
+
readonly setNodes: StoreSetter<NodeType[]>;
|
|
1270
|
+
/** Writes the edges root (canonical Solid store setter — mutate the draft or return a new array). */
|
|
1271
|
+
readonly setEdges: StoreSetter<EdgeType[]>;
|
|
1272
|
+
/** Merges (or replaces, with `options.replace`) a node by id. */
|
|
1273
|
+
readonly updateNode: (id: string, nodeUpdate: Partial<NodeType> | ((node: NodeType) => Partial<NodeType>), options?: {
|
|
1274
|
+
replace: boolean;
|
|
1275
|
+
}) => void;
|
|
1276
|
+
/** Merges (or replaces, with `options.replace`) a node's `data` by id. */
|
|
1277
|
+
readonly updateNodeData: (id: string, dataUpdate: Partial<NodeType["data"]> | ((node: NodeType) => Partial<NodeType["data"]>), options?: {
|
|
1278
|
+
replace: boolean;
|
|
1279
|
+
}) => void;
|
|
1280
|
+
/** Merges (or replaces, with `options.replace`) an edge by id. */
|
|
1281
|
+
readonly updateEdge: (id: string, edgeUpdate: Partial<EdgeType> | ((edge: EdgeType) => Partial<EdgeType>), options?: {
|
|
1282
|
+
replace: boolean;
|
|
1283
|
+
}) => void;
|
|
1284
|
+
/** Deletes the given nodes/edges plus connected edges, honoring `onBeforeDelete`. */
|
|
1285
|
+
readonly deleteElements: (params: {
|
|
1286
|
+
nodes?: (Partial<NodeType> & {
|
|
1287
|
+
id: string;
|
|
1288
|
+
})[];
|
|
1289
|
+
edges?: (Partial<EdgeType> & {
|
|
1290
|
+
id: string;
|
|
1291
|
+
})[];
|
|
1292
|
+
}) => Promise<{
|
|
1293
|
+
deletedNodes: NodeType[];
|
|
1294
|
+
deletedEdges: EdgeType[];
|
|
1295
|
+
}>;
|
|
1296
|
+
/** All nodes intersecting the given node or rect. */
|
|
1297
|
+
readonly getIntersectingNodes: (nodeOrRect: NodeType | {
|
|
1298
|
+
id: NodeType["id"];
|
|
1299
|
+
} | Rect$1, partially?: boolean, nodesToIntersect?: NodeType[]) => NodeType[];
|
|
1300
|
+
/** Whether the given node or rect intersects the area. */
|
|
1301
|
+
readonly isNodeIntersecting: (nodeOrRect: NodeType | {
|
|
1302
|
+
id: NodeType["id"];
|
|
1303
|
+
} | Rect$1, area: Rect$1, partially?: boolean) => boolean;
|
|
1304
|
+
/** The bounding rect of the given nodes (or node ids). */
|
|
1305
|
+
readonly getNodesBounds: (nodes: (NodeType | InternalNode<NodeType> | string)[]) => Rect$1;
|
|
1306
|
+
/** Requests a DOM re-measure of the given node id(s). */
|
|
1307
|
+
readonly updateNodeInternals: (id: string | string[]) => void;
|
|
1308
|
+
/** The nodes, edges, and viewport as a plain JSON-safe object. */
|
|
1309
|
+
readonly toObject: () => {
|
|
1310
|
+
nodes: NodeType[];
|
|
1311
|
+
edges: EdgeType[];
|
|
1312
|
+
viewport: Viewport$1;
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
//#endregion
|
|
1156
1316
|
//#region src/data/createEdgeStore.d.ts
|
|
1157
1317
|
type ExtractEdgeInfo<T> = T extends ((props: EdgeProps<infer TData, infer TType>) => unknown) ? {
|
|
1158
1318
|
data: TData;
|
|
@@ -1236,7 +1396,7 @@ type EdgesInput<TUserEdgeTypes extends EdgeTypes> = { [K in keyof AllEdgeTypes<T
|
|
|
1236
1396
|
* - Works seamlessly with both built-in and custom node types
|
|
1237
1397
|
* - Type errors prevent invalid type names or incorrect data structures
|
|
1238
1398
|
*/
|
|
1239
|
-
declare const createEdgeStore: <TUserEdgeTypes extends EdgeTypes = Record<string, never>>(edges: EdgesInput<TUserEdgeTypes>[]) => readonly [Store<EdgesInput<TUserEdgeTypes>[]>,
|
|
1399
|
+
declare const createEdgeStore: <TUserEdgeTypes extends EdgeTypes = Record<string, never>>(edges: EdgesInput<TUserEdgeTypes>[]) => readonly [Store<EdgesInput<TUserEdgeTypes>[]>, StoreSetter<EdgesInput<TUserEdgeTypes>[]>];
|
|
1240
1400
|
//#endregion
|
|
1241
1401
|
//#region src/data/createNodeStore.d.ts
|
|
1242
1402
|
type ExtractNodeInfo<T> = T extends ((props: NodeProps<infer TData, infer TType>) => unknown) ? {
|
|
@@ -1316,7 +1476,7 @@ type NodesInput<TUserNodeTypes extends NodeTypes> = { [K in keyof AllNodeTypes<T
|
|
|
1316
1476
|
* - Works seamlessly with both built-in and custom node types
|
|
1317
1477
|
* - Type errors prevent invalid type names or incorrect data structures
|
|
1318
1478
|
*/
|
|
1319
|
-
declare const createNodeStore: <TUserNodeTypes extends NodeTypes = Record<string, never>>(nodes: NodesInput<TUserNodeTypes>[]) => readonly [Store<NodesInput<TUserNodeTypes>[]>,
|
|
1479
|
+
declare const createNodeStore: <TUserNodeTypes extends NodeTypes = Record<string, never>>(nodes: NodesInput<TUserNodeTypes>[]) => readonly [Store<NodesInput<TUserNodeTypes>[]>, StoreSetter<NodesInput<TUserNodeTypes>[]>];
|
|
1320
1480
|
//#endregion
|
|
1321
1481
|
//#region src/hooks/useColorMode.d.ts
|
|
1322
1482
|
/**
|
|
@@ -1428,265 +1588,62 @@ declare function useNodesData<NodeType extends Node = Node>(nodeIds: Accessor<st
|
|
|
1428
1588
|
//#endregion
|
|
1429
1589
|
//#region src/hooks/useSolidFlow.d.ts
|
|
1430
1590
|
/**
|
|
1431
|
-
*
|
|
1591
|
+
* The canonical flow API: the reactive {@link FlowState} struct plus the
|
|
1592
|
+
* {@link FlowCommands} write surface. Every command is also spread onto the
|
|
1593
|
+
* returned object directly for upstream (React Flow / Svelte Flow)
|
|
1594
|
+
* familiarity — `useSolidFlow().fitView()` and
|
|
1595
|
+
* `useSolidFlow().commands.fitView()` are the same function.
|
|
1432
1596
|
*
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1597
|
+
* The imperative getters are deprecated: event handlers are untracked scopes
|
|
1598
|
+
* in Solid, so reading `flow.viewport.zoom` (or `flow.internalNodes[id]`)
|
|
1599
|
+
* inside one already IS the imperative read — no wrapper needed — while the
|
|
1600
|
+
* same read in a tracked scope subscribes.
|
|
1435
1601
|
*/
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
/**
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
* Returns a node by id.
|
|
1458
|
-
*
|
|
1459
|
-
* @param id - the node id
|
|
1460
|
-
* @returns the node or undefined if no node was found
|
|
1461
|
-
*/
|
|
1462
|
-
getNode: (id: string) => NodeType | undefined;
|
|
1463
|
-
/**
|
|
1464
|
-
* Returns nodes.
|
|
1465
|
-
*
|
|
1466
|
-
* @returns nodes array
|
|
1467
|
-
*/
|
|
1468
|
-
getNodes: (ids?: string[]) => NodeType[];
|
|
1469
|
-
/**
|
|
1470
|
-
* Returns an edge by id.
|
|
1471
|
-
*
|
|
1472
|
-
* @param id - the edge id
|
|
1473
|
-
* @returns the edge or undefined if no edge was found
|
|
1474
|
-
*/
|
|
1475
|
-
getEdge: (id: string) => EdgeType | undefined;
|
|
1476
|
-
/**
|
|
1477
|
-
* Returns edges.
|
|
1478
|
-
*
|
|
1479
|
-
* @returns edges array
|
|
1480
|
-
*/
|
|
1481
|
-
getEdges: (ids?: string[]) => EdgeType[];
|
|
1482
|
-
/**
|
|
1483
|
-
* Add one or many nodes to your existing nodes array.
|
|
1484
|
-
*
|
|
1485
|
-
* @param payload - the nodes to add
|
|
1486
|
-
*/
|
|
1487
|
-
addNodes: (payload: NodeType[] | NodeType) => void;
|
|
1488
|
-
/**
|
|
1489
|
-
* Add one or many edges to your existing edges array.
|
|
1490
|
-
*
|
|
1491
|
-
* @param payload - the edges to add
|
|
1492
|
-
*/
|
|
1493
|
-
addEdges: (payload: EdgeType[] | EdgeType) => void;
|
|
1494
|
-
/**
|
|
1495
|
-
* Sets the current zoom level.
|
|
1496
|
-
*
|
|
1497
|
-
* @param zoomLevel - the zoom level to set
|
|
1498
|
-
* @param options.duration - optional duration. If set, a transition will be applied
|
|
1499
|
-
*/
|
|
1500
|
-
setZoom: (zoomLevel: number, options?: ViewportHelperFunctionOptions$1) => Promise<boolean>;
|
|
1501
|
-
/**
|
|
1502
|
-
* Returns the current zoom level.
|
|
1503
|
-
*
|
|
1504
|
-
* @returns current zoom as a number
|
|
1505
|
-
*/
|
|
1506
|
-
getZoom: () => number;
|
|
1507
|
-
/**
|
|
1508
|
-
* Sets the center of the view to the given position.
|
|
1509
|
-
*
|
|
1510
|
-
* @param x - x position
|
|
1511
|
-
* @param y - y position
|
|
1512
|
-
* @param options.zoom - optional zoom
|
|
1513
|
-
*/
|
|
1514
|
-
setCenter: (x: number, y: number, options?: SetCenterOptions$1) => Promise<boolean>;
|
|
1515
|
-
/**
|
|
1516
|
-
* Sets the current viewport.
|
|
1517
|
-
*
|
|
1518
|
-
* @param viewport - the viewport to set
|
|
1519
|
-
* @param options.duration - optional duration. If set, a transition will be applied
|
|
1520
|
-
*/
|
|
1521
|
-
setViewport: (viewport: Viewport$1, options?: ViewportHelperFunctionOptions$1) => Promise<boolean>;
|
|
1522
|
-
/**
|
|
1523
|
-
* Returns the current viewport.
|
|
1524
|
-
*
|
|
1525
|
-
* @returns Viewport
|
|
1526
|
-
*/
|
|
1527
|
-
getViewport: () => Viewport$1;
|
|
1528
|
-
/**
|
|
1529
|
-
* Fits the view.
|
|
1530
|
-
*
|
|
1531
|
-
* @param options.padding - optional padding
|
|
1532
|
-
* @param options.includeHiddenNodes - optional includeHiddenNodes
|
|
1533
|
-
* @param options.minZoom - optional minZoom
|
|
1534
|
-
* @param options.maxZoom - optional maxZoom
|
|
1535
|
-
* @param options.duration - optional duration. If set, a transition will be applied
|
|
1536
|
-
* @param options.nodes - optional nodes to fit the view to
|
|
1537
|
-
*/
|
|
1538
|
-
fitView: (options?: FitViewOptions<NodeType>) => Promise<boolean>;
|
|
1539
|
-
/**
|
|
1540
|
-
* Returns all nodes that intersect with the given node or rect.
|
|
1541
|
-
*
|
|
1542
|
-
* @param node - the node or rect to check for intersections
|
|
1543
|
-
* @param partially - if true, the node is considered to be intersecting if it partially overlaps with the passed node or rect
|
|
1544
|
-
* @param nodes - optional nodes array to check for intersections
|
|
1545
|
-
*
|
|
1546
|
-
* @returns an array of intersecting nodes
|
|
1547
|
-
*/
|
|
1548
|
-
getIntersectingNodes: (nodeOrRect: NodeType | {
|
|
1549
|
-
id: NodeType["id"];
|
|
1550
|
-
} | Rect$1, partially?: boolean, nodesToIntersect?: NodeType[]) => NodeType[];
|
|
1551
|
-
/**
|
|
1552
|
-
* Checks if the given node or rect intersects with the passed rect.
|
|
1553
|
-
*
|
|
1554
|
-
* @param node - the node or rect to check for intersections
|
|
1555
|
-
* @param area - the rect to check for intersections
|
|
1556
|
-
* @param partially - if true, the node is considered to be intersecting if it partially overlaps with the passed react
|
|
1557
|
-
*
|
|
1558
|
-
* @returns true if the node or rect intersects with the given area
|
|
1559
|
-
*/
|
|
1560
|
-
isNodeIntersecting: (nodeOrRect: NodeType | {
|
|
1561
|
-
id: NodeType["id"];
|
|
1562
|
-
} | Rect$1, area: Rect$1, partially?: boolean) => boolean;
|
|
1563
|
-
/**
|
|
1564
|
-
* Fits the view to the given bounds .
|
|
1565
|
-
*
|
|
1566
|
-
* @param bounds - the bounds ({ x: number, y: number, width: number, height: number }) to fit the view to
|
|
1567
|
-
* @param options.padding - optional padding
|
|
1568
|
-
*/
|
|
1569
|
-
fitBounds: (bounds: Rect$1, options?: FitBoundsOptions$1) => Promise<boolean>;
|
|
1570
|
-
/**
|
|
1571
|
-
* Deletes nodes and edges.
|
|
1572
|
-
*
|
|
1573
|
-
* @param params.nodes - optional nodes array to delete
|
|
1574
|
-
* @param params.edges - optional edges array to delete
|
|
1575
|
-
*
|
|
1576
|
-
* @returns a promise that resolves with the deleted nodes and edges
|
|
1577
|
-
*/
|
|
1578
|
-
deleteElements: ({ nodes, edges }: {
|
|
1579
|
-
nodes?: (Partial<NodeType> & {
|
|
1580
|
-
id: string;
|
|
1581
|
-
})[];
|
|
1582
|
-
edges?: (Partial<EdgeType> & {
|
|
1583
|
-
id: string;
|
|
1584
|
-
})[];
|
|
1585
|
-
}) => Promise<{
|
|
1586
|
-
deletedNodes: NodeType[];
|
|
1587
|
-
deletedEdges: EdgeType[];
|
|
1588
|
-
}>;
|
|
1589
|
-
/**
|
|
1590
|
-
* Converts a screen / client position to a flow position.
|
|
1591
|
-
*
|
|
1592
|
-
* @param clientPosition - the screen / client position. When you are working with events you can use event.clientX and event.clientY
|
|
1593
|
-
* @param options.snapToGrid - if true, the converted position will be snapped to the grid
|
|
1594
|
-
* @returns position as { x: number, y: number }
|
|
1595
|
-
*
|
|
1596
|
-
* @example
|
|
1597
|
-
* const flowPosition = screenToFlowPosition({ x: event.clientX, y: event.clientY })
|
|
1598
|
-
*/
|
|
1599
|
-
screenToFlowPosition: (clientPosition: XYPosition$1, options?: {
|
|
1600
|
-
snapToGrid: boolean;
|
|
1601
|
-
}) => XYPosition$1;
|
|
1602
|
-
/**
|
|
1603
|
-
* Converts a flow position to a screen / client position.
|
|
1604
|
-
*
|
|
1605
|
-
* @param flowPosition - the screen / client position. When you are working with events you can use event.clientX and event.clientY
|
|
1606
|
-
* @returns position as { x: number, y: number }
|
|
1607
|
-
*
|
|
1608
|
-
* @example
|
|
1609
|
-
* const clientPosition = flowToScreenPosition({ x: node.position.x, y: node.position.y })
|
|
1610
|
-
*/
|
|
1611
|
-
flowToScreenPosition: (flowPosition: XYPosition$1) => XYPosition$1;
|
|
1612
|
-
/**
|
|
1613
|
-
* Updates a node.
|
|
1614
|
-
*
|
|
1615
|
-
* @param id - id of the node to update
|
|
1616
|
-
* @param nodeUpdate - the node update as an object or a function that receives the current node and returns the node update
|
|
1617
|
-
* @param options.replace - if true, the node is replaced with the node update, otherwise the changes get merged
|
|
1618
|
-
*
|
|
1619
|
-
* @example
|
|
1620
|
-
* updateNode('node-1', (node) => ({ position: { x: node.position.x + 10, y: node.position.y } }));
|
|
1621
|
-
*/
|
|
1622
|
-
updateNode: (id: string, nodeUpdate: Partial<NodeType> | ((node: NodeType) => Partial<NodeType>), options?: {
|
|
1623
|
-
replace: boolean;
|
|
1624
|
-
}) => void;
|
|
1625
|
-
/**
|
|
1626
|
-
* Updates the data attribute of a node.
|
|
1627
|
-
*
|
|
1628
|
-
* @param id - id of the node to update
|
|
1629
|
-
* @param dataUpdate - the data update as an object or a function that receives the current data and returns the data update
|
|
1630
|
-
* @param options.replace - if true, the data is replaced with the data update, otherwise the changes get merged
|
|
1631
|
-
*
|
|
1632
|
-
* @example
|
|
1633
|
-
* updateNodeData('node-1', { label: 'A new label' });
|
|
1634
|
-
*/
|
|
1635
|
-
updateNodeData: (id: string, dataUpdate: Partial<NodeType["data"]> | ((node: NodeType) => Partial<NodeType["data"]>), options?: {
|
|
1636
|
-
replace: boolean;
|
|
1637
|
-
}) => void;
|
|
1638
|
-
/**
|
|
1639
|
-
* Returns the nodes, edges and the viewport as a JSON object.
|
|
1640
|
-
*
|
|
1641
|
-
* @returns the nodes, edges and the viewport as a JSON object
|
|
1642
|
-
*/
|
|
1643
|
-
/**
|
|
1644
|
-
* Updates an edge.
|
|
1645
|
-
*
|
|
1646
|
-
* @param id - id of the edge to update
|
|
1647
|
-
* @param edgeUpdate - the edge update as an object or a function that receives the current edge and returns the edge update
|
|
1648
|
-
* @param options.replace - if true, the edge is replaced with the edge update, otherwise the changes get merged
|
|
1649
|
-
*
|
|
1650
|
-
* @example
|
|
1651
|
-
* updateNode('node-1', (node) => ({ position: { x: node.position.x + 10, y: node.position.y } }));
|
|
1652
|
-
*/
|
|
1653
|
-
updateEdge: (id: string, edgeUpdate: Partial<EdgeType> | ((edge: EdgeType) => Partial<EdgeType>), options?: {
|
|
1654
|
-
replace: boolean;
|
|
1655
|
-
}) => void;
|
|
1656
|
-
toObject: () => {
|
|
1657
|
-
nodes: NodeType[];
|
|
1658
|
-
edges: EdgeType[];
|
|
1659
|
-
viewport: Viewport$1;
|
|
1660
|
-
};
|
|
1661
|
-
/**
|
|
1662
|
-
* Returns the bounds of the given nodes or node ids.
|
|
1663
|
-
*
|
|
1664
|
-
* @param nodes - the nodes or node ids to calculate the bounds for
|
|
1665
|
-
*
|
|
1666
|
-
* @returns the bounds of the given nodes
|
|
1667
|
-
*/
|
|
1668
|
-
getNodesBounds: (nodes: (NodeType | InternalNode<NodeType> | string)[]) => Rect$1;
|
|
1669
|
-
/** Gets all connections for a given handle belonging to a specific node.
|
|
1670
|
-
*
|
|
1671
|
-
* @param type - handle type 'source' or 'target'
|
|
1672
|
-
* @param id - the handle id (this is only needed if you have multiple handles of the same type, meaning you have to provide a unique id for each handle)
|
|
1673
|
-
* @param nodeId - the node id the handle belongs to
|
|
1674
|
-
* @returns an array with handle connections
|
|
1675
|
-
*/
|
|
1676
|
-
getHandleConnections: ({ type, id, nodeId }: {
|
|
1602
|
+
type UseSolidFlowReturn<NodeType extends Node = Node, EdgeType extends Edge = Edge> = FlowCommands<NodeType, EdgeType> & {
|
|
1603
|
+
/** The flow's data graph as one reactive struct — the canonical read surface. */
|
|
1604
|
+
readonly flow: FlowState<NodeType, EdgeType>;
|
|
1605
|
+
/** The flow's write surface (same functions as the spread members). */
|
|
1606
|
+
readonly commands: FlowCommands<NodeType, EdgeType>;
|
|
1607
|
+
/** @deprecated Read `flow.internalNodes[id]` instead. */
|
|
1608
|
+
readonly getInternalNode: (id: string) => InternalNode<NodeType> | undefined;
|
|
1609
|
+
/** @deprecated Read `flow.internalNodes[id]?.internals.userNode` (or find in `flow.nodes`) instead. */
|
|
1610
|
+
readonly getNode: (id: string) => NodeType | undefined;
|
|
1611
|
+
/** @deprecated Read `flow.nodes` (or map ids over `flow.internalNodes`) instead. */
|
|
1612
|
+
readonly getNodes: (ids?: string[]) => NodeType[];
|
|
1613
|
+
/** @deprecated Read `flow.edges` (or find by id) instead. */
|
|
1614
|
+
readonly getEdge: (id: string) => EdgeType | undefined;
|
|
1615
|
+
/** @deprecated Read `flow.edges` (or filter by ids) instead. */
|
|
1616
|
+
readonly getEdges: (ids?: string[]) => EdgeType[];
|
|
1617
|
+
/** @deprecated Read `flow.viewport` instead. */
|
|
1618
|
+
readonly getViewport: () => Viewport$1;
|
|
1619
|
+
/** @deprecated Read `flow.viewport.zoom` instead. */
|
|
1620
|
+
readonly getZoom: () => number;
|
|
1621
|
+
/** @deprecated Read `flow.connections[connectionKey(nodeId, type, id)]` (or use `useNodeConnections`) instead. */
|
|
1622
|
+
readonly getHandleConnections: (params: {
|
|
1677
1623
|
type: HandleType;
|
|
1678
1624
|
nodeId: string;
|
|
1679
1625
|
id?: string | null;
|
|
1680
1626
|
}) => HandleConnection$1[];
|
|
1681
1627
|
};
|
|
1628
|
+
/**
|
|
1629
|
+
* Hook for accessing the flow instance: `{ flow, commands }` plus the
|
|
1630
|
+
* commands spread at the top level for upstream familiarity.
|
|
1631
|
+
*
|
|
1632
|
+
* `flow` and `commands` are stable identities, so destructuring them is safe:
|
|
1633
|
+
* `const { flow, commands } = useSolidFlow()`.
|
|
1634
|
+
*
|
|
1635
|
+
* @public
|
|
1636
|
+
* @returns the flow's read struct, write surface, and deprecated aliases
|
|
1637
|
+
*/
|
|
1638
|
+
declare function useSolidFlow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(): UseSolidFlowReturn<NodeType, EdgeType>;
|
|
1682
1639
|
//#endregion
|
|
1683
1640
|
//#region src/hooks/useUpdateNodeInternals.d.ts
|
|
1684
1641
|
/**
|
|
1685
|
-
* Hook for updating node internals.
|
|
1642
|
+
* Hook for updating node internals. Sugar for `commands.updateNodeInternals`.
|
|
1686
1643
|
*
|
|
1687
1644
|
* @public
|
|
1688
1645
|
* @returns function for updating node internals
|
|
1689
1646
|
*/
|
|
1690
1647
|
declare function useUpdateNodeInternals(): UpdateNodeInternals;
|
|
1691
1648
|
//#endregion
|
|
1692
|
-
export { type Align, type AriaLabelConfig, Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, type BezierPathOptions, type Box, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, type ColorMode, type ColorModeClass, type Connection, ConnectionData, ConnectionLine, type ConnectionLineComponentProps, ConnectionLineType, ConnectionMode, ControlButton, type ControlLinePosition, type ControlPosition, Controls, type CoordinateExtent, type DefaultEdgeOptions, DefaultNode, DeleteEvents, type Dimensions, type Edge, EdgeConnection, EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeMarker, type EdgeMarkerType, type EdgeProps, EdgeReconnectAnchor, EdgeReconnectEvents, EdgeRenderer, EdgeToolbar, EdgeToolbarProps, type EdgeTypes, EdgeWrapper, type FitBounds, type FitBoundsOptions, FitViewOptions, type GetBezierPathParams, type GetSmoothStepPathParams, type GetStraightPathParams, GroupNode, Handle, type HandleConnection, InputNode, type InternalNode, IsValidConnection, KeyDefinition, KeyDefinitionObject, KeyModifier, Marker, MarkerDefinition, MarkerType, MiniMap, type Node, type NodeConnection, NodeEvents, NodeGraph, type NodeOrigin, type NodeProps, NodeRenderer, NodeResizer, NodeSelection, NodeSelectionEvents, NodeToolbar, NodeToolbarProps, type NodeTypes, NodeWrapper, OnBeforeDelete, OnBeforeEdgeConnect, OnBeforeReconnect, type OnConnect, type OnConnectEnd, type OnConnectStart, type OnConnectStartParams, OnDelete, OnEdgeConnect, OnEdgeCreate, type OnError, type OnMove, type OnMoveEnd, type OnMoveStart, type OnReconnect, type OnReconnectEnd, type OnReconnectStart, type OnResize, type OnResizeEnd, type OnResizeStart, OnSelectionChange, OnSelectionDrag, OutputNode, PanOnScrollMode, Pane, PaneEvents, Panel, type PanelPosition, Position$1 as Position, type ProOptions, type Rect, ResizeControl, ResizeControlVariant, type ResizeDragEvent, type ResizeParams, type ResizeParamsWithDirection, Selection, SelectionMode, type SelectionRect, type SetCenter, type SetCenterOptions, type SetViewport, ShortcutModifier, ShortcutModifierDefinition, type ShouldResize, SmoothStepEdge, SmoothStepEdgeInternal, type SmoothStepEdgeProps, type SmoothStepPathOptions, type SnapGrid, SolidFlow, SolidFlowProvider, StepEdge, StepEdgeInternal, type StepEdgeProps, StraightEdge, StraightEdgeInternal, type StraightEdgeProps, type Transform, Viewport, type ViewportHelperFunctionOptions, ViewportPortal, type XYPosition, type XYZPosition, Zoom, addEdge, createEdgeStore, createNodeStore, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, useColorMode, useConnection, useEdges, useHandleEdgeSelect, useInternalNode, useNodeConnections, useNodes, useNodesData, useNodesInitialized, useSolidFlow, useUpdateNodeInternals, useViewport, useViewportInitialized };
|
|
1649
|
+
export { type Align, type AriaLabelConfig, Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, type BezierPathOptions, type Box, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, type ColorMode, type ColorModeClass, type Connection, ConnectionData, ConnectionLine, type ConnectionLineComponentProps, ConnectionLineType, ConnectionMode, type ConnectionsRecord, ControlButton, type ControlLinePosition, type ControlPosition, Controls, type CoordinateExtent, type DefaultEdgeOptions, DefaultNode, DeleteEvents, type Dimensions, type Edge, EdgeConnection, EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeMarker, type EdgeMarkerType, type EdgeProps, EdgeReconnectAnchor, EdgeReconnectEvents, EdgeRenderer, EdgeToolbar, EdgeToolbarProps, type EdgeTypes, EdgeWrapper, type FitBounds, type FitBoundsOptions, FitViewOptions, type FlowCommands, type FlowSelection, type FlowState, type GetBezierPathParams, type GetSmoothStepPathParams, type GetStraightPathParams, GroupNode, Handle, type HandleConnection, InputNode, type InternalNode, IsValidConnection, KeyDefinition, KeyDefinitionObject, KeyModifier, Marker, MarkerDefinition, MarkerType, MiniMap, type Node, type NodeConnection, NodeEvents, NodeGraph, type NodeOrigin, type NodeProps, NodeRenderer, NodeResizer, NodeSelection, NodeSelectionEvents, NodeToolbar, NodeToolbarProps, type NodeTypes, NodeWrapper, OnBeforeDelete, OnBeforeEdgeConnect, OnBeforeReconnect, type OnConnect, type OnConnectEnd, type OnConnectStart, type OnConnectStartParams, OnDelete, OnEdgeConnect, OnEdgeCreate, type OnError, type OnMove, type OnMoveEnd, type OnMoveStart, type OnReconnect, type OnReconnectEnd, type OnReconnectStart, type OnResize, type OnResizeEnd, type OnResizeStart, OnSelectionChange, OnSelectionDrag, OutputNode, PanOnScrollMode, Pane, PaneEvents, Panel, type PanelPosition, Position$1 as Position, type ProOptions, type Rect, ResizeControl, ResizeControlVariant, type ResizeDragEvent, type ResizeParams, type ResizeParamsWithDirection, Selection, SelectionMode, type SelectionRect, type SetCenter, type SetCenterOptions, type SetViewport, ShortcutModifier, ShortcutModifierDefinition, type ShouldResize, SmoothStepEdge, SmoothStepEdgeInternal, type SmoothStepEdgeProps, type SmoothStepPathOptions, type SnapGrid, SolidFlow, SolidFlowProvider, StepEdge, StepEdgeInternal, type StepEdgeProps, StraightEdge, StraightEdgeInternal, type StraightEdgeProps, type Transform, UseSolidFlowReturn, Viewport, type ViewportHelperFunctionOptions, ViewportPortal, type XYPosition, type XYZPosition, Zoom, addEdge, connectionKey, createEdgeStore, createNodeStore, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, useColorMode, useConnection, useEdges, useHandleEdgeSelect, useInternalNode, useNodeConnections, useNodes, useNodesData, useNodesInitialized, useSolidFlow, useUpdateNodeInternals, useViewport, useViewportInitialized };
|