"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyEditorText = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const TextField_1 = tslib_1.__importDefault(require("@material-ui/core/TextField"));
const PropertyEditorText = (props) => {
    const onChange = (event) => {
        if (props.parentDefaultValue && event.target.value === props.parentDefaultValue) {
            Reflect.set(props.editObject, props.propertyName, null);
        }
        else {
            Reflect.set(props.editObject, props.propertyName, event.target.value);
        }
        props.updateCallback();
    };
    const onKeyDown = (event) => {
        event.stopPropagation();
    };
    const value = Reflect.get(props.editObject, props.propertyName) ?? props.parentDefaultValue;
    return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(TextField_1.default, { "data-testid": `property-${props.propertyName}-text`, error: Boolean(props.issue), value: value || "", label: props.label, onChange: onChange, onKeyDown: onKeyDown, variant: "outlined", fullWidth: true, autoFocus: props.autoFocus, helperText: props.issue ? props.issue.issue : props.hint }) }));
};
exports.PropertyEditorText = PropertyEditorText;
//# sourceMappingURL=PropertyEditorText.js.map