PromucFlow_constructor/app/client/src/components/designSystems/blueprint/RadioGroupComponent.tsx

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-11-05 05:09:50 +00:00
import React from "react";
import { ComponentProps } from "../appsmith/BaseComponent";
import { RadioOption } from "../../../widgets/RadioGroupWidget";
import { RadioGroup, Radio } from "@blueprintjs/core";
class RadioGroupComponent extends React.Component<RadioGroupComponentProps> {
render() {
return (
<RadioGroup
label={this.props.label}
selectedValue={this.props.selectedOptionValue}
onChange={this.onRadioSelectionChange}
>
{this.props.options.map(option => {
return (
<Radio
label={option.label}
value={option.value}
key={option.value}
/>
);
})}
</RadioGroup>
2019-11-05 05:09:50 +00:00
);
}
onRadioSelectionChange = (event: React.FormEvent<HTMLInputElement>) => {
this.props.onRadioSelectionChange(event.currentTarget.value);
};
}
export interface RadioGroupComponentProps extends ComponentProps {
label: string;
options: RadioOption[];
onRadioSelectionChange: (updatedOptionValue: string) => void;
selectedOptionValue: string;
}
export default RadioGroupComponent;