feat(core): allow setting node/edge type with generic
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -147,20 +147,29 @@ export interface EdgePositions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Internal edge type */
|
/** Internal edge type */
|
||||||
export type GraphEdge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> = Edge<Data, CustomEvents> & {
|
export type GraphEdge<
|
||||||
|
Data = ElementData,
|
||||||
|
CustomEvents extends Record<string, CustomEvent> = any,
|
||||||
|
Type extends string = string,
|
||||||
|
> = Edge<Data, CustomEvents> & {
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
sourceNode: GraphNode
|
sourceNode: GraphNode
|
||||||
targetNode: GraphNode
|
targetNode: GraphNode
|
||||||
data: Data
|
data: Data
|
||||||
events: Partial<EdgeEventsHandler<CustomEvents>>
|
events: Partial<EdgeEventsHandler<CustomEvents>>
|
||||||
|
type: Type
|
||||||
} & EdgePositions
|
} & EdgePositions
|
||||||
|
|
||||||
/** these props are passed to edge components */
|
/** these props are passed to edge components */
|
||||||
export interface EdgeProps<Data = ElementData, CustomEvents = {}> extends EdgeLabelOptions, EdgePositions {
|
export interface EdgeProps<Data = ElementData, CustomEvents = {}, Type extends string = string>
|
||||||
|
extends EdgeLabelOptions,
|
||||||
|
EdgePositions {
|
||||||
id: string
|
id: string
|
||||||
sourceNode: GraphNode
|
sourceNode: GraphNode
|
||||||
targetNode: GraphNode
|
targetNode: GraphNode
|
||||||
type?: keyof DefaultEdgeTypes | string
|
source: string
|
||||||
|
target: string
|
||||||
|
type?: Type
|
||||||
label?: string | VNode | Component<EdgeTextProps> | Object
|
label?: string | VNode | Component<EdgeTextProps> | Object
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
@@ -168,8 +177,6 @@ export interface EdgeProps<Data = ElementData, CustomEvents = {}> extends EdgeLa
|
|||||||
targetPosition: Position
|
targetPosition: Position
|
||||||
sourceHandleId?: string
|
sourceHandleId?: string
|
||||||
targetHandleId?: string
|
targetHandleId?: string
|
||||||
source: string
|
|
||||||
target: string
|
|
||||||
animated?: boolean
|
animated?: boolean
|
||||||
updatable?: boolean
|
updatable?: boolean
|
||||||
markerStart: string
|
markerStart: string
|
||||||
|
|||||||
@@ -86,8 +86,11 @@ export interface Node<Data = ElementData, CustomEvents extends Record<string, Cu
|
|||||||
ariaLabel?: string
|
ariaLabel?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GraphNode<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>
|
export interface GraphNode<
|
||||||
extends Node<Data, CustomEvents> {
|
Data = ElementData,
|
||||||
|
CustomEvents extends Record<string, CustomEvent> = any,
|
||||||
|
Type extends string = string,
|
||||||
|
> extends Node<Data, CustomEvents> {
|
||||||
/** absolute position in relation to parent elements + z-index */
|
/** absolute position in relation to parent elements + z-index */
|
||||||
computedPosition: XYZPosition
|
computedPosition: XYZPosition
|
||||||
handleBounds: NodeHandleBounds
|
handleBounds: NodeHandleBounds
|
||||||
@@ -100,14 +103,15 @@ export interface GraphNode<Data = ElementData, CustomEvents extends Record<strin
|
|||||||
initialized: boolean
|
initialized: boolean
|
||||||
data: Data
|
data: Data
|
||||||
events: Partial<NodeEventsHandler<CustomEvents>>
|
events: Partial<NodeEventsHandler<CustomEvents>>
|
||||||
|
type: Type
|
||||||
}
|
}
|
||||||
|
|
||||||
/** these props are passed to node components */
|
/** these props are passed to node components */
|
||||||
export interface NodeProps<Data = ElementData, CustomEvents = {}> {
|
export interface NodeProps<Data = ElementData, CustomEvents = {}, Type extends string = keyof DefaultNodeTypes> {
|
||||||
/** unique node id */
|
/** unique node id */
|
||||||
id: string
|
id: string
|
||||||
/** node type */
|
/** node type */
|
||||||
type: keyof DefaultNodeTypes | string
|
type?: Type
|
||||||
/** is node selected */
|
/** is node selected */
|
||||||
selected: boolean
|
selected: boolean
|
||||||
/** can node handles be connected */
|
/** can node handles be connected */
|
||||||
|
|||||||
Reference in New Issue
Block a user