'use client'; import * as React from 'react'; import { Eye, EyeOff, ChevronDown, ChevronUp } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/utils/cn'; import type { AutomationMode } from '@/types/automation'; export interface AutomationHeaderProps { parameterName: string; currentValue?: number; visible: boolean; mode: AutomationMode; color?: string; onToggleVisible?: () => void; onModeChange?: (mode: AutomationMode) => void; onHeightChange?: (delta: number) => void; className?: string; formatter?: (value: number) => string; // Parameter selection availableParameters?: Array<{ id: string; name: string }>; selectedParameterId?: string; onParameterChange?: (parameterId: string) => void; } const MODE_LABELS: Record = { read: 'R', write: 'W', touch: 'T', latch: 'L', }; const MODE_COLORS: Record = { read: 'text-muted-foreground', write: 'text-red-500', touch: 'text-yellow-500', latch: 'text-orange-500', }; export function AutomationHeader({ parameterName, currentValue, visible, mode, color, onToggleVisible, onModeChange, onHeightChange, className, formatter, availableParameters, selectedParameterId, onParameterChange, }: AutomationHeaderProps) { const modes: AutomationMode[] = ['read', 'write', 'touch', 'latch']; const currentModeIndex = modes.indexOf(mode); const handleCycleModeClick = () => { if (!onModeChange) return; const nextIndex = (currentModeIndex + 1) % modes.length; onModeChange(modes[nextIndex]); }; const formatValue = (value: number) => { if (formatter) return formatter(value); return value.toFixed(2); }; return (
{/* Color indicator */} {color && (
)} {/* Parameter name / selector */} {availableParameters && availableParameters.length > 1 ? ( ) : ( {parameterName} )} {/* Current value display */} {currentValue !== undefined && ( {formatValue(currentValue)} )} {/* Automation mode button */} {/* Height controls */} {onHeightChange && (
)} {/* Show/hide toggle - Positioned absolutely on the right */}
); }