feat(core,edges): add pathOptions to edge types

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-18 21:06:02 +01:00
committed by Braks
parent 699d7861ce
commit 58ede7355e

View File

@@ -45,7 +45,20 @@ export type EdgeMarkerType = string | MarkerType | EdgeMarker
export type EdgeUpdatable = boolean | 'target' | 'source'
export interface Edge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> {
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
}
interface DefaultEdge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> extends EdgeLabelOptions {
/** Unique edge id */
id: string
/** An edge label */
@@ -60,16 +73,6 @@ export interface Edge<Data = ElementData, CustomEvents extends Record<string, Cu
sourceHandle?: string | null
/** Target handle id */
targetHandle?: string | null
/** 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
/** Animated edge */
animated?: boolean
/** EdgeMarker */
@@ -96,6 +99,36 @@ export interface Edge<Data = ElementData, CustomEvents extends Record<string, Cu
events?: Partial<EdgeEventsHandler<CustomEvents>>
}
export interface SmoothStepPathOptions {
offset?: number
borderRadius?: number
}
type SmoothStepEdgeType<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> = DefaultEdge<
Data,
CustomEvents
> & {
type: 'smoothstep'
pathOptions?: SmoothStepPathOptions
}
export interface BezierPathOptions {
curvature?: number
}
type BezierEdgeType<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> = DefaultEdge<
Data,
CustomEvents
> & {
type: 'default'
pathOptions?: BezierPathOptions
}
export type Edge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any> =
| DefaultEdge<Data, CustomEvents>
| SmoothStepEdgeType<Data, CustomEvents>
| BezierEdgeType<Data, CustomEvents>
export type DefaultEdgeOptions = Omit<Edge, 'id' | 'source' | 'target' | 'sourceHandle' | 'targetHandle'>
export interface EdgePositions {