UNPKG

@intuitionrobotics/thunderstorm

Version:
25 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FieldEditor = void 0; const React = require("react"); const BaseComponent_1 = require("../core/BaseComponent"); const TS_Input_1 = require("../components/TS_Input"); class FieldEditor extends BaseComponent_1.BaseComponent { constructor(props) { super(props); this.onChange = (value) => { this.props.storageKey.set(value); this.forceUpdate(); }; this.renderInput = () => { return (React.createElement(TS_Input_1.TS_Input, { id: this.props.id, key: this.props.id, type: "text", value: this.props.storageKey.get() || "", style: this.props.inputStyle, onChange: this.onChange, onAccept: this.props.onAccept, onCancel: this.props.onCancel, placeholder: this.props.placeholder, focus: this.props.isEditing })); }; this.renderLabel = () => React.createElement("div", { style: this.props.labelStyle }, this.props.value || ""); this.props.storageKey.set(this.props.value || ""); } render() { return this.props.isEditing ? this.renderInput() : this.renderLabel(); } } exports.FieldEditor = FieldEditor; //# sourceMappingURL=FieldEditor.js.map