import * as React from "react"; import { AxisInputBox } from "./axis_input_box"; import { Row, Col } from "../ui/index"; import { AxisInputBoxGroupProps, AxisInputBoxGroupState } from "./interfaces"; import { isNumber } from "lodash"; import { Vector3 } from "farmbot"; import { t } from "../i18next_wrapper"; /** Coordinate input and GO button for Move widget. */ export class AxisInputBoxGroup extends React.Component> { constructor(props: AxisInputBoxGroupProps) { super(props); this.state = {}; } change = (axis: keyof Vector3, val: number) => { this.setState({ [axis]: val }); } get vector() { const { x, y, z } = this.state; const p = this.props.position; const x2 = p.x, y2 = p.y, z2 = p.z; return { x: isNumber(x) ? x : (x2 || 0), y: isNumber(y) ? y : (y2 || 0), z: isNumber(z) ? z : (z2 || 0) }; } clicked = () => { this.props.onCommit(this.vector); this.setState({ x: undefined, y: undefined, z: undefined }); } render() { const { x, y, z } = this.state; return ; } }