@xyflow/vue 2.0.0-next.3 → 2.0.0-next.5
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.d.mts +338 -32
- package/dist/index.d.ts +338 -32
- package/dist/index.js +287 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +283 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createPropsRestProxy, createTextVNode, createVNode, defineComponent, effectScope, getCurrentInstance, h, inject, isMemoSame, isRef, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, openBlock, provide, reactive, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toRaw, toRef, toRefs, toValue, unref, useAttrs, useId, useModel, useSlots, watch, watchEffect, withCtx } from "vue";
|
|
2
|
-
import { ConnectionLineType, ConnectionLineType as ConnectionLineType$1, ConnectionMode, ConnectionMode as ConnectionMode$1, PanOnScrollMode, PanOnScrollMode as PanOnScrollMode$1, Position, Position as Position$1, ResizeControlVariant, ResizeControlVariant as ResizeControlVariant$2, SelectionMode, SelectionMode as SelectionMode$1, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, adoptUserNodes, areConnectionMapsEqual, areSetsEqual, calcAutoPan, calculateNodePosition, clamp, clampPosition, clampPositionToParent, evaluateAbsolutePosition, fitViewport, getBezierEdgeCenter, getBezierEdgeCenter as getBezierEdgeCenter$1, getBezierPath, getBezierPath as getBezierPath$1, getBoundsOfBoxes, getBoundsOfRects, getBoundsOfRects as getBoundsOfRects$1, getConnectedEdges, getConnectedEdges as getConnectedEdges$1, getConnectionStatus, getDimensions, getEdgeId, getElementsToRemove, getElevatedEdgeZIndex, getEventPosition, getHandleBounds, getHandlePosition, getHostForElement, getIncomers, getMarkerId, getMarkerId as getMarkerId$1, getNodeDimensions, getNodeToolbarTransform, getNodesBounds, getNodesBounds as getNodesBounds$1, getNodesInside, getNodesInside as getNodesInside$1, getOutgoers, getOverlappingArea, getSmoothStepPath, getSmoothStepPath as getSmoothStepPath$1, getStraightPath, getStraightPath as getStraightPath$1, getViewportForBounds, getViewportForBounds as getViewportForBounds$1, handleConnectionChange, handleExpandParent, infiniteExtent, isCoordinateExtent, isEdgeBase, isEdgeBase as isEdgeBase$1, isEdgeVisible, isInternalNodeBase, isInternalNodeBase as isInternalNodeBase$1, isMacOs, isMacOs as isMacOs$1, isMouseEvent, isNodeBase, isNodeBase as isNodeBase$1, isRectObject, mergeAriaLabelConfig, nodeHasDimensions, nodeToRect, oppositePosition, panBy, pointToRendererPoint, pointToRendererPoint as pointToRendererPoint$1, rendererPointToPoint, rendererPointToPoint as rendererPointToPoint$1, snapPosition, updateAbsolutePositions } from "@xyflow/system";
|
|
2
|
+
import { ConnectionLineType, ConnectionLineType as ConnectionLineType$1, ConnectionMode, ConnectionMode as ConnectionMode$1, PanOnScrollMode, PanOnScrollMode as PanOnScrollMode$1, Position, Position as Position$1, ResizeControlVariant, ResizeControlVariant as ResizeControlVariant$2, SelectionMode, SelectionMode as SelectionMode$1, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, addEdge as addEdge$1, adoptUserNodes, areConnectionMapsEqual, areSetsEqual, calcAutoPan, calculateNodePosition, clamp, clampPosition, clampPositionToParent, createDevWarn, evaluateAbsolutePosition, fitViewport, getBezierEdgeCenter, getBezierEdgeCenter as getBezierEdgeCenter$1, getBezierPath, getBezierPath as getBezierPath$1, getBoundsOfBoxes, getBoundsOfRects, getBoundsOfRects as getBoundsOfRects$1, getConnectedEdges, getConnectedEdges as getConnectedEdges$1, getConnectionStatus, getDimensions, getEdgeId, getEdgeToolbarTransform, getElementsToRemove, getElevatedEdgeZIndex, getEventPosition, getHandleBounds, getHandlePosition, getHostForElement, getIncomers, getMarkerId, getMarkerId as getMarkerId$1, getNodeDimensions, getNodeToolbarTransform, getNodesBounds, getNodesBounds as getNodesBounds$1, getNodesInside, getNodesInside as getNodesInside$1, getOutgoers, getOverlappingArea, getSmoothStepPath, getSmoothStepPath as getSmoothStepPath$1, getStraightPath, getStraightPath as getStraightPath$1, getViewportForBounds, getViewportForBounds as getViewportForBounds$1, handleConnectionChange, handleExpandParent, infiniteExtent, isCoordinateExtent, isEdgeBase, isEdgeBase as isEdgeBase$1, isEdgeVisible, isInternalNodeBase, isInternalNodeBase as isInternalNodeBase$1, isMacOs, isMacOs as isMacOs$1, isMouseEvent, isNodeBase, isNodeBase as isNodeBase$1, isRectObject, mergeAriaLabelConfig, nodeHasDimensions, nodeToRect, oppositePosition, panBy, pointToRendererPoint, pointToRendererPoint as pointToRendererPoint$1, reconnectEdge as reconnectEdge$1, rendererPointToPoint, rendererPointToPoint as rendererPointToPoint$1, snapPosition, updateAbsolutePositions } from "@xyflow/system";
|
|
3
3
|
import { onKeyStroke, until, useEventListener } from "@vueuse/core";
|
|
4
4
|
//#region src/context/index.ts
|
|
5
5
|
/** the curated instance (`useVueFlow()`) */
|
|
@@ -21,12 +21,14 @@ let ErrorCode = /* @__PURE__ */ function(ErrorCode) {
|
|
|
21
21
|
ErrorCode["NODE_MISSING_PARENT"] = "NODE_MISSING_PARENT";
|
|
22
22
|
ErrorCode["NODE_TYPE_MISSING"] = "NODE_TYPE_MISSING";
|
|
23
23
|
ErrorCode["NODE_EXTENT_INVALID"] = "NODE_EXTENT_INVALID";
|
|
24
|
+
ErrorCode["NODE_DUPLICATE_ID"] = "NODE_DUPLICATE_ID";
|
|
24
25
|
ErrorCode["EDGE_INVALID"] = "EDGE_INVALID";
|
|
25
26
|
ErrorCode["EDGE_NOT_FOUND"] = "EDGE_NOT_FOUND";
|
|
26
27
|
ErrorCode["EDGE_SOURCE_MISSING"] = "EDGE_SOURCE_MISSING";
|
|
27
28
|
ErrorCode["EDGE_TARGET_MISSING"] = "EDGE_TARGET_MISSING";
|
|
28
29
|
ErrorCode["EDGE_TYPE_MISSING"] = "EDGE_TYPE_MISSING";
|
|
29
30
|
ErrorCode["EDGE_SOURCE_TARGET_MISSING"] = "EDGE_SOURCE_TARGET_MISSING";
|
|
31
|
+
ErrorCode["EDGE_DUPLICATE_ID"] = "EDGE_DUPLICATE_ID";
|
|
30
32
|
ErrorCode["USE_VUE_FLOW_OUTSIDE_PROVIDER"] = "USE_VUE_FLOW_OUTSIDE_PROVIDER";
|
|
31
33
|
return ErrorCode;
|
|
32
34
|
}({});
|
|
@@ -38,11 +40,13 @@ const messages = {
|
|
|
38
40
|
["NODE_MISSING_PARENT"]: (id, parentId) => `Node is missing a parent\nNode id: ${id}\nParent id: ${parentId}`,
|
|
39
41
|
["NODE_TYPE_MISSING"]: (type) => `Node type is missing\nType: ${type}`,
|
|
40
42
|
["NODE_EXTENT_INVALID"]: (id) => `Only child nodes can use a parent extent\nNode id: ${id}`,
|
|
43
|
+
["NODE_DUPLICATE_ID"]: (id) => `Node id is not unique — a later node overwrites the earlier one in the lookup\nNode id: ${id}`,
|
|
41
44
|
["EDGE_INVALID"]: (id) => `An edge needs a source and a target\nEdge id: ${id}`,
|
|
42
45
|
["EDGE_SOURCE_MISSING"]: (id, source) => `Edge source is missing\nEdge id: ${id} \nSource id: ${source}`,
|
|
43
46
|
["EDGE_TARGET_MISSING"]: (id, target) => `Edge target is missing\nEdge id: ${id} \nTarget id: ${target}`,
|
|
44
47
|
["EDGE_TYPE_MISSING"]: (type) => `Edge type is missing\nType: ${type}`,
|
|
45
48
|
["EDGE_SOURCE_TARGET_MISSING"]: (id, source, target) => `Edge source or target is missing\nEdge id: ${id} \nSource id: ${source} \nTarget id: ${target}`,
|
|
49
|
+
["EDGE_DUPLICATE_ID"]: (id) => `Edge id is not unique — a later edge overwrites the earlier one in the lookup\nEdge id: ${id}`,
|
|
46
50
|
["EDGE_NOT_FOUND"]: (id) => `Edge not found\nEdge id: ${id}`,
|
|
47
51
|
["USE_VUE_FLOW_OUTSIDE_PROVIDER"]: () => `useVueFlow() was called without a <VueFlow> or <VueFlowProvider> ancestor (or outside a component setup). Render one of them above the call, or wrap your components in <VueFlowProvider> to share a store.`
|
|
48
52
|
};
|
|
@@ -110,7 +114,7 @@ var export_helper_default = (sfc, props) => {
|
|
|
110
114
|
};
|
|
111
115
|
//#endregion
|
|
112
116
|
//#region src/components/Background/Background.vue
|
|
113
|
-
const _sfc_main$
|
|
117
|
+
const _sfc_main$25 = /* @__PURE__ */ defineComponent({
|
|
114
118
|
name: "Background",
|
|
115
119
|
compatConfig: { MODE: 3 },
|
|
116
120
|
props: {
|
|
@@ -195,7 +199,7 @@ const _sfc_main$24 = /* @__PURE__ */ defineComponent({
|
|
|
195
199
|
return __returned__;
|
|
196
200
|
}
|
|
197
201
|
});
|
|
198
|
-
const _hoisted_1$
|
|
202
|
+
const _hoisted_1$15 = { class: "vue-flow__background vue-flow__container" };
|
|
199
203
|
const _hoisted_2$4 = [
|
|
200
204
|
"id",
|
|
201
205
|
"x",
|
|
@@ -209,8 +213,8 @@ const _hoisted_3$3 = [
|
|
|
209
213
|
"y",
|
|
210
214
|
"fill"
|
|
211
215
|
];
|
|
212
|
-
function _sfc_render$
|
|
213
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
216
|
+
function _sfc_render$25(_ctx, _cache, $props, $setup, $data, $options) {
|
|
217
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$15, [
|
|
214
218
|
renderSlot(_ctx.$slots, "pattern-container", { id: $setup.patternId }, () => [createElementVNode("pattern", {
|
|
215
219
|
id: $setup.patternId,
|
|
216
220
|
x: $setup.viewport.x % $setup.background.scaledGap[0],
|
|
@@ -243,10 +247,10 @@ function _sfc_render$24(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
243
247
|
renderSlot(_ctx.$slots, "default", { id: $setup.patternId })
|
|
244
248
|
]);
|
|
245
249
|
}
|
|
246
|
-
var Background_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
250
|
+
var Background_default = /* @__PURE__ */ export_helper_default(_sfc_main$25, [["render", _sfc_render$25], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Background/Background.vue"]]);
|
|
247
251
|
//#endregion
|
|
248
252
|
//#region src/components/Controls/ControlButton.vue
|
|
249
|
-
const _sfc_main$
|
|
253
|
+
const _sfc_main$24 = /* @__PURE__ */ defineComponent({
|
|
250
254
|
name: "ControlButton",
|
|
251
255
|
compatConfig: { MODE: 3 },
|
|
252
256
|
props: {
|
|
@@ -270,12 +274,12 @@ const _sfc_main$23 = /* @__PURE__ */ defineComponent({
|
|
|
270
274
|
return __returned__;
|
|
271
275
|
}
|
|
272
276
|
});
|
|
273
|
-
const _hoisted_1$
|
|
277
|
+
const _hoisted_1$14 = [
|
|
274
278
|
"disabled",
|
|
275
279
|
"aria-label",
|
|
276
280
|
"title"
|
|
277
281
|
];
|
|
278
|
-
function _sfc_render$
|
|
282
|
+
function _sfc_render$24(_ctx, _cache, $props, $setup, $data, $options) {
|
|
279
283
|
return openBlock(), createElementBlock("button", {
|
|
280
284
|
type: "button",
|
|
281
285
|
class: "vue-flow__controls-button",
|
|
@@ -283,9 +287,9 @@ function _sfc_render$23(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
283
287
|
"aria-label": $props.label,
|
|
284
288
|
title: $props.label,
|
|
285
289
|
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click", $event))
|
|
286
|
-
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$
|
|
290
|
+
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$14);
|
|
287
291
|
}
|
|
288
|
-
var ControlButton_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
292
|
+
var ControlButton_default = /* @__PURE__ */ export_helper_default(_sfc_main$24, [["render", _sfc_render$24], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Controls/ControlButton.vue"]]);
|
|
289
293
|
//#endregion
|
|
290
294
|
//#region src/composables/storeToRefs.ts
|
|
291
295
|
/**
|
|
@@ -314,7 +318,7 @@ function storeToRefs(store) {
|
|
|
314
318
|
* @param params
|
|
315
319
|
*/
|
|
316
320
|
function useDrag(params) {
|
|
317
|
-
const { panBy, getInternalNode, removeSelectedNodes, removeSelectedEdges, updateNodePositions, getNodes, getEdges } = useVueFlow();
|
|
321
|
+
const { panBy, getInternalNode, addSelectedNodes, removeSelectedNodes, removeSelectedEdges, updateNodePositions, getNodes, getEdges } = useVueFlow();
|
|
318
322
|
const store = useStore();
|
|
319
323
|
const { nodeLookup } = store;
|
|
320
324
|
const { onStart, onDrag, onStop, onClick, el, disabled, id, selectable, dragHandle } = params;
|
|
@@ -386,6 +390,13 @@ function useDrag(params) {
|
|
|
386
390
|
},
|
|
387
391
|
autoPanSpeed: store.autoPanSpeed
|
|
388
392
|
}),
|
|
393
|
+
onNodeMouseDown: (nodeId) => {
|
|
394
|
+
const node = getInternalNode(nodeId);
|
|
395
|
+
if (!node) return;
|
|
396
|
+
store.nodesSelectionActive = false;
|
|
397
|
+
if (!node.selected) addSelectedNodes([node]);
|
|
398
|
+
else if (store.multiSelectionActive) removeSelectedNodes([node]);
|
|
399
|
+
},
|
|
389
400
|
onDragStart: (event, _dragItems, node, nodes) => {
|
|
390
401
|
dragFired = true;
|
|
391
402
|
dragging.value = true;
|
|
@@ -825,12 +836,15 @@ function reconnectEdgeAction(edge, newConnection, prevEdge, shouldReplaceId, tri
|
|
|
825
836
|
*/
|
|
826
837
|
function adoptNodes(nodes, nodeLookup, parentLookup, triggerError, options) {
|
|
827
838
|
const validNodes = [];
|
|
839
|
+
const seenNodeIds = /* @__PURE__ */ new Set();
|
|
828
840
|
for (let i = 0; i < nodes.length; ++i) {
|
|
829
841
|
const node = nodes[i];
|
|
830
842
|
if (!isNode(node)) {
|
|
831
843
|
triggerError(new VueFlowError("NODE_INVALID", node?.id ?? `[ID UNKNOWN|INDEX ${i}]`));
|
|
832
844
|
continue;
|
|
833
845
|
}
|
|
846
|
+
if (seenNodeIds.has(node.id)) triggerError(new VueFlowError("NODE_DUPLICATE_ID", node.id));
|
|
847
|
+
else seenNodeIds.add(node.id);
|
|
834
848
|
validNodes.push(markRaw(toRaw(node)));
|
|
835
849
|
}
|
|
836
850
|
const priorInternals = /* @__PURE__ */ new Map();
|
|
@@ -1553,9 +1567,10 @@ function useViewportHelper(state, nodeLookup) {
|
|
|
1553
1567
|
/**
|
|
1554
1568
|
* Two-way bind a `v-model` array ref to the store, identity-in / snapshot-out, with native `watch`.
|
|
1555
1569
|
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1570
|
+
* Runs for BOTH the owned- and reused-store paths: the store's canonical nodes/edges are always an
|
|
1571
|
+
* internal `shallowRef` (see `createStore`), never the v-model ref, so this is the single place the model
|
|
1572
|
+
* ref is bridged to the store. Both directions flush synchronously so the model ref and the store's
|
|
1573
|
+
* synchronous reads (`getNodes`/`state.nodes`) never disagree within a tick.
|
|
1559
1574
|
*
|
|
1560
1575
|
* - **out** (store → model): snapshot on every membership change; element refs are shared, so per-node
|
|
1561
1576
|
* field mutations surface without a copy.
|
|
@@ -1568,24 +1583,29 @@ function syncModelArray(model, storeItems, setItems) {
|
|
|
1568
1583
|
watch([storeItems, () => storeItems.value.length], () => {
|
|
1569
1584
|
lastSnapshot = [...storeItems.value];
|
|
1570
1585
|
model.value = lastSnapshot;
|
|
1571
|
-
}, {
|
|
1586
|
+
}, {
|
|
1587
|
+
immediate: storeItems.value.length > 0,
|
|
1588
|
+
flush: "sync"
|
|
1589
|
+
});
|
|
1572
1590
|
watch([model, () => model.value?.length], ([next]) => {
|
|
1573
1591
|
if (!Array.isArray(next)) return;
|
|
1574
1592
|
const nextRaw = toRaw(next);
|
|
1575
1593
|
if (nextRaw === lastSnapshot) return;
|
|
1576
1594
|
setItems(nextRaw);
|
|
1577
|
-
}, {
|
|
1595
|
+
}, {
|
|
1596
|
+
immediate: true,
|
|
1597
|
+
flush: "sync"
|
|
1598
|
+
});
|
|
1578
1599
|
}
|
|
1579
1600
|
/**
|
|
1580
1601
|
* Watches props and updates the store accordingly
|
|
1581
1602
|
*
|
|
1582
1603
|
* @internal
|
|
1583
|
-
* @param models v-model refs for nodes/edges
|
|
1604
|
+
* @param models v-model refs for nodes/edges — bridged to the store here (see {@link syncModelArray})
|
|
1584
1605
|
* @param props the `<VueFlow>` props
|
|
1585
1606
|
* @param handle the created store handle ({@link VueFlowStoreHandle}) — instance (actions) + reactive state
|
|
1586
|
-
* @param ownsStore whether this `<VueFlow>` created the store (then nodes/edges are signal-backed and skipped here)
|
|
1587
1607
|
*/
|
|
1588
|
-
function useWatchProps(models, props, handle
|
|
1608
|
+
function useWatchProps(models, props, handle) {
|
|
1589
1609
|
const { instance, state } = handle;
|
|
1590
1610
|
const storeRefs = storeToRefs(state);
|
|
1591
1611
|
const scope = effectScope(true);
|
|
@@ -1689,10 +1709,8 @@ function useWatchProps(models, props, handle, ownsStore = false) {
|
|
|
1689
1709
|
}
|
|
1690
1710
|
};
|
|
1691
1711
|
const runAll = () => {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
watchEdgesValue();
|
|
1695
|
-
}
|
|
1712
|
+
watchNodesValue();
|
|
1713
|
+
watchEdgesValue();
|
|
1696
1714
|
watchMinZoom();
|
|
1697
1715
|
watchMaxZoom();
|
|
1698
1716
|
watchTranslateExtent();
|
|
@@ -1708,13 +1726,14 @@ function useWatchProps(models, props, handle, ownsStore = false) {
|
|
|
1708
1726
|
}
|
|
1709
1727
|
//#endregion
|
|
1710
1728
|
//#region src/components/Panel/Panel.vue
|
|
1711
|
-
const _sfc_main$
|
|
1729
|
+
const _sfc_main$23 = /* @__PURE__ */ defineComponent({
|
|
1712
1730
|
name: "Panel",
|
|
1713
1731
|
compatConfig: { MODE: 3 },
|
|
1714
1732
|
props: {
|
|
1715
1733
|
position: {
|
|
1716
1734
|
type: String,
|
|
1717
|
-
required:
|
|
1735
|
+
required: false,
|
|
1736
|
+
default: "top-left"
|
|
1718
1737
|
},
|
|
1719
1738
|
label: {
|
|
1720
1739
|
type: [String, null],
|
|
@@ -1737,15 +1756,15 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
|
|
|
1737
1756
|
return __returned__;
|
|
1738
1757
|
}
|
|
1739
1758
|
});
|
|
1740
|
-
const _hoisted_1$
|
|
1741
|
-
function _sfc_render$
|
|
1759
|
+
const _hoisted_1$13 = ["aria-label"];
|
|
1760
|
+
function _sfc_render$23(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1742
1761
|
return openBlock(), createElementBlock("div", {
|
|
1743
1762
|
class: normalizeClass(["vue-flow__panel", $setup.positionClasses]),
|
|
1744
1763
|
"aria-label": $props.label ?? void 0,
|
|
1745
1764
|
style: normalizeStyle({ pointerEvents: $setup.userSelectionActive ? "none" : "all" })
|
|
1746
|
-
}, [renderSlot(_ctx.$slots, "default")], 14, _hoisted_1$
|
|
1765
|
+
}, [renderSlot(_ctx.$slots, "default")], 14, _hoisted_1$13);
|
|
1747
1766
|
}
|
|
1748
|
-
var Panel_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
1767
|
+
var Panel_default = /* @__PURE__ */ export_helper_default(_sfc_main$23, [["render", _sfc_render$23], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Panel/Panel.vue"]]);
|
|
1749
1768
|
//#endregion
|
|
1750
1769
|
//#region src/components/Controls/icons.ts
|
|
1751
1770
|
function icon(viewBox, d) {
|
|
@@ -1762,7 +1781,7 @@ const Lock = icon("0 0 25 32", "M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 1
|
|
|
1762
1781
|
const Unlock = icon("0 0 25 32", "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");
|
|
1763
1782
|
//#endregion
|
|
1764
1783
|
//#region src/components/Controls/Controls.vue
|
|
1765
|
-
const _sfc_main$
|
|
1784
|
+
const _sfc_main$22 = /* @__PURE__ */ defineComponent({
|
|
1766
1785
|
name: "Controls",
|
|
1767
1786
|
compatConfig: { MODE: 3 },
|
|
1768
1787
|
props: {
|
|
@@ -1872,7 +1891,7 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
|
1872
1891
|
return __returned__;
|
|
1873
1892
|
}
|
|
1874
1893
|
});
|
|
1875
|
-
function _sfc_render$
|
|
1894
|
+
function _sfc_render$22(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1876
1895
|
return openBlock(), createBlock($setup["Panel"], {
|
|
1877
1896
|
class: "vue-flow__controls",
|
|
1878
1897
|
position: $props.position,
|
|
@@ -1919,10 +1938,10 @@ function _sfc_render$21(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1919
1938
|
_: 3
|
|
1920
1939
|
}, 8, ["position", "label"]);
|
|
1921
1940
|
}
|
|
1922
|
-
var Controls_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
1941
|
+
var Controls_default = /* @__PURE__ */ export_helper_default(_sfc_main$22, [["render", _sfc_render$22], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Controls/Controls.vue"]]);
|
|
1923
1942
|
//#endregion
|
|
1924
1943
|
//#region src/components/Edges/EdgeText.vue
|
|
1925
|
-
const _sfc_main$
|
|
1944
|
+
const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
1926
1945
|
name: "EdgeText",
|
|
1927
1946
|
compatConfig: { MODE: 3 },
|
|
1928
1947
|
props: {
|
|
@@ -2002,7 +2021,7 @@ const _sfc_main$20 = /* @__PURE__ */ defineComponent({
|
|
|
2002
2021
|
return __returned__;
|
|
2003
2022
|
}
|
|
2004
2023
|
});
|
|
2005
|
-
const _hoisted_1$
|
|
2024
|
+
const _hoisted_1$12 = ["transform", "visibility"];
|
|
2006
2025
|
const _hoisted_2$3 = [
|
|
2007
2026
|
"width",
|
|
2008
2027
|
"height",
|
|
@@ -2012,7 +2031,7 @@ const _hoisted_2$3 = [
|
|
|
2012
2031
|
"ry"
|
|
2013
2032
|
];
|
|
2014
2033
|
const _hoisted_3$2 = ["y"];
|
|
2015
|
-
function _sfc_render$
|
|
2034
|
+
function _sfc_render$21(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2016
2035
|
return openBlock(), createElementBlock("g", {
|
|
2017
2036
|
transform: $setup.transform,
|
|
2018
2037
|
visibility: $setup.box.width ? "visible" : "hidden",
|
|
@@ -2033,12 +2052,12 @@ function _sfc_render$20(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2033
2052
|
y: $setup.box.height / 2,
|
|
2034
2053
|
dy: "0.3em",
|
|
2035
2054
|
style: $props.labelStyle
|
|
2036
|
-
}), [renderSlot(_ctx.$slots, "default", {}, () => [typeof $props.label !== "string" ? (openBlock(), createBlock(resolveDynamicComponent($props.label), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString($props.label), 1)], 64))])], 16, _hoisted_3$2)], 8, _hoisted_1$
|
|
2055
|
+
}), [renderSlot(_ctx.$slots, "default", {}, () => [typeof $props.label !== "string" ? (openBlock(), createBlock(resolveDynamicComponent($props.label), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString($props.label), 1)], 64))])], 16, _hoisted_3$2)], 8, _hoisted_1$12);
|
|
2037
2056
|
}
|
|
2038
|
-
var EdgeText_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
2057
|
+
var EdgeText_default = /* @__PURE__ */ export_helper_default(_sfc_main$21, [["render", _sfc_render$21], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Edges/EdgeText.vue"]]);
|
|
2039
2058
|
//#endregion
|
|
2040
2059
|
//#region src/components/Edges/BaseEdge.vue
|
|
2041
|
-
const _sfc_main$
|
|
2060
|
+
const _sfc_main$20 = /* @__PURE__ */ defineComponent({
|
|
2042
2061
|
name: "BaseEdge",
|
|
2043
2062
|
inheritAttrs: false,
|
|
2044
2063
|
compatConfig: { MODE: 3 },
|
|
@@ -2121,14 +2140,14 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
|
|
|
2121
2140
|
return __returned__;
|
|
2122
2141
|
}
|
|
2123
2142
|
});
|
|
2124
|
-
const _hoisted_1$
|
|
2143
|
+
const _hoisted_1$11 = [
|
|
2125
2144
|
"id",
|
|
2126
2145
|
"d",
|
|
2127
2146
|
"marker-end",
|
|
2128
2147
|
"marker-start"
|
|
2129
2148
|
];
|
|
2130
2149
|
const _hoisted_2$2 = ["d", "stroke-width"];
|
|
2131
|
-
function _sfc_render$
|
|
2150
|
+
function _sfc_render$20(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2132
2151
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
2133
2152
|
createElementVNode("path", mergeProps($setup.attrs, {
|
|
2134
2153
|
id: $props.id,
|
|
@@ -2137,7 +2156,7 @@ function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2137
2156
|
class: "vue-flow__edge-path",
|
|
2138
2157
|
"marker-end": $props.markerEnd,
|
|
2139
2158
|
"marker-start": $props.markerStart
|
|
2140
|
-
}), null, 16, _hoisted_1$
|
|
2159
|
+
}), null, 16, _hoisted_1$11),
|
|
2141
2160
|
$props.interactionWidth ? (openBlock(), createElementBlock("path", {
|
|
2142
2161
|
key: 0,
|
|
2143
2162
|
ref: "interactionEl",
|
|
@@ -2170,7 +2189,7 @@ function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2170
2189
|
])) : createCommentVNode("v-if", true)
|
|
2171
2190
|
], 64);
|
|
2172
2191
|
}
|
|
2173
|
-
var BaseEdge_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
2192
|
+
var BaseEdge_default = /* @__PURE__ */ export_helper_default(_sfc_main$20, [["render", _sfc_render$20], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Edges/BaseEdge.vue"]]);
|
|
2174
2193
|
//#endregion
|
|
2175
2194
|
//#region src/components/Edges/utils.ts
|
|
2176
2195
|
/**
|
|
@@ -2238,7 +2257,7 @@ const BezierEdge = defineComponent({
|
|
|
2238
2257
|
});
|
|
2239
2258
|
//#endregion
|
|
2240
2259
|
//#region src/components/Edges/EdgeLabelRenderer.vue
|
|
2241
|
-
const _sfc_main$
|
|
2260
|
+
const _sfc_main$19 = /* @__PURE__ */ defineComponent({
|
|
2242
2261
|
name: "EdgeLabelRenderer",
|
|
2243
2262
|
compatConfig: { MODE: 3 },
|
|
2244
2263
|
setup(__props, { expose: __expose }) {
|
|
@@ -2255,17 +2274,17 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
|
|
|
2255
2274
|
return __returned__;
|
|
2256
2275
|
}
|
|
2257
2276
|
});
|
|
2258
|
-
const _hoisted_1$
|
|
2277
|
+
const _hoisted_1$10 = {
|
|
2259
2278
|
height: "0",
|
|
2260
2279
|
width: "0"
|
|
2261
2280
|
};
|
|
2262
|
-
function _sfc_render$
|
|
2263
|
-
return openBlock(), createElementBlock("svg", null, [(openBlock(), createElementBlock("foreignObject", _hoisted_1$
|
|
2281
|
+
function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2282
|
+
return openBlock(), createElementBlock("svg", null, [(openBlock(), createElementBlock("foreignObject", _hoisted_1$10, [(openBlock(), createBlock(Teleport, {
|
|
2264
2283
|
to: $setup.teleportTarget,
|
|
2265
2284
|
disabled: !$setup.teleportTarget
|
|
2266
2285
|
}, [renderSlot(_ctx.$slots, "default")], 8, ["to", "disabled"]))]))]);
|
|
2267
2286
|
}
|
|
2268
|
-
var EdgeLabelRenderer_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
2287
|
+
var EdgeLabelRenderer_default = /* @__PURE__ */ export_helper_default(_sfc_main$19, [["render", _sfc_render$19], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Edges/EdgeLabelRenderer.vue"]]);
|
|
2269
2288
|
//#endregion
|
|
2270
2289
|
//#region src/components/Edges/SimpleBezierEdge.ts
|
|
2271
2290
|
function getControl({ pos, x1, y1, x2, y2 }) {
|
|
@@ -2474,7 +2493,7 @@ const StraightEdge = defineComponent({
|
|
|
2474
2493
|
});
|
|
2475
2494
|
//#endregion
|
|
2476
2495
|
//#region src/components/Handle/Handle.vue
|
|
2477
|
-
const _sfc_main$
|
|
2496
|
+
const _sfc_main$18 = /* @__PURE__ */ defineComponent({
|
|
2478
2497
|
name: "Handle",
|
|
2479
2498
|
compatConfig: { MODE: 3 },
|
|
2480
2499
|
props: {
|
|
@@ -2646,8 +2665,8 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
|
|
|
2646
2665
|
return __returned__;
|
|
2647
2666
|
}
|
|
2648
2667
|
});
|
|
2649
|
-
const _hoisted_1$
|
|
2650
|
-
function _sfc_render$
|
|
2668
|
+
const _hoisted_1$9 = ["aria-label"];
|
|
2669
|
+
function _sfc_render$18(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2651
2670
|
return openBlock(), createElementBlock("div", mergeProps({ ref: "handle" }, $setup.handleDataIds, {
|
|
2652
2671
|
"aria-label": $setup.store.ariaLabelConfig["handle.ariaLabel"],
|
|
2653
2672
|
class: ["vue-flow__handle", [
|
|
@@ -2661,9 +2680,84 @@ function _sfc_render$17(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2661
2680
|
onMousedown: $setup.onPointerDown,
|
|
2662
2681
|
onTouchstartPassive: $setup.onPointerDown,
|
|
2663
2682
|
onClick: $setup.onClick
|
|
2664
|
-
}), [renderSlot(_ctx.$slots, "default", { id: $props.id })], 16, _hoisted_1$
|
|
2683
|
+
}), [renderSlot(_ctx.$slots, "default", { id: $props.id })], 16, _hoisted_1$9);
|
|
2665
2684
|
}
|
|
2666
|
-
var Handle_default = /* @__PURE__ */ export_helper_default(_sfc_main$
|
|
2685
|
+
var Handle_default = /* @__PURE__ */ export_helper_default(_sfc_main$18, [["render", _sfc_render$18], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/Handle/Handle.vue"]]);
|
|
2686
|
+
//#endregion
|
|
2687
|
+
//#region src/components/EdgeToolbar/EdgeToolbar.vue
|
|
2688
|
+
const _sfc_main$17 = /* @__PURE__ */ defineComponent({
|
|
2689
|
+
name: "EdgeToolbar",
|
|
2690
|
+
compatConfig: { MODE: 3 },
|
|
2691
|
+
inheritAttrs: false,
|
|
2692
|
+
props: {
|
|
2693
|
+
edgeId: {
|
|
2694
|
+
type: String,
|
|
2695
|
+
required: true
|
|
2696
|
+
},
|
|
2697
|
+
x: {
|
|
2698
|
+
type: Number,
|
|
2699
|
+
required: true
|
|
2700
|
+
},
|
|
2701
|
+
y: {
|
|
2702
|
+
type: Number,
|
|
2703
|
+
required: true
|
|
2704
|
+
},
|
|
2705
|
+
isVisible: {
|
|
2706
|
+
type: Boolean,
|
|
2707
|
+
required: false,
|
|
2708
|
+
default: void 0
|
|
2709
|
+
},
|
|
2710
|
+
alignX: {
|
|
2711
|
+
type: String,
|
|
2712
|
+
required: false,
|
|
2713
|
+
default: "center"
|
|
2714
|
+
},
|
|
2715
|
+
alignY: {
|
|
2716
|
+
type: String,
|
|
2717
|
+
required: false,
|
|
2718
|
+
default: "center"
|
|
2719
|
+
}
|
|
2720
|
+
},
|
|
2721
|
+
setup(__props, { expose: __expose }) {
|
|
2722
|
+
__expose();
|
|
2723
|
+
const props = __props;
|
|
2724
|
+
const { viewport } = useVueFlow();
|
|
2725
|
+
const { edgeLookup } = useStore();
|
|
2726
|
+
const edge = computed(() => edgeLookup.get(props.edgeId));
|
|
2727
|
+
const __returned__ = {
|
|
2728
|
+
props,
|
|
2729
|
+
viewport,
|
|
2730
|
+
edgeLookup,
|
|
2731
|
+
edge,
|
|
2732
|
+
isActive: computed(() => typeof props.isVisible === "boolean" ? props.isVisible : edge.value?.selected),
|
|
2733
|
+
wrapperStyle: computed(() => ({
|
|
2734
|
+
position: "absolute",
|
|
2735
|
+
transform: getEdgeToolbarTransform(props.x, props.y, viewport.value.zoom, props.alignX, props.alignY),
|
|
2736
|
+
zIndex: (edge.value?.zIndex ?? 0) + 1,
|
|
2737
|
+
pointerEvents: "all",
|
|
2738
|
+
transformOrigin: "0 0"
|
|
2739
|
+
})),
|
|
2740
|
+
EdgeLabelRenderer: EdgeLabelRenderer_default
|
|
2741
|
+
};
|
|
2742
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
2743
|
+
enumerable: false,
|
|
2744
|
+
value: true
|
|
2745
|
+
});
|
|
2746
|
+
return __returned__;
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
const _hoisted_1$8 = ["data-id"];
|
|
2750
|
+
function _sfc_render$17(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2751
|
+
return $setup.isActive ? (openBlock(), createBlock($setup["EdgeLabelRenderer"], { key: 0 }, {
|
|
2752
|
+
default: withCtx(() => [createElementVNode("div", mergeProps(_ctx.$attrs, {
|
|
2753
|
+
style: $setup.wrapperStyle,
|
|
2754
|
+
"data-id": $setup.edge?.id ?? "",
|
|
2755
|
+
class: "vue-flow__edge-toolbar"
|
|
2756
|
+
}), [renderSlot(_ctx.$slots, "default")], 16, _hoisted_1$8)]),
|
|
2757
|
+
_: 3
|
|
2758
|
+
})) : createCommentVNode("v-if", true);
|
|
2759
|
+
}
|
|
2760
|
+
var EdgeToolbar_default = /* @__PURE__ */ export_helper_default(_sfc_main$17, [["render", _sfc_render$17], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/EdgeToolbar/EdgeToolbar.vue"]]);
|
|
2667
2761
|
//#endregion
|
|
2668
2762
|
//#region src/components/MiniMap/types.ts
|
|
2669
2763
|
const Slots = Symbol("MiniMapSlots");
|
|
@@ -3306,14 +3400,16 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
|
|
|
3306
3400
|
const { nodeLookup, parentLookup } = useStore();
|
|
3307
3401
|
const { transform, nodeOrigin, snapGrid, snapToGrid, vueFlowRef, noDragClassName } = storeToRefs(useStore());
|
|
3308
3402
|
const resizeControlRef = shallowRef();
|
|
3403
|
+
const contextNodeId = inject(NodeId, null);
|
|
3404
|
+
const nodeId = toRef(() => typeof props.nodeId === "string" ? props.nodeId : contextNodeId ?? void 0);
|
|
3309
3405
|
const controlPosition = toRef(() => props.position ?? DefaultPositions[props.variant]);
|
|
3310
3406
|
const positionClassNames = computed(() => controlPosition.value.split("-"));
|
|
3311
3407
|
const controlStyle = toRef(() => props.color ? { [StylingProperty[props.variant]]: props.color } : {});
|
|
3312
3408
|
watchEffect((onCleanup) => {
|
|
3313
|
-
if (!resizeControlRef.value || !
|
|
3409
|
+
if (!resizeControlRef.value || !nodeId.value) return;
|
|
3314
3410
|
const resizerInstance = XYResizer({
|
|
3315
3411
|
domNode: resizeControlRef.value,
|
|
3316
|
-
nodeId:
|
|
3412
|
+
nodeId: nodeId.value,
|
|
3317
3413
|
getStoreItems: () => ({
|
|
3318
3414
|
nodeLookup,
|
|
3319
3415
|
transform: transform.value,
|
|
@@ -3324,7 +3420,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
|
|
|
3324
3420
|
}),
|
|
3325
3421
|
onChange: (changes, childChanges) => {
|
|
3326
3422
|
const nodeChanges = [];
|
|
3327
|
-
const node = nodeLookup.get(
|
|
3423
|
+
const node = nodeLookup.get(nodeId.value);
|
|
3328
3424
|
let nextX = changes.x;
|
|
3329
3425
|
let nextY = changes.y;
|
|
3330
3426
|
if (node?.expandParent && node.parentId) {
|
|
@@ -3356,14 +3452,14 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
|
|
|
3356
3452
|
y: nextY ?? node?.position.y ?? 0
|
|
3357
3453
|
};
|
|
3358
3454
|
nodeChanges.push({
|
|
3359
|
-
id:
|
|
3455
|
+
id: nodeId.value,
|
|
3360
3456
|
type: "position",
|
|
3361
3457
|
position,
|
|
3362
3458
|
positionAbsolute: position
|
|
3363
3459
|
});
|
|
3364
3460
|
}
|
|
3365
3461
|
if (typeof changes.width !== "undefined" || typeof changes.height !== "undefined") nodeChanges.push({
|
|
3366
|
-
id:
|
|
3462
|
+
id: nodeId.value,
|
|
3367
3463
|
type: "dimensions",
|
|
3368
3464
|
setAttributes: true,
|
|
3369
3465
|
resizing: true,
|
|
@@ -3382,7 +3478,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
|
|
|
3382
3478
|
},
|
|
3383
3479
|
onEnd: ({ width, height }) => {
|
|
3384
3480
|
triggerEmits.nodesChange([{
|
|
3385
|
-
id:
|
|
3481
|
+
id: nodeId.value,
|
|
3386
3482
|
type: "dimensions",
|
|
3387
3483
|
resizing: false,
|
|
3388
3484
|
dimensions: {
|
|
@@ -3433,6 +3529,8 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
|
|
|
3433
3529
|
vueFlowRef,
|
|
3434
3530
|
noDragClassName,
|
|
3435
3531
|
resizeControlRef,
|
|
3532
|
+
contextNodeId,
|
|
3533
|
+
nodeId,
|
|
3436
3534
|
controlPosition,
|
|
3437
3535
|
positionClassNames,
|
|
3438
3536
|
controlStyle,
|
|
@@ -4276,8 +4374,11 @@ function useActions(state, nodeLookup, parentLookup, edgeLookup) {
|
|
|
4276
4374
|
*/
|
|
4277
4375
|
function commitEdges(next) {
|
|
4278
4376
|
const rawEdgeLookup = toRaw(edgeLookup);
|
|
4377
|
+
const seenEdgeIds = /* @__PURE__ */ new Set();
|
|
4279
4378
|
for (let i = 0; i < next.length; i++) {
|
|
4280
4379
|
const edge = next[i] = markRaw(toRaw(next[i]));
|
|
4380
|
+
if (seenEdgeIds.has(edge.id)) state.hooks.error.trigger(new VueFlowError("EDGE_DUPLICATE_ID", edge.id));
|
|
4381
|
+
else seenEdgeIds.add(edge.id);
|
|
4281
4382
|
if (rawEdgeLookup.get(edge.id) !== edge) edgeLookup.set(edge.id, edge);
|
|
4282
4383
|
}
|
|
4283
4384
|
if (rawEdgeLookup.size !== next.length) {
|
|
@@ -4961,17 +5062,14 @@ function useGetters(state, nodeLookup) {
|
|
|
4961
5062
|
* @internal
|
|
4962
5063
|
*/
|
|
4963
5064
|
function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
4964
|
-
const nodesSignal = signals?.nodes ??
|
|
4965
|
-
const edgesSignal = signals?.edges ??
|
|
4966
|
-
let lastWriteNodes;
|
|
4967
|
-
let lastWriteEdges;
|
|
5065
|
+
const nodesSignal = shallowRef(signals?.nodes?.value ?? []);
|
|
5066
|
+
const edgesSignal = shallowRef(signals?.edges?.value ?? []);
|
|
4968
5067
|
const emptyNodes = [];
|
|
4969
5068
|
const emptyEdges = [];
|
|
4970
5069
|
const state = useState();
|
|
4971
5070
|
Object.defineProperty(state, "nodes", {
|
|
4972
5071
|
get: () => nodesSignal.value ?? emptyNodes,
|
|
4973
5072
|
set: (value) => {
|
|
4974
|
-
lastWriteNodes = toRaw(value);
|
|
4975
5073
|
nodesSignal.value = value;
|
|
4976
5074
|
},
|
|
4977
5075
|
enumerable: true,
|
|
@@ -4980,7 +5078,6 @@ function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
|
4980
5078
|
Object.defineProperty(state, "edges", {
|
|
4981
5079
|
get: () => edgesSignal.value ?? emptyEdges,
|
|
4982
5080
|
set: (value) => {
|
|
4983
|
-
lastWriteEdges = toRaw(value);
|
|
4984
5081
|
edgesSignal.value = value;
|
|
4985
5082
|
},
|
|
4986
5083
|
enumerable: true,
|
|
@@ -5003,14 +5100,6 @@ function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
|
5003
5100
|
...reactiveState,
|
|
5004
5101
|
...preloadedState
|
|
5005
5102
|
});
|
|
5006
|
-
if (signals?.nodes) watch(nodesSignal, (next) => {
|
|
5007
|
-
const nextRaw = next && toRaw(next);
|
|
5008
|
-
if (nextRaw && nextRaw !== lastWriteNodes) actions.setNodes(nextRaw);
|
|
5009
|
-
});
|
|
5010
|
-
if (signals?.edges) watch(edgesSignal, (next) => {
|
|
5011
|
-
const nextRaw = next && toRaw(next);
|
|
5012
|
-
if (nextRaw && nextRaw !== lastWriteEdges) actions.setEdges(nextRaw);
|
|
5013
|
-
});
|
|
5014
5103
|
return {
|
|
5015
5104
|
instance: {
|
|
5016
5105
|
...hooksOn,
|
|
@@ -5161,7 +5250,7 @@ function useViewportSync(model, state = useStore()) {
|
|
|
5161
5250
|
};
|
|
5162
5251
|
if (sameViewport(viewport, model.value)) return;
|
|
5163
5252
|
model.value = viewport;
|
|
5164
|
-
});
|
|
5253
|
+
}, { flush: "sync" });
|
|
5165
5254
|
}
|
|
5166
5255
|
//#endregion
|
|
5167
5256
|
//#region src/components/ConnectionLine/index.ts
|
|
@@ -5194,13 +5283,13 @@ const ConnectionLine = defineComponent({
|
|
|
5194
5283
|
}
|
|
5195
5284
|
const fromHandle = (startHandleId ? handleBounds.find((d) => d.id === startHandleId) : handleBounds[0]) ?? null;
|
|
5196
5285
|
const fromPosition = fromHandle?.position ?? Position$1.Top;
|
|
5197
|
-
const { x: fromX, y: fromY } = getHandlePosition(fromNode.value, fromHandle, fromPosition);
|
|
5286
|
+
const { x: fromX, y: fromY } = getHandlePosition(fromNode.value, fromHandle, fromPosition, true);
|
|
5198
5287
|
let toHandle = null;
|
|
5199
5288
|
if (toNode.value) if (connectionMode.value === ConnectionMode$1.Strict) toHandle = toNode.value.internals.handleBounds?.[handleType === "source" ? "target" : "source"]?.find((d) => d.id === connectionEndHandle.value?.id) || null;
|
|
5200
5289
|
else toHandle = [...toNode.value.internals.handleBounds?.source ?? [], ...toNode.value.internals.handleBounds?.target ?? []].find((d) => d.id === connectionEndHandle.value?.id) || null;
|
|
5201
5290
|
const toPosition = connectionEndHandle.value?.position ?? (fromPosition ? oppositePosition[fromPosition] : null);
|
|
5202
5291
|
if (!fromPosition || !toPosition) return null;
|
|
5203
|
-
const { x: toX, y: toY } = toHandle && toNode.value ? getHandlePosition(toNode.value, toHandle, toPosition) : pointer.value;
|
|
5292
|
+
const { x: toX, y: toY } = toHandle && toNode.value ? getHandlePosition(toNode.value, toHandle, toPosition, true) : pointer.value;
|
|
5204
5293
|
const type = connectionLineOptions.value.type ?? ConnectionLineType$1.Bezier;
|
|
5205
5294
|
let dAttr = "";
|
|
5206
5295
|
const pathParams = {
|
|
@@ -5941,6 +6030,8 @@ const NodeWrapper = defineComponent({
|
|
|
5941
6030
|
const getStyle = computed(() => {
|
|
5942
6031
|
const node = nodeRef.value;
|
|
5943
6032
|
const styles = { ...node?.style };
|
|
6033
|
+
if (typeof styles.width === "number") styles.width = `${styles.width}px`;
|
|
6034
|
+
if (typeof styles.height === "number") styles.height = `${styles.height}px`;
|
|
5944
6035
|
const isMeasured = !!node?.internals.handleBounds;
|
|
5945
6036
|
const width = node?.width ?? (isMeasured ? void 0 : node?.initialWidth);
|
|
5946
6037
|
const height = node?.height ?? (isMeasured ? void 0 : node?.initialHeight);
|
|
@@ -7309,7 +7400,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7309
7400
|
}, props, {
|
|
7310
7401
|
instance,
|
|
7311
7402
|
state
|
|
7312
|
-
}
|
|
7403
|
+
});
|
|
7313
7404
|
useHooks(emit, state.hooks);
|
|
7314
7405
|
useOnInitHandler(instance);
|
|
7315
7406
|
useSelectionChange(instance);
|
|
@@ -7382,6 +7473,120 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
7382
7473
|
}
|
|
7383
7474
|
var VueFlowProvider_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/container/VueFlowProvider/VueFlowProvider.vue"]]);
|
|
7384
7475
|
//#endregion
|
|
7385
|
-
|
|
7476
|
+
//#region src/utils/prop-of.ts
|
|
7477
|
+
function propOf(required = false) {
|
|
7478
|
+
return {
|
|
7479
|
+
type: null,
|
|
7480
|
+
required
|
|
7481
|
+
};
|
|
7482
|
+
}
|
|
7483
|
+
//#endregion
|
|
7484
|
+
//#region src/props-objects.gen.ts
|
|
7485
|
+
function nodeProps() {
|
|
7486
|
+
return {
|
|
7487
|
+
data: propOf(true),
|
|
7488
|
+
deletable: propOf(true),
|
|
7489
|
+
dragHandle: propOf(),
|
|
7490
|
+
draggable: propOf(true),
|
|
7491
|
+
dragging: propOf(true),
|
|
7492
|
+
height: propOf(),
|
|
7493
|
+
id: propOf(true),
|
|
7494
|
+
isConnectable: propOf(true),
|
|
7495
|
+
parentId: propOf(),
|
|
7496
|
+
positionAbsoluteX: propOf(true),
|
|
7497
|
+
positionAbsoluteY: propOf(true),
|
|
7498
|
+
selectable: propOf(true),
|
|
7499
|
+
selected: propOf(true),
|
|
7500
|
+
sourcePosition: propOf(),
|
|
7501
|
+
targetPosition: propOf(),
|
|
7502
|
+
type: propOf(true),
|
|
7503
|
+
width: propOf(),
|
|
7504
|
+
zIndex: propOf(true)
|
|
7505
|
+
};
|
|
7506
|
+
}
|
|
7507
|
+
function edgeProps() {
|
|
7508
|
+
return {
|
|
7509
|
+
animated: propOf(),
|
|
7510
|
+
curvature: propOf(),
|
|
7511
|
+
data: propOf(),
|
|
7512
|
+
deletable: propOf(),
|
|
7513
|
+
id: propOf(true),
|
|
7514
|
+
interactionWidth: propOf(),
|
|
7515
|
+
label: propOf(),
|
|
7516
|
+
labelBgBorderRadius: propOf(),
|
|
7517
|
+
labelBgPadding: propOf(),
|
|
7518
|
+
labelBgStyle: propOf(),
|
|
7519
|
+
labelShowBg: propOf(),
|
|
7520
|
+
labelStyle: propOf(),
|
|
7521
|
+
markerEnd: propOf(),
|
|
7522
|
+
markerStart: propOf(),
|
|
7523
|
+
reconnectable: propOf(),
|
|
7524
|
+
selectable: propOf(),
|
|
7525
|
+
selected: propOf(),
|
|
7526
|
+
source: propOf(true),
|
|
7527
|
+
sourceHandleId: propOf(),
|
|
7528
|
+
sourcePosition: propOf(true),
|
|
7529
|
+
sourceX: propOf(true),
|
|
7530
|
+
sourceY: propOf(true),
|
|
7531
|
+
style: propOf(),
|
|
7532
|
+
target: propOf(true),
|
|
7533
|
+
targetHandleId: propOf(),
|
|
7534
|
+
targetPosition: propOf(true),
|
|
7535
|
+
targetX: propOf(true),
|
|
7536
|
+
targetY: propOf(true),
|
|
7537
|
+
type: propOf()
|
|
7538
|
+
};
|
|
7539
|
+
}
|
|
7540
|
+
function connectionLineProps() {
|
|
7541
|
+
return {
|
|
7542
|
+
connectionStatus: propOf(true),
|
|
7543
|
+
fromHandle: propOf(true),
|
|
7544
|
+
fromNode: propOf(true),
|
|
7545
|
+
fromPosition: propOf(true),
|
|
7546
|
+
fromX: propOf(true),
|
|
7547
|
+
fromY: propOf(true),
|
|
7548
|
+
markerEnd: propOf(),
|
|
7549
|
+
markerStart: propOf(),
|
|
7550
|
+
pointer: propOf(true),
|
|
7551
|
+
toHandle: propOf(true),
|
|
7552
|
+
toNode: propOf(true),
|
|
7553
|
+
toPosition: propOf(true),
|
|
7554
|
+
toX: propOf(true),
|
|
7555
|
+
toY: propOf(true)
|
|
7556
|
+
};
|
|
7557
|
+
}
|
|
7558
|
+
//#endregion
|
|
7559
|
+
//#region src/utils/edges.ts
|
|
7560
|
+
const defaultOnError = createDevWarn("Vue Flow", "https://vueflow.dev/");
|
|
7561
|
+
/**
|
|
7562
|
+
* Adds a `Connection` (or a full `Edge`) to an edges array and returns a new array — generating the
|
|
7563
|
+
* edge id and skipping the add when an equivalent connection already exists. The pure helper to use
|
|
7564
|
+
* in an `@connect` handler against a `v-model:edges` array, e.g.
|
|
7565
|
+
* `edges.value = addEdge(connection, edges.value)`, with no store/instance access.
|
|
7566
|
+
*
|
|
7567
|
+
* Mirrors xyflow/react's + xyflow/svelte's `addEdge`.
|
|
7568
|
+
*/
|
|
7569
|
+
function addEdge(edgeParams, edges, options = {}) {
|
|
7570
|
+
return addEdge$1(edgeParams, edges, {
|
|
7571
|
+
...options,
|
|
7572
|
+
onError: options.onError ?? defaultOnError
|
|
7573
|
+
});
|
|
7574
|
+
}
|
|
7575
|
+
/**
|
|
7576
|
+
* Reconnects an existing edge to a new `Connection`, returning a new edges array. The pure,
|
|
7577
|
+
* controlled counterpart to the store action `useVueFlow().reconnectEdge` — use it in an
|
|
7578
|
+
* `@reconnect` handler against a `v-model:edges` array, e.g.
|
|
7579
|
+
* `edges.value = reconnectEdge(oldEdge, newConnection, edges.value)`.
|
|
7580
|
+
*
|
|
7581
|
+
* Mirrors xyflow/react's `reconnectEdge`.
|
|
7582
|
+
*/
|
|
7583
|
+
function reconnectEdge(oldEdge, newConnection, edges, options = { shouldReplaceId: true }) {
|
|
7584
|
+
return reconnectEdge$1(oldEdge, newConnection, edges, {
|
|
7585
|
+
...options,
|
|
7586
|
+
onError: options.onError ?? defaultOnError
|
|
7587
|
+
});
|
|
7588
|
+
}
|
|
7589
|
+
//#endregion
|
|
7590
|
+
export { Background_default as Background, BaseEdge_default as BaseEdge, BezierEdge, ConnectionLineType, ConnectionMode, ControlButton_default as ControlButton, Controls_default as Controls, EdgeLabelRenderer_default as EdgeLabelRenderer, EdgeText_default as EdgeText, EdgeToolbar_default as EdgeToolbar, ErrorCode, Handle_default as Handle, MarkerType, MiniMap_default as MiniMap, MiniMapNode_default as MiniMapNode, NodeId as NodeIdInjection, ResizeControl_default as NodeResizeControl, NodeResizer_default as NodeResizer, NodeToolbar_default as NodeToolbar, PanOnScrollMode, Panel_default as Panel, Position, ResizeControlVariant, SelectionMode, SimpleBezierEdge, Slots, SmoothStepEdge, StepEdge, StraightEdge, VueFlow_default as VueFlow, VueFlowError, VueFlow as VueFlowInjection, VueFlowProvider_default as VueFlowProvider, addEdge, applyChanges, applyEdgeChanges, applyNodeChanges, clamp, connectionExists, connectionLineProps, defaultEdgeTypes, defaultNodeTypes, edgeProps, getBezierEdgeCenter, getBezierPath, getBoundsOfBoxes, getBoundsOfRects, getConnectedEdges, getConnectionStatus, getIncomers, getMarkerId, getNodesBounds, getNodesInside, getOutgoers, getSimpleBezierPath, getSmoothStepPath, getStraightPath, getViewportForBounds, isEdge, isEdgeBase, isErrorOfType, isInternalNode, isInternalNodeBase, isMacOs, isNode, isNodeBase, nodeProps, pointToRendererPoint, reconnectEdge, rendererPointToPoint, storeToRefs, useConnection, useEdge, useEdgesData, useHandle, useInternalNode, useKeyPress, useNode, useNodeConnections, useNodeId, useNodesData, useNodesInitialized, useStore, useVueFlow };
|
|
7386
7591
|
|
|
7387
7592
|
//# sourceMappingURL=index.mjs.map
|