"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LabelFormControl = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const InputLabel_1 = tslib_1.__importDefault(require("@material-ui/core/InputLabel"));
const FormControl_1 = require("../FormControl");
const core_1 = require("@material-ui/core");
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
const PropertyEditorText_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorText");
const PropertyEditorBoolean_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorBoolean");
const PropertyEditorInteger_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorInteger");
const DataUtilities_1 = require("@appglue/common/dist/Common/DataUtilities");
class XLabelEditUI extends react_1.default.Component {
    render() {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { editObject: this.props.editMe, propertyName: "htmlFor", label: "Label For", updateCallback: this.props.editMe.controlUpdate }), (0, jsx_runtime_1.jsx)(PropertyEditorInteger_1.PropertyEditorInteger, { editObject: this.props.editMe, propertyName: "maxLength", label: "Max Length", updateCallback: this.props.editMe.controlUpdate }), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { editObject: this.props.editMe, propertyName: "fromData", label: "From Data?", updateCallback: this.props.editMe.controlUpdate }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: this.props.editMe.fromData, children: (0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { editObject: this.props.editMe, propertyName: "valueName", label: "Value Name For Data", updateCallback: this.props.editMe.controlUpdate }) }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: !this.props.editMe.fromData, children: (0, jsx_runtime_1.jsx)(PropertyEditorText_1.PropertyEditorText, { editObject: this.props.editMe, propertyName: "text", label: "Static Text", updateCallback: this.props.editMe.controlUpdate }) })] }));
    }
}
class LabelFormControl extends FormControl_1.FormControl {
    __type = "Label";
    text = "Label Text";
    htmlFor = "html-for";
    valueName;
    fromData = false;
    maxLength = 20;
    constructor() {
        super();
        this.canFocus = false;
    }
    render() {
        const labelText = this.fromData ? (this.valueName ? this.getFormDataValue(this.valueName) : "") : this.text;
        if ((labelText || "").length > this.maxLength) {
            return ((0, jsx_runtime_1.jsx)(core_1.Tooltip, { title: labelText, children: (0, jsx_runtime_1.jsxs)(StyledLabel, { style: { width: "100%" }, htmlFor: this.htmlFor, "data-testid": "xlabel", children: [labelText.slice(0, this.maxLength), "..."] }) }));
        }
        return ((0, jsx_runtime_1.jsx)(StyledLabel, { style: { width: "100%" }, htmlFor: this.htmlFor, "data-testid": "xlabel", children: labelText }));
    }
    renderEditUI() {
        return (0, jsx_runtime_1.jsx)(XLabelEditUI, { editMe: this });
    }
    getDesignValidationIssues() {
        return [];
    }
    getRuntimeValidationIssues() {
        return [];
    }
    getAddedData() {
        return;
    }
    getStorageData() {
        let retData = super.getStorageData();
        retData = DataUtilities_1.DataUtilities.addStorageData(this, retData, "__type", "text", "htmlFor", "valueName", "fromData", "maxLength");
        return retData;
    }
    setStorageData(data) {
        super.setStorageData(data);
        DataUtilities_1.DataUtilities.setStorageData(this, data, "__type", "text", "htmlFor", "valueName", "fromData", "maxLength");
    }
}
exports.LabelFormControl = LabelFormControl;
const StyledLabel = (0, styled_components_1.default)(InputLabel_1.default) `
    && {
        //styleName: text/Inter SemiBold 12px;

        font-size: 12px;
        font-style: normal;
        font-weight: 600;
        line-height: 17px;
        letter-spacing: 0px;
        text-align: left;
        color: rgba(39, 41, 50, 0.7);
    }
`;
//# sourceMappingURL=LabelFormControl.js.map