diff --git a/src/components/nodes/InteractionNode.tsx b/src/components/nodes/InteractionNode.tsx new file mode 100644 index 0000000..b164103 --- /dev/null +++ b/src/components/nodes/InteractionNode.tsx @@ -0,0 +1,120 @@ +import { memo, useState } from 'react'; +import { Handle, Position } from '@xyflow/react'; +import type { NodeProps } from '@xyflow/react'; +import { MessageSquare, ChevronDown, ChevronUp } from 'lucide-react'; +import type { InteractionNodeData } from '../../types/nodes'; + +export const InteractionNode = memo(({ data }: NodeProps) => { + const [isExpanded, setIsExpanded] = useState(true); + const nodeData = data as InteractionNodeData; + + const handleChange = (field: keyof InteractionNodeData, value: string | undefined) => { + Object.assign(nodeData, { [field]: value }); + }; + + return ( +
+ {/* Node Header */} +
+
+ + Interaction +
+ +
+ + {/* Input Handle */} + + + {/* Node Content */} + {isExpanded && ( +
+
+ + +
+ + {nodeData.interactionType === 'dialogue' && ( +
+ + handleChange('dialogueReference', e.target.value)} + className="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:ring-2 focus:ring-purple-500 focus:border-purple-500" + placeholder="cobblemon:my_dialogue" + /> +

+ Reference to a dialogue configuration +

+
+ )} + + {nodeData.interactionType === 'script' && ( +
+ + handleChange('scriptReference', e.target.value)} + className="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:ring-2 focus:ring-purple-500 focus:border-purple-500" + placeholder="cobblemon:interaction_script" + /> +

+ MoLang script for custom interactions +

+
+ )} + + {nodeData.interactionType === 'none' && ( +
+ No interaction configured +
+ )} + + {(nodeData.interactionType === 'shop' || nodeData.interactionType === 'heal') && ( +
+ {nodeData.interactionType === 'shop' + ? 'Shop interaction - configure items in data' + : 'Heal interaction - heals player Pokemon'} +
+ )} +
+ )} + + {/* Output Handle */} + +
+ ); +}); + +InteractionNode.displayName = 'InteractionNode';