fix(core,edges): correct edge component prop types

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-29 09:32:27 +01:00
committed by Braks
parent da9ec23188
commit 608f797527
9 changed files with 44 additions and 35 deletions
@@ -1,9 +1,14 @@
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
import type { EdgeProps } from '~/types' import type { BaseEdgeProps, BezierPathOptions, EdgePositions, EdgeProps } from '~/types'
const BezierEdge: FunctionalComponent<EdgeProps> = function ( export type BezierEdgeProps = EdgePositions &
BezierPathOptions &
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'>
const BezierEdge: FunctionalComponent<BezierEdgeProps> = function (
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props }, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
{ attrs }, { attrs },
) { ) {
@@ -1,9 +1,13 @@
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
import type { EdgeProps } from '~/types' import type { BaseEdgeProps, EdgePositions, EdgeProps } from '~/types'
const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ( export type SimpleBezierEdgeProps = EdgePositions &
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'>
const SimpleBezierEdge: FunctionalComponent<SimpleBezierEdgeProps> = function (
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props }, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
{ attrs }, { attrs },
) { ) {
@@ -1,8 +1,13 @@
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import type { SmoothStepEdgeProps } from '~/types' import type { BaseEdgeProps, EdgePositions, EdgeProps, SmoothStepPathOptions } from '~/types'
import { Position } from '~/types' import { Position } from '~/types'
export type SmoothStepEdgeProps = EdgePositions &
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'> &
SmoothStepPathOptions
const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ( const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function (
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props }, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
{ attrs }, { attrs },
@@ -39,6 +44,7 @@ SmoothStepEdge.props = [
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'interactionWidth', 'interactionWidth',
'offset',
] ]
SmoothStepEdge.inheritAttrs = false SmoothStepEdge.inheritAttrs = false
@@ -1,8 +1,12 @@
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import SmoothStepEdge from './SmoothStepEdge' import SmoothStepEdge from './SmoothStepEdge'
import type { EdgeProps } from '~/types' import type { BaseEdgeProps, EdgePositions, EdgeProps } from '~/types'
const StepEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) { export type StepEdgeProps = EdgePositions &
Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'> &
Pick<EdgeProps, 'sourcePosition' | 'targetPosition'>
const StepEdge: FunctionalComponent<StepEdgeProps> = function (props, { attrs }) {
return h(SmoothStepEdge, { ...props, ...attrs, borderRadius: 0 }) return h(SmoothStepEdge, { ...props, ...attrs, borderRadius: 0 })
} }
@@ -1,8 +1,10 @@
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import type { EdgeProps } from '~/types' import type { BaseEdgeProps, EdgePositions } from '~/types'
const StraightEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) { export type StraightEdgeProps = EdgePositions & Omit<BaseEdgeProps, 'labelX' | 'labelY' | 'path'>
const StraightEdge: FunctionalComponent<StraightEdgeProps> = function (props, { attrs }) {
const [path, labelX, labelY] = getStraightPath(props) const [path, labelX, labelY] = getStraightPath(props)
return h(BaseEdge, { return h(BaseEdge, {
+5 -5
View File
@@ -1,9 +1,9 @@
export { default as BaseEdge } from './BaseEdge' export { default as BaseEdge } from './BaseEdge'
export { default as BezierEdge } from './BezierEdge' export { default as BezierEdge, BezierEdgeProps } from './BezierEdge'
export { default as SimpleBezierEdge } from './SimpleBezierEdge' export { default as SimpleBezierEdge, SimpleBezierEdgeProps } from './SimpleBezierEdge'
export { default as StepEdge } from './StepEdge' export { default as StepEdge, StepEdgeProps } from './StepEdge'
export { default as SmoothStepEdge } from './SmoothStepEdge' export { default as SmoothStepEdge, SmoothStepEdgeProps } from './SmoothStepEdge'
export { default as StraightEdge } from './StraightEdge' export { default as StraightEdge, StraightEdgeProps } from './StraightEdge'
export { default as EdgeAnchor } from './EdgeAnchor' export { default as EdgeAnchor } from './EdgeAnchor'
export { default as EdgeText } from './EdgeText.vue' export { default as EdgeText } from './EdgeText.vue'
export { default as EdgeWrapper } from './EdgeWrapper' export { default as EdgeWrapper } from './EdgeWrapper'
+5
View File
@@ -11,10 +11,15 @@ export { default as Panel } from './components/Panel/Panel.vue'
export { export {
StraightEdge, StraightEdge,
StraightEdgeProps,
StepEdge, StepEdge,
StepEdgeProps,
BezierEdge, BezierEdge,
BezierEdgeProps,
SimpleBezierEdge, SimpleBezierEdge,
SimpleBezierEdgeProps,
SmoothStepEdge, SmoothStepEdge,
SmoothStepEdgeProps,
BaseEdge, BaseEdge,
EdgeText, EdgeText,
EdgeLabelRenderer, EdgeLabelRenderer,
+2 -21
View File
@@ -154,17 +154,13 @@ export type GraphEdge<Data = ElementData, CustomEvents extends Record<string, Cu
} & EdgePositions } & EdgePositions
/** these props are passed to edge components */ /** these props are passed to edge components */
export interface EdgeProps<Data = ElementData, CustomEvents = {}> { export interface EdgeProps<Data = ElementData, CustomEvents = {}> extends EdgeLabelOptions, EdgePositions {
id: string id: string
sourceNode: GraphNode sourceNode: GraphNode
targetNode: GraphNode targetNode: GraphNode
type?: keyof DefaultEdgeTypes | string type?: keyof DefaultEdgeTypes | string
label?: string | VNode | Component<EdgeTextProps> | Object label?: string | VNode | Component<EdgeTextProps> | Object
style?: CSSProperties style?: CSSProperties
sourceX: number
sourceY: number
targetX: number
targetY: number
selected?: boolean selected?: boolean
sourcePosition: Position sourcePosition: Position
targetPosition: Position targetPosition: Position
@@ -172,11 +168,6 @@ export interface EdgeProps<Data = ElementData, CustomEvents = {}> {
targetHandleId?: string targetHandleId?: string
source: string source: string
target: string target: string
labelStyle?: CSSProperties
labelShowBg?: boolean
labelBgStyle?: any
labelBgPadding?: [number, number]
labelBgBorderRadius?: number
animated?: boolean animated?: boolean
updatable?: boolean updatable?: boolean
markerStart: string markerStart: string
@@ -188,21 +179,11 @@ export interface EdgeProps<Data = ElementData, CustomEvents = {}> {
events: EdgeEventsOn<CustomEvents> events: EdgeEventsOn<CustomEvents>
} }
/** these props are passed to smooth step edges */ export interface BaseEdgeProps extends EdgeLabelOptions {
export interface SmoothStepEdgeProps<Data = ElementData, CustomEvents = {}> extends Omit<EdgeProps<Data, CustomEvents>, 'type'> {
borderRadius?: number
}
export interface BaseEdgeProps {
labelX?: number labelX?: number
labelY?: number labelY?: number
path: string path: string
label?: any label?: any
labelStyle?: any
labelShowBg?: boolean
labelBgStyle?: any
labelBgPadding?: [number, number]
labelBgBorderRadius?: number
markerStart?: string markerStart?: string
markerEnd?: string markerEnd?: string
interactionWidth?: number interactionWidth?: number
+2
View File
@@ -34,8 +34,10 @@ export interface Node<Data = ElementData, CustomEvents extends Record<string, Cu
connectable?: HandleConnectable connectable?: HandleConnectable
focusable?: boolean focusable?: boolean
dragHandle?: string dragHandle?: string
// todo: deprecate this and remove them in next minor release
/** called when used as target for new connection */ /** called when used as target for new connection */
isValidTargetPos?: ValidConnectionFunc isValidTargetPos?: ValidConnectionFunc
// todo: deprecate this and remove them in next minor release
/** called when used as source for new connection */ /** called when used as source for new connection */
isValidSourcePos?: ValidConnectionFunc isValidSourcePos?: ValidConnectionFunc
/** define node extent, i.e. area in which node can be moved */ /** define node extent, i.e. area in which node can be moved */