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

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-06-23 15:14:14 +01:00
import { SplitOperatorType } from '../../pages/string/split/service';
import { Box, Stack } from '@mui/material';
import { Field } from 'formik';
import Typography from '@mui/material/Typography';
import React from 'react';
import TextFieldWithDesc from './TextFieldWithDesc';
2024-06-25 03:11:48 +01:00
import { globalDescriptionFontSize } from '../../config/uiConfig';
import SimpleRadio from './SimpleRadio';
2024-06-23 15:14:14 +01:00
const RadioWithTextField = <T,>({
fieldName,
2024-06-25 03:11:48 +01:00
radioValue,
2024-06-23 15:14:14 +01:00
title,
2024-06-25 03:11:48 +01:00
onRadioChange,
2024-06-23 15:14:14 +01:00
value,
description,
2024-06-25 03:11:48 +01:00
onTextChange,
typeDescription
2024-06-23 15:14:14 +01:00
}: {
fieldName: string;
title: string;
2024-06-25 03:11:48 +01:00
radioValue: T;
onRadioChange: (val: T) => void;
2024-06-23 15:14:14 +01:00
value: string;
description: string;
onTextChange: (value: string) => void;
2024-06-25 03:11:48 +01:00
typeDescription?: string;
2024-06-23 15:14:14 +01:00
}) => {
2024-06-25 03:11:48 +01:00
const onChange = () => onRadioChange(radioValue);
2024-06-23 15:14:14 +01:00
return (
<Box>
2024-06-25 03:11:48 +01:00
<SimpleRadio
value={radioValue}
onChange={onChange}
fieldName={fieldName}
title={title}
description={typeDescription}
/>
2024-06-23 15:14:14 +01:00
<TextFieldWithDesc
value={value}
onChange={onTextChange}
description={description}
/>
</Box>
);
};
export default RadioWithTextField;