"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportNameSelector = 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 ReportNameSelector = (props) => {
    const { reportName, onReportNameSelected, size = 'normal' } = props;
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const exportApi = adaptable.api.exportApi;
    const allReportNames = exportApi.internalApi.getAllAvailableReportNames();
    const reportItems = allReportNames.map((report) => {
        return {
            label: report,
            value: report,
        };
    });
    const elementType = props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
    return (react_1.default.createElement(Flex_1.Flex, { "data-name": "report-name-selector", className: "twa:min-w-[160px] twa:flex-1" },
        react_1.default.createElement(Select_1.Select, { "aria-label": GeneralConstants_1.SELECT_REPORT_STRING, size: size, "data-name": "report-name-selector", placeholder: GeneralConstants_1.SELECT_REPORT_STRING, disabled: !allReportNames.length, className: `ab-${elementType}__Export__report-select twa:w-full`, options: reportItems, onChange: (report) => onReportNameSelected(report), value: reportName, isClearable: true })));
};
exports.ReportNameSelector = ReportNameSelector;
