import React from "react"; import type { ParamDef } from "../scenarios/types"; interface ParamControlsProps

> { paramsDef: Record>; values: P; onChange: (key: keyof P, value: number) => void; onReset: () => void; } export function ParamControls

>({ paramsDef, values, onChange, onReset, }: ParamControlsProps

): React.JSX.Element { const paramKeys = (Object.keys(paramsDef) as (keyof P)[]).filter((key) => { const spec = paramsDef[key]; if (!spec) return false; if (spec.hidden) return false; if (spec.visibleWhen && !spec.visibleWhen(values)) return false; return true; }); return (

Điều khiển thông số mô phỏng

{paramKeys.map((key) => { const def = paramsDef[key]; const val = values[key] ?? def.default; return (
{val} {def.unit ?? ""}
onChange(key, parseFloat(e.target.value))} className="w-full accent-indigo-600 cursor-pointer h-2 bg-slate-200 rounded-lg" /> {def.marks && def.marks.length > 0 ? (
{def.marks.map((m, idx) => ( {m.label} ))}
) : (
Min: {def.min} {def.unit ?? ""} Mặc định: {def.default} {def.unit ?? ""} Max: {def.max} {def.unit ?? ""}
)} {def.description && (

{def.description}

)}
); })}
); }