Files
VirtWeb/virtweb_frontend/src/widgets/forms/RadioGroupInput.tsx
Pierre HUBERT f5202f596d
All checks were successful
continuous-integration/drone/push Build is passing
Fix all ESLint errors
2025-03-28 12:25:04 +01:00

44 lines
854 B
TypeScript

import {
RadioGroup,
FormControlLabel,
Radio,
FormControl,
FormLabel,
} from "@mui/material";
interface RadioGroupOption {
label: string;
value: string;
}
export function RadioGroupInput(p: {
editable: boolean;
label?: string;
options: RadioGroupOption[];
value: string;
onValueChange: (v: string) => void;
}): React.ReactElement {
return (
<FormControl>
{p.label && <FormLabel>{p.label}</FormLabel>}
<RadioGroup
row
value={p.value}
onChange={(_ev, v) => {
p.onValueChange(v);
}}
>
{p.options.map((o) => (
<FormControlLabel
key={o.value}
disabled={!p.editable}
value={o.value}
control={<Radio />}
label={o.label}
/>
))}
</RadioGroup>
</FormControl>
);
}