PromucFlow_constructor/app/client/src/widgets/RadioGroupWidget.tsx

49 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-09-09 09:08:54 +00:00
import * as React from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "../constants/WidgetConstants";
import RadioGroupComponent from "../editorComponents/RadioGroupComponent";
import { IOptionProps } from "@blueprintjs/core";
2019-03-21 12:10:32 +00:00
2019-09-09 09:08:54 +00:00
class RadioButtonWidget extends BaseWidget<RadioGroupWidgetProps, WidgetState> {
2019-03-21 12:10:32 +00:00
getPageView() {
return (
<RadioGroupComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
key={this.props.widgetId}
inline={this.props.inline}
label={this.props.label}
name={this.props.name}
handleRadioChange={this.props.handleRadioChange}
selectedValue={this.props.selectedValue}
items={this.props.items}
disabled={this.props.disabled}
className={this.props.className}
options={this.props.options}
/>
2019-09-09 09:08:54 +00:00
);
2019-03-21 12:10:32 +00:00
}
getWidgetType(): WidgetType {
2019-09-09 09:08:54 +00:00
return "RADIO_GROUP_WIDGET";
2019-03-21 12:10:32 +00:00
}
}
2019-09-09 09:08:54 +00:00
export interface RadioGroupWidgetProps extends WidgetProps {
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-09-09 09:08:54 +00:00
key: string;
2019-08-29 11:22:09 +00:00
}>;
2019-03-21 12:10:32 +00:00
}
2019-09-09 09:08:54 +00:00
export default RadioButtonWidget;