import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { XBaseControl } from "../Controls/XBaseControl";
import { FormDesignConstants } from "../FormDesignConstants";
import { PropertyEditorInteger } from "../../CommonUI/PropertyEditing/PropertyEditorInteger";
import { PropertyEditorSelect } from "../../CommonUI/PropertyEditing/PropertyEditorSelect";
import { Collapse } from "@material-ui/core";
import { PropertyEditorColor } from "../../CommonUI/PropertyEditing/PropertyEditorColor";
import { DefaultOnOff } from "../Utilities/DefaultOnOff";
import { PropertyEditorOptionWithButtonGroup } from "../../CommonUI/PropertyEditing/PropertyEditorOptionWithButtonGroup";
import { EmptyContainer, ControlDiv } from "../Components/EmptyContainer";
import { MovingIcon } from "../../CommonUI/Icon/MovingIcon";
import { ChildFullWidthDiv } from "../Controls/XCommonStyled";
export class XBaseContainer extends XBaseControl {
    constructor() {
        super(...arguments);
        this.overrideFormBorderSettings = DefaultOnOff.DEFAULT;
    }
    getDesignValidationIssues() {
        return [];
    }
    getRuntimeValidationIssues() {
        return [];
    }
    getAddedData() {
        return;
    }
    renderEmptyControlDiv(colGap, message) {
        return (_jsxs(EmptyContainer, Object.assign({ colGap: colGap }, { children: [_jsx("span", { children: `${message || "Drag controls from toolbox."}` }, void 0),
                _jsxs(ControlDiv, { children: ["Control ", _jsx(MovingIcon, {}, void 0)] }, void 0)] }), void 0));
    }
    renderBorderConfigUI() {
        var _a, _b, _c, _d, _e, _f, _g;
        return (_jsxs(ChildFullWidthDiv, { children: [_jsx(PropertyEditorOptionWithButtonGroup, { editObject: this, label: "Override Border Settings", propertyName: "overrideFormBorderSettings", updateCallback: this.controlUpdate }, void 0),
                _jsx(Collapse, Object.assign({ in: this.overrideFormBorderSettings === DefaultOnOff.On }, { children: _jsxs(ChildFullWidthDiv, { children: [_jsx(PropertyEditorInteger, { editObject: this, label: "Border Width", propertyName: "containerBorderWidth", updateCallback: this.controlUpdate, parentDefaultValue: (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form.defaultContainerBorderWidth }, void 0),
                            _jsx(PropertyEditorInteger, { editObject: this, label: "Border Radius", propertyName: "containerBorderRadius", updateCallback: this.controlUpdate, parentDefaultValue: (_c = (_b = this.getFormContext()) === null || _b === void 0 ? void 0 : _b.form) === null || _c === void 0 ? void 0 : _c.defaultContainerBorderRadius }, void 0),
                            _jsx(PropertyEditorColor, { editObject: this, label: "Border Color", propertyName: "containerBorderColor", updateCallback: this.controlUpdate, parentDefaultValue: (_e = (_d = this.getFormContext()) === null || _d === void 0 ? void 0 : _d.form) === null || _e === void 0 ? void 0 : _e.defaultContainerBorderColor }, void 0),
                            _jsx(PropertyEditorSelect, { editObject: this, label: "Border Style", propertyName: "containerBorderStyle", updateCallback: this.controlUpdate, options: FormDesignConstants.BORDER_STYLES, parentDefaultValue: (_g = (_f = this.getFormContext()) === null || _f === void 0 ? void 0 : _f.form) === null || _g === void 0 ? void 0 : _g.defaultContainerBorderStyle }, void 0)] }, void 0) }), void 0)] }, void 0));
    }
    hasOwnBorder() {
        return this.overrideFormBorderSettings === DefaultOnOff.On;
    }
    hasBorder() {
        var _a, _b;
        return (this.hasOwnBorder() ||
            (this.overrideFormBorderSettings === DefaultOnOff.DEFAULT && ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.defaultShowContainerBorder)));
    }
    borderColor() {
        var _a, _b;
        return ((this.hasOwnBorder() && this.containerBorderColor) || ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.defaultContainerBorderColor));
    }
    borderStyle() {
        var _a, _b;
        return ((this.hasOwnBorder() && this.containerBorderStyle) || ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.defaultContainerBorderStyle));
    }
    borderWidth() {
        var _a, _b;
        return ((this.hasOwnBorder() && this.containerBorderWidth) || ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.defaultContainerBorderWidth));
    }
    borderRadius() {
        var _a, _b;
        return ((this.hasOwnBorder() && this.containerBorderRadius) || ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.defaultContainerBorderRadius));
    }
    backgroundColor() {
        var _a, _b;
        return this.containerBackgroundColor || ((_b = (_a = this.getFormContext()) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.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);
            }
        }
    }
}
//# sourceMappingURL=XBaseContainer.js.map