UNPKG

@intuitionrobotics/thunderstorm

Version:
22 lines 1.08 kB
import * as React from 'react'; import { StorageKey } from '../modules/StorageModule.js'; import { BaseComponent } from '../core/BaseComponent.js'; import { TS_Input } from '../components/TS_Input.js'; export class FieldEditor extends BaseComponent { constructor(props) { super(props); this.props.storageKey.set(this.props.value || ""); } onChange = (value) => { this.props.storageKey.set(value); this.forceUpdate(); }; renderInput = () => { return (React.createElement(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 })); }; renderLabel = () => React.createElement("div", { style: this.props.labelStyle }, this.props.value || ""); render() { return this.props.isEditing ? this.renderInput() : this.renderLabel(); } } //# sourceMappingURL=FieldEditor.js.map