Add method to disable StyledRadioGroup and wrap description in element with a className

This commit is contained in:
Michael Telatynski 2021-06-08 16:31:39 +01:00
parent 5c85ee1ea0
commit 78debcc93b

View file

@ -34,10 +34,19 @@ interface IProps<T extends string> {
definitions: IDefinition<T>[]; definitions: IDefinition<T>[];
value?: T; // if not provided no options will be selected value?: T; // if not provided no options will be selected
outlined?: boolean; outlined?: boolean;
disabled?: boolean;
onChange(newValue: T): void; onChange(newValue: T): void;
} }
function StyledRadioGroup<T extends string>({name, definitions, value, className, outlined, onChange}: IProps<T>) { function StyledRadioGroup<T extends string>({
name,
definitions,
value,
className,
outlined,
disabled,
onChange,
}: IProps<T>) {
const _onChange = e => { const _onChange = e => {
onChange(e.target.value); onChange(e.target.value);
}; };
@ -50,12 +59,12 @@ function StyledRadioGroup<T extends string>({name, definitions, value, className
checked={d.checked !== undefined ? d.checked : d.value === value} checked={d.checked !== undefined ? d.checked : d.value === value}
name={name} name={name}
value={d.value} value={d.value}
disabled={d.disabled} disabled={disabled || d.disabled}
outlined={outlined} outlined={outlined}
> >
{d.label} { d.label }
</StyledRadioButton> </StyledRadioButton>
{d.description} { d.description ? <span>{ d.description }</span> : null }
</React.Fragment>)} </React.Fragment>)}
</React.Fragment>; </React.Fragment>;
} }