PromucFlow_constructor/app/client/src/components/propertyControls/SwitchControl.tsx
Aswath K c29fd2db19
chore: Adds canDisplayValue to property controls (#13309)
* Adds canDisplayValue to property controls

* Adds tests

* add fn for LocationSearch & ActionSelector

* Adds CSV value support in ButtonTabControl
2022-06-03 10:37:02 +05:30

34 lines
838 B
TypeScript

import React from "react";
import BaseControl, { ControlData, ControlProps } from "./BaseControl";
import Switch from "components/ads/Switch";
class SwitchControl extends BaseControl<ControlProps> {
render() {
return (
<Switch
checked={this.props.propertyValue}
className={this.props.propertyValue ? "checked" : "unchecked"}
defaultChecked={this.props.propertyValue}
large
onChange={this.onToggle}
/>
);
}
onToggle = () => {
this.updateProperty(this.props.propertyName, !this.props.propertyValue);
};
static getControlType() {
return "SWITCH";
}
static canDisplayValueInUI(config: ControlData, value: any): boolean {
return value === "true" || value === "false";
}
}
export type SwitchControlProps = ControlProps;
export default SwitchControl;