fix(types): node/edge label type
* add Component to label type
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user