|
|
@ -18,10 +18,12 @@ const RadioGroupWithLabel: FC<RadioGroupWithLabelProps> = ({ |
|
|
|
formLabelProps, |
|
|
|
formLabelProps, |
|
|
|
id, |
|
|
|
id, |
|
|
|
label, |
|
|
|
label, |
|
|
|
|
|
|
|
name, |
|
|
|
onChange: onRadioGroupChange, |
|
|
|
onChange: onRadioGroupChange, |
|
|
|
radioItems, |
|
|
|
radioItems, |
|
|
|
radioProps: { sx: radioSx, ...restRadioProps } = {}, |
|
|
|
radioProps: { sx: radioSx, ...restRadioProps } = {}, |
|
|
|
radioGroupProps, |
|
|
|
radioGroupProps, |
|
|
|
|
|
|
|
value, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const labelElement = useMemo( |
|
|
|
const labelElement = useMemo( |
|
|
|
() => (typeof label === 'string' ? <BodyText>{label}</BodyText> : label), |
|
|
|
() => (typeof label === 'string' ? <BodyText>{label}</BodyText> : label), |
|
|
@ -30,7 +32,7 @@ const RadioGroupWithLabel: FC<RadioGroupWithLabelProps> = ({ |
|
|
|
const itemElements = useMemo(() => { |
|
|
|
const itemElements = useMemo(() => { |
|
|
|
const items = Object.entries(radioItems); |
|
|
|
const items = Object.entries(radioItems); |
|
|
|
|
|
|
|
|
|
|
|
return items.map(([itemId, { label: itemLabel, value }]) => { |
|
|
|
return items.map(([itemId, { label: itemLabel, value: itemValue }]) => { |
|
|
|
const itemLabelElement = |
|
|
|
const itemLabelElement = |
|
|
|
typeof itemLabel === 'string' ? ( |
|
|
|
typeof itemLabel === 'string' ? ( |
|
|
|
<BodyText>{itemLabel}</BodyText> |
|
|
|
<BodyText>{itemLabel}</BodyText> |
|
|
@ -53,7 +55,7 @@ const RadioGroupWithLabel: FC<RadioGroupWithLabelProps> = ({ |
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
key={`${id}-${itemId}`} |
|
|
|
key={`${id}-${itemId}`} |
|
|
|
value={value} |
|
|
|
value={itemValue} |
|
|
|
label={itemLabelElement} |
|
|
|
label={itemLabelElement} |
|
|
|
{...formControlLabelProps} |
|
|
|
{...formControlLabelProps} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -64,7 +66,14 @@ const RadioGroupWithLabel: FC<RadioGroupWithLabelProps> = ({ |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<MUIFormControl {...formControlProps}> |
|
|
|
<MUIFormControl {...formControlProps}> |
|
|
|
<MUIFormLabel {...formLabelProps}>{labelElement}</MUIFormLabel> |
|
|
|
<MUIFormLabel {...formLabelProps}>{labelElement}</MUIFormLabel> |
|
|
|
<MUIRadioGroup onChange={onRadioGroupChange} row {...radioGroupProps}> |
|
|
|
<MUIRadioGroup |
|
|
|
|
|
|
|
id={id} |
|
|
|
|
|
|
|
name={name} |
|
|
|
|
|
|
|
onChange={onRadioGroupChange} |
|
|
|
|
|
|
|
row |
|
|
|
|
|
|
|
value={value} |
|
|
|
|
|
|
|
{...radioGroupProps} |
|
|
|
|
|
|
|
> |
|
|
|
{itemElements} |
|
|
|
{itemElements} |
|
|
|
</MUIRadioGroup> |
|
|
|
</MUIRadioGroup> |
|
|
|
</MUIFormControl> |
|
|
|
</MUIFormControl> |
|
|
|