PromucFlow_constructor/app/client/src/editorComponents/RadioGroupComponent.tsx

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-03-21 12:10:32 +00:00
import * as React from "react"
2019-09-05 17:47:50 +00:00
import { ComponentProps } from "./BaseComponent"
2019-03-21 12:10:32 +00:00
import { Radio, RadioGroup, IOptionProps } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
2019-08-29 11:22:09 +00:00
class RadioGroupComponent extends React.Component<RadioGroupComponentProps> {
2019-03-21 12:10:32 +00:00
render() {
return (
<Container {...this.props}>
<RadioGroup
inline={this.props.inline}
label={this.props.label}
name={this.props.name}
onChange={this.props.handleRadioChange}
selectedValue={this.props.selectedValue}
disabled={this.props.disabled}
className={this.props.className}
options={this.props.options}
>
{this.props.items.map(item => (
<Radio label={item.label} value={item.value} />
))}
</RadioGroup>
</Container>
)
}
}
2019-09-05 17:47:50 +00:00
export interface RadioGroupComponentProps extends ComponentProps {
2019-08-29 11:22:09 +00:00
label: string;
inline: boolean;
selectedValue: string | number;
handleRadioChange: (event: React.FormEvent<HTMLInputElement>) => void;
disabled: boolean;
className: string;
name: string;
options: IOptionProps[];
2019-03-21 12:10:32 +00:00
items: Array<{
2019-08-29 11:22:09 +00:00
label: string;
value: number | string;
}>;
2019-03-21 12:10:32 +00:00
}
export default RadioGroupComponent