UNPKG

@adaptabletools/adaptable-cjs

Version:

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

28 lines (27 loc) 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExportDestinationPicker = void 0; const tslib_1 = require("tslib"); const react_1 = tslib_1.__importDefault(require("react")); const DropdownButton_1 = tslib_1.__importDefault(require("../../components/DropdownButton")); const icons_1 = require("../../components/icons"); const AdaptableContext_1 = require("../AdaptableContext"); const ButtonExport_1 = require("../Components/Buttons/ButtonExport"); const ExportDestinationPicker = ({ reportName, reportFormat, viewType, }) => { const adaptable = (0, AdaptableContext_1.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 (react_1.default.createElement(ButtonExport_1.ButtonExport, { marginRight: viewType !== 'StatusBar' ? 20 : undefined, paddingRight: 0, onClick: () => handleExport(supportedDestinations[0]), tooltip: "Export Report", disabled: reportName == undefined || reportFormat == undefined })); } const destinationItems = supportedDestinations.map((destination) => ({ label: destination, onClick: () => handleExport(destination), })); return (react_1.default.createElement(DropdownButton_1.default, { "data-name": "report-export-selector", disabled: reportName == undefined || reportFormat == undefined, columns: ['label'], tooltip: "Export Report", variant: "text", items: destinationItems }, react_1.default.createElement(icons_1.Icon, { name: "export" }))); }; exports.ExportDestinationPicker = ExportDestinationPicker;