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

39 lines
1.0 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";
2019-10-30 10:23:20 +00:00
import RadioGroupComponent from "../components/blueprint/RadioGroupComponent";
import { ActionPayload } from "../constants/ActionConstants";
2019-03-21 12:10:32 +00:00
class RadioGroupWidget 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}
label={this.props.label}
2019-09-12 08:11:25 +00:00
defaultOptionValue={this.props.defaultOptionValue}
2019-03-21 12:10:32 +00:00
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-12 08:11:25 +00:00
export interface RadioOption {
label: string;
value: string;
2019-09-12 08:11:25 +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;
options: RadioOption[];
defaultOptionValue: string;
onOptionSelected?: ActionPayload[];
2019-03-21 12:10:32 +00:00
}
export default RadioGroupWidget;