"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormatColumnSettingsWizardSection = exports.renderFormatColumnSettingsSummary = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const FormLayout_1 = tslib_1.__importStar(require("../../../components/FormLayout"));
const CheckBox_1 = require("../../../components/CheckBox");
const Tabs_1 = require("../../../components/Tabs");
const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
const Tag_1 = require("../../../components/Tag");
const ToggleGroup_1 = require("../../../components/Toggle/ToggleGroup");
const Toggle_1 = require("../../../components/Toggle/Toggle");
const renderFormatColumnSettingsSummary = (data) => {
    var _a, _b, _c, _d;
    return (React.createElement(rebass_1.Box, { padding: 2 },
        React.createElement(rebass_1.Text, null,
            "Cell alignment ",
            React.createElement(Tag_1.Tag, null, (_a = data.CellAlignment) !== null && _a !== void 0 ? _a : 'default')),
        React.createElement(rebass_1.Text, { mt: 3 },
            "Data Rows ",
            React.createElement(Tag_1.Tag, null, ((_b = data.RowScope) === null || _b === void 0 ? void 0 : _b.ExcludeDataRows) ? 'no' : 'yes')),
        ' ',
        React.createElement(rebass_1.Text, { mt: 3 },
            "Group Rows ",
            React.createElement(Tag_1.Tag, null, ((_c = data.RowScope) === null || _c === void 0 ? void 0 : _c.ExcludeGroupRows) ? 'no' : 'yes')),
        React.createElement(rebass_1.Text, { mt: 3 },
            "Summary Rows ",
            React.createElement(Tag_1.Tag, null, ((_d = data.RowScope) === null || _d === void 0 ? void 0 : _d.ExcludeSummaryRows) ? 'no' : 'yes'))));
};
exports.renderFormatColumnSettingsSummary = renderFormatColumnSettingsSummary;
const FormatColumnSettingsWizardSection = (props) => {
    var _a, _b, _c;
    const { data } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
    const onCellAlignmentSelectChanged = (CellAlignment) => {
        const newData = Object.assign(Object.assign({}, data), { CellAlignment });
        if (CellAlignment === null) {
            delete newData.CellAlignment;
        }
        props.onChange(newData);
    };
    const onExcludeDataRowsChanged = (ExcludeDataRows) => {
        props.onChange(Object.assign(Object.assign({}, data), { RowScope: Object.assign(Object.assign({}, data.RowScope), { ExcludeDataRows }) }));
    };
    const onExcludeGroupedRowsChanged = (ExcludeGroupedRows) => {
        props.onChange(Object.assign(Object.assign({}, data), { RowScope: Object.assign(Object.assign({}, data.RowScope), { ExcludeGroupRows: ExcludeGroupedRows }) }));
    };
    const onExcludeSummaryRowsChanged = (ExcludeSummaryRows) => {
        props.onChange(Object.assign(Object.assign({}, data), { RowScope: Object.assign(Object.assign({}, data.RowScope), { ExcludeSummaryRows }) }));
    };
    return (React.createElement(Tabs_1.Tabs, null,
        React.createElement(Tabs_1.Tabs.Tab, null, "Settings"),
        React.createElement(Tabs_1.Tabs.Content, null,
            React.createElement(rebass_1.Flex, { flexDirection: "row" },
                React.createElement(FormLayout_1.default, null,
                    React.createElement(FormLayout_1.FormRow, { label: "Cell Alignment" },
                        React.createElement(ToggleGroup_1.ToggleGroup, null,
                            React.createElement(Toggle_1.Toggle, { icon: "align-left", pressed: data.CellAlignment === 'Left', onPressedChange: (pressed) => pressed
                                    ? onCellAlignmentSelectChanged('Left')
                                    : onCellAlignmentSelectChanged(null) }),
                            React.createElement(Toggle_1.Toggle, { icon: "align-center", pressed: data.CellAlignment === 'Center', onPressedChange: (pressed) => pressed
                                    ? onCellAlignmentSelectChanged('Center')
                                    : onCellAlignmentSelectChanged(null) }),
                            React.createElement(Toggle_1.Toggle, { icon: "align-right", pressed: data.CellAlignment === 'Right', onPressedChange: (pressed) => pressed
                                    ? onCellAlignmentSelectChanged('Right')
                                    : onCellAlignmentSelectChanged(null) }))),
                    React.createElement(FormLayout_1.FormRow, { label: "Exclude Data Rows:" },
                        React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
                            React.createElement(CheckBox_1.CheckBox, { "data-name": "exclude-data-rows-checkbox", checked: (_a = data.RowScope) === null || _a === void 0 ? void 0 : _a.ExcludeDataRows, onChange: onExcludeDataRowsChanged, mr: 2 }))),
                    React.createElement(FormLayout_1.FormRow, { label: "Exclude Group Rows:" },
                        React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
                            React.createElement(CheckBox_1.CheckBox, { "data-name": "exclude-grouped-rows-checkbox", checked: (_b = data.RowScope) === null || _b === void 0 ? void 0 : _b.ExcludeGroupRows, onChange: onExcludeGroupedRowsChanged, mr: 2 }))),
                    React.createElement(FormLayout_1.FormRow, { label: "Exclude Row Summaries:" },
                        React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
                            React.createElement(CheckBox_1.CheckBox, { "data-name": "exclude-summary-rows-checkbox", checked: (_c = data.RowScope) === null || _c === void 0 ? void 0 : _c.ExcludeSummaryRows, onChange: onExcludeSummaryRowsChanged, mr: 2 }))))))));
};
exports.FormatColumnSettingsWizardSection = FormatColumnSettingsWizardSection;
