"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageFormControl = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const PropertyEditorText_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorText");
const PropertyEditorBoolean_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorBoolean");
const core_1 = require("@material-ui/core");
const TextEntryFormControl_1 = require("../TextEntryFormControl");
const PropertyEditorInteger_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorInteger");
const DataUtilities_1 = require("@appglue/common/dist/Common/DataUtilities");
class ImageFormControl extends TextEntryFormControl_1.TextEntryFormControl {
    __type = "Image";
    link;
    staticImageLink = true;
    tooltip = "";
    getAddedData() {
        return;
    }
    render() {
        const customWidth = this.fullWidth ? "100%" : this.width ? `${this.width}px` : "200px";
        let imageSource = this.staticImageLink
            ? this.link
                ? this.link
                : ""
            : this.valueName
                ? this.getFormDataValue(this.valueName)
                : "";
        return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(core_1.Tooltip, { title: this.tooltip, children: (0, jsx_runtime_1.jsx)("input", { type: "image", src: imageSource, width: customWidth, "data-testid": "image", value: this.valueName ? this.getFormDataValue(this.valueName) : "", alt: "" }) }) }));
    }
    renderEditUI() {
        return (0, jsx_runtime_1.jsx)(XImageFieldEditUi, { editMe: this });
    }
    getStorageData() {
        let retData = super.getStorageData();
        retData = DataUtilities_1.DataUtilities.addStorageData(this, retData, "__type", "link", "staticImageLink", "tooltip");
        return retData;
    }
    setStorageData(data) {
        super.setStorageData(data);
        DataUtilities_1.DataUtilities.setStorageData(this, data, "__type", "link", "staticImageLink", "tooltip");
    }
}
exports.ImageFormControl = ImageFormControl;
function XImageFieldEditUi(props) {
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { label: "Tooltip", updateCallback: props.editMe.controlUpdate, propertyName: "tooltip", editObject: props.editMe }), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { label: "Static Image Link", updateCallback: props.editMe.controlUpdate, propertyName: "staticImageLink", editObject: props.editMe }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: props.editMe.staticImageLink, children: (0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { label: "Static Image Link", updateCallback: props.editMe.controlUpdate, propertyName: "link", editObject: props.editMe }) }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: !props.editMe.staticImageLink, children: (0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { editObject: props.editMe, label: "Value Name", propertyName: "valueName", updateCallback: props.editMe.controlUpdate }) }), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { label: "Full Width", updateCallback: props.editMe.controlUpdate, propertyName: "fullWidth", editObject: props.editMe }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: !props.editMe.fullWidth, children: (0, jsx_runtime_1.jsx)(PropertyEditorInteger_1.PropertyEditorInteger, { label: "Width", updateCallback: props.editMe.controlUpdate, propertyName: "width", editObject: props.editMe }) })] }));
}
//# sourceMappingURL=ImageFormControl.js.map