import Box from '@mui/material/Box'; import RadioGroup from '@mui/material/RadioGroup'; import type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4'; import type { ReactNode } from 'react'; import { ChoiceItemOrientation } from '../../../interfaces/choice.enum'; import { useRendererConfigStore } from '../../../stores'; import { getChoiceOrientation } from '../../../utils/choice'; import { StyledRequiredTypography } from '../Item.styles'; import ClearInputButton from './ClearInputButton'; import ExpressionUpdateFadingIcon from './ExpressionUpdateFadingIcon'; import RadioOptionList from './RadioOptionList'; interface ChoiceRadioGroupProps { qItem: QuestionnaireItem; options: QuestionnaireItemAnswerOption[]; valueRadio: string | null; feedback: string; feedbackSeverity?: 'error' | 'warning'; readOnly: boolean; expressionUpdated: boolean; answerOptionsToggleExpressionsMap: Map; isTabled: boolean; instructionsId?: string | undefined; onCheckedChange: (newValue: string) => void; onClear: () => void; children?: ReactNode; // Mainly used for open-choice openLabel field } function RadioFormGroup(props: ChoiceRadioGroupProps) { const { qItem, options, valueRadio, feedback, feedbackSeverity, readOnly, expressionUpdated, answerOptionsToggleExpressionsMap, isTabled, instructionsId, onCheckedChange, onClear, children } = props; const readOnlyVisualStyle = useRendererConfigStore.use.readOnlyVisualStyle(); const inputsFlexGrow = useRendererConfigStore.use.inputsFlexGrow(); const rendererStrings = useRendererConfigStore.use.rendererStrings(); const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical; return ( <> { // If item.readOnly=true, do not allow any changes if (readOnly) { return; } onCheckedChange(e.target.value); }} value={valueRadio} data-test="q-item-radio-group"> {children} {feedback ? ( {feedback} ) : null} ); } export default RadioFormGroup;