import { NodeResizer, type NodeProps, type Node } from '@xyflow/react' import { useCanvasStore } from '@/stores/canvasStore' import type { NodeData, TextPosition } from '@/types' const FONT_FAMILIES: Record = { inter: 'Inter, sans-serif', mono: '"JetBrains Mono", monospace', serif: 'Georgia, serif', } interface AlignStyle { alignItems: string justifyContent: string textAlign: React.CSSProperties['textAlign'] } const POSITION_STYLES: Record = { 'top-left': { alignItems: 'flex-start', justifyContent: 'flex-start', textAlign: 'left' }, 'top-center': { alignItems: 'flex-start', justifyContent: 'center', textAlign: 'center' }, 'top-right': { alignItems: 'flex-start', justifyContent: 'flex-end', textAlign: 'right' }, 'middle-left': { alignItems: 'center', justifyContent: 'flex-start', textAlign: 'left' }, 'center': { alignItems: 'center', justifyContent: 'center', textAlign: 'center' }, 'middle-right': { alignItems: 'center', justifyContent: 'flex-end', textAlign: 'right' }, 'bottom-left': { alignItems: 'flex-end', justifyContent: 'flex-start', textAlign: 'left' }, 'bottom-center': { alignItems: 'flex-end', justifyContent: 'center', textAlign: 'center' }, 'bottom-right': { alignItems: 'flex-end', justifyContent: 'flex-end', textAlign: 'right' }, } export function GroupRectNode({ id, data, selected }: NodeProps>) { const setEditingGroupRectId = useCanvasStore((s) => s.setEditingGroupRectId) const rc = data.custom_colors ?? {} const borderColor = rc.border ?? '#00d4ff' const borderStyle = rc.border_style ?? 'solid' const backgroundColor = rc.background ?? 'rgba(0,212,255,0.05)' const textColor = rc.text_color ?? '#e6edf3' const fontFamily = FONT_FAMILIES[rc.font ?? 'inter'] ?? FONT_FAMILIES.inter const textPos = (rc.text_position ?? 'top-left') as TextPosition const posStyle = POSITION_STYLES[textPos] return ( <>
{ e.stopPropagation() setEditingGroupRectId(id) }} > {data.label && ( {data.label} )}
) }