@xyflow/vue 2.0.0-next.0 → 2.0.0-next.2

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.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
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, useMediaQuery } from "@vueuse/core";
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");
@@ -2565,18 +2565,6 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
2565
2565
  "data-nodeid": nodeId,
2566
2566
  "data-handlepos": __props.position
2567
2567
  }));
2568
- const isConnectableStart = toRef(() => typeof __props.connectableStart !== "undefined" ? __props.connectableStart : true);
2569
- const isConnectableEnd = toRef(() => typeof __props.connectableEnd !== "undefined" ? __props.connectableEnd : true);
2570
- const connectionInProcess = toRef(() => store.connectionStartHandle !== null);
2571
- const clickConnectionInProcess = toRef(() => store.connectionClickStartHandle !== null);
2572
- const isPossibleEndHandle = toRef(() => {
2573
- const fromHandle = store.connectionStartHandle;
2574
- return store.connectionMode === ConnectionMode$1.Strict ? fromHandle?.type !== type.value : nodeId !== fromHandle?.nodeId || __props.id !== fromHandle?.id;
2575
- });
2576
- const isClickConnecting = toRef(() => store.connectionClickStartHandle?.nodeId === nodeId && store.connectionClickStartHandle?.id === __props.id && store.connectionClickStartHandle?.type === type.value);
2577
- const connectingFrom = toRef(() => store.connectionStartHandle?.nodeId === nodeId && store.connectionStartHandle?.id === __props.id && store.connectionStartHandle?.type === type.value);
2578
- const connectingTo = toRef(() => store.connectionEndHandle?.nodeId === nodeId && store.connectionEndHandle?.id === __props.id && store.connectionEndHandle?.type === type.value);
2579
- const valid = toRef(() => connectingTo.value && store.connectionStatus === "valid");
2580
2568
  const { handlePointerDown, handleClick } = useHandle({
2581
2569
  nodeId,
2582
2570
  handleId: __props.id,
@@ -2597,6 +2585,28 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
2597
2585
  if (typeof __props.isConnectable === "function") return nodeRef.value ? __props.isConnectable(nodeRef.value, connectedEdges.value) : false;
2598
2586
  return isDef(__props.isConnectable) ? __props.isConnectable : store.nodesConnectable;
2599
2587
  });
2588
+ const connectionClasses = computed((prev) => {
2589
+ const fromHandle = store.connectionStartHandle;
2590
+ const clickFromHandle = store.connectionClickStartHandle;
2591
+ const toHandle = store.connectionEndHandle;
2592
+ const handleType = type.value;
2593
+ const connectionInProcess = fromHandle !== null;
2594
+ const clickConnectionInProcess = clickFromHandle !== null;
2595
+ const isPossibleEndHandle = store.connectionMode === ConnectionMode$1.Strict ? fromHandle?.type !== handleType : nodeId !== fromHandle?.nodeId || __props.id !== fromHandle?.id;
2596
+ const connectingto = toHandle?.nodeId === nodeId && toHandle?.id === __props.id && toHandle?.type === handleType;
2597
+ const next = {
2598
+ connectable: isHandleConnectable.value,
2599
+ connecting: clickFromHandle?.nodeId === nodeId && clickFromHandle?.id === __props.id && clickFromHandle?.type === handleType,
2600
+ connectablestart: __props.connectableStart,
2601
+ connectableend: __props.connectableEnd,
2602
+ connectingfrom: fromHandle?.nodeId === nodeId && fromHandle?.id === __props.id && fromHandle?.type === handleType,
2603
+ connectingto,
2604
+ valid: connectingto && store.connectionStatus === "valid",
2605
+ connectionindicator: isHandleConnectable.value && (!connectionInProcess || isPossibleEndHandle) && (connectionInProcess || clickConnectionInProcess ? __props.connectableEnd : __props.connectableStart)
2606
+ };
2607
+ if (prev && prev.connectable === next.connectable && prev.connecting === next.connecting && prev.connectablestart === next.connectablestart && prev.connectableend === next.connectableend && prev.connectingfrom === next.connectingfrom && prev.connectingto === next.connectingto && prev.valid === next.valid && prev.connectionindicator === next.connectionindicator) return prev;
2608
+ return next;
2609
+ });
2600
2610
  onMounted(() => {
2601
2611
  const node = nodeRef.value;
2602
2612
  if (!node || !nodeHasDimensions(node)) return;
@@ -2626,10 +2636,10 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
2626
2636
  });
2627
2637
  function onPointerDown(event) {
2628
2638
  const isMouseTriggered = isMouseEvent(event);
2629
- if (isHandleConnectable.value && isConnectableStart.value && (isMouseTriggered && event.button === 0 || !isMouseTriggered)) handlePointerDown(event);
2639
+ if (isHandleConnectable.value && __props.connectableStart && (isMouseTriggered && event.button === 0 || !isMouseTriggered)) handlePointerDown(event);
2630
2640
  }
2631
2641
  function onClick(event) {
2632
- if (!nodeId || !store.connectionClickStartHandle && !isConnectableStart.value) return;
2642
+ if (!nodeId || !store.connectionClickStartHandle && !__props.connectableStart) return;
2633
2643
  if (isHandleConnectable.value) handleClick(event);
2634
2644
  }
2635
2645
  __expose({
@@ -2650,18 +2660,10 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
2650
2660
  connectedEdges,
2651
2661
  handle,
2652
2662
  handleDataIds,
2653
- isConnectableStart,
2654
- isConnectableEnd,
2655
- connectionInProcess,
2656
- clickConnectionInProcess,
2657
- isPossibleEndHandle,
2658
- isClickConnecting,
2659
- connectingFrom,
2660
- connectingTo,
2661
- valid,
2662
2663
  handlePointerDown,
2663
2664
  handleClick,
2664
2665
  isHandleConnectable,
2666
+ connectionClasses,
2665
2667
  onPointerDown,
2666
2668
  onClick
2667
2669
  };
@@ -2682,16 +2684,7 @@ function _sfc_render$17(_ctx, _cache, $props, $setup, $data, $options) {
2682
2684
  $setup.store.noDragClassName,
2683
2685
  $setup.store.noPanClassName,
2684
2686
  $setup.type,
2685
- {
2686
- connectable: $setup.isHandleConnectable,
2687
- connecting: $setup.isClickConnecting,
2688
- connectablestart: $setup.isConnectableStart,
2689
- connectableend: $setup.isConnectableEnd,
2690
- connectingfrom: $setup.connectingFrom,
2691
- connectingto: $setup.connectingTo,
2692
- valid: $setup.valid,
2693
- connectionindicator: $setup.isHandleConnectable && (!$setup.connectionInProcess || $setup.isPossibleEndHandle) && ($setup.connectionInProcess || $setup.clickConnectionInProcess ? $setup.isConnectableEnd : $setup.isConnectableStart)
2694
- }
2687
+ $setup.connectionClasses
2695
2688
  ]],
2696
2689
  onMousedown: $setup.onPointerDown,
2697
2690
  onTouchstartPassive: $setup.onPointerDown,
@@ -4040,23 +4033,6 @@ function _sfc_render$11(_ctx, _cache, $props, $setup, $data, $options) {
4040
4033
  }
4041
4034
  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"]]);
4042
4035
  //#endregion
4043
- //#region src/composables/useColorModeClass.ts
4044
- /**
4045
- * Resolves the `colorMode` prop to the `light`/`dark` class applied to the flow container, tracking
4046
- * `prefers-color-scheme` reactively when `colorMode` is `system` (matching xyflow/react+svelte).
4047
- *
4048
- * Takes the state explicitly because it runs inside `<VueFlow>`'s own setup; defaults to `useStore()`.
4049
- *
4050
- * @internal
4051
- */
4052
- function useColorModeClass(state = useStore()) {
4053
- const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
4054
- return computed(() => {
4055
- if (state.colorMode === "system") return prefersDark.value ? "dark" : "light";
4056
- return state.colorMode;
4057
- });
4058
- }
4059
- //#endregion
4060
4036
  //#region src/store/hooks.ts
4061
4037
  function createHooks() {
4062
4038
  return {
@@ -4174,7 +4150,6 @@ function useState() {
4174
4150
  translateExtent: [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]],
4175
4151
  nodeExtent: [[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]],
4176
4152
  nodeOrigin: [0, 0],
4177
- colorMode: "light",
4178
4153
  selectionMode: SelectionMode$1.Full,
4179
4154
  paneDragging: false,
4180
4155
  preventScrolling: true,
@@ -7115,7 +7090,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7115
7090
  type: Array,
7116
7091
  required: false
7117
7092
  },
7118
- colorMode: {
7093
+ forceColorMode: {
7119
7094
  type: String,
7120
7095
  required: false,
7121
7096
  default: void 0
@@ -7367,7 +7342,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7367
7342
  useOnInitHandler(instance);
7368
7343
  useSelectionChange(instance);
7369
7344
  useStylesLoadedWarning(instance);
7370
- const colorModeClass = useColorModeClass(state);
7371
7345
  useViewportSync(modelViewport, state);
7372
7346
  const stateRefs = storeToRefs(state);
7373
7347
  provide(Slots$1, slots);
@@ -7386,7 +7360,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7386
7360
  instance,
7387
7361
  state,
7388
7362
  disposeWatchers,
7389
- colorModeClass,
7390
7363
  stateRefs,
7391
7364
  A11yDescriptions: A11yDescriptions_default,
7392
7365
  ZoomPane: ZoomPane_default
@@ -7401,7 +7374,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7401
7374
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
7402
7375
  return openBlock(), createElementBlock("div", {
7403
7376
  ref: $setup.stateRefs.vueFlowRef,
7404
- class: normalizeClass(["vue-flow", $setup.colorModeClass])
7377
+ class: normalizeClass(["vue-flow", $setup.props.forceColorMode])
7405
7378
  }, [
7406
7379
  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 "),
7407
7380
  createVNode($setup["ZoomPane"]),