import type { ComponentProps, ReactNode } from "react"; import { NodeResizeControl } from "@xyflow/react"; import { cn } from "@/lib/utils"; export type BaseNodeProps = ComponentProps<"div"> & { /** When true, shows a bottom-right resize handle. Requires nodeId when used inside React Flow. */ resizable?: boolean; /** Node id for the resize control (required when resizable is true). */ nodeId?: string; /** Connection handles (InputHandle, OutputHandle). Rendered outside the overflow layer so they stay visible. */ handles?: ReactNode; /** When provided, node uses this size (e.g. from React Flow width/height). Enables correct resize behavior. */ dimensions?: { width: number; height: number }; }; export function BaseNode({ className, style, dimensions, resizable, nodeId, handles, children, ...props }: BaseNodeProps) { const hasSize = dimensions && dimensions.width > 0 && dimensions.height > 0; // Don't set overflow: hidden on the root — handles are positioned at left/right -10px // and would be clipped. The inner content wrapper has overflow-hidden for scrolling. const appliedStyle = hasSize ? { ...style, width: dimensions.width, height: dimensions.height, display: "flex" as const, flexDirection: "column" as const, contain: "layout" as const, } : style ? { ...style, display: "flex", flexDirection: "column" as const } : undefined; return (