import type { CSSProperties, Component, VNode, VNodeRef } from 'vue' import type { ClassFunc, ElementData, Position, StyleFunc, Styles } from './flow' import type { GraphNode } from './node' import type { EdgeComponent, EdgeTextProps } from './components' import type { CustomEvent, EdgeEventsHandler, EdgeEventsOn } from './hooks' /** Edge markers */ export declare enum MarkerType { Arrow = 'arrow', ArrowClosed = 'arrowclosed', } /** Edge marker definition */ export interface EdgeMarker { /** Unique marker id */ id?: string /** Marker type */ type: MarkerType /** Marker color */ color?: string /** Marker width */ width?: number /** Marker height */ height?: number /** Marker units */ markerUnits?: string /** Marker orientation */ orient?: string /** Marker stroke width */ strokeWidth?: number } export interface MarkerProps { id: string type: MarkerType | string color?: string width?: number height?: number markerUnits?: string orient?: string strokeWidth?: number } export type EdgeMarkerType = string | MarkerType | EdgeMarker export type EdgeUpdatable = boolean | 'target' | 'source' export interface EdgeLabelOptions { /** Label styles (CSSProperties) */ labelStyle?: CSSProperties /** Show label bg */ labelShowBg?: boolean /** Label Bg styles (CSSProperties) */ labelBgStyle?: CSSProperties /** Label Bg padding */ labelBgPadding?: [number, number] /** Label Bg border radius */ labelBgBorderRadius?: number } export interface DefaultEdge< Data = ElementData, CustomEvents extends Record = any, Type extends string = string, > extends EdgeLabelOptions { /** Unique edge id */ id: string /** An edge label */ label?: string | VNode | Component /** Edge type, can be a default type or a custom type */ type?: Type /** Source node id */ source: string /** Target node id */ target: string /** Source handle id */ sourceHandle?: string | null /** Target handle id */ targetHandle?: string | null /** Animated edge */ animated?: boolean /** EdgeMarker */ markerStart?: EdgeMarkerType /** EdgeMarker */ markerEnd?: EdgeMarkerType /** Disable/enable updating edge */ updatable?: EdgeUpdatable /** Disable/enable selecting edge */ selectable?: boolean /** Disable/enable focusing edge (a11y) */ focusable?: boolean /** Disable/enable deleting edge */ deletable?: boolean /** Additional class names, can be a string or a callback returning a string (receives current flow element) */ class?: string | ClassFunc> /** Additional styles, can be an object or a callback returning an object (receives current flow element) */ style?: Styles | StyleFunc> /** Is edge hidden */ hidden?: boolean /** Radius of mouse event triggers (to ease selecting edges), defaults to 2 */ interactionWidth?: number /** Overwrites current edge type */ template?: EdgeComponent /** Additional data that is passed to your custom components */ data?: Data /** contextual and custom events of edge */ events?: Partial> /** Aria label for edge (a11y) */ zIndex?: number ariaLabel?: string | null } export interface SmoothStepPathOptions { offset?: number borderRadius?: number } export type SmoothStepEdgeType = any> = DefaultEdge< Data, CustomEvents > & { type: 'smoothstep' pathOptions?: SmoothStepPathOptions } export interface BezierPathOptions { curvature?: number } export type BezierEdgeType = any> = DefaultEdge< Data, CustomEvents > & { type: 'default' pathOptions?: BezierPathOptions } export type Edge = any, Type extends string = string> = | DefaultEdge | SmoothStepEdgeType | BezierEdgeType export type DefaultEdgeOptions = Omit export interface EdgePositions { sourceX: number sourceY: number targetX: number targetY: number } /** Internal edge type */ export type GraphEdge< Data = ElementData, CustomEvents extends Record = any, Type extends string = string, > = Edge & { selected: boolean sourceNode: GraphNode targetNode: GraphNode data: Data events: Partial> type: Type } & EdgePositions /** these props are passed to edge components */ export interface EdgeProps extends EdgeLabelOptions, EdgePositions { id: string sourceNode: GraphNode targetNode: GraphNode source: string target: string type: Type label?: string | VNode | Component | Object style?: CSSProperties selected?: boolean sourcePosition: Position targetPosition: Position sourceHandleId?: string targetHandleId?: string animated?: boolean updatable?: boolean markerStart: string markerEnd: string curvature?: number interactionWidth?: number data: Data /** contextual and custom events of edge */ events: EdgeEventsOn } export interface BaseEdgeProps extends EdgeLabelOptions { id?: string labelX?: number labelY?: number path: string label?: any markerStart?: string markerEnd?: string interactionWidth?: number style?: CSSProperties ref?: VNodeRef } export type BezierEdgeProps = EdgePositions & BezierPathOptions & Omit & Pick export type SimpleBezierEdgeProps = EdgePositions & Omit & Pick export type StraightEdgeProps = EdgePositions & Omit export type StepEdgeProps = EdgePositions & Omit & Pick export type SmoothStepEdgeProps = EdgePositions & Omit & Pick & SmoothStepPathOptions export type ToGraphEdge = GraphEdge< T extends Edge ? Data : never, T extends Edge ? CustomEvents : never, T extends Edge ? Type : never >