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

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-11-05 05:09:50 +00:00
import React from "react";
2019-11-25 05:07:27 +00:00
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
import { RadioOption } from "widgets/RadioGroupWidget";
2019-11-05 05:09:50 +00:00
import { RadioGroup, Radio } from "@blueprintjs/core";
2019-11-05 05:09:50 +00:00
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 (
2019-12-03 04:41:10 +00:00
<Radio
className={this.props.isLoading ? "bp3-skeleton" : ""}
label={option.label}
value={option.value}
key={option.id}
/>
);
})}
</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;
2019-12-03 04:41:10 +00:00
isLoading: boolean;
2019-11-05 05:09:50 +00:00
}
export default RadioGroupComponent;