Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.add('Export Button for xlsx file', () => ())
.add('Export Button for csv file', () => (
export default React.memo((props: IExportButtonProps) => {
const { columns, export_columns, export_format, virtual_data, export_headers, visibleColumns, merge_duplicate_headers } = props;
const isFormatSupported = export_format === ExportFormat.Csv || export_format === ExportFormat.Xlsx;
const exportedColumns = export_columns === ExportColumns.Visible ? visibleColumns : columns;
const handleExport = async () => {
const columnID = exportedColumns.map(column => column.id);
const columnHeaders = exportedColumns.map(column => column.name);
const maxLength = getHeaderRows(columns);
const heading = (export_headers !== ExportHeaders.None) ? createHeadings(columnHeaders, maxLength) : [];
const wb = await createWorkbook(heading, virtual_data.data, columnID, export_headers, merge_duplicate_headers);
await exportWorkbook(wb, export_format);
};
return (<div></div>
sanitize(props: PropsWithDefaults): SanitizedProps {
const locale_format = this.applyDefaultToLocale(props.locale_format);
const columns = this.applyDefaultsToColumns(locale_format, props.sort_as_null, props.columns, props.editable);
const visibleColumns = this.getVisibleColumns(columns, props.hidden_columns);
let headerFormat = props.export_headers;
if (props.export_format === ExportFormat.Xlsx && R.isNil(headerFormat)) {
headerFormat = ExportHeaders.Names;
} else if (props.export_format === ExportFormat.Csv && R.isNil(headerFormat)) {
headerFormat = ExportHeaders.Ids;
}
return R.merge(props, {
columns,
export_headers: headerFormat,
fixed_columns: getFixedColumns(props.fixed_columns, props.row_deletable, props.row_selectable),
fixed_rows: getFixedRows(props.fixed_rows, props.columns, props.filter_action),
loading_state: dataLoading(props.loading_state),
locale_format,
visibleColumns
});
}