@xyflow/react 12.8.6 → 12.9.0
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/LICENSE +1 -1
- package/dist/esm/additional-components/EdgeToolbar/EdgeToolbar.d.ts +26 -0
- package/dist/esm/additional-components/EdgeToolbar/EdgeToolbar.d.ts.map +1 -0
- package/dist/esm/additional-components/EdgeToolbar/index.d.ts +3 -0
- package/dist/esm/additional-components/EdgeToolbar/index.d.ts.map +1 -0
- package/dist/esm/additional-components/EdgeToolbar/types.d.ts +9 -0
- package/dist/esm/additional-components/EdgeToolbar/types.d.ts.map +1 -0
- package/dist/esm/additional-components/index.d.ts +1 -0
- package/dist/esm/additional-components/index.d.ts.map +1 -1
- package/dist/esm/components/EdgeWrapper/index.d.ts +3 -1
- package/dist/esm/components/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/esm/components/NodeWrapper/index.d.ts +3 -1
- package/dist/esm/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/esm/container/Pane/index.d.ts +0 -3
- package/dist/esm/container/Pane/index.d.ts.map +1 -1
- package/dist/esm/index.js +69 -8
- package/dist/esm/index.mjs +69 -8
- package/dist/esm/types/edges.d.ts +1 -1
- package/dist/esm/types/edges.d.ts.map +1 -1
- package/dist/umd/additional-components/EdgeToolbar/EdgeToolbar.d.ts +26 -0
- package/dist/umd/additional-components/EdgeToolbar/EdgeToolbar.d.ts.map +1 -0
- package/dist/umd/additional-components/EdgeToolbar/index.d.ts +3 -0
- package/dist/umd/additional-components/EdgeToolbar/index.d.ts.map +1 -0
- package/dist/umd/additional-components/EdgeToolbar/types.d.ts +9 -0
- package/dist/umd/additional-components/EdgeToolbar/types.d.ts.map +1 -0
- package/dist/umd/additional-components/index.d.ts +1 -0
- package/dist/umd/additional-components/index.d.ts.map +1 -1
- package/dist/umd/components/EdgeWrapper/index.d.ts +3 -1
- package/dist/umd/components/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/umd/components/NodeWrapper/index.d.ts +3 -1
- package/dist/umd/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/umd/container/Pane/index.d.ts +0 -3
- package/dist/umd/container/Pane/index.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/types/edges.d.ts +1 -1
- package/dist/umd/types/edges.d.ts.map +1 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EdgeToolbarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* This component can render a toolbar or tooltip to one side of a custom edge. This
|
|
4
|
+
* toolbar doesn't scale with the viewport so that the content stays the same size.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* import { EdgeToolbar, BaseEdge, getBezierPath, type EdgeProps } from "@xyflow/react";
|
|
10
|
+
*
|
|
11
|
+
* export function CustomEdge({ id, data, ...props }: EdgeProps) {
|
|
12
|
+
* const [edgePath, centerX, centerY] = getBezierPath(props);
|
|
13
|
+
*
|
|
14
|
+
* return (
|
|
15
|
+
* <>
|
|
16
|
+
* <BaseEdge id={id} path={edgePath} />
|
|
17
|
+
* <EdgeToolbar edgeId={id} x={centerX} y={centerY} isVisible>
|
|
18
|
+
* <button onClick={() => console.log('edge', id, 'click')}}>Click me</button>
|
|
19
|
+
* </EdgeToolbar>
|
|
20
|
+
* </>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alignX, alignY, ...rest }: EdgeToolbarProps): import("react/jsx-runtime").JSX.Element | null;
|
|
26
|
+
//# sourceMappingURL=EdgeToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeToolbar.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/EdgeToolbar.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,CAAC,EACD,CAAC,EACD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,MAAiB,EACjB,MAAiB,EACjB,GAAG,IAAI,EACR,EAAE,gBAAgB,kDAgClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { EdgeToolbarBaseProps } from '@xyflow/system';
|
|
3
|
+
/**
|
|
4
|
+
* @inline
|
|
5
|
+
*/
|
|
6
|
+
export type EdgeToolbarProps = EdgeToolbarBaseProps & HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GACjD,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/additional-components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/additional-components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import type { Edge, EdgeWrapperProps } from '../../types';
|
|
3
|
-
|
|
3
|
+
declare function EdgeWrapper<EdgeType extends Edge = Edge>({ id, edgesFocusable, edgesReconnectable, elementsSelectable, onClick, onDoubleClick, onContextMenu, onMouseEnter, onMouseMove, onMouseLeave, reconnectRadius, onReconnect, onReconnectStart, onReconnectEnd, rfId, edgeTypes, noPanClassName, onError, disableKeyboardA11y, }: EdgeWrapperProps<EdgeType>): JSX.Element | null;
|
|
4
|
+
declare const _default: typeof EdgeWrapper;
|
|
5
|
+
export default _default;
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8D,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8D,GAAG,EAAQ,MAAM,OAAO,CAAC;AAe9F,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,iBAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,EACjD,EAAE,EACF,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,IAAI,EACJ,SAAS,EACT,cAAc,EACd,OAAO,EACP,mBAAmB,GACpB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmOjD;wBAEmC,OAAO,WAAW;AAAtD,wBAAuD"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Node, NodeWrapperProps } from '../../types';
|
|
2
|
-
|
|
2
|
+
declare function NodeWrapper<NodeType extends Node>({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onContextMenu, onDoubleClick, nodesDraggable, elementsSelectable, nodesConnectable, nodesFocusable, resizeObserver, noDragClassName, noPanClassName, disableKeyboardA11y, rfId, nodeTypes, nodeClickDistance, onError, }: NodeWrapperProps<NodeType>): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
declare const _default: typeof NodeWrapper;
|
|
4
|
+
export default _default;
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,iBAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,EAAE,EAC1C,EAAE,EACF,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,OAAO,GACR,EAAE,gBAAgB,CAAC,QAAQ,CAAC,kDAgN5B;wBAEmC,OAAO,WAAW;AAAtD,wBAAuD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgBf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAqBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAgOX"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
|
|
4
4
|
import cc from 'classcat';
|
|
5
|
-
import { errorMessages, mergeAriaLabelConfig, infiniteExtent, isInputDOMNode, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, withResolvers, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, initialConnection, devWarn, defaultAriaLabelConfig, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
|
|
5
|
+
import { errorMessages, mergeAriaLabelConfig, infiniteExtent, isInputDOMNode, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, withResolvers, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, initialConnection, devWarn, defaultAriaLabelConfig, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform, getEdgeToolbarTransform } from '@xyflow/system';
|
|
6
6
|
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
|
|
7
7
|
import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
|
|
8
8
|
import { shallow } from 'zustand/shallow';
|
|
@@ -1432,16 +1432,31 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1432
1432
|
onPaneContextMenu?.(event);
|
|
1433
1433
|
};
|
|
1434
1434
|
const onWheel = onPaneScroll ? (event) => onPaneScroll(event) : undefined;
|
|
1435
|
-
const
|
|
1435
|
+
const onClickCapture = (event) => {
|
|
1436
|
+
const isSelectionOnDragActive = (selectionOnDrag && container.current === event.target) || !selectionOnDrag || selectionKeyPressed;
|
|
1437
|
+
if (!isSelectionOnDragActive) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
event.stopPropagation();
|
|
1441
|
+
};
|
|
1442
|
+
// We are using capture here in order to prevent other pointer events
|
|
1443
|
+
// to be able to create a selection above a node or an edge
|
|
1444
|
+
const onPointerDownCapture = (event) => {
|
|
1436
1445
|
const { resetSelectedElements, domNode } = store.getState();
|
|
1437
1446
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
1447
|
+
const isNoKeyEvent = event.target !== container.current && !!event.target.closest('.nokey');
|
|
1448
|
+
const isSelectionActive = (selectionOnDrag && container.current === event.target) || !selectionOnDrag || selectionKeyPressed;
|
|
1438
1449
|
if (!elementsSelectable ||
|
|
1439
1450
|
!isSelecting ||
|
|
1440
1451
|
event.button !== 0 ||
|
|
1441
|
-
|
|
1442
|
-
|
|
1452
|
+
!containerBounds.current ||
|
|
1453
|
+
isNoKeyEvent ||
|
|
1454
|
+
!isSelectionActive ||
|
|
1455
|
+
!event.isPrimary) {
|
|
1443
1456
|
return;
|
|
1444
1457
|
}
|
|
1458
|
+
event.stopPropagation();
|
|
1459
|
+
event.preventDefault();
|
|
1445
1460
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
1446
1461
|
selectionStarted.current = true;
|
|
1447
1462
|
selectionInProgress.current = false;
|
|
@@ -1535,7 +1550,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1535
1550
|
selectionStarted.current = false;
|
|
1536
1551
|
};
|
|
1537
1552
|
const draggable = panOnDrag === true || (Array.isArray(panOnDrag) && panOnDrag.includes(0));
|
|
1538
|
-
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: hasActiveSelection ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: hasActiveSelection ? undefined : onPaneMouseEnter,
|
|
1553
|
+
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: hasActiveSelection ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: hasActiveSelection ? undefined : onPaneMouseEnter, onPointerMove: hasActiveSelection ? onPointerMove : onPaneMouseMove, onPointerUp: hasActiveSelection ? onPointerUp : undefined, onPointerDownCapture: hasActiveSelection ? onPointerDownCapture : undefined, onClickCapture: hasActiveSelection ? onClickCapture : undefined, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children, jsx(UserSelection, {})] }));
|
|
1539
1554
|
}
|
|
1540
1555
|
|
|
1541
1556
|
/*
|
|
@@ -2218,6 +2233,7 @@ function NodeWrapper({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onC
|
|
|
2218
2233
|
...inlineDimensions,
|
|
2219
2234
|
}, "data-id": id, "data-testid": `rf__node-${id}`, onMouseEnter: onMouseEnterHandler, onMouseMove: onMouseMoveHandler, onMouseLeave: onMouseLeaveHandler, onContextMenu: onContextMenuHandler, onClick: onSelectNodeHandler, onDoubleClick: onDoubleClickHandler, onKeyDown: isFocusable ? onKeyDown : undefined, tabIndex: isFocusable ? 0 : undefined, onFocus: isFocusable ? onFocus : undefined, role: node.ariaRole ?? (isFocusable ? 'group' : undefined), "aria-roledescription": "node", "aria-describedby": disableKeyboardA11y ? undefined : `${ARIA_NODE_DESC_KEY}-${rfId}`, "aria-label": node.ariaLabel, ...node.domAttributes, children: jsx(Provider, { value: id, children: jsx(NodeComponent, { id: id, data: node.data, type: nodeType, positionAbsoluteX: internals.positionAbsolute.x, positionAbsoluteY: internals.positionAbsolute.y, selected: node.selected ?? false, selectable: isSelectable, draggable: isDraggable, deletable: node.deletable ?? true, isConnectable: isConnectable, sourcePosition: node.sourcePosition, targetPosition: node.targetPosition, dragging: dragging, dragHandle: node.dragHandle, zIndex: internals.z, parentId: node.parentId, ...nodeDimensions }) }) }));
|
|
2220
2235
|
}
|
|
2236
|
+
var NodeWrapper$1 = memo(NodeWrapper);
|
|
2221
2237
|
|
|
2222
2238
|
const selector$b = (s) => ({
|
|
2223
2239
|
nodesDraggable: s.nodesDraggable,
|
|
@@ -2257,7 +2273,7 @@ function NodeRendererComponent(props) {
|
|
|
2257
2273
|
* memorized – so if `NodeRenderer` *has* to rerender, it only
|
|
2258
2274
|
* needs to regenerate the list of nodes, nothing else.
|
|
2259
2275
|
*/
|
|
2260
|
-
jsx(NodeWrapper, { id: nodeId, nodeTypes: props.nodeTypes, nodeExtent: props.nodeExtent, onClick: props.onNodeClick, onMouseEnter: props.onNodeMouseEnter, onMouseMove: props.onNodeMouseMove, onMouseLeave: props.onNodeMouseLeave, onContextMenu: props.onNodeContextMenu, onDoubleClick: props.onNodeDoubleClick, noDragClassName: props.noDragClassName, noPanClassName: props.noPanClassName, rfId: props.rfId, disableKeyboardA11y: props.disableKeyboardA11y, resizeObserver: resizeObserver, nodesDraggable: nodesDraggable, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, elementsSelectable: elementsSelectable, nodeClickDistance: props.nodeClickDistance, onError: onError }, nodeId));
|
|
2276
|
+
jsx(NodeWrapper$1, { id: nodeId, nodeTypes: props.nodeTypes, nodeExtent: props.nodeExtent, onClick: props.onNodeClick, onMouseEnter: props.onNodeMouseEnter, onMouseMove: props.onNodeMouseMove, onMouseLeave: props.onNodeMouseLeave, onContextMenu: props.onNodeContextMenu, onDoubleClick: props.onNodeDoubleClick, noDragClassName: props.noDragClassName, noPanClassName: props.noPanClassName, rfId: props.rfId, disableKeyboardA11y: props.disableKeyboardA11y, resizeObserver: resizeObserver, nodesDraggable: nodesDraggable, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, elementsSelectable: elementsSelectable, nodeClickDistance: props.nodeClickDistance, onError: onError }, nodeId));
|
|
2261
2277
|
}) }));
|
|
2262
2278
|
}
|
|
2263
2279
|
NodeRendererComponent.displayName = 'NodeRenderer';
|
|
@@ -2896,6 +2912,7 @@ function EdgeWrapper({ id, edgesFocusable, edgesReconnectable, elementsSelectabl
|
|
|
2896
2912
|
},
|
|
2897
2913
|
]), onClick: onEdgeClick, onDoubleClick: onEdgeDoubleClick, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onKeyDown: isFocusable ? onKeyDown : undefined, tabIndex: isFocusable ? 0 : undefined, role: edge.ariaRole ?? (isFocusable ? 'group' : 'img'), "aria-roledescription": "edge", "data-id": id, "data-testid": `rf__edge-${id}`, "aria-label": edge.ariaLabel === null ? undefined : edge.ariaLabel || `Edge from ${edge.source} to ${edge.target}`, "aria-describedby": isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined, ref: edgeRef, ...edge.domAttributes, children: [!reconnecting && (jsx(EdgeComponent, { id: id, source: edge.source, target: edge.target, type: edge.type, selected: edge.selected, animated: edge.animated, selectable: isSelectable, deletable: edge.deletable ?? true, label: edge.label, labelStyle: edge.labelStyle, labelShowBg: edge.labelShowBg, labelBgStyle: edge.labelBgStyle, labelBgPadding: edge.labelBgPadding, labelBgBorderRadius: edge.labelBgBorderRadius, sourceX: sourceX, sourceY: sourceY, targetX: targetX, targetY: targetY, sourcePosition: sourcePosition, targetPosition: targetPosition, data: edge.data, style: edge.style, sourceHandleId: edge.sourceHandle, targetHandleId: edge.targetHandle, markerStart: markerStartUrl, markerEnd: markerEndUrl, pathOptions: 'pathOptions' in edge ? edge.pathOptions : undefined, interactionWidth: edge.interactionWidth })), isReconnectable && (jsx(EdgeUpdateAnchors, { edge: edge, isReconnectable: isReconnectable, reconnectRadius: reconnectRadius, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, sourceX: sourceX, sourceY: sourceY, targetX: targetX, targetY: targetY, sourcePosition: sourcePosition, targetPosition: targetPosition, setUpdateHover: setUpdateHover, setReconnecting: setReconnecting }))] }) }));
|
|
2898
2914
|
}
|
|
2915
|
+
var EdgeWrapper$1 = memo(EdgeWrapper);
|
|
2899
2916
|
|
|
2900
2917
|
const selector$a = (s) => ({
|
|
2901
2918
|
edgesFocusable: s.edgesFocusable,
|
|
@@ -2908,7 +2925,7 @@ function EdgeRendererComponent({ defaultMarkerColor, onlyRenderVisibleElements,
|
|
|
2908
2925
|
const { edgesFocusable, edgesReconnectable, elementsSelectable, onError } = useStore(selector$a, shallow);
|
|
2909
2926
|
const edgeIds = useVisibleEdgeIds(onlyRenderVisibleElements);
|
|
2910
2927
|
return (jsxs("div", { className: "react-flow__edges", children: [jsx(MarkerDefinitions$1, { defaultColor: defaultMarkerColor, rfId: rfId }), edgeIds.map((id) => {
|
|
2911
|
-
return (jsx(EdgeWrapper, { id: id, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, noPanClassName: noPanClassName, onReconnect: onReconnect, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onClick: onEdgeClick, reconnectRadius: reconnectRadius, onDoubleClick: onEdgeDoubleClick, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, rfId: rfId, onError: onError, edgeTypes: edgeTypes, disableKeyboardA11y: disableKeyboardA11y }, id));
|
|
2928
|
+
return (jsx(EdgeWrapper$1, { id: id, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, noPanClassName: noPanClassName, onReconnect: onReconnect, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onClick: onEdgeClick, reconnectRadius: reconnectRadius, onDoubleClick: onEdgeDoubleClick, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, rfId: rfId, onError: onError, edgeTypes: edgeTypes, disableKeyboardA11y: disableKeyboardA11y }, id));
|
|
2912
2929
|
})] }));
|
|
2913
2930
|
}
|
|
2914
2931
|
EdgeRendererComponent.displayName = 'EdgeRenderer';
|
|
@@ -4843,4 +4860,48 @@ function NodeToolbar({ nodeId, children, className, style, isVisible, position =
|
|
|
4843
4860
|
return (jsx(NodeToolbarPortal, { children: jsx("div", { style: wrapperStyle, className: cc(['react-flow__node-toolbar', className]), ...rest, "data-id": nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim(), children: children }) }));
|
|
4844
4861
|
}
|
|
4845
4862
|
|
|
4846
|
-
|
|
4863
|
+
const zoomSelector = (state) => state.transform[2];
|
|
4864
|
+
/**
|
|
4865
|
+
* This component can render a toolbar or tooltip to one side of a custom edge. This
|
|
4866
|
+
* toolbar doesn't scale with the viewport so that the content stays the same size.
|
|
4867
|
+
*
|
|
4868
|
+
* @public
|
|
4869
|
+
* @example
|
|
4870
|
+
* ```jsx
|
|
4871
|
+
* import { EdgeToolbar, BaseEdge, getBezierPath, type EdgeProps } from "@xyflow/react";
|
|
4872
|
+
*
|
|
4873
|
+
* export function CustomEdge({ id, data, ...props }: EdgeProps) {
|
|
4874
|
+
* const [edgePath, centerX, centerY] = getBezierPath(props);
|
|
4875
|
+
*
|
|
4876
|
+
* return (
|
|
4877
|
+
* <>
|
|
4878
|
+
* <BaseEdge id={id} path={edgePath} />
|
|
4879
|
+
* <EdgeToolbar edgeId={id} x={centerX} y={centerY} isVisible>
|
|
4880
|
+
* <button onClick={() => console.log('edge', id, 'click')}}>Click me</button>
|
|
4881
|
+
* </EdgeToolbar>
|
|
4882
|
+
* </>
|
|
4883
|
+
* );
|
|
4884
|
+
* }
|
|
4885
|
+
* ```
|
|
4886
|
+
*/
|
|
4887
|
+
function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alignX = 'center', alignY = 'center', ...rest }) {
|
|
4888
|
+
const edgeSelector = useCallback((state) => state.edgeLookup.get(edgeId), [edgeId]);
|
|
4889
|
+
const edge = useStore(edgeSelector, shallow);
|
|
4890
|
+
const isActive = typeof isVisible === 'boolean' ? isVisible : edge?.selected;
|
|
4891
|
+
const zoom = useStore(zoomSelector);
|
|
4892
|
+
if (!isActive) {
|
|
4893
|
+
return null;
|
|
4894
|
+
}
|
|
4895
|
+
const zIndex = (edge?.zIndex ?? 0) + 1;
|
|
4896
|
+
const transform = getEdgeToolbarTransform(x, y, zoom, alignX, alignY);
|
|
4897
|
+
return (jsx(EdgeLabelRenderer, { children: jsx("div", { style: {
|
|
4898
|
+
position: 'absolute',
|
|
4899
|
+
transform,
|
|
4900
|
+
zIndex,
|
|
4901
|
+
pointerEvents: 'all',
|
|
4902
|
+
transformOrigin: '0 0',
|
|
4903
|
+
...style,
|
|
4904
|
+
}, className: cc(['react-flow__edge-toolbar', className]), "data-id": edge?.id ?? '', ...rest, children: children }) }));
|
|
4905
|
+
}
|
|
4906
|
+
|
|
4907
|
+
export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, EdgeToolbar, Handle, MiniMap, MiniMapNode, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
|
|
4
4
|
import cc from 'classcat';
|
|
5
|
-
import { errorMessages, mergeAriaLabelConfig, infiniteExtent, isInputDOMNode, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, withResolvers, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, initialConnection, devWarn, defaultAriaLabelConfig, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
|
|
5
|
+
import { errorMessages, mergeAriaLabelConfig, infiniteExtent, isInputDOMNode, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, withResolvers, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, initialConnection, devWarn, defaultAriaLabelConfig, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform, getEdgeToolbarTransform } from '@xyflow/system';
|
|
6
6
|
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
|
|
7
7
|
import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
|
|
8
8
|
import { shallow } from 'zustand/shallow';
|
|
@@ -1432,16 +1432,31 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1432
1432
|
onPaneContextMenu?.(event);
|
|
1433
1433
|
};
|
|
1434
1434
|
const onWheel = onPaneScroll ? (event) => onPaneScroll(event) : undefined;
|
|
1435
|
-
const
|
|
1435
|
+
const onClickCapture = (event) => {
|
|
1436
|
+
const isSelectionOnDragActive = (selectionOnDrag && container.current === event.target) || !selectionOnDrag || selectionKeyPressed;
|
|
1437
|
+
if (!isSelectionOnDragActive) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
event.stopPropagation();
|
|
1441
|
+
};
|
|
1442
|
+
// We are using capture here in order to prevent other pointer events
|
|
1443
|
+
// to be able to create a selection above a node or an edge
|
|
1444
|
+
const onPointerDownCapture = (event) => {
|
|
1436
1445
|
const { resetSelectedElements, domNode } = store.getState();
|
|
1437
1446
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
1447
|
+
const isNoKeyEvent = event.target !== container.current && !!event.target.closest('.nokey');
|
|
1448
|
+
const isSelectionActive = (selectionOnDrag && container.current === event.target) || !selectionOnDrag || selectionKeyPressed;
|
|
1438
1449
|
if (!elementsSelectable ||
|
|
1439
1450
|
!isSelecting ||
|
|
1440
1451
|
event.button !== 0 ||
|
|
1441
|
-
|
|
1442
|
-
|
|
1452
|
+
!containerBounds.current ||
|
|
1453
|
+
isNoKeyEvent ||
|
|
1454
|
+
!isSelectionActive ||
|
|
1455
|
+
!event.isPrimary) {
|
|
1443
1456
|
return;
|
|
1444
1457
|
}
|
|
1458
|
+
event.stopPropagation();
|
|
1459
|
+
event.preventDefault();
|
|
1445
1460
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
1446
1461
|
selectionStarted.current = true;
|
|
1447
1462
|
selectionInProgress.current = false;
|
|
@@ -1535,7 +1550,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1535
1550
|
selectionStarted.current = false;
|
|
1536
1551
|
};
|
|
1537
1552
|
const draggable = panOnDrag === true || (Array.isArray(panOnDrag) && panOnDrag.includes(0));
|
|
1538
|
-
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: hasActiveSelection ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: hasActiveSelection ? undefined : onPaneMouseEnter,
|
|
1553
|
+
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: hasActiveSelection ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: hasActiveSelection ? undefined : onPaneMouseEnter, onPointerMove: hasActiveSelection ? onPointerMove : onPaneMouseMove, onPointerUp: hasActiveSelection ? onPointerUp : undefined, onPointerDownCapture: hasActiveSelection ? onPointerDownCapture : undefined, onClickCapture: hasActiveSelection ? onClickCapture : undefined, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children, jsx(UserSelection, {})] }));
|
|
1539
1554
|
}
|
|
1540
1555
|
|
|
1541
1556
|
/*
|
|
@@ -2218,6 +2233,7 @@ function NodeWrapper({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onC
|
|
|
2218
2233
|
...inlineDimensions,
|
|
2219
2234
|
}, "data-id": id, "data-testid": `rf__node-${id}`, onMouseEnter: onMouseEnterHandler, onMouseMove: onMouseMoveHandler, onMouseLeave: onMouseLeaveHandler, onContextMenu: onContextMenuHandler, onClick: onSelectNodeHandler, onDoubleClick: onDoubleClickHandler, onKeyDown: isFocusable ? onKeyDown : undefined, tabIndex: isFocusable ? 0 : undefined, onFocus: isFocusable ? onFocus : undefined, role: node.ariaRole ?? (isFocusable ? 'group' : undefined), "aria-roledescription": "node", "aria-describedby": disableKeyboardA11y ? undefined : `${ARIA_NODE_DESC_KEY}-${rfId}`, "aria-label": node.ariaLabel, ...node.domAttributes, children: jsx(Provider, { value: id, children: jsx(NodeComponent, { id: id, data: node.data, type: nodeType, positionAbsoluteX: internals.positionAbsolute.x, positionAbsoluteY: internals.positionAbsolute.y, selected: node.selected ?? false, selectable: isSelectable, draggable: isDraggable, deletable: node.deletable ?? true, isConnectable: isConnectable, sourcePosition: node.sourcePosition, targetPosition: node.targetPosition, dragging: dragging, dragHandle: node.dragHandle, zIndex: internals.z, parentId: node.parentId, ...nodeDimensions }) }) }));
|
|
2220
2235
|
}
|
|
2236
|
+
var NodeWrapper$1 = memo(NodeWrapper);
|
|
2221
2237
|
|
|
2222
2238
|
const selector$b = (s) => ({
|
|
2223
2239
|
nodesDraggable: s.nodesDraggable,
|
|
@@ -2257,7 +2273,7 @@ function NodeRendererComponent(props) {
|
|
|
2257
2273
|
* memorized – so if `NodeRenderer` *has* to rerender, it only
|
|
2258
2274
|
* needs to regenerate the list of nodes, nothing else.
|
|
2259
2275
|
*/
|
|
2260
|
-
jsx(NodeWrapper, { id: nodeId, nodeTypes: props.nodeTypes, nodeExtent: props.nodeExtent, onClick: props.onNodeClick, onMouseEnter: props.onNodeMouseEnter, onMouseMove: props.onNodeMouseMove, onMouseLeave: props.onNodeMouseLeave, onContextMenu: props.onNodeContextMenu, onDoubleClick: props.onNodeDoubleClick, noDragClassName: props.noDragClassName, noPanClassName: props.noPanClassName, rfId: props.rfId, disableKeyboardA11y: props.disableKeyboardA11y, resizeObserver: resizeObserver, nodesDraggable: nodesDraggable, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, elementsSelectable: elementsSelectable, nodeClickDistance: props.nodeClickDistance, onError: onError }, nodeId));
|
|
2276
|
+
jsx(NodeWrapper$1, { id: nodeId, nodeTypes: props.nodeTypes, nodeExtent: props.nodeExtent, onClick: props.onNodeClick, onMouseEnter: props.onNodeMouseEnter, onMouseMove: props.onNodeMouseMove, onMouseLeave: props.onNodeMouseLeave, onContextMenu: props.onNodeContextMenu, onDoubleClick: props.onNodeDoubleClick, noDragClassName: props.noDragClassName, noPanClassName: props.noPanClassName, rfId: props.rfId, disableKeyboardA11y: props.disableKeyboardA11y, resizeObserver: resizeObserver, nodesDraggable: nodesDraggable, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, elementsSelectable: elementsSelectable, nodeClickDistance: props.nodeClickDistance, onError: onError }, nodeId));
|
|
2261
2277
|
}) }));
|
|
2262
2278
|
}
|
|
2263
2279
|
NodeRendererComponent.displayName = 'NodeRenderer';
|
|
@@ -2896,6 +2912,7 @@ function EdgeWrapper({ id, edgesFocusable, edgesReconnectable, elementsSelectabl
|
|
|
2896
2912
|
},
|
|
2897
2913
|
]), onClick: onEdgeClick, onDoubleClick: onEdgeDoubleClick, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onKeyDown: isFocusable ? onKeyDown : undefined, tabIndex: isFocusable ? 0 : undefined, role: edge.ariaRole ?? (isFocusable ? 'group' : 'img'), "aria-roledescription": "edge", "data-id": id, "data-testid": `rf__edge-${id}`, "aria-label": edge.ariaLabel === null ? undefined : edge.ariaLabel || `Edge from ${edge.source} to ${edge.target}`, "aria-describedby": isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined, ref: edgeRef, ...edge.domAttributes, children: [!reconnecting && (jsx(EdgeComponent, { id: id, source: edge.source, target: edge.target, type: edge.type, selected: edge.selected, animated: edge.animated, selectable: isSelectable, deletable: edge.deletable ?? true, label: edge.label, labelStyle: edge.labelStyle, labelShowBg: edge.labelShowBg, labelBgStyle: edge.labelBgStyle, labelBgPadding: edge.labelBgPadding, labelBgBorderRadius: edge.labelBgBorderRadius, sourceX: sourceX, sourceY: sourceY, targetX: targetX, targetY: targetY, sourcePosition: sourcePosition, targetPosition: targetPosition, data: edge.data, style: edge.style, sourceHandleId: edge.sourceHandle, targetHandleId: edge.targetHandle, markerStart: markerStartUrl, markerEnd: markerEndUrl, pathOptions: 'pathOptions' in edge ? edge.pathOptions : undefined, interactionWidth: edge.interactionWidth })), isReconnectable && (jsx(EdgeUpdateAnchors, { edge: edge, isReconnectable: isReconnectable, reconnectRadius: reconnectRadius, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, sourceX: sourceX, sourceY: sourceY, targetX: targetX, targetY: targetY, sourcePosition: sourcePosition, targetPosition: targetPosition, setUpdateHover: setUpdateHover, setReconnecting: setReconnecting }))] }) }));
|
|
2898
2914
|
}
|
|
2915
|
+
var EdgeWrapper$1 = memo(EdgeWrapper);
|
|
2899
2916
|
|
|
2900
2917
|
const selector$a = (s) => ({
|
|
2901
2918
|
edgesFocusable: s.edgesFocusable,
|
|
@@ -2908,7 +2925,7 @@ function EdgeRendererComponent({ defaultMarkerColor, onlyRenderVisibleElements,
|
|
|
2908
2925
|
const { edgesFocusable, edgesReconnectable, elementsSelectable, onError } = useStore(selector$a, shallow);
|
|
2909
2926
|
const edgeIds = useVisibleEdgeIds(onlyRenderVisibleElements);
|
|
2910
2927
|
return (jsxs("div", { className: "react-flow__edges", children: [jsx(MarkerDefinitions$1, { defaultColor: defaultMarkerColor, rfId: rfId }), edgeIds.map((id) => {
|
|
2911
|
-
return (jsx(EdgeWrapper, { id: id, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, noPanClassName: noPanClassName, onReconnect: onReconnect, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onClick: onEdgeClick, reconnectRadius: reconnectRadius, onDoubleClick: onEdgeDoubleClick, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, rfId: rfId, onError: onError, edgeTypes: edgeTypes, disableKeyboardA11y: disableKeyboardA11y }, id));
|
|
2928
|
+
return (jsx(EdgeWrapper$1, { id: id, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, noPanClassName: noPanClassName, onReconnect: onReconnect, onContextMenu: onEdgeContextMenu, onMouseEnter: onEdgeMouseEnter, onMouseMove: onEdgeMouseMove, onMouseLeave: onEdgeMouseLeave, onClick: onEdgeClick, reconnectRadius: reconnectRadius, onDoubleClick: onEdgeDoubleClick, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, rfId: rfId, onError: onError, edgeTypes: edgeTypes, disableKeyboardA11y: disableKeyboardA11y }, id));
|
|
2912
2929
|
})] }));
|
|
2913
2930
|
}
|
|
2914
2931
|
EdgeRendererComponent.displayName = 'EdgeRenderer';
|
|
@@ -4843,4 +4860,48 @@ function NodeToolbar({ nodeId, children, className, style, isVisible, position =
|
|
|
4843
4860
|
return (jsx(NodeToolbarPortal, { children: jsx("div", { style: wrapperStyle, className: cc(['react-flow__node-toolbar', className]), ...rest, "data-id": nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim(), children: children }) }));
|
|
4844
4861
|
}
|
|
4845
4862
|
|
|
4846
|
-
|
|
4863
|
+
const zoomSelector = (state) => state.transform[2];
|
|
4864
|
+
/**
|
|
4865
|
+
* This component can render a toolbar or tooltip to one side of a custom edge. This
|
|
4866
|
+
* toolbar doesn't scale with the viewport so that the content stays the same size.
|
|
4867
|
+
*
|
|
4868
|
+
* @public
|
|
4869
|
+
* @example
|
|
4870
|
+
* ```jsx
|
|
4871
|
+
* import { EdgeToolbar, BaseEdge, getBezierPath, type EdgeProps } from "@xyflow/react";
|
|
4872
|
+
*
|
|
4873
|
+
* export function CustomEdge({ id, data, ...props }: EdgeProps) {
|
|
4874
|
+
* const [edgePath, centerX, centerY] = getBezierPath(props);
|
|
4875
|
+
*
|
|
4876
|
+
* return (
|
|
4877
|
+
* <>
|
|
4878
|
+
* <BaseEdge id={id} path={edgePath} />
|
|
4879
|
+
* <EdgeToolbar edgeId={id} x={centerX} y={centerY} isVisible>
|
|
4880
|
+
* <button onClick={() => console.log('edge', id, 'click')}}>Click me</button>
|
|
4881
|
+
* </EdgeToolbar>
|
|
4882
|
+
* </>
|
|
4883
|
+
* );
|
|
4884
|
+
* }
|
|
4885
|
+
* ```
|
|
4886
|
+
*/
|
|
4887
|
+
function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alignX = 'center', alignY = 'center', ...rest }) {
|
|
4888
|
+
const edgeSelector = useCallback((state) => state.edgeLookup.get(edgeId), [edgeId]);
|
|
4889
|
+
const edge = useStore(edgeSelector, shallow);
|
|
4890
|
+
const isActive = typeof isVisible === 'boolean' ? isVisible : edge?.selected;
|
|
4891
|
+
const zoom = useStore(zoomSelector);
|
|
4892
|
+
if (!isActive) {
|
|
4893
|
+
return null;
|
|
4894
|
+
}
|
|
4895
|
+
const zIndex = (edge?.zIndex ?? 0) + 1;
|
|
4896
|
+
const transform = getEdgeToolbarTransform(x, y, zoom, alignX, alignY);
|
|
4897
|
+
return (jsx(EdgeLabelRenderer, { children: jsx("div", { style: {
|
|
4898
|
+
position: 'absolute',
|
|
4899
|
+
transform,
|
|
4900
|
+
zIndex,
|
|
4901
|
+
pointerEvents: 'all',
|
|
4902
|
+
transformOrigin: '0 0',
|
|
4903
|
+
...style,
|
|
4904
|
+
}, className: cc(['react-flow__edge-toolbar', className]), "data-id": edge?.id ?? '', ...rest, children: children }) }));
|
|
4905
|
+
}
|
|
4906
|
+
|
|
4907
|
+
export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, EdgeToolbar, Handle, MiniMap, MiniMapNode, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
|
|
@@ -95,7 +95,7 @@ export type EdgeTextProps = Omit<SVGAttributes<SVGElement>, 'x' | 'y'> & EdgeLab
|
|
|
95
95
|
* @public
|
|
96
96
|
* @expand
|
|
97
97
|
*/
|
|
98
|
-
export type EdgeProps<EdgeType extends Edge = Edge> = Pick<EdgeType, 'id' | 'animated' | 'data' | 'style' | 'selected' | 'source' | 'target' | 'selectable' | 'deletable'> & EdgePosition & EdgeLabelOptions & {
|
|
98
|
+
export type EdgeProps<EdgeType extends Edge = Edge> = Pick<EdgeType, 'id' | 'type' | 'animated' | 'data' | 'style' | 'selected' | 'source' | 'target' | 'selectable' | 'deletable'> & EdgePosition & EdgeLabelOptions & {
|
|
99
99
|
sourceHandleId?: string | null;
|
|
100
100
|
targetHandleId?: string | null;
|
|
101
101
|
markerStart?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/types/edges.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,IAAI,eAAe,EAC7B,aAAa,EACb,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,YAAY,EACZ,eAAe,EACf,OAAO,EACP,WAAW,EACX,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;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,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,QAAQ,CAAC;IACvB,UAAU,EAAE,QAAQ,CAAC;IACrB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IAC7C,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI,aAAa,CAC/E,4BAA4B,CAAC,QAAQ,CAAC,CACvC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EdgeToolbarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* This component can render a toolbar or tooltip to one side of a custom edge. This
|
|
4
|
+
* toolbar doesn't scale with the viewport so that the content stays the same size.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* import { EdgeToolbar, BaseEdge, getBezierPath, type EdgeProps } from "@xyflow/react";
|
|
10
|
+
*
|
|
11
|
+
* export function CustomEdge({ id, data, ...props }: EdgeProps) {
|
|
12
|
+
* const [edgePath, centerX, centerY] = getBezierPath(props);
|
|
13
|
+
*
|
|
14
|
+
* return (
|
|
15
|
+
* <>
|
|
16
|
+
* <BaseEdge id={id} path={edgePath} />
|
|
17
|
+
* <EdgeToolbar edgeId={id} x={centerX} y={centerY} isVisible>
|
|
18
|
+
* <button onClick={() => console.log('edge', id, 'click')}}>Click me</button>
|
|
19
|
+
* </EdgeToolbar>
|
|
20
|
+
* </>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alignX, alignY, ...rest }: EdgeToolbarProps): import("react/jsx-runtime").JSX.Element | null;
|
|
26
|
+
//# sourceMappingURL=EdgeToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeToolbar.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/EdgeToolbar.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,CAAC,EACD,CAAC,EACD,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,MAAiB,EACjB,MAAiB,EACjB,GAAG,IAAI,EACR,EAAE,gBAAgB,kDAgClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { EdgeToolbarBaseProps } from '@xyflow/system';
|
|
3
|
+
/**
|
|
4
|
+
* @inline
|
|
5
|
+
*/
|
|
6
|
+
export type EdgeToolbarProps = EdgeToolbarBaseProps & HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/additional-components/EdgeToolbar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GACjD,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/additional-components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/additional-components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import type { Edge, EdgeWrapperProps } from '../../types';
|
|
3
|
-
|
|
3
|
+
declare function EdgeWrapper<EdgeType extends Edge = Edge>({ id, edgesFocusable, edgesReconnectable, elementsSelectable, onClick, onDoubleClick, onContextMenu, onMouseEnter, onMouseMove, onMouseLeave, reconnectRadius, onReconnect, onReconnectStart, onReconnectEnd, rfId, edgeTypes, noPanClassName, onError, disableKeyboardA11y, }: EdgeWrapperProps<EdgeType>): JSX.Element | null;
|
|
4
|
+
declare const _default: typeof EdgeWrapper;
|
|
5
|
+
export default _default;
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8D,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8D,GAAG,EAAQ,MAAM,OAAO,CAAC;AAe9F,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,iBAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,EACjD,EAAE,EACF,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,IAAI,EACJ,SAAS,EACT,cAAc,EACd,OAAO,EACP,mBAAmB,GACpB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmOjD;wBAEmC,OAAO,WAAW;AAAtD,wBAAuD"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Node, NodeWrapperProps } from '../../types';
|
|
2
|
-
|
|
2
|
+
declare function NodeWrapper<NodeType extends Node>({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onContextMenu, onDoubleClick, nodesDraggable, elementsSelectable, nodesConnectable, nodesFocusable, resizeObserver, noDragClassName, noPanClassName, disableKeyboardA11y, rfId, nodeTypes, nodeClickDistance, onError, }: NodeWrapperProps<NodeType>): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
declare const _default: typeof NodeWrapper;
|
|
4
|
+
export default _default;
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,iBAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,EAAE,EAC1C,EAAE,EACF,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,OAAO,GACR,EAAE,gBAAgB,CAAC,QAAQ,CAAC,kDAgN5B;wBAEmC,OAAO,WAAW;AAAtD,wBAAuD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgBf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAqBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAgOX"}
|