diff --git a/packages/vue-flow/src/types/components.ts b/packages/vue-flow/src/types/components.ts index c67882a8..fd731ec3 100644 --- a/packages/vue-flow/src/types/components.ts +++ b/packages/vue-flow/src/types/components.ts @@ -1,5 +1,5 @@ import type { CSSProperties, Component, DefineComponent, SVGAttributes, VNode } from 'vue' -import type { BackgroundVariant, Dimensions, ElementData, XYPosition } from './flow' +import type { BackgroundVariant, Dimensions, XYPosition } from './flow' import type { GraphNode, NodeProps } from './node' import type { EdgeProps } from './edge' import type { FitViewParams } from './zoom' @@ -8,16 +8,10 @@ import type { FitViewParams } from './zoom' type GlobalComponentName = string /** Node Components can either be a component definition or a string name */ -export type NodeComponent = - | Component> - | DefineComponent, any, any, any, any> - | GlobalComponentName +export type NodeComponent = Component | DefineComponent | GlobalComponentName /** Edge Components can either be a component definition or a string name */ -export type EdgeComponent = - | Component> - | DefineComponent, any, any, any, any, any> - | GlobalComponentName +export type EdgeComponent = Component | DefineComponent | GlobalComponentName export type DefaultEdgeTypes = { [key in 'default' | 'straight' | 'smoothstep' | 'step' | 'simplebezier']: EdgeComponent } export type DefaultNodeTypes = { [key in 'input' | 'output' | 'default']: NodeComponent } @@ -55,20 +49,20 @@ export interface ControlProps { } /** expects a node and returns a color value */ -export type MiniMapNodeFunc = (node: GraphNode) => string +export type MiniMapNodeFunc = (node: GraphNode) => string // hack for vue-type imports -type MiniMapNodeFunc2 = (node: GraphNode) => string -type MiniMapNodeFunc3 = (node: GraphNode) => string +type MiniMapNodeFunc2 = (node: GraphNode) => string +type MiniMapNodeFunc3 = (node: GraphNode) => string export type ShapeRendering = CSSProperties['shapeRendering'] -export interface MiniMapProps { +export interface MiniMapProps { /** Node color, can be either a string or a string func that receives the current node */ - nodeColor?: string | MiniMapNodeFunc + nodeColor?: string | MiniMapNodeFunc /** Node stroke color, can be either a string or a string func that receives the current node */ - nodeStrokeColor?: string | MiniMapNodeFunc2 + nodeStrokeColor?: string | MiniMapNodeFunc2 /** Additional node class name, can be either a string or a string func that receives the current node */ - nodeClassName?: string | MiniMapNodeFunc3 + nodeClassName?: string | MiniMapNodeFunc3 /** Node border radius */ nodeBorderRadius?: number /** Node stroke width */ diff --git a/packages/vue-flow/src/types/edge.ts b/packages/vue-flow/src/types/edge.ts index 4fd54641..f8df1997 100644 --- a/packages/vue-flow/src/types/edge.ts +++ b/packages/vue-flow/src/types/edge.ts @@ -2,6 +2,7 @@ import type { CSSProperties, Component, VNode } from 'vue' import type { ClassFunc, ElementData, Position, StyleFunc, Styles } from './flow' import type { GraphNode } from './node' import type { DefaultEdgeTypes, EdgeComponent, EdgeTextProps } from './components' +import type { CustomEvent, EdgeEventsHandler, EdgeEventsOn } from "./hooks"; /** Edge markers */ export enum MarkerType { @@ -42,7 +43,7 @@ export interface MarkerProps { export type EdgeMarkerType = string | MarkerType | EdgeMarker -export interface Edge { +export interface Edge = any> { /** Unique edge id */ id: string /** An edge label */ @@ -82,15 +83,17 @@ export interface Edge { /** Disable/enable selecting edge */ selectable?: boolean /** Additional class names, can be a string or a callback returning a string (receives current flow element) */ - class?: string | ClassFunc> + class?: string | ClassFunc> /** Additional styles, can be an object or a callback returning an object (receives current flow element) */ - style?: Styles | StyleFunc> + style?: Styles | StyleFunc> /** Is edge hidden */ hidden?: boolean /** 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> } export type DefaultEdgeOptions = Omit< @@ -106,7 +109,7 @@ export interface EdgePositions { } /** Internal edge type */ -export type GraphEdge = Edge & { +export type GraphEdge = any> = Edge & { selected?: boolean z?: number sourceNode: GraphNode @@ -114,13 +117,12 @@ export type GraphEdge = Edge & { } & EdgePositions /** these props are passed to edge components */ -export interface EdgeProps { +export interface EdgeProps { id: string sourceNode: GraphNode targetNode: GraphNode label?: string | VNode | Component | Object type?: string - data?: Data style?: CSSProperties sourceX: number sourceY: number @@ -143,16 +145,18 @@ export interface EdgeProps { markerStart?: string markerEnd?: string curvature?: number + data?: Data + /** contextual and custom events of edge */ + events?: Partial> } /** these props are passed to smooth step edges */ -export interface SmoothStepEdgeProps extends EdgeProps { +export interface SmoothStepEdgeProps extends EdgeProps { id: string sourceNode: GraphNode targetNode: GraphNode label?: string | VNode | Component | Object type?: string - data?: Data style?: CSSProperties sourceX: number sourceY: number @@ -175,6 +179,9 @@ export interface SmoothStepEdgeProps extends EdgeProps markerStart?: string markerEnd?: string borderRadius?: number + data?: Data + /** contextual and custom events of edge */ + events?: Partial> } export interface BaseEdgeProps { diff --git a/packages/vue-flow/src/types/node.ts b/packages/vue-flow/src/types/node.ts index f4a85273..7fbbd664 100644 --- a/packages/vue-flow/src/types/node.ts +++ b/packages/vue-flow/src/types/node.ts @@ -12,13 +12,9 @@ export interface NodeHandleBounds { target?: HandleElement[] } -export type WidthFunc = any> = ( - node: GraphNode, -) => number | string | void +export type WidthFunc = (node: GraphNode) => number | string | void -export type HeightFunc = any> = ( - node: GraphNode, -) => number | string | void +export type HeightFunc = (node: GraphNode) => number | string | void export interface Node = any> { /** Unique node id */ @@ -55,14 +51,14 @@ export interface Node width: 300px) * or pass a string with units (width: `10rem` -> width: 10rem) */ - width?: number | string | WidthFunc + width?: number | string | WidthFunc /** * Fixed height of node, applied as style * You can pass a number which will be used in pixel values (height: 300 -> height: 300px) * or pass a string with units (height: `10rem` -> height: 10rem) */ - height?: number | string | HeightFunc + height?: number | string | HeightFunc /** Additional class names, can be a string or a callback returning a string (receives current flow element) */ class?: string | ClassFunc> @@ -71,7 +67,7 @@ export interface Node