UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

23 lines (22 loc) 1.46 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { NewDropdownButton } from '../../components/DropdownButton'; import { Icon } from '../../components/icons'; import { useAdaptable } from '../AdaptableContext'; import { ButtonExport } from '../Components/Buttons/ButtonExport'; import { cn } from '../../lib/utils'; export const ExportDestinationPicker = ({ reportName, reportFormat, viewType, }) => { const adaptable = useAdaptable(); const exportApi = adaptable.api.exportApi; const handleExport = (destination) => { exportApi.exportReport(reportName, reportFormat, destination); }; const supportedDestinations = exportApi.getSupportedExportDestinations(reportFormat); if (supportedDestinations.length === 0 || supportedDestinations.length === 1) { return (_jsx(ButtonExport, { tooltip: 'Export Report', className: cn(viewType !== 'StatusBar' ? '' : undefined, ''), onClick: () => handleExport(supportedDestinations[0]), disabled: reportName == undefined || reportFormat == undefined })); } const destinationItems = supportedDestinations.map((destination) => ({ label: destination, onClick: () => handleExport(destination), })); return (_jsx(NewDropdownButton, { "data-name": "report-export-selector", disabled: reportName == undefined || reportFormat == undefined, tooltip: "Export Report", variant: "text", items: destinationItems, children: _jsx(Icon, { name: "export" }) })); };