@dschz/solid-flow 0.2.3 → 0.3.0-next.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/index.d.ts +5 -4
- package/dist/index/index.js +1258 -1375
- package/dist/index/index.jsx +608 -693
- package/package.json +15 -20
package/dist/index/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { Dynamic, Portal,
|
|
2
|
-
import { For,
|
|
1
|
+
import { Dynamic, Portal, addEvent, claimElement, className, createComponent, delegateEvents, effect, insert, isServer, memo, mergeProps, ref, setAttribute, setStyleProperty, spread, style, template } from "@solidjs/web";
|
|
2
|
+
import { For, Show, createContext, createEffect, createMemo, createRenderEffect, createSignal, createStore, flush, mapArray, merge, omit, onCleanup, onSettled, snapshot, untrack, useContext } from "solid-js";
|
|
3
3
|
import { ReactiveMap } from "@solid-primitives/map";
|
|
4
4
|
import { createMediaQuery } from "@solid-primitives/media";
|
|
5
|
-
import { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, SelectionMode as SelectionMode$1, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, XY_RESIZER_HANDLE_POSITIONS, XY_RESIZER_LINE_POSITIONS, addEdge, addEdge as addEdge$1, areConnectionMapsEqual, calcAutoPan, calculateNodePosition, clampPosition, clampPositionToParent, createDevWarn, createMarkerIds, elementSelectionKeys, evaluateAbsolutePosition, fitViewport, getBezierEdgeCenter, getBezierPath, getBezierPath as getBezierPath$1, getBoundsOfRects, getConnectedEdges, getConnectionStatus, getEdgeCenter, getEdgePosition, getEdgeToolbarTransform, getElementsToRemove, getElevatedEdgeZIndex, getEventPosition, getHostForElement, getIncomers, getInternalNodesBounds, getMarkerId, getNodeDimensions, getNodePositionWithOrigin, getNodeToolbarTransform, getNodesBounds, getNodesBounds as getNodesBounds$1, getNodesInside, getOutgoers, getOverlappingArea, getSmoothStepPath, getSmoothStepPath as getSmoothStepPath$1, getStraightPath, getStraightPath as getStraightPath$1, getViewportForBounds, getViewportForBounds as getViewportForBounds$1, handleConnectionChange, infiniteExtent, initialConnection, isCoordinateExtent, isEdgeBase, isEdgeVisible, isInputDOMNode, isMacOs, isNodeBase, isNumeric, isRectObject, mergeAriaLabelConfig, nodeHasDimensions, nodeToRect, panBy, pointToRendererPoint, rendererPointToPoint, shallowNodeData, snapPosition, updateAbsolutePositions, updateNodeInternals } from "@xyflow/system";
|
|
6
|
-
import {
|
|
7
|
-
import clsx$1, { clsx } from "clsx";
|
|
8
|
-
import { createResizeObserver } from "@solid-primitives/resize-observer";
|
|
5
|
+
import { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, Position as Position$1, ResizeControlVariant, SelectionMode, SelectionMode as SelectionMode$1, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, XY_RESIZER_HANDLE_POSITIONS, XY_RESIZER_LINE_POSITIONS, addEdge, addEdge as addEdge$1, areConnectionMapsEqual, calcAutoPan, calculateNodePosition, clampPosition, clampPositionToParent, createDevWarn, createMarkerIds, elementSelectionKeys, evaluateAbsolutePosition, fitViewport, getBezierEdgeCenter, getBezierPath, getBezierPath as getBezierPath$1, getBoundsOfRects, getConnectedEdges, getConnectionStatus, getEdgeCenter, getEdgePosition, getEdgeToolbarTransform, getElementsToRemove, getElevatedEdgeZIndex, getEventPosition, getHostForElement, getIncomers, getInternalNodesBounds, getMarkerId, getNodeDimensions, getNodePositionWithOrigin, getNodeToolbarTransform, getNodesBounds, getNodesBounds as getNodesBounds$1, getNodesInside, getOutgoers, getOverlappingArea, getSmoothStepPath, getSmoothStepPath as getSmoothStepPath$1, getStraightPath, getStraightPath as getStraightPath$1, getViewportForBounds, getViewportForBounds as getViewportForBounds$1, handleConnectionChange, infiniteExtent, initialConnection, isCoordinateExtent, isEdgeBase, isEdgeVisible, isInputDOMNode, isMacOs, isNodeBase, isNumeric, isRectObject, mergeAriaLabelConfig, nodeHasDimensions, nodeToRect, panBy, pointToRendererPoint, rendererPointToPoint, shallowNodeData, snapPosition, updateAbsolutePositions, updateNodeInternals } from "@xyflow/system";
|
|
6
|
+
import { createEventListener, createEventListenerMap } from "@solid-primitives/event-listener";
|
|
9
7
|
//#region src/components/contexts/edgeId.tsx
|
|
10
|
-
const EdgeIdContext = createContext();
|
|
8
|
+
const EdgeIdContext = createContext(null);
|
|
11
9
|
function useEdgeId() {
|
|
12
10
|
let ctx = useContext(EdgeIdContext);
|
|
13
11
|
if (!ctx) throw Error("solid-flow: Your application must be wrapped with <SolidFlow> in order to invoke useEdgeId");
|
|
@@ -39,46 +37,26 @@ const isNode = (element) => isNodeBase(element), isEdge = (element) => isEdgeBas
|
|
|
39
37
|
x: 1,
|
|
40
38
|
y: 0
|
|
41
39
|
}
|
|
42
|
-
};
|
|
40
|
+
}, scheduleIdleCallback = typeof requestIdleCallback == "function" ? requestIdleCallback : (callback) => setTimeout(callback, 0);
|
|
43
41
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* ```ts
|
|
50
|
-
* const [width, setWidth] = createWritable(() => config().width);
|
|
51
|
-
* // width() will return config().width initially
|
|
52
|
-
* // setWidth(100) will update the signal to 100
|
|
53
|
-
* // If config().width changes, a new signal width() is updated to the new value
|
|
54
|
-
* ```
|
|
42
|
+
* Reactive prop defaulting with skip-undefined semantics: a prop counts as
|
|
43
|
+
* "absent" when it reads `undefined`, so parents forwarding optional props
|
|
44
|
+
* (e.g. `<Handle position={props.targetPosition} />`) do not clobber defaults.
|
|
45
|
+
* This is deliberate policy on top of Solid 2.0's `merge`, where `undefined`
|
|
46
|
+
* is a real value that overrides.
|
|
55
47
|
*/
|
|
56
|
-
function
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let [get, set] = createStore(accessor());
|
|
63
|
-
return {
|
|
64
|
-
get,
|
|
65
|
-
set
|
|
66
|
-
};
|
|
48
|
+
function propDefaults(props, defaults) {
|
|
49
|
+
let out = {}, keys = /* @__PURE__ */ new Set([...Object.keys(defaults), ...Object.keys(props)]);
|
|
50
|
+
for (let key of keys) Object.defineProperty(out, key, {
|
|
51
|
+
get: () => props[key] === void 0 ? defaults[key] : props[key],
|
|
52
|
+
enumerable: !0,
|
|
53
|
+
configurable: !0
|
|
67
54
|
});
|
|
68
|
-
return
|
|
69
|
-
get() {
|
|
70
|
-
return storeMemo().get;
|
|
71
|
-
},
|
|
72
|
-
get set() {
|
|
73
|
-
return storeMemo().set;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
55
|
+
return out;
|
|
76
56
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*/
|
|
81
|
-
const scheduleIdleCallback = typeof requestIdleCallback == "function" ? requestIdleCallback : (callback) => setTimeout(callback, 0), EdgeLabelRenderer = (props) => {
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/components/graph/edge/EdgeLabelRenderer.tsx
|
|
59
|
+
const EdgeLabelRenderer = (props) => {
|
|
82
60
|
let { store } = useInternalSolidFlow(), labelNode = () => store.domNode?.querySelector(".solid-flow__edge-labels");
|
|
83
61
|
return createComponent(Show, {
|
|
84
62
|
get when() {
|
|
@@ -96,117 +74,102 @@ const scheduleIdleCallback = typeof requestIdleCallback == "function" ? requestI
|
|
|
96
74
|
};
|
|
97
75
|
//#endregion
|
|
98
76
|
//#region src/components/graph/edge/EdgeLabel.tsx
|
|
99
|
-
var _tmpl$$34 =
|
|
77
|
+
var _tmpl$$34 = /* @__PURE__ */ template("<div>");
|
|
100
78
|
const EdgeLabel = (props) => {
|
|
101
|
-
let _props =
|
|
79
|
+
let _props = propDefaults(props, {
|
|
102
80
|
x: 0,
|
|
103
81
|
y: 0,
|
|
104
82
|
selectEdgeOnClick: !1,
|
|
105
83
|
transparent: !1,
|
|
106
84
|
style: {}
|
|
107
|
-
},
|
|
108
|
-
"x",
|
|
109
|
-
"y",
|
|
110
|
-
"width",
|
|
111
|
-
"height",
|
|
112
|
-
"selectEdgeOnClick",
|
|
113
|
-
"transparent",
|
|
114
|
-
"children",
|
|
115
|
-
"class",
|
|
116
|
-
"style"
|
|
117
|
-
]), { actions } = useInternalSolidFlow(), id = useEdgeId(), zIndex = () => actions.getEdge(id())?.zIndex;
|
|
85
|
+
}), rest = omit(_props, "x", "y", "width", "height", "selectEdgeOnClick", "transparent", "children", "class", "style"), { actions } = useInternalSolidFlow(), id = useEdgeId(), zIndex = () => actions.getEdge(id())?.zIndex;
|
|
118
86
|
return createComponent(EdgeLabelRenderer, { get children() {
|
|
119
87
|
var _el$ = _tmpl$$34();
|
|
120
|
-
return _el
|
|
121
|
-
|
|
122
|
-
|
|
88
|
+
return spread(_el$, mergeProps({
|
|
89
|
+
role: "button",
|
|
90
|
+
tabindex: -1,
|
|
123
91
|
get class() {
|
|
124
|
-
return
|
|
92
|
+
return [
|
|
93
|
+
"solid-flow__edge-label",
|
|
94
|
+
{ transparent: _props.transparent },
|
|
95
|
+
_props.class
|
|
96
|
+
];
|
|
125
97
|
},
|
|
126
98
|
get style() {
|
|
127
99
|
return {
|
|
128
100
|
"pointer-events": "all",
|
|
129
|
-
width: toPxString(
|
|
130
|
-
height: toPxString(
|
|
131
|
-
transform: `translate(-50%, -50%) translate(${
|
|
132
|
-
cursor:
|
|
101
|
+
width: toPxString(_props.width),
|
|
102
|
+
height: toPxString(_props.height),
|
|
103
|
+
transform: `translate(-50%, -50%) translate(${_props.x}px,${_props.y}px)`,
|
|
104
|
+
cursor: _props.selectEdgeOnClick ? "pointer" : void 0,
|
|
133
105
|
"z-index": zIndex(),
|
|
134
|
-
...
|
|
106
|
+
..._props.style
|
|
135
107
|
};
|
|
108
|
+
},
|
|
109
|
+
onClick: () => {
|
|
110
|
+
_props.selectEdgeOnClick && actions.handleEdgeSelection(id());
|
|
136
111
|
}
|
|
137
|
-
}, rest), !
|
|
112
|
+
}, rest), !0), insert(_el$, () => _props.children), _el$;
|
|
138
113
|
} });
|
|
139
114
|
};
|
|
140
|
-
delegateEvents(["click"]);
|
|
141
115
|
//#endregion
|
|
142
116
|
//#region src/components/graph/edge/BaseEdge.tsx
|
|
143
|
-
var _tmpl$$33 =
|
|
117
|
+
var _tmpl$$33 = /* @__PURE__ */ template("<svg><path></svg>", 2), _tmpl$2$4 = /* @__PURE__ */ template("<svg><path stroke-opacity=0 fill=none class=solid-flow__edge-interaction></svg>", 2);
|
|
144
118
|
const BaseEdge = (props) => {
|
|
145
|
-
let _props =
|
|
146
|
-
"class",
|
|
147
|
-
"style",
|
|
148
|
-
"path",
|
|
149
|
-
"interactionWidth",
|
|
150
|
-
"label",
|
|
151
|
-
"labelStyle",
|
|
152
|
-
"labelX",
|
|
153
|
-
"labelY",
|
|
154
|
-
"markerStart",
|
|
155
|
-
"markerEnd"
|
|
156
|
-
]);
|
|
119
|
+
let _props = propDefaults(props, { interactionWidth: 20 }), rest = omit(_props, "class", "style", "path", "interactionWidth", "label", "labelStyle", "labelX", "labelY", "markerStart", "markerEnd");
|
|
157
120
|
return [
|
|
158
121
|
(() => {
|
|
159
122
|
var _el$ = _tmpl$$33();
|
|
160
123
|
return spread(_el$, mergeProps({
|
|
161
124
|
get d() {
|
|
162
|
-
return
|
|
125
|
+
return _props.path;
|
|
163
126
|
},
|
|
164
127
|
get class() {
|
|
165
|
-
return
|
|
128
|
+
return ["solid-flow__edge-path", _props.class];
|
|
166
129
|
},
|
|
167
130
|
get "marker-start"() {
|
|
168
|
-
return
|
|
131
|
+
return _props.markerStart;
|
|
169
132
|
},
|
|
170
133
|
get "marker-end"() {
|
|
171
|
-
return
|
|
134
|
+
return _props.markerEnd;
|
|
172
135
|
},
|
|
136
|
+
fill: "none",
|
|
173
137
|
get style() {
|
|
174
|
-
return
|
|
138
|
+
return _props.style;
|
|
175
139
|
}
|
|
176
|
-
}, rest), !
|
|
140
|
+
}, rest), !1), _el$;
|
|
177
141
|
})(),
|
|
178
142
|
createComponent(Show, {
|
|
179
143
|
get when() {
|
|
180
|
-
return
|
|
144
|
+
return _props.interactionWidth > 0;
|
|
181
145
|
},
|
|
182
146
|
get children() {
|
|
183
147
|
var _el$2 = _tmpl$2$4();
|
|
184
|
-
return effect((
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}, {
|
|
188
|
-
e
|
|
189
|
-
t: void 0
|
|
148
|
+
return effect(() => ({
|
|
149
|
+
e: _props.path,
|
|
150
|
+
t: _props.interactionWidth
|
|
151
|
+
}), ({ e, t }, _p$) => {
|
|
152
|
+
e !== _p$?.e && setAttribute(_el$2, "d", e), t !== _p$?.t && setAttribute(_el$2, "stroke-width", t);
|
|
190
153
|
}), _el$2;
|
|
191
154
|
}
|
|
192
155
|
}),
|
|
193
156
|
createComponent(Show, {
|
|
194
157
|
get when() {
|
|
195
|
-
return
|
|
158
|
+
return _props.label;
|
|
196
159
|
},
|
|
197
160
|
get children() {
|
|
198
161
|
return createComponent(EdgeLabel, {
|
|
199
162
|
get x() {
|
|
200
|
-
return
|
|
163
|
+
return _props.labelX;
|
|
201
164
|
},
|
|
202
165
|
get y() {
|
|
203
|
-
return
|
|
166
|
+
return _props.labelY;
|
|
204
167
|
},
|
|
205
168
|
get style() {
|
|
206
|
-
return
|
|
169
|
+
return _props.labelStyle;
|
|
207
170
|
},
|
|
208
171
|
get children() {
|
|
209
|
-
return
|
|
172
|
+
return _props.label;
|
|
210
173
|
}
|
|
211
174
|
});
|
|
212
175
|
}
|
|
@@ -309,26 +272,18 @@ const BaseEdge = (props) => {
|
|
|
309
272
|
};
|
|
310
273
|
//#endregion
|
|
311
274
|
//#region src/components/graph/edge/EdgeReconnectAnchor.tsx
|
|
312
|
-
var _tmpl$$32 =
|
|
275
|
+
var _tmpl$$32 = /* @__PURE__ */ template("<div style=background:transparent;border:none;cursor:move>");
|
|
313
276
|
const EdgeReconnectAnchor = (props) => {
|
|
314
|
-
let _props =
|
|
277
|
+
let _props = propDefaults(props, {
|
|
315
278
|
size: 25,
|
|
316
279
|
reconnecting: !1,
|
|
317
280
|
style: {}
|
|
318
|
-
},
|
|
319
|
-
"type",
|
|
320
|
-
"class",
|
|
321
|
-
"style",
|
|
322
|
-
"position",
|
|
323
|
-
"size",
|
|
324
|
-
"reconnecting",
|
|
325
|
-
"children"
|
|
326
|
-
]), { store, nodeLookup, edgeLookup, actions } = useInternalSolidFlow(), edgeId = useEdgeId(), [reconnecting, setReconnecting] = createSignal(!1);
|
|
281
|
+
}), rest = omit(_props, "type", "class", "style", "position", "size", "reconnecting", "children"), { store, nodeLookup, edgeLookup, actions } = useInternalSolidFlow(), edgeId = useEdgeId(), [reconnecting, setReconnecting] = createSignal(!1);
|
|
327
282
|
if (!edgeId()) throw Error("[solid-flow]: EdgeReconnectAnchor must be used within an Edge component");
|
|
328
283
|
let edge = () => edgeLookup.get(edgeId()), onPointerDown = (event) => {
|
|
329
284
|
if (event.button !== 0) return;
|
|
330
|
-
setReconnecting(!0), store.onReconnectStart?.(event, edge(),
|
|
331
|
-
let opposite =
|
|
285
|
+
setReconnecting(!0), store.onReconnectStart?.(event, edge(), _props.type);
|
|
286
|
+
let opposite = _props.type === "target" ? {
|
|
332
287
|
nodeId: edge().source,
|
|
333
288
|
handleId: edge().sourceHandle ?? null,
|
|
334
289
|
type: "source"
|
|
@@ -374,13 +329,13 @@ const EdgeReconnectAnchor = (props) => {
|
|
|
374
329
|
};
|
|
375
330
|
return createComponent(EdgeLabel, mergeProps({
|
|
376
331
|
get x() {
|
|
377
|
-
return
|
|
332
|
+
return _props.position?.x;
|
|
378
333
|
},
|
|
379
334
|
get y() {
|
|
380
|
-
return
|
|
335
|
+
return _props.position?.y;
|
|
381
336
|
},
|
|
382
337
|
get style() {
|
|
383
|
-
return
|
|
338
|
+
return _props.style;
|
|
384
339
|
}
|
|
385
340
|
}, rest, { get children() {
|
|
386
341
|
var _el$ = _tmpl$$32();
|
|
@@ -389,21 +344,22 @@ const EdgeReconnectAnchor = (props) => {
|
|
|
389
344
|
return !reconnecting();
|
|
390
345
|
},
|
|
391
346
|
get children() {
|
|
392
|
-
return
|
|
347
|
+
return _props.children;
|
|
393
348
|
}
|
|
394
|
-
})), effect((
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
349
|
+
})), effect(() => ({
|
|
350
|
+
e: [
|
|
351
|
+
"solid-flow__edgeupdater",
|
|
352
|
+
`solid-flow__edgeupdater-${_props.type}`,
|
|
353
|
+
store.noPanClass,
|
|
354
|
+
_props.class
|
|
355
|
+
],
|
|
356
|
+
t: {
|
|
357
|
+
width: toPxString(_props.size),
|
|
358
|
+
height: toPxString(_props.size),
|
|
359
|
+
..._props.style
|
|
360
|
+
}
|
|
361
|
+
}), ({ e, t }, _p$) => {
|
|
362
|
+
className(_el$, e, _p$?.e), style(_el$, t, _p$?.t);
|
|
407
363
|
}), _el$;
|
|
408
364
|
} }));
|
|
409
365
|
};
|
|
@@ -413,17 +369,24 @@ delegateEvents(["pointerdown"]);
|
|
|
413
369
|
const ARIA_NODE_DESC_KEY = "solid-flow__node-desc", ARIA_EDGE_DESC_KEY = "solid-flow__edge-desc";
|
|
414
370
|
//#endregion
|
|
415
371
|
//#region src/components/accessibility/A11yDescriptions.tsx
|
|
416
|
-
var _tmpl$$31 =
|
|
372
|
+
var _tmpl$$31 = /* @__PURE__ */ template("<div class=a11y-hidden>"), _tmpl$2$3 = /* @__PURE__ */ template("<div aria-live=assertive aria-atomic=true class=a11y-live-msg>");
|
|
417
373
|
const A11yDescriptions = () => {
|
|
418
374
|
let { store } = useInternalSolidFlow();
|
|
419
375
|
return [
|
|
420
376
|
(() => {
|
|
421
377
|
var _el$ = _tmpl$$31();
|
|
422
|
-
return insert(_el$, (
|
|
378
|
+
return insert(_el$, (() => {
|
|
379
|
+
var _c$ = memo(() => !!store.disableKeyboardA11y);
|
|
380
|
+
return () => _c$() ? store.ariaLabelConfig["node.a11yDescription.default"] : store.ariaLabelConfig["node.a11yDescription.keyboardDisabled"];
|
|
381
|
+
})()), effect(() => `${ARIA_NODE_DESC_KEY}-${store.id}`, (_v$) => {
|
|
382
|
+
setAttribute(_el$, "id", _v$);
|
|
383
|
+
}), _el$;
|
|
423
384
|
})(),
|
|
424
385
|
(() => {
|
|
425
386
|
var _el$2 = _tmpl$$31();
|
|
426
|
-
return insert(_el$2, () => store.ariaLabelConfig["edge.a11yDescription.default"]), effect(() =>
|
|
387
|
+
return insert(_el$2, () => store.ariaLabelConfig["edge.a11yDescription.default"]), effect(() => `${ARIA_EDGE_DESC_KEY}-${store.id}`, (_v$) => {
|
|
388
|
+
setAttribute(_el$2, "id", _v$);
|
|
389
|
+
}), _el$2;
|
|
427
390
|
})(),
|
|
428
391
|
createComponent(Show, {
|
|
429
392
|
get when() {
|
|
@@ -431,14 +394,16 @@ const A11yDescriptions = () => {
|
|
|
431
394
|
},
|
|
432
395
|
get children() {
|
|
433
396
|
var _el$3 = _tmpl$2$3();
|
|
434
|
-
return insert(_el$3, () => store.ariaLiveMessage), effect(() =>
|
|
397
|
+
return insert(_el$3, () => store.ariaLiveMessage), effect(() => `solid-flow__aria-live-${store.id}`, (_v$) => {
|
|
398
|
+
setAttribute(_el$3, "id", _v$);
|
|
399
|
+
}), _el$3;
|
|
435
400
|
}
|
|
436
401
|
})
|
|
437
402
|
];
|
|
438
403
|
};
|
|
439
404
|
//#endregion
|
|
440
405
|
//#region src/components/graph/edge/EdgeWrapper.tsx
|
|
441
|
-
var _tmpl$$30 =
|
|
406
|
+
var _tmpl$$30 = /* @__PURE__ */ template("<svg class=solid-flow__edge-wrapper><g>");
|
|
442
407
|
const EdgeWrapper = (props) => {
|
|
443
408
|
let edgeRef, { store, actions } = useInternalSolidFlow(), edgeId = () => props.edgeId, edge = () => actions.getEdge(edgeId()), edgeType = () => edge().type ?? "default", selectable = () => edge().selectable ?? store.elementsSelectable, focusable = () => edge().focusable ?? store.edgesFocusable, edgeComponent = () => store.edgeTypes[edgeType()], markerStartUrl = () => edge().markerStart ? `url('#${getMarkerId(edge().markerStart, store.id)}')` : void 0, markerEndUrl = () => edge().markerEnd ? `url('#${getMarkerId(edge().markerEnd, store.id)}')` : void 0, onClick = (event) => {
|
|
444
409
|
selectable() && actions.handleEdgeSelection(edgeId()), props.onEdgeClick?.({
|
|
@@ -457,7 +422,7 @@ const EdgeWrapper = (props) => {
|
|
|
457
422
|
}, onKeyDown = (event) => {
|
|
458
423
|
store.disableKeyboardA11y || !elementSelectionKeys.includes(event.key) || !selectable() || (event.key === "Escape" ? (edgeRef?.blur(), actions.unselectNodesAndEdges({ edges: [edge()] })) : actions.addSelectedEdges([edge().id]));
|
|
459
424
|
}, ariaLabel = () => edge().ariaLabel ?? `Edge from ${edge().source} to ${edge().target}`;
|
|
460
|
-
return createComponent(EdgeIdContext
|
|
425
|
+
return createComponent(EdgeIdContext, {
|
|
461
426
|
value: edgeId,
|
|
462
427
|
get children() {
|
|
463
428
|
return createComponent(Show, {
|
|
@@ -465,14 +430,12 @@ const EdgeWrapper = (props) => {
|
|
|
465
430
|
return !edge().hidden;
|
|
466
431
|
},
|
|
467
432
|
get children() {
|
|
468
|
-
var _el$ = _tmpl$$30(), _el$2 = _el$.firstChild;
|
|
469
|
-
|
|
470
|
-
var _ref$ = edgeRef;
|
|
471
|
-
return typeof _ref$ == "function" ? use(_ref$, _el$2) : edgeRef = _el$2, spread(_el$2, mergeProps({
|
|
433
|
+
var _el$ = _tmpl$$30(), _el$2 = _el$.firstChild, _ref$ = edgeRef;
|
|
434
|
+
return typeof _ref$ == "function" || Array.isArray(_ref$) ? ref(() => _ref$, _el$2) : edgeRef = _el$2, spread(_el$2, mergeProps({
|
|
472
435
|
get "data-id"() {
|
|
473
436
|
return edge().id;
|
|
474
437
|
},
|
|
475
|
-
get
|
|
438
|
+
get tabindex() {
|
|
476
439
|
return focusable() ? 0 : void 0;
|
|
477
440
|
},
|
|
478
441
|
get role() {
|
|
@@ -481,17 +444,28 @@ const EdgeWrapper = (props) => {
|
|
|
481
444
|
get "aria-label"() {
|
|
482
445
|
return ariaLabel();
|
|
483
446
|
},
|
|
447
|
+
"aria-roledescription": "edge",
|
|
484
448
|
get "aria-describedby"() {
|
|
485
449
|
return focusable() ? `${ARIA_EDGE_DESC_KEY}-${store.id}` : void 0;
|
|
486
450
|
},
|
|
487
451
|
get class() {
|
|
488
|
-
return
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
452
|
+
return [
|
|
453
|
+
"solid-flow__edge",
|
|
454
|
+
`solid-flow__edge-${edgeType()}`,
|
|
455
|
+
{
|
|
456
|
+
animated: !!edge().animated,
|
|
457
|
+
selected: !!edge().selected,
|
|
458
|
+
selectable: !!selectable()
|
|
459
|
+
},
|
|
460
|
+
edge().class
|
|
461
|
+
];
|
|
462
|
+
},
|
|
463
|
+
onClick,
|
|
464
|
+
onKeyDown: (e) => focusable() && onKeyDown(e),
|
|
465
|
+
onContextMenu: (e) => onPointerEvent(e, "contextmenu"),
|
|
466
|
+
onPointerEnter: (e) => onPointerEvent(e, "pointerenter"),
|
|
467
|
+
onPointerLeave: (e) => onPointerEvent(e, "pointerleave")
|
|
468
|
+
}, () => edge().domAttributes), !0), insert(_el$2, createComponent(Dynamic, {
|
|
495
469
|
get component() {
|
|
496
470
|
return edgeComponent();
|
|
497
471
|
},
|
|
@@ -564,20 +538,14 @@ const EdgeWrapper = (props) => {
|
|
|
564
538
|
get markerEnd() {
|
|
565
539
|
return markerEndUrl();
|
|
566
540
|
}
|
|
567
|
-
})), effect((
|
|
541
|
+
})), effect(() => edge().zIndex, (_v$) => {
|
|
542
|
+
setStyleProperty(_el$, "z-index", _v$);
|
|
543
|
+
}), _el$;
|
|
568
544
|
}
|
|
569
545
|
});
|
|
570
546
|
}
|
|
571
547
|
});
|
|
572
|
-
}
|
|
573
|
-
delegateEvents([
|
|
574
|
-
"click",
|
|
575
|
-
"keydown",
|
|
576
|
-
"contextmenu"
|
|
577
|
-
]);
|
|
578
|
-
//#endregion
|
|
579
|
-
//#region src/components/graph/edge/SmoothStepEdge.tsx
|
|
580
|
-
const SmoothStepEdge = (props) => {
|
|
548
|
+
}, SmoothStepEdge = (props) => {
|
|
581
549
|
let pathData = createMemo(() => {
|
|
582
550
|
let [path, labelX, labelY] = getSmoothStepPath$1({
|
|
583
551
|
sourceX: props.sourceX,
|
|
@@ -860,7 +828,7 @@ const SmoothStepEdge = (props) => {
|
|
|
860
828
|
}, getEdgeId = (connection) => {
|
|
861
829
|
let { source, sourceHandle, target, targetHandle } = connection;
|
|
862
830
|
return `xy-edge__${source}${sourceHandle || ""}-${target}${targetHandle || ""}`;
|
|
863
|
-
}, NodeConnectableContext = createContext();
|
|
831
|
+
}, NodeConnectableContext = createContext(null);
|
|
864
832
|
function useNodeConnectable() {
|
|
865
833
|
let ctx = useContext(NodeConnectableContext);
|
|
866
834
|
if (!ctx) throw Error("solid-flow: Your application must be wrapped with <SolidFlow> in order to invoke useNodeConnectable");
|
|
@@ -868,32 +836,22 @@ function useNodeConnectable() {
|
|
|
868
836
|
}
|
|
869
837
|
//#endregion
|
|
870
838
|
//#region src/components/graph/handle/Handle.tsx
|
|
871
|
-
var _tmpl$$29 =
|
|
839
|
+
var _tmpl$$29 = /* @__PURE__ */ template("<div>");
|
|
872
840
|
const Handle = (props) => {
|
|
873
|
-
let _props =
|
|
874
|
-
id: null,
|
|
841
|
+
let _props = propDefaults(props, {
|
|
875
842
|
type: "source",
|
|
876
843
|
position: "top",
|
|
877
844
|
isConnectableStart: !0,
|
|
878
845
|
isConnectableEnd: !0
|
|
879
|
-
}
|
|
880
|
-
"id",
|
|
881
|
-
"type",
|
|
882
|
-
"position",
|
|
883
|
-
"isConnectable",
|
|
884
|
-
"isConnectableStart",
|
|
885
|
-
"isConnectableEnd",
|
|
886
|
-
"isValidConnection",
|
|
887
|
-
"onConnect",
|
|
888
|
-
"onDisconnect",
|
|
889
|
-
"children",
|
|
890
|
-
"class",
|
|
891
|
-
"style"
|
|
892
|
-
]), nodeId = useNodeId(), nodeConnectable = useNodeConnectable(), connectable = () => local.isConnectable ?? nodeConnectable(), isTarget = () => local.type === "target", handleId = () => local.id ?? null, connectionInProcess = () => !!store.connection.fromHandle, connectingFrom = () => store.connection.fromHandle && store.connection.fromHandle.nodeId === nodeId() && store.connection.fromHandle.type === local.type && store.connection.fromHandle.id === handleId(), connectingTo = () => store.connection.toHandle && store.connection.toHandle.nodeId === nodeId() && store.connection.toHandle.type === local.type && store.connection.toHandle.id === handleId(), isPossibleTargetHandle = () => store.connectionMode === "strict" ? store.connection.fromHandle?.type !== local.type : nodeId() !== store.connection.fromHandle?.nodeId || handleId() !== store.connection.fromHandle?.id, valid = () => !!(connectingTo() && store.connection.isValid), prevConnections = null, connections;
|
|
846
|
+
}), { store, nodeLookup, connectionLookup, actions } = useInternalSolidFlow(), rest = omit(_props, "id", "type", "position", "isConnectable", "isConnectableStart", "isConnectableEnd", "isValidConnection", "onConnect", "onDisconnect", "children", "class", "style"), nodeId = useNodeId(), nodeConnectable = useNodeConnectable(), connectable = () => _props.isConnectable ?? nodeConnectable(), isTarget = () => _props.type === "target", handleId = () => _props.id ?? null, connectionInProcess = () => !!store.connection.fromHandle, connectingFrom = () => store.connection.fromHandle && store.connection.fromHandle.nodeId === nodeId() && store.connection.fromHandle.type === _props.type && store.connection.fromHandle.id === handleId(), connectingTo = () => store.connection.toHandle && store.connection.toHandle.nodeId === nodeId() && store.connection.toHandle.type === _props.type && store.connection.toHandle.id === handleId(), isPossibleTargetHandle = () => store.connectionMode === "strict" ? store.connection.fromHandle?.type !== _props.type : nodeId() !== store.connection.fromHandle?.nodeId || handleId() !== store.connection.fromHandle?.id, valid = () => !!(connectingTo() && store.connection.isValid), prevConnections = null;
|
|
893
847
|
createEffect(() => {
|
|
894
|
-
if (!
|
|
895
|
-
let
|
|
896
|
-
|
|
848
|
+
if (!_props.onConnect && !_props.onDisconnect) return null;
|
|
849
|
+
let connectionKey = `${nodeId()}-${_props.type}${_props.id ? `-${_props.id}` : ""}`;
|
|
850
|
+
return { connections: connectionLookup.get(connectionKey) };
|
|
851
|
+
}, (current) => {
|
|
852
|
+
if (!current) return;
|
|
853
|
+
let { connections } = current;
|
|
854
|
+
if (prevConnections && !areConnectionMapsEqual(connections, prevConnections)) {
|
|
897
855
|
let _connections = connections ?? /* @__PURE__ */ new Map();
|
|
898
856
|
handleConnectionChange(prevConnections, _connections, props.onDisconnect), handleConnectionChange(_connections, prevConnections, props.onConnect);
|
|
899
857
|
}
|
|
@@ -917,8 +875,10 @@ const Handle = (props) => {
|
|
|
917
875
|
lib: store.lib,
|
|
918
876
|
autoPanOnConnect: store.autoPanOnConnect,
|
|
919
877
|
flowId: store.id,
|
|
920
|
-
isValidConnection:
|
|
921
|
-
updateConnection:
|
|
878
|
+
isValidConnection: _props.isValidConnection ?? store.isValidConnection,
|
|
879
|
+
updateConnection: ((connection) => {
|
|
880
|
+
actions.setConnection(connection), flush();
|
|
881
|
+
}),
|
|
922
882
|
cancelConnection: actions.cancelConnection,
|
|
923
883
|
panBy: actions.panBy,
|
|
924
884
|
onConnect: onConnectExtended,
|
|
@@ -937,24 +897,24 @@ const Handle = (props) => {
|
|
|
937
897
|
handleDomNode: event.currentTarget
|
|
938
898
|
});
|
|
939
899
|
}, onClick = (event) => {
|
|
940
|
-
if (!nodeId() || !store.clickConnectStartHandle && !
|
|
900
|
+
if (!nodeId() || !store.clickConnectStartHandle && !_props.isConnectableStart) return;
|
|
941
901
|
if (!store.clickConnectStartHandle) {
|
|
942
902
|
store.onClickConnectStart?.(event, {
|
|
943
903
|
nodeId: nodeId(),
|
|
944
904
|
handleId: handleId(),
|
|
945
|
-
handleType:
|
|
905
|
+
handleType: _props.type
|
|
946
906
|
}), actions.setClickConnectStartHandle({
|
|
947
907
|
nodeId: nodeId(),
|
|
948
|
-
type:
|
|
908
|
+
type: _props.type,
|
|
949
909
|
id: handleId()
|
|
950
910
|
});
|
|
951
911
|
return;
|
|
952
912
|
}
|
|
953
|
-
let doc = getHostForElement(event.target), isValidConnectionHandler =
|
|
913
|
+
let doc = getHostForElement(event.target), isValidConnectionHandler = _props.isValidConnection ?? store.isValidConnection, { connection, isValid } = XYHandle.isValid(event, {
|
|
954
914
|
handle: {
|
|
955
915
|
nodeId: nodeId(),
|
|
956
916
|
id: handleId(),
|
|
957
|
-
type:
|
|
917
|
+
type: _props.type
|
|
958
918
|
},
|
|
959
919
|
connectionMode: store.connectionMode,
|
|
960
920
|
fromNodeId: store.clickConnectStartHandle.nodeId,
|
|
@@ -967,57 +927,61 @@ const Handle = (props) => {
|
|
|
967
927
|
nodeLookup
|
|
968
928
|
});
|
|
969
929
|
isValid && connection && onConnectExtended(connection);
|
|
970
|
-
let connectionClone = structuredClone(
|
|
930
|
+
let connectionClone = structuredClone(snapshot(store.connection));
|
|
971
931
|
delete connectionClone.inProgress, connectionClone.toPosition = connectionClone.toHandle ? connectionClone.toHandle.position : null, store.onClickConnectEnd?.(event, connectionClone), actions.setClickConnectStartHandle(void 0);
|
|
972
|
-
}, connectionIndicator = () => connectable() && (!connectionInProcess() || isPossibleTargetHandle()) && (connectionInProcess() || store.clickConnectStartHandle ?
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
932
|
+
}, connectionIndicator = () => connectable() && (!connectionInProcess() || isPossibleTargetHandle()) && (connectionInProcess() || store.clickConnectStartHandle ? _props.isConnectableEnd : _props.isConnectableStart);
|
|
933
|
+
var _el$ = _tmpl$$29();
|
|
934
|
+
return spread(_el$, mergeProps(rest, {
|
|
935
|
+
role: "button",
|
|
936
|
+
get "aria-label"() {
|
|
937
|
+
return store.ariaLabelConfig["handle.ariaLabel"];
|
|
938
|
+
},
|
|
939
|
+
tabindex: -1,
|
|
940
|
+
get "data-handleid"() {
|
|
941
|
+
return handleId();
|
|
942
|
+
},
|
|
943
|
+
get "data-nodeid"() {
|
|
944
|
+
return nodeId();
|
|
945
|
+
},
|
|
946
|
+
get "data-handlepos"() {
|
|
947
|
+
return _props.position;
|
|
948
|
+
},
|
|
949
|
+
get "data-id"() {
|
|
950
|
+
return `${store.id}-${nodeId()}-${_props.id || null}-${_props.type}`;
|
|
951
|
+
},
|
|
952
|
+
get onClick() {
|
|
953
|
+
return store.clickConnect ? onClick : void 0;
|
|
954
|
+
},
|
|
955
|
+
onPointerDown,
|
|
956
|
+
get style() {
|
|
957
|
+
return _props.style;
|
|
958
|
+
},
|
|
959
|
+
get class() {
|
|
960
|
+
return [
|
|
961
|
+
"solid-flow__handle",
|
|
962
|
+
`solid-flow__handle-${_props.position}`,
|
|
963
|
+
store.noDragClass,
|
|
964
|
+
store.noPanClass,
|
|
965
|
+
_props.class,
|
|
966
|
+
{
|
|
999
967
|
valid: valid(),
|
|
1000
|
-
connectingto: connectingTo(),
|
|
1001
|
-
connectingfrom: connectingFrom(),
|
|
968
|
+
connectingto: !!connectingTo(),
|
|
969
|
+
connectingfrom: !!connectingFrom(),
|
|
1002
970
|
source: !isTarget(),
|
|
1003
971
|
target: isTarget(),
|
|
1004
972
|
connectablestart: _props.isConnectableStart,
|
|
1005
973
|
connectableend: _props.isConnectableEnd,
|
|
1006
|
-
connectable: connectable(),
|
|
974
|
+
connectable: !!connectable(),
|
|
1007
975
|
connectionindicator: connectionIndicator()
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
})()
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
let _props = mergeProps$1({
|
|
1018
|
-
targetPosition: "top",
|
|
1019
|
-
sourcePosition: "bottom"
|
|
1020
|
-
}, props);
|
|
976
|
+
}
|
|
977
|
+
];
|
|
978
|
+
}
|
|
979
|
+
}), !0), insert(_el$, () => _props.children), _el$;
|
|
980
|
+
}, DefaultNode = (props) => {
|
|
981
|
+
let _props = propDefaults(props, {
|
|
982
|
+
targetPosition: Position$1.Top,
|
|
983
|
+
sourcePosition: Position$1.Bottom
|
|
984
|
+
});
|
|
1021
985
|
return [
|
|
1022
986
|
createComponent(Handle, {
|
|
1023
987
|
type: "target",
|
|
@@ -1042,18 +1006,17 @@ const DefaultNode = (props) => {
|
|
|
1042
1006
|
};
|
|
1043
1007
|
//#endregion
|
|
1044
1008
|
//#region src/components/graph/node/GroupNode.tsx
|
|
1045
|
-
var _tmpl$$28 =
|
|
1009
|
+
var _tmpl$$28 = /* @__PURE__ */ template("<div style=position:absolute;left:0;top:0>");
|
|
1046
1010
|
const GroupNode = (props) => (() => {
|
|
1047
1011
|
var _el$ = _tmpl$$28();
|
|
1048
|
-
return
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}, {
|
|
1052
|
-
e
|
|
1053
|
-
t: void 0
|
|
1012
|
+
return effect(() => ({
|
|
1013
|
+
e: toPxString(props.width),
|
|
1014
|
+
t: toPxString(props.height)
|
|
1015
|
+
}), ({ e, t }, _p$) => {
|
|
1016
|
+
e !== _p$?.e && setStyleProperty(_el$, "width", e), t !== _p$?.t && setStyleProperty(_el$, "height", t);
|
|
1054
1017
|
}), _el$;
|
|
1055
1018
|
})(), InputNode = (props) => {
|
|
1056
|
-
let _props =
|
|
1019
|
+
let _props = propDefaults(props, { sourcePosition: Position$1.Bottom });
|
|
1057
1020
|
return [memo(() => props.data?.label), createComponent(Handle, {
|
|
1058
1021
|
type: "source",
|
|
1059
1022
|
get position() {
|
|
@@ -1065,8 +1028,12 @@ const GroupNode = (props) => (() => {
|
|
|
1065
1028
|
})];
|
|
1066
1029
|
}, createDraggable = (elem, params) => {
|
|
1067
1030
|
let { store, nodeLookup, actions } = useInternalSolidFlow(), [dragging, setDragging] = createSignal(!1);
|
|
1068
|
-
return
|
|
1069
|
-
|
|
1031
|
+
return createEffect(() => ({
|
|
1032
|
+
el: elem(),
|
|
1033
|
+
current: params()
|
|
1034
|
+
}), ({ el, current }) => {
|
|
1035
|
+
if (!el || current.disabled) return;
|
|
1036
|
+
let { onDrag, onDragStart, onDragStop, onNodeMouseDown } = current, dragInstance = XYDrag({
|
|
1070
1037
|
onDrag,
|
|
1071
1038
|
onDragStart: (event, dragItems, node, nodes) => {
|
|
1072
1039
|
setDragging(!0), onDragStart?.(event, dragItems, node, nodes);
|
|
@@ -1096,27 +1063,18 @@ const GroupNode = (props) => (() => {
|
|
|
1096
1063
|
panBy: actions.panBy
|
|
1097
1064
|
})
|
|
1098
1065
|
});
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
noDragClassName: params.noDragClass,
|
|
1108
|
-
handleSelector: params.handleSelector,
|
|
1109
|
-
isSelectable: params.isSelectable,
|
|
1110
|
-
nodeClickDistance: params.nodeClickDistance
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
createEffect(() => {
|
|
1114
|
-
updateDrag(elem(), params());
|
|
1115
|
-
}), onCleanup(() => {
|
|
1066
|
+
return dragInstance.update({
|
|
1067
|
+
domNode: el,
|
|
1068
|
+
nodeId: current.nodeId,
|
|
1069
|
+
noDragClassName: current.noDragClass,
|
|
1070
|
+
handleSelector: current.handleSelector,
|
|
1071
|
+
isSelectable: current.isSelectable,
|
|
1072
|
+
nodeClickDistance: current.nodeClickDistance
|
|
1073
|
+
}), () => {
|
|
1116
1074
|
dragInstance.destroy();
|
|
1117
|
-
}
|
|
1075
|
+
};
|
|
1118
1076
|
}), dragging;
|
|
1119
|
-
}, NodeIdContext = createContext();
|
|
1077
|
+
}, NodeIdContext = createContext(null);
|
|
1120
1078
|
function useNodeId() {
|
|
1121
1079
|
let ctx = useContext(NodeIdContext);
|
|
1122
1080
|
if (!ctx) throw Error("solid-flow: Your application must be wrapped with <SolidFlow> in order to invoke useNodeId");
|
|
@@ -1124,7 +1082,7 @@ function useNodeId() {
|
|
|
1124
1082
|
}
|
|
1125
1083
|
//#endregion
|
|
1126
1084
|
//#region src/components/graph/node/NodeWrapper.tsx
|
|
1127
|
-
var _tmpl$$27 =
|
|
1085
|
+
var _tmpl$$27 = /* @__PURE__ */ template("<div>");
|
|
1128
1086
|
const NodeWrapper = (props) => {
|
|
1129
1087
|
let { store, nodeLookup, parentLookup, actions } = useInternalSolidFlow(), [nodeRef, setNodeRef] = createSignal(), node = () => nodeLookup.get(props.nodeId), nodeId = () => node().id, nodeType = () => node().type ?? "default", deletable = () => node().deletable ?? !0, selectable = () => node().selectable ?? store.elementsSelectable, focusable = () => node().focusable ?? store.nodesFocusable, draggable = () => node().draggable ?? store.nodesDraggable, connectable = () => node().connectable ?? store.nodesConnectable, userNode = () => node().internals.userNode, nodeTypeValid = () => nodeType() in store.nodeTypes, nodeComponent = () => store.nodeTypes[nodeType()], isParentNode = () => parentLookup.has(node().id), transform = () => {
|
|
1130
1088
|
let { x, y } = node().internals.positionAbsolute;
|
|
@@ -1143,19 +1101,27 @@ const NodeWrapper = (props) => {
|
|
|
1143
1101
|
...sizeStyle(),
|
|
1144
1102
|
...node().style ?? {}
|
|
1145
1103
|
});
|
|
1146
|
-
createEffect(() => {
|
|
1147
|
-
nodeTypeValid()
|
|
1148
|
-
|
|
1104
|
+
createEffect(() => ({
|
|
1105
|
+
valid: nodeTypeValid(),
|
|
1106
|
+
nodeType: nodeType()
|
|
1107
|
+
}), ({ valid, nodeType }) => {}), createEffect(() => ({
|
|
1149
1108
|
id: node().id,
|
|
1150
1109
|
nodeElement: nodeRef(),
|
|
1151
|
-
force: !0
|
|
1152
|
-
}]]), {
|
|
1153
1110
|
nodeType: nodeType(),
|
|
1154
1111
|
sourcePosition: node().sourcePosition,
|
|
1155
1112
|
targetPosition: node().targetPosition
|
|
1156
|
-
})
|
|
1157
|
-
|
|
1158
|
-
|
|
1113
|
+
}), (current, prev) => {
|
|
1114
|
+
current.nodeElement && (prev && prev.nodeElement === current.nodeElement && prev.sourcePosition === current.sourcePosition && prev.targetPosition === current.targetPosition && prev.nodeType === current.nodeType || actions.requestUpdateNodeInternals([[current.id, {
|
|
1115
|
+
id: current.id,
|
|
1116
|
+
nodeElement: current.nodeElement,
|
|
1117
|
+
force: !0
|
|
1118
|
+
}]]));
|
|
1119
|
+
}), createEffect(() => ({
|
|
1120
|
+
nodeElement: nodeRef(),
|
|
1121
|
+
hasDimensions: nodeHasDimensions(node()),
|
|
1122
|
+
resizeObserver: props.resizeObserver
|
|
1123
|
+
}), (current, prev) => {
|
|
1124
|
+
current.nodeElement === prev?.nodeElement && current.resizeObserver === prev?.resizeObserver && current.hasDimensions || (prev?.nodeElement && prev.resizeObserver?.unobserve(prev.nodeElement), current.nodeElement && current.resizeObserver?.observe(current.nodeElement));
|
|
1159
1125
|
});
|
|
1160
1126
|
let onSelectNodeHandler = (event) => {
|
|
1161
1127
|
selectable() && (!store.selectNodesOnDrag || !draggable() || store.nodeDragThreshold > 0) && actions.handleNodeSelection(node().id), props.onNodeClick?.({
|
|
@@ -1169,13 +1135,11 @@ const NodeWrapper = (props) => {
|
|
|
1169
1135
|
return;
|
|
1170
1136
|
}
|
|
1171
1137
|
let arrowKeyDiff = ARROW_KEY_DIFFS[event.key];
|
|
1172
|
-
draggable() && node().selected && arrowKeyDiff &&
|
|
1173
|
-
event.
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
})), actions.moveSelectedNodes(arrowKeyDiff, event.shiftKey ? 4 : 1);
|
|
1178
|
-
});
|
|
1138
|
+
draggable() && node().selected && arrowKeyDiff && (event.preventDefault(), actions.setAriaLiveMessage(store.ariaLabelConfig["node.a11yDescription.ariaLiveMessage"]({
|
|
1139
|
+
direction: event.key.replace("Arrow", "").toLowerCase(),
|
|
1140
|
+
x: ~~node().internals.positionAbsolute.x,
|
|
1141
|
+
y: ~~node().internals.positionAbsolute.y
|
|
1142
|
+
})), actions.moveSelectedNodes(arrowKeyDiff, event.shiftKey ? 4 : 1));
|
|
1179
1143
|
}, onFocus = () => {
|
|
1180
1144
|
if (store.disableKeyboardA11y || !store.autoPanOnNodeFocus || !nodeRef()?.matches(":focus-visible")) return;
|
|
1181
1145
|
let { width, height, viewport } = store;
|
|
@@ -1225,49 +1189,62 @@ const NodeWrapper = (props) => {
|
|
|
1225
1189
|
},
|
|
1226
1190
|
get children() {
|
|
1227
1191
|
var _el$ = _tmpl$$27();
|
|
1228
|
-
return
|
|
1229
|
-
node: userNode(),
|
|
1230
|
-
event
|
|
1231
|
-
}), _el$.$$pointermove = (event) => props.onNodePointerMove?.({
|
|
1232
|
-
node: userNode(),
|
|
1233
|
-
event
|
|
1234
|
-
}), _el$.addEventListener("pointerleave", (event) => props.onNodePointerLeave?.({
|
|
1235
|
-
node: userNode(),
|
|
1236
|
-
event
|
|
1237
|
-
})), _el$.addEventListener("pointerenter", (event) => props.onNodePointerEnter?.({
|
|
1238
|
-
node: userNode(),
|
|
1239
|
-
event
|
|
1240
|
-
})), _el$.$$click = onSelectNodeHandler, use(setNodeRef, _el$), spread(_el$, mergeProps({
|
|
1192
|
+
return ref(() => setNodeRef, _el$), spread(_el$, mergeProps({
|
|
1241
1193
|
get "data-id"() {
|
|
1242
1194
|
return node().id;
|
|
1243
1195
|
},
|
|
1244
1196
|
get class() {
|
|
1245
|
-
return
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1197
|
+
return [
|
|
1198
|
+
"solid-flow__node",
|
|
1199
|
+
`solid-flow__node-${nodeType()}`,
|
|
1200
|
+
{
|
|
1201
|
+
connectable: !!connectable(),
|
|
1202
|
+
draggable: !!draggable(),
|
|
1203
|
+
dragging: dragging(),
|
|
1204
|
+
nopan: !!draggable(),
|
|
1205
|
+
parent: isParentNode(),
|
|
1206
|
+
selectable: !!selectable(),
|
|
1207
|
+
selected: !!node().selected
|
|
1208
|
+
},
|
|
1209
|
+
node().class
|
|
1210
|
+
];
|
|
1254
1211
|
},
|
|
1255
1212
|
get style() {
|
|
1256
1213
|
return style();
|
|
1257
1214
|
},
|
|
1258
|
-
|
|
1215
|
+
onClick: onSelectNodeHandler,
|
|
1216
|
+
onPointerEnter: (event) => props.onNodePointerEnter?.({
|
|
1217
|
+
node: userNode(),
|
|
1218
|
+
event
|
|
1219
|
+
}),
|
|
1220
|
+
onPointerLeave: (event) => props.onNodePointerLeave?.({
|
|
1221
|
+
node: userNode(),
|
|
1222
|
+
event
|
|
1223
|
+
}),
|
|
1224
|
+
onPointerMove: (event) => props.onNodePointerMove?.({
|
|
1225
|
+
node: userNode(),
|
|
1226
|
+
event
|
|
1227
|
+
}),
|
|
1228
|
+
onContextMenu: (event) => props.onNodeContextMenu?.({
|
|
1229
|
+
node: userNode(),
|
|
1230
|
+
event
|
|
1231
|
+
}),
|
|
1232
|
+
onKeyDown: (e) => focusable() && onKeyDown(e),
|
|
1233
|
+
onFocus: () => focusable() && onFocus(),
|
|
1234
|
+
get tabindex() {
|
|
1259
1235
|
return focusable() ? 0 : void 0;
|
|
1260
1236
|
},
|
|
1261
1237
|
get role() {
|
|
1262
1238
|
return node().ariaRole ?? (focusable() ? "group" : void 0);
|
|
1263
1239
|
},
|
|
1240
|
+
"aria-roledescription": "node",
|
|
1264
1241
|
get "aria-describedby"() {
|
|
1265
1242
|
return store.disableKeyboardA11y ? void 0 : `${ARIA_NODE_DESC_KEY}-${store.id}`;
|
|
1266
1243
|
}
|
|
1267
|
-
}, () => node().domAttributes), !
|
|
1244
|
+
}, () => node().domAttributes), !0), insert(_el$, createComponent(NodeIdContext, {
|
|
1268
1245
|
value: nodeId,
|
|
1269
1246
|
get children() {
|
|
1270
|
-
return createComponent(NodeConnectableContext
|
|
1247
|
+
return createComponent(NodeConnectableContext, {
|
|
1271
1248
|
value: connectable,
|
|
1272
1249
|
get children() {
|
|
1273
1250
|
return createComponent(Dynamic, {
|
|
@@ -1335,17 +1312,8 @@ const NodeWrapper = (props) => {
|
|
|
1335
1312
|
})), _el$;
|
|
1336
1313
|
}
|
|
1337
1314
|
});
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
"click",
|
|
1341
|
-
"pointermove",
|
|
1342
|
-
"contextmenu",
|
|
1343
|
-
"keydown"
|
|
1344
|
-
]);
|
|
1345
|
-
//#endregion
|
|
1346
|
-
//#region src/components/graph/node/OutputNode.tsx
|
|
1347
|
-
const OutputNode = (props) => {
|
|
1348
|
-
let _props = mergeProps$1({ targetPosition: "top" }, props);
|
|
1315
|
+
}, OutputNode = (props) => {
|
|
1316
|
+
let _props = propDefaults(props, { targetPosition: Position$1.Top });
|
|
1349
1317
|
return [createComponent(Handle, {
|
|
1350
1318
|
type: "target",
|
|
1351
1319
|
get position() {
|
|
@@ -1495,24 +1463,20 @@ function calculateChildXYZ(childNode, parentNode, nodeOrigin, nodeExtent, select
|
|
|
1495
1463
|
* @param handleId handleId of the conneciton
|
|
1496
1464
|
*/
|
|
1497
1465
|
function addConnectionToLookup(type, connection, connectionKey, connectionLookup, nodeId, handleId) {
|
|
1498
|
-
let
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
let handleMap = connectionLookup.get(key) || /* @__PURE__ */ new Map();
|
|
1504
|
-
connectionLookup.set(key, handleMap.set(connectionKey, connection));
|
|
1505
|
-
}
|
|
1466
|
+
let add = (key) => {
|
|
1467
|
+
let next = new Map(untrack(() => connectionLookup.get(key)));
|
|
1468
|
+
next.set(connectionKey, connection), connectionLookup.set(key, next);
|
|
1469
|
+
};
|
|
1470
|
+
add(nodeId), add(`${nodeId}-${type}`), handleId && add(`${nodeId}-${type}-${handleId}`);
|
|
1506
1471
|
}
|
|
1507
1472
|
function removeConnectionFromLookup(type, connectionKey, connectionLookup, nodeId, handleId) {
|
|
1508
|
-
let
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
key
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1473
|
+
let remove = (key) => {
|
|
1474
|
+
let current = untrack(() => connectionLookup.get(key));
|
|
1475
|
+
if (!current) return;
|
|
1476
|
+
let next = new Map(current);
|
|
1477
|
+
next.delete(connectionKey), next.size === 0 ? connectionLookup.delete(key) : connectionLookup.set(key, next);
|
|
1478
|
+
};
|
|
1479
|
+
remove(nodeId), remove(`${nodeId}-${type}`), handleId && remove(`${nodeId}-${type}-${handleId}`);
|
|
1516
1480
|
}
|
|
1517
1481
|
//#endregion
|
|
1518
1482
|
//#region src/data/createSolidFlow.tsx
|
|
@@ -1537,22 +1501,30 @@ const InitialNodeTypesMap = {
|
|
|
1537
1501
|
zoom: 1
|
|
1538
1502
|
};
|
|
1539
1503
|
}, createSolidFlow = (props) => {
|
|
1540
|
-
let _props =
|
|
1504
|
+
let _props = merge(getDefaultFlowStateProps(), props), nodeLookup = new ReactiveMap(), parentLookup = new ReactiveMap(), edgeLookup = new ReactiveMap(), connectionLookup = new ReactiveMap(), layoutedEdgesMap = new ReactiveMap(), startNodesInitialized = untrack(() => adoptUserNodes(_props.nodes, nodeLookup, parentLookup, {
|
|
1541
1505
|
nodeExtent: _props.nodeExtent,
|
|
1542
1506
|
nodeOrigin: _props.nodeOrigin,
|
|
1543
1507
|
elevateNodesOnSelect: _props.elevateNodesOnSelect,
|
|
1544
1508
|
zIndexMode: _props.zIndexMode,
|
|
1545
1509
|
checkEquality: !0
|
|
1546
|
-
})), initialViewport = getInitialViewport(startNodesInitialized, _props.fitView, _props.initialViewport, _props.width ?? 0, _props.height ?? 0, nodeLookup), mediaPrefersDark = createMediaQuery("(prefers-color-scheme: dark)", _props.colorModeSSR === "dark"), [config, setConfig] = createSignal(_props), [ariaLabelConfig, setAriaLabelConfig] =
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1510
|
+
})), initialViewport = getInitialViewport(startNodesInitialized, _props.fitView, _props.initialViewport, _props.width ?? 0, _props.height ?? 0, nodeLookup), mediaPrefersDark = createMediaQuery("(prefers-color-scheme: dark)", _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), [nodesStore, setNodesStore] = createStore(_props.nodes), [edgesStore, setEdgesStore] = createStore(_props.edges), [viewportStore, setViewportStore] = createStore(_props.viewport ?? initialViewport);
|
|
1511
|
+
createEffect(() => config().nodes, (next) => {
|
|
1512
|
+
setNodesStore(() => next);
|
|
1513
|
+
}, { defer: !0 }), createEffect(() => config().edges, (next) => {
|
|
1514
|
+
setEdgesStore(() => next);
|
|
1515
|
+
}, { defer: !0 }), createEffect(() => config().viewport, (next) => {
|
|
1516
|
+
next && setViewportStore(() => next);
|
|
1517
|
+
}, { defer: !0 });
|
|
1518
|
+
let transform = createMemo(() => [
|
|
1519
|
+
viewportStore.x,
|
|
1520
|
+
viewportStore.y,
|
|
1521
|
+
viewportStore.zoom
|
|
1550
1522
|
]), nodesInitialized = createMemo(() => {
|
|
1551
|
-
let nodes =
|
|
1523
|
+
let nodes = nodesStore;
|
|
1552
1524
|
if (nodes.length === 0) return !1;
|
|
1553
1525
|
for (let node of nodes) if (!node.hidden && (node.measured?.width === void 0 || node.measured?.height === void 0)) return !1;
|
|
1554
1526
|
return !0;
|
|
1555
|
-
}), store =
|
|
1527
|
+
}), store = merge({
|
|
1556
1528
|
width: 0,
|
|
1557
1529
|
height: 0
|
|
1558
1530
|
}, config, {
|
|
@@ -1620,8 +1592,11 @@ const InitialNodeTypesMap = {
|
|
|
1620
1592
|
get minZoom() {
|
|
1621
1593
|
return minZoom();
|
|
1622
1594
|
},
|
|
1595
|
+
get edges() {
|
|
1596
|
+
return edgesStore;
|
|
1597
|
+
},
|
|
1623
1598
|
get nodes() {
|
|
1624
|
-
return
|
|
1599
|
+
return nodesStore;
|
|
1625
1600
|
},
|
|
1626
1601
|
get nodesConnectable() {
|
|
1627
1602
|
return nodesConnectable();
|
|
@@ -1639,10 +1614,10 @@ const InitialNodeTypesMap = {
|
|
|
1639
1614
|
return panZoom();
|
|
1640
1615
|
},
|
|
1641
1616
|
get selectedNodes() {
|
|
1642
|
-
return
|
|
1617
|
+
return nodesStore.filter((node) => node.selected);
|
|
1643
1618
|
},
|
|
1644
1619
|
get selectedEdges() {
|
|
1645
|
-
return
|
|
1620
|
+
return edgesStore.filter((edge) => edge.selected);
|
|
1646
1621
|
},
|
|
1647
1622
|
get selectionRect() {
|
|
1648
1623
|
return selectionRect();
|
|
@@ -1654,7 +1629,7 @@ const InitialNodeTypesMap = {
|
|
|
1654
1629
|
return snapGrid();
|
|
1655
1630
|
},
|
|
1656
1631
|
get viewport() {
|
|
1657
|
-
return
|
|
1632
|
+
return viewportStore;
|
|
1658
1633
|
},
|
|
1659
1634
|
get viewportInitialized() {
|
|
1660
1635
|
return panZoom() !== null;
|
|
@@ -1703,28 +1678,31 @@ const InitialNodeTypesMap = {
|
|
|
1703
1678
|
minZoom: store.minZoom,
|
|
1704
1679
|
maxZoom: store.maxZoom
|
|
1705
1680
|
}, options ?? config().fitViewOptions) : !1, resetStoreValues = () => {
|
|
1706
|
-
setDragging(!1), setSelectionRect(void 0), setSelectionRectMode(void 0), setSelectionKeyPressed(!1), setMultiselectionKeyPressed(!1), setDeleteKeyPressed(!1), setPanActivationKeyPressed(!1), setZoomActivationKeyPressed(!1), setConnection({ ...initialConnection }), setClickConnectStartHandle(void 0),
|
|
1681
|
+
setDragging(!1), setSelectionRect(void 0), setSelectionRectMode(void 0), setSelectionKeyPressed(!1), setMultiselectionKeyPressed(!1), setDeleteKeyPressed(!1), setPanActivationKeyPressed(!1), setZoomActivationKeyPressed(!1), setConnection({ ...initialConnection }), setClickConnectStartHandle(void 0), setViewportStore(() => config().initialViewport ?? {
|
|
1707
1682
|
x: 0,
|
|
1708
1683
|
y: 0,
|
|
1709
1684
|
zoom: 1
|
|
1710
1685
|
}), setAriaLiveMessage(""), setSnapGrid(void 0);
|
|
1711
1686
|
}, addEdge = (edgeParams) => {
|
|
1712
|
-
|
|
1687
|
+
setEdgesStore((edges) => {
|
|
1688
|
+
let next = addEdge$1(edgeParams, edges);
|
|
1689
|
+
next !== edges && edges.push(next[next.length - 1]);
|
|
1690
|
+
});
|
|
1713
1691
|
}, initialFitViewApplied = !1, initialNodesMeasured = !1, applyInitialFitView = (initialFitView) => {
|
|
1714
1692
|
initialFitViewApplied = !initialFitView;
|
|
1715
1693
|
}, tryInitialFitView = () => {
|
|
1716
1694
|
initialFitViewApplied || !initialNodesMeasured || untrack(() => store.panZoom && store.width && store.height) && (initialFitViewApplied = !0, untrack(() => fitView()));
|
|
1717
1695
|
}, updateNodePositions = (nodeDragItems, dragging = !1) => {
|
|
1718
|
-
|
|
1719
|
-
node.dragging = dragging, node.position = nodeDragItems.get(node.id).position;
|
|
1720
|
-
})
|
|
1696
|
+
setNodesStore((nodes) => {
|
|
1697
|
+
for (let node of nodes) nodeDragItems.has(node.id) && (node.dragging = dragging, node.position = nodeDragItems.get(node.id).position);
|
|
1698
|
+
});
|
|
1721
1699
|
}, pendingEntries, requestUpdateNodeInternals = (updateEntries) => {
|
|
1722
1700
|
if (pendingEntries) {
|
|
1723
1701
|
pendingEntries.push(...updateEntries);
|
|
1724
1702
|
return;
|
|
1725
1703
|
}
|
|
1726
1704
|
pendingEntries = updateEntries, scheduleIdleCallback(() => {
|
|
1727
|
-
|
|
1705
|
+
{
|
|
1728
1706
|
let updates = new Map(pendingEntries);
|
|
1729
1707
|
pendingEntries = void 0;
|
|
1730
1708
|
let { changes, updatedInternals } = updateNodeInternals(updates, nodeLookup, parentLookup, store.domNode, store.nodeOrigin);
|
|
@@ -1738,19 +1716,21 @@ const InitialNodeTypesMap = {
|
|
|
1738
1716
|
let node = nodeLookup.get(change.id)?.internals.userNode;
|
|
1739
1717
|
return node && acc.set(node.id, change), acc;
|
|
1740
1718
|
}, /* @__PURE__ */ new Map());
|
|
1741
|
-
|
|
1742
|
-
let
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1719
|
+
setNodesStore((nodes) => {
|
|
1720
|
+
for (let node of nodes) {
|
|
1721
|
+
let change = nodeToChange.get(node.id);
|
|
1722
|
+
if (change) switch (change.type) {
|
|
1723
|
+
case "dimensions":
|
|
1724
|
+
change.setAttributes && (node.width = change.dimensions?.width ?? node.width, node.height = change.dimensions?.height ?? node.height), node.measured = {
|
|
1725
|
+
...node.measured,
|
|
1726
|
+
...change.dimensions
|
|
1727
|
+
};
|
|
1728
|
+
break;
|
|
1729
|
+
case "position": node.position = change.position ?? node.position;
|
|
1730
|
+
}
|
|
1751
1731
|
}
|
|
1752
|
-
})), initialNodesMeasured = !0, tryInitialFitView();
|
|
1753
|
-
}
|
|
1732
|
+
}), flush(), initialNodesMeasured = !0, tryInitialFitView();
|
|
1733
|
+
}
|
|
1754
1734
|
});
|
|
1755
1735
|
}, zoomBy = async (factor, options) => store.panZoom ? store.panZoom.scaleBy(factor, options) : !1, zoomIn = (options) => zoomBy(1.2, options), zoomOut = (options) => zoomBy(1 / 1.2, options), setCenter = async (x, y, options) => {
|
|
1756
1736
|
let nextZoom = options?.zoom === void 0 ? store.maxZoom : options.zoom, currentPanZoom = store.panZoom;
|
|
@@ -1767,44 +1747,55 @@ const InitialNodeTypesMap = {
|
|
|
1767
1747
|
store.panZoom?.setClickDistance(distance);
|
|
1768
1748
|
}, unselectNodesAndEdges = ({ nodes: _nodes, edges } = {}) => {
|
|
1769
1749
|
let nodesToUnselect = new Set((_nodes || store.nodes).map(({ id }) => id));
|
|
1770
|
-
nodesToUnselect.size &&
|
|
1771
|
-
node.selected = !1;
|
|
1772
|
-
})
|
|
1773
|
-
let edgesToUnselect = new Set((edges
|
|
1774
|
-
edgesToUnselect.size &&
|
|
1775
|
-
edge.selected = !1;
|
|
1776
|
-
})
|
|
1750
|
+
nodesToUnselect.size && setNodesStore((nodes) => {
|
|
1751
|
+
for (let node of nodes) nodesToUnselect.has(node.id) && (node.selected = !1);
|
|
1752
|
+
});
|
|
1753
|
+
let edgesToUnselect = new Set((edges ?? store.edges).map(({ id }) => id));
|
|
1754
|
+
edgesToUnselect.size && setEdgesStore((edges) => {
|
|
1755
|
+
for (let edge of edges) edgesToUnselect.has(edge.id) && (edge.selected = !1);
|
|
1756
|
+
});
|
|
1777
1757
|
}, addSelectedNodes = (ids) => {
|
|
1778
1758
|
let isMultiSelection = store.multiselectionKeyPressed, selectState = /* @__PURE__ */ new Map();
|
|
1779
|
-
|
|
1780
|
-
let
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1759
|
+
setNodesStore((nodes) => {
|
|
1760
|
+
for (let node of nodes) {
|
|
1761
|
+
let nodeWillBeSelected = ids.includes(node.id), selected = isMultiSelection && node.selected || nodeWillBeSelected;
|
|
1762
|
+
if (selectState.set(node.id, selected), node.selected === selected) continue;
|
|
1763
|
+
let internalNode = nodeLookup.get(node.id);
|
|
1764
|
+
internalNode && (internalNode.selected = selected), node.selected = selected;
|
|
1765
|
+
}
|
|
1766
|
+
}), isMultiSelection || unselectNodesAndEdges({ nodes: [] });
|
|
1786
1767
|
}, addSelectedEdges = (ids) => {
|
|
1787
1768
|
let isMultiSelection = store.multiselectionKeyPressed, edgeSelectState = /* @__PURE__ */ new Map();
|
|
1788
|
-
|
|
1789
|
-
let
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
})
|
|
1769
|
+
setEdgesStore((edges) => {
|
|
1770
|
+
for (let edge of edges) {
|
|
1771
|
+
let edgeWillBeSelected = ids.includes(edge.id), selected = isMultiSelection && edge.selected || edgeWillBeSelected;
|
|
1772
|
+
edgeSelectState.set(edge.id, selected), edge.selected !== selected && (edge.selected = selected);
|
|
1773
|
+
}
|
|
1774
|
+
}), isMultiSelection || unselectNodesAndEdges({ edges: [] });
|
|
1794
1775
|
};
|
|
1795
|
-
return createEffect(() => {
|
|
1796
|
-
|
|
1797
|
-
}), createEffect(() => {
|
|
1798
|
-
store.panZoom
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
}),
|
|
1807
|
-
|
|
1776
|
+
return createEffect(() => !!(width() && height() && panZoom()), (ready) => {
|
|
1777
|
+
ready && tryInitialFitView();
|
|
1778
|
+
}), createEffect(() => ({
|
|
1779
|
+
panZoom: store.panZoom,
|
|
1780
|
+
viewport: {
|
|
1781
|
+
x: store.viewport.x,
|
|
1782
|
+
y: store.viewport.y,
|
|
1783
|
+
zoom: store.viewport.zoom
|
|
1784
|
+
}
|
|
1785
|
+
}), ({ panZoom, viewport }) => {
|
|
1786
|
+
panZoom?.syncViewport(viewport);
|
|
1787
|
+
}), createEffect(() => ({
|
|
1788
|
+
panZoom: panZoom(),
|
|
1789
|
+
extent: [store.minZoom, store.maxZoom]
|
|
1790
|
+
}), ({ panZoom, extent }) => {
|
|
1791
|
+
panZoom?.setScaleExtent(extent);
|
|
1792
|
+
}), createEffect(() => ({
|
|
1793
|
+
panZoom: panZoom(),
|
|
1794
|
+
extent: store.translateExtent
|
|
1795
|
+
}), ({ panZoom, extent }) => {
|
|
1796
|
+
panZoom?.setTranslateExtent(extent);
|
|
1797
|
+
}), createRenderEffect(mapArray(() => store.nodes, (userNode) => {
|
|
1798
|
+
createRenderEffect(() => {
|
|
1808
1799
|
let internalNode = untrack(() => nodeLookup.get(userNode.id)), selectedNodeZ = store.elevateNodesOnSelect && store.zIndexMode !== "manual" ? 1e3 : 0, clampedPosition = clampPosition(getNodePositionWithOrigin(userNode, store.nodeOrigin), isCoordinateExtent(userNode.extent) ? userNode.extent : store.nodeExtent, getNodeDimensions(userNode)), preservedMeasured = {
|
|
1809
1800
|
width: userNode.measured?.width ?? internalNode?.measured?.width,
|
|
1810
1801
|
height: userNode.measured?.height ?? internalNode?.measured?.height
|
|
@@ -1825,11 +1816,10 @@ const InitialNodeTypesMap = {
|
|
|
1825
1816
|
zIndexMode: store.zIndexMode,
|
|
1826
1817
|
checkEquality: !0
|
|
1827
1818
|
});
|
|
1828
|
-
}), onCleanup(() => {});
|
|
1829
|
-
})), createEffect(() => {
|
|
1830
|
-
let
|
|
1831
|
-
|
|
1832
|
-
}), createComputed(mapArray(() => store.edges, (edge) => {
|
|
1819
|
+
}, () => {}), onCleanup(() => {});
|
|
1820
|
+
}), () => {}), createEffect(() => new Set(store.nodes.map((n) => n.id)), (currentIds) => {
|
|
1821
|
+
for (let id of untrack(() => Array.from(nodeLookup.keys()))) currentIds.has(id) || nodeLookup.delete(id);
|
|
1822
|
+
}), createRenderEffect(mapArray(() => store.edges, (edge) => {
|
|
1833
1823
|
let { source: sourceNodeId, target: targetNodeId, sourceHandle = null, targetHandle = null } = edge, connection = {
|
|
1834
1824
|
edgeId: edge.id,
|
|
1835
1825
|
source: sourceNodeId,
|
|
@@ -1837,11 +1827,9 @@ const InitialNodeTypesMap = {
|
|
|
1837
1827
|
sourceHandle,
|
|
1838
1828
|
targetHandle
|
|
1839
1829
|
}, sourceKey = `${sourceNodeId}-${sourceHandle}--${targetNodeId}-${targetHandle}`, targetKey = `${targetNodeId}-${targetHandle}--${sourceNodeId}-${sourceHandle}`;
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
});
|
|
1844
|
-
}), createComputed(() => {
|
|
1830
|
+
createRenderEffect(() => {
|
|
1831
|
+
addConnectionToLookup("source", connection, targetKey, connectionLookup, sourceNodeId, sourceHandle), addConnectionToLookup("target", connection, sourceKey, connectionLookup, targetNodeId, targetHandle), edgeLookup.set(edge.id, edge);
|
|
1832
|
+
}, () => {}), createRenderEffect(() => {
|
|
1845
1833
|
let sourceNode = nodeLookup.get(edge.source), targetNode = nodeLookup.get(edge.target);
|
|
1846
1834
|
if (!sourceNode || !targetNode) return;
|
|
1847
1835
|
if (store.onlyRenderVisibleElements) {
|
|
@@ -1879,14 +1867,11 @@ const InitialNodeTypesMap = {
|
|
|
1879
1867
|
targetNode,
|
|
1880
1868
|
edge
|
|
1881
1869
|
});
|
|
1882
|
-
}), onCleanup(() => {
|
|
1883
|
-
|
|
1884
|
-
edgeLookup.delete(edge.id), layoutedEdgesMap.delete(edge.id), removeConnectionFromLookup("source", targetKey, connectionLookup, sourceNodeId, sourceHandle), removeConnectionFromLookup("target", sourceKey, connectionLookup, targetNodeId, targetHandle);
|
|
1885
|
-
});
|
|
1870
|
+
}, () => {}), onCleanup(() => {
|
|
1871
|
+
edgeLookup.delete(edge.id), layoutedEdgesMap.delete(edge.id), removeConnectionFromLookup("source", targetKey, connectionLookup, sourceNodeId, sourceHandle), removeConnectionFromLookup("target", sourceKey, connectionLookup, targetNodeId, targetHandle);
|
|
1886
1872
|
});
|
|
1887
|
-
})), createEffect(() => {
|
|
1888
|
-
let
|
|
1889
|
-
for (let id of Array.from(edgeLookup.keys())) currentIds.has(id) || (edgeLookup.delete(id), connectionLookup.delete(id), layoutedEdgesMap.delete(id));
|
|
1873
|
+
}), () => {}), createEffect(() => new Set(store.edges.map((e) => e.id)), (currentIds) => {
|
|
1874
|
+
for (let id of untrack(() => Array.from(edgeLookup.keys()))) currentIds.has(id) || (edgeLookup.delete(id), connectionLookup.delete(id), layoutedEdgesMap.delete(id));
|
|
1890
1875
|
}), {
|
|
1891
1876
|
store,
|
|
1892
1877
|
nodeLookup,
|
|
@@ -1907,13 +1892,13 @@ const InitialNodeTypesMap = {
|
|
|
1907
1892
|
setDomNode,
|
|
1908
1893
|
setDragging,
|
|
1909
1894
|
get setEdges() {
|
|
1910
|
-
return
|
|
1895
|
+
return setEdgesStore;
|
|
1911
1896
|
},
|
|
1912
1897
|
setElementsSelectable,
|
|
1913
1898
|
setHeight,
|
|
1914
1899
|
setMultiselectionKeyPressed,
|
|
1915
1900
|
get setNodes() {
|
|
1916
|
-
return
|
|
1901
|
+
return setNodesStore;
|
|
1917
1902
|
},
|
|
1918
1903
|
setNodesConnectable,
|
|
1919
1904
|
setNodesDraggable,
|
|
@@ -1923,7 +1908,7 @@ const InitialNodeTypesMap = {
|
|
|
1923
1908
|
setSelectionRect,
|
|
1924
1909
|
setSelectionRectMode,
|
|
1925
1910
|
get setViewport() {
|
|
1926
|
-
return
|
|
1911
|
+
return (viewport) => setViewportStore(() => viewport);
|
|
1927
1912
|
},
|
|
1928
1913
|
setWidth,
|
|
1929
1914
|
setZoomActivationKeyPressed,
|
|
@@ -1939,18 +1924,14 @@ const InitialNodeTypesMap = {
|
|
|
1939
1924
|
addSelectedEdges,
|
|
1940
1925
|
handleNodeSelection: (id, unselect, nodeRef) => {
|
|
1941
1926
|
let node = store.nodes.find((n) => n.id === id);
|
|
1942
|
-
node && (
|
|
1943
|
-
setSelectionRect(void 0), setSelectionRectMode(void 0);
|
|
1944
|
-
}), node.selected ? (unselect || node.selected && store.multiselectionKeyPressed) && (unselectNodesAndEdges({
|
|
1927
|
+
node && (setSelectionRect(void 0), setSelectionRectMode(void 0), node.selected ? (unselect || node.selected && store.multiselectionKeyPressed) && (unselectNodesAndEdges({
|
|
1945
1928
|
nodes: [node],
|
|
1946
1929
|
edges: []
|
|
1947
1930
|
}), requestAnimationFrame(() => nodeRef?.blur())) : addSelectedNodes([id]));
|
|
1948
1931
|
},
|
|
1949
1932
|
handleEdgeSelection: (id) => {
|
|
1950
1933
|
let edge = edgeLookup.get(id);
|
|
1951
|
-
edge && (edge.selectable || store.elementsSelectable && edge.selectable === void 0) && (
|
|
1952
|
-
setSelectionRect(void 0), setSelectionRectMode(void 0);
|
|
1953
|
-
}), edge.selected ? edge.selected && store.multiselectionKeyPressed && unselectNodesAndEdges({
|
|
1934
|
+
edge && (edge.selectable || store.elementsSelectable && edge.selectable === void 0) && (setSelectionRect(void 0), setSelectionRectMode(void 0), edge.selected ? edge.selected && store.multiselectionKeyPressed && unselectNodesAndEdges({
|
|
1954
1935
|
nodes: [],
|
|
1955
1936
|
edges: [edge]
|
|
1956
1937
|
}) : addSelectedEdges([id]));
|
|
@@ -1992,7 +1973,7 @@ const InitialNodeTypesMap = {
|
|
|
1992
1973
|
}
|
|
1993
1974
|
}
|
|
1994
1975
|
};
|
|
1995
|
-
}, SolidFlowContext = createContext();
|
|
1976
|
+
}, SolidFlowContext = createContext(null);
|
|
1996
1977
|
function useInternalSolidFlow() {
|
|
1997
1978
|
let ctx = useContext(SolidFlowContext);
|
|
1998
1979
|
if (!ctx) throw Error("solid-flow: Your application must be wrapped with <SolidFlow> in order to invoke useInternalSolidFlow within your components");
|
|
@@ -2000,59 +1981,52 @@ function useInternalSolidFlow() {
|
|
|
2000
1981
|
}
|
|
2001
1982
|
//#endregion
|
|
2002
1983
|
//#region src/components/graph/marker/Marker.tsx
|
|
2003
|
-
var _tmpl$$26 =
|
|
1984
|
+
var _tmpl$$26 = /* @__PURE__ */ template("<svg><polyline class=arrow fill=none stroke-linecap=round stroke-linejoin=round points=\"-5,-4 0,0 -5,4\"></svg>", 2), _tmpl$2$2 = /* @__PURE__ */ template("<svg><marker class=solid-flow__arrowhead viewBox=\"-10 -10 20 20\"refX=0 refY=0></svg>", 2), _tmpl$3$1 = /* @__PURE__ */ template("<svg><polyline class=arrowclosed stroke-linecap=round stroke-linejoin=round points=\"-5,-4 0,0 -5,4 -5,-4\"></svg>", 2);
|
|
2004
1985
|
const Marker = (props) => {
|
|
2005
|
-
let _props =
|
|
1986
|
+
let _props = propDefaults(props, {
|
|
2006
1987
|
markerUnits: "strokeWidth",
|
|
2007
1988
|
orient: "auto-start-reverse",
|
|
2008
1989
|
width: 12.5,
|
|
2009
1990
|
height: 12.5,
|
|
2010
1991
|
color: "none"
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
e: void 0,
|
|
2046
|
-
t: void 0,
|
|
2047
|
-
a: void 0,
|
|
2048
|
-
o: void 0,
|
|
2049
|
-
i: void 0
|
|
2050
|
-
}), _el$;
|
|
2051
|
-
})();
|
|
1992
|
+
}), color = () => _props.color ?? "var(--xy-edge-stroke)";
|
|
1993
|
+
var _el$ = _tmpl$2$2();
|
|
1994
|
+
return insert(_el$, createComponent(Show, {
|
|
1995
|
+
get when() {
|
|
1996
|
+
return _props.type === "arrow";
|
|
1997
|
+
},
|
|
1998
|
+
get fallback() {
|
|
1999
|
+
var _el$3 = _tmpl$3$1();
|
|
2000
|
+
return effect(() => ({
|
|
2001
|
+
e: color(),
|
|
2002
|
+
t: color(),
|
|
2003
|
+
a: _props.strokeWidth
|
|
2004
|
+
}), ({ e, t, a }, _p$) => {
|
|
2005
|
+
e !== _p$?.e && setAttribute(_el$3, "stroke", e), t !== _p$?.t && setAttribute(_el$3, "fill", t), a !== _p$?.a && setAttribute(_el$3, "stroke-width", a);
|
|
2006
|
+
}), _el$3;
|
|
2007
|
+
},
|
|
2008
|
+
get children() {
|
|
2009
|
+
var _el$2 = _tmpl$$26();
|
|
2010
|
+
return effect(() => ({
|
|
2011
|
+
e: color(),
|
|
2012
|
+
t: _props.strokeWidth
|
|
2013
|
+
}), ({ e, t }, _p$) => {
|
|
2014
|
+
e !== _p$?.e && setAttribute(_el$2, "stroke", e), t !== _p$?.t && setAttribute(_el$2, "stroke-width", t);
|
|
2015
|
+
}), _el$2;
|
|
2016
|
+
}
|
|
2017
|
+
})), effect(() => ({
|
|
2018
|
+
e: _props.id,
|
|
2019
|
+
t: _props.width,
|
|
2020
|
+
a: _props.height,
|
|
2021
|
+
o: _props.markerUnits,
|
|
2022
|
+
i: _props.orient
|
|
2023
|
+
}), ({ e, t, a, o, i }, _p$) => {
|
|
2024
|
+
e !== _p$?.e && setAttribute(_el$, "id", e), t !== _p$?.t && setAttribute(_el$, "markerWidth", t), a !== _p$?.a && setAttribute(_el$, "markerHeight", a), o !== _p$?.o && setAttribute(_el$, "markerUnits", o), i !== _p$?.i && setAttribute(_el$, "orient", i);
|
|
2025
|
+
}), _el$;
|
|
2052
2026
|
};
|
|
2053
2027
|
//#endregion
|
|
2054
2028
|
//#region src/components/graph/marker/MarkerDefinition.tsx
|
|
2055
|
-
var _tmpl$$25 =
|
|
2029
|
+
var _tmpl$$25 = /* @__PURE__ */ template("<svg class=solid-flow__marker><defs>");
|
|
2056
2030
|
const MarkerDefinition = () => {
|
|
2057
2031
|
let { store } = useInternalSolidFlow(), markers = createMemo(() => createMarkerIds(store.edges, {
|
|
2058
2032
|
id: store.id,
|
|
@@ -2077,36 +2051,34 @@ const MarkerDefinition = () => {
|
|
|
2077
2051
|
};
|
|
2078
2052
|
//#endregion
|
|
2079
2053
|
//#region src/components/container/EdgeRenderer.tsx
|
|
2080
|
-
var _tmpl$$24 =
|
|
2054
|
+
var _tmpl$$24 = /* @__PURE__ */ template("<div class=solid-flow__edges><!><!>");
|
|
2081
2055
|
const EdgeRenderer = (props) => {
|
|
2082
2056
|
let { store } = useInternalSolidFlow();
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2057
|
+
var _el$ = _tmpl$$24(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
|
|
2058
|
+
return insert(_el$, createComponent(MarkerDefinition, {}), _el$2), insert(_el$, createComponent(For, {
|
|
2059
|
+
get each() {
|
|
2060
|
+
return store.visibleEdgeIds;
|
|
2061
|
+
},
|
|
2062
|
+
children: (edgeId) => createComponent(EdgeWrapper, {
|
|
2063
|
+
edgeId,
|
|
2064
|
+
get onEdgeClick() {
|
|
2065
|
+
return props.onEdgeClick;
|
|
2088
2066
|
},
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
get onEdgePointerLeave() {
|
|
2101
|
-
return props.onEdgePointerLeave;
|
|
2102
|
-
}
|
|
2103
|
-
})
|
|
2104
|
-
}), null), _el$;
|
|
2105
|
-
})();
|
|
2067
|
+
get onEdgeContextMenu() {
|
|
2068
|
+
return props.onEdgeContextMenu;
|
|
2069
|
+
},
|
|
2070
|
+
get onEdgePointerEnter() {
|
|
2071
|
+
return props.onEdgePointerEnter;
|
|
2072
|
+
},
|
|
2073
|
+
get onEdgePointerLeave() {
|
|
2074
|
+
return props.onEdgePointerLeave;
|
|
2075
|
+
}
|
|
2076
|
+
})
|
|
2077
|
+
}), _el$3), _el$;
|
|
2106
2078
|
};
|
|
2107
2079
|
//#endregion
|
|
2108
2080
|
//#region src/components/container/NodeRenderer.tsx
|
|
2109
|
-
var _tmpl$$23 =
|
|
2081
|
+
var _tmpl$$23 = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__nodes\">");
|
|
2110
2082
|
const NodeRenderer = (props) => {
|
|
2111
2083
|
let { actions, store } = useInternalSolidFlow(), resizeObserver = isServer ? void 0 : new ResizeObserver((entries) => {
|
|
2112
2084
|
actions.requestUpdateNodeInternals(entries.map((entry) => {
|
|
@@ -2118,57 +2090,56 @@ const NodeRenderer = (props) => {
|
|
|
2118
2090
|
}];
|
|
2119
2091
|
}));
|
|
2120
2092
|
});
|
|
2121
|
-
|
|
2093
|
+
onCleanup(() => {
|
|
2122
2094
|
resizeObserver?.disconnect();
|
|
2123
|
-
})
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2095
|
+
});
|
|
2096
|
+
var _el$ = _tmpl$$23();
|
|
2097
|
+
return insert(_el$, createComponent(For, {
|
|
2098
|
+
get each() {
|
|
2099
|
+
return store.visibleNodeIds;
|
|
2100
|
+
},
|
|
2101
|
+
children: (nodeId) => createComponent(NodeWrapper, {
|
|
2102
|
+
nodeId,
|
|
2103
|
+
resizeObserver,
|
|
2104
|
+
get nodeClickDistance() {
|
|
2105
|
+
return props.nodeClickDistance;
|
|
2128
2106
|
},
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
},
|
|
2156
|
-
get onNodeContextMenu() {
|
|
2157
|
-
return props.onNodeContextMenu;
|
|
2158
|
-
}
|
|
2159
|
-
})
|
|
2160
|
-
})), _el$;
|
|
2161
|
-
})();
|
|
2107
|
+
get onNodeClick() {
|
|
2108
|
+
return props.onNodeClick;
|
|
2109
|
+
},
|
|
2110
|
+
get onNodePointerEnter() {
|
|
2111
|
+
return props.onNodePointerEnter;
|
|
2112
|
+
},
|
|
2113
|
+
get onNodePointerMove() {
|
|
2114
|
+
return props.onNodePointerMove;
|
|
2115
|
+
},
|
|
2116
|
+
get onNodePointerLeave() {
|
|
2117
|
+
return props.onNodePointerLeave;
|
|
2118
|
+
},
|
|
2119
|
+
get onNodeDrag() {
|
|
2120
|
+
return props.onNodeDrag;
|
|
2121
|
+
},
|
|
2122
|
+
get onNodeDragStart() {
|
|
2123
|
+
return props.onNodeDragStart;
|
|
2124
|
+
},
|
|
2125
|
+
get onNodeDragStop() {
|
|
2126
|
+
return props.onNodeDragStop;
|
|
2127
|
+
},
|
|
2128
|
+
get onNodeContextMenu() {
|
|
2129
|
+
return props.onNodeContextMenu;
|
|
2130
|
+
}
|
|
2131
|
+
})
|
|
2132
|
+
})), _el$;
|
|
2162
2133
|
};
|
|
2163
2134
|
//#endregion
|
|
2164
2135
|
//#region src/components/container/Pane.tsx
|
|
2165
|
-
var _tmpl$$22 =
|
|
2136
|
+
var _tmpl$$22 = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__pane\">");
|
|
2166
2137
|
const isSetEqual = (a, b) => {
|
|
2167
2138
|
if (a.size !== b.size) return !1;
|
|
2168
2139
|
for (let item of a) if (!b.has(item)) return !1;
|
|
2169
2140
|
return !0;
|
|
2170
2141
|
}, Pane = (props) => {
|
|
2171
|
-
let { store, nodeLookup, edgeLookup, connectionLookup, actions } = useInternalSolidFlow(), container, containerBounds = null, connectionEndedOnPane = !1, selectionInProgress = !1, selectedNodeIds = /* @__PURE__ */ new Set(), selectedEdgeIds = /* @__PURE__ */ new Set(), autoPanId = 0, position = {
|
|
2142
|
+
let { store, nodeLookup, edgeLookup, connectionLookup, actions } = useInternalSolidFlow(), [containerRef, setContainerRef] = createSignal(), container, containerBounds = null, connectionEndedOnPane = !1, selectionInProgress = !1, selectedNodeIds = /* @__PURE__ */ new Set(), selectedEdgeIds = /* @__PURE__ */ new Set(), autoPanId = 0, position = {
|
|
2172
2143
|
x: 0,
|
|
2173
2144
|
y: 0
|
|
2174
2145
|
}, autoPanStarted = !1, autoPanOnSelection = () => props.autoPanOnSelection ?? !0, paneClickDistance = () => props.paneClickDistance ?? 1, _panOnDrag = () => store.panActivationKeyPressed || props.panOnDrag, isSelecting = () => store.selectionKeyPressed || !!store.selectionRect || props.selectionOnDrag && _panOnDrag() !== !0, isSelectionEnabled = () => store.elementsSelectable && (isSelecting() || store.selectionRectMode === "user"), onClick = (event) => {
|
|
@@ -2177,9 +2148,7 @@ const isSetEqual = (a, b) => {
|
|
|
2177
2148
|
selectionInProgress = !1, connectionEndedOnPane = !1;
|
|
2178
2149
|
return;
|
|
2179
2150
|
}
|
|
2180
|
-
props.onPaneClick?.({ event }),
|
|
2181
|
-
actions.unselectNodesAndEdges(), actions.setSelectionRectMode(void 0), actions.setSelectionRect(void 0);
|
|
2182
|
-
});
|
|
2151
|
+
props.onPaneClick?.({ event }), actions.unselectNodesAndEdges(), actions.setSelectionRectMode(void 0), actions.setSelectionRect(void 0);
|
|
2183
2152
|
}
|
|
2184
2153
|
}, onPointerDownCapture = (event) => {
|
|
2185
2154
|
if (event.pointerType === "touch" && _panOnDrag() !== !1 && !store.selectionKeyPressed || (containerBounds = container?.getBoundingClientRect() ?? null, !containerBounds)) return;
|
|
@@ -2197,7 +2166,7 @@ const isSetEqual = (a, b) => {
|
|
|
2197
2166
|
startY: userSelectionFlowOrigin.y,
|
|
2198
2167
|
x,
|
|
2199
2168
|
y
|
|
2200
|
-
}), eventTargetIsContainer || (event.stopPropagation(), event.preventDefault());
|
|
2169
|
+
}), flush(), eventTargetIsContainer || (event.stopPropagation(), event.preventDefault());
|
|
2201
2170
|
}, commitUserSelectionRect = (mouseX, mouseY) => {
|
|
2202
2171
|
let selectionRect = store.selectionRect;
|
|
2203
2172
|
if (selectionRect?.startX === void 0 || selectionRect.startY === void 0) return;
|
|
@@ -2222,27 +2191,17 @@ const isSetEqual = (a, b) => {
|
|
|
2222
2191
|
edge && (edge.selectable ?? edgesSelectable) && selectedEdgeIds.add(edgeId);
|
|
2223
2192
|
}
|
|
2224
2193
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
let
|
|
2228
|
-
|
|
2229
|
-
let isSelected = selectedNodeIds.has(node.id);
|
|
2230
|
-
return selectionMap.set(node.id, isSelected), !!node.selected !== isSelected;
|
|
2231
|
-
}, produce((node) => {
|
|
2232
|
-
node.selected = selectionMap.get(node.id);
|
|
2233
|
-
}));
|
|
2194
|
+
isSetEqual(prevSelectedNodeIds, selectedNodeIds) || actions.setNodes((nodes) => {
|
|
2195
|
+
for (let node of nodes) {
|
|
2196
|
+
let isSelected = selectedNodeIds.has(node.id);
|
|
2197
|
+
!!node.selected !== isSelected && (node.selected = isSelected);
|
|
2234
2198
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
return selectionMap.set(edge.id, isSelected), !!edge.selected !== isSelected;
|
|
2240
|
-
}, produce((edge) => {
|
|
2241
|
-
edge.selected = selectionMap.get(edge.id);
|
|
2242
|
-
}));
|
|
2199
|
+
}), isSetEqual(prevSelectedEdgeIds, selectedEdgeIds) || actions.setEdges((edges) => {
|
|
2200
|
+
for (let edge of edges) {
|
|
2201
|
+
let isSelected = selectedEdgeIds.has(edge.id);
|
|
2202
|
+
!!edge.selected !== isSelected && (edge.selected = isSelected);
|
|
2243
2203
|
}
|
|
2244
|
-
|
|
2245
|
-
});
|
|
2204
|
+
}), actions.setSelectionRectMode("user"), actions.setSelectionRect(nextUserSelectRect), flush();
|
|
2246
2205
|
}, autoPan = () => {
|
|
2247
2206
|
if (!autoPanOnSelection() || !containerBounds) return;
|
|
2248
2207
|
let [x = 0, y = 0] = calcAutoPan(position, containerBounds, store.autoPanSpeed);
|
|
@@ -2284,14 +2243,18 @@ const isSetEqual = (a, b) => {
|
|
|
2284
2243
|
event.target === container && store.connection.inProgress && (connectionEndedOnPane = !0);
|
|
2285
2244
|
return;
|
|
2286
2245
|
}
|
|
2287
|
-
event.button === 0 && (event.target?.releasePointerCapture?.(event.pointerId), !selectionInProgress && event.target === container && onClick(event),
|
|
2288
|
-
actions.setSelectionRect(void 0), selectionInProgress && actions.setSelectionRectMode(selectedNodeIds.size > 0 ? "nodes" : void 0);
|
|
2289
|
-
}), selectionInProgress && props.onSelectionEnd?.(event), cleanupAutoPan());
|
|
2246
|
+
event.button === 0 && (event.target?.releasePointerCapture?.(event.pointerId), !selectionInProgress && event.target === container && onClick(event), actions.setSelectionRect(void 0), selectionInProgress && actions.setSelectionRectMode(selectedNodeIds.size > 0 ? "nodes" : void 0), flush(), selectionInProgress && props.onSelectionEnd?.(event), cleanupAutoPan());
|
|
2290
2247
|
}, onPointerCancel = (event) => {
|
|
2291
2248
|
event.target?.releasePointerCapture?.(event.pointerId), cleanupAutoPan();
|
|
2292
2249
|
}, onClickCapture = (event) => {
|
|
2293
2250
|
selectionInProgress &&= (event.stopPropagation(), !1);
|
|
2294
|
-
}
|
|
2251
|
+
};
|
|
2252
|
+
createEventListener(containerRef, "pointerdown", (e) => {
|
|
2253
|
+
isSelectionEnabled() && onPointerDownCapture(e);
|
|
2254
|
+
}, { capture: !0 }), createEventListener(containerRef, "click", (e) => {
|
|
2255
|
+
isSelectionEnabled() && onClickCapture(e);
|
|
2256
|
+
}, { capture: !0 });
|
|
2257
|
+
let onContextMenu = (event) => {
|
|
2295
2258
|
if (event.target !== container) return;
|
|
2296
2259
|
let result = _panOnDrag();
|
|
2297
2260
|
if (Array.isArray(result) && result.includes(2)) {
|
|
@@ -2300,23 +2263,16 @@ const isSetEqual = (a, b) => {
|
|
|
2300
2263
|
}
|
|
2301
2264
|
props.onPaneContextMenu?.({ event });
|
|
2302
2265
|
};
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
}, { capture: !0 });
|
|
2314
|
-
}, _el$), insert(_el$, () => props.children), effect(() => className(_el$, clsx$1("solid-flow__container solid-flow__pane", {
|
|
2315
|
-
selection: isSelecting(),
|
|
2316
|
-
dragging: store.dragging,
|
|
2317
|
-
draggable: props.panOnDrag === !0 || Array.isArray(props.panOnDrag) && props.panOnDrag.includes(0)
|
|
2318
|
-
}))), _el$;
|
|
2319
|
-
})();
|
|
2266
|
+
var _el$ = _tmpl$$22();
|
|
2267
|
+
return _el$.$$contextmenu = onContextMenu, _el$.addEventListener("pointercancel", (e) => isSelectionEnabled() ? onPointerCancel(e) : void 0), _el$.$$pointerup = onPointerUp, _el$.$$pointermove = (e) => isSelectionEnabled() ? onPointerMove(e) : void 0, _el$.$$click = (e) => isSelectionEnabled() ? void 0 : onClick(e), ref(() => (el) => {
|
|
2268
|
+
container = el, setContainerRef(el);
|
|
2269
|
+
}, _el$), insert(_el$, () => props.children), effect(() => ({
|
|
2270
|
+
e: !!isSelecting(),
|
|
2271
|
+
t: !!store.dragging,
|
|
2272
|
+
a: !!(props.panOnDrag === !0 || Array.isArray(props.panOnDrag) && props.panOnDrag.includes(0))
|
|
2273
|
+
}), ({ e, t, a }, _p$) => {
|
|
2274
|
+
e !== _p$?.e && _el$.classList.toggle("selection", e), t !== _p$?.t && _el$.classList.toggle("dragging", t), a !== _p$?.a && _el$.classList.toggle("draggable", a);
|
|
2275
|
+
}), _el$;
|
|
2320
2276
|
};
|
|
2321
2277
|
delegateEvents([
|
|
2322
2278
|
"click",
|
|
@@ -2326,45 +2282,38 @@ delegateEvents([
|
|
|
2326
2282
|
]);
|
|
2327
2283
|
//#endregion
|
|
2328
2284
|
//#region src/components/container/Panel.tsx
|
|
2329
|
-
var _tmpl$$21 =
|
|
2285
|
+
var _tmpl$$21 = /* @__PURE__ */ template("<div>");
|
|
2330
2286
|
const Panel = (props) => {
|
|
2331
|
-
let { store } = useInternalSolidFlow(), _props =
|
|
2287
|
+
let { store } = useInternalSolidFlow(), _props = propDefaults(props, {
|
|
2332
2288
|
position: "top-right",
|
|
2333
2289
|
style: {}
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
return {
|
|
2352
|
-
"pointer-events": store.selectionRectMode ? "none" : void 0,
|
|
2353
|
-
...local.style
|
|
2354
|
-
};
|
|
2355
|
-
}
|
|
2356
|
-
}, rest), !1, !0), insert(_el$, () => local.children), _el$;
|
|
2357
|
-
})();
|
|
2290
|
+
}), rest = omit(_props, "class", "position", "style", "children");
|
|
2291
|
+
var _el$ = _tmpl$$21();
|
|
2292
|
+
return spread(_el$, mergeProps({
|
|
2293
|
+
get class() {
|
|
2294
|
+
return [
|
|
2295
|
+
"solid-flow__panel",
|
|
2296
|
+
..._props.position.split("-"),
|
|
2297
|
+
_props.class
|
|
2298
|
+
];
|
|
2299
|
+
},
|
|
2300
|
+
get style() {
|
|
2301
|
+
return {
|
|
2302
|
+
"pointer-events": store.selectionRectMode ? "none" : void 0,
|
|
2303
|
+
..._props.style
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
}, rest), !0), insert(_el$, () => _props.children), _el$;
|
|
2358
2307
|
};
|
|
2359
2308
|
//#endregion
|
|
2360
2309
|
//#region src/components/container/Viewport.tsx
|
|
2361
|
-
var _tmpl$$20 =
|
|
2310
|
+
var _tmpl$$20 = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__viewport xyflow__viewport\">");
|
|
2362
2311
|
const Viewport = (props) => {
|
|
2363
2312
|
let { store } = useInternalSolidFlow();
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
})
|
|
2313
|
+
var _el$ = _tmpl$$20();
|
|
2314
|
+
return insert(_el$, () => props.children), effect(() => `translate(${store.viewport.x}px, ${store.viewport.y}px) scale(${store.viewport.zoom})`, (_v$) => {
|
|
2315
|
+
setStyleProperty(_el$, "transform", _v$);
|
|
2316
|
+
}), _el$;
|
|
2368
2317
|
}, ViewportPortal = (props) => {
|
|
2369
2318
|
let { store } = useInternalSolidFlow();
|
|
2370
2319
|
return createComponent(Show, {
|
|
@@ -2383,9 +2332,9 @@ const Viewport = (props) => {
|
|
|
2383
2332
|
};
|
|
2384
2333
|
//#endregion
|
|
2385
2334
|
//#region src/components/container/Zoom.tsx
|
|
2386
|
-
var _tmpl$$19 =
|
|
2335
|
+
var _tmpl$$19 = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__zoom\">");
|
|
2387
2336
|
const Zoom = (props) => {
|
|
2388
|
-
let ref, { store, actions } = useInternalSolidFlow(), viewPort = () => props.initialViewport || {
|
|
2337
|
+
let [ref$3, setRef] = createSignal(), { store, actions } = useInternalSolidFlow(), viewPort = () => props.initialViewport || {
|
|
2389
2338
|
x: 0,
|
|
2390
2339
|
y: 0,
|
|
2391
2340
|
zoom: 1
|
|
@@ -2397,9 +2346,10 @@ const Zoom = (props) => {
|
|
|
2397
2346
|
zoom
|
|
2398
2347
|
});
|
|
2399
2348
|
};
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2349
|
+
createEffect(() => ref$3(), (el) => {
|
|
2350
|
+
if (!el) return;
|
|
2351
|
+
let panZoomInstance = untrack(() => XYPanZoom({
|
|
2352
|
+
domNode: el,
|
|
2403
2353
|
minZoom: store.minZoom,
|
|
2404
2354
|
maxZoom: store.maxZoom,
|
|
2405
2355
|
translateExtent: store.translateExtent,
|
|
@@ -2408,43 +2358,45 @@ const Zoom = (props) => {
|
|
|
2408
2358
|
onPanZoomStart: props.onMoveStart,
|
|
2409
2359
|
onPanZoom: props.onMove,
|
|
2410
2360
|
onPanZoomEnd: props.onMoveEnd
|
|
2411
|
-
}), vp = panZoomInstance.getViewport();
|
|
2412
|
-
(
|
|
2361
|
+
})), vp = panZoomInstance.getViewport(), initial = untrack(() => viewPort());
|
|
2362
|
+
(initial.x !== vp.x || initial.y !== vp.y || initial.zoom !== vp.zoom) && onTransformChange([
|
|
2413
2363
|
vp.x,
|
|
2414
2364
|
vp.y,
|
|
2415
2365
|
vp.zoom
|
|
2416
|
-
]),
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2366
|
+
]), actions.setViewport(vp), actions.setPanZoom(panZoomInstance), props.onViewportInitialized?.();
|
|
2367
|
+
}), createEffect(() => ({
|
|
2368
|
+
panZoom: store.panZoom,
|
|
2369
|
+
options: {
|
|
2370
|
+
lib: store.lib,
|
|
2371
|
+
panActivationKeyPressed: store.panActivationKeyPressed,
|
|
2372
|
+
zoomActivationKeyPressed: store.zoomActivationKeyPressed,
|
|
2373
|
+
noPanClassName: store.noPanClass,
|
|
2374
|
+
noWheelClassName: store.noWheelClass,
|
|
2375
|
+
userSelectionActive: !!store.selectionRect,
|
|
2376
|
+
panOnScrollSpeed: props.panOnScrollSpeed,
|
|
2377
|
+
panOnDrag: panOnDrag(),
|
|
2378
|
+
panOnScroll: panOnScroll(),
|
|
2379
|
+
zoomOnScroll: props.zoomOnScroll,
|
|
2380
|
+
zoomOnDoubleClick: props.zoomOnDoubleClick,
|
|
2381
|
+
zoomOnPinch: props.zoomOnPinch,
|
|
2382
|
+
panOnScrollMode: props.panOnScrollMode,
|
|
2383
|
+
preventScrolling: typeof props.preventScrolling != "boolean" || props.preventScrolling,
|
|
2384
|
+
paneClickDistance: props.paneClickDistance,
|
|
2385
|
+
selectionOnDrag: props.selectionOnDrag,
|
|
2386
|
+
connectionInProgress: store.connection.inProgress
|
|
2387
|
+
}
|
|
2388
|
+
}), ({ panZoom, options }) => {
|
|
2389
|
+
panZoom?.update({
|
|
2390
|
+
...options,
|
|
2391
|
+
onTransformChange
|
|
2439
2392
|
});
|
|
2440
|
-
})
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
})();
|
|
2393
|
+
});
|
|
2394
|
+
var _el$ = _tmpl$$19();
|
|
2395
|
+
return ref(() => setRef, _el$), insert(_el$, () => props.children), _el$;
|
|
2444
2396
|
};
|
|
2445
2397
|
//#endregion
|
|
2446
2398
|
//#region src/components/graph/connection/ConnectionLine.tsx
|
|
2447
|
-
var _tmpl$$18 =
|
|
2399
|
+
var _tmpl$$18 = /* @__PURE__ */ template("<svg class=\"solid-flow__container solid-flow__connectionline\"><g>"), _tmpl$2$1 = /* @__PURE__ */ template("<svg><path class=solid-flow__connection-path fill=none></svg>", 2);
|
|
2448
2400
|
const ConnectionLine = (props) => {
|
|
2449
2401
|
let { store } = useInternalSolidFlow(), connectionStatus = () => getConnectionStatus(store.connection.isValid);
|
|
2450
2402
|
return createComponent(Show, {
|
|
@@ -2506,14 +2458,13 @@ const ConnectionLine = (props) => {
|
|
|
2506
2458
|
}
|
|
2507
2459
|
});
|
|
2508
2460
|
}
|
|
2509
|
-
})), effect((
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
a
|
|
2516
|
-
o: void 0
|
|
2461
|
+
})), effect(() => ({
|
|
2462
|
+
e: store.width,
|
|
2463
|
+
t: store.height,
|
|
2464
|
+
a: props.containerStyle,
|
|
2465
|
+
o: ["solid-flow__connection", connectionStatus()]
|
|
2466
|
+
}), ({ e, t, a, o }, _p$) => {
|
|
2467
|
+
e !== _p$?.e && setAttribute(_el$, "width", e), t !== _p$?.t && setAttribute(_el$, "height", t), style(_el$, a, _p$?.a), className(_el$2, o, _p$?.o);
|
|
2517
2468
|
}), _el$;
|
|
2518
2469
|
}
|
|
2519
2470
|
});
|
|
@@ -2547,237 +2498,204 @@ const ConnectionLine = (props) => {
|
|
|
2547
2498
|
}
|
|
2548
2499
|
}
|
|
2549
2500
|
};
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
t: void 0
|
|
2558
|
-
}), _el$3;
|
|
2559
|
-
})();
|
|
2501
|
+
var _el$3 = _tmpl$2$1();
|
|
2502
|
+
return effect(() => ({
|
|
2503
|
+
e: props.style,
|
|
2504
|
+
t: path()
|
|
2505
|
+
}), ({ e, t }, _p$) => {
|
|
2506
|
+
style(_el$3, e, _p$?.e), t !== _p$?.t && setAttribute(_el$3, "d", t);
|
|
2507
|
+
}), _el$3;
|
|
2560
2508
|
};
|
|
2561
2509
|
//#endregion
|
|
2562
2510
|
//#region src/components/graph/plugins/background/DotPattern.tsx
|
|
2563
|
-
var _tmpl$$17 =
|
|
2511
|
+
var _tmpl$$17 = /* @__PURE__ */ template("<svg><circle></svg>", 2);
|
|
2564
2512
|
const DotPattern = (props) => {
|
|
2565
|
-
let _props =
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2513
|
+
let _props = propDefaults(props, { radius: 5 });
|
|
2514
|
+
var _el$ = _tmpl$$17();
|
|
2515
|
+
return effect(() => ({
|
|
2516
|
+
e: [
|
|
2517
|
+
"solid-flow__background-pattern",
|
|
2518
|
+
"dots",
|
|
2519
|
+
_props.class
|
|
2520
|
+
],
|
|
2521
|
+
t: _props.radius,
|
|
2522
|
+
a: _props.radius,
|
|
2523
|
+
o: _props.radius
|
|
2524
|
+
}), ({ e, t, a, o }, _p$) => {
|
|
2525
|
+
className(_el$, e, _p$?.e), t !== _p$?.t && setAttribute(_el$, "cx", t), a !== _p$?.a && setAttribute(_el$, "cy", a), o !== _p$?.o && setAttribute(_el$, "r", o);
|
|
2526
|
+
}), _el$;
|
|
2578
2527
|
};
|
|
2579
2528
|
//#endregion
|
|
2580
2529
|
//#region src/components/graph/plugins/background/LinePattern.tsx
|
|
2581
|
-
var _tmpl$$16 =
|
|
2530
|
+
var _tmpl$$16 = /* @__PURE__ */ template("<svg><path></svg>", 2);
|
|
2582
2531
|
const LinePattern = (props) => {
|
|
2583
|
-
let _props =
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2532
|
+
let _props = propDefaults(props, { lineWidth: 1 });
|
|
2533
|
+
var _el$ = _tmpl$$16();
|
|
2534
|
+
return effect(() => ({
|
|
2535
|
+
e: _props.lineWidth,
|
|
2536
|
+
t: `M${_props.dimensions[0] / 2} 0 V${_props.dimensions[1]} M0 ${_props.dimensions[1] / 2} H${_props.dimensions[0]}`,
|
|
2537
|
+
a: [
|
|
2538
|
+
"solid-flow__background-pattern",
|
|
2539
|
+
_props.variant,
|
|
2540
|
+
_props.class
|
|
2541
|
+
]
|
|
2542
|
+
}), ({ e, t, a }, _p$) => {
|
|
2543
|
+
e !== _p$?.e && setAttribute(_el$, "stroke-width", e), t !== _p$?.t && setAttribute(_el$, "d", t), className(_el$, a, _p$?.a);
|
|
2544
|
+
}), _el$;
|
|
2595
2545
|
};
|
|
2596
2546
|
//#endregion
|
|
2597
2547
|
//#region src/components/graph/plugins/background/Background.tsx
|
|
2598
|
-
var _tmpl$$15 =
|
|
2548
|
+
var _tmpl$$15 = /* @__PURE__ */ template("<svg data-testid=solid-flow__background><pattern patternUnits=userSpaceOnUse></pattern><rect x=0 y=0 width=100% height=100%>");
|
|
2599
2549
|
const DEFAULT_SIZE = {
|
|
2600
2550
|
dots: 1,
|
|
2601
2551
|
lines: 1,
|
|
2602
2552
|
cross: 6
|
|
2603
2553
|
}, Background = (props) => {
|
|
2604
|
-
let _props =
|
|
2554
|
+
let _props = propDefaults(props, {
|
|
2605
2555
|
variant: "dots",
|
|
2606
2556
|
gap: 20,
|
|
2607
2557
|
size: 1,
|
|
2608
2558
|
lineWidth: 1,
|
|
2609
2559
|
style: {}
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
r: void 0
|
|
2660
|
-
}), _el$;
|
|
2661
|
-
})();
|
|
2560
|
+
}), { store } = useInternalSolidFlow(), isDots = () => _props.variant === "dots", isCross = () => _props.variant === "cross", patternId = () => `background-pattern-${store.id}-${_props.id ?? ""}`, scaledSize = () => (_props.size ?? DEFAULT_SIZE[_props.variant]) * store.viewport.zoom, gapXY = () => Array.isArray(_props.gap) ? _props.gap : [_props.gap, _props.gap], scaledGap = () => [gapXY()[0] * store.viewport.zoom || 1, gapXY()[1] * store.viewport.zoom || 1], patternDimensions = () => isCross() ? [scaledSize(), scaledSize()] : scaledGap(), patternOffset = () => isDots() ? [scaledSize() / 2, scaledSize() / 2] : [patternDimensions()[0] / 2, patternDimensions()[1] / 2];
|
|
2561
|
+
var _el$ = _tmpl$$15(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
|
|
2562
|
+
return insert(_el$2, createComponent(Show, {
|
|
2563
|
+
get when() {
|
|
2564
|
+
return !isDots();
|
|
2565
|
+
},
|
|
2566
|
+
get fallback() {
|
|
2567
|
+
return createComponent(DotPattern, {
|
|
2568
|
+
get radius() {
|
|
2569
|
+
return scaledSize() / 2;
|
|
2570
|
+
},
|
|
2571
|
+
get class() {
|
|
2572
|
+
return _props.patternClass;
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
},
|
|
2576
|
+
get children() {
|
|
2577
|
+
return createComponent(LinePattern, {
|
|
2578
|
+
get class() {
|
|
2579
|
+
return _props.patternClass;
|
|
2580
|
+
},
|
|
2581
|
+
get dimensions() {
|
|
2582
|
+
return patternDimensions();
|
|
2583
|
+
},
|
|
2584
|
+
get variant() {
|
|
2585
|
+
return _props.variant;
|
|
2586
|
+
},
|
|
2587
|
+
get lineWidth() {
|
|
2588
|
+
return _props.lineWidth;
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
})), effect(() => ({
|
|
2593
|
+
e: ["solid-flow__container solid-flow__background", _props.class],
|
|
2594
|
+
t: {
|
|
2595
|
+
"--xy-background-color-props": _props.bgColor,
|
|
2596
|
+
"--xy-background-pattern-color-props": _props.patternColor,
|
|
2597
|
+
..._props.style
|
|
2598
|
+
},
|
|
2599
|
+
a: patternId(),
|
|
2600
|
+
o: store.viewport.x % scaledGap()[0],
|
|
2601
|
+
i: store.viewport.y % scaledGap()[1],
|
|
2602
|
+
n: scaledGap()[0],
|
|
2603
|
+
s: scaledGap()[1],
|
|
2604
|
+
h: `translate(-${patternOffset()[0]},-${patternOffset()[1]})`,
|
|
2605
|
+
r: `url(#${patternId()})`
|
|
2606
|
+
}), ({ e, t, a, o, i, n, s, h, r }, _p$) => {
|
|
2607
|
+
className(_el$, e, _p$?.e), style(_el$, t, _p$?.t), a !== _p$?.a && setAttribute(_el$2, "id", a), o !== _p$?.o && setAttribute(_el$2, "x", o), i !== _p$?.i && setAttribute(_el$2, "y", i), n !== _p$?.n && setAttribute(_el$2, "width", n), s !== _p$?.s && setAttribute(_el$2, "height", s), h !== _p$?.h && setAttribute(_el$2, "patternTransform", h), r !== _p$?.r && setAttribute(_el$3, "fill", r);
|
|
2608
|
+
}), _el$;
|
|
2662
2609
|
};
|
|
2663
2610
|
//#endregion
|
|
2664
2611
|
//#region src/components/graph/plugins/controls/ControlButton.tsx
|
|
2665
|
-
var _tmpl$$14 =
|
|
2612
|
+
var _tmpl$$14 = /* @__PURE__ */ template("<button>");
|
|
2666
2613
|
const ControlButton = (props) => {
|
|
2667
|
-
let
|
|
2668
|
-
"
|
|
2669
|
-
"
|
|
2670
|
-
"
|
|
2671
|
-
"color",
|
|
2672
|
-
"
|
|
2673
|
-
"borderColor",
|
|
2674
|
-
"onClick",
|
|
2675
|
-
"children"
|
|
2676
|
-
]), style = () => Object.entries({
|
|
2677
|
-
"--xy-controls-button-background-color-props": local.bgColor,
|
|
2678
|
-
"--xy-controls-button-background-color-hover-props": local.bgColorHover,
|
|
2679
|
-
"--xy-controls-button-color-props": local.color,
|
|
2680
|
-
"--xy-controls-button-color-hover-props": local.colorHover,
|
|
2681
|
-
"--xy-controls-button-border-color-props": local.borderColor
|
|
2614
|
+
let rest = omit(props, "class", "bgColor", "bgColorHover", "color", "colorHover", "borderColor", "onClick", "children"), style = () => Object.entries({
|
|
2615
|
+
"--xy-controls-button-background-color-props": props.bgColor,
|
|
2616
|
+
"--xy-controls-button-background-color-hover-props": props.bgColorHover,
|
|
2617
|
+
"--xy-controls-button-color-props": props.color,
|
|
2618
|
+
"--xy-controls-button-color-hover-props": props.colorHover,
|
|
2619
|
+
"--xy-controls-button-border-color-props": props.borderColor
|
|
2682
2620
|
}).filter(([_, value]) => value !== void 0).reduce((acc, [key, value]) => (acc[key] = value, acc), {});
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
}
|
|
2693
|
-
})()
|
|
2621
|
+
var _el$ = _tmpl$$14();
|
|
2622
|
+
return spread(_el$, mergeProps({
|
|
2623
|
+
type: "button",
|
|
2624
|
+
get class() {
|
|
2625
|
+
return ["solid-flow__controls-button", props.class];
|
|
2626
|
+
},
|
|
2627
|
+
onClick: (e) => props.onClick?.(e),
|
|
2628
|
+
get style() {
|
|
2629
|
+
return style();
|
|
2630
|
+
}
|
|
2631
|
+
}, rest), !0), insert(_el$, () => props.children), _el$;
|
|
2694
2632
|
};
|
|
2695
|
-
delegateEvents(["click"]);
|
|
2696
2633
|
//#endregion
|
|
2697
2634
|
//#region src/components/graph/plugins/controls/icons/Fit.tsx
|
|
2698
|
-
var _tmpl$$13 =
|
|
2635
|
+
var _tmpl$$13 = /* @__PURE__ */ template("<svg viewBox=\"0 0 32 30\"><path d=\"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z\">");
|
|
2699
2636
|
const Fit = () => _tmpl$$13();
|
|
2700
2637
|
//#endregion
|
|
2701
2638
|
//#region src/components/graph/plugins/controls/icons/Lock.tsx
|
|
2702
|
-
var _tmpl$$12 =
|
|
2639
|
+
var _tmpl$$12 = /* @__PURE__ */ template("<svg viewBox=\"0 0 25 32\"><path d=\"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z\">");
|
|
2703
2640
|
const Lock = () => _tmpl$$12();
|
|
2704
2641
|
//#endregion
|
|
2705
2642
|
//#region src/components/graph/plugins/controls/icons/Minus.tsx
|
|
2706
|
-
var _tmpl$$11 =
|
|
2643
|
+
var _tmpl$$11 = /* @__PURE__ */ template("<svg viewBox=\"0 0 32 5\"><path d=\"M0 0h32v4.2H0z\">");
|
|
2707
2644
|
const Minus = () => _tmpl$$11();
|
|
2708
2645
|
//#endregion
|
|
2709
2646
|
//#region src/components/graph/plugins/controls/icons/Plus.tsx
|
|
2710
|
-
var _tmpl$$10 =
|
|
2647
|
+
var _tmpl$$10 = /* @__PURE__ */ template("<svg viewBox=\"0 0 32 32\"><path d=\"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z\">");
|
|
2711
2648
|
const Plus = () => _tmpl$$10();
|
|
2712
2649
|
//#endregion
|
|
2713
2650
|
//#region src/components/graph/plugins/controls/icons/Unlock.tsx
|
|
2714
|
-
var _tmpl$$9 =
|
|
2651
|
+
var _tmpl$$9 = /* @__PURE__ */ template("<svg viewBox=\"0 0 25 32\"><path d=\"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z\">");
|
|
2715
2652
|
const Unlock = () => _tmpl$$9(), Controls = (props) => {
|
|
2716
|
-
let { store, actions } = useInternalSolidFlow(), _props =
|
|
2653
|
+
let { store, actions } = useInternalSolidFlow(), _props = propDefaults(props, {
|
|
2717
2654
|
position: "bottom-left",
|
|
2718
2655
|
showZoom: !0,
|
|
2719
2656
|
showFitView: !0,
|
|
2720
2657
|
showLock: !0,
|
|
2721
2658
|
orientation: "vertical"
|
|
2722
|
-
},
|
|
2723
|
-
"class",
|
|
2724
|
-
"position",
|
|
2725
|
-
"showZoom",
|
|
2726
|
-
"showFitView",
|
|
2727
|
-
"showLock",
|
|
2728
|
-
"orientation",
|
|
2729
|
-
"fitViewOptions",
|
|
2730
|
-
"beforeControls",
|
|
2731
|
-
"afterControls",
|
|
2732
|
-
"buttonBgColor",
|
|
2733
|
-
"buttonBgColorHover",
|
|
2734
|
-
"buttonColor",
|
|
2735
|
-
"buttonColorHover",
|
|
2736
|
-
"buttonBorderColor",
|
|
2737
|
-
"style",
|
|
2738
|
-
"children"
|
|
2739
|
-
]), getMinZoomReached = () => store.viewport.zoom <= store.minZoom, getMaxZoomReached = () => store.viewport.zoom >= store.maxZoom, getIsInteractive = () => store.nodesDraggable || store.nodesConnectable || store.elementsSelectable, onZoomInHandler = () => {
|
|
2659
|
+
}), rest = omit(_props, "class", "position", "showZoom", "showFitView", "showLock", "orientation", "fitViewOptions", "beforeControls", "afterControls", "buttonBgColor", "buttonBgColorHover", "buttonColor", "buttonColorHover", "buttonBorderColor", "style", "children"), getMinZoomReached = () => store.viewport.zoom <= store.minZoom, getMaxZoomReached = () => store.viewport.zoom >= store.maxZoom, getIsInteractive = () => store.nodesDraggable || store.nodesConnectable || store.elementsSelectable, onZoomInHandler = () => {
|
|
2740
2660
|
actions.zoomIn();
|
|
2741
2661
|
}, onZoomOutHandler = () => {
|
|
2742
2662
|
actions.zoomOut();
|
|
2743
2663
|
}, onFitViewHandler = () => {
|
|
2744
|
-
actions.fitView(
|
|
2664
|
+
actions.fitView(_props.fitViewOptions);
|
|
2745
2665
|
}, onToggleInteractivity = () => {
|
|
2746
2666
|
let newValue = !getIsInteractive();
|
|
2747
|
-
|
|
2748
|
-
actions.setNodesDraggable(newValue), actions.setNodesConnectable(newValue), actions.setElementsSelectable(newValue);
|
|
2749
|
-
});
|
|
2667
|
+
actions.setNodesDraggable(newValue), actions.setNodesConnectable(newValue), actions.setElementsSelectable(newValue);
|
|
2750
2668
|
}, buttonProps = () => ({
|
|
2751
|
-
bgColor:
|
|
2752
|
-
bgColorHover:
|
|
2753
|
-
color:
|
|
2754
|
-
colorHover:
|
|
2755
|
-
borderColor:
|
|
2669
|
+
bgColor: _props.buttonBgColor,
|
|
2670
|
+
bgColorHover: _props.buttonBgColorHover,
|
|
2671
|
+
color: _props.buttonColor,
|
|
2672
|
+
colorHover: _props.buttonColorHover,
|
|
2673
|
+
borderColor: _props.buttonBorderColor
|
|
2756
2674
|
});
|
|
2757
2675
|
return createComponent(Panel, mergeProps({
|
|
2758
2676
|
get class() {
|
|
2759
|
-
return
|
|
2677
|
+
return [
|
|
2760
2678
|
"solid-flow__controls",
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
]
|
|
2679
|
+
_props.orientation,
|
|
2680
|
+
_props.class
|
|
2681
|
+
];
|
|
2764
2682
|
},
|
|
2765
2683
|
get position() {
|
|
2766
|
-
return
|
|
2684
|
+
return _props.position;
|
|
2767
2685
|
},
|
|
2768
2686
|
"data-testid": "solid-flow__controls",
|
|
2769
2687
|
get "aria-label"() {
|
|
2770
2688
|
return store.ariaLabelConfig["controls.ariaLabel"];
|
|
2771
2689
|
},
|
|
2772
2690
|
get style() {
|
|
2773
|
-
return
|
|
2691
|
+
return _props.style;
|
|
2774
2692
|
}
|
|
2775
2693
|
}, rest, { get children() {
|
|
2776
2694
|
return [
|
|
2777
|
-
memo(() =>
|
|
2695
|
+
memo(() => _props.beforeControls),
|
|
2778
2696
|
createComponent(Show, {
|
|
2779
2697
|
get when() {
|
|
2780
|
-
return
|
|
2698
|
+
return _props.showZoom;
|
|
2781
2699
|
},
|
|
2782
2700
|
get children() {
|
|
2783
2701
|
return [createComponent(ControlButton, mergeProps({
|
|
@@ -2813,7 +2731,7 @@ const Unlock = () => _tmpl$$9(), Controls = (props) => {
|
|
|
2813
2731
|
}),
|
|
2814
2732
|
createComponent(Show, {
|
|
2815
2733
|
get when() {
|
|
2816
|
-
return
|
|
2734
|
+
return _props.showFitView;
|
|
2817
2735
|
},
|
|
2818
2736
|
get children() {
|
|
2819
2737
|
return createComponent(ControlButton, mergeProps({
|
|
@@ -2832,7 +2750,7 @@ const Unlock = () => _tmpl$$9(), Controls = (props) => {
|
|
|
2832
2750
|
}),
|
|
2833
2751
|
createComponent(Show, {
|
|
2834
2752
|
get when() {
|
|
2835
|
-
return
|
|
2753
|
+
return _props.showLock;
|
|
2836
2754
|
},
|
|
2837
2755
|
get children() {
|
|
2838
2756
|
return createComponent(ControlButton, mergeProps({
|
|
@@ -2859,14 +2777,14 @@ const Unlock = () => _tmpl$$9(), Controls = (props) => {
|
|
|
2859
2777
|
} }));
|
|
2860
2778
|
}
|
|
2861
2779
|
}),
|
|
2862
|
-
memo(() =>
|
|
2863
|
-
memo(() =>
|
|
2780
|
+
memo(() => _props.children),
|
|
2781
|
+
memo(() => _props.afterControls)
|
|
2864
2782
|
];
|
|
2865
2783
|
} }));
|
|
2866
2784
|
};
|
|
2867
2785
|
//#endregion
|
|
2868
2786
|
//#region src/components/graph/plugins/EdgeToolbar.tsx
|
|
2869
|
-
var _tmpl$$8 =
|
|
2787
|
+
var _tmpl$$8 = /* @__PURE__ */ template("<div>");
|
|
2870
2788
|
/**
|
|
2871
2789
|
* The `<EdgeToolbar />` component renders a toolbar or tooltip for an edge.
|
|
2872
2790
|
* It must be used inside a custom edge component. By default it is only
|
|
@@ -2875,16 +2793,7 @@ var _tmpl$$8 = /*#__PURE__*/ template("<div>");
|
|
|
2875
2793
|
* The toolbar does not scale with the viewport so that its content is always legible.
|
|
2876
2794
|
*/
|
|
2877
2795
|
const EdgeToolbar = (props) => {
|
|
2878
|
-
let
|
|
2879
|
-
"x",
|
|
2880
|
-
"y",
|
|
2881
|
-
"alignX",
|
|
2882
|
-
"alignY",
|
|
2883
|
-
"isVisible",
|
|
2884
|
-
"selectEdgeOnClick",
|
|
2885
|
-
"class",
|
|
2886
|
-
"children"
|
|
2887
|
-
]), { store, edgeLookup } = useInternalSolidFlow(), edgeId = useEdgeId(), isActive = () => typeof local.isVisible == "boolean" ? local.isVisible : !!edgeLookup.get(edgeId())?.selected, transform = () => getEdgeToolbarTransform(local.x, local.y, store.viewport.zoom, local.alignX ?? "center", local.alignY ?? "center");
|
|
2796
|
+
let rest = omit(props, "x", "y", "alignX", "alignY", "isVisible", "selectEdgeOnClick", "class", "children"), { store, edgeLookup } = useInternalSolidFlow(), edgeId = useEdgeId(), isActive = () => typeof props.isVisible == "boolean" ? props.isVisible : !!edgeLookup.get(edgeId())?.selected, transform = () => getEdgeToolbarTransform(props.x, props.y, store.viewport.zoom, props.alignX ?? "center", props.alignY ?? "center");
|
|
2888
2797
|
return createComponent(Show, {
|
|
2889
2798
|
get when() {
|
|
2890
2799
|
return isActive();
|
|
@@ -2892,14 +2801,14 @@ const EdgeToolbar = (props) => {
|
|
|
2892
2801
|
get children() {
|
|
2893
2802
|
return createComponent(EdgeLabel, {
|
|
2894
2803
|
get selectEdgeOnClick() {
|
|
2895
|
-
return
|
|
2804
|
+
return props.selectEdgeOnClick;
|
|
2896
2805
|
},
|
|
2897
2806
|
transparent: !0,
|
|
2898
2807
|
get children() {
|
|
2899
2808
|
var _el$ = _tmpl$$8();
|
|
2900
2809
|
return spread(_el$, mergeProps({
|
|
2901
2810
|
get class() {
|
|
2902
|
-
return
|
|
2811
|
+
return ["solid-flow__edge-toolbar", props.class];
|
|
2903
2812
|
},
|
|
2904
2813
|
get style() {
|
|
2905
2814
|
return {
|
|
@@ -2911,7 +2820,7 @@ const EdgeToolbar = (props) => {
|
|
|
2911
2820
|
get "data-id"() {
|
|
2912
2821
|
return edgeId();
|
|
2913
2822
|
}
|
|
2914
|
-
}, rest), !
|
|
2823
|
+
}, rest), !0), insert(_el$, () => props.children), _el$;
|
|
2915
2824
|
}
|
|
2916
2825
|
});
|
|
2917
2826
|
}
|
|
@@ -2919,40 +2828,41 @@ const EdgeToolbar = (props) => {
|
|
|
2919
2828
|
};
|
|
2920
2829
|
//#endregion
|
|
2921
2830
|
//#region src/components/graph/plugins/minimap/MiniMapNode.tsx
|
|
2922
|
-
var _tmpl$$7 =
|
|
2831
|
+
var _tmpl$$7 = /* @__PURE__ */ template("<svg><rect></svg>", 2);
|
|
2923
2832
|
const MiniMapNode = (props) => {
|
|
2924
|
-
let _props =
|
|
2833
|
+
let _props = propDefaults(props, {
|
|
2925
2834
|
borderRadius: 5,
|
|
2926
2835
|
width: 0,
|
|
2927
2836
|
height: 0
|
|
2928
|
-
}
|
|
2837
|
+
}), style$1 = () => Object.entries({
|
|
2929
2838
|
fill: _props.color,
|
|
2930
2839
|
stroke: _props.strokeColor,
|
|
2931
2840
|
"stroke-width": _props.strokeWidth
|
|
2932
2841
|
}).filter(([_, value]) => value !== void 0).reduce((acc, [key, value]) => (acc[key] = value, acc), {});
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2842
|
+
var _el$ = _tmpl$$7();
|
|
2843
|
+
return effect(() => ({
|
|
2844
|
+
e: [
|
|
2845
|
+
"solid-flow__minimap-node",
|
|
2846
|
+
{ selected: !!_props.selected },
|
|
2847
|
+
_props.class
|
|
2848
|
+
],
|
|
2849
|
+
t: _props.x,
|
|
2850
|
+
a: _props.y,
|
|
2851
|
+
o: _props.borderRadius,
|
|
2852
|
+
i: _props.borderRadius,
|
|
2853
|
+
n: _props.width,
|
|
2854
|
+
s: _props.height,
|
|
2855
|
+
h: _props.shapeRendering,
|
|
2856
|
+
r: style$1()
|
|
2857
|
+
}), ({ e, t, a, o, i, n, s, h, r }, _p$) => {
|
|
2858
|
+
className(_el$, e, _p$?.e), t !== _p$?.t && setAttribute(_el$, "x", t), a !== _p$?.a && setAttribute(_el$, "y", a), o !== _p$?.o && setAttribute(_el$, "rx", o), i !== _p$?.i && setAttribute(_el$, "ry", i), n !== _p$?.n && setAttribute(_el$, "width", n), s !== _p$?.s && setAttribute(_el$, "height", s), h !== _p$?.h && setAttribute(_el$, "shape-rendering", h), style(_el$, r, _p$?.r);
|
|
2859
|
+
}), _el$;
|
|
2950
2860
|
};
|
|
2951
2861
|
//#endregion
|
|
2952
2862
|
//#region src/components/graph/plugins/minimap/MiniMap.tsx
|
|
2953
|
-
var _tmpl$$6 =
|
|
2863
|
+
var _tmpl$$6 = /* @__PURE__ */ template("<svg class=solid-flow__minimap-svg role=img><title></title><path class=solid-flow__minimap-mask fill-rule=evenodd pointer-events=none>");
|
|
2954
2864
|
const getAttrFunction = (func) => func instanceof Function ? func : () => func, MiniMap = (props) => {
|
|
2955
|
-
let { store, nodeLookup } = useInternalSolidFlow(), _props =
|
|
2865
|
+
let { store, nodeLookup } = useInternalSolidFlow(), _props = propDefaults(props, {
|
|
2956
2866
|
position: "bottom-right",
|
|
2957
2867
|
nodeClass: "",
|
|
2958
2868
|
nodeStrokeColor: "transparent",
|
|
@@ -2963,26 +2873,7 @@ const getAttrFunction = (func) => func instanceof Function ? func : () => func,
|
|
|
2963
2873
|
nodeBorderRadius: 5,
|
|
2964
2874
|
nodeStrokeWidth: 2,
|
|
2965
2875
|
style: {}
|
|
2966
|
-
},
|
|
2967
|
-
"class",
|
|
2968
|
-
"style",
|
|
2969
|
-
"position",
|
|
2970
|
-
"nodeClass",
|
|
2971
|
-
"nodeStrokeColor",
|
|
2972
|
-
"nodeColor",
|
|
2973
|
-
"pannable",
|
|
2974
|
-
"zoomable",
|
|
2975
|
-
"inversePan",
|
|
2976
|
-
"zoomStep",
|
|
2977
|
-
"bgColor",
|
|
2978
|
-
"width",
|
|
2979
|
-
"height",
|
|
2980
|
-
"maskColor",
|
|
2981
|
-
"maskStrokeColor",
|
|
2982
|
-
"maskStrokeWidth",
|
|
2983
|
-
"nodeBorderRadius",
|
|
2984
|
-
"nodeStrokeWidth"
|
|
2985
|
-
]), nodeColorFunc = () => local.nodeColor === void 0 ? void 0 : getAttrFunction(local.nodeColor), nodeStrokeColorFunc = () => getAttrFunction(local.nodeStrokeColor), nodeClassFunc = () => getAttrFunction(local.nodeClass), shapeRendering = () => typeof window > "u" || window.chrome ? "crispEdges" : "geometricPrecision", labelledBy = createMemo(() => `solid-flow__minimap-desc-${store.id}`), getViewBB = () => ({
|
|
2876
|
+
}), paneProps = omit(_props, "class", "style", "position", "nodeClass", "nodeStrokeColor", "nodeColor", "pannable", "zoomable", "inversePan", "zoomStep", "bgColor", "width", "height", "maskColor", "maskStrokeColor", "maskStrokeWidth", "nodeBorderRadius", "nodeStrokeWidth"), nodeColorFunc = () => _props.nodeColor === void 0 ? void 0 : getAttrFunction(_props.nodeColor), nodeStrokeColorFunc = () => getAttrFunction(_props.nodeStrokeColor), nodeClassFunc = () => getAttrFunction(_props.nodeClass), shapeRendering = () => typeof window > "u" || window.chrome ? "crispEdges" : "geometricPrecision", labelledBy = createMemo(() => `solid-flow__minimap-desc-${store.id}`), getViewBB = () => ({
|
|
2986
2877
|
x: -store.viewport.x / store.viewport.zoom,
|
|
2987
2878
|
y: -store.viewport.y / store.viewport.zoom,
|
|
2988
2879
|
width: store.width / store.viewport.zoom,
|
|
@@ -2990,28 +2881,28 @@ const getAttrFunction = (func) => func instanceof Function ? func : () => func,
|
|
|
2990
2881
|
}), getBoundingRect = () => {
|
|
2991
2882
|
let viewBB = getViewBB();
|
|
2992
2883
|
return nodeLookup.size > 0 ? getBoundsOfRects(getInternalNodesBounds(nodeLookup), viewBB) : viewBB;
|
|
2993
|
-
}, getScaledWidth = () => getBoundingRect().width /
|
|
2884
|
+
}, getScaledWidth = () => getBoundingRect().width / _props.width, getScaledHeight = () => getBoundingRect().height / _props.height, getViewScale = () => Math.max(getScaledWidth(), getScaledHeight()), getViewWidth = () => getViewScale() * _props.width, getViewHeight = () => getViewScale() * _props.height, getOffset = () => 5 * getViewScale(), getX = () => {
|
|
2994
2885
|
let boundingRect = getBoundingRect();
|
|
2995
2886
|
return boundingRect.x - (getViewWidth() - boundingRect.width) / 2 - getOffset();
|
|
2996
2887
|
}, getY = () => {
|
|
2997
2888
|
let boundingRect = getBoundingRect();
|
|
2998
2889
|
return boundingRect.y - (getViewHeight() - boundingRect.height) / 2 - getOffset();
|
|
2999
|
-
}, getViewboxWidth = () => getViewWidth() + getOffset() * 2, getViewboxHeight = () => getViewHeight() + getOffset() * 2, strokeWidth = () =>
|
|
2890
|
+
}, getViewboxWidth = () => getViewWidth() + getOffset() * 2, getViewboxHeight = () => getViewHeight() + getOffset() * 2, strokeWidth = () => _props.maskStrokeWidth ? _props.maskStrokeWidth * getViewScale() : void 0, prevNodeIds = [], nodeIds = () => {
|
|
3000
2891
|
let currentNodeIds = store.nodes.map((node) => node.id), currentSet = new Set(currentNodeIds);
|
|
3001
2892
|
return (prevNodeIds.length !== currentNodeIds.length || !prevNodeIds.every((id) => currentSet.has(id))) && (prevNodeIds = currentNodeIds), prevNodeIds;
|
|
3002
2893
|
};
|
|
3003
2894
|
return createComponent(Panel, mergeProps({
|
|
3004
2895
|
get position() {
|
|
3005
|
-
return
|
|
2896
|
+
return _props.position;
|
|
3006
2897
|
},
|
|
3007
2898
|
"data-testid": "solid-flow__minimap",
|
|
3008
2899
|
get class() {
|
|
3009
|
-
return
|
|
2900
|
+
return ["solid-flow__minimap", _props.class];
|
|
3010
2901
|
},
|
|
3011
2902
|
get style() {
|
|
3012
2903
|
return {
|
|
3013
|
-
"--xy-minimap-background-color-props":
|
|
3014
|
-
...
|
|
2904
|
+
"--xy-minimap-background-color-props": _props.bgColor,
|
|
2905
|
+
..._props.style
|
|
3015
2906
|
};
|
|
3016
2907
|
}
|
|
3017
2908
|
}, paneProps, { get children() {
|
|
@@ -3020,101 +2911,107 @@ const getAttrFunction = (func) => func instanceof Function ? func : () => func,
|
|
|
3020
2911
|
return store.panZoom;
|
|
3021
2912
|
},
|
|
3022
2913
|
children: (panZoom) => {
|
|
3023
|
-
let [ref, setRef] = createSignal();
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
2914
|
+
let [ref$2, setRef] = createSignal(), [minimap, setMinimap] = createSignal();
|
|
2915
|
+
createEffect(() => ({
|
|
2916
|
+
el: ref$2(),
|
|
2917
|
+
panZoom: panZoom()
|
|
2918
|
+
}), ({ el, panZoom }) => {
|
|
2919
|
+
if (!el) return;
|
|
2920
|
+
let instance = XYMinimap({
|
|
2921
|
+
domNode: el,
|
|
2922
|
+
panZoom,
|
|
3028
2923
|
getTransform: () => store.transform,
|
|
3029
2924
|
getViewScale
|
|
3030
2925
|
});
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
2926
|
+
return setMinimap(instance), () => {
|
|
2927
|
+
instance.destroy();
|
|
2928
|
+
};
|
|
2929
|
+
}), createEffect(() => ({
|
|
2930
|
+
instance: minimap(),
|
|
2931
|
+
options: {
|
|
2932
|
+
translateExtent: store.translateExtent,
|
|
2933
|
+
width: store.width,
|
|
2934
|
+
height: store.height,
|
|
2935
|
+
inversePan: _props.inversePan,
|
|
2936
|
+
zoomStep: _props.zoomStep,
|
|
2937
|
+
pannable: _props.pannable,
|
|
2938
|
+
zoomable: _props.zoomable
|
|
2939
|
+
}
|
|
2940
|
+
}), ({ instance, options }) => {
|
|
2941
|
+
instance?.update(options);
|
|
2942
|
+
});
|
|
2943
|
+
var _el$ = _tmpl$$6(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
|
|
2944
|
+
return ref(() => setRef, _el$), insert(_el$2, () => store.ariaLabelConfig["minimap.ariaLabel"]), insert(_el$, createComponent(For, {
|
|
2945
|
+
keyed: !1,
|
|
2946
|
+
get each() {
|
|
2947
|
+
return nodeIds();
|
|
2948
|
+
},
|
|
2949
|
+
children: (nodeId) => {
|
|
2950
|
+
let node = createMemo(() => nodeLookup.get(nodeId())), nodeVisible = () => !!(node() && nodeHasDimensions(node()) && !node().hidden);
|
|
2951
|
+
return createComponent(Show, {
|
|
2952
|
+
get when() {
|
|
2953
|
+
return memo(() => !!nodeVisible())() ? getNodeDimensions(node()) : nodeVisible();
|
|
2954
|
+
},
|
|
2955
|
+
children: (nodeDimensions) => createComponent(MiniMapNode, {
|
|
2956
|
+
get x() {
|
|
2957
|
+
return node().internals.positionAbsolute.x;
|
|
3055
2958
|
},
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
n: void 0,
|
|
3104
|
-
s: void 0,
|
|
3105
|
-
h: void 0,
|
|
3106
|
-
r: void 0
|
|
3107
|
-
}), _el$;
|
|
3108
|
-
})();
|
|
2959
|
+
get y() {
|
|
2960
|
+
return node().internals.positionAbsolute.y;
|
|
2961
|
+
},
|
|
2962
|
+
get borderRadius() {
|
|
2963
|
+
return _props.nodeBorderRadius;
|
|
2964
|
+
},
|
|
2965
|
+
get strokeWidth() {
|
|
2966
|
+
return _props.nodeStrokeWidth;
|
|
2967
|
+
},
|
|
2968
|
+
get shapeRendering() {
|
|
2969
|
+
return shapeRendering();
|
|
2970
|
+
},
|
|
2971
|
+
get width() {
|
|
2972
|
+
return nodeDimensions().width;
|
|
2973
|
+
},
|
|
2974
|
+
get height() {
|
|
2975
|
+
return nodeDimensions().height;
|
|
2976
|
+
},
|
|
2977
|
+
get selected() {
|
|
2978
|
+
return node().selected;
|
|
2979
|
+
},
|
|
2980
|
+
get color() {
|
|
2981
|
+
return nodeColorFunc()?.call(null, node());
|
|
2982
|
+
},
|
|
2983
|
+
get strokeColor() {
|
|
2984
|
+
return nodeStrokeColorFunc().call(null, node());
|
|
2985
|
+
},
|
|
2986
|
+
get class() {
|
|
2987
|
+
return nodeClassFunc().call(null, node());
|
|
2988
|
+
}
|
|
2989
|
+
})
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
}), _el$2.nextSibling), effect(() => ({
|
|
2993
|
+
e: _props.width,
|
|
2994
|
+
t: _props.height,
|
|
2995
|
+
a: `${getX()} ${getY()} ${getViewboxWidth()} ${getViewboxHeight()}`,
|
|
2996
|
+
o: labelledBy(),
|
|
2997
|
+
i: _props.maskColor,
|
|
2998
|
+
n: _props.maskStrokeColor,
|
|
2999
|
+
s: strokeWidth(),
|
|
3000
|
+
h: labelledBy(),
|
|
3001
|
+
r: `M${getX() - getOffset()},${getY() - getOffset()}h${getViewboxWidth() + getOffset() * 2}v${getViewboxHeight() + getOffset() * 2}h${-getViewboxWidth() - getOffset() * 2}z
|
|
3002
|
+
M${getViewBB().x},${getViewBB().y}h${getViewBB().width}v${getViewBB().height}h${-getViewBB().width}z`
|
|
3003
|
+
}), ({ e, t, a, o, i, n, s, h, r }, _p$) => {
|
|
3004
|
+
e !== _p$?.e && setAttribute(_el$, "width", e), t !== _p$?.t && setAttribute(_el$, "height", t), a !== _p$?.a && setAttribute(_el$, "viewBox", a), o !== _p$?.o && setAttribute(_el$, "aria-labelledby", o), i !== _p$?.i && setStyleProperty(_el$, "--xy-minimap-mask-background-color-props", i), n !== _p$?.n && setStyleProperty(_el$, "--xy-minimap-mask-stroke-color-props", n), s !== _p$?.s && setStyleProperty(_el$, "--xy-minimap-mask-stroke-width-props", s), h !== _p$?.h && setAttribute(_el$2, "id", h), r !== _p$?.r && setAttribute(_el$3, "d", r);
|
|
3005
|
+
}), _el$;
|
|
3109
3006
|
}
|
|
3110
3007
|
});
|
|
3111
3008
|
} }));
|
|
3112
3009
|
};
|
|
3113
3010
|
//#endregion
|
|
3114
3011
|
//#region src/components/graph/plugins/nodeResizer/ResizeControl.tsx
|
|
3115
|
-
var _tmpl$$5 =
|
|
3012
|
+
var _tmpl$$5 = /* @__PURE__ */ template("<div>");
|
|
3116
3013
|
const ResizeControl = (props) => {
|
|
3117
|
-
let _props =
|
|
3014
|
+
let _props = propDefaults(props, {
|
|
3118
3015
|
variant: "handle",
|
|
3119
3016
|
minWidth: 10,
|
|
3120
3017
|
minHeight: 10,
|
|
@@ -3123,28 +3020,11 @@ const ResizeControl = (props) => {
|
|
|
3123
3020
|
keepAspectRatio: !1,
|
|
3124
3021
|
autoScale: !0,
|
|
3125
3022
|
style: {}
|
|
3126
|
-
},
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
"minHeight",
|
|
3132
|
-
"maxWidth",
|
|
3133
|
-
"maxHeight",
|
|
3134
|
-
"keepAspectRatio",
|
|
3135
|
-
"autoScale",
|
|
3136
|
-
"onResizeStart",
|
|
3137
|
-
"onResize",
|
|
3138
|
-
"onResizeEnd",
|
|
3139
|
-
"shouldResize",
|
|
3140
|
-
"class",
|
|
3141
|
-
"children",
|
|
3142
|
-
"color",
|
|
3143
|
-
"style"
|
|
3144
|
-
]), resizeControlRef, { store, nodeLookup, actions } = useInternalSolidFlow(), ctxNodeId = useNodeId(), nodeId = () => local.nodeId ?? ctxNodeId(), isLineVariant = () => local.variant === "line", controlPosition = () => local.position ?? (isLineVariant() ? "right" : "bottom-right"), positionClassNames = () => controlPosition().split("-");
|
|
3145
|
-
return onMount(() => {
|
|
3146
|
-
let resizer = XYResizer({
|
|
3147
|
-
domNode: resizeControlRef,
|
|
3023
|
+
}), rest = omit(_props, "nodeId", "variant", "position", "minWidth", "minHeight", "maxWidth", "maxHeight", "keepAspectRatio", "autoScale", "onResizeStart", "onResize", "onResizeEnd", "shouldResize", "class", "children", "color", "style"), [resizeControlRef, setResizeControlRef] = createSignal(), { store, nodeLookup, actions } = useInternalSolidFlow(), ctxNodeId = useNodeId(), nodeId = () => _props.nodeId ?? ctxNodeId(), isLineVariant = () => _props.variant === "line", controlPosition = () => _props.position ?? (isLineVariant() ? "right" : "bottom-right"), positionClassNames = () => controlPosition().split("-"), [resizer, setResizer] = createSignal();
|
|
3024
|
+
createEffect(() => resizeControlRef(), (el) => {
|
|
3025
|
+
if (!el) return;
|
|
3026
|
+
let instance = XYResizer({
|
|
3027
|
+
domNode: el,
|
|
3148
3028
|
nodeId: nodeId(),
|
|
3149
3029
|
getStoreItems: () => ({
|
|
3150
3030
|
nodeLookup,
|
|
@@ -3164,65 +3044,64 @@ const ResizeControl = (props) => {
|
|
|
3164
3044
|
position
|
|
3165
3045
|
});
|
|
3166
3046
|
for (let childChange of childChanges) changes.set(childChange.id, { position: childChange.position });
|
|
3167
|
-
actions.setNodes((
|
|
3168
|
-
let
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3047
|
+
actions.setNodes((nodes) => {
|
|
3048
|
+
for (let node of nodes) {
|
|
3049
|
+
let nodeChange = changes.get(node.id);
|
|
3050
|
+
nodeChange && (node.width = nodeChange.width, node.height = nodeChange.height, node.position = {
|
|
3051
|
+
x: nodeChange.position?.x ?? node.position.x,
|
|
3052
|
+
y: nodeChange.position?.y ?? node.position.y
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
});
|
|
3174
3056
|
}
|
|
3175
3057
|
});
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
onResizeEnd: local.onResizeEnd,
|
|
3189
|
-
shouldResize: local.shouldResize
|
|
3190
|
-
});
|
|
3191
|
-
}), onCleanup(() => {
|
|
3192
|
-
resizer.destroy();
|
|
3193
|
-
});
|
|
3194
|
-
}), (() => {
|
|
3195
|
-
var _el$ = _tmpl$$5(), _ref$ = resizeControlRef;
|
|
3196
|
-
return typeof _ref$ == "function" ? use(_ref$, _el$) : resizeControlRef = _el$, spread(_el$, mergeProps({
|
|
3197
|
-
get class() {
|
|
3198
|
-
return clsx$1([
|
|
3199
|
-
"solid-flow__resize-control",
|
|
3200
|
-
local.variant,
|
|
3201
|
-
store.noDragClass,
|
|
3202
|
-
...positionClassNames(),
|
|
3203
|
-
local.class
|
|
3204
|
-
]);
|
|
3058
|
+
return setResizer(instance), () => {
|
|
3059
|
+
instance.destroy();
|
|
3060
|
+
};
|
|
3061
|
+
}), createEffect(() => ({
|
|
3062
|
+
instance: resizer(),
|
|
3063
|
+
options: {
|
|
3064
|
+
controlPosition: controlPosition(),
|
|
3065
|
+
boundaries: {
|
|
3066
|
+
minWidth: _props.minWidth,
|
|
3067
|
+
minHeight: _props.minHeight,
|
|
3068
|
+
maxWidth: _props.maxWidth,
|
|
3069
|
+
maxHeight: _props.maxHeight
|
|
3205
3070
|
},
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3071
|
+
keepAspectRatio: !!_props.keepAspectRatio,
|
|
3072
|
+
onResizeStart: _props.onResizeStart,
|
|
3073
|
+
onResize: _props.onResize,
|
|
3074
|
+
onResizeEnd: _props.onResizeEnd,
|
|
3075
|
+
shouldResize: _props.shouldResize
|
|
3076
|
+
}
|
|
3077
|
+
}), ({ instance, options }) => {
|
|
3078
|
+
instance?.update(options);
|
|
3079
|
+
});
|
|
3080
|
+
var _el$ = _tmpl$$5();
|
|
3081
|
+
return ref(() => setResizeControlRef, _el$), spread(_el$, mergeProps({
|
|
3082
|
+
get class() {
|
|
3083
|
+
return [
|
|
3084
|
+
"solid-flow__resize-control",
|
|
3085
|
+
_props.variant,
|
|
3086
|
+
store.noDragClass,
|
|
3087
|
+
...positionClassNames(),
|
|
3088
|
+
_props.class
|
|
3089
|
+
];
|
|
3090
|
+
},
|
|
3091
|
+
get style() {
|
|
3092
|
+
return {
|
|
3093
|
+
"border-color": isLineVariant() ? _props.color : void 0,
|
|
3094
|
+
"background-color": isLineVariant() ? void 0 : _props.color,
|
|
3095
|
+
scale: isLineVariant() || !_props.autoScale ? void 0 : Math.max(1 / store.viewport.zoom, 1),
|
|
3096
|
+
..._props.style
|
|
3097
|
+
};
|
|
3098
|
+
}
|
|
3099
|
+
}, rest), !0), insert(_el$, () => _props.children), _el$;
|
|
3216
3100
|
}, NodeResizer = (props) => {
|
|
3217
|
-
let _props =
|
|
3101
|
+
let _props = propDefaults(props, {
|
|
3218
3102
|
autoScale: !0,
|
|
3219
3103
|
visible: !0
|
|
3220
|
-
}
|
|
3221
|
-
"handleClass",
|
|
3222
|
-
"handleStyle",
|
|
3223
|
-
"lineClass",
|
|
3224
|
-
"lineStyle"
|
|
3225
|
-
]);
|
|
3104
|
+
}), rest = omit(props, "handleClass", "handleStyle", "lineClass", "lineStyle");
|
|
3226
3105
|
return createComponent(Show, {
|
|
3227
3106
|
get when() {
|
|
3228
3107
|
return _props.visible;
|
|
@@ -3234,10 +3113,10 @@ const ResizeControl = (props) => {
|
|
|
3234
3113
|
variant: "line",
|
|
3235
3114
|
position,
|
|
3236
3115
|
get class() {
|
|
3237
|
-
return
|
|
3116
|
+
return props.lineClass;
|
|
3238
3117
|
},
|
|
3239
3118
|
get style() {
|
|
3240
|
-
return
|
|
3119
|
+
return props.lineStyle;
|
|
3241
3120
|
}
|
|
3242
3121
|
}, rest))
|
|
3243
3122
|
}), createComponent(For, {
|
|
@@ -3245,10 +3124,10 @@ const ResizeControl = (props) => {
|
|
|
3245
3124
|
children: (position) => createComponent(ResizeControl, mergeProps({
|
|
3246
3125
|
position,
|
|
3247
3126
|
get class() {
|
|
3248
|
-
return
|
|
3127
|
+
return props.handleClass;
|
|
3249
3128
|
},
|
|
3250
3129
|
get style() {
|
|
3251
|
-
return
|
|
3130
|
+
return props.handleStyle;
|
|
3252
3131
|
}
|
|
3253
3132
|
}, rest))
|
|
3254
3133
|
})];
|
|
@@ -3320,12 +3199,10 @@ function useHandleEdgeSelect() {
|
|
|
3320
3199
|
let { store, edgeLookup, actions } = useInternalSolidFlow();
|
|
3321
3200
|
return (id) => {
|
|
3322
3201
|
let edge = edgeLookup.get(id);
|
|
3323
|
-
edge && (edge.selectable || store.elementsSelectable && edge.selectable === void 0) &&
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
}) : actions.addSelectedEdges([id]);
|
|
3328
|
-
});
|
|
3202
|
+
edge && (edge.selectable || store.elementsSelectable && edge.selectable === void 0) && (actions.setSelectionRect(void 0), actions.setSelectionRectMode(void 0), edge.selected ? edge.selected && store.multiselectionKeyPressed && actions.unselectNodesAndEdges({
|
|
3203
|
+
nodes: [],
|
|
3204
|
+
edges: [edge]
|
|
3205
|
+
}) : actions.addSelectedEdges([id]));
|
|
3329
3206
|
};
|
|
3330
3207
|
}
|
|
3331
3208
|
//#endregion
|
|
@@ -3385,10 +3262,9 @@ const useNodeConnections = (params) => {
|
|
|
3385
3262
|
let { connectionLookup } = useInternalSolidFlow(), ctxNodeId = () => {
|
|
3386
3263
|
let id = useContext(NodeIdContext);
|
|
3387
3264
|
return id ? id() : "";
|
|
3388
|
-
}, id = () => params().handleId, type = () => params().handleType, nodeId = () => params().id ?? ctxNodeId(), [connections, setConnections] = createSignal([]), lookupKey = () => `${nodeId()}${type() ? id() ? `-${type()}-${id()}` : `-${type()}` : ""}
|
|
3389
|
-
return createEffect((
|
|
3390
|
-
|
|
3391
|
-
return areConnectionMapsEqual(nextConnections, prevConnections) || (prevConnections = nextConnections, setConnections(Array.from(prevConnections?.values() ?? []))), nextConnections;
|
|
3265
|
+
}, id = () => params().handleId, type = () => params().handleType, nodeId = () => params().id ?? ctxNodeId(), [connections, setConnections] = createSignal([]), lookupKey = () => `${nodeId()}${type() ? id() ? `-${type()}-${id()}` : `-${type()}` : ""}`, prevConnections;
|
|
3266
|
+
return createEffect(() => ({ connections: connectionLookup.get(lookupKey()) }), ({ connections: nextConnections }) => {
|
|
3267
|
+
areConnectionMapsEqual(nextConnections, prevConnections) || (prevConnections = nextConnections, setConnections(Array.from(nextConnections?.values() ?? [])));
|
|
3392
3268
|
}), connections;
|
|
3393
3269
|
};
|
|
3394
3270
|
//#endregion
|
|
@@ -3428,17 +3304,21 @@ function useSolidFlow() {
|
|
|
3428
3304
|
};
|
|
3429
3305
|
return nodeToRect(nodeWithPosition);
|
|
3430
3306
|
}, updateNode = (id, nodeUpdate, options = { replace: !1 }) => {
|
|
3431
|
-
actions.setNodes((
|
|
3432
|
-
let
|
|
3433
|
-
|
|
3307
|
+
actions.setNodes((nodes) => {
|
|
3308
|
+
let index = nodes.findIndex((node) => node.id === id);
|
|
3309
|
+
if (index === -1) return;
|
|
3310
|
+
let node = nodes[index], nextNode = typeof nodeUpdate == "function" ? nodeUpdate(node) : nodeUpdate;
|
|
3311
|
+
nodes[index] = options?.replace && isNode(nextNode) ? nextNode : {
|
|
3434
3312
|
...node,
|
|
3435
3313
|
...nextNode
|
|
3436
3314
|
};
|
|
3437
3315
|
});
|
|
3438
3316
|
}, updateEdge = (id, edgeUpdate, options = { replace: !1 }) => {
|
|
3439
|
-
actions.setEdges((
|
|
3440
|
-
let
|
|
3441
|
-
|
|
3317
|
+
actions.setEdges((edges) => {
|
|
3318
|
+
let index = edges.findIndex((edge) => edge.id === id);
|
|
3319
|
+
if (index === -1) return;
|
|
3320
|
+
let edge = edges[index], nextEdge = typeof edgeUpdate == "function" ? edgeUpdate(edge) : edgeUpdate;
|
|
3321
|
+
edges[index] = options.replace && isEdge(nextEdge) ? nextEdge : {
|
|
3442
3322
|
...edge,
|
|
3443
3323
|
...nextEdge
|
|
3444
3324
|
};
|
|
@@ -3462,7 +3342,7 @@ function useSolidFlow() {
|
|
|
3462
3342
|
let newEdges = Array.isArray(payload) ? payload : [payload];
|
|
3463
3343
|
actions.setEdges((edges) => [...edges, ...newEdges]);
|
|
3464
3344
|
},
|
|
3465
|
-
getViewport: () =>
|
|
3345
|
+
getViewport: () => snapshot(store.viewport),
|
|
3466
3346
|
setViewport: async (nextViewport, options) => {
|
|
3467
3347
|
let currentViewport = store.viewport;
|
|
3468
3348
|
return store.panZoom ? (await store.panZoom.setViewport({
|
|
@@ -3508,16 +3388,15 @@ function useSolidFlow() {
|
|
|
3508
3388
|
edges: store.edges,
|
|
3509
3389
|
onBeforeDelete: store.onBeforeDelete
|
|
3510
3390
|
});
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
}), {
|
|
3391
|
+
if (matchingEdges) {
|
|
3392
|
+
let remmainingEdges = store.edges.filter((edge) => !matchingEdges.some(({ id }) => id === edge.id));
|
|
3393
|
+
store.onEdgesDelete?.(matchingEdges), actions.setEdges(() => remmainingEdges);
|
|
3394
|
+
}
|
|
3395
|
+
if (matchingNodes) {
|
|
3396
|
+
let remmainingNodes = store.nodes.filter((node) => !matchingNodes.some(({ id }) => id === node.id));
|
|
3397
|
+
store.onNodesDelete?.(matchingNodes), actions.setNodes(() => remmainingNodes);
|
|
3398
|
+
}
|
|
3399
|
+
return {
|
|
3521
3400
|
deletedNodes: matchingNodes,
|
|
3522
3401
|
deletedEdges: matchingEdges
|
|
3523
3402
|
};
|
|
@@ -3552,9 +3431,9 @@ function useSolidFlow() {
|
|
|
3552
3431
|
};
|
|
3553
3432
|
},
|
|
3554
3433
|
toObject: () => structuredClone({
|
|
3555
|
-
nodes: [...
|
|
3556
|
-
edges: [...
|
|
3557
|
-
viewport: { ...
|
|
3434
|
+
nodes: [...snapshot(store.nodes)],
|
|
3435
|
+
edges: [...snapshot(store.edges)],
|
|
3436
|
+
viewport: { ...snapshot(store.viewport) }
|
|
3558
3437
|
}),
|
|
3559
3438
|
updateNode,
|
|
3560
3439
|
updateNodeData: (id, dataUpdate, options) => {
|
|
@@ -3613,36 +3492,28 @@ function useUpdateNodeInternals() {
|
|
|
3613
3492
|
}
|
|
3614
3493
|
//#endregion
|
|
3615
3494
|
//#region src/components/graph/plugins/NodeToolbar.tsx
|
|
3616
|
-
var _tmpl$$4 =
|
|
3495
|
+
var _tmpl$$4 = /* @__PURE__ */ template("<div>");
|
|
3617
3496
|
const NodeToolbar = (props) => {
|
|
3618
|
-
let { store } = useInternalSolidFlow(), { getNodes, getNodesBounds, getInternalNode } = useSolidFlow(), _props =
|
|
3497
|
+
let { store } = useInternalSolidFlow(), { getNodes, getNodesBounds, getInternalNode } = useSolidFlow(), _props = propDefaults(props, {
|
|
3619
3498
|
offset: 10,
|
|
3620
3499
|
position: "top",
|
|
3621
3500
|
align: "center",
|
|
3622
3501
|
style: {}
|
|
3623
|
-
}
|
|
3624
|
-
"nodeId",
|
|
3625
|
-
"position",
|
|
3626
|
-
"align",
|
|
3627
|
-
"offset",
|
|
3628
|
-
"isVisible",
|
|
3629
|
-
"style",
|
|
3630
|
-
"children"
|
|
3631
|
-
]), ctxNodeId = () => {
|
|
3502
|
+
}), divProps = omit(_props, "nodeId", "position", "align", "offset", "isVisible", "style", "children"), ctxNodeId = () => {
|
|
3632
3503
|
let id = useContext(NodeIdContext);
|
|
3633
3504
|
return id ? id() : "";
|
|
3634
|
-
}, toolbarNodes = () => (Array.isArray(
|
|
3505
|
+
}, toolbarNodes = () => (Array.isArray(_props.nodeId) ? _props.nodeId : [_props.nodeId ?? ctxNodeId()]).reduce((res, nodeId) => {
|
|
3635
3506
|
let node = getInternalNode(nodeId);
|
|
3636
3507
|
return node && res.push(node), res;
|
|
3637
3508
|
}, []), transform = () => {
|
|
3638
3509
|
let nodeRect = getNodesBounds(toolbarNodes());
|
|
3639
|
-
return nodeRect ? getNodeToolbarTransform(nodeRect, store.viewport,
|
|
3510
|
+
return nodeRect ? getNodeToolbarTransform(nodeRect, store.viewport, _props.position, _props.offset, _props.align) : "";
|
|
3640
3511
|
}, zIndex = () => {
|
|
3641
3512
|
let nodes = toolbarNodes();
|
|
3642
3513
|
return nodes.length === 0 ? 1 : Math.max(...nodes.map((node) => (node.internals.z || 5) + 1));
|
|
3643
3514
|
}, selectedNodesCount = () => getNodes().filter((node) => node.selected).length, isActive = () => {
|
|
3644
3515
|
let nodes = toolbarNodes();
|
|
3645
|
-
return typeof
|
|
3516
|
+
return typeof _props.isVisible == "boolean" ? _props.isVisible : nodes.length === 1 && !!nodes[0].selected && selectedNodesCount() === 1;
|
|
3646
3517
|
}, showPortal = () => !!(store.domNode && isActive() && toolbarNodes().length > 0);
|
|
3647
3518
|
return createComponent(Show, {
|
|
3648
3519
|
get when() {
|
|
@@ -3656,6 +3527,7 @@ const NodeToolbar = (props) => {
|
|
|
3656
3527
|
get children() {
|
|
3657
3528
|
var _el$ = _tmpl$$4();
|
|
3658
3529
|
return spread(_el$, mergeProps({
|
|
3530
|
+
class: "solid-flow__node-toolbar",
|
|
3659
3531
|
get "data-id"() {
|
|
3660
3532
|
return toolbarNodes().reduce((acc, node) => `${acc}${node.id} `, "").trim();
|
|
3661
3533
|
},
|
|
@@ -3664,10 +3536,10 @@ const NodeToolbar = (props) => {
|
|
|
3664
3536
|
position: "absolute",
|
|
3665
3537
|
transform: transform(),
|
|
3666
3538
|
"z-index": zIndex(),
|
|
3667
|
-
...
|
|
3539
|
+
..._props.style
|
|
3668
3540
|
};
|
|
3669
3541
|
}
|
|
3670
|
-
}, divProps), !
|
|
3542
|
+
}, divProps), !0), insert(_el$, () => _props.children), _el$;
|
|
3671
3543
|
}
|
|
3672
3544
|
});
|
|
3673
3545
|
}
|
|
@@ -3675,9 +3547,9 @@ const NodeToolbar = (props) => {
|
|
|
3675
3547
|
};
|
|
3676
3548
|
//#endregion
|
|
3677
3549
|
//#region src/components/graph/selection/Selection.tsx
|
|
3678
|
-
var _tmpl$$3 =
|
|
3550
|
+
var _tmpl$$3 = /* @__PURE__ */ template("<div class=solid-flow__selection>");
|
|
3679
3551
|
const Selection = (props) => {
|
|
3680
|
-
let _props =
|
|
3552
|
+
let _props = propDefaults(props, { isVisible: !0 }), styles = () => ({
|
|
3681
3553
|
..._props.width != null && { width: typeof _props.width == "string" ? _props.width : toPxString(_props.width) },
|
|
3682
3554
|
..._props.height != null && { height: typeof _props.height == "string" ? _props.height : toPxString(_props.height) },
|
|
3683
3555
|
..._props.x != null && _props.y != null && { transform: `translate(${props.x}px, ${props.y}px)` }
|
|
@@ -3688,17 +3560,22 @@ const Selection = (props) => {
|
|
|
3688
3560
|
},
|
|
3689
3561
|
get children() {
|
|
3690
3562
|
var _el$ = _tmpl$$3();
|
|
3691
|
-
return effect((
|
|
3563
|
+
return effect(() => styles(), (_v$, _$p) => {
|
|
3564
|
+
style(_el$, _v$, _$p);
|
|
3565
|
+
}), _el$;
|
|
3692
3566
|
}
|
|
3693
3567
|
});
|
|
3694
3568
|
};
|
|
3695
3569
|
//#endregion
|
|
3696
3570
|
//#region src/components/graph/selection/NodeSelection.tsx
|
|
3697
|
-
var _tmpl$$2 =
|
|
3571
|
+
var _tmpl$$2 = /* @__PURE__ */ template("<div>");
|
|
3698
3572
|
const NodeSelection = (props) => {
|
|
3699
|
-
let { store, nodeLookup, actions } = useInternalSolidFlow(), [ref, setRef] = createSignal(), bounds = () => store.selectionRectMode === "nodes" ? getInternalNodesBounds(nodeLookup, { filter: (node) => !!node.selected }) : null;
|
|
3700
|
-
createEffect(() => {
|
|
3701
|
-
|
|
3573
|
+
let { store, nodeLookup, actions } = useInternalSolidFlow(), [ref$1, setRef] = createSignal(), bounds = () => store.selectionRectMode === "nodes" ? getInternalNodesBounds(nodeLookup, { filter: (node) => !!node.selected }) : null;
|
|
3574
|
+
createEffect(() => ({
|
|
3575
|
+
el: ref$1(),
|
|
3576
|
+
focusable: !store.disableKeyboardA11y
|
|
3577
|
+
}), ({ el, focusable }) => {
|
|
3578
|
+
focusable && el?.focus({ preventScroll: !0 });
|
|
3702
3579
|
});
|
|
3703
3580
|
let onContextMenu = (event) => {
|
|
3704
3581
|
let selectedNodes = store.nodes.filter((n) => n.selected);
|
|
@@ -3713,7 +3590,7 @@ const NodeSelection = (props) => {
|
|
|
3713
3590
|
event
|
|
3714
3591
|
});
|
|
3715
3592
|
};
|
|
3716
|
-
createDraggable(ref, () => ({
|
|
3593
|
+
createDraggable(ref$1, () => ({
|
|
3717
3594
|
disabled: !1,
|
|
3718
3595
|
onDrag: (event, _, __, nodes) => {
|
|
3719
3596
|
props.onNodeDrag?.({
|
|
@@ -3743,25 +3620,24 @@ const NodeSelection = (props) => {
|
|
|
3743
3620
|
};
|
|
3744
3621
|
return createComponent(Show, {
|
|
3745
3622
|
get when() {
|
|
3746
|
-
return memo(() => !!(store.selectionRectMode === "nodes" && bounds() && isNumeric(bounds()?.x)))()
|
|
3623
|
+
return memo(() => !!(store.selectionRectMode === "nodes" && bounds() && isNumeric(bounds()?.x)))() ? isNumeric(bounds()?.y) : store.selectionRectMode === "nodes" && bounds() && isNumeric(bounds()?.x);
|
|
3747
3624
|
},
|
|
3748
3625
|
get children() {
|
|
3749
3626
|
var _el$ = _tmpl$$2();
|
|
3750
|
-
return
|
|
3627
|
+
return addEvent(_el$, "keydown", store.disableKeyboardA11y ? void 0 : onKeyDown, !0), _el$.$$contextmenu = onContextMenu, _el$.$$click = onClick, ref(() => setRef, _el$), insert(_el$, createComponent(Selection, {
|
|
3751
3628
|
width: "100%",
|
|
3752
3629
|
height: "100%",
|
|
3753
3630
|
x: 0,
|
|
3754
3631
|
y: 0
|
|
3755
|
-
})), effect((
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
i
|
|
3764
|
-
n: void 0
|
|
3632
|
+
})), effect(() => ({
|
|
3633
|
+
e: ["solid-flow__selection-wrapper", store.noPanClass],
|
|
3634
|
+
t: toPxString(bounds()?.width),
|
|
3635
|
+
a: toPxString(bounds()?.height),
|
|
3636
|
+
o: `translate(${bounds()?.x}px, ${bounds()?.y}px)`,
|
|
3637
|
+
i: store.disableKeyboardA11y ? void 0 : "button",
|
|
3638
|
+
n: store.disableKeyboardA11y ? void 0 : -1
|
|
3639
|
+
}), ({ e, t, a, o, i, n }, _p$) => {
|
|
3640
|
+
className(_el$, e, _p$?.e), t !== _p$?.t && setStyleProperty(_el$, "width", t), a !== _p$?.a && setStyleProperty(_el$, "height", a), o !== _p$?.o && setStyleProperty(_el$, "transform", o), i !== _p$?.i && setAttribute(_el$, "role", i), n !== _p$?.n && setAttribute(_el$, "tabindex", n);
|
|
3765
3641
|
}), _el$;
|
|
3766
3642
|
}
|
|
3767
3643
|
});
|
|
@@ -3773,7 +3649,7 @@ delegateEvents([
|
|
|
3773
3649
|
]);
|
|
3774
3650
|
//#endregion
|
|
3775
3651
|
//#region src/components/utility/Attribution.tsx
|
|
3776
|
-
var _tmpl$$1 =
|
|
3652
|
+
var _tmpl$$1 = /* @__PURE__ */ template("<a href=https://solidflow.dev target=_blank rel=\"noopener noreferrer\"aria-label=\"Solid Flow attribution\">Solid Flow");
|
|
3777
3653
|
const Attribution = (props) => createComponent(Show, {
|
|
3778
3654
|
get when() {
|
|
3779
3655
|
return !props.proOptions?.hideAttribution;
|
|
@@ -3786,7 +3662,8 @@ const Attribution = (props) => createComponent(Show, {
|
|
|
3786
3662
|
class: "solid-flow__attribution",
|
|
3787
3663
|
"data-message": "Feel free to remove the attribution or check out how you could support us: https://solidflow.dev/support-us",
|
|
3788
3664
|
get children() {
|
|
3789
|
-
|
|
3665
|
+
var _el$ = _tmpl$$1();
|
|
3666
|
+
return claimElement(_el$), _el$;
|
|
3790
3667
|
}
|
|
3791
3668
|
});
|
|
3792
3669
|
}
|
|
@@ -3825,16 +3702,24 @@ function matchesKeyArray(event, keyDefs) {
|
|
|
3825
3702
|
return keyDefs ? (Array.isArray(keyDefs) ? keyDefs : [keyDefs]).some((keyDef) => matchesKey(event, keyDef)) : !1;
|
|
3826
3703
|
}
|
|
3827
3704
|
const KeyHandler = (props) => {
|
|
3828
|
-
let { store, actions } = useInternalSolidFlow(), { deleteElements } = useSolidFlow(), _props =
|
|
3829
|
-
selectionKey
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
}
|
|
3705
|
+
let { store, actions } = useInternalSolidFlow(), { deleteElements } = useSolidFlow(), _props = {
|
|
3706
|
+
get selectionKey() {
|
|
3707
|
+
return props.selectionKey ?? "Shift";
|
|
3708
|
+
},
|
|
3709
|
+
get multiSelectionKey() {
|
|
3710
|
+
return props.multiSelectionKey ?? (isMacOs() ? "Meta" : "Control");
|
|
3711
|
+
},
|
|
3712
|
+
get deleteKey() {
|
|
3713
|
+
return props.deleteKey ?? "Backspace";
|
|
3714
|
+
},
|
|
3715
|
+
get panActivationKey() {
|
|
3716
|
+
return props.panActivationKey ?? " ";
|
|
3717
|
+
},
|
|
3718
|
+
get zoomActivationKey() {
|
|
3719
|
+
return props.zoomActivationKey ?? (isMacOs() ? "Meta" : "Control");
|
|
3720
|
+
}
|
|
3721
|
+
}, resetKeysAndSelection = () => {
|
|
3722
|
+
actions.setSelectionRect(void 0), actions.setSelectionKeyPressed(!1), actions.setMultiselectionKeyPressed(!1), actions.setDeleteKeyPressed(!1), actions.setPanActivationKeyPressed(!1), actions.setZoomActivationKeyPressed(!1);
|
|
3838
3723
|
}, handleDelete = async () => {
|
|
3839
3724
|
let selectedNodes = store.nodes.filter((node) => node.selected), selectedEdges = store.edges.filter((edge) => edge.selected), { deletedNodes, deletedEdges } = await deleteElements({
|
|
3840
3725
|
nodes: selectedNodes,
|
|
@@ -3844,26 +3729,23 @@ const KeyHandler = (props) => {
|
|
|
3844
3729
|
nodes: deletedNodes,
|
|
3845
3730
|
edges: deletedEdges
|
|
3846
3731
|
});
|
|
3847
|
-
}, handleKeyDown = (event) => {
|
|
3848
|
-
batch(() => {
|
|
3849
|
-
matchesKeyArray(event, _props.selectionKey) && actions.setSelectionKeyPressed(!0), matchesKeyArray(event, _props.multiSelectionKey) && actions.setMultiselectionKeyPressed(!0), matchesKeyArray(event, _props.deleteKey) && !isInputDOMNode(event) && (event.ctrlKey || event.metaKey || event.shiftKey || (actions.setDeleteKeyPressed(!0), handleDelete())), matchesKeyArray(event, _props.panActivationKey) && actions.setPanActivationKeyPressed(!0), matchesKeyArray(event, _props.zoomActivationKey) && actions.setZoomActivationKeyPressed(!0);
|
|
3850
|
-
});
|
|
3851
|
-
}, handleKeyUp = (event) => {
|
|
3852
|
-
batch(() => {
|
|
3853
|
-
matchesKeyArray(event, _props.selectionKey) && actions.setSelectionKeyPressed(!1), matchesKeyArray(event, _props.multiSelectionKey) && actions.setMultiselectionKeyPressed(!1), matchesKeyArray(event, _props.deleteKey) && actions.setDeleteKeyPressed(!1), matchesKeyArray(event, _props.panActivationKey) && actions.setPanActivationKeyPressed(!1), matchesKeyArray(event, _props.zoomActivationKey) && actions.setZoomActivationKeyPressed(!1);
|
|
3854
|
-
});
|
|
3855
3732
|
};
|
|
3856
|
-
return
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
}
|
|
3733
|
+
return isServer || createEventListenerMap(window, {
|
|
3734
|
+
keydown: (event) => {
|
|
3735
|
+
matchesKeyArray(event, _props.selectionKey) && actions.setSelectionKeyPressed(!0), matchesKeyArray(event, _props.multiSelectionKey) && actions.setMultiselectionKeyPressed(!0), matchesKeyArray(event, _props.deleteKey) && !isInputDOMNode(event) && (event.ctrlKey || event.metaKey || event.shiftKey || (actions.setDeleteKeyPressed(!0), handleDelete())), matchesKeyArray(event, _props.panActivationKey) && actions.setPanActivationKeyPressed(!0), matchesKeyArray(event, _props.zoomActivationKey) && actions.setZoomActivationKeyPressed(!0), flush();
|
|
3736
|
+
},
|
|
3737
|
+
keyup: (event) => {
|
|
3738
|
+
matchesKeyArray(event, _props.selectionKey) && actions.setSelectionKeyPressed(!1), matchesKeyArray(event, _props.multiSelectionKey) && actions.setMultiselectionKeyPressed(!1), matchesKeyArray(event, _props.deleteKey) && actions.setDeleteKeyPressed(!1), matchesKeyArray(event, _props.panActivationKey) && actions.setPanActivationKeyPressed(!1), matchesKeyArray(event, _props.zoomActivationKey) && actions.setZoomActivationKeyPressed(!1), flush();
|
|
3739
|
+
},
|
|
3740
|
+
blur: resetKeysAndSelection,
|
|
3741
|
+
contextmenu: resetKeysAndSelection
|
|
3860
3742
|
}), null;
|
|
3861
3743
|
};
|
|
3862
3744
|
//#endregion
|
|
3863
3745
|
//#region src/components/SolidFlow/component.tsx
|
|
3864
|
-
var _tmpl$ =
|
|
3746
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__viewport-back\">"), _tmpl$2 = /* @__PURE__ */ template("<div class=\"solid-flow__container solid-flow__edge-labels\">"), _tmpl$3 = /* @__PURE__ */ template("<div>");
|
|
3865
3747
|
const SolidFlow = (props) => {
|
|
3866
|
-
let domNode, _props =
|
|
3748
|
+
let [domNodeRef, setDomNodeRef] = createSignal(), domNode, _props = merge({
|
|
3867
3749
|
...getDefaultFlowStateProps(),
|
|
3868
3750
|
colorMode: "light",
|
|
3869
3751
|
deleteKeyCode: "Backspace",
|
|
@@ -3889,274 +3771,275 @@ const SolidFlow = (props) => {
|
|
|
3889
3771
|
zoomOnPinch: !0,
|
|
3890
3772
|
zoomOnDoubleClick: !0,
|
|
3891
3773
|
zoomOnScroll: !0
|
|
3892
|
-
}, props),
|
|
3893
|
-
|
|
3894
|
-
actions.
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
actions.setPaneClickDistance(flowProps.paneClickDistance);
|
|
3900
|
-
}), onCleanup(() => {
|
|
3901
|
-
actions.reset();
|
|
3774
|
+
}, 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;
|
|
3775
|
+
onSettled(() => (actions.applyInitialFitView(_props.fitView), actions.setConfig(_props), actions.setDomNode(domNode), () => {
|
|
3776
|
+
actions.reset();
|
|
3777
|
+
})), createEffect(() => domNodeRef(), (el) => {
|
|
3778
|
+
if (!el) return;
|
|
3779
|
+
let observer = new ResizeObserver(() => {
|
|
3780
|
+
actions.setWidth(el.clientWidth), actions.setHeight(el.clientHeight);
|
|
3902
3781
|
});
|
|
3782
|
+
return observer.observe(el), () => observer.disconnect();
|
|
3783
|
+
}), createEffect(() => ({
|
|
3784
|
+
panZoom: store.panZoom,
|
|
3785
|
+
distance: _props.paneClickDistance
|
|
3786
|
+
}), ({ panZoom, distance }) => {
|
|
3787
|
+
panZoom?.setClickDistance(distance);
|
|
3903
3788
|
});
|
|
3904
3789
|
let selectedElements = createMemo(() => ({
|
|
3905
3790
|
nodes: store.selectedNodes,
|
|
3906
3791
|
edges: store.selectedEdges
|
|
3907
|
-
}),
|
|
3908
|
-
createEffect(() => {
|
|
3909
|
-
|
|
3910
|
-
untrack(() => flowProps.onSelectionChange)?.(params);
|
|
3792
|
+
}), { equals: (a, b) => a.nodes.length === b.nodes.length && a.edges.length === b.edges.length && a.nodes.every((node, i) => node.id === b.nodes[i].id) && a.edges.every((edge, i) => edge.id === b.edges[i].id) });
|
|
3793
|
+
createEffect(() => selectedElements(), (params) => {
|
|
3794
|
+
untrack(() => _props.onSelectionChange)?.(params);
|
|
3911
3795
|
});
|
|
3912
3796
|
let rootStyle = () => ({
|
|
3913
|
-
width: toPxString(
|
|
3914
|
-
height: toPxString(
|
|
3915
|
-
...
|
|
3797
|
+
width: toPxString(_props.width),
|
|
3798
|
+
height: toPxString(_props.height),
|
|
3799
|
+
..._props.style
|
|
3916
3800
|
});
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3801
|
+
var _el$ = _tmpl$3();
|
|
3802
|
+
return ref(() => (el) => {
|
|
3803
|
+
domNode = el, setDomNodeRef(el);
|
|
3804
|
+
}, _el$), spread(_el$, mergeProps({
|
|
3805
|
+
role: "application",
|
|
3806
|
+
"data-testid": "solid-flow__wrapper",
|
|
3807
|
+
get class() {
|
|
3808
|
+
return [
|
|
3809
|
+
"solid-flow",
|
|
3810
|
+
"solid-flow__container",
|
|
3811
|
+
_props.class,
|
|
3812
|
+
store.colorMode
|
|
3813
|
+
];
|
|
3814
|
+
},
|
|
3815
|
+
get style() {
|
|
3816
|
+
return rootStyle();
|
|
3817
|
+
},
|
|
3818
|
+
onScroll: (e) => {
|
|
3920
3819
|
e.currentTarget.scrollTo({
|
|
3921
3820
|
top: 0,
|
|
3922
3821
|
left: 0,
|
|
3923
3822
|
behavior: "auto"
|
|
3924
3823
|
});
|
|
3925
|
-
}
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
}
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
get
|
|
4021
|
-
return
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
}
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
}
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
createComponent(Attribution, {
|
|
4140
|
-
get proOptions() {
|
|
4141
|
-
return flowProps.proOptions;
|
|
4142
|
-
},
|
|
4143
|
-
get position() {
|
|
4144
|
-
return flowProps.attributionPosition;
|
|
4145
|
-
}
|
|
4146
|
-
}),
|
|
4147
|
-
createComponent(A11yDescriptions, {}),
|
|
4148
|
-
memo(() => flowProps.children)
|
|
4149
|
-
];
|
|
4150
|
-
}
|
|
4151
|
-
})), _el$;
|
|
4152
|
-
})();
|
|
3824
|
+
}
|
|
3825
|
+
}, htmlProps), !0), insert(_el$, createComponent(TypedSolidFlowContext, {
|
|
3826
|
+
value: solidFlow,
|
|
3827
|
+
get children() {
|
|
3828
|
+
return [
|
|
3829
|
+
createComponent(KeyHandler, {
|
|
3830
|
+
get selectionKey() {
|
|
3831
|
+
return _props.selectionKey;
|
|
3832
|
+
},
|
|
3833
|
+
get deleteKey() {
|
|
3834
|
+
return _props.deleteKey;
|
|
3835
|
+
},
|
|
3836
|
+
get panActivationKey() {
|
|
3837
|
+
return _props.panActivationKey;
|
|
3838
|
+
},
|
|
3839
|
+
get multiSelectionKey() {
|
|
3840
|
+
return _props.multiSelectionKey;
|
|
3841
|
+
},
|
|
3842
|
+
get zoomActivationKey() {
|
|
3843
|
+
return _props.zoomActivationKey;
|
|
3844
|
+
}
|
|
3845
|
+
}),
|
|
3846
|
+
createComponent(Zoom, {
|
|
3847
|
+
get panOnScrollMode() {
|
|
3848
|
+
return _props.panOnScrollMode;
|
|
3849
|
+
},
|
|
3850
|
+
get preventScrolling() {
|
|
3851
|
+
return _props.preventScrolling;
|
|
3852
|
+
},
|
|
3853
|
+
get zoomOnScroll() {
|
|
3854
|
+
return _props.zoomOnScroll;
|
|
3855
|
+
},
|
|
3856
|
+
get zoomOnDoubleClick() {
|
|
3857
|
+
return _props.zoomOnDoubleClick;
|
|
3858
|
+
},
|
|
3859
|
+
get zoomOnPinch() {
|
|
3860
|
+
return _props.zoomOnPinch;
|
|
3861
|
+
},
|
|
3862
|
+
get panOnScroll() {
|
|
3863
|
+
return _props.panOnScroll;
|
|
3864
|
+
},
|
|
3865
|
+
get panOnScrollSpeed() {
|
|
3866
|
+
return _props.panOnScrollSpeed;
|
|
3867
|
+
},
|
|
3868
|
+
get panOnDrag() {
|
|
3869
|
+
return _props.panOnDrag;
|
|
3870
|
+
},
|
|
3871
|
+
get paneClickDistance() {
|
|
3872
|
+
return _props.paneClickDistance;
|
|
3873
|
+
},
|
|
3874
|
+
get selectionOnDrag() {
|
|
3875
|
+
return _props.selectionOnDrag;
|
|
3876
|
+
},
|
|
3877
|
+
get onMoveStart() {
|
|
3878
|
+
return _props.onMoveStart;
|
|
3879
|
+
},
|
|
3880
|
+
get onMove() {
|
|
3881
|
+
return _props.onMove;
|
|
3882
|
+
},
|
|
3883
|
+
get onMoveEnd() {
|
|
3884
|
+
return _props.onMoveEnd;
|
|
3885
|
+
},
|
|
3886
|
+
get onViewportInitialized() {
|
|
3887
|
+
return _props.onInit;
|
|
3888
|
+
},
|
|
3889
|
+
get initialViewport() {
|
|
3890
|
+
return _props.viewport || _props.initialViewport;
|
|
3891
|
+
},
|
|
3892
|
+
get children() {
|
|
3893
|
+
return createComponent(Pane, {
|
|
3894
|
+
get onPaneClick() {
|
|
3895
|
+
return _props.onPaneClick;
|
|
3896
|
+
},
|
|
3897
|
+
get onPaneContextMenu() {
|
|
3898
|
+
return _props.onPaneContextMenu;
|
|
3899
|
+
},
|
|
3900
|
+
get onSelectionStart() {
|
|
3901
|
+
return _props.onSelectionStart;
|
|
3902
|
+
},
|
|
3903
|
+
get onSelectionEnd() {
|
|
3904
|
+
return _props.onSelectionEnd;
|
|
3905
|
+
},
|
|
3906
|
+
get panOnDrag() {
|
|
3907
|
+
return _props.panOnDrag;
|
|
3908
|
+
},
|
|
3909
|
+
get selectionOnDrag() {
|
|
3910
|
+
return _props.selectionOnDrag;
|
|
3911
|
+
},
|
|
3912
|
+
get paneClickDistance() {
|
|
3913
|
+
return _props.paneClickDistance;
|
|
3914
|
+
},
|
|
3915
|
+
get autoPanOnSelection() {
|
|
3916
|
+
return _props.autoPanOnSelection;
|
|
3917
|
+
},
|
|
3918
|
+
get children() {
|
|
3919
|
+
return [createComponent(Viewport, { get children() {
|
|
3920
|
+
return [
|
|
3921
|
+
_tmpl$(),
|
|
3922
|
+
createComponent(EdgeRenderer, {
|
|
3923
|
+
get reconnectRadius() {
|
|
3924
|
+
return _props.reconnectRadius;
|
|
3925
|
+
},
|
|
3926
|
+
get onEdgeClick() {
|
|
3927
|
+
return _props.onEdgeClick;
|
|
3928
|
+
},
|
|
3929
|
+
get onEdgeContextMenu() {
|
|
3930
|
+
return _props.onEdgeContextMenu;
|
|
3931
|
+
},
|
|
3932
|
+
get onEdgePointerEnter() {
|
|
3933
|
+
return _props.onEdgePointerEnter;
|
|
3934
|
+
},
|
|
3935
|
+
get onEdgePointerLeave() {
|
|
3936
|
+
return _props.onEdgePointerLeave;
|
|
3937
|
+
},
|
|
3938
|
+
get defaultEdgeOptions() {
|
|
3939
|
+
return _props.defaultEdgeOptions;
|
|
3940
|
+
}
|
|
3941
|
+
}),
|
|
3942
|
+
_tmpl$2(),
|
|
3943
|
+
createComponent(ConnectionLine, {
|
|
3944
|
+
get type() {
|
|
3945
|
+
return _props.connectionLineType;
|
|
3946
|
+
},
|
|
3947
|
+
get component() {
|
|
3948
|
+
return _props.connectionLineComponent;
|
|
3949
|
+
},
|
|
3950
|
+
get containerStyle() {
|
|
3951
|
+
return _props.connectionLineContainerStyle;
|
|
3952
|
+
},
|
|
3953
|
+
get style() {
|
|
3954
|
+
return _props.connectionLineStyle;
|
|
3955
|
+
}
|
|
3956
|
+
}),
|
|
3957
|
+
createComponent(NodeRenderer, {
|
|
3958
|
+
get nodeClickDistance() {
|
|
3959
|
+
return _props.nodeClickDistance;
|
|
3960
|
+
},
|
|
3961
|
+
get onNodeClick() {
|
|
3962
|
+
return _props.onNodeClick;
|
|
3963
|
+
},
|
|
3964
|
+
get onNodeContextMenu() {
|
|
3965
|
+
return _props.onNodeContextMenu;
|
|
3966
|
+
},
|
|
3967
|
+
get onNodePointerEnter() {
|
|
3968
|
+
return _props.onNodePointerEnter;
|
|
3969
|
+
},
|
|
3970
|
+
get onNodePointerMove() {
|
|
3971
|
+
return _props.onNodePointerMove;
|
|
3972
|
+
},
|
|
3973
|
+
get onNodePointerLeave() {
|
|
3974
|
+
return _props.onNodePointerLeave;
|
|
3975
|
+
},
|
|
3976
|
+
get onNodeDrag() {
|
|
3977
|
+
return _props.onNodeDrag;
|
|
3978
|
+
},
|
|
3979
|
+
get onNodeDragStart() {
|
|
3980
|
+
return _props.onNodeDragStart;
|
|
3981
|
+
},
|
|
3982
|
+
get onNodeDragStop() {
|
|
3983
|
+
return _props.onNodeDragStop;
|
|
3984
|
+
}
|
|
3985
|
+
}),
|
|
3986
|
+
createComponent(NodeSelection, {
|
|
3987
|
+
get onSelectionClick() {
|
|
3988
|
+
return _props.onSelectionClick;
|
|
3989
|
+
},
|
|
3990
|
+
get onSelectionContextMenu() {
|
|
3991
|
+
return _props.onSelectionContextMenu;
|
|
3992
|
+
},
|
|
3993
|
+
get onNodeDrag() {
|
|
3994
|
+
return _props.onNodeDrag;
|
|
3995
|
+
},
|
|
3996
|
+
get onNodeDragStart() {
|
|
3997
|
+
return _props.onNodeDragStart;
|
|
3998
|
+
},
|
|
3999
|
+
get onNodeDragStop() {
|
|
4000
|
+
return _props.onNodeDragStop;
|
|
4001
|
+
}
|
|
4002
|
+
})
|
|
4003
|
+
];
|
|
4004
|
+
} }), createComponent(Selection, {
|
|
4005
|
+
get isVisible() {
|
|
4006
|
+
return memo(() => !!store.selectionRect)() && store.selectionRectMode === "user";
|
|
4007
|
+
},
|
|
4008
|
+
get width() {
|
|
4009
|
+
return store.selectionRect?.width;
|
|
4010
|
+
},
|
|
4011
|
+
get height() {
|
|
4012
|
+
return store.selectionRect?.height;
|
|
4013
|
+
},
|
|
4014
|
+
get x() {
|
|
4015
|
+
return store.selectionRect?.x;
|
|
4016
|
+
},
|
|
4017
|
+
get y() {
|
|
4018
|
+
return store.selectionRect?.y;
|
|
4019
|
+
}
|
|
4020
|
+
})];
|
|
4021
|
+
}
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
4024
|
+
}),
|
|
4025
|
+
createComponent(Attribution, {
|
|
4026
|
+
get proOptions() {
|
|
4027
|
+
return _props.proOptions;
|
|
4028
|
+
},
|
|
4029
|
+
get position() {
|
|
4030
|
+
return _props.attributionPosition;
|
|
4031
|
+
}
|
|
4032
|
+
}),
|
|
4033
|
+
createComponent(A11yDescriptions, {}),
|
|
4034
|
+
memo(() => _props.children)
|
|
4035
|
+
];
|
|
4036
|
+
}
|
|
4037
|
+
})), _el$;
|
|
4153
4038
|
}, SolidFlowProvider = (props) => {
|
|
4154
|
-
let _props =
|
|
4155
|
-
onCleanup(() => {
|
|
4039
|
+
let _props = merge(getDefaultFlowStateProps(), props), solidFlow = createSolidFlow(_props);
|
|
4040
|
+
return onCleanup(() => {
|
|
4156
4041
|
solidFlow.actions.reset();
|
|
4157
|
-
})
|
|
4158
|
-
let ContextProvider = SolidFlowContext.Provider;
|
|
4159
|
-
return createComponent(ContextProvider, {
|
|
4042
|
+
}), createComponent(SolidFlowContext, {
|
|
4160
4043
|
value: solidFlow,
|
|
4161
4044
|
get children() {
|
|
4162
4045
|
return props.children;
|