import * as React from 'react';
import { useAdaptable } from '../../View/AdaptableContext';
import { CheckBox } from '../CheckBox';
import EditorButton from './EditorButton';
import { Flex } from '../Flex';
export const NamedQueryEditor = (props) => {
    const adaptable = useAdaptable();
    const [showColumnIds, setShowColumnIds] = React.useState(false);
    const [inlineQuery, setInlineQuery] = React.useState(false);
    return (React.createElement(Flex, { flexDirection: "column", alignItems: "flex-start", className: "twa:mt-[2px]" },
        React.createElement(CheckBox, { checked: showColumnIds, onChange: (checked) => setShowColumnIds(checked) }, "Show Column IDs"),
        React.createElement(CheckBox, { checked: inlineQuery, onChange: (checked) => setInlineQuery(checked) }, "Inline Query"),
        props.namedQueries.map((namedQuery) => (React.createElement(Flex, { key: namedQuery.Uuid, flexDirection: "column", alignItems: "flex-start", className: "twa:p-1 twa:my-2 twa:w-full twa:bg-primarylight" },
            ' ',
            React.createElement(EditorButton, { className: "twa:w-full twa:h-full twa:bg-primary twa:cursor-grab", data: inlineQuery ? namedQuery.BooleanExpression : `QUERY("${namedQuery.Name}")`, "data-name": "column", icon: "drag" },
                React.createElement(Flex, { flexDirection: "column", alignItems: "flex-start" }, namedQuery.Name)),
            React.createElement(Flex, { alignItems: "flex-start", className: "twa:p-1" }, showColumnIds
                ? namedQuery.BooleanExpression
                : adaptable.api.expressionApi.getAdaptableQueryExpressionWithColumnFriendlyNames(namedQuery)))))));
};
