"use client"; import React from "react"; import { EdgeProps, getBezierPath, EdgeLabelRenderer, BaseEdge } from "@xyflow/react"; interface CustomEdgeData { relationshipType: string; connectionType: string; label?: string; } export const CustomEdge: React.FC> = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, markerEnd, selected, }) => { const [edgePath, labelX, labelY] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, }); // 연결 타입에 따른 색상 반환 const getEdgeColor = (connectionType: string) => { switch (connectionType) { case "simple-key": return "#3B82F6"; // 파란색 - 단순 키값 연결 case "data-save": return "#10B981"; // 초록색 - 데이터 저장 case "external-call": return "#F59E0B"; // 주황색 - 외부 호출 default: return "#6B7280"; // 회색 - 기본 } }; // 연결 타입에 따른 스타일 반환 const getEdgeStyle = (connectionType: string) => { switch (connectionType) { case "simple-key": return { strokeWidth: 2, strokeDasharray: "5,5", opacity: selected ? 1 : 0.8, }; case "data-save": return { strokeWidth: 3, opacity: selected ? 1 : 0.8, }; case "external-call": return { strokeWidth: 2, strokeDasharray: "10,5", opacity: selected ? 1 : 0.8, }; default: return { strokeWidth: 2, opacity: selected ? 1 : 0.6, }; } }; // 관계 타입에 따른 아이콘 반환 const getRelationshipIcon = (relationshipType: string) => { switch (relationshipType) { case "one-to-one": return "1:1"; case "one-to-many": return "1:N"; case "many-to-one": return "N:1"; case "many-to-many": return "N:N"; default: return "1:1"; } }; // 연결 타입에 따른 설명 반환 const getConnectionTypeDescription = (connectionType: string) => { switch (connectionType) { case "simple-key": return "단순 키값"; case "data-save": return "데이터 저장"; case "external-call": return "외부 호출"; default: return "연결"; } }; const edgeColor = getEdgeColor(data?.connectionType || ""); const edgeStyle = getEdgeStyle(data?.connectionType || ""); return ( <>
{data?.label || getRelationshipIcon(data?.relationshipType || "one-to-one")}
{getConnectionTypeDescription(data?.connectionType || "simple-key")}
{/* 선택된 상태일 때 추가 시각적 효과 */} {selected && ( )} ); };