@xyflow/vue 2.0.0-next.1 → 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/base.css +161 -79
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +15 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -65
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +203 -133
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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";
|
|
3
|
-
import { onKeyStroke, until, useEventListener
|
|
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
|
+
import { onKeyStroke, until, useEventListener } from "@vueuse/core";
|
|
4
4
|
//#region src/context/index.ts
|
|
5
5
|
/** the curated instance (`useVueFlow()`) */
|
|
6
6
|
const VueFlow = Symbol("vueFlow");
|
|
@@ -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);
|
|
@@ -4033,23 +4005,6 @@ function _sfc_render$11(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4033
4005
|
}
|
|
4034
4006
|
var A11yDescriptions_default = /* @__PURE__ */ export_helper_default(_sfc_main$11, [["render", _sfc_render$11], ["__file", "/Users/moritz/xyflow/xyflow/packages/vue/src/components/A11y/A11yDescriptions.vue"]]);
|
|
4035
4007
|
//#endregion
|
|
4036
|
-
//#region src/composables/useColorModeClass.ts
|
|
4037
|
-
/**
|
|
4038
|
-
* Resolves the `colorMode` prop to the `light`/`dark` class applied to the flow container, tracking
|
|
4039
|
-
* `prefers-color-scheme` reactively when `colorMode` is `system` (matching xyflow/react+svelte).
|
|
4040
|
-
*
|
|
4041
|
-
* Takes the state explicitly because it runs inside `<VueFlow>`'s own setup; defaults to `useStore()`.
|
|
4042
|
-
*
|
|
4043
|
-
* @internal
|
|
4044
|
-
*/
|
|
4045
|
-
function useColorModeClass(state = useStore()) {
|
|
4046
|
-
const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
|
|
4047
|
-
return computed(() => {
|
|
4048
|
-
if (state.colorMode === "system") return prefersDark.value ? "dark" : "light";
|
|
4049
|
-
return state.colorMode;
|
|
4050
|
-
});
|
|
4051
|
-
}
|
|
4052
|
-
//#endregion
|
|
4053
4008
|
//#region src/store/hooks.ts
|
|
4054
4009
|
function createHooks() {
|
|
4055
4010
|
return {
|
|
@@ -4167,7 +4122,6 @@ function useState() {
|
|
|
4167
4122
|
translateExtent: [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]],
|
|
4168
4123
|
nodeExtent: [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]],
|
|
4169
4124
|
nodeOrigin: [0, 0],
|
|
4170
|
-
colorMode: "light",
|
|
4171
4125
|
selectionMode: SelectionMode$1.Full,
|
|
4172
4126
|
paneDragging: false,
|
|
4173
4127
|
preventScrolling: true,
|
|
@@ -4332,7 +4286,7 @@ function useActions(state, nodeLookup, parentLookup, edgeLookup) {
|
|
|
4332
4286
|
for (const id of rawEdgeLookup.keys()) if (!nextIds.has(id)) edgeLookup.delete(id);
|
|
4333
4287
|
}
|
|
4334
4288
|
state.edges = next;
|
|
4335
|
-
updateConnectionLookup(state.connectionLookup,
|
|
4289
|
+
updateConnectionLookup(state.connectionLookup, next);
|
|
4336
4290
|
}
|
|
4337
4291
|
/**
|
|
4338
4292
|
* Recompute parent-aware `internals.positionAbsolute` on the system lookup, then mirror into the
|
|
@@ -7108,7 +7062,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7108
7062
|
type: Array,
|
|
7109
7063
|
required: false
|
|
7110
7064
|
},
|
|
7111
|
-
|
|
7065
|
+
forceColorMode: {
|
|
7112
7066
|
type: String,
|
|
7113
7067
|
required: false,
|
|
7114
7068
|
default: void 0
|
|
@@ -7360,7 +7314,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7360
7314
|
useOnInitHandler(instance);
|
|
7361
7315
|
useSelectionChange(instance);
|
|
7362
7316
|
useStylesLoadedWarning(instance);
|
|
7363
|
-
const colorModeClass = useColorModeClass(state);
|
|
7364
7317
|
useViewportSync(modelViewport, state);
|
|
7365
7318
|
const stateRefs = storeToRefs(state);
|
|
7366
7319
|
provide(Slots$1, slots);
|
|
@@ -7379,7 +7332,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7379
7332
|
instance,
|
|
7380
7333
|
state,
|
|
7381
7334
|
disposeWatchers,
|
|
7382
|
-
colorModeClass,
|
|
7383
7335
|
stateRefs,
|
|
7384
7336
|
A11yDescriptions: A11yDescriptions_default,
|
|
7385
7337
|
ZoomPane: ZoomPane_default
|
|
@@ -7394,7 +7346,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7394
7346
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
7395
7347
|
return openBlock(), createElementBlock("div", {
|
|
7396
7348
|
ref: $setup.stateRefs.vueFlowRef,
|
|
7397
|
-
class: normalizeClass(["vue-flow", $setup.
|
|
7349
|
+
class: normalizeClass(["vue-flow", $setup.props.forceColorMode])
|
|
7398
7350
|
}, [
|
|
7399
7351
|
createCommentVNode(" the `zoom-pane` slot (affected by zooming & panning) renders inside the transformed Viewport via\n the provided `Slots` (see ZoomPaneSlot), not drilled through ZoomPane → Pane → Viewport "),
|
|
7400
7352
|
createVNode($setup["ZoomPane"]),
|