2025-09-09 14:37:32 +05:30
|
|
|
import { Handle, HandleProps } from "@xyflow/react";
|
|
|
|
|
import { forwardRef } from "react";
|
|
|
|
|
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
export type BaseHandleProps = HandleProps;
|
|
|
|
|
|
|
|
|
|
export const BaseHandle = forwardRef<HTMLDivElement, BaseHandleProps>(
|
2025-11-06 18:26:15 +05:30
|
|
|
({ className, children, type, ...props }, ref) => {
|
|
|
|
|
const isSource = type === 'source';
|
|
|
|
|
const isTarget = type === 'target';
|
|
|
|
|
|
2025-09-09 14:37:32 +05:30
|
|
|
return (
|
|
|
|
|
<Handle
|
|
|
|
|
ref={ref}
|
2025-11-06 18:26:15 +05:30
|
|
|
type={type}
|
2025-09-09 14:37:32 +05:30
|
|
|
{...props}
|
|
|
|
|
className={cn(
|
2025-11-06 18:26:15 +05:30
|
|
|
"transition-all hover:!bg-blue-500",
|
|
|
|
|
// Source (outgoing) has larger visible handle for easier connection
|
|
|
|
|
isSource && "!h-[16px] !w-[16px] rounded-full",
|
|
|
|
|
// Target (incoming) smaller rectangle
|
|
|
|
|
isTarget && "!h-[10px] !w-[14px] rounded-sm",
|
2025-09-09 14:37:32 +05:30
|
|
|
className,
|
|
|
|
|
)}
|
2025-11-06 18:26:15 +05:30
|
|
|
style={{
|
|
|
|
|
border: 'none',
|
|
|
|
|
background: '#94A3B8', // slate-400
|
|
|
|
|
...props.style,
|
|
|
|
|
}}
|
2025-09-09 14:37:32 +05:30
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</Handle>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
BaseHandle.displayName = "BaseHandle";
|