import React from "react"; import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget"; import { WidgetType } from "constants/WidgetConstants"; import CheckboxComponent from "components/designSystems/blueprint/CheckboxComponent"; import { ActionPayload } from "constants/ActionConstants"; import { VALIDATION_TYPES } from "constants/WidgetValidation"; import { WidgetPropertyValidationType } from "utils/ValidationFactory"; class CheckboxWidget extends BaseWidget { static getPropertyValidationMap(): WidgetPropertyValidationType { return { isDisabled: VALIDATION_TYPES.BOOLEAN, label: VALIDATION_TYPES.TEXT, defaultCheckedState: VALIDATION_TYPES.BOOLEAN, isChecked: VALIDATION_TYPES.BOOLEAN, }; } getPageView() { return ( ); } onCheckChange = (isChecked: boolean) => { this.updateWidgetProperty("isChecked", isChecked); super.executeAction(this.props.onCheckChange); }; getWidgetType(): WidgetType { return "CHECKBOX_WIDGET"; } } export interface CheckboxWidgetProps extends WidgetProps { label: string; defaultCheckedState: boolean; isChecked?: boolean; isDisabled?: boolean; onCheckChange?: ActionPayload[]; } export default CheckboxWidget;