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

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-09-09 09:08:54 +00:00
import * as React from "react";
import { ComponentProps } from "./BaseComponent";
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 => (
2019-09-09 09:08:54 +00:00
<Radio key={item.key} label={item.label} value={item.value} />
2019-03-21 12:10:32 +00:00
))}
</RadioGroup>
</Container>
2019-09-09 09:08:54 +00:00
);
2019-03-21 12:10:32 +00:00
}
}
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;
2019-09-09 09:08:54 +00:00
key: string;
2019-08-29 11:22:09 +00:00
value: number | string;
}>;
2019-03-21 12:10:32 +00:00
}
2019-09-09 09:08:54 +00:00
export default RadioGroupComponent;