2026-01-14 20:00:35 -05:00
|
|
|
import { DragEvent } from 'react';
|
|
|
|
|
import { NodeType } from '../../../lib/canvas/schema';
|
2026-01-15 22:29:39 -05:00
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Cpu,
|
|
|
|
|
SlidersHorizontal,
|
|
|
|
|
FlaskConical,
|
|
|
|
|
Target,
|
|
|
|
|
ShieldAlert,
|
|
|
|
|
BrainCircuit,
|
|
|
|
|
Rocket,
|
|
|
|
|
} from 'lucide-react';
|
2026-01-14 20:00:35 -05:00
|
|
|
|
|
|
|
|
interface PaletteItem {
|
|
|
|
|
type: NodeType;
|
|
|
|
|
label: string;
|
2026-01-15 22:29:39 -05:00
|
|
|
icon: React.ReactNode;
|
2026-01-14 20:00:35 -05:00
|
|
|
description: string;
|
2026-01-15 22:29:39 -05:00
|
|
|
color: string;
|
2026-01-14 20:00:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PALETTE_ITEMS: PaletteItem[] = [
|
2026-01-15 22:29:39 -05:00
|
|
|
{ type: 'model', label: 'Model', icon: <Box size={18} />, description: 'NX model file (.prt, .sim)', color: 'text-blue-400' },
|
|
|
|
|
{ type: 'solver', label: 'Solver', icon: <Cpu size={18} />, description: 'Nastran solution type', color: 'text-violet-400' },
|
|
|
|
|
{ type: 'designVar', label: 'Design Variable', icon: <SlidersHorizontal size={18} />, description: 'Parameter to optimize', color: 'text-emerald-400' },
|
|
|
|
|
{ type: 'extractor', label: 'Extractor', icon: <FlaskConical size={18} />, description: 'Physics result extraction', color: 'text-cyan-400' },
|
|
|
|
|
{ type: 'objective', label: 'Objective', icon: <Target size={18} />, description: 'Optimization goal', color: 'text-rose-400' },
|
|
|
|
|
{ type: 'constraint', label: 'Constraint', icon: <ShieldAlert size={18} />, description: 'Design constraint', color: 'text-amber-400' },
|
|
|
|
|
{ type: 'algorithm', label: 'Algorithm', icon: <BrainCircuit size={18} />, description: 'Optimization method', color: 'text-indigo-400' },
|
|
|
|
|
{ type: 'surrogate', label: 'Surrogate', icon: <Rocket size={18} />, description: 'Neural acceleration', color: 'text-pink-400' },
|
2026-01-14 20:00:35 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function NodePalette() {
|
|
|
|
|
const onDragStart = (event: DragEvent, nodeType: NodeType) => {
|
|
|
|
|
event.dataTransfer.setData('application/reactflow', nodeType);
|
|
|
|
|
event.dataTransfer.effectAllowed = 'move';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-01-16 11:34:41 -05:00
|
|
|
<div className="w-60 bg-dark-850 border-r border-dark-700 flex flex-col">
|
2026-01-15 22:29:39 -05:00
|
|
|
<div className="p-4 border-b border-dark-700">
|
2026-01-16 11:34:41 -05:00
|
|
|
<h3 className="text-sm font-semibold text-dark-300 uppercase tracking-wider">
|
2026-01-15 22:29:39 -05:00
|
|
|
Components
|
|
|
|
|
</h3>
|
2026-01-16 11:34:41 -05:00
|
|
|
<p className="text-xs text-dark-400 mt-1">
|
2026-01-15 22:29:39 -05:00
|
|
|
Drag to canvas
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-01-16 11:34:41 -05:00
|
|
|
<div className="flex-1 overflow-y-auto p-3 space-y-2">
|
2026-01-14 20:00:35 -05:00
|
|
|
{PALETTE_ITEMS.map((item) => (
|
|
|
|
|
<div
|
|
|
|
|
key={item.type}
|
|
|
|
|
draggable
|
|
|
|
|
onDragStart={(e) => onDragStart(e, item.type)}
|
2026-01-16 11:34:41 -05:00
|
|
|
className="flex items-center gap-3 px-3 py-3 bg-dark-800/50 rounded-lg border border-dark-700/50
|
2026-01-15 22:29:39 -05:00
|
|
|
cursor-grab hover:border-primary-500/50 hover:bg-dark-800
|
|
|
|
|
active:cursor-grabbing transition-all group"
|
2026-01-14 20:00:35 -05:00
|
|
|
>
|
2026-01-16 11:34:41 -05:00
|
|
|
<div className={`${item.color} opacity-90 group-hover:opacity-100 transition-opacity`}>
|
2026-01-15 22:29:39 -05:00
|
|
|
{item.icon}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-1 min-w-0">
|
2026-01-16 11:34:41 -05:00
|
|
|
<div className="font-semibold text-white text-sm leading-tight">{item.label}</div>
|
|
|
|
|
<div className="text-xs text-dark-400 truncate">{item.description}</div>
|
2026-01-14 20:00:35 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|