fix(types): edge text type
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties, DefineComponent } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
||||||
import { getCenter, getMarkerEnd, getBezierPath } from './utils'
|
import { getCenter, getMarkerEnd, getBezierPath } from './utils'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
@@ -19,7 +19,7 @@ interface BezierEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent<EdgeTextProps>
|
component: any
|
||||||
props?: EdgeTextProps
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties, DefineComponent } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
|
|
||||||
interface EdgeTextProps {
|
interface EdgeTextProps {
|
||||||
x: number
|
x: number
|
||||||
@@ -7,12 +7,12 @@ interface EdgeTextProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent
|
component: any
|
||||||
props?: Record<string, any>
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: CSSProperties
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,6 @@ const props = withDefaults(defineProps<EdgeTextProps>(), {
|
|||||||
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
||||||
const { width, height, x, y } = useElementBounding(edgeRef)
|
const { width, height, x, y } = useElementBounding(edgeRef)
|
||||||
const transform = computed(() => `translate(${props.x - width.value / 2 || 0} ${props.y - height.value / 2 || 0})`)
|
const transform = computed(() => `translate(${props.x - width.value / 2 || 0} ${props.y - height.value / 2 || 0})`)
|
||||||
const bgPadding = computed(() => [props.labelBgPadding[0], props.labelBgPadding[1]])
|
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -39,11 +38,11 @@ export default {
|
|||||||
<g :transform="transform" class="vue-flow__edge-textwrapper">
|
<g :transform="transform" class="vue-flow__edge-textwrapper">
|
||||||
<rect
|
<rect
|
||||||
v-if="props.labelShowBg"
|
v-if="props.labelShowBg"
|
||||||
:width="width + 2 * bgPadding[0] + 'px'"
|
|
||||||
:height="height + 2 * bgPadding[1] + 'px'"
|
|
||||||
:x="-bgPadding[0]"
|
|
||||||
:y="-bgPadding[1]"
|
|
||||||
class="vue-flow__edge-textbg"
|
class="vue-flow__edge-textbg"
|
||||||
|
:width="width + 2 * props.labelBgPadding[0] + 'px'"
|
||||||
|
:height="height + 2 * props.labelBgPadding[1] + 'px'"
|
||||||
|
:x="-props.labelBgPadding[0]"
|
||||||
|
:y="-props.labelBgPadding[1]"
|
||||||
:style="props.labelBgStyle"
|
:style="props.labelBgStyle"
|
||||||
:rx="props.labelBgBorderRadius"
|
:rx="props.labelBgBorderRadius"
|
||||||
:ry="props.labelBgBorderRadius"
|
:ry="props.labelBgBorderRadius"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties, DefineComponent } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils'
|
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils'
|
||||||
@@ -19,7 +19,7 @@ interface SmoothStepEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent<EdgeTextProps>
|
component: any
|
||||||
props?: EdgeTextProps
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties, DefineComponent } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
||||||
import SmoothStepEdge from './SmoothStepEdge.vue'
|
import SmoothStepEdge from './SmoothStepEdge.vue'
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ interface StepEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent<EdgeTextProps>
|
component: any
|
||||||
props?: EdgeTextProps
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties, DefineComponent } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, EdgeTextProps, ElementId, Position } from '../../types'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
import { getMarkerEnd, getBezierPath } from './utils'
|
import { getMarkerEnd, getBezierPath } from './utils'
|
||||||
@@ -19,7 +19,7 @@ interface StraightEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent<EdgeTextProps>
|
component: any
|
||||||
props?: EdgeTextProps
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const checkElementBelowIsValid = (
|
|||||||
connectionMode: ConnectionMode,
|
connectionMode: ConnectionMode,
|
||||||
isTarget: boolean,
|
isTarget: boolean,
|
||||||
nodeId: ElementId,
|
nodeId: ElementId,
|
||||||
handleId: ElementId | null,
|
handleId: ElementId,
|
||||||
isValidConnection: ValidConnectionFunc,
|
isValidConnection: ValidConnectionFunc,
|
||||||
doc: Document,
|
doc: Document,
|
||||||
) => {
|
) => {
|
||||||
@@ -26,7 +26,7 @@ export const checkElementBelowIsValid = (
|
|||||||
const result: Result = {
|
const result: Result = {
|
||||||
elementBelow,
|
elementBelow,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
connection: { source: null, target: null, sourceHandle: null, targetHandle: null },
|
connection: { source: '', target: '', sourceHandle: '', targetHandle: '' },
|
||||||
isHoveringHandle: false,
|
isHoveringHandle: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ export const checkElementBelowIsValid = (
|
|||||||
connectionMode === ConnectionMode.Strict ? (isTarget && elementBelowIsSource) || (!isTarget && elementBelowIsTarget) : true
|
connectionMode === ConnectionMode.Strict ? (isTarget && elementBelowIsSource) || (!isTarget && elementBelowIsTarget) : true
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
const elementBelowNodeId = elementBelow.getAttribute('data-nodeid')
|
const elementBelowNodeId = elementBelow.getAttribute('data-nodeid') ?? ''
|
||||||
const elementBelowHandleId = elementBelow.getAttribute('data-handleid')
|
const elementBelowHandleId = elementBelow.getAttribute('data-handleid') ?? ''
|
||||||
const connection: Connection = isTarget
|
const connection: Connection = isTarget
|
||||||
? {
|
? {
|
||||||
source: elementBelowNodeId,
|
source: elementBelowNodeId,
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ export interface MiniMapNodeProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface EdgeTextProps {
|
export interface EdgeTextProps {
|
||||||
x?: number
|
x: number
|
||||||
y?: number
|
y: number
|
||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ export interface Edge<T = any> {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: DefineComponent<EdgeTextProps> | any
|
component: any
|
||||||
props?: EdgeTextProps | any
|
props?: EdgeTextProps
|
||||||
}
|
}
|
||||||
labelStyle?: any
|
labelStyle?: any
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user