45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import * as React from "react";
|
|
import { ComponentProps } from "./BaseComponent";
|
|
import { Radio, RadioGroup, IOptionProps } from "@blueprintjs/core";
|
|
import { Container } from "./ContainerComponent";
|
|
class RadioGroupComponent extends React.Component<RadioGroupComponentProps> {
|
|
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 key={item.key} label={item.label} value={item.value} />
|
|
))}
|
|
</RadioGroup>
|
|
</Container>
|
|
);
|
|
}
|
|
}
|
|
|
|
export interface RadioGroupComponentProps extends ComponentProps {
|
|
label: string;
|
|
inline: boolean;
|
|
selectedValue: string | number;
|
|
handleRadioChange: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
disabled: boolean;
|
|
className: string;
|
|
name: string;
|
|
options: IOptionProps[];
|
|
items: Array<{
|
|
label: string;
|
|
key: string;
|
|
value: number | string;
|
|
}>;
|
|
}
|
|
|
|
export default RadioGroupComponent;
|