@dschz/solid-flow 0.3.0-next.5 → 1.0.0-next.6
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/README.md +14 -12
- package/dist/index/index.d.ts +23 -7
- package/dist/index/index.js +13 -8
- package/dist/index/index.jsx +13 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,12 +15,12 @@ A SolidJS port of [React Flow](https://reactflow.dev/) and [Svelte Flow](https:/
|
|
|
15
15
|
|
|
16
16
|
## Version pairing
|
|
17
17
|
|
|
18
|
-
| Solid Flow | SolidJS | Status
|
|
19
|
-
| ---------- | --------------- |
|
|
20
|
-
| `
|
|
21
|
-
| `0.2.x` | `solid-js` 1.9+ | Maintenance (fixes)
|
|
18
|
+
| Solid Flow | SolidJS | Status |
|
|
19
|
+
| ---------- | --------------- | ------------------------------- |
|
|
20
|
+
| `1.x` | `solid-js` 2.x | Active development (`next` tag) |
|
|
21
|
+
| `0.2.x` | `solid-js` 1.9+ | Maintenance (fixes) |
|
|
22
22
|
|
|
23
|
-
The
|
|
23
|
+
The 1.x line is built for SolidJS 2.0 and its deferred, fine-grained reactive graph; the stable 1.0.0 ships alongside SolidJS 2.0 stable (until then, install with the `next` tag). Keep `solid-js` and `@solidjs/web` on matching 2.0 versions — mixing them breaks at import time. Upgrading from 0.2.x? See [Migrating from 0.2.x](#migrating-from-02x).
|
|
24
24
|
|
|
25
25
|
## Key Features
|
|
26
26
|
|
|
@@ -135,11 +135,11 @@ const [nodes] = createNodeStore<typeof nodeTypes>([
|
|
|
135
135
|
The same guided unions are exported as standalone types, so plain arrays, props, and vanilla stores get identical narrowing:
|
|
136
136
|
|
|
137
137
|
```tsx
|
|
138
|
-
import type {
|
|
138
|
+
import type { SolidFlowEdge, SolidFlowNode } from "@dschz/solid-flow";
|
|
139
139
|
|
|
140
140
|
const initialNodes = [
|
|
141
141
|
{ id: "a", type: "counter", data: { count: 1 }, position: { x: 0, y: 0 } },
|
|
142
|
-
] satisfies
|
|
142
|
+
] satisfies SolidFlowNode<typeof nodeTypes>[];
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## Who owns the data
|
|
@@ -150,6 +150,8 @@ The stores you pass as `nodes` / `edges` props are **controlled** — a delibera
|
|
|
150
150
|
- **The flow writes runtime fields onto your rows.** Dragging updates `position`, selection updates `selected`, measurement fills `measured` — on the same objects you provided, so reading your store is always live.
|
|
151
151
|
- **Imperative commands don't write membership back.** `commands.addNodes(...)` and friends update the flow, not your store. To keep an element across a store replacement, adopt it — like the `onConnect` handler in the Quick Start pushing the new connection into the edge store.
|
|
152
152
|
|
|
153
|
+
**Prefer letting the flow own the data?** Pass `defaultNodes` / `defaultEdges` instead of `nodes` / `edges` for an **uncontrolled** flow (React Flow parity): the arrays seed the flow once (later values are ignored), and membership belongs to the flow — commands like `addNodes` and completed connections persist with no adoption step. Read live state through `useSolidFlow()`'s `flow.nodes` / `flow.edges`. The two axes are independent, so you can control edges while leaving nodes uncontrolled (or vice versa); supplying both props on one axis is a mistake (`nodes` wins, with a dev warning).
|
|
154
|
+
|
|
153
155
|
## The flow API
|
|
154
156
|
|
|
155
157
|
`useSolidFlow()` returns `{ flow, commands }` (with `commands` also spread at the top level for React/Svelte Flow familiarity). Both are stable identities — destructuring is safe.
|
|
@@ -280,7 +282,7 @@ The MiniMap always renders the full graph in either mode — it reads the data g
|
|
|
280
282
|
|
|
281
283
|
## Migrating from 0.2.x
|
|
282
284
|
|
|
283
|
-
The
|
|
285
|
+
The 1.x line targets SolidJS 2.0, which changes how you write to stores, and reworks the read API. The gestures, components, plugins, and commands are otherwise the same.
|
|
284
286
|
|
|
285
287
|
**1. Upgrade the peer dependencies.** `solid-js` and `@solidjs/web` move to matching 2.0 versions.
|
|
286
288
|
|
|
@@ -291,7 +293,7 @@ The 0.3 line targets SolidJS 2.0, which changes how you write to stores, and rew
|
|
|
291
293
|
setNodes(0, "position", "x", (x) => x + 20);
|
|
292
294
|
setEdges((edge) => edge.id === "e1", "animated", true);
|
|
293
295
|
|
|
294
|
-
//
|
|
296
|
+
// 1.x (SolidJS 2.0) — draft callback
|
|
295
297
|
setNodes((nodes) => {
|
|
296
298
|
nodes[0]!.position.x += 20;
|
|
297
299
|
});
|
|
@@ -307,7 +309,7 @@ setNodes(() => nextNodes);
|
|
|
307
309
|
**3. `useSolidFlow` reads moved to the reactive `flow` struct.** The flat getters (`getNodes()`, `getEdges()`, `getNode(id)`, `getEdge(id)`, `getInternalNode(id)`, `getViewport()`, `getZoom()`) are removed:
|
|
308
310
|
|
|
309
311
|
```tsx
|
|
310
|
-
// 0.2.x //
|
|
312
|
+
// 0.2.x // 1.x
|
|
311
313
|
solidFlow.getNodes();
|
|
312
314
|
flow.nodes;
|
|
313
315
|
solidFlow.getViewport();
|
|
@@ -322,9 +324,9 @@ useInternalNode(() => "a");
|
|
|
322
324
|
|
|
323
325
|
`flow.*` reads are reactive — using them in JSX or a tracked scope subscribes. Commands (`fitView`, `setViewport`, `updateNode`, `deleteElements`, ...) are unchanged and now also available namespaced under `commands`.
|
|
324
326
|
|
|
325
|
-
**4. New connections are no longer written into your edge store.** In 0.2.x the flow inserted the connected edge into your store before `onConnect` fired. Under
|
|
327
|
+
**4. New connections are no longer written into your edge store.** In 0.2.x the flow inserted the connected edge into your store before `onConnect` fired. Under the 1.x ownership contract your store owns membership: adopt the connection yourself (see the Quick Start's `onConnect`). Unadopted connections still render, but won't survive a wholesale store replacement.
|
|
326
328
|
|
|
327
|
-
**5. `onlyRenderVisibleElements` now does what it says.** In 0.2.x the prop was accepted but inert. In
|
|
329
|
+
**5. `onlyRenderVisibleElements` now does what it says.** In 0.2.x the prop was accepted but inert. In 1.x it opts into unmount culling (off-screen elements are not mounted at all — see [Performance](#performance)), while the CSS culling tier is always on and needs no prop.
|
|
328
330
|
|
|
329
331
|
**6. Smaller signature changes.** `useNodes()` / `useEdges()` return `readonly` arrays; `useHandleEdgeSelect` is removed (it was internal plumbing — select edges through `commands`).
|
|
330
332
|
|
package/dist/index/index.d.ts
CHANGED
|
@@ -627,6 +627,22 @@ type SolidFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge>
|
|
|
627
627
|
* ]);
|
|
628
628
|
*/
|
|
629
629
|
readonly edges?: Store<EdgeType[]>;
|
|
630
|
+
/**
|
|
631
|
+
* Initial nodes for an UNCONTROLLED flow. When `nodes` is not supplied,
|
|
632
|
+
* the flow owns element state: this array seeds it once (later values
|
|
633
|
+
* are ignored), and membership belongs to the flow — commands like
|
|
634
|
+
* `addNodes`/`deleteElements` and completed connections write through
|
|
635
|
+
* and persist, with no adoption step. Mutually exclusive with `nodes`
|
|
636
|
+
* (which wins, with a dev warning). Mode is fixed at mount, per axis:
|
|
637
|
+
* nodes and edges can each be controlled or uncontrolled independently.
|
|
638
|
+
*/
|
|
639
|
+
readonly defaultNodes?: readonly NodeType[];
|
|
640
|
+
/**
|
|
641
|
+
* Initial edges for an UNCONTROLLED flow — the edge-axis counterpart of
|
|
642
|
+
* `defaultNodes`: seeds once, flow owns membership, completed
|
|
643
|
+
* connections are kept automatically. Mutually exclusive with `edges`.
|
|
644
|
+
*/
|
|
645
|
+
readonly defaultEdges?: readonly EdgeType[];
|
|
630
646
|
/**
|
|
631
647
|
* Custom node types to be available in a flow.
|
|
632
648
|
* Solid Flow matches a node's type to a component in the nodeTypes object.
|
|
@@ -1083,11 +1099,11 @@ type AllEdgeTypes<TUserEdgeTypes extends EdgeTypes> = TUserEdgeTypes extends Rec
|
|
|
1083
1099
|
* ```typescript
|
|
1084
1100
|
* const initialEdges = [
|
|
1085
1101
|
* { id: "e1", source: "1", target: "2", type: "labeled", data: { label: "hi" } },
|
|
1086
|
-
* ] satisfies
|
|
1102
|
+
* ] satisfies SolidFlowEdge<typeof edgeTypes>[];
|
|
1087
1103
|
* ```
|
|
1088
1104
|
*/
|
|
1089
|
-
type
|
|
1090
|
-
type EdgesInput<TUserEdgeTypes extends EdgeTypes> =
|
|
1105
|
+
type SolidFlowEdge<TUserEdgeTypes extends EdgeTypes = Record<string, never>> = { [K in keyof AllEdgeTypes<TUserEdgeTypes>]: Edge<EdgeDataOf<AllEdgeTypes<TUserEdgeTypes>[K]>, K & string>; }[keyof AllEdgeTypes<TUserEdgeTypes>];
|
|
1106
|
+
type EdgesInput<TUserEdgeTypes extends EdgeTypes> = SolidFlowEdge<TUserEdgeTypes>;
|
|
1091
1107
|
/**
|
|
1092
1108
|
* Creates a type-safe reactive store of edges for use in Solid Flow.
|
|
1093
1109
|
*
|
|
@@ -1332,11 +1348,11 @@ type AllNodeTypes<TUserNodeTypes extends NodeTypes> = TUserNodeTypes extends Rec
|
|
|
1332
1348
|
* ```typescript
|
|
1333
1349
|
* const initialNodes = [
|
|
1334
1350
|
* { id: "1", type: "custom", position: { x: 0, y: 0 }, data: { value: 1 } },
|
|
1335
|
-
* ] satisfies
|
|
1351
|
+
* ] satisfies SolidFlowNode<typeof nodeTypes>[];
|
|
1336
1352
|
* ```
|
|
1337
1353
|
*/
|
|
1338
|
-
type
|
|
1339
|
-
type NodesInput<TUserNodeTypes extends NodeTypes> =
|
|
1354
|
+
type SolidFlowNode<TUserNodeTypes extends NodeTypes = Record<string, never>> = { [K in keyof AllNodeTypes<TUserNodeTypes>]: Node<NodeDataOf<AllNodeTypes<TUserNodeTypes>[K]>, K & string>; }[keyof AllNodeTypes<TUserNodeTypes>];
|
|
1355
|
+
type NodesInput<TUserNodeTypes extends NodeTypes> = SolidFlowNode<TUserNodeTypes>;
|
|
1340
1356
|
/**
|
|
1341
1357
|
* Creates a type-safe reactive store of nodes for use in Solid Flow.
|
|
1342
1358
|
*
|
|
@@ -1929,4 +1945,4 @@ declare const getEdgeCenter: typeof getEdgeCenter$1;
|
|
|
1929
1945
|
/** Returns the label center and offsets for a bezier edge. */
|
|
1930
1946
|
declare const getBezierEdgeCenter: typeof getBezierEdgeCenter$1;
|
|
1931
1947
|
//#endregion
|
|
1932
|
-
export { Align, AriaLabelConfig, Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, BezierPathOptions, Box, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, ColorMode, ColorModeClass, type Connection, ConnectionData, ConnectionLine, ConnectionLineComponentProps, ConnectionLineType, ConnectionMode, type ConnectionsRecord, ControlButton, type ControlLinePosition, type ControlPosition, Controls, type CoordinateExtent, type DefaultEdgeOptions, DefaultNode, DeleteEvents, Dimensions, type Edge, EdgeConnection, EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeMarker, EdgeMarkerType, type EdgeProps, EdgeReconnectAnchor, EdgeReconnectEvents, EdgeRenderer, EdgeToolbar, EdgeToolbarProps, type EdgeTypes, EdgeWrapper, type
|
|
1948
|
+
export { Align, AriaLabelConfig, Background, type BackgroundProps, type BackgroundVariant, BaseEdge, BezierEdge, BezierEdgeInternal, type BezierEdgeProps, BezierPathOptions, Box, type BuiltInEdge, type BuiltInNode, type BuiltInNodeTypes, ColorMode, ColorModeClass, type Connection, ConnectionData, ConnectionLine, ConnectionLineComponentProps, ConnectionLineType, ConnectionMode, type ConnectionsRecord, ControlButton, type ControlLinePosition, type ControlPosition, Controls, type CoordinateExtent, type DefaultEdgeOptions, DefaultNode, DeleteEvents, Dimensions, type Edge, EdgeConnection, EdgeEvents, EdgeLabel, EdgeLabelRenderer, type EdgeMarker, EdgeMarkerType, type EdgeProps, EdgeReconnectAnchor, EdgeReconnectEvents, EdgeRenderer, EdgeToolbar, EdgeToolbarProps, type EdgeTypes, EdgeWrapper, type FitBounds, FitBoundsOptions, FitViewOptions, type FlowCommands, type FlowSelection, type FlowState, GetBezierPathParams, type GetMiniMapNodeAttribute, GetSmoothStepPathParams, GetStraightPathParams, GroupNode, Handle, type HandleConnection, InputNode, type InternalNode, IsValidConnection, KeyDefinition, KeyDefinitionObject, KeyModifier, Marker, MarkerDefinition, MarkerType, MiniMap, MiniMapNode, type MiniMapNodeProps, type MiniMapProps, type Node, type NodeConnection, NodeEvents, NodeGraph, type NodeOrigin, type NodeProps, NodeRenderer, NodeResizer, NodeSelection, NodeSelectionEvents, NodeToolbar, NodeToolbarProps, type NodeTypes, NodeWrapper, OnBeforeDelete, OnBeforeEdgeConnect, OnBeforeReconnect, OnConnect, OnConnectEnd, OnConnectStart, OnConnectStartParams, OnDelete, OnEdgeConnect, OnEdgeCreate, OnError, type OnMove, OnMoveEnd, OnMoveStart, OnReconnect, OnReconnectEnd, OnReconnectStart, OnResize, OnResizeEnd, OnResizeStart, OnSelectionChange, OnSelectionDrag, OutputNode, PanOnScrollMode, Pane, PaneEvents, Panel, type PanelPosition, Position, ProOptions, Rect, ResizeControl, ResizeControlVariant, ResizeDragEvent, ResizeParams, ResizeParamsWithDirection, Selection, SelectionMode, SelectionRect, type SetCenter, SetCenterOptions, type SetViewport, ShortcutModifier, ShortcutModifierDefinition, type ShouldResize, SmoothStepEdge, SmoothStepEdgeInternal, type SmoothStepEdgeProps, SmoothStepPathOptions, SnapGrid, SolidFlow, type SolidFlowEdge, type SolidFlowInitialProps, type SolidFlowNode, type SolidFlowProps, SolidFlowProvider, StepEdge, StepEdgeInternal, type StepEdgeProps, StraightEdge, StraightEdgeInternal, type StraightEdgeProps, Transform, UseSolidFlowReturn, Viewport, ViewportHelperFunctionOptions, ViewportPortal, type XYPosition, XYZPosition, Zoom, addEdge, connectionKey, createEdgeStore, createNodeStore, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, useColorMode, useConnection, useEdgeId, useEdges, useInternalNode, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useSolidFlow, useUpdateNodeInternals, useViewport, useViewportInitialized };
|
package/dist/index/index.js
CHANGED
|
@@ -451,8 +451,6 @@ const A11yDescriptions = () => {
|
|
|
451
451
|
}, cullingViewport);
|
|
452
452
|
}, getDefaultFlowStateProps = () => ({
|
|
453
453
|
id: "1",
|
|
454
|
-
nodes: [],
|
|
455
|
-
edges: [],
|
|
456
454
|
nodeOrigin: [0, 0],
|
|
457
455
|
nodeExtent: infiniteExtent,
|
|
458
456
|
defaultEdgeOptions: {},
|
|
@@ -753,7 +751,9 @@ const createLayoutedEdges = (source) => {
|
|
|
753
751
|
zoom: 1
|
|
754
752
|
};
|
|
755
753
|
}, createFlowState = (props, injections = {}) => {
|
|
756
|
-
let _props = merge(getDefaultFlowStateProps(), props), initialNodeTypes = injections.initialNodeTypes ?? {}, initialEdgeTypes = injections.initialEdgeTypes ?? {}, prefersDark = injections.prefersDark ?? (() => _props.colorModeSSR === "dark"), [config, setConfig] = createSignal(_props), [ariaLabelConfig, setAriaLabelConfig] = createSignal(() => mergeAriaLabelConfig(config().ariaLabelConfig)), [ariaLiveMessage, setAriaLiveMessage] = createSignal(() => config().ariaLiveMessage), [clickConnectStartHandle, setClickConnectStartHandle] = createSignal(void 0), [connection, setConnection] = createSignal(initialConnection), [domNode, setDomNode] = createSignal(null), [dragging, setDragging] = createSignal(!1), [elementsSelectable, setElementsSelectable] = createSignal(() => config().elementsSelectable), [height, setHeight] = createSignal(() => config().height), [minZoom, _setMinZoom] = createSignal(() => config().minZoom), [maxZoom, _setMaxZoom] = createSignal(() => config().maxZoom), [nodesConnectable, setNodesConnectable] = createSignal(() => config().nodesDraggable), [nodesDraggable, setNodesDraggable] = createSignal(() => config().nodesDraggable), [panZoom, setPanZoom] = createSignal(null), [selectionRect, setSelectionRect] = createSignal(), [selectionRectMode, setSelectionRectMode] = createSignal(), [snapGrid, setSnapGrid] = createSignal(() => config().snapGrid), [translateExtent, _setTranslateExtent] = createSignal(() => config().translateExtent ?? infiniteExtent), [width, setWidth] = createSignal(() => config().width), [selectionKeyPressed, setSelectionKeyPressed] = createSignal(!1), [multiselectionKeyPressed, setMultiselectionKeyPressed] = createSignal(!1), [deleteKeyPressed, setDeleteKeyPressed] = createSignal(!1), [panActivationKeyPressed, setPanActivationKeyPressed] = createSignal(!1), [zoomActivationKeyPressed, setZoomActivationKeyPressed] = createSignal(!1)
|
|
754
|
+
let _props = merge(getDefaultFlowStateProps(), props), initialNodeTypes = injections.initialNodeTypes ?? {}, initialEdgeTypes = injections.initialEdgeTypes ?? {}, prefersDark = injections.prefersDark ?? (() => _props.colorModeSSR === "dark"), [config, setConfig] = createSignal(_props), [ariaLabelConfig, setAriaLabelConfig] = createSignal(() => mergeAriaLabelConfig(config().ariaLabelConfig)), [ariaLiveMessage, setAriaLiveMessage] = createSignal(() => config().ariaLiveMessage), [clickConnectStartHandle, setClickConnectStartHandle] = createSignal(void 0), [connection, setConnection] = createSignal(initialConnection), [domNode, setDomNode] = createSignal(null), [dragging, setDragging] = createSignal(!1), [elementsSelectable, setElementsSelectable] = createSignal(() => config().elementsSelectable), [height, setHeight] = createSignal(() => config().height), [minZoom, _setMinZoom] = createSignal(() => config().minZoom), [maxZoom, _setMaxZoom] = createSignal(() => config().maxZoom), [nodesConnectable, setNodesConnectable] = createSignal(() => config().nodesDraggable), [nodesDraggable, setNodesDraggable] = createSignal(() => config().nodesDraggable), [panZoom, setPanZoom] = createSignal(null), [selectionRect, setSelectionRect] = createSignal(), [selectionRectMode, setSelectionRectMode] = createSignal(), [snapGrid, setSnapGrid] = createSignal(() => config().snapGrid), [translateExtent, _setTranslateExtent] = createSignal(() => config().translateExtent ?? infiniteExtent), [width, setWidth] = createSignal(() => config().width), [selectionKeyPressed, setSelectionKeyPressed] = createSignal(!1), [multiselectionKeyPressed, setMultiselectionKeyPressed] = createSignal(!1), [deleteKeyPressed, setDeleteKeyPressed] = createSignal(!1), [panActivationKeyPressed, setPanActivationKeyPressed] = createSignal(!1), [zoomActivationKeyPressed, setZoomActivationKeyPressed] = createSignal(!1);
|
|
755
|
+
props.nodes !== void 0 && props.defaultNodes, props.edges !== void 0 && props.defaultEdges;
|
|
756
|
+
let [nodesStore, setNodesStore] = createStore(props.nodes ?? [...props.defaultNodes ?? []]), [edgesStore, setEdgesStore] = createStore(props.edges ?? [...props.defaultEdges ?? []]), nodeSeedAdopted = props.nodes !== void 0 || props.defaultNodes !== void 0, edgeSeedAdopted = props.edges !== void 0 || props.defaultEdges !== void 0, [measurementsStore, setMeasurementsStore] = createStore({}), internalNodes = createInternalNodes({
|
|
757
757
|
get nodes() {
|
|
758
758
|
return nodesStore;
|
|
759
759
|
},
|
|
@@ -775,16 +775,21 @@ const createLayoutedEdges = (source) => {
|
|
|
775
775
|
}), nodeLookup = new RecordMapFacade(internalNodes), initialViewport = getInitialViewport(_props.fitView, _props.initialViewport, _props.width ?? 0, _props.height ?? 0, nodeLookup), [viewportStore, setViewportStore] = createStore(_props.viewport ?? initialViewport);
|
|
776
776
|
createEffect(() => {
|
|
777
777
|
let next = config().nodes;
|
|
778
|
-
for (let node of next);
|
|
778
|
+
if (next) for (let node of next);
|
|
779
779
|
return { next };
|
|
780
780
|
}, ({ next }) => {
|
|
781
|
-
setNodesStore(() => next);
|
|
781
|
+
next && (nodeSeedAdopted = !0, setNodesStore(() => next));
|
|
782
782
|
}, { defer: !0 }), createEffect(() => {
|
|
783
783
|
let next = config().edges;
|
|
784
|
-
for (let edge of next);
|
|
784
|
+
if (next) for (let edge of next);
|
|
785
785
|
return { next };
|
|
786
786
|
}, ({ next }) => {
|
|
787
|
-
setEdgesStore(() => next);
|
|
787
|
+
next && (edgeSeedAdopted = !0, setEdgesStore(() => next));
|
|
788
|
+
}, { defer: !0 }), createEffect(() => ({
|
|
789
|
+
nodes: config().defaultNodes,
|
|
790
|
+
edges: config().defaultEdges
|
|
791
|
+
}), ({ nodes: defaultNodes, edges: defaultEdges }) => {
|
|
792
|
+
defaultNodes && !nodeSeedAdopted && config().nodes === void 0 && (nodeSeedAdopted = !0, setNodesStore(() => [...defaultNodes])), defaultEdges && !edgeSeedAdopted && config().edges === void 0 && (edgeSeedAdopted = !0, setEdgesStore(() => [...defaultEdges]));
|
|
788
793
|
}, { defer: !0 }), createEffect(() => config().viewport, (next) => {
|
|
789
794
|
next && setViewportStore(() => next);
|
|
790
795
|
}, { defer: !0 });
|
|
@@ -3397,7 +3402,7 @@ const SolidFlow = (props) => {
|
|
|
3397
3402
|
zoomOnPinch: !0,
|
|
3398
3403
|
zoomOnDoubleClick: !0,
|
|
3399
3404
|
zoomOnScroll: !0
|
|
3400
|
-
}, props), htmlProps = omit(_props, "nodes", "edges", "nodeTypes", "edgeTypes", "width", "height", "fitView", "fitViewOptions", "nodeOrigin", "nodeDragThreshold", "paneClickDistance", "nodeClickDistance", "minZoom", "maxZoom", "zIndexMode", "initialViewport", "viewport", "translateExtent", "nodeExtent", "selectionKey", "panActivationKey", "deleteKey", "multiSelectionKey", "zoomActivationKey", "panOnDrag", "panOnScroll", "panOnScrollMode", "panOnScrollSpeed", "selectionOnDrag", "selectNodesOnDrag", "preventScrolling", "zoomOnScroll", "zoomOnDoubleClick", "zoomOnPinch", "onlyRenderVisibleElements", "autoPanOnConnect", "autoPanOnNodeDrag", "autoPanOnNodeFocus", "autoPanOnSelection", "autoPanSpeed", "connectionRadius", "connectionMode", "connectionLineType", "connectionLineComponent", "connectionLineStyle", "connectionLineContainerStyle", "connectionDragThreshold", "isValidConnection", "clickConnect", "reconnectRadius", "selectionMode", "elementsSelectable", "nodesDraggable", "nodesConnectable", "nodesFocusable", "edgesFocusable", "disableKeyboardA11y", "ariaLabelConfig", "ariaLiveMessage", "colorMode", "colorModeSSR", "class", "style", "snapGrid", "defaultMarkerColor", "defaultEdgeOptions", "elevateNodesOnSelect", "elevateEdgesOnSelect", "noDragClass", "noPanClass", "noWheelClass", "attributionPosition", "proOptions", "onInit", "onMoveStart", "onMove", "onMoveEnd", "onFlowError", "onNodeClick", "onNodeContextMenu", "onNodeDrag", "onNodeDragStart", "onNodeDragStop", "onNodePointerEnter", "onNodePointerMove", "onNodePointerLeave", "onEdgeClick", "onEdgeContextMenu", "onEdgePointerEnter", "onEdgePointerLeave", "onPaneClick", "onPaneContextMenu", "onSelectionChange", "onSelectionClick", "onSelectionContextMenu", "onSelectionDrag", "onSelectionDragStart", "onSelectionDragStop", "onSelectionStart", "onSelectionEnd", "onConnect", "onConnectStart", "onConnectEnd", "onReconnect", "onReconnectStart", "onReconnectEnd", "onClickConnectStart", "onClickConnectEnd", "onBeforeConnect", "onBeforeReconnect", "onDelete", "onBeforeDelete", "deleteKeyCode", "selectionKeyCode", "panActivationKeyCode", "multiSelectionKeyCode", "zoomActivationKeyCode", "children"), TypedSolidFlowContext = SolidFlowContext, solidFlow = useContext(TypedSolidFlowContext) ?? createSolidFlow(_props), { store, actions } = solidFlow;
|
|
3405
|
+
}, props), htmlProps = omit(_props, "nodes", "edges", "defaultNodes", "defaultEdges", "nodeTypes", "edgeTypes", "width", "height", "fitView", "fitViewOptions", "nodeOrigin", "nodeDragThreshold", "paneClickDistance", "nodeClickDistance", "minZoom", "maxZoom", "zIndexMode", "initialViewport", "viewport", "translateExtent", "nodeExtent", "selectionKey", "panActivationKey", "deleteKey", "multiSelectionKey", "zoomActivationKey", "panOnDrag", "panOnScroll", "panOnScrollMode", "panOnScrollSpeed", "selectionOnDrag", "selectNodesOnDrag", "preventScrolling", "zoomOnScroll", "zoomOnDoubleClick", "zoomOnPinch", "onlyRenderVisibleElements", "autoPanOnConnect", "autoPanOnNodeDrag", "autoPanOnNodeFocus", "autoPanOnSelection", "autoPanSpeed", "connectionRadius", "connectionMode", "connectionLineType", "connectionLineComponent", "connectionLineStyle", "connectionLineContainerStyle", "connectionDragThreshold", "isValidConnection", "clickConnect", "reconnectRadius", "selectionMode", "elementsSelectable", "nodesDraggable", "nodesConnectable", "nodesFocusable", "edgesFocusable", "disableKeyboardA11y", "ariaLabelConfig", "ariaLiveMessage", "colorMode", "colorModeSSR", "class", "style", "snapGrid", "defaultMarkerColor", "defaultEdgeOptions", "elevateNodesOnSelect", "elevateEdgesOnSelect", "noDragClass", "noPanClass", "noWheelClass", "attributionPosition", "proOptions", "onInit", "onMoveStart", "onMove", "onMoveEnd", "onFlowError", "onNodeClick", "onNodeContextMenu", "onNodeDrag", "onNodeDragStart", "onNodeDragStop", "onNodePointerEnter", "onNodePointerMove", "onNodePointerLeave", "onEdgeClick", "onEdgeContextMenu", "onEdgePointerEnter", "onEdgePointerLeave", "onPaneClick", "onPaneContextMenu", "onSelectionChange", "onSelectionClick", "onSelectionContextMenu", "onSelectionDrag", "onSelectionDragStart", "onSelectionDragStop", "onSelectionStart", "onSelectionEnd", "onConnect", "onConnectStart", "onConnectEnd", "onReconnect", "onReconnectStart", "onReconnectEnd", "onClickConnectStart", "onClickConnectEnd", "onBeforeConnect", "onBeforeReconnect", "onDelete", "onBeforeDelete", "deleteKeyCode", "selectionKeyCode", "panActivationKeyCode", "multiSelectionKeyCode", "zoomActivationKeyCode", "children"), TypedSolidFlowContext = SolidFlowContext, solidFlow = useContext(TypedSolidFlowContext) ?? createSolidFlow(_props), { store, actions } = solidFlow;
|
|
3401
3406
|
onSettled(() => (actions.applyInitialFitView(_props.fitView), actions.setConfig(_props), actions.setDomNode(domNode), () => {
|
|
3402
3407
|
actions.reset();
|
|
3403
3408
|
})), createEffect(() => domNodeRef(), (el) => {
|
package/dist/index/index.jsx
CHANGED
|
@@ -271,8 +271,6 @@ const getEdgeId = (connection) => {
|
|
|
271
271
|
}, cullingViewport);
|
|
272
272
|
}, getDefaultFlowStateProps = () => ({
|
|
273
273
|
id: "1",
|
|
274
|
-
nodes: [],
|
|
275
|
-
edges: [],
|
|
276
274
|
nodeOrigin: [0, 0],
|
|
277
275
|
nodeExtent: infiniteExtent,
|
|
278
276
|
defaultEdgeOptions: {},
|
|
@@ -573,7 +571,9 @@ const createLayoutedEdges = (source) => {
|
|
|
573
571
|
zoom: 1
|
|
574
572
|
};
|
|
575
573
|
}, createFlowState = (props, injections = {}) => {
|
|
576
|
-
let _props = merge(getDefaultFlowStateProps(), props), initialNodeTypes = injections.initialNodeTypes ?? {}, initialEdgeTypes = injections.initialEdgeTypes ?? {}, prefersDark = injections.prefersDark ?? (() => _props.colorModeSSR === "dark"), [config, setConfig] = createSignal(_props), [ariaLabelConfig, setAriaLabelConfig] = createSignal(() => mergeAriaLabelConfig(config().ariaLabelConfig)), [ariaLiveMessage, setAriaLiveMessage] = createSignal(() => config().ariaLiveMessage), [clickConnectStartHandle, setClickConnectStartHandle] = createSignal(void 0), [connection, setConnection] = createSignal(initialConnection), [domNode, setDomNode] = createSignal(null), [dragging, setDragging] = createSignal(!1), [elementsSelectable, setElementsSelectable] = createSignal(() => config().elementsSelectable), [height, setHeight] = createSignal(() => config().height), [minZoom, _setMinZoom] = createSignal(() => config().minZoom), [maxZoom, _setMaxZoom] = createSignal(() => config().maxZoom), [nodesConnectable, setNodesConnectable] = createSignal(() => config().nodesDraggable), [nodesDraggable, setNodesDraggable] = createSignal(() => config().nodesDraggable), [panZoom, setPanZoom] = createSignal(null), [selectionRect, setSelectionRect] = createSignal(), [selectionRectMode, setSelectionRectMode] = createSignal(), [snapGrid, setSnapGrid] = createSignal(() => config().snapGrid), [translateExtent, _setTranslateExtent] = createSignal(() => config().translateExtent ?? infiniteExtent), [width, setWidth] = createSignal(() => config().width), [selectionKeyPressed, setSelectionKeyPressed] = createSignal(!1), [multiselectionKeyPressed, setMultiselectionKeyPressed] = createSignal(!1), [deleteKeyPressed, setDeleteKeyPressed] = createSignal(!1), [panActivationKeyPressed, setPanActivationKeyPressed] = createSignal(!1), [zoomActivationKeyPressed, setZoomActivationKeyPressed] = createSignal(!1)
|
|
574
|
+
let _props = merge(getDefaultFlowStateProps(), props), initialNodeTypes = injections.initialNodeTypes ?? {}, initialEdgeTypes = injections.initialEdgeTypes ?? {}, prefersDark = injections.prefersDark ?? (() => _props.colorModeSSR === "dark"), [config, setConfig] = createSignal(_props), [ariaLabelConfig, setAriaLabelConfig] = createSignal(() => mergeAriaLabelConfig(config().ariaLabelConfig)), [ariaLiveMessage, setAriaLiveMessage] = createSignal(() => config().ariaLiveMessage), [clickConnectStartHandle, setClickConnectStartHandle] = createSignal(void 0), [connection, setConnection] = createSignal(initialConnection), [domNode, setDomNode] = createSignal(null), [dragging, setDragging] = createSignal(!1), [elementsSelectable, setElementsSelectable] = createSignal(() => config().elementsSelectable), [height, setHeight] = createSignal(() => config().height), [minZoom, _setMinZoom] = createSignal(() => config().minZoom), [maxZoom, _setMaxZoom] = createSignal(() => config().maxZoom), [nodesConnectable, setNodesConnectable] = createSignal(() => config().nodesDraggable), [nodesDraggable, setNodesDraggable] = createSignal(() => config().nodesDraggable), [panZoom, setPanZoom] = createSignal(null), [selectionRect, setSelectionRect] = createSignal(), [selectionRectMode, setSelectionRectMode] = createSignal(), [snapGrid, setSnapGrid] = createSignal(() => config().snapGrid), [translateExtent, _setTranslateExtent] = createSignal(() => config().translateExtent ?? infiniteExtent), [width, setWidth] = createSignal(() => config().width), [selectionKeyPressed, setSelectionKeyPressed] = createSignal(!1), [multiselectionKeyPressed, setMultiselectionKeyPressed] = createSignal(!1), [deleteKeyPressed, setDeleteKeyPressed] = createSignal(!1), [panActivationKeyPressed, setPanActivationKeyPressed] = createSignal(!1), [zoomActivationKeyPressed, setZoomActivationKeyPressed] = createSignal(!1);
|
|
575
|
+
props.nodes !== void 0 && props.defaultNodes, props.edges !== void 0 && props.defaultEdges;
|
|
576
|
+
let [nodesStore, setNodesStore] = createStore(props.nodes ?? [...props.defaultNodes ?? []]), [edgesStore, setEdgesStore] = createStore(props.edges ?? [...props.defaultEdges ?? []]), nodeSeedAdopted = props.nodes !== void 0 || props.defaultNodes !== void 0, edgeSeedAdopted = props.edges !== void 0 || props.defaultEdges !== void 0, [measurementsStore, setMeasurementsStore] = createStore({}), internalNodes = createInternalNodes({
|
|
577
577
|
get nodes() {
|
|
578
578
|
return nodesStore;
|
|
579
579
|
},
|
|
@@ -595,16 +595,21 @@ const createLayoutedEdges = (source) => {
|
|
|
595
595
|
}), nodeLookup = new RecordMapFacade(internalNodes), initialViewport = getInitialViewport(_props.fitView, _props.initialViewport, _props.width ?? 0, _props.height ?? 0, nodeLookup), [viewportStore, setViewportStore] = createStore(_props.viewport ?? initialViewport);
|
|
596
596
|
createEffect(() => {
|
|
597
597
|
let next = config().nodes;
|
|
598
|
-
for (let node of next);
|
|
598
|
+
if (next) for (let node of next);
|
|
599
599
|
return { next };
|
|
600
600
|
}, ({ next }) => {
|
|
601
|
-
setNodesStore(() => next);
|
|
601
|
+
next && (nodeSeedAdopted = !0, setNodesStore(() => next));
|
|
602
602
|
}, { defer: !0 }), createEffect(() => {
|
|
603
603
|
let next = config().edges;
|
|
604
|
-
for (let edge of next);
|
|
604
|
+
if (next) for (let edge of next);
|
|
605
605
|
return { next };
|
|
606
606
|
}, ({ next }) => {
|
|
607
|
-
setEdgesStore(() => next);
|
|
607
|
+
next && (edgeSeedAdopted = !0, setEdgesStore(() => next));
|
|
608
|
+
}, { defer: !0 }), createEffect(() => ({
|
|
609
|
+
nodes: config().defaultNodes,
|
|
610
|
+
edges: config().defaultEdges
|
|
611
|
+
}), ({ nodes: defaultNodes, edges: defaultEdges }) => {
|
|
612
|
+
defaultNodes && !nodeSeedAdopted && config().nodes === void 0 && (nodeSeedAdopted = !0, setNodesStore(() => [...defaultNodes])), defaultEdges && !edgeSeedAdopted && config().edges === void 0 && (edgeSeedAdopted = !0, setEdgesStore(() => [...defaultEdges]));
|
|
608
613
|
}, { defer: !0 }), createEffect(() => config().viewport, (next) => {
|
|
609
614
|
next && setViewportStore(() => next);
|
|
610
615
|
}, { defer: !0 });
|
|
@@ -2499,7 +2504,7 @@ const KeyHandler = (props) => {
|
|
|
2499
2504
|
zoomOnPinch: !0,
|
|
2500
2505
|
zoomOnDoubleClick: !0,
|
|
2501
2506
|
zoomOnScroll: !0
|
|
2502
|
-
}, props), htmlProps = omit(_props, "nodes", "edges", "nodeTypes", "edgeTypes", "width", "height", "fitView", "fitViewOptions", "nodeOrigin", "nodeDragThreshold", "paneClickDistance", "nodeClickDistance", "minZoom", "maxZoom", "zIndexMode", "initialViewport", "viewport", "translateExtent", "nodeExtent", "selectionKey", "panActivationKey", "deleteKey", "multiSelectionKey", "zoomActivationKey", "panOnDrag", "panOnScroll", "panOnScrollMode", "panOnScrollSpeed", "selectionOnDrag", "selectNodesOnDrag", "preventScrolling", "zoomOnScroll", "zoomOnDoubleClick", "zoomOnPinch", "onlyRenderVisibleElements", "autoPanOnConnect", "autoPanOnNodeDrag", "autoPanOnNodeFocus", "autoPanOnSelection", "autoPanSpeed", "connectionRadius", "connectionMode", "connectionLineType", "connectionLineComponent", "connectionLineStyle", "connectionLineContainerStyle", "connectionDragThreshold", "isValidConnection", "clickConnect", "reconnectRadius", "selectionMode", "elementsSelectable", "nodesDraggable", "nodesConnectable", "nodesFocusable", "edgesFocusable", "disableKeyboardA11y", "ariaLabelConfig", "ariaLiveMessage", "colorMode", "colorModeSSR", "class", "style", "snapGrid", "defaultMarkerColor", "defaultEdgeOptions", "elevateNodesOnSelect", "elevateEdgesOnSelect", "noDragClass", "noPanClass", "noWheelClass", "attributionPosition", "proOptions", "onInit", "onMoveStart", "onMove", "onMoveEnd", "onFlowError", "onNodeClick", "onNodeContextMenu", "onNodeDrag", "onNodeDragStart", "onNodeDragStop", "onNodePointerEnter", "onNodePointerMove", "onNodePointerLeave", "onEdgeClick", "onEdgeContextMenu", "onEdgePointerEnter", "onEdgePointerLeave", "onPaneClick", "onPaneContextMenu", "onSelectionChange", "onSelectionClick", "onSelectionContextMenu", "onSelectionDrag", "onSelectionDragStart", "onSelectionDragStop", "onSelectionStart", "onSelectionEnd", "onConnect", "onConnectStart", "onConnectEnd", "onReconnect", "onReconnectStart", "onReconnectEnd", "onClickConnectStart", "onClickConnectEnd", "onBeforeConnect", "onBeforeReconnect", "onDelete", "onBeforeDelete", "deleteKeyCode", "selectionKeyCode", "panActivationKeyCode", "multiSelectionKeyCode", "zoomActivationKeyCode", "children"), TypedSolidFlowContext = SolidFlowContext, solidFlow = useContext(TypedSolidFlowContext) ?? createSolidFlow(_props), { store, actions } = solidFlow;
|
|
2507
|
+
}, props), htmlProps = omit(_props, "nodes", "edges", "defaultNodes", "defaultEdges", "nodeTypes", "edgeTypes", "width", "height", "fitView", "fitViewOptions", "nodeOrigin", "nodeDragThreshold", "paneClickDistance", "nodeClickDistance", "minZoom", "maxZoom", "zIndexMode", "initialViewport", "viewport", "translateExtent", "nodeExtent", "selectionKey", "panActivationKey", "deleteKey", "multiSelectionKey", "zoomActivationKey", "panOnDrag", "panOnScroll", "panOnScrollMode", "panOnScrollSpeed", "selectionOnDrag", "selectNodesOnDrag", "preventScrolling", "zoomOnScroll", "zoomOnDoubleClick", "zoomOnPinch", "onlyRenderVisibleElements", "autoPanOnConnect", "autoPanOnNodeDrag", "autoPanOnNodeFocus", "autoPanOnSelection", "autoPanSpeed", "connectionRadius", "connectionMode", "connectionLineType", "connectionLineComponent", "connectionLineStyle", "connectionLineContainerStyle", "connectionDragThreshold", "isValidConnection", "clickConnect", "reconnectRadius", "selectionMode", "elementsSelectable", "nodesDraggable", "nodesConnectable", "nodesFocusable", "edgesFocusable", "disableKeyboardA11y", "ariaLabelConfig", "ariaLiveMessage", "colorMode", "colorModeSSR", "class", "style", "snapGrid", "defaultMarkerColor", "defaultEdgeOptions", "elevateNodesOnSelect", "elevateEdgesOnSelect", "noDragClass", "noPanClass", "noWheelClass", "attributionPosition", "proOptions", "onInit", "onMoveStart", "onMove", "onMoveEnd", "onFlowError", "onNodeClick", "onNodeContextMenu", "onNodeDrag", "onNodeDragStart", "onNodeDragStop", "onNodePointerEnter", "onNodePointerMove", "onNodePointerLeave", "onEdgeClick", "onEdgeContextMenu", "onEdgePointerEnter", "onEdgePointerLeave", "onPaneClick", "onPaneContextMenu", "onSelectionChange", "onSelectionClick", "onSelectionContextMenu", "onSelectionDrag", "onSelectionDragStart", "onSelectionDragStop", "onSelectionStart", "onSelectionEnd", "onConnect", "onConnectStart", "onConnectEnd", "onReconnect", "onReconnectStart", "onReconnectEnd", "onClickConnectStart", "onClickConnectEnd", "onBeforeConnect", "onBeforeReconnect", "onDelete", "onBeforeDelete", "deleteKeyCode", "selectionKeyCode", "panActivationKeyCode", "multiSelectionKeyCode", "zoomActivationKeyCode", "children"), TypedSolidFlowContext = SolidFlowContext, solidFlow = useContext(TypedSolidFlowContext) ?? createSolidFlow(_props), { store, actions } = solidFlow;
|
|
2503
2508
|
onSettled(() => (actions.applyInitialFitView(_props.fitView), actions.setConfig(_props), actions.setDomNode(domNode), () => {
|
|
2504
2509
|
actions.reset();
|
|
2505
2510
|
})), createEffect(() => domNodeRef(), (el) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dschz/solid-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-next.6",
|
|
4
4
|
"description": "Solid Flow - A highly customizable Solid library for building node-based editors, workflow systems, diagrams and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai workflows",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@changesets/cli": "2.31.1",
|
|
102
|
-
"@dagrejs/dagre": "
|
|
102
|
+
"@dagrejs/dagre": "3.1.1",
|
|
103
103
|
"@dom-expressions/compiler": "0.50.0-next.43",
|
|
104
104
|
"@playwright/test": "1.62.1",
|
|
105
105
|
"@solidjs/testing-library": "1.0.0-beta.2",
|