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

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-09-09 09:08:54 +00:00
import React from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "../constants/WidgetConstants";
2019-11-04 10:57:19 +00:00
import CheckboxComponent from "../components/designSystems/blueprint/CheckboxComponent";
import { ActionPayload } from "../constants/ActionConstants";
2019-03-21 12:10:32 +00:00
2019-09-09 09:08:54 +00:00
class CheckboxWidget extends BaseWidget<CheckboxWidgetProps, WidgetState> {
2019-03-21 12:10:32 +00:00
getPageView() {
return (
<CheckboxComponent
style={this.getPositionStyle()}
2019-09-12 08:11:25 +00:00
defaultCheckedState={this.props.defaultCheckedState}
label={this.props.label}
2019-03-21 12:10:32 +00:00
widgetId={this.props.widgetId}
key={this.props.widgetId}
isDisabled={this.props.isDisabled}
onCheckChange={this.onCheckChange}
2019-03-21 12:10:32 +00:00
/>
2019-09-09 09:08:54 +00:00
);
2019-03-21 12:10:32 +00:00
}
onCheckChange = (isChecked: boolean) => {
this.context.updateWidgetProperty(
this.props.widgetId,
"isChecked",
isChecked,
);
};
2019-03-21 12:10:32 +00:00
getWidgetType(): WidgetType {
return "CHECKBOX_WIDGET";
2019-03-21 12:10:32 +00:00
}
}
2019-09-09 09:08:54 +00:00
export interface CheckboxWidgetProps extends WidgetProps {
label: string;
defaultCheckedState: boolean;
isChecked?: boolean;
isDisabled?: boolean;
onCheckChange?: ActionPayload[];
2019-03-21 12:10:32 +00:00
}
2019-09-09 09:08:54 +00:00
export default CheckboxWidget;