import { useState } from 'react'; import { cn } from '@/lib/utils'; import { WheelRange } from '@/components/WheelRange'; // LevelRow — a named level with a slider, a value you can type into, and ±. // // Shared, like ShiftRow, and for the same complaint: the consoles each drew // their levels their own way. This is the wide shape — one row per level, the // slider taking the width it needs — rather than two half-width sliders side by // side, which is what "c'est laid et elles sont toutes petites" was about. // // Four ways to move it, so nobody has to learn ours: drag, wheel over the // track, ± for one step, or click the number and type. Typing matters for the // levels TCI reports in real units — a squelch at -95 dBm is a value an // operator knows, not a position to hunt for with a mouse. export function LevelRow({ label, value, min = 0, max = 100, step = 1, unit = '', accent, disabled, onSet, }: { label: string; value: number; min?: number; max?: number; step?: number; unit?: string; accent?: string; disabled?: boolean; onSet: (v: number) => void; }) { const [editing, setEditing] = useState(null); const clamp = (v: number) => Math.max(min, Math.min(max, v)); const commit = (raw: string) => { setEditing(null); const v = parseInt(raw.replace(/[^0-9+-]/g, ''), 10); if (!Number.isNaN(v)) onSet(clamp(v)); }; return (
{label}
{editing !== null ? ( setEditing(e.target.value)} onBlur={(e) => commit(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') commit((e.target as HTMLInputElement).value); else if (e.key === 'Escape') setEditing(null); }} className="w-14 rounded border border-border bg-background px-1 text-right text-xs font-mono tabular-nums outline-none" /> ) : ( )}
); }