@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
26 lines (25 loc) • 1.6 kB
JavaScript
;
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 rebass_1 = require("rebass");
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
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(rebass_1.Flex, { "data-name": "report-format-selector", flex: 1, minWidth: 140 },
react_1.default.createElement(Select_1.Select, { "aria-label": GeneralConstants_1.SELECT_REPORT_FORMAT_STRING, style: { width: '100%' }, size: size, placeholder: GeneralConstants_1.SELECT_REPORT_FORMAT_STRING, disabled: !allFormats.length || reportName == undefined, className: `ab-${elementType}__Export__format-select`, options: formatItems, onChange: (format) => onReportFormatSelected(format), value: reportFormat, isClearable: true })));
};
exports.ReportFormatSelector = ReportFormatSelector;