fix(types): node/edge label type

* add Component to label type
This commit is contained in:
Braks
2022-04-10 17:54:19 +02:00
parent 88f808711a
commit 440ad3c681
5 changed files with 6 additions and 15 deletions

View File

@@ -29,12 +29,7 @@ const initialEdges: Edge[] = [
id: 'e5-6',
source: '5',
target: '6',
label: {
component: markRaw(CustomLabel),
props: {
label: 'custom label text',
},
},
label: h(CustomLabel, { label: 'custom label text' }, {}),
labelStyle: { fill: 'red', fontWeight: 700 },
markerEnd: {
type: MarkerType.Arrow,

View File

@@ -6,12 +6,7 @@ interface Props {
centerX: number
centerY: number
path: string
label?:
| string
| {
props?: any
component: any
}
label?: any
style?: CSSProperties
labelStyle?: any
labelShowBg?: boolean

View File

@@ -41,6 +41,7 @@ export default {
<slot v-bind="props">
<component :is="props.label" v-if="typeof props.label !== 'string' && typeof props.label" />
<template v-else v-html="props.label">
Floo
{{ props.label }}
</template>
</slot>

View File

@@ -106,7 +106,7 @@ export interface EdgeProps<Data = ElementData, SourceNodeData = any, TargetNodeD
id: string
sourceNode: GraphNode<SourceNodeData>
targetNode: GraphNode<TargetNodeData>
label?: string | VNode
label?: string | VNode | Component<EdgeTextProps> | Object
type?: string
data?: Data
style?: CSSProperties
@@ -139,7 +139,7 @@ export interface SmoothStepEdgeProps<Data = ElementData, SourceNodeData = any, T
id: string
sourceNode: GraphNode<SourceNodeData>
targetNode: GraphNode<TargetNodeData>
label?: string | VNode
label?: string | VNode | Component<EdgeTextProps> | Object
type?: string
data?: Data
style?: CSSProperties

View File

@@ -94,7 +94,7 @@ export interface NodeProps<Data = ElementData> {
* For example like this: `h('div', props, children)`)
* Object is just a type-hack for Vue, ignore that
*/
label?: string | VNode | Object
label?: string | VNode | Component | Object
/** called when used as target for new connection */
isValidTargetPos?: ValidConnectionFunc
/** called when used as source for new connection */