"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XBaseContainer = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const FormControl_1 = require("../Controls/FormControl");
const FormDesignConstants_1 = require("../Utilities/FormDesignConstants");
const PropertyEditorInteger_1 = require("../../CommonUI/PropertyEditing/PropertyEditorInteger");
const PropertyEditorSelect_1 = require("../../CommonUI/PropertyEditing/PropertyEditorSelect");
const core_1 = require("@material-ui/core");
const PropertyEditorColor_1 = require("../../CommonUI/PropertyEditing/PropertyEditorColor");
const DefaultOnOff_1 = require("../Utilities/DefaultOnOff");
const PropertyEditorOptionWithButtonGroup_1 = require("../../CommonUI/PropertyEditing/PropertyEditorOptionWithButtonGroup");
const EmptyContainer_1 = require("../Builder/EmptyContainer");
const MovingIcon_1 = require("../../CommonUI/Icon/MovingIcon");
const CommonStyled_1 = require("../Controls/Web/CommonStyled");
const DataUtilities_1 = require("@appglue/common/dist/Common/DataUtilities");
class XBaseContainer extends FormControl_1.FormControl {
    overrideFormBorderSettings = DefaultOnOff_1.DefaultOnOff.DEFAULT;
    showContainerBorder;
    containerBorderType;
    containerBorderRadius;
    containerBorderWidth;
    containerBorderStyle;
    containerBorderColor;
    containerBackgroundColor;
    getStorageData() {
        let d = super.getStorageData();
        return DataUtilities_1.DataUtilities.addStorageData(this, d, "overrideFormBorderSettings", "showContainerBorder", "containerBorderType", "containerBorderRadius", "containerBorderWidth", "containerBorderStyle", "containerBorderColor", "containerBackgroundColor");
    }
    setStorageData(data) {
        super.setStorageData(data);
        DataUtilities_1.DataUtilities.setStorageData(this, data, "overrideFormBorderSettings", "showContainerBorder", "containerBorderType", "containerBorderRadius", "containerBorderWidth", "containerBorderStyle", "containerBorderColor", "containerBackgroundColor");
    }
    getDesignValidationIssues() {
        return [];
    }
    getRuntimeValidationIssues() {
        return [];
    }
    getAddedData() {
        return;
    }
    renderEmptyControlDiv(colGap, message) {
        return ((0, jsx_runtime_1.jsxs)(EmptyContainer_1.EmptyContainer, { colGap: colGap, children: [(0, jsx_runtime_1.jsx)("span", { children: `${message || "Drag controls from toolbox."}` }), (0, jsx_runtime_1.jsxs)(EmptyContainer_1.ControlDiv, { children: ["Control ", (0, jsx_runtime_1.jsx)(MovingIcon_1.MovingIcon, {})] })] }));
    }
    renderBorderConfigUI() {
        return ((0, jsx_runtime_1.jsxs)(CommonStyled_1.ChildFullWidthDiv, { children: [(0, jsx_runtime_1.jsx)(PropertyEditorOptionWithButtonGroup_1.PropertyEditorOptionWithButtonGroup, { editObject: this, label: "Override Border Settings", propertyName: "overrideFormBorderSettings", updateCallback: this.controlUpdate }), (0, jsx_runtime_1.jsx)(core_1.Collapse, { in: this.overrideFormBorderSettings === DefaultOnOff_1.DefaultOnOff.On, children: (0, jsx_runtime_1.jsxs)(CommonStyled_1.ChildFullWidthDiv, { children: [(0, jsx_runtime_1.jsx)(PropertyEditorInteger_1.PropertyEditorInteger, { editObject: this, label: "Border Width", propertyName: "containerBorderWidth", updateCallback: this.controlUpdate, parentDefaultValue: this.getFormContext()?.form.defaultContainerBorderWidth }), (0, jsx_runtime_1.jsx)(PropertyEditorInteger_1.PropertyEditorInteger, { editObject: this, label: "Border Radius", propertyName: "containerBorderRadius", updateCallback: this.controlUpdate, parentDefaultValue: this.getFormContext()?.form?.defaultContainerBorderRadius }), (0, jsx_runtime_1.jsx)(PropertyEditorColor_1.PropertyEditorColor, { editObject: this, label: "Border Color", propertyName: "containerBorderColor", updateCallback: this.controlUpdate, parentDefaultValue: this.getFormContext()?.form?.defaultContainerBorderColor }), (0, jsx_runtime_1.jsx)(PropertyEditorSelect_1.PropertyEditorSelect, { editObject: this, label: "Border Style", propertyName: "containerBorderStyle", updateCallback: this.controlUpdate, options: FormDesignConstants_1.FormDesignConstants.BORDER_STYLES, parentDefaultValue: this.getFormContext()?.form?.defaultContainerBorderStyle })] }) })] }));
    }
    hasOwnBorder() {
        return this.overrideFormBorderSettings === DefaultOnOff_1.DefaultOnOff.On;
    }
    hasBorder() {
        return (this.hasOwnBorder() ||
            (this.overrideFormBorderSettings === DefaultOnOff_1.DefaultOnOff.DEFAULT &&
                this.getFormContext()?.form?.defaultShowContainerBorder));
    }
    borderColor() {
        return ((this.hasOwnBorder() && this.containerBorderColor) ||
            this.getFormContext()?.form?.defaultContainerBorderColor);
    }
    borderStyle() {
        return ((this.hasOwnBorder() && this.containerBorderStyle) ||
            this.getFormContext()?.form?.defaultContainerBorderStyle);
    }
    borderWidth() {
        return ((this.hasOwnBorder() && this.containerBorderWidth) ||
            this.getFormContext()?.form?.defaultContainerBorderWidth);
    }
    borderRadius() {
        return ((this.hasOwnBorder() && this.containerBorderRadius) ||
            this.getFormContext()?.form?.defaultContainerBorderRadius);
    }
    backgroundColor() {
        return this.containerBackgroundColor || this.getFormContext()?.form?.defaultContainerBackgroundColor;
    }
    // ----- Overrides to set contexts ----
    setFormContext(value) {
        if (!value)
            return;
        super.setFormContext(value);
        let controls = this.getControls();
        if (controls) {
            for (let control of controls) {
                // set edit context first
                control.setFormContext(value);
            }
        }
    }
}
exports.XBaseContainer = XBaseContainer;
//# sourceMappingURL=XBaseContainer.js.map