@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
127 lines (126 loc) • 7.78 kB
JavaScript
"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 Radio_1 = tslib_1.__importStar(require("../../../components/Radio"));
const renderFormatColumnSettingsSummary = (data) => {
return (React.createElement(rebass_1.Box, { padding: 2 },
React.createElement(rebass_1.Text, null,
"Cell alignment ",
React.createElement(Tag_1.Tag, null, data.CellAlignment ?? 'default')),
React.createElement(rebass_1.Text, { mt: 3 },
"Data Rows ",
React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeDataRows ? 'no' : 'yes')),
' ',
React.createElement(rebass_1.Text, { mt: 3 },
"Group Rows ",
React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeGroupRows ? 'no' : 'yes')),
React.createElement(rebass_1.Text, { mt: 3 },
"Summary Rows ",
React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeSummaryRows ? 'no' : 'yes')),
React.createElement(rebass_1.Text, { mt: 3 },
"Total Rows ",
React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeTotalRows ? 'no' : 'yes')),
React.createElement(rebass_1.Text, { mt: 3 },
"Apply on Column Groups:",
' ',
React.createElement(Tag_1.Tag, null, !data.ColumnGroupScope || data.ColumnGroupScope === 'Both'
? 'Always'
: data.ColumnGroupScope))));
};
exports.renderFormatColumnSettingsSummary = renderFormatColumnSettingsSummary;
const FormatColumnSettingsWizardSection = (props) => {
const { data } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
const onCellAlignmentSelectChanged = (CellAlignment) => {
const newData = { ...data, CellAlignment };
if (CellAlignment === null) {
delete newData.CellAlignment;
}
props.onChange(newData);
};
const onExcludeDataRowsChanged = (ExcludeDataRows) => {
props.onChange({
...data,
RowScope: {
...data.RowScope,
ExcludeDataRows,
},
});
};
const onExcludeGroupedRowsChanged = (ExcludeGroupedRows) => {
props.onChange({
...data,
RowScope: {
...data.RowScope,
ExcludeGroupRows: ExcludeGroupedRows,
},
});
};
const onExcludeSummaryRowsChanged = (ExcludeSummaryRows) => {
props.onChange({
...data,
RowScope: {
...data.RowScope,
ExcludeSummaryRows,
},
});
};
const onExcludeTotalRowsChanged = (ExcludeTotalRows) => {
props.onChange({
...data,
RowScope: {
...data.RowScope,
ExcludeTotalRows,
},
});
};
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,
data.Target === 'cell' && (React.createElement(React.Fragment, 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: data.RowScope?.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: data.RowScope?.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: data.RowScope?.ExcludeSummaryRows, onChange: onExcludeSummaryRowsChanged, mr: 2 }))),
React.createElement(FormLayout_1.FormRow, { label: "Exclude Total Rows:" },
React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
React.createElement(CheckBox_1.CheckBox, { "data-name": "exclude-total-rows-checkbox", checked: data.RowScope?.ExcludeTotalRows, onChange: onExcludeTotalRowsChanged, mr: 2 }))))),
React.createElement(FormLayout_1.FormRow, { label: "Apply on Column Group:" },
React.createElement(Radio_1.RadioGroup, { value: data.ColumnGroupScope || 'Both', name: "columnGroupScope", orientation: "horizontal", onRadioChange: (columnGroupScope) => {
props.onChange({
...data,
ColumnGroupScope: columnGroupScope,
});
} },
React.createElement(Radio_1.default, { marginLeft: 1, value: "Both" }, "Always"),
React.createElement(Radio_1.default, { marginLeft: 4, value: "Expanded" }, "Expanded"),
React.createElement(Radio_1.default, { marginLeft: 4, value: "Collapsed" }, "Collapsed"))))))));
};
exports.FormatColumnSettingsWizardSection = FormatColumnSettingsWizardSection;