Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

feat: create relationships on canvas modal (#946)

Guy Ben-Aharon34475add32f1
diff --git a/src/components/select-box/select-box.tsx b/src/components/select-box/select-box.tsx
index 9f14adf2..496bff8c 100644
--- a/src/components/select-box/select-box.tsx
+++ b/src/components/select-box/select-box.tsx
@@ -58,6 +58,7 @@ export interface SelectBoxProps {
footerButtons?: React.ReactNode;
commandOnMouseDown?: (e: React.MouseEvent) => void;
commandOnClick?: (e: React.MouseEvent) => void;
+ onSearchChange?: (search: string) => void;
}
export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
@@ -87,6 +88,7 @@ export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
footerButtons,
commandOnMouseDown,
commandOnClick,
+ onSearchChange,
},
ref
) => {
@@ -240,6 +242,7 @@ export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
<CommandItem
className="flex items-center"
key={option.value}
+ value={option.label}
keywords={option.regex ? [option.regex] : undefined}
onSelect={() =>
handleSelect(
@@ -404,7 +407,10 @@ export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
<div className="relative">
<CommandInput
value={searchTerm}
- onValueChange={(e) => setSearchTerm(e)}
+ onValueChange={(e) => {
+ setSearchTerm(e);
+ onSearchChange?.(e);
+ }}
ref={ref}
placeholder={inputPlaceholder ?? 'Search...'}
className="h-9"
diff --git a/src/context/canvas-context/canvas-context.tsx b/src/context/canvas-context/canvas-context.tsx
index 7ec899aa..f9b76ed0 100644
--- a/src/context/canvas-context/canvas-context.tsx
+++ b/src/context/canvas-context/canvas-context.tsx
@@ -24,6 +24,31 @@ export interface CanvasContext {
fieldId?: string;
} | null>
>;
+ tempFloatingEdge: {
+ sourceNodeId: string;
+ targetNodeId?: string;
+ } | null;
+ setTempFloatingEdge: React.Dispatch<
+ React.SetStateAction<{
+ sourceNodeId: string;
+ targetNodeId?: string;
+ } | null>
+ >;
+ startFloatingEdgeCreation: ({
+ sourceNodeId,
+ }: {
+ sourceNodeId: string;
+ }) => void;
+ endFloatingEdgeCreation: () => void;
+ hoveringTableId: string | null;
+ setHoveringTableId: React.Dispatch<React.SetStateAction<string | null>>;
+ showCreateRelationshipNode: (params: {
+ sourceTableId: string;
+ targetTableId: string;
+ x: number;
+ y: number;
+ }) => void;
+ hideCreateRelationshipNode: () => void;
}
export const canvasContext = createContext<CanvasContext>({
@@ -35,4 +60,12 @@ export const canvasContext = createContext<CanvasContext>({
showFilter: false,
editTableModeTable: null,
setEditTableModeTable: emptyFn,
+ tempFloatingEdge: null,
+ setTempFloatingEdge: emptyFn,
+ startFloatingEdgeCreation: emptyFn,
+ endFloatingEdgeCreation: emptyFn,
+ hoveringTableId: null,
+ setHoveringTableId: emptyFn,
+ showCreateRelationshipNode: emptyFn,
+ hideCreateRelationshipNode: emptyFn,
});
diff --git a/src/context/canvas-context/canvas-provider.tsx b/src/context/canvas-context/canvas-provider.tsx
index 62cae45b..c0ed8c03 100644
--- a/src/context/canvas-context/canvas-provider.tsx
+++ b/src/context/canvas-context/canvas-provider.tsx
@@ -5,6 +5,7 @@ import React, {
useEffect,
useRef,
} from 'react';
+import type { CanvasContext } from './canvas-context';
import { canvasContext } from './canvas-context';
import { useChartDB } from '@/hooks/use-chartdb';
import { adjustTablePositions } from '@/lib/domain/db-table';
@@ -15,6 +16,10 @@ import { createGraph } from '@/lib/graph';
import { useDiagramFilter } from '../diagram-filter-context/use-diagram-filter';
import { filterTable } from '@/lib/domain/diagram-filter/filter';
import { defaultSchemas } from '@/lib/data/default-schemas';
+import {
+ CREATE_RELATIONSHIP_NODE_ID,
+ type CreateRelationshipNodeType,
+} from '@/pages/editor-page/canvas/create-relationship-node/create-relationship-node';
interface CanvasProviderProps {
children: ReactNode;
@@ -30,7 +35,7 @@ export const CanvasProvider = ({ children }: CanvasProviderProps) => {
diagramId,
} = useChartDB();
const { filter, loading: filterLoading } = useDiagramFilter();
- const { fitView } = useReactFlow();
+ const { fitView, screenToFlowPosition, setNodes } = useReactFlow();
const [overlapGraph, setOverlapGraph] =
useState<Graph<string>>(createGraph());
const [editTableModeTable, setEditTableModeTable] = useState<{
@@ -39,6 +44,12 @@ export const CanvasProvider = ({ children }: CanvasProviderProps) => {
} | null>(null);
const [showFilter, setShowFilter] = useState(false);
+
+ const [tempFloatingEdge, setTempFloatingEdge] =
+ useState<CanvasContext['tempFloatingEdge']>(null);
+
+ const [hoveringTableId, setHoveringTableId] = useState<string | null>(null);
+
const diagramIdActiveFilterRef = useRef<string>();
useEffect(() => {
@@ -122,6 +133,66 @@ export const CanvasProvider = ({ children }: CanvasProviderProps) => {
]
);
+ const startFloatingEdgeCreation: CanvasContext['startFloatingEdgeCreation'] =
+ useCallback(({ sourceNodeId }) => {
+ setShowFilter(false);
+ setTempFloatingEdge({
+ sourceNodeId,
+ });
+ }, []);
+
+ const endFloatingEdgeCreation: CanvasContext['endFloatingEdgeCreation'] =
+ useCallback(() => {
+ setTempFloatingEdge(null);
+ }, []);
+
+ const hideCreateRelationshipNode: CanvasContext['hideCreateRelationshipNode'] =
+ useCallback(() => {
+ setNodes((nds) =>
+ nds.filter((n) => n.id !== CREATE_RELATIONSHIP_NODE_ID)
+ );
+ endFloatingEdgeCreation();
+ }, [setNodes, endFloatingEdgeCreation]);
+
+ const showCreateRelationshipNode: CanvasContext['showCreateRelationshipNode'] =
+ useCallback(
+ ({ sourceTableId, targetTableId, x, y }) => {
+ setTempFloatingEdge((edge) =>
+ edge
+ ? {
+ ...edge,
+ targetNodeId: targetTableId,
+ }
+ : null
+ );
+ const cursorPos = screenToFlowPosition({
+ x,
+ y,
+ });
+
+ const newNode: CreateRelationshipNodeType = {
+ id: CREATE_RELATIONSHIP_NODE_ID,
+ type: 'create-relationship',
+ position: cursorPos,
+ data: {
+ sourceTableId,
+ targetTableId,
+ },
+ draggable: true,
+ selectable: false,
+ zIndex: 1000,
+ };
+
+ setNodes((nds) => {
+ const nodesWithoutOldCreateRelationshipNode = nds.filter(
+ (n) => n.id !== CREATE_RELATIONSHIP_NODE_ID
+ );
+ return [...nodesWithoutOldCreateRelationshipNode, newNode];
+ });
+ },
+ [screenToFlowPosition, setNodes]
+ );
+
return (
<canvasContext.Provider
value={{
@@ -133,6 +204,14 @@ export const CanvasProvider = ({ children }: CanvasProviderProps) => {
showFilter,
editTableModeTable,
setEditTableModeTable,
+ tempFloatingEdge: tempFloatingEdge,
+ setTempFloatingEdge: setTempFloatingEdge,
+ startFloatingEdgeCreation: startFloatingEdgeCreation,
+ endFloatingEdgeCreation: endFloatingEdgeCreation,
+ hoveringTableId,
+ setHoveringTableId,
+ showCreateRelationshipNode,
+ hideCreateRelationshipNode,
}}
>
{children}
diff --git a/src/pages/editor-page/canvas/canvas.tsx b/src/pages/editor-page/canvas/canvas.tsx
index b9c1187f..bf0afe29 100644
--- a/src/pages/editor-page/canvas/canvas.tsx
+++ b/src/pages/editor-page/canvas/canvas.tsx
@@ -30,7 +30,11 @@ import {
import '@xyflow/react/dist/style.css';
import equal from 'fast-deep-equal';
import type { TableNodeType } from './table-node/table-node';
-import { TableNode } from './table-node/table-node';
+import {
+ TABLE_RELATIONSHIP_SOURCE_HANDLE_ID_PREFIX,
+ TABLE_RELATIONSHIP_TARGET_HANDLE_ID_PREFIX,
+ TableNode,
+} from './table-node/table-node';
import type { RelationshipEdgeType } from './relationship-edge/relationship-edge';
import { RelationshipEdge } from './relationship-edge/relationship-edge';
import { useChartDB } from '@/hooks/use-chartdb';
@@ -79,6 +83,20 @@ import { useCanvas } from '@/hooks/use-canvas';
import type { AreaNodeType } from './area-node/area-node';
import { AreaNode } from './area-node/area-node';
import type { Area } from '@/lib/domain/area';
+import type { TempCursorNodeType } from './temp-cursor-node/temp-cursor-node';
+import {
+ TEMP_CURSOR_HANDLE_ID,
+ TEMP_CURSOR_NODE_ID,
+ TempCursorNode,
+} from './temp-cursor-node/temp-cursor-node';
+import type { TempFloatingEdgeType } from './temp-floating-edge/temp-floating-edge';
+import {
+ TEMP_FLOATING_EDGE_ID,
+ TempFloatingEdge,
+} from './temp-floating-edge/temp-floating-edge';
+import type { CreateRelationshipNodeType } from './create-relationship-node/create-relationship-node';
+import { CreateRelationshipNode } from './create-relationship-node/create-relationship-node';
+import { ConnectionLine } from './connection-line/connection-line';
import {
updateTablesParentAreas,
getTablesInArea,
@@ -97,20 +115,30 @@ import { useClickAway } from 'react-use';
const HIGHLIGHTED_EDGE_Z_INDEX = 1;
const DEFAULT_EDGE_Z_INDEX = 0;
-export type EdgeType = RelationshipEdgeType | DependencyEdgeType;
+export type EdgeType =
+ | RelationshipEdgeType
+ | DependencyEdgeType
+ | TempFloatingEdgeType;
-export type NodeType = TableNodeType | AreaNodeType;
+export type NodeType =
+ | TableNodeType
+ | AreaNodeType
+ | TempCursorNodeType
+ | CreateRelationshipNodeType;
type AddEdgeParams = Parameters<typeof addEdge<EdgeType>>[0];
const edgeTypes: EdgeTypes = {
'relationship-edge': RelationshipEdge,
'dependency-edge': DependencyEdge,
+ 'temp-floating-edge': TempFloatingEdge,
};
const nodeTypes: NodeTypes = {
table: TableNode,
area: AreaNode,
+ 'temp-cursor': TempCursorNode,
+ 'create-relationship': CreateRelationshipNode,
};
const initialEdges: EdgeType[] = [];
@@ -123,12 +151,14 @@ const tableToTableNode = (
filterLoading,
showDBViews,
forceShow,
+ isRelationshipCreatingTarget = false,
}: {
filter?: DiagramFilter;
databaseType: DatabaseType;
filterLoading: boolean;
showDBViews?: boolean;
forceShow?: boolean;
+ isRelationshipCreatingTarget?: boolean;
}
): TableNodeType => {
// Always use absolute position for now
@@ -156,6 +186,7 @@ const tableToTableNode = (
data: {
table,
isOverlapping: false,
+ isRelationshipCreatingTarget,
},
width: table.width ?? MIN_TABLE_SIZE,
hidden,
@@ -252,6 +283,10 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
showFilter,
setShowFilter,
setEditTableModeTable,
+ tempFloatingEdge,
+ endFloatingEdgeCreation,
+ hoveringTableId,
+ hideCreateRelationshipNode,
} = useCanvas();
const { filter, loading: filterLoading } = useDiagramFilter();
const { checkIfNewTable } = useDiff();
@@ -273,6 +308,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
filterLoading,
showDBViews,
forceShow: shouldForceShowTable(table.id),
+ isRelationshipCreatingTarget: false,
})
)
);
@@ -281,6 +317,11 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
const [snapToGridEnabled, setSnapToGridEnabled] = useState(false);
+ const [cursorPosition, setCursorPosition] = useState<{
+ x: number;
+ y: number;
+ } | null>(null);
+
useEffect(() => {
setIsInitialLoadingNodes(true);
}, [initialTables]);
@@ -293,6 +334,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
filterLoading,
showDBViews,
forceShow: shouldForceShowTable(table.id),
+ isRelationshipCreatingTarget: false,
})
);
if (equal(initialNodes, nodes)) {
@@ -398,58 +440,62 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
// Check if any edge needs updating
let hasChanges = false;
- const newEdges = prevEdges.map((edge): EdgeType => {
- const shouldBeHighlighted =
- selectedRelationshipIdsSet.has(edge.id) ||
- selectedTableIdsSet.has(edge.source) ||
- selectedTableIdsSet.has(edge.target);
-
- const currentHighlighted = edge.data?.highlighted ?? false;
- const currentAnimated = edge.animated ?? false;
- const currentZIndex = edge.zIndex ?? 0;
-
- // Skip if no changes needed
- if (
- currentHighlighted === shouldBeHighlighted &&
- currentAnimated === shouldBeHighlighted &&
- currentZIndex ===
- (shouldBeHighlighted
- ? HIGHLIGHTED_EDGE_Z_INDEX
- : DEFAULT_EDGE_Z_INDEX)
- ) {
- return edge;
- }
+ const newEdges = prevEdges
+ .filter((e) => e.type !== 'temp-floating-edge')
+ .map((edge): EdgeType => {
+ const shouldBeHighlighted =
+ selectedRelationshipIdsSet.has(edge.id) ||
+ selectedTableIdsSet.has(edge.source) ||
+ selectedTableIdsSet.has(edge.target);
+
+ const currentHighlighted =
+ (edge as Exclude<EdgeType, TempFloatingEdgeType>).data
+ ?.highlighted ?? false;
+ const currentAnimated = edge.animated ?? false;
+ const currentZIndex = edge.zIndex ?? 0;
+
+ // Skip if no changes needed
+ if (
+ currentHighlighted === shouldBeHighlighted &&
+ currentAnimated === shouldBeHighlighted &&
+ currentZIndex ===
+ (shouldBeHighlighted
+ ? HIGHLIGHTED_EDGE_Z_INDEX
+ : DEFAULT_EDGE_Z_INDEX)
+ ) {
+ return edge;
+ }
- hasChanges = true;
+ hasChanges = true;
- if (edge.type === 'dependency-edge') {
- const dependencyEdge = edge as DependencyEdgeType;
- return {
- ...dependencyEdge,
- data: {
- ...dependencyEdge.data!,
- highlighted: shouldBeHighlighted,
- },
- animated: shouldBeHighlighted,
- zIndex: shouldBeHighlighted
- ? HIGHLIGHTED_EDGE_Z_INDEX
- : DEFAULT_EDGE_Z_INDEX,
- };
- } else {
- const relationshipEdge = edge as RelationshipEdgeType;
- return {
- ...relationshipEdge,
- data: {
- ...relationshipEdge.data!,
- highlighted: shouldBeHighlighted,
- },
- animated: shouldBeHighlighted,
- zIndex: shouldBeHighlighted
- ? HIGHLIGHTED_EDGE_Z_INDEX
- : DEFAULT_EDGE_Z_INDEX,
- };
- }
- });
+ if (edge.type === 'dependency-edge') {
+ const dependencyEdge = edge as DependencyEdgeType;
+ return {
+ ...dependencyEdge,
+ data: {
+ ...dependencyEdge.data!,
+ highlighted: shouldBeHighlighted,
+ },
+ animated: shouldBeHighlighted,
+ zIndex: shouldBeHighlighted
+ ? HIGHLIGHTED_EDGE_Z_INDEX
+ : DEFAULT_EDGE_Z_INDEX,
+ };
+ } else {
+ const relationshipEdge = edge as RelationshipEdgeType;
+ return {
+ ...relationshipEdge,
+ data: {
+ ...relationshipEdge.data!,
+ highlighted: shouldBeHighlighted,
+ },
+ animated: shouldBeHighlighted,
+ zIndex: shouldBeHighlighted
+ ? HIGHLIGHTED_EDGE_Z_INDEX
+ : DEFAULT_EDGE_Z_INDEX,
+ };
+ }
+ });
return hasChanges ? newEdges : prevEdges;
});
@@ -467,6 +513,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
filterLoading,
showDBViews,
forceShow: shouldForceShowTable(table.id),
+ isRelationshipCreatingTarget: false,
});
// Check if table uses the highlighted custom type
@@ -496,6 +543,11 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
filterLoading,
})
),
+ ...prevNodes.filter(
+ (n) =>
+ n.type === 'temp-cursor' ||
+ n.type === 'create-relationship'
+ ),
];
// Check if nodes actually changed
@@ -520,6 +572,37 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
shouldForceShowTable,
]);
+ // Surgical update for relationship creation target highlighting
+ // This avoids expensive full node recalculation when only the visual state changes
+ useEffect(() => {
+ setNodes((nds) => {
+ let hasChanges = false;
+ const updatedNodes = nds.map((node) => {
+ if (node.type !== 'table') return node;
+
+ const shouldBeTarget =
+ !!tempFloatingEdge?.sourceNodeId &&
+ node.id !== tempFloatingEdge.sourceNodeId;
+ const isCurrentlyTarget =
+ node.data.isRelationshipCreatingTarget ?? false;
+
+ if (shouldBeTarget !== isCurrentlyTarget) {
+ hasChanges = true;
+ return {
+ ...node,
+ data: {
+ ...node.data,
+ isRelationshipCreatingTarget: shouldBeTarget,
+ },
+ };
+ }
+ return node;
+ });
+
+ return hasChanges ? updatedNodes : nds;
+ });
+ }, [tempFloatingEdge?.sourceNodeId, setNodes]);
+
const prevFilter = useRef<DiagramFilter | undefined>(undefined);
useEffect(() => {
if (!equal(filter, prevFilter.current)) {
@@ -1227,6 +1310,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
[setEditTableModeTable]
);
useClickAway(containerRef, exitEditTableMode);
+ useClickAway(containerRef, hideCreateRelationshipNode);
const shiftPressed = useKeyPress('Shift');
const operatingSystem = getOperatingSystem();
@@ -1243,19 +1327,134 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
[]
);
+ // Handle mouse move to update cursor position for floating edge
+ const { screenToFlowPosition } = useReactFlow();
+ const rafIdRef = useRef<number>();
+ const handleMouseMove = useCallback(
+ (event: React.MouseEvent) => {
+ if (tempFloatingEdge) {
+ // Throttle using requestAnimationFrame
+ if (rafIdRef.current) {
+ return;
+ }
+
+ rafIdRef.current = requestAnimationFrame(() => {
+ const position = screenToFlowPosition({
+ x: event.clientX,
+ y: event.clientY,
+ });
+ setCursorPosition(position);
+ rafIdRef.current = undefined;
+ });
+ }
+ },
+ [tempFloatingEdge, screenToFlowPosition]
+ );
+
+ // Cleanup RAF on unmount
+ useEffect(() => {
+ return () => {
+ if (rafIdRef.current) {
+ cancelAnimationFrame(rafIdRef.current);
+ }
+ };
+ }, []);
+
+ // Handle escape key to cancel floating edge creation and close relationship node
+ useEffect(() => {
+ const handleEscape = (event: KeyboardEvent) => {
+ if (event.key === 'Escape') {
+ if (tempFloatingEdge) {
+ endFloatingEdgeCreation();
+ setCursorPosition(null);
+ }
+ // Also close CreateRelationshipNode if present
+ hideCreateRelationshipNode();
+ }
+ };
+ document.addEventListener('keydown', handleEscape);
+ return () => document.removeEventListener('keydown', handleEscape);
+ }, [tempFloatingEdge, endFloatingEdgeCreation, hideCreateRelationshipNode]);
+
+ // Add temporary invisible node at cursor position and edge
+ const nodesWithCursor = useMemo(() => {
+ if (!tempFloatingEdge || !cursorPosition) {
+ return nodes;
+ }
+
+ const tempNode: TempCursorNodeType = {
+ id: TEMP_CURSOR_NODE_ID,
+ type: 'temp-cursor',
+ position: cursorPosition,
+ data: {},
+ draggable: false,
+ selectable: false,
+ };
+
+ return [...nodes, tempNode];
+ }, [nodes, tempFloatingEdge, cursorPosition]);
+
+ const edgesWithFloating = useMemo(() => {
+ if (!tempFloatingEdge || !cursorPosition) return edges;
+
+ let target = TEMP_CURSOR_NODE_ID;
+ let targetHandle: string | undefined = TEMP_CURSOR_HANDLE_ID;
+
+ if (tempFloatingEdge.targetNodeId) {
+ target = tempFloatingEdge.targetNodeId;
+ targetHandle = `${TABLE_RELATIONSHIP_TARGET_HANDLE_ID_PREFIX}${tempFloatingEdge.targetNodeId}`;
+ } else if (
+ hoveringTableId &&
+ hoveringTableId !== tempFloatingEdge.sourceNodeId
+ ) {
+ target = hoveringTableId;
+ targetHandle = `${TABLE_RELATIONSHIP_TARGET_HANDLE_ID_PREFIX}${hoveringTableId}`;
+ }
+
+ const tempEdge: TempFloatingEdgeType = {
+ id: TEMP_FLOATING_EDGE_ID,
+ source: tempFloatingEdge.sourceNodeId,
+ sourceHandle: `${TABLE_RELATIONSHIP_SOURCE_HANDLE_ID_PREFIX}${tempFloatingEdge.sourceNodeId}`,
+ target,
+ targetHandle,
+ type: 'temp-floating-edge',
+ };
+
+ return [...edges, tempEdge];
+ }, [edges, tempFloatingEdge, cursorPosition, hoveringTableId]);
+
+ const onPaneClickHandler = useCallback(() => {
+ if (tempFloatingEdge) {
+ endFloatingEdgeCreation();
+ setCursorPosition(null);
+ }
+
+ // Close CreateRelationshipNode if it exists
+ hideCreateRelationshipNode();
+
+ // Exit edit table mode
+ exitEditTableMode();
+ }, [
+ tempFloatingEdge,
+ exitEditTableMode,
+ endFloatingEdgeCreation,
+ hideCreateRelationshipNode,
+ ]);
+
return (
<CanvasContextMenu>
<div
className="relative flex h-full"
id="canvas"
ref={containerRef}
+ onMouseMove={handleMouseMove}
>
<ReactFlow
onlyRenderVisibleElements
colorMode={effectiveTheme}
className="canvas-cursor-default nodes-animated"
- nodes={nodes}
- edges={edges}
+ nodes={nodesWithCursor}
+ edges={edgesWithFloating}
onNodesChange={onNodesChangeHandler}
onEdgesChange={onEdgesChangeHandler}
maxZoom={5}
@@ -1274,7 +1473,8 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
panOnScroll={scrollAction === 'pan'}
snapToGrid={shiftPressed || snapToGridEnabled}
snapGrid={[20, 20]}
- onPaneClick={exitEditTableMode}
+ onPaneClick={onPaneClickHandler}
+ connectionLineComponent={ConnectionLine}
>
<Controls
position="top-left"
diff --git a/src/pages/editor-page/canvas/connection-line/connection-line.tsx b/src/pages/editor-page/canvas/connection-line/connection-line.tsx
new file mode 100644
index 00000000..7c60f609
--- /dev/null
+++ b/src/pages/editor-page/canvas/connection-line/connection-line.tsx
@@ -0,0 +1,38 @@
+import React from 'react';
+import type { ConnectionLineComponentProps } from '@xyflow/react';
+import { getSmoothStepPath, Position } from '@xyflow/react';
+import type { NodeType } from '../canvas';
+
+export const ConnectionLine: React.FC<
+ ConnectionLineComponentProps<NodeType>
+> = ({ fromX, fromY, toX, toY, fromPosition, toPosition }) => {
+ const [edgePath] = getSmoothStepPath({
+ sourceX: fromX,
+ sourceY: fromY,
+ sourcePosition: fromPosition ?? Position.Right,
+ targetX: toX,
+ targetY: toY,
+ targetPosition: toPosition ?? Position.Left,
+ borderRadius: 14,
+ });
+
+ return (
+ <g>
+ <path
+ fill="none"
+ stroke="#ec4899"
+ strokeWidth={2}
+ strokeDasharray="5,5"
+ d={edgePath}
+ />
+ <circle
+ cx={toX}
+ cy={toY}
+ fill="#fff"
+ r={3}
+ stroke="#ec4899"
+ strokeWidth={1.5}
+ />
+ </g>
+ );
+};
diff --git a/src/pages/editor-page/canvas/create-relationship-node/create-relationship-node.tsx b/src/pages/editor-page/canvas/create-relationship-node/create-relationship-node.tsx
new file mode 100644
index 00000000..5a6b3129
--- /dev/null
+++ b/src/pages/editor-page/canvas/create-relationship-node/create-relationship-node.tsx
@@ -0,0 +1,321 @@
+import React, { useCallback, useEffect, useMemo, useState } from 'react';
+import type { NodeProps, Node } from '@xyflow/react';
+import { Button } from '@/components/button/button';
+import { useChartDB } from '@/hooks/use-chartdb';
+import type { SelectBoxOption } from '@/components/select-box/select-box';
+import { SelectBox } from '@/components/select-box/select-box';
+import { areFieldTypesCompatible } from '@/lib/data/data-types/data-types';
+import { useLayout } from '@/hooks/use-layout';
+import { ArrowRight, X } from 'lucide-react';
+import { cn } from '@/lib/utils';
+import { generateId } from '@/lib/utils';
+import type { DBField } from '@/lib/domain/db-field';
+import { useReactFlow } from '@xyflow/react';
+import { useCanvas } from '@/hooks/use-canvas';
+
+export const CREATE_RELATIONSHIP_NODE_ID = '__create-relationship-node__';
+
+const CREATE_NEW_FIELD_VALUE = 'CREATE_NEW';
+
+export type CreateRelationshipNodeType = Node<
+ {
+ sourceTableId: string;
+ targetTableId: string;
+ },
+ 'create-relationship'
+>;
+
+export const CreateRelationshipNode: React.FC<
+ NodeProps<CreateRelationshipNodeType>
+> = React.memo(({ data }) => {
+ const { sourceTableId, targetTableId } = data;
+ const { getTable, createRelationship, databaseType, addField } =
+ useChartDB();
+ const { hideCreateRelationshipNode } = useCanvas();
+ const { setEdges } = useReactFlow();
+ const { openRelationshipFromSidebar } = useLayout();
+ const [targetFieldId, setTargetFieldId] = useState<string | undefined>();
+ const [errorMessage, setErrorMessage] = useState('');
+ const [isVisible, setIsVisible] = useState(false);
+ const [selectOpen, setSelectOpen] = useState(false);
+ const [searchTerm, setSearchTerm] = useState<string>('');
+
+ const sourceTable = useMemo(
+ () => getTable(sourceTableId),
+ [sourceTableId, getTable]
+ );
+ const targetTable = useMemo(
+ () => getTable(targetTableId),
+ [targetTableId, getTable]
+ );
+
+ // Get the PK field from source table
+ const sourcePKField = useMemo(() => {
+ if (!sourceTable) return null;
+ return (
+ sourceTable.fields.find((f) => f.primaryKey) ||
+ sourceTable.fields[0]
+ );
+ }, [sourceTable]);
+
+ // Get compatible target fields (FK columns)
+ // Reset state when source or target table changes
+ useEffect(() => {
+ setTargetFieldId(undefined);
+ setSearchTerm('');
+ setErrorMessage('');
+ setSelectOpen(true);
+ }, [sourceTableId, targetTableId]);
+
+ const targetFieldOptions = useMemo(() => {
+ if (!targetTable || !sourcePKField) return [];
+
+ const compatibleFields = targetTable.fields
+ .filter((field) =>
+ areFieldTypesCompatible(
+ sourcePKField.type,
+ field.type,
+ databaseType
+ )
+ )
+ .map(
+ (field) =>
+ ({
+ label: field.name,
+ value: field.id,
+ description: `(${field.type.name})`,
+ }) as SelectBoxOption
+ );
+
+ // Add option to create a new field if user typed a custom name
+ if (
+ searchTerm &&
+ !compatibleFields.find(
+ (f) => f.label.toLowerCase() === searchTerm.toLowerCase()
+ )
+ ) {
+ compatibleFields.push({
+ label: `Create "${searchTerm}"`,
+ value: CREATE_NEW_FIELD_VALUE,
+ description: `(${sourcePKField.type.name})`,
+ });
+ }
+
+ return compatibleFields;
+ }, [targetTable, sourcePKField, databaseType, searchTerm]);
+
+ // Auto-select first compatible field OR pre-populate suggested name
+ useEffect(() => {
+ if (targetFieldOptions.length > 0 && !targetFieldId) {
+ setTargetFieldId(targetFieldOptions[0].value as string);
+ } else if (
+ targetFieldOptions.length === 0 &&
+ !searchTerm &&
+ sourceTable &&
+ sourcePKField
+ ) {
+ // No compatible fields - suggest a field name based on source table + PK field
+ const suggestedName =
+ sourcePKField.name.toLowerCase() === 'id'
+ ? `${sourceTable.name}_${sourcePKField.name}`
+ : sourcePKField.name;
+ setSearchTerm(suggestedName);
+ }
+ }, [
+ targetFieldOptions.length,
+ sourceTable,
+ sourcePKField,
+ searchTerm,
+ targetFieldId,
+ targetFieldOptions,
+ ]);
+
+ // Auto-open the select immediately and trigger animation
+ useEffect(() => {
+ setSelectOpen(true);
+ const rafId = requestAnimationFrame(() => {
+ setIsVisible(true);
+ });
+ return () => cancelAnimationFrame(rafId);
+ }, []);
+
+ const handleCreate = useCallback(async () => {
+ if (!sourcePKField) return;
+
+ try {
+ let finalTargetFieldId = targetFieldId;
+
+ // If user selected "CREATE_NEW", create the field first
+ if (targetFieldId === CREATE_NEW_FIELD_VALUE && searchTerm) {
+ const newField: DBField = {
+ id: generateId(),
+ name: searchTerm,
+ type: sourcePKField.type,
+ unique: false,
+ nullable: true,
+ primaryKey: false,
+ createdAt: Date.now(),
+ };
+
+ try {
+ await addField(targetTableId, newField);
+ finalTargetFieldId = newField.id;
+ } catch (fieldError) {
+ console.error('Failed to create field:', fieldError);
+ setErrorMessage('Failed to create new field');
+ return;
+ }
+ }
+
+ if (!finalTargetFieldId) {
+ setErrorMessage('Please select a target field');
+ return;
+ }
+
+ const relationship = await createRelationship({
+ sourceTableId,
+ sourceFieldId: sourcePKField.id,
+ targetTableId,
+ targetFieldId: finalTargetFieldId,
+ });
+
+ setEdges((edges) =>
+ edges.map((edge) =>
+ edge.id === relationship.id
+ ? { ...edge, selected: true }
+ : { ...edge, selected: false }
+ )
+ );
+
+ openRelationshipFromSidebar(relationship.id);
+ hideCreateRelationshipNode();
+ } catch (error) {
+ console.error(error);
+ setErrorMessage('Failed to create relationship');
+ }
+ }, [
+ sourcePKField,
+ targetFieldId,
+ searchTerm,
+ sourceTableId,
+ targetTableId,
+ createRelationship,
+ addField,
+ setEdges,
+ openRelationshipFromSidebar,
+ hideCreateRelationshipNode,
+ ]);
+
+ // Note: Escape key handling is done in canvas.tsx to avoid duplicate listeners
+
+ if (!sourceTable || !targetTable || !sourcePKField) {
+ return null;
+ }
+
+ return (
+ <div
+ className={cn(
+ 'pointer-events-auto flex cursor-auto flex-col rounded-lg border border-slate-300 bg-white shadow-xl transition-all duration-150 ease-out dark:border-slate-600 dark:bg-slate-800',
+ {
+ 'scale-100 opacity-100': isVisible,
+ 'scale-95 opacity-0': !isVisible,
+ }
+ )}
+ style={{
+ minWidth: '380px',
+ maxWidth: '420px',
+ }}
+ onClick={(e) => e.stopPropagation()}
+ >
+ {/* Header - draggable */}
+ <div className="flex cursor-move items-center justify-between gap-2 rounded-t-[7px] border-b bg-sky-600 px-3 py-1 dark:border-slate-600 dark:bg-sky-800">
+ <div className="text-xs font-semibold text-white">
+ Create Relationship
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="size-6 p-0 text-white hover:bg-white/20 hover:text-white dark:hover:bg-white/10"
+ onClick={hideCreateRelationshipNode}
+ >
+ <X className="size-4" />
+ </Button>
+ </div>
+
+ {/* Content */}
+ <div className="nodrag flex flex-col gap-3 p-3">
+ <div className="flex flex-row gap-2">
+ {/* PK Column (Source) */}
+ <div className="flex flex-1 flex-col gap-1.5">
+ <label className="text-xs font-medium text-slate-600 dark:text-slate-300">
+ From (PK)
+ </label>
+ <div className="flex h-7 items-center rounded-md border border-slate-200 bg-slate-50 px-2.5 text-sm font-medium text-slate-700 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-200">
+ {sourcePKField.name}
+ </div>
+ <div className="text-xs text-slate-500 dark:text-slate-400">
+ {sourceTable.name}
+ </div>
+ </div>
+
+ {/* Arrow indicator */}
+ <div className="flex items-center">
+ <ArrowRight className="size-3.5 text-slate-400 dark:text-slate-500" />
+ </div>
+
+ {/* FK Column (Target) */}
+ <div className="flex flex-1 flex-col gap-1.5">
+ <label className="text-xs font-medium text-slate-600 dark:text-slate-300">
+ To (FK)
+ </label>
+ <SelectBox
+ className="flex h-7 min-h-0 w-full dark:border-slate-200"
+ popoverClassName="!z-[1001]"
+ options={targetFieldOptions}
+ placeholder="Select field..."
+ inputPlaceholder="Search or Create..."
+ value={targetFieldId}
+ onChange={(value) => {
+ setTargetFieldId(value as string);
+ }}
+ emptyPlaceholder="No compatible fields"
+ onSearchChange={setSearchTerm}
+ open={selectOpen}
+ onOpenChange={setSelectOpen}
+ />
+ <div className="text-xs text-slate-500 dark:text-slate-400">
+ {targetTable.name}
+ </div>
+ </div>
+ </div>
+
+ {errorMessage && (
+ <div className="rounded-md bg-red-50 p-2 text-xs text-red-600 dark:bg-red-900/20 dark:text-red-400">
+ {errorMessage}
+ </div>
+ )}
+
+ {targetFieldOptions.length === 0 && (
+ <div className="rounded-md bg-yellow-50 p-2 text-xs text-yellow-700 dark:bg-yellow-900/20 dark:text-yellow-400">
+ No compatible fields found in target table
+ </div>
+ )}
+ </div>
+
+ {/* Footer */}
+ <div className="flex cursor-move items-center justify-end gap-2 rounded-b-lg border-t border-slate-200 bg-slate-50 px-3 py-2 dark:border-slate-600 dark:bg-slate-900">
+ <Button
+ disabled={!targetFieldId || targetFieldOptions.length === 0}
+ type="button"
+ onClick={handleCreate}
+ variant="default"
+ className="h-7 bg-sky-600 px-3 text-xs text-white hover:bg-sky-700 dark:bg-sky-800 dark:text-white dark:hover:bg-sky-900"
+ >
+ Create
+ </Button>
+ </div>
+ </div>
+ );
+});
+
+CreateRelationshipNode.displayName = 'CreateRelationshipNode';
diff --git a/src/pages/editor-page/canvas/table-node/table-node-context-menu.tsx b/src/pages/editor-page/canvas/table-node/table-node-context-menu.tsx
index 3343b06f..b89efef2 100644
--- a/src/pages/editor-page/canvas/table-node/table-node-context-menu.tsx
+++ b/src/pages/editor-page/canvas/table-node/table-node-context-menu.tsx
@@ -12,7 +12,6 @@ import type { DBTable } from '@/lib/domain/db-table';
import { Copy, Pencil, Trash2, Workflow } from 'lucide-react';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
-import { useDialog } from '@/hooks/use-dialog';
import { useCanvas } from '@/hooks/use-canvas';
export interface TableNodeContextMenuProps {
@@ -26,37 +25,56 @@ export const TableNodeContextMenu: React.FC<
const { closeAllTablesInSidebar } = useLayout();
const { t } = useTranslation();
const { isMd: isDesktop } = useBreakpoint('md');
- const { openCreateRelationshipDialog } = useDialog();
- const { setEditTableModeTable } = useCanvas();
+ const { setEditTableModeTable, startFloatingEdgeCreation } = useCanvas();
- const duplicateTableHandler = useCallback(() => {
- const clonedTable = cloneTable(table);
+ const duplicateTableHandler: React.MouseEventHandler<HTMLDivElement> =
+ useCallback(
+ (e) => {
+ e.stopPropagation();
+ const clonedTable = cloneTable(table);
- clonedTable.name = `${clonedTable.name}_copy`;
- clonedTable.x += 30;
- clonedTable.y += 50;
+ clonedTable.name = `${clonedTable.name}_copy`;
+ clonedTable.x += 30;
+ clonedTable.y += 50;
- createTable(clonedTable);
- }, [createTable, table]);
+ createTable(clonedTable);
+ },
+ [createTable, table]
+ );
- const editTableHandler = useCallback(() => {
- if (readonly) {
- return;
- }
+ const editTableHandler: React.MouseEventHandler<HTMLDivElement> =
+ useCallback(
+ (e) => {
+ e.stopPropagation();
+ if (readonly) {
+ return;
+ }
- closeAllTablesInSidebar();
- setEditTableModeTable({ tableId: table.id });
- }, [table.id, setEditTableModeTable, closeAllTablesInSidebar, readonly]);
+ closeAllTablesInSidebar();
+ setEditTableModeTable({ tableId: table.id });
+ },
+ [table.id, setEditTableModeTable, closeAllTablesInSidebar, readonly]
+ );
- const removeTableHandler = useCallback(() => {
- removeTable(table.id);
- }, [removeTable, table.id]);
+ const removeTableHandler: React.MouseEventHandler<HTMLDivElement> =
+ useCallback(
+ (e) => {
+ e.stopPropagation();
+ removeTable(table.id);
+ },
+ [removeTable, table.id]
+ );
- const addRelationshipHandler = useCallback(() => {
- openCreateRelationshipDialog({
- sourceTableId: table.id,
- });
- }, [openCreateRelationshipDialog, table.id]);
+ const addRelationshipHandler: React.MouseEventHandler<HTMLDivElement> =
+ useCallback(
+ (e) => {
+ e.stopPropagation();
+ startFloatingEdgeCreation({
+ sourceNodeId: table.id,
+ });
+ },
+ [startFloatingEdgeCreation, table.id]
+ );
if (!isDesktop || readonly) {
return <>{children}</>;
diff --git a/src/pages/editor-page/canvas/table-node/table-node.tsx b/src/pages/editor-page/canvas/table-node/table-node.tsx
index dd658212..831f4130 100644
--- a/src/pages/editor-page/canvas/table-node/table-node.tsx
+++ b/src/pages/editor-page/canvas/table-node/table-node.tsx
@@ -6,7 +6,13 @@ import React, {
useEffect,
} from 'react';
import type { NodeProps, Node } from '@xyflow/react';
-import { NodeResizer, useConnection, useStore } from '@xyflow/react';
+import {
+ NodeResizer,
+ useConnection,
+ useStore,
+ Handle,
+ Position,
+} from '@xyflow/react';
import { Button } from '@/components/button/button';
import {
ChevronsLeftRight,
@@ -47,6 +53,9 @@ import { TableNodeStatus } from './table-node-status/table-node-status';
import { TableEditMode } from './table-edit-mode/table-edit-mode';
import { useCanvas } from '@/hooks/use-canvas';
+export const TABLE_RELATIONSHIP_SOURCE_HANDLE_ID_PREFIX = 'table_rel_source_';
+export const TABLE_RELATIONSHIP_TARGET_HANDLE_ID_PREFIX = 'table_rel_target_';
+
export type TableNodeType = Node<
{
table: DBTable;
@@ -54,6 +63,7 @@ export type TableNodeType = Node<
highlightOverlappingTables?: boolean;
hasHighlightedCustomType?: boolean;
highlightTable?: boolean;
+ isRelationshipCreatingTarget?: boolean;
},
'table'
>;
@@ -69,6 +79,7 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
highlightOverlappingTables,
hasHighlightedCustomType,
highlightTable,
+ isRelationshipCreatingTarget,
},
}) => {
const { updateTable, relationships, readonly } = useChartDB();
@@ -81,7 +92,13 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
const [expanded, setExpanded] = useState(table.expanded ?? false);
const { t } = useTranslation();
const [isHovering, setIsHovering] = useState(false);
- const { setEditTableModeTable, editTableModeTable } = useCanvas();
+ const {
+ setEditTableModeTable,
+ editTableModeTable,
+ setHoveringTableId,
+ showCreateRelationshipNode,
+ tempFloatingEdge,
+ } = useCanvas();
// Get edit mode state directly from context
const editTableMode = useMemo(
@@ -314,11 +331,20 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
editModeInitialFieldCount,
]);
+ const isPartOfCreatingRelationship = useMemo(
+ () =>
+ tempFloatingEdge?.sourceNodeId === id ||
+ (isRelationshipCreatingTarget &&
+ tempFloatingEdge?.targetNodeId === id) ||
+ isHovering,
+ [tempFloatingEdge, id, isRelationshipCreatingTarget, isHovering]
+ );
+
const tableClassName = useMemo(
() =>
cn(
'flex w-full flex-col border-2 bg-slate-50 dark:bg-slate-950 rounded-lg shadow-sm transition-transform duration-300',
- selected || isTarget
+ selected || isTarget || isPartOfCreatingRelationship
? 'border-pink-600'
: 'border-slate-500 dark:border-slate-700',
isOverlapping
@@ -363,6 +389,7 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
isDiffTableRemoved,
isTarget,
editTableMode,
+ isPartOfCreatingRelationship,
]
);
@@ -400,11 +427,33 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
className={tableClassName}
onClick={(e) => {
if (e.detail === 2 && !readonly) {
+ e.stopPropagation();
enterEditTableMode();
+ } else if (e.detail === 1 && !readonly) {
+ // Handle single click
+ if (
+ isRelationshipCreatingTarget &&
+ tempFloatingEdge
+ ) {
+ e.stopPropagation();
+ showCreateRelationshipNode({
+ sourceTableId:
+ tempFloatingEdge.sourceNodeId,
+ targetTableId: table.id,
+ x: e.clientX,
+ y: e.clientY,
+ });
+ }
}
}}
- onMouseEnter={() => setIsHovering(true)}
- onMouseLeave={() => setIsHovering(false)}
+ onMouseEnter={() => {
+ setIsHovering(true);
+ setHoveringTableId(table.id);
+ }}
+ onMouseLeave={() => {
+ setIsHovering(false);
+ setHoveringTableId(null);
+ }}
>
<NodeResizer
isVisible={focused}
@@ -414,6 +463,25 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = React.memo(
shouldResize={(event) => event.dy === 0}
handleClassName="!hidden"
/>
+ {/* Center handle for floating edge creation */}
+ {!readonly ? (
+ <Handle
+ id={`${TABLE_RELATIONSHIP_SOURCE_HANDLE_ID_PREFIX}${table.id}`}
+ type="source"
+ position={Position.Top}
+ className="!invisible !left-1/2 !top-1/2 !h-1 !w-1 !-translate-x-1/2 !-translate-y-1/2 !transform"
+ />
+ ) : null}
+ {/* Target handle covering entire table for floating edge creation */}
+ {!readonly ? (
+ <Handle
+ id={`${TABLE_RELATIONSHIP_TARGET_HANDLE_ID_PREFIX}${table.id}`}
+ type="target"
+ position={Position.Top}
+ className="!absolute !left-0 !top-0 !h-full !w-full !transform-none !rounded-none !border-none !opacity-0"
+ isConnectable={isRelationshipCreatingTarget}
+ />
+ ) : null}
<TableNodeDependencyIndicator
table={table}
focused={focused}
diff --git a/src/pages/editor-page/canvas/temp-cursor-node/temp-cursor-node.tsx b/src/pages/editor-page/canvas/temp-cursor-node/temp-cursor-node.tsx
new file mode 100644
index 00000000..afa0d6af
--- /dev/null
+++ b/src/pages/editor-page/canvas/temp-cursor-node/temp-cursor-node.tsx
@@ -0,0 +1,36 @@
+import React from 'react';
+import { type NodeProps, type Node, Handle, Position } from '@xyflow/react';
+
+export const TEMP_CURSOR_NODE_ID = '__temp_cursor_node__';
+export const TEMP_CURSOR_HANDLE_ID = '__temp-cursor-target__';
+
+export type TempCursorNodeType = Node<
+ {
+ // Empty data object - this is just a cursor position marker
+ },
+ 'temp-cursor'
+>;
+
+export const TempCursorNode: React.FC<NodeProps<TempCursorNodeType>> =
+ React.memo(() => {
+ // Invisible node that just serves as a connection point
+ return (
+ <div
+ style={{
+ width: 1,
+ height: 1,
+ opacity: 0,
+ pointerEvents: 'none',
+ }}
+ >
+ <Handle
+ id={TEMP_CURSOR_HANDLE_ID}
+ className="!invisible"
+ position={Position.Right}
+ type="target"
+ />
+ </div>
+ );
+ });
+
+TempCursorNode.displayName = 'TempCursorNode';
diff --git a/src/pages/editor-page/canvas/temp-floating-edge/temp-floating-edge.tsx b/src/pages/editor-page/canvas/temp-floating-edge/temp-floating-edge.tsx
new file mode 100644
index 00000000..3b18cd56
--- /dev/null
+++ b/src/pages/editor-page/canvas/temp-floating-edge/temp-floating-edge.tsx
@@ -0,0 +1,64 @@
+import React from 'react';
+import type { Edge, EdgeProps } from '@xyflow/react';
+import { getSmoothStepPath, Position } from '@xyflow/react';
+
+export const TEMP_FLOATING_EDGE_ID = '__temp_floating_edge__';
+
+export type TempFloatingEdgeType = Edge<
+ {
+ // No relationship data - this is a temporary visual edge
+ },
+ 'temp-floating-edge'
+>;
+
+export const TempFloatingEdge: React.FC<EdgeProps<TempFloatingEdgeType>> =
+ React.memo(
+ ({
+ id,
+ sourceX,
+ sourceY,
+ targetX,
+ targetY,
+ sourcePosition = Position.Right,
+ targetPosition = Position.Left,
+ }) => {
+ const [edgePath] = getSmoothStepPath({
+ sourceX,
+ sourceY,
+ sourcePosition,
+ targetX,
+ targetY,
+ targetPosition,
+ borderRadius: 14,
+ });
+
+ return (
+ <g>
+ <path
+ id={id}
+ fill="none"
+ stroke="#ec4899"
+ strokeWidth={2}
+ strokeDasharray="5,5"
+ d={edgePath}
+ style={{
+ pointerEvents: 'none',
+ }}
+ />
+ <circle
+ cx={targetX}
+ cy={targetY}
+ fill="#fff"
+ r={3}
+ stroke="#ec4899"
+ strokeWidth={1.5}
+ style={{
+ pointerEvents: 'none',
+ }}
+ />
+ </g>
+ );
+ }
+ );
+
+TempFloatingEdge.displayName = 'TempFloatingEdge';