"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportFormatSelector = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const Select_1 = require("../../components/Select");
const AdaptableContext_1 = require("../AdaptableContext");
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
const Flex_1 = require("../../components/Flex");
const ReportFormatSelector = (props) => {
    const { reportName, reportFormat, onReportFormatSelected, size = 'normal' } = props;
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const exportApi = adaptable.api.exportApi;
    const allFormats = exportApi.getAvailableSystemFormats();
    const formatItems = allFormats.map((format) => {
        return {
            label: format,
            value: format,
        };
    });
    const elementType = props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
    return (react_1.default.createElement(Flex_1.Flex, { "data-name": "report-format-selector", className: "twa:min-w-[140px] twa:flex-1" },
        react_1.default.createElement(Select_1.Select, { "aria-label": GeneralConstants_1.SELECT_REPORT_FORMAT_STRING, size: size, placeholder: GeneralConstants_1.SELECT_REPORT_FORMAT_STRING, disabled: !allFormats.length || reportName == undefined, className: `ab-${elementType}__Export__format-select twa:w-full`, options: formatItems, onChange: (format) => onReportFormatSelected(format), value: reportFormat, isClearable: true })));
};
exports.ReportFormatSelector = ReportFormatSelector;
