"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var factory_1 = require("../../factory");
var Collapse_1 = require("../Collapse");
;
var FieldSetControl = /** @class */ (function (_super) {
    tslib_1.__extends(FieldSetControl, _super);
    function FieldSetControl(props) {
        var _this = _super.call(this, props) || this;
        _this.renderBody = _this.renderBody.bind(_this);
        return _this;
    }
    FieldSetControl.prototype.renderBody = function () {
        var _a = this.props, renderFormItems = _a.renderFormItems, controls = _a.controls, body = _a.body, collapsable = _a.collapsable, horizontal = _a.horizontal, render = _a.render, mode = _a.mode, formMode = _a.formMode, $path = _a.$path, cx = _a.classnames;
        if (!controls) {
            return render('body', body);
        }
        var props = {};
        mode && (props.mode = mode);
        typeof collapsable !== 'undefined' && (props.collapsable = collapsable);
        horizontal && (props.horizontal = horizontal);
        return (React.createElement("div", { className: cx("Form--" + (props.mode || formMode || 'normal')) }, renderFormItems({ controls: controls }, $path.replace(/^.*form\//, ''), props)));
    };
    FieldSetControl.prototype.render = function () {
        var _a = this.props, controls = _a.controls, className = _a.className, mode = _a.mode, rest = tslib_1.__rest(_a, ["controls", "className", "mode"]);
        return (React.createElement(Collapse_1.default, tslib_1.__assign({}, rest, { className: className, children: this.renderBody, wrapperComponent: "fieldset", headingComponent: "legend" })));
    };
    FieldSetControl.defaultProps = {
        headingClassName: '',
        collapsable: false
    };
    return FieldSetControl;
}(React.Component));
exports.default = FieldSetControl;
var FieldSetRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(FieldSetRenderer, _super);
    function FieldSetRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FieldSetRenderer = tslib_1.__decorate([
        factory_1.Renderer({
            test: /(^|\/)form(?:.+)?\/control\/fieldSet$/i,
            weight: -100,
            name: "fieldset"
        })
    ], FieldSetRenderer);
    return FieldSetRenderer;
}(FieldSetControl));
exports.FieldSetRenderer = FieldSetRenderer;
;
//# sourceMappingURL=./renderers/Form/FieldSet.js.map
