"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileUploadFormControl = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
const StyledButton_1 = require("../../../CommonUI/BuildlingBlocks/StyledButton");
const UploadIcon_1 = require("../../../CommonUI/Icon/UploadIcon");
const PropertyEditorBoolean_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorBoolean");
const CommonStyled_1 = require("./CommonStyled");
const PropertyEditorInteger_1 = require("../../../CommonUI/PropertyEditing/PropertyEditorInteger");
const FileFormControl_1 = require("../FileFormControl");
const DataUtilities_1 = require("@appglue/common/dist/Common/DataUtilities");
class XFileUploadEditUI extends react_1.default.Component {
    render() {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [this.props.editMe.renderBaseDataControlEditor(), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { editObject: this.props.editMe, propertyName: "showFileName", updateCallback: this.props.editMe.controlUpdate, label: "Show File Name" }), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { editObject: this.props.editMe, propertyName: "showFileSize", updateCallback: this.props.editMe.controlUpdate, label: "Show File Size" }), (0, jsx_runtime_1.jsx)(PropertyEditorBoolean_1.PropertyEditorBoolean, { editObject: this.props.editMe, propertyName: "showPreview", updateCallback: this.props.editMe.controlUpdate, label: "Show Preview" }), (0, jsx_runtime_1.jsx)(PropertyEditorInteger_1.PropertyEditorInteger, { editObject: this.props.editMe, propertyName: "filesLimit", updateCallback: this.props.editMe.controlUpdate, label: "Files Limit" })] }));
    }
}
class FileUploadFormControl extends FileFormControl_1.FileFormControl {
    __type = "File Upload";
    render() {
        const issueData = this.getFormContext().getControlContext(this).getRuntimeIssueData();
        const issueText = issueData?.text || "";
        return ((0, jsx_runtime_1.jsxs)(UploadControlRender, { className: "UploadControl-root", children: [this.label && (0, jsx_runtime_1.jsx)(CommonStyled_1.StyledInputLabel, { children: this.label }), (0, jsx_runtime_1.jsx)(StyledButton_1.StyledButton, { variant: "contained", color: "primary", startIcon: (0, jsx_runtime_1.jsx)(UploadIcon_1.UploadIcon, {}), style: { marginBottom: "30px" }, onClick: this.openLayer, "data-testid": "btn-xFileUpload-upload", ref: this.ref, children: "Upload" }), this.renderLayerContent(), issueText && ((0, jsx_runtime_1.jsx)(CommonStyled_1.StyledFormHelperText, { error: Boolean(issueText), children: issueText ? issueText : "" }))] }));
    }
    renderEditUI() {
        return (0, jsx_runtime_1.jsx)(XFileUploadEditUI, { editMe: this });
    }
    getStorageData() {
        let retData = super.getStorageData();
        retData = DataUtilities_1.DataUtilities.addStorageData(this, retData, "__type");
        return retData;
    }
    setStorageData(data) {
        super.setStorageData(data);
        DataUtilities_1.DataUtilities.setStorageData(this, data, "__type");
    }
}
exports.FileUploadFormControl = FileUploadFormControl;
const UploadControlRender = styled_components_1.default.div `
    position: relative;
`;
//# sourceMappingURL=FileUploadFormControl.js.map