import {ChangeEventHandler} from "react"; import {BPComponentProps, UiConfigRendererContextType} from "./BPComponent"; import {Switch} from "@blueprintjs/core"; import {BPInputComponent} from "./BPInputComponent"; export class BPToggleInputComponent extends BPInputComponent { constructor(props: BPComponentProps, context: UiConfigRendererContextType) { super(props, context, {value: false, label: 'Input'}); } private _onChange: ChangeEventHandler = (e) => { this.setValue(e.target.checked); // todo: set loading while this promise is happening. } renderInput() { return ( {this.state.label})} onChange={this._onChange} inline={false} large={false} className="switch"/> ) } render() { return !this.state.hidden ? (
{this.renderInput()}
) : null } }