@particle-academy/fancy-flow 0.5.2 → 0.5.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.js CHANGED
@@ -1,9 +1,9 @@
1
- import { useFlowState, useFlowRun, applyStatusesToNodes } from './chunk-4PZQRN5Y.js';
2
- export { applyStatusesToNodes, useFlowRun, useFlowState } from './chunk-4PZQRN5Y.js';
3
- export { runFlow } from './chunk-DW66NGU5.js';
4
- import { registerBuiltinKinds, buildNodeTypes } from './chunk-35OXF6W3.js';
5
- export { BUILTIN_KINDS, RegistryNode, buildNodeTypes, registerBuiltinKinds } from './chunk-35OXF6W3.js';
6
- import { Position, Handle, index, BackgroundVariant, Background, Controls, MiniMap, ReactFlowProvider, addEdge, applyEdgeChanges, applyNodeChanges, useReactFlow } from './chunk-2BZ6OE5H.js';
1
+ import { useFlowState, useFlowRun, applyStatusesToNodes } from './chunk-QSSQRQN4.js';
2
+ export { applyStatusesToNodes, useFlowRun, useFlowState } from './chunk-QSSQRQN4.js';
3
+ export { runFlow } from './chunk-NVULCEDX.js';
4
+ import { registerBuiltinKinds, buildNodeTypes } from './chunk-M2XKGQQL.js';
5
+ export { BUILTIN_KINDS, RegistryNode, buildNodeTypes, registerBuiltinKinds } from './chunk-M2XKGQQL.js';
6
+ import { Position, Handle, index, BackgroundVariant, Background, Controls, MiniMap, ReactFlowProvider, addEdge, applyEdgeChanges, applyNodeChanges, useReactFlow } from './chunk-NF6NPY5N.js';
7
7
  import { exportWorkflow, workflowToBlob, importWorkflow } from './chunk-BCXECQUC.js';
8
8
  export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, workflowToBlob } from './chunk-BCXECQUC.js';
9
9
  import { onNodeKindsChanged, listNodeKinds, categoryAccent, getNodeKind, validateConfig, defaultConfigFor } from './chunk-WNVBXXOL.js';
package/dist/registry.cjs CHANGED
@@ -3055,7 +3055,7 @@ function zoom_default2() {
3055
3055
 
3056
3056
  // node_modules/@xyflow/system/dist/esm/index.js
3057
3057
  var errorMessages = {
3058
- error001: (lib = "react") => `Seems like you have not used zustand provider as an ancestor. Help: https://${lib}flow.dev/error#001`,
3058
+ error001: (lib = "react") => `Seems like you have not used ${lib === "svelte" ? "SvelteFlowProvider" : "ReactFlowProvider"} as an ancestor. Help: https://${lib}flow.dev/error#001`,
3059
3059
  error002: () => "It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
3060
3060
  error003: (nodeType) => `Node type "${nodeType}" not found. Using fallback type "default".`,
3061
3061
  error004: () => "The parent container needs a width and a height to render the graph.",
@@ -3194,21 +3194,21 @@ var getInternalNodesBounds = (nodeLookup, params = {}) => {
3194
3194
  return hasVisibleNodes ? boxToRect(box) : { x: 0, y: 0, width: 0, height: 0 };
3195
3195
  };
3196
3196
  var getNodesInside = (nodes, rect, [tx, ty, tScale] = [0, 0, 1], partially = false, excludeNonSelectableNodes = false) => {
3197
- const paneRect = {
3198
- ...pointToRendererPoint(rect, [tx, ty, tScale]),
3199
- width: rect.width / tScale,
3200
- height: rect.height / tScale
3201
- };
3197
+ const paneX = (rect.x - tx) / tScale;
3198
+ const paneY = (rect.y - ty) / tScale;
3199
+ const paneWidth = rect.width / tScale;
3200
+ const paneHeight = rect.height / tScale;
3202
3201
  const visibleNodes = [];
3203
3202
  for (const node of nodes.values()) {
3204
3203
  const { measured, selectable = true, hidden = false } = node;
3205
3204
  if (excludeNonSelectableNodes && !selectable || hidden) {
3206
3205
  continue;
3207
3206
  }
3208
- const width = measured.width ?? node.width ?? node.initialWidth ?? null;
3209
- const height = measured.height ?? node.height ?? node.initialHeight ?? null;
3210
- const overlappingArea = getOverlappingArea(paneRect, nodeToRect(node));
3211
- const area = (width ?? 0) * (height ?? 0);
3207
+ const width = measured.width ?? node.width ?? node.initialWidth ?? 0;
3208
+ const height = measured.height ?? node.height ?? node.initialHeight ?? 0;
3209
+ const { x, y } = node.internals.positionAbsolute;
3210
+ const overlappingArea = getRectsOverlappingArea(paneX, paneY, paneWidth, paneHeight, x, y, width, height);
3211
+ const area = width * height;
3212
3212
  const partiallyVisible = partially && overlappingArea > 0;
3213
3213
  const forceInitialRender = !node.internals.handleBounds;
3214
3214
  const isVisible = forceInitialRender || partiallyVisible || overlappingArea >= area;
@@ -3388,11 +3388,12 @@ var nodeToBox = (node, nodeOrigin = [0, 0]) => {
3388
3388
  };
3389
3389
  };
3390
3390
  var getBoundsOfRects = (rect1, rect2) => boxToRect(getBoundsOfBoxes(rectToBox(rect1), rectToBox(rect2)));
3391
- var getOverlappingArea = (rectA, rectB) => {
3392
- const xOverlap = Math.max(0, Math.min(rectA.x + rectA.width, rectB.x + rectB.width) - Math.max(rectA.x, rectB.x));
3393
- const yOverlap = Math.max(0, Math.min(rectA.y + rectA.height, rectB.y + rectB.height) - Math.max(rectA.y, rectB.y));
3391
+ var getRectsOverlappingArea = (aX, aY, aWidth, aHeight, bX, bY, bWidth, bHeight) => {
3392
+ const xOverlap = Math.max(0, Math.min(aX + aWidth, bX + bWidth) - Math.max(aX, bX));
3393
+ const yOverlap = Math.max(0, Math.min(aY + aHeight, bY + bHeight) - Math.max(aY, bY));
3394
3394
  return Math.ceil(xOverlap * yOverlap);
3395
3395
  };
3396
+ var getOverlappingArea = (rectA, rectB) => getRectsOverlappingArea(rectA.x, rectA.y, rectA.width, rectA.height, rectB.x, rectB.y, rectB.width, rectB.height);
3396
3397
  var isRectObject = (obj) => isNumeric(obj.width) && isNumeric(obj.height) && isNumeric(obj.x) && isNumeric(obj.y);
3397
3398
  var isNumeric = (n) => !isNaN(n) && isFinite(n);
3398
3399
  var createDevWarn = (lib, helpUrl) => (id2, message) => {
@@ -5854,11 +5855,12 @@ var Panel = ReactExports.forwardRef(({ position = "top-left", children: children
5854
5855
  return jsxRuntime.jsx("div", { className: cc(["react-flow__panel", className, ...positionClasses]), style: style2, ref, ...rest, children: children2 });
5855
5856
  });
5856
5857
  Panel.displayName = "Panel";
5858
+ var link = `https://reactflow.dev${process.env.NODE_ENV === "production" ? "?utm_source=attribution" : "/attribution"}`;
5857
5859
  function Attribution({ proOptions, position = "bottom-right" }) {
5858
5860
  if (proOptions?.hideAttribution) {
5859
5861
  return null;
5860
5862
  }
5861
- return jsxRuntime.jsx(Panel, { position, className: "react-flow__attribution", "data-message": "Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev", children: jsxRuntime.jsx("a", { href: "https://reactflow.dev", target: "_blank", rel: "noopener noreferrer", "aria-label": "React Flow attribution", children: "React Flow" }) });
5863
+ return jsxRuntime.jsx(Panel, { position, className: "react-flow__attribution", "data-message": `Please only hide this attribution when you are subscribed to React Flow Pro: ${link}`, children: jsxRuntime.jsx("a", { href: link, target: "_blank", rel: "noopener noreferrer", "aria-label": "React Flow attribution", children: "React Flow" }) });
5862
5864
  }
5863
5865
  var selector$m = (s) => {
5864
5866
  const selectedNodes = [];
@@ -6785,7 +6787,6 @@ var wrapHandler = (handler, containerRef) => {
6785
6787
  var selector$h = (s) => ({
6786
6788
  userSelectionActive: s.userSelectionActive,
6787
6789
  elementsSelectable: s.elementsSelectable,
6788
- connectionInProgress: s.connection.inProgress,
6789
6790
  dragging: s.paneDragging,
6790
6791
  panBy: s.panBy,
6791
6792
  autoPanSpeed: s.autoPanSpeed
@@ -6793,18 +6794,20 @@ var selector$h = (s) => ({
6793
6794
  function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, autoPanOnSelection, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children: children2 }) {
6794
6795
  const autoPanId = ReactExports.useRef(0);
6795
6796
  const store = useStoreApi();
6796
- const { userSelectionActive, elementsSelectable, dragging, connectionInProgress, panBy: panBy2, autoPanSpeed } = useStore(selector$h, shallow$1);
6797
+ const { userSelectionActive, elementsSelectable, dragging, panBy: panBy2, autoPanSpeed } = useStore(selector$h, shallow$1);
6797
6798
  const isSelectionEnabled = elementsSelectable && (isSelecting || userSelectionActive);
6798
6799
  const container = ReactExports.useRef(null);
6799
6800
  const containerBounds = ReactExports.useRef();
6800
6801
  const selectedNodeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
6801
6802
  const selectedEdgeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
6803
+ const connectionEndedOnPane = ReactExports.useRef(false);
6802
6804
  const selectionInProgress = ReactExports.useRef(false);
6803
6805
  const position = ReactExports.useRef({ x: 0, y: 0 });
6804
6806
  const autoPanStarted = ReactExports.useRef(false);
6805
6807
  const onClick = (event) => {
6806
- if (selectionInProgress.current || connectionInProgress) {
6808
+ if (selectionInProgress.current || connectionEndedOnPane.current || store.getState().connection.inProgress) {
6807
6809
  selectionInProgress.current = false;
6810
+ connectionEndedOnPane.current = false;
6808
6811
  return;
6809
6812
  }
6810
6813
  onPaneClick?.(event);
@@ -6949,6 +6952,12 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
6949
6952
  commitUserSelectionRect(mouseX, mouseY);
6950
6953
  };
6951
6954
  const onPointerUp = (event) => {
6955
+ if (!isSelectionEnabled) {
6956
+ if (event.target === container.current && store.getState().connection.inProgress) {
6957
+ connectionEndedOnPane.current = true;
6958
+ }
6959
+ return;
6960
+ }
6952
6961
  if (event.button !== 0) {
6953
6962
  return;
6954
6963
  }
@@ -6973,7 +6982,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
6973
6982
  cleanupAutoPan();
6974
6983
  };
6975
6984
  const draggable = panOnDrag === true || Array.isArray(panOnDrag) && panOnDrag.includes(0);
6976
- return jsxRuntime.jsxs("div", { className: cc(["react-flow__pane", { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? void 0 : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? void 0 : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp: isSelectionEnabled ? onPointerUp : void 0, onPointerCancel: isSelectionEnabled ? onPointerCancel : void 0, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : void 0, onClickCapture: isSelectionEnabled ? onClickCapture : void 0, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children2, jsxRuntime.jsx(UserSelection, {})] });
6985
+ return jsxRuntime.jsxs("div", { className: cc(["react-flow__pane", { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? void 0 : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? void 0 : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp, onPointerCancel: isSelectionEnabled ? onPointerCancel : void 0, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : void 0, onClickCapture: isSelectionEnabled ? onClickCapture : void 0, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children2, jsxRuntime.jsx(UserSelection, {})] });
6977
6986
  }
6978
6987
  function handleNodeClick({ id: id2, store, unselect = false, nodeRef }) {
6979
6988
  const { addSelectedNodes, unselectNodesAndEdges, multiSelectionActive, nodeLookup, onError } = store.getState();
@@ -7080,9 +7089,33 @@ var selector$g = (s) => ({
7080
7089
  noPanClassName: s.noPanClassName,
7081
7090
  rfId: s.rfId
7082
7091
  });
7092
+ var HandleConfigContext = ReactExports.createContext(null);
7093
+ function HandleConfigProvider({ children: children2 }) {
7094
+ const config = useStore(selector$g, shallow$1);
7095
+ return jsxRuntime.jsx(HandleConfigContext.Provider, { value: config, children: children2 });
7096
+ }
7097
+ function useHandleConfig() {
7098
+ const config = ReactExports.useContext(HandleConfigContext);
7099
+ if (!config) {
7100
+ throw new Error("useHandleConfig must be used within a HandleConfigProvider");
7101
+ }
7102
+ return config;
7103
+ }
7104
+ var idleConnectingState = {
7105
+ connectingFrom: false,
7106
+ connectingTo: false,
7107
+ clickConnecting: false,
7108
+ isPossibleEndHandle: true,
7109
+ connectionInProcess: false,
7110
+ clickConnectionInProcess: false,
7111
+ valid: false
7112
+ };
7083
7113
  var connectingSelector = (nodeId, handleId, type) => (state) => {
7084
7114
  const { connectionClickStartHandle: clickHandle, connectionMode, connection } = state;
7085
7115
  const { fromHandle, toHandle, isValid } = connection;
7116
+ if (!fromHandle && !clickHandle) {
7117
+ return idleConnectingState;
7118
+ }
7086
7119
  const connectingTo = toHandle?.nodeId === nodeId && toHandle?.id === handleId && toHandle?.type === type;
7087
7120
  return {
7088
7121
  connectingFrom: fromHandle?.nodeId === nodeId && fromHandle?.id === handleId && fromHandle?.type === type,
@@ -7099,7 +7132,7 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
7099
7132
  const isTarget = type === "target";
7100
7133
  const store = useStoreApi();
7101
7134
  const nodeId = useNodeId();
7102
- const { connectOnClick, noPanClassName, rfId } = useStore(selector$g, shallow$1);
7135
+ const { connectOnClick, noPanClassName, rfId } = useHandleConfig();
7103
7136
  const { connectingFrom, connectingTo, clickConnecting, isPossibleEndHandle, connectionInProcess, clickConnectionInProcess, valid } = useStore(connectingSelector(nodeId, handleId, type), shallow$1);
7104
7137
  if (!nodeId) {
7105
7138
  store.getState().onError?.("010", errorMessages["error010"]());
@@ -7802,7 +7835,8 @@ var nullPosition = {
7802
7835
  targetX: null,
7803
7836
  targetY: null,
7804
7837
  sourcePosition: null,
7805
- targetPosition: null
7838
+ targetPosition: null,
7839
+ zIndex: void 0
7806
7840
  };
7807
7841
  var shiftX = (x, shift, position) => {
7808
7842
  if (position === Position.Left)
@@ -7890,14 +7924,11 @@ function EdgeWrapper({ id: id2, edgesFocusable, edgesReconnectable, elementsSele
7890
7924
  const [updateHover, setUpdateHover] = ReactExports.useState(false);
7891
7925
  const [reconnecting, setReconnecting] = ReactExports.useState(false);
7892
7926
  const store = useStoreApi();
7893
- const { zIndex, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition } = useStore(ReactExports.useCallback((store2) => {
7927
+ const { zIndex = edge.zIndex, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition } = useStore(ReactExports.useCallback((store2) => {
7894
7928
  const sourceNode = store2.nodeLookup.get(edge.source);
7895
7929
  const targetNode = store2.nodeLookup.get(edge.target);
7896
7930
  if (!sourceNode || !targetNode) {
7897
- return {
7898
- zIndex: edge.zIndex,
7899
- ...nullPosition
7900
- };
7931
+ return nullPosition;
7901
7932
  }
7902
7933
  const edgePosition = getEdgePosition({
7903
7934
  id: id2,
@@ -7917,8 +7948,8 @@ function EdgeWrapper({ id: id2, edgesFocusable, edgesReconnectable, elementsSele
7917
7948
  zIndexMode: store2.zIndexMode
7918
7949
  });
7919
7950
  return {
7920
- zIndex: zIndex2,
7921
- ...edgePosition || nullPosition
7951
+ ...edgePosition || nullPosition,
7952
+ zIndex: zIndex2
7922
7953
  };
7923
7954
  }, [edge.source, edge.target, edge.sourceHandle, edge.targetHandle, edge.selected, edge.zIndex]), shallow$1);
7924
7955
  const markerStartUrl = ReactExports.useMemo(() => edge.markerStart ? `url('#${getMarkerId(edge.markerStart, rfId)}')` : void 0, [edge.markerStart, rfId]);
@@ -8516,7 +8547,7 @@ function ReactFlowProvider({ initialNodes: nodes, initialEdges: edges, defaultNo
8516
8547
  nodeExtent,
8517
8548
  zIndexMode
8518
8549
  }));
8519
- return jsxRuntime.jsx(Provider$1, { value: store, children: jsxRuntime.jsx(BatchProvider, { children: children2 }) });
8550
+ return jsxRuntime.jsx(Provider$1, { value: store, children: jsxRuntime.jsx(BatchProvider, { children: jsxRuntime.jsx(HandleConfigProvider, { children: children2 }) }) });
8520
8551
  }
8521
8552
  function Wrapper({ children: children2, nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode }) {
8522
8553
  const isWrapped = ReactExports.useContext(StoreContext);