@xyflow/vue 2.0.0-next.2 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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, 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, 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, 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";
|
|
3
3
|
import { onKeyStroke, until, useEventListener } from "@vueuse/core";
|
|
4
4
|
//#region src/context/index.ts
|
|
5
5
|
/** the curated instance (`useVueFlow()`) */
|
|
@@ -644,39 +644,6 @@ function createExtendedEventHook(defaultHandler) {
|
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
646
|
//#endregion
|
|
647
|
-
//#region src/utils/drag.ts
|
|
648
|
-
function getParentExtent(parent) {
|
|
649
|
-
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]];
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
function getExtent(item, triggerError, extent, parent) {
|
|
653
|
-
let currentExtent = item.extent || extent;
|
|
654
|
-
if (currentExtent === "parent" && !item.expandParent) if (item.parentId && parent && item.measured.width && item.measured.height) {
|
|
655
|
-
const parentExtent = getParentExtent(parent);
|
|
656
|
-
if (parentExtent) currentExtent = parentExtent;
|
|
657
|
-
} else {
|
|
658
|
-
triggerError(new VueFlowError("NODE_EXTENT_INVALID", item.id));
|
|
659
|
-
currentExtent = extent;
|
|
660
|
-
}
|
|
661
|
-
else if (Array.isArray(currentExtent)) {
|
|
662
|
-
const parentX = parent?.internals.positionAbsolute.x || 0;
|
|
663
|
-
const parentY = parent?.internals.positionAbsolute.y || 0;
|
|
664
|
-
currentExtent = [[currentExtent[0][0] + parentX, currentExtent[0][1] + parentY], [currentExtent[1][0] + parentX, currentExtent[1][1] + parentY]];
|
|
665
|
-
}
|
|
666
|
-
return currentExtent === "parent" ? [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]] : currentExtent;
|
|
667
|
-
}
|
|
668
|
-
function calcNextPosition(node, nextPosition, triggerError, nodeExtent, parentNode) {
|
|
669
|
-
const measured = getNodeDimensions(node);
|
|
670
|
-
const clampedPos = clampPosition(nextPosition, getExtent(node, triggerError, nodeExtent, parentNode), measured);
|
|
671
|
-
return {
|
|
672
|
-
position: {
|
|
673
|
-
x: clampedPos.x - (parentNode?.internals.positionAbsolute.x || 0),
|
|
674
|
-
y: clampedPos.y - (parentNode?.internals.positionAbsolute.y || 0)
|
|
675
|
-
},
|
|
676
|
-
computedPosition: clampedPos
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
//#endregion
|
|
680
647
|
//#region src/utils/edge.ts
|
|
681
648
|
function getEdgeHandle(bounds, handleId) {
|
|
682
649
|
if (!bounds) return null;
|
|
@@ -1413,7 +1380,7 @@ function useNode(id) {
|
|
|
1413
1380
|
* @internal
|
|
1414
1381
|
*/
|
|
1415
1382
|
function useUpdateNodePositions() {
|
|
1416
|
-
const { getSelectedNodes, updateNodePositions, getInternalNode
|
|
1383
|
+
const { getSelectedNodes, updateNodePositions, getInternalNode } = useVueFlow();
|
|
1417
1384
|
const store = useStore();
|
|
1418
1385
|
return (positionDiff, isShiftPressed = false) => {
|
|
1419
1386
|
const xVelo = store.snapToGrid ? store.snapGrid[0] : 5;
|
|
@@ -1425,10 +1392,18 @@ function useUpdateNodePositions() {
|
|
|
1425
1392
|
for (const node of getSelectedNodes.value) if (node.draggable || store.nodesDraggable && typeof node.draggable === "undefined") {
|
|
1426
1393
|
const internalNode = getInternalNode(node.id);
|
|
1427
1394
|
if (!internalNode) continue;
|
|
1428
|
-
|
|
1395
|
+
let nextPosition = {
|
|
1429
1396
|
x: internalNode.internals.positionAbsolute.x + positionDiffX,
|
|
1430
1397
|
y: internalNode.internals.positionAbsolute.y + positionDiffY
|
|
1431
|
-
}
|
|
1398
|
+
};
|
|
1399
|
+
if (store.snapToGrid) nextPosition = snapPosition(nextPosition, store.snapGrid);
|
|
1400
|
+
const { position, positionAbsolute } = calculateNodePosition({
|
|
1401
|
+
nodeId: node.id,
|
|
1402
|
+
nextPosition,
|
|
1403
|
+
nodeLookup: store.nodeLookup,
|
|
1404
|
+
nodeExtent: store.nodeExtent,
|
|
1405
|
+
nodeOrigin: store.nodeOrigin
|
|
1406
|
+
});
|
|
1432
1407
|
nodeUpdates.push({
|
|
1433
1408
|
id: node.id,
|
|
1434
1409
|
position,
|
|
@@ -1437,10 +1412,7 @@ function useUpdateNodePositions() {
|
|
|
1437
1412
|
y: positionDiff.y
|
|
1438
1413
|
},
|
|
1439
1414
|
measured: getNodeDimensions(internalNode),
|
|
1440
|
-
internals: { positionAbsolute
|
|
1441
|
-
x: internalNode.internals.positionAbsolute.x,
|
|
1442
|
-
y: internalNode.internals.positionAbsolute.y
|
|
1443
|
-
} }
|
|
1415
|
+
internals: { positionAbsolute }
|
|
1444
1416
|
});
|
|
1445
1417
|
}
|
|
1446
1418
|
updateNodePositions(nodeUpdates, true, false);
|
|
@@ -4314,7 +4286,7 @@ function useActions(state, nodeLookup, parentLookup, edgeLookup) {
|
|
|
4314
4286
|
for (const id of rawEdgeLookup.keys()) if (!nextIds.has(id)) edgeLookup.delete(id);
|
|
4315
4287
|
}
|
|
4316
4288
|
state.edges = next;
|
|
4317
|
-
updateConnectionLookup(state.connectionLookup,
|
|
4289
|
+
updateConnectionLookup(state.connectionLookup, next);
|
|
4318
4290
|
}
|
|
4319
4291
|
/**
|
|
4320
4292
|
* Recompute parent-aware `internals.positionAbsolute` on the system lookup, then mirror into the
|