Files
vue-flow/packages/core/src/components/Nodes/DefaultNode.ts
T
Braks f7a266415a fix(core): escape node labels (#1695)
* fix(core): escape node labels

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(changeset): add

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

---------

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
2024-11-13 20:20:43 +01:00

30 lines
1.0 KiB
TypeScript

import type { Component, FunctionalComponent } from 'vue'
import { Fragment, h } from 'vue'
import Handle from '../Handle/Handle.vue'
import type { NodeProps } from '../../types'
import { Position } from '../../types'
const DefaultNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
sourcePosition = Position.Bottom,
targetPosition = Position.Top,
label: _label,
connectable = true,
isValidTargetPos,
isValidSourcePos,
data,
}) {
const label = data.label || _label
return [
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
h(Handle as Component, { type: 'source', position: sourcePosition, connectable, isValidConnection: isValidSourcePos }),
]
}
DefaultNode.props = ['sourcePosition', 'targetPosition', 'label', 'isValidTargetPos', 'isValidSourcePos', 'connectable', 'data']
DefaultNode.inheritAttrs = false
DefaultNode.compatConfig = { MODE: 3 }
export default DefaultNode