@fragiola/flow-react 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1678 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
+ import { a as useIsomorphicLayoutEffect, c as EdgeLabelLayerContext, d as eraseModel, f as typedEngine, g as usePartNodeId, h as useFlowContext, i as useFlowValue, l as FlowContext, m as useEdgeId, n as useRenderElement, o as shallowEqual, p as typedModel, r as sameValue, s as EdgeContext, t as attributeProps, u as NodeContext } from "./use-render-Dfsx9V4b.js";
3
+ import { ENGINE_EVENT_CALLBACKS, createFlowEngine, createFlowModel, edgesLayerAttributes, flag, partAttributes, sameFlowValue, staticGeometry, watchKeyPress } from "@fragiola/flow";
4
+ import * as React from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { createPortal } from "react-dom";
7
+ export * from "@fragiola/flow";
8
+ // src/hooks/create-flow-ref.ts
9
+ const slots = /* @__PURE__ */ new WeakMap();
10
+ function slotOf(ref) {
11
+ const slot = slots.get(ref);
12
+ if (!slot) throw new Error("not a flow ref: create it with createFlowRef");
13
+ return slot;
14
+ }
15
+ /**
16
+ * Creates a flow ref outside React (a module, a test). In a component, `useFlowRef` keeps one and
17
+ * re-renders when it attaches.
18
+ *
19
+ * ```tsx
20
+ * const flow = createFlowRef<Types, typeof features>();
21
+ * <Flow.Root flowRef={flow} features={features} defaultNodes={nodes}>…</Flow.Root>;
22
+ * flow.current?.engine.run("fit-view");
23
+ * ```
24
+ */
25
+ function createFlowRef() {
26
+ const slot = {
27
+ value: null,
28
+ listeners: /* @__PURE__ */ new Set()
29
+ };
30
+ const ref = Object.freeze({ get current() {
31
+ return slot.value;
32
+ } });
33
+ slots.set(ref, slot);
34
+ return ref;
35
+ }
36
+ /** @internal what `Flow.Root` calls: attaches (or, with `null`, detaches) its model and engine */
37
+ function setFlowRef(ref, value) {
38
+ const slot = slotOf(ref);
39
+ if (slot.value === value) return;
40
+ slot.value = value;
41
+ for (const listener of [...slot.listeners]) listener();
42
+ }
43
+ /** @internal calls `listener` when the ref attaches or detaches; returns its remover */
44
+ function subscribeFlowRef(ref, listener) {
45
+ const { listeners } = slotOf(ref);
46
+ listeners.add(listener);
47
+ return () => {
48
+ listeners.delete(listener);
49
+ };
50
+ }
51
+ // src/hooks/use-connection.ts
52
+ /**
53
+ * The connection being drawn from a handle (`connection()`), or null, re-rendering the component
54
+ * when it changes: where it starts and ends, the handle it would end at and whether the drop
55
+ * would be accepted (`status`).
56
+ */
57
+ function useConnection() {
58
+ const { model, engine } = useFlowContext("useConnection");
59
+ return useFlowValue(model, engine, () => engine?.get("connection") ?? null, (a, b) => a === b || a !== null && b !== null && a.path === b.path && a.status === b.status && a.to === b.to && a.from === b.from && a.toSide === b.toSide);
60
+ }
61
+ // src/hooks/use-edge.ts
62
+ /** Two edge paths that draw the same (`edge-path-by` builds a new one at every read). */
63
+ function sameEdgePath(a, b) {
64
+ if (a === b) return true;
65
+ if (!a || !b) return false;
66
+ return a.path === b.path && a.sourceSide === b.sourceSide && a.targetSide === b.targetSide && a.label.x === b.label.x && a.label.y === b.label.y && a.source.x === b.source.x && a.source.y === b.source.y && a.target.x === b.target.x && a.target.y === b.target.y;
67
+ }
68
+ /** An edge's state and the props of its element, for an edge drawn by hand (`Flow.Edge` uses it). */
69
+ function useEdge(edge) {
70
+ const { model, engine, staticGeometry } = useFlowContext("useEdge");
71
+ const edgeId = edge.id;
72
+ const view = useFlowValue(model, engine, () => engine ? {
73
+ attributes: engine.adapter.attributes("edge", { edgeId }),
74
+ path: engine.get("edge-path-by", { edgeId }),
75
+ reconnecting: engine.is("edge-reconnecting", { edgeId }),
76
+ focusable: engine.is("edge-focusable", { edgeId })
77
+ } : {
78
+ attributes: staticEdgeAttributes("edge", edge),
79
+ path: staticGeometry?.edgePaths[edgeId],
80
+ reconnecting: false,
81
+ focusable: false
82
+ }, (a, b) => a.reconnecting === b.reconnecting && a.focusable === b.focusable && sameEdgePath(a.path, b.path) && shallowEqual(a.attributes, b.attributes), "entity", {
83
+ kind: "edge",
84
+ id: edgeId
85
+ });
86
+ const { attributes } = view;
87
+ return {
88
+ state: {
89
+ edgeId,
90
+ edge,
91
+ path: view.path,
92
+ selected: attributes["data-selected"] !== void 0,
93
+ reconnecting: view.reconnecting,
94
+ focusable: view.focusable,
95
+ attributes
96
+ },
97
+ props: {
98
+ ...attributes,
99
+ tabIndex: view.focusable ? 0 : void 0
100
+ }
101
+ };
102
+ }
103
+ /**
104
+ * @internal an edge part's attributes before the engine (the server render, the first client
105
+ * render): its part, its id, `data-selected` and `data-animated` from the document, as the
106
+ * engine gives them
107
+ */
108
+ function staticEdgeAttributes(part, edge) {
109
+ return {
110
+ ...partAttributes(part, edge.id),
111
+ "data-selected": flag(edge.selected === true),
112
+ "data-animated": flag(edge.animated === true)
113
+ };
114
+ }
115
+ /**
116
+ * @internal an edge's path, re-rendering when it changes (`Flow.EdgePath`, `Flow.EdgeLabel`): the
117
+ * engine's, or the static geometry's before the engine
118
+ */
119
+ function useEdgePath(edgeId) {
120
+ const { model, engine, staticGeometry } = useFlowContext("EdgePath");
121
+ return useFlowValue(model, engine, () => engine ? engine.get("edge-path-by", { edgeId }) : staticGeometry?.edgePaths[edgeId], sameEdgePath, "entity", {
122
+ kind: "edge",
123
+ id: edgeId
124
+ });
125
+ }
126
+ // src/hooks/use-edges.ts
127
+ /** Every edge of the enclosing `Flow.Root`, in drawing order, re-rendering on every change of one. */
128
+ function useEdges() {
129
+ const { model } = useFlowContext("useEdges");
130
+ return useFlowValue(model, null, () => model.get("all-edges"), Object.is);
131
+ }
132
+ // src/hooks/use-flow.ts
133
+ /**
134
+ * The model and the engine of the enclosing `Flow.Root`. Pass the registry and the features as the
135
+ * type arguments (`useFlow<Types, typeof features>()`): a child cannot infer them through context.
136
+ */
137
+ function useFlow() {
138
+ const context = useFlowContext("useFlow");
139
+ return {
140
+ model: typedModel(context.model),
141
+ engine: typedEngine(context.publicEngine)
142
+ };
143
+ }
144
+ // src/hooks/use-flow-ref.ts
145
+ /**
146
+ * A flow ref kept by this component, which re-renders when the `Flow.Root` it is given to mounts
147
+ * or unmounts: read `flow.current` in render (a toolbar next to the flow) or in handlers.
148
+ *
149
+ * ```tsx
150
+ * const flow = useFlowRef<Types>();
151
+ * <button type="button" onClick={() => flow.current?.engine.run("fit-view")}>Fit</button>
152
+ * <Flow.Root flowRef={flow} defaultNodes={nodes}>…</Flow.Root>
153
+ * ```
154
+ */
155
+ function useFlowRef() {
156
+ const [ref] = React.useState(() => createFlowRef());
157
+ const subscribe = React.useCallback((onChange) => subscribeFlowRef(ref, onChange), [ref]);
158
+ const snapshot = () => ref.current;
159
+ React.useSyncExternalStore(subscribe, snapshot, () => null);
160
+ return ref;
161
+ }
162
+ // src/hooks/use-flow-store.ts
163
+ /**
164
+ * A value selected from the model and the engine of the enclosing `Flow.Root`, re-rendering the
165
+ * component only when it changes (`equal`, default `Object.is`): `selector` runs again on every
166
+ * change of the model and every view change of the engine (a measurement, the viewport, a
167
+ * gesture), and on every render. Pass the registry and the features as the type arguments after
168
+ * the selected value's (`useFlowStore<number, Types, typeof features>(…)`). Keep a selector that
169
+ * builds an object or an array with an `equal` that compares it (`sameFlowValue`), or it
170
+ * re-renders on every change.
171
+ */
172
+ function useFlowStore(selector, equal = Object.is) {
173
+ const { model, engine, publicEngine } = useFlowContext("useFlowStore");
174
+ return useFlowValue(model, engine, () => selector({
175
+ model: typedModel(model),
176
+ engine: typedEngine(publicEngine)
177
+ }), equal);
178
+ }
179
+ // src/hooks/use-handle.ts
180
+ /**
181
+ * A handle's state and the props of its element, for a handle rendered by hand (`Flow.Handle`
182
+ * uses it): registered with the engine, which measures its centre relative to its node.
183
+ */
184
+ function useHandle(options) {
185
+ const { model, engine } = useFlowContext("useHandle");
186
+ const nodeId = usePartNodeId("Handle", options.nodeId);
187
+ const { type, side, handleId, connectable, connectableStart, connectableEnd } = options;
188
+ const registration = React.useMemo(() => ({
189
+ nodeId,
190
+ handleId,
191
+ type,
192
+ side,
193
+ connectable,
194
+ connectableStart,
195
+ connectableEnd
196
+ }), [
197
+ nodeId,
198
+ handleId,
199
+ type,
200
+ side,
201
+ connectable,
202
+ connectableStart,
203
+ connectableEnd
204
+ ]);
205
+ const attributes = useFlowValue(model, engine, () => engine ? engine.adapter.attributes("handle", registration) : {
206
+ ...partAttributes("handle", handleId),
207
+ "data-handle-type": type,
208
+ "data-side": side
209
+ }, sameValue, "entity");
210
+ const ref = React.useCallback((element) => {
211
+ if (!engine || !element) return;
212
+ engine.adapter.registerHandle(registration, element);
213
+ return () => engine.adapter.registerHandle(registration, null);
214
+ }, [engine, registration]);
215
+ return {
216
+ state: {
217
+ nodeId,
218
+ handleId,
219
+ type,
220
+ side,
221
+ connectable: attributes["data-connectable"] !== void 0,
222
+ connectableStart: attributes["data-connectable-start"] !== void 0,
223
+ connectableEnd: attributes["data-connectable-end"] !== void 0,
224
+ connecting: attributes["data-connecting"] !== void 0,
225
+ valid: attributes["data-valid"] !== void 0,
226
+ invalid: attributes["data-invalid"] !== void 0,
227
+ attributes
228
+ },
229
+ props: {
230
+ ...attributeProps(attributes),
231
+ ref
232
+ }
233
+ };
234
+ }
235
+ // src/hooks/use-internal-node.ts
236
+ /**
237
+ * A node as the engine knows it on screen (`internal-node-by`): the document's node, its absolute
238
+ * position and box (`nodeOrigin` applied), whether its size is known, its z-index and its handles
239
+ * with their centres; undefined while it does not exist or before the root is mounted. It
240
+ * re-renders the component only when one of them changes (compared by value): a pan does not.
241
+ */
242
+ function useInternalNode(nodeId) {
243
+ const { model, engine } = useFlowContext("useInternalNode");
244
+ return useFlowValue(model, engine, () => engine?.get("internal-node-by", { nodeId }), sameFlowValue);
245
+ }
246
+ // src/hooks/use-key-press.ts
247
+ /**
248
+ * Whether a key, or a combo of keys, is held, re-rendering the component when that changes.
249
+ * `keys` is a combo or several (any of them): key names joined by `+`, held at once (`"Shift"`,
250
+ * `"Meta+s"`, `["Meta+z", "Control+z"]`); a name is a `KeyboardEvent.key` or `.code`, without case
251
+ * (`watchKeyPress`). The keys are read on `target`, by default the window of the enclosing
252
+ * `Flow.Root`'s element (never the global one): false before the root is mounted, or outside a
253
+ * root without a `target`.
254
+ */
255
+ function useKeyPress(keys, options = {}) {
256
+ const rootElement = React.useContext(FlowContext)?.rootElement ?? null;
257
+ const target = options.target === void 0 ? rootElement?.ownerDocument.defaultView ?? null : options.target;
258
+ const [pressed, setPressed] = React.useState(false);
259
+ const combos = JSON.stringify(typeof keys === "string" ? [keys] : keys);
260
+ React.useEffect(() => {
261
+ if (!target) return;
262
+ const stop = watchKeyPress(target, JSON.parse(combos), setPressed);
263
+ return () => {
264
+ stop();
265
+ setPressed(false);
266
+ };
267
+ }, [target, combos]);
268
+ return pressed;
269
+ }
270
+ // src/hooks/use-node.ts
271
+ /**
272
+ * A node's state and the props of its element, for a node rendered by hand (`Flow.Node` uses it).
273
+ * Spread `props` on the element (the engine resolves presses from its attributes).
274
+ */
275
+ function useNode(node) {
276
+ const { model, engine, staticGeometry } = useFlowContext("useNode");
277
+ const nodeId = node.id;
278
+ const view = useFlowValue(model, engine, () => {
279
+ if (!engine) {
280
+ const rect = staticGeometry?.nodeRects[nodeId];
281
+ const at = rect ? void 0 : model.get("absolute-position-by", { nodeId });
282
+ return {
283
+ attributes: {
284
+ ...partAttributes("node", nodeId),
285
+ "data-selected": flag(node.selected === true)
286
+ },
287
+ x: rect?.x ?? at?.x ?? node.position.x,
288
+ y: rect?.y ?? at?.y ?? node.position.y,
289
+ zIndex: staticGeometry?.nodeZIndexes[nodeId],
290
+ focusable: false
291
+ };
292
+ }
293
+ const rect = engine.get("node-rect-by", { nodeId });
294
+ return {
295
+ attributes: engine.adapter.attributes("node", { nodeId }),
296
+ x: rect?.x ?? node.position.x,
297
+ y: rect?.y ?? node.position.y,
298
+ zIndex: engine.get("node-z-index-by", { nodeId }),
299
+ focusable: engine.is("node-focusable", { nodeId })
300
+ };
301
+ }, sameValue, "entity", {
302
+ kind: "node",
303
+ id: nodeId
304
+ });
305
+ const ref = React.useCallback((element) => {
306
+ if (!engine || !element) return;
307
+ engine.adapter.registerNode(nodeId, element);
308
+ return () => engine.adapter.registerNode(nodeId, null);
309
+ }, [engine, nodeId]);
310
+ const { attributes } = view;
311
+ const style = {
312
+ position: "absolute",
313
+ top: 0,
314
+ left: 0,
315
+ transform: `translate(${view.x}px, ${view.y}px)`,
316
+ ...view.zIndex === void 0 ? {} : { zIndex: view.zIndex },
317
+ ...node.width === void 0 ? {} : { width: node.width },
318
+ ...node.height === void 0 ? {} : { height: node.height }
319
+ };
320
+ return {
321
+ state: {
322
+ nodeId,
323
+ node,
324
+ x: view.x,
325
+ y: view.y,
326
+ selected: attributes["data-selected"] !== void 0,
327
+ dragging: attributes["data-dragging"] !== void 0,
328
+ resizing: attributes["data-resizing"] !== void 0,
329
+ measured: attributes["data-measured"] !== void 0,
330
+ focusable: view.focusable,
331
+ attributes
332
+ },
333
+ props: {
334
+ ...attributes,
335
+ ref,
336
+ tabIndex: view.focusable ? 0 : void 0,
337
+ style
338
+ }
339
+ };
340
+ }
341
+ // src/hooks/use-node-connections.ts
342
+ /**
343
+ * The connections at a node (`node-connections-by`): each edge that starts or ends at it, as its
344
+ * `edgeId`, `source`, `sourceHandle`, `target` and `targetHandle`, in the document's order. It
345
+ * re-renders the component only when they change (an edge added, removed or reconnected there),
346
+ * not when a node moves or an edge's data changes.
347
+ */
348
+ function useNodeConnections(options = {}) {
349
+ const { model } = useFlowContext("useNodeConnections");
350
+ const enclosing = React.useContext(NodeContext)?.nodeId;
351
+ const nodeId = options.id ?? enclosing;
352
+ if (nodeId === void 0) throw new Error("useNodeConnections must be called inside Flow.Node (or be given an id)");
353
+ const { handleId, type } = options;
354
+ return useFlowValue(model, null, () => model.get("node-connections-by", {
355
+ nodeId,
356
+ handleId,
357
+ handleType: type
358
+ }), sameFlowValue);
359
+ }
360
+ // src/hooks/use-node-id.ts
361
+ /**
362
+ * The id of the node the component renders inside (`Flow.Node`), or null outside one: a custom
363
+ * node's piece reads its own node without being given its id.
364
+ */
365
+ function useNodeId() {
366
+ return React.useContext(NodeContext)?.nodeId ?? null;
367
+ }
368
+ // src/hooks/use-nodes.ts
369
+ /** Every node of the enclosing `Flow.Root`, in drawing order, re-rendering on every change of one. */
370
+ function useNodes() {
371
+ const { model } = useFlowContext("useNodes");
372
+ return useFlowValue(model, null, () => model.get("all-nodes"), Object.is);
373
+ }
374
+ // src/hooks/use-nodes-data.ts
375
+ function useNodesData(ids) {
376
+ const { model } = useFlowContext("useNodesData");
377
+ const one = typeof ids === "string";
378
+ const list = useFlowValue(model, null, () => model.get("nodes-data-by", { nodeIds: one ? [ids] : ids }), sameFlowValue);
379
+ return one ? list[0] ?? null : list;
380
+ }
381
+ // src/hooks/use-on-viewport-change.ts
382
+ /**
383
+ * Calls back on the viewport's changes of the enclosing `Flow.Root` (the engine's events),
384
+ * without re-rendering the component: `gesture` is true for a pan, the wheel, a pinch or auto-pan,
385
+ * false for an action. The latest callbacks are called.
386
+ */
387
+ function useOnViewportChange(options) {
388
+ const { engine } = useFlowContext("useOnViewportChange");
389
+ const latest = React.useRef(options);
390
+ latest.current = options;
391
+ React.useEffect(() => {
392
+ if (!engine) return;
393
+ return engine.subscribe((event) => {
394
+ const { onStart, onChange, onEnd } = latest.current;
395
+ if (event.type === "viewport-change-start") onStart?.(event.viewport, event.gesture);
396
+ else if (event.type === "viewport-change") onChange?.(event.viewport, event.gesture);
397
+ else if (event.type === "viewport-change-end") onEnd?.(event.viewport, event.gesture);
398
+ });
399
+ }, [engine]);
400
+ }
401
+ // src/hooks/use-selection.ts
402
+ const NONE = Object.freeze([]);
403
+ /**
404
+ * The selected nodes and edges of the enclosing `Flow.Root` (`selection()`; none without it),
405
+ * re-rendering the component when they change: a panel showing the selection, a Delete button.
406
+ */
407
+ function useSelection() {
408
+ const { model } = useFlowContext("useSelection");
409
+ return useFlowValue(model, null, () => ({
410
+ nodes: model.get("selected-nodes") ?? NONE,
411
+ edges: model.get("selected-edges") ?? NONE
412
+ }), (a, b) => a.nodes.length === b.nodes.length && a.edges.length === b.edges.length && a.nodes.every((node, i) => node === b.nodes[i]) && a.edges.every((edge, i) => edge === b.edges[i]));
413
+ }
414
+ // src/hooks/use-viewport.ts
415
+ /**
416
+ * The viewport of the enclosing `Flow.Root` (`{ x, y, zoom }`), re-rendering the component when it
417
+ * changes: a zoom level readout, a control's state. Change it with `engine.run("set-viewport")`.
418
+ */
419
+ function useViewport() {
420
+ const { model, engine, publicEngine } = useFlowContext("useViewport");
421
+ return useFlowValue(model, engine, () => publicEngine.get("viewport"));
422
+ }
423
+ // src/components/background.tsx
424
+ const BACKGROUND_STYLE = {
425
+ position: "absolute",
426
+ top: 0,
427
+ left: 0,
428
+ width: "100%",
429
+ height: "100%",
430
+ pointerEvents: "none"
431
+ };
432
+ /**
433
+ * The flow's background (`data-flow-part="background"`): an SVG pattern of dots, lines or crosses
434
+ * that pans and zooms with the viewport (`background-pattern`), inside `Flow.Root` before
435
+ * `Flow.Viewport`. The marks are drawn in `currentColor`: set the `color` (and the background
436
+ * itself) in your style.
437
+ */
438
+ function Background(props) {
439
+ const { variant, gap, size, offset, ...rest } = props;
440
+ const { model, engine } = useFlowContext("Background");
441
+ const pattern = useFlowValue(model, engine, () => engine ? engine.get("background-pattern", {
442
+ variant,
443
+ gap,
444
+ size,
445
+ offset
446
+ }) : void 0);
447
+ const id = `flow-background-${React.useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
448
+ const tile = pattern;
449
+ return useRenderElement("svg", rest, {
450
+ state: { pattern: tile ?? EMPTY_PATTERN },
451
+ props: {
452
+ ...partAttributes("background"),
453
+ children: tile ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("pattern", {
454
+ "data-flow-part": "background-pattern",
455
+ id,
456
+ patternUnits: "userSpaceOnUse",
457
+ x: tile.x,
458
+ y: tile.y,
459
+ width: tile.width,
460
+ height: tile.height,
461
+ children: tile.dot ? /* @__PURE__ */ jsx("circle", {
462
+ "data-flow-part": "background-mark",
463
+ cx: tile.dot.cx,
464
+ cy: tile.dot.cy,
465
+ r: tile.dot.r,
466
+ fill: "currentColor"
467
+ }) : /* @__PURE__ */ jsx("path", {
468
+ "data-flow-part": "background-mark",
469
+ d: tile.path,
470
+ fill: "none",
471
+ stroke: "currentColor",
472
+ strokeWidth: tile.strokeWidth
473
+ })
474
+ }), /* @__PURE__ */ jsx("rect", {
475
+ "data-flow-part": "background-fill",
476
+ width: "100%",
477
+ height: "100%",
478
+ fill: `url(#${id})`
479
+ })] }) : null
480
+ },
481
+ style: BACKGROUND_STYLE
482
+ });
483
+ }
484
+ const EMPTY_PATTERN = Object.freeze({
485
+ variant: "dots",
486
+ x: 0,
487
+ y: 0,
488
+ width: 0,
489
+ height: 0,
490
+ dot: void 0,
491
+ path: void 0,
492
+ strokeWidth: 0
493
+ });
494
+ // src/components/connection-line.tsx
495
+ const LINE_STYLE = {
496
+ position: "absolute",
497
+ top: 0,
498
+ left: 0,
499
+ width: "100%",
500
+ height: "100%",
501
+ overflow: "visible",
502
+ pointerEvents: "none"
503
+ };
504
+ /**
505
+ * The connection being drawn (`data-flow-part="connection-line"`, `data-valid` / `data-invalid`,
506
+ * `connection()`): an SVG inside `Flow.Viewport`, rendered only while a connection is under way.
507
+ */
508
+ function ConnectionLine(props) {
509
+ const connection = useConnection();
510
+ if (!connection) return null;
511
+ return /* @__PURE__ */ jsx(ConnectionLineElement, {
512
+ ...props,
513
+ connection
514
+ });
515
+ }
516
+ function ConnectionLineElement(props) {
517
+ const { connection, children, ...rest } = props;
518
+ const { model, engine } = useFlowContext("ConnectionLine");
519
+ const attributes = useFlowValue(model, engine, () => engine?.adapter.attributes("connection-line") ?? {});
520
+ const state = {
521
+ connection,
522
+ valid: attributes["data-valid"] !== void 0,
523
+ invalid: attributes["data-invalid"] !== void 0
524
+ };
525
+ return useRenderElement("svg", rest, {
526
+ state,
527
+ props: {
528
+ ...attributes,
529
+ "data-flow-part": "connection-line",
530
+ children: children ? children(connection) : /* @__PURE__ */ jsx("path", {
531
+ "data-flow-part": "connection-path",
532
+ d: connection.path,
533
+ fill: "none"
534
+ })
535
+ },
536
+ style: LINE_STYLE
537
+ });
538
+ }
539
+ // src/components/controls.tsx
540
+ /**
541
+ * A group of the viewport's buttons (`data-flow-part="controls"`): `Flow.ZoomIn`, `Flow.ZoomOut`,
542
+ * `Flow.FitView`, `Flow.ToggleInteractive`, or your own. Inside `Flow.Root`, outside
543
+ * `Flow.Viewport`; presses and the wheel over it are left to it. Place it with your style.
544
+ */
545
+ function Controls(props) {
546
+ const { children, ...rest } = props;
547
+ return useRenderElement("div", rest, {
548
+ state: {},
549
+ props: {
550
+ ...partAttributes("controls"),
551
+ children
552
+ }
553
+ });
554
+ }
555
+ // src/components/edge-path.tsx
556
+ /**
557
+ * An edge's path (`data-flow-part="edge-path"`): an SVG `<path>` whose `d` is the engine's
558
+ * (`edge-path-by`, D9), unfilled. A `d` of your own draws an app type (from `state.path`'s ends).
559
+ * Several may share an edge: a wide transparent one is a bigger press target.
560
+ */
561
+ function EdgePath$1(props) {
562
+ const { edgeId: edgeIdProp, ...rest } = props;
563
+ const edgeId = useEdgeId("EdgePath", edgeIdProp);
564
+ const { model, engine } = useFlowContext("EdgePath");
565
+ const path = useEdgePath(edgeId);
566
+ const attributes = useFlowValue(model, engine, () => engine ? engine.adapter.attributes("edge-path", { edgeId }) : staticEdgeAttributes("edge-path", model.get("edge-by", { id: edgeId }) ?? { id: edgeId }), sameValue, "entity", {
567
+ kind: "edge",
568
+ id: edgeId
569
+ });
570
+ if (!path || !attributes) return null;
571
+ return /* @__PURE__ */ jsx(EdgePathElement, {
572
+ ...rest,
573
+ state: {
574
+ edgeId,
575
+ path,
576
+ selected: attributes["data-selected"] !== void 0
577
+ },
578
+ attributes
579
+ });
580
+ }
581
+ function EdgePathElement(props) {
582
+ const { state, attributes, ...rest } = props;
583
+ return useRenderElement("path", rest, {
584
+ state,
585
+ props: {
586
+ ...attributes,
587
+ d: state.path.path,
588
+ fill: "none"
589
+ }
590
+ });
591
+ }
592
+ // src/components/edge.tsx
593
+ const EDGE_STYLE = { pointerEvents: "visibleStroke" };
594
+ /**
595
+ * One edge (`data-flow-part="edge"`, `data-flow-id`): an SVG group inside `Flow.Edges`, drawn once
596
+ * both its nodes have a size. It renders its children (`Flow.EdgePath` by default,
597
+ * `Flow.EdgeLabel`, `Flow.ReconnectAnchor`); a press on its stroke selects it (`selection()`).
598
+ */
599
+ function Edge(props) {
600
+ const { edge, children, ...rest } = props;
601
+ const { state, props: own } = useEdge(edge);
602
+ const { engine } = useFlowContext("Edge");
603
+ const context = React.useMemo(() => ({ edgeId: edge.id }), [edge.id]);
604
+ const ref = React.useCallback((element) => {
605
+ if (engine && element) engine.adapter.refocus(element);
606
+ }, [engine]);
607
+ const element = useRenderElement("g", rest, {
608
+ state,
609
+ ref,
610
+ props: {
611
+ ...own,
612
+ children: children ?? /* @__PURE__ */ jsx(EdgePath$1, {})
613
+ },
614
+ style: EDGE_STYLE
615
+ });
616
+ if (!state.path) return null;
617
+ return /* @__PURE__ */ jsx(EdgeContext.Provider, {
618
+ value: context,
619
+ children: element
620
+ });
621
+ }
622
+ // src/components/edge-label.tsx
623
+ /**
624
+ * An edge's label (`data-flow-part="edge-label"`): HTML, centred on the path's label point in
625
+ * flow coordinates, in the HTML layer of `Flow.Edges` (a portal: SVG holds no HTML). It renders
626
+ * only its children; a press on it selects its edge.
627
+ */
628
+ function EdgeLabel(props) {
629
+ const { edgeId: edgeIdProp, ...rest } = props;
630
+ const edgeId = useEdgeId("EdgeLabel", edgeIdProp);
631
+ const layer = React.useContext(EdgeLabelLayerContext);
632
+ const { model, engine } = useFlowContext("EdgeLabel");
633
+ const path = useEdgePath(edgeId);
634
+ const attributes = useFlowValue(model, engine, () => engine ? engine.adapter.attributes("edge-label", { edgeId }) : staticEdgeAttributes("edge-label", model.get("edge-by", { id: edgeId }) ?? { id: edgeId }), sameValue, "entity", {
635
+ kind: "edge",
636
+ id: edgeId
637
+ });
638
+ if (!path || !attributes || !layer) return null;
639
+ return createPortal(/* @__PURE__ */ jsx(EdgeLabelElement, {
640
+ ...rest,
641
+ state: {
642
+ edgeId,
643
+ path,
644
+ selected: attributes["data-selected"] !== void 0
645
+ },
646
+ attributes
647
+ }), layer);
648
+ }
649
+ function EdgeLabelElement(props) {
650
+ const { state, attributes, children, ...rest } = props;
651
+ const { x, y } = state.path.label;
652
+ return useRenderElement("div", rest, {
653
+ state,
654
+ props: {
655
+ ...attributes,
656
+ children
657
+ },
658
+ style: {
659
+ position: "absolute",
660
+ top: 0,
661
+ left: 0,
662
+ transform: `translate(${x}px, ${y}px) translate(-50%, -50%)`,
663
+ pointerEvents: "all"
664
+ }
665
+ });
666
+ }
667
+ // src/components/edge-toolbar.tsx
668
+ /**
669
+ * A toolbar on an edge (`data-flow-part="toolbar"`, `data-flow-id` its edge's id), outside the
670
+ * zoom: rendered in `Flow.Root` (a portal), centred at the point `edge-toolbar-by` gives (the
671
+ * edge's label point or one of its ends), so it keeps its size at any zoom. Presses and the wheel
672
+ * over it are left to it. It renders only its children (your buttons).
673
+ */
674
+ function EdgeToolbar(props) {
675
+ const { edgeId: edgeIdProp, position = "label", point, offset, alignX, alignY, open, ...rest } = props;
676
+ const edgeId = useEdgeId("EdgeToolbar", edgeIdProp);
677
+ const { model, engine, rootElement } = useFlowContext("EdgeToolbar");
678
+ const view = useFlowValue(model, engine, () => {
679
+ if (!engine) return void 0;
680
+ if (!(open ?? model.is("edge-selected", { edgeId }))) return void 0;
681
+ const anchor = engine.get("edge-toolbar-by", {
682
+ edgeId,
683
+ position,
684
+ point,
685
+ offset,
686
+ alignX,
687
+ alignY
688
+ });
689
+ return anchor ? {
690
+ anchor,
691
+ attributes: engine.adapter.attributes("toolbar", { edgeId })
692
+ } : void 0;
693
+ });
694
+ if (!view || !rootElement) return null;
695
+ return createPortal(/* @__PURE__ */ jsx(EdgeToolbarElement, {
696
+ ...rest,
697
+ state: {
698
+ edgeId,
699
+ position,
700
+ anchor: view.anchor
701
+ },
702
+ attributes: view.attributes
703
+ }), rootElement);
704
+ }
705
+ function EdgeToolbarElement(props) {
706
+ const { state, attributes, children, ...rest } = props;
707
+ const { x, y, anchorX, anchorY } = state.anchor;
708
+ return useRenderElement("div", rest, {
709
+ state,
710
+ props: {
711
+ ...attributes,
712
+ children
713
+ },
714
+ style: {
715
+ position: "absolute",
716
+ top: 0,
717
+ left: 0,
718
+ transform: `translate(${x}px, ${y}px) translate(${-anchorX * 100}%, ${-anchorY * 100}%)`
719
+ }
720
+ });
721
+ }
722
+ // src/components/edges.tsx
723
+ const LAYER_STYLE = {
724
+ position: "absolute",
725
+ top: 0,
726
+ left: 0,
727
+ width: "100%",
728
+ height: "100%",
729
+ overflow: "visible",
730
+ pointerEvents: "none"
731
+ };
732
+ const NO_EDGES = Object.freeze([]);
733
+ const EdgeSlot = React.memo(function EdgeSlot({ edge, render }) {
734
+ return render(edge);
735
+ });
736
+ function sameLevels(a, b) {
737
+ return a.length === b.length && a.every((level, i) => {
738
+ const other = b[i];
739
+ return level.level === other.level && level.zIndex === other.zIndex && (level.attributes === other.attributes || level.attributes !== void 0 && other.attributes !== void 0 && shallowEqual(level.attributes, other.attributes)) && level.edges.length === other.edges.length && level.edges.every((edge, j) => edge === other.edges[j]);
740
+ });
741
+ }
742
+ function EdgeList({ edges, render }) {
743
+ return /* @__PURE__ */ jsx("svg", {
744
+ ...partAttributes("edges"),
745
+ style: LAYER_STYLE,
746
+ children: edges.map((edge) => /* @__PURE__ */ jsx(EdgeSlot, {
747
+ edge,
748
+ render
749
+ }, edge.id))
750
+ });
751
+ }
752
+ function LevelLayer({ level, render }) {
753
+ const [layer, setLayer] = React.useState(null);
754
+ return /* @__PURE__ */ jsx(EdgeLabelLayerContext.Provider, {
755
+ value: layer,
756
+ children: /* @__PURE__ */ jsx("div", {
757
+ ...level.attributes,
758
+ ref: setLayer,
759
+ style: {
760
+ ...LAYER_STYLE,
761
+ zIndex: level.zIndex
762
+ },
763
+ children: /* @__PURE__ */ jsx(EdgeList, {
764
+ edges: level.edges,
765
+ render
766
+ })
767
+ })
768
+ });
769
+ }
770
+ /**
771
+ * The layer of the edges (`data-flow-part="edges"`), inside `Flow.Viewport`, before `Flow.Nodes`:
772
+ * an SVG (`data-flow-part="edges"` too) where `children` draws each edge, once both its nodes have
773
+ * a size, in the engine's drawing order (`drawn-edges`: by `zIndex`), and the HTML layer edge
774
+ * labels go to. When an edge stands above some node (`render-layers`: a selected edge with
775
+ * `zIndexMode` `"auto"`, a high `zIndex`), each render level gets a wrapper of its own
776
+ * (`data-flow-part="edges-layer"`, `data-level`, the level's `z-index`) holding its SVG and its
777
+ * labels. Before the engine (the server render, the first client render) it draws the document's
778
+ * static geometry (with `onlyRenderVisible`, no edge: the view is not known yet). It lets presses
779
+ * through to the pane; the edges' own parts take them.
780
+ */
781
+ function Edges(props) {
782
+ const { children, ...rest } = props;
783
+ const { model, engine, staticGeometry, onlyRenderVisible } = useFlowContext("Edges");
784
+ const levels = useFlowValue(model, engine, () => {
785
+ const layers = engine ? engine.get("render-layers") : staticGeometry?.layers ?? [];
786
+ const layered = layers.length > 1;
787
+ const none = !engine && onlyRenderVisible;
788
+ return layers.map((layer) => ({
789
+ level: layer.level,
790
+ zIndex: layer.zIndex,
791
+ attributes: !layered ? void 0 : engine ? engine.adapter.attributes("edges-layer", { level: layer.level }) : edgesLayerAttributes(layer.level),
792
+ edges: none ? NO_EDGES : layer.edgeIds.flatMap((id) => {
793
+ const edge = model.get("edge-by", { id });
794
+ return edge ? [edge] : [];
795
+ })
796
+ }));
797
+ }, sameLevels);
798
+ const [layer, setLayer] = React.useState(null);
799
+ const render = children;
800
+ const count = levels.reduce((sum, level) => sum + level.edges.length, 0);
801
+ const element = useRenderElement("div", rest, {
802
+ state: { count },
803
+ ref: setLayer,
804
+ props: {
805
+ ...partAttributes("edges"),
806
+ children: levels.length > 1 ? levels.map((level) => /* @__PURE__ */ jsx(LevelLayer, {
807
+ level,
808
+ render
809
+ }, level.level)) : /* @__PURE__ */ jsx(EdgeList, {
810
+ edges: levels[0]?.edges ?? [],
811
+ render
812
+ })
813
+ },
814
+ style: LAYER_STYLE
815
+ });
816
+ return /* @__PURE__ */ jsx(EdgeLabelLayerContext.Provider, {
817
+ value: layer,
818
+ children: element
819
+ });
820
+ }
821
+ // src/hooks/use-control-button.ts
822
+ /** @internal a control button's state and own props: it runs `action` when clicked */
823
+ function useControlButton(part, action, payload, disabledProp) {
824
+ const { model, engine } = useFlowContext(part);
825
+ const allowed = useFlowValue(model, engine, () => engine ? engine.can(action, payload()) : false);
826
+ const disabled = disabledProp === true || !allowed;
827
+ return {
828
+ state: { disabled },
829
+ props: {
830
+ type: "button",
831
+ "data-flow-part": partName(part),
832
+ "data-disabled": disabled ? "" : void 0,
833
+ disabled,
834
+ onClick: (_event) => {
835
+ engine?.run(action, payload());
836
+ }
837
+ }
838
+ };
839
+ }
840
+ /** @internal a control's payload: its `duration` when given (an absent one is the engine's default) */
841
+ function durationPayload(duration) {
842
+ return givenPayload({ duration });
843
+ }
844
+ /** @internal a control's payload: the fields its props give (an absent one is the engine's default) */
845
+ function givenPayload(fields) {
846
+ return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== void 0));
847
+ }
848
+ /** `ZoomIn` → `zoom-in`. */
849
+ function partName(part) {
850
+ return part.replace(/[A-Z]/g, (letter, at) => `${at === 0 ? "" : "-"}${letter.toLowerCase()}`);
851
+ }
852
+ // src/components/fit-view.tsx
853
+ /**
854
+ * A button (`data-flow-part="fit-view"`): Fits every node in the root, or its `nodeIds` (`fit-view`, with its props as the payload), disabled before a node is measured. It renders only its
855
+ * children (an icon, a label).
856
+ */
857
+ function FitView(props) {
858
+ const { children, disabled, duration, padding, nodeIds, includeHidden, minZoom, maxZoom, ...rest } = props;
859
+ const { state, props: own } = useControlButton("FitView", "fit-view", () => givenPayload({
860
+ duration,
861
+ padding,
862
+ nodeIds,
863
+ includeHidden,
864
+ minZoom,
865
+ maxZoom
866
+ }), disabled);
867
+ return useRenderElement("button", rest, {
868
+ state,
869
+ props: {
870
+ ...own,
871
+ children
872
+ }
873
+ });
874
+ }
875
+ // src/components/handle.tsx
876
+ /** Where a handle sits by default: centred on its side of the node (a style may move it). */
877
+ const SIDE_STYLE = {
878
+ top: {
879
+ top: 0,
880
+ left: "50%",
881
+ transform: "translate(-50%, -50%)"
882
+ },
883
+ right: {
884
+ top: "50%",
885
+ left: "100%",
886
+ transform: "translate(-50%, -50%)"
887
+ },
888
+ bottom: {
889
+ top: "100%",
890
+ left: "50%",
891
+ transform: "translate(-50%, -50%)"
892
+ },
893
+ left: {
894
+ top: "50%",
895
+ left: 0,
896
+ transform: "translate(-50%, -50%)"
897
+ }
898
+ };
899
+ const HANDLE_STYLE = { position: "absolute" };
900
+ /**
901
+ * A node's connection point (`data-flow-part="handle"`, `data-handle-type`, `data-side`), inside
902
+ * `Flow.Node`: registered with the engine (D8), which measures its centre; with `connection()`, a
903
+ * press on it draws a connection. Absolutely positioned at the middle of its `side` by default;
904
+ * your `style` may place it elsewhere on the node. Give it its size and look.
905
+ */
906
+ function Handle(props) {
907
+ const { type, side, handleId, connectable, connectableStart, connectableEnd, nodeId, children, ...rest } = props;
908
+ const { state, props: own } = useHandle({
909
+ type,
910
+ side,
911
+ handleId,
912
+ connectable,
913
+ connectableStart,
914
+ connectableEnd,
915
+ nodeId
916
+ });
917
+ const { ref, ...attributes } = own;
918
+ return useRenderElement("div", rest, {
919
+ state,
920
+ ref,
921
+ props: {
922
+ ...attributes,
923
+ children
924
+ },
925
+ style: HANDLE_STYLE,
926
+ baseStyle: SIDE_STYLE[side]
927
+ });
928
+ }
929
+ // src/components/node.tsx
930
+ /**
931
+ * One node (`data-flow-part="node"`, `data-flow-id`), absolutely positioned at its place in the
932
+ * viewport (a structural `transform`), registered with the engine, which measures it and resolves
933
+ * presses on it (drag, select, connect from its handles). It renders only its children: the
934
+ * content, `Flow.Handle`s, a resizer, a toolbar.
935
+ */
936
+ function Node(props) {
937
+ const { node, children, ...rest } = props;
938
+ const { state, props: own } = useNode(node);
939
+ const { ref, style, ...attributes } = own;
940
+ const context = React.useMemo(() => ({ nodeId: node.id }), [node.id]);
941
+ const element = useRenderElement("div", rest, {
942
+ state,
943
+ ref,
944
+ props: {
945
+ ...attributes,
946
+ children
947
+ },
948
+ style
949
+ });
950
+ return /* @__PURE__ */ jsx(NodeContext.Provider, {
951
+ value: context,
952
+ children: element
953
+ });
954
+ }
955
+ // src/components/node-toolbar.tsx
956
+ /**
957
+ * A toolbar next to a node, or beside several nodes' bounds (`nodeIds`; `data-flow-part="toolbar"`),
958
+ * outside the zoom: rendered in
959
+ * `Flow.Root` (a portal), at the anchor `node-toolbar-by` gives, so it keeps its size at any zoom.
960
+ * Presses and the wheel over it are left to it. It renders only its children (your buttons).
961
+ */
962
+ function NodeToolbar(props) {
963
+ const { nodeId: nodeIdProp, nodeIds: nodeIdsProp, side = "top", align, offset, open, ...rest } = props;
964
+ const around = React.useContext(NodeContext);
965
+ const many = nodeIdsProp !== void 0 && nodeIdsProp.length > 0;
966
+ const nodeId = many ? void 0 : nodeIdProp ?? around?.nodeId;
967
+ if (!many && nodeId === void 0) throw new Error("Flow.NodeToolbar must be rendered inside Flow.Node (or be given a nodeId or nodeIds)");
968
+ const { model, engine, rootElement } = useFlowContext("NodeToolbar");
969
+ const view = useFlowValue(model, engine, () => {
970
+ if (!engine) return void 0;
971
+ const nodeIds = many ? nodeIdsProp : [nodeId];
972
+ if (!(open ?? nodeIds.every((id) => model.is("node-selected", { nodeId: id })))) return void 0;
973
+ const position = engine.get("node-toolbar-by", {
974
+ ...many ? { nodeIds } : { nodeId },
975
+ side,
976
+ align,
977
+ offset
978
+ });
979
+ return position ? {
980
+ position,
981
+ nodeIds,
982
+ attributes: engine.adapter.attributes("toolbar", many ? {} : { nodeId })
983
+ } : void 0;
984
+ });
985
+ if (!view || !rootElement) return null;
986
+ return createPortal(/* @__PURE__ */ jsx(NodeToolbarElement, {
987
+ ...rest,
988
+ state: {
989
+ nodeId,
990
+ nodeIds: view.nodeIds,
991
+ position: view.position,
992
+ side
993
+ },
994
+ attributes: view.attributes
995
+ }), rootElement);
996
+ }
997
+ function NodeToolbarElement(props) {
998
+ const { state, attributes, children, ...rest } = props;
999
+ const { x, y, anchorX, anchorY } = state.position;
1000
+ return useRenderElement("div", rest, {
1001
+ state,
1002
+ props: {
1003
+ ...attributes,
1004
+ children
1005
+ },
1006
+ style: {
1007
+ position: "absolute",
1008
+ top: 0,
1009
+ left: 0,
1010
+ transform: `translate(${x}px, ${y}px) translate(${-anchorX * 100}%, ${-anchorY * 100}%)`
1011
+ }
1012
+ });
1013
+ }
1014
+ // src/components/nodes.tsx
1015
+ const NODES_STYLE = {
1016
+ position: "absolute",
1017
+ top: 0,
1018
+ left: 0,
1019
+ isolation: "isolate"
1020
+ };
1021
+ const LAYERED_NODES_STYLE = {
1022
+ position: "absolute",
1023
+ top: 0,
1024
+ left: 0
1025
+ };
1026
+ const NO_NODES = Object.freeze([]);
1027
+ const shownNodes = (nodes) => nodes.filter((node) => node.hidden !== true);
1028
+ const NodeSlot = React.memo(function NodeSlot({ node, render }) {
1029
+ return render(node);
1030
+ });
1031
+ /**
1032
+ * The layer of the nodes (`data-flow-part="nodes"`), inside `Flow.Viewport`: calls `children` for
1033
+ * each node that is not hidden (with `onlyRenderVisible`, each one in view, `visible-nodes`), in
1034
+ * drawing order, keyed by its id (a node keeps its element when it moves, and never leaves this
1035
+ * layer: with several render levels its `z-index` places it among the edge levels). You render each
1036
+ * node. With `onlyRenderVisible`, the server render and the first client render (before the
1037
+ * engine knows the view) render none.
1038
+ */
1039
+ function Nodes(props) {
1040
+ const { children, ...rest } = props;
1041
+ const { model, engine, staticGeometry, onlyRenderVisible } = useFlowContext("Nodes");
1042
+ const list = useFlowValue(model, engine, () => engine ? engine.adapter.settings.onlyRenderVisible ? engine.get("visible-nodes") : shownNodes(model.get("all-nodes")) : onlyRenderVisible ? NO_NODES : shownNodes(model.get("all-nodes")));
1043
+ const layered = useFlowValue(model, engine, () => (engine ? engine.get("render-layers") : staticGeometry?.layers ?? []).length > 1);
1044
+ const render = children;
1045
+ return useRenderElement("div", rest, {
1046
+ state: { count: list.length },
1047
+ props: {
1048
+ ...partAttributes("nodes"),
1049
+ children: list.map((node) => /* @__PURE__ */ jsx(NodeSlot, {
1050
+ node,
1051
+ render
1052
+ }, node.id))
1053
+ },
1054
+ style: layered ? LAYERED_NODES_STYLE : NODES_STYLE
1055
+ });
1056
+ }
1057
+ // src/components/nodes-selection.tsx
1058
+ /**
1059
+ * The rectangle around the selected nodes (`data-flow-part="nodes-selection"`, `selection()`),
1060
+ * inside `Flow.Viewport` next to `Flow.Nodes` (it is in flow coordinates): rendered at
1061
+ * `selection-rect`, while two or more nodes are selected by a box (or always, with
1062
+ * `selection({ rect: "always" })`). A press on it drags the selection (`drag()`), its context
1063
+ * menu is the selection's. With `keyboard()` it takes focus, and its keys are a focused selected
1064
+ * node's: the arrows move the selection, the delete keys remove it, Escape clears it. Give it its
1065
+ * look.
1066
+ */
1067
+ function NodesSelection(props) {
1068
+ const { model, engine } = useFlowContext("NodesSelection");
1069
+ const rect = useFlowValue(model, engine, () => engine ? engine.get("selection-rect") ?? null : null);
1070
+ if (!rect) return null;
1071
+ return /* @__PURE__ */ jsx(NodesSelectionElement, {
1072
+ ...props,
1073
+ rect
1074
+ });
1075
+ }
1076
+ function NodesSelectionElement(props) {
1077
+ const { rect, children, ...rest } = props;
1078
+ const { model, engine } = useFlowContext("NodesSelection");
1079
+ const attributes = useFlowValue(model, engine, () => engine?.adapter.attributes("nodes-selection") ?? {});
1080
+ return useRenderElement("div", rest, {
1081
+ state: {
1082
+ rect,
1083
+ dragging: attributes["data-dragging"] !== void 0
1084
+ },
1085
+ props: {
1086
+ ...attributeProps(attributes),
1087
+ "data-flow-part": "nodes-selection",
1088
+ children
1089
+ },
1090
+ style: {
1091
+ position: "absolute",
1092
+ top: 0,
1093
+ left: 0,
1094
+ transform: `translate(${rect.x}px, ${rect.y}px)`,
1095
+ width: rect.width,
1096
+ height: rect.height
1097
+ }
1098
+ });
1099
+ }
1100
+ // src/components/reconnect-anchor.tsx
1101
+ /**
1102
+ * An edge end's grab area (`data-flow-part="reconnect-anchor"`, `data-end`): an SVG circle at the
1103
+ * end, inside `Flow.Edge`. With `reconnection()`, a press on it moves that end to another handle;
1104
+ * an end its edge's `reconnectable` keeps fixed (`false`, or the other end's name) draws none.
1105
+ * Transparent by default; give it its radius (`r`, default 10) and look.
1106
+ */
1107
+ function ReconnectAnchor(props) {
1108
+ const { edgeId: edgeIdProp, end, ...rest } = props;
1109
+ const edgeId = useEdgeId("ReconnectAnchor", edgeIdProp);
1110
+ const { model, engine } = useFlowContext("ReconnectAnchor");
1111
+ const path = useEdgePath(edgeId);
1112
+ const view = useFlowValue(model, engine, () => engine ? {
1113
+ attributes: engine.adapter.attributes("reconnect-anchor", {
1114
+ edgeId,
1115
+ end
1116
+ }),
1117
+ reconnecting: engine.is("edge-reconnecting", { edgeId }),
1118
+ movable: model.is("edge-reconnectable", {
1119
+ edgeId,
1120
+ end
1121
+ })
1122
+ } : void 0, sameValue, "entity", {
1123
+ kind: "edge",
1124
+ id: edgeId
1125
+ });
1126
+ if (!path || !view?.movable) return null;
1127
+ return /* @__PURE__ */ jsx(ReconnectAnchorElement, {
1128
+ ...rest,
1129
+ state: {
1130
+ edgeId,
1131
+ end,
1132
+ path,
1133
+ reconnecting: view.reconnecting
1134
+ },
1135
+ attributes: view.attributes
1136
+ });
1137
+ }
1138
+ function ReconnectAnchorElement(props) {
1139
+ const { state, attributes, ...rest } = props;
1140
+ const point = state.path[state.end];
1141
+ return useRenderElement("circle", rest, {
1142
+ state,
1143
+ props: {
1144
+ ...attributes,
1145
+ cx: point.x,
1146
+ cy: point.y,
1147
+ r: 10,
1148
+ fill: "transparent"
1149
+ },
1150
+ style: { pointerEvents: "all" }
1151
+ });
1152
+ }
1153
+ // src/utils/engine-facade.ts
1154
+ const NOT_MOUNTED = Object.freeze({
1155
+ ok: false,
1156
+ error: Object.freeze({
1157
+ code: "refused",
1158
+ message: "the flow is not mounted"
1159
+ })
1160
+ });
1161
+ /** A facade whose reads before the mount answer `viewport` with `initial`. */
1162
+ function createEngineFacade(initial) {
1163
+ let current = null;
1164
+ const listeners = /* @__PURE__ */ new Set();
1165
+ let unsubscribe = () => {};
1166
+ const empty = {
1167
+ viewport: Object.freeze({ ...initial }),
1168
+ "root-size": Object.freeze({
1169
+ width: 0,
1170
+ height: 0
1171
+ }),
1172
+ "handles-by": Object.freeze([]),
1173
+ "dragging-node-ids": Object.freeze([]),
1174
+ "selection-box": null,
1175
+ connection: null
1176
+ };
1177
+ const forward = (verb, fallback) => (key, payload) => current ? current[verb](key, payload) : fallback(key, payload);
1178
+ return {
1179
+ engine: Object.freeze({
1180
+ run: forward("run", () => NOT_MOUNTED),
1181
+ can: forward("can", () => false),
1182
+ check: forward("check", () => NOT_MOUNTED),
1183
+ get: forward("get", (key) => Object.hasOwn(empty, key) ? empty[key] : void 0),
1184
+ is: forward("is", () => false),
1185
+ subscribe(listener) {
1186
+ const wrapper = (event) => listener(event);
1187
+ listeners.add(wrapper);
1188
+ return () => {
1189
+ listeners.delete(wrapper);
1190
+ };
1191
+ },
1192
+ destroy() {},
1193
+ get adapter() {
1194
+ if (!current) throw new Error("the flow is not mounted");
1195
+ return current.adapter;
1196
+ }
1197
+ }),
1198
+ get current() {
1199
+ return current;
1200
+ },
1201
+ set(next) {
1202
+ if (next === current) return;
1203
+ unsubscribe();
1204
+ current = next;
1205
+ unsubscribe = next ? next.subscribe((event) => {
1206
+ for (const listener of [...listeners]) listener(event);
1207
+ }) : () => {};
1208
+ }
1209
+ };
1210
+ }
1211
+ // src/components/root.tsx
1212
+ /** The callback props' names, from the core's table. */
1213
+ const CALLBACK_PROPS = Object.entries(ENGINE_EVENT_CALLBACKS).map(([type, name]) => [type, `on${name}`]);
1214
+ const CALLBACK_BY_TYPE = new Map(CALLBACK_PROPS);
1215
+ /** Splits the event callbacks off a root's other props. */
1216
+ function splitCallbacks(props) {
1217
+ const callbacks = {};
1218
+ const rest = { ...props };
1219
+ for (const [, name] of CALLBACK_PROPS) if (name in rest) {
1220
+ callbacks[name] = rest[name];
1221
+ delete rest[name];
1222
+ }
1223
+ return [callbacks, rest];
1224
+ }
1225
+ /** The `meta` of the commands that bring the model to the controlled props. */
1226
+ const CONTROLLED_META = Object.freeze({ source: "controlled" });
1227
+ /** A list of features by their names, in order: an equal new list (`features={[drag()]}`) is the same. */
1228
+ function featureNames(features) {
1229
+ return (features ?? []).map((feature) => feature.name).join(",");
1230
+ }
1231
+ /** Warns once per message and root: misuse that the root ignores. */
1232
+ function useWarnOnce() {
1233
+ const warned = React.useRef(/* @__PURE__ */ new Set());
1234
+ return (message) => {
1235
+ if (warned.current.has(message)) return;
1236
+ warned.current.add(message);
1237
+ console.warn(`[@fragiola/flow-react] ${message}`);
1238
+ };
1239
+ }
1240
+ /**
1241
+ * Each engine option's value as a key: a new equal object (`pathOptions`) is the same, a function
1242
+ * (`easing`) is itself, and `null` (`panActivationKey={null}`: none) is not `undefined` (the
1243
+ * default).
1244
+ */
1245
+ function optionKeys(options) {
1246
+ return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, typeof value === "function" || value === void 0 ? value : JSON.stringify(value)]));
1247
+ }
1248
+ /** A key that changes when an engine option's value does (but a function's: see `easing`). */
1249
+ function optionsKey(options) {
1250
+ return JSON.stringify(optionKeys(options), (_key, value) => value === void 0 ? "undefined" : value);
1251
+ }
1252
+ const DEFAULT_VIEWPORT = Object.freeze({
1253
+ x: 0,
1254
+ y: 0,
1255
+ zoom: 1
1256
+ });
1257
+ const ROOT_STYLE = {
1258
+ position: "relative",
1259
+ overflow: "hidden"
1260
+ };
1261
+ /**
1262
+ * The flow (`data-flow-part="root"`): owns the model (unless given) and the engine, attaches the
1263
+ * engine to its element (the engine listens to it: pointer, wheel, keys, focus) and re-renders
1264
+ * when the flow changes. It renders only its children; no Provider is needed above it. Give it a
1265
+ * size (the flow fills it).
1266
+ */
1267
+ function Root(allProps) {
1268
+ const [callbacks, props] = splitCallbacks(allProps);
1269
+ const { model: modelProp, defaultNodes, defaultEdges, nodes, onNodesChange, edges, onEdgesChange, features, createId, defaultEdgeOptions, viewport, defaultViewport, onViewportChange, fitView, flowRef, minZoom, maxZoom, translateExtent, panOnDrag, panOnScroll, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, zoomStep, interactive, onlyRenderVisible, pathOptions, autoPan, panActivationKey, panOnScrollMode, panOnScrollSpeed, zoomActivationKey, easing, nodeOrigin, nodeExtent, elevateNodesOnSelect, elevateEdgesOnSelect, paneClickDistance, nodeClickDistance, preventScrolling, nodesFocusable, edgesFocusable, zIndexMode, children, ...rest } = props;
1270
+ const [ownModel] = React.useState(() => modelProp ? null : createFlowModel({
1271
+ version: 1,
1272
+ nodes: [...nodes ?? defaultNodes ?? []],
1273
+ edges: [...edges ?? defaultEdges ?? []]
1274
+ }, {
1275
+ features,
1276
+ createId,
1277
+ defaultEdgeOptions
1278
+ }));
1279
+ const typed = modelProp ?? ownModel;
1280
+ const model = eraseModel(typed);
1281
+ const warn = useWarnOnce();
1282
+ const [firstFeatures] = React.useState(() => featureNames(features));
1283
+ if (!modelProp && featureNames(features) !== firstFeatures) warn("the features prop changed after the root created its model: the change is ignored (the features are fixed when the model is created)");
1284
+ const engineProps = {
1285
+ minZoom,
1286
+ maxZoom,
1287
+ translateExtent,
1288
+ panOnDrag,
1289
+ panOnScroll,
1290
+ zoomOnScroll,
1291
+ zoomOnPinch,
1292
+ zoomOnDoubleClick,
1293
+ zoomStep,
1294
+ interactive,
1295
+ onlyRenderVisible,
1296
+ pathOptions,
1297
+ autoPan,
1298
+ panActivationKey,
1299
+ panOnScrollMode,
1300
+ panOnScrollSpeed,
1301
+ zoomActivationKey,
1302
+ easing,
1303
+ nodeOrigin,
1304
+ nodeExtent,
1305
+ elevateNodesOnSelect,
1306
+ elevateEdgesOnSelect,
1307
+ paneClickDistance,
1308
+ nodeClickDistance,
1309
+ preventScrolling,
1310
+ nodesFocusable,
1311
+ edgesFocusable,
1312
+ zIndexMode
1313
+ };
1314
+ const engineKey = optionsKey(engineProps);
1315
+ const latest = React.useRef({
1316
+ onNodesChange,
1317
+ onEdgesChange,
1318
+ onViewportChange,
1319
+ callbacks,
1320
+ engineProps,
1321
+ start: viewport ?? defaultViewport ?? DEFAULT_VIEWPORT,
1322
+ fitView
1323
+ });
1324
+ latest.current = {
1325
+ ...latest.current,
1326
+ onNodesChange,
1327
+ onEdgesChange,
1328
+ onViewportChange,
1329
+ callbacks,
1330
+ engineProps
1331
+ };
1332
+ const [facade] = React.useState(() => createEngineFacade(viewport ?? defaultViewport ?? DEFAULT_VIEWPORT));
1333
+ const [engine, setEngine] = React.useState(null);
1334
+ const sentOptions = React.useRef({});
1335
+ useIsomorphicLayoutEffect(() => {
1336
+ const { start, fitView: fit, engineProps: options } = latest.current;
1337
+ const created = createFlowEngine(model, {
1338
+ ...options,
1339
+ defaultViewport: facade.current?.get("viewport") ?? start,
1340
+ fitView: fit
1341
+ });
1342
+ sentOptions.current = optionKeys(options);
1343
+ facade.set(created);
1344
+ setEngine(created);
1345
+ const stop = created.subscribe((event) => {
1346
+ if (event.type === "viewport-change") {
1347
+ latest.current.start = event.viewport;
1348
+ latest.current.onViewportChange?.(event.viewport, event.gesture);
1349
+ return;
1350
+ }
1351
+ const name = CALLBACK_BY_TYPE.get(event.type);
1352
+ const callback = name ? latest.current.callbacks[name] : void 0;
1353
+ if (typeof callback === "function") callback(event);
1354
+ });
1355
+ return () => {
1356
+ stop();
1357
+ facade.set(null);
1358
+ created.destroy();
1359
+ };
1360
+ }, [model, facade]);
1361
+ const live = engine && engine.adapter.model === model ? engine : null;
1362
+ useIsomorphicLayoutEffect(() => {
1363
+ if (!live) return;
1364
+ const next = optionKeys(latest.current.engineProps);
1365
+ const changed = Object.keys(next).filter((key) => next[key] !== sentOptions.current[key]);
1366
+ sentOptions.current = next;
1367
+ if (changed.length === 0) return;
1368
+ const props = latest.current.engineProps;
1369
+ live.adapter.setOptions(Object.fromEntries(changed.map((key) => [key, props[key]])));
1370
+ }, [
1371
+ live,
1372
+ engineKey,
1373
+ easing
1374
+ ]);
1375
+ useIsomorphicLayoutEffect(() => {
1376
+ if (!live || !viewport) return;
1377
+ const current = live.get("viewport");
1378
+ if (current.x !== viewport.x || current.y !== viewport.y || current.zoom !== viewport.zoom) live.run("set-viewport", {
1379
+ x: viewport.x,
1380
+ y: viewport.y,
1381
+ zoom: viewport.zoom
1382
+ });
1383
+ }, [
1384
+ live,
1385
+ viewport?.x,
1386
+ viewport?.y,
1387
+ viewport?.zoom
1388
+ ]);
1389
+ useIsomorphicLayoutEffect(() => model.subscribe((event) => {
1390
+ if (event.meta?.source === CONTROLLED_META.source) return;
1391
+ const { onNodesChange: nodesChanged, onEdgesChange: edgesChanged } = latest.current;
1392
+ if (event.before.nodes !== event.after.nodes) nodesChanged?.(event.after.nodes);
1393
+ if (event.before.edges !== event.after.edges) edgesChanged?.(event.after.edges);
1394
+ }), [model]);
1395
+ const sent = React.useRef({
1396
+ model: ownModel,
1397
+ nodes,
1398
+ edges
1399
+ });
1400
+ useIsomorphicLayoutEffect(() => {
1401
+ const previous = sent.current;
1402
+ const sameModel = previous.model === model;
1403
+ const target = {
1404
+ nodes: sameModel && previous.nodes === nodes ? void 0 : nodes,
1405
+ edges: sameModel && previous.edges === edges ? void 0 : edges
1406
+ };
1407
+ sent.current = {
1408
+ model,
1409
+ nodes,
1410
+ edges
1411
+ };
1412
+ if (target.nodes === void 0 && target.edges === void 0) return;
1413
+ const commands = model.get("commands-to", target);
1414
+ if (commands.length === 0) return;
1415
+ const options = { meta: CONTROLLED_META };
1416
+ if (!model.run("batch", { commands: [...commands] }, options).ok) {
1417
+ const refused = [];
1418
+ for (const entry of commands) {
1419
+ const result = model.run("batch", { commands: [entry] }, options);
1420
+ if (!result.ok) refused.push(`${entry.command}: ${result.error.message}`);
1421
+ }
1422
+ warn(`the controlled nodes / edges were not all applied (the model's are reported back):\n${refused.join("\n")}`);
1423
+ }
1424
+ const { onNodesChange: nodesChanged, onEdgesChange: edgesChanged } = latest.current;
1425
+ if (target.nodes !== void 0 && model.get("commands-to", { nodes: target.nodes }).length > 0) nodesChanged?.(model.get("all-nodes"));
1426
+ if (target.edges !== void 0 && model.get("commands-to", { edges: target.edges }).length > 0) edgesChanged?.(model.get("all-edges"));
1427
+ });
1428
+ useIsomorphicLayoutEffect(() => {
1429
+ if (!flowRef) return;
1430
+ const ref = flowRef;
1431
+ setFlowRef(ref, {
1432
+ model: typed,
1433
+ engine: facade.engine
1434
+ });
1435
+ return () => setFlowRef(ref, null);
1436
+ }, [
1437
+ flowRef,
1438
+ typed,
1439
+ facade
1440
+ ]);
1441
+ const [rootElement, setRootElement] = React.useState(null);
1442
+ const rootRef = React.useCallback((element) => {
1443
+ setRootElement(element);
1444
+ if (!element || !live) return;
1445
+ live.adapter.attachRoot(element);
1446
+ return () => live.adapter.detachRoot();
1447
+ }, [live]);
1448
+ const staticOptions = {
1449
+ nodeOrigin,
1450
+ pathOptions,
1451
+ zIndexMode,
1452
+ elevateNodesOnSelect,
1453
+ elevateEdgesOnSelect
1454
+ };
1455
+ const staticKey = JSON.stringify(staticOptions);
1456
+ const staticCache = React.useRef(void 0);
1457
+ const geometry = useFlowValue(model, live, () => {
1458
+ if (live) return null;
1459
+ const flow = {
1460
+ nodes: model.get("all-nodes"),
1461
+ edges: model.get("all-edges")
1462
+ };
1463
+ const cached = staticCache.current;
1464
+ if (cached?.nodes === flow.nodes && cached.edges === flow.edges && cached.key === staticKey) return cached.geometry;
1465
+ const computed = staticGeometry(flow, staticOptions);
1466
+ staticCache.current = {
1467
+ ...flow,
1468
+ key: staticKey,
1469
+ geometry: computed
1470
+ };
1471
+ return computed;
1472
+ });
1473
+ const attributes = useFlowValue(model, live, () => live ? live.adapter.attributes("root") : partAttributes("root"));
1474
+ const state = {
1475
+ interactive: live ? attributes["data-interactive"] !== void 0 : true,
1476
+ panning: attributes["data-panning"] !== void 0,
1477
+ dragging: attributes["data-dragging"] !== void 0,
1478
+ connecting: attributes["data-connecting"] !== void 0,
1479
+ selecting: attributes["data-selecting"] !== void 0
1480
+ };
1481
+ const context = React.useMemo(() => ({
1482
+ model,
1483
+ engine: live,
1484
+ publicEngine: facade.engine,
1485
+ rootElement,
1486
+ staticGeometry: geometry,
1487
+ onlyRenderVisible: onlyRenderVisible === true
1488
+ }), [
1489
+ model,
1490
+ live,
1491
+ facade,
1492
+ rootElement,
1493
+ geometry,
1494
+ onlyRenderVisible
1495
+ ]);
1496
+ const element = useRenderElement("div", rest, {
1497
+ state,
1498
+ ref: rootRef,
1499
+ props: {
1500
+ ...attributes,
1501
+ children
1502
+ },
1503
+ style: ROOT_STYLE
1504
+ });
1505
+ return /* @__PURE__ */ jsx(FlowContext.Provider, {
1506
+ value: context,
1507
+ children: element
1508
+ });
1509
+ }
1510
+ // src/components/selection-box.tsx
1511
+ /**
1512
+ * The box selection being drawn (`data-flow-part="selection-box"`, `selection()`): absolutely
1513
+ * positioned in `Flow.Root` (outside `Flow.Viewport`: it is in screen pixels), rendered only
1514
+ * while a box is drawn. Give it its look.
1515
+ */
1516
+ function SelectionBox(props) {
1517
+ const { model, engine } = useFlowContext("SelectionBox");
1518
+ const box = useFlowValue(model, engine, () => engine ? engine.get("selection-box") : null);
1519
+ if (!box) return null;
1520
+ return /* @__PURE__ */ jsx(SelectionBoxElement, {
1521
+ ...props,
1522
+ box
1523
+ });
1524
+ }
1525
+ function SelectionBoxElement(props) {
1526
+ const { box, children, ...rest } = props;
1527
+ const { model, engine } = useFlowContext("SelectionBox");
1528
+ const attributes = useFlowValue(model, engine, () => engine?.adapter.attributes("selection-box") ?? {});
1529
+ return useRenderElement("div", rest, {
1530
+ state: { box },
1531
+ props: {
1532
+ ...attributes,
1533
+ "data-flow-part": "selection-box",
1534
+ children
1535
+ },
1536
+ style: {
1537
+ position: "absolute",
1538
+ left: box.x,
1539
+ top: box.y,
1540
+ width: box.width,
1541
+ height: box.height,
1542
+ pointerEvents: "none"
1543
+ }
1544
+ });
1545
+ }
1546
+ // src/components/toggle-interactive.tsx
1547
+ /** The switches the lock turns off and on (React Flow's: dragging, connecting, selecting). */
1548
+ const LOCKED_KINDS = [
1549
+ "drag",
1550
+ "connect",
1551
+ "select"
1552
+ ];
1553
+ /**
1554
+ * A toggle button (`data-flow-part="toggle-interactive"`, `aria-pressed` while the flow is locked,
1555
+ * `data-interactive`): locks and unlocks the flow, React Flow's interactive button: locking turns
1556
+ * dragging, connecting and selecting off (`set-interactive { drag, connect, select }`), unlocking
1557
+ * turns them and `interactive` on; pan and zoom stay. It renders only its children.
1558
+ */
1559
+ function ToggleInteractive(props) {
1560
+ const { children, ...rest } = props;
1561
+ const { model, engine } = useFlowContext("ToggleInteractive");
1562
+ const interactive = useFlowValue(model, engine, () => engine ? LOCKED_KINDS.some((kind) => engine.is("interactive-by", { kind })) : true);
1563
+ return useRenderElement("button", rest, {
1564
+ state: { interactive },
1565
+ props: {
1566
+ type: "button",
1567
+ "data-flow-part": "toggle-interactive",
1568
+ "data-interactive": interactive ? "" : void 0,
1569
+ "aria-pressed": !interactive,
1570
+ disabled: engine === null,
1571
+ onClick: () => {
1572
+ engine?.run("set-interactive", interactive ? {
1573
+ drag: false,
1574
+ connect: false,
1575
+ select: false
1576
+ } : {
1577
+ interactive: true,
1578
+ drag: true,
1579
+ connect: true,
1580
+ select: true
1581
+ });
1582
+ },
1583
+ children
1584
+ }
1585
+ });
1586
+ }
1587
+ // src/components/viewport.tsx
1588
+ const VIEWPORT_STYLE = {
1589
+ position: "absolute",
1590
+ top: 0,
1591
+ left: 0,
1592
+ width: "100%",
1593
+ height: "100%",
1594
+ isolation: "isolate"
1595
+ };
1596
+ /**
1597
+ * The pannable, zoomable layer (`data-flow-part="viewport"`): what is inside is in flow
1598
+ * coordinates (`Flow.Edges`, `Flow.Nodes`, `Flow.ConnectionLine`). The engine writes its
1599
+ * `transform` itself (D4), never React: a pan or a zoom re-renders nothing inside it.
1600
+ */
1601
+ function Viewport$1(props) {
1602
+ const { children, ...rest } = props;
1603
+ const { engine } = useFlowContext("Viewport");
1604
+ const viewport = useViewport();
1605
+ const ref = React.useCallback((element) => {
1606
+ if (!engine) return;
1607
+ engine.adapter.attachViewport(element);
1608
+ return () => engine.adapter.attachViewport(null);
1609
+ }, [engine]);
1610
+ return useRenderElement("div", rest, {
1611
+ state: { viewport },
1612
+ ref,
1613
+ props: {
1614
+ ...partAttributes("viewport"),
1615
+ children
1616
+ },
1617
+ style: VIEWPORT_STYLE
1618
+ });
1619
+ }
1620
+ // src/components/zoom-in.tsx
1621
+ /**
1622
+ * A button (`data-flow-part="zoom-in"`): Zooms in by a step around the root's centre (`zoom-in`), disabled at the greatest zoom. It renders only its
1623
+ * children (an icon, a label).
1624
+ */
1625
+ function ZoomIn(props) {
1626
+ const { children, disabled, duration, ...rest } = props;
1627
+ const { state, props: own } = useControlButton("ZoomIn", "zoom-in", () => durationPayload(duration), disabled);
1628
+ return useRenderElement("button", rest, {
1629
+ state,
1630
+ props: {
1631
+ ...own,
1632
+ children
1633
+ }
1634
+ });
1635
+ }
1636
+ // src/components/zoom-out.tsx
1637
+ /**
1638
+ * A button (`data-flow-part="zoom-out"`): Zooms out by a step around the root's centre (`zoom-out`), disabled at the least zoom. It renders only its
1639
+ * children (an icon, a label).
1640
+ */
1641
+ function ZoomOut(props) {
1642
+ const { children, disabled, duration, ...rest } = props;
1643
+ const { state, props: own } = useControlButton("ZoomOut", "zoom-out", () => durationPayload(duration), disabled);
1644
+ return useRenderElement("button", rest, {
1645
+ state,
1646
+ props: {
1647
+ ...own,
1648
+ children
1649
+ }
1650
+ });
1651
+ }
1652
+ // src/parts.ts
1653
+ var parts_exports = /* @__PURE__ */ __exportAll({
1654
+ Background: () => Background,
1655
+ ConnectionLine: () => ConnectionLine,
1656
+ Controls: () => Controls,
1657
+ Edge: () => Edge,
1658
+ EdgeLabel: () => EdgeLabel,
1659
+ EdgePath: () => EdgePath$1,
1660
+ EdgeToolbar: () => EdgeToolbar,
1661
+ Edges: () => Edges,
1662
+ FitView: () => FitView,
1663
+ Handle: () => Handle,
1664
+ Node: () => Node,
1665
+ NodeToolbar: () => NodeToolbar,
1666
+ Nodes: () => Nodes,
1667
+ NodesSelection: () => NodesSelection,
1668
+ ReconnectAnchor: () => ReconnectAnchor,
1669
+ Root: () => Root,
1670
+ SelectionBox: () => SelectionBox,
1671
+ ToggleInteractive: () => ToggleInteractive,
1672
+ Viewport: () => Viewport$1,
1673
+ ZoomIn: () => ZoomIn,
1674
+ ZoomOut: () => ZoomOut
1675
+ });
1676
+ export { parts_exports as Flow, createFlowRef, useConnection, useEdge, useEdges, useFlow, useFlowRef, useFlowStore, useHandle, useInternalNode, useKeyPress, useNode, useNodeConnections, useNodeId, useNodes, useNodesData, useOnViewportChange, useSelection, useViewport };
1677
+
1678
+ //# sourceMappingURL=index.js.map