import * as React from 'react';
import FormLayout, { FormRow } from '../../../components/FormLayout';
import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableWizard';
import { Tag } from '../../../components/Tag';
import Radio, { RadioGroup } from '../../../components/Radio';
import { Box, Flex } from '../../../components/Flex';
import { Tabs } from '../../../components/Tabs';
import Input from '../../../components/Input';
import { TypeRadio } from '../../Wizard/TypeRadio';
export const renderFormatColumnSettingsSummary = (data) => {
    return (React.createElement(Box, { className: "twa:p-2" },
        React.createElement(Box, { className: "twa:mt-3" },
            "Name ",
            React.createElement(Tag, null, data.Name)),
        React.createElement(Box, { className: "twa:mt-3" },
            "Target",
            ' ',
            React.createElement(Tag, null, !data.Target || data.Target === 'cell' ? 'Column Cells' : 'Column Header')),
        ' ',
        React.createElement(Box, { className: "twa:mt-3" },
            "Apply on Column Groups:",
            ' ',
            React.createElement(Tag, null, !data.ColumnGroupScope || data.ColumnGroupScope === 'Both'
                ? 'Always'
                : data.ColumnGroupScope))));
};
export const FormatColumnSettingsWizardSection = (props) => {
    const { data, api } = useOnePageAdaptableWizardContext();
    const currentTarget = data.Target ? data.Target : 'cell';
    const handleTargetChange = (target) => {
        // Update the formatColumn object
        props.onChange({
            ...data,
            Target: target,
        });
    };
    const onNameChange = (event) => {
        props.onChange({
            ...data,
            Name: event.target.value,
        });
    };
    const behaviourSpellingVariant = api.internalApi.getCorrectEnglishVariant('Behaviour');
    return (React.createElement(Flex, { flexDirection: "column", style: { height: '100%' } },
        React.createElement(Tabs, { className: "twa:mb-3" },
            React.createElement(Tabs.Tab, null, "Settings"),
            React.createElement(Tabs.Content, null,
                React.createElement(Flex, { flexDirection: "row" },
                    React.createElement(FormLayout, { className: "twa:max-w-[300px] twa:w-full" },
                        React.createElement(FormRow, { label: "Name" },
                            React.createElement(Input, { className: "twa:w-full", "data-name": "format-column-name", onChange: onNameChange, value: data?.Name ?? '' })))))),
        React.createElement(Tabs, { className: "twa:mb-3" },
            React.createElement(Tabs.Tab, null, "Target"),
            React.createElement(Tabs.Content, null,
                React.createElement(Flex, { flexDirection: "column" },
                    React.createElement(TypeRadio, { "data-name": "target-column-cell", text: 'Column Cells', description: "Column Cells are styled and formatted", checked: currentTarget === 'cell', onClick: () => handleTargetChange('cell') }),
                    React.createElement(TypeRadio, { "data-name": "target-column-header", text: 'Column Header', description: "The Column Header is styled (Note: Conditions are not available for Column Headers)", checked: currentTarget === 'columnHeader', onClick: () => handleTargetChange('columnHeader') })))),
        React.createElement(Tabs, null,
            React.createElement(Tabs.Tab, null,
                "Column Group ",
                behaviourSpellingVariant,
                " "),
            React.createElement(Tabs.Content, null,
                React.createElement(Flex, { flexDirection: "row" },
                    React.createElement(FormLayout, null,
                        React.createElement(FormRow, { label: "Apply on Column Group:" },
                            React.createElement(RadioGroup, { value: data.ColumnGroupScope || 'Both', name: "columnGroupScope", orientation: "horizontal", onRadioChange: (columnGroupScope) => {
                                    props.onChange({
                                        ...data,
                                        ColumnGroupScope: columnGroupScope,
                                    });
                                } },
                                React.createElement(Radio, { className: "twa:ml-1", value: "Both" }, "Always"),
                                React.createElement(Radio, { className: "twa:ml-4", value: "Expanded" }, "When Expanded"),
                                React.createElement(Radio, { className: "twa:ml-4", value: "Collapsed" }, "When Collapsed")))))))));
};
