fix(core): add missing Type generic to edge types
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import type { CSSProperties, Component, VNode } from 'vue'
|
import type { CSSProperties, Component, VNode } from 'vue'
|
||||||
import type { ClassFunc, ElementData, Position, StyleFunc, Styles } from './flow'
|
import type { ClassFunc, ElementData, Position, StyleFunc, Styles } from './flow'
|
||||||
import type { GraphNode } from './node'
|
import type { GraphNode } from './node'
|
||||||
import type { DefaultEdgeTypes, EdgeComponent, EdgeTextProps } from './components'
|
import type { EdgeComponent, EdgeTextProps } from './components'
|
||||||
import type { CustomEvent, EdgeEventsHandler, EdgeEventsOn } from './hooks'
|
import type { CustomEvent, EdgeEventsHandler, EdgeEventsOn } from './hooks'
|
||||||
|
|
||||||
/** Edge markers */
|
/** Edge markers */
|
||||||
@@ -58,14 +58,17 @@ export interface EdgeLabelOptions {
|
|||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DefaultEdge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>
|
export interface DefaultEdge<
|
||||||
extends EdgeLabelOptions {
|
Data = ElementData,
|
||||||
|
CustomEvents extends Record<string, CustomEvent> = any,
|
||||||
|
Type extends string = string,
|
||||||
|
> extends EdgeLabelOptions {
|
||||||
/** Unique edge id */
|
/** Unique edge id */
|
||||||
id: string
|
id: string
|
||||||
/** An edge label */
|
/** An edge label */
|
||||||
label?: string | VNode | Component<EdgeTextProps>
|
label?: string | VNode | Component<EdgeTextProps>
|
||||||
/** Edge type, can be a default type or a custom type */
|
/** Edge type, can be a default type or a custom type */
|
||||||
type?: keyof DefaultEdgeTypes | string
|
type?: Type
|
||||||
/** Source node id */
|
/** Source node id */
|
||||||
source: string
|
source: string
|
||||||
/** Target node id */
|
/** Target node id */
|
||||||
@@ -132,8 +135,8 @@ export type BezierEdgeType<Data = ElementData, CustomEvents extends Record<strin
|
|||||||
pathOptions?: BezierPathOptions
|
pathOptions?: BezierPathOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Edge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> =
|
export type Edge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any, Type extends string = string> =
|
||||||
| DefaultEdge<Data, CustomEvents>
|
| DefaultEdge<Data, CustomEvents, Type>
|
||||||
| SmoothStepEdgeType<Data, CustomEvents>
|
| SmoothStepEdgeType<Data, CustomEvents>
|
||||||
| BezierEdgeType<Data, CustomEvents>
|
| BezierEdgeType<Data, CustomEvents>
|
||||||
|
|
||||||
@@ -217,3 +220,9 @@ export type SmoothStepEdgeProps = EdgePositions &
|
|||||||
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
|
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
|
||||||
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'> &
|
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'> &
|
||||||
SmoothStepPathOptions
|
SmoothStepPathOptions
|
||||||
|
|
||||||
|
export type ToGraphEdge<T extends Edge> = GraphEdge<
|
||||||
|
T extends Edge<infer Data> ? Data : never,
|
||||||
|
T extends Edge<never, infer CustomEvents> ? CustomEvents : never,
|
||||||
|
T extends Edge<never, never, infer Type> ? Type : never
|
||||||
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user