Files
omni-tools/src/components/options/RadioWithTextField.tsx

44 lines
949 B
TypeScript
Raw Normal View History

2024-06-26 09:02:05 +01:00
import { Box } from '@mui/material';
2024-06-23 15:14:14 +01:00
import React from 'react';
import TextFieldWithDesc from './TextFieldWithDesc';
2024-06-25 03:11:48 +01:00
import SimpleRadio from './SimpleRadio';
2024-06-23 15:14:14 +01:00
2024-06-27 20:27:03 +01:00
const RadioWithTextField = ({
2024-06-23 15:14:14 +01:00
title,
2024-06-27 20:27:03 +01:00
onRadioClick,
checked,
2024-06-23 15:14:14 +01:00
value,
description,
2024-06-25 03:11:48 +01:00
onTextChange,
2024-06-27 20:27:03 +01:00
radioDescription
2024-06-23 15:14:14 +01:00
}: {
fieldName: string;
title: string;
2024-06-27 20:27:03 +01:00
checked: boolean;
onRadioClick: () => void;
2024-06-23 15:14:14 +01:00
value: string;
description: string;
onTextChange: (value: string) => void;
2024-06-27 20:27:03 +01:00
radioDescription?: string;
2024-06-23 15:14:14 +01:00
}) => {
return (
<Box>
2024-06-25 03:11:48 +01:00
<SimpleRadio
2024-06-27 20:27:03 +01:00
checked={checked}
onClick={onRadioClick}
2024-06-25 03:11:48 +01:00
title={title}
2024-06-27 20:27:03 +01:00
description={radioDescription}
2024-06-25 03:11:48 +01:00
/>
2024-06-23 15:14:14 +01:00
<TextFieldWithDesc
value={value}
2024-06-27 12:39:38 +01:00
onChange={(val) => {
if (typeof val === 'string') onTextChange(val);
else onTextChange(val.target.value);
}}
2024-06-23 15:14:14 +01:00
description={description}
/>
</Box>
);
};
export default RadioWithTextField;