Initial commit with Advoware proxy

This commit is contained in:
root
2025-10-19 14:57:07 +00:00
commit 273aa8b549
45771 changed files with 5534555 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2024 webkid GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,62 @@
# @xyflow/system
Core system utilities powering [React Flow](https://reactflow.dev) and [Svelte Flow](https://svelteflow.dev).
> **Note:** This package is designed as a shared vanilla utility layer for React Flow and Svelte Flow. It is not intended for use with unrelated libraries.
## Installation
```sh
pnpm add @xyflow/system
```
## What is this package?
`@xyflow/system` provides core, framework-agnostic helpers and types for building node-based editors and flow diagrams. It contains the logic and utilities that are shared between React Flow and Svelte Flow, such as edge path calculations, pan/zoom, node dragging, and more.
## Features
- **Pan & Zoom (`XYPanZoom`)**: Utilities for adding interactive pan and zoom to your canvas.
- **Dragging (`XYDrag`)**: Helpers for node and selection dragging.
- **Handles/Connections (`XYHandle`)**: Logic for drawing and managing connection lines between nodes.
- **Minimap (`XYMiniMap`)**: Interactive minimap utilities for overview and navigation.
- **Edge Utilities**: Functions for SVG edge path creation (bezier, straight, step, smoothstep, etc.).
- **Store Utilities**: Helpers for managing and updating flow state.
- **DOM Utilities**: Functions for DOM measurements and interactions.
- **Marker Utilities**: Helpers for SVG markers on edges.
- **Graph Utilities**: Functions for working with nodes, edges, and graph structure.
- **General Utilities**: Miscellaneous helpers used throughout the system.
- **Types & Constants**: Shared types, enums, and constants for consistent data structures.
## Usage
You can import any utility, type, or helper directly from the package:
```ts
import { getBezierPath, getConnectedEdges, Position, XYPanZoom } from '@xyflow/system';
```
### Example: Bezier Edge Path Creation
```ts
import { getBezierPath, Position } from '@xyflow/system';
const [path, labelX, labelY] = getBezierPath({
sourceX: 0,
sourceY: 20,
sourcePosition: Position.Right,
targetX: 150,
targetY: 100,
targetPosition: Position.Left,
});
```
## API Reference
There is currently no dedicated API documentation for this package. For details on available utilities, types, and helpers, please refer to the [source code](./src) or check out the [React Flow documentation](https://reactflow.dev/api-reference/) where we are documenting a lot of stuff from this package.
## Contributing
See the main [xyflow repository](https://github.com/xyflow/xyflow) for contribution guidelines.

View File

@@ -0,0 +1,43 @@
import { CoordinateExtent, HandleType } from './types';
export declare const errorMessages: {
error001: () => string;
error002: () => string;
error003: (nodeType: string) => string;
error004: () => string;
error005: () => string;
error006: () => string;
error007: (id: string) => string;
error009: (type: string) => string;
error008: (handleType: HandleType, { id, sourceHandle, targetHandle }: {
id: string;
sourceHandle: string | null;
targetHandle: string | null;
}) => string;
error010: () => string;
error011: (edgeType: string) => string;
error012: (id: string) => string;
error013: (lib?: string) => string;
error014: () => string;
error015: () => string;
};
export declare const infiniteExtent: CoordinateExtent;
export declare const elementSelectionKeys: string[];
export declare const defaultAriaLabelConfig: {
'node.a11yDescription.default': string;
'node.a11yDescription.keyboardDisabled': string;
'node.a11yDescription.ariaLiveMessage': ({ direction, x, y }: {
direction: string;
x: number;
y: number;
}) => string;
'edge.a11yDescription.default': string;
'controls.ariaLabel': string;
'controls.zoomIn.ariaLabel': string;
'controls.zoomOut.ariaLabel': string;
'controls.fitView.ariaLabel': string;
'controls.interactive.ariaLabel': string;
'minimap.ariaLabel': string;
'handle.ariaLabel': string;
};
export type AriaLabelConfig = typeof defaultAriaLabelConfig;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,aAAa;;;yBAKH,MAAM;;;;mBAIZ,MAAM;qBACJ,MAAM;2BAET,UAAU,sCACc;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;yBAMzF,MAAM;mBACZ,MAAM;qBAEL,MAAM;;;CAMvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAA2B,CAAC;AAE7D,eAAO,MAAM,sBAAsB;;;kEAK6B;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;CAiB1G,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,sBAAsB,CAAC"}

View File

@@ -0,0 +1,9 @@
export * from './constants';
export * from './types';
export * from './utils';
export * from './xydrag';
export * from './xyhandle';
export * from './xyminimap';
export * from './xypanzoom';
export * from './xyresizer';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
import type { XYPosition, Dimensions, NodeBase, EdgeBase } from '.';
export type NodeDimensionChange = {
id: string;
type: 'dimensions';
dimensions?: Dimensions;
resizing?: boolean;
setAttributes?: boolean | 'width' | 'height';
};
export type NodePositionChange = {
id: string;
type: 'position';
position?: XYPosition;
positionAbsolute?: XYPosition;
dragging?: boolean;
};
export type NodeSelectionChange = {
id: string;
type: 'select';
selected: boolean;
};
export type NodeRemoveChange = {
id: string;
type: 'remove';
};
export type NodeAddChange<NodeType extends NodeBase = NodeBase> = {
item: NodeType;
type: 'add';
index?: number;
};
export type NodeReplaceChange<NodeType extends NodeBase = NodeBase> = {
id: string;
item: NodeType;
type: 'replace';
};
/**
* The [`onNodesChange`](/api-reference/react-flow#on-nodes-change) callback takes
*an array of `NodeChange` objects that you should use to update your flow's state.
*The `NodeChange` type is a union of six different object types that represent that
*various ways an node can change in a flow.
* @public
*/
export type NodeChange<NodeType extends NodeBase = NodeBase> = NodeDimensionChange | NodePositionChange | NodeSelectionChange | NodeRemoveChange | NodeAddChange<NodeType> | NodeReplaceChange<NodeType>;
export type EdgeSelectionChange = NodeSelectionChange;
export type EdgeRemoveChange = NodeRemoveChange;
export type EdgeAddChange<EdgeType extends EdgeBase = EdgeBase> = {
item: EdgeType;
type: 'add';
index?: number;
};
export type EdgeReplaceChange<EdgeType extends EdgeBase = EdgeBase> = {
id: string;
item: EdgeType;
type: 'replace';
};
/**
* The [`onEdgesChange`](/api-reference/react-flow#on-edges-change) callback takes
*an array of `EdgeChange` objects that you should use to update your flow's state.
*The `EdgeChange` type is a union of four different object types that represent that
*various ways an edge can change in a flow.
*
* @public
*/
export type EdgeChange<EdgeType extends EdgeBase = EdgeBase> = EdgeSelectionChange | EdgeRemoveChange | EdgeAddChange<EdgeType> | EdgeReplaceChange<EdgeType>;
//# sourceMappingURL=changes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jB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IACvD,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,aAAa,CAAC,QAAQ,CAAC,GACvB,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEhC,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI;IAChE,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IACvD,mBAAmB,GACnB,gBAAgB,GAChB,aAAa,CAAC,QAAQ,CAAC,GACvB,iBAAiB,CAAC,QAAQ,CAAC,CAAC"}

View File

@@ -0,0 +1,114 @@
import { Position } from './utils';
export type EdgeBase<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = {
/** Unique id of an edge. */
id: string;
/** Type of edge defined in `edgeTypes`. */
type?: EdgeType;
/** Id of source node. */
source: string;
/** Id of target node. */
target: string;
/** Id of source handle, only needed if there are multiple handles per node. */
sourceHandle?: string | null;
/** Id of target handle, only needed if there are multiple handles per node. */
targetHandle?: string | null;
animated?: boolean;
hidden?: boolean;
deletable?: boolean;
selectable?: boolean;
/** Arbitrary data passed to an edge. */
data?: EdgeData;
selected?: boolean;
/**
* Set the marker on the beginning of an edge.
* @example 'arrow', 'arrowclosed' or custom marker
*/
markerStart?: EdgeMarkerType;
/**
* Set the marker on the end of an edge.
* @example 'arrow', 'arrowclosed' or custom marker
*/
markerEnd?: EdgeMarkerType;
zIndex?: number;
ariaLabel?: string;
/**
* ReactFlow renders an invisible path around each edge to make them easier to click or tap on.
* This property sets the width of that invisible path.
*/
interactionWidth?: number;
};
export type SmoothStepPathOptions = {
offset?: number;
borderRadius?: number;
stepPosition?: number;
};
export type StepPathOptions = {
offset?: number;
};
export type BezierPathOptions = {
curvature?: number;
};
/**
* @inline
*/
export type DefaultEdgeOptionsBase<EdgeType extends EdgeBase> = Omit<EdgeType, 'id' | 'source' | 'target' | 'sourceHandle' | 'targetHandle' | 'selected'>;
/**
* If you set the `connectionLineType` prop on your [`<ReactFlow />`](/api-reference/react-flow#connection-connectionLineType)
*component, it will dictate the style of connection line rendered when creating
*new edges.
*
* @public
*
* @remarks If you choose to render a custom connection line component, this value will be
*passed to your component as part of its [`ConnectionLineComponentProps`](/api-reference/types/connection-line-component-props).
*/
export declare enum ConnectionLineType {
Bezier = "default",
Straight = "straight",
Step = "step",
SmoothStep = "smoothstep",
SimpleBezier = "simplebezier"
}
/**
* Edges can optionally have markers at the start and end of an edge. The `EdgeMarker`
*type is used to configure those markers! Check the docs for [`MarkerType`](/api-reference/types/marker-type)
*for details on what types of edge marker are available.
*
* @public
*/
export type EdgeMarker = {
type: MarkerType | `${MarkerType}`;
color?: string | null;
width?: number;
height?: number;
markerUnits?: string;
orient?: string;
strokeWidth?: number;
};
export type EdgeMarkerType = string | EdgeMarker;
/**
* Edges may optionally have a marker on either end. The MarkerType type enumerates
* the options available to you when configuring a given marker.
*
* @public
*/
export declare enum MarkerType {
Arrow = "arrow",
ArrowClosed = "arrowclosed"
}
export type MarkerProps = EdgeMarker & {
id: string;
};
/**
* @inline
*/
export type EdgePosition = {
sourceX: number;
sourceY: number;
targetX: number;
targetY: number;
sourcePosition: Position;
targetPosition: Position;
};
export type EdgeLookup<EdgeType extends EdgeBase = EdgeBase> = Map<string, EdgeType>;
//# sourceMappingURL=edges.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/types/edges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,MAAM,QAAQ,CAClB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IACtD;IACF,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG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AChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}

View File

@@ -0,0 +1,284 @@
import type { Selection as D3Selection } from 'd3-selection';
import type { D3DragEvent, SubjectPosition } from 'd3-drag';
import type { ZoomBehavior } from 'd3-zoom';
import type { XYPosition, Rect, Position } from './utils';
import type { InternalNodeBase, NodeBase, NodeDragItem } from './nodes';
import type { Handle, HandleType } from './handles';
import { PanZoomInstance } from './panzoom';
import { EdgeBase } from '..';
export type Project = (position: XYPosition) => XYPosition;
/**
* This type is used to define the `onMove` handler.
*/
export type OnMove = (event: MouseEvent | TouchEvent | null, viewport: Viewport) => void;
export type OnMoveStart = OnMove;
export type OnMoveEnd = OnMove;
/**
* @inline
*/
export type ZoomInOut = (options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* @inline
*/
export type ZoomTo = (zoomLevel: number, options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* @inline
*/
export type GetZoom = () => number;
/**
* @inline
*/
export type GetViewport = () => Viewport;
/**
* The `SetViewport` function is used to set the viewport of the flow.
*
* @inline
* @param viewport - The viewport to set.
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type SetViewport = (viewport: Viewport, options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* The `SetCenter` function is used to set the center of the flow viewport to a specific position
*
* @inline
* @param x - x coordinate
* @param y - y coordinate
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type SetCenter = (x: number, y: number, options?: SetCenterOptions) => Promise<boolean>;
/**
* The `FitBounds` function is used to fit the flow viewport to the bounds of the nodes.
*
* @inline
* @param bounds - The bounds to fit the viewport to.
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type FitBounds = (bounds: Rect, options?: FitBoundsOptions) => Promise<boolean>;
/**
* The `Connection` type is the basic minimal description of an [`Edge`](/api-reference/types/edge)
* between two nodes. The [`addEdge`](/api-reference/utils/add-edge) util can be used to upgrade
* a `Connection` to an [`Edge`](/api-reference/types/edge).
*
* @public
*/
export type Connection = {
/** The id of the node this connection originates from. */
source: string;
/** The id of the node this connection terminates at. */
target: string;
/** When not `null`, the id of the handle on the source node that this connection originates from. */
sourceHandle: string | null;
/** When not `null`, the id of the handle on the target node that this connection terminates at. */
targetHandle: string | null;
};
/**
* The `HandleConnection` type is an extension of a basic [Connection](/api-reference/types/connection) that includes the `edgeId`.
*/
export type HandleConnection = Connection & {
edgeId: string;
};
/**
* The `NodeConnection` type is an extension of a basic [Connection](/api-reference/types/connection) that includes the `edgeId`.
*
*/
export type NodeConnection = Connection & {
edgeId: string;
};
/**
* The `ConnectionMode` is used to set the mode of connection between nodes.
* The `Strict` mode is the default one and only allows source to target edges.
* `Loose` mode allows source to source and target to target edges as well.
*
* @public
*/
export declare enum ConnectionMode {
Strict = "strict",
Loose = "loose"
}
export type OnConnectStartParams = {
nodeId: string | null;
handleId: string | null;
handleType: HandleType | null;
};
export type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
export type OnConnect = (connection: Connection) => void;
export type OnConnectEnd = (event: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
export type OnReconnect<EdgeType extends EdgeBase = EdgeBase> = (oldEdge: EdgeType, newConnection: Connection) => void;
export type OnReconnectStart<EdgeType extends EdgeBase = EdgeBase> = (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType) => void;
export type OnReconnectEnd<EdgeType extends EdgeBase = EdgeBase> = (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType, connectionState: FinalConnectionState) => void;
export type IsValidConnection = (edge: EdgeBase | Connection) => boolean;
/**
* @inline
*/
export type FitViewParamsBase<NodeType extends NodeBase> = {
nodes: Map<string, InternalNodeBase<NodeType>>;
width: number;
height: number;
panZoom: PanZoomInstance;
minZoom: number;
maxZoom: number;
};
export type PaddingUnit = 'px' | '%';
export type PaddingWithUnit = `${number}${PaddingUnit}` | number;
export type Padding = PaddingWithUnit | {
top?: PaddingWithUnit;
right?: PaddingWithUnit;
bottom?: PaddingWithUnit;
left?: PaddingWithUnit;
x?: PaddingWithUnit;
y?: PaddingWithUnit;
};
/**
* @inline
*/
export type FitViewOptionsBase<NodeType extends NodeBase = NodeBase> = {
padding?: Padding;
includeHiddenNodes?: boolean;
minZoom?: number;
maxZoom?: number;
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
nodes?: (NodeType | {
id: string;
})[];
};
/**
* Internally, React Flow maintains a coordinate system that is independent of the
* rest of the page. The `Viewport` type tells you where in that system your flow
* is currently being display at and how zoomed in or out it is.
*
* @public
* @remarks A `Transform` has the same properties as the viewport, but they represent
* different things. Make sure you don't get them muddled up or things will start
* to look weird!
*
*/
export type Viewport = {
x: number;
y: number;
zoom: number;
};
export type KeyCode = string | Array<string>;
export type SnapGrid = [number, number];
/**
* This enum is used to set the different modes of panning the viewport when the
* user scrolls. The `Free` mode allows the user to pan in any direction by scrolling
* with a device like a trackpad. The `Vertical` and `Horizontal` modes restrict
* scroll panning to only the vertical or horizontal axis, respectively.
*
* @public
*/
export declare enum PanOnScrollMode {
Free = "free",
Vertical = "vertical",
Horizontal = "horizontal"
}
/**
* @inline
*/
export type ViewportHelperFunctionOptions = {
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
};
/**
* @inline
*/
export type SetCenterOptions = ViewportHelperFunctionOptions & {
zoom?: number;
};
/**
* @inline
*/
export type FitBoundsOptions = ViewportHelperFunctionOptions & {
padding?: number;
};
export type OnViewportChange = (viewport: Viewport) => void;
export type D3ZoomInstance = ZoomBehavior<Element, unknown>;
export type D3SelectionInstance = D3Selection<Element, unknown, null, undefined>;
export type D3ZoomHandler = (this: Element, event: any, d: unknown) => void;
export type UpdateNodeInternals = (nodeId: string | string[]) => void;
/**
* This type is mostly used to help position things on top of the flow viewport. For
* example both the [`<MiniMap />`](/api-reference/components/minimap) and
* [`<Controls />`](/api-reference/components/controls) components take a `position`
* prop of this type.
*
* @public
*/
export type PanelPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-right';
export type ProOptions = {
account?: string;
hideAttribution: boolean;
};
export type UseDragEvent = D3DragEvent<HTMLDivElement, null, SubjectPosition>;
export declare enum SelectionMode {
Partial = "partial",
Full = "full"
}
export type SelectionRect = Rect & {
startX: number;
startY: number;
};
export type OnError = (id: string, message: string) => void;
export type UpdateNodePositions = (dragItems: Map<string, NodeDragItem | InternalNodeBase>, dragging?: boolean) => void;
export type PanBy = (delta: XYPosition) => Promise<boolean>;
export declare const initialConnection: NoConnection;
export type NoConnection = {
inProgress: false;
isValid: null;
from: null;
fromHandle: null;
fromPosition: null;
fromNode: null;
to: null;
toHandle: null;
toPosition: null;
toNode: null;
};
export type ConnectionInProgress<NodeType extends InternalNodeBase = InternalNodeBase> = {
/** Indicates whether a connection is currently in progress. */
inProgress: true;
/**
* If an ongoing connection is above a handle or inside the connection radius, this will be `true`
* or `false`, otherwise `null`.
*/
isValid: boolean | null;
/** Returns the xy start position or `null` if no connection is in progress. */
from: XYPosition;
/** Returns the start handle or `null` if no connection is in progress. */
fromHandle: Handle;
/** Returns the side (called position) of the start handle or `null` if no connection is in progress. */
fromPosition: Position;
/** Returns the start node or `null` if no connection is in progress. */
fromNode: NodeType;
/** Returns the xy end position or `null` if no connection is in progress. */
to: XYPosition;
/** Returns the end handle or `null` if no connection is in progress. */
toHandle: Handle | null;
/** Returns the side (called position) of the end handle or `null` if no connection is in progress. */
toPosition: Position;
/** Returns the end node or `null` if no connection is in progress. */
toNode: NodeType | null;
};
/**
* The `ConnectionState` type bundles all information about an ongoing connection.
* It is returned by the [`useConnection`](/api-reference/hooks/use-connection) hook.
*
* @public
*/
export type ConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = ConnectionInProgress<NodeType> | NoConnection;
export type FinalConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = Omit<ConnectionState<NodeType>, 'inProgress'>;
export type UpdateConnection<NodeType extends InternalNodeBase = InternalNodeBase> = (params: ConnectionState<NodeType>) => void;
export type ColorModeClass = 'light' | 'dark';
export type ColorMode = ColorModeClass | 'system';
export type ConnectionLookup = Map<string, Map<string, HandleConnection>>;
export type OnBeforeDeleteBase<NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase> = ({ nodes, edges, }: {
nodes: NodeType[];
edges: EdgeType[];
}) => Promise<boolean | {
nodes: NodeType[];
edges: EdgeType[];
}>;
//# sourceMappingURL=general.d.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
import type { Position, IsValidConnection } from '.';
/**
* @inline
*/
export type HandleType = 'source' | 'target';
export type Handle = {
id?: string | null;
nodeId: string;
x: number;
y: number;
position: Position;
type: HandleType;
width: number;
height: number;
};
export type HandleProps = {
/**
* Type of the handle.
* @default "source"
*/
type: HandleType;
/**
* The position of the handle relative to the node. In a horizontal flow source handles are
* typically `Position.Right` and in a vertical flow they are typically `Position.Top`.
* @default Position.Top
* @example Position.Top, Position.Right, Position.Bottom, Position.Left
*/
position: Position;
/**
* Should you be able to connect to/from this handle.
* @default true
*/
isConnectable?: boolean;
/**
* Dictates whether a connection can start from this handle.
* @default true
*/
isConnectableStart?: boolean;
/**
* Dictates whether a connection can end on this handle.
* @default true
*/
isConnectableEnd?: boolean;
/**
* Called when a connection is dragged to this handle. You can use this callback to perform some
* custom validation logic based on the connection target and source, for example. Where possible,
* we recommend you move this logic to the `isValidConnection` prop on the main ReactFlow
* component for performance reasons.
* @remarks connection becomes an edge if isValidConnection returns true
*/
isValidConnection?: IsValidConnection;
/**
* Id of the handle.
* @remarks optional if there is only one handle of this type
*/
id?: string | null;
};
//# sourceMappingURL=handles.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/types/handles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7C,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC"}

View File

@@ -0,0 +1,8 @@
export * from './changes';
export * from './general';
export * from './nodes';
export * from './edges';
export * from './handles';
export * from './utils';
export * from './panzoom';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}

View File

@@ -0,0 +1,156 @@
import type { XYPosition, Position, CoordinateExtent, Handle } from '.';
import { Optional } from '../utils/types';
/**
* Framework independent node data structure.
*
* @inline
* @typeParam NodeData - type of the node data
* @typeParam NodeType - type of the node
*/
export type NodeBase<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = {
/** Unique id of a node. */
id: string;
/**
* Position of a node on the pane.
* @example { x: 0, y: 0 }
*/
position: XYPosition;
/** Arbitrary data passed to a node. */
data: NodeData;
/**
* Only relevant for default, source, target nodeType. Controls source position.
* @example 'right', 'left', 'top', 'bottom'
*/
sourcePosition?: Position;
/**
* Only relevant for default, source, target nodeType. Controls target position.
* @example 'right', 'left', 'top', 'bottom'
*/
targetPosition?: Position;
/** Whether or not the node should be visible on the canvas. */
hidden?: boolean;
selected?: boolean;
/** Whether or not the node is currently being dragged. */
dragging?: boolean;
/** Whether or not the node is able to be dragged. */
draggable?: boolean;
selectable?: boolean;
connectable?: boolean;
deletable?: boolean;
/**
* A class name that can be applied to elements inside the node that allows those elements to act
* as drag handles, letting the user drag the node by clicking and dragging on those elements.
*/
dragHandle?: string;
width?: number;
height?: number;
initialWidth?: number;
initialHeight?: number;
/** Parent node id, used for creating sub-flows. */
parentId?: string;
zIndex?: number;
/**
* Boundary a node can be moved in.
* @example 'parent' or [[0, 0], [100, 100]]
*/
extent?: 'parent' | CoordinateExtent | null;
/**
* When `true`, the parent node will automatically expand if this node is dragged to the edge of
* the parent node's bounds.
*/
expandParent?: boolean;
ariaLabel?: string;
/**
* Origin of the node relative to its position.
* @example
* [0.5, 0.5] // centers the node
* [0, 0] // top left
* [1, 1] // bottom right
*/
origin?: NodeOrigin;
handles?: NodeHandle[];
measured?: {
width?: number;
height?: number;
};
} & (undefined extends NodeType ? {
/** Type of node defined in nodeTypes */
type?: string | undefined;
} : {
/** Type of node defined in nodeTypes */
type: NodeType;
});
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = Omit<NodeType, 'measured'> & {
measured: {
width?: number;
height?: number;
};
internals: {
positionAbsolute: XYPosition;
z: number;
/**
* Holds a reference to the original node object provided by the user.
* Used as an optimization to avoid certain operations.
*/
userNode: NodeType;
handleBounds?: NodeHandleBounds;
bounds?: NodeBounds;
};
};
/**
* The node data structure that gets used for the custom nodes props.
*
* @public
*/
export type NodeProps<NodeType extends NodeBase> = Pick<NodeType, 'id' | 'data' | 'width' | 'height' | 'sourcePosition' | 'targetPosition' | 'dragHandle' | 'parentId'> & Required<Pick<NodeType, 'type' | 'dragging' | 'zIndex' | 'selectable' | 'deletable' | 'selected' | 'draggable'>> & {
/** Whether a node is connectable or not. */
isConnectable: boolean;
/** Position absolute x value. */
positionAbsoluteX: number;
/** Position absolute y value. */
positionAbsoluteY: number;
};
export type NodeHandleBounds = {
source: Handle[] | null;
target: Handle[] | null;
};
export type InternalNodeUpdate = {
id: string;
nodeElement: HTMLDivElement;
force?: boolean;
};
export type NodeBounds = XYPosition & {
width: number | null;
height: number | null;
};
export type NodeDragItem = {
id: string;
position: XYPosition;
distance: XYPosition;
measured: {
width: number;
height: number;
};
internals: {
positionAbsolute: XYPosition;
};
} & Pick<InternalNodeBase, 'extent' | 'parentId' | 'origin' | 'expandParent' | 'dragging'>;
/**
* The origin of a Node determines how it is placed relative to its own coordinates.
* `[0, 0]` places it at the top left corner, `[0.5, 0.5]` right in the center and
* `[1, 1]` at the bottom right of its position.
*
* @public
*/
export type NodeOrigin = [number, number];
export type OnSelectionDrag = (event: MouseEvent, nodes: NodeBase[]) => void;
/**
* Type for the handles of a node
*
* @public
*/
export type NodeHandle = Omit<Optional<Handle, 'width' | 'height'>, 'nodeId'>;
export type Align = 'center' | 'start' | 'end';
export type NodeLookup<NodeType extends InternalNodeBase = InternalNodeBase> = Map<string, NodeType>;
export type ParentLookup<NodeType extends InternalNodeBase = InternalNodeBase> = Map<string, Map<string, NodeType>>;
//# sourceMappingURL=nodes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/types/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,CAClB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IACtD;IACF,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,QAAQ,EAAE,UAAU,CAAC;IACrB,uCAAuC;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EA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AAE1C,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;AAE9E,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAE/C,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACrG,MAAM,MAAM,YAAY,CAAC,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,54 @@
import type { ZoomTransform } from 'd3-zoom';
import { PanOnScrollMode, type CoordinateExtent, type Transform, type Viewport } from './';
export type OnDraggingChange = (dragging: boolean) => void;
export type OnTransformChange = (transform: Transform) => void;
export type PanZoomParams = {
domNode: Element;
minZoom: number;
maxZoom: number;
paneClickDistance: number;
viewport: Viewport;
translateExtent: CoordinateExtent;
onDraggingChange: OnDraggingChange;
onPanZoomStart?: OnPanZoom;
onPanZoom?: OnPanZoom;
onPanZoomEnd?: OnPanZoom;
};
export type PanZoomTransformOptions = {
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
};
export type OnPanZoom = (event: MouseEvent | TouchEvent | null, viewport: Viewport) => void;
export type PanZoomUpdateOptions = {
noWheelClassName: string;
noPanClassName: string;
onPaneContextMenu?: (event: MouseEvent) => void;
preventScrolling: boolean;
panOnScroll: boolean;
panOnDrag: boolean | number[];
panOnScrollMode: PanOnScrollMode;
panOnScrollSpeed: number;
userSelectionActive: boolean;
zoomOnPinch: boolean;
zoomOnScroll: boolean;
zoomOnDoubleClick: boolean;
zoomActivationKeyPressed: boolean;
lib: string;
onTransformChange: OnTransformChange;
connectionInProgress: boolean;
};
export type PanZoomInstance = {
update: (params: PanZoomUpdateOptions) => void;
destroy: () => void;
getViewport: () => Viewport;
setViewport: (viewport: Viewport, options?: PanZoomTransformOptions) => Promise<ZoomTransform | undefined>;
setViewportConstrained: (viewport: Viewport, extent: CoordinateExtent, translateExtent: CoordinateExtent) => Promise<ZoomTransform | undefined>;
setScaleExtent: (scaleExtent: [number, number]) => void;
setTranslateExtent: (translateExtent: CoordinateExtent) => void;
scaleTo: (scale: number, options?: PanZoomTransformOptions) => Promise<boolean>;
scaleBy: (factor: number, options?: PanZoomTransformOptions) => Promise<boolean>;
syncViewport: (viewport: Viewport) => void;
setClickDistance: (distance: number) => void;
};
//# sourceMappingURL=panzoom.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"panzoom.d.ts","sourceRoot":"","sources":["../../src/types/panzoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE3F,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;AAC3D,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,gBAAgB,CAAC;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,S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OAAO,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAC3G,sBAAsB,EAAE,CACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,gBAAgB,KAC9B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IACxC,cAAc,EAAE,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACxD,kBAAkB,EAAE,CAAC,eAAe,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAChE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChF,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjF,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC"}

View File

@@ -0,0 +1,53 @@
/**
* While [`PanelPosition`](/api-reference/types/panel-position) can be used to place a
* component in the corners of a container, the `Position` enum is less precise and used
* primarily in relation to edges and handles.
*
* @public
*/
export declare enum Position {
Left = "left",
Top = "top",
Right = "right",
Bottom = "bottom"
}
export declare const oppositePosition: {
left: Position;
right: Position;
top: Position;
bottom: Position;
};
/**
* All positions are stored in an object with x and y coordinates.
*
* @public
*/
export type XYPosition = {
x: number;
y: number;
};
export type XYZPosition = XYPosition & {
z: number;
};
export type Dimensions = {
width: number;
height: number;
};
export type Rect = Dimensions & XYPosition;
export type Box = XYPosition & {
x2: number;
y2: number;
};
export type Transform = [number, number, number];
/**
* A coordinate extent represents two points in a coordinate system: one in the top
* left corner and one in the bottom right corner. It is used to represent the
* bounds of nodes in the flow or the bounds of the viewport.
*
* @public
*
* @remarks Props that expect a `CoordinateExtent` usually default to `[[-∞, -∞], [+∞, +∞]]`
* to represent an unbounded extent.
*/
export type CoordinateExtent = [[number, number], [number, number]];
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC;AAE3C,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,13 @@
import { HandleConnection } from '../types';
/**
* @internal
*/
export declare function areConnectionMapsEqual(a?: Map<string, HandleConnection>, b?: Map<string, HandleConnection>): boolean;
/**
* We call the callback for all connections in a that are not in b
*
* @internal
*/
export declare function handleConnectionChange(a: Map<string, HandleConnection>, b: Map<string, HandleConnection>, cb?: (diff: HandleConnection[]) => void): void;
export declare function getConnectionStatus(isValid: boolean | null): "valid" | "invalid" | null;
//# sourceMappingURL=connections.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/utils/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,WAoB1G;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAChC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAChC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,IAAI,QAiBxC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,8BAE1D"}

View File

@@ -0,0 +1,21 @@
import type { Transform, XYPosition, SnapGrid, Dimensions, Handle } from '../types';
export type GetPointerPositionParams = {
transform: Transform;
snapGrid?: SnapGrid;
snapToGrid?: boolean;
containerBounds: DOMRect | null;
};
export declare function getPointerPosition(event: MouseEvent | TouchEvent, { snapGrid, snapToGrid, transform, containerBounds }: GetPointerPositionParams): XYPosition & {
xSnapped: number;
ySnapped: number;
};
export declare const getDimensions: (node: HTMLDivElement) => Dimensions;
export declare const getHostForElement: (element: HTMLElement | EventTarget | null) => Document | ShadowRoot;
export declare function isInputDOMNode(event: KeyboardEvent): boolean;
export declare const isMouseEvent: (event: MouseEvent | TouchEvent) => event is MouseEvent;
export declare const getEventPosition: (event: MouseEvent | TouchEvent, bounds?: DOMRect) => {
x: number;
y: number;
};
export declare const getHandleBounds: (type: "source" | "target", nodeElement: HTMLDivElement, nodeBounds: DOMRect, zoom: number, nodeId: string) => Handle[] | null;
//# sourceMappingURL=dom.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAG9F,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,GAAG,UAAU,EAC9B,EAAE,QAAiB,EAAE,UAAkB,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,wBAAwB,GAC9F,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAcrD;AAED,eAAO,MAAM,aAAa,SAAU,cAAc,KAAG,UAGnD,CAAC;AAEH,eAAO,MAAM,iBAAiB,YAAa,WAAW,GAAG,WAAW,GAAG,IAAI,KAAG,QAAQ,GAAG,UACiB,CAAC;AAI3G,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAS5D;AAED,eAAO,MAAM,YAAY,UAAW,UAAU,GAAG,UAAU,KAAG,KAAK,IAAI,UAAgC,CAAC;AAExG,eAAO,MAAM,gBAAgB,UAAW,UAAU,GAAG,UAAU,WAAW,OAAO;;;CAShF,CAAC;AAOF,eAAO,MAAM,eAAe,SACpB,QAAQ,GAAG,QAAQ,eACZ,cAAc,cACf,OAAO,QACb,MAAM,UACJ,MAAM,KACb,MAAM,EAAE,GAAG,IAoBb,CAAC"}

View File

@@ -0,0 +1,77 @@
import { Position } from '../../types';
export type GetBezierPathParams = {
/** The `x` position of the source handle. */
sourceX: number;
/** The `y` position of the source handle. */
sourceY: number;
/**
* The position of the source handle.
* @default Position.Bottom
*/
sourcePosition?: Position;
/** The `x` position of the target handle. */
targetX: number;
/** The `y` position of the target handle. */
targetY: number;
/**
* The position of the target handle.
* @default Position.Top
*/
targetPosition?: Position;
/**
* The curvature of the bezier edge.
* @default 0.25
*/
curvature?: number;
};
export type GetControlWithCurvatureParams = {
pos: Position;
x1: number;
y1: number;
x2: number;
y2: number;
c: number;
};
export declare function getBezierEdgeCenter({ sourceX, sourceY, targetX, targetY, sourceControlX, sourceControlY, targetControlX, targetControlY, }: {
sourceX: number;
sourceY: number;
targetX: number;
targetY: number;
sourceControlX: number;
sourceControlY: number;
targetControlX: number;
targetControlY: number;
}): [number, number, number, number];
/**
* The `getBezierPath` util returns everything you need to render a bezier edge
*between two nodes.
* @public
* @returns A path string you can use in an SVG, the `labelX` and `labelY` position (center of path)
* and `offsetX`, `offsetY` between source handle and label.
* - `path`: the path to use in an SVG `<path>` element.
* - `labelX`: the `x` position you can use to render a label for this edge.
* - `labelY`: the `y` position you can use to render a label for this edge.
* - `offsetX`: the absolute difference between the source `x` position and the `x` position of the
* middle of this path.
* - `offsetY`: the absolute difference between the source `y` position and the `y` position of the
* middle of this path.
* @example
* ```js
* const source = { x: 0, y: 20 };
* const target = { x: 150, y: 100 };
*
* const [path, labelX, labelY, offsetX, offsetY] = getBezierPath({
* sourceX: source.x,
* sourceY: source.y,
* sourcePosition: Position.Right,
* targetX: target.x,
* targetY: target.y,
* targetPosition: Position.Left,
*});
*```
*
* @remarks This function returns a tuple (aka a fixed-size array) to make it easier to
*work with multiple edge paths at once.
*/
export declare function getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, curvature, }: GetBezierPathParams): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number];
//# sourceMappingURL=bezier-edge.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bezier-edge.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/bezier-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,mBAAmB,GAAG;IAChC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,GAAG,EAAE,QAAQ,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,GACf,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAWnC;AAuBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,OAAO,EACP,cAAgC,EAChC,OAAO,EACP,OAAO,EACP,cAA6B,EAC7B,SAAgB,GACjB,EAAE,mBAAmB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAmCxG"}

View File

@@ -0,0 +1,67 @@
import { Connection, InternalNodeBase, Transform, EdgeBase } from '../..';
export declare function getEdgeCenter({ sourceX, sourceY, targetX, targetY, }: {
sourceX: number;
sourceY: number;
targetX: number;
targetY: number;
}): [number, number, number, number];
export type GetEdgeZIndexParams = {
sourceNode: InternalNodeBase;
targetNode: InternalNodeBase;
selected?: boolean;
zIndex?: number;
elevateOnSelect?: boolean;
};
/**
* Returns the z-index for an edge based on the node it connects and whether it is selected.
* By default, edges are rendered below nodes. This behaviour is different for edges that are
* connected to nodes with a parent, as they are rendered above the parent node.
*/
export declare function getElevatedEdgeZIndex({ sourceNode, targetNode, selected, zIndex, elevateOnSelect, }: GetEdgeZIndexParams): number;
type IsEdgeVisibleParams = {
sourceNode: InternalNodeBase;
targetNode: InternalNodeBase;
width: number;
height: number;
transform: Transform;
};
export declare function isEdgeVisible({ sourceNode, targetNode, width, height, transform }: IsEdgeVisibleParams): boolean;
/**
* This util is a convenience function to add a new Edge to an array of edges. It also performs some validation to make sure you don't add an invalid edge or duplicate an existing one.
* @public
* @param edgeParams - Either an `Edge` or a `Connection` you want to add.
* @param edges - The array of all current edges.
* @returns A new array of edges with the new edge added.
*
* @remarks If an edge with the same `target` and `source` already exists (and the same
*`targetHandle` and `sourceHandle` if those are set), then this util won't add
*a new edge even if the `id` property is different.
*
*/
export declare const addEdge: <EdgeType extends EdgeBase>(edgeParams: EdgeType | Connection, edges: EdgeType[]) => EdgeType[];
export type ReconnectEdgeOptions = {
/**
* Should the id of the old edge be replaced with the new connection id.
* @default true
*/
shouldReplaceId?: boolean;
};
/**
* A handy utility to update an existing [`Edge`](/api-reference/types/edge) with new properties.
*This searches your edge array for an edge with a matching `id` and updates its
*properties with the connection you provide.
* @public
* @param oldEdge - The edge you want to update.
* @param newConnection - The new connection you want to update the edge with.
* @param edges - The array of all current edges.
* @returns The updated edges array.
*
* @example
* ```js
*const onReconnect = useCallback(
* (oldEdge: Edge, newConnection: Connection) => setEdges((els) => reconnectEdge(oldEdge, newConnection, els)),[]);
*```
*/
export declare const reconnectEdge: <EdgeType extends EdgeBase>(oldEdge: EdgeType, newConnection: Connection, edges: EdgeType[], options?: ReconnectEdgeOptions) => EdgeType[];
export {};
//# sourceMappingURL=general.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAA6B,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIrG,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQnC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,UAAU,EACV,QAAgB,EAChB,MAAM,EACN,eAAuB,GACxB,EAAE,mBAAmB,GAAG,MAAM,CAY9B;AAED,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAmBhH;AAeD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,SAAS,QAAQ,cACnC,QAAQ,GAAG,UAAU,SAC1B,QAAQ,EAAE,KAChB,QAAQ,EA8BV,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,SAAS,QAAQ,WAC5C,QAAQ,iBACF,UAAU,SAClB,QAAQ,EAAE,YACR,oBAAoB,KAC5B,QAAQ,EA4BV,CAAC"}

View File

@@ -0,0 +1,6 @@
export * from './bezier-edge';
export * from './straight-edge';
export * from './smoothstep-edge';
export * from './general';
export * from './positions';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}

View File

@@ -0,0 +1,17 @@
import { EdgePosition } from '../../types/edges';
import { ConnectionMode, OnError } from '../../types/general';
import { InternalNodeBase } from '../../types/nodes';
import { Position, XYPosition } from '../../types/utils';
import { Handle } from '../../types';
export type GetEdgePositionParams = {
id: string;
sourceNode: InternalNodeBase;
sourceHandle: string | null;
targetNode: InternalNodeBase;
targetHandle: string | null;
connectionMode: ConnectionMode;
onError?: OnError;
};
export declare function getEdgePosition(params: GetEdgePositionParams): EdgePosition | null;
export declare function getHandlePosition(node: InternalNodeBase, handle: Handle | null, fallbackPosition?: Position, center?: boolean): XYPosition;
//# sourceMappingURL=positions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/positions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAc,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,gBAAgB,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAUF,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA6ClF;AA2BD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,gBAAgB,GAAE,QAAwB,EAC1C,MAAM,UAAQ,GACb,UAAU,CAqBZ"}

View File

@@ -0,0 +1,66 @@
import { Position } from '../../types';
export interface GetSmoothStepPathParams {
/** The `x` position of the source handle. */
sourceX: number;
/** The `y` position of the source handle. */
sourceY: number;
/**
* The position of the source handle.
* @default Position.Bottom
*/
sourcePosition?: Position;
/** The `x` position of the target handle. */
targetX: number;
/** The `y` position of the target handle. */
targetY: number;
/**
* The position of the target handle.
* @default Position.Top
*/
targetPosition?: Position;
/** @default 5 */
borderRadius?: number;
centerX?: number;
centerY?: number;
/** @default 20 */
offset?: number;
/**
* Controls where the bend occurs along the path.
* 0 = at source, 1 = at target, 0.5 = midpoint
* @default 0.5
*/
stepPosition?: number;
}
/**
* The `getSmoothStepPath` util returns everything you need to render a stepped path
* between two nodes. The `borderRadius` property can be used to choose how rounded
* the corners of those steps are.
* @public
* @returns A path string you can use in an SVG, the `labelX` and `labelY` position (center of path)
* and `offsetX`, `offsetY` between source handle and label.
*
* - `path`: the path to use in an SVG `<path>` element.
* - `labelX`: the `x` position you can use to render a label for this edge.
* - `labelY`: the `y` position you can use to render a label for this edge.
* - `offsetX`: the absolute difference between the source `x` position and the `x` position of the
* middle of this path.
* - `offsetY`: the absolute difference between the source `y` position and the `y` position of the
* middle of this path.
* @example
* ```js
* const source = { x: 0, y: 20 };
* const target = { x: 150, y: 100 };
*
* const [path, labelX, labelY, offsetX, offsetY] = getSmoothStepPath({
* sourceX: source.x,
* sourceY: source.y,
* sourcePosition: Position.Right,
* targetX: target.x,
* targetY: target.y,
* targetPosition: Position.Left,
* });
* ```
* @remarks This function returns a tuple (aka a fixed-size array) to make it easier to work with multiple edge paths at once.
*/
export declare function getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, borderRadius, centerX, centerY, offset, stepPosition, }: GetSmoothStepPathParams): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number];
//# sourceMappingURL=smoothstep-edge.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"smoothstep-edge.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/smoothstep-edge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,iBAAiB;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAkMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EACP,cAAgC,EAChC,OAAO,EACP,OAAO,EACP,cAA6B,EAC7B,YAAgB,EAChB,OAAO,EACP,OAAO,EACP,MAAW,EACX,YAAkB,GACnB,EAAE,uBAAuB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CA0B5G"}

View File

@@ -0,0 +1,41 @@
export type GetStraightPathParams = {
/** The `x` position of the source handle. */
sourceX: number;
/** The `y` position of the source handle. */
sourceY: number;
/** The `x` position of the target handle. */
targetX: number;
/** The `y` position of the target handle. */
targetY: number;
};
/**
* Calculates the straight line path between two points.
* @public
* @returns A path string you can use in an SVG, the `labelX` and `labelY` position (center of path)
* and `offsetX`, `offsetY` between source handle and label.
*
* - `path`: the path to use in an SVG `<path>` element.
* - `labelX`: the `x` position you can use to render a label for this edge.
* - `labelY`: the `y` position you can use to render a label for this edge.
* - `offsetX`: the absolute difference between the source `x` position and the `x` position of the
* middle of this path.
* - `offsetY`: the absolute difference between the source `y` position and the `y` position of the
* middle of this path.
* @example
* ```js
* const source = { x: 0, y: 20 };
* const target = { x: 150, y: 100 };
*
* const [path, labelX, labelY, offsetX, offsetY] = getStraightPath({
* sourceX: source.x,
* sourceY: source.y,
* sourcePosition: Position.Right,
* targetX: target.x,
* targetY: target.y,
* targetPosition: Position.Left,
* });
* ```
* @remarks This function returns a tuple (aka a fixed-size array) to make it easier to work with multiple edge paths at once.
*/
export declare function getStraightPath({ sourceX, sourceY, targetX, targetY, }: GetStraightPathParams): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number];
//# sourceMappingURL=straight-edge.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"straight-edge.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/straight-edge.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAAG;IAClC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,GACR,EAAE,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAS1G"}

View File

@@ -0,0 +1,85 @@
import type { Dimensions, XYPosition, CoordinateExtent, Box, Rect, NodeBase, NodeOrigin, SnapGrid, Transform, InternalNodeBase, NodeLookup, Padding } from '../types';
import { type Viewport } from '../types';
import { type AriaLabelConfig } from '../constants';
export declare const clamp: (val: number, min?: number, max?: number) => number;
export declare const clampPosition: (position: XYPosition | undefined, extent: CoordinateExtent, dimensions: Partial<Dimensions>) => {
x: number;
y: number;
};
export declare function clampPositionToParent<NodeType extends NodeBase>(childPosition: XYPosition, childDimensions: Dimensions, parent: InternalNodeBase<NodeType>): {
x: number;
y: number;
};
export declare const calcAutoPan: (pos: XYPosition, bounds: Dimensions, speed?: number, distance?: number) => number[];
export declare const getBoundsOfBoxes: (box1: Box, box2: Box) => Box;
export declare const rectToBox: ({ x, y, width, height }: Rect) => Box;
export declare const boxToRect: ({ x, y, x2, y2 }: Box) => Rect;
export declare const nodeToRect: (node: InternalNodeBase | NodeBase, nodeOrigin?: NodeOrigin) => Rect;
export declare const nodeToBox: (node: InternalNodeBase | NodeBase, nodeOrigin?: NodeOrigin) => Box;
export declare const getBoundsOfRects: (rect1: Rect, rect2: Rect) => Rect;
export declare const getOverlappingArea: (rectA: Rect, rectB: Rect) => number;
export declare const isRectObject: (obj: any) => obj is Rect;
export declare const isNumeric: (n: any) => n is number;
export declare const devWarn: (id: string, message: string) => void;
export declare const snapPosition: (position: XYPosition, snapGrid?: SnapGrid) => XYPosition;
export declare const pointToRendererPoint: ({ x, y }: XYPosition, [tx, ty, tScale]: Transform, snapToGrid?: boolean, snapGrid?: SnapGrid) => XYPosition;
export declare const rendererPointToPoint: ({ x, y }: XYPosition, [tx, ty, tScale]: Transform) => XYPosition;
/**
* Returns a viewport that encloses the given bounds with padding.
* @public
* @remarks You can determine bounds of nodes with {@link getNodesBounds} and {@link getBoundsOfRects}
* @param bounds - Bounds to fit inside viewport.
* @param width - Width of the viewport.
* @param height - Height of the viewport.
* @param minZoom - Minimum zoom level of the resulting viewport.
* @param maxZoom - Maximum zoom level of the resulting viewport.
* @param padding - Padding around the bounds.
* @returns A transformed {@link Viewport} that encloses the given bounds which you can pass to e.g. {@link setViewport}.
* @example
* const { x, y, zoom } = getViewportForBounds(
* { x: 0, y: 0, width: 100, height: 100},
* 1200, 800, 0.5, 2);
*/
export declare const getViewportForBounds: (bounds: Rect, width: number, height: number, minZoom: number, maxZoom: number, padding: Padding) => Viewport;
export declare const isMacOs: () => boolean;
export declare function isCoordinateExtent(extent?: CoordinateExtent | 'parent' | null): extent is CoordinateExtent;
export declare function getNodeDimensions(node: {
measured?: {
width?: number;
height?: number;
};
width?: number;
height?: number;
initialWidth?: number;
initialHeight?: number;
}): {
width: number;
height: number;
};
export declare function nodeHasDimensions<NodeType extends NodeBase = NodeBase>(node: NodeType): boolean;
/**
* Convert child position to aboslute position
*
* @internal
* @param position
* @param parentId
* @param nodeLookup
* @param nodeOrigin
* @returns an internal node with an absolute position
*/
export declare function evaluateAbsolutePosition(position: XYPosition, dimensions: {
width?: number;
height?: number;
} | undefined, parentId: string, nodeLookup: NodeLookup, nodeOrigin: NodeOrigin): XYPosition;
export declare function areSetsEqual(a: Set<string>, b: Set<string>): boolean;
/**
* Polyfill for Promise.withResolvers until we can use it in all browsers
* @internal
*/
export declare function withResolvers<T>(): {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
reject: (reason?: unknown) => void;
};
export declare function mergeAriaLabelConfig(partial?: Partial<AriaLabelConfig>): AriaLabelConfig;
//# sourceMappingURL=general.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/utils/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,OAAO,EAER,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5E,eAAO,MAAM,KAAK,QAAS,MAAM,iCAAq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C,KAAK;IAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CASA;AAED,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAExF"}

View File

@@ -0,0 +1,191 @@
import { type Transform, type XYPosition, type Rect, type NodeOrigin, type NodeBase, type EdgeBase, type FitViewParamsBase, type FitViewOptionsBase, CoordinateExtent, OnError, OnBeforeDeleteBase, NodeLookup, InternalNodeBase, NodeDragItem } from '../types';
/**
* Test whether an object is usable as an Edge
* @public
* @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Edge if it returns true
* @param element - The element to test
* @returns A boolean indicating whether the element is an Edge
*/
export declare const isEdgeBase: <EdgeType extends EdgeBase = EdgeBase>(element: any) => element is EdgeType;
/**
* Test whether an object is usable as a Node
* @public
* @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Node if it returns true
* @param element - The element to test
* @returns A boolean indicating whether the element is an Node
*/
export declare const isNodeBase: <NodeType extends NodeBase = NodeBase>(element: any) => element is NodeType;
export declare const isInternalNodeBase: <NodeType extends InternalNodeBase = InternalNodeBase>(element: any) => element is NodeType;
/**
* This util is used to tell you what nodes, if any, are connected to the given node
* as the _target_ of an edge.
* @public
* @param node - The node to get the connected nodes from.
* @param nodes - The array of all nodes.
* @param edges - The array of all edges.
* @returns An array of nodes that are connected over edges where the source is the given node.
*
* @example
* ```ts
*import { getOutgoers } from '@xyflow/react';
*
*const nodes = [];
*const edges = [];
*
*const outgoers = getOutgoers(
* { id: '1', position: { x: 0, y: 0 }, data: { label: 'node' } },
* nodes,
* edges,
*);
*```
*/
export declare const getOutgoers: <NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase>(node: NodeType | {
id: string;
}, nodes: NodeType[], edges: EdgeType[]) => NodeType[];
/**
* This util is used to tell you what nodes, if any, are connected to the given node
* as the _source_ of an edge.
* @public
* @param node - The node to get the connected nodes from.
* @param nodes - The array of all nodes.
* @param edges - The array of all edges.
* @returns An array of nodes that are connected over edges where the target is the given node.
*
* @example
* ```ts
*import { getIncomers } from '@xyflow/react';
*
*const nodes = [];
*const edges = [];
*
*const incomers = getIncomers(
* { id: '1', position: { x: 0, y: 0 }, data: { label: 'node' } },
* nodes,
* edges,
*);
*```
*/
export declare const getIncomers: <NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase>(node: NodeType | {
id: string;
}, nodes: NodeType[], edges: EdgeType[]) => NodeType[];
export declare const getNodePositionWithOrigin: (node: NodeBase, nodeOrigin?: NodeOrigin) => XYPosition;
export type GetNodesBoundsParams<NodeType extends NodeBase = NodeBase> = {
/**
* Origin of the nodes: `[0, 0]` for top-left, `[0.5, 0.5]` for center.
* @default [0, 0]
*/
nodeOrigin?: NodeOrigin;
nodeLookup?: NodeLookup<InternalNodeBase<NodeType>>;
};
/**
* Returns the bounding box that contains all the given nodes in an array. This can
* be useful when combined with [`getViewportForBounds`](/api-reference/utils/get-viewport-for-bounds)
* to calculate the correct transform to fit the given nodes in a viewport.
* @public
* @remarks Useful when combined with {@link getViewportForBounds} to calculate the correct transform to fit the given nodes in a viewport.
* @param nodes - Nodes to calculate the bounds for.
* @returns Bounding box enclosing all nodes.
*
* @remarks This function was previously called `getRectOfNodes`
*
* @example
* ```js
*import { getNodesBounds } from '@xyflow/react';
*
*const nodes = [
* {
* id: 'a',
* position: { x: 0, y: 0 },
* data: { label: 'a' },
* width: 50,
* height: 25,
* },
* {
* id: 'b',
* position: { x: 100, y: 100 },
* data: { label: 'b' },
* width: 50,
* height: 25,
* },
*];
*
*const bounds = getNodesBounds(nodes);
*```
*/
export declare const getNodesBounds: <NodeType extends NodeBase = NodeBase>(nodes: (NodeType | InternalNodeBase<NodeType> | string)[], params?: GetNodesBoundsParams<NodeType>) => Rect;
export type GetInternalNodesBoundsParams<NodeType> = {
useRelativePosition?: boolean;
filter?: (node: NodeType) => boolean;
};
/**
* Determines a bounding box that contains all given nodes in an array
* @internal
*/
export declare const getInternalNodesBounds: <NodeType extends InternalNodeBase | NodeDragItem>(nodeLookup: Map<string, NodeType>, params?: GetInternalNodesBoundsParams<NodeType>) => Rect;
export declare const getNodesInside: <NodeType extends NodeBase = NodeBase>(nodes: Map<string, InternalNodeBase<NodeType>>, rect: Rect, [tx, ty, tScale]?: Transform, partially?: boolean, excludeNonSelectableNodes?: boolean) => InternalNodeBase<NodeType>[];
/**
* This utility filters an array of edges, keeping only those where either the source or target
* node is present in the given array of nodes.
* @public
* @param nodes - Nodes you want to get the connected edges for.
* @param edges - All edges.
* @returns Array of edges that connect any of the given nodes with each other.
*
* @example
* ```js
*import { getConnectedEdges } from '@xyflow/react';
*
*const nodes = [
* { id: 'a', position: { x: 0, y: 0 } },
* { id: 'b', position: { x: 100, y: 0 } },
*];
*
*const edges = [
* { id: 'a->c', source: 'a', target: 'c' },
* { id: 'c->d', source: 'c', target: 'd' },
*];
*
*const connectedEdges = getConnectedEdges(nodes, edges);
* // => [{ id: 'a->c', source: 'a', target: 'c' }]
*```
*/
export declare const getConnectedEdges: <NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase>(nodes: NodeType[], edges: EdgeType[]) => EdgeType[];
export declare function fitViewport<Params extends FitViewParamsBase<NodeBase>, Options extends FitViewOptionsBase<NodeBase>>({ nodes, width, height, panZoom, minZoom, maxZoom }: Params, options?: Omit<Options, 'nodes' | 'includeHiddenNodes'>): Promise<boolean>;
/**
* This function calculates the next position of a node, taking into account the node's extent, parent node, and origin.
*
* @internal
* @returns position, positionAbsolute
*/
export declare function calculateNodePosition<NodeType extends NodeBase>({ nodeId, nextPosition, nodeLookup, nodeOrigin, nodeExtent, onError, }: {
nodeId: string;
nextPosition: XYPosition;
nodeLookup: NodeLookup<InternalNodeBase<NodeType>>;
nodeOrigin?: NodeOrigin;
nodeExtent?: CoordinateExtent;
onError?: OnError;
}): {
position: XYPosition;
positionAbsolute: XYPosition;
};
/**
* Pass in nodes & edges to delete, get arrays of nodes and edges that actually can be deleted
* @internal
* @param param.nodesToRemove - The nodes to remove
* @param param.edgesToRemove - The edges to remove
* @param param.nodes - All nodes
* @param param.edges - All edges
* @param param.onBeforeDelete - Callback to check which nodes and edges can be deleted
* @returns nodes: nodes that can be deleted, edges: edges that can be deleted
*/
export declare function getElementsToRemove<NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase>({ nodesToRemove, edgesToRemove, nodes, edges, onBeforeDelete, }: {
nodesToRemove: Partial<NodeType>[];
edgesToRemove: Partial<EdgeType>[];
nodes: NodeType[];
edges: EdgeType[];
onBeforeDelete?: OnBeforeDeleteBase<NodeType, EdgeType>;
}): Promise<{
nodes: NodeType[];
edges: EdgeType[];
}>;
//# sourceMappingURL=graph.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/utils/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,QAAQ,sBAAsB,GAAG,KAAG,OAAO,IAAI,QAC5B,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,QAAQ,sBAAsB,GAAG,KAAG,OAAO,IAAI,QACG,CAAC;AAE/F,eAAO,MAAM,kBAAkB,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CAAC,EAAE,OAAO,CAAC;CACnB,GAAG;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,gBAAgB,EAAE,UAAU,CAAA;CAAE,CA4CzD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,EACpH,aAAkB,EAClB,aAAkB,EAClB,KAAK,EACL,KAAK,EACL,cAAc,GACf,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CACzD,GAAG,OAAO,CAAC;IACV,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC,CA+CD"}

View File

@@ -0,0 +1,11 @@
export * from './connections';
export * from './dom';
export * from './edges';
export * from './graph';
export * from './general';
export * from './marker';
export * from './node-toolbar';
export * from './store';
export * from './types';
export * from './shallow-node-data';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC"}

View File

@@ -0,0 +1,9 @@
import type { EdgeBase, EdgeMarkerType, MarkerProps } from '../types';
export declare function getMarkerId(marker: EdgeMarkerType | undefined, id?: string | null): string;
export declare function createMarkerIds(edges: EdgeBase[], { id, defaultColor, defaultMarkerStart, defaultMarkerEnd, }: {
id?: string | null;
defaultColor?: string | null;
defaultMarkerStart?: EdgeMarkerType;
defaultMarkerEnd?: EdgeMarkerType;
}): MarkerProps[];
//# sourceMappingURL=marker.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../src/utils/marker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAc,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElF,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAe1F;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,EACE,EAAE,EACF,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,GACjB,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,cAAc,CAAC;IACpC,gBAAgB,CAAC,EAAE,cAAc,CAAC;CACnC,iBAmBF"}

View File

@@ -0,0 +1,3 @@
import { Position, type Rect, type Viewport, type Align } from '../';
export declare function getNodeToolbarTransform(nodeRect: Rect, viewport: Viewport, position: Position, offset: number, align: Align): string;
//# sourceMappingURL=node-toolbar.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"node-toolbar.d.ts","sourceRoot":"","sources":["../../src/utils/node-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAErE,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,MAAM,CA0CR"}

View File

@@ -0,0 +1,5 @@
import { NodeBase } from '../types';
type NodeData = Pick<NodeBase, 'id' | 'type' | 'data'>;
export declare function shallowNodeData(a: NodeData | NodeData[] | null, b: NodeData | NodeData[] | null): boolean;
export {};
//# sourceMappingURL=shallow-node-data.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"shallow-node-data.d.ts","sourceRoot":"","sources":["../../src/utils/shallow-node-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;AAEvD,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,IAAI,WAmB/F"}

View File

@@ -0,0 +1,27 @@
import { NodeBase, CoordinateExtent, InternalNodeUpdate, NodeOrigin, PanZoomInstance, Transform, XYPosition, ConnectionLookup, EdgeBase, EdgeLookup, InternalNodeBase, NodeLookup, NodeDimensionChange, NodePositionChange, ParentLookup } from '../types';
import { ParentExpandChild } from './types';
export declare function updateAbsolutePositions<NodeType extends NodeBase>(nodeLookup: NodeLookup<InternalNodeBase<NodeType>>, parentLookup: ParentLookup<InternalNodeBase<NodeType>>, options?: UpdateNodesOptions<NodeType>): void;
type UpdateNodesOptions<NodeType extends NodeBase> = {
nodeOrigin?: NodeOrigin;
nodeExtent?: CoordinateExtent;
elevateNodesOnSelect?: boolean;
defaults?: Partial<NodeType>;
checkEquality?: boolean;
};
export declare function adoptUserNodes<NodeType extends NodeBase>(nodes: NodeType[], nodeLookup: NodeLookup<InternalNodeBase<NodeType>>, parentLookup: ParentLookup<InternalNodeBase<NodeType>>, options?: UpdateNodesOptions<NodeType>): boolean;
export declare function handleExpandParent(children: ParentExpandChild[], nodeLookup: NodeLookup, parentLookup: ParentLookup, nodeOrigin?: NodeOrigin): (NodeDimensionChange | NodePositionChange)[];
export declare function updateNodeInternals<NodeType extends InternalNodeBase>(updates: Map<string, InternalNodeUpdate>, nodeLookup: NodeLookup<NodeType>, parentLookup: ParentLookup<NodeType>, domNode: HTMLElement | null, nodeOrigin?: NodeOrigin, nodeExtent?: CoordinateExtent): {
changes: (NodeDimensionChange | NodePositionChange)[];
updatedInternals: boolean;
};
export declare function panBy({ delta, panZoom, transform, translateExtent, width, height, }: {
delta: XYPosition;
panZoom: PanZoomInstance | null;
transform: Transform;
translateExtent: CoordinateExtent;
width: number;
height: number;
}): Promise<boolean>;
export declare function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeLookup: EdgeLookup, edges: EdgeBase[]): void;
export {};
//# sourceMappingURL=store.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/utils/store.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,UAAU,EAEV,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAYlB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA0B5C,wBAAgB,uBAAuB,CAAC,QAAQ,SAAS,QAAQ,EAC/D,UAAU,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAClD,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EACtD,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,QAavC;AAkCD,KAAK,kBAAkB,CAAC,QAAQ,S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EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,gBAAgB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBnB;AAwCD,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,QAgBnH"}

View File

@@ -0,0 +1,8 @@
import { Rect } from '../types';
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
export type ParentExpandChild = {
id: string;
parentId: string;
rect: Rect;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC"}

View File

@@ -0,0 +1,55 @@
import type { NodeBase, NodeDragItem, EdgeBase, CoordinateExtent, NodeOrigin, OnError, SnapGrid, Transform, PanBy, OnSelectionDrag, UpdateNodePositions, InternalNodeBase } from '../types';
export type OnDrag = (event: MouseEvent, dragItems: Map<string, NodeDragItem>, node: NodeBase, nodes: NodeBase[]) => void;
type StoreItems<OnNodeDrag> = {
nodes: NodeBase[];
nodeLookup: Map<string, InternalNodeBase>;
edges: EdgeBase[];
nodeExtent: CoordinateExtent;
snapGrid: SnapGrid;
snapToGrid: boolean;
nodeOrigin: NodeOrigin;
multiSelectionActive: boolean;
domNode?: Element | null;
transform: Transform;
autoPanOnNodeDrag: boolean;
nodesDraggable: boolean;
selectNodesOnDrag: boolean;
nodeDragThreshold: number;
panBy: PanBy;
unselectNodesAndEdges: (params?: {
nodes?: NodeBase[];
edges?: EdgeBase[];
}) => void;
onError?: OnError;
onNodeDragStart?: OnNodeDrag;
onNodeDrag?: OnNodeDrag;
onNodeDragStop?: OnNodeDrag;
onSelectionDragStart?: OnSelectionDrag;
onSelectionDrag?: OnSelectionDrag;
onSelectionDragStop?: OnSelectionDrag;
updateNodePositions: UpdateNodePositions;
autoPanSpeed?: number;
};
export type XYDragParams<OnNodeDrag> = {
getStoreItems: () => StoreItems<OnNodeDrag>;
onDragStart?: OnDrag;
onDrag?: OnDrag;
onDragStop?: OnDrag;
onNodeMouseDown?: (id: string) => void;
autoPanSpeed?: number;
};
export type XYDragInstance = {
update: (params: DragUpdateParams) => void;
destroy: () => void;
};
export type DragUpdateParams = {
noDragClassName?: string;
handleSelector?: string;
isSelectable?: boolean;
nodeId?: string;
domNode: Element;
nodeClickDistance?: number;
};
export declare function XYDrag<OnNodeDrag extends (e: any, nodes: any, node: any) => void | undefined>({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragStop, }: XYDragParams<OnNodeDrag>): XYDragInstance;
export {};
//# sourceMappingURL=XYDrag.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"XYDrag.d.ts","sourceRoot":"","sources":["../../src/xydrag/XYDrag.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAGZ,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,MAAM,GAAG,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M,MAAM,YAAY,CAAC,UAAU,IAAI;IACrC,aAAa,EAAE,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAGF,wBAAgB,MAAM,CAAC,UAAU,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,SAAS,EAAE,EAC7F,eAAe,EACf,aAAa,EACb,WAAW,EACX,MAAM,EACN,UAAU,GACX,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,cAAc,CAyT3C"}

View File

@@ -0,0 +1,2 @@
export * from './XYDrag';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xydrag/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}

View File

@@ -0,0 +1,24 @@
import { type NodeDragItem, type XYPosition, InternalNodeBase, NodeBase, NodeLookup, SnapGrid } from '../types';
export declare function isParentSelected<NodeType extends NodeBase>(node: NodeType, nodeLookup: NodeLookup): boolean;
export declare function hasSelector(target: Element | EventTarget | null, selector: string, domNode: Element): boolean;
export declare function getDragItems<NodeType extends NodeBase>(nodeLookup: Map<string, InternalNodeBase<NodeType>>, nodesDraggable: boolean, mousePos: XYPosition, nodeId?: string): Map<string, NodeDragItem>;
export declare function getEventHandlerParams<NodeType extends InternalNodeBase>({ nodeId, dragItems, nodeLookup, dragging, }: {
nodeId?: string;
dragItems: Map<string, NodeDragItem>;
nodeLookup: Map<string, NodeType>;
dragging?: boolean;
}): [NodeBase, NodeBase[]];
/**
* If a selection is being dragged we want to apply the same snap offset to all nodes in the selection.
* This function calculates the snap offset based on the first node in the selection.
*/
export declare function calculateSnapOffset({ dragItems, snapGrid, x, y, }: {
dragItems: Map<string, NodeDragItem>;
snapGrid: SnapGrid;
x: number;
y: number;
}): {
x: number;
y: number;
} | null;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xydrag/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGhH,wBAAgB,gBAAgB,CAAC,QAAQ,SAAS,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAgB3G;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAU7G;AAGD,wBAAgB,YAAY,CAAC,QAAQ,SAAS,QAAQ,EACpD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EACnD,cAAc,EAAE,OAAO,EACvB,QAAQ,EAAE,UAAU,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAoC3B;AAOD,wBAAgB,qBAAqB,CAAC,QAAQ,SAAS,gBAAgB,EAAE,EACvE,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAe,GAChB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CA+BzB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,QAAQ,EACR,CAAC,EACD,CAAC,GACF,EAAE;IACD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;;;SAiBA"}

View File

@@ -0,0 +1,3 @@
import { XYHandleInstance } from './types';
export declare const XYHandle: XYHandleInstance;
//# sourceMappingURL=XYHandle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"XYHandle.d.ts","sourceRoot":"","sources":["../../src/xyhandle/XYHandle.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAwTvF,eAAO,MAAM,QAAQ,EAAE,gBAGtB,CAAC"}

View File

@@ -0,0 +1,2 @@
export * from './XYHandle';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xyhandle/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}

View File

@@ -0,0 +1,50 @@
import { ConnectionMode, type Connection, type OnConnect, type OnConnectStart, type HandleType, type PanBy, type Transform, type Handle, type OnConnectEnd, type UpdateConnection, type IsValidConnection, NodeLookup, FinalConnectionState } from '../types';
export type OnPointerDownParams = {
autoPanOnConnect: boolean;
connectionMode: ConnectionMode;
connectionRadius: number;
domNode: HTMLDivElement | null;
handleId: string | null;
nodeId: string;
isTarget: boolean;
nodeLookup: NodeLookup;
lib: string;
flowId: string | null;
edgeUpdaterType?: HandleType;
updateConnection: UpdateConnection;
panBy: PanBy;
cancelConnection: () => void;
onConnectStart?: OnConnectStart;
onConnect?: OnConnect;
onConnectEnd?: OnConnectEnd;
isValidConnection?: IsValidConnection;
onReconnectEnd?: (evt: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
getTransform: () => Transform;
getFromHandle: () => Handle | null;
autoPanSpeed?: number;
dragThreshold?: number;
handleDomNode: Element;
};
export type IsValidParams = {
handle: Pick<Handle, 'nodeId' | 'id' | 'type'> | null;
connectionMode: ConnectionMode;
fromNodeId: string;
fromHandleId: string | null;
fromType: HandleType;
isValidConnection?: IsValidConnection;
doc: Document | ShadowRoot;
lib: string;
flowId: string | null;
nodeLookup: NodeLookup;
};
export type XYHandleInstance = {
onPointerDown: (event: MouseEvent | TouchEvent, params: OnPointerDownParams) => void;
isValid: (event: MouseEvent | TouchEvent, params: IsValidParams) => Result;
};
export type Result = {
handleDomNode: Element | null;
isValid: boolean;
connection: Connection | null;
toHandle: Handle | null;
};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/xyhandle/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,UAAU,EACV,oBAAoB,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IAC5B,QAAQ,EAAE,UAAU,CAAC;IACrB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,GAAG,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrF,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC"}

View File

@@ -0,0 +1,10 @@
import type { HandleType, XYPosition, Handle, NodeLookup, ConnectionMode } from '../types';
export declare function getClosestHandle(position: XYPosition, connectionRadius: number, nodeLookup: NodeLookup, fromHandle: {
nodeId: string;
type: HandleType;
id?: string | null;
}): Handle | null;
export declare function getHandle(nodeId: string, handleType: HandleType, handleId: string | null, nodeLookup: NodeLookup, connectionMode: ConnectionMode, withAbsolutePosition?: boolean): Handle | null;
export declare function getHandleType(edgeUpdaterType: HandleType | undefined, handleDomNode: Element | null): HandleType | null;
export declare function isConnectionValid(isInsideConnectionRadius: boolean, isHandleValid: boolean): boolean | null;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xyhandle/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAoB,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA0B7G,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,UAAU,EACpB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACnE,MAAM,GAAG,IAAI,CA2Cf;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,oBAAoB,UAAQ,GAC3B,MAAM,GAAG,IAAI,CAef;AAED,wBAAgB,aAAa,CAC3B,eAAe,EAAE,UAAU,GAAG,SAAS,EACvC,aAAa,EAAE,OAAO,GAAG,IAAI,GAC5B,UAAU,GAAG,IAAI,CAUnB;AAED,wBAAgB,iBAAiB,CAAC,wBAAwB,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,kBAU1F"}

View File

@@ -0,0 +1,28 @@
import { pointer } from 'd3-selection';
import type { CoordinateExtent, PanZoomInstance, Transform } from '../types';
export type XYMinimapInstance = {
update: (params: XYMinimapUpdate) => void;
destroy: () => void;
pointer: typeof pointer;
};
export type XYMinimapParams = {
panZoom: PanZoomInstance;
domNode: Element;
getTransform: () => Transform;
getViewScale: () => number;
};
export type XYMinimapUpdate = {
translateExtent: CoordinateExtent;
width: number;
height: number;
inversePan?: boolean;
zoomStep?: number;
pannable?: boolean;
zoomable?: boolean;
};
export declare function XYMinimap({ domNode, panZoom, getTransform, getViewScale }: XYMinimapParams): {
update: ({ translateExtent, width, height, zoomStep, pannable, zoomable, inversePan, }: XYMinimapUpdate) => void;
destroy: () => void;
pointer: typeof pointer;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xyminimap/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG7E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,EAAE,gBAAgB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,eAAe;4FAWtF,eAAe;;;EAqFnB"}

View File

@@ -0,0 +1,12 @@
import { type Viewport, PanZoomParams, PanZoomInstance } from '../types';
export type ZoomPanValues = {
isZoomingOrPanning: boolean;
usedRightMouseButton: boolean;
prevViewport: Viewport;
mouseButton: number;
timerId: ReturnType<typeof setTimeout> | undefined;
panScrollTimeout: ReturnType<typeof setTimeout> | undefined;
isPanScrolling: boolean;
};
export declare function XYPanZoom({ domNode, minZoom, maxZoom, paneClickDistance, translateExtent, viewport, onPanZoom, onPanZoomStart, onPanZoomEnd, onDraggingChange, }: PanZoomParams): PanZoomInstance;
//# sourceMappingURL=XYPanZoom.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"XYPanZoom.d.ts","sourceRoot":"","sources":["../../src/xypanzoom/XYPanZoom.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,QAAQ,EAGb,aAAa,EACb,eAAe,EAChB,MAAM,UAAU,CAAC;AAclB,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IACnD,gBAAgB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IAC5D,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,SAAS,EACT,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,EAAE,aAAa,GAAG,eAAe,CA4PjC"}

View File

@@ -0,0 +1,46 @@
import type { D3ZoomEvent } from 'd3-zoom';
import { PanOnScrollMode, type D3SelectionInstance, type D3ZoomHandler, type D3ZoomInstance, type OnPanZoom, type OnDraggingChange, type OnTransformChange } from '../types';
import { ZoomPanValues } from './XYPanZoom';
export type PanOnScrollParams = {
zoomPanValues: ZoomPanValues;
noWheelClassName: string;
d3Selection: D3SelectionInstance;
d3Zoom: D3ZoomInstance;
panOnScrollMode: PanOnScrollMode;
panOnScrollSpeed: number;
zoomOnPinch: boolean;
onPanZoomStart?: OnPanZoom;
onPanZoom?: OnPanZoom;
onPanZoomEnd?: OnPanZoom;
};
export type ZoomOnScrollParams = {
noWheelClassName: string;
preventScrolling: boolean;
d3ZoomHandler: D3ZoomHandler;
};
export type PanZoomStartParams = {
zoomPanValues: ZoomPanValues;
onDraggingChange: OnDraggingChange;
onPanZoomStart?: OnPanZoom;
};
export type PanZoomParams = {
zoomPanValues: ZoomPanValues;
panOnDrag: boolean | number[];
onPaneContextMenu: boolean;
onTransformChange: OnTransformChange;
onPanZoom?: OnPanZoom;
};
export type PanZoomEndParams = {
zoomPanValues: ZoomPanValues;
panOnDrag: boolean | number[];
panOnScroll: boolean;
onDraggingChange: (isDragging: boolean) => void;
onPanZoomEnd?: OnPanZoom;
onPaneContextMenu?: (event: any) => void;
};
export declare function createPanOnScrollHandler({ zoomPanValues, noWheelClassName, d3Selection, d3Zoom, panOnScrollMode, panOnScrollSpeed, zoomOnPinch, onPanZoomStart, onPanZoom, onPanZoomEnd, }: PanOnScrollParams): (event: any) => false | undefined;
export declare function createZoomOnScrollHandler({ noWheelClassName, preventScrolling, d3ZoomHandler }: ZoomOnScrollParams): (this: Element, event: any, d: unknown) => null | undefined;
export declare function createPanZoomStartHandler({ zoomPanValues, onDraggingChange, onPanZoomStart }: PanZoomStartParams): (event: D3ZoomEvent<HTMLDivElement, any>) => void;
export declare function createPanZoomHandler({ zoomPanValues, panOnDrag, onPaneContextMenu, onTransformChange, onPanZoom, }: PanZoomParams): (event: D3ZoomEvent<HTMLDivElement, any>) => void;
export declare function createPanZoomEndHandler({ zoomPanValues, panOnDrag, panOnScroll, onDraggingChange, onPanZoomEnd, onPaneContextMenu, }: PanZoomEndParams): (event: D3ZoomEvent<HTMLDivElement, any>) => void;
//# sourceMappingURL=eventhandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"eventhandler.d.ts","sourceRoot":"","sources":["../../src/xypanzoom/eventhandler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,aAAa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AAO,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EACvC,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,GACb,EAAE,iBAAiB,WACH,GAAG,uBAsEnB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,kBAAkB,UAC1F,OAAO,SAAS,GAAG,KAAK,OAAO,sBAmBvD;AAED,wBAAgB,yBAAyB,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,kBAAkB,WAChG,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,UAoBhD;AAED,wBAAgB,oBAAoB,CAAC,EACnC,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,GACV,EAAE,aAAa,WACC,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,UAahD;AAED,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GAClB,EAAE,gBAAgB,WACF,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,UAiChD"}

View File

@@ -0,0 +1,15 @@
export type FilterParams = {
zoomActivationKeyPressed: boolean;
zoomOnScroll: boolean;
zoomOnPinch: boolean;
panOnDrag: boolean | number[];
panOnScroll: boolean;
zoomOnDoubleClick: boolean;
userSelectionActive: boolean;
noWheelClassName: string;
noPanClassName: string;
lib: string;
connectionInProgress: boolean;
};
export declare function createFilter({ zoomActivationKeyPressed, zoomOnScroll, zoomOnPinch, panOnDrag, panOnScroll, zoomOnDoubleClick, userSelectionActive, noWheelClassName, noPanClassName, lib, connectionInProgress, }: FilterParams): (event: any) => boolean;
//# sourceMappingURL=filter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/xypanzoom/filter.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,wBAAwB,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,GAAG,EACH,oBAAoB,GACrB,EAAE,YAAY,WACE,GAAG,KAAG,OAAO,CAwE7B"}

View File

@@ -0,0 +1,2 @@
export * from './XYPanZoom';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xypanzoom/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}

View File

@@ -0,0 +1,10 @@
import { type ZoomTransform } from 'd3-zoom';
import { type D3SelectionInstance, type Viewport } from '../types';
export declare const viewChanged: (prevViewport: Viewport, eventViewport: any) => boolean;
export declare const transformToViewport: (transform: ZoomTransform) => Viewport;
export declare const viewportToTransform: ({ x, y, zoom }: Viewport) => ZoomTransform;
export declare const isWrappedWithClass: (event: any, className: string | undefined) => any;
export declare const isRightClickPan: (panOnDrag: boolean | number[], usedButton: number) => boolean;
export declare const getD3Transition: (selection: D3SelectionInstance, duration?: number, ease?: (t: number) => number, onEnd?: () => void) => D3SelectionInstance | import("d3-transition").Transition<Element, unknown, null, undefined>;
export declare const wheelDelta: (event: any) => number;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xypanzoom/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,SAAS,CAAC;AAI3D,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGnE,eAAO,MAAM,WAAW,iBAAkB,QAAQ,iBAAiB,GAAG,KAAG,OAC0C,CAAC;AAEpH,eAAO,MAAM,mBAAmB,cAAe,aAAa,KAAG,QAI7D,CAAC;AAEH,eAAO,MAAM,mBAAmB,mBAAoB,QAAQ,KAAG,aACrB,CAAC;AAE3C,eAAO,MAAM,kBAAkB,UAAW,GAAG,aAAa,MAAM,GAAG,SAAS,QAA0C,CAAC;AAEvH,eAAO,MAAM,eAAe,cAAe,OAAO,GAAG,MAAM,EAAE,cAAc,MAAM,YACV,CAAC;AAKxE,eAAO,MAAM,eAAe,cAAe,mBAAmB,gCAFtC,MAAM,+HAU7B,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,GAAG,WAIpC,CAAC"}

View File

@@ -0,0 +1,49 @@
import type { NodeBase, NodeLookup, NodeOrigin, Transform, XYPosition } from '../types';
import type { OnResize, OnResizeEnd, OnResizeStart, ShouldResize, ControlPosition, ResizeControlDirection } from './types';
export type XYResizerChange = {
x?: number;
y?: number;
width?: number;
height?: number;
};
export type XYResizerChildChange = {
id: string;
position: XYPosition;
extent?: NodeBase['extent'];
};
type XYResizerParams = {
domNode: HTMLDivElement;
nodeId: string;
getStoreItems: () => {
nodeLookup: NodeLookup;
transform: Transform;
snapGrid?: [number, number];
snapToGrid: boolean;
nodeOrigin: NodeOrigin;
paneDomNode: HTMLDivElement | null;
};
onChange: (changes: XYResizerChange, childChanges: XYResizerChildChange[]) => void;
onEnd?: (change: Required<XYResizerChange>) => void;
};
type XYResizerUpdateParams = {
controlPosition: ControlPosition;
boundaries: {
minWidth: number;
minHeight: number;
maxWidth: number;
maxHeight: number;
};
keepAspectRatio: boolean;
resizeDirection?: ResizeControlDirection;
onResizeStart: OnResizeStart | undefined;
onResize: OnResize | undefined;
onResizeEnd: OnResizeEnd | undefined;
shouldResize: ShouldResize | undefined;
};
export type XYResizerInstance = {
update: (params: XYResizerUpdateParams) => void;
destroy: () => void;
};
export declare function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }: XYResizerParams): XYResizerInstance;
export {};
//# sourceMappingURL=XYResizer.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"XYResizer.d.ts","sourceRoot":"","sources":["../../src/xyresizer/XYResizer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,aAAa,EAEb,YAAY,EACZ,eAAe,EACf,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAWjB,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;I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# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xyresizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}

View File

@@ -0,0 +1,59 @@
import type { D3DragEvent, SubjectPosition } from 'd3-drag';
/**
* @public
* @inline
*/
export type ResizeParams = {
x: number;
y: number;
width: number;
height: number;
};
export type ResizeParamsWithDirection = ResizeParams & {
direction: number[];
};
/**
* Used to determine the control line position of the NodeResizer
*
* @public
* @inline
*/
export type ControlLinePosition = 'top' | 'bottom' | 'left' | 'right';
/**
* Used to determine the control position of the NodeResizer
*
* @public
* @inline
*/
export type ControlPosition = ControlLinePosition | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
/**
* Used to determine the variant of the resize control
*
* @public
*/
export declare enum ResizeControlVariant {
Line = "line",
Handle = "handle"
}
/**
* The direction the user can resize the node.
* @public
* @inline
*/
export type ResizeControlDirection = 'horizontal' | 'vertical';
export declare const XY_RESIZER_HANDLE_POSITIONS: ControlPosition[];
export declare const XY_RESIZER_LINE_POSITIONS: ControlLinePosition[];
type OnResizeHandler<Params = ResizeParams, Result = void> = (event: ResizeDragEvent, params: Params) => Result;
export type ResizeDragEvent = D3DragEvent<HTMLDivElement, null, SubjectPosition>;
/**
* Callback to determine if node should resize
*
* @inline
* @public
*/
export type ShouldResize = OnResizeHandler<ResizeParamsWithDirection, boolean>;
export type OnResizeStart = OnResizeHandler;
export type OnResize = OnResizeHandler<ResizeParamsWithDirection>;
export type OnResizeEnd = OnResizeHandler;
export {};
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/xyresizer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;I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osition } from './types';
type GetResizeDirectionParams = {
width: number;
prevWidth: number;
height: number;
prevHeight: number;
affectsX: boolean;
affectsY: boolean;
};
/**
* Get all connecting edges for a given set of nodes
* @param width - new width of the node
* @param prevWidth - previous width of the node
* @param height - new height of the node
* @param prevHeight - previous height of the node
* @param affectsX - whether to invert the resize direction for the x axis
* @param affectsY - whether to invert the resize direction for the y axis
* @returns array of two numbers representing the direction of the resize for each axis, 0 = no change, 1 = increase, -1 = decrease
*/
export declare function getResizeDirection({ width, prevWidth, height, prevHeight, affectsX, affectsY, }: GetResizeDirectionParams): number[];
/**
* Parses the control position that is being dragged to dimensions that are being resized
* @param controlPosition - position of the control that is being dragged
* @returns isHorizontal, isVertical, affectsX, affectsY,
*/
export declare function getControlDirection(controlPosition: ControlPosition): {
isHorizontal: boolean;
isVertical: boolean;
affectsX: boolean;
affectsY: boolean;
};
type PrevValues = {
width: number;
height: number;
x: number;
y: number;
};
type StartValues = PrevValues & {
pointerX: number;
pointerY: number;
aspectRatio: number;
};
/**
* Calculates new width & height and x & y of node after resize based on pointer position
* @description - Buckle up, this is a chunky one... If you want to determine the new dimensions of a node after a resize,
* you have to account for all possible restrictions: min/max width/height of the node, the maximum extent the node is allowed
* to move in (in this case: resize into) determined by the parent node, the minimal extent determined by child nodes
* with expandParent or extent: 'parent' set and oh yeah, these things also have to work with keepAspectRatio!
* The way this is done is by determining how much each of these restricting actually restricts the resize and then applying the
* strongest restriction. Because the resize affects x, y and width, height and width, height of a opposing side with keepAspectRatio,
* the resize amount is always kept in distX & distY amount (the distance in mouse movement)
* Instead of clamping each value, we first calculate the biggest 'clamp' (for the lack of a better name) and then apply it to all values.
* To complicate things nodeOrigin has to be taken into account as well. This is done by offsetting the nodes as if their origin is [0, 0],
* then calculating the restrictions as usual
* @param startValues - starting values of resize
* @param controlDirection - dimensions affected by the resize
* @param pointerPosition - the current pointer position corrected for snapping
* @param boundaries - minimum and maximum dimensions of the node
* @param keepAspectRatio - prevent changes of asprect ratio
* @returns x, y, width and height of the node after resize
*/
export declare function getDimensionsAfterResize(startValues: StartValues, controlDirection: ReturnType<typeof getControlDirection>, pointerPosition: ReturnType<typeof getPointerPosition>, boundaries: {
minWidth: number;
maxWidth: number;
minHeight: number;
maxHeight: number;
}, keepAspectRatio: boolean, nodeOrigin: NodeOrigin, extent?: CoordinateExtent, childExtent?: CoordinateExtent): {
width: number;
height: number;
x: number;
y: number;
};
export {};
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xyresizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB,YAc1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,eAAe;;;;;EAYnE;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,WAAW,GAAG,UAAU,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAkBF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,EACxD,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,EACtD,UAAU,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACxF,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,gBAAgB,EACzB,WAAW,CAAC,EAAE,gBAAgB;;;;;EA8J/B"}

View File

@@ -0,0 +1,43 @@
import { CoordinateExtent, HandleType } from './types';
export declare const errorMessages: {
error001: () => string;
error002: () => string;
error003: (nodeType: string) => string;
error004: () => string;
error005: () => string;
error006: () => string;
error007: (id: string) => string;
error009: (type: string) => string;
error008: (handleType: HandleType, { id, sourceHandle, targetHandle }: {
id: string;
sourceHandle: string | null;
targetHandle: string | null;
}) => string;
error010: () => string;
error011: (edgeType: string) => string;
error012: (id: string) => string;
error013: (lib?: string) => string;
error014: () => string;
error015: () => string;
};
export declare const infiniteExtent: CoordinateExtent;
export declare const elementSelectionKeys: string[];
export declare const defaultAriaLabelConfig: {
'node.a11yDescription.default': string;
'node.a11yDescription.keyboardDisabled': string;
'node.a11yDescription.ariaLiveMessage': ({ direction, x, y }: {
direction: string;
x: number;
y: number;
}) => string;
'edge.a11yDescription.default': string;
'controls.ariaLabel': string;
'controls.zoomIn.ariaLabel': string;
'controls.zoomOut.ariaLabel': string;
'controls.fitView.ariaLabel': string;
'controls.interactive.ariaLabel': string;
'minimap.ariaLabel': string;
'handle.ariaLabel': string;
};
export type AriaLabelConfig = typeof defaultAriaLabelConfig;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,aAAa;;;yBAKH,MAAM;;;;mBAIZ,MAAM;qBACJ,MAAM;2BAET,UAAU,sCACc;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;yBAMzF,MAAM;mBACZ,MAAM;qBAEL,MAAM;;;CAMvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAA2B,CAAC;AAE7D,eAAO,MAAM,sBAAsB;;;kEAK6B;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;CAiB1G,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,sBAAsB,CAAC"}

View File

@@ -0,0 +1,9 @@
export * from './constants';
export * from './types';
export * from './utils';
export * from './xydrag';
export * from './xyhandle';
export * from './xyminimap';
export * from './xypanzoom';
export * from './xyresizer';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,64 @@
import type { XYPosition, Dimensions, NodeBase, EdgeBase } from '.';
export type NodeDimensionChange = {
id: string;
type: 'dimensions';
dimensions?: Dimensions;
resizing?: boolean;
setAttributes?: boolean | 'width' | 'height';
};
export type NodePositionChange = {
id: string;
type: 'position';
position?: XYPosition;
positionAbsolute?: XYPosition;
dragging?: boolean;
};
export type NodeSelectionChange = {
id: string;
type: 'select';
selected: boolean;
};
export type NodeRemoveChange = {
id: string;
type: 'remove';
};
export type NodeAddChange<NodeType extends NodeBase = NodeBase> = {
item: NodeType;
type: 'add';
index?: number;
};
export type NodeReplaceChange<NodeType extends NodeBase = NodeBase> = {
id: string;
item: NodeType;
type: 'replace';
};
/**
* The [`onNodesChange`](/api-reference/react-flow#on-nodes-change) callback takes
*an array of `NodeChange` objects that you should use to update your flow's state.
*The `NodeChange` type is a union of six different object types that represent that
*various ways an node can change in a flow.
* @public
*/
export type NodeChange<NodeType extends NodeBase = NodeBase> = NodeDimensionChange | NodePositionChange | NodeSelectionChange | NodeRemoveChange | NodeAddChange<NodeType> | NodeReplaceChange<NodeType>;
export type EdgeSelectionChange = NodeSelectionChange;
export type EdgeRemoveChange = NodeRemoveChange;
export type EdgeAddChange<EdgeType extends EdgeBase = EdgeBase> = {
item: EdgeType;
type: 'add';
index?: number;
};
export type EdgeReplaceChange<EdgeType extends EdgeBase = EdgeBase> = {
id: string;
item: EdgeType;
type: 'replace';
};
/**
* The [`onEdgesChange`](/api-reference/react-flow#on-edges-change) callback takes
*an array of `EdgeChange` objects that you should use to update your flow's state.
*The `EdgeChange` type is a union of four different object types that represent that
*various ways an edge can change in a flow.
*
* @public
*/
export type EdgeChange<EdgeType extends EdgeBase = EdgeBase> = EdgeSelectionChange | EdgeRemoveChange | EdgeAddChange<EdgeType> | EdgeReplaceChange<EdgeType>;
//# sourceMappingURL=changes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../../src/types/changes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,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C,GACvB,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEhC,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI;IAChE,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IACvD,mBAAmB,GACnB,gBAAgB,GAChB,aAAa,CAAC,QAAQ,CAAC,GACvB,iBAAiB,CAAC,QAAQ,CAAC,CAAC"}

View File

@@ -0,0 +1,114 @@
import { Position } from './utils';
export type EdgeBase<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = {
/** Unique id of an edge. */
id: string;
/** Type of edge defined in `edgeTypes`. */
type?: EdgeType;
/** Id of source node. */
source: string;
/** Id of target node. */
target: string;
/** Id of source handle, only needed if there are multiple handles per node. */
sourceHandle?: string | null;
/** Id of target handle, only needed if there are multiple handles per node. */
targetHandle?: string | null;
animated?: boolean;
hidden?: boolean;
deletable?: boolean;
selectable?: boolean;
/** Arbitrary data passed to an edge. */
data?: EdgeData;
selected?: boolean;
/**
* Set the marker on the beginning of an edge.
* @example 'arrow', 'arrowclosed' or custom marker
*/
markerStart?: EdgeMarkerType;
/**
* Set the marker on the end of an edge.
* @example 'arrow', 'arrowclosed' or custom marker
*/
markerEnd?: EdgeMarkerType;
zIndex?: number;
ariaLabel?: string;
/**
* ReactFlow renders an invisible path around each edge to make them easier to click or tap on.
* This property sets the width of that invisible path.
*/
interactionWidth?: number;
};
export type SmoothStepPathOptions = {
offset?: number;
borderRadius?: number;
stepPosition?: number;
};
export type StepPathOptions = {
offset?: number;
};
export type BezierPathOptions = {
curvature?: number;
};
/**
* @inline
*/
export type DefaultEdgeOptionsBase<EdgeType extends EdgeBase> = Omit<EdgeType, 'id' | 'source' | 'target' | 'sourceHandle' | 'targetHandle' | 'selected'>;
/**
* If you set the `connectionLineType` prop on your [`<ReactFlow />`](/api-reference/react-flow#connection-connectionLineType)
*component, it will dictate the style of connection line rendered when creating
*new edges.
*
* @public
*
* @remarks If you choose to render a custom connection line component, this value will be
*passed to your component as part of its [`ConnectionLineComponentProps`](/api-reference/types/connection-line-component-props).
*/
export declare enum ConnectionLineType {
Bezier = "default",
Straight = "straight",
Step = "step",
SmoothStep = "smoothstep",
SimpleBezier = "simplebezier"
}
/**
* Edges can optionally have markers at the start and end of an edge. The `EdgeMarker`
*type is used to configure those markers! Check the docs for [`MarkerType`](/api-reference/types/marker-type)
*for details on what types of edge marker are available.
*
* @public
*/
export type EdgeMarker = {
type: MarkerType | `${MarkerType}`;
color?: string | null;
width?: number;
height?: number;
markerUnits?: string;
orient?: string;
strokeWidth?: number;
};
export type EdgeMarkerType = string | EdgeMarker;
/**
* Edges may optionally have a marker on either end. The MarkerType type enumerates
* the options available to you when configuring a given marker.
*
* @public
*/
export declare enum MarkerType {
Arrow = "arrow",
ArrowClosed = "arrowclosed"
}
export type MarkerProps = EdgeMarker & {
id: string;
};
/**
* @inline
*/
export type EdgePosition = {
sourceX: number;
sourceY: number;
targetX: number;
targetY: number;
sourcePosition: Position;
targetPosition: Position;
};
export type EdgeLookup<EdgeType extends EdgeBase = EdgeBase> = Map<string, EdgeType>;
//# sourceMappingURL=edges.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/types/edges.ts"],"names":[],"mappings":"AA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MAAM,UAAU,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}

View File

@@ -0,0 +1,284 @@
import type { Selection as D3Selection } from 'd3-selection';
import type { D3DragEvent, SubjectPosition } from 'd3-drag';
import type { ZoomBehavior } from 'd3-zoom';
import type { XYPosition, Rect, Position } from './utils';
import type { InternalNodeBase, NodeBase, NodeDragItem } from './nodes';
import type { Handle, HandleType } from './handles';
import { PanZoomInstance } from './panzoom';
import { EdgeBase } from '..';
export type Project = (position: XYPosition) => XYPosition;
/**
* This type is used to define the `onMove` handler.
*/
export type OnMove = (event: MouseEvent | TouchEvent | null, viewport: Viewport) => void;
export type OnMoveStart = OnMove;
export type OnMoveEnd = OnMove;
/**
* @inline
*/
export type ZoomInOut = (options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* @inline
*/
export type ZoomTo = (zoomLevel: number, options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* @inline
*/
export type GetZoom = () => number;
/**
* @inline
*/
export type GetViewport = () => Viewport;
/**
* The `SetViewport` function is used to set the viewport of the flow.
*
* @inline
* @param viewport - The viewport to set.
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type SetViewport = (viewport: Viewport, options?: ViewportHelperFunctionOptions) => Promise<boolean>;
/**
* The `SetCenter` function is used to set the center of the flow viewport to a specific position
*
* @inline
* @param x - x coordinate
* @param y - y coordinate
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type SetCenter = (x: number, y: number, options?: SetCenterOptions) => Promise<boolean>;
/**
* The `FitBounds` function is used to fit the flow viewport to the bounds of the nodes.
*
* @inline
* @param bounds - The bounds to fit the viewport to.
* @param options - Optional parameters to control the animation and easing of the viewport change.
*/
export type FitBounds = (bounds: Rect, options?: FitBoundsOptions) => Promise<boolean>;
/**
* The `Connection` type is the basic minimal description of an [`Edge`](/api-reference/types/edge)
* between two nodes. The [`addEdge`](/api-reference/utils/add-edge) util can be used to upgrade
* a `Connection` to an [`Edge`](/api-reference/types/edge).
*
* @public
*/
export type Connection = {
/** The id of the node this connection originates from. */
source: string;
/** The id of the node this connection terminates at. */
target: string;
/** When not `null`, the id of the handle on the source node that this connection originates from. */
sourceHandle: string | null;
/** When not `null`, the id of the handle on the target node that this connection terminates at. */
targetHandle: string | null;
};
/**
* The `HandleConnection` type is an extension of a basic [Connection](/api-reference/types/connection) that includes the `edgeId`.
*/
export type HandleConnection = Connection & {
edgeId: string;
};
/**
* The `NodeConnection` type is an extension of a basic [Connection](/api-reference/types/connection) that includes the `edgeId`.
*
*/
export type NodeConnection = Connection & {
edgeId: string;
};
/**
* The `ConnectionMode` is used to set the mode of connection between nodes.
* The `Strict` mode is the default one and only allows source to target edges.
* `Loose` mode allows source to source and target to target edges as well.
*
* @public
*/
export declare enum ConnectionMode {
Strict = "strict",
Loose = "loose"
}
export type OnConnectStartParams = {
nodeId: string | null;
handleId: string | null;
handleType: HandleType | null;
};
export type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
export type OnConnect = (connection: Connection) => void;
export type OnConnectEnd = (event: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
export type OnReconnect<EdgeType extends EdgeBase = EdgeBase> = (oldEdge: EdgeType, newConnection: Connection) => void;
export type OnReconnectStart<EdgeType extends EdgeBase = EdgeBase> = (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType) => void;
export type OnReconnectEnd<EdgeType extends EdgeBase = EdgeBase> = (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType, connectionState: FinalConnectionState) => void;
export type IsValidConnection = (edge: EdgeBase | Connection) => boolean;
/**
* @inline
*/
export type FitViewParamsBase<NodeType extends NodeBase> = {
nodes: Map<string, InternalNodeBase<NodeType>>;
width: number;
height: number;
panZoom: PanZoomInstance;
minZoom: number;
maxZoom: number;
};
export type PaddingUnit = 'px' | '%';
export type PaddingWithUnit = `${number}${PaddingUnit}` | number;
export type Padding = PaddingWithUnit | {
top?: PaddingWithUnit;
right?: PaddingWithUnit;
bottom?: PaddingWithUnit;
left?: PaddingWithUnit;
x?: PaddingWithUnit;
y?: PaddingWithUnit;
};
/**
* @inline
*/
export type FitViewOptionsBase<NodeType extends NodeBase = NodeBase> = {
padding?: Padding;
includeHiddenNodes?: boolean;
minZoom?: number;
maxZoom?: number;
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
nodes?: (NodeType | {
id: string;
})[];
};
/**
* Internally, React Flow maintains a coordinate system that is independent of the
* rest of the page. The `Viewport` type tells you where in that system your flow
* is currently being display at and how zoomed in or out it is.
*
* @public
* @remarks A `Transform` has the same properties as the viewport, but they represent
* different things. Make sure you don't get them muddled up or things will start
* to look weird!
*
*/
export type Viewport = {
x: number;
y: number;
zoom: number;
};
export type KeyCode = string | Array<string>;
export type SnapGrid = [number, number];
/**
* This enum is used to set the different modes of panning the viewport when the
* user scrolls. The `Free` mode allows the user to pan in any direction by scrolling
* with a device like a trackpad. The `Vertical` and `Horizontal` modes restrict
* scroll panning to only the vertical or horizontal axis, respectively.
*
* @public
*/
export declare enum PanOnScrollMode {
Free = "free",
Vertical = "vertical",
Horizontal = "horizontal"
}
/**
* @inline
*/
export type ViewportHelperFunctionOptions = {
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
};
/**
* @inline
*/
export type SetCenterOptions = ViewportHelperFunctionOptions & {
zoom?: number;
};
/**
* @inline
*/
export type FitBoundsOptions = ViewportHelperFunctionOptions & {
padding?: number;
};
export type OnViewportChange = (viewport: Viewport) => void;
export type D3ZoomInstance = ZoomBehavior<Element, unknown>;
export type D3SelectionInstance = D3Selection<Element, unknown, null, undefined>;
export type D3ZoomHandler = (this: Element, event: any, d: unknown) => void;
export type UpdateNodeInternals = (nodeId: string | string[]) => void;
/**
* This type is mostly used to help position things on top of the flow viewport. For
* example both the [`<MiniMap />`](/api-reference/components/minimap) and
* [`<Controls />`](/api-reference/components/controls) components take a `position`
* prop of this type.
*
* @public
*/
export type PanelPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-right';
export type ProOptions = {
account?: string;
hideAttribution: boolean;
};
export type UseDragEvent = D3DragEvent<HTMLDivElement, null, SubjectPosition>;
export declare enum SelectionMode {
Partial = "partial",
Full = "full"
}
export type SelectionRect = Rect & {
startX: number;
startY: number;
};
export type OnError = (id: string, message: string) => void;
export type UpdateNodePositions = (dragItems: Map<string, NodeDragItem | InternalNodeBase>, dragging?: boolean) => void;
export type PanBy = (delta: XYPosition) => Promise<boolean>;
export declare const initialConnection: NoConnection;
export type NoConnection = {
inProgress: false;
isValid: null;
from: null;
fromHandle: null;
fromPosition: null;
fromNode: null;
to: null;
toHandle: null;
toPosition: null;
toNode: null;
};
export type ConnectionInProgress<NodeType extends InternalNodeBase = InternalNodeBase> = {
/** Indicates whether a connection is currently in progress. */
inProgress: true;
/**
* If an ongoing connection is above a handle or inside the connection radius, this will be `true`
* or `false`, otherwise `null`.
*/
isValid: boolean | null;
/** Returns the xy start position or `null` if no connection is in progress. */
from: XYPosition;
/** Returns the start handle or `null` if no connection is in progress. */
fromHandle: Handle;
/** Returns the side (called position) of the start handle or `null` if no connection is in progress. */
fromPosition: Position;
/** Returns the start node or `null` if no connection is in progress. */
fromNode: NodeType;
/** Returns the xy end position or `null` if no connection is in progress. */
to: XYPosition;
/** Returns the end handle or `null` if no connection is in progress. */
toHandle: Handle | null;
/** Returns the side (called position) of the end handle or `null` if no connection is in progress. */
toPosition: Position;
/** Returns the end node or `null` if no connection is in progress. */
toNode: NodeType | null;
};
/**
* The `ConnectionState` type bundles all information about an ongoing connection.
* It is returned by the [`useConnection`](/api-reference/hooks/use-connection) hook.
*
* @public
*/
export type ConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = ConnectionInProgress<NodeType> | NoConnection;
export type FinalConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = Omit<ConnectionState<NodeType>, 'inProgress'>;
export type UpdateConnection<NodeType extends InternalNodeBase = InternalNodeBase> = (params: ConnectionState<NodeType>) => void;
export type ColorModeClass = 'light' | 'dark';
export type ColorMode = ColorModeClass | 'system';
export type ConnectionLookup = Map<string, Map<string, HandleConnection>>;
export type OnBeforeDeleteBase<NodeType extends NodeBase = NodeBase, EdgeType extends EdgeBase = EdgeBase> = ({ nodes, edges, }: {
nodes: NodeType[];
edges: EdgeType[];
}) => Promise<boolean | {
nodes: NodeType[];
edges: EdgeType[];
}>;
//# sourceMappingURL=general.d.ts.map

Some files were not shown because too many files have changed in this diff Show More