import React from 'react';
import { Flex } from 'rebass';
import { Select } from '../../components/Select';
import { useAdaptable } from '../AdaptableContext';
import { SELECT_REPORT_STRING } from '../../Utilities/Constants/GeneralConstants';
export const ReportNameSelector = (props) => {
    const { reportName, onReportNameSelected, size = 'normal' } = props;
    const adaptable = 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.createElement(Flex, { flex: 1, minWidth: props.viewType !== 'StatusBar' ? 160 : undefined },
        React.createElement(Select, { style: { width: '100%' }, size: size, "data-name": "report-name-selector", placeholder: SELECT_REPORT_STRING, disabled: !allReportNames.length, className: `ab-${elementType}__Export__report-select`, options: reportItems, onChange: (report) => onReportNameSelected(report), value: reportName, isClearable: true })));
};
