@xyflow/vue 2.0.0-next.2 → 2.0.0-next.4
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 +265 -4
- package/dist/index.d.ts +265 -4
- package/dist/index.js +145 -78
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -22,12 +22,14 @@ let ErrorCode = /* @__PURE__ */ function(ErrorCode) {
|
|
|
22
22
|
ErrorCode["NODE_MISSING_PARENT"] = "NODE_MISSING_PARENT";
|
|
23
23
|
ErrorCode["NODE_TYPE_MISSING"] = "NODE_TYPE_MISSING";
|
|
24
24
|
ErrorCode["NODE_EXTENT_INVALID"] = "NODE_EXTENT_INVALID";
|
|
25
|
+
ErrorCode["NODE_DUPLICATE_ID"] = "NODE_DUPLICATE_ID";
|
|
25
26
|
ErrorCode["EDGE_INVALID"] = "EDGE_INVALID";
|
|
26
27
|
ErrorCode["EDGE_NOT_FOUND"] = "EDGE_NOT_FOUND";
|
|
27
28
|
ErrorCode["EDGE_SOURCE_MISSING"] = "EDGE_SOURCE_MISSING";
|
|
28
29
|
ErrorCode["EDGE_TARGET_MISSING"] = "EDGE_TARGET_MISSING";
|
|
29
30
|
ErrorCode["EDGE_TYPE_MISSING"] = "EDGE_TYPE_MISSING";
|
|
30
31
|
ErrorCode["EDGE_SOURCE_TARGET_MISSING"] = "EDGE_SOURCE_TARGET_MISSING";
|
|
32
|
+
ErrorCode["EDGE_DUPLICATE_ID"] = "EDGE_DUPLICATE_ID";
|
|
31
33
|
ErrorCode["USE_VUE_FLOW_OUTSIDE_PROVIDER"] = "USE_VUE_FLOW_OUTSIDE_PROVIDER";
|
|
32
34
|
return ErrorCode;
|
|
33
35
|
}({});
|
|
@@ -39,11 +41,13 @@ const messages = {
|
|
|
39
41
|
["NODE_MISSING_PARENT"]: (id, parentId) => `Node is missing a parent\nNode id: ${id}\nParent id: ${parentId}`,
|
|
40
42
|
["NODE_TYPE_MISSING"]: (type) => `Node type is missing\nType: ${type}`,
|
|
41
43
|
["NODE_EXTENT_INVALID"]: (id) => `Only child nodes can use a parent extent\nNode id: ${id}`,
|
|
44
|
+
["NODE_DUPLICATE_ID"]: (id) => `Node id is not unique — a later node overwrites the earlier one in the lookup\nNode id: ${id}`,
|
|
42
45
|
["EDGE_INVALID"]: (id) => `An edge needs a source and a target\nEdge id: ${id}`,
|
|
43
46
|
["EDGE_SOURCE_MISSING"]: (id, source) => `Edge source is missing\nEdge id: ${id} \nSource id: ${source}`,
|
|
44
47
|
["EDGE_TARGET_MISSING"]: (id, target) => `Edge target is missing\nEdge id: ${id} \nTarget id: ${target}`,
|
|
45
48
|
["EDGE_TYPE_MISSING"]: (type) => `Edge type is missing\nType: ${type}`,
|
|
46
49
|
["EDGE_SOURCE_TARGET_MISSING"]: (id, source, target) => `Edge source or target is missing\nEdge id: ${id} \nSource id: ${source} \nTarget id: ${target}`,
|
|
50
|
+
["EDGE_DUPLICATE_ID"]: (id) => `Edge id is not unique — a later edge overwrites the earlier one in the lookup\nEdge id: ${id}`,
|
|
47
51
|
["EDGE_NOT_FOUND"]: (id) => `Edge not found\nEdge id: ${id}`,
|
|
48
52
|
["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.`
|
|
49
53
|
};
|
|
@@ -645,39 +649,6 @@ function createExtendedEventHook(defaultHandler) {
|
|
|
645
649
|
};
|
|
646
650
|
}
|
|
647
651
|
//#endregion
|
|
648
|
-
//#region src/utils/drag.ts
|
|
649
|
-
function getParentExtent(parent) {
|
|
650
|
-
if (parent && typeof parent.internals.positionAbsolute.x !== "undefined" && typeof parent.internals.positionAbsolute.y !== "undefined" && typeof parent.measured.width !== "undefined" && typeof parent.measured.height !== "undefined") return [[parent.internals.positionAbsolute.x, parent.internals.positionAbsolute.y], [parent.internals.positionAbsolute.x + parent.measured.width, parent.internals.positionAbsolute.y + parent.measured.height]];
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
653
|
-
function getExtent(item, triggerError, extent, parent) {
|
|
654
|
-
let currentExtent = item.extent || extent;
|
|
655
|
-
if (currentExtent === "parent" && !item.expandParent) if (item.parentId && parent && item.measured.width && item.measured.height) {
|
|
656
|
-
const parentExtent = getParentExtent(parent);
|
|
657
|
-
if (parentExtent) currentExtent = parentExtent;
|
|
658
|
-
} else {
|
|
659
|
-
triggerError(new VueFlowError("NODE_EXTENT_INVALID", item.id));
|
|
660
|
-
currentExtent = extent;
|
|
661
|
-
}
|
|
662
|
-
else if (Array.isArray(currentExtent)) {
|
|
663
|
-
const parentX = parent?.internals.positionAbsolute.x || 0;
|
|
664
|
-
const parentY = parent?.internals.positionAbsolute.y || 0;
|
|
665
|
-
currentExtent = [[currentExtent[0][0] + parentX, currentExtent[0][1] + parentY], [currentExtent[1][0] + parentX, currentExtent[1][1] + parentY]];
|
|
666
|
-
}
|
|
667
|
-
return currentExtent === "parent" ? [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]] : currentExtent;
|
|
668
|
-
}
|
|
669
|
-
function calcNextPosition(node, nextPosition, triggerError, nodeExtent, parentNode) {
|
|
670
|
-
const measured = (0, _xyflow_system.getNodeDimensions)(node);
|
|
671
|
-
const clampedPos = (0, _xyflow_system.clampPosition)(nextPosition, getExtent(node, triggerError, nodeExtent, parentNode), measured);
|
|
672
|
-
return {
|
|
673
|
-
position: {
|
|
674
|
-
x: clampedPos.x - (parentNode?.internals.positionAbsolute.x || 0),
|
|
675
|
-
y: clampedPos.y - (parentNode?.internals.positionAbsolute.y || 0)
|
|
676
|
-
},
|
|
677
|
-
computedPosition: clampedPos
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
//#endregion
|
|
681
652
|
//#region src/utils/edge.ts
|
|
682
653
|
function getEdgeHandle(bounds, handleId) {
|
|
683
654
|
if (!bounds) return null;
|
|
@@ -859,12 +830,15 @@ function reconnectEdgeAction(edge, newConnection, prevEdge, shouldReplaceId, tri
|
|
|
859
830
|
*/
|
|
860
831
|
function adoptNodes(nodes, nodeLookup, parentLookup, triggerError, options) {
|
|
861
832
|
const validNodes = [];
|
|
833
|
+
const seenNodeIds = /* @__PURE__ */ new Set();
|
|
862
834
|
for (let i = 0; i < nodes.length; ++i) {
|
|
863
835
|
const node = nodes[i];
|
|
864
836
|
if (!isNode(node)) {
|
|
865
837
|
triggerError(new VueFlowError("NODE_INVALID", node?.id ?? `[ID UNKNOWN|INDEX ${i}]`));
|
|
866
838
|
continue;
|
|
867
839
|
}
|
|
840
|
+
if (seenNodeIds.has(node.id)) triggerError(new VueFlowError("NODE_DUPLICATE_ID", node.id));
|
|
841
|
+
else seenNodeIds.add(node.id);
|
|
868
842
|
validNodes.push((0, vue.markRaw)((0, vue.toRaw)(node)));
|
|
869
843
|
}
|
|
870
844
|
const priorInternals = /* @__PURE__ */ new Map();
|
|
@@ -1414,7 +1388,7 @@ function useNode(id) {
|
|
|
1414
1388
|
* @internal
|
|
1415
1389
|
*/
|
|
1416
1390
|
function useUpdateNodePositions() {
|
|
1417
|
-
const { getSelectedNodes, updateNodePositions, getInternalNode
|
|
1391
|
+
const { getSelectedNodes, updateNodePositions, getInternalNode } = useVueFlow();
|
|
1418
1392
|
const store = useStore();
|
|
1419
1393
|
return (positionDiff, isShiftPressed = false) => {
|
|
1420
1394
|
const xVelo = store.snapToGrid ? store.snapGrid[0] : 5;
|
|
@@ -1426,10 +1400,18 @@ function useUpdateNodePositions() {
|
|
|
1426
1400
|
for (const node of getSelectedNodes.value) if (node.draggable || store.nodesDraggable && typeof node.draggable === "undefined") {
|
|
1427
1401
|
const internalNode = getInternalNode(node.id);
|
|
1428
1402
|
if (!internalNode) continue;
|
|
1429
|
-
|
|
1403
|
+
let nextPosition = {
|
|
1430
1404
|
x: internalNode.internals.positionAbsolute.x + positionDiffX,
|
|
1431
1405
|
y: internalNode.internals.positionAbsolute.y + positionDiffY
|
|
1432
|
-
}
|
|
1406
|
+
};
|
|
1407
|
+
if (store.snapToGrid) nextPosition = (0, _xyflow_system.snapPosition)(nextPosition, store.snapGrid);
|
|
1408
|
+
const { position, positionAbsolute } = (0, _xyflow_system.calculateNodePosition)({
|
|
1409
|
+
nodeId: node.id,
|
|
1410
|
+
nextPosition,
|
|
1411
|
+
nodeLookup: store.nodeLookup,
|
|
1412
|
+
nodeExtent: store.nodeExtent,
|
|
1413
|
+
nodeOrigin: store.nodeOrigin
|
|
1414
|
+
});
|
|
1433
1415
|
nodeUpdates.push({
|
|
1434
1416
|
id: node.id,
|
|
1435
1417
|
position,
|
|
@@ -1438,10 +1420,7 @@ function useUpdateNodePositions() {
|
|
|
1438
1420
|
y: positionDiff.y
|
|
1439
1421
|
},
|
|
1440
1422
|
measured: (0, _xyflow_system.getNodeDimensions)(internalNode),
|
|
1441
|
-
internals: { positionAbsolute
|
|
1442
|
-
x: internalNode.internals.positionAbsolute.x,
|
|
1443
|
-
y: internalNode.internals.positionAbsolute.y
|
|
1444
|
-
} }
|
|
1423
|
+
internals: { positionAbsolute }
|
|
1445
1424
|
});
|
|
1446
1425
|
}
|
|
1447
1426
|
updateNodePositions(nodeUpdates, true, false);
|
|
@@ -1582,9 +1561,10 @@ function useViewportHelper(state, nodeLookup) {
|
|
|
1582
1561
|
/**
|
|
1583
1562
|
* Two-way bind a `v-model` array ref to the store, identity-in / snapshot-out, with native `watch`.
|
|
1584
1563
|
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1564
|
+
* Runs for BOTH the owned- and reused-store paths: the store's canonical nodes/edges are always an
|
|
1565
|
+
* internal `shallowRef` (see `createStore`), never the v-model ref, so this is the single place the model
|
|
1566
|
+
* ref is bridged to the store. Both directions flush synchronously so the model ref and the store's
|
|
1567
|
+
* synchronous reads (`getNodes`/`state.nodes`) never disagree within a tick.
|
|
1588
1568
|
*
|
|
1589
1569
|
* - **out** (store → model): snapshot on every membership change; element refs are shared, so per-node
|
|
1590
1570
|
* field mutations surface without a copy.
|
|
@@ -1597,24 +1577,29 @@ function syncModelArray(model, storeItems, setItems) {
|
|
|
1597
1577
|
(0, vue.watch)([storeItems, () => storeItems.value.length], () => {
|
|
1598
1578
|
lastSnapshot = [...storeItems.value];
|
|
1599
1579
|
model.value = lastSnapshot;
|
|
1600
|
-
}, {
|
|
1580
|
+
}, {
|
|
1581
|
+
immediate: storeItems.value.length > 0,
|
|
1582
|
+
flush: "sync"
|
|
1583
|
+
});
|
|
1601
1584
|
(0, vue.watch)([model, () => model.value?.length], ([next]) => {
|
|
1602
1585
|
if (!Array.isArray(next)) return;
|
|
1603
1586
|
const nextRaw = (0, vue.toRaw)(next);
|
|
1604
1587
|
if (nextRaw === lastSnapshot) return;
|
|
1605
1588
|
setItems(nextRaw);
|
|
1606
|
-
}, {
|
|
1589
|
+
}, {
|
|
1590
|
+
immediate: true,
|
|
1591
|
+
flush: "sync"
|
|
1592
|
+
});
|
|
1607
1593
|
}
|
|
1608
1594
|
/**
|
|
1609
1595
|
* Watches props and updates the store accordingly
|
|
1610
1596
|
*
|
|
1611
1597
|
* @internal
|
|
1612
|
-
* @param models v-model refs for nodes/edges
|
|
1598
|
+
* @param models v-model refs for nodes/edges — bridged to the store here (see {@link syncModelArray})
|
|
1613
1599
|
* @param props the `<VueFlow>` props
|
|
1614
1600
|
* @param handle the created store handle ({@link VueFlowStoreHandle}) — instance (actions) + reactive state
|
|
1615
|
-
* @param ownsStore whether this `<VueFlow>` created the store (then nodes/edges are signal-backed and skipped here)
|
|
1616
1601
|
*/
|
|
1617
|
-
function useWatchProps(models, props, handle
|
|
1602
|
+
function useWatchProps(models, props, handle) {
|
|
1618
1603
|
const { instance, state } = handle;
|
|
1619
1604
|
const storeRefs = storeToRefs(state);
|
|
1620
1605
|
const scope = (0, vue.effectScope)(true);
|
|
@@ -1718,10 +1703,8 @@ function useWatchProps(models, props, handle, ownsStore = false) {
|
|
|
1718
1703
|
}
|
|
1719
1704
|
};
|
|
1720
1705
|
const runAll = () => {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
watchEdgesValue();
|
|
1724
|
-
}
|
|
1706
|
+
watchNodesValue();
|
|
1707
|
+
watchEdgesValue();
|
|
1725
1708
|
watchMinZoom();
|
|
1726
1709
|
watchMaxZoom();
|
|
1727
1710
|
watchTranslateExtent();
|
|
@@ -1743,7 +1726,8 @@ const _sfc_main$22 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1743
1726
|
props: {
|
|
1744
1727
|
position: {
|
|
1745
1728
|
type: String,
|
|
1746
|
-
required:
|
|
1729
|
+
required: false,
|
|
1730
|
+
default: "top-left"
|
|
1747
1731
|
},
|
|
1748
1732
|
label: {
|
|
1749
1733
|
type: [String, null],
|
|
@@ -3335,14 +3319,16 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
3335
3319
|
const { nodeLookup, parentLookup } = useStore();
|
|
3336
3320
|
const { transform, nodeOrigin, snapGrid, snapToGrid, vueFlowRef, noDragClassName } = storeToRefs(useStore());
|
|
3337
3321
|
const resizeControlRef = (0, vue.shallowRef)();
|
|
3322
|
+
const contextNodeId = (0, vue.inject)(NodeId, null);
|
|
3323
|
+
const nodeId = (0, vue.toRef)(() => typeof props.nodeId === "string" ? props.nodeId : contextNodeId ?? void 0);
|
|
3338
3324
|
const controlPosition = (0, vue.toRef)(() => props.position ?? DefaultPositions[props.variant]);
|
|
3339
3325
|
const positionClassNames = (0, vue.computed)(() => controlPosition.value.split("-"));
|
|
3340
3326
|
const controlStyle = (0, vue.toRef)(() => props.color ? { [StylingProperty[props.variant]]: props.color } : {});
|
|
3341
3327
|
(0, vue.watchEffect)((onCleanup) => {
|
|
3342
|
-
if (!resizeControlRef.value || !
|
|
3328
|
+
if (!resizeControlRef.value || !nodeId.value) return;
|
|
3343
3329
|
const resizerInstance = (0, _xyflow_system.XYResizer)({
|
|
3344
3330
|
domNode: resizeControlRef.value,
|
|
3345
|
-
nodeId:
|
|
3331
|
+
nodeId: nodeId.value,
|
|
3346
3332
|
getStoreItems: () => ({
|
|
3347
3333
|
nodeLookup,
|
|
3348
3334
|
transform: transform.value,
|
|
@@ -3353,7 +3339,7 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
3353
3339
|
}),
|
|
3354
3340
|
onChange: (changes, childChanges) => {
|
|
3355
3341
|
const nodeChanges = [];
|
|
3356
|
-
const node = nodeLookup.get(
|
|
3342
|
+
const node = nodeLookup.get(nodeId.value);
|
|
3357
3343
|
let nextX = changes.x;
|
|
3358
3344
|
let nextY = changes.y;
|
|
3359
3345
|
if (node?.expandParent && node.parentId) {
|
|
@@ -3385,14 +3371,14 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
3385
3371
|
y: nextY ?? node?.position.y ?? 0
|
|
3386
3372
|
};
|
|
3387
3373
|
nodeChanges.push({
|
|
3388
|
-
id:
|
|
3374
|
+
id: nodeId.value,
|
|
3389
3375
|
type: "position",
|
|
3390
3376
|
position,
|
|
3391
3377
|
positionAbsolute: position
|
|
3392
3378
|
});
|
|
3393
3379
|
}
|
|
3394
3380
|
if (typeof changes.width !== "undefined" || typeof changes.height !== "undefined") nodeChanges.push({
|
|
3395
|
-
id:
|
|
3381
|
+
id: nodeId.value,
|
|
3396
3382
|
type: "dimensions",
|
|
3397
3383
|
setAttributes: true,
|
|
3398
3384
|
resizing: true,
|
|
@@ -3411,7 +3397,7 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
3411
3397
|
},
|
|
3412
3398
|
onEnd: ({ width, height }) => {
|
|
3413
3399
|
triggerEmits.nodesChange([{
|
|
3414
|
-
id:
|
|
3400
|
+
id: nodeId.value,
|
|
3415
3401
|
type: "dimensions",
|
|
3416
3402
|
resizing: false,
|
|
3417
3403
|
dimensions: {
|
|
@@ -3462,6 +3448,8 @@ const _sfc_main$14 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
3462
3448
|
vueFlowRef,
|
|
3463
3449
|
noDragClassName,
|
|
3464
3450
|
resizeControlRef,
|
|
3451
|
+
contextNodeId,
|
|
3452
|
+
nodeId,
|
|
3465
3453
|
controlPosition,
|
|
3466
3454
|
positionClassNames,
|
|
3467
3455
|
controlStyle,
|
|
@@ -4305,8 +4293,11 @@ function useActions(state, nodeLookup, parentLookup, edgeLookup) {
|
|
|
4305
4293
|
*/
|
|
4306
4294
|
function commitEdges(next) {
|
|
4307
4295
|
const rawEdgeLookup = (0, vue.toRaw)(edgeLookup);
|
|
4296
|
+
const seenEdgeIds = /* @__PURE__ */ new Set();
|
|
4308
4297
|
for (let i = 0; i < next.length; i++) {
|
|
4309
4298
|
const edge = next[i] = (0, vue.markRaw)((0, vue.toRaw)(next[i]));
|
|
4299
|
+
if (seenEdgeIds.has(edge.id)) state.hooks.error.trigger(new VueFlowError("EDGE_DUPLICATE_ID", edge.id));
|
|
4300
|
+
else seenEdgeIds.add(edge.id);
|
|
4310
4301
|
if (rawEdgeLookup.get(edge.id) !== edge) edgeLookup.set(edge.id, edge);
|
|
4311
4302
|
}
|
|
4312
4303
|
if (rawEdgeLookup.size !== next.length) {
|
|
@@ -4315,7 +4306,7 @@ function useActions(state, nodeLookup, parentLookup, edgeLookup) {
|
|
|
4315
4306
|
for (const id of rawEdgeLookup.keys()) if (!nextIds.has(id)) edgeLookup.delete(id);
|
|
4316
4307
|
}
|
|
4317
4308
|
state.edges = next;
|
|
4318
|
-
updateConnectionLookup(state.connectionLookup,
|
|
4309
|
+
updateConnectionLookup(state.connectionLookup, next);
|
|
4319
4310
|
}
|
|
4320
4311
|
/**
|
|
4321
4312
|
* Recompute parent-aware `internals.positionAbsolute` on the system lookup, then mirror into the
|
|
@@ -4990,17 +4981,14 @@ function useGetters(state, nodeLookup) {
|
|
|
4990
4981
|
* @internal
|
|
4991
4982
|
*/
|
|
4992
4983
|
function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
4993
|
-
const nodesSignal =
|
|
4994
|
-
const edgesSignal =
|
|
4995
|
-
let lastWriteNodes;
|
|
4996
|
-
let lastWriteEdges;
|
|
4984
|
+
const nodesSignal = (0, vue.shallowRef)(signals?.nodes?.value ?? []);
|
|
4985
|
+
const edgesSignal = (0, vue.shallowRef)(signals?.edges?.value ?? []);
|
|
4997
4986
|
const emptyNodes = [];
|
|
4998
4987
|
const emptyEdges = [];
|
|
4999
4988
|
const state = useState();
|
|
5000
4989
|
Object.defineProperty(state, "nodes", {
|
|
5001
4990
|
get: () => nodesSignal.value ?? emptyNodes,
|
|
5002
4991
|
set: (value) => {
|
|
5003
|
-
lastWriteNodes = (0, vue.toRaw)(value);
|
|
5004
4992
|
nodesSignal.value = value;
|
|
5005
4993
|
},
|
|
5006
4994
|
enumerable: true,
|
|
@@ -5009,7 +4997,6 @@ function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
|
5009
4997
|
Object.defineProperty(state, "edges", {
|
|
5010
4998
|
get: () => edgesSignal.value ?? emptyEdges,
|
|
5011
4999
|
set: (value) => {
|
|
5012
|
-
lastWriteEdges = (0, vue.toRaw)(value);
|
|
5013
5000
|
edgesSignal.value = value;
|
|
5014
5001
|
},
|
|
5015
5002
|
enumerable: true,
|
|
@@ -5032,14 +5019,6 @@ function createVueFlowStore(id, preloadedState, onDestroy, signals) {
|
|
|
5032
5019
|
...reactiveState,
|
|
5033
5020
|
...preloadedState
|
|
5034
5021
|
});
|
|
5035
|
-
if (signals?.nodes) (0, vue.watch)(nodesSignal, (next) => {
|
|
5036
|
-
const nextRaw = next && (0, vue.toRaw)(next);
|
|
5037
|
-
if (nextRaw && nextRaw !== lastWriteNodes) actions.setNodes(nextRaw);
|
|
5038
|
-
});
|
|
5039
|
-
if (signals?.edges) (0, vue.watch)(edgesSignal, (next) => {
|
|
5040
|
-
const nextRaw = next && (0, vue.toRaw)(next);
|
|
5041
|
-
if (nextRaw && nextRaw !== lastWriteEdges) actions.setEdges(nextRaw);
|
|
5042
|
-
});
|
|
5043
5022
|
return {
|
|
5044
5023
|
instance: {
|
|
5045
5024
|
...hooksOn,
|
|
@@ -5190,7 +5169,7 @@ function useViewportSync(model, state = useStore()) {
|
|
|
5190
5169
|
};
|
|
5191
5170
|
if (sameViewport(viewport, model.value)) return;
|
|
5192
5171
|
model.value = viewport;
|
|
5193
|
-
});
|
|
5172
|
+
}, { flush: "sync" });
|
|
5194
5173
|
}
|
|
5195
5174
|
//#endregion
|
|
5196
5175
|
//#region src/components/ConnectionLine/index.ts
|
|
@@ -5223,13 +5202,13 @@ const ConnectionLine = (0, vue.defineComponent)({
|
|
|
5223
5202
|
}
|
|
5224
5203
|
const fromHandle = (startHandleId ? handleBounds.find((d) => d.id === startHandleId) : handleBounds[0]) ?? null;
|
|
5225
5204
|
const fromPosition = fromHandle?.position ?? _xyflow_system.Position.Top;
|
|
5226
|
-
const { x: fromX, y: fromY } = (0, _xyflow_system.getHandlePosition)(fromNode.value, fromHandle, fromPosition);
|
|
5205
|
+
const { x: fromX, y: fromY } = (0, _xyflow_system.getHandlePosition)(fromNode.value, fromHandle, fromPosition, true);
|
|
5227
5206
|
let toHandle = null;
|
|
5228
5207
|
if (toNode.value) if (connectionMode.value === _xyflow_system.ConnectionMode.Strict) toHandle = toNode.value.internals.handleBounds?.[handleType === "source" ? "target" : "source"]?.find((d) => d.id === connectionEndHandle.value?.id) || null;
|
|
5229
5208
|
else toHandle = [...toNode.value.internals.handleBounds?.source ?? [], ...toNode.value.internals.handleBounds?.target ?? []].find((d) => d.id === connectionEndHandle.value?.id) || null;
|
|
5230
5209
|
const toPosition = connectionEndHandle.value?.position ?? (fromPosition ? _xyflow_system.oppositePosition[fromPosition] : null);
|
|
5231
5210
|
if (!fromPosition || !toPosition) return null;
|
|
5232
|
-
const { x: toX, y: toY } = toHandle && toNode.value ? (0, _xyflow_system.getHandlePosition)(toNode.value, toHandle, toPosition) : pointer.value;
|
|
5211
|
+
const { x: toX, y: toY } = toHandle && toNode.value ? (0, _xyflow_system.getHandlePosition)(toNode.value, toHandle, toPosition, true) : pointer.value;
|
|
5233
5212
|
const type = connectionLineOptions.value.type ?? _xyflow_system.ConnectionLineType.Bezier;
|
|
5234
5213
|
let dAttr = "";
|
|
5235
5214
|
const pathParams = {
|
|
@@ -5970,6 +5949,8 @@ const NodeWrapper = (0, vue.defineComponent)({
|
|
|
5970
5949
|
const getStyle = (0, vue.computed)(() => {
|
|
5971
5950
|
const node = nodeRef.value;
|
|
5972
5951
|
const styles = { ...node?.style };
|
|
5952
|
+
if (typeof styles.width === "number") styles.width = `${styles.width}px`;
|
|
5953
|
+
if (typeof styles.height === "number") styles.height = `${styles.height}px`;
|
|
5973
5954
|
const isMeasured = !!node?.internals.handleBounds;
|
|
5974
5955
|
const width = node?.width ?? (isMeasured ? void 0 : node?.initialWidth);
|
|
5975
5956
|
const height = node?.height ?? (isMeasured ? void 0 : node?.initialHeight);
|
|
@@ -7338,7 +7319,7 @@ const _sfc_main$1 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
7338
7319
|
}, props, {
|
|
7339
7320
|
instance,
|
|
7340
7321
|
state
|
|
7341
|
-
}
|
|
7322
|
+
});
|
|
7342
7323
|
useHooks(emit, state.hooks);
|
|
7343
7324
|
useOnInitHandler(instance);
|
|
7344
7325
|
useSelectionChange(instance);
|
|
@@ -7411,6 +7392,89 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
7411
7392
|
}
|
|
7412
7393
|
var VueFlowProvider_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/container/VueFlowProvider/VueFlowProvider.vue"]]);
|
|
7413
7394
|
//#endregion
|
|
7395
|
+
//#region src/utils/prop-of.ts
|
|
7396
|
+
function propOf(required = false) {
|
|
7397
|
+
return {
|
|
7398
|
+
type: null,
|
|
7399
|
+
required
|
|
7400
|
+
};
|
|
7401
|
+
}
|
|
7402
|
+
//#endregion
|
|
7403
|
+
//#region src/props-objects.gen.ts
|
|
7404
|
+
function nodeProps() {
|
|
7405
|
+
return {
|
|
7406
|
+
data: propOf(true),
|
|
7407
|
+
deletable: propOf(true),
|
|
7408
|
+
dragHandle: propOf(),
|
|
7409
|
+
draggable: propOf(true),
|
|
7410
|
+
dragging: propOf(true),
|
|
7411
|
+
height: propOf(),
|
|
7412
|
+
id: propOf(true),
|
|
7413
|
+
isConnectable: propOf(true),
|
|
7414
|
+
parentId: propOf(),
|
|
7415
|
+
positionAbsoluteX: propOf(true),
|
|
7416
|
+
positionAbsoluteY: propOf(true),
|
|
7417
|
+
selectable: propOf(true),
|
|
7418
|
+
selected: propOf(true),
|
|
7419
|
+
sourcePosition: propOf(),
|
|
7420
|
+
targetPosition: propOf(),
|
|
7421
|
+
type: propOf(true),
|
|
7422
|
+
width: propOf(),
|
|
7423
|
+
zIndex: propOf(true)
|
|
7424
|
+
};
|
|
7425
|
+
}
|
|
7426
|
+
function edgeProps() {
|
|
7427
|
+
return {
|
|
7428
|
+
animated: propOf(),
|
|
7429
|
+
curvature: propOf(),
|
|
7430
|
+
data: propOf(),
|
|
7431
|
+
deletable: propOf(),
|
|
7432
|
+
id: propOf(true),
|
|
7433
|
+
interactionWidth: propOf(),
|
|
7434
|
+
label: propOf(),
|
|
7435
|
+
labelBgBorderRadius: propOf(),
|
|
7436
|
+
labelBgPadding: propOf(),
|
|
7437
|
+
labelBgStyle: propOf(),
|
|
7438
|
+
labelShowBg: propOf(),
|
|
7439
|
+
labelStyle: propOf(),
|
|
7440
|
+
markerEnd: propOf(),
|
|
7441
|
+
markerStart: propOf(),
|
|
7442
|
+
reconnectable: propOf(),
|
|
7443
|
+
selectable: propOf(),
|
|
7444
|
+
selected: propOf(),
|
|
7445
|
+
source: propOf(true),
|
|
7446
|
+
sourceHandleId: propOf(),
|
|
7447
|
+
sourcePosition: propOf(true),
|
|
7448
|
+
sourceX: propOf(true),
|
|
7449
|
+
sourceY: propOf(true),
|
|
7450
|
+
style: propOf(),
|
|
7451
|
+
target: propOf(true),
|
|
7452
|
+
targetHandleId: propOf(),
|
|
7453
|
+
targetPosition: propOf(true),
|
|
7454
|
+
targetX: propOf(true),
|
|
7455
|
+
targetY: propOf(true),
|
|
7456
|
+
type: propOf()
|
|
7457
|
+
};
|
|
7458
|
+
}
|
|
7459
|
+
function connectionLineProps() {
|
|
7460
|
+
return {
|
|
7461
|
+
connectionStatus: propOf(true),
|
|
7462
|
+
fromHandle: propOf(true),
|
|
7463
|
+
fromNode: propOf(true),
|
|
7464
|
+
fromPosition: propOf(true),
|
|
7465
|
+
fromX: propOf(true),
|
|
7466
|
+
fromY: propOf(true),
|
|
7467
|
+
markerEnd: propOf(),
|
|
7468
|
+
markerStart: propOf(),
|
|
7469
|
+
pointer: propOf(true),
|
|
7470
|
+
toHandle: propOf(true),
|
|
7471
|
+
toNode: propOf(true),
|
|
7472
|
+
toPosition: propOf(true),
|
|
7473
|
+
toX: propOf(true),
|
|
7474
|
+
toY: propOf(true)
|
|
7475
|
+
};
|
|
7476
|
+
}
|
|
7477
|
+
//#endregion
|
|
7414
7478
|
exports.Background = Background_default;
|
|
7415
7479
|
exports.BaseEdge = BaseEdge_default;
|
|
7416
7480
|
exports.BezierEdge = BezierEdge;
|
|
@@ -7483,8 +7547,10 @@ Object.defineProperty(exports, "clamp", {
|
|
|
7483
7547
|
}
|
|
7484
7548
|
});
|
|
7485
7549
|
exports.connectionExists = connectionExists;
|
|
7550
|
+
exports.connectionLineProps = connectionLineProps;
|
|
7486
7551
|
exports.defaultEdgeTypes = defaultEdgeTypes;
|
|
7487
7552
|
exports.defaultNodeTypes = defaultNodeTypes;
|
|
7553
|
+
exports.edgeProps = edgeProps;
|
|
7488
7554
|
Object.defineProperty(exports, "getBezierEdgeCenter", {
|
|
7489
7555
|
enumerable: true,
|
|
7490
7556
|
get: function() {
|
|
@@ -7598,6 +7664,7 @@ Object.defineProperty(exports, "isNodeBase", {
|
|
|
7598
7664
|
return _xyflow_system.isNodeBase;
|
|
7599
7665
|
}
|
|
7600
7666
|
});
|
|
7667
|
+
exports.nodeProps = nodeProps;
|
|
7601
7668
|
Object.defineProperty(exports, "pointToRendererPoint", {
|
|
7602
7669
|
enumerable: true,
|
|
7603
7670
|
get: function() {
|