feat(svelte): add step edge
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { getSmoothStepPath } from '@reactflow/edge-utils';
|
||||||
|
|
||||||
|
import type { EdgeProps } from '$lib/types';
|
||||||
|
import { BaseEdge } from '$lib/components/BaseEdge';
|
||||||
|
|
||||||
|
type $$Props = EdgeProps;
|
||||||
|
|
||||||
|
$: [path, labelX, labelY] = getSmoothStepPath({
|
||||||
|
sourceX: $$props.sourceX,
|
||||||
|
sourceY: $$props.sourceY,
|
||||||
|
targetX: $$props.targetX,
|
||||||
|
targetY: $$props.targetY,
|
||||||
|
sourcePosition: $$props.sourcePosition,
|
||||||
|
targetPosition: $$props.targetPosition,
|
||||||
|
borderRadius: 0
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<BaseEdge {path} {labelX} {labelY} {...$$props} />
|
||||||
@@ -16,6 +16,7 @@ import OutputNode from '$lib/components/nodes/OutputNode.svelte';
|
|||||||
import BezierEdge from '$lib/components/edges/BezierEdge.svelte';
|
import BezierEdge from '$lib/components/edges/BezierEdge.svelte';
|
||||||
import StraightEdge from '$lib/components/edges/StraightEdge.svelte';
|
import StraightEdge from '$lib/components/edges/StraightEdge.svelte';
|
||||||
import SmoothStepEdge from '$lib/components/edges/SmoothStepEdge.svelte';
|
import SmoothStepEdge from '$lib/components/edges/SmoothStepEdge.svelte';
|
||||||
|
import StepEdge from '$lib/components/edges/StepEdge.svelte';
|
||||||
import type {
|
import type {
|
||||||
ConnectionData,
|
ConnectionData,
|
||||||
NodeTypes,
|
NodeTypes,
|
||||||
@@ -43,7 +44,8 @@ export const initialNodeTypes = {
|
|||||||
export const initialEdgeTypes = {
|
export const initialEdgeTypes = {
|
||||||
straight: StraightEdge,
|
straight: StraightEdge,
|
||||||
smoothstep: SmoothStepEdge,
|
smoothstep: SmoothStepEdge,
|
||||||
default: BezierEdge
|
default: BezierEdge,
|
||||||
|
step: StepEdge
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initialStoreState = {
|
export const initialStoreState = {
|
||||||
|
|||||||
@@ -28,7 +28,15 @@ type BezierEdgeType<T> = DefaultEdge<T> & {
|
|||||||
pathOptions?: BezierPathOptions;
|
pathOptions?: BezierPathOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Edge<T = any> = DefaultEdge<T> | SmoothStepEdgeType<T> | BezierEdgeType<T>;
|
type StepEdgeType<T> = DefaultEdge<T> & {
|
||||||
|
type: 'step';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Edge<T = any> =
|
||||||
|
| DefaultEdge<T>
|
||||||
|
| SmoothStepEdgeType<T>
|
||||||
|
| BezierEdgeType<T>
|
||||||
|
| StepEdgeType<T>;
|
||||||
|
|
||||||
export type EdgeLayouted = Omit<Edge, 'sourceHandle' | 'targetHandle'> & {
|
export type EdgeLayouted = Omit<Edge, 'sourceHandle' | 'targetHandle'> & {
|
||||||
sourceX: number;
|
sourceX: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user